@itwin/grouping-mapping-widget 0.2.1 → 0.3.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 (95) hide show
  1. package/lib/cjs/widget/components/ActionPanel.d.ts +3 -2
  2. package/lib/cjs/widget/components/ActionPanel.js +6 -4
  3. package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
  4. package/lib/cjs/widget/components/CalculatedPropertyAction.js +8 -3
  5. package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
  6. package/lib/cjs/widget/components/CalculatedPropertyAction.scss +5 -5
  7. package/lib/cjs/widget/components/ConfirmMappingsImport.js +30 -12
  8. package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
  9. package/lib/cjs/widget/components/ConfirmMappingsImport.scss +0 -7
  10. package/lib/cjs/widget/components/CustomCalculationAction.js +1 -1
  11. package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
  12. package/lib/cjs/widget/components/DeleteModal.js +4 -2
  13. package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
  14. package/lib/cjs/widget/components/DeleteModal.scss +6 -0
  15. package/lib/cjs/widget/components/GroupAction.js +97 -18
  16. package/lib/cjs/widget/components/GroupAction.js.map +1 -1
  17. package/lib/cjs/widget/components/GroupAction.scss +23 -0
  18. package/lib/cjs/widget/components/GroupPropertyAction.js +51 -20
  19. package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
  20. package/lib/cjs/widget/components/GroupQueryBuilderContext.d.ts +2 -0
  21. package/lib/cjs/widget/components/GroupQueryBuilderContext.js +2 -0
  22. package/lib/cjs/widget/components/GroupQueryBuilderContext.js.map +1 -1
  23. package/lib/cjs/widget/components/Grouping.js +8 -5
  24. package/lib/cjs/widget/components/Grouping.js.map +1 -1
  25. package/lib/cjs/widget/components/MappingAction.js +1 -1
  26. package/lib/cjs/widget/components/MappingAction.js.map +1 -1
  27. package/lib/cjs/widget/components/PropertyMenu.js +4 -0
  28. package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
  29. package/lib/cjs/widget/components/QueryBuilder.d.ts +1 -1
  30. package/lib/cjs/widget/components/QueryBuilder.js +12 -6
  31. package/lib/cjs/widget/components/QueryBuilder.js.map +1 -1
  32. package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js +7 -3
  33. package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -1
  34. package/lib/cjs/widget/components/property-grid/PropertyGrid.scss +3 -3
  35. package/lib/cjs/widget/components/property-grid/PropertyRender.d.ts +1 -1
  36. package/lib/cjs/widget/components/property-grid/PropertyRender.js +5 -8
  37. package/lib/cjs/widget/components/property-grid/PropertyRender.js.map +1 -1
  38. package/lib/cjs/widget/components/property-grid/PropertyView.d.ts +2 -0
  39. package/lib/cjs/widget/components/property-grid/PropertyView.js +17 -11
  40. package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
  41. package/lib/cjs/widget/components/property-grid/PropertyView.scss +19 -4
  42. package/lib/cjs/widget/components/utils.d.ts +1 -0
  43. package/lib/cjs/widget/components/utils.js +25 -26
  44. package/lib/cjs/widget/components/utils.js.map +1 -1
  45. package/lib/cjs/widget/components/utils.scss +5 -0
  46. package/lib/cjs/widget/components/viewerUtils.js +1 -1
  47. package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
  48. package/lib/esm/widget/components/ActionPanel.d.ts +3 -2
  49. package/lib/esm/widget/components/ActionPanel.js +7 -5
  50. package/lib/esm/widget/components/ActionPanel.js.map +1 -1
  51. package/lib/esm/widget/components/CalculatedPropertyAction.js +8 -3
  52. package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
  53. package/lib/esm/widget/components/CalculatedPropertyAction.scss +5 -5
  54. package/lib/esm/widget/components/ConfirmMappingsImport.js +30 -12
  55. package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
  56. package/lib/esm/widget/components/ConfirmMappingsImport.scss +0 -7
  57. package/lib/esm/widget/components/CustomCalculationAction.js +1 -1
  58. package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
  59. package/lib/esm/widget/components/DeleteModal.js +6 -4
  60. package/lib/esm/widget/components/DeleteModal.js.map +1 -1
  61. package/lib/esm/widget/components/DeleteModal.scss +6 -0
  62. package/lib/esm/widget/components/GroupAction.js +99 -20
  63. package/lib/esm/widget/components/GroupAction.js.map +1 -1
  64. package/lib/esm/widget/components/GroupAction.scss +23 -0
  65. package/lib/esm/widget/components/GroupPropertyAction.js +51 -20
  66. package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
  67. package/lib/esm/widget/components/GroupQueryBuilderContext.d.ts +2 -0
  68. package/lib/esm/widget/components/GroupQueryBuilderContext.js +2 -0
  69. package/lib/esm/widget/components/GroupQueryBuilderContext.js.map +1 -1
  70. package/lib/esm/widget/components/Grouping.js +8 -5
  71. package/lib/esm/widget/components/Grouping.js.map +1 -1
  72. package/lib/esm/widget/components/MappingAction.js +1 -1
  73. package/lib/esm/widget/components/MappingAction.js.map +1 -1
  74. package/lib/esm/widget/components/PropertyMenu.js +4 -0
  75. package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
  76. package/lib/esm/widget/components/QueryBuilder.d.ts +1 -1
  77. package/lib/esm/widget/components/QueryBuilder.js +12 -6
  78. package/lib/esm/widget/components/QueryBuilder.js.map +1 -1
  79. package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js +7 -3
  80. package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -1
  81. package/lib/esm/widget/components/property-grid/PropertyGrid.scss +3 -3
  82. package/lib/esm/widget/components/property-grid/PropertyRender.d.ts +1 -1
  83. package/lib/esm/widget/components/property-grid/PropertyRender.js +5 -8
  84. package/lib/esm/widget/components/property-grid/PropertyRender.js.map +1 -1
  85. package/lib/esm/widget/components/property-grid/PropertyView.d.ts +2 -0
  86. package/lib/esm/widget/components/property-grid/PropertyView.js +17 -11
  87. package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
  88. package/lib/esm/widget/components/property-grid/PropertyView.scss +19 -4
  89. package/lib/esm/widget/components/utils.d.ts +1 -0
  90. package/lib/esm/widget/components/utils.js +24 -26
  91. package/lib/esm/widget/components/utils.js.map +1 -1
  92. package/lib/esm/widget/components/utils.scss +5 -0
  93. package/lib/esm/widget/components/viewerUtils.js +1 -1
  94. package/lib/esm/widget/components/viewerUtils.js.map +1 -1
  95. package/package.json +6 -4
@@ -70,19 +70,16 @@ export class PropertyRenderer extends React.Component {
70
70
  };
71
71
  switch (this.props.propertyRecord.value.valueFormat) {
72
72
  case PropertyValueFormat.Primitive:
73
- return React.createElement(PrimitivePropertyRenderer, { ...primitiveRendererProps });
73
+ return (React.createElement(PrimitivePropertyRenderer, { ...primitiveRendererProps }));
74
74
  case PropertyValueFormat.Array:
75
75
  // If array is empty, render it as a primitive property
76
- if (this.props.propertyRecord.value.valueFormat ===
77
- PropertyValueFormat.Array &&
78
- this.props.propertyRecord.value.items.length === 0) {
79
- return React.createElement(PrimitivePropertyRenderer, { ...primitiveRendererProps });
80
- }
81
- break;
76
+ if (this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array
77
+ && this.props.propertyRecord.value.items.length === 0)
78
+ return (React.createElement(PrimitivePropertyRenderer, { ...primitiveRendererProps }));
79
+ // eslint-disable-next-line no-fallthrough
82
80
  case PropertyValueFormat.Struct:
83
81
  return (React.createElement(NonPrimitivePropertyRenderer, { isCollapsible: true, ...primitiveRendererProps }));
84
82
  }
85
- return;
86
83
  }
87
84
  }
