@sankhyalabs/ezui 2.3.14 → 2.4.0

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.
@@ -352,9 +352,13 @@ let EzComboBox = class {
352
352
  }
353
353
  }
354
354
  componentDidRender() {
355
+ var _a;
355
356
  if (this._floatingID === undefined) {
356
357
  this._listWrapper.remove();
357
358
  }
359
+ (_a = this._optionsList) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".item").forEach((elem) => {
360
+ core.ElementIDUtils.addIDInfoIfNotExists(elem, "itemComboBox");
361
+ });
358
362
  }
359
363
  componentDidLoad() {
360
364
  CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
@@ -118,7 +118,7 @@ const buildFromConfig = (config, dataUnit) => {
118
118
  }
119
119
  });
120
120
  (_b = config === null || config === void 0 ? void 0 : config.fields) === null || _b === void 0 ? void 0 : _b.forEach((field) => {
121
- var _a, _b, _c;
121
+ var _a, _b, _c, _d;
122
122
  if (field.visible !== false) {
123
123
  const tabConfig = getTabConfig(field.tab || "__main", sheets);
124
124
  if (hiddenTabs.has(tabConfig.label)) {
@@ -134,10 +134,10 @@ const buildFromConfig = (config, dataUnit) => {
134
134
  requiredFields.push(field.name);
135
135
  }
136
136
  const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
137
- if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum)) {
137
+ if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum) || ((_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.cleanOnCopy)) {
138
138
  cleanOnCopyFields.push(field.name);
139
139
  }
140
- const defaultValue = field.defaultValue == undefined ? (_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.defaultValue : field.defaultValue;
140
+ const defaultValue = field.defaultValue == undefined ? (_d = descriptor.properties) === null || _d === void 0 ? void 0 : _d.defaultValue : field.defaultValue;
141
141
  if (defaultValue) {
142
142
  defaultValues[field.name] = field.defaultValue;
143
143
  }
@@ -196,6 +196,7 @@ let EzTextInput = class {
196
196
  this._labelElem.classList.add("input__label--right");
197
197
  }
198
198
  }
199
+ slot.name && core.ElementIDUtils.addIDInfo(content, slot.name);
199
200
  }
200
201
  this.observeErrorMessage();
201
202
  }
@@ -236,7 +237,7 @@ let EzTextInput = class {
236
237
  return (index.h(index.Host, null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label && this.mode != "slim" ?
237
238
  index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
238
239
  : null, index.h("input", { "data-element-id": core.ElementIDUtils.getInternalIDInfo("input"), onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", class: this.mode === "slim" ? "input--slim" : "", placeholder: this.mode === "slim" && this.label ? this.label : "", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }), index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.canShowError && this.mode != "slim" &&
239
- index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
240
+ index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage, "data-element-id": core.ElementIDUtils.getInternalIDInfo("message_box") }, this.errorMessage)));
240
241
  }
241
242
  get _hostElement() { return index.getElement(this); }
242
243
  static get watchers() { return {
@@ -342,9 +342,13 @@ export class EzComboBox {
342
342
  }
343
343
  }
344
344
  componentDidRender() {
345
+ var _a;
345
346
  if (this._floatingID === undefined) {
346
347
  this._listWrapper.remove();
347
348
  }
349
+ (_a = this._optionsList) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".item").forEach((elem) => {
350
+ ElementIDUtils.addIDInfoIfNotExists(elem, "itemComboBox");
351
+ });
348
352
  }
349
353
  componentDidLoad() {
350
354
  CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
@@ -108,7 +108,7 @@ export const buildFromConfig = (config, dataUnit) => {
108
108
  }
109
109
  });
110
110
  (_b = config === null || config === void 0 ? void 0 : config.fields) === null || _b === void 0 ? void 0 : _b.forEach((field) => {
111
- var _a, _b, _c;
111
+ var _a, _b, _c, _d;
112
112
  if (field.visible !== false) {
113
113
  const tabConfig = getTabConfig(field.tab || "__main", sheets);
114
114
  if (hiddenTabs.has(tabConfig.label)) {
@@ -124,10 +124,10 @@ export const buildFromConfig = (config, dataUnit) => {
124
124
  requiredFields.push(field.name);
125
125
  }
126
126
  const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
127
- if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum)) {
127
+ if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum) || ((_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.cleanOnCopy)) {
128
128
  cleanOnCopyFields.push(field.name);
129
129
  }
130
- const defaultValue = field.defaultValue == undefined ? (_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.defaultValue : field.defaultValue;
130
+ const defaultValue = field.defaultValue == undefined ? (_d = descriptor.properties) === null || _d === void 0 ? void 0 : _d.defaultValue : field.defaultValue;
131
131
  if (defaultValue) {
132
132
  defaultValues[field.name] = field.defaultValue;
133
133
  }
@@ -187,6 +187,7 @@ export class EzTextInput {
187
187
  this._labelElem.classList.add("input__label--right");
188
188
  }
189
189
  }
190
+ slot.name && ElementIDUtils.addIDInfo(content, slot.name);
190
191
  }
191
192
  this.observeErrorMessage();
192
193
  }
@@ -232,7 +233,7 @@ export class EzTextInput {
232
233
  h("input", { "data-element-id": ElementIDUtils.getInternalIDInfo("input"), onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", class: this.mode === "slim" ? "input--slim" : "", placeholder: this.mode === "slim" && this.label ? this.label : "", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }),
233
234
  h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }),
234
235
  this.canShowError && this.mode != "slim" &&
235
- h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
236
+ h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage, "data-element-id": ElementIDUtils.getInternalIDInfo("message_box") }, this.errorMessage)));
236
237
  }
237
238
  static get is() { return "ez-text-input"; }
238
239
  static get encapsulation() { return "shadow"; }
@@ -1370,9 +1370,13 @@ let EzComboBox$1 = class extends HTMLElement$1 {
1370
1370
  }
1371
1371
  }
1372
1372
  componentDidRender() {
1373
+ var _a;
1373
1374
  if (this._floatingID === undefined) {
1374
1375
  this._listWrapper.remove();
1375
1376
  }
1377
+ (_a = this._optionsList) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".item").forEach((elem) => {
1378
+ ElementIDUtils.addIDInfoIfNotExists(elem, "itemComboBox");
1379
+ });
1376
1380
  }
1377
1381
  componentDidLoad() {
1378
1382
  CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
@@ -2170,7 +2174,7 @@ const buildFromConfig = (config, dataUnit) => {
2170
2174
  }
2171
2175
  });
2172
2176
  (_b = config === null || config === void 0 ? void 0 : config.fields) === null || _b === void 0 ? void 0 : _b.forEach((field) => {
2173
- var _a, _b, _c;
2177
+ var _a, _b, _c, _d;
2174
2178
  if (field.visible !== false) {
2175
2179
  const tabConfig = getTabConfig(field.tab || "__main", sheets);
2176
2180
  if (hiddenTabs.has(tabConfig.label)) {
@@ -2186,10 +2190,10 @@ const buildFromConfig = (config, dataUnit) => {
2186
2190
  requiredFields.push(field.name);
2187
2191
  }
2188
2192
  const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
2189
- if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum)) {
2193
+ if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum) || ((_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.cleanOnCopy)) {
2190
2194
  cleanOnCopyFields.push(field.name);
2191
2195
  }
2192
- const defaultValue = field.defaultValue == undefined ? (_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.defaultValue : field.defaultValue;
2196
+ const defaultValue = field.defaultValue == undefined ? (_d = descriptor.properties) === null || _d === void 0 ? void 0 : _d.defaultValue : field.defaultValue;
2193
2197
  if (defaultValue) {
2194
2198
  defaultValues[field.name] = field.defaultValue;
2195
2199
  }
@@ -120573,6 +120577,7 @@ let EzTextInput$1 = class extends HTMLElement$1 {
120573
120577
  this._labelElem.classList.add("input__label--right");
120574
120578
  }
120575
120579
  }
120580
+ slot.name && ElementIDUtils.addIDInfo(content, slot.name);
120576
120581
  }
120577
120582
  this.observeErrorMessage();
120578
120583
  }
@@ -120613,7 +120618,7 @@ let EzTextInput$1 = class extends HTMLElement$1 {
120613
120618
  return (h(Host, null, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label && this.mode != "slim" ?
120614
120619
  h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
120615
120620
  : null, h("input", { "data-element-id": ElementIDUtils.getInternalIDInfo("input"), onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", class: this.mode === "slim" ? "input--slim" : "", placeholder: this.mode === "slim" && this.label ? this.label : "", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }), h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.canShowError && this.mode != "slim" &&
120616
- h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
120621
+ h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage, "data-element-id": ElementIDUtils.getInternalIDInfo("message_box") }, this.errorMessage)));
120617
120622
  }
120618
120623
  get _hostElement() { return this; }
120619
120624
  static get watchers() { return {
@@ -348,9 +348,13 @@ let EzComboBox = class {
348
348
  }
349
349
  }
350
350
  componentDidRender() {
351
+ var _a;
351
352
  if (this._floatingID === undefined) {
352
353
  this._listWrapper.remove();
353
354
  }
355
+ (_a = this._optionsList) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".item").forEach((elem) => {
356
+ ElementIDUtils.addIDInfoIfNotExists(elem, "itemComboBox");
357
+ });
354
358
  }
355
359
  componentDidLoad() {
356
360
  CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
@@ -114,7 +114,7 @@ const buildFromConfig = (config, dataUnit) => {
114
114
  }
115
115
  });
