@itwin/components-react 4.6.0 → 4.6.1

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 (170) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/components-react/common/DelayedSpinner.js +2 -3
  3. package/lib/cjs/components-react/common/DelayedSpinner.js.map +1 -1
  4. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +1 -2
  5. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  6. package/lib/cjs/components-react/converters/NumericTypeConverter.js +2 -4
  7. package/lib/cjs/components-react/converters/NumericTypeConverter.js.map +1 -1
  8. package/lib/cjs/components-react/converters/TypeConverter.js +1 -2
  9. package/lib/cjs/components-react/converters/TypeConverter.js.map +1 -1
  10. package/lib/cjs/components-react/editors/CustomNumberEditor.js +6 -8
  11. package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
  12. package/lib/cjs/components-react/editors/DateTimeEditor.js +2 -3
  13. package/lib/cjs/components-react/editors/DateTimeEditor.js.map +1 -1
  14. package/lib/cjs/components-react/editors/PopupButton.js +3 -4
  15. package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
  16. package/lib/cjs/components-react/editors/TextEditor.js +2 -4
  17. package/lib/cjs/components-react/editors/TextEditor.js.map +1 -1
  18. package/lib/cjs/components-react/favorite/FavoritePropertyList.js +3 -3
  19. package/lib/cjs/components-react/favorite/FavoritePropertyList.js.map +1 -1
  20. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +1 -2
  21. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  22. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
  23. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  24. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js +1 -1
  25. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  26. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js +2 -2
  27. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  28. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js +3 -4
  29. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  30. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  31. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  32. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js +2 -3
  33. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  34. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  35. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  36. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -2
  37. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  38. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +3 -6
  39. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  40. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -2
  41. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  42. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +3 -6
  43. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  44. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -2
  45. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  46. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +1 -2
  47. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  48. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -2
  49. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  50. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  51. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  52. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js +48 -54
  53. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  54. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js +11 -13
  55. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  56. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  57. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  58. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -2
  59. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  60. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +1 -2
  61. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  62. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  63. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  64. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +2 -3
  65. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  66. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  67. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  68. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  69. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  70. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +5 -7
  71. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  72. package/lib/cjs/components-react/selectable-content/SelectableContent.js +2 -3
  73. package/lib/cjs/components-react/selectable-content/SelectableContent.js.map +1 -1
  74. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js +4 -6
  75. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  76. package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js +5 -6
  77. package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js.map +1 -1
  78. package/lib/cjs/components-react/tree/controlled/TreeModel.js +7 -8
  79. package/lib/cjs/components-react/tree/controlled/TreeModel.js.map +1 -1
  80. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js +6 -8
  81. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  82. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js +1 -2
  83. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  84. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js +2 -4
  85. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  86. package/lib/esm/components-react/common/DelayedSpinner.js +2 -3
  87. package/lib/esm/components-react/common/DelayedSpinner.js.map +1 -1
  88. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +1 -2
  89. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  90. package/lib/esm/components-react/converters/NumericTypeConverter.js +2 -4
  91. package/lib/esm/components-react/converters/NumericTypeConverter.js.map +1 -1
  92. package/lib/esm/components-react/converters/TypeConverter.js +1 -2
  93. package/lib/esm/components-react/converters/TypeConverter.js.map +1 -1
  94. package/lib/esm/components-react/editors/CustomNumberEditor.js +6 -8
  95. package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
  96. package/lib/esm/components-react/editors/DateTimeEditor.js +2 -3
  97. package/lib/esm/components-react/editors/DateTimeEditor.js.map +1 -1
  98. package/lib/esm/components-react/editors/PopupButton.js +3 -4
  99. package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
  100. package/lib/esm/components-react/editors/TextEditor.js +2 -4
  101. package/lib/esm/components-react/editors/TextEditor.js.map +1 -1
  102. package/lib/esm/components-react/favorite/FavoritePropertyList.js +3 -3
  103. package/lib/esm/components-react/favorite/FavoritePropertyList.js.map +1 -1
  104. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +1 -2
  105. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  106. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
  107. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  108. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js +1 -1
  109. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  110. package/lib/esm/components-react/filter-builder/FilterBuilderState.js +2 -2
  111. package/lib/esm/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  112. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js +3 -4
  113. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  114. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  115. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  116. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js +2 -3
  117. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  118. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  119. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  120. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -2
  121. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  122. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +3 -6
  123. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  124. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -2
  125. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  126. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +3 -6
  127. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  128. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -2
  129. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  130. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +1 -2
  131. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  132. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -2
  133. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  134. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  135. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  136. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js +48 -54
  137. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  138. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js +11 -13
  139. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  140. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  141. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  142. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -2
  143. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  144. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +1 -2
  145. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  146. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  147. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  148. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +2 -3
  149. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  150. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  151. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  152. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  153. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  154. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +5 -7
  155. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  156. package/lib/esm/components-react/selectable-content/SelectableContent.js +2 -3
  157. package/lib/esm/components-react/selectable-content/SelectableContent.js.map +1 -1
  158. package/lib/esm/components-react/toolbar/InternalToolbarComponent.js +4 -6
  159. package/lib/esm/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  160. package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js +5 -6
  161. package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js.map +1 -1
  162. package/lib/esm/components-react/tree/controlled/TreeModel.js +7 -8
  163. package/lib/esm/components-react/tree/controlled/TreeModel.js.map +1 -1
  164. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js +6 -8
  165. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  166. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js +1 -2
  167. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  168. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js +2 -4
  169. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  170. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"TextEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/TextEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6BAA2B;AAC3B,4DAAoC;AACpC,6CAA+B;AAQ/B,0DAG+B;AAC/B,kDAAoD;AAEpD,wDAA6C;AAC7C,6EAA0E;AAE1E,kDAA+C;AAY/C;;GAEG;AACH,MAAa,UACX,SAAQ,KAAK,CAAC,aAAmD;IADnE;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,eAAU,GAAG,2BAAY,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,CAAC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AAa;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,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU;SACxD,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,iBAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG,CACV,oBAAC,sBAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,wBAAwB,GACpC,CACH,CAAC;SACH;aAAM;YACL,SAAS,GAAG,CACV,oBAAC,qBAAK,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;AA9LD,gCA8LC","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 type { InputProps } from \"@itwin/itwinui-react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { UiComponents } from \"../UiComponents\";\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 setFocus: 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,6BAA2B;AAC3B,4DAAoC;AACpC,6CAA+B;AAQ/B,0DAG+B;AAC/B,kDAAoD;AAEpD,wDAA6C;AAC7C,6EAA0E;AAE1E,kDAA+C;AAY/C;;GAEG;AACH,MAAa,UACX,SAAQ,KAAK,CAAC,aAAmD;IADnE;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,eAAU,GAAG,2BAAY,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;gBACj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D,gCA8LC","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 type { InputProps } from \"@itwin/itwinui-react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport { UiComponents } from \"../UiComponents\";\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 setFocus: 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"]}
@@ -39,12 +39,12 @@ const PropertyList_1 = require("../propertygrid/component/PropertyList");
39
39
  * @alpha
40
40
  */
41
41
  function FavoritePropertyList(props) {
42
- var _a, _b;
43
42
  const [listWidth, setListWidth] = React.useState();
44
43
  const onListResize = React.useCallback(setListWidth, [setListWidth]);
45
44
  if (props.propertyData.records.Favorite !== undefined) {
46
- const propertyValueRendererManager = (_a = props.propertyValueRendererManager) !== null && _a !== void 0 ? _a : ValueRendererManager_1.PropertyValueRendererManager.defaultManager;
47
- const orientation = (_b = props.orientation) !== null && _b !== void 0 ? _b : core_react_1.Orientation.Horizontal;
45
+ const propertyValueRendererManager = props.propertyValueRendererManager ??
46
+ ValueRendererManager_1.PropertyValueRendererManager.defaultManager;
47
+ const orientation = props.orientation ?? core_react_1.Orientation.Horizontal;
48
48
  return (React.createElement("div", { className: "components-favorite-property-list" },
49
49
  React.createElement(core_react_1.ResizableContainerObserver, { onResize: onListResize }),
50
50
  listWidth ? (React.createElement(PropertyList_1.PropertyList, { orientation: orientation, width: listWidth, properties: props.propertyData.records.Favorite, columnRatio: 1 / 3, propertyValueRendererManager: propertyValueRendererManager })) : null));
@@ -1 +1 @@
1
- {"version":3,"file":"FavoritePropertyList.js","sourceRoot":"","sources":["../../../../src/components-react/favorite/FavoritePropertyList.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,kDAA4E;AAC5E,6EAAkF;AAClF,yEAAsE;AAYtE;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAgC;;IACnE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAsB,CAAC;IACvE,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACrE,IAAI,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;QACrD,MAAM,4BAA4B,GAChC,MAAA,KAAK,CAAC,4BAA4B,mCAClC,mDAA4B,CAAC,cAAc,CAAC;QAC9C,MAAM,WAAW,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,wBAAW,CAAC,UAAU,CAAC;QAChE,OAAO,CACL,6BAAK,SAAS,EAAC,mCAAmC;YAChD,oBAAC,uCAA0B,IAAC,QAAQ,EAAE,YAAY,GAAI;YACrD,SAAS,CAAC,CAAC,CAAC,CACX,oBAAC,2BAAY,IACX,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,EAC/C,WAAW,EAAE,CAAC,GAAG,CAAC,EAClB,4BAA4B,EAAE,4BAA4B,GAC1D,CACH,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAxBD,oDAwBC","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 Favorite\n */\n\nimport * as React from \"react\";\nimport { Orientation, ResizableContainerObserver } from \"@itwin/core-react\";\nimport { PropertyValueRendererManager } from \"../properties/ValueRendererManager\";\nimport { PropertyList } from \"../propertygrid/component/PropertyList\";\nimport type { PropertyData } from \"../propertygrid/PropertyDataProvider\";\n\n/** Properties for [[FavoritePropertyList]] React component\n * @alpha\n */\nexport interface FavoritePropertyListProps {\n propertyData: PropertyData;\n propertyValueRendererManager?: PropertyValueRendererManager;\n orientation?: Orientation;\n}\n\n/** Favorite Property List React component\n * @alpha\n */\nexport function FavoritePropertyList(props: FavoritePropertyListProps) {\n const [listWidth, setListWidth] = React.useState<number | undefined>();\n const onListResize = React.useCallback(setListWidth, [setListWidth]);\n if (props.propertyData.records.Favorite !== undefined) {\n const propertyValueRendererManager =\n props.propertyValueRendererManager ??\n PropertyValueRendererManager.defaultManager;\n const orientation = props.orientation ?? Orientation.Horizontal;\n return (\n <div className=\"components-favorite-property-list\">\n <ResizableContainerObserver onResize={onListResize} />\n {listWidth ? (\n <PropertyList\n orientation={orientation}\n width={listWidth}\n properties={props.propertyData.records.Favorite}\n columnRatio={1 / 3}\n propertyValueRendererManager={propertyValueRendererManager}\n />\n ) : null}\n </div>\n );\n }\n return null;\n}\n"]}
1
+ {"version":3,"file":"FavoritePropertyList.js","sourceRoot":"","sources":["../../../../src/components-react/favorite/FavoritePropertyList.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,kDAA4E;AAC5E,6EAAkF;AAClF,yEAAsE;AAYtE;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAgC;IACnE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAsB,CAAC;IACvE,MAAM,YAAY,GAAG,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACrE,IAAI,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE;QACrD,MAAM,4BAA4B,GAChC,KAAK,CAAC,4BAA4B;YAClC,mDAA4B,CAAC,cAAc,CAAC;QAC9C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,wBAAW,CAAC,UAAU,CAAC;QAChE,OAAO,CACL,6BAAK,SAAS,EAAC,mCAAmC;YAChD,oBAAC,uCAA0B,IAAC,QAAQ,EAAE,YAAY,GAAI;YACrD,SAAS,CAAC,CAAC,CAAC,CACX,oBAAC,2BAAY,IACX,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,EAC/C,WAAW,EAAE,CAAC,GAAG,CAAC,EAClB,4BAA4B,EAAE,4BAA4B,GAC1D,CACH,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAxBD,oDAwBC","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 Favorite\n */\n\nimport * as React from \"react\";\nimport { Orientation, ResizableContainerObserver } from \"@itwin/core-react\";\nimport { PropertyValueRendererManager } from \"../properties/ValueRendererManager\";\nimport { PropertyList } from \"../propertygrid/component/PropertyList\";\nimport type { PropertyData } from \"../propertygrid/PropertyDataProvider\";\n\n/** Properties for [[FavoritePropertyList]] React component\n * @alpha\n */\nexport interface FavoritePropertyListProps {\n propertyData: PropertyData;\n propertyValueRendererManager?: PropertyValueRendererManager;\n orientation?: Orientation;\n}\n\n/** Favorite Property List React component\n * @alpha\n */\nexport function FavoritePropertyList(props: FavoritePropertyListProps) {\n const [listWidth, setListWidth] = React.useState<number | undefined>();\n const onListResize = React.useCallback(setListWidth, [setListWidth]);\n if (props.propertyData.records.Favorite !== undefined) {\n const propertyValueRendererManager =\n props.propertyValueRendererManager ??\n PropertyValueRendererManager.defaultManager;\n const orientation = props.orientation ?? Orientation.Horizontal;\n return (\n <div className=\"components-favorite-property-list\">\n <ResizableContainerObserver onResize={onListResize} />\n {listWidth ? (\n <PropertyList\n orientation={orientation}\n width={listWidth}\n properties={props.propertyData.records.Favorite}\n columnRatio={1 / 3}\n propertyValueRendererManager={propertyValueRendererManager}\n />\n ) : null}\n </div>\n );\n }\n return null;\n}\n"]}
@@ -39,10 +39,9 @@ const Operators_1 = require("./Operators");
39
39
  * @internal
40
40
  */
41
41
  function PropertyFilterBuilderRuleOperator(props) {
42
- var _a;
43
42
  const { operator, property, onChange } = props;
44
43
  const availableOperators = React.useMemo(() => (0, Operators_1.getPropertyFilterOperators)(property), [property]);
45
- const selectedOperator = (_a = availableOperators.find((op) => op === operator)) !== null && _a !== void 0 ? _a : availableOperators[0];
44
+ const selectedOperator = availableOperators.find((op) => op === operator) ?? availableOperators[0];
46
45
  React.useEffect(() => {
47
46
  onChange(selectedOperator);
48
47
  }, [onChange, selectedOperator]);
@@ -1 +1 @@
1
- {"version":3,"file":"FilterBuilderRuleOperator.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleOperator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,wDAA8C;AAE9C,2CAGqB;AAerB;;;GAGG;AACH,SAAgB,iCAAiC,CAC/C,KAA6C;;IAE7C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE/C,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CACtC,GAAG,EAAE,CAAC,IAAA,sCAA0B,EAAC,QAAQ,CAAC,EAC1C,CAAC,QAAQ,CAAC,CACX,CAAC;IACF,MAAM,gBAAgB,GACpB,MAAA,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,QAAQ,CAAC,mCAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAE5E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEjC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CACpC,GAAG,EAAE,CACH,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9B,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,IAAA,0CAA8B,EAAC,EAAE,CAAC;KAC1C,CAAC,CAAC,EACL,CAAC,kBAAkB,CAAC,CACrB,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,eAAe;QAC5B,oBAAC,sBAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,GACZ,CACE,CACP,CAAC;AACJ,CAAC;AAnCD,8EAmCC","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 * as React from \"react\";\nimport type { PropertyDescription } from \"@itwin/appui-abstract\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport type { PropertyFilterRuleOperator } from \"./Operators\";\nimport {\n getPropertyFilterOperatorLabel,\n getPropertyFilterOperators,\n} from \"./Operators\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleOperator]] component.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleOperatorProps {\n /** Currently selected operator. */\n operator?: PropertyFilterRuleOperator;\n /** Property used in rule for which this operator will be used. */\n property: PropertyDescription;\n /** Callback that is invoked when selected operator changes. */\n onChange: (operator: PropertyFilterRuleOperator) => void;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] operator selector.\n * @internal\n */\nexport function PropertyFilterBuilderRuleOperator(\n props: PropertyFilterBuilderRuleOperatorProps\n) {\n const { operator, property, onChange } = props;\n\n const availableOperators = React.useMemo(\n () => getPropertyFilterOperators(property),\n [property]\n );\n const selectedOperator =\n availableOperators.find((op) => op === operator) ?? availableOperators[0];\n\n React.useEffect(() => {\n onChange(selectedOperator);\n }, [onChange, selectedOperator]);\n\n const availableOptions = React.useMemo(\n () =>\n availableOperators.map((op) => ({\n value: op,\n label: getPropertyFilterOperatorLabel(op),\n })),\n [availableOperators]\n );\n\n return (\n <div className=\"rule-operator\">\n <Select\n options={availableOptions}\n value={selectedOperator}\n onChange={onChange}\n size=\"small\"\n />\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"FilterBuilderRuleOperator.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleOperator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,wDAA8C;AAE9C,2CAGqB;AAerB;;;GAGG;AACH,SAAgB,iCAAiC,CAC/C,KAA6C;IAE7C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE/C,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CACtC,GAAG,EAAE,CAAC,IAAA,sCAA0B,EAAC,QAAQ,CAAC,EAC1C,CAAC,QAAQ,CAAC,CACX,CAAC;IACF,MAAM,gBAAgB,GACpB,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAE5E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEjC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CACpC,GAAG,EAAE,CACH,kBAAkB,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9B,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,IAAA,0CAA8B,EAAC,EAAE,CAAC;KAC1C,CAAC,CAAC,EACL,CAAC,kBAAkB,CAAC,CACrB,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,eAAe;QAC5B,oBAAC,sBAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,GACZ,CACE,CACP,CAAC;AACJ,CAAC;AAnCD,8EAmCC","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 * as React from \"react\";\nimport type { PropertyDescription } from \"@itwin/appui-abstract\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport type { PropertyFilterRuleOperator } from \"./Operators\";\nimport {\n getPropertyFilterOperatorLabel,\n getPropertyFilterOperators,\n} from \"./Operators\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleOperator]] component.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleOperatorProps {\n /** Currently selected operator. */\n operator?: PropertyFilterRuleOperator;\n /** Property used in rule for which this operator will be used. */\n property: PropertyDescription;\n /** Callback that is invoked when selected operator changes. */\n onChange: (operator: PropertyFilterRuleOperator) => void;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] operator selector.\n * @internal\n */\nexport function PropertyFilterBuilderRuleOperator(\n props: PropertyFilterBuilderRuleOperatorProps\n) {\n const { operator, property, onChange } = props;\n\n const availableOperators = React.useMemo(\n () => getPropertyFilterOperators(property),\n [property]\n );\n const selectedOperator =\n availableOperators.find((op) => op === operator) ?? availableOperators[0];\n\n React.useEffect(() => {\n onChange(selectedOperator);\n }, [onChange, selectedOperator]);\n\n const availableOptions = React.useMemo(\n () =>\n availableOperators.map((op) => ({\n value: op,\n label: getPropertyFilterOperatorLabel(op),\n })),\n [availableOperators]\n );\n\n return (\n <div className=\"rule-operator\">\n <Select\n options={availableOptions}\n value={selectedOperator}\n onChange={onChange}\n size=\"small\"\n />\n </div>\n );\n}\n"]}
@@ -49,8 +49,8 @@ function PropertyFilterBuilderRuleProperty(props) {
49
49
  onSelectedPropertyChanged(properties.find((property) => property.name === name));
50
50
  }, [properties, onSelectedPropertyChanged]);
51
51
  React.useEffect(() => {
52
- const currentSelectedProperty = properties.find((property) => property.name === (selectedProperty === null || selectedProperty === void 0 ? void 0 : selectedProperty.name));
53
- if ((currentSelectedProperty === null || currentSelectedProperty === void 0 ? void 0 : currentSelectedProperty.name) !== (selectedProperty === null || selectedProperty === void 0 ? void 0 : selectedProperty.name))
52
+ const currentSelectedProperty = properties.find((property) => property.name === selectedProperty?.name);
53
+ if (currentSelectedProperty?.name !== selectedProperty?.name)
54
54
  onSelectedPropertyChanged(currentSelectedProperty);
55
55
  }, [properties, selectedProperty, onSelectedPropertyChanged]);
56
56
  const itemRenderer = React.useCallback((selectOption, { isSelected, id }) => {
@@ -59,7 +59,7 @@ function PropertyFilterBuilderRuleProperty(props) {
59
59
  : selectOption.label));
60
60
  }, [propertyRenderer]);
