@itwin/components-react 4.10.0-dev.1 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/lib/cjs/components-react/converters/DateTimeTypeConverter.js +1 -1
  3. package/lib/cjs/components-react/converters/DateTimeTypeConverter.js.map +1 -1
  4. package/lib/cjs/components-react/converters/PointTypeConverter.d.ts.map +1 -1
  5. package/lib/cjs/components-react/converters/PointTypeConverter.js +2 -0
  6. package/lib/cjs/components-react/converters/PointTypeConverter.js.map +1 -1
  7. package/lib/cjs/components-react/converters/TypeConverter.d.ts.map +1 -1
  8. package/lib/cjs/components-react/converters/TypeConverter.js +1 -0
  9. package/lib/cjs/components-react/converters/TypeConverter.js.map +1 -1
  10. package/lib/cjs/components-react/datepicker/DatePicker.js +5 -5
  11. package/lib/cjs/components-react/datepicker/DatePicker.js.map +1 -1
  12. package/lib/cjs/components-react/datepicker/TimeField.d.ts.map +1 -1
  13. package/lib/cjs/components-react/datepicker/TimeField.js +21 -18
  14. package/lib/cjs/components-react/datepicker/TimeField.js.map +1 -1
  15. package/lib/cjs/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  16. package/lib/cjs/components-react/editors/CustomNumberEditor.js +6 -5
  17. package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
  18. package/lib/cjs/components-react/editors/EditorContainer.js +3 -3
  19. package/lib/cjs/components-react/editors/EditorContainer.js.map +1 -1
  20. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js +1 -1
  21. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  22. package/lib/cjs/components-react/editors/IconEditor.d.ts.map +1 -1
  23. package/lib/cjs/components-react/editors/IconEditor.js +1 -1
  24. package/lib/cjs/components-react/editors/IconEditor.js.map +1 -1
  25. package/lib/cjs/components-react/editors/ImageCheckBoxEditor.js +1 -1
  26. package/lib/cjs/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
  27. package/lib/cjs/components-react/editors/NumericInputEditor.js +2 -2
  28. package/lib/cjs/components-react/editors/NumericInputEditor.js.map +1 -1
  29. package/lib/cjs/components-react/editors/PopupButton.js +2 -2
  30. package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
  31. package/lib/cjs/components-react/editors/SliderEditor.js +1 -1
  32. package/lib/cjs/components-react/editors/SliderEditor.js.map +1 -1
  33. package/lib/cjs/components-react/editors/TextEditor.js +2 -2
  34. package/lib/cjs/components-react/editors/TextEditor.js.map +1 -1
  35. package/lib/cjs/components-react/editors/TextareaEditor.js +2 -2
  36. package/lib/cjs/components-react/editors/TextareaEditor.js.map +1 -1
  37. package/lib/cjs/components-react/filter-builder/Operators.js +13 -13
  38. package/lib/cjs/components-react/filter-builder/Operators.js.map +1 -1
  39. package/lib/cjs/components-react/filtering/FilteringInput.js +1 -1
  40. package/lib/cjs/components-react/filtering/FilteringInput.js.map +1 -1
  41. package/lib/cjs/components-react/filtering/ResultSelector.js +1 -1
  42. package/lib/cjs/components-react/filtering/ResultSelector.js.map +1 -1
  43. package/lib/cjs/components-react/inputs/ParsedInput.js +2 -2
  44. package/lib/cjs/components-react/inputs/ParsedInput.js.map +1 -1
  45. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -1
  46. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  47. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -1
  48. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  49. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js +1 -1
  50. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  51. package/lib/esm/components-react/converters/DateTimeTypeConverter.js +1 -1
  52. package/lib/esm/components-react/converters/DateTimeTypeConverter.js.map +1 -1
  53. package/lib/esm/components-react/converters/PointTypeConverter.d.ts.map +1 -1
  54. package/lib/esm/components-react/converters/PointTypeConverter.js +2 -0
  55. package/lib/esm/components-react/converters/PointTypeConverter.js.map +1 -1
  56. package/lib/esm/components-react/converters/TypeConverter.d.ts.map +1 -1
  57. package/lib/esm/components-react/converters/TypeConverter.js +1 -0
  58. package/lib/esm/components-react/converters/TypeConverter.js.map +1 -1
  59. package/lib/esm/components-react/datepicker/DatePicker.js +5 -5
  60. package/lib/esm/components-react/datepicker/DatePicker.js.map +1 -1
  61. package/lib/esm/components-react/datepicker/TimeField.d.ts.map +1 -1
  62. package/lib/esm/components-react/datepicker/TimeField.js +21 -18
  63. package/lib/esm/components-react/datepicker/TimeField.js.map +1 -1
  64. package/lib/esm/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  65. package/lib/esm/components-react/editors/CustomNumberEditor.js +6 -5
  66. package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
  67. package/lib/esm/components-react/editors/EditorContainer.js +3 -3
  68. package/lib/esm/components-react/editors/EditorContainer.js.map +1 -1
  69. package/lib/esm/components-react/editors/EnumButtonGroupEditor.js +1 -1
  70. package/lib/esm/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  71. package/lib/esm/components-react/editors/IconEditor.d.ts.map +1 -1
  72. package/lib/esm/components-react/editors/IconEditor.js +1 -1
  73. package/lib/esm/components-react/editors/IconEditor.js.map +1 -1
  74. package/lib/esm/components-react/editors/ImageCheckBoxEditor.js +1 -1
  75. package/lib/esm/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
  76. package/lib/esm/components-react/editors/NumericInputEditor.js +2 -2
  77. package/lib/esm/components-react/editors/NumericInputEditor.js.map +1 -1
  78. package/lib/esm/components-react/editors/PopupButton.js +2 -2
  79. package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
  80. package/lib/esm/components-react/editors/SliderEditor.js +1 -1
  81. package/lib/esm/components-react/editors/SliderEditor.js.map +1 -1
  82. package/lib/esm/components-react/editors/TextEditor.js +2 -2
  83. package/lib/esm/components-react/editors/TextEditor.js.map +1 -1
  84. package/lib/esm/components-react/editors/TextareaEditor.js +2 -2
  85. package/lib/esm/components-react/editors/TextareaEditor.js.map +1 -1
  86. package/lib/esm/components-react/filter-builder/Operators.js +13 -13
  87. package/lib/esm/components-react/filter-builder/Operators.js.map +1 -1
  88. package/lib/esm/components-react/filtering/FilteringInput.js +1 -1
  89. package/lib/esm/components-react/filtering/FilteringInput.js.map +1 -1
  90. package/lib/esm/components-react/filtering/ResultSelector.js +1 -1
  91. package/lib/esm/components-react/filtering/ResultSelector.js.map +1 -1
  92. package/lib/esm/components-react/inputs/ParsedInput.js +2 -2
  93. package/lib/esm/components-react/inputs/ParsedInput.js.map +1 -1
  94. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -1
  95. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  96. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -1
  97. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  98. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js +1 -1
  99. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  100. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EA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CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,MAAM,IAAI,GAAG,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG,CACV,oBAAC,SAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,wBAAwB,GACpC,CACH,CAAC;SACH;aAAM;YACL,SAAS,GAAG,CACV,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,wBAAwB,EACpC,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./TextEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { UiComponents } from \"../UiComponents\";\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Input>;\n\n/** @internal */\ninterface TextEditorState {\n inputValue: string;\n readonly: boolean;\n isDisabled?: boolean;\n size?: number;\n maxLength?: number;\n iconSpec?: string;\n}\n\n/** TextEditor React component that is a property editor with text input\n * @public\n */\nexport class TextEditor\n extends React.PureComponent<PropertyEditorProps, TextEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _ariaLabel = UiComponents.translate(\"editor.text\");\n private _inputElement = React.createRef<HTMLInputElement>();\n\n /** @internal */\n public override readonly state: Readonly<TextEditorState> = {\n inputValue: \"\",\n readonly: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = await TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).convertFromStringToPropertyValue(this.state.inputValue, record);\n (propertyValue as PrimitiveValue).displayValue = this.state.inputValue;\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (this._isMounted)\n this.setState(\n {\n inputValue: e.target.value,\n },\n async () => {\n if (\n this.props.shouldCommitOnChange &&\n this.props.onCommit &&\n this.props.propertyRecord\n ) {\n const newValue = await this.getPropertyValue();\n // istanbul ignore else\n if (newValue)\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue,\n });\n }\n }\n );\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).convertPropertyToString(record.property, value);\n }\n\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | undefined;\n\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n // istanbul ignore else\n if (editorSizeParams.size) size = editorSizeParams.size;\n // istanbul ignore else\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Icon\n ) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: initialValue,\n readonly,\n size,\n maxLength,\n isDisabled,\n iconSpec,\n });\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const className = classnames(\n \"components-cell-editor\",\n \"components-text-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const inputProps: InputProps = {\n type: \"text\",\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly: this.state.readonly,\n disabled: this.state.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onBlur: this.props.onBlur,\n onChange: this._updateInputValue,\n autoFocus: this.props.setFocus && !this.state.isDisabled,\n };\n\n inputProps[\"aria-label\"] = this._ariaLabel;\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-text-editor\"\n />\n );\n } else {\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-text-editor\"\n size=\"small\"\n />\n );\n }\n\n return reactNode;\n }\n}\n"]}
