@sankhyalabs/ezui 1.1.76 → 1.1.77

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 (164) hide show
  1. package/dist/cjs/ApplicationUtils-d1c1db56.js +35 -0
  2. package/dist/cjs/AssetsUtils-dd585fba.js +24 -0
  3. package/dist/cjs/DataUnit-fdd7c70e.js +474 -0
  4. package/dist/cjs/DateUtils-716769e0.js +46 -0
  5. package/dist/cjs/ez-action-chip.cjs.entry.js +1 -1
  6. package/dist/cjs/ez-application.cjs.entry.js +28 -0
  7. package/dist/cjs/ez-button_11.cjs.entry.js +111771 -0
  8. package/dist/cjs/ez-calendar.cjs.entry.js +212 -0
  9. package/dist/cjs/ez-collapsible-box_6.cjs.entry.js +630 -0
  10. package/dist/cjs/ez-combo-box.cjs.entry.js +250 -0
  11. package/dist/cjs/ez-date-time-input.cjs.entry.js +144 -0
  12. package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
  13. package/dist/cjs/ez-form.cjs.entry.js +1838 -0
  14. package/dist/cjs/ez-label-chip.cjs.entry.js +1 -1
  15. package/dist/cjs/ez-number-input.cjs.entry.js +61 -190
  16. package/dist/cjs/ez-popover.cjs.entry.js +3 -3
  17. package/dist/cjs/ez-popup.cjs.entry.js +2 -2
  18. package/dist/cjs/ez-time-input.cjs.entry.js +9 -27
  19. package/dist/cjs/ez-toast.cjs.entry.js +1 -1
  20. package/dist/cjs/ezui.cjs.js +3 -3
  21. package/dist/cjs/form-metadata.cjs.entry.js +129 -0
  22. package/dist/cjs/index-262d703b.js +7442 -0
  23. package/dist/cjs/{index-9431aeeb.js → index-4e4bae01.js} +1 -5
  24. package/dist/cjs/loader.cjs.js +3 -3
  25. package/dist/collection/collection-manifest.json +8 -3
  26. package/dist/collection/components/ez-application/ez-application.css +3 -0
  27. package/dist/collection/components/ez-application/ez-application.js +37 -0
  28. package/dist/collection/components/ez-button/ez-button.css +16 -1
  29. package/dist/collection/components/ez-button/ez-button.js +27 -2
  30. package/dist/collection/components/ez-calendar/ez-calendar.css +70 -3
  31. package/dist/collection/components/ez-calendar/ez-calendar.js +168 -24
  32. package/dist/collection/components/ez-check/ez-check.css +78 -78
  33. package/dist/collection/components/ez-check/ez-check.js +3 -3
  34. package/dist/collection/components/ez-combo-box/ez-combo-box.css +67 -51
  35. package/dist/collection/components/ez-combo-box/ez-combo-box.js +1 -0
  36. package/dist/collection/components/ez-date-time-input/ez-date-time-input.css +49 -0
  37. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +254 -0
  38. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +4 -4
  39. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +1 -1
  40. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +2 -2
  41. package/dist/collection/components/ez-grid/controller/DataUnitBridge.js +21 -0
  42. package/dist/collection/components/ez-grid/controller/EzGridController.js +1 -0
  43. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +203 -0
  44. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +41 -0
  45. package/dist/collection/components/ez-grid/controller/ag-grid/i18n/pt-BR.js +75 -0
  46. package/dist/collection/components/ez-grid/controller/ag-grid/mock/Server.js +69 -0
  47. package/dist/collection/components/ez-grid/controller/ag-grid/template/HeaderColumnTemplate.js +12 -0
  48. package/dist/collection/components/ez-grid/ez-grid.css +15 -0
  49. package/dist/collection/components/ez-grid/ez-grid.js +414 -0
  50. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +105 -0
  51. package/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.js +354 -0
  52. package/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +7 -0
  53. package/dist/collection/components/ez-grid/subcomponents/select-box/select-box.js +66 -0
  54. package/dist/collection/components/ez-icon/ez-icon.css +1 -1
  55. package/dist/collection/components/ez-list/ez-list.css +227 -44
  56. package/dist/collection/components/ez-list/ez-list.js +529 -149
  57. package/dist/collection/components/ez-modal/ez-modal.css +4 -4
  58. package/dist/collection/components/ez-modal/ez-modal.js +1 -1
  59. package/dist/collection/components/ez-number-input/ez-number-input.css +7 -162
  60. package/dist/collection/components/ez-number-input/ez-number-input.js +90 -281
  61. package/dist/collection/components/ez-popover/ez-popover.css +10 -6
  62. package/dist/collection/components/ez-popup/ez-popup.css +25 -27
  63. package/dist/collection/components/ez-tabselector/ez-tabselector.css +0 -1
  64. package/dist/collection/components/ez-tabselector/ez-tabselector.js +3 -3
  65. package/dist/collection/components/ez-text-area/ez-text-area.js +1 -0
  66. package/dist/collection/components/ez-text-input/ez-text-input.js +1 -0
  67. package/dist/collection/components/ez-upload/ez-upload.js +3 -3
  68. package/dist/collection/components/test-du/test-du.css +3 -0
  69. package/dist/collection/components/test-du/test-du.js +45 -0
  70. package/dist/collection/servidor.js +94 -94
  71. package/dist/collection/utils/{Application.js → ApplicationUtils.js} +4 -4
  72. package/dist/custom-elements/index.d.ts +36 -6
  73. package/dist/custom-elements/index.js +120975 -3013
  74. package/dist/esm/ApplicationUtils-01280a9d.js +33 -0
  75. package/dist/esm/AssetsUtils-3803e935.js +22 -0
  76. package/dist/esm/DataUnit-1cd45202.js +464 -0
  77. package/dist/esm/DateUtils-0a1bbd7a.js +44 -0
  78. package/dist/esm/ez-action-chip.entry.js +1 -1
  79. package/dist/esm/ez-application.entry.js +24 -0
  80. package/dist/esm/ez-button_11.entry.js +111757 -0
  81. package/dist/esm/ez-calendar.entry.js +208 -0
  82. package/dist/esm/ez-collapsible-box_6.entry.js +621 -0
  83. package/dist/esm/ez-combo-box.entry.js +246 -0
  84. package/dist/esm/ez-date-time-input.entry.js +140 -0
  85. package/dist/esm/ez-dialog.entry.js +1 -1
  86. package/dist/esm/ez-form.entry.js +1834 -0
  87. package/dist/esm/ez-label-chip.entry.js +1 -1
  88. package/dist/esm/ez-number-input.entry.js +61 -190
  89. package/dist/esm/ez-popover.entry.js +3 -3
  90. package/dist/esm/ez-popup.entry.js +2 -2
  91. package/dist/esm/ez-time-input.entry.js +3 -21
  92. package/dist/esm/ez-toast.entry.js +1 -1
  93. package/dist/esm/ezui.js +3 -3
  94. package/dist/esm/form-metadata.entry.js +125 -0
  95. package/dist/esm/{index-fd3c8023.js → index-1dacecd3.js} +1 -5
  96. package/dist/esm/index-cfd5e193.js +7433 -0
  97. package/dist/esm/loader.js +3 -3
  98. package/dist/ezui/ezui.esm.js +1 -1
  99. package/dist/ezui/p-1ea8187e.entry.js +369 -0
  100. package/dist/ezui/p-37a611ea.js +1 -0
  101. package/dist/ezui/p-45689464.entry.js +1 -0
  102. package/dist/ezui/{p-a0b6eee2.entry.js → p-516d0e0f.entry.js} +1 -1
  103. package/dist/ezui/p-57291f97.entry.js +1 -0
  104. package/dist/ezui/{p-66954a04.entry.js → p-5a86e18a.entry.js} +1 -1
  105. package/dist/ezui/{p-823ff0a0.entry.js → p-5da66d3e.entry.js} +1 -1
  106. package/dist/ezui/p-69416bec.entry.js +1 -0
  107. package/dist/ezui/p-7107d7ef.js +1 -0
  108. package/dist/ezui/p-7ef97c5f.entry.js +1 -0
  109. package/dist/ezui/p-88f45a83.entry.js +1 -0
  110. package/dist/ezui/p-8c51a6aa.entry.js +1 -0
  111. package/dist/ezui/{p-e0ab3746.js → p-8f4851a6.js} +1 -1
  112. package/dist/ezui/p-9dfd537e.js +1 -0
  113. package/dist/ezui/{p-d443f020.entry.js → p-a18a2d7b.entry.js} +1 -1
  114. package/dist/ezui/p-a223eed8.entry.js +1 -0
  115. package/dist/ezui/p-b36308e7.js +1 -0
  116. package/dist/ezui/p-c0af195b.entry.js +1 -0
  117. package/dist/ezui/p-c6d469fc.entry.js +1 -0
  118. package/dist/ezui/p-c89629eb.js +1 -0
  119. package/dist/ezui/p-e7ee2836.entry.js +1 -0
  120. package/dist/ezui/p-f7b835cf.entry.js +1 -0
  121. package/dist/types/components/ez-application/ez-application.d.ts +12 -0
  122. package/dist/types/components/ez-button/ez-button.d.ts +5 -0
  123. package/dist/types/components/ez-calendar/ez-calendar.d.ts +21 -0
  124. package/dist/types/components/ez-check/ez-check.d.ts +1 -1
  125. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +42 -0
  126. package/dist/types/components/ez-grid/controller/DataUnitBridge.d.ts +8 -0
  127. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +195 -0
  128. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +34 -0
  129. package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +11 -0
  130. package/dist/types/components/ez-grid/controller/ag-grid/i18n/pt-BR.d.ts +2 -0
  131. package/dist/types/components/ez-grid/controller/ag-grid/mock/Server.d.ts +8 -0
  132. package/dist/types/components/ez-grid/ez-grid.d.ts +78 -0
  133. package/dist/types/components/ez-grid/subcomponents/gridconfig/grid-config.d.ts +30 -0
  134. package/dist/types/components/ez-grid/subcomponents/select-box/select-box.d.ts +9 -0
  135. package/dist/types/components/ez-list/ez-list.d.ts +70 -17
  136. package/dist/types/components/ez-number-input/ez-number-input.d.ts +33 -50
  137. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +1 -1
  138. package/dist/types/components/test-du/test-du.d.ts +6 -0
  139. package/dist/types/components.d.ts +283 -117
  140. package/dist/types/stencil-public-runtime.d.ts +6 -4
  141. package/dist/types/utils/{Application.d.ts → ApplicationUtils.d.ts} +1 -1
  142. package/package.json +10 -8
  143. package/react/components.d.ts +6 -1
  144. package/react/components.js +6 -1
  145. package/react/components.js.map +1 -1
  146. package/dist/cjs/RequestMetadata-2cd01e8a.js +0 -531
  147. package/dist/cjs/ez-button_16.cjs.entry.js +0 -4079
  148. package/dist/cjs/ez-list.cjs.entry.js +0 -174
  149. package/dist/cjs/ez-modal.cjs.entry.js +0 -65
  150. package/dist/collection/components/ez-numeric-input/ez-numeric-input.css +0 -13
  151. package/dist/collection/components/ez-numeric-input/ez-numeric-input.js +0 -185
  152. package/dist/esm/RequestMetadata-c265c9d5.js +0 -527
  153. package/dist/esm/ez-button_16.entry.js +0 -4060
  154. package/dist/esm/ez-list.entry.js +0 -170
  155. package/dist/esm/ez-modal.entry.js +0 -61
  156. package/dist/ezui/p-11ae4ae7.entry.js +0 -1
  157. package/dist/ezui/p-47fa3d6c.entry.js +0 -1
  158. package/dist/ezui/p-8ab6168f.entry.js +0 -1
  159. package/dist/ezui/p-9c1fb51c.entry.js +0 -1
  160. package/dist/ezui/p-9d85125b.entry.js +0 -1
  161. package/dist/ezui/p-9dfccb16.js +0 -1
  162. package/dist/ezui/p-a7b546b2.entry.js +0 -1
  163. package/dist/ezui/p-c833c94f.entry.js +0 -1
  164. package/dist/types/components/ez-numeric-input/ez-numeric-input.d.ts +0 -45
