@sankhyalabs/ezui 1.1.131 → 1.1.134

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 (44) hide show
  1. package/dist/cjs/ez-form.cjs.entry.js +14 -3
  2. package/dist/cjs/ez-grid.cjs.entry.js +215 -51
  3. package/dist/cjs/ez-list.cjs.entry.js +11 -0
  4. package/dist/cjs/ez-time-input.cjs.entry.js +1 -2
  5. package/dist/cjs/ezui.cjs.js +1 -1
  6. package/dist/cjs/grid-config.cjs.entry.js +64 -4
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/collection/components/ez-form/DataBinder.js +13 -2
  9. package/dist/collection/components/ez-form/ez-form.js +1 -1
  10. package/dist/collection/components/ez-grid/controller/DataUnitBridge.js +10 -5
  11. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +128 -36
  12. package/dist/collection/components/ez-grid/ez-grid.js +253 -15
  13. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.js +44 -2
  14. package/dist/collection/components/ez-list/ez-list.js +27 -0
  15. package/dist/collection/components/ez-time-input/ez-time-input.js +1 -2
  16. package/dist/collection/utils/interfaces/PageableComponent.js +1 -0
  17. package/dist/custom-elements/index.js +305 -78
  18. package/dist/esm/ez-form.entry.js +14 -3
  19. package/dist/esm/ez-grid.entry.js +216 -52
  20. package/dist/esm/ez-list.entry.js +11 -0
  21. package/dist/esm/ez-time-input.entry.js +1 -2
  22. package/dist/esm/ezui.js +1 -1
  23. package/dist/esm/grid-config.entry.js +64 -4
  24. package/dist/esm/loader.js +1 -1
  25. package/dist/ezui/ezui.esm.js +1 -1
  26. package/dist/ezui/{p-2d165ca8.entry.js → p-80d863c2.entry.js} +7 -7
  27. package/dist/ezui/p-bb7ad4ae.entry.js +1 -0
  28. package/dist/ezui/{p-47fe4273.entry.js → p-cfa7378a.entry.js} +1 -1
  29. package/dist/ezui/p-d9bb2a96.entry.js +1 -0
  30. package/dist/ezui/p-f1a18697.entry.js +1 -0
  31. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +46 -0
  32. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +12 -0
  33. package/dist/types/components/ez-grid/ez-grid.d.ts +45 -4
  34. package/dist/types/components/ez-grid/subcomponents/gridconfig/grid-config.d.ts +1 -0
  35. package/dist/types/components/ez-list/ez-list.d.ts +4 -0
  36. package/dist/types/components.d.ts +45 -0
  37. package/dist/types/utils/interfaces/PageableComponent.d.ts +12 -0
  38. package/package.json +1 -1
  39. package/dist/cjs/AssetsUtils-78164781.js +0 -24
  40. package/dist/esm/AssetsUtils-aab9ca8f.js +0 -22
  41. package/dist/ezui/p-51b878f7.js +0 -1
  42. package/dist/ezui/p-6d39b7ea.entry.js +0 -1
  43. package/dist/ezui/p-7d5b2ebf.entry.js +0 -1
  44. package/dist/ezui/p-ed1e0331.entry.js +0 -1
@@ -4,7 +4,26 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-0e284e03.js');
6
6
  const core = require('@sankhyalabs/core');
7
- const AssetsUtils = require('./AssetsUtils-78164781.js');
7
+ const ApplicationUtils = require('./ApplicationUtils-4a223c7a.js');
8
+
9
+ const getSpritePath = (sprite) => `${getContextAssetsPath("../assets/actions-sprite.svg")}#${sprite}`;
10
+ let ctxLoaded = false;
11
+ function getContextAssetsPath(resource) {
12
+ if (!ctxLoaded) {
13
+ const scriptElem = document.querySelector("script[data-ezui-assets-url]");
14
+ if (scriptElem) {
15
+ let assetsPath = scriptElem.dataset.ezuiAssetsUrl;
16
+ if (assetsPath) {
17
+ if (assetsPath.startsWith('/')) {
18
+ assetsPath = window.location.origin + assetsPath;
19
+ }
20
+ index.setAssetPath(assetsPath);
21
+ }
22
+ }
23
+ ctxLoaded = true;
24
+ }
25
+ return index.getAssetPath(resource);
26
+ }
8
27
 
