@sankhyalabs/sankhyablocks 8.2.0-dev.5 → 8.2.0-dev.7

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 (151) hide show
  1. package/dist/cjs/{ConfigStorage-12397f18.js → ConfigStorage-349cf0fd.js} +2 -2
  2. package/dist/cjs/{DataFetcher-f2da1f79.js → DataFetcher-7ba52c1d.js} +12 -206
  3. package/dist/cjs/PrintUtils-bcaeb82f.js +215 -0
  4. package/dist/cjs/{SnkFormConfigManager-13f79e37.js → SnkFormConfigManager-9083c12f.js} +2 -2
  5. package/dist/cjs/{auth-fetcher-319a4cb2.js → auth-fetcher-718ca8b4.js} +1 -1
  6. package/dist/cjs/{dataunit-fetcher-e72068c1.js → dataunit-fetcher-076fcbf7.js} +1 -1
  7. package/dist/cjs/{form-config-fetcher-5d62ab62.js → form-config-fetcher-c7ec4ff9.js} +1 -1
  8. package/dist/cjs/index-f9e81701.js +4 -0
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/{pesquisa-fetcher-8c363096.js → pesquisa-fetcher-a9c5a2f5.js} +1 -1
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button.cjs.entry.js +4 -3
  13. package/dist/cjs/snk-application.cjs.entry.js +17 -6
  14. package/dist/cjs/snk-attach.cjs.entry.js +4 -3
  15. package/dist/cjs/snk-crud.cjs.entry.js +8 -6
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -1
  17. package/dist/cjs/snk-detail-view.cjs.entry.js +10 -8
  18. package/dist/cjs/snk-filter-bar.cjs.entry.js +4 -3
  19. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +4 -3
  20. package/dist/cjs/snk-form-config.cjs.entry.js +3 -2
  21. package/dist/cjs/snk-form.cjs.entry.js +5 -4
  22. package/dist/cjs/snk-grid-config.cjs.entry.js +4 -3
  23. package/dist/cjs/snk-grid.cjs.entry.js +9 -5
  24. package/dist/cjs/{snk-guides-viewer-a7cd6fda.js → snk-guides-viewer-18e9666c.js} +8 -7
  25. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -7
  26. package/dist/cjs/snk-personalized-filter.cjs.entry.js +4 -3
  27. package/dist/cjs/snk-print-selector.cjs.entry.js +2 -4
  28. package/dist/cjs/snk-simple-crud.cjs.entry.js +6 -5
  29. package/dist/cjs/snk-taskbar-custom-elements.cjs.entry.js +20 -0
  30. package/dist/cjs/snk-taskbar.cjs.entry.js +69 -4
  31. package/dist/cjs/{taskbar-elements-b98dd6e9.js → taskbar-elements-39949c7a.js} +4 -4
  32. package/dist/collection/collection-manifest.json +1 -0
  33. package/dist/collection/components/snk-application/snk-application.js +60 -0
  34. package/dist/collection/components/snk-crud/snk-crud.js +6 -4
  35. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +19 -1
  36. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +20 -2
  37. package/dist/collection/components/snk-grid/snk-grid.js +57 -1
  38. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +1 -1
  39. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +4 -4
  40. package/dist/collection/components/snk-taskbar/snk-taskbar-custom-elements.js +43 -0
  41. package/dist/collection/components/snk-taskbar/snk-taskbar.css +4 -0
  42. package/dist/collection/components/snk-taskbar/snk-taskbar.js +107 -4
  43. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +10 -4
  44. package/dist/collection/lib/utils/PrintUtils.js +18 -9
  45. package/dist/components/DataFetcher.js +13 -206
  46. package/dist/components/PrintUtils.js +213 -0
  47. package/dist/components/index.d.ts +1 -0
  48. package/dist/components/index.js +1 -0
  49. package/dist/components/snk-application2.js +11 -1
  50. package/dist/components/snk-crud.js +5 -3
  51. package/dist/components/snk-detail-view2.js +9 -5
  52. package/dist/components/snk-grid2.js +7 -1
  53. package/dist/components/snk-print-selector.js +1 -1
  54. package/dist/components/snk-simple-crud2.js +1 -1
  55. package/dist/components/snk-taskbar-custom-elements.d.ts +11 -0
  56. package/dist/components/snk-taskbar-custom-elements.js +35 -0
  57. package/dist/components/snk-taskbar2.js +78 -8
  58. package/dist/esm/{ConfigStorage-932ab366.js → ConfigStorage-8d420626.js} +2 -2
  59. package/dist/esm/{DataFetcher-7e18aa30.js → DataFetcher-e97b3942.js} +13 -206
  60. package/dist/esm/PrintUtils-3e4ff0f5.js +213 -0
  61. package/dist/esm/{SnkFormConfigManager-bb9afc3f.js → SnkFormConfigManager-4c6a5b41.js} +2 -2
  62. package/dist/esm/{auth-fetcher-6d9664b7.js → auth-fetcher-55e5cbce.js} +1 -1
  63. package/dist/esm/{dataunit-fetcher-91a4eb82.js → dataunit-fetcher-716a99ca.js} +1 -1
  64. package/dist/esm/{form-config-fetcher-aaaa79a6.js → form-config-fetcher-b69da2f1.js} +1 -1
  65. package/dist/esm/index-a7d3d3f1.js +4 -0
  66. package/dist/esm/loader.js +1 -1
  67. package/dist/esm/{pesquisa-fetcher-56b30fb4.js → pesquisa-fetcher-c9a53822.js} +1 -1
  68. package/dist/esm/sankhyablocks.js +1 -1
  69. package/dist/esm/snk-actions-button.entry.js +4 -3
  70. package/dist/esm/snk-application.entry.js +17 -6
  71. package/dist/esm/snk-attach.entry.js +4 -3
  72. package/dist/esm/snk-crud.entry.js +10 -8
  73. package/dist/esm/snk-data-exporter.entry.js +2 -1
  74. package/dist/esm/snk-detail-view.entry.js +10 -8
  75. package/dist/esm/snk-filter-bar.entry.js +4 -3
  76. package/dist/esm/snk-filter-modal-item.entry.js +4 -3
  77. package/dist/esm/snk-form-config.entry.js +3 -2
  78. package/dist/esm/snk-form.entry.js +5 -4
  79. package/dist/esm/snk-grid-config.entry.js +4 -3
  80. package/dist/esm/snk-grid.entry.js +9 -5
  81. package/dist/esm/{snk-guides-viewer-cc709b5f.js → snk-guides-viewer-2e97c0c3.js} +8 -7
  82. package/dist/esm/snk-guides-viewer.entry.js +8 -7
  83. package/dist/esm/snk-personalized-filter.entry.js +4 -3
  84. package/dist/esm/snk-print-selector.entry.js +1 -3
  85. package/dist/esm/snk-simple-crud.entry.js +6 -5
  86. package/dist/esm/snk-taskbar-custom-elements.entry.js +16 -0
  87. package/dist/esm/snk-taskbar.entry.js +69 -4
  88. package/dist/esm/{taskbar-elements-2c761819.js → taskbar-elements-0a6b8b95.js} +4 -4
  89. package/dist/sankhyablocks/p-0b19beb9.entry.js +1 -0
  90. package/dist/sankhyablocks/p-110136be.entry.js +1 -0
  91. package/dist/sankhyablocks/p-12e48665.entry.js +1 -0
  92. package/dist/sankhyablocks/p-236cd346.js +1 -0
  93. package/dist/sankhyablocks/p-34604220.entry.js +1 -0
  94. package/dist/sankhyablocks/{p-ed41b38c.js → p-41f81c72.js} +1 -1
  95. package/dist/sankhyablocks/p-4e701fa7.js +1 -0
  96. package/dist/sankhyablocks/{p-41e897f1.js → p-615874db.js} +1 -1
  97. package/dist/sankhyablocks/p-648a7c72.entry.js +1 -0
  98. package/dist/sankhyablocks/p-72fc257b.entry.js +1 -0
  99. package/dist/sankhyablocks/p-7453735e.entry.js +1 -0
  100. package/dist/sankhyablocks/p-776514a8.entry.js +11 -0
  101. package/dist/sankhyablocks/{p-a52a6c9d.js → p-81392ced.js} +1 -1
  102. package/dist/sankhyablocks/p-8d884fab.js +1 -0
  103. package/dist/sankhyablocks/p-a2854b5a.entry.js +1 -0
  104. package/dist/sankhyablocks/p-c149dca8.entry.js +1 -0
  105. package/dist/sankhyablocks/p-c303d74f.entry.js +1 -0
  106. package/dist/sankhyablocks/p-c51a4f28.entry.js +1 -0
  107. package/dist/sankhyablocks/{p-a2493d11.js → p-c9841939.js} +1 -1
  108. package/dist/sankhyablocks/p-ce6d7e3f.js +1 -0
  109. package/dist/sankhyablocks/p-cee68227.entry.js +1 -0
  110. package/dist/sankhyablocks/{p-2d333d22.js → p-e696a8f6.js} +1 -1
  111. package/dist/sankhyablocks/p-e6c00493.entry.js +1 -0
  112. package/dist/sankhyablocks/p-ecbb878e.entry.js +1 -0
  113. package/dist/sankhyablocks/{p-14eac6fe.js → p-f390386d.js} +1 -1
  114. package/dist/sankhyablocks/p-fbb4597a.entry.js +1 -0
  115. package/dist/sankhyablocks/p-ff2f2152.entry.js +1 -0
  116. package/dist/sankhyablocks/p-ff8778e6.entry.js +1 -0
  117. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  118. package/dist/types/components/snk-application/snk-application.d.ts +1 -9
  119. package/dist/types/components/snk-crud/snk-crud.d.ts +1 -0
  120. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +4 -0
  121. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +4 -0
  122. package/dist/types/components/snk-grid/snk-grid.d.ts +12 -0
  123. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +2 -2
  124. package/dist/types/components/snk-taskbar/snk-taskbar-custom-elements.d.ts +7 -0
  125. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +23 -0
  126. package/dist/types/components.d.ts +78 -1
  127. package/dist/types/lib/utils/PrintUtils.d.ts +1 -0
  128. package/package.json +1 -1
  129. package/react/components.d.ts +1 -0
  130. package/react/components.js +1 -0
  131. package/react/components.js.map +1 -1
  132. package/dist/sankhyablocks/p-01739b21.entry.js +0 -1
  133. package/dist/sankhyablocks/p-02b89228.entry.js +0 -1
  134. package/dist/sankhyablocks/p-03bb1aea.entry.js +0 -1
  135. package/dist/sankhyablocks/p-05dbc70e.entry.js +0 -1
  136. package/dist/sankhyablocks/p-611aa624.entry.js +0 -1
  137. package/dist/sankhyablocks/p-66bb8c20.entry.js +0 -1
  138. package/dist/sankhyablocks/p-6f154396.entry.js +0 -1
  139. package/dist/sankhyablocks/p-787071a8.js +0 -1
  140. package/dist/sankhyablocks/p-8818d8f6.entry.js +0 -1
  141. package/dist/sankhyablocks/p-93f6ca04.entry.js +0 -1
  142. package/dist/sankhyablocks/p-951e98c9.entry.js +0 -1
  143. package/dist/sankhyablocks/p-b6003974.entry.js +0 -1
  144. package/dist/sankhyablocks/p-cfb33a4a.entry.js +0 -1
  145. package/dist/sankhyablocks/p-d53a9169.entry.js +0 -1
  146. package/dist/sankhyablocks/p-d7638f45.entry.js +0 -11
  147. package/dist/sankhyablocks/p-e64f3e17.entry.js +0 -1
  148. package/dist/sankhyablocks/p-efc10705.entry.js +0 -1
  149. package/dist/sankhyablocks/p-f74fe358.js +0 -1
  150. package/dist/sankhyablocks/p-f8e6b97e.js +0 -1
  151. package/dist/sankhyablocks/p-fa523d6b.entry.js +0 -1
