@sankhyalabs/ezui 1.2.0-beta.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/dist/cjs/{ApplicationUtils-2ac1b73e.js → ApplicationUtils-edc62c5c.js} +4 -1
  2. package/dist/cjs/CheckMode-ecb90b87.js +7 -0
  3. package/dist/cjs/{DialogType-a1e288e6.js → DialogType-aa435c52.js} +1 -0
  4. package/dist/cjs/ez-actions-button.cjs.entry.js +68 -17
  5. package/dist/cjs/ez-application.cjs.entry.js +1 -1
  6. package/dist/cjs/ez-button.cjs.entry.js +13 -11
  7. package/dist/cjs/ez-calendar.cjs.entry.js +5 -5
  8. package/dist/cjs/ez-card-item.cjs.entry.js +1 -1
  9. package/dist/cjs/ez-check.cjs.entry.js +11 -9
  10. package/dist/cjs/ez-chip.cjs.entry.js +17 -7
  11. package/dist/cjs/ez-collapsible-box.cjs.entry.js +85 -7
  12. package/dist/cjs/ez-combo-box.cjs.entry.js +51 -20
  13. package/dist/cjs/ez-date-input.cjs.entry.js +13 -18
  14. package/dist/cjs/ez-date-time-input.cjs.entry.js +12 -17
  15. package/dist/cjs/ez-dialog.cjs.entry.js +43 -8
  16. package/dist/cjs/ez-filter-input.cjs.entry.js +1 -1
  17. package/dist/cjs/ez-form.cjs.entry.js +99 -486
  18. package/dist/cjs/ez-grid-config.cjs.entry.js +8 -9
  19. package/dist/cjs/ez-grid.cjs.entry.js +1073 -1168
  20. package/dist/cjs/ez-icon.cjs.entry.js +3 -3
  21. package/dist/cjs/ez-list.cjs.entry.js +2 -4
  22. package/dist/cjs/ez-loading-bar.cjs.entry.js +1 -1
  23. package/dist/cjs/ez-modal-container.cjs.entry.js +58 -0
  24. package/dist/cjs/ez-modal.cjs.entry.js +1 -1
  25. package/dist/cjs/ez-number-input.cjs.entry.js +4 -4
  26. package/dist/cjs/ez-popover.cjs.entry.js +6 -6
  27. package/dist/cjs/ez-popup.cjs.entry.js +8 -4
  28. package/dist/cjs/ez-radio-button.cjs.entry.js +3 -3
  29. package/dist/cjs/ez-scroller.cjs.entry.js +2 -2
  30. package/dist/cjs/ez-search.cjs.entry.js +1 -1
  31. package/dist/cjs/ez-select-box.cjs.entry.js +1 -1
  32. package/dist/cjs/ez-tabselector.cjs.entry.js +8 -7
  33. package/dist/cjs/ez-text-area.cjs.entry.js +7 -7
  34. package/dist/cjs/ez-text-edit.cjs.entry.js +103 -0
  35. package/dist/cjs/ez-text-input.cjs.entry.js +14 -4
  36. package/dist/cjs/ez-time-input.cjs.entry.js +7 -7
  37. package/dist/cjs/ez-toast.cjs.entry.js +2 -2
  38. package/dist/cjs/ez-upload.cjs.entry.js +4 -4
  39. package/dist/cjs/ez-view-stack.cjs.entry.js +10 -7
  40. package/dist/cjs/ezui.cjs.js +4 -112
  41. package/dist/cjs/loader.cjs.js +2 -18
  42. package/dist/collection/collection-manifest.json +2 -0
  43. package/dist/collection/components/ez-actions-button/ez-actions-button.css +49 -20
  44. package/dist/collection/components/ez-actions-button/ez-actions-button.js +219 -23
  45. package/dist/collection/components/ez-button/ez-button.css +0 -6
  46. package/dist/collection/components/ez-button/ez-button.js +11 -9
  47. package/dist/collection/components/ez-calendar/ez-calendar.css +17 -20
  48. package/dist/collection/components/ez-check/CheckMode.js +5 -0
  49. package/dist/collection/components/ez-check/ez-check.css +23 -24
  50. package/dist/collection/components/ez-check/ez-check.js +10 -8
  51. package/dist/collection/components/ez-chip/ez-chip.css +4 -2
  52. package/dist/collection/components/ez-chip/ez-chip.js +16 -6
  53. package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +16 -0
  54. package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.js +226 -7
  55. package/dist/collection/components/ez-combo-box/ez-combo-box.css +1 -22
  56. package/dist/collection/components/ez-combo-box/ez-combo-box.js +51 -20
  57. package/dist/collection/components/ez-date-input/ez-date-input.js +8 -13
  58. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +8 -13
  59. package/dist/collection/components/ez-dialog/DialogType.js +1 -0
  60. package/dist/collection/components/ez-dialog/ez-dialog.css +19 -25
  61. package/dist/collection/components/ez-dialog/ez-dialog.js +41 -6
  62. package/dist/collection/components/ez-form/DataBinder.js +1 -0
  63. package/dist/collection/components/ez-form/ez-form.js +22 -13
  64. package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +3 -3
  65. package/dist/collection/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.js +2 -1
  66. package/dist/collection/components/ez-form/fieldbuilder/tpl/DateInput.tpl.js +4 -4
  67. package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +25 -15
  68. package/dist/collection/components/ez-grid/controller/DataUnitBridge.js +3 -0
  69. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +51 -15
  70. package/dist/collection/components/ez-grid/controller/ag-grid/components/cellRenderer.js +31 -0
  71. package/dist/collection/components/ez-grid/ez-grid.js +40 -3
  72. package/dist/collection/components/ez-grid/subcomponents/ez-grid-config/ez-grid-config.css +38 -27
  73. package/dist/collection/components/ez-grid/subcomponents/ez-grid-config/ez-grid-config.js +1 -2
  74. package/dist/collection/components/ez-grid/subcomponents/ez-select-box/ez-select-box.js +5 -4
  75. package/dist/collection/components/ez-list/ez-list.css +12 -4
  76. package/dist/collection/components/ez-modal-container/ez-modal-container.css +38 -0
  77. package/dist/collection/components/ez-modal-container/ez-modal-container.js +190 -0
  78. package/dist/collection/components/ez-modal-container/index.js +2 -0
  79. package/dist/collection/components/ez-modal-container/modal-action.js +8 -0
  80. package/dist/collection/components/ez-modal-container/modal-button-status.js +7 -0
  81. package/dist/collection/components/ez-popover/ez-popover.css +1 -1
  82. package/dist/collection/components/ez-popup/ez-popup.css +6 -1
  83. package/dist/collection/components/ez-popup/ez-popup.js +26 -4
  84. package/dist/collection/components/ez-radio-button/ez-radio-button.css +16 -5
  85. package/dist/collection/components/ez-radio-button/ez-radio-button.js +1 -1
  86. package/dist/collection/components/ez-scroller/ez-scroller.css +3 -2
  87. package/dist/collection/components/ez-search/ez-search.js +6 -6
  88. package/dist/collection/components/ez-tabselector/ez-tabselector.css +10 -1
  89. package/dist/collection/components/ez-tabselector/ez-tabselector.js +7 -3
  90. package/dist/collection/components/ez-text-area/ez-text-area.css +6 -3
  91. package/dist/collection/components/ez-text-area/ez-text-area.js +5 -5
  92. package/dist/collection/components/ez-text-edit/ez-text-edit.css +19 -0
  93. package/dist/collection/components/ez-text-edit/ez-text-edit.js +188 -0
  94. package/dist/collection/components/ez-text-input/ez-text-input.css +18 -2
  95. package/dist/collection/components/ez-text-input/ez-text-input.js +28 -0
  96. package/dist/collection/components/ez-toast/ez-toast.css +1 -1
  97. package/dist/collection/components/ez-upload/ez-upload.css +1 -1
  98. package/dist/collection/components/ez-view-stack/ez-view-stack.js +12 -6
  99. package/dist/collection/utils/ApplicationUtils.js +3 -0
  100. package/dist/collection/utils/index.js +1 -0
  101. package/dist/custom-elements/index.d.ts +12 -0
  102. package/dist/custom-elements/index.js +1595 -4005
  103. package/dist/{ezui/ApplicationUtils-30a69eb0.js → esm/ApplicationUtils-205ac4bc.js} +4 -2
  104. package/dist/esm/CheckMode-bdb2ec19.js +7 -0
  105. package/dist/esm/{DialogType-72afa679.js → DialogType-4059dc4d.js} +1 -0
  106. package/dist/esm/ez-actions-button.entry.js +68 -17
  107. package/dist/esm/ez-application.entry.js +1 -1
  108. package/dist/esm/ez-button.entry.js +13 -11
  109. package/dist/esm/ez-calendar.entry.js +3 -3
  110. package/dist/esm/ez-card-item.entry.js +1 -1
  111. package/dist/esm/ez-check.entry.js +11 -9
  112. package/dist/esm/ez-chip.entry.js +17 -7
  113. package/dist/esm/ez-collapsible-box.entry.js +85 -7
  114. package/dist/esm/ez-combo-box.entry.js +48 -17
  115. package/dist/esm/ez-date-input.entry.js +10 -15
  116. package/dist/esm/ez-date-time-input.entry.js +10 -15
  117. package/dist/esm/ez-dialog.entry.js +43 -8
  118. package/dist/esm/ez-filter-input.entry.js +1 -1
  119. package/dist/esm/ez-form.entry.js +65 -452
  120. package/dist/esm/ez-grid-config.entry.js +6 -7
  121. package/dist/esm/ez-grid.entry.js +1039 -1134
  122. package/dist/esm/ez-icon.entry.js +2 -2
  123. package/dist/esm/ez-list.entry.js +2 -4
  124. package/dist/esm/ez-loading-bar.entry.js +1 -1
  125. package/dist/esm/ez-modal-container.entry.js +54 -0
  126. package/dist/esm/ez-modal.entry.js +1 -1
  127. package/dist/esm/ez-number-input.entry.js +2 -2
  128. package/dist/esm/ez-popover.entry.js +3 -3
  129. package/dist/esm/ez-popup.entry.js +8 -4
  130. package/dist/esm/ez-radio-button.entry.js +3 -3
  131. package/dist/esm/ez-scroller.entry.js +2 -2
  132. package/dist/esm/ez-search.entry.js +1 -1
  133. package/dist/esm/ez-select-box.entry.js +1 -1
  134. package/dist/esm/ez-tabselector.entry.js +8 -7
  135. package/dist/esm/ez-text-area.entry.js +7 -7
  136. package/dist/esm/ez-text-edit.entry.js +99 -0
  137. package/dist/esm/ez-text-input.entry.js +13 -3
  138. package/dist/esm/ez-time-input.entry.js +2 -2
  139. package/dist/esm/ez-toast.entry.js +2 -2
  140. package/dist/esm/ez-upload.entry.js +4 -4
  141. package/dist/esm/ez-view-stack.entry.js +10 -7
  142. package/dist/esm/ezui.js +4 -112
  143. package/dist/esm/loader.js +2 -18
  144. package/dist/ezui/ezui.esm.js +1 -125
  145. package/dist/ezui/index.esm.js +0 -1
  146. package/dist/ezui/p-04a41a44.entry.js +1 -0
  147. package/dist/ezui/p-0b44cf1c.js +1 -0
  148. package/dist/ezui/p-0c7203d5.entry.js +1 -0
  149. package/dist/ezui/p-2213da1f.entry.js +1 -0
  150. package/dist/ezui/p-2c6398b3.entry.js +1 -0
  151. package/dist/ezui/p-2ccad880.entry.js +1 -0
  152. package/dist/ezui/p-333d79c4.entry.js +1 -0
  153. package/dist/ezui/p-3987f8d8.entry.js +1 -0
  154. package/dist/ezui/{p-81eb2738.entry.js → p-42c6493e.entry.js} +1 -1
  155. package/dist/ezui/{p-b4ad3b15.entry.js → p-482c3dd8.entry.js} +1 -1
  156. package/dist/ezui/p-5bdb1a41.entry.js +1 -0
  157. package/dist/ezui/{p-b2cf7db2.entry.js → p-63d567cc.entry.js} +1 -1
  158. package/dist/ezui/p-659616e4.entry.js +1 -0
  159. package/dist/ezui/p-6608b9a5.entry.js +1 -0
  160. package/dist/ezui/p-77ec47ac.entry.js +1 -0
  161. package/dist/ezui/p-9b9ebf95.entry.js +1 -0
  162. package/dist/ezui/{p-88bfdea4.entry.js → p-ae5af8f9.entry.js} +1 -1
  163. package/dist/ezui/p-b853763b.js +1 -0
  164. package/dist/ezui/p-be06251d.entry.js +1 -0
  165. package/dist/ezui/{p-e7d03a0d.entry.js → p-bffae598.entry.js} +1 -1
  166. package/dist/ezui/p-cd4677d4.entry.js +1 -0
  167. package/dist/ezui/p-cfcc23e6.entry.js +1 -0
  168. package/dist/ezui/p-dfcf55e0.entry.js +1 -0
  169. package/dist/ezui/p-e1148f5c.js +1 -0
  170. package/dist/ezui/p-e1f2b5da.entry.js +1 -0
  171. package/dist/ezui/p-e230bfd2.entry.js +1 -0
  172. package/dist/ezui/{p-867aac16.entry.js → p-e3ee814c.entry.js} +1 -1
  173. package/dist/ezui/p-e697ffd5.entry.js +1 -0
  174. package/dist/ezui/{p-4eb273f8.entry.js → p-efa32bcc.entry.js} +1 -1
  175. package/dist/types/components/ez-actions-button/ez-actions-button.d.ts +42 -9
  176. package/dist/types/components/ez-check/CheckMode.d.ts +4 -0
  177. package/dist/types/components/ez-chip/ez-chip.d.ts +2 -1
  178. package/dist/types/components/ez-collapsible-box/ez-collapsible-box.d.ts +46 -1
  179. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +15 -5
  180. package/dist/types/components/ez-date-input/ez-date-input.d.ts +0 -1
  181. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +0 -1
  182. package/dist/types/components/ez-dialog/DialogType.d.ts +1 -0
  183. package/dist/types/components/ez-dialog/ez-dialog.d.ts +3 -0
  184. package/dist/types/components/ez-form/DataBinder.d.ts +2 -2
  185. package/dist/types/components/ez-form/ez-form.d.ts +21 -11
  186. package/dist/types/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.d.ts +3 -3
  187. package/dist/types/components/ez-form/fieldbuilder/tpl/DateInput.tpl.d.ts +4 -2
  188. package/dist/types/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.d.ts +2 -5
  189. package/dist/types/components/ez-form/structure/FormSheetMetadata.d.ts +3 -3
  190. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +11 -0
  191. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -1
  192. package/dist/types/components/ez-grid/controller/ag-grid/components/cellRenderer.d.ts +9 -0
  193. package/dist/types/components/ez-grid/ez-grid.d.ts +8 -3
  194. package/dist/types/components/ez-grid/subcomponents/ez-select-box/ez-select-box.d.ts +2 -6
  195. package/dist/types/components/ez-modal-container/ez-modal-container.d.ts +47 -0
  196. package/dist/types/components/ez-modal-container/index.d.ts +2 -0
  197. package/dist/types/components/ez-modal-container/modal-action.d.ts +7 -0
  198. package/dist/types/components/ez-modal-container/modal-button-status.d.ts +6 -0
  199. package/dist/types/components/ez-popup/ez-popup.d.ts +4 -0
  200. package/dist/types/components/ez-search/ez-search.d.ts +3 -3
  201. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +2 -0
  202. package/dist/types/components/ez-text-edit/ez-text-edit.d.ts +39 -0
  203. package/dist/types/components/ez-text-input/ez-text-input.d.ts +5 -0
  204. package/dist/types/components/ez-view-stack/ez-view-stack.d.ts +5 -1
  205. package/dist/types/components.d.ts +274 -28
  206. package/dist/types/utils/ApplicationUtils.d.ts +1 -0
  207. package/dist/types/utils/index.d.ts +1 -0
  208. package/package.json +5 -5
  209. package/react/components.d.ts +2 -0
  210. package/react/components.js +2 -0
  211. package/react/components.js.map +1 -1
  212. package/dist/cjs/ApplicationUtils-475b50d9.js +0 -63
  213. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  214. package/dist/cjs/css-shim-3bfdba4f.js +0 -6
  215. package/dist/cjs/dom-8ac1ad03.js +0 -75
  216. package/dist/cjs/index-2ec1da82.js +0 -2307
  217. package/dist/cjs/index-55178184.js +0 -6
  218. package/dist/cjs/index-d9c5cb88.js +0 -3068
  219. package/dist/cjs/shadow-css-41d9783d.js +0 -390
  220. package/dist/esm/ApplicationUtils-30a69eb0.js +0 -61
  221. package/dist/esm/ApplicationUtils-a4a76132.js +0 -60
  222. package/dist/esm/app-globals-0f993ce5.js +0 -3
  223. package/dist/esm/css-shim-20dbffa5.js +0 -4
  224. package/dist/esm/dom-c5ed0ba5.js +0 -73
  225. package/dist/esm/index-1e9d524f.js +0 -3031
  226. package/dist/esm/index-b96183c8.js +0 -2295
  227. package/dist/esm/index-f32470b5.js +0 -3
  228. package/dist/esm/shadow-css-8c625855.js +0 -388
  229. package/dist/ezui/CSSVarsUtils-00f67f32.js +0 -70
  230. package/dist/ezui/DialogType-72afa679.js +0 -8
  231. package/dist/ezui/app-globals-0f993ce5.js +0 -3
  232. package/dist/ezui/css-shim-20dbffa5.js +0 -4
  233. package/dist/ezui/dom-c5ed0ba5.js +0 -73
  234. package/dist/ezui/ez-actions-button.entry.js +0 -98
  235. package/dist/ezui/ez-application.entry.js +0 -22
  236. package/dist/ezui/ez-button.entry.js +0 -73
  237. package/dist/ezui/ez-calendar.entry.js +0 -219
  238. package/dist/ezui/ez-card-item.entry.js +0 -40
  239. package/dist/ezui/ez-check.entry.js +0 -72
  240. package/dist/ezui/ez-chip.entry.js +0 -97
  241. package/dist/ezui/ez-collapsible-box.entry.js +0 -57
  242. package/dist/ezui/ez-combo-box.entry.js +0 -439
  243. package/dist/ezui/ez-date-input.entry.js +0 -159
  244. package/dist/ezui/ez-date-time-input.entry.js +0 -214
  245. package/dist/ezui/ez-dialog.entry.js +0 -108
  246. package/dist/ezui/ez-filter-input.entry.js +0 -75
  247. package/dist/ezui/ez-form.entry.js +0 -1395
  248. package/dist/ezui/ez-grid-config.entry.js +0 -433
  249. package/dist/ezui/ez-grid.entry.js +0 -115419
  250. package/dist/ezui/ez-icon.entry.js +0 -37
  251. package/dist/ezui/ez-list.entry.js +0 -516
  252. package/dist/ezui/ez-loading-bar.entry.js +0 -24
  253. package/dist/ezui/ez-modal.entry.js +0 -67
  254. package/dist/ezui/ez-number-input.entry.js +0 -148
  255. package/dist/ezui/ez-popover.entry.js +0 -141
  256. package/dist/ezui/ez-popup.entry.js +0 -49
  257. package/dist/ezui/ez-radio-button.entry.js +0 -45
  258. package/dist/ezui/ez-scroller.entry.js +0 -101
  259. package/dist/ezui/ez-search.entry.js +0 -83
  260. package/dist/ezui/ez-select-box.entry.js +0 -18
  261. package/dist/ezui/ez-tabselector.entry.js +0 -195
  262. package/dist/ezui/ez-text-area.entry.js +0 -158
  263. package/dist/ezui/ez-text-input.entry.js +0 -235
  264. package/dist/ezui/ez-time-input.entry.js +0 -164
  265. package/dist/ezui/ez-toast.entry.js +0 -84
  266. package/dist/ezui/ez-upload.entry.js +0 -379
  267. package/dist/ezui/ez-view-stack.entry.js +0 -74
  268. package/dist/ezui/index-1e9d524f.js +0 -3031
  269. package/dist/ezui/index-b96183c8.js +0 -2295
  270. package/dist/ezui/index-f32470b5.js +0 -3
  271. package/dist/ezui/p-2f02347d.entry.js +0 -1
  272. package/dist/ezui/p-416bedbe.entry.js +0 -1
  273. package/dist/ezui/p-544f0c63.entry.js +0 -1
  274. package/dist/ezui/p-62110996.entry.js +0 -1
  275. package/dist/ezui/p-719e9ef9.entry.js +0 -1
  276. package/dist/ezui/p-787fbdfe.js +0 -1
  277. package/dist/ezui/p-9d5be6a7.entry.js +0 -1
  278. package/dist/ezui/p-a27dafa4.entry.js +0 -1
  279. package/dist/ezui/p-aba3fa6c.entry.js +0 -1
  280. package/dist/ezui/p-adbe4188.js +0 -1
  281. package/dist/ezui/p-af43be42.entry.js +0 -1
  282. package/dist/ezui/p-b7467ad6.entry.js +0 -1
  283. package/dist/ezui/p-c019e137.entry.js +0 -1
  284. package/dist/ezui/p-c9d2060e.entry.js +0 -1
  285. package/dist/ezui/p-cccd8cde.entry.js +0 -1
  286. package/dist/ezui/p-d0671e14.entry.js +0 -1
  287. package/dist/ezui/p-e0f06d73.entry.js +0 -1
  288. package/dist/ezui/p-e59adce6.entry.js +0 -1
  289. package/dist/ezui/p-ed835b36.entry.js +0 -1
  290. package/dist/ezui/shadow-css-8c625855.js +0 -388
