@sankhyalabs/ezui 1.1.140 → 1.1.143

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 (60) hide show
  1. package/dist/cjs/ez-date-input.cjs.entry.js +16 -5
  2. package/dist/cjs/ez-date-time-input.cjs.entry.js +7 -1
  3. package/dist/cjs/ez-form.cjs.entry.js +57 -12
  4. package/dist/cjs/ez-grid.cjs.entry.js +3 -0
  5. package/dist/cjs/ez-number-input.cjs.entry.js +8 -1
  6. package/dist/cjs/ez-text-area.cjs.entry.js +35 -22
  7. package/dist/cjs/ez-text-input.cjs.entry.js +11 -9
  8. package/dist/cjs/ez-time-input.cjs.entry.js +5 -0
  9. package/dist/cjs/ez-upload.cjs.entry.js +28 -9
  10. package/dist/collection/components/ez-date-input/ez-date-input.js +49 -5
  11. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +40 -1
  12. package/dist/collection/components/ez-form/DataBinder.js +54 -8
  13. package/dist/collection/components/ez-form/ez-form.js +0 -1
  14. package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +4 -4
  15. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +5 -2
  16. package/dist/collection/components/ez-number-input/ez-number-input.js +41 -1
  17. package/dist/collection/components/ez-text-area/ez-text-area.js +35 -22
  18. package/dist/collection/components/ez-text-input/ez-text-input.js +11 -9
  19. package/dist/collection/components/ez-time-input/ez-time-input.js +38 -0
  20. package/dist/collection/components/ez-upload/RemoteFile.js +6 -1
  21. package/dist/collection/components/ez-upload/ez-upload.js +36 -8
  22. package/dist/custom-elements/index.js +171 -60
  23. package/dist/esm/ez-date-input.entry.js +16 -5
  24. package/dist/esm/ez-date-time-input.entry.js +7 -1
  25. package/dist/esm/ez-form.entry.js +58 -13
  26. package/dist/esm/ez-grid.entry.js +4 -1
  27. package/dist/esm/ez-number-input.entry.js +8 -1
  28. package/dist/esm/ez-text-area.entry.js +35 -22
  29. package/dist/esm/ez-text-input.entry.js +11 -9
  30. package/dist/esm/ez-time-input.entry.js +5 -0
  31. package/dist/esm/ez-upload.entry.js +28 -9
  32. package/dist/ezui/ezui.esm.js +1 -1
  33. package/dist/ezui/p-140f7085.entry.js +1 -0
  34. package/dist/ezui/p-24e98dc1.entry.js +1 -0
  35. package/dist/ezui/p-49fdfa4b.entry.js +1 -0
  36. package/dist/ezui/p-4fdceb7d.entry.js +1 -0
  37. package/dist/ezui/{p-9ce93746.entry.js → p-6816c9ee.entry.js} +5 -5
  38. package/dist/ezui/p-7746460e.entry.js +1 -0
  39. package/dist/ezui/p-8639fc8c.entry.js +1 -0
  40. package/dist/ezui/p-b524dfca.entry.js +1 -0
  41. package/dist/ezui/p-ec21ecce.entry.js +1 -0
  42. package/dist/types/components/ez-date-input/ez-date-input.d.ts +12 -1
  43. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +11 -0
  44. package/dist/types/components/ez-form/DataBinder.d.ts +1 -0
  45. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +1 -0
  46. package/dist/types/components/ez-number-input/ez-number-input.d.ts +11 -0
  47. package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -3
  48. package/dist/types/components/ez-text-input/ez-text-input.d.ts +1 -1
  49. package/dist/types/components/ez-time-input/ez-time-input.d.ts +10 -0
  50. package/dist/types/components/ez-upload/ez-upload.d.ts +5 -0
  51. package/dist/types/components.d.ts +36 -0
  52. package/package.json +1 -1
  53. package/dist/ezui/p-248361f5.entry.js +0 -1
  54. package/dist/ezui/p-347b145b.entry.js +0 -1
  55. package/dist/ezui/p-9b82c2fe.entry.js +0 -1
  56. package/dist/ezui/p-b8d64970.entry.js +0 -1
  57. package/dist/ezui/p-c620258b.entry.js +0 -1
  58. package/dist/ezui/p-cb73bee7.entry.js +0 -1
  59. package/dist/ezui/p-db0981c1.entry.js +0 -1
  60. package/dist/ezui/p-ec8419f1.entry.js +0 -1
