@sankhyalabs/ezui 0.0.0-bugfix-dev-KB-76362.0 → 0.0.0-bugfix-dev-KB-75609.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/DataBinder-aff1dcc7.js +445 -0
- package/dist/cjs/FocusResolver-885f2173.js +35 -0
- package/dist/cjs/ez-card-item_3.cjs.entry.js +12 -19
- package/dist/cjs/ez-combo-box.cjs.entry.js +46 -10
- package/dist/cjs/ez-date-input.cjs.entry.js +8 -2
- package/dist/cjs/ez-date-time-input.cjs.entry.js +8 -2
- package/dist/cjs/ez-dialog.cjs.entry.js +9 -1
- package/dist/cjs/ez-form.cjs.entry.js +3 -324
- package/dist/cjs/ez-grid.cjs.entry.js +254 -62
- package/dist/cjs/ez-list.cjs.entry.js +151 -100
- package/dist/cjs/ez-number-input.cjs.entry.js +7 -0
- package/dist/cjs/ez-popover.cjs.entry.js +1 -1
- package/dist/cjs/ez-popup.cjs.entry.js +2 -9
- package/dist/cjs/ez-search.cjs.entry.js +28 -12
- package/dist/cjs/ez-text-area.cjs.entry.js +66 -4
- package/dist/cjs/ez-text-input.cjs.entry.js +8 -3
- package/dist/cjs/ez-time-input.cjs.entry.js +6 -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-card-item/ez-card-item.css +14 -5
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +75 -14
- package/dist/collection/components/ez-date-input/ez-date-input.js +35 -4
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +35 -4
- package/dist/collection/components/ez-dialog/ez-dialog.js +9 -1
- package/dist/collection/components/ez-filter-input/ez-filter-input.css +0 -11
- package/dist/collection/components/ez-filter-input/ez-filter-input.js +22 -52
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +52 -14
- package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +3 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +166 -45
- package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +7 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +4 -1
- package/dist/collection/components/ez-grid/ez-grid.js +83 -1
- package/dist/collection/components/ez-list/ez-list.css +5 -5
- package/dist/collection/components/ez-list/ez-list.js +152 -170
- package/dist/collection/components/ez-number-input/ez-number-input.js +25 -0
- package/dist/collection/components/ez-popover/ez-popover.css +3 -10
- package/dist/collection/components/ez-popup/ez-popup.css +2 -6
- package/dist/collection/components/ez-popup/ez-popup.js +3 -10
- package/dist/collection/components/ez-search/ez-search.css +1 -1
- package/dist/collection/components/ez-search/ez-search.js +55 -14
- package/dist/collection/components/ez-text-area/ez-text-area.css +49 -0
- package/dist/collection/components/ez-text-area/ez-text-area.js +102 -2
- package/dist/collection/components/ez-text-input/ez-text-input.css +27 -53
- package/dist/collection/components/ez-text-input/ez-text-input.js +25 -2
- package/dist/collection/components/ez-time-input/ez-time-input.js +24 -0
- package/dist/collection/utils/FocusResolver.js +31 -0
- package/dist/collection/utils/form/DataBinder.js +18 -3
- package/dist/custom-elements/index.js +663 -237
- package/dist/esm/DataBinder-bd240826.js +441 -0
- package/dist/esm/FocusResolver-1ccbf850.js +33 -0
- package/dist/esm/ez-card-item_3.entry.js +12 -19
- package/dist/esm/ez-combo-box.entry.js +47 -11
- package/dist/esm/ez-date-input.entry.js +8 -2
- package/dist/esm/ez-date-time-input.entry.js +8 -2
- package/dist/esm/ez-dialog.entry.js +9 -1
- package/dist/esm/ez-form.entry.js +2 -323
- package/dist/esm/ez-grid.entry.js +253 -61
- package/dist/esm/ez-list.entry.js +152 -101
- package/dist/esm/ez-number-input.entry.js +7 -0
- package/dist/esm/ez-popover.entry.js +1 -1
- package/dist/esm/ez-popup.entry.js +2 -9
- package/dist/esm/ez-search.entry.js +28 -12
- package/dist/esm/ez-text-area.entry.js +66 -4
- package/dist/esm/ez-text-input.entry.js +8 -3
- package/dist/esm/ez-time-input.entry.js +6 -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-03a2c7d1.entry.js +1 -0
- package/dist/ezui/p-0a75bb05.entry.js +1 -0
- package/dist/ezui/p-0db68715.entry.js +1 -0
- package/dist/ezui/p-19098a3f.entry.js +1 -0
- package/dist/ezui/p-1f830a2f.entry.js +1 -0
- package/dist/ezui/p-3dd919b7.entry.js +1 -0
- package/dist/ezui/p-7bfae0fc.entry.js +1 -0
- package/dist/ezui/p-81f06699.js +1 -0
- package/dist/ezui/p-97af4b13.entry.js +1 -0
- package/dist/ezui/p-9ceefe4d.entry.js +1 -0
- package/dist/ezui/p-a80b1287.entry.js +1 -0
- package/dist/ezui/{p-c3c3d640.entry.js → p-b0a5c2cd.entry.js} +2 -2
- package/dist/ezui/p-b54e17d2.entry.js +1 -0
- package/dist/ezui/p-bfad39eb.entry.js +1 -0
- package/dist/ezui/p-d0ca26fe.entry.js +1 -0
- package/dist/ezui/p-dc628ed3.js +1 -0
- package/dist/ezui/p-ffd246f5.entry.js +1 -0
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +7 -1
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +6 -1
- package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +6 -1
- package/dist/types/components/ez-dialog/ez-dialog.d.ts +2 -0
- package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +4 -11
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +10 -0
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -0
- package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +18 -6
- package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +2 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +1 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +10 -0
- package/dist/types/components/ez-list/ez-list.d.ts +3 -26
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +4 -0
- package/dist/types/components/ez-popup/ez-popup.d.ts +2 -2
- package/dist/types/components/ez-search/ez-search.d.ts +6 -1
- package/dist/types/components/ez-text-area/ez-text-area.d.ts +17 -0
- package/dist/types/components/ez-text-input/ez-text-input.d.ts +4 -0
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +4 -0
- package/dist/types/components.d.ts +101 -44
- package/dist/types/utils/FocusResolver.d.ts +5 -0
- package/dist/types/utils/form/DataBinder.d.ts +3 -0
- package/package.json +1 -1
- package/dist/cjs/RecordValidationProcessor-10846595.js +0 -108
- package/dist/esm/RecordValidationProcessor-9c6cc267.js +0 -105
- package/dist/ezui/p-188f1c4c.entry.js +0 -1
- package/dist/ezui/p-25ac5376.entry.js +0 -1
- package/dist/ezui/p-49456b34.entry.js +0 -1
- package/dist/ezui/p-5a90d7d1.entry.js +0 -1
- package/dist/ezui/p-62732269.entry.js +0 -1
- package/dist/ezui/p-86b6aa01.entry.js +0 -1
- package/dist/ezui/p-b3b94f72.entry.js +0 -1
- package/dist/ezui/p-b95632e8.entry.js +0 -1
- package/dist/ezui/p-bcd47eda.entry.js +0 -1
- package/dist/ezui/p-d2c06f38.entry.js +0 -1
- package/dist/ezui/p-dc4ada32.entry.js +0 -1
- package/dist/ezui/p-e85c48d7.entry.js +0 -1
- package/dist/ezui/p-f299c608.entry.js +0 -1
- package/dist/ezui/p-f42855b9.js +0 -1
- package/dist/ezui/p-f80ac647.entry.js +0 -1
|
@@ -38,12 +38,13 @@ const EzComboBox = class {
|
|
|
38
38
|
this.suppressSearch = false;
|
|
39
39
|
this.optionLoader = undefined;
|
|
40
40
|
this.suppressEmptyOption = false;
|
|
41
|
-
this.stopPropagateEnterKeyEvent =
|
|
41
|
+
this.stopPropagateEnterKeyEvent = true;
|
|
42
42
|
this.canShowError = true;
|
|
43
43
|
this.mode = "regular";
|
|
44
44
|
this.hideErrorOnFocusOut = true;
|
|
45
45
|
this.listOptionsPosition = undefined;
|
|
46
46
|
this.isTextSearch = false;
|
|
47
|
+
this.autoFocus = false;
|
|
47
48
|
}
|
|
48
49
|
observeErrorMessage() {
|
|
49
50
|
var _a;
|
|
@@ -106,9 +107,9 @@ const EzComboBox = class {
|
|
|
106
107
|
/**
|
|
107
108
|
* Aplica o foco no campo.
|
|
108
109
|
*/
|
|
109
|
-
async setFocus() {
|
|
110
|
+
async setFocus(options) {
|
|
110
111
|
if (this._textInput) {
|
|
111
|
-
this._textInput.setFocus();
|
|
112
|
+
this._textInput.setFocus(options);
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
@@ -268,11 +269,15 @@ const EzComboBox = class {
|
|
|
268
269
|
: undefined, index.h("span", { class: "item__label " + (this.showOptionValue ? "item__label--bold" : ""), title: opt.label }, opt.label));
|
|
269
270
|
}
|
|
270
271
|
showOptions() {
|
|
272
|
+
var _a, _b;
|
|
271
273
|
if (!this.enabled)
|
|
272
274
|
return;
|
|
273
275
|
if (this.isOptionsVisible()) {
|
|
274
276
|
return;
|
|
275
277
|
}
|
|
278
|
+
const valueString = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : this.value;
|
|
279
|
+
const indexValue = this._visibleOptions.findIndex(option => option.value === valueString);
|
|
280
|
+
this._preSelection = indexValue === -1 ? 0 : indexValue;
|
|
276
281
|
if (!!this._resizeObserver)
|
|
277
282
|
this._resizeObserver.observe(this._textInput);
|
|
278
283
|
this._floatingID = core.FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, isFixed: true, backClickListener: () => this.hideOptions() });
|
|
@@ -314,11 +319,26 @@ const EzComboBox = class {
|
|
|
314
319
|
liElem.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
315
320
|
});
|
|
316
321
|
}
|
|
317
|
-
selectCurrentOption() {
|
|
322
|
+
selectCurrentOption(focusOnInput = true) {
|
|
318
323
|
if (this._preSelection !== undefined) {
|
|
319
|
-
this.selectOption(this._visibleOptions[this._preSelection]);
|
|
324
|
+
this.selectOption(this._visibleOptions[this._preSelection], focusOnInput);
|
|
320
325
|
this._preSelection = undefined;
|
|
321
326
|
}
|
|
327
|
+
else {
|
|
328
|
+
this.controlListWithOnlyOne(focusOnInput);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
controlListWithOnlyOne(focusOnInput = true) {
|
|
332
|
+
var _a;
|
|
333
|
+
const source = (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.filter((opt) => opt.label !== "" && opt.value != undefined);
|
|
334
|
+
if ((source === null || source === void 0 ? void 0 : source.length) > 0) {
|
|
335
|
+
let title = core.StringUtils.decodeHtmlEntities(source[0].label);
|
|
336
|
+
const option = {
|
|
337
|
+
value: source[0].value,
|
|
338
|
+
label: title,
|
|
339
|
+
};
|
|
340
|
+
this.selectOption(option, focusOnInput);
|
|
341
|
+
}
|
|
322
342
|
}
|
|
323
343
|
updateSource(source) {
|
|
324
344
|
this._startLoading = false;
|
|
@@ -344,7 +364,7 @@ const EzComboBox = class {
|
|
|
344
364
|
}
|
|
345
365
|
}
|
|
346
366
|
}
|
|
347
|
-
selectOption(newOption) {
|
|
367
|
+
selectOption(newOption, focusOnInput = true) {
|
|
348
368
|
var _a, _b;
|
|
349
369
|
const currentValue = this.getSelectedOption(this.value);
|
|
350
370
|
if ((((_a = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = newOption === null || newOption === void 0 ? void 0 : newOption.value) === null || _b === void 0 ? void 0 : _b.toString()))
|
|
@@ -355,6 +375,11 @@ const EzComboBox = class {
|
|
|
355
375
|
else {
|
|
356
376
|
this.resetOptions();
|
|
357
377
|
}
|
|
378
|
+
if (focusOnInput) {
|
|
379
|
+
setTimeout(() => {
|
|
380
|
+
this.setFocus();
|
|
381
|
+
}, 0);
|
|
382
|
+
}
|
|
358
383
|
}
|
|
359
384
|
loadOptions(mode, argument = "") {
|
|
360
385
|
this._criteria = argument;
|
|
@@ -438,6 +463,11 @@ const EzComboBox = class {
|
|
|
438
463
|
}
|
|
439
464
|
});
|
|
440
465
|
});
|
|
466
|
+
if (this.autoFocus) {
|
|
467
|
+
requestAnimationFrame(() => {
|
|
468
|
+
this.setFocus({ selectText: true });
|
|
469
|
+
});
|
|
470
|
+
}
|
|
441
471
|
}
|
|
442
472
|
//---------------------------------------------
|
|
443
473
|
// Event handlers
|
|
@@ -492,18 +522,24 @@ const EzComboBox = class {
|
|
|
492
522
|
}
|
|
493
523
|
switch (event.key) {
|
|
494
524
|
case "ArrowDown":
|
|
525
|
+
event.stopPropagation();
|
|
526
|
+
if (this.canShowListOptions())
|
|
527
|
+
event.preventDefault();
|
|
495
528
|
this.showOptions();
|
|
496
529
|
this.nextOption();
|
|
497
|
-
event.stopPropagation();
|
|
498
530
|
break;
|
|
499
531
|
case "ArrowUp":
|
|
532
|
+
event.stopPropagation();
|
|
533
|
+
if (this.canShowListOptions())
|
|
534
|
+
event.preventDefault();
|
|
500
535
|
this.showOptions();
|
|
501
536
|
this.previousOption();
|
|
502
|
-
event.stopPropagation();
|
|
503
537
|
break;
|
|
504
538
|
case "Enter":
|
|
505
539
|
this.handleEventPropagation(event);
|
|
506
|
-
this.
|
|
540
|
+
if (this.isOptionsVisible()) {
|
|
541
|
+
this.selectCurrentOption();
|
|
542
|
+
}
|
|
507
543
|
break;
|
|
508
544
|
case "Escape":
|
|
509
545
|
if (this.isOptionsVisible()) {
|
|
@@ -515,7 +551,7 @@ const EzComboBox = class {
|
|
|
515
551
|
case "Tab":
|
|
516
552
|
this._tabPressed = true;
|
|
517
553
|
if (this.isOptionsVisible()) {
|
|
518
|
-
this.selectCurrentOption();
|
|
554
|
+
this.selectCurrentOption(false);
|
|
519
555
|
}
|
|
520
556
|
this.resetOptions();
|
|
521
557
|
break;
|
|
@@ -23,6 +23,7 @@ const EzDateInput = class {
|
|
|
23
23
|
this.errorMessage = undefined;
|
|
24
24
|
this.mode = "regular";
|
|
25
25
|
this.canShowError = true;
|
|
26
|
+
this.autoFocus = false;
|
|
26
27
|
}
|
|
27
28
|
observeLabel() {
|
|
28
29
|
if (this._textInput) {
|
|
@@ -59,8 +60,8 @@ const EzDateInput = class {
|
|
|
59
60
|
/**
|
|
60
61
|
* Aplica o foco no campo.
|
|
61
62
|
*/
|
|
62
|
-
async setFocus() {
|
|
63
|
-
this._textInput.setFocus();
|
|
63
|
+
async setFocus(options) {
|
|
64
|
+
this._textInput.setFocus(options);
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
66
67
|
* Remove o foco do campo.
|
|
@@ -178,6 +179,11 @@ const EzDateInput = class {
|
|
|
178
179
|
componentDidLoad() {
|
|
179
180
|
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
180
181
|
this.setInputValue();
|
|
182
|
+
if (this.autoFocus) {
|
|
183
|
+
requestAnimationFrame(() => {
|
|
184
|
+
this.setFocus({ selectText: true });
|
|
185
|
+
});
|
|
186
|
+
}
|
|
181
187
|
}
|
|
182
188
|
render() {
|
|
183
189
|
core.ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
|
|
@@ -24,6 +24,7 @@ const EzDateTimeInput = class {
|
|
|
24
24
|
this.showSeconds = false;
|
|
25
25
|
this.mode = "regular";
|
|
26
26
|
this.canShowError = true;
|
|
27
|
+
this.autoFocus = false;
|
|
27
28
|
}
|
|
28
29
|
observeLabel() {
|
|
29
30
|
if (this._textInput) {
|
|
@@ -60,8 +61,8 @@ const EzDateTimeInput = class {
|
|
|
60
61
|
/**
|
|
61
62
|
* Aplica o foco no campo.
|
|
62
63
|
*/
|
|
63
|
-
async setFocus() {
|
|
64
|
-
this._textInput.setFocus();
|
|
64
|
+
async setFocus(options) {
|
|
65
|
+
this._textInput.setFocus(options);
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* Remove o foco do campo.
|
|
@@ -228,6 +229,11 @@ const EzDateTimeInput = class {
|
|
|
228
229
|
componentDidLoad() {
|
|
229
230
|
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
230
231
|
this.setInputValue();
|
|
232
|
+
if (this.autoFocus) {
|
|
233
|
+
requestAnimationFrame(() => {
|
|
234
|
+
this.setFocus({ selectText: true });
|
|
235
|
+
});
|
|
236
|
+
}
|
|
231
237
|
}
|
|
232
238
|
render() {
|
|
233
239
|
core.ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const index = require('./index-a7b0c73d.js');
|
|
6
6
|
const DialogType = require('./DialogType-2114c337.js');
|
|
7
7
|
const core = require('@sankhyalabs/core');
|
|
8
|
+
const FocusResolver = require('./FocusResolver-885f2173.js');
|
|
8
9
|
|
|
9
10
|
const ezDialogCss = ":host{--dialog__container-padding:var(--space--large, 24px);--dialog__btn__close--background-color:var(--title--primary, #2b3a54);--dialog__btn__no--padding-right:var(--space--large, 24px);--dialog__btn__close__image:url('data:image/svg+xml;utf8,<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" xmlns=\"http://www.w3.org/2000/svg%22%3E<path d=\"M 7.0060773,5.995511 11.461972,1.5397722 c 0.132856,-0.1328413 0.207547,-0.3130253 0.207547,-0.5009046 0,-0.18786999 -0.07469,-0.3680541 -0.207547,-0.5009048 -0.132857,-0.13284126 -0.31302,-0.20748126 -0.500927,-0.20748126 -0.187812,0 -0.36807,0.07464 -0.500926,0.20748126 L 6.0042244,4.9937015 1.5482921,0.5379628 C 1.4154357,0.40512154 1.2352533,0.33048154 1.0473657,0.33048154 c -0.18787813,0 -0.36807,0.07464 -0.50092647,0.20748126 -0.13285646,0.1328507 -0.20749026,0.31303481 -0.20749026,0.5009048 0,0.1878793 0.0746338,0.3680633 0.20749026,0.5009046 L 5.0023715,5.995511 0.54643923,10.452213 c -0.0676086,0.06534 -0.12151598,0.14352 -0.15859681,0.229916 -0.0370714,0.08639 -0.0565645,0.1794 -0.0573369,0.27335 -7.724e-4,0.09404 0.0171873,0.187331 0.0528423,0.274293 0.0356455,0.08705 0.0882688,0.166087 0.15479148,0.23256 0.0665321,0.06648 0.14562277,0.11897 0.2326735,0.154567 0.0870507,0.0356 0.18031463,0.05344 0.2743433,0.05259 0.094029,-8.5e-4 0.1869528,-0.02049 0.2733331,-0.0576 0.08639,-0.0372 0.1645078,-0.09121 0.2298029,-0.158817 L 6.0042244,6.9973204 10.460119,11.453078 c 0.132856,0.132851 0.313114,0.207444 0.500926,0.207444 0.187907,0 0.36807,-0.07459 0.500927,-0.207444 0.132856,-0.13285 0.207547,-0.313006 0.207547,-0.500904 0,-0.187898 -0.07469,-0.368054 -0.207547,-0.500905 z\"/></svg>');--dialog__title--font-pattern:var(--font-pattern, \"Roboto\");--dialog__title--padding-left:var(--space--small, 6px);--dialog__title__container--padding-bottom:var(--space--medium, 12px);--dialog__title--weight--large:var(--text-weight--large, 600);--dialog__body--font-pattern:var(--font-pattern, \"Roboto\");--dialog__body--text-shadow:var(--text-shadow, \"0 0 0 #353535, 0 0 1px transparent\");--dialog__body--text-weight--medium:var(--text-weight--medium, 400);--dialog__body--padding-bottom:var(--space--large, 24px);--dialog__body--font-size:var(--text--medium, 14px);--dialog__body--color:var(--text--primary, #626e82);--dialog__icon--color:var(--text--inverted, #fff);--dialog__critical--background-color:var(--color--alert-error-800, #BD0025);--dialog__warning--background-color:var(--color--alert-warning-500, #EFB103);--dialog__success--background-color:var(--color--alert-success-500, #00523c);--dialog-z-index:var(--elevation--100, 100);--dialog--warning__image:url('data: image/svg+xml;utf8,<svg width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M 7.5,0 0,13 h 15 z m 0,2.73684 5.1341,8.89476 H 2.36591 Z M 6.81818,5.47368 V 8.21053 H 8.18182 V 5.47368 Z m 0,4.10527 V 10.9474 H 8.18182 V 9.57895\"/></svg>');--dialog--critical__image:url('data: image/svg+xml;utf8,<svg width=\"13\" height=\"13\" viewBox=\"0 0 13 13\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M 7.6534493,6.4948538 12.762051,1.3864299 C 12.914368,1.2341297 13,1.027552 13,0.81215179 13,0.59676225 12.914369,0.39018443 12.762051,0.23787352 12.609733,0.08557341 12.40318,0 12.187747,0 11.972425,0 11.765762,0.08557341 11.613445,0.23787352 L 6.5048431,5.3462975 1.3961977,0.23787352 C 1.2438802,0.08557341 1.0373043,0 0.82189458,0 0.60649572,0 0.39990901,0.08557341 0.24759147,0.23787352 0.09527396,0.39018443 0.00970766,0.59676225 0.00970766,0.81215179 c 0,0.21540021 0.0855663,0.42197791 0.23788381,0.57427811 L 5.3562369,6.4948538 0.24759147,11.604381 c -0.0775121,0.07492 -0.13931586,0.164543 -0.18182835,0.263595 -0.04250169,0.09905 -0.064850182,0.205678 -0.0657357237,0.313391 -8.8554258e-4,0.107813 0.0197049337,0.214771 0.0605827337,0.314472 0.04086693,0.0998 0.10119858,0.190415 0.17746563,0.266625 0.0762779,0.07622 0.16695386,0.136398 0.26675594,0.177208 0.099802,0.04082 0.20672745,0.06127 0.31452961,0.06029 0.1078025,-9.53e-4 0.21433799,-0.0235 0.31337139,-0.06604 0.099045,-0.04265 0.1886052,-0.104571 0.263465,-0.182081 L 6.5048431,7.6434102 11.613445,12.751855 c 0.152317,0.152312 0.35898,0.237831 0.574302,0.237831 0.215433,0 0.421986,-0.08552 0.574304,-0.237831 C 12.914368,12.599545 13,12.393 13,12.177578 13,11.962157 12.91437,11.75561 12.762051,11.603299 Z\"/></svg>')}h2{margin-block-start:0;margin-block-end:0;margin-inline-start:0px;margin-inline-end:0px}.overlay{position:fixed;display:flex;top:0px;z-index:var(--dialog-z-index);left:0px;width:100%;box-sizing:border-box;height:100vh;background-color:rgba(var(--rgb-background--overlay), var(--opacity--soft));backdrop-filter:blur(var(--background-blur--medium))}.dialog{display:flex;width:80%;position:absolute;top:50%;left:50%;margin-right:-50%;box-sizing:border-box;transform:translate(-50%, -50%);box-shadow:0px 0px 16px rgba(0, 38, 111, 0.122)}@media screen and (min-width: 768px){.dialog{width:50%}}@media screen and (min-width: 992px){.dialog{width:33.33333%}}.dialog__container{width:100%;background:#FFFF;border-radius:0px 6px 6px 0px;box-sizing:border-box;padding:var(--dialog__container-padding)}.dialog__container--default{border-radius:6px 6px 6px 6px}.dialog__critical--indicator{box-sizing:border-box;width:12px;border-radius:6px 0px 0px 6px;background-color:var(--dialog__critical--background-color)}.dialog__warning--indicator{width:12px;border-radius:6px 0px 0px 6px;box-sizing:border-box;background-color:var(--dialog__warning--background-color)}.dialog__success--indicator{width:12px;border-radius:6px 0px 0px 6px;box-sizing:border-box;background-color:var(--dialog__success--background-color)}.message{font-size:var(--dialog__body--font-size);font-weight:var(--dialog__body--text-weight--medium);font-family:var(--dialog__body--font-pattern);text-shadow:var(--dialog__body--text-shadow);padding-bottom:var(--dialog__body--padding-bottom);color:var(--dialog__body--color);max-height:30vh;content-visibility:auto;margin-bottom:24px;overflow-y:auto}.changeable__icon{background:var(--dialog__warning--background-color);--ez-icon--color:var(--dialog__icon--color);display:grid;place-items:center;width:26px;height:26px;border-radius:50%}.changeable__icon.critical{background:var(--dialog__critical--background-color)}.title{display:flex;font-family:var(--dialog__title--font-pattern);margin:0;font-weight:var(--dialog__title--weight--large);line-height:0;color:var(--title--primary)}.title__container{display:flex;padding-bottom:var(--dialog__title__container--padding-bottom)}.title__box{display:flex;width:100%;align-items:center;align-self:center}.title__label{padding-left:var(--dialog__title--padding-left)}.title__label--no-icon{padding-left:0}.title-icon--critical{background-color:var(--dialog__critical--background-color)}.title-icon--success{background-color:var(--dialog__success--background-color)}.title-icon--warn{background-color:var(--dialog__warning--background-color)}.btn-close{justify-content:flex-end;align-self:flex-start;align-items:flex-start;display:flex;outline:none;width:10%;border:none;background-color:unset;cursor:pointer}.btn-close::after{content:'';display:flex;background-color:var(--dialog__btn__close--background-color);width:12px;height:12px;-webkit-mask-image:var(--dialog__btn__close__image);mask-image:var(--dialog__btn__close__image)}.title-icon::after{content:'';display:flex;background-color:#FFFF;width:15px;height:15px;-webkit-mask-image:var(--dialog--warning__image);mask-image:var(--dialog--warning__image)}.button-yes-no__container{display:flex;box-sizing:border-box;align-self:center;align-items:center;justify-content:flex-end}.button__cancel{padding-right:var(--dialog__btn__no--padding-right)}.button__confirm{--ez-button--background-color:var(--color--primary);--ez-button--color:var(--color--inverted);--ez-button--hover--background-color:var(--color--primary-600);--ez-button--hover-color:var(--color--inverted)}.button__confirm--danger{--ez-button--background-color:var(--color--alert-error-800, #BD0025);--ez-button--color:var(--color--inverted);--ez-button--hover--background-color:var(--color-alert--error-900, #a10020);--ez-button--hover-color:var(--color--inverted)}.button__confirm--container{display:flex;justify-content:flex-end}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}";
|
|
10
11
|
|
|
@@ -174,6 +175,7 @@ const EzDialog = class {
|
|
|
174
175
|
const dialog = this._element.shadowRoot.querySelector('.overlay .dialog');
|
|
175
176
|
if (dialog instanceof HTMLDivElement) {
|
|
176
177
|
dialog.style.outline = 'none';
|
|
178
|
+
this._lastActiveElement = document.activeElement;
|
|
177
179
|
dialog.focus();
|
|
178
180
|
}
|
|
179
181
|
}
|
|
@@ -186,7 +188,13 @@ const EzDialog = class {
|
|
|
186
188
|
focusOnPrimaryButton() {
|
|
187
189
|
const btnConfirm = this._element.shadowRoot.querySelector(`#${this.PRIMARY_BUTTON_ID}`);
|
|
188
190
|
const buttonElement = btnConfirm === null || btnConfirm === void 0 ? void 0 : btnConfirm.shadowRoot.querySelector('button');
|
|
189
|
-
|
|
191
|
+
requestAnimationFrame(() => {
|
|
192
|
+
buttonElement === null || buttonElement === void 0 ? void 0 : buttonElement.focus();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
disconnectedCallback() {
|
|
196
|
+
FocusResolver.FocusResolver.resolveFocus(this._lastActiveElement);
|
|
197
|
+
this._lastActiveElement = undefined;
|
|
190
198
|
}
|
|
191
199
|
render() {
|
|
192
200
|
if (this.opened && this._currentMessage) {
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-a7b0c73d.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
-
const
|
|
7
|
+
const DataBinder = require('./DataBinder-aff1dcc7.js');
|
|
8
8
|
require('./ApplicationUtils-c9d1205c.js');
|
|
9
9
|
require('./DialogType-2114c337.js');
|
|
10
10
|
|
|
@@ -109,7 +109,7 @@ const buildFormMetadata = (config, dataUnit, includeDetails = false) => {
|
|
|
109
109
|
if (!sheets.has(tabConfig)) {
|
|
110
110
|
sheets.set(tabConfig, []);
|
|
111
111
|
}
|
|
112
|
-
const formField =
|
|
112
|
+
const formField = DataBinder.buildFieldMetadata(descriptor, field);
|
|
113
113
|
sheets.get(tabConfig).push(formField);
|
|
114
114
|
if (formField.required) {
|
|
115
115
|
requiredFields.push(field.name);
|
|
@@ -183,327 +183,6 @@ const buildDetailSheet = (child) => {
|
|
|
183
183
|
};
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
-
class DataBinder {
|
|
187
|
-
constructor(dataUnit) {
|
|
188
|
-
this.onDataUnitEvent = (action) => {
|
|
189
|
-
var _a, _b;
|
|
190
|
-
switch (action.type) {
|
|
191
|
-
case core.Action.DATA_LOADED:
|
|
192
|
-
case core.Action.DATA_SAVED:
|
|
193
|
-
case core.Action.RECORDS_REMOVED:
|
|
194
|
-
case core.Action.RECORDS_ADDED:
|
|
195
|
-
case core.Action.RECORDS_COPIED:
|
|
196
|
-
case core.Action.EDITION_CANCELED:
|
|
197
|
-
case core.Action.SELECTION_CHANGED:
|
|
198
|
-
case core.Action.NEXT_SELECTED:
|
|
199
|
-
case core.Action.PREVIOUS_SELECTED:
|
|
200
|
-
this.clearInvalid();
|
|
201
|
-
case core.Action.DATA_CHANGED:
|
|
202
|
-
case core.Action.CHANGE_UNDONE:
|
|
203
|
-
case core.Action.CHANGE_REDONE:
|
|
204
|
-
case core.Action.RECORD_LOADED:
|
|
205
|
-
(_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
206
|
-
this.updateValue(field.fieldName, field.field);
|
|
207
|
-
});
|
|
208
|
-
break;
|
|
209
|
-
case core.Action.FIELD_INVALIDATED:
|
|
210
|
-
(_b = this._fields) === null || _b === void 0 ? void 0 : _b.forEach(field => {
|
|
211
|
-
this.updateErrorMessage(field.fieldName, field.field);
|
|
212
|
-
});
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
this._uuid = core.StringUtils.generateUUID();
|
|
217
|
-
this._fields = new Map();
|
|
218
|
-
this._dataUnit = dataUnit;
|
|
219
|
-
this.applyDefaultValues();
|
|
220
|
-
this._dataUnit.subscribe(this.onDataUnitEvent);
|
|
221
|
-
this._dataUnit.addInterceptor(this);
|
|
222
|
-
this.setContextDataBinder(dataUnit);
|
|
223
|
-
}
|
|
224
|
-
get dataBinderId() {
|
|
225
|
-
return this._uuid;
|
|
226
|
-
}
|
|
227
|
-
setContextDataBinder(dataUnit) {
|
|
228
|
-
const dataBindersByDataUnit = core.ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
|
|
229
|
-
const dataBinders = [...(dataBindersByDataUnit.get(dataUnit.dataUnitId) || []), this];
|
|
230
|
-
dataBindersByDataUnit.set(dataUnit.dataUnitId, dataBinders);
|
|
231
|
-
core.ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
|
|
232
|
-
}
|
|
233
|
-
applyDefaultValues() {
|
|
234
|
-
const recordIds = (this._dataUnit.getAddedRecords() || []).map(r => r.__record__id__);
|
|
235
|
-
if (recordIds.length > 0) {
|
|
236
|
-
const defaultValues = this.getDefaultValues();
|
|
237
|
-
if (defaultValues) {
|
|
238
|
-
Object.keys(defaultValues).forEach(field => {
|
|
239
|
-
this._dataUnit.setFieldValue(field, defaultValues[field], recordIds);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
bind(fields, currentContextName, formMetadata, recordsValidator) {
|
|
245
|
-
fields.forEach(fieldElement => {
|
|
246
|
-
const { fieldName, contextName } = fieldElement.dataset;
|
|
247
|
-
if (contextName == undefined || contextName === currentContextName) {
|
|
248
|
-
this.updateBind(fieldName, fieldElement);
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
this._formMetadata = formMetadata;
|
|
252
|
-
this._recordValidatorProcessor = new RecordValidationProcessor.RecordValidationProcessor(this._dataUnit, {
|
|
253
|
-
getRequiredFields: () => this._formMetadata.getRequiredFields(),
|
|
254
|
-
markAsInvalid: field => this.markInvalid(field),
|
|
255
|
-
getMessageForField: field => this.getErrorMessage(field),
|
|
256
|
-
}, recordsValidator);
|
|
257
|
-
}
|
|
258
|
-
disconnectDataUnit() {
|
|
259
|
-
const dataBindersByDataUnit = core.ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
|
|
260
|
-
const dataBinders = dataBindersByDataUnit.get(this._dataUnit.dataUnitId);
|
|
261
|
-
const dataBindersFiltered = dataBinders.filter((dataBinder) => dataBinder.dataBinderId !== this.dataBinderId);
|
|
262
|
-
dataBindersByDataUnit.set(this._dataUnit.dataUnitId, dataBindersFiltered);
|
|
263
|
-
core.ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
|
|
264
|
-
}
|
|
265
|
-
onDisconnectedCallback() {
|
|
266
|
-
this._dataUnit.unsubscribe(this.onDataUnitEvent);
|
|
267
|
-
this._dataUnit.removeInterceptor(this);
|
|
268
|
-
this.disconnectDataUnit();
|
|
269
|
-
}
|
|
270
|
-
getCurrentRecordId() {
|
|
271
|
-
const record = this._dataUnit.getSelectedRecord();
|
|
272
|
-
return record === null || record === void 0 ? void 0 : record.__record__id__;
|
|
273
|
-
}
|
|
274
|
-
markInvalid(field) {
|
|
275
|
-
if (this._fields.has(field.name)) {
|
|
276
|
-
const fieldElement = this._fields.get(field.name).field;
|
|
277
|
-
this.updateErrorMessage(field.name, fieldElement, field.message);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
setFocus(fieldName) {
|
|
281
|
-
if (!this._fields.has(fieldName)) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
const fieldElement = this._fields.get(fieldName).field;
|
|
285
|
-
if (typeof fieldElement["setFocus"] != "function") {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
fieldElement["setFocus"]();
|
|
289
|
-
}
|
|
290
|
-
clearInvalid(recordId) {
|
|
291
|
-
this._dataUnit.clearInvalid(recordId);
|
|
292
|
-
this._fields.forEach(fieldBinder => {
|
|
293
|
-
const fieldElement = fieldBinder.field;
|
|
294
|
-
fieldElement["errorMessage"] = "";
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
updateValue(fieldName, field) {
|
|
298
|
-
const bind = this._fields.get(fieldName);
|
|
299
|
-
try {
|
|
300
|
-
if (bind) {
|
|
301
|
-
bind.listen = false;
|
|
302
|
-
}
|
|
303
|
-
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
304
|
-
this.updateErrorMessage(fieldName, field);
|
|
305
|
-
}
|
|
306
|
-
finally {
|
|
307
|
-
if (bind) {
|
|
308
|
-
bind.listen = true;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
validate() {
|
|
313
|
-
return this._recordValidatorProcessor.validate();
|
|
314
|
-
}
|
|
315
|
-
static async validateByDataunit(dataUnit) {
|
|
316
|
-
try {
|
|
317
|
-
const dataBindersByDataUnit = core.ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__");
|
|
318
|
-
const dataBinders = dataBindersByDataUnit.get(dataUnit.dataUnitId) || [];
|
|
319
|
-
await Promise.all(dataBinders.map((dataBinder) => dataBinder.validate()));
|
|
320
|
-
return true;
|
|
321
|
-
}
|
|
322
|
-
catch (_a) {
|
|
323
|
-
return false;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
updateErrorMessage(fieldName, field, message) {
|
|
327
|
-
if (message == undefined) {
|
|
328
|
-
message = this._dataUnit.getInvalidMessage(this.getCurrentRecordId(), fieldName);
|
|
329
|
-
}
|
|
330
|
-
if (!field["errorMessage"]) {
|
|
331
|
-
field["errorMessage"] = message;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
getErrorMessage(fieldName) {
|
|
335
|
-
if (this._fields.has(fieldName)) {
|
|
336
|
-
const fieldElement = this._fields.get(fieldName).field;
|
|
337
|
-
return fieldElement["errorMessage"];
|
|
338
|
-
}
|
|
339
|
-
return undefined;
|
|
340
|
-
}
|
|
341
|
-
updateBind(fieldName, field) {
|
|
342
|
-
const oldBind = this._fields.get(fieldName);
|
|
343
|
-
if (oldBind) {
|
|
344
|
-
oldBind.destroy();
|
|
345
|
-
}
|
|
346
|
-
this.bindSearchOptionsLoader(fieldName, field);
|
|
347
|
-
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
348
|
-
this.updateErrorMessage(fieldName, field);
|
|
349
|
-
this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName) => this.cancelWaitingChange(fieldName), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
|
|
350
|
-
this.applyEzUploadContext(fieldName, field);
|
|
351
|
-
}
|
|
352
|
-
changeStarted(fieldName, waitingChange) {
|
|
353
|
-
/**
|
|
354
|
-
* se o waitingChange não é blocante, add um event listener pra
|
|
355
|
-
* fazer o accept da promise
|
|
356
|
-
*
|
|
357
|
-
* se não tiver promise no waitingChange, eu crio uma e resolvo no bind
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*/
|
|
361
|
-
if (this._dataUnit.records.length === 0) {
|
|
362
|
-
this._dataUnit.addRecord();
|
|
363
|
-
}
|
|
364
|
-
if (!waitingChange.blocking && waitingChange.promise == undefined) {
|
|
365
|
-
const bind = this._fields.get(fieldName);
|
|
366
|
-
if (bind) {
|
|
367
|
-
waitingChange.promise = new Promise((resolve, reject) => {
|
|
368
|
-
bind.waitingChangePromiseResolve = resolve;
|
|
369
|
-
bind.waitingChangePromiseReject = reject;
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
this._dataUnit.startChange(fieldName, waitingChange);
|
|
374
|
-
}
|
|
375
|
-
cancelWaitingChange(fieldName) {
|
|
376
|
-
if (this._dataUnit.waitingForChange(fieldName)) {
|
|
377
|
-
this._dataUnit.cancelWaitingChange(fieldName);
|
|
378
|
-
const bind = this._fields.get(fieldName);
|
|
379
|
-
if (bind) {
|
|
380
|
-
bind.rejectWaitingChange(new core.WaitingChangeException("Change canceled", fieldName));
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
setFieldValue(fieldName, newValue) {
|
|
385
|
-
if (this._dataUnit.records.length === 0) {
|
|
386
|
-
this._dataUnit.addRecord();
|
|
387
|
-
}
|
|
388
|
-
this._dataUnit.clearInvalid(this.getCurrentRecordId(), fieldName);
|
|
389
|
-
const record = this._dataUnit.getSelectedRecord();
|
|
390
|
-
this._dataUnit.setFieldValue(fieldName, newValue, record ? [record.__record__id__] : undefined);
|
|
391
|
-
if (this._dataUnit.waitingForChange(fieldName)) {
|
|
392
|
-
const bind = this._fields.get(fieldName);
|
|
393
|
-
if (bind) {
|
|
394
|
-
bind.acceptWaitingChange();
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
bindSearchOptionsLoader(fieldName, field) {
|
|
399
|
-
if (field.nodeName === "EZ-SEARCH" && field["optionLoader"] == undefined) {
|
|
400
|
-
const loader = core.ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
|
|
401
|
-
if (loader) {
|
|
402
|
-
field["optionLoader"] = (arg) => {
|
|
403
|
-
return loader(arg, fieldName, this._dataUnit);
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
applyEzUploadContext(fieldName, field) {
|
|
409
|
-
var _a, _b;
|
|
410
|
-
if (field.nodeName === "EZ-UPLOAD") {
|
|
411
|
-
field["urlUpload"] = core.ApplicationContext.getContextValue("__EZUI__UPLOAD__ADD__URL__");
|
|
412
|
-
field["urlDelete"] = core.ApplicationContext.getContextValue("__EZUI__UPLOAD__DEL__URL__");
|
|
413
|
-
const descriptor = this._dataUnit.getField(fieldName);
|
|
414
|
-
const destination = (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.DESTINATION;
|
|
415
|
-
if (destination) {
|
|
416
|
-
field["requestHeaders"] = { XTRAINF: `{"destination": "${destination}"}` };
|
|
417
|
-
}
|
|
418
|
-
field["maxFiles"] = ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.MAX_FILES) || 0;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
interceptAction(action) {
|
|
422
|
-
if (action.type === core.Action.RECORDS_COPIED) {
|
|
423
|
-
const cleanFields = this._formMetadata.getCleanOnCopyFields();
|
|
424
|
-
if (cleanFields) {
|
|
425
|
-
const records = action.payload;
|
|
426
|
-
return new core.DataUnitAction(core.Action.RECORDS_COPIED, records.map(record => {
|
|
427
|
-
const newRecord = Object.assign({}, record);
|
|
428
|
-
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
429
|
-
return newRecord;
|
|
430
|
-
}));
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
if (action.type === core.Action.SAVING_DATA) {
|
|
434
|
-
return new Promise((resolve) => {
|
|
435
|
-
this.validate()
|
|
436
|
-
.then(() => resolve(action))
|
|
437
|
-
.catch(() => { });
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
if (action.type === core.Action.RECORDS_ADDED) {
|
|
441
|
-
const defaultValues = this.getDefaultValues();
|
|
442
|
-
if (defaultValues) {
|
|
443
|
-
const records = action.payload;
|
|
444
|
-
return new core.DataUnitAction(core.Action.RECORDS_ADDED, records.map(record => {
|
|
445
|
-
return Object.assign(Object.assign({}, record), defaultValues);
|
|
446
|
-
}));
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
return action;
|
|
450
|
-
}
|
|
451
|
-
getDefaultValues() {
|
|
452
|
-
var _a;
|
|
453
|
-
const rawDefaultValues = (_a = this._formMetadata) === null || _a === void 0 ? void 0 : _a.getDefaultValues();
|
|
454
|
-
if (rawDefaultValues) {
|
|
455
|
-
const defaultValues = {};
|
|
456
|
-
for (const field in rawDefaultValues) {
|
|
457
|
-
defaultValues[field] = this._dataUnit.valueFromString(field, rawDefaultValues[field]);
|
|
458
|
-
}
|
|
459
|
-
return defaultValues;
|
|
460
|
-
}
|
|
461
|
-
return undefined;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
class Bind {
|
|
465
|
-
constructor() {
|
|
466
|
-
this.listen = true;
|
|
467
|
-
this.startChangeEventName = "ezStartChange";
|
|
468
|
-
this.cancelWaitingChangeEventName = "ezCancelWaitingChange";
|
|
469
|
-
this.changeEventName = "ezChange";
|
|
470
|
-
}
|
|
471
|
-
destroy() {
|
|
472
|
-
this.field.removeEventListener(this.startChangeEventName, this.startChangeListener);
|
|
473
|
-
this.field.removeEventListener(this.cancelWaitingChangeEventName, this.cancelWaitingChangeListener);
|
|
474
|
-
this.field.removeEventListener(this.changeEventName, this.changeListener);
|
|
475
|
-
}
|
|
476
|
-
acceptWaitingChange() {
|
|
477
|
-
if (this.waitingChangePromiseResolve) {
|
|
478
|
-
this.waitingChangePromiseResolve();
|
|
479
|
-
this.waitingChangePromiseReject = undefined;
|
|
480
|
-
this.waitingChangePromiseResolve = undefined;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
rejectWaitingChange(reason) {
|
|
484
|
-
if (this.waitingChangePromiseReject) {
|
|
485
|
-
this.waitingChangePromiseReject(reason);
|
|
486
|
-
this.waitingChangePromiseReject = undefined;
|
|
487
|
-
this.waitingChangePromiseResolve = undefined;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
static create(fieldName, field, startChangeCallback, cancelWaitingChangeCallback, changeCallback) {
|
|
491
|
-
const b = new Bind();
|
|
492
|
-
b.field = field;
|
|
493
|
-
b.fieldName = fieldName;
|
|
494
|
-
b.startChangeListener = (evt) => { if (b.listen)
|
|
495
|
-
startChangeCallback(fieldName, evt.detail); };
|
|
496
|
-
b.field.addEventListener(b.startChangeEventName, b.startChangeListener);
|
|
497
|
-
b.cancelWaitingChangeListener = () => { if (b.listen)
|
|
498
|
-
cancelWaitingChangeCallback(fieldName); };
|
|
499
|
-
b.field.addEventListener(b.cancelWaitingChangeEventName, b.cancelWaitingChangeListener);
|
|
500
|
-
b.changeListener = (evt) => { if (b.listen)
|
|
501
|
-
changeCallback(fieldName, evt.detail); };
|
|
502
|
-
b.field.addEventListener(b.changeEventName, b.changeListener);
|
|
503
|
-
return b;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
186
|
/**
|
|
508
187
|
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
|
509
188
|
*
|
|
@@ -968,7 +647,7 @@ const EzForm = class {
|
|
|
968
647
|
this.dataUnit = new core.DataUnit("ez-form");
|
|
969
648
|
}
|
|
970
649
|
this.dataUnit.subscribe(this.onDataUnitAction);
|
|
971
|
-
this._dataBinder = new DataBinder(this.dataUnit);
|
|
650
|
+
this._dataBinder = new DataBinder.DataBinder(this.dataUnit);
|
|
972
651
|
this._store = createStore(formReducer);
|
|
973
652
|
this._store.subscribe(() => index.forceUpdate(this));
|
|
974
653
|
this._staticFields = Array.from(this._element.querySelectorAll("[data-field-name]"));
|