1
+ {"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/TextEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAc/C;;GAEG;AACH,MAAM,OAAO,UACX,SAAQ,KAAK,CAAC,aAAmD;IADnE;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,eAAU,GAAG,YAAY,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACnD,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAE5D,gBAAgB;QACS,UAAK,GAA8B;YAC1D,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE,KAAK;SAChB,CAAC;QA0BM,sBAAiB,GAAG,CAAC,CAAsC,EAAE,EAAE;YACrE,uBAAuB;YACvB,IAAI,IAAI,CAAC,UAAU;gBACjB,IAAI,CAAC,QAAQ,CACX;oBACE,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK;iBAC3B,EACD,KAAK,IAAI,EAAE;oBACT,IACE,IAAI,CAAC,KAAK,CAAC,oBAAoB;wBAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ;wBACnB,IAAI,CAAC,KAAK,CAAC,cAAc,EACzB;wBACA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAA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CAAC,CAAC,aAAa;YAC1D,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ;YAC7B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;YAC/B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;YAC5B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;YACzB,QAAQ,EAAE,IAAI,CAAC,iBAAiB;YAChC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU;SACzD,CAAC;QAEF,UAAU,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;QAE3C,IAAI,SAA0B,CAAC;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,MAAM,IAAI,GAAG,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG,CACV,oBAAC,SAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,wBAAwB,GACpC,CACH,CAAC;SACH;aAAM;YACL,SAAS,GAAG,CACV,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,wBAAwB,EACpC,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./TextEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { UiComponents } from \"../UiComponents\";\n\ntype InputProps = React.ComponentPropsWithoutRef<typeof Input>;\n\n/** @internal */\ninterface TextEditorState {\n inputValue: string;\n readonly: boolean;\n isDisabled?: boolean;\n size?: number;\n maxLength?: number;\n iconSpec?: string;\n}\n\n/** TextEditor React component that is a property editor with text input\n * @public\n */\nexport class TextEditor\n extends React.PureComponent<PropertyEditorProps, TextEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _ariaLabel = UiComponents.translate(\"editor.text\");\n private _inputElement = React.createRef<HTMLInputElement>();\n\n /** @internal */\n public override readonly state: Readonly<TextEditorState> = {\n inputValue: \"\",\n readonly: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = await TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).convertFromStringToPropertyValue(this.state.inputValue, record);\n (propertyValue as PrimitiveValue).displayValue = this.state.inputValue;\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (this._isMounted)\n this.setState(\n {\n inputValue: e.target.value,\n },\n async () => {\n if (\n this.props.shouldCommitOnChange &&\n this.props.onCommit &&\n this.props.propertyRecord\n ) {\n const newValue = await this.getPropertyValue();\n // istanbul ignore else\n if (newValue)\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue,\n });\n }\n }\n );\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).convertPropertyToString(record.property, value);\n }\n\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | undefined;\n\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n // istanbul ignore else\n if (editorSizeParams.size) size = editorSizeParams.size;\n // istanbul ignore else\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Icon.valueOf()\n ) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: initialValue,\n readonly,\n size,\n maxLength,\n isDisabled,\n iconSpec,\n });\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const className = classnames(\n \"components-cell-editor\",\n \"components-text-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const inputProps: InputProps = {\n type: \"text\",\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly: this.state.readonly,\n disabled: this.state.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onBlur: this.props.onBlur,\n onChange: this._updateInputValue,\n autoFocus: this.props.setFocus && !this.state.isDisabled,\n };\n\n inputProps[\"aria-label\"] = this._ariaLabel;\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-text-editor\"\n />\n );\n } else {\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-text-editor\"\n size=\"small\"\n />\n );\n }\n\n return reactNode;\n }\n}\n"]}
@@ -112,7 +112,7 @@ export class TextareaEditor extends React.PureComponent {
112
112
  record.property &&
113
113
  record.property.editor &&
114
114
  record.property.editor.params) {
115
- const editorSizeParams = record.property.editor.params.find((param) => param.type === PropertyEditorParamTypes.InputEditorSize);
115
+ const editorSizeParams = record.property.editor.params.find((param) => param.type === PropertyEditorParamTypes.InputEditorSize.valueOf());
116
116
  if (editorSizeParams) {
117
117
  // istanbul ignore else
118
118
  if (editorSizeParams.size)
@@ -121,7 +121,7 @@ export class TextareaEditor extends React.PureComponent {
121
121
  if (editorSizeParams.maxLength)
122
122
  maxLength = editorSizeParams.maxLength;
123
123
  }
124
- const multilineParams = record.property.editor.params.find((param) => param.type === PropertyEditorParamTypes.MultilineText);
124
+ const multilineParams = record.property.editor.params.find((param) => param.type === PropertyEditorParamTypes.MultilineText.valueOf());
125
125
  if (multilineParams) {
126
126
  rows = multilineParams.rows;
127
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TextareaEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/TextareaEditor.tsx"],"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,GAC5B,CACW,CACH,CACV,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,uBAAuB;IACvB,IAAoB,oBAAoB;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,uBAAuB;IACvB,IAAoB,qBAAqB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,OAAG,CAAC;IAC5B,CAAC;CACF;AAED,qBAAqB,CAAC,cAAc,CAClC,iBAAiB,CAAC,IAAI,EACtB,sBAAsB,EACtB,mBAAmB,CAAC,SAAS,CAC9B,CAAC;AACF,qBAAqB,CAAC,cAAc,CAClC,iBAAiB,CAAC,MAAM,EACxB,sBAAsB,EACtB,mBAAmB,CAAC,SAAS,CAC9B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./TextareaEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n InputEditorSizeParams,\n MultilineTextEditorParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n StandardEditorNames,\n StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { Textarea } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport { PopupButton, PopupContent, PopupOkCancelButtons } from \"./PopupButton\";\nimport { UiComponents } from \"../UiComponents\";\n\ntype TextareaProps = React.ComponentPropsWithoutRef<typeof Textarea>;\n\n/** @internal */\ninterface TextareaEditorState {\n inputValue: string;\n readonly: boolean;\n isDisabled?: boolean;\n size?: number;\n maxLength?: number;\n rows: number;\n}\n\nconst DEFAULT_ROWS = 3;\n\n/** TextareaEditor React component that is a property editor with text input\n * @public\n */\nexport class TextareaEditor\n extends React.PureComponent<PropertyEditorProps, TextareaEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _ariaLabel = UiComponents.translate(\"editor.textarea\");\n private _divElement = React.createRef<HTMLDivElement>();\n private _textAreaElement = React.createRef<HTMLTextAreaElement>();\n\n /** @internal */\n public override readonly state: Readonly<TextareaEditorState> = {\n inputValue: \"\",\n readonly: false,\n rows: DEFAULT_ROWS,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = await TypeConverterManager.getConverter(\n record.property.typename\n ).convertFromStringToPropertyValue(this.state.inputValue, record);\n (propertyValue as PrimitiveValue).displayValue = this.state.inputValue;\n }\n\n return propertyValue;\n }\n\n // istanbul ignore next\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n // istanbul ignore next\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private _updateTextareaValue = (\n e: React.ChangeEvent<HTMLTextAreaElement>\n ) => {\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: e.target.value,\n });\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(\n record.property.typename\n ).convertPropertyToString(record.property, value);\n }\n\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n let size: number | undefined;\n let maxLength: number | undefined;\n let rows: number = DEFAULT_ROWS;\n\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n // istanbul ignore else\n if (editorSizeParams.size) size = editorSizeParams.size;\n // istanbul ignore else\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const multilineParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.MultilineText\n ) as MultilineTextEditorParams;\n if (multilineParams) {\n rows = multilineParams.rows;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: initialValue,\n readonly,\n size,\n maxLength,\n isDisabled,\n rows,\n });\n }\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n // istanbul ignore else\n if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const className = classnames(\n \"components-cell-editor\",\n \"components-textarea-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize * 0.75}em`,\n };\n const textareaProps: TextareaProps = {\n className: \"components-textarea-editor-textarea\",\n style,\n rows: this.state.rows,\n readOnly: this.state.readonly,\n disabled: this.state.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateTextareaValue,\n autoFocus: this.props.setFocus && !this.state.isDisabled,\n };\n\n textareaProps[\"aria-label\"] = this._ariaLabel;\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n label={this.state.inputValue}\n closeOnEnter={false}\n setFocus={this.props.setFocus}\n focusTarget={this._textAreaElement}\n >\n <PopupContent>\n <Textarea\n {...textareaProps}\n data-testid=\"components-textarea-editor\"\n ref={this._textAreaElement}\n />\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** Textarea Property Editor registered for the \"text\" and \"string\" type names and \"multi-line\" editor name.\n * It uses the [[TextareaEditor]] React component.\n * @public\n */\nexport class TextareaPropertyEditor extends PropertyEditorBase {\n // istanbul ignore next\n public override get containerHandlesBlur(): boolean {\n return false;\n }\n // istanbul ignore next\n public override get containerHandlesEnter(): boolean {\n return false;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <TextareaEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Text,\n TextareaPropertyEditor,\n StandardEditorNames.MultiLine\n);\nPropertyEditorManager.registerEditor(\n StandardTypeNames.String,\n TextareaPropertyEditor,\n StandardEditorNames.MultiLine\n);\n"]}
1
+ {"version":3,"file":"TextareaEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/TextareaEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CA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H,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,uBAAuB;IACvB,IAAoB,oBAAoB;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,uBAAuB;IACvB,IAAoB,qBAAqB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,OAAG,CAAC;IAC5B,CAAC;CACF;AAED,qBAAqB,CAAC,cAAc,CAClC,iBAAiB,CAAC,IAAI,EACtB,sBAAsB,EACtB,mBAAmB,CAAC,SAAS,CAC9B,CAAC;AACF,qBAAqB,CAAC,cAAc,CAClC,iBAAiB,CAAC,MAAM,EACxB,sBAAsB,EACtB,mBAAmB,CAAC,SAAS,CAC9B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyEditors\n */\n\nimport \"./TextareaEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n InputEditorSizeParams,\n MultilineTextEditorParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n StandardEditorNames,\n StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { Textarea } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport { PopupButton, PopupContent, PopupOkCancelButtons } from \"./PopupButton\";\nimport { UiComponents } from \"../UiComponents\";\n\ntype TextareaProps = React.ComponentPropsWithoutRef<typeof Textarea>;\n\n/** @internal */\ninterface TextareaEditorState {\n inputValue: string;\n readonly: boolean;\n isDisabled?: boolean;\n size?: number;\n maxLength?: number;\n rows: number;\n}\n\nconst DEFAULT_ROWS = 3;\n\n/** TextareaEditor React component that is a property editor with text input\n * @public\n */\nexport class TextareaEditor\n extends React.PureComponent<PropertyEditorProps, TextareaEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _ariaLabel = UiComponents.translate(\"editor.textarea\");\n private _divElement = React.createRef<HTMLDivElement>();\n private _textAreaElement = React.createRef<HTMLTextAreaElement>();\n\n /** @internal */\n public override readonly state: Readonly<TextareaEditorState> = {\n inputValue: \"\",\n readonly: false,\n rows: DEFAULT_ROWS,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = await TypeConverterManager.getConverter(\n record.property.typename\n ).convertFromStringToPropertyValue(this.state.inputValue, record);\n (propertyValue as PrimitiveValue).displayValue = this.state.inputValue;\n }\n\n return propertyValue;\n }\n\n // istanbul ignore next\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n // istanbul ignore next\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private _updateTextareaValue = (\n e: React.ChangeEvent<HTMLTextAreaElement>\n ) => {\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: e.target.value,\n });\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const value = record.value.value;\n initialValue = await TypeConverterManager.getConverter(\n record.property.typename\n ).convertPropertyToString(record.property, value);\n }\n\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n let size: number | undefined;\n let maxLength: number | undefined;\n let rows: number = DEFAULT_ROWS;\n\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize.valueOf()\n ) as InputEditorSizeParams;\n if (editorSizeParams) {\n // istanbul ignore else\n if (editorSizeParams.size) size = editorSizeParams.size;\n // istanbul ignore else\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const multilineParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.MultilineText.valueOf()\n ) as MultilineTextEditorParams;\n if (multilineParams) {\n rows = multilineParams.rows;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: initialValue,\n readonly,\n size,\n maxLength,\n isDisabled,\n rows,\n });\n }\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n // istanbul ignore else\n if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const className = classnames(\n \"components-cell-editor\",\n \"components-textarea-editor\",\n this.props.className\n );\n const minSize = this.state.size ? this.state.size : 8;\n const style: React.CSSProperties = {\n ...this.props.style,\n minWidth: `${minSize * 0.75}em`,\n };\n const textareaProps: TextareaProps = {\n className: \"components-textarea-editor-textarea\",\n style,\n rows: this.state.rows,\n readOnly: this.state.readonly,\n disabled: this.state.isDisabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateTextareaValue,\n autoFocus: this.props.setFocus && !this.state.isDisabled,\n };\n\n textareaProps[\"aria-label\"] = this._ariaLabel;\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n label={this.state.inputValue}\n closeOnEnter={false}\n setFocus={this.props.setFocus}\n focusTarget={this._textAreaElement}\n >\n <PopupContent>\n <Textarea\n {...textareaProps}\n data-testid=\"components-textarea-editor\"\n ref={this._textAreaElement}\n />\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** Textarea Property Editor registered for the \"text\" and \"string\" type names and \"multi-line\" editor name.\n * It uses the [[TextareaEditor]] React component.\n * @public\n */\nexport class TextareaPropertyEditor extends PropertyEditorBase {\n // istanbul ignore next\n public override get containerHandlesBlur(): boolean {\n return false;\n }\n // istanbul ignore next\n public override get containerHandlesEnter(): boolean {\n return false;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <TextareaEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Text,\n TextareaPropertyEditor,\n StandardEditorNames.MultiLine\n);\nPropertyEditorManager.registerEditor(\n StandardTypeNames.String,\n TextareaPropertyEditor,\n StandardEditorNames.MultiLine\n);\n"]}
@@ -39,8 +39,8 @@ export var PropertyFilterRuleOperator;
39
39
  */
