@itwin/grouping-mapping-widget 0.3.4 → 0.5.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/formula/FormulaDataTypeResolver.d.ts +12 -0
- package/lib/cjs/formula/FormulaDataTypeResolver.js +50 -0
- package/lib/cjs/formula/FormulaDataTypeResolver.js.map +1 -0
- package/lib/cjs/formula/FormulaFunctionProvider.js +59 -59
- package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/cjs/formula/FormulaOperatorsProvider.js +7 -7
- package/lib/cjs/formula/FormulaOperatorsProvider.js.map +1 -1
- package/lib/cjs/formula/FormulaTokensDataTypeResolver.d.ts +6 -0
- package/lib/cjs/formula/{FormulaTokensValidator.js → FormulaTokensDataTypeResolver.js} +33 -31
- package/lib/cjs/formula/FormulaTokensDataTypeResolver.js.map +1 -0
- package/lib/cjs/formula/Types.d.ts +2 -2
- package/lib/cjs/formula/Types.js.map +1 -1
- package/lib/cjs/grouping-mapping-widget.d.ts +9 -0
- package/lib/cjs/grouping-mapping-widget.js +9 -1
- package/lib/cjs/grouping-mapping-widget.js.map +1 -1
- package/lib/cjs/widget/GroupingMappingWidget.d.ts +3 -4
- package/lib/cjs/widget/GroupingMappingWidget.js +3 -4
- package/lib/cjs/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/cjs/widget/IMappingClient.d.ts +327 -0
- package/lib/cjs/widget/IMappingClient.js +7 -0
- package/lib/cjs/widget/IMappingClient.js.map +1 -0
- package/lib/cjs/widget/components/CalculatedPropertyAction.js +7 -6
- package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/CalculatedPropertyTable.js +6 -5
- package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/ConfirmMappingsImport.js +6 -5
- package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationAction.js +8 -7
- package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/cjs/widget/components/CustomCalculationTable.js +6 -5
- package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/cjs/widget/components/GroupAction.d.ts +2 -1
- package/lib/cjs/widget/components/GroupAction.js +21 -14
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyAction.js +19 -10
- package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/cjs/widget/components/GroupPropertyTable.js +6 -5
- package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.js +8 -5
- package/lib/cjs/widget/components/GroupQueryBuilderContainer.js.map +1 -1
- package/lib/cjs/widget/components/GroupTile.d.ts +13 -0
- package/lib/cjs/widget/components/GroupTile.js +18 -0
- package/lib/cjs/widget/components/GroupTile.js.map +1 -0
- package/lib/cjs/widget/components/GroupTile.scss +32 -0
- package/lib/cjs/widget/components/Grouping.js +215 -166
- package/lib/cjs/widget/components/Grouping.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.scss +39 -4
- package/lib/cjs/widget/components/GroupingMapping.d.ts +18 -11
- package/lib/cjs/widget/components/GroupingMapping.js +24 -15
- package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
- package/lib/cjs/widget/components/Mapping.js +20 -17
- package/lib/cjs/widget/components/Mapping.js.map +1 -1
- package/lib/cjs/widget/components/MappingAction.js +8 -7
- package/lib/cjs/widget/components/MappingAction.js.map +1 -1
- package/lib/cjs/widget/components/PropertyMenu.js +34 -26
- package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
- package/lib/cjs/widget/components/QueryBuilder.d.ts +10 -4
- package/lib/cjs/widget/components/QueryBuilder.js +223 -141
- package/lib/cjs/widget/components/QueryBuilder.js.map +1 -1
- package/lib/cjs/widget/components/SelectIModel.js +13 -4
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -1
- package/lib/cjs/widget/components/SelectMappings.js +9 -8
- package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
- package/lib/cjs/widget/components/SelectProject.js +13 -4
- package/lib/cjs/widget/components/SelectProject.js.map +1 -1
- package/lib/cjs/widget/components/{GroupQueryBuilderContext.d.ts → context/GroupQueryBuilderContext.d.ts} +2 -1
- package/lib/cjs/widget/components/{GroupQueryBuilderContext.js → context/GroupQueryBuilderContext.js} +2 -1
- package/lib/cjs/widget/components/context/GroupQueryBuilderContext.js.map +1 -0
- package/lib/cjs/widget/components/context/GroupingApiConfigContext.d.ts +11 -0
- package/lib/cjs/widget/components/context/GroupingApiConfigContext.js +37 -0
- package/lib/cjs/widget/components/context/GroupingApiConfigContext.js.map +1 -0
- package/lib/cjs/widget/components/context/MappingClientContext.d.ts +7 -0
- package/lib/cjs/widget/components/context/MappingClientContext.js +30 -0
- package/lib/cjs/widget/components/context/MappingClientContext.js.map +1 -0
- package/lib/cjs/widget/components/property-grid/PropertyGrid.d.ts +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGrid.js +5 -5
- package/lib/cjs/widget/components/property-grid/PropertyGrid.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.d.ts +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.js +2 -2
- package/lib/cjs/widget/components/property-grid/PropertyGridWrapper.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.js +14 -6
- package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/cjs/widget/components/utils.d.ts +6 -0
- package/lib/cjs/widget/components/utils.js +9 -1
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/cjs/widget/components/utils.scss +12 -3
- package/lib/cjs/widget/components/viewerUtils.d.ts +19 -0
- package/lib/cjs/widget/components/viewerUtils.js +224 -3
- package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
- package/lib/cjs/widget/hooks/useFormulaValidation.d.ts +1 -1
- package/lib/cjs/widget/hooks/useFormulaValidation.js +7 -6
- package/lib/cjs/widget/hooks/useFormulaValidation.js.map +1 -1
- package/lib/esm/formula/FormulaDataTypeResolver.d.ts +12 -0
- package/lib/esm/formula/FormulaDataTypeResolver.js +46 -0
- package/lib/esm/formula/FormulaDataTypeResolver.js.map +1 -0
- package/lib/esm/formula/FormulaFunctionProvider.js +59 -59
- package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/esm/formula/FormulaOperatorsProvider.js +7 -7
- package/lib/esm/formula/FormulaOperatorsProvider.js.map +1 -1
- package/lib/esm/formula/FormulaTokensDataTypeResolver.d.ts +6 -0
- package/lib/esm/formula/{FormulaTokensValidator.js → FormulaTokensDataTypeResolver.js} +31 -29
- package/lib/esm/formula/FormulaTokensDataTypeResolver.js.map +1 -0
- package/lib/esm/formula/Types.d.ts +2 -2
- package/lib/esm/formula/Types.js.map +1 -1
- package/lib/esm/grouping-mapping-widget.d.ts +9 -0
- package/lib/esm/grouping-mapping-widget.js +6 -0
- package/lib/esm/grouping-mapping-widget.js.map +1 -1
- package/lib/esm/widget/GroupingMappingWidget.d.ts +3 -4
- package/lib/esm/widget/GroupingMappingWidget.js +3 -4
- package/lib/esm/widget/GroupingMappingWidget.js.map +1 -1
- package/lib/esm/widget/IMappingClient.d.ts +327 -0
- package/lib/esm/widget/IMappingClient.js +6 -0
- package/lib/esm/widget/IMappingClient.js.map +1 -0
- package/lib/esm/widget/components/CalculatedPropertyAction.js +8 -7
- package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/CalculatedPropertyTable.js +7 -6
- package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/ConfirmMappingsImport.js +7 -6
- package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationAction.js +9 -8
- package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
- package/lib/esm/widget/components/CustomCalculationTable.js +7 -6
- package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
- package/lib/esm/widget/components/GroupAction.d.ts +2 -1
- package/lib/esm/widget/components/GroupAction.js +23 -16
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyAction.js +20 -11
- package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
- package/lib/esm/widget/components/GroupPropertyTable.js +7 -6
- package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
- package/lib/esm/widget/components/GroupQueryBuilderContainer.js +8 -5
- package/lib/esm/widget/components/GroupQueryBuilderContainer.js.map +1 -1
- package/lib/esm/widget/components/GroupTile.d.ts +13 -0
- package/lib/esm/widget/components/GroupTile.js +11 -0
- package/lib/esm/widget/components/GroupTile.js.map +1 -0
- package/lib/esm/widget/components/GroupTile.scss +32 -0
- package/lib/esm/widget/components/Grouping.js +220 -171
- package/lib/esm/widget/components/Grouping.js.map +1 -1
- package/lib/esm/widget/components/Grouping.scss +39 -4
- package/lib/esm/widget/components/GroupingMapping.d.ts +18 -11
- package/lib/esm/widget/components/GroupingMapping.js +25 -15
- package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
- package/lib/esm/widget/components/Mapping.js +21 -18
- package/lib/esm/widget/components/Mapping.js.map +1 -1
- package/lib/esm/widget/components/MappingAction.js +9 -8
- package/lib/esm/widget/components/MappingAction.js.map +1 -1
- package/lib/esm/widget/components/PropertyMenu.js +36 -28
- package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
- package/lib/esm/widget/components/QueryBuilder.d.ts +10 -4
- package/lib/esm/widget/components/QueryBuilder.js +224 -142
- package/lib/esm/widget/components/QueryBuilder.js.map +1 -1
- package/lib/esm/widget/components/SelectIModel.js +14 -5
- package/lib/esm/widget/components/SelectIModel.js.map +1 -1
- package/lib/esm/widget/components/SelectMappings.js +10 -9
- package/lib/esm/widget/components/SelectMappings.js.map +1 -1
- package/lib/esm/widget/components/SelectProject.js +14 -5
- package/lib/esm/widget/components/SelectProject.js.map +1 -1
- package/lib/esm/widget/components/{GroupQueryBuilderContext.d.ts → context/GroupQueryBuilderContext.d.ts} +2 -1
- package/lib/esm/widget/components/{GroupQueryBuilderContext.js → context/GroupQueryBuilderContext.js} +2 -1
- package/lib/esm/widget/components/context/GroupQueryBuilderContext.js.map +1 -0
- package/lib/esm/widget/components/context/GroupingApiConfigContext.d.ts +11 -0
- package/lib/esm/widget/components/context/GroupingApiConfigContext.js +14 -0
- package/lib/esm/widget/components/context/GroupingApiConfigContext.js.map +1 -0
- package/lib/esm/widget/components/context/MappingClientContext.d.ts +7 -0
- package/lib/esm/widget/components/context/MappingClientContext.js +25 -0
- package/lib/esm/widget/components/context/MappingClientContext.js.map +1 -0
- package/lib/esm/widget/components/property-grid/PropertyGrid.d.ts +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGrid.js +6 -6
- package/lib/esm/widget/components/property-grid/PropertyGrid.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.d.ts +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.js +2 -2
- package/lib/esm/widget/components/property-grid/PropertyGridWrapper.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyView.js +14 -6
- package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/esm/widget/components/utils.d.ts +6 -0
- package/lib/esm/widget/components/utils.js +6 -0
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/lib/esm/widget/components/utils.scss +12 -3
- package/lib/esm/widget/components/viewerUtils.d.ts +19 -0
- package/lib/esm/widget/components/viewerUtils.js +207 -3
- package/lib/esm/widget/components/viewerUtils.js.map +1 -1
- package/lib/esm/widget/hooks/useFormulaValidation.d.ts +1 -1
- package/lib/esm/widget/hooks/useFormulaValidation.js +7 -6
- package/lib/esm/widget/hooks/useFormulaValidation.js.map +1 -1
- package/package.json +30 -30
- package/lib/cjs/formula/FormulaTokensValidator.d.ts +0 -5
- package/lib/cjs/formula/FormulaTokensValidator.js.map +0 -1
- package/lib/cjs/formula/FormulaValidator.d.ts +0 -3
- package/lib/cjs/formula/FormulaValidator.js +0 -35
- package/lib/cjs/formula/FormulaValidator.js.map +0 -1
- package/lib/cjs/widget/components/GroupQueryBuilderContext.js.map +0 -1
- package/lib/esm/formula/FormulaTokensValidator.d.ts +0 -5
- package/lib/esm/formula/FormulaTokensValidator.js.map +0 -1
- package/lib/esm/formula/FormulaValidator.d.ts +0 -3
- package/lib/esm/formula/FormulaValidator.js +0 -31
- package/lib/esm/formula/FormulaValidator.js.map +0 -1
- package/lib/esm/widget/components/GroupQueryBuilderContext.js.map +0 -1
|
@@ -1,7 +1,164 @@
|
|
|
1
|
-
import { EmphasizeElements, IModelApp
|
|
2
|
-
import { ColorDef, FeatureOverrideType
|
|
1
|
+
import { EmphasizeElements, IModelApp } from "@itwin/core-frontend";
|
|
2
|
+
import { ColorDef, FeatureOverrideType } from "@itwin/core-common";
|
|
3
3
|
import { KeySet } from "@itwin/presentation-common";
|
|
4
4
|
import { HiliteSetProvider } from "@itwin/presentation-frontend";
|
|
5
|
+
export const isolateElementsByKeys = async (keySet, replace = false) => {
|
|
6
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
10
|
+
const hiliteProvider = HiliteSetProvider.create({
|
|
11
|
+
imodel: vp.iModel,
|
|
12
|
+
});
|
|
13
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
14
|
+
if (set.elements) {
|
|
15
|
+
const ids = [...set.elements];
|
|
16
|
+
isolateElements(ids, replace);
|
|
17
|
+
return ids;
|
|
18
|
+
}
|
|
19
|
+
return [];
|
|
20
|
+
};
|
|
21
|
+
export const isolateElementsById = async (elementIds, iModelConnection, replace = false) => {
|
|
22
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
26
|
+
const keySet = await manufactureKeys(elementIds, iModelConnection);
|
|
27
|
+
const hiliteProvider = HiliteSetProvider.create({
|
|
28
|
+
imodel: vp.iModel,
|
|
29
|
+
});
|
|
30
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
31
|
+
if (set.elements) {
|
|
32
|
+
const ids = [...set.elements];
|
|
33
|
+
isolateElements(ids, replace);
|
|
34
|
+
return ids;
|
|
35
|
+
}
|
|
36
|
+
return [];
|
|
37
|
+
};
|
|
38
|
+
export const isolateElements = (hilitedIds, replace = false) => {
|
|
39
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
43
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
44
|
+
emph.isolateElements(hilitedIds, vp, replace);
|
|
45
|
+
};
|
|
46
|
+
export const clearIsolatedElements = () => {
|
|
47
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
51
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
52
|
+
emph.clearIsolatedElements(vp);
|
|
53
|
+
};
|
|
54
|
+
export const hideElementsById = async (elementIds, iModelConnection, replace = false) => {
|
|
55
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
59
|
+
const keySet = await manufactureKeys(elementIds, iModelConnection);
|
|
60
|
+
const hiliteProvider = HiliteSetProvider.create({
|
|
61
|
+
imodel: vp.iModel,
|
|
62
|
+
});
|
|
63
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
64
|
+
if (set.elements) {
|
|
65
|
+
const ids = [...set.elements];
|
|
66
|
+
hideElements(ids, replace);
|
|
67
|
+
return ids;
|
|
68
|
+
}
|
|
69
|
+
return [];
|
|
70
|
+
};
|
|
71
|
+
export const hideElements = (hilitedIds, replace = false) => {
|
|
72
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
76
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
77
|
+
emph.hideElements(hilitedIds, vp, replace);
|
|
78
|
+
};
|
|
79
|
+
export const clearHiddenElements = () => {
|
|
80
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
84
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
85
|
+
emph.clearHiddenElements(vp);
|
|
86
|
+
};
|
|
87
|
+
export const overrideElementsById = async (iModelConnection, elementIds, color, overrideType = FeatureOverrideType.ColorOnly) => {
|
|
88
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
92
|
+
const keySet = await manufactureKeys(elementIds, iModelConnection);
|
|
93
|
+
const hiliteProvider = HiliteSetProvider.create({
|
|
94
|
+
imodel: vp.iModel,
|
|
95
|
+
});
|
|
96
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
97
|
+
if (set.elements) {
|
|
98
|
+
const ids = [...set.elements];
|
|
99
|
+
overrideElements(ids, color, overrideType);
|
|
100
|
+
return ids;
|
|
101
|
+
}
|
|
102
|
+
return [];
|
|
103
|
+
};
|
|
104
|
+
export const overrideElements = (hilitedIds, color, overrideType = FeatureOverrideType.ColorOnly) => {
|
|
105
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
109
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
110
|
+
emph.overrideElements(hilitedIds, vp, ColorDef.fromString(color), overrideType, true);
|
|
111
|
+
};
|
|
112
|
+
export const clearOverriddenElements = () => {
|
|
113
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
117
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
118
|
+
emph.clearOverriddenElements(vp);
|
|
119
|
+
};
|
|
120
|
+
export const emphasizeElements = (hilitedIds, defaultAppearance = undefined, replace = false) => {
|
|
121
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
125
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
126
|
+
emph.wantEmphasis = true;
|
|
127
|
+
emph.emphasizeElements(hilitedIds, vp, defaultAppearance, replace);
|
|
128
|
+
};
|
|
129
|
+
export const emphasisElementsById = async (iModelConnection, elementIds, defaultAppearance = undefined, replace = false) => {
|
|
130
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
134
|
+
const keySet = await manufactureKeys(elementIds, iModelConnection);
|
|
135
|
+
const hiliteProvider = HiliteSetProvider.create({
|
|
136
|
+
imodel: vp.iModel,
|
|
137
|
+
});
|
|
138
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
139
|
+
if (set.elements) {
|
|
140
|
+
const ids = [...set.elements];
|
|
141
|
+
emphasizeElements(ids, defaultAppearance, replace);
|
|
142
|
+
return ids;
|
|
143
|
+
}
|
|
144
|
+
return [];
|
|
145
|
+
};
|
|
146
|
+
export const emphasizeElementsByKeys = async (keySet, defaultAppearance = undefined, replace = false) => {
|
|
147
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
151
|
+
const hiliteProvider = HiliteSetProvider.create({
|
|
152
|
+
imodel: vp.iModel,
|
|
153
|
+
});
|
|
154
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
155
|
+
if (set.elements) {
|
|
156
|
+
const ids = [...set.elements];
|
|
157
|
+
emphasizeElements(ids, defaultAppearance, replace);
|
|
158
|
+
return ids;
|
|
159
|
+
}
|
|
160
|
+
return [];
|
|
161
|
+
};
|
|
5
162
|
export const visualizeElementsById = async (elementIds, color, iModelConnection, replace = false, wantEmphasis = true) => {
|
|
6
163
|
if (!IModelApp.viewManager.selectedView) {
|
|
7
164
|
return [];
|
|
@@ -41,13 +198,27 @@ export const visualizeElements = (elementIds, color, replace = false, wantEmphas
|
|
|
41
198
|
}
|
|
42
199
|
const vp = IModelApp.viewManager.selectedView;
|
|
43
200
|
const emph = EmphasizeElements.getOrCreate(vp);
|
|
44
|
-
emph.overrideElements(elementIds, vp, ColorDef.fromString(color), FeatureOverrideType.
|
|
201
|
+
emph.overrideElements(elementIds, vp, ColorDef.fromString(color), FeatureOverrideType.ColorAndAlpha, true);
|
|
45
202
|
if (!wantEmphasis) {
|
|
46
203
|
return;
|
|
47
204
|
}
|
|
48
205
|
emph.wantEmphasis = true;
|
|
49
206
|
emph.emphasizeElements(elementIds, vp, undefined, replace);
|
|
50
207
|
};
|
|
208
|
+
export const transparentOverriddenElements = () => {
|
|
209
|
+
var _a;
|
|
210
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
214
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
215
|
+
const ids = (_a = emph.getOverriddenElements()) === null || _a === void 0 ? void 0 : _a.values();
|
|
216
|
+
if (ids) {
|
|
217
|
+
const toOverride = new Set();
|
|
218
|
+
Array.from(ids).forEach((a) => a.forEach((id) => toOverride.add(id)));
|
|
219
|
+
emph.overrideElements(toOverride, vp, ColorDef.red.withAlpha(50), FeatureOverrideType.AlphaOnly, true);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
51
222
|
export const zoomToElements = async (elementIds) => {
|
|
52
223
|
if (!IModelApp.viewManager.selectedView || elementIds.length === 0) {
|
|
53
224
|
return;
|
|
@@ -59,6 +230,21 @@ export const zoomToElements = async (elementIds) => {
|
|
|
59
230
|
// viewChangeOpts.marginPercent = new MarginPercent(0.1, 0.1, 0.1, 0.1);
|
|
60
231
|
await vp.zoomToElements(elementIds, { ...viewChangeOpts });
|
|
61
232
|
};
|
|
233
|
+
export const getHiliteIds = async (elementIds, iModelConnection) => {
|
|
234
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
238
|
+
const keySet = await manufactureKeys(elementIds, iModelConnection);
|
|
239
|
+
const hiliteProvider = HiliteSetProvider.create({
|
|
240
|
+
imodel: vp.iModel,
|
|
241
|
+
});
|
|
242
|
+
const set = await hiliteProvider.getHiliteSet(keySet);
|
|
243
|
+
if (set.elements) {
|
|
244
|
+
return [...set.elements];
|
|
245
|
+
}
|
|
246
|
+
return [];
|
|
247
|
+
};
|
|
62
248
|
export const manufactureKeys = async (elementIds, iModelConnection) => {
|
|
63
249
|
// segment ids into batches
|
|
64
250
|
const batches = [];
|
|
@@ -101,6 +287,24 @@ export const clearEmphasizedElements = () => {
|
|
|
101
287
|
const vp = IModelApp.viewManager.selectedView;
|
|
102
288
|
const emph = EmphasizeElements.getOrCreate(vp);
|
|
103
289
|
emph.clearEmphasizedElements(vp);
|
|
290
|
+
};
|
|
291
|
+
export const clearEmphasizedOverriddenElements = () => {
|
|
292
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
296
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
297
|
+
emph.clearEmphasizedElements(vp);
|
|
298
|
+
emph.clearOverriddenElements(vp);
|
|
299
|
+
};
|
|
300
|
+
export const clearAll = () => {
|
|
301
|
+
if (!IModelApp.viewManager.selectedView) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const vp = IModelApp.viewManager.selectedView;
|
|
305
|
+
const emph = EmphasizeElements.getOrCreate(vp);
|
|
306
|
+
emph.clearEmphasizedElements(vp);
|
|
104
307
|
emph.clearOverriddenElements(vp);
|
|
308
|
+
emph.clearHiddenElements(vp);
|
|
105
309
|
};
|
|
106
310
|
//# sourceMappingURL=viewerUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewerUtils.js","sourceRoot":"","sources":["../../../../src/widget/components/viewerUtils.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,iBAAiB,EACjB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,QAAQ,EACR,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,UAAoB,EACpB,KAAa,EACb,gBAAkC,EAClC,OAAO,GAAG,KAAK,EACf,YAAY,GAAG,IAAI,EACnB,EAAE;IACF,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO,EAAE,CAAC;KACX;IAED,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAE9C,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACnE,MAAM,cAAc,GAAsB,iBAAiB,CAAC,MAAM,CAAC;QACjE,MAAM,EAAE,EAAE,CAAC,MAAM;KAClB,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,GAAG,CAAC,QAAQ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,CAAC,CAAC;SAClB;KACF;IACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,IAAI,SAAS,EAAE;QACzD,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACzB;IAED,yCAAyC;IACzC,IAAI,SAAS,GAAmB,EAAE,CAAC;IACnC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9D,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KACrC;IAED,MAAM,WAAW,GAAG,CAAC,IAGpB,EAGC,EAAE;QACF,OAAO,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC;IAC/B,CAAC,CAAC;IAEF,4CAA4C;IAC5C,MAAM,IAAI,GAAG,SAAS;SACnB,GAAG,CAAC,CAAC,IAAkB,EAAE,EAAE,CAAC,CAAC;QAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,SAAS,EAAE,IAAI,CAAC,aAAa;KAC9B,CAAC,CAAC;SACF,MAAM,CAAC,WAAW,CAAC,CAAC;IACvB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO;KACR;IACD,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;AACnC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type {\n IModelConnection,\n ViewChangeOptions,\n} from \"@itwin/core-frontend\";\nimport {\n EmphasizeElements,\n IModelApp,\n} from \"@itwin/core-frontend\";\nimport type {\n ElementProps,\n} from \"@itwin/core-common\";\nimport {\n ColorDef,\n FeatureOverrideType,\n} from \"@itwin/core-common\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { HiliteSetProvider } from \"@itwin/presentation-frontend\";\n\nexport const visualizeElementsById = async (\n elementIds: string[],\n color: string,\n iModelConnection: IModelConnection,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsByKeys = async (\n keySet: KeySet,\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElements = (\n elementIds: string[],\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n elementIds,\n vp,\n ColorDef.fromString(color),\n FeatureOverrideType.ColorOnly,\n true,\n );\n if (!wantEmphasis) {\n return;\n }\n emph.wantEmphasis = true;\n emph.emphasizeElements(elementIds, vp, undefined, replace);\n};\n\nexport const zoomToElements = async (elementIds: string[]) => {\n if (!IModelApp.viewManager.selectedView || elementIds.length === 0) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const viewChangeOpts: ViewChangeOptions = {};\n viewChangeOpts.animateFrustumChange = true;\n // It was removed. Should be a prop to be passed to lookAtViewAlignedVolume within the implementation.\n // viewChangeOpts.marginPercent = new MarginPercent(0.1, 0.1, 0.1, 0.1);\n await vp.zoomToElements(elementIds, { ...viewChangeOpts });\n};\n\nexport const manufactureKeys = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n): Promise<KeySet> => {\n // segment ids into batches\n const batches: string[][] = [];\n let currBatch: string[] = [];\n const batchSize = 100000;\n for (const id of elementIds) {\n if (currBatch.length < batchSize) {\n currBatch.push(id);\n } else {\n batches.push(currBatch);\n currBatch = [id];\n }\n }\n if (currBatch.length > 0 && currBatch.length <= batchSize) {\n batches.push(currBatch);\n }\n\n // retrieve element properties in batches\n let elemProps: ElementProps[] = [];\n for (const batch of batches) {\n const props = await iModelConnection.elements.getProps(batch);\n elemProps = elemProps.concat(props);\n }\n\n const isElementId = (elem: {\n id: string | undefined;\n className: string;\n }): elem is {\n id: string;\n className: string;\n } => {\n return elem.id !== undefined;\n };\n\n // create keyset from the element properties\n const keys = elemProps\n .map((elem: ElementProps) => ({\n id: elem.id,\n className: elem.classFullName,\n }))\n .filter(isElementId);\n return new KeySet(keys);\n};\n\nexport const clearEmphasizedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"viewerUtils.js","sourceRoot":"","sources":["../../../../src/widget/components/viewerUtils.tsx"],"names":[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------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { IModelConnection, ViewChangeOptions } from \"@itwin/core-frontend\";\nimport { EmphasizeElements, IModelApp } from \"@itwin/core-frontend\";\nimport type { ElementProps, FeatureAppearance } from \"@itwin/core-common\";\nimport { ColorDef, FeatureOverrideType } from \"@itwin/core-common\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { HiliteSetProvider } from \"@itwin/presentation-frontend\";\n\nexport const isolateElementsByKeys = async (\n keySet: KeySet,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n isolateElements(ids, replace);\n return ids;\n }\n return [];\n};\n\nexport const isolateElementsById = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n isolateElements(ids, replace);\n return ids;\n }\n return [];\n};\n\nexport const isolateElements = (hilitedIds: string[], replace = false) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.isolateElements(hilitedIds, vp, replace);\n};\n\nexport const clearIsolatedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearIsolatedElements(vp);\n};\n\nexport const hideElementsById = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n hideElements(ids, replace);\n return ids;\n }\n return [];\n};\n\nexport const hideElements = (hilitedIds: string[], replace = false) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.hideElements(hilitedIds, vp, replace);\n};\n\nexport const clearHiddenElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearHiddenElements(vp);\n};\n\nexport const overrideElementsById = async (\n iModelConnection: IModelConnection,\n elementIds: string[],\n color: string,\n overrideType = FeatureOverrideType.ColorOnly,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n overrideElements(ids, color, overrideType);\n return ids;\n }\n return [];\n};\n\nexport const overrideElements = (\n hilitedIds: string[],\n color: string,\n overrideType = FeatureOverrideType.ColorOnly,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n hilitedIds,\n vp,\n ColorDef.fromString(color),\n overrideType,\n true,\n );\n};\n\nexport const clearOverriddenElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearOverriddenElements(vp);\n};\n\nexport const emphasizeElements = (\n hilitedIds: string[],\n defaultAppearance: FeatureAppearance | undefined = undefined,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.wantEmphasis = true;\n emph.emphasizeElements(hilitedIds, vp, defaultAppearance, replace);\n};\n\nexport const emphasisElementsById = async (\n iModelConnection: IModelConnection,\n elementIds: string[],\n defaultAppearance: FeatureAppearance | undefined = undefined,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n emphasizeElements(ids, defaultAppearance, replace);\n return ids;\n }\n return [];\n};\n\nexport const emphasizeElementsByKeys = async (\n keySet: KeySet,\n defaultAppearance: FeatureAppearance | undefined = undefined,\n replace = false,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n emphasizeElements(ids, defaultAppearance, replace);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsById = async (\n elementIds: string[],\n color: string,\n iModelConnection: IModelConnection,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsByKeys = async (\n keySet: KeySet,\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElements = (\n elementIds: string[],\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n elementIds,\n vp,\n ColorDef.fromString(color),\n FeatureOverrideType.ColorAndAlpha,\n true,\n );\n if (!wantEmphasis) {\n return;\n }\n emph.wantEmphasis = true;\n emph.emphasizeElements(elementIds, vp, undefined, replace);\n};\n\nexport const transparentOverriddenElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n const ids = emph.getOverriddenElements()?.values();\n if (ids) {\n const toOverride = new Set<string>();\n Array.from(ids).forEach((a) => a.forEach((id) => toOverride.add(id)));\n emph.overrideElements(\n toOverride,\n vp,\n ColorDef.red.withAlpha(50),\n FeatureOverrideType.AlphaOnly,\n true,\n );\n }\n};\n\nexport const zoomToElements = async (elementIds: string[]) => {\n if (!IModelApp.viewManager.selectedView || elementIds.length === 0) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const viewChangeOpts: ViewChangeOptions = {};\n viewChangeOpts.animateFrustumChange = true;\n // It was removed. Should be a prop to be passed to lookAtViewAlignedVolume within the implementation.\n // viewChangeOpts.marginPercent = new MarginPercent(0.1, 0.1, 0.1, 0.1);\n await vp.zoomToElements(elementIds, { ...viewChangeOpts });\n};\n\nexport const getHiliteIds = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n return [...set.elements];\n }\n return [];\n};\n\nexport const manufactureKeys = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n): Promise<KeySet> => {\n // segment ids into batches\n const batches: string[][] = [];\n let currBatch: string[] = [];\n const batchSize = 100000;\n for (const id of elementIds) {\n if (currBatch.length < batchSize) {\n currBatch.push(id);\n } else {\n batches.push(currBatch);\n currBatch = [id];\n }\n }\n if (currBatch.length > 0 && currBatch.length <= batchSize) {\n batches.push(currBatch);\n }\n\n // retrieve element properties in batches\n let elemProps: ElementProps[] = [];\n for (const batch of batches) {\n const props = await iModelConnection.elements.getProps(batch);\n elemProps = elemProps.concat(props);\n }\n\n const isElementId = (elem: {\n id: string | undefined;\n className: string;\n }): elem is {\n id: string;\n className: string;\n } => {\n return elem.id !== undefined;\n };\n\n // create keyset from the element properties\n const keys = elemProps\n .map((elem: ElementProps) => ({\n id: elem.id,\n className: elem.classFullName,\n }))\n .filter(isElementId);\n return new KeySet(keys);\n};\n\nexport const clearEmphasizedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n};\n\nexport const clearEmphasizedOverriddenElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n};\n\nexport const clearAll = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n emph.clearHiddenElements(vp);\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PropertyMap } from "../../formula/Types";
|
|
2
|
-
export declare function useFormulaValidation(formula: string, properties: PropertyMap, setFormulaErrorMessage: (s: string) => void): {
|
|
2
|
+
export declare function useFormulaValidation(formulaName: string, formula: string, properties: PropertyMap, setFormulaErrorMessage: (s: string) => void): {
|
|
3
3
|
isValid: boolean;
|
|
4
4
|
forceValidation: () => boolean;
|
|
5
5
|
};
|
|
@@ -3,23 +3,24 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { useEffect, useState } from "react";
|
|
6
|
-
import {
|
|
6
|
+
import { resolveFormulaDataType } from "../../formula/FormulaDataTypeResolver";
|
|
7
7
|
import { debounce } from "../utils";
|
|
8
|
-
function validate(formula, properties, setFormulaErrorMessage, setIsValid) {
|
|
8
|
+
function validate(formulaName, formula, properties, setFormulaErrorMessage, setIsValid) {
|
|
9
|
+
var _a;
|
|
9
10
|
if (!formula) {
|
|
10
11
|
setFormulaErrorMessage("");
|
|
11
12
|
setIsValid(false);
|
|
12
13
|
return false;
|
|
13
14
|
}
|
|
14
|
-
const error =
|
|
15
|
+
const error = (_a = resolveFormulaDataType(formulaName, formula, properties).errorMessage) !== null && _a !== void 0 ? _a : "";
|
|
15
16
|
setFormulaErrorMessage(error);
|
|
16
17
|
setIsValid(!error);
|
|
17
18
|
return !error;
|
|
18
19
|
}
|
|
19
20
|
const debouncedValidationFunc = debounce(validate, 1000);
|
|
20
|
-
export function useFormulaValidation(formula, properties, setFormulaErrorMessage) {
|
|
21
|
+
export function useFormulaValidation(formulaName, formula, properties, setFormulaErrorMessage) {
|
|
21
22
|
const [isValid, setIsValid] = useState(false);
|
|
22
|
-
useEffect(() => debouncedValidationFunc(formula, properties, setFormulaErrorMessage, setIsValid), [formula, properties, setFormulaErrorMessage]);
|
|
23
|
-
return { isValid, forceValidation: () => validate(formula, properties, setFormulaErrorMessage, setIsValid) };
|
|
23
|
+
useEffect(() => debouncedValidationFunc(formulaName, formula, properties, setFormulaErrorMessage, setIsValid), [formulaName, formula, properties, setFormulaErrorMessage]);
|
|
24
|
+
return { isValid, forceValidation: () => validate(formulaName, formula, properties, setFormulaErrorMessage, setIsValid) };
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=useFormulaValidation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormulaValidation.js","sourceRoot":"","sources":["../../../../src/widget/hooks/useFormulaValidation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useFormulaValidation.js","sourceRoot":"","sources":["../../../../src/widget/hooks/useFormulaValidation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,SAAS,QAAQ,CAAC,WAAmB,EAAE,OAAe,EAAE,UAAuB,EAAE,sBAA2C,EAAE,UAAgC;;IAC5J,IAAI,CAAC,OAAO,EAAE;QACZ,sBAAsB,CAAC,EAAE,CAAC,CAAC;QAC3B,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,KAAK,CAAC;KACd;IAED,MAAM,KAAK,GAAG,MAAA,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,YAAY,mCAAI,EAAE,CAAC;IAC1F,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9B,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO,CAAC,KAAK,CAAC;AAChB,CAAC;AAED,MAAM,uBAAuB,GAAG,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAEzD,MAAM,UAAU,oBAAoB,CAAC,WAAmB,EAAE,OAAe,EAAE,UAAuB,EAAE,sBAA2C;IAC7I,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAC3K,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,CAAC,EAAE,CAAC;AAC5H,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 { PropertyMap } from \"../../formula/Types\";\nimport { debounce } from \"../utils\";\n\nfunction validate(formulaName: string, formula: string, properties: PropertyMap, setFormulaErrorMessage: (s: string) => void, setIsValid: (b: boolean) => void): boolean {\n if (!formula) {\n setFormulaErrorMessage(\"\");\n setIsValid(false);\n return false;\n }\n\n const error = resolveFormulaDataType(formulaName, formula, properties).errorMessage ?? \"\";\n setFormulaErrorMessage(error);\n setIsValid(!error);\n return !error;\n}\n\nconst debouncedValidationFunc = debounce(validate, 1000);\n\nexport function useFormulaValidation(formulaName: string, formula: string, properties: PropertyMap, setFormulaErrorMessage: (s: string) => void) {\n const [isValid, setIsValid] = useState(false);\n useEffect(() => debouncedValidationFunc(formulaName, formula, properties, setFormulaErrorMessage, setIsValid), [formulaName, formula, properties, setFormulaErrorMessage]);\n return { isValid, forceValidation: () => validate(formulaName, formula, properties, setFormulaErrorMessage, setIsValid) };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/grouping-mapping-widget",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "An iTwin.js 3D Viewer Widget that interfaces with the iTwin Reporting Platform.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Bentley",
|
|
@@ -37,35 +37,35 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@itwin/imodel-browser-react": "^0.12.1",
|
|
40
|
-
"@itwin/insights-client": "0.
|
|
40
|
+
"@itwin/insights-client": "0.2.1",
|
|
41
41
|
"@itwin/itwinui-icons-react": "^1.7.0",
|
|
42
|
-
"@itwin/itwinui-react": "
|
|
42
|
+
"@itwin/itwinui-react": "~1.37.3",
|
|
43
43
|
"classnames": "^2.3.1",
|
|
44
44
|
"cross-fetch": "^3.1.4",
|
|
45
45
|
"immer": "^9.0.7",
|
|
46
46
|
"simple-react-validator": "^1.6.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@itwin/appui-abstract": "^3.
|
|
50
|
-
"@itwin/appui-layout-react": "^3.
|
|
51
|
-
"@itwin/appui-react": "^3.
|
|
52
|
-
"@itwin/build-tools": "^3.
|
|
53
|
-
"@itwin/components-react": "^3.
|
|
54
|
-
"@itwin/core-bentley": "^3.
|
|
55
|
-
"@itwin/core-common": "^3.
|
|
56
|
-
"@itwin/core-frontend": "^3.
|
|
57
|
-
"@itwin/core-geometry": "^3.
|
|
58
|
-
"@itwin/core-i18n": "^3.
|
|
59
|
-
"@itwin/core-markup": "^3.
|
|
60
|
-
"@itwin/core-orbitgt": "^3.
|
|
61
|
-
"@itwin/core-quantity": "^3.
|
|
62
|
-
"@itwin/core-react": "^3.
|
|
63
|
-
"@itwin/eslint-plugin": "^3.
|
|
64
|
-
"@itwin/imodel-components-react": "^3.
|
|
65
|
-
"@itwin/presentation-common": "^3.
|
|
66
|
-
"@itwin/presentation-components": "^3.
|
|
67
|
-
"@itwin/presentation-frontend": "^3.
|
|
68
|
-
"@itwin/webgl-compatibility": "^3.
|
|
49
|
+
"@itwin/appui-abstract": "^3.2.0",
|
|
50
|
+
"@itwin/appui-layout-react": "^3.2.0",
|
|
51
|
+
"@itwin/appui-react": "^3.2.0",
|
|
52
|
+
"@itwin/build-tools": "^3.2.0",
|
|
53
|
+
"@itwin/components-react": "^3.2.0",
|
|
54
|
+
"@itwin/core-bentley": "^3.2.0",
|
|
55
|
+
"@itwin/core-common": "^3.2.0",
|
|
56
|
+
"@itwin/core-frontend": "^3.2.0",
|
|
57
|
+
"@itwin/core-geometry": "^3.2.0",
|
|
58
|
+
"@itwin/core-i18n": "^3.2.0",
|
|
59
|
+
"@itwin/core-markup": "^3.2.0",
|
|
60
|
+
"@itwin/core-orbitgt": "^3.2.0",
|
|
61
|
+
"@itwin/core-quantity": "^3.2.0",
|
|
62
|
+
"@itwin/core-react": "^3.2.0",
|
|
63
|
+
"@itwin/eslint-plugin": "^3.2.0",
|
|
64
|
+
"@itwin/imodel-components-react": "^3.2.0",
|
|
65
|
+
"@itwin/presentation-common": "^3.2.0",
|
|
66
|
+
"@itwin/presentation-components": "^3.2.0",
|
|
67
|
+
"@itwin/presentation-frontend": "^3.2.0",
|
|
68
|
+
"@itwin/webgl-compatibility": "^3.2.0",
|
|
69
69
|
"@types/i18next": "^8.4.2",
|
|
70
70
|
"@types/node": "^14.14.20",
|
|
71
71
|
"@types/react": "^17.0.19",
|
|
@@ -87,13 +87,13 @@
|
|
|
87
87
|
"typescript": "~4.3.0"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"@itwin/appui-abstract": "^3.
|
|
91
|
-
"@itwin/appui-react": "^3.
|
|
92
|
-
"@itwin/components-react": "^3.
|
|
93
|
-
"@itwin/core-frontend": "^3.
|
|
94
|
-
"@itwin/core-react": "^3.
|
|
95
|
-
"@itwin/presentation-components": "^3.
|
|
96
|
-
"@itwin/presentation-frontend": "^3.
|
|
90
|
+
"@itwin/appui-abstract": "^3.2.0",
|
|
91
|
+
"@itwin/appui-react": "^3.2.0",
|
|
92
|
+
"@itwin/components-react": "^3.2.0",
|
|
93
|
+
"@itwin/core-frontend": "^3.2.0",
|
|
94
|
+
"@itwin/core-react": "^3.2.0",
|
|
95
|
+
"@itwin/presentation-components": "^3.2.0",
|
|
96
|
+
"@itwin/presentation-frontend": "^3.2.0",
|
|
97
97
|
"react": "^17.0.2",
|
|
98
98
|
"react-dom": "^17.0.2",
|
|
99
99
|
"react-redux": "^7.2.0"
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Token } from "./InfixToPostfixConverter";
|
|
2
|
-
import type { Queue } from "./Queue";
|
|
3
|
-
import type { PropertyMap } from "./Types";
|
|
4
|
-
export declare function validateTokens(tokens: Queue<Token>, properties: PropertyMap): string;
|
|
5
|
-
//# sourceMappingURL=FormulaTokensValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormulaTokensValidator.js","sourceRoot":"","sources":["../../../src/formula/FormulaTokensValidator.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,uEAAsF;AACtF,yEAA+G;AAE/G,uEAAsD;AAEtD,mCA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,CAAC,CAAC,KAAK,CAAC,EAAE;wBACxB,OAAO,aAAa,KAAK,CAAC,KAAK,sCAAsC,KAAK,CAAC,QAAQ,wBAAwB,CAAC;qBAC7G;yBAAM;wBACL,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,EAAE;4BACxB,OAAO,aAAa,KAAK,CAAC,KAAK,sBAAsB,WAAW,CAAC,CAAC,CAAC,uCAAuC,CAAC;yBAC5G;6BAAM;4BACL,OAAO,aAAa,KAAK,CAAC,KAAK,sBAAsB,WAAW,CAAC,CAAC,CAAC,mBAAmB,KAAK,CAAC,QAAQ,wBAAwB,CAAC;yBAC9H;qBACF;iBACF;gBAED,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;gBACtD,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE;oBACjC,OAAO,yCAAyC,KAAK,CAAC,KAAK,IAAI,CAAC;iBACjE;gBAED,MAAM,cAAc,GAAG,sDAA4B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAClE,IAAI,cAAc,CAAC,YAAY;oBAC7B,OAAO,aAAa,KAAK,CAAC,KAAK,iBAAiB,cAAc,CAAC,YAAY,EAAE,CAAC;;oBAE9E,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,KAAM,CAAC,CAAC;gBAEvC,MAAM;SACT;KACF;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO,qBAAqB,CAAC;KAC9B;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAClC,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,WAAW,EAAE;QAC7C,OAAO,oCAAoC,CAAC;KAC7C;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AArHD,wCAqHC","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 { getFormulaFunctionReturnType, getFunction } from \"./FormulaFunctionProvider\";\nimport { getOperatorArgumentCountBounds, getOperatorReturnType, isOperator } from \"./FormulaOperatorsProvider\";\nimport type { Token } from \"./InfixToPostfixConverter\";\nimport { TokenType } from \"./InfixToPostfixConverter\";\nimport type { Queue } from \"./Queue\";\nimport { Stack } from \"./Stack\";\nimport type { PossibleDataType, PropertyMap } from \"./Types\";\n\nfunction isNumericalConstant(name: string): boolean {\n return [\n \"e\",\n \"ln2\",\n \"ln10\",\n \"log2e\",\n \"log10e\",\n \"pi\",\n \"sqrt1_2\",\n \"sqrt2\",\n ].includes(name.toLowerCase());\n}\n\nexport function validateTokens(tokens: Queue<Token>, properties: PropertyMap): string {\n if (tokens.length === 0)\n return \"Formula cannot be empty.\";\n\n const argStack = new Stack<PossibleDataType>();\n\n while (tokens.length > 0) {\n const token = tokens.dequeue()!;\n\n switch (token.type) {\n case TokenType.Number:\n argStack.push(\"number\");\n break;\n case TokenType.String:\n argStack.push(\"string\");\n break;\n case TokenType.Boolean:\n argStack.push(\"boolean\");\n break;\n case TokenType.Null:\n argStack.push(\"undefined\");\n break;\n case TokenType.Variable:\n const isConstant = isNumericalConstant(token.value);\n if (isConstant) {\n argStack.push(\"number\");\n } else {\n const prop = properties[token.value];\n if (!prop)\n return `Variable \"${token.value}\" is not available.`;\n argStack.push(prop);\n }\n break;\n case TokenType.Operator:\n if (!isOperator(token.value))\n return `Operator \"${token.value}\" is not supported.`;\n\n const operatorBounds = getOperatorArgumentCountBounds(token.value);\n if (!operatorBounds)\n return `Operator \"${token.value}\" is not supported.`;\n\n if (operatorBounds[0] === 2 && token.argCount === 1)\n return `Unary operator \"${token.value}\" is not supported.`;\n\n if (argStack.length < token.argCount) {\n return `Too few arguments given for ${token.argCount === 1 ? \"unary\" : \"binary\"} operator \"${token.value}\".`;\n }\n const opArgs = argStack.popN(token.argCount).reverse();\n let operationResult;\n if (opArgs.length === 1)\n operationResult = getOperatorReturnType(token.value, opArgs[0]);\n else if (opArgs.length === 2)\n operationResult = getOperatorReturnType(token.value, opArgs[0], opArgs[1]);\n else\n return `Operator \"${token.value}\" does not support ${token.argCount} operands.`;\n\n if (operationResult.errorMessage)\n return operationResult.errorMessage;\n else\n argStack.push(operationResult.value!);\n\n break;\n case TokenType.Function:\n const fnArg = getFunction(token.value);\n if (!fnArg)\n return `Function \"${token.value}\" is not supported.`;\n\n const fnArgBounds = fnArg.argumentCountBounds;\n if (fnArgBounds[0] === 0 && fnArgBounds[1] === 0 && token.argCount > 0) {\n return `Function \"${token.value}\" does not accept any arguments.`;\n } else if (fnArgBounds[1] === -1 && token.argCount < fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return `Function \"${token.value}\" requires at least 1 argument.`;\n } else {\n if (token.argCount === 1) {\n return `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only 1 argument was given.`;\n } else {\n return `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only ${token.argCount} arguments were given.`;\n }\n }\n } else if (fnArgBounds[0] === fnArgBounds[1] && token.argCount !== fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return `Function \"${token.value}\" requires exactly 1 argument, but ${token.argCount} arguments were given.`;\n } else {\n if (token.argCount === 1) {\n return `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but 1 argument was given.`;\n } else {\n return `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but ${token.argCount} arguments were given.`;\n }\n }\n }\n\n const fArgs = argStack.popN(token.argCount).reverse();\n if (fArgs.length < token.argCount) {\n return `Too few arguments given for function \"${token.value}\".`;\n }\n\n const functionResult = getFormulaFunctionReturnType(fnArg, fArgs);\n if (functionResult.errorMessage)\n return `Function \"${token.value}\" is invalid. ${functionResult.errorMessage}`;\n else\n argStack.push(functionResult.value!);\n\n break;\n }\n }\n\n if (argStack.length !== 1) {\n return \"Formula is invalid.\";\n }\n\n const resultType = argStack.pop();\n if (!resultType || resultType === \"undefined\") {\n return \"Formula cannot always return null.\";\n }\n\n return \"\";\n}\n\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFormula = void 0;
|
|
4
|
-
/*---------------------------------------------------------------------------------------------
|
|
5
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
-
*--------------------------------------------------------------------------------------------*/
|
|
8
|
-
const FormulaSplitter_1 = require("./FormulaSplitter");
|
|
9
|
-
const FormulaTokensValidator_1 = require("./FormulaTokensValidator");
|
|
10
|
-
const InfixToPostfixConverter_1 = require("./InfixToPostfixConverter");
|
|
11
|
-
const ParenthesisValidator_1 = require("./ParenthesisValidator");
|
|
12
|
-
function validateFormula(formula, properties) {
|
|
13
|
-
var _a;
|
|
14
|
-
const parenthesisState = ParenthesisValidator_1.validateParenthesis(formula);
|
|
15
|
-
if (ParenthesisValidator_1.ParenthesisState.NotClosed === parenthesisState) {
|
|
16
|
-
return "Opened but not closed parenthesis found.";
|
|
17
|
-
}
|
|
18
|
-
else if (ParenthesisValidator_1.ParenthesisState.NotOpened === parenthesisState) {
|
|
19
|
-
return "Closed but not opened parenthesis found.";
|
|
20
|
-
}
|
|
21
|
-
let infixFormulaTokens;
|
|
22
|
-
try {
|
|
23
|
-
infixFormulaTokens = FormulaSplitter_1.splitFormula(formula);
|
|
24
|
-
}
|
|
25
|
-
catch (ex) {
|
|
26
|
-
return ex.message;
|
|
27
|
-
}
|
|
28
|
-
const postfixFormulaTokens = InfixToPostfixConverter_1.convertInfixToPostfix(infixFormulaTokens);
|
|
29
|
-
if (undefined === postfixFormulaTokens.value) {
|
|
30
|
-
return (_a = postfixFormulaTokens.errorMessage) !== null && _a !== void 0 ? _a : "Unknown error";
|
|
31
|
-
}
|
|
32
|
-
return FormulaTokensValidator_1.validateTokens(postfixFormulaTokens.value, properties);
|
|
33
|
-
}
|
|
34
|
-
exports.validateFormula = validateFormula;
|
|
35
|
-
//# sourceMappingURL=FormulaValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormulaValidator.js","sourceRoot":"","sources":["../../../src/formula/FormulaValidator.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,uDAAiD;AACjD,qEAA0D;AAC1D,uEAAkE;AAClE,iEAA+E;AAG/E,SAAgB,eAAe,CAAC,OAAe,EAAE,UAAuB;;IACtE,MAAM,gBAAgB,GAAG,0CAAmB,CAAC,OAAO,CAAC,CAAC;IACtD,IAAI,uCAAgB,CAAC,SAAS,KAAK,gBAAgB,EAAE;QACnD,OAAO,0CAA0C,CAAC;KACnD;SAAM,IAAI,uCAAgB,CAAC,SAAS,KAAK,gBAAgB,EAAE;QAC1D,OAAO,0CAA0C,CAAC;KACnD;IAED,IAAI,kBAAkB,CAAC;IACvB,IAAI;QACF,kBAAkB,GAAG,8BAAY,CAAC,OAAO,CAAC,CAAC;KAC5C;IAAC,OAAO,EAAE,EAAE;QACX,OAAQ,EAAY,CAAC,OAAO,CAAC;KAC9B;IAED,MAAM,oBAAoB,GAAG,+CAAqB,CAAC,kBAAkB,CAAC,CAAC;IAEvE,IAAI,SAAS,KAAK,oBAAoB,CAAC,KAAK,EAAE;QAC5C,OAAO,MAAA,oBAAoB,CAAC,YAAY,mCAAI,eAAe,CAAC;KAC7D;IAED,OAAO,uCAAc,CAAC,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AAChE,CAAC;AAtBD,0CAsBC","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 { splitFormula } from \"./FormulaSplitter\";\nimport { validateTokens } from \"./FormulaTokensValidator\";\nimport { convertInfixToPostfix } from \"./InfixToPostfixConverter\";\nimport { ParenthesisState, validateParenthesis } from \"./ParenthesisValidator\";\nimport type { PropertyMap } from \"./Types\";\n\nexport function validateFormula(formula: string, properties: PropertyMap): string {\n const parenthesisState = validateParenthesis(formula);\n if (ParenthesisState.NotClosed === parenthesisState) {\n return \"Opened but not closed parenthesis found.\";\n } else if (ParenthesisState.NotOpened === parenthesisState) {\n return \"Closed but not opened parenthesis found.\";\n }\n\n let infixFormulaTokens;\n try {\n infixFormulaTokens = splitFormula(formula);\n } catch (ex) {\n return (ex as Error).message;\n }\n\n const postfixFormulaTokens = convertInfixToPostfix(infixFormulaTokens);\n\n if (undefined === postfixFormulaTokens.value) {\n return postfixFormulaTokens.errorMessage ?? \"Unknown error\";\n }\n\n return validateTokens(postfixFormulaTokens.value, properties);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GroupQueryBuilderContext.js","sourceRoot":"","sources":["../../../../src/widget/components/GroupQueryBuilderContext.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,6CAA+B;AAE/B,iDAA8C;AAcjC,QAAA,wBAAwB,GAAG,KAAK,CAAC,aAAa,CAAoB;IAC7E,mBAAmB,EAAE,EAAE;IACvB,sBAAsB,EAAE,GAAG,EAAE,CAAC,EAAE;IAChC,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE;IAClB,YAAY,EAAE,IAAI,2BAAY,CAAC,SAAS,CAAC;IACzC,eAAe,EAAE,GAAG,EAAE,CAAC,IAAI,2BAAY,CAAC,SAAS,CAAC;IAClD,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,KAAK;CACnB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { QueryBuilder } from \"./QueryBuilder\";\n\nexport interface PropertySelection {\n currentPropertyList: PropertyRecord[];\n setCurrentPropertyList: React.Dispatch<\n React.SetStateAction<PropertyRecord[]>\n >;\n query: string;\n setQuery: React.Dispatch<React.SetStateAction<string>>;\n queryBuilder: QueryBuilder;\n setQueryBuilder: React.Dispatch<React.SetStateAction<QueryBuilder>>;\n isLoading: boolean;\n isRendering: boolean;\n}\nexport const GroupQueryBuilderContext = React.createContext<PropertySelection>({\n currentPropertyList: [],\n setCurrentPropertyList: () => [],\n query: \"\",\n setQuery: () => \"\",\n queryBuilder: new QueryBuilder(undefined),\n setQueryBuilder: () => new QueryBuilder(undefined),\n isLoading: false,\n isRendering: false,\n});\n"]}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Token } from "./InfixToPostfixConverter";
|
|
2
|
-
import type { Queue } from "./Queue";
|
|
3
|
-
import type { PropertyMap } from "./Types";
|
|
4
|
-
export declare function validateTokens(tokens: Queue<Token>, properties: PropertyMap): string;
|
|
5
|
-
//# sourceMappingURL=FormulaTokensValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormulaTokensValidator.js","sourceRoot":"","sources":["../../../src/formula/FormulaTokensValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,4BAA4B,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE/G,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,SAAS,mBAAmB,CAAC,IAAY;IACvC,OAAO;QACL,GAAG;QACH,KAAK;QACL,MAAM;QACN,OAAO;QACP,QAAQ;QACR,IAAI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AAM;wBACL,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,EAAE;4BACxB,OAAO,aAAa,KAAK,CAAC,KAAK,sBAAsB,WAAW,CAAC,CAAC,CAAC,uCAAuC,CAAC;yBAC5G;6BAAM;4BACL,OAAO,aAAa,KAAK,CAAC,KAAK,sBAAsB,WAAW,CAAC,CAAC,CAAC,mBAAmB,KAAK,CAAC,QAAQ,wBAAwB,CAAC;yBAC9H;qBACF;iBACF;gBAED,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;gBACtD,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE;oBACjC,OAAO,yCAAyC,KAAK,CAAC,KAAK,IAAI,CAAC;iBACjE;gBAED,MAAM,cAAc,GAAG,4BAA4B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAClE,IAAI,cAAc,CAAC,YAAY;oBAC7B,OAAO,aAAa,KAAK,CAAC,KAAK,iBAAiB,cAAc,CAAC,YAAY,EAAE,CAAC;;oBAE9E,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,KAAM,CAAC,CAAC;gBAEvC,MAAM;SACT;KACF;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO,qBAAqB,CAAC;KAC9B;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;IAClC,IAAI,CAAC,UAAU,IAAI,UAAU,KAAK,WAAW,EAAE;QAC7C,OAAO,oCAAoC,CAAC;KAC7C;IAED,OAAO,EAAE,CAAC;AACZ,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 { getFormulaFunctionReturnType, getFunction } from \"./FormulaFunctionProvider\";\nimport { getOperatorArgumentCountBounds, getOperatorReturnType, isOperator } from \"./FormulaOperatorsProvider\";\nimport type { Token } from \"./InfixToPostfixConverter\";\nimport { TokenType } from \"./InfixToPostfixConverter\";\nimport type { Queue } from \"./Queue\";\nimport { Stack } from \"./Stack\";\nimport type { PossibleDataType, PropertyMap } from \"./Types\";\n\nfunction isNumericalConstant(name: string): boolean {\n return [\n \"e\",\n \"ln2\",\n \"ln10\",\n \"log2e\",\n \"log10e\",\n \"pi\",\n \"sqrt1_2\",\n \"sqrt2\",\n ].includes(name.toLowerCase());\n}\n\nexport function validateTokens(tokens: Queue<Token>, properties: PropertyMap): string {\n if (tokens.length === 0)\n return \"Formula cannot be empty.\";\n\n const argStack = new Stack<PossibleDataType>();\n\n while (tokens.length > 0) {\n const token = tokens.dequeue()!;\n\n switch (token.type) {\n case TokenType.Number:\n argStack.push(\"number\");\n break;\n case TokenType.String:\n argStack.push(\"string\");\n break;\n case TokenType.Boolean:\n argStack.push(\"boolean\");\n break;\n case TokenType.Null:\n argStack.push(\"undefined\");\n break;\n case TokenType.Variable:\n const isConstant = isNumericalConstant(token.value);\n if (isConstant) {\n argStack.push(\"number\");\n } else {\n const prop = properties[token.value];\n if (!prop)\n return `Variable \"${token.value}\" is not available.`;\n argStack.push(prop);\n }\n break;\n case TokenType.Operator:\n if (!isOperator(token.value))\n return `Operator \"${token.value}\" is not supported.`;\n\n const operatorBounds = getOperatorArgumentCountBounds(token.value);\n if (!operatorBounds)\n return `Operator \"${token.value}\" is not supported.`;\n\n if (operatorBounds[0] === 2 && token.argCount === 1)\n return `Unary operator \"${token.value}\" is not supported.`;\n\n if (argStack.length < token.argCount) {\n return `Too few arguments given for ${token.argCount === 1 ? \"unary\" : \"binary\"} operator \"${token.value}\".`;\n }\n const opArgs = argStack.popN(token.argCount).reverse();\n let operationResult;\n if (opArgs.length === 1)\n operationResult = getOperatorReturnType(token.value, opArgs[0]);\n else if (opArgs.length === 2)\n operationResult = getOperatorReturnType(token.value, opArgs[0], opArgs[1]);\n else\n return `Operator \"${token.value}\" does not support ${token.argCount} operands.`;\n\n if (operationResult.errorMessage)\n return operationResult.errorMessage;\n else\n argStack.push(operationResult.value!);\n\n break;\n case TokenType.Function:\n const fnArg = getFunction(token.value);\n if (!fnArg)\n return `Function \"${token.value}\" is not supported.`;\n\n const fnArgBounds = fnArg.argumentCountBounds;\n if (fnArgBounds[0] === 0 && fnArgBounds[1] === 0 && token.argCount > 0) {\n return `Function \"${token.value}\" does not accept any arguments.`;\n } else if (fnArgBounds[1] === -1 && token.argCount < fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return `Function \"${token.value}\" requires at least 1 argument.`;\n } else {\n if (token.argCount === 1) {\n return `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only 1 argument was given.`;\n } else {\n return `Function \"${token.value}\" requires at least ${fnArgBounds[0]} arguments, but only ${token.argCount} arguments were given.`;\n }\n }\n } else if (fnArgBounds[0] === fnArgBounds[1] && token.argCount !== fnArgBounds[0]) {\n if (fnArgBounds[0] === 1) {\n return `Function \"${token.value}\" requires exactly 1 argument, but ${token.argCount} arguments were given.`;\n } else {\n if (token.argCount === 1) {\n return `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but 1 argument was given.`;\n } else {\n return `Function \"${token.value}\" requires exactly ${fnArgBounds[0]} arguments, but ${token.argCount} arguments were given.`;\n }\n }\n }\n\n const fArgs = argStack.popN(token.argCount).reverse();\n if (fArgs.length < token.argCount) {\n return `Too few arguments given for function \"${token.value}\".`;\n }\n\n const functionResult = getFormulaFunctionReturnType(fnArg, fArgs);\n if (functionResult.errorMessage)\n return `Function \"${token.value}\" is invalid. ${functionResult.errorMessage}`;\n else\n argStack.push(functionResult.value!);\n\n break;\n }\n }\n\n if (argStack.length !== 1) {\n return \"Formula is invalid.\";\n }\n\n const resultType = argStack.pop();\n if (!resultType || resultType === \"undefined\") {\n return \"Formula cannot always return null.\";\n }\n\n return \"\";\n}\n\n"]}
|
|
@@ -1,31 +0,0 @@
|
|
|
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 { splitFormula } from "./FormulaSplitter";
|
|
6
|
-
import { validateTokens } from "./FormulaTokensValidator";
|
|
7
|
-
import { convertInfixToPostfix } from "./InfixToPostfixConverter";
|
|
8
|
-
import { ParenthesisState, validateParenthesis } from "./ParenthesisValidator";
|
|
9
|
-
export function validateFormula(formula, properties) {
|
|
10
|
-
var _a;
|
|
11
|
-
const parenthesisState = validateParenthesis(formula);
|
|
12
|
-
if (ParenthesisState.NotClosed === parenthesisState) {
|
|
13
|
-
return "Opened but not closed parenthesis found.";
|
|
14
|
-
}
|
|
15
|
-
else if (ParenthesisState.NotOpened === parenthesisState) {
|
|
16
|
-
return "Closed but not opened parenthesis found.";
|
|
17
|
-
}
|
|
18
|
-
let infixFormulaTokens;
|
|
19
|
-
try {
|
|
20
|
-
infixFormulaTokens = splitFormula(formula);
|
|
21
|
-
}
|
|
22
|
-
catch (ex) {
|
|
23
|
-
return ex.message;
|
|
24
|
-
}
|
|
25
|
-
const postfixFormulaTokens = convertInfixToPostfix(infixFormulaTokens);
|
|
26
|
-
if (undefined === postfixFormulaTokens.value) {
|
|
27
|
-
return (_a = postfixFormulaTokens.errorMessage) !== null && _a !== void 0 ? _a : "Unknown error";
|
|
28
|
-
}
|
|
29
|
-
return validateTokens(postfixFormulaTokens.value, properties);
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=FormulaValidator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormulaValidator.js","sourceRoot":"","sources":["../../../src/formula/FormulaValidator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG/E,MAAM,UAAU,eAAe,CAAC,OAAe,EAAE,UAAuB;;IACtE,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACtD,IAAI,gBAAgB,CAAC,SAAS,KAAK,gBAAgB,EAAE;QACnD,OAAO,0CAA0C,CAAC;KACnD;SAAM,IAAI,gBAAgB,CAAC,SAAS,KAAK,gBAAgB,EAAE;QAC1D,OAAO,0CAA0C,CAAC;KACnD;IAED,IAAI,kBAAkB,CAAC;IACvB,IAAI;QACF,kBAAkB,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;KAC5C;IAAC,OAAO,EAAE,EAAE;QACX,OAAQ,EAAY,CAAC,OAAO,CAAC;KAC9B;IAED,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAEvE,IAAI,SAAS,KAAK,oBAAoB,CAAC,KAAK,EAAE;QAC5C,OAAO,MAAA,oBAAoB,CAAC,YAAY,mCAAI,eAAe,CAAC;KAC7D;IAED,OAAO,cAAc,CAAC,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AAChE,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 { splitFormula } from \"./FormulaSplitter\";\nimport { validateTokens } from \"./FormulaTokensValidator\";\nimport { convertInfixToPostfix } from \"./InfixToPostfixConverter\";\nimport { ParenthesisState, validateParenthesis } from \"./ParenthesisValidator\";\nimport type { PropertyMap } from \"./Types\";\n\nexport function validateFormula(formula: string, properties: PropertyMap): string {\n const parenthesisState = validateParenthesis(formula);\n if (ParenthesisState.NotClosed === parenthesisState) {\n return \"Opened but not closed parenthesis found.\";\n } else if (ParenthesisState.NotOpened === parenthesisState) {\n return \"Closed but not opened parenthesis found.\";\n }\n\n let infixFormulaTokens;\n try {\n infixFormulaTokens = splitFormula(formula);\n } catch (ex) {\n return (ex as Error).message;\n }\n\n const postfixFormulaTokens = convertInfixToPostfix(infixFormulaTokens);\n\n if (undefined === postfixFormulaTokens.value) {\n return postfixFormulaTokens.errorMessage ?? \"Unknown error\";\n }\n\n return validateTokens(postfixFormulaTokens.value, properties);\n}\n"]}
|