@@ -1,6 +1,6 @@
1
1
  import { HTMLElement as HTMLElement$1, createEvent, h, forceUpdate, Host, proxyCustomElement } from '@stencil/core/internal/client';
2
2
  export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
3
- import { FloatingManager, DateUtils, TimeFormatter, UserInterface, Action, ApplicationContext, DataUnitAction, DataUnit, NumberUtils, DataType, StringUtils, MaskFormatter } from '@sankhyalabs/core';
3
+ import { FloatingManager, DateUtils, TimeFormatter, UserInterface, Action, WaitingChangeException, ApplicationContext, DataUnitAction, DataUnit, NumberUtils, DataType, StringUtils, MaskFormatter } from '@sankhyalabs/core';
4
4
  import { UserInterface as UserInterface$1, SortMode } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
5
5
 
6
6
  const ezApplicationCss = "";
@@ -844,6 +844,8 @@ let EzDateInput$1 = class extends HTMLElement$1 {
844
844
  this.__registerHost();
845
845
  this.__attachShadow();
846
846
  this.ezChange = createEvent(this, "ezChange", 7);
847
+ this.ezStartChange = createEvent(this, "ezStartChange", 7);
848
+ this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
847
849
  /**
848
850
  * Deixa o campo disponível ou não para uso.
849
851
  */
@@ -857,11 +859,16 @@ let EzDateInput$1 = class extends HTMLElement$1 {
857
859
  this._textInput.label = this.label;
858
860
  }
859
861
  observeErrorMessage() {
860
- this._textInput.errorMessage = this.errorMessage;
861
- }
862
- observeValue() {
863
862
  if (this._textInput) {
864
- this._textInput.value = this.getTextValue(this.value);
863
+ this._textInput.errorMessage = this.errorMessage;
864
+ }
865
+ }
866
+ observeValue(newValue, oldValue) {
867
+ if (newValue != oldValue) {
868
+ if (this._textInput) {
869
+ this.errorMessage = "";
870
+ this._textInput.value = this.getTextValue(this.value);
871
+ }
865
872
  }
866
873
  }
867
874
  /**
@@ -911,12 +918,16 @@ let EzDateInput$1 = class extends HTMLElement$1 {
911
918
  }
912
919
  }
913
920
  else {
921
+ this.ezCancelWaitingChange.emit();
914
922
  this._textInput.errorMessage = "O valor digitado não é uma data válida";
915
923
  }
916
924
  }
917
925
  getTextValue(d) {
918
926
  return d ? new Intl.DateTimeFormat("pt-BR").format(d) : undefined;
919
927
  }
928
+ startChange() {
929
+ this.ezStartChange.emit({ waitmessage: "", blocking: false });
930
+ }
920
931
  componentDidLoad() {
921
932
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
922
933
  }
@@ -924,7 +935,7 @@ let EzDateInput$1 = class extends HTMLElement$1 {
924
935
  return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
925
936
  if (event.key === "H" || event.key === "h")
926
937
  this.changeValue(new Date());
927
- }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
938
+ }, label: this.label, value: this.getTextValue(this.value), onInput: () => this.startChange(), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
928
939
  }
929
940
  get _elem() { return this; }
930
941
  static get watchers() { return {
@@ -943,6 +954,8 @@ let EzDateTimeInput$1 = class extends HTMLElement$1 {
943
954
  this.__registerHost();
944
955
  this.__attachShadow();
945
956
  this.ezChange = createEvent(this, "ezChange", 7);
957
+ this.ezStartChange = createEvent(this, "ezStartChange", 7);
958
+ this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
946
959
  /**
947
960
  * Deixa o campo disponível ou não para uso.
948
961
  */
@@ -1048,6 +1061,7 @@ let EzDateTimeInput$1 = class extends HTMLElement$1 {
1048
1061
  }
1049
1062
  }
1050
1063
  else {
1064
+ this.ezCancelWaitingChange.emit();
1051
1065
  this._textInput.errorMessage = "O valor digitado não é uma data válida";
1052
1066
  }
1053
1067
  }
