@itwin/components-react 5.18.0 → 5.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/lib/components-react/UiComponents.js +2 -1
  3. package/lib/components-react/UiComponents.js.map +1 -1
  4. package/lib/components-react/common/ImageRenderer.js +1 -1
  5. package/lib/components-react/common/ImageRenderer.js.map +1 -1
  6. package/lib/components-react/common/SubscriptionScheduler.js +1 -1
  7. package/lib/components-react/common/SubscriptionScheduler.js.map +1 -1
  8. package/lib/components-react/common/selection/SelectionHandler.js +20 -2
  9. package/lib/components-react/common/selection/SelectionHandler.js.map +1 -1
  10. package/lib/components-react/converters/BooleanTypeConverter.js +4 -4
  11. package/lib/components-react/converters/BooleanTypeConverter.js.map +1 -1
  12. package/lib/components-react/converters/PointTypeConverter.js +1 -0
  13. package/lib/components-react/converters/PointTypeConverter.js.map +1 -1
  14. package/lib/components-react/converters/TypeConverterManager.js +2 -1
  15. package/lib/components-react/converters/TypeConverterManager.js.map +1 -1
  16. package/lib/components-react/datepicker/IntlFormatter.js +1 -0
  17. package/lib/components-react/datepicker/IntlFormatter.js.map +1 -1
  18. package/lib/components-react/editors/BooleanEditor.js +23 -26
  19. package/lib/components-react/editors/BooleanEditor.js.map +1 -1
  20. package/lib/components-react/editors/CustomNumberEditor.js +92 -97
  21. package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
  22. package/lib/components-react/editors/DateTimeEditor.js +60 -63
  23. package/lib/components-react/editors/DateTimeEditor.js.map +1 -1
  24. package/lib/components-react/editors/EnumButtonGroupEditor.js +23 -26
  25. package/lib/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  26. package/lib/components-react/editors/EnumEditor.js +30 -33
  27. package/lib/components-react/editors/EnumEditor.js.map +1 -1
  28. package/lib/components-react/editors/IconEditor.js +16 -16
  29. package/lib/components-react/editors/IconEditor.js.map +1 -1
  30. package/lib/components-react/editors/ImageCheckBoxEditor.js +22 -25
  31. package/lib/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
  32. package/lib/components-react/editors/NumericInputEditor.js +26 -29
  33. package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
  34. package/lib/components-react/editors/PopupButton.js +26 -29
  35. package/lib/components-react/editors/PopupButton.js.map +1 -1
  36. package/lib/components-react/editors/PropertyEditorManager.js +2 -4
  37. package/lib/components-react/editors/PropertyEditorManager.js.map +1 -1
  38. package/lib/components-react/editors/SliderEditor.js +65 -68
  39. package/lib/components-react/editors/SliderEditor.js.map +1 -1
  40. package/lib/components-react/editors/TextEditor.js +22 -25
  41. package/lib/components-react/editors/TextEditor.js.map +1 -1
  42. package/lib/components-react/editors/TextareaEditor.js +29 -32
  43. package/lib/components-react/editors/TextareaEditor.js.map +1 -1
  44. package/lib/components-react/editors/ToggleEditor.js +26 -29
  45. package/lib/components-react/editors/ToggleEditor.js.map +1 -1
  46. package/lib/components-react/filter-builder/FilterBuilderState.js +1 -0
  47. package/lib/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  48. package/lib/components-react/filtering/FilteringInput.js +36 -36
  49. package/lib/components-react/filtering/FilteringInput.js.map +1 -1
  50. package/lib/components-react/filtering/ResultSelector.js +50 -50
  51. package/lib/components-react/filtering/ResultSelector.js.map +1 -1
  52. package/lib/components-react/iconpicker/IconPickerButton.js +18 -18
  53. package/lib/components-react/iconpicker/IconPickerButton.js.map +1 -1
  54. package/lib/components-react/properties/ValueRendererManager.js +6 -7
  55. package/lib/components-react/properties/ValueRendererManager.js.map +1 -1
  56. package/lib/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +17 -17
  57. package/lib/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  58. package/lib/components-react/properties/renderers/PropertyGridColumns.js +4 -3
  59. package/lib/components-react/properties/renderers/PropertyGridColumns.js.map +1 -1
  60. package/lib/components-react/properties/renderers/PropertyView.js +23 -23
  61. package/lib/components-react/properties/renderers/PropertyView.js.map +1 -1
  62. package/lib/components-react/properties/renderers/label/NonPrimitivePropertyLabelRenderer.js +6 -9
  63. package/lib/components-react/properties/renderers/label/NonPrimitivePropertyLabelRenderer.js.map +1 -1
  64. package/lib/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.js +9 -12
  65. package/lib/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.js.map +1 -1
  66. package/lib/components-react/propertygrid/MergingPropertyDataProvider.js +2 -1
  67. package/lib/components-react/propertygrid/MergingPropertyDataProvider.js.map +1 -1
  68. package/lib/components-react/propertygrid/PropertyCategoryRendererManager.js +2 -4
  69. package/lib/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  70. package/lib/components-react/propertygrid/SimplePropertyDataProvider.js +6 -4
  71. package/lib/components-react/propertygrid/SimplePropertyDataProvider.js.map +1 -1
  72. package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +26 -29
  73. package/lib/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  74. package/lib/components-react/propertygrid/component/PropertyCategoryBlock.js +3 -3
  75. package/lib/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  76. package/lib/components-react/propertygrid/component/PropertyGridCommons.js +9 -9
  77. package/lib/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  78. package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js +22 -22
  79. package/lib/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js.map +1 -1
  80. package/lib/components-react/propertygrid/component/PropertyList.js +5 -5
  81. package/lib/components-react/propertygrid/component/PropertyList.js.map +1 -1
  82. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js +29 -29
  83. package/lib/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  84. package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js +12 -14
  85. package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  86. package/lib/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +3 -0
  87. package/lib/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  88. package/lib/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -1
  89. package/lib/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  90. package/lib/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js +1 -1
  91. package/lib/components-react/propertygrid/dataproviders/filterers/LabelPropertyDataFilterer.js.map +1 -1
  92. package/lib/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js +1 -1
  93. package/lib/components-react/propertygrid/dataproviders/filterers/PropertyCategoryLabelFilterer.js.map +1 -1
  94. package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.js +1 -3
  95. package/lib/components-react/propertygrid/dataproviders/filterers/PropertyDataFiltererBase.js.map +1 -1
  96. package/lib/components-react/propertygrid/internal/PropertyGridEventHandler.js +11 -10
  97. package/lib/components-react/propertygrid/internal/PropertyGridEventHandler.js.map +1 -1
  98. package/lib/components-react/propertygrid/internal/PropertyGridModel.js +3 -3
  99. package/lib/components-react/propertygrid/internal/PropertyGridModel.js.map +1 -1
  100. package/lib/components-react/propertygrid/internal/PropertyGridModelSource.js +4 -2
  101. package/lib/components-react/propertygrid/internal/PropertyGridModelSource.js.map +1 -1
  102. package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js +2 -0
  103. package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedArrayProperty.js.map +1 -1
  104. package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js +2 -0
  105. package/lib/components-react/propertygrid/internal/flat-items/MutableCategorizedStructProperty.js.map +1 -1
  106. package/lib/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +6 -1
  107. package/lib/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  108. package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +10 -7
  109. package/lib/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  110. package/lib/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +3 -0
  111. package/lib/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  112. package/lib/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +8 -8
  113. package/lib/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  114. package/lib/components-react/toolbar/InternalToolbarComponent.js +4 -4
  115. package/lib/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  116. package/lib/components-react/toolbar/utilities/Direction.js +12 -12
  117. package/lib/components-react/toolbar/utilities/Direction.js.map +1 -1
  118. package/lib/components-react/tree/HighlightingEngine.js +3 -1
  119. package/lib/components-react/tree/HighlightingEngine.js.map +1 -1
  120. package/lib/components-react/tree/SimpleTreeDataProvider.js +1 -0
  121. package/lib/components-react/tree/SimpleTreeDataProvider.js.map +1 -1
  122. package/lib/components-react/tree/controlled/TreeEventDispatcher.js +5 -1
  123. package/lib/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
  124. package/lib/components-react/tree/controlled/TreeEventHandler.js +10 -14
  125. package/lib/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
  126. package/lib/components-react/tree/controlled/TreeModel.js +7 -9
  127. package/lib/components-react/tree/controlled/TreeModel.js.map +1 -1
  128. package/lib/components-react/tree/controlled/TreeModelSource.js +3 -2
  129. package/lib/components-react/tree/controlled/TreeModelSource.js.map +1 -1
  130. package/lib/components-react/tree/controlled/TreeNodeLoader.js +11 -3
  131. package/lib/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  132. package/lib/components-react/tree/controlled/component/TreeRenderer.js +1 -4
  133. package/lib/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
  134. package/lib/components-react/tree/controlled/internal/SparseTree.js +7 -5
  135. package/lib/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  136. package/lib/components-react/tree/controlled/internal/TreeModelMutator.js +3 -0
  137. package/lib/components-react/tree/controlled/internal/TreeModelMutator.js.map +1 -1
  138. package/lib/components-react/tree/controlled/internal/TreeSelectionManager.js +56 -51
  139. package/lib/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  140. package/package.json +6 -7
@@ -15,15 +15,12 @@ import { PropertyLabelRenderer } from "./PropertyLabelRenderer.js";
15
15
  * @public
16
16
  */