9
28
  const gridConfigCss = ".sc-grid-config-h{--ez-grid-config__footer--padding-top:var(--space--medium, 12px);--ez-grid-config__main--padding-right:var(--space--medium, 12px);--ez-grid-config__tabselector-container--padding:var(--space--medium, 12px);--ez-grid-config__button-close--padding-left:var(--space--medium, 12px);--ez-grid-config__subtitle--font-family:var(--font-pattern, \"Sora\");--ez-grid-config__title--font-family:var(--font-pattern, \"Sora\");--ez-grid-config__title--font-weight:var(--text-weight--large, 700);--ez-grid-config__subtitle--font-size:var(--text--medium, 14px);--ez-grid-config__scrollbar--width:var(--space--medium, 12px);--ez-grid-config__main__scrollbar--background-color:var(--text--primary, #626e82);--ez-grid-config__main__scrollbar--border-radius:var(--border--radius-medium, 12px);--ez-grid__group--font-family:var(--font-pattern, \"Sora\");--ez-grid__group--font-size:var(--text--medium, 14px);--ez-grid__group--font-weight:var(--text-weight--large, 600);--ez-grid__group--padding-bottom:var(--space-small, 6px);display:grid;grid-template-rows:auto 1fr auto;max-height:100%;width:100%}.padding-right--medium.sc-grid-config{padding-right:var(--space--medium)}ez-list.sc-grid-config{height:100%}.heigth-calc.sc-grid-config{max-height:calc(100% - 24px)}.grid-config__footer.sc-grid-config{padding-top:var(--ez-grid-config__footer--padding-top);display:flex;justify-content:flex-end;width:100%}.hidden.sc-grid-config{display:none}.grid-config__main.sc-grid-config{padding-right:var(--ez-grid-config__main--padding-right);overflow-y:auto}.tabselector-container.sc-grid-config{padding:var(--ez-grid-config__tabselector-container--padding) 0}.button-close.sc-grid-config{padding-left:var(--ez-grid-config__button-close--padding-left)}.title-container.sc-grid-config{display:flex;justify-content:space-between;align-items:center;width:359px}.subtitle.sc-grid-config{font-family:var(--ez-grid-config__subtitle--font-family);font-size:var(--ez-grid-config__subtitle--font-size);color:var(--text--primary)}.title.sc-grid-config{display:flex;margin:0;font-family:var(--ez-grid-config__title--font-family);font-size:var(--title--large);font-weight:var(--ez-grid-config__title--font-weight);line-height:normal;letter-spacing:0em;text-align:left;color:var(--title--primary)}.grid-config__main.sc-grid-config::-webkit-scrollbar-track{background-color:#f0f2f5}.grid-config__main.sc-grid-config::-webkit-scrollbar-thumb{background-color:var(--ez-grid-config__main__scrollbar--background-color);border-radius:var(--ez-grid-config__main__scrollbar--border-radius)}.grid-config__main.sc-grid-config::-webkit-scrollbar{background-color:#f0f2f5;width:var(--ez-grid-config__scrollbar--width);max-width:var(--ez-grid-config__scrollbar--width);min-width:var(--ez-grid-config__scrollbar--width)}.group-name.sc-grid-config{font-family:var(--ez-grid__group--font-family);font-size:var(--ez-grid__group--font-size);font-weight:var(--ez-grid__group--font-weight);padding-bottom:var(--ez-grid__group--padding-bottom)}";
10
29
 
@@ -17,6 +36,7 @@ let GridConfig = class {
17
36
  this._orderPriorityList = [];
18
37
  this._columListItems = [];
19
38
  this._selectedIndex = -1;
39
+ this._dataChanged = false;
20
40
  this.selectedTab = "Colunas";
21
41
  }
22
42
  /* Creation Methods */
@@ -92,6 +112,7 @@ let GridConfig = class {
92
112
  }
