@bgroup/wise-form 1.0.2 → 1.0.5

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 (269) hide show
  1. package/README.md +1 -1
  2. package/package.json +23 -4
  3. package/postcss.config.js +6 -0
  4. package/src/form/styles.css +11 -37
  5. package/src/form/view/components/containers/index.tsx +33 -4
  6. package/src/form/view/components/error.tsx +0 -3
  7. package/src/form/view/components/field/container.tsx +1 -1
  8. package/src/form/view/components/field/index.tsx +42 -7
  9. package/src/form/view/components/rows/row-container.tsx +37 -9
  10. package/src/form/view/components/rows/wrapper.tsx +17 -6
  11. package/src/form/view/components/wrapped-form.tsx +38 -5
  12. package/src/form/view/hooks/use-model.ts +91 -25
  13. package/src/form/view/index.tsx +15 -3
  14. package/src/models/field.ts +504 -458
  15. package/tailwind.config.js +11 -0
  16. package/tsconfig.json +2 -0
  17. package/vite.config.ts +59 -0
  18. package/dist/components/ui/Checkbox.d.ts +0 -14
  19. package/dist/components/ui/Checkbox.d.ts.map +0 -1
  20. package/dist/components/ui/Checkbox.js +0 -43
  21. package/dist/components/ui/Checkbox.js.map +0 -1
  22. package/dist/components/ui/CheckboxGroup.d.ts +0 -15
  23. package/dist/components/ui/CheckboxGroup.d.ts.map +0 -1
  24. package/dist/components/ui/CheckboxGroup.js +0 -33
  25. package/dist/components/ui/CheckboxGroup.js.map +0 -1
  26. package/dist/components/ui/Input.d.ts +0 -14
  27. package/dist/components/ui/Input.d.ts.map +0 -1
  28. package/dist/components/ui/Input.js +0 -49
  29. package/dist/components/ui/Input.js.map +0 -1
  30. package/dist/components/ui/Radio.d.ts +0 -14
  31. package/dist/components/ui/Radio.d.ts.map +0 -1
  32. package/dist/components/ui/Radio.js +0 -43
  33. package/dist/components/ui/Radio.js.map +0 -1
  34. package/dist/components/ui/Select.d.ts +0 -18
  35. package/dist/components/ui/Select.d.ts.map +0 -1
  36. package/dist/components/ui/Select.js +0 -44
  37. package/dist/components/ui/Select.js.map +0 -1
  38. package/dist/components/ui/Textarea.d.ts +0 -13
  39. package/dist/components/ui/Textarea.d.ts.map +0 -1
  40. package/dist/components/ui/Textarea.js +0 -42
  41. package/dist/components/ui/Textarea.js.map +0 -1
  42. package/dist/components/ui/index.d.ts +0 -13
  43. package/dist/components/ui/index.d.ts.map +0 -1
  44. package/dist/components/ui/index.js +0 -7
  45. package/dist/components/ui/index.js.map +0 -1
  46. package/dist/form/index.d.ts +0 -10
  47. package/dist/form/index.d.ts.map +0 -1
  48. package/dist/form/index.js +0 -5
  49. package/dist/form/index.js.map +0 -1
  50. package/dist/form/interfaces/field-container.d.ts +0 -8
  51. package/dist/form/interfaces/field-container.d.ts.map +0 -1
  52. package/dist/form/interfaces/field-container.js +0 -2
  53. package/dist/form/interfaces/field-container.js.map +0 -1
  54. package/dist/form/interfaces/interfaces.d.ts +0 -8
  55. package/dist/form/interfaces/interfaces.d.ts.map +0 -1
  56. package/dist/form/interfaces/interfaces.js +0 -2
  57. package/dist/form/interfaces/interfaces.js.map +0 -1
  58. package/dist/form/interfaces/settings.d.ts +0 -10
  59. package/dist/form/interfaces/settings.d.ts.map +0 -1
  60. package/dist/form/interfaces/settings.js +0 -2
  61. package/dist/form/interfaces/settings.js.map +0 -1
  62. package/dist/form/interfaces/template.d.ts +0 -6
  63. package/dist/form/interfaces/template.d.ts.map +0 -1
  64. package/dist/form/interfaces/template.js +0 -2
  65. package/dist/form/interfaces/template.js.map +0 -1
  66. package/dist/form/interfaces/wise-form-specs.d.ts +0 -9
  67. package/dist/form/interfaces/wise-form-specs.d.ts.map +0 -1
  68. package/dist/form/interfaces/wise-form-specs.js +0 -2
  69. package/dist/form/interfaces/wise-form-specs.js.map +0 -1
  70. package/dist/form/view/components/containers/index.d.ts +0 -3
  71. package/dist/form/view/components/containers/index.d.ts.map +0 -1
  72. package/dist/form/view/components/containers/index.js +0 -12
  73. package/dist/form/view/components/containers/index.js.map +0 -1
  74. package/dist/form/view/components/error.d.ts +0 -5
  75. package/dist/form/view/components/error.d.ts.map +0 -1
  76. package/dist/form/view/components/error.js +0 -8
  77. package/dist/form/view/components/error.js.map +0 -1
  78. package/dist/form/view/components/field/container.d.ts +0 -5
  79. package/dist/form/view/components/field/container.d.ts.map +0 -1
  80. package/dist/form/view/components/field/container.js +0 -5
  81. package/dist/form/view/components/field/container.js.map +0 -1
  82. package/dist/form/view/components/field/index.d.ts +0 -18
  83. package/dist/form/view/components/field/index.d.ts.map +0 -1
  84. package/dist/form/view/components/field/index.js +0 -89
  85. package/dist/form/view/components/field/index.js.map +0 -1
  86. package/dist/form/view/components/field/selection.d.ts +0 -2
  87. package/dist/form/view/components/field/selection.d.ts.map +0 -1
  88. package/dist/form/view/components/field/selection.js +0 -35
  89. package/dist/form/view/components/field/selection.js.map +0 -1
  90. package/dist/form/view/components/field/use-field.d.ts +0 -4
  91. package/dist/form/view/components/field/use-field.d.ts.map +0 -1
  92. package/dist/form/view/components/field/use-field.js +0 -41
  93. package/dist/form/view/components/field/use-field.js.map +0 -1
  94. package/dist/form/view/components/rows/row-container.d.ts +0 -18
  95. package/dist/form/view/components/rows/row-container.d.ts.map +0 -1
  96. package/dist/form/view/components/rows/row-container.js +0 -89
  97. package/dist/form/view/components/rows/row-container.js.map +0 -1
  98. package/dist/form/view/components/rows/wrapper.d.ts +0 -12
  99. package/dist/form/view/components/rows/wrapper.d.ts.map +0 -1
  100. package/dist/form/view/components/rows/wrapper.js +0 -27
  101. package/dist/form/view/components/rows/wrapper.js.map +0 -1
  102. package/dist/form/view/components/wrapped-form.d.ts +0 -6
  103. package/dist/form/view/components/wrapped-form.d.ts.map +0 -1
  104. package/dist/form/view/components/wrapped-form.js +0 -26
  105. package/dist/form/view/components/wrapped-form.js.map +0 -1
  106. package/dist/form/view/context.d.ts +0 -23
  107. package/dist/form/view/context.d.ts.map +0 -1
  108. package/dist/form/view/context.js +0 -7
  109. package/dist/form/view/context.js.map +0 -1
  110. package/dist/form/view/hooks/use-model.d.ts +0 -10
  111. package/dist/form/view/hooks/use-model.d.ts.map +0 -1
  112. package/dist/form/view/hooks/use-model.js +0 -31
  113. package/dist/form/view/hooks/use-model.js.map +0 -1
  114. package/dist/form/view/hooks/use-template.d.ts +0 -14
  115. package/dist/form/view/hooks/use-template.d.ts.map +0 -1
  116. package/dist/form/view/hooks/use-template.js +0 -57
  117. package/dist/form/view/hooks/use-template.js.map +0 -1
  118. package/dist/form/view/hooks/use-types.d.ts +0 -2
  119. package/dist/form/view/hooks/use-types.d.ts.map +0 -1
  120. package/dist/form/view/hooks/use-types.js +0 -19
  121. package/dist/form/view/hooks/use-types.js.map +0 -1
  122. package/dist/form/view/index.d.ts +0 -3
  123. package/dist/form/view/index.d.ts.map +0 -1
  124. package/dist/form/view/index.js +0 -38
  125. package/dist/form/view/index.js.map +0 -1
  126. package/dist/formulas/helpers/condition-types.d.ts +0 -5
  127. package/dist/formulas/helpers/condition-types.d.ts.map +0 -1
  128. package/dist/formulas/helpers/condition-types.js +0 -5
  129. package/dist/formulas/helpers/condition-types.js.map +0 -1
  130. package/dist/formulas/helpers/evaluations.d.ts +0 -15
  131. package/dist/formulas/helpers/evaluations.d.ts.map +0 -1
  132. package/dist/formulas/helpers/evaluations.js +0 -44
  133. package/dist/formulas/helpers/evaluations.js.map +0 -1
  134. package/dist/formulas/helpers/formula.d.ts +0 -6
  135. package/dist/formulas/helpers/formula.d.ts.map +0 -1
  136. package/dist/formulas/helpers/formula.js +0 -26
  137. package/dist/formulas/helpers/formula.js.map +0 -1
  138. package/dist/formulas/helpers/lexer.d.ts +0 -10
  139. package/dist/formulas/helpers/lexer.d.ts.map +0 -1
  140. package/dist/formulas/helpers/lexer.js +0 -73
  141. package/dist/formulas/helpers/lexer.js.map +0 -1
  142. package/dist/formulas/helpers/parser.d.ts +0 -24
  143. package/dist/formulas/helpers/parser.d.ts.map +0 -1
  144. package/dist/formulas/helpers/parser.js +0 -48
  145. package/dist/formulas/helpers/parser.js.map +0 -1
  146. package/dist/formulas/helpers/token.d.ts +0 -14
  147. package/dist/formulas/helpers/token.d.ts.map +0 -1
  148. package/dist/formulas/helpers/token.js +0 -14
  149. package/dist/formulas/helpers/token.js.map +0 -1
  150. package/dist/formulas/index.d.ts +0 -59
  151. package/dist/formulas/index.d.ts.map +0 -1
  152. package/dist/formulas/index.js +0 -186
  153. package/dist/formulas/index.js.map +0 -1
  154. package/dist/formulas/types/formulas.d.ts +0 -68
  155. package/dist/formulas/types/formulas.d.ts.map +0 -1
  156. package/dist/formulas/types/formulas.js +0 -2
  157. package/dist/formulas/types/formulas.js.map +0 -1
  158. package/dist/formulas/types/index.d.ts +0 -5
  159. package/dist/formulas/types/index.d.ts.map +0 -1
  160. package/dist/formulas/types/index.js +0 -2
  161. package/dist/formulas/types/index.js.map +0 -1
  162. package/dist/formulas/variants/array-formula.d.ts +0 -24
  163. package/dist/formulas/variants/array-formula.d.ts.map +0 -1
  164. package/dist/formulas/variants/array-formula.js +0 -142
  165. package/dist/formulas/variants/array-formula.js.map +0 -1
  166. package/dist/formulas/variants/base.d.ts +0 -6
  167. package/dist/formulas/variants/base.d.ts.map +0 -1
  168. package/dist/formulas/variants/base.js +0 -3
  169. package/dist/formulas/variants/base.js.map +0 -1
  170. package/dist/formulas/variants/basic.d.ts +0 -18
  171. package/dist/formulas/variants/basic.d.ts.map +0 -1
  172. package/dist/formulas/variants/basic.js +0 -128
  173. package/dist/formulas/variants/basic.js.map +0 -1
  174. package/dist/formulas/variants/comparison.d.ts +0 -25
  175. package/dist/formulas/variants/comparison.d.ts.map +0 -1
  176. package/dist/formulas/variants/comparison.js +0 -153
  177. package/dist/formulas/variants/comparison.js.map +0 -1
  178. package/dist/formulas/variants/conditional.d.ts +0 -18
  179. package/dist/formulas/variants/conditional.d.ts.map +0 -1
  180. package/dist/formulas/variants/conditional.js +0 -183
  181. package/dist/formulas/variants/conditional.js.map +0 -1
  182. package/dist/formulas/variants/iterative-array.d.ts +0 -20
  183. package/dist/formulas/variants/iterative-array.d.ts.map +0 -1
  184. package/dist/formulas/variants/iterative-array.js +0 -155
  185. package/dist/formulas/variants/iterative-array.js.map +0 -1
  186. package/dist/formulas/variants/per-value.d.ts +0 -20
  187. package/dist/formulas/variants/per-value.d.ts.map +0 -1
  188. package/dist/formulas/variants/per-value.js +0 -154
  189. package/dist/formulas/variants/per-value.js.map +0 -1
  190. package/dist/index.d.ts +0 -5
  191. package/dist/index.d.ts.map +0 -1
  192. package/dist/index.js +0 -6
  193. package/dist/index.js.map +0 -1
  194. package/dist/models/base.d.ts +0 -55
  195. package/dist/models/base.d.ts.map +0 -1
  196. package/dist/models/base.js +0 -146
  197. package/dist/models/base.js.map +0 -1
  198. package/dist/models/callback-manager.d.ts +0 -7
  199. package/dist/models/callback-manager.d.ts.map +0 -1
  200. package/dist/models/callback-manager.js +0 -89
  201. package/dist/models/callback-manager.js.map +0 -1
  202. package/dist/models/field.d.ts +0 -121
  203. package/dist/models/field.d.ts.map +0 -1
  204. package/dist/models/field.js +0 -443
  205. package/dist/models/field.js.map +0 -1
  206. package/dist/models/index.d.ts +0 -13
  207. package/dist/models/index.d.ts.map +0 -1
  208. package/dist/models/index.js +0 -7
  209. package/dist/models/index.js.map +0 -1
  210. package/dist/models/model.d.ts +0 -37
  211. package/dist/models/model.d.ts.map +0 -1
  212. package/dist/models/model.js +0 -245
  213. package/dist/models/model.js.map +0 -1
  214. package/dist/models/plugins/base.d.ts +0 -9
  215. package/dist/models/plugins/base.d.ts.map +0 -1
  216. package/dist/models/plugins/base.js +0 -3
  217. package/dist/models/plugins/base.js.map +0 -1
  218. package/dist/models/plugins/formula.d.ts +0 -18
  219. package/dist/models/plugins/formula.d.ts.map +0 -1
  220. package/dist/models/plugins/formula.js +0 -82
  221. package/dist/models/plugins/formula.js.map +0 -1
  222. package/dist/models/plugins/index.d.ts +0 -11
  223. package/dist/models/plugins/index.d.ts.map +0 -1
  224. package/dist/models/plugins/index.js +0 -52
  225. package/dist/models/plugins/index.js.map +0 -1
  226. package/dist/models/plugins/plugins.d.ts +0 -7
  227. package/dist/models/plugins/plugins.d.ts.map +0 -1
  228. package/dist/models/plugins/plugins.js +0 -7
  229. package/dist/models/plugins/plugins.js.map +0 -1
  230. package/dist/models/types/base-wise-model.d.ts +0 -7
  231. package/dist/models/types/base-wise-model.d.ts.map +0 -1
  232. package/dist/models/types/base-wise-model.js +0 -2
  233. package/dist/models/types/base-wise-model.js.map +0 -1
  234. package/dist/models/types/callbacks.d.ts +0 -19
  235. package/dist/models/types/callbacks.d.ts.map +0 -1
  236. package/dist/models/types/callbacks.js +0 -2
  237. package/dist/models/types/callbacks.js.map +0 -1
  238. package/dist/models/types/disabled.d.ts +0 -8
  239. package/dist/models/types/disabled.d.ts.map +0 -1
  240. package/dist/models/types/disabled.js +0 -2
  241. package/dist/models/types/disabled.js.map +0 -1
  242. package/dist/models/types/form-field.d.ts +0 -25
  243. package/dist/models/types/form-field.d.ts.map +0 -1
  244. package/dist/models/types/form-field.js +0 -2
  245. package/dist/models/types/form-field.js.map +0 -1
  246. package/dist/models/types/model.d.ts +0 -13
  247. package/dist/models/types/model.d.ts.map +0 -1
  248. package/dist/models/types/model.js +0 -2
  249. package/dist/models/types/model.js.map +0 -1
  250. package/dist/models/types/plugins.d.ts +0 -13
  251. package/dist/models/types/plugins.d.ts.map +0 -1
  252. package/dist/models/types/plugins.js +0 -2
  253. package/dist/models/types/plugins.js.map +0 -1
  254. package/dist/models/types/wrapped-form-model-props.d.ts +0 -11
  255. package/dist/models/types/wrapped-form-model-props.d.ts.map +0 -1
  256. package/dist/models/types/wrapped-form-model-props.js +0 -2
  257. package/dist/models/types/wrapped-form-model-props.js.map +0 -1
  258. package/dist/models/wrapper.d.ts +0 -30
  259. package/dist/models/wrapper.d.ts.map +0 -1
  260. package/dist/models/wrapper.js +0 -213
  261. package/dist/models/wrapper.js.map +0 -1
  262. package/dist/settings/index.d.ts +0 -7
  263. package/dist/settings/index.d.ts.map +0 -1
  264. package/dist/settings/index.js +0 -26
  265. package/dist/settings/index.js.map +0 -1
  266. package/dist/utils/pending-promise.d.ts +0 -6
  267. package/dist/utils/pending-promise.d.ts.map +0 -1
  268. package/dist/utils/pending-promise.js +0 -24
  269. package/dist/utils/pending-promise.js.map +0 -1
