@sankhyalabs/ezui 5.13.0 → 5.14.0-dev.1

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 (55) hide show
  1. package/dist/cjs/{constants-3a1d64fb.js → constants-2714478b.js} +2 -0
  2. package/dist/cjs/ez-actions-button.cjs.entry.js +2 -2
  3. package/dist/cjs/ez-combo-box.cjs.entry.js +1 -1
  4. package/dist/cjs/ez-dropdown.cjs.entry.js +2 -2
  5. package/dist/cjs/ez-form-view.cjs.entry.js +1 -1
  6. package/dist/cjs/ez-grid.cjs.entry.js +38 -22
  7. package/dist/cjs/ez-multi-selection-list.cjs.entry.js +19 -8
  8. package/dist/cjs/ezui.cjs.js +1 -1
  9. package/dist/cjs/filter-column.cjs.entry.js +16 -4
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/collection/components/ez-actions-button/ez-actions-button.css +9 -1
  12. package/dist/collection/components/ez-actions-button/ez-actions-button.js +1 -1
  13. package/dist/collection/components/ez-dropdown/ez-dropdown.css +4 -3
  14. package/dist/collection/components/ez-dropdown/ez-dropdown.js +1 -1
  15. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +11 -9
  16. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +7 -1
  17. package/dist/collection/components/ez-grid/controller/ag-grid/components/cellRendererStatus.js +1 -1
  18. package/dist/collection/components/ez-grid/ez-grid.js +14 -11
  19. package/dist/collection/components/ez-grid/subcomponents/filter-column.js +16 -4
  20. package/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource.js +6 -0
  21. package/dist/collection/components/ez-multi-selection-list/ez-multi-selection-list.js +20 -9
  22. package/dist/collection/utils/constants.js +1 -0
  23. package/dist/custom-elements/index.js +78 -38
  24. package/dist/esm/constants-4e0d35b7.js +5 -0
  25. package/dist/esm/ez-actions-button.entry.js +2 -2
  26. package/dist/esm/ez-combo-box.entry.js +1 -1
  27. package/dist/esm/ez-dropdown.entry.js +2 -2
  28. package/dist/esm/ez-form-view.entry.js +1 -1
  29. package/dist/esm/ez-grid.entry.js +38 -22
  30. package/dist/esm/ez-multi-selection-list.entry.js +19 -8
  31. package/dist/esm/ezui.js +1 -1
  32. package/dist/esm/filter-column.entry.js +16 -4
  33. package/dist/esm/loader.js +1 -1
  34. package/dist/ezui/ezui.esm.js +1 -1
  35. package/dist/ezui/p-05e1f4e7.js +1 -0
  36. package/dist/ezui/{p-b977d29c.entry.js → p-16b5126b.entry.js} +1 -1
  37. package/dist/ezui/{p-a32bded2.entry.js → p-40cf4952.entry.js} +2 -2
  38. package/dist/ezui/p-74049254.entry.js +1 -0
  39. package/dist/ezui/{p-3078d25c.entry.js → p-7fd54841.entry.js} +1 -1
  40. package/dist/ezui/p-a42fe2ce.entry.js +1 -0
  41. package/dist/ezui/p-b12b31a7.entry.js +1 -0
  42. package/dist/ezui/p-d4cfe7cd.entry.js +1 -0
  43. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +0 -5
  44. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +1 -3
  45. package/dist/types/components/ez-grid/ez-grid.d.ts +2 -0
  46. package/dist/types/components/ez-grid/utils/InMemoryFilterColumnDataSource.d.ts +1 -0
  47. package/dist/types/components/ez-multi-selection-list/interfaces/IMultiSelectionListDataSource.d.ts +1 -0
  48. package/dist/types/utils/constants.d.ts +1 -0
  49. package/package.json +1 -1
  50. package/dist/esm/constants-6dab64f7.js +0 -4
  51. package/dist/ezui/p-061f4d73.entry.js +0 -1
  52. package/dist/ezui/p-110c68a1.entry.js +0 -1
  53. package/dist/ezui/p-27a01a26.js +0 -1
  54. package/dist/ezui/p-5e55a42b.entry.js +0 -1
  55. package/dist/ezui/p-a510a4c5.entry.js +0 -1
