@itwin/grouping-mapping-widget 0.26.1 → 0.27.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/WidgetShell/Router/GroupingMappingRouter.js +1 -15
- package/lib/cjs/WidgetShell/Router/GroupingMappingRouter.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useKeySetHiliteQueries.d.ts +1 -1
- package/lib/cjs/components/Mappings/MappingViewActionGroup.d.ts +1 -1
- package/lib/cjs/components/Mappings/MappingViewActionGroup.js +1 -2
- package/lib/cjs/components/Mappings/MappingViewActionGroup.js.map +1 -1
- package/lib/cjs/components/Mappings/MappingsView.js +1 -1
- package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.d.ts +2 -0
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +2 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.d.ts +7 -8
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +21 -61
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.d.ts +5 -9
- package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js +3 -12
- package/lib/cjs/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.d.ts +8 -9
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js +17 -164
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationAction.scss +4 -3
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js +76 -19
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyAction.scss +3 -2
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js +10 -2
- package/lib/cjs/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyMenu.d.ts +1 -1
- package/lib/cjs/components/Properties/PropertyMenu.js +2 -7
- package/lib/cjs/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/cjs/components/Properties/ScrollableExpandableBlock.d.ts +11 -0
- package/lib/cjs/components/Properties/ScrollableExpandableBlock.js +55 -0
- package/lib/cjs/components/Properties/ScrollableExpandableBlock.js.map +1 -0
- package/lib/cjs/components/Properties/hooks/useFormulaValidation.d.ts +6 -3
- package/lib/cjs/components/Properties/hooks/useFormulaValidation.js +59 -13
- package/lib/cjs/components/Properties/hooks/useFormulaValidation.js.map +1 -1
- package/lib/cjs/components/Properties/hooks/useForwardRef.d.ts +3 -0
- package/lib/cjs/components/Properties/hooks/useForwardRef.js +20 -0
- package/lib/cjs/components/Properties/hooks/useForwardRef.js.map +1 -0
- package/lib/cjs/components/SharedComponents/ActionPanel.d.ts +3 -1
- package/lib/cjs/components/SharedComponents/ActionPanel.js +3 -3
- package/lib/cjs/components/SharedComponents/ActionPanel.js.map +1 -1
- package/lib/cjs/formula/FormulaDataTypeResolver.d.ts +3 -2
- package/lib/cjs/formula/FormulaDataTypeResolver.js +10 -6
- package/lib/cjs/formula/FormulaDataTypeResolver.js.map +1 -1
- package/lib/cjs/grouping-mapping-widget.d.ts +0 -2
- package/lib/cjs/grouping-mapping-widget.js +1 -5
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/esm/WidgetShell/Router/GroupingMappingRouter.js +1 -15
- package/lib/esm/WidgetShell/Router/GroupingMappingRouter.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useKeySetHiliteQueries.d.ts +1 -1
- package/lib/esm/components/Mappings/MappingViewActionGroup.d.ts +1 -1
- package/lib/esm/components/Mappings/MappingViewActionGroup.js +1 -2
- package/lib/esm/components/Mappings/MappingViewActionGroup.js.map +1 -1
- package/lib/esm/components/Mappings/MappingsView.js +1 -1
- package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.d.ts +2 -0
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js +2 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.d.ts +7 -8
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js +23 -60
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals.js.map +1 -1
- package/lib/esm/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.d.ts +5 -9
- package/lib/esm/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js +4 -13
- package/lib/esm/components/Properties/CalculatedProperties/SharedCalculatedPropertyForms.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.d.ts +8 -9
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js +18 -142
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.js.map +1 -1
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationAction.scss +4 -3
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js +79 -22
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.js.map +1 -1
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyAction.scss +3 -2
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js +12 -4
- package/lib/esm/components/Properties/GroupProperties/GroupPropertyTable.js.map +1 -1
- package/lib/esm/components/Properties/PropertyMenu.d.ts +1 -1
- package/lib/esm/components/Properties/PropertyMenu.js +2 -7
- package/lib/esm/components/Properties/PropertyMenu.js.map +1 -1
- package/lib/esm/components/Properties/ScrollableExpandableBlock.d.ts +11 -0
- package/lib/esm/components/Properties/ScrollableExpandableBlock.js +29 -0
- package/lib/esm/components/Properties/ScrollableExpandableBlock.js.map +1 -0
- package/lib/esm/components/Properties/hooks/useFormulaValidation.d.ts +6 -3
- package/lib/esm/components/Properties/hooks/useFormulaValidation.js +57 -12
- package/lib/esm/components/Properties/hooks/useFormulaValidation.js.map +1 -1
- package/lib/esm/components/Properties/hooks/useForwardRef.d.ts +3 -0
- package/lib/esm/components/Properties/hooks/useForwardRef.js +16 -0
- package/lib/esm/components/Properties/hooks/useForwardRef.js.map +1 -0
- package/lib/esm/components/SharedComponents/ActionPanel.d.ts +3 -1
- package/lib/esm/components/SharedComponents/ActionPanel.js +3 -3
- package/lib/esm/components/SharedComponents/ActionPanel.js.map +1 -1
- package/lib/esm/formula/FormulaDataTypeResolver.d.ts +3 -2
- package/lib/esm/formula/FormulaDataTypeResolver.js +10 -6
- package/lib/esm/formula/FormulaDataTypeResolver.js.map +1 -1
- package/lib/esm/grouping-mapping-widget.d.ts +0 -2
- package/lib/esm/grouping-mapping-widget.js +0 -2
- package/lib/esm/grouping-mapping-widget.js.map +1 -1
- package/package.json +1 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.d.ts +0 -14
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +0 -87
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +0 -1
- package/lib/cjs/components/Properties/CalculatedProperties/CalculatedPropertyTable.scss +0 -9
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.d.ts +0 -13
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js +0 -91
- package/lib/cjs/components/Properties/CustomCalculations/CustomCalculationTable.js.map +0 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.d.ts +0 -14
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js +0 -60
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.js.map +0 -1
- package/lib/esm/components/Properties/CalculatedProperties/CalculatedPropertyTable.scss +0 -9
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.d.ts +0 -13
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js +0 -64
- package/lib/esm/components/Properties/CustomCalculations/CustomCalculationTable.js.map +0 -1
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
flex-grow: 1;
|
|
41
41
|
gap: var(--iui-size-s);
|
|
42
42
|
min-height: calc(var(--iui-size-3x1) * 2);
|
|
43
|
-
padding: var(--iui-size-s) var(--iui-size-m);
|
|
44
43
|
min-width: 0;
|
|
45
44
|
.gmw-property-view-button {
|
|
46
45
|
display: flex;
|
|
46
|
+
margin-bottom: 7.5xp;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
justify-content: center;
|
|
53
53
|
align-items: center;
|
|
54
54
|
flex-direction: column;
|
|
55
|
+
flex: 1;
|
|
55
56
|
gap: var(--iui-size-s);
|
|
56
|
-
padding: var(--iui-size-s) var(--iui-size-m);
|
|
57
57
|
height: 100%;
|
|
58
|
+
padding-top: var(--iui-size-s);
|
|
58
59
|
}
|
|
@@ -43,13 +43,21 @@ const GroupPropertyTable = ({ mappingId, groupId, onClickAdd, onClickModify, isL
|
|
|
43
43
|
const columnsFactory = (0, react_1.useCallback)((handleShowDeleteModal) => [
|
|
44
44
|
{
|
|
45
45
|
id: "propertyName",
|
|
46
|
-
Header: "Property",
|
|
47
46
|
accessor: "propertyName",
|
|
48
47
|
Cell: (value) => react_1.default.createElement(PropertyNameCell_1.PropertyNameCell, { property: value.row.original, onClickModify: onClickModify }),
|
|
49
48
|
},
|
|
49
|
+
{
|
|
50
|
+
id: "propertyTypeIcons",
|
|
51
|
+
Cell: (value) => (react_1.default.createElement(itwinui_react_1.Flex, { flexDirection: "row", gap: "xs" },
|
|
52
|
+
react_1.default.createElement(itwinui_react_1.Icon, { fill: value.row.original.ecProperties ? "informational" : "default" },
|
|
53
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgLabel, null)),
|
|
54
|
+
react_1.default.createElement(itwinui_react_1.Icon, { fill: value.row.original.calculatedPropertyType ? "informational" : "default" },
|
|
55
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgMeasure, null)),
|
|
56
|
+
react_1.default.createElement(itwinui_react_1.Icon, { fill: value.row.original.formula ? "informational" : "default" },
|
|
57
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgFunction, null)))),
|
|
58
|
+
},
|
|
50
59
|
{
|
|
51
60
|
id: "dropdown",
|
|
52
|
-
Header: "",
|
|
53
61
|
width: 80,
|
|
54
62
|
Cell: (value) => {
|
|
55
63
|
return (react_1.default.createElement(itwinui_react_1.DropdownMenu, { menuItems: (close) => [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupPropertyTable.js","sourceRoot":"","sources":["../../../../../src/components/Properties/GroupProperties/GroupPropertyTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,
|
|
1
|
+
{"version":3,"file":"GroupPropertyTable.js","sourceRoot":"","sources":["../../../../../src/components/Properties/GroupProperties/GroupPropertyTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,oEAA4G;AAC5G,wDAAsF;AACtF,+CAA2C;AAG3C,0DAAuD;AACvD,oDAAiD;AACjD,qFAAqF;AACrF,uDAAoE;AACpE,mFAA4E;AAarE,MAAM,kBAAkB,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAA2B,EAAE,EAAE;IACpJ,MAAM,gBAAgB,GAAG,IAAA,6CAAmB,GA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OAAO,CACL,8BAAC,6BAAa,IACZ,YAAY,EAAC,OAAO,EACpB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,EACtB,iBAAiB,EAAE,OAAO,EAC1B,cAAc,EAAE,cAAc,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC;AA/FW,QAAA,kBAAkB,sBA+F7B","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, SvgFunction, SvgLabel, SvgMeasure, SvgMore } from \"@itwin/itwinui-icons-react\";\nimport { DropdownMenu, Flex, Icon, IconButton, MenuItem } from \"@itwin/itwinui-react\";\nimport React, { useCallback } from \"react\";\nimport type { CellProps, Column } from \"react-table\";\nimport type { Property } from \"@itwin/insights-client\";\nimport { PropertyNameCell } from \"../PropertyNameCell\";\nimport { PropertyTable } from \"../PropertyTable\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { usePropertiesClient } from \"../../context/PropertiesClientContext\";\n\nexport interface GroupPropertyTableProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n onClickAdd?: () => void;\n onClickModify?: (value: Property) => void;\n isLoading: boolean;\n groupProperties: Property[];\n refresh: () => Promise<void>;\n}\n\nexport const GroupPropertyTable = ({ mappingId, groupId, onClickAdd, onClickModify, isLoading, groupProperties, refresh }: GroupPropertyTableProps) => {\n const propertiesClient = usePropertiesClient();\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const queryClient = useQueryClient();\n\n const columnsFactory = useCallback(\n (handleShowDeleteModal: (value: Property) => void): Column<Property>[] => [\n {\n id: \"propertyName\",\n accessor: \"propertyName\",\n Cell: (value: CellProps<Property>) => <PropertyNameCell property={value.row.original} onClickModify={onClickModify} />,\n },\n {\n id: \"propertyTypeIcons\",\n Cell: (value: CellProps<Property>) => (\n <Flex flexDirection={\"row\"} gap=\"xs\">\n <Icon fill={value.row.original.ecProperties ? \"informational\" : \"default\"}>\n <SvgLabel />\n </Icon>\n <Icon fill={value.row.original.calculatedPropertyType ? \"informational\" : \"default\"}>\n <SvgMeasure />\n </Icon>\n <Icon fill={value.row.original.formula ? \"informational\" : \"default\"}>\n <SvgFunction />\n </Icon>\n </Flex>\n ),\n },\n {\n id: \"dropdown\",\n width: 80,\n Cell: (value: CellProps<Property>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) =>\n [\n onClickModify\n ? [\n <MenuItem\n key={0}\n onClick={() => {\n onClickModify(value.row.original);\n close();\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\" title=\"Property Options\">\n <SvgMore />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n [onClickModify],\n );\n\n const { mutateAsync: deleteProperty } = useMutation({\n mutationFn: async (propertyId: string) => {\n const accessToken = await getAccessToken();\n await propertiesClient.deleteProperty(accessToken, mappingId, groupId, propertyId);\n },\n onSuccess: async () => {\n await queryClient.invalidateQueries({ queryKey: [\"properties\", iModelId, mappingId, groupId] });\n },\n });\n\n return (\n <PropertyTable\n propertyType=\"Group\"\n columnsFactory={columnsFactory}\n data={groupProperties}\n isLoading={isLoading}\n onClickAdd={onClickAdd}\n refreshProperties={refresh}\n deleteProperty={deleteProperty}\n />\n );\n};\n"]}
|
|
@@ -22,5 +22,5 @@ export interface PropertyMenuProps {
|
|
|
22
22
|
* Component to display the properties of a group.
|
|
23
23
|
* @public
|
|
24
24
|
*/
|
|
25
|
-
export declare const PropertyMenu: ({ mapping, group, onClickAddGroupProperty, onClickModifyGroupProperty,
|
|
25
|
+
export declare const PropertyMenu: ({ mapping, group, onClickAddGroupProperty, onClickModifyGroupProperty, hideGroupProps }: PropertyMenuProps) => JSX.Element;
|
|
26
26
|
//# sourceMappingURL=PropertyMenu.d.ts.map
|
|
@@ -32,8 +32,6 @@ const react_1 = __importStar(require("react"));
|
|
|
32
32
|
require("./PropertyMenu.scss");
|
|
33
33
|
const GroupPropertyTable_1 = require("./GroupProperties/GroupPropertyTable");
|
|
34
34
|
const GroupingApiConfigContext_1 = require("../context/GroupingApiConfigContext");
|
|
35
|
-
const CalculatedPropertyTable_1 = require("./CalculatedProperties/CalculatedPropertyTable");
|
|
36
|
-
const CustomCalculationTable_1 = require("./CustomCalculations/CustomCalculationTable");
|
|
37
35
|
const usePropertiesQuery_1 = require("./hooks/usePropertiesQuery");
|
|
38
36
|
const react_query_1 = require("@tanstack/react-query");
|
|
39
37
|
const PropertiesClientContext_1 = require("../context/PropertiesClientContext");
|
|
@@ -41,7 +39,7 @@ const PropertiesClientContext_1 = require("../context/PropertiesClientContext");
|
|
|
41
39
|
* Component to display the properties of a group.
|
|
42
40
|
* @public
|
|
43
41
|
*/
|
|
44
|
-
const PropertyMenu = ({ mapping, group, onClickAddGroupProperty, onClickModifyGroupProperty,
|
|
42
|
+
const PropertyMenu = ({ mapping, group, onClickAddGroupProperty, onClickModifyGroupProperty, hideGroupProps = false }) => {
|
|
45
43
|
const groupId = group.id;
|
|
46
44
|
const mappingId = mapping.id;
|
|
47
45
|
const { getAccessToken, iModelId } = (0, GroupingApiConfigContext_1.useGroupingMappingApiConfig)();
|
|
@@ -49,10 +47,7 @@ const PropertyMenu = ({ mapping, group, onClickAddGroupProperty, onClickModifyGr
|
|
|
49
47
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
50
48
|
const { data: groupProperties, isFetching: isLoadingGroupProperties } = (0, usePropertiesQuery_1.usePropertiesQuery)(iModelId, mappingId, groupId, getAccessToken, propertiesClient);
|
|
51
49
|
const refreshGroupProperties = (0, react_1.useCallback)(async () => queryClient.invalidateQueries({ queryKey: ["properties", iModelId, mappingId, group.id] }), [group.id, iModelId, mappingId, queryClient]);
|
|
52
|
-
return (react_1.default.createElement("div", { className: "gmw-property-menu-wrapper" },
|
|
53
|
-
!hideGroupProps && (react_1.default.createElement(GroupPropertyTable_1.GroupPropertyTable, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, onClickAdd: onClickAddGroupProperty, onClickModify: onClickModifyGroupProperty, isLoading: isLoadingGroupProperties, groupProperties: groupProperties ? groupProperties.properties : [], refresh: refreshGroupProperties })),
|
|
54
|
-
!hideCalculatedProps && (react_1.default.createElement(CalculatedPropertyTable_1.CalculatedPropertyTable, { mappingId: mappingId, groupId: groupId, onClickAdd: onClickAddCalculatedProperty, onClickModify: onClickModifyCalculatedProperty, isLoading: isLoadingGroupProperties, calculatedProperties: groupProperties ? groupProperties.properties : [], refresh: refreshGroupProperties })),
|
|
55
|
-
!hideCustomCalculationProps && (react_1.default.createElement(CustomCalculationTable_1.CustomCalculationTable, { mappingId: mappingId, groupId: groupId, onClickAdd: onClickAddCustomCalculationProperty, onClickModify: onClickModifyCustomCalculation, isLoading: isLoadingGroupProperties, customCalculations: groupProperties ? groupProperties.properties : [], refresh: refreshGroupProperties }))));
|
|
50
|
+
return (react_1.default.createElement("div", { className: "gmw-property-menu-wrapper" }, !hideGroupProps && (react_1.default.createElement(GroupPropertyTable_1.GroupPropertyTable, { iModelId: iModelId, mappingId: mappingId, groupId: groupId, onClickAdd: onClickAddGroupProperty, onClickModify: onClickModifyGroupProperty, isLoading: isLoadingGroupProperties, groupProperties: groupProperties ? groupProperties.properties : [], refresh: refreshGroupProperties }))));
|
|
56
51
|
};
|
|
57
52
|
exports.PropertyMenu = PropertyMenu;
|
|
58
53
|
//# sourceMappingURL=PropertyMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyMenu.js","sourceRoot":"","sources":["../../../../src/components/Properties/PropertyMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,+CAA2C;AAC3C,+BAA6B;AAC7B,6EAA0E;AAC1E,kFAAkF;AAElF,
|
|
1
|
+
{"version":3,"file":"PropertyMenu.js","sourceRoot":"","sources":["../../../../src/components/Properties/PropertyMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,+CAA2C;AAC3C,+BAA6B;AAC7B,6EAA0E;AAC1E,kFAAkF;AAElF,mEAAgE;AAChE,uDAAuD;AACvD,gFAAyE;AAoBzE;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,EAC3B,OAAO,EACP,KAAK,EACL,uBAAuB,EACvB,0BAA0B,EAC1B,cAAc,GAAG,KAAK,EACJ,EAAE,EAAE;IACtB,MAAM,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC;IACzB,MAAM,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC;IAC7B,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,IAAA,sDAA2B,GAAE,CAAC;IACnE,MAAM,gBAAgB,GAAG,IAAA,6CAAmB,GAAE,CAAC;IAC/C,MAAM,WAAW,GAAG,IAAA,4BAAc,GAAE,CAAC;IAErC,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,UAAU,EAAE,wBAAwB,EAAE,GAAG,IAAA,uCAAkB,EAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAE3J,MAAM,sBAAsB,GAAG,IAAA,mBAAW,EACxC,KAAK,IAAI,EAAE,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EACtG,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAC7C,CAAC;IAEF,OAAO,CACL,uCAAK,SAAS,EAAC,2BAA2B,IACvC,CAAC,cAAc,IAAI,CAClB,8BAAC,uCAAkB,IACjB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,uBAAuB,EACnC,aAAa,EAAE,0BAA0B,EACzC,SAAS,EAAE,wBAAwB,EACnC,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAClE,OAAO,EAAE,sBAAsB,GAC/B,CACH,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,YAAY,gBAoCvB","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, { useCallback } from \"react\";\nimport \"./PropertyMenu.scss\";\nimport { GroupPropertyTable } from \"./GroupProperties/GroupPropertyTable\";\nimport { useGroupingMappingApiConfig } from \"../context/GroupingApiConfigContext\";\nimport type { GroupMinimal, Mapping, Property } from \"@itwin/insights-client\";\nimport { usePropertiesQuery } from \"./hooks/usePropertiesQuery\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { usePropertiesClient } from \"../context/PropertiesClientContext\";\n\n/**\n * Props for the {@link PropertyMenu} component.\n * @public\n */\nexport interface PropertyMenuProps {\n mapping: Mapping;\n group: GroupMinimal;\n onClickAddGroupProperty?: () => void;\n onClickModifyGroupProperty?: (groupProperty: Property) => void;\n onClickAddCalculatedProperty?: () => void;\n onClickModifyCalculatedProperty?: (calculatedProperty: Property) => void;\n onClickAddCustomCalculationProperty?: () => void;\n onClickModifyCustomCalculation?: (customCalculation: Property) => void;\n hideGroupProps?: boolean;\n hideCalculatedProps?: boolean;\n hideCustomCalculationProps?: boolean;\n}\n\n/**\n * Component to display the properties of a group.\n * @public\n */\nexport const PropertyMenu = ({\n mapping,\n group,\n onClickAddGroupProperty,\n onClickModifyGroupProperty,\n hideGroupProps = false\n}: PropertyMenuProps) => {\n const groupId = group.id;\n const mappingId = mapping.id;\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const propertiesClient = usePropertiesClient();\n const queryClient = useQueryClient();\n\n const { data: groupProperties, isFetching: isLoadingGroupProperties } = usePropertiesQuery(iModelId, mappingId, groupId, getAccessToken, propertiesClient);\n\n const refreshGroupProperties = useCallback(\n async () => queryClient.invalidateQueries({ queryKey: [\"properties\", iModelId, mappingId, group.id] }),\n [group.id, iModelId, mappingId, queryClient],\n );\n\n return (\n <div className=\"gmw-property-menu-wrapper\">\n {!hideGroupProps && (\n <GroupPropertyTable\n iModelId={iModelId}\n mappingId={mappingId}\n groupId={groupId}\n onClickAdd={onClickAddGroupProperty}\n onClickModify={onClickModifyGroupProperty}\n isLoading={isLoadingGroupProperties}\n groupProperties={groupProperties ? groupProperties.properties : []}\n refresh={refreshGroupProperties}\n />\n )}\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ExpandableBlockProps } from "@itwin/itwinui-react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface ScrollableExpandableBlockProps extends ExpandableBlockProps {
|
|
4
|
+
parentRef?: React.RefObject<HTMLDivElement>;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
isExpanded: boolean;
|
|
7
|
+
setIsExpanded: (isExpanded: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const ScrollableExpandableBlock: React.ForwardRefExoticComponent<ScrollableExpandableBlockProps & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=ScrollableExpandableBlock.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ScrollableExpandableBlock = void 0;
|
|
27
|
+
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const useForwardRef_1 = require("./hooks/useForwardRef");
|
|
30
|
+
exports.ScrollableExpandableBlock = (0, react_1.forwardRef)(function ExpandableBlockWithRef(props, forwardRef) {
|
|
31
|
+
const { parentRef, children, isExpanded, setIsExpanded, ...rest } = props;
|
|
32
|
+
const forwardedRef = (0, useForwardRef_1.useForwardRef)(forwardRef);
|
|
33
|
+
const scrollToBlock = (0, react_1.useCallback)(() => {
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
if (parentRef?.current && forwardedRef.current) {
|
|
36
|
+
parentRef?.current.scrollTo({
|
|
37
|
+
top: forwardedRef.current.offsetTop,
|
|
38
|
+
behavior: "smooth",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}, 500);
|
|
42
|
+
}, [forwardedRef, parentRef]);
|
|
43
|
+
const handleToggle = (0, react_1.useCallback)((isExpanding) => {
|
|
44
|
+
if (isExpanding === true) {
|
|
45
|
+
setIsExpanded(true);
|
|
46
|
+
scrollToBlock();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
setIsExpanded(false);
|
|
50
|
+
}
|
|
51
|
+
}, [scrollToBlock, setIsExpanded]);
|
|
52
|
+
return (react_1.default.createElement("div", { ref: forwardedRef },
|
|
53
|
+
react_1.default.createElement(itwinui_react_1.ExpandableBlock, { onToggle: handleToggle, isExpanded: isExpanded, ...rest }, children)));
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=ScrollableExpandableBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollableExpandableBlock.js","sourceRoot":"","sources":["../../../../src/components/Properties/ScrollableExpandableBlock.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wDAAuD;AACvD,+CAAuD;AACvD,yDAAsD;AASzC,QAAA,yBAAyB,GAAG,IAAA,kBAAU,EAAiD,SAAS,sBAAsB,CAAC,KAAK,EAAE,UAAU;IACnJ,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAC,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACzE,MAAM,YAAY,GAAG,IAAA,6BAAa,EAAiB,UAAU,CAAC,CAAC;IAE/D,MAAM,aAAa,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACrC,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,SAAS,EAAE,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE;gBAC9C,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC;oBAC1B,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,SAAS;oBACnC,QAAQ,EAAE,QAAQ;iBACnB,CAAC,CAAC;aACJ;QACH,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAE9B,MAAM,YAAY,GAAG,IAAA,mBAAW,EAC9B,CAAC,WAAoB,EAAE,EAAE;QACvB,IAAI,WAAW,KAAK,IAAI,EAAE;YACxB,aAAa,CAAC,IAAI,CAAC,CAAC;YACpB,aAAa,EAAE,CAAC;SACjB;aAAK;YACJ,aAAa,CAAC,KAAK,CAAC,CAAC;SACtB;IACH,CAAC,EACD,CAAC,aAAa,EAAE,aAAa,CAAC,CAC/B,CAAC;IAEF,OAAO,CACL,uCAAK,GAAG,EAAE,YAAY;QACpB,8BAAC,+BAAe,IAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,KAAM,IAAI,IACtE,QAAQ,CACO,CACd,CACP,CAAC;AACJ,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 type { ExpandableBlockProps } from \"@itwin/itwinui-react\";\nimport { ExpandableBlock } from \"@itwin/itwinui-react\";\nimport React, { forwardRef, useCallback } from \"react\";\nimport { useForwardRef } from \"./hooks/useForwardRef\";\n\ninterface ScrollableExpandableBlockProps extends ExpandableBlockProps {\n parentRef?: React.RefObject<HTMLDivElement>;\n children: React.ReactNode;\n isExpanded: boolean;\n setIsExpanded: (isExpanded: boolean) => void;\n}\n\nexport const ScrollableExpandableBlock = forwardRef<HTMLDivElement, ScrollableExpandableBlockProps>(function ExpandableBlockWithRef(props, forwardRef) {\n const { parentRef, children, isExpanded, setIsExpanded,...rest } = props;\n const forwardedRef = useForwardRef<HTMLDivElement>(forwardRef);\n\n const scrollToBlock = useCallback(() => {\n setTimeout(() => {\n if (parentRef?.current && forwardedRef.current) {\n parentRef?.current.scrollTo({\n top: forwardedRef.current.offsetTop,\n behavior: \"smooth\",\n });\n }\n }, 500);\n }, [forwardedRef, parentRef]);\n\n const handleToggle = useCallback(\n (isExpanding: boolean) => {\n if (isExpanding === true) {\n setIsExpanded(true);\n scrollToBlock();\n }else {\n setIsExpanded(false);\n }\n },\n [scrollToBlock, setIsExpanded],\n );\n\n return (\n <div ref={forwardedRef}>\n <ExpandableBlock onToggle={handleToggle} isExpanded={isExpanded} {...rest}>\n {children}\n </ExpandableBlock>\n </div>\n );\n});\n"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { DataType
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { DataType as FormulaDataType } from "../../../formula/Types";
|
|
2
|
+
import type { Property } from "@itwin/insights-client";
|
|
3
|
+
import { DataType } from "@itwin/insights-client";
|
|
4
|
+
export declare function useFormulaValidation(formulaName: string, formula: string | undefined, groupProperties: Property[], setFormulaErrorMessage: (s: string | undefined) => void, providedDataType?: DataType): {
|
|
5
|
+
isFormulaValid: boolean;
|
|
4
6
|
inferredDataType: DataType | undefined;
|
|
5
7
|
forceValidation: () => boolean;
|
|
6
8
|
};
|
|
9
|
+
export declare const inferToPropertyDataType: (value: FormulaDataType | undefined) => DataType;
|
|
7
10
|
//# sourceMappingURL=useFormulaValidation.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useFormulaValidation = void 0;
|
|
3
|
+
exports.inferToPropertyDataType = exports.useFormulaValidation = 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.
|
|
@@ -8,26 +8,72 @@ exports.useFormulaValidation = void 0;
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const FormulaDataTypeResolver_1 = require("../../../formula/FormulaDataTypeResolver");
|
|
10
10
|
const utils_1 = require("../../../common/utils");
|
|
11
|
-
|
|
11
|
+
const insights_client_1 = require("@itwin/insights-client");
|
|
12
|
+
function validate(formulaName, formula, properties, setFormulaErrorMessage, setIsFormulaValid, setDataType, providedDataType) {
|
|
12
13
|
if (!formula) {
|
|
13
|
-
setFormulaErrorMessage(
|
|
14
|
-
|
|
14
|
+
setFormulaErrorMessage(undefined);
|
|
15
|
+
setIsFormulaValid(false);
|
|
15
16
|
setDataType(undefined);
|
|
16
17
|
return false;
|
|
17
18
|
}
|
|
18
|
-
const resolveFormulaType = (0, FormulaDataTypeResolver_1.resolveFormulaDataType)(formulaName, formula, properties);
|
|
19
|
-
const error = resolveFormulaType.errorMessage
|
|
19
|
+
const resolveFormulaType = (0, FormulaDataTypeResolver_1.resolveFormulaDataType)(formulaName, formula, properties, providedDataType);
|
|
20
|
+
const error = resolveFormulaType.errorMessage;
|
|
20
21
|
setFormulaErrorMessage(error);
|
|
21
|
-
|
|
22
|
-
setDataType(resolveFormulaType.value);
|
|
22
|
+
setIsFormulaValid(!error);
|
|
23
|
+
setDataType((0, exports.inferToPropertyDataType)(resolveFormulaType.value));
|
|
23
24
|
return !error;
|
|
24
25
|
}
|
|
25
|
-
const debouncedValidationFunc = (0, utils_1.debounce)(validate,
|
|
26
|
-
function useFormulaValidation(formulaName, formula,
|
|
27
|
-
const [
|
|
26
|
+
const debouncedValidationFunc = (0, utils_1.debounce)(validate, 2000);
|
|
27
|
+
function useFormulaValidation(formulaName, formula, groupProperties, setFormulaErrorMessage, providedDataType) {
|
|
28
|
+
const [isFormulaValid, setIsFormulaValid] = (0, react_1.useState)(false);
|
|
28
29
|
const [inferredDataType, setDataType] = (0, react_1.useState)(undefined);
|
|
29
|
-
(0, react_1.
|
|
30
|
-
|
|
30
|
+
const [propertyMap, setPropertyMap] = (0, react_1.useState)({});
|
|
31
|
+
(0, react_1.useEffect)(() => setPropertyMap(convertToPropertyMap(groupProperties)), [groupProperties]);
|
|
32
|
+
(0, react_1.useEffect)(() => debouncedValidationFunc(formulaName, formula, propertyMap, setFormulaErrorMessage, setIsFormulaValid, setDataType, providedDataType), [formulaName, formula, groupProperties, setFormulaErrorMessage, propertyMap, providedDataType]);
|
|
33
|
+
return {
|
|
34
|
+
isFormulaValid,
|
|
35
|
+
inferredDataType,
|
|
36
|
+
forceValidation: () => validate(formulaName, formula, propertyMap, setFormulaErrorMessage, setIsFormulaValid, setDataType, providedDataType),
|
|
37
|
+
};
|
|
31
38
|
}
|
|
32
39
|
exports.useFormulaValidation = useFormulaValidation;
|
|
40
|
+
const inferToPropertyDataType = (value) => {
|
|
41
|
+
switch (value) {
|
|
42
|
+
case "Double":
|
|
43
|
+
return insights_client_1.DataType.Double;
|
|
44
|
+
case "Integer":
|
|
45
|
+
return insights_client_1.DataType.Integer;
|
|
46
|
+
case "String":
|
|
47
|
+
return insights_client_1.DataType.String;
|
|
48
|
+
case "Boolean":
|
|
49
|
+
return insights_client_1.DataType.Boolean;
|
|
50
|
+
default:
|
|
51
|
+
return insights_client_1.DataType.String;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.inferToPropertyDataType = inferToPropertyDataType;
|
|
55
|
+
const convertToPropertyMap = (properties, selectedPropertyName) => {
|
|
56
|
+
const map = {};
|
|
57
|
+
const selectedLowerName = selectedPropertyName?.toLowerCase();
|
|
58
|
+
properties.forEach((p) => {
|
|
59
|
+
const lowerName = p.propertyName?.toLowerCase();
|
|
60
|
+
if (lowerName && lowerName !== selectedLowerName)
|
|
61
|
+
map[lowerName] = stringToPossibleDataType(p.dataType);
|
|
62
|
+
});
|
|
63
|
+
return map;
|
|
64
|
+
};
|
|
65
|
+
const stringToPossibleDataType = (str) => {
|
|
66
|
+
switch (str?.toLowerCase()) {
|
|
67
|
+
case "double":
|
|
68
|
+
return "Double";
|
|
69
|
+
case "integer":
|
|
70
|
+
return "Integer";
|
|
71
|
+
case "string":
|
|
72
|
+
return "String";
|
|
73
|
+
case "boolean":
|
|
74
|
+
return "Boolean";
|
|
75
|
+
default:
|
|
76
|
+
return "Undefined";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
33
79
|
//# sourceMappingURL=useFormulaValidation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormulaValidation.js","sourceRoot":"","sources":["../../../../../src/components/Properties/hooks/useFormulaValidation.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,iCAA4C;AAC5C,sFAAkF;AAElF,iDAAiD;AAEjD,SAAS,QAAQ,CACf,WAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"useFormulaValidation.js","sourceRoot":"","sources":["../../../../../src/components/Properties/hooks/useFormulaValidation.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,iCAA4C;AAC5C,sFAAkF;AAElF,iDAAiD;AAEjD,4DAAkD;AAElD,SAAS,QAAQ,CACf,WAAmB,EACnB,OAA2B,EAC3B,UAAuB,EACvB,sBAAuD,EACvD,iBAAuC,EACvC,WAA6D,EAC7D,gBAA2B;IAE3B,IAAI,CAAC,OAAO,EAAE;QACZ,sBAAsB,CAAC,SAAS,CAAC,CAAC;QAClC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACzB,WAAW,CAAC,SAAS,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;KACd;IAED,MAAM,kBAAkB,GAAG,IAAA,gDAAsB,EAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACtG,MAAM,KAAK,GAAG,kBAAkB,CAAC,YAAY,CAAC;IAC9C,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9B,iBAAiB,CAAC,CAAC,KAAK,CAAC,CAAC;IAC1B,WAAW,CAAC,IAAA,+BAAuB,EAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,OAAO,CAAC,KAA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O,CAAC;QAC1B,KAAK,QAAQ;YACX,OAAO,0BAAQ,CAAC,MAAM,CAAC;QACzB,KAAK,SAAS;YACZ,OAAO,0BAAQ,CAAC,OAAO,CAAC;QAC1B;YACE,OAAO,0BAAQ,CAAC,MAAM,CAAC;KAC1B;AACH,CAAC,CAAC;AAbW,QAAA,uBAAuB,2BAalC;AAEF,MAAM,oBAAoB,GAAG,CAAC,UAAsB,EAAE,oBAA6B,EAAe,EAAE;IAClG,MAAM,GAAG,GAAgB,EAAE,CAAC;IAC5B,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,WAAW,EAAE,CAAC;IAE9D,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACvB,MAAM,SAAS,GAAG,CAAC,CAAC,YAAY,EAAE,WAAW,EAAE,CAAC;QAChD,IAAI,SAAS,IAAI,SAAS,KAAK,iBAAiB;YAAE,GAAG,CAAC,SAAS,CAAC,GAAG,wBAAwB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC1G,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,GAAY,EAAoB,EAAE;IAClE,QAAQ,GAAG,EAAE,WAAW,EAAE,EAAE;QAC1B,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,WAAW,CAAC;KACtB;AACH,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 { useEffect, useState } from \"react\";\nimport { resolveFormulaDataType } from \"../../../formula/FormulaDataTypeResolver\";\nimport type { DataType as FormulaDataType, PossibleDataType, PropertyMap } from \"../../../formula/Types\";\nimport { debounce } from \"../../../common/utils\";\nimport type { Property } from \"@itwin/insights-client\";\nimport { DataType } from \"@itwin/insights-client\";\n\nfunction validate(\n formulaName: string,\n formula: string | undefined,\n properties: PropertyMap,\n setFormulaErrorMessage: (s: string | undefined) => void,\n setIsFormulaValid: (b: boolean) => void,\n setDataType: (inferredDataType: DataType | undefined) => void,\n providedDataType?: DataType,\n): boolean {\n if (!formula) {\n setFormulaErrorMessage(undefined);\n setIsFormulaValid(false);\n setDataType(undefined);\n return false;\n }\n\n const resolveFormulaType = resolveFormulaDataType(formulaName, formula, properties, providedDataType);\n const error = resolveFormulaType.errorMessage;\n setFormulaErrorMessage(error);\n setIsFormulaValid(!error);\n setDataType(inferToPropertyDataType(resolveFormulaType.value));\n return !error;\n}\n\nconst debouncedValidationFunc = debounce(validate, 2000);\n\nexport function useFormulaValidation(\n formulaName: string,\n formula: string | undefined,\n groupProperties: Property[],\n setFormulaErrorMessage: (s: string | undefined) => void,\n providedDataType?: DataType,\n) {\n const [isFormulaValid, setIsFormulaValid] = useState(false);\n const [inferredDataType, setDataType] = useState<DataType | undefined>(undefined);\n const [propertyMap, setPropertyMap] = useState<PropertyMap>({});\n useEffect(() => setPropertyMap(convertToPropertyMap(groupProperties)), [groupProperties]);\n useEffect(\n () => debouncedValidationFunc(formulaName, formula, propertyMap, setFormulaErrorMessage, setIsFormulaValid, setDataType, providedDataType),\n [formulaName, formula, groupProperties, setFormulaErrorMessage, propertyMap, providedDataType],\n );\n return {\n isFormulaValid,\n inferredDataType,\n forceValidation: () => validate(formulaName, formula, propertyMap, setFormulaErrorMessage, setIsFormulaValid, setDataType, providedDataType),\n };\n}\n\nexport const inferToPropertyDataType = (value: FormulaDataType | undefined): DataType => {\n switch (value) {\n case \"Double\":\n return DataType.Double;\n case \"Integer\":\n return DataType.Integer;\n case \"String\":\n return DataType.String;\n case \"Boolean\":\n return DataType.Boolean;\n default:\n return DataType.String;\n }\n};\n\nconst convertToPropertyMap = (properties: Property[], selectedPropertyName?: string): PropertyMap => {\n const map: PropertyMap = {};\n const selectedLowerName = selectedPropertyName?.toLowerCase();\n\n properties.forEach((p) => {\n const lowerName = p.propertyName?.toLowerCase();\n if (lowerName && lowerName !== selectedLowerName) map[lowerName] = stringToPossibleDataType(p.dataType);\n });\n\n return map;\n};\n\nconst stringToPossibleDataType = (str?: string): PossibleDataType => {\n switch (str?.toLowerCase()) {\n case \"double\":\n return \"Double\";\n case \"integer\":\n return \"Integer\";\n case \"string\":\n return \"String\";\n case \"boolean\":\n return \"Boolean\";\n default:\n return \"Undefined\";\n }\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useForwardRef = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useForwardRef = (ref, initialValue = null) => {
|
|
6
|
+
const targetRef = (0, react_1.useRef)(initialValue);
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
if (!ref)
|
|
9
|
+
return;
|
|
10
|
+
if (typeof ref === 'function') {
|
|
11
|
+
ref(targetRef.current);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
ref.current = targetRef.current;
|
|
15
|
+
}
|
|
16
|
+
}, [ref]);
|
|
17
|
+
return targetRef;
|
|
18
|
+
};
|
|
19
|
+
exports.useForwardRef = useForwardRef;
|
|
20
|
+
//# sourceMappingURL=useForwardRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForwardRef.js","sourceRoot":"","sources":["../../../../../src/components/Properties/hooks/useForwardRef.ts"],"names":[],"mappings":";;;AAKA,iCAA0C;AAEnC,MAAM,aAAa,GAAG,CACzB,GAAoB,EACpB,eAAoB,IAAI,EACxB,EAAE;IACF,MAAM,SAAS,GAAG,IAAA,cAAM,EAAI,YAAY,CAAC,CAAC;IAE1C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG;YAAE,OAAO;QAEjB,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;YAC7B,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;SACxB;aAAM;YACL,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;SACjC;IACH,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAjBS,QAAA,aAAa,iBAiBtB","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 { ForwardedRef } from \"react\";\nimport { useEffect, useRef } from \"react\";\n\nexport const useForwardRef = <T,>(\n ref: ForwardedRef<T>,\n initialValue: any = null\n ) => {\n const targetRef = useRef<T>(initialValue);\n \n useEffect(() => {\n if (!ref) return;\n \n if (typeof ref === 'function') {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }, [ref]);\n \n return targetRef;\n };"]}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import "./ActionPanel.scss";
|
|
3
3
|
export interface ActionPanelProps {
|
|
4
4
|
onSave: () => void;
|
|
5
|
+
onSaveCapture?: () => void;
|
|
5
6
|
onCancel?: () => void;
|
|
7
|
+
onCancelCapture?: () => void;
|
|
6
8
|
isCancelDisabled?: boolean;
|
|
7
9
|
isSavingDisabled?: boolean;
|
|
8
10
|
isLoading?: boolean;
|
|
9
11
|
}
|
|
10
|
-
declare const ActionPanel: ({ onSave, onCancel, isCancelDisabled, isSavingDisabled, isLoading }: ActionPanelProps) => JSX.Element;
|
|
12
|
+
declare const ActionPanel: ({ onSave, onSaveCapture, onCancel, onCancelCapture, isCancelDisabled, isSavingDisabled, isLoading }: ActionPanelProps) => JSX.Element;
|
|
11
13
|
export default ActionPanel;
|
|
12
14
|
//# sourceMappingURL=ActionPanel.d.ts.map
|
|
@@ -31,12 +31,12 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
|
31
31
|
const React = __importStar(require("react"));
|
|
32
32
|
require("./ActionPanel.scss");
|
|
33
33
|
const LoadingSpinner_1 = require("./LoadingSpinner");
|
|
34
|
-
const ActionPanel = ({ onSave, onCancel, isCancelDisabled = false, isSavingDisabled = false, isLoading = false }) => {
|
|
34
|
+
const ActionPanel = ({ onSave, onSaveCapture, onCancel, onCancelCapture, isCancelDisabled = false, isSavingDisabled = false, isLoading = false }) => {
|
|
35
35
|
return (React.createElement("div", { id: "action", className: "gmw-action-panel-container" },
|
|
36
36
|
React.createElement("div", { className: "gmw-action-panel" },
|
|
37
37
|
isLoading && React.createElement(LoadingSpinner_1.LoadingSpinner, null),
|
|
38
|
-
React.createElement(itwinui_react_1.Button, { disabled: isSavingDisabled || isLoading, styleType: "high-visibility", id: "save-app", onClick: onSave }, "Save"),
|
|
39
|
-
onCancel && (React.createElement(itwinui_react_1.Button, { styleType: "default", type: "button", id: "cancel", onClick: onCancel, disabled: isCancelDisabled || isLoading }, "Cancel")))));
|
|
38
|
+
React.createElement(itwinui_react_1.Button, { disabled: isSavingDisabled || isLoading, styleType: "high-visibility", id: "save-app", onClick: onSave, onClickCapture: onSaveCapture }, "Save"),
|
|
39
|
+
onCancel && (React.createElement(itwinui_react_1.Button, { styleType: "default", type: "button", id: "cancel", onClick: onCancel, disabled: isCancelDisabled || isLoading, onClickCapture: onCancelCapture }, "Cancel")))));
|
|
40
40
|
};
|
|
41
41
|
exports.default = ActionPanel;
|
|
42
42
|
//# sourceMappingURL=ActionPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionPanel.js","sourceRoot":"","sources":["../../../../src/components/SharedComponents/ActionPanel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,wDAA8C;AAC9C,6CAA+B;AAC/B,8BAA4B;AAC5B,qDAAkD;
|
|
1
|
+
{"version":3,"file":"ActionPanel.js","sourceRoot":"","sources":["../../../../src/components/SharedComponents/ActionPanel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,wDAA8C;AAC9C,6CAA+B;AAC/B,8BAA4B;AAC5B,qDAAkD;AAYlD,MAAM,WAAW,GAAG,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,GAAG,KAAK,EAAE,gBAAgB,GAAG,KAAK,EAAE,SAAS,GAAG,KAAK,EAAoB,EAAe,EAAE;IACjL,OAAO,CACL,6BAAK,EAAE,EAAC,QAAQ,EAAC,SAAS,EAAC,4BAA4B;QACrD,6BAAK,SAAS,EAAC,kBAAkB;YAC9B,SAAS,IAAI,oBAAC,+BAAc,OAAG;YAChC,oBAAC,sBAAM,IAAC,QAAQ,EAAE,gBAAgB,IAAI,SAAS,EAAE,SAAS,EAAC,iBAAiB,EAAC,EAAE,EAAC,UAAU,EAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,WAEhI;YACR,QAAQ,IAAI,CACX,oBAAC,sBAAM,IAAC,SAAS,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,EAAC,EAAE,EAAC,QAAQ,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,IAAI,SAAS,EAAE,cAAc,EAAE,eAAe,aAExI,CACV,CACG,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,WAAW,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 { Button } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport \"./ActionPanel.scss\";\nimport { LoadingSpinner } from \"./LoadingSpinner\";\n\nexport interface ActionPanelProps {\n onSave: () => void;\n onSaveCapture?: () => void;\n onCancel?: () => void;\n onCancelCapture?: () => void;\n isCancelDisabled?: boolean;\n isSavingDisabled?: boolean;\n isLoading?: boolean;\n}\n\nconst ActionPanel = ({ onSave, onSaveCapture, onCancel, onCancelCapture, isCancelDisabled = false, isSavingDisabled = false, isLoading = false }: ActionPanelProps): JSX.Element => {\n return (\n <div id=\"action\" className=\"gmw-action-panel-container\">\n <div className=\"gmw-action-panel\">\n {isLoading && <LoadingSpinner />}\n <Button disabled={isSavingDisabled || isLoading} styleType=\"high-visibility\" id=\"save-app\" onClick={onSave} onClickCapture={onSaveCapture}>\n Save\n </Button>\n {onCancel && (\n <Button styleType=\"default\" type=\"button\" id=\"cancel\" onClick={onCancel} disabled={isCancelDisabled || isLoading} onClickCapture={onCancelCapture}>\n Cancel\n </Button>\n )}\n </div>\n </div>\n );\n};\n\nexport default ActionPanel;\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { DataType } from "@itwin/insights-client";
|
|
1
2
|
import type { IResult } from "./IResult";
|
|
2
|
-
import type { DataType, PropertyMap } from "./Types";
|
|
3
|
+
import type { DataType as FormulaDataType, PropertyMap } from "./Types";
|
|
3
4
|
/**
|
|
4
5
|
* Resolves DataType of the given formula.
|
|
5
6
|
* @param formulaName Name of the current formula. Expected to be lowercase.
|
|
@@ -9,5 +10,5 @@ import type { DataType, PropertyMap } from "./Types";
|
|
|
9
10
|
* @returns `dataType` if formula is valid. `errorMessage` otherwise.
|
|
10
11
|
* @public
|
|
11
12
|
*/
|
|
12
|
-
export declare function resolveFormulaDataType(formulaName: string, formula: string, properties: PropertyMap): IResult<
|
|
13
|
+
export declare function resolveFormulaDataType(formulaName: string, formula: string, properties: PropertyMap, providedDataType?: DataType): IResult<FormulaDataType>;
|
|
13
14
|
//# sourceMappingURL=FormulaDataTypeResolver.d.ts.map
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveFormulaDataType = 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
4
|
const FormulaSplitter_1 = require("./FormulaSplitter");
|
|
9
5
|
const FormulaTokensDataTypeResolver_1 = require("./FormulaTokensDataTypeResolver");
|
|
10
6
|
const InfixToPostfixConverter_1 = require("./InfixToPostfixConverter");
|
|
11
7
|
const ParenthesisValidator_1 = require("./ParenthesisValidator");
|
|
8
|
+
const useFormulaValidation_1 = require("../components/Properties/hooks/useFormulaValidation");
|
|
12
9
|
/**
|
|
13
10
|
* Resolves DataType of the given formula.
|
|
14
11
|
* @param formulaName Name of the current formula. Expected to be lowercase.
|
|
@@ -18,7 +15,7 @@ const ParenthesisValidator_1 = require("./ParenthesisValidator");
|
|
|
18
15
|
* @returns `dataType` if formula is valid. `errorMessage` otherwise.
|
|
19
16
|
* @public
|
|
20
17
|
*/
|
|
21
|
-
function resolveFormulaDataType(formulaName, formula, properties) {
|
|
18
|
+
function resolveFormulaDataType(formulaName, formula, properties, providedDataType) {
|
|
22
19
|
const parenthesisState = (0, ParenthesisValidator_1.validateParenthesis)(formula);
|
|
23
20
|
if (ParenthesisValidator_1.ParenthesisState.NotClosed === parenthesisState) {
|
|
24
21
|
return { errorMessage: "Opened but not closed parenthesis found." };
|
|
@@ -44,7 +41,14 @@ function resolveFormulaDataType(formulaName, formula, properties) {
|
|
|
44
41
|
if (undefined === postfixFormulaTokens.value) {
|
|
45
42
|
return { errorMessage: postfixFormulaTokens.errorMessage ?? "Unknown error." };
|
|
46
43
|
}
|
|
47
|
-
|
|
44
|
+
const tokensDataType = (0, FormulaTokensDataTypeResolver_1.resolveTokensDataType)(formulaName, postfixFormulaTokens.value, properties);
|
|
45
|
+
if (providedDataType && !tokensDataType.errorMessage) {
|
|
46
|
+
const formulaDataType = (0, useFormulaValidation_1.inferToPropertyDataType)(tokensDataType.value);
|
|
47
|
+
if (providedDataType !== formulaDataType) {
|
|
48
|
+
return { errorMessage: `The formula result data type ${formulaDataType} does not match the provided data type ${providedDataType}` };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return tokensDataType;
|
|
48
52
|
}
|
|
49
53
|
exports.resolveFormulaDataType = resolveFormulaDataType;
|
|
50
54
|
//# sourceMappingURL=FormulaDataTypeResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormulaDataTypeResolver.js","sourceRoot":"","sources":["../../../src/formula/FormulaDataTypeResolver.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"FormulaDataTypeResolver.js","sourceRoot":"","sources":["../../../src/formula/FormulaDataTypeResolver.ts"],"names":[],"mappings":";;;AAKA,uDAAiD;AACjD,mFAAwE;AACxE,uEAAkE;AAElE,iEAA+E;AAE/E,8FAA8F;AAE9F;;;;;;;;GAQG;AAEH,SAAgB,sBAAsB,CAAC,WAAmB,EAAE,OAAe,EAAE,UAAuB,EAAE,gBAA2B;IAC/H,MAAM,gBAAgB,GAAG,IAAA,0CAAmB,EAAC,OAAO,CAAC,CAAC;IACtD,IAAI,uCAAgB,CAAC,SAAS,KAAK,gBAAgB,EAAE;QACnD,OAAO,EAAE,YAAY,EAAE,0CAA0C,EAAE,CAAC;KACrE;SAAM,IAAI,uCAAgB,CAAC,SAAS,KAAK,gBAAgB,EAAE;QAC1D,OAAO,EAAE,YAAY,EAAE,0CAA0C,EAAE,CAAC;KACrE;IAED,IAAI,kBAAkB,CAAC;IACvB,IAAI;QACF,kBAAkB,GAAG,IAAA,8BAAY,EAAC,OAAO,CAAC,CAAC;KAC5C;IAAC,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,YAAY,KAAK,EAAE;YACvB,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC;SACrC;aAAM;YACL,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;YACpC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;SAC3C;KACF;IAED,MAAM,oBAAoB,GAAG,IAAA,+CAAqB,EAAC,kBAAkB,CAAC,CAAC;IAEvE,IAAI,SAAS,KAAK,oBAAoB,CAAC,KAAK,EAAE;QAC5C,OAAO,EAAE,YAAY,EAAE,oBAAoB,CAAC,YAAY,IAAI,gBAAgB,EAAE,CAAC;KAChF;IAED,MAAM,cAAc,GAAG,IAAA,qDAAqB,EAAC,WAAW,EAAE,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAElG,IAAI,gBAAgB,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE;QACpD,MAAM,eAAe,GAAG,IAAA,8CAAuB,EAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtE,IAAI,gBAAgB,KAAK,eAAe,EAAE;YACxC,OAAO,EAAE,YAAY,EAAE,gCAAgC,eAAe,0CAA0C,gBAAgB,EAAE,EAAE,CAAC;SACtI;KACF;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AArCD,wDAqCC","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 { DataType } from \"@itwin/insights-client\";\nimport { splitFormula } from \"./FormulaSplitter\";\nimport { resolveTokensDataType } from \"./FormulaTokensDataTypeResolver\";\nimport { convertInfixToPostfix } from \"./InfixToPostfixConverter\";\nimport type { IResult } from \"./IResult\";\nimport { ParenthesisState, validateParenthesis } from \"./ParenthesisValidator\";\nimport type { DataType as FormulaDataType, PropertyMap } from \"./Types\";\nimport { inferToPropertyDataType } from \"../components/Properties/hooks/useFormulaValidation\";\n\n/**\n * Resolves DataType of the given formula.\n * @param formulaName Name of the current formula. Expected to be lowercase.\n * @param formula The formula itself.\n * @param properties All available properties or variables with their data types\n * that could be used in formula. Names are expected to be lowercase.\n * @returns `dataType` if formula is valid. `errorMessage` otherwise.\n * @public\n */\n\nexport function resolveFormulaDataType(formulaName: string, formula: string, properties: PropertyMap, providedDataType?: DataType): IResult<FormulaDataType> {\n const parenthesisState = validateParenthesis(formula);\n if (ParenthesisState.NotClosed === parenthesisState) {\n return { errorMessage: \"Opened but not closed parenthesis found.\" };\n } else if (ParenthesisState.NotOpened === parenthesisState) {\n return { errorMessage: \"Closed but not opened parenthesis found.\" };\n }\n\n let infixFormulaTokens;\n try {\n infixFormulaTokens = splitFormula(formula);\n } catch (ex) {\n if (ex instanceof Error) {\n return { errorMessage: ex.message };\n } else {\n // eslint-disable-next-line no-console\n console.error(\"Unknown error.\", ex);\n return { errorMessage: \"Unknown error.\" };\n }\n }\n\n const postfixFormulaTokens = convertInfixToPostfix(infixFormulaTokens);\n\n if (undefined === postfixFormulaTokens.value) {\n return { errorMessage: postfixFormulaTokens.errorMessage ?? \"Unknown error.\" };\n }\n\n const tokensDataType = resolveTokensDataType(formulaName, postfixFormulaTokens.value, properties);\n\n if (providedDataType && !tokensDataType.errorMessage) {\n const formulaDataType = inferToPropertyDataType(tokensDataType.value);\n if (providedDataType !== formulaDataType) {\n return { errorMessage: `The formula result data type ${formulaDataType} does not match the provided data type ${providedDataType}` };\n }\n }\n\n return tokensDataType;\n}\n"]}
|
|
@@ -21,8 +21,6 @@ export { PropertyMenu, PropertyMenuProps } from "./components/Properties/Propert
|
|
|
21
21
|
export { PropertyMenuWithVisualization, PropertyMenuWithVisualizationProps } from "./components/Properties/PropertyMenuWithVisualization";
|
|
22
22
|
export { GroupPropertyAction, GroupPropertyActionProps } from "./components/Properties/GroupProperties/GroupPropertyAction";
|
|
23
23
|
export { CalculatedPropertyAction, CalculatedPropertyActionProps } from "./components/Properties/CalculatedProperties/CalculatedPropertyAction";
|
|
24
|
-
export { CalculatedPropertyActionWithVisuals, CalculatedPropertyActionWithVisualsProps, } from "./components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals";
|
|
25
|
-
export { CustomCalculationAction, CustomCalculationActionProps } from "./components/Properties/CustomCalculations/CustomCalculationAction";
|
|
26
24
|
export { SearchGroupingCustomUI } from "./components/customUI/SearchGroupingCustomUI";
|
|
27
25
|
export { ManualGroupingCustomUI } from "./components/customUI/ManualGroupingCustomUI";
|
|
28
26
|
export { GroupQueryBuilderCustomUI } from "./components/customUI/GroupQueryBuilderCustomUI";
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.resolveFormulaDataType = exports.GroupingMappingCustomUIType = exports.GroupQueryBuilderCustomUI = exports.ManualGroupingCustomUI = exports.SearchGroupingCustomUI = exports.
|
|
17
|
+
exports.resolveFormulaDataType = exports.GroupingMappingCustomUIType = exports.GroupQueryBuilderCustomUI = exports.ManualGroupingCustomUI = exports.SearchGroupingCustomUI = exports.CalculatedPropertyAction = exports.GroupPropertyAction = exports.PropertyMenuWithVisualization = exports.PropertyMenu = exports.GroupAction = exports.GroupsVisualization = exports.Groups = exports.GroupingMappingContext = exports.GroupsView = exports.useGroupsOperations = exports.MappingsView = exports.MappingAction = exports.useMappingsOperations = exports.Mappings = exports.useGroupingMappingApiConfig = exports.GroupingMappingApiConfigContext = exports.usePropertiesClient = exports.PropertiesClientContext = exports.createPropertiesClient = exports.createDefaultPropertiesClient = exports.useGroupsClient = exports.GroupsClientContext = exports.createGroupsClient = exports.createDefaultGroupsClient = exports.useMappingClient = exports.MappingClientContext = exports.createMappingClient = exports.createDefaultMappingClient = void 0;
|
|
18
18
|
/*---------------------------------------------------------------------------------------------
|
|
19
19
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
20
20
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -70,10 +70,6 @@ var GroupPropertyAction_1 = require("./components/Properties/GroupProperties/Gro
|
|
|
70
70
|
Object.defineProperty(exports, "GroupPropertyAction", { enumerable: true, get: function () { return GroupPropertyAction_1.GroupPropertyAction; } });
|
|
71
71
|
var CalculatedPropertyAction_1 = require("./components/Properties/CalculatedProperties/CalculatedPropertyAction");
|
|
72
72
|
Object.defineProperty(exports, "CalculatedPropertyAction", { enumerable: true, get: function () { return CalculatedPropertyAction_1.CalculatedPropertyAction; } });
|
|
73
|
-
var CalculatedPropertyActionWithVisuals_1 = require("./components/Properties/CalculatedProperties/CalculatedPropertyActionWithVisuals");
|
|
74
|
-
Object.defineProperty(exports, "CalculatedPropertyActionWithVisuals", { enumerable: true, get: function () { return CalculatedPropertyActionWithVisuals_1.CalculatedPropertyActionWithVisuals; } });
|
|
75
|
-
var CustomCalculationAction_1 = require("./components/Properties/CustomCalculations/CustomCalculationAction");
|
|
76
|
-
Object.defineProperty(exports, "CustomCalculationAction", { enumerable: true, get: function () { return CustomCalculationAction_1.CustomCalculationAction; } });
|
|
77
73
|
var SearchGroupingCustomUI_1 = require("./components/customUI/SearchGroupingCustomUI");
|
|
78
74
|
Object.defineProperty(exports, "SearchGroupingCustomUI", { enumerable: true, get: function () { return SearchGroupingCustomUI_1.SearchGroupingCustomUI; } });
|
|
79
75
|
var ManualGroupingCustomUI_1 = require("./components/customUI/ManualGroupingCustomUI");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grouping-mapping-widget.js","sourceRoot":"","sources":["../../src/grouping-mapping-widget.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,gDAAgD;AAChD,sEAAoD;AAEpD,0EAA0E;AAC1E,kFAAoJ;AAA3I,kIAAA,0BAA0B,OAAA;AAAE,2HAAA,mBAAmB,OAAA;AAAE,4HAAA,oBAAoB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,sBAAsB,OAAA","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/** UI Provider for iTwin Viewer Applications */\nexport * from \"./WidgetShell/GroupingMappingWidget\";\n\n/** Interfaces for providing custom MappingClient and API configuration */\nexport { createDefaultMappingClient, createMappingClient, MappingClientContext, useMappingClient } from \"./components/context/MappingClientContext\";\nexport { createDefaultGroupsClient, createGroupsClient, GroupsClientContext, useGroupsClient } from \"./components/context/GroupsClientContext\";\nexport {\n createDefaultPropertiesClient,\n createPropertiesClient,\n PropertiesClientContext,\n usePropertiesClient,\n} from \"./components/context/PropertiesClientContext\";\nexport {\n ClientPrefix,\n GetAccessTokenFn,\n GroupingMappingApiConfig,\n GroupingMappingApiConfigContext,\n useGroupingMappingApiConfig,\n} from \"./components/context/GroupingApiConfigContext\";\nexport * from \"@itwin/insights-client\";\n\n/** Internal components for custom UIs */\nexport { Mappings, MappingsProps } from \"./components/Mappings/Mappings\";\nexport { useMappingsOperations, MappingsOperationsProps } from \"./components/Mappings/hooks/useMappingsOperations\";\nexport { MappingAction, MappingActionProps } from \"./components/Mappings/Editing/MappingAction\";\nexport { MappingsView, MappingsViewProps } from \"./components/Mappings/MappingsView\";\nexport { useGroupsOperations, GroupsOperationsProps } from \"./components/Groups/hooks/useGroupsOperations\";\nexport { GroupsView, GroupsViewProps } from \"./components/Groups/GroupsView\";\nexport { GroupingMappingContext, GroupingMappingContextProps } from \"./components/GroupingMappingContext\";\nexport { Groups, GroupsProps } from \"./components/Groups/Groups\";\nexport { GroupsVisualization, GroupsVisualizationProps } from \"./components/Groups/GroupsVisualization\";\nexport { GroupAction, GroupActionProps } from \"./components/Groups/Editing/GroupAction\";\nexport { PropertyMenu, PropertyMenuProps } from \"./components/Properties/PropertyMenu\";\nexport { PropertyMenuWithVisualization, PropertyMenuWithVisualizationProps } from \"./components/Properties/PropertyMenuWithVisualization\";\nexport { GroupPropertyAction, GroupPropertyActionProps } from \"./components/Properties/GroupProperties/GroupPropertyAction\";\nexport { CalculatedPropertyAction, CalculatedPropertyActionProps } from \"./components/Properties/CalculatedProperties/CalculatedPropertyAction\";\nexport { SearchGroupingCustomUI } from \"./components/customUI/SearchGroupingCustomUI\";\nexport { ManualGroupingCustomUI } from \"./components/customUI/ManualGroupingCustomUI\";\nexport { GroupQueryBuilderCustomUI } from \"./components/customUI/GroupQueryBuilderCustomUI\";\nexport {\n GroupingMappingCustomUI,\n GroupingMappingCustomUIType,\n ContextCustomUI,\n GroupingCustomUI,\n GroupingCustomUIProps,\n ContextCustomUIProps,\n} from \"./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"]}
|