@sankhyalabs/ezui 5.11.0-dev.4 → 5.11.0-dev.5

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.
@@ -99,15 +99,49 @@ uiBuilders.set(core.UserInterface.LONGTEXT, buildTextArea);
99
99
  const fieldBuilder = (field) => {
100
100
  const builder = uiBuilders.get(field.userInterface) || buildTextInput;
101
101
  const label = field.required ? `${field.label}${constants.REQUIRED_INFO}` : field.label;
102
- return builder(Object.assign(Object.assign({}, field), { label }));
102
+ const builtElement = builder(Object.assign(Object.assign({}, field), { label }));
103
+ //@ts-ignore
104
+ builtElement.$attrs$['data-form-item'] = field.name;
105
+ return builtElement;
103
106
  };
104
107
 
108
+ class FormItem {
109
+ constructor(elem) {
110
+ this.elem = elem;
111
+ }
112
+ addRightElement(el) {
113
+ el.classList.add('ez-padding-left--small');
114
+ this.elem.classList.add('ez-col--nowrap');
115
+ this.elem.appendChild(el);
116
+ }
117
+ get fieldName() {
118
+ return this.elem.getAttribute('data-form-item');
119
+ }
120
+ }
121
+ class FormItems {
122
+ constructor(items, formId) {
123
+ this.items = new Map();
124
+ this.formId = formId;
125
+ items.forEach(item => {
126
+ const formItem = new FormItem(item);
127
+ this.items.set(formItem.fieldName, formItem);
128
+ });
129
+ }
130
+ getItem(name) {
131
+ return this.items.get(name);
132
+ }
133
+ get formName() {
134
+ return this.formId;
135
+ }
136
+ }
137
+
105
138
  const ezFormViewCss = ".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";
106
139
 
107
140
  const EzFormView = class {
108
141
  constructor(hostRef) {
109
142
  index.registerInstance(this, hostRef);
110
143
  this.ezContentReady = index.createEvent(this, "ezContentReady", 7);
144
+ this.formItemsReady = index.createEvent(this, "formItemsReady", 7);
111
145
  this.fields = undefined;
112
146
  }
113
147
  async showUp() {
@@ -133,6 +167,8 @@ const EzFormView = class {
133
167
  }
134
168
  componentDidRender() {
135
169
  this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));
170
+ const formItems = new FormItems(Array.from(this._element.querySelectorAll("[data-form-item]")));
171
+ this.formItemsReady.emit(formItems);
136
172
  }
137
173
  render() {
138
174
  core.ElementIDUtils.addIDInfoIfNotExists(this._element, 'ezFormView');
@@ -835,6 +835,7 @@ const EzForm = class {
835
835
  constructor(hostRef) {
836
836
  index.registerInstance(this, hostRef);
837
837
  this.ezReady = index.createEvent(this, "ezReady", 7);
838
+ this.formItemsReady = index.createEvent(this, "formItemsReady", 7);
838
839
  this.onDataUnitAction = (action) => {
839
840
  if (action.type === core.Action.METADATA_LOADED) {
840
841
  this.processMetadata();
@@ -185,6 +185,26 @@ export class EzForm {
185
185
  "resolved": "void",
186
186
  "references": {}
187
187
  }
188
+ }, {
189
+ "method": "formItemsReady",
190
+ "name": "formItemsReady",
191
+ "bubbles": true,
192
+ "cancelable": true,
193
+ "composed": true,
194
+ "docs": {
195
+ "tags": [],
196
+ "text": "Respons\u00E1vel por notificar quando ocorrer a renderiza\u00E7\u00E3o de itens do formul\u00E1rio."
197
+ },
198
+ "complexType": {
199
+ "original": "FormItems",
200
+ "resolved": "FormItems",
201
+ "references": {
202
+ "FormItems": {
203
+ "location": "import",
204
+ "path": "../ez-form-view/structure"
205
+ }
206
+ }
207
+ }
188
208
  }];
189
209
  }
190
210
  static get methods() {
@@ -1,6 +1,7 @@
1
1
  import { Host, h } from '@stencil/core';
2
2
  import { fieldBuilder } from './fieldbuilder/FieldBuilder';
3
3
  import { ElementIDUtils } from '@sankhyalabs/core';
4
+ import { FormItems } from './structure';
4
5
  export class EzFormView {
5
6
  constructor() {
6
7
  this.fields = undefined;
@@ -28,6 +29,8 @@ export class EzFormView {
28
29
  }
29
30
  componentDidRender() {
30
31
  this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));
32
+ const formItems = new FormItems(Array.from(this._element.querySelectorAll("[data-form-item]")));
33
+ this.formItemsReady.emit(formItems);
31
34
  }
32
35
  render() {
33
36
  ElementIDUtils.addIDInfoIfNotExists(this._element, 'ezFormView');
@@ -105,6 +108,26 @@ export class EzFormView {
105
108
  }
106
109
  }
107
110
  }
111
+ }, {
112
+ "method": "formItemsReady",
113
+ "name": "formItemsReady",
114
+ "bubbles": true,
115
+ "cancelable": true,
116
+ "composed": true,
117
+ "docs": {
118
+ "tags": [],
119
+ "text": "Respons\u00E1vel por notificar quando ocorrer a renderiza\u00E7\u00E3o de itens do formul\u00E1rio."
120
+ },
121
+ "complexType": {
122
+ "original": "FormItems",
123
+ "resolved": "FormItems",
124
+ "references": {
125
+ "FormItems": {
126
+ "location": "import",
127
+ "path": "./structure"
128
+ }
129
+ }
130
+ }
108
131
  }];
109
132
  }
