@sankhyalabs/ezui 2.3.7 → 2.3.8
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.
- package/dist/cjs/ez-form.cjs.entry.js +140 -130
- package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +4 -6
- package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +15 -2
- package/dist/custom-elements/index.js +140 -130
- package/dist/esm/ez-form.entry.js +140 -130
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-c869b682.entry.js +1 -0
- package/dist/types/components/ez-form/structure/FormSheetMetadata.d.ts +2 -0
- package/package.json +1 -1
- package/dist/ezui/p-642c530f.entry.js +0 -1
|
@@ -8,134 +8,6 @@ const CheckMode = require('./CheckMode-ecb90b87.js');
|
|
|
8
8
|
const ApplicationUtils = require('./ApplicationUtils-edc62c5c.js');
|
|
9
9
|
require('./DialogType-aa435c52.js');
|
|
10
10
|
|
|
11
|
-
const buildTextArea = ({ name, label, readOnly }) => {
|
|
12
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small", key: name },
|
|
13
|
-
index.h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const buildTextInput = ({ name, label, readOnly }) => {
|
|
17
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
18
|
-
index.h("ez-text-input", { label: label, "data-field-name": name, key: name, enabled: !readOnly })));
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const buildSwitch = (fieldConfig) => {
|
|
22
|
-
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, true);
|
|
23
|
-
};
|
|
24
|
-
const buildCheckBox = (fieldConfig) => {
|
|
25
|
-
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, false);
|
|
26
|
-
};
|
|
27
|
-
function buildField$1(fieldName, fieldLabel, readOnly, switchMode = false) {
|
|
28
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large" },
|
|
29
|
-
index.h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? CheckMode.CheckMode.SWITCH : CheckMode.CheckMode.REGULAR, "data-field-name": fieldName, key: fieldName })));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const buildComboBox = ({ name, label, readOnly, required }, properties) => {
|
|
33
|
-
const prop = properties === null || properties === void 0 ? void 0 : properties.options;
|
|
34
|
-
let options;
|
|
35
|
-
if (typeof prop === "string") {
|
|
36
|
-
const parsed = JSON.parse(prop);
|
|
37
|
-
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
options = prop;
|
|
41
|
-
}
|
|
42
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
43
|
-
index.h("ez-combo-box", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name, options: options })));
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const buildSearch = ({ name, label, readOnly, required }) => {
|
|
47
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
48
|
-
index.h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name })));
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const buildFile = ({ name, label, readOnly }) => {
|
|
52
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
|
|
53
|
-
index.h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const buildDate = ({ name, label, readOnly }) => {
|
|
57
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
58
|
-
index.h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
59
|
-
};
|
|
60
|
-
const buildTime = ({ name, label, readOnly }) => {
|
|
61
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
62
|
-
index.h("ez-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
63
|
-
};
|
|
64
|
-
const buildTimeDate = ({ name, label, readOnly }) => {
|
|
65
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
66
|
-
index.h("ez-date-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const buildDecimal = ({ name, label, readOnly }, properties) => {
|
|
70
|
-
const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
|
|
71
|
-
const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
|
|
72
|
-
return buildNumeric(name, label, readOnly, precision, prettyPrecision);
|
|
73
|
-
};
|
|
74
|
-
const buildInteger = ({ name, label, readOnly }) => {
|
|
75
|
-
return buildNumeric(name, label, readOnly, 0, 0);
|
|
76
|
-
};
|
|
77
|
-
function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
|
|
78
|
-
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
79
|
-
index.h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const uiBuilders = new Map();
|
|
83
|
-
uiBuilders.set(core.UserInterface.LONGTEXT, buildTextArea);
|
|
84
|
-
uiBuilders.set(core.UserInterface.CHECKBOX, buildCheckBox);
|
|
85
|
-
uiBuilders.set(core.UserInterface.SWITCH, buildSwitch);
|
|
86
|
-
uiBuilders.set(core.UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
87
|
-
uiBuilders.set(core.UserInterface.SEARCH, buildSearch);
|
|
88
|
-
uiBuilders.set(core.UserInterface.FILE, buildFile);
|
|
89
|
-
uiBuilders.set(core.UserInterface.DATE, buildDate);
|
|
90
|
-
uiBuilders.set(core.UserInterface.TIME, buildTime);
|
|
91
|
-
uiBuilders.set(core.UserInterface.DATETIME, buildTimeDate);
|
|
92
|
-
uiBuilders.set(core.UserInterface.DECIMALNUMBER, buildDecimal);
|
|
93
|
-
uiBuilders.set(core.UserInterface.INTEGERNUMBER, buildInteger);
|
|
94
|
-
const buildField = (field) => {
|
|
95
|
-
const descriptor = field.descriptor;
|
|
96
|
-
const config = Object.assign({}, field.config);
|
|
97
|
-
let builder;
|
|
98
|
-
let props;
|
|
99
|
-
if (descriptor) {
|
|
100
|
-
if (!config.label) {
|
|
101
|
-
config.label = descriptor.label;
|
|
102
|
-
}
|
|
103
|
-
if (!config.name) {
|
|
104
|
-
config.name = descriptor.name;
|
|
105
|
-
}
|
|
106
|
-
if (config.required == undefined || descriptor.required === true) {
|
|
107
|
-
config.required = descriptor.required;
|
|
108
|
-
}
|
|
109
|
-
if (config.readOnly == undefined || descriptor.readOnly === true) {
|
|
110
|
-
config.readOnly = descriptor.readOnly;
|
|
111
|
-
}
|
|
112
|
-
props = descriptor.properties;
|
|
113
|
-
builder = uiBuilders.get(descriptor.userInterface);
|
|
114
|
-
}
|
|
115
|
-
if (config.required) {
|
|
116
|
-
config.label = `${config.label} (obrigatório) *`;
|
|
117
|
-
}
|
|
118
|
-
if (!builder) {
|
|
119
|
-
builder = buildTextInput;
|
|
120
|
-
}
|
|
121
|
-
return builder(config, props);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const FormItem = ({ source }) => {
|
|
125
|
-
if ("items" in source) {
|
|
126
|
-
const fieldSet = source;
|
|
127
|
-
return index.h("ez-collapsible-box", { label: source.label, "header-size": "large" }, fieldSet.items.map(fi => buildField(fi)));
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
return buildField(source);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const FormSheet = ({ store, source, dataElementId }) => {
|
|
135
|
-
return (index.h("div", { class: "dynamic-content ez-box__container", "data-element-id": dataElementId },
|
|
136
|
-
index.h("div", { class: "ez-row ez-padding-vertical--small" }, source.items.map(item => index.h(FormItem, { store: store, source: item })))));
|
|
137
|
-
};
|
|
138
|
-
|
|
139
11
|
class FormMetadata {
|
|
140
12
|
constructor() {
|
|
141
13
|
this._sheets = new Map();
|
|
@@ -165,6 +37,20 @@ class FormMetadata {
|
|
|
165
37
|
return this._defaultValues;
|
|
166
38
|
}
|
|
167
39
|
}
|
|
40
|
+
const isRequiredField = (descriptor, config) => {
|
|
41
|
+
if (descriptor.required) {
|
|
42
|
+
//Se for required pelo descritor não olha pra configuração.
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return config === null || config === void 0 ? void 0 : config.required;
|
|
46
|
+
};
|
|
47
|
+
const isReadOnlyField = (descriptor, config) => {
|
|
48
|
+
if (descriptor.readOnly) {
|
|
49
|
+
//Se for readOnly pelo descritor não olha pra configuração.
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return config === null || config === void 0 ? void 0 : config.readOnly;
|
|
53
|
+
};
|
|
168
54
|
const buildFromDataUnit = (dataUnit) => {
|
|
169
55
|
var _a, _b;
|
|
170
56
|
const unitMD = dataUnit.metadata;
|
|
@@ -244,8 +130,7 @@ const buildFromConfig = (config, dataUnit) => {
|
|
|
244
130
|
sheets.set(tabConfig, new Map());
|
|
245
131
|
}
|
|
246
132
|
const tabItens = sheets.get(tabConfig);
|
|
247
|
-
|
|
248
|
-
if (isRequired) {
|
|
133
|
+
if (isRequiredField(descriptor, field)) {
|
|
249
134
|
requiredFields.push(field.name);
|
|
250
135
|
}
|
|
251
136
|
const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
|
|
@@ -276,6 +161,131 @@ const buildFromConfig = (config, dataUnit) => {
|
|
|
276
161
|
return metadata;
|
|
277
162
|
};
|
|
278
163
|
|
|
164
|
+
const buildTextArea = ({ name, label, readOnly }) => {
|
|
165
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small", key: name },
|
|
166
|
+
index.h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const buildTextInput = ({ name, label, readOnly }) => {
|
|
170
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
171
|
+
index.h("ez-text-input", { label: label, "data-field-name": name, key: name, enabled: !readOnly })));
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const buildSwitch = (fieldConfig) => {
|
|
175
|
+
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, true);
|
|
176
|
+
};
|
|
177
|
+
const buildCheckBox = (fieldConfig) => {
|
|
178
|
+
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, false);
|
|
179
|
+
};
|
|
180
|
+
function buildField$1(fieldName, fieldLabel, readOnly, switchMode = false) {
|
|
181
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large" },
|
|
182
|
+
index.h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? CheckMode.CheckMode.SWITCH : CheckMode.CheckMode.REGULAR, "data-field-name": fieldName, key: fieldName })));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const buildComboBox = ({ name, label, readOnly, required }, properties) => {
|
|
186
|
+
const prop = properties === null || properties === void 0 ? void 0 : properties.options;
|
|
187
|
+
let options;
|
|
188
|
+
if (typeof prop === "string") {
|
|
189
|
+
const parsed = JSON.parse(prop);
|
|
190
|
+
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
options = prop;
|
|
194
|
+
}
|
|
195
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
196
|
+
index.h("ez-combo-box", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name, options: options })));
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const buildSearch = ({ name, label, readOnly, required }) => {
|
|
200
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
201
|
+
index.h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name })));
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const buildFile = ({ name, label, readOnly }) => {
|
|
205
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
|
|
206
|
+
index.h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const buildDate = ({ name, label, readOnly }) => {
|
|
210
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
211
|
+
index.h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
212
|
+
};
|
|
213
|
+
const buildTime = ({ name, label, readOnly }) => {
|
|
214
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
215
|
+
index.h("ez-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
216
|
+
};
|
|
217
|
+
const buildTimeDate = ({ name, label, readOnly }) => {
|
|
218
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
219
|
+
index.h("ez-date-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const buildDecimal = ({ name, label, readOnly }, properties) => {
|
|
223
|
+
const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
|
|
224
|
+
const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
|
|
225
|
+
return buildNumeric(name, label, readOnly, precision, prettyPrecision);
|
|
226
|
+
};
|
|
227
|
+
const buildInteger = ({ name, label, readOnly }) => {
|
|
228
|
+
return buildNumeric(name, label, readOnly, 0, 0);
|
|
229
|
+
};
|
|
230
|
+
function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
|
|
231
|
+
return (index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
232
|
+
index.h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const uiBuilders = new Map();
|
|
236
|
+
uiBuilders.set(core.UserInterface.LONGTEXT, buildTextArea);
|
|
237
|
+
uiBuilders.set(core.UserInterface.CHECKBOX, buildCheckBox);
|
|
238
|
+
uiBuilders.set(core.UserInterface.SWITCH, buildSwitch);
|
|
239
|
+
uiBuilders.set(core.UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
240
|
+
uiBuilders.set(core.UserInterface.SEARCH, buildSearch);
|
|
241
|
+
uiBuilders.set(core.UserInterface.FILE, buildFile);
|
|
242
|
+
uiBuilders.set(core.UserInterface.DATE, buildDate);
|
|
243
|
+
uiBuilders.set(core.UserInterface.TIME, buildTime);
|
|
244
|
+
uiBuilders.set(core.UserInterface.DATETIME, buildTimeDate);
|
|
245
|
+
uiBuilders.set(core.UserInterface.DECIMALNUMBER, buildDecimal);
|
|
246
|
+
uiBuilders.set(core.UserInterface.INTEGERNUMBER, buildInteger);
|
|
247
|
+
const buildField = (field) => {
|
|
248
|
+
const descriptor = field.descriptor;
|
|
249
|
+
const config = Object.assign({}, field.config);
|
|
250
|
+
let builder;
|
|
251
|
+
let props;
|
|
252
|
+
if (descriptor) {
|
|
253
|
+
if (!config.label) {
|
|
254
|
+
config.label = descriptor.label;
|
|
255
|
+
}
|
|
256
|
+
if (!config.name) {
|
|
257
|
+
config.name = descriptor.name;
|
|
258
|
+
}
|
|
259
|
+
// Forçamos uma avaliação priorizando o descriptor.
|
|
260
|
+
config.required = isRequiredField(descriptor, config);
|
|
261
|
+
config.readOnly = isReadOnlyField(descriptor, config);
|
|
262
|
+
props = descriptor.properties;
|
|
263
|
+
builder = uiBuilders.get(descriptor.userInterface);
|
|
264
|
+
}
|
|
265
|
+
if (config.required) {
|
|
266
|
+
config.label = `${config.label} (obrigatório) *`;
|
|
267
|
+
}
|
|
268
|
+
if (!builder) {
|
|
269
|
+
builder = buildTextInput;
|
|
270
|
+
}
|
|
271
|
+
return builder(config, props);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const FormItem = ({ source }) => {
|
|
275
|
+
if ("items" in source) {
|
|
276
|
+
const fieldSet = source;
|
|
277
|
+
return index.h("ez-collapsible-box", { label: source.label, "header-size": "large" }, fieldSet.items.map(fi => buildField(fi)));
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
return buildField(source);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const FormSheet = ({ store, source, dataElementId }) => {
|
|
285
|
+
return (index.h("div", { class: "dynamic-content ez-box__container", "data-element-id": dataElementId },
|
|
286
|
+
index.h("div", { class: "ez-row ez-padding-vertical--small" }, source.items.map(item => index.h(FormItem, { store: store, source: item })))));
|
|
287
|
+
};
|
|
288
|
+
|
|
279
289
|
/**
|
|
280
290
|
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
|
281
291
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UserInterface } from "@sankhyalabs/core";
|
|
2
|
+
import { isReadOnlyField, isRequiredField } from "../structure/FormSheetMetadata";
|
|
2
3
|
import { buildTextArea } from "./tpl/TextArea.tpl";
|
|
3
4
|
import { buildTextInput } from "./tpl/TextInput.tpl";
|
|
4
5
|
import { buildCheckBox, buildSwitch } from "./tpl/CheckBox.tpl";
|
|
@@ -31,12 +32,9 @@ export const buildField = (field) => {
|
|
|
31
32
|
if (!config.name) {
|
|
32
33
|
config.name = descriptor.name;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (config.readOnly == undefined || descriptor.readOnly === true) {
|
|
38
|
-
config.readOnly = descriptor.readOnly;
|
|
39
|
-
}
|
|
35
|
+
// Forçamos uma avaliação priorizando o descriptor.
|
|
36
|
+
config.required = isRequiredField(descriptor, config);
|
|
37
|
+
config.readOnly = isReadOnlyField(descriptor, config);
|
|
40
38
|
props = descriptor.properties;
|
|
41
39
|
builder = uiBuilders.get(descriptor.userInterface);
|
|
42
40
|
}
|
|
@@ -27,6 +27,20 @@ export class FormMetadata {
|
|
|
27
27
|
return this._defaultValues;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
export const isRequiredField = (descriptor, config) => {
|
|
31
|
+
if (descriptor.required) {
|
|
32
|
+
//Se for required pelo descritor não olha pra configuração.
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return config === null || config === void 0 ? void 0 : config.required;
|
|
36
|
+
};
|
|
37
|
+
export const isReadOnlyField = (descriptor, config) => {
|
|
38
|
+
if (descriptor.readOnly) {
|
|
39
|
+
//Se for readOnly pelo descritor não olha pra configuração.
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return config === null || config === void 0 ? void 0 : config.readOnly;
|
|
43
|
+
};
|
|
30
44
|
export const buildFromDataUnit = (dataUnit) => {
|
|
31
45
|
var _a, _b;
|
|
32
46
|
const unitMD = dataUnit.metadata;
|
|
@@ -106,8 +120,7 @@ export const buildFromConfig = (config, dataUnit) => {
|
|
|
106
120
|
sheets.set(tabConfig, new Map());
|
|
107
121
|
}
|
|
108
122
|
const tabItens = sheets.get(tabConfig);
|
|
109
|
-
|
|
110
|
-
if (isRequired) {
|
|
123
|
+
if (isRequiredField(descriptor, field)) {
|
|
111
124
|
requiredFields.push(field.name);
|
|
112
125
|
}
|
|
113
126
|
const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
|
|
@@ -2022,134 +2022,6 @@ let EzFilterInput$1 = class extends HTMLElement$1 {
|
|
|
2022
2022
|
static get style() { return ezFilterInputCss; }
|
|
2023
2023
|
};
|
|
2024
2024
|
|
|
2025
|
-
const buildTextArea = ({ name, label, readOnly }) => {
|
|
2026
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small", key: name },
|
|
2027
|
-
h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
|
|
2028
|
-
};
|
|
2029
|
-
|
|
2030
|
-
const buildTextInput = ({ name, label, readOnly }) => {
|
|
2031
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2032
|
-
h("ez-text-input", { label: label, "data-field-name": name, key: name, enabled: !readOnly })));
|
|
2033
|
-
};
|
|
2034
|
-
|
|
2035
|
-
const buildSwitch = (fieldConfig) => {
|
|
2036
|
-
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, true);
|
|
2037
|
-
};
|
|
2038
|
-
const buildCheckBox = (fieldConfig) => {
|
|
2039
|
-
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, false);
|
|
2040
|
-
};
|
|
2041
|
-
function buildField$1(fieldName, fieldLabel, readOnly, switchMode = false) {
|
|
2042
|
-
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" },
|
|
2043
|
-
h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? CheckMode.SWITCH : CheckMode.REGULAR, "data-field-name": fieldName, key: fieldName })));
|
|
2044
|
-
}
|
|
2045
|
-
|
|
2046
|
-
const buildComboBox = ({ name, label, readOnly, required }, properties) => {
|
|
2047
|
-
const prop = properties === null || properties === void 0 ? void 0 : properties.options;
|
|
2048
|
-
let options;
|
|
2049
|
-
if (typeof prop === "string") {
|
|
2050
|
-
const parsed = JSON.parse(prop);
|
|
2051
|
-
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
2052
|
-
}
|
|
2053
|
-
else {
|
|
2054
|
-
options = prop;
|
|
2055
|
-
}
|
|
2056
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2057
|
-
h("ez-combo-box", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name, options: options })));
|
|
2058
|
-
};
|
|
2059
|
-
|
|
2060
|
-
const buildSearch = ({ name, label, readOnly, required }) => {
|
|
2061
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2062
|
-
h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name })));
|
|
2063
|
-
};
|
|
2064
|
-
|
|
2065
|
-
const buildFile = ({ name, label, readOnly }) => {
|
|
2066
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
|
|
2067
|
-
h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
2068
|
-
};
|
|
2069
|
-
|
|
2070
|
-
const buildDate = ({ name, label, readOnly }) => {
|
|
2071
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2072
|
-
h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
2073
|
-
};
|
|
2074
|
-
const buildTime = ({ name, label, readOnly }) => {
|
|
2075
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2076
|
-
h("ez-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
2077
|
-
};
|
|
2078
|
-
const buildTimeDate = ({ name, label, readOnly }) => {
|
|
2079
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2080
|
-
h("ez-date-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
2081
|
-
};
|
|
2082
|
-
|
|
2083
|
-
const buildDecimal = ({ name, label, readOnly }, properties) => {
|
|
2084
|
-
const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
|
|
2085
|
-
const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
|
|
2086
|
-
return buildNumeric(name, label, readOnly, precision, prettyPrecision);
|
|
2087
|
-
};
|
|
2088
|
-
const buildInteger = ({ name, label, readOnly }) => {
|
|
2089
|
-
return buildNumeric(name, label, readOnly, 0, 0);
|
|
2090
|
-
};
|
|
2091
|
-
function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
|
|
2092
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2093
|
-
h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
const uiBuilders = new Map();
|
|
2097
|
-
uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
|
|
2098
|
-
uiBuilders.set(UserInterface.CHECKBOX, buildCheckBox);
|
|
2099
|
-
uiBuilders.set(UserInterface.SWITCH, buildSwitch);
|
|
2100
|
-
uiBuilders.set(UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
2101
|
-
uiBuilders.set(UserInterface.SEARCH, buildSearch);
|
|
2102
|
-
uiBuilders.set(UserInterface.FILE, buildFile);
|
|
2103
|
-
uiBuilders.set(UserInterface.DATE, buildDate);
|
|
2104
|
-
uiBuilders.set(UserInterface.TIME, buildTime);
|
|
2105
|
-
uiBuilders.set(UserInterface.DATETIME, buildTimeDate);
|
|
2106
|
-
uiBuilders.set(UserInterface.DECIMALNUMBER, buildDecimal);
|
|
2107
|
-
uiBuilders.set(UserInterface.INTEGERNUMBER, buildInteger);
|
|
2108
|
-
const buildField = (field) => {
|
|
2109
|
-
const descriptor = field.descriptor;
|
|
2110
|
-
const config = Object.assign({}, field.config);
|
|
2111
|
-
let builder;
|
|
2112
|
-
let props;
|
|
2113
|
-
if (descriptor) {
|
|
2114
|
-
if (!config.label) {
|
|
2115
|
-
config.label = descriptor.label;
|
|
2116
|
-
}
|
|
2117
|
-
if (!config.name) {
|
|
2118
|
-
config.name = descriptor.name;
|
|
2119
|
-
}
|
|
2120
|
-
if (config.required == undefined || descriptor.required === true) {
|
|
2121
|
-
config.required = descriptor.required;
|
|
2122
|
-
}
|
|
2123
|
-
if (config.readOnly == undefined || descriptor.readOnly === true) {
|
|
2124
|
-
config.readOnly = descriptor.readOnly;
|
|
2125
|
-
}
|
|
2126
|
-
props = descriptor.properties;
|
|
2127
|
-
builder = uiBuilders.get(descriptor.userInterface);
|
|
2128
|
-
}
|
|
2129
|
-
if (config.required) {
|
|
2130
|
-
config.label = `${config.label} (obrigatório) *`;
|
|
2131
|
-
}
|
|
2132
|
-
if (!builder) {
|
|
2133
|
-
builder = buildTextInput;
|
|
2134
|
-
}
|
|
2135
|
-
return builder(config, props);
|
|
2136
|
-
};
|
|
2137
|
-
|
|
2138
|
-
const FormItem = ({ source }) => {
|
|
2139
|
-
if ("items" in source) {
|
|
2140
|
-
const fieldSet = source;
|
|
2141
|
-
return h("ez-collapsible-box", { label: source.label, "header-size": "large" }, fieldSet.items.map(fi => buildField(fi)));
|
|
2142
|
-
}
|
|
2143
|
-
else {
|
|
2144
|
-
return buildField(source);
|
|
2145
|
-
}
|
|
2146
|
-
};
|
|
2147
|
-
|
|
2148
|
-
const FormSheet = ({ store, source, dataElementId }) => {
|
|
2149
|
-
return (h("div", { class: "dynamic-content ez-box__container", "data-element-id": dataElementId },
|
|
2150
|
-
h("div", { class: "ez-row ez-padding-vertical--small" }, source.items.map(item => h(FormItem, { store: store, source: item })))));
|
|
2151
|
-
};
|
|
2152
|
-
|
|
2153
2025
|
class FormMetadata {
|
|
2154
2026
|
constructor() {
|
|
2155
2027
|
this._sheets = new Map();
|
|
@@ -2179,6 +2051,20 @@ class FormMetadata {
|
|
|
2179
2051
|
return this._defaultValues;
|
|
2180
2052
|
}
|
|
2181
2053
|
}
|
|
2054
|
+
const isRequiredField = (descriptor, config) => {
|
|
2055
|
+
if (descriptor.required) {
|
|
2056
|
+
//Se for required pelo descritor não olha pra configuração.
|
|
2057
|
+
return true;
|
|
2058
|
+
}
|
|
2059
|
+
return config === null || config === void 0 ? void 0 : config.required;
|
|
2060
|
+
};
|
|
2061
|
+
const isReadOnlyField = (descriptor, config) => {
|
|
2062
|
+
if (descriptor.readOnly) {
|
|
2063
|
+
//Se for readOnly pelo descritor não olha pra configuração.
|
|
2064
|
+
return true;
|
|
2065
|
+
}
|
|
2066
|
+
return config === null || config === void 0 ? void 0 : config.readOnly;
|
|
2067
|
+
};
|
|
2182
2068
|
const buildFromDataUnit = (dataUnit) => {
|
|
2183
2069
|
var _a, _b;
|
|
2184
2070
|
const unitMD = dataUnit.metadata;
|
|
@@ -2258,8 +2144,7 @@ const buildFromConfig = (config, dataUnit) => {
|
|
|
2258
2144
|
sheets.set(tabConfig, new Map());
|
|
2259
2145
|
}
|
|
2260
2146
|
const tabItens = sheets.get(tabConfig);
|
|
2261
|
-
|
|
2262
|
-
if (isRequired) {
|
|
2147
|
+
if (isRequiredField(descriptor, field)) {
|
|
2263
2148
|
requiredFields.push(field.name);
|
|
2264
2149
|
}
|
|
2265
2150
|
const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
|
|
@@ -2290,6 +2175,131 @@ const buildFromConfig = (config, dataUnit) => {
|
|
|
2290
2175
|
return metadata;
|
|
2291
2176
|
};
|
|
2292
2177
|
|
|
2178
|
+
const buildTextArea = ({ name, label, readOnly }) => {
|
|
2179
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small", key: name },
|
|
2180
|
+
h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
|
|
2181
|
+
};
|
|
2182
|
+
|
|
2183
|
+
const buildTextInput = ({ name, label, readOnly }) => {
|
|
2184
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2185
|
+
h("ez-text-input", { label: label, "data-field-name": name, key: name, enabled: !readOnly })));
|
|
2186
|
+
};
|
|
2187
|
+
|
|
2188
|
+
const buildSwitch = (fieldConfig) => {
|
|
2189
|
+
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, true);
|
|
2190
|
+
};
|
|
2191
|
+
const buildCheckBox = (fieldConfig) => {
|
|
2192
|
+
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, false);
|
|
2193
|
+
};
|
|
2194
|
+
function buildField$1(fieldName, fieldLabel, readOnly, switchMode = false) {
|
|
2195
|
+
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" },
|
|
2196
|
+
h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? CheckMode.SWITCH : CheckMode.REGULAR, "data-field-name": fieldName, key: fieldName })));
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
const buildComboBox = ({ name, label, readOnly, required }, properties) => {
|
|
2200
|
+
const prop = properties === null || properties === void 0 ? void 0 : properties.options;
|
|
2201
|
+
let options;
|
|
2202
|
+
if (typeof prop === "string") {
|
|
2203
|
+
const parsed = JSON.parse(prop);
|
|
2204
|
+
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
2205
|
+
}
|
|
2206
|
+
else {
|
|
2207
|
+
options = prop;
|
|
2208
|
+
}
|
|
2209
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2210
|
+
h("ez-combo-box", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name, options: options })));
|
|
2211
|
+
};
|
|
2212
|
+
|
|
2213
|
+
const buildSearch = ({ name, label, readOnly, required }) => {
|
|
2214
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2215
|
+
h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name })));
|
|
2216
|
+
};
|
|
2217
|
+
|
|
2218
|
+
const buildFile = ({ name, label, readOnly }) => {
|
|
2219
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
|
|
2220
|
+
h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
2221
|
+
};
|
|
2222
|
+
|
|
2223
|
+
const buildDate = ({ name, label, readOnly }) => {
|
|
2224
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2225
|
+
h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
2226
|
+
};
|
|
2227
|
+
const buildTime = ({ name, label, readOnly }) => {
|
|
2228
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2229
|
+
h("ez-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
2230
|
+
};
|
|
2231
|
+
const buildTimeDate = ({ name, label, readOnly }) => {
|
|
2232
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2233
|
+
h("ez-date-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
2234
|
+
};
|
|
2235
|
+
|
|
2236
|
+
const buildDecimal = ({ name, label, readOnly }, properties) => {
|
|
2237
|
+
const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
|
|
2238
|
+
const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
|
|
2239
|
+
return buildNumeric(name, label, readOnly, precision, prettyPrecision);
|
|
2240
|
+
};
|
|
2241
|
+
const buildInteger = ({ name, label, readOnly }) => {
|
|
2242
|
+
return buildNumeric(name, label, readOnly, 0, 0);
|
|
2243
|
+
};
|
|
2244
|
+
function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
|
|
2245
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
2246
|
+
h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
const uiBuilders = new Map();
|
|
2250
|
+
uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
|
|
2251
|
+
uiBuilders.set(UserInterface.CHECKBOX, buildCheckBox);
|
|
2252
|
+
uiBuilders.set(UserInterface.SWITCH, buildSwitch);
|
|
2253
|
+
uiBuilders.set(UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
2254
|
+
uiBuilders.set(UserInterface.SEARCH, buildSearch);
|
|
2255
|
+
uiBuilders.set(UserInterface.FILE, buildFile);
|
|
2256
|
+
uiBuilders.set(UserInterface.DATE, buildDate);
|
|
2257
|
+
uiBuilders.set(UserInterface.TIME, buildTime);
|
|
2258
|
+
uiBuilders.set(UserInterface.DATETIME, buildTimeDate);
|
|
2259
|
+
uiBuilders.set(UserInterface.DECIMALNUMBER, buildDecimal);
|
|
2260
|
+
uiBuilders.set(UserInterface.INTEGERNUMBER, buildInteger);
|
|
2261
|
+
const buildField = (field) => {
|
|
2262
|
+
const descriptor = field.descriptor;
|
|
2263
|
+
const config = Object.assign({}, field.config);
|
|
2264
|
+
let builder;
|
|
2265
|
+
let props;
|
|
2266
|
+
if (descriptor) {
|
|
2267
|
+
if (!config.label) {
|
|
2268
|
+
config.label = descriptor.label;
|
|
2269
|
+
}
|
|
2270
|
+
if (!config.name) {
|
|
2271
|
+
config.name = descriptor.name;
|
|
2272
|
+
}
|
|
2273
|
+
// Forçamos uma avaliação priorizando o descriptor.
|
|
2274
|
+
config.required = isRequiredField(descriptor, config);
|
|
2275
|
+
config.readOnly = isReadOnlyField(descriptor, config);
|
|
2276
|
+
props = descriptor.properties;
|
|
2277
|
+
builder = uiBuilders.get(descriptor.userInterface);
|
|
2278
|
+
}
|
|
2279
|
+
if (config.required) {
|
|
2280
|
+
config.label = `${config.label} (obrigatório) *`;
|
|
2281
|
+
}
|
|
2282
|
+
if (!builder) {
|
|
2283
|
+
builder = buildTextInput;
|
|
2284
|
+
}
|
|
2285
|
+
return builder(config, props);
|
|
2286
|
+
};
|
|
2287
|
+
|
|
2288
|
+
const FormItem = ({ source }) => {
|
|
2289
|
+
if ("items" in source) {
|
|
2290
|
+
const fieldSet = source;
|
|
2291
|
+
return h("ez-collapsible-box", { label: source.label, "header-size": "large" }, fieldSet.items.map(fi => buildField(fi)));
|
|
2292
|
+
}
|
|
2293
|
+
else {
|
|
2294
|
+
return buildField(source);
|
|
2295
|
+
}
|
|
2296
|
+
};
|
|
2297
|
+
|
|
2298
|
+
const FormSheet = ({ store, source, dataElementId }) => {
|
|
2299
|
+
return (h("div", { class: "dynamic-content ez-box__container", "data-element-id": dataElementId },
|
|
2300
|
+
h("div", { class: "ez-row ez-padding-vertical--small" }, source.items.map(item => h(FormItem, { store: store, source: item })))));
|
|
2301
|
+
};
|
|
2302
|
+
|
|
2293
2303
|
/**
|
|
2294
2304
|
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
|
2295
2305
|
*
|
|
@@ -4,134 +4,6 @@ import { C as CheckMode } from './CheckMode-bdb2ec19.js';
|
|
|
4
4
|
import { A as ApplicationUtils } from './ApplicationUtils-205ac4bc.js';
|
|
5
5
|
import './DialogType-4059dc4d.js';
|
|
6
6
|
|
|
7
|
-
const buildTextArea = ({ name, label, readOnly }) => {
|
|
8
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small", key: name },
|
|
9
|
-
h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const buildTextInput = ({ name, label, readOnly }) => {
|
|
13
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
14
|
-
h("ez-text-input", { label: label, "data-field-name": name, key: name, enabled: !readOnly })));
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const buildSwitch = (fieldConfig) => {
|
|
18
|
-
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, true);
|
|
19
|
-
};
|
|
20
|
-
const buildCheckBox = (fieldConfig) => {
|
|
21
|
-
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, false);
|
|
22
|
-
};
|
|
23
|
-
function buildField$1(fieldName, fieldLabel, readOnly, switchMode = false) {
|
|
24
|
-
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" },
|
|
25
|
-
h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? CheckMode.SWITCH : CheckMode.REGULAR, "data-field-name": fieldName, key: fieldName })));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const buildComboBox = ({ name, label, readOnly, required }, properties) => {
|
|
29
|
-
const prop = properties === null || properties === void 0 ? void 0 : properties.options;
|
|
30
|
-
let options;
|
|
31
|
-
if (typeof prop === "string") {
|
|
32
|
-
const parsed = JSON.parse(prop);
|
|
33
|
-
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
options = prop;
|
|
37
|
-
}
|
|
38
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
39
|
-
h("ez-combo-box", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name, options: options })));
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const buildSearch = ({ name, label, readOnly, required }) => {
|
|
43
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
44
|
-
h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name })));
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const buildFile = ({ name, label, readOnly }) => {
|
|
48
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
|
|
49
|
-
h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const buildDate = ({ name, label, readOnly }) => {
|
|
53
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
54
|
-
h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
55
|
-
};
|
|
56
|
-
const buildTime = ({ name, label, readOnly }) => {
|
|
57
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
58
|
-
h("ez-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
59
|
-
};
|
|
60
|
-
const buildTimeDate = ({ name, label, readOnly }) => {
|
|
61
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
62
|
-
h("ez-date-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const buildDecimal = ({ name, label, readOnly }, properties) => {
|
|
66
|
-
const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
|
|
67
|
-
const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
|
|
68
|
-
return buildNumeric(name, label, readOnly, precision, prettyPrecision);
|
|
69
|
-
};
|
|
70
|
-
const buildInteger = ({ name, label, readOnly }) => {
|
|
71
|
-
return buildNumeric(name, label, readOnly, 0, 0);
|
|
72
|
-
};
|
|
73
|
-
function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
|
|
74
|
-
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
75
|
-
h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const uiBuilders = new Map();
|
|
79
|
-
uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
|
|
80
|
-
uiBuilders.set(UserInterface.CHECKBOX, buildCheckBox);
|
|
81
|
-
uiBuilders.set(UserInterface.SWITCH, buildSwitch);
|
|
82
|
-
uiBuilders.set(UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
83
|
-
uiBuilders.set(UserInterface.SEARCH, buildSearch);
|
|
84
|
-
uiBuilders.set(UserInterface.FILE, buildFile);
|
|
85
|
-
uiBuilders.set(UserInterface.DATE, buildDate);
|
|
86
|
-
uiBuilders.set(UserInterface.TIME, buildTime);
|
|
87
|
-
uiBuilders.set(UserInterface.DATETIME, buildTimeDate);
|
|
88
|
-
uiBuilders.set(UserInterface.DECIMALNUMBER, buildDecimal);
|
|
89
|
-
uiBuilders.set(UserInterface.INTEGERNUMBER, buildInteger);
|
|
90
|
-
const buildField = (field) => {
|
|
91
|
-
const descriptor = field.descriptor;
|
|
92
|
-
const config = Object.assign({}, field.config);
|
|
93
|
-
let builder;
|
|
94
|
-
let props;
|
|
95
|
-
if (descriptor) {
|
|
96
|
-
if (!config.label) {
|
|
97
|
-
config.label = descriptor.label;
|
|
98
|
-
}
|
|
99
|
-
if (!config.name) {
|
|
100
|
-
config.name = descriptor.name;
|
|
101
|
-
}
|
|
102
|
-
if (config.required == undefined || descriptor.required === true) {
|
|
103
|
-
config.required = descriptor.required;
|
|
104
|
-
}
|
|
105
|
-
if (config.readOnly == undefined || descriptor.readOnly === true) {
|
|
106
|
-
config.readOnly = descriptor.readOnly;
|
|
107
|
-
}
|
|
108
|
-
props = descriptor.properties;
|
|
109
|
-
builder = uiBuilders.get(descriptor.userInterface);
|
|
110
|
-
}
|
|
111
|
-
if (config.required) {
|
|
112
|
-
config.label = `${config.label} (obrigatório) *`;
|
|
113
|
-
}
|
|
114
|
-
if (!builder) {
|
|
115
|
-
builder = buildTextInput;
|
|
116
|
-
}
|
|
117
|
-
return builder(config, props);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const FormItem = ({ source }) => {
|
|
121
|
-
if ("items" in source) {
|
|
122
|
-
const fieldSet = source;
|
|
123
|
-
return h("ez-collapsible-box", { label: source.label, "header-size": "large" }, fieldSet.items.map(fi => buildField(fi)));
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
return buildField(source);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const FormSheet = ({ store, source, dataElementId }) => {
|
|
131
|
-
return (h("div", { class: "dynamic-content ez-box__container", "data-element-id": dataElementId },
|
|
132
|
-
h("div", { class: "ez-row ez-padding-vertical--small" }, source.items.map(item => h(FormItem, { store: store, source: item })))));
|
|
133
|
-
};
|
|
134
|
-
|
|
135
7
|
class FormMetadata {
|
|
136
8
|
constructor() {
|
|
137
9
|
this._sheets = new Map();
|
|
@@ -161,6 +33,20 @@ class FormMetadata {
|
|
|
161
33
|
return this._defaultValues;
|
|
162
34
|
}
|
|
163
35
|
}
|
|
36
|
+
const isRequiredField = (descriptor, config) => {
|
|
37
|
+
if (descriptor.required) {
|
|
38
|
+
//Se for required pelo descritor não olha pra configuração.
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return config === null || config === void 0 ? void 0 : config.required;
|
|
42
|
+
};
|
|
43
|
+
const isReadOnlyField = (descriptor, config) => {
|
|
44
|
+
if (descriptor.readOnly) {
|
|
45
|
+
//Se for readOnly pelo descritor não olha pra configuração.
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return config === null || config === void 0 ? void 0 : config.readOnly;
|
|
49
|
+
};
|
|
164
50
|
const buildFromDataUnit = (dataUnit) => {
|
|
165
51
|
var _a, _b;
|
|
166
52
|
const unitMD = dataUnit.metadata;
|
|
@@ -240,8 +126,7 @@ const buildFromConfig = (config, dataUnit) => {
|
|
|
240
126
|
sheets.set(tabConfig, new Map());
|
|
241
127
|
}
|
|
242
128
|
const tabItens = sheets.get(tabConfig);
|
|
243
|
-
|
|
244
|
-
if (isRequired) {
|
|
129
|
+
if (isRequiredField(descriptor, field)) {
|
|
245
130
|
requiredFields.push(field.name);
|
|
246
131
|
}
|
|
247
132
|
const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
|
|
@@ -272,6 +157,131 @@ const buildFromConfig = (config, dataUnit) => {
|
|
|
272
157
|
return metadata;
|
|
273
158
|
};
|
|
274
159
|
|
|
160
|
+
const buildTextArea = ({ name, label, readOnly }) => {
|
|
161
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small", key: name },
|
|
162
|
+
h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const buildTextInput = ({ name, label, readOnly }) => {
|
|
166
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
167
|
+
h("ez-text-input", { label: label, "data-field-name": name, key: name, enabled: !readOnly })));
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const buildSwitch = (fieldConfig) => {
|
|
171
|
+
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, true);
|
|
172
|
+
};
|
|
173
|
+
const buildCheckBox = (fieldConfig) => {
|
|
174
|
+
return buildField$1(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, false);
|
|
175
|
+
};
|
|
176
|
+
function buildField$1(fieldName, fieldLabel, readOnly, switchMode = false) {
|
|
177
|
+
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" },
|
|
178
|
+
h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? CheckMode.SWITCH : CheckMode.REGULAR, "data-field-name": fieldName, key: fieldName })));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const buildComboBox = ({ name, label, readOnly, required }, properties) => {
|
|
182
|
+
const prop = properties === null || properties === void 0 ? void 0 : properties.options;
|
|
183
|
+
let options;
|
|
184
|
+
if (typeof prop === "string") {
|
|
185
|
+
const parsed = JSON.parse(prop);
|
|
186
|
+
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
options = prop;
|
|
190
|
+
}
|
|
191
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
192
|
+
h("ez-combo-box", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name, options: options })));
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const buildSearch = ({ name, label, readOnly, required }) => {
|
|
196
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
197
|
+
h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name })));
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const buildFile = ({ name, label, readOnly }) => {
|
|
201
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
|
|
202
|
+
h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const buildDate = ({ name, label, readOnly }) => {
|
|
206
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
207
|
+
h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
208
|
+
};
|
|
209
|
+
const buildTime = ({ name, label, readOnly }) => {
|
|
210
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
211
|
+
h("ez-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
212
|
+
};
|
|
213
|
+
const buildTimeDate = ({ name, label, readOnly }) => {
|
|
214
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
215
|
+
h("ez-date-time-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const buildDecimal = ({ name, label, readOnly }, properties) => {
|
|
219
|
+
const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
|
|
220
|
+
const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
|
|
221
|
+
return buildNumeric(name, label, readOnly, precision, prettyPrecision);
|
|
222
|
+
};
|
|
223
|
+
const buildInteger = ({ name, label, readOnly }) => {
|
|
224
|
+
return buildNumeric(name, label, readOnly, 0, 0);
|
|
225
|
+
};
|
|
226
|
+
function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
|
|
227
|
+
return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
|
|
228
|
+
h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const uiBuilders = new Map();
|
|
232
|
+
uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
|
|
233
|
+
uiBuilders.set(UserInterface.CHECKBOX, buildCheckBox);
|
|
234
|
+
uiBuilders.set(UserInterface.SWITCH, buildSwitch);
|
|
235
|
+
uiBuilders.set(UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
236
|
+
uiBuilders.set(UserInterface.SEARCH, buildSearch);
|
|
237
|
+
uiBuilders.set(UserInterface.FILE, buildFile);
|
|
238
|
+
uiBuilders.set(UserInterface.DATE, buildDate);
|
|
239
|
+
uiBuilders.set(UserInterface.TIME, buildTime);
|
|
240
|
+
uiBuilders.set(UserInterface.DATETIME, buildTimeDate);
|
|
241
|
+
uiBuilders.set(UserInterface.DECIMALNUMBER, buildDecimal);
|
|
242
|
+
uiBuilders.set(UserInterface.INTEGERNUMBER, buildInteger);
|
|
243
|
+
const buildField = (field) => {
|
|
244
|
+
const descriptor = field.descriptor;
|
|
245
|
+
const config = Object.assign({}, field.config);
|
|
246
|
+
let builder;
|
|
247
|
+
let props;
|
|
248
|
+
if (descriptor) {
|
|
249
|
+
if (!config.label) {
|
|
250
|
+
config.label = descriptor.label;
|
|
251
|
+
}
|
|
252
|
+
if (!config.name) {
|
|
253
|
+
config.name = descriptor.name;
|
|
254
|
+
}
|
|
255
|
+
// Forçamos uma avaliação priorizando o descriptor.
|
|
256
|
+
config.required = isRequiredField(descriptor, config);
|
|
257
|
+
config.readOnly = isReadOnlyField(descriptor, config);
|
|
258
|
+
props = descriptor.properties;
|
|
259
|
+
builder = uiBuilders.get(descriptor.userInterface);
|
|
260
|
+
}
|
|
261
|
+
if (config.required) {
|
|
262
|
+
config.label = `${config.label} (obrigatório) *`;
|
|
263
|
+
}
|
|
264
|
+
if (!builder) {
|
|
265
|
+
builder = buildTextInput;
|
|
266
|
+
}
|
|
267
|
+
return builder(config, props);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const FormItem = ({ source }) => {
|
|
271
|
+
if ("items" in source) {
|
|
272
|
+
const fieldSet = source;
|
|
273
|
+
return h("ez-collapsible-box", { label: source.label, "header-size": "large" }, fieldSet.items.map(fi => buildField(fi)));
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
return buildField(source);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const FormSheet = ({ store, source, dataElementId }) => {
|
|
281
|
+
return (h("div", { class: "dynamic-content ez-box__container", "data-element-id": dataElementId },
|
|
282
|
+
h("div", { class: "ez-row ez-padding-vertical--small" }, source.items.map(item => h(FormItem, { store: store, source: item })))));
|
|
283
|
+
};
|
|
284
|
+
|
|
275
285
|
/**
|
|
276
286
|
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
|
277
287
|
*
|
package/dist/ezui/ezui.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as o}from"./p-3c7ea91b.js";(()=>{const o=import.meta.url,s={};return""!==o&&(s.resourcesUrl=new URL(".",o).href),e(s)})().then((e=>o([["p-96265e26",[[1,"ez-actions-button",{enabled:[516],actions:[1040],size:[513],showLabel:[516,"show-label"],displayIcon:[513,"display-icon"],checkOption:[516,"check-option"],value:[513],isTransparent:[516,"is-transparent"],arrowActive:[516,"arrow-active"],_selectedAction:[32],hideActions:[64],isOpened:[64]}]]],["p-f13f3123",[[1,"ez-dialog",{confirm:[1028],dialogType:[1025,"dialog-type"],message:[1025],opened:[1540],personalizedIconPath:[1025,"personalized-icon-path"],ezTitle:[1025,"ez-title"],show:[64]}]]],["p-ccbe8272",[[1,"ez-filter-input",{label:[1],value:[1537],enabled:[4],errorMessage:[1537,"error-message"],restrict:[1],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-0398e14a",[[6,"ez-grid",{multipleSelection:[4,"multiple-selection"],config:[1040],serverUrl:[1,"server-url"],dataUnit:[16],statusResolver:[16],_paginationInfo:[32],_paginationChangedByKeyboard:[32],setColumnsDef:[64],addColumnMenuItem:[64],setColumnsState:[64],setData:[64],getSelection:[64],getColumnsState:[64],getColumns:[64],quickFilter:[64]}]]],["p-def4cd05",[[6,"ez-modal-container",{modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],showTitleBar:[4,"show-title-bar"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],cancelButtonStatus:[1,"cancel-button-status"],okButtonStatus:[1,"ok-button-status"]}]]],["p-66ebdf34",[[1,"ez-chip",{label:[513],enabled:[516],removePosition:[513,"remove-position"],mode:[513],value:[1540],setFocus:[64],setBlur:[64]}]]],["p-1cc11468",[[0,"ez-application"]]],["p-3cfefc57",[[1,"ez-card-item",{item:[16]}]]],["p-1214c5ce",[[1,"ez-list",{dataSource:[1040],useGroups:[1540,"use-groups"],ezDraggable:[1028,"ez-draggable"],ezSelectable:[1028,"ez-selectable"],itemSlotBuilder:[1040],_listItems:[32],_listGroupItems:[32],clearHistory:[64],scrollToTop:[64],setSelection:[64],getSelection:[64],getList:[64]}]]],["p-f6111077",[[1,"ez-loading-bar",{_showLoading:[32],hide:[64],show:[64]}]]],["p-7c227b86",[[1,"ez-modal",{modalSize:[1,"modal-size"],align:[1],opened:[1028],closeEsc:[4,"close-esc"],closeOutsideClick:[4,"close-outside-click"]}]]],["p-bffae598",[[1,"ez-popover",{autoClose:[516,"auto-close"],top:[1537],left:[1537],bottom:[1537],right:[1537],boxWidth:[513,"box-width"],opened:[1540],innerElement:[1537,"inner-element"],updatePosition:[64],show:[64],hide:[64]}]]],["p-cfcc23e6",[[1,"ez-popup",{size:[1],opened:[1540],useHeader:[516,"use-header"],heightMode:[513,"height-mode"],ezTitle:[1,"ez-title"]}]]],["p-8964287f",[[1,"ez-radio-button",{value:[1544],options:[1040],enabled:[516],label:[513],direction:[1537]}]]],["p-e165c3ef",[[1,"ez-scroller",{direction:[1],locked:[4],activeShadow:[4,"active-shadow"],isFirefox:[32]},[[2,"click","clickListener"],[1,"mousedown","mouseDownHandler"],[1,"mouseup","mouseUpHandler"],[1,"mousemove","mouseMoveHandler"]]]]],["p-482c3dd8",[[1,"ez-toast",{message:[1025],fadeTime:[1026,"fade-time"],useIcon:[1028,"use-icon"],canClose:[1028,"can-close"],show:[64]}]]],["p-04fab1e9",[[0,"ez-view-stack",{show:[64],getSelectedIndex:[64]}]]],["p-ac15d77e",[[1,"ez-text-input",{label:[513],value:[1537],enabled:[516],errorMessage:[1537,"error-message"],mask:[1],canShowError:[516,"can-show-error"],restrict:[1],mode:[513],noBorder:[516,"no-border"],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-8c874b58",[[1,"ez-collapsible-box",{value:[1540],label:[513],headerSize:[513,"header-size"],iconPlacement:[513,"icon-placement"],stretchTitle:[516,"stretch-title"],removable:[516],editable:[516],conditionalSave:[16],_activeEditText:[32],showHide:[64],applyFocusTextEdit:[64],cancelEdition:[64]}]]],["p-ede1328a",[[1,"ez-search",{value:[1537],label:[1537],enabled:[1540],errorMessage:[1537,"error-message"],optionLoader:[16],showSelectedValue:[4,"show-selected-value"],showOptionValue:[4,"show-option-value"],suppressEmptyOption:[4,"suppress-empty-option"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-c2ebc450",[[1,"ez-date-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-7cf71eb3",[[1,"ez-date-time-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-72d755a8",[[1,"ez-time-input",{label:[513],value:[1026],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-941d9bf9",[[1,"ez-number-input",{label:[1],value:[1538],enabled:[4],errorMessage:[1537,"error-message"],precision:[2],prettyPrecision:[2,"pretty-precision"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-f4d2438e",[[1,"ez-tabselector",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32]}]]],["p-e2337c61",[[1,"ez-check",{label:[513],value:[1540],enabled:[1540],indeterminate:[516],mode:[513],getMode:[64],setFocus:[64]}]]],["p-6bcf35fd",[[1,"ez-text-area",{label:[513],value:[1537],enabled:[516],errorMessage:[1537,"error-message"],rows:[1538],canShowError:[516,"can-show-error"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-a713a1aa",[[1,"ez-upload",{label:[1],enabled:[4],maxFileSize:[2,"max-file-size"],maxFiles:[2,"max-files"],requestHeaders:[8,"request-headers"],urlUpload:[1,"url-upload"],urlDelete:[1,"url-delete"],value:[1040],addFiles:[64],setFocus:[64],setBlur:[64]}]]],["p-81fb0c90",[[1,"ez-text-edit",{value:[1],styled:[16],_newValue:[32],applyFocusSelect:[64]}]]],["p-ca9a0a49",[[1,"ez-combo-box",{value:[1537],label:[513],enabled:[516],options:[1040],errorMessage:[1537,"error-message"],searchMode:[4,"search-mode"],showSelectedValue:[4,"show-selected-value"],showOptionValue:[4,"show-option-value"],suppressSearch:[4,"suppress-search"],optionLoader:[16],suppressEmptyOption:[4,"suppress-empty-option"],canShowError:[516,"can-show-error"],mode:[513],_preSelection:[32],_visibleOptions:[32],_startLoading:[32],_showLoading:[32],_criteria:[32],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-9d57e44a",[[1,"ez-calendar",{value:[1040],floating:[516],time:[516],showSeconds:[516,"show-seconds"],show:[64],fitVertical:[64],hide:[64]}]]],["p-ec9decf2",[[1,"ez-icon",{size:[513],href:[513],iconName:[513,"icon-name"]}]]],["p-88d0fc06",[[1,"ez-button",{label:[513],enabled:[516],mode:[513],image:[513],iconName:[513,"icon-name"],size:[513],setFocus:[64],setBlur:[64]}]]],["p-
|
|
1
|
+
import{p as e,b as o}from"./p-3c7ea91b.js";(()=>{const o=import.meta.url,s={};return""!==o&&(s.resourcesUrl=new URL(".",o).href),e(s)})().then((e=>o([["p-96265e26",[[1,"ez-actions-button",{enabled:[516],actions:[1040],size:[513],showLabel:[516,"show-label"],displayIcon:[513,"display-icon"],checkOption:[516,"check-option"],value:[513],isTransparent:[516,"is-transparent"],arrowActive:[516,"arrow-active"],_selectedAction:[32],hideActions:[64],isOpened:[64]}]]],["p-f13f3123",[[1,"ez-dialog",{confirm:[1028],dialogType:[1025,"dialog-type"],message:[1025],opened:[1540],personalizedIconPath:[1025,"personalized-icon-path"],ezTitle:[1025,"ez-title"],show:[64]}]]],["p-ccbe8272",[[1,"ez-filter-input",{label:[1],value:[1537],enabled:[4],errorMessage:[1537,"error-message"],restrict:[1],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-0398e14a",[[6,"ez-grid",{multipleSelection:[4,"multiple-selection"],config:[1040],serverUrl:[1,"server-url"],dataUnit:[16],statusResolver:[16],_paginationInfo:[32],_paginationChangedByKeyboard:[32],setColumnsDef:[64],addColumnMenuItem:[64],setColumnsState:[64],setData:[64],getSelection:[64],getColumnsState:[64],getColumns:[64],quickFilter:[64]}]]],["p-def4cd05",[[6,"ez-modal-container",{modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],showTitleBar:[4,"show-title-bar"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],cancelButtonStatus:[1,"cancel-button-status"],okButtonStatus:[1,"ok-button-status"]}]]],["p-66ebdf34",[[1,"ez-chip",{label:[513],enabled:[516],removePosition:[513,"remove-position"],mode:[513],value:[1540],setFocus:[64],setBlur:[64]}]]],["p-1cc11468",[[0,"ez-application"]]],["p-3cfefc57",[[1,"ez-card-item",{item:[16]}]]],["p-1214c5ce",[[1,"ez-list",{dataSource:[1040],useGroups:[1540,"use-groups"],ezDraggable:[1028,"ez-draggable"],ezSelectable:[1028,"ez-selectable"],itemSlotBuilder:[1040],_listItems:[32],_listGroupItems:[32],clearHistory:[64],scrollToTop:[64],setSelection:[64],getSelection:[64],getList:[64]}]]],["p-f6111077",[[1,"ez-loading-bar",{_showLoading:[32],hide:[64],show:[64]}]]],["p-7c227b86",[[1,"ez-modal",{modalSize:[1,"modal-size"],align:[1],opened:[1028],closeEsc:[4,"close-esc"],closeOutsideClick:[4,"close-outside-click"]}]]],["p-bffae598",[[1,"ez-popover",{autoClose:[516,"auto-close"],top:[1537],left:[1537],bottom:[1537],right:[1537],boxWidth:[513,"box-width"],opened:[1540],innerElement:[1537,"inner-element"],updatePosition:[64],show:[64],hide:[64]}]]],["p-cfcc23e6",[[1,"ez-popup",{size:[1],opened:[1540],useHeader:[516,"use-header"],heightMode:[513,"height-mode"],ezTitle:[1,"ez-title"]}]]],["p-8964287f",[[1,"ez-radio-button",{value:[1544],options:[1040],enabled:[516],label:[513],direction:[1537]}]]],["p-e165c3ef",[[1,"ez-scroller",{direction:[1],locked:[4],activeShadow:[4,"active-shadow"],isFirefox:[32]},[[2,"click","clickListener"],[1,"mousedown","mouseDownHandler"],[1,"mouseup","mouseUpHandler"],[1,"mousemove","mouseMoveHandler"]]]]],["p-482c3dd8",[[1,"ez-toast",{message:[1025],fadeTime:[1026,"fade-time"],useIcon:[1028,"use-icon"],canClose:[1028,"can-close"],show:[64]}]]],["p-04fab1e9",[[0,"ez-view-stack",{show:[64],getSelectedIndex:[64]}]]],["p-ac15d77e",[[1,"ez-text-input",{label:[513],value:[1537],enabled:[516],errorMessage:[1537,"error-message"],mask:[1],canShowError:[516,"can-show-error"],restrict:[1],mode:[513],noBorder:[516,"no-border"],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-8c874b58",[[1,"ez-collapsible-box",{value:[1540],label:[513],headerSize:[513,"header-size"],iconPlacement:[513,"icon-placement"],stretchTitle:[516,"stretch-title"],removable:[516],editable:[516],conditionalSave:[16],_activeEditText:[32],showHide:[64],applyFocusTextEdit:[64],cancelEdition:[64]}]]],["p-ede1328a",[[1,"ez-search",{value:[1537],label:[1537],enabled:[1540],errorMessage:[1537,"error-message"],optionLoader:[16],showSelectedValue:[4,"show-selected-value"],showOptionValue:[4,"show-option-value"],suppressEmptyOption:[4,"suppress-empty-option"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-c2ebc450",[[1,"ez-date-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-7cf71eb3",[[1,"ez-date-time-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-72d755a8",[[1,"ez-time-input",{label:[513],value:[1026],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-941d9bf9",[[1,"ez-number-input",{label:[1],value:[1538],enabled:[4],errorMessage:[1537,"error-message"],precision:[2],prettyPrecision:[2,"pretty-precision"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-f4d2438e",[[1,"ez-tabselector",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32]}]]],["p-e2337c61",[[1,"ez-check",{label:[513],value:[1540],enabled:[1540],indeterminate:[516],mode:[513],getMode:[64],setFocus:[64]}]]],["p-6bcf35fd",[[1,"ez-text-area",{label:[513],value:[1537],enabled:[516],errorMessage:[1537,"error-message"],rows:[1538],canShowError:[516,"can-show-error"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-a713a1aa",[[1,"ez-upload",{label:[1],enabled:[4],maxFileSize:[2,"max-file-size"],maxFiles:[2,"max-files"],requestHeaders:[8,"request-headers"],urlUpload:[1,"url-upload"],urlDelete:[1,"url-delete"],value:[1040],addFiles:[64],setFocus:[64],setBlur:[64]}]]],["p-81fb0c90",[[1,"ez-text-edit",{value:[1],styled:[16],_newValue:[32],applyFocusSelect:[64]}]]],["p-ca9a0a49",[[1,"ez-combo-box",{value:[1537],label:[513],enabled:[516],options:[1040],errorMessage:[1537,"error-message"],searchMode:[4,"search-mode"],showSelectedValue:[4,"show-selected-value"],showOptionValue:[4,"show-option-value"],suppressSearch:[4,"suppress-search"],optionLoader:[16],suppressEmptyOption:[4,"suppress-empty-option"],canShowError:[516,"can-show-error"],mode:[513],_preSelection:[32],_visibleOptions:[32],_startLoading:[32],_showLoading:[32],_criteria:[32],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-9d57e44a",[[1,"ez-calendar",{value:[1040],floating:[516],time:[516],showSeconds:[516,"show-seconds"],show:[64],fitVertical:[64],hide:[64]}]]],["p-ec9decf2",[[1,"ez-icon",{size:[513],href:[513],iconName:[513,"icon-name"]}]]],["p-88d0fc06",[[1,"ez-button",{label:[513],enabled:[516],mode:[513],image:[513],iconName:[513,"icon-name"],size:[513],setFocus:[64],setBlur:[64]}]]],["p-c869b682",[[0,"ez-form",{dataUnit:[1040],config:[16],recordsValidator:[16],validate:[64]}]]]],e)));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e,r as t,c as i,f as n,H as s,g as l}from"./p-3c7ea91b.js";import{UserInterface as a,Action as r,WaitingChangeException as o,ApplicationContext as c,StringUtils as d,DataUnitAction as h,DataUnit as u,ElementIDUtils as f}from"@sankhyalabs/core";import{C as b}from"./p-b853763b.js";import{A as p}from"./p-0b44cf1c.js";import"./p-e1148f5c.js";class m{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}getSheet(e){return this._sheets.get(e)}getAllSheets(){return this._sheets}addSheet(e){this._sheets.set(e.name,e),this._requiredFields=this._requiredFields.concat(e.requiredFields),this._cleanOnCopyFields=this._cleanOnCopyFields.concat(e.cleanOnCopyFields),this._defaultValues=e.defaultValues}getRequiredFields(){return this._requiredFields}getCleanOnCopyFields(){return this._cleanOnCopyFields}getDefaultValues(){return this._defaultValues}}const v=(e,t)=>!!e.required||(null==t?void 0:t.required);function z(e,t){return"__main"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function y(e,t,i){const n={config:t,descriptor:i};let s=(null==t?void 0:t.group)||i.group;if(s){const t=`group::${s}`;e.has(t)?e.get(t).items.push(n):e.set(t,{label:s,items:[n]})}else e.set((null==t?void 0:t.name)||i.name,n)}const g=({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:i,"data-field-name":t,key:t,enabled:!n}));function _(t,i,n,s=!1){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large"},e("ez-check",{enabled:!n,label:i,mode:s?b.SWITCH:b.REGULAR,"data-field-name":t,key:t}))}function w(t,i,n,s,l){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!n,label:i,precision:s,prettyPrecision:l,"data-field-name":t,key:t}))}const O=new Map;O.set(a.LONGTEXT,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:t},e("ez-text-area",{enabled:!n,label:i,"data-field-name":t})))),O.set(a.CHECKBOX,(e=>_(e.name,e.label,e.readOnly,!1))),O.set(a.SWITCH,(e=>_(e.name,e.label,e.readOnly,!0))),O.set(a.OPTIONSELECTOR,(({name:t,label:i,readOnly:n,required:s},l)=>{const a=null==l?void 0:l.options;let r;if("string"==typeof a){const e=JSON.parse(a);r=Object.keys(e).map((t=>({value:t,label:e[t]})))}else r=a;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t,options:r}))})),O.set(a.SEARCH,(({name:t,label:i,readOnly:n,required:s})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t})))),O.set(a.FILE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(a.DATE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(a.TIME,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(a.DATETIME,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(a.DECIMALNUMBER,(({name:e,label:t,readOnly:i},n)=>{const s=Number((null==n?void 0:n.precision)||2);return w(e,t,i,s,Number((null==n?void 0:n.prettyPrecision)||s))})),O.set(a.INTEGERNUMBER,(({name:e,label:t,readOnly:i})=>w(e,t,i,0,0)));const E=e=>{const t=e.descriptor,i=Object.assign({},e.config);let n,s;return t&&(i.label||(i.label=t.label),i.name||(i.name=t.name),i.required=v(t,i),i.readOnly=((e,t)=>!!e.readOnly||(null==t?void 0:t.readOnly))(t,i),s=t.properties,n=O.get(t.userInterface)),i.required&&(i.label=`${i.label} (obrigatório) *`),n||(n=g),n(i,s)},A=({source:t})=>"items"in t?e("ez-collapsible-box",{label:t.label,"header-size":"large"},t.items.map((e=>E(e)))):E(t),C=({store:t,source:i,dataElementId:n})=>e("div",{class:"dynamic-content ez-box__container","data-element-id":n},e("div",{class:"ez-row ez-padding-vertical--small"},i.items.map((i=>e(A,{store:t,source:i})))));function j(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var x="function"==typeof Symbol&&Symbol.observable||"@@observable",M=function(){return Math.random().toString(36).substring(7).split("").join(".")},R={INIT:"@@redux/INIT"+M(),REPLACE:"@@redux/REPLACE"+M(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+M()}};function S(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function k(e,t,i){var n;if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(j(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(j(1));return i(k)(e,t)}if("function"!=typeof e)throw new Error(j(2));var s=e,l=t,a=[],r=a,o=!1;function c(){r===a&&(r=a.slice())}function d(){if(o)throw new Error(j(3));return l}function h(e){if("function"!=typeof e)throw new Error(j(4));if(o)throw new Error(j(5));var t=!0;return c(),r.push(e),function(){if(t){if(o)throw new Error(j(6));t=!1,c();var i=r.indexOf(e);r.splice(i,1),a=null}}}function u(e){if(!S(e))throw new Error(j(7));if(void 0===e.type)throw new Error(j(8));if(o)throw new Error(j(9));try{o=!0,l=s(l,e)}finally{o=!1}for(var t=a=r,i=0;i<t.length;i++)(0,t[i])();return e}function f(e){if("function"!=typeof e)throw new Error(j(10));s=e,u({type:R.REPLACE})}function b(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(j(11));function i(){e.next&&e.next(d())}return i(),{unsubscribe:t(i)}}})[x]=function(){return this},e}return u({type:R.INIT}),(n={dispatch:u,subscribe:h,getState:d,replaceReducer:f})[x]=b,n}const I={};function N(e=I,t){switch(t.type){case P.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload,currentSheet:void 0});case P.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function D(e){return e.formMetadata}var P;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(P||(P={}));class L{constructor(e){this._invalidFields=new Map,this.onDataUnitEvent=e=>{var t;switch(e.type){case r.DATA_LOADED:case r.DATA_SAVED:case r.RECORDS_REMOVED:case r.RECORDS_ADDED:case r.RECORDS_COPIED:case r.EDITION_CANCELED:case r.SELECTION_CHANGED:case r.NEXT_SELECTED:case r.PREVIOUS_SELECTED:this.clearInvalid();case r.DATA_CHANGED:case r.CHANGE_UNDONE:case r.CHANGE_REDONE:case r.RECORD_LOADED:null===(t=this._fields)||void 0===t||t.forEach((e=>{this.updateValue(e.fieldName,e.field)}))}},this._fields=new Map,this._dataUnit=e,this._dataUnit.subscribe(this.onDataUnitEvent)}bind(e){e.forEach((e=>{this.updateBind(e.dataset.fieldName,e)}))}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent)}markInvalid(e){if(this._invalidFields.set(e.name,e),this._fields.has(e.name)){const t=this._fields.get(e.name).field;t.errorMessage||this.updateErrorMessage(e.name,t)}}clearInvalid(){this._invalidFields.clear(),this._fields.forEach((e=>{this.updateErrorMessage(e.field.dataset.fieldName,e.field)}))}updateValue(e,t){const i=this._fields.get(e);try{i&&(i.listen=!1),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t)}finally{i&&(i.listen=!0)}}updateErrorMessage(e,t){const i=this._invalidFields.get(e);i&&(t.errorMessage=i.message)}getErrorMessage(e){if(this._fields.has(e))return this._fields.get(e).field.errorMessage||null}updateBind(e,t){const i=this._fields.get(e);i&&i.destroy(),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t),this._fields.set(e,T.create(e,t,((e,t)=>this.changeStarted(e,t)),(e=>this.cancelWaitingChange(e)),((e,t)=>this.setFieldValue(e,t)))),this.bindSearchOptionsLoader(e,t),this.applyEzUploadContext(e,t)}changeStarted(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!t.blocking&&null==t.promise){const i=this._fields.get(e);i&&(t.promise=new Promise(((e,t)=>{i.waitingChangePromiseResolve=e,i.waitingChangePromiseReject=t})))}this._dataUnit.startChange(e,t)}cancelWaitingChange(e){if(this._dataUnit.waitingForChange(e)){this._dataUnit.cancelWaitingChange(e);const t=this._fields.get(e);t&&t.rejectWaitingChange(new o("Change canceled",e))}}setFieldValue(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._invalidFields.delete(e),this._dataUnit.setFieldValue(e,t),this._dataUnit.waitingForChange(e)){const t=this._fields.get(e);t&&t.acceptWaitingChange()}}bindSearchOptionsLoader(e,t){if("EZ-SEARCH"===t.nodeName&&null==t.optionLoader){const i=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");i&&(t.optionLoader=t=>i(t,e,this._dataUnit))}}applyEzUploadContext(e,t){var i,n;if("EZ-UPLOAD"===t.nodeName){t.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),t.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const s=this._dataUnit.getField(e),l=null===(i=s.properties)||void 0===i?void 0:i.DESTINATION;l&&(t.requestHeaders={XTRAINF:`{"destination": "${l}"}`}),t.maxFiles=(null===(n=s.properties)||void 0===n?void 0:n.MAX_FILES)||0}}}class T{constructor(){this.listen=!0,this.startChangeEventName="ezStartChange",this.cancelWaitingChangeEventName="ezCancelWaitingChange",this.changeEventName="ezChange"}destroy(){this.field.removeEventListener(this.startChangeEventName,this.startChangeListener),this.field.removeEventListener(this.cancelWaitingChangeEventName,this.cancelWaitingChangeListener),this.field.removeEventListener(this.changeEventName,this.changeListener)}acceptWaitingChange(){this.waitingChangePromiseResolve&&(this.waitingChangePromiseResolve(),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}rejectWaitingChange(e){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(e),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(e,t,i,n,s){const l=new T;return l.field=t,l.fieldName=e,l.startChangeListener=t=>{l.listen&&i(e,t.detail)},l.field.addEventListener(l.startChangeEventName,l.startChangeListener),l.cancelWaitingChangeListener=()=>{l.listen&&n(e)},l.field.addEventListener(l.cancelWaitingChangeEventName,l.cancelWaitingChangeListener),l.changeListener=t=>{l.listen&&s(e,t.detail)},l.field.addEventListener(l.changeEventName,l.changeListener),l}}let U=class{constructor(e){t(this,e),this.ezReady=i(this,"ezReady",7),this.onDataUnitAction=e=>{e.type===r.METADATA_LOADED&&this.processMetadata()}}validate(){return new Promise(((e,t)=>{var i;const n=this.dataUnit.getModifiedRecords();for(let e=0;e<n.length;e++){const s=n[e],l=[];let a=this.validateRequired(s);if(a&&!a.isValid&&l.push(a),a=null===(i=this.recordsValidator)||void 0===i?void 0:i.validateRecord(this,s),a&&!a.isValid&&l.push(a),l.length>0){this.processValidationResult(l),t();break}}e()}))}observeConfig(){this.processMetadata()}validateRequired(e){const t=D(this._store.getState()),i=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(t.getRequiredFields()),n=[];if(new Set(i).forEach((t=>{const i=e[t];if(null==i||""===i){const e=this._dataBinder.getErrorMessage(t);n.push(e?{name:t,message:e}:{name:t,message:"Essa informação é obrigatória"})}})),n.length>0)return{isValid:!1,invalidFields:n,infoMessage:"Há pelo menos um campo obrigatório não preenchido."}}processValidationResult(e){e.forEach((e=>{const t=e.invalidFields;if(t&&t.forEach((e=>{this._dataBinder.markInvalid(e)})),e.infoMessage&&p.info(e.infoMessage),e.errorMessage){const{errorTitle:t,errorMessage:i}=e;p.error(t,i)}}))}getDynamicContent(){var t;const i=D(this._store.getState());if(!i)return null;const n=(s=null===(t=this._store)||void 0===t?void 0:t.getState()).currentSheet?s.formMetadata.getSheet(s.currentSheet):Array.from(s.formMetadata.getAllSheets().values())[0];var s;if(!n)return null;const l=Array.from(i.getAllSheets().values()),a=[];if(l.length>1){const t=l.map(((e,t)=>({tabKey:e.name,label:e.label,index:t}))),i=`${this._dataElementIdEzForm}_internal_tabSelector`;a.push(e("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:e=>this._store.dispatch(function(e){return{type:P.CHANGE_TAB,payload:e.tabKey}}(e.detail)),selectedTab:n.name,"data-element-id":i}))}const r=`${this._dataElementIdEzForm}_${d.replaceAccentuatedChars(d.toCamelCase(n.label),!1)}`;return a.push(e(C,{store:this._store,source:n,dataElementId:r})),a}processMetadata(){if(!this.isStatic()&&this.dataUnit){const e=null!=this.config&&Object.values(this.config).length>0?((e,t)=>{var i,n;const s=new Map,l=new Map,a=[],r=[],o={};null===(i=null==e?void 0:e.tabs)||void 0===i||i.forEach((e=>{l.has(e.label)||!1!==e.visible||l.set(e.label,e)})),null===(n=null==e?void 0:e.fields)||void 0===n||n.forEach((e=>{var i,n,c;if(!1!==e.visible){const d=function(e,t){return("string"==typeof e?Array.from(t.keys()).find((t=>t.label===e)):e)||{label:e,visible:!0}}(e.tab||"__main",s);if(l.has(d.label))return;const h=t.getField(e.name);if(h&&d.visible){s.has(d)||s.set(d,new Map);const t=s.get(d);v(h,e)&&a.push(e.name),((null==e.cleanOnCopy?null===(i=h.properties)||void 0===i?void 0:i.cleanOnCopy:e.cleanOnCopy)||(null===(n=h.properties)||void 0===n?void 0:n.autoNum))&&r.push(e.name),(null==e.defaultValue?null===(c=h.properties)||void 0===c?void 0:c.defaultValue:e.defaultValue)&&(o[e.name]=e.defaultValue),y(t,e,h)}}}));const c=new m;return Array.from(s.entries()).sort(z).forEach((([e,t])=>{c.addSheet({label:"__main"===e.label?"Principal":e.label,name:e.label,items:Array.from(t.values()),requiredFields:a,cleanOnCopyFields:r,defaultValues:o})})),c})(this.config,this.dataUnit):(()=>{var e,t;const i=this.dataUnit.metadata,n=new m;if(i){const s=null===(e=i.fields)||void 0===e?void 0:e.filter((e=>!1!==e.visible)),l=new Map;null===(t=null==i?void 0:i.fields)||void 0===t||t.forEach((e=>{!1!==e.visible&&y(l,null,e)}));let a={};s.filter((e=>e.defaultValue)).map((e=>a[e.name]=e.defaultValue)),n.addSheet({label:i.label,name:i.name,items:Array.from(l.values()),requiredFields:s.filter((e=>e.required)).map((e=>e.name)),cleanOnCopyFields:s.filter((e=>{var t,i;return(null===(t=e.properties)||void 0===t?void 0:t.cleanOnCopy)||(null===(i=e.properties)||void 0===i?void 0:i.autoNum)})).map((e=>e.name)),defaultValues:a})}return n})();this._store.dispatch({type:P.METADATA_LOADED,payload:e})}}isStatic(){var e;return(null===(e=this._staticFields)||void 0===e?void 0:e.length)>0}interceptAction(e){if(e.type===r.RECORDS_COPIED){const t=D(this._store.getState()).getCleanOnCopyFields();if(t)return new h(r.RECORDS_COPIED,e.payload.map((e=>{const i=Object.assign({},e);return t.forEach((e=>delete i[e])),i})))}if(e.type===r.SAVING_DATA)return new Promise((t=>{this.validate().then((()=>t(e))).catch((()=>{}))}));if(e.type===r.RECORDS_ADDED){const t=D(this._store.getState()).getDefaultValues();if(t)return new h(r.RECORDS_ADDED,e.payload.map((e=>{const i=Object.assign({},e);for(const e in t){const n="formattedValue"in t[e]?t[e].formattedValue:t[e].value,s=null!=n?n:t[e],l="function"==typeof s?s():s;i[e]=this.dataUnit.valueFromString(e,l)}return i})))}return e}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new u("ez-form")),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new L(this.dataUnit),this._store=k(N),this._store.subscribe((()=>n(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),this._dataElementIdEzForm=f.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]"))),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this.dataUnit.removeInterceptor(this),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(e){return e&&e.forEach((e=>e[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`${this._dataElementIdEzForm}_${d.toCamelCase(e.label)}`)),e}render(){return e(s,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return l(this)}static get watchers(){return{config:["observeConfig"]}}};U.style="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)}";export{U as ez_form}
|
|
@@ -29,5 +29,7 @@ export interface FieldSetMetadata {
|
|
|
29
29
|
label?: string;
|
|
30
30
|
items?: Array<FieldMetadata>;
|
|
31
31
|
}
|
|
32
|
+
export declare const isRequiredField: (descriptor: FieldDescriptor, config?: IFieldConfig) => boolean;
|
|
33
|
+
export declare const isReadOnlyField: (descriptor: FieldDescriptor, config?: IFieldConfig) => boolean;
|
|
32
34
|
export declare const buildFromDataUnit: (dataUnit: DataUnit) => FormMetadata;
|
|
33
35
|
export declare const buildFromConfig: (config: IFormConfig, dataUnit: DataUnit) => FormMetadata;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e,r as t,c as i,f as n,H as s,g as l}from"./p-3c7ea91b.js";import{UserInterface as a,Action as r,WaitingChangeException as o,ApplicationContext as c,StringUtils as d,DataUnitAction as h,DataUnit as u,ElementIDUtils as f}from"@sankhyalabs/core";import{C as b}from"./p-b853763b.js";import{A as p}from"./p-0b44cf1c.js";import"./p-e1148f5c.js";const m=({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:i,"data-field-name":t,key:t,enabled:!n}));function v(t,i,n,s=!1){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large"},e("ez-check",{enabled:!n,label:i,mode:s?b.SWITCH:b.REGULAR,"data-field-name":t,key:t}))}function z(t,i,n,s,l){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!n,label:i,precision:s,prettyPrecision:l,"data-field-name":t,key:t}))}const y=new Map;y.set(a.LONGTEXT,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:t},e("ez-text-area",{enabled:!n,label:i,"data-field-name":t})))),y.set(a.CHECKBOX,(e=>v(e.name,e.label,e.readOnly,!1))),y.set(a.SWITCH,(e=>v(e.name,e.label,e.readOnly,!0))),y.set(a.OPTIONSELECTOR,(({name:t,label:i,readOnly:n,required:s},l)=>{const a=null==l?void 0:l.options;let r;if("string"==typeof a){const e=JSON.parse(a);r=Object.keys(e).map((t=>({value:t,label:e[t]})))}else r=a;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t,options:r}))})),y.set(a.SEARCH,(({name:t,label:i,readOnly:n,required:s})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t})))),y.set(a.FILE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",{enabled:!n,label:i,"data-field-name":t,key:t})))),y.set(a.DATE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),y.set(a.TIME,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),y.set(a.DATETIME,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),y.set(a.DECIMALNUMBER,(({name:e,label:t,readOnly:i},n)=>{const s=Number((null==n?void 0:n.precision)||2);return z(e,t,i,s,Number((null==n?void 0:n.prettyPrecision)||s))})),y.set(a.INTEGERNUMBER,(({name:e,label:t,readOnly:i})=>z(e,t,i,0,0)));const g=e=>{const t=e.descriptor,i=Object.assign({},e.config);let n,s;return t&&(i.label||(i.label=t.label),i.name||(i.name=t.name),null!=i.required&&!0!==t.required||(i.required=t.required),null!=i.readOnly&&!0!==t.readOnly||(i.readOnly=t.readOnly),s=t.properties,n=y.get(t.userInterface)),i.required&&(i.label=`${i.label} (obrigatório) *`),n||(n=m),n(i,s)},_=({source:t})=>"items"in t?e("ez-collapsible-box",{label:t.label,"header-size":"large"},t.items.map((e=>g(e)))):g(t),w=({store:t,source:i,dataElementId:n})=>e("div",{class:"dynamic-content ez-box__container","data-element-id":n},e("div",{class:"ez-row ez-padding-vertical--small"},i.items.map((i=>e(_,{store:t,source:i})))));class O{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}getSheet(e){return this._sheets.get(e)}getAllSheets(){return this._sheets}addSheet(e){this._sheets.set(e.name,e),this._requiredFields=this._requiredFields.concat(e.requiredFields),this._cleanOnCopyFields=this._cleanOnCopyFields.concat(e.cleanOnCopyFields),this._defaultValues=e.defaultValues}getRequiredFields(){return this._requiredFields}getCleanOnCopyFields(){return this._cleanOnCopyFields}getDefaultValues(){return this._defaultValues}}function E(e,t){return"__main"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function A(e,t,i){const n={config:t,descriptor:i};let s=(null==t?void 0:t.group)||i.group;if(s){const t=`group::${s}`;e.has(t)?e.get(t).items.push(n):e.set(t,{label:s,items:[n]})}else e.set((null==t?void 0:t.name)||i.name,n)}function C(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var j="function"==typeof Symbol&&Symbol.observable||"@@observable",x=function(){return Math.random().toString(36).substring(7).split("").join(".")},M={INIT:"@@redux/INIT"+x(),REPLACE:"@@redux/REPLACE"+x(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+x()}};function R(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function S(e,t,i){var n;if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(C(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(C(1));return i(S)(e,t)}if("function"!=typeof e)throw new Error(C(2));var s=e,l=t,a=[],r=a,o=!1;function c(){r===a&&(r=a.slice())}function d(){if(o)throw new Error(C(3));return l}function h(e){if("function"!=typeof e)throw new Error(C(4));if(o)throw new Error(C(5));var t=!0;return c(),r.push(e),function(){if(t){if(o)throw new Error(C(6));t=!1,c();var i=r.indexOf(e);r.splice(i,1),a=null}}}function u(e){if(!R(e))throw new Error(C(7));if(void 0===e.type)throw new Error(C(8));if(o)throw new Error(C(9));try{o=!0,l=s(l,e)}finally{o=!1}for(var t=a=r,i=0;i<t.length;i++)(0,t[i])();return e}function f(e){if("function"!=typeof e)throw new Error(C(10));s=e,u({type:M.REPLACE})}function b(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(C(11));function i(){e.next&&e.next(d())}return i(),{unsubscribe:t(i)}}})[j]=function(){return this},e}return u({type:M.INIT}),(n={dispatch:u,subscribe:h,getState:d,replaceReducer:f})[j]=b,n}const k={};function I(e=k,t){switch(t.type){case D.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload,currentSheet:void 0});case D.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function N(e){return e.formMetadata}var D;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(D||(D={}));class P{constructor(e){this._invalidFields=new Map,this.onDataUnitEvent=e=>{var t;switch(e.type){case r.DATA_LOADED:case r.DATA_SAVED:case r.RECORDS_REMOVED:case r.RECORDS_ADDED:case r.RECORDS_COPIED:case r.EDITION_CANCELED:case r.SELECTION_CHANGED:case r.NEXT_SELECTED:case r.PREVIOUS_SELECTED:this.clearInvalid();case r.DATA_CHANGED:case r.CHANGE_UNDONE:case r.CHANGE_REDONE:case r.RECORD_LOADED:null===(t=this._fields)||void 0===t||t.forEach((e=>{this.updateValue(e.fieldName,e.field)}))}},this._fields=new Map,this._dataUnit=e,this._dataUnit.subscribe(this.onDataUnitEvent)}bind(e){e.forEach((e=>{this.updateBind(e.dataset.fieldName,e)}))}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent)}markInvalid(e){if(this._invalidFields.set(e.name,e),this._fields.has(e.name)){const t=this._fields.get(e.name).field;t.errorMessage||this.updateErrorMessage(e.name,t)}}clearInvalid(){this._invalidFields.clear(),this._fields.forEach((e=>{this.updateErrorMessage(e.field.dataset.fieldName,e.field)}))}updateValue(e,t){const i=this._fields.get(e);try{i&&(i.listen=!1),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t)}finally{i&&(i.listen=!0)}}updateErrorMessage(e,t){const i=this._invalidFields.get(e);i&&(t.errorMessage=i.message)}getErrorMessage(e){if(this._fields.has(e))return this._fields.get(e).field.errorMessage||null}updateBind(e,t){const i=this._fields.get(e);i&&i.destroy(),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t),this._fields.set(e,L.create(e,t,((e,t)=>this.changeStarted(e,t)),(e=>this.cancelWaitingChange(e)),((e,t)=>this.setFieldValue(e,t)))),this.bindSearchOptionsLoader(e,t),this.applyEzUploadContext(e,t)}changeStarted(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!t.blocking&&null==t.promise){const i=this._fields.get(e);i&&(t.promise=new Promise(((e,t)=>{i.waitingChangePromiseResolve=e,i.waitingChangePromiseReject=t})))}this._dataUnit.startChange(e,t)}cancelWaitingChange(e){if(this._dataUnit.waitingForChange(e)){this._dataUnit.cancelWaitingChange(e);const t=this._fields.get(e);t&&t.rejectWaitingChange(new o("Change canceled",e))}}setFieldValue(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._invalidFields.delete(e),this._dataUnit.setFieldValue(e,t),this._dataUnit.waitingForChange(e)){const t=this._fields.get(e);t&&t.acceptWaitingChange()}}bindSearchOptionsLoader(e,t){if("EZ-SEARCH"===t.nodeName&&null==t.optionLoader){const i=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");i&&(t.optionLoader=t=>i(t,e,this._dataUnit))}}applyEzUploadContext(e,t){var i,n;if("EZ-UPLOAD"===t.nodeName){t.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),t.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const s=this._dataUnit.getField(e),l=null===(i=s.properties)||void 0===i?void 0:i.DESTINATION;l&&(t.requestHeaders={XTRAINF:`{"destination": "${l}"}`}),t.maxFiles=(null===(n=s.properties)||void 0===n?void 0:n.MAX_FILES)||0}}}class L{constructor(){this.listen=!0,this.startChangeEventName="ezStartChange",this.cancelWaitingChangeEventName="ezCancelWaitingChange",this.changeEventName="ezChange"}destroy(){this.field.removeEventListener(this.startChangeEventName,this.startChangeListener),this.field.removeEventListener(this.cancelWaitingChangeEventName,this.cancelWaitingChangeListener),this.field.removeEventListener(this.changeEventName,this.changeListener)}acceptWaitingChange(){this.waitingChangePromiseResolve&&(this.waitingChangePromiseResolve(),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}rejectWaitingChange(e){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(e),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(e,t,i,n,s){const l=new L;return l.field=t,l.fieldName=e,l.startChangeListener=t=>{l.listen&&i(e,t.detail)},l.field.addEventListener(l.startChangeEventName,l.startChangeListener),l.cancelWaitingChangeListener=()=>{l.listen&&n(e)},l.field.addEventListener(l.cancelWaitingChangeEventName,l.cancelWaitingChangeListener),l.changeListener=t=>{l.listen&&s(e,t.detail)},l.field.addEventListener(l.changeEventName,l.changeListener),l}}let T=class{constructor(e){t(this,e),this.ezReady=i(this,"ezReady",7),this.onDataUnitAction=e=>{e.type===r.METADATA_LOADED&&this.processMetadata()}}validate(){return new Promise(((e,t)=>{var i;const n=this.dataUnit.getModifiedRecords();for(let e=0;e<n.length;e++){const s=n[e],l=[];let a=this.validateRequired(s);if(a&&!a.isValid&&l.push(a),a=null===(i=this.recordsValidator)||void 0===i?void 0:i.validateRecord(this,s),a&&!a.isValid&&l.push(a),l.length>0){this.processValidationResult(l),t();break}}e()}))}observeConfig(){this.processMetadata()}validateRequired(e){const t=N(this._store.getState()),i=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(t.getRequiredFields()),n=[];if(new Set(i).forEach((t=>{const i=e[t];if(null==i||""===i){const e=this._dataBinder.getErrorMessage(t);n.push(e?{name:t,message:e}:{name:t,message:"Essa informação é obrigatória"})}})),n.length>0)return{isValid:!1,invalidFields:n,infoMessage:"Há pelo menos um campo obrigatório não preenchido."}}processValidationResult(e){e.forEach((e=>{const t=e.invalidFields;if(t&&t.forEach((e=>{this._dataBinder.markInvalid(e)})),e.infoMessage&&p.info(e.infoMessage),e.errorMessage){const{errorTitle:t,errorMessage:i}=e;p.error(t,i)}}))}getDynamicContent(){var t;const i=N(this._store.getState());if(!i)return null;const n=(s=null===(t=this._store)||void 0===t?void 0:t.getState()).currentSheet?s.formMetadata.getSheet(s.currentSheet):Array.from(s.formMetadata.getAllSheets().values())[0];var s;if(!n)return null;const l=Array.from(i.getAllSheets().values()),a=[];if(l.length>1){const t=l.map(((e,t)=>({tabKey:e.name,label:e.label,index:t}))),i=`${this._dataElementIdEzForm}_internal_tabSelector`;a.push(e("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:e=>this._store.dispatch(function(e){return{type:D.CHANGE_TAB,payload:e.tabKey}}(e.detail)),selectedTab:n.name,"data-element-id":i}))}const r=`${this._dataElementIdEzForm}_${d.replaceAccentuatedChars(d.toCamelCase(n.label),!1)}`;return a.push(e(w,{store:this._store,source:n,dataElementId:r})),a}processMetadata(){if(!this.isStatic()&&this.dataUnit){const e=null!=this.config&&Object.values(this.config).length>0?((e,t)=>{var i,n;const s=new Map,l=new Map,a=[],r=[],o={};null===(i=null==e?void 0:e.tabs)||void 0===i||i.forEach((e=>{l.has(e.label)||!1!==e.visible||l.set(e.label,e)})),null===(n=null==e?void 0:e.fields)||void 0===n||n.forEach((e=>{var i,n,c;if(!1!==e.visible){const d=function(e,t){return("string"==typeof e?Array.from(t.keys()).find((t=>t.label===e)):e)||{label:e,visible:!0}}(e.tab||"__main",s);if(l.has(d.label))return;const h=t.getField(e.name);if(h&&d.visible){s.has(d)||s.set(d,new Map);const t=s.get(d);(null==e.required?h.required:e.required)&&a.push(e.name),((null==e.cleanOnCopy?null===(i=h.properties)||void 0===i?void 0:i.cleanOnCopy:e.cleanOnCopy)||(null===(n=h.properties)||void 0===n?void 0:n.autoNum))&&r.push(e.name),(null==e.defaultValue?null===(c=h.properties)||void 0===c?void 0:c.defaultValue:e.defaultValue)&&(o[e.name]=e.defaultValue),A(t,e,h)}}}));const c=new O;return Array.from(s.entries()).sort(E).forEach((([e,t])=>{c.addSheet({label:"__main"===e.label?"Principal":e.label,name:e.label,items:Array.from(t.values()),requiredFields:a,cleanOnCopyFields:r,defaultValues:o})})),c})(this.config,this.dataUnit):(()=>{var e,t;const i=this.dataUnit.metadata,n=new O;if(i){const s=null===(e=i.fields)||void 0===e?void 0:e.filter((e=>!1!==e.visible)),l=new Map;null===(t=null==i?void 0:i.fields)||void 0===t||t.forEach((e=>{!1!==e.visible&&A(l,null,e)}));let a={};s.filter((e=>e.defaultValue)).map((e=>a[e.name]=e.defaultValue)),n.addSheet({label:i.label,name:i.name,items:Array.from(l.values()),requiredFields:s.filter((e=>e.required)).map((e=>e.name)),cleanOnCopyFields:s.filter((e=>{var t,i;return(null===(t=e.properties)||void 0===t?void 0:t.cleanOnCopy)||(null===(i=e.properties)||void 0===i?void 0:i.autoNum)})).map((e=>e.name)),defaultValues:a})}return n})();this._store.dispatch({type:D.METADATA_LOADED,payload:e})}}isStatic(){var e;return(null===(e=this._staticFields)||void 0===e?void 0:e.length)>0}interceptAction(e){if(e.type===r.RECORDS_COPIED){const t=N(this._store.getState()).getCleanOnCopyFields();if(t)return new h(r.RECORDS_COPIED,e.payload.map((e=>{const i=Object.assign({},e);return t.forEach((e=>delete i[e])),i})))}if(e.type===r.SAVING_DATA)return new Promise((t=>{this.validate().then((()=>t(e))).catch((()=>{}))}));if(e.type===r.RECORDS_ADDED){const t=N(this._store.getState()).getDefaultValues();if(t)return new h(r.RECORDS_ADDED,e.payload.map((e=>{const i=Object.assign({},e);for(const e in t){const n="formattedValue"in t[e]?t[e].formattedValue:t[e].value,s=null!=n?n:t[e],l="function"==typeof s?s():s;i[e]=this.dataUnit.valueFromString(e,l)}return i})))}return e}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new u("ez-form")),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new P(this.dataUnit),this._store=S(I),this._store.subscribe((()=>n(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),this._dataElementIdEzForm=f.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]"))),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this.dataUnit.removeInterceptor(this),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(e){return e&&e.forEach((e=>e[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=`${this._dataElementIdEzForm}_${d.toCamelCase(e.label)}`)),e}render(){return e(s,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return l(this)}static get watchers(){return{config:["observeConfig"]}}};T.style="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)}";export{T as ez_form}
|