@sankhyalabs/ezui 0.0.0-bugfix-dev-59880.5 → 0.0.0-bugfix-dev-KB-59889.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.
Files changed (47) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/ez-form-view.cjs.entry.js +3 -4
  3. package/dist/cjs/ez-form.cjs.entry.js +26 -0
  4. package/dist/cjs/ez-grid.cjs.entry.js +27 -4
  5. package/dist/cjs/ez-number-input.cjs.entry.js +27 -26
  6. package/dist/cjs/ez-tabselector.cjs.entry.js +34 -29
  7. package/dist/cjs/ezui.cjs.js +1 -1
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/collection/components/ez-form-view/ez-form-view.js +1 -1
  10. package/dist/collection/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.js +2 -3
  11. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +17 -0
  12. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +1 -0
  13. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +2 -3
  14. package/dist/collection/components/ez-grid/ez-grid.css +1 -0
  15. package/dist/collection/components/ez-grid/ez-grid.js +22 -0
  16. package/dist/collection/components/ez-number-input/ez-number-input.js +27 -31
  17. package/dist/collection/components/ez-tabselector/ez-tabselector.js +34 -29
  18. package/dist/collection/utils/form/DataBinder.js +26 -0
  19. package/dist/collection/utils/form/test/DataBinder.test.js +41 -4
  20. package/dist/collection/utils/form/test/resources/metadataTest.js +15 -0
  21. package/dist/custom-elements/index.js +119 -65
  22. package/dist/esm/ez-form-view.entry.js +3 -4
  23. package/dist/esm/ez-form.entry.js +27 -1
  24. package/dist/esm/ez-grid.entry.js +27 -4
  25. package/dist/esm/ez-number-input.entry.js +27 -26
  26. package/dist/esm/ez-tabselector.entry.js +34 -29
  27. package/dist/esm/ezui.js +1 -1
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/ezui/ezui.esm.js +1 -1
  30. package/dist/ezui/p-13727aec.entry.js +1 -0
  31. package/dist/ezui/p-1ee2479b.entry.js +1 -0
  32. package/dist/ezui/p-2dcb50d4.entry.js +1 -0
  33. package/dist/ezui/{p-34190f80.entry.js → p-362c3c80.entry.js} +1 -1
  34. package/dist/ezui/p-99f46950.entry.js +1 -0
  35. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +1 -0
  36. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +3 -0
  37. package/dist/types/components/ez-grid/ez-grid.d.ts +4 -0
  38. package/dist/types/components/ez-number-input/ez-number-input.d.ts +0 -2
  39. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +3 -2
  40. package/dist/types/components.d.ts +4 -0
  41. package/dist/types/utils/form/DataBinder.d.ts +3 -0
  42. package/dist/types/utils/form/test/resources/metadataTest.d.ts +2 -0
  43. package/package.json +1 -1
  44. package/dist/ezui/p-3b9e5664.entry.js +0 -1
  45. package/dist/ezui/p-6ca64193.entry.js +0 -1
  46. package/dist/ezui/p-77362d3a.entry.js +0 -1
  47. package/dist/ezui/p-cc2dc4f4.entry.js +0 -1
@@ -1,6 +1,6 @@
1
1
  import { HTMLElement as HTMLElement$1, createEvent, h, Host, forceUpdate, Fragment, proxyCustomElement } from '@stencil/core/internal/client';
2
2
  export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
3
- import { UserInterface, DateUtils as DateUtils$1, Action, WaitingChangeException, ApplicationContext, DataUnitAction, FloatingManager, ElementIDUtils, ObjectUtils as ObjectUtils$1, JSUtils, StringUtils as StringUtils$1, HTMLBuilder, TimeFormatter, DataUnit, NumberUtils as NumberUtils$1, MaskFormatter, DataType, SortMode, FieldComparator, ArrayUtils as ArrayUtils$1, OverflowWatcher, OVERFLOWED_CLASS_NAME, KeyboardManager } from '@sankhyalabs/core';
3
+ import { UserInterface, DateUtils as DateUtils$1, Action, ApplicationContext, WaitingChangeException, DataUnitAction, FloatingManager, ElementIDUtils, ObjectUtils as ObjectUtils$1, JSUtils, StringUtils as StringUtils$1, HTMLBuilder, TimeFormatter, DataUnit, NumberUtils as NumberUtils$1, MaskFormatter, DataType, SortMode, FieldComparator, ArrayUtils as ArrayUtils$1, OverflowWatcher, OVERFLOWED_CLASS_NAME, KeyboardManager } from '@sankhyalabs/core';
4
4
  import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
5
5
 
6
6
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
@@ -616,6 +616,13 @@ class DataBinder {
616
616
  this.applyDefaultValues();
617
617
  this._dataUnit.subscribe(this.onDataUnitEvent);
618
618
  this._dataUnit.addInterceptor(this);
619
+ this.setContextDataBinder(dataUnit);
620
+ }
621
+ setContextDataBinder(dataUnit) {
622
+ const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
623
+ const dataBinders = [...(dataBindersByDataUnit.get(dataUnit.dataUnitId) || []), this];
624
+ dataBindersByDataUnit.set(dataUnit.dataUnitId, dataBinders);
625
+ ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
619
626
  }
620
627
  applyDefaultValues() {
621
628
  const recordIds = (this._dataUnit.getAddedRecords() || []).map(r => r.__record__id__);
@@ -642,9 +649,17 @@ class DataBinder {
642
649
  getMessageForField: field => this.getErrorMessage(field)
643
650
  }, recordsValidator);