110
133
  static get methods() {
@@ -23,5 +23,8 @@ uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
23
23
  export const fieldBuilder = (field) => {
24
24
  const builder = uiBuilders.get(field.userInterface) || buildTextInput;
25
25
  const label = field.required ? `${field.label}${REQUIRED_INFO}` : field.label;
26
- return builder(Object.assign(Object.assign({}, field), { label }));
26
+ const builtElement = builder(Object.assign(Object.assign({}, field), { label }));
27
+ //@ts-ignore
28
+ builtElement.$attrs$['data-form-item'] = field.name;
29
+ return builtElement;
27
30
  };
@@ -0,0 +1,29 @@
1
+ class FormItem {
2
+ constructor(elem) {
3
+ this.elem = elem;
4
+ }
5
+ addRightElement(el) {
6
+ el.classList.add('ez-padding-left--small');
7
+ this.elem.classList.add('ez-col--nowrap');
8
+ this.elem.appendChild(el);
9
+ }
10
+ get fieldName() {
11
+ return this.elem.getAttribute('data-form-item');
12
+ }
13
+ }
14
+ export class FormItems {
15
+ constructor(items, formId) {
16
+ this.items = new Map();
17
+ this.formId = formId;
18
+ items.forEach(item => {
19
+ const formItem = new FormItem(item);
20
+ this.items.set(formItem.fieldName, formItem);
21
+ });
22
+ }
23
+ getItem(name) {
24
+ return this.items.get(name);
25
+ }
26
+ get formName() {
27
+ return this.formId;
28
+ }
29
+ }
@@ -4449,6 +4449,7 @@ const EzForm$1 = class extends HTMLElement$1 {
4449
4449
  super();
4450
4450
  this.__registerHost();
4451
4451
  this.ezReady = createEvent(this, "ezReady", 7);
4452
+ this.formItemsReady = createEvent(this, "formItemsReady", 7);
4452
4453
  this.onDataUnitAction = (action) => {
4453
4454
  if (action.type === Action.METADATA_LOADED) {
4454
4455
  this.processMetadata();
@@ -4635,9 +4636,42 @@ uiBuilders$1.set(UserInterface.LONGTEXT, buildTextArea);
4635
4636
  const fieldBuilder = (field) => {
4636
4637
  const builder = uiBuilders$1.get(field.userInterface) || buildTextInput$1;
4637
4638
  const label = field.required ? `${field.label}${REQUIRED_INFO}` : field.label;
4638
- return builder(Object.assign(Object.assign({}, field), { label }));
4639
+ const builtElement = builder(Object.assign(Object.assign({}, field), { label }));
4640
+ //@ts-ignore
4641
+ builtElement.$attrs$['data-form-item'] = field.name;
4642
+ return builtElement;
4639
4643
  };
4640
4644
 
4645
+ class FormItem {
4646
+ constructor(elem) {
4647
+ this.elem = elem;
4648
+ }
4649
+ addRightElement(el) {
4650
+ el.classList.add('ez-padding-left--small');
4651
+ this.elem.classList.add('ez-col--nowrap');
4652
+ this.elem.appendChild(el);
4653
+ }
4654
+ get fieldName() {
4655
+ return this.elem.getAttribute('data-form-item');
4656
+ }
4657
+ }
4658
+ class FormItems {
4659
+ constructor(items, formId) {
4660
+ this.items = new Map();
4661
+ this.formId = formId;
4662
+ items.forEach(item => {
4663
+ const formItem = new FormItem(item);
4664
+ this.items.set(formItem.fieldName, formItem);
4665
+ });
4666
+ }
4667
+ getItem(name) {
4668
+ return this.items.get(name);
4669
+ }
4670
+ get formName() {
4671
+ return this.formId;
4672
+ }
4673
+ }
4674
+
4641
4675
  const ezFormViewCss = ".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";
4642
4676
 
4643
4677
  const EzFormView$1 = class extends HTMLElement$1 {
@@ -4645,6 +4679,7 @@ const EzFormView$1 = class extends HTMLElement$1 {
4645
4679
  super();
4646
4680
  this.__registerHost();
4647
4681
  this.ezContentReady = createEvent(this, "ezContentReady", 7);
4682
+ this.formItemsReady = createEvent(this, "formItemsReady", 7);
4648
4683
  this.fields = undefined;
4649
4684
  }
4650
4685
  async showUp() {
@@ -4670,6 +4705,8 @@ const EzFormView$1 = class extends HTMLElement$1 {
4670
4705
  }
4671
4706
  componentDidRender() {
4672
4707
  this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));
4708
+ const formItems = new FormItems(Array.from(this._element.querySelectorAll("[data-form-item]")));
4709
+ this.formItemsReady.emit(formItems);
4673
4710
  }
4674
4711
  render() {
4675
4712
  ElementIDUtils.addIDInfoIfNotExists(this._element, 'ezFormView');
@@ -95,15 +95,49 @@ uiBuilders.set(UserInterface.LONGTEXT, buildTextArea);
95
95
  const fieldBuilder = (field) => {
96
96
  const builder = uiBuilders.get(field.userInterface) || buildTextInput;
97
97
  const label = field.required ? `${field.label}${REQUIRED_INFO}` : field.label;
98
- return builder(Object.assign(Object.assign({}, field), { label }));
98
+ const builtElement = builder(Object.assign(Object.assign({}, field), { label }));
99
+ //@ts-ignore
100
+ builtElement.$attrs$['data-form-item'] = field.name;
101
+ return builtElement;
99
102
  };
100
103
 
104
+ class FormItem {
105
+ constructor(elem) {
106
+ this.elem = elem;
107
+ }
108
+ addRightElement(el) {
109
+ el.classList.add('ez-padding-left--small');
110
+ this.elem.classList.add('ez-col--nowrap');
111
+ this.elem.appendChild(el);
112
+ }
113
+ get fieldName() {
114
+ return this.elem.getAttribute('data-form-item');
115
+ }
116
+ }
117
+ class FormItems {
118
+ constructor(items, formId) {
119
+ this.items = new Map();
120
+ this.formId = formId;
121
+ items.forEach(item => {
122
+ const formItem = new FormItem(item);
123
+ this.items.set(formItem.fieldName, formItem);
124
+ });
125
+ }
126
+ getItem(name) {
127
+ return this.items.get(name);
128
+ }
129
+ get formName() {
130
+ return this.formId;
131
+ }
132
+ }
133
+
101
134
  const ezFormViewCss = ".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";
102
135
 
103
136
  const EzFormView = class {
104
137
  constructor(hostRef) {
105
138
  registerInstance(this, hostRef);
106
139
  this.ezContentReady = createEvent(this, "ezContentReady", 7);
140
+ this.formItemsReady = createEvent(this, "formItemsReady", 7);
107
141
  this.fields = undefined;
108
142
  }
109
143
  async showUp() {
@@ -129,6 +163,8 @@ const EzFormView = class {
129
163
  }
130
164
  componentDidRender() {
131
165
  this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));
166
+ const formItems = new FormItems(Array.from(this._element.querySelectorAll("[data-form-item]")));
167
+ this.formItemsReady.emit(formItems);
132
168
  }
133
169
  render() {
134
170
  ElementIDUtils.addIDInfoIfNotExists(this._element, 'ezFormView');
@@ -831,6 +831,7 @@ const EzForm = class {
831
831
  constructor(hostRef) {
832
832
  registerInstance(this, hostRef);
833
833
  this.ezReady = createEvent(this, "ezReady", 7);
834
+ this.formItemsReady = createEvent(this, "formItemsReady", 7);
834
835
  this.onDataUnitAction = (action) => {
835
836
  if (action.type === Action.METADATA_LOADED) {
836
837
  this.processMetadata();
@@ -1 +1 @@
1
- import{p as e,b as o}from"./p-e318d280.js";export{s as setNonce}from"./p-e318d280.js";(()=>{const o=import.meta.url,t={};return""!==o&&(t.resourcesUrl=new URL(".",o).href),e(t)})().then((e=>o(JSON.parse('[["p-fd54b5b4",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"config":[1040],"selectionToastConfig":[16],"serverUrl":[1,"server-url"],"dataUnit":[16],"statusResolver":[16],"columnfilterDataSource":[16],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"_paginationInfo":[32],"_paginationChangedByKeyboard":[32],"_showSelectionCounter":[32],"_isAllSelection":[32],"_currentPageSelected":[32],"_selectionCount":[32],"_originalRecords":[32],"setColumnsDef":[64],"addColumnMenuItem":[64],"setColumnsState":[64],"setData":[64],"getSelection":[64],"getColumnsState":[64],"getColumns":[64],"quickFilter":[64]},[[0,"ezSelectionChange","onSelectionChange"]]]]],["p-9285b53e",[[1,"ez-guide-navigator",{"open":[1540],"selectedId":[1537,"selected-id"],"items":[16],"tooltipResolver":[16],"filterText":[32],"disableItem":[64],"enableItem":[64],"updateItem":[64],"getItem":[64],"getCurrentPath":[64],"selectGuide":[64],"getParent":[64]}]]],["p-ff82b176",[[1,"ez-actions-button",{"enabled":[516],"actions":[1040],"size":[513],"showLabel":[516,"show-label"],"displayIcon":[513,"display-icon"],"checkOption":[516,"check-option"],"value":[513],"isTransparent":[516,"is-transparent"],"arrowActive":[516,"arrow-active"],"_selectedAction":[32],"hideActions":[64],"isOpened":[64]}]]],["p-cd19a6f8",[[1,"ez-breadcrumb",{"items":[1040],"fillMode":[1025,"fill-mode"],"maxItems":[1026,"max-items"],"positionEllipsis":[1026,"position-ellipsis"],"visibleItems":[32],"hiddenItems":[32],"showDropdown":[32],"collapseConfigPosition":[32]}]]],["p-db528b31",[[1,"ez-dialog",{"confirm":[1028],"dialogType":[1025,"dialog-type"],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"],"beforeClose":[1040],"show":[64]}]]],["p-a01068e1",[[6,"ez-modal-container",{"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"showTitleBar":[4,"show-title-bar"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"cancelButtonStatus":[1,"cancel-button-status"],"okButtonStatus":[1,"ok-button-status"]}]]],["p-60ba28ea",[[1,"ez-alert",{"alertType":[513,"alert-type"]}]]],["p-c49dbf23",[[1,"ez-badge",{"size":[513],"label":[513],"iconLeft":[513,"icon-left"],"iconRight":[513,"icon-right"],"position":[1040],"hasSlot":[32]}]]],["p-f4208819",[[1,"ez-chip",{"label":[513],"enabled":[516],"removePosition":[513,"remove-position"],"mode":[513],"value":[1540],"showNativeTooltip":[4,"show-native-tooltip"],"setFocus":[64],"setBlur":[64]}]]],["p-ccb4ccd9",[[1,"ez-file-item",{"canRemove":[4,"can-remove"],"fileName":[1,"file-name"],"iconName":[1,"icon-name"],"fileSize":[2,"file-size"],"progress":[2]}]]],["p-d51aa09b",[[0,"ez-application"]]],["p-68352e41",[[1,"ez-card-item",{"item":[16]}]]],["p-7525e604",[[1,"ez-loading-bar",{"_showLoading":[32],"hide":[64],"show":[64]}]]],["p-5ce6548c",[[1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"heightMode":[1,"height-mode"],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"],"scrim":[1]}]]],["p-e7fa0ad6",[[1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[516,"use-header"],"heightMode":[513,"height-mode"],"ezTitle":[1,"ez-title"]}]]],["p-b11f035c",[[1,"ez-radio-button",{"value":[1544],"options":[1040],"enabled":[516],"label":[513],"direction":[1537]}]]],["p-5d6f2550",[[0,"ez-skeleton",{"count":[2],"variant":[1],"width":[1],"height":[1],"marginBottom":[1,"margin-bottom"],"animation":[1]}]]],["p-fa571a4e",[[1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"],"show":[64]}]]],["p-9b347f04",[[0,"ez-view-stack",{"show":[64],"getSelectedIndex":[64]}]]],["p-4e31b69b",[[2,"ez-form-view",{"fields":[16],"showUp":[64]}]]],["p-87e85160",[[0,"multi-selection-box-message",{"message":[1]}],[1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"asyncSearch":[516,"async-search"],"canShowError":[516,"can-show-error"],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"setValue":[64],"endSearch":[64]}]]],["p-2a0e1679",[[2,"ez-multi-selection-list",{"columnName":[1,"column-name"],"dataSource":[16],"useOptions":[1028,"use-options"],"options":[16],"filteredOptions":[32],"displayOptions":[32],"viewScenario":[32],"displayOptionToCheckAllItems":[32],"clearFilteredOptions":[64]}]]],["p-4c8b029b",[[0,"filter-column",{"opened":[4],"columnName":[1,"column-name"],"columnLabel":[1,"column-label"],"gridHeaderHidden":[4,"grid-header-hidden"],"dataSource":[16],"dataUnit":[16],"options":[1040],"selectedItems":[32],"fieldDescriptor":[32],"useOptions":[32],"hide":[64],"show":[64]}]]],["p-a510a4c5",[[1,"ez-dropdown",{"items":[1040],"value":[1040],"itemBuilder":[16]}]]],["p-83885b21",[[1,"ez-tabselector",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32]}]]],["p-8bd3903b",[[1,"ez-collapsible-box",{"value":[1540],"boxBordered":[4,"box-bordered"],"label":[513],"subtitle":[513],"headerSize":[513,"header-size"],"iconPlacement":[513,"icon-placement"],"headerAlign":[513,"header-align"],"removable":[516],"editable":[516],"conditionalSave":[16],"_activeEditText":[32],"showHide":[64],"applyFocusTextEdit":[64],"cancelEdition":[64]}]]],["p-5cef0264",[[1,"ez-calendar",{"value":[1040],"floating":[516],"time":[516],"showSeconds":[516,"show-seconds"],"show":[64],"fitVertical":[64],"fitHorizontal":[64],"hide":[64]},[[11,"scroll","scrollListener"]]]]],["p-e67d0bd5",[[1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"noBorder":[516,"no-border"],"setFocus":[64],"setBlur":[64],"isInvalid":[64]}]]],["p-d43b22f3",[[1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"mode":[513],"canShowError":[516,"can-show-error"],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"getValueAsync":[64]}]]],["p-ce035beb",[[1,"ez-date-time-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"canShowError":[516,"can-show-error"],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"getValueAsync":[64]}]]],["p-028f264f",[[1,"ez-time-input",{"label":[513],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"canShowError":[516,"can-show-error"],"setFocus":[64],"setBlur":[64],"isInvalid":[64]}]]],["p-e2dfd935",[[1,"ez-number-input",{"label":[1],"value":[1538],"enabled":[4],"canShowError":[516,"can-show-error"],"errorMessage":[1537,"error-message"],"precision":[2],"prettyPrecision":[2,"pretty-precision"],"mode":[513],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"getValueAsync":[64]}]]],["p-2da09f70",[[1,"ez-popover",{"autoClose":[516,"auto-close"],"boxWidth":[513,"box-width"],"opened":[1540],"innerElement":[1537,"inner-element"],"overlayType":[513,"overlay-type"],"updatePosition":[64],"show":[64],"showUnder":[64],"hide":[64]}]]],["p-391de0e4",[[1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"errorMessage":[1537,"error-message"],"rows":[1538],"canShowError":[516,"can-show-error"],"mode":[513],"enableResize":[516,"enable-resize"],"appendTextToSelection":[64],"setFocus":[64],"setBlur":[64],"isInvalid":[64]}]]],["p-37673563",[[1,"ez-upload",{"label":[1],"subtitle":[1],"enabled":[4],"maxFileSize":[2,"max-file-size"],"maxFiles":[2,"max-files"],"requestHeaders":[8,"request-headers"],"urlUpload":[1,"url-upload"],"urlDelete":[1,"url-delete"],"value":[1040],"addFiles":[64],"setFocus":[64],"setBlur":[64]}]]],["p-a5e09759",[[1,"ez-text-edit",{"value":[1],"styled":[16],"_newValue":[32],"applyFocusSelect":[64]}]]],["p-050247dc",[[1,"ez-tree",{"items":[1040],"value":[1040],"selectedId":[1537,"selected-id"],"iconResolver":[16],"tooltipResolver":[16],"_tree":[32],"_waintingForLoad":[32],"selectItem":[64],"openItem":[64],"disableItem":[64],"enableItem":[64],"addChild":[64],"applyFilter":[64],"updateItem":[64],"getItem":[64],"getCurrentPath":[64],"getParent":[64]},[[2,"keydown","onKeyDownListener"]]],[1,"ez-scroller",{"direction":[1],"locked":[4],"activeShadow":[4,"active-shadow"],"isActive":[32]},[[2,"click","clickListener"],[1,"mousedown","mouseDownHandler"],[1,"mouseup","mouseUpHandler"],[1,"mousemove","mouseMoveHandler"]]],[1,"ez-sidebar-button"]]],["p-244dfe8a",[[1,"ez-list",{"dataSource":[1040],"listMode":[1,"list-mode"],"useGroups":[1540,"use-groups"],"ezDraggable":[1028,"ez-draggable"],"ezSelectable":[1028,"ez-selectable"],"itemSlotBuilder":[1040],"itemLeftSlotBuilder":[1040],"hoverFeedback":[1028,"hover-feedback"],"_listItems":[32],"_listGroupItems":[32],"clearHistory":[64],"scrollToTop":[64],"setSelection":[64],"getSelection":[64],"getList":[64],"removeSelection":[64]}]]],["p-411f3579",[[1,"ez-combo-box",{"value":[1537],"label":[513],"enabled":[516],"options":[1040],"errorMessage":[1537,"error-message"],"searchMode":[4,"search-mode"],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressSearch":[4,"suppress-search"],"optionLoader":[16],"suppressEmptyOption":[4,"suppress-empty-option"],"canShowError":[516,"can-show-error"],"mode":[513],"hideErrorOnFocusOut":[4,"hide-error-on-focus-out"],"listOptionsPosition":[16],"_preSelection":[32],"_visibleOptions":[32],"_startLoading":[32],"_showLoading":[32],"_criteria":[32],"getValueAsync":[64],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"clearValue":[64]},[[11,"scroll","scrollListener"]]]]],["p-5a1d8bf8",[[1,"ez-search",{"value":[1537],"label":[1537],"enabled":[1540],"errorMessage":[1537,"error-message"],"optionLoader":[16],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressEmptyOption":[4,"suppress-empty-option"],"mode":[513],"canShowError":[516,"can-show-error"],"hideErrorOnFocusOut":[4,"hide-error-on-focus-out"],"listOptionsPosition":[16],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"clearValue":[64],"getValueAsync":[64]}]]],["p-95426f93",[[1,"ez-check",{"label":[513],"value":[1540],"enabled":[1540],"indeterminate":[1540],"mode":[513],"compact":[4],"getMode":[64],"setFocus":[64]}]]],["p-1e7c4986",[[1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]]],["p-32b4163f",[[1,"ez-button",{"label":[513],"enabled":[516],"mode":[513],"image":[513],"iconName":[513,"icon-name"],"size":[513],"setFocus":[64],"setBlur":[64]},[[2,"click","clickListener"]]]]],["p-9f41b414",[[2,"ez-form",{"dataUnit":[1040],"config":[16],"recordsValidator":[16],"validate":[64]}]]]]'),e)));
1
+ import{p as e,b as o}from"./p-e318d280.js";export{s as setNonce}from"./p-e318d280.js";(()=>{const o=import.meta.url,t={};return""!==o&&(t.resourcesUrl=new URL(".",o).href),e(t)})().then((e=>o(JSON.parse('[["p-fd54b5b4",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"config":[1040],"selectionToastConfig":[16],"serverUrl":[1,"server-url"],"dataUnit":[16],"statusResolver":[16],"columnfilterDataSource":[16],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"_paginationInfo":[32],"_paginationChangedByKeyboard":[32],"_showSelectionCounter":[32],"_isAllSelection":[32],"_currentPageSelected":[32],"_selectionCount":[32],"_originalRecords":[32],"setColumnsDef":[64],"addColumnMenuItem":[64],"setColumnsState":[64],"setData":[64],"getSelection":[64],"getColumnsState":[64],"getColumns":[64],"quickFilter":[64]},[[0,"ezSelectionChange","onSelectionChange"]]]]],["p-9285b53e",[[1,"ez-guide-navigator",{"open":[1540],"selectedId":[1537,"selected-id"],"items":[16],"tooltipResolver":[16],"filterText":[32],"disableItem":[64],"enableItem":[64],"updateItem":[64],"getItem":[64],"getCurrentPath":[64],"selectGuide":[64],"getParent":[64]}]]],["p-ff82b176",[[1,"ez-actions-button",{"enabled":[516],"actions":[1040],"size":[513],"showLabel":[516,"show-label"],"displayIcon":[513,"display-icon"],"checkOption":[516,"check-option"],"value":[513],"isTransparent":[516,"is-transparent"],"arrowActive":[516,"arrow-active"],"_selectedAction":[32],"hideActions":[64],"isOpened":[64]}]]],["p-cd19a6f8",[[1,"ez-breadcrumb",{"items":[1040],"fillMode":[1025,"fill-mode"],"maxItems":[1026,"max-items"],"positionEllipsis":[1026,"position-ellipsis"],"visibleItems":[32],"hiddenItems":[32],"showDropdown":[32],"collapseConfigPosition":[32]}]]],["p-db528b31",[[1,"ez-dialog",{"confirm":[1028],"dialogType":[1025,"dialog-type"],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"],"beforeClose":[1040],"show":[64]}]]],["p-a01068e1",[[6,"ez-modal-container",{"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"showTitleBar":[4,"show-title-bar"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"cancelButtonStatus":[1,"cancel-button-status"],"okButtonStatus":[1,"ok-button-status"]}]]],["p-60ba28ea",[[1,"ez-alert",{"alertType":[513,"alert-type"]}]]],["p-c49dbf23",[[1,"ez-badge",{"size":[513],"label":[513],"iconLeft":[513,"icon-left"],"iconRight":[513,"icon-right"],"position":[1040],"hasSlot":[32]}]]],["p-f4208819",[[1,"ez-chip",{"label":[513],"enabled":[516],"removePosition":[513,"remove-position"],"mode":[513],"value":[1540],"showNativeTooltip":[4,"show-native-tooltip"],"setFocus":[64],"setBlur":[64]}]]],["p-ccb4ccd9",[[1,"ez-file-item",{"canRemove":[4,"can-remove"],"fileName":[1,"file-name"],"iconName":[1,"icon-name"],"fileSize":[2,"file-size"],"progress":[2]}]]],["p-d51aa09b",[[0,"ez-application"]]],["p-68352e41",[[1,"ez-card-item",{"item":[16]}]]],["p-7525e604",[[1,"ez-loading-bar",{"_showLoading":[32],"hide":[64],"show":[64]}]]],["p-5ce6548c",[[1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"heightMode":[1,"height-mode"],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"],"scrim":[1]}]]],["p-e7fa0ad6",[[1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[516,"use-header"],"heightMode":[513,"height-mode"],"ezTitle":[1,"ez-title"]}]]],["p-b11f035c",[[1,"ez-radio-button",{"value":[1544],"options":[1040],"enabled":[516],"label":[513],"direction":[1537]}]]],["p-5d6f2550",[[0,"ez-skeleton",{"count":[2],"variant":[1],"width":[1],"height":[1],"marginBottom":[1,"margin-bottom"],"animation":[1]}]]],["p-fa571a4e",[[1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"],"show":[64]}]]],["p-9b347f04",[[0,"ez-view-stack",{"show":[64],"getSelectedIndex":[64]}]]],["p-8fdff9cd",[[2,"ez-form-view",{"fields":[16],"showUp":[64]}]]],["p-87e85160",[[0,"multi-selection-box-message",{"message":[1]}],[1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"asyncSearch":[516,"async-search"],"canShowError":[516,"can-show-error"],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"setValue":[64],"endSearch":[64]}]]],["p-2a0e1679",[[2,"ez-multi-selection-list",{"columnName":[1,"column-name"],"dataSource":[16],"useOptions":[1028,"use-options"],"options":[16],"filteredOptions":[32],"displayOptions":[32],"viewScenario":[32],"displayOptionToCheckAllItems":[32],"clearFilteredOptions":[64]}]]],["p-4c8b029b",[[0,"filter-column",{"opened":[4],"columnName":[1,"column-name"],"columnLabel":[1,"column-label"],"gridHeaderHidden":[4,"grid-header-hidden"],"dataSource":[16],"dataUnit":[16],"options":[1040],"selectedItems":[32],"fieldDescriptor":[32],"useOptions":[32],"hide":[64],"show":[64]}]]],["p-a510a4c5",[[1,"ez-dropdown",{"items":[1040],"value":[1040],"itemBuilder":[16]}]]],["p-83885b21",[[1,"ez-tabselector",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32]}]]],["p-8bd3903b",[[1,"ez-collapsible-box",{"value":[1540],"boxBordered":[4,"box-bordered"],"label":[513],"subtitle":[513],"headerSize":[513,"header-size"],"iconPlacement":[513,"icon-placement"],"headerAlign":[513,"header-align"],"removable":[516],"editable":[516],"conditionalSave":[16],"_activeEditText":[32],"showHide":[64],"applyFocusTextEdit":[64],"cancelEdition":[64]}]]],["p-5cef0264",[[1,"ez-calendar",{"value":[1040],"floating":[516],"time":[516],"showSeconds":[516,"show-seconds"],"show":[64],"fitVertical":[64],"fitHorizontal":[64],"hide":[64]},[[11,"scroll","scrollListener"]]]]],["p-e67d0bd5",[[1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"noBorder":[516,"no-border"],"setFocus":[64],"setBlur":[64],"isInvalid":[64]}]]],["p-d43b22f3",[[1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"mode":[513],"canShowError":[516,"can-show-error"],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"getValueAsync":[64]}]]],["p-ce035beb",[[1,"ez-date-time-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"canShowError":[516,"can-show-error"],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"getValueAsync":[64]}]]],["p-028f264f",[[1,"ez-time-input",{"label":[513],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"canShowError":[516,"can-show-error"],"setFocus":[64],"setBlur":[64],"isInvalid":[64]}]]],["p-e2dfd935",[[1,"ez-number-input",{"label":[1],"value":[1538],"enabled":[4],"canShowError":[516,"can-show-error"],"errorMessage":[1537,"error-message"],"precision":[2],"prettyPrecision":[2,"pretty-precision"],"mode":[513],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"getValueAsync":[64]}]]],["p-2da09f70",[[1,"ez-popover",{"autoClose":[516,"auto-close"],"boxWidth":[513,"box-width"],"opened":[1540],"innerElement":[1537,"inner-element"],"overlayType":[513,"overlay-type"],"updatePosition":[64],"show":[64],"showUnder":[64],"hide":[64]}]]],["p-391de0e4",[[1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"errorMessage":[1537,"error-message"],"rows":[1538],"canShowError":[516,"can-show-error"],"mode":[513],"enableResize":[516,"enable-resize"],"appendTextToSelection":[64],"setFocus":[64],"setBlur":[64],"isInvalid":[64]}]]],["p-37673563",[[1,"ez-upload",{"label":[1],"subtitle":[1],"enabled":[4],"maxFileSize":[2,"max-file-size"],"maxFiles":[2,"max-files"],"requestHeaders":[8,"request-headers"],"urlUpload":[1,"url-upload"],"urlDelete":[1,"url-delete"],"value":[1040],"addFiles":[64],"setFocus":[64],"setBlur":[64]}]]],["p-a5e09759",[[1,"ez-text-edit",{"value":[1],"styled":[16],"_newValue":[32],"applyFocusSelect":[64]}]]],["p-050247dc",[[1,"ez-tree",{"items":[1040],"value":[1040],"selectedId":[1537,"selected-id"],"iconResolver":[16],"tooltipResolver":[16],"_tree":[32],"_waintingForLoad":[32],"selectItem":[64],"openItem":[64],"disableItem":[64],"enableItem":[64],"addChild":[64],"applyFilter":[64],"updateItem":[64],"getItem":[64],"getCurrentPath":[64],"getParent":[64]},[[2,"keydown","onKeyDownListener"]]],[1,"ez-scroller",{"direction":[1],"locked":[4],"activeShadow":[4,"active-shadow"],"isActive":[32]},[[2,"click","clickListener"],[1,"mousedown","mouseDownHandler"],[1,"mouseup","mouseUpHandler"],[1,"mousemove","mouseMoveHandler"]]],[1,"ez-sidebar-button"]]],["p-244dfe8a",[[1,"ez-list",{"dataSource":[1040],"listMode":[1,"list-mode"],"useGroups":[1540,"use-groups"],"ezDraggable":[1028,"ez-draggable"],"ezSelectable":[1028,"ez-selectable"],"itemSlotBuilder":[1040],"itemLeftSlotBuilder":[1040],"hoverFeedback":[1028,"hover-feedback"],"_listItems":[32],"_listGroupItems":[32],"clearHistory":[64],"scrollToTop":[64],"setSelection":[64],"getSelection":[64],"getList":[64],"removeSelection":[64]}]]],["p-411f3579",[[1,"ez-combo-box",{"value":[1537],"label":[513],"enabled":[516],"options":[1040],"errorMessage":[1537,"error-message"],"searchMode":[4,"search-mode"],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressSearch":[4,"suppress-search"],"optionLoader":[16],"suppressEmptyOption":[4,"suppress-empty-option"],"canShowError":[516,"can-show-error"],"mode":[513],"hideErrorOnFocusOut":[4,"hide-error-on-focus-out"],"listOptionsPosition":[16],"_preSelection":[32],"_visibleOptions":[32],"_startLoading":[32],"_showLoading":[32],"_criteria":[32],"getValueAsync":[64],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"clearValue":[64]},[[11,"scroll","scrollListener"]]]]],["p-5a1d8bf8",[[1,"ez-search",{"value":[1537],"label":[1537],"enabled":[1540],"errorMessage":[1537,"error-message"],"optionLoader":[16],"showSelectedValue":[4,"show-selected-value"],"showOptionValue":[4,"show-option-value"],"suppressEmptyOption":[4,"suppress-empty-option"],"mode":[513],"canShowError":[516,"can-show-error"],"hideErrorOnFocusOut":[4,"hide-error-on-focus-out"],"listOptionsPosition":[16],"setFocus":[64],"setBlur":[64],"isInvalid":[64],"clearValue":[64],"getValueAsync":[64]}]]],["p-95426f93",[[1,"ez-check",{"label":[513],"value":[1540],"enabled":[1540],"indeterminate":[1540],"mode":[513],"compact":[4],"getMode":[64],"setFocus":[64]}]]],["p-1e7c4986",[[1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]]],["p-32b4163f",[[1,"ez-button",{"label":[513],"enabled":[516],"mode":[513],"image":[513],"iconName":[513,"icon-name"],"size":[513],"setFocus":[64],"setBlur":[64]},[[2,"click","clickListener"]]]]],["p-6ab2f7c2",[[2,"ez-form",{"dataUnit":[1040],"config":[16],"recordsValidator":[16],"validate":[64]}]]]]'),e)));
@@ -1 +1 @@
1
- import{r as t,c as i,h as e,f as s,H as n,g as r}from"./p-e318d280.js";import{DateUtils as o,Action as a,WaitingChangeException as h,ApplicationContext as l,DataUnitAction as c,StringUtils as u,DataUnit as d,ElementIDUtils as f}from"@sankhyalabs/core";import{b as v,R as p}from"./p-86a2036d.js";import"./p-f15ec3bb.js";import"./p-ab574d59.js";const b=/child\[([^\]]+)\]/,m=/\$\{.+\}/;class _{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}static getDetailName(t){const i=b.exec(t);return i?i[1]:void 0}getSheet(t){return this._sheets.get(t)}getAllSheets(){return this._sheets}addSheet(t){this._sheets.set(t.name,t)}addRequiredFields(t){this._requiredFields=this._requiredFields.concat(t)}getRequiredFields(){return this._requiredFields}addCleanOnCopyFields(t){this._cleanOnCopyFields=this._cleanOnCopyFields.concat(t)}getCleanOnCopyFields(){return this._cleanOnCopyFields}addDefaultValues(t){return this._defaultValues=Object.assign(Object.assign({},this._defaultValues),t)}getDefaultValues(){const t={};return Object.entries(this._defaultValues).forEach((([i,e])=>{if("string"==typeof e){const t=m.exec(e);t&&(e=this.getDefaultVar(t[0]))}t[i]=e})),t}getDefaultVar(t){return"${data}"===t?o.getToday():"${datahora}"===t?o.getToday(!0):this._defaultVars?this._defaultVars.get(t):void 0}setDefaultVars(t){this._defaultVars=t}}const y=(t,i)=>"__main"==t[0].label?-1:(t[0].order||1e4)-(i[0].order||1e4);class g{constructor(t){this.onDataUnitEvent=t=>{var i,e;switch(t.type){case a.DATA_LOADED:case a.DATA_SAVED:case a.RECORDS_REMOVED:case a.RECORDS_ADDED:case a.RECORDS_COPIED:case a.EDITION_CANCELED:case a.SELECTION_CHANGED:case a.NEXT_SELECTED:case a.PREVIOUS_SELECTED:this.clearInvalid();case a.DATA_CHANGED:case a.CHANGE_UNDONE:case a.CHANGE_REDONE:case a.RECORD_LOADED:null===(i=this._fields)||void 0===i||i.forEach((t=>{this.updateValue(t.fieldName,t.field)}));break;case a.FIELD_INVALIDATED:null===(e=this._fields)||void 0===e||e.forEach((t=>{this.updateErrorMessage(t.fieldName,t.field)}))}},this._fields=new Map,this._dataUnit=t,this.applyDefaultValues(),this._dataUnit.subscribe(this.onDataUnitEvent),this._dataUnit.addInterceptor(this)}applyDefaultValues(){const t=(this._dataUnit.getAddedRecords()||[]).map((t=>t.__record__id__));if(t.length>0){const i=this.getDefaultValues();i&&Object.keys(i).forEach((e=>{this._dataUnit.setFieldValue(e,i[e],t)}))}}bind(t,i,e,s){t.forEach((t=>{const{fieldName:e,contextName:s}=t.dataset;null!=s&&s!==i||this.updateBind(e,t)})),this._formMetadata=e,this._recordValidatorProcessor=new p(this._dataUnit,{getRequiredFields:()=>this._formMetadata.getRequiredFields(),markAsInvalid:t=>this.markInvalid(t),getMessageForField:t=>this.getErrorMessage(t)},s)}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent),this._dataUnit.removeInterceptor(this)}getCurrentRecordId(){const t=this._dataUnit.getSelectedRecord();return null==t?void 0:t.__record__id__}markInvalid(t){if(this._fields.has(t.name)){const i=this._fields.get(t.name).field;this.updateErrorMessage(t.name,i,t.message)}}clearInvalid(t){this._dataUnit.clearInvalid(t),this._fields.forEach((t=>{t.field.errorMessage=""}))}updateValue(t,i){const e=this._fields.get(t);try{e&&(e.listen=!1),i.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,i)}finally{e&&(e.listen=!0)}}validate(){return this._recordValidatorProcessor.validate()}updateErrorMessage(t,i,e){null==e&&(e=this._dataUnit.getInvalidMessage(this.getCurrentRecordId(),t)),i.errorMessage||(i.errorMessage=e)}getErrorMessage(t){if(this._fields.has(t))return this._fields.get(t).field.errorMessage}updateBind(t,i){const e=this._fields.get(t);e&&e.destroy(),i.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,i),this._fields.set(t,w.create(t,i,((t,i)=>this.changeStarted(t,i)),(t=>this.cancelWaitingChange(t)),((t,i)=>this.setFieldValue(t,i)))),this.bindSearchOptionsLoader(t,i),this.applyEzUploadContext(t,i)}changeStarted(t,i){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!i.blocking&&null==i.promise){const e=this._fields.get(t);e&&(i.promise=new Promise(((t,i)=>{e.waitingChangePromiseResolve=t,e.waitingChangePromiseReject=i})))}this._dataUnit.startChange(t,i)}cancelWaitingChange(t){if(this._dataUnit.waitingForChange(t)){this._dataUnit.cancelWaitingChange(t);const i=this._fields.get(t);i&&i.rejectWaitingChange(new h("Change canceled",t))}}setFieldValue(t,i){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._dataUnit.clearInvalid(this.getCurrentRecordId(),t),this._dataUnit.setFieldValue(t,i),this._dataUnit.waitingForChange(t)){const i=this._fields.get(t);i&&i.acceptWaitingChange()}}bindSearchOptionsLoader(t,i){if("EZ-SEARCH"===i.nodeName&&null==i.optionLoader){const e=l.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");e&&(i.optionLoader=i=>e(i,t,this._dataUnit))}}applyEzUploadContext(t,i){var e,s;if("EZ-UPLOAD"===i.nodeName){i.urlUpload=l.getContextValue("__EZUI__UPLOAD__ADD__URL__"),i.urlDelete=l.getContextValue("__EZUI__UPLOAD__DEL__URL__");const n=this._dataUnit.getField(t),r=null===(e=n.properties)||void 0===e?void 0:e.DESTINATION;r&&(i.requestHeaders={XTRAINF:`{"destination": "${r}"}`}),i.maxFiles=(null===(s=n.properties)||void 0===s?void 0:s.MAX_FILES)||0}}interceptAction(t){if(t.type===a.RECORDS_COPIED){const i=this._formMetadata.getCleanOnCopyFields();if(i)return new c(a.RECORDS_COPIED,t.payload.map((t=>{const e=Object.assign({},t);return i.forEach((t=>delete e[t])),e})))}if(t.type===a.SAVING_DATA)return new Promise((i=>{this.validate().then((()=>i(t))).catch((()=>{}))}));if(t.type===a.RECORDS_ADDED){const i=this.getDefaultValues();if(i)return new c(a.RECORDS_ADDED,t.payload.map((t=>Object.assign(Object.assign({},t),i))))}return t}getDefaultValues(){var t;const i=null===(t=this._formMetadata)||void 0===t?void 0:t.getDefaultValues();if(i){const t={};for(const e in i)t[e]=this._dataUnit.valueFromString(e,i[e]);return t}}}class w{constructor(){this.listen=!0,this.startChangeEventName="ezStartChange",this.cancelWaitingChangeEventName="ezCancelWaitingChange",this.changeEventName="ezChange"}destroy(){this.field.removeEventListener(this.startChangeEventName,this.startChangeListener),this.field.removeEventListener(this.cancelWaitingChangeEventName,this.cancelWaitingChangeListener),this.field.removeEventListener(this.changeEventName,this.changeListener)}acceptWaitingChange(){this.waitingChangePromiseResolve&&(this.waitingChangePromiseResolve(),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}rejectWaitingChange(t){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(t),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(t,i,e,s,n){const r=new w;return r.field=i,r.fieldName=t,r.startChangeListener=i=>{r.listen&&e(t,i.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{r.listen&&s(t)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=i=>{r.listen&&n(t,i.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}function E(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var O="function"==typeof Symbol&&Symbol.observable||"@@observable",C=function(){return Math.random().toString(36).substring(7).split("").join(".")},A={INIT:"@@redux/INIT"+C(),REPLACE:"@@redux/REPLACE"+C(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+C()}};function j(t){if("object"!=typeof t||null===t)return!1;for(var i=t;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return Object.getPrototypeOf(t)===i}function R(t,i,e){var s;if("function"==typeof i&&"function"==typeof e||"function"==typeof e&&"function"==typeof arguments[3])throw new Error(E(0));if("function"==typeof i&&void 0===e&&(e=i,i=void 0),void 0!==e){if("function"!=typeof e)throw new Error(E(1));return e(R)(t,i)}if("function"!=typeof t)throw new Error(E(2));var n=t,r=i,o=[],a=o,h=!1;function l(){a===o&&(a=o.slice())}function c(){if(h)throw new Error(E(3));return r}function u(t){if("function"!=typeof t)throw new Error(E(4));if(h)throw new Error(E(5));var i=!0;return l(),a.push(t),function(){if(i){if(h)throw new Error(E(6));i=!1,l();var e=a.indexOf(t);a.splice(e,1),o=null}}}function d(t){if(!j(t))throw new Error(E(7));if(void 0===t.type)throw new Error(E(8));if(h)throw new Error(E(9));try{h=!0,r=n(r,t)}finally{h=!1}for(var i=o=a,e=0;e<i.length;e++)(0,i[e])();return t}function f(t){if("function"!=typeof t)throw new Error(E(10));n=t,d({type:A.REPLACE})}function v(){var t,i=u;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(E(11));function e(){t.next&&t.next(c())}return e(),{unsubscribe:i(e)}}})[O]=function(){return this},t}return d({type:A.INIT}),(s={dispatch:d,subscribe:u,getState:c,replaceReducer:f})[O]=v,s}const D={};function z(t=D,i){switch(i.type){case x.METADATA_LOADED:return Object.assign(Object.assign({},t),{formMetadata:i.payload,currentSheet:void 0});case x.CHANGE_TAB:return Object.assign(Object.assign({},t),{currentSheet:i.payload});default:return t}}function N(t){return t.formMetadata}var x;!function(t){t.METADATA_LOADED="FORM/METADATA_LOADED",t.CHANGE_TAB="FORM/CHANGE_TAB"}(x||(x={}));const I=class{constructor(e){t(this,e),this.ezReady=i(this,"ezReady",7),this.onDataUnitAction=t=>{t.type===a.METADATA_LOADED&&this.processMetadata()},this.dataUnit=void 0,this.config=void 0,this.recordsValidator=void 0}validate(){return this._dataBinder.validate()}observeConfig(){this.processMetadata()}getDynamicContent(){var t;const i=N(this._store.getState());if(!i)return null;const s=Array.from(i.getAllSheets().values()),n=function(t){const i=function(t){return t.currentSheet}(t);return i?t.formMetadata.getSheet(i):Array.from(t.formMetadata.getAllSheets().values())[0]}(null===(t=this._store)||void 0===t?void 0:t.getState());let r=[];if(s.length>1){const t=s.map(((t,i)=>({tabKey:t.name,label:t.label,index:i}))),i="selector";r.push(e("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:t=>this._store.dispatch(function(t){return{type:x.CHANGE_TAB,payload:"string"==typeof t?t:t.tabKey}}(t.detail)),selectedTab:n.name,"data-element-id":i}))}return r=r.concat(this.buildFormContent(n)),r}buildFormContent(t){const i=null==t?void 0:t.fields;if(null==t)return;const s=`${u.replaceAccentuatedChars(u.toCamelCase(null==t?void 0:t.label),!1)}_selectorContainer`;return e("div",{class:"dynamic-content","data-element-id":s},e("ez-form-view",{class:"ez-row ez-padding-vertical--small",fields:i}))}processMetadata(){if(!this.isStatic()&&this.dataUnit&&this._store){const t=((t,i,e=!1)=>{var s,n;null!=t&&!0!==(null==t?void 0:t.emptyConfig)||(t=(t=>{const i=t.metadata;let e;return i&&(e=i.fields.filter((t=>!1!==t.visible)).map((t=>({name:t.name,defaultValue:t.defaultValue})))),{emptyConfig:!1,fields:e}})(i));const r=new Map,o=new Map,a=[],h=[],l={};null===(s=null==t?void 0:t.tabs)||void 0===s||s.forEach((t=>{o.has(t.label)||!1!==t.visible||o.set(t.label,t)})),null===(n=null==t?void 0:t.fields)||void 0===n||n.forEach((t=>{var e,s,n;if(!1!==t.visible){const c=((t,i)=>("string"==typeof t?Array.from(i.keys()).find((i=>i.label===t)):t)||{label:t,visible:!0})(t.tab||"__main",r);if(o.has(c.label))return;const u=i.getField(t.name);if(u&&c.visible){r.has(c)||r.set(c,[]);const i=v(u,t);r.get(c).push(i),i.required&&a.push(t.name),((null==t.cleanOnCopy?null===(e=u.properties)||void 0===e?void 0:e.cleanOnCopy:t.cleanOnCopy)||(null===(s=u.properties)||void 0===s?void 0:s.cleanOnCopy))&&h.push(t.name);let o=null==t.defaultValue?null===(n=u.properties)||void 0===n?void 0:n.defaultValue:t.defaultValue;if(o&&null!=o.value){const{type:i,value:e}=o;if(i)if("V"===i)o=e;else try{const t=JSON.parse(e);o=t&&"value"in t?t:e}catch(t){}l[t.name]=o}}}}));const c=new _;if(c.setDefaultVars(t.defaultVars),e){const t=i.metadata;null!=t&&null!=t.children&&t.children.forEach((t=>{const{label:i,name:e,fields:s}=(t=>({name:`child[${t.name}]`,label:t.label,fields:[]}))(t);r.set({name:e,label:i},s)}))}return Array.from(r.entries()).sort(y).forEach((([t,i])=>{c.addSheet({label:"__main"===t.label?"Principal":t.label,name:t.name||t.label,fields:i})})),c.addRequiredFields(a),c.addCleanOnCopyFields(h),c.addDefaultValues(l),c})(this.config,this.dataUnit);this._store.dispatch({type:x.METADATA_LOADED,payload:t})}}isStatic(){var t;return(null===(t=this._staticFields)||void 0===t?void 0:t.length)>0}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new d("ez-form")),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new g(this.dataUnit),this._store=R(z),this._store.subscribe((()=>s(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),f.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){const t=N(this._store.getState());t.addRequiredFields(this._staticFields.filter((t=>t.dataset.required)).map((t=>t.dataset.fieldName))),this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")),this.dataUnit.dataUnitId,t,this.recordsValidator),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(t){return t&&t.forEach((t=>t[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=u.toCamelCase(t.label))),t}render(){return e(n,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};I.style=".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)}";export{I as ez_form}
1
+ import{r as t,c as i,h as e,f as s,H as n,g as r}from"./p-e318d280.js";import{DateUtils as o,Action as a,WaitingChangeException as h,ApplicationContext as l,DataUnitAction as c,StringUtils as u,DataUnit as d,ElementIDUtils as f}from"@sankhyalabs/core";import{b as v,R as p}from"./p-86a2036d.js";import"./p-f15ec3bb.js";import"./p-ab574d59.js";const b=/child\[([^\]]+)\]/,m=/\$\{.+\}/;class y{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}static getDetailName(t){const i=b.exec(t);return i?i[1]:void 0}getSheet(t){return this._sheets.get(t)}getAllSheets(){return this._sheets}addSheet(t){this._sheets.set(t.name,t)}addRequiredFields(t){this._requiredFields=this._requiredFields.concat(t)}getRequiredFields(){return this._requiredFields}addCleanOnCopyFields(t){this._cleanOnCopyFields=this._cleanOnCopyFields.concat(t)}getCleanOnCopyFields(){return this._cleanOnCopyFields}addDefaultValues(t){return this._defaultValues=Object.assign(Object.assign({},this._defaultValues),t)}getDefaultValues(){const t={};return Object.entries(this._defaultValues).forEach((([i,e])=>{if("string"==typeof e){const t=m.exec(e);t&&(e=this.getDefaultVar(t[0]))}t[i]=e})),t}getDefaultVar(t){return"${data}"===t?o.getToday():"${datahora}"===t?o.getToday(!0):this._defaultVars?this._defaultVars.get(t):void 0}setDefaultVars(t){this._defaultVars=t}}const _=(t,i)=>"__main"==t[0].label?-1:(t[0].order||1e4)-(i[0].order||1e4);class g{constructor(t){this.onDataUnitEvent=t=>{var i,e;switch(t.type){case a.DATA_LOADED:case a.DATA_SAVED:case a.RECORDS_REMOVED:case a.RECORDS_ADDED:case a.RECORDS_COPIED:case a.EDITION_CANCELED:case a.SELECTION_CHANGED:case a.NEXT_SELECTED:case a.PREVIOUS_SELECTED:this.clearInvalid();case a.DATA_CHANGED:case a.CHANGE_UNDONE:case a.CHANGE_REDONE:case a.RECORD_LOADED:null===(i=this._fields)||void 0===i||i.forEach((t=>{this.updateValue(t.fieldName,t.field)}));break;case a.FIELD_INVALIDATED:null===(e=this._fields)||void 0===e||e.forEach((t=>{this.updateErrorMessage(t.fieldName,t.field)}))}},this._fields=new Map,this._dataUnit=t,this.applyDefaultValues(),this._dataUnit.subscribe(this.onDataUnitEvent),this._dataUnit.addInterceptor(this)}applyDefaultValues(){const t=(this._dataUnit.getAddedRecords()||[]).map((t=>t.__record__id__));if(t.length>0){const i=this.getDefaultValues();i&&Object.keys(i).forEach((e=>{this._dataUnit.setFieldValue(e,i[e],t)}))}}bind(t,i,e,s){t.forEach((t=>{const{fieldName:e,contextName:s}=t.dataset;null!=s&&s!==i||this.updateBind(e,t)})),this._formMetadata=e,this._recordValidatorProcessor=new p(this._dataUnit,{getRequiredFields:()=>this._formMetadata.getRequiredFields(),markAsInvalid:t=>this.markInvalid(t),getMessageForField:t=>this.getErrorMessage(t)},s)}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent),this._dataUnit.removeInterceptor(this)}getCurrentRecordId(){const t=this._dataUnit.getSelectedRecord();return null==t?void 0:t.__record__id__}markInvalid(t){if(this._fields.has(t.name)){const i=this._fields.get(t.name).field;this.updateErrorMessage(t.name,i,t.message)}}clearInvalid(t){this._dataUnit.clearInvalid(t),this._fields.forEach((t=>{t.field.errorMessage=""}))}updateValue(t,i){const e=this._fields.get(t);try{e&&(e.listen=!1),i.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,i)}finally{e&&(e.listen=!0)}}validate(){return this._recordValidatorProcessor.validate()}updateErrorMessage(t,i,e){null==e&&(e=this._dataUnit.getInvalidMessage(this.getCurrentRecordId(),t)),i.errorMessage||(i.errorMessage=e)}getErrorMessage(t){if(this._fields.has(t))return this._fields.get(t).field.errorMessage}updateBind(t,i){const e=this._fields.get(t);e&&e.destroy(),i.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,i),this._fields.set(t,w.create(t,i,((t,i)=>this.changeStarted(t,i)),(t=>this.cancelWaitingChange(t)),((t,i)=>this.setFieldValue(t,i)))),this.bindSearchOptionsLoader(t,i),this.applyEzUploadContext(t,i)}changeStarted(t,i){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!i.blocking&&null==i.promise){const e=this._fields.get(t);e&&(i.promise=new Promise(((t,i)=>{e.waitingChangePromiseResolve=t,e.waitingChangePromiseReject=i})))}this._dataUnit.startChange(t,i)}cancelWaitingChange(t){if(this._dataUnit.waitingForChange(t)){this._dataUnit.cancelWaitingChange(t);const i=this._fields.get(t);i&&i.rejectWaitingChange(new h("Change canceled",t))}}setFieldValue(t,i){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._dataUnit.clearInvalid(this.getCurrentRecordId(),t),this._dataUnit.setFieldValue(t,i),this._dataUnit.waitingForChange(t)){const i=this._fields.get(t);i&&i.acceptWaitingChange()}}bindSearchOptionsLoader(t,i){if("EZ-SEARCH"===i.nodeName&&null==i.optionLoader){const e=l.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");e&&(i.optionLoader=i=>e(i,t,this._dataUnit))}}applyEzUploadContext(t,i){var e,s;if("EZ-UPLOAD"===i.nodeName){i.urlUpload=l.getContextValue("__EZUI__UPLOAD__ADD__URL__"),i.urlDelete=l.getContextValue("__EZUI__UPLOAD__DEL__URL__");const n=this._dataUnit.getField(t),r=null===(e=n.properties)||void 0===e?void 0:e.DESTINATION;r&&(i.requestHeaders={XTRAINF:`{"destination": "${r}"}`}),i.maxFiles=(null===(s=n.properties)||void 0===s?void 0:s.MAX_FILES)||0}}interceptAction(t){if(t.type===a.RECORDS_COPIED){const i=this._formMetadata.getCleanOnCopyFields();if(i)return new c(a.RECORDS_COPIED,t.payload.map((t=>{const e=Object.assign({},t);return i.forEach((t=>delete e[t])),e})))}if(t.type===a.SAVING_DATA)return new Promise((i=>{this.validate().then((()=>i(t))).catch((()=>{}))}));if(t.type===a.RECORDS_ADDED){const i=this.getDefaultValues();if(i)return new c(a.RECORDS_ADDED,t.payload.map((t=>Object.assign(Object.assign({},t),i))))}return t}getDefaultValues(){var t;const i=null===(t=this._formMetadata)||void 0===t?void 0:t.getDefaultValues();if(i){const t={};for(const e in i)t[e]=this._dataUnit.valueFromString(e,i[e]);return t}}}class w{constructor(){this.listen=!0,this.startChangeEventName="ezStartChange",this.cancelWaitingChangeEventName="ezCancelWaitingChange",this.changeEventName="ezChange"}destroy(){this.field.removeEventListener(this.startChangeEventName,this.startChangeListener),this.field.removeEventListener(this.cancelWaitingChangeEventName,this.cancelWaitingChangeListener),this.field.removeEventListener(this.changeEventName,this.changeListener)}acceptWaitingChange(){this.waitingChangePromiseResolve&&(this.waitingChangePromiseResolve(),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}rejectWaitingChange(t){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(t),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(t,i,e,s,n){const r=new w;return r.field=i,r.fieldName=t,r.startChangeListener=i=>{r.listen&&e(t,i.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{r.listen&&s(t)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=i=>{r.listen&&n(t,i.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}function E(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var O="function"==typeof Symbol&&Symbol.observable||"@@observable",C=function(){return Math.random().toString(36).substring(7).split("").join(".")},A={INIT:"@@redux/INIT"+C(),REPLACE:"@@redux/REPLACE"+C(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+C()}};function j(t){if("object"!=typeof t||null===t)return!1;for(var i=t;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return Object.getPrototypeOf(t)===i}function R(t,i,e){var s;if("function"==typeof i&&"function"==typeof e||"function"==typeof e&&"function"==typeof arguments[3])throw new Error(E(0));if("function"==typeof i&&void 0===e&&(e=i,i=void 0),void 0!==e){if("function"!=typeof e)throw new Error(E(1));return e(R)(t,i)}if("function"!=typeof t)throw new Error(E(2));var n=t,r=i,o=[],a=o,h=!1;function l(){a===o&&(a=o.slice())}function c(){if(h)throw new Error(E(3));return r}function u(t){if("function"!=typeof t)throw new Error(E(4));if(h)throw new Error(E(5));var i=!0;return l(),a.push(t),function(){if(i){if(h)throw new Error(E(6));i=!1,l();var e=a.indexOf(t);a.splice(e,1),o=null}}}function d(t){if(!j(t))throw new Error(E(7));if(void 0===t.type)throw new Error(E(8));if(h)throw new Error(E(9));try{h=!0,r=n(r,t)}finally{h=!1}for(var i=o=a,e=0;e<i.length;e++)(0,i[e])();return t}function f(t){if("function"!=typeof t)throw new Error(E(10));n=t,d({type:A.REPLACE})}function v(){var t,i=u;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(E(11));function e(){t.next&&t.next(c())}return e(),{unsubscribe:i(e)}}})[O]=function(){return this},t}return d({type:A.INIT}),(s={dispatch:d,subscribe:u,getState:c,replaceReducer:f})[O]=v,s}const D={};function z(t=D,i){switch(i.type){case N.METADATA_LOADED:return Object.assign(Object.assign({},t),{formMetadata:i.payload,currentSheet:void 0});case N.CHANGE_TAB:return Object.assign(Object.assign({},t),{currentSheet:i.payload});default:return t}}function I(t){return t.formMetadata}var N;!function(t){t.METADATA_LOADED="FORM/METADATA_LOADED",t.CHANGE_TAB="FORM/CHANGE_TAB"}(N||(N={}));const x=class{constructor(e){t(this,e),this.ezReady=i(this,"ezReady",7),this.formItemsReady=i(this,"formItemsReady",7),this.onDataUnitAction=t=>{t.type===a.METADATA_LOADED&&this.processMetadata()},this.dataUnit=void 0,this.config=void 0,this.recordsValidator=void 0}validate(){return this._dataBinder.validate()}observeConfig(){this.processMetadata()}getDynamicContent(){var t;const i=I(this._store.getState());if(!i)return null;const s=Array.from(i.getAllSheets().values()),n=function(t){const i=function(t){return t.currentSheet}(t);return i?t.formMetadata.getSheet(i):Array.from(t.formMetadata.getAllSheets().values())[0]}(null===(t=this._store)||void 0===t?void 0:t.getState());let r=[];if(s.length>1){const t=s.map(((t,i)=>({tabKey:t.name,label:t.label,index:i}))),i="selector";r.push(e("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:t=>this._store.dispatch(function(t){return{type:N.CHANGE_TAB,payload:"string"==typeof t?t:t.tabKey}}(t.detail)),selectedTab:n.name,"data-element-id":i}))}return r=r.concat(this.buildFormContent(n)),r}buildFormContent(t){const i=null==t?void 0:t.fields;if(null==t)return;const s=`${u.replaceAccentuatedChars(u.toCamelCase(null==t?void 0:t.label),!1)}_selectorContainer`;return e("div",{class:"dynamic-content","data-element-id":s},e("ez-form-view",{class:"ez-row ez-padding-vertical--small",fields:i}))}processMetadata(){if(!this.isStatic()&&this.dataUnit&&this._store){const t=((t,i,e=!1)=>{var s,n;null!=t&&!0!==(null==t?void 0:t.emptyConfig)||(t=(t=>{const i=t.metadata;let e;return i&&(e=i.fields.filter((t=>!1!==t.visible)).map((t=>({name:t.name,defaultValue:t.defaultValue})))),{emptyConfig:!1,fields:e}})(i));const r=new Map,o=new Map,a=[],h=[],l={};null===(s=null==t?void 0:t.tabs)||void 0===s||s.forEach((t=>{o.has(t.label)||!1!==t.visible||o.set(t.label,t)})),null===(n=null==t?void 0:t.fields)||void 0===n||n.forEach((t=>{var e,s,n;if(!1!==t.visible){const c=((t,i)=>("string"==typeof t?Array.from(i.keys()).find((i=>i.label===t)):t)||{label:t,visible:!0})(t.tab||"__main",r);if(o.has(c.label))return;const u=i.getField(t.name);if(u&&c.visible){r.has(c)||r.set(c,[]);const i=v(u,t);r.get(c).push(i),i.required&&a.push(t.name),((null==t.cleanOnCopy?null===(e=u.properties)||void 0===e?void 0:e.cleanOnCopy:t.cleanOnCopy)||(null===(s=u.properties)||void 0===s?void 0:s.cleanOnCopy))&&h.push(t.name);let o=null==t.defaultValue?null===(n=u.properties)||void 0===n?void 0:n.defaultValue:t.defaultValue;if(o&&null!=o.value){const{type:i,value:e}=o;if(i)if("V"===i)o=e;else try{const t=JSON.parse(e);o=t&&"value"in t?t:e}catch(t){}l[t.name]=o}}}}));const c=new y;if(c.setDefaultVars(t.defaultVars),e){const t=i.metadata;null!=t&&null!=t.children&&t.children.forEach((t=>{const{label:i,name:e,fields:s}=(t=>({name:`child[${t.name}]`,label:t.label,fields:[]}))(t);r.set({name:e,label:i},s)}))}return Array.from(r.entries()).sort(_).forEach((([t,i])=>{c.addSheet({label:"__main"===t.label?"Principal":t.label,name:t.name||t.label,fields:i})})),c.addRequiredFields(a),c.addCleanOnCopyFields(h),c.addDefaultValues(l),c})(this.config,this.dataUnit);this._store.dispatch({type:N.METADATA_LOADED,payload:t})}}isStatic(){var t;return(null===(t=this._staticFields)||void 0===t?void 0:t.length)>0}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new d("ez-form")),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new g(this.dataUnit),this._store=R(z),this._store.subscribe((()=>s(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),f.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){const t=I(this._store.getState());t.addRequiredFields(this._staticFields.filter((t=>t.dataset.required)).map((t=>t.dataset.fieldName))),this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")),this.dataUnit.dataUnitId,t,this.recordsValidator),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(t){return t&&t.forEach((t=>t[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=u.toCamelCase(t.label))),t}render(){return e(n,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};x.style=".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)}";export{x as ez_form}
@@ -0,0 +1 @@
1
+ import{h as e,r as a,c as l,H as t,g as o}from"./p-e318d280.js";import{ObjectUtils as n,UserInterface as r,ElementIDUtils as s}from"@sankhyalabs/core";import{R as d}from"./p-27a01a26.js";import{C as i}from"./p-b853763b.js";function c(a,l,t,o,n){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large"},e("ez-check",{enabled:!t,label:l,mode:n?i.SWITCH:i.REGULAR,"data-field-name":a,"data-context-name":o,key:a}))}function m(a,l,t,o,n,r,s){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!t,label:l,precision:o,prettyPrecision:n,"data-field-name":a,"data-context-name":r,key:a,canShowError:s}))}const z=({name:a,label:l,readOnly:t,contextName:o,canShowError:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:l,"data-field-name":a,"data-context-name":o,key:a,enabled:!t,canShowError:n})),h=new Map;h.set(r.CHECKBOX,(e=>c(e.name,e.label,e.readOnly,e.contextName,!1))),h.set(r.SWITCH,(e=>c(e.name,e.label,e.readOnly,e.contextName,!0))),h.set(r.OPTIONSELECTOR,(({name:a,label:l,readOnly:t,required:o,props:n,contextName:r,canShowError:s})=>{const d=null==n?void 0:n.options;let i;if("string"==typeof d){const e=JSON.parse(d);i=Object.keys(e).map((a=>({value:a,label:e[a]})))}else i=d;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!t,suppressEmptyOption:o,label:l,"data-field-name":a,"data-context-name":r,key:a,options:i,canShowError:s}))})),h.set(r.DATE,(({name:a,label:l,readOnly:t,canShowError:o})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!t,label:l,"data-field-name":a,key:a,canShowError:o})))),h.set(r.TIME,(({name:a,label:l,readOnly:t,canShowError:o})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{enabled:!t,label:l,"data-field-name":a,key:a,canShowError:o})))),h.set(r.DATETIME,(({name:a,label:l,readOnly:t,contextName:o,canShowError:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{enabled:!t,label:l,"data-field-name":a,"data-context-name":o,key:a,canShowError:n})))),h.set(r.FILE,(({name:a,label:l,readOnly:t,contextName:o,props:r})=>{const s=n.removeEmptyValues({subTitle:r.subTitle,requestHeaders:r.STORAGESTRATEGY?{STORAGESTRATEGY:r.STORAGESTRATEGY}:null});return e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",Object.assign({enabled:!t,label:l,"data-field-name":a,"data-context-name":o,key:a},s)))})),h.set(r.DECIMALNUMBER,(({name:e,label:a,readOnly:l,props:t,contextName:o,canShowError:n})=>{const r=Number((null==t?void 0:t.precision)||2);return m(e,a,l,r,Number((null==t?void 0:t.prettyPrecision)||r),o,n)})),h.set(r.INTEGERNUMBER,(({name:e,label:a,readOnly:l,contextName:t,canShowError:o})=>m(e,a,l,0,0,t,o))),h.set(r.SEARCH,(({name:a,label:l,readOnly:t,required:o,contextName:n,canShowError:r,optionLoader:s})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!t,suppressEmptyOption:o,label:l,"data-field-name":a,"data-context-name":n,key:a,canShowError:r,optionLoader:s})))),h.set(r.LONGTEXT,(({name:a,label:l,readOnly:t,contextName:o,rows:n,canShowError:r})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:a},e("ez-text-area",{enabled:!t,label:l,"data-field-name":a,"data-context-name":o,rows:n,canShowError:r}))));const b=e=>{const a=h.get(e.userInterface)||z,l=e.required?`${e.label}${d}`:e.label,t=a(Object.assign(Object.assign({},e),{label:l}));return t.l["data-form-item"]=e.name,t};class p{constructor(e){this.elem=e}addRightElement(e){e.classList.add("ez-padding-left--small"),this.elem.classList.add("ez-col--nowrap"),this.elem.appendChild(e)}get fieldName(){return this.elem.getAttribute("data-form-item")}}class u{constructor(e,a){this.items=new Map,this.formId=a,e.forEach((e=>{const a=new p(e);this.items.set(a.fieldName,a)}))}getItem(e){return this.items.get(e)}get formName(){return this.formId}}const y=class{constructor(e){a(this,e),this.ezContentReady=l(this,"ezContentReady",7),this.formItemsReady=l(this,"formItemsReady",7),this.fields=void 0}async showUp(){this._element.scrollIntoView({behavior:"smooth",block:"start"})}groupFields(e){const a=new Map;return e.forEach((e=>{const l=e.group;if(l){let t=a.get(l);null==t&&(t=[],a.set(l,t)),t.push(e)}else a.set(e.name,e)})),a}componentDidRender(){this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")));const e=new u(Array.from(this._element.querySelectorAll("[data-form-item]")));this.formItemsReady.emit(e)}render(){if(s.addIDInfoIfNotExists(this._element,"ezFormView"),null!=this.fields)return e(t,null,Array.from(this.groupFields(this.fields).entries()).map((([a,l])=>Array.isArray(l)?e("ez-collapsible-box",{id:`group-${a}`,label:a,"header-size":"large",key:a},l.map((e=>b(e)))):b(l))))}get _element(){return o(this)}};y.style=".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";export{y as ez_form_view}
@@ -2,6 +2,7 @@ import { DataUnit } from "@sankhyalabs/core";
2
2
  import { EventEmitter } from "../../stencil-public-runtime";
3
3
  import { Tab } from "../ez-tabselector/ez-tabselector";
4
4
  import { IFormConfig, IRecordValidator } from "../../utils/form/interfaces";
5
+ import { FormItems } from "../ez-form-view/structure";
5
6
  export declare class EzForm {
6
7
  private _element;
7
8
  private _store;
@@ -24,6 +25,10 @@ export declare class EzForm {
24
25
  * Evento disparado quando o formulário está disponível na DOM.
25
26
  */
26
27
  ezReady: EventEmitter<void>;
28
+ /**
29
+ * Responsável por notificar quando ocorrer a renderização de itens do formulário.
30
+ */
31
+ formItemsReady: EventEmitter<FormItems>;
27
32
  /**
28
33
  * Realiza validação no conteúdo de todos os campos.
29
34
  */
@@ -1,11 +1,16 @@
1
1
  import { EventEmitter } from '../../stencil-public-runtime';
2
2
  import { IFormViewField } from './interfaces/IFormViewField';
3
+ import { FormItems } from './structure';
3
4
  export declare class EzFormView {
4
5
  _element: HTMLEzFormViewElement;
5
6
  /**
6
7
  * Evento emitido quando o componente foi totalmente carregado na DOM.
7
8
  */
8
9
  ezContentReady: EventEmitter<Array<HTMLElement>>;
10
+ /**
11
+ * Responsável por notificar quando ocorrer a renderização de itens do formulário.
12
+ */
13
+ formItemsReady: EventEmitter<FormItems>;
9
14
  /**
10
15
  * Define a lista de metadados usada para criar os campos de user interface.
11
16
  */
@@ -0,0 +1,14 @@
1
+ declare class FormItem {
2
+ private elem;
3
+ constructor(elem: HTMLElement);
4
+ addRightElement(el: Element): void;
5
+ get fieldName(): string;
6
+ }
7
+ export declare class FormItems {
8
+ items: Map<string, FormItem>;
9
+ private formId;
10
+ constructor(items: Array<HTMLElement>, formId?: string);
11
+ getItem(name: string): FormItem;
12
+ get formName(): string;
13
+ }
14
+ export {};
@@ -15,6 +15,7 @@ import { DataUnit, WaitingChange } from "@sankhyalabs/core";
15
15
  import { DialogType } from "./components/ez-dialog/DialogType";
16
16
  import { IDropdownItem, IDropdownSubAction } from "./components/ez-dropdown/structure/DropdownItem";
17
17
  import { IFormConfig, IRecordValidator } from "./utils/form/interfaces";
18
+ import { FormItems } from "./components/ez-form-view/structure";
18
19
  import { IFormViewField } from "./components/ez-form-view/interfaces/IFormViewField";
19
20
  import { EzGridColumn, EzGridColumnConfig, EzGridColumStateEvent, IGridConfig, IStatusResolver, StatusResolverFunction } from "./components/ez-grid/controller/EzGridController";
20
21
  import { ISelection, ISelectionToastConfig } from "./components/ez-grid/interfaces";
@@ -2562,6 +2563,10 @@ declare namespace LocalJSX {
2562
2563
  * Evento disparado quando o formulário está disponível na DOM.
2563
2564
  */
2564
2565
  "onEzReady"?: (event: EzFormCustomEvent<void>) => void;
2566
+ /**
2567
+ * Responsável por notificar quando ocorrer a renderização de itens do formulário.
2568
+ */
2569
+ "onFormItemsReady"?: (event: EzFormCustomEvent<FormItems>) => void;
2565
2570
  /**
2566
2571
  * Define um validador responsável pela integridade dos registros.
2567
2572
  */
@@ -2576,6 +2581,10 @@ declare namespace LocalJSX {
2576
2581
  * Evento emitido quando o componente foi totalmente carregado na DOM.
2577
2582
  */
2578
2583
  "onEzContentReady"?: (event: EzFormViewCustomEvent<Array<HTMLElement>>) => void;
2584
+ /**
2585
+ * Responsável por notificar quando ocorrer a renderização de itens do formulário.
2586
+ */
2587
+ "onFormItemsReady"?: (event: EzFormViewCustomEvent<FormItems>) => void;
2579
2588
  }
2580
2589
  interface EzGrid {
2581
2590
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/ezui",
3
- "version": "5.11.0-dev.4",
3
+ "version": "5.11.0-dev.5",
4
4
  "description": "Biblioteca de componentes Sankhya.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/custom-elements/index.js",
@@ -1 +0,0 @@
1
- import{h as e,r as a,c as l,H as o,g as n}from"./p-e318d280.js";import{ObjectUtils as t,UserInterface as r,ElementIDUtils as d}from"@sankhyalabs/core";import{R as s}from"./p-27a01a26.js";import{C as c}from"./p-b853763b.js";function i(a,l,o,n,t){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large"},e("ez-check",{enabled:!o,label:l,mode:t?c.SWITCH:c.REGULAR,"data-field-name":a,"data-context-name":n,key:a}))}function m(a,l,o,n,t,r,d){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!o,label:l,precision:n,prettyPrecision:t,"data-field-name":a,"data-context-name":r,key:a,canShowError:d}))}const z=({name:a,label:l,readOnly:o,contextName:n,canShowError:t})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:l,"data-field-name":a,"data-context-name":n,key:a,enabled:!o,canShowError:t})),b=new Map;b.set(r.CHECKBOX,(e=>i(e.name,e.label,e.readOnly,e.contextName,!1))),b.set(r.SWITCH,(e=>i(e.name,e.label,e.readOnly,e.contextName,!0))),b.set(r.OPTIONSELECTOR,(({name:a,label:l,readOnly:o,required:n,props:t,contextName:r,canShowError:d})=>{const s=null==t?void 0:t.options;let c;if("string"==typeof s){const e=JSON.parse(s);c=Object.keys(e).map((a=>({value:a,label:e[a]})))}else c=s;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!o,suppressEmptyOption:n,label:l,"data-field-name":a,"data-context-name":r,key:a,options:c,canShowError:d}))})),b.set(r.DATE,(({name:a,label:l,readOnly:o,canShowError:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!o,label:l,"data-field-name":a,key:a,canShowError:n})))),b.set(r.TIME,(({name:a,label:l,readOnly:o,canShowError:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{enabled:!o,label:l,"data-field-name":a,key:a,canShowError:n})))),b.set(r.DATETIME,(({name:a,label:l,readOnly:o,contextName:n,canShowError:t})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{enabled:!o,label:l,"data-field-name":a,"data-context-name":n,key:a,canShowError:t})))),b.set(r.FILE,(({name:a,label:l,readOnly:o,contextName:n,props:r})=>{const d=t.removeEmptyValues({subTitle:r.subTitle,requestHeaders:r.STORAGESTRATEGY?{STORAGESTRATEGY:r.STORAGESTRATEGY}:null});return e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",Object.assign({enabled:!o,label:l,"data-field-name":a,"data-context-name":n,key:a},d)))})),b.set(r.DECIMALNUMBER,(({name:e,label:a,readOnly:l,props:o,contextName:n,canShowError:t})=>{const r=Number((null==o?void 0:o.precision)||2);return m(e,a,l,r,Number((null==o?void 0:o.prettyPrecision)||r),n,t)})),b.set(r.INTEGERNUMBER,(({name:e,label:a,readOnly:l,contextName:o,canShowError:n})=>m(e,a,l,0,0,o,n))),b.set(r.SEARCH,(({name:a,label:l,readOnly:o,required:n,contextName:t,canShowError:r,optionLoader:d})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!o,suppressEmptyOption:n,label:l,"data-field-name":a,"data-context-name":t,key:a,canShowError:r,optionLoader:d})))),b.set(r.LONGTEXT,(({name:a,label:l,readOnly:o,contextName:n,rows:t,canShowError:r})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:a},e("ez-text-area",{enabled:!o,label:l,"data-field-name":a,"data-context-name":n,rows:t,canShowError:r}))));const p=e=>{const a=b.get(e.userInterface)||z,l=e.required?`${e.label}${s}`:e.label;return a(Object.assign(Object.assign({},e),{label:l}))},h=class{constructor(e){a(this,e),this.ezContentReady=l(this,"ezContentReady",7),this.fields=void 0}async showUp(){this._element.scrollIntoView({behavior:"smooth",block:"start"})}groupFields(e){const a=new Map;return e.forEach((e=>{const l=e.group;if(l){let o=a.get(l);null==o&&(o=[],a.set(l,o)),o.push(e)}else a.set(e.name,e)})),a}componentDidRender(){this.ezContentReady.emit(Array.from(this._element.querySelectorAll("[data-field-name]")))}render(){if(d.addIDInfoIfNotExists(this._element,"ezFormView"),null!=this.fields)return e(o,null,Array.from(this.groupFields(this.fields).entries()).map((([a,l])=>Array.isArray(l)?e("ez-collapsible-box",{id:`group-${a}`,label:a,"header-size":"large",key:a},l.map((e=>p(e)))):p(l))))}get _element(){return n(this)}};h.style=".sc-ez-form-view-h{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}";export{h as ez_form_view}