88
85
  //# sourceMappingURL=PropertyRender.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyRender.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyRender.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAO5D,OAAO,EACL,eA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;gBAC5B,uDAAuD;gBACvD,IACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW;oBAC3C,mBAAmB,CAAC,KAAK;oBACzB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAClD;oBACA,OAAO,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAAC;iBAClE;gBACD,MAAM;YACR,KAAK,mBAAmB,CAAC,MAAM;gBAC7B,OAAO,CACL,oBAAC,4BAA4B,IAC3B,aAAa,EAAE,IAAI,KACf,sBAAsB,GAC1B,CACH,CAAC;SACL;QACD,OAAO;IACT,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*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyRecord} from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { Orientation, RatioChangeResult } from \"@itwin/core-react\";\nimport type {\n ActionButtonRenderer,\n PrimitiveRendererProps,\n PropertyUpdatedArgs,\n PropertyValueRendererManager} from \"@itwin/components-react\";\nimport {\n EditorContainer,\n UiComponents,\n} from \"@itwin/components-react\";\n\nimport { NonPrimitivePropertyRenderer } from \"./NonPrimitivePropertyRenderer\";\nimport { PrimitivePropertyRenderer } from \"./PrimitivePropertyRenderer\";\nimport type { PropertyGridColumnInfo } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport type { HighlightingComponentProps } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightingComponentProps\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties shared by all renderers and PropertyView\n * @public\n */\nexport interface SharedRendererProps {\n /** PropertyRecord to render */\n propertyRecord: PropertyRecord;\n /** Unique string, that identifies this property component. Should be used if onClick or onRightClick are provided */\n uniqueKey?: string;\n /** Orientation to use for displaying the property */\n orientation: Orientation;\n /** Controls component selection */\n isSelected?: boolean;\n /** Called when property gets clicked. If undefined, clicking is disabled */\n onClick?: (property: PropertyRecord, key?: string) => void;\n /** Called when property gets right clicked. If undefined, right clicking is not working */\n onRightClick?: (property: PropertyRecord, key?: string) => void;\n /** Called to show a context menu for properties */\n onContextMenu?: (property: PropertyRecord, e: React.MouseEvent) => void;\n /** Ratio between label and value cells */\n columnRatio?: number;\n /** Callback to column ratio changed event */\n onColumnRatioChanged?: (ratio: number) => void | RatioChangeResult;\n /** Indicates that properties have *hover* effect */\n isHoverable?: boolean;\n /** Indicates that properties can be selected */\n isSelectable?: boolean;\n /** Width of the whole property element */\n width?: number;\n /** Array of action button renderers @beta */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Is resize handle hovered */\n isResizeHandleHovered?: boolean;\n /** Callback to hover event change */\n onResizeHandleHoverChanged?: (isHovered: boolean) => void;\n /** Is resize handle being dragged */\n isResizeHandleBeingDragged?: boolean;\n /** Callback to drag event change */\n onResizeHandleDragChanged?: (isDragStarted: boolean) => void;\n /** Information for styling property grid columns */\n columnInfo?: PropertyGridColumnInfo;\n}\n\n/** Properties of [[PropertyRenderer]] React component\n * @public\n */\nexport interface PropertyRendererProps extends SharedRendererProps {\n /** Custom value renderer */\n propertyValueRendererManager?: PropertyValueRendererManager;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Indicates property is being edited @beta */\n isEditing?: boolean;\n /** Called when property edit is committed. @beta */\n onEditCommit?: (args: PropertyUpdatedArgs) => void;\n /** Called when property edit is cancelled. @beta */\n onEditCancel?: () => void;\n /** Props used for highlighting. @beta */\n highlight?: HighlightingComponentProps;\n}\n\n/** State of [[PropertyRenderer]] React component\n * @internal\n */\ninterface PropertyRendererState {\n /** Currently loaded property value */\n displayValue?: React.ReactNode;\n}\n\n/** A React component that renders properties\n * @public\n */\nexport class PropertyRenderer extends React.Component<\nPropertyRendererProps,\nPropertyRendererState\n> {\n /** @internal */\n public override readonly state: Readonly<PropertyRendererState> = {\n displayValue: UiComponents.translate(\"general.loading\"),\n };\n\n public static getLabelOffset(\n indentation?: number,\n orientation?: Orientation,\n width?: number,\n columnRatio?: number,\n minColumnLabelWidth?: number,\n ): number {\n return CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation,\n width,\n columnRatio,\n minColumnLabelWidth,\n );\n }\n\n private updateDisplayValue(props: PropertyRendererProps) {\n if (props.isEditing) {\n this.updateDisplayValueAsEditor(props);\n return;\n }\n\n const displayValue = CommonPropertyRenderer.createNewDisplayValue(\n props.orientation,\n props.propertyRecord,\n props.indentation,\n props.propertyValueRendererManager,\n );\n this.setState({ displayValue });\n }\n\n private _onEditCommit = (args: PropertyUpdatedArgs) => {\n // istanbul ignore else\n if (this.props.onEditCommit) {\n this.props.onEditCommit(args);\n }\n };\n\n private _onEditCancel = () => {\n // istanbul ignore else\n if (this.props.onEditCancel) {\n this.props.onEditCancel();\n }\n };\n\n /** Display property record value in an editor */\n public updateDisplayValueAsEditor(props: PropertyRendererProps) {\n this.setState({\n displayValue: (\n <EditorContainer\n propertyRecord={props.propertyRecord}\n onCommit={this._onEditCommit}\n onCancel={this._onEditCancel}\n setFocus={true}\n />\n ),\n });\n }\n\n /** @internal */\n public override componentDidMount() {\n this.updateDisplayValue(this.props);\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyRendererProps) {\n if (\n prevProps.propertyRecord !== this.props.propertyRecord ||\n prevProps.isEditing !== this.props.isEditing ||\n prevProps.orientation !== this.props.orientation\n ) {\n this.updateDisplayValue(this.props);\n }\n }\n\n /** @internal */\n public override render() {\n const { ...props } = this.props;\n const primitiveRendererProps: PrimitiveRendererProps = {\n ...props,\n valueElement: this.state.displayValue,\n indentation: this.props.indentation,\n };\n\n switch (this.props.propertyRecord.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n return <PrimitivePropertyRenderer {...primitiveRendererProps} />;\n case PropertyValueFormat.Array:\n // If array is empty, render it as a primitive property\n if (\n this.props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Array &&\n this.props.propertyRecord.value.items.length === 0\n ) {\n return <PrimitivePropertyRenderer {...primitiveRendererProps} />;\n }\n break;\n case PropertyValueFormat.Struct:\n return (\n <NonPrimitivePropertyRenderer\n isCollapsible={true}\n {...primitiveRendererProps}\n />\n );\n }\n return;\n }\n}\n"]}