93
113
  updateOrder(sortOrder, updatedItemLabel) {
94
114
  var _a;
115
+ this._dataChanged = true;
95
116
  let newList = [...this.columns];
96
117
  let newItem = newList.find(item => item.label === updatedItemLabel);
97
118
  if (newItem) {
@@ -120,6 +141,7 @@ let GridConfig = class {
120
141
  switchColumnGroup(ev, switchedItem) {
121
142
  ev.stopPropagation();
122
143
  let newList = [...this._columListItems];
144
+ this._dataChanged = true;
123
145
  if (ev.detail === true) {
124
146
  let hiddenGroup = newList.find(group => group.group === "Ocultas");
125
147
  let index = hiddenGroup.items.findIndex(item => item.label === switchedItem.label);
@@ -159,6 +181,9 @@ let GridConfig = class {
159
181
  });
160
182
  });
161
183
  this.columns = newColumnList;
184
+ this._dataChanged = false;
185
+ this.closeConfig();
186
+ ApplicationUtils.ApplicationUtils.info("As configurações foram salvas com sucesso!");
162
187
  this.save();
163
188
  }
164
189
  save() {
@@ -341,13 +366,46 @@ let GridConfig = class {
341
366
  return false;
342
367
  }
343
368
  closeConfig() {
344
- this.configCancel.emit();
345
- this._orderList.clearHistory();
369
+ this._orderList.scrollToTop();
370
+ this._columnList.scrollToTop();
371
+ this._searchElement.value = "";
372
+ if (this._dataChanged) {
373
+ let options = {
374
+ canClose: false,
375
+ labelCancel: "Descartar",
376
+ labelConfirm: "Salvar",
377
+ btnConfirmDanger: false
378
+ };
379
+ ApplicationUtils.ApplicationUtils.confirm("Aviso", "As alterações realizadas serão descartadas. Gostaria de salvar antes de sair?", null, false, options)
380
+ .then(response => {
381
+ if (!response) {
382
+ this._dataChanged = false;
383
+ this.configCancel.emit();
384
+ this._orderList.clearHistory();
385
+ }
386
+ else {
387
+ this.finish();
388
+ }
389
+ });
390
+ }
391
+ else {
392
+ this.configCancel.emit();
393
+ this._orderList.clearHistory();
394
+ }
346
395
  }
347
396
  /* Handlers */
348
397
  handleTabChange(ev) {
349
398
  var _a;
350
399
  if ((_a = ev === null || ev === void 0 ? void 0 : ev.target) === null || _a === void 0 ? void 0 : _a.selectedTab) {
400
+ if (this.selectedTab !== ev.target.selectedTab) {
401
+ if (ev.target.selectedTab === "Colunas") {
402
+ this._orderList.scrollToTop();
403
+ }
404
+ else if (ev.target.selectedTab === "Ordenação das linhas") {
405
+ this._columnList.scrollToTop();
406
+ }
407
+ this._searchElement.value = "";
408
+ }
351
409
  if (ev.target.selectedTab === "Ordenação das linhas") {
352
410
  this.createOrderList();
353
411
  }
@@ -359,6 +417,7 @@ let GridConfig = class {
359
417
  if (ev.detail) {
360
418
  let visibleItems = (_a = ev.detail.find(group => group.group === "Visíveis")) === null || _a === void 0 ? void 0 : _a.items;
361
419
  if (visibleItems) {
420
+ this._dataChanged = true;
362
421
  this._orderListItems = visibleItems;
363
422
  }
364
423
  }
@@ -367,6 +426,7 @@ let GridConfig = class {
367
426
  if (ev.detail) {
368
427
  let orderPriorityList = ev.detail;
369
428
  if (orderPriorityList) {
429
+ this._dataChanged = true;
370
430
  this._orderPriorityList = orderPriorityList;
371
431
  }
372
432
  }
@@ -384,7 +444,7 @@ let GridConfig = class {
384
444
  }
385
445
  }
386
446
  render() {
387
- return (index.h(index.Host, null, index.h("div", { class: "grid-config__header" }, index.h("div", { class: "title-container" }, index.h("div", { class: "" }, index.h("label", { class: "title" }, "Configura\u00E7\u00E3o da Grade"), index.h("label", { class: "subtitle" }, "Defina visibilidade e ordem das colunas.")), index.h("div", { class: "button-close" }, index.h("ez-button", { mode: 'icon', image: AssetsUtils.getSpritePath("close"), size: 'medium', onClick: () => this.closeConfig() }))), index.h("div", { class: "tabselector-container" }, index.h("ez-tabselector", { selectedTab: this.selectedTab, selectedIndex: 0, onEzChange: (ev) => { this.handleTabChange(ev); }, tabs: 'Colunas, Ordena\u00E7\u00E3o das linhas' })), index.h("div", null, index.h("ez-text-input", { ref: (el) => this._searchElement = el, label: "Localizar coluna", onKeyUp: evt => this.locateColumn(evt) }, index.h("ez-icon", { slot: "leftIcon", size: "medium", href: AssetsUtils.getSpritePath("search") })))), index.h("div", { class: "grid-config__main" }, index.h("ez-list", { ref: (el) => this._columnList = el, class: this.selectedTab === "Colunas" ? "" : "hidden", dataSource: this._columListItems, onEzChange: ev => this.handleColumnListChange(ev), ezDraggable: true, ezSelectable: true, itemSlotBuilder: (item, group) => this.buildColumnListSlot(item, group), useGroups: true }), index.h("div", { class: this.selectedTab === "Ordenação das linhas" ? "group-name" : "hidden" }, "Sequ\u00EAncia da ordena\u00E7\u00E3o"), index.h("ez-list", { ref: (el) => this._orderList = el, class: this.selectedTab === "Ordenação das linhas" ? "heigth-calc" : "hidden", dataSource: this._orderListItems, ezSelectable: true, onEzChange: ev => this.handleOrderListChange(ev), ezDraggable: true, itemSlotBuilder: (item) => this.buildOrderListSlot(item) })), index.h("div", { class: "grid-config__footer" }, index.h("ez-button", { class: "padding-right--medium", label: "Cancelar", onClick: () => this.closeConfig() }), index.h("ez-button", { label: "Concluir", class: "ez-button--primary", onClick: () => this.finish() }))));
447
+ return (index.h(index.Host, null, index.h("div", { class: "grid-config__header" }, index.h("div", { class: "title-container" }, index.h("div", { class: "" }, index.h("label", { class: "title" }, "Configura\u00E7\u00E3o da Grade"), index.h("label", { class: "subtitle" }, "Defina visibilidade e ordem das colunas.")), index.h("div", { class: "button-close" }, index.h("ez-button", { mode: 'icon', image: getSpritePath("close"), size: 'medium', onClick: () => this.closeConfig() }))), index.h("div", { class: "tabselector-container" }, index.h("ez-tabselector", { selectedTab: this.selectedTab, selectedIndex: 0, onEzChange: (ev) => { this.handleTabChange(ev); }, tabs: 'Colunas, Ordena\u00E7\u00E3o das linhas' })), index.h("div", null, index.h("ez-text-input", { ref: (el) => this._searchElement = el, label: "Localizar coluna", onKeyUp: evt => this.locateColumn(evt) }, index.h("ez-icon", { slot: "leftIcon", size: "medium", href: getSpritePath("search") })))), index.h("div", { class: "grid-config__main" }, index.h("ez-list", { ref: (el) => this._columnList = el, class: this.selectedTab === "Colunas" ? "" : "hidden", dataSource: this._columListItems, onEzChange: ev => this.handleColumnListChange(ev), ezDraggable: true, ezSelectable: true, itemSlotBuilder: (item, group) => this.buildColumnListSlot(item, group), useGroups: true }), index.h("div", { class: this.selectedTab === "Ordenação das linhas" ? "group-name" : "hidden" }, "Sequ\u00EAncia da ordena\u00E7\u00E3o"), index.h("ez-list", { ref: (el) => this._orderList = el, class: this.selectedTab === "Ordenação das linhas" ? "heigth-calc" : "hidden", dataSource: this._orderListItems, ezSelectable: true, onEzChange: ev => this.handleOrderListChange(ev), ezDraggable: true, itemSlotBuilder: (item) => this.buildOrderListSlot(item) })), index.h("div", { class: "grid-config__footer" }, index.h("ez-button", { class: "padding-right--medium", label: "Cancelar", onClick: () => this.closeConfig() }), index.h("ez-button", { label: "Concluir", class: "ez-button--primary", onClick: () => this.finish() }))));
388
448
  }
389
449
  static get assetsDirs() { return ["../assets"]; }
390
450
  };
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["ez-grid.cjs",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"config":[1040],"pageSize":[2,"page-size"],"serverUrl":[1,"server-url"],"dataUnit":[16],"_navigationHasPrevious":[32],"_navigationHasNext":[32],"_navigationFirstRow":[32],"_navigationLastRow":[32],"_navigationTotalRows":[32],"_popUpVisible":[32],"setColumnsDef":[64],"addColumnMenuItem":[64],"setColumnsState":[64],"setData":[64],"getSelection":[64],"getColumnsState":[64],"getColumns":[64],"refresh":[64],"quickFilter":[64]}]]],["ez-dialog.cjs",[[1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"],"handleButtonClick":[64],"show":[64]}]]],["ez-filter-input.cjs",[[1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"loading":[516],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-action-chip.cjs",[[1,"ez-action-chip",{"label":[513],"enabled":[516]}]]],["ez-application.cjs",[[0,"ez-application"]]],["ez-label-chip.cjs",[[1,"ez-label-chip",{"label":[513],"enabled":[516],"removable":[516],"value":[1540],"setFocus":[64],"setBlur":[64]}]]],["ez-popover.cjs",[[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]}]]],["ez-popup.cjs",[[1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[1540,"use-header"],"ezTitle":[1,"ez-title"]}]]],["ez-toast.cjs",[[1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"],"show":[64]}]]],["grid-config.cjs",[[2,"grid-config",{"selectedTab":[1025,"selected-tab"],"columns":[1040],"config":[1040]}]]],["ez-modal.cjs",[[1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"]}]]],["ez-text-input.cjs",[[1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-search.cjs",[[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]}]]],["select-box.cjs",[[1,"select-box",{"selectedOption":[1,"selected-option"]}]]],["ez-date-input.cjs",[[1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-time-input.cjs",[[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]}]]],["ez-time-input.cjs",[[1,"ez-time-input",{"label":[513],"viewValue":[1537,"view-value"],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-number-input.cjs",[[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]}]]],["ez-list.cjs",[[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],"setSelection":[64],"getSelection":[64],"getList":[64]}]]],["ez-text-area.cjs",[[1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"rows":[1538],"canShowError":[516,"can-show-error"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-icon.cjs",[[1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]]],["ez-collapsible-box.cjs",[[1,"ez-collapsible-box",{"value":[1540],"label":[513],"headerSize":[513,"header-size"],"iconPlacement":[513,"icon-placement"],"stretchTitle":[516,"stretch-title"],"showHide":[64]}]]],["ez-upload.cjs",[[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]}]]],["ez-button.cjs",[[1,"ez-button",{"label":[513],"enabled":[516],"mode":[513],"image":[513],"iconName":[513,"icon-name"],"size":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-calendar.cjs",[[1,"ez-calendar",{"value":[1040],"floating":[516],"time":[516],"showSeconds":[516,"show-seconds"],"show":[64],"fitVertical":[64],"hide":[64]}]]],["ez-check.cjs",[[1,"ez-check",{"label":[513],"value":[1540],"enabled":[1540],"mode":[513],"getMode":[64],"setFocus":[64]}]]],["ez-tabselector.cjs",[[1,"ez-tabselector",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1]}]]],["ez-combo-box.cjs",[[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],"setFocus":[64],"setBlur":[64]}]]],["ez-form.cjs",[[0,"ez-form",{"dataUnit":[1040],"config":[16],"submit":[64],"cancel":[64],"validate":[64]}]]],["test-du.cjs",[[0,"test-du",{"isDirty":[32]}]]]], options);
17
+ return index.bootstrapLazy([["ez-grid.cjs",[[6,"ez-grid",{"multipleSelection":[4,"multiple-selection"],"config":[1040],"pageSize":[2,"page-size"],"serverUrl":[1,"server-url"],"dataUnit":[16],"_navigationHasPrevious":[32],"_navigationHasNext":[32],"_navigationFirstRow":[32],"_navigationLastRow":[32],"_navigationTotalRows":[32],"_popUpGridConfig":[32],"setColumnsDef":[64],"addColumnMenuItem":[64],"setColumnsState":[64],"setData":[64],"getSelection":[64],"getColumnsState":[64],"getColumns":[64],"refresh":[64],"quickFilter":[64],"nextPage":[64],"previousPage":[64],"hasNextPage":[64],"hasPreviousPage":[64],"isLastOfPage":[64],"isFirstOfPage":[64],"nextRecord":[64],"previousRecord":[64],"hasNextRecord":[64],"hasPreviousRecord":[64],"openGridConfig":[64]}]]],["ez-dialog.cjs",[[1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"opened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"],"handleButtonClick":[64],"show":[64]}]]],["ez-filter-input.cjs",[[1,"ez-filter-input",{"label":[1],"value":[1537],"enabled":[4],"loading":[516],"errorMessage":[1537,"error-message"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-action-chip.cjs",[[1,"ez-action-chip",{"label":[513],"enabled":[516]}]]],["ez-application.cjs",[[0,"ez-application"]]],["ez-label-chip.cjs",[[1,"ez-label-chip",{"label":[513],"enabled":[516],"removable":[516],"value":[1540],"setFocus":[64],"setBlur":[64]}]]],["ez-popover.cjs",[[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]}]]],["ez-popup.cjs",[[1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[1540,"use-header"],"ezTitle":[1,"ez-title"]}]]],["ez-toast.cjs",[[1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"],"canClose":[1028,"can-close"],"show":[64]}]]],["grid-config.cjs",[[2,"grid-config",{"selectedTab":[1025,"selected-tab"],"columns":[1040],"config":[1040]}]]],["ez-modal.cjs",[[1,"ez-modal",{"modalSize":[1,"modal-size"],"align":[1],"opened":[1028],"closeEsc":[4,"close-esc"],"closeOutsideClick":[4,"close-outside-click"]}]]],["ez-text-input.cjs",[[1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"mask":[1],"canShowError":[516,"can-show-error"],"restrict":[1],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-search.cjs",[[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]}]]],["select-box.cjs",[[1,"select-box",{"selectedOption":[1,"selected-option"]}]]],["ez-date-input.cjs",[[1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errorMessage":[1537,"error-message"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-date-time-input.cjs",[[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]}]]],["ez-time-input.cjs",[[1,"ez-time-input",{"label":[513],"viewValue":[1537,"view-value"],"value":[1026],"enabled":[516],"errorMessage":[1537,"error-message"],"showSeconds":[516,"show-seconds"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-number-input.cjs",[[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]}]]],["ez-list.cjs",[[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]}]]],["ez-text-area.cjs",[[1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errorMessage":[1537,"error-message"],"rows":[1538],"canShowError":[516,"can-show-error"],"mode":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-icon.cjs",[[1,"ez-icon",{"size":[513],"href":[513],"iconName":[513,"icon-name"]}]]],["ez-collapsible-box.cjs",[[1,"ez-collapsible-box",{"value":[1540],"label":[513],"headerSize":[513,"header-size"],"iconPlacement":[513,"icon-placement"],"stretchTitle":[516,"stretch-title"],"showHide":[64]}]]],["ez-upload.cjs",[[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]}]]],["ez-button.cjs",[[1,"ez-button",{"label":[513],"enabled":[516],"mode":[513],"image":[513],"iconName":[513,"icon-name"],"size":[513],"setFocus":[64],"setBlur":[64]}]]],["ez-calendar.cjs",[[1,"ez-calendar",{"value":[1040],"floating":[516],"time":[516],"showSeconds":[516,"show-seconds"],"show":[64],"fitVertical":[64],"hide":[64]}]]],["ez-check.cjs",[[1,"ez-check",{"label":[513],"value":[1540],"enabled":[1540],"mode":[513],"getMode":[64],"setFocus":[64]}]]],["ez-tabselector.cjs",[[1,"ez-tabselector",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1]}]]],["ez-combo-box.cjs",[[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],"setFocus":[64],"setBlur":[64]}]]],["ez-form.cjs",[[0,"ez-form",{"dataUnit":[1040],"config":[16],"submit":[64],"cancel":[64],"validate":[64]}]]],["test-du.cjs",[[0,"test-du",{"isDirty":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -39,7 +39,12 @@ export default class DataBinder {
39
39
  const oldValue = field["value"];
40
40
  const newValue = this._dataUnit.getFieldValue(fieldName);
41
41
  if (oldValue != newValue) {
42
- field["value"] = newValue;
42
+ if (newValue === undefined) {
43
+ field.removeAttribute("value");
44
+ }
45
+ else {
46
+ field["value"] = newValue;
47
+ }
43
48
  }
44
49
  }
45
50
  updateBind(fieldName, field) {
@@ -47,7 +52,13 @@ export default class DataBinder {
47
52
  if (oldBind) {
48
53
  oldBind.destroy();
49
54
  }
50
- field["value"] = this._dataUnit.getFieldValue(fieldName);
55
+ const value = this._dataUnit.getFieldValue(fieldName);
56
+ if (value === undefined) {
57
+ field.removeAttribute("value");
58
+ }
59
+ else {
60
+ field["value"] = value;
61
+ }
51
62
  this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
52
63
  this.bindSearchOptionsLoader(fieldName, field);
53
64
  this.applyEzUploadContext(fieldName, field);
@@ -27,7 +27,7 @@ export class EzForm {
27
27
  .filter(f => f.dataset.required)
28
28
  .map(f => f.dataset.fieldName)
29
29
  .concat(metadata.getRequiredFields());
30
- const records = this.dataUnit.records;
30
+ const records = this.dataUnit.getModifiedRecords();
31
31
  for (let i = 0; i < records.length; i++) {
32
32
  if (!this.validateRequired(requiredFields, records[i])) {
33
33
  reject();
@@ -10,10 +10,6 @@ export default class DataUnitBridge {
10
10
  const { records } = action.payload;
11
11
  this._gridController.removeRows(records);
12
12
  break;
13
- case Action.RECORDS_ADDED:
14
- case Action.RECORDS_COPIED:
15
- this._gridController.addRows(action.payload);
16
- break;
17
13
  case Action.EDITION_CANCELED:
18
14
  case Action.DATA_SAVED:
19
15
  this._gridController.refresh();
@@ -22,6 +18,10 @@ export default class DataUnitBridge {
22
18
  const { selection } = action.payload;
23
19
  this._gridController.selectRows(selection);
24
20
  break;
21
+ case Action.NEXT_SELECTED:
22
+ case Action.PREVIOUS_SELECTED:
23
+ this._gridController.selectRows(this._dataUnit.getSelection());
24
+ break;
25
25
  case Action.DATA_CHANGED:
26
26
  const changes = Object.assign({}, action.payload);
27
27
  delete changes.records;
@@ -38,7 +38,12 @@ export default class DataUnitBridge {
38
38
  this._dataUnit.metadata.fields.forEach(f => {
39
39
  var _a;
40
40
  if (f.visible !== false) {
41
- columnDefs.push({ label: f.label, name: f.name, userInterface: f.userInterface, options: (_a = this._dataUnit.getField(f.name).properties) === null || _a === void 0 ? void 0 : _a.options });
41
+ const props = new Map();
42
+ const properties = this._dataUnit.getField(f.name).properties;
43
+ for (const value in properties) {
44
+ props.set(value, properties[value]);
45
+ }
46
+ columnDefs.push({ label: f.label, name: f.name, userInterface: f.userInterface, options: (_a = this._dataUnit.getField(f.name).properties) === null || _a === void 0 ? void 0 : _a.options, props });
42
47
  }
43
48
  });
44
49
  }
@@ -5,10 +5,14 @@ import HeaderColumnTemplate from "./template/HeaderColumnTemplate.js";
5
5
  import DataSource from "./DataSource";
6
6
  import { DataType } from "@sankhyalabs/core";
7
7
  import { SortMode, UserInterface } from "@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";
8
+ import { NumberUtils } from "@sankhyalabs/core";
8
9
  export default class AgGridController {
9
10
  constructor(enterprise) {
11
+ this.DEFAULT_ROW_HEIGHT = 25;
10
12
  this._menuItems = [];
11
13
  this._idAttribName = "__record__id__";
14
+ this._isFirstRecordOfPage = true;
15
+ this._isLastRecordOfPage = false;
12
16
  this._enterprise = enterprise;
13
17
  }
14
18
  getSort() {
@@ -36,7 +40,9 @@ export default class AgGridController {
36
40
  this._pageSize = options.pageSize;
37
41
  this._serverURL = options.serverURL;
38
42
  this._dataUnit = options.dataUnit;
39
- this._dataUnit.sortingProvider = this;
43
+ if (this._dataUnit) {
44
+ this._dataUnit.sortingProvider = this;
45
+ }
40
46
  this._dataSource = new DataSource(this._dataUnit, this._serverURL);
41
47
  this._gridOptions = {
42
48
  localeText: gridTerms,
@@ -45,7 +51,7 @@ export default class AgGridController {
45
51
  rowSelection: this._multipleSelection ? "multiple" : "single",
46
52
  serverSideDatasource: this._dataSource,
47
53
  sortingOrder: ['desc', 'asc', null],
48
- getRowNodeId: (params) => typeof params === "string" ? params : params[this._idAttribName],
54
+ getRowNodeId: this._dataUnit ? (params) => typeof params === "string" ? params : params[this._idAttribName] : undefined,
49
55
  getMainMenuItems: (params) => {
50
56
  const column = params.column;
51
57
  const items = [column.isPinned() ? "clearPinned" : "pinLeft", "separator"];
@@ -55,14 +61,12 @@ export default class AgGridController {
55
61
  }));
56
62
  return items;
57
63
  },
58
- getRowHeight: () => {
59
- //FIXME: Existe um bug no PartialStore.prototype.destroyAllBlocks do ag-grid, pois
60
- //apesar de destruir os blocos, mantém a variável "blockHeights" com o tamanho antigo
61
- //dos blocos, então, quando removemos uma linha, a altura do bloco não é recalculada.
62
- //Descobri que setando manualmente a altura das linhas, apesar do bloco ficar com
63
- //tamanho errado, isso afeta menos o componente.
64
- return 25;
65
- }
64
+ //FIXME: Existe um bug no PartialStore.prototype.destroyAllBlocks do ag-grid, pois
65
+ //apesar de destruir os blocos, mantém a variável "blockHeights" com o tamanho antigo
66
+ //dos blocos, então, quando removemos uma linha, a altura do bloco não é recalculada.
67
+ //Descobri que setando manualmente a altura das linhas, apesar do bloco ficar com
68
+ //tamanho errado, isso afeta menos o componente.
69
+ rowHeight: this.DEFAULT_ROW_HEIGHT
66
70
  };
67
71
  this.setOptionsEvents(this._gridOptions);
68
72
  this.setOptionsPagination(this._gridOptions);
@@ -85,16 +89,17 @@ export default class AgGridController {
85
89
  opt.onPaginationChanged = () => this.onPaginationChange();
86
90
  opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
87
91
  opt.onDragStopped = evt => this.onCallStateChange("columnMovedEnd", evt);
88
- opt.onViewportChanged = () => {
89
- if (this._dataUnit) {
90
- this.selectRows(this._dataUnit.getSelection());
91
- }
92
- };
92
+ }
93
+ syncSelection() {
94
+ if (this._dataUnit) {
95
+ this.selectRows(this._dataUnit.getSelection());
96
+ }
93
97
  }
94
98
  setOptionsPagination(opt) {
95
99
  opt.pagination = (this._pageSize > -1);
96
100
  opt.paginationPageSize = this._pageSize;
97
101
  opt.cacheBlockSize = this._pageSize;
102
+ opt.maxBlocksInCache = 1;
98
103
  }
99
104
  setOptionsSupress(opt) {
100
105
  opt.suppressDragLeaveHidesColumns = true;
@@ -130,7 +135,7 @@ export default class AgGridController {
130
135
  if (this._grid === undefined) {
131
136
  throw new Error("Erro interno: Grid ainda não inicializado.");
132
137
  }
133
- this._gridOptions.api.refreshServerSideStore({});
138
+ this._gridOptions.api.refreshServerSideStore({ purge: true });
134
139
  }
135
140
  changeValues(changes, rowIds) {
136
141
  if (this._grid === undefined) {
@@ -267,6 +272,75 @@ export default class AgGridController {
267
272
  this.goToPage(0);
268
273
  this._gridOptions.api.refreshServerSideStore({ purge: true });
269
274
  }
275
+ isLastOfPage() {
276
+ return this._isLastRecordOfPage;
277
+ }
278
+ isFirstOfPage() {
279
+ return this._isFirstRecordOfPage;
280
+ }
281
+ previousRecord() {
282
+ const pagination = this.getPaginationStatus();
283
+ if (this._isFirstRecordOfPage && pagination.hasPrevious) {
284
+ this.previousPage();
285
+ }
286
+ else {
287
+ if (this._dataUnit) {
288
+ this._dataUnit.previousRecord();
289
+ }
290
+ else {
291
+ const node = this._gridOptions.api.getSelectedNodes()[0];
292
+ this.setSelectedIndex(node.rowIndex - 1);
293
+ }
294
+ }
295
+ }
296
+ nextRecord() {
297
+ const pagination = this.getPaginationStatus();
298
+ if (this._isLastRecordOfPage && pagination.hasNext) {
299
+ this.nextPage();
300
+ }
301
+ else {
302
+ if (this._dataUnit) {
303
+ this._dataUnit.nextRecord();
304
+ }
305
+ else {
306
+ const node = this._gridOptions.api.getSelectedNodes()[0];
307
+ this.setSelectedIndex(node.rowIndex + 1);
308
+ }
309
+ }
310
+ }
311
+ setSelectedIndex(index) {
312
+ var _a;
313
+ (_a = this._gridOptions.api.getDisplayedRowAtIndex(index)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
314
+ }
315
+ hasPreviousRecord() {
316
+ const pagination = this.getPaginationStatus();
317
+ if (this._isFirstRecordOfPage) {
318
+ return pagination.hasPrevious;
319
+ }
320
+ else {
321
+ if (this._dataUnit) {
322
+ return this._dataUnit.hasPrevious();
323
+ }
324
+ else {
325
+ return pagination.hasPrevious || this._gridOptions.api.getSelectedRows()[0].rowIndex > 0;
326
+ }
327
+ }
328
+ }
329
+ hasNextRecord() {
330
+ const pagination = this.getPaginationStatus();
331
+ if (this._isLastRecordOfPage) {
332
+ return pagination.hasNext;
333
+ }
334
+ else {
335
+ if (this._dataUnit) {
336
+ return this._dataUnit.hasNext() || this.getPaginationStatus().hasNext;
337
+ }
338
+ else {
339
+ const api = this._gridOptions.api;
340
+ return pagination.hasNext || api.getSelectedRows()[0].rowIndex < api.getDisplayedRowCount();
341
+ }
342
+ }
343
+ }
270
344
  buildColDef(source) {
271
345
  return {
272
346
  headerName: source.label,
@@ -301,19 +375,24 @@ export default class AgGridController {
301
375
  });
302
376
  return optionSelected === null || optionSelected === void 0 ? void 0 : optionSelected.label;
303
377
  }
304
- if ((source === null || source === void 0 ? void 0 : source.userInterface) === "SWITCH") {
305
- if ((params === null || params === void 0 ? void 0 : params.value) === "S" || (params === null || params === void 0 ? void 0 : params.value) === true) {
378
+ if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.SWITCH) {
379
+ if ((params === null || params === void 0 ? void 0 : params.value) === "S" || (params === null || params === void 0 ? void 0 : params.value) === true || (params === null || params === void 0 ? void 0 : params.value) === "true") {
306
380
  return "Sim";
307
381
  }
308
- else if ((params === null || params === void 0 ? void 0 : params.value) === "N" || (params === null || params === void 0 ? void 0 : params.value) === false) {
382
+ else if ((params === null || params === void 0 ? void 0 : params.value) === "N" || (params === null || params === void 0 ? void 0 : params.value) === false || (params === null || params === void 0 ? void 0 : params.value) === "false") {
309
383
  return "Não";
310
384
  }
311
385
  }
312
- if ((source === null || source === void 0 ? void 0 : source.userInterface) === "SEARCH") {
386
+ if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.SEARCH) {
313
387
  if (params.value !== undefined) {
314
388
  return ((_a = params === null || params === void 0 ? void 0 : params.value) === null || _a === void 0 ? void 0 : _a.value) + " - " + ((_b = params === null || params === void 0 ? void 0 : params.value) === null || _b === void 0 ? void 0 : _b.label);
315
389
  }
316
390
  }
391
+ if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.DECIMALNUMBER) {
392
+ if (params.value !== undefined) {
393
+ return NumberUtils.format(params.value.toString(), 2, 2);
394
+ }
395
+ }
317
396
  if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.DATE || (source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.DATETIME) {
318
397
  if (params.value !== undefined) {
319
398
  return params.value.toLocaleDateString();
@@ -343,31 +422,44 @@ export default class AgGridController {
343
422
  return false;
344
423
  }
345
424
  onSelectionChange(e) {
425
+ const selectedNodes = e.api.getSelectedNodes();
426
+ if (selectedNodes.length > 0) {
427
+ this._isFirstRecordOfPage = selectedNodes[0].rowIndex === e.api.getFirstDisplayedRow();
428
+ this._isLastRecordOfPage = selectedNodes[0].rowIndex === e.api.getLastDisplayedRow();
429
+ }
346
430
  if (this._selectionChangeCallback) {
347
- this._selectionChangeCallback(e.api.getSelectedRows());
431
+ this._selectionChangeCallback({
432
+ selection: e.api.getSelectedRows(),
433
+ isFirstOfPage: this._isFirstRecordOfPage,
434
+ isLastOfPage: this._isLastRecordOfPage
435
+ });
348
436
  }
349
437
  }
350
438
  onPaginationChange() {
439
+ this.syncSelection();
351
440
  if (this._paginationChangeCallback) {
352
441
  if (this._gridOptions.api) {
353
- const api = this._gridOptions.api;
354
- const currentPage = api.paginationGetCurrentPage();
355
- const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
356
- const pageSize = api.paginationGetPageSize();
357
- const totalRows = api.paginationGetRowCount();
358
- const pageStart = currentPage * pageSize + 1;
359
- const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
360
- this._paginationChangeCallback({
361
- hasPrevious: currentPage > 0,
362
- hasNext: !isLastPage,
363
- currentPage: currentPage + 1,
364
- pageStart,
365
- pageEnd,
366
- totalRows
367
- });
442
+ this._paginationChangeCallback(this.getPaginationStatus());
368
443
  }
369
444
  }
370
445
  }
446
+ getPaginationStatus() {
447
+ const api = this._gridOptions.api;
448
+ const currentPage = api.paginationGetCurrentPage();
449
+ const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
450
+ const pageSize = api.paginationGetPageSize();
451
+ const totalRows = api.paginationGetRowCount();
452
+ const pageStart = currentPage * pageSize + 1;
453
+ const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
454
+ return {
455
+ hasPrevious: currentPage > 0,
456
+ hasNext: !isLastPage,
457
+ currentPage: currentPage + 1,
458
+ pageStart,
459
+ pageEnd,
460
+ totalRows
461
+ };
462
+ }
371
463
  onRowDoubleClick(evt) {
372
464
  if (this._doubleClickCallBack) {
373
465
  this._doubleClickCallBack(evt.data);