@@ -0,0 +1,254 @@
1
+ import { Component, Element, Host, h, Prop, Watch, Event } from '@stencil/core';
2
+ import { DateUtils } from '@sankhyalabs/core';
3
+ import CSSVarsUtils from '../../utils/CSSVarsUtils';
4
+ export class EzDateTimeInput {
5
+ constructor() {
6
+ /**
7
+ * Deixa o campo disponível ou não para uso.
8
+ */
9
+ this.enabled = true;
10
+ /**
11
+ * Exibe ou não os segundos no input
12
+ */
13
+ this.showSeconds = false;
14
+ }
15
+ setLabel() {
16
+ this._textInput.label = this.label;
17
+ }
18
+ setErrorMessage() {
19
+ this._textInput.errorMessage = this.errorMessage;
20
+ }
21
+ applyValueToInput() {
22
+ if (this._textInput) {
23
+ this._textInput.value = this.getTextValue(this.value);
24
+ }
25
+ }
26
+ onChangeKeyDown(ev) {
27
+ const input = this._textInput.shadowRoot.querySelector('input');
28
+ if (ev.key === "H" || ev.key === "h") {
29
+ this.changeValue(new Date());
30
+ }
31
+ else if (ev.shiftKey && ev.key === "Tab") {
32
+ if (input.selectionStart > 0) {
33
+ let selectIni = input.value.lastIndexOf(":", input.selectionStart);
34
+ selectIni = selectIni === -1 ? input.value.lastIndexOf(" ", input.selectionStart) : selectIni;
35
+ selectIni = selectIni === -1 ? input.value.lastIndexOf("/", input.selectionStart) : selectIni;
36
+ selectIni = selectIni === -1 ? input.selectionStart : selectIni;
37
+ let selectFin = input.value.lastIndexOf(":", selectIni - 1);
38
+ selectFin = selectFin === -1 ? input.value.lastIndexOf(" ", selectIni - 1) : selectFin;
39
+ selectFin = selectFin === -1 ? input.value.lastIndexOf("/", selectIni - 1) : selectFin;
40
+ selectFin = selectFin === -1 ? 0 : selectFin + 1;
41
+ input.setSelectionRange(selectFin, selectIni);
42
+ ev.preventDefault();
43
+ }
44
+ }
45
+ else if (ev.key === "Tab") {
46
+ if (input.value.length !== input.selectionEnd) {
47
+ let selectIni = input.value.indexOf("/", input.selectionEnd);
48
+ selectIni = selectIni === -1 ? input.value.indexOf(" ", input.selectionEnd) : selectIni;
49
+ selectIni = selectIni === -1 ? input.value.indexOf(":", input.selectionEnd) : selectIni;
50
+ selectIni = selectIni === -1 ? input.selectionEnd : selectIni + 1;
51
+ let selectFin = input.value.indexOf("/", selectIni);
52
+ selectFin = selectFin === -1 ? input.value.indexOf(" ", selectIni) : selectFin;
53
+ selectFin = selectFin === -1 ? input.value.indexOf(":", selectIni) : selectFin;
54
+ selectFin = selectFin === -1 ? input.value.length : selectFin;
55
+ input.setSelectionRange(selectIni, selectFin);
56
+ ev.preventDefault();
57
+ }
58
+ }
59
+ }
60
+ onFocused() {
61
+ const input = this._textInput.shadowRoot.querySelector('input');
62
+ if (input.selectionStart !== input.selectionEnd) {
63
+ let selectFin = input.value.indexOf("/");
64
+ selectFin = selectFin === -1 ? input.value.indexOf(" ") : selectFin;
65
+ selectFin = selectFin === -1 ? input.value.indexOf(":") : selectFin;
66
+ selectFin = selectFin === -1 ? input.value.length : selectFin;
67
+ input.setSelectionRange(0, selectFin);
68
+ }
69
+ }
70
+ onClicked() {
71
+ const input = this._textInput.shadowRoot.querySelector('input');
72
+ let selectIni = input.value.indexOf("/", input.selectionEnd);
73
+ selectIni = selectIni === -1 ? input.value.indexOf(" ", input.selectionEnd) : selectIni;
74
+ selectIni = selectIni === -1 ? input.value.indexOf(":", input.selectionEnd) : selectIni;
75
+ let selectFin = input.value.lastIndexOf(":", input.selectionEnd);
76
+ selectFin = selectFin === -1 ? input.value.lastIndexOf(" ", selectIni - 1) : selectFin;
77
+ selectFin = selectFin === -1 ? input.value.lastIndexOf("/", selectIni - 1) : selectFin;
78
+ selectFin = selectFin === -1 ? 0 : selectFin + 1;
79
+ input.setSelectionRange(selectFin, selectIni);
80
+ }
81
+ changeValue(newValue) {
82
+ this._textInput.errorMessage = "";
83
+ if (this.getTextValue(newValue) !== this.getTextValue(this.value)) {
84
+ this.value = newValue;
85
+ this.ezChange.emit();
86
+ }
87
+ }
88
+ showCalendar() {
89
+ const top = this._textInput.errorMessage ? 0 : -17;
90
+ this._calendar.fitVertical(top, this._elem.clientHeight);
91
+ this._calendar.style.visibility = 'inherit';
92
+ }
93
+ parseDate() {
94
+ const strValue = this._textInput.value;
95
+ const parsedDate = DateUtils.strToDate(strValue);
96
+ if (parsedDate || !strValue) {
97
+ if (this.value === parsedDate) {
98
+ this.changeValue(this.value);
99
+ }
100
+ else {
101
+ this.changeValue(parsedDate);
102
+ }
103
+ }
104
+ else {
105
+ this._textInput.errorMessage = "O valor digitado não é uma data válida";
106
+ }
107
+ }
108
+ getTextValue(d) {
109
+ const options = {
110
+ year: 'numeric', month: 'numeric', day: 'numeric',
111
+ hour: 'numeric', minute: 'numeric'
112
+ };
113
+ const optionsSecond = {
114
+ year: 'numeric', month: 'numeric', day: 'numeric',
115
+ hour: 'numeric', minute: 'numeric', second: 'numeric'
116
+ };
117
+ return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : null;
118
+ }
119
+ componentDidLoad() {
120
+ CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
121
+ }
122
+ render() {
123
+ return (h(Host, null,
124
+ h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, onFocus: () => this.onFocused(), onClick: () => this.onClicked() },
125
+ h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })),
126
+ h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
127
+ }
128
+ static get is() { return "ez-date-time-input"; }
129
+ static get encapsulation() { return "shadow"; }
130
+ static get originalStyleUrls() { return {
131
+ "$": ["ez-date-time-input.css"]
132
+ }; }
133
+ static get styleUrls() { return {
134
+ "$": ["ez-date-time-input.css"]
135
+ }; }
136
+ static get properties() { return {
137
+ "label": {
138
+ "type": "string",
139
+ "mutable": false,
140
+ "complexType": {
141
+ "original": "string",
142
+ "resolved": "string",
143
+ "references": {}
144
+ },
145
+ "required": false,
146
+ "optional": false,
147
+ "docs": {
148
+ "tags": [],
149
+ "text": "T\u00EDtulo do campo"
150
+ },
151
+ "attribute": "label",
152
+ "reflect": true
153
+ },
154
+ "value": {
155
+ "type": "unknown",
156
+ "mutable": true,
157
+ "complexType": {
158
+ "original": "Date",
159
+ "resolved": "Date",
160
+ "references": {
161
+ "Date": {
162
+ "location": "global"
163
+ }
164
+ }
165
+ },
166
+ "required": false,
167
+ "optional": false,
168
+ "docs": {
169
+ "tags": [],
170
+ "text": "A data informada pelo usu\u00E1rio"
171
+ }
172
+ },
173
+ "enabled": {
174
+ "type": "boolean",
175
+ "mutable": false,
176
+ "complexType": {
177
+ "original": "boolean",
178
+ "resolved": "boolean",
179
+ "references": {}
180
+ },
181
+ "required": false,
182
+ "optional": false,
183
+ "docs": {
184
+ "tags": [],
185
+ "text": "Deixa o campo dispon\u00EDvel ou n\u00E3o para uso."
186
+ },
187
+ "attribute": "enabled",
188
+ "reflect": true,
189
+ "defaultValue": "true"
190
+ },
191
+ "errorMessage": {
192
+ "type": "string",
193
+ "mutable": true,
194
+ "complexType": {
195
+ "original": "string",
196
+ "resolved": "string",
197
+ "references": {}
198
+ },
199
+ "required": false,
200
+ "optional": false,
201
+ "docs": {
202
+ "tags": [],
203
+ "text": "Quando h\u00E1 um problema de valida\u00E7\u00E3o, serve como orienta\u00E7\u00E3o ao usu\u00E1rio"
204
+ },
205
+ "attribute": "error-message",
206
+ "reflect": true
207
+ },
208
+ "showSeconds": {
209
+ "type": "boolean",
210
+ "mutable": false,
211
+ "complexType": {
212
+ "original": "boolean",
213
+ "resolved": "boolean",
214
+ "references": {}
215
+ },
216
+ "required": false,
217
+ "optional": false,
218
+ "docs": {
219
+ "tags": [],
220
+ "text": "Exibe ou n\u00E3o os segundos no input"
221
+ },
222
+ "attribute": "show-seconds",
223
+ "reflect": true,
224
+ "defaultValue": "false"
225
+ }
226
+ }; }
227
+ static get events() { return [{
228
+ "method": "ezChange",
229
+ "name": "ezChange",
230
+ "bubbles": true,
231
+ "cancelable": true,
232
+ "composed": true,
233
+ "docs": {
234
+ "tags": [],
235
+ "text": "Evento disparado ao mudar o estado do componente(onEzChange)."
236
+ },
237
+ "complexType": {
238
+ "original": "string",
239
+ "resolved": "string",
240
+ "references": {}
241
+ }
242
+ }]; }
243
+ static get elementRef() { return "_elem"; }
244
+ static get watchers() { return [{
245
+ "propName": "label",
246
+ "methodName": "setLabel"
247
+ }, {
248
+ "propName": "errorMessage",
249
+ "methodName": "setErrorMessage"
250
+ }, {
251
+ "propName": "value",
252
+ "methodName": "applyValueToInput"
253
+ }]; }
254
+ }
@@ -1,6 +1,6 @@
1
1
  import { changeFieldValue, changesSaved, clearEdition, dataLoaded, dataLoading, insertRecord, nextRecord, previousRecord, recordRemoved, removingRecord, savingChanges } from "../store/Form.actions";