61
61
  return (React.createElement("div", { className: "rule-property" },
62
- React.createElement(itwinui_react_1.ComboBox, { options: selectOptions, onChange: onPropertyChanged, value: selectedProperty === null || selectedProperty === void 0 ? void 0 : selectedProperty.name, inputProps: {
62
+ React.createElement(itwinui_react_1.ComboBox, { options: selectOptions, onChange: onPropertyChanged, value: selectedProperty?.name, inputProps: {
63
63
  placeholder: UiComponents_1.UiComponents.translate("filterBuilder.chooseProperty"),
64
64
  disabled: isDisabled,
65
65
  size: "small",
@@ -1 +1 @@
1
- {"version":3,"file":"FilterBuilderRuleProperty.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleProperty.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAA0D;AAC1D,kDAA+C;AAmB/C;;;GAGG;AACH,SAAgB,iCAAiC,CAC/C,KAA6C;IAE7C,MAAM,EACJ,gBAAgB,EAChB,UAAU,EACV,yBAAyB,EACzB,gBAAgB,EAChB,UAAU,GACX,GAAG,KAAK,CAAC;IAEV,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CACjC,GAAG,EAAE,CACH,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC5B,EAAE,EAAE,QAAQ,CAAC,IAAI;QACjB,KAAK,EAAE,QAAQ,CAAC,YAAY;QAC5B,KAAK,EAAE,QAAQ,CAAC,IAAI;KACrB,CAAC,CAAC,EACL,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,CAAC,IAAY,EAAE,EAAE;QACf,yBAAyB,CACvB,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ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SAAS,CAAC,8BAA8B,CAAC;gBACnE,QAAQ,EAAE,UAAU;gBACpB,IAAI,EAAE,OAAO;aACd,EACD,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,IAAI,GAC1B,CACE,CACP,CAAC;AACJ,CAAC;AArED,8EAqEC","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 * as React from \"react\";\nimport type { PropertyDescription } from \"@itwin/appui-abstract\";\nimport type { ComboBoxProps, SelectOption } from \"@itwin/itwinui-react\";\nimport { ComboBox, MenuItem } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleProperty]] component.\n * @internal\n */\nexport interface PropertyFilterBuilderRulePropertyProps {\n /** List of available properties. */\n properties: PropertyDescription[];\n /** Currently selected property. */\n selectedProperty?: PropertyDescription;\n /** Callback that is invoked when selected property changes. */\n onSelectedPropertyChanged: (property?: PropertyDescription) => void;\n /** Custom renderer for property item inside selector. */\n propertyRenderer?: (name: string) => React.ReactNode;\n /** Specifies whether selector should be disabled or not. */\n isDisabled?: boolean;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] property selector.\n * @internal\n */\nexport function PropertyFilterBuilderRuleProperty(\n props: PropertyFilterBuilderRulePropertyProps\n) {\n const {\n selectedProperty,\n properties,\n onSelectedPropertyChanged,\n propertyRenderer,\n isDisabled,\n } = props;\n\n const selectOptions = React.useMemo<SelectOption<string>[]>(\n () =>\n properties.map((property) => ({\n id: property.name,\n label: property.displayLabel,\n value: property.name,\n })),\n [properties]\n );\n\n const onPropertyChanged = React.useCallback(\n (name: string) => {\n onSelectedPropertyChanged(\n properties.find((property) => property.name === name)\n );\n },\n [properties, onSelectedPropertyChanged]\n );\n\n React.useEffect(() => {\n const currentSelectedProperty = properties.find(\n (property) => property.name === selectedProperty?.name\n );\n if (currentSelectedProperty?.name !== selectedProperty?.name)\n onSelectedPropertyChanged(currentSelectedProperty);\n }, [properties, selectedProperty, onSelectedPropertyChanged]);\n\n const itemRenderer = React.useCallback<\n Required<ComboBoxProps<string>>[\"itemRenderer\"]\n >(\n (selectOption, { isSelected, id }) => {\n return (\n <MenuItem key={id} id={id} isSelected={isSelected}>\n {propertyRenderer\n ? propertyRenderer(selectOption.value)\n : selectOption.label}\n </MenuItem>\n );\n },\n [propertyRenderer]\n );\n\n return (\n <div className=\"rule-property\">\n <ComboBox\n options={selectOptions}\n onChange={onPropertyChanged}\n value={selectedProperty?.name}\n inputProps={{\n placeholder: UiComponents.translate(\"filterBuilder.chooseProperty\"),\n disabled: isDisabled,\n size: \"small\",\n }}\n itemRenderer={itemRenderer}\n enableVirtualization={true}\n />\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"FilterBuilderRuleProperty.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleProperty.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAA0D;AAC1D,kDAA+C;AAmB/C;;;GAGG;AACH,SAAgB,iCAAiC,CAC/C,KAA6C;IAE7C,MAAM,EACJ,gBAAgB,EAChB,UAAU,EACV,yBAAyB,EACzB,gBAAgB,EAChB,UAAU,GACX,GAAG,KAAK,CAAC;IAEV,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CACjC,GAAG,EAAE,CACH,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC5B,EAAE,EAAE,QAAQ,CAAC,IAAI;QACjB,KAAK,EAAE,QAAQ,CAAC,YAAY;QAC5B,KAAK,EAAE,QAAQ,CAAC,IAAI;KACrB,CAAC,CAAC,EACL,CAAC,UAAU,CAAC,CACb,CAAC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8B,CAAC;gBACnE,QAAQ,EAAE,UAAU;gBACpB,IAAI,EAAE,OAAO;aACd,EACD,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,IAAI,GAC1B,CACE,CACP,CAAC;AACJ,CAAC;AArED,8EAqEC","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 * as React from \"react\";\nimport type { PropertyDescription } from \"@itwin/appui-abstract\";\nimport type { ComboBoxProps, SelectOption } from \"@itwin/itwinui-react\";\nimport { ComboBox, MenuItem } from \"@itwin/itwinui-react\";\nimport { UiComponents } from \"../UiComponents\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleProperty]] component.\n * @internal\n */\nexport interface PropertyFilterBuilderRulePropertyProps {\n /** List of available properties. */\n properties: PropertyDescription[];\n /** Currently selected property. */\n selectedProperty?: PropertyDescription;\n /** Callback that is invoked when selected property changes. */\n onSelectedPropertyChanged: (property?: PropertyDescription) => void;\n /** Custom renderer for property item inside selector. */\n propertyRenderer?: (name: string) => React.ReactNode;\n /** Specifies whether selector should be disabled or not. */\n isDisabled?: boolean;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] property selector.\n * @internal\n */\nexport function PropertyFilterBuilderRuleProperty(\n props: PropertyFilterBuilderRulePropertyProps\n) {\n const {\n selectedProperty,\n properties,\n onSelectedPropertyChanged,\n propertyRenderer,\n isDisabled,\n } = props;\n\n const selectOptions = React.useMemo<SelectOption<string>[]>(\n () =>\n properties.map((property) => ({\n id: property.name,\n label: property.displayLabel,\n value: property.name,\n })),\n [properties]\n );\n\n const onPropertyChanged = React.useCallback(\n (name: string) => {\n onSelectedPropertyChanged(\n properties.find((property) => property.name === name)\n );\n },\n [properties, onSelectedPropertyChanged]\n );\n\n React.useEffect(() => {\n const currentSelectedProperty = properties.find(\n (property) => property.name === selectedProperty?.name\n );\n if (currentSelectedProperty?.name !== selectedProperty?.name)\n onSelectedPropertyChanged(currentSelectedProperty);\n }, [properties, selectedProperty, onSelectedPropertyChanged]);\n\n const itemRenderer = React.useCallback<\n Required<ComboBoxProps<string>>[\"itemRenderer\"]\n >(\n (selectOption, { isSelected, id }) => {\n return (\n <MenuItem key={id} id={id} isSelected={isSelected}>\n {propertyRenderer\n ? propertyRenderer(selectOption.value)\n : selectOption.label}\n </MenuItem>\n );\n },\n [propertyRenderer]\n );\n\n return (\n <div className=\"rule-property\">\n <ComboBox\n options={selectOptions}\n onChange={onPropertyChanged}\n value={selectedProperty?.name}\n inputProps={{\n placeholder: UiComponents.translate(\"filterBuilder.chooseProperty\"),\n disabled: isDisabled,\n size: \"small\",\n }}\n itemRenderer={itemRenderer}\n enableVirtualization={true}\n />\n </div>\n );\n}\n"]}
@@ -41,7 +41,7 @@ const EditorContainer_1 = require("../editors/EditorContainer");
41
41
  function PropertyFilterBuilderRuleValue(props) {
42
42
  const { value, property, onChange } = props;
43
43
  const propertyRecord = React.useMemo(() => {
44
- return new appui_abstract_1.PropertyRecord(value !== null && value !== void 0 ? value : { valueFormat: appui_abstract_1.PropertyValueFormat.Primitive }, property);
44
+ return new appui_abstract_1.PropertyRecord(value ?? { valueFormat: appui_abstract_1.PropertyValueFormat.Primitive }, property);
45
45
  }, [value, property]);
46
46
  const onValueChange = React.useCallback(({ newValue }) => {
47
47
  onChange(newValue);
@@ -1 +1 @@
1
- {"version":3,"file":"FilterBuilderRuleValue.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleValue.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,0DAA4E;AAE5E,gEAA6D;AA0B7D;;;GAGG;AACH,SAAgB,8BAA8B,CAC5C,KAA0C;IAE1C,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE5C,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxC,OAAO,IAAI,+BAAc,CACvB,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,WAAW,EAAE,oCAAmB,CAAC,SAAS,EAAE,EACvD,QAAQ,CACT,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEtB,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CACrC,CAAC,EAAE,QAAQ,EAAuB,EAAE,EAAE;QACpC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,CACL,oBAAC,iCAAe,IACd,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAE,CAAC,EAC7C,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,KAAK,EACf,oBAAoB,EAAE,KAAK,GAC3B,CACH,CAAC;AACJ,CAAC;AA5BD,wEA4BC","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 * as React from \"react\";\nimport type { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyRecord, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyUpdatedArgs } from \"../editors/EditorContainer\";\nimport { EditorContainer } from \"../editors/EditorContainer\";\nimport type { PropertyFilterRuleOperator } from \"./Operators\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleValue]] component.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleValueProps {\n /** Currently entered value. */\n value?: PropertyValue;\n /** Property used in rule to which this value will be compared to. */\n property: PropertyDescription;\n /** Callback that is invoked when value changes. */\n onChange: (value: PropertyValue) => void;\n}\n\n/**\n * Props for custom [[PropertyFilterBuilderRuleValue]] renderer.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleValueRendererProps\n extends PropertyFilterBuilderRuleValueProps {\n /** Current operator. */\n operator: PropertyFilterRuleOperator;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] value input.\n * @beta\n */\nexport function PropertyFilterBuilderRuleValue(\n props: PropertyFilterBuilderRuleValueProps\n) {\n const { value, property, onChange } = props;\n\n const propertyRecord = React.useMemo(() => {\n return new PropertyRecord(\n value ?? { valueFormat: PropertyValueFormat.Primitive },\n property\n );\n }, [value, property]);\n\n const onValueChange = React.useCallback(\n ({ newValue }: PropertyUpdatedArgs) => {\n onChange(newValue);\n },\n [onChange]\n );\n\n return (\n <EditorContainer\n propertyRecord={propertyRecord}\n onCancel={/* istanbul ignore next */ () => {}}\n onCommit={onValueChange}\n setFocus={false}\n shouldCommitOnChange={false}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"FilterBuilderRuleValue.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderRuleValue.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,0DAA4E;AAE5E,gEAA6D;AA0B7D;;;GAGG;AACH,SAAgB,8BAA8B,CAC5C,KAA0C;IAE1C,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE5C,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACxC,OAAO,IAAI,+BAAc,CACvB,KAAK,IAAI,EAAE,WAAW,EAAE,oCAAmB,CAAC,SAAS,EAAE,EACvD,QAAQ,CACT,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEtB,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CACrC,CAAC,EAAE,QAAQ,EAAuB,EAAE,EAAE;QACpC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,CACL,oBAAC,iCAAe,IACd,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAE,CAAC,EAC7C,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,KAAK,EACf,oBAAoB,EAAE,KAAK,GAC3B,CACH,CAAC;AACJ,CAAC;AA5BD,wEA4BC","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 * as React from \"react\";\nimport type { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyRecord, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyUpdatedArgs } from \"../editors/EditorContainer\";\nimport { EditorContainer } from \"../editors/EditorContainer\";\nimport type { PropertyFilterRuleOperator } from \"./Operators\";\n\n/**\n * Props for [[PropertyFilterBuilderRuleValue]] component.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleValueProps {\n /** Currently entered value. */\n value?: PropertyValue;\n /** Property used in rule to which this value will be compared to. */\n property: PropertyDescription;\n /** Callback that is invoked when value changes. */\n onChange: (value: PropertyValue) => void;\n}\n\n/**\n * Props for custom [[PropertyFilterBuilderRuleValue]] renderer.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleValueRendererProps\n extends PropertyFilterBuilderRuleValueProps {\n /** Current operator. */\n operator: PropertyFilterRuleOperator;\n}\n\n/**\n * Component that renders [[PropertyFilterBuilderRuleRenderer]] value input.\n * @beta\n */\nexport function PropertyFilterBuilderRuleValue(\n props: PropertyFilterBuilderRuleValueProps\n) {\n const { value, property, onChange } = props;\n\n const propertyRecord = React.useMemo(() => {\n return new PropertyRecord(\n value ?? { valueFormat: PropertyValueFormat.Primitive },\n property\n );\n }, [value, property]);\n\n const onValueChange = React.useCallback(\n ({ newValue }: PropertyUpdatedArgs) => {\n onChange(newValue);\n },\n [onChange]\n );\n\n return (\n <EditorContainer\n propertyRecord={propertyRecord}\n onCancel={/* istanbul ignore next */ () => {}}\n onCommit={onValueChange}\n setFocus={false}\n shouldCommitOnChange={false}\n />\n );\n}\n"]}
@@ -162,7 +162,7 @@ exports.isPropertyFilterBuilderRuleGroup = isPropertyFilterBuilderRuleGroup;
162
162
  * @beta
163
163
  */
164
164
  function usePropertyFilterBuilder(props) {
165
- const { initialFilter, ruleValidator } = props !== null && props !== void 0 ? props : {
165
+ const { initialFilter, ruleValidator } = props ?? {
166
166
  initialFilter: undefined,
167
167
  ruleValidator: undefined,
168
168
  };
@@ -172,7 +172,7 @@ function usePropertyFilterBuilder(props) {
172
172
  const [actions] = React.useState(() => new PropertyFilterBuilderActions(setState));
173
173
  const buildFilter = React.useCallback((options) => {
174
174
  const ruleErrors = validateRules(state.rootGroup, ruleValidator);
175
- if (!(options === null || options === void 0 ? void 0 : options.ignoreErrors)) {
175
+ if (!options?.ignoreErrors) {
176
176
  actions.setRuleErrorMessages(ruleErrors);
177
177
  }
178
178
  return ruleErrors.size === 0
@@ -1 +1 @@
1
- {"version":3,"file":"FilterBuilderState.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderState.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,iCAAgC;AAChC,6CAA+B;AAE/B,0DAA4D;AAC5D,sDAA2C;AAC3C,2CAAyD;AACzD,2CAGqB;AAErB,mCAAoD;AACpD,kDAA+C;AAoD/C;;;GAGG;AACH,MAAa,4BAA4B;IACvC,YACU,QAIC;QAJD,aAAQ,GAAR,QAAQ,CA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AM,EAAE,EAAE,CAAC,CAAC;SACjC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAC1B,aAA0C,EAC1C,cAA2C;IAE3C,OAAO,CACL,CAAC,2BAA2B,CAAC,aAAa,CAAC;QACzC,2BAA2B,CAAC,cAAc,CAAC,CAAC;QAC9C,CAAC,oBAAoB,CAAC,aAAa,CAAC;YAClC,oBAAoB,CAAC,cAAc,CAAC,CAAC,CACxC,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B,CAAC,QAAqC;IACxE,OAAO,CACL,QAAQ,KAAK,sCAA0B,CAAC,OAAO;QAC/C,QAAQ,KAAK,sCAA0B,CAAC,UAAU,CACnD,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAqC;IACjE,OAAO,CACL,QAAQ,KAAK,sCAA0B,CAAC,IAAI;QAC5C,QAAQ,KAAK,sCAA0B,CAAC,WAAW;QACnD,QAAQ,KAAK,sCAA0B,CAAC,OAAO;QAC/C,QAAQ,KAAK,sCAA0B,CAAC,cAAc,CACvD,CAAC;AACJ,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 { Draft } from \"immer\";\nimport { produce } from \"immer\";\nimport * as React from \"react\";\nimport type { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { PropertyFilterRuleOperator } from \"./Operators\";\nimport {\n isUnaryPropertyFilterOperator,\n PropertyFilterRuleGroupOperator,\n} from \"./Operators\";\nimport type { PropertyFilter, PropertyFilterRule } from \"./Types\";\nimport { isPropertyFilterRuleGroup } from \"./Types\";\nimport { UiComponents } from \"../UiComponents\";\n/**\n * Data structure that describes [[PropertyFilterBuilder]] component state.\n * @beta\n */\nexport interface PropertyFilterBuilderState {\n /** Root group of rules in [[PropertyFilterBuilder]] component. */\n rootGroup: PropertyFilterBuilderRuleGroup;\n}\n\n/**\n * Type that describes [[PropertyFilterBuilder]] component group item.\n * @beta\n */\nexport type PropertyFilterBuilderRuleGroupItem =\n | PropertyFilterBuilderRuleGroup\n | PropertyFilterBuilderRule;\n\n/**\n * Data structure that describes [[PropertyFilterBuilder]] component rule group.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleGroup {\n /** Id of this rule group. */\n id: string;\n /** Id of rule group that this group is nested in. */\n groupId?: string;\n /** Operator that should join items in this group. */\n operator: PropertyFilterRuleGroupOperator;\n /** Items in this group. */\n items: PropertyFilterBuilderRuleGroupItem[];\n}\n\n/**\n * Data structure that describes [[PropertyFilterBuilder]] component single rule.\n * @beta\n */\nexport interface PropertyFilterBuilderRule {\n /** Id of this rule. */\n id: string;\n /** Id of rule group that this rule is nested in. */\n groupId: string;\n /** Property used in this rule. */\n property?: PropertyDescription;\n /** Operator that should be used to compare property value. */\n operator?: PropertyFilterRuleOperator;\n /** Value that property should be compared to. */\n value?: PropertyValue;\n /** Error message of this rule. */\n errorMessage?: string;\n}\n\n/**\n * Actions for controlling [[PropertyFilterBuilder]] component state.\n * @beta\n */\nexport class PropertyFilterBuilderActions {\n constructor(\n private setState: (\n setter: (\n prevState: PropertyFilterBuilderState\n ) => PropertyFilterBuilderState\n ) => void\n ) {}\n\n private updateState(\n updater: (state: Draft<PropertyFilterBuilderState>) => void\n ) {\n this.setState(produce(updater));\n }\n\n /** Adds new rule or group of rules to the group specified by path. */\n public addItem(path: string[], itemType: \"RULE_GROUP\" | \"RULE\") {\n this.updateState((state) => {\n const parentGroup = findRuleGroup(state.rootGroup, path);\n if (!parentGroup) return;\n const item =\n itemType === \"RULE_GROUP\"\n ? createEmptyRuleGroup(parentGroup.id)\n : createEmptyRule(parentGroup.id);\n parentGroup.items.push(item);\n });\n }\n\n /** Removes item specified by path. */\n public removeItem(path: string[]) {\n function removeItemFromGroup(\n state: Draft<PropertyFilterBuilderState>,\n pathToItem: string[]\n ) {\n const pathToParent = pathToItem.slice(0, -1);\n const parentGroup = findRuleGroup(state.rootGroup, pathToParent);\n if (!parentGroup) return;\n const itemId = pathToItem[pathToItem.length - 1];\n const itemIndex = parentGroup.items.findIndex(\n (item) => item.id === itemId\n );\n if (itemIndex === -1) return;\n if (parentGroup.items.length === 1) {\n parentGroup.items[0] = createEmptyRule(parentGroup.id);\n return;\n }\n parentGroup.items.splice(itemIndex, 1);\n }\n\n this.updateState((state) => {\n removeItemFromGroup(state, path);\n });\n }\n\n /** Sets operator of rule group specified by the path. */\n public setRuleGroupOperator(\n path: string[],\n operator: PropertyFilterRuleGroupOperator\n ) {\n this.updateState((state) => {\n const group = findRuleGroup(state.rootGroup, path);\n if (!group) return;\n group.operator = operator;\n });\n }\n\n /** Sets property of rule specified by the path. */\n public setRuleProperty(path: string[], property?: PropertyDescription) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule) return;\n rule.property = property;\n rule.value = undefined;\n rule.errorMessage = undefined;\n });\n }\n\n /** Sets operator of rule specified by the path. */\n public setRuleOperator(path: string[], operator: PropertyFilterRuleOperator) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule) return;\n if (isUnaryPropertyFilterOperator(operator)) rule.value = undefined;\n if (\n operator !== rule.operator &&\n !areOperatorsSimilar(operator, rule.operator)\n ) {\n rule.value = undefined;\n }\n rule.operator = operator;\n });\n }\n\n /** Sets value of rule specified by the path. */\n public setRuleValue(path: string[], value: PropertyValue) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule) return;\n rule.value = value;\n });\n }\n\n /**\n * Sets error messages of the rules specified by id.\n * If rule id is not present in the map, then its error message will be cleared.\n */\n public setRuleErrorMessages(ruleIdsAndErrorMessages: Map<string, string>) {\n this.updateState((state) => {\n const setErrorMessages = (item: PropertyFilterBuilderRuleGroupItem) => {\n if (isPropertyFilterBuilderRuleGroup(item)) {\n item.items.forEach((itm) => {\n setErrorMessages(itm);\n });\n } else {\n item.errorMessage = ruleIdsAndErrorMessages.get(item.id);\n }\n };\n\n setErrorMessages(state.rootGroup);\n });\n }\n}\n\n/**\n * Function to check if supplied [[PropertyFilterBuilderRuleGroupItem]] is [[PropertyFilterBuilderRuleGroup]].\n * @beta\n */\nexport function isPropertyFilterBuilderRuleGroup(\n item: PropertyFilterBuilderRuleGroupItem\n): item is PropertyFilterBuilderRuleGroup {\n return (item as any).items !== undefined;\n}\n\n/**\n * Props for [[usePropertyFilterBuilder]]\n * @beta\n */\nexport interface UsePropertyFilterBuilderProps {\n /** Initial filter for [[PropertyFilterBuilder]] */\n initialFilter?: PropertyFilter;\n /** Custom rule validator to be used when [[UsePropertyFilterBuilderResult.buildFilter]] is invoked. Should return error message or `undefined`, if rule is valid. */\n ruleValidator?: (rule: PropertyFilterBuilderRule) => string | undefined;\n}\n\n/**\n * Options for [[UsePropertyFilterBuilderResult.buildFilter]].\n * @beta\n */\nexport interface BuildFilterOptions {\n /**\n * Specifies whether errors encountered while validating filter rules should be ignored and not persisted in state.\n * This is useful in case component needs to get filter matching rule validator but does not want to show errors in UI.\n */\n ignoreErrors?: boolean;\n}\n\n/**\n * Type for [[usePropertyFilterBuilder]] return object.\n * @beta\n */\nexport interface UsePropertyFilterBuilderResult {\n /** Root group of the [[PropertyFilterBuilder]]. */\n rootGroup: PropertyFilterBuilderRuleGroup;\n /** Actions for manipulating [[PropertyFilterBuilder]] state. */\n actions: PropertyFilterBuilderActions;\n /**\n * Validates and builds [[PropertyFilter]] based on current state. It uses [[defaultPropertyFilterBuilderRuleValidator]] or\n * custom validator provided through [[UsePropertyFilterBuilderProps]] to validate each rule.\n * @returns [[PropertyFilter]] if all rules are valid, `undefined` otherwise.\n */\n buildFilter: (options?: BuildFilterOptions) => PropertyFilter | undefined;\n}\n\n/**\n * Custom hook that creates state for [[PropertyFilterBuilder]] component. It creates empty state or initializes\n * state from supplied initial filter.\n * @beta\n */\nexport function usePropertyFilterBuilder(\n props?: UsePropertyFilterBuilderProps\n): UsePropertyFilterBuilderResult {\n const { initialFilter, ruleValidator } = props ?? {\n initialFilter: undefined,\n ruleValidator: undefined,\n };\n const [state, setState] = React.useState<PropertyFilterBuilderState>(\n initialFilter\n ? convertFilterToState(initialFilter)\n : { rootGroup: createEmptyRuleGroup() }\n );\n\n const [actions] = React.useState(\n () => new PropertyFilterBuilderActions(setState)\n );\n\n const buildFilter = React.useCallback(\n (options?: BuildFilterOptions) => {\n const ruleErrors = validateRules(state.rootGroup, ruleValidator);\n if (!options?.ignoreErrors) {\n actions.setRuleErrorMessages(ruleErrors);\n }\n\n return ruleErrors.size === 0\n ? buildPropertyFilter(state.rootGroup)\n : undefined;\n },\n [state.rootGroup, actions, ruleValidator]\n );\n return { rootGroup: state.rootGroup, actions, buildFilter };\n}\n\nfunction validateRules(\n rule: PropertyFilterBuilderRuleGroupItem,\n ruleValidator?: (item: PropertyFilterBuilderRule) => string | undefined\n) {\n const ruleIdsAndErrorMessages = new Map<string, string>();\n\n const validateRulesInner = (item: PropertyFilterBuilderRuleGroupItem) => {\n if (isPropertyFilterBuilderRuleGroup(item)) {\n item.items.forEach((itm) => {\n validateRulesInner(itm);\n });\n } else {\n const errorMessage = ruleValidator\n ? ruleValidator(item)\n : defaultPropertyFilterBuilderRuleValidator(item);\n if (errorMessage) ruleIdsAndErrorMessages.set(item.id, errorMessage);\n }\n };\n\n validateRulesInner(rule);\n\n return ruleIdsAndErrorMessages;\n}\n\n/**\n * Default rule validator.\n * @beta\n */\nexport function defaultPropertyFilterBuilderRuleValidator(\n item: PropertyFilterBuilderRule\n): string | undefined {\n if (\n item.property === undefined ||\n item.operator === undefined ||\n isUnaryPropertyFilterOperator(item.operator)\n ) {\n return undefined;\n }\n if (item.value === undefined) {\n return UiComponents.translate(\"filterBuilder.errorMessages.emptyValue\");\n }\n if (\n item.value.valueFormat === PropertyValueFormat.Primitive &&\n (item.value.value === undefined || item.value.value === \"\")\n ) {\n return UiComponents.translate(\"filterBuilder.errorMessages.emptyValue\");\n }\n return undefined;\n}\n\n/** @internal */\nexport function buildPropertyFilter(\n groupItem: PropertyFilterBuilderRuleGroupItem\n): PropertyFilter | undefined {\n if (isPropertyFilterBuilderRuleGroup(groupItem))\n return buildPropertyFilterFromRuleGroup(groupItem);\n return buildPropertyFilterFromRule(groupItem);\n}\n\nfunction buildPropertyFilterFromRuleGroup(\n rootGroup: PropertyFilterBuilderRuleGroup\n): PropertyFilter | undefined {\n const rules = new Array<PropertyFilter>();\n for (const item of rootGroup.items) {\n const rule = buildPropertyFilter(item);\n if (rule) rules.push(rule);\n }\n\n if (rules.length === 0) return undefined;\n\n if (rules.length === 1) return rules[0];\n\n return {\n operator: rootGroup.operator,\n rules,\n };\n}\n\nfunction buildPropertyFilterFromRule(\n rule: PropertyFilterBuilderRule\n): PropertyFilter | undefined {\n const { property, operator, value } = rule;\n if (!property || operator === undefined) return undefined;\n\n if (\n !isUnaryPropertyFilterOperator(operator) &&\n (!value ||\n value.valueFormat !== PropertyValueFormat.Primitive ||\n value.value === undefined)\n )\n return undefined;\n\n return { property, operator, value };\n}\n\nfunction createEmptyRule(groupId: string): PropertyFilterBuilderRule {\n return {\n id: Guid.createValue(),\n groupId,\n };\n}\n\nfunction createEmptyRuleGroup(\n groupId?: string\n): PropertyFilterBuilderRuleGroup {\n const id = Guid.createValue();\n return {\n id,\n groupId,\n operator: PropertyFilterRuleGroupOperator.And,\n items: [createEmptyRule(id)],\n };\n}\n\nfunction findRuleGroup(\n rootGroup: PropertyFilterBuilderRuleGroup,\n path: string[]\n): PropertyFilterBuilderRuleGroup | undefined {\n if (path.length === 0) return rootGroup;\n\n const [currentItemId, ...rest] = path;\n const currentItem = rootGroup.items.find((item) => item.id === currentItemId);\n if (!currentItem || !isPropertyFilterBuilderRuleGroup(currentItem))\n return undefined;\n\n return findRuleGroup(currentItem, rest);\n}\n\nfunction findRule(\n rootGroup: PropertyFilterBuilderRuleGroup,\n path: string[]\n): PropertyFilterBuilderRule | undefined {\n if (path.length === 0) return undefined;\n\n const [currentItemId, ...rest] = path;\n const currentItem = rootGroup.items.find((item) => item.id === currentItemId);\n if (!currentItem) return undefined;\n\n if (isPropertyFilterBuilderRuleGroup(currentItem))\n return findRule(currentItem, rest);\n\n return currentItem;\n}\n\nfunction getRuleGroupItem(\n filter: PropertyFilter,\n parentId: string\n): PropertyFilterBuilderRuleGroupItem {\n const id = Guid.createValue();\n if (isPropertyFilterRuleGroup(filter))\n return {\n id,\n groupId: parentId,\n operator: filter.operator,\n items: filter.rules.map((rule) => getRuleGroupItem(rule, id)),\n };\n return getRuleItem(filter, id);\n}\n\nfunction getRuleItem(filter: PropertyFilterRule, parentId: string) {\n return {\n id: Guid.createValue(),\n groupId: parentId,\n property: filter.property,\n operator: filter.operator,\n value: filter.value,\n };\n}\n\nfunction convertFilterToState(\n filter: PropertyFilter\n): PropertyFilterBuilderState {\n const id = Guid.createValue();\n if (isPropertyFilterRuleGroup(filter)) {\n return {\n rootGroup: {\n id,\n operator: filter.operator,\n items: filter.rules.map((rule) => getRuleGroupItem(rule, id)),\n },\n };\n }\n return {\n rootGroup: {\n id,\n operator: PropertyFilterRuleGroupOperator.And,\n items: [getRuleItem(filter, id)],\n },\n };\n}\n\nfunction areOperatorsSimilar(\n firstOperator?: PropertyFilterRuleOperator,\n secondOperator?: PropertyFilterRuleOperator\n) {\n return (\n (isOperatorEqualOrIsNotEqual(firstOperator) &&\n isOperatorEqualOrIsNotEqual(secondOperator)) ||\n (isInequalityOperator(firstOperator) &&\n isInequalityOperator(secondOperator))\n );\n}\n\nfunction isOperatorEqualOrIsNotEqual(operator?: PropertyFilterRuleOperator) {\n return (\n operator === PropertyFilterRuleOperator.IsEqual ||\n operator === PropertyFilterRuleOperator.IsNotEqual\n );\n}\n\nfunction isInequalityOperator(operator?: PropertyFilterRuleOperator) {\n return (\n operator === PropertyFilterRuleOperator.Less ||\n operator === PropertyFilterRuleOperator.LessOrEqual ||\n operator === PropertyFilterRuleOperator.Greater ||\n operator === PropertyFilterRuleOperator.GreaterOrEqual\n );\n}\n"]}
1
+ {"version":3,"file":"FilterBuilderState.js","sourceRoot":"","sources":["../../../../src/components-react/filter-builder/FilterBuilderState.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,iCAAgC;AAChC,6CAA+B;AAE/B,0DAA4D;AAC5D,sDAA2C;AAC3C,2CAAyD;AACzD,2CAGqB;AAErB,mCAAoD;AACpD,kDAA+C;AAoD/C;;;GAGG;AACH,MAAa,4BAA4B;IACvC,YACU,QAIC;QAJD,aAAQ,GAAR,QAAQ,CAIP;IACR,CAAC;IAEI,WAAW,CACjB,OAA2D;QAE3D,IAAI,CAAC,QAAQ,CAAC,IAAA,eAAO,EAAC,OAAO,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,sEAAsE;IAC/D,OAAO,CAAC,IAAc,EAAE,QAA+B;QAC5D,IAAI,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;YACzB,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACzD,IAAI,CAAC,WAAW;gBAAE,OAAO;YACzB,MAAM,IAAI,GACR,QAAQ,KAAK,YAAY;gBACvB,CAAC,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtC,CAAC,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACtC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,sCAAsC;IAC/B,UAAU,CAAC,IAAc;QAC9B,SAAS,mBAAmB,CAC1B,KAAwC,EACxC,UAAoB;YAEpB,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CA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IAC9B,IAAI,IAAA,iCAAyB,EAAC,MAAM,CAAC,EAAE;QACrC,OAAO;YACL,SAAS,EAAE;gBACT,EAAE;gBACF,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;aAC9D;SACF,CAAC;KACH;IACD,OAAO;QACL,SAAS,EAAE;YACT,EAAE;YACF,QAAQ,EAAE,2CAA+B,CAAC,GAAG;YAC7C,KAAK,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SACjC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAC1B,aAA0C,EAC1C,cAA2C;IAE3C,OAAO,CACL,CAAC,2BAA2B,CAAC,aAAa,CAAC;QACzC,2BAA2B,CAAC,cAAc,CAAC,CAAC;QAC9C,CAAC,oBAAoB,CAAC,aAAa,CAAC;YAClC,oBAAoB,CAAC,cAAc,CAAC,CAAC,CACxC,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B,CAAC,QAAqC;IACxE,OAAO,CACL,QAAQ,KAAK,sCAA0B,CAAC,OAAO;QAC/C,QAAQ,KAAK,sCAA0B,CAAC,UAAU,CACnD,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAqC;IACjE,OAAO,CACL,QAAQ,KAAK,sCAA0B,CAAC,IAAI;QAC5C,QAAQ,KAAK,sCAA0B,CAAC,WAAW;QACnD,QAAQ,KAAK,sCAA0B,CAAC,OAAO;QAC/C,QAAQ,KAAK,sCAA0B,CAAC,cAAc,CACvD,CAAC;AACJ,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 { Draft } from \"immer\";\nimport { produce } from \"immer\";\nimport * as React from \"react\";\nimport type { PropertyDescription, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { PropertyFilterRuleOperator } from \"./Operators\";\nimport {\n isUnaryPropertyFilterOperator,\n PropertyFilterRuleGroupOperator,\n} from \"./Operators\";\nimport type { PropertyFilter, PropertyFilterRule } from \"./Types\";\nimport { isPropertyFilterRuleGroup } from \"./Types\";\nimport { UiComponents } from \"../UiComponents\";\n/**\n * Data structure that describes [[PropertyFilterBuilder]] component state.\n * @beta\n */\nexport interface PropertyFilterBuilderState {\n /** Root group of rules in [[PropertyFilterBuilder]] component. */\n rootGroup: PropertyFilterBuilderRuleGroup;\n}\n\n/**\n * Type that describes [[PropertyFilterBuilder]] component group item.\n * @beta\n */\nexport type PropertyFilterBuilderRuleGroupItem =\n | PropertyFilterBuilderRuleGroup\n | PropertyFilterBuilderRule;\n\n/**\n * Data structure that describes [[PropertyFilterBuilder]] component rule group.\n * @beta\n */\nexport interface PropertyFilterBuilderRuleGroup {\n /** Id of this rule group. */\n id: string;\n /** Id of rule group that this group is nested in. */\n groupId?: string;\n /** Operator that should join items in this group. */\n operator: PropertyFilterRuleGroupOperator;\n /** Items in this group. */\n items: PropertyFilterBuilderRuleGroupItem[];\n}\n\n/**\n * Data structure that describes [[PropertyFilterBuilder]] component single rule.\n * @beta\n */\nexport interface PropertyFilterBuilderRule {\n /** Id of this rule. */\n id: string;\n /** Id of rule group that this rule is nested in. */\n groupId: string;\n /** Property used in this rule. */\n property?: PropertyDescription;\n /** Operator that should be used to compare property value. */\n operator?: PropertyFilterRuleOperator;\n /** Value that property should be compared to. */\n value?: PropertyValue;\n /** Error message of this rule. */\n errorMessage?: string;\n}\n\n/**\n * Actions for controlling [[PropertyFilterBuilder]] component state.\n * @beta\n */\nexport class PropertyFilterBuilderActions {\n constructor(\n private setState: (\n setter: (\n prevState: PropertyFilterBuilderState\n ) => PropertyFilterBuilderState\n ) => void\n ) {}\n\n private updateState(\n updater: (state: Draft<PropertyFilterBuilderState>) => void\n ) {\n this.setState(produce(updater));\n }\n\n /** Adds new rule or group of rules to the group specified by path. */\n public addItem(path: string[], itemType: \"RULE_GROUP\" | \"RULE\") {\n this.updateState((state) => {\n const parentGroup = findRuleGroup(state.rootGroup, path);\n if (!parentGroup) return;\n const item =\n itemType === \"RULE_GROUP\"\n ? createEmptyRuleGroup(parentGroup.id)\n : createEmptyRule(parentGroup.id);\n parentGroup.items.push(item);\n });\n }\n\n /** Removes item specified by path. */\n public removeItem(path: string[]) {\n function removeItemFromGroup(\n state: Draft<PropertyFilterBuilderState>,\n pathToItem: string[]\n ) {\n const pathToParent = pathToItem.slice(0, -1);\n const parentGroup = findRuleGroup(state.rootGroup, pathToParent);\n if (!parentGroup) return;\n const itemId = pathToItem[pathToItem.length - 1];\n const itemIndex = parentGroup.items.findIndex(\n (item) => item.id === itemId\n );\n if (itemIndex === -1) return;\n if (parentGroup.items.length === 1) {\n parentGroup.items[0] = createEmptyRule(parentGroup.id);\n return;\n }\n parentGroup.items.splice(itemIndex, 1);\n }\n\n this.updateState((state) => {\n removeItemFromGroup(state, path);\n });\n }\n\n /** Sets operator of rule group specified by the path. */\n public setRuleGroupOperator(\n path: string[],\n operator: PropertyFilterRuleGroupOperator\n ) {\n this.updateState((state) => {\n const group = findRuleGroup(state.rootGroup, path);\n if (!group) return;\n group.operator = operator;\n });\n }\n\n /** Sets property of rule specified by the path. */\n public setRuleProperty(path: string[], property?: PropertyDescription) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule) return;\n rule.property = property;\n rule.value = undefined;\n rule.errorMessage = undefined;\n });\n }\n\n /** Sets operator of rule specified by the path. */\n public setRuleOperator(path: string[], operator: PropertyFilterRuleOperator) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule) return;\n if (isUnaryPropertyFilterOperator(operator)) rule.value = undefined;\n if (\n operator !== rule.operator &&\n !areOperatorsSimilar(operator, rule.operator)\n ) {\n rule.value = undefined;\n }\n rule.operator = operator;\n });\n }\n\n /** Sets value of rule specified by the path. */\n public setRuleValue(path: string[], value: PropertyValue) {\n this.updateState((state) => {\n const rule = findRule(state.rootGroup, path);\n if (!rule) return;\n rule.value = value;\n });\n }\n\n /**\n * Sets error messages of the rules specified by id.\n * If rule id is not present in the map, then its error message will be cleared.\n */\n public setRuleErrorMessages(ruleIdsAndErrorMessages: Map<string, string>) {\n this.updateState((state) => {\n const setErrorMessages = (item: PropertyFilterBuilderRuleGroupItem) => {\n if (isPropertyFilterBuilderRuleGroup(item)) {\n item.items.forEach((itm) => {\n setErrorMessages(itm);\n });\n } else {\n item.errorMessage = ruleIdsAndErrorMessages.get(item.id);\n }\n };\n\n setErrorMessages(state.rootGroup);\n });\n }\n}\n\n/**\n * Function to check if supplied [[PropertyFilterBuilderRuleGroupItem]] is [[PropertyFilterBuilderRuleGroup]].\n * @beta\n */\nexport function isPropertyFilterBuilderRuleGroup(\n item: PropertyFilterBuilderRuleGroupItem\n): item is PropertyFilterBuilderRuleGroup {\n return (item as any).items !== undefined;\n}\n\n/**\n * Props for [[usePropertyFilterBuilder]]\n * @beta\n */\nexport interface UsePropertyFilterBuilderProps {\n /** Initial filter for [[PropertyFilterBuilder]] */\n initialFilter?: PropertyFilter;\n /** Custom rule validator to be used when [[UsePropertyFilterBuilderResult.buildFilter]] is invoked. Should return error message or `undefined`, if rule is valid. */\n ruleValidator?: (rule: PropertyFilterBuilderRule) => string | undefined;\n}\n\n/**\n * Options for [[UsePropertyFilterBuilderResult.buildFilter]].\n * @beta\n */\nexport interface BuildFilterOptions {\n /**\n * Specifies whether errors encountered while validating filter rules should be ignored and not persisted in state.\n * This is useful in case component needs to get filter matching rule validator but does not want to show errors in UI.\n */\n ignoreErrors?: boolean;\n}\n\n/**\n * Type for [[usePropertyFilterBuilder]] return object.\n * @beta\n */\nexport interface UsePropertyFilterBuilderResult {\n /** Root group of the [[PropertyFilterBuilder]]. */\n rootGroup: PropertyFilterBuilderRuleGroup;\n /** Actions for manipulating [[PropertyFilterBuilder]] state. */\n actions: PropertyFilterBuilderActions;\n /**\n * Validates and builds [[PropertyFilter]] based on current state. It uses [[defaultPropertyFilterBuilderRuleValidator]] or\n * custom validator provided through [[UsePropertyFilterBuilderProps]] to validate each rule.\n * @returns [[PropertyFilter]] if all rules are valid, `undefined` otherwise.\n */\n buildFilter: (options?: BuildFilterOptions) => PropertyFilter | undefined;\n}\n\n/**\n * Custom hook that creates state for [[PropertyFilterBuilder]] component. It creates empty state or initializes\n * state from supplied initial filter.\n * @beta\n */\nexport function usePropertyFilterBuilder(\n props?: UsePropertyFilterBuilderProps\n): UsePropertyFilterBuilderResult {\n const { initialFilter, ruleValidator } = props ?? {\n initialFilter: undefined,\n ruleValidator: undefined,\n };\n const [state, setState] = React.useState<PropertyFilterBuilderState>(\n initialFilter\n ? convertFilterToState(initialFilter)\n : { rootGroup: createEmptyRuleGroup() }\n );\n\n const [actions] = React.useState(\n () => new PropertyFilterBuilderActions(setState)\n );\n\n const buildFilter = React.useCallback(\n (options?: BuildFilterOptions) => {\n const ruleErrors = validateRules(state.rootGroup, ruleValidator);\n if (!options?.ignoreErrors) {\n actions.setRuleErrorMessages(ruleErrors);\n }\n\n return ruleErrors.size === 0\n ? buildPropertyFilter(state.rootGroup)\n : undefined;\n },\n [state.rootGroup, actions, ruleValidator]\n );\n return { rootGroup: state.rootGroup, actions, buildFilter };\n}\n\nfunction validateRules(\n rule: PropertyFilterBuilderRuleGroupItem,\n ruleValidator?: (item: PropertyFilterBuilderRule) => string | undefined\n) {\n const ruleIdsAndErrorMessages = new Map<string, string>();\n\n const validateRulesInner = (item: PropertyFilterBuilderRuleGroupItem) => {\n if (isPropertyFilterBuilderRuleGroup(item)) {\n item.items.forEach((itm) => {\n validateRulesInner(itm);\n });\n } else {\n const errorMessage = ruleValidator\n ? ruleValidator(item)\n : defaultPropertyFilterBuilderRuleValidator(item);\n if (errorMessage) ruleIdsAndErrorMessages.set(item.id, errorMessage);\n }\n };\n\n validateRulesInner(rule);\n\n return ruleIdsAndErrorMessages;\n}\n\n/**\n * Default rule validator.\n * @beta\n */\nexport function defaultPropertyFilterBuilderRuleValidator(\n item: PropertyFilterBuilderRule\n): string | undefined {\n if (\n item.property === undefined ||\n item.operator === undefined ||\n isUnaryPropertyFilterOperator(item.operator)\n ) {\n return undefined;\n }\n if (item.value === undefined) {\n return UiComponents.translate(\"filterBuilder.errorMessages.emptyValue\");\n }\n if (\n item.value.valueFormat === PropertyValueFormat.Primitive &&\n (item.value.value === undefined || item.value.value === \"\")\n ) {\n return UiComponents.translate(\"filterBuilder.errorMessages.emptyValue\");\n }\n return undefined;\n}\n\n/** @internal */\nexport function buildPropertyFilter(\n groupItem: PropertyFilterBuilderRuleGroupItem\n): PropertyFilter | undefined {\n if (isPropertyFilterBuilderRuleGroup(groupItem))\n return buildPropertyFilterFromRuleGroup(groupItem);\n return buildPropertyFilterFromRule(groupItem);\n}\n\nfunction buildPropertyFilterFromRuleGroup(\n rootGroup: PropertyFilterBuilderRuleGroup\n): PropertyFilter | undefined {\n const rules = new Array<PropertyFilter>();\n for (const item of rootGroup.items) {\n const rule = buildPropertyFilter(item);\n if (rule) rules.push(rule);\n }\n\n if (rules.length === 0) return undefined;\n\n if (rules.length === 1) return rules[0];\n\n return {\n operator: rootGroup.operator,\n rules,\n };\n}\n\nfunction buildPropertyFilterFromRule(\n rule: PropertyFilterBuilderRule\n): PropertyFilter | undefined {\n const { property, operator, value } = rule;\n if (!property || operator === undefined) return undefined;\n\n if (\n !isUnaryPropertyFilterOperator(operator) &&\n (!value ||\n value.valueFormat !== PropertyValueFormat.Primitive ||\n value.value === undefined)\n )\n return undefined;\n\n return { property, operator, value };\n}\n\nfunction createEmptyRule(groupId: string): PropertyFilterBuilderRule {\n return {\n id: Guid.createValue(),\n groupId,\n };\n}\n\nfunction createEmptyRuleGroup(\n groupId?: string\n): PropertyFilterBuilderRuleGroup {\n const id = Guid.createValue();\n return {\n id,\n groupId,\n operator: PropertyFilterRuleGroupOperator.And,\n items: [createEmptyRule(id)],\n };\n}\n\nfunction findRuleGroup(\n rootGroup: PropertyFilterBuilderRuleGroup,\n path: string[]\n): PropertyFilterBuilderRuleGroup | undefined {\n if (path.length === 0) return rootGroup;\n\n const [currentItemId, ...rest] = path;\n const currentItem = rootGroup.items.find((item) => item.id === currentItemId);\n if (!currentItem || !isPropertyFilterBuilderRuleGroup(currentItem))\n return undefined;\n\n return findRuleGroup(currentItem, rest);\n}\n\nfunction findRule(\n rootGroup: PropertyFilterBuilderRuleGroup,\n path: string[]\n): PropertyFilterBuilderRule | undefined {\n if (path.length === 0) return undefined;\n\n const [currentItemId, ...rest] = path;\n const currentItem = rootGroup.items.find((item) => item.id === currentItemId);\n if (!currentItem) return undefined;\n\n if (isPropertyFilterBuilderRuleGroup(currentItem))\n return findRule(currentItem, rest);\n\n return currentItem;\n}\n\nfunction getRuleGroupItem(\n filter: PropertyFilter,\n parentId: string\n): PropertyFilterBuilderRuleGroupItem {\n const id = Guid.createValue();\n if (isPropertyFilterRuleGroup(filter))\n return {\n id,\n groupId: parentId,\n operator: filter.operator,\n items: filter.rules.map((rule) => getRuleGroupItem(rule, id)),\n };\n return getRuleItem(filter, id);\n}\n\nfunction getRuleItem(filter: PropertyFilterRule, parentId: string) {\n return {\n id: Guid.createValue(),\n groupId: parentId,\n property: filter.property,\n operator: filter.operator,\n value: filter.value,\n };\n}\n\nfunction convertFilterToState(\n filter: PropertyFilter\n): PropertyFilterBuilderState {\n const id = Guid.createValue();\n if (isPropertyFilterRuleGroup(filter)) {\n return {\n rootGroup: {\n id,\n operator: filter.operator,\n items: filter.rules.map((rule) => getRuleGroupItem(rule, id)),\n },\n };\n }\n return {\n rootGroup: {\n id,\n operator: PropertyFilterRuleGroupOperator.And,\n items: [getRuleItem(filter, id)],\n },\n };\n}\n\nfunction areOperatorsSimilar(\n firstOperator?: PropertyFilterRuleOperator,\n secondOperator?: PropertyFilterRuleOperator\n) {\n return (\n (isOperatorEqualOrIsNotEqual(firstOperator) &&\n isOperatorEqualOrIsNotEqual(secondOperator)) ||\n (isInequalityOperator(firstOperator) &&\n isInequalityOperator(secondOperator))\n );\n}\n\nfunction isOperatorEqualOrIsNotEqual(operator?: PropertyFilterRuleOperator) {\n return (\n operator === PropertyFilterRuleOperator.IsEqual ||\n operator === PropertyFilterRuleOperator.IsNotEqual\n );\n}\n\nfunction isInequalityOperator(operator?: PropertyFilterRuleOperator) {\n return (\n operator === PropertyFilterRuleOperator.Less ||\n operator === PropertyFilterRuleOperator.LessOrEqual ||\n operator === PropertyFilterRuleOperator.Greater ||\n operator === PropertyFilterRuleOperator.GreaterOrEqual\n );\n}\n"]}
@@ -61,7 +61,7 @@ class CommonPropertyRenderer {
61
61
  return currentSize - minColumnLabelWidth;
62
62
  }
63
63
  static createNewDisplayValue(orientation, propertyRecord, indentation, propertyValueRendererManager, isExpanded, onExpansionToggled, onHeightChanged, highlight) {
64
- const highlightCallback = (highlight === null || highlight === void 0 ? void 0 : highlight.applyOnValue)
64
+ const highlightCallback = highlight?.applyOnValue
65
65
  ? CommonPropertyRenderer.createHighlightCallback(highlight, propertyRecord)
66
66
  : undefined;
67
67
  const rendererContext = {
@@ -85,10 +85,9 @@ class CommonPropertyRenderer {
85
85
  return displayValue;
86
86
  }
87
87
  static createHighlightCallback(highlight, propertyRecord) {
88
- var _a;
89
88
  const activeMatch = highlight.activeHighlight;
90
- const propertyName = activeMatch === null || activeMatch === void 0 ? void 0 : activeMatch.highlightedItemIdentifier;
91
- const matchIndex = (_a = activeMatch === null || activeMatch === void 0 ? void 0 : activeMatch.highlightIndex) !== null && _a !== void 0 ? _a : 0;
89
+ const propertyName = activeMatch?.highlightedItemIdentifier;
90
+ const matchIndex = activeMatch?.highlightIndex ?? 0;
92
91
  let labelMatches;
93
92
  if (highlight.applyOnLabel) {
94
93
  labelMatches = (0, countMatchesInString_1.countMatchesInString)(propertyRecord.property.displayLabel.toLowerCase(), highlight.highlightedText);
@@ -1 +1 @@
1
- {"version":3,"file":"CommonPropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/CommonPropertyRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,kDAAgD;AAChD,4EAAyE;AACzE,kEAA+D;AAG/D,kEAGiC;AAEjC;;GAEG;AACH,MAAa,sBAAsB;IAC1B,MAAM,CAAC,cAAc,CAC1B,WAAoB,EACpB,WAAyB,EACzB,KAAc,EACd,WAAoB,EACpB,mBAA4B;QAE5B,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,CAAC;QAE3B,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,SAAS,GAAG,CAAC,CAAC;QACpB,IACE,WAAW,KAAK,wBAAW,CAAC,UAAU;YACtC,CAAC,KAAK;YACN,CAAC,WAAW;YACZ,CAAC,mBAAmB;YAEpB,OAAO,WAAW,GAAG,SAAS,CAAC;QAEjC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,CAAC;QACnD,MAAM,eAAe,GAAG,mBAAmB,GAAG,SAAS,GAAG,WAAW,CAAC;QACtE,IAAI,WAAW,IAAI,eAAe;YAAE,OAAO,WAAW,GAAG,SAAS,CAAC;QAEnE,MAAM,SAAS,GACb,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QAClE,IAAI,WAAW,IAAI,SAAS;YAC1B,OAAO,CACL,SAAS;gBACT,IAAI,CAAC,cAAc,CACjB,WAAW,GAAG,CAAC,EACf,WAAW,EACX,KAAK,EACL,WAAW,EACX,mBAAmB,CACpB,CACF,CAAC;QAEJ,OAAO,WAAW,GAAG,mBAAmB,CAAC;IAC3C,CAAC;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C,YAAY,EAAE;YAC1B,YAAY,GAAG,IAAA,2CAAoB,EACjC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,EAClD,SAAS,CAAC,eAAe,CAC1B,CAAC;SACH;aAAM;YACL,YAAY,GAAG,CAAC,CAAC;SAClB;QAED,MAAM,gBAAgB,GACpB,cAAc,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;YAC7C,UAAU,GAAG,YAAY,IAAI,CAAC;YAC5B,CAAC,CAAC,UAAU,GAAG,YAAY;YAC3B,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAC1C,oBAAC,iCAAe,IACd,IAAI,EAAE,IAAI,EACV,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,SAAS,CAAC,eAAe,GACrC,CACH,CAAC;QAEF,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AApID,wDAoIC","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 { Orientation } from \"@itwin/core-react\";\nimport { countMatchesInString } from \"../../common/countMatchesInString\";\nimport { HighlightedText } from \"../../common/HighlightedText\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps\";\nimport type { PropertyValueRendererContext } from \"../ValueRendererManager\";\nimport {\n PropertyContainerType,\n PropertyValueRendererManager,\n} from \"../ValueRendererManager\";\n\n/**\n * @internal\n */\nexport class CommonPropertyRenderer {\n public static getLabelOffset(\n indentation?: number,\n orientation?: Orientation,\n width?: number,\n columnRatio?: number,\n minColumnLabelWidth?: number\n ): number {\n if (!indentation) return 0;\n\n const maxIndent = 17;\n const minIndent = 6;\n if (\n orientation !== Orientation.Horizontal ||\n !width ||\n !columnRatio ||\n !minColumnLabelWidth\n )\n return indentation * maxIndent;\n\n const currentSize = Math.ceil(width * columnRatio);\n const shrinkThreshold = minColumnLabelWidth + maxIndent * indentation;\n if (currentSize >= shrinkThreshold) return indentation * maxIndent;\n\n const minShrink =\n minColumnLabelWidth + minIndent + maxIndent * (indentation - 1);\n if (currentSize <= minShrink)\n return (\n minIndent +\n this.getLabelOffset(\n indentation - 1,\n orientation,\n width,\n columnRatio,\n minColumnLabelWidth\n )\n );\n\n return currentSize - minColumnLabelWidth;\n }\n\n public static createNewDisplayValue(\n orientation: Orientation,\n propertyRecord: PropertyRecord,\n indentation?: number,\n propertyValueRendererManager?: PropertyValueRendererManager,\n isExpanded?: boolean,\n onExpansionToggled?: () => void,\n onHeightChanged?: (newHeight: number) => void,\n highlight?: HighlightingComponentProps & {\n applyOnLabel: boolean;\n applyOnValue: boolean;\n }\n ) {\n const highlightCallback = highlight?.applyOnValue\n ? CommonPropertyRenderer.createHighlightCallback(\n highlight,\n propertyRecord\n )\n : undefined;\n const rendererContext: PropertyValueRendererContext = {\n orientation,\n containerType: PropertyContainerType.PropertyPane,\n isExpanded,\n onExpansionToggled,\n onHeightChanged,\n textHighlighter: highlightCallback,\n };\n\n let displayValue: React.ReactNode | undefined;\n if (propertyValueRendererManager)\n displayValue = propertyValueRendererManager.render(\n propertyRecord,\n rendererContext\n );\n else\n displayValue = PropertyValueRendererManager.defaultManager.render(\n propertyRecord,\n rendererContext\n );\n\n // Align value with label if orientation is vertical\n if (orientation === Orientation.Vertical)\n displayValue = (\n <span\n style={{\n paddingLeft: CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation\n ),\n }}\n >\n {displayValue}\n </span>\n );\n\n return displayValue;\n }\n\n private static createHighlightCallback(\n highlight: HighlightingComponentProps & { applyOnLabel: boolean },\n propertyRecord: PropertyRecord\n ) {\n const activeMatch = highlight.activeHighlight;\n const propertyName = activeMatch?.highlightedItemIdentifier;\n const matchIndex = activeMatch?.highlightIndex ?? 0;\n let labelMatches: number;\n\n if (highlight.applyOnLabel) {\n labelMatches = countMatchesInString(\n propertyRecord.property.displayLabel.toLowerCase(),\n highlight.highlightedText\n );\n } else {\n labelMatches = 0;\n }\n\n const activeMatchIndex =\n propertyRecord.property.name === propertyName &&\n matchIndex - labelMatches >= 0\n ? matchIndex - labelMatches\n : undefined;\n const highlightCallback = (text: string) => (\n <HighlightedText\n text={text}\n activeMatchIndex={activeMatchIndex}\n searchText={highlight.highlightedText}\n />\n );\n\n return highlightCallback;\n }\n}\n"]}
1
+ {"version":3,"file":"CommonPropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/CommonPropertyRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,kDAAgD;AAChD,4EAAyE;AACzE,kEAA+D;AAG/D,kEAGiC;AAEjC;;GAEG;AACH,MAAa,sBAAsB;IAC1B,MAAM,CAAC,cAAc,CAC1B,WAAoB,EACpB,WAAyB,EACzB,KAAc,EACd,WAAoB,EACpB,mBAA4B;QAE5B,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,CAAC;QAE3B,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,SAAS,GAAG,CAAC,CAAC;QACpB,IACE,WAAW,KAAK,wBAAW,CAAC,UAAU;YACtC,CAAC,KAAK;YACN,CAAC,WAAW;YACZ,CAAC,mBAAmB;YAEpB,OAAO,WAAW,GAAG,SAAS,CAAC;QAEjC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,CAAC;QACnD,MAAM,eAAe,GAAG,mBAAmB,GAAG,SAAS,GAAG,WAAW,CAAC;QACtE,IAAI,WAAW,IAAI,eAAe;YAAE,OAAO,WAAW,GAAG,SAAS,CAAC;QAEnE,MAAM,SAAS,GACb,mBAAmB,GAAG,SAAS,GAAG,SA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eAAe,CAAC;QAC9C,MAAM,YAAY,GAAG,WAAW,EAAE,yBAAyB,CAAC;QAC5D,MAAM,UAAU,GAAG,WAAW,EAAE,cAAc,IAAI,CAAC,CAAC;QACpD,IAAI,YAAoB,CAAC;QAEzB,IAAI,SAAS,CAAC,YAAY,EAAE;YAC1B,YAAY,GAAG,IAAA,2CAAoB,EACjC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,EAClD,SAAS,CAAC,eAAe,CAC1B,CAAC;SACH;aAAM;YACL,YAAY,GAAG,CAAC,CAAC;SAClB;QAED,MAAM,gBAAgB,GACpB,cAAc,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;YAC7C,UAAU,GAAG,YAAY,IAAI,CAAC;YAC5B,CAAC,CAAC,UAAU,GAAG,YAAY;YAC3B,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,CAC1C,oBAAC,iCAAe,IACd,IAAI,EAAE,IAAI,EACV,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,SAAS,CAAC,eAAe,GACrC,CACH,CAAC;QAEF,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AApID,wDAoIC","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 { Orientation } from \"@itwin/core-react\";\nimport { countMatchesInString } from \"../../common/countMatchesInString\";\nimport { HighlightedText } from \"../../common/HighlightedText\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps\";\nimport type { PropertyValueRendererContext } from \"../ValueRendererManager\";\nimport {\n PropertyContainerType,\n PropertyValueRendererManager,\n} from \"../ValueRendererManager\";\n\n/**\n * @internal\n */\nexport class CommonPropertyRenderer {\n public static getLabelOffset(\n indentation?: number,\n orientation?: Orientation,\n width?: number,\n columnRatio?: number,\n minColumnLabelWidth?: number\n ): number {\n if (!indentation) return 0;\n\n const maxIndent = 17;\n const minIndent = 6;\n if (\n orientation !== Orientation.Horizontal ||\n !width ||\n !columnRatio ||\n !minColumnLabelWidth\n )\n return indentation * maxIndent;\n\n const currentSize = Math.ceil(width * columnRatio);\n const shrinkThreshold = minColumnLabelWidth + maxIndent * indentation;\n if (currentSize >= shrinkThreshold) return indentation * maxIndent;\n\n const minShrink =\n minColumnLabelWidth + minIndent + maxIndent * (indentation - 1);\n if (currentSize <= minShrink)\n return (\n minIndent +\n this.getLabelOffset(\n indentation - 1,\n orientation,\n width,\n columnRatio,\n minColumnLabelWidth\n )\n );\n\n return currentSize - minColumnLabelWidth;\n }\n\n public static createNewDisplayValue(\n orientation: Orientation,\n propertyRecord: PropertyRecord,\n indentation?: number,\n propertyValueRendererManager?: PropertyValueRendererManager,\n isExpanded?: boolean,\n onExpansionToggled?: () => void,\n onHeightChanged?: (newHeight: number) => void,\n highlight?: HighlightingComponentProps & {\n applyOnLabel: boolean;\n applyOnValue: boolean;\n }\n ) {\n const highlightCallback = highlight?.applyOnValue\n ? CommonPropertyRenderer.createHighlightCallback(\n highlight,\n propertyRecord\n )\n : undefined;\n const rendererContext: PropertyValueRendererContext = {\n orientation,\n containerType: PropertyContainerType.PropertyPane,\n isExpanded,\n onExpansionToggled,\n onHeightChanged,\n textHighlighter: highlightCallback,\n };\n\n let displayValue: React.ReactNode | undefined;\n if (propertyValueRendererManager)\n displayValue = propertyValueRendererManager.render(\n propertyRecord,\n rendererContext\n );\n else\n displayValue = PropertyValueRendererManager.defaultManager.render(\n propertyRecord,\n rendererContext\n );\n\n // Align value with label if orientation is vertical\n if (orientation === Orientation.Vertical)\n displayValue = (\n <span\n style={{\n paddingLeft: CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation\n ),\n }}\n >\n {displayValue}\n </span>\n );\n\n return displayValue;\n }\n\n private static createHighlightCallback(\n highlight: HighlightingComponentProps & { applyOnLabel: boolean },\n propertyRecord: PropertyRecord\n ) {\n const activeMatch = highlight.activeHighlight;\n const propertyName = activeMatch?.highlightedItemIdentifier;\n const matchIndex = activeMatch?.highlightIndex ?? 0;\n let labelMatches: number;\n\n if (highlight.applyOnLabel) {\n labelMatches = countMatchesInString(\n propertyRecord.property.displayLabel.toLowerCase(),\n highlight.highlightedText\n );\n } else {\n labelMatches = 0;\n }\n\n const activeMatchIndex =\n propertyRecord.property.name === propertyName &&\n matchIndex - labelMatches >= 0\n ? matchIndex - labelMatches\n : undefined;\n const highlightCallback = (text: string) => (\n <HighlightedText\n text={text}\n activeMatchIndex={activeMatchIndex}\n searchText={highlight.highlightedText}\n />\n );\n\n return highlightCallback;\n }\n}\n"]}
@@ -66,7 +66,7 @@ class NonPrimitivePropertyRenderer extends React.Component {
66
66
  getLabel(props, state) {
67
67
  const { orientation, indentation, width, columnRatio, columnInfo } = props;
68
68
  // istanbul ignore next
69
- const minLabelWidth = columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.minLabelWidth;
69
+ const minLabelWidth = columnInfo?.minLabelWidth;
70
70
  const offset = CommonPropertyRenderer_1.CommonPropertyRenderer.getLabelOffset(indentation, orientation, width, columnRatio, minLabelWidth);
71
71
  let displayLabel = props.propertyRecord.property.displayLabel;
72
72
  if (this.props.propertyRecord.value.valueFormat === appui_abstract_1.PropertyValueFormat.Array)
@@ -1 +1 @@
1
- {"version":3,"file":"NonPrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/NonPrimitivePropertyRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAA6C;AAC7C,6CAA+B;AAC/B,0DAA4E;AAC5E,qEAAkE;AAClE,iGAA8F;AAE9F,yDAAsD;AACtD,iDAA8C;AAmB9C;;GAEG;A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AwHC","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 \"./NonPrimitivePropertyRenderer.scss\";\nimport * as React from \"react\";\nimport { PropertyRecord, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { CommonPropertyRenderer } from \"./CommonPropertyRenderer\";\nimport { NonPrimitivePropertyLabelRenderer } from \"./label/NonPrimitivePropertyLabelRenderer\";\nimport type { PrimitiveRendererProps } from \"./PrimitivePropertyRenderer\";\nimport { PropertyRenderer } from \"./PropertyRenderer\";\nimport { PropertyView } from \"./PropertyView\";\n\n/** Properties of [[NonPrimitivePropertyRenderer]] React component\n * @public\n */\nexport interface NonPrimitivePropertyRendererProps\n extends PrimitiveRendererProps {\n /** Can struct/array property be collapsed */\n isCollapsible?: boolean;\n}\n\n/** State of [[NonPrimitivePropertyRenderer]] React component\n * @internal\n */\ninterface NonPrimitivePropertyRendererState {\n /** Is struct/array property expanded */\n isExpanded?: boolean;\n}\n\n/** React Component that renders struct and array properties\n * @public\n */\nexport class NonPrimitivePropertyRenderer extends React.Component<\n NonPrimitivePropertyRendererProps,\n NonPrimitivePropertyRendererState\n> {\n /** @internal */\n public override readonly state: NonPrimitivePropertyRendererState = {\n /** If it's not collapsible, that means it's expanded by default and can't be collapsed */\n isExpanded:\n !this.props.isCollapsible || this.props.propertyRecord.autoExpand,\n };\n\n constructor(props: NonPrimitivePropertyRendererProps) {\n super(props);\n }\n\n private _onExpanded = () => {\n this.setState({ isExpanded: true });\n };\n\n private _onCollapsed = () => {\n this.setState({ isExpanded: false });\n };\n\n private getLabel(\n props: NonPrimitivePropertyRendererProps,\n state: NonPrimitivePropertyRendererState\n ): React.ReactNode {\n const { orientation, indentation, width, columnRatio, columnInfo } = props;\n // istanbul ignore next\n const minLabelWidth = columnInfo?.minLabelWidth;\n const offset = CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation,\n width,\n columnRatio,\n minLabelWidth\n );\n\n let displayLabel = props.propertyRecord.property.displayLabel;\n if (\n this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array\n )\n displayLabel = `${displayLabel} (${this.props.propertyRecord.value.items.length})`;\n\n return (\n <NonPrimitivePropertyLabelRenderer\n isExpanded={!!state.isExpanded}\n onExpand={this._onExpanded}\n onCollapse={this._onCollapsed}\n offset={offset}\n renderColon={false}\n >\n {displayLabel}\n </NonPrimitivePropertyLabelRenderer>\n );\n }\n\n private overrideArrayChildrenNames(items: PropertyRecord[]) {\n const modifiedProperties: PropertyRecord[] = items.map(\n (item, index): PropertyRecord => {\n const newProperty = { ...item.property };\n newProperty.displayLabel = `[${index + 1}]`;\n newProperty.name = `${newProperty.name}_${index}`;\n return new PropertyRecord(item.value, newProperty);\n }\n );\n\n return modifiedProperties;\n }\n\n private _renderPropertyForItem = (item: PropertyRecord) => {\n const prefix = this.props.uniqueKey\n ? this.props.uniqueKey\n : this.props.propertyRecord.property.name;\n const uniqueKey = `${prefix}_${item.property.name}`;\n return (\n <PropertyRenderer\n key={uniqueKey}\n uniqueKey={uniqueKey}\n propertyRecord={item}\n indentation={this.props.indentation ? this.props.indentation + 1 : 1}\n orientation={this.props.orientation}\n columnRatio={this.props.columnRatio}\n actionButtonRenderers={this.props.actionButtonRenderers}\n onColumnRatioChanged={this.props.onColumnRatioChanged}\n width={this.props.width}\n isResizeHandleHovered={this.props.isResizeHandleHovered}\n onResizeHandleHoverChanged={this.props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={this.props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={this.props.onResizeHandleDragChanged}\n columnInfo={this.props.columnInfo}\n />\n );\n };\n\n /** @internal */\n public override render() {\n let items: PropertyRecord[] =\n this.props.propertyRecord.getChildrenRecords();\n if (\n this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array\n )\n items = this.overrideArrayChildrenNames(items);\n\n const { indentation, ...props } = this.props;\n return (\n <>\n {this.props.isCollapsible ? (\n <PropertyView\n labelElement={this.getLabel(this.props, this.state)}\n {...props}\n />\n ) : undefined}\n\n {this.state.isExpanded\n ? items.map(this._renderPropertyForItem)\n : undefined}\n </>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"NonPrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/NonPrimitivePropertyRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAA6C;AAC7C,6CAA+B;AAC/B,0DAA4E;AAC5E,qEAAkE;AAClE,iGAA8F;AAE9F,yDAAsD;AACtD,iDAA8C;AAmB9C;;GAEG;AACH,MAAa,4BAA6B,SAAQ,KAAK,CAAC,SAGvD;IAQC,YAAY,KAAwC;QAClD,KAAK,CAAC,KAAK,CAAC,CAAC;QARf,gBAAgB;QACS,UAAK,GAAsC;YAClE,0FAA0F;YAC1F,UAAU,EACR,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU;SACpE,CAAC;QAMM,gBAAW,GAAG,GAAG,EAAE;YACzB,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC,CAAC;QAEM,iBAAY,GAAG,GAAG,EAAE;YAC1B,IAAI,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACvC,CAAC,CAAC;QAiDM,2BAAsB,GAAG,CAAC,IAAoB,EAAE,EAAE;YACxD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS;gBACjC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS;gBACtB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC5C,MA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AAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7C,OAAO,CACL;YACG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAC1B,oBAAC,2BAAY,IACX,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAC/C,KAAK,GACT,CACH,CAAC,CAAC,CAAC,SAAS;YAEZ,IAAI,CAAC,KAAK,CAAC,UAAU;gBACpB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC;gBACxC,CAAC,CAAC,SAAS,CACZ,CACJ,CAAC;IACJ,CAAC;CACF;AAxHD,oEAwHC","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 \"./NonPrimitivePropertyRenderer.scss\";\nimport * as React from \"react\";\nimport { PropertyRecord, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { CommonPropertyRenderer } from \"./CommonPropertyRenderer\";\nimport { NonPrimitivePropertyLabelRenderer } from \"./label/NonPrimitivePropertyLabelRenderer\";\nimport type { PrimitiveRendererProps } from \"./PrimitivePropertyRenderer\";\nimport { PropertyRenderer } from \"./PropertyRenderer\";\nimport { PropertyView } from \"./PropertyView\";\n\n/** Properties of [[NonPrimitivePropertyRenderer]] React component\n * @public\n */\nexport interface NonPrimitivePropertyRendererProps\n extends PrimitiveRendererProps {\n /** Can struct/array property be collapsed */\n isCollapsible?: boolean;\n}\n\n/** State of [[NonPrimitivePropertyRenderer]] React component\n * @internal\n */\ninterface NonPrimitivePropertyRendererState {\n /** Is struct/array property expanded */\n isExpanded?: boolean;\n}\n\n/** React Component that renders struct and array properties\n * @public\n */\nexport class NonPrimitivePropertyRenderer extends React.Component<\n NonPrimitivePropertyRendererProps,\n NonPrimitivePropertyRendererState\n> {\n /** @internal */\n public override readonly state: NonPrimitivePropertyRendererState = {\n /** If it's not collapsible, that means it's expanded by default and can't be collapsed */\n isExpanded:\n !this.props.isCollapsible || this.props.propertyRecord.autoExpand,\n };\n\n constructor(props: NonPrimitivePropertyRendererProps) {\n super(props);\n }\n\n private _onExpanded = () => {\n this.setState({ isExpanded: true });\n };\n\n private _onCollapsed = () => {\n this.setState({ isExpanded: false });\n };\n\n private getLabel(\n props: NonPrimitivePropertyRendererProps,\n state: NonPrimitivePropertyRendererState\n ): React.ReactNode {\n const { orientation, indentation, width, columnRatio, columnInfo } = props;\n // istanbul ignore next\n const minLabelWidth = columnInfo?.minLabelWidth;\n const offset = CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation,\n width,\n columnRatio,\n minLabelWidth\n );\n\n let displayLabel = props.propertyRecord.property.displayLabel;\n if (\n this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array\n )\n displayLabel = `${displayLabel} (${this.props.propertyRecord.value.items.length})`;\n\n return (\n <NonPrimitivePropertyLabelRenderer\n isExpanded={!!state.isExpanded}\n onExpand={this._onExpanded}\n onCollapse={this._onCollapsed}\n offset={offset}\n renderColon={false}\n >\n {displayLabel}\n </NonPrimitivePropertyLabelRenderer>\n );\n }\n\n private overrideArrayChildrenNames(items: PropertyRecord[]) {\n const modifiedProperties: PropertyRecord[] = items.map(\n (item, index): PropertyRecord => {\n const newProperty = { ...item.property };\n newProperty.displayLabel = `[${index + 1}]`;\n newProperty.name = `${newProperty.name}_${index}`;\n return new PropertyRecord(item.value, newProperty);\n }\n );\n\n return modifiedProperties;\n }\n\n private _renderPropertyForItem = (item: PropertyRecord) => {\n const prefix = this.props.uniqueKey\n ? this.props.uniqueKey\n : this.props.propertyRecord.property.name;\n const uniqueKey = `${prefix}_${item.property.name}`;\n return (\n <PropertyRenderer\n key={uniqueKey}\n uniqueKey={uniqueKey}\n propertyRecord={item}\n indentation={this.props.indentation ? this.props.indentation + 1 : 1}\n orientation={this.props.orientation}\n columnRatio={this.props.columnRatio}\n actionButtonRenderers={this.props.actionButtonRenderers}\n onColumnRatioChanged={this.props.onColumnRatioChanged}\n width={this.props.width}\n isResizeHandleHovered={this.props.isResizeHandleHovered}\n onResizeHandleHoverChanged={this.props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={this.props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={this.props.onResizeHandleDragChanged}\n columnInfo={this.props.columnInfo}\n />\n );\n };\n\n /** @internal */\n public override render() {\n let items: PropertyRecord[] =\n this.props.propertyRecord.getChildrenRecords();\n if (\n this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array\n )\n items = this.overrideArrayChildrenNames(items);\n\n const { indentation, ...props } = this.props;\n return (\n <>\n {this.props.isCollapsible ? (\n <PropertyView\n labelElement={this.getLabel(this.props, this.state)}\n {...props}\n />\n ) : undefined}\n\n {this.state.isExpanded\n ? items.map(this._renderPropertyForItem)\n : undefined}\n </>\n );\n }\n}\n"]}
@@ -46,12 +46,11 @@ class PrimitivePropertyRenderer extends React.Component {
46
46
  }
47
47
  /** @internal */
48
48
  render() {
49
- var _a, _b;
50
49
  const { indentation, highlight, ...props } = this.props;
51
50
  const displayLabel = this.props.propertyRecord.property.displayLabel;
52
- const offset = CommonPropertyRenderer_1.CommonPropertyRenderer.getLabelOffset(indentation, props.orientation, props.width, props.columnRatio, (_a = props.columnInfo) === null || _a === void 0 ? void 0 : _a.minLabelWidth);
51
+ const offset = CommonPropertyRenderer_1.CommonPropertyRenderer.getLabelOffset(indentation, props.orientation, props.width, props.columnRatio, props.columnInfo?.minLabelWidth);
53
52
  const activeMatchIndex = this.props.propertyRecord.property.name ===
54
- ((_b = highlight === null || highlight === void 0 ? void 0 : highlight.activeHighlight) === null || _b === void 0 ? void 0 : _b.highlightedItemIdentifier)
53
+ highlight?.activeHighlight?.highlightedItemIdentifier
55
54
  ? highlight.activeHighlight.highlightIndex
56
55
  : undefined;
57
56
  const label = highlight
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/PrimitivePropertyRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,kDAAgD;AAChD,kEAA+D;AAE/D,qEAAkE;AAClE,2FAAwF;AAExF,iDAA8C;AAiB9C;;GAEG;AACH,MAAa,yBAA0B,SAAQ,KAAK,CAAC,SAAiC;IACpF,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED,gBAAgB;IACA,MAAM;;QACpB,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;QACrE,MAAM,MAAM,GAAG,+CAAsB,CAAC,cAAc,CAClD,WAAW,EACX,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,MAAA,KAAK,CAAC,UAAU,0CAAE,aAAa,CAChC,CAAC;QAEF,MAAM,gBAAgB,GACpB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI;aACvC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,eAAe,0CAAE,yBAAyB,CAAA;YACnD,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,cAAc;YAC1C,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,KAAK,GAAG,SAAS;YACrB,CAAC,CAAC,IAAA,iCAAe,EAAC;gBACd,IAAI,EAAE,YAAY;gBAClB,UAAU,EAAE,SAAS,CAAC,eAAe;gBACrC,gBAAgB;aACjB,CAAC;YACJ,CAAC,CAAC,YAAY,CAAC;QAEjB,OAAO,CACL,oBAAC,2BAAY,OACP,KAAK,EACT,YAAY,EACV,oBAAC,+DAA8B,IAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,wBAAW,CAAC,UAAU,EAC9D,OAAO,EAAE,YAAY,IAEpB,KAAK,CACyB,GAEnC,CACH,CAAC;IACJ,CAAC;CACF;AA7CD,8DA6CC","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 { Orientation } from \"@itwin/core-react\";\nimport { HighlightedText } from \"../../common/HighlightedText\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps\";\nimport { CommonPropertyRenderer } from \"./CommonPropertyRenderer\";\nimport { PrimitivePropertyLabelRenderer } from \"./label/PrimitivePropertyLabelRenderer\";\nimport type { SharedRendererProps } from \"./PropertyRenderer\";\nimport { PropertyView } from \"./PropertyView\";\n\n/** Properties of [[PrimitivePropertyRenderer]] React component\n * @public\n */\nexport interface PrimitiveRendererProps extends SharedRendererProps {\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Properties used for highlighting\n */\n highlight?: HighlightingComponentProps;\n}\n\n/** React Component that renders primitive properties\n * @public\n */\nexport class PrimitivePropertyRenderer extends React.Component<PrimitiveRendererProps> {\n constructor(props: PrimitiveRendererProps) {\n super(props);\n }\n\n /** @internal */\n public override render() {\n const { indentation, highlight, ...props } = this.props;\n const displayLabel = this.props.propertyRecord.property.displayLabel;\n const offset = CommonPropertyRenderer.getLabelOffset(\n indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth\n );\n\n const activeMatchIndex =\n this.props.propertyRecord.property.name ===\n highlight?.activeHighlight?.highlightedItemIdentifier\n ? highlight.activeHighlight.highlightIndex\n : undefined;\n const label = highlight\n ? HighlightedText({\n text: displayLabel,\n searchText: highlight.highlightedText,\n activeMatchIndex,\n })\n : displayLabel;\n\n return (\n <PropertyView\n {...props}\n labelElement={\n <PrimitivePropertyLabelRenderer\n offset={offset}\n renderColon={this.props.orientation === Orientation.Horizontal}\n tooltip={displayLabel}\n >\n {label}\n </PrimitivePropertyLabelRenderer>\n }\n />\n );\n }\n}\n"]}
1
+ {"version":3,"file":"PrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/PrimitivePropertyRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,kDAAgD;AAChD,kEAA+D;AAE/D,qEAAkE;AAClE,2FAAwF;AAExF,iDAA8C;AAiB9C;;GAEG;AACH,MAAa,yBAA0B,SAAQ,KAAK,CAAC,SAAiC;IACpF,YAAY,KAA6B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED,gBAAgB;IACA,MAAM;QACpB,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;QACrE,MAAM,MAAM,GAAG,+CAAsB,CAAC,cAAc,CAClD,WAAW,EACX,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,UAAU,EAAE,aAAa,CAChC,CAAC;QAEF,MAAM,gBAAgB,GACpB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI;YACvC,SAAS,EAAE,eAAe,EAAE,yBAAyB;YACnD,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,cAAc;YAC1C,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,KAAK,GAAG,SAAS;YACrB,CAAC,CAAC,IAAA,iCAAe,EAAC;gBACd,IAAI,EAAE,YAAY;gBAClB,UAAU,EAAE,SAAS,CAAC,eAAe;gBACrC,gBAAgB;aACjB,CAAC;YACJ,CAAC,CAAC,YAAY,CAAC;QAEjB,OAAO,CACL,oBAAC,2BAAY,OACP,KAAK,EACT,YAAY,EACV,oBAAC,+DAA8B,IAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,wBAAW,CAAC,UAAU,EAC9D,OAAO,EAAE,YAAY,IAEpB,KAAK,CACyB,GAEnC,CACH,CAAC;IACJ,CAAC;CACF;AA7CD,8DA6CC","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 { Orientation } from \"@itwin/core-react\";\nimport { HighlightedText } from \"../../common/HighlightedText\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps\";\nimport { CommonPropertyRenderer } from \"./CommonPropertyRenderer\";\nimport { PrimitivePropertyLabelRenderer } from \"./label/PrimitivePropertyLabelRenderer\";\nimport type { SharedRendererProps } from \"./PropertyRenderer\";\nimport { PropertyView } from \"./PropertyView\";\n\n/** Properties of [[PrimitivePropertyRenderer]] React component\n * @public\n */\nexport interface PrimitiveRendererProps extends SharedRendererProps {\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Properties used for highlighting\n */\n highlight?: HighlightingComponentProps;\n}\n\n/** React Component that renders primitive properties\n * @public\n */\nexport class PrimitivePropertyRenderer extends React.Component<PrimitiveRendererProps> {\n constructor(props: PrimitiveRendererProps) {\n super(props);\n }\n\n /** @internal */\n public override render() {\n const { indentation, highlight, ...props } = this.props;\n const displayLabel = this.props.propertyRecord.property.displayLabel;\n const offset = CommonPropertyRenderer.getLabelOffset(\n indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth\n );\n\n const activeMatchIndex =\n this.props.propertyRecord.property.name ===\n highlight?.activeHighlight?.highlightedItemIdentifier\n ? highlight.activeHighlight.highlightIndex\n : undefined;\n const label = highlight\n ? HighlightedText({\n text: displayLabel,\n searchText: highlight.highlightedText,\n activeMatchIndex,\n })\n : displayLabel;\n\n return (\n <PropertyView\n {...props}\n labelElement={\n <PrimitivePropertyLabelRenderer\n offset={offset}\n renderColon={this.props.orientation === Orientation.Horizontal}\n tooltip={displayLabel}\n >\n {label}\n </PrimitivePropertyLabelRenderer>\n }\n />\n );\n }\n}\n"]}
@@ -44,10 +44,10 @@ class PropertyLabelRenderer extends React.PureComponent {
44
44
  };
45
45
  }
46
46
  render() {
47
- var _a;
48
- const title = (_a = this.props.tooltip) !== null && _a !== void 0 ? _a : (typeof this.props.children == "string"
49
- ? this.props.children
50
- : /* istanbul ignore next */ undefined);
47
+ const title = this.props.tooltip ??
48
+ (typeof this.props.children == "string"
49
+ ? this.props.children
50
+ : /* istanbul ignore next */ undefined);
51
51
  return (React.createElement(React.Fragment, null,
52
52
  React.createElement("span", { className: "components-property-label-renderer", title: title }, this.props.children),
53
53
  this.props.renderColon ? (React.createElement("span", { className: "components-property-label-renderer-colon" }, ":")) : undefined));
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyLabelRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/properties/renderers/label/PropertyLabelRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wCAAsC;AACtC,6CAA+B;AAc/B,gBAAgB;AAChB,MAAa,qBAAsB,SAAQ,KAAK,CAAC,aAAyC;IACxF,6EAA6E;IACtE,MAAM,CAAC,QAAQ,CAAC,MAAe;QACpC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,OAAO;YACL,WAAW,EAAE,MAAM;YACnB,KAAK,EAAE,eAAe,MAAM,KAAK;SAClC,CAAC;IACJ,CAAC;IAEe,MAAM;;QACpB,MAAM,KAAK,GACT,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,mCAClB,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,QAAQ;YACrC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;YACrB,CAAC,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;QAC5C,OAAO,CACL;YACE,8BAAM,SAAS,EAAC,oCAAoC,EAAC,KAAK,EAAE,KAAK,IAC9D,IAAI,CAAC,KAAK,CAAC,QAAQ,CACf;YACN,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CACxB,8BAAM,SAAS,EAAC,0CAA0C,QAAS,CACpE,CAAC,CAAC,CAAC,SAAS,CACZ,CACJ,CAAC;IACJ,CAAC;CACF;AA3BD,sDA2BC","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 \"./PropertyLabelRenderer.scss\";\nimport * as React from \"react\";\n\n/** Base properties for a property label renderer\n * @public\n */\nexport interface PropertyLabelRendererProps {\n /** Label to be rendered */\n children: string | React.ReactElement;\n /** Indicates whether to render a colon after the label */\n renderColon?: boolean;\n /** Custom tooltip for the component. */\n tooltip?: string;\n}\n\n/** @internal */\nexport class PropertyLabelRenderer extends React.PureComponent<PropertyLabelRendererProps> {\n /** Get React CSS style object based on provided offset from the left side */\n public static getStyle(offset?: number): React.CSSProperties {\n offset = offset ? offset : 0;\n return {\n paddingLeft: offset,\n width: `calc(100% - ${offset}px)`,\n };\n }\n\n public override render() {\n const title =\n this.props.tooltip ??\n (typeof this.props.children == \"string\"\n ? this.props.children\n : /* istanbul ignore next */ undefined);\n return (\n <>\n <span className=\"components-property-label-renderer\" title={title}>\n {this.props.children}\n </span>\n {this.props.renderColon ? (\n <span className=\"components-property-label-renderer-colon\">:</span>\n ) : undefined}\n </>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"PropertyLabelRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/properties/renderers/label/PropertyLabelRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wCAAsC;AACtC,6CAA+B;AAc/B,gBAAgB;AAChB,MAAa,qBAAsB,SAAQ,KAAK,CAAC,aAAyC;IACxF,6EAA6E;IACtE,MAAM,CAAC,QAAQ,CAAC,MAAe;QACpC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,OAAO;YACL,WAAW,EAAE,MAAM;YACnB,KAAK,EAAE,eAAe,MAAM,KAAK;SAClC,CAAC;IACJ,CAAC;IAEe,MAAM;QACpB,MAAM,KAAK,GACT,IAAI,CAAC,KAAK,CAAC,OAAO;YAClB,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,QAAQ;gBACrC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;gBACrB,CAAC,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC;QAC5C,OAAO,CACL;YACE,8BAAM,SAAS,EAAC,oCAAoC,EAAC,KAAK,EAAE,KAAK,IAC9D,IAAI,CAAC,KAAK,CAAC,QAAQ,CACf;YACN,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CACxB,8BAAM,SAAS,EAAC,0CAA0C,QAAS,CACpE,CAAC,CAAC,CAAC,SAAS,CACZ,CACJ,CAAC;IACJ,CAAC;CACF;AA3BD,sDA2BC","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 \"./PropertyLabelRenderer.scss\";\nimport * as React from \"react\";\n\n/** Base properties for a property label renderer\n * @public\n */\nexport interface PropertyLabelRendererProps {\n /** Label to be rendered */\n children: string | React.ReactElement;\n /** Indicates whether to render a colon after the label */\n renderColon?: boolean;\n /** Custom tooltip for the component. */\n tooltip?: string;\n}\n\n/** @internal */\nexport class PropertyLabelRenderer extends React.PureComponent<PropertyLabelRendererProps> {\n /** Get React CSS style object based on provided offset from the left side */\n public static getStyle(offset?: number): React.CSSProperties {\n offset = offset ? offset : 0;\n return {\n paddingLeft: offset,\n width: `calc(100% - ${offset}px)`,\n };\n }\n\n public override render() {\n const title =\n this.props.tooltip ??\n (typeof this.props.children == \"string\"\n ? this.props.children\n : /* istanbul ignore next */ undefined);\n return (\n <>\n <span className=\"components-property-label-renderer\" title={title}>\n {this.props.children}\n </span>\n {this.props.renderColon ? (\n <span className=\"components-property-label-renderer-colon\">:</span>\n ) : undefined}\n </>\n );\n }\n}\n"]}
@@ -51,10 +51,9 @@ class DoublePropertyValueRenderer {
51
51
  }
52
52
  exports.DoublePropertyValueRenderer = DoublePropertyValueRenderer;
53
53
  function convertRecordToString(record) {
54
- var _a;
55
54
  const primitive = record.value;
56
55
  if (primitive.displayValue)
57
56
  return primitive.displayValue;
58
- return TypeConverterManager_1.TypeConverterManager.getConverter(record.property.typename, (_a = record.property.converter) === null || _a === void 0 ? void 0 : _a.name).convertPropertyToString(record.property, primitive.value);
57
+ return TypeConverterManager_1.TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name).convertPropertyToString(record.property, primitive.value);
59
58
  }
60
59
  //# sourceMappingURL=DoublePropertyValueRenderer.js.map
@@ -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,6CAA+B;AAE/B,0DAA+E;AAC/E,mFAAgF;AAKhF,qFAAsF;AAEtF;;GAEG;AACH,MAAa,2BAA2B;IACtC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,oCAAmB,CAAC,SAAS;YAC1D,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,kCAAiB,CAAC,MAAM,CACtD,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,mEAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,GAC5C,CACH,CAAC;IACJ,CAAC;CACF;AAtBD,kEAsBC;AAED,SAAS,qBAAqB,CAC5B,MAAsB;;IAEtB,MAAM,SAAS,GAAG,MAAM,CAAC,KAAuB,CAAC;IACjD,IAAI,SAAS,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC,YAAY,CAAC;IAC1D,OAAO,2CAAoB,CAAC,YAAY,CACtC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EACxB,MAAA,MAAM,CAAC,QAAQ,CAAC,SAAS,0CAAE,IAAI,CAChC,CAAC,uBAAuB,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9D,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 Properties\n */\n\nimport * as React from \"react\";\nimport type { PrimitiveValue, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { TypeConverterManager } from \"../../../converters/TypeConverterManager\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager\";\nimport { PrimitivePropertyValueRendererImpl } from \"./PrimitivePropertyValueRenderer\";\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\nfunction convertRecordToString(\n record: PropertyRecord\n): string | Promise<string> {\n const primitive = record.value as PrimitiveValue;\n if (primitive.displayValue) return primitive.displayValue;\n return TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).convertPropertyToString(record.property, primitive.value);\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,6CAA+B;AAE/B,0DAA+E;AAC/E,mFAAgF;AAKhF,qFAAsF;AAEtF;;GAEG;AACH,MAAa,2BAA2B;IACtC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,oCAAmB,CAAC,SAAS;YAC1D,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,kCAAiB,CAAC,MAAM,CACtD,CAAC;IACJ,CAAC;IAED,iEAAiE;IAC1D,MAAM,CACX,MAAsB,EACtB,OAAsC;QAEtC,OAAO,CACL,oBAAC,mEAAkC,IACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,qBAAqB,GAC5C,CACH,CAAC;IACJ,CAAC;CACF;AAtBD,kEAsBC;AAED,SAAS,qBAAqB,CAC5B,MAAsB;IAEtB,MAAM,SAAS,GAAG,MAAM,CAAC,KAAuB,CAAC;IACjD,IAAI,SAAS,CAAC,YAAY;QAAE,OAAO,SAAS,CAAC,YAAY,CAAC;IAC1D,OAAO,2CAAoB,CAAC,YAAY,CACtC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EACxB,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAChC,CAAC,uBAAuB,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;AAC9D,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 Properties\n */\n\nimport * as React from \"react\";\nimport type { PrimitiveValue, PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { TypeConverterManager } from \"../../../converters/TypeConverterManager\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"../../ValueRendererManager\";\nimport { PrimitivePropertyValueRendererImpl } from \"./PrimitivePropertyValueRenderer\";\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\nfunction convertRecordToString(\n record: PropertyRecord\n): string | Promise<string> {\n const primitive = record.value as PrimitiveValue;\n if (primitive.displayValue) return primitive.displayValue;\n return TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n ).convertPropertyToString(record.property, primitive.value);\n}\n"]}