@itwin/grouping-mapping-widget 0.3.0 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/lib/cjs/formula/FormulaFunctionProvider.d.ts +18 -0
  2. package/lib/cjs/formula/FormulaFunctionProvider.js +136 -0
  3. package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -0
  4. package/lib/cjs/formula/FormulaOperatorsProvider.d.ts +34 -0
  5. package/lib/cjs/formula/FormulaOperatorsProvider.js +185 -0
  6. package/lib/cjs/formula/FormulaOperatorsProvider.js.map +1 -0
  7. package/lib/cjs/formula/FormulaSplitter.d.ts +2 -0
  8. package/lib/cjs/formula/FormulaSplitter.js +140 -0
  9. package/lib/cjs/formula/FormulaSplitter.js.map +1 -0
  10. package/lib/cjs/formula/FormulaTokensValidator.d.ts +5 -0
  11. package/lib/cjs/formula/FormulaTokensValidator.js +135 -0
  12. package/lib/cjs/formula/FormulaTokensValidator.js.map +1 -0
  13. package/lib/cjs/formula/FormulaValidator.d.ts +3 -0
  14. package/lib/cjs/formula/FormulaValidator.js +35 -0
  15. package/lib/cjs/formula/FormulaValidator.js.map +1 -0
  16. package/lib/cjs/formula/IResult.d.ts +5 -0
  17. package/lib/cjs/formula/IResult.js +3 -0
  18. package/lib/cjs/formula/IResult.js.map +1 -0
  19. package/lib/cjs/formula/InfixToPostfixConverter.d.ts +18 -0
  20. package/lib/cjs/formula/InfixToPostfixConverter.js +299 -0
  21. package/lib/cjs/formula/InfixToPostfixConverter.js.map +1 -0
  22. package/lib/cjs/formula/InputStream.d.ts +12 -0
  23. package/lib/cjs/formula/InputStream.js +36 -0
  24. package/lib/cjs/formula/InputStream.js.map +1 -0
  25. package/lib/cjs/formula/ParenthesisValidator.d.ts +7 -0
  26. package/lib/cjs/formula/ParenthesisValidator.js +34 -0
  27. package/lib/cjs/formula/ParenthesisValidator.js.map +1 -0
  28. package/lib/cjs/formula/Queue.d.ts +11 -0
  29. package/lib/cjs/formula/Queue.js +42 -0
  30. package/lib/cjs/formula/Queue.js.map +1 -0
  31. package/lib/cjs/formula/Stack.d.ts +14 -0
  32. package/lib/cjs/formula/Stack.js +71 -0
  33. package/lib/cjs/formula/Stack.js.map +1 -0
  34. package/lib/cjs/formula/StringBuilder.d.ts +9 -0
  35. package/lib/cjs/formula/StringBuilder.js +26 -0
  36. package/lib/cjs/formula/StringBuilder.js.map +1 -0
  37. package/lib/cjs/formula/Types.d.ts +8 -0
  38. package/lib/cjs/formula/Types.js +3 -0
  39. package/lib/cjs/formula/Types.js.map +1 -0
  40. package/lib/cjs/formula/Utils.d.ts +7 -0
  41. package/lib/cjs/formula/Utils.js +39 -0
  42. package/lib/cjs/formula/Utils.js.map +1 -0
  43. package/lib/cjs/widget/GroupingMappingWidget.d.ts +4 -0
  44. package/lib/cjs/widget/GroupingMappingWidget.js +6 -23
  45. package/lib/cjs/widget/GroupingMappingWidget.js.map +1 -1
  46. package/lib/cjs/widget/components/CalculatedPropertyAction.d.ts +3 -3
  47. package/lib/cjs/widget/components/CalculatedPropertyAction.js +15 -10
  48. package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
  49. package/lib/cjs/widget/components/CalculatedPropertyTable.d.ts +9 -6
  50. package/lib/cjs/widget/components/CalculatedPropertyTable.js +8 -33
  51. package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
  52. package/lib/cjs/widget/components/ConfirmMappingsImport.d.ts +3 -3
  53. package/lib/cjs/widget/components/ConfirmMappingsImport.js +6 -3
  54. package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
  55. package/lib/cjs/widget/components/ConfirmMappingsImport.scss +4 -2
  56. package/lib/cjs/widget/components/CustomCalculationAction.d.ts +6 -4
  57. package/lib/cjs/widget/components/CustomCalculationAction.js +23 -12
  58. package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
  59. package/lib/cjs/widget/components/CustomCalculationTable.d.ts +9 -6
  60. package/lib/cjs/widget/components/CustomCalculationTable.js +8 -33
  61. package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
  62. package/lib/cjs/widget/components/GroupAction.d.ts +2 -2
  63. package/lib/cjs/widget/components/GroupAction.js +25 -51
  64. package/lib/cjs/widget/components/GroupAction.js.map +1 -1
  65. package/lib/cjs/widget/components/GroupPropertyAction.d.ts +1 -1
  66. package/lib/cjs/widget/components/GroupPropertyAction.js +12 -8
  67. package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
  68. package/lib/cjs/widget/components/GroupPropertyTable.d.ts +9 -6
  69. package/lib/cjs/widget/components/GroupPropertyTable.js +8 -33
  70. package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
  71. package/lib/cjs/widget/components/Grouping.d.ts +3 -3
  72. package/lib/cjs/widget/components/Grouping.js +22 -22
  73. package/lib/cjs/widget/components/Grouping.js.map +1 -1
  74. package/lib/cjs/widget/components/GroupingMapping.d.ts +12 -2
  75. package/lib/cjs/widget/components/GroupingMapping.js +18 -4
  76. package/lib/cjs/widget/components/GroupingMapping.js.map +1 -1
  77. package/lib/cjs/widget/components/Mapping.d.ts +2 -2
  78. package/lib/cjs/widget/components/Mapping.js +14 -14
  79. package/lib/cjs/widget/components/Mapping.js.map +1 -1
  80. package/lib/cjs/widget/components/MappingAction.d.ts +2 -2
  81. package/lib/cjs/widget/components/MappingAction.js +8 -13
  82. package/lib/cjs/widget/components/MappingAction.js.map +1 -1
  83. package/lib/cjs/widget/components/MappingImportWizardModal.js +2 -2
  84. package/lib/cjs/widget/components/MappingImportWizardModal.js.map +1 -1
  85. package/lib/cjs/widget/components/MappingImportWizardModal.scss +6 -2
  86. package/lib/cjs/widget/components/PropertyMenu.d.ts +2 -2
  87. package/lib/cjs/widget/components/PropertyMenu.js +68 -21
  88. package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
  89. package/lib/cjs/widget/components/SelectIModel.js +4 -8
  90. package/lib/cjs/widget/components/SelectIModel.js.map +1 -1
  91. package/lib/cjs/widget/components/SelectIModel.scss +2 -1
  92. package/lib/cjs/widget/components/SelectMapping.scss +2 -1
  93. package/lib/cjs/widget/components/SelectMappings.d.ts +2 -2
  94. package/lib/cjs/widget/components/SelectMappings.js +10 -11
  95. package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
  96. package/lib/cjs/widget/components/SelectProject.js +12 -16
  97. package/lib/cjs/widget/components/SelectProject.js.map +1 -1
  98. package/lib/cjs/widget/components/SelectProject.scss +3 -8
  99. package/lib/cjs/widget/hooks/useFetchData.d.ts +9 -0
  100. package/lib/cjs/widget/hooks/useFetchData.js +41 -0
  101. package/lib/cjs/widget/hooks/useFetchData.js.map +1 -0
  102. package/lib/cjs/widget/hooks/useFormulaValidation.d.ts +6 -0
  103. package/lib/cjs/widget/hooks/useFormulaValidation.js +29 -0
  104. package/lib/cjs/widget/hooks/useFormulaValidation.js.map +1 -0
  105. package/lib/cjs/widget/utils.d.ts +1 -0
  106. package/lib/cjs/widget/utils.js +9 -0
  107. package/lib/cjs/widget/utils.js.map +1 -1
  108. package/lib/esm/formula/FormulaFunctionProvider.d.ts +18 -0
  109. package/lib/esm/formula/FormulaFunctionProvider.js +130 -0
  110. package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -0
  111. package/lib/esm/formula/FormulaOperatorsProvider.d.ts +34 -0
  112. package/lib/esm/formula/FormulaOperatorsProvider.js +174 -0
  113. package/lib/esm/formula/FormulaOperatorsProvider.js.map +1 -0
  114. package/lib/esm/formula/FormulaSplitter.d.ts +2 -0
  115. package/lib/esm/formula/FormulaSplitter.js +136 -0
  116. package/lib/esm/formula/FormulaSplitter.js.map +1 -0
  117. package/lib/esm/formula/FormulaTokensValidator.d.ts +5 -0
  118. package/lib/esm/formula/FormulaTokensValidator.js +131 -0
  119. package/lib/esm/formula/FormulaTokensValidator.js.map +1 -0
  120. package/lib/esm/formula/FormulaValidator.d.ts +3 -0
  121. package/lib/esm/formula/FormulaValidator.js +31 -0
  122. package/lib/esm/formula/FormulaValidator.js.map +1 -0
  123. package/lib/esm/formula/IResult.d.ts +5 -0
  124. package/lib/esm/formula/IResult.js +2 -0
  125. package/lib/esm/formula/IResult.js.map +1 -0
  126. package/lib/esm/formula/InfixToPostfixConverter.d.ts +18 -0
  127. package/lib/esm/formula/InfixToPostfixConverter.js +295 -0
  128. package/lib/esm/formula/InfixToPostfixConverter.js.map +1 -0
  129. package/lib/esm/formula/InputStream.d.ts +12 -0
  130. package/lib/esm/formula/InputStream.js +32 -0
  131. package/lib/esm/formula/InputStream.js.map +1 -0
  132. package/lib/esm/formula/ParenthesisValidator.d.ts +7 -0
  133. package/lib/esm/formula/ParenthesisValidator.js +30 -0
  134. package/lib/esm/formula/ParenthesisValidator.js.map +1 -0
  135. package/lib/esm/formula/Queue.d.ts +11 -0
  136. package/lib/esm/formula/Queue.js +38 -0
  137. package/lib/esm/formula/Queue.js.map +1 -0
  138. package/lib/esm/formula/Stack.d.ts +14 -0
  139. package/lib/esm/formula/Stack.js +67 -0
  140. package/lib/esm/formula/Stack.js.map +1 -0
  141. package/lib/esm/formula/StringBuilder.d.ts +9 -0
  142. package/lib/esm/formula/StringBuilder.js +22 -0
  143. package/lib/esm/formula/StringBuilder.js.map +1 -0
  144. package/lib/esm/formula/Types.d.ts +8 -0
  145. package/lib/esm/formula/Types.js +2 -0
  146. package/lib/esm/formula/Types.js.map +1 -0
  147. package/lib/esm/formula/Utils.d.ts +7 -0
  148. package/lib/esm/formula/Utils.js +30 -0
  149. package/lib/esm/formula/Utils.js.map +1 -0
  150. package/lib/esm/widget/GroupingMappingWidget.d.ts +4 -0
  151. package/lib/esm/widget/GroupingMappingWidget.js +6 -4
  152. package/lib/esm/widget/GroupingMappingWidget.js.map +1 -1
  153. package/lib/esm/widget/components/CalculatedPropertyAction.d.ts +3 -3
  154. package/lib/esm/widget/components/CalculatedPropertyAction.js +16 -11
  155. package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
  156. package/lib/esm/widget/components/CalculatedPropertyTable.d.ts +9 -6
  157. package/lib/esm/widget/components/CalculatedPropertyTable.js +9 -34
  158. package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
  159. package/lib/esm/widget/components/ConfirmMappingsImport.d.ts +3 -3
  160. package/lib/esm/widget/components/ConfirmMappingsImport.js +7 -4
  161. package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
  162. package/lib/esm/widget/components/ConfirmMappingsImport.scss +4 -2
  163. package/lib/esm/widget/components/CustomCalculationAction.d.ts +6 -4
  164. package/lib/esm/widget/components/CustomCalculationAction.js +24 -13
  165. package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
  166. package/lib/esm/widget/components/CustomCalculationTable.d.ts +9 -6
  167. package/lib/esm/widget/components/CustomCalculationTable.js +9 -34
  168. package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
  169. package/lib/esm/widget/components/GroupAction.d.ts +2 -2
  170. package/lib/esm/widget/components/GroupAction.js +26 -52
  171. package/lib/esm/widget/components/GroupAction.js.map +1 -1
  172. package/lib/esm/widget/components/GroupPropertyAction.d.ts +1 -1
  173. package/lib/esm/widget/components/GroupPropertyAction.js +13 -9
  174. package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
  175. package/lib/esm/widget/components/GroupPropertyTable.d.ts +9 -6
  176. package/lib/esm/widget/components/GroupPropertyTable.js +9 -34
  177. package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
  178. package/lib/esm/widget/components/Grouping.d.ts +3 -3
  179. package/lib/esm/widget/components/Grouping.js +23 -23
  180. package/lib/esm/widget/components/Grouping.js.map +1 -1
  181. package/lib/esm/widget/components/GroupingMapping.d.ts +12 -2
  182. package/lib/esm/widget/components/GroupingMapping.js +17 -4
  183. package/lib/esm/widget/components/GroupingMapping.js.map +1 -1
  184. package/lib/esm/widget/components/Mapping.d.ts +2 -2
  185. package/lib/esm/widget/components/Mapping.js +15 -15
  186. package/lib/esm/widget/components/Mapping.js.map +1 -1
  187. package/lib/esm/widget/components/MappingAction.d.ts +2 -2
  188. package/lib/esm/widget/components/MappingAction.js +9 -14
  189. package/lib/esm/widget/components/MappingAction.js.map +1 -1
  190. package/lib/esm/widget/components/MappingImportWizardModal.js +2 -2
  191. package/lib/esm/widget/components/MappingImportWizardModal.js.map +1 -1
  192. package/lib/esm/widget/components/MappingImportWizardModal.scss +6 -2
  193. package/lib/esm/widget/components/PropertyMenu.d.ts +2 -2
  194. package/lib/esm/widget/components/PropertyMenu.js +69 -22
  195. package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
  196. package/lib/esm/widget/components/SelectIModel.js +5 -6
  197. package/lib/esm/widget/components/SelectIModel.js.map +1 -1
  198. package/lib/esm/widget/components/SelectIModel.scss +2 -1
  199. package/lib/esm/widget/components/SelectMapping.scss +2 -1
  200. package/lib/esm/widget/components/SelectMappings.d.ts +2 -2
  201. package/lib/esm/widget/components/SelectMappings.js +11 -12
  202. package/lib/esm/widget/components/SelectMappings.js.map +1 -1
  203. package/lib/esm/widget/components/SelectProject.js +13 -14
  204. package/lib/esm/widget/components/SelectProject.js.map +1 -1
  205. package/lib/esm/widget/components/SelectProject.scss +3 -8
  206. package/lib/esm/widget/hooks/useFetchData.d.ts +9 -0
  207. package/lib/esm/widget/hooks/useFetchData.js +35 -0
  208. package/lib/esm/widget/hooks/useFetchData.js.map +1 -0
  209. package/lib/esm/widget/hooks/useFormulaValidation.d.ts +6 -0
  210. package/lib/esm/widget/hooks/useFormulaValidation.js +25 -0
  211. package/lib/esm/widget/hooks/useFormulaValidation.js.map +1 -0
  212. package/lib/esm/widget/utils.d.ts +1 -0
  213. package/lib/esm/widget/utils.js +7 -1
  214. package/lib/esm/widget/utils.js.map +1 -1
  215. package/package.json +3 -2
  216. package/lib/cjs/api/generated/api.d.ts +0 -3222
  217. package/lib/cjs/api/generated/api.js +0 -5291
  218. package/lib/cjs/api/generated/api.js.map +0 -1
  219. package/lib/cjs/api/generated/configuration.d.ts +0 -56
  220. package/lib/cjs/api/generated/configuration.js +0 -30
  221. package/lib/cjs/api/generated/configuration.js.map +0 -1
  222. package/lib/cjs/api/generated/index.d.ts +0 -14
  223. package/lib/cjs/api/generated/index.js +0 -31
  224. package/lib/cjs/api/generated/index.js.map +0 -1
  225. package/lib/cjs/api/reportingClient.d.ts +0 -34
  226. package/lib/cjs/api/reportingClient.js +0 -177
  227. package/lib/cjs/api/reportingClient.js.map +0 -1
  228. package/lib/cjs/widget/hooks/useFetchAccessToken.d.ts +0 -3
  229. package/lib/cjs/widget/hooks/useFetchAccessToken.js +0 -22
  230. package/lib/cjs/widget/hooks/useFetchAccessToken.js.map +0 -1
  231. package/lib/esm/api/generated/api.d.ts +0 -3222
  232. package/lib/esm/api/generated/api.js +0 -5248
  233. package/lib/esm/api/generated/api.js.map +0 -1
  234. package/lib/esm/api/generated/configuration.d.ts +0 -56
  235. package/lib/esm/api/generated/configuration.js +0 -26
  236. package/lib/esm/api/generated/configuration.js.map +0 -1
  237. package/lib/esm/api/generated/index.d.ts +0 -14
  238. package/lib/esm/api/generated/index.js +0 -19
  239. package/lib/esm/api/generated/index.js.map +0 -1
  240. package/lib/esm/api/reportingClient.d.ts +0 -34
  241. package/lib/esm/api/reportingClient.js +0 -173
  242. package/lib/esm/api/reportingClient.js.map +0 -1
  243. package/lib/esm/widget/hooks/useFetchAccessToken.d.ts +0 -3
  244. package/lib/esm/widget/hooks/useFetchAccessToken.js +0 -20
  245. package/lib/esm/widget/hooks/useFetchAccessToken.js.map +0 -1
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputStream = 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
+ class InputStream {
9
+ constructor(_stream) {
10
+ this._stream = _stream;
11
+ this._nextIndex = 0;
12
+ this._current = "";
13
+ }
14
+ get next() {
15
+ this._current = this.isEOF ? "" : this._stream[this._nextIndex++];
16
+ return this.current;
17
+ }
18
+ get undo() {
19
+ if (this._nextIndex === 0)
20
+ return this.current;
21
+ this._nextIndex--;
22
+ this._current = this._nextIndex === 0 ? "" : this._stream[this._nextIndex - 1];
23
+ return this.current;
24
+ }
25
+ get current() {
26
+ return this._current;
27
+ }
28
+ get peek() {
29
+ return this.isEOF ? "" : this._stream[this._nextIndex];
30
+ }
31
+ get isEOF() {
32
+ return this._nextIndex >= this._stream.length;
33
+ }
34
+ }
35
+ exports.InputStream = InputStream;
36
+ //# sourceMappingURL=InputStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputStream.js","sourceRoot":"","sources":["../../../src/formula/InputStream.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,MAAa,WAAW;IAItB,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAHpC,eAAU,GAAG,CAAC,CAAC;QACf,aAAQ,GAAG,EAAE,CAAC;IAE0B,CAAC;IAEjD,IAAW,IAAI;QACb,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAW,IAAI;QACb,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC;YACvB,OAAO,IAAI,CAAC,OAAO,CAAC;QAEtB,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzD,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAChD,CAAC;CACF;AA/BD,kCA+BC","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*--------------------------------------------------------------------------------------------*/\nexport class InputStream {\n private _nextIndex = 0;\n private _current = \"\";\n\n constructor(private readonly _stream: string) { }\n\n public get next(): string {\n this._current = this.isEOF ? \"\" : this._stream[this._nextIndex++];\n return this.current;\n }\n\n public get undo(): string {\n if (this._nextIndex === 0)\n return this.current;\n\n this._nextIndex--;\n this._current = this._nextIndex === 0 ? \"\" : this._stream[this._nextIndex - 1];\n return this.current;\n }\n\n public get current(): string {\n return this._current;\n }\n\n public get peek(): string {\n return this.isEOF ? \"\" : this._stream[this._nextIndex];\n }\n\n public get isEOF(): boolean {\n return this._nextIndex >= this._stream.length;\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export declare enum ParenthesisState {
2
+ Valid = 0,
3
+ NotClosed = 1,
4
+ NotOpened = 2
5
+ }
6
+ export declare function validateParenthesis(infixFormula: string): ParenthesisState;
7
+ //# sourceMappingURL=ParenthesisValidator.d.ts.map
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateParenthesis = exports.ParenthesisState = 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 Stack_1 = require("./Stack");
9
+ var ParenthesisState;
10
+ (function (ParenthesisState) {
11
+ ParenthesisState[ParenthesisState["Valid"] = 0] = "Valid";
12
+ ParenthesisState[ParenthesisState["NotClosed"] = 1] = "NotClosed";
13
+ ParenthesisState[ParenthesisState["NotOpened"] = 2] = "NotOpened";
14
+ })(ParenthesisState = exports.ParenthesisState || (exports.ParenthesisState = {}));
15
+ function validateParenthesis(infixFormula) {
16
+ const s = new Stack_1.Stack();
17
+ for (const c of infixFormula) {
18
+ if (c === "(") {
19
+ s.push("(");
20
+ }
21
+ else if (c === ")") {
22
+ if (s.peek() === undefined) {
23
+ return ParenthesisState.NotOpened;
24
+ }
25
+ s.pop();
26
+ }
27
+ }
28
+ if (s.length !== 0) {
29
+ return ParenthesisState.NotClosed;
30
+ }
31
+ return ParenthesisState.Valid;
32
+ }
33
+ exports.validateParenthesis = validateParenthesis;
34
+ //# sourceMappingURL=ParenthesisValidator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParenthesisValidator.js","sourceRoot":"","sources":["../../../src/formula/ParenthesisValidator.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAAgC;AAEhC,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,yDAAS,CAAA;IACT,iEAAa,CAAA;IACb,iEAAa,CAAA;AACf,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B;AAED,SAAgB,mBAAmB,CAAC,YAAoB;IACtD,MAAM,CAAC,GAAG,IAAI,aAAK,EAAU,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;QAC5B,IAAI,CAAC,KAAK,GAAG,EAAE;YACb,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACb;aAAM,IAAI,CAAC,KAAK,GAAG,EAAE;YACpB,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,SAAS,EAAE;gBAC1B,OAAO,gBAAgB,CAAC,SAAS,CAAC;aACnC;YACD,CAAC,CAAC,GAAG,EAAE,CAAC;SACT;KACF;IACD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QAClB,OAAO,gBAAgB,CAAC,SAAS,CAAC;KACnC;IACD,OAAO,gBAAgB,CAAC,KAAK,CAAC;AAChC,CAAC;AAhBD,kDAgBC","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 { Stack } from \"./Stack\";\n\nexport enum ParenthesisState {\n Valid = 0,\n NotClosed = 1,\n NotOpened = 2,\n}\n\nexport function validateParenthesis(infixFormula: string): ParenthesisState {\n const s = new Stack<string>();\n for (const c of infixFormula) {\n if (c === \"(\") {\n s.push(\"(\");\n } else if (c === \")\") {\n if (s.peek() === undefined) {\n return ParenthesisState.NotOpened;\n }\n s.pop();\n }\n }\n if (s.length !== 0) {\n return ParenthesisState.NotClosed;\n }\n return ParenthesisState.Valid;\n}\n"]}
@@ -0,0 +1,11 @@
1
+ export declare class Queue<TData> {
2
+ private _dataStore;
3
+ constructor(_dataStore?: TData[]);
4
+ enqueue(element: TData): Queue<TData>;
5
+ dequeue(): TData | undefined;
6
+ dequeueN(n: number): TData[];
7
+ peek(): TData | undefined;
8
+ get length(): number;
9
+ get asArray(): TData[];
10
+ }
11
+ //# sourceMappingURL=Queue.d.ts.map
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Queue = 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
+ class Queue {
9
+ constructor(_dataStore = []) {
10
+ this._dataStore = _dataStore;
11
+ }
12
+ enqueue(element) {
13
+ this._dataStore.push(element);
14
+ return this;
15
+ }
16
+ dequeue() {
17
+ if (this._dataStore.length === 0) {
18
+ return undefined;
19
+ }
20
+ return this._dataStore.splice(0, 1)[0];
21
+ }
22
+ dequeueN(n) {
23
+ if (n <= 0 || this._dataStore.length === 0) {
24
+ return [];
25
+ }
26
+ return this._dataStore.splice(0, n);
27
+ }
28
+ peek() {
29
+ if (this._dataStore.length === 0) {
30
+ return undefined;
31
+ }
32
+ return this._dataStore[0];
33
+ }
34
+ get length() {
35
+ return this._dataStore.length;
36
+ }
37
+ get asArray() {
38
+ return [...this._dataStore];
39
+ }
40
+ }
41
+ exports.Queue = Queue;
42
+ //# sourceMappingURL=Queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Queue.js","sourceRoot":"","sources":["../../../src/formula/Queue.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,MAAa,KAAK;IAChB,YAAoB,aAAsB,EAAE;QAAxB,eAAU,GAAV,UAAU,CAAc;IAAI,CAAC;IAE1C,OAAO,CAAC,OAAc;QAC3B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,OAAO;QACZ,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IAEM,QAAQ,CAAC,CAAS;QACvB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1C,OAAO,EAAE,CAAC;SACX;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,CAAC;IAEM,IAAI;QACT,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAChC,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;CACF;AAtCD,sBAsCC","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*--------------------------------------------------------------------------------------------*/\nexport class Queue<TData> {\n constructor(private _dataStore: TData[] = []) { }\n\n public enqueue(element: TData): Queue<TData> {\n this._dataStore.push(element);\n return this;\n }\n\n public dequeue(): TData | undefined {\n if (this._dataStore.length === 0) {\n return undefined;\n }\n\n return this._dataStore.splice(0, 1)[0];\n }\n\n public dequeueN(n: number): TData[] {\n if (n <= 0 || this._dataStore.length === 0) {\n return [];\n }\n\n return this._dataStore.splice(0, n);\n }\n\n public peek(): TData | undefined {\n if (this._dataStore.length === 0) {\n return undefined;\n }\n return this._dataStore[0];\n }\n\n public get length(): number {\n return this._dataStore.length;\n }\n\n public get asArray(): TData[] {\n return [...this._dataStore];\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ export declare class Stack<TData> {
2
+ private _dataStore;
3
+ constructor();
4
+ push(element: TData): Stack<TData>;
5
+ pop(): TData | undefined;
6
+ popN(n: number): TData[];
7
+ peek(): TData | undefined;
8
+ peekN(n: number): TData[];
9
+ indexOf(element: TData): number;
10
+ findIndex(filter: (element: TData) => boolean): number;
11
+ get length(): number;
12
+ get asArray(): TData[];
13
+ }
14
+ //# sourceMappingURL=Stack.d.ts.map
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stack = 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
+ class Stack {
9
+ constructor() {
10
+ this._dataStore = [];
11
+ }
12
+ push(element) {
13
+ this._dataStore.push(element);
14
+ return this;
15
+ }
16
+ pop() {
17
+ if (this._dataStore.length === 0) {
18
+ return undefined;
19
+ }
20
+ return this._dataStore.pop();
21
+ }
22
+ popN(n) {
23
+ if (n <= 0 || this._dataStore.length === 0) {
24
+ return [];
25
+ }
26
+ if (this._dataStore.length >= n) {
27
+ return [...this._dataStore.splice(this._dataStore.length - n)].reverse();
28
+ }
29
+ else {
30
+ const result = [...this._dataStore];
31
+ this._dataStore = [];
32
+ return result.reverse();
33
+ }
34
+ }
35
+ peek() {
36
+ if (this._dataStore.length === 0) {
37
+ return undefined;
38
+ }
39
+ return this._dataStore[this._dataStore.length - 1];
40
+ }
41
+ peekN(n) {
42
+ if (n <= 0 || this._dataStore.length === 0) {
43
+ return [];
44
+ }
45
+ if (this._dataStore.length >= n) {
46
+ return this._dataStore.slice(-n).reverse();
47
+ }
48
+ else {
49
+ return [...this._dataStore].reverse();
50
+ }
51
+ }
52
+ indexOf(element) {
53
+ return this.findIndex((e) => e === element);
54
+ }
55
+ findIndex(filter) {
56
+ for (let i = 0; i < this._dataStore.length; i++) {
57
+ if (filter(this._dataStore[this._dataStore.length - 1 - i])) {
58
+ return i;
59
+ }
60
+ }
61
+ return -1;
62
+ }
63
+ get length() {
64
+ return this._dataStore.length;
65
+ }
66
+ get asArray() {
67
+ return [...this._dataStore].reverse();
68
+ }
69
+ }
70
+ exports.Stack = Stack;
71
+ //# sourceMappingURL=Stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stack.js","sourceRoot":"","sources":["../../../src/formula/Stack.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,MAAa,KAAK;IAEhB;QADQ,eAAU,GAAY,EAAE,CAAC;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I,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SAC5C;aAAM;YACL,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;SACvC;IACH,CAAC;IAEM,OAAO,CAAC,OAAc;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;IAC9C,CAAC;IAEM,SAAS,CAAC,MAAmC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC/C,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;gBAC3D,OAAO,CAAC,CAAC;aACV;SACF;QACD,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAChC,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;CACF;AArED,sBAqEC","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*--------------------------------------------------------------------------------------------*/\nexport class Stack<TData> {\n private _dataStore: TData[] = [];\n constructor() { }\n\n public push(element: TData): Stack<TData> {\n this._dataStore.push(element);\n return this;\n }\n\n public pop(): TData | undefined {\n if (this._dataStore.length === 0) {\n return undefined;\n }\n return this._dataStore.pop();\n }\n\n public popN(n: number): TData[] {\n if (n <= 0 || this._dataStore.length === 0) {\n return [];\n }\n\n if (this._dataStore.length >= n) {\n return [...this._dataStore.splice(this._dataStore.length - n)].reverse();\n } else {\n const result = [...this._dataStore];\n this._dataStore = [];\n return result.reverse();\n }\n }\n\n public peek(): TData | undefined {\n if (this._dataStore.length === 0) {\n return undefined;\n }\n return this._dataStore[this._dataStore.length - 1];\n }\n\n public peekN(n: number): TData[] {\n if (n <= 0 || this._dataStore.length === 0) {\n return [];\n }\n\n if (this._dataStore.length >= n) {\n return this._dataStore.slice(-n).reverse();\n } else {\n return [...this._dataStore].reverse();\n }\n }\n\n public indexOf(element: TData): number {\n return this.findIndex((e) => e === element);\n }\n\n public findIndex(filter: (element: TData) => boolean): number {\n for (let i = 0; i < this._dataStore.length; i++) {\n if (filter(this._dataStore[this._dataStore.length - 1 - i])) {\n return i;\n }\n }\n return -1;\n }\n\n public get length(): number {\n return this._dataStore.length;\n }\n\n public get asArray(): TData[] {\n return [...this._dataStore].reverse();\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ export declare class StringBuilder {
2
+ private readonly _stringParts;
3
+ constructor(...initial: string[]);
4
+ push(value: string): void;
5
+ pop(): string | undefined;
6
+ get length(): number;
7
+ get value(): string;
8
+ }
9
+ //# sourceMappingURL=StringBuilder.d.ts.map
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StringBuilder = 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
+ class StringBuilder {
9
+ constructor(...initial) {
10
+ this._stringParts = initial.filter((v) => !!v);
11
+ }
12
+ push(value) {
13
+ value && this._stringParts.push(value);
14
+ }
15
+ pop() {
16
+ return this._stringParts.pop();
17
+ }
18
+ get length() {
19
+ return this._stringParts.length;
20
+ }
21
+ get value() {
22
+ return this._stringParts.join("");
23
+ }
24
+ }
25
+ exports.StringBuilder = StringBuilder;
26
+ //# sourceMappingURL=StringBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StringBuilder.js","sourceRoot":"","sources":["../../../src/formula/StringBuilder.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,MAAa,aAAa;IAGxB,YAAY,GAAG,OAAiB;QAC9B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAEM,IAAI,CAAC,KAAa;QACvB,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAEM,GAAG;QACR,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;IAClC,CAAC;IAED,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;CACF;AAtBD,sCAsBC","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*--------------------------------------------------------------------------------------------*/\nexport class StringBuilder {\n private readonly _stringParts: string[];\n\n constructor(...initial: string[]) {\n this._stringParts = initial.filter((v) => !!v);\n }\n\n public push(value: string) {\n value && this._stringParts.push(value);\n }\n\n public pop() {\n return this._stringParts.pop();\n }\n\n public get length() {\n return this._stringParts.length;\n }\n\n public get value() {\n return this._stringParts.join(\"\");\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export declare type ValueType = number | string | boolean;
2
+ export declare type PossibleValueType = ValueType | undefined;
3
+ export declare type DataType = "number" | "string" | "boolean";
4
+ export declare type PossibleDataType = DataType | "undefined";
5
+ export interface PropertyMap {
6
+ [key: string]: PossibleDataType;
7
+ }
8
+ //# sourceMappingURL=Types.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Types.js","sourceRoot":"","sources":["../../../src/formula/Types.ts"],"names":[],"mappings":"","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*--------------------------------------------------------------------------------------------*/\nexport type ValueType = number | string | boolean;\n\nexport type PossibleValueType = ValueType | undefined;\n\nexport type DataType = \"number\" | \"string\" | \"boolean\";\n\nexport type PossibleDataType = DataType | \"undefined\";\n\nexport interface PropertyMap { [key: string]: PossibleDataType }\n"]}
@@ -0,0 +1,7 @@
1
+ export declare function isDigit(char: string): boolean;
2
+ export declare function isLetterOrUnderscore(char: string): boolean;
3
+ export declare function isStringDelimiter(char: string): boolean;
4
+ export declare function isWhitespace(char: string): boolean;
5
+ export declare function isDecimalSeparator(char: string): boolean;
6
+ export declare function formatNumericalPositionString(num: number): string;
7
+ //# sourceMappingURL=Utils.d.ts.map
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatNumericalPositionString = exports.isDecimalSeparator = exports.isWhitespace = exports.isStringDelimiter = exports.isLetterOrUnderscore = exports.isDigit = 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
+ function isDigit(char) {
9
+ return /^\d/.test(char);
10
+ }
11
+ exports.isDigit = isDigit;
12
+ function isLetterOrUnderscore(char) {
13
+ return /^[\p{L}_]/u.test(char);
14
+ }
15
+ exports.isLetterOrUnderscore = isLetterOrUnderscore;
16
+ function isStringDelimiter(char) {
17
+ return ["\"", "'", "`"].includes(char);
18
+ }
19
+ exports.isStringDelimiter = isStringDelimiter;
20
+ function isWhitespace(char) {
21
+ return /^\s/.test(char);
22
+ }
23
+ exports.isWhitespace = isWhitespace;
24
+ function isDecimalSeparator(char) {
25
+ return char === ".";
26
+ }
27
+ exports.isDecimalSeparator = isDecimalSeparator;
28
+ function formatNumericalPositionString(num) {
29
+ const str = num.toString();
30
+ if (str.endsWith("1") && num !== 11)
31
+ return `${str}st`;
32
+ if (str.endsWith("2") && num !== 12)
33
+ return `${str}nd`;
34
+ if (str.endsWith("3") && num !== 13)
35
+ return `${str}rd`;
36
+ return `${str}th`;
37
+ }
38
+ exports.formatNumericalPositionString = formatNumericalPositionString;
39
+ //# sourceMappingURL=Utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/formula/Utils.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,SAAgB,OAAO,CAAC,IAAY;IAClC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAFD,0BAEC;AAED,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAFD,oDAEC;AAED,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAFD,8CAEC;AAED,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAFD,oCAEC;AAED,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,OAAO,IAAI,KAAK,GAAG,CAAC;AACtB,CAAC;AAFD,gDAEC;AAED,SAAgB,6BAA6B,CAAC,GAAW;IACvD,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC3B,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE;QACjC,OAAO,GAAG,GAAG,IAAI,CAAC;IACpB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE;QACjC,OAAO,GAAG,GAAG,IAAI,CAAC;IACpB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,EAAE;QACjC,OAAO,GAAG,GAAG,IAAI,CAAC;IAEpB,OAAO,GAAG,GAAG,IAAI,CAAC;AACpB,CAAC;AAVD,sEAUC","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*--------------------------------------------------------------------------------------------*/\nexport function isDigit(char: string): boolean {\n return /^\\d/.test(char);\n}\n\nexport function isLetterOrUnderscore(char: string): boolean {\n return /^[\\p{L}_]/u.test(char);\n}\n\nexport function isStringDelimiter(char: string): boolean {\n return [\"\\\"\", \"'\", \"`\"].includes(char);\n}\n\nexport function isWhitespace(char: string): boolean {\n return /^\\s/.test(char);\n}\n\nexport function isDecimalSeparator(char: string): boolean {\n return char === \".\";\n}\n\nexport function formatNumericalPositionString(num: number): string {\n const str = num.toString();\n if (str.endsWith(\"1\") && num !== 11)\n return `${str}st`;\n if (str.endsWith(\"2\") && num !== 12)\n return `${str}nd`;\n if (str.endsWith(\"3\") && num !== 13)\n return `${str}rd`;\n\n return `${str}th`;\n}\n"]}
@@ -1,7 +1,11 @@
1
1
  import type { AbstractWidgetProps, UiItemsProvider } from "@itwin/appui-abstract";
