@sankhyalabs/ezui 1.1.5 → 1.1.9

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 (141) hide show
  1. package/README.md +72 -72
  2. package/dist/cjs/{DataUnit-6a98d9de.js → DataUnit-9a4a35ca.js} +415 -368
  3. package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
  4. package/dist/cjs/ez-button_14.cjs.entry.js +1911 -1908
  5. package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
  6. package/dist/cjs/ez-modal.cjs.entry.js +104 -104
  7. package/dist/cjs/ez-number-input.cjs.entry.js +236 -236
  8. package/dist/cjs/ez-time-input.cjs.entry.js +168 -168
  9. package/dist/cjs/form-metadata.cjs.entry.js +65 -65
  10. package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -82
  11. package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -109
  12. package/dist/collection/components/ez-button/ez-button.css +94 -94
  13. package/dist/collection/components/ez-button/ez-button.js +125 -125
  14. package/dist/collection/components/ez-calendar/ez-calendar.css +210 -210
  15. package/dist/collection/components/ez-calendar/ez-calendar.js +215 -215
  16. package/dist/collection/components/ez-check/ez-check.css +265 -265
  17. package/dist/collection/components/ez-check/ez-check.js +168 -168
  18. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +67 -67
  19. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -108
  20. package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -2
  21. package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -167
  22. package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -363
  23. package/dist/collection/components/ez-date-input/ez-date-input.css +38 -38
  24. package/dist/collection/components/ez-date-input/ez-date-input.js +172 -172
  25. package/dist/collection/components/ez-form/ez-form.css +19 -19
  26. package/dist/collection/components/ez-form/ez-form.js +368 -365
  27. package/dist/collection/components/ez-form/store/Form.actions.js +132 -132
  28. package/dist/collection/components/ez-form/store/Form.reducer.js +194 -194
  29. package/dist/collection/components/ez-form/store/Form.selectors.js +44 -44
  30. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +251 -204
  31. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -16
  32. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +23 -23
  33. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -173
  34. package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -14
  35. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -71
  36. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -27
  37. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -40
  38. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -27
  39. package/dist/collection/components/ez-icon/ez-icon.css +36 -36
  40. package/dist/collection/components/ez-icon/ez-icon.js +56 -56
  41. package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -117
  42. package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -276
  43. package/dist/collection/components/ez-modal/ez-modal.css +86 -86
  44. package/dist/collection/components/ez-modal/ez-modal.js +224 -224
  45. package/dist/collection/components/ez-number-input/ez-number-input.css +144 -144
  46. package/dist/collection/components/ez-number-input/ez-number-input.js +465 -465
  47. package/dist/collection/components/ez-popover/ez-popover.css +38 -38
  48. package/dist/collection/components/ez-popover/ez-popover.js +323 -323
  49. package/dist/collection/components/ez-search/ez-search.css +295 -295
  50. package/dist/collection/components/ez-search/ez-search.js +527 -527
  51. package/dist/collection/components/ez-tabselector/ez-tabselector.css +125 -125
  52. package/dist/collection/components/ez-tabselector/ez-tabselector.js +283 -283
  53. package/dist/collection/components/ez-text-area/ez-text-area.css +139 -139
  54. package/dist/collection/components/ez-text-area/ez-text-area.js +267 -267
  55. package/dist/collection/components/ez-text-input/ez-text-input.css +169 -169
  56. package/dist/collection/components/ez-text-input/ez-text-input.js +395 -395
  57. package/dist/collection/components/ez-time-input/ez-time-input.css +155 -155
  58. package/dist/collection/components/ez-time-input/ez-time-input.js +326 -326
  59. package/dist/collection/index.js +1 -1
  60. package/dist/collection/servidor.js +100 -100
  61. package/dist/collection/utils/FloatingManager.js +15 -15
  62. package/dist/collection/utils/utils.js +6 -6
  63. package/dist/custom-elements/index.js +3125 -3075
  64. package/dist/esm/{DataUnit-ac4cc054.js → DataUnit-d5d4c9a3.js} +415 -368
  65. package/dist/esm/ez-action-chip.entry.js +41 -41
  66. package/dist/esm/ez-button_14.entry.js +1911 -1908
  67. package/dist/esm/ez-label-chip.entry.js +120 -120
  68. package/dist/esm/ez-modal.entry.js +104 -104
  69. package/dist/esm/ez-number-input.entry.js +236 -236
  70. package/dist/esm/ez-time-input.entry.js +168 -168
  71. package/dist/esm/form-metadata.entry.js +65 -65
  72. package/dist/esm/polyfills/core-js.js +0 -0
  73. package/dist/esm/polyfills/dom.js +0 -0
  74. package/dist/esm/polyfills/es5-html-element.js +0 -0
  75. package/dist/esm/polyfills/index.js +0 -0
  76. package/dist/esm/polyfills/system.js +0 -0
  77. package/dist/ezui/ezui.esm.js +1 -1
  78. package/dist/ezui/{p-f95e3c71.entry.js → p-0fcdfb51.entry.js} +1 -1
  79. package/dist/ezui/p-dac7a6c2.js +1 -0
  80. package/dist/ezui/{p-346050cf.entry.js → p-dbef7060.entry.js} +1 -1
  81. package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
  82. package/dist/types/components/ez-button/ez-button.d.ts +20 -20
  83. package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
  84. package/dist/types/components/ez-check/ez-check.d.ts +32 -32
  85. package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
  86. package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
  87. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
  88. package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
  89. package/dist/types/components/ez-form/ez-form.d.ts +26 -31
  90. package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -111
  91. package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -20
  92. package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -14
  93. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +60 -55
  94. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
  95. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
  96. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
  97. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
  98. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
  99. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
  100. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -17
  101. package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
  102. package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
  103. package/dist/types/components/ez-modal/ez-modal.d.ts +32 -32
  104. package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
  105. package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
  106. package/dist/types/components/ez-search/ez-search.d.ts +95 -95
  107. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
  108. package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
  109. package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
  110. package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
  111. package/dist/types/index.d.ts +1 -1
  112. package/dist/types/utils/utils.d.ts +2 -2
  113. package/package.json +114 -114
  114. package/dist/ezui/p-593c03ba.js +0 -1
  115. package/react/components.d.ts +0 -22
  116. package/react/components.js +0 -25
  117. package/react/components.js.map +0 -1
  118. package/react/react-component-lib/createComponent.d.ts +0 -10
  119. package/react/react-component-lib/createComponent.js +0 -59
  120. package/react/react-component-lib/createComponent.js.map +0 -1
  121. package/react/react-component-lib/createOverlayComponent.d.ts +0 -20
  122. package/react/react-component-lib/createOverlayComponent.js +0 -89
  123. package/react/react-component-lib/createOverlayComponent.js.map +0 -1
  124. package/react/react-component-lib/index.d.ts +0 -2
  125. package/react/react-component-lib/index.js +0 -3
  126. package/react/react-component-lib/index.js.map +0 -1
  127. package/react/react-component-lib/interfaces.d.ts +0 -29
  128. package/react/react-component-lib/interfaces.js +0 -1
  129. package/react/react-component-lib/interfaces.js.map +0 -1
  130. package/react/react-component-lib/utils/attachProps.d.ts +0 -12
  131. package/react/react-component-lib/utils/attachProps.js +0 -96
  132. package/react/react-component-lib/utils/attachProps.js.map +0 -1
  133. package/react/react-component-lib/utils/case.d.ts +0 -2
  134. package/react/react-component-lib/utils/case.js +0 -7
  135. package/react/react-component-lib/utils/case.js.map +0 -1
  136. package/react/react-component-lib/utils/dev.d.ts +0 -2
  137. package/react/react-component-lib/utils/dev.js +0 -13
  138. package/react/react-component-lib/utils/dev.js.map +0 -1
  139. package/react/react-component-lib/utils/index.d.ts +0 -7
  140. package/react/react-component-lib/utils/index.js +0 -21
  141. package/react/react-component-lib/utils/index.js.map +0 -1
