@sankhyalabs/sankhyablocks 8.16.0-dev.39 → 8.16.0-dev.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/dist/cjs/index-f9e81701.js +8 -28
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  4. package/dist/cjs/{snk-form-config.cjs.entry.js → snk-config-options_3.cjs.entry.js} +363 -1
  5. package/dist/cjs/{snk-filter-bar.cjs.entry.js → snk-filter-bar_4.cjs.entry.js} +685 -0
  6. package/dist/cjs/snk-simple-crud.cjs.entry.js +3 -1
  7. package/dist/collection/collection-manifest.json +11 -31
  8. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +3 -1
  9. package/dist/collection/sw.js +46 -0
  10. package/dist/components/snk-simple-crud2.js +3 -1
  11. package/dist/esm/{SnkFormConfigManager-139f09fa.js → SnkFormConfigManager-f1a0fc92.js} +1 -1
  12. package/dist/esm/{constants-8457af36.js → constants-7302ee87.js} +1 -1
  13. package/dist/esm/index-a7d3d3f1.js +8 -28
  14. package/dist/esm/loader.js +1 -1
  15. package/dist/esm/sankhyablocks.js +1 -1
  16. package/dist/esm/snk-actions-button_4.entry.js +1 -1
  17. package/dist/esm/snk-attach.entry.js +1 -1
  18. package/dist/esm/{snk-form-config.entry.js → snk-config-options_3.entry.js} +364 -4
  19. package/dist/esm/snk-configurator.entry.js +1 -1
  20. package/dist/esm/snk-crud.entry.js +1 -1
  21. package/dist/esm/snk-data-exporter.entry.js +1 -1
  22. package/dist/esm/snk-detail-view.entry.js +3 -3
  23. package/dist/esm/snk-field-config.entry.js +1 -1
  24. package/dist/esm/{snk-filter-bar.entry.js → snk-filter-bar_4.entry.js} +684 -2
  25. package/dist/esm/{snk-guides-viewer-c1ef991c.js → snk-guides-viewer-2f4dcdc5.js} +2 -2
  26. package/dist/esm/snk-guides-viewer.entry.js +3 -3
  27. package/dist/esm/snk-simple-crud.entry.js +5 -3
  28. package/dist/esm/snk-tab-config.entry.js +1 -1
  29. package/dist/sankhyablocks/p-052213ba.entry.js +1 -0
  30. package/dist/sankhyablocks/{p-11a0a7ac.entry.js → p-0b6cd238.entry.js} +1 -1
  31. package/dist/sankhyablocks/p-0e320bd2.entry.js +1 -0
  32. package/dist/sankhyablocks/{p-281bc322.entry.js → p-275de842.entry.js} +1 -1
  33. package/dist/sankhyablocks/{p-8eb67fa4.entry.js → p-2d3f9482.entry.js} +1 -1
  34. package/dist/sankhyablocks/{p-7663f597.entry.js → p-41793e17.entry.js} +1 -1
  35. package/dist/sankhyablocks/{p-1b6d51bf.entry.js → p-5e51e833.entry.js} +1 -1
  36. package/dist/sankhyablocks/{p-d3341910.entry.js → p-72c10005.entry.js} +1 -1
  37. package/dist/sankhyablocks/{p-11cc69fc.js → p-7bd9683d.js} +1 -1
  38. package/dist/sankhyablocks/{p-95df461f.entry.js → p-8b4fc28f.entry.js} +1 -1
  39. package/dist/sankhyablocks/{p-b0ef4383.js → p-95ce311a.js} +1 -1
  40. package/dist/sankhyablocks/{p-5ea74956.entry.js → p-ab1645fb.entry.js} +1 -1
  41. package/dist/sankhyablocks/{p-47f79aa0.entry.js → p-cefb0ee1.entry.js} +1 -1
  42. package/dist/sankhyablocks/p-fa6c5826.entry.js +1 -0
  43. package/dist/sankhyablocks/{p-afbb070d.js → p-fadc8339.js} +1 -1
  44. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  45. package/package.json +3 -2
  46. package/dist/cjs/snk-config-options.cjs.entry.js +0 -239
  47. package/dist/cjs/snk-filter-item.cjs.entry.js +0 -312
  48. package/dist/cjs/snk-filter-list.cjs.entry.js +0 -152
  49. package/dist/cjs/snk-filter-modal.cjs.entry.js +0 -249
  50. package/dist/cjs/snk-form.cjs.entry.js +0 -144
  51. package/dist/esm/snk-config-options.entry.js +0 -235
  52. package/dist/esm/snk-filter-item.entry.js +0 -308
  53. package/dist/esm/snk-filter-list.entry.js +0 -148
  54. package/dist/esm/snk-filter-modal.entry.js +0 -245
  55. package/dist/esm/snk-form.entry.js +0 -140
  56. package/dist/sankhyablocks/p-06898e5a.entry.js +0 -1
  57. package/dist/sankhyablocks/p-3b60db06.entry.js +0 -1
  58. package/dist/sankhyablocks/p-60b29483.entry.js +0 -1
  59. package/dist/sankhyablocks/p-70a4af56.entry.js +0 -1
  60. package/dist/sankhyablocks/p-b9679243.entry.js +0 -1
  61. package/dist/sankhyablocks/p-d3f53df2.entry.js +0 -1
  62. package/dist/sankhyablocks/p-e8763234.entry.js +0 -1
  63. package/dist/sankhyablocks/p-feba9d4b.entry.js +0 -1