40
40
  export function getPropertyFilterBuilderOperators(property) {
41
41
  const typename = property.typename;
42
- if (typename === StandardTypeNames.Bool ||
43
- typename === StandardTypeNames.Boolean) {
42
+ if (typename === StandardTypeNames.Bool.valueOf() ||
43
+ typename === StandardTypeNames.Boolean.valueOf()) {
44
44
  return ["is-true", "is-false"];
45
45
  }
46
46
  const operators = [
@@ -49,15 +49,15 @@ export function getPropertyFilterBuilderOperators(property) {
49
49
  "is-null",
50
50
  "is-not-null",
51
51
  ];
52
- if (typename === StandardTypeNames.Number ||
53
- typename === StandardTypeNames.Int ||
54
- typename === StandardTypeNames.Integer ||
55
- typename === StandardTypeNames.Double ||
56
- typename === StandardTypeNames.Float ||
57
- typename === StandardTypeNames.Hex ||
58
- typename === StandardTypeNames.Hexadecimal ||
59
- typename === StandardTypeNames.ShortDate ||
60
- typename === StandardTypeNames.DateTime) {
52
+ if (typename === StandardTypeNames.Number.valueOf() ||
53
+ typename === StandardTypeNames.Int.valueOf() ||
54
+ typename === StandardTypeNames.Integer.valueOf() ||
55
+ typename === StandardTypeNames.Double.valueOf() ||
56
+ typename === StandardTypeNames.Float.valueOf() ||
57
+ typename === StandardTypeNames.Hex.valueOf() ||
58
+ typename === StandardTypeNames.Hexadecimal.valueOf() ||
59
+ typename === StandardTypeNames.ShortDate.valueOf() ||
60
+ typename === StandardTypeNames.DateTime.valueOf()) {
61
61
  return [
62
62
  ...operators,
63
63
  "greater",
@@ -68,8 +68,8 @@ export function getPropertyFilterBuilderOperators(property) {
68
68
  "not-between",
69
69
  ];
70
70
  }
71
- if (typename === StandardTypeNames.String ||
72
- typename === StandardTypeNames.Text) {
71
+ if (typename === StandardTypeNames.String.valueOf() ||
72
+ typename === StandardTypeNames.Text.valueOf()) {
73
73
  return ["like", ...operators];
74
74
  }
75
75
  return operators;
@@ -1 +1 @@
1
- {"version":3,"file":"Operators.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/Operators.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAN,IAAY,+BAGX;AAHD,WAAY,+BAA+B;IACzC,8CAAW,CAAA;IACX,4CAAS,CAAA;AACX,CAAC,EAHW,+B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AQ,KAAK,iBAAiB,CAAC,IAAI,EACnC;QACA,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;KAC/B;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oCAAoC,CAClD,QAA2C;IAE3C,OAAO,CACL,QAAQ,KAAK,SAAS;QACtB,QAAQ,KAAK,aAAa;QAC1B,6BAA6B,CAAC,QAAQ,CAAC,CACxC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAyC;IAEzC,QAAQ,QAAQ,EAAE;QAChB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,SAAS,CAAC;QACf,KAAK,aAAa;YAChB,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyFilterBuilder\n */\n\nimport type { PropertyDescription } from \"@itwin/appui-abstract\";\nimport { StandardTypeNames } from \"@itwin/appui-abstract\";\n\n/**\n * Logical operator for joining rules.\n * @beta\n */\nexport enum PropertyFilterRuleGroupOperator {\n And = \"and\",\n Or = \"or\",\n}\n\n/**\n * Operators for comparing property value in [[PropertyFilterRule]].\n * @beta\n */\nexport enum PropertyFilterRuleOperator {\n IsTrue = \"is-true\",\n IsFalse = \"is-false\",\n IsEqual = \"is-equal\",\n IsNotEqual = \"is-not-equal\",\n Greater = \"greater\",\n GreaterOrEqual = \"greater-or-equal\",\n Less = \"less\",\n LessOrEqual = \"less-or-equal\",\n Like = \"like\",\n IsNull = \"is-null\",\n IsNotNull = \"is-not-null\",\n}\n\n/**\n * Operators supported by [[usePropertyFilterBuilder]] when building filter rules.\n * @beta\n */\nexport type PropertyFilterBuilderRuleOperator =\n | `${PropertyFilterRuleOperator}`\n | \"between\"\n | \"not-between\";\n\n/**\n * Function that returns set of available operator based on property type.\n * @beta\n */\nexport function getPropertyFilterBuilderOperators(\n property: PropertyDescription\n): PropertyFilterBuilderRuleOperator[] {\n const typename = property.typename;\n\n if (\n typename === StandardTypeNames.Bool ||\n typename === StandardTypeNames.Boolean\n ) {\n return [\"is-true\", \"is-false\"];\n }\n\n const operators: PropertyFilterBuilderRuleOperator[] = [\n \"is-equal\",\n \"is-not-equal\",\n \"is-null\",\n \"is-not-null\",\n ];\n\n if (\n typename === StandardTypeNames.Number ||\n typename === StandardTypeNames.Int ||\n typename === StandardTypeNames.Integer ||\n typename === StandardTypeNames.Double ||\n typename === StandardTypeNames.Float ||\n typename === StandardTypeNames.Hex ||\n typename === StandardTypeNames.Hexadecimal ||\n typename === StandardTypeNames.ShortDate ||\n typename === StandardTypeNames.DateTime\n ) {\n return [\n ...operators,\n \"greater\",\n \"greater-or-equal\",\n \"less\",\n \"less-or-equal\",\n \"between\",\n \"not-between\",\n ];\n }\n\n if (\n typename === StandardTypeNames.String ||\n typename === StandardTypeNames.Text\n ) {\n return [\"like\", ...operators];\n }\n\n return operators;\n}\n\n/**\n * Function that checks if supplied [[PropertyFilterBuilderRuleOperator]] operator is unary.\n * @beta\n */\nexport function isUnaryPropertyFilterBuilderOperator(\n operator: PropertyFilterBuilderRuleOperator\n) {\n return (\n operator !== \"between\" &&\n operator !== \"not-between\" &&\n isUnaryPropertyFilterOperator(operator)\n );\n}\n\n/**\n * Function that checks if supplied [[PropertyFilterRuleOperator]] operator is unary.\n * @beta\n */\nexport function isUnaryPropertyFilterOperator(\n operator: `${PropertyFilterRuleOperator}`\n) {\n switch (operator) {\n case \"is-true\":\n case \"is-false\":\n case \"is-null\":\n case \"is-not-null\":\n return true;\n }\n return false;\n}\n"]}
1
+ {"version":3,"file":"Operators.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/Operators.ts"],"names":[],"mappings":"AAAA;;;gGA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QAAQ,KAAK,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE;QAC5C,QAAQ,KAAK,iBAAiB,CAAC,WAAW,CAAC,OAAO,EAAE;QACpD,QAAQ,KAAK,iBAAiB,CAAC,SAAS,CAAC,OAAO,EAAE;QAClD,QAAQ,KAAK,iBAAiB,CAAC,QAAQ,CAAC,OAAO,EAAE,EACjD;QACA,OAAO;YACL,GAAG,SAAS;YACZ,SAAS;YACT,kBAAkB;YAClB,MAAM;YACN,eAAe;YACf,SAAS;YACT,aAAa;SACd,CAAC;KACH;IAED,IACE,QAAQ,KAAK,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE;QAC/C,QAAQ,KAAK,iBAAiB,CAAC,IAAI,CAAC,OAAO,EAAE,EAC7C;QACA,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;KAC/B;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oCAAoC,CAClD,QAA2C;IAE3C,OAAO,CACL,QAAQ,KAAK,SAAS;QACtB,QAAQ,KAAK,aAAa;QAC1B,6BAA6B,CAAC,QAAQ,CAAC,CACxC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAyC;IAEzC,QAAQ,QAAQ,EAAE;QAChB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,SAAS,CAAC;QACf,KAAK,aAAa;YAChB,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyFilterBuilder\n */\n\nimport type { PropertyDescription } from \"@itwin/appui-abstract\";\nimport { StandardTypeNames } from \"@itwin/appui-abstract\";\n\n/**\n * Logical operator for joining rules.\n * @beta\n */\nexport enum PropertyFilterRuleGroupOperator {\n And = \"and\",\n Or = \"or\",\n}\n\n/**\n * Operators for comparing property value in [[PropertyFilterRule]].\n * @beta\n */\nexport enum PropertyFilterRuleOperator {\n IsTrue = \"is-true\",\n IsFalse = \"is-false\",\n IsEqual = \"is-equal\",\n IsNotEqual = \"is-not-equal\",\n Greater = \"greater\",\n GreaterOrEqual = \"greater-or-equal\",\n Less = \"less\",\n LessOrEqual = \"less-or-equal\",\n Like = \"like\",\n IsNull = \"is-null\",\n IsNotNull = \"is-not-null\",\n}\n\n/**\n * Operators supported by [[usePropertyFilterBuilder]] when building filter rules.\n * @beta\n */\nexport type PropertyFilterBuilderRuleOperator =\n | `${PropertyFilterRuleOperator}`\n | \"between\"\n | \"not-between\";\n\n/**\n * Function that returns set of available operator based on property type.\n * @beta\n */\nexport function getPropertyFilterBuilderOperators(\n property: PropertyDescription\n): PropertyFilterBuilderRuleOperator[] {\n const typename = property.typename;\n\n if (\n typename === StandardTypeNames.Bool.valueOf() ||\n typename === StandardTypeNames.Boolean.valueOf()\n ) {\n return [\"is-true\", \"is-false\"];\n }\n\n const operators: PropertyFilterBuilderRuleOperator[] = [\n \"is-equal\",\n \"is-not-equal\",\n \"is-null\",\n \"is-not-null\",\n ];\n\n if (\n typename === StandardTypeNames.Number.valueOf() ||\n typename === StandardTypeNames.Int.valueOf() ||\n typename === StandardTypeNames.Integer.valueOf() ||\n typename === StandardTypeNames.Double.valueOf() ||\n typename === StandardTypeNames.Float.valueOf() ||\n typename === StandardTypeNames.Hex.valueOf() ||\n typename === StandardTypeNames.Hexadecimal.valueOf() ||\n typename === StandardTypeNames.ShortDate.valueOf() ||\n typename === StandardTypeNames.DateTime.valueOf()\n ) {\n return [\n ...operators,\n \"greater\",\n \"greater-or-equal\",\n \"less\",\n \"less-or-equal\",\n \"between\",\n \"not-between\",\n ];\n }\n\n if (\n typename === StandardTypeNames.String.valueOf() ||\n typename === StandardTypeNames.Text.valueOf()\n ) {\n return [\"like\", ...operators];\n }\n\n return operators;\n}\n\n/**\n * Function that checks if supplied [[PropertyFilterBuilderRuleOperator]] operator is unary.\n * @beta\n */\nexport function isUnaryPropertyFilterBuilderOperator(\n operator: PropertyFilterBuilderRuleOperator\n) {\n return (\n operator !== \"between\" &&\n operator !== \"not-between\" &&\n isUnaryPropertyFilterOperator(operator)\n );\n}\n\n/**\n * Function that checks if supplied [[PropertyFilterRuleOperator]] operator is unary.\n * @beta\n */\nexport function isUnaryPropertyFilterOperator(\n operator: `${PropertyFilterRuleOperator}`\n) {\n switch (operator) {\n case \"is-true\":\n case \"is-false\":\n case \"is-null\":\n case \"is-not-null\":\n return true;\n }\n return false;\n}\n"]}
@@ -58,7 +58,7 @@ export class FilteringInput extends React.PureComponent {
58
58
  this.focus();
59
59
  };
60
60
  this._onFilterKeyDown = (e) => {
61
- if (e.key !== Key.Enter)
61
+ if (e.key !== Key.Enter.valueOf())
62
62
  return;
63
63
  if (!this.state.searchText)
64
64
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"FilteringInput.js","sourceRoot":"","sources":["../../../../src/components-react/filtering/FilteringInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA0CjE;;;GAGG;AACH,MAAM,CAAN,IAAY,oBAOX;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AAa,CAAC,CAAC,CAAC;oBAC/C,iEAAiE;oBACjE,8BACE,SAAS,EAAC,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,oBAAoB,iBACtB,qBAAqB,EACjC,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,EACZ,KAAK,EAAE,IAAI,CAAC,YAAY;wBAExB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,SAAS,OAAG,GAAI;wBAAC,GAAG,CAChC,CACR,CAAC,CAAC,CAAC,SAAS;oBACZ,MAAM,KAAK,oBAAoB,CAAC,mBAAmB,CAAC,CAAC,CAAC;oBACrD,iEAAiE;oBACjE,8BACE,SAAS,EAAC,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,oBAAoB,iBACtB,oBAAoB,EAChC,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,EACZ,KAAK,EAAE,IAAI,CAAC,YAAY;wBAExB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,QAAQ,OAAG,GAAI;wBAAC,GAAG,CAC/B,CACR,CAAC,CAAC,CAAC,SAAS;oBACZ,MAAM,KAAK,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,CAAC;oBACnD,iEAAiE;oBACjE,8BACE,SAAS,EAAC,uCAAuC,EACjD,OAAO,EAAE,IAAI,CAAC,mBAAmB,iBACrB,oBAAoB,EAChC,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,EACZ,KAAK,EAAE,IAAI,CAAC,WAAW;wBAEvB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,QAAQ,OAAG,GAAI;wBAAC,GAAG,CAC/B,CACR,CAAC,CAAC,CAAC,SAAS,CACR,CACF,CACH,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Filtering\n */\n\nimport \"./FilteringInput.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon, UiCore } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport type { ResultSelectorProps } from \"./ResultSelector\";\nimport { ResultSelector } from \"./ResultSelector\";\nimport { SvgClose, SvgSearch } from \"@itwin/itwinui-icons-react\";\n\n/** [[FilteringInput]] React Component state\n * @internal\n */\ninterface FilteringInputState {\n /** A string which will be used for search */\n searchText: string;\n /**\n * Tells the component if the search was started.\n * Gets reset to false if search is canceled/cleared or searchText is changed.\n */\n searchStarted: boolean;\n /* Used for resetting the state of [[ResultSelector]] component */\n resultSelectorKey: number;\n}\n\n/**\n * [[FilteringInput]] React Component properties\n * @public\n */\nexport interface FilteringInputProps extends CommonProps {\n /** Filtering should start */\n onFilterStart: (searchText: string) => void;\n /** Filtering is canceled while still in progress */\n onFilterCancel: () => void;\n /** Filtering is cleared after everything's loaded */\n onFilterClear: () => void;\n /**\n * Tells the component what is the status of filtering.\n */\n status: FilteringInputStatus;\n /**\n * [[ResultSelector]] React Component properties.\n * Attribute should be memoized and updated when [[ResultSelector]] state needs to be reset.\n * This allows resetting the selected active match index back to 0.\n */\n resultSelectorProps?: ResultSelectorProps;\n /** Specify that the <input> element should automatically get focus */\n autoFocus?: boolean;\n}\n\n/**\n * Enumeration of possible component contexts\n * @public\n */\nexport enum FilteringInputStatus {\n /** Component is ready to filter */\n ReadyToFilter,\n /** Component's parent is currently filtering */\n FilteringInProgress,\n /** Component's parent has finished filtering */\n FilteringFinished,\n}\n\n/** A helper component for filtering trees and stepping through results\n * @public\n */\nexport class FilteringInput extends React.PureComponent<\n FilteringInputProps,\n FilteringInputState\n> {\n private _inputElement = React.createRef<HTMLInputElement>();\n private _searchLabel = UiCore.translate(\"general.search\");\n private _cancelLabel = UiCore.translate(\"dialog.cancel\");\n private _clearLabel = UiCore.translate(\"general.search\");\n\n constructor(props: FilteringInputProps) {\n super(props);\n this.state = {\n searchText: \"\",\n searchStarted: false,\n resultSelectorKey: 0,\n };\n }\n\n private focus() {\n // istanbul ignore next\n if (this._inputElement.current) this._inputElement.current.focus();\n }\n\n private _onSearchButtonClick = () => {\n if (!this.state.searchText) {\n // Empty search string is the same as clearing the search.\n this.setState({ searchStarted: false, searchText: \"\" });\n this.props.onFilterClear();\n return;\n }\n\n this.props.onFilterStart(this.state.searchText);\n this.setState({ searchStarted: true });\n };\n\n private _onCancelButtonClick = () => {\n this.setState({ searchStarted: false, searchText: \"\" });\n this.props.onFilterCancel();\n this.focus();\n };\n\n private _onClearButtonClick = () => {\n this.setState({ searchStarted: false, searchText: \"\" });\n this.props.onFilterClear();\n this.focus();\n };\n\n private _onFilterKeyDown = (e: React.KeyboardEvent<HTMLElement>): void => {\n if (e.key !== Key.Enter) return;\n\n if (!this.state.searchText) return;\n\n this.props.onFilterStart(this.state.searchText);\n this.setState({ searchStarted: true });\n e.stopPropagation();\n };\n\n private _onInputChanged = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (this.state.searchStarted) {\n this.props.onFilterCancel();\n }\n this.setState({ searchText: e.target.value, searchStarted: false });\n };\n\n /** @internal */\n public override componentDidUpdate(prevProps: FilteringInputProps) {\n if (this.props.resultSelectorProps !== prevProps.resultSelectorProps) {\n this.setState((state) => ({\n resultSelectorKey: state.resultSelectorKey + 1,\n }));\n }\n }\n\n public override render() {\n const status = this.props.status;\n return (\n // TODO: What is filtering-input-preload-images?\n <div\n className={classnames(\n \"components-filtering-input\",\n \"filtering-input-preload-images\",\n this.props.className\n )}\n style={this.props.style}\n onKeyDown={this._onFilterKeyDown}\n role=\"presentation\"\n >\n <span className=\"components-filtering-input-input\">\n <Input\n type=\"text\"\n placeholder={UiComponents.translate(\"filteringInput.placeholder\")}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={this.props.autoFocus}\n onKeyDown={this._onFilterKeyDown}\n value={this.state.searchText}\n onChange={this._onInputChanged}\n aria-label={UiCore.translate(\"general.search\")}\n size=\"small\"\n />\n\n <span className=\"components-filtering-input-input-components\">\n {status === FilteringInputStatus.FilteringFinished &&\n this.props.resultSelectorProps ? (\n <ResultSelector\n key={this.state.resultSelectorKey}\n {...this.props.resultSelectorProps}\n />\n ) : undefined}\n {status === FilteringInputStatus.ReadyToFilter ? (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <span\n className=\"icon\"\n onClick={this._onSearchButtonClick}\n data-testid=\"filter-input-search\"\n role=\"button\"\n tabIndex={-1}\n title={this._searchLabel}\n >\n <Icon iconSpec={<SvgSearch />} />{\" \"}\n </span>\n ) : undefined}\n {status === FilteringInputStatus.FilteringInProgress ? (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <span\n className=\"icon\"\n onClick={this._onCancelButtonClick}\n data-testid=\"filter-input-close\"\n role=\"button\"\n tabIndex={-1}\n title={this._cancelLabel}\n >\n <Icon iconSpec={<SvgClose />} />{\" \"}\n </span>\n ) : undefined}\n {status === FilteringInputStatus.FilteringFinished ? (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <span\n className=\"components-filtering-input-clear icon\"\n onClick={this._onClearButtonClick}\n data-testid=\"filter-input-close\"\n role=\"button\"\n tabIndex={-1}\n title={this._clearLabel}\n >\n <Icon iconSpec={<SvgClose />} />{\" \"}\n </span>\n ) : undefined}\n </span>\n </span>\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"FilteringInput.js","sourceRoot":"","sources":["../../../../src/components-react/filtering/FilteringInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,a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AC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,EACZ,KAAK,EAAE,IAAI,CAAC,WAAW;wBAEvB,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,QAAQ,OAAG,GAAI;wBAAC,GAAG,CAC/B,CACR,CAAC,CAAC,CAAC,SAAS,CACR,CACF,CACH,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Filtering\n */\n\nimport \"./FilteringInput.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon, UiCore } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport type { ResultSelectorProps } from \"./ResultSelector\";\nimport { ResultSelector } from \"./ResultSelector\";\nimport { SvgClose, SvgSearch } from \"@itwin/itwinui-icons-react\";\n\n/** [[FilteringInput]] React Component state\n * @internal\n */\ninterface FilteringInputState {\n /** A string which will be used for search */\n searchText: string;\n /**\n * Tells the component if the search was started.\n * Gets reset to false if search is canceled/cleared or searchText is changed.\n */\n searchStarted: boolean;\n /* Used for resetting the state of [[ResultSelector]] component */\n resultSelectorKey: number;\n}\n\n/**\n * [[FilteringInput]] React Component properties\n * @public\n */\nexport interface FilteringInputProps extends CommonProps {\n /** Filtering should start */\n onFilterStart: (searchText: string) => void;\n /** Filtering is canceled while still in progress */\n onFilterCancel: () => void;\n /** Filtering is cleared after everything's loaded */\n onFilterClear: () => void;\n /**\n * Tells the component what is the status of filtering.\n */\n status: FilteringInputStatus;\n /**\n * [[ResultSelector]] React Component properties.\n * Attribute should be memoized and updated when [[ResultSelector]] state needs to be reset.\n * This allows resetting the selected active match index back to 0.\n */\n resultSelectorProps?: ResultSelectorProps;\n /** Specify that the <input> element should automatically get focus */\n autoFocus?: boolean;\n}\n\n/**\n * Enumeration of possible component contexts\n * @public\n */\nexport enum FilteringInputStatus {\n /** Component is ready to filter */\n ReadyToFilter,\n /** Component's parent is currently filtering */\n FilteringInProgress,\n /** Component's parent has finished filtering */\n FilteringFinished,\n}\n\n/** A helper component for filtering trees and stepping through results\n * @public\n */\nexport class FilteringInput extends React.PureComponent<\n FilteringInputProps,\n FilteringInputState\n> {\n private _inputElement = React.createRef<HTMLInputElement>();\n private _searchLabel = UiCore.translate(\"general.search\");\n private _cancelLabel = UiCore.translate(\"dialog.cancel\");\n private _clearLabel = UiCore.translate(\"general.search\");\n\n constructor(props: FilteringInputProps) {\n super(props);\n this.state = {\n searchText: \"\",\n searchStarted: false,\n resultSelectorKey: 0,\n };\n }\n\n private focus() {\n // istanbul ignore next\n if (this._inputElement.current) this._inputElement.current.focus();\n }\n\n private _onSearchButtonClick = () => {\n if (!this.state.searchText) {\n // Empty search string is the same as clearing the search.\n this.setState({ searchStarted: false, searchText: \"\" });\n this.props.onFilterClear();\n return;\n }\n\n this.props.onFilterStart(this.state.searchText);\n this.setState({ searchStarted: true });\n };\n\n private _onCancelButtonClick = () => {\n this.setState({ searchStarted: false, searchText: \"\" });\n this.props.onFilterCancel();\n this.focus();\n };\n\n private _onClearButtonClick = () => {\n this.setState({ searchStarted: false, searchText: \"\" });\n this.props.onFilterClear();\n this.focus();\n };\n\n private _onFilterKeyDown = (e: React.KeyboardEvent<HTMLElement>): void => {\n if (e.key !== Key.Enter.valueOf()) return;\n\n if (!this.state.searchText) return;\n\n this.props.onFilterStart(this.state.searchText);\n this.setState({ searchStarted: true });\n e.stopPropagation();\n };\n\n private _onInputChanged = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (this.state.searchStarted) {\n this.props.onFilterCancel();\n }\n this.setState({ searchText: e.target.value, searchStarted: false });\n };\n\n /** @internal */\n public override componentDidUpdate(prevProps: FilteringInputProps) {\n if (this.props.resultSelectorProps !== prevProps.resultSelectorProps) {\n this.setState((state) => ({\n resultSelectorKey: state.resultSelectorKey + 1,\n }));\n }\n }\n\n public override render() {\n const status = this.props.status;\n return (\n // TODO: What is filtering-input-preload-images?\n <div\n className={classnames(\n \"components-filtering-input\",\n \"filtering-input-preload-images\",\n this.props.className\n )}\n style={this.props.style}\n onKeyDown={this._onFilterKeyDown}\n role=\"presentation\"\n >\n <span className=\"components-filtering-input-input\">\n <Input\n type=\"text\"\n placeholder={UiComponents.translate(\"filteringInput.placeholder\")}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={this.props.autoFocus}\n onKeyDown={this._onFilterKeyDown}\n value={this.state.searchText}\n onChange={this._onInputChanged}\n aria-label={UiCore.translate(\"general.search\")}\n size=\"small\"\n />\n\n <span className=\"components-filtering-input-input-components\">\n {status === FilteringInputStatus.FilteringFinished &&\n this.props.resultSelectorProps ? (\n <ResultSelector\n key={this.state.resultSelectorKey}\n {...this.props.resultSelectorProps}\n />\n ) : undefined}\n {status === FilteringInputStatus.ReadyToFilter ? (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <span\n className=\"icon\"\n onClick={this._onSearchButtonClick}\n data-testid=\"filter-input-search\"\n role=\"button\"\n tabIndex={-1}\n title={this._searchLabel}\n >\n <Icon iconSpec={<SvgSearch />} />{\" \"}\n </span>\n ) : undefined}\n {status === FilteringInputStatus.FilteringInProgress ? (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <span\n className=\"icon\"\n onClick={this._onCancelButtonClick}\n data-testid=\"filter-input-close\"\n role=\"button\"\n tabIndex={-1}\n title={this._cancelLabel}\n >\n <Icon iconSpec={<SvgClose />} />{\" \"}\n </span>\n ) : undefined}\n {status === FilteringInputStatus.FilteringFinished ? (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <span\n className=\"components-filtering-input-clear icon\"\n onClick={this._onClearButtonClick}\n data-testid=\"filter-input-close\"\n role=\"button\"\n tabIndex={-1}\n title={this._clearLabel}\n >\n <Icon iconSpec={<SvgClose />} />{\" \"}\n </span>\n ) : undefined}\n </span>\n </span>\n </div>\n );\n }\n}\n"]}
@@ -67,7 +67,7 @@ export class ResultSelector extends React.PureComponent {
67
67
  }));
68
68
  };