2
2
  import { AbstractZoneLocation, StagePanelLocation, StagePanelSection } from "@itwin/appui-abstract";
3
+ import type { AccessToken } from "@itwin/core-bentley";
3
4
  export declare class GroupingMappingProvider implements UiItemsProvider {
4
5
  readonly id = "GroupingMappingProvider";
6
+ private readonly _accessToken?;
7
+ private readonly _prefix?;
8
+ constructor(accessToken?: AccessToken, prefix?: "" | "dev" | "qa");
5
9
  provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zonelocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps>;
6
10
  }
7
11
  //# sourceMappingURL=GroupingMappingWidget.d.ts.map
@@ -1,34 +1,17 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
22
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
4
  };
24
5
  Object.defineProperty(exports, "__esModule", { value: true });
25
6
  exports.GroupingMappingProvider = void 0;
26
7
  const appui_abstract_1 = require("@itwin/appui-abstract");
27
- const React = __importStar(require("react"));
8
+ const react_1 = __importDefault(require("react"));
28
9
  const GroupingMapping_1 = __importDefault(require("./components/GroupingMapping"));
29
10
  class GroupingMappingProvider {
30
- constructor() {
11
+ constructor(accessToken, prefix) {
31
12
  this.id = "GroupingMappingProvider";
13
+ this._accessToken = accessToken;
14
+ this._prefix = prefix;
32
15
  }
33
16
  provideWidgets(_stageId, stageUsage, location, section, zonelocation) {
34
17
  const widgets = [];
@@ -39,8 +22,8 @@ class GroupingMappingProvider {
39
22
  const GroupingMappingWidget = {
40
23
  id: "GroupingMappingWidget",
41
24
  label: "Grouping & Mapping",
42
- getWidgetContent() {
43
- return React.createElement(GroupingMapping_1.default, null);
25
+ getWidgetContent: () => {
26
+ return react_1.default.createElement(GroupingMapping_1.default, { accessToken: this._accessToken, prefix: this._prefix });
44
27
  },
45
28
  };
46
29
  widgets.push(GroupingMappingWidget);
@@ -1 +1 @@
1
- {"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOA,0DAK+B;AAE/B,6CAA+B;AAC/B,mFAA2D;AAE3D,MAAa,uBAAuB;IAApC;QACkB,OAAE,GAAG,yBAAyB,CAAC;IA6BjD,CAAC;IA3BQ,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B,EAC3B,YAAmC;QAEnC,MAAM,OAAO,GAA0B,EAAE,CAAC;QAC1C,IACE,CAAC,QAAQ,KAAK,mCAAkB,CAAC,IAAI;YACrC,OAAO,KAAK,kCAAiB,CAAC,KAAK;YACnC,UAAU,KAAK,2BAAU,CAAC,OAAO,CAAC;YAClC,YAAY,KAAK,qCAAoB,CAAC,UAAU,EAChD;YACA,MAAM,qBAAqB,GAAwB;gBACjD,EAAE,EAAE,uBAAuB;gBAC3B,KAAK,EAAE,oBAAoB;gBAC3B,gBAAgB;oBACd,OAAO,oBAAC,yBAAe,OAAG,CAAC;gBAC7B,CAAC;aACF,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACrC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA9BD,0DA8BC","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 AbstractWidgetProps,\n UiItemsProvider} from \"@itwin/appui-abstract\";\nimport {\n AbstractZoneLocation,\n StagePanelLocation,\n StagePanelSection,\n StageUsage,\n} from \"@itwin/appui-abstract\";\n\nimport * as React from \"react\";\nimport GroupingMapping from \"./components/GroupingMapping\";\n\nexport class GroupingMappingProvider implements UiItemsProvider {\n public readonly id = \"GroupingMappingProvider\";\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection,\n zonelocation?: AbstractZoneLocation\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n if (\n (location === StagePanelLocation.Left &&\n section === StagePanelSection.Start &&\n stageUsage === StageUsage.General) ||\n zonelocation === AbstractZoneLocation.CenterLeft\n ) {\n const GroupingMappingWidget: AbstractWidgetProps = {\n id: \"GroupingMappingWidget\",\n label: \"Grouping & Mapping\",\n getWidgetContent() {\n return <GroupingMapping />;\n },\n };\n\n widgets.push(GroupingMappingWidget);\n }\n\n return widgets;\n }\n}\n"]}
1
+ {"version":3,"file":"GroupingMappingWidget.js","sourceRoot":"","sources":["../../../src/widget/GroupingMappingWidget.tsx"],"names":[],"mappings":";;;;;;AAQA,0DAK+B;AAE/B,kDAA0B;AAC1B,mFAA2D;AAE3D,MAAa,uBAAuB;IAMlC,YAAY,WAAyB,EAAE,MAA0B;QALjD,OAAE,GAAG,yBAAyB,CAAC;QAM7C,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAEM,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B,EAC3B,YAAmC;QAEnC,MAAM,OAAO,GAA0B,EAAE,CAAC;QAC1C,IACE,CAAC,QAAQ,KAAK,mCAAkB,CAAC,IAAI;YACnC,OAAO,KAAK,kCAAiB,CAAC,KAAK;YACnC,UAAU,KAAK,2BAAU,CAAC,OAAO,CAAC;YACpC,YAAY,KAAK,qCAAoB,CAAC,UAAU,EAChD;YACA,MAAM,qBAAqB,GAAwB;gBACjD,EAAE,EAAE,uBAAuB;gBAC3B,KAAK,EAAE,oBAAoB;gBAC3B,gBAAgB,EAAE,GAAG,EAAE;oBACrB,OAAO,8BAAC,yBAAe,IAAC,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,GAAI,CAAC;gBACnF,CAAC;aACF,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACrC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAtCD,0DAsCC","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 AbstractWidgetProps,\n UiItemsProvider,\n} from \"@itwin/appui-abstract\";\nimport {\n AbstractZoneLocation,\n StagePanelLocation,\n StagePanelSection,\n StageUsage,\n} from \"@itwin/appui-abstract\";\nimport type { AccessToken } from \"@itwin/core-bentley\";\nimport React from \"react\";\nimport GroupingMapping from \"./components/GroupingMapping\";\n\nexport class GroupingMappingProvider implements UiItemsProvider {\n public readonly id = \"GroupingMappingProvider\";\n\n private readonly _accessToken?: AccessToken;\n private readonly _prefix?: \"\" | \"dev\" | \"qa\";\n\n constructor(accessToken?: AccessToken, prefix?: \"\" | \"dev\" | \"qa\") {\n this._accessToken = accessToken;\n this._prefix = prefix;\n }\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection,\n zonelocation?: AbstractZoneLocation\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n if (\n (location === StagePanelLocation.Left &&\n section === StagePanelSection.Start &&\n stageUsage === StageUsage.General) ||\n zonelocation === AbstractZoneLocation.CenterLeft\n ) {\n const GroupingMappingWidget: AbstractWidgetProps = {\n id: \"GroupingMappingWidget\",\n label: \"Grouping & Mapping\",\n getWidgetContent: () => {\n return <GroupingMapping accessToken={this._accessToken} prefix={this._prefix} />;\n },\n };\n\n widgets.push(GroupingMappingWidget);\n }\n\n return widgets;\n }\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import "./CalculatedPropertyAction.scss";
3
- import type { CalculatedProperty } from "./CalculatedPropertyTable";
3
+ import type { CalculatedPropertyType } from "./CalculatedPropertyTable";
4
4
  interface CalculatedPropertyActionProps {
5
5
  iModelId: string;
6
6
  mappingId: string;
7
7
  groupId: string;
8
- property?: CalculatedProperty;
8
+ property?: CalculatedPropertyType;
9
9
  ids: string[];
10
- returnFn: () => Promise<void>;
10
+ returnFn: (modified: boolean) => Promise<void>;
11
11
  }
12
12
  declare const CalculatedPropertyAction: ({ iModelId, mappingId, groupId, property, ids, returnFn, }: CalculatedPropertyActionProps) => JSX.Element;
13
13
  export default CalculatedPropertyAction;
@@ -29,15 +29,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const core_frontend_1 = require("@itwin/core-frontend");
30
30
  const itwinui_react_1 = require("@itwin/itwinui-react");
31
31
  const react_1 = __importStar(require("react"));
32
- const reportingClient_1 = require("../../api/reportingClient");
33
32
  const ActionPanel_1 = __importDefault(require("./ActionPanel"));
34
33
  const BboxDimensionsDecorator_1 = require("../../decorators/BboxDimensionsDecorator");
35
34
  const useValidator_1 = __importStar(require("../hooks/useValidator"));
36
35
  const utils_1 = require("./utils");
37
36
  const viewerUtils_1 = require("./viewerUtils");
38
37
  require("./CalculatedPropertyAction.scss");
38
+ const insights_client_1 = require("@itwin/insights-client");
39
+ const GroupingMapping_1 = require("./GroupingMapping");
39
40
  const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids, returnFn, }) => {
40
41
  var _a, _b, _c;
42
+ const apiContext = react_1.useContext(GroupingMapping_1.ApiContext);
41
43
  const [propertyName, setPropertyName] = react_1.useState((_a = property === null || property === void 0 ? void 0 : property.propertyName) !== null && _a !== void 0 ? _a : "");
42
44
  const [type, setType] = react_1.useState((_b = property === null || property === void 0 ? void 0 : property.type) !== null && _b !== void 0 ? _b : "");
43
45
  const [bboxDecorator, setBboxDecorator] = react_1.useState();
@@ -86,14 +88,17 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
86
88
  }
87
89
  try {
88
90
  setIsLoading(true);
89
- const calculatedProperty = {
90
- propertyName,
91
- type,
92
- };
91
+ const reportingClientApi = new insights_client_1.ReportingClient(apiContext.prefix);
93
92
  property
94
- ? await reportingClient_1.reportingClientApi.updateCalculatedProperty(iModelId, mappingId, groupId, (_a = property.id) !== null && _a !== void 0 ? _a : "", calculatedProperty)
95
- : await reportingClient_1.reportingClientApi.createCalculatedProperty(iModelId, mappingId, groupId, calculatedProperty);
96
- await returnFn();
93
+ ? await reportingClientApi.updateCalculatedProperty(apiContext.accessToken, iModelId, mappingId, groupId, (_a = property.id) !== null && _a !== void 0 ? _a : "", {
94
+ propertyName,
95
+ type,
96
+ })
97
+ : await reportingClientApi.createCalculatedProperty(apiContext.accessToken, iModelId, mappingId, groupId, {
98
+ propertyName,
99
+ type,
100
+ });
101
+ await returnFn(true);
97
102
  }
98
103
  catch (error) {
99
104
  utils_1.handleError(error.status);
@@ -107,7 +112,7 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
107
112
  return (react_1.default.createElement(react_1.default.Fragment, null,
108
113
  react_1.default.createElement(utils_1.WidgetHeader, { title: property
109
114
  ? `${(_c = property === null || property === void 0 ? void 0 : property.propertyName) !== null && _c !== void 0 ? _c : ""}`
110
- : "Create Calculated Property", returnFn: returnFn }),
115
+ : "Create Calculated Property", returnFn: async () => returnFn(false) }),
111
116
  react_1.default.createElement("div", { className: 'calculated-properties-action-container' },
112
117
  react_1.default.createElement(itwinui_react_1.Fieldset, { legend: 'Calculated Property Details', className: 'details-form' },
113
118
  react_1.default.createElement(itwinui_react_1.Small, { className: 'field-legend' }, "Asterisk * indicates mandatory fields."),
@@ -160,7 +165,7 @@ const CalculatedPropertyAction = ({ iModelId, mappingId, groupId, property, ids,
160
165
  getSpatialData(option.value)))), selectedItemRenderer: (option) => (react_1.default.createElement("div", { className: 'select-item' },
161
166
  react_1.default.createElement("div", null, option.label),
162
167
  getSpatialData(option.value))), onShow: () => { }, onHide: () => { } }))),
163
- react_1.default.createElement(ActionPanel_1.default, { onSave: onSave, onCancel: returnFn, isSavingDisabled: !(type && propertyName), isLoading: isLoading })));
168
+ react_1.default.createElement(ActionPanel_1.default, { onSave: onSave, onCancel: async () => returnFn(false), isSavingDisabled: !(type && propertyName), isLoading: isLoading })));
164
169
  };