@@ -3,16 +3,376 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-f9e81701.js');
6
- const Sortable = require('./Sortable-fb1c4cbb.js');
7
6
  const core = require('@sankhyalabs/core');
7
+ const DataType = require('@sankhyalabs/core/dist/dataunit/metadata/DataType');
8
8
  const utils = require('@sankhyalabs/ezui/dist/collection/utils');
9
9
  const constants = require('./constants-35ddd366.js');
10
+ const SnkFormConfigManager = require('./SnkFormConfigManager-f1c92f79.js');
11
+ const ResourceIDUtils = require('./ResourceIDUtils-5ff86aa7.js');
12
+ const Sortable = require('./Sortable-fb1c4cbb.js');
10
13
  const formConfigFetcher = require('./form-config-fetcher-ed497282.js');
11
14
  const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
15
+ require('./ConfigStorage-ecc0ed20.js');
16
+ require('./filter-item-type.enum-a7ffdaa6.js');
12
17
  require('./DataFetcher-cadeef8e.js');
13
18
  require('./PrintUtils-bcaeb82f.js');
14
19
  require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
15
20
 
21
+ const snkConfigOptionsCss = ".sc-snk-config-options-h{--snk-config-options--border:2px solid var(--color--secondary-200, #D2D3DA);width:100%;border-radius:15px;border:var(--snk-config-options--border)}.config-options__switch-row.sc-snk-config-options{margin-top:-30px}";
22
+
23
+ const SnkConfigOptions = class {
24
+ constructor(hostRef) {
25
+ index.registerInstance(this, hostRef);
26
+ this.configOptionsChanged = index.createEvent(this, "configOptionsChanged", 7);
27
+ this._defaultType = undefined;
28
+ this.fieldConfig = {};
29
+ this.idConfig = undefined;
30
+ this.dataUnit = undefined;
31
+ this.messagesBuilder = undefined;
32
+ }
33
+ onConfigDefault(optionSelected) {
34
+ if (optionSelected != undefined) {
35
+ this._defaultType = optionSelected;
36
+ this.fieldConfig.defaultValue = {
37
+ type: this._defaultType
38
+ };
39
+ this.configOptionsChanged.emit(this.fieldConfig);
40
+ }
41
+ }
42
+ buildOptions() {
43
+ var _a, _b, _c;
44
+ let interfaceField = (_c = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField((_b = this.fieldConfig) === null || _b === void 0 ? void 0 : _b.name)) === null || _c === void 0 ? void 0 : _c.userInterface;
45
+ if (interfaceField === core.UserInterface.SEARCH) {
46
+ interfaceField = core.UserInterface.INTEGERNUMBER;
47
+ }
48
+ return constants.VARS_BY_TYPE.UserInterface[interfaceField];
49
+ }
50
+ enabledValueDefault() {
51
+ var _a, _b, _c;
52
+ const field = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField((_b = this.fieldConfig) === null || _b === void 0 ? void 0 : _b.name);
53
+ const allowDefault = (_c = field === null || field === void 0 ? void 0 : field.properties) === null || _c === void 0 ? void 0 : _c.allowDefault;
54
+ const hasVariableVar = constants.VARS_BY_TYPE.UserInterface.hasOwnProperty(field === null || field === void 0 ? void 0 : field.userInterface)
55
+ || (field === null || field === void 0 ? void 0 : field.userInterface) === core.UserInterface.SEARCH;
56
+ if ((allowDefault == undefined || allowDefault === "true") && hasVariableVar) {
57
+ return true;
58
+ }
59
+ return false;
60
+ }
61
+ isAllowDefault() {
62
+ var _a, _b;
63
+ const allowDefault = (_b = (_a = this._fieldProperties) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.allowDefault;
64
+ if (allowDefault == undefined) {
65
+ return true;
66
+ }
67
+ return allowDefault === "true";
68
+ }
69
+ loadDefaultValue() {
70
+ var _a;
71
+ if (this.fieldConfig == undefined) {
72
+ this._defaultType = constants.DEFAULT_TYPE.fixed;
73
+ this.fieldConfig = {
74
+ defaultValue: {
75
+ type: this._defaultType
76
+ }
77
+ };
78
+ }
79
+ else if (((_a = this.fieldConfig.defaultValue) === null || _a === void 0 ? void 0 : _a.type) == undefined) {
80
+ this._defaultType = constants.DEFAULT_TYPE.fixed;
81
+ this.fieldConfig.defaultValue = {
82
+ type: this._defaultType
83
+ };
84
+ }
85
+ else {
86
+ this._defaultType = this.fieldConfig.defaultValue.type;
87
+ }
88
+ }
89
+ getFieldProperties(field) {
90
+ var _a;
91
+ if (field != undefined) {
92
+ return (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(field);
93
+ }
94
+ }
95
+ getMessage(key, params) {
96
+ return this.messagesBuilder.getMessage(key, params);
97
+ }
98
+ getDefaultType() {
99
+ var _a;
100
+ return (_a = this.fieldConfig.defaultValue.type) !== null && _a !== void 0 ? _a : constants.DEFAULT_TYPE.fixed;
101
+ }
102
+ getEnabledByProperty(attribName, propertyName) {
103
+ const fieldDescriptor = this._fieldProperties;
104
+ if (fieldDescriptor == undefined) {
105
+ return true;
106
+ }
107
+ const fieldProperties = fieldDescriptor.properties || {};
108
+ return fieldProperties.hasOwnProperty(propertyName) ? fieldProperties[propertyName] !== "S" : fieldDescriptor[attribName] !== true;
109
+ }
110
+ getValueByProperty(property) {
111
+ const properties = this._fieldProperties;
112
+ if (properties != undefined && properties[property] === true) {
113
+ return true;
114
+ }
115
+ return this.fieldConfig[property];
116
+ }
117
+ getValidatedValue(fieldValue) {
118
+ var _a, _b;
119
+ if (fieldValue == undefined) {
120
+ return;
121
+ }
122
+ const field = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField((_b = this.fieldConfig) === null || _b === void 0 ? void 0 : _b.name);
123
+ const dataType = field === null || field === void 0 ? void 0 : field.dataType;
124
+ if (dataType == undefined) {
125
+ return;
126
+ }
127
+ const value = (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.waitmessage) != undefined ? undefined :
128
+ dataType !== DataType.DataType.OBJECT && dataType !== DataType.DataType.DATE
129
+ && typeof fieldValue === "object"
130
+ ? fieldValue.value
131
+ : fieldValue;
132
+ return dataType === DataType.DataType.OBJECT ? JSON.stringify(value) : value;
133
+ }
134
+ buildInputDefault({ value, enabled, label, name, required, userInterface }, properties = undefined, mode = undefined) {
135
+ let options;
136
+ let precision = 0;
137
+ let prettyPrecision = 0;
138
+ const TagName = userInterface == undefined || constants.TAGS_BY_TYPE[userInterface] == undefined
139
+ ? constants.TAGS_BY_TYPE.DEFAULT
140
+ : constants.TAGS_BY_TYPE[userInterface];
141
+ if (userInterface === core.UserInterface.OPTIONSELECTOR) {
142
+ const prop = properties === null || properties === void 0 ? void 0 : properties.options;
143
+ if (typeof prop === "string") {
144
+ const parsed = core.ObjectUtils.stringToObject(prop);
145
+ options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
146
+ }
147
+ else {
148
+ options = prop;
149
+ }
150
+ }
151
+ else if (userInterface === core.UserInterface.DECIMALNUMBER) {
152
+ precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
153
+ prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
154
+ }
155
+ return index.h(TagName, Object.assign({ value: value, enabled: enabled, label: label, "data-field-name": name, key: name, onEzChange: (evt) => this.onChange(evt === null || evt === void 0 ? void 0 : evt.detail) }, (this.getConditionalAttributes(userInterface, required, options, precision, prettyPrecision, mode))));
156
+ }
157
+ getConditionalAttributes(userInterface, required, options, precision, prettyPrecision, mode) {
158
+ switch (userInterface) {
159
+ case core.UserInterface.SEARCH:
160
+ return {
161
+ suppressEmptyOption: required,
162
+ optionLoader: (searchArgument) => this.onSearch(searchArgument)
163
+ };
164
+ case core.UserInterface.OPTIONSELECTOR:
165
+ return {
166
+ suppressEmptyOption: required,
167
+ options
168
+ };
169
+ case core.UserInterface.CHECKBOX:
170
+ case core.UserInterface.SWITCH:
171
+ return {
172
+ mode
173
+ };
174
+ case core.UserInterface.INTEGERNUMBER:
175
+ case core.UserInterface.DECIMALNUMBER:
176
+ return {
177
+ precision,
178
+ prettyPrecision,
179
+ onEzStartChange: (evt) => this.onChange(evt === null || evt === void 0 ? void 0 : evt.detail)
180
+ };
181
+ case core.UserInterface.DATE:
182
+ case core.UserInterface.DATETIME:
183
+ case core.UserInterface.TIME:
184
+ return {
185
+ onEzStartChange: (evt) => this.onChange(evt === null || evt === void 0 ? void 0 : evt.detail)
186
+ };
187
+ default:
188
+ return {};
189
+ }
190
+ }
191
+ onChange(fieldValue) {
192
+ this.fieldConfig.defaultValue.value = this.getValidatedValue(fieldValue);
193
+ this.configOptionsChanged.emit(this.fieldConfig);
194
+ }
195
+ onSearch(searchArgument) {
196
+ if (this._application != undefined && this.fieldConfig != undefined) {
197
+ return this._application.executeSearch(searchArgument, this.fieldConfig.name, this.dataUnit);
198
+ }
199
+ }
200
+ buildField(descriptor, config) {
201
+ const { name, label, readOnly, required, defaultValue } = config;
202
+ const { userInterface, properties } = descriptor;
203
+ const allowDefault = properties === null || properties === void 0 ? void 0 : properties.allowDefault;
204
+ let value;
205
+ let enabled = core.StringUtils.getBooleanValue(allowDefault, !readOnly);
206
+ if (userInterface === core.UserInterface.FILE) {
207
+ enabled = false;
208
+ }
209
+ if (enabled) {
210
+ value = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value;
211
+ if (value != undefined) {
212
+ value = DataType.getConvertedValue(descriptor === null || descriptor === void 0 ? void 0 : descriptor.dataType, value);
213
+ }
214
+ }
215
+ const configField = { value, enabled, label, name, required, userInterface };
216
+ switch (userInterface) {
217
+ case core.UserInterface.SWITCH:
218
+ return this.buildInputDefault(configField, undefined, utils.CheckMode.SWITCH);
219
+ case core.UserInterface.CHECKBOX:
220
+ return this.buildInputDefault(configField, undefined, utils.CheckMode.REGULAR);
221
+ case core.UserInterface.OPTIONSELECTOR:
222
+ case core.UserInterface.DECIMALNUMBER:
223
+ return this.buildInputDefault(configField, properties);
224
+ default:
225
+ return this.buildInputDefault(configField);
226
+ }
227
+ }
228
+ componentWillLoad() {
229
+ var _a;
230
+ this.loadDefaultValue();
231
+ this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
232
+ this._fieldProperties = this.getFieldProperties((_a = this.fieldConfig) === null || _a === void 0 ? void 0 : _a.name);
233
+ }
234
+ componentDidLoad() {
235
+ core.ElementIDUtils.addIDInfo(this._element, this.fieldConfig.name);
236
+ }
237
+ render() {
238
+ var _a, _b;
239
+ return (index.h(index.Host, null, index.h("div", { id: this.idConfig }, index.h("div", { class: "ez-row ez-padding--medium" }, index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, index.h("ez-text-input", { label: this.getMessage("snkConfigOptions.label.nameField"), value: (_a = this.fieldConfig) === null || _a === void 0 ? void 0 : _a.label, onEzChange: (evt) => { this.fieldConfig.label = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, index.h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.typeValueDefault"), suppressEmptyOption: true, enabled: this.enabledValueDefault(), onEzChange: (evt) => { var _a; return this.onConfigDefault((_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value); }, value: this.getDefaultType() }, index.h("option", { value: constants.DEFAULT_TYPE.fixed }, this.getMessage("snkConfigOptions.options.valueFixed")), index.h("option", { value: constants.DEFAULT_TYPE.variable }, this.getMessage("snkConfigOptions.options.variable")))), index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, this._defaultType === constants.DEFAULT_TYPE.variable ?
240
+ index.h("ez-combo-box", { label: this.getMessage("snkConfigOptions.label.valueDefault"), enabled: this.isAllowDefault(), onEzChange: (evt) => { var _a; this.fieldConfig.defaultValue.value = (_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value; this.configOptionsChanged.emit(this.fieldConfig); }, value: this.fieldConfig.defaultValue.value, options: this.buildOptions() })
241
+ :
242
+ ((_b = this._fieldProperties) === null || _b === void 0 ? void 0 : _b.userInterface) &&
243
+ this.buildField(this._fieldProperties, this.fieldConfig))), index.h("div", { class: "ez-row ez-padding--medium config-options__switch-row" }, index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, index.h("ez-check", { mode: utils.CheckMode.SWITCH, label: this.getMessage("snkConfigOptions.label.clearDuplicate"), value: this.fieldConfig.cleanOnCopy, onEzChange: (evt) => { this.fieldConfig.cleanOnCopy = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, index.h("ez-check", { mode: utils.CheckMode.SWITCH, label: this.getMessage("snkConfigOptions.label.requiredField"), enabled: this.getEnabledByProperty("required", "systemRequired"), value: this.getValueByProperty("required"), onEzChange: (evt) => { this.fieldConfig.required = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } })), index.h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small" }, index.h("ez-check", { mode: utils.CheckMode.SWITCH, label: this.getMessage("snkConfigOptions.label.protectedField"), enabled: this.getEnabledByProperty("readOnly", "systemReadOnly"), value: this.getValueByProperty("readOnly"), onEzChange: (evt) => { this.fieldConfig.readOnly = evt.detail; this.configOptionsChanged.emit(this.fieldConfig); } }))))));
244
+ }
245
+ get _element() { return index.getElement(this); }
246
+ };
247
+ SnkConfigOptions.style = snkConfigOptionsCss;
248
+
249
+ const snkFormCss = ".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";
250
+
251
+ const SnkForm = class {
252
+ constructor(hostRef) {
253
+ index.registerInstance(this, hostRef);
254
+ this.exit = index.createEvent(this, "exit", 7);
255
+ this.actionClick = index.createEvent(this, "actionClick", 7);
256
+ this.formItemsReady = index.createEvent(this, "formItemsReady", 7);
257
+ this._customEditors = new Map();
258
+ this._dataUnit = undefined;
259
+ this._dataState = undefined;
260
+ this._showFormConfig = false;
261
+ this._configManager = undefined;
262
+ this.configName = undefined;
263
+ this.recordsValidator = undefined;
264
+ this.messagesBuilder = undefined;
265
+ this.formLegacyConfigName = undefined;
266
+ this.resourceID = undefined;
267
+ }
268
+ /**
269
+ * Exibe a janela de configurações do formulário.
270
+ */
271
+ async showConfig() {
272
+ this._showFormConfig = true;
273
+ }
274
+ /**
275
+ * Fecha a janela de configurações do formulário.
276
+ */
277
+ async hideConfig() {
278
+ this._showFormConfig = false;
279
+ }
280
+ /**
281
+ * Registra um editor customizado para campos da grade e formulário.
282
+ */
283
+ async addCustomEditor(fieldName, customEditor) {
284
+ if (this._form) {
285
+ this._form.addCustomEditor(fieldName, customEditor);
286
+ return;
287
+ }
288
+ const newCustomEditors = new Map(this._customEditors);
289
+ newCustomEditors.set(fieldName, customEditor);
290
+ this._customEditors = newCustomEditors;
291
+ }
292
+ /**
293
+ * Altera/adiciona uma propriedade nos metadados do campo.
294
+ */
295
+ async setFieldProp(fieldName, propName, value) {
296
+ await this._form.setFieldProp(fieldName, propName, value);
297
+ }
298
+ closeConfig() {
299
+ this.hideConfig();
300
+ }
301
+ dataunitReady() {
302
+ const dataInfo = { dataUnit: this._dataUnit };
303
+ core.ElementIDUtils.addIDInfo(this._element, null, dataInfo);
304
+ }
305
+ setCustomEditors() {
306
+ if (!this._form) {
307
+ return;
308
+ }
309
+ for (const [fieldName, customEditor] of this._customEditors) {
310
+ this._form.addCustomEditor(fieldName, customEditor);
311
+ this._customEditors.delete(fieldName);
312
+ }
313
+ }
314
+ async componentDidRender() {
315
+ this.setCustomEditors();
316
+ }
317
+ async componentWillLoad() {
318
+ let parent = this._element.parentElement;
319
+ while (parent) {
320
+ if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
321
+ this._snkDataUnit = parent;
322
+ this._dataUnit = this._snkDataUnit.dataUnit;
323
+ this._dataState = this._snkDataUnit.dataState;
324
+ if (this._dataUnit) {
325
+ this.dataunitReady();
326
+ }
327
+ else {
328
+ this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
329
+ this._dataUnit = evt.detail;
330
+ });
331
+ }
332
+ this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
333
+ break;
334
+ }
335
+ parent = parent.parentElement;
336
+ }
337
+ if (this.resourceID == undefined) {
338
+ this.resourceID = await ResourceIDUtils.ResourceIDUtils.getResourceID();
339
+ }
340
+ this._configManager = new SnkFormConfigManager.SnkFormConfigManager(this.configName, this.resourceID, undefined, this._dataUnit);
341
+ this.addFormLegacyConfig();
342
+ await this._configManager.loadConfig();
343
+ }
344
+ async handleDataStateChange(evt) {
345
+ var _a;
346
+ this._dataState = evt.detail;
347
+ const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
348
+ for (const field of fieldsWithRmPrecision || []) {
349
+ if (!field) {
350
+ continue;
351
+ }
352
+ const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
353
+ if (!rmPrecision && rmPrecision !== 0) {
354
+ continue;
355
+ }
356
+ await this.setFieldProp(field, 'precision', rmPrecision);
357
+ await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
358
+ }
359
+ }
360
+ addFormLegacyConfig() {
361
+ if (this.formLegacyConfigName) {
362
+ this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
363
+ }
364
+ }
365
+ render() {
366
+ if (!this._dataUnit || !this._dataState) {
367
+ return undefined;
368
+ }
369
+ return (index.h("section", null, index.h("div", { class: "ez-row" }, index.h("div", { class: "ez-col ez-col--sd-12" }, index.h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
370
+ index.h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
371
+ }
372
+ get _element() { return index.getElement(this); }
373
+ };
374
+ SnkForm.style = snkFormCss;
375
+
16
376
  const snkFormConfigCss = ".sc-snk-form-config-h{--snk-form-config--z-index:var(--more-visible, 2);--snk-form-config--background-color:var(--background--xlight, #fff);--snk-form-config__icon--color:var(--text--disable, #AFB6C0);--snk-form-config__label-counter--font-weight:var(--text-weight--extra-small, 200);--snk-form-config__add-group-container--border-radius:var(--border--radius-medium, 12px);--snk-form-config__add-group-container--background-color:var(--background--medium, #d2dce9);--snk-form-config__add-group-container--padding:var(--space--small, 6px);--snk-form-config__add-group-content--border:2px dashed var(--color-strokes, #DCE0E8);--snk-form-config__add-group-content--border-radius:var(--border--radius-small, 6px);--snk-form-config__add-group-label--padding:var(--space--large, 24px);--snk-form-config__btn-add-group--padding:var(--space--large, 24px) var(--space--medium, 12px) 0;--snk-form-config__btn-add-group-container--padding:var(--space--medium, 12px);--snk-form-config__btn-add-group-container--border-radius:var(--border--radius-medium, 12px);--snk-form-config__btn-add-group-container--border:2px solid var(--color-strokes, #DCE0E8);--snk-form-config__btn-add-group-container--background-color:var(--background--body, #fafcff);display:flex;flex-direction:column;position:fixed;top:0;left:0;width:100%;height:100%;z-index:var(--snk-form-config--z-index);background-color:var(--snk-form-config--background-color)}div.sc-snk-form-config:focus-visible,div.sc-snk-form-config:focus{outline:none}.form-config__header-container.sc-snk-form-config{display:flex}.form-config__field-container.sc-snk-form-config{width:32%;padding:6px}.form-config__hide-content.sc-snk-form-config{display:none}ez-icon.sc-snk-form-config .left-icon.sc-snk-form-config{--ez-icon--color:var(--snk-form-config__icon--color)}.ez-box__label-counter.sc-snk-form-config{margin-top:-7px;font-weight:var(--snk-form-config__label-counter--font-weight)}.form-config__btn-options.sc-snk-form-config{--ez-button--min-width:300px;--ez-button--background-color:var(--snk-form-config--background-color)}[data-draggable-parent].sc-snk-form-config{position:relative}.form-config__field-config--selected.sc-snk-form-config{position:static}.form-config__field-config--dragged.sc-snk-form-config .draggable-mirror.sc-snk-form-config{z-index:var(--snk-form-config--z-index)}.form-config__config-options.sc-snk-form-config{position:relative;margin-top:-3px;min-width:100%;z-index:1}.form-config__tab-container.sc-snk-form-config,.form-config__fields-available.sc-snk-form-config{position:relative;height:100%;max-height:calc(100vh - 92px)}.form-config__tab-container.sc-snk-form-config .ez-box__container.sc-snk-form-config,.form-config__fields-available.sc-snk-form-config .ez-box__container.sc-snk-form-config{align-content:flex-start;height:100%}.form-config__fields-available.sc-snk-form-config [data-draggable-parent].sc-snk-form-config{align-content:flex-start;overflow-y:auto;height:100%;max-height:calc(100% - 122px)}.form-config__tab-content.sc-snk-form-config{align-content:flex-start;overflow-y:auto;height:auto;max-height:calc(100% - 128px)}[data-draggable-element].sc-snk-form-config{cursor:grab}.form-config__actions-button.sc-snk-form-config{--ez-actions-button__btn-action--min-width:235px}.form-config__add-group.sc-snk-form-config{position:relative;min-height:120px;margin-bottom:10px}.form-config__add-group-container.sc-snk-form-config{position:absolute;display:flex;flex-wrap:wrap;width:100%;box-sizing:border-box;border-radius:var(--snk-form-config__add-group-container--border-radius);background-color:var(--snk-form-config__add-group-container--background-color);padding:var(--snk-form-config__add-group-container--padding)}.form-config__add-group-content.sc-snk-form-config{width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;box-sizing:border-box;border:var(--snk-form-config__add-group-content--border);border-radius:var(--snk-form-config__add-group-content--border-radius)}.form-config__add-group-label.sc-snk-form-config{display:flex;justify-content:center;box-sizing:border-box;padding:var(--snk-form-config__add-group-label--padding)}.form-config__btn-add-group.sc-snk-form-config{position:relative;padding:var(--snk-form-config__btn-add-group--padding)}.form-config__btn-add-group-container.sc-snk-form-config{padding:var(--snk-form-config__btn-add-group-container--padding);border-radius:var(--snk-form-config__btn-add-group-container--border-radius);border:var(--snk-form-config__btn-add-group-container--border);background-color:var(--snk-form-config__btn-add-group-container--background-color)}ez-collapsible-box.draggable-mirror.sc-snk-form-config{display:table;background-color:var(--snk-form-config--background-color)}ez-collapsible-box.sc-snk-form-config{margin-bottom:10px}@media screen and (min-width: 480px){.form-config__field-config--selected.sc-snk-form-config .ez-flex.form-config__config-options.sc-snk-form-config{min-width:calc(300% + 12px)}.form-config__field-config--selected.sc-snk-form-config:nth-child(3n+2) .ez-flex.form-config__config-options.sc-snk-form-config{left:calc(100% / 1 * -1)}.form-config__field-config--selected.sc-snk-form-config:nth-child(3n+3) .ez-flex.form-config__config-options.sc-snk-form-config{left:calc(100% / 1 * -2)}}";
17
377
 
18
378
  const CONTAINER_ID = {
@@ -1011,4 +1371,6 @@ const SnkFormConfig = class {
1011
1371
  };
1012
1372
  SnkFormConfig.style = snkFormConfigCss;
1013
1373
 
1374
+ exports.snk_config_options = SnkConfigOptions;
1375
+ exports.snk_form = SnkForm;
1014
1376
  exports.snk_form_config = SnkFormConfig;