@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
|
@@ -1,8 +1,287 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent,
|
|
2
|
-
import { Action, WaitingChangeException, ApplicationContext,
|
|
1
|
+
import { h, r as registerInstance, c as createEvent, f as forceUpdate, H as Host, g as getElement } from './index-c5203f95.js';
|
|
2
|
+
import { UserInterface, Action, WaitingChangeException, ApplicationContext, StringUtils, DataUnitAction, DataUnit, ElementIDUtils } from '@sankhyalabs/core';
|
|
3
|
+
import { C as CheckMode } from './CheckMode-bdb2ec19.js';
|
|
3
4
|
import { A as ApplicationUtils } from './ApplicationUtils-9fda4796.js';
|
|
4
5
|
import './DialogType-54a62731.js';
|
|
5
6
|
|
|
7
|
+
class FormMetadata {
|
|
8
|
+
constructor() {
|
|
9
|
+
this._sheets = new Map();
|
|
10
|
+
this._requiredFields = [];
|
|
11
|
+
this._cleanOnCopyFields = [];
|
|
12
|
+
this._defaultValues = {};
|
|
13
|
+
}
|
|
14
|
+
getSheet(name) {
|
|
15
|
+
return this._sheets.get(name);
|
|
16
|
+
}
|
|
17
|
+
getAllSheets() {
|
|
18
|
+
return this._sheets;
|
|
19
|
+
}
|
|
20
|
+
addSheet(sheet) {
|
|
21
|
+
this._sheets.set(sheet.name, sheet);
|
|
22
|
+
this._requiredFields = this._requiredFields.concat(sheet.requiredFields);
|
|
23
|
+
this._cleanOnCopyFields = this._cleanOnCopyFields.concat(sheet.cleanOnCopyFields);
|
|
24
|
+
this._defaultValues = sheet.defaultValues;
|
|
25
|
+
}
|
|
26
|
+
getRequiredFields() {
|
|
27
|
+
return this._requiredFields;
|
|
28
|
+
}
|
|
29
|
+
getCleanOnCopyFields() {
|
|
30
|
+
return this._cleanOnCopyFields;
|
|
31
|
+
}
|
|
32
|
+
getDefaultValues() {
|
|
33
|
+
return this._defaultValues;
|
|
34
|
+
}
|
|
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
|
+
};
|
|
50
|
+
const buildFromDataUnit = (dataUnit) => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const unitMD = dataUnit.metadata;
|
|
53
|
+
const metadata = new FormMetadata();
|
|
54
|
+
if (unitMD) {
|
|
55
|
+
const visibleFields = (_a = unitMD.fields) === null || _a === void 0 ? void 0 : _a.filter(descriptor => descriptor.visible !== false);
|
|
56
|
+
const items = new Map();
|
|
57
|
+
(_b = unitMD === null || unitMD === void 0 ? void 0 : unitMD.fields) === null || _b === void 0 ? void 0 : _b.forEach((descriptor) => {
|
|
58
|
+
if (descriptor.visible !== false) {
|
|
59
|
+
resolveFieldGroup(items, null, descriptor);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
let defaultValues = {};
|
|
63
|
+
visibleFields
|
|
64
|
+
.filter(descriptor => descriptor.defaultValue)
|
|
65
|
+
.forEach((descriptor) => defaultValues[descriptor.name] = descriptor.defaultValue);
|
|
66
|
+
metadata.addSheet({
|
|
67
|
+
label: unitMD.label,
|
|
68
|
+
name: unitMD.name,
|
|
69
|
+
items: Array.from(items.values()),
|
|
70
|
+
requiredFields: visibleFields
|
|
71
|
+
.filter(descriptor => descriptor.required)
|
|
72
|
+
.map(descriptor => descriptor.name),
|
|
73
|
+
cleanOnCopyFields: visibleFields
|
|
74
|
+
.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); })
|
|
75
|
+
.map(descriptor => descriptor.name),
|
|
76
|
+
defaultValues
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return metadata;
|
|
80
|
+
};
|
|
81
|
+
function getTabConfig(tab, sheets) {
|
|
82
|
+
const tabConfig = (typeof tab === "string" ? Array.from(sheets.keys()).find(t => t.label === tab) : tab);
|
|
83
|
+
return tabConfig || { label: tab, visible: true };
|
|
84
|
+
}
|
|
85
|
+
function sortTabs(a, b) {
|
|
86
|
+
return a[0].label == '__main' ? -1 : (a[0].order || 10000) - (b[0].order || 10000);
|
|
87
|
+
}
|
|
88
|
+
function resolveFieldGroup(items, field, descriptor) {
|
|
89
|
+
const fieldMD = { config: field, descriptor: descriptor };
|
|
90
|
+
let group = (field === null || field === void 0 ? void 0 : field.group) || descriptor.group;
|
|
91
|
+
if (group) {
|
|
92
|
+
const key = `group::${group}`;
|
|
93
|
+
if (!items.has(key)) {
|
|
94
|
+
items.set(key, { label: group, items: [fieldMD] });
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
items.get(key).items.push(fieldMD);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
items.set((field === null || field === void 0 ? void 0 : field.name) || descriptor.name, fieldMD);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const buildFromConfig = (config, dataUnit) => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
const sheets = new Map();
|
|
107
|
+
const hiddenTabs = new Map();
|
|
108
|
+
const requiredFields = [];
|
|
109
|
+
const cleanOnCopyFields = [];
|
|
110
|
+
const defaultValues = {};
|
|
111
|
+
(_a = config === null || config === void 0 ? void 0 : config.tabs) === null || _a === void 0 ? void 0 : _a.forEach((tab) => {
|
|
112
|
+
if (!hiddenTabs.has(tab.label) && tab.visible === false) {
|
|
113
|
+
hiddenTabs.set(tab.label, tab);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
(_b = config === null || config === void 0 ? void 0 : config.fields) === null || _b === void 0 ? void 0 : _b.forEach((field) => {
|
|
117
|
+
var _a, _b, _c, _d;
|
|
118
|
+
if (field.visible !== false) {
|
|
119
|
+
const tabConfig = getTabConfig(field.tab || "__main", sheets);
|
|
120
|
+
if (hiddenTabs.has(tabConfig.label)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const descriptor = dataUnit.getField(field.name);
|
|
124
|
+
if (descriptor && tabConfig.visible) {
|
|
125
|
+
if (!sheets.has(tabConfig)) {
|
|
126
|
+
sheets.set(tabConfig, new Map());
|
|
127
|
+
}
|
|
128
|
+
const tabItens = sheets.get(tabConfig);
|
|
129
|
+
if (isRequiredField(descriptor, field)) {
|
|
130
|
+
requiredFields.push(field.name);
|
|
131
|
+
}
|
|
132
|
+
const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
|
|
133
|
+
if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum) || ((_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.cleanOnCopy)) {
|
|
134
|
+
cleanOnCopyFields.push(field.name);
|
|
135
|
+
}
|
|
136
|
+
const defaultValue = field.defaultValue == undefined ? (_d = descriptor.properties) === null || _d === void 0 ? void 0 : _d.defaultValue : field.defaultValue;
|
|
137
|
+
if (defaultValue) {
|
|
138
|
+
defaultValues[field.name] = field.defaultValue;
|
|
139
|
+
}
|
|
140
|
+
resolveFieldGroup(tabItens, field, descriptor);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
const metadata = new FormMetadata();
|
|
145
|
+
Array.from(sheets.entries())
|
|
146
|
+
.sort(sortTabs)
|
|
147
|
+
.forEach(([key, value]) => {
|
|
148
|
+
metadata.addSheet({
|
|
149
|
+
label: (key.label === "__main") ? "Principal" : key.label,
|
|
150
|
+
name: key.label,
|
|
151
|
+
items: Array.from(value.values()),
|
|
152
|
+
requiredFields,
|
|
153
|
+
cleanOnCopyFields,
|
|
154
|
+
defaultValues
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
return metadata;
|
|
158
|
+
};
|
|
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", key: source.label }, 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
|
+
|
|
6
285
|
/**
|
|
7
286
|
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
|
8
287
|
*
|
|
@@ -326,6 +605,49 @@ function createStore(reducer, preloadedState, enhancer) {
|
|
|
326
605
|
}, _ref2[$$observable] = observable, _ref2;
|
|
327
606
|
}
|
|
328
607
|
|
|
608
|
+
const inicialState = {};
|
|
609
|
+
/////////////////////////////// REDUCERS ///////////////////////////////
|
|
610
|
+
function formReducer(state = inicialState, action) {
|
|
611
|
+
switch (action.type) {
|
|
612
|
+
case FormActions.METADATA_LOADED:
|
|
613
|
+
return Object.assign(Object.assign({}, state), { formMetadata: action.payload, currentSheet: undefined });
|
|
614
|
+
case FormActions.CHANGE_TAB:
|
|
615
|
+
return Object.assign(Object.assign({}, state), { currentSheet: action.payload });
|
|
616
|
+
default:
|
|
617
|
+
return state;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/////////////////////////////// ACTION CREATORS ///////////////////////////////
|
|
621
|
+
function loadMetadata(formMetadata) {
|
|
622
|
+
return {
|
|
623
|
+
type: FormActions.METADATA_LOADED,
|
|
624
|
+
payload: formMetadata
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
function changeTab(currentSheet) {
|
|
628
|
+
return {
|
|
629
|
+
type: FormActions.CHANGE_TAB,
|
|
630
|
+
payload: typeof currentSheet === "string" ? currentSheet : currentSheet.tabKey
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
/////////////////////////////// SELECTORS ///////////////////////////////
|
|
634
|
+
function selectFormMetadata(state) {
|
|
635
|
+
return state.formMetadata;
|
|
636
|
+
}
|
|
637
|
+
function selectCurrentSheetId(state) {
|
|
638
|
+
return state.currentSheet;
|
|
639
|
+
}
|
|
640
|
+
function selectCurrentSheet(state) {
|
|
641
|
+
const currentSheetId = selectCurrentSheetId(state);
|
|
642
|
+
return currentSheetId ? state.formMetadata.getSheet(currentSheetId) : Array.from(state.formMetadata.getAllSheets().values())[0];
|
|
643
|
+
}
|
|
644
|
+
/////////////////////////////// TYPES ///////////////////////////////
|
|
645
|
+
var FormActions;
|
|
646
|
+
(function (FormActions) {
|
|
647
|
+
FormActions["METADATA_LOADED"] = "FORM/METADATA_LOADED";
|
|
648
|
+
FormActions["CHANGE_TAB"] = "FORM/CHANGE_TAB";
|
|
649
|
+
})(FormActions || (FormActions = {}));
|
|
650
|
+
|
|
329
651
|
class DataBinder {
|
|
330
652
|
constructor(dataUnit) {
|
|
331
653
|
this._invalidFields = new Map();
|
|
@@ -532,187 +854,7 @@ class Bind {
|
|
|
532
854
|
}
|
|
533
855
|
}
|
|
534
856
|
|
|
535
|
-
const
|
|
536
|
-
/////////////////////////////// REDUCERS ///////////////////////////////
|
|
537
|
-
function formReducer(state = inicialState, action) {
|
|
538
|
-
switch (action.type) {
|
|
539
|
-
case FormActions.METADATA_LOADED:
|
|
540
|
-
return Object.assign(Object.assign({}, state), { formMetadata: action.payload, currentSheet: undefined });
|
|
541
|
-
case FormActions.CHANGE_TAB:
|
|
542
|
-
return Object.assign(Object.assign({}, state), { currentSheet: action.payload });
|
|
543
|
-
default:
|
|
544
|
-
return state;
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
/////////////////////////////// ACTION CREATORS ///////////////////////////////
|
|
548
|
-
function loadMetadata(formMetadata) {
|
|
549
|
-
return {
|
|
550
|
-
type: FormActions.METADATA_LOADED,
|
|
551
|
-
payload: formMetadata
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
function changeTab(currentSheet) {
|
|
555
|
-
return {
|
|
556
|
-
type: FormActions.CHANGE_TAB,
|
|
557
|
-
payload: typeof currentSheet === "string" ? currentSheet : currentSheet.tabKey
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
/////////////////////////////// SELECTORS ///////////////////////////////
|
|
561
|
-
function selectFormMetadata(state) {
|
|
562
|
-
return state.formMetadata;
|
|
563
|
-
}
|
|
564
|
-
function selectCurrentSheetId(state) {
|
|
565
|
-
return state.currentSheet;
|
|
566
|
-
}
|
|
567
|
-
function selectCurrentSheet(state) {
|
|
568
|
-
const currentSheetId = selectCurrentSheetId(state);
|
|
569
|
-
return currentSheetId ? state.formMetadata.getSheet(currentSheetId) : Array.from(state.formMetadata.getAllSheets().values())[0];
|
|
570
|
-
}
|
|
571
|
-
/////////////////////////////// TYPES ///////////////////////////////
|
|
572
|
-
var FormActions;
|
|
573
|
-
(function (FormActions) {
|
|
574
|
-
FormActions["METADATA_LOADED"] = "FORM/METADATA_LOADED";
|
|
575
|
-
FormActions["CHANGE_TAB"] = "FORM/CHANGE_TAB";
|
|
576
|
-
})(FormActions || (FormActions = {}));
|
|
577
|
-
|
|
578
|
-
class FormMetadata {
|
|
579
|
-
constructor() {
|
|
580
|
-
this._sheets = new Map();
|
|
581
|
-
this._requiredFields = [];
|
|
582
|
-
this._cleanOnCopyFields = [];
|
|
583
|
-
this._defaultValues = {};
|
|
584
|
-
}
|
|
585
|
-
getSheet(name) {
|
|
586
|
-
return this._sheets.get(name);
|
|
587
|
-
}
|
|
588
|
-
getAllSheets() {
|
|
589
|
-
return this._sheets;
|
|
590
|
-
}
|
|
591
|
-
addSheet(sheet) {
|
|
592
|
-
this._sheets.set(sheet.name, sheet);
|
|
593
|
-
this._requiredFields = this._requiredFields.concat(sheet.requiredFields);
|
|
594
|
-
this._cleanOnCopyFields = this._cleanOnCopyFields.concat(sheet.cleanOnCopyFields);
|
|
595
|
-
this._defaultValues = sheet.defaultValues;
|
|
596
|
-
}
|
|
597
|
-
getRequiredFields() {
|
|
598
|
-
return this._requiredFields;
|
|
599
|
-
}
|
|
600
|
-
getCleanOnCopyFields() {
|
|
601
|
-
return this._cleanOnCopyFields;
|
|
602
|
-
}
|
|
603
|
-
getDefaultValues() {
|
|
604
|
-
return this._defaultValues;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
const buildFromDataUnit = (dataUnit) => {
|
|
608
|
-
const unitMD = dataUnit.metadata;
|
|
609
|
-
const metadata = new FormMetadata();
|
|
610
|
-
if (unitMD) {
|
|
611
|
-
const visibleFields = (unitMD.fields || []).filter(descriptor => descriptor.visible !== false);
|
|
612
|
-
const fields = visibleFields.map(descriptor => buildFormField(descriptor));
|
|
613
|
-
let defaultValues = {};
|
|
614
|
-
visibleFields
|
|
615
|
-
.filter(descriptor => descriptor.defaultValue)
|
|
616
|
-
.forEach((descriptor) => defaultValues[descriptor.name] = descriptor.defaultValue);
|
|
617
|
-
metadata.addSheet({
|
|
618
|
-
name: unitMD.name,
|
|
619
|
-
label: unitMD.label,
|
|
620
|
-
fields,
|
|
621
|
-
requiredFields: visibleFields
|
|
622
|
-
.filter(descriptor => descriptor.required)
|
|
623
|
-
.map(descriptor => descriptor.name),
|
|
624
|
-
cleanOnCopyFields: visibleFields
|
|
625
|
-
.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); })
|
|
626
|
-
.map(descriptor => descriptor.name),
|
|
627
|
-
defaultValues
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
return metadata;
|
|
631
|
-
};
|
|
632
|
-
const buildFromConfig = (config, dataUnit) => {
|
|
633
|
-
var _a, _b;
|
|
634
|
-
const sheets = new Map();
|
|
635
|
-
const hiddenTabs = new Map();
|
|
636
|
-
const requiredFields = [];
|
|
637
|
-
const cleanOnCopyFields = [];
|
|
638
|
-
const defaultValues = {};
|
|
639
|
-
(_a = config === null || config === void 0 ? void 0 : config.tabs) === null || _a === void 0 ? void 0 : _a.forEach((tab) => {
|
|
640
|
-
if (!hiddenTabs.has(tab.label) && tab.visible === false) {
|
|
641
|
-
hiddenTabs.set(tab.label, tab);
|
|
642
|
-
}
|
|
643
|
-
});
|
|
644
|
-
(_b = config === null || config === void 0 ? void 0 : config.fields) === null || _b === void 0 ? void 0 : _b.forEach((field) => {
|
|
645
|
-
var _a, _b, _c, _d;
|
|
646
|
-
if (field.visible !== false) {
|
|
647
|
-
const tabConfig = getTabConfig(field.tab || "__main", sheets);
|
|
648
|
-
if (hiddenTabs.has(tabConfig.label)) {
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
const descriptor = dataUnit.getField(field.name);
|
|
652
|
-
if (descriptor && tabConfig.visible) {
|
|
653
|
-
if (!sheets.has(tabConfig)) {
|
|
654
|
-
sheets.set(tabConfig, []);
|
|
655
|
-
}
|
|
656
|
-
const formField = buildFormField(descriptor, field);
|
|
657
|
-
sheets.get(tabConfig).push(formField);
|
|
658
|
-
if (formField.required) {
|
|
659
|
-
requiredFields.push(field.name);
|
|
660
|
-
}
|
|
661
|
-
const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
|
|
662
|
-
if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum) || ((_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.cleanOnCopy)) {
|
|
663
|
-
cleanOnCopyFields.push(field.name);
|
|
664
|
-
}
|
|
665
|
-
const defaultValue = field.defaultValue == undefined ? (_d = descriptor.properties) === null || _d === void 0 ? void 0 : _d.defaultValue : field.defaultValue;
|
|
666
|
-
if (defaultValue) {
|
|
667
|
-
defaultValues[field.name] = field.defaultValue;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
});
|
|
672
|
-
const metadata = new FormMetadata();
|
|
673
|
-
Array.from(sheets.entries())
|
|
674
|
-
.sort(sortTabs)
|
|
675
|
-
.forEach(([key, fields]) => {
|
|
676
|
-
metadata.addSheet({
|
|
677
|
-
label: (key.label === "__main") ? "Principal" : key.label,
|
|
678
|
-
name: key.label,
|
|
679
|
-
fields,
|
|
680
|
-
requiredFields,
|
|
681
|
-
cleanOnCopyFields,
|
|
682
|
-
defaultValues
|
|
683
|
-
});
|
|
684
|
-
});
|
|
685
|
-
return metadata;
|
|
686
|
-
};
|
|
687
|
-
const buildFormField = (descriptor, config) => {
|
|
688
|
-
let { name, label, group } = Object.assign({}, config);
|
|
689
|
-
let { readOnly, required } = Object.assign({}, config);
|
|
690
|
-
let props;
|
|
691
|
-
let userInterface;
|
|
692
|
-
if (descriptor) {
|
|
693
|
-
label = label || descriptor.label;
|
|
694
|
-
name = name || descriptor.name;
|
|
695
|
-
required = descriptor.required || (config === null || config === void 0 ? void 0 : config.required);
|
|
696
|
-
readOnly = descriptor.readOnly || (config === null || config === void 0 ? void 0 : config.readOnly);
|
|
697
|
-
props = descriptor.properties;
|
|
698
|
-
userInterface = descriptor.userInterface;
|
|
699
|
-
}
|
|
700
|
-
return {
|
|
701
|
-
name, label, group,
|
|
702
|
-
readOnly, required,
|
|
703
|
-
props,
|
|
704
|
-
userInterface: userInterface || UserInterface.SHORTTEXT
|
|
705
|
-
};
|
|
706
|
-
};
|
|
707
|
-
const getTabConfig = (tab, sheets) => {
|
|
708
|
-
const tabConfig = (typeof tab === "string" ? Array.from(sheets.keys()).find(t => t.label === tab) : tab);
|
|
709
|
-
return tabConfig || { label: tab, visible: true };
|
|
710
|
-
};
|
|
711
|
-
const sortTabs = (a, b) => {
|
|
712
|
-
return a[0].label == '__main' ? -1 : (a[0].order || 10000) - (b[0].order || 10000);
|
|
713
|
-
};
|
|
714
|
-
|
|
715
|
-
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%}";
|
|
857
|
+
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%}";
|
|
716
858
|
|
|
717
859
|
let EzForm = class {
|
|
718
860
|
constructor(hostRef) {
|
|
@@ -840,9 +982,8 @@ let EzForm = class {
|
|
|
840
982
|
return result;
|
|
841
983
|
}
|
|
842
984
|
buildFormContent(sheetId, currentSheet) {
|
|
843
|
-
const fields = currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.fields;
|
|
844
985
|
if (this.contentBuilder != undefined) {
|
|
845
|
-
const customContent = this.contentBuilder(sheetId,
|
|
986
|
+
const customContent = this.contentBuilder(sheetId, currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.items, buildField);
|
|
846
987
|
if (customContent != undefined) {
|
|
847
988
|
return h("div", { "innerHTML": customContent });
|
|
848
989
|
}
|
|
@@ -851,7 +992,7 @@ let EzForm = class {
|
|
|
851
992
|
return;
|
|
852
993
|
}
|
|
853
994
|
const idFormSheet = `${StringUtils.replaceAccentuatedChars(StringUtils.toCamelCase(currentSheet === null || currentSheet === void 0 ? void 0 : currentSheet.label), false)}_selectorContainer`;
|
|
854
|
-
return
|
|
995
|
+
return h(FormSheet, { store: this._store, source: currentSheet, dataElementId: idFormSheet });
|
|
855
996
|
}
|
|
856
997
|
processMetadata() {
|
|
857
998
|
if (!this.isStatic() && this.dataUnit && this._store) {
|