@sankhyalabs/ezui 1.1.125 → 1.1.128

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 (68) hide show
  1. package/dist/cjs/ez-collapsible-box.cjs.entry.js +22 -9
  2. package/dist/cjs/ez-form.cjs.entry.js +18 -15
  3. package/dist/cjs/ez-grid.cjs.entry.js +115 -25
  4. package/dist/cjs/ez-list.cjs.entry.js +6 -0
  5. package/dist/cjs/ez-tabselector.cjs.entry.js +2 -2
  6. package/dist/cjs/ez-text-area.cjs.entry.js +13 -3
  7. package/dist/cjs/ezui.cjs.js +1 -1
  8. package/dist/cjs/grid-config.cjs.entry.js +164 -32
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/select-box.cjs.entry.js +1 -1
  11. package/dist/collection/components/ez-check/ez-check.js +1 -1
  12. package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +92 -83
  13. package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.js +52 -21
  14. package/dist/collection/components/ez-form/ez-form.css +5 -0
  15. package/dist/collection/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.js +1 -1
  16. package/dist/collection/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.js +1 -1
  17. package/dist/collection/components/ez-form/fieldbuilder/tpl/DateInput.tpl.js +3 -3
  18. package/dist/collection/components/ez-form/fieldbuilder/tpl/FileInput.tpl.js +1 -1
  19. package/dist/collection/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.js +1 -1
  20. package/dist/collection/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.js +1 -1
  21. package/dist/collection/components/ez-form/fieldbuilder/tpl/TextArea.tpl.js +1 -1
  22. package/dist/collection/components/ez-form/fieldbuilder/tpl/TextInput.tpl.js +1 -1
  23. package/dist/collection/components/ez-form/structure/FormItem.js +1 -1
  24. package/dist/collection/components/ez-form/structure/FormSheet.js +2 -2
  25. package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +4 -1
  26. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +38 -18
  27. package/dist/collection/components/ez-grid/ez-grid.js +124 -14
  28. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.js +188 -39
  29. package/dist/collection/components/ez-grid/subcomponents/select-box/select-box.js +1 -1
  30. package/dist/collection/components/ez-list/ez-list.js +23 -1
  31. package/dist/collection/components/ez-tabselector/ez-tabselector.css +1 -1
  32. package/dist/collection/components/ez-tabselector/ez-tabselector.js +1 -1
  33. package/dist/collection/components/ez-text-area/ez-text-area.js +15 -4
  34. package/dist/custom-elements/index.js +344 -90
  35. package/dist/esm/ez-collapsible-box.entry.js +23 -10
  36. package/dist/esm/ez-form.entry.js +18 -15
  37. package/dist/esm/ez-grid.entry.js +115 -25
  38. package/dist/esm/ez-list.entry.js +6 -0
  39. package/dist/esm/ez-tabselector.entry.js +2 -2
  40. package/dist/esm/ez-text-area.entry.js +13 -3
  41. package/dist/esm/ezui.js +1 -1
  42. package/dist/esm/grid-config.entry.js +164 -32
  43. package/dist/esm/loader.js +1 -1
  44. package/dist/esm/select-box.entry.js +1 -1
  45. package/dist/ezui/ezui.esm.js +1 -1
  46. package/dist/ezui/{p-4262a462.entry.js → p-2d165ca8.entry.js} +1 -1
  47. package/dist/ezui/p-47fe4273.entry.js +1 -0
  48. package/dist/ezui/p-5a9ab4f7.entry.js +1 -0
  49. package/dist/ezui/p-5b7405e8.entry.js +1 -0
  50. package/dist/ezui/p-66adbed5.entry.js +1 -0
  51. package/dist/ezui/p-6d39b7ea.entry.js +1 -0
  52. package/dist/ezui/p-7d5b2ebf.entry.js +1 -0
  53. package/dist/ezui/p-ef17f443.entry.js +1 -0
  54. package/dist/types/components/ez-collapsible-box/ez-collapsible-box.d.ts +13 -5
  55. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +35 -1
  56. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +3 -3
  57. package/dist/types/components/ez-grid/ez-grid.d.ts +14 -3
  58. package/dist/types/components/ez-grid/subcomponents/gridconfig/grid-config.d.ts +10 -4
  59. package/dist/types/components/ez-list/ez-list.d.ts +5 -0
  60. package/dist/types/components.d.ts +36 -10
  61. package/package.json +2 -2
  62. package/dist/ezui/p-1c28d99b.entry.js +0 -1
  63. package/dist/ezui/p-35edc488.entry.js +0 -1
  64. package/dist/ezui/p-46d1340b.entry.js +0 -1
  65. package/dist/ezui/p-6745931a.entry.js +0 -1
  66. package/dist/ezui/p-7ee0ff27.entry.js +0 -1
  67. package/dist/ezui/p-91e51dc9.entry.js +0 -1
  68. package/dist/ezui/p-c621cab9.entry.js +0 -1
