@sankhyalabs/ezui 2.12.0 → 2.14.0-develop.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{ez-tree.cjs.entry.js → ez-filter-input_3.cjs.entry.js} +103 -16
- package/dist/cjs/ez-form.cjs.entry.js +325 -184
- package/dist/cjs/ez-guide-navigator.cjs.entry.js +339 -0
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/ez-form/ez-form.css +1 -1
- package/dist/collection/components/ez-form/ez-form.js +20 -16
- package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +48 -0
- package/dist/collection/components/{ez-form-view/fieldbuilder/templates → ez-form/fieldbuilder/tpl}/CheckBox.tpl.js +4 -4
- package/dist/collection/components/{ez-form-view/fieldbuilder/templates → ez-form/fieldbuilder/tpl}/ComboBox.tpl.js +2 -2
- package/dist/collection/components/{ez-form-view/fieldbuilder/templates → ez-form/fieldbuilder/tpl}/DateInput.tpl.js +1 -1
- package/dist/collection/components/{ez-form-view/fieldbuilder/templates → ez-form/fieldbuilder/tpl}/NumberInput.tpl.js +3 -3
- package/dist/collection/components/ez-form/structure/FormItem.js +11 -0
- package/dist/collection/components/ez-form/{FormMetadata.js → structure/FormMetadata.js} +53 -38
- package/dist/collection/components/ez-form/structure/FormSheet.js +6 -0
- package/dist/collection/components/ez-guide-navigator/Guide.js +200 -0
- package/dist/collection/components/ez-guide-navigator/ez-guide-navigator.css +53 -0
- package/dist/collection/components/ez-guide-navigator/ez-guide-navigator.js +230 -0
- package/dist/collection/components/ez-tree/ez-tree.js +5 -5
- package/dist/collection/components/ez-tree/subcomponents/TreeItem.js +1 -1
- package/dist/collection/components/ez-tree/types/Tree.js +0 -11
- package/dist/custom-elements/index.d.ts +6 -6
- package/dist/custom-elements/index.js +667 -337
- package/dist/esm/{ez-tree.entry.js → ez-filter-input_3.entry.js} +103 -18
- package/dist/esm/ez-form.entry.js +327 -186
- package/dist/esm/ez-guide-navigator.entry.js +335 -0
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-6500a260.entry.js +1 -0
- package/dist/ezui/p-6c45dc64.entry.js +1 -0
- package/dist/ezui/p-fa2f4ea5.entry.js +1 -0
- package/dist/types/components/ez-form/DataBinder.d.ts +1 -1
- package/dist/types/components/ez-form/ez-form.d.ts +3 -4
- package/dist/types/components/ez-form/fieldbuilder/FieldBuilder.d.ts +2 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.d.ts +3 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.d.ts +6 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/DateInput.tpl.d.ts +15 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/FileInput.tpl.d.ts +5 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.d.ts +7 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.d.ts +6 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/TextArea.tpl.d.ts +5 -0
- package/dist/types/components/ez-form/fieldbuilder/tpl/TextInput.tpl.d.ts +5 -0
- package/dist/types/components/ez-form/store/form.slice.d.ts +2 -2
- package/dist/types/components/ez-form/structure/FormItem.d.ts +9 -0
- package/dist/types/components/ez-form/{FormMetadata.d.ts → structure/FormMetadata.d.ts} +5 -2
- package/dist/types/components/ez-form/structure/FormSheet.d.ts +10 -0
- package/dist/types/components/ez-guide-navigator/Guide.d.ts +69 -0
- package/dist/types/components/ez-tree/types/Tree.d.ts +0 -1
- package/dist/types/components.d.ts +41 -26
- package/dist/types/interfaces/ez-form/IFieldMetadata.d.ts +6 -0
- package/dist/types/interfaces/ez-form/IFieldSetMetadata.d.ts +5 -0
- package/dist/types/{components/ez-form/interfaces → interfaces/ez-form}/IFormSheetMetadata.d.ts +3 -2
- package/dist/types/{components/ez-form/interfaces → interfaces/ez-form}/IRecordValidator.d.ts +1 -1
- package/dist/types/{components/ez-form/interfaces → interfaces/ez-form}/index.d.ts +2 -0
- package/package.json +2 -2
- package/react/components.d.ts +1 -1
- package/react/components.js +1 -1
- package/react/components.js.map +1 -1
- package/dist/cjs/ez-filter-input.cjs.entry.js +0 -81
- package/dist/cjs/ez-form-view.cjs.entry.js +0 -140
- package/dist/cjs/ez-sidebar-button.cjs.entry.js +0 -31
- package/dist/collection/components/ez-form-view/ez-form-view.css +0 -6
- package/dist/collection/components/ez-form-view/ez-form-view.js +0 -71
- package/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder.js +0 -26
- package/dist/esm/ez-filter-input.entry.js +0 -77
- package/dist/esm/ez-form-view.entry.js +0 -136
- package/dist/esm/ez-sidebar-button.entry.js +0 -27
- package/dist/ezui/p-36ed5c45.entry.js +0 -1
- package/dist/ezui/p-7799666d.entry.js +0 -1
- package/dist/ezui/p-81897c04.entry.js +0 -1
- package/dist/ezui/p-97d2d2f6.entry.js +0 -1
- package/dist/ezui/p-ba03ac61.entry.js +0 -1
- package/dist/types/components/ez-form-view/fieldbuilder/FieldBuilder.d.ts +0 -2
- package/dist/types/components/ez-form-view/fieldbuilder/templates/CheckBox.tpl.d.ts +0 -3
- package/dist/types/components/ez-form-view/fieldbuilder/templates/ComboBox.tpl.d.ts +0 -2
- package/dist/types/components/ez-form-view/fieldbuilder/templates/DateInput.tpl.d.ts +0 -4
- package/dist/types/components/ez-form-view/fieldbuilder/templates/FileInput.tpl.d.ts +0 -2
- package/dist/types/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.d.ts +0 -3
- package/dist/types/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.d.ts +0 -2
- package/dist/types/components/ez-form-view/fieldbuilder/templates/TextArea.tpl.d.ts +0 -2
- package/dist/types/components/ez-form-view/fieldbuilder/templates/TextInput.tpl.d.ts +0 -2
- package/dist/types/components/ez-form-view/interfaces/IFormViewField.d.ts +0 -10
- package/dist/types/components/ez-form-view/interfaces/index.d.ts +0 -1
- /package/dist/collection/components/{ez-form-view/fieldbuilder/templates → ez-form/fieldbuilder/tpl}/FileInput.tpl.js +0 -0
- /package/dist/collection/components/{ez-form-view/fieldbuilder/templates → ez-form/fieldbuilder/tpl}/SearchInput.tpl.js +0 -0
- /package/dist/collection/components/{ez-form-view/fieldbuilder/templates → ez-form/fieldbuilder/tpl}/TextArea.tpl.js +0 -0
- /package/dist/collection/components/{ez-form-view/fieldbuilder/templates → ez-form/fieldbuilder/tpl}/TextInput.tpl.js +0 -0
- /package/dist/collection/{components/ez-form/interfaces → interfaces/ez-form}/IDefaultConfig.js +0 -0
- /package/dist/collection/{components/ez-form/interfaces → interfaces/ez-form}/IFieldConfig.js +0 -0
- /package/dist/collection/{components/ez-form-view/interfaces/IFormViewField.js → interfaces/ez-form/IFieldMetadata.js} +0 -0
- /package/dist/collection/{components/ez-form-view/interfaces/index.js → interfaces/ez-form/IFieldSetMetadata.js} +0 -0
- /package/dist/collection/{components/ez-form/interfaces → interfaces/ez-form}/IFormConfig.js +0 -0
- /package/dist/collection/{components/ez-form/interfaces → interfaces/ez-form}/IFormSheetMetadata.js +0 -0
- /package/dist/collection/{components/ez-form/interfaces → interfaces/ez-form}/IInvalidField.js +0 -0
- /package/dist/collection/{components/ez-form/interfaces → interfaces/ez-form}/IRecordValidator.js +0 -0
- /package/dist/collection/{components/ez-form/interfaces → interfaces/ez-form}/ITabConfig.js +0 -0
- /package/dist/collection/{components/ez-form/interfaces → interfaces/ez-form}/IValidationResult.js +0 -0
- /package/dist/collection/{components/ez-form/interfaces → interfaces/ez-form}/index.js +0 -0
- /package/dist/types/{components/ez-form/interfaces → interfaces/ez-form}/IDefaultConfig.d.ts +0 -0
- /package/dist/types/{components/ez-form/interfaces → interfaces/ez-form}/IFieldConfig.d.ts +0 -0
- /package/dist/types/{components/ez-form/interfaces → interfaces/ez-form}/IFormConfig.d.ts +0 -0
- /package/dist/types/{components/ez-form/interfaces → interfaces/ez-form}/IInvalidField.d.ts +0 -0
- /package/dist/types/{components/ez-form/interfaces → interfaces/ez-form}/ITabConfig.d.ts +0 -0
- /package/dist/types/{components/ez-form/interfaces → interfaces/ez-form}/IValidationResult.d.ts +0 -0
|
@@ -4,9 +4,288 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-5e208fa5.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
+
const CheckMode = require('./CheckMode-ecb90b87.js');
|
|
7
8
|
const ApplicationUtils = require('./ApplicationUtils-350ac2ff.js');
|
|
8
9
|
require('./DialogType-2114c337.js');
|
|
9
10
|
|
|
11
|
+
class FormMetadata {
|
|
12
|
+
constructor() {
|
|
13
|
+
this._sheets = new Map();
|
|
14
|
+
this._requiredFields = [];
|
|
15
|
+
this._cleanOnCopyFields = [];
|
|
16
|
+
this._defaultValues = {};
|
|
17
|
+
}
|
|
18
|
+
getSheet(name) {
|
|
19
|
+
return this._sheets.get(name);
|
|
20
|
+
}
|
|
21
|
+
getAllSheets() {
|
|
22
|
+
return this._sheets;
|
|
23
|
+
}
|
|
24
|
+
addSheet(sheet) {
|
|
25
|
+
this._sheets.set(sheet.name, sheet);
|
|
26
|
+
this._requiredFields = this._requiredFields.concat(sheet.requiredFields);
|
|
27
|
+
this._cleanOnCopyFields = this._cleanOnCopyFields.concat(sheet.cleanOnCopyFields);
|
|
28
|
+
this._defaultValues = sheet.defaultValues;
|
|
29
|
+
}
|
|
30
|
+
getRequiredFields() {
|
|
31
|
+
return this._requiredFields;
|
|
32
|
+
}
|
|
33
|
+
getCleanOnCopyFields() {
|
|
34
|
+
return this._cleanOnCopyFields;
|
|
35
|
+
}
|
|
36
|
+
getDefaultValues() {
|
|
37
|
+
return this._defaultValues;
|
|
38
|
+
}
|
|
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
|
+
};
|
|
54
|
+
const buildFromDataUnit = (dataUnit) => {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
const unitMD = dataUnit.metadata;
|
|
57
|
+
const metadata = new FormMetadata();
|
|
58
|
+
if (unitMD) {
|
|
59
|
+
const visibleFields = (_a = unitMD.fields) === null || _a === void 0 ? void 0 : _a.filter(descriptor => descriptor.visible !== false);
|
|
60
|
+
const items = new Map();
|
|
61
|
+
(_b = unitMD === null || unitMD === void 0 ? void 0 : unitMD.fields) === null || _b === void 0 ? void 0 : _b.forEach((descriptor) => {
|
|
62
|
+
if (descriptor.visible !== false) {
|
|
63
|
+
resolveFieldGroup(items, null, descriptor);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
let defaultValues = {};
|
|
67
|
+
visibleFields
|
|
68
|
+
.filter(descriptor => descriptor.defaultValue)
|
|
69
|
+
.forEach((descriptor) => defaultValues[descriptor.name] = descriptor.defaultValue);
|
|
70
|
+
metadata.addSheet({
|
|
71
|
+
label: unitMD.label,
|
|
72
|
+
name: unitMD.name,
|
|
73
|
+
items: Array.from(items.values()),
|
|
74
|
+
requiredFields: visibleFields
|
|
75
|
+
.filter(descriptor => descriptor.required)
|
|
76
|
+
.map(descriptor => descriptor.name),
|
|
77
|
+
cleanOnCopyFields: visibleFields
|
|
78
|
+
.filter(descriptor => { var _a, _b; return ((_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy) || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum); })
|
|
79
|
+
.map(descriptor => descriptor.name),
|
|
80
|
+
defaultValues
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return metadata;
|
|
84
|
+
};
|
|
85
|
+
function getTabConfig(tab, sheets) {
|
|
86
|
+
const tabConfig = (typeof tab === "string" ? Array.from(sheets.keys()).find(t => t.label === tab) : tab);
|
|
87
|
+
return tabConfig || { label: tab, visible: true };
|
|
88
|
+
}
|
|
89
|
+
function sortTabs(a, b) {
|
|
90
|
+
return a[0].label == '__main' ? -1 : (a[0].order || 10000) - (b[0].order || 10000);
|
|
91
|
+
}
|
|
92
|
+
function resolveFieldGroup(items, field, descriptor) {
|
|
93
|
+
const fieldMD = { config: field, descriptor: descriptor };
|
|
94
|
+
let group = (field === null || field === void 0 ? void 0 : field.group) || descriptor.group;
|
|
95
|
+
if (group) {
|
|
96
|
+
const key = `group::${group}`;
|
|
97
|
+
if (!items.has(key)) {
|
|
98
|
+
items.set(key, { label: group, items: [fieldMD] });
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
items.get(key).items.push(fieldMD);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
items.set((field === null || field === void 0 ? void 0 : field.name) || descriptor.name, fieldMD);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const buildFromConfig = (config, dataUnit) => {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
const sheets = new Map();
|
|
111
|
+
const hiddenTabs = new Map();
|
|
112
|
+
const requiredFields = [];
|
|
113
|
+
const cleanOnCopyFields = [];
|
|
114
|
+
const defaultValues = {};
|
|
115
|
+
(_a = config === null || config === void 0 ? void 0 : config.tabs) === null || _a === void 0 ? void 0 : _a.forEach((tab) => {
|
|
116
|
+
if (!hiddenTabs.has(tab.label) && tab.visible === false) {
|
|
117
|
+
hiddenTabs.set(tab.label, tab);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
(_b = config === null || config === void 0 ? void 0 : config.fields) === null || _b === void 0 ? void 0 : _b.forEach((field) => {
|
|
121
|
+
var _a, _b, _c, _d;
|
|
122
|
+
if (field.visible !== false) {
|
|
123
|
+
const tabConfig = getTabConfig(field.tab || "__main", sheets);
|
|
124
|
+
if (hiddenTabs.has(tabConfig.label)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const descriptor = dataUnit.getField(field.name);
|
|
128
|
+
if (descriptor && tabConfig.visible) {
|
|
129
|
+
if (!sheets.has(tabConfig)) {
|
|
130
|
+
sheets.set(tabConfig, new Map());
|
|
131
|
+
}
|
|
132
|
+
const tabItens = sheets.get(tabConfig);
|
|
133
|
+
if (isRequiredField(descriptor, field)) {
|
|
134
|
+
requiredFields.push(field.name);
|
|
135
|
+
}
|
|
136
|
+
const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
|
|
137
|
+
if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum) || ((_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.cleanOnCopy)) {
|
|
138
|
+
cleanOnCopyFields.push(field.name);
|
|
139
|
+
}
|
|
140
|
+
const defaultValue = field.defaultValue == undefined ? (_d = descriptor.properties) === null || _d === void 0 ? void 0 : _d.defaultValue : field.defaultValue;
|
|
141
|
+
if (defaultValue) {
|
|
142
|
+
defaultValues[field.name] = field.defaultValue;
|
|
143
|
+
}
|
|
144
|
+
resolveFieldGroup(tabItens, field, descriptor);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
const metadata = new FormMetadata();
|
|
149
|
+
Array.from(sheets.entries())
|
|
150
|
+
.sort(sortTabs)
|
|
151
|
+
.forEach(([key, value]) => {
|
|
152
|
+
metadata.addSheet({
|
|
153
|
+
label: (key.label === "__main") ? "Principal" : key.label,
|
|
154
|
+
name: key.label,
|
|
155
|
+
items: Array.from(value.values()),
|
|
156
|
+
requiredFields,
|
|
157
|
+
cleanOnCopyFields,
|
|
158
|
+
defaultValues
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
return metadata;
|
|
162
|
+
};
|
|
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", key: source.label }, 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
|
+
|
|
10
289
|
/**
|
|
11
290
|
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
|
12
291
|
*
|
|
@@ -330,6 +609,49 @@ function createStore(reducer, preloadedState, enhancer) {
|
|
|
330
609
|
}, _ref2[$$observable] = observable, _ref2;
|
|
331
610
|
}
|
|
332
611
|
|
|
612
|
+
const inicialState = {};
|
|
613
|
+
/////////////////////////////// REDUCERS ///////////////////////////////
|
|
614
|
+
function formReducer(state = inicialState, action) {
|
|
615
|
+
switch (action.type) {
|
|
616
|
+
case FormActions.METADATA_LOADED:
|
|
617
|
+
return Object.assign(Object.assign({}, state), { formMetadata: action.payload, currentSheet: undefined });
|
|
618
|
+
case FormActions.CHANGE_TAB:
|
|
619
|
+
return Object.assign(Object.assign({}, state), { currentSheet: action.payload });
|
|
620
|
+
default:
|
|
621
|
+
return state;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
/////////////////////////////// ACTION CREATORS ///////////////////////////////
|
|
625
|
+
function loadMetadata(formMetadata) {
|
|
626
|
+
return {
|
|
627
|
+
type: FormActions.METADATA_LOADED,
|
|
628
|
+
payload: formMetadata
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
function changeTab(currentSheet) {
|
|
632
|
+
return {
|
|
633
|
+
type: FormActions.CHANGE_TAB,
|
|
634
|
+
payload: typeof currentSheet === "string" ? currentSheet : currentSheet.tabKey
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
/////////////////////////////// SELECTORS ///////////////////////////////
|
|
638
|
+
function selectFormMetadata(state) {
|
|
639
|
+
return state.formMetadata;
|
|
640
|
+
}
|
|
641
|
+
function selectCurrentSheetId(state) {
|
|
642
|
+
return state.currentSheet;
|
|
643
|
+
}
|
|
644
|
+
function selectCurrentSheet(state) {
|
|
645
|
+
const currentSheetId = selectCurrentSheetId(state);
|
|
646
|
+
return currentSheetId ? state.formMetadata.getSheet(currentSheetId) : Array.from(state.formMetadata.getAllSheets().values())[0];
|
|
647
|
+
}
|
|
648
|
+
/////////////////////////////// TYPES ///////////////////////////////
|
|
649
|
+
var FormActions;
|
|
650
|
+
(function (FormActions) {
|
|
651
|
+
FormActions["METADATA_LOADED"] = "FORM/METADATA_LOADED";
|
|
652
|
+
FormActions["CHANGE_TAB"] = "FORM/CHANGE_TAB";
|
|
653
|
+
})(FormActions || (FormActions = {}));
|
|
654
|
+
|
|
333
655
|
class DataBinder {
|
|
334
656
|
constructor(dataUnit) {
|
|
335
657
|
this._invalidFields = new Map();
|
|
@@ -536,187 +858,7 @@ class Bind {
|
|
|
536
858
|
}
|
|
537
859
|
}
|
|
538
860
|
|
|
539
|
-
const
|
|
540
|
-
/////////////////////////////// REDUCERS ///////////////////////////////
|
|
541
|
-
function formReducer(state = inicialState, action) {
|
|
542
|
-
switch (action.type) {
|
|
543
|
-
case FormActions.METADATA_LOADED:
|
|
544
|
-
return Object.assign(Object.assign({}, state), { formMetadata: action.payload, currentSheet: undefined });
|
|
545
|
-
case FormActions.CHANGE_TAB:
|
|
546
|
-
return Object.assign(Object.assign({}, state), { currentSheet: action.payload });
|
|
547
|
-
default:
|
|
548
|
-
return state;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
/////////////////////////////// ACTION CREATORS ///////////////////////////////
|
|
552
|
-
function loadMetadata(formMetadata) {
|
|
553
|
-
return {
|
|
554
|
-
type: FormActions.METADATA_LOADED,
|
|
555
|
-
payload: formMetadata
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
|
-
function changeTab(currentSheet) {
|
|
559
|
-
return {
|
|
560
|
-
type: FormActions.CHANGE_TAB,
|
|
561
|
-
payload: typeof currentSheet === "string" ? currentSheet : currentSheet.tabKey
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
/////////////////////////////// SELECTORS ///////////////////////////////
|
|
565
|
-
function selectFormMetadata(state) {
|
|
566
|
-
return state.formMetadata;
|
|
567
|
-
}
|
|
568
|
-
function selectCurrentSheetId(state) {
|
|
569
|
-
return state.currentSheet;
|
|
570
|
-
}
|
|
571
|
-
function selectCurrentSheet(state) {
|
|
572
|
-
const currentSheetId = selectCurrentSheetId(state);
|
|
573
|
-
return currentSheetId ? state.formMetadata.getSheet(currentSheetId) : Array.from(state.formMetadata.getAllSheets().values())[0];
|
|
574
|
-
}
|
|
575
|
-
/////////////////////////////// TYPES ///////////////////////////////
|
|
576
|
-
var FormActions;
|
|
577
|
-
(function (FormActions) {
|
|
578
|
-
FormActions["METADATA_LOADED"] = "FORM/METADATA_LOADED";
|
|
579
|
-
FormActions["CHANGE_TAB"] = "FORM/CHANGE_TAB";
|
|
580
|
-
})(FormActions || (FormActions = {}));
|
|
581
|
-
|
|
582
|
-
class FormMetadata {
|
|
583
|
-
constructor() {
|
|
584
|
-
this._sheets = new Map();
|
|
585
|
-
this._requiredFields = [];
|
|
586
|
-
this._cleanOnCopyFields = [];
|
|
587
|
-
this._defaultValues = {};
|
|
588
|
-
}
|
|
589
|
-
getSheet(name) {
|
|
590
|
-
return this._sheets.get(name);
|
|
591
|
-
}
|
|
592
|
-
getAllSheets() {
|
|
593
|
-
return this._sheets;
|
|
594
|
-
}
|
|
595
|
-
addSheet(sheet) {
|
|
596
|
-
this._sheets.set(sheet.name, sheet);
|
|
597
|
-
this._requiredFields = this._requiredFields.concat(sheet.requiredFields);
|
|
598
|
-
this._cleanOnCopyFields = this._cleanOnCopyFields.concat(sheet.cleanOnCopyFields);
|
|
599
|
-
this._defaultValues = sheet.defaultValues;
|
|
600
|
-
}
|
|
601
|
-
getRequiredFields() {
|
|
602
|
-
return this._requiredFields;
|
|
603
|
-
}
|
|
604
|
-
getCleanOnCopyFields() {
|
|
605
|
-
return this._cleanOnCopyFields;
|
|
606
|
-
}
|
|
607
|
-
getDefaultValues() {
|
|
608
|
-
return this._defaultValues;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
const buildFromDataUnit = (dataUnit) => {
|
|
612
|
-
const unitMD = dataUnit.metadata;
|
|
613
|
-
const metadata = new FormMetadata();
|
|
614
|
-
if (unitMD) {
|
|
615
|
-
const visibleFields = (unitMD.fields || []).filter(descriptor => descriptor.visible !== false);
|
|
616
|
-
const fields = visibleFields.map(descriptor => buildFormField(descriptor));
|
|
617
|
-
let defaultValues = {};
|
|
618
|
-
visibleFields
|
|
619
|
-
.filter(descriptor => descriptor.defaultValue)
|
|
620
|
-
.forEach((descriptor) => defaultValues[descriptor.name] = descriptor.defaultValue);
|
|
621
|
-
metadata.addSheet({
|
|
622
|
-
name: unitMD.name,
|
|
623
|
-
label: unitMD.label,
|
|
624
|
-
fields,
|
|
625
|
-
requiredFields: visibleFields
|
|
626
|
-
.filter(descriptor => descriptor.required)
|
|
627
|
-
.map(descriptor => descriptor.name),
|
|
628
|
-
cleanOnCopyFields: visibleFields
|
|
629
|
-
.filter(descriptor => { var _a, _b; return ((_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy) || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum); })
|
|
630
|
-
.map(descriptor => descriptor.name),
|
|
631
|
-
defaultValues
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
return metadata;
|
|
635
|
-
};
|
|
636
|
-
const buildFromConfig = (config, dataUnit) => {
|
|
637
|
-
var _a, _b;
|
|
638
|
-
const sheets = new Map();
|
|
639
|
-
const hiddenTabs = new Map();
|
|
640
|
-
const requiredFields = [];
|
|
641
|
-
const cleanOnCopyFields = [];
|
|
642
|
-
const defaultValues = {};
|
|
643
|
-
(_a = config === null || config === void 0 ? void 0 : config.tabs) === null || _a === void 0 ? void 0 : _a.forEach((tab) => {
|
|
644
|
-
if (!hiddenTabs.has(tab.label) && tab.visible === false) {
|
|
645
|
-
hiddenTabs.set(tab.label, tab);
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
(_b = config === null || config === void 0 ? void 0 : config.fields) === null || _b === void 0 ? void 0 : _b.forEach((field) => {
|
|
649
|
-
var _a, _b, _c, _d;
|
|
650
|
-
if (field.visible !== false) {
|
|
651
|
-
const tabConfig = getTabConfig(field.tab || "__main", sheets);
|
|
652
|
-
if (hiddenTabs.has(tabConfig.label)) {
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
const descriptor = dataUnit.getField(field.name);
|
|
656
|
-
if (descriptor && tabConfig.visible) {
|
|
657
|
-
if (!sheets.has(tabConfig)) {
|
|
658
|
-
sheets.set(tabConfig, []);
|
|
659
|
-
}
|
|
660
|
-
const formField = buildFormField(descriptor, field);
|
|
661
|
-
sheets.get(tabConfig).push(formField);
|
|
662
|
-
if (formField.required) {
|
|
663
|
-
requiredFields.push(field.name);
|
|
664
|
-
}
|
|
665
|
-
const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
|
|
666
|
-
if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum) || ((_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.cleanOnCopy)) {
|
|
667
|
-
cleanOnCopyFields.push(field.name);
|
|
668
|
-
}
|
|
669
|
-
const defaultValue = field.defaultValue == undefined ? (_d = descriptor.properties) === null || _d === void 0 ? void 0 : _d.defaultValue : field.defaultValue;
|
|
670
|
-
if (defaultValue) {
|
|
671
|
-
defaultValues[field.name] = field.defaultValue;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
});
|
|
676
|
-
const metadata = new FormMetadata();
|
|
677
|
-
Array.from(sheets.entries())
|
|
678
|
-
.sort(sortTabs)
|
|
679
|
-
.forEach(([key, fields]) => {
|
|
680
|
-
metadata.addSheet({
|
|
681
|
-
label: (key.label === "__main") ? "Principal" : key.label,
|
|
682
|
-
name: key.label,
|
|
683
|
-
fields,
|
|
684
|
-
requiredFields,
|
|
685
|
-
cleanOnCopyFields,
|
|
686
|
-
defaultValues
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
return metadata;
|
|
690
|
-
};
|
|
691
|
-
const buildFormField = (descriptor, config) => {
|
|
692
|
-
let { name, label, group } = Object.assign({}, config);
|
|
693
|
-
let { readOnly, required } = Object.assign({}, config);
|
|
694
|
-
let props;
|
|
695
|
-
let userInterface;
|
|
696
|
-
if (descriptor) {
|
|
697
|
-
label = label || descriptor.label;
|
|
698
|
-
name = name || descriptor.name;
|
|
699
|
-
required = descriptor.required || (config === null || config === void 0 ? void 0 : config.required);
|
|
700
|
-
readOnly = descriptor.readOnly || (config === null || config === void 0 ? void 0 : config.readOnly);
|
|
701
|
-
props = descriptor.properties;
|
|
702
|
-
userInterface = descriptor.userInterface;
|
|
703
|
-
}
|
|
704
|
-
return {
|
|
705
|
-
name, label, group,
|
|
706
|
-
readOnly, required,
|
|
707
|
-
props,
|
|
708
|
-
userInterface: userInterface || core.UserInterface.SHORTTEXT
|
|
709
|
-
};
|
|
710
|
-
};
|
|
711
|
-
const getTabConfig = (tab, sheets) => {
|
|
712
|
-
const tabConfig = (typeof tab === "string" ? Array.from(sheets.keys()).find(t => t.label === tab) : tab);
|
|
713
|
-
return tabConfig || { label: tab, visible: true };
|
|
714
|
-
};
|
|
715
|
-
const sortTabs = (a, b) => {
|
|
716
|
-
return a[0].label == '__main' ? -1 : (a[0].order || 10000) - (b[0].order || 10000);
|
|
717
|
-
};
|
|
718
|
-
|
|
719
|
-
const ezFormCss = ".sc-ez-form-h{display:flex;flex-direction:column;width:100%}.dynamic-content.sc-ez-form ez-collapsible-box.sc-ez-form{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}.multi-level__container.sc-ez-form{display:grid;grid-template-columns:minmax(20%, 300px) auto;width:100%}";
|
|
861
|
+
const ezFormCss = "ez-form.sc-ez-form{display:flex;flex-direction:column;width:100%}.dynamic-content.sc-ez-form ez-collapsible-box.sc-ez-form{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}.multi-level__container.sc-ez-form{display:grid;grid-template-columns:minmax(20%, 300px) auto;width:100%}";
|
|
720
862
|
|
|
721
863
|
let EzForm = class {
|
|
722
864
|
constructor(hostRef) {
|
|
@@ -844,9 +986,8 @@ let EzForm = class {
|
|
|
844
986
|
return result;
|
|
845
987
|
}
|
|
846
988
|
buildFormContent(sheetId, currentSheet) {
|
|
847
|
-
const fields = currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.fields;
|
|
848
989
|
if (this.contentBuilder != undefined) {
|
|
849
|
-
const customContent = this.contentBuilder(sheetId,
|
|
990
|
+
const customContent = this.contentBuilder(sheetId, currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.items, buildField);
|
|
850
991
|
if (customContent != undefined) {
|
|
851
992
|
return index.h("div", { "innerHTML": customContent });
|
|
852
993
|
}
|
|
@@ -855,7 +996,7 @@ let EzForm = class {
|
|
|
855
996
|
return;
|
|
856
997
|
}
|
|
857
998
|
const idFormSheet = `${core.StringUtils.replaceAccentuatedChars(core.StringUtils.toCamelCase(currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.label), false)}_selectorContainer`;
|
|
858
|
-
return
|
|
999
|
+
return index.h(FormSheet, { store: this._store, source: currentSheet, dataElementId: idFormSheet });
|
|
859
1000
|
}
|
|
860
1001
|
processMetadata() {
|
|
861
1002
|
if (!this.isStatic() && this.dataUnit && this._store) {
|