@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.
- package/lib/cjs/grouping-mapping-widget.d.ts +4 -1
- package/lib/cjs/grouping-mapping-widget.js +7 -1
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/cjs/test/WidgetHeader.test.js +3 -3
- package/lib/cjs/test/WidgetHeader.test.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyAction.d.ts +7 -9
- package/lib/cjs/widget/components/CalculatedPropertyAction.js +49 -24
- package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyTable.d.ts +9 -16
- package/lib/cjs/widget/components/CalculatedPropertyTable.js +29 -31
- package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyTable.scss +9 -0
- package/lib/cjs/widget/components/CustomCalculationAction.d.ts +6 -9
- package/lib/cjs/widget/components/CustomCalculationAction.js +79 -9
- package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationTable.d.ts +8 -16
- package/lib/cjs/widget/components/CustomCalculationTable.js +22 -29
- package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.d.ts +4 -5
- package/lib/cjs/widget/components/DeleteModal.js +9 -13
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
- package/lib/cjs/widget/components/GroupAction.js +1 -0
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupInformationPanel.d.ts +10 -0
- package/lib/cjs/widget/components/GroupInformationPanel.js +23 -0
- package/lib/cjs/widget/components/GroupInformationPanel.js.map +1 -0
- package/lib/cjs/widget/components/GroupInformationPanel.scss +13 -0
- package/lib/cjs/widget/components/GroupPropertyAction.d.ts +6 -9
- package/lib/cjs/widget/components/GroupPropertyAction.js +26 -15
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyTable.d.ts +8 -15
- package/lib/cjs/widget/components/GroupPropertyTable.js +23 -28
- package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.d.ts +2 -1
- package/lib/cjs/widget/components/Grouping.js +12 -15
- package/lib/cjs/widget/components/Grouping.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.scss +2 -9
- package/lib/cjs/widget/components/GroupingMapping.js +1 -2
- package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMappingContent.js +8 -4
- package/lib/cjs/widget/components/GroupingMappingContent.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMappingContext.js +17 -1
- package/lib/cjs/widget/components/GroupingMappingContext.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMappingHeader.js +2 -2
- package/lib/cjs/widget/components/GroupingMappingHeader.js.map +1 -1
- package/lib/cjs/widget/components/GroupingMappingRouter.js +23 -2
- package/lib/cjs/widget/components/GroupingMappingRouter.js.map +1 -1
- package/lib/cjs/widget/components/GroupsAddButton.d.ts +9 -0
- package/lib/cjs/widget/components/GroupsAddButton.js +17 -0
- package/lib/cjs/widget/components/GroupsAddButton.js.map +1 -0
- package/lib/cjs/widget/components/GroupsAddButton.scss +7 -0
- package/lib/cjs/widget/components/Mapping.js +5 -11
- package/lib/cjs/widget/components/Mapping.js.map +1 -1
- package/lib/cjs/widget/components/PropertyMenu.d.ts +12 -17
- package/lib/cjs/widget/components/PropertyMenu.js +52 -155
- package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
- package/lib/cjs/widget/components/PropertyMenu.scss +4 -28
- package/lib/cjs/widget/components/PropertyNameCell.d.ts +11 -0
- package/lib/cjs/widget/components/PropertyNameCell.js +15 -0
- package/lib/cjs/widget/components/PropertyNameCell.js.map +1 -0
- package/lib/cjs/widget/components/PropertyTable.d.ts +18 -0
- package/lib/cjs/widget/components/PropertyTable.js +54 -0
- package/lib/cjs/widget/components/PropertyTable.js.map +1 -0
- package/lib/cjs/widget/components/PropertyTable.scss +11 -0
- package/lib/cjs/widget/components/PropertyTableToolbar.d.ts +10 -0
- package/lib/cjs/widget/components/PropertyTableToolbar.js +23 -0
- package/lib/cjs/widget/components/PropertyTableToolbar.js.map +1 -0
- package/lib/cjs/widget/components/PropertyTableToolbar.scss +12 -0
- package/lib/cjs/widget/components/ToggleGroupVisibility.d.ts +9 -0
- package/lib/cjs/widget/components/ToggleGroupVisibility.js +16 -0
- package/lib/cjs/widget/components/ToggleGroupVisibility.js.map +1 -0
- package/lib/cjs/widget/components/ToggleGroupVisibility.scss +9 -0
- package/lib/cjs/widget/components/WidgetHeader.d.ts +9 -0
- package/lib/cjs/widget/components/WidgetHeader.js +22 -0
- package/lib/cjs/widget/components/WidgetHeader.js.map +1 -0
- package/lib/cjs/widget/components/WidgetHeader.scss +36 -0
- package/lib/cjs/widget/components/context/GroupHilitedElementsContext.d.ts +6 -1
- package/lib/cjs/widget/components/context/GroupHilitedElementsContext.js.map +1 -1
- package/lib/cjs/widget/components/context/PropertiesContext.d.ts +15 -0
- package/lib/cjs/widget/components/context/PropertiesContext.js +43 -0
- package/lib/cjs/widget/components/context/PropertiesContext.js.map +1 -0
- package/lib/cjs/widget/components/groupsHelpers.d.ts +6 -3
- package/lib/cjs/widget/components/groupsHelpers.js +43 -40
- package/lib/cjs/widget/components/groupsHelpers.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyRender.js +2 -1
- package/lib/cjs/widget/components/property-grid/PropertyRender.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/countMatchesInString.d.ts +8 -0
- package/lib/cjs/widget/components/property-grid/countMatchesInString.js +32 -0
- package/lib/cjs/widget/components/property-grid/countMatchesInString.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/createNewDisplayValue.d.ts +10 -0
- package/lib/cjs/widget/components/property-grid/createNewDisplayValue.js +65 -0
- package/lib/cjs/widget/components/property-grid/createNewDisplayValue.js.map +1 -0
- package/lib/cjs/widget/components/utils.d.ts +0 -6
- package/lib/cjs/widget/components/utils.js +1 -9
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/cjs/widget/components/utils.scss +0 -29
- package/lib/cjs/widget/components/viewerUtils.d.ts +4 -2
- package/lib/cjs/widget/components/viewerUtils.js +4 -22
- package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
- package/lib/cjs/widget/hooks/useFetchData.d.ts +3 -5
- package/lib/cjs/widget/hooks/useFetchData.js +9 -7
- package/lib/cjs/widget/hooks/useFetchData.js.map +1 -1
- package/lib/esm/grouping-mapping-widget.d.ts +4 -1
- package/lib/esm/grouping-mapping-widget.js +3 -0
- package/lib/esm/grouping-mapping-widget.js.map +1 -1
- package/lib/esm/test/WidgetHeader.test.js +1 -1
- package/lib/esm/test/WidgetHeader.test.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyAction.d.ts +7 -9
- package/lib/esm/widget/components/CalculatedPropertyAction.js +50 -27
- package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyTable.d.ts +9 -16
- package/lib/esm/widget/components/CalculatedPropertyTable.js +30 -31
- package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyTable.scss +9 -0
- package/lib/esm/widget/components/CustomCalculationAction.d.ts +6 -9
- package/lib/esm/widget/components/CustomCalculationAction.js +79 -11
- package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationTable.d.ts +8 -16
- package/lib/esm/widget/components/CustomCalculationTable.js +23 -29
- package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/esm/widget/components/DeleteModal.d.ts +4 -5
- package/lib/esm/widget/components/DeleteModal.js +9 -13
- package/lib/esm/widget/components/DeleteModal.js.map +1 -1
- package/lib/esm/widget/components/GroupAction.js +1 -0
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/GroupInformationPanel.d.ts +10 -0
- package/lib/esm/widget/components/GroupInformationPanel.js +16 -0
- package/lib/esm/widget/components/GroupInformationPanel.js.map +1 -0
- package/lib/esm/widget/components/GroupInformationPanel.scss +13 -0
- package/lib/esm/widget/components/GroupPropertyAction.d.ts +6 -9
- package/lib/esm/widget/components/GroupPropertyAction.js +25 -15
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyTable.d.ts +8 -15
- package/lib/esm/widget/components/GroupPropertyTable.js +24 -28
- package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/Grouping.d.ts +2 -1
- package/lib/esm/widget/components/Grouping.js +14 -17
- package/lib/esm/widget/components/Grouping.js.map +1 -1
- package/lib/esm/widget/components/Grouping.scss +2 -9
- package/lib/esm/widget/components/GroupingMapping.js +1 -2
- package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
- package/lib/esm/widget/components/GroupingMappingContent.js +9 -5
- package/lib/esm/widget/components/GroupingMappingContent.js.map +1 -1
- package/lib/esm/widget/components/GroupingMappingContext.js +17 -1
- package/lib/esm/widget/components/GroupingMappingContext.js.map +1 -1
- package/lib/esm/widget/components/GroupingMappingHeader.js +1 -1
- package/lib/esm/widget/components/GroupingMappingHeader.js.map +1 -1
- package/lib/esm/widget/components/GroupingMappingRouter.js +23 -2
- package/lib/esm/widget/components/GroupingMappingRouter.js.map +1 -1
- package/lib/esm/widget/components/GroupsAddButton.d.ts +9 -0
- package/lib/esm/widget/components/GroupsAddButton.js +10 -0
- package/lib/esm/widget/components/GroupsAddButton.js.map +1 -0
- package/lib/esm/widget/components/GroupsAddButton.scss +7 -0
- package/lib/esm/widget/components/Mapping.js +5 -11
- package/lib/esm/widget/components/Mapping.js.map +1 -1
- package/lib/esm/widget/components/PropertyMenu.d.ts +12 -17
- package/lib/esm/widget/components/PropertyMenu.js +54 -154
- package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
- package/lib/esm/widget/components/PropertyMenu.scss +4 -28
- package/lib/esm/widget/components/PropertyNameCell.d.ts +11 -0
- package/lib/esm/widget/components/PropertyNameCell.js +8 -0
- package/lib/esm/widget/components/PropertyNameCell.js.map +1 -0
- package/lib/esm/widget/components/PropertyTable.d.ts +18 -0
- package/lib/esm/widget/components/PropertyTable.js +28 -0
- package/lib/esm/widget/components/PropertyTable.js.map +1 -0
- package/lib/esm/widget/components/PropertyTable.scss +11 -0
- package/lib/esm/widget/components/PropertyTableToolbar.d.ts +10 -0
- package/lib/esm/widget/components/PropertyTableToolbar.js +16 -0
- package/lib/esm/widget/components/PropertyTableToolbar.js.map +1 -0
- package/lib/esm/widget/components/PropertyTableToolbar.scss +12 -0
- package/lib/esm/widget/components/ToggleGroupVisibility.d.ts +9 -0
- package/lib/esm/widget/components/ToggleGroupVisibility.js +9 -0
- package/lib/esm/widget/components/ToggleGroupVisibility.js.map +1 -0
- package/lib/esm/widget/components/ToggleGroupVisibility.scss +9 -0
- package/lib/esm/widget/components/WidgetHeader.d.ts +9 -0
- package/lib/esm/widget/components/WidgetHeader.js +15 -0
- package/lib/esm/widget/components/WidgetHeader.js.map +1 -0
- package/lib/esm/widget/components/WidgetHeader.scss +36 -0
- package/lib/esm/widget/components/context/GroupHilitedElementsContext.d.ts +6 -1
- package/lib/esm/widget/components/context/GroupHilitedElementsContext.js.map +1 -1
- package/lib/esm/widget/components/context/PropertiesContext.d.ts +15 -0
- package/lib/esm/widget/components/context/PropertiesContext.js +20 -0
- package/lib/esm/widget/components/context/PropertiesContext.js.map +1 -0
- package/lib/esm/widget/components/groupsHelpers.d.ts +6 -3
- package/lib/esm/widget/components/groupsHelpers.js +41 -40
- package/lib/esm/widget/components/groupsHelpers.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyRender.js +2 -1
- package/lib/esm/widget/components/property-grid/PropertyRender.js.map +1 -1
- package/lib/esm/widget/components/property-grid/countMatchesInString.d.ts +8 -0
- package/lib/esm/widget/components/property-grid/countMatchesInString.js +28 -0
- package/lib/esm/widget/components/property-grid/countMatchesInString.js.map +1 -0
- package/lib/esm/widget/components/property-grid/createNewDisplayValue.d.ts +10 -0
- package/lib/esm/widget/components/property-grid/createNewDisplayValue.js +42 -0
- package/lib/esm/widget/components/property-grid/createNewDisplayValue.js.map +1 -0
- package/lib/esm/widget/components/utils.d.ts +0 -6
- package/lib/esm/widget/components/utils.js +0 -7
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/lib/esm/widget/components/utils.scss +0 -29
- package/lib/esm/widget/components/viewerUtils.d.ts +4 -2
- package/lib/esm/widget/components/viewerUtils.js +3 -20
- package/lib/esm/widget/components/viewerUtils.js.map +1 -1
- package/lib/esm/widget/hooks/useFetchData.d.ts +3 -5
- package/lib/esm/widget/hooks/useFetchData.js +9 -7
- package/lib/esm/widget/hooks/useFetchData.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouping-mapping-widget.js","sourceRoot":"","sources":["../../src/grouping-mapping-widget.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,gDAAgD;AAChD,cAAc,gCAAgC,CAAC;AAE/C,0EAA0E;AAC1E,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAC3J,OAAO,EAA4D,+BAA+B,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AAC9L,cAAc,wBAAwB,CAAC;AAEvC,yCAAyC;AACzC,OAAO,EAAE,QAAQ,EAAiB,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAsB,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,sBAAsB,EAA+B,MAAM,4CAA4C,CAAC;AACjH,OAAO,EAAE,SAAS,EAAiB,MAAM,8BA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ent":["/*---------------------------------------------------------------------------------------------\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/** UI Provider for iTwin Viewer Applications */\nexport * from \"./widget/GroupingMappingWidget\";\n\n/** Interfaces for providing custom MappingClient and API configuration */\nexport { createDefaultMappingClient, createMappingClient, MappingClientContext, useMappingClient } from \"./widget/components/context/MappingClientContext\";\nexport { ClientPrefix, GetAccessTokenFn, GroupingMappingApiConfig, GroupingMappingApiConfigContext, useGroupingMappingApiConfig } from \"./widget/components/context/GroupingApiConfigContext\";\nexport * from \"@itwin/insights-client\";\n\n/** Internal components for custom UIs */\nexport { Mappings, MappingsProps } from \"./widget/components/Mapping\";\nexport { MappingAction, MappingActionProps } from \"./widget/components/MappingAction\";\nexport { GroupingMappingContext, GroupingMappingContextProps } from \"./widget/components/GroupingMappingContext\";\nexport { Groupings, GroupingProps } from \"./widget/components/Grouping\";\nexport { GroupAction, GroupActionProps } from \"./widget/components/GroupAction\";\nexport { PropertyMenu, PropertyMenuProps } from \"./widget/components/PropertyMenu\";\nexport { GroupPropertyAction, GroupPropertyActionProps } from \"./widget/components/GroupPropertyAction\";\nexport { CalculatedPropertyAction, CalculatedPropertyActionProps } from \"./widget/components/CalculatedPropertyAction\";\nexport { CustomCalculationAction, CustomCalculationActionProps } from \"./widget/components/CustomCalculationAction\";\nexport { SearchGroupingCustomUI } from \"./widget/components/customUI/SearchGroupingCustomUI\";\nexport { ManualGroupingCustomUI } from \"./widget/components/customUI/ManualGroupingCustomUI\";\nexport { GroupQueryBuilderCustomUI } from \"./widget/components/customUI/GroupQueryBuilderCustomUI\";\nexport { GroupingMappingCustomUI, GroupingMappingCustomUIType, ContextCustomUI, GroupingCustomUI, GroupingCustomUIProps, ContextCustomUIProps } from \"./widget/components/customUI/GroupingMappingCustomUI\";\n\n/** Formula DataType resolver */\nexport { resolveFormulaDataType } from \"./formula/FormulaDataTypeResolver\";\nexport { DataType, PropertyMap } from \"./formula/Types\";\nexport { IResult } from \"./formula/IResult\";\n"]}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import "@testing-library/jest-dom";
|
|
7
7
|
import { render, screen } from "../test/test-utils";
|
|
8
|
-
import { WidgetHeader } from "../widget/components/utils";
|
|
9
8
|
import { faker } from "@faker-js/faker";
|
|
9
|
+
import { WidgetHeader } from "../widget/components/WidgetHeader";
|
|
10
10
|
describe("Widget Header Component", () => {
|
|
11
11
|
it("title renders", async () => {
|
|
12
12
|
// Arrange
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WidgetHeader.test.js","sourceRoot":"","sources":["../../../src/test/WidgetHeader.test.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"WidgetHeader.test.js","sourceRoot":"","sources":["../../../src/test/WidgetHeader.test.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;QAC7B,UAAU;QACV,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAE5C,MAAM;QACN,MAAM,CAAC,oBAAC,YAAY,IAAC,KAAK,EAAE,SAAS,GAAI,CAAC,CAAC;QAE3C,SAAS;QACT,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC7C,UAAU;QACV,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAE/B,MAAM;QACN,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,oBAAC,YAAY,IAAC,KAAK,EAAC,EAAE,EAAC,QAAQ,EAAE,YAAY,GAAI,CAAC,CAAC;QAEtF,SAAS;QACT,MAAM,SAAS,GAAG,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC5B,MAAM,CAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport React from \"react\";\nimport \"@testing-library/jest-dom\";\nimport { render, screen } from \"../test/test-utils\";\nimport { faker } from \"@faker-js/faker\";\nimport { WidgetHeader } from \"../widget/components/WidgetHeader\";\n\ndescribe(\"Widget Header Component\", () => {\n it(\"title renders\", async () => {\n // Arrange\n const fakeTitle = faker.word.interjection();\n\n // Act\n render(<WidgetHeader title={fakeTitle} />);\n\n // Assert\n const title = screen.getByText(fakeTitle);\n expect(title).toHaveTextContent(fakeTitle);\n });\n\n it(\"header allows return callback\", async () => {\n // Arrange\n const mockReturnFn = jest.fn();\n\n // Act\n const { user, container } = render(<WidgetHeader title=\"\" returnFn={mockReturnFn} />);\n\n // Assert\n const returnBtn = container.getElementsByClassName(\"gmw-chevron\")[0];\n await user.click(returnBtn);\n expect(mockReturnFn).toHaveBeenCalledTimes(1);\n });\n});\n"]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./CalculatedPropertyAction.scss";
|
|
3
|
-
import type {
|
|
4
|
-
interface CalculatedPropertyActionProps {
|
|
5
|
-
iModelId: string;
|
|
3
|
+
import type { CalculatedProperty, Group } from "@itwin/insights-client";
|
|
4
|
+
export interface CalculatedPropertyActionProps {
|
|
6
5
|
mappingId: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
group: Group;
|
|
7
|
+
calculatedProperty?: CalculatedProperty;
|
|
8
|
+
onSaveSuccess: () => void;
|
|
9
|
+
onClickCancel?: () => void;
|
|
11
10
|
}
|
|
12
|
-
declare const CalculatedPropertyAction: ({
|
|
13
|
-
export default CalculatedPropertyAction;
|
|
11
|
+
export declare const CalculatedPropertyAction: ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }: CalculatedPropertyActionProps) => JSX.Element;
|
|
14
12
|
//# sourceMappingURL=CalculatedPropertyAction.d.ts.map
|
|
@@ -3,27 +3,34 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { IModelApp } from "@itwin/core-frontend";
|
|
6
|
-
import { Fieldset, LabeledInput, LabeledSelect, MenuItem, Small, } from "@itwin/itwinui-react";
|
|
6
|
+
import { Fieldset, LabeledInput, LabeledSelect, MenuItem, Small, ToggleSwitch, } from "@itwin/itwinui-react";
|
|
7
7
|
import React, { useEffect, useState } from "react";
|
|
8
8
|
import ActionPanel from "./ActionPanel";
|
|
9
9
|
import { BboxDimension, BboxDimensionsDecorator, } from "../../decorators/BboxDimensionsDecorator";
|
|
10
10
|
import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
|
|
11
|
-
import { handleError
|
|
12
|
-
import { visualizeElements, zoomToElements } from "./viewerUtils";
|
|
11
|
+
import { handleError } from "./utils";
|
|
12
|
+
import { clearEmphasizedOverriddenElements, visualizeElements, zoomToElements } from "./viewerUtils";
|
|
13
13
|
import "./CalculatedPropertyAction.scss";
|
|
14
14
|
import { useMappingClient } from "./context/MappingClientContext";
|
|
15
15
|
import { useGroupingMappingApiConfig } from "./context/GroupingApiConfigContext";
|
|
16
16
|
import { CalculatedPropertyType } from "@itwin/insights-client";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
import { useGroupHilitedElementsContext } from "./context/GroupHilitedElementsContext";
|
|
18
|
+
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
19
|
+
import { getHiliteIdsAndKeysetFromGroup } from "./groupsHelpers";
|
|
20
|
+
export const CalculatedPropertyAction = ({ mappingId, group, calculatedProperty, onSaveSuccess, onClickCancel, }) => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const { getAccessToken, iModelId } = useGroupingMappingApiConfig();
|
|
20
23
|
const mappingClient = useMappingClient();
|
|
21
|
-
const [propertyName, setPropertyName] = useState((_a =
|
|
22
|
-
const
|
|
24
|
+
const [propertyName, setPropertyName] = useState((_a = calculatedProperty === null || calculatedProperty === void 0 ? void 0 : calculatedProperty.propertyName) !== null && _a !== void 0 ? _a : "");
|
|
25
|
+
const iModelConnection = useActiveIModelConnection();
|
|
26
|
+
const [type, setType] = useState((_b = calculatedProperty === null || calculatedProperty === void 0 ? void 0 : calculatedProperty.type) !== null && _b !== void 0 ? _b : CalculatedPropertyType.Undefined);
|
|
23
27
|
const [bboxDecorator, setBboxDecorator] = useState();
|
|
24
28
|
const [isLoading, setIsLoading] = useState(false);
|
|
29
|
+
const { hilitedElementsQueryCache } = useGroupHilitedElementsContext();
|
|
25
30
|
const [inferredSpatialData, setInferredSpatialData] = useState();
|
|
26
31
|
const [validator, showValidationMessage] = useValidator();
|
|
32
|
+
const [resolvedHiliteIds, setResolvedHiliteIds] = useState([]);
|
|
33
|
+
const [colorProperty, setColorProperty] = useState(false);
|
|
27
34
|
useEffect(() => {
|
|
28
35
|
const decorator = new BboxDimensionsDecorator();
|
|
29
36
|
IModelApp.viewManager.addDecorator(decorator);
|
|
@@ -33,31 +40,45 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
|
|
|
33
40
|
};
|
|
34
41
|
}, []);
|
|
35
42
|
useEffect(() => {
|
|
36
|
-
|
|
43
|
+
const initialize = async () => {
|
|
44
|
+
if (!iModelConnection)
|
|
45
|
+
return;
|
|
46
|
+
clearEmphasizedOverriddenElements();
|
|
47
|
+
if (!colorProperty)
|
|
48
|
+
return;
|
|
49
|
+
setIsLoading(true);
|
|
50
|
+
const result = await getHiliteIdsAndKeysetFromGroup(iModelConnection, group, hilitedElementsQueryCache);
|
|
51
|
+
setResolvedHiliteIds(result.ids);
|
|
52
|
+
setIsLoading(false);
|
|
53
|
+
};
|
|
54
|
+
void initialize();
|
|
55
|
+
}, [iModelConnection, hilitedElementsQueryCache, group, colorProperty]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!colorProperty || resolvedHiliteIds.length === 0) {
|
|
37
58
|
return;
|
|
38
59
|
}
|
|
39
|
-
visualizeElements([
|
|
40
|
-
void zoomToElements([
|
|
41
|
-
}, [
|
|
60
|
+
visualizeElements([resolvedHiliteIds[0]], "red");
|
|
61
|
+
void zoomToElements([resolvedHiliteIds[0]]);
|
|
62
|
+
}, [colorProperty, resolvedHiliteIds]);
|
|
42
63
|
useEffect(() => {
|
|
43
|
-
if (
|
|
64
|
+
if (!colorProperty || resolvedHiliteIds.length === 0) {
|
|
44
65
|
return;
|
|
45
66
|
}
|
|
46
67
|
const setContext = async () => {
|
|
47
68
|
if (bboxDecorator) {
|
|
48
|
-
await bboxDecorator.setContext(
|
|
69
|
+
await bboxDecorator.setContext(resolvedHiliteIds[0]);
|
|
49
70
|
setInferredSpatialData(bboxDecorator.getInferredSpatialData());
|
|
50
71
|
}
|
|
51
72
|
};
|
|
52
73
|
void setContext();
|
|
53
|
-
}, [bboxDecorator,
|
|
74
|
+
}, [bboxDecorator, colorProperty, resolvedHiliteIds]);
|
|
54
75
|
useEffect(() => {
|
|
55
76
|
if (bboxDecorator && type && inferredSpatialData) {
|
|
56
|
-
inferredSpatialData.has(BboxDimension[type])
|
|
77
|
+
inferredSpatialData.has(BboxDimension[type]) && colorProperty
|
|
57
78
|
? bboxDecorator.drawContext(BboxDimension[type])
|
|
58
79
|
: bboxDecorator.clearContext();
|
|
59
80
|
}
|
|
60
|
-
}, [bboxDecorator, inferredSpatialData, type]);
|
|
81
|
+
}, [bboxDecorator, colorProperty, inferredSpatialData, type]);
|
|
61
82
|
const onSave = async () => {
|
|
62
83
|
if (!validator.allValid()) {
|
|
63
84
|
showValidationMessage(true);
|
|
@@ -66,19 +87,23 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
|
|
|
66
87
|
try {
|
|
67
88
|
setIsLoading(true);
|
|
68
89
|
const accessToken = await getAccessToken();
|
|
69
|
-
|
|
70
|
-
? await mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId,
|
|
90
|
+
calculatedProperty
|
|
91
|
+
? await mappingClient.updateCalculatedProperty(accessToken, iModelId, mappingId, group.id, calculatedProperty.id, {
|
|
71
92
|
propertyName,
|
|
72
93
|
type,
|
|
73
94
|
})
|
|
74
|
-
: await mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId,
|
|
95
|
+
: await mappingClient.createCalculatedProperty(accessToken, iModelId, mappingId, group.id, {
|
|
75
96
|
propertyName,
|
|
76
97
|
type,
|
|
77
98
|
});
|
|
78
|
-
|
|
99
|
+
onSaveSuccess();
|
|
100
|
+
setPropertyName("");
|
|
101
|
+
setType(CalculatedPropertyType.Undefined);
|
|
79
102
|
}
|
|
80
103
|
catch (error) {
|
|
81
104
|
handleError(error.status);
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
82
107
|
setIsLoading(false);
|
|
83
108
|
}
|
|
84
109
|
};
|
|
@@ -87,12 +112,11 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
|
|
|
87
112
|
return (inferredSpatialData === null || inferredSpatialData === void 0 ? void 0 : inferredSpatialData.has(BboxDimension[value])) && (React.createElement("div", null, `${(_a = inferredSpatialData === null || inferredSpatialData === void 0 ? void 0 : inferredSpatialData.get(BboxDimension[value])) === null || _a === void 0 ? void 0 : _a.toPrecision(4)}m`));
|
|
88
113
|
};
|
|
89
114
|
return (React.createElement(React.Fragment, null,
|
|
90
|
-
React.createElement(WidgetHeader, { title: property
|
|
91
|
-
? `${(_c = property === null || property === void 0 ? void 0 : property.propertyName) !== null && _c !== void 0 ? _c : ""}`
|
|
92
|
-
: "Create Calculated Property", returnFn: async () => returnFn(false) }),
|
|
93
115
|
React.createElement("div", { className: 'gmw-calculated-properties-action-container' },
|
|
94
116
|
React.createElement(Fieldset, { legend: 'Calculated Property Details', className: 'gmw-details-form' },
|
|
95
|
-
React.createElement(
|
|
117
|
+
React.createElement("div", { className: 'gmw-field-legend-container' },
|
|
118
|
+
React.createElement(Small, { className: 'gmw-field-legend' }, "Asterisk * indicates mandatory fields."),
|
|
119
|
+
React.createElement(ToggleSwitch, { label: 'Visualize Dimensions', labelPosition: 'left', disabled: isLoading, checked: colorProperty, onChange: () => setColorProperty((b) => !b) })),
|
|
96
120
|
React.createElement(LabeledInput, { value: propertyName, required: true, name: 'name', label: 'Name', onChange: (event) => {
|
|
97
121
|
setPropertyName(event.target.value);
|
|
98
122
|
validator.showMessageFor("name");
|
|
@@ -142,7 +166,6 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
|
|
|
142
166
|
getSpatialData(option.value)))), selectedItemRenderer: (option) => (React.createElement("div", { className: 'gmw-select-item' },
|
|
143
167
|
React.createElement("div", null, option.label),
|
|
144
168
|
getSpatialData(option.value))), onShow: () => { }, onHide: () => { } }))),
|
|
145
|
-
React.createElement(ActionPanel, { onSave: onSave, onCancel:
|
|
169
|
+
React.createElement(ActionPanel, { onSave: onSave, onCancel: onClickCancel, isSavingDisabled: !(type && propertyName), isLoading: isLoading })));
|
|
146
170
|
};
|
|
147
|
-
export default CalculatedPropertyAction;
|
|
148
171
|
//# sourceMappingURL=CalculatedPropertyAction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,aAAa,EACb,uBAAuB,GACxB,MAAM,0CAA0C,CAAC;AAClD,OAAO,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAWhE,MAAM,wBAAwB,GAAG,CAAC,EAChC,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,EACH,QAAQ,GACsB,EAAE,EAAE;;IAClC,MAAM,EAAE,cAAc,E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,sBAAsB,CAAC,oCAAoC;4BAClE,KAAK,EAAE,8BAA8B;yBACtC;wBACD;4BACE,KAAK,EAAE,sBAAsB,CAAC,yCAAyC;4BACvE,KAAK,EAAE,mCAAmC;yBAC3C;wBACD;4BACE,KAAK,EAAE,sBAAsB,CAAC,qCAAqC;4BACnE,KAAK,EAAE,+BAA+B;yBACvC;qBACF,EACD,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CAC9C,oBAAC,QAAQ;wBACP,6BAAK,SAAS,EAAC,qBAAqB;4BAClC,iCAAM,MAAM,CAAC,KAAK,CAAO;4BACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACG,CACZ,EACD,oBAAoB,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,6BAAK,SAAS,EAAC,iBAAiB;wBAC9B,iCAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,EACD,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EACrC,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,wBAAwB,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 { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { ICalculatedPropertyTyped } from \"./CalculatedPropertyTable\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport { CalculatedPropertyType } from \"@itwin/insights-client\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n property?: ICalculatedPropertyTyped;\n ids: string[];\n returnFn: (modified: boolean) => Promise<void>;\n}\n\nconst CalculatedPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n property,\n ids,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const { getAccessToken } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n property?.propertyName ?? \"\",\n );\n const [type, setType] = useState<CalculatedPropertyType>(property?.type ?? CalculatedPropertyType.Undefined);\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n visualizeElements([ids[0]], \"red\");\n void zoomToElements([ids[0]]);\n }, [ids]);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(ids[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, ids]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension])\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const accessToken = await getAccessToken();\n\n property\n ? await mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n property.id,\n {\n propertyName,\n type,\n },\n )\n : await mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n {\n propertyName,\n type,\n },\n );\n await returnFn(true);\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <WidgetHeader\n title={\n property\n ? `${property?.propertyName ?? \"\"}`\n : \"Create Calculated Property\"\n }\n returnFn={async () => returnFn(false)}\n />\n <div className='gmw-calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='gmw-details-form'>\n <Small className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledSelect<CalculatedPropertyType>\n label='Quantity Type'\n required\n options={[\n { value: CalculatedPropertyType.Length, label: \"Length\" },\n { value: CalculatedPropertyType.Area, label: \"Area\" },\n { value: CalculatedPropertyType.Volume, label: \"Volume\" },\n {\n value: CalculatedPropertyType.BoundingBoxLongestEdgeLength,\n label: \"Longest Edge Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxIntermediateEdgeLength,\n label: \"Intermediate Edge Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxShortestEdgeLength,\n label: \"Shortest Edge Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxDiagonalLength,\n label: \"Diagonal Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxLongestFaceDiagonalLength,\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxIntermediateFaceDiagonalLength,\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxShortestFaceDiagonalLength,\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gmw-gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='gmw-select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={async () => returnFn(false)}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyAction;\n"]}
|
|
1
|
+
{"version":3,"file":"Calculated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AE,CAAC,MAA4B,EAAE,EAAE,CAAC,CAC9C,oBAAC,QAAQ;wBACP,6BAAK,SAAS,EAAC,qBAAqB;4BAClC,iCAAM,MAAM,CAAC,KAAK,CAAO;4BACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACG,CACZ,EACD,oBAAoB,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,CACtD,6BAAK,SAAS,EAAC,iBAAiB;wBAC9B,iCAAM,MAAM,CAAC,KAAK,CAAO;wBACxB,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,EACD,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,oBAAC,WAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,aAAa,EACvB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n ToggleSwitch,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError } from \"./utils\";\nimport { clearEmphasizedOverriddenElements, visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport type { CalculatedProperty, Group } from \"@itwin/insights-client\";\nimport { CalculatedPropertyType } from \"@itwin/insights-client\";\nimport { useGroupHilitedElementsContext } from \"./context/GroupHilitedElementsContext\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { getHiliteIdsAndKeysetFromGroup } from \"./groupsHelpers\";\n\nexport interface CalculatedPropertyActionProps {\n mappingId: string;\n group: Group;\n calculatedProperty?: CalculatedProperty;\n onSaveSuccess: () => void;\n onClickCancel?: () => void;\n}\n\nexport const CalculatedPropertyAction = ({\n mappingId,\n group,\n calculatedProperty,\n onSaveSuccess,\n onClickCancel,\n}: CalculatedPropertyActionProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [propertyName, setPropertyName] = useState<string>(\n calculatedProperty?.propertyName ?? \"\",\n );\n const iModelConnection = useActiveIModelConnection();\n const [type, setType] = useState<CalculatedPropertyType>(calculatedProperty?.type ?? CalculatedPropertyType.Undefined);\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const { hilitedElementsQueryCache } = useGroupHilitedElementsContext();\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n const [resolvedHiliteIds, setResolvedHiliteIds] = useState<string[]>([]);\n const [colorProperty, setColorProperty] = useState<boolean>(false);\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n const initialize = async () => {\n if (!iModelConnection) return;\n clearEmphasizedOverriddenElements();\n if (!colorProperty) return;\n setIsLoading(true);\n const result = await getHiliteIdsAndKeysetFromGroup(iModelConnection, group, hilitedElementsQueryCache);\n setResolvedHiliteIds(result.ids);\n setIsLoading(false);\n };\n void initialize();\n }, [iModelConnection, hilitedElementsQueryCache, group, colorProperty]);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n visualizeElements([resolvedHiliteIds[0]], \"red\");\n void zoomToElements([resolvedHiliteIds[0]]);\n }, [colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (!colorProperty || resolvedHiliteIds.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(resolvedHiliteIds[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, colorProperty, resolvedHiliteIds]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension]) && colorProperty\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, colorProperty, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const accessToken = await getAccessToken();\n\n calculatedProperty\n ? await mappingClient.updateCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n calculatedProperty.id,\n {\n propertyName,\n type,\n },\n )\n : await mappingClient.createCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n group.id,\n {\n propertyName,\n type,\n },\n );\n onSaveSuccess();\n setPropertyName(\"\");\n setType(CalculatedPropertyType.Undefined);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <div className='gmw-calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='gmw-details-form'>\n <div className='gmw-field-legend-container'>\n <Small className='gmw-field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <ToggleSwitch\n label='Visualize Dimensions'\n labelPosition='left'\n disabled={isLoading}\n checked={colorProperty}\n onChange={() => setColorProperty((b) => !b)}\n ></ToggleSwitch>\n </div>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledSelect<CalculatedPropertyType>\n label='Quantity Type'\n required\n options={[\n { value: CalculatedPropertyType.Length, label: \"Length\" },\n { value: CalculatedPropertyType.Area, label: \"Area\" },\n { value: CalculatedPropertyType.Volume, label: \"Volume\" },\n {\n value: CalculatedPropertyType.BoundingBoxLongestEdgeLength,\n label: \"Longest Edge Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxIntermediateEdgeLength,\n label: \"Intermediate Edge Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxShortestEdgeLength,\n label: \"Shortest Edge Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxDiagonalLength,\n label: \"Diagonal Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxLongestFaceDiagonalLength,\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxIntermediateFaceDiagonalLength,\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: CalculatedPropertyType.BoundingBoxShortestFaceDiagonalLength,\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gmw-gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='gmw-select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={onClickCancel}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n"]}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import type { CreateTypeFromInterface } from "../utils";
|
|
3
|
-
import { PropertyMenuView } from "./PropertyMenu";
|
|
4
|
-
import type { CellProps } from "react-table";
|
|
1
|
+
/// <reference types="react" />
|
|
5
2
|
import type { CalculatedProperty } from "@itwin/insights-client";
|
|
6
|
-
|
|
7
|
-
interface CalculatedPropertyTableProps {
|
|
8
|
-
iModelId: string;
|
|
3
|
+
import "./CalculatedPropertyTable.scss";
|
|
4
|
+
export interface CalculatedPropertyTableProps {
|
|
9
5
|
mappingId: string;
|
|
10
6
|
groupId: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
refreshCalculatedProperties: () => Promise<void>;
|
|
17
|
-
selectedCalculatedProperty?: ICalculatedPropertyTyped;
|
|
7
|
+
onClickAdd?: () => void;
|
|
8
|
+
onClickModify?: (value: CalculatedProperty) => void;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
calculatedProperties: CalculatedProperty[];
|
|
11
|
+
refresh: () => Promise<void>;
|
|
18
12
|
}
|
|
19
|
-
declare const CalculatedPropertyTable: ({
|
|
20
|
-
export default CalculatedPropertyTable;
|
|
13
|
+
export declare const CalculatedPropertyTable: ({ mappingId, groupId, onClickAdd, onClickModify, isLoading, calculatedProperties, refresh, }: CalculatedPropertyTableProps) => JSX.Element;
|
|
21
14
|
//# sourceMappingURL=CalculatedPropertyTable.d.ts.map
|
|
@@ -1,20 +1,19 @@
|
|
|
1
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 {
|
|
6
|
-
import {
|
|
7
|
-
import React, {
|
|
8
|
-
import { PropertyMenuView } from "./PropertyMenu";
|
|
9
|
-
import DeleteModal from "./DeleteModal";
|
|
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 { SvgDelete, SvgEdit, SvgMore } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import { DropdownMenu, IconButton, MenuItem, } from "@itwin/itwinui-react";
|
|
7
|
+
import React, { useCallback } from "react";
|
|
10
8
|
import { useMappingClient } from "./context/MappingClientContext";
|
|
9
|
+
import "./CalculatedPropertyTable.scss";
|
|
10
|
+
import { PropertyNameCell } from "./PropertyNameCell";
|
|
11
|
+
import { PropertyTable } from "./PropertyTable";
|
|
11
12
|
import { useGroupingMappingApiConfig } from "./context/GroupingApiConfigContext";
|
|
12
|
-
const CalculatedPropertyTable = ({
|
|
13
|
-
var _a;
|
|
14
|
-
const { getAccessToken } = useGroupingMappingApiConfig();
|
|
13
|
+
export const CalculatedPropertyTable = ({ mappingId, groupId, onClickAdd, onClickModify, isLoading, calculatedProperties, refresh, }) => {
|
|
15
14
|
const mappingClient = useMappingClient();
|
|
16
|
-
const
|
|
17
|
-
const
|
|
15
|
+
const { getAccessToken, iModelId } = useGroupingMappingApiConfig();
|
|
16
|
+
const columnsFactory = useCallback((handleShowDeleteModal) => [
|
|
18
17
|
{
|
|
19
18
|
Header: "Table",
|
|
20
19
|
columns: [
|
|
@@ -22,7 +21,7 @@ const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalc
|
|
|
22
21
|
id: "propertyName",
|
|
23
22
|
Header: "Calculated Property",
|
|
24
23
|
accessor: "propertyName",
|
|
25
|
-
Cell: (value) => (React.createElement(
|
|
24
|
+
Cell: (value) => (React.createElement(PropertyNameCell, { property: value.row.original, onClickModify: onClickModify })),
|
|
26
25
|
},
|
|
27
26
|
{
|
|
28
27
|
id: "dropdown",
|
|
@@ -30,14 +29,20 @@ const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalc
|
|
|
30
29
|
width: 80,
|
|
31
30
|
Cell: (value) => {
|
|
32
31
|
return (React.createElement(DropdownMenu, { menuItems: (close) => [
|
|
33
|
-
|
|
32
|
+
onClickModify
|
|
33
|
+
? [
|
|
34
|
+
React.createElement(MenuItem, { key: 0, onClick: () => {
|
|
35
|
+
onClickModify(value.row.original);
|
|
36
|
+
close();
|
|
37
|
+
}, icon: React.createElement(SvgEdit, null) }, "Modify"),
|
|
38
|
+
]
|
|
39
|
+
: [],
|
|
34
40
|
React.createElement(MenuItem, { key: 1, onClick: () => {
|
|
35
|
-
|
|
36
|
-
setShowCalculatedPropertyDeleteModal(true);
|
|
41
|
+
handleShowDeleteModal(value.row.original);
|
|
37
42
|
close();
|
|
38
43
|
}, icon: React.createElement(SvgDelete, null) }, "Remove"),
|
|
39
|
-
] },
|
|
40
|
-
React.createElement(IconButton, { styleType:
|
|
44
|
+
].flatMap((p) => p) },
|
|
45
|
+
React.createElement(IconButton, { styleType: "borderless" },
|
|
41
46
|
React.createElement(SvgMore, { style: {
|
|
42
47
|
width: "16px",
|
|
43
48
|
height: "16px",
|
|
@@ -46,17 +51,11 @@ const CalculatedPropertyTable = ({ iModelId, mappingId, groupId, setSelectedCalc
|
|
|
46
51
|
},
|
|
47
52
|
],
|
|
48
53
|
},
|
|
49
|
-
], [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
React.createElement(DeleteModal, { entityName: (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.propertyName) !== null && _a !== void 0 ? _a : "", show: showCalculatedPropertyDeleteModal, setShow: setShowCalculatedPropertyDeleteModal, onDelete: async () => {
|
|
56
|
-
var _a;
|
|
57
|
-
const accessToken = await getAccessToken();
|
|
58
|
-
await mappingClient.deleteCalculatedProperty(accessToken, iModelId, mappingId, groupId, (_a = selectedCalculatedProperty === null || selectedCalculatedProperty === void 0 ? void 0 : selectedCalculatedProperty.id) !== null && _a !== void 0 ? _a : "");
|
|
59
|
-
}, refresh: refreshCalculatedProperties })));
|
|
54
|
+
], [onClickModify]);
|
|
55
|
+
const deleteProperty = useCallback(async (propertyId) => {
|
|
56
|
+
const accessToken = await getAccessToken();
|
|
57
|
+
await mappingClient.deleteCalculatedProperty(accessToken, iModelId, mappingId, groupId, propertyId);
|
|
58
|
+
}, [getAccessToken, groupId, iModelId, mappingClient, mappingId]);
|
|
59
|
+
return (React.createElement(PropertyTable, { propertyType: "Calculated", columnsFactory: columnsFactory, data: calculatedProperties, isLoading: isLoading, onClickAdd: onClickAdd, refreshProperties: refresh, deleteProperty: deleteProperty }));
|
|
60
60
|
};
|
|
61
|
-
export default CalculatedPropertyTable;
|
|
62
61
|
//# sourceMappingURL=CalculatedPropertyTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedPropertyTable.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyTable.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"CalculatedPropertyTable.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyTable.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,QAAQ,GACT,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AC9B,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport { SvgDelete, SvgEdit, SvgMore } from \"@itwin/itwinui-icons-react\";\nimport {\n DropdownMenu,\n IconButton,\n MenuItem,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback } from \"react\";\nimport type { CellProps } from \"react-table\";\nimport type { CalculatedProperty } from \"@itwin/insights-client\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport \"./CalculatedPropertyTable.scss\";\nimport { PropertyNameCell } from \"./PropertyNameCell\";\nimport { PropertyTable } from \"./PropertyTable\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\nexport interface CalculatedPropertyTableProps {\n mappingId: string;\n groupId: string;\n onClickAdd?: () => void;\n onClickModify?: (value: CalculatedProperty) => void;\n isLoading: boolean;\n calculatedProperties: CalculatedProperty[];\n refresh: () => Promise<void>;\n}\n\nexport const CalculatedPropertyTable = ({\n mappingId,\n groupId,\n onClickAdd,\n onClickModify,\n isLoading,\n calculatedProperties,\n refresh,\n}: CalculatedPropertyTableProps) => {\n const mappingClient = useMappingClient();\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n\n const columnsFactory = useCallback(\n (handleShowDeleteModal: (value: CalculatedProperty) => void) => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"propertyName\",\n Header: \"Calculated Property\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<CalculatedProperty>) => (\n <PropertyNameCell\n property={value.row.original}\n onClickModify={onClickModify}\n />\n ),\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<CalculatedProperty>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) =>\n [\n onClickModify\n ? [\n <MenuItem\n key={0}\n onClick={() => {\n onClickModify(\n value.row.original\n );\n close();\n }\n }\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n ]\n : [],\n <MenuItem\n key={1}\n onClick={() => {\n handleShowDeleteModal(value.row.original);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ].flatMap((p) => p)\n }\n >\n <IconButton styleType=\"borderless\">\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n },\n ],\n [onClickModify]\n );\n\n const deleteProperty = useCallback(async (propertyId: string) => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteCalculatedProperty(\n accessToken,\n iModelId,\n mappingId,\n groupId,\n propertyId,\n );\n }, [getAccessToken, groupId, iModelId, mappingClient, mappingId]);\n\n return (\n <PropertyTable\n propertyType=\"Calculated\"\n columnsFactory={columnsFactory}\n data={calculatedProperties}\n isLoading={isLoading}\n onClickAdd={onClickAdd}\n refreshProperties={refresh}\n deleteProperty={deleteProperty}\n />\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
|
+
|
|
6
|
+
.gmw-field-legend-container {
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import "./CalculatedPropertyAction.scss";
|
|
3
|
-
import type { ICustomCalculationTyped } from "./CustomCalculationTable";
|
|
4
3
|
import "./CustomCalculationAction.scss";
|
|
5
|
-
import type {
|
|
6
|
-
interface
|
|
7
|
-
iModelId: string;
|
|
4
|
+
import type { CustomCalculation } from "@itwin/insights-client";
|
|
5
|
+
export interface CustomCalculationActionProps {
|
|
8
6
|
mappingId: string;
|
|
9
7
|
groupId: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
customCalculation?: CustomCalculation;
|
|
9
|
+
onSaveSuccess: () => void;
|
|
10
|
+
onClickCancel?: () => void;
|
|
13
11
|
}
|
|
14
|
-
declare const CustomCalculationAction: ({
|
|
15
|
-
export default CustomCalculationAction;
|
|
12
|
+
export declare const CustomCalculationAction: ({ mappingId, groupId, customCalculation, onSaveSuccess, onClickCancel, }: CustomCalculationActionProps) => JSX.Element;
|
|
16
13
|
//# sourceMappingURL=CustomCalculationAction.d.ts.map
|