@sankhyalabs/sankhyablocks 1.1.22 → 1.1.25

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 (184) hide show
  1. package/dist/cjs/ApplicationUtils-05b74ee9.js +39 -0
  2. package/dist/cjs/AssetsUtils-7e3c38f9.js +24 -0
  3. package/dist/cjs/CSSVarsUtils-75ca9c64.js +19 -0
  4. package/dist/cjs/ez-action-chip.cjs.entry.js +27 -0
  5. package/dist/cjs/ez-application.cjs.entry.js +26 -0
  6. package/dist/cjs/ez-button_4.cjs.entry.js +660 -0
  7. package/dist/cjs/ez-calendar.cjs.entry.js +223 -0
  8. package/dist/cjs/ez-collapsible-box.cjs.entry.js +47 -0
  9. package/dist/cjs/ez-combo-box.cjs.entry.js +278 -0
  10. package/dist/cjs/ez-date-input.cjs.entry.js +102 -0
  11. package/dist/cjs/ez-date-time-input.cjs.entry.js +145 -0
  12. package/dist/cjs/ez-dialog.cjs.entry.js +89 -0
  13. package/dist/cjs/ez-form.cjs.entry.js +463 -0
  14. package/dist/cjs/ez-grid.cjs.entry.js +647 -0
  15. package/dist/cjs/ez-icon.cjs.entry.js +41 -0
  16. package/dist/cjs/ez-label-chip.cjs.entry.js +104 -0
  17. package/dist/cjs/ez-modal_2.cjs.entry.js +316 -0
  18. package/dist/cjs/ez-number-input.cjs.entry.js +86 -0
  19. package/dist/cjs/ez-popover.cjs.entry.js +120 -0
  20. package/dist/cjs/ez-popup.cjs.entry.js +48 -0
  21. package/dist/cjs/ez-search.cjs.entry.js +64 -0
  22. package/dist/cjs/ez-tabselector.cjs.entry.js +198 -0
  23. package/dist/cjs/ez-text-area.cjs.entry.js +114 -0
  24. package/dist/cjs/ez-text-input.cjs.entry.js +201 -0
  25. package/dist/cjs/ez-time-input.cjs.entry.js +118 -0
  26. package/dist/cjs/ez-toast.cjs.entry.js +44 -0
  27. package/dist/cjs/ez-upload.cjs.entry.js +356 -0
  28. package/dist/cjs/index-682c98b2.js +1771 -0
  29. package/dist/cjs/loader.cjs.js +3 -3
  30. package/dist/cjs/sankhyablocks.cjs.js +3 -3
  31. package/dist/cjs/snk-application.cjs.entry.js +319 -1275
  32. package/dist/cjs/test-du.cjs.entry.js +76 -0
  33. package/dist/collection/collection-manifest.json +37 -2
  34. package/dist/collection/components/snk-application/snk-application.js +8 -4
  35. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +16 -9
  36. package/dist/{collection/temp → components}/ApplicationUtils.js +37 -31
  37. package/dist/components/AssetsUtils.js +22 -0
  38. package/dist/components/CSSVarsUtils.js +17 -0
  39. package/dist/components/ez-action-chip.js +44 -0
  40. package/dist/components/ez-application.js +39 -0
  41. package/dist/components/ez-button.js +6 -0
  42. package/dist/components/ez-button2.js +105 -0
  43. package/dist/components/ez-calendar.js +6 -0
  44. package/dist/components/ez-calendar2.js +242 -0
  45. package/dist/components/ez-check.js +6 -0
  46. package/dist/components/ez-check2.js +94 -0
  47. package/dist/components/ez-collapsible-box.js +67 -0
  48. package/dist/components/ez-combo-box.js +6 -0
  49. package/dist/components/ez-combo-box2.js +311 -0
  50. package/dist/components/ez-date-input.js +135 -0
  51. package/dist/components/ez-date-time-input.js +179 -0
  52. package/dist/components/ez-dialog.js +124 -0
  53. package/dist/components/ez-form.js +6 -0
  54. package/dist/components/ez-form2.js +485 -0
  55. package/dist/components/ez-grid.js +738 -0
  56. package/dist/components/ez-icon.js +6 -0
  57. package/dist/components/ez-icon2.js +56 -0
  58. package/dist/components/ez-label-chip.js +125 -0
  59. package/dist/components/ez-list.js +6 -0
  60. package/dist/components/ez-list2.js +523 -0
  61. package/dist/components/ez-modal.js +6 -0
  62. package/dist/components/ez-modal2.js +82 -0
  63. package/dist/components/ez-number-input.js +115 -0
  64. package/dist/components/ez-popover.js +145 -0
  65. package/dist/components/ez-popup.js +67 -0
  66. package/dist/components/ez-search.js +100 -0
  67. package/dist/components/ez-tabselector.js +6 -0
  68. package/dist/components/ez-tabselector2.js +213 -0
  69. package/dist/components/ez-text-area.js +137 -0
  70. package/dist/components/ez-text-input.js +6 -0
  71. package/dist/components/ez-text-input2.js +223 -0
  72. package/dist/components/ez-time-input.js +153 -0
  73. package/dist/components/ez-toast.js +64 -0
  74. package/dist/components/ez-upload.js +382 -0
  75. package/dist/components/grid-config.js +6 -0
  76. package/dist/components/grid-config2.js +318 -0
  77. package/dist/components/select-box.js +6 -0
  78. package/dist/components/select-box2.js +47 -0
  79. package/dist/components/snk-application.js +310 -1266
  80. package/dist/components/test-du.js +101 -0
  81. package/dist/esm/ApplicationUtils-e0b6d857.js +37 -0
  82. package/dist/esm/AssetsUtils-6e6624dc.js +22 -0
  83. package/dist/esm/CSSVarsUtils-0787c3f3.js +17 -0
  84. package/dist/esm/ez-action-chip.entry.js +23 -0
  85. package/dist/esm/ez-application.entry.js +22 -0
  86. package/dist/esm/ez-button_4.entry.js +653 -0
  87. package/dist/esm/ez-calendar.entry.js +219 -0
  88. package/dist/esm/ez-collapsible-box.entry.js +43 -0
  89. package/dist/esm/ez-combo-box.entry.js +274 -0
  90. package/dist/esm/ez-date-input.entry.js +98 -0
  91. package/dist/esm/ez-date-time-input.entry.js +141 -0
  92. package/dist/esm/ez-dialog.entry.js +85 -0
  93. package/dist/esm/ez-form.entry.js +459 -0
  94. package/dist/esm/ez-grid.entry.js +643 -0
  95. package/dist/esm/ez-icon.entry.js +37 -0
  96. package/dist/esm/ez-label-chip.entry.js +100 -0
  97. package/dist/esm/ez-modal_2.entry.js +311 -0
  98. package/dist/esm/ez-number-input.entry.js +82 -0
  99. package/dist/esm/ez-popover.entry.js +116 -0
  100. package/dist/esm/ez-popup.entry.js +44 -0
  101. package/dist/esm/ez-search.entry.js +60 -0
  102. package/dist/esm/ez-tabselector.entry.js +194 -0
  103. package/dist/esm/ez-text-area.entry.js +110 -0
  104. package/dist/esm/ez-text-input.entry.js +197 -0
  105. package/dist/esm/ez-time-input.entry.js +114 -0
  106. package/dist/esm/ez-toast.entry.js +40 -0
  107. package/dist/esm/ez-upload.entry.js +352 -0
  108. package/dist/esm/index-35088a3f.js +1740 -0
  109. package/dist/esm/loader.js +3 -3
  110. package/dist/esm/sankhyablocks.js +3 -3
  111. package/dist/esm/snk-application.entry.js +311 -1267
  112. package/dist/esm/test-du.entry.js +72 -0
  113. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-action-chip/ez-action-chip.css +67 -0
  114. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-application/ez-application.css +3 -0
  115. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-button/ez-button.css +180 -0
  116. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-calendar/ez-calendar.css +319 -0
  117. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-check/ez-check.css +327 -0
  118. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +162 -0
  119. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-combo-box/ez-combo-box.css +217 -0
  120. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-input/ez-date-input.css +49 -0
  121. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-time-input/ez-date-time-input.css +44 -0
  122. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-dialog/ez-dialog.css +527 -0
  123. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-form/ez-form.css +5 -0
  124. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/ez-grid.css +31 -0
  125. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +129 -0
  126. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +10 -0
  127. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-icon/ez-icon.css +176 -0
  128. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-label-chip/ez-label-chip.css +139 -0
  129. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-list/ez-list.css +335 -0
  130. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-modal/ez-modal.css +358 -0
  131. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-number-input/ez-number-input.css +4 -0
  132. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popover/ez-popover.css +44 -0
  133. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popup/ez-popup.css +405 -0
  134. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-search/ez-search.css +3 -0
  135. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-tabselector/ez-tabselector.css +138 -0
  136. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-area/ez-text-area.css +165 -0
  137. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-input/ez-text-input.css +196 -0
  138. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-time-input/ez-time-input.css +10 -0
  139. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-toast/ez-toast.css +127 -0
  140. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-upload/ez-upload.css +568 -0
  141. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/test-du/test-du.css +3 -0
  142. package/dist/sankhyablocks/p-0183d259.entry.js +1 -0
  143. package/dist/sankhyablocks/p-01f23a70.entry.js +1 -0
  144. package/dist/sankhyablocks/p-07c32f68.entry.js +1 -0
  145. package/dist/sankhyablocks/p-0f90499d.entry.js +1 -0
  146. package/dist/sankhyablocks/p-105724a3.entry.js +1 -0
  147. package/dist/sankhyablocks/p-2ac02d48.entry.js +1 -0
  148. package/dist/sankhyablocks/p-35364a97.entry.js +1 -0
  149. package/dist/sankhyablocks/p-3f6aa9a7.entry.js +1 -0
  150. package/dist/sankhyablocks/p-5f9af495.entry.js +1 -0
  151. package/dist/sankhyablocks/p-60967cf0.js +1 -0
  152. package/dist/sankhyablocks/p-6ce33b60.entry.js +57 -0
  153. package/dist/sankhyablocks/p-70ad6c16.entry.js +1 -0
  154. package/dist/sankhyablocks/p-710bfffe.entry.js +1 -0
  155. package/dist/sankhyablocks/p-735440c1.entry.js +1 -0
  156. package/dist/sankhyablocks/p-811b4b9d.js +1 -0
  157. package/dist/sankhyablocks/p-813fe4f7.js +1 -0
  158. package/dist/sankhyablocks/p-85a9446b.js +2 -0
  159. package/dist/sankhyablocks/p-89a1100f.entry.js +1 -0
  160. package/dist/sankhyablocks/p-8b543003.entry.js +1 -0
  161. package/dist/sankhyablocks/p-9750632b.entry.js +1 -0
  162. package/dist/sankhyablocks/p-a96272f7.entry.js +1 -0
  163. package/dist/sankhyablocks/p-ac8842e5.entry.js +1 -0
  164. package/dist/sankhyablocks/p-ba64cc41.entry.js +1 -0
  165. package/dist/sankhyablocks/p-c1ede043.entry.js +1 -0
  166. package/dist/sankhyablocks/p-d90ebb85.entry.js +1 -0
  167. package/dist/sankhyablocks/p-e17dfaae.entry.js +1 -0
  168. package/dist/sankhyablocks/p-e5355a29.entry.js +1 -0
  169. package/dist/sankhyablocks/p-ef04b633.entry.js +1 -0
  170. package/dist/sankhyablocks/p-f6db07fb.entry.js +1 -0
  171. package/dist/sankhyablocks/p-fcd9bd92.entry.js +1 -0
  172. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  173. package/dist/types/components/snk-application/snk-application.d.ts +1 -1
  174. package/dist/types/components.d.ts +7 -3
  175. package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +1 -0
  176. package/package.json +12 -7
  177. package/react/components.d.ts +29 -0
  178. package/react/components.js +29 -0
  179. package/react/components.js.map +1 -1
  180. package/dist/cjs/index-20a7d705.js +0 -733
  181. package/dist/esm/index-8d3572c4.js +0 -707
  182. package/dist/sankhyablocks/p-5fa264b9.js +0 -1
  183. package/dist/sankhyablocks/p-fe95f2c4.entry.js +0 -57
  184. package/dist/types/temp/ApplicationUtils.d.ts +0 -7
