@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
@@ -1,1220 +1,6 @@
1
- import { r as registerInstance, c as createEvent, h } from './index-8d3572c4.js';
2
-
3
- /**
4
- * Classe com utiliários comuns para Strings.
5
- */
6
- class StringUtils {
7
- /**
8
- * Verifica se a string está vazia.
9
- * Valores null e undefined são considerados como vazio.
10
- *
11
- * @param value String para ser validada.
12
- */
13
- static isEmpty(value) {
14
- if (value == undefined || value === null) {
15
- return true;
16
- }
17
- value = value.toString();
18
- value = value.trim();
19
- if (value.length === 0) {
20
- return true;
21
- }
22
- return false;
23
- }
24
- /**
25
- * Remove acentos de vogais, substitui Ç por c e retorna a string em caixa alta.
26
- *
27
- * @param value String para ser transformada.
28
- */
29
- static replaceAccentuatedChars(text) {
30
- text = text.toUpperCase();
31
- text = text.replace(/[À]/, "A");
32
- text = text.replace(/[Á]/, "A");
33
- text = text.replace(/[Â]/, "A");
34
- text = text.replace(/[Ã]/, "A");
35
- text = text.replace(/[Ä]/, "A");
36
- text = text.replace(/[È]/, "E");
37
- text = text.replace(/[É]/, "E");
38
- text = text.replace(/[Ê]/, "E");
39
- text = text.replace(/[Ë]/, "E");
40
- text = text.replace(/[Ì]/, "I");
41
- text = text.replace(/[Í]/, "I");
42
- text = text.replace(/[Î]/, "I");
43
- text = text.replace(/[Ï]/, "I");
44
- text = text.replace(/[Ò]/, "O");
45
- text = text.replace(/[Ó]/, "O");
46
- text = text.replace(/[Ô]/, "O");
47
- text = text.replace(/[Ö]/, "O");
48
- text = text.replace(/[Ù]/, "U");
49
- text = text.replace(/[Ú]/, "U");
50
- text = text.replace(/[Û]/, "U");
51
- text = text.replace(/[Ü]/, "U");
52
- text = text.replace(/[Ç]/, "C");
53
- return text.replace(/[^a-z0-9]/gi, '');
54
- }
55
- }
56
-
57
- /**
58
- * `MaskFormatter` é usado para formatar strings. Seu comportamento
59
- * é controlado pela formato do atributo `mask` que especifica quais
60
- * caracteres são válidos e onde devem estar posicionados, intercalando-os
61
- * com eventuais caracteres literais expressados no padrão informado.
62
- * Sua implementação é inspirada pela implementação em Java do [MaskFormatter](https://docs.oracle.com/javase/7/docs/api/javax/swing/text/MaskFormatter.html).
63
- *
64
- * Para o padrão da máscara podem ser usados os seguintes caracteres especiais:
65
- *
66
- * | Caractere | Comportamento |
67
- * |:---------:|-------------------------------------------------------------------------------------------------------------|
68
- * | # | Qualquer número |
69
- * | ' | "Escapa" o caractere que vem na sequência. Útil quando desejamos converter um caractere especial em literal.|
70
- * | U | Qualquer letra. Transforma letras maiúsculas em maiúsculas. |
71
- * | L | Qualquer letra. Transforma letras maiúsculas em minúsculas. |
72
- * | A | Qualquer letra ou número. |
73
- * | ? | Qualquer letra. Preserva maiúsculas e minúsculas. |
74
- * | * | Qualquer caractere. |
75
- *
76
- * Os demais caracteres presentes no padrão serão tratados como literais, isto é,
77
- * serão apenas inseridos naquela posição.
78
- *
79
- * Quando o o valor a ser formatado é menor que a máscara um 'placeHolder'
80
- * será inserido em cada posição ausente, completando a formatação.
81
- * Por padrão será usado um espaço em branco como 'placeHolder' mas
82
- * esse valor pode ser alterado.
83
- *
84
- * For por exemplo:
85
- * '''
86
- * const formatter: MaskFormatter = new MaskFormatter("###-####");
87
- * formatter.placeholder = '_';
88
- * console.log(formatter.format("123"));
89
- * '''
90
- * resultaria na string '123-____'.
91
- *
92
- * ##Veja mais alguns exemplos:
93
- * |Padrão |Máscara |Entrada |Saída |
94
- * |----------------|------------------|--------------|------------------|
95
- * |Telefone |(##) ####-#### |3432192515 |(34) 3219-2515 |
96
- * |CPF |###.###.###-## |12345678901 |123.456.789-01 |
97
- * |CNPJ |##.###.###/####-##|12345678901234|12.345.678/9012-34|
98
- * |CEP |##.###-### |12345678 |12.345-678 |
99
- * |PLACA (veículo) |UUU-#### |abc1234 |ABC-1234 |
100
- * |Cor RGB |'#AAAAAA |00000F0 |#0000F0 |
101
- *
102
- */
103
- class MaskFormatter {
104
- constructor(mask) {
105
- this._mask = '';
106
- this._maskChars = new Array();
107
- /**
108
- * Determina qual caractere será usado dos caracteres não presentes no valor
109
- * ou seja, aqueles que o usuário ainda não informou. Por padrão usamos um espaço
110
- */
111
- this.placeholder = ' ';
112
- this.mask = mask;
113
- }
114
- /**
115
- * Setter para mask. Trata-se do padrão que se espera ao formatar o texto.
116
- */
117
- set mask(mask) {
118
- this._mask = mask;
119
- this.updateInternalMask();
120
- }
121
- /**
122
- * Getter para mask
123
- *
124
- * @return A última máscara informada.
125
- */
126
- get mask() {
127
- return this._mask;
128
- }
129
- /**
130
- * Formata a string passada baseada na máscara definda pelo atributo mask.
131
- *
132
- * @param value Valor a ser formatado
133
- * @return O valor processado de acordo com o padrão
134
- */
135
- format(value) {
136
- let result = '';
137
- const index = [0];
138
- let counter = 0;
139
- const maxCounter = this._maskChars.length;
140
- while (counter < maxCounter) {
141
- result = this._maskChars[counter].append(result, value, index);
142
- counter++;
143
- }
144
- return result;
145
- }
146
- /**
147
- * Preparamos a formatação internamente de acordo com o padrão.
148
- */
149
- updateInternalMask() {
150
- this._maskChars.length = 0;
151
- if (this.mask != null) {
152
- let counter = 0;
153
- const maxCounter = this.mask.length;
154
- while (counter < maxCounter) {
155
- let maskChar = this.mask.charAt(counter);
156
- switch (maskChar) {
157
- case MaskFormatter.DIGIT_KEY:
158
- this._maskChars.push(new MaskFormatter.DigitMaskCharacter(this, maskChar));
159
- break;
160
- case MaskFormatter.LITERAL_KEY:
161
- if (++counter < maxCounter) {
162
- maskChar = this.mask.charAt(counter);
163
- this._maskChars.push(new MaskFormatter.LiteralCharacter(this, maskChar));
164
- }
165
- break;
166
- case MaskFormatter.UPPERCASE_KEY:
167
- this._maskChars.push(new MaskFormatter.UpperCaseCharacter(this, maskChar));
168
- break;
169
- case MaskFormatter.LOWERCASE_KEY:
170
- this._maskChars.push(new MaskFormatter.LowerCaseCharacter(this, maskChar));
171
- break;
172
- case MaskFormatter.ALPHA_NUMERIC_KEY:
173
- this._maskChars.push(new MaskFormatter.AlphaNumericCharacter(this, maskChar));
174
- break;
175
- case MaskFormatter.CHARACTER_KEY:
176
- this._maskChars.push(new MaskFormatter.CharCharacter(this, maskChar));
177
- break;
178
- case MaskFormatter.ANYTHING_KEY:
179
- this._maskChars.push(new MaskFormatter.MaskCharacter(this, maskChar));
180
- break;
181
- default:
182
- this._maskChars.push(new MaskFormatter.LiteralCharacter(this, maskChar));
183
- break;
184
- }
185
- counter++;
186
- }
187
- }
188
- }
189
- }
190
- MaskFormatter.DIGIT_KEY = "#";
191
- MaskFormatter.LITERAL_KEY = "'";
192
- MaskFormatter.UPPERCASE_KEY = "U";
193
- MaskFormatter.LOWERCASE_KEY = "L";
194
- MaskFormatter.ALPHA_NUMERIC_KEY = "A";
195
- MaskFormatter.CHARACTER_KEY = "?";
196
- MaskFormatter.ANYTHING_KEY = "*";
197
- //
198
- // Classes internas usadas para representar a máscara.
199
- //
200
- MaskFormatter.MaskCharacter = class {
201
- constructor(maskFormatter, type) {
202
- this.maskFormatter = maskFormatter;
203
- this.type = type;
204
- }
205
- /**
206
- * Cada subclasse deve sobrescrever o retornando true, caso represente
207
- * um caractere literal. Por padrão o retorno é false.
208
- */
209
- isLiteral() {
210
- return false;
211
- }
212
- /**
213
- * Returns true if <code>aChar</code> is a valid reprensentation of
214
- * the receiver. The default implementation returns true if the
215
- * receiver represents a literal character and <code>getChar</code>
216
- * == aChar. Otherwise, this will return true is <code>aChar</code>
217
- * is contained in the valid characters and not contained
218
- * in the invalid characters.
219
- */
220
- isValidCharacter(aChar) {
221
- if (this.isLiteral()) {
222
- return (this.getChar(aChar) == aChar);
223
- }
224
- aChar = this.getChar(aChar);
225
- return true;
226
- }
227
- /**
228
- * Returns the character to insert for <code>aChar</code>. The
229
- * default implementation returns <code>aChar</code>. Subclasses
230
- * that wish to do some sort of mapping, perhaps lower case to upper
231
- * case should override this and do the necessary mapping.
232
- */
233
- getChar(aChar) {
234
- return aChar;
235
- }
236
- /**
237
- * Appends the necessary character in <code>formatting</code> at
238
- * <code>index</code> to <code>buff</code>.
239
- */
240
- append(result, formatting, index) {
241
- const inString = index[0] < formatting.length;
242
- const aChar = inString ? formatting.charAt(index[0]) : '';
243
- if (this.isLiteral()) {
244
- const literal = this.getChar(aChar);
245
- result += literal;
246
- if (literal === aChar) {
247
- index[0] = index[0] + 1;
248
- }
249
- }
250
- else if (index[0] >= formatting.length) {
251
- result += this.maskFormatter.placeholder;
252
- index[0] = index[0] + 1;
253
- }
254
- else if (this.isValidCharacter(aChar)) {
255
- result += this.getChar(aChar);
256
- index[0] = index[0] + 1;
257
- }
258
- else {
259
- throw new Error(`Valor inválido: "${aChar}". Na posição ${index[0] + 1} espera-se ${this.getFormatMessage()}.`);
260
- }
261
- return result;
262
- }
263
- getFormatMessage() {
264
- let message;
265
- switch (this.type) {
266
- case MaskFormatter.UPPERCASE_KEY:
267
- case MaskFormatter.LOWERCASE_KEY:
268
- case MaskFormatter.CHARACTER_KEY:
269
- message = 'uma letra';
270
- break;
271
- case MaskFormatter.DIGIT_KEY:
272
- message = 'um número';
273
- break;
274
- case MaskFormatter.ALPHA_NUMERIC_KEY:
275
- message = 'uma letra ou um número';
276
- break;
277
- default:
278
- message = '';
279
- }
280
- return message;
281
- }
282
- };
283
- MaskFormatter.LiteralCharacter = class extends MaskFormatter.MaskCharacter {
284
- constructor(maskFormatter, fixedChar) {
285
- super(maskFormatter, fixedChar);
286
- this._fixedChar = fixedChar;
287
- }
288
- isLiteral() {
289
- return true;
290
- }
291
- getChar(aChar) {
292
- return this._fixedChar;
293
- }
294
- };
295
- MaskFormatter.DigitMaskCharacter = class extends MaskFormatter.MaskCharacter {
296
- isValidCharacter(aChar) {
297
- return (this.isDigit(aChar) && super.isValidCharacter(aChar));
298
- }
299
- isDigit(char) {
300
- return char >= '0' && char <= '9';
301
- }
302
- };
303
- MaskFormatter.UpperCaseCharacter = class extends MaskFormatter.MaskCharacter {
304
- isValidCharacter(aChar) {
305
- return (/[a-z]/i.test(aChar) && super.isValidCharacter(aChar));
306
- }
307
- getChar(aChar) {
308
- return aChar.toUpperCase();
309
- }
310
- };
311
- MaskFormatter.LowerCaseCharacter = class extends MaskFormatter.MaskCharacter {
312
- isValidCharacter(aChar) {
313
- return (/[a-z]/i.test(aChar) && super.isValidCharacter(aChar));
314
- }
315
- getChar(aChar) {
316
- return aChar.toLocaleLowerCase();
317
- }
318
- };
319
- MaskFormatter.AlphaNumericCharacter = class extends MaskFormatter.MaskCharacter {
320
- isValidCharacter(aChar) {
321
- //FIXME: talvez seja problema usar regex aqui... avaliar se existe forma mais barata
322
- return (/[a-z0-9]/i.test(aChar)) && super.isValidCharacter(aChar);
323
- }
324
- };
325
- MaskFormatter.CharCharacter = class extends MaskFormatter.MaskCharacter {
326
- isValidCharacter(aChar) {
327
- //FIXME: talvez seja problema usar regex aqui... avaliar se existe forma mais barata
328
- return (/[a-z]/i.test(aChar) && super.isValidCharacter(aChar));
329
- }
330
- };
331
-
332
- class DateUtils {
333
- static clearTime(date, adjustDayLightSavingTime = true) {
334
- const newDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
335
- return adjustDayLightSavingTime ? DateUtils.adjustDLST(newDate) : newDate;
336
- }
337
- static strToDate(strValue, adjustDayLightSavingTime = true, monthYearMode = false) {
338
- /** monthYearMode é um booleano para usar o formato MM/YYYY.
339
- * Quando ativado, é retornado o primeiro dia do mês apenas para construir a data.
340
- * Não há necessidade de verificar o horário de verão quando utilizado esse modo. */
341
- let parts;
342
- if (monthYearMode) {
343
- parts = /^(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
344
- }
345
- else {
346
- parts = /^(3[01]|[1-2]\d|0[1-9]|[1-9])[^\d]?(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
347
- }
348
- if (!parts) {
349
- return undefined;
350
- }
351
- var day = monthYearMode ? 1 : Number(parts[1]);
352
- var month = Number(parts[(monthYearMode ? 1 : 2)]);
353
- var year = Number(parts[(monthYearMode ? 2 : 3)]);
354
- var hour = Number(parts[(monthYearMode ? 3 : 4)] || 0);
355
- var min = Number(parts[(monthYearMode ? 4 : 5)] || 0);
356
- var sec = Number(parts[(monthYearMode ? 5 : 6)] || 0);
357
- if (year < 100) {
358
- year += year < 30 ? 2000 : 1900;
359
- }
360
- let date = new Date(year, month - 1, day, hour, min, sec, 0);
361
- if (adjustDayLightSavingTime === true && !monthYearMode && hour == 0) {
362
- date = DateUtils.adjustDLST(date);
363
- }
364
- return date;
365
- }
366
- static adjustDLST(date) {
367
- //Work around para corrigir o Bug do horário de verão.
368
- if (date.getHours() == 23) {
369
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, 1, 0, 0, 0);
370
- }
371
- return date;
372
- }
373
- }
374
-
375
- new MaskFormatter("##:##");
376
-
377
- /**
378
- * Representa as propriedades necessárias para se executar uma requisição.
379
- */
380
- /** Representa os verbos HTTP suportados */
381
- var Method;
382
- (function (Method) {
383
- Method[Method["GET"] = 0] = "GET";
384
- Method[Method["PUT"] = 1] = "PUT";
385
- Method[Method["POST"] = 2] = "POST";
386
- Method[Method["DELETE"] = 3] = "DELETE";
387
- })(Method || (Method = {}));
388
-
389
- var DataType;
390
- (function (DataType) {
391
- DataType["NUMBER"] = "NUMBER";
392
- DataType["DATE"] = "DATE";
393
- DataType["TEXT"] = "TEXT";
394
- DataType["BOOLEAN"] = "BOOLEAN";
395
- DataType["OBJECT"] = "OBJECT";
396
- })(DataType || (DataType = {}));
397
- const convertType = (dataType, value) => {
398
- if (value === undefined || value === null) {
399
- return value;
400
- }
401
- switch (dataType) {
402
- case DataType.NUMBER:
403
- return value === "" || isNaN(value) ? null : Number(value);
404
- case DataType.OBJECT:
405
- return typeof value === "string" ? JSON.parse(value) : value;
406
- case DataType.BOOLEAN:
407
- return Boolean(value);
408
- case DataType.DATE:
409
- return new Date(value.toString());
410
- default:
411
- return value;
412
- }
413
- };
414
-
415
- class DataUnitAction {
416
- constructor(type, payload) {
417
- this._type = type;
418
- this._payload = payload;
419
- }
420
- get type() {
421
- return this._type;
422
- }
423
- get payload() {
424
- return this._payload;
425
- }
426
- }
427
- var Action;
428
- (function (Action) {
429
- Action["LOADING_METADATA"] = "loadingMetadata";
430
- Action["METADATA_LOADED"] = "metadataLoaded";
431
- Action["LOADING_DATA"] = "loadingData";
432
- Action["DATA_LOADED"] = "dataLoaded";
433
- Action["SAVING_DATA"] = "savingData";
434
- Action["DATA_SAVED"] = "dataSaved";
435
- Action["REMOVING_RECORDS"] = "removingRecords";
436
- Action["RECORDS_REMOVED"] = "recordsRemoved";
437
- Action["RECORDS_ADDED"] = "recordsAdded";
438
- Action["RECORDS_COPIED"] = "recordsCopied";
439
- Action["DATA_CHANGED"] = "dataChanged";
440
- Action["EDITION_CANCELED"] = "editionCanceled";
441
- Action["CHANGE_UNDONE"] = "changeUndone";
442
- Action["CHANGE_REDONE"] = "changeRedone";
443
- Action["SELECTION_CHANGED"] = "selectionChanged";
444
- Action["NEXT_SELECTED"] = "nextSelected";
445
- Action["PREVIOUS_SELECTED"] = "previousSelected";
446
- Action["STATE_CHANGED"] = "stateChanged";
447
- })(Action || (Action = {}));
448
-
449
- /**
450
- * Essa classe representa uma interpretação do padrão de projetos Flux.
451
- * No padrão Flux os dados da aplicação são chamados de "estado" e existem
452
- * algumas regras para gerenciamento/manipulação desse estado:
453
- *
454
- * 1 - O estado é imutável.
455
- * 2 - Toda modificação de estado é representada por uma "ação".
456
- * 3 - Quando "ações" acontecem a "store" cria um novo estado e notifica a todos interessados.
457
- *
458
- * Nessa interpretação desse design pattern, o StateManager faz o papel da store,
459
- * notificando os manipuladores de estado (handlers), que são responsáveis por pedaços
460
- * do estado (slices).
461
- *
462
- * O StateManager mantém dois tipos de estados: "Histórico" e "Não Histórico". No estado
463
- * "Histórico", sempre que uma alteração de estado acontece, o estado anterior é guardado em
464
- * uma pilha, o que permite que possamos voltar no tempo, desfazendo algumas ações
465
- */
466
- class StateManager {
467
- constructor(reducers) {
468
- this._past = [];
469
- this._future = [];
470
- this._present = {};
471
- this._nonHist = {};
472
- this._histClean = false;
473
- this._reducers = reducers;
474
- }
475
- process(action) {
476
- const oldPresent = this._present;
477
- let hasHistChange = false;
478
- this._histClean = false;
479
- this._reducers.forEach(reducer => {
480
- const sliceName = reducer.sliceName;
481
- const isHistoric = this.isHistoric(sliceName);
482
- const oldSlice = this.getSlice(sliceName, isHistoric);
483
- const newSlice = reducer.reduce(this, oldSlice, action);
484
- if (newSlice !== oldSlice) {
485
- this.updateSlice(sliceName, newSlice, isHistoric);
486
- hasHistChange || (hasHistChange = isHistoric);
487
- }
488
- });
489
- if (hasHistChange && !this._histClean) {
490
- this._past.push(oldPresent);
491
- this._future = [];
492
- document.dispatchEvent(new CustomEvent("undoableAction", { detail: this }));
493
- }
494
- }
495
- select(sliceName, selector) {
496
- const isHistoric = this.isHistoric(sliceName);
497
- return selector(this.getSlice(sliceName, isHistoric));
498
- }
499
- isHistoric(slice) {
500
- return slice.startsWith("hist::");
501
- }
502
- updateSlice(name, slice, isHistoric) {
503
- if (isHistoric) {
504
- this._present = Object.assign(Object.assign({}, this._present), { [name]: slice });
505
- if (slice === undefined) {
506
- delete this._present[name];
507
- }
508
- }
509
- else {
510
- this._nonHist = Object.assign(Object.assign({}, this._nonHist), { [name]: slice });
511
- if (slice === undefined) {
512
- delete this._nonHist[name];
513
- }
514
- }
515
- }
516
- getSlice(name, isHistoric) {
517
- return isHistoric ? this._present[name] : this._nonHist[name];
518
- }
519
- canUndo() {
520
- return this._past.length > 0;
521
- }
522
- canRedo() {
523
- return this._future.length > 0;
524
- }
525
- undo() {
526
- if (this.canUndo()) {
527
- this._future.push(this._present);
528
- this._present = this._past.pop();
529
- }
530
- }
531
- redo() {
532
- if (this.canRedo()) {
533
- this._past.push(this._present);
534
- this._present = this._future.pop();
535
- }
536
- }
537
- clearUndo() {
538
- this._histClean = true;
539
- this._past = [];
540
- this._future = [];
541
- }
542
- persist() {
543
- }
544
- }
545
-
546
- class HistReducerImpl {
547
- constructor() {
548
- this.sliceName = "";
549
- }
550
- reduce(stateManager, _currentState, action) {
551
- switch (action.type) {
552
- case Action.DATA_SAVED:
553
- case Action.EDITION_CANCELED:
554
- stateManager.clearUndo();
555
- break;
556
- case Action.CHANGE_UNDONE:
557
- stateManager.undo();
558
- break;
559
- case Action.CHANGE_REDONE:
560
- stateManager.redo();
561
- break;
562
- }
563
- }
564
- }
565
- const HistReducer = new HistReducerImpl();
566
- const canUndo = (stateManager) => {
567
- return stateManager.canUndo();
568
- };
569
- const canRedo = (stateManager) => {
570
- return stateManager.canRedo();
571
- };
572
-
573
- class UnitMetadataReducerImpl {
574
- constructor() {
575
- this.sliceName = "unitMetadata";
576
- }
577
- reduce(_stateManager, currentState, action) {
578
- if (action.type === Action.METADATA_LOADED) {
579
- return action.payload;
580
- }
581
- return currentState;
582
- }
583
- }
584
- const UnitMetadataReducer = new UnitMetadataReducerImpl();
585
- const getMetadata = (stateManager) => {
586
- return stateManager.select(UnitMetadataReducer.sliceName, (state) => state);
587
- };
588
- const getField = (stateManager, fieldName) => {
589
- const md = getMetadata(stateManager);
590
- return md ? md.fields.find(fmd => fmd.name === fieldName) : undefined;
591
- };
592
-
593
- class RemovedRecordsReducerImpl {
594
- constructor() {
595
- this.sliceName = "hist::removedRecords";
596
- }
597
- reduce(_stateManager, currentState, action) {
598
- switch (action.type) {
599
- case Action.RECORDS_REMOVED:
600
- const { records, buffered } = action.payload;
601
- if (buffered) {
602
- return (currentState || []).concat(records);
603
- }
604
- return currentState;
605
- case Action.EDITION_CANCELED:
606
- case Action.DATA_SAVED:
607
- return undefined;
608
- }
609
- return currentState;
610
- }
611
- }
612
- const RemovedRecordsReducer = new RemovedRecordsReducerImpl();
613
- const getRemovedRecords = (stateManager) => {
614
- return stateManager.select(RemovedRecordsReducer.sliceName, (state) => state);
615
- };
616
-
617
- class RecordsReducerImpl {
618
- constructor() {
619
- this.sliceName = "records";
620
- }
621
- reduce(stateManager, currentState, action) {
622
- switch (action.type) {
623
- case Action.DATA_LOADED:
624
- return action.payload;
625
- case Action.RECORDS_REMOVED:
626
- const { records, buffered } = action.payload;
627
- if (!buffered) {
628
- return currentState.filter(r => !records.includes(r.__record__id__));
629
- }
630
- return currentState;
631
- case Action.DATA_SAVED:
632
- const recordsMap = new Map();
633
- const currentRecords = getRecords(stateManager);
634
- if (currentRecords) {
635
- const removed = getRemovedRecords(stateManager) || [];
636
- currentRecords.forEach(r => {
637
- if (!removed.includes(r.__record__id__)) {
638
- recordsMap.set(r.__record__id__, r);
639
- }
640
- });
641
- }
642
- const savedRecords = action.payload.records;
643
- savedRecords.forEach(sr => {
644
- const recordId = sr.__old__id__ || sr.__record__id__;
645
- const newRecord = Object.assign({}, sr);
646
- delete newRecord["__old__id__"];
647
- recordsMap.set(recordId, newRecord);
648
- });
649
- return Array.from(recordsMap.values());
650
- }
651
- return currentState;
652
- }
653
- }
654
- const RecordsReducer = new RecordsReducerImpl();
655
- const getRecords = (stateManager) => {
656
- return stateManager.select(RecordsReducer.sliceName, (state) => state);
657
- };
658
-
659
- class AddedRecordsReducerImpl {
660
- constructor() {
661
- this.sliceName = "hist::addedRecords";
662
- }
663
- reduce(_stateManager, currentState, action) {
664
- switch (action.type) {
665
- case Action.RECORDS_ADDED:
666
- case Action.RECORDS_COPIED:
667
- return (currentState || []).concat(action.payload);
668
- case Action.DATA_SAVED:
669
- case Action.EDITION_CANCELED:
670
- return undefined;
671
- }
672
- return currentState;
673
- }
674
- }
675
- const AddedRecordsReducer = new AddedRecordsReducerImpl();
676
- const getAddedRecords = (stateManager) => {
677
- return stateManager.select(AddedRecordsReducer.sliceName, (state) => state);
678
- };
679
- const prepareAddedRecordId = (stateManager, source) => {
680
- let index = (getAddedRecords(stateManager) || []).length;
681
- return source.map(item => { return Object.assign(Object.assign({}, item), { __record__id__: "NEW_" + (index++) }); });
682
- };
683
-
684
- class ChangesReducerImpl {
685
- constructor() {
686
- this.sliceName = "hist::changes";
687
- }
688
- reduce(stateManager, currentState, action) {
689
- switch (action.type) {
690
- case Action.DATA_CHANGED:
691
- const selection = action.payload.records || getSelection(stateManager);
692
- if (selection) {
693
- const newState = new Map(currentState);
694
- selection.forEach(recordId => {
695
- const newChanges = Object.assign(Object.assign({}, newState.get(recordId)), action.payload);
696
- delete newChanges.records;
697
- newState.set(recordId, newChanges);
698
- });
699
- return newState;
700
- }
701
- return currentState;
702
- case Action.DATA_SAVED:
703
- case Action.EDITION_CANCELED:
704
- return undefined;
705
- }
706
- return currentState;
707
- }
708
- }
709
- const ChangesReducer = new ChangesReducerImpl();
710
- const getChanges = (stateManager) => {
711
- return stateManager.select(ChangesReducer.sliceName, (state) => state);
712
- };
713
- const isDirty = (stateManager) => {
714
- if (getAddedRecords(stateManager) !== undefined) {
715
- return true;
716
- }
717
- if (getRemovedRecords(stateManager) !== undefined) {
718
- return true;
719
- }
720
- return getChanges(stateManager) !== undefined;
721
- };
722
- const getChangesToSave = (dataUnit, stateManager) => {
723
- const result = [];
724
- const changes = getChanges(stateManager);
725
- const records = getRecords(stateManager);
726
- records === null || records === void 0 ? void 0 : records.forEach(r => {
727
- if (changes) {
728
- const c = changes.get(r.__record__id__);
729
- if (c) {
730
- result.push(new Change(dataUnit, r, c, ChangeOperation.UPDATE));
731
- }
732
- }
733
- });
734
- const addedRecords = getAddedRecords(stateManager);
735
- if (addedRecords) {
736
- addedRecords.forEach(r => {
737
- result.push(new Change(dataUnit, r, changes === null || changes === void 0 ? void 0 : changes.get(r.__record__id__), ChangeOperation.INSERT));
738
- });
739
- }
740
- const removedRecords = getRemovedRecords(stateManager);
741
- const recordsById = {};
742
- records === null || records === void 0 ? void 0 : records.forEach(r => recordsById[r.__record__id__] = r);
743
- if (removedRecords) {
744
- removedRecords.forEach(id => {
745
- result.push(new Change(dataUnit, recordsById[id], undefined, ChangeOperation.DELETE));
746
- });
747
- }
748
- return result;
749
- };
750
-
751
- class CurrentRecordsReducerImpl {
752
- constructor() {
753
- this.sliceName = "currentRecords";
754
- }
755
- reduce(stateManager, _currentState, _action) {
756
- let records = getRecords(stateManager);
757
- const added = getAddedRecords(stateManager);
758
- if (!records && !added) {
759
- return undefined;
760
- }
761
- if (added) {
762
- records = (records || []).concat(added);
763
- }
764
- const removedRecords = getRemovedRecords(stateManager);
765
- if (removedRecords) {
766
- records = records.filter(r => !removedRecords.includes(r.__record__id__));
767
- }
768
- const changes = getChanges(stateManager);
769
- return new Map(records.map(r => {
770
- const recordId = r.__record__id__;
771
- const record = Object.assign(Object.assign({}, r), changes === null || changes === void 0 ? void 0 : changes.get(recordId));
772
- return [recordId, record];
773
- }));
774
- }
775
- }
776
- const CurrentRecordsReducer = new CurrentRecordsReducerImpl();
777
- const getCurrentRecords = (stateManager) => {
778
- return stateManager.select(CurrentRecordsReducer.sliceName, (state) => state);
779
- };
780
- const getFieldValue = (stateManager, fieldName) => {
781
- const selection = getSelection(stateManager);
782
- if (selection && selection.length > 0) {
783
- const currentRecords = getCurrentRecords(stateManager);
784
- if (currentRecords) {
785
- const record = currentRecords.get(selection[0]);
786
- return record ? record[fieldName] : undefined;
787
- }
788
- }
789
- return undefined;
790
- };
791
-
792
- class SelectionReducerImpl {
793
- constructor() {
794
- this.sliceName = "hist::selection";
795
- }
796
- reduce(stateManager, currentState, action) {
797
- switch (action.type) {
798
- case Action.RECORDS_ADDED:
799
- case Action.RECORDS_COPIED:
800
- return action.payload.map((r) => r.__record__id__);
801
- case Action.DATA_SAVED:
802
- return updateSavedIds(stateManager, action.payload.records);
803
- case Action.RECORDS_REMOVED:
804
- const removed = action.payload.records;
805
- if (currentState && removed) {
806
- return currentState.filter(recordId => !removed.includes(recordId));
807
- }
808
- return currentState;
809
- case Action.NEXT_SELECTED:
810
- case Action.PREVIOUS_SELECTED:
811
- const currentRecords = getCurrentRecords(stateManager);
812
- if (currentRecords && currentRecords.size > 0) {
813
- let index;
814
- if (!currentState || currentState.length === 0) {
815
- index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(1, currentRecords.size);
816
- }
817
- else {
818
- index = getItemIndex(currentState[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
819
- }
820
- if (index < currentRecords.size && index >= 0) {
821
- return [Array.from(currentRecords.values())[index].__record__id__];
822
- }
823
- }
824
- return undefined;
825
- case Action.SELECTION_CHANGED:
826
- const { type, selection: selectionSource } = action.payload;
827
- if (selectionSource && type === "index") {
828
- const currentRecords = getCurrentRecords(stateManager);
829
- if (currentRecords) {
830
- const records = Array.from(currentRecords.values());
831
- const selectionById = [];
832
- selectionSource.forEach((i) => {
833
- if (i > 0 && i < currentRecords.size) {
834
- selectionById.push(records[i].__record__id__);
835
- }
836
- });
837
- return selectionById;
838
- }
839
- }
840
- return selectionSource;
841
- }
842
- return currentState;
843
- }
844
- }
845
- const SelectionReducer = new SelectionReducerImpl();
846
- const getSelection = (stateManager) => {
847
- let selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
848
- const currentRecords = Array.from((getCurrentRecords(stateManager) || new Map()).keys());
849
- if (selection) {
850
- selection = selection.filter(id => currentRecords.includes(id));
851
- }
852
- if (!selection || selection.length === 0) {
853
- if (currentRecords && currentRecords.length > 0) {
854
- return [currentRecords[0]];
855
- }
856
- }
857
- return selection;
858
- };
859
- const hasNext = (stateManager) => {
860
- const records = getCurrentRecords(stateManager);
861
- if (records) {
862
- const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
863
- if (!selection || selection.length === 0) {
864
- return records.size > 0;
865
- }
866
- return records.size > (getItemIndex(selection[0], records) + 1);
867
- }
868
- return false;
869
- };
870
- const hasPrevious = (stateManager) => {
871
- const records = getCurrentRecords(stateManager);
872
- if (records) {
873
- const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
874
- if (!selection || selection.length === 0) {
875
- return false;
876
- }
877
- return getItemIndex(selection[0], records) > 0;
878
- }
879
- return false;
880
- };
881
- function getItemIndex(key, map) {
882
- return Array.from(map.keys()).indexOf(key);
883
- }
884
- function updateSavedIds(stateManager, savedRecords) {
885
- const currentSelection = getSelection(stateManager);
886
- if (currentSelection) {
887
- const newSelection = [];
888
- currentSelection.forEach(id => {
889
- const record = savedRecords.find(r => r.__old__id__ === id);
890
- if (record) {
891
- newSelection.push(record.__record__id__);
892
- }
893
- else {
894
- newSelection.push(id);
895
- }
896
- });
897
- return newSelection;
898
- }
899
- return currentSelection;
900
- }
901
-
902
- var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
903
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
904
- return new (P || (P = Promise))(function (resolve, reject) {
905
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
906
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
907
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
908
- step((generator = generator.apply(thisArg, _arguments || [])).next());
909
- });
910
- };
911
- class DataUnit {
912
- constructor(name) {
913
- this._name = name;
914
- this._stateManager = new StateManager([
915
- HistReducer,
916
- UnitMetadataReducer,
917
- RecordsReducer,
918
- RemovedRecordsReducer,
919
- AddedRecordsReducer,
920
- SelectionReducer,
921
- ChangesReducer,
922
- CurrentRecordsReducer
923
- ]);
924
- this._observers = [];
925
- this._filterProviders = [];
926
- this._sortingProvider = undefined;
927
- this._interceptors = [];
928
- }
929
- get name() {
930
- return this._name;
931
- }
932
- // Métodos privados
933
- validateAndTypeValue(fieldName, newValue) {
934
- //FIXME: Validações devem ser feitas aqui
935
- const descriptor = this.getField(fieldName);
936
- return descriptor ? convertType(descriptor.dataType, newValue) : newValue;
937
- }
938
- getFilters() {
939
- let filters = undefined;
940
- this._filterProviders.forEach(p => {
941
- const f = p.getFilter(this.name);
942
- if (f) {
943
- filters = (filters || []).concat(f);
944
- }
945
- });
946
- return filters;
947
- }
948
- getSort() {
949
- return this._sortingProvider ? this._sortingProvider.getSort(this._name) : undefined;
950
- }
951
- // Loaders
952
- loadMetadata() {
953
- return __awaiter(this, void 0, void 0, function* () {
954
- this.dispatchAction(Action.LOADING_METADATA);
955
- return new Promise((resolve, fail) => {
956
- if (this.metadataLoader) {
957
- this.metadataLoader(this).then(metadata => {
958
- this.metadata = metadata;
959
- resolve(this.metadata);
960
- }).catch(error => fail(error));
961
- }
962
- });
963
- });
964
- }
965
- loadData() {
966
- return __awaiter(this, void 0, void 0, function* () {
967
- this.dispatchAction(Action.LOADING_DATA);
968
- return new Promise((resolve, fail) => {
969
- if (this.dataLoader) {
970
- const sort = this.getSort();
971
- const filters = this.getFilters();
972
- this.dataLoader(this, sort, filters).then(records => {
973
- this.records = records;
974
- resolve(this.records);
975
- }).catch(error => fail(error));
976
- }
977
- });
978
- });
979
- }
980
- saveData() {
981
- return __awaiter(this, void 0, void 0, function* () {
982
- const changes = getChangesToSave(this._name, this._stateManager);
983
- if (changes.length > 0) {
984
- this.dispatchAction(Action.SAVING_DATA);
985
- return new Promise((resolve, fail) => {
986
- if (this.saveLoader) {
987
- this.saveLoader(this, changes).then(records => this.dispatchAction(Action.DATA_SAVED, { changes, records })).catch(error => fail(error));
988
- }
989
- });
990
- }
991
- return Promise.resolve();
992
- });
993
- }
994
- removeSelectedRecords(buffered = false) {
995
- return __awaiter(this, void 0, void 0, function* () {
996
- const selection = getSelection(this._stateManager);
997
- if (selection) {
998
- return this.removeRecords(selection, buffered);
999
- }
1000
- return Promise.resolve(selection);
1001
- });
1002
- }
1003
- removeRecords(records, buffered = false) {
1004
- return __awaiter(this, void 0, void 0, function* () {
1005
- if (records) {
1006
- if (buffered || !this.removeLoader) {
1007
- this.dispatchAction(Action.RECORDS_REMOVED, { records, buffered: true });
1008
- }
1009
- else {
1010
- this.dispatchAction(Action.REMOVING_RECORDS);
1011
- return new Promise((resolve, fail) => {
1012
- if (this.removeLoader) {
1013
- this.removeLoader(this, records).then(records => {
1014
- this.dispatchAction(Action.RECORDS_REMOVED, { records, buffered: false });
1015
- resolve(records);
1016
- }).catch(error => fail(error));
1017
- }
1018
- });
1019
- }
1020
- }
1021
- return Promise.resolve(records);
1022
- });
1023
- }
1024
- // API
1025
- valueFromString(fieldName, value) {
1026
- const descriptor = this.getField(fieldName);
1027
- return descriptor ? convertType(descriptor.dataType, value) : value;
1028
- }
1029
- addInterceptor(interceptor) {
1030
- this._interceptors.push(interceptor);
1031
- }
1032
- addFilterProvider(provider) {
1033
- this._filterProviders.push(provider);
1034
- }
1035
- set sortingProvider(provider) {
1036
- this._sortingProvider = provider;
1037
- }
1038
- set metadata(md) {
1039
- this.dispatchAction(Action.METADATA_LOADED, md);
1040
- }
1041
- get metadata() {
1042
- return getMetadata(this._stateManager);
1043
- }
1044
- set records(r) {
1045
- this.dispatchAction(Action.DATA_LOADED, r);
1046
- }
1047
- get records() {
1048
- const records = getCurrentRecords(this._stateManager);
1049
- return records ? Array.from(records.values()) : [];
1050
- }
1051
- getField(fieldName) {
1052
- return getField(this._stateManager, fieldName);
1053
- }
1054
- addRecord() {
1055
- this.dispatchAction(Action.RECORDS_ADDED, prepareAddedRecordId(this._stateManager, [{}]));
1056
- }
1057
- copySelected() {
1058
- const selectedRecords = this.getSelectedRecords();
1059
- if (selectedRecords) {
1060
- this.dispatchAction(Action.RECORDS_COPIED, prepareAddedRecordId(this._stateManager, selectedRecords));
1061
- }
1062
- }
1063
- getFieldValue(fieldName) {
1064
- return getFieldValue(this._stateManager, fieldName);
1065
- }
1066
- setFieldValue(fieldName, newValue, records) {
1067
- const typedValue = this.validateAndTypeValue(fieldName, newValue);
1068
- const currentValue = this.getFieldValue(fieldName);
1069
- if (currentValue !== typedValue) {
1070
- this.dispatchAction(Action.DATA_CHANGED, { [fieldName]: typedValue, records });
1071
- }
1072
- }
1073
- getSelection() {
1074
- return getSelection(this._stateManager);
1075
- }
1076
- setSelection(selection) {
1077
- this.dispatchAction(Action.SELECTION_CHANGED, { type: "id", selection });
1078
- }
1079
- setSelectionByIndex(selection) {
1080
- this.dispatchAction(Action.SELECTION_CHANGED, { type: "index", selection });
1081
- }
1082
- getSelectedRecords() {
1083
- const selection = this.getSelection();
1084
- if (selection) {
1085
- const currentRecords = this.records;
1086
- return currentRecords === null || currentRecords === void 0 ? void 0 : currentRecords.filter(r => selection.includes(r.__record__id__));
1087
- }
1088
- }
1089
- nextRecord() {
1090
- this.dispatchAction(Action.NEXT_SELECTED);
1091
- }
1092
- previousRecord() {
1093
- this.dispatchAction(Action.PREVIOUS_SELECTED);
1094
- }
1095
- cancelEdition() {
1096
- this.dispatchAction(Action.EDITION_CANCELED);
1097
- }
1098
- isDirty() {
1099
- return isDirty(this._stateManager);
1100
- }
1101
- hasNext() {
1102
- return hasNext(this._stateManager);
1103
- }
1104
- hasPrevious() {
1105
- return hasPrevious(this._stateManager);
1106
- }
1107
- canUndo() {
1108
- return canUndo(this._stateManager);
1109
- }
1110
- canRedo() {
1111
- return canRedo(this._stateManager);
1112
- }
1113
- undo() {
1114
- this.dispatchAction(Action.CHANGE_UNDONE);
1115
- }
1116
- redo() {
1117
- this.dispatchAction(Action.CHANGE_REDONE);
1118
- }
1119
- toString() {
1120
- return this.name;
1121
- }
1122
- // Actions / State manager
1123
- dispatchAction(actionType, payload) {
1124
- var _a;
1125
- let action = new DataUnitAction(actionType, payload);
1126
- (_a = this._interceptors) === null || _a === void 0 ? void 0 : _a.forEach(interceptor => {
1127
- if (action) {
1128
- action = interceptor.interceptAction(action);
1129
- }
1130
- });
1131
- if (action) {
1132
- this._stateManager.process(action);
1133
- this._observers.forEach(f => f(action));
1134
- }
1135
- }
1136
- subscribe(observer) {
1137
- this._observers.push(observer);
1138
- }
1139
- unsubscribe(observer) {
1140
- this._observers = this._observers.filter(f => f !== observer);
1141
- }
1142
- }
1143
- var ChangeOperation;
1144
- (function (ChangeOperation) {
1145
- ChangeOperation["INSERT"] = "INSERT";
1146
- ChangeOperation["UPDATE"] = "UPDATE";
1147
- ChangeOperation["DELETE"] = "DELETE";
1148
- })(ChangeOperation || (ChangeOperation = {}));
1149
- class Change {
1150
- constructor(dataUnit, record, updates, operation) {
1151
- this.dataUnit = dataUnit;
1152
- this.record = record;
1153
- this.updatingFields = updates;
1154
- this._operation = operation;
1155
- }
1156
- get operation() {
1157
- return this._operation.toString();
1158
- }
1159
- isInsert() {
1160
- return this._operation === ChangeOperation.INSERT;
1161
- }
1162
- isDelete() {
1163
- return this._operation === ChangeOperation.DELETE;
1164
- }
1165
- isUpdate() {
1166
- return this._operation === ChangeOperation.UPDATE;
1167
- }
1168
- }
1169
-
1170
- var SortMode;
1171
- (function (SortMode) {
1172
- SortMode["ASC"] = "ASC";
1173
- SortMode["DESC"] = "DESC";
1174
- })(SortMode || (SortMode = {}));
1175
- var DependencyType;
1176
- (function (DependencyType) {
1177
- DependencyType["SEARCHING"] = "SEARCHING";
1178
- DependencyType["REQUIREMENT"] = "REQUIREMENT";
1179
- DependencyType["VISIBILITY"] = "REQUIREMENT";
1180
- })(DependencyType || (DependencyType = {}));
1181
- var UserInterface;
1182
- (function (UserInterface) {
1183
- UserInterface["FILE"] = "FILE";
1184
- UserInterface["IMAGE"] = "IMAGE";
1185
- UserInterface["DATE"] = "DATE";
1186
- UserInterface["DATETIME"] = "DATETIME";
1187
- UserInterface["TIME"] = "TIME";
1188
- UserInterface["ELAPSEDTIME"] = "ELAPSEDTIME";
1189
- UserInterface["CHECKBOX"] = "CHECKBOX";
1190
- UserInterface["SWITCH"] = "SWITCH";
1191
- UserInterface["OPTIONSELECTOR"] = "OPTIONSELECTOR";
1192
- UserInterface["DECIMALNUMBER"] = "DECIMALNUMBER";
1193
- UserInterface["INTEGERNUMBER"] = "INTEGERNUMBER";
1194
- UserInterface["SEARCH"] = "SEARCH";
1195
- UserInterface["SHORTTEXT"] = "SHORTTEXT";
1196
- UserInterface["PASSWORD"] = "PASSWORD";
1197
- UserInterface["MASKEDTEXT"] = "MASKEDTEXT";
1198
- UserInterface["LONGTEXT"] = "LONGTEXT";
1199
- UserInterface["HTML"] = "HTML";
1200
- })(UserInterface || (UserInterface = {}));
1201
-
1202
- class ApplicationContext {
1203
- static getContextValue(key) {
1204
- return ApplicationContext.getCtx()[key];
1205
- }
1206
- static setContextValue(key, value) {
1207
- ApplicationContext.getCtx()[key] = value;
1208
- }
1209
- static getCtx() {
1210
- let ctx = window.___snkcore___ctx___;
1211
- if (!ctx) {
1212
- ctx = {};
1213
- window.___snkcore___ctx___ = ctx;
1214
- }
1215
- return ctx;
1216
- }
1217
- }
1
+ import { r as registerInstance, c as createEvent, h } from './index-35088a3f.js';
2
+ import { DataUnit, ChangeOperation, DateUtils, StringUtils, ApplicationContext } from '@sankhyalabs/core';
3
+ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
1218
4
 
1219
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1220
6
 
@@ -6880,6 +5666,280 @@ exports.ClientError = ClientError;
6880
5666
  //# sourceMappingURL=types.js.map
6881
5667
  });