17
17
  export class NonPrimitivePropertyLabelRenderer extends React.PureComponent {
18
- constructor() {
19
- super(...arguments);
20
- this._onClick = () => {
21
- if (this.props.isExpanded)
22
- this.props.onCollapse();
23
- else
24
- this.props.onExpand();
25
- };
26
- }
18
+ _onClick = () => {
19
+ if (this.props.isExpanded)
20
+ this.props.onCollapse();
21
+ else
22
+ this.props.onExpand();
23
+ };
27
24
  render() {
28
25
  return (React.createElement("div", { style: PropertyLabelRenderer.getStyle(this.props.offset), className: `components-nonprimitive-property-label-renderer ${this.props.className ? this.props.className : ""}`, onClick: this._onClick, role: "presentation" },
29
26
  React.createElement("div", { className: this.props.isExpanded ? "components-expanded" : "" },
@@ -1 +1 @@
1
- {"version":3,"file":"NonPrimitivePropertyLabelRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/label/NonPrimitivePropertyLabelRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAYnE;;;;GAIG;AACH,MAAM,OAAO,iCAAkC,SAAQ,KAAK,CAAC,aAAqD;IAAlH;;QACU,aAAQ,GAAG,GAAG,EAAE;YACtB,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU;gBAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;;gBAC9C,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC;IAqBJ,CAAC;IAnBiB,MAAM;QACpB,OAAO,CACL,6BACE,KAAK,EAAE,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EACxD,SAAS,EAAE,mDACT,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAChD,EAAE,EACF,OAAO,EAAE,IAAI,CAAC,QAAQ,EACtB,IAAI,EAAC,cAAc;YAEnB,6BAAK,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE;gBAChE,oBAAC,eAAe,OAAG,CACf;YACN,oBAAC,qBAAqB,IAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,IACvD,IAAI,CAAC,KAAK,CAAC,QAAQ,CACE,CACpB,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Properties\n */\n\nimport \"./PropertyLabelRenderer.scss\";\nimport * as React from \"react\";\nimport { SvgChevronRight } from \"@itwin/itwinui-icons-react\";\nimport type { PrimitivePropertyLabelRendererProps } from \"./PrimitivePropertyLabelRenderer.js\";\nimport { PropertyLabelRenderer } from \"./PropertyLabelRenderer.js\";\n\n/** Properties for the [[NonPrimitivePropertyLabelRenderer]] React component\n * @public\n */\nexport interface NonPrimitivePropertyLabelRendererProps\n extends PrimitivePropertyLabelRendererProps {\n isExpanded: boolean;\n onExpand: () => void;\n onCollapse: () => void;\n}\n\n/**\n * A React component that renders a non-primitive property label.\n * It renders an animated arrow with text which expands when label is clicked.\n * @public\n */\nexport class NonPrimitivePropertyLabelRenderer extends React.PureComponent<NonPrimitivePropertyLabelRendererProps> {\n private _onClick = () => {\n if (this.props.isExpanded) this.props.onCollapse();\n else this.props.onExpand();\n };\n\n public override render() {\n return (\n <div\n style={PropertyLabelRenderer.getStyle(this.props.offset)}\n className={`components-nonprimitive-property-label-renderer ${\n this.props.className ? this.props.className : \"\"\n }`}\n onClick={this._onClick}\n role=\"presentation\"\n >\n <div className={this.props.isExpanded ? \"components-expanded\" : \"\"}>\n <SvgChevronRight />\n </div>\n <PropertyLabelRenderer renderColon={this.props.renderColon}>\n {this.props.children}\n </PropertyLabelRenderer>\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"NonPrimitivePropertyLabelRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/properties/renderers/label/NonPrimitivePropertyLabelRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAYnE;;;;GAIG;AACH,MAAM,OAAO,iCAAkC,SAAQ,KAAK,CAAC,aAAqD;IACxG,QAAQ,GAAG,GAAG,EAAE;QACtB,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU;YAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;;YAC9C,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC,CAAC;IAEc,MAAM;QACpB,OAAO,CACL,6BACE,KAAK,EAAE,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EACxD,SAAS,EAAE,mDACT,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAChD,EAAE,EACF,OAAO,EAAE,IAAI,CAAC,QAAQ,EACtB,IAAI,EAAC,cAAc;YAEnB,6BAAK,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE;gBAChE,oBAAC,eAAe,OAAG,CACf;YACN,oBAAC,qBAAqB,IAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,IACvD,IAAI,CAAC,KAAK,CAAC,QAAQ,CACE,CACpB,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Properties\n */\n\nimport \"./PropertyLabelRenderer.scss\";\nimport * as React from \"react\";\nimport { SvgChevronRight } from \"@itwin/itwinui-icons-react\";\nimport type { PrimitivePropertyLabelRendererProps } from \"./PrimitivePropertyLabelRenderer.js\";\nimport { PropertyLabelRenderer } from \"./PropertyLabelRenderer.js\";\n\n/** Properties for the [[NonPrimitivePropertyLabelRenderer]] React component\n * @public\n */\nexport interface NonPrimitivePropertyLabelRendererProps\n extends PrimitivePropertyLabelRendererProps {\n isExpanded: boolean;\n onExpand: () => void;\n onCollapse: () => void;\n}\n\n/**\n * A React component that renders a non-primitive property label.\n * It renders an animated arrow with text which expands when label is clicked.\n * @public\n */\nexport class NonPrimitivePropertyLabelRenderer extends React.PureComponent<NonPrimitivePropertyLabelRendererProps> {\n private _onClick = () => {\n if (this.props.isExpanded) this.props.onCollapse();\n else this.props.onExpand();\n };\n\n public override render() {\n return (\n <div\n style={PropertyLabelRenderer.getStyle(this.props.offset)}\n className={`components-nonprimitive-property-label-renderer ${\n this.props.className ? this.props.className : \"\"\n }`}\n onClick={this._onClick}\n role=\"presentation\"\n >\n <div className={this.props.isExpanded ? \"components-expanded\" : \"\"}>\n <SvgChevronRight />\n </div>\n <PropertyLabelRenderer renderColon={this.props.renderColon}>\n {this.props.children}\n </PropertyLabelRenderer>\n </div>\n );\n }\n}\n"]}
@@ -13,19 +13,16 @@ import { UnderlinedButton } from "@itwin/core-react";
13
13
  * @public
14
14
  */
15
15
  export class TableNonPrimitiveValueRenderer extends React.PureComponent {
16
- constructor() {
17
- // private _buttonRef = React.createRef<HTMLButtonElement>();
18
- super(...arguments);
19
- this._onClick = () => {
20
- if (!this.props.onDialogOpen)
21
- return;
22
- const dialogState = {
23
- content: this.props.dialogContents,
24
- title: this.props.dialogTitle,
25
- };
26
- this.props.onDialogOpen(dialogState);
16
+ // private _buttonRef = React.createRef<HTMLButtonElement>();
17
+ _onClick = () => {
18
+ if (!this.props.onDialogOpen)
19
+ return;
20
+ const dialogState = {
21
+ content: this.props.dialogContents,
22
+ title: this.props.dialogTitle,
27
23
  };
28
- }
24
+ this.props.onDialogOpen(dialogState);
25
+ };
29
26
  // TODO: Enable, when table gets refactored
30
27
  // Disabled fancy tooltips, because table controls it's state.
31
28
  // But, because everything is in table state and there is no shouldComponentUpdate,
@@ -1 +1 @@
1
- {"version":3,"file":"NonPrimitiveValueRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAwCrD;;;;GAIG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK,CAAC,aAAkD;IAA5G;QACE,6DAA6D;;QAErD,aAAQ,GAAG,GAAG,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY;gBAAE,OAAO;YAErC,MAAM,WAAW,GAAwB;gBACvC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc;gBAClC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;aAC9B,CAAC;YAEF,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC,CAAC;IAkDJ,CAAC;IAhDC,2CAA2C;IAC3C,8DAA8D;IAC9D,mFAAmF;IACnF,6CAA6C;IAC7C,iCAAiC;IACjC,iCAAiC;IACjC,cAAc;IAEd,mDAAmD;IAEnD,wBAAwB;IACxB,cAAc;IAEd,6DAA6D;IAE7D,6CAA6C;IAC7C,uBAAuB;IACvB,iCAAiC;IACjC,oDAAoD;IACpD,SAAS;IACT,eAAe;IACf,wDAAwD;IACxD,6DAA6D;IAC7D,iBAAiB;IACjB,OAAO;IACP,wCAAwC;IACxC,IAAI;IAEJ,iCAAiC;IACjC,gCAAgC;IAChC,gCAAgC;IAChC,IAAI;IAEY,MAAM;QACpB,OAAO;QACL,4DAA4D;QAC5D,oBAAC,gBAAgB;QACf,wBAAwB;;YAAxB,wBAAwB;YACxB,SAAS,EAAC,+BAA+B,EACzC,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,mCAAmC;YACnC,mCAAmC;YACnC,KAAK,EAAE,QAAQ,IAAI,CAAC,KAAK,CAAC,WAAW,kBAAkB,IAEtD,IAAI,CAAC,KAAK,CAAC,WAAW,CACN,CACpB,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Properties\n */\n\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { UnderlinedButton } from \"@itwin/core-react\";\nimport type { PropertyDialogState } from \"../../../ValueRendererManager.js\";\nimport type { Orientation } from \"../../../../common/Orientation.js\";\n\n/** Properties for [[TableArrayValueRenderer]] and [[TableStructValueRenderer]] React component\n * @public\n */\nexport interface TableSpecificValueRendererProps\n extends SharedTableNonPrimitiveValueRendererProps {\n /** Property record */\n propertyRecord: PropertyRecord;\n /** Orientation of the rendered property */\n orientation: Orientation;\n}\n\n/** Shared properties between table non-primitive value renderers\n * @public\n */\nexport interface SharedTableNonPrimitiveValueRendererProps {\n // /** Callback to request for a Popup to be shown. */\n // onPopupShow?: (popupState: PropertyPopupState) => void;\n // /** Callback to request for a Popup to be hidden. */\n // onPopupHide?: () => void;\n /** Callback to request for dialog to be opened. */\n onDialogOpen?: (dialogState: PropertyDialogState) => void;\n}\n\n/** Properties for [[TableNonPrimitiveValueRenderer]] React component\n * @public\n */\nexport interface TableNonPrimitiveValueRendererProps\n extends SharedTableNonPrimitiveValueRendererProps {\n /** Title of the dialog that shows property in more detail. */\n dialogTitle: string;\n /** Contents of the dialog. Should be the property record shown in more detail. */\n dialogContents: React.ReactNode;\n /** Text that will be rendered in the table cell, in other words - Property value */\n buttonLabel: string;\n}\n\n/**\n * A React component that renders non primitive values as a button with text.\n * When clicked, a dialog appears that shows the value in greater detail.\n * @public\n */\nexport class TableNonPrimitiveValueRenderer extends React.PureComponent<TableNonPrimitiveValueRendererProps> {\n // private _buttonRef = React.createRef<HTMLButtonElement>();\n\n private _onClick = () => {\n if (!this.props.onDialogOpen) return;\n\n const dialogState: PropertyDialogState = {\n content: this.props.dialogContents,\n title: this.props.dialogTitle,\n };\n\n this.props.onDialogOpen(dialogState);\n };\n\n // TODO: Enable, when table gets refactored\n // Disabled fancy tooltips, because table controls it's state.\n // But, because everything is in table state and there is no shouldComponentUpdate,\n // tooltips cause rerender of the whole table\n // private _showTooltip = () => {\n // if (!this.props.onPopupShow)\n // return;\n\n // const buttonElement = this._buttonRef.current;\n\n // if (!buttonElement)\n // return;\n\n // const buttonBox = buttonElement.getBoundingClientRect();\n\n // const popupState: PropertyPopupState = {\n // fixedPosition: {\n // top: buttonBox.top - 10,\n // left: buttonBox.left + buttonBox.width / 2,\n // },\n // content:\n // <span className=\"components-table-value-popup\">\n // {`View ${this.props.buttonLabel} in more detail.`}\n // </span>,\n // };\n // this.props.onPopupShow(popupState);\n // }\n\n // private _hideTooltip = () => {\n // if (this.props.onPopupHide)\n // this.props.onPopupHide();\n // }\n\n public override render() {\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <UnderlinedButton\n // ref={this._buttonRef}\n className=\"components-table-value-button\"\n onClick={this._onClick}\n // onMouseEnter={this._showTooltip}\n // onMouseLeave={this._hideTooltip}\n title={`View ${this.props.buttonLabel} in more detail.`}\n >\n {this.props.buttonLabel}\n </UnderlinedButton>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"NonPrimitiveValueRenderer.js","sourceRoot":"","sources":["../../../../../../src/components-react/properties/renderers/value/table/NonPrimitiveValueRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAwCrD;;;;GAIG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK,CAAC,aAAkD;IAC1G,6DAA6D;IAErD,QAAQ,GAAG,GAAG,EAAE;QACtB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY;YAAE,OAAO;QAErC,MAAM,WAAW,GAAwB;YACvC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc;YAClC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;SAC9B,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC,CAAC;IAEF,2CAA2C;IAC3C,8DAA8D;IAC9D,mFAAmF;IACnF,6CAA6C;IAC7C,iCAAiC;IACjC,iCAAiC;IACjC,cAAc;IAEd,mDAAmD;IAEnD,wBAAwB;IACxB,cAAc;IAEd,6DAA6D;IAE7D,6CAA6C;IAC7C,uBAAuB;IACvB,iCAAiC;IACjC,oDAAoD;IACpD,SAAS;IACT,eAAe;IACf,wDAAwD;IACxD,6DAA6D;IAC7D,iBAAiB;IACjB,OAAO;IACP,wCAAwC;IACxC,IAAI;IAEJ,iCAAiC;IACjC,gCAAgC;IAChC,gCAAgC;IAChC,IAAI;IAEY,MAAM;QACpB,OAAO;QACL,4DAA4D;QAC5D,oBAAC,gBAAgB;QACf,wBAAwB;;YAAxB,wBAAwB;YACxB,SAAS,EAAC,+BAA+B,EACzC,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,mCAAmC;YACnC,mCAAmC;YACnC,KAAK,EAAE,QAAQ,IAAI,CAAC,KAAK,CAAC,WAAW,kBAAkB,IAEtD,IAAI,CAAC,KAAK,CAAC,WAAW,CACN,CACpB,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Properties\n */\n\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { UnderlinedButton } from \"@itwin/core-react\";\nimport type { PropertyDialogState } from \"../../../ValueRendererManager.js\";\nimport type { Orientation } from \"../../../../common/Orientation.js\";\n\n/** Properties for [[TableArrayValueRenderer]] and [[TableStructValueRenderer]] React component\n * @public\n */\nexport interface TableSpecificValueRendererProps\n extends SharedTableNonPrimitiveValueRendererProps {\n /** Property record */\n propertyRecord: PropertyRecord;\n /** Orientation of the rendered property */\n orientation: Orientation;\n}\n\n/** Shared properties between table non-primitive value renderers\n * @public\n */\nexport interface SharedTableNonPrimitiveValueRendererProps {\n // /** Callback to request for a Popup to be shown. */\n // onPopupShow?: (popupState: PropertyPopupState) => void;\n // /** Callback to request for a Popup to be hidden. */\n // onPopupHide?: () => void;\n /** Callback to request for dialog to be opened. */\n onDialogOpen?: (dialogState: PropertyDialogState) => void;\n}\n\n/** Properties for [[TableNonPrimitiveValueRenderer]] React component\n * @public\n */\nexport interface TableNonPrimitiveValueRendererProps\n extends SharedTableNonPrimitiveValueRendererProps {\n /** Title of the dialog that shows property in more detail. */\n dialogTitle: string;\n /** Contents of the dialog. Should be the property record shown in more detail. */\n dialogContents: React.ReactNode;\n /** Text that will be rendered in the table cell, in other words - Property value */\n buttonLabel: string;\n}\n\n/**\n * A React component that renders non primitive values as a button with text.\n * When clicked, a dialog appears that shows the value in greater detail.\n * @public\n */\nexport class TableNonPrimitiveValueRenderer extends React.PureComponent<TableNonPrimitiveValueRendererProps> {\n // private _buttonRef = React.createRef<HTMLButtonElement>();\n\n private _onClick = () => {\n if (!this.props.onDialogOpen) return;\n\n const dialogState: PropertyDialogState = {\n content: this.props.dialogContents,\n title: this.props.dialogTitle,\n };\n\n this.props.onDialogOpen(dialogState);\n };\n\n // TODO: Enable, when table gets refactored\n // Disabled fancy tooltips, because table controls it's state.\n // But, because everything is in table state and there is no shouldComponentUpdate,\n // tooltips cause rerender of the whole table\n // private _showTooltip = () => {\n // if (!this.props.onPopupShow)\n // return;\n\n // const buttonElement = this._buttonRef.current;\n\n // if (!buttonElement)\n // return;\n\n // const buttonBox = buttonElement.getBoundingClientRect();\n\n // const popupState: PropertyPopupState = {\n // fixedPosition: {\n // top: buttonBox.top - 10,\n // left: buttonBox.left + buttonBox.width / 2,\n // },\n // content:\n // <span className=\"components-table-value-popup\">\n // {`View ${this.props.buttonLabel} in more detail.`}\n // </span>,\n // };\n // this.props.onPopupShow(popupState);\n // }\n\n // private _hideTooltip = () => {\n // if (this.props.onPopupHide)\n // this.props.onPopupHide();\n // }\n\n public override render() {\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <UnderlinedButton\n // ref={this._buttonRef}\n className=\"components-table-value-button\"\n onClick={this._onClick}\n // onMouseEnter={this._showTooltip}\n // onMouseLeave={this._hideTooltip}\n title={`View ${this.props.buttonLabel} in more detail.`}\n >\n {this.props.buttonLabel}\n </UnderlinedButton>\n );\n }\n}\n"]}
@@ -10,8 +10,9 @@ import { PropertyDataChangeEvent } from "./PropertyDataProvider.js";
10
10
  import { UiComponents } from "../UiComponents.js";
11
11
  const SOURCE_PROVIDER_KEY = `${UiComponents.packageName}/source-provider`;
12
12
  class MergingPropertyDataProviderImpl {
13
+ onDataChanged = new PropertyDataChangeEvent();
14
+ _providers;
13
15
  constructor(providers) {
14
- this.onDataChanged = new PropertyDataChangeEvent();
15
16
  this._providers = providers;
16
17
  for (const provider of this._providers) {
17
18
  provider.onDataChanged.addListener(() => this.onDataChanged.raiseEvent());
@@ -1 +1 @@
1
- {"version":3,"file":"MergingPropertyDataProvider.js","sourceRoot":"","sources":["../../../src/components-react/propertygrid/MergingPropertyDataProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,mBAAmB,GAAG,GAAG,YAAY,CAAC,WAAW,kBAAkB,CAAC;AA2B1E,MAAM,+BAA+B;IAInC,YAAY,SAAkC;QAHvC,kBAAa,GAAG,IAAI,uBAAuB,EAAE,CAAC;QAInD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACvC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC3D,IAAI,CAAC,8BAA8B,CAAC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AS,CAAC;QACnB,CAAC;QAED,OAAO,MAAM,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;IAClD,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAC9C,SAAkC;IAElC,OAAO,IAAI,+BAA+B,CAAC,SAAS,CAAC,CAAC;AACxD,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 PropertyGrid\n */\n\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyDataProvider,\n PropertyCategory,\n PropertyData,\n} from \"./PropertyDataProvider.js\";\nimport { PropertyDataChangeEvent } from \"./PropertyDataProvider.js\";\nimport { UiComponents } from \"../UiComponents.js\";\n\nconst SOURCE_PROVIDER_KEY = `${UiComponents.packageName}/source-provider`;\n\n/**\n * An interface for property data provider which combines any number of [[IPropertyDataProvider]] instances.\n * @public\n */\nexport interface IMergingPropertyDataProvider {\n /**\n * Property data change event that is raised when any of the source providers raise this event.\n */\n onDataChanged: PropertyDataChangeEvent;\n /**\n * Determines source provider from a given [[PropertyRecord]].\n *\n * @returns\n * - `undefined` if source provider can't be determined.\n * - Source provider if it is found.\n */\n getSourceProviderFromPropertyRecord(\n record: PropertyRecord\n ): IPropertyDataProvider | undefined;\n /**\n * Returns merged property data from all source providers.\n */\n getData(): Promise<PropertyData>;\n}\n\nclass MergingPropertyDataProviderImpl implements IMergingPropertyDataProvider {\n public onDataChanged = new PropertyDataChangeEvent();\n private _providers: IPropertyDataProvider[];\n\n constructor(providers: IPropertyDataProvider[]) {\n this._providers = providers;\n\n for (const provider of this._providers) {\n provider.onDataChanged.addListener(() => this.onDataChanged.raiseEvent());\n }\n }\n\n public async getData(): Promise<PropertyData> {\n const providersData = this._providers.map(async (provider) =>\n this.getDataWithReferenceToProvider(provider)\n );\n const dataArray = await Promise.all(providersData);\n\n return this.mergePropertyDataArray(dataArray);\n }\n\n private async getDataWithReferenceToProvider(\n provider: IPropertyDataProvider\n ): Promise<PropertyData> {\n const providerData = await provider.getData();\n for (const categoryName in providerData.records) {\n if (!providerData.records.hasOwnProperty(categoryName)) {\n continue;\n }\n\n providerData.records[categoryName].forEach((categoryRecord) => {\n categoryRecord.extendedData = {\n ...categoryRecord.extendedData,\n [SOURCE_PROVIDER_KEY]: provider,\n };\n });\n }\n return providerData;\n }\n\n private mergePropertyDataArray(dataArray: PropertyData[]): PropertyData {\n return {\n label: this.mergeLabels(dataArray),\n description: this.mergeDescriptions(dataArray),\n categories: this.mergeCategories(dataArray),\n records: this.mergeRecords(dataArray),\n };\n }\n\n private mergeLabels(dataArray: PropertyData[]): PropertyRecord {\n // We don't care about labels, just use the first one\n if (dataArray.length > 0) {\n return dataArray[0].label;\n }\n\n return PropertyRecord.fromString(\"\");\n }\n\n private mergeDescriptions(dataArray: PropertyData[]): string | undefined {\n // We don't care about descriptions, just use the first one\n if (dataArray.length > 0) {\n return dataArray[0].description;\n }\n\n return undefined;\n }\n\n private mergeCategories(dataArray: PropertyData[]): PropertyCategory[] {\n let mergedCategories: PropertyCategory[] | undefined;\n if (dataArray.length > 0) {\n mergedCategories = [...dataArray[0].categories];\n }\n\n for (let i = 1; i < dataArray.length; ++i) {\n mergedCategories = this.mergeChildCategories(\n mergedCategories,\n dataArray[i].categories\n );\n }\n\n return mergedCategories ?? [];\n }\n\n private mergeChildCategories(\n lhs: PropertyCategory[] | undefined,\n rhs: PropertyCategory[] | undefined\n ): PropertyCategory[] | undefined {\n if (!lhs || lhs.length === 0) {\n return rhs;\n }\n\n if (!rhs || rhs.length === 0) {\n return lhs;\n }\n\n const mergedCategories = [...lhs];\n\n for (const rhsCategory of rhs) {\n const childCategoryIndex = mergedCategories.findIndex(\n (mergedCategory) => mergedCategory.name === rhsCategory.name\n );\n if (childCategoryIndex === -1) {\n mergedCategories.push(rhsCategory);\n continue;\n }\n\n const newChildCategories = this.mergeChildCategories(\n mergedCategories[childCategoryIndex].childCategories,\n rhsCategory.childCategories\n );\n mergedCategories[childCategoryIndex] = {\n ...mergedCategories[childCategoryIndex],\n ...(newChildCategories ? { childCategories: newChildCategories } : {}),\n };\n }\n return mergedCategories;\n }\n\n private mergeRecords(dataArray: PropertyData[]): {\n [categoryName: string]: PropertyRecord[];\n } {\n const mergedRecords: { [categoryName: string]: PropertyRecord[] } = {};\n dataArray.forEach((data) => {\n for (const categoryName in data.records) {\n if (!data.records.hasOwnProperty(categoryName)) {\n continue;\n }\n\n if (mergedRecords.hasOwnProperty(categoryName)) {\n mergedRecords[categoryName].push(...data.records[categoryName]);\n continue;\n }\n\n mergedRecords[categoryName] = [...data.records[categoryName]];\n }\n });\n\n return mergedRecords;\n }\n\n public getSourceProviderFromPropertyRecord(\n record: PropertyRecord\n ): IPropertyDataProvider | undefined {\n if (\n !record.extendedData ||\n !record.extendedData.hasOwnProperty(SOURCE_PROVIDER_KEY)\n ) {\n return undefined;\n }\n\n return record.extendedData[SOURCE_PROVIDER_KEY];\n }\n}\n\n/**\n * Factory function that creates [[IMergingPropertyDataProvider]] instance\n * @public\n */\nexport function createMergedPropertyDataProvider(\n providers: IPropertyDataProvider[]\n): IMergingPropertyDataProvider {\n return new MergingPropertyDataProviderImpl(providers);\n}\n"]}
1
+ {"version":3,"file":"MergingPropertyDataProvider.js","sourceRoot":"","sources":["../../../src/components-react/propertygrid/MergingPropertyDataProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,mBAAmB,GAAG,GAAG,YAAY,CAAC,WAAW,kBAAkB,CAAC;AA2B1E,MAAM,+BAA+B;IAC5B,aAAa,GAAG,IA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AC;oBAC/C,aAAa,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;oBAChE,SAAS;gBACX,CAAC;gBAED,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACvB,CAAC;IAEM,mCAAmC,CACxC,MAAsB;QAEtB,IACE,CAAC,MAAM,CAAC,YAAY;YACpB,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,mBAAmB,CAAC,EACxD,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,MAAM,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;IAClD,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAC9C,SAAkC;IAElC,OAAO,IAAI,+BAA+B,CAAC,SAAS,CAAC,CAAC;AACxD,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 PropertyGrid\n */\n\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyDataProvider,\n PropertyCategory,\n PropertyData,\n} from \"./PropertyDataProvider.js\";\nimport { PropertyDataChangeEvent } from \"./PropertyDataProvider.js\";\nimport { UiComponents } from \"../UiComponents.js\";\n\nconst SOURCE_PROVIDER_KEY = `${UiComponents.packageName}/source-provider`;\n\n/**\n * An interface for property data provider which combines any number of [[IPropertyDataProvider]] instances.\n * @public\n */\nexport interface IMergingPropertyDataProvider {\n /**\n * Property data change event that is raised when any of the source providers raise this event.\n */\n onDataChanged: PropertyDataChangeEvent;\n /**\n * Determines source provider from a given [[PropertyRecord]].\n *\n * @returns\n * - `undefined` if source provider can't be determined.\n * - Source provider if it is found.\n */\n getSourceProviderFromPropertyRecord(\n record: PropertyRecord\n ): IPropertyDataProvider | undefined;\n /**\n * Returns merged property data from all source providers.\n */\n getData(): Promise<PropertyData>;\n}\n\nclass MergingPropertyDataProviderImpl implements IMergingPropertyDataProvider {\n public onDataChanged = new PropertyDataChangeEvent();\n private _providers: IPropertyDataProvider[];\n\n constructor(providers: IPropertyDataProvider[]) {\n this._providers = providers;\n\n for (const provider of this._providers) {\n provider.onDataChanged.addListener(() => this.onDataChanged.raiseEvent());\n }\n }\n\n public async getData(): Promise<PropertyData> {\n const providersData = this._providers.map(async (provider) =>\n this.getDataWithReferenceToProvider(provider)\n );\n const dataArray = await Promise.all(providersData);\n\n return this.mergePropertyDataArray(dataArray);\n }\n\n private async getDataWithReferenceToProvider(\n provider: IPropertyDataProvider\n ): Promise<PropertyData> {\n const providerData = await provider.getData();\n for (const categoryName in providerData.records) {\n if (!providerData.records.hasOwnProperty(categoryName)) {\n continue;\n }\n\n providerData.records[categoryName].forEach((categoryRecord) => {\n categoryRecord.extendedData = {\n ...categoryRecord.extendedData,\n [SOURCE_PROVIDER_KEY]: provider,\n };\n });\n }\n return providerData;\n }\n\n private mergePropertyDataArray(dataArray: PropertyData[]): PropertyData {\n return {\n label: this.mergeLabels(dataArray),\n description: this.mergeDescriptions(dataArray),\n categories: this.mergeCategories(dataArray),\n records: this.mergeRecords(dataArray),\n };\n }\n\n private mergeLabels(dataArray: PropertyData[]): PropertyRecord {\n // We don't care about labels, just use the first one\n if (dataArray.length > 0) {\n return dataArray[0].label;\n }\n\n return PropertyRecord.fromString(\"\");\n }\n\n private mergeDescriptions(dataArray: PropertyData[]): string | undefined {\n // We don't care about descriptions, just use the first one\n if (dataArray.length > 0) {\n return dataArray[0].description;\n }\n\n return undefined;\n }\n\n private mergeCategories(dataArray: PropertyData[]): PropertyCategory[] {\n let mergedCategories: PropertyCategory[] | undefined;\n if (dataArray.length > 0) {\n mergedCategories = [...dataArray[0].categories];\n }\n\n for (let i = 1; i < dataArray.length; ++i) {\n mergedCategories = this.mergeChildCategories(\n mergedCategories,\n dataArray[i].categories\n );\n }\n\n return mergedCategories ?? [];\n }\n\n private mergeChildCategories(\n lhs: PropertyCategory[] | undefined,\n rhs: PropertyCategory[] | undefined\n ): PropertyCategory[] | undefined {\n if (!lhs || lhs.length === 0) {\n return rhs;\n }\n\n if (!rhs || rhs.length === 0) {\n return lhs;\n }\n\n const mergedCategories = [...lhs];\n\n for (const rhsCategory of rhs) {\n const childCategoryIndex = mergedCategories.findIndex(\n (mergedCategory) => mergedCategory.name === rhsCategory.name\n );\n if (childCategoryIndex === -1) {\n mergedCategories.push(rhsCategory);\n continue;\n }\n\n const newChildCategories = this.mergeChildCategories(\n mergedCategories[childCategoryIndex].childCategories,\n rhsCategory.childCategories\n );\n mergedCategories[childCategoryIndex] = {\n ...mergedCategories[childCategoryIndex],\n ...(newChildCategories ? { childCategories: newChildCategories } : {}),\n };\n }\n return mergedCategories;\n }\n\n private mergeRecords(dataArray: PropertyData[]): {\n [categoryName: string]: PropertyRecord[];\n } {\n const mergedRecords: { [categoryName: string]: PropertyRecord[] } = {};\n dataArray.forEach((data) => {\n for (const categoryName in data.records) {\n if (!data.records.hasOwnProperty(categoryName)) {\n continue;\n }\n\n if (mergedRecords.hasOwnProperty(categoryName)) {\n mergedRecords[categoryName].push(...data.records[categoryName]);\n continue;\n }\n\n mergedRecords[categoryName] = [...data.records[categoryName]];\n }\n });\n\n return mergedRecords;\n }\n\n public getSourceProviderFromPropertyRecord(\n record: PropertyRecord\n ): IPropertyDataProvider | undefined {\n if (\n !record.extendedData ||\n !record.extendedData.hasOwnProperty(SOURCE_PROVIDER_KEY)\n ) {\n return undefined;\n }\n\n return record.extendedData[SOURCE_PROVIDER_KEY];\n }\n}\n\n/**\n * Factory function that creates [[IMergingPropertyDataProvider]] instance\n * @public\n */\nexport function createMergedPropertyDataProvider(\n providers: IPropertyDataProvider[]\n): IMergingPropertyDataProvider {\n return new MergingPropertyDataProviderImpl(providers);\n}\n"]}
@@ -11,9 +11,8 @@
11
11
  * @public
12
12
  */
13
13
  export class PropertyCategoryRendererManager {
14
- constructor() {
15
- this._categoryRenderers = new Map();
16
- }
14
+ _categoryRenderers = new Map();
15
+ static defaultManager = new PropertyCategoryRendererManager();
17
16
  /** Retrieves a category rendering component based for the passed category item. */
18
17
  getCategoryComponent(categoryItem) {
19
18
  if (categoryItem.derivedCategory.renderer === undefined) {
@@ -35,5 +34,4 @@ export class PropertyCategoryRendererManager {
35
34
  this._categoryRenderers.delete(rendererName);
36
35
  }
37
36
  }
38
- PropertyCategoryRendererManager.defaultManager = new PropertyCategoryRendererManager();
39
37
  //# sourceMappingURL=PropertyCategoryRendererManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyCategoryRendererManager.js","sourceRoot":"","sources":["../../../src/components-react/propertygrid/PropertyCategoryRendererManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AA2BH;;;;GAIG;AACH,MAAM,OAAO,+BAA+B;IAA5C;QACU,uBAAkB,GAAG,IAAI,GAAG,EAAoC,CAAC;IAuC3E,CAAC;IAnCC,mFAAmF;IAC5E,oBAAoB,CACzB,YAA8B;QAE9B,IAAI,YAAY,CAAC,eAAe,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACxD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAChC,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAC3C,EAAE,CAAC,YAAY,CAAC,CAAC;IACpB,CAAC;IAED,qGAAqG;IAC9F,WAAW,CAChB,YAAoB,EACpB,gBAA0C,EAC1C,QAAQ,GAAG,KAAK;QAEhB,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC3D,MAAM,SAAS,GAAG,+BAA+B,CAAC,IAAI,CAAC;YACvD,MAAM,UAAU,GACd,+BAA+B,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC;YAC7D,MAAM,IAAI,KAAK,CACb,GAAG,SAAS,IAAI,UAAU,qBAAqB,YAAY,wDAAwD,CACpH,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;IAED,sDAAsD;IAC/C,cAAc,CAAC,YAAoB;QACxC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;;AApCa,8CAAc,GAAG,IAAI,+BAA+B,EAAE,AAAxC,CAAyC","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 PropertyGrid\n */\n\nimport type * as React from \"react\";\nimport type { VirtualizedPropertyGridContext } from \"./component/VirtualizedPropertyGrid.js\";\nimport type { GridCategoryItem } from \"./internal/flat-items/FlatGridItem.js\";\n\n/**\n * Props that property category renderer receives.\n * @public\n */\nexport interface PropertyCategoryRendererProps {\n /** The category being rendered. */\n categoryItem: GridCategoryItem;\n /** Context of the surrounding property grid. */\n gridContext: VirtualizedPropertyGridContext;\n /** Sets the allocated height for category contents. */\n onHeightChanged: (newHeight: number) => void;\n}\n\n/**\n * Factory function that produces custom property category components.\n * @public\n */\nexport type PropertyCategoryRenderer = (\n categoryItem: GridCategoryItem\n) => React.ComponentType<PropertyCategoryRendererProps> | undefined;\n\n/**\n * Keeps a record of currently registered property category renderers and determines which renderers get invoked for\n * each category.\n * @public\n */\nexport class PropertyCategoryRendererManager {\n private _categoryRenderers = new Map<string, PropertyCategoryRenderer>();\n\n public static defaultManager = new PropertyCategoryRendererManager();\n\n /** Retrieves a category rendering component based for the passed category item. */\n public getCategoryComponent(\n categoryItem: GridCategoryItem\n ): React.ComponentType<PropertyCategoryRendererProps> | undefined {\n if (categoryItem.derivedCategory.renderer === undefined) {\n return undefined;\n }\n\n return this._categoryRenderers.get(\n categoryItem.derivedCategory.renderer.name\n )?.(categoryItem);\n }\n\n /** Registers a renderer factory function to be invoked on categories with specific renderer name. */\n public addRenderer(\n rendererName: string,\n categoryRenderer: PropertyCategoryRenderer,\n override = false\n ): void {\n if (this._categoryRenderers.has(rendererName) && !override) {\n const className = PropertyCategoryRendererManager.name;\n const methodName =\n PropertyCategoryRendererManager.prototype.addRenderer.name;\n throw new Error(\n `${className}.${methodName} error: renderer '${rendererName}' has already been added. Did you mean to override it?`\n );\n }\n\n this._categoryRenderers.set(rendererName, categoryRenderer);\n }\n\n /** Removes previous renderer factory registration. */\n public removeRenderer(rendererName: string): void {\n this._categoryRenderers.delete(rendererName);\n }\n}\n"]}
1
+ {"version":3,"file":"PropertyCategoryRendererManager.js","sourceRoot":"","sources":["../../../src/components-react/propertygrid/PropertyCategoryRendererManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AA2BH;;;;GAIG;AACH,MAAM,OAAO,+BAA+B;IAClC,kBAAkB,GAAG,IAAI,GAAG,EAAoC,CAAC;IAElE,MAAM,CAAC,cAAc,GAAG,IAAI,+BAA+B,EAAE,CAAC;IAErE,mFAAmF;IAC5E,oBAAoB,CACzB,YAA8B;QAE9B,IAAI,YAAY,CAAC,eAAe,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACxD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAChC,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAC3C,EAAE,CAAC,YAAY,CAAC,CAAC;IACpB,CAAC;IAED,qGAAqG;IAC9F,WAAW,CAChB,YAAoB,EACpB,gBAA0C,EAC1C,QAAQ,GAAG,KAAK;QAEhB,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC3D,MAAM,SAAS,GAAG,+BAA+B,CAAC,IAAI,CAAC;YACvD,MAAM,UAAU,GACd,+BAA+B,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC;YAC7D,MAAM,IAAI,KAAK,CACb,GAAG,SAAS,IAAI,UAAU,qBAAqB,YAAY,wDAAwD,CACpH,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;IAED,sDAAsD;IAC/C,cAAc,CAAC,YAAoB;QACxC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/C,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 PropertyGrid\n */\n\nimport type * as React from \"react\";\nimport type { VirtualizedPropertyGridContext } from \"./component/VirtualizedPropertyGrid.js\";\nimport type { GridCategoryItem } from \"./internal/flat-items/FlatGridItem.js\";\n\n/**\n * Props that property category renderer receives.\n * @public\n */\nexport interface PropertyCategoryRendererProps {\n /** The category being rendered. */\n categoryItem: GridCategoryItem;\n /** Context of the surrounding property grid. */\n gridContext: VirtualizedPropertyGridContext;\n /** Sets the allocated height for category contents. */\n onHeightChanged: (newHeight: number) => void;\n}\n\n/**\n * Factory function that produces custom property category components.\n * @public\n */\nexport type PropertyCategoryRenderer = (\n categoryItem: GridCategoryItem\n) => React.ComponentType<PropertyCategoryRendererProps> | undefined;\n\n/**\n * Keeps a record of currently registered property category renderers and determines which renderers get invoked for\n * each category.\n * @public\n */\nexport class PropertyCategoryRendererManager {\n private _categoryRenderers = new Map<string, PropertyCategoryRenderer>();\n\n public static defaultManager = new PropertyCategoryRendererManager();\n\n /** Retrieves a category rendering component based for the passed category item. */\n public getCategoryComponent(\n categoryItem: GridCategoryItem\n ): React.ComponentType<PropertyCategoryRendererProps> | undefined {\n if (categoryItem.derivedCategory.renderer === undefined) {\n return undefined;\n }\n\n return this._categoryRenderers.get(\n categoryItem.derivedCategory.renderer.name\n )?.(categoryItem);\n }\n\n /** Registers a renderer factory function to be invoked on categories with specific renderer name. */\n public addRenderer(\n rendererName: string,\n categoryRenderer: PropertyCategoryRenderer,\n override = false\n ): void {\n if (this._categoryRenderers.has(rendererName) && !override) {\n const className = PropertyCategoryRendererManager.name;\n const methodName =\n PropertyCategoryRendererManager.prototype.addRenderer.name;\n throw new Error(\n `${className}.${methodName} error: renderer '${rendererName}' has already been added. Did you mean to override it?`\n );\n }\n\n this._categoryRenderers.set(rendererName, categoryRenderer);\n }\n\n /** Removes previous renderer factory registration. */\n public removeRenderer(rendererName: string): void {\n this._categoryRenderers.delete(rendererName);\n }\n}\n"]}
@@ -12,11 +12,13 @@ import { PropertyDataChangeEvent } from "./PropertyDataProvider.js";
12
12
  * @public
13
13
  */
14
14
  export class SimplePropertyDataProvider {
15
+ label = PropertyRecord.fromString("");
16
+ description;
17
+ categories = [];
18
+ records = {};
19
+ onDataChanged = new PropertyDataChangeEvent();
20
+ _propertyData;
15
21
  constructor() {
16
- this.label = PropertyRecord.fromString("");
17
- this.categories = [];
18
- this.records = {};
19
- this.onDataChanged = new PropertyDataChangeEvent();
20
22
  this._propertyData = this.createPropertyData();
21
23
  }
22
24
  createPropertyData() {
@@ -1 +1 @@
1
- {"version":3,"file":"SimplePropertyDataProvider.js","sourceRoot":"","sources":["../../../src/components-react/propertygrid/SimplePropertyDataProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;GAGG;AACH,MA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ChB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyDataProvider,\n PropertyCategory,\n PropertyData,\n} from \"./PropertyDataProvider.js\";\nimport { PropertyDataChangeEvent } from \"./PropertyDataProvider.js\";\n\n/**\n * Implementation of [[IPropertyDataProvider]] that uses an associative array.\n * @public\n */\nexport class SimplePropertyDataProvider\n implements IPropertyDataProvider, PropertyData\n{\n public label: PropertyRecord = PropertyRecord.fromString(\"\");\n public description?: string;\n public categories: PropertyCategory[] = [];\n public records: { [categoryName: string]: PropertyRecord[] } = {};\n public onDataChanged = new PropertyDataChangeEvent();\n private _propertyData: PropertyData;\n\n constructor() {\n this._propertyData = this.createPropertyData();\n }\n\n private createPropertyData(): PropertyData {\n return {\n label: this.label,\n description: this.description,\n categories: this.categories,\n records: this.records,\n };\n }\n\n private updatePropertyData() {\n this._propertyData = this.createPropertyData();\n this.onDataChanged.raiseEvent();\n }\n\n public addCategory(category: PropertyCategory): number {\n const categoryIdx = this.categories.push(category) - 1;\n this.records[this.categories[categoryIdx].name] = [];\n this.updatePropertyData();\n return categoryIdx;\n }\n\n public findCategoryIndex(category: PropertyCategory): number {\n const index = this.categories.findIndex(\n (testCategory: PropertyCategory) => {\n return testCategory.name === category.name;\n }\n );\n return index;\n }\n\n public addProperty(\n propertyRecord: PropertyRecord,\n categoryIdx: number\n ): void {\n this.records[this.categories[categoryIdx].name].push(propertyRecord);\n this.updatePropertyData();\n }\n\n public removeProperty(\n propertyRecord: PropertyRecord,\n categoryIdx: number\n ): boolean {\n const index = this.records[this.categories[categoryIdx].name].findIndex(\n (record: PropertyRecord) => {\n return record === propertyRecord;\n }\n );\n\n let result = false;\n\n if (index >= 0) {\n this.records[this.categories[categoryIdx].name].splice(index, 1);\n this.updatePropertyData();\n result = true;\n }\n return result;\n }\n\n public replaceProperty(\n propertyRecord: PropertyRecord,\n categoryIdx: number,\n newRecord: PropertyRecord\n ): boolean {\n const index = this.records[this.categories[categoryIdx].name].findIndex(\n (record: PropertyRecord) => {\n return record === propertyRecord;\n }\n );\n\n let result = false;\n\n if (index >= 0) {\n this.records[this.categories[categoryIdx].name].splice(\n index,\n 1,\n newRecord\n );\n result = true;\n }\n return result;\n }\n\n public async getData(): Promise<PropertyData> {\n return this._propertyData;\n }\n}\n"]}
1
+ {"version":3,"file":"SimplePropertyDataProvider.js","sourceRoot":"","sources":["../../../src/components-react/propertygrid/SimplePropertyDataProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAMvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IAG9B,KAAK,GAAmB,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtD,WAAW,CAAU;IACrB,UAAU,GAAuB,EAAE,CAAC;IACpC,OAAO,GAAiD,EAAE,CAAC;IAC3D,aAAa,GAAG,IAAI,uBAAuB,EAAE,CAAC;IAC7C,aAAa,CAAe;IAEpC;QACE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACjD,CAAC;IAEO,kBAAkB;QACxB,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;IAEO,kBAAkB;QACxB,IAAI,CAAC,aAAa,GAA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,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACjE,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,eAAe,CACpB,cAA8B,EAC9B,WAAmB,EACnB,SAAyB;QAEzB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CACrE,CAAC,MAAsB,EAAE,EAAE;YACzB,OAAO,MAAM,KAAK,cAAc,CAAC;QACnC,CAAC,CACF,CAAC;QAEF,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CACpD,KAAK,EACL,CAAC,EACD,SAAS,CACV,CAAC;YACF,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type {\n IPropertyDataProvider,\n PropertyCategory,\n PropertyData,\n} from \"./PropertyDataProvider.js\";\nimport { PropertyDataChangeEvent } from \"./PropertyDataProvider.js\";\n\n/**\n * Implementation of [[IPropertyDataProvider]] that uses an associative array.\n * @public\n */\nexport class SimplePropertyDataProvider\n implements IPropertyDataProvider, PropertyData\n{\n public label: PropertyRecord = PropertyRecord.fromString(\"\");\n public description?: string;\n public categories: PropertyCategory[] = [];\n public records: { [categoryName: string]: PropertyRecord[] } = {};\n public onDataChanged = new PropertyDataChangeEvent();\n private _propertyData: PropertyData;\n\n constructor() {\n this._propertyData = this.createPropertyData();\n }\n\n private createPropertyData(): PropertyData {\n return {\n label: this.label,\n description: this.description,\n categories: this.categories,\n records: this.records,\n };\n }\n\n private updatePropertyData() {\n this._propertyData = this.createPropertyData();\n this.onDataChanged.raiseEvent();\n }\n\n public addCategory(category: PropertyCategory): number {\n const categoryIdx = this.categories.push(category) - 1;\n this.records[this.categories[categoryIdx].name] = [];\n this.updatePropertyData();\n return categoryIdx;\n }\n\n public findCategoryIndex(category: PropertyCategory): number {\n const index = this.categories.findIndex(\n (testCategory: PropertyCategory) => {\n return testCategory.name === category.name;\n }\n );\n return index;\n }\n\n public addProperty(\n propertyRecord: PropertyRecord,\n categoryIdx: number\n ): void {\n this.records[this.categories[categoryIdx].name].push(propertyRecord);\n this.updatePropertyData();\n }\n\n public removeProperty(\n propertyRecord: PropertyRecord,\n categoryIdx: number\n ): boolean {\n const index = this.records[this.categories[categoryIdx].name].findIndex(\n (record: PropertyRecord) => {\n return record === propertyRecord;\n }\n );\n\n let result = false;\n\n if (index >= 0) {\n this.records[this.categories[categoryIdx].name].splice(index, 1);\n this.updatePropertyData();\n result = true;\n }\n return result;\n }\n\n public replaceProperty(\n propertyRecord: PropertyRecord,\n categoryIdx: number,\n newRecord: PropertyRecord\n ): boolean {\n const index = this.records[this.categories[categoryIdx].name].findIndex(\n (record: PropertyRecord) => {\n return record === propertyRecord;\n }\n );\n\n let result = false;\n\n if (index >= 0) {\n this.records[this.categories[categoryIdx].name].splice(\n index,\n 1,\n newRecord\n );\n result = true;\n }\n return result;\n }\n\n public async getData(): Promise<PropertyData> {\n return this._propertyData;\n }\n}\n"]}
@@ -12,32 +12,33 @@ const VALUE_MIN_WIDTH = 10;
12
12
  * @internal
13
13
  */
14
14
  export class ColumnResizingPropertyListPropsSupplier extends React.Component {
15
- constructor() {
16
- super(...arguments);
17
- this._initialRatio = 0.25;
18
- this._defaultMinRatio = 0.15;
19
- this._defaultMaxRatio = 0.6;
20
- this._minRatio = this._defaultMinRatio;
21
- this._maxRatio = this._defaultMaxRatio;
22
- this.state = {
23
- columnRatio: this._initialRatio,
24
- isResizeHandleHovered: false,
25
- isResizeHandleBeingDragged: false,
26
- };
27
- this._onColumnRatioChanged = (ratio) => {
28
- ratio = clamp(ratio, this._minRatio, this._maxRatio);
29
- if (this.state.columnRatio === ratio)
30
- return { ratio };
31
- this.setState({ columnRatio: ratio });
15
+ _initialRatio = 0.25;
16
+ _defaultMinRatio = 0.15;
17
+ _defaultMaxRatio = 0.6;
18
+ _minRatio = this._defaultMinRatio;
19
+ _maxRatio = this._defaultMaxRatio;
20
+ state = {
21
+ columnRatio: this._initialRatio,
22
+ isResizeHandleHovered: false,
23
+ isResizeHandleBeingDragged: false,
24
+ };
25
+ static defaultProps = {
26
+ minLabelWidth: 100,
27
+ minValueWidth: 100,
28
+ };
29
+ _onColumnRatioChanged = (ratio) => {
30
+ ratio = clamp(ratio, this._minRatio, this._maxRatio);
31
+ if (this.state.columnRatio === ratio)
32
32
  return { ratio };
33
- };
34
- this._onResizeHandleHoverChanged = (isHovered) => {
35
- this.setState({ isResizeHandleHovered: isHovered });
36
- };
37
- this._onResizeHandleDragChanged = (isDragStarted) => {
38
- this.setState({ isResizeHandleBeingDragged: isDragStarted });
39
- };
40
- }
33
+ this.setState({ columnRatio: ratio });
34
+ return { ratio };
35
+ };
36
+ _onResizeHandleHoverChanged = (isHovered) => {
37
+ this.setState({ isResizeHandleHovered: isHovered });
38
+ };
39
+ _onResizeHandleDragChanged = (isDragStarted) => {
40
+ this.setState({ isResizeHandleBeingDragged: isDragStarted });
41
+ };
41
42
  isMinimumColumnSizeEnabled() {
42
43
  if (this.props.orientation !== Orientation.Horizontal)
43
44
  return false;
@@ -102,10 +103,6 @@ export class ColumnResizingPropertyListPropsSupplier extends React.Component {
102
103
  return this.props.children(listProps);
103
104
  }
104
105
  }
105
- ColumnResizingPropertyListPropsSupplier.defaultProps = {
106
- minLabelWidth: 100,
107
- minValueWidth: 100,
108
- };
109
106
  function clamp(value, min, max) {
110
107
  return Math.max(min, Math.min(max, value));
111
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnResizingPropertyListPropsSupplier.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,eAAe,GAAG,EAAE,CAAC;AA2C3B;;;GAGG;AACH,MAAM,OAAO,uCAAwC,SAAQ,KAAK,CAAC,SAGlE;IAHD;;QAImB,kBAAa,GAAG,IAAI,CAAC;QACrB,qBAAgB,GAAG,IAAI,CAAC;QACxB,qBAAgB,GAAG,GAAG,CAAC;QAChC,cAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAClC,cAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC;QAE1B,UAAK,GAAiD;YACpE,WAAW,EAAE,IAAI,CAAC,aAAa;YAC/B,qBAAqB,EAAE,KAAK;YAC5B,0BAA0B,EAAE,KAAK;SAClC,CAAC;QAQM,0BAAqB,GAAG,CAAC,KAAa,EAAE,EAAE;YAChD,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YACrD,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,KAAK;gBAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YAEvD,IAAI,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAA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,0BAA0B,EAAE,IAAI,CAAC,0BAA0B,EAAE;aAC9D;SACF,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;;AAzFa,oDAAY,GACxB;IACE,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,GAAG;CACnB,AAJuB,CAItB;AAwFN,SAAS,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7C,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 *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyListProps } from \"./PropertyList.js\";\nimport { Orientation } from \"../../common/Orientation.js\";\n\nconst BORDER_WIDTH = 10;\nconst PROPERTY_PADDING = 16;\nconst VALUE_MIN_WIDTH = 10;\n\n/** @internal */\nexport type ColumnResizeRelatedPropertyListProps = Required<\n Pick<\n PropertyListProps,\n | \"onColumnChanged\"\n | \"columnRatio\"\n | \"isResizeHandleHovered\"\n | \"onResizeHandleHoverChanged\"\n | \"isResizeHandleBeingDragged\"\n | \"onResizeHandleDragChanged\"\n | \"columnInfo\"\n | \"orientation\"\n | \"width\"\n >\n>;\n\n/** @internal */\nexport interface ColumnResizingPropertyListPropsSupplierProps {\n /** Orientation of the properties */\n orientation: Orientation;\n /** Width of the property list */\n width: number;\n /** Minimum allowed label column width, after which resizing stops */\n minLabelWidth?: number;\n /** Minimum allowed value column width, after which resizing stops */\n minValueWidth?: number;\n /** Fixed action button column width */\n actionButtonWidth?: number;\n /** Maximum depth of the properties shown */\n maxPropertyDepth?: number;\n /** A callback that receives the required column-resize-related props for the [[PropertyList]] component */\n children: (props: ColumnResizeRelatedPropertyListProps) => React.ReactNode;\n}\n\n/** @internal */\nexport interface ColumnResizingPropertyListPropsSupplierState {\n columnRatio: number;\n isResizeHandleHovered: boolean;\n isResizeHandleBeingDragged: boolean;\n}\n\n/**\n * Wrapped PropertyCategoryBlock React component with list of properties and render optimization\n * @internal\n */\nexport class ColumnResizingPropertyListPropsSupplier extends React.Component<\n ColumnResizingPropertyListPropsSupplierProps,\n ColumnResizingPropertyListPropsSupplierState\n> {\n private readonly _initialRatio = 0.25;\n private readonly _defaultMinRatio = 0.15;\n private readonly _defaultMaxRatio = 0.6;\n private _minRatio = this._defaultMinRatio;\n private _maxRatio = this._defaultMaxRatio;\n\n public override state: ColumnResizingPropertyListPropsSupplierState = {\n columnRatio: this._initialRatio,\n isResizeHandleHovered: false,\n isResizeHandleBeingDragged: false,\n };\n\n public static defaultProps: Partial<ColumnResizingPropertyListPropsSupplierProps> =\n {\n minLabelWidth: 100,\n minValueWidth: 100,\n };\n\n private _onColumnRatioChanged = (ratio: number) => {\n ratio = clamp(ratio, this._minRatio, this._maxRatio);\n if (this.state.columnRatio === ratio) return { ratio };\n\n this.setState({ columnRatio: ratio });\n return { ratio };\n };\n\n private _onResizeHandleHoverChanged = (isHovered: boolean) => {\n this.setState({ isResizeHandleHovered: isHovered });\n };\n\n private _onResizeHandleDragChanged = (isDragStarted: boolean) => {\n this.setState({ isResizeHandleBeingDragged: isDragStarted });\n };\n\n private isMinimumColumnSizeEnabled() {\n if (this.props.orientation !== Orientation.Horizontal) return false;\n\n // calculated how much width all the borders of nested properties takes up.\n const bordersWidth = this.props.maxPropertyDepth\n ? this.props.maxPropertyDepth * BORDER_WIDTH\n : 0;\n const actionButtonWidth = this.props.actionButtonWidth ?? 0;\n\n // minimum with required to render property. This consists of:\n // * minimum label width\n // * 1px resizer\n // * minimum value width\n // * actions buttons width\n // * all nested borders width\n // * padding\n const propertyWidth =\n this.props.minLabelWidth! +\n 1 +\n this.props.minValueWidth! +\n actionButtonWidth +\n bordersWidth +\n PROPERTY_PADDING;\n // default behavior for screens that are too small to have minimum column widths\n if (this.props.width < propertyWidth) {\n this._minRatio = this._defaultMinRatio;\n // if there are action buttons calculate maximum ratio for label. Otherwise use default.\n this._maxRatio = this.props.actionButtonWidth\n ? (this.props.width -\n this.props.actionButtonWidth -\n bordersWidth -\n PROPERTY_PADDING -\n VALUE_MIN_WIDTH) /\n this.props.width\n : this._defaultMaxRatio;\n return false;\n }\n\n this._minRatio = this.props.minLabelWidth! / this.props.width;\n this._maxRatio =\n (this.props.width - actionButtonWidth - this.props.minValueWidth!) /\n this.props.width;\n return true;\n }\n\n private getValidColumnRatio(): number {\n return clamp(this.state.columnRatio, this._minRatio, this._maxRatio);\n }\n\n public override render(): React.ReactNode {\n const listProps: ColumnResizeRelatedPropertyListProps = {\n orientation: this.props.orientation,\n width: this.props.width,\n onColumnChanged: this._onColumnRatioChanged,\n columnRatio: this.getValidColumnRatio(),\n isResizeHandleHovered: this.state.isResizeHandleHovered,\n onResizeHandleHoverChanged: this._onResizeHandleHoverChanged,\n isResizeHandleBeingDragged: this.state.isResizeHandleBeingDragged,\n onResizeHandleDragChanged: this._onResizeHandleDragChanged,\n columnInfo: {\n minLabelWidth: this.props.minLabelWidth!,\n minValueWidth: this.props.minValueWidth!,\n actionButtonWidth: this.props.actionButtonWidth!,\n isMinimumColumnSizeEnabled: this.isMinimumColumnSizeEnabled(),\n },\n };\n return this.props.children(listProps);\n }\n}\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value));\n}\n"]}
1
+ {"version":3,"file":"ColumnResizingPropertyListPropsSupplier.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,gBAAgB,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C;gBAClE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,mBAAmB;QACzB,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACvE,CAAC;IAEe,MAAM;QACpB,MAAM,SAAS,GAAyC;YACtD,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;YACnC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;YACvB,eAAe,EAAE,IAAI,CAAC,qBAAqB;YAC3C,WAAW,EAAE,IAAI,CAAC,mBAAmB,EAAE;YACvC,qBAAqB,EAAE,IAAI,CAAC,KAAK,CAAC,qBAAqB;YACvD,0BAA0B,EAAE,IAAI,CAAC,2BAA2B;YAC5D,0BAA0B,EAAE,IAAI,CAAC,KAAK,CAAC,0BAA0B;YACjE,yBAAyB,EAAE,IAAI,CAAC,0BAA0B;YAC1D,UAAU,EAAE;gBACV,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAc;gBACxC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAc;gBACxC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,iBAAkB;gBAChD,0BAA0B,EAAE,IAAI,CAAC,0BAA0B,EAAE;aAC9D;SACF,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;;AAGH,SAAS,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7C,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 *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyListProps } from \"./PropertyList.js\";\nimport { Orientation } from \"../../common/Orientation.js\";\n\nconst BORDER_WIDTH = 10;\nconst PROPERTY_PADDING = 16;\nconst VALUE_MIN_WIDTH = 10;\n\n/** @internal */\nexport type ColumnResizeRelatedPropertyListProps = Required<\n Pick<\n PropertyListProps,\n | \"onColumnChanged\"\n | \"columnRatio\"\n | \"isResizeHandleHovered\"\n | \"onResizeHandleHoverChanged\"\n | \"isResizeHandleBeingDragged\"\n | \"onResizeHandleDragChanged\"\n | \"columnInfo\"\n | \"orientation\"\n | \"width\"\n >\n>;\n\n/** @internal */\nexport interface ColumnResizingPropertyListPropsSupplierProps {\n /** Orientation of the properties */\n orientation: Orientation;\n /** Width of the property list */\n width: number;\n /** Minimum allowed label column width, after which resizing stops */\n minLabelWidth?: number;\n /** Minimum allowed value column width, after which resizing stops */\n minValueWidth?: number;\n /** Fixed action button column width */\n actionButtonWidth?: number;\n /** Maximum depth of the properties shown */\n maxPropertyDepth?: number;\n /** A callback that receives the required column-resize-related props for the [[PropertyList]] component */\n children: (props: ColumnResizeRelatedPropertyListProps) => React.ReactNode;\n}\n\n/** @internal */\nexport interface ColumnResizingPropertyListPropsSupplierState {\n columnRatio: number;\n isResizeHandleHovered: boolean;\n isResizeHandleBeingDragged: boolean;\n}\n\n/**\n * Wrapped PropertyCategoryBlock React component with list of properties and render optimization\n * @internal\n */\nexport class ColumnResizingPropertyListPropsSupplier extends React.Component<\n ColumnResizingPropertyListPropsSupplierProps,\n ColumnResizingPropertyListPropsSupplierState\n> {\n private readonly _initialRatio = 0.25;\n private readonly _defaultMinRatio = 0.15;\n private readonly _defaultMaxRatio = 0.6;\n private _minRatio = this._defaultMinRatio;\n private _maxRatio = this._defaultMaxRatio;\n\n public override state: ColumnResizingPropertyListPropsSupplierState = {\n columnRatio: this._initialRatio,\n isResizeHandleHovered: false,\n isResizeHandleBeingDragged: false,\n };\n\n public static defaultProps: Partial<ColumnResizingPropertyListPropsSupplierProps> =\n {\n minLabelWidth: 100,\n minValueWidth: 100,\n };\n\n private _onColumnRatioChanged = (ratio: number) => {\n ratio = clamp(ratio, this._minRatio, this._maxRatio);\n if (this.state.columnRatio === ratio) return { ratio };\n\n this.setState({ columnRatio: ratio });\n return { ratio };\n };\n\n private _onResizeHandleHoverChanged = (isHovered: boolean) => {\n this.setState({ isResizeHandleHovered: isHovered });\n };\n\n private _onResizeHandleDragChanged = (isDragStarted: boolean) => {\n this.setState({ isResizeHandleBeingDragged: isDragStarted });\n };\n\n private isMinimumColumnSizeEnabled() {\n if (this.props.orientation !== Orientation.Horizontal) return false;\n\n // calculated how much width all the borders of nested properties takes up.\n const bordersWidth = this.props.maxPropertyDepth\n ? this.props.maxPropertyDepth * BORDER_WIDTH\n : 0;\n const actionButtonWidth = this.props.actionButtonWidth ?? 0;\n\n // minimum with required to render property. This consists of:\n // * minimum label width\n // * 1px resizer\n // * minimum value width\n // * actions buttons width\n // * all nested borders width\n // * padding\n const propertyWidth =\n this.props.minLabelWidth! +\n 1 +\n this.props.minValueWidth! +\n actionButtonWidth +\n bordersWidth +\n PROPERTY_PADDING;\n // default behavior for screens that are too small to have minimum column widths\n if (this.props.width < propertyWidth) {\n this._minRatio = this._defaultMinRatio;\n // if there are action buttons calculate maximum ratio for label. Otherwise use default.\n this._maxRatio = this.props.actionButtonWidth\n ? (this.props.width -\n this.props.actionButtonWidth -\n bordersWidth -\n PROPERTY_PADDING -\n VALUE_MIN_WIDTH) /\n this.props.width\n : this._defaultMaxRatio;\n return false;\n }\n\n this._minRatio = this.props.minLabelWidth! / this.props.width;\n this._maxRatio =\n (this.props.width - actionButtonWidth - this.props.minValueWidth!) /\n this.props.width;\n return true;\n }\n\n private getValidColumnRatio(): number {\n return clamp(this.state.columnRatio, this._minRatio, this._maxRatio);\n }\n\n public override render(): React.ReactNode {\n const listProps: ColumnResizeRelatedPropertyListProps = {\n orientation: this.props.orientation,\n width: this.props.width,\n onColumnChanged: this._onColumnRatioChanged,\n columnRatio: this.getValidColumnRatio(),\n isResizeHandleHovered: this.state.isResizeHandleHovered,\n onResizeHandleHoverChanged: this._onResizeHandleHoverChanged,\n isResizeHandleBeingDragged: this.state.isResizeHandleBeingDragged,\n onResizeHandleDragChanged: this._onResizeHandleDragChanged,\n columnInfo: {\n minLabelWidth: this.props.minLabelWidth!,\n minValueWidth: this.props.minValueWidth!,\n actionButtonWidth: this.props.actionButtonWidth!,\n isMinimumColumnSizeEnabled: this.isMinimumColumnSizeEnabled(),\n },\n };\n return this.props.children(listProps);\n }\n}\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value));\n}\n"]}
@@ -15,14 +15,14 @@ import { HighlightedText } from "../../common/HighlightedText.js";
15
15
  export class PropertyCategoryBlock extends React.Component {
16
16
  constructor(props) {
17
17
  super(props);
18
- this._handleToggle = (_isExpanding) => {
19
- this.toggleExpansion();
20
- };
21
18
  }
22
19
  toggleExpansion() {
23
20
  if (this.props.onExpansionToggled)
24
21
  this.props.onExpansionToggled(this.props.category.name);
25
22
  }
23
+ _handleToggle = (_isExpanding) => {
24
+ this.toggleExpansion();
25
+ };
26
26
  render() {
27
27
  const { highlight, category, children, onExpansionToggled, ...other } = this.props;
28
28
  const activeMatchIndex = this.props.category.name ===
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyCategoryBlock.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyCategoryBlock.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAoBlE;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK,CAAC,SAAqC;IACpF,YAAY,KAAiC;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAC;QAQP,kBAAa,GAAG,CAAC,YAAqB,EAAQ,EAAE;YACtD,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,CAAC,CAAC;IATF,CAAC;IAEO,eAAe;QACrB,IAAI,IAAI,CAAC,KAAK,CAAC,kBAAkB;YAC/B,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC;IAMe,MAAM;QACpB,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,KAAK,EAAE,GACnE,IAAI,CAAC,KAAK,CAAC;QACb,MAAM,gBAAgB,GACpB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI;YACxB,SAAS,EAAE,eAAe,EAAE,yBAAyB;YACnD,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,cAAc;YAC1C,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CACxB,oBAAC,eAAe,IACd,IAAI,EAAE,QAAQ,CAAC,KAAK,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,SAAS,CAAC,eAAe,GACrC,CACH,CAAC,CAAC,CAAC,CACF,QAAQ,CAAC,KAAK,CACf,CAAC;QACF,OAAO,CACL,oBAAC,eAAe,CAAC,OAAO,IACtB,UAAU,EAAE,QAAQ,CAAC,MAAM,EAC3B,QAAQ,EAAE,IAAI,CAAC,aAAa,EAC5B,IAAI,EAAC,OAAO,KACR,KAAK;YAET,oBAAC,eAAe,CAAC,OAAO,IAAC,KAAK,EAAE,KAAK,GAAI;YACzC,oBAAC,eAAe,CAAC,OAAO,IAAC,SAAS,EAAC,+BAA+B,IAC/D,QAAQ,CAAC,MAAM,IAAI,QAAQ,CACJ,CACF,CAC3B,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { ExpandableBlock } from \"@itwin/itwinui-react\";\nimport { HighlightedText } from \"../../common/HighlightedText.js\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\n\n/**\n * Properties for the [[PropertyCategoryBlock]] React component\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface PropertyCategoryBlockProps extends CommonProps {\n /** Category of the properties */\n category: PropertyCategory;\n /** Callback to when PropertyCategoryBlock gets expended or collapsed */\n onExpansionToggled?: (categoryName: string) => void;\n /** Properties used for highlighting */\n highlight?: HighlightingComponentProps;\n /** Content */\n children?: React.ReactNode;\n}\n\n/**\n * PropertyCategoryBlock React component\n * @public\n */\nexport class PropertyCategoryBlock extends React.Component<PropertyCategoryBlockProps> {\n constructor(props: PropertyCategoryBlockProps) {\n super(props);\n }\n\n private toggleExpansion() {\n if (this.props.onExpansionToggled)\n this.props.onExpansionToggled(this.props.category.name);\n }\n\n private _handleToggle = (_isExpanding: boolean): void => {\n this.toggleExpansion();\n };\n\n public override render() {\n const { highlight, category, children, onExpansionToggled, ...other } =\n this.props;\n const activeMatchIndex =\n this.props.category.name ===\n highlight?.activeHighlight?.highlightedItemIdentifier\n ? highlight.activeHighlight.highlightIndex\n : undefined;\n const label = highlight ? (\n <HighlightedText\n text={category.label}\n activeMatchIndex={activeMatchIndex}\n searchText={highlight.highlightedText}\n />\n ) : (\n category.label\n );\n return (\n <ExpandableBlock.Wrapper\n isExpanded={category.expand}\n onToggle={this._handleToggle}\n size=\"small\"\n {...other}\n >\n <ExpandableBlock.Trigger label={label} />\n <ExpandableBlock.Content className=\"components-expandable-content\">\n {category.expand && children}\n </ExpandableBlock.Content>\n </ExpandableBlock.Wrapper>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"PropertyCategoryBlock.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyCategoryBlock.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAoBlE;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK,CAAC,SAAqC;IACpF,YAAY,KAAiC;QAC3C,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEO,eAAe;QACrB,IAAI,IAAI,CAAC,KAAK,CAAC,kBAAkB;YAC/B,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC;IAEO,aAAa,GAAG,CAAC,YAAqB,EAAQ,EAAE;QACtD,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC,CAAC;IAEc,MAAM;QACpB,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,GAAG,KAAK,EAAE,GACnE,IAAI,CAAC,KAAK,CAAC;QACb,MAAM,gBAAgB,GACpB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI;YACxB,SAAS,EAAE,eAAe,EAAE,yBAAyB;YACnD,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,cAAc;YAC1C,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CACxB,oBAAC,eAAe,IACd,IAAI,EAAE,QAAQ,CAAC,KAAK,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,SAAS,CAAC,eAAe,GACrC,CACH,CAAC,CAAC,CAAC,CACF,QAAQ,CAAC,KAAK,CACf,CAAC;QACF,OAAO,CACL,oBAAC,eAAe,CAAC,OAAO,IACtB,UAAU,EAAE,QAAQ,CAAC,MAAM,EAC3B,QAAQ,EAAE,IAAI,CAAC,aAAa,EAC5B,IAAI,EAAC,OAAO,KACR,KAAK;YAET,oBAAC,eAAe,CAAC,OAAO,IAAC,KAAK,EAAE,KAAK,GAAI;YACzC,oBAAC,eAAe,CAAC,OAAO,IAAC,SAAS,EAAC,+BAA+B,IAC/D,QAAQ,CAAC,MAAM,IAAI,QAAQ,CACJ,CACF,CAC3B,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { ExpandableBlock } from \"@itwin/itwinui-react\";\nimport { HighlightedText } from \"../../common/HighlightedText.js\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\n\n/**\n * Properties for the [[PropertyCategoryBlock]] React component\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface PropertyCategoryBlockProps extends CommonProps {\n /** Category of the properties */\n category: PropertyCategory;\n /** Callback to when PropertyCategoryBlock gets expended or collapsed */\n onExpansionToggled?: (categoryName: string) => void;\n /** Properties used for highlighting */\n highlight?: HighlightingComponentProps;\n /** Content */\n children?: React.ReactNode;\n}\n\n/**\n * PropertyCategoryBlock React component\n * @public\n */\nexport class PropertyCategoryBlock extends React.Component<PropertyCategoryBlockProps> {\n constructor(props: PropertyCategoryBlockProps) {\n super(props);\n }\n\n private toggleExpansion() {\n if (this.props.onExpansionToggled)\n this.props.onExpansionToggled(this.props.category.name);\n }\n\n private _handleToggle = (_isExpanding: boolean): void => {\n this.toggleExpansion();\n };\n\n public override render() {\n const { highlight, category, children, onExpansionToggled, ...other } =\n this.props;\n const activeMatchIndex =\n this.props.category.name ===\n highlight?.activeHighlight?.highlightedItemIdentifier\n ? highlight.activeHighlight.highlightIndex\n : undefined;\n const label = highlight ? (\n <HighlightedText\n text={category.label}\n activeMatchIndex={activeMatchIndex}\n searchText={highlight.highlightedText}\n />\n ) : (\n category.label\n );\n return (\n <ExpandableBlock.Wrapper\n isExpanded={category.expand}\n onToggle={this._handleToggle}\n size=\"small\"\n {...other}\n >\n <ExpandableBlock.Trigger label={label} />\n <ExpandableBlock.Content className=\"components-expandable-content\">\n {category.expand && children}\n </ExpandableBlock.Content>\n </ExpandableBlock.Wrapper>\n );\n }\n}\n"]}
@@ -33,14 +33,14 @@ export class PropertyGridCommons {
33
33
  }
34
34
  openLink(foundLink.url);
35
35
  }
36
+ /**
37
+ * A helper method to get links from string.
38
+ * @internal
39
+ */
40
+ static getLinks = (value) => {
41
+ return matchLinks(value).map((linkInfo) => {
42
+ return { start: linkInfo.index, end: linkInfo.lastIndex };
43
+ });
44
+ };
36
45
  }
37
- /**
38
- * A helper method to get links from string.
39
- * @internal
40
- */
41
- PropertyGridCommons.getLinks = (value) => {
42
- return matchLinks(value).map((linkInfo) => {
43
- return { start: linkInfo.index, end: linkInfo.lastIndex };
44
- });
45
- };
46
46
  //# sourceMappingURL=PropertyGridCommons.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyGridCommons.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridCommons.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAKH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAM7D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AA8F1D,gBAAgB;AAChB,MAAM,OAAO,mBAAmB;IACvB,MAAM,CAAC,qBAAqB,CACjC,KAAa,EACb,oBAAkC,EAClC,kBAA4B,EAC5B,6BAAsC;QAEtC,MAAM,WAAW,GAAG,oBAAoB,IAAI,WAAW,CAAC,UAAU,CAAC;QACnE,IAAI,kBAAkB;YAAE,OAAO,WAAW,CAAC;QAE3C,6BAA6B,GAAG,6BAA6B,IAAI,GAAG,CAAC;QACrE,wCAAwC;QACxC,IAAI,KAAK,GAAG,6BAA6B;YAAE,OAAO,WAAW,CAAC,QAAQ,CAAC;QAEvE,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,IAAY;QACxC,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC;YAAE,OAAO;QACnC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;;AAED;;;GAGG;AACW,4BAAQ,GAAG,CACvB,KAAa,EAC0B,EAAE;IACzC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAC1B,CAAC,QAA8C,EAAE,EAAE;QACjD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;IAC5D,CAAC,CACF,CAAC;AACJ,CAAC,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 PropertyGrid\n */\n\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps.js\";\nimport { matchLinks, openLink } from \"../../common/Links.js\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport type { ActionButtonRenderer } from \"../../properties/renderers/ActionButtonRenderer.js\";\nimport type { PropertyValueRendererManager } from \"../../properties/ValueRendererManager.js\";\nimport type { FilteredType } from \"../dataproviders/filterers/PropertyDataFiltererBase.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\nimport { Orientation } from \"../../common/Orientation.js\";\n\n/** Arguments for the Property Editing event callback\n * @public\n */\nexport interface PropertyEditingArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** Unique key of currently edited property */\n propertyKey?: string;\n}\n\n/** Arguments for `PropertyGridProps.onPropertyContextMenu` callback\n * @public\n */\nexport interface PropertyGridContextMenuArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** An event which caused the context menu callback */\n event: React.MouseEvent;\n}\n\n/**\n * Common Property Grid Props to be used by Property Grid Variants\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface CommonPropertyGridProps extends CommonProps {\n /** Grid orientation. When not defined, it is chosen automatically based on width of the grid. */\n orientation?: Orientation;\n\n /** Enables/disables property hovering effect */\n isPropertyHoverEnabled?: boolean;\n\n /** Called to show a context menu when properties are right-clicked */\n onPropertyContextMenu?: (args: PropertyGridContextMenuArgs) => void;\n\n /** Enables/disables property selection */\n isPropertySelectionEnabled?: boolean;\n /** Enables/disables property selection with right click */\n isPropertySelectionOnRightClickEnabled?: boolean;\n /** Callback to property selection */\n onPropertySelectionChanged?: (property: PropertyRecord) => void;\n\n /** Enables/disables property editing */\n isPropertyEditingEnabled?: boolean;\n /** Callback for when properties are being edited */\n onPropertyEditing?: (\n args: PropertyEditingArgs,\n category: PropertyCategory\n ) => void;\n /** Callback for when properties are updated */\n onPropertyUpdated?: (\n args: PropertyUpdatedArgs,\n category: PropertyCategory\n ) => Promise<boolean>;\n\n /** Custom property value renderer manager */\n propertyValueRendererManager?: PropertyValueRendererManager;\n\n /** Indicates whether the orientation is fixed and does not auto-switch to Vertical when the width is too narrow. Defaults to false. */\n isOrientationFixed?: boolean;\n /** The minimum width before the auto-switch to Vertical when the width is too narrow. Defaults to 300. */\n horizontalOrientationMinWidth?: number;\n\n /** Minimum allowed label column width, after which resizing stops */\n minLabelWidth?: number;\n /** Minimum allowed value column width, after which resizing stops */\n minValueWidth?: number;\n /** Fixed action button column width */\n actionButtonWidth?: number;\n\n /**\n * Array of action button renderers. Each renderer is called for each property and can decide\n * to render an action button for the property or not.\n */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Callback to determine which editors should be always visible */\n alwaysShowEditor?: (property: PropertyRecord) => boolean;\n}\n\n/**\n * Properties for highlighting text in property grid.\n * @public\n */\nexport interface PropertyGridContentHighlightProps\n extends HighlightingComponentProps {\n /**\n * Specifies what the highlighting should be applied on - category labels, property labels and / or property values.\n * Defaults to \"nowhere\".\n */\n filteredTypes?: FilteredType[];\n}\n\n/** @internal */\nexport class PropertyGridCommons {\n public static getCurrentOrientation(\n width: number,\n preferredOrientation?: Orientation,\n isOrientationFixed?: boolean,\n horizontalOrientationMinWidth?: number\n ): Orientation {\n const orientation = preferredOrientation ?? Orientation.Horizontal;\n if (isOrientationFixed) return orientation;\n\n horizontalOrientationMinWidth = horizontalOrientationMinWidth ?? 300;\n // Switch to Vertical if width too small\n if (width < horizontalOrientationMinWidth) return Orientation.Vertical;\n\n return orientation;\n }\n\n /**\n * Helper method to handle link clicks\n * @internal\n */\n public static handleLinkClick(text: string) {\n const linksArray = matchLinks(text);\n if (linksArray.length <= 0) return;\n const foundLink = linksArray[0];\n if (!foundLink || !foundLink.url) {\n return;\n }\n\n openLink(foundLink.url);\n }\n\n /**\n * A helper method to get links from string.\n * @internal\n */\n public static getLinks = (\n value: string\n ): Array<{ start: number; end: number }> => {\n return matchLinks(value).map(\n (linkInfo: { index: number; lastIndex: number }) => {\n return { start: linkInfo.index, end: linkInfo.lastIndex };\n }\n );\n };\n}\n"]}
1
+ {"version":3,"file":"PropertyGridCommons.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridCommons.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAKH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAM7D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AA8F1D,gBAAgB;AAChB,MAAM,OAAO,mBAAmB;IACvB,MAAM,CAAC,qBAAqB,CACjC,KAAa,EACb,oBAAkC,EAClC,kBAA4B,EAC5B,6BAAsC;QAEtC,MAAM,WAAW,GAAG,oBAAoB,IAAI,WAAW,CAAC,UAAU,CAAC;QACnE,IAAI,kBAAkB;YAAE,OAAO,WAAW,CAAC;QAE3C,6BAA6B,GAAG,6BAA6B,IAAI,GAAG,CAAC;QACrE,wCAAwC;QACxC,IAAI,KAAK,GAAG,6BAA6B;YAAE,OAAO,WAAW,CAAC,QAAQ,CAAC;QAEvE,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,IAAY;QACxC,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC;YAAE,OAAO;QACnC,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,QAAQ,GAAG,CACvB,KAAa,EAC0B,EAAE;QACzC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAC1B,CAAC,QAA8C,EAAE,EAAE;YACjD,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;QAC5D,CAAC,CACF,CAAC;IACJ,CAAC,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 PropertyGrid\n */\n\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { HighlightingComponentProps } from \"../../common/HighlightingComponentProps.js\";\nimport { matchLinks, openLink } from \"../../common/Links.js\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport type { ActionButtonRenderer } from \"../../properties/renderers/ActionButtonRenderer.js\";\nimport type { PropertyValueRendererManager } from \"../../properties/ValueRendererManager.js\";\nimport type { FilteredType } from \"../dataproviders/filterers/PropertyDataFiltererBase.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\nimport { Orientation } from \"../../common/Orientation.js\";\n\n/** Arguments for the Property Editing event callback\n * @public\n */\nexport interface PropertyEditingArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** Unique key of currently edited property */\n propertyKey?: string;\n}\n\n/** Arguments for `PropertyGridProps.onPropertyContextMenu` callback\n * @public\n */\nexport interface PropertyGridContextMenuArgs {\n /** PropertyRecord being edited */\n propertyRecord: PropertyRecord;\n /** An event which caused the context menu callback */\n event: React.MouseEvent;\n}\n\n/**\n * Common Property Grid Props to be used by Property Grid Variants\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface CommonPropertyGridProps extends CommonProps {\n /** Grid orientation. When not defined, it is chosen automatically based on width of the grid. */\n orientation?: Orientation;\n\n /** Enables/disables property hovering effect */\n isPropertyHoverEnabled?: boolean;\n\n /** Called to show a context menu when properties are right-clicked */\n onPropertyContextMenu?: (args: PropertyGridContextMenuArgs) => void;\n\n /** Enables/disables property selection */\n isPropertySelectionEnabled?: boolean;\n /** Enables/disables property selection with right click */\n isPropertySelectionOnRightClickEnabled?: boolean;\n /** Callback to property selection */\n onPropertySelectionChanged?: (property: PropertyRecord) => void;\n\n /** Enables/disables property editing */\n isPropertyEditingEnabled?: boolean;\n /** Callback for when properties are being edited */\n onPropertyEditing?: (\n args: PropertyEditingArgs,\n category: PropertyCategory\n ) => void;\n /** Callback for when properties are updated */\n onPropertyUpdated?: (\n args: PropertyUpdatedArgs,\n category: PropertyCategory\n ) => Promise<boolean>;\n\n /** Custom property value renderer manager */\n propertyValueRendererManager?: PropertyValueRendererManager;\n\n /** Indicates whether the orientation is fixed and does not auto-switch to Vertical when the width is too narrow. Defaults to false. */\n isOrientationFixed?: boolean;\n /** The minimum width before the auto-switch to Vertical when the width is too narrow. Defaults to 300. */\n horizontalOrientationMinWidth?: number;\n\n /** Minimum allowed label column width, after which resizing stops */\n minLabelWidth?: number;\n /** Minimum allowed value column width, after which resizing stops */\n minValueWidth?: number;\n /** Fixed action button column width */\n actionButtonWidth?: number;\n\n /**\n * Array of action button renderers. Each renderer is called for each property and can decide\n * to render an action button for the property or not.\n */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Callback to determine which editors should be always visible */\n alwaysShowEditor?: (property: PropertyRecord) => boolean;\n}\n\n/**\n * Properties for highlighting text in property grid.\n * @public\n */\nexport interface PropertyGridContentHighlightProps\n extends HighlightingComponentProps {\n /**\n * Specifies what the highlighting should be applied on - category labels, property labels and / or property values.\n * Defaults to \"nowhere\".\n */\n filteredTypes?: FilteredType[];\n}\n\n/** @internal */\nexport class PropertyGridCommons {\n public static getCurrentOrientation(\n width: number,\n preferredOrientation?: Orientation,\n isOrientationFixed?: boolean,\n horizontalOrientationMinWidth?: number\n ): Orientation {\n const orientation = preferredOrientation ?? Orientation.Horizontal;\n if (isOrientationFixed) return orientation;\n\n horizontalOrientationMinWidth = horizontalOrientationMinWidth ?? 300;\n // Switch to Vertical if width too small\n if (width < horizontalOrientationMinWidth) return Orientation.Vertical;\n\n return orientation;\n }\n\n /**\n * Helper method to handle link clicks\n * @internal\n */\n public static handleLinkClick(text: string) {\n const linksArray = matchLinks(text);\n if (linksArray.length <= 0) return;\n const foundLink = linksArray[0];\n if (!foundLink || !foundLink.url) {\n return;\n }\n\n openLink(foundLink.url);\n }\n\n /**\n * A helper method to get links from string.\n * @internal\n */\n public static getLinks = (\n value: string\n ): Array<{ start: number; end: number }> => {\n return matchLinks(value).map(\n (linkInfo: { index: number; lastIndex: number }) => {\n return { start: linkInfo.index, end: linkInfo.lastIndex };\n }\n );\n };\n}\n"]}
@@ -13,28 +13,6 @@ import * as React from "react";
13
13
  export class PropertyGridEventsRelatedPropsSupplier extends React.Component {
14
14
  constructor(props) {
15
15
  super(props);
16
- this._onPropertyRightClicked = (property, key) => {
17
- if (this._isRightClickSupported())
18
- this.onEnabledPropertyRightClicked(property, key);
19
- };
20
- this._onPropertyClicked = (property, key) => {
21
- if (this._isClickSupported())
22
- this.onEnabledPropertyLeftClicked(property, key);
23
- };
24
- this._onPropertyContextMenu = (property, e) => {
25
- if (this.props.onPropertyContextMenu) {
26
- this.props.onPropertyContextMenu({ propertyRecord: property, event: e });
27
- }
28
- };
29
- this._onEditCommit = async (args, category) => {
30
- if (this.props.onPropertyUpdated) {
31
- await this.props.onPropertyUpdated(args, category);
32
- this.setState({ editingPropertyKey: undefined });
33
- }
34
- };
35
- this._onEditCancel = () => {
36
- this.setState({ editingPropertyKey: undefined });
37
- };
38
16
  this.state = {};
39
17
  }
40
18
  _isClickSupported() {
@@ -44,6 +22,28 @@ export class PropertyGridEventsRelatedPropsSupplier extends React.Component {
44
22
  _isRightClickSupported() {
45
23
  return this.props.isPropertySelectionOnRightClickEnabled;
46
24
  }
25
+ _onPropertyRightClicked = (property, key) => {
26
+ if (this._isRightClickSupported())
27
+ this.onEnabledPropertyRightClicked(property, key);
28
+ };
29
+ _onPropertyClicked = (property, key) => {
30
+ if (this._isClickSupported())
31
+ this.onEnabledPropertyLeftClicked(property, key);
32
+ };
33
+ _onPropertyContextMenu = (property, e) => {
34
+ if (this.props.onPropertyContextMenu) {
35
+ this.props.onPropertyContextMenu({ propertyRecord: property, event: e });
36
+ }
37
+ };
38
+ _onEditCommit = async (args, category) => {
39
+ if (this.props.onPropertyUpdated) {
40
+ await this.props.onPropertyUpdated(args, category);
41
+ this.setState({ editingPropertyKey: undefined });
42
+ }
43
+ };
44
+ _onEditCancel = () => {
45
+ this.setState({ editingPropertyKey: undefined });
46
+ };
47
47
  onEnabledPropertyRightClicked(property, key) {
48
48
  let selectedPropertyKey = this.state.selectedPropertyKey;
49
49
  let editingPropertyKey = this.state.editingPropertyKey;
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyGridEventsRelatedPropsSupplier.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;GAEG;AACH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA2D/B;;GAEG;AACH,MAAM,OAAO,sCAAuC,SAAQ,KAAK,CAAC,SAGjE;IACC,YAAY,KAAkD;QAC5D,KAAK,CAAC,KAAK,CAAC,CAAC;QAeP,4BAAuB,GAAG,CAChC,QAAwB,EACxB,GAAY,EACZ,EAAE;YACF,IAAI,IAAI,CAAC,sBAAsB,EAAE;gBAC/B,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACtD,CAAC,CAAC;QAEM,uBAAkB,GAAG,CAAC,QAAwB,EAAE,GAAY,EAAE,EAAE;YACtE,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAC1B,IAAI,CAAC,4BAA4B,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACrD,CAAC,CAAC;QAEM,2BAAsB,GAAG,CAC/B,QAAwB,EACxB,CAAmB,EACnB,EAAE;YACF,IAAI,IAAI,CAAC,KAAK,CAAC,qBAAq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AAI,CAAC,KAAK,CAAC,wBAAwB;YAC7D,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB;YACnD,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,kBAAkB;YACjD,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE;gBACzC,CAAC,CAAC,IAAI,CAAC,kBAAkB;gBACzB,CAAC,CAAC,SAAS;YACb,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EAAE;gBACnD,CAAC,CAAC,IAAI,CAAC,uBAAuB;gBAC9B,CAAC,CAAC,SAAS;YACb,qBAAqB,EAAE,IAAI,CAAC,KAAK,CAAC,qBAAqB;gBACrD,CAAC,CAAC,IAAI,CAAC,sBAAsB;gBAC7B,CAAC,CAAC,SAAS;SACd,CAAC;QAEF,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,QAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAkB,CACtE,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module PropertyGrid\n */\nimport \"./PropertyGrid.scss\";\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\nimport type { CommonPropertyGridProps } from \"./PropertyGridCommons.js\";\nimport type { PropertyListProps } from \"./PropertyList.js\";\n\n/** @internal */\nexport type PropertyGridEventsRelatedProps = Pick<\n PropertyListProps,\n | \"onPropertyClicked\"\n | \"onPropertyRightClicked\"\n | \"onPropertyContextMenu\"\n | \"onEditCommit\"\n | \"onEditCancel\"\n | \"selectedPropertyKey\"\n | \"editingPropertyKey\"\n> &\n Pick<\n CommonPropertyGridProps,\n \"isPropertySelectionOnRightClickEnabled\" | \"isPropertyEditingEnabled\"\n > &\n Required<\n Pick<\n CommonPropertyGridProps,\n \"isPropertyHoverEnabled\" | \"isPropertySelectionEnabled\"\n >\n >;\n\n/** Properties for [[PropertyGridEventsRelatedPropsSupplier]] React component\n * @internal\n */\nexport type PropertyGridEventsRelatedPropsSupplierProps = Pick<\n CommonPropertyGridProps,\n | \"onPropertyContextMenu\"\n | \"isPropertySelectionOnRightClickEnabled\"\n | \"onPropertySelectionChanged\"\n | \"isPropertyEditingEnabled\"\n | \"onPropertyUpdated\"\n> &\n Required<\n Pick<\n CommonPropertyGridProps,\n \"isPropertyHoverEnabled\" | \"isPropertySelectionEnabled\"\n >\n > & {\n children: (context: PropertyGridEventsRelatedProps) => React.ReactNode;\n };\n\n/** State of [[PropertyGridEventsRelatedPropsSupplier]] React component\n * @internal\n */\ninterface PropertyGridEventsRelatedPropsSupplierState {\n /** Unique key of currently selected property */\n selectedPropertyKey?: string;\n /** Unique key of currently edited property */\n editingPropertyKey?: string;\n}\n\n/** PropertyGridEventsRelatedPropsSupplier React component.\n * @internal\n */\nexport class PropertyGridEventsRelatedPropsSupplier extends React.Component<\n PropertyGridEventsRelatedPropsSupplierProps,\n PropertyGridEventsRelatedPropsSupplierState\n> {\n constructor(props: PropertyGridEventsRelatedPropsSupplierProps) {\n super(props);\n this.state = {};\n }\n\n private _isClickSupported() {\n return (\n this.props.isPropertySelectionEnabled ||\n this.props.isPropertyEditingEnabled\n );\n }\n\n private _isRightClickSupported() {\n return this.props.isPropertySelectionOnRightClickEnabled;\n }\n\n private _onPropertyRightClicked = (\n property: PropertyRecord,\n key?: string\n ) => {\n if (this._isRightClickSupported())\n this.onEnabledPropertyRightClicked(property, key);\n };\n\n private _onPropertyClicked = (property: PropertyRecord, key?: string) => {\n if (this._isClickSupported())\n this.onEnabledPropertyLeftClicked(property, key);\n };\n\n private _onPropertyContextMenu = (\n property: PropertyRecord,\n e: React.MouseEvent\n ) => {\n if (this.props.onPropertyContextMenu) {\n this.props.onPropertyContextMenu({ propertyRecord: property, event: e });\n }\n };\n\n private _onEditCommit = async (\n args: PropertyUpdatedArgs,\n category: PropertyCategory\n ) => {\n if (this.props.onPropertyUpdated) {\n await this.props.onPropertyUpdated(args, category);\n this.setState({ editingPropertyKey: undefined });\n }\n };\n\n private _onEditCancel = () => {\n this.setState({ editingPropertyKey: undefined });\n };\n\n private onEnabledPropertyRightClicked(\n property: PropertyRecord,\n key: string | undefined\n ) {\n let selectedPropertyKey = this.state.selectedPropertyKey;\n let editingPropertyKey = this.state.editingPropertyKey;\n\n editingPropertyKey = undefined;\n if (selectedPropertyKey !== key) selectedPropertyKey = key;\n\n if (this.props.onPropertySelectionChanged)\n this.props.onPropertySelectionChanged(property);\n\n this.setState({ selectedPropertyKey, editingPropertyKey });\n }\n\n private onEnabledPropertyLeftClicked(\n property: PropertyRecord,\n key: string | undefined\n ) {\n let selectedPropertyKey = this.state.selectedPropertyKey;\n let editingPropertyKey = this.state.editingPropertyKey;\n\n const isEditingEnabled = this.props.isPropertyEditingEnabled;\n const isSelectionEnabled = this.props.isPropertySelectionEnabled;\n\n if (isEditingEnabled) {\n // Deselect editing key only if another selection was made\n editingPropertyKey =\n isSelectionEnabled && selectedPropertyKey !== key ? undefined : key;\n }\n\n if (editingPropertyKey === key) {\n this.setState({ editingPropertyKey });\n return;\n }\n\n // Select/Deselect\n selectedPropertyKey = selectedPropertyKey !== key ? key : undefined;\n\n if (this.props.onPropertySelectionChanged)\n this.props.onPropertySelectionChanged(property);\n\n this.setState({ selectedPropertyKey, editingPropertyKey });\n }\n\n public override render() {\n const renderContext: PropertyGridEventsRelatedProps = {\n isPropertyHoverEnabled: this.props.isPropertyHoverEnabled,\n isPropertySelectionEnabled: this.props.isPropertySelectionEnabled,\n isPropertySelectionOnRightClickEnabled:\n this.props.isPropertySelectionOnRightClickEnabled,\n isPropertyEditingEnabled: this.props.isPropertyEditingEnabled,\n selectedPropertyKey: this.state.selectedPropertyKey,\n editingPropertyKey: this.state.editingPropertyKey,\n onEditCommit: this._onEditCommit,\n onEditCancel: this._onEditCancel,\n onPropertyClicked: this._isClickSupported()\n ? this._onPropertyClicked\n : undefined,\n onPropertyRightClicked: this._isRightClickSupported()\n ? this._onPropertyRightClicked\n : undefined,\n onPropertyContextMenu: this.props.onPropertyContextMenu\n ? this._onPropertyContextMenu\n : undefined,\n };\n\n return (\n <React.Fragment>{this.props.children(renderContext)}</React.Fragment>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"PropertyGridEventsRelatedPropsSupplier.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;GAEG;AACH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA2D/B;;GAEG;AACH,MAAM,OAAO,sCAAuC,SAAQ,KAAK,CAAC,SAGjE;IACC,YAAY,KAAkD;QAC5D,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IAEO,iBAAiB;QACvB,OAAO,CACL,IAAI,CAAC,KAAK,CAAC,0BAA0B;YACrC,IAAI,CAAC,KAAK,CAAC,wBAAwB,CACpC,CAAC;IACJ,CAAC;IAEO,sBAAsB;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,sCAAsC,CAAC;IAC3D,CAAC;IAEO,uBAAuB,GAAG,CAChC,QAAwB,EACxB,GAAY,EACZ,EAAE;QACF,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC,CAAC;IAEM,kBAAkB,GAAG,CAAC,QAAwB,EAAE,GAAY,EAAE,EAAE;QACtE,IAAI,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,CAAC,KAAK,CAAC,mBAAmB;YACnD,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,kBAAkB;YACjD,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,YAAY,EAAE,IAAI,CAAC,aAAa;YAChC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE;gBACzC,CAAC,CAAC,IAAI,CAAC,kBAAkB;gBACzB,CAAC,CAAC,SAAS;YACb,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EAAE;gBACnD,CAAC,CAAC,IAAI,CAAC,uBAAuB;gBAC9B,CAAC,CAAC,SAAS;YACb,qBAAqB,EAAE,IAAI,CAAC,KAAK,CAAC,qBAAqB;gBACrD,CAAC,CAAC,IAAI,CAAC,sBAAsB;gBAC7B,CAAC,CAAC,SAAS;SACd,CAAC;QAEF,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,QAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAkB,CACtE,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module PropertyGrid\n */\nimport \"./PropertyGrid.scss\";\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type { PropertyUpdatedArgs } from \"../../editors/EditorContainer.js\";\nimport type { PropertyCategory } from \"../PropertyDataProvider.js\";\nimport type { CommonPropertyGridProps } from \"./PropertyGridCommons.js\";\nimport type { PropertyListProps } from \"./PropertyList.js\";\n\n/** @internal */\nexport type PropertyGridEventsRelatedProps = Pick<\n PropertyListProps,\n | \"onPropertyClicked\"\n | \"onPropertyRightClicked\"\n | \"onPropertyContextMenu\"\n | \"onEditCommit\"\n | \"onEditCancel\"\n | \"selectedPropertyKey\"\n | \"editingPropertyKey\"\n> &\n Pick<\n CommonPropertyGridProps,\n \"isPropertySelectionOnRightClickEnabled\" | \"isPropertyEditingEnabled\"\n > &\n Required<\n Pick<\n CommonPropertyGridProps,\n \"isPropertyHoverEnabled\" | \"isPropertySelectionEnabled\"\n >\n >;\n\n/** Properties for [[PropertyGridEventsRelatedPropsSupplier]] React component\n * @internal\n */\nexport type PropertyGridEventsRelatedPropsSupplierProps = Pick<\n CommonPropertyGridProps,\n | \"onPropertyContextMenu\"\n | \"isPropertySelectionOnRightClickEnabled\"\n | \"onPropertySelectionChanged\"\n | \"isPropertyEditingEnabled\"\n | \"onPropertyUpdated\"\n> &\n Required<\n Pick<\n CommonPropertyGridProps,\n \"isPropertyHoverEnabled\" | \"isPropertySelectionEnabled\"\n >\n > & {\n children: (context: PropertyGridEventsRelatedProps) => React.ReactNode;\n };\n\n/** State of [[PropertyGridEventsRelatedPropsSupplier]] React component\n * @internal\n */\ninterface PropertyGridEventsRelatedPropsSupplierState {\n /** Unique key of currently selected property */\n selectedPropertyKey?: string;\n /** Unique key of currently edited property */\n editingPropertyKey?: string;\n}\n\n/** PropertyGridEventsRelatedPropsSupplier React component.\n * @internal\n */\nexport class PropertyGridEventsRelatedPropsSupplier extends React.Component<\n PropertyGridEventsRelatedPropsSupplierProps,\n PropertyGridEventsRelatedPropsSupplierState\n> {\n constructor(props: PropertyGridEventsRelatedPropsSupplierProps) {\n super(props);\n this.state = {};\n }\n\n private _isClickSupported() {\n return (\n this.props.isPropertySelectionEnabled ||\n this.props.isPropertyEditingEnabled\n );\n }\n\n private _isRightClickSupported() {\n return this.props.isPropertySelectionOnRightClickEnabled;\n }\n\n private _onPropertyRightClicked = (\n property: PropertyRecord,\n key?: string\n ) => {\n if (this._isRightClickSupported())\n this.onEnabledPropertyRightClicked(property, key);\n };\n\n private _onPropertyClicked = (property: PropertyRecord, key?: string) => {\n if (this._isClickSupported())\n this.onEnabledPropertyLeftClicked(property, key);\n };\n\n private _onPropertyContextMenu = (\n property: PropertyRecord,\n e: React.MouseEvent\n ) => {\n if (this.props.onPropertyContextMenu) {\n this.props.onPropertyContextMenu({ propertyRecord: property, event: e });\n }\n };\n\n private _onEditCommit = async (\n args: PropertyUpdatedArgs,\n category: PropertyCategory\n ) => {\n if (this.props.onPropertyUpdated) {\n await this.props.onPropertyUpdated(args, category);\n this.setState({ editingPropertyKey: undefined });\n }\n };\n\n private _onEditCancel = () => {\n this.setState({ editingPropertyKey: undefined });\n };\n\n private onEnabledPropertyRightClicked(\n property: PropertyRecord,\n key: string | undefined\n ) {\n let selectedPropertyKey = this.state.selectedPropertyKey;\n let editingPropertyKey = this.state.editingPropertyKey;\n\n editingPropertyKey = undefined;\n if (selectedPropertyKey !== key) selectedPropertyKey = key;\n\n if (this.props.onPropertySelectionChanged)\n this.props.onPropertySelectionChanged(property);\n\n this.setState({ selectedPropertyKey, editingPropertyKey });\n }\n\n private onEnabledPropertyLeftClicked(\n property: PropertyRecord,\n key: string | undefined\n ) {\n let selectedPropertyKey = this.state.selectedPropertyKey;\n let editingPropertyKey = this.state.editingPropertyKey;\n\n const isEditingEnabled = this.props.isPropertyEditingEnabled;\n const isSelectionEnabled = this.props.isPropertySelectionEnabled;\n\n if (isEditingEnabled) {\n // Deselect editing key only if another selection was made\n editingPropertyKey =\n isSelectionEnabled && selectedPropertyKey !== key ? undefined : key;\n }\n\n if (editingPropertyKey === key) {\n this.setState({ editingPropertyKey });\n return;\n }\n\n // Select/Deselect\n selectedPropertyKey = selectedPropertyKey !== key ? key : undefined;\n\n if (this.props.onPropertySelectionChanged)\n this.props.onPropertySelectionChanged(property);\n\n this.setState({ selectedPropertyKey, editingPropertyKey });\n }\n\n public override render() {\n const renderContext: PropertyGridEventsRelatedProps = {\n isPropertyHoverEnabled: this.props.isPropertyHoverEnabled,\n isPropertySelectionEnabled: this.props.isPropertySelectionEnabled,\n isPropertySelectionOnRightClickEnabled:\n this.props.isPropertySelectionOnRightClickEnabled,\n isPropertyEditingEnabled: this.props.isPropertyEditingEnabled,\n selectedPropertyKey: this.state.selectedPropertyKey,\n editingPropertyKey: this.state.editingPropertyKey,\n onEditCommit: this._onEditCommit,\n onEditCancel: this._onEditCancel,\n onPropertyClicked: this._isClickSupported()\n ? this._onPropertyClicked\n : undefined,\n onPropertyRightClicked: this._isRightClickSupported()\n ? this._onPropertyRightClicked\n : undefined,\n onPropertyContextMenu: this.props.onPropertyContextMenu\n ? this._onPropertyContextMenu\n : undefined,\n };\n\n return (\n <React.Fragment>{this.props.children(renderContext)}</React.Fragment>\n );\n }\n}\n"]}