165
170
  exports.default = CalculatedPropertyAction;
166
171
  //# sourceMappingURL=CalculatedPropertyAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAiD;AAIjD,wDAM8B;AAC9B,+CAAmD;AAEnD,+DAA+D;AAC/D,gEAAwC;AACxC,sFAGkD;AAClD,sEAAwE;AACxE,mCAAoD;AACpD,+CAAkE;AAClE,2CAAyC;AAYzC,MAAM,wBAAwB,GAAG,CAAC,EAChC,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,EACH,QAAQ,GACsB,EAAE,EAAE;;IAClC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,gBAAQ,CAC9C,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,mCAAI,EAAE,CAC7B,CAAC;IACF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,gBAAQ,CAAS,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,mCAAI,EAAE,CAAC,CAAC;IAC/D,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,gBAAQ,EAE/C,CAA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AC,CACzB,CACP,EACD,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,wBAAwB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport type { CalculatedPropertyCreateReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedProperty } from \"./CalculatedPropertyTable\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n property?: CalculatedProperty;\n ids: string[];\n returnFn: () => Promise<void>;\n}\n\nconst CalculatedPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n property,\n ids,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const [propertyName, setPropertyName] = useState<string>(\n property?.propertyName ?? \"\",\n );\n const [type, setType] = useState<string>(property?.type ?? \"\");\n const [bboxDecorator, setBboxDecorator] = useState<\n BboxDimensionsDecorator | undefined\n >();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<\n Map<BboxDimension, number> | undefined\n >();\n const [validator, showValidationMessage] = useValidator();\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n visualizeElements([ids[0]], \"red\");\n void zoomToElements([ids[0]]);\n }, [ids]);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(ids[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, ids]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension])\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const calculatedProperty: CalculatedPropertyCreateReportingAPI = {\n propertyName,\n type,\n };\n\n property\n ? await reportingClientApi.updateCalculatedProperty(\n iModelId,\n mappingId,\n groupId,\n property.id ?? \"\",\n calculatedProperty,\n )\n : await reportingClientApi.createCalculatedProperty(\n iModelId,\n mappingId,\n groupId,\n calculatedProperty,\n );\n await returnFn();\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <WidgetHeader\n title={\n property\n ? `${property?.propertyName ?? \"\"}`\n : \"Create Calculated Property\"\n }\n returnFn={returnFn}\n />\n <div className='calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledSelect<string>\n label='Quantity Type'\n required\n options={[\n { value: \"Length\", label: \"Length\" },\n { value: \"Area\", label: \"Area\" },\n { value: \"Volume\", label: \"Volume\" },\n {\n value: \"BoundingBoxLongestEdgeLength\",\n label: \"Longest Edge Length\",\n },\n {\n value: \"BoundingBoxIntermediateEdgeLength\",\n label: \"Intermediate Edge Length\",\n },\n {\n value: \"BoundingBoxShortestEdgeLength\",\n label: \"Shortest Edge Length\",\n },\n {\n value: \"BoundingBoxDiagonalLength\",\n label: \"Diagonal Length\",\n },\n {\n value: \"BoundingBoxLongestFaceDiagonalLength\",\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxIntermediateFaceDiagonalLength\",\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxShortestFaceDiagonalLength\",\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={returnFn}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyAction;\n"]}
