All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.account.resources.content.my-resources-page.PermissionSelect.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"PermissionSelect.js","names":["React","Select","SelectOption","SelectVariant","Msg","ScopeValue","constructor","value","_defineProperty","toString","displayName","name","compareTo","selectOption","PermissionSelect","Component","props","event","selected","state","onSelect","includes","setState","prevState","filter","item","map","sv","isExpanded","values","s","scopes","option","index","createElement","key","find","render","titleId","id","hidden","msgKey","maxHeight","direction","variant","typeaheadMulti","typeAheadAriaLabel","localize","onToggle","onClear","clearSelection","selections","isOpen","placeholderText","menuAppendTo"],"sources":["../../../src/app/content/my-resources-page/PermissionSelect.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Select, SelectOption, SelectVariant, SelectOptionObject } from '@patternfly/react-core';\nimport { Scope } from './resource-model';\nimport { Msg } from '../../widgets/Msg';\n\ninterface PermissionSelectState {\n  selected: ScopeValue[];\n  isExpanded: boolean;\n  scopes: JSX.Element[];\n}\n\ninterface PermissionSelectProps {\n  scopes: Scope[];\n  selected?: Scope[];\n  direction?: 'up' | 'down';\n  onSelect: (selected: Scope[]) => void;\n}\n\nclass ScopeValue implements SelectOptionObject {\n  value: Scope;\n  constructor(value: Scope) {\n    this.value = value;\n  }\n\n  toString() {\n    return this.value.displayName ? this.value.displayName : this.value.name;\n  }\n\n  compareTo(selectOption: Scope): boolean {\n    return selectOption.name === this.value.name;\n  }\n}\n\nexport class PermissionSelect extends React.Component {\n  constructor(props: PermissionSelectProps) {\n    super(props);\n\n    let values: ScopeValue[] = [];\n    if (this.props.selected) {\n      values = this.props.selected!.map(s => new ScopeValue(s))\n    }\n\n    this.state = {\n      isExpanded: false,\n      selected: values,\n      scopes: this.props.scopes.map((option, index) => (\n         s.compareTo(option)) || new ScopeValue(option)} />\n      ))\n    };\n  }\n\n  private onSelect = (event: React.MouseEvent | React.ChangeEvent, value: string | SelectOptionObject): void => {\n    const { selected } = this.state;\n    const { onSelect } = this.props;\n\n    if (!(value instanceof ScopeValue)) {\n      return;\n    }\n\n    if (selected.includes(value)) {\n      this.setState(\n        prevState => ({ selected: prevState.selected.filter(item => item !== value) }),\n        () => onSelect(this.state.selected.map(sv => sv.value))\n      );\n    } else {\n      this.setState(\n        prevState => ({ selected: [...prevState.selected, value] }),\n        () => onSelect(this.state.selected.map(sv => sv.value))\n      );\n    }\n  }\n\n  private onToggle = (isExpanded: boolean) => {\n    this.setState({\n      isExpanded\n    });\n  }\n\n  private clearSelection = () => {\n    this.setState({\n      selected: [],\n      isExpanded: false\n    });\n    this.props.onSelect([]);\n  };\n\n  render() {\n    const { isExpanded, selected } = this.state;\n    const titleId = 'permission-id';\n\n    return (\n      
\n \n \n {this.state.scopes}\n \n
\n );\n }\n}\n"],"mappings":";;;AAAA,OAAO,KAAKA,KAAK;AAEjB,SAASC,MAAM,EAAEC,YAAY,EAAEC,aAAa;AAE5C,SAASC,GAAG;AAeZ,MAAMC,UAAU,CAA+B;EAE7CC,WAAWA,CAACC,KAAY,EAAE;IAAAC,eAAA;IACxB,IAAI,CAACD,KAAK,GAAGA,KAAK;EACpB;EAEAE,QAAQA,CAAA,EAAG;IACT,OAAO,IAAI,CAACF,KAAK,CAACG,WAAW,GAAG,IAAI,CAACH,KAAK,CAACG,WAAW,GAAG,IAAI,CAACH,KAAK,CAACI,IAAI;EAC1E;EAEAC,SAASA,CAACC,YAAmB,EAAW;IACtC,OAAOA,YAAY,CAACF,IAAI,KAAK,IAAI,CAACJ,KAAK,CAACI,IAAI;EAC9C;AACF;AAEA,OAAO,MAAMG,gBAAgB,SAASd,KAAK,CAACe,SAAS,CAA+C;EAClGT,WAAWA,CAACU,KAA4B,EAAE;IACxC,KAAK,CAACA,KAAK,CAAC;IAACR,eAAA,mBAgBI,CAACS,KAA2C,EAAEV,KAAkC,KAAW;MAC5G,MAAM;QAAEW;MAAS,CAAC,GAAG,IAAI,CAACC,KAAK;MAC/B,MAAM;QAAEC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