@@ -12,10 +12,8 @@
12
12
  --ez-dropdown--background-color: var(--background--xlight, #fff);
13
13
  /*@doc Define a fonte do componente.*/
14
14
  --ez-dropdown--font-family: var(--font-pattern, 'Roboto');
15
- /*@doc Define a largura máxima do componente.*/
16
- --ez-dropdown--max-width: 320px;
17
15
  /*@doc Define a altura máxima do componente.*/
18
- --ez-dropdown--max-height: 440px;
16
+ --ez-dropdown--max-height: 415px;
19
17
 
20
18
  /* item*/
21
19
  /*@doc Define o espaçamento interno de cada item do componente.*/
@@ -120,6 +118,9 @@
120
118
  border-radius: var(--ez-dropdown--border-radius);
121
119
  background-color: var(--ez-dropdown--background-color);
122
120
  max-width: var(--ez-dropdown--max-width);
121
+ }
122
+
123
+ .ez-dropdown__max-height {
123
124
  max-height: var(--ez-dropdown--max-height);
124
125
  }
125
126
 
@@ -137,7 +137,7 @@ export class EzDropdown {
137
137
  const hasGroup = this.hasGroup(branchItems);
138
138
  const hasIcon = this.hasIcon(branchItems);
139
139
  const hasChildren = this.hasChildren(branchItems);
140
- return (h("div", { class: "ez-dropdown", "data-level": level }, h("div", { class: "ez-dropdown__container" }, Object.keys(itemsByGroup)
140
+ return (h("div", { class: "ez-dropdown ez-dropdown__max-height", "data-level": level }, h("div", { class: "ez-dropdown__container" }, Object.keys(itemsByGroup)
141
141
  .map((groupLabel) => {
142
142
  return (h("div", Object.assign({ class: "ez-dropdown__group" }, { [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(`${groupLabel}_ezDropdownGroup`) }), groupLabel !== "noGroup" &&
143
143
  h("label", { class: "ez-dropdown__group-label", title: groupLabel }, groupLabel), hasGroup &&
@@ -6,7 +6,7 @@ import { EzGridCustomHeader } from './components/EzGridCustomHeader';
6
6
  import { CellRendererStatus } from './components/cellRendererStatus';
7
7
  import SelectionHeader from './components/selectionHeader';
8
8
  import gridTerms from './i18n/pt-BR.js';
9
- import { DISTINCT_FILTER_NAME_PREFIX } from '../../../../utils/constants';
9
+ import { EZ_GRID_LOADING_SOURCE, DISTINCT_FILTER_NAME_PREFIX } from '../../../../utils/constants';
10
10
  import { calcFilterColumnLeftPosition } from './AgGridUtils';
11
11
  import GridEditionManager from './GridEditionManager';
12
12
  export default class AgGridController {
@@ -18,7 +18,7 @@ export default class AgGridController {
18
18
  const applied = event.detail;
19
19
  this._filteredColumns.set(applied.field, applied.values);
20
20
  this._gridOptions.api.refreshHeader();
21
- this._dataUnit.loadData();
21
+ this._dataUnit.loadData(undefined, undefined, undefined, EZ_GRID_LOADING_SOURCE);
22
22
  }
23
23
  showFilterColumn(configs) {
24
24
  var _a;
@@ -30,7 +30,7 @@ export default class AgGridController {
30
30
  this.CHECK_BOX_COL_ID = 'checkBoxColumn';
31
31
  this.STATUS_COL_ID = 'statusColumn';
32
32
  this.RECORD_ARCHIVE_COL_ID = '__RECORD_ARCHIVE__';
33
- this.BLOCK_LOAD_DEBOUNCE = 400;
33
+ this.BLOCK_LOAD_DEBOUNCE = 100;
34
34
  this.DEFAULT_FONT_SIZE = 14;
35
35
  this.DEFAULT_ICON_SIZE = 12;
36
36
  this.DEFAULT_MAX_SIZE = 200;
@@ -44,10 +44,7 @@ export default class AgGridController {
44
44
  getGridConfig() {
45
45
  return this._gridConfig;
46
46
  }
47
- getGridApi() {
48
- return this._gridOptions.api;
49
- }
50
- getSort() {
47
+ getSort(_dataUnitName, defaultSorting) {
51
48
  const sortedColumns = [];
52
49
  this._gridOptions.columnApi
53
50
  .getColumnState()
@@ -60,7 +57,7 @@ export default class AgGridController {
60
57
  sortedColumns.push(sortField);
61
58
  }
62
59
  });
63
- return sortedColumns;
60
+ return sortedColumns.length === 0 && this._gridConfig === undefined ? defaultSorting : sortedColumns;
64
61
  }
65
62
  getFilter() {
66
63
  if (!this._filteredColumns || this._filteredColumns.size === 0) {
@@ -131,6 +128,7 @@ export default class AgGridController {
131
128
  height: '100%'
132
129
  }
133
130
  },
131
+ suppressFieldDotNotation: true,
134
132
  components: Object.assign({ ezGridHeaderComponent: SelectionHeader, ezGridCustomHeader: EzGridCustomHeader }, this._editionManager.getComponents()),
135
133
  context: {
136
134
  editionManager: this._editionManager,
@@ -149,6 +147,10 @@ export default class AgGridController {
149
147
  else {
150
148
  this._grid = new Grid(container, this._gridOptions);
151
149
  }
150
+ container.addEventListener('focusout', (event) => {
151
+ if (!container.contains(event.relatedTarget))
152
+ this._gridOptions.api.clearFocusedCell();
153
+ });
152
154
  const selection = (_a = this._dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
153
155
  if (selection === null || selection === void 0 ? void 0 : selection.isAllRecords()) {
154
156
  this.selectAll(true);
@@ -424,7 +426,7 @@ export default class AgGridController {
424
426
  if (this._grid === undefined) {
425
427
  throw new Error('Erro interno: Grid ainda não inicializado.');
426
428
  }
427
- this._gridOptions.api.refreshServerSide({ purge: false });
429
+ this._gridOptions.api.refreshServerSide({ purge: true });
428
430
  }
429
431
  setFocusFirstRow() {
430
432
  const firstRow = this._gridOptions.api.getDisplayedRowAtIndex(0);
@@ -1,4 +1,5 @@
1
1
  import { Action, ObjectUtils } from "@sankhyalabs/core";
2
+ import { EZ_GRID_LOADING_SOURCE } from "../../../../utils/constants";
2
3
  export default class DataSource {
3
4
  constructor(dataUnit, controller, options) {
4
5
  this.RECORD_ARCHIVE = "__RECORD_ARCHIVE__";
@@ -19,6 +20,11 @@ export default class DataSource {
19
20
  }
20
21
  this.updateSelection();
21
22
  break;
23
+ case Action.PAGINATION_UPDATED:
24
+ if (this._options) {
25
+ this._options.onPaginationChange(this._dataUnit.getPaginationInfo());
26
+ }
27
+ break;
22
28
  case Action.RECORDS_REMOVED:
23
29
  case Action.DATA_SAVED:
24
30
  case Action.EDITION_CANCELED:
@@ -51,7 +57,7 @@ export default class DataSource {
51
57
  getRows(params) {
52
58
  if (this.needReload(params)) {
53
59
  this._lastLoadingParams = params;
54
- this._dataUnit.loadData(this.quickFilter).then(() => this.updateSelection());
60
+ this._dataUnit.loadData(this.quickFilter, undefined, true, EZ_GRID_LOADING_SOURCE).then(() => this.updateSelection());
55
61
  }
56
62
  else {
57
63
  this._lastLoadingParams = params;
@@ -8,7 +8,7 @@ export class CellRendererStatus {
8
8
  }
9
9
  refresh(params) {
10
10
  this.renderStatus(params);
11
- return true;
11
+ return false;
12
12
  }
13
13
  destroy() {
14
14
  this._eGui = undefined;
@@ -217,21 +217,26 @@ export class EzGrid {
217
217
  }
218
218
  previousPage() {
219
219
  if (this.dataUnit) {
220
- this.dataUnit.previousPage();
221
- this._paginationChangedByKeyboard = false;
220
+ this.dataUnit.previousPage()
221
+ .then(() => this.resetPaginationState());
222
222
  }
223
223
  }
224
224
  nextPage() {
225
225
  if (this.dataUnit) {
226
- this.dataUnit.nextPage();
227
- this._paginationChangedByKeyboard = false;
226
+ this.dataUnit.nextPage()
227
+ .then(() => this.resetPaginationState());
228
228
  }
229
229
  }
230
+ resetPaginationState() {
231
+ var _a;
232
+ this._paginationChangedByKeyboard = false;
233
+ (_a = this._gridApi) === null || _a === void 0 ? void 0 : _a.clearRangeSelection();
234
+ }
230
235
  getPaginationControl() {
231
236
  if (this._paginationInfo) {
232
- const { firstRecord, lastRecord, total, currentPage, hasMore } = this._paginationInfo;
237
+ const { firstRecord, lastRecord, total, count, currentPage, hasMore } = this._paginationInfo;
233
238
  return [
234
- h("div", { class: "ez-text ez-text--primary ez-text--medium ez-margin-right--medium" }, h("strong", { class: "ez-text ez-text--primary ez-text--medium" }, `${firstRecord}-${lastRecord}`), ` de ${total}`),
239
+ h("div", { class: "ez-text ez-text--primary ez-text--medium ez-margin-right--medium" }, h("strong", { class: "ez-text ez-text--primary ez-text--medium" }, `${firstRecord}-${lastRecord}`), total == undefined ? ` de ${count + 1} ou mais` : ` de ${total}`),
235
240
  h("ez-button", { size: "small", iconName: "chevron-left", class: "ez-margin-right--medium", mode: "icon", enabled: currentPage > 0, onClick: () => this.previousPage(), label: "P\u00E1gina anterior" }),
236
241
  h("ez-button", { size: "small", iconName: "chevron-right", class: "ez-margin-right--medium", mode: "icon", enabled: hasMore, onClick: () => this.nextPage(), label: "Pr\u00F3xima P\u00E1gina" }),
237
242
  ];
@@ -267,15 +272,13 @@ export class EzGrid {
267
272
  if (this.config) {
268
273
  this.observeConfig(this.config);
269
274
  }
275
+ if (this.dataUnit != undefined) {
276
+ this._paginationInfo = this.dataUnit.getPaginationInfo();
277
+ }
270
278
  this.buildDataElementId();
271
279
  this.setEvents();
272
280
  this.componentReady.emit();
273
281
  this._gridController.configFilterColumn(this._filterColumn);
274
- this._container.addEventListener('focusout', (event) => {
275
- const api = this._gridController.getGridApi();
276
- if (api && !this._container.contains(event.relatedTarget))
277
- api.clearFocusedCell();
278
- });
279
282
  }
280
283
  componentWillRender() {
281
284
  this.configSelectionCounter();
@@ -39,9 +39,9 @@ export class FilterColumn {
39
39
  await this.hide();
40
40
  this.fieldDescriptor = this.dataUnit.getField(configs.columnName);
41
41
  this.buildIsTextSearch();
42
- this.setOptions(configs.filteredOptions);
43
42
  this.columnName = configs.columnName;
44
43
  this.columnLabel = configs.columnLabel;
44
+ await this.setOptions(configs.filteredOptions);
45
45
  await this.ezPopoverElement.show(this.calcTopPosition(), this.calculateLeftPosition(configs));
46
46
  }
47
47
  }
@@ -106,10 +106,22 @@ export class FilterColumn {
106
106
  return this.fieldDescriptor.userInterface === UserInterface.SWITCH
107
107
  || this.fieldDescriptor.userInterface === UserInterface.CHECKBOX;
108
108
  }
109
- setOptions(selectedItems) {
109
+ async setOptions(selectedItems) {
110
110
  const validateFieldUserInterfaceOptionSelector = this.hasToUseOptions();
111
- this.useOptions = validateFieldUserInterfaceOptionSelector;
112
- this.options = validateFieldUserInterfaceOptionSelector ? this.buildOptions(selectedItems) : (selectedItems !== null && selectedItems !== void 0 ? selectedItems : null);
111
+ if (validateFieldUserInterfaceOptionSelector) {
112
+ this.useOptions = validateFieldUserInterfaceOptionSelector;
113
+ this.options = validateFieldUserInterfaceOptionSelector ? this.buildOptions(selectedItems) : (selectedItems !== null && selectedItems !== void 0 ? selectedItems : null);
114
+ return;
115
+ }
116
+ const options = await this.dataSource.getStaticOptions(this.columnName);
117
+ if (options != undefined) {
118
+ const selected = new Set((selectedItems || []).filter(item => item.check).map(item => item.label));
119
+ this.useOptions = true;
120
+ this.options = selected.size === 0 ? options : options.map(option => (Object.assign(Object.assign({}, option), { check: selected.has(option.label) })));
121
+ return;
122
+ }
123
+ this.useOptions = false;
124
+ this.options = null;
113
125
  }
114
126
  buildOptions(selectedItems) {
115
127
  var _a, _b;
@@ -11,6 +11,12 @@ export default class InMemoryFilterColumnDataSource {
11
11
  this.originalRecords = (_a = this.dataUnit.records) !== null && _a !== void 0 ? _a : [];
12
12
  this.dataUnit.subscribe(this.onDataUnitAction);
13
13
  }
14
+ getStaticOptions(fieldName) {
15
+ return new Promise(resolve => {
16
+ const options = this.originalRecords.map(item => this.buildFieldOption(item, fieldName));
17
+ resolve(this.removeDuplicatedOptions(options));
18
+ });
19
+ }
14
20
  fetchData(filterTerm, fieldName) {
15
21
  return new Promise(resolve => {
16
22
  const filteredRecords = this.originalRecords.filter(record => this.includesSearchTerm(record, fieldName, filterTerm));
@@ -52,8 +52,18 @@ export class EzMuiltiSelectionList {
52
52
  ordenationByCheckStateAndAlphabetically(filteredOptions) {
53
53
  const listWithSelectChecked = [];
54
54
  const listWithNotSelectChecked = [];
55
- filteredOptions.forEach(item => (item.check ? listWithSelectChecked.push(item) : listWithNotSelectChecked.push(item)));
56
- return [...ArrayUtils.sortAlphabetically(listWithSelectChecked), ...ArrayUtils.sortAlphabetically(listWithNotSelectChecked)];
55
+ let emptyElement;
56
+ filteredOptions.forEach(item => {
57
+ if (item.value == undefined || item.label === "") {
58
+ emptyElement = Object.assign(Object.assign({}, item), { label: "(Vazio)" });
59
+ }
60
+ else {
61
+ (item.check ? listWithSelectChecked.push(item) : listWithNotSelectChecked.push(item));
62
+ }
63
+ });
64
+ return (emptyElement == undefined ? [] : [emptyElement])
65
+ .concat(ArrayUtils.sortAlphabetically(listWithSelectChecked))
66
+ .concat(ArrayUtils.sortAlphabetically(listWithNotSelectChecked));
57
67
  }
58
68
  changeCheckAllValeuFromFilteredOptions() {
59
69
  var _a, _b, _c, _d;
@@ -152,13 +162,14 @@ export class EzMuiltiSelectionList {
152
162
  }
153
163
  scenarioToDisplay(view) {
154
164
  const scenarios = {
155
- [ViewScenarios.DATASOURCE_INIT]: this.buildInitViewWithDataSource(),
156
- [ViewScenarios.DATASOURCE_RESULTS]: this.buildViewList(true),
157
- [ViewScenarios.DATASOURCE_RESULTS_EMPTY]: this.buildViewEmptyResults(),
158
- [ViewScenarios.OPTIONS_EMPTY]: this.buildViewEmptyResults(),
159
- [ViewScenarios.OPTIONS]: this.buildViewList(false),
165
+ [ViewScenarios.DATASOURCE_INIT]: () => this.buildInitViewWithDataSource(),
166
+ [ViewScenarios.DATASOURCE_RESULTS]: () => this.buildViewList(true),
167
+ [ViewScenarios.DATASOURCE_RESULTS_EMPTY]: () => this.buildViewEmptyResults(),
168
+ [ViewScenarios.OPTIONS_EMPTY]: () => this.buildViewEmptyResults(),
169
+ [ViewScenarios.OPTIONS]: () => this.buildViewList(false),
160
170
  };
161
- return scenarios[view];
171
+ const scenarioBuilder = scenarios[view];
172
+ return scenarioBuilder ? scenarioBuilder() : undefined;
162
173
  }
163
174
  render() {
164
175
  return (h(Host, null, h("div", { class: "multi-selection" }, this.useOptions ? (h("ez-filter-input", { ref: (element) => (this.filterInput = element), label: `Buscar..`, onEzChange: this.handleSearchOnOption.bind(this) })) : (h("ez-search", { class: "multi-selection__input", label: `Buscar...`, ref: (element) => (this.searchInput = element), suppressEmptyOption: true, showOptionValue: false, showSelectedValue: false, optionLoader: (search) => this.searchWithDataSource(search, this.columnName), onEzChange: this.handleSearchOnDataSource.bind(this), isTextSearch: this.isTextSearch })), h("ez-scroll", { class: "multi-selection__content-options" }, this.scenarioToDisplay(this.viewScenario)))));
@@ -234,7 +245,7 @@ export class EzMuiltiSelectionList {
234
245
  },
235
246
  "options": {
236
247
  "type": "unknown",
237
- "mutable": false,
248
+ "mutable": true,
238
249
  "complexType": {
239
250
  "original": "IMultiSelectionOption[]",
240
251
  "resolved": "IMultiSelectionOption[]",
@@ -1,3 +1,4 @@
1
1
  export const REQUIRED_INFO = " (obrigatório) *";
2
2
  export const ALL_RECORD = "ALL_RECORD";
3
3
  export const DISTINCT_FILTER_NAME_PREFIX = 'FILTRO_COLUNA_';
4
+ export const EZ_GRID_LOADING_SOURCE = "EZ_GRID_LOADING_SOURCE";