1
+ {"version":3,"file":"CalculatedPropertyAction.js","sourceRoot":"","sources":["../../../../src/widget/components/CalculatedPropertyAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wDAAiD;AAIjD,wDAM8B;AAC9B,+CAA+D;AAC/D,gEAAwC;AACxC,sFAGkD;AAClD,sEAAwE;AACxE,mCAAoD;AACpD,+CAAkE;AAClE,2CAAyC;AAEzC,4DAAyD;AACzD,uDAA+C;AAW/C,MAAM,wBAAwB,GAAG,CAAC,EAChC,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,EACH,QAAQ,GACsB,EAAE,EAAE;;IAClC,MAAM,UAAU,GAAG,kBAAU,CAAC,4BAAU,CAAC,CAAC;IAC1C,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,gBAAQ,CAC9C,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,mCAAI,EAAE,CAC7B,CAAC;IACF,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,gBAAQ,CAAS,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,mCAAI,EAAE,CAAC,CAAC;IAC/D,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,gBAAQ,EAAuC,CAAC;IAC1F,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,gBAAQ,CAAU,KAAK,CAAC,CAAC;IAC3D,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC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AAC,MAAM,CAAC,KAAK,CAAC,CACzB,CACP,EACD,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EACjB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,GACjB,CACO,CACP;QACN,8BAAC,qBAAW,IACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EACrC,gBAAgB,EAAE,CAAC,CAAC,IAAI,IAAI,YAAY,CAAC,EACzC,SAAS,EAAE,SAAS,GACpB,CACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,wBAAwB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n SelectOption,\n} from \"@itwin/itwinui-react\";\nimport {\n Fieldset,\n LabeledInput,\n LabeledSelect,\n MenuItem,\n Small,\n} from \"@itwin/itwinui-react\";\nimport React, { useContext, useEffect, useState } from \"react\";\nimport ActionPanel from \"./ActionPanel\";\nimport {\n BboxDimension,\n BboxDimensionsDecorator,\n} from \"../../decorators/BboxDimensionsDecorator\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../hooks/useValidator\";\nimport { handleError, WidgetHeader } from \"./utils\";\nimport { visualizeElements, zoomToElements } from \"./viewerUtils\";\nimport \"./CalculatedPropertyAction.scss\";\nimport type { CalculatedPropertyType } from \"./CalculatedPropertyTable\";\nimport { ReportingClient } from \"@itwin/insights-client\";\nimport { ApiContext } from \"./GroupingMapping\";\n\ninterface CalculatedPropertyActionProps {\n iModelId: string;\n mappingId: string;\n groupId: string;\n property?: CalculatedPropertyType;\n ids: string[];\n returnFn: (modified: boolean) => Promise<void>;\n}\n\nconst CalculatedPropertyAction = ({\n iModelId,\n mappingId,\n groupId,\n property,\n ids,\n returnFn,\n}: CalculatedPropertyActionProps) => {\n const apiContext = useContext(ApiContext);\n const [propertyName, setPropertyName] = useState<string>(\n property?.propertyName ?? \"\",\n );\n const [type, setType] = useState<string>(property?.type ?? \"\");\n const [bboxDecorator, setBboxDecorator] = useState<BboxDimensionsDecorator | undefined>();\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [inferredSpatialData, setInferredSpatialData] = useState<Map<BboxDimension, number> | undefined>();\n const [validator, showValidationMessage] = useValidator();\n\n useEffect(() => {\n const decorator = new BboxDimensionsDecorator();\n IModelApp.viewManager.addDecorator(decorator);\n setBboxDecorator(decorator);\n return () => {\n IModelApp.viewManager.dropDecorator(decorator);\n };\n }, []);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n visualizeElements([ids[0]], \"red\");\n void zoomToElements([ids[0]]);\n }, [ids]);\n\n useEffect(() => {\n if (ids.length === 0) {\n return;\n }\n const setContext = async () => {\n if (bboxDecorator) {\n await bboxDecorator.setContext(ids[0]);\n setInferredSpatialData(bboxDecorator.getInferredSpatialData());\n }\n };\n void setContext();\n }, [bboxDecorator, ids]);\n\n useEffect(() => {\n if (bboxDecorator && type && inferredSpatialData) {\n inferredSpatialData.has(BboxDimension[type as keyof typeof BboxDimension])\n ? bboxDecorator.drawContext(\n BboxDimension[type as keyof typeof BboxDimension],\n )\n : bboxDecorator.clearContext();\n }\n }, [bboxDecorator, inferredSpatialData, type]);\n\n const onSave = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n try {\n setIsLoading(true);\n\n const reportingClientApi = new ReportingClient(apiContext.prefix);\n\n property\n ? await reportingClientApi.updateCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n property.id ?? \"\",\n {\n propertyName,\n type,\n },\n )\n : await reportingClientApi.createCalculatedProperty(\n apiContext.accessToken,\n iModelId,\n mappingId,\n groupId,\n {\n propertyName,\n type,\n },\n );\n await returnFn(true);\n } catch (error: any) {\n handleError(error.status);\n setIsLoading(false);\n }\n };\n\n const getSpatialData = (value: string) =>\n inferredSpatialData?.has(\n BboxDimension[value as keyof typeof BboxDimension],\n ) && (\n <div>\n {`${inferredSpatialData\n ?.get(BboxDimension[value as keyof typeof BboxDimension])\n ?.toPrecision(4)}m`}\n </div>\n );\n\n return (\n <>\n <WidgetHeader\n title={\n property\n ? `${property?.propertyName ?? \"\"}`\n : \"Create Calculated Property\"\n }\n returnFn={async () => returnFn(false)}\n />\n <div className='calculated-properties-action-container'>\n <Fieldset legend='Calculated Property Details' className='details-form'>\n <Small className='field-legend'>\n Asterisk * indicates mandatory fields.\n </Small>\n <LabeledInput\n value={propertyName}\n required\n name='name'\n label='Name'\n onChange={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n message={validator.message(\"name\", propertyName, NAME_REQUIREMENTS)}\n status={\n validator.message(\"name\", propertyName, NAME_REQUIREMENTS)\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(\"name\");\n }}\n onBlurCapture={(event) => {\n setPropertyName(event.target.value);\n validator.showMessageFor(\"name\");\n }}\n />\n <LabeledSelect<string>\n label='Quantity Type'\n required\n options={[\n { value: \"Length\", label: \"Length\" },\n { value: \"Area\", label: \"Area\" },\n { value: \"Volume\", label: \"Volume\" },\n {\n value: \"BoundingBoxLongestEdgeLength\",\n label: \"Longest Edge Length\",\n },\n {\n value: \"BoundingBoxIntermediateEdgeLength\",\n label: \"Intermediate Edge Length\",\n },\n {\n value: \"BoundingBoxShortestEdgeLength\",\n label: \"Shortest Edge Length\",\n },\n {\n value: \"BoundingBoxDiagonalLength\",\n label: \"Diagonal Length\",\n },\n {\n value: \"BoundingBoxLongestFaceDiagonalLength\",\n label: \"Longest Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxIntermediateFaceDiagonalLength\",\n label: \"Intermediate Face Diagonal Length\",\n },\n {\n value: \"BoundingBoxShortestFaceDiagonalLength\",\n label: \"Shortest Face Diagonal Length\",\n },\n ]}\n value={type}\n onChange={setType}\n itemRenderer={(option: SelectOption<string>) => (\n <MenuItem>\n <div className='gr-cp-menu-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n </MenuItem>\n )}\n selectedItemRenderer={(option: SelectOption<string>) => (\n <div className='select-item'>\n <div>{option.label}</div>\n {getSpatialData(option.value)}\n </div>\n )}\n onShow={() => { }}\n onHide={() => { }}\n />\n </Fieldset>\n </div>\n <ActionPanel\n onSave={onSave}\n onCancel={async () => returnFn(false)}\n isSavingDisabled={!(type && propertyName)}\n isLoading={isLoading}\n />\n </>\n );\n};\n\nexport default CalculatedPropertyAction;\n"]}