2
2
  import { selectRecordChanges, selectCurrentRecordIndex, selectLoadingData, selectNewRecordIndex, selectDataUnitChanges, selectErrorMessage } from "../store/Form.selectors";
3
- import Application from "../../../utils/Application";
3
+ import ApplicationUtils from "../../../utils/ApplicationUtils";
4
4
  export default class DataUnit {
5
5
  constructor(name, unitLabel, cardinality = "1", parentDU = null) {
6
6
  this.name = name;
@@ -113,7 +113,7 @@ export default class DataUnit {
113
113
  "__sub__changes": subChanges
114
114
  };
115
115
  if (recordChanges) {
116
- Object.keys(recordChanges).forEach(fieldName => { change[fieldName] = recordChanges[fieldName]; });
116
+ Object.keys(recordChanges).forEach(fieldName => { [fieldName] = recordChanges[fieldName]; });
117
117
  }
118
118
  return change;
119
119
  }
@@ -157,7 +157,7 @@ export default class DataUnit {
157
157
  .then(r => this.processSaveResult(r))
158
158
  .catch(e => {
159
159
  this._store.dispatch(dataLoaded(this.name));
160
- Application.error("Falha ao tentar salvar", e);
160
+ ApplicationUtils.error("Falha ao tentar salvar", e);
161
161
  });
162
162
  }
163
163
  else {
@@ -282,7 +282,7 @@ export default class DataUnit {
282
282
  });
283
283
  const result = this.recordsValidator.validateRecords(this, recordsToValidate, triggedBy);
284
284
  if (result.message) {
285
- Application.info(result.message);
285
+ ApplicationUtils.info(result.message);
286
286
  }
287
287
  return result.isValid;
288
288
  }