@@ -1,128 +0,0 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _FormulaBasic_plugin, _FormulaBasic_specs, _FormulaBasic_tokens, _FormulaBasic_value, _FormulaBasic_emptyValue, _FormulaBasic_variables, _FormulaBasic_round, _FormulaBasic_ceil, _FormulaBasic_parent, _FormulaBasic_isNotListenToChanges;
13
- import { parse } from 'mathjs';
14
- export class FormulaBasic {
15
- get formula() {
16
- return __classPrivateFieldGet(this, _FormulaBasic_specs, "f").formula;
17
- }
18
- get base() {
19
- const formula = __classPrivateFieldGet(this, _FormulaBasic_specs, "f").formula;
20
- return formula.base;
21
- }
22
- get value() {
23
- return __classPrivateFieldGet(this, _FormulaBasic_value, "f");
24
- }
25
- get name() {
26
- return __classPrivateFieldGet(this, _FormulaBasic_specs, "f").name;
27
- }
28
- /**
29
- * Represents the fields defined in the plugin settings
30
- */
31
- get fields() {
32
- const formula = this.formula;
33
- return typeof formula?.fields === 'string'
34
- ? [formula?.fields]
35
- : formula?.fields;
36
- }
37
- get conditions() {
38
- if (typeof __classPrivateFieldGet(this, _FormulaBasic_specs, "f").formula === 'string')
39
- return;
40
- const formula = __classPrivateFieldGet(this, _FormulaBasic_specs, "f").formula;
41
- return formula.conditions;
42
- }
43
- get variables() {
44
- return __classPrivateFieldGet(this, _FormulaBasic_variables, "f");
45
- }
46
- constructor(parent, plugin, specs) {
47
- _FormulaBasic_plugin.set(this, void 0);
48
- _FormulaBasic_specs.set(this, void 0);
49
- _FormulaBasic_tokens.set(this, void 0);
50
- _FormulaBasic_value.set(this, void 0);
51
- _FormulaBasic_emptyValue.set(this, void 0);
52
- _FormulaBasic_variables.set(this, []);
53
- _FormulaBasic_round.set(this, void 0);
54
- _FormulaBasic_ceil.set(this, void 0);
55
- _FormulaBasic_parent.set(this, void 0);
56
- _FormulaBasic_isNotListenToChanges.set(this, false);
57
- __classPrivateFieldSet(this, _FormulaBasic_parent, parent, "f");
58
- __classPrivateFieldSet(this, _FormulaBasic_plugin, plugin, "f");
59
- __classPrivateFieldSet(this, _FormulaBasic_specs, specs, "f");
60
- __classPrivateFieldSet(this, _FormulaBasic_round, specs.round, "f");
61
- __classPrivateFieldSet(this, _FormulaBasic_ceil, specs.ceil, "f");
62
- __classPrivateFieldSet(this, _FormulaBasic_emptyValue, specs.emptyValue, "f");
63
- __classPrivateFieldSet(this, _FormulaBasic_isNotListenToChanges, specs.isNotListenToChanges, "f");
64
- }
65
- initialize() {
66
- const { tokens } = __classPrivateFieldGet(this, _FormulaBasic_parent, "f").getParser(__classPrivateFieldGet(this, _FormulaBasic_specs, "f"));
67
- __classPrivateFieldSet(this, _FormulaBasic_tokens, tokens, "f");
68
- const variables = __classPrivateFieldGet(this, _FormulaBasic_tokens, "f")
69
- .filter((token) => token.type === 'variable')
70
- .map((item) => item.value);
71
- __classPrivateFieldSet(this, _FormulaBasic_variables, variables, "f");
72
- const models = __classPrivateFieldGet(this, _FormulaBasic_parent, "f").getModels(variables);
73
- if (!__classPrivateFieldGet(this, _FormulaBasic_isNotListenToChanges, "f"))
74
- models.forEach((model) => {
75
- if ([undefined].includes(model)) {
76
- return;
77
- }
78
- model.on('change', this.calculate.bind(this));
79
- });
80
- if (!Array.isArray(__classPrivateFieldGet(this, _FormulaBasic_variables, "f")) || !__classPrivateFieldGet(this, _FormulaBasic_variables, "f").length) {
81
- __classPrivateFieldSet(this, _FormulaBasic_value, parse(this.formula).evaluate(), "f");
82
- }
83
- }
84
- async calculate() {
85
- const variables = __classPrivateFieldGet(this, _FormulaBasic_variables, "f");
86
- const formulaField = __classPrivateFieldGet(this, _FormulaBasic_plugin, "f").form.getField(this.name);
87
- let params = await __classPrivateFieldGet(this, _FormulaBasic_parent, "f").getParams(variables);
88
- const models = __classPrivateFieldGet(this, _FormulaBasic_parent, "f").getModels(variables);
89
- const empty = models.every((model) => [null, undefined, ''].includes(model.value));
90
- if (empty) {
91
- // If all models are empty, set the input to empty if exists.
92
- if (formulaField)
93
- formulaField.set({ value: __classPrivateFieldGet(this, _FormulaBasic_emptyValue, "f") || '' });
94
- __classPrivateFieldSet(this, _FormulaBasic_value, undefined, "f");
95
- return;
96
- }
97
- try {
98
- let result = models.length === 1 &&
99
- !['+', '-', '*', '/'].some((item) => this.formula.toString().includes(item))
100
- ? models[0].value
101
- : parse(this.formula).evaluate(params);
102
- const isInvalidResult = [
103
- -Infinity,
104
- Infinity,
105
- undefined,
106
- null,
107
- NaN,
108
- ].includes(result);
109
- if (__classPrivateFieldGet(this, _FormulaBasic_round, "f") && !isInvalidResult)
110
- result = Math.round(result);
111
- if (__classPrivateFieldGet(this, _FormulaBasic_ceil, "f") && !isInvalidResult)
112
- result = Math.ceil(result);
113
- __classPrivateFieldSet(this, _FormulaBasic_value, isInvalidResult
114
- ? __classPrivateFieldGet(this, _FormulaBasic_emptyValue, "f")
115
- : Number(result.toFixed(2)), "f");
116
- if (formulaField)
117
- formulaField.set({ value: __classPrivateFieldGet(this, _FormulaBasic_value, "f") });
118
- __classPrivateFieldGet(this, _FormulaBasic_parent, "f").trigger('change');
119
- }
120
- catch (e) {
121
- console.log('formula', this.name, this.formula, params);
122
- console.trace(e);
123
- throw new Error(`Error calculating the formula: ${e.message} ${this.name}`);
124
- }
125
- }
126
- }
127
- _FormulaBasic_plugin = new WeakMap(), _FormulaBasic_specs = new WeakMap(), _FormulaBasic_tokens = new WeakMap(), _FormulaBasic_value = new WeakMap(), _FormulaBasic_emptyValue = new WeakMap(), _FormulaBasic_variables = new WeakMap(), _FormulaBasic_round = new WeakMap(), _FormulaBasic_ceil = new WeakMap(), _FormulaBasic_parent = new WeakMap(), _FormulaBasic_isNotListenToChanges = new WeakMap();
128
- //# sourceMappingURL=basic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../src/formulas/variants/basic.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,MAAM,OAAO,YAAY;IAIrB,IAAI,OAAO;QACP,OAAO,uBAAA,IAAI,2BAAO,CAAC,OAAO,CAAC;IAC/B,CAAC;IACD,IAAI,IAAI;QACJ,MAAM,OAAO,GAAsB,uBAAA,IAAI,2BAAO,CAAC,OAAO,CAAC;QACvD,OAAO,OAAO,CAAC,IAAI,CAAC;IACxB,CAAC;IAED,IAAI,KAAK;QACL,OAAO,uBAAA,IAAI,2BAAO,CAAC;IACvB,CAAC;IACD,IAAI,IAAI;QACJ,OAAO,uBAAA,IAAI,2BAAO,CAAC,IAAI,CAAC;IAC5B,CAAC;IACD;;OAEG;IACH,IAAI,MAAM;QACN,MAAM,OAAO,GAAsB,IAAI,CAAC,OAAO,CAAC;QAChD,OAAO,OAAO,OAAO,EAAE,MAAM,KAAK,QAAQ;YACtC,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC;YACnB,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,CAAC;IAED,IAAI,UAAU;QACV,IAAI,OAAO,uBAAA,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BAAA,IAAI,4BAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACxD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,MAAM,IAAI,KAAK,CACX,kCAAkC,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAC7D,CAAC;QACN,CAAC;IACL,CAAC;CACJ"}
@@ -1,25 +0,0 @@
1
- import { IComplexCondition, IConditionalField } from "../types/formulas";
2
- export declare class FormulaComparison {
3
- #private;
4
- get formula(): string | IComplexCondition;
5
- get base(): string;
6
- get value(): string | number;
7
- get name(): string;
8
- /**
9
- * Represents the fields defined in the plugin settings
10
- */
11
- get fields(): string[];
12
- get conditions(): IConditionalField | IConditionalField[];
13
- get variables(): string[];
14
- get observers(): string[];
15
- constructor(parent: any, plugin: any, specs: any);
16
- initialize(): void;
17
- start(): void;
18
- evaluate(): {
19
- name: any;
20
- value: any;
21
- };
22
- calculate(): Promise<number>;
23
- calculateUpper(models: any): any;
24
- }
25
- //# sourceMappingURL=comparison.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"comparison.d.ts","sourceRoot":"","sources":["../../../src/formulas/variants/comparison.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG1F,qBAAa,iBAAiB;;IAK7B,IAAI,OAAO,+BAEV;IACD,IAAI,IAAI,WAGP;IAED,IAAI,KAAK,oBAER;IACD,IAAI,IAAI,WAEP;IACD;;OAEG;IACH,IAAI,MAAM,aAGT;IAED,IAAI,UAAU,4CAIb;IAGD,IAAI,SAAS,aAEZ;IAGD,IAAI,SAAS,aAEZ;gBAKW,MAAM,KAAA,EAAE,MAAM,KAAA,EAAE,KAAK,KAAA;IAQjC,UAAU;IAgBV,KAAK;IAEL,QAAQ;;;;IAkCF,SAAS;IAiCf,cAAc,CAAC,MAAM,KAAA;CAQrB"}
@@ -1,153 +0,0 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _FormulaComparison_plugin, _FormulaComparison_specs, _FormulaComparison_emptyValue, _FormulaComparison_tokens, _FormulaComparison_value, _FormulaComparison_variables, _FormulaComparison_observers, _FormulaComparison_isNotListenToChanges, _FormulaComparison_parent;
13
- import { EvaluationsManager } from "../helpers/evaluations";
14
- import { parse } from "mathjs";
15
- export class FormulaComparison {
16
- get formula() {
17
- return __classPrivateFieldGet(this, _FormulaComparison_specs, "f").formula;
18
- }
19
- get base() {
20
- const formula = __classPrivateFieldGet(this, _FormulaComparison_specs, "f").formula;
21
- return formula.base;
22
- }
23
- get value() {
24
- return __classPrivateFieldGet(this, _FormulaComparison_value, "f");
25
- }
26
- get name() {
27
- return __classPrivateFieldGet(this, _FormulaComparison_specs, "f").name;
28
- }
29
- /**
30
- * Represents the fields defined in the plugin settings
31
- */
32
- get fields() {
33
- const formula = this.formula;
34
- return typeof formula?.fields === "string" ? [formula?.fields] : formula?.fields;
35
- }
36
- get conditions() {
37
- if (typeof __classPrivateFieldGet(this, _FormulaComparison_specs, "f").formula === "string")
38
- return;
39
- const formula = __classPrivateFieldGet(this, _FormulaComparison_specs, "f").formula;
40
- return formula.conditions;
41
- }
42
- get variables() {
43
- return __classPrivateFieldGet(this, _FormulaComparison_variables, "f");
44
- }
45
- ;
46
- get observers() {
47
- return __classPrivateFieldGet(this, _FormulaComparison_observers, "f");
48
- }
49
- constructor(parent, plugin, specs) {
50
- _FormulaComparison_plugin.set(this, void 0);
51
- _FormulaComparison_specs.set(this, void 0);
52
- _FormulaComparison_emptyValue.set(this, void 0);
53
- _FormulaComparison_tokens.set(this, void 0);
54
- _FormulaComparison_value.set(this, void 0);
55
- _FormulaComparison_variables.set(this, []);
56
- _FormulaComparison_observers.set(this, void 0);
57
- _FormulaComparison_isNotListenToChanges.set(this, false);
58
- _FormulaComparison_parent.set(this, void 0);
59
- __classPrivateFieldSet(this, _FormulaComparison_parent, parent, "f");
60
- __classPrivateFieldSet(this, _FormulaComparison_plugin, plugin, "f");
61
- __classPrivateFieldSet(this, _FormulaComparison_specs, specs, "f");
62
- __classPrivateFieldSet(this, _FormulaComparison_isNotListenToChanges, specs.isNotListenToChanges, "f");
63
- __classPrivateFieldSet(this, _FormulaComparison_observers, specs.formula.observers, "f");
64
- }
65
- initialize() {
66
- if (!Array.isArray(__classPrivateFieldGet(this, _FormulaComparison_specs, "f").fields)) {
67
- throw new Error("The fields property must be an array");
68
- }
69
- if (!__classPrivateFieldGet(this, _FormulaComparison_isNotListenToChanges, "f") && __classPrivateFieldGet(this, _FormulaComparison_observers, "f") && Array.isArray(__classPrivateFieldGet(this, _FormulaComparison_observers, "f")) && !!__classPrivateFieldGet(this, _FormulaComparison_observers, "f").length) {
70
- const fields = __classPrivateFieldGet(this, _FormulaComparison_parent, "f").getModels(__classPrivateFieldGet(this, _FormulaComparison_observers, "f"));
71
- fields.forEach(field => {
72
- if (!field)
73
- return;
74
- field.on('change', this.calculate.bind(this));
75
- });
76
- }
77
- const models = __classPrivateFieldGet(this, _FormulaComparison_parent, "f").getModels(__classPrivateFieldGet(this, _FormulaComparison_specs, "f").fields);
78
- if (!__classPrivateFieldGet(this, _FormulaComparison_isNotListenToChanges, "f"))
79
- models.forEach(model => model.on("change", this.calculate.bind(this)));
80
- }
81
- start() { }
82
- evaluate() {
83
- const formula = __classPrivateFieldGet(this, _FormulaComparison_specs, "f").formula;
84
- if (typeof formula === "string" || !formula.conditions) {
85
- console.error("Invalid formula configuration");
86
- return null;
87
- }
88
- const models = __classPrivateFieldGet(this, _FormulaComparison_parent, "f").getModels(__classPrivateFieldGet(this, _FormulaComparison_specs, "f").fields);
89
- let fieldValues = models.map(fieldModel => {
90
- if (!fieldModel)
91
- return;
92
- return { name: fieldModel.name, value: fieldModel ? fieldModel.value : null };
93
- });
94
- // Utilizar reduce para comparar cada par de valores consecutivos y determinar cuál cumple la condición
95
- const resultField = fieldValues.reduce((prevField, currentField) => {
96
- if (!prevField)
97
- return currentField;
98
- // Si el campo previo cumple la condición con respecto al actual, se mantiene como el campo elegido
99
- if (EvaluationsManager.validate(formula.condition, prevField.value, currentField.value)) {
100
- return prevField;
101
- }
102
- // De lo contrario, el campo actual se convierte en el nuevo campo elegido
103
- return currentField;
104
- }, null);
105
- if (resultField) {
106
- // Ajustar según la lógica específica deseada, como devolver una fórmula particular basada en el resultado
107
- return resultField;
108
- }
109
- else {
110
- // Manejar el caso de que ninguno cumpla la condición
111
- return null;
112
- }
113
- }
114
- async calculate() {
115
- let applied = this.evaluate();
116
- if (!applied || !applied?.value) {
117
- // any formula apply, so we need to reset the value
118
- __classPrivateFieldSet(this, _FormulaComparison_value, 0, "f");
119
- return;
120
- }
121
- /**
122
- * Get the formula analyzer
123
- */
124
- const specsFormula = __classPrivateFieldGet(this, _FormulaComparison_specs, "f").formula;
125
- const formulaString = specsFormula.conditions[applied.name];
126
- const formula = __classPrivateFieldGet(this, _FormulaComparison_parent, "f").getParser({ formula: formulaString });
127
- const variables = formula.tokens.filter(token => token.type === "variable").map(item => item.value);
128
- const params = await __classPrivateFieldGet(this, _FormulaComparison_parent, "f").getParams(variables);
129
- try {
130
- const keys = Object.keys(params);
131
- const result = keys.length === 1 ? params[keys[0]] : parse(this.formula).evaluate(params);
132
- __classPrivateFieldSet(this, _FormulaComparison_value, [-Infinity, Infinity, undefined, null, NaN].includes(result)
133
- ? __classPrivateFieldGet(this, _FormulaComparison_emptyValue, "f")
134
- : Number(result.toFixed(2)), "f");
135
- __classPrivateFieldGet(this, _FormulaComparison_parent, "f").trigger("change");
136
- return __classPrivateFieldGet(this, _FormulaComparison_value, "f");
137
- }
138
- catch (e) {
139
- console.log("formula", this.name, this.formula, params);
140
- throw new Error("Error calculating the formula");
141
- }
142
- }
143
- calculateUpper(models) {
144
- let glue;
145
- models.forEach(item => {
146
- if (Number(item.value) > Number(glue?.value ?? 0))
147
- glue = item;
148
- });
149
- return glue;
150
- }
151
- }
152
- _FormulaComparison_plugin = new WeakMap(), _FormulaComparison_specs = new WeakMap(), _FormulaComparison_emptyValue = new WeakMap(), _FormulaComparison_tokens = new WeakMap(), _FormulaComparison_value = new WeakMap(), _FormulaComparison_variables = new WeakMap(), _FormulaComparison_observers = new WeakMap(), _FormulaComparison_isNotListenToChanges = new WeakMap(), _FormulaComparison_parent = new WeakMap();
153
- //# sourceMappingURL=comparison.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"comparison.js","sourceRoot":"","sources":["../../../src/formulas/variants/comparison.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAI5D,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,OAAO,iBAAiB;IAK7B,IAAI,OAAO;QACV,OAAO,uBAAA,IAAI,gCAAO,CAAC,OAAO,CAAC;IAC5B,CAAC;IACD,IAAI,IAAI;QACP,MAAM,OAAO,GAAsB,uBAAA,IAAI,gCAAO,CAAC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ACZ,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACxD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAClD,CAAC;IACF,CAAC;IAED,cAAc,CAAC,MAAM;QACpB,IAAI,IAAI,CAAC;QACT,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACrB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC,CAAC;gBAAE,IAAI,GAAG,IAAI,CAAC;QAChE,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
@@ -1,18 +0,0 @@
1
- import { IComplexCondition, IConditionalField } from '../types/formulas';
2
- export declare class FormulaConditional {
3
- #private;
4
- get formula(): string | IComplexCondition;
5
- get base(): string;
6
- get value(): string | number;
7
- get name(): string;
8
- /**
9
- * Represents the fields defined in the plugin settings
10
- */
11
- get fields(): string[];
12
- get conditions(): IConditionalField | IConditionalField[];
13
- constructor(parent: any, plugin: any, specs: any);
14
- initialize(): void;
15
- evaluate(): any;
16
- calculate(): Promise<string | number>;
17
- }
18
- //# sourceMappingURL=conditional.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../../src/formulas/variants/conditional.ts"],"names":[],"mappings":"AAGA,OAAO,EAGH,iBAAiB,EACjB,iBAAiB,EACpB,MAAM,mBAAmB,CAAC;AAG3B,qBAAa,kBAAkB;;IAI3B,IAAI,OAAO,+BAEV;IACD,IAAI,IAAI,WAGP;IAED,IAAI,KAAK,oBAER;IACD,IAAI,IAAI,WAEP;IACD;;OAEG;IACH,IAAI,MAAM,aAKT;IAED,IAAI,UAAU,4CAIb;gBAWW,MAAM,KAAA,EAAE,MAAM,KAAA,EAAE,KAAK,KAAA;IAYjC,UAAU;IA6BV,QAAQ;IAyDF,SAAS;CAsDlB"}
@@ -1,183 +0,0 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _FormulaConditional_plugin, _FormulaConditional_specs, _FormulaConditional_emptyValue, _FormulaConditional_value, _FormulaConditional_fields, _FormulaConditional_parent, _FormulaConditional_ceil, _FormulaConditional_round, _FormulaConditional_isNotListenToChanges;
13
- import { conditionsTypes } from '../helpers/condition-types';
14
- import { EvaluationsManager } from '../helpers/evaluations';
15
- import { parse } from 'mathjs';
16
- export class FormulaConditional {
17
- get formula() {
18
- return __classPrivateFieldGet(this, _FormulaConditional_specs, "f").formula;
19
- }
20
- get base() {
21
- const formula = __classPrivateFieldGet(this, _FormulaConditional_specs, "f").formula;
22
- return formula.base;
23
- }
24
- get value() {
25
- return __classPrivateFieldGet(this, _FormulaConditional_value, "f");
26
- }
27
- get name() {
28
- return __classPrivateFieldGet(this, _FormulaConditional_specs, "f").name;
29
- }
30
- /**
31
- * Represents the fields defined in the plugin settings
32
- */
33
- get fields() {
34
- const formula = this.formula;
35
- return typeof formula?.fields === 'string'
36
- ? [formula?.fields]
37
- : formula?.fields;
38
- }
39
- get conditions() {
40
- if (typeof __classPrivateFieldGet(this, _FormulaConditional_specs, "f").formula === 'string')
41
- return;
42
- const formula = __classPrivateFieldGet(this, _FormulaConditional_specs, "f").formula;
43
- return formula.conditions;
44
- }
45
- constructor(parent, plugin, specs) {
46
- _FormulaConditional_plugin.set(this, void 0);
47
- _FormulaConditional_specs.set(this, void 0);
48
- _FormulaConditional_emptyValue.set(this, void 0);
49
- _FormulaConditional_value.set(this, void 0);
50
- /**
51
- * FormField type
52
- */
53
- _FormulaConditional_fields.set(this, void 0);
54
- _FormulaConditional_parent.set(this, void 0);
55
- _FormulaConditional_ceil.set(this, void 0);
56
- _FormulaConditional_round.set(this, void 0);
57
- _FormulaConditional_isNotListenToChanges.set(this, false);
58
- __classPrivateFieldSet(this, _FormulaConditional_parent, parent, "f");
59
- __classPrivateFieldSet(this, _FormulaConditional_plugin, plugin, "f");
60
- __classPrivateFieldSet(this, _FormulaConditional_specs, specs, "f");
61
- __classPrivateFieldSet(this, _FormulaConditional_round, specs.round, "f");
62
- __classPrivateFieldSet(this, _FormulaConditional_ceil, specs.ceil, "f");
63
- __classPrivateFieldSet(this, _FormulaConditional_emptyValue, specs.emptyValue, "f");
64
- if (specs.isNotListenToChanges)
65
- __classPrivateFieldSet(this, _FormulaConditional_isNotListenToChanges, specs.isNotListenToChanges, "f");
66
- }
67
- initialize() {
68
- try {
69
- const { form } = __classPrivateFieldGet(this, _FormulaConditional_plugin, "f");
70
- if (!this.fields) {
71
- throw new Error(`Fields not found in formula ${this.name}`);
72
- }
73
- const fields = this.fields.map((name) => {
74
- const formula = __classPrivateFieldGet(this, _FormulaConditional_plugin, "f").formulas.get(name);
75
- if (formula)
76
- return formula;
77
- const field = form.getField(name);
78
- return field;
79
- });
80
- __classPrivateFieldSet(this, _FormulaConditional_fields, fields, "f");
81
- if (this.name === 'costoTotalGrafico') {
82
- console.log('fields', fields);
83
- }
84
- if (!__classPrivateFieldGet(this, _FormulaConditional_isNotListenToChanges, "f"))
85
- fields.forEach((field) => {
86
- if (!field) {
87
- throw new Error(`Field ${this.name} not found in form ${form.name}`);
88
- }
89
- field.on('change', this.calculate.bind(this));
90
- });
91
- }
92
- catch (e) { }
93
- }
94
- evaluate() {
95
- const formula = __classPrivateFieldGet(this, _FormulaConditional_specs, "f").formula;
96
- let evaluatedFormula = { formula: formula.base }; // Use the base formula by default
97
- if (formula.conditions) {
98
- const conditionsArray = Array.isArray(formula.conditions) ? formula.conditions : [formula.conditions];
99
- for (const condition of conditionsArray) {
100
- let conditionMet = false;
101
- if (condition.conditions) {
102
- // If there are nested conditions, all must be met
103
- conditionMet = condition.conditions.every((subCondition) => {
104
- const fieldValues = subCondition.fields.map((fieldName) => {
105
- const field = __classPrivateFieldGet(this, _FormulaConditional_fields, "f").find((f) => f.name === fieldName);
106
- return field
107
- ? field.value
108
- : __classPrivateFieldGet(this, _FormulaConditional_emptyValue, "f");
109
- });
110
- return EvaluationsManager.validateAll(subCondition.condition, fieldValues, subCondition.value);
111
- });
112
- }
113
- else {
114
- const fieldValues = condition.fields.map((fieldName) => {
115
- const field = __classPrivateFieldGet(this, _FormulaConditional_fields, "f").find((f) => f.name === fieldName);
116
- return field ? field.value : __classPrivateFieldGet(this, _FormulaConditional_emptyValue, "f");
117
- });
118
- const conditionType = !!condition.type && conditionsTypes[condition.type]
119
- ? conditionsTypes[condition.type]
120
- : conditionsTypes.some;
121
- // Check if any of the specified fields meet the condition
122
- conditionMet = EvaluationsManager[conditionType](condition.condition, fieldValues, condition.value);
123
- }
124
- if (conditionMet) {
125
- evaluatedFormula.formula = condition.formula;
126
- evaluatedFormula.fi = condition;
127
- break;
128
- }
129
- }
130
- }
131
- return evaluatedFormula;
132
- }
133
- async calculate() {
134
- /**
135
- * the formula is taken from the evaluate method since the conditions are evaluated there and
136
- * can change the formula to be applied
137
- */
138
- const model = __classPrivateFieldGet(this, _FormulaConditional_plugin, "f").form.getField(this.name);
139
- const formula = this.evaluate();
140
- if (!formula.formula) {
141
- __classPrivateFieldSet(this, _FormulaConditional_value, __classPrivateFieldGet(this, _FormulaConditional_emptyValue, "f") !== undefined ? __classPrivateFieldGet(this, _FormulaConditional_emptyValue, "f") : '', "f");
142
- model && model.set({ value: __classPrivateFieldGet(this, _FormulaConditional_value, "f") });
143
- __classPrivateFieldGet(this, _FormulaConditional_parent, "f").trigger('change');
144
- return __classPrivateFieldGet(this, _FormulaConditional_value, "f");
145
- }
146
- // todo: Review if this section can be replaced by formulaManager.variables property.
147
- const { tokens } = __classPrivateFieldGet(this, _FormulaConditional_parent, "f").getParser(formula);
148
- const variables = tokens
149
- .filter((token) => token.type === 'variable')
150
- .map((item) => item.value);
151
- const params = await __classPrivateFieldGet(this, _FormulaConditional_parent, "f").getParams(variables);
152
- try {
153
- const keys = Object.keys(params);
154
- let result = keys.length === 1
155
- ? params[keys[0]]
156
- : parse(formula.formula).evaluate(params);
157
- const isInvalidResult = [
158
- -Infinity,
159
- Infinity,
160
- undefined,
161
- null,
162
- NaN,
163
- ].includes(result);
164
- if (__classPrivateFieldGet(this, _FormulaConditional_round, "f") && !isInvalidResult)
165
- result = Math.round(result);
166
- if (__classPrivateFieldGet(this, _FormulaConditional_ceil, "f") && !isInvalidResult)
167
- result = Math.ceil(result);
168
- __classPrivateFieldSet(this, _FormulaConditional_value, isInvalidResult || typeof result === 'object'
169
- ? __classPrivateFieldGet(this, _FormulaConditional_emptyValue, "f")
170
- : Number(result.toFixed(2)), "f");
171
- __classPrivateFieldGet(this, _FormulaConditional_parent, "f").trigger('change');
172
- model && model.set({ value: __classPrivateFieldGet(this, _FormulaConditional_value, "f") });
173
- return __classPrivateFieldGet(this, _FormulaConditional_value, "f");
174
- }
175
- catch (e) {
176
- console.log('formula', this.name, formula.formula, params);
177
- console.error(e);
178
- throw new Error('Error calculating the formula');
179
- }
180
- }
181
- }
182
- _FormulaConditional_plugin = new WeakMap(), _FormulaConditional_specs = new WeakMap(), _FormulaConditional_emptyValue = new WeakMap(), _FormulaConditional_value = new WeakMap(), _FormulaConditional_fields = new WeakMap(), _FormulaConditional_parent = new WeakMap(), _FormulaConditional_ceil = new WeakMap(), _FormulaConditional_round = new WeakMap(), _FormulaConditional_isNotListenToChanges = new WeakMap();
183
- //# sourceMappingURL=conditional.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conditional.js","sourceRoot":"","sources":["../../../src/formulas/variants/conditional.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAO5D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,MAAM,OAAO,kBAAkB;IAI3B,IAAI,OAAO;QACP,OAAO,uBAAA,IAAI,iCAAO,CAAC,OAAO,CAAC;IAC/B,CAAC;IACD,IAAI,IAAI;QACJ,MAAM,OAAO,GAAsB,uBAAA,IAAI,iCAAO,CAAC,OAAO,CAAC;QACvD,OAAO,OAAO,CAAC,IAAI,CAAC;IACxB,CAAC;IAED,IAAI,KAAK;QACL,OAAO,uBAAA,IAAI,iCAAO,CAAC;IACvB,CAAC;IACD,IAAI,IAAI;QACJ,OAAO,uBAAA,IAAI,iCAAO,CAAC,IAAI,CAAC;IAC5B,CAAC;IACD;;OAEG;IACH,IAAI,MAAM;QACN,MAAM,OAAO,GAAsB,IAAI,CAAC,OAAO,CAAC;QAChD,OAAO,OAAO,OAAO,EAAE,MAAM,KAAK,QAAQ;YACtC,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC;YACnB,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,CAAC;IAED,IAAI,UAAU;QACV,IAAI,OAAO,uBAAA,IAAI,iCAAO,CAAC,OAAO,KAAK,QAAQ;YAAE,OAAO;QACpD,MAAM,OAAO,GAAG,uBAAA,IAAI,iCAAO,CAAC,OAA4B,CAAC;QACzD,OAAO,OAAO,CAAC,UAAU,CAAC;IAC9B,CAAC;IAWD,YAAY,MAAM,EAAE,MAAM,EAAE,KA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IComplexCondition;
5
- get base(): string;
6
- get value(): string | number;
7
- get name(): string;
8
- /**
9
- * Represents the fields defined in the plugin settings
10
- */
11
- get fields(): string[];
12
- get conditions(): import("../types/formulas").IConditionalField | import("../types/formulas").IConditionalField[];
13
- get variables(): string[];
14
- constructor(parent: any, plugin: any, specs: any);
15
- initialize(): void;
16
- calculate(): Promise<void>;
17
- private sanitizeData;
18
- private sanitizeValue;
19
- }
20
- //# sourceMappingURL=iterative-array.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"iterative-array.d.ts","sourceRoot":"","sources":["../../../src/formulas/variants/iterative-array.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGvE,qBAAa,qBAAqB;;IAIjC,IAAI,OAAO,+BAEV;IACD,IAAI,IAAI,WAGP;IAED,IAAI,KAAK,oBAER;IACD,IAAI,IAAI,WAEP;IACD;;OAEG;IACH,IAAI,MAAM,aAGT;IAED,IAAI,UAAU,oGAIb;IAID,IAAI,SAAS,aAEZ;gBAQW,MAAM,KAAA,EAAE,MAAM,KAAA,EAAE,KAAK,KAAA;IAUjC,UAAU;IASJ,SAAS;IA8Df,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,aAAa;CAGrB"}