6882
5668
 
5669
+ var graphqlWs = createCommonjsModule(function (module, exports) {
5670
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
5671
+ __assign = Object.assign || function(t) {
5672
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5673
+ s = arguments[i];
5674
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
5675
+ t[p] = s[p];
5676
+ }
5677
+ return t;
5678
+ };
5679
+ return __assign.apply(this, arguments);
5680
+ };
5681
+ var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
5682
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5683
+ return new (P || (P = Promise))(function (resolve, reject) {
5684
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5685
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5686
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
5687
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
5688
+ });
5689
+ };
5690
+ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
5691
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
5692
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
5693
+ function verb(n) { return function (v) { return step([n, v]); }; }
5694
+ function step(op) {
5695
+ if (f) throw new TypeError("Generator is already executing.");
5696
+ while (_) try {
5697
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
5698
+ if (y = 0, t) op = [op[0] & 2, t.value];
5699
+ switch (op[0]) {
5700
+ case 0: case 1: t = op; break;
5701
+ case 4: _.label++; return { value: op[1], done: false };
5702
+ case 5: _.label++; y = op[1]; op = [0]; continue;
5703
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
5704
+ default:
5705
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
5706
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
5707
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
5708
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
5709
+ if (t[2]) _.ops.pop();
5710
+ _.trys.pop(); continue;
5711
+ }
5712
+ op = body.call(thisArg, _);
5713
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
5714
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
5715
+ }
5716
+ };
5717
+ Object.defineProperty(exports, "__esModule", { value: true });
5718
+ exports.GraphQLWebSocketClient = void 0;
5719
+
5720
+
5721
+ var CONNECTION_INIT = 'connection_init';
5722
+ var CONNECTION_ACK = 'connection_ack';
5723
+ var PING = 'ping';
5724
+ var PONG = 'pong';
5725
+ var SUBSCRIBE = 'subscribe';
5726
+ var NEXT = 'next';
5727
+ var ERROR = 'error';
5728
+ var COMPLETE = 'complete';
5729
+ var GraphQLWebSocketMessage = /** @class */ (function () {
5730
+ function GraphQLWebSocketMessage(type, payload, id) {
5731
+ this._type = type;
5732
+ this._payload = payload;
5733
+ this._id = id;
5734
+ }
5735
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "type", {
5736
+ get: function () { return this._type; },
5737
+ enumerable: false,
5738
+ configurable: true
5739
+ });
5740
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "id", {
5741
+ get: function () { return this._id; },
5742
+ enumerable: false,
5743
+ configurable: true
5744
+ });
5745
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "payload", {
5746
+ get: function () { return this._payload; },
5747
+ enumerable: false,
5748
+ configurable: true
5749
+ });
5750
+ Object.defineProperty(GraphQLWebSocketMessage.prototype, "text", {
5751
+ get: function () {
5752
+ var result = { type: this.type };
5753
+ if (this.id != null && this.id != undefined)
5754
+ result.id = this.id;
5755
+ if (this.payload != null && this.payload != undefined)
5756
+ result.payload = this.payload;
5757
+ return JSON.stringify(result);
5758
+ },
5759
+ enumerable: false,
5760
+ configurable: true
5761
+ });
5762
+ GraphQLWebSocketMessage.parse = function (data, f) {
5763
+ var _a = JSON.parse(data), type = _a.type, payload = _a.payload, id = _a.id;
5764
+ return new GraphQLWebSocketMessage(type, f(payload), id);
5765
+ };
5766
+ return GraphQLWebSocketMessage;
5767
+ }());
5768
+ var GraphQLWebSocketClient = /** @class */ (function () {
5769
+ function GraphQLWebSocketClient(socket, _a) {
5770
+ var _this = this;
5771
+ var onInit = _a.onInit, onAcknowledged = _a.onAcknowledged, onPing = _a.onPing, onPong = _a.onPong;
5772
+ this.socketState = { acknowledged: false, lastRequestId: 0, subscriptions: {} };
5773
+ this.socket = socket;
5774
+ socket.onopen = function (e) { return __awaiter(_this, void 0, void 0, function () {
5775
+ var _a, _b, _c, _d;
5776
+ return __generator(this, function (_e) {
5777
+ switch (_e.label) {
5778
+ case 0:
5779
+ this.socketState.acknowledged = false;
5780
+ this.socketState.subscriptions = {};
5781
+ _b = (_a = socket).send;
5782
+ _c = ConnectionInit;
5783
+ if (!onInit) return [3 /*break*/, 2];
5784
+ return [4 /*yield*/, onInit()];
5785
+ case 1:
5786
+ _d = _e.sent();
5787
+ return [3 /*break*/, 3];
5788
+ case 2:
5789
+ _d = null;
5790
+ _e.label = 3;
5791
+ case 3:
5792
+ _b.apply(_a, [_c.apply(void 0, [_d]).text]);
5793
+ return [2 /*return*/];
5794
+ }
5795
+ });
5796
+ }); };
5797
+ socket.onclose = function (e) {
5798
+ _this.socketState.acknowledged = false;
5799
+ _this.socketState.subscriptions = {};
5800
+ };
5801
+ socket.onerror = function (e) {
5802
+ console.error(e);
5803
+ };
5804
+ socket.onmessage = function (e) {
5805
+ try {
5806
+ var message = parseMessage(e.data);
5807
+ switch (message.type) {
5808
+ case CONNECTION_ACK: {
5809
+ if (_this.socketState.acknowledged) {
5810
+ console.warn("Duplicate CONNECTION_ACK message ignored");
5811
+ }
5812
+ else {
5813
+ _this.socketState.acknowledged = true;
5814
+ if (onAcknowledged)
5815
+ onAcknowledged(message.payload);
5816
+ }
5817
+ return;
5818
+ }
5819
+ case PING: {
5820
+ if (onPing)
5821
+ onPing(message.payload).then(function (r) { return socket.send(Pong(r).text); });
5822
+ else
5823
+ socket.send(Pong(null).text);
5824
+ return;
5825
+ }
5826
+ case PONG: {
5827
+ if (onPong)
5828
+ onPong(message.payload);
5829
+ return;
5830
+ }
5831
+ }
5832
+ if (!_this.socketState.acknowledged) {
5833
+ // Web-socket connection not acknowledged
5834
+ return;
5835
+ }
5836
+ if (message.id === undefined || message.id === null || !_this.socketState.subscriptions[message.id]) {
5837
+ // No subscription identifer or subscription indentifier is not found
5838
+ return;
5839
+ }
5840
+ var _a = _this.socketState.subscriptions[message.id], query = _a.query, variables = _a.variables, subscriber = _a.subscriber;
5841
+ switch (message.type) {
5842
+ case NEXT: {
5843
+ if (!message.payload.errors && message.payload.data) {
5844
+ subscriber.next && subscriber.next(message.payload.data);
5845
+ }
5846
+ if (message.payload.errors) {
5847
+ subscriber.error && subscriber.error(new types.ClientError(__assign(__assign({}, message.payload), { status: 200 }), { query: query, variables: variables }));
5848
+ }
5849
+ return;
5850
+ }
5851
+ case ERROR: {
5852
+ subscriber.error && subscriber.error(new types.ClientError({ errors: message.payload, status: 200 }, { query: query, variables: variables }));
5853
+ return;
5854
+ }
5855
+ case COMPLETE: {
5856
+ subscriber.complete && subscriber.complete();
5857
+ delete _this.socketState.subscriptions[message.id];
5858
+ return;
5859
+ }
5860
+ }
5861
+ }
5862
+ catch (e) {
5863
+ // Unexpected errors while handling graphql-ws message
5864
+ console.error(e);
5865
+ socket.close(1006);
5866
+ }
5867
+ socket.close(4400, "Unknown graphql-ws message.");
5868
+ };
5869
+ }
5870
+ GraphQLWebSocketClient.prototype.makeSubscribe = function (query, operationName, variables, subscriber) {
5871
+ var _this = this;
5872
+ var subscriptionId = (this.socketState.lastRequestId++).toString();
5873
+ this.socketState.subscriptions[subscriptionId] = { query: query, variables: variables, subscriber: subscriber };
5874
+ this.socket.send(Subscribe(subscriptionId, { query: query, operationName: operationName, variables: variables }).text);
5875
+ return function () {
5876
+ _this.socket.send(Complete(subscriptionId).text);
5877
+ delete _this.socketState.subscriptions[subscriptionId];
5878
+ };
5879
+ };
5880
+ GraphQLWebSocketClient.prototype.rawRequest = function (query, variables) {
5881
+ var _this = this;
5882
+ return new Promise(function (resolve, reject) {
5883
+ var result;
5884
+ _this.rawSubscribe(query, {
5885
+ next: function (data, extensions) { return (result = { data: data, extensions: extensions }); },
5886
+ error: reject,
5887
+ complete: function () { return resolve(result); },
5888
+ }, variables);
5889
+ });
5890
+ };
5891
+ GraphQLWebSocketClient.prototype.request = function (document, variables) {
5892
+ var _this = this;
5893
+ return new Promise(function (resolve, reject) {
5894
+ var result;
5895
+ _this.subscribe(document, {
5896
+ next: function (data) { return (result = data); },
5897
+ error: reject,
5898
+ complete: function () { return resolve(result); },
5899
+ }, variables);
5900
+ });
5901
+ };
5902
+ GraphQLWebSocketClient.prototype.subscribe = function (document, subscriber, variables) {
5903
+ var _a = dist.resolveRequestDocument(document), query = _a.query, operationName = _a.operationName;
5904
+ return this.makeSubscribe(query, operationName, variables, subscriber);
5905
+ };
5906
+ GraphQLWebSocketClient.prototype.rawSubscribe = function (query, subscriber, variables) {
5907
+ return this.makeSubscribe(query, undefined, variables, subscriber);
5908
+ };
5909
+ GraphQLWebSocketClient.prototype.ping = function (payload) {
5910
+ this.socket.send(Ping(payload).text);
5911
+ };
5912
+ GraphQLWebSocketClient.prototype.close = function () {
5913
+ this.socket.close(1000);
5914
+ };
5915
+ GraphQLWebSocketClient.PROTOCOL = "graphql-transport-ws";
5916
+ return GraphQLWebSocketClient;
5917
+ }());
5918
+ exports.GraphQLWebSocketClient = GraphQLWebSocketClient;
5919
+ // Helper functions
5920
+ function parseMessage(data, f) {
5921
+ if (f === void 0) { f = function (a) { return a; }; }
5922
+ var m = GraphQLWebSocketMessage.parse(data, f);
5923
+ return m;
5924
+ }
5925
+ function ConnectionInit(payload) {
5926
+ return new GraphQLWebSocketMessage(CONNECTION_INIT, payload);
5927
+ }
5928
+ function Ping(payload) {
5929
+ return new GraphQLWebSocketMessage(PING, payload, undefined);
5930
+ }
5931
+ function Pong(payload) {
5932
+ return new GraphQLWebSocketMessage(PONG, payload, undefined);
5933
+ }
5934
+ function Subscribe(id, payload) {
5935
+ return new GraphQLWebSocketMessage(SUBSCRIBE, payload, id);
5936
+ }
5937
+ function Complete(id) {
5938
+ return new GraphQLWebSocketMessage(COMPLETE, undefined, id);
5939
+ }
5940
+ //# sourceMappingURL=graphql-ws.js.map
5941
+ });
5942
+
6883
5943
  var dist = createCommonjsModule(function (module, exports) {
6884
5944
  var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
6885
5945
  __assign = Object.assign || function(t) {
@@ -6962,7 +6022,7 @@ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || func
6962
6022
  return (mod && mod.__esModule) ? mod : { "default": mod };
6963
6023
  };
6964
6024
  Object.defineProperty(exports, "__esModule", { value: true });
6965
- exports.gql = exports.batchRequests = exports.request = exports.rawRequest = exports.GraphQLClient = exports.ClientError = void 0;
6025
+ exports.GraphQLWebSocketClient = exports.gql = exports.resolveRequestDocument = exports.batchRequests = exports.request = exports.rawRequest = exports.GraphQLClient = exports.ClientError = void 0;
6966
6026
  var cross_fetch_1 = __importStar(browserPonyfill), CrossFetch = cross_fetch_1;
6967
6027
 
6968
6028
 
@@ -7096,7 +6156,7 @@ var GraphQLClient = /** @class */ (function () {
7096
6156
  url: url,
7097
6157
  query: rawRequestOptions.query,
7098
6158
  variables: rawRequestOptions.variables,
7099
- headers: __assign(__assign({}, resolveHeaders(headers)), resolveHeaders(rawRequestOptions.requestHeaders)),
6159
+ headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(rawRequestOptions.requestHeaders)),
7100
6160
  operationName: operationName,
7101
6161
  fetch: fetch,
7102
6162
  method: method,
@@ -7122,7 +6182,7 @@ var GraphQLClient = /** @class */ (function () {
7122
6182
  url: url,
7123
6183
  query: query,
7124
6184
  variables: requestOptions.variables,
7125
- headers: __assign(__assign({}, resolveHeaders(headers)), resolveHeaders(requestOptions.requestHeaders)),
6185
+ headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(requestOptions.requestHeaders)),
7126
6186
  operationName: operationName,
7127
6187
  fetch: fetch,
7128
6188
  method: method,
@@ -7159,7 +6219,7 @@ var GraphQLClient = /** @class */ (function () {
7159
6219
  url: url,
7160
6220
  query: queries,
7161
6221
  variables: variables,
7162
- headers: __assign(__assign({}, resolveHeaders(headers)), resolveHeaders(batchRequestOptions.requestHeaders)),
6222
+ headers: __assign(__assign({}, resolveHeaders(callOrIdentity(headers))), resolveHeaders(batchRequestOptions.requestHeaders)),
7163
6223
  operationName: undefined,
7164
6224
  fetch: fetch,
7165
6225
  method: method,
@@ -7205,7 +6265,7 @@ exports.GraphQLClient = GraphQLClient;
7205
6265
  function makeRequest(_a) {
7206
6266
  var url = _a.url, query = _a.query, variables = _a.variables, headers = _a.headers, operationName = _a.operationName, fetch = _a.fetch, _b = _a.method, method = _b === void 0 ? 'POST' : _b, fetchOptions = _a.fetchOptions;
7207
6267
  return __awaiter(this, void 0, void 0, function () {
7208
- var fetcher, isBathchingQuery, response, result, successfullyReceivedData, headers_1, status_1, errorResult;
6268
+ var fetcher, isBathchingQuery, response, result, successfullyReceivedData, successfullyPassedErrorPolicy, headers_1, status_1, rest, data, errorResult;
7209
6269
  return __generator(this, function (_c) {
7210
6270
  switch (_c.label) {
7211
6271
  case 0:
@@ -7229,9 +6289,12 @@ function makeRequest(_a) {
7229
6289
  var data = _a.data;
7230
6290
  return !data;
7231
6291
  }) : !!result.data;
7232
- if (response.ok && !result.errors && successfullyReceivedData) {
6292
+ successfullyPassedErrorPolicy = !result.errors || fetchOptions.errorPolicy === 'all' || fetchOptions.errorPolicy === 'ignore';
6293
+ if (response.ok && successfullyPassedErrorPolicy && successfullyReceivedData) {
7233
6294
  headers_1 = response.headers, status_1 = response.status;
7234
- return [2 /*return*/, __assign(__assign({}, (isBathchingQuery ? { data: result } : result)), { headers: headers_1, status: status_1 })];
6295
+ rest = __rest(result, ["errors"]);
6296
+ data = fetchOptions.errorPolicy === 'ignore' ? rest : result;
6297
+ return [2 /*return*/, __assign(__assign({}, (isBathchingQuery ? { data: data } : data)), { headers: headers_1, status: status_1 })];
7235
6298
  }
7236
6299
  else {
7237
6300
  errorResult = typeof result === 'string' ? { error: result } : result;
@@ -7326,6 +6389,10 @@ function resolveRequestDocument(document) {
7326
6389
  var operationName = extractOperationName(document);
7327
6390
  return { query: printer.print(document), operationName: operationName };
7328
6391
  }
6392
+ exports.resolveRequestDocument = resolveRequestDocument;
6393
+ function callOrIdentity(value) {
6394
+ return typeof value === 'function' ? value() : value;
6395
+ }
7329
6396
  /**
7330
6397
  * Convenience passthrough template tag to get the benefits of tooling for the gql template tag. This does not actually parse the input into a GraphQL DocumentNode like graphql-tag package does. It just returns the string with any variables given interpolated. Can save you a bit of performance and having to install another package.
7331
6398
  *
@@ -7357,6 +6424,8 @@ function HeadersInstanceToPlainObject(headers) {
7357
6424
  });
7358
6425
  return o;
7359
6426
  }
6427
+
6428
+ Object.defineProperty(exports, "GraphQLWebSocketClient", { enumerable: true, get: function () { return graphqlWs.GraphQLWebSocketClient; } });
7360
6429
  //# sourceMappingURL=index.js.map
7361
6430
  });
7362
6431
 
@@ -7640,15 +6709,7 @@ class DataUnitFetcher {
7640
6709
  const changes = duChanges.map((change) => {
7641
6710
  const { dataUnit: changeDU, record, updatingFields, operation } = change;
7642
6711
  const parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
7643
- if (value) {
7644
- try {
7645
- value = JSON.stringify(value);
7646
- }
7647
- catch (_a) {
7648
- value = value.toString();
7649
- }
7650
- }
7651
- return { fieldName, value };
6712
+ return { fieldName, value: this.formatValueToServer(value) };
7652
6713
  });
7653
6714
  return { dataUnit: changeDU, updatingFields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
7654
6715
  });
@@ -7677,6 +6738,21 @@ class DataUnitFetcher {
7677
6738
  });
7678
6739
  });
7679
6740
  }
6741
+ formatValueToServer(value) {
6742
+ if (value === undefined)
6743
+ return value;
6744
+ try {
6745
+ if (value instanceof Date) {
6746
+ return value.toString();
6747
+ }
6748
+ //Any others objects
6749
+ value = JSON.stringify(value);
6750
+ }
6751
+ catch (_a) {
6752
+ value = value.toString();
6753
+ }
6754
+ return value;
6755
+ }
7680
6756
  removeRecords(dataUnit, recordIds) {
7681
6757
  const changes = recordIds.map((recordId) => {
7682
6758
  return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
@@ -7786,38 +6862,6 @@ class ParametersFetcher {
7786
6862
  }
7787
6863
  }
7788
6864
 
7789
- class ApplicationUtils {
7790
- static async showDialog(title, message, icon = null, confirm, critical = false) {
7791
- return new Promise(resolve => {
7792
- let dialog = document.querySelector("ez-dialog");
7793
- if (!dialog) {
7794
- dialog = document.createElement("ez-dialog");
7795
- window.document.body.appendChild(dialog);
7796
- }
7797
- dialog.show(title, message, critical, confirm, icon).then(ok => resolve(ok));
7798
- });
7799
- }
7800
- static async alert(title, message, icon = null) {
7801
- return ApplicationUtils.showDialog(title, message, icon, false, false);
7802
- }
7803
- static async error(title, message, icon = null) {
7804
- return ApplicationUtils.showDialog(title, message, icon, false, true);
7805
- }
7806
- static async confirm(title, message, icon = null, critical = false) {
7807
- return ApplicationUtils.showDialog(title, message, icon, true, critical);
7808
- }
7809
- static async info(message) {
7810
- let toast = document.querySelector("ez-toast");
7811
- if (!toast) {
7812
- toast = document.createElement("ez-toast");
7813
- window.document.body.appendChild(toast);
7814
- }
7815
- toast.message = message;
7816
- toast.fadeTime = 4000;
7817
- toast.show();
7818
- }
7819
- }
7820
-
7821
6865
  class ResourceFetcher {
7822
6866
  constructor() {
7823
6867
  this.templateByQuery = new Map();
@@ -7975,8 +7019,8 @@ const SnkApplication = class {
7975
7019
  async confirm(title, message, icon, critical) {
7976
7020
  return ApplicationUtils.confirm(title, message, icon, critical);
7977
7021
  }
7978
- async info(message) {
7979
- return ApplicationUtils.info(message);
7022
+ async info(message, options = undefined) {
7023
+ return ApplicationUtils.info(message, options);
7980
7024
  }
7981
7025
  async loadFormConfig(name) {
7982
7026
  return this.formConfigFetcher.loadFormConfig(name, this.resourceID);