@@ -1,8 +1,8 @@
1
- import { Component, h, Host, Prop, Event, Watch, Method } from "@stencil/core";
1
+ import { Component, h, Prop, Event, Watch, Method } from "@stencil/core";
2
2
  export class EzCollapsibleBox {
3
3
  constructor() {
4
4
  /**
5
- * Valor externalizado que garante a exibição ou não do componente
5
+ * Valor externalizado que garante a exibição ou não do componente.
6
6
  */
7
7
  this.value = false;
8
8
  /**
@@ -13,27 +13,40 @@ export class EzCollapsibleBox {
13
13
  * Define o local onde o ícone será renderizado.
14
14
  */
15
15
  this.iconPlacement = "left";
16
+ /**
17
+ * Define se o titulo irá ocupar toda a largura do componente.
18
+ */
19
+ this.stretchTitle = false;
16
20
  }
17
- observeValue() {
21
+ observeCollapsedValue() {
18
22
  this.ezChange.emit(this.value);
19
23
  }
20
24
  /**
21
- * Esconde ou revela o conteúdo do componente
25
+ * Esconde ou revela o conteúdo do componente.
22
26
  */
23
27
  async showHide() {
24
28
  this.value = !this.value;
25
29
  }
30
+ /**
31
+ * Retorna o tamanho configurado do texto e do ícone.
32
+ */
33
+ getHeaderSize() {
34
+ const sizeAlias = ["xsmall", "xlarge"];
35
+ const sizeList = ["x-small", "small", "medium", "large", "x-large"];
36
+ const sizeLowerCase = this.headerSize && this.headerSize.toLowerCase();
37
+ const sizeCustom = sizeAlias.includes(sizeLowerCase) ? sizeLowerCase.replace('x', 'x-') : sizeLowerCase;
38
+ return sizeList.includes(sizeCustom) ? sizeCustom : "small";
39
+ }
26
40
  render() {
27
- return (h(Host, null,
28
- this.iconPlacement == "right" ?
29
- h("div", { class: "collapsible-box__title" },
30
- h("label", { class: (this.iconPlacement == "right" ? "collapsible-box__label--icon-right " : "collapsible-box__label ") + (this.headerSize ? "font--" + this.headerSize : ""), onClick: () => this.showHide(), title: this.label }, this.label),
31
- h("button", { class: this.value ? "collapsible-box__btn collapsible-box__btn--collapsed " + "collapsible-box__btn--" + this.headerSize : "collapsible-box__btn " + "collapsible-box__btn--" + this.headerSize, onClick: () => this.showHide() }))
32
- :
33
- h("div", { class: "collapsible-box__title" },
34
- h("button", { class: this.value ? "collapsible-box__btn collapsible-box__btn--collapsed " + "collapsible-box__btn--" + this.headerSize : "collapsible-box__btn " + "collapsible-box__btn--" + this.headerSize, onClick: () => this.showHide() }),
35
- h("label", { class: (this.iconPlacement == "right" ? "collapsible-box__label--icon-right " : "collapsible-box__label ") + (this.headerSize ? "font--" + this.headerSize : ""), onClick: () => this.showHide(), title: this.label }, this.label)),
36
- !this.value ? h("slot", null) : null));
41
+ return (h("div", { class: "collapsible-box" },
42
+ h("div", { class: "collapsible-box__header" },
43
+ h("button", { onClick: () => this.showHide(), class: "collapsible-box__title" +
44
+ (this.iconPlacement === "right" ? " collapsible-box__title--icon-right" : "") +
45
+ (this.stretchTitle ? " collapsible-box__title--stretched" : "") },
46
+ h("ez-icon", { slot: "icon", "icon-name": "chevron-right", size: this.getHeaderSize(), class: "collapsible-box__icon collapsible-box__icon--" + this.getHeaderSize() + (this.value ? " collapsible-box__icon--collapsed" : "") }),
47
+ h("label", { class: "collapsible-box__label font--" + this.getHeaderSize(), title: this.label }, this.label))),
48
+ h("div", { class: "collapsible-box__content" + (this.value ? "" : " collapsible-box__content--show") },
49
+ h("slot", null))));
37
50
  }
38
51
  static get is() { return "ez-collapsible-box"; }
39
52
  static get encapsulation() { return "shadow"; }
@@ -56,7 +69,7 @@ export class EzCollapsibleBox {
56
69
  "optional": false,
57
70
  "docs": {
58
71
  "tags": [],
59
- "text": "Valor externalizado que garante a exibi\u00E7\u00E3o ou n\u00E3o do componente"
72
+ "text": "Valor externalizado que garante a exibi\u00E7\u00E3o ou n\u00E3o do componente."
60
73
  },
61
74
  "attribute": "value",
62
75
  "reflect": true,
@@ -83,8 +96,8 @@ export class EzCollapsibleBox {
83
96
  "type": "string",
84
97
  "mutable": false,
85
98
  "complexType": {
86
- "original": "string",
87
- "resolved": "string",
99
+ "original": "\"x-small\" | \"small\" | \"medium\" | \"large\" | \"x-large\" | undefined",
100
+ "resolved": "\"large\" | \"medium\" | \"small\" | \"x-large\" | \"x-small\"",
88
101
  "references": {}
89
102
  },
90
103
  "required": false,
@@ -101,8 +114,8 @@ export class EzCollapsibleBox {
101
114
  "type": "string",
102
115
  "mutable": false,
103
116
  "complexType": {
104
- "original": "string",
105
- "resolved": "string",
117
+ "original": "\"left\" | \"right\"",
118
+ "resolved": "\"left\" | \"right\"",
106
119
  "references": {}
107
120
  },
108
121
  "required": false,
@@ -114,6 +127,24 @@ export class EzCollapsibleBox {
114
127
  "attribute": "icon-placement",
115
128
  "reflect": true,
116
129
  "defaultValue": "\"left\""
130
+ },
131
+ "stretchTitle": {
132
+ "type": "boolean",
133
+ "mutable": false,
134
+ "complexType": {
135
+ "original": "boolean",
136
+ "resolved": "boolean",
137
+ "references": {}
138
+ },
139
+ "required": false,
140
+ "optional": false,
141
+ "docs": {
142
+ "tags": [],
143
+ "text": "Define se o titulo ir\u00E1 ocupar toda a largura do componente."
144
+ },
145
+ "attribute": "stretch-title",
146
+ "reflect": true,
147
+ "defaultValue": "false"
117
148
  }
118
149
  }; }
119
150
  static get events() { return [{
@@ -145,13 +176,13 @@ export class EzCollapsibleBox {
145
176
  "return": "Promise<void>"
146
177
  },
147
178
  "docs": {
148
- "text": "Esconde ou revela o conte\u00FAdo do componente",
179
+ "text": "Esconde ou revela o conte\u00FAdo do componente.",
149
180
  "tags": []
150
181
  }
151
182
  }
152
183
  }; }
153
184
  static get watchers() { return [{
154
185
  "propName": "value",
155
- "methodName": "observeValue"
186
+ "methodName": "observeCollapsedValue"
156
187
  }]; }
157
188
  }
@@ -2,4 +2,9 @@ ez-form {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: 100%;
5
+ }
6
+
7
+ .dynamic-content ez-collapsible-box {
8
+ --ez-collapsible-box__header--padding-right: var(--space-small, 6px);
9
+ --ez-collapsible-box__header--padding-left: var(--space-small, 6px);
5
10
  }
@@ -6,6 +6,6 @@ export const buildCheckBox = (fieldConfig) => {
6
6
  return buildField(fieldConfig.name, fieldConfig.label, fieldConfig.readOnly, false);
7
7
  };
8
8
  function buildField(fieldName, fieldLabel, readOnly, switchMode = false) {
9
- return (h("div", { class: "col col--sd-12 col--tb-3 align--middle padding-horizontal--small padding-bottom--large" },
9
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-align--middle ez-padding-horizontal--small ez-padding-bottom--large" },
10
10
  h("ez-check", { enabled: !readOnly, label: fieldLabel, mode: switchMode ? "switch" : "regular", "data-field-name": fieldName, key: fieldName })));
11
11
  }
@@ -9,6 +9,6 @@ export const buildComboBox = ({ name, label, readOnly, required }, properties) =
9
9
  else {
10
10
  options = prop;
11
11
  }
12
- return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
12
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
13
13
  h("ez-combo-box", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name, options: options })));
