@itwin/grouping-mapping-widget 0.11.0 → 0.12.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 (205) hide show
  1. package/lib/cjs/grouping-mapping-widget.d.ts +4 -1
  2. package/lib/cjs/grouping-mapping-widget.js +7 -1
  3. package/lib/cjs/grouping-mapping-widget.js.map +1 -1
  4. package/lib/cjs/test/WidgetHeader.test.js +3 -3
  5. package/lib/cjs/test/WidgetHeader.test.js.map +1 -1
  6. package/lib/cjs/widget/components/CalculatedPropertyAction.d.ts +7 -9
  7. package/lib/cjs/widget/components/CalculatedPropertyAction.js +49 -24
  8. package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
  9. package/lib/cjs/widget/components/CalculatedPropertyTable.d.ts +9 -16
  10. package/lib/cjs/widget/components/CalculatedPropertyTable.js +29 -31
  11. package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
  12. package/lib/cjs/widget/components/CalculatedPropertyTable.scss +9 -0
  13. package/lib/cjs/widget/components/CustomCalculationAction.d.ts +6 -9
  14. package/lib/cjs/widget/components/CustomCalculationAction.js +79 -9
  15. package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
  16. package/lib/cjs/widget/components/CustomCalculationTable.d.ts +8 -16
  17. package/lib/cjs/widget/components/CustomCalculationTable.js +22 -29
  18. package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
  19. package/lib/cjs/widget/components/DeleteModal.d.ts +4 -5
  20. package/lib/cjs/widget/components/DeleteModal.js +9 -13
  21. package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
  22. package/lib/cjs/widget/components/GroupAction.js +1 -0
  23. package/lib/cjs/widget/components/GroupAction.js.map +1 -1
  24. package/lib/cjs/widget/components/GroupInformationPanel.d.ts +10 -0
  25. package/lib/cjs/widget/components/GroupInformationPanel.js +23 -0
  26. package/lib/cjs/widget/components/GroupInformationPanel.js.map +1 -0
  27. package/lib/cjs/widget/components/GroupInformationPanel.scss +13 -0
  28. package/lib/cjs/widget/components/GroupPropertyAction.d.ts +6 -9
  29. package/lib/cjs/widget/components/GroupPropertyAction.js +26 -15
  30. package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
  31. package/lib/cjs/widget/components/GroupPropertyTable.d.ts +8 -15
  32. package/lib/cjs/widget/components/GroupPropertyTable.js +23 -28
  33. package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
  34. package/lib/cjs/widget/components/Grouping.d.ts +2 -1
  35. package/lib/cjs/widget/components/Grouping.js +12 -15
  36. package/lib/cjs/widget/components/Grouping.js.map +1 -1
  37. package/lib/cjs/widget/components/Grouping.scss +2 -9
  38. package/lib/cjs/widget/components/GroupingMapping.js +1 -2
  39. package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
  40. package/lib/cjs/widget/components/GroupingMappingContent.js +8 -4
  41. package/lib/cjs/widget/components/GroupingMappingContent.js.map +1 -1
  42. package/lib/cjs/widget/components/GroupingMappingContext.js +17 -1
  43. package/lib/cjs/widget/components/GroupingMappingContext.js.map +1 -1
  44. package/lib/cjs/widget/components/GroupingMappingHeader.js +2 -2
  45. package/lib/cjs/widget/components/GroupingMappingHeader.js.map +1 -1
  46. package/lib/cjs/widget/components/GroupingMappingRouter.js +23 -2
  47. package/lib/cjs/widget/components/GroupingMappingRouter.js.map +1 -1
  48. package/lib/cjs/widget/components/GroupsAddButton.d.ts +9 -0
  49. package/lib/cjs/widget/components/GroupsAddButton.js +17 -0
  50. package/lib/cjs/widget/components/GroupsAddButton.js.map +1 -0
  51. package/lib/cjs/widget/components/GroupsAddButton.scss +7 -0
  52. package/lib/cjs/widget/components/Mapping.js +5 -11
  53. package/lib/cjs/widget/components/Mapping.js.map +1 -1
  54. package/lib/cjs/widget/components/PropertyMenu.d.ts +12 -17
  55. package/lib/cjs/widget/components/PropertyMenu.js +52 -155
  56. package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
  57. package/lib/cjs/widget/components/PropertyMenu.scss +4 -28
  58. package/lib/cjs/widget/components/PropertyNameCell.d.ts +11 -0
  59. package/lib/cjs/widget/components/PropertyNameCell.js +15 -0
  60. package/lib/cjs/widget/components/PropertyNameCell.js.map +1 -0
  61. package/lib/cjs/widget/components/PropertyTable.d.ts +18 -0
  62. package/lib/cjs/widget/components/PropertyTable.js +54 -0
  63. package/lib/cjs/widget/components/PropertyTable.js.map +1 -0
  64. package/lib/cjs/widget/components/PropertyTable.scss +11 -0
  65. package/lib/cjs/widget/components/PropertyTableToolbar.d.ts +10 -0
  66. package/lib/cjs/widget/components/PropertyTableToolbar.js +23 -0
  67. package/lib/cjs/widget/components/PropertyTableToolbar.js.map +1 -0
  68. package/lib/cjs/widget/components/PropertyTableToolbar.scss +12 -0
  69. package/lib/cjs/widget/components/ToggleGroupVisibility.d.ts +9 -0
  70. package/lib/cjs/widget/components/ToggleGroupVisibility.js +16 -0
  71. package/lib/cjs/widget/components/ToggleGroupVisibility.js.map +1 -0
  72. package/lib/cjs/widget/components/ToggleGroupVisibility.scss +9 -0
  73. package/lib/cjs/widget/components/WidgetHeader.d.ts +9 -0
  74. package/lib/cjs/widget/components/WidgetHeader.js +22 -0
  75. package/lib/cjs/widget/components/WidgetHeader.js.map +1 -0
  76. package/lib/cjs/widget/components/WidgetHeader.scss +36 -0
  77. package/lib/cjs/widget/components/context/GroupHilitedElementsContext.d.ts +6 -1
  78. package/lib/cjs/widget/components/context/GroupHilitedElementsContext.js.map +1 -1
  79. package/lib/cjs/widget/components/context/PropertiesContext.d.ts +15 -0
  80. package/lib/cjs/widget/components/context/PropertiesContext.js +43 -0
  81. package/lib/cjs/widget/components/context/PropertiesContext.js.map +1 -0
  82. package/lib/cjs/widget/components/groupsHelpers.d.ts +6 -3
  83. package/lib/cjs/widget/components/groupsHelpers.js +43 -40
  84. package/lib/cjs/widget/components/groupsHelpers.js.map +1 -1
  85. package/lib/cjs/widget/components/property-grid/PropertyRender.js +2 -1
  86. package/lib/cjs/widget/components/property-grid/PropertyRender.js.map +1 -1
  87. package/lib/cjs/widget/components/property-grid/countMatchesInString.d.ts +8 -0
  88. package/lib/cjs/widget/components/property-grid/countMatchesInString.js +32 -0
  89. package/lib/cjs/widget/components/property-grid/countMatchesInString.js.map +1 -0
  90. package/lib/cjs/widget/components/property-grid/createNewDisplayValue.d.ts +10 -0
  91. package/lib/cjs/widget/components/property-grid/createNewDisplayValue.js +65 -0
  92. package/lib/cjs/widget/components/property-grid/createNewDisplayValue.js.map +1 -0
  93. package/lib/cjs/widget/components/utils.d.ts +0 -6
  94. package/lib/cjs/widget/components/utils.js +1 -9
  95. package/lib/cjs/widget/components/utils.js.map +1 -1
  96. package/lib/cjs/widget/components/utils.scss +0 -29
  97. package/lib/cjs/widget/components/viewerUtils.d.ts +4 -2
  98. package/lib/cjs/widget/components/viewerUtils.js +4 -22
  99. package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
  100. package/lib/cjs/widget/hooks/useFetchData.d.ts +3 -5
  101. package/lib/cjs/widget/hooks/useFetchData.js +9 -7
  102. package/lib/cjs/widget/hooks/useFetchData.js.map +1 -1
  103. package/lib/esm/grouping-mapping-widget.d.ts +4 -1
  104. package/lib/esm/grouping-mapping-widget.js +3 -0
  105. package/lib/esm/grouping-mapping-widget.js.map +1 -1
  106. package/lib/esm/test/WidgetHeader.test.js +1 -1
  107. package/lib/esm/test/WidgetHeader.test.js.map +1 -1
  108. package/lib/esm/widget/components/CalculatedPropertyAction.d.ts +7 -9
  109. package/lib/esm/widget/components/CalculatedPropertyAction.js +50 -27
  110. package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
  111. package/lib/esm/widget/components/CalculatedPropertyTable.d.ts +9 -16
  112. package/lib/esm/widget/components/CalculatedPropertyTable.js +30 -31
  113. package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
  114. package/lib/esm/widget/components/CalculatedPropertyTable.scss +9 -0
  115. package/lib/esm/widget/components/CustomCalculationAction.d.ts +6 -9
  116. package/lib/esm/widget/components/CustomCalculationAction.js +79 -11
  117. package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
  118. package/lib/esm/widget/components/CustomCalculationTable.d.ts +8 -16
  119. package/lib/esm/widget/components/CustomCalculationTable.js +23 -29
  120. package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
  121. package/lib/esm/widget/components/DeleteModal.d.ts +4 -5
  122. package/lib/esm/widget/components/DeleteModal.js +9 -13
  123. package/lib/esm/widget/components/DeleteModal.js.map +1 -1
  124. package/lib/esm/widget/components/GroupAction.js +1 -0
  125. package/lib/esm/widget/components/GroupAction.js.map +1 -1
  126. package/lib/esm/widget/components/GroupInformationPanel.d.ts +10 -0
  127. package/lib/esm/widget/components/GroupInformationPanel.js +16 -0
  128. package/lib/esm/widget/components/GroupInformationPanel.js.map +1 -0
  129. package/lib/esm/widget/components/GroupInformationPanel.scss +13 -0
  130. package/lib/esm/widget/components/GroupPropertyAction.d.ts +6 -9
  131. package/lib/esm/widget/components/GroupPropertyAction.js +25 -15
  132. package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
  133. package/lib/esm/widget/components/GroupPropertyTable.d.ts +8 -15
  134. package/lib/esm/widget/components/GroupPropertyTable.js +24 -28
  135. package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
  136. package/lib/esm/widget/components/Grouping.d.ts +2 -1
  137. package/lib/esm/widget/components/Grouping.js +14 -17
  138. package/lib/esm/widget/components/Grouping.js.map +1 -1
  139. package/lib/esm/widget/components/Grouping.scss +2 -9
  140. package/lib/esm/widget/components/GroupingMapping.js +1 -2
  141. package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
  142. package/lib/esm/widget/components/GroupingMappingContent.js +9 -5
  143. package/lib/esm/widget/components/GroupingMappingContent.js.map +1 -1
  144. package/lib/esm/widget/components/GroupingMappingContext.js +17 -1
  145. package/lib/esm/widget/components/GroupingMappingContext.js.map +1 -1
  146. package/lib/esm/widget/components/GroupingMappingHeader.js +1 -1
  147. package/lib/esm/widget/components/GroupingMappingHeader.js.map +1 -1
  148. package/lib/esm/widget/components/GroupingMappingRouter.js +23 -2
  149. package/lib/esm/widget/components/GroupingMappingRouter.js.map +1 -1
  150. package/lib/esm/widget/components/GroupsAddButton.d.ts +9 -0
  151. package/lib/esm/widget/components/GroupsAddButton.js +10 -0
  152. package/lib/esm/widget/components/GroupsAddButton.js.map +1 -0
  153. package/lib/esm/widget/components/GroupsAddButton.scss +7 -0
  154. package/lib/esm/widget/components/Mapping.js +5 -11
  155. package/lib/esm/widget/components/Mapping.js.map +1 -1
  156. package/lib/esm/widget/components/PropertyMenu.d.ts +12 -17
  157. package/lib/esm/widget/components/PropertyMenu.js +54 -154
  158. package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
  159. package/lib/esm/widget/components/PropertyMenu.scss +4 -28
  160. package/lib/esm/widget/components/PropertyNameCell.d.ts +11 -0
  161. package/lib/esm/widget/components/PropertyNameCell.js +8 -0
  162. package/lib/esm/widget/components/PropertyNameCell.js.map +1 -0
  163. package/lib/esm/widget/components/PropertyTable.d.ts +18 -0
  164. package/lib/esm/widget/components/PropertyTable.js +28 -0
  165. package/lib/esm/widget/components/PropertyTable.js.map +1 -0
  166. package/lib/esm/widget/components/PropertyTable.scss +11 -0
  167. package/lib/esm/widget/components/PropertyTableToolbar.d.ts +10 -0
  168. package/lib/esm/widget/components/PropertyTableToolbar.js +16 -0
  169. package/lib/esm/widget/components/PropertyTableToolbar.js.map +1 -0
  170. package/lib/esm/widget/components/PropertyTableToolbar.scss +12 -0
  171. package/lib/esm/widget/components/ToggleGroupVisibility.d.ts +9 -0
  172. package/lib/esm/widget/components/ToggleGroupVisibility.js +9 -0
  173. package/lib/esm/widget/components/ToggleGroupVisibility.js.map +1 -0
  174. package/lib/esm/widget/components/ToggleGroupVisibility.scss +9 -0
  175. package/lib/esm/widget/components/WidgetHeader.d.ts +9 -0
  176. package/lib/esm/widget/components/WidgetHeader.js +15 -0
  177. package/lib/esm/widget/components/WidgetHeader.js.map +1 -0
  178. package/lib/esm/widget/components/WidgetHeader.scss +36 -0
  179. package/lib/esm/widget/components/context/GroupHilitedElementsContext.d.ts +6 -1
  180. package/lib/esm/widget/components/context/GroupHilitedElementsContext.js.map +1 -1
  181. package/lib/esm/widget/components/context/PropertiesContext.d.ts +15 -0
  182. package/lib/esm/widget/components/context/PropertiesContext.js +20 -0
  183. package/lib/esm/widget/components/context/PropertiesContext.js.map +1 -0
  184. package/lib/esm/widget/components/groupsHelpers.d.ts +6 -3
  185. package/lib/esm/widget/components/groupsHelpers.js +41 -40
  186. package/lib/esm/widget/components/groupsHelpers.js.map +1 -1
  187. package/lib/esm/widget/components/property-grid/PropertyRender.js +2 -1
  188. package/lib/esm/widget/components/property-grid/PropertyRender.js.map +1 -1
  189. package/lib/esm/widget/components/property-grid/countMatchesInString.d.ts +8 -0
  190. package/lib/esm/widget/components/property-grid/countMatchesInString.js +28 -0
  191. package/lib/esm/widget/components/property-grid/countMatchesInString.js.map +1 -0
  192. package/lib/esm/widget/components/property-grid/createNewDisplayValue.d.ts +10 -0
  193. package/lib/esm/widget/components/property-grid/createNewDisplayValue.js +42 -0
  194. package/lib/esm/widget/components/property-grid/createNewDisplayValue.js.map +1 -0
  195. package/lib/esm/widget/components/utils.d.ts +0 -6
  196. package/lib/esm/widget/components/utils.js +0 -7
  197. package/lib/esm/widget/components/utils.js.map +1 -1
  198. package/lib/esm/widget/components/utils.scss +0 -29
  199. package/lib/esm/widget/components/viewerUtils.d.ts +4 -2
  200. package/lib/esm/widget/components/viewerUtils.js +3 -20
  201. package/lib/esm/widget/components/viewerUtils.js.map +1 -1
  202. package/lib/esm/widget/hooks/useFetchData.d.ts +3 -5
  203. package/lib/esm/widget/hooks/useFetchData.js +9 -7
  204. package/lib/esm/widget/hooks/useFetchData.js.map +1 -1
  205. package/package.json +1 -1
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export interface PropertyNameCellProps<T extends {
3
+ propertyName: string;
4
+ }> {
5
+ property: T;
6
+ onClickModify?: (value: T) => void;
7
+ }
8
+ export declare const PropertyNameCell: <T extends {
9
+ propertyName: string;
10
+ }>({ property, onClickModify, }: PropertyNameCellProps<T>) => JSX.Element;
11
+ //# sourceMappingURL=PropertyNameCell.d.ts.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PropertyNameCell = void 0;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ const react_1 = __importDefault(require("react"));
12
+ const itwinui_react_1 = require("@itwin/itwinui-react");
13
+ const PropertyNameCell = ({ property, onClickModify, }) => onClickModify ? (react_1.default.createElement("div", { className: "iui-anchor", onClick: () => onClickModify(property) }, property.propertyName)) : (react_1.default.createElement(itwinui_react_1.Text, null, property.propertyName));
14
+ exports.PropertyNameCell = PropertyNameCell;
15
+ //# sourceMappingURL=PropertyNameCell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyNameCell.js","sourceRoot":"","sources":["../../../../src/widget/components/PropertyNameCell.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,kDAA0B;AAC1B,wDAA4C;AAOrC,MAAM,gBAAgB,GAAG,CAAsC,EACpE,QAAQ,EACR,aAAa,GACY,EAAE,EAAE,CAC7B,aAAa,CAAC,CAAC,CAAC,CACd,uCAAK,SAAS,EAAC,YAAY,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,IAC/D,QAAQ,CAAC,YAAY,CAClB,CACP,CAAC,CAAC,CAAC,CACF,8BAAC,oBAAI,QAAE,QAAQ,CAAC,YAAY,CAAQ,CACrC,CAAC;AAVS,QAAA,gBAAgB,oBAUzB","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 React from \"react\";\nimport { Text } from \"@itwin/itwinui-react\";\n\nexport interface PropertyNameCellProps<T extends { propertyName: string }> {\n property: T;\n onClickModify?: (value: T) => void;\n}\n\nexport const PropertyNameCell = <T extends { propertyName: string },>({\n property,\n onClickModify,\n}: PropertyNameCellProps<T>) =>\n onClickModify ? (\n <div className=\"iui-anchor\" onClick={() => onClickModify(property)}>\n {property.propertyName}\n </div>\n ) : (\n <Text>{property.propertyName}</Text>\n );\n"]}
@@ -0,0 +1,18 @@
1
+ /// <reference types="react" />
2
+ import type { Column } from "react-table";
3
+ import "./PropertyTable.scss";
4
+ export interface PropertyTableItem {
5
+ propertyName: string;
6
+ id: string;
7
+ }
8
+ export interface PropertyTableProps<T extends PropertyTableItem> {
9
+ propertyType: string;
10
+ columnsFactory: (handleShowDeleteModal: (value: T) => void) => ReadonlyArray<Column<T>>;
11
+ data: T[];
12
+ isLoading: boolean;
13
+ onClickAdd?: () => void;
14
+ refreshProperties: () => Promise<void>;
15
+ deleteProperty: (propertyId: string) => Promise<void>;
16
+ }
17
+ export declare const PropertyTable: <T extends PropertyTableItem>({ propertyType, columnsFactory, data, isLoading, onClickAdd, refreshProperties, deleteProperty, }: PropertyTableProps<T>) => JSX.Element;
18
+ //# sourceMappingURL=PropertyTable.d.ts.map
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.PropertyTable = void 0;
26
+ /*---------------------------------------------------------------------------------------------
27
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
28
+ * See LICENSE.md in the project root for license terms and full copyright notice.
29
+ *--------------------------------------------------------------------------------------------*/
30
+ const itwinui_react_1 = require("@itwin/itwinui-react");
31
+ const react_1 = __importStar(require("react"));
32
+ const DeleteModal_1 = __importDefault(require("./DeleteModal"));
33
+ const PropertyTableToolbar_1 = require("./PropertyTableToolbar");
34
+ require("./PropertyTable.scss");
35
+ const PropertyTable = ({ propertyType, columnsFactory, data, isLoading, onClickAdd, refreshProperties, deleteProperty, }) => {
36
+ const [showDeleteModal, setShowDeleteModal] = react_1.useState(undefined);
37
+ const handleDeleteProperty = react_1.useCallback(async () => {
38
+ var _a;
39
+ await deleteProperty((_a = showDeleteModal === null || showDeleteModal === void 0 ? void 0 : showDeleteModal.id) !== null && _a !== void 0 ? _a : "");
40
+ }, [deleteProperty, showDeleteModal === null || showDeleteModal === void 0 ? void 0 : showDeleteModal.id]);
41
+ const handleShowDeleteModal = react_1.useCallback((property) => {
42
+ setShowDeleteModal(property);
43
+ }, []);
44
+ const handleCloseDeleteModal = () => {
45
+ setShowDeleteModal(undefined);
46
+ };
47
+ const memoizedColumns = react_1.useMemo(() => columnsFactory(handleShowDeleteModal), [columnsFactory, handleShowDeleteModal]);
48
+ return (react_1.default.createElement("div", { className: "gmw-property-table-container" },
49
+ react_1.default.createElement(PropertyTableToolbar_1.PropertyTableToolbar, { propertyType: propertyType, onClickAddProperty: onClickAdd, refreshProperties: refreshProperties, isLoading: isLoading }),
50
+ react_1.default.createElement(itwinui_react_1.Table, { data: isLoading ? [] : data, density: 'extra-condensed', columns: memoizedColumns, emptyTableContent: `No ${propertyType} Properties`, isSortable: true, isLoading: isLoading }),
51
+ react_1.default.createElement(DeleteModal_1.default, { entityName: showDeleteModal === null || showDeleteModal === void 0 ? void 0 : showDeleteModal.propertyName, onClose: handleCloseDeleteModal, onDelete: handleDeleteProperty, refresh: refreshProperties })));
52
+ };
53
+ exports.PropertyTable = PropertyTable;
54
+ //# sourceMappingURL=PropertyTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyTable.js","sourceRoot":"","sources":["../../../../src/widget/components/PropertyTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAA6C;AAC7C,+CAA8D;AAG9D,gEAAwC;AACxC,iEAA8D;AAC9D,gCAA8B;AAiBvB,MAAM,aAAa,GAAG,CAA8B,EACzD,YAAY,EACZ,cAAc,EACd,IAAI,EACJ,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,cAAc,GACQ,EAAE,EAAE;IAE1B,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,gBAAQ,CAAgB,SAAS,CAAC,CAAC;IAEjF,MAAM,oBAAoB,GAAG,mBAAW,CAAC,KAAK,IAAI,EAAE;;QAClD,MAAM,cAAc,CAAC,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,EAAE,mCAAI,EAAE,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,cAAc,EAAE,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,EAAE,CAAC,CAAC,CAAC;IAE1C,MAAM,qBAAqB,GAAG,mBAAW,CAAC,CAAC,QAAW,EAAE,EAAE;QACxD,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,sBAAsB,GAAG,GAAG,EAAE;QAClC,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC,CAAC;IAEF,MAAM,eAAe,GAAG,eAAO,CAAC,GAAG,EAAE,CACnC,cAAc,CAAC,qBAAqB,CAAC,EAAE,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAElF,OAAO,CACL,uCAAK,SAAS,EAAC,8BAA8B;QAC3C,8BAAC,2CAAoB,IACnB,YAAY,EAAE,YAAY,EAC1B,kBAAkB,EAAE,UAAU,EAC9B,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,SAAS,GACpB;QACF,8BAAC,qBAAK,IACJ,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAC3B,OAAO,EAAC,iBAAiB,EACzB,OAAO,EAAE,eAAe,EACxB,iBAAiB,EAAE,MAAM,YAAY,aAAa,EAClD,UAAU,QACV,SAAS,EAAE,SAAS,GACpB;QACF,8BAAC,qBAAW,IACV,UAAU,EAAE,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,YAAY,EACzC,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,EAAE,iBAAiB,GAC1B,CACE,CACP,CAAC;AACJ,CAAC,CAAC;AAnDW,QAAA,aAAa,iBAmDxB","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 { Table } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport type { Column } from \"react-table\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport DeleteModal from \"./DeleteModal\";\nimport { PropertyTableToolbar } from \"./PropertyTableToolbar\";\nimport \"./PropertyTable.scss\";\n\nexport interface PropertyTableItem {\n propertyName: string;\n id: string;\n}\n\nexport interface PropertyTableProps<T extends PropertyTableItem> {\n propertyType: string;\n columnsFactory: (handleShowDeleteModal: (value: T) => void) => ReadonlyArray<Column<T>>;\n data: T[];\n isLoading: boolean;\n onClickAdd?: () => void;\n refreshProperties: () => Promise<void>;\n deleteProperty: (propertyId: string) => Promise<void>;\n}\n\nexport const PropertyTable = <T extends PropertyTableItem>({\n propertyType,\n columnsFactory,\n data,\n isLoading,\n onClickAdd,\n refreshProperties,\n deleteProperty,\n}: PropertyTableProps<T>) => {\n\n const [showDeleteModal, setShowDeleteModal] = useState<T | undefined>(undefined);\n\n const handleDeleteProperty = useCallback(async () => {\n await deleteProperty(showDeleteModal?.id ?? \"\");\n }, [deleteProperty, showDeleteModal?.id]);\n\n const handleShowDeleteModal = useCallback((property: T) => {\n setShowDeleteModal(property);\n }, []);\n\n const handleCloseDeleteModal = () => {\n setShowDeleteModal(undefined);\n };\n\n const memoizedColumns = useMemo(() =>\n columnsFactory(handleShowDeleteModal), [columnsFactory, handleShowDeleteModal]);\n\n return (\n <div className=\"gmw-property-table-container\">\n <PropertyTableToolbar\n propertyType={propertyType}\n onClickAddProperty={onClickAdd}\n refreshProperties={refreshProperties}\n isLoading={isLoading}\n />\n <Table<CreateTypeFromInterface<T>>\n data={isLoading ? [] : data}\n density='extra-condensed'\n columns={memoizedColumns}\n emptyTableContent={`No ${propertyType} Properties`}\n isSortable\n isLoading={isLoading}\n />\n <DeleteModal\n entityName={showDeleteModal?.propertyName}\n onClose={handleCloseDeleteModal}\n onDelete={handleDeleteProperty}\n refresh={refreshProperties}\n />\n </div>\n );\n};\n"]}
@@ -0,0 +1,11 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ @import "~@itwin/itwinui-css/scss/variables";
6
+
7
+ .gmw-property-table-container {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: $iui-baseline;
11
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import "./PropertyTableToolbar.scss";
3
+ export interface PropertyTableToolbarProps {
4
+ propertyType: string;
5
+ onClickAddProperty?: () => void;
6
+ refreshProperties: () => void;
7
+ isLoading: boolean;
8
+ }
9
+ export declare const PropertyTableToolbar: ({ propertyType, onClickAddProperty, refreshProperties, isLoading, }: PropertyTableToolbarProps) => JSX.Element;
10
+ //# sourceMappingURL=PropertyTableToolbar.d.ts.map
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PropertyTableToolbar = void 0;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ const react_1 = __importDefault(require("react"));
12
+ const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
13
+ const itwinui_react_1 = require("@itwin/itwinui-react");
14
+ require("./PropertyTableToolbar.scss");
15
+ const PropertyTableToolbar = ({ propertyType, onClickAddProperty, refreshProperties, isLoading, }) => (react_1.default.createElement("div", { className: "gmw-property-table-toolbar" },
16
+ onClickAddProperty && (react_1.default.createElement(itwinui_react_1.Button, { startIcon: react_1.default.createElement(itwinui_icons_react_1.SvgAdd, null), styleType: "high-visibility", onClick: onClickAddProperty },
17
+ "Add ",
18
+ propertyType,
19
+ " Property")),
20
+ react_1.default.createElement(itwinui_react_1.IconButton, { title: "Refresh", className: "gmw-property-table-refresh-button", onClick: refreshProperties, disabled: isLoading, styleType: "borderless" },
21
+ react_1.default.createElement(itwinui_icons_react_1.SvgRefresh, null))));
22
+ exports.PropertyTableToolbar = PropertyTableToolbar;
23
+ //# sourceMappingURL=PropertyTableToolbar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyTableToolbar.js","sourceRoot":"","sources":["../../../../src/widget/components/PropertyTableToolbar.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,kDAA0B;AAC1B,oEAAgE;AAChE,wDAA0D;AAC1D,uCAAqC;AAS9B,MAAM,oBAAoB,GAAG,CAAC,EACnC,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,GACiB,EAAE,EAAE,CAAC,CAC/B,uCAAK,SAAS,EAAC,4BAA4B;IACxC,kBAAkB,IAAI,CACrB,8BAAC,sBAAM,IACL,SAAS,EAAE,8BAAC,4BAAM,OAAG,EACrB,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,kBAAkB;;QAEtB,YAAY;oBACV,CACV;IACD,8BAAC,0BAAU,IACT,KAAK,EAAC,SAAS,EACf,SAAS,EAAC,mCAAmC,EAC7C,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAC,YAAY;QAEtB,8BAAC,gCAAU,OAAG,CACH,CACT,CACP,CAAC;AA1BW,QAAA,oBAAoB,wBA0B/B","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 React from \"react\";\nimport { SvgAdd, SvgRefresh } from \"@itwin/itwinui-icons-react\";\nimport { Button, IconButton } from \"@itwin/itwinui-react\";\nimport \"./PropertyTableToolbar.scss\";\n\nexport interface PropertyTableToolbarProps {\n propertyType: string;\n onClickAddProperty?: () => void;\n refreshProperties: () => void;\n isLoading: boolean;\n}\n\nexport const PropertyTableToolbar = ({\n propertyType,\n onClickAddProperty,\n refreshProperties,\n isLoading,\n}: PropertyTableToolbarProps) => (\n <div className=\"gmw-property-table-toolbar\">\n {onClickAddProperty && (\n <Button\n startIcon={<SvgAdd />}\n styleType=\"high-visibility\"\n onClick={onClickAddProperty}\n >\n Add {propertyType} Property\n </Button>\n )}\n <IconButton\n title=\"Refresh\"\n className=\"gmw-property-table-refresh-button\"\n onClick={refreshProperties}\n disabled={isLoading}\n styleType=\"borderless\"\n >\n <SvgRefresh />\n </IconButton>\n </div>\n);\n"]}
@@ -0,0 +1,12 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ .gmw-property-table-toolbar {
7
+ display: flex;
8
+ justify-content: space-between;
9
+ .gmw-property-table-refresh-button {
10
+ margin-left: auto;
11
+ }
12
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import "./ToggleGroupVisibility.scss";
3
+ export interface ToggleGroupVisibilityProps {
4
+ isLoadingQuery: boolean;
5
+ showGroupColor: boolean;
6
+ setShowGroupColor: (value: ((prevState: boolean) => boolean) | boolean) => void;
7
+ }
8
+ export declare const ToggleGroupVisibility: ({ isLoadingQuery, showGroupColor, setShowGroupColor }: ToggleGroupVisibilityProps) => JSX.Element;
9
+ //# sourceMappingURL=ToggleGroupVisibility.d.ts.map
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ToggleGroupVisibility = void 0;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ const itwinui_react_1 = require("@itwin/itwinui-react");
12
+ require("./ToggleGroupVisibility.scss");
13
+ const react_1 = __importDefault(require("react"));
14
+ const ToggleGroupVisibility = ({ isLoadingQuery, showGroupColor, setShowGroupColor }) => (react_1.default.createElement(itwinui_react_1.ToggleSwitch, { label: "Color by Group", labelPosition: "left", className: "gmw-toggle", disabled: isLoadingQuery, checked: showGroupColor, onChange: () => setShowGroupColor((b) => !b) }));
15
+ exports.ToggleGroupVisibility = ToggleGroupVisibility;
16
+ //# sourceMappingURL=ToggleGroupVisibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToggleGroupVisibility.js","sourceRoot":"","sources":["../../../../src/widget/components/ToggleGroupVisibility.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,wDAAoD;AACpD,wCAAsC;AACtC,kDAA0B;AAQnB,MAAM,qBAAqB,GAAG,CAAC,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAA8B,EAAE,EAAE,CAAC,CAC1H,8BAAC,4BAAY,IACX,KAAK,EAAC,gBAAgB,EACtB,aAAa,EAAC,MAAM,EACpB,SAAS,EAAC,YAAY,EACtB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAC5C,CACH,CAAC;AATW,QAAA,qBAAqB,yBAShC","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 { ToggleSwitch } from \"@itwin/itwinui-react\";\nimport \"./ToggleGroupVisibility.scss\";\nimport React from \"react\";\n\nexport interface ToggleGroupVisibilityProps {\n isLoadingQuery: boolean;\n showGroupColor: boolean;\n setShowGroupColor: (value: ((prevState: boolean) => boolean) | boolean) => void;\n}\n\nexport const ToggleGroupVisibility = ({ isLoadingQuery, showGroupColor, setShowGroupColor }: ToggleGroupVisibilityProps) => (\n <ToggleSwitch\n label=\"Color by Group\"\n labelPosition=\"left\"\n className=\"gmw-toggle\"\n disabled={isLoadingQuery}\n checked={showGroupColor}\n onChange={() => setShowGroupColor((b) => !b)}\n />\n);\n"]}
@@ -0,0 +1,9 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ @import "~@itwin/itwinui-css/scss/variables";
6
+
7
+ .gmw-toggle {
8
+ margin-right: $iui-xs;
9
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import "./WidgetHeader.scss";
3
+ export interface WidgetHeaderProps {
4
+ title: string;
5
+ disabled?: boolean;
6
+ returnFn?: () => void;
7
+ }
8
+ export declare const WidgetHeader: ({ title, disabled, returnFn, }: WidgetHeaderProps) => JSX.Element;
9
+ //# sourceMappingURL=WidgetHeader.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WidgetHeader = void 0;
7
+ /*---------------------------------------------------------------------------------------------
8
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
9
+ * See LICENSE.md in the project root for license terms and full copyright notice.
10
+ *--------------------------------------------------------------------------------------------*/
11
+ const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
12
+ const itwinui_react_1 = require("@itwin/itwinui-react");
13
+ require("./WidgetHeader.scss");
14
+ const react_1 = __importDefault(require("react"));
15
+ const WidgetHeader = ({ title, disabled = false, returnFn, }) => {
16
+ return (react_1.default.createElement("div", { className: 'gmw-widget-header-container' },
17
+ returnFn && (react_1.default.createElement("div", { className: disabled ? "gmw-chevron-disabled" : "gmw-chevron", onClick: disabled ? undefined : returnFn },
18
+ react_1.default.createElement(itwinui_icons_react_1.SvgChevronLeft, null))),
19
+ react_1.default.createElement(itwinui_react_1.Text, { className: 'gmw-title', variant: 'title' }, title)));
20
+ };
21
+ exports.WidgetHeader = WidgetHeader;
22
+ //# sourceMappingURL=WidgetHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetHeader.js","sourceRoot":"","sources":["../../../../src/widget/components/WidgetHeader.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,oEAA4D;AAC5D,wDAA4C;AAC5C,+BAA6B;AAC7B,kDAA0B;AAQnB,MAAM,YAAY,GAAG,CAAC,EAC3B,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,QAAQ,GACU,EAAE,EAAE;IACtB,OAAO,CACL,uCAAK,SAAS,EAAC,6BAA6B;QACzC,QAAQ,IAAI,CACX,uCACE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,aAAa,EAC5D,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;YAExC,8BAAC,oCAAc,OAAG,CACd,CACP;QACD,8BAAC,oBAAI,IAAC,SAAS,EAAC,WAAW,EAAC,OAAO,EAAC,OAAO,IACxC,KAAK,CACD,CACH,CACP,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,YAAY,gBAoBvB","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 } from \"@itwin/itwinui-react\";\nimport \"./WidgetHeader.scss\";\nimport React from \"react\";\n\nexport interface WidgetHeaderProps {\n title: string;\n disabled?: boolean;\n returnFn?: () => void;\n}\n\nexport const WidgetHeader = ({\n title,\n disabled = false,\n returnFn,\n}: WidgetHeaderProps) => {\n return (\n <div className='gmw-widget-header-container'>\n {returnFn && (\n <div\n className={disabled ? \"gmw-chevron-disabled\" : \"gmw-chevron\"}\n onClick={disabled ? undefined : returnFn}\n >\n <SvgChevronLeft />\n </div>\n )}\n <Text className='gmw-title' variant='title'>\n {title}\n </Text>\n </div>\n );\n};\n"]}
@@ -0,0 +1,36 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ @import "~@itwin/itwinui-css/scss/variables";
6
+ @import "~@itwin/itwinui-css/scss/icon/index";
7
+ @import "~@itwin/itwinui-css/scss/button/index";
8
+
9
+ .gmw-widget-header-container {
10
+ display: flex;
11
+ margin-bottom: $iui-baseline * 2;
12
+
13
+ .gmw-chevron {
14
+ @include iui-icons-large();
15
+ cursor: pointer;
16
+ align-self: center;
17
+ margin-right: $iui-s;
18
+ }
19
+
20
+ .gmw-chevron-disabled {
21
+ @include iui-icons-large();
22
+ @include themed {
23
+ fill: t(iui-icons-color-actionable-disabled);
24
+ }
25
+ cursor: not-allowed;
26
+
27
+ align-self: center;
28
+ margin-right: $iui-s;
29
+ }
30
+
31
+ .gmw-title {
32
+ overflow: hidden;
33
+ white-space: nowrap;
34
+ text-overflow: ellipsis;
35
+ }
36
+ }
@@ -1,8 +1,13 @@
1
1
  import * as React from "react";
2
2
  import type { MutableRefObject } from "react";
3
3
  import type { Group } from "@itwin/insights-client";
4
+ import type { KeySet } from "@itwin/presentation-common";
5
+ export interface QueryCacheItem {
6
+ keySet: KeySet;
7
+ ids: string[];
8
+ }
4
9
  export interface GroupHilitedElements {
5
- hilitedElementsQueryCache: MutableRefObject<Map<string, string[]>>;
10
+ hilitedElementsQueryCache: MutableRefObject<Map<string, QueryCacheItem>>;
6
11
  hiddenGroupsIds: string[];
7
12
  showGroupColor: boolean;
8
13
  groups: Group[];
@@ -1 +1 @@
1
- {"version":3,"file":"GroupHilitedElementsContext.js","sourceRoot":"","sources":["../../../../../src/widget/components/context/GroupHilitedElementsContext.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,6CAA+B;AAclB,QAAA,2BAA2B,GAAG,KAAK,CAAC,aAAa,CAAuB;IACnF,yBAAyB,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE;IACjD,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,KAAK;IACrB,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,GAAG,EAAE,GAAG,CAAC;IACpB,kBAAkB,EAAE,GAAG,EAAE,GAAG,CAAC;IAC7B,iBAAiB,EAAE,GAAG,EAAE,GAAG,CAAC;CAC7B,CAAC,CAAC;AAEI,MAAM,8BAA8B,GAAG,GAAyB,EAAE;IACvE,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,mCAA2B,CAAC,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,8BAA8B,kCAQzC","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 { MutableRefObject } from \"react\";\nimport type { Group } from \"@itwin/insights-client\";\n\nexport interface GroupHilitedElements {\n hilitedElementsQueryCache: MutableRefObject<Map<string, string[]>>;\n hiddenGroupsIds: string[];\n showGroupColor: boolean;\n groups: Group[];\n setGroups: (groups: Group[]) => void;\n setHiddenGroupsIds: (hiddenGroupIds: string[]) => void;\n setShowGroupColor: (showGroupColor: boolean | ((showGroupColor: boolean) => boolean)) => void;\n}\n\nexport const GroupHilitedElementsContext = React.createContext<GroupHilitedElements>({\n hilitedElementsQueryCache: { current: new Map() },\n hiddenGroupsIds: [],\n showGroupColor: false,\n groups: [],\n setGroups: () => { },\n setHiddenGroupsIds: () => { },\n setShowGroupColor: () => { },\n});\n\nexport const useGroupHilitedElementsContext = (): GroupHilitedElements => {\n const context = React.useContext(GroupHilitedElementsContext);\n if (!context) {\n throw new Error(\n \"useGroupHilitedElementsContext should be used within a GroupHilitedElementsContext provider\"\n );\n }\n return context;\n};\n"]}
1
+ {"version":3,"file":"GroupHilitedElementsContext.js","sourceRoot":"","sources":["../../../../../src/widget/components/context/GroupHilitedElementsContext.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,6CAA+B;AAkBlB,QAAA,2BAA2B,GAAG,KAAK,CAAC,aAAa,CAAuB;IACnF,yBAAyB,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE;IACjD,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,KAAK;IACrB,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,GAAG,EAAE,GAAG,CAAC;IACpB,kBAAkB,EAAE,GAAG,EAAE,GAAG,CAAC;IAC7B,iBAAiB,EAAE,GAAG,EAAE,GAAG,CAAC;CAC7B,CAAC,CAAC;AAEI,MAAM,8BAA8B,GAAG,GAAyB,EAAE;IACvE,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,mCAA2B,CAAC,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,6FAA6F,CAC9F,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,8BAA8B,kCAQzC","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 { MutableRefObject } from \"react\";\nimport type { Group } from \"@itwin/insights-client\";\nimport type { KeySet } from \"@itwin/presentation-common\";\nexport interface QueryCacheItem {\n keySet: KeySet;\n ids: string[];\n}\nexport interface GroupHilitedElements {\n hilitedElementsQueryCache: MutableRefObject<Map<string, QueryCacheItem>>;\n hiddenGroupsIds: string[];\n showGroupColor: boolean;\n groups: Group[];\n setGroups: (groups: Group[]) => void;\n setHiddenGroupsIds: (hiddenGroupIds: string[]) => void;\n setShowGroupColor: (showGroupColor: boolean | ((showGroupColor: boolean) => boolean)) => void;\n}\n\nexport const GroupHilitedElementsContext = React.createContext<GroupHilitedElements>({\n hilitedElementsQueryCache: { current: new Map() },\n hiddenGroupsIds: [],\n showGroupColor: false,\n groups: [],\n setGroups: () => { },\n setHiddenGroupsIds: () => { },\n setShowGroupColor: () => { },\n});\n\nexport const useGroupHilitedElementsContext = (): GroupHilitedElements => {\n const context = React.useContext(GroupHilitedElementsContext);\n if (!context) {\n throw new Error(\n \"useGroupHilitedElementsContext should be used within a GroupHilitedElementsContext provider\"\n );\n }\n return context;\n};\n"]}
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import type { CalculatedProperty, CustomCalculation, GroupProperty } from "@itwin/insights-client";
3
+ export interface Properties {
4
+ showGroupColor: boolean;
5
+ groupProperties?: GroupProperty[];
6
+ calculatedProperties?: CalculatedProperty[];
7
+ customCalculationProperties?: CustomCalculation[];
8
+ setGroupProperties: (groupProperties: GroupProperty[]) => void;
9
+ setCalculatedProperties: (calculatedProperties: CalculatedProperty[]) => void;
10
+ setCustomCalculationProperties: (customCalculationProperties: CustomCalculation[]) => void;
11
+ setShowGroupColor: (showGroupColor: boolean | ((showGroupColor: boolean) => boolean)) => void;
12
+ }
13
+ export declare const PropertiesContext: React.Context<Properties>;
14
+ export declare const usePropertiesContext: () => Properties;
15
+ //# sourceMappingURL=PropertiesContext.d.ts.map
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.usePropertiesContext = exports.PropertiesContext = void 0;
23
+ /*---------------------------------------------------------------------------------------------
24
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
+ * See LICENSE.md in the project root for license terms and full copyright notice.
26
+ *--------------------------------------------------------------------------------------------*/
27
+ const React = __importStar(require("react"));
28
+ exports.PropertiesContext = React.createContext({
29
+ showGroupColor: false,
30
+ setGroupProperties: () => { },
31
+ setCalculatedProperties: () => { },
32
+ setCustomCalculationProperties: () => { },
33
+ setShowGroupColor: () => { },
34
+ });
35
+ const usePropertiesContext = () => {
36
+ const context = React.useContext(exports.PropertiesContext);
37
+ if (!context) {
38
+ throw new Error("usePropertiesContext should be used within a PropertiesContext provider");
39
+ }
40
+ return context;
41
+ };
42
+ exports.usePropertiesContext = usePropertiesContext;
43
+ //# sourceMappingURL=PropertiesContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertiesContext.js","sourceRoot":"","sources":["../../../../../src/widget/components/context/PropertiesContext.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,6CAA+B;AAclB,QAAA,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAAa;IAC/D,cAAc,EAAE,KAAK;IACrB,kBAAkB,EAAE,GAAG,EAAE,GAAG,CAAC;IAC7B,uBAAuB,EAAE,GAAG,EAAE,GAAG,CAAC;IAClC,8BAA8B,EAAE,GAAG,EAAE,GAAG,CAAC;IACzC,iBAAiB,EAAE,GAAG,EAAE,GAAG,CAAC;CAC7B,CAAC,CAAC;AAEI,MAAM,oBAAoB,GAAG,GAAe,EAAE;IACnD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,yBAAiB,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,oBAAoB,wBAQ/B","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 { CalculatedProperty, CustomCalculation, GroupProperty } from \"@itwin/insights-client\";\n\nexport interface Properties {\n showGroupColor: boolean;\n groupProperties?: GroupProperty[];\n calculatedProperties?: CalculatedProperty[];\n customCalculationProperties?: CustomCalculation[];\n setGroupProperties: (groupProperties: GroupProperty[]) => void;\n setCalculatedProperties: (calculatedProperties: CalculatedProperty[]) => void;\n setCustomCalculationProperties: (customCalculationProperties: CustomCalculation[]) => void;\n setShowGroupColor: (showGroupColor: boolean | ((showGroupColor: boolean) => boolean)) => void;\n}\n\nexport const PropertiesContext = React.createContext<Properties>({\n showGroupColor: false,\n setGroupProperties: () => { },\n setCalculatedProperties: () => { },\n setCustomCalculationProperties: () => { },\n setShowGroupColor: () => { },\n});\n\nexport const usePropertiesContext = (): Properties => {\n const context = React.useContext(PropertiesContext);\n if (!context) {\n throw new Error(\n \"usePropertiesContext should be used within a PropertiesContext provider\"\n );\n }\n return context;\n};\n"]}
@@ -1,7 +1,10 @@
1
1
  import type { IModelConnection } from "@itwin/core-frontend";
2
2
  import type { Group } from "@itwin/insights-client";
3
+ import type { QueryCacheItem } from "./context/GroupHilitedElementsContext";
3
4
  export declare const getGroupColor: (index: number) => string;
4
- export declare const getHiliteIdsFromGroups: (iModelConnection: IModelConnection, groups: Group[], hilitedElementsQueryCache: React.MutableRefObject<Map<string, string[]>>) => Promise<string[]>;
5
- export declare const hideGroups: (iModelConnection: IModelConnection, viewGroups: Group[], hilitedElementsQueryCache: React.MutableRefObject<Map<string, string[]>>) => Promise<void>;
6
- export declare const visualizeGroupColors: (iModelConnection: IModelConnection, groups: Group[], viewGroups: Group[], hiddenGroupsIds: string[], hilitedElementsQueryCache: React.MutableRefObject<Map<string, string[]>>, doEmphasizeElements?: boolean) => Promise<void>;
5
+ export declare const getHiliteIdsFromGroups: (iModelConnection: IModelConnection, groups: Group[], hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>) => Promise<string[]>;
6
+ export declare const hideGroups: (iModelConnection: IModelConnection, viewGroups: Group[], hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>) => Promise<void>;
7
+ export declare const hideGroup: (iModelConnection: IModelConnection, viewGroup: Group, hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>) => Promise<void>;
8
+ export declare const visualizeGroupColors: (iModelConnection: IModelConnection, groups: Group[], viewGroups: Group[], hiddenGroupsIds: string[], hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>, doEmphasizeElements?: boolean) => Promise<void>;
9
+ export declare const getHiliteIdsAndKeysetFromGroup: (iModelConnection: IModelConnection, group: Group, hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>) => Promise<QueryCacheItem>;
7
10
  //# sourceMappingURL=groupsHelpers.d.ts.map
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.visualizeGroupColors = exports.hideGroups = exports.getHiliteIdsFromGroups = exports.getGroupColor = void 0;
3
+ exports.getHiliteIdsAndKeysetFromGroup = exports.visualizeGroupColors = exports.hideGroup = exports.hideGroups = exports.getHiliteIdsFromGroups = exports.getGroupColor = void 0;
4
4
  /*---------------------------------------------------------------------------------------------
5
5
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
6
  * See LICENSE.md in the project root for license terms and full copyright notice.
7
7
  *--------------------------------------------------------------------------------------------*/
8
8
  const core_common_1 = require("@itwin/core-common");
9
9
  const itwinui_react_1 = require("@itwin/itwinui-react");
10
+ const presentation_common_1 = require("@itwin/presentation-common");
10
11
  const viewerUtils_1 = require("./viewerUtils");
11
12
  const goldenAngle = 180 * (3 - Math.sqrt(5));
12
13
  const getGroupColor = function (index) {
@@ -14,56 +15,36 @@ const getGroupColor = function (index) {
14
15
  };
15
16
  exports.getGroupColor = getGroupColor;
16
17
  const getHiliteIdsFromGroups = async (iModelConnection, groups, hilitedElementsQueryCache) => {
17
- var _a;
18
- let allIds = [];
18
+ const distinctQueries = new Set();
19
+ const promises = [];
19
20
  for (const group of groups) {
20
- const query = group.query;
21
- let currentIds = [];
22
- if (hilitedElementsQueryCache.current.has(query)) {
23
- currentIds = (_a = hilitedElementsQueryCache.current.get(query)) !== null && _a !== void 0 ? _a : [];
24
- }
25
- else {
26
- try {
27
- const queryRowCount = await iModelConnection.queryRowCount(query);
28
- if (queryRowCount === 0) {
29
- itwinui_react_1.toaster.warning(`${group.groupName}'s query is valid but produced no results.`);
30
- }
31
- currentIds = await viewerUtils_1.getHiliteIds(query, iModelConnection);
32
- hilitedElementsQueryCache.current.set(query, currentIds);
33
- }
34
- catch {
35
- itwinui_react_1.toaster.negative(`Could not hide/show ${group.groupName}. Query could not be resolved.`);
36
- }
21
+ if (!distinctQueries.has(group.query)) {
22
+ distinctQueries.add(group.query);
23
+ promises.push(exports.getHiliteIdsAndKeysetFromGroup(iModelConnection, group, hilitedElementsQueryCache));
37
24
  }
38
- allIds = allIds.concat(currentIds);
39
25
  }
26
+ const results = await Promise.all(promises);
27
+ const allIds = results.flatMap((result) => result.ids);
40
28
  return allIds;
41
29
  };
42
30
  exports.getHiliteIdsFromGroups = getHiliteIdsFromGroups;
43
31
  const hideGroups = async (iModelConnection, viewGroups, hilitedElementsQueryCache) => {
44
- var _a;
32
+ const distinctQueries = new Set();
33
+ const promises = [];
45
34
  for (const viewGroup of viewGroups) {
46
- const query = viewGroup.query;
47
- if (hilitedElementsQueryCache.current.has(query)) {
48
- const hilitedIds = (_a = hilitedElementsQueryCache.current.get(query)) !== null && _a !== void 0 ? _a : [];
49
- viewerUtils_1.hideElements(hilitedIds);
50
- }
51
- else {
52
- try {
53
- const queryRowCount = await iModelConnection.queryRowCount(query);
54
- if (queryRowCount === 0) {
55
- itwinui_react_1.toaster.warning(`${viewGroup.groupName}'s query is valid but produced no results.`);
56
- }
57
- const hiliteIds = await viewerUtils_1.hideElementsByQuery(query, iModelConnection, false);
58
- hilitedElementsQueryCache.current.set(query, hiliteIds);
59
- }
60
- catch {
61
- itwinui_react_1.toaster.negative(`Could not hide/show ${viewGroup.groupName}. Query could not be resolved.`);
62
- }
35
+ if (!distinctQueries.has(viewGroup.query)) {
36
+ distinctQueries.add(viewGroup.query);
37
+ promises.push(exports.hideGroup(iModelConnection, viewGroup, hilitedElementsQueryCache));
63
38
  }
64
39
  }
40
+ await Promise.all(promises);
65
41
  };
66
42
  exports.hideGroups = hideGroups;
43
+ const hideGroup = async (iModelConnection, viewGroup, hilitedElementsQueryCache) => {
44
+ const result = await exports.getHiliteIdsAndKeysetFromGroup(iModelConnection, viewGroup, hilitedElementsQueryCache);
45
+ viewerUtils_1.hideElements(result.ids);
46
+ };
47
+ exports.hideGroup = hideGroup;
67
48
  const visualizeGroupColors = async (iModelConnection, groups, viewGroups, hiddenGroupsIds, hilitedElementsQueryCache, doEmphasizeElements = true) => {
68
49
  viewerUtils_1.clearEmphasizedOverriddenElements();
69
50
  let allIds = [];
@@ -71,7 +52,8 @@ const visualizeGroupColors = async (iModelConnection, groups, viewGroups, hidden
71
52
  const index = viewGroups.length > groups.length
72
53
  ? viewGroups.findIndex((g) => g.id === group.id)
73
54
  : groups.findIndex((g) => g.id === group.id);
74
- const hilitedIds = await exports.getHiliteIdsFromGroups(iModelConnection, [group], hilitedElementsQueryCache);
55
+ const result = await exports.getHiliteIdsAndKeysetFromGroup(iModelConnection, group, hilitedElementsQueryCache);
56
+ const hilitedIds = result.ids;
75
57
  viewerUtils_1.overrideElements(hilitedIds, exports.getGroupColor(index), core_common_1.FeatureOverrideType.ColorAndAlpha);
76
58
  doEmphasizeElements && viewerUtils_1.emphasizeElements(hilitedIds, undefined);
77
59
  if (!hiddenGroupsIds.includes(group.id)) {
@@ -81,4 +63,25 @@ const visualizeGroupColors = async (iModelConnection, groups, viewGroups, hidden
81
63
  await viewerUtils_1.zoomToElements(allIds);
82
64
  };
83
65
  exports.visualizeGroupColors = visualizeGroupColors;
66
+ const getHiliteIdsAndKeysetFromGroup = async (iModelConnection, group, hilitedElementsQueryCache) => {
67
+ var _a;
68
+ const query = group.query;
69
+ if (hilitedElementsQueryCache.current.has(query)) {
70
+ return (_a = hilitedElementsQueryCache.current.get(query)) !== null && _a !== void 0 ? _a : ({ keySet: new presentation_common_1.KeySet(), ids: [] });
71
+ }
72
+ try {
73
+ const queryRowCount = await iModelConnection.queryRowCount(query);
74
+ if (queryRowCount === 0) {
75
+ itwinui_react_1.toaster.warning(`${group.groupName}'s query is valid but produced no results.`);
76
+ }
77
+ const result = await viewerUtils_1.getHiliteIds(query, iModelConnection);
78
+ hilitedElementsQueryCache.current.set(query, result);
79
+ return result;
80
+ }
81
+ catch {
82
+ itwinui_react_1.toaster.negative(`Query could not be resolved.`);
83
+ return ({ keySet: new presentation_common_1.KeySet(), ids: [] });
84
+ }
85
+ };
86
+ exports.getHiliteIdsAndKeysetFromGroup = getHiliteIdsAndKeysetFromGroup;
84
87
  //# sourceMappingURL=groupsHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"groupsHelpers.js","sourceRoot":"","sources":["../../../../src/widget/components/groupsHelpers.ts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KAAK,MAAM,KAAK,IAAI,UAAU,EAAE;QAC9B,MAAM,KAAK,GACT,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;YAC/B,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC;YAChD,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,UAAU,GAAG,MAAM,8BAAsB,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,EAAE,yBAAyB,CAAC,CAAC;QACtG,8BAAgB,CACd,UAAU,EACV,qBAAa,CAAC,KAAK,CAAC,EACpB,iCAAmB,CAAC,aAAa,CAClC,CAAC;QACF,mBAAmB,IAAI,+BAAiB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAChE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;YACvC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;SACpC;KACF;IAED,MAAM,4BAAc,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AA5BW,QAAA,oBAAoB,wBA4B/B","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 { FeatureOverrideType } from \"@itwin/core-common\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { Group } from \"@itwin/insights-client\";\nimport { toaster } from \"@itwin/itwinui-react\";\nimport { clearEmphasizedOverriddenElements, emphasizeElements, getHiliteIds, hideElements, hideElementsByQuery, overrideElements, zoomToElements } from \"./viewerUtils\";\n\nconst goldenAngle = 180 * (3 - Math.sqrt(5));\n\nexport const getGroupColor = function (index: number) {\n return `hsl(${index * goldenAngle + 60}, 100%, 50%)`;\n};\n\nexport const getHiliteIdsFromGroups = async (\n iModelConnection: IModelConnection,\n groups: Group[],\n hilitedElementsQueryCache: React.MutableRefObject<Map<string, string[]>>\n) => {\n let allIds: string[] = [];\n for (const group of groups) {\n const query = group.query;\n let currentIds: string[] = [];\n if (hilitedElementsQueryCache.current.has(query)) {\n currentIds = hilitedElementsQueryCache.current.get(query) ?? [];\n } else {\n try {\n const queryRowCount = await iModelConnection.queryRowCount(query);\n if (queryRowCount === 0) {\n toaster.warning(\n `${group.groupName}'s query is valid but produced no results.`\n );\n }\n currentIds = await getHiliteIds(query, iModelConnection);\n hilitedElementsQueryCache.current.set(query, currentIds);\n } catch {\n toaster.negative(\n `Could not hide/show ${group.groupName}. Query could not be resolved.`\n );\n }\n }\n allIds = allIds.concat(currentIds);\n }\n return allIds;\n};\n\nexport const hideGroups = async (\n iModelConnection: IModelConnection,\n viewGroups: Group[],\n hilitedElementsQueryCache: React.MutableRefObject<Map<string, string[]>>\n) => {\n for (const viewGroup of viewGroups) {\n const query = viewGroup.query;\n if (hilitedElementsQueryCache.current.has(query)) {\n const hilitedIds = hilitedElementsQueryCache.current.get(query) ?? [];\n hideElements(hilitedIds);\n } else {\n try {\n const queryRowCount = await iModelConnection.queryRowCount(query);\n if (queryRowCount === 0) {\n toaster.warning(\n `${viewGroup.groupName}'s query is valid but produced no results.`\n );\n }\n const hiliteIds = await hideElementsByQuery(\n query,\n iModelConnection,\n false\n );\n hilitedElementsQueryCache.current.set(query, hiliteIds);\n } catch {\n toaster.negative(\n `Could not hide/show ${viewGroup.groupName}. Query could not be resolved.`\n );\n }\n }\n }\n};\n\nexport const visualizeGroupColors = async (\n iModelConnection: IModelConnection,\n groups: Group[],\n viewGroups: Group[],\n hiddenGroupsIds: string[],\n hilitedElementsQueryCache: React.MutableRefObject<Map<string, string[]>>,\n doEmphasizeElements: boolean = true\n) => {\n clearEmphasizedOverriddenElements();\n let allIds: string[] = [];\n for (const group of viewGroups) {\n const index =\n viewGroups.length > groups.length\n ? viewGroups.findIndex((g) => g.id === group.id)\n : groups.findIndex((g) => g.id === group.id);\n const hilitedIds = await getHiliteIdsFromGroups(iModelConnection, [group], hilitedElementsQueryCache);\n overrideElements(\n hilitedIds,\n getGroupColor(index),\n FeatureOverrideType.ColorAndAlpha,\n );\n doEmphasizeElements && emphasizeElements(hilitedIds, undefined);\n if (!hiddenGroupsIds.includes(group.id)) {\n allIds = allIds.concat(hilitedIds);\n }\n }\n\n await zoomToElements(allIds);\n};\n"]}
1
+ {"version":3,"file":"groupsHelpers.js","sourceRoot":"","sources":["../../../../src/widget/components/groupsHelpers.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,oDAAyD;AAGzD,wDAA+C;AAC/C,oEAAoD;AAEpD,+CAAmJ;AAEnJ,MAAM,WAAW,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtC,MAAM,aAAa,GAAG,UAAU,KAAa;IAClD,OAAO,OAAO,KAAK,GAAG,WAAW,GAAG,EAAE,cAAc,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEK,MAAM,sBAAsB,GAAG,KAAK,EACzC,gBAAkC,EAClC,MAAe,EACf,yBAA8E,EAC9E,EAAE;IACF,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAC1C,MAAM,QAAQ,GAAiC,EAAE,CAAC;IAClD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YACrC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,QAAQ,CAAC,IAAI,CAAC,sCAA8B,CAAC,gBAAgB,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAC,CAAC;SACn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E,MAAM,EAAE,IAAI,4BAAM,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;KAC5F;IACD,IAAI;QACF,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAClE,IAAI,aAAa,KAAK,CAAC,EAAE;YACvB,uBAAO,CAAC,OAAO,CACb,GAAG,KAAK,CAAC,SAAS,4CAA4C,CAC/D,CAAC;SACH;QACD,MAAM,MAAM,GAAG,MAAM,0BAAY,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QAC3D,yBAAyB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrD,OAAO,MAAM,CAAC;KACf;IAAC,MAAM;QACN,uBAAO,CAAC,QAAQ,CACd,8BAA8B,CAC/B,CAAC;QACF,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,4BAAM,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;KAC5C;AAEH,CAAC,CAAC;AA1BW,QAAA,8BAA8B,kCA0BzC","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 { FeatureOverrideType } from \"@itwin/core-common\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport type { Group } from \"@itwin/insights-client\";\nimport { toaster } from \"@itwin/itwinui-react\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport type { QueryCacheItem } from \"./context/GroupHilitedElementsContext\";\nimport { clearEmphasizedOverriddenElements, emphasizeElements, getHiliteIds, hideElements, overrideElements, zoomToElements } from \"./viewerUtils\";\n\nconst goldenAngle = 180 * (3 - Math.sqrt(5));\n\nexport const getGroupColor = function (index: number) {\n return `hsl(${index * goldenAngle + 60}, 100%, 50%)`;\n};\n\nexport const getHiliteIdsFromGroups = async (\n iModelConnection: IModelConnection,\n groups: Group[],\n hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>\n) => {\n const distinctQueries = new Set<string>();\n const promises: Promise<{ ids: string[] }>[] = [];\n for (const group of groups) {\n if (!distinctQueries.has(group.query)) {\n distinctQueries.add(group.query);\n promises.push(getHiliteIdsAndKeysetFromGroup(iModelConnection, group, hilitedElementsQueryCache));\n }\n }\n const results = await Promise.all(promises);\n const allIds = results.flatMap((result) => result.ids);\n return allIds;\n};\n\nexport const hideGroups = async (\n iModelConnection: IModelConnection,\n viewGroups: Group[],\n hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>\n) => {\n const distinctQueries = new Set<string>();\n const promises: Promise<void>[] = [];\n\n for (const viewGroup of viewGroups) {\n if (!distinctQueries.has(viewGroup.query)) {\n distinctQueries.add(viewGroup.query);\n promises.push(hideGroup(iModelConnection, viewGroup, hilitedElementsQueryCache));\n }\n }\n await Promise.all(promises);\n};\n\nexport const hideGroup = async (\n iModelConnection: IModelConnection,\n viewGroup: Group,\n hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>\n) => {\n const result = await getHiliteIdsAndKeysetFromGroup(iModelConnection, viewGroup, hilitedElementsQueryCache);\n hideElements(result.ids);\n};\n\nexport const visualizeGroupColors = async (\n iModelConnection: IModelConnection,\n groups: Group[],\n viewGroups: Group[],\n hiddenGroupsIds: string[],\n hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>,\n doEmphasizeElements: boolean = true\n) => {\n clearEmphasizedOverriddenElements();\n let allIds: string[] = [];\n for (const group of viewGroups) {\n const index =\n viewGroups.length > groups.length\n ? viewGroups.findIndex((g) => g.id === group.id)\n : groups.findIndex((g) => g.id === group.id);\n const result = await getHiliteIdsAndKeysetFromGroup(iModelConnection, group, hilitedElementsQueryCache);\n const hilitedIds = result.ids;\n overrideElements(\n hilitedIds,\n getGroupColor(index),\n FeatureOverrideType.ColorAndAlpha,\n );\n doEmphasizeElements && emphasizeElements(hilitedIds, undefined);\n if (!hiddenGroupsIds.includes(group.id)) {\n allIds = allIds.concat(hilitedIds);\n }\n }\n\n await zoomToElements(allIds);\n};\n\nexport const getHiliteIdsAndKeysetFromGroup = async (\n iModelConnection: IModelConnection,\n group: Group,\n hilitedElementsQueryCache: React.MutableRefObject<Map<string, QueryCacheItem>>\n) => {\n const query = group.query;\n if (hilitedElementsQueryCache.current.has(query)) {\n return hilitedElementsQueryCache.current.get(query) ?? ({ keySet: new KeySet(), ids: [] });\n }\n try {\n const queryRowCount = await iModelConnection.queryRowCount(query);\n if (queryRowCount === 0) {\n toaster.warning(\n `${group.groupName}'s query is valid but produced no results.`\n );\n }\n const result = await getHiliteIds(query, iModelConnection);\n hilitedElementsQueryCache.current.set(query, result);\n return result;\n } catch {\n toaster.negative(\n `Query could not be resolved.`\n );\n return ({ keySet: new KeySet(), ids: [] });\n }\n\n};\n"]}