@@ -1,1395 +0,0 @@
1
- import { h, r as registerInstance, e as createEvent, i as forceUpdate, f as Host, g as getElement } from './index-1e9d524f.js';
2
- import { U as UserInterface, A as Action, W as WaitingChangeException, a as ApplicationContext, D as DataUnitAction, b as DataUnit } from './index-b96183c8.js';
3
- import { A as ApplicationUtils } from './ApplicationUtils-30a69eb0.js';
4
- import './DialogType-72afa679.js';
5
-
6
- const buildTextArea = ({ name, label, readOnly }) => {
7
- return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small", key: name },
8
- h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
9
- };
10
-
11
- const buildTextInput = ({ name, label, readOnly }) => {
12
- return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
13
- h("ez-text-input", { label: label, "data-field-name": name, key: name, enabled: !readOnly })));
14
- };
15
-
16
- const buildSwitch = (fieldConfig) => {
17
- return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, true);
18
- };
19
- const buildCheckBox = (fieldConfig) => {
20
- return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, false);
21
- };
22
- function buildField$1(fieldName, fieldLabel, readOnly, switchMode = false) {
23
- return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large" },
24
- h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? "switch" : "regular", "data-field-name": fieldName, key: fieldName })));
25
- }
26
-
27
- const buildComboBox = ({ name, label, readOnly, required }, properties) => {
28
- const prop = properties === null || properties === void 0 ? void 0 : properties.options;
29
- let options;
30
- if (typeof prop === "string") {
31
- const parsed = JSON.parse(prop);
32
- options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
33
- }
34
- else {
35
- options = prop;
36
- }
37
- return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
38
- h("ez-combo-box", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name, options: options })));
39
- };
40
-
41
- const buildSearch = ({ name, label, readOnly, required }) => {
42
- return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
43
- h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name })));
44
- };
45
-
46
- const buildFile = ({ name, label, readOnly }) => {
47
- return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
48
- h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
49
- };
50
-
51
- const buildDate = ({ name, label, readOnly }) => {
52
- return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
53
- h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
54
- };
55
- const buildTime = ({ name, label }) => {
56
- return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
57
- h("ez-time-input", { label: label, "data-field-name": name, key: name })));
58
- };
59
- const buildTimeDate = ({ name, label }) => {
60
- return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
61
- h("ez-date-time-input", { label: label, "data-field-name": name, key: name })));
62
- };
63
-
64
- const buildDecimal = ({ name, label, readOnly }, properties) => {
65
- const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
66
- const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
67
- return buildNumeric(name, label, readOnly, precision, prettyPrecision);
68
- };
69
- const buildInteger = ({ name, label, readOnly }) => {
70
- return buildNumeric(name, label, readOnly, 0, 0);
71
- };
72
- function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
73
- return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
74
- h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
75
- }
76
-
77
- const uiBuilders = new Map();
78
- uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
79
- uiBuilders.set(UserInterface.CHECKBOX, buildCheckBox);
80
- uiBuilders.set(UserInterface.SWITCH, buildSwitch);
81
- uiBuilders.set(UserInterface.OPTIONSELECTOR, buildComboBox);
82
- uiBuilders.set(UserInterface.SEARCH, buildSearch);
83
- uiBuilders.set(UserInterface.FILE, buildFile);
84
- uiBuilders.set(UserInterface.DATE, buildDate);
85
- uiBuilders.set(UserInterface.TIME, buildTime);
86
- uiBuilders.set(UserInterface.DATETIME, buildTimeDate);
87
- uiBuilders.set(UserInterface.DECIMALNUMBER, buildDecimal);
88
- uiBuilders.set(UserInterface.INTEGERNUMBER, buildInteger);
89
- const buildField = (field) => {
90
- const descriptor = field.descriptor;
91
- const config = Object.assign({}, field.config);
92
- let builder;
93
- let props;
94
- if (descriptor) {
95
- if (!config.label) {
96
- config.label = descriptor.label;
97
- }
98
- if (!config.name) {
99
- config.name = descriptor.name;
100
- }
101
- if (config.required === undefined) {
102
- config.required = descriptor.required;
103
- }
104
- if (config.readOnly === undefined) {
105
- config.readOnly = descriptor.readOnly;
106
- }
107
- props = descriptor.properties;
108
- builder = uiBuilders.get(descriptor.userInterface);
109
- }
110
- if (config.required) {
111
- config.label = `* ${config.label} (obrigatório)`;
112
- }
113
- if (!builder) {
114
- builder = buildTextInput;
115
- }
116
- return builder(config, props);
117
- };
118
-
119
- const FormItem = ({ source }) => {
120
- if ("items" in source) {
121
- const fieldSet = source;
122
- return h("ez-collapsible-box", { label: source.label, "header-size": "large" }, fieldSet.items.map(fi => buildField(fi)));
123
- }
124
- else {
125
- return buildField(source);
126
- }
127
- };
128
-
129
- const FormSheet = ({ store, source }) => {
130
- return (h("div", { class: "dynamic-content ez-box__container" },
131
- h("div", { class: "ez-row ez-padding-vertical--small" }, source.items.map(item => h(FormItem, { store: store, source: item })))));
132
- };
133
-
134
- class FormMetadata {
135
- constructor() {
136
- this._sheets = new Map();
137
- this._requiredFields = [];
138
- this._cleanOnCopyFields = [];
139
- this._defaultValues = {};
140
- }
141
- getSheet(name) {
142
- return this._sheets.get(name);
143
- }
144
- getAllSheets() {
145
- return this._sheets;
146
- }
147
- addSheet(sheet) {
148
- this._sheets.set(sheet.name, sheet);
149
- this._requiredFields = this._requiredFields.concat(sheet.requiredFields);
150
- this._cleanOnCopyFields = this._cleanOnCopyFields.concat(sheet.cleanOnCopyFields);
151
- this._defaultValues = sheet.defaultValues;
152
- }
153
- getRequiredFields() {
154
- return this._requiredFields;
155
- }
156
- getCleanOnCopyFields() {
157
- return this._cleanOnCopyFields;
158
- }
159
- getDefaultValues() {
160
- return this._defaultValues;
161
- }
162
- }
163
- const buildFromDataUnit = (dataUnit) => {
164
- var _a;
165
- const unitMD = dataUnit.metadata;
166
- const metadata = new FormMetadata();
167
- if (unitMD) {
168
- const visibleFields = (_a = unitMD.fields) === null || _a === void 0 ? void 0 : _a.filter(descriptor => descriptor.visible !== false);
169
- let defaultValues = {};
170
- visibleFields
171
- .filter(descriptor => descriptor.defaultValue)
172
- .map((descriptor) => defaultValues[descriptor.name] = descriptor.defaultValue);
173
- metadata.addSheet({
174
- label: unitMD.label,
175
- name: unitMD.name,
176
- items: visibleFields.map(descriptor => { return { descriptor }; }),
177
- requiredFields: visibleFields
178
- .filter(descriptor => descriptor.required)
179
- .map(descriptor => descriptor.name),
180
- cleanOnCopyFields: visibleFields
181
- .filter(descriptor => { var _a, _b; return ((_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy) || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum); })
182
- .map(descriptor => descriptor.name),
183
- defaultValues
184
- });
185
- }
186
- return metadata;
187
- };
188
- function getTabConfig(tab, sheets) {
189
- const tabConfig = (typeof tab === "string" ? Array.from(sheets.keys()).find(t => t.label === tab) : tab);
190
- return tabConfig || { label: tab, visible: true };
191
- }
192
- function sortTabs(a, b) {
193
- return a[0].label == '__main' ? -1 : (a[0].order || 10000) - (b[0].order || 10000);
194
- }
195
- const buildFromConfig = (fields, dataUnit) => {
196
- const sheets = new Map();
197
- const requiredFields = [];
198
- const cleanOnCopyFields = [];
199
- const defaultValues = {};
200
- fields.forEach(config => {
201
- var _a, _b, _c;
202
- if (config.visible !== false) {
203
- const tabConfig = getTabConfig(config.tab || "__main", sheets);
204
- const descriptor = dataUnit.getField(config.name);
205
- if (descriptor && tabConfig.visible) {
206
- if (!sheets.has(tabConfig)) {
207
- sheets.set(tabConfig, new Map());
208
- }
209
- const tabItens = sheets.get(tabConfig);
210
- const isRequired = config.required === undefined ? descriptor.required : config.required;
211
- if (isRequired) {
212
- requiredFields.push(config.name);
213
- }
214
- const clearOnCopy = config.cleanOnCopy === undefined ? (((_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy) || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum)) : config.cleanOnCopy;
215
- if (clearOnCopy) {
216
- cleanOnCopyFields.push(config.name);
217
- }
218
- const defaultValue = config.defaultValue === undefined ? (_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.defaultValue : config.defaultValue;
219
- if (defaultValue) {
220
- defaultValues[config.name] = config.defaultValue;
221
- }
222
- const fieldMD = { config, descriptor };
223
- const group = config.group;
224
- if (group) {
225
- const key = `group::${group}`;
226
- if (!tabItens.has(key)) {
227
- tabItens.set(key, { label: group, items: [fieldMD] });
228
- }
229
- else {
230
- tabItens.get(key).items.push(fieldMD);
231
- }
232
- }
233
- else {
234
- tabItens.set(config.name, fieldMD);
235
- }
236
- }
237
- }
238
- });
239
- const metadata = new FormMetadata();
240
- Array.from(sheets.entries())
241
- .sort(sortTabs)
242
- .forEach(([key, value]) => {
243
- metadata.addSheet({
244
- label: (key.label === "__main") ? "Principal" : key.label,
245
- name: key.label,
246
- items: Array.from(value.values()),
247
- requiredFields,
248
- cleanOnCopyFields,
249
- defaultValues
250
- });
251
- });
252
- return metadata;
253
- };
254
-
255
- function _defineProperty(obj, key, value) {
256
- if (key in obj) {
257
- Object.defineProperty(obj, key, {
258
- value: value,
259
- enumerable: true,
260
- configurable: true,
261
- writable: true
262
- });
263
- } else {
264
- obj[key] = value;
265
- }
266
-
267
- return obj;
268
- }
269
-
270
- function ownKeys(object, enumerableOnly) {
271
- var keys = Object.keys(object);
272
-
273
- if (Object.getOwnPropertySymbols) {
274
- var symbols = Object.getOwnPropertySymbols(object);
275
-
276
- if (enumerableOnly) {
277
- symbols = symbols.filter(function (sym) {
278
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
279
- });
280
- }
281
-
282
- keys.push.apply(keys, symbols);
283
- }
284
-
285
- return keys;
286
- }
287
-
288
- function _objectSpread2(target) {
289
- for (var i = 1; i < arguments.length; i++) {
290
- var source = arguments[i] != null ? arguments[i] : {};
291
-
292
- if (i % 2) {
293
- ownKeys(Object(source), true).forEach(function (key) {
294
- _defineProperty(target, key, source[key]);
295
- });
296
- } else if (Object.getOwnPropertyDescriptors) {
297
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
298
- } else {
299
- ownKeys(Object(source)).forEach(function (key) {
300
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
301
- });
302
- }
303
- }
304
-
305
- return target;
306
- }
307
-
308
- /**
309
- * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
310
- *
311
- * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
312
- * during build.
313
- * @param {number} code
314
- */
315
- function formatProdErrorMessage(code) {
316
- return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
317
- }
318
-
319
- // Inlined version of the `symbol-observable` polyfill
320
- var $$observable = (function () {
321
- return typeof Symbol === 'function' && Symbol.observable || '@@observable';
322
- })();
323
-
324
- /**
325
- * These are private action types reserved by Redux.
326
- * For any unknown actions, you must return the current state.
327
- * If the current state is undefined, you must return the initial state.
328
- * Do not reference these action types directly in your code.
329
- */
330
- var randomString = function randomString() {
331
- return Math.random().toString(36).substring(7).split('').join('.');
332
- };
333
-
334
- var ActionTypes = {
335
- INIT: "@@redux/INIT" + randomString(),
336
- REPLACE: "@@redux/REPLACE" + randomString(),
337
- PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
338
- return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
339
- }
340
- };
341
-
342
- /**
343
- * @param {any} obj The object to inspect.
344
- * @returns {boolean} True if the argument appears to be a plain object.
345
- */
346
- function isPlainObject(obj) {
347
- if (typeof obj !== 'object' || obj === null) return false;
348
- var proto = obj;
349
-
350
- while (Object.getPrototypeOf(proto) !== null) {
351
- proto = Object.getPrototypeOf(proto);
352
- }
353
-
354
- return Object.getPrototypeOf(obj) === proto;
355
- }
356
-
357
- // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
358
- function miniKindOf(val) {
359
- if (val === void 0) return 'undefined';
360
- if (val === null) return 'null';
361
- var type = typeof val;
362
-
363
- switch (type) {
364
- case 'boolean':
365
- case 'string':
366
- case 'number':
367
- case 'symbol':
368
- case 'function':
369
- {
370
- return type;
371
- }
372
- }
373
-
374
- if (Array.isArray(val)) return 'array';
375
- if (isDate(val)) return 'date';
376
- if (isError(val)) return 'error';
377
- var constructorName = ctorName(val);
378
-
379
- switch (constructorName) {
380
- case 'Symbol':
381
- case 'Promise':
382
- case 'WeakMap':
383
- case 'WeakSet':
384
- case 'Map':
385
- case 'Set':
386
- return constructorName;
387
- } // other
388
-
389
-
390
- return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
391
- }
392
-
393
- function ctorName(val) {
394
- return typeof val.constructor === 'function' ? val.constructor.name : null;
395
- }
396
-
397
- function isError(val) {
398
- return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
399
- }
400
-
401
- function isDate(val) {
402
- if (val instanceof Date) return true;
403
- return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
404
- }
405
-
406
- function kindOf(val) {
407
- var typeOfVal = typeof val;
408
-
409
- if ("development" !== 'production') {
410
- typeOfVal = miniKindOf(val);
411
- }
412
-
413
- return typeOfVal;
414
- }
415
-
416
- /**
417
- * Creates a Redux store that holds the state tree.
418
- * The only way to change the data in the store is to call `dispatch()` on it.
419
- *
420
- * There should only be a single store in your app. To specify how different
421
- * parts of the state tree respond to actions, you may combine several reducers
422
- * into a single reducer function by using `combineReducers`.
423
- *
424
- * @param {Function} reducer A function that returns the next state tree, given
425
- * the current state tree and the action to handle.
426
- *
427
- * @param {any} [preloadedState] The initial state. You may optionally specify it
428
- * to hydrate the state from the server in universal apps, or to restore a
429
- * previously serialized user session.
430
- * If you use `combineReducers` to produce the root reducer function, this must be
431
- * an object with the same shape as `combineReducers` keys.
432
- *
433
- * @param {Function} [enhancer] The store enhancer. You may optionally specify it
434
- * to enhance the store with third-party capabilities such as middleware,
435
- * time travel, persistence, etc. The only store enhancer that ships with Redux
436
- * is `applyMiddleware()`.
437
- *
438
- * @returns {Store} A Redux store that lets you read the state, dispatch actions
439
- * and subscribe to changes.
440
- */
441
-
442
- function createStore(reducer, preloadedState, enhancer) {
443
- var _ref2;
444
-
445
- if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
446
- throw new Error("development" === "production" ? formatProdErrorMessage(0) : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
447
- }
448
-
449
- if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
450
- enhancer = preloadedState;
451
- preloadedState = undefined;
452
- }
453
-
454
- if (typeof enhancer !== 'undefined') {
455
- if (typeof enhancer !== 'function') {
456
- throw new Error("development" === "production" ? formatProdErrorMessage(1) : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
457
- }
458
-
459
- return enhancer(createStore)(reducer, preloadedState);
460
- }
461
-
462
- if (typeof reducer !== 'function') {
463
- throw new Error("development" === "production" ? formatProdErrorMessage(2) : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
464
- }
465
-
466
- var currentReducer = reducer;
467
- var currentState = preloadedState;
468
- var currentListeners = [];
469
- var nextListeners = currentListeners;
470
- var isDispatching = false;
471
- /**
472
- * This makes a shallow copy of currentListeners so we can use
473
- * nextListeners as a temporary list while dispatching.
474
- *
475
- * This prevents any bugs around consumers calling
476
- * subscribe/unsubscribe in the middle of a dispatch.
477
- */
478
-
479
- function ensureCanMutateNextListeners() {
480
- if (nextListeners === currentListeners) {
481
- nextListeners = currentListeners.slice();
482
- }
483
- }
484
- /**
485
- * Reads the state tree managed by the store.
486
- *
487
- * @returns {any} The current state tree of your application.
488
- */
489
-
490
-
491
- function getState() {
492
- if (isDispatching) {
493
- throw new Error("development" === "production" ? formatProdErrorMessage(3) : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
494
- }
495
-
496
- return currentState;
497
- }
498
- /**
499
- * Adds a change listener. It will be called any time an action is dispatched,
500
- * and some part of the state tree may potentially have changed. You may then
501
- * call `getState()` to read the current state tree inside the callback.
502
- *
503
- * You may call `dispatch()` from a change listener, with the following
504
- * caveats:
505
- *
506
- * 1. The subscriptions are snapshotted just before every `dispatch()` call.
507
- * If you subscribe or unsubscribe while the listeners are being invoked, this
508
- * will not have any effect on the `dispatch()` that is currently in progress.
509
- * However, the next `dispatch()` call, whether nested or not, will use a more
510
- * recent snapshot of the subscription list.
511
- *
512
- * 2. The listener should not expect to see all state changes, as the state
513
- * might have been updated multiple times during a nested `dispatch()` before
514
- * the listener is called. It is, however, guaranteed that all subscribers
515
- * registered before the `dispatch()` started will be called with the latest
516
- * state by the time it exits.
517
- *
518
- * @param {Function} listener A callback to be invoked on every dispatch.
519
- * @returns {Function} A function to remove this change listener.
520
- */
521
-
522
-
523
- function subscribe(listener) {
524
- if (typeof listener !== 'function') {
525
- throw new Error("development" === "production" ? formatProdErrorMessage(4) : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
526
- }
527
-
528
- if (isDispatching) {
529
- throw new Error("development" === "production" ? formatProdErrorMessage(5) : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
530
- }
531
-
532
- var isSubscribed = true;
533
- ensureCanMutateNextListeners();
534
- nextListeners.push(listener);
535
- return function unsubscribe() {
536
- if (!isSubscribed) {
537
- return;
538
- }
539
-
540
- if (isDispatching) {
541
- throw new Error("development" === "production" ? formatProdErrorMessage(6) : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
542
- }
543
-
544
- isSubscribed = false;
545
- ensureCanMutateNextListeners();
546
- var index = nextListeners.indexOf(listener);
547
- nextListeners.splice(index, 1);
548
- currentListeners = null;
549
- };
550
- }
551
- /**
552
- * Dispatches an action. It is the only way to trigger a state change.
553
- *
554
- * The `reducer` function, used to create the store, will be called with the
555
- * current state tree and the given `action`. Its return value will
556
- * be considered the **next** state of the tree, and the change listeners
557
- * will be notified.
558
- *
559
- * The base implementation only supports plain object actions. If you want to
560
- * dispatch a Promise, an Observable, a thunk, or something else, you need to
561
- * wrap your store creating function into the corresponding middleware. For
562
- * example, see the documentation for the `redux-thunk` package. Even the
563
- * middleware will eventually dispatch plain object actions using this method.
564
- *
565
- * @param {Object} action A plain object representing “what changed”. It is
566
- * a good idea to keep actions serializable so you can record and replay user
567
- * sessions, or use the time travelling `redux-devtools`. An action must have
568
- * a `type` property which may not be `undefined`. It is a good idea to use
569
- * string constants for action types.
570
- *
571
- * @returns {Object} For convenience, the same action object you dispatched.
572
- *
573
- * Note that, if you use a custom middleware, it may wrap `dispatch()` to
574
- * return something else (for example, a Promise you can await).
575
- */
576
-
577
-
578
- function dispatch(action) {
579
- if (!isPlainObject(action)) {
580
- throw new Error("development" === "production" ? formatProdErrorMessage(7) : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
581
- }
582
-
583
- if (typeof action.type === 'undefined') {
584
- throw new Error("development" === "production" ? formatProdErrorMessage(8) : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
585
- }
586
-
587
- if (isDispatching) {
588
- throw new Error("development" === "production" ? formatProdErrorMessage(9) : 'Reducers may not dispatch actions.');
589
- }
590
-
591
- try {
592
- isDispatching = true;
593
- currentState = currentReducer(currentState, action);
594
- } finally {
595
- isDispatching = false;
596
- }
597
-
598
- var listeners = currentListeners = nextListeners;
599
-
600
- for (var i = 0; i < listeners.length; i++) {
601
- var listener = listeners[i];
602
- listener();
603
- }
604
-
605
- return action;
606
- }
607
- /**
608
- * Replaces the reducer currently used by the store to calculate the state.
609
- *
610
- * You might need this if your app implements code splitting and you want to
611
- * load some of the reducers dynamically. You might also need this if you
612
- * implement a hot reloading mechanism for Redux.
613
- *
614
- * @param {Function} nextReducer The reducer for the store to use instead.
615
- * @returns {void}
616
- */
617
-
618
-
619
- function replaceReducer(nextReducer) {
620
- if (typeof nextReducer !== 'function') {
621
- throw new Error("development" === "production" ? formatProdErrorMessage(10) : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
622
- }
623
-
624
- currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
625
- // Any reducers that existed in both the new and old rootReducer
626
- // will receive the previous state. This effectively populates
627
- // the new state tree with any relevant data from the old one.
628
-
629
- dispatch({
630
- type: ActionTypes.REPLACE
631
- });
632
- }
633
- /**
634
- * Interoperability point for observable/reactive libraries.
635
- * @returns {observable} A minimal observable of state changes.
636
- * For more information, see the observable proposal:
637
- * https://github.com/tc39/proposal-observable
638
- */
639
-
640
-
641
- function observable() {
642
- var _ref;
643
-
644
- var outerSubscribe = subscribe;
645
- return _ref = {
646
- /**
647
- * The minimal observable subscription method.
648
- * @param {Object} observer Any object that can be used as an observer.
649
- * The observer object should have a `next` method.
650
- * @returns {subscription} An object with an `unsubscribe` method that can
651
- * be used to unsubscribe the observable from the store, and prevent further
652
- * emission of values from the observable.
653
- */
654
- subscribe: function subscribe(observer) {
655
- if (typeof observer !== 'object' || observer === null) {
656
- throw new Error("development" === "production" ? formatProdErrorMessage(11) : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
657
- }
658
-
659
- function observeState() {
660
- if (observer.next) {
661
- observer.next(getState());
662
- }
663
- }
664
-
665
- observeState();
666
- var unsubscribe = outerSubscribe(observeState);
667
- return {
668
- unsubscribe: unsubscribe
669
- };
670
- }
671
- }, _ref[$$observable] = function () {
672
- return this;
673
- }, _ref;
674
- } // When a store is created, an "INIT" action is dispatched so that every
675
- // reducer returns their initial state. This effectively populates
676
- // the initial state tree.
677
-
678
-
679
- dispatch({
680
- type: ActionTypes.INIT
681
- });
682
- return _ref2 = {
683
- dispatch: dispatch,
684
- subscribe: subscribe,
685
- getState: getState,
686
- replaceReducer: replaceReducer
687
- }, _ref2[$$observable] = observable, _ref2;
688
- }
689
-
690
- /**
691
- * Prints a warning in the console if it exists.
692
- *
693
- * @param {String} message The warning message.
694
- * @returns {void}
695
- */
696
- function warning(message) {
697
- /* eslint-disable no-console */
698
- if (typeof console !== 'undefined' && typeof console.error === 'function') {
699
- console.error(message);
700
- }
701
- /* eslint-enable no-console */
702
-
703
-
704
- try {
705
- // This error was thrown as a convenience so that if you enable
706
- // "break on all exceptions" in your console,
707
- // it would pause the execution at this line.
708
- throw new Error(message);
709
- } catch (e) {} // eslint-disable-line no-empty
710
-
711
- }
712
-
713
- function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
714
- var reducerKeys = Object.keys(reducers);
715
- var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
716
-
717
- if (reducerKeys.length === 0) {
718
- return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
719
- }
720
-
721
- if (!isPlainObject(inputState)) {
722
- return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
723
- }
724
-
725
- var unexpectedKeys = Object.keys(inputState).filter(function (key) {
726
- return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
727
- });
728
- unexpectedKeys.forEach(function (key) {
729
- unexpectedKeyCache[key] = true;
730
- });
731
- if (action && action.type === ActionTypes.REPLACE) return;
732
-
733
- if (unexpectedKeys.length > 0) {
734
- return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
735
- }
736
- }
737
-
738
- function assertReducerShape(reducers) {
739
- Object.keys(reducers).forEach(function (key) {
740
- var reducer = reducers[key];
741
- var initialState = reducer(undefined, {
742
- type: ActionTypes.INIT
743
- });
744
-
745
- if (typeof initialState === 'undefined') {
746
- throw new Error("development" === "production" ? formatProdErrorMessage(12) : "The slice reducer for key \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
747
- }
748
-
749
- if (typeof reducer(undefined, {
750
- type: ActionTypes.PROBE_UNKNOWN_ACTION()
751
- }) === 'undefined') {
752
- throw new Error("development" === "production" ? formatProdErrorMessage(13) : "The slice reducer for key \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle '" + ActionTypes.INIT + "' or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
753
- }
754
- });
755
- }
756
- /**
757
- * Turns an object whose values are different reducer functions, into a single
758
- * reducer function. It will call every child reducer, and gather their results
759
- * into a single state object, whose keys correspond to the keys of the passed
760
- * reducer functions.
761
- *
762
- * @param {Object} reducers An object whose values correspond to different
763
- * reducer functions that need to be combined into one. One handy way to obtain
764
- * it is to use ES6 `import * as reducers` syntax. The reducers may never return
765
- * undefined for any action. Instead, they should return their initial state
766
- * if the state passed to them was undefined, and the current state for any
767
- * unrecognized action.
768
- *
769
- * @returns {Function} A reducer function that invokes every reducer inside the
770
- * passed object, and builds a state object with the same shape.
771
- */
772
-
773
-
774
- function combineReducers(reducers) {
775
- var reducerKeys = Object.keys(reducers);
776
- var finalReducers = {};
777
-
778
- for (var i = 0; i < reducerKeys.length; i++) {
779
- var key = reducerKeys[i];
780
-
781
- if ("development" !== 'production') {
782
- if (typeof reducers[key] === 'undefined') {
783
- warning("No reducer provided for key \"" + key + "\"");
784
- }
785
- }
786
-
787
- if (typeof reducers[key] === 'function') {
788
- finalReducers[key] = reducers[key];
789
- }
790
- }
791
-
792
- var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
793
- // keys multiple times.
794
-
795
- var unexpectedKeyCache;
796
-
797
- if ("development" !== 'production') {
798
- unexpectedKeyCache = {};
799
- }
800
-
801
- var shapeAssertionError;
802
-
803
- try {
804
- assertReducerShape(finalReducers);
805
- } catch (e) {
806
- shapeAssertionError = e;
807
- }
808
-
809
- return function combination(state, action) {
810
- if (state === void 0) {
811
- state = {};
812
- }
813
-
814
- if (shapeAssertionError) {
815
- throw shapeAssertionError;
816
- }
817
-
818
- if ("development" !== 'production') {
819
- var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
820
-
821
- if (warningMessage) {
822
- warning(warningMessage);
823
- }
824
- }
825
-
826
- var hasChanged = false;
827
- var nextState = {};
828
-
829
- for (var _i = 0; _i < finalReducerKeys.length; _i++) {
830
- var _key = finalReducerKeys[_i];
831
- var reducer = finalReducers[_key];
832
- var previousStateForKey = state[_key];
833
- var nextStateForKey = reducer(previousStateForKey, action);
834
-
835
- if (typeof nextStateForKey === 'undefined') {
836
- var actionType = action && action.type;
837
- throw new Error("development" === "production" ? formatProdErrorMessage(14) : "When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.");
838
- }
839
-
840
- nextState[_key] = nextStateForKey;
841
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
842
- }
843
-
844
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
845
- return hasChanged ? nextState : state;
846
- };
847
- }
848
-
849
- function bindActionCreator(actionCreator, dispatch) {
850
- return function () {
851
- return dispatch(actionCreator.apply(this, arguments));
852
- };
853
- }
854
- /**
855
- * Turns an object whose values are action creators, into an object with the
856
- * same keys, but with every function wrapped into a `dispatch` call so they
857
- * may be invoked directly. This is just a convenience method, as you can call
858
- * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
859
- *
860
- * For convenience, you can also pass an action creator as the first argument,
861
- * and get a dispatch wrapped function in return.
862
- *
863
- * @param {Function|Object} actionCreators An object whose values are action
864
- * creator functions. One handy way to obtain it is to use ES6 `import * as`
865
- * syntax. You may also pass a single function.
866
- *
867
- * @param {Function} dispatch The `dispatch` function available on your Redux
868
- * store.
869
- *
870
- * @returns {Function|Object} The object mimicking the original object, but with
871
- * every action creator wrapped into the `dispatch` call. If you passed a
872
- * function as `actionCreators`, the return value will also be a single
873
- * function.
874
- */
875
-
876
-
877
- function bindActionCreators(actionCreators, dispatch) {
878
- if (typeof actionCreators === 'function') {
879
- return bindActionCreator(actionCreators, dispatch);
880
- }
881
-
882
- if (typeof actionCreators !== 'object' || actionCreators === null) {
883
- throw new Error("development" === "production" ? formatProdErrorMessage(16) : "bindActionCreators expected an object or a function, but instead received: '" + kindOf(actionCreators) + "'. " + "Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?");
884
- }
885
-
886
- var boundActionCreators = {};
887
-
888
- for (var key in actionCreators) {
889
- var actionCreator = actionCreators[key];
890
-
891
- if (typeof actionCreator === 'function') {
892
- boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
893
- }
894
- }
895
-
896
- return boundActionCreators;
897
- }
898
-
899
- /**
900
- * Composes single-argument functions from right to left. The rightmost
901
- * function can take multiple arguments as it provides the signature for
902
- * the resulting composite function.
903
- *
904
- * @param {...Function} funcs The functions to compose.
905
- * @returns {Function} A function obtained by composing the argument functions
906
- * from right to left. For example, compose(f, g, h) is identical to doing
907
- * (...args) => f(g(h(...args))).
908
- */
909
- function compose() {
910
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
911
- funcs[_key] = arguments[_key];
912
- }
913
-
914
- if (funcs.length === 0) {
915
- return function (arg) {
916
- return arg;
917
- };
918
- }
919
-
920
- if (funcs.length === 1) {
921
- return funcs[0];
922
- }
923
-
924
- return funcs.reduce(function (a, b) {
925
- return function () {
926
- return a(b.apply(void 0, arguments));
927
- };
928
- });
929
- }
930
-
931
- /**
932
- * Creates a store enhancer that applies middleware to the dispatch method
933
- * of the Redux store. This is handy for a variety of tasks, such as expressing
934
- * asynchronous actions in a concise manner, or logging every action payload.
935
- *
936
- * See `redux-thunk` package as an example of the Redux middleware.
937
- *
938
- * Because middleware is potentially asynchronous, this should be the first
939
- * store enhancer in the composition chain.
940
- *
941
- * Note that each middleware will be given the `dispatch` and `getState` functions
942
- * as named arguments.
943
- *
944
- * @param {...Function} middlewares The middleware chain to be applied.
945
- * @returns {Function} A store enhancer applying the middleware.
946
- */
947
-
948
- function applyMiddleware() {
949
- for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
950
- middlewares[_key] = arguments[_key];
951
- }
952
-
953
- return function (createStore) {
954
- return function () {
955
- var store = createStore.apply(void 0, arguments);
956
-
957
- var _dispatch = function dispatch() {
958
- throw new Error("development" === "production" ? formatProdErrorMessage(15) : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
959
- };
960
-
961
- var middlewareAPI = {
962
- getState: store.getState,
963
- dispatch: function dispatch() {
964
- return _dispatch.apply(void 0, arguments);
965
- }
966
- };
967
- var chain = middlewares.map(function (middleware) {
968
- return middleware(middlewareAPI);
969
- });
970
- _dispatch = compose.apply(void 0, chain)(store.dispatch);
971
- return _objectSpread2(_objectSpread2({}, store), {}, {
972
- dispatch: _dispatch
973
- });
974
- };
975
- };
976
- }
977
-
978
- /*
979
- * This is a dummy function to check if the function name has been altered by minification.
980
- * If the function has been minified and NODE_ENV !== 'production', warn the user.
981
- */
982
-
983
- function isCrushed() {}
984
-
985
- if ("development" !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
986
- warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
987
- }
988
-
989
- const inicialState = {};
990
- /////////////////////////////// REDUCERS ///////////////////////////////
991
- function formReducer(state = inicialState, action) {
992
- switch (action.type) {
993
- case FormActions.METADATA_LOADED:
994
- return Object.assign(Object.assign({}, state), { formMetadata: action.payload });
995
- case FormActions.CHANGE_TAB:
996
- return Object.assign(Object.assign({}, state), { currentSheet: action.payload });
997
- default:
998
- return state;
999
- }
1000
- }
1001
- /////////////////////////////// ACTION CREATORS ///////////////////////////////
1002
- function loadMetadata(formMetadata) {
1003
- return {
1004
- type: FormActions.METADATA_LOADED,
1005
- payload: formMetadata
1006
- };
1007
- }
1008
- function changeTab(currentSheet) {
1009
- return {
1010
- type: FormActions.CHANGE_TAB,
1011
- payload: currentSheet.tabKey
1012
- };
1013
- }
1014
- /////////////////////////////// SELECTORS ///////////////////////////////
1015
- function selectFormMetadata(state) {
1016
- return state.formMetadata;
1017
- }
1018
- function selectCurrentSheet(state) {
1019
- return state.currentSheet ? state.formMetadata.getSheet(state.currentSheet) : Array.from(state.formMetadata.getAllSheets().values())[0];
1020
- }
1021
- /////////////////////////////// TYPES ///////////////////////////////
1022
- var FormActions;
1023
- (function (FormActions) {
1024
- FormActions["METADATA_LOADED"] = "FORM/METADATA_LOADED";
1025
- FormActions["CHANGE_TAB"] = "FORM/CHANGE_TAB";
1026
- })(FormActions || (FormActions = {}));
1027
-
1028
- class DataBinder {
1029
- constructor(dataUnit) {
1030
- this._invalidFields = new Map();
1031
- this.onDataUnitEvent = (action) => {
1032
- var _a;
1033
- switch (action.type) {
1034
- case Action.DATA_LOADED:
1035
- case Action.DATA_SAVED:
1036
- case Action.RECORDS_REMOVED:
1037
- case Action.RECORDS_ADDED:
1038
- case Action.RECORDS_COPIED:
1039
- case Action.EDITION_CANCELED:
1040
- case Action.SELECTION_CHANGED:
1041
- case Action.NEXT_SELECTED:
1042
- case Action.PREVIOUS_SELECTED:
1043
- this.clearInvalid();
1044
- case Action.DATA_CHANGED:
1045
- case Action.CHANGE_UNDONE:
1046
- case Action.CHANGE_REDONE:
1047
- (_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
1048
- this.updateValue(field.fieldName, field.field);
1049
- });
1050
- break;
1051
- }
1052
- };
1053
- this._fields = new Map();
1054
- this._dataUnit = dataUnit;
1055
- this._dataUnit.subscribe(this.onDataUnitEvent);
1056
- }
1057
- bind(fields) {
1058
- fields.forEach(fieldElement => {
1059
- const fieldName = fieldElement.dataset.fieldName;
1060
- this.updateBind(fieldName, fieldElement);
1061
- });
1062
- }
1063
- onDisconnectedCallback() {
1064
- this._dataUnit.unsubscribe(this.onDataUnitEvent);
1065
- }
1066
- markInvalid(field) {
1067
- this._invalidFields.set(field.name, field);
1068
- if (this._fields.has(field.name)) {
1069
- this.updateErrorMessage(field.name, this._fields.get(field.name).field);
1070
- }
1071
- }
1072
- clearInvalid() {
1073
- this._invalidFields.clear();
1074
- this._fields.forEach(fieldBinder => {
1075
- const fieldName = fieldBinder.field.dataset.fieldName;
1076
- this.updateErrorMessage(fieldName, fieldBinder.field);
1077
- });
1078
- }
1079
- updateValue(fieldName, field) {
1080
- const bind = this._fields.get(fieldName);
1081
- try {
1082
- if (bind) {
1083
- bind.listen = false;
1084
- }
1085
- field["value"] = this._dataUnit.getFieldValue(fieldName);
1086
- this.updateErrorMessage(fieldName, field);
1087
- }
1088
- finally {
1089
- if (bind) {
1090
- bind.listen = true;
1091
- }
1092
- }
1093
- }
1094
- updateErrorMessage(fieldName, field) {
1095
- const invalidField = this._invalidFields.get(fieldName);
1096
- field["errorMessage"] = invalidField ? invalidField.message : "";
1097
- }
1098
- updateBind(fieldName, field) {
1099
- const oldBind = this._fields.get(fieldName);
1100
- if (oldBind) {
1101
- oldBind.destroy();
1102
- }
1103
- field["value"] = this._dataUnit.getFieldValue(fieldName);
1104
- this.updateErrorMessage(fieldName, field);
1105
- this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName) => this.cancelWaitingChange(fieldName), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
1106
- this.bindSearchOptionsLoader(fieldName, field);
1107
- this.applyEzUploadContext(fieldName, field);
1108
- }
1109
- changeStarted(fieldName, waitingChange) {
1110
- /**
1111
- * se o waitingChange não é blocante, add um event listener pra
1112
- * fazer o accept da promise
1113
- *
1114
- * se não tiver promise no waitingChange, eu crio uma e resolvo no bind
1115
- *
1116
- *
1117
- */
1118
- if (this._dataUnit.records.length === 0) {
1119
- this._dataUnit.addRecord();
1120
- }
1121
- if (!waitingChange.blocking && waitingChange.promise == undefined) {
1122
- const bind = this._fields.get(fieldName);
1123
- if (bind) {
1124
- waitingChange.promise = new Promise((resolve, reject) => {
1125
- bind.waitingChangePromiseResolve = resolve;
1126
- bind.waitingChangePromiseReject = reject;
1127
- });
1128
- }
1129
- }
1130
- this._dataUnit.startChange(fieldName, waitingChange);
1131
- }
1132
- cancelWaitingChange(fieldName) {
1133
- if (this._dataUnit.waitingForChange(fieldName)) {
1134
- this._dataUnit.cancelWaitingChange(fieldName);
1135
- const bind = this._fields.get(fieldName);
1136
- if (bind) {
1137
- bind.rejectWaitingChange(new WaitingChangeException("Change canceled", fieldName));
1138
- }
1139
- }
1140
- }
1141
- setFieldValue(fieldName, newValue) {
1142
- if (this._dataUnit.records.length === 0) {
1143
- this._dataUnit.addRecord();
1144
- }
1145
- this._invalidFields.delete(fieldName);
1146
- this._dataUnit.setFieldValue(fieldName, newValue);
1147
- if (this._dataUnit.waitingForChange(fieldName)) {
1148
- const bind = this._fields.get(fieldName);
1149
- if (bind) {
1150
- bind.acceptWaitingChange();
1151
- }
1152
- }
1153
- }
1154
- bindSearchOptionsLoader(fieldName, field) {
1155
- if (field.nodeName === "EZ-SEARCH" && field["optionLoader"] == undefined) {
1156
- const loader = ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
1157
- if (loader) {
1158
- field["optionLoader"] = (arg) => {
1159
- return loader(arg, fieldName, this._dataUnit);
1160
- };
1161
- }
1162
- }
1163
- }
1164
- applyEzUploadContext(fieldName, field) {
1165
- var _a, _b;
1166
- if (field.nodeName === "EZ-UPLOAD") {
1167
- field["urlUpload"] = ApplicationContext.getContextValue("__EZUI__UPLOAD__ADD__URL__");
1168
- field["urlDelete"] = ApplicationContext.getContextValue("__EZUI__UPLOAD__DEL__URL__");
1169
- const descriptor = this._dataUnit.getField(fieldName);
1170
- const destination = (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.DESTINATION;
1171
- if (destination) {
1172
- field["requestHeaders"] = { XTRAINF: `{"destination": "${destination}"}` };
1173
- }
1174
- field["maxFiles"] = ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.MAX_FILES) || 0;
1175
- }
1176
- }
1177
- }
1178
- class Bind {
1179
- constructor() {
1180
- this.listen = true;
1181
- this.startChangeEventName = "ezStartChange";
1182
- this.cancelWaitingChangeEventName = "ezCancelWaitingChange";
1183
- this.changeEventName = "ezChange";
1184
- }
1185
- destroy() {
1186
- this.field.removeEventListener(this.startChangeEventName, this.startChangeListener);
1187
- this.field.removeEventListener(this.cancelWaitingChangeEventName, this.cancelWaitingChangeListener);
1188
- this.field.removeEventListener(this.changeEventName, this.changeListener);
1189
- }
1190
- acceptWaitingChange() {
1191
- if (this.waitingChangePromiseResolve) {
1192
- this.waitingChangePromiseResolve();
1193
- this.waitingChangePromiseReject = undefined;
1194
- this.waitingChangePromiseResolve = undefined;
1195
- }
1196
- }
1197
- rejectWaitingChange(reason) {
1198
- if (this.waitingChangePromiseReject) {
1199
- this.waitingChangePromiseReject(reason);
1200
- this.waitingChangePromiseReject = undefined;
1201
- this.waitingChangePromiseResolve = undefined;
1202
- }
1203
- }
1204
- static create(fieldName, field, startChangeCallback, cancelWaitingChangeCallback, changeCallback) {
1205
- const b = new Bind();
1206
- b.field = field;
1207
- b.fieldName = fieldName;
1208
- b.startChangeListener = (evt) => { if (b.listen)
1209
- startChangeCallback(fieldName, evt.detail); };
1210
- b.field.addEventListener(b.startChangeEventName, b.startChangeListener);
1211
- b.cancelWaitingChangeListener = () => { if (b.listen)
1212
- cancelWaitingChangeCallback(fieldName); };
1213
- b.field.addEventListener(b.cancelWaitingChangeEventName, b.cancelWaitingChangeListener);
1214
- b.changeListener = (evt) => { if (b.listen)
1215
- changeCallback(fieldName, evt.detail); };
1216
- b.field.addEventListener(b.changeEventName, b.changeListener);
1217
- return b;
1218
- }
1219
- }
1220
-
1221
- const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}.dynamic-content ez-collapsible-box{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";
1222
-
1223
- let EzForm = class {
1224
- constructor(hostRef) {
1225
- registerInstance(this, hostRef);
1226
- this.ezReady = createEvent(this, "ezReady", 7);
1227
- this.onDataUnitAction = (action) => {
1228
- if (action.type === Action.METADATA_LOADED) {
1229
- this.processMetadata();
1230
- }
1231
- };
1232
- }
1233
- submit() {
1234
- return Promise.resolve();
1235
- }
1236
- cancel() {
1237
- return Promise.resolve();
1238
- }
1239
- validate() {
1240
- return new Promise((accept, reject) => {
1241
- var _a;
1242
- const records = this.dataUnit.getModifiedRecords();
1243
- for (let i = 0; i < records.length; i++) {
1244
- const record = records[i];
1245
- const invalidResults = [];
1246
- let validationResult = this.validateRequired(record);
1247
- if (validationResult && !validationResult.isValid) {
1248
- invalidResults.push(validationResult);
1249
- }
1250
- validationResult = (_a = this.recordsValidator) === null || _a === void 0 ? void 0 : _a.validateRecord(this, record);
1251
- if (validationResult && !validationResult.isValid) {
1252
- invalidResults.push(validationResult);
1253
- }
1254
- if (invalidResults.length > 0) {
1255
- this.processValidationResult(invalidResults);
1256
- reject();
1257
- break;
1258
- }
1259
- }
1260
- accept();
1261
- });
1262
- }
1263
- observeConfig() {
1264
- this.processMetadata();
1265
- }
1266
- validateRequired(record) {
1267
- const metadata = selectFormMetadata(this._store.getState());
1268
- const requiredFields = this._staticFields
1269
- .filter(f => f.dataset.required)
1270
- .map(f => f.dataset.fieldName)
1271
- .concat(metadata.getRequiredFields());
1272
- const invalidFields = [];
1273
- requiredFields.forEach(field => {
1274
- const value = record[field];
1275
- if (value == undefined || value === "") {
1276
- invalidFields.push({ name: field, message: "Essa informação é obrigatória" });
1277
- }
1278
- });
1279
- if (invalidFields.length > 0) {
1280
- return { isValid: false, invalidFields, infoMessage: "Há pelo menos um campo obrigatório não preenchido." };
1281
- }
1282
- return undefined;
1283
- }
1284
- processValidationResult(validationResult) {
1285
- validationResult.forEach(invalidResult => {
1286
- const invalidFields = invalidResult.invalidFields;
1287
- if (invalidFields) {
1288
- invalidFields.forEach(field => {
1289
- this._dataBinder.markInvalid(field);
1290
- });
1291
- }
1292
- if (invalidResult.infoMessage) {
1293
- ApplicationUtils.info(invalidResult.infoMessage);
1294
- }
1295
- if (invalidResult.errorMessage) {
1296
- const { errorTitle, errorMessage } = invalidResult;
1297
- ApplicationUtils.error(errorTitle, errorMessage);
1298
- }
1299
- });
1300
- }
1301
- getDynamicContent() {
1302
- var _a;
1303
- const formMD = selectFormMetadata(this._store.getState());
1304
- if (!formMD)
1305
- return null;
1306
- const currentSheet = selectCurrentSheet((_a = this._store) === null || _a === void 0 ? void 0 : _a.getState());
1307
- if (!currentSheet) {
1308
- return null;
1309
- }
1310
- const allSheets = Array.from(formMD.getAllSheets().values());
1311
- const result = [];
1312
- if (allSheets.length > 1) {
1313
- result.push(h("ez-tabselector", { onEzChange: (evt) => this._store.dispatch(changeTab(evt.detail)), selectedTab: currentSheet.name }, allSheets.map(s => h("ez-tab", { tabKey: s.name, label: s.label }))));
1314
- }
1315
- result.push(h(FormSheet, { store: this._store, source: currentSheet }));
1316
- return result;
1317
- }
1318
- processMetadata() {
1319
- if (!this.isStatic() && this.dataUnit) {
1320
- const metadata = this.config && this.config.length > 0 ? buildFromConfig(this.config, this.dataUnit) : buildFromDataUnit(this.dataUnit);
1321
- this._store.dispatch(loadMetadata(metadata));
1322
- }
1323
- }
1324
- isStatic() {
1325
- var _a;
1326
- return ((_a = this._staticFields) === null || _a === void 0 ? void 0 : _a.length) > 0;
1327
- }
1328
- interceptAction(action) {
1329
- if (action.type === Action.RECORDS_COPIED) {
1330
- const metadata = selectFormMetadata(this._store.getState());
1331
- const cleanFields = metadata.getCleanOnCopyFields();
1332
- if (cleanFields) {
1333
- const records = action.payload;
1334
- return new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
1335
- const newRecord = Object.assign({}, record);
1336
- cleanFields.forEach(fieldName => delete newRecord[fieldName]);
1337
- return newRecord;
1338
- }));
1339
- }
1340
- }
1341
- if (action.type === Action.SAVING_DATA) {
1342
- return new Promise((resolve) => {
1343
- this.validate()
1344
- .then(() => resolve(action))
1345
- .catch(() => { });
1346
- });
1347
- }
1348
- if (action.type === Action.RECORDS_ADDED) {
1349
- const metadata = selectFormMetadata(this._store.getState());
1350
- const defaultValues = metadata.getDefaultValues();
1351
- if (defaultValues) {
1352
- const records = action.payload;
1353
- return new DataUnitAction(Action.RECORDS_ADDED, records.map(record => {
1354
- const newRecord = Object.assign({}, record);
1355
- for (const field in defaultValues) {
1356
- newRecord[field] = this.dataUnit.valueFromString(field, defaultValues[field]);
1357
- }
1358
- return newRecord;
1359
- }));
1360
- }
1361
- }
1362
- return action;
1363
- }
1364
- componentWillLoad() {
1365
- if (this.dataUnit === undefined) {
1366
- this.dataUnit = new DataUnit("ez-form");
1367
- }
1368
- this.dataUnit.addInterceptor(this);
1369
- this.dataUnit.subscribe(this.onDataUnitAction);
1370
- this._dataBinder = new DataBinder(this.dataUnit);
1371
- this._store = createStore(formReducer);
1372
- this._store.subscribe(() => forceUpdate(this));
1373
- this._staticFields = Array.from(this._element.querySelectorAll("[data-field-name]"));
1374
- this.processMetadata();
1375
- }
1376
- componentDidRender() {
1377
- this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")));
1378
- this.ezReady.emit();
1379
- }
1380
- disconnectedCallback() {
1381
- this.dataUnit.unsubscribe(this.onDataUnitAction);
1382
- this.dataUnit.removeInterceptor(this);
1383
- this._dataBinder.onDisconnectedCallback();
1384
- }
1385
- render() {
1386
- return (h(Host, null, this.isStatic() ? null : this.getDynamicContent()));
1387
- }
1388
- get _element() { return getElement(this); }
1389
- static get watchers() { return {
1390
- "config": ["observeConfig"]
1391
- }; }
1392
- };
1393
- EzForm.style = ezFormCss;
1394
-
1395
- export { EzForm as ez_form };