1
+ {"version":3,"file":"PropertyRender.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyRender.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAQ5D,OAAO,EACL,eAAe,EACf,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAGxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8FAA8F,CAAC;AAsEtI;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK,CAAC,SAG3C;IAHD;;QAIE,gBAAgB;QACS,UAAK,GAAoC;YAChE,YAAY,EAAE,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC;SACxD,CAAC;QAiCM,kBAAa,GAAG,CAAC,IAAyB,EAAE,EAAE;YACpD,uBAAuB;YACvB,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;gBAC3B,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;aAC/B;QACH,CAAC,CAAC;QAEM,kBAAa,GAAG,GAAG,EAAE;YAC3B,uBAAuB;YACvB,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;gBAC3B,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;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YACA,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;IACH,CAAC;IAED,gBAAgB;IACA,MAAM;QACpB,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAChC,MAAM,sBAAsB,GAA2B;YACrD,GAAG,KAAK;YACR,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;YACrC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;SACpC,CAAC;QAEF,QAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE;YACnD,KAAK,mBAAmB,CAAC,SAAS;gBAChC,OAAO,CACL,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAC1D,CAAC;YACJ,KAAK,mBAAmB,CAAC,KAAK;gBAC5B,uDAAuD;gBACvD,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,KAAK;uBACxE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;oBACrD,OAAO,CACL,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAC1D,CAAC;YACN,0CAA0C;YAC1C,KAAK,mBAAmB,CAAC,MAAM;gBAC7B,OAAO,CACL,oBAAC,4BAA4B,IAC3B,aAAa,EAAE,IAAI,KACf,sBAAsB,GAC1B,CACH,CAAC;SACL;IACH,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*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { Orientation, RatioChangeResult } from \"@itwin/core-react\";\nimport type {\n ActionButtonRenderer,\n PrimitiveRendererProps,\n PropertyUpdatedArgs,\n PropertyValueRendererManager,\n} from \"@itwin/components-react\";\nimport {\n EditorContainer,\n UiComponents,\n} from \"@itwin/components-react\";\n\nimport { NonPrimitivePropertyRenderer } from \"./NonPrimitivePropertyRenderer\";\nimport { PrimitivePropertyRenderer } from \"./PrimitivePropertyRenderer\";\nimport type { PropertyGridColumnInfo } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport type { HighlightingComponentProps } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightingComponentProps\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties shared by all renderers and PropertyView\n * @public\n */\nexport interface SharedRendererProps {\n /** PropertyRecord to render */\n propertyRecord: PropertyRecord;\n /** Unique string, that identifies this property component. Should be used if onClick or onRightClick are provided */\n uniqueKey?: string;\n /** Orientation to use for displaying the property */\n orientation: Orientation;\n /** Controls component selection */\n isSelected?: boolean;\n /** Called when property gets clicked. If undefined, clicking is disabled */\n onClick?: (property: PropertyRecord, key?: string) => void;\n /** Called when property gets right clicked. If undefined, right clicking is not working */\n onRightClick?: (property: PropertyRecord, key?: string) => void;\n /** Called to show a context menu for properties */\n onContextMenu?: (property: PropertyRecord, e: React.MouseEvent) => void;\n /** Ratio between label and value cells */\n columnRatio?: number;\n /** Callback to column ratio changed event */\n onColumnRatioChanged?: (ratio: number) => void | RatioChangeResult;\n /** Indicates that properties have *hover* effect */\n isHoverable?: boolean;\n /** Indicates that properties can be selected */\n isSelectable?: boolean;\n /** Width of the whole property element */\n width?: number;\n /** Array of action button renderers @beta */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Is resize handle hovered */\n isResizeHandleHovered?: boolean;\n /** Callback to hover event change */\n onResizeHandleHoverChanged?: (isHovered: boolean) => void;\n /** Is resize handle being dragged */\n isResizeHandleBeingDragged?: boolean;\n /** Callback to drag event change */\n onResizeHandleDragChanged?: (isDragStarted: boolean) => void;\n /** Information for styling property grid columns */\n columnInfo?: PropertyGridColumnInfo;\n}\n\n/** Properties of [[PropertyRenderer]] React component\n * @public\n */\nexport interface PropertyRendererProps extends SharedRendererProps {\n /** Custom value renderer */\n propertyValueRendererManager?: PropertyValueRendererManager;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Indicates property is being edited @beta */\n isEditing?: boolean;\n /** Called when property edit is committed. @beta */\n onEditCommit?: (args: PropertyUpdatedArgs) => void;\n /** Called when property edit is cancelled. @beta */\n onEditCancel?: () => void;\n /** Props used for highlighting. @beta */\n highlight?: HighlightingComponentProps;\n}\n\n/** State of [[PropertyRenderer]] React component\n * @internal\n */\ninterface PropertyRendererState {\n /** Currently loaded property value */\n displayValue?: React.ReactNode;\n}\n\n/** A React component that renders properties\n * @public\n */\nexport class PropertyRenderer extends React.Component<\nPropertyRendererProps,\nPropertyRendererState\n> {\n /** @internal */\n public override readonly state: Readonly<PropertyRendererState> = {\n displayValue: UiComponents.translate(\"general.loading\"),\n };\n\n public static getLabelOffset(\n indentation?: number,\n orientation?: Orientation,\n width?: number,\n columnRatio?: number,\n minColumnLabelWidth?: number,\n ): number {\n return CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation,\n width,\n columnRatio,\n minColumnLabelWidth,\n );\n }\n\n private updateDisplayValue(props: PropertyRendererProps) {\n if (props.isEditing) {\n this.updateDisplayValueAsEditor(props);\n return;\n }\n\n const displayValue = CommonPropertyRenderer.createNewDisplayValue(\n props.orientation,\n props.propertyRecord,\n props.indentation,\n props.propertyValueRendererManager,\n );\n this.setState({ displayValue });\n }\n\n private _onEditCommit = (args: PropertyUpdatedArgs) => {\n // istanbul ignore else\n if (this.props.onEditCommit) {\n this.props.onEditCommit(args);\n }\n };\n\n private _onEditCancel = () => {\n // istanbul ignore else\n if (this.props.onEditCancel) {\n this.props.onEditCancel();\n }\n };\n\n /** Display property record value in an editor */\n public updateDisplayValueAsEditor(props: PropertyRendererProps) {\n this.setState({\n displayValue: (\n <EditorContainer\n propertyRecord={props.propertyRecord}\n onCommit={this._onEditCommit}\n onCancel={this._onEditCancel}\n setFocus={true}\n />\n ),\n });\n }\n\n /** @internal */\n public override componentDidMount() {\n this.updateDisplayValue(this.props);\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyRendererProps) {\n if (\n prevProps.propertyRecord !== this.props.propertyRecord ||\n prevProps.isEditing !== this.props.isEditing ||\n prevProps.orientation !== this.props.orientation\n ) {\n this.updateDisplayValue(this.props);\n }\n }\n\n /** @internal */\n public override render() {\n const { ...props } = this.props;\n const primitiveRendererProps: PrimitiveRendererProps = {\n ...props,\n valueElement: this.state.displayValue,\n indentation: this.props.indentation,\n };\n\n switch (this.props.propertyRecord.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n return (\n <PrimitivePropertyRenderer {...primitiveRendererProps} />\n );\n case PropertyValueFormat.Array:\n // If array is empty, render it as a primitive property\n if (this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array\n && this.props.propertyRecord.value.items.length === 0)\n return (\n <PrimitivePropertyRenderer {...primitiveRendererProps} />\n );\n // eslint-disable-next-line no-fallthrough\n case PropertyValueFormat.Struct:\n return (\n <NonPrimitivePropertyRenderer\n isCollapsible={true}\n {...primitiveRendererProps}\n />\n );\n }\n }\n}\n"]}
@@ -11,6 +11,8 @@ export interface PropertyViewProps extends SharedRendererProps {
11
11
  valueElement?: React.ReactNode;
12
12
  /** Render callback for property value. If specified, `valueElement` is ignored. */
13
13
  valueElementRenderer?: () => React.ReactNode;
14
+ /** Multiplier of how much the property is indented to the right */
15
+ indentation?: number;
14
16
  }
15
17
  /**
16
18
  * A React component that renders property as label/value pair
@@ -11,12 +11,15 @@ import { GroupQueryBuilderContext } from "../GroupQueryBuilderContext";
11
11
  import { useCallback } from "react";
12
12
  import { PropertyGridColumnStyleProvider } from "@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns";
13
13
  import { Checkbox } from "@itwin/itwinui-react";
14
+ import { CommonPropertyRenderer } from "@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer";
14
15
  /**
15
16
  * A React component that renders property as label/value pair
16
17
  * @public
17
18
  */