116
116
  (_b = config === null || config === void 0 ? void 0 : config.fields) === null || _b === void 0 ? void 0 : _b.forEach((field) => {
117
- var _a, _b, _c;
117
+ var _a, _b, _c, _d;
118
118
  if (field.visible !== false) {
119
119
  const tabConfig = getTabConfig(field.tab || "__main", sheets);
120
120
  if (hiddenTabs.has(tabConfig.label)) {
@@ -130,10 +130,10 @@ const buildFromConfig = (config, dataUnit) => {
130
130
  requiredFields.push(field.name);
131
131
  }
132
132
  const cleanOnCopy = field.cleanOnCopy == undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : field.cleanOnCopy;
133
- if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum)) {
133
+ if (cleanOnCopy || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum) || ((_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.cleanOnCopy)) {
134
134
  cleanOnCopyFields.push(field.name);
135
135
  }
136
- const defaultValue = field.defaultValue == undefined ? (_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.defaultValue : field.defaultValue;
136
+ const defaultValue = field.defaultValue == undefined ? (_d = descriptor.properties) === null || _d === void 0 ? void 0 : _d.defaultValue : field.defaultValue;
137
137
  if (defaultValue) {
138
138
  defaultValues[field.name] = field.defaultValue;
139
139
  }
@@ -192,6 +192,7 @@ let EzTextInput = class {
192
192
  this._labelElem.classList.add("input__label--right");
193
193
  }
194
194
  }
195
+ slot.name && ElementIDUtils.addIDInfo(content, slot.name);
195
196
  }
196
197
  this.observeErrorMessage();
197
198
  }
@@ -232,7 +233,7 @@ let EzTextInput = class {
232
233
  return (h(Host, null, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label && this.mode != "slim" ?
233
234
  h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
234
235
  : null, h("input", { "data-element-id": ElementIDUtils.getInternalIDInfo("input"), onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", class: this.mode === "slim" ? "input--slim" : "", placeholder: this.mode === "slim" && this.label ? this.label : "", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }), h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.canShowError && this.mode != "slim" &&
235
- h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
236
+ h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage, "data-element-id": ElementIDUtils.getInternalIDInfo("message_box") }, this.errorMessage)));
236
237
  }
237
238
  get _hostElement() { return getElement(this); }
238
239
  static get watchers() { return {
@@ -1 +1 @@
1
- import{p as e,b as o}from"./p-3c7ea91b.js";(()=>{const o=import.meta.url,s={};return""!==o&&(s.resourcesUrl=new URL(".",o).href),e(s)})().then((e=>o([["p-a34b52f8",[[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-f13f3123",[[1,"ez-dialog",{confirm:[1028],dialogType:[1025,"dialog-type"],message:[1025],opened:[1540],personalizedIconPath:[1025,"personalized-icon-path"],ezTitle:[1025,"ez-title"],show:[64]}]]],["p-123a2bd5",[[1,"ez-filter-input",{label:[1],value:[1537],enabled:[4],errorMessage:[1537,"error-message"],restrict:[1],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-4c061e51",[[6,"ez-grid",{multipleSelection:[4,"multiple-selection"],config:[1040],serverUrl:[1,"server-url"],dataUnit:[16],statusResolver:[16],_paginationInfo:[32],_paginationChangedByKeyboard:[32],setColumnsDef:[64],addColumnMenuItem:[64],setColumnsState:[64],setData:[64],getSelection:[64],getColumnsState:[64],getColumns:[64],quickFilter:[64]},[[0,"ezSelectionChange","onSelectionChange"]]]]],["p-739d60d1",[[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-9def6fd0",[[1,"ez-chip",{label:[513],enabled:[516],removePosition:[513,"remove-position"],mode:[513],value:[1540],setFocus:[64],setBlur:[64]}]]],["p-1cc11468",[[0,"ez-application"]]],["p-3cfefc57",[[1,"ez-card-item",{item:[16]}]]],["p-6d0b9d3c",[[1,"ez-list",{dataSource:[1040],useGroups:[1540,"use-groups"],ezDraggable:[1028,"ez-draggable"],ezSelectable:[1028,"ez-selectable"],itemSlotBuilder:[1040],_listItems:[32],_listGroupItems:[32],clearHistory:[64],scrollToTop:[64],setSelection:[64],getSelection:[64],getList:[64]}]]],["p-f6111077",[[1,"ez-loading-bar",{_showLoading:[32],hide:[64],show:[64]}]]],["p-7c227b86",[[1,"ez-modal",{modalSize:[1,"modal-size"],align:[1],opened:[1028],closeEsc:[4,"close-esc"],closeOutsideClick:[4,"close-outside-click"]}]]],["p-bffae598",[[1,"ez-popover",{autoClose:[516,"auto-close"],top:[1537],left:[1537],bottom:[1537],right:[1537],boxWidth:[513,"box-width"],opened:[1540],innerElement:[1537,"inner-element"],updatePosition:[64],show:[64],hide:[64]}]]],["p-cfcc23e6",[[1,"ez-popup",{size:[1],opened:[1540],useHeader:[516,"use-header"],heightMode:[513,"height-mode"],ezTitle:[1,"ez-title"]}]]],["p-5cb4b43b",[[1,"ez-radio-button",{value:[1544],options:[1040],enabled:[516],label:[513],direction:[1537]}]]],["p-e165c3ef",[[1,"ez-scroller",{direction:[1],locked:[4],activeShadow:[4,"active-shadow"],isFirefox:[32]},[[2,"click","clickListener"],[1,"mousedown","mouseDownHandler"],[1,"mouseup","mouseUpHandler"],[1,"mousemove","mouseMoveHandler"]]]]],["p-482c3dd8",[[1,"ez-toast",{message:[1025],fadeTime:[1026,"fade-time"],useIcon:[1028,"use-icon"],canClose:[1028,"can-close"],show:[64]}]]],["p-04fab1e9",[[0,"ez-view-stack",{show:[64],getSelectedIndex:[64]}]]],["p-51e31ecb",[[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-abcd17e6",[[1,"ez-collapsible-box",{value:[1540],label:[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-ad5fe50b",[[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],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-7e496975",[[1,"ez-date-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-7b906805",[[1,"ez-date-time-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-ea877274",[[1,"ez-time-input",{label:[513],value:[1026],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-1a89d3ff",[[1,"ez-number-input",{label:[1],value:[1538],enabled:[4],errorMessage:[1537,"error-message"],precision:[2],prettyPrecision:[2,"pretty-precision"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-941e9792",[[1,"ez-tabselector",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32]}]]],["p-f2c4e811",[[1,"ez-check",{label:[513],value:[1540],enabled:[1540],indeterminate:[516],mode:[513],getMode:[64],setFocus:[64]}]]],["p-f2627de5",[[1,"ez-text-area",{label:[513],value:[1537],enabled:[516],errorMessage:[1537,"error-message"],rows:[1538],canShowError:[516,"can-show-error"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-a713a1aa",[[1,"ez-upload",{label:[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-01b79946",[[1,"ez-text-edit",{value:[1],styled:[16],_newValue:[32],applyFocusSelect:[64]}]]],["p-bf26ae36",[[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],_preSelection:[32],_visibleOptions:[32],_startLoading:[32],_showLoading:[32],_criteria:[32],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-9d57e44a",[[1,"ez-calendar",{value:[1040],floating:[516],time:[516],showSeconds:[516,"show-seconds"],show:[64],fitVertical:[64],hide:[64]}]]],["p-87ee59e8",[[1,"ez-icon",{size:[513],href:[513],iconName:[513,"icon-name"]}]]],["p-a2e55b33",[[1,"ez-button",{label:[513],enabled:[516],mode:[513],image:[513],iconName:[513,"icon-name"],size:[513],setFocus:[64],setBlur:[64]}]]],["p-52997e83",[[0,"ez-form",{dataUnit:[1040],config:[16],recordsValidator:[16],validate:[64]}]]]],e)));
1
+ import{p as e,b as o}from"./p-3c7ea91b.js";(()=>{const o=import.meta.url,s={};return""!==o&&(s.resourcesUrl=new URL(".",o).href),e(s)})().then((e=>o([["p-a34b52f8",[[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-f13f3123",[[1,"ez-dialog",{confirm:[1028],dialogType:[1025,"dialog-type"],message:[1025],opened:[1540],personalizedIconPath:[1025,"personalized-icon-path"],ezTitle:[1025,"ez-title"],show:[64]}]]],["p-123a2bd5",[[1,"ez-filter-input",{label:[1],value:[1537],enabled:[4],errorMessage:[1537,"error-message"],restrict:[1],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-4c061e51",[[6,"ez-grid",{multipleSelection:[4,"multiple-selection"],config:[1040],serverUrl:[1,"server-url"],dataUnit:[16],statusResolver:[16],_paginationInfo:[32],_paginationChangedByKeyboard:[32],setColumnsDef:[64],addColumnMenuItem:[64],setColumnsState:[64],setData:[64],getSelection:[64],getColumnsState:[64],getColumns:[64],quickFilter:[64]},[[0,"ezSelectionChange","onSelectionChange"]]]]],["p-739d60d1",[[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-9def6fd0",[[1,"ez-chip",{label:[513],enabled:[516],removePosition:[513,"remove-position"],mode:[513],value:[1540],setFocus:[64],setBlur:[64]}]]],["p-1cc11468",[[0,"ez-application"]]],["p-3cfefc57",[[1,"ez-card-item",{item:[16]}]]],["p-6d0b9d3c",[[1,"ez-list",{dataSource:[1040],useGroups:[1540,"use-groups"],ezDraggable:[1028,"ez-draggable"],ezSelectable:[1028,"ez-selectable"],itemSlotBuilder:[1040],_listItems:[32],_listGroupItems:[32],clearHistory:[64],scrollToTop:[64],setSelection:[64],getSelection:[64],getList:[64]}]]],["p-f6111077",[[1,"ez-loading-bar",{_showLoading:[32],hide:[64],show:[64]}]]],["p-7c227b86",[[1,"ez-modal",{modalSize:[1,"modal-size"],align:[1],opened:[1028],closeEsc:[4,"close-esc"],closeOutsideClick:[4,"close-outside-click"]}]]],["p-bffae598",[[1,"ez-popover",{autoClose:[516,"auto-close"],top:[1537],left:[1537],bottom:[1537],right:[1537],boxWidth:[513,"box-width"],opened:[1540],innerElement:[1537,"inner-element"],updatePosition:[64],show:[64],hide:[64]}]]],["p-cfcc23e6",[[1,"ez-popup",{size:[1],opened:[1540],useHeader:[516,"use-header"],heightMode:[513,"height-mode"],ezTitle:[1,"ez-title"]}]]],["p-5cb4b43b",[[1,"ez-radio-button",{value:[1544],options:[1040],enabled:[516],label:[513],direction:[1537]}]]],["p-e165c3ef",[[1,"ez-scroller",{direction:[1],locked:[4],activeShadow:[4,"active-shadow"],isFirefox:[32]},[[2,"click","clickListener"],[1,"mousedown","mouseDownHandler"],[1,"mouseup","mouseUpHandler"],[1,"mousemove","mouseMoveHandler"]]]]],["p-482c3dd8",[[1,"ez-toast",{message:[1025],fadeTime:[1026,"fade-time"],useIcon:[1028,"use-icon"],canClose:[1028,"can-close"],show:[64]}]]],["p-04fab1e9",[[0,"ez-view-stack",{show:[64],getSelectedIndex:[64]}]]],["p-9334a724",[[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-abcd17e6",[[1,"ez-collapsible-box",{value:[1540],label:[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-ad5fe50b",[[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],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-7e496975",[[1,"ez-date-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-7b906805",[[1,"ez-date-time-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-ea877274",[[1,"ez-time-input",{label:[513],value:[1026],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-1a89d3ff",[[1,"ez-number-input",{label:[1],value:[1538],enabled:[4],errorMessage:[1537,"error-message"],precision:[2],prettyPrecision:[2,"pretty-precision"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-941e9792",[[1,"ez-tabselector",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32]}]]],["p-f2c4e811",[[1,"ez-check",{label:[513],value:[1540],enabled:[1540],indeterminate:[516],mode:[513],getMode:[64],setFocus:[64]}]]],["p-f2627de5",[[1,"ez-text-area",{label:[513],value:[1537],enabled:[516],errorMessage:[1537,"error-message"],rows:[1538],canShowError:[516,"can-show-error"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-a713a1aa",[[1,"ez-upload",{label:[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-01b79946",[[1,"ez-text-edit",{value:[1],styled:[16],_newValue:[32],applyFocusSelect:[64]}]]],["p-590d9e91",[[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],_preSelection:[32],_visibleOptions:[32],_startLoading:[32],_showLoading:[32],_criteria:[32],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-9d57e44a",[[1,"ez-calendar",{value:[1040],floating:[516],time:[516],showSeconds:[516,"show-seconds"],show:[64],fitVertical:[64],hide:[64]}]]],["p-87ee59e8",[[1,"ez-icon",{size:[513],href:[513],iconName:[513,"icon-name"]}]]],["p-a2e55b33",[[1,"ez-button",{label:[513],enabled:[516],mode:[513],image:[513],iconName:[513,"icon-name"],size:[513],setFocus:[64],setBlur:[64]}]]],["p-05dbdaeb",[[0,"ez-form",{dataUnit:[1040],config:[16],recordsValidator:[16],validate:[64]}]]]],e)));
@@ -1 +1 @@
1
- import{h as e,r as t,c as i,f as n,H as s,g as l}from"./p-3c7ea91b.js";import{UserInterface as r,Action as a,WaitingChangeException as o,ApplicationContext as c,StringUtils as d,DataUnitAction as h,DataUnit as u,ElementIDUtils as f}from"@sankhyalabs/core";import{C as b}from"./p-b853763b.js";import{A as p}from"./p-0b44cf1c.js";import"./p-e1148f5c.js";class m{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}getSheet(e){return this._sheets.get(e)}getAllSheets(){return this._sheets}addSheet(e){this._sheets.set(e.name,e),this._requiredFields=this._requiredFields.concat(e.requiredFields),this._cleanOnCopyFields=this._cleanOnCopyFields.concat(e.cleanOnCopyFields),this._defaultValues=e.defaultValues}getRequiredFields(){return this._requiredFields}getCleanOnCopyFields(){return this._cleanOnCopyFields}getDefaultValues(){return this._defaultValues}}const v=(e,t)=>!!e.required||(null==t?void 0:t.required);function z(e,t){return"__main"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function y(e,t,i){const n={config:t,descriptor:i};let s=(null==t?void 0:t.group)||i.group;if(s){const t=`group::${s}`;e.has(t)?e.get(t).items.push(n):e.set(t,{label:s,items:[n]})}else e.set((null==t?void 0:t.name)||i.name,n)}const g=({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:i,"data-field-name":t,key:t,enabled:!n}));function _(t,i,n,s=!1){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:!n,label:i,mode:s?b.SWITCH:b.REGULAR,"data-field-name":t,key:t}))}function w(t,i,n,s,l){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!n,label:i,precision:s,prettyPrecision:l,"data-field-name":t,key:t}))}const O=new Map;O.set(r.LONGTEXT,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:t},e("ez-text-area",{enabled:!n,label:i,"data-field-name":t})))),O.set(r.CHECKBOX,(e=>_(e.name,e.label,e.readOnly,!1))),O.set(r.SWITCH,(e=>_(e.name,e.label,e.readOnly,!0))),O.set(r.OPTIONSELECTOR,(({name:t,label:i,readOnly:n,required:s},l)=>{const r=null==l?void 0:l.options;let a;if("string"==typeof r){const e=JSON.parse(r);a=Object.keys(e).map((t=>({value:t,label:e[t]})))}else a=r;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t,options:a}))})),O.set(r.SEARCH,(({name:t,label:i,readOnly:n,required:s})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t})))),O.set(r.FILE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(r.DATE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(r.TIME,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(r.DATETIME,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(r.DECIMALNUMBER,(({name:e,label:t,readOnly:i},n)=>{const s=Number((null==n?void 0:n.precision)||2);return w(e,t,i,s,Number((null==n?void 0:n.prettyPrecision)||s))})),O.set(r.INTEGERNUMBER,(({name:e,label:t,readOnly:i})=>w(e,t,i,0,0)));const E=e=>{const t=e.descriptor,i=Object.assign({},e.config);let n,s;return t&&(i.label||(i.label=t.label),i.name||(i.name=t.name),i.required=v(t,i),i.readOnly=((e,t)=>!!e.readOnly||(null==t?void 0:t.readOnly))(t,i),s=t.properties,n=O.get(t.userInterface)),i.required&&(i.label=`${i.label} (obrigatório) *`),n||(n=g),n(i,s)},A=({source:t})=>"items"in t?e("ez-collapsible-box",{label:t.label,"header-size":"large",key:t.label},t.items.map((e=>E(e)))):E(t),C=({store:t,source:i,dataElementId:n})=>e("div",{class:"dynamic-content ez-box__container","data-element-id":n},e("div",{class:"ez-row ez-padding-vertical--small"},i.items.map((i=>e(A,{store:t,source:i})))));function j(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var x="function"==typeof Symbol&&Symbol.observable||"@@observable",M=function(){return Math.random().toString(36).substring(7).split("").join(".")},R={INIT:"@@redux/INIT"+M(),REPLACE:"@@redux/REPLACE"+M(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+M()}};function k(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function S(e,t,i){var n;if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(j(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(j(1));return i(S)(e,t)}if("function"!=typeof e)throw new Error(j(2));var s=e,l=t,r=[],a=r,o=!1;function c(){a===r&&(a=r.slice())}function d(){if(o)throw new Error(j(3));return l}function h(e){if("function"!=typeof e)throw new Error(j(4));if(o)throw new Error(j(5));var t=!0;return c(),a.push(e),function(){if(t){if(o)throw new Error(j(6));t=!1,c();var i=a.indexOf(e);a.splice(i,1),r=null}}}function u(e){if(!k(e))throw new Error(j(7));if(void 0===e.type)throw new Error(j(8));if(o)throw new Error(j(9));try{o=!0,l=s(l,e)}finally{o=!1}for(var t=r=a,i=0;i<t.length;i++)(0,t[i])();return e}function f(e){if("function"!=typeof e)throw new Error(j(10));s=e,u({type:R.REPLACE})}function b(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(j(11));function i(){e.next&&e.next(d())}return i(),{unsubscribe:t(i)}}})[x]=function(){return this},e}return u({type:R.INIT}),(n={dispatch:u,subscribe:h,getState:d,replaceReducer:f})[x]=b,n}const I={};function N(e=I,t){switch(t.type){case P.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload,currentSheet:void 0});case P.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function D(e){return e.formMetadata}var P;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(P||(P={}));class L{constructor(e){this._invalidFields=new Map,this.onDataUnitEvent=e=>{var t;switch(e.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===(t=this._fields)||void 0===t||t.forEach((e=>{this.updateValue(e.fieldName,e.field)}))}},this._fields=new Map,this._dataUnit=e,this._dataUnit.subscribe(this.onDataUnitEvent)}bind(e){e.forEach((e=>{this.updateBind(e.dataset.fieldName,e)}))}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent)}markInvalid(e){if(this._invalidFields.set(e.name,e),this._fields.has(e.name)){const t=this._fields.get(e.name).field;t.errorMessage||this.updateErrorMessage(e.name,t)}}clearInvalid(){this._invalidFields.clear(),this._fields.forEach((e=>{e.field.errorMessage=""}))}updateValue(e,t){const i=this._fields.get(e);try{i&&(i.listen=!1),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t)}finally{i&&(i.listen=!0)}}updateErrorMessage(e,t){const i=this._invalidFields.get(e);i&&(t.errorMessage=i.message)}getErrorMessage(e){if(this._fields.has(e))return this._fields.get(e).field.errorMessage||null}updateBind(e,t){const i=this._fields.get(e);i&&i.destroy(),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t),this._fields.set(e,T.create(e,t,((e,t)=>this.changeStarted(e,t)),(e=>this.cancelWaitingChange(e)),((e,t)=>this.setFieldValue(e,t)))),this.bindSearchOptionsLoader(e,t),this.applyEzUploadContext(e,t)}changeStarted(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!t.blocking&&null==t.promise){const i=this._fields.get(e);i&&(t.promise=new Promise(((e,t)=>{i.waitingChangePromiseResolve=e,i.waitingChangePromiseReject=t})))}this._dataUnit.startChange(e,t)}cancelWaitingChange(e){if(this._dataUnit.waitingForChange(e)){this._dataUnit.cancelWaitingChange(e);const t=this._fields.get(e);t&&t.rejectWaitingChange(new o("Change canceled",e))}}setFieldValue(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._invalidFields.delete(e),this._dataUnit.setFieldValue(e,t),this._dataUnit.waitingForChange(e)){const t=this._fields.get(e);t&&t.acceptWaitingChange()}}bindSearchOptionsLoader(e,t){if("EZ-SEARCH"===t.nodeName&&null==t.optionLoader){const i=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");i&&(t.optionLoader=t=>i(t,e,this._dataUnit))}}applyEzUploadContext(e,t){var i,n;if("EZ-UPLOAD"===t.nodeName){t.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),t.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const s=this._dataUnit.getField(e),l=null===(i=s.properties)||void 0===i?void 0:i.DESTINATION;l&&(t.requestHeaders={XTRAINF:`{"destination": "${l}"}`}),t.maxFiles=(null===(n=s.properties)||void 0===n?void 0:n.MAX_FILES)||0}}}class T{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(e){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(e),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(e,t,i,n,s){const l=new T;return l.field=t,l.fieldName=e,l.startChangeListener=t=>{l.listen&&i(e,t.detail)},l.field.addEventListener(l.startChangeEventName,l.startChangeListener),l.cancelWaitingChangeListener=()=>{l.listen&&n(e)},l.field.addEventListener(l.cancelWaitingChangeEventName,l.cancelWaitingChangeListener),l.changeListener=t=>{l.listen&&s(e,t.detail)},l.field.addEventListener(l.changeEventName,l.changeListener),l}}let U=class{constructor(e){t(this,e),this.ezReady=i(this,"ezReady",7),this.onDataUnitAction=e=>{e.type===a.METADATA_LOADED&&this.processMetadata()}}validate(){return new Promise(((e,t)=>{var i;const n=this.dataUnit.getModifiedRecords();for(let e=0;e<n.length;e++){const s=n[e],l=[];let r=this.validateRequired(s);if(r&&!r.isValid&&l.push(r),r=null===(i=this.recordsValidator)||void 0===i?void 0:i.validateRecord(this,s),r&&!r.isValid&&l.push(r),l.length>0){this.processValidationResult(l),t();break}}e()}))}observeConfig(){this.processMetadata()}validateRequired(e){const t=D(this._store.getState()),i=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(t.getRequiredFields()),n=[];if(new Set(i).forEach((t=>{const i=e[t];if(null==i||""===i){const e=this._dataBinder.getErrorMessage(t);n.push(e?{name:t,message:e}:{name:t,message:"Essa informação é obrigatória"})}})),n.length>0)return{isValid:!1,invalidFields:n,infoMessage:"Há pelo menos um campo obrigatório não preenchido."}}processValidationResult(e){e.forEach((e=>{const t=e.invalidFields;if(t&&t.forEach((e=>{this._dataBinder.markInvalid(e)})),e.infoMessage&&p.info(e.infoMessage),e.errorMessage){const{errorTitle:t,errorMessage:i}=e;p.error(t,i)}}))}getDynamicContent(){var t;const i=D(this._store.getState());if(!i)return null;const n=(s=null===(t=this._store)||void 0===t?void 0:t.getState()).currentSheet?s.formMetadata.getSheet(s.currentSheet):Array.from(s.formMetadata.getAllSheets().values())[0];var s;if(!n)return null;const l=Array.from(i.getAllSheets().values()),r=[];if(l.length>1){const t=l.map(((e,t)=>({tabKey:e.name,label:e.label,index:t}))),i="selector";r.push(e("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:e=>this._store.dispatch(function(e){return{type:P.CHANGE_TAB,payload:e.tabKey}}(e.detail)),selectedTab:n.name,"data-element-id":i}))}const a=`${d.replaceAccentuatedChars(d.toCamelCase(n.label),!1)}_selectorContainer`;return r.push(e(C,{store:this._store,source:n,dataElementId:a})),r}processMetadata(){if(!this.isStatic()&&this.dataUnit){const e=null!=this.config&&Object.values(this.config).length>0?((e,t)=>{var i,n;const s=new Map,l=new Map,r=[],a=[],o={};null===(i=null==e?void 0:e.tabs)||void 0===i||i.forEach((e=>{l.has(e.label)||!1!==e.visible||l.set(e.label,e)})),null===(n=null==e?void 0:e.fields)||void 0===n||n.forEach((e=>{var i,n,c;if(!1!==e.visible){const d=function(e,t){return("string"==typeof e?Array.from(t.keys()).find((t=>t.label===e)):e)||{label:e,visible:!0}}(e.tab||"__main",s);if(l.has(d.label))return;const h=t.getField(e.name);if(h&&d.visible){s.has(d)||s.set(d,new Map);const t=s.get(d);v(h,e)&&r.push(e.name),((null==e.cleanOnCopy?null===(i=h.properties)||void 0===i?void 0:i.cleanOnCopy:e.cleanOnCopy)||(null===(n=h.properties)||void 0===n?void 0:n.autoNum))&&a.push(e.name),(null==e.defaultValue?null===(c=h.properties)||void 0===c?void 0:c.defaultValue:e.defaultValue)&&(o[e.name]=e.defaultValue),y(t,e,h)}}}));const c=new m;return Array.from(s.entries()).sort(z).forEach((([e,t])=>{c.addSheet({label:"__main"===e.label?"Principal":e.label,name:e.label,items:Array.from(t.values()),requiredFields:r,cleanOnCopyFields:a,defaultValues:o})})),c})(this.config,this.dataUnit):(()=>{var e,t;const i=this.dataUnit.metadata,n=new m;if(i){const s=null===(e=i.fields)||void 0===e?void 0:e.filter((e=>!1!==e.visible)),l=new Map;null===(t=null==i?void 0:i.fields)||void 0===t||t.forEach((e=>{!1!==e.visible&&y(l,null,e)}));let r={};s.filter((e=>e.defaultValue)).map((e=>r[e.name]=e.defaultValue)),n.addSheet({label:i.label,name:i.name,items:Array.from(l.values()),requiredFields:s.filter((e=>e.required)).map((e=>e.name)),cleanOnCopyFields:s.filter((e=>{var t,i;return(null===(t=e.properties)||void 0===t?void 0:t.cleanOnCopy)||(null===(i=e.properties)||void 0===i?void 0:i.autoNum)})).map((e=>e.name)),defaultValues:r})}return n})();this._store.dispatch({type:P.METADATA_LOADED,payload:e})}}isStatic(){var e;return(null===(e=this._staticFields)||void 0===e?void 0:e.length)>0}interceptAction(e){if(e.type===a.RECORDS_COPIED){const t=D(this._store.getState()).getCleanOnCopyFields();if(t)return new h(a.RECORDS_COPIED,e.payload.map((e=>{const i=Object.assign({},e);return t.forEach((e=>delete i[e])),i})))}if(e.type===a.SAVING_DATA)return new Promise((t=>{this.validate().then((()=>t(e))).catch((()=>{}))}));if(e.type===a.RECORDS_ADDED){const t=D(this._store.getState()).getDefaultValues();if(t)return new h(a.RECORDS_ADDED,e.payload.map((e=>{const i=Object.assign({},e);for(const e in t){const n="formattedValue"in t[e]?t[e].formattedValue:t[e].value,s=null!=n?n:t[e],l="function"==typeof s?s():s;i[e]=this.dataUnit.valueFromString(e,l)}return i})))}return e}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new u("ez-form")),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new L(this.dataUnit),this._store=S(N),this._store.subscribe((()=>n(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),f.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]"))),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this.dataUnit.removeInterceptor(this),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(e){return e&&e.forEach((e=>e[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=d.toCamelCase(e.label))),e}render(){return e(s,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return l(this)}static get watchers(){return{config:["observeConfig"]}}};U.style="ez-form{display:flex;flex-direction:column;width:100%}.dynamic-content ez-collapsible-box{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";export{U as ez_form}
1
+ import{h as e,r as t,c as i,f as n,H as s,g as l}from"./p-3c7ea91b.js";import{UserInterface as r,Action as a,WaitingChangeException as o,ApplicationContext as c,StringUtils as d,DataUnitAction as h,DataUnit as u,ElementIDUtils as f}from"@sankhyalabs/core";import{C as b}from"./p-b853763b.js";import{A as p}from"./p-0b44cf1c.js";import"./p-e1148f5c.js";class m{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}getSheet(e){return this._sheets.get(e)}getAllSheets(){return this._sheets}addSheet(e){this._sheets.set(e.name,e),this._requiredFields=this._requiredFields.concat(e.requiredFields),this._cleanOnCopyFields=this._cleanOnCopyFields.concat(e.cleanOnCopyFields),this._defaultValues=e.defaultValues}getRequiredFields(){return this._requiredFields}getCleanOnCopyFields(){return this._cleanOnCopyFields}getDefaultValues(){return this._defaultValues}}const v=(e,t)=>!!e.required||(null==t?void 0:t.required);function z(e,t){return"__main"==e[0].label?-1:(e[0].order||1e4)-(t[0].order||1e4)}function y(e,t,i){const n={config:t,descriptor:i};let s=(null==t?void 0:t.group)||i.group;if(s){const t=`group::${s}`;e.has(t)?e.get(t).items.push(n):e.set(t,{label:s,items:[n]})}else e.set((null==t?void 0:t.name)||i.name,n)}const g=({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-text-input",{label:i,"data-field-name":t,key:t,enabled:!n}));function _(t,i,n,s=!1){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:!n,label:i,mode:s?b.SWITCH:b.REGULAR,"data-field-name":t,key:t}))}function w(t,i,n,s,l){return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-number-input",{enabled:!n,label:i,precision:s,prettyPrecision:l,"data-field-name":t,key:t}))}const O=new Map;O.set(r.LONGTEXT,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small",key:t},e("ez-text-area",{enabled:!n,label:i,"data-field-name":t})))),O.set(r.CHECKBOX,(e=>_(e.name,e.label,e.readOnly,!1))),O.set(r.SWITCH,(e=>_(e.name,e.label,e.readOnly,!0))),O.set(r.OPTIONSELECTOR,(({name:t,label:i,readOnly:n,required:s},l)=>{const r=null==l?void 0:l.options;let a;if("string"==typeof r){const e=JSON.parse(r);a=Object.keys(e).map((t=>({value:t,label:e[t]})))}else a=r;return e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-combo-box",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t,options:a}))})),O.set(r.SEARCH,(({name:t,label:i,readOnly:n,required:s})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-search",{enabled:!n,suppressEmptyOption:s,label:i,"data-field-name":t,key:t})))),O.set(r.FILE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-padding-horizontal--small"},e("ez-upload",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(r.DATE,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(r.TIME,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(r.DATETIME,(({name:t,label:i,readOnly:n})=>e("div",{class:"ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small"},e("ez-date-time-input",{enabled:!n,label:i,"data-field-name":t,key:t})))),O.set(r.DECIMALNUMBER,(({name:e,label:t,readOnly:i},n)=>{const s=Number((null==n?void 0:n.precision)||2);return w(e,t,i,s,Number((null==n?void 0:n.prettyPrecision)||s))})),O.set(r.INTEGERNUMBER,(({name:e,label:t,readOnly:i})=>w(e,t,i,0,0)));const E=e=>{const t=e.descriptor,i=Object.assign({},e.config);let n,s;return t&&(i.label||(i.label=t.label),i.name||(i.name=t.name),i.required=v(t,i),i.readOnly=((e,t)=>!!e.readOnly||(null==t?void 0:t.readOnly))(t,i),s=t.properties,n=O.get(t.userInterface)),i.required&&(i.label=`${i.label} (obrigatório) *`),n||(n=g),n(i,s)},A=({source:t})=>"items"in t?e("ez-collapsible-box",{label:t.label,"header-size":"large",key:t.label},t.items.map((e=>E(e)))):E(t),C=({store:t,source:i,dataElementId:n})=>e("div",{class:"dynamic-content ez-box__container","data-element-id":n},e("div",{class:"ez-row ez-padding-vertical--small"},i.items.map((i=>e(A,{store:t,source:i})))));function j(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var x="function"==typeof Symbol&&Symbol.observable||"@@observable",M=function(){return Math.random().toString(36).substring(7).split("").join(".")},R={INIT:"@@redux/INIT"+M(),REPLACE:"@@redux/REPLACE"+M(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+M()}};function k(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function S(e,t,i){var n;if("function"==typeof t&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(j(0));if("function"==typeof t&&void 0===i&&(i=t,t=void 0),void 0!==i){if("function"!=typeof i)throw new Error(j(1));return i(S)(e,t)}if("function"!=typeof e)throw new Error(j(2));var s=e,l=t,r=[],a=r,o=!1;function c(){a===r&&(a=r.slice())}function d(){if(o)throw new Error(j(3));return l}function h(e){if("function"!=typeof e)throw new Error(j(4));if(o)throw new Error(j(5));var t=!0;return c(),a.push(e),function(){if(t){if(o)throw new Error(j(6));t=!1,c();var i=a.indexOf(e);a.splice(i,1),r=null}}}function u(e){if(!k(e))throw new Error(j(7));if(void 0===e.type)throw new Error(j(8));if(o)throw new Error(j(9));try{o=!0,l=s(l,e)}finally{o=!1}for(var t=r=a,i=0;i<t.length;i++)(0,t[i])();return e}function f(e){if("function"!=typeof e)throw new Error(j(10));s=e,u({type:R.REPLACE})}function b(){var e,t=h;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(j(11));function i(){e.next&&e.next(d())}return i(),{unsubscribe:t(i)}}})[x]=function(){return this},e}return u({type:R.INIT}),(n={dispatch:u,subscribe:h,getState:d,replaceReducer:f})[x]=b,n}const I={};function N(e=I,t){switch(t.type){case P.METADATA_LOADED:return Object.assign(Object.assign({},e),{formMetadata:t.payload,currentSheet:void 0});case P.CHANGE_TAB:return Object.assign(Object.assign({},e),{currentSheet:t.payload});default:return e}}function D(e){return e.formMetadata}var P;!function(e){e.METADATA_LOADED="FORM/METADATA_LOADED",e.CHANGE_TAB="FORM/CHANGE_TAB"}(P||(P={}));class L{constructor(e){this._invalidFields=new Map,this.onDataUnitEvent=e=>{var t;switch(e.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===(t=this._fields)||void 0===t||t.forEach((e=>{this.updateValue(e.fieldName,e.field)}))}},this._fields=new Map,this._dataUnit=e,this._dataUnit.subscribe(this.onDataUnitEvent)}bind(e){e.forEach((e=>{this.updateBind(e.dataset.fieldName,e)}))}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent)}markInvalid(e){if(this._invalidFields.set(e.name,e),this._fields.has(e.name)){const t=this._fields.get(e.name).field;t.errorMessage||this.updateErrorMessage(e.name,t)}}clearInvalid(){this._invalidFields.clear(),this._fields.forEach((e=>{e.field.errorMessage=""}))}updateValue(e,t){const i=this._fields.get(e);try{i&&(i.listen=!1),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t)}finally{i&&(i.listen=!0)}}updateErrorMessage(e,t){const i=this._invalidFields.get(e);i&&(t.errorMessage=i.message)}getErrorMessage(e){if(this._fields.has(e))return this._fields.get(e).field.errorMessage||null}updateBind(e,t){const i=this._fields.get(e);i&&i.destroy(),t.value=this._dataUnit.getFieldValue(e),this.updateErrorMessage(e,t),this._fields.set(e,T.create(e,t,((e,t)=>this.changeStarted(e,t)),(e=>this.cancelWaitingChange(e)),((e,t)=>this.setFieldValue(e,t)))),this.bindSearchOptionsLoader(e,t),this.applyEzUploadContext(e,t)}changeStarted(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!t.blocking&&null==t.promise){const i=this._fields.get(e);i&&(t.promise=new Promise(((e,t)=>{i.waitingChangePromiseResolve=e,i.waitingChangePromiseReject=t})))}this._dataUnit.startChange(e,t)}cancelWaitingChange(e){if(this._dataUnit.waitingForChange(e)){this._dataUnit.cancelWaitingChange(e);const t=this._fields.get(e);t&&t.rejectWaitingChange(new o("Change canceled",e))}}setFieldValue(e,t){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._invalidFields.delete(e),this._dataUnit.setFieldValue(e,t),this._dataUnit.waitingForChange(e)){const t=this._fields.get(e);t&&t.acceptWaitingChange()}}bindSearchOptionsLoader(e,t){if("EZ-SEARCH"===t.nodeName&&null==t.optionLoader){const i=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");i&&(t.optionLoader=t=>i(t,e,this._dataUnit))}}applyEzUploadContext(e,t){var i,n;if("EZ-UPLOAD"===t.nodeName){t.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),t.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const s=this._dataUnit.getField(e),l=null===(i=s.properties)||void 0===i?void 0:i.DESTINATION;l&&(t.requestHeaders={XTRAINF:`{"destination": "${l}"}`}),t.maxFiles=(null===(n=s.properties)||void 0===n?void 0:n.MAX_FILES)||0}}}class T{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(e){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(e),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(e,t,i,n,s){const l=new T;return l.field=t,l.fieldName=e,l.startChangeListener=t=>{l.listen&&i(e,t.detail)},l.field.addEventListener(l.startChangeEventName,l.startChangeListener),l.cancelWaitingChangeListener=()=>{l.listen&&n(e)},l.field.addEventListener(l.cancelWaitingChangeEventName,l.cancelWaitingChangeListener),l.changeListener=t=>{l.listen&&s(e,t.detail)},l.field.addEventListener(l.changeEventName,l.changeListener),l}}let U=class{constructor(e){t(this,e),this.ezReady=i(this,"ezReady",7),this.onDataUnitAction=e=>{e.type===a.METADATA_LOADED&&this.processMetadata()}}validate(){return new Promise(((e,t)=>{var i;const n=this.dataUnit.getModifiedRecords();for(let e=0;e<n.length;e++){const s=n[e],l=[];let r=this.validateRequired(s);if(r&&!r.isValid&&l.push(r),r=null===(i=this.recordsValidator)||void 0===i?void 0:i.validateRecord(this,s),r&&!r.isValid&&l.push(r),l.length>0){this.processValidationResult(l),t();break}}e()}))}observeConfig(){this.processMetadata()}validateRequired(e){const t=D(this._store.getState()),i=this._staticFields.filter((e=>e.dataset.required)).map((e=>e.dataset.fieldName)).concat(t.getRequiredFields()),n=[];if(new Set(i).forEach((t=>{const i=e[t];if(null==i||""===i){const e=this._dataBinder.getErrorMessage(t);n.push(e?{name:t,message:e}:{name:t,message:"Essa informação é obrigatória"})}})),n.length>0)return{isValid:!1,invalidFields:n,infoMessage:"Há pelo menos um campo obrigatório não preenchido."}}processValidationResult(e){e.forEach((e=>{const t=e.invalidFields;if(t&&t.forEach((e=>{this._dataBinder.markInvalid(e)})),e.infoMessage&&p.info(e.infoMessage),e.errorMessage){const{errorTitle:t,errorMessage:i}=e;p.error(t,i)}}))}getDynamicContent(){var t;const i=D(this._store.getState());if(!i)return null;const n=(s=null===(t=this._store)||void 0===t?void 0:t.getState()).currentSheet?s.formMetadata.getSheet(s.currentSheet):Array.from(s.formMetadata.getAllSheets().values())[0];var s;if(!n)return null;const l=Array.from(i.getAllSheets().values()),r=[];if(l.length>1){const t=l.map(((e,t)=>({tabKey:e.name,label:e.label,index:t}))),i="selector";r.push(e("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:e=>this._store.dispatch(function(e){return{type:P.CHANGE_TAB,payload:e.tabKey}}(e.detail)),selectedTab:n.name,"data-element-id":i}))}const a=`${d.replaceAccentuatedChars(d.toCamelCase(n.label),!1)}_selectorContainer`;return r.push(e(C,{store:this._store,source:n,dataElementId:a})),r}processMetadata(){if(!this.isStatic()&&this.dataUnit){const e=null!=this.config&&Object.values(this.config).length>0?((e,t)=>{var i,n;const s=new Map,l=new Map,r=[],a=[],o={};null===(i=null==e?void 0:e.tabs)||void 0===i||i.forEach((e=>{l.has(e.label)||!1!==e.visible||l.set(e.label,e)})),null===(n=null==e?void 0:e.fields)||void 0===n||n.forEach((e=>{var i,n,c,d;if(!1!==e.visible){const h=function(e,t){return("string"==typeof e?Array.from(t.keys()).find((t=>t.label===e)):e)||{label:e,visible:!0}}(e.tab||"__main",s);if(l.has(h.label))return;const u=t.getField(e.name);if(u&&h.visible){s.has(h)||s.set(h,new Map);const t=s.get(h);v(u,e)&&r.push(e.name),((null==e.cleanOnCopy?null===(i=u.properties)||void 0===i?void 0:i.cleanOnCopy:e.cleanOnCopy)||(null===(n=u.properties)||void 0===n?void 0:n.autoNum)||(null===(c=u.properties)||void 0===c?void 0:c.cleanOnCopy))&&a.push(e.name),(null==e.defaultValue?null===(d=u.properties)||void 0===d?void 0:d.defaultValue:e.defaultValue)&&(o[e.name]=e.defaultValue),y(t,e,u)}}}));const c=new m;return Array.from(s.entries()).sort(z).forEach((([e,t])=>{c.addSheet({label:"__main"===e.label?"Principal":e.label,name:e.label,items:Array.from(t.values()),requiredFields:r,cleanOnCopyFields:a,defaultValues:o})})),c})(this.config,this.dataUnit):(()=>{var e,t;const i=this.dataUnit.metadata,n=new m;if(i){const s=null===(e=i.fields)||void 0===e?void 0:e.filter((e=>!1!==e.visible)),l=new Map;null===(t=null==i?void 0:i.fields)||void 0===t||t.forEach((e=>{!1!==e.visible&&y(l,null,e)}));let r={};s.filter((e=>e.defaultValue)).map((e=>r[e.name]=e.defaultValue)),n.addSheet({label:i.label,name:i.name,items:Array.from(l.values()),requiredFields:s.filter((e=>e.required)).map((e=>e.name)),cleanOnCopyFields:s.filter((e=>{var t,i;return(null===(t=e.properties)||void 0===t?void 0:t.cleanOnCopy)||(null===(i=e.properties)||void 0===i?void 0:i.autoNum)})).map((e=>e.name)),defaultValues:r})}return n})();this._store.dispatch({type:P.METADATA_LOADED,payload:e})}}isStatic(){var e;return(null===(e=this._staticFields)||void 0===e?void 0:e.length)>0}interceptAction(e){if(e.type===a.RECORDS_COPIED){const t=D(this._store.getState()).getCleanOnCopyFields();if(t)return new h(a.RECORDS_COPIED,e.payload.map((e=>{const i=Object.assign({},e);return t.forEach((e=>delete i[e])),i})))}if(e.type===a.SAVING_DATA)return new Promise((t=>{this.validate().then((()=>t(e))).catch((()=>{}))}));if(e.type===a.RECORDS_ADDED){const t=D(this._store.getState()).getDefaultValues();if(t)return new h(a.RECORDS_ADDED,e.payload.map((e=>{const i=Object.assign({},e);for(const e in t){const n="formattedValue"in t[e]?t[e].formattedValue:t[e].value,s=null!=n?n:t[e],l="function"==typeof s?s():s;i[e]=this.dataUnit.valueFromString(e,l)}return i})))}return e}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new u("ez-form")),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new L(this.dataUnit),this._store=S(N),this._store.subscribe((()=>n(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),f.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]"))),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this.dataUnit.removeInterceptor(this),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(e){return e&&e.forEach((e=>e[f.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=d.toCamelCase(e.label))),e}render(){return e(s,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return l(this)}static get watchers(){return{config:["observeConfig"]}}};U.style="ez-form{display:flex;flex-direction:column;width:100%}.dynamic-content ez-collapsible-box{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";export{U as ez_form}
@@ -0,0 +1 @@
1
+ import{r as o,c as i,h as t,H as e,g as s}from"./p-3c7ea91b.js";import{FloatingManager as r,ElementIDUtils as a}from"@sankhyalabs/core";import{A as l}from"./p-0b44cf1c.js";import{C as n}from"./p-4a5e37a7.js";import"./p-e1148f5c.js";import"./p-b853763b.js";let h=class{constructor(t){o(this,t),this.ezChange=i(this,"ezChange",7),this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._textEmptyList="Nenhum resultado encontrado",this._startLoading=!1,this._showLoading=!0,this.enabled=!0,this.showSelectedValue=!1,this.showOptionValue=!1,this.suppressSearch=!1,this.suppressEmptyOption=!1,this.canShowError=!0,this.mode="regular"}observeErrorMessage(){var o;this._textInput&&(this._textInput.errorMessage=this.errorMessage,(null===(o=this.errorMessage)||void 0===o?void 0:o.trim())||this.setInputValue())}observeValue(o,i){var t,e,s,r;if(this._textInput&&o!=i){const a=this.getSelectedOption(o),l=this.getSelectedOption(i),n=this.getSelectedOption(this.value);(null===(t=null==n?void 0:n.value)||void 0===t?void 0:t.toString())!=(null===(e=null==a?void 0:a.value)||void 0===e?void 0:e.toString())&&(this.value=a),(null===(s=null==a?void 0:a.value)||void 0===s?void 0:s.toString())!==(null===(r=null==l?void 0:l.value)||void 0===r?void 0:r.toString())&&(this.setInputValue(),this.ezChange.emit(null===a?void 0:a)),this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}}async setFocus(){this._textInput.setFocus()}async setBlur(){this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}getText(){let o="";const i=this.getSelectedOption(this.value);if(i&&(o=this.showSelectedValue?`${i.value} - ${i.label}`:i.label),null!=o)return String(o).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"')}getSelectedOption(o){return"string"==typeof o||o instanceof String?this._visibleOptions.find((i=>i.value===o)):o}updateVisibleOptions(){let o=this._source||[];if(!this.searchMode&&this._criteria){const i=this._criteria.toUpperCase();o=o.filter((o=>o.label.toLocaleUpperCase().indexOf(i)>-1))}this._visibleOptions=this.suppressEmptyOption?o:[{value:void 0,label:""}].concat(o),this._maxWidthValue=this.getMaxWidthValue()}getMaxWidthValue(){var o;if(this.showOptionValue){const i=[];return null===(o=this._visibleOptions)||void 0===o||o.forEach((o=>{const t=this.getWidthValue(o.value);i.includes(t)||i.push(t)})),i.length>1?Math.max(...i):0}return 0}getWidthValue(o){if(null!=this._itemValueBasis){const i=this._itemValueBasis;if(null!=o)return i.innerHTML=o,i.clientWidth>0?i.clientWidth+2:0;i.innerHTML=""}return 0}buildItem(o,i){const e=this.showOptionValue&&this._maxWidthValue>0?`${this._maxWidthValue}px`:"";return t("li",{class:i===this._preSelection?"item preselected":"item",id:`item_${o.value}`,onMouseDown:()=>this.selectOption(o),onMouseOver:()=>this._preSelection=i},this.showOptionValue?t("span",{class:"item__value",title:o.value,style:{width:e,minWidth:e,maxWidth:e}},o.value):void 0,t("span",{class:"item__label "+(this.showOptionValue?"item__label--bold":""),title:o.label},o.label))}showOptions(){this.enabled&&(this._floatingID=r.float(this._listWrapper,this._listContainer,{autoClose:!0,top:this.errorMessage||!this.canShowError||"slim"===this.mode?"6px":"-13px"}),this.setFocus(),window.requestAnimationFrame((()=>{this._listWrapper.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})})))}hideOptions(){void 0!==this._floatingID&&r.close(this._floatingID),this._floatingID=void 0}isOptionsVisible(){return void 0!==this._floatingID&&r.isFloating(this._floatingID)}nextOption(){this.searchMode&&!this.isOptionsVisible()||(this.showOptions(),this._preSelection=void 0===this._preSelection?0:Math.min(this._preSelection+1,this._visibleOptions.length-1),this.scrollToOption(this._visibleOptions[this._preSelection],!0))}previousOption(){this._preSelection=void 0===this._preSelection?0:Math.max(this._preSelection-1,0),this.scrollToOption(this._visibleOptions[this._preSelection],!1)}scrollToOption(o,i){window.requestAnimationFrame((()=>{const t=(null==o?void 0:o.value)?this._optionsList.querySelector(`li#item_${o.value}`):void 0;if(t){const o=t.parentElement,e=o.getBoundingClientRect(),s=t.getBoundingClientRect();i&&s.bottom>e.bottom?o.scrollTop=s.height*(this._preSelection-3):!i&&s.top<e.top&&(o.scrollTop=s.height*this._preSelection)}}))}selectCurrentOption(){void 0!==this._preSelection?(this.selectOption(this._visibleOptions[this._preSelection]),this._preSelection=void 0):this.controlListWithOnlyOne()}updateSource(o){this._startLoading=!1,o instanceof Promise?(this._showLoading=!0,o.then((o=>{this._showLoading=!1,this.updateSource(o)})).catch((()=>this._showLoading=!1)),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(o)?(this._source=o,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1,this.controlEmptySearch())):this.selectOption(o))}clearSource(){this._source=[],this.updateVisibleOptions()}selectOption(o){var i,t;const e=this.getSelectedOption(this.value);(null===(i=null==e?void 0:e.value)||void 0===i?void 0:i.toString())!==(null===(t=null==o?void 0:o.value)||void 0===t?void 0:t.toString())?this.value=(null==o?void 0:o.value)?o:void 0:(this.setInputValue(),this.hideOptions()),this.searchMode&&(this._visibleOptions=[]),this.searchMode&&(this._visibleOptions=[])}loadOptions(o,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:o,argument:i}):this.options)}cancelPreselection(){!this._textInput.value&&this.value?this.selectOption(void 0):this.setInputValue()}setInputValue(o=!0){const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,o&&(this.errorMessage=""))}clearSearch(){this.value=null}controlListWithOnlyOne(){if(this.searchMode){const o=this._visibleOptions;1===(null==o?void 0:o.length)&&this.selectOption(o[0])}}controlEmptySearch(){var o;this.searchMode&&((null===(o=this._visibleOptions)||void 0===o?void 0:o.length)?this.controlListWithOnlyOne():(this.clearSearch(),l.info(this._textEmptyList)))}componentWillLoad(){if(void 0===this.options){this.options=[];const o=this.el.querySelectorAll("option");o&&o.forEach((o=>{let i=o.innerText,t=o.getAttribute("value");t||(t=i),this.options.push({label:i,value:t}),o.hidden=!0}))}this.searchMode?this.updateSource([]):this.loadOptions(c.PRELOAD)}componentDidRender(){var o;void 0===this._floatingID&&this._listWrapper.remove(),null===(o=this._optionsList)||void 0===o||o.querySelectorAll(".item").forEach((o=>{a.addIDInfoIfNotExists(o,"itemComboBox")}))}componentDidLoad(){n.applyVarsTextInput(this.el,this._textInput),this.setInputValue(!1)}handlerIconClick(){this.searchMode?this.loadOptions(c.ADVANCED):this.showOptions()}onTextInputChangeHandler(o){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(o)}),this._deboucingTime));const t=null===(i=o.target.value)||void 0===i?void 0:i.trim(),e=Number(t||void 0);this._criteria||(this._textInput.value=o.data||t),this._criteria=t,t&&(!isNaN(e)||t.length>=this._limitCharsToSearch)?(this.searchMode?(this._showLoading=!0,this.clearSource(),this._changeDeboucingTimeout=window.setTimeout((()=>{this.loadOptions(c.PREDICTIVE,isNaN(e)?t:e.toString())}),this._deboucingTime)):this.updateVisibleOptions(),this.showOptions()):this.hideOptions()}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=void 0)}onTextInputClickHandler(){this.searchMode||this.showOptions()}keyDownHandler(o){switch(this._tabPressed=!1,o.ctrlKey&&("f"!==o.key&&"F"!==o.key||(this.loadOptions(c.ADVANCED),o.stopPropagation(),o.stopImmediatePropagation(),o.preventDefault())),o.key){case"ArrowDown":this.nextOption();break;case"ArrowUp":this.previousOption();break;case"Enter":this.selectCurrentOption();break;case"Escape":this.cancelPreselection();break;case"Tab":this._tabPressed=!0,this.controlListWithOnlyOne()}}onTextInputFocusOutHandler(){this.cancelPreselection()}render(){var o;return a.addIDInfoIfNotExists(this.el,"input"),t(e,null,t("ez-text-input",{"data-element-id":a.getInternalIDInfo("textInput"),class:this.suppressSearch?"suppressed-search-input":"",ref:o=>this._textInput=o,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:o=>this.onTextInputChangeHandler(o),onClick:()=>this.onTextInputClickHandler(),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:o=>this.keyDownHandler(o),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode},t("button",{class:"btn",slot:this.searchMode?"leftIcon":"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},t("ez-icon",{iconName:this.searchMode?"search":"chevron-down"})),this.searchMode&&(null===(o=this._textInput)||void 0===o?void 0:o.value)&&(this._criteria||this.value)?t("button",{class:"btn btn__close",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.clearSearch()},t("ez-icon",{iconName:"close"})):void 0),t("section",{class:"list-container",ref:o=>this._listContainer=o},t("div",{class:"list-wrapper",ref:o=>this._listWrapper=o},t("div",{class:"list-options",ref:o=>this._optionsList=o},0===this._visibleOptions.length&&t("div",{class:"message"},!this._showLoading&&t("span",{class:"message__no-result"},this._textEmptyList),this._showLoading&&t("div",{class:"message__loading"})),this.showOptionValue?t("span",{class:"item__value item__value--hidden",ref:o=>this._itemValueBasis=o}):void 0,this._visibleOptions.length>0&&this._visibleOptions.map(((o,i)=>this.buildItem(o,i)))))))}get el(){return s(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"]}}};var c;!function(o){o.ADVANCED="ADVANCED",o.PRELOAD="PRELOAD",o.PREDICTIVE="PREDICTIVE"}(c||(c={})),h.style=":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box--line-height:calc(var(--text--medium, 14px) + 4px);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium) + 4px);--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__list-scrollbar--background-color-primary:var(--scrollbar--primary, #2B3A54);--ez-combo-box__list-scrollbar--background-color-secondary:var(--scrollbar--secondary, #E5EAF0);--ez-combo-box__list-scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__list-scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small) + 9px);background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto;scrollbar-width:thin;gap:3px;scrollbar-color:var(--ez-combo-box__list-scrollbar--background-color-primary) var(--ez-combo-box__list-scrollbar--background-color-secondary)}.list-options::-webkit-scrollbar-track{background-color:var(--ez-combo-box__list-scrollbar--background-color-secondary);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__list-scrollbar--background-color-primary);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar{background-color:var(--ez-combo-box__list-scrollbar--background-color-secondary);width:var(--ez-combo-box__list-scrollbar--width);max-width:var(--ez-combo-box__list-scrollbar--width);min-width:var(--ez-combo-box__list-scrollbar--width)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size);line-height:var(--ez-combo-box--line-height)}.item__label{font-weight:var(--ez-combo-box--font-weight--medium)}.item__label--bold{font-weight:var(--ez-combo-box--font-weight--large)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large)}.item__value--hidden{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:var(--ez-combo-box__list-height)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:14px;height:14px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";export{h as ez_combo_box}
@@ -0,0 +1 @@
1
+ import{r as t,c as i,h as e,H as o,g as r}from"./p-3c7ea91b.js";import{MaskFormatter as n,ElementIDUtils as a}from"@sankhyalabs/core";let l=class{constructor(e){t(this,e),this.ezChange=i(this,"ezChange",7),this.enabled=!0,this.canShowError=!0,this.mode="regular",this.noBorder=!1}observeErrorMessage(){this._inputElem&&this.isInvalid().then((t=>{var i,e;t?(this._inputElem.classList.add("hasError"),null===(i=this._messageBoxElem)||void 0===i||i.classList.add("hasError")):(this._inputElem.classList.remove("hasError"),null===(e=this._messageBoxElem)||void 0===e||e.classList.remove("hasError"))}))}observeMask(){this.mask&&(null==this._maskFormatter?this._maskFormatter=new n(this.mask):this._maskFormatter.mask=this.mask)}observeValue(t,i){this._inputElem&&t!=i&&(this._inputElem.value=this.value||"",this.handleChange(),this.adjustFloatingLabel(),this.isSlaveMode()||(this.errorMessage="",this.ezChange.emit(this.value)))}adjustFloatingLabel(){if(this.label&&this._labelElem){this._inputElem&&!this._inputElem.classList.contains("input--with--label")&&this._inputElem.classList.add("input--with--label");const t=this.value&&this.value.toString().length>0,i=this._labelElem.classList.contains("input__label--floated");t||this.isFocused()?i||this._labelElem.classList.add("input__label--floated"):i&&this._labelElem.classList.remove("input__label--floated")}}isFocused(){return null!==this._hostElement.shadowRoot.activeElement}isSlaveMode(){var t,i;return"true"===(null===(i=null===(t=this._hostElement)||void 0===t?void 0:t.dataset)||void 0===i?void 0:i.slaveMode)}adjustColorContentSlot(t=""){this._contentLeftSlot&&(this._contentLeftSlot.style.color=t)}adjustBorderInput(){this.noBorder&&this._inputElem.classList.add("input__slim--noborder")}async setFocus(){this._inputElem.focus()}async setBlur(){this._inputElem.blur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}handleFocusout(){const t=this._inputElem.value;if(t&&this._maskFormatter)try{this._inputElem.value=this._maskFormatter.format(t)}catch(t){this.errorMessage=t.message}this.controlChangeValue(),this.adjustFloatingLabel(),this.adjustColorContentSlot()}isValidValue(t){return!this.restrict||Array.from(t).reduce(((t,i)=>t&&this.restrict.indexOf(i)>-1),!0)}controlChangeValue(){this._inputElem&&(this.value||"")!==this._inputElem.value&&(this.value=this._inputElem.value)}handleChange(){if(!this._inputElem)return;const t=this._inputElem.value;this.isValidValue(t)?this._lastValidValue=t:this._inputElem.value=null==this._lastValidValue?"":this._lastValidValue,this.controlChangeValue()}handleSlotChange(t){const i=t.target,e=i.assignedElements()[0];e&&(e.style.position="absolute",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",e.style.overflow="hidden",e.style.top="0px",e.style.width="var(--ez-text-input__icon--width)",e.style.height="slim"!=this.mode?"var(--ez-text-input--height)":"var(--ez-text-input--height--slim)","leftIcon"==i.name?(e.style.left="0px",e.style.borderRadius="var(--ez-text-input--border-radius) 0 0 var(--ez-text-input--border-radius)",this._inputElem.classList.add("icon--left"),this._labelElem&&this._labelElem.classList.add("input__label--left"),this._contentLeftSlot=e):"rightIcon"==i.name&&(e.style.right="0px",e.style.borderRadius="0 var(--ez-text-input--border-radius) var(--ez-text-input--border-radius) 0",this._inputElem.classList.add("icon--right"),this._labelElem&&this._labelElem.classList.add("input__label--right")),i.name&&a.addIDInfo(e,i.name)),this.observeErrorMessage()}doFocus(){this.label&&this._labelElem&&!this._labelElem.classList.contains("input__label--floated")&&this._labelElem.classList.add("input__label--floated"),this.adjustColorContentSlot("var(--ez-text-input__input--focus--border-color)")}componentDidLoad(){this.observeErrorMessage(),this.observeMask(),this.adjustFloatingLabel(),this.adjustBorderInput()}componentWillLoad(){if(this.observeMask(),this.value){if(this._maskFormatter)try{this.value=this._maskFormatter.format(this.value)}catch(t){this.errorMessage=t.message}this.isValidValue(this.value)||(this._lastValidValue="",this.value="")}}render(){return a.addIDInfoIfNotExists(this._hostElement,"input"),e(o,null,e("slot",{name:"leftIcon",onSlotchange:t=>{this.handleSlotChange(t)}}),this.label&&"slim"!=this.mode?e("label",{ref:t=>this._labelElem=t,class:this.enabled?"input__label":"input__label input__label--disabled",onClick:()=>this._inputElem.focus(),title:this.label},this.label):null,e("input",{"data-element-id":a.getInternalIDInfo("input"),onFocus:()=>this.doFocus(),ref:t=>this._inputElem=t,type:"text",class:"slim"===this.mode?"input--slim":"",placeholder:"slim"===this.mode&&this.label?this.label:"",value:this.value,disabled:!this.enabled,onInput:()=>{this.handleChange()},onFocusout:()=>{this.handleFocusout()}}),e("slot",{name:"rightIcon",onSlotchange:t=>{this.handleSlotChange(t)}}),this.canShowError&&"slim"!=this.mode&&e("span",{class:"message-box",ref:t=>this._messageBoxElem=t,title:this.errorMessage,"data-element-id":a.getInternalIDInfo("message_box")},this.errorMessage))}get _hostElement(){return r(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],mask:["observeMask"],value:["observeValue"]}}};l.style=":host{--ez-text-input--height:42px;--ez-text-input--width:100%;--ez-text-input__icon--width:48px;--ez-text-input--height--slim:32px;--ez-text-input--border-radius:var(--border--radius-medium, 12px);--ez-text-input--font-size:var(--text--medium, 14px);--ez-text-input--font-family:var(--font-pattern, Arial);--ez-text-input--font-weight:var(--text-weight--medium, 400);--ez-text-input--color:var(--title--primary, #2B3A54);--ez-text-input__input--background-color:var(--background--medium, #e0e0e0);--ez-text-input__input--border:var(--border--medium, 2px solid);--ez-text-input__input--border-color:var(--ez-text-input__input--background-color);--ez-text-input__input--focus--border-color:var(--color--primary, #008561);--ez-text-input__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-text-input__input--disabled--color:var(--text--disable, #AFB6C0);--ez-text-input__input--error--border-color:#CC2936;--ez-text-input__input--noborder-color:white;--ez-text-input__input--padding:var(--space--medium, 6px);--ez-text-input__message_box--font-size:var(--text--small, 12px);--ez-text-input__message_box--info--color:var(--color--success, #22085d);--ez-text-input__message_box--error--color:var(--color--error, #FF0000);--ez-text-input__label--floating--top:6px;--ez-text-input__label--padding-top:12px;--ez-text-input__label--padding-left:14px;--ez-text-input__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--ez-text-input--width)}input{width:100%;box-sizing:border-box;height:var(--ez-text-input--height);border-radius:var(--ez-text-input--border-radius);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);border:var(--ez-text-input__input--border);border-color:var(--ez-text-input__input--border-color);background-color:var(--ez-text-input__input--background-color);color:var(--ez-text-input--color);font-weight:var(--ez-text-input--font-weight);padding:var(--ez-text-input__input--padding)}input:disabled{background-color:var(--ez-text-input__input--disabled--background-color);color:var(--ez-text-input__input--disabled--color)}input:focus{outline:none;border-color:var(--ez-text-input__input--focus--border-color)}input.icon--left{padding-left:var(--ez-text-input__icon--width)}input.icon--right{padding-right:var(--ez-text-input__icon--width)}input.hasError{color:var(--ez-text-input--color);border-color:var(--ez-text-input__input--error--border-color)}input:disabled.hasError{color:var(--ez-text-input__input--disabled--color)}input.text--right{text-align:right}input:read-only{cursor:default}.message-box{min-height:16px;min-width:100%;margin-top:3px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input__message_box--font-size);color:var(--ez-text-input__message_box--info--color)}.hasError{color:var(--ez-text-input__message_box--error--color)}.input__label{box-sizing:border-box;position:absolute;z-index:var(--visible);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:font-size .05s, top .05s;transition:font-size .05s, top .05s;width:calc(100% - var(--ez-text-input__label--padding-right));left:var(--ez-text-input--space--medium);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color);top:var(--ez-text-input__label--padding-top);left:var(--ez-text-input__label--padding-left);padding-right:var(--ez-text-input__label--padding-right)}.input__label--floated{font-family:var(--ez-text-input--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--ez-text-input__label--floating--top)}.input__label--disabled{color:var(--ez-text-input__input--disabled--color)}.input__label--left{text-align:left;left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--right{right:var(--ez-text-input__icon--width);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--left.input__label--right{left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width) * 2)}.input--with--label{padding-bottom:0}.input--slim{padding-top:var(--space--small, 3px);padding-bottom:var(--space--small, 3px);height:var(--ez-text-input--height--slim)}.input__slim--title{font-size:16px;font-weight:bold}.input--slim::-webkit-input-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim:-moz-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim::-moz-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim:-ms-input-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim::placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim:disabled::-webkit-input-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled:-moz-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled::-moz-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled:-ms-input-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled::placeholder{color:var(--ez-text-input__input--disabled--color)}input.input__slim--noborder{box-shadow:0 0 0 0;border:0 none;outline:0;background:var(--ez-text-input__input--noborder-color)}";export{l as ez_text_input}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/ezui",
3
- "version": "2.3.14",
3
+ "version": "2.4.0",
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{r as t,c as i,h as e,H as o,g as r}from"./p-3c7ea91b.js";import{MaskFormatter as n,ElementIDUtils as a}from"@sankhyalabs/core";let l=class{constructor(e){t(this,e),this.ezChange=i(this,"ezChange",7),this.enabled=!0,this.canShowError=!0,this.mode="regular",this.noBorder=!1}observeErrorMessage(){this._inputElem&&this.isInvalid().then((t=>{var i,e;t?(this._inputElem.classList.add("hasError"),null===(i=this._messageBoxElem)||void 0===i||i.classList.add("hasError")):(this._inputElem.classList.remove("hasError"),null===(e=this._messageBoxElem)||void 0===e||e.classList.remove("hasError"))}))}observeMask(){this.mask&&(null==this._maskFormatter?this._maskFormatter=new n(this.mask):this._maskFormatter.mask=this.mask)}observeValue(t,i){this._inputElem&&t!=i&&(this._inputElem.value=this.value||"",this.handleChange(),this.adjustFloatingLabel(),this.isSlaveMode()||(this.errorMessage="",this.ezChange.emit(this.value)))}adjustFloatingLabel(){if(this.label&&this._labelElem){this._inputElem&&!this._inputElem.classList.contains("input--with--label")&&this._inputElem.classList.add("input--with--label");const t=this.value&&this.value.toString().length>0,i=this._labelElem.classList.contains("input__label--floated");t||this.isFocused()?i||this._labelElem.classList.add("input__label--floated"):i&&this._labelElem.classList.remove("input__label--floated")}}isFocused(){return null!==this._hostElement.shadowRoot.activeElement}isSlaveMode(){var t,i;return"true"===(null===(i=null===(t=this._hostElement)||void 0===t?void 0:t.dataset)||void 0===i?void 0:i.slaveMode)}adjustColorContentSlot(t=""){this._contentLeftSlot&&(this._contentLeftSlot.style.color=t)}adjustBorderInput(){this.noBorder&&this._inputElem.classList.add("input__slim--noborder")}async setFocus(){this._inputElem.focus()}async setBlur(){this._inputElem.blur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}handleFocusout(){const t=this._inputElem.value;if(t&&this._maskFormatter)try{this._inputElem.value=this._maskFormatter.format(t)}catch(t){this.errorMessage=t.message}this.controlChangeValue(),this.adjustFloatingLabel(),this.adjustColorContentSlot()}isValidValue(t){return!this.restrict||Array.from(t).reduce(((t,i)=>t&&this.restrict.indexOf(i)>-1),!0)}controlChangeValue(){this._inputElem&&(this.value||"")!==this._inputElem.value&&(this.value=this._inputElem.value)}handleChange(){if(!this._inputElem)return;const t=this._inputElem.value;this.isValidValue(t)?this._lastValidValue=t:this._inputElem.value=null==this._lastValidValue?"":this._lastValidValue,this.controlChangeValue()}handleSlotChange(t){const i=t.target,e=i.assignedElements()[0];e&&(e.style.position="absolute",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",e.style.overflow="hidden",e.style.top="0px",e.style.width="var(--ez-text-input__icon--width)",e.style.height="slim"!=this.mode?"var(--ez-text-input--height)":"var(--ez-text-input--height--slim)","leftIcon"==i.name?(e.style.left="0px",e.style.borderRadius="var(--ez-text-input--border-radius) 0 0 var(--ez-text-input--border-radius)",this._inputElem.classList.add("icon--left"),this._labelElem&&this._labelElem.classList.add("input__label--left"),this._contentLeftSlot=e):"rightIcon"==i.name&&(e.style.right="0px",e.style.borderRadius="0 var(--ez-text-input--border-radius) var(--ez-text-input--border-radius) 0",this._inputElem.classList.add("icon--right"),this._labelElem&&this._labelElem.classList.add("input__label--right"))),this.observeErrorMessage()}doFocus(){this.label&&this._labelElem&&!this._labelElem.classList.contains("input__label--floated")&&this._labelElem.classList.add("input__label--floated"),this.adjustColorContentSlot("var(--ez-text-input__input--focus--border-color)")}componentDidLoad(){this.observeErrorMessage(),this.observeMask(),this.adjustFloatingLabel(),this.adjustBorderInput()}componentWillLoad(){if(this.observeMask(),this.value){if(this._maskFormatter)try{this.value=this._maskFormatter.format(this.value)}catch(t){this.errorMessage=t.message}this.isValidValue(this.value)||(this._lastValidValue="",this.value="")}}render(){return a.addIDInfoIfNotExists(this._hostElement,"input"),e(o,null,e("slot",{name:"leftIcon",onSlotchange:t=>{this.handleSlotChange(t)}}),this.label&&"slim"!=this.mode?e("label",{ref:t=>this._labelElem=t,class:this.enabled?"input__label":"input__label input__label--disabled",onClick:()=>this._inputElem.focus(),title:this.label},this.label):null,e("input",{"data-element-id":a.getInternalIDInfo("input"),onFocus:()=>this.doFocus(),ref:t=>this._inputElem=t,type:"text",class:"slim"===this.mode?"input--slim":"",placeholder:"slim"===this.mode&&this.label?this.label:"",value:this.value,disabled:!this.enabled,onInput:()=>{this.handleChange()},onFocusout:()=>{this.handleFocusout()}}),e("slot",{name:"rightIcon",onSlotchange:t=>{this.handleSlotChange(t)}}),this.canShowError&&"slim"!=this.mode&&e("span",{class:"message-box",ref:t=>this._messageBoxElem=t,title:this.errorMessage},this.errorMessage))}get _hostElement(){return r(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],mask:["observeMask"],value:["observeValue"]}}};l.style=":host{--ez-text-input--height:42px;--ez-text-input--width:100%;--ez-text-input__icon--width:48px;--ez-text-input--height--slim:32px;--ez-text-input--border-radius:var(--border--radius-medium, 12px);--ez-text-input--font-size:var(--text--medium, 14px);--ez-text-input--font-family:var(--font-pattern, Arial);--ez-text-input--font-weight:var(--text-weight--medium, 400);--ez-text-input--color:var(--title--primary, #2B3A54);--ez-text-input__input--background-color:var(--background--medium, #e0e0e0);--ez-text-input__input--border:var(--border--medium, 2px solid);--ez-text-input__input--border-color:var(--ez-text-input__input--background-color);--ez-text-input__input--focus--border-color:var(--color--primary, #008561);--ez-text-input__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-text-input__input--disabled--color:var(--text--disable, #AFB6C0);--ez-text-input__input--error--border-color:#CC2936;--ez-text-input__input--noborder-color:white;--ez-text-input__input--padding:var(--space--medium, 6px);--ez-text-input__message_box--font-size:var(--text--small, 12px);--ez-text-input__message_box--info--color:var(--color--success, #22085d);--ez-text-input__message_box--error--color:var(--color--error, #FF0000);--ez-text-input__label--floating--top:6px;--ez-text-input__label--padding-top:12px;--ez-text-input__label--padding-left:14px;--ez-text-input__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--ez-text-input--width)}input{width:100%;box-sizing:border-box;height:var(--ez-text-input--height);border-radius:var(--ez-text-input--border-radius);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);border:var(--ez-text-input__input--border);border-color:var(--ez-text-input__input--border-color);background-color:var(--ez-text-input__input--background-color);color:var(--ez-text-input--color);font-weight:var(--ez-text-input--font-weight);padding:var(--ez-text-input__input--padding)}input:disabled{background-color:var(--ez-text-input__input--disabled--background-color);color:var(--ez-text-input__input--disabled--color)}input:focus{outline:none;border-color:var(--ez-text-input__input--focus--border-color)}input.icon--left{padding-left:var(--ez-text-input__icon--width)}input.icon--right{padding-right:var(--ez-text-input__icon--width)}input.hasError{color:var(--ez-text-input--color);border-color:var(--ez-text-input__input--error--border-color)}input:disabled.hasError{color:var(--ez-text-input__input--disabled--color)}input.text--right{text-align:right}input:read-only{cursor:default}.message-box{min-height:16px;min-width:100%;margin-top:3px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input__message_box--font-size);color:var(--ez-text-input__message_box--info--color)}.hasError{color:var(--ez-text-input__message_box--error--color)}.input__label{box-sizing:border-box;position:absolute;z-index:var(--visible);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:font-size .05s, top .05s;transition:font-size .05s, top .05s;width:calc(100% - var(--ez-text-input__label--padding-right));left:var(--ez-text-input--space--medium);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color);top:var(--ez-text-input__label--padding-top);left:var(--ez-text-input__label--padding-left);padding-right:var(--ez-text-input__label--padding-right)}.input__label--floated{font-family:var(--ez-text-input--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--ez-text-input__label--floating--top)}.input__label--disabled{color:var(--ez-text-input__input--disabled--color)}.input__label--left{text-align:left;left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--right{right:var(--ez-text-input__icon--width);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--left.input__label--right{left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width) * 2)}.input--with--label{padding-bottom:0}.input--slim{padding-top:var(--space--small, 3px);padding-bottom:var(--space--small, 3px);height:var(--ez-text-input--height--slim)}.input__slim--title{font-size:16px;font-weight:bold}.input--slim::-webkit-input-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim:-moz-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim::-moz-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim:-ms-input-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim::placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim:disabled::-webkit-input-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled:-moz-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled::-moz-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled:-ms-input-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled::placeholder{color:var(--ez-text-input__input--disabled--color)}input.input__slim--noborder{box-shadow:0 0 0 0;border:0 none;outline:0;background:var(--ez-text-input__input--noborder-color)}";export{l as ez_text_input}
@@ -1 +0,0 @@
1
- import{r as o,c as i,h as t,H as s,g as e}from"./p-3c7ea91b.js";import{FloatingManager as r,ElementIDUtils as a}from"@sankhyalabs/core";import{A as l}from"./p-0b44cf1c.js";import{C as n}from"./p-4a5e37a7.js";import"./p-e1148f5c.js";import"./p-b853763b.js";let h=class{constructor(t){o(this,t),this.ezChange=i(this,"ezChange",7),this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._textEmptyList="Nenhum resultado encontrado",this._startLoading=!1,this._showLoading=!0,this.enabled=!0,this.showSelectedValue=!1,this.showOptionValue=!1,this.suppressSearch=!1,this.suppressEmptyOption=!1,this.canShowError=!0,this.mode="regular"}observeErrorMessage(){var o;this._textInput&&(this._textInput.errorMessage=this.errorMessage,(null===(o=this.errorMessage)||void 0===o?void 0:o.trim())||this.setInputValue())}observeValue(o,i){var t,s,e,r;if(this._textInput&&o!=i){const a=this.getSelectedOption(o),l=this.getSelectedOption(i),n=this.getSelectedOption(this.value);(null===(t=null==n?void 0:n.value)||void 0===t?void 0:t.toString())!=(null===(s=null==a?void 0:a.value)||void 0===s?void 0:s.toString())&&(this.value=a),(null===(e=null==a?void 0:a.value)||void 0===e?void 0:e.toString())!==(null===(r=null==l?void 0:l.value)||void 0===r?void 0:r.toString())&&(this.setInputValue(),this.ezChange.emit(null===a?void 0:a)),this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}}async setFocus(){this._textInput.setFocus()}async setBlur(){this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}getText(){let o="";const i=this.getSelectedOption(this.value);if(i&&(o=this.showSelectedValue?`${i.value} - ${i.label}`:i.label),null!=o)return String(o).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"')}getSelectedOption(o){return"string"==typeof o||o instanceof String?this._visibleOptions.find((i=>i.value===o)):o}updateVisibleOptions(){let o=this._source||[];if(!this.searchMode&&this._criteria){const i=this._criteria.toUpperCase();o=o.filter((o=>o.label.toLocaleUpperCase().indexOf(i)>-1))}this._visibleOptions=this.suppressEmptyOption?o:[{value:void 0,label:""}].concat(o),this._maxWidthValue=this.getMaxWidthValue()}getMaxWidthValue(){var o;if(this.showOptionValue){const i=[];return null===(o=this._visibleOptions)||void 0===o||o.forEach((o=>{const t=this.getWidthValue(o.value);i.includes(t)||i.push(t)})),i.length>1?Math.max(...i):0}return 0}getWidthValue(o){if(null!=this._itemValueBasis){const i=this._itemValueBasis;if(null!=o)return i.innerHTML=o,i.clientWidth>0?i.clientWidth+2:0;i.innerHTML=""}return 0}buildItem(o,i){const s=this.showOptionValue&&this._maxWidthValue>0?`${this._maxWidthValue}px`:"";return t("li",{class:i===this._preSelection?"item preselected":"item",id:`item_${o.value}`,onMouseDown:()=>this.selectOption(o),onMouseOver:()=>this._preSelection=i},this.showOptionValue?t("span",{class:"item__value",title:o.value,style:{width:s,minWidth:s,maxWidth:s}},o.value):void 0,t("span",{class:"item__label "+(this.showOptionValue?"item__label--bold":""),title:o.label},o.label))}showOptions(){this.enabled&&(this._floatingID=r.float(this._listWrapper,this._listContainer,{autoClose:!0,top:this.errorMessage||!this.canShowError||"slim"===this.mode?"6px":"-13px"}),this.setFocus(),window.requestAnimationFrame((()=>{this._listWrapper.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})})))}hideOptions(){void 0!==this._floatingID&&r.close(this._floatingID),this._floatingID=void 0}isOptionsVisible(){return void 0!==this._floatingID&&r.isFloating(this._floatingID)}nextOption(){this.searchMode&&!this.isOptionsVisible()||(this.showOptions(),this._preSelection=void 0===this._preSelection?0:Math.min(this._preSelection+1,this._visibleOptions.length-1),this.scrollToOption(this._visibleOptions[this._preSelection],!0))}previousOption(){this._preSelection=void 0===this._preSelection?0:Math.max(this._preSelection-1,0),this.scrollToOption(this._visibleOptions[this._preSelection],!1)}scrollToOption(o,i){window.requestAnimationFrame((()=>{const t=(null==o?void 0:o.value)?this._optionsList.querySelector(`li#item_${o.value}`):void 0;if(t){const o=t.parentElement,s=o.getBoundingClientRect(),e=t.getBoundingClientRect();i&&e.bottom>s.bottom?o.scrollTop=e.height*(this._preSelection-3):!i&&e.top<s.top&&(o.scrollTop=e.height*this._preSelection)}}))}selectCurrentOption(){void 0!==this._preSelection?(this.selectOption(this._visibleOptions[this._preSelection]),this._preSelection=void 0):this.controlListWithOnlyOne()}updateSource(o){this._startLoading=!1,o instanceof Promise?(this._showLoading=!0,o.then((o=>{this._showLoading=!1,this.updateSource(o)})).catch((()=>this._showLoading=!1)),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(o)?(this._source=o,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1,this.controlEmptySearch())):this.selectOption(o))}clearSource(){this._source=[],this.updateVisibleOptions()}selectOption(o){var i,t;const s=this.getSelectedOption(this.value);(null===(i=null==s?void 0:s.value)||void 0===i?void 0:i.toString())!==(null===(t=null==o?void 0:o.value)||void 0===t?void 0:t.toString())?this.value=(null==o?void 0:o.value)?o:void 0:(this.setInputValue(),this.hideOptions()),this.searchMode&&(this._visibleOptions=[]),this.searchMode&&(this._visibleOptions=[])}loadOptions(o,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:o,argument:i}):this.options)}cancelPreselection(){!this._textInput.value&&this.value?this.selectOption(void 0):this.setInputValue()}setInputValue(o=!0){const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,o&&(this.errorMessage=""))}clearSearch(){this.value=null}controlListWithOnlyOne(){if(this.searchMode){const o=this._visibleOptions;1===(null==o?void 0:o.length)&&this.selectOption(o[0])}}controlEmptySearch(){var o;this.searchMode&&((null===(o=this._visibleOptions)||void 0===o?void 0:o.length)?this.controlListWithOnlyOne():(this.clearSearch(),l.info(this._textEmptyList)))}componentWillLoad(){if(void 0===this.options){this.options=[];const o=this.el.querySelectorAll("option");o&&o.forEach((o=>{let i=o.innerText,t=o.getAttribute("value");t||(t=i),this.options.push({label:i,value:t}),o.hidden=!0}))}this.searchMode?this.updateSource([]):this.loadOptions(c.PRELOAD)}componentDidRender(){void 0===this._floatingID&&this._listWrapper.remove()}componentDidLoad(){n.applyVarsTextInput(this.el,this._textInput),this.setInputValue(!1)}handlerIconClick(){this.searchMode?this.loadOptions(c.ADVANCED):this.showOptions()}onTextInputChangeHandler(o){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(o)}),this._deboucingTime));const t=null===(i=o.target.value)||void 0===i?void 0:i.trim(),s=Number(t||void 0);this._criteria||(this._textInput.value=o.data||t),this._criteria=t,t&&(!isNaN(s)||t.length>=this._limitCharsToSearch)?(this.searchMode?(this._showLoading=!0,this.clearSource(),this._changeDeboucingTimeout=window.setTimeout((()=>{this.loadOptions(c.PREDICTIVE,isNaN(s)?t:s.toString())}),this._deboucingTime)):this.updateVisibleOptions(),this.showOptions()):this.hideOptions()}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=void 0)}onTextInputClickHandler(){this.searchMode||this.showOptions()}keyDownHandler(o){switch(this._tabPressed=!1,o.ctrlKey&&("f"!==o.key&&"F"!==o.key||(this.loadOptions(c.ADVANCED),o.stopPropagation(),o.stopImmediatePropagation(),o.preventDefault())),o.key){case"ArrowDown":this.nextOption();break;case"ArrowUp":this.previousOption();break;case"Enter":this.selectCurrentOption();break;case"Escape":this.cancelPreselection();break;case"Tab":this._tabPressed=!0,this.controlListWithOnlyOne()}}onTextInputFocusOutHandler(){this.cancelPreselection()}render(){var o;return a.addIDInfoIfNotExists(this.el,"input"),t(s,null,t("ez-text-input",{"data-element-id":a.getInternalIDInfo("textInput"),class:this.suppressSearch?"suppressed-search-input":"",ref:o=>this._textInput=o,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:o=>this.onTextInputChangeHandler(o),onClick:()=>this.onTextInputClickHandler(),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:o=>this.keyDownHandler(o),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode},t("button",{class:"btn",slot:this.searchMode?"leftIcon":"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},t("ez-icon",{iconName:this.searchMode?"search":"chevron-down"})),this.searchMode&&(null===(o=this._textInput)||void 0===o?void 0:o.value)&&(this._criteria||this.value)?t("button",{class:"btn btn__close",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.clearSearch()},t("ez-icon",{iconName:"close"})):void 0),t("section",{class:"list-container",ref:o=>this._listContainer=o},t("div",{class:"list-wrapper",ref:o=>this._listWrapper=o},t("div",{class:"list-options",ref:o=>this._optionsList=o},0===this._visibleOptions.length&&t("div",{class:"message"},!this._showLoading&&t("span",{class:"message__no-result"},this._textEmptyList),this._showLoading&&t("div",{class:"message__loading"})),this.showOptionValue?t("span",{class:"item__value item__value--hidden",ref:o=>this._itemValueBasis=o}):void 0,this._visibleOptions.length>0&&this._visibleOptions.map(((o,i)=>this.buildItem(o,i)))))))}get el(){return e(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"]}}};var c;!function(o){o.ADVANCED="ADVANCED",o.PRELOAD="PRELOAD",o.PREDICTIVE="PREDICTIVE"}(c||(c={})),h.style=":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box--line-height:calc(var(--text--medium, 14px) + 4px);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium) + 4px);--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__list-scrollbar--background-color-primary:var(--scrollbar--primary, #2B3A54);--ez-combo-box__list-scrollbar--background-color-secondary:var(--scrollbar--secondary, #E5EAF0);--ez-combo-box__list-scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__list-scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small) + 9px);background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto;scrollbar-width:thin;gap:3px;scrollbar-color:var(--ez-combo-box__list-scrollbar--background-color-primary) var(--ez-combo-box__list-scrollbar--background-color-secondary)}.list-options::-webkit-scrollbar-track{background-color:var(--ez-combo-box__list-scrollbar--background-color-secondary);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__list-scrollbar--background-color-primary);border-radius:var(--ez-combo-box__list-scrollbar--border-radius)}.list-options::-webkit-scrollbar{background-color:var(--ez-combo-box__list-scrollbar--background-color-secondary);width:var(--ez-combo-box__list-scrollbar--width);max-width:var(--ez-combo-box__list-scrollbar--width);min-width:var(--ez-combo-box__list-scrollbar--width)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size);line-height:var(--ez-combo-box--line-height)}.item__label{font-weight:var(--ez-combo-box--font-weight--medium)}.item__label--bold{font-weight:var(--ez-combo-box--font-weight--large)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large)}.item__value--hidden{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:var(--ez-combo-box__list-height)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:14px;height:14px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";export{h as ez_combo_box}