@@ -1,365 +1,368 @@
1
- import { Component, h, Element, forceUpdate, Prop, Method } from '@stencil/core';
2
- import { createStore, applyMiddleware, combineReducers } from 'redux';
3
- import thunk from 'redux-thunk';
4
- import { formLoad, invalidField, showHideNavigationButtons } from './store/Form.actions';
5
- import undoable from 'redux-undo';
6
- import formReducer, { formNonHistoricReducer } from './store/Form.reducer';
7
- import { FormSheet } from './subcomponents/structure/FormSheet';
8
- import DataUnit from './subcomponents/DataUnit';
9
- export class EzForm {
10
- constructor() {
11
- this._dataUnits = [];
12
- this._requiredFieldsByDU = {};
13
- }
14
- async validate() {
15
- for (let i = 0; i < this._dataUnits.length; i++) {
16
- if (!this._dataUnits[i].validateRecords()) {
17
- return false;
18
- }
19
- }
20
- }
21
- async getChanges() {
22
- let allChanges = [];
23
- for (let i = 0; i < this._dataUnits.length; i++) {
24
- allChanges = allChanges.concat(this._dataUnits[i].getChangesToSave());
25
- }
26
- return allChanges;
27
- }
28
- validateRecords(dataUnit, records) {
29
- const result = { isValid: true, message: '' };
30
- const reqFields = this._requiredFieldsByDU[dataUnit.name];
31
- const recordValidator = record => {
32
- reqFields.forEach(field => {
33
- const recordIndex = record["record__index"];
34
- const fieldName = field.name;
35
- const fieldValue = record[fieldName];
36
- if (fieldValue === null || fieldValue === undefined || fieldValue === '') {
37
- this._store.dispatch(invalidField(field.tabControler, field.tabIndex, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
38
- result.isValid = false;
39
- result.message = "Há pelo menos um campo obrigatório não preenchido.";
40
- }
41
- });
42
- };
43
- if (records.length == 0) {
44
- recordValidator({});
45
- }
46
- else {
47
- records.forEach(recordValidator);
48
- }
49
- return result;
50
- }
51
- componentWillRender() {
52
- if (this._store === undefined) {
53
- const rootReducer = combineReducers({
54
- "hist": undoable(formReducer),
55
- "nonhist": formNonHistoricReducer
56
- });
57
- this._store = createStore(rootReducer, applyMiddleware(thunk));
58
- this._store.subscribe(() => { forceUpdate(this); });
59
- if (this.slavemode) {
60
- this._store.dispatch(showHideNavigationButtons("saveVisible", false));
61
- this._store.dispatch(showHideNavigationButtons("cancelVisible", false));
62
- this._store.dispatch(showHideNavigationButtons("reloadVisible", false));
63
- }
64
- }
65
- }
66
- loadMDFromExecutor(callBack) {
67
- if (this._loadMetadataFunction) {
68
- const result = this._loadMetadataFunction();
69
- if (result) {
70
- if (result instanceof Promise) {
71
- result.then(md => {
72
- callBack(md);
73
- });
74
- }
75
- else {
76
- callBack(result);
77
- }
78
- }
79
- }
80
- }
81
- loadMDFromElement(callBack) {
82
- const metadata = [];
83
- Array.from(this._host.children).forEach(elem => {
84
- if (elem.tagName === "FORM-METADATA") {
85
- const formMetadata = elem;
86
- metadata.push(formMetadata.metadata);
87
- }
88
- });
89
- callBack(metadata.length > 0 ? metadata : null);
90
- }
91
- updateMetadata(metadata) {
92
- if (metadata) {
93
- const processFields = (duName, form, tabController, tabIndex) => {
94
- var _a;
95
- let requiredFields = this._requiredFieldsByDU[duName];
96
- if (requiredFields === undefined) {
97
- requiredFields = [];
98
- this._requiredFieldsByDU[duName] = requiredFields;
99
- }
100
- form.items.forEach(item => {
101
- if ("fields" in item) {
102
- const fSet = item;
103
- fSet.fields.forEach(f => {
104
- f.tabControler = tabController;
105
- f.tabIndex = tabIndex;
106
- if (f.required) {
107
- requiredFields.push(f);
108
- }
109
- });
110
- }
111
- else {
112
- const f = item;
113
- f.tabControler = tabController;
114
- f.tabIndex = tabIndex;
115
- if (f.required) {
116
- requiredFields.push(f);
117
- }
118
- }
119
- });
120
- (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
121
- const subDU = subForm.dataUnit ? subForm.dataUnit.name : duName;
122
- processFields(subDU, subForm, form.name, index);
123
- });
124
- };
125
- this.metadata = metadata;
126
- metadata.map((form, index) => {
127
- processFields(form.dataUnit.name, form, "__MAIN__FORM__", index);
128
- });
129
- this._store.dispatch(formLoad());
130
- }
131
- }
132
- parseExecutor(executor) {
133
- if (executor) {
134
- return executor instanceof Function ? executor : eval(executor);
135
- }
136
- return null;
137
- }
138
- componentDidLoad() {
139
- this._loadMetadataFunction = this.parseExecutor(this.metadataexecutor);
140
- this._loadDataFunction = this.parseExecutor(this.loadexecutor);
141
- this._saveFunction = this.parseExecutor(this.saveexecutor);
142
- this._removeFunction = this.parseExecutor(this.removeexecutor);
143
- this._fieldSearchFunction = this.parseExecutor(this.fieldsearchexecutor);
144
- if (this.metadata) {
145
- this.updateMetadata(this.metadata);
146
- }
147
- else {
148
- this.loadMDFromElement((md) => this.updateMetadata(md));
149
- if (!this.metadata) {
150
- this.loadMDFromExecutor((md) => this.updateMetadata(md));
151
- }
152
- }
153
- }
154
- buildDataUnit(dataUnit) {
155
- if (dataUnit) {
156
- const { name, unitLabel, records, cardinality } = dataUnit;
157
- if (!(dataUnit instanceof DataUnit)) {
158
- dataUnit = new DataUnit(name, unitLabel, cardinality);
159
- this._dataUnits.push(dataUnit);
160
- if (records) {
161
- dataUnit.records = records;
162
- }
163
- dataUnit.store = this._store;
164
- dataUnit.loadExecutor = this._loadDataFunction;
165
- dataUnit.saveExecutor = this._saveFunction;
166
- dataUnit.removeExecutor = this._removeFunction;
167
- dataUnit.recordsValidator = this;
168
- dataUnit.fieldSearchExecutor = this._fieldSearchFunction;
169
- }
170
- }
171
- return dataUnit;
172
- }
173
- render() {
174
- return this.metadata ? h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du) => this.buildDataUnit(du) }) : null;
175
- }
176
- static get is() { return "ez-form"; }
177
- static get originalStyleUrls() { return {
178
- "$": ["ez-form.css"]
179
- }; }
180
- static get styleUrls() { return {
181
- "$": ["ez-form.css"]
182
- }; }
183
- static get properties() { return {
184
- "metadataexecutor": {
185
- "type": "string",
186
- "mutable": false,
187
- "complexType": {
188
- "original": "string | Function",
189
- "resolved": "Function | string",
190
- "references": {
191
- "Function": {
192
- "location": "global"
193
- }
194
- }
195
- },
196
- "required": false,
197
- "optional": false,
198
- "docs": {
199
- "tags": [],
200
- "text": ""
201
- },
202
- "attribute": "metadataexecutor",
203
- "reflect": false
204
- },
205
- "loadexecutor": {
206
- "type": "string",
207
- "mutable": false,
208
- "complexType": {
209
- "original": "string | Function",
210
- "resolved": "Function | string",
211
- "references": {
212
- "Function": {
213
- "location": "global"
214
- }
215
- }
216
- },
217
- "required": false,
218
- "optional": false,
219
- "docs": {
220
- "tags": [],
221
- "text": ""
222
- },
223
- "attribute": "loadexecutor",
224
- "reflect": false
225
- },
226
- "saveexecutor": {
227
- "type": "string",
228
- "mutable": false,
229
- "complexType": {
230
- "original": "string | Function",
231
- "resolved": "Function | string",
232
- "references": {
233
- "Function": {
234
- "location": "global"
235
- }
236
- }
237
- },
238
- "required": false,
239
- "optional": false,
240
- "docs": {
241
- "tags": [],
242
- "text": ""
243
- },
244
- "attribute": "saveexecutor",
245
- "reflect": false
246
- },
247
- "removeexecutor": {
248
- "type": "string",
249
- "mutable": false,
250
- "complexType": {
251
- "original": "string | Function",
252
- "resolved": "Function | string",
253
- "references": {
254
- "Function": {
255
- "location": "global"
256
- }
257
- }
258
- },
259
- "required": false,
260
- "optional": false,
261
- "docs": {
262
- "tags": [],
263
- "text": ""
264
- },
265
- "attribute": "removeexecutor",
266
- "reflect": false
267
- },
268
- "fieldsearchexecutor": {
269
- "type": "string",
270
- "mutable": false,
271
- "complexType": {
272
- "original": "string | Function",
273
- "resolved": "Function | string",
274
- "references": {
275
- "Function": {
276
- "location": "global"
277
- }
278
- }
279
- },
280
- "required": false,
281
- "optional": false,
282
- "docs": {
283
- "tags": [],
284
- "text": ""
285
- },
286
- "attribute": "fieldsearchexecutor",
287
- "reflect": false
288
- },
289
- "metadata": {
290
- "type": "unknown",
291
- "mutable": true,
292
- "complexType": {
293
- "original": "Array<Form>",
294
- "resolved": "Form[]",
295
- "references": {
296
- "Array": {
297
- "location": "global"
298
- },
299
- "Form": {
300
- "location": "import",
301
- "path": "./subcomponents/FormMetadata"
302
- }
303
- }
304
- },
305
- "required": false,
306
- "optional": false,
307
- "docs": {
308
- "tags": [],
309
- "text": ""
310
- }
311
- },
312
- "slavemode": {
313
- "type": "boolean",
314
- "mutable": false,
315
- "complexType": {
316
- "original": "boolean",
317
- "resolved": "boolean",
318
- "references": {}
319
- },
320
- "required": false,
321
- "optional": false,
322
- "docs": {
323
- "tags": [],
324
- "text": ""
325
- },
326
- "attribute": "slavemode",
327
- "reflect": false
328
- }
329
- }; }
330
- static get methods() { return {
331
- "validate": {
332
- "complexType": {
333
- "signature": "() => Promise<boolean>",
334
- "parameters": [],
335
- "references": {
336
- "Promise": {
337
- "location": "global"
338
- }
339
- },
340
- "return": "Promise<boolean>"
341
- },
342
- "docs": {
343
- "text": "",
344
- "tags": []
345
- }
346
- },
347
- "getChanges": {
348
- "complexType": {
349
- "signature": "() => Promise<any[]>",
350
- "parameters": [],
351
- "references": {
352
- "Promise": {
353
- "location": "global"
354
- }
355
- },
356
- "return": "Promise<any[]>"
357
- },
358
- "docs": {
359
- "text": "",
360
- "tags": []
361
- }
362
- }
363
- }; }
364
- static get elementRef() { return "_host"; }
365
- }
1
+ import { Component, h, Element, forceUpdate, Prop, Method } from '@stencil/core';
2
+ import { createStore, applyMiddleware, combineReducers } from 'redux';
3
+ import thunk from 'redux-thunk';
4
+ import { formLoad, invalidField, showHideNavigationButtons } from './store/Form.actions';
5
+ import undoable from 'redux-undo';
6
+ import formReducer, { formNonHistoricReducer } from './store/Form.reducer';
7
+ import { FormSheet } from './subcomponents/structure/FormSheet';
8
+ import DataUnit from './subcomponents/DataUnit';
9
+ export class EzForm {
10
+ constructor() {
11
+ this._dataUnits = [];
12
+ this._requiredFieldsByDU = {};
13
+ }
14
+ async validate() {
15
+ for (let i = 0; i < this._dataUnits.length; i++) {
16
+ if (!this._dataUnits[i].validateRecords()) {
17
+ return false;
18
+ }
19
+ }
20
+ }
21
+ async getChanges() {
22
+ let allChanges = [];
23
+ for (let i = 0; i < this._dataUnits.length; i++) {
24
+ const du = this._dataUnits[i];
25
+ //Só devemos buscar as alterações de DU raiz, pois os sub DUs serão enviados junto.
26
+ if (!du.parentDU) {
27
+ const duChanges = du.getChangesToSave();
28
+ if (duChanges) {
29
+ allChanges = allChanges.concat(duChanges);
30
+ }
31
+ }
32
+ }
33
+ return allChanges;
34
+ }
35
+ validateRecords(dataUnit, records) {
36
+ const result = { isValid: true, message: '' };
37
+ const reqFields = this._requiredFieldsByDU[dataUnit.name];
38
+ const recordValidator = record => {
39
+ reqFields.forEach(field => {
40
+ const recordIndex = record["record__index"];
41
+ const fieldName = field.name;
42
+ const fieldValue = record[fieldName];
43
+ if (fieldValue === null || fieldValue === undefined || fieldValue === '') {
44
+ this._store.dispatch(invalidField(field.tabControler, field.tabIndex, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
45
+ result.isValid = false;
46
+ result.message = "Há pelo menos um campo obrigatório não preenchido.";
47
+ }
48
+ });
49
+ };
50
+ if (records.length == 0) {
51
+ recordValidator({});
52
+ }
53
+ else {
54
+ records.forEach(recordValidator);
55
+ }
56
+ return result;
57
+ }
58
+ componentWillRender() {
59
+ if (this._store === undefined) {
60
+ const rootReducer = combineReducers({
61
+ "hist": undoable(formReducer),
62
+ "nonhist": formNonHistoricReducer
63
+ });
64
+ this._store = createStore(rootReducer, applyMiddleware(thunk));
65
+ this._store.subscribe(() => { forceUpdate(this); });
66
+ if (this.slavemode) {
67
+ this._store.dispatch(showHideNavigationButtons("saveVisible", false));
68
+ this._store.dispatch(showHideNavigationButtons("cancelVisible", false));
69
+ this._store.dispatch(showHideNavigationButtons("reloadVisible", false));
70
+ }
71
+ }
72
+ }
73
+ loadMDFromExecutor(callBack) {
74
+ const loadMetadataFunction = this.parseExecutor(this.metadataexecutor);
75
+ if (loadMetadataFunction) {
76
+ const result = loadMetadataFunction();
77
+ if (result) {
78
+ if (result instanceof Promise) {
79
+ result.then(md => {
80
+ callBack(md);
81
+ });
82
+ }
83
+ else {
84
+ callBack(result);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ loadMDFromElement(callBack) {
90
+ const metadata = [];
91
+ Array.from(this._host.children).forEach(elem => {
92
+ if (elem.tagName === "FORM-METADATA") {
93
+ const formMetadata = elem;
94
+ metadata.push(formMetadata.metadata);
95
+ }
96
+ });
97
+ callBack(metadata.length > 0 ? metadata : null);
98
+ }
99
+ updateMetadata(metadata) {
100
+ if (metadata) {
101
+ const processFields = (duName, form, tabController, tabIndex) => {
102
+ var _a;
103
+ let requiredFields = this._requiredFieldsByDU[duName];
104
+ if (requiredFields === undefined) {
105
+ requiredFields = [];
106
+ this._requiredFieldsByDU[duName] = requiredFields;
107
+ }
108
+ form.items.forEach(item => {
109
+ if ("fields" in item) {
110
+ const fSet = item;
111
+ fSet.fields.forEach(f => {
112
+ f.tabControler = tabController;
113
+ f.tabIndex = tabIndex;
114
+ if (f.required) {
115
+ requiredFields.push(f);
116
+ }
117
+ });
118
+ }
119
+ else {
120
+ const f = item;
121
+ f.tabControler = tabController;
122
+ f.tabIndex = tabIndex;
123
+ if (f.required) {
124
+ requiredFields.push(f);
125
+ }
126
+ }
127
+ });
128
+ (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
129
+ const subDU = subForm.dataUnit ? subForm.dataUnit.name : duName;
130
+ processFields(subDU, subForm, form.name, index);
131
+ });
132
+ };
133
+ this.metadata = metadata;
134
+ metadata.map((form, index) => {
135
+ processFields(form.dataUnit.name, form, "__MAIN__FORM__", index);
136
+ });
137
+ this._store.dispatch(formLoad());
138
+ }
139
+ }
140
+ parseExecutor(executor) {
141
+ if (executor) {
142
+ return executor instanceof Function ? executor : eval(executor);
143
+ }
144
+ return null;
145
+ }
146
+ componentDidLoad() {
147
+ if (this.metadata) {
148
+ this.updateMetadata(this.metadata);
149
+ }
150
+ else {
151
+ this.loadMDFromElement((md) => this.updateMetadata(md));
152
+ if (!this.metadata) {
153
+ this.loadMDFromExecutor((md) => this.updateMetadata(md));
154
+ }
155
+ }
156
+ }
157
+ buildDataUnit(dataUnit, parentDataUnit) {
158
+ if (dataUnit) {
159
+ const { name, unitLabel, records, cardinality } = dataUnit;
160
+ if (!(dataUnit instanceof DataUnit)) {
161
+ dataUnit = new DataUnit(name, unitLabel, cardinality, parentDataUnit);
162
+ this._dataUnits.push(dataUnit);
163
+ if (records) {
164
+ dataUnit.records = records;
165
+ }
166
+ dataUnit.store = this._store;
167
+ dataUnit.loadExecutor = this.parseExecutor(this.loadexecutor);
168
+ dataUnit.saveExecutor = this.parseExecutor(this.saveexecutor);
169
+ dataUnit.removeExecutor = this.parseExecutor(this.removeexecutor);
170
+ dataUnit.recordsValidator = this;
171
+ dataUnit.fieldSearchExecutor = this.parseExecutor(this.fieldsearchexecutor);
172
+ }
173
+ }
174
+ return dataUnit;
175
+ }
176
+ render() {
177
+ return this.metadata ? h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du, parentDataUnit) => this.buildDataUnit(du, parentDataUnit) }) : null;
178
+ }
179
+ static get is() { return "ez-form"; }
180
+ static get originalStyleUrls() { return {
181
+ "$": ["ez-form.css"]
182
+ }; }
183
+ static get styleUrls() { return {
184
+ "$": ["ez-form.css"]
185
+ }; }
186
+ static get properties() { return {
187
+ "metadataexecutor": {
188
+ "type": "string",
189
+ "mutable": false,
190
+ "complexType": {
191
+ "original": "string | Function",
192
+ "resolved": "Function | string",
193
+ "references": {
194
+ "Function": {
195
+ "location": "global"
196
+ }
197
+ }
198
+ },
199
+ "required": false,
200
+ "optional": false,
201
+ "docs": {
202
+ "tags": [],
203
+ "text": ""
204
+ },
205
+ "attribute": "metadataexecutor",
206
+ "reflect": false
207
+ },
208
+ "loadexecutor": {
209
+ "type": "string",
210
+ "mutable": false,
211
+ "complexType": {
212
+ "original": "string | Function",
213
+ "resolved": "Function | string",
214
+ "references": {
215
+ "Function": {
216
+ "location": "global"
217
+ }
218
+ }
219
+ },
220
+ "required": false,
221
+ "optional": false,
222
+ "docs": {
223
+ "tags": [],
224
+ "text": ""
225
+ },
226
+ "attribute": "loadexecutor",
227
+ "reflect": false
228
+ },
229
+ "saveexecutor": {
230
+ "type": "string",
231
+ "mutable": false,
232
+ "complexType": {
233
+ "original": "string | Function",
234
+ "resolved": "Function | string",
235
+ "references": {
236
+ "Function": {
237
+ "location": "global"
238
+ }
239
+ }
240
+ },
241
+ "required": false,
242
+ "optional": false,
243
+ "docs": {
244
+ "tags": [],
245
+ "text": ""
246
+ },
247
+ "attribute": "saveexecutor",
248
+ "reflect": false
249
+ },
250
+ "removeexecutor": {
251
+ "type": "string",
252
+ "mutable": false,
253
+ "complexType": {
254
+ "original": "string | Function",
255
+ "resolved": "Function | string",
256
+ "references": {
257
+ "Function": {
258
+ "location": "global"
259
+ }
260
+ }
261
+ },
262
+ "required": false,
263
+ "optional": false,
264
+ "docs": {
265
+ "tags": [],
266
+ "text": ""
267
+ },
268
+ "attribute": "removeexecutor",
269
+ "reflect": false
270
+ },
271
+ "fieldsearchexecutor": {
272
+ "type": "string",
273
+ "mutable": false,
274
+ "complexType": {
275
+ "original": "string | Function",
276
+ "resolved": "Function | string",
277
+ "references": {
278
+ "Function": {
279
+ "location": "global"
280
+ }
281
+ }
282
+ },
283
+ "required": false,
284
+ "optional": false,
285
+ "docs": {
286
+ "tags": [],
287
+ "text": ""
288
+ },
289
+ "attribute": "fieldsearchexecutor",
290
+ "reflect": false
291
+ },
292
+ "metadata": {
293
+ "type": "unknown",
294
+ "mutable": true,
295
+ "complexType": {
296
+ "original": "Array<Form>",
297
+ "resolved": "Form[]",
298
+ "references": {
299
+ "Array": {
300
+ "location": "global"
301
+ },
302
+ "Form": {
303
+ "location": "import",
304
+ "path": "./subcomponents/FormMetadata"
305
+ }
306
+ }
307
+ },
308
+ "required": false,
309
+ "optional": false,
310
+ "docs": {
311
+ "tags": [],
312
+ "text": ""
313
+ }
314
+ },
315
+ "slavemode": {
316
+ "type": "boolean",
317
+ "mutable": false,
318
+ "complexType": {
319
+ "original": "boolean",
320
+ "resolved": "boolean",
321
+ "references": {}
322
+ },
323
+ "required": false,
324
+ "optional": false,
325
+ "docs": {
326
+ "tags": [],
327
+ "text": ""
328
+ },
329
+ "attribute": "slavemode",
330
+ "reflect": false
331
+ }
332
+ }; }
333
+ static get methods() { return {
334
+ "validate": {
335
+ "complexType": {
336
+ "signature": "() => Promise<boolean>",
337
+ "parameters": [],
338
+ "references": {
339
+ "Promise": {
340
+ "location": "global"
341
+ }
342
+ },
343
+ "return": "Promise<boolean>"
344
+ },
345
+ "docs": {
346
+ "text": "",
347
+ "tags": []
348
+ }
349
+ },
350
+ "getChanges": {
351
+ "complexType": {
352
+ "signature": "() => Promise<any[]>",
353
+ "parameters": [],
354
+ "references": {
355
+ "Promise": {
356
+ "location": "global"
357
+ }
358
+ },
359
+ "return": "Promise<any[]>"
360
+ },
361
+ "docs": {
362
+ "text": "",
363
+ "tags": []
364
+ }
365
+ }
366
+ }; }
367
+ static get elementRef() { return "_host"; }
368
+ }