@@ -33,7 +33,7 @@ export const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitB
33
33
  buttons.previousVisible = false;
34
34
  }
35
35
  return h("div", { class: "form-sheet" },
36
- tabs ? h("ez-tabselector", { selectedIndex: selectedTab, selectedTab: name, onChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
36
+ tabs ? h("ez-tabselector", { selectedIndex: selectedTab, selectedTab: name, onEzChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
37
37
  dataUnit ? h(NavigationBar, { enabled: enabled, dataUnit: dataUnit, buttonProps: buttons }) : null,
38
38
  h("div", { class: "tab__container" },
39
39
  items ? items.map(item => buildFormItem(item, name, store, currentDU, enabled)) : null,
@@ -1,7 +1,7 @@
1
1
  import { h } from "@stencil/core";
2
- import Application from "../../../../utils/Application";
2
+ import ApplicationUtils from "../../../../utils/ApplicationUtils";
3
3
  function removeHandler(dataUnit) {
4
- Application.confirm("Exclusão de registro", "Tem certeza que deseja Remover?", null, true).then(ok => {
4
+ ApplicationUtils.confirm("Exclusão de registro", "Tem certeza que deseja Remover?", null, true).then(ok => {
5
5
  if (ok) {
6
6
  dataUnit.remove();
7
7
  }
@@ -0,0 +1,21 @@
1
+ import { Action } from "@sankhyalabs/core";
2
+ export default class DataUnitBridge {
3
+ constructor(gridController, dataUnit) {
4
+ this._gridController = gridController;
5
+ this._dataUnit = dataUnit;
6
+ this._dataUnit.subscribe(action => this.processAction(action));
7
+ }
8
+ processAction(action) {
9
+ switch (action.type) {
10
+ case Action.METADATA_LOADED:
11
+ const columnDefs = [];
12
+ this._dataUnit.metadata.fields.forEach(f => {
13
+ if (f.visible !== false) {
14
+ columnDefs.push({ label: f.label, name: f.name });
15
+ }
16
+ });
17
+ this._gridController.setColumnsDef(columnDefs, true);
18
+ break;
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,203 @@
1
+ import { Grid as EnterpriseGrid } from "ag-grid-enterprise";
2
+ import { Grid } from "ag-grid-community";
3
+ import gridTerms from "./i18n/pt-BR.js";
4
+ import HeaderColumnTemplate from "./template/HeaderColumnTemplate.js";
5
+ import DataSource from "./DataSource";
6
+ export default class AgGridController {
7
+ constructor(enterprise) {
8
+ this._menuItems = [];
9
+ this._enterprise = enterprise;
10
+ }
11
+ initDatagrid(container, options) {
12
+ if (this._grid === undefined) {
13
+ this._columnStateChangeCallback = options.onColumnStateChange;
14
+ this._selectionChangeCallback = options.onSelectionChange;
15
+ this._paginationChangeCallback = options.onPaginationChange;
16
+ this._multipleSelection = options.allowMultipleSelection;
17
+ this._pageSize = options.pageSize;
18
+ this._serverURL = options.serverURL;
19
+ this._dataUnit = options.dataUnit;
20
+ this._gridOptions = {
21
+ localeText: gridTerms,
22
+ rowModelType: "serverSide",
23
+ serverSideStoreType: "partial",
24
+ rowSelection: this._multipleSelection ? "multiple" : "single",
25
+ serverSideDatasource: new DataSource(this._dataUnit, this._serverURL),
26
+ getMainMenuItems: (params) => {
27
+ const column = params.column;
28
+ const items = [column.isPinned() ? "clearPinned" : "pinLeft", "separator"];
29
+ this._menuItems.forEach(m => items.push({
30
+ name: m.label,
31
+ action: () => m.action(column.getColId(), m.name)
32
+ }));
33
+ return items;
34
+ }
35
+ };
36
+ this.setOptionsEvents(this._gridOptions);
37
+ this.setOptionsPagination(this._gridOptions);
38
+ this.setOptionsSupress(this._gridOptions);
39
+ if (this._enterprise) {
40
+ this._grid = new EnterpriseGrid(container, this._gridOptions);
41
+ }
42
+ else {
43
+ this._grid = new Grid(container, this._gridOptions);
44
+ }
45
+ }
46
+ }
47
+ setOptionsEvents(opt) {
48
+ opt.onSortChanged = e => this.onCallStateChange("sort", e);
49
+ opt.onColumnResized = e => this.onCallStateChange("columnResize", e);
50
+ opt.onColumnPinned = e => this.onCallStateChange("columnPinned", e);
51
+ opt.onColumnMoved = e => this.onCallStateChange("columnMoved", e);
52
+ opt.onColumnVisible = e => this.onCallStateChange("visibleChange", e);
53
+ opt.onSelectionChanged = e => this.onSelectionChange(e);
54
+ opt.onPaginationChanged = () => this.onPaginationChange();
55
+ }
56
+ setOptionsPagination(opt) {
57
+ opt.pagination = (this._pageSize > -1);
58
+ opt.paginationPageSize = this._pageSize;
59
+ opt.cacheBlockSize = this._pageSize;
60
+ }
61
+ setOptionsSupress(opt) {
62
+ opt.suppressDragLeaveHidesColumns = true;
63
+ opt.suppressPaginationPanel = true;
64
+ opt.suppressMenuHide = true;
65
+ }
66
+ setData(data) {
67
+ if (this._grid === undefined) {
68
+ throw new Error("Erro interno: Grid ainda não inicializado.");
69
+ }
70
+ this._gridOptions.api.setRowData(data);
71
+ }
72
+ setColumnsDef(cols, showCheckSelection) {
73
+ if (this._grid === undefined) {
74
+ throw new Error("Erro interno: Grid ainda não inicializado.");
75
+ }
76
+ const colDefs = [];
77
+ if (showCheckSelection) {
78
+ colDefs.push({
79
+ headerName: "",
80
+ checkboxSelection: true,
81
+ headerCheckboxSelection: false,
82
+ width: 100,
83
+ suppressMovable: true
84
+ });
85
+ }
86
+ cols.forEach(c => {
87
+ colDefs.push(this.buildColDef(c));
88
+ });
89
+ this._gridOptions.api.setColumnDefs(colDefs);
90
+ }
91
+ getColumnsDef() {
92
+ if (this._grid === undefined) {
93
+ throw new Error("Erro interno: Grid ainda não inicializado.");
94
+ }
95
+ const colDef = this._gridOptions.columnApi.getAllColumns();
96
+ return colDef.map(c => {
97
+ const def = c.getColDef();
98
+ const colDef = { name: def.field, label: def.headerName };
99
+ this.conditionalSet(colDef, "sortable", def.sortable);
100
+ this.conditionalSet(colDef, "resizable", def.resizable);
101
+ this.conditionalSet(colDef, "sort", def.sort);
102
+ this.conditionalSet(colDef, "sortIndex", def.sortIndex);
103
+ this.conditionalSet(colDef, "width", def.width);
104
+ this.conditionalSet(colDef, "pinned", def.pinned !== null);
105
+ this.conditionalSet(colDef, "hidden", def.hide);
106
+ return colDef;
107
+ });
108
+ }
109
+ setColumnsState(state) {
110
+ if (this._grid === undefined) {
111
+ throw new Error("Erro interno: Grid ainda não inicializado.");
112
+ }
113
+ this._gridOptions.columnApi.applyColumnState({ state: state.map(s => this.buildColState(s)) });
114
+ }
115
+ getColumnsState() {
116
+ if (this._grid === undefined) {
117
+ throw new Error("Erro interno: Grid ainda não inicializado.");
118
+ }
119
+ const colState = this._gridOptions.columnApi.getColumnState();
120
+ return colState.map(s => {
121
+ const def = this._gridOptions.columnApi.getColumn(s.colId).getColDef();
122
+ const label = def.headerName;
123
+ const name = def.checkboxSelection ? "__SELECTION__" : s.colId;
124
+ const colState = { label, name };
125
+ this.conditionalSet(colState, "sort", s.sort);
126
+ this.conditionalSet(colState, "sortIndex", s.sortIndex);
127
+ this.conditionalSet(colState, "width", s.width);
128
+ this.conditionalSet(colState, "pinned", s.pinned !== null);
129
+ this.conditionalSet(colState, "hidden", s.hide);
130
+ return colState;
131
+ }).filter(c => c.name !== "__SELECTION__");
132
+ }
133
+ getSelection() {
134
+ return this._gridOptions.api.getSelectedRows();
135
+ }
136
+ addColumnMenuItem(item) {
137
+ this._menuItems.push(item);
138
+ }
139
+ nextPage() {
140
+ this._gridOptions.api.paginationGoToNextPage();
141
+ }
142
+ previousPage() {
143
+ this._gridOptions.api.paginationGoToPreviousPage();
144
+ }
145
+ buildColDef(source) {
146
+ return {
147
+ headerName: source.label,
148
+ field: source.name,
149
+ sortable: true,
150
+ resizable: true,
151
+ headerComponentParams: {
152
+ template: HeaderColumnTemplate
153
+ }
154
+ };
155
+ }
156
+ buildColState(source) {
157
+ return {
158
+ colId: source.name,
159
+ sort: source.sort,
160
+ sortIndex: source.sortIndex,
161
+ width: source.width,
162
+ pinned: source.pinned ? "left" : null,
163
+ hide: source.hidden
164
+ };
165
+ }
166
+ onCallStateChange(type, e) {
167
+ const finished = !("finished" in e) || e["finished"];
168
+ if (finished && this._columnStateChangeCallback) {
169
+ this._columnStateChangeCallback(type, this.getColumnsState());
170
+ }
171
+ }
172
+ onSelectionChange(e) {
173
+ if (this._selectionChangeCallback) {
174
+ this._selectionChangeCallback(e.api.getSelectedRows());
175
+ }
176
+ }
177
+ onPaginationChange() {
178
+ if (this._paginationChangeCallback) {
179
+ if (this._gridOptions.api) {
180
+ const api = this._gridOptions.api;
181
+ const currentPage = api.paginationGetCurrentPage();
182
+ const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
183
+ const pageSize = api.paginationGetPageSize();
184
+ const totalRows = api.paginationGetRowCount();
185
+ const pageStart = currentPage * pageSize + 1;
186
+ const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
187
+ this._paginationChangeCallback({
188
+ hasPrevious: currentPage > 0,
189
+ hasNext: !isLastPage,
190
+ currentPage: currentPage + 1,
191
+ pageStart,
192
+ pageEnd,
193
+ totalRows
194
+ });
195
+ }
196
+ }
197
+ }
198
+ conditionalSet(host, attribute, value) {
199
+ if (value !== null && value !== undefined && value !== false) {
200
+ host[attribute] = value;
201
+ }
202
+ }
203
+ }
@@ -0,0 +1,41 @@
1
+ import Server from "./mock/Server";
2
+ export default class DataSource {
3
+ constructor(dataUnit, serverURL) {
4
+ this._dataUnit = dataUnit;
5
+ this._serverURL = serverURL;
6
+ }
7
+ getRows(params) {
8
+ if (this._useMockedServer) {
9
+ if (this._mockedServer === undefined) {
10
+ this.loadData()
11
+ .then(data => {
12
+ this._mockedServer = new Server(data.rowData);
13
+ params.success(this._mockedServer.getData(params.request));
14
+ })
15
+ .catch(() => params.fail());
16
+ }
17
+ else {
18
+ params.success(this._mockedServer.getData(params.request));
19
+ }
20
+ }
21
+ else {
22
+ this.loadData()
23
+ .then(data => params.success(data))
24
+ .catch(() => params.fail());
25
+ }
26
+ }
27
+ loadData() {
28
+ return new Promise((resolve, reject) => {
29
+ if (this._dataUnit) {
30
+ this._dataUnit.loadData().then(rowData => resolve({ rowData, rowCount: rowData.length }));
31
+ }
32
+ else {
33
+ fetch(this._serverURL)
34
+ .then(response => {
35
+ response.json().then(rowData => resolve({ rowData }));
36
+ })
37
+ .catch(() => reject());
38
+ }
39
+ });
40
+ }
41
+ }
@@ -0,0 +1,75 @@
1
+ const gridTerms = {
2
+ // for filter panel
3
+ page: "Página",
4
+ more: "mais",
5
+ to: "para",
6
+ of: "de",
7
+ next: "Próximo",
8
+ last: "Último",
9
+ first: "Primeiro",
10
+ previous: "Anterior",
11
+ loadingOoo: "Carregar",
12
+ // for set filter
13
+ selectAll: "Selecionar tudo",
14
+ searchOoo: "Procurar",
15
+ blanks: "Vazio",
16
+ // for number filter and text filter
17
+ filterOoo: "Filtrar",
18
+ applyFilter: "Aplicar filtro",
19
+ // for number filter
20
+ equals: "Igual",
21
+ lessThan: "Menor que",
22
+ greaterThan: "Maior que",
23
+ // for text filter
24
+ contains: "Contém",
25
+ startsWith: "Começa com",
26
+ endsWith: "Termina com",
27
+ // the header of the default group column
28
+ group: "Grupo",
29
+ // tool panel
30
+ columns: "Colunas",
31
+ rowGroupColumns: "Colunas do grupo de linhas",
32
+ rowGroupColumnsEmptyMessage: "Colunas do grupo de linhas vazias",
33
+ valueColumns: "Valores das colunas",
34
+ pivotMode: "Modo pivô",
35
+ groups: "Grupos",
36
+ values: "Valores",
37
+ pivots: "Pivôs",
38
+ valueColumnsEmptyMessage: "Valores de colunas vazias",
39
+ pivotColumnsEmptyMessage: "Pivôs de colunas vazias",
40
+ toolPanelButton: "Botão de painel de ferramentas",
41
+ // other
42
+ noRowsToShow: "Não há registros para mostrar.",
43
+ // enterprise menu
44
+ pinColumn: "Fixar coluna",
45
+ valueAggregation: "Agregar valor",
46
+ autosizeThiscolumn: "Redimensionar esta coluna",
47
+ autosizeAllColumns: "Redimensionar todas colunas",
48
+ groupBy: "Agrupar por",
49
+ ungroupBy: "Desagrupar por",
50
+ resetColumns: "Resetar colunas",
51
+ expandAll: "Expandir tudo",
52
+ collapseAll: "Contrair tudo",
53
+ toolPanel: "Painel de ferramentas",
54
+ export: "Exportar",
55
+ csvExport: "Exportar para CSV",
56
+ excelExport: "Exportar para Excel",
57
+ // enterprise menu pinning
58
+ pinLeft: "Fixar coluna",
59
+ pinRight: "Fixar a direita",
60
+ noPin: "Desfixar coluna",
61
+ // enterprise menu aggregation and status panel
62
+ sum: "Soma",
63
+ min: "Mínimo",
64
+ max: "Máximo",
65
+ none: "Nenhum",
66
+ count: "Contagem",
67
+ average: "Média",
68
+ // standard menu
69
+ copy: "Copiar",
70
+ copyWithHeaders: "Copiar com cabeçalho",
71
+ ctrlC: "Ctrl+C",
72
+ paste: "Colar",
73
+ ctrlV: "Ctrl+V"
74
+ };
75
+ export default gridTerms;