@@ -0,0 +1,43 @@
1
+ import { h, Host } from '@stencil/core';
2
+ export class SnkTaskbarCustomElements {
3
+ constructor() {
4
+ this.slot = 'TASKBAR_CUSTOM_ELEMENTS';
5
+ }
6
+ render() {
7
+ return (h(Host, { slot: this.slot }, h("div", { id: this.slot, class: "taskbar-custom-elements-container" }, h("slot", null))));
8
+ }
9
+ static get is() { return "snk-taskbar-custom-elements"; }
10
+ static get encapsulation() { return "scoped"; }
11
+ static get originalStyleUrls() {
12
+ return {
13
+ "$": ["snk-taskbar.css"]
14
+ };
15
+ }
16
+ static get styleUrls() {
17
+ return {
18
+ "$": ["snk-taskbar.css"]
19
+ };
20
+ }
21
+ static get properties() {
22
+ return {
23
+ "slot": {
24
+ "type": "string",
25
+ "mutable": false,
26
+ "complexType": {
27
+ "original": "string",
28
+ "resolved": "string",
29
+ "references": {}
30
+ },
31
+ "required": false,
32
+ "optional": false,
33
+ "docs": {
34
+ "tags": [],
35
+ "text": "Nome do slot da Taskbar onde os elementos customizados dever\u00E3o aparecer."
36
+ },
37
+ "attribute": "slot",
38
+ "reflect": false,
39
+ "defaultValue": "'TASKBAR_CUSTOM_ELEMENTS'"
40
+ }
41
+ };
42
+ }
43
+ }
@@ -1,3 +1,7 @@
1
1
  :host {
2
2
  display: flex;
3
3
  }