644
651
  }
652
+ disconnectDataUnit() {
653
+ const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
654
+ const dataBinders = dataBindersByDataUnit.get(this._dataUnit.dataUnitId);
655
+ const dataBindersFiltered = dataBinders.filter((dataBinder) => JSON.stringify(dataBinder) !== JSON.stringify(this));
656
+ dataBindersByDataUnit.set(this._dataUnit.dataUnitId, dataBindersFiltered);
657
+ ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
658
+ }
645
659
  onDisconnectedCallback() {
646
660
  this._dataUnit.unsubscribe(this.onDataUnitEvent);
647
661
  this._dataUnit.removeInterceptor(this);
662
+ this.disconnectDataUnit();
648
663
  }
649
664
  getCurrentRecordId() {
650
665
  const record = this._dataUnit.getSelectedRecord();
@@ -691,6 +706,17 @@ class DataBinder {
691
706
  validate() {
692
707
  return this._recordValidatorProcessor.validate();
693
708
  }
709
+ static async validateByDataunit(dataUnit) {
710
+ try {
711
+ const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__");
712
+ const dataBinders = dataBindersByDataUnit.get(dataUnit.dataUnitId) || [];
713
+ await Promise.all(dataBinders.map((dataBinder) => dataBinder.validate()));
714
+ return true;
715
+ }
716
+ catch (_a) {
717
+ return false;
718
+ }
719
+ }
694
720
  updateErrorMessage(fieldName, field, message) {
695
721
  if (message == undefined) {
696
722
  message = this._dataUnit.getInvalidMessage(this.getCurrentRecordId(), fieldName);
@@ -4929,9 +4955,8 @@ const buildFile = ({ name, label, readOnly, contextName, props }) => {
4929
4955
  };
4930
4956
 
4931
4957
  const buildDecimal$1 = ({ name, label, readOnly, props, contextName, canShowError }) => {
4932
- var _a, _b;
4933
- const precision = Number((_a = props === null || props === void 0 ? void 0 : props.precision) !== null && _a !== void 0 ? _a : 2);
4934
- const prettyPrecision = Number((_b = props === null || props === void 0 ? void 0 : props.prettyPrecision) !== null && _b !== void 0 ? _b : precision);
4958
+ const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
4959
+ const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
4935
4960
  return buildNumeric$1(name, label, readOnly, precision, prettyPrecision, contextName, canShowError);
4936
4961
  };
4937
4962
  const buildInteger$1 = ({ name, label, readOnly, contextName, canShowError }) => {
@@ -5040,7 +5065,7 @@ const EzFormView$1 = class extends HTMLElement$1 {
5040
5065
  */
5041
5066
  async setFieldProp(fieldName, propName, value) {
5042
5067
  const fields = this.fields.map(field => {
5043
- if (field.name === fieldName && (value || value === 0)) {
5068
+ if (field.name === fieldName) {
5044
5069
  field.props = field.props || {};
5045
5070
  field.props[propName] = value;
5046
5071
  }
@@ -124034,6 +124059,7 @@ class DataSource {
124034
124059
  else {
124035
124060
  this._controller.selectRows(selectionInfo.recordIds, true);
124036
124061
  }
124062
+ this._controller.setFocusFirstRow();
124037
124063
  }
124038
124064
  getRows(params) {
124039
124065
  if (this.needReload(params)) {
@@ -124420,9 +124446,8 @@ const buildDateTime = ({ readOnly }) => {
124420
124446
  };
124421
124447
 
124422
124448
  const buildDecimal = ({ readOnly, props }) => {
124423
- var _a, _b;
124424
- const precision = Number((_a = props === null || props === void 0 ? void 0 : props.precision) !== null && _a !== void 0 ? _a : 2);
124425
- const prettyPrecision = Number((_b = props === null || props === void 0 ? void 0 : props.prettyPrecision) !== null && _b !== void 0 ? _b : precision);
124449
+ const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
124450
+ const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
124426
124451
  return buildNumeric(readOnly, precision, prettyPrecision);
124427
124452
  };
124428
124453
  const buildInteger = ({ readOnly }) => {
@@ -125052,6 +125077,7 @@ class AgGridController {
125052
125077
  }
125053
125078
  initDatagrid(container, options) {
125054
125079
  var _a;
125080
+ this._container = container;
125055
125081
  if (this._grid === undefined) {
125056
125082
  LicenseManager.setLicenseKey(ApplicationContext.getContextValue('__EZUI__GRID_LICENSE__'));
125057
125083
  this._columnStateChangeCallback = options.onColumnStateChange;
@@ -125406,11 +125432,27 @@ class AgGridController {
125406
125432
  }
125407
125433
  this._gridOptions.api.refreshServerSide({ purge: true });
125408
125434
  }
125435
+ focusOnGridContainer() {
125436
+ this._container.setAttribute('tabindex', '-1');
125437
+ this._container.focus();
125438
+ }
125439
+ setFocus() {
125440
+ var _a, _b;
125441
+ if ((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.length) {
125442
+ this.setFocusFirstRow();
125443
+ }
125444
+ else {
125445
+ this.focusOnGridContainer();
125446
+ }
125447
+ }
125409
125448
  setFocusFirstRow() {
125410
125449
  const firstRow = this._gridOptions.api.getDisplayedRowAtIndex(0);
125411
125450
  if (firstRow) {
125412
125451
  this.setFocusOnRow(firstRow.rowIndex);
125413
125452
  }
125453
+ else {
125454
+ this.focusOnGridContainer();
125455
+ }
125414
125456
  }
125415
125457
  setFocusLastRow() {
125416
125458
  const lastRow = this._gridOptions.api.getDisplayedRowAtIndex(this._gridOptions.api.getLastDisplayedRow());
@@ -126014,7 +126056,7 @@ class InMemoryFilterColumnDataSource {
126014
126056
  }
126015
126057
  }
126016
126058
 
126017
- const ezGridCss = ".sc-ez-grid-h{display:grid;grid-template-rows:auto 1fr auto;height:100%;width:100%;--ez-grid__header--background-color:var(--background--xlight, #FFF);--ez-grid__selection-counter--z-index:var(--visible, 1);--ez-grid__container--shadow:0 0 16px 0 rgb(0 38 111 / 12%);--ez-grid--min-height:300px;min-height:var(--ez-grid--min-height)}.grid-header.sc-ez-grid{display:grid;justify-content:space-between;align-items:center;grid-row-start:1;grid-template-columns:1fr;background-color:var(--ez-grid__header--background-color, #FFF)}.grid__container.sc-ez-grid{padding-top:15px;margin-top:-12px;box-shadow:var(--ez-grid__container--shadow);background-color:var(--ez-grid__header--background-color)}.grid-header__popover.sc-ez-grid{position:relative;top:var(--space--sm, 16px)}.grid-header__container.sc-ez-grid{display:flex;align-items:center}.grid-header__position.sc-ez-grid{display:flex;align-items:center;justify-content:space-between}.grid__selection-counter.sc-ez-grid{position:fixed;white-space:nowrap;transform:translate(-50%, 0px);left:50%;opacity:0;bottom:-100%;transition:opacity 0.1s, bottom 0.5s}.grid__selection-counter--opened.sc-ez-grid{opacity:1;bottom:0px}.grid__btn-close.sc-ez-grid{display:flex;align-items:center;justify-content:center;padding:0;outline:none;width:20px;height:20px;border:none;background-color:unset;cursor:pointer}.grid__btn-clear.sc-ez-grid{--ez-button--link-color:var(--color--alert-warning-900, #8C6B00);--ez-button--link--hover-color:var(--color--alert-warning-900, #8C6B00)}[no-header].sc-ez-grid-h .grid-header.sc-ez-grid{height:0;padding:0}.grid-header__pagination.sc-ez-grid{width:30%;min-width:100px;justify-content:flex-end;flex-wrap:wrap}.grid-header__left-container.sc-ez-grid{width:70%}.grid-header__pagination-label.sc-ez-grid{width:100%;white-space:nowrap}.overflowed.sc-ez-grid{display:none}";
126059
+ const ezGridCss = ".sc-ez-grid-h{display:grid;grid-template-rows:auto 1fr auto;height:100%;width:100%;--ez-grid__header--background-color:var(--background--xlight, #FFF);--ez-grid__selection-counter--z-index:var(--visible, 1);--ez-grid__container--shadow:0 0 16px 0 rgb(0 38 111 / 12%);--ez-grid--min-height:300px;min-height:var(--ez-grid--min-height)}.grid-header.sc-ez-grid{display:grid;justify-content:space-between;align-items:center;grid-row-start:1;grid-template-columns:1fr;background-color:var(--ez-grid__header--background-color, #FFF)}.grid__container.sc-ez-grid{padding-top:15px;margin-top:-12px;outline:none;box-shadow:var(--ez-grid__container--shadow);background-color:var(--ez-grid__header--background-color)}.grid-header__popover.sc-ez-grid{position:relative;top:var(--space--sm, 16px)}.grid-header__container.sc-ez-grid{display:flex;align-items:center}.grid-header__position.sc-ez-grid{display:flex;align-items:center;justify-content:space-between}.grid__selection-counter.sc-ez-grid{position:fixed;white-space:nowrap;transform:translate(-50%, 0px);left:50%;opacity:0;bottom:-100%;transition:opacity 0.1s, bottom 0.5s}.grid__selection-counter--opened.sc-ez-grid{opacity:1;bottom:0px}.grid__btn-close.sc-ez-grid{display:flex;align-items:center;justify-content:center;padding:0;outline:none;width:20px;height:20px;border:none;background-color:unset;cursor:pointer}.grid__btn-clear.sc-ez-grid{--ez-button--link-color:var(--color--alert-warning-900, #8C6B00);--ez-button--link--hover-color:var(--color--alert-warning-900, #8C6B00)}[no-header].sc-ez-grid-h .grid-header.sc-ez-grid{height:0;padding:0}.grid-header__pagination.sc-ez-grid{width:30%;min-width:100px;justify-content:flex-end;flex-wrap:wrap}.grid-header__left-container.sc-ez-grid{width:70%}.grid-header__pagination-label.sc-ez-grid{width:100%;white-space:nowrap}.overflowed.sc-ez-grid{display:none}";
126018
126060
 
126019
126061
  const windowInstace$1 = window;
126020
126062
  const matches = (text, filter) => {
@@ -126171,6 +126213,12 @@ const EzGrid$1 = class extends HTMLElement$1 {
126171
126213
  async getCustomValueFormatter(columnName) {
126172
126214
  return this._customFormatters.get(columnName);
126173
126215
  }
126216
+ /**
126217
+ * Atribui o foco para a grade.
126218
+ */
126219
+ async setFocus() {
126220
+ this._gridController.setFocus();
126221
+ }
126174
126222
  observeConfig(config) {
126175
126223
  this._gridController.setColumnsState(config === null || config === void 0 ? void 0 : config.columns);
126176
126224
  }
@@ -127532,7 +127580,6 @@ const EzNumberInput$1 = class extends HTMLElement$1 {
127532
127580
  this._focused = false;
127533
127581
  this._changePending = false;
127534
127582
  this._valuePromiseCallbacks = [];
127535
- this._value = undefined;
127536
127583
  this.label = undefined;
127537
127584
  this.value = undefined;
127538
127585
  this.enabled = true;
@@ -127588,7 +127635,24 @@ const EzNumberInput$1 = class extends HTMLElement$1 {
127588
127635
  }
127589
127636
  observeValue(newValue, oldValue) {
127590
127637
  if (this._textInput && newValue != oldValue) {
127591
- this.handleNewValue(newValue, oldValue);
127638
+ const newValueValidated = this.validateValue(newValue);
127639
+ const oldValueValidated = this.validateValue(oldValue);
127640
+ if (newValueValidated === null) {
127641
+ this._textInput.value = '';
127642
+ }
127643
+ if (newValueValidated != oldValueValidated) {
127644
+ const textValue = this.getTextValue(newValueValidated) || '';
127645
+ if ((this._textInput.value || '') !== textValue) {
127646
+ const parsedNumber = this.getParsedNumber(textValue);
127647
+ if (parsedNumber !== undefined || !this._focused) {
127648
+ this._textInput.value = textValue;
127649
+ this._focused = false;
127650
+ this.errorMessage = "";
127651
+ }
127652
+ }
127653
+ const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
127654
+ this.ezChange.emit(valueEmitted);
127655
+ }
127592
127656
  }
127593
127657
  this._changePending = false;
127594
127658
  }
@@ -127597,31 +127661,12 @@ const EzNumberInput$1 = class extends HTMLElement$1 {
127597
127661
  this.setInputValue();
127598
127662
  }
127599
127663
  }
127600
- handleNewValue(newValue, oldValue) {
127601
- const newValueValidated = this.validateValue(newValue);
127602
- const oldValueValidated = this.validateValue(oldValue);
127603
- if (newValueValidated === null) {
127604
- this._value = '';
127605
- }
127606
- if (newValueValidated === oldValueValidated) {
127607
- return;
127608
- }
127609
- const textValue = this.getTextValue(newValueValidated) || '';
127610
- const parsedNumber = this.getParsedNumber(textValue);
127611
- if ((this._value || '') !== textValue && (parsedNumber !== undefined || !this._focused)) {
127612
- this._value = textValue;
127613
- this._focused = false;
127614
- this.errorMessage = "";
127615
- }
127616
- const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
127617
- this.ezChange.emit(valueEmitted);
127618
- }
127619
127664
  validateValue(value) {
127620
127665
  return isNaN(value) || value === undefined ? null : value;
127621
127666
  }
127622
127667
  getTextValue(value) {
127623
127668
  if (value != undefined) {
127624
- return this.precision >= 0 ? NumberUtils$1.format(value.toString(), Number(this.precision), Number(this.prettyPrecision)) : value.toString();
127669
+ return this.precision > 0 ? NumberUtils$1.format(value.toString(), Number(this.precision), Number(this.prettyPrecision)) : value.toString();
127625
127670
  }
127626
127671
  return undefined;
127627
127672
  }
@@ -127674,13 +127719,17 @@ const EzNumberInput$1 = class extends HTMLElement$1 {
127674
127719
  this.ezStartChange.emit({ waitmessage: "", blocking: false });
127675
127720
  }
127676
127721
  }
127677
- getParsedNumber(value = this._value) {
127722
+ getParsedNumber(value) {
127723
+ var _a;
127724
+ if (value === void 0) {
127725
+ value = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value;
127726
+ }
127678
127727
  return (value === null || value === void 0 ? void 0 : value.trim()) ? NumberUtils$1.stringToNumber(value) : undefined;
127679
127728
  }
127680
127729
  setInputValue() {
127681
127730
  const textValue = this.getTextValue(this.value) || '';
127682
- if ((this._value || '') !== textValue) {
127683
- this._value = textValue;
127731
+ if ((this._textInput.value || '') !== textValue) {
127732
+ this._textInput.value = textValue;
127684
127733
  }
127685
127734
  }
127686
127735
  componentDidLoad() {
@@ -127689,7 +127738,7 @@ const EzNumberInput$1 = class extends HTMLElement$1 {
127689
127738
  }
127690
127739
  render() {
127691
127740
  ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
127692
- return (h("ez-text-input", { class: "number__input", "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, canShowError: this.canShowError, value: this._value }));
127741
+ return (h("ez-text-input", { class: "number__input", "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, canShowError: this.canShowError }));
127693
127742
  }
127694
127743
  get _elem() { return this; }
127695
127744
  static get watchers() { return {
@@ -129995,9 +130044,13 @@ const EzTabselector$1 = class extends HTMLElement$1 {
129995
130044
  this.selectedTab = undefined;
129996
130045
  this.tabs = undefined;
129997
130046
  }
129998
- observeTabs(newValue) {
130047
+ observeTabs(newValue, oldValue) {
129999
130048
  if (newValue && typeof newValue !== "string") {
130000
130049
  this._processedTabs = newValue;
130050
+ return;
130051
+ }
130052
+ if (newValue !== oldValue) {
130053
+ this.processesTabs();
130001
130054
  }
130002
130055
  }
130003
130056
  handleTabClick(tab) {
@@ -130007,36 +130060,37 @@ const EzTabselector$1 = class extends HTMLElement$1 {
130007
130060
  this.ezChange.emit(tab);
130008
130061
  this.setFocusedBtn(false, tab.index);
130009
130062
  }
130010
- componentWillRender() {
130011
- if (!this._processedTabs) {
130012
- if (this.tabs) {
130013
- if (Array.isArray(this.tabs)) {
130014
- this._processedTabs = [...this.tabs];
130015
- }
130016
- else {
130017
- this._processedTabs = [];
130018
- this.tabs.split(",").forEach((label) => {
130019
- label = label.trim();
130020
- this._processedTabs.push({ label, tabKey: label, index: this._processedTabs.length });
130021
- this.buildElementIdTab(this._processedTabs);
130022
- });
130023
- }
130063
+ componentWillLoad() {
130064
+ this.processesTabs();
130065
+ }
130066
+ processesTabs() {
130067
+ if (this.tabs) {
130068
+ if (Array.isArray(this.tabs)) {
130069
+ this._processedTabs = [...this.tabs];
130070
+ }
130071
+ else {
130072
+ this._processedTabs = [];
130073
+ this.tabs.split(",").forEach((label) => {
130074
+ label = label.trim();
130075
+ this._processedTabs.push({ label, tabKey: label, index: this._processedTabs.length });
130076
+ this.buildElementIdTab(this._processedTabs);
130077
+ });
130024
130078
  }
130025
- this._hostElem.querySelectorAll("ez-tab").forEach((elem) => {
130026
- const tabKey = elem.getAttribute("tabKey");
130027
- const label = elem.getAttribute("label");
130028
- const leftIcon = elem.getAttribute("leftIcon");
130029
- const rightIcon = elem.getAttribute("rightIcon");
130030
- const tab = { label, tabKey, leftIcon, rightIcon, index: this._processedTabs.length };
130031
- const content = elem.firstChild;
130032
- if (content) {
130033
- content.setAttribute("slot", "tab" + tab.index);
130034
- this._hostElem.appendChild(content);
130035
- }
130036
- this._processedTabs.push(tab);
130037
- this.buildElementIdTab(this._processedTabs);
130038
- });
130039
130079
  }
130080
+ this._hostElem.querySelectorAll("ez-tab").forEach((elem) => {
130081
+ const tabKey = elem.getAttribute("tabKey");
130082
+ const label = elem.getAttribute("label");
130083
+ const leftIcon = elem.getAttribute("leftIcon");
130084
+ const rightIcon = elem.getAttribute("rightIcon");
130085
+ const tab = { label, tabKey, leftIcon, rightIcon, index: this._processedTabs.length };
130086
+ const content = elem.firstChild;
130087
+ if (content) {
130088
+ content.setAttribute("slot", "tab" + tab.index);
130089
+ this._hostElem.appendChild(content);
130090
+ }
130091
+ this._processedTabs.push(tab);
130092
+ this.buildElementIdTab(this._processedTabs);
130093
+ });
130040
130094
  }
130041
130095
  componentDidRender() {
130042
130096
  this.updateScroll();
@@ -132186,7 +132240,7 @@ const EzLoadingBar = /*@__PURE__*/proxyCustomElement(EzLoadingBar$1, [1,"ez-load
132186
132240
  const EzModal = /*@__PURE__*/proxyCustomElement(EzModal$1, [1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"heightMode":[1,"height-mode"],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"],"scrim":[1]}]);
132187
132241
  const EzModalContainer = /*@__PURE__*/proxyCustomElement(EzModalContainer$1, [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"]},[[4,"ezCloseModal","handleEzModalAction"]]]);
132188
132242
  const EzMultiSelectionList = /*@__PURE__*/proxyCustomElement(EzMuiltiSelectionList, [2,"ez-multi-selection-list",{"columnName":[1,"column-name"],"dataSource":[16],"useOptions":[1028,"use-options"],"options":[1040],"isTextSearch":[4,"is-text-search"],"filteredOptions":[32],"displayOptions":[32],"viewScenario":[32],"displayOptionToCheckAllItems":[32]}]);
132189
- const EzNumberInput = /*@__PURE__*/proxyCustomElement(EzNumberInput$1, [1,"ez-number-input",{"label":[1],"value":[1538],"enabled":[4],"canShowError":[516,"can-show-error"],"errorMessage":[1537,"error-message"],"precision":[2],"prettyPrecision":[2,"pretty-precision"],"mode":[513],"_value":[32]}]);
132243
+ const EzNumberInput = /*@__PURE__*/proxyCustomElement(EzNumberInput$1, [1,"ez-number-input",{"label":[1],"value":[1538],"enabled":[4],"canShowError":[516,"can-show-error"],"errorMessage":[1537,"error-message"],"precision":[2],"prettyPrecision":[2,"pretty-precision"],"mode":[513]}]);
132190
132244
  const EzPopover = /*@__PURE__*/proxyCustomElement(EzPopover$1, [1,"ez-popover",{"autoClose":[516,"auto-close"],"boxWidth":[513,"box-width"],"opened":[1540],"innerElement":[1537,"inner-element"],"overlayType":[513,"overlay-type"]}]);
132191
132245
  const EzPopup = /*@__PURE__*/proxyCustomElement(EzPopup$1, [1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[516,"use-header"],"heightMode":[513,"height-mode"],"ezTitle":[1,"ez-title"]}]);
132192
132246
  const EzRadioButton = /*@__PURE__*/proxyCustomElement(EzRadioButton$1, [1,"ez-radio-button",{"value":[1544],"options":[1040],"enabled":[516],"label":[513],"direction":[1537]}]);
@@ -55,9 +55,8 @@ const buildFile = ({ name, label, readOnly, contextName, props }) => {
55
55
  };
56
56
 
57
57
  const buildDecimal = ({ name, label, readOnly, props, contextName, canShowError }) => {
58
- var _a, _b;
59
- const precision = Number((_a = props === null || props === void 0 ? void 0 : props.precision) !== null && _a !== void 0 ? _a : 2);
60
- const prettyPrecision = Number((_b = props === null || props === void 0 ? void 0 : props.prettyPrecision) !== null && _b !== void 0 ? _b : precision);
58
+ const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
59
+ const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
61
60
  return buildNumeric(name, label, readOnly, precision, prettyPrecision, contextName, canShowError);
62
61
  };
63
62
  const buildInteger = ({ name, label, readOnly, contextName, canShowError }) => {
@@ -165,7 +164,7 @@ const EzFormView = class {
165
164
  */
166
165
  async setFieldProp(fieldName, propName, value) {
167
166
  const fields = this.fields.map(field => {
168
- if (field.name === fieldName && (value || value === 0)) {
167
+ if (field.name === fieldName) {
169
168
  field.props = field.props || {};
170
169
  field.props[propName] = value;
171
170
  }
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, f as forceUpdate, H as Host, g as getElement } from './index-baa5e267.js';
2
- import { DateUtils, Action, WaitingChangeException, ApplicationContext, DataUnitAction, StringUtils, DataUnit, ElementIDUtils } from '@sankhyalabs/core';
2
+ import { DateUtils, Action, ApplicationContext, WaitingChangeException, DataUnitAction, StringUtils, DataUnit, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { b as buildFieldMetadata, R as RecordValidationProcessor } from './RecordValidationProcessor-b00b8b77.js';
4
4
  import './ApplicationUtils-eaf91331.js';
5
5
  import './DialogType-54a62731.js';
@@ -214,6 +214,13 @@ class DataBinder {
214
214
  this.applyDefaultValues();
215
215
  this._dataUnit.subscribe(this.onDataUnitEvent);
216
216
  this._dataUnit.addInterceptor(this);
217
+ this.setContextDataBinder(dataUnit);
218
+ }
219
+ setContextDataBinder(dataUnit) {
220
+ const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
221
+ const dataBinders = [...(dataBindersByDataUnit.get(dataUnit.dataUnitId) || []), this];
222
+ dataBindersByDataUnit.set(dataUnit.dataUnitId, dataBinders);
223
+ ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
217
224
  }
218
225
  applyDefaultValues() {
219
226
  const recordIds = (this._dataUnit.getAddedRecords() || []).map(r => r.__record__id__);
@@ -240,9 +247,17 @@ class DataBinder {
240
247
  getMessageForField: field => this.getErrorMessage(field)
241
248
  }, recordsValidator);
242
249
  }
250
+ disconnectDataUnit() {
251
+ const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
252
+ const dataBinders = dataBindersByDataUnit.get(this._dataUnit.dataUnitId);
253
+ const dataBindersFiltered = dataBinders.filter((dataBinder) => JSON.stringify(dataBinder) !== JSON.stringify(this));
254
+ dataBindersByDataUnit.set(this._dataUnit.dataUnitId, dataBindersFiltered);
255
+ ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
256
+ }
243
257
  onDisconnectedCallback() {
244
258
  this._dataUnit.unsubscribe(this.onDataUnitEvent);
245
259
  this._dataUnit.removeInterceptor(this);
260
+ this.disconnectDataUnit();
246
261
  }
247
262
  getCurrentRecordId() {
248
263
  const record = this._dataUnit.getSelectedRecord();
@@ -289,6 +304,17 @@ class DataBinder {
289
304
  validate() {
290
305
  return this._recordValidatorProcessor.validate();
291
306
  }
307
+ static async validateByDataunit(dataUnit) {
308
+ try {
309
+ const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__");
310
+ const dataBinders = dataBindersByDataUnit.get(dataUnit.dataUnitId) || [];
311
+ await Promise.all(dataBinders.map((dataBinder) => dataBinder.validate()));
312
+ return true;
313
+ }
314
+ catch (_a) {
315
+ return false;
316
+ }
317
+ }
292
318
  updateErrorMessage(fieldName, field, message) {
293
319
  if (message == undefined) {
294
320
  message = this._dataUnit.getInvalidMessage(this.getCurrentRecordId(), fieldName);
@@ -118929,6 +118929,7 @@ class DataSource {
118929
118929
  else {
118930
118930
  this._controller.selectRows(selectionInfo.recordIds, true);
118931
118931
  }
118932
+ this._controller.setFocusFirstRow();
118932
118933
  }
118933
118934
  getRows(params) {
118934
118935
  if (this.needReload(params)) {
@@ -119315,9 +119316,8 @@ const buildDateTime = ({ readOnly }) => {
119315
119316
  };
119316
119317
 
119317
119318
  const buildDecimal = ({ readOnly, props }) => {
119318
- var _a, _b;
119319
- const precision = Number((_a = props === null || props === void 0 ? void 0 : props.precision) !== null && _a !== void 0 ? _a : 2);
119320
- const prettyPrecision = Number((_b = props === null || props === void 0 ? void 0 : props.prettyPrecision) !== null && _b !== void 0 ? _b : precision);
119319
+ const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
119320
+ const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
119321
119321
  return buildNumeric(readOnly, precision, prettyPrecision);
119322
119322
  };
119323
119323
  const buildInteger = ({ readOnly }) => {
@@ -119947,6 +119947,7 @@ class AgGridController {
119947
119947
  }
119948
119948
  initDatagrid(container, options) {
119949
119949
  var _a;
119950
+ this._container = container;
119950
119951
  if (this._grid === undefined) {
119951
119952
  LicenseManager.setLicenseKey(ApplicationContext.getContextValue('__EZUI__GRID_LICENSE__'));
119952
119953
  this._columnStateChangeCallback = options.onColumnStateChange;
@@ -120301,11 +120302,27 @@ class AgGridController {
120301
120302
  }
120302
120303
  this._gridOptions.api.refreshServerSide({ purge: true });
120303
120304
  }
120305
+ focusOnGridContainer() {
120306
+ this._container.setAttribute('tabindex', '-1');
120307
+ this._container.focus();
120308
+ }
120309
+ setFocus() {
120310
+ var _a, _b;
120311
+ if ((_b = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b.length) {
120312
+ this.setFocusFirstRow();
120313
+ }
120314
+ else {
120315
+ this.focusOnGridContainer();
120316
+ }
120317
+ }
120304
120318
  setFocusFirstRow() {
120305
120319
  const firstRow = this._gridOptions.api.getDisplayedRowAtIndex(0);
120306
120320
  if (firstRow) {
120307
120321
  this.setFocusOnRow(firstRow.rowIndex);
120308
120322
  }
120323
+ else {
120324
+ this.focusOnGridContainer();
120325
+ }
120309
120326
  }
120310
120327
  setFocusLastRow() {
120311
120328
  const lastRow = this._gridOptions.api.getDisplayedRowAtIndex(this._gridOptions.api.getLastDisplayedRow());
@@ -120909,7 +120926,7 @@ class InMemoryFilterColumnDataSource {
120909
120926
  }
120910
120927
  }
120911
120928
 
120912
- const ezGridCss = ".sc-ez-grid-h{display:grid;grid-template-rows:auto 1fr auto;height:100%;width:100%;--ez-grid__header--background-color:var(--background--xlight, #FFF);--ez-grid__selection-counter--z-index:var(--visible, 1);--ez-grid__container--shadow:0 0 16px 0 rgb(0 38 111 / 12%);--ez-grid--min-height:300px;min-height:var(--ez-grid--min-height)}.grid-header.sc-ez-grid{display:grid;justify-content:space-between;align-items:center;grid-row-start:1;grid-template-columns:1fr;background-color:var(--ez-grid__header--background-color, #FFF)}.grid__container.sc-ez-grid{padding-top:15px;margin-top:-12px;box-shadow:var(--ez-grid__container--shadow);background-color:var(--ez-grid__header--background-color)}.grid-header__popover.sc-ez-grid{position:relative;top:var(--space--sm, 16px)}.grid-header__container.sc-ez-grid{display:flex;align-items:center}.grid-header__position.sc-ez-grid{display:flex;align-items:center;justify-content:space-between}.grid__selection-counter.sc-ez-grid{position:fixed;white-space:nowrap;transform:translate(-50%, 0px);left:50%;opacity:0;bottom:-100%;transition:opacity 0.1s, bottom 0.5s}.grid__selection-counter--opened.sc-ez-grid{opacity:1;bottom:0px}.grid__btn-close.sc-ez-grid{display:flex;align-items:center;justify-content:center;padding:0;outline:none;width:20px;height:20px;border:none;background-color:unset;cursor:pointer}.grid__btn-clear.sc-ez-grid{--ez-button--link-color:var(--color--alert-warning-900, #8C6B00);--ez-button--link--hover-color:var(--color--alert-warning-900, #8C6B00)}[no-header].sc-ez-grid-h .grid-header.sc-ez-grid{height:0;padding:0}.grid-header__pagination.sc-ez-grid{width:30%;min-width:100px;justify-content:flex-end;flex-wrap:wrap}.grid-header__left-container.sc-ez-grid{width:70%}.grid-header__pagination-label.sc-ez-grid{width:100%;white-space:nowrap}.overflowed.sc-ez-grid{display:none}";
120929
+ const ezGridCss = ".sc-ez-grid-h{display:grid;grid-template-rows:auto 1fr auto;height:100%;width:100%;--ez-grid__header--background-color:var(--background--xlight, #FFF);--ez-grid__selection-counter--z-index:var(--visible, 1);--ez-grid__container--shadow:0 0 16px 0 rgb(0 38 111 / 12%);--ez-grid--min-height:300px;min-height:var(--ez-grid--min-height)}.grid-header.sc-ez-grid{display:grid;justify-content:space-between;align-items:center;grid-row-start:1;grid-template-columns:1fr;background-color:var(--ez-grid__header--background-color, #FFF)}.grid__container.sc-ez-grid{padding-top:15px;margin-top:-12px;outline:none;box-shadow:var(--ez-grid__container--shadow);background-color:var(--ez-grid__header--background-color)}.grid-header__popover.sc-ez-grid{position:relative;top:var(--space--sm, 16px)}.grid-header__container.sc-ez-grid{display:flex;align-items:center}.grid-header__position.sc-ez-grid{display:flex;align-items:center;justify-content:space-between}.grid__selection-counter.sc-ez-grid{position:fixed;white-space:nowrap;transform:translate(-50%, 0px);left:50%;opacity:0;bottom:-100%;transition:opacity 0.1s, bottom 0.5s}.grid__selection-counter--opened.sc-ez-grid{opacity:1;bottom:0px}.grid__btn-close.sc-ez-grid{display:flex;align-items:center;justify-content:center;padding:0;outline:none;width:20px;height:20px;border:none;background-color:unset;cursor:pointer}.grid__btn-clear.sc-ez-grid{--ez-button--link-color:var(--color--alert-warning-900, #8C6B00);--ez-button--link--hover-color:var(--color--alert-warning-900, #8C6B00)}[no-header].sc-ez-grid-h .grid-header.sc-ez-grid{height:0;padding:0}.grid-header__pagination.sc-ez-grid{width:30%;min-width:100px;justify-content:flex-end;flex-wrap:wrap}.grid-header__left-container.sc-ez-grid{width:70%}.grid-header__pagination-label.sc-ez-grid{width:100%;white-space:nowrap}.overflowed.sc-ez-grid{display:none}";
120913
120930
 
120914
120931
  const windowInstace = window;
120915
120932
  const matches = (text, filter) => {
@@ -121065,6 +121082,12 @@ const EzGrid = class {
121065
121082
  async getCustomValueFormatter(columnName) {
121066
121083
  return this._customFormatters.get(columnName);
121067
121084
  }
121085
+ /**
121086
+ * Atribui o foco para a grade.
121087
+ */
121088
+ async setFocus() {
121089
+ this._gridController.setFocus();
121090
+ }
121068
121091
  observeConfig(config) {
121069
121092
  this._gridController.setColumnsState(config === null || config === void 0 ? void 0 : config.columns);
121070
121093
  }
@@ -13,7 +13,6 @@ const EzNumberInput = class {
13
13
  this._focused = false;
14
14
  this._changePending = false;
15
15
  this._valuePromiseCallbacks = [];
16
- this._value = undefined;
17
16
  this.label = undefined;
18
17
  this.value = undefined;
19
18
  this.enabled = true;
@@ -69,7 +68,24 @@ const EzNumberInput = class {
69
68
  }
70
69
  observeValue(newValue, oldValue) {
71
70
  if (this._textInput && newValue != oldValue) {
72
- this.handleNewValue(newValue, oldValue);
71
+ const newValueValidated = this.validateValue(newValue);
72
+ const oldValueValidated = this.validateValue(oldValue);
73
+ if (newValueValidated === null) {
74
+ this._textInput.value = '';
75
+ }
76
+ if (newValueValidated != oldValueValidated) {
77
+ const textValue = this.getTextValue(newValueValidated) || '';
78
+ if ((this._textInput.value || '') !== textValue) {
79
+ const parsedNumber = this.getParsedNumber(textValue);
80
+ if (parsedNumber !== undefined || !this._focused) {
81
+ this._textInput.value = textValue;
82
+ this._focused = false;
83
+ this.errorMessage = "";
84
+ }
85
+ }
86
+ const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
87
+ this.ezChange.emit(valueEmitted);
88
+ }
73
89
  }
74
90
  this._changePending = false;
75
91
  }
@@ -78,31 +94,12 @@ const EzNumberInput = class {
78
94
  this.setInputValue();
79
95
  }
80
96
  }
81
- handleNewValue(newValue, oldValue) {
82
- const newValueValidated = this.validateValue(newValue);
83
- const oldValueValidated = this.validateValue(oldValue);
84
- if (newValueValidated === null) {
85
- this._value = '';
86
- }
87
- if (newValueValidated === oldValueValidated) {
88
- return;
89
- }
90
- const textValue = this.getTextValue(newValueValidated) || '';
91
- const parsedNumber = this.getParsedNumber(textValue);
92
- if ((this._value || '') !== textValue && (parsedNumber !== undefined || !this._focused)) {
93
- this._value = textValue;
94
- this._focused = false;
95
- this.errorMessage = "";
96
- }
97
- const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
98
- this.ezChange.emit(valueEmitted);
99
- }
100
97
  validateValue(value) {
101
98
  return isNaN(value) || value === undefined ? null : value;
102
99
  }
103
100
  getTextValue(value) {
104
101
  if (value != undefined) {
105
- return this.precision >= 0 ? NumberUtils.format(value.toString(), Number(this.precision), Number(this.prettyPrecision)) : value.toString();
102
+ return this.precision > 0 ? NumberUtils.format(value.toString(), Number(this.precision), Number(this.prettyPrecision)) : value.toString();
106
103
  }
107
104
  return undefined;
108
105
  }
@@ -155,13 +152,17 @@ const EzNumberInput = class {
155
152
  this.ezStartChange.emit({ waitmessage: "", blocking: false });
156
153
  }
157
154
  }
158
- getParsedNumber(value = this._value) {
155
+ getParsedNumber(value) {
156
+ var _a;
157
+ if (value === void 0) {
158
+ value = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value;
159
+ }
159
160
  return (value === null || value === void 0 ? void 0 : value.trim()) ? NumberUtils.stringToNumber(value) : undefined;
160
161
  }
161
162
  setInputValue() {
162
163
  const textValue = this.getTextValue(this.value) || '';
163
- if ((this._value || '') !== textValue) {
164
- this._value = textValue;
164
+ if ((this._textInput.value || '') !== textValue) {
165
+ this._textInput.value = textValue;
165
166
  }
166
167
  }
167
168
  componentDidLoad() {
@@ -170,7 +171,7 @@ const EzNumberInput = class {
170
171
  }
171
172
  render() {
172
173
  ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
173
- return (h("ez-text-input", { class: "number__input", "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, canShowError: this.canShowError, value: this._value }));
174
+ return (h("ez-text-input", { class: "number__input", "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, canShowError: this.canShowError }));
174
175
  }
175
176
  get _elem() { return getElement(this); }
176
177
  static get watchers() { return {