18
19
  export const PropertyView = (props) => {
20
+ var _a;
19
21
  const context = React.useContext(GroupQueryBuilderContext);
22
+ const [isCheckboxLoading, setIsCheckboxLoading] = React.useState(false);
20
23
  const _validatePropertySelection = () => {
21
24
  if (context.currentPropertyList.includes(props.propertyRecord)) {
22
25
  return true;
@@ -58,8 +61,12 @@ export const PropertyView = (props) => {
58
61
  // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)
59
62
  if (!context.currentPropertyList.includes(prop) &&
60
63
  prop.value.valueFormat === PropertyValueFormat.Primitive) {
64
+ if (!(await context.queryBuilder.addProperty(prop))) {
65
+ setIsCheckboxLoading(false);
66
+ setIsPropertySelected(false);
67
+ return;
68
+ }
61
69
  context.setCurrentPropertyList(context.currentPropertyList.concat(prop));
62
- await context.queryBuilder.addProperty(prop);
63
70
  context.setQuery(context.queryBuilder.buildQueryString());
64
71
  }
65
72
  }, [context]);
@@ -109,6 +116,9 @@ export const PropertyView = (props) => {
109
116
  React.useEffect(() => {
110
117
  if (props === null || props === void 0 ? void 0 : props.propertyRecord) {
111
118
  if (isPropertySelected) {
119
+ if (context.isRendering) {
120
+ setIsCheckboxLoading(true);
121
+ }
112
122
  _addNestedProperties(props.propertyRecord);
113
123
  }
114
124
  else {
@@ -120,17 +130,12 @@ export const PropertyView = (props) => {
120
130
  _removeNestedProperties,
121
131
  isPropertySelected,
122
132
  props.propertyRecord,
133
+ context.isRendering,
123
134
  ]);
124
135
  React.useEffect(() => {
125
- if (props === null || props === void 0 ? void 0 : props.propertyRecord) {
126
- if (context.currentPropertyList.includes(props.propertyRecord)) {
127
- setIsPropertySelected(true);
128
- }
129
- else {
130
- setIsPropertySelected(false);
131
- }
132
- }
133
- }, [context.currentPropertyList, props.propertyRecord]);
136
+ if (!context.isRendering)
137
+ setIsCheckboxLoading(false);
138
+ }, [context.isRendering]);
134
139
  const _onPropertySelectionChanged = () => {
135
140
  setIsPropertySelected(!isPropertySelected);
136
141
  };
@@ -179,10 +184,11 @@ export const PropertyView = (props) => {
179
184
  !!props.onColumnRatioChanged;
180
185
  const needActionButtons = !!props.actionButtonRenderers;
181
186
  const columnsStyleProvider = new PropertyGridColumnStyleProvider(props.columnInfo);
187
+ const offset = CommonPropertyRenderer.getLabelOffset(props.indentation, props.orientation, props.width, props.columnRatio, (_a = props.columnInfo) === null || _a === void 0 ? void 0 : _a.minLabelWidth);
182
188
  return (React.createElement("div", { style: columnsStyleProvider.getStyle(props.orientation, needActionButtons, ratio, needElementSeparator), className: getClassName(props), onClick: _onClick, onContextMenu: _onContextMenu, onMouseEnter: _onMouseEnter, onMouseLeave: _onMouseLeave, role: 'presentation' },
183
189
  React.createElement("div", { className: 'components-property-record-label' },
184
190
  props.propertyRecord.value.valueFormat ===
185
- PropertyValueFormat.Primitive && (React.createElement(Checkbox, { className: 'components-property-selection-checkbox', checked: isPropertySelected, onChange: _onPropertySelectionChanged })),
191
+ PropertyValueFormat.Primitive && (React.createElement(Checkbox, { style: { marginLeft: offset }, className: 'components-property-selection-checkbox', checked: isPropertySelected, onChange: _onPropertySelectionChanged, disabled: context.isLoading || context.isRendering || (props.propertyRecord.value.value === undefined), isLoading: isCheckboxLoading })),
186
192
  props.labelElement),
187
193
  needElementSeparator ? (React.createElement(ElementSeparator, { movableArea: props.width, onRatioChanged: props.onColumnRatioChanged, ratio: ratio, orientation: props.orientation, isResizeHandleHovered: props.isResizeHandleHovered, onResizeHandleHoverChanged: props.onResizeHandleHoverChanged, isResizeHandleBeingDragged: props.isResizeHandleBeingDragged, onResizeHandleDragChanged: props.onResizeHandleDragChanged })) : undefined,
188
194
  props.propertyRecord.value.valueFormat ===
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyView.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyView.tsx"],"names":[],"mappings":"AAA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AwC,EAClD,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,2BAA2B,GACrC,CACH;YACA,KAAK,CAAC,YAAY,CACf;QACL,oBAAoB,CAAC,CAAC,CAAC,CACtB,oBAAC,gBAAgB,IACf,WAAW,EAAE,KAAK,CAAC,KAAK,EACxB,cAAc,EAAE,KAAK,CAAC,oBAAoB,EAC1C,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAClD,0BAA0B,EAAE,KAAK,CAAC,0BAA0B,EAC5D,0BAA0B,EAAE,KAAK,CAAC,0BAA0B,EAC5D,yBAAyB,EAAE,KAAK,CAAC,yBAAyB,GAC1D,CACH,CAAC,CAAC,CAAC,SAAS;QACZ,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW;YACrC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAC9B,6BAAK,SAAS,EAAC,kCAAkC;YAC/C,kCACG,KAAK,CAAC,oBAAoB;gBACzB,CAAC,CAAC,KAAK,CAAC,oBAAoB,EAAE;gBAC9B,CAAC,CAAC,KAAK,CAAC,YAAY,CACjB,CACH,CACP,CAAC,CAAC,CAAC,SAAS;QACd,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAC7B,oBAAC,gBAAgB,IACf,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,QAAQ,EAAE,KAAK,CAAC,cAAc,EAC9B,iBAAiB,EAAE,SAAS,EAC5B,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,GAClD,CACH,CAAC,CAAC,CAAC,SAAS,CACT,CACP,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*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyRecord} from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { ElementSeparator, Orientation } from \"@itwin/core-react\";\nimport { ActionButtonList } from \"@itwin/components-react\";\n\nimport \"./PropertyView.scss\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { GroupQueryBuilderContext } from \"../GroupQueryBuilderContext\";\nimport { useCallback } from \"react\";\nimport { PropertyGridColumnStyleProvider } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\n\n/** Properties of [[PropertyView]] React component\n * @public\n */\nexport interface PropertyViewProps extends SharedRendererProps {\n /** Property label as a React element */\n labelElement: React.ReactNode;\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n}\n\n/**\n * A React component that renders property as label/value pair\n * @public\n */\nexport const PropertyView = (props: PropertyViewProps) => {\n const context = React.useContext(GroupQueryBuilderContext);\n\n const _validatePropertySelection = () => {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n return true;\n }\n // Check if all subproperties are selected\n if (!_validateNestedPropertiesSelection(props.propertyRecord)) {\n return false;\n }\n return true;\n };\n\n const _validateNestedPropertiesSelection = (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n if (\n !_validateNestedPropertiesSelection(\n prop.value.members[subPropName]\n )\n ) {\n return false;\n }\n }\n }\n }\n return true;\n };\n\n const [isHovered, setIsHovered] = React.useState<boolean>(false);\n const [isPropertySelected, setIsPropertySelected] = React.useState<boolean>(\n _validatePropertySelection()\n );\n\n const _addSelectedProperty = useCallback(\n async (prop: PropertyRecord) => {\n // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)\n if (\n !context.currentPropertyList.includes(prop) &&\n prop.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n context.setCurrentPropertyList(\n context.currentPropertyList.concat(prop)\n );\n await context.queryBuilder.addProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _addNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _addSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _addSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _addNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_addSelectedProperty]\n );\n\n const _removeSelectedProperty = useCallback(\n async (prop: PropertyRecord): Promise<void> => {\n if (context.currentPropertyList.includes(prop)) {\n context.setCurrentPropertyList(\n context.currentPropertyList.filter((x: PropertyRecord) => x !== prop)\n );\n await context.queryBuilder.removeProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _removeNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _removeSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _removeSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _removeNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_removeSelectedProperty]\n );\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (isPropertySelected) {\n _addNestedProperties(props.propertyRecord);\n } else {\n _removeNestedProperties(props.propertyRecord);\n }\n }\n }, [\n _addNestedProperties,\n _removeNestedProperties,\n isPropertySelected,\n props.propertyRecord,\n ]);\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n setIsPropertySelected(true);\n } else {\n setIsPropertySelected(false);\n }\n }\n }, [context.currentPropertyList, props.propertyRecord]);\n\n const _onPropertySelectionChanged = () => {\n setIsPropertySelected(!isPropertySelected);\n };\n\n const _onClick = () => {\n if (props.onClick) {\n props.onClick(props.propertyRecord, props.uniqueKey);\n }\n };\n\n const _onMouseEnter = () => {\n if (props.isHoverable) {\n setIsHovered(true);\n }\n };\n\n const _onMouseLeave = () => {\n if (props.isHoverable) {\n setIsHovered(false);\n }\n };\n\n const _onContextMenu = (e: React.MouseEvent) => {\n if (props.onContextMenu) {\n props.onContextMenu(props.propertyRecord, e);\n }\n if (props.onRightClick) {\n props.onRightClick(props.propertyRecord, props.uniqueKey);\n }\n e.preventDefault();\n return false;\n };\n\n const getClassName = (viewProps: PropertyViewProps) => {\n let propertyRecordClassName =\n viewProps.orientation === Orientation.Horizontal\n ? \"components-property-record--horizontal\"\n : \"components-property-record--vertical\";\n if (viewProps.isSelected) {\n propertyRecordClassName += \" components--selected\";\n }\n if (viewProps.onClick) {\n propertyRecordClassName += \" components--clickable\";\n }\n if (viewProps.isHoverable) {\n propertyRecordClassName += \" components--hoverable\";\n }\n return propertyRecordClassName;\n };\n\n const ratio = props.columnRatio ? props.columnRatio : 0.25;\n const needElementSeparator =\n props.orientation === Orientation.Horizontal &&\n !!props.onColumnRatioChanged;\n const needActionButtons = !!props.actionButtonRenderers;\n const columnsStyleProvider = new PropertyGridColumnStyleProvider(\n props.columnInfo\n );\n\n return (\n <div\n style={columnsStyleProvider.getStyle(\n props.orientation,\n needActionButtons,\n ratio,\n needElementSeparator\n )}\n className={getClassName(props)}\n onClick={_onClick}\n onContextMenu={_onContextMenu}\n onMouseEnter={_onMouseEnter}\n onMouseLeave={_onMouseLeave}\n role='presentation'\n >\n <div className='components-property-record-label'>\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive && (\n <Checkbox\n className='components-property-selection-checkbox'\n checked={isPropertySelected}\n onChange={_onPropertySelectionChanged}\n />\n )}\n {props.labelElement}\n </div>\n {needElementSeparator ? (\n <ElementSeparator\n movableArea={props.width}\n onRatioChanged={props.onColumnRatioChanged}\n ratio={ratio}\n orientation={props.orientation}\n isResizeHandleHovered={props.isResizeHandleHovered}\n onResizeHandleHoverChanged={props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={props.onResizeHandleDragChanged}\n />\n ) : undefined}\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive ? (\n <div className='components-property-record-value'>\n <span>\n {props.valueElementRenderer\n ? props.valueElementRenderer()\n : props.valueElement}\n </span>\n </div>\n ) : undefined}\n {props.actionButtonRenderers ? (\n <ActionButtonList\n orientation={props.orientation}\n property={props.propertyRecord}\n isPropertyHovered={isHovered}\n actionButtonRenderers={props.actionButtonRenderers}\n />\n ) : undefined}\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"PropertyView.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyView.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,+BAA+B,E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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*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { ElementSeparator, Orientation } from \"@itwin/core-react\";\nimport { ActionButtonList } from \"@itwin/components-react\";\n\nimport \"./PropertyView.scss\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { GroupQueryBuilderContext } from \"../GroupQueryBuilderContext\";\nimport { useCallback } from \"react\";\nimport { PropertyGridColumnStyleProvider } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties of [[PropertyView]] React component\n * @public\n */\nexport interface PropertyViewProps extends SharedRendererProps {\n /** Property label as a React element */\n labelElement: React.ReactNode;\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n}\n\n/**\n * A React component that renders property as label/value pair\n * @public\n */\nexport const PropertyView = (props: PropertyViewProps) => {\n const context = React.useContext(GroupQueryBuilderContext);\n const [isCheckboxLoading, setIsCheckboxLoading] = React.useState(false);\n\n const _validatePropertySelection = () => {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n return true;\n }\n // Check if all subproperties are selected\n if (!_validateNestedPropertiesSelection(props.propertyRecord)) {\n return false;\n }\n return true;\n };\n\n const _validateNestedPropertiesSelection = (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n if (\n !_validateNestedPropertiesSelection(\n prop.value.members[subPropName]\n )\n ) {\n return false;\n }\n }\n }\n }\n return true;\n };\n\n const [isHovered, setIsHovered] = React.useState<boolean>(false);\n const [isPropertySelected, setIsPropertySelected] = React.useState<boolean>(\n _validatePropertySelection()\n );\n\n const _addSelectedProperty = useCallback(\n async (prop: PropertyRecord) => {\n // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)\n if (\n !context.currentPropertyList.includes(prop) &&\n prop.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n\n if (!(await context.queryBuilder.addProperty(prop))) {\n setIsCheckboxLoading(false);\n setIsPropertySelected(false);\n return;\n }\n context.setCurrentPropertyList(\n context.currentPropertyList.concat(prop)\n );\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _addNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _addSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _addSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _addNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_addSelectedProperty]\n );\n\n const _removeSelectedProperty = useCallback(\n async (prop: PropertyRecord): Promise<void> => {\n if (context.currentPropertyList.includes(prop)) {\n context.setCurrentPropertyList(\n context.currentPropertyList.filter((x: PropertyRecord) => x !== prop)\n );\n await context.queryBuilder.removeProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _removeNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _removeSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _removeSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _removeNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_removeSelectedProperty]\n );\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (isPropertySelected) {\n if (context.isRendering) {\n setIsCheckboxLoading(true);\n }\n _addNestedProperties(props.propertyRecord);\n } else {\n _removeNestedProperties(props.propertyRecord);\n }\n }\n }, [\n _addNestedProperties,\n _removeNestedProperties,\n isPropertySelected,\n props.propertyRecord,\n context.isRendering,\n ]);\n\n React.useEffect(() => {\n if (!context.isRendering)\n setIsCheckboxLoading(false);\n }, [context.isRendering]);\n\n const _onPropertySelectionChanged = () => {\n setIsPropertySelected(!isPropertySelected);\n };\n\n const _onClick = () => {\n if (props.onClick) {\n props.onClick(props.propertyRecord, props.uniqueKey);\n }\n };\n\n const _onMouseEnter = () => {\n if (props.isHoverable) {\n setIsHovered(true);\n }\n };\n\n const _onMouseLeave = () => {\n if (props.isHoverable) {\n setIsHovered(false);\n }\n };\n\n const _onContextMenu = (e: React.MouseEvent) => {\n if (props.onContextMenu) {\n props.onContextMenu(props.propertyRecord, e);\n }\n if (props.onRightClick) {\n props.onRightClick(props.propertyRecord, props.uniqueKey);\n }\n e.preventDefault();\n return false;\n };\n\n const getClassName = (viewProps: PropertyViewProps) => {\n let propertyRecordClassName =\n viewProps.orientation === Orientation.Horizontal\n ? \"components-property-record--horizontal\"\n : \"components-property-record--vertical\";\n if (viewProps.isSelected) {\n propertyRecordClassName += \" components--selected\";\n }\n if (viewProps.onClick) {\n propertyRecordClassName += \" components--clickable\";\n }\n if (viewProps.isHoverable) {\n propertyRecordClassName += \" components--hoverable\";\n }\n return propertyRecordClassName;\n };\n\n const ratio = props.columnRatio ? props.columnRatio : 0.25;\n const needElementSeparator =\n props.orientation === Orientation.Horizontal &&\n !!props.onColumnRatioChanged;\n const needActionButtons = !!props.actionButtonRenderers;\n const columnsStyleProvider = new PropertyGridColumnStyleProvider(\n props.columnInfo\n );\n\n const offset = CommonPropertyRenderer.getLabelOffset(\n props.indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth,\n );\n\n return (\n <div\n style={columnsStyleProvider.getStyle(\n props.orientation,\n needActionButtons,\n ratio,\n needElementSeparator\n )}\n className={getClassName(props)}\n onClick={_onClick}\n onContextMenu={_onContextMenu}\n onMouseEnter={_onMouseEnter}\n onMouseLeave={_onMouseLeave}\n role='presentation'\n >\n <div className='components-property-record-label'>\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive && (\n <Checkbox\n style={{ marginLeft: offset }}\n className='components-property-selection-checkbox'\n checked={isPropertySelected}\n onChange={_onPropertySelectionChanged}\n disabled={context.isLoading || context.isRendering || (props.propertyRecord.value.value === undefined)}\n isLoading={isCheckboxLoading}\n />\n )}\n {props.labelElement}\n </div>\n {needElementSeparator ? (\n <ElementSeparator\n movableArea={props.width}\n onRatioChanged={props.onColumnRatioChanged}\n ratio={ratio}\n orientation={props.orientation}\n isResizeHandleHovered={props.isResizeHandleHovered}\n onResizeHandleHoverChanged={props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={props.onResizeHandleDragChanged}\n />\n ) : undefined}\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive ? (\n <div className='components-property-record-value'>\n <span>\n {props.valueElementRenderer\n ? props.valueElementRenderer()\n : props.valueElement}\n </span>\n </div>\n ) : undefined}\n {props.actionButtonRenderers ? (\n <ActionButtonList\n orientation={props.orientation}\n property={props.propertyRecord}\n isPropertyHovered={isHovered}\n actionButtonRenderers={props.actionButtonRenderers}\n />\n ) : undefined}\n </div>\n );\n};\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/style/themecolors";
6
- @import "~@itwin/itwinui-css/scss/style/typography";
7
- @import "~@itwin/itwinui-css/scss/variables";
5
+ @import '~@itwin/core-react/lib/cjs/core-react/style/themecolors';
6
+ @import '~@itwin/itwinui-css/scss/style/typography';
7
+ @import '~@itwin/itwinui-css/scss/variables';
8
8
 
9
9
  $text-font-size: $iui-font-size;
10
10
  $text-font-color: $buic-text-color;
@@ -52,8 +52,23 @@ $text-font-color: $buic-text-color;
52
52
 
53
53
  .components-property-record-label {
54
54
  @include record-cell;
55
+ position: relative;
55
56
  .components-property-selection-checkbox {
56
- margin-right: $iui-s;
57
+ flex-shrink: 0;
58
+ position: absolute;
59
+ z-index: 1;
60
+ }
61
+ // Radial does not respect checkbox positioning, have to force it.
62
+ > .iui-progress-indicator-radial {
63
+ position: absolute;
64
+ }
65
+ .components-property-selection-loading {
66
+ display: flex;
67
+ width: $iui-m;
68
+ height: $iui-m;
69
+ align-items: center;
70
+ justify-content: center;
71
+ flex-shrink: 0;
57
72
  }
58
73
  }
59
74
 
@@ -12,4 +12,5 @@ export declare const WidgetHeader: ({ title, disabled, returnFn, }: WidgetHeader
12
12
  export declare const handleInputChange: <T>(e: React.ChangeEvent<HTMLInputElement>, values: T, setValues: React.Dispatch<React.SetStateAction<T>>) => void;
13
13
  export declare const fetchIdsFromQuery: (query: string, iModelConnection: IModelConnection) => Promise<string[]>;
14
14
  export declare const handleError: (errorStatus: number) => void;
15
+ export declare const LoadingSpinner: () => JSX.Element;
15
16
  //# sourceMappingURL=utils.d.ts.map
@@ -3,7 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { SvgChevronLeft } from "@itwin/itwinui-icons-react";
6
- import { Text, toaster } from "@itwin/itwinui-react";
6
+ import { ProgressRadial, Text, toaster } from "@itwin/itwinui-react";
7
7
  import "./utils.scss";
8
8
  import React from "react";
9
9
  import { QueryRowFormat } from "@itwin/core-common";
@@ -48,35 +48,29 @@ export const fetchIdsFromQuery = async (query, iModelConnection) => {
48
48
  if (query === "") {
49
49
  return [];
50
50
  }
51
- try {
52
- const ids = [];
53
- const rowIterator = iModelConnection.query(query, undefined, {
54
- rowFormat: QueryRowFormat.UseJsPropertyNames,
55
- });
56
- while (true) {
57
- const { done, value } = await rowIterator.next();
58
- if (done) {
59
- break;
60
- }
61
- if (Object.keys(value).includes("id")) {
62
- ids.push(value.id);
63
- }
64
- else if (Object.keys(value).includes("element.id")) {
65
- ids.push(value["element.id"]);
66
- }
67
- else if (Object.keys(value).includes("eCInstanceId")) {
68
- ids.push(value.eCInstanceId);
69
- }
51
+ const ids = [];
52
+ const rowIterator = iModelConnection.query(query, undefined, {
53
+ rowFormat: QueryRowFormat.UseJsPropertyNames,
54
+ });
55
+ while (true) {
56
+ const { done, value } = await rowIterator.next();
57
+ if (done) {
58
+ break;
59
+ }
60
+ if (Object.keys(value).includes("id")) {
61
+ ids.push(value.id);
62
+ }
63
+ else if (Object.keys(value).includes("element.id")) {
64
+ ids.push(value["element.id"]);
65
+ }
66
+ else if (Object.keys(value).includes("eCInstanceId")) {
67
+ ids.push(value.eCInstanceId);
70
68
  }
71
- return ids;
72
- }
73
- catch (error) {
74
- toaster.negative("Failed to resolve query.");
75
- throw (error);
76
69
  }
70
+ return ids;
77
71
  };
78
72
  export const handleError = (errorStatus) => {
79
- let errorMessage = `Error ${errorStatus}: `;
73
+ let errorMessage = "Error! ";
80
74
  switch (errorStatus) {
81
75
  case 401:
82
76
  errorMessage += `You are unauthorized to do this operation.`;
@@ -110,4 +104,8 @@ export const handleError = (errorStatus) => {
110
104
  }
111
105
  toaster.negative(errorMessage);
112
106
  };
107
+ export const LoadingSpinner = () => {
108
+ return (React.createElement("div", { className: "gm-loading-spinner" },
109
+ React.createElement(ProgressRadial, { size: "small", indeterminate: true })));
110
+ };
113
111
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,GAA6B,EAC7B,iBAAqC,EACrC,EAAE;IACF,+BAA+B;IAC/B,MAAM,SAAS,GAAG,iBAAiB,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,SAAS,CAAC,OAAO,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;KACxD;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,IAAI,SAAS,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,EAAE;YACrC,0DAA0D;YAC1D,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC5B,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;gBAC9C,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACrD,CAAC,CAAC,CAAC;SACJ;QACD,IAAI,SAAS,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;QACR,KAAK,GAAG;YACN,YAAY,IAAI,uCAAuC,CAAC;YACxD,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,2CAA2C,CAAC;YAC5D,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,gCAAgC,CAAC;YACjD,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,oBAAoB,CAAC;YACrC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,wBAAwB,CAAC;YACzC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,cAAc,CAAC;YAC/B,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,sBAAsB,CAAC;YACvC,MAAM;QACR;YACE,YAAY,IAAI,uBAAuB,CAAC;KAC3C;IACD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAEjC,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*--------------------------------------------------------------------------------------------*/\nimport { SvgChevronLeft } from \"@itwin/itwinui-icons-react\";\nimport { Text, toaster } from \"@itwin/itwinui-react\";\nimport \"./utils.scss\";\nimport React from \"react\";\nimport type {\n ISelectionProvider,\n SelectionChangeEventArgs,\n} from \"@itwin/presentation-frontend\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\n\nexport const onSelectionChanged = (\n evt: SelectionChangeEventArgs,\n selectionProvider: ISelectionProvider,\n) => {\n /* eslint-disable no-console */\n const selection = selectionProvider.getSelection(evt.imodel, evt.level);\n if (selection.isEmpty) {\n console.log(\"========== Selection cleared ==========\");\n } else {\n console.log(\"========== Selection change ===========\");\n if (selection.instanceKeys.size !== 0) {\n // log all selected ECInstance ids grouped by ECClass name\n console.log(\"ECInstances:\");\n selection.instanceKeys.forEach((ids, ecclass) => {\n console.log(`${ecclass}: [${[...ids].join(\",\")}]`);\n });\n }\n if (selection.nodeKeys.size !== 0) {\n // log all selected node keys\n console.log(\"Nodes:\");\n selection.nodeKeys.forEach((key) => console.log(JSON.stringify(key)));\n }\n console.log(\"=======================================\");\n }\n /* eslint-enable no-console */\n};\n\nexport interface WidgetHeaderProps {\n title: string;\n disabled?: boolean;\n returnFn?: () => Promise<void>;\n}\n\nexport const WidgetHeader = ({\n title,\n disabled = false,\n returnFn,\n}: WidgetHeaderProps) => {\n return (\n <div className='widget-header-container'>\n {returnFn && (\n <div\n className={disabled ? \"chevron-disabled\" : \"chevron\"}\n onClick={disabled ? undefined : returnFn}\n >\n <SvgChevronLeft />\n </div>\n )}\n <Text className='title' variant='title'>\n {title}\n </Text>\n </div>\n );\n};\n\nexport const handleInputChange = <T,>(\n e: React.ChangeEvent<HTMLInputElement>,\n values: T,\n setValues: React.Dispatch<React.SetStateAction<T>>,\n) => {\n const { name, value } = e.target;\n\n setValues({\n ...values,\n [name]: value,\n });\n};\n\nexport const fetchIdsFromQuery = async (\n query: string,\n iModelConnection: IModelConnection,\n) => {\n if (query === \"\") {\n return [];\n }\n try {\n const ids: string[] = [];\n const rowIterator = iModelConnection.query(query, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n });\n while (true) {\n const { done, value } = await rowIterator.next();\n if (done) {\n break;\n }\n if (Object.keys(value).includes(\"id\")) {\n ids.push(value.id);\n } else if (Object.keys(value).includes(\"element.id\")) {\n ids.push(value[\"element.id\"]);\n } else if (Object.keys(value).includes(\"eCInstanceId\")) {\n ids.push(value.eCInstanceId);\n }\n }\n return ids;\n } catch (error) {\n toaster.negative(\"Failed to resolve query.\");\n throw (error);\n\n }\n};\n\nexport const handleError = (errorStatus: number) => {\n let errorMessage = `Error ${errorStatus}: `;\n switch (errorStatus) {\n case 401:\n errorMessage += `You are unauthorized to do this operation.`;\n break;\n case 403:\n errorMessage += `You don't have permission to access the requested resource.`;\n break;\n case 404:\n errorMessage += `The requested resource was not found.`;\n break;\n case 409:\n errorMessage += `This property name is already being used.`;\n break;\n case 422:\n errorMessage += `Unable to process the request.`;\n break;\n case 429:\n errorMessage += `Too many requests.`;\n break;\n case 500:\n errorMessage += `Internal server error.`;\n break;\n case 502:\n errorMessage += `Bad gateway.`;\n break;\n case 503:\n errorMessage += `Service unavailable.`;\n break;\n default:\n errorMessage += `Something went wrong!`;\n }\n toaster.negative(errorMessage);\n\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,GAA6B,EAC7B,iBAAqC,EACrC,EAAE;IACF,+BAA+B;IAC/B,MAAM,SAAS,GAAG,iBAAiB,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,SAAS,CAAC,OAAO,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;KACxD;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,IAAI,SAAS,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,EAAE;YACrC,0DAA0D;YAC1D,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC5B,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;gBAC9C,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,G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AAI,2CAA2C,CAAC;YAC5D,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,gCAAgC,CAAC;YACjD,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,oBAAoB,CAAC;YACrC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,wBAAwB,CAAC;YACzC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,cAAc,CAAC;YAC/B,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,sBAAsB,CAAC;YACvC,MAAM;QACR;YACE,YAAY,IAAI,uBAAuB,CAAC;KAC3C;IACD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAEjC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO,CACL,6BAAK,SAAS,EAAC,oBAAoB;QACjC,oBAAC,cAAc,IAAC,IAAI,EAAC,OAAO,EAAC,aAAa,SAAG,CACzC,CACP,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*--------------------------------------------------------------------------------------------*/\nimport { SvgChevronLeft } from \"@itwin/itwinui-icons-react\";\nimport { ProgressRadial, Text, toaster } from \"@itwin/itwinui-react\";\nimport \"./utils.scss\";\nimport React from \"react\";\nimport type {\n ISelectionProvider,\n SelectionChangeEventArgs,\n} from \"@itwin/presentation-frontend\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\n\nexport const onSelectionChanged = (\n evt: SelectionChangeEventArgs,\n selectionProvider: ISelectionProvider,\n) => {\n /* eslint-disable no-console */\n const selection = selectionProvider.getSelection(evt.imodel, evt.level);\n if (selection.isEmpty) {\n console.log(\"========== Selection cleared ==========\");\n } else {\n console.log(\"========== Selection change ===========\");\n if (selection.instanceKeys.size !== 0) {\n // log all selected ECInstance ids grouped by ECClass name\n console.log(\"ECInstances:\");\n selection.instanceKeys.forEach((ids, ecclass) => {\n console.log(`${ecclass}: [${[...ids].join(\",\")}]`);\n });\n }\n if (selection.nodeKeys.size !== 0) {\n // log all selected node keys\n console.log(\"Nodes:\");\n selection.nodeKeys.forEach((key) => console.log(JSON.stringify(key)));\n }\n console.log(\"=======================================\");\n }\n /* eslint-enable no-console */\n};\n\nexport interface WidgetHeaderProps {\n title: string;\n disabled?: boolean;\n returnFn?: () => Promise<void>;\n}\n\nexport const WidgetHeader = ({\n title,\n disabled = false,\n returnFn,\n}: WidgetHeaderProps) => {\n return (\n <div className='widget-header-container'>\n {returnFn && (\n <div\n className={disabled ? \"chevron-disabled\" : \"chevron\"}\n onClick={disabled ? undefined : returnFn}\n >\n <SvgChevronLeft />\n </div>\n )}\n <Text className='title' variant='title'>\n {title}\n </Text>\n </div>\n );\n};\n\nexport const handleInputChange = <T,>(\n e: React.ChangeEvent<HTMLInputElement>,\n values: T,\n setValues: React.Dispatch<React.SetStateAction<T>>,\n) => {\n const { name, value } = e.target;\n\n setValues({\n ...values,\n [name]: value,\n });\n};\n\nexport const fetchIdsFromQuery = async (\n query: string,\n iModelConnection: IModelConnection,\n) => {\n if (query === \"\") {\n return [];\n }\n const ids: string[] = [];\n const rowIterator = iModelConnection.query(query, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n });\n while (true) {\n const { done, value } = await rowIterator.next();\n if (done) {\n break;\n }\n if (Object.keys(value).includes(\"id\")) {\n ids.push(value.id);\n } else if (Object.keys(value).includes(\"element.id\")) {\n ids.push(value[\"element.id\"]);\n } else if (Object.keys(value).includes(\"eCInstanceId\")) {\n ids.push(value.eCInstanceId);\n }\n }\n return ids;\n};\n\nexport const handleError = (errorStatus: number) => {\n let errorMessage = \"Error! \";\n switch (errorStatus) {\n case 401:\n errorMessage += `You are unauthorized to do this operation.`;\n break;\n case 403:\n errorMessage += `You don't have permission to access the requested resource.`;\n break;\n case 404:\n errorMessage += `The requested resource was not found.`;\n break;\n case 409:\n errorMessage += `This property name is already being used.`;\n break;\n case 422:\n errorMessage += `Unable to process the request.`;\n break;\n case 429:\n errorMessage += `Too many requests.`;\n break;\n case 500:\n errorMessage += `Internal server error.`;\n break;\n case 502:\n errorMessage += `Bad gateway.`;\n break;\n case 503:\n errorMessage += `Service unavailable.`;\n break;\n default:\n errorMessage += `Something went wrong!`;\n }\n toaster.negative(errorMessage);\n\n};\n\nexport const LoadingSpinner = () => {\n return (\n <div className=\"gm-loading-spinner\">\n <ProgressRadial size=\"small\" indeterminate />\n </div>\n );\n};\n"]}
@@ -34,3 +34,8 @@
34
34
  text-overflow: ellipsis;
35
35
  }
36
36
  }
37
+
38
+ .gm-loading-spinner {
39
+ display: flex;
40
+ align-items: center;
41
+ }
@@ -49,7 +49,7 @@ export const visualizeElements = (elementIds, color, replace = false, wantEmphas
49
49
  emph.emphasizeElements(elementIds, vp, undefined, replace);
50
50
  };
51
51
  export const zoomToElements = async (elementIds) => {
52
- if (!IModelApp.viewManager.selectedView) {
52
+ if (!IModelApp.viewManager.selectedView || elementIds.length === 0) {
53
53
  return;
54
54
  }
55
55
  const vp = IModelApp.viewManager.selectedView;
@@ -1 +1 @@
1
- {"version":3,"file":"viewerUtils.js","sourceRoot":"","sources":["../../../../src/widget/components/viewerUtils.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,iBAAiB,EACjB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,QAAQ,EACR,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,UAAoB,EACpB,KAAa,EACb,gBAAkC,EAClC,OAAO,GAAG,KAAK,EACf,YAAY,GAAG,IAAI,EACnB,EAAE;IACF,IAAI,CAAC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AAG,EAAE;IAC1C,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO;KACR;IACD,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;AACnC,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*--------------------------------------------------------------------------------------------*/\nimport type {\n IModelConnection,\n ViewChangeOptions} from \"@itwin/core-frontend\";\nimport {\n EmphasizeElements,\n IModelApp,\n} from \"@itwin/core-frontend\";\nimport type {\n ElementProps} from \"@itwin/core-common\";\nimport {\n ColorDef,\n FeatureOverrideType,\n} from \"@itwin/core-common\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { HiliteSetProvider } from \"@itwin/presentation-frontend\";\n\nexport const visualizeElementsById = async (\n elementIds: string[],\n color: string,\n iModelConnection: IModelConnection,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsByKeys = async (\n keySet: KeySet,\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElements = (\n elementIds: string[],\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n elementIds,\n vp,\n ColorDef.fromString(color),\n FeatureOverrideType.ColorOnly,\n true,\n );\n if (!wantEmphasis) {\n return;\n }\n emph.wantEmphasis = true;\n emph.emphasizeElements(elementIds, vp, undefined, replace);\n};\n\nexport const zoomToElements = async (elementIds: string[]) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const viewChangeOpts: ViewChangeOptions = {};\n viewChangeOpts.animateFrustumChange = true;\n // It was removed. Should be a prop to be passed to lookAtViewAlignedVolume within the implementation.\n // viewChangeOpts.marginPercent = new MarginPercent(0.1, 0.1, 0.1, 0.1);\n await vp.zoomToElements(elementIds, { ...viewChangeOpts });\n};\n\nexport const manufactureKeys = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n): Promise<KeySet> => {\n // segment ids into batches\n const batches: string[][] = [];\n let currBatch: string[] = [];\n const batchSize = 100000;\n for (const id of elementIds) {\n if (currBatch.length < batchSize) {\n currBatch.push(id);\n } else {\n batches.push(currBatch);\n currBatch = [id];\n }\n }\n if (currBatch.length > 0 && currBatch.length <= batchSize) {\n batches.push(currBatch);\n }\n\n // retrieve element properties in batches\n let elemProps: ElementProps[] = [];\n for (const batch of batches) {\n const props = await iModelConnection.elements.getProps(batch);\n elemProps = elemProps.concat(props);\n }\n\n const isElementId = (elem: {\n id: string | undefined;\n className: string;\n }): elem is {\n id: string;\n className: string;\n } => {\n return elem.id !== undefined;\n };\n\n // create keyset from the element properties\n const keys = elemProps\n .map((elem: ElementProps) => ({\n id: elem.id,\n className: elem.classFullName,\n }))\n .filter(isElementId);\n return new KeySet(keys);\n};\n\nexport const clearEmphasizedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n};\n"]}
1
+ {"version":3,"file":"viewerUtils.js","sourceRoot":"","sources":["../../../../src/widget/components/viewerUtils.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,iBAAiB,EACjB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,QAAQ,EACR,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,UAAoB,EACpB,KAAa,EACb,gBAAkC,EAClC,OAAO,GAAG,KAAK,EACf,YAAY,GAAG,IAAI,EACnB,EAAE;IACF,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO,EAAE,CAAC;KACX;IAED,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAE9C,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACnE,MAAM,cAAc,GAAsB,iBAAiB,CAAC,MAAM,CAAC;QACjE,MAAM,EAAE,EAAE,CAAC,MAAM;KAClB,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,GAAG,CAAC,QAAQ,EAAE;QAChB,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9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AC,MAAM,IAAI,SAAS,EAAE;QACzD,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACzB;IAED,yCAAyC;IACzC,IAAI,SAAS,GAAmB,EAAE,CAAC;IACnC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9D,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KACrC;IAED,MAAM,WAAW,GAAG,CAAC,IAGpB,EAGC,EAAE;QACF,OAAO,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC;IAC/B,CAAC,CAAC;IAEF,4CAA4C;IAC5C,MAAM,IAAI,GAAG,SAAS;SACnB,GAAG,CAAC,CAAC,IAAkB,EAAE,EAAE,CAAC,CAAC;QAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,SAAS,EAAE,IAAI,CAAC,aAAa;KAC9B,CAAC,CAAC;SACF,MAAM,CAAC,WAAW,CAAC,CAAC;IACvB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO;KACR;IACD,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;AACnC,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*--------------------------------------------------------------------------------------------*/\nimport type {\n IModelConnection,\n ViewChangeOptions,\n} from \"@itwin/core-frontend\";\nimport {\n EmphasizeElements,\n IModelApp,\n} from \"@itwin/core-frontend\";\nimport type {\n ElementProps,\n} from \"@itwin/core-common\";\nimport {\n ColorDef,\n FeatureOverrideType,\n} from \"@itwin/core-common\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { HiliteSetProvider } from \"@itwin/presentation-frontend\";\n\nexport const visualizeElementsById = async (\n elementIds: string[],\n color: string,\n iModelConnection: IModelConnection,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsByKeys = async (\n keySet: KeySet,\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElements = (\n elementIds: string[],\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n elementIds,\n vp,\n ColorDef.fromString(color),\n FeatureOverrideType.ColorOnly,\n true,\n );\n if (!wantEmphasis) {\n return;\n }\n emph.wantEmphasis = true;\n emph.emphasizeElements(elementIds, vp, undefined, replace);\n};\n\nexport const zoomToElements = async (elementIds: string[]) => {\n if (!IModelApp.viewManager.selectedView || elementIds.length === 0) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const viewChangeOpts: ViewChangeOptions = {};\n viewChangeOpts.animateFrustumChange = true;\n // It was removed. Should be a prop to be passed to lookAtViewAlignedVolume within the implementation.\n // viewChangeOpts.marginPercent = new MarginPercent(0.1, 0.1, 0.1, 0.1);\n await vp.zoomToElements(elementIds, { ...viewChangeOpts });\n};\n\nexport const manufactureKeys = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n): Promise<KeySet> => {\n // segment ids into batches\n const batches: string[][] = [];\n let currBatch: string[] = [];\n const batchSize = 100000;\n for (const id of elementIds) {\n if (currBatch.length < batchSize) {\n currBatch.push(id);\n } else {\n batches.push(currBatch);\n currBatch = [id];\n }\n }\n if (currBatch.length > 0 && currBatch.length <= batchSize) {\n batches.push(currBatch);\n }\n\n // retrieve element properties in batches\n let elemProps: ElementProps[] = [];\n for (const batch of batches) {\n const props = await iModelConnection.elements.getProps(batch);\n elemProps = elemProps.concat(props);\n }\n\n const isElementId = (elem: {\n id: string | undefined;\n className: string;\n }): elem is {\n id: string;\n className: string;\n } => {\n return elem.id !== undefined;\n };\n\n // create keyset from the element properties\n const keys = elemProps\n .map((elem: ElementProps) => ({\n id: elem.id,\n className: elem.classFullName,\n }))\n .filter(isElementId);\n return new KeySet(keys);\n};\n\nexport const clearEmphasizedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/grouping-mapping-widget",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "An iTwin.js 3D Viewer Widget that interfaces with the iTwin Reporting Platform.",
5
5
  "keywords": [
6
6
  "Bentley",
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@itwin/imodel-browser-react": "^0.12.1",
40
40
  "@itwin/itwinui-icons-react": "^1.7.0",
41
- "@itwin/itwinui-react": "^1.29.2",
41
+ "@itwin/itwinui-react": "^1.33.0",
42
42
  "classnames": "^2.3.1",
43
43
  "cross-fetch": "^3.1.4",
44
44
  "immer": "^9.0.7",
@@ -60,7 +60,7 @@
60
60
  "@itwin/core-quantity": "^3.0.0",
61
61
  "@itwin/core-react": "^3.0.0",
62
62
  "@itwin/eslint-plugin": "^3.0.0",
63
- "@itwin/itwinui-css": "^0.44.1",
63
+ "@itwin/imodel-components-react": "^3.0.0",
64
64
  "@itwin/presentation-common": "^3.0.0",
65
65
  "@itwin/presentation-components": "^3.0.0",
66
66
  "@itwin/presentation-frontend": "^3.0.0",
@@ -89,6 +89,7 @@
89
89
  "@itwin/appui-abstract": "^3.0.0",
90
90
  "@itwin/appui-react": "^3.0.0",
91
91
  "@itwin/components-react": "^3.0.0",
92
+ "@itwin/core-frontend": "^3.0.0",
92
93
  "@itwin/core-react": "^3.0.0",
93
94
  "@itwin/presentation-components": "^3.0.0",
94
95
  "@itwin/presentation-frontend": "^3.0.0",
@@ -112,5 +113,6 @@
112
113
  "pseudolocalize": "betools pseudolocalize --englishDir ./public/locales/en --out ./public/locales/en-PSEUDO",
113
114
  "rebuild": "npm run clean && npm run build",
114
115
  "test": ""
115
- }
116
+ },
117
+ "readme": "# @itwin/grouping-mapping-widget\r\n\r\nCopyright © Bentley Systems, Incorporated. All rights reserved.\r\nThe Grouping Mapping widget is a UI component for iTwin Viewer applications that simplifies how users (and developers) interface with the [Reporting Platform APIs](https://developer.bentley.com/apis/insights/overview/).\r\nThe grouping-mapping-widget package provides a UiProvider class - `GroupingMappingProvider` - which can be passed into the `uiProviders` prop of the iTwin Viewer's `<Viewer />` component.\r\n\r\n## Getting Started\r\n\r\nThis is not a standalone UI and requires a parent iTwin Viewer application to work as intended.\r\nA guide on how to create a basic iTwin Viewer application can be found here: <https://www.itwinjs.org/learning/tutorials/develop-web-viewer/>.\r\nThis package provides a viewer 'widget'. Documentation on how to add a widget to your application can be found here: <https://developer.bentley.com/tutorials/itwin-viewer-hello-world/#2-your-first-ui-widget>.\r\n\r\n## Permissions and Scopes\r\n\r\nThe SPA client used by your iTwin viewer must have these additional scopes:\r\n\r\n- `insights:read`\r\n- `insights:modify`\r\n- `projects:read`\r\n\r\nIn addition, users must have the `imodels_read` and `imodels_write` [permissions](https://developer.bentley.com/apis/insights/operations/create-mapping/#authorization) assigned at either the Project or iModel level. Further instruction on how to create roles and assign permissions can be found in the [iTwin Platform Projects API documentation](https://developer.bentley.com/apis/projects/tutorials/).\r\n\r\n## Sample usage\r\n\r\n```tsx\r\nimport { GroupingMappingProvider } from \"@itwin/grouping-mapping-widget\";\r\n<Viewer\r\n ...\r\n uiProviders={[new GroupingMappingProvider()]}\r\n/>\r\n```\r\n"
116
118
  }