69
69
  this._onSelectedResultKeyDown = (event) => {
70
- if (event.key === Key.Enter)
70
+ if (event.key === Key.Enter.valueOf())
71
71
  this._onSelectedResultConfirmed();
72
72
  };
73
73
  this.state = {
@@ -1 +1 @@
1
- {"version":3,"file":"ResultSelector.js","sourceRoot":"","sources":["../../../../src/components-react/filtering/ResultSelector.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAwB7E;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK,CAAC,aAGzC;IAGC,gBAAgB;IAChB,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAJP,aAAQ,GAAG,YAAY,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAYhD,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,IAAI,CAAC,KAAK,CAAC,wBAAwB,EAAE;gBACvC,IAAI,CAAC,0BAA0B,EAAE,CAAC;gBAClC,OAAO;aACR;YACD,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,EAAE;gBACnC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,CA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AE,IACnD,IAAI,CAAC,QAAQ,CACT;gBACP,kCAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAQ,CAChC;YAEP,gCACE,SAAS,EAAC,wCAAwC,iBACtC,aAAa,EACzB,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC;gBAErC,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,eAAe,OAAG,GAAI,CAChC,CACJ,CACR,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Filtering\n */\n\nimport \"./ResultSelector.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport { SvgChevronLeft, SvgChevronRight } from \"@itwin/itwinui-icons-react\";\n\n/** [[ResultSelector]] React Component state\n * @internal\n */\ninterface ResultSelectorState {\n /** Currently selected result/entry index */\n selectedResultId: number;\n /** Input string */\n selectedResultEdit: string;\n /** Informs if selectedResult is currently being edited */\n selectedResultInEditMode: boolean;\n}\n\n/** [[ResultSelector]] React Component properties\n * @public\n */\nexport interface ResultSelectorProps extends CommonProps {\n /** Total number of results/entries */\n resultCount: number;\n /** Callback to currently selected result/entry change */\n onSelectedChanged: (index: number) => void;\n}\n\n/** Component for stepping through results/entries\n * @public\n */\nexport class ResultSelector extends React.PureComponent<\n ResultSelectorProps,\n ResultSelectorState\n> {\n private _ofLabel = UiComponents.translate(\"general.of\");\n\n /** @internal */\n constructor(props: ResultSelectorProps) {\n super(props);\n this.state = {\n selectedResultId: props.resultCount ? 1 : 0,\n selectedResultEdit: \"\",\n selectedResultInEditMode: false,\n };\n }\n\n private _onClickPrevious = () => {\n if (this.state.selectedResultInEditMode) {\n this._onSelectedResultConfirmed();\n return;\n }\n if (this.state.selectedResultId > 1) {\n this.props.onSelectedChanged(this.state.selectedResultId - 1);\n this.setState((state) => ({\n selectedResultId: state.selectedResultId - 1,\n }));\n }\n };\n\n private _onClickNext = () => {\n if (this.state.selectedResultInEditMode) {\n this._onSelectedResultConfirmed();\n return;\n }\n if (this.state.selectedResultId < this.props.resultCount) {\n this.props.onSelectedChanged(this.state.selectedResultId + 1);\n this.setState((state) => ({\n selectedResultId: state.selectedResultId + 1,\n }));\n }\n };\n\n private get _maxSelectedResultInputLength() {\n return this.props.resultCount.toString().length;\n }\n\n private _onSelectedResultChanged = (\n event: React.ChangeEvent<HTMLInputElement>\n ) => {\n if (event.target.value.length <= this._maxSelectedResultInputLength)\n this.setState({ selectedResultEdit: event.target.value });\n };\n\n private _onSelectedResultConfirmed = () => {\n let selectedId = +this.state.selectedResultEdit;\n if (selectedId > this.props.resultCount)\n selectedId = this.props.resultCount;\n else if (selectedId < 1) selectedId = 1;\n\n this.setState({\n selectedResultInEditMode: false,\n selectedResultId: selectedId,\n });\n this.props.onSelectedChanged(selectedId);\n };\n\n private _onSelectedResultClick = () => {\n this.setState((state) => ({\n selectedResultInEditMode: true,\n selectedResultEdit: state.selectedResultId.toString(),\n }));\n };\n\n private _onSelectedResultKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === Key.Enter) this._onSelectedResultConfirmed();\n };\n\n /** @internal */\n public override componentDidMount() {\n this.props.onSelectedChanged(this.props.resultCount ? 1 : 0);\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: ResultSelectorProps) {\n if (this.props.resultCount !== prevProps.resultCount) {\n this.props.onSelectedChanged(this.props.resultCount ? 1 : 0);\n }\n }\n\n /** @internal */\n public override render() {\n return (\n <span\n className={classnames(\n \"components-result-selector\",\n this.props.className\n )}\n style={this.props.style}\n >\n <button\n className={classnames(\"components-result-selector-button\", \"icon\")}\n data-testid=\"previous-button\"\n onClick={this._onClickPrevious}\n disabled={this.props.resultCount <= 0}\n >\n <Icon iconSpec={<SvgChevronLeft />} />\n </button>\n\n <span\n style={{ pointerEvents: this.props.resultCount ? \"auto\" : \"none\" }}\n className=\"components-result-selector-current-result\"\n onClick={this._onSelectedResultClick}\n role=\"presentation\"\n >\n {this.state.selectedResultInEditMode ? (\n <input\n type=\"number\"\n style={{\n width: `${this.state.selectedResultEdit.length * 0.6 + 1}em`,\n }}\n value={this.state.selectedResultEdit}\n onChange={this._onSelectedResultChanged}\n onBlur={this._onSelectedResultConfirmed}\n onKeyDown={this._onSelectedResultKeyDown}\n />\n ) : (\n this.state.selectedResultId\n )}\n <span style={{ marginLeft: \"5px\", marginRight: \"5px\" }}>\n {this._ofLabel}\n </span>\n <span>{this.props.resultCount}</span>\n </span>\n\n <button\n className=\"components-result-selector-button icon\"\n data-testid=\"next-button\"\n onClick={this._onClickNext}\n disabled={this.props.resultCount <= 0}\n >\n <Icon iconSpec={<SvgChevronRight />} />\n </button>\n </span>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"ResultSelector.js","sourceRoot":"","sources":["../../../../src/components-react/filtering/ResultSelector.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAwB7E;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK,CAAC,aAGzC;IAGC,gBAAgB;IAChB,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,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AC,KAAK,CAAC,kBAAkB,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI;qBAC7D,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACpC,QAAQ,EAAE,IAAI,CAAC,wBAAwB,EACvC,MAAM,EAAE,IAAI,CAAC,0BAA0B,EACvC,SAAS,EAAE,IAAI,CAAC,wBAAwB,GACxC,CACH,CAAC,CAAC,CAAC,CACF,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAC5B;gBACD,8BAAM,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,IACnD,IAAI,CAAC,QAAQ,CACT;gBACP,kCAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAQ,CAChC;YAEP,gCACE,SAAS,EAAC,wCAAwC,iBACtC,aAAa,EACzB,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC;gBAErC,oBAAC,IAAI,IAAC,QAAQ,EAAE,oBAAC,eAAe,OAAG,GAAI,CAChC,CACJ,CACR,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Filtering\n */\n\nimport \"./ResultSelector.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { UiComponents } from \"../UiComponents\";\nimport { SvgChevronLeft, SvgChevronRight } from \"@itwin/itwinui-icons-react\";\n\n/** [[ResultSelector]] React Component state\n * @internal\n */\ninterface ResultSelectorState {\n /** Currently selected result/entry index */\n selectedResultId: number;\n /** Input string */\n selectedResultEdit: string;\n /** Informs if selectedResult is currently being edited */\n selectedResultInEditMode: boolean;\n}\n\n/** [[ResultSelector]] React Component properties\n * @public\n */\nexport interface ResultSelectorProps extends CommonProps {\n /** Total number of results/entries */\n resultCount: number;\n /** Callback to currently selected result/entry change */\n onSelectedChanged: (index: number) => void;\n}\n\n/** Component for stepping through results/entries\n * @public\n */\nexport class ResultSelector extends React.PureComponent<\n ResultSelectorProps,\n ResultSelectorState\n> {\n private _ofLabel = UiComponents.translate(\"general.of\");\n\n /** @internal */\n constructor(props: ResultSelectorProps) {\n super(props);\n this.state = {\n selectedResultId: props.resultCount ? 1 : 0,\n selectedResultEdit: \"\",\n selectedResultInEditMode: false,\n };\n }\n\n private _onClickPrevious = () => {\n if (this.state.selectedResultInEditMode) {\n this._onSelectedResultConfirmed();\n return;\n }\n if (this.state.selectedResultId > 1) {\n this.props.onSelectedChanged(this.state.selectedResultId - 1);\n this.setState((state) => ({\n selectedResultId: state.selectedResultId - 1,\n }));\n }\n };\n\n private _onClickNext = () => {\n if (this.state.selectedResultInEditMode) {\n this._onSelectedResultConfirmed();\n return;\n }\n if (this.state.selectedResultId < this.props.resultCount) {\n this.props.onSelectedChanged(this.state.selectedResultId + 1);\n this.setState((state) => ({\n selectedResultId: state.selectedResultId + 1,\n }));\n }\n };\n\n private get _maxSelectedResultInputLength() {\n return this.props.resultCount.toString().length;\n }\n\n private _onSelectedResultChanged = (\n event: React.ChangeEvent<HTMLInputElement>\n ) => {\n if (event.target.value.length <= this._maxSelectedResultInputLength)\n this.setState({ selectedResultEdit: event.target.value });\n };\n\n private _onSelectedResultConfirmed = () => {\n let selectedId = +this.state.selectedResultEdit;\n if (selectedId > this.props.resultCount)\n selectedId = this.props.resultCount;\n else if (selectedId < 1) selectedId = 1;\n\n this.setState({\n selectedResultInEditMode: false,\n selectedResultId: selectedId,\n });\n this.props.onSelectedChanged(selectedId);\n };\n\n private _onSelectedResultClick = () => {\n this.setState((state) => ({\n selectedResultInEditMode: true,\n selectedResultEdit: state.selectedResultId.toString(),\n }));\n };\n\n private _onSelectedResultKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === Key.Enter.valueOf()) this._onSelectedResultConfirmed();\n };\n\n /** @internal */\n public override componentDidMount() {\n this.props.onSelectedChanged(this.props.resultCount ? 1 : 0);\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: ResultSelectorProps) {\n if (this.props.resultCount !== prevProps.resultCount) {\n this.props.onSelectedChanged(this.props.resultCount ? 1 : 0);\n }\n }\n\n /** @internal */\n public override render() {\n return (\n <span\n className={classnames(\n \"components-result-selector\",\n this.props.className\n )}\n style={this.props.style}\n >\n <button\n className={classnames(\"components-result-selector-button\", \"icon\")}\n data-testid=\"previous-button\"\n onClick={this._onClickPrevious}\n disabled={this.props.resultCount <= 0}\n >\n <Icon iconSpec={<SvgChevronLeft />} />\n </button>\n\n <span\n style={{ pointerEvents: this.props.resultCount ? \"auto\" : \"none\" }}\n className=\"components-result-selector-current-result\"\n onClick={this._onSelectedResultClick}\n role=\"presentation\"\n >\n {this.state.selectedResultInEditMode ? (\n <input\n type=\"number\"\n style={{\n width: `${this.state.selectedResultEdit.length * 0.6 + 1}em`,\n }}\n value={this.state.selectedResultEdit}\n onChange={this._onSelectedResultChanged}\n onBlur={this._onSelectedResultConfirmed}\n onKeyDown={this._onSelectedResultKeyDown}\n />\n ) : (\n this.state.selectedResultId\n )}\n <span style={{ marginLeft: \"5px\", marginRight: \"5px\" }}>\n {this._ofLabel}\n </span>\n <span>{this.props.resultCount}</span>\n </span>\n\n <button\n className=\"components-result-selector-button icon\"\n data-testid=\"next-button\"\n onClick={this._onClickNext}\n disabled={this.props.resultCount <= 0}\n >\n <Icon iconSpec={<SvgChevronRight />} />\n </button>\n </span>\n );\n }\n}\n"]}
@@ -67,11 +67,11 @@ const ForwardRefParsedInput = React.forwardRef(function ForwardRefParsedInput({
67
67
  }, [updateValueFromString]);
68
68
  const handleKeyDown = React.useCallback((event) => {
69
69
  // istanbul ignore else
70
- if (event.key === Key.Enter) {
70
+ if (event.key === Key.Enter.valueOf()) {
71
71
  updateValueFromString(event.currentTarget.value);
72
72
  event.preventDefault();
73
73
  }
74
- if (event.key === Key.Escape) {
74
+ if (event.key === Key.Escape.valueOf()) {
75
75
  setFormattedValue(formatValue(currentValueRef.current));
76
76
  setHasBadInput(false);
77
77
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"ParsedInput.js","sourceRoot":"","sources":["../../../../src/components-react/inputs/ParsedInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,OAAO,oBAAoB,CAAC;AAoB5B,MAAM,qBAAqB,GAAG,KAAK,CAAC,UAAU,CAG5C,SAAS,qBAAqB,CAC9B,EACE,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,KAAK,EACL,QAAQ,GACT,EACD,GAAG;IAEH,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACnD,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,qBAAqB,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IACtE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CACxD,GAAG,EAAE,CAAC,qBAAqB,CAAC,OAAO,CACpC,CAAC;IACF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5D,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,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AK,mBACQ,yBAAyB,EACrC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,UAAU,EACrB,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAES,qBAAqB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Inputs\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { Key } from \"ts-key-enum\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { ParseResults } from \"@itwin/appui-abstract\";\nimport \"./ParsedInput.scss\";\n\n/** Props for [[ParsedInput]] control\n * @public\n */\nexport interface ParsedInputProps extends CommonProps {\n /** InitialValue which is used to restore input field if ESC is pressed */\n initialValue: number;\n /** Function used to format the value */\n formatValue: (value: number) => string;\n /** Function used to parse user input into a value */\n parseString: (stringValue: string) => ParseResults;\n /** Function to call when value is changed */\n onChange?: (newValue: number) => void;\n /** if readonly then only the formatValue function is used. */\n readonly?: boolean;\n /** Provides ability to return reference to HTMLInputElement */\n ref?: React.Ref<HTMLInputElement>;\n}\n\nconst ForwardRefParsedInput = React.forwardRef<\n HTMLInputElement,\n ParsedInputProps\n>(function ForwardRefParsedInput(\n {\n initialValue,\n formatValue,\n parseString,\n readonly,\n className,\n style,\n onChange,\n },\n ref\n) {\n const currentValueRef = React.useRef(initialValue);\n const isMountedRef = React.useRef(false);\n const lastFormattedValueRef = React.useRef(formatValue(initialValue));\n const [formattedValue, setFormattedValue] = React.useState(\n () => lastFormattedValueRef.current\n );\n const [hasBadInput, setHasBadInput] = React.useState(false);\n\n React.useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n // See if new initialValue props have changed since component mounted\n React.useEffect(() => {\n currentValueRef.current = initialValue;\n const currentFormattedValue = formatValue(currentValueRef.current);\n if (currentFormattedValue !== lastFormattedValueRef.current) {\n lastFormattedValueRef.current = currentFormattedValue;\n setFormattedValue(lastFormattedValueRef.current);\n setHasBadInput(false);\n }\n }, [formatValue, initialValue]);\n\n const handleChange = React.useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setFormattedValue(event.currentTarget.value);\n },\n []\n );\n\n const updateValueFromString = React.useCallback(\n (strVal: string) => {\n if (lastFormattedValueRef.current === strVal) return;\n\n const parseResults = parseString(strVal);\n // istanbul ignore else\n if (!parseResults.parseError) {\n // istanbul ignore else\n if (\n undefined !== parseResults.value &&\n typeof parseResults.value === \"number\"\n ) {\n const currentValue = parseResults.value;\n // istanbul ignore else\n if (currentValue !== currentValueRef.current) {\n currentValueRef.current = currentValue;\n onChange && onChange(currentValueRef.current);\n }\n // istanbul ignore else\n if (isMountedRef.current) {\n lastFormattedValueRef.current = formatValue(currentValue);\n setFormattedValue(lastFormattedValueRef.current);\n setHasBadInput(false);\n }\n }\n } else {\n setHasBadInput(true);\n }\n },\n [formatValue, onChange, parseString]\n );\n\n const handleBlur = React.useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n updateValueFromString(event.target.value);\n },\n [updateValueFromString]\n );\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (event.key === Key.Enter) {\n updateValueFromString(event.currentTarget.value);\n event.preventDefault();\n }\n if (event.key === Key.Escape) {\n setFormattedValue(formatValue(currentValueRef.current));\n setHasBadInput(false);\n event.preventDefault();\n }\n },\n [formatValue, updateValueFromString]\n );\n\n const classNames = classnames(\n className,\n \"components-parsed-input\",\n hasBadInput && \"components-parsed-input-has-error\"\n );\n\n return (\n <Input\n data-testid=\"components-parsed-input\"\n ref={ref}\n style={style}\n className={classNames}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n onChange={handleChange}\n value={formattedValue}\n disabled={readonly}\n size=\"small\"\n />\n );\n});\n\n/** Generic Input component that requires formatting and parsing functions to be passed in as props.\n * @public\n */\nexport const ParsedInput: (\n props: ParsedInputProps\n) => React.ReactElement | null = ForwardRefParsedInput;\n"]}
1
+ {"version":3,"file":"ParsedInput.js","sourceRoot":"","sources":["../../../../src/components-react/inputs/ParsedInput.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,OAAO,oBAAoB,CAAC;AAoB5B,MAAM,qBAAqB,GAAG,KAAK,CAAC,UAAU,CAG5C,SAAS,qBAAqB,CAC9B,EACE,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,KAAK,EACL,QAAQ,GACT,EACD,GAAG;IAEH,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACnD,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,qBAAqB,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IACtE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CACxD,GAAG,EAAE,CAAC,qBAAqB,CAAC,OAAO,CACpC,CAAC;IACF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC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CACrC,CAAC;IAEF,MAAM,UAAU,GAAG,UAAU,CAC3B,SAAS,EACT,yBAAyB,EACzB,WAAW,IAAI,mCAAmC,CACnD,CAAC;IAEF,OAAO,CACL,oBAAC,KAAK,mBACQ,yBAAyB,EACrC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,UAAU,EACrB,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAES,qBAAqB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Inputs\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { Key } from \"ts-key-enum\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { ParseResults } from \"@itwin/appui-abstract\";\nimport \"./ParsedInput.scss\";\n\n/** Props for [[ParsedInput]] control\n * @public\n */\nexport interface ParsedInputProps extends CommonProps {\n /** InitialValue which is used to restore input field if ESC is pressed */\n initialValue: number;\n /** Function used to format the value */\n formatValue: (value: number) => string;\n /** Function used to parse user input into a value */\n parseString: (stringValue: string) => ParseResults;\n /** Function to call when value is changed */\n onChange?: (newValue: number) => void;\n /** if readonly then only the formatValue function is used. */\n readonly?: boolean;\n /** Provides ability to return reference to HTMLInputElement */\n ref?: React.Ref<HTMLInputElement>;\n}\n\nconst ForwardRefParsedInput = React.forwardRef<\n HTMLInputElement,\n ParsedInputProps\n>(function ForwardRefParsedInput(\n {\n initialValue,\n formatValue,\n parseString,\n readonly,\n className,\n style,\n onChange,\n },\n ref\n) {\n const currentValueRef = React.useRef(initialValue);\n const isMountedRef = React.useRef(false);\n const lastFormattedValueRef = React.useRef(formatValue(initialValue));\n const [formattedValue, setFormattedValue] = React.useState(\n () => lastFormattedValueRef.current\n );\n const [hasBadInput, setHasBadInput] = React.useState(false);\n\n React.useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n // See if new initialValue props have changed since component mounted\n React.useEffect(() => {\n currentValueRef.current = initialValue;\n const currentFormattedValue = formatValue(currentValueRef.current);\n if (currentFormattedValue !== lastFormattedValueRef.current) {\n lastFormattedValueRef.current = currentFormattedValue;\n setFormattedValue(lastFormattedValueRef.current);\n setHasBadInput(false);\n }\n }, [formatValue, initialValue]);\n\n const handleChange = React.useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setFormattedValue(event.currentTarget.value);\n },\n []\n );\n\n const updateValueFromString = React.useCallback(\n (strVal: string) => {\n if (lastFormattedValueRef.current === strVal) return;\n\n const parseResults = parseString(strVal);\n // istanbul ignore else\n if (!parseResults.parseError) {\n // istanbul ignore else\n if (\n undefined !== parseResults.value &&\n typeof parseResults.value === \"number\"\n ) {\n const currentValue = parseResults.value;\n // istanbul ignore else\n if (currentValue !== currentValueRef.current) {\n currentValueRef.current = currentValue;\n onChange && onChange(currentValueRef.current);\n }\n // istanbul ignore else\n if (isMountedRef.current) {\n lastFormattedValueRef.current = formatValue(currentValue);\n setFormattedValue(lastFormattedValueRef.current);\n setHasBadInput(false);\n }\n }\n } else {\n setHasBadInput(true);\n }\n },\n [formatValue, onChange, parseString]\n );\n\n const handleBlur = React.useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n updateValueFromString(event.target.value);\n },\n [updateValueFromString]\n );\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (event.key === Key.Enter.valueOf()) {\n updateValueFromString(event.currentTarget.value);\n event.preventDefault();\n }\n if (event.key === Key.Escape.valueOf()) {\n setFormattedValue(formatValue(currentValueRef.current));\n setHasBadInput(false);\n event.preventDefault();\n }\n },\n [formatValue, updateValueFromString]\n );\n\n const classNames = classnames(\n className,\n \"components-parsed-input\",\n hasBadInput && \"components-parsed-input-has-error\"\n );\n\n return (\n <Input\n data-testid=\"components-parsed-input\"\n ref={ref}\n style={style}\n className={classNames}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n onChange={handleChange}\n value={formattedValue}\n disabled={readonly}\n size=\"small\"\n />\n );\n});\n\n/** Generic Input component that requires formatting and parsing functions to be passed in as props.\n * @public\n */\nexport const ParsedInput: (\n props: ParsedInputProps\n) => React.ReactElement | null = ForwardRefParsedInput;\n"]}
@@ -16,7 +16,7 @@ export class DoublePropertyValueRenderer {
16
16
  /** Checks if the renderer can handle given property */
17
17
  canRender(record) {
18
18
  return (record.value.valueFormat === PropertyValueFormat.Primitive &&
19
- record.property.typename === StandardTypeNames.Double);
19
+ record.property.typename === StandardTypeNames.Double.valueOf());
20
20
  }
21
21
  /** Method that returns a JSX representation of PropertyRecord */
22
22
  render(record, context) {
@@ -1 +1 @@
1
- {"version":3,"file":"DoublePropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/properties/renderers/value/DoublePropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,2BAA2B;IACtC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS;YAC1D,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,iBAAiB,CAAC,MAAM,CACtD,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,GAC5C,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Properties\n */\n\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager\";\nimport { PrimitivePropertyValueRendererImpl } from \"./PrimitivePropertyValueRenderer\";\nimport { convertRecordToString } from \"./Common\";\n\n/** Default Double Property Renderer\n * @public\n */\nexport class DoublePropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return (\n record.value.valueFormat === PropertyValueFormat.Primitive &&\n record.property.typename === StandardTypeNames.Double\n );\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={convertRecordToString}\n />\n );\n }\n}\n"]}
1
+ {"version":3,"file":"DoublePropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/properties/renderers/value/DoublePropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,2BAA2B;IACtC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS;YAC1D,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE,CAChE,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,GAC5C,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Properties\n */\n\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager\";\nimport { PrimitivePropertyValueRendererImpl } from \"./PrimitivePropertyValueRenderer\";\nimport { convertRecordToString } from \"./Common\";\n\n/** Default Double Property Renderer\n * @public\n */\nexport class DoublePropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return (\n record.value.valueFormat === PropertyValueFormat.Primitive &&\n record.property.typename === StandardTypeNames.Double.valueOf()\n );\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={convertRecordToString}\n />\n );\n }\n}\n"]}
@@ -16,7 +16,7 @@ export class NavigationPropertyValueRenderer {
16
16
  /** Checks if the renderer can handle given property */
17
17
  canRender(record) {
18
18
  return (record.value.valueFormat === PropertyValueFormat.Primitive &&
19
- record.property.typename === StandardTypeNames.Navigation);
19
+ record.property.typename === StandardTypeNames.Navigation.valueOf());
20
20
  }
21
21
  /** Method that returns a JSX representation of PropertyRecord */
22
22
  render(record, context) {
@@ -1 +1 @@
1
- {"version":3,"file":"NavigationPropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/properties/renderers/value/NavigationPropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,+BAA+B;IAC1C,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS;YAC1D,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,iBAAiB,CAAC,UAAU,CAC1D,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,GAC5C,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Properties\n */\n\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager\";\nimport { PrimitivePropertyValueRendererImpl } from \"./PrimitivePropertyValueRenderer\";\nimport { convertRecordToString } from \"./Common\";\n\n/** Default Navigation Property Renderer\n * @public\n */\nexport class NavigationPropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return (\n record.value.valueFormat === PropertyValueFormat.Primitive &&\n record.property.typename === StandardTypeNames.Navigation\n );\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={convertRecordToString}\n />\n );\n }\n}\n"]}
1
+ {"version":3,"file":"NavigationPropertyValueRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/properties/renderers/value/NavigationPropertyValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,kCAAkC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,+BAA+B;IAC1C,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS;YAC1D,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,CACpE,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,kCAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,GAC5C,CACH,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Properties\n */\n\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager\";\nimport { PrimitivePropertyValueRendererImpl } from \"./PrimitivePropertyValueRenderer\";\nimport { convertRecordToString } from \"./Common\";\n\n/** Default Navigation Property Renderer\n * @public\n */\nexport class NavigationPropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return (\n record.value.valueFormat === PropertyValueFormat.Primitive &&\n record.property.typename === StandardTypeNames.Navigation.valueOf()\n );\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={convertRecordToString}\n />\n );\n }\n}\n"]}
@@ -133,7 +133,7 @@ export class TreeSelectionManager {
133
133
  }
134
134
  onNodeClicked(nodeId, event) {
135
135
  const selectionFunc = this._selectionHandler.createSelectionFunction(...this.createSelectionHandlers(nodeId));
136
- selectionFunc(event.shiftKey, event.ctrlKey);
136
+ selectionFunc(event.shiftKey, event.ctrlKey || event.metaKey);
137
137
  }
138
138
  onNodeMouseDown(nodeId) {
139
139
  this._selectionHandler.createDragAction(this.createSelectionHandlers(nodeId)[0], this._itemHandlers, nodeId);
@@ -1 +1 @@
1
- {"version":3,"file":"TreeSelectionManager.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/TreeSelectionManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAI9E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AA2B3B,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,SAAc;IAC7C,OAAO,CACL,SAAS;QACT,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,EAAE,KAAK,QAAQ,CACjC,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,oBAAoB;IAc/B,YACE,aAA4B,EAC5B,eAAuC;QANlC,uBAAkB,GAAG,IAAI,SAAS,EAA8B,CAAC;QACjE,wBAAmB,GAAG,IAAI,SAAS,EAA6B,CAAC;QACjE,oBAAe,GAAG,IAAI,SAAS,EAA2B,CAAC;QAuK1D,qBAAgB,GAAG,CACzB,CAAsB,EACtB,OAAoB,EACpB,SAAkB,EAClB,EAAE;YACF,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;YAC7D,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,eAAe,CAAC,EAAE;gBACtE,OAAO;aACR;YAED,MAAM,YAAY,GAAG,CAAC,IA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AG,EAAE,CAAC,MAAM;SACnB,CAAC;QAEF,OAAO,CAAC,qBAAqB,EAAE,sBAAsB,CAAC,CAAC;IACzD,CAAC;IAEM,aAAa,CAAC,KAA0B,EAAE,OAAoB;QACnE,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEM,WAAW,CAAC,KAA0B,EAAE,OAAoB;QACjE,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;CAkEF;AAID,SAAS,qBAAqB,CAC5B,SAAgC;IAEhC,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC;AACvC,CAAC;AAED,MAAM,WAAW;IAGf,YAAY,IAA+B;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,gCAAgC;IACzB,SAAS,KAAI,CAAC;IAErB,gCAAgC;IACzB,MAAM,KAAI,CAAC;IAElB,gCAAgC;IACzB,QAAQ,KAAI,CAAC;IAEpB,6CAA6C;IACtC,UAAU;QACf,uBAAuB;QACvB,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC;IAClC,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC;IAC9B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport type { Observable } from \"rxjs\";\nimport { Subject } from \"rxjs\";\nimport { BeUiEvent } from \"@itwin/core-bentley\";\nimport type {\n MultiSelectionHandler,\n SingleSelectionHandler,\n} from \"../../../common/selection/SelectionHandler\";\nimport { SelectionHandler } from \"../../../common/selection/SelectionHandler\";\nimport type { SelectionMode } from \"../../../common/selection/SelectionModes\";\nimport type { TreeActions } from \"../TreeActions\";\nimport type { TreeModelNode, VisibleTreeNodes } from \"../TreeModel\";\nimport { isTreeModelNode } from \"../TreeModel\";\nimport {\n isNavigationKey,\n ItemKeyboardNavigator,\n Orientation,\n} from \"@itwin/core-react\";\n\n/** @internal */\nexport interface SelectionReplacementEvent {\n selectedNodeIds: IndividualSelection | RangeSelection;\n}\n\n/** @internal */\nexport interface SelectionModificationEvent {\n selectedNodes: IndividualSelection | RangeSelection;\n deselectedNodes: IndividualSelection;\n}\n\n/** @internal */\nexport interface DragSelectionStartEvent {\n selectionChanges: Observable<SelectionModificationEvent>;\n}\n\n/** @internal */\nexport type IndividualSelection = string[];\n\n/** @internal */\nexport interface RangeSelection {\n from: string;\n to: string;\n}\n\n/** @internal */\nexport function isRangeSelection(selection: any): selection is RangeSelection {\n return (\n selection &&\n typeof selection.from === \"string\" &&\n typeof selection.to === \"string\"\n );\n}\n\n/** @internal */\nexport class TreeSelectionManager\n implements\n Pick<TreeActions, \"onNodeClicked\" | \"onNodeMouseDown\" | \"onNodeMouseMove\">\n{\n private _selectionHandler: SelectionHandler<Selection>;\n private _dragSelectionOperation?: Subject<SelectionModificationEvent>;\n private _itemHandlers: Array<Array<SingleSelectionHandler<string>>>;\n\n private _getVisibleNodes: () => VisibleTreeNodes;\n\n public onSelectionChanged = new BeUiEvent<SelectionModificationEvent>();\n public onSelectionReplaced = new BeUiEvent<SelectionReplacementEvent>();\n public onDragSelection = new BeUiEvent<DragSelectionStartEvent>();\n\n constructor(\n selectionMode: SelectionMode,\n getVisibleNodes: () => VisibleTreeNodes\n ) {\n this._getVisibleNodes = getVisibleNodes;\n\n const onItemsSelected = (selections: Selection[], replacement: boolean) => {\n // Assumes that `selections` will only contain either a list of\n // `IndividualSelection` items or a single `RangeSelection` item.\n if (isIndividualSelection(selections[0])) {\n if (replacement) {\n this.onSelectionReplaced.emit({\n selectedNodeIds: selections as IndividualSelection,\n });\n } else {\n this.onSelectionChanged.emit({\n selectedNodes: selections as IndividualSelection,\n deselectedNodes: [],\n });\n }\n } else {\n if (replacement) {\n this.onSelectionReplaced.emit({\n selectedNodeIds: selections[0],\n });\n } else {\n this.onSelectionChanged.emit({\n selectedNodes: selections[0],\n deselectedNodes: [],\n });\n }\n }\n };\n\n const onItemsDeselected = (deselections: Selection[]) => {\n // Assumes that this will be always called with `IndividualSelection` items\n this.onSelectionChanged.emit({\n selectedNodes: [],\n deselectedNodes: deselections as IndividualSelection,\n });\n };\n\n this._selectionHandler = new SelectionHandler(\n selectionMode,\n onItemsSelected,\n onItemsDeselected\n );\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const _this = this;\n const itemHandlers = new Proxy(\n {},\n {\n get(_target, prop) {\n if (prop === \"length\") {\n return _this._getVisibleNodes().getNumNodes();\n }\n\n const index: number = +(prop as string);\n const node = _this.getVisibleNodeAtIndex(\n _this._getVisibleNodes(),\n index\n );\n return new ItemHandler(node);\n },\n }\n ) as Array<SingleSelectionHandler<string>>;\n this._itemHandlers = [itemHandlers];\n }\n\n private getVisibleNodeAtIndex(\n nodes: VisibleTreeNodes | undefined,\n index: number\n ): TreeModelNode | undefined {\n const foundNode =\n nodes !== undefined\n ? nodes.getAtIndex(index)\n : /* istanbul ignore next */ undefined;\n return isTreeModelNode(foundNode) ? foundNode : undefined;\n }\n\n public onNodeClicked(nodeId: string, event: React.MouseEvent) {\n const selectionFunc = this._selectionHandler.createSelectionFunction(\n ...this.createSelectionHandlers(nodeId)\n );\n selectionFunc(event.shiftKey, event.ctrlKey);\n }\n\n public onNodeMouseDown(nodeId: string) {\n this._selectionHandler.createDragAction(\n this.createSelectionHandlers(nodeId)[0],\n this._itemHandlers,\n nodeId\n );\n window.addEventListener(\n \"mouseup\",\n () => {\n /* istanbul ignore else */\n if (this._dragSelectionOperation) {\n this._selectionHandler.completeDragAction();\n this._dragSelectionOperation.complete();\n this._dragSelectionOperation = undefined;\n }\n },\n { once: true }\n );\n this._dragSelectionOperation = new Subject();\n this.onDragSelection.emit({\n selectionChanges: this._dragSelectionOperation,\n });\n }\n\n public onNodeMouseMove(nodeId: string) {\n this._selectionHandler.updateDragAction(nodeId);\n }\n\n private createSelectionHandlers(\n nodeId: string\n ): [MultiSelectionHandler<Selection>, SingleSelectionHandler<string>] {\n let deselectedAll = false;\n const multiSelectionHandler: MultiSelectionHandler<Selection> = {\n selectBetween: (item1, item2) => [\n { from: item1 as string, to: item2 as string },\n ],\n updateSelection: (selections, deselections) => {\n // Assumes `updateSelection` will never be called with selection ranges\n const selectedNodeIds = selections as string[];\n const deselectedNodeIds = deselections as string[];\n this._dragSelectionOperation!.next({\n selectedNodes: selectedNodeIds,\n deselectedNodes: deselectedNodeIds,\n });\n },\n deselectAll: () => {\n deselectedAll = true;\n },\n areEqual: (item1, item2) => item1 === item2,\n };\n\n const singleSelectionHandler: SingleSelectionHandler<string> = {\n preselect: () => {},\n select: () => {},\n deselect: () => {},\n isSelected: () => {\n if (deselectedAll) {\n return false;\n }\n\n const node = this._getVisibleNodes().getModel().getNode(nodeId);\n return node !== undefined && node.isSelected;\n },\n item: () => nodeId,\n };\n\n return [multiSelectionHandler, singleSelectionHandler];\n }\n\n public onTreeKeyDown(event: React.KeyboardEvent, actions: TreeActions): void {\n this._onKeyboardEvent(event, actions, true);\n }\n\n public onTreeKeyUp(event: React.KeyboardEvent, actions: TreeActions): void {\n this._onKeyboardEvent(event, actions, false);\n }\n\n private _onKeyboardEvent = (\n e: React.KeyboardEvent,\n actions: TreeActions,\n isKeyDown: boolean\n ) => {\n const processedNodeId = this._selectionHandler.processedItem;\n if (!isNavigationKey(e.key) || !isIndividualSelection(processedNodeId)) {\n return;\n }\n\n const isExpandable = (node: TreeModelNode): boolean =>\n !node.isLoading && node.numChildren !== 0;\n const isEditing = (node: TreeModelNode): boolean =>\n node.editingInfo !== undefined;\n\n const processedNode = this._getVisibleNodes()\n .getModel()\n .getNode(processedNodeId);\n\n // istanbul ignore if\n if (!processedNode || isEditing(processedNode)) return;\n\n const handleKeyboardSelectItem = (index: number) => {\n const node = this.getVisibleNodeAtIndex(this._getVisibleNodes(), index);\n // istanbul ignore if\n if (!node || isEditing(node)) return;\n\n const selectionFunc = this._selectionHandler.createSelectionFunction(\n ...this.createSelectionHandlers(node.id)\n );\n selectionFunc(e.shiftKey, e.ctrlKey);\n };\n const handleKeyboardActivateItem = (_index: number) => {\n if (isExpandable(processedNode)) {\n if (!processedNode.isExpanded) actions.onNodeExpanded(processedNode.id);\n else actions.onNodeCollapsed(processedNode.id);\n } else {\n actions.onNodeEditorActivated(processedNode.id);\n }\n };\n const handleCrossAxisArrowKey = (forward: boolean) => {\n if (!isExpandable(processedNode)) return;\n\n if (forward && !processedNode.isExpanded)\n actions.onNodeExpanded(processedNode.id);\n else if (!forward && processedNode.isExpanded)\n actions.onNodeCollapsed(processedNode.id);\n };\n\n const itemKeyboardNavigator = new ItemKeyboardNavigator(\n handleKeyboardSelectItem,\n handleKeyboardActivateItem\n );\n itemKeyboardNavigator.orientation = Orientation.Vertical;\n itemKeyboardNavigator.crossAxisArrowKeyHandler = handleCrossAxisArrowKey;\n itemKeyboardNavigator.allowWrap = false;\n itemKeyboardNavigator.itemCount = this._getVisibleNodes().getNumNodes();\n\n const processedNodeIndex =\n this._getVisibleNodes().getIndexOfNode(processedNodeId);\n isKeyDown\n ? itemKeyboardNavigator.handleKeyDownEvent(e, processedNodeIndex)\n : itemKeyboardNavigator.handleKeyUpEvent(e, processedNodeIndex);\n };\n}\n\ntype Selection = string | RangeSelection;\n\nfunction isIndividualSelection(\n selection: Selection | undefined\n): selection is string {\n return typeof selection === \"string\";\n}\n\nclass ItemHandler implements SingleSelectionHandler<string> {\n private _node: TreeModelNode | undefined;\n\n constructor(node: TreeModelNode | undefined) {\n this._node = node;\n }\n\n /* istanbul ignore next: noop */\n public preselect() {}\n\n /* istanbul ignore next: noop */\n public select() {}\n\n /* istanbul ignore next: noop */\n public deselect() {}\n\n // eslint-disable-next-line @itwin/prefer-get\n public isSelected(): boolean {\n // istanbul ignore next\n return !!this._node?.isSelected;\n }\n\n public item(): string {\n return this._node?.id ?? \"\";\n }\n}\n"]}
1
+ {"version":3,"file":"TreeSelectionManager.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/TreeSelectionManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAI9E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AA2B3B,gBAAgB;AAChB,MAAM,UAAU,gBAAgB,CAAC,SAAc;IAC7C,OAAO,CACL,SAAS;QACT,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,EAAE,KAAK,QAAQ,CACjC,CAAC;AACJ,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,oBAAoB;IAc/B,YACE,aAA4B,EAC5B,eAAuC;QANlC,uBAAkB,GAAG,IAAI,SAAS,EAA8B,CAAC;QACjE,wBAAmB,GAAG,IAAI,SAAS,EAA6B,CAAC;QACjE,oBAAe,GAAG,IAAI,SAAS,EAA2B,CAAC;QAuK1D,qBAAgB,GAAG,CACzB,CAAsB,EACtB,OAAoB,EACpB,SAAkB,EAClB,EAAE;YACF,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;YAC7D,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,eAAe,CAAC,EAAE;gBACtE,OAAO;aACR;YAED,MAAM,YAAY,GAAG,CAAC,IAAmB,EAAW,EAAE,CACpD,CAAC,IAAI,CAAC,SAAS,IAAI,IAA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QAEF,OAAO,CAAC,qBAAqB,EAAE,sBAAsB,CAAC,CAAC;IACzD,CAAC;IAEM,aAAa,CAAC,KAA0B,EAAE,OAAoB;QACnE,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEM,WAAW,CAAC,KAA0B,EAAE,OAAoB;QACjE,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;CAkEF;AAID,SAAS,qBAAqB,CAC5B,SAAgC;IAEhC,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC;AACvC,CAAC;AAED,MAAM,WAAW;IAGf,YAAY,IAA+B;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,gCAAgC;IACzB,SAAS,KAAI,CAAC;IAErB,gCAAgC;IACzB,MAAM,KAAI,CAAC;IAElB,gCAAgC;IACzB,QAAQ,KAAI,CAAC;IAEpB,6CAA6C;IACtC,UAAU;QACf,uBAAuB;QACvB,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC;IAClC,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC;IAC9B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport type { Observable } from \"rxjs\";\nimport { Subject } from \"rxjs\";\nimport { BeUiEvent } from \"@itwin/core-bentley\";\nimport type {\n MultiSelectionHandler,\n SingleSelectionHandler,\n} from \"../../../common/selection/SelectionHandler\";\nimport { SelectionHandler } from \"../../../common/selection/SelectionHandler\";\nimport type { SelectionMode } from \"../../../common/selection/SelectionModes\";\nimport type { TreeActions } from \"../TreeActions\";\nimport type { TreeModelNode, VisibleTreeNodes } from \"../TreeModel\";\nimport { isTreeModelNode } from \"../TreeModel\";\nimport {\n isNavigationKey,\n ItemKeyboardNavigator,\n Orientation,\n} from \"@itwin/core-react\";\n\n/** @internal */\nexport interface SelectionReplacementEvent {\n selectedNodeIds: IndividualSelection | RangeSelection;\n}\n\n/** @internal */\nexport interface SelectionModificationEvent {\n selectedNodes: IndividualSelection | RangeSelection;\n deselectedNodes: IndividualSelection;\n}\n\n/** @internal */\nexport interface DragSelectionStartEvent {\n selectionChanges: Observable<SelectionModificationEvent>;\n}\n\n/** @internal */\nexport type IndividualSelection = string[];\n\n/** @internal */\nexport interface RangeSelection {\n from: string;\n to: string;\n}\n\n/** @internal */\nexport function isRangeSelection(selection: any): selection is RangeSelection {\n return (\n selection &&\n typeof selection.from === \"string\" &&\n typeof selection.to === \"string\"\n );\n}\n\n/** @internal */\nexport class TreeSelectionManager\n implements\n Pick<TreeActions, \"onNodeClicked\" | \"onNodeMouseDown\" | \"onNodeMouseMove\">\n{\n private _selectionHandler: SelectionHandler<Selection>;\n private _dragSelectionOperation?: Subject<SelectionModificationEvent>;\n private _itemHandlers: Array<Array<SingleSelectionHandler<string>>>;\n\n private _getVisibleNodes: () => VisibleTreeNodes;\n\n public onSelectionChanged = new BeUiEvent<SelectionModificationEvent>();\n public onSelectionReplaced = new BeUiEvent<SelectionReplacementEvent>();\n public onDragSelection = new BeUiEvent<DragSelectionStartEvent>();\n\n constructor(\n selectionMode: SelectionMode,\n getVisibleNodes: () => VisibleTreeNodes\n ) {\n this._getVisibleNodes = getVisibleNodes;\n\n const onItemsSelected = (selections: Selection[], replacement: boolean) => {\n // Assumes that `selections` will only contain either a list of\n // `IndividualSelection` items or a single `RangeSelection` item.\n if (isIndividualSelection(selections[0])) {\n if (replacement) {\n this.onSelectionReplaced.emit({\n selectedNodeIds: selections as IndividualSelection,\n });\n } else {\n this.onSelectionChanged.emit({\n selectedNodes: selections as IndividualSelection,\n deselectedNodes: [],\n });\n }\n } else {\n if (replacement) {\n this.onSelectionReplaced.emit({\n selectedNodeIds: selections[0],\n });\n } else {\n this.onSelectionChanged.emit({\n selectedNodes: selections[0],\n deselectedNodes: [],\n });\n }\n }\n };\n\n const onItemsDeselected = (deselections: Selection[]) => {\n // Assumes that this will be always called with `IndividualSelection` items\n this.onSelectionChanged.emit({\n selectedNodes: [],\n deselectedNodes: deselections as IndividualSelection,\n });\n };\n\n this._selectionHandler = new SelectionHandler(\n selectionMode,\n onItemsSelected,\n onItemsDeselected\n );\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const _this = this;\n const itemHandlers = new Proxy(\n {},\n {\n get(_target, prop) {\n if (prop === \"length\") {\n return _this._getVisibleNodes().getNumNodes();\n }\n\n const index: number = +(prop as string);\n const node = _this.getVisibleNodeAtIndex(\n _this._getVisibleNodes(),\n index\n );\n return new ItemHandler(node);\n },\n }\n ) as Array<SingleSelectionHandler<string>>;\n this._itemHandlers = [itemHandlers];\n }\n\n private getVisibleNodeAtIndex(\n nodes: VisibleTreeNodes | undefined,\n index: number\n ): TreeModelNode | undefined {\n const foundNode =\n nodes !== undefined\n ? nodes.getAtIndex(index)\n : /* istanbul ignore next */ undefined;\n return isTreeModelNode(foundNode) ? foundNode : undefined;\n }\n\n public onNodeClicked(nodeId: string, event: React.MouseEvent) {\n const selectionFunc = this._selectionHandler.createSelectionFunction(\n ...this.createSelectionHandlers(nodeId)\n );\n selectionFunc(event.shiftKey, event.ctrlKey || event.metaKey);\n }\n\n public onNodeMouseDown(nodeId: string) {\n this._selectionHandler.createDragAction(\n this.createSelectionHandlers(nodeId)[0],\n this._itemHandlers,\n nodeId\n );\n window.addEventListener(\n \"mouseup\",\n () => {\n /* istanbul ignore else */\n if (this._dragSelectionOperation) {\n this._selectionHandler.completeDragAction();\n this._dragSelectionOperation.complete();\n this._dragSelectionOperation = undefined;\n }\n },\n { once: true }\n );\n this._dragSelectionOperation = new Subject();\n this.onDragSelection.emit({\n selectionChanges: this._dragSelectionOperation,\n });\n }\n\n public onNodeMouseMove(nodeId: string) {\n this._selectionHandler.updateDragAction(nodeId);\n }\n\n private createSelectionHandlers(\n nodeId: string\n ): [MultiSelectionHandler<Selection>, SingleSelectionHandler<string>] {\n let deselectedAll = false;\n const multiSelectionHandler: MultiSelectionHandler<Selection> = {\n selectBetween: (item1, item2) => [\n { from: item1 as string, to: item2 as string },\n ],\n updateSelection: (selections, deselections) => {\n // Assumes `updateSelection` will never be called with selection ranges\n const selectedNodeIds = selections as string[];\n const deselectedNodeIds = deselections as string[];\n this._dragSelectionOperation!.next({\n selectedNodes: selectedNodeIds,\n deselectedNodes: deselectedNodeIds,\n });\n },\n deselectAll: () => {\n deselectedAll = true;\n },\n areEqual: (item1, item2) => item1 === item2,\n };\n\n const singleSelectionHandler: SingleSelectionHandler<string> = {\n preselect: () => {},\n select: () => {},\n deselect: () => {},\n isSelected: () => {\n if (deselectedAll) {\n return false;\n }\n\n const node = this._getVisibleNodes().getModel().getNode(nodeId);\n return node !== undefined && node.isSelected;\n },\n item: () => nodeId,\n };\n\n return [multiSelectionHandler, singleSelectionHandler];\n }\n\n public onTreeKeyDown(event: React.KeyboardEvent, actions: TreeActions): void {\n this._onKeyboardEvent(event, actions, true);\n }\n\n public onTreeKeyUp(event: React.KeyboardEvent, actions: TreeActions): void {\n this._onKeyboardEvent(event, actions, false);\n }\n\n private _onKeyboardEvent = (\n e: React.KeyboardEvent,\n actions: TreeActions,\n isKeyDown: boolean\n ) => {\n const processedNodeId = this._selectionHandler.processedItem;\n if (!isNavigationKey(e.key) || !isIndividualSelection(processedNodeId)) {\n return;\n }\n\n const isExpandable = (node: TreeModelNode): boolean =>\n !node.isLoading && node.numChildren !== 0;\n const isEditing = (node: TreeModelNode): boolean =>\n node.editingInfo !== undefined;\n\n const processedNode = this._getVisibleNodes()\n .getModel()\n .getNode(processedNodeId);\n\n // istanbul ignore if\n if (!processedNode || isEditing(processedNode)) return;\n\n const handleKeyboardSelectItem = (index: number) => {\n const node = this.getVisibleNodeAtIndex(this._getVisibleNodes(), index);\n // istanbul ignore if\n if (!node || isEditing(node)) return;\n\n const selectionFunc = this._selectionHandler.createSelectionFunction(\n ...this.createSelectionHandlers(node.id)\n );\n selectionFunc(e.shiftKey, e.ctrlKey);\n };\n const handleKeyboardActivateItem = (_index: number) => {\n if (isExpandable(processedNode)) {\n if (!processedNode.isExpanded) actions.onNodeExpanded(processedNode.id);\n else actions.onNodeCollapsed(processedNode.id);\n } else {\n actions.onNodeEditorActivated(processedNode.id);\n }\n };\n const handleCrossAxisArrowKey = (forward: boolean) => {\n if (!isExpandable(processedNode)) return;\n\n if (forward && !processedNode.isExpanded)\n actions.onNodeExpanded(processedNode.id);\n else if (!forward && processedNode.isExpanded)\n actions.onNodeCollapsed(processedNode.id);\n };\n\n const itemKeyboardNavigator = new ItemKeyboardNavigator(\n handleKeyboardSelectItem,\n handleKeyboardActivateItem\n );\n itemKeyboardNavigator.orientation = Orientation.Vertical;\n itemKeyboardNavigator.crossAxisArrowKeyHandler = handleCrossAxisArrowKey;\n itemKeyboardNavigator.allowWrap = false;\n itemKeyboardNavigator.itemCount = this._getVisibleNodes().getNumNodes();\n\n const processedNodeIndex =\n this._getVisibleNodes().getIndexOfNode(processedNodeId);\n isKeyDown\n ? itemKeyboardNavigator.handleKeyDownEvent(e, processedNodeIndex)\n : itemKeyboardNavigator.handleKeyUpEvent(e, processedNodeIndex);\n };\n}\n\ntype Selection = string | RangeSelection;\n\nfunction isIndividualSelection(\n selection: Selection | undefined\n): selection is string {\n return typeof selection === \"string\";\n}\n\nclass ItemHandler implements SingleSelectionHandler<string> {\n private _node: TreeModelNode | undefined;\n\n constructor(node: TreeModelNode | undefined) {\n this._node = node;\n }\n\n /* istanbul ignore next: noop */\n public preselect() {}\n\n /* istanbul ignore next: noop */\n public select() {}\n\n /* istanbul ignore next: noop */\n public deselect() {}\n\n // eslint-disable-next-line @itwin/prefer-get\n public isSelected(): boolean {\n // istanbul ignore next\n return !!this._node?.isSelected;\n }\n\n public item(): string {\n return this._node?.id ?? \"\";\n }\n}\n"]}