@bgroup/wise-form 1.0.1

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 (319) hide show
  1. package/README.md +34 -0
  2. package/dist/components/ui/Checkbox.d.ts +14 -0
  3. package/dist/components/ui/Checkbox.d.ts.map +1 -0
  4. package/dist/components/ui/Checkbox.js +43 -0
  5. package/dist/components/ui/Checkbox.js.map +1 -0
  6. package/dist/components/ui/CheckboxGroup.d.ts +15 -0
  7. package/dist/components/ui/CheckboxGroup.d.ts.map +1 -0
  8. package/dist/components/ui/CheckboxGroup.js +33 -0
  9. package/dist/components/ui/CheckboxGroup.js.map +1 -0
  10. package/dist/components/ui/Input.d.ts +14 -0
  11. package/dist/components/ui/Input.d.ts.map +1 -0
  12. package/dist/components/ui/Input.js +49 -0
  13. package/dist/components/ui/Input.js.map +1 -0
  14. package/dist/components/ui/Radio.d.ts +14 -0
  15. package/dist/components/ui/Radio.d.ts.map +1 -0
  16. package/dist/components/ui/Radio.js +43 -0
  17. package/dist/components/ui/Radio.js.map +1 -0
  18. package/dist/components/ui/Select.d.ts +18 -0
  19. package/dist/components/ui/Select.d.ts.map +1 -0
  20. package/dist/components/ui/Select.js +44 -0
  21. package/dist/components/ui/Select.js.map +1 -0
  22. package/dist/components/ui/Textarea.d.ts +13 -0
  23. package/dist/components/ui/Textarea.d.ts.map +1 -0
  24. package/dist/components/ui/Textarea.js +42 -0
  25. package/dist/components/ui/Textarea.js.map +1 -0
  26. package/dist/components/ui/index.d.ts +13 -0
  27. package/dist/components/ui/index.d.ts.map +1 -0
  28. package/dist/components/ui/index.js +7 -0
  29. package/dist/components/ui/index.js.map +1 -0
  30. package/dist/form/index.d.ts +10 -0
  31. package/dist/form/index.d.ts.map +1 -0
  32. package/dist/form/index.js +5 -0
  33. package/dist/form/index.js.map +1 -0
  34. package/dist/form/interfaces/field-container.d.ts +8 -0
  35. package/dist/form/interfaces/field-container.d.ts.map +1 -0
  36. package/dist/form/interfaces/field-container.js +2 -0
  37. package/dist/form/interfaces/field-container.js.map +1 -0
  38. package/dist/form/interfaces/interfaces.d.ts +8 -0
  39. package/dist/form/interfaces/interfaces.d.ts.map +1 -0
  40. package/dist/form/interfaces/interfaces.js +2 -0
  41. package/dist/form/interfaces/interfaces.js.map +1 -0
  42. package/dist/form/interfaces/settings.d.ts +10 -0
  43. package/dist/form/interfaces/settings.d.ts.map +1 -0
  44. package/dist/form/interfaces/settings.js +2 -0
  45. package/dist/form/interfaces/settings.js.map +1 -0
  46. package/dist/form/interfaces/template.d.ts +6 -0
  47. package/dist/form/interfaces/template.d.ts.map +1 -0
  48. package/dist/form/interfaces/template.js +2 -0
  49. package/dist/form/interfaces/template.js.map +1 -0
  50. package/dist/form/interfaces/wise-form-specs.d.ts +9 -0
  51. package/dist/form/interfaces/wise-form-specs.d.ts.map +1 -0
  52. package/dist/form/interfaces/wise-form-specs.js +2 -0
  53. package/dist/form/interfaces/wise-form-specs.js.map +1 -0
  54. package/dist/form/view/components/containers/index.d.ts +3 -0
  55. package/dist/form/view/components/containers/index.d.ts.map +1 -0
  56. package/dist/form/view/components/containers/index.js +12 -0
  57. package/dist/form/view/components/containers/index.js.map +1 -0
  58. package/dist/form/view/components/error.d.ts +5 -0
  59. package/dist/form/view/components/error.d.ts.map +1 -0
  60. package/dist/form/view/components/error.js +8 -0
  61. package/dist/form/view/components/error.js.map +1 -0
  62. package/dist/form/view/components/field/container.d.ts +5 -0
  63. package/dist/form/view/components/field/container.d.ts.map +1 -0
  64. package/dist/form/view/components/field/container.js +5 -0
  65. package/dist/form/view/components/field/container.js.map +1 -0
  66. package/dist/form/view/components/field/index.d.ts +18 -0
  67. package/dist/form/view/components/field/index.d.ts.map +1 -0
  68. package/dist/form/view/components/field/index.js +89 -0
  69. package/dist/form/view/components/field/index.js.map +1 -0
  70. package/dist/form/view/components/field/selection.d.ts +2 -0
  71. package/dist/form/view/components/field/selection.d.ts.map +1 -0
  72. package/dist/form/view/components/field/selection.js +35 -0
  73. package/dist/form/view/components/field/selection.js.map +1 -0
  74. package/dist/form/view/components/field/use-field.d.ts +4 -0
  75. package/dist/form/view/components/field/use-field.d.ts.map +1 -0
  76. package/dist/form/view/components/field/use-field.js +41 -0
  77. package/dist/form/view/components/field/use-field.js.map +1 -0
  78. package/dist/form/view/components/rows/row-container.d.ts +18 -0
  79. package/dist/form/view/components/rows/row-container.d.ts.map +1 -0
  80. package/dist/form/view/components/rows/row-container.js +89 -0
  81. package/dist/form/view/components/rows/row-container.js.map +1 -0
  82. package/dist/form/view/components/rows/wrapper.d.ts +12 -0
  83. package/dist/form/view/components/rows/wrapper.d.ts.map +1 -0
  84. package/dist/form/view/components/rows/wrapper.js +27 -0
  85. package/dist/form/view/components/rows/wrapper.js.map +1 -0
  86. package/dist/form/view/components/wrapped-form.d.ts +6 -0
  87. package/dist/form/view/components/wrapped-form.d.ts.map +1 -0
  88. package/dist/form/view/components/wrapped-form.js +26 -0
  89. package/dist/form/view/components/wrapped-form.js.map +1 -0
  90. package/dist/form/view/context.d.ts +23 -0
  91. package/dist/form/view/context.d.ts.map +1 -0
  92. package/dist/form/view/context.js +7 -0
  93. package/dist/form/view/context.js.map +1 -0
  94. package/dist/form/view/hooks/use-model.d.ts +10 -0
  95. package/dist/form/view/hooks/use-model.d.ts.map +1 -0
  96. package/dist/form/view/hooks/use-model.js +31 -0
  97. package/dist/form/view/hooks/use-model.js.map +1 -0
  98. package/dist/form/view/hooks/use-template.d.ts +14 -0
  99. package/dist/form/view/hooks/use-template.d.ts.map +1 -0
  100. package/dist/form/view/hooks/use-template.js +57 -0
  101. package/dist/form/view/hooks/use-template.js.map +1 -0
  102. package/dist/form/view/hooks/use-types.d.ts +2 -0
  103. package/dist/form/view/hooks/use-types.d.ts.map +1 -0
  104. package/dist/form/view/hooks/use-types.js +19 -0
  105. package/dist/form/view/hooks/use-types.js.map +1 -0
  106. package/dist/form/view/index.d.ts +3 -0
  107. package/dist/form/view/index.d.ts.map +1 -0
  108. package/dist/form/view/index.js +38 -0
  109. package/dist/form/view/index.js.map +1 -0
  110. package/dist/formulas/helpers/condition-types.d.ts +5 -0
  111. package/dist/formulas/helpers/condition-types.d.ts.map +1 -0
  112. package/dist/formulas/helpers/condition-types.js +5 -0
  113. package/dist/formulas/helpers/condition-types.js.map +1 -0
  114. package/dist/formulas/helpers/evaluations.d.ts +15 -0
  115. package/dist/formulas/helpers/evaluations.d.ts.map +1 -0
  116. package/dist/formulas/helpers/evaluations.js +44 -0
  117. package/dist/formulas/helpers/evaluations.js.map +1 -0
  118. package/dist/formulas/helpers/formula.d.ts +6 -0
  119. package/dist/formulas/helpers/formula.d.ts.map +1 -0
  120. package/dist/formulas/helpers/formula.js +26 -0
  121. package/dist/formulas/helpers/formula.js.map +1 -0
  122. package/dist/formulas/helpers/lexer.d.ts +10 -0
  123. package/dist/formulas/helpers/lexer.d.ts.map +1 -0
  124. package/dist/formulas/helpers/lexer.js +73 -0
  125. package/dist/formulas/helpers/lexer.js.map +1 -0
  126. package/dist/formulas/helpers/parser.d.ts +24 -0
  127. package/dist/formulas/helpers/parser.d.ts.map +1 -0
  128. package/dist/formulas/helpers/parser.js +48 -0
  129. package/dist/formulas/helpers/parser.js.map +1 -0
  130. package/dist/formulas/helpers/token.d.ts +14 -0
  131. package/dist/formulas/helpers/token.d.ts.map +1 -0
  132. package/dist/formulas/helpers/token.js +14 -0
  133. package/dist/formulas/helpers/token.js.map +1 -0
  134. package/dist/formulas/index.d.ts +59 -0
  135. package/dist/formulas/index.d.ts.map +1 -0
  136. package/dist/formulas/index.js +186 -0
  137. package/dist/formulas/index.js.map +1 -0
  138. package/dist/formulas/types/formulas.d.ts +68 -0
  139. package/dist/formulas/types/formulas.d.ts.map +1 -0
  140. package/dist/formulas/types/formulas.js +2 -0
  141. package/dist/formulas/types/formulas.js.map +1 -0
  142. package/dist/formulas/types/index.d.ts +5 -0
  143. package/dist/formulas/types/index.d.ts.map +1 -0
  144. package/dist/formulas/types/index.js +2 -0
  145. package/dist/formulas/types/index.js.map +1 -0
  146. package/dist/formulas/variants/array-formula.d.ts +24 -0
  147. package/dist/formulas/variants/array-formula.d.ts.map +1 -0
  148. package/dist/formulas/variants/array-formula.js +142 -0
  149. package/dist/formulas/variants/array-formula.js.map +1 -0
  150. package/dist/formulas/variants/base.d.ts +6 -0
  151. package/dist/formulas/variants/base.d.ts.map +1 -0
  152. package/dist/formulas/variants/base.js +3 -0
  153. package/dist/formulas/variants/base.js.map +1 -0
  154. package/dist/formulas/variants/basic.d.ts +18 -0
  155. package/dist/formulas/variants/basic.d.ts.map +1 -0
  156. package/dist/formulas/variants/basic.js +128 -0
  157. package/dist/formulas/variants/basic.js.map +1 -0
  158. package/dist/formulas/variants/comparison.d.ts +25 -0
  159. package/dist/formulas/variants/comparison.d.ts.map +1 -0
  160. package/dist/formulas/variants/comparison.js +153 -0
  161. package/dist/formulas/variants/comparison.js.map +1 -0
  162. package/dist/formulas/variants/conditional.d.ts +18 -0
  163. package/dist/formulas/variants/conditional.d.ts.map +1 -0
  164. package/dist/formulas/variants/conditional.js +183 -0
  165. package/dist/formulas/variants/conditional.js.map +1 -0
  166. package/dist/formulas/variants/iterative-array.d.ts +20 -0
  167. package/dist/formulas/variants/iterative-array.d.ts.map +1 -0
  168. package/dist/formulas/variants/iterative-array.js +155 -0
  169. package/dist/formulas/variants/iterative-array.js.map +1 -0
  170. package/dist/formulas/variants/per-value.d.ts +20 -0
  171. package/dist/formulas/variants/per-value.d.ts.map +1 -0
  172. package/dist/formulas/variants/per-value.js +154 -0
  173. package/dist/formulas/variants/per-value.js.map +1 -0
  174. package/dist/index.d.ts +5 -0
  175. package/dist/index.d.ts.map +1 -0
  176. package/dist/index.js +6 -0
  177. package/dist/index.js.map +1 -0
  178. package/dist/models/base.d.ts +55 -0
  179. package/dist/models/base.d.ts.map +1 -0
  180. package/dist/models/base.js +146 -0
  181. package/dist/models/base.js.map +1 -0
  182. package/dist/models/callback-manager.d.ts +7 -0
  183. package/dist/models/callback-manager.d.ts.map +1 -0
  184. package/dist/models/callback-manager.js +89 -0
  185. package/dist/models/callback-manager.js.map +1 -0
  186. package/dist/models/field.d.ts +121 -0
  187. package/dist/models/field.d.ts.map +1 -0
  188. package/dist/models/field.js +374 -0
  189. package/dist/models/field.js.map +1 -0
  190. package/dist/models/index.d.ts +13 -0
  191. package/dist/models/index.d.ts.map +1 -0
  192. package/dist/models/index.js +7 -0
  193. package/dist/models/index.js.map +1 -0
  194. package/dist/models/model.d.ts +37 -0
  195. package/dist/models/model.d.ts.map +1 -0
  196. package/dist/models/model.js +245 -0
  197. package/dist/models/model.js.map +1 -0
  198. package/dist/models/plugins/base.d.ts +9 -0
  199. package/dist/models/plugins/base.d.ts.map +1 -0
  200. package/dist/models/plugins/base.js +3 -0
  201. package/dist/models/plugins/base.js.map +1 -0
  202. package/dist/models/plugins/formula.d.ts +18 -0
  203. package/dist/models/plugins/formula.d.ts.map +1 -0
  204. package/dist/models/plugins/formula.js +82 -0
  205. package/dist/models/plugins/formula.js.map +1 -0
  206. package/dist/models/plugins/index.d.ts +11 -0
  207. package/dist/models/plugins/index.d.ts.map +1 -0
  208. package/dist/models/plugins/index.js +52 -0
  209. package/dist/models/plugins/index.js.map +1 -0
  210. package/dist/models/plugins/plugins.d.ts +7 -0
  211. package/dist/models/plugins/plugins.d.ts.map +1 -0
  212. package/dist/models/plugins/plugins.js +7 -0
  213. package/dist/models/plugins/plugins.js.map +1 -0
  214. package/dist/models/types/base-wise-model.d.ts +7 -0
  215. package/dist/models/types/base-wise-model.d.ts.map +1 -0
  216. package/dist/models/types/base-wise-model.js +2 -0
  217. package/dist/models/types/base-wise-model.js.map +1 -0
  218. package/dist/models/types/callbacks.d.ts +19 -0
  219. package/dist/models/types/callbacks.d.ts.map +1 -0
  220. package/dist/models/types/callbacks.js +2 -0
  221. package/dist/models/types/callbacks.js.map +1 -0
  222. package/dist/models/types/disabled.d.ts +8 -0
  223. package/dist/models/types/disabled.d.ts.map +1 -0
  224. package/dist/models/types/disabled.js +2 -0
  225. package/dist/models/types/disabled.js.map +1 -0
  226. package/dist/models/types/form-field.d.ts +25 -0
  227. package/dist/models/types/form-field.d.ts.map +1 -0
  228. package/dist/models/types/form-field.js +2 -0
  229. package/dist/models/types/form-field.js.map +1 -0
  230. package/dist/models/types/model.d.ts +13 -0
  231. package/dist/models/types/model.d.ts.map +1 -0
  232. package/dist/models/types/model.js +2 -0
  233. package/dist/models/types/model.js.map +1 -0
  234. package/dist/models/types/plugins.d.ts +13 -0
  235. package/dist/models/types/plugins.d.ts.map +1 -0
  236. package/dist/models/types/plugins.js +2 -0
  237. package/dist/models/types/plugins.js.map +1 -0
  238. package/dist/models/types/wrapped-form-model-props.d.ts +11 -0
  239. package/dist/models/types/wrapped-form-model-props.d.ts.map +1 -0
  240. package/dist/models/types/wrapped-form-model-props.js +2 -0
  241. package/dist/models/types/wrapped-form-model-props.js.map +1 -0
  242. package/dist/models/wrapper.d.ts +30 -0
  243. package/dist/models/wrapper.d.ts.map +1 -0
  244. package/dist/models/wrapper.js +213 -0
  245. package/dist/models/wrapper.js.map +1 -0
  246. package/dist/settings/index.d.ts +7 -0
  247. package/dist/settings/index.d.ts.map +1 -0
  248. package/dist/settings/index.js +26 -0
  249. package/dist/settings/index.js.map +1 -0
  250. package/dist/utils/pending-promise.d.ts +6 -0
  251. package/dist/utils/pending-promise.d.ts.map +1 -0
  252. package/dist/utils/pending-promise.js +24 -0
  253. package/dist/utils/pending-promise.js.map +1 -0
  254. package/package.json +38 -0
  255. package/src/components/ui/Checkbox.tsx +68 -0
  256. package/src/components/ui/CheckboxGroup.tsx +60 -0
  257. package/src/components/ui/Input.tsx +72 -0
  258. package/src/components/ui/Radio.tsx +68 -0
  259. package/src/components/ui/Select.tsx +73 -0
  260. package/src/components/ui/Textarea.tsx +63 -0
  261. package/src/components/ui/index.ts +14 -0
  262. package/src/form/index.ts +11 -0
  263. package/src/form/interfaces/field-container.ts +9 -0
  264. package/src/form/interfaces/interfaces.ts +12 -0
  265. package/src/form/interfaces/settings.ts +11 -0
  266. package/src/form/interfaces/template.ts +7 -0
  267. package/src/form/interfaces/wise-form-specs.ts +10 -0
  268. package/src/form/styles.css +40 -0
  269. package/src/form/view/components/containers/index.tsx +18 -0
  270. package/src/form/view/components/error.tsx +9 -0
  271. package/src/form/view/components/field/container.tsx +6 -0
  272. package/src/form/view/components/field/index.tsx +107 -0
  273. package/src/form/view/components/field/selection.tsx +39 -0
  274. package/src/form/view/components/field/use-field.tsx +49 -0
  275. package/src/form/view/components/rows/row-container.tsx +96 -0
  276. package/src/form/view/components/rows/wrapper.tsx +28 -0
  277. package/src/form/view/components/wrapped-form.tsx +32 -0
  278. package/src/form/view/context.tsx +26 -0
  279. package/src/form/view/hooks/use-model.ts +37 -0
  280. package/src/form/view/hooks/use-template.tsx +64 -0
  281. package/src/form/view/hooks/use-types.ts +21 -0
  282. package/src/form/view/index.tsx +48 -0
  283. package/src/formulas/helpers/condition-types.ts +5 -0
  284. package/src/formulas/helpers/evaluations.ts +48 -0
  285. package/src/formulas/helpers/formula.ts +27 -0
  286. package/src/formulas/helpers/lexer.ts +82 -0
  287. package/src/formulas/helpers/parser.ts +55 -0
  288. package/src/formulas/helpers/token.ts +22 -0
  289. package/src/formulas/index.ts +198 -0
  290. package/src/formulas/types/formulas.ts +72 -0
  291. package/src/formulas/types/index.ts +5 -0
  292. package/src/formulas/variants/array-formula.ts +138 -0
  293. package/src/formulas/variants/base.ts +6 -0
  294. package/src/formulas/variants/basic.ts +141 -0
  295. package/src/formulas/variants/comparison.ts +156 -0
  296. package/src/formulas/variants/conditional.ts +208 -0
  297. package/src/formulas/variants/iterative-array.ts +152 -0
  298. package/src/formulas/variants/per-value.ts +152 -0
  299. package/src/index.ts +6 -0
  300. package/src/models/base.ts +164 -0
  301. package/src/models/callback-manager.ts +102 -0
  302. package/src/models/field.ts +426 -0
  303. package/src/models/index.ts +14 -0
  304. package/src/models/model.ts +260 -0
  305. package/src/models/plugins/base.ts +11 -0
  306. package/src/models/plugins/formula.ts +80 -0
  307. package/src/models/plugins/index.ts +48 -0
  308. package/src/models/plugins/plugins.ts +8 -0
  309. package/src/models/types/base-wise-model.ts +7 -0
  310. package/src/models/types/callbacks.ts +23 -0
  311. package/src/models/types/disabled.ts +8 -0
  312. package/src/models/types/form-field.ts +22 -0
  313. package/src/models/types/model.ts +14 -0
  314. package/src/models/types/plugins.ts +15 -0
  315. package/src/models/types/wrapped-form-model-props.ts +9 -0
  316. package/src/models/wrapper.ts +242 -0
  317. package/src/settings/index.ts +11 -0
  318. package/src/utils/pending-promise.ts +29 -0
  319. package/tsconfig.json +39 -0
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { FormModel } from '@bgroup/wise-form/models';
3
+ import { useTemplate } from './use-template';
4
+ export function useModel(settings, form) {
5
+ const [model, setModel] = React.useState(form);
6
+ const [ready, setReady] = React.useState(false);
7
+ const [values, setValues] = React.useState(form?.values || {});
8
+ const templateSpecs = settings ? settings : form;
9
+ const { type, styles, items } = useTemplate(templateSpecs, templateSpecs.gap);
10
+ const startup = () => {
11
+ setReady(false);
12
+ const onChange = () => {
13
+ setReady(form.ready);
14
+ setValues({ ...form.values });
15
+ };
16
+ if (!form) {
17
+ const properties = settings.fields.map(item => item.name);
18
+ const values = settings.values || {};
19
+ form = new FormModel(settings, { properties, ...values });
20
+ }
21
+ setModel(form);
22
+ form.on('change', onChange);
23
+ onChange();
24
+ return () => {
25
+ form.off('change', onChange);
26
+ };
27
+ };
28
+ React.useEffect(startup, [form?.name]);
29
+ return { ready, model, values, type, styles, items };
30
+ }
31
+ //# sourceMappingURL=use-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-model.js","sourceRoot":"","sources":["../../../../src/form/view/hooks/use-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAA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C;QAE5B,QAAQ,EAAE,CAAC;QAEX,OAAO,GAAG,EAAE;YACX,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC9B,CAAC,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAEvC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACtD,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Applies a template to create a structured layout, optionally using a gap between elements.
3
+ *
4
+ * @param template - The template to be applied. Can be an array or an object conforming to the IFormTemplate interface.
5
+ * @param gap - Specifies the gap between elements.
6
+ * The `gap` parameter is deprecated and will be removed in a future version. Use the gap property within the template object instead.
7
+ * @returns An object representing the structured layout with type, styles, and items.
8
+ */
9
+ export declare function useTemplate(settings: any, gap?: any): {
10
+ type: string;
11
+ styles: {};
12
+ items: any;
13
+ };
14
+ //# sourceMappingURL=use-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-template.d.ts","sourceRoot":"","sources":["../../../../src/form/view/hooks/use-template.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,KAAA,EAAE,GAAG,MAAY;;;;EAoDpD"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Applies a template to create a structured layout, optionally using a gap between elements.
3
+ *
4
+ * @param template - The template to be applied. Can be an array or an object conforming to the IFormTemplate interface.
5
+ * @param gap - Specifies the gap between elements.
6
+ * The `gap` parameter is deprecated and will be removed in a future version. Use the gap property within the template object instead.
7
+ * @returns An object representing the structured layout with type, styles, and items.
8
+ */
9
+ export function useTemplate(settings, gap = undefined) {
10
+ if (!settings?.template)
11
+ throw new Error(`${settings?.name} Doesn't have a template`);
12
+ let template = settings?.template;
13
+ let structure = template;
14
+ let styles = {};
15
+ if (!template) {
16
+ return {
17
+ type: 'grid',
18
+ styles: {},
19
+ items: settings.fields.map(item => [1, '1fr']),
20
+ };
21
+ }
22
+ if (gap) {
23
+ template = { structure: template, gap: gap };
24
+ }
25
+ const isArray = Array.isArray(template);
26
+ if (!isArray) {
27
+ if (typeof template !== 'object' || !template.structure || !Array.isArray(template.structure)) {
28
+ throw new Error('Template must be an array or an object');
29
+ }
30
+ structure = template.structure;
31
+ styles = template.gap ? { gap: template.gap } : {};
32
+ }
33
+ const processString = str => {
34
+ if (typeof str === 'number')
35
+ return [1, '1fr'];
36
+ const [num, times] = str.split('x').map(Number);
37
+ const tpl = times
38
+ ? [
39
+ times,
40
+ Array(times)
41
+ .fill(num)
42
+ .reduce((acc, v) => `${acc} 1fr`, ''),
43
+ ]
44
+ : [1, '1fr'];
45
+ return tpl;
46
+ };
47
+ return {
48
+ type: 'grid',
49
+ styles: styles,
50
+ items: structure.map(item => {
51
+ if (!Array.isArray(item))
52
+ return processString(item);
53
+ return item;
54
+ }),
55
+ };
56
+ }
57
+ //# sourceMappingURL=use-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-template.js","sourceRoot":"","sources":["../../../../src/form/view/hooks/use-template.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,QAAQ,EAAE,GAAG,GAAG,SAAS;IACpD,IAAI,CAAC,QAAQ,EAAE,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,EAAE,IAAI,0BAA0B,CAAC,CAAC;IAEtF,IAAI,QAAQ,GAAG,QAAQ,EAAE,QAAQ,CAAC;IAClC,IAAI,SAAS,GAAG,QAAQ,CAAC;IACzB,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,OAAO;YACN,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,QAAQ,CAAC,MAAM,C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AAC,CAAC;QACd,OAAO,GAAG,CAAC;IACZ,CAAC,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;YACrD,OAAO,IAAI,CAAC;QACb,CAAC,CAAC;KACF,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function useTypes(types: any): any;
2
+ //# sourceMappingURL=use-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-types.d.ts","sourceRoot":"","sources":["../../../../src/form/view/hooks/use-types.ts"],"names":[],"mappings":"AAKA,wBAAgB,QAAQ,CAAC,KAAK,KAAA,OAc7B"}
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { WFSettings } from '../../../settings';
3
+ import { SelectionField } from '../components/field/selection';
4
+ import { Input, Textarea } from '../../../components/ui';
5
+ export function useTypes(types) {
6
+ return React.useMemo(() => {
7
+ const defaultTypes = {
8
+ checkbox: SelectionField,
9
+ radio: SelectionField,
10
+ select: SelectionField,
11
+ textarea: Textarea,
12
+ text: Input,
13
+ password: Input,
14
+ default: Input,
15
+ };
16
+ return { ...defaultTypes, ...WFSettings.types, ...types };
17
+ }, [types]);
18
+ }
19
+ //# sourceMappingURL=use-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-types.js","sourceRoot":"","sources":["../../../../src/form/view/hooks/use-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,UAAU,QAAQ,CAAC,KAAK;IAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACzB,MAAM,YAAY,GAAG;YACpB,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,cAAc;YACtB,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,KAAK;SACd,CAAC;QAEF,OAAO,EAAE,GAAG,YAAY,EAAE,GAAG,UAAU,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC;IAC3D,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { IWiseFormSpecs } from '../interfaces/wise-form-specs';
2
+ export declare function WiseForm({ children, settings, types, model }: IWiseFormSpecs): JSX.Element;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/view/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CAsC1F"}
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { useModel } from './hooks/use-model';
3
+ import { WiseFormContext } from './context';
4
+ import { useTypes } from './hooks/use-types';
5
+ import { Containers } from './components/containers';
6
+ export function WiseForm({ children, settings, types, model }) {
7
+ const { ready, model: instance, type, styles, items } = useModel(settings, model);
8
+ const formTypes = useTypes(types);
9
+ if (!ready)
10
+ return null;
11
+ if (!settings && !model) {
12
+ console.error('the form does not have settings or model defined', settings);
13
+ }
14
+ const onSubmit = (event) => {
15
+ event.preventDefault();
16
+ // Form submission can be handled via callbacks or custom handlers
17
+ if (instance.callbacks?.onSubmit) {
18
+ instance.callbacks.onSubmit({ form: instance, event });
19
+ }
20
+ };
21
+ const value = {
22
+ model: instance,
23
+ items,
24
+ rows: items,
25
+ values: instance.values,
26
+ name: instance.name,
27
+ template: { type, styles, items },
28
+ formTypes,
29
+ };
30
+ return (React.createElement(WiseFormContext.Provider, { value: value },
31
+ React.createElement("form", { onKeyDown: (e) => {
32
+ if (e.key === 'Enter')
33
+ e.preventDefault();
34
+ }, className: "reactive-form-container", onSubmit: onSubmit },
35
+ React.createElement(Containers, null),
36
+ children)));
37
+ }
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/form/view/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,UAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAkB;IAC5E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAClF,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,kDAAkD,EAAE,QAAQ,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,KAAsB,EAAE,EAAE;QAC3C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,kEAAkE;QAClE,IAAI,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;YAClC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QACxD,CAAC;IACF,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG;QACb,KAAK,EAAE,QAAQ;QACf,KAAK;QACL,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE;QACjC,SAAS;KACT,CAAC;IAEF,OAAO,CACN,oBAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK;QACrC,8BAAM,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;gBACtB,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO;oBAAE,CAAC,CAAC,cAAc,EAAE,CAAC;YAC3C,CAAC,EAAE,SAAS,EAAC,yBAAyB,EAAC,QAAQ,EAAE,QAAQ;YACxD,oBAAC,UAAU,OAAG;YACb,QAAQ,CACH,CACmB,CAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const conditionsTypes: {
2
+ every: string;
3
+ some: string;
4
+ };
5
+ //# sourceMappingURL=condition-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-types.d.ts","sourceRoot":"","sources":["../../../src/formulas/helpers/condition-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;CAG3B,CAAA"}
@@ -0,0 +1,5 @@
1
+ export const conditionsTypes = {
2
+ every: "validateAll",
3
+ some: "validateAny"
4
+ };
5
+ //# sourceMappingURL=condition-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"condition-types.js","sourceRoot":"","sources":["../../../src/formulas/helpers/condition-types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,KAAK,EAAE,aAAa;IACpB,IAAI,EAAE,aAAa;CACtB,CAAA"}
@@ -0,0 +1,15 @@
1
+ export declare class EvaluationsManager {
2
+ private static evaluations;
3
+ static validate(identifier: string, value: any, comparisonValue?: any): boolean;
4
+ /**
5
+ * Evalúa un arreglo de valores para ver si alguno cumple con la condición especificada.
6
+ * Retorna true si al menos uno de los valores cumple con la condición.
7
+ */
8
+ static validateAny(identifier: string, values: any[], comparisonValue?: any): boolean;
9
+ /**
10
+ * Evalúa un arreglo de valores para ver si todos cumplen con la condición especificada.
11
+ * Retorna true solo si todos los valores cumplen con la condición.
12
+ */
13
+ static validateAll(identifier: string, values: any[], comparisonValue?: any): boolean;
14
+ }
15
+ //# sourceMappingURL=evaluations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluations.d.ts","sourceRoot":"","sources":["../../../src/formulas/helpers/evaluations.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,MAAM,CAAC,WAAW,CAaxB;IAEF,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,GAAG,GAAG,OAAO;IAS/E;;;KAGI;IACJ,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,eAAe,CAAC,EAAE,GAAG,GAAG,OAAO;IAOrF;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,eAAe,CAAC,EAAE,GAAG,GAAG,OAAO;CAMrF"}
@@ -0,0 +1,44 @@
1
+ export class EvaluationsManager {
2
+ static validate(identifier, value, comparisonValue) {
3
+ if (!this.evaluations[identifier]) {
4
+ throw new Error(`Evaluation identifier "${identifier}" not recognized.`);
5
+ }
6
+ const result = this.evaluations[identifier](value, comparisonValue);
7
+ return result;
8
+ }
9
+ /**
10
+ * Evalúa un arreglo de valores para ver si alguno cumple con la condición especificada.
11
+ * Retorna true si al menos uno de los valores cumple con la condición.
12
+ */
13
+ static validateAny(identifier, values, comparisonValue) {
14
+ if (!this.evaluations[identifier]) {
15
+ throw new Error(`Evaluation identifier "${identifier}" not recognized.`);
16
+ }
17
+ return values.some(value => this.evaluations[identifier](value, comparisonValue));
18
+ }
19
+ /**
20
+ * Evalúa un arreglo de valores para ver si todos cumplen con la condición especificada.
21
+ * Retorna true solo si todos los valores cumplen con la condición.
22
+ */
23
+ static validateAll(identifier, values, comparisonValue) {
24
+ if (!this.evaluations[identifier]) {
25
+ throw new Error(`Evaluation identifier "${identifier}" not recognized.`);
26
+ }
27
+ return values.every(value => this.evaluations[identifier](value, comparisonValue));
28
+ }
29
+ }
30
+ EvaluationsManager.evaluations = {
31
+ equal: (value, comparisonValue) => value == comparisonValue,
32
+ lower: (value, comparisonValue) => Number(value) < Number(comparisonValue),
33
+ upper: (value, comparisonValue) => Number(value) > Number(comparisonValue),
34
+ between: (value, [min, max]) => {
35
+ const numValue = Number(value);
36
+ return numValue >= Number(min) && numValue <= Number(max);
37
+ },
38
+ different: (value, comparisonValue) => value != comparisonValue,
39
+ hasValue: value => ![undefined, null, '', false].includes(value),
40
+ empty: value => [undefined, null, '',].includes(value),
41
+ lessOrEqual: (value, comparisonValue) => Number(value) <= Number(comparisonValue),
42
+ greaterOrEqual: (value, comparisonValue) => Number(value) >= Number(comparisonValue),
43
+ };
44
+ //# sourceMappingURL=evaluations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluations.js","sourceRoot":"","sources":["../../../src/formulas/helpers/evaluations.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAkB;IAgB9B,MAAM,CAAC,QAAQ,CAAC,UAAkB,EAAE,KAAU,EAAE,eAAqB;QACpE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,U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,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC;IAC1E,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;QAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;IACD,SAAS,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,CAAC,KAAK,IAAI,eAAe;IAC/D,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;IAChE,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;IACtD,WAAW,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,eAAe,CAAC;IACjF,cAAc,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,eAAe,CAAC;CACpF,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare class Formula {
2
+ #private;
3
+ constructor(data: any);
4
+ initialize(): void;
5
+ }
6
+ //# sourceMappingURL=formula.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula.d.ts","sourceRoot":"","sources":["../../../src/formulas/helpers/formula.ts"],"names":[],"mappings":"AAUA,qBAAa,OAAO;;gBAIP,IAAI,KAAA;IAUhB,UAAU;CACV"}
@@ -0,0 +1,26 @@
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 _Formula_lexer, _Formula_parsers, _Formula_tokens;
7
+ import { Lexer } from './lexer';
8
+ import { Parser } from './parser';
9
+ export class Formula {
10
+ constructor(data) {
11
+ _Formula_lexer.set(this, new Lexer());
12
+ _Formula_parsers.set(this, new Map());
13
+ _Formula_tokens.set(this, void 0);
14
+ if (!data.formula)
15
+ throw new Error('To get a parser you must provide a formula');
16
+ // if (this.#parsers.has(data.formula)) return this.#parsers.get(data.formula);
17
+ const tokens = __classPrivateFieldGet(this, _Formula_lexer, "f").tokenize(data.formula);
18
+ const parser = new Parser(tokens);
19
+ const result = { tokens, parser, ...data };
20
+ __classPrivateFieldGet(this, _Formula_parsers, "f").set(data.formula, result);
21
+ return result;
22
+ }
23
+ initialize() { }
24
+ }
25
+ _Formula_lexer = new WeakMap(), _Formula_parsers = new WeakMap(), _Formula_tokens = new WeakMap();
26
+ //# sourceMappingURL=formula.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula.js","sourceRoot":"","sources":["../../../src/formulas/helpers/formula.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AASlC,MAAM,OAAO,OAAO;IAInB,YAAY,IAAI;QAHhB,yBAAS,IAAI,KAAK,EAAE,EAAC;QACrB,2BAAoC,IAAI,GAAG,EAAE,EAAC;QAC9C,kCAAiB;QAEhB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QACjF,+EAA+E;QAC/E,MAAM,MAAM,GAAG,uBAAA,IAAI,sBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;QAC3C,uBAAA,IAAI,wBAAS,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC;IACf,CAAC;IAED,UAAU,KAAI,CAAC;CACf"}
@@ -0,0 +1,10 @@
1
+ import { Token } from './token';
2
+ export declare class Lexer {
3
+ private tokenRegex;
4
+ private flattenTokens;
5
+ constructor(flattenTokens?: boolean);
6
+ tokenize(formula: string): Token[];
7
+ private determineTokenType;
8
+ private flatten;
9
+ }
10
+ //# sourceMappingURL=lexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../../../src/formulas/helpers/lexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,qBAAa,KAAK;IACjB,OAAO,CAAC,UAAU,CAA4E;IAC9F,OAAO,CAAC,aAAa,CAAU;gBAEnB,aAAa,GAAE,OAAe;IAI1C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE;IA8ClC,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,OAAO;CAWf"}
@@ -0,0 +1,73 @@
1
+ import { Token } from './token';
2
+ export class Lexer {
3
+ constructor(flattenTokens = false) {
4
+ this.tokenRegex = /\s*(\(|\)|\+|\-|\*|\/|\d+\.\d+|\d+|[A-Za-z_][A-Za-z0-9_]*)\s*/g;
5
+ this.flattenTokens = flattenTokens;
6
+ }
7
+ tokenize(formula) {
8
+ this.tokenRegex.lastIndex = 0;
9
+ const tokens = [];
10
+ const stack = [tokens]; // Stack to manage nested token lists
11
+ let match;
12
+ while ((match = this.tokenRegex.exec(formula)) !== null) {
13
+ const tokenValue = match[1];
14
+ let tokenType = this.determineTokenType(tokenValue);
15
+ if (tokenType === 'parenthesis') {
16
+ if (tokenValue === '(') {
17
+ if (!this.flattenTokens) {
18
+ // Start a new scope for tokens
19
+ stack.push([]);
20
+ }
21
+ }
22
+ else {
23
+ if (!this.flattenTokens) {
24
+ // End the current scope
25
+ const subTokens = stack.pop();
26
+ if (!subTokens) {
27
+ throw new Error('Mismatched parentheses in the formula');
28
+ }
29
+ // Create a parenthesis token with these subtokens as children
30
+ const parentTokens = stack[stack.length - 1];
31
+ parentTokens.push(new Token('parenthesis', '()', null, subTokens));
32
+ }
33
+ }
34
+ }
35
+ else {
36
+ // Add this token to the current scope
37
+ stack[stack.length - 1].push(new Token(tokenType, tokenValue));
38
+ }
39
+ }
40
+ if (stack.length !== 1) {
41
+ throw new Error('Mismatched parentheses in the formula');
42
+ }
43
+ // If flattenTokens is true, flatten all tokens into a single array
44
+ if (this.flattenTokens) {
45
+ return this.flatten(tokens);
46
+ }
47
+ return tokens; // Return the outermost list of tokens
48
+ }
49
+ determineTokenType(value) {
50
+ const operators = {
51
+ '+': 'operator',
52
+ '-': 'operator',
53
+ '*': 'operator',
54
+ '/': 'operator',
55
+ '(': 'parenthesis',
56
+ ')': 'parenthesis',
57
+ };
58
+ return operators[value] || (!isNaN(parseFloat(value)) ? 'number' : 'variable');
59
+ }
60
+ flatten(tokens) {
61
+ const flatList = [];
62
+ for (const token of tokens) {
63
+ if (token.type === 'parenthesis' && token.children) {
64
+ flatList.push(...this.flatten(token.children)); // Flatten nested tokens
65
+ }
66
+ else {
67
+ flatList.push(token);
68
+ }
69
+ }
70
+ return flatList;
71
+ }
72
+ }
73
+ //# sourceMappingURL=lexer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../../src/formulas/helpers/lexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;A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AQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;QACF,CAAC;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD"}
@@ -0,0 +1,24 @@
1
+ import { Token } from './token';
2
+ /**
3
+ * The Parser class is responsible for parsing a sequence of tokens into an abstract syntax tree (AST).
4
+ * The tokens should be an array of objects with `type` and `value` properties.
5
+ *
6
+ * The Parser handles mathematical expressions and ensures that the tokens are in the correct order
7
+ * for later evaluation. It understands variables, numbers, and parentheses, and is extendable to support
8
+ * additional operations and precedence rules.
9
+ *
10
+ * Example usage:
11
+ * ```
12
+ * const tokens: Token[] = [...];
13
+ * const parser = new Parser(tokens);
14
+ * const ast = parser.parse();
15
+ * ```
16
+ */
17
+ export declare class Parser {
18
+ private tokens;
19
+ private currentTokenIndex;
20
+ constructor(tokens: Token[]);
21
+ parse(): Token | undefined;
22
+ private parseExpression;
23
+ }
24
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/formulas/helpers/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAIhC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,MAAM;IAClB,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,MAAM,EAAE,KAAK,EAAE;IAKpB,KAAK,IAAI,KAAK,GAAG,SAAS;IAIjC,OAAO,CAAC,eAAe;CAqBvB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The Parser class is responsible for parsing a sequence of tokens into an abstract syntax tree (AST).
3
+ * The tokens should be an array of objects with `type` and `value` properties.
4
+ *
5
+ * The Parser handles mathematical expressions and ensures that the tokens are in the correct order
6
+ * for later evaluation. It understands variables, numbers, and parentheses, and is extendable to support
7
+ * additional operations and precedence rules.
8
+ *
9
+ * Example usage:
10
+ * ```
11
+ * const tokens: Token[] = [...];
12
+ * const parser = new Parser(tokens);
13
+ * const ast = parser.parse();
14
+ * ```
15
+ */
16
+ export class Parser {
17
+ constructor(tokens) {
18
+ this.tokens = tokens;
19
+ this.currentTokenIndex = 0;
20
+ }
21
+ parse() {
22
+ return this.parseExpression();
23
+ }
24
+ parseExpression() {
25
+ let token = this.tokens[this.currentTokenIndex];
26
+ if (token && token.type === 'variable') {
27
+ this.currentTokenIndex++;
28
+ return token;
29
+ }
30
+ else if (token && token.type === 'number') {
31
+ this.currentTokenIndex++;
32
+ return token;
33
+ }
34
+ else if (token && token.value === '(') {
35
+ this.currentTokenIndex++; // Skip '('
36
+ let expr = this.parseExpression(); // Parse subexpression
37
+ if (this.tokens[this.currentTokenIndex] && this.tokens[this.currentTokenIndex].value === ')') {
38
+ this.currentTokenIndex++; // Skip ')'
39
+ return expr;
40
+ }
41
+ }
42
+ // TODO: Add cases for parsing different operations (like addition, multiplication etc.)
43
+ // TODO: Implement precedence handling for different operations
44
+ // This function should be extended to fully construct the AST.
45
+ return undefined;
46
+ }
47
+ }
48
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/formulas/helpers/parser.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,MAAM;IAIlB,YAAY,MAAe;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEM,KAAK;QACX,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAC/B,CAAC;IAEO,eAAe;QACtB,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAChD,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACxC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACd,CAAC;aAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7C,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACd,CAAC;aAAM,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,GAAG,EAAE,CAAC;YACzC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,WAAW;YACrC,IAAI,IAAI,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,sBAAsB;YACzD,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,KAAK,KAAK,GAAG,EAAE,CAAC;gBAC9F,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,WAAW;gBACrC,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;QACD,wFAAwF;QACxF,+DAA+D;QAC/D,+DAA+D;QAC/D,OAAO,SAAS,CAAC;IAClB,CAAC;CACD"}
@@ -0,0 +1,14 @@
1
+ import { TokenType } from '../types';
2
+ /**
3
+ * The Token class now includes a stringValue property for storing the original string value
4
+ * of the expression inside the parentheses and an optional parent property for storing the parent token.
5
+ */
6
+ export declare class Token {
7
+ type: TokenType;
8
+ value: string;
9
+ stringValue?: string;
10
+ children?: Token[];
11
+ parent?: Token;
12
+ constructor(type: TokenType, value: string, stringValue?: string, children?: Token[], parent?: Token);
13
+ }
14
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/formulas/helpers/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;;GAGG;AACH,qBAAa,KAAK;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,KAAK,CAAC;gBAEH,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC,EAAE,KAAK;CAOpG"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The Token class now includes a stringValue property for storing the original string value
3
+ * of the expression inside the parentheses and an optional parent property for storing the parent token.
4
+ */
5
+ export class Token {
6
+ constructor(type, value, stringValue, children, parent) {
7
+ this.type = type;
8
+ this.value = value;
9
+ this.stringValue = stringValue;
10
+ this.children = children;
11
+ this.parent = parent;
12
+ }
13
+ }
14
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../../../src/formulas/helpers/token.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,KAAK;IAOjB,YAAY,IAAe,EAAE,KAAa,EAAE,WAAoB,EAAE,QAAkB,EAAE,MAAc;QACnG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD"}
@@ -0,0 +1,59 @@
1
+ import { ReactiveModel } from '@beyond-js/reactive/model';
2
+ import { Parser } from './helpers/parser';
3
+ import { Token } from './helpers/token';
4
+ import { IComplexCondition, FormulaFields } from './types/formulas';
5
+ type ParserData = {
6
+ parser: Parser;
7
+ tokens: Token[];
8
+ [key: string]: any;
9
+ };
10
+ export declare class FormulaManager extends ReactiveModel<FormulaManager> {
11
+ #private;
12
+ get tokens(): Token[];
13
+ get parser(): Parser;
14
+ get formula(): string | IComplexCondition;
15
+ get name(): string;
16
+ get conditional(): boolean;
17
+ get conditions(): import("./types/formulas").IConditionalField | import("./types/formulas").IConditionalField[];
18
+ /**
19
+ * Represents the fields defined in the plugin settings
20
+ */
21
+ get fields(): string[];
22
+ get parsedBase(): any;
23
+ get type(): string;
24
+ get base(): string;
25
+ get variables(): string[];
26
+ get value(): any;
27
+ constructor(plugin: any, specs: any);
28
+ initialize(): void;
29
+ /**
30
+ * Returns the models that are part of the formula
31
+ * The models could be fields or formulas
32
+ * @param variables
33
+ * @returns
34
+ */
35
+ getModels(variables: FormulaFields): any[];
36
+ private getType;
37
+ processConditional(): void;
38
+ calculate(): void;
39
+ /**
40
+ * Returns the parser for the formula, if the parser is already created it will return the memoized parser
41
+ *
42
+ *
43
+ * The formula is tokenized and parsed to create a parser instance
44
+ * the object returned contains the tokens, the parser and the formula
45
+ * @param data Receives the formula to be parsed
46
+ * @returns
47
+ */
48
+ getParser(data: any): ParserData;
49
+ getParams(variables: string[]): Promise<{}>;
50
+ /**
51
+ * A form can have multiple formulas, this method will create an instance of the formula manager
52
+ * and memoize it to avoid creating multiple instances of the same formula.
53
+ * @param specs
54
+ * @returns
55
+ */
56
+ static create(plugin: any, specs: any): Promise<FormulaManager>;
57
+ }
58
+ export {};
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formulas/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAqD,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOvH,KAAK,UAAU,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB,CAAC;AACF,qBAAa,cAAe,SAAQ,aAAa,CAAC,cAAc,CAAC;;IAIhE,IAAI,MAAM,YAET;IAED,IAAI,MAAM,WAET;IAGD,IAAI,OAAO,+BAEV;IACD,IAAI,IAAI,WAEP;IAED,IAAI,WAAW,YAEd;IAED,IAAI,UAAU,kGAIb;IAED;;OAEG;IACH,IAAI,MAAM,aAGT;IAGD,IAAI,UAAU,QAEb;IAED,IAAI,IAAI,WAEP;IAED,IAAI,IAAI,WAGP;IAGD,IAAI,SAAS,aAEZ;IAED,IAAI,KAAK,QAER;gBAMW,MAAM,KAAA,EAAE,KAAK,KAAA;IA0BzB,UAAU;IAGV;;;;;OAKG;IACH,SAAS,CAAC,SAAS,EAAE,aAAa;IAQlC,OAAO,CAAC,OAAO;IAOf,kBAAkB;IAMlB,SAAS;IAST;;;;;;;;OAQG;IACH,SAAS,CAAC,IAAI,KAAA,GAAG,UAAU;IAWrB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE;IAkBnC;;;;;OAKG;WACU,MAAM,CAAC,MAAM,KAAA,EAAE,KAAK,KAAA;CAKjC"}