@@ -0,0 +1,738 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { Grid } from 'ag-grid-enterprise';
3
+ import { Grid as Grid$1 } from 'ag-grid-community';
4
+ import { DataType, Action } from '@sankhyalabs/core';
5
+ import { UserInterface, SortMode } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
6
+ import { d as defineCustomElement$b } from './ez-button2.js';
7
+ import { d as defineCustomElement$a } from './ez-check2.js';
8
+ import { d as defineCustomElement$9 } from './ez-combo-box2.js';
9
+ import { d as defineCustomElement$8 } from './ez-icon2.js';
10
+ import { d as defineCustomElement$7 } from './ez-list2.js';
11
+ import { d as defineCustomElement$6 } from './ez-modal2.js';
12
+ import { d as defineCustomElement$5 } from './ez-tabselector2.js';
13
+ import { d as defineCustomElement$4 } from './ez-text-input2.js';
14
+ import { d as defineCustomElement$3 } from './grid-config2.js';
15
+ import { d as defineCustomElement$2 } from './select-box2.js';
16
+
17
+ const gridTerms = {
18
+ // for filter panel
19
+ page: "Página",
20
+ more: "mais",
21
+ to: "para",
22
+ of: "de",
23
+ next: "Próximo",
24
+ last: "Último",
25
+ first: "Primeiro",
26
+ previous: "Anterior",
27
+ loadingOoo: "Carregar",
28
+ // for set filter
29
+ selectAll: "Selecionar tudo",
30
+ searchOoo: "Procurar",
31
+ blanks: "Vazio",
32
+ // for number filter and text filter
33
+ filterOoo: "Filtrar",
34
+ applyFilter: "Aplicar filtro",
35
+ // for number filter
36
+ equals: "Igual",
37
+ lessThan: "Menor que",
38
+ greaterThan: "Maior que",
39
+ // for text filter
40
+ contains: "Contém",
41
+ startsWith: "Começa com",
42
+ endsWith: "Termina com",
43
+ // the header of the default group column
44
+ group: "Grupo",
45
+ // tool panel
46
+ columns: "Colunas",
47
+ rowGroupColumns: "Colunas do grupo de linhas",
48
+ rowGroupColumnsEmptyMessage: "Colunas do grupo de linhas vazias",
49
+ valueColumns: "Valores das colunas",
50
+ pivotMode: "Modo pivô",
51
+ groups: "Grupos",
52
+ values: "Valores",
53
+ pivots: "Pivôs",
54
+ valueColumnsEmptyMessage: "Valores de colunas vazias",
55
+ pivotColumnsEmptyMessage: "Pivôs de colunas vazias",
56
+ toolPanelButton: "Botão de painel de ferramentas",
57
+ // other
58
+ noRowsToShow: "Não há registros para mostrar.",
59
+ // enterprise menu
60
+ pinColumn: "Fixar coluna",
61
+ valueAggregation: "Agregar valor",
62
+ autosizeThiscolumn: "Redimensionar esta coluna",
63
+ autosizeAllColumns: "Redimensionar todas colunas",
64
+ groupBy: "Agrupar por",
65
+ ungroupBy: "Desagrupar por",
66
+ resetColumns: "Resetar colunas",
67
+ expandAll: "Expandir tudo",
68
+ collapseAll: "Contrair tudo",
69
+ toolPanel: "Painel de ferramentas",
70
+ export: "Exportar",
71
+ csvExport: "Exportar para CSV",
72
+ excelExport: "Exportar para Excel",
73
+ // enterprise menu pinning
74
+ pinLeft: "Fixar coluna",
75
+ pinRight: "Fixar a direita",
76
+ noPin: "Desfixar coluna",
77
+ // enterprise menu aggregation and status panel
78
+ sum: "Soma",
79
+ min: "Mínimo",
80
+ max: "Máximo",
81
+ none: "Nenhum",
82
+ count: "Contagem",
83
+ average: "Média",
84
+ // standard menu
85
+ copy: "Copiar",
86
+ copyWithHeaders: "Copiar com cabeçalho",
87
+ ctrlC: "Ctrl+C",
88
+ paste: "Colar",
89
+ ctrlV: "Ctrl+V"
90
+ };
91
+
92
+ const HeaderColumnTemplate = `<div class="ag-cell-label-container" role="presentation">
93
+ <span ref="eMenu" class="ag-header-icon ag-header-cell-menu-button" aria-hidden="true"></span>
94
+ <div ref="eLabel" class="ag-header-cell-label" role="presentation" unselectable="on">
95
+ <span ref="eText" class="ag-header-cell-text" unselectable="on"></span>
96
+ <span ref="eFilter" class="ag-header-icon ag-header-label-icon ag-filter-icon" aria-hidden="true"></span>
97
+ <span ref="eSortAsc" class="ag-header-icon ag-header-label-icon ag-sort-ascending-icon" aria-hidden="true"></span>
98
+ <span ref="eSortDesc" class="ag-header-icon ag-header-label-icon ag-sort-descending-icon" aria-hidden="true"></span>
99
+ <span ref="eSortNone" class="ag-header-icon ag-header-label-icon ag-sort-none-icon" aria-hidden="true"></span>
100
+ </div>
101
+ </div>`;
102
+
103
+ class Server {
104
+ constructor(data) {
105
+ this._data = data;
106
+ }
107
+ getData(request) {
108
+ const finalArray = this.sort(this.filter(this._data, request), request);
109
+ return { rowData: finalArray.slice(request.startRow, request.endRow), rowCount: finalArray.length };
110
+ }
111
+ filter(data, _request) {
112
+ return data;
113
+ }
114
+ sort(data, _request) {
115
+ return data;
116
+ }
117
+ }
118
+ /* alasql.options.cache = false;
119
+
120
+ return {
121
+ getData: function (request) {
122
+ var results = executeQuery(request);
123
+
124
+ return {
125
+ success: true,
126
+ rows: results,
127
+ lastRow: getLastRowIndex(request, results),
128
+ };
129
+ },
130
+ };
131
+
132
+ function executeQuery(request) {
133
+ var sql = buildSql(request);
134
+
135
+ console.log("[FakeServer] - about to execute query:", sql);
136
+
137
+ return alasql(sql, [allData]);
138
+ }
139
+
140
+ function buildSql(request) {
141
+ return "SELECT * FROM ?" + orderBySql(request) + limitSql(request);
142
+ }
143
+
144
+ function orderBySql(request) {
145
+ var sortModel = request.sortModel;
146
+
147
+ if (sortModel.length === 0) return "";
148
+
149
+ var sorts = sortModel.map(function (s) {
150
+ return s.colId + " " + s.sort.toUpperCase();
151
+ });
152
+
153
+ return " ORDER BY " + sorts.join(", ");
154
+ }
155
+
156
+ function limitSql(request) {
157
+ var blockSize = request.endRow - request.startRow;
158
+
159
+ return " LIMIT " + (blockSize + 1) + " OFFSET " + request.startRow;
160
+ }
161
+
162
+ function getLastRowIndex(request, results) {
163
+ if (!results || results.length === 0) {
164
+ return null;
165
+ }
166
+
167
+ var currentLastRow = request.startRow + results.length;
168
+
169
+ return currentLastRow <= request.endRow ? currentLastRow : -1;
170
+ }
171
+ }*/
172
+
173
+ class DataSource {
174
+ constructor(dataUnit, serverURL) {
175
+ this._dataUnit = dataUnit;
176
+ this._serverURL = serverURL;
177
+ }
178
+ getRows(params) {
179
+ if (this._useMockedServer) {
180
+ if (this._mockedServer === undefined) {
181
+ this.loadData()
182
+ .then(data => {
183
+ this._mockedServer = new Server(data.rowData);
184
+ params.success(this._mockedServer.getData(params.request));
185
+ })
186
+ .catch(() => params.fail());
187
+ }
188
+ else {
189
+ params.success(this._mockedServer.getData(params.request));
190
+ }
191
+ }
192
+ else {
193
+ this.loadData()
194
+ .then(data => params.success(data))
195
+ .catch(() => params.fail());
196
+ }
197
+ }
198
+ loadData() {
199
+ return new Promise((resolve, reject) => {
200
+ if (this._dataUnit) {
201
+ this._dataUnit.loadData().then(rowData => resolve({ rowData, rowCount: rowData.length }));
202
+ }
203
+ else {
204
+ fetch(this._serverURL)
205
+ .then(response => {
206
+ response.json().then(rowData => resolve({ rowData }));
207
+ })
208
+ .catch(() => reject());
209
+ }
210
+ });
211
+ }
212
+ }
213
+
214
+ class AgGridController {
215
+ constructor(enterprise) {
216
+ this._menuItems = [];
217
+ this._enterprise = enterprise;
218
+ }
219
+ getSort() {
220
+ const sortedColumns = [];
221
+ this._gridOptions.api.getSortModel().forEach(({ colId, sort }) => {
222
+ if (sort) {
223
+ const field = this._dataUnit.getField(colId);
224
+ const mode = sort === "asc" ? SortMode.ASC : SortMode.DESC;
225
+ const sortField = field ? { field: field.name, dataType: field.dataType, mode } : { field: colId, dataType: DataType.TEXT, mode };
226
+ sortedColumns.push(sortField);
227
+ }
228
+ });
229
+ return sortedColumns;
230
+ }
231
+ ;
232
+ initDatagrid(container, options) {
233
+ if (this._grid === undefined) {
234
+ this._columnStateChangeCallback = options.onColumnStateChange;
235
+ this._selectionChangeCallback = options.onSelectionChange;
236
+ this._paginationChangeCallback = options.onPaginationChange;
237
+ this._doubleClickCallBack = options.onDoubleClick;
238
+ this._multipleSelection = options.allowMultipleSelection;
239
+ this._pageSize = options.pageSize;
240
+ this._serverURL = options.serverURL;
241
+ this._dataUnit = options.dataUnit;
242
+ this._dataUnit.sortingProvider = this;
243
+ this._gridOptions = {
244
+ localeText: gridTerms,
245
+ rowModelType: "serverSide",
246
+ serverSideStoreType: "partial",
247
+ rowSelection: this._multipleSelection ? "multiple" : "single",
248
+ serverSideDatasource: new DataSource(this._dataUnit, this._serverURL),
249
+ getRowNodeId: (params) => params.__record__id__,
250
+ getMainMenuItems: (params) => {
251
+ const column = params.column;
252
+ const items = [column.isPinned() ? "clearPinned" : "pinLeft", "separator"];
253
+ this._menuItems.forEach(m => items.push({
254
+ name: m.label,
255
+ action: () => m.action(column.getColId(), m.name)
256
+ }));
257
+ return items;
258
+ },
259
+ onViewportChanged: (evt) => {
260
+ if (this._gridOptions && this._gridOptions.api && evt && evt.api) {
261
+ if (this._dataUnit.getSelection()) {
262
+ this._dataUnit.getSelection().forEach(id => {
263
+ let node = evt.api.getRowNode(id);
264
+ node.setSelected(true);
265
+ });
266
+ }
267
+ }
268
+ }
269
+ };
270
+ this.setOptionsEvents(this._gridOptions);
271
+ this.setOptionsPagination(this._gridOptions);
272
+ this.setOptionsSupress(this._gridOptions);
273
+ if (this._enterprise) {
274
+ this._grid = new Grid(container, this._gridOptions);
275
+ }
276
+ else {
277
+ this._grid = new Grid$1(container, this._gridOptions);
278
+ }
279
+ }
280
+ }
281
+ setOptionsEvents(opt) {
282
+ opt.onSortChanged = e => this.onCallStateChange("sort", e);
283
+ opt.onColumnResized = e => this.onCallStateChange("columnResize", e);
284
+ opt.onColumnPinned = e => this.onCallStateChange("columnPinned", e);
285
+ opt.onColumnMoved = e => this.onCallStateChange("columnMoved", e);
286
+ opt.onColumnVisible = e => this.onCallStateChange("visibleChange", e);
287
+ opt.onSelectionChanged = e => this.onSelectionChange(e);
288
+ opt.onPaginationChanged = () => this.onPaginationChange();
289
+ opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
290
+ }
291
+ setOptionsPagination(opt) {
292
+ opt.pagination = (this._pageSize > -1);
293
+ opt.paginationPageSize = this._pageSize;
294
+ opt.cacheBlockSize = this._pageSize;
295
+ }
296
+ setOptionsSupress(opt) {
297
+ opt.suppressDragLeaveHidesColumns = true;
298
+ opt.suppressPaginationPanel = true;
299
+ opt.suppressMenuHide = true;
300
+ }
301
+ setData(data) {
302
+ if (this._grid === undefined) {
303
+ throw new Error("Erro interno: Grid ainda não inicializado.");
304
+ }
305
+ this._gridOptions.api.setRowData(data);
306
+ }
307
+ refresh() {
308
+ if (this._grid === undefined) {
309
+ throw new Error("Erro interno: Grid ainda não inicializado.");
310
+ }
311
+ this._gridOptions.api.refreshServerSideStore({ purge: false });
312
+ }
313
+ setColumnsDef(cols, showCheckSelection) {
314
+ if (this._grid === undefined) {
315
+ throw new Error("Erro interno: Grid ainda não inicializado.");
316
+ }
317
+ const colDefs = [];
318
+ if (showCheckSelection) {
319
+ colDefs.push({
320
+ headerName: "",
321
+ checkboxSelection: true,
322
+ headerCheckboxSelection: false,
323
+ width: 28,
324
+ suppressMovable: true,
325
+ suppressAutoSize: true,
326
+ suppressMenu: true,
327
+ lockPosition: true
328
+ });
329
+ }
330
+ cols.forEach(c => {
331
+ colDefs.push(this.buildColDef(c));
332
+ });
333
+ this._gridOptions.api.setColumnDefs(colDefs);
334
+ }
335
+ getColumnsDef() {
336
+ if (this._grid === undefined) {
337
+ throw new Error("Erro interno: Grid ainda não inicializado.");
338
+ }
339
+ const colDef = this._gridOptions.columnApi.getAllColumns();
340
+ return colDef.map(c => {
341
+ const def = c.getColDef();
342
+ const colDef = { name: def.field, label: def.headerName };
343
+ this.conditionalSet(colDef, "sortable", def.sortable);
344
+ this.conditionalSet(colDef, "resizable", def.resizable);
345
+ this.conditionalSet(colDef, "sort", def.sort);
346
+ this.conditionalSet(colDef, "sortIndex", def.sortIndex);
347
+ this.conditionalSet(colDef, "width", def.width);
348
+ this.conditionalSet(colDef, "pinned", def.pinned !== null);
349
+ this.conditionalSet(colDef, "hidden", def.hide);
350
+ return colDef;
351
+ });
352
+ }
353
+ setColumnsState(state) {
354
+ if (this._grid === undefined) {
355
+ throw new Error("Erro interno: Grid ainda não inicializado.");
356
+ }
357
+ //TODO neste ponto estamos utilizando um método descontinuado,
358
+ //pelo fato de que o applyColumnState não reordena as colunas conforme
359
+ //o estado passado.
360
+ //https://stackoverflow.com/questions/51488241/ag-grid-how-to-save-and-reload-column-order
361
+ //Assim que for corrigido o applyColumnState devemos substituir o setColumnState por ele.
362
+ // this._gridOptions.columnApi.applyColumnState({ state: state.map(s => this.buildColState(s)) });
363
+ this._gridOptions.columnApi.setColumnState(state.map(s => this.buildColState(s)));
364
+ }
365
+ getColumnsState() {
366
+ if (this._grid === undefined) {
367
+ throw new Error("Erro interno: Grid ainda não inicializado.");
368
+ }
369
+ const colState = this._gridOptions.columnApi.getColumnState();
370
+ return colState.map(s => {
371
+ const def = this._gridOptions.columnApi.getColumn(s.colId).getColDef();
372
+ const label = def.headerName;
373
+ const name = def.checkboxSelection ? "__SELECTION__" : s.colId;
374
+ const colState = { label, name };
375
+ this.conditionalSet(colState, "sort", s.sort);
376
+ this.conditionalSet(colState, "sortIndex", s.sortIndex);
377
+ this.conditionalSet(colState, "width", s.width);
378
+ this.conditionalSet(colState, "pinned", s.pinned !== null);
379
+ this.conditionalSet(colState, "hidden", s.hide);
380
+ return colState;
381
+ }).filter(c => c.name !== "__SELECTION__");
382
+ }
383
+ getSelection() {
384
+ return this._gridOptions.api.getSelectedRows();
385
+ }
386
+ addColumnMenuItem(item) {
387
+ this._menuItems.push(item);
388
+ }
389
+ nextPage() {
390
+ this._gridOptions.api.paginationGoToNextPage();
391
+ }
392
+ previousPage() {
393
+ this._gridOptions.api.paginationGoToPreviousPage();
394
+ }
395
+ buildColDef(source) {
396
+ return {
397
+ headerName: source.label,
398
+ field: source.name,
399
+ sortable: true,
400
+ resizable: true,
401
+ headerComponentParams: {
402
+ template: HeaderColumnTemplate
403
+ },
404
+ valueFormatter: params => {
405
+ return this.getFormatterByColumn(params, source);
406
+ }
407
+ };
408
+ }
409
+ getFormatterByColumn(params, source) {
410
+ var _a, _b;
411
+ if ((source === null || source === void 0 ? void 0 : source.userInterface) === "OPTIONSELECTOR" && source.options) {
412
+ const prop = source === null || source === void 0 ? void 0 : source.options;
413
+ let options;
414
+ if (typeof prop === "string") {
415
+ const parsed = JSON.parse(prop);
416
+ options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
417
+ }
418
+ else {
419
+ options = prop;
420
+ }
421
+ let optionSelected;
422
+ options.forEach((option) => {
423
+ if (option.value == params.value) {
424
+ optionSelected = option;
425
+ }
426
+ });
427
+ return optionSelected === null || optionSelected === void 0 ? void 0 : optionSelected.label;
428
+ }
429
+ if ((source === null || source === void 0 ? void 0 : source.userInterface) === "SWITCH") {
430
+ if ((params === null || params === void 0 ? void 0 : params.value) === "S" || (params === null || params === void 0 ? void 0 : params.value) === true) {
431
+ return "Sim";
432
+ }
433
+ else if ((params === null || params === void 0 ? void 0 : params.value) === "N" || (params === null || params === void 0 ? void 0 : params.value) === false) {
434
+ return "Não";
435
+ }
436
+ }
437
+ if ((source === null || source === void 0 ? void 0 : source.userInterface) === "SEARCH") {
438
+ if (params.value !== undefined) {
439
+ 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);
440
+ }
441
+ }
442
+ if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.DATE || (source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.DATETIME) {
443
+ if (params.value !== undefined) {
444
+ return params.value.toLocaleDateString();
445
+ }
446
+ }
447
+ }
448
+ buildColState(source) {
449
+ return {
450
+ colId: source.name,
451
+ sort: source.sort,
452
+ sortIndex: source.sortIndex,
453
+ width: source.width,
454
+ pinned: source.pinned ? "left" : null,
455
+ hide: source.hidden
456
+ };
457
+ }
458
+ onCallStateChange(type, e) {
459
+ const finished = !("finished" in e) || e["finished"];
460
+ if (finished && this._columnStateChangeCallback) {
461
+ this._columnStateChangeCallback(type, this.getColumnsState());
462
+ }
463
+ }
464
+ onSelectionChange(e) {
465
+ if (this._selectionChangeCallback) {
466
+ this._selectionChangeCallback(e.api.getSelectedRows());
467
+ }
468
+ }
469
+ onPaginationChange() {
470
+ if (this._paginationChangeCallback) {
471
+ if (this._gridOptions.api) {
472
+ const api = this._gridOptions.api;
473
+ const currentPage = api.paginationGetCurrentPage();
474
+ const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
475
+ const pageSize = api.paginationGetPageSize();
476
+ const totalRows = api.paginationGetRowCount();
477
+ const pageStart = currentPage * pageSize + 1;
478
+ const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
479
+ this._paginationChangeCallback({
480
+ hasPrevious: currentPage > 0,
481
+ hasNext: !isLastPage,
482
+ currentPage: currentPage + 1,
483
+ pageStart,
484
+ pageEnd,
485
+ totalRows
486
+ });
487
+ }
488
+ }
489
+ }
490
+ onRowDoubleClick(evt) {
491
+ if (this._doubleClickCallBack) {
492
+ this._doubleClickCallBack(evt.data);
493
+ }
494
+ }
495
+ conditionalSet(host, attribute, value) {
496
+ if (value !== null && value !== undefined && value !== false) {
497
+ host[attribute] = value;
498
+ }
499
+ }
500
+ }
501
+
502
+ class DataUnitBridge {
503
+ constructor(gridController, dataUnit) {
504
+ this._gridController = gridController;
505
+ this._dataUnit = dataUnit;
506
+ this._dataUnit.subscribe(action => this.processAction(action));
507
+ }
508
+ processAction(action) {
509
+ switch (action.type) {
510
+ case Action.METADATA_LOADED:
511
+ this._gridController.setColumnsDef(this.buildColumnDefs(), true);
512
+ break;
513
+ case Action.RECORDS_REMOVED:
514
+ case Action.EDITION_CANCELED:
515
+ case Action.RECORDS_ADDED:
516
+ case Action.RECORDS_COPIED:
517
+ case Action.DATA_SAVED:
518
+ this._gridController.refresh();
519
+ break;
520
+ }
521
+ }
522
+ buildColumnDefs() {
523
+ const columnDefs = [];
524
+ if (this._dataUnit.metadata) {
525
+ this._dataUnit.metadata.fields.forEach(f => {
526
+ var _a;
527
+ if (f.visible !== false) {
528
+ 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 });
529
+ }
530
+ });
531
+ }
532
+ return columnDefs;
533
+ }
534
+ }
535
+
536
+ const ezGridCss = ".sc-ez-grid-h{display:grid;grid-template-rows:auto 1fr auto;height:100%;width:100%;--ezgrid__header--background-color:var(--background--xlight, #FFF)}.grid-header.sc-ez-grid{display:flex;justify-content:space-between;align-items:center;background-color:var(--ezgrid__header--background-color, #FFF);z-index:var(--visible)}.grid__container.sc-ez-grid{box-shadow:0 0 16px 0 rgb(0 38 111 / 12%);padding-top:15px;margin-top:-12px;background-color:var(--ezgrid__header--background-color)}.grid-header__container.sc-ez-grid{display:flex;align-items:center}";
537
+
538
+ const EzGrid$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
539
+ constructor() {
540
+ super();
541
+ this.__registerHost();
542
+ this.ezColumnStateChange = createEvent(this, "ezColumnStateChange", 7);
543
+ this.ezSelectionChange = createEvent(this, "ezSelectionChange", 7);
544
+ this.ezDoubleClick = createEvent(this, "ezDoubleClick", 7);
545
+ this._gridController = new AgGridController(false);
546
+ this._popUpVisible = false;
547
+ /**
548
+ * Determina o número de linhas de cada página. Caso informado o valor -1
549
+ * não haverá paginação.
550
+ */
551
+ this.pageSize = -1;
552
+ }
553
+ /**
554
+ * Método responsável por receber a definição das colunas
555
+ */
556
+ async setColumnsDef(cols) {
557
+ this._gridController.setColumnsDef(cols, this.multipleSelection);
558
+ }
559
+ /**
560
+ * Adiciona item de menu nas colunas.
561
+ */
562
+ async addColumnMenuItem(label, name, action) {
563
+ this._gridController.addColumnMenuItem({ label, name, action });
564
+ }
565
+ /**
566
+ * Método responsável por aplicar estado pré-existente nas colunas do grid.
567
+ */
568
+ async setColumnsState(state) {
569
+ this._gridController.setColumnsState(state);
570
+ }
571
+ /**
572
+ * Método de carga dos registros. Os objetos deste array devem conter atributos
573
+ * para as colunas desejadas.
574
+ */
575
+ async setData(data) {
576
+ this._gridController.setData(data);
577
+ }
578
+ /**
579
+ * Retorna as linhas selecionadas na grade.
580
+ */
581
+ async getSelection() {
582
+ return Promise.resolve(this._gridController.getSelection());
583
+ }
584
+ /**
585
+ * Método retornar o estado atual das colunas do grid.
586
+ */
587
+ async getColumnsState() {
588
+ return Promise.resolve(this._gridController.getColumnsState());
589
+ }
590
+ /**
591
+ * Método retornar o estado atual das colunas do grid.
592
+ */
593
+ async getColumns() {
594
+ return Promise.resolve(this._gridController.getColumnsDef());
595
+ }
596
+ componentWillLoad() {
597
+ if (this.dataUnit) {
598
+ this._dataUnitBridge = new DataUnitBridge(this._gridController, this.dataUnit);
599
+ addEventListener("ezSelectionChange", (evt) => this.dataUnit.setSelection(evt.detail.map((r) => r.__record__id__)));
600
+ }
601
+ }
602
+ componentDidLoad() {
603
+ this._gridController.initDatagrid(this._container, {
604
+ onColumnStateChange: (type, state) => this.ezColumnStateChange.emit({ type, state }),
605
+ onSelectionChange: (selection) => this.ezSelectionChange.emit(selection),
606
+ onPaginationChange: (status) => {
607
+ this._navigationHasPrevious = status.hasPrevious;
608
+ this._navigationHasNext = status.hasNext;
609
+ this._navigationFirstRow = status.pageStart;
610
+ this._navigationLastRow = status.pageEnd;
611
+ this._navigationTotalRows = status.totalRows;
612
+ },
613
+ onDoubleClick: (row) => {
614
+ this.ezDoubleClick.emit(row);
615
+ },
616
+ allowMultipleSelection: this.multipleSelection,
617
+ pageSize: this.pageSize,
618
+ serverURL: this.serverUrl,
619
+ dataUnit: this.dataUnit
620
+ });
621
+ if (this._dataUnitBridge) {
622
+ this._gridController.setColumnsDef(this._dataUnitBridge.buildColumnDefs(), true);
623
+ }
624
+ }
625
+ getPaginationControl() {
626
+ if (this.pageSize === -1) {
627
+ return null;
628
+ }
629
+ return [
630
+ h("div", { class: "text text--primary text--medium margin-right--medium" }, h("strong", { class: "text text--primary text--medium" }, `${this._navigationFirstRow}-${this._navigationLastRow}`), ` de ${this._navigationTotalRows}`),
631
+ 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" }),
632
+ 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" })
633
+ ];
634
+ }
635
+ applyConfig(cols) {
636
+ this._gridController.setColumnsState(cols);
637
+ this.closeConfig();
638
+ }
639
+ closeConfig() {
640
+ this._popUpVisible = false;
641
+ }
642
+ openConfig() {
643
+ this._gridConfig.columns = this._gridController.getColumnsState().filter(c => c.name);
644
+ this._gridConfig.selectedTab = "Colunas";
645
+ this._popUpVisible = true;
646
+ }
647
+ render() {
648
+ return (h(Host, null, h("div", { class: "box box--shadow padding--medium grid-header" }, h("div", { class: "grid-header__container" }, h("slot", { name: "leftButtons" })), h("div", { class: "grid-header__container" }, this.getPaginationControl(), h("ez-button", { size: "small", iconName: "settings", class: "button--secondary", mode: "icon", onClick: () => { this.openConfig(); } }))), h("div", { class: "grid__container ag-sankhya-theme", ref: elem => this._container = elem }), h("div", { class: "grid__footer" }), h("ez-modal", { modalSize: "small", closeEsc: true, closeOutsideClick: true, opened: this._popUpVisible, onEzCloseModal: () => this._popUpVisible = false }, h("grid-config", { ref: ref => this._gridConfig = ref, selectedTab: "Colunas", onConfigFinish: evt => this.applyConfig(evt.detail), onConfigCancel: _evt => this.closeConfig() }))));
649
+ }
650
+ static get assetsDirs() { return ["../assets"]; }
651
+ static get style() { return ezGridCss; }
652
+ }, [6, "ez-grid", {
653
+ "multipleSelection": [4, "multiple-selection"],
654
+ "pageSize": [2, "page-size"],
655
+ "serverUrl": [1, "server-url"],
656
+ "dataUnit": [16],
657
+ "_navigationHasPrevious": [32],
658
+ "_navigationHasNext": [32],
659
+ "_navigationFirstRow": [32],
660
+ "_navigationLastRow": [32],
661
+ "_navigationTotalRows": [32],
662
+ "_popUpVisible": [32],
663
+ "setColumnsDef": [64],
664
+ "addColumnMenuItem": [64],
665
+ "setColumnsState": [64],
666
+ "setData": [64],
667
+ "getSelection": [64],
668
+ "getColumnsState": [64],
669
+ "getColumns": [64]
670
+ }]);
671
+ function defineCustomElement$1() {
672
+ if (typeof customElements === "undefined") {
673
+ return;
674
+ }
675
+ const components = ["ez-grid", "ez-button", "ez-check", "ez-combo-box", "ez-icon", "ez-list", "ez-modal", "ez-tabselector", "ez-text-input", "grid-config", "select-box"];
676
+ components.forEach(tagName => { switch (tagName) {
677
+ case "ez-grid":
678
+ if (!customElements.get(tagName)) {
679
+ customElements.define(tagName, EzGrid$1);
680
+ }
681
+ break;
682
+ case "ez-button":
683
+ if (!customElements.get(tagName)) {
684
+ defineCustomElement$b();
685
+ }
686
+ break;
687
+ case "ez-check":
688
+ if (!customElements.get(tagName)) {
689
+ defineCustomElement$a();
690
+ }
691
+ break;
692
+ case "ez-combo-box":
693
+ if (!customElements.get(tagName)) {
694
+ defineCustomElement$9();
695
+ }
696
+ break;
697
+ case "ez-icon":
698
+ if (!customElements.get(tagName)) {
699
+ defineCustomElement$8();
700
+ }
701
+ break;
702
+ case "ez-list":
703
+ if (!customElements.get(tagName)) {
704
+ defineCustomElement$7();
705
+ }
706
+ break;
707
+ case "ez-modal":
708
+ if (!customElements.get(tagName)) {
709
+ defineCustomElement$6();
710
+ }
711
+ break;
712
+ case "ez-tabselector":
713
+ if (!customElements.get(tagName)) {
714
+ defineCustomElement$5();
715
+ }
716
+ break;
717
+ case "ez-text-input":
718
+ if (!customElements.get(tagName)) {
719
+ defineCustomElement$4();
720
+ }
721
+ break;
722
+ case "grid-config":
723
+ if (!customElements.get(tagName)) {
724
+ defineCustomElement$3();
725
+ }
726
+ break;
727
+ case "select-box":
728
+ if (!customElements.get(tagName)) {
729
+ defineCustomElement$2();
730
+ }
731
+ break;
732
+ } });
733
+ }
734
+
735
+ const EzGrid = EzGrid$1;
736
+ const defineCustomElement = defineCustomElement$1;
737
+
738
+ export { EzGrid, defineCustomElement };