4
+
5
+ .taskbar-custom-elements-container{
6
+ display: none;
7
+ }
@@ -1,10 +1,11 @@
1
1
  import { ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
2
2
  import { h, Host } from '@stencil/core';
3
3
  import { AuthorizationConfig } from '../snk-configurator/AuthorizationConfig';
4
- import { TaskbarElement, buildElem, AuthorizationElements, buildCustomButton, VisibleWhenForbidden } from './elements/taskbar-elements';
4
+ import { AuthorizationElements, buildCustomButton, buildElem, TaskbarElement, VisibleWhenForbidden, } from './elements/taskbar-elements';
5
5
  import { PresentationMode } from '../../lib/@types';
6
6
  export class SnkTaskbar {
7
7
  constructor() {
8
+ this.TASKBAR_ITEM_ID_PREFIX = 'TASKBAR_ITEM_';
8
9
  this._titleKeyByElement = {
9
10
  [TaskbarElement.UPDATE]: "snkTaskbar.titleUpdate",
10
11
  [TaskbarElement.PREVIOUS]: "snkTaskbar.titlePrevious",
@@ -22,6 +23,11 @@ export class SnkTaskbar {
22
23
  [TaskbarElement.ATTACH]: "snkTaskbar.titleAttach",
23
24
  };
24
25
  this._permissions = undefined;
26
+ this._customElements = undefined;
27
+ this._customElementsId = undefined;
28
+ this._slotContainer = undefined;
29
+ this.customSlotId = "TASKBAR_CUSTOM_ELEMENTS";
30
+ this.customContainerId = undefined;
25
31
  this.configName = undefined;
26
32
  this.resourceID = undefined;
27
33
  this.buttons = undefined;
@@ -162,6 +168,43 @@ export class SnkTaskbar {
162
168
  return true;
163
169
  });
164
170
  }
171
+ appendCustomElementsInTaskbar() {
172
+ this._customElementsId.forEach(id => {
173
+ const elementId = id.replace(this.TASKBAR_ITEM_ID_PREFIX, '');
174
+ const customElement = this._customElements.get(elementId);
175
+ const container = this._element.querySelector(`#${id}`);
176
+ if (container) {
177
+ container === null || container === void 0 ? void 0 : container.appendChild(customElement);
178
+ }
179
+ else {
180
+ this.unlinkCustomElementFromTaskbar(customElement);
181
+ }
182
+ });
183
+ }
184
+ addCustomElementContainer(elem) {
185
+ const elementId = `${this.TASKBAR_ITEM_ID_PREFIX}${elem}`;
186
+ if (!this._customElementsId.includes(elementId)) {
187
+ this._customElementsId.push(elementId);
188
+ }
189
+ return h("span", { key: elementId, id: elementId });
190
+ }
191
+ getCustomElements() {
192
+ var _a, _b;
193
+ this._customElementsId = [];
194
+ this._customElements = new Map();
195
+ this._slotContainer = this.buildSlotContainer();
196
+ const customElementsArray = Array.from((_b = (_a = this._slotContainer) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []);
197
+ customElementsArray.forEach(item => this._customElements.set(item.id, item));
198
+ }
199
+ buildSlotContainer() {
200
+ if (this.customContainerId) {
201
+ const container = document.querySelector(`#${this.customContainerId}`);
202
+ return container === null || container === void 0 ? void 0 : container.querySelector(`#${this.customSlotId}`);
203
+ }
204
+ else {
205
+ return this._element.querySelector(`#${this.customSlotId}`);
206
+ }
207
+ }
165
208
  componentWillLoad() {
166
209
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
167
210
  if (this._application) {
@@ -170,6 +213,7 @@ export class SnkTaskbar {
170
213
  else {
171
214
  this._permissions = {};
172
215
  }
216
+ this.getCustomElements();
173
217
  }
174
218
  componentWillRender() {
175
219
  if (this._definitions == undefined && this._permissions) {
@@ -181,12 +225,30 @@ export class SnkTaskbar {
181
225
  const dataInfo = { dataUnit: this.dataUnit };
182
226
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
183
227
  }
228
+ componentDidRender() {
229
+ this.appendCustomElementsInTaskbar();
230
+ }
231
+ disconnectedCallback() {
232
+ this.unlinkAllCustomElements();
233
+ }
234
+ unlinkAllCustomElements() {
235
+ var _a;
236
+ (_a = this._customElementsId) === null || _a === void 0 ? void 0 : _a.forEach(id => {
237
+ const elementId = id.replace(this.TASKBAR_ITEM_ID_PREFIX, '');
238
+ const customElement = this._customElements.get(elementId);
239
+ this.unlinkCustomElementFromTaskbar(customElement);
240
+ });
241
+ }
242
+ unlinkCustomElementFromTaskbar(customElement) {
243
+ this._slotContainer.appendChild(customElement);
244
+ }
184
245
  render() {
185
246
  if (this._definitions === undefined) {
186
247
  return undefined;
187
248
  }
188
249
  let index = 0;
189
250
  return (h(Host, null, this.removeEmpty(this._definitions.map((elem) => {
251
+ var _a;
190
252
  if (elem === TaskbarElement.DIVIDER) {
191
253
  index = 0;
192
254
  }
@@ -196,11 +258,14 @@ export class SnkTaskbar {
196
258
  if (TaskbarElement[elem]) {
197
259
  return this.getElement(index, TaskbarElement[elem]);
198
260
  }
199
- if (this.customButtons.has(elem)) {
261
+ if ((_a = this.customButtons) === null || _a === void 0 ? void 0 : _a.has(elem)) {
200
262
  return this.getElement(index, this.customButtons.get(elem));
201
263
  }
264
+ if (this._customElements.has(elem)) {
265
+ return this.addCustomElementContainer(elem);
266
+ }
202
267
  return h("slot", { name: elem });
203
- }))));
268
+ })), h("div", { class: "taskbar-custom-elements-container" }, h("slot", { name: this.customSlotId }))));
204
269
  }
205
270
  static get is() { return "snk-taskbar"; }
206
271
  static get encapsulation() { return "scoped"; }
@@ -216,6 +281,41 @@ export class SnkTaskbar {
216
281
  }
217
282
  static get properties() {
218
283
  return {
284
+ "customSlotId": {
285
+ "type": "string",
286
+ "mutable": false,
287
+ "complexType": {
288
+ "original": "string",
289
+ "resolved": "string",
290
+ "references": {}
291
+ },
292
+ "required": false,
293
+ "optional": false,
294
+ "docs": {
295
+ "tags": [],
296
+ "text": "Usado para determinar o identificador do slot que recebe elementos personalizados."
297
+ },
298
+ "attribute": "custom-slot-id",
299
+ "reflect": false,
300
+ "defaultValue": "\"TASKBAR_CUSTOM_ELEMENTS\""
301
+ },
302
+ "customContainerId": {
303
+ "type": "string",
304
+ "mutable": false,
305
+ "complexType": {
306
+ "original": "string",
307
+ "resolved": "string",
308
+ "references": {}
309
+ },
310
+ "required": false,
311
+ "optional": false,
312
+ "docs": {
313
+ "tags": [],
314
+ "text": "Usado para determinar o identificador do container na DOM que \u00E9 responsavel por guardar os elementos personalizados\nque n\u00E3o podem ser passados por slot.\n\nExemplo: Elementos customizados na Taskbar da aba de detalhes."
315
+ },
316
+ "attribute": "custom-container-id",
317
+ "reflect": false
318
+ },
219
319
  "configName": {
220
320
  "type": "string",
221
321
  "mutable": false,
@@ -414,7 +514,10 @@ export class SnkTaskbar {
414
514
  }
415
515
  static get states() {
416
516
  return {
417
- "_permissions": {}
517
+ "_permissions": {},
518
+ "_customElements": {},
519
+ "_customElementsId": {},
520
+ "_slotContainer": {}
418
521
  };
419
522
  }
420
523
  static get events() {
@@ -155,9 +155,9 @@ export class DataFetcher {
155
155
  }
156
156
  });
157
157
  }
158
- processPrinting(payload) {
158
+ async processPrinting(payload) {
159
159
  if ((payload === null || payload === void 0 ? void 0 : payload.pendingPrinting) === 'true') {
160
- PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
160
+ await PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
161
161
  }
162
162
  if ('localPrintings' in payload) {
163
163
  PrintUtils.getInstance().processLocalPrinting(payload === null || payload === void 0 ? void 0 : payload.localPrintings);
@@ -205,11 +205,18 @@ export class DataFetcher {
205
205
  http.open("POST", url, true);
206
206
  http.withCredentials = true;
207
207
  http.send(ObjectUtils.objectToString(payloadJson));
208
- http.onreadystatechange = () => {
208
+ http.onreadystatechange = async () => {
209
209
  var _a;
210
210
  if (http.readyState == 4 && http.status == 200) {
211
211
  try {
212
212
  const jsonResp = JSON.parse(http.responseText);
213
+ /**
214
+ * Este trecho difere do projeto HTML5 devido à decisão de adotar uma abordagem síncrona para esta chamada. Isso é justificado pelo fato de que, no cenário em questão, a abordagem assíncrona teria impactos negativos.
215
+ *
216
+ * Descrição do caso de uso:
217
+ * Ao concluir um recebimento com cartão (Movimentação Financeira), é acionado um EzDialog de confirmação. Posteriormente, a PopUp de impressão é exibida, e, ao ser cancelada, gera a invocação de um novo EzDialog.
218
+ */
219
+ await this.processPrinting(jsonResp);
213
220
  if (this.isServiceBrokerError(jsonResp)) {
214
221
  reject(this.processServiceBrokerErrorInfo(jsonResp));
215
222
  }
@@ -223,7 +230,6 @@ export class DataFetcher {
223
230
  }
224
231
  }
225
232
  this.proccessServiceBorkerClientEvents(jsonResp === null || jsonResp === void 0 ? void 0 : jsonResp.clientEvents, serviceName, payloadJson, accept, reject);
226
- this.processPrinting(jsonResp);
227
233
  }
228
234
  catch (err) {
229
235
  console.warn(`Erro ao executar serviço: ${err}`);
@@ -1,8 +1,9 @@
1
- import { StringUtils } from "@sankhyalabs/core";
2
- import { DataFetcher } from "../http/data-fetcher/DataFetcher";
1
+ import { ApplicationContext, StringUtils } from "@sankhyalabs/core";
3
2
  export class PrintUtils {
4
3
  constructor() {
5
4
  this.appletImpressao = new AppletImpressao();
5
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
6
+ application.getDataFetcher().then(result => this.DataFetcher = result);
6
7
  }
7
8
  static getInstance() {
8
9
  if (!PrintUtils.instance) {
@@ -23,12 +24,18 @@ export class PrintUtils {
23
24
  }
24
25
  ]
25
26
  };
26
- const response = await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
27
- const printJobData = this.parsePrintData(response);
28
- const pendingPrints = await this.processDirectPrint(printJobData);
29
- if (!pendingPrints.length)
30
- return;
31
- this.openSnkPrintSelector(Object.assign(Object.assign({}, printJobData), { pendingPrinters: pendingPrints }));
27
+ Promise.resolve(this.DataFetcher).then(async (res) => {
28
+ res = await Promise.resolve(this.DataFetcher);
29
+ while (!res || !res.application) {
30
+ res = await Promise.resolve(this.DataFetcher);
31
+ }
32
+ const response = await res.application.callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
33
+ const printJobData = this.parsePrintData(response);
34
+ const pendingPrints = await this.processDirectPrint(printJobData);
35
+ if (!pendingPrints.length)
36
+ return;
37
+ this.openSnkPrintSelector(Object.assign(Object.assign({}, printJobData), { pendingPrinters: pendingPrints }));
38
+ });
32
39
  }
33
40
  getLocalPrinters() {
34
41
  const localPrinters = this.appletImpressao.findLocalPrinters();
@@ -125,7 +132,9 @@ export class PrintUtils {
125
132
  }
126
133
  }
127
134
  };
128
- await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
135
+ Promise.resolve(this.DataFetcher).then(async (res) => {
136
+ await res.application.callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
137
+ });
129
138
  }
130
139
  async processDirectPrint(printJobData) {
131
140
  const isWCRunning = this.appletImpressao.checkWebConnection();
@@ -1,6 +1,7 @@
1
- import { DataType, StringUtils, ApplicationContext, ErrorException, WarningException, ObjectUtils } from '@sankhyalabs/core';
1
+ import { DataType, ApplicationContext, ErrorException, WarningException, ObjectUtils, StringUtils } from '@sankhyalabs/core';
2
2
  import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers.js';
3
3
  import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
4
+ import { P as PrintUtils } from './PrintUtils.js';
4
5
 
5
6
  var browserPonyfill = createCommonjsModule(function (module, exports) {
6
7
  var global = typeof self !== 'undefined' ? self : commonjsGlobal;
@@ -6506,206 +6507,6 @@ class GraphQLRecaller {
6506
6507
  }
6507
6508
  }
6508
6509
 
6509
- class PrintUtils {
6510
- constructor() {
6511
- this.appletImpressao = new AppletImpressao();
6512
- }
6513
- static getInstance() {
6514
- if (!PrintUtils.instance) {
6515
- PrintUtils.instance = new PrintUtils();
6516
- }
6517
- return PrintUtils.instance;
6518
- }
6519
- async processPendingPrinting(transactionId) {
6520
- await this.findPendingPrints(transactionId);
6521
- }
6522
- async findPendingPrints(transactionId) {
6523
- const requestBody = {
6524
- transactionIds: [
6525
- {
6526
- transactionId: {
6527
- $: transactionId
6528
- }
6529
- }
6530
- ]
6531
- };
6532
- const response = await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
6533
- const printJobData = this.parsePrintData(response);
6534
- const pendingPrints = await this.processDirectPrint(printJobData);
6535
- if (!pendingPrints.length)
6536
- return;
6537
- this.openSnkPrintSelector(Object.assign(Object.assign({}, printJobData), { pendingPrinters: pendingPrints }));
6538
- }
6539
- getLocalPrinters() {
6540
- const localPrinters = this.appletImpressao.findLocalPrinters();
6541
- const printers = [];
6542
- for (const printerName of localPrinters) {
6543
- printers.push({
6544
- nome: printerName,
6545
- printerUri: PrintUtils.LOCAL_SERVER_URI + printerName,
6546
- isLocal: true
6547
- });
6548
- }
6549
- return printers;
6550
- }
6551
- parsePrintData(payload) {
6552
- const pendingPrintJobData = payload.pendindPrintJobData;
6553
- if (!pendingPrintJobData)
6554
- return undefined;
6555
- let { printServers: { printServer }, pendingPrinters: { pendingPrinter } } = pendingPrintJobData;
6556
- printServer = printServer ? (Array.isArray(printServer) ? printServer : [printServer]) : [];
6557
- pendingPrinter = pendingPrinter ? (Array.isArray(pendingPrinter) ? pendingPrinter : [pendingPrinter]) : [];
6558
- const normalizedPrintServer = printServer.map(item => {
6559
- const printerList = Array.isArray(item.printerLocation) ? item.printerLocation : [item.printerLocation];
6560
- return {
6561
- printServerUri: item.printServerUri,
6562
- printerList: printerList.map(this.normalize)
6563
- };
6564
- });
6565
- const normalizedPendingPrinter = pendingPrinter.map(this.normalize);
6566
- return {
6567
- transactionId: pendingPrintJobData.transactionId.$,
6568
- printServers: normalizedPrintServer,
6569
- pendingPrinters: normalizedPendingPrinter,
6570
- printServerActive: pendingPrintJobData.printServers.printServerActive === 'true'
6571
- };
6572
- }
6573
- normalize(object) {
6574
- const normalizedObject = {};
6575
- Object.keys(object).forEach((key) => {
6576
- normalizedObject[key] = PrintUtils.ENCODED_PROPERTIES.includes(key) ? window.atob(object[key].$) : object[key].$;
6577
- });
6578
- return normalizedObject;
6579
- }
6580
- processLocalPrinting(localPrintings) {
6581
- const transactionIds = localPrintings.map((item) => item.transactionId);
6582
- this.appletImpressao.doLocalPrinting(transactionIds.join());
6583
- }
6584
- async openSnkPrintSelector(printJobData) {
6585
- let printSelector = document.querySelector('snk-print-selector');
6586
- if (!printSelector) {
6587
- printSelector = document.createElement('snk-print-selector');
6588
- printSelector.setAttribute('id', StringUtils.generateUUID());
6589
- window.document.body.appendChild(printSelector);
6590
- }
6591
- const { selectedPrinter, saveSubstitute } = await printSelector.openPrintSelector(printJobData);
6592
- if (!selectedPrinter)
6593
- return;
6594
- const params = {
6595
- transactionId: printJobData.transactionId,
6596
- pendingPrinters: printJobData.pendingPrinters,
6597
- printerUri: selectedPrinter.printerUri,
6598
- saveSubstitutePrinters: saveSubstitute
6599
- };
6600
- await this.saveSubstitutePrinter(params);
6601
- }
6602
- async saveSubstitutePrinter(params) {
6603
- const { transactionId, pendingPrinters, printerUri, saveSubstitutePrinters = false } = params;
6604
- const parsedPendingPrinters = pendingPrinters.map((item) => ({
6605
- printerUri: {
6606
- $: item.printerUri || printerUri
6607
- },
6608
- originalPrinterName: {
6609
- $: item.originalPrinterName
6610
- },
6611
- printJobCount: {
6612
- $: item.printJobCount
6613
- },
6614
- docType: {
6615
- $: item.docType
6616
- },
6617
- docTypeDescription: {
6618
- $: item.docTypeDescription
6619
- }
6620
- }));
6621
- const requestBody = {
6622
- substitutePrintersRequest: {
6623
- substitutePrinters: {
6624
- pendingPrinter: parsedPendingPrinters
6625
- },
6626
- saveSubstitutePrinters: {
6627
- $: saveSubstitutePrinters.toString()
6628
- },
6629
- transactionId: {
6630
- $: transactionId
6631
- }
6632
- }
6633
- };
6634
- await DataFetcher.get().callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
6635
- }
6636
- async processDirectPrint(printJobData) {
6637
- const isWCRunning = this.appletImpressao.checkWebConnection();
6638
- if (!isWCRunning) {
6639
- return [];
6640
- }
6641
- const localPrinters = this.getLocalPrinters();
6642
- if (!localPrinters.length)
6643
- return [];
6644
- const directPendingPrints = [];
6645
- const pendingPrints = printJobData.pendingPrinters.filter(item => {
6646
- const defaultPrinterName = this.getDefaultPrinterName(item.originalPrinterName);
6647
- const isDirectPrint = !!localPrinters.find(localPrinter => localPrinter.nome === defaultPrinterName) || this.isPrinterNameAFile(defaultPrinterName);
6648
- if (isDirectPrint) {
6649
- directPendingPrints.push(Object.assign(Object.assign({}, item), { printerUri: PrintUtils.LOCAL_SERVER_URI + defaultPrinterName }));
6650
- return false;
6651
- }
6652
- return true;
6653
- });
6654
- if (!directPendingPrints.length)
6655
- return pendingPrints;
6656
- const params = {
6657
- transactionId: printJobData.transactionId,
6658
- pendingPrinters: directPendingPrints
6659
- };
6660
- await this.saveSubstitutePrinter(params);
6661
- return pendingPrints;
6662
- }
6663
- getDefaultPrinterName(printerName) {
6664
- const defaultPrinterName = this.appletImpressao.getDefaultPrinter();
6665
- const isDefaultPrinterName = /padr[aã]o/ig.test(printerName);
6666
- return (defaultPrinterName && isDefaultPrinterName) ? defaultPrinterName : printerName;
6667
- }
6668
- isPrinterNameAFile(printerName) {
6669
- const regExp = new RegExp("^(\w:)?[/\\\w\s]+?\.\w{3}$", "mis");
6670
- return regExp.test(printerName);
6671
- }
6672
- }
6673
- PrintUtils.SERVICE_FIND_PENDING_PRINTS = 'mge@PrintServiceSP.findPendingPrinters';
6674
- PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER = 'mge@PrintServiceSP.saveSubstitutePrinter';
6675
- PrintUtils.LOCAL_SERVER_URI = 'LOCAL:0/';
6676
- PrintUtils.ENCODED_PROPERTIES = ['printerName', 'printerUri'];
6677
- class AppletImpressao {
6678
- constructor() {
6679
- this.appletImpressao = document.getElementById('centralNotaAppletImpressao');
6680
- }
6681
- checkWebConnection() {
6682
- if (!this.appletImpressao)
6683
- return false;
6684
- if (!this.appletImpressao.testRunningWC)
6685
- return false;
6686
- const isRunning = this.appletImpressao.testRunningWC();
6687
- return !!isRunning;
6688
- }
6689
- findLocalPrinters() {
6690
- if (!this.appletImpressao)
6691
- return [];
6692
- const localPrinters = this.appletImpressao.getLocalPrinters();
6693
- if (!localPrinters)
6694
- return [];
6695
- return localPrinters.split(",");
6696
- }
6697
- doLocalPrinting(transactionIds) {
6698
- if (!this.appletImpressao)
6699
- return;
6700
- this.appletImpressao.doLocalPrinting(transactionIds);
6701
- }
6702
- getDefaultPrinter() {
6703
- if (!this.appletImpressao)
6704
- return '';
6705
- return this.appletImpressao.getPrintDefault();
6706
- }
6707
- }
6708
-
6709
6510
  class DataFetcher {
6710
6511
  constructor() {
6711
6512
  this.GRAPHQL_PATH = `/${window.MGE_MODULE_NAME || 'mgefin-bff'}/graphql`;
@@ -6856,9 +6657,9 @@ class DataFetcher {
6856
6657
  }
6857
6658
  });
6858
6659
  }
6859
- processPrinting(payload) {
6660
+ async processPrinting(payload) {
6860
6661
  if ((payload === null || payload === void 0 ? void 0 : payload.pendingPrinting) === 'true') {
6861
- PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
6662
+ await PrintUtils.getInstance().processPendingPrinting(payload === null || payload === void 0 ? void 0 : payload.transactionId);
6862
6663
  }
6863
6664
  if ('localPrintings' in payload) {
6864
6665
  PrintUtils.getInstance().processLocalPrinting(payload === null || payload === void 0 ? void 0 : payload.localPrintings);
@@ -6906,11 +6707,18 @@ class DataFetcher {
6906
6707
  http.open("POST", url, true);
6907
6708
  http.withCredentials = true;
6908
6709
  http.send(ObjectUtils.objectToString(payloadJson));
6909
- http.onreadystatechange = () => {
6710
+ http.onreadystatechange = async () => {
6910
6711
  var _a;
6911
6712
  if (http.readyState == 4 && http.status == 200) {
6912
6713
  try {
6913
6714
  const jsonResp = JSON.parse(http.responseText);
6715
+ /**
6716
+ * Este trecho difere do projeto HTML5 devido à decisão de adotar uma abordagem síncrona para esta chamada. Isso é justificado pelo fato de que, no cenário em questão, a abordagem assíncrona teria impactos negativos.
6717
+ *
6718
+ * Descrição do caso de uso:
6719
+ * Ao concluir um recebimento com cartão (Movimentação Financeira), é acionado um EzDialog de confirmação. Posteriormente, a PopUp de impressão é exibida, e, ao ser cancelada, gera a invocação de um novo EzDialog.
6720
+ */
6721
+ await this.processPrinting(jsonResp);
6914
6722
  if (this.isServiceBrokerError(jsonResp)) {
6915
6723
  reject(this.processServiceBrokerErrorInfo(jsonResp));
6916
6724
  }
@@ -6924,7 +6732,6 @@ class DataFetcher {
6924
6732
  }
6925
6733
  }
6926
6734
  this.proccessServiceBorkerClientEvents(jsonResp === null || jsonResp === void 0 ? void 0 : jsonResp.clientEvents, serviceName, payloadJson, accept, reject);
6927
- this.processPrinting(jsonResp);
6928
6735
  }
6929
6736
  catch (err) {
6930
6737
  console.warn(`Erro ao executar serviço: ${err}`);
@@ -7117,4 +6924,4 @@ class WaitingRequest {
7117
6924
  }
7118
6925
  }
7119
6926
 
7120
- export { DataFetcher as D, PrintUtils as P, UrlUtils as U, dist as d };
6927
+ export { DataFetcher as D, UrlUtils as U, dist as d };