14
14
  };
@@ -1,13 +1,13 @@
1
1
  import { h } from "@stencil/core";
2
2
  export const buildDate = ({ name, label, readOnly }) => {
3
- return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
3
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
4
4
  h("ez-date-input", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
5
5
  };
6
6
  export const buildTime = ({ name, label }) => {
7
- return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
7
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
8
8
  h("ez-time-input", { label: label, "data-field-name": name, key: name })));
9
9
  };
10
10
  export const buildTimeDate = ({ name, label }) => {
11
- return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
11
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
12
12
  h("ez-date-time-input", { label: label, "data-field-name": name, key: name })));
13
13
  };
@@ -1,5 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
2
  export const buildFile = ({ name, label, readOnly }) => {
3
- return (h("div", { class: "col col--sd-12 padding-horizontal--small" },
3
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small" },
4
4
  h("ez-upload", { enabled: !readOnly, label: label, "data-field-name": name, key: name })));
5
5
  };
@@ -8,6 +8,6 @@ export const buildInteger = ({ name, label, readOnly }) => {
8
8
  return buildNumeric(name, label, readOnly, 0, 0);
9
9
  };
10
10
  function buildNumeric(fieldName, fieldLabel, readOnly, precision, prettyPrecision) {
11
- return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
11
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
12
12
  h("ez-number-input", { enabled: !readOnly, label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
13
13
  }
@@ -1,5 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
2
  export const buildSearch = ({ name, label, readOnly, required }) => {
3
- return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
3
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
4
4
  h("ez-search", { enabled: !readOnly, suppressEmptyOption: required, label: label, "data-field-name": name, key: name })));
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
2
  export const buildTextArea = ({ name, label, readOnly }) => {
3
- return (h("div", { class: "col col--sd-12 padding-horizontal--small", key: name },
3
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-padding-horizontal--small", key: name },
4
4
  h("ez-text-area", { enabled: !readOnly, label: label, "data-field-name": name })));
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import { h } from "@stencil/core";
2
2
  export const buildTextInput = ({ name, label }) => {
3
- return (h("div", { class: "col col--sd-12 col--tb-3 padding-horizontal--small" },
3
+ return (h("div", { class: "ez-col ez-col--sd-12 ez-col--tb-3 ez-padding-horizontal--small" },
4
4
  h("ez-text-input", { label: label, "data-field-name": name, key: name })));
5
5
  };
@@ -3,7 +3,7 @@ import { buildField } from "../fieldbuilder/FieldBuilder";
3
3
  export const FormItem = ({ source }) => {
4
4
  if ("items" in source) {
5
5
  const fieldSet = source;
6
- return h("ez-collapsible-box", { label: source.label }, fieldSet.items.map(fi => buildField(fi)));
6
+ return h("ez-collapsible-box", { label: source.label, "header-size": "large" }, fieldSet.items.map(fi => buildField(fi)));
7
7
  }
8
8
  else {
9
9
  return buildField(source);
@@ -1,6 +1,6 @@
1
1
  import { h } from "@stencil/core";
2
2
  import { FormItem } from "./FormItem";
3
3
  export const FormSheet = ({ store, source }) => {
4
- return (h("div", { class: "box__container" },
5
- h("div", { class: "row padding-vertical--small" }, source.items.map(item => h(FormItem, { store: store, source: item })))));
4
+ return (h("div", { class: "dynamic-content ez-box__container" },
5
+ h("div", { class: "ez-row ez-padding-vertical--small" }, source.items.map(item => h(FormItem, { store: store, source: item })))));
6
6
  };
@@ -46,6 +46,9 @@ function getTabConfig(tab, sheets) {
46
46
  const tabConfig = (typeof tab === "string" ? Array.from(sheets.keys()).find(t => t.label === tab) : tab);
47
47
  return tabConfig || { label: tab, visible: true };
48
48
  }
49
+ function sortTabs(a, b) {
50
+ return a[0].label == 'Geral' ? -1 : (a[0].order || 10000) - (b[0].order || 10000);
51
+ }
49
52
  export const buildFromConfig = (fields, dataUnit) => {
50
53
  const sheets = new Map();
51
54
  const requiredFields = [];
@@ -87,7 +90,7 @@ export const buildFromConfig = (fields, dataUnit) => {
87
90
  });
88
91
  const metadata = new FormMetadata();
89
92
  Array.from(sheets.entries())
90
- .sort((a, b) => (a[0].order || 10000) - (b[0].order || 10000))
93
+ .sort(sortTabs)
91
94
  .forEach(([key, value]) => {
92
95
  metadata.addSheet({
93
96
  label: key.label,
@@ -44,6 +44,7 @@ export default class AgGridController {
44
44
  serverSideStoreType: "partial",
45
45
  rowSelection: this._multipleSelection ? "multiple" : "single",
46
46
  serverSideDatasource: this._dataSource,
47
+ sortingOrder: ['desc', 'asc', null],
47
48
  getRowNodeId: (params) => typeof params === "string" ? params : params[this._idAttribName],
48
49
  getMainMenuItems: (params) => {
49
50
  const column = params.column;
@@ -83,6 +84,7 @@ export default class AgGridController {
83
84
  opt.onSelectionChanged = e => this.onSelectionChange(e);
84
85
  opt.onPaginationChanged = () => this.onPaginationChange();
85
86
  opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
87
+ opt.onDragStopped = evt => this.onCallStateChange("columnMovedEnd", evt);
86
88
  opt.onViewportChanged = () => {
87
89
  if (this._dataUnit) {
88
90
  this.selectRows(this._dataUnit.getSelection());
@@ -170,6 +172,7 @@ export default class AgGridController {
170
172
  const colDefs = [];
171
173
  if (showCheckSelection) {
172
174
  colDefs.push({
175
+ colId: "checkBoxColumn",
173
176
  headerName: "",
174
177
  checkboxSelection: true,
175
178
  headerCheckboxSelection: false,
@@ -207,13 +210,24 @@ export default class AgGridController {
207
210
  if (this._grid === undefined) {
208
211
  throw new Error("Erro interno: Grid ainda não inicializado.");
209
212
  }
210
- //TODO neste ponto estamos utilizando um método descontinuado,
211
- //pelo fato de que o applyColumnState não reordena as colunas conforme
212
- //o estado passado.
213
- //https://stackoverflow.com/questions/51488241/ag-grid-how-to-save-and-reload-column-order
214
- //Assim que for corrigido o applyColumnState devemos substituir o setColumnState por ele.
215
- // this._gridOptions.columnApi.applyColumnState({ state: state.map(s => this.buildColState(s)) });
216
- this._gridOptions.columnApi.setColumnState(state.map(s => this.buildColState(s)));
213
+ let columns = this.getColumnsDef();
214
+ let visibleColumns = [];
215
+ let sort = [];
216
+ state.forEach((cfgColumn, index) => {
217
+ this._gridOptions.columnApi.moveColumn(cfgColumn.name, index + 1);
218
+ this._gridOptions.columnApi.setColumnWidth(cfgColumn.name, cfgColumn.width);
219
+ visibleColumns.push(cfgColumn.name);
220
+ if (cfgColumn.ascending !== undefined) {
221
+ sort.push({ colId: cfgColumn.name, sort: cfgColumn.ascending !== true ? 'desc' : 'asc', sortIndex: cfgColumn.orderIndex });
222
+ }
223
+ });
224
+ let invisibleColumns = columns.filter(column => !visibleColumns.includes(column.name)).map(column => column.name);
225
+ this._gridOptions.columnApi.setColumnsVisible(visibleColumns, true);
226
+ this._gridOptions.columnApi.setColumnsVisible(invisibleColumns, false);
227
+ this._gridOptions.columnApi.applyColumnState({
228
+ state: sort,
229
+ defaultState: { sort: null },
230
+ });
217
231
  }
218
232
  getColumnsState() {
219
233
  if (this._grid === undefined) {
@@ -306,21 +320,27 @@ export default class AgGridController {
306
320
  }
307
321
  }
308
322
  }
309
- buildColState(source) {
310
- return {
311
- colId: source.name,
312
- sort: source.sort,
313
- sortIndex: source.sortIndex,
314
- width: source.width,
315
- pinned: source.pinned ? "left" : null,
316
- hide: source.hidden
317
- };
318
- }
319
323
  onCallStateChange(type, e) {
320
324
  const finished = !("finished" in e) || e["finished"];
321
325
  if (finished && this._columnStateChangeCallback) {
322
- this._columnStateChangeCallback(type, this.getColumnsState());
326
+ let info = {};
327
+ let isUserChange = this.isUIEvent(e['source'], e['type']);
328
+ if (type === 'columnResize') {
329
+ info['column'] = { colId: e['column'].colId, actualWidth: e['column'].actualWidth };
330
+ }
331
+ info['isUserChange'] = isUserChange;
332
+ this._columnStateChangeCallback(type, this.getColumnsState(), info);
333
+ }
334
+ }
335
+ isUIEvent(source, type) {
336
+ let optionsArr = ["uiColumnMoved", "uiColumnResized", "uiColumnDragged", "uiColumnExpanded", "uiColumnSorted"];
337
+ if (type === 'dragStopped') {
338
+ return true;
339
+ }
340
+ if (source) {
341
+ return optionsArr.includes(source);
323
342
  }
343
+ return false;
324
344
  }
325
345
  onSelectionChange(e) {
326
346
  if (this._selectionChangeCallback) {
@@ -1,4 +1,4 @@
1
- import { Component, h, Host, Prop, Method, Event, State } from "@stencil/core";
1
+ import { Component, h, Host, Prop, Method, Event, State, Watch } from "@stencil/core";
2
2
  import AgGridController from "./controller/ag-grid/AgGridController";
3
3
  import DataUnitBridge from "./controller/DataUnitBridge";
4
4
  export class EzGrid {
@@ -72,9 +72,72 @@ export class EzGrid {
72
72
  addEventListener("ezSelectionChange", (evt) => this.dataUnit.setSelection(evt.detail.map((r) => r.__record__id__)));
73
73
  }
74
74
  }
75
+ onColumnStateChange(type, state, info) {
76
+ var _a;
77
+ this.ezColumnStateChange.emit({ type, state, isUserChange: info.isUserChange });
78
+ if (info.isUserChange) {
79
+ if (type === 'columnMovedEnd') {
80
+ let newConfig;
81
+ if (this.config) {
82
+ newConfig = { columns: [] };
83
+ state.forEach(columnState => {
84
+ let newConfigColumn = this.config.columns.find(column => column.name === columnState.name);
85
+ if (newConfigColumn) {
86
+ newConfigColumn.width = columnState.width;
87
+ newConfig.columns.push(newConfigColumn);
88
+ }
89
+ });
90
+ }
91
+ else {
92
+ newConfig = this.createConfigFromState(state);
93
+ }
94
+ if (newConfig.columns.length > 0) {
95
+ this.configChange.emit(newConfig);
96
+ }
97
+ }
98
+ else if (type === 'columnResize') {
99
+ if ((_a = info.column) === null || _a === void 0 ? void 0 : _a.colId) {
100
+ let newConfig;
101
+ if (this.config) {
102
+ newConfig = Object.assign({}, this.config);
103
+ }
104
+ else {
105
+ newConfig = this.createConfigFromState(state);
106
+ }
107
+ let newColumn = newConfig.columns.find(column => column.name === info.column.colId);
108
+ if (newColumn) {
109
+ newColumn.width = info.column.actualWidth;
110
+ this.configChange.emit(newConfig);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ createConfigFromState(state) {
117
+ let newConfig = { columns: [] };
118
+ state.forEach(columnState => {
119
+ if (!columnState.hidden) {
120
+ let newConfigColumn = { name: columnState.name };
121
+ if (columnState.width) {
122
+ newConfigColumn['width'] = columnState.width;
123
+ }
124
+ if (columnState.sort) {
125
+ newConfigColumn['ascending'] = (columnState.sort.toUpperCase() === 'ASC');
126
+ newConfigColumn['orderIndex'] = columnState.sortIndex;
127
+ }
128
+ else {
129
+ newConfigColumn['orderIndex'] = 0;
130
+ }
131
+ if (newConfigColumn) {
132
+ newConfig.columns.push(newConfigColumn);
133
+ }
134
+ }
135
+ });
136
+ return newConfig;
137
+ }
75
138
  componentDidLoad() {
76
139
  this._gridController.initDatagrid(this._container, {
77
- onColumnStateChange: (type, state) => this.ezColumnStateChange.emit({ type, state }),
140
+ onColumnStateChange: (type, state, info) => this.onColumnStateChange(type, state, info),
78
141
  onSelectionChange: (selection) => this.ezSelectionChange.emit(selection),
79
142
  onPaginationChange: (status) => {
80
143
  this._navigationHasPrevious = status.hasPrevious;
@@ -94,6 +157,9 @@ export class EzGrid {
94
157
  if (this._dataUnitBridge) {
95
158
  this._gridController.setColumnsDef(this._dataUnitBridge.buildColumnDefs(), true);
96
159
  }
160
+ if (this.config) {
161
+ this.applyConfig(this.config);
162
+ }
97
163
  }
98
164
  disconnectedCallback() {
99
165
  if (this._dataUnitBridge) {
@@ -105,15 +171,15 @@ export class EzGrid {
105
171
  return null;
106
172
  }
107
173
  return [
108
- h("div", { class: "text text--primary text--medium margin-right--medium" },
109
- h("strong", { class: "text text--primary text--medium" }, `${this._navigationFirstRow}-${this._navigationLastRow}`),
174
+ h("div", { class: "ez-text ez-text--primary ez-text--medium ez-margin-right--medium" },
175
+ h("strong", { class: "ez-text ez-text--primary ez-text--medium" }, `${this._navigationFirstRow}-${this._navigationLastRow}`),
110
176
  ` de ${this._navigationTotalRows}`),
111
- h("ez-button", { size: "small", iconName: "chevron-left", class: "margin-right--medium", mode: "icon", enabled: this._navigationHasPrevious, onClick: () => this._gridController.previousPage(), label: "P\u00E1gina anterior" }),
112
- h("ez-button", { size: "small", iconName: "chevron-right", class: "margin-right--medium", mode: "icon", enabled: this._navigationHasNext, onClick: () => this._gridController.nextPage(), label: "Pr\u00F3xima P\u00E1gina" })
177
+ h("ez-button", { size: "small", iconName: "chevron-left", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasPrevious, onClick: () => this._gridController.previousPage(), label: "P\u00E1gina anterior" }),
178
+ h("ez-button", { size: "small", iconName: "chevron-right", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasNext, onClick: () => this._gridController.nextPage(), label: "Pr\u00F3xima P\u00E1gina" })
113
179
  ];
114
180
  }
115
- applyConfig(cols) {
116
- this._gridController.setColumnsState(cols);
181
+ applyConfig(config) {
182
+ this._gridController.setColumnsState(config.columns);
117
183
  this.closeConfig();
118
184
  }
119
185
  closeConfig() {
@@ -126,16 +192,16 @@ export class EzGrid {
126
192
  }
127
193
  render() {
128
194
  return (h(Host, null,
129
- h("div", { class: "box box--shadow padding--medium grid-header" },
195
+ h("div", { class: "ez-box ez-box--shadow ez-padding--medium grid-header" },
130
196
  h("div", { class: "grid-header__container" },
131
197
  h("slot", { name: "leftButtons" })),
132
198
  h("div", { class: "grid-header__container" },
133
199
  this.getPaginationControl(),
134
- h("ez-button", { size: "small", iconName: "settings", class: "button--secondary", mode: "icon", onClick: () => { this.openConfig(); } }))),
135
- h("div", { class: "grid__container ag-sankhya-theme", ref: elem => this._container = elem }),
200
+ h("ez-button", { size: "small", iconName: "settings", class: "ez-button--secondary", mode: "icon", onClick: () => { this.openConfig(); } }))),
201
+ h("div", { class: "grid__container ez-grid", ref: elem => this._container = elem }),
136
202
  h("div", { class: "grid__footer" }),
137
203
  h("ez-modal", { modalSize: "small", closeEsc: true, closeOutsideClick: true, opened: this._popUpVisible, onEzCloseModal: () => this._popUpVisible = false },
138
- h("grid-config", { ref: ref => this._gridConfig = ref, selectedTab: "Colunas", onConfigFinish: evt => this.applyConfig(evt.detail), onConfigCancel: _evt => this.closeConfig() }))));
204
+ h("grid-config", { ref: ref => this._gridConfig = ref, config: this.config, selectedTab: "Colunas", onConfigFinish: evt => { this.applyConfig(evt.detail); this.configChange.emit(evt.detail); }, onConfigCancel: _evt => this.closeConfig() }))));
139
205
  }
140
206
  static get is() { return "ez-grid"; }
141
207
  static get encapsulation() { return "scoped"; }
@@ -164,6 +230,26 @@ export class EzGrid {
164
230
  "attribute": "multiple-selection",
165
231
  "reflect": false
166
232
  },
233
+ "config": {
234
+ "type": "unknown",
235
+ "mutable": true,
236
+ "complexType": {
237
+ "original": "EzGridConfig",
238
+ "resolved": "EzGridConfig",
239
+ "references": {
240
+ "EzGridConfig": {
241
+ "location": "import",
242
+ "path": "./controller/EzGridController"
243
+ }
244
+ }
245
+ },
246
+ "required": false,
247
+ "optional": false,
248
+ "docs": {
249
+ "tags": [],
250
+ "text": "Configura\u00E7\u00E3o de exibi\u00E7\u00E3o da grade."
251
+ }
252
+ },
167
253
  "pageSize": {
168
254
  "type": "number",
169
255
  "mutable": false,
@@ -282,6 +368,26 @@ export class EzGrid {
282
368
  "resolved": "any",
283
369
  "references": {}
284
370
  }
371
+ }, {
372
+ "method": "configChange",
373
+ "name": "configChange",
374
+ "bubbles": true,
375
+ "cancelable": true,
376
+ "composed": true,
377
+ "docs": {
378
+ "tags": [],
379
+ "text": "Evento disparado ao realizar alguma modifica\u00E7\u00E3o na configura\u00E7\u00E3o da grid."
380
+ },
381
+ "complexType": {
382
+ "original": "EzGridConfig",
383
+ "resolved": "EzGridConfig",
384
+ "references": {
385
+ "EzGridConfig": {
386
+ "location": "import",
387
+ "path": "./controller/EzGridController"
388
+ }
389
+ }
390
+ }
285
391
  }]; }
286
392
  static get methods() { return {
287
393
  "setColumnsDef": {
@@ -340,7 +446,7 @@ export class EzGrid {
340
446
  },
341
447
  "setColumnsState": {
342
448
  "complexType": {
343
- "signature": "(state: Array<EzGridColumn>) => Promise<any>",
449
+ "signature": "(state: Array<EzGridColumnConfig>) => Promise<any>",
344
450
  "parameters": [{
345
451
  "tags": [],
346
452
  "text": ""
@@ -352,7 +458,7 @@ export class EzGrid {
352
458
  "Array": {
353
459
  "location": "global"
354
460
  },
355
- "EzGridColumn": {
461
+ "EzGridColumnConfig": {
356
462
  "location": "import",
357
463
  "path": "./controller/EzGridController"
358
464
  }
@@ -487,4 +593,8 @@ export class EzGrid {
487
593
  }
488
594
  }
489
595
  }; }
596
+ static get watchers() { return [{
597
+ "propName": "config",
598
+ "methodName": "applyConfig"
599
+ }]; }
490
600
  }