@@ -1062,11 +1076,14 @@ let EzDateTimeInput$1 = class extends HTMLElement$1 {
1062
1076
  };
1063
1077
  return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : undefined;
1064
1078
  }
1079
+ startChange() {
1080
+ this.ezStartChange.emit({ waitmessage: "", blocking: false });
1081
+ }
1065
1082
  componentDidLoad() {
1066
1083
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
1067
1084
  }
1068
1085
  render() {
1069
- return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onFocus: () => this.onFocused(), onClick: () => this.onClicked(), slaveMode: true }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
1086
+ return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onInput: () => this.startChange(), onFocus: () => this.onFocused(), onClick: () => this.onClicked(), slaveMode: true }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
1070
1087
  }
1071
1088
  get _elem() { return this; }
1072
1089
  static get watchers() { return {
@@ -1407,7 +1424,7 @@ const buildFromDataUnit = (dataUnit) => {
1407
1424
  .filter(descriptor => descriptor.required)
1408
1425
  .map(descriptor => descriptor.name),
1409
1426
  cleanOnCopyFields: visibleFields
1410
- .filter(descriptor => { var _a; return (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy; })
1427
+ .filter(descriptor => { var _a, _b; return ((_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy) || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum); })
1411
1428
  .map(descriptor => descriptor.name),
1412
1429
  defaultValues
1413
1430
  });
@@ -1427,7 +1444,7 @@ const buildFromConfig = (fields, dataUnit) => {
1427
1444
  const cleanOnCopyFields = [];
1428
1445
  const defaultValues = {};
1429
1446
  fields.forEach(config => {
1430
- var _a, _b;
1447
+ var _a, _b, _c;
1431
1448
  if (config.visible !== false) {
1432
1449
  const tabConfig = getTabConfig(config.tab || "Geral", sheets);
1433
1450
  const descriptor = dataUnit.getField(config.name);
@@ -1440,11 +1457,11 @@ const buildFromConfig = (fields, dataUnit) => {
1440
1457
  if (isRequired) {
1441
1458
  requiredFields.push(config.name);
1442
1459
  }
1443
- const clearOnCopy = config.cleanOnCopy === undefined ? (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy : config.cleanOnCopy;
1460
+ const clearOnCopy = config.cleanOnCopy === undefined ? (((_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy) || ((_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.autoNum)) : config.cleanOnCopy;
1444
1461
  if (clearOnCopy) {
1445
1462
  cleanOnCopyFields.push(config.name);
1446
1463
  }
1447
- const defaultValue = config.defaultValue === undefined ? (_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.defaultValue : config.defaultValue;
1464
+ const defaultValue = config.defaultValue === undefined ? (_c = descriptor.properties) === null || _c === void 0 ? void 0 : _c.defaultValue : config.defaultValue;
1448
1465
  if (defaultValue) {
1449
1466
  defaultValues[config.name] = config.defaultValue;
1450
1467
  }
@@ -1880,11 +1897,7 @@ class DataBinder {
1880
1897
  this._dataUnit.unsubscribe(this.onDataUnitEvent);
1881
1898
  }
1882
1899
  updateValue(fieldName, field) {
1883
- const oldValue = field["value"];
1884
- const newValue = this._dataUnit.getFieldValue(fieldName);
1885
- if (oldValue != newValue) {
1886
- field["value"] = newValue;
1887
- }
1900
+ field["value"] = this._dataUnit.getFieldValue(fieldName);
1888
1901
  }
1889
1902
  updateBind(fieldName, field) {
1890
1903
  const oldBind = this._fields.get(fieldName);
@@ -1892,21 +1905,53 @@ class DataBinder {
1892
1905
  oldBind.destroy();
1893
1906
  }
1894
1907
  field["value"] = this._dataUnit.getFieldValue(fieldName);
1895
- this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
1908
+ this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName) => this.cancelWaitingChange(fieldName), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
1896
1909
  this.bindSearchOptionsLoader(fieldName, field);
1897
1910
  this.applyEzUploadContext(fieldName, field);
1898
1911
  }
1899
1912
  changeStarted(fieldName, waitingChange) {
1913
+ /**
1914
+ * se o waitingChange não é blocante, add um event listener pra
1915
+ * fazer o accept da promise
1916
+ *
1917
+ * se não tiver promise no waitingChange, eu crio uma e resolvo no bind
1918
+ *
1919
+ *
1920
+ */
1900
1921
  if (this._dataUnit.records.length === 0) {
1901
1922
  this._dataUnit.addRecord();
1902
1923
  }
1924
+ if (!waitingChange.blocking && waitingChange.promise == undefined) {
1925
+ const bind = this._fields.get(fieldName);
1926
+ if (bind) {
1927
+ waitingChange.promise = new Promise((resolve, reject) => {
1928
+ bind.waitingChangePromiseResolve = resolve;
1929
+ bind.waitingChangePromiseReject = reject;
1930
+ });
1931
+ }
1932
+ }
1903
1933
  this._dataUnit.startChange(fieldName, waitingChange);
1904
1934
  }
1935
+ cancelWaitingChange(fieldName) {
1936
+ if (this._dataUnit.waitingForChange(fieldName)) {
1937
+ this._dataUnit.cancelWaitingChange(fieldName);
1938
+ const bind = this._fields.get(fieldName);
1939
+ if (bind) {
1940
+ bind.rejectWaitingChange(new WaitingChangeException("Change canceled", fieldName));
1941
+ }
1942
+ }
1943
+ }
1905
1944
  setFieldValue(fieldName, newValue) {
1906
1945
  if (this._dataUnit.records.length === 0) {
1907
1946
  this._dataUnit.addRecord();
1908
1947
  }
1909
1948
  this._dataUnit.setFieldValue(fieldName, newValue);
1949
+ if (this._dataUnit.waitingForChange(fieldName)) {
1950
+ const bind = this._fields.get(fieldName);
1951
+ if (bind) {
1952
+ bind.acceptWaitingChange();
1953
+ }
1954
+ }
1910
1955
  }
1911
1956
  bindSearchOptionsLoader(fieldName, field) {
1912
1957
  if (field.nodeName === "EZ-SEARCH" && field["optionLoader"] == undefined) {
@@ -1935,18 +1980,36 @@ class DataBinder {
1935
1980
  class Bind {
1936
1981
  constructor() {
1937
1982
  this.startChangeEventName = "ezStartChange";
1983
+ this.cancelWaitingChangeEventName = "ezCancelWaitingChange";
1938
1984
  this.changeEventName = "ezChange";
1939
1985
  }
1940
1986
  destroy() {
1941
1987
  this.field.removeEventListener(this.startChangeEventName, this.startChangeListener);
1988
+ this.field.removeEventListener(this.cancelWaitingChangeEventName, this.cancelWaitingChangeListener);
1942
1989
  this.field.removeEventListener(this.changeEventName, this.changeListener);
1943
1990
  }
1944
- static create(fieldName, field, startChangeCallback, changeCallback) {
1991
+ acceptWaitingChange() {
1992
+ if (this.waitingChangePromiseResolve) {
1993
+ this.waitingChangePromiseResolve();
1994
+ this.waitingChangePromiseReject = undefined;
1995
+ this.waitingChangePromiseResolve = undefined;
1996
+ }
1997
+ }
1998
+ rejectWaitingChange(reason) {
1999
+ if (this.waitingChangePromiseReject) {
2000
+ this.waitingChangePromiseReject(reason);
2001
+ this.waitingChangePromiseReject = undefined;
2002
+ this.waitingChangePromiseResolve = undefined;
2003
+ }
2004
+ }
2005
+ static create(fieldName, field, startChangeCallback, cancelWaitingChangeCallback, changeCallback) {
1945
2006
  const b = new Bind();
1946
2007
  b.field = field;
1947
2008
  b.fieldName = fieldName;
1948
2009
  b.startChangeListener = (evt) => { startChangeCallback(fieldName, evt.detail); };
1949
2010
  b.field.addEventListener(b.startChangeEventName, b.startChangeListener);
2011
+ b.cancelWaitingChangeListener = () => { cancelWaitingChangeCallback(fieldName); };
2012
+ b.field.addEventListener(b.cancelWaitingChangeEventName, b.cancelWaitingChangeListener);
1950
2013
  b.changeListener = (evt) => { changeCallback(fieldName, evt.detail); };
1951
2014
  b.field.addEventListener(b.changeEventName, b.changeListener);
1952
2015
  return b;
@@ -2091,7 +2154,6 @@ let EzForm$1 = class extends HTMLElement$1 {
2091
2154
  }
2092
2155
  }
2093
2156
  if (action.type === Action.RECORDS_ADDED) {
2094
- debugger;
2095
2157
  const metadata = selectFormMetadata(this._store.getState());
2096
2158
  const defaultValues = metadata.getDefaultValues();
2097
2159
  if (defaultValues) {
@@ -112198,6 +112260,7 @@ class AgGridController {
112198
112260
  this.DEFAULT_ROW_HEIGHT = 25;
112199
112261
  this.CHECK_BOX_COL_ID = "checkBoxColumn";
112200
112262
  this.RECORD_ARCHIVE_COL_ID = "__RECORD_ARCHIVE__";
112263
+ this.BLOCK_LOAD_DEBOUNCE = 400;
112201
112264
  this._menuItems = [];
112202
112265
  this._idAttribName = "__record__id__";
112203
112266
  this._isFirstRecordOfPage = true;
@@ -112221,6 +112284,7 @@ class AgGridController {
112221
112284
  ;
112222
112285
  initDatagrid(container, options) {
112223
112286
  if (this._grid === undefined) {
112287
+ agGridEnterprise_cjs.LicenseManager.setLicenseKey(ApplicationContext.getContextValue("__EZUI__GRID_LICENSE__"));
112224
112288
  this._columnStateChangeCallback = options.onColumnStateChange;
112225
112289
  this._selectionChangeCallback = options.onSelectionChange;
112226
112290
  this._paginationChangeCallback = options.onPaginationChange;
@@ -112240,6 +112304,7 @@ class AgGridController {
112240
112304
  rowSelection: this._multipleSelection ? "multiple" : "single",
112241
112305
  serverSideDatasource: this._dataSource,
112242
112306
  sortingOrder: ['desc', 'asc', null],
112307
+ blockLoadDebounceMillis: this.BLOCK_LOAD_DEBOUNCE,
112243
112308
  getRowNodeId: this._dataUnit ? (params) => typeof params === "string" ? params : params[this._idAttribName] : undefined,
112244
112309
  getMainMenuItems: (params) => {
112245
112310
  const column = params.column;
@@ -113637,6 +113702,8 @@ let EzNumberInput$1 = class extends HTMLElement$1 {
113637
113702
  this.__registerHost();
113638
113703
  this.__attachShadow();
113639
113704
  this.ezChange = createEvent(this, "ezChange", 7);
113705
+ this.ezStartChange = createEvent(this, "ezStartChange", 7);
113706
+ this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
113640
113707
  /**
113641
113708
  * Deixa o campo disponível ou não para uso.
113642
113709
  */
@@ -113686,6 +113753,7 @@ let EzNumberInput$1 = class extends HTMLElement$1 {
113686
113753
  parseNumber() {
113687
113754
  const parsedNumber = this._textInput.value ? NumberUtils.stringToNumber(this._textInput.value) : undefined;
113688
113755
  if (parsedNumber !== undefined && isNaN(parsedNumber)) {
113756
+ this.ezCancelWaitingChange.emit();
113689
113757
  this.errorMessage = "O valor digitado não é um número válido";
113690
113758
  }
113691
113759
  else {
@@ -113693,6 +113761,7 @@ let EzNumberInput$1 = class extends HTMLElement$1 {
113693
113761
  this.changeValue(parsedNumber);
113694
113762
  }
113695
113763
  catch (e) {
113764
+ this.ezCancelWaitingChange.emit();
113696
113765
  this.errorMessage = e.message;
113697
113766
  return;
113698
113767
  }
@@ -113704,11 +113773,14 @@ let EzNumberInput$1 = class extends HTMLElement$1 {
113704
113773
  }
113705
113774
  return undefined;
113706
113775
  }
113776
+ startChange() {
113777
+ this.ezStartChange.emit({ waitmessage: "", blocking: false });
113778
+ }
113707
113779
  componentDidLoad() {
113708
113780
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
113709
113781
  }
113710
113782
  render() {
113711
- return (h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseNumber(), label: this.label, value: this.getTextValue(this.value), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }));
113783
+ return (h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseNumber(), label: this.label, onInput: () => this.startChange(), value: this.getTextValue(this.value), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }));
113712
113784
  }
113713
113785
  get _elem() { return this; }
113714
113786
  static get watchers() { return {
@@ -114191,11 +114263,17 @@ let EzTextArea$1 = class extends HTMLElement$1 {
114191
114263
  (_b = this._messageBoxElem) === null || _b === void 0 ? void 0 : _b.classList.remove('hasError');
114192
114264
  }
114193
114265
  }
114194
- observeValue() {
114195
- this._inputElem.value = this.value == undefined ? "" : this.value;
114196
- this.handleChange();
114197
- this.adjustFloatingLabel();
114198
- this.ezChange.emit(this.value);
114266
+ observeValue(newValue, oldValue) {
114267
+ if (this._inputElem) {
114268
+ if (newValue != oldValue) {
114269
+ if (this.canChangeValue()) {
114270
+ this._inputElem.value = this.value || "";
114271
+ }
114272
+ this.adjustFloatingLabel();
114273
+ this.errorMessage = "";
114274
+ this.ezChange.emit(this.value);
114275
+ }
114276
+ }
114199
114277
  }
114200
114278
  observeMode() {
114201
114279
  if (this._initialRows == undefined) {
@@ -114213,6 +114291,27 @@ let EzTextArea$1 = class extends HTMLElement$1 {
114213
114291
  this._initialRows = rows;
114214
114292
  }
114215
114293
  }
114294
+ //---------------------------------------------
114295
+ // Public methods
114296
+ //---------------------------------------------
114297
+ /**
114298
+ * Faz o foco no componente de input
114299
+ */
114300
+ async setFocus() {
114301
+ this._inputElem.focus();
114302
+ }
114303
+ /**
114304
+ * Remove o foco no componente de input
114305
+ */
114306
+ async setBlur() {
114307
+ this._inputElem.blur();
114308
+ }
114309
+ //---------------------------------------------
114310
+ // Private methods
114311
+ //---------------------------------------------
114312
+ canChangeValue() {
114313
+ return this._inputElem && (this.value || "") !== this._inputElem.value;
114314
+ }
114216
114315
  adjustFloatingLabel() {
114217
114316
  if (this.label && this._labelElem) {
114218
114317
  const hasValue = this.value && this.value.toString().length > 0;
@@ -114233,21 +114332,6 @@ let EzTextArea$1 = class extends HTMLElement$1 {
114233
114332
  return this._hostElement.shadowRoot.activeElement !== null;
114234
114333
  }
114235
114334
  //---------------------------------------------
114236
- // Public methods
114237
- //---------------------------------------------
114238
- /**
114239
- * Faz o foco no componente de input
114240
- */
114241
- async setFocus() {
114242
- this._inputElem.focus();
114243
- }
114244
- /**
114245
- * Remove o foco no componente de input
114246
- */
114247
- async setBlur() {
114248
- this._inputElem.blur();
114249
- }
114250
- //---------------------------------------------
114251
114335
  // Event handlers
114252
114336
  //---------------------------------------------
114253
114337
  handleFocusout() {
@@ -114257,8 +114341,9 @@ let EzTextArea$1 = class extends HTMLElement$1 {
114257
114341
  }
114258
114342
  }
114259
114343
  handleChange() {
114260
- this.errorMessage = "";
114261
- this.value = this._inputElem.value;
114344
+ if (this.canChangeValue()) {
114345
+ this.value = this._inputElem.value;
114346
+ }
114262
114347
  }
114263
114348
  handleFocus() {
114264
114349
  if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
@@ -114341,17 +114426,19 @@ let EzTextInput$1 = class extends HTMLElement$1 {
114341
114426
  }
114342
114427
  }
114343
114428
  }
114344
- observeValue() {
114429
+ observeValue(newValue, oldValue) {
114345
114430
  if (this._inputElem) {
114346
- this._inputElem.value = this.value || "";
114347
- }
114348
- this.handleChange();
114349
- this.adjustFloatingLabel();
114350
- if (this.slaveMode) {
114351
- return;
114431
+ if (newValue != oldValue) {
114432
+ this._inputElem.value = this.value || "";
114433
+ this.handleChange();
114434
+ this.adjustFloatingLabel();
114435
+ if (this.slaveMode) {
114436
+ return;
114437
+ }
114438
+ this.errorMessage = "";
114439
+ this.ezChange.emit(this.value);
114440
+ }
114352
114441
  }
114353
- this.errorMessage = "";
114354
- this.ezChange.emit(this.value);
114355
114442
  }
114356
114443
  adjustFloatingLabel() {
114357
114444
  if (this.label && this._labelElem) {
@@ -114514,6 +114601,8 @@ let EzTimeInput$1 = class extends HTMLElement$1 {
114514
114601
  this.__registerHost();
114515
114602
  this.__attachShadow();
114516
114603
  this.ezChange = createEvent(this, "ezChange", 7);
114604
+ this.ezStartChange = createEvent(this, "ezStartChange", 7);
114605
+ this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
114517
114606
  /**
114518
114607
  * Deixa o campo disponível ou não para digitação.
114519
114608
  */
@@ -114574,10 +114663,12 @@ let EzTimeInput$1 = class extends HTMLElement$1 {
114574
114663
  this.prepareValue(this.viewValue);
114575
114664
  if (this.viewValue && !TimeFormatter.validateTime(this.viewValue, this.showSeconds)) {
114576
114665
  this._oldViewValue = this.viewValue;
114666
+ this.ezCancelWaitingChange.emit();
114577
114667
  this.errorMessage = "Favor inserir um horário válido.";
114578
114668
  }
114579
114669
  else {
114580
114670
  if (this.viewValue === this._oldViewValue) {
114671
+ this.ezCancelWaitingChange.emit();
114581
114672
  return;
114582
114673
  }
114583
114674
  this._oldViewValue = this.viewValue;
@@ -114596,6 +114687,7 @@ let EzTimeInput$1 = class extends HTMLElement$1 {
114596
114687
  }
114597
114688
  }
114598
114689
  handleChange() {
114690
+ this.ezStartChange.emit({ waitmessage: "", blocking: false });
114599
114691
  this.viewValue = this._inputElem.value;
114600
114692
  this.value = NumberUtils.stringToNumber(this.viewValue.replace(/\D/g, ""));
114601
114693
  }
@@ -114755,7 +114847,12 @@ class RemoteFile {
114755
114847
  }
114756
114848
  const response = xhr.response;
114757
114849
  if (response) {
114758
- resolve(JSON.parse(response));
114850
+ try {
114851
+ resolve(JSON.parse(response));
114852
+ }
114853
+ catch (error) {
114854
+ reject(`Servidor não retornou um objeto válido: ${response}.\n${error}`);
114855
+ }
114759
114856
  }
114760
114857
  }
114761
114858
  };
@@ -114809,6 +114906,7 @@ let EzUpload$1 = class extends HTMLElement$1 {
114809
114906
  this.__attachShadow();
114810
114907
  this.ezChange = createEvent(this, "ezChange", 7);
114811
114908
  this.ezStartChange = createEvent(this, "ezStartChange", 7);
114909
+ this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
114812
114910
  this._filePointers = new Map();
114813
114911
  /**
114814
114912
  * Deixa o campo disponível ou não para digitação.
@@ -114897,14 +114995,27 @@ let EzUpload$1 = class extends HTMLElement$1 {
114897
114995
  }
114898
114996
  }
114899
114997
  async doAddFile(file) {
114900
- if (this.validateFile(file)) {
114901
- this.ezStartChange.emit({ waitmessage: "Há arquivos sendo enviados. Por favor aguarde a conclusão ou cancele o envio." });
114902
- const uploadingFile = new RemoteFile(file);
114903
- this._filePointers.set(file.name, uploadingFile);
114904
- uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
114905
- .then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
114906
- .catch(msg => this.showError(msg));
114907
- forceUpdate(this);
114998
+ try {
114999
+ if (this.validateFile(file)) {
115000
+ this.ezStartChange.emit({ waitmessage: "Há arquivos sendo enviados. Por favor aguarde a conclusão ou cancele o envio.", blocking: true });
115001
+ const uploadingFile = new RemoteFile(file);
115002
+ const oldPointer = this._filePointers.get(file.name);
115003
+ if (oldPointer && this.isRemoteFile(oldPointer)) {
115004
+ oldPointer.abortUpload();
115005
+ }
115006
+ this._filePointers.set(file.name, uploadingFile);
115007
+ uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
115008
+ .then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
115009
+ .catch(msg => {
115010
+ this.ezCancelWaitingChange.emit();
115011
+ this.showError(msg);
115012
+ });
115013
+ forceUpdate(this);
115014
+ }
115015
+ }
115016
+ catch (error) {
115017
+ this.ezCancelWaitingChange.emit();
115018
+ throw error;
114908
115019
  }
114909
115020
  }
114910
115021
  finishUpload(ezFile) {
@@ -8,6 +8,8 @@ let EzDateInput = class {
8
8
  constructor(hostRef) {
9
9
  registerInstance(this, hostRef);
10
10
  this.ezChange = createEvent(this, "ezChange", 7);
11
+ this.ezStartChange = createEvent(this, "ezStartChange", 7);
12
+ this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
11
13
  /**
12
14
  * Deixa o campo disponível ou não para uso.
13
15
  */
@@ -21,11 +23,16 @@ let EzDateInput = class {
21
23
  this._textInput.label = this.label;
22
24
  }
23
25
  observeErrorMessage() {
24
- this._textInput.errorMessage = this.errorMessage;
25
- }
26
- observeValue() {
27
26
  if (this._textInput) {
28
- this._textInput.value = this.getTextValue(this.value);
27
+ this._textInput.errorMessage = this.errorMessage;
28
+ }
29
+ }
30
+ observeValue(newValue, oldValue) {
31
+ if (newValue != oldValue) {
32
+ if (this._textInput) {
33
+ this.errorMessage = "";
34
+ this._textInput.value = this.getTextValue(this.value);
35
+ }
29
36
  }
30
37
  }
31
38
  /**
@@ -75,12 +82,16 @@ let EzDateInput = class {
75
82
  }
76
83
  }
77
84
  else {
85
+ this.ezCancelWaitingChange.emit();
78
86
  this._textInput.errorMessage = "O valor digitado não é uma data válida";
79
87
  }
80
88
  }
81
89
  getTextValue(d) {
82
90
  return d ? new Intl.DateTimeFormat("pt-BR").format(d) : undefined;
83
91
  }
92
+ startChange() {
93
+ this.ezStartChange.emit({ waitmessage: "", blocking: false });
94
+ }
84
95
  componentDidLoad() {
85
96
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
86
97
  }
@@ -88,7 +99,7 @@ let EzDateInput = class {
88
99
  return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
89
100
  if (event.key === "H" || event.key === "h")
90
101
  this.changeValue(new Date());
91
- }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
102
+ }, label: this.label, value: this.getTextValue(this.value), onInput: () => this.startChange(), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
92
103
  }
93
104
  get _elem() { return getElement(this); }
94
105
  static get watchers() { return {
@@ -8,6 +8,8 @@ let EzDateTimeInput = class {
8
8
  constructor(hostRef) {
9
9
  registerInstance(this, hostRef);
10
10
  this.ezChange = createEvent(this, "ezChange", 7);
11
+ this.ezStartChange = createEvent(this, "ezStartChange", 7);
12
+ this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
11
13
  /**
12
14
  * Deixa o campo disponível ou não para uso.
13
15
  */
@@ -113,6 +115,7 @@ let EzDateTimeInput = class {
113
115
  }
114
116
  }
115
117
  else {
118
+ this.ezCancelWaitingChange.emit();
116
119
  this._textInput.errorMessage = "O valor digitado não é uma data válida";
117
120
  }
118
121
  }
@@ -127,11 +130,14 @@ let EzDateTimeInput = class {
127
130
  };
128
131
  return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : undefined;
129
132
  }
133
+ startChange() {
134
+ this.ezStartChange.emit({ waitmessage: "", blocking: false });
135
+ }
130
136
  componentDidLoad() {
131
137
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
132
138
  }
133
139
  render() {
134
- return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onFocus: () => this.onFocused(), onClick: () => this.onClicked(), slaveMode: true }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
140
+ return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onInput: () => this.startChange(), onFocus: () => this.onFocused(), onClick: () => this.onClicked(), slaveMode: true }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
135
141
  }
136
142
  get _elem() { return getElement(this); }
137
143
  static get watchers() { return {