@itwin/grouping-mapping-widget 0.22.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/WidgetShell/GroupingMapping.js +5 -1
- package/lib/cjs/WidgetShell/GroupingMapping.js.map +1 -1
- package/lib/cjs/WidgetShell/GroupingMappingContent.js +5 -1
- package/lib/cjs/WidgetShell/GroupingMappingContent.js.map +1 -1
- package/lib/cjs/common/hooks/useIsMounted.d.ts +2 -0
- package/lib/cjs/common/hooks/useIsMounted.js +20 -0
- package/lib/cjs/common/hooks/useIsMounted.js.map +1 -0
- package/lib/cjs/common/utils.d.ts +1 -0
- package/lib/cjs/common/utils.js +13 -1
- package/lib/cjs/common/utils.js.map +1 -1
- package/lib/cjs/components/Constants.d.ts +4 -0
- package/lib/cjs/components/Constants.js +13 -0
- package/lib/cjs/components/Constants.js.map +1 -0
- package/lib/cjs/components/GroupingMappingContext.d.ts +5 -0
- package/lib/cjs/components/GroupingMappingContext.js +31 -19
- package/lib/cjs/components/GroupingMappingContext.js.map +1 -1
- package/lib/cjs/components/Groups/Editing/GroupAction.js +61 -57
- package/lib/cjs/components/Groups/Editing/GroupAction.js.map +1 -1
- package/lib/cjs/components/Groups/Editing/GroupDetailsActionPanel.d.ts +1 -1
- package/lib/cjs/components/Groups/Editing/GroupDetailsActionPanel.js.map +1 -1
- package/lib/cjs/components/Groups/GroupItem.js +1 -1
- package/lib/cjs/components/Groups/GroupItem.js.map +1 -1
- package/lib/cjs/components/Groups/GroupMenuActions.js +5 -1
- package/lib/cjs/components/Groups/GroupMenuActions.js.map +1 -1
- package/lib/cjs/components/Groups/Groups.d.ts +3 -2
- package/lib/cjs/components/Groups/Groups.js +8 -4
- package/lib/cjs/components/Groups/Groups.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsShowHideButtons.d.ts +2 -2
- package/lib/cjs/components/Groups/GroupsShowHideButtons.js +8 -4
- package/lib/cjs/components/Groups/GroupsShowHideButtons.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsView.js +1 -1
- package/lib/cjs/components/Groups/GroupsView.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualization.d.ts +1 -1
- package/lib/cjs/components/Groups/GroupsVisualization.js +112 -66
- package/lib/cjs/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualizationActions.d.ts +6 -4
- package/lib/cjs/components/Groups/GroupsVisualizationActions.js +8 -6
- package/lib/cjs/components/Groups/GroupsVisualizationActions.js.map +1 -1
- package/lib/cjs/components/Groups/GroupsVisualizationActions.scss +1 -0
- package/lib/cjs/components/Groups/groupsHelpers.d.ts +20 -7
- package/lib/cjs/components/Groups/groupsHelpers.js +15 -71
- package/lib/cjs/components/Groups/groupsHelpers.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useGroupsOperations.d.ts +1 -5
- package/lib/cjs/components/Groups/hooks/useGroupsOperations.js +17 -31
- package/lib/cjs/components/Groups/hooks/useGroupsOperations.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.d.ts +32 -0
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.js +31 -0
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -0
- package/lib/cjs/components/Groups/hooks/useVisualization.js +4 -4
- package/lib/cjs/components/Groups/hooks/useVisualization.js.map +1 -1
- package/lib/cjs/components/Mappings/Editing/MappingAction.js +5 -1
- package/lib/cjs/components/Mappings/Editing/MappingAction.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionLogCustomFilter.js +5 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionLogCustomFilter.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js +5 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/ConfirmMappingsImport.js +5 -1
- package/lib/cjs/components/Mappings/Import/ConfirmMappingsImport.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/MappingImportWizardModal.js +5 -1
- package/lib/cjs/components/Mappings/Import/MappingImportWizardModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/SelectIModel.js +6 -3
- package/lib/cjs/components/Mappings/Import/SelectIModel.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/SelectITwin.js +5 -1
- package/lib/cjs/components/Mappings/Import/SelectITwin.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/SelectMappings.js +5 -1
- package/lib/cjs/components/Mappings/Import/SelectMappings.js.map +1 -1
- package/lib/cjs/components/Mappings/MappingsView.js +5 -1
- package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +5 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +16 -21
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +5 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js +5 -1
- package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js +5 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js +5 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/components/Properties/GroupColorToggle.js +13 -10
- package/lib/cjs/components/Properties/GroupColorToggle.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js +7 -3
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js +5 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/SortableHorizontalTile.js +5 -1
- package/lib/cjs/components/Properties/GroupProperties/SortableHorizontalTile.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyAction.js +5 -1
- package/lib/cjs/components/Properties/PropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyMenu.js +5 -1
- package/lib/cjs/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyMenuWithVisualization.js +5 -1
- package/lib/cjs/components/Properties/PropertyMenuWithVisualization.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyTable.js +5 -1
- package/lib/cjs/components/Properties/PropertyTable.js.map +1 -1
- package/lib/cjs/components/SharedComponents/ActionPanel.js +5 -1
- package/lib/cjs/components/SharedComponents/ActionPanel.js.map +1 -1
- package/lib/cjs/components/SharedComponents/DeleteModal.js +5 -1
- package/lib/cjs/components/SharedComponents/DeleteModal.js.map +1 -1
- package/lib/cjs/components/context/GroupHilitedElementsContext.d.ts +9 -16
- package/lib/cjs/components/context/GroupHilitedElementsContext.js +13 -10
- package/lib/cjs/components/context/GroupHilitedElementsContext.js.map +1 -1
- package/lib/cjs/components/context/GroupingApiConfigContext.js +5 -1
- package/lib/cjs/components/context/GroupingApiConfigContext.js.map +1 -1
- package/lib/cjs/components/context/PropertiesContext.js +5 -1
- package/lib/cjs/components/context/PropertiesContext.js.map +1 -1
- package/lib/cjs/components/context/PropertyGridWrapperContext.js +5 -1
- package/lib/cjs/components/context/PropertyGridWrapperContext.js.map +1 -1
- package/lib/cjs/components/customUI/GroupQueryBuilderCustomUI.js +5 -1
- package/lib/cjs/components/customUI/GroupQueryBuilderCustomUI.js.map +1 -1
- package/lib/cjs/grouping-mapping-widget.js +5 -1
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/cjs/test/GroupingMappingCustomUI.test.js +5 -1
- package/lib/cjs/test/GroupingMappingCustomUI.test.js.map +1 -1
- package/lib/cjs/test/MockFactory.js +5 -1
- package/lib/cjs/test/MockFactory.js.map +1 -1
- package/lib/cjs/test/PropertyFieldsHelpers.d.ts +4 -20
- package/lib/cjs/test/test-utils.js +13 -1
- package/lib/cjs/test/test-utils.js.map +1 -1
- package/lib/esm/common/hooks/useIsMounted.d.ts +2 -0
- package/lib/esm/common/hooks/useIsMounted.js +16 -0
- package/lib/esm/common/hooks/useIsMounted.js.map +1 -0
- package/lib/esm/common/utils.d.ts +1 -0
- package/lib/esm/common/utils.js +11 -0
- package/lib/esm/common/utils.js.map +1 -1
- package/lib/esm/components/Constants.d.ts +4 -0
- package/lib/esm/components/Constants.js +10 -0
- package/lib/esm/components/Constants.js.map +1 -0
- package/lib/esm/components/GroupingMappingContext.d.ts +5 -0
- package/lib/esm/components/GroupingMappingContext.js +27 -19
- package/lib/esm/components/GroupingMappingContext.js.map +1 -1
- package/lib/esm/components/Groups/Editing/GroupAction.js +57 -57
- package/lib/esm/components/Groups/Editing/GroupAction.js.map +1 -1
- package/lib/esm/components/Groups/Editing/GroupDetailsActionPanel.d.ts +1 -1
- package/lib/esm/components/Groups/Editing/GroupDetailsActionPanel.js.map +1 -1
- package/lib/esm/components/Groups/GroupItem.js +1 -1
- package/lib/esm/components/Groups/GroupItem.js.map +1 -1
- package/lib/esm/components/Groups/Groups.d.ts +3 -2
- package/lib/esm/components/Groups/Groups.js +3 -3
- package/lib/esm/components/Groups/Groups.js.map +1 -1
- package/lib/esm/components/Groups/GroupsShowHideButtons.d.ts +2 -2
- package/lib/esm/components/Groups/GroupsShowHideButtons.js +3 -3
- package/lib/esm/components/Groups/GroupsShowHideButtons.js.map +1 -1
- package/lib/esm/components/Groups/GroupsView.js +1 -1
- package/lib/esm/components/Groups/GroupsView.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualization.d.ts +1 -1
- package/lib/esm/components/Groups/GroupsVisualization.js +109 -67
- package/lib/esm/components/Groups/GroupsVisualization.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualizationActions.d.ts +6 -4
- package/lib/esm/components/Groups/GroupsVisualizationActions.js +9 -7
- package/lib/esm/components/Groups/GroupsVisualizationActions.js.map +1 -1
- package/lib/esm/components/Groups/GroupsVisualizationActions.scss +1 -0
- package/lib/esm/components/Groups/groupsHelpers.d.ts +20 -7
- package/lib/esm/components/Groups/groupsHelpers.js +13 -68
- package/lib/esm/components/Groups/groupsHelpers.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useGroupsOperations.d.ts +1 -5
- package/lib/esm/components/Groups/hooks/useGroupsOperations.js +18 -32
- package/lib/esm/components/Groups/hooks/useGroupsOperations.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.d.ts +32 -0
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.js +25 -0
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.js.map +1 -0
- package/lib/esm/components/Groups/hooks/useVisualization.js +4 -4
- package/lib/esm/components/Groups/hooks/useVisualization.js.map +1 -1
- package/lib/esm/components/Mappings/Import/SelectIModel.js +1 -2
- package/lib/esm/components/Mappings/Import/SelectIModel.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +13 -22
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/esm/components/Properties/GroupColorToggle.js +9 -10
- package/lib/esm/components/Properties/GroupColorToggle.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js +3 -3
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/esm/components/context/GroupHilitedElementsContext.d.ts +9 -16
- package/lib/esm/components/context/GroupHilitedElementsContext.js +8 -9
- package/lib/esm/components/context/GroupHilitedElementsContext.js.map +1 -1
- package/lib/esm/test/PropertyFieldsHelpers.d.ts +4 -20
- package/lib/esm/test/test-utils.js +8 -0
- package/lib/esm/test/test-utils.js.map +1 -1
- package/package.json +27 -28
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingMapping.js","sourceRoot":"","sources":["../../../src/WidgetShell/GroupingMapping.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GroupingMapping.js","sourceRoot":"","sources":["../../../src/WidgetShell/GroupingMapping.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,+CAA8D;AAE9D,iFAA8E;AAC9E,kCAAgC;AAChC,oDAA+D;AAK/D,4FAA6F;AAC7F,oEAEoC;AACpC,qEAAkE;AAClE,mEAAgE;AAChE,gFAA6E;AAI7E,IAAY,SAUX;AAVD,WAAY,SAAS;IACnB,iDAAQ,CAAA;IACR,6DAAc,CAAA;IACd,6CAAM,CAAA;IACN,uDAAW,CAAA;IACX,yEAAoB,CAAA;IACpB,qDAAU,CAAA;IACV,6DAAc,CAAA;IACd,iFAAwB,CAAA;IACxB,+FAA+B,CAAA;AACjC,CAAC,EAVW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAUpB;AAkBD,MAAM,eAAe,GAAG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C,SAAS;gBACtB,mBAAmB,EAAE,EAAE,GAAG,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE;aAC7D,CAAC,CAAC;SACN;QACD,2DAA2D;QAC3D,GAAG,KAAK,CAAC,SAAS,IAAI,qCAAiB;KACxC,EACD,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAC9B,CAAC;IAEF,OAAO,CACL,8BAAC,+CAAsB,IACrB,QAAQ,EAAE,QAAQ,KACd,KAAK,EACT,SAAS,EAAE,gBAAgB;QAE3B,uCAAK,SAAS,EAAC,6BAA6B;YAC1C,8BAAC,6CAAqB,IACpB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,GAC1B;YACF,8BAAC,+CAAsB,IACrB,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACd,CACE,CACiB,CAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,eAAe,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 CalculatedProperty,\n CustomCalculation,\n Group,\n GroupProperty,\n Mapping,\n} from \"@itwin/insights-client\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport type { GroupingMappingContextProps } from \"../components/GroupingMappingContext\";\nimport { GroupingMappingContext } from \"../components/GroupingMappingContext\";\nimport \"./GroupingMapping.scss\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport type {\n ContextCustomUI,\n GroupingMappingCustomUI,\n} from \"../components/customUI/GroupingMappingCustomUI\";\nimport { GroupingMappingCustomUIType } from \"../components/customUI/GroupingMappingCustomUI\";\nimport {\n SvgList,\n} from \"@itwin/itwinui-icons-react\";\nimport { GroupingMappingContent } from \"./GroupingMappingContent\";\nimport { GroupingMappingHeader } from \"./GroupingMappingHeader\";\nimport { defaultGroupingUI } from \"../components/customUI/DefaultGroupingUI\";\n\nexport type GroupingMappingProps = Omit<GroupingMappingContextProps, \"iModelId\">;\n\nexport enum RouteStep {\n Mappings,\n MappingsAction,\n Groups,\n GroupAction,\n GroupContextCustomUI,\n Properties,\n PropertyAction,\n CalculatedPropertyAction,\n CustomCalculationPropertyAction,\n}\n\nexport interface Route {\n step: RouteStep;\n title: string;\n groupingRouteFields: GroupingRouteFields;\n}\nexport interface GroupingRouteFields {\n mapping?: Mapping;\n group?: Group;\n property?: GroupProperty;\n calculatedProperty?: CalculatedProperty;\n customCalculation?: CustomCalculation;\n // Optional prop but cannot be declared undefined.\n groupContextCustomUI?: Exclude<ContextCustomUI[\"uiComponent\"], undefined>;\n queryGenerationType?: string;\n}\n\nconst GroupingMapping = (props: GroupingMappingProps) => {\n const [routingHistory, setRoutingHistory] = useState<Route[]>([\n { step: RouteStep.Mappings, title: \"Mapping\", groupingRouteFields: {} },\n ]);\n const currentRoute = routingHistory[routingHistory.length - 1];\n const iModelId = useActiveIModelConnection()?.iModelId ?? \"\";\n const navigateTo = useCallback((toRoute: (prev: Route | undefined) => Route) => {\n setRoutingHistory((r) => [...r, toRoute(r[r.length - 1])]);\n }, []);\n\n const goBack = useCallback(() => {\n const updatedRouting = [...routingHistory];\n updatedRouting.pop();\n setRoutingHistory(updatedRouting);\n }, [routingHistory]);\n\n const injectedCustomUI = useMemo<GroupingMappingCustomUI[]>(\n () => [\n {\n name: \"Properties\",\n displayLabel: \"Properties\",\n type: GroupingMappingCustomUIType.Context,\n icon: <SvgList />,\n onClick: (group) =>\n navigateTo((prev) => ({\n step: RouteStep.Properties,\n title: group.groupName,\n groupingRouteFields: { ...prev?.groupingRouteFields, group },\n })),\n },\n // No group UI's provided means the widget provides its own\n ...props.customUIs ?? defaultGroupingUI,\n ],\n [props.customUIs, navigateTo]\n );\n\n return (\n <GroupingMappingContext\n iModelId={iModelId}\n {...props}\n customUIs={injectedCustomUI}\n >\n <div className=\"gmw-group-mapping-container\">\n <GroupingMappingHeader\n goBack={goBack}\n currentRoute={currentRoute}\n />\n <GroupingMappingContent\n routingHistory={routingHistory}\n navigateTo={navigateTo}\n goBack={goBack}\n />\n </div>\n </GroupingMappingContext>\n );\n};\n\nexport default GroupingMapping;\n"]}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingMappingContent.js","sourceRoot":"","sources":["../../../src/WidgetShell/GroupingMappingContent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GroupingMappingContent.js","sourceRoot":"","sources":["../../../src/WidgetShell/GroupingMappingContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAAyC;AACzC,mGAAmG;AACnG,+EAA+E;AAE/E,0EAAuE;AACvE,uDAAiD;AAE1C,MAAM,sBAAsB,GAAG,CAAC,EACrC,cAAc,EACd,UAAU,EACV,MAAM,GAKP,EAAE,EAAE;IACH,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,GAAG,IAAA,4DAA8B,GAAE,CAAC;IACnF,MAAM,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,GAAG,IAAA,wCAAoB,GAAE,CAAC;IAC7E,MAAM,YAAY,GAAG,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE/D,gDAAgD;IAChD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YAC/B,iBAAiB,CAAC,KAAK,CAAC,CAAC;YACzB,kBAAkB,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;YAC9B,IAAA,sBAAQ,GAAE,CAAC;YACX,2CAA2C;SAC5C;aAAM,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;YACtC,sBAAsB,CAAC,KAAK,CAAC,CAAC;SAC/B;IACH,CAAC,EAAE,CAAC,cAAc,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAEpF,OAAO,CACL,8BAAC,6CAAqB,IACpB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACd,CACH,CAAC;AACJ,CAAC,CAAC;AAhCW,QAAA,sBAAsB,0BAgCjC","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, { useEffect } from \"react\";\nimport { useGroupHilitedElementsContext } from \"../components/context/GroupHilitedElementsContext\";\nimport { usePropertiesContext } from \"../components/context/PropertiesContext\";\nimport type { Route } from \"./GroupingMapping\";\nimport { GroupingMappingRouter } from \"./Router/GroupingMappingRouter\";\nimport { clearAll } from \"../common/viewerUtils\";\n\nexport const GroupingMappingContent = ({\n routingHistory,\n navigateTo,\n goBack,\n}: {\n routingHistory: Route[];\n navigateTo: (toRoute: (prev: Route | undefined) => Route) => void;\n goBack: () => void;\n}) => {\n const { setShowGroupColor, setHiddenGroupsIds } = useGroupHilitedElementsContext();\n const { setShowGroupColor: setPropertiesShowGroup } = usePropertiesContext();\n const currentRoute = routingHistory[routingHistory.length - 1];\n\n // Clean up group visualization when in mappings\n useEffect(() => {\n if (routingHistory.length === 1) {\n setShowGroupColor(false);\n setHiddenGroupsIds(new Set());\n clearAll();\n // Turn off visualiztion in properties menu\n } else if (routingHistory.length === 2) {\n setPropertiesShowGroup(false);\n }\n }, [routingHistory, setHiddenGroupsIds, setPropertiesShowGroup, setShowGroupColor]);\n\n return (\n <GroupingMappingRouter\n currentRoute={currentRoute}\n navigateTo={navigateTo}\n goBack={goBack}\n />\n );\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsMounted = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const useIsMounted = () => {
|
|
10
|
+
const isMountedRef = (0, react_1.useRef)(true);
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
return () => {
|
|
13
|
+
isMountedRef.current = false;
|
|
14
|
+
};
|
|
15
|
+
}, []);
|
|
16
|
+
const isMounted = (0, react_1.useCallback)(() => isMountedRef.current, []);
|
|
17
|
+
return isMounted;
|
|
18
|
+
};
|
|
19
|
+
exports.useIsMounted = useIsMounted;
|
|
20
|
+
//# sourceMappingURL=useIsMounted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsMounted.js","sourceRoot":"","sources":["../../../../src/common/hooks/useIsMounted.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,iCAAuD;AAEhD,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,YAAY,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC;IAElC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,GAAG,KAAK,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAE9D,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAZW,QAAA,YAAY,gBAYvB","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 { useCallback, useEffect, useRef } from \"react\";\n\nexport const useIsMounted = () => {\n const isMountedRef = useRef(true);\n\n useEffect(() => {\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n\n const isMounted = useCallback(() => isMountedRef.current, []);\n\n return isMounted;\n};\n"]}
|
|
@@ -8,4 +8,5 @@ export declare const getErrorMessage: (errorStatus: number) => string;
|
|
|
8
8
|
export declare const handleError: (errorStatus: number) => void;
|
|
9
9
|
export declare const handleInputChange: <T>(e: React.ChangeEvent<HTMLInputElement>, values: T, setValues: (newValues: T) => void) => void;
|
|
10
10
|
export declare const enableExperimentalFeatures: (iModelConnection: IModelConnection) => Promise<void>;
|
|
11
|
+
export declare const getLocalizedStringPresentation: (input: string) => string;
|
|
11
12
|
//# sourceMappingURL=utils.d.ts.map
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enableExperimentalFeatures = exports.handleInputChange = exports.handleError = exports.getErrorMessage = exports.fetchIdsFromQuery = exports.debounce = void 0;
|
|
3
|
+
exports.getLocalizedStringPresentation = exports.enableExperimentalFeatures = exports.handleInputChange = exports.handleError = exports.getErrorMessage = exports.fetchIdsFromQuery = exports.debounce = 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
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
9
10
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
10
11
|
function debounce(f, delay) {
|
|
11
12
|
let timer;
|
|
@@ -86,4 +87,15 @@ const enableExperimentalFeatures = async (iModelConnection) => {
|
|
|
86
87
|
await reader.step();
|
|
87
88
|
};
|
|
88
89
|
exports.enableExperimentalFeatures = enableExperimentalFeatures;
|
|
90
|
+
const getLocalizedStringPresentation = (input) => {
|
|
91
|
+
// https://www.itwinjs.org/presentation/advanced/localization/
|
|
92
|
+
// Check if the string starts and ends with "@"
|
|
93
|
+
if (input.startsWith("@") && input.endsWith("@")) {
|
|
94
|
+
// Remove the leading and trailing "@" from the string
|
|
95
|
+
const trimmedString = input.substring(1, input.length - 1);
|
|
96
|
+
return core_frontend_1.IModelApp.localization.getLocalizedString(trimmedString);
|
|
97
|
+
}
|
|
98
|
+
return input;
|
|
99
|
+
};
|
|
100
|
+
exports.getLocalizedStringPresentation = getLocalizedStringPresentation;
|
|
89
101
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,oDAAoD;AAEpD,wDAA+C;AAM/C,SAAgB,QAAQ,CAAqC,CAAI,EAAE,KAAa;IAC9E,IAAI,KAAyB,CAAC;IAC9B,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,KAAK,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACpC,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE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------------------------\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 { QueryRowFormat } from \"@itwin/core-common\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { toaster } from \"@itwin/itwinui-react\";\n\nexport type CreateTypeFromInterface<Interface> = {\n [Property in keyof Interface]: Interface[Property];\n};\n\nexport function debounce<F extends (...args: any[]) => void>(f: F, delay: number) {\n let timer: number | undefined;\n return (...args: any[]) => {\n timer && window.clearTimeout(timer);\n timer = window.setTimeout(f, delay, ...args);\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 getErrorMessage = (errorStatus: number): string => {\n switch (errorStatus) {\n case 401:\n return \"You are unauthorized to do this operation.\";\n case 403:\n return \"You don't have permission to access the requested resource.\";\n case 404:\n return \"The requested resource was not found.\";\n case 409:\n return \"This property name is already being used.\";\n case 422:\n return \"Unable to process the request.\";\n case 429:\n return \"Too many requests.\";\n case 500:\n return \"Internal server error.\";\n case 502:\n return \"Bad gateway.\";\n case 503:\n return \"Service unavailable.\";\n default:\n return \"Something went wrong!\";\n }\n};\n\nexport const handleError = (errorStatus: number) => {\n const baseErrorMessage = \"Error!\";\n const specificErrorMessage = getErrorMessage(errorStatus);\n const fullErrorMessage = `${baseErrorMessage} ${specificErrorMessage}`;\n\n toaster.negative(fullErrorMessage);\n};\n\nexport const handleInputChange = <T,>(\n e: React.ChangeEvent<HTMLInputElement>,\n values: T,\n setValues: (newValues: T) => void,\n) => {\n const { name, value } = e.target;\n\n setValues({\n ...values,\n [name]: value,\n });\n};\n\nexport const enableExperimentalFeatures = async (iModelConnection: IModelConnection) => {\n const reader = iModelConnection.createQueryReader(\"PRAGMA experimental_features_enabled=true\");\n await reader.step();\n};\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,oDAAoD;AAEpD,wDAAiD;AACjD,wDAA+C;AAM/C,SAAgB,QAAQ,CAAqC,CAAI,EAAE,KAAa;IAC9E,IAAI,KAAyB,CAAC;IAC9B,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,KAAK,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACpC,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC;AAND,4BAMC;AAEM,MAAM,iBAAiB,GAAG,KAAK,EACpC,KAAa,EACb,gBAAkC,EAClC,EAAE;IACF,IAAI,KAAK,KAAK,EAAE,EAAE;QAChB,OAAO,EAAE,CAAC;KACX;IACD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE;QAC3D,SAAS,EAAE,4BAAc,CAAC,kBAAkB;KAC7C,CAAC,CAAC;IACH,OAAO,IAAI,EAAE;QACX,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;QACjD,IAAI,IAAI,EAAE;YACR,MAAM;SACP;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACrC,GAAG,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QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACrC,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB;AAEK,MAAM,iBAAiB,GAAG,CAC/B,CAAsC,EACtC,MAAS,EACT,SAAiC,EACjC,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;IAEjC,SAAS,CAAC;QACR,GAAG,MAAM;QACT,CAAC,IAAI,CAAC,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC,CAAC;AAXW,QAAA,iBAAiB,qBAW5B;AAEK,MAAM,0BAA0B,GAAG,KAAK,EAAE,gBAAkC,EAAE,EAAE;IACrF,MAAM,MAAM,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,2CAA2C,CAAC,CAAC;IAC/F,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC,CAAC;AAHW,QAAA,0BAA0B,8BAGrC;AAEK,MAAM,8BAA8B,GAAG,CAAC,KAAa,EAAU,EAAE;IACtE,8DAA8D;IAC9D,+CAA+C;IAC/C,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAChD,sDAAsD;QACtD,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE3D,OAAO,yBAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;KACjE;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAXW,QAAA,8BAA8B,kCAWzC","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 { QueryRowFormat } from \"@itwin/core-common\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { toaster } from \"@itwin/itwinui-react\";\n\nexport type CreateTypeFromInterface<Interface> = {\n [Property in keyof Interface]: Interface[Property];\n};\n\nexport function debounce<F extends (...args: any[]) => void>(f: F, delay: number) {\n let timer: number | undefined;\n return (...args: any[]) => {\n timer && window.clearTimeout(timer);\n timer = window.setTimeout(f, delay, ...args);\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 getErrorMessage = (errorStatus: number): string => {\n switch (errorStatus) {\n case 401:\n return \"You are unauthorized to do this operation.\";\n case 403:\n return \"You don't have permission to access the requested resource.\";\n case 404:\n return \"The requested resource was not found.\";\n case 409:\n return \"This property name is already being used.\";\n case 422:\n return \"Unable to process the request.\";\n case 429:\n return \"Too many requests.\";\n case 500:\n return \"Internal server error.\";\n case 502:\n return \"Bad gateway.\";\n case 503:\n return \"Service unavailable.\";\n default:\n return \"Something went wrong!\";\n }\n};\n\nexport const handleError = (errorStatus: number) => {\n const baseErrorMessage = \"Error!\";\n const specificErrorMessage = getErrorMessage(errorStatus);\n const fullErrorMessage = `${baseErrorMessage} ${specificErrorMessage}`;\n\n toaster.negative(fullErrorMessage);\n};\n\nexport const handleInputChange = <T,>(\n e: React.ChangeEvent<HTMLInputElement>,\n values: T,\n setValues: (newValues: T) => void,\n) => {\n const { name, value } = e.target;\n\n setValues({\n ...values,\n [name]: value,\n });\n};\n\nexport const enableExperimentalFeatures = async (iModelConnection: IModelConnection) => {\n const reader = iModelConnection.createQueryReader(\"PRAGMA experimental_features_enabled=true\");\n await reader.step();\n};\n\nexport const getLocalizedStringPresentation = (input: string): string => {\n // https://www.itwinjs.org/presentation/advanced/localization/\n // Check if the string starts and ends with \"@\"\n if (input.startsWith(\"@\") && input.endsWith(\"@\")) {\n // Remove the leading and trailing \"@\" from the string\n const trimmedString = input.substring(1, input.length - 1);\n\n return IModelApp.localization.getLocalizedString(trimmedString);\n }\n\n return input;\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.TErrCodes = void 0;
|
|
8
|
+
// Types of error codes that get handled by query cache error handler.
|
|
9
|
+
var TErrCodes;
|
|
10
|
+
(function (TErrCodes) {
|
|
11
|
+
TErrCodes[TErrCodes["QUERY_HILITE_FETCH_FAILED"] = 0] = "QUERY_HILITE_FETCH_FAILED"; // Error code when failing to fetch hilite ids for a group.
|
|
12
|
+
})(TErrCodes = exports.TErrCodes || (exports.TErrCodes = {}));
|
|
13
|
+
//# sourceMappingURL=Constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../src/components/Constants.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sEAAsE;AACtE,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,mFAAyB,CAAA,CAAC,2DAA2D;AACvF,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n// Types of error codes that get handled by query cache error handler.\nexport enum TErrCodes {\n QUERY_HILITE_FETCH_FAILED // Error code when failing to fetch hilite ids for a group.\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import type { IModelConnection } from "@itwin/core-frontend";
|
|
|
3
3
|
import type { ClientPrefix, GetAccessTokenFn } from "./context/GroupingApiConfigContext";
|
|
4
4
|
import type { IExtractionClient, IMappingsClient } from "@itwin/insights-client";
|
|
5
5
|
import type { GroupingMappingCustomUI } from "./customUI/GroupingMappingCustomUI";
|
|
6
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
6
7
|
export interface GroupingMappingContextProps {
|
|
7
8
|
/**
|
|
8
9
|
* Custom callback to retrieve access token.
|
|
@@ -33,6 +34,10 @@ export interface GroupingMappingContextProps {
|
|
|
33
34
|
* A custom iModelConnection to use instead of the active iModelConnection from UiFramework.
|
|
34
35
|
*/
|
|
35
36
|
iModelConnection?: IModelConnection;
|
|
37
|
+
/**
|
|
38
|
+
* A custom QueryClient. If not provided, a default QueryClient will be used.
|
|
39
|
+
*/
|
|
40
|
+
queryClient?: QueryClient;
|
|
36
41
|
children?: React.ReactNode;
|
|
37
42
|
}
|
|
38
43
|
export declare const GroupingMappingContext: (props: GroupingMappingContextProps) => JSX.Element;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -36,8 +40,9 @@ const ExtractionClientContext_1 = require("./context/ExtractionClientContext");
|
|
|
36
40
|
const react_query_1 = require("@tanstack/react-query");
|
|
37
41
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
38
42
|
const utils_1 = require("../common/utils");
|
|
43
|
+
const Constants_1 = require("./Constants");
|
|
39
44
|
const authorizationClientGetAccessToken = async () => (await core_frontend_1.IModelApp.authorizationClient?.getAccessToken()) ?? "";
|
|
40
|
-
const
|
|
45
|
+
const defaultQueryClient = new react_query_1.QueryClient({
|
|
41
46
|
defaultOptions: {
|
|
42
47
|
queries: {
|
|
43
48
|
refetchOnWindowFocus: false,
|
|
@@ -45,11 +50,18 @@ const queryClient = new react_query_1.QueryClient({
|
|
|
45
50
|
},
|
|
46
51
|
},
|
|
47
52
|
queryCache: new react_query_1.QueryCache({
|
|
48
|
-
onError: (error) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
onError: (error, query) => {
|
|
54
|
+
switch (query.meta?.errorCode) {
|
|
55
|
+
case Constants_1.TErrCodes.QUERY_HILITE_FETCH_FAILED:
|
|
56
|
+
itwinui_react_1.toaster.negative(query.meta?.message);
|
|
57
|
+
break;
|
|
58
|
+
default: {
|
|
59
|
+
if (error.status)
|
|
60
|
+
itwinui_react_1.toaster.negative((0, utils_1.getErrorMessage)(error.status));
|
|
61
|
+
else
|
|
62
|
+
itwinui_react_1.toaster.negative("An error occurred while fetching data.");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
53
65
|
},
|
|
54
66
|
}),
|
|
55
67
|
mutationCache: new react_query_1.MutationCache({
|
|
@@ -73,7 +85,6 @@ const GroupingMappingContext = (props) => {
|
|
|
73
85
|
iModelId: props.iModelId,
|
|
74
86
|
prefix: props.prefix,
|
|
75
87
|
});
|
|
76
|
-
const hilitedElementsQueryCache = (0, react_1.useRef)(new Map());
|
|
77
88
|
const [hiddenGroupsIds, setHiddenGroupsIds] = (0, react_1.useState)(new Set());
|
|
78
89
|
const [showGroupColor, setShowGroupColor] = (0, react_1.useState)(false);
|
|
79
90
|
const [propertiesShowGroup, setPropertiesShowGroup] = (0, react_1.useState)(false);
|
|
@@ -82,11 +93,15 @@ const GroupingMappingContext = (props) => {
|
|
|
82
93
|
const [calculatedProperties, setCalculatedProperties] = (0, react_1.useState)([]);
|
|
83
94
|
const [customCalculationProperties, setCustomCalculationProperties] = (0, react_1.useState)([]);
|
|
84
95
|
const [numberOfVisualizedGroups, setNumberOfVisualizedGroups] = (0, react_1.useState)(0);
|
|
85
|
-
const [overlappedElementsInfo, setOverlappedElementsInfo] = (0, react_1.useState)(new Map());
|
|
86
|
-
const [groupElementsInfo, setGroupElementsInfo] = (0, react_1.useState)(new Map());
|
|
87
96
|
const [isOverlappedColored, setIsOverlappedColored] = (0, react_1.useState)(false);
|
|
88
97
|
const [currentHilitedGroups, setCurrentHilitedGroups] = (0, react_1.useState)(1);
|
|
89
|
-
const [
|
|
98
|
+
const [isVisualizationsEnabled, setIsVisualizationsEnabled] = (0, react_1.useState)(false);
|
|
99
|
+
const [overlappedElementsMetadata, setOverlappedElementsMetadata] = (0, react_1.useState)({
|
|
100
|
+
overlappedElementsInfo: new Map(),
|
|
101
|
+
groupElementsInfo: new Map(),
|
|
102
|
+
overlappedElementGroupPairs: [],
|
|
103
|
+
});
|
|
104
|
+
const queryClient = props.queryClient ?? defaultQueryClient;
|
|
90
105
|
(0, react_1.useEffect)(() => {
|
|
91
106
|
setApiConfig(() => ({
|
|
92
107
|
prefix: props.prefix,
|
|
@@ -109,22 +124,19 @@ const GroupingMappingContext = (props) => {
|
|
|
109
124
|
setShowGroupColor,
|
|
110
125
|
hiddenGroupsIds,
|
|
111
126
|
setHiddenGroupsIds,
|
|
112
|
-
hilitedElementsQueryCache,
|
|
113
127
|
groups,
|
|
114
128
|
setGroups,
|
|
115
129
|
numberOfVisualizedGroups,
|
|
116
130
|
setNumberOfVisualizedGroups,
|
|
117
|
-
overlappedElementsInfo,
|
|
118
|
-
setOverlappedElementsInfo,
|
|
119
|
-
groupElementsInfo,
|
|
120
|
-
setGroupElementsInfo,
|
|
121
131
|
isOverlappedColored,
|
|
122
132
|
setIsOverlappedColored,
|
|
123
133
|
currentHilitedGroups,
|
|
124
134
|
setCurrentHilitedGroups,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
135
|
+
isVisualizationsEnabled,
|
|
136
|
+
setIsVisualizationsEnabled,
|
|
137
|
+
overlappedElementsMetadata,
|
|
138
|
+
setOverlappedElementsMetadata,
|
|
139
|
+
}), [showGroupColor, hiddenGroupsIds, groups, numberOfVisualizedGroups, isOverlappedColored, currentHilitedGroups, isVisualizationsEnabled, overlappedElementsMetadata]);
|
|
128
140
|
const propertiesContextValue = (0, react_1.useMemo)(() => ({
|
|
129
141
|
showGroupColor: propertiesShowGroup,
|
|
130
142
|
setShowGroupColor: setPropertiesShowGroup,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingMappingContext.js","sourceRoot":"","sources":["../../../src/components/GroupingMappingContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAAoE;AAEpE,wDAAiD;AAMjD,iFAAqF;AACrF,yEAGwC;AAExC,6FAAyH;AAGzH,uFAAoF;AACpF,mEAAgE;AAChE,oDAA+D;AAC/D,+EAAoG;AACpG,uDAAoG;AACpG,wDAA+C;AAC/C,2CAAkD;AAmClD,MAAM,iCAAiC,GAAG,KAAK,IAAI,EAAE,CACnD,CAAC,MAAM,yBAAS,CAAC,mBAAmB,EAAE,cAAc,EAAE,CAAC,IAAI,EAAE,CAAC;AAEhE,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC;IAClC,cAAc,EAAE;QACd,OAAO,EAAE;YACP,oBAAoB,EAAE,KAAK;YAC3B,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,aAAa;SACzC;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8BAAC,qCAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,sBAAsB,IACtD,KAAK,CAAC,QAAQ,CACY,CACQ,CACC,CACT,CACL,CACS,CACvB,CACvB,CAAC;AACJ,CAAC,CAAC;AA/GW,QAAA,sBAAsB,0BA+GjC","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, { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n ClientPrefix,\n GetAccessTokenFn,\n GroupingMappingApiConfig,\n} from \"./context/GroupingApiConfigContext\";\nimport { GroupingMappingApiConfigContext } from \"./context/GroupingApiConfigContext\";\nimport {\n createMappingClient,\n MappingClientContext,\n} from \"./context/MappingClientContext\";\nimport type { CalculatedProperty, CustomCalculation, Group, GroupProperty, IExtractionClient, IMappingsClient } from \"@itwin/insights-client\";\nimport { createGroupingMappingCustomUI, GroupingMappingCustomUIContext } from \"./context/GroupingMappingCustomUIContext\";\nimport type { GroupingMappingCustomUI } from \"./customUI/GroupingMappingCustomUI\";\nimport type { OverlappedElementGroupPairs, OverlappedInfo, QueryCacheItem } from \"./context/GroupHilitedElementsContext\";\nimport { GroupHilitedElementsContext } from \"./context/GroupHilitedElementsContext\";\nimport { PropertiesContext } from \"./context/PropertiesContext\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { createExtractionClient, ExtractionClientContext } from \"./context/ExtractionClientContext\";\nimport { MutationCache, QueryCache, QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { toaster } from \"@itwin/itwinui-react\";\nimport { getErrorMessage } from \"../common/utils\";\n\nexport interface GroupingMappingContextProps {\n /**\n * Custom callback to retrieve access token.\n */\n getAccessToken?: GetAccessTokenFn;\n /**\n * The iTwin iModel Id.\n */\n iModelId: string;\n /**\n * Used for iTwin and iModel APIs.\n * Also used for Mapping API if a custom {@link client} is not provided.\n */\n prefix?: ClientPrefix;\n /**\n * A custom implementation of MappingClient.\n */\n client?: IMappingsClient;\n /**\n * A custom implementation of ExtractionClient.\n */\n extractionClient?: IExtractionClient;\n /**\n * Custom UI to add and update groups or provide additional group context capabilities.\n */\n customUIs?: GroupingMappingCustomUI[];\n /**\n * A custom iModelConnection to use instead of the active iModelConnection from UiFramework.\n */\n iModelConnection?: IModelConnection;\n children?: React.ReactNode;\n}\n\nconst authorizationClientGetAccessToken = async () =>\n (await IModelApp.authorizationClient?.getAccessToken()) ?? \"\";\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n staleTime: 20 * 60 * 1000, // 20 minutes\n },\n },\n queryCache: new QueryCache({\n onError: (error: any) => {\n if (error.status)\n toaster.negative(getErrorMessage(error.status));\n else\n toaster.negative(\"An error occurred while fetching data.\");\n },\n }),\n mutationCache: new MutationCache({\n onError: (error: any) => {\n if (error.status)\n toaster.negative(getErrorMessage(error.status));\n else\n toaster.negative(\"A network error occured while processing this action.\");\n },\n }),\n});\n\nexport const GroupingMappingContext = (props: GroupingMappingContextProps) => {\n const activeIModelConntextion = useActiveIModelConnection();\n const clientProp: IMappingsClient | ClientPrefix = props.client ?? props.prefix;\n const extractionClientProp: IExtractionClient | ClientPrefix = props.extractionClient ?? props.prefix;\n const [mappingClient, setMappingClient] = useState<IMappingsClient>(createMappingClient(clientProp));\n const [extractionClient, setExtractionClient] = useState<IExtractionClient>(createExtractionClient(extractionClientProp));\n const [customUIs, setCustomUIs] = useState<GroupingMappingCustomUI[]>(\n createGroupingMappingCustomUI(props.customUIs),\n );\n const [apiConfig, setApiConfig] = useState<GroupingMappingApiConfig>({\n getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,\n iModelId: props.iModelId,\n prefix: props.prefix,\n });\n const hilitedElementsQueryCache = useRef<Map<string, QueryCacheItem>>(new Map());\n const [hiddenGroupsIds, setHiddenGroupsIds] = useState<Set<string>>(new Set());\n const [showGroupColor, setShowGroupColor] = useState<boolean>(false);\n const [propertiesShowGroup, setPropertiesShowGroup] = useState<boolean>(false);\n const [groups, setGroups] = useState<Group[]>([]);\n const [groupProperties, setGroupProperties] = useState<GroupProperty[]>([]);\n const [calculatedProperties, setCalculatedProperties] = useState<CalculatedProperty[]>([]);\n const [customCalculationProperties, setCustomCalculationProperties] = useState<CustomCalculation[]>([]);\n const [numberOfVisualizedGroups, setNumberOfVisualizedGroups] = useState(0);\n const [overlappedElementsInfo, setOverlappedElementsInfo] = useState<Map<string, OverlappedInfo[]>>(new Map());\n const [groupElementsInfo, setGroupElementsInfo] = useState<Map<string, number>>(new Map());\n const [isOverlappedColored, setIsOverlappedColored] = useState<boolean>(false);\n const [currentHilitedGroups, setCurrentHilitedGroups] = useState<number>(1);\n const [overlappedElementGroupPairs, setOverlappedElementGroupPairs] = useState<OverlappedElementGroupPairs[]>([]);\n\n useEffect(() => {\n setApiConfig(() => ({\n prefix: props.prefix,\n iModelId: props.iModelId,\n getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,\n iModelConnection: props.iModelConnection ?? activeIModelConntextion,\n }));\n }, [activeIModelConntextion, props.getAccessToken, props.iModelConnection, props.iModelId, props.prefix]);\n\n useEffect(() => {\n setMappingClient(createMappingClient(clientProp));\n }, [clientProp]);\n\n useEffect(() => {\n setExtractionClient(createExtractionClient(extractionClientProp));\n }, [extractionClientProp]);\n\n useEffect(() => {\n setCustomUIs(createGroupingMappingCustomUI(props.customUIs));\n }, [props.customUIs]);\n\n const hilitedElementsContextValue = useMemo(\n () => ({\n showGroupColor,\n setShowGroupColor,\n hiddenGroupsIds,\n setHiddenGroupsIds,\n hilitedElementsQueryCache,\n groups,\n setGroups,\n numberOfVisualizedGroups,\n setNumberOfVisualizedGroups,\n overlappedElementsInfo,\n setOverlappedElementsInfo,\n groupElementsInfo,\n setGroupElementsInfo,\n isOverlappedColored,\n setIsOverlappedColored,\n currentHilitedGroups,\n setCurrentHilitedGroups,\n overlappedElementGroupPairs,\n setOverlappedElementGroupPairs,\n }),\n [showGroupColor, hiddenGroupsIds, groups, numberOfVisualizedGroups, overlappedElementsInfo, groupElementsInfo, isOverlappedColored, currentHilitedGroups, overlappedElementGroupPairs]\n );\n\n const propertiesContextValue = useMemo(\n () => ({\n showGroupColor: propertiesShowGroup,\n setShowGroupColor: setPropertiesShowGroup,\n groupProperties,\n setGroupProperties,\n calculatedProperties,\n setCalculatedProperties,\n customCalculationProperties,\n setCustomCalculationProperties,\n }),\n [calculatedProperties, customCalculationProperties, groupProperties, propertiesShowGroup]\n );\n\n const customUIContextValue = useMemo(() => ({\n customUIs,\n setCustomUIs,\n }), [customUIs]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <GroupingMappingApiConfigContext.Provider value={apiConfig}>\n <MappingClientContext.Provider value={mappingClient}>\n <ExtractionClientContext.Provider value={extractionClient}>\n <GroupingMappingCustomUIContext.Provider value={customUIContextValue}>\n <GroupHilitedElementsContext.Provider value={hilitedElementsContextValue}>\n <PropertiesContext.Provider value={propertiesContextValue}>\n {props.children}\n </PropertiesContext.Provider>\n </GroupHilitedElementsContext.Provider>\n </GroupingMappingCustomUIContext.Provider>\n </ExtractionClientContext.Provider>\n </MappingClientContext.Provider>\n </GroupingMappingApiConfigContext.Provider>\n </QueryClientProvider>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"GroupingMappingContext.js","sourceRoot":"","sources":["../../../src/components/GroupingMappingContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,+CAA4D;AAE5D,wDAAiD;AAMjD,iFAAqF;AACrF,yEAGwC;AAExC,6FAAyH;AAGzH,uFAAoF;AACpF,mEAAgE;AAChE,oDAA+D;AAC/D,+EAAoG;AAEpG,uDAAoG;AACpG,wDAA+C;AAC/C,2CAAkD;AAClD,2CAAwC;AAuCxC,MAAM,iCAAi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Y;KACb,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,8BAAC,iCAAmB,IAAC,MAAM,EAAE,WAAW;QACtC,8BAAC,0DAA+B,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS;YACxD,8BAAC,2CAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa;gBACjD,8BAAC,iDAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB;oBACvD,8BAAC,+DAA8B,CAAC,QAAQ,IAAC,KAAK,EAAE,oBAAoB;wBAClE,8BAAC,yDAA2B,CAAC,QAAQ,IAAC,KAAK,EAAE,2BAA2B;4BACtE,8BAAC,qCAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,sBAAsB,IACtD,KAAK,CAAC,QAAQ,CACY,CACQ,CACC,CACT,CACL,CACS,CACvB,CACvB,CAAC;AACJ,CAAC,CAAC;AA/GW,QAAA,sBAAsB,0BA+GjC","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, { useEffect, useMemo, useState } from \"react\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n ClientPrefix,\n GetAccessTokenFn,\n GroupingMappingApiConfig,\n} from \"./context/GroupingApiConfigContext\";\nimport { GroupingMappingApiConfigContext } from \"./context/GroupingApiConfigContext\";\nimport {\n createMappingClient,\n MappingClientContext,\n} from \"./context/MappingClientContext\";\nimport type { CalculatedProperty, CustomCalculation, Group, GroupProperty, IExtractionClient, IMappingsClient } from \"@itwin/insights-client\";\nimport { createGroupingMappingCustomUI, GroupingMappingCustomUIContext } from \"./context/GroupingMappingCustomUIContext\";\nimport type { GroupingMappingCustomUI } from \"./customUI/GroupingMappingCustomUI\";\nimport type { OverlappedElementsMetadata } from \"./context/GroupHilitedElementsContext\";\nimport { GroupHilitedElementsContext } from \"./context/GroupHilitedElementsContext\";\nimport { PropertiesContext } from \"./context/PropertiesContext\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { createExtractionClient, ExtractionClientContext } from \"./context/ExtractionClientContext\";\nimport type { Query } from \"@tanstack/react-query\";\nimport { MutationCache, QueryCache, QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { toaster } from \"@itwin/itwinui-react\";\nimport { getErrorMessage } from \"../common/utils\";\nimport { TErrCodes } from \"./Constants\";\n\nexport interface GroupingMappingContextProps {\n /**\n * Custom callback to retrieve access token.\n */\n getAccessToken?: GetAccessTokenFn;\n /**\n * The iTwin iModel Id.\n */\n iModelId: string;\n /**\n * Used for iTwin and iModel APIs.\n * Also used for Mapping API if a custom {@link client} is not provided.\n */\n prefix?: ClientPrefix;\n /**\n * A custom implementation of MappingClient.\n */\n client?: IMappingsClient;\n /**\n * A custom implementation of ExtractionClient.\n */\n extractionClient?: IExtractionClient;\n /**\n * Custom UI to add and update groups or provide additional group context capabilities.\n */\n customUIs?: GroupingMappingCustomUI[];\n /**\n * A custom iModelConnection to use instead of the active iModelConnection from UiFramework.\n */\n iModelConnection?: IModelConnection;\n /**\n * A custom QueryClient. If not provided, a default QueryClient will be used.\n */\n queryClient?: QueryClient;\n children?: React.ReactNode;\n}\n\nconst authorizationClientGetAccessToken = async () =>\n (await IModelApp.authorizationClient?.getAccessToken()) ?? \"\";\n\nconst defaultQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n staleTime: 20 * 60 * 1000, // 20 minutes\n },\n },\n queryCache: new QueryCache({\n onError: (error: any, query: Query) => {\n switch (query.meta?.errorCode) {\n case TErrCodes.QUERY_HILITE_FETCH_FAILED:\n toaster.negative(query.meta?.message as string);\n break;\n default: {\n if (error.status)\n toaster.negative(getErrorMessage(error.status));\n else\n toaster.negative(\"An error occurred while fetching data.\");\n }\n }\n },\n }),\n mutationCache: new MutationCache({\n onError: (error: any) => {\n if (error.status)\n toaster.negative(getErrorMessage(error.status));\n else\n toaster.negative(\"A network error occured while processing this action.\");\n },\n }),\n});\n\nexport const GroupingMappingContext = (props: GroupingMappingContextProps) => {\n const activeIModelConntextion = useActiveIModelConnection();\n const clientProp: IMappingsClient | ClientPrefix = props.client ?? props.prefix;\n const extractionClientProp: IExtractionClient | ClientPrefix = props.extractionClient ?? props.prefix;\n const [mappingClient, setMappingClient] = useState<IMappingsClient>(createMappingClient(clientProp));\n const [extractionClient, setExtractionClient] = useState<IExtractionClient>(createExtractionClient(extractionClientProp));\n const [customUIs, setCustomUIs] = useState<GroupingMappingCustomUI[]>(\n createGroupingMappingCustomUI(props.customUIs),\n );\n const [apiConfig, setApiConfig] = useState<GroupingMappingApiConfig>({\n getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,\n iModelId: props.iModelId,\n prefix: props.prefix,\n });\n const [hiddenGroupsIds, setHiddenGroupsIds] = useState<Set<string>>(new Set());\n const [showGroupColor, setShowGroupColor] = useState<boolean>(false);\n const [propertiesShowGroup, setPropertiesShowGroup] = useState<boolean>(false);\n const [groups, setGroups] = useState<Group[]>([]);\n const [groupProperties, setGroupProperties] = useState<GroupProperty[]>([]);\n const [calculatedProperties, setCalculatedProperties] = useState<CalculatedProperty[]>([]);\n const [customCalculationProperties, setCustomCalculationProperties] = useState<CustomCalculation[]>([]);\n const [numberOfVisualizedGroups, setNumberOfVisualizedGroups] = useState(0);\n const [isOverlappedColored, setIsOverlappedColored] = useState<boolean>(false);\n const [currentHilitedGroups, setCurrentHilitedGroups] = useState<number>(1);\n const [isVisualizationsEnabled, setIsVisualizationsEnabled] = useState<boolean>(false);\n const [overlappedElementsMetadata, setOverlappedElementsMetadata] = useState<OverlappedElementsMetadata>({\n overlappedElementsInfo: new Map(),\n groupElementsInfo: new Map(),\n overlappedElementGroupPairs: [],\n });\n const queryClient = props.queryClient ?? defaultQueryClient;\n\n useEffect(() => {\n setApiConfig(() => ({\n prefix: props.prefix,\n iModelId: props.iModelId,\n getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,\n iModelConnection: props.iModelConnection ?? activeIModelConntextion,\n }));\n }, [activeIModelConntextion, props.getAccessToken, props.iModelConnection, props.iModelId, props.prefix]);\n\n useEffect(() => {\n setMappingClient(createMappingClient(clientProp));\n }, [clientProp]);\n\n useEffect(() => {\n setExtractionClient(createExtractionClient(extractionClientProp));\n }, [extractionClientProp]);\n\n useEffect(() => {\n setCustomUIs(createGroupingMappingCustomUI(props.customUIs));\n }, [props.customUIs]);\n\n const hilitedElementsContextValue = useMemo(\n () => ({\n showGroupColor,\n setShowGroupColor,\n hiddenGroupsIds,\n setHiddenGroupsIds,\n groups,\n setGroups,\n numberOfVisualizedGroups,\n setNumberOfVisualizedGroups,\n isOverlappedColored,\n setIsOverlappedColored,\n currentHilitedGroups,\n setCurrentHilitedGroups,\n isVisualizationsEnabled,\n setIsVisualizationsEnabled,\n overlappedElementsMetadata,\n setOverlappedElementsMetadata,\n }),\n [showGroupColor, hiddenGroupsIds, groups, numberOfVisualizedGroups, isOverlappedColored, currentHilitedGroups, isVisualizationsEnabled, overlappedElementsMetadata]\n );\n\n const propertiesContextValue = useMemo(\n () => ({\n showGroupColor: propertiesShowGroup,\n setShowGroupColor: setPropertiesShowGroup,\n groupProperties,\n setGroupProperties,\n calculatedProperties,\n setCalculatedProperties,\n customCalculationProperties,\n setCustomCalculationProperties,\n }),\n [calculatedProperties, customCalculationProperties, groupProperties, propertiesShowGroup]\n );\n\n const customUIContextValue = useMemo(() => ({\n customUIs,\n setCustomUIs,\n }), [customUIs]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <GroupingMappingApiConfigContext.Provider value={apiConfig}>\n <MappingClientContext.Provider value={mappingClient}>\n <ExtractionClientContext.Provider value={extractionClient}>\n <GroupingMappingCustomUIContext.Provider value={customUIContextValue}>\n <GroupHilitedElementsContext.Provider value={hilitedElementsContextValue}>\n <PropertiesContext.Provider value={propertiesContextValue}>\n {props.children}\n </PropertiesContext.Provider>\n </GroupHilitedElementsContext.Provider>\n </GroupingMappingCustomUIContext.Provider>\n </ExtractionClientContext.Provider>\n </MappingClientContext.Provider>\n </GroupingMappingApiConfigContext.Provider>\n </QueryClientProvider>\n );\n};\n"]}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -26,7 +30,6 @@ exports.GroupAction = void 0;
|
|
|
26
30
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
27
31
|
const react_1 = __importStar(require("react"));
|
|
28
32
|
const LoadingSpinner_1 = require("../../SharedComponents/LoadingSpinner");
|
|
29
|
-
const utils_1 = require("../../../common/utils");
|
|
30
33
|
require("./GroupAction.scss");
|
|
31
34
|
const useValidator_1 = __importDefault(require("../../Properties/hooks/useValidator"));
|
|
32
35
|
const GroupingApiConfigContext_1 = require("../../context/GroupingApiConfigContext");
|
|
@@ -38,6 +41,7 @@ const GroupDetailsStep_1 = require("./GroupDetailsStep");
|
|
|
38
41
|
const QueryBuilderActionPanel_1 = require("../QueryBuilder/QueryBuilderActionPanel");
|
|
39
42
|
const GroupDetailsActionPanel_1 = require("./GroupDetailsActionPanel");
|
|
40
43
|
const useVisualization_1 = require("../hooks/useVisualization");
|
|
44
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
41
45
|
const defaultDisplayStrings = {
|
|
42
46
|
groupDetails: "Group Details",
|
|
43
47
|
groupBy: "Group By",
|
|
@@ -62,37 +66,29 @@ const GroupAction = (props) => {
|
|
|
62
66
|
const [query, setQuery] = (0, react_1.useState)("");
|
|
63
67
|
const [queryRowCount, setQueryRowCount] = (0, react_1.useState)(0);
|
|
64
68
|
const [validator, setShowValidationMessage] = (0, useValidator_1.default)();
|
|
65
|
-
const
|
|
69
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
66
70
|
const [queryGenerationType, setQueryGenerationType] = (0, react_1.useState)(props.queryGenerationType);
|
|
67
|
-
const { isRendering,
|
|
68
|
-
const isUpdating = isLoading || isRendering;
|
|
71
|
+
const { isRendering, simpleSelectionQuery, setSimpleSelectionQuery, clearPresentationSelection, resetView, } = (0, useVisualization_1.useVisualization)(props.shouldVisualize, iModelConnection, query, queryGenerationType);
|
|
69
72
|
const [currentStep, setCurrentStep] = react_1.default.useState(GroupActionStep.QueryBuilder);
|
|
70
73
|
const displayStrings = react_1.default.useMemo(() => ({ ...defaultDisplayStrings, ...props.displayStrings }), [props.displayStrings]);
|
|
71
74
|
(0, react_1.useEffect)(() => setQueryGenerationType(props.queryGenerationType), [props.queryGenerationType]);
|
|
75
|
+
const fetchQueryRowCount = async (query) => {
|
|
76
|
+
const rowCount = (await iModelConnection.createQueryReader(`SELECT count(*) FROM (${query})`).next()).value[0];
|
|
77
|
+
return rowCount;
|
|
78
|
+
};
|
|
79
|
+
const { mutate, isLoading: isQueryLoading } = (0, react_query_1.useMutation)(fetchQueryRowCount, {
|
|
80
|
+
onSuccess: (result) => {
|
|
81
|
+
setQueryRowCount(result);
|
|
82
|
+
},
|
|
83
|
+
});
|
|
72
84
|
(0, react_1.useEffect)(() => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const result = await iModelConnection.queryRowCount(query);
|
|
81
|
-
setQueryRowCount(result);
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
itwinui_react_1.toaster.negative("Query failed to resolve.");
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
setIsLoading(false);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
void fetchQueryRowCount();
|
|
91
|
-
}, [iModelConnection, query, setIsRendering]);
|
|
92
|
-
const isBlockingActions = !(details.groupName &&
|
|
93
|
-
(query || simpleSelectionQuery) &&
|
|
94
|
-
!isRendering &&
|
|
95
|
-
!isLoading);
|
|
85
|
+
if (query) {
|
|
86
|
+
mutate(query);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
setQueryRowCount(0);
|
|
90
|
+
}
|
|
91
|
+
}, [iModelConnection, query, mutate]);
|
|
96
92
|
const getOptions = (0, react_1.useMemo)(() => groupUIs.map((ui) => ({
|
|
97
93
|
label: ui.displayLabel,
|
|
98
94
|
value: ui.name,
|
|
@@ -105,21 +101,16 @@ const GroupAction = (props) => {
|
|
|
105
101
|
setSimpleSelectionQuery("");
|
|
106
102
|
await resetView();
|
|
107
103
|
}, [clearPresentationSelection, resetView, setSimpleSelectionQuery]);
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
? await mappingClient.updateGroup(accessToken, iModelId, props.mappingId, props.group.id ?? "", { ...details, query: currentQuery })
|
|
119
|
-
: await mappingClient.createGroup(accessToken, iModelId, props.mappingId, {
|
|
120
|
-
...details,
|
|
121
|
-
query: currentQuery,
|
|
122
|
-
});
|
|
104
|
+
const saveGroup = async () => {
|
|
105
|
+
const accessToken = await getAccessToken();
|
|
106
|
+
const currentQuery = query || simpleSelectionQuery;
|
|
107
|
+
return props.group
|
|
108
|
+
? mappingClient.updateGroup(accessToken, iModelId, props.mappingId, props.group.id, { ...details, query: currentQuery })
|
|
109
|
+
: mappingClient.createGroup(accessToken, iModelId, props.mappingId, { ...details, query: currentQuery });
|
|
110
|
+
};
|
|
111
|
+
const { mutate: onSaveMutate, isLoading: isSaveLoading } = (0, react_query_1.useMutation)(saveGroup, {
|
|
112
|
+
onSuccess: async () => {
|
|
113
|
+
await queryClient.invalidateQueries({ queryKey: ["groups"] });
|
|
123
114
|
clearPresentationSelection();
|
|
124
115
|
setDetails({
|
|
125
116
|
groupName: props.group?.groupName ?? "",
|
|
@@ -128,16 +119,32 @@ const GroupAction = (props) => {
|
|
|
128
119
|
setCurrentStep(GroupActionStep.QueryBuilder);
|
|
129
120
|
setShowValidationMessage(false);
|
|
130
121
|
props.onSaveSuccess();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
(0, utils_1.handleError)(error.status);
|
|
134
|
-
}
|
|
135
|
-
finally {
|
|
136
|
-
setIsLoading(false);
|
|
137
|
-
}
|
|
138
|
-
}, [validator, setShowValidationMessage, query, simpleSelectionQuery, getAccessToken, props, mappingClient, iModelId, details, clearPresentationSelection]);
|
|
122
|
+
},
|
|
123
|
+
});
|
|
139
124
|
const isQueryBuilderStep = currentStep === GroupActionStep.QueryBuilder;
|
|
140
125
|
const isGroupDetailsStep = currentStep === GroupActionStep.GroupDetails;
|
|
126
|
+
const isLoading = isSaveLoading || isQueryLoading;
|
|
127
|
+
const isUpdating = isLoading || isRendering;
|
|
128
|
+
const isBlockingActions = !(details.groupName && (query || simpleSelectionQuery)) || isRendering || isLoading;
|
|
129
|
+
const onClickSave = (0, react_1.useCallback)(() => {
|
|
130
|
+
if (!validator.allValid()) {
|
|
131
|
+
setShowValidationMessage(true);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
onSaveMutate();
|
|
135
|
+
}, [onSaveMutate, setShowValidationMessage, validator]);
|
|
136
|
+
const onClickBack = (0, react_1.useCallback)(() => {
|
|
137
|
+
setCurrentStep(GroupActionStep.QueryBuilder);
|
|
138
|
+
}, []);
|
|
139
|
+
const onClickCancel = (0, react_1.useCallback)(() => {
|
|
140
|
+
clearPresentationSelection();
|
|
141
|
+
if (props.onClickCancel) {
|
|
142
|
+
props.onClickCancel();
|
|
143
|
+
}
|
|
144
|
+
}, [clearPresentationSelection, props]);
|
|
145
|
+
const onClickNext = (0, react_1.useCallback)(() => {
|
|
146
|
+
setCurrentStep(GroupActionStep.GroupDetails);
|
|
147
|
+
}, []);
|
|
141
148
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
142
149
|
react_1.default.createElement("div", { className: "gmw-group-add-modify-container" },
|
|
143
150
|
react_1.default.createElement(QueryBuilderStep_1.QueryBuilderStep, { queryRowCount: queryRowCount, isHidden: !isQueryBuilderStep, queryGenerationType: queryGenerationType, groupUIs: groupUIs, isUpdating: isUpdating, resetView: resetView, setQuery: setQuery, onChange: onChange, getOptions: getOptions, displayStrings: { ...displayStrings }, group: props.group }),
|
|
@@ -145,12 +152,9 @@ const GroupAction = (props) => {
|
|
|
145
152
|
react_1.default.createElement("div", { className: 'gmw-action-panel' },
|
|
146
153
|
isLoading &&
|
|
147
154
|
react_1.default.createElement(LoadingSpinner_1.LoadingSpinner, null),
|
|
148
|
-
isQueryBuilderStep && (react_1.default.createElement(QueryBuilderActionPanel_1.QueryBuilderActionPanel, { onClickNext:
|
|
149
|
-
isGroupDetailsStep && (react_1.default.createElement(GroupDetailsActionPanel_1.GroupDetailsActionPanel, { isSaveDisabled: isBlockingActions, onClickSave:
|
|
150
|
-
props.onClickCancel && react_1.default.createElement(itwinui_react_1.Button, { type: 'button', id: 'cancel', onClick:
|
|
151
|
-
clearPresentationSelection();
|
|
152
|
-
props.onClickCancel && props.onClickCancel();
|
|
153
|
-
} }, "Cancel"))));
|
|
155
|
+
isQueryBuilderStep && (react_1.default.createElement(QueryBuilderActionPanel_1.QueryBuilderActionPanel, { onClickNext: onClickNext })),
|
|
156
|
+
isGroupDetailsStep && (react_1.default.createElement(GroupDetailsActionPanel_1.GroupDetailsActionPanel, { isSaveDisabled: isBlockingActions, onClickSave: onClickSave, onClickBack: onClickBack })),
|
|
157
|
+
props.onClickCancel && react_1.default.createElement(itwinui_react_1.Button, { type: 'button', id: 'cancel', onClick: onClickCancel }, "Cancel"))));
|
|
154
158
|
};
|
|
155
159
|
exports.GroupAction = GroupAction;
|
|
156
160
|
//# sourceMappingURL=GroupAction.js.map
|