@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
@@ -105,28 +105,29 @@ const buildElem = (element, className, dataElementId, getTitle, action, isEnable
105
105
  }
106
106
  };
107
107
  function textButton(name, className, dataElementId, text, title, action, isEnabled) {
108
- return h("ez-button", { title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) });
108
+ return h("ez-button", { key: dataElementId, title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) });
109
109
  }
110
110
  function iconButton(iconName, name, className, dataElementId, title, action, isEnabled) {
111
- return h("ez-button", { title: title, mode: "icon", size: "small", class: className, "data-element-id": dataElementId, iconName: iconName, enabled: isEnabled(name), onClick: () => action(name) });
111
+ return h("ez-button", { key: dataElementId, title: title, mode: "icon", size: "small", class: className, "data-element-id": dataElementId, iconName: iconName, enabled: isEnabled(name), onClick: () => action(name) });
112
112
  }
113
113
  function iconTextButton(iconName, name, className, dataElementId, text, title, action, isEnabled) {
114
- return h("ez-button", { title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) },
114
+ return h("ez-button", { key: dataElementId, title: title, label: text, size: "small", class: className, "data-element-id": dataElementId, enabled: isEnabled(name), onClick: () => action(name) },
115
115
  h("ez-icon", { class: "ez-padding-right--small", slot: "leftIcon", iconName: iconName }));
116
116
  }
117
117
  function actionButton(element, className, dataElementId, title, action, isEnabled, actions) {
118
118
  return actions && actions.length > 0
119
- ? h("ez-actions-button", { title: title, size: "small", "data-element-id": dataElementId, arrowActive: true, class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions })
119
+ ? h("ez-actions-button", { key: dataElementId, title: title, size: "small", "data-element-id": dataElementId, arrowActive: true, class: className, enabled: isEnabled(element), onEzAction: (evt) => action(evt.detail.value), actions: actions })
120
120
  : undefined;
121
121
  }
122
122
 
123
- const snkTaskbarCss = ".sc-snk-taskbar-h{display:flex}";
123
+ const snkTaskbarCss = ".sc-snk-taskbar-h{display:flex}.taskbar-custom-elements-container.sc-snk-taskbar{display:none}";
124
124
 
125
125
  const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
126
126
  constructor() {
127
127
  super();
128
128
  this.__registerHost();
129
129
  this.actionClick = createEvent(this, "actionClick", 7);
130
+ this.TASKBAR_ITEM_ID_PREFIX = 'TASKBAR_ITEM_';
130
131
  this._titleKeyByElement = {
131
132
  [TaskbarElement.UPDATE]: "snkTaskbar.titleUpdate",
132
133
  [TaskbarElement.PREVIOUS]: "snkTaskbar.titlePrevious",
@@ -144,6 +145,11 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
144
145
  [TaskbarElement.ATTACH]: "snkTaskbar.titleAttach",
145
146
  };
146
147
  this._permissions = undefined;
148
+ this._customElements = undefined;
149
+ this._customElementsId = undefined;
150
+ this._slotContainer = undefined;
151
+ this.customSlotId = "TASKBAR_CUSTOM_ELEMENTS";
152
+ this.customContainerId = undefined;
147
153
  this.configName = undefined;
148
154
  this.resourceID = undefined;
149
155
  this.buttons = undefined;
@@ -284,6 +290,43 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
284
290
  return true;
285
291
  });
286
292
  }
293
+ appendCustomElementsInTaskbar() {
294
+ this._customElementsId.forEach(id => {
295
+ const elementId = id.replace(this.TASKBAR_ITEM_ID_PREFIX, '');
296
+ const customElement = this._customElements.get(elementId);
297
+ const container = this._element.querySelector(`#${id}`);
298
+ if (container) {
299
+ container === null || container === void 0 ? void 0 : container.appendChild(customElement);
300
+ }
301
+ else {
302
+ this.unlinkCustomElementFromTaskbar(customElement);
303
+ }
304
+ });
305
+ }
306
+ addCustomElementContainer(elem) {
307
+ const elementId = `${this.TASKBAR_ITEM_ID_PREFIX}${elem}`;
308
+ if (!this._customElementsId.includes(elementId)) {
309
+ this._customElementsId.push(elementId);
310
+ }
311
+ return h("span", { key: elementId, id: elementId });
312
+ }
313
+ getCustomElements() {
314
+ var _a, _b;
315
+ this._customElementsId = [];
316
+ this._customElements = new Map();
317
+ this._slotContainer = this.buildSlotContainer();
318
+ const customElementsArray = Array.from((_b = (_a = this._slotContainer) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []);
319
+ customElementsArray.forEach(item => this._customElements.set(item.id, item));
320
+ }
321
+ buildSlotContainer() {
322
+ if (this.customContainerId) {
323
+ const container = document.querySelector(`#${this.customContainerId}`);
324
+ return container === null || container === void 0 ? void 0 : container.querySelector(`#${this.customSlotId}`);
325
+ }
326
+ else {
327
+ return this._element.querySelector(`#${this.customSlotId}`);
328
+ }
329
+ }
287
330
  componentWillLoad() {
288
331
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
289
332
  if (this._application) {
@@ -292,6 +335,7 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
292
335
  else {
293
336
  this._permissions = {};
294
337
  }
338
+ this.getCustomElements();
295
339
  }
296
340
  componentWillRender() {
297
341
  if (this._definitions == undefined && this._permissions) {
@@ -303,12 +347,30 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
303
347
  const dataInfo = { dataUnit: this.dataUnit };
304
348
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
305
349
  }
350
+ componentDidRender() {
351
+ this.appendCustomElementsInTaskbar();
352
+ }
353
+ disconnectedCallback() {
354
+ this.unlinkAllCustomElements();
355
+ }
356
+ unlinkAllCustomElements() {
357
+ var _a;
358
+ (_a = this._customElementsId) === null || _a === void 0 ? void 0 : _a.forEach(id => {
359
+ const elementId = id.replace(this.TASKBAR_ITEM_ID_PREFIX, '');
360
+ const customElement = this._customElements.get(elementId);
361
+ this.unlinkCustomElementFromTaskbar(customElement);
362
+ });
363
+ }
364
+ unlinkCustomElementFromTaskbar(customElement) {
365
+ this._slotContainer.appendChild(customElement);
366
+ }
306
367
  render() {
307
368
  if (this._definitions === undefined) {
308
369
  return undefined;
309
370
  }
310
371
  let index = 0;
311
372
  return (h(Host, null, this.removeEmpty(this._definitions.map((elem) => {
373
+ var _a;
312
374
  if (elem === TaskbarElement.DIVIDER) {
313
375
  index = 0;
314
376
  }
@@ -318,11 +380,14 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
318
380
  if (TaskbarElement[elem]) {
319
381
  return this.getElement(index, TaskbarElement[elem]);
320
382
  }
321
- if (this.customButtons.has(elem)) {
383
+ if ((_a = this.customButtons) === null || _a === void 0 ? void 0 : _a.has(elem)) {
322
384
  return this.getElement(index, this.customButtons.get(elem));
323
385
  }
386
+ if (this._customElements.has(elem)) {
387
+ return this.addCustomElementContainer(elem);
388
+ }
324
389
  return h("slot", { name: elem });
325
- }))));
390
+ })), h("div", { class: "taskbar-custom-elements-container" }, h("slot", { name: this.customSlotId }))));
326
391
  }
327
392
  get _element() { return this; }
328
393
  static get watchers() { return {
@@ -330,6 +395,8 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
330
395
  }; }
331
396
  static get style() { return snkTaskbarCss; }
332
397
  }, [6, "snk-taskbar", {
398
+ "customSlotId": [1, "custom-slot-id"],
399
+ "customContainerId": [1, "custom-container-id"],
333
400
  "configName": [1, "config-name"],
334
401
  "resourceID": [1, "resource-i-d"],
335
402
  "buttons": [1],
@@ -340,7 +407,10 @@ const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
340
407
  "dataUnit": [16],
341
408
  "presentationMode": [1537, "presentation-mode"],
342
409
  "messagesBuilder": [1040],
343
- "_permissions": [32]
410
+ "_permissions": [32],
411
+ "_customElements": [32],
412
+ "_customElementsId": [32],
413
+ "_slotContainer": [32]
344
414
  }]);
345
415
  function defineCustomElement() {
346
416
  if (typeof customElements === "undefined") {
@@ -1,6 +1,6 @@
1
- import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-aaaa79a6.js';
1
+ import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-b69da2f1.js';
2
2
  import { F as FilterItemType } from './filter-item-type.enum-5028ed3f.js';
3
- import { d as dist, D as DataFetcher } from './DataFetcher-7e18aa30.js';
3
+ import { d as dist, D as DataFetcher } from './DataFetcher-e97b3942.js';
4
4
 
5
5
  class GridConfigFetcher extends ResourceFetcher {
6
6
  constructor() {
@@ -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-9943807e.js';
3
3
  import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
4
+ import { P as PrintUtils } from './PrintUtils-3e4ff0f5.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 };
@@ -0,0 +1,213 @@
1
+ import { ApplicationContext, StringUtils } from '@sankhyalabs/core';
2
+
3
+ class PrintUtils {
4
+ constructor() {
5
+ this.appletImpressao = new AppletImpressao();
6
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
7
+ application.getDataFetcher().then(result => this.DataFetcher = result);
8
+ }
9
+ static getInstance() {
10
+ if (!PrintUtils.instance) {
11
+ PrintUtils.instance = new PrintUtils();
12
+ }
13
+ return PrintUtils.instance;
14
+ }
15
+ async processPendingPrinting(transactionId) {
16
+ await this.findPendingPrints(transactionId);
17
+ }
18
+ async findPendingPrints(transactionId) {
19
+ const requestBody = {
20
+ transactionIds: [
21
+ {
22
+ transactionId: {
23
+ $: transactionId
24
+ }
25
+ }
26
+ ]
27
+ };
28
+ Promise.resolve(this.DataFetcher).then(async (res) => {
29
+ res = await Promise.resolve(this.DataFetcher);
30
+ while (!res || !res.application) {
31
+ res = await Promise.resolve(this.DataFetcher);
32
+ }
33
+ const response = await res.application.callServiceBroker(PrintUtils.SERVICE_FIND_PENDING_PRINTS, JSON.stringify(requestBody));
34
+ const printJobData = this.parsePrintData(response);
35
+ const pendingPrints = await this.processDirectPrint(printJobData);
36
+ if (!pendingPrints.length)
37
+ return;
38
+ this.openSnkPrintSelector(Object.assign(Object.assign({}, printJobData), { pendingPrinters: pendingPrints }));
39
+ });
40
+ }
41
+ getLocalPrinters() {
42
+ const localPrinters = this.appletImpressao.findLocalPrinters();
43
+ const printers = [];
44
+ for (const printerName of localPrinters) {
45
+ printers.push({
46
+ nome: printerName,
47
+ printerUri: PrintUtils.LOCAL_SERVER_URI + printerName,
48
+ isLocal: true
49
+ });
50
+ }
51
+ return printers;
52
+ }
53
+ parsePrintData(payload) {
54
+ const pendingPrintJobData = payload.pendindPrintJobData;
55
+ if (!pendingPrintJobData)
56
+ return undefined;
57
+ let { printServers: { printServer }, pendingPrinters: { pendingPrinter } } = pendingPrintJobData;
58
+ printServer = printServer ? (Array.isArray(printServer) ? printServer : [printServer]) : [];
59
+ pendingPrinter = pendingPrinter ? (Array.isArray(pendingPrinter) ? pendingPrinter : [pendingPrinter]) : [];
60
+ const normalizedPrintServer = printServer.map(item => {
61
+ const printerList = Array.isArray(item.printerLocation) ? item.printerLocation : [item.printerLocation];
62
+ return {
63
+ printServerUri: item.printServerUri,
64
+ printerList: printerList.map(this.normalize)
65
+ };
66
+ });
67
+ const normalizedPendingPrinter = pendingPrinter.map(this.normalize);
68
+ return {
69
+ transactionId: pendingPrintJobData.transactionId.$,
70
+ printServers: normalizedPrintServer,
71
+ pendingPrinters: normalizedPendingPrinter,
72
+ printServerActive: pendingPrintJobData.printServers.printServerActive === 'true'
73
+ };
74
+ }
75
+ normalize(object) {
76
+ const normalizedObject = {};
77
+ Object.keys(object).forEach((key) => {
78
+ normalizedObject[key] = PrintUtils.ENCODED_PROPERTIES.includes(key) ? window.atob(object[key].$) : object[key].$;
79
+ });
80
+ return normalizedObject;
81
+ }
82
+ processLocalPrinting(localPrintings) {
83
+ const transactionIds = localPrintings.map((item) => item.transactionId);
84
+ this.appletImpressao.doLocalPrinting(transactionIds.join());
85
+ }
86
+ async openSnkPrintSelector(printJobData) {
87
+ let printSelector = document.querySelector('snk-print-selector');
88
+ if (!printSelector) {
89
+ printSelector = document.createElement('snk-print-selector');
90
+ printSelector.setAttribute('id', StringUtils.generateUUID());
91
+ window.document.body.appendChild(printSelector);
92
+ }
93
+ const { selectedPrinter, saveSubstitute } = await printSelector.openPrintSelector(printJobData);
94
+ if (!selectedPrinter)
95
+ return;
96
+ const params = {
97
+ transactionId: printJobData.transactionId,
98
+ pendingPrinters: printJobData.pendingPrinters,
99
+ printerUri: selectedPrinter.printerUri,
100
+ saveSubstitutePrinters: saveSubstitute
101
+ };
102
+ await this.saveSubstitutePrinter(params);
103
+ }
104
+ async saveSubstitutePrinter(params) {
105
+ const { transactionId, pendingPrinters, printerUri, saveSubstitutePrinters = false } = params;
106
+ const parsedPendingPrinters = pendingPrinters.map((item) => ({
107
+ printerUri: {
108
+ $: item.printerUri || printerUri
109
+ },
110
+ originalPrinterName: {
111
+ $: item.originalPrinterName
112
+ },
113
+ printJobCount: {
114
+ $: item.printJobCount
115
+ },
116
+ docType: {
117
+ $: item.docType
118
+ },
119
+ docTypeDescription: {
120
+ $: item.docTypeDescription
121
+ }
122
+ }));
123
+ const requestBody = {
124
+ substitutePrintersRequest: {
125
+ substitutePrinters: {
126
+ pendingPrinter: parsedPendingPrinters
127
+ },
128
+ saveSubstitutePrinters: {
129
+ $: saveSubstitutePrinters.toString()
130
+ },
131
+ transactionId: {
132
+ $: transactionId
133
+ }
134
+ }
135
+ };
136
+ Promise.resolve(this.DataFetcher).then(async (res) => {
137
+ await res.application.callServiceBroker(PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER, JSON.stringify(requestBody));
138
+ });
139
+ }
140
+ async processDirectPrint(printJobData) {
141
+ const isWCRunning = this.appletImpressao.checkWebConnection();
142
+ if (!isWCRunning) {
143
+ return [];
144
+ }
145
+ const localPrinters = this.getLocalPrinters();
146
+ if (!localPrinters.length)
147
+ return [];
148
+ const directPendingPrints = [];
149
+ const pendingPrints = printJobData.pendingPrinters.filter(item => {
150
+ const defaultPrinterName = this.getDefaultPrinterName(item.originalPrinterName);
151
+ const isDirectPrint = !!localPrinters.find(localPrinter => localPrinter.nome === defaultPrinterName) || this.isPrinterNameAFile(defaultPrinterName);
152
+ if (isDirectPrint) {
153
+ directPendingPrints.push(Object.assign(Object.assign({}, item), { printerUri: PrintUtils.LOCAL_SERVER_URI + defaultPrinterName }));
154
+ return false;
155
+ }
156
+ return true;
157
+ });
158
+ if (!directPendingPrints.length)
159
+ return pendingPrints;
160
+ const params = {
161
+ transactionId: printJobData.transactionId,
162
+ pendingPrinters: directPendingPrints
163
+ };
164
+ await this.saveSubstitutePrinter(params);
165
+ return pendingPrints;
166
+ }
167
+ getDefaultPrinterName(printerName) {
168
+ const defaultPrinterName = this.appletImpressao.getDefaultPrinter();
169
+ const isDefaultPrinterName = /padr[aã]o/ig.test(printerName);
170
+ return (defaultPrinterName && isDefaultPrinterName) ? defaultPrinterName : printerName;
171
+ }
172
+ isPrinterNameAFile(printerName) {
173
+ const regExp = new RegExp("^(\w:)?[/\\\w\s]+?\.\w{3}$", "mis");
174
+ return regExp.test(printerName);
175
+ }
176
+ }
177
+ PrintUtils.SERVICE_FIND_PENDING_PRINTS = 'mge@PrintServiceSP.findPendingPrinters';
178
+ PrintUtils.SERVICE_SAVE_SUBSTITUTE_PRINTER = 'mge@PrintServiceSP.saveSubstitutePrinter';
179
+ PrintUtils.LOCAL_SERVER_URI = 'LOCAL:0/';
180
+ PrintUtils.ENCODED_PROPERTIES = ['printerName', 'printerUri'];
181
+ class AppletImpressao {
182
+ constructor() {
183
+ this.appletImpressao = document.getElementById('centralNotaAppletImpressao');
184
+ }
185
+ checkWebConnection() {
186
+ if (!this.appletImpressao)
187
+ return false;
188
+ if (!this.appletImpressao.testRunningWC)
189
+ return false;
190
+ const isRunning = this.appletImpressao.testRunningWC();
191
+ return !!isRunning;
192
+ }
193
+ findLocalPrinters() {
194
+ if (!this.appletImpressao)
195
+ return [];
196
+ const localPrinters = this.appletImpressao.getLocalPrinters();
197
+ if (!localPrinters)
198
+ return [];
199
+ return localPrinters.split(",");
200
+ }
201
+ doLocalPrinting(transactionIds) {
202
+ if (!this.appletImpressao)
203
+ return;
204
+ this.appletImpressao.doLocalPrinting(transactionIds);
205
+ }
206
+ getDefaultPrinter() {
207
+ if (!this.appletImpressao)
208
+ return '';
209
+ return this.appletImpressao.getPrintDefault();
210
+ }
211
+ }
212
+
213
+ export { PrintUtils as P };
@@ -1,6 +1,6 @@
1
- import { C as ConfigStorage } from './ConfigStorage-932ab366.js';
1
+ import { C as ConfigStorage } from './ConfigStorage-8d420626.js';
2
2
  import { ObjectUtils } from '@sankhyalabs/core';
3
- import { F as FormConfigFetcher } from './form-config-fetcher-aaaa79a6.js';
3
+ import { F as FormConfigFetcher } from './form-config-fetcher-b69da2f1.js';
4
4
 
5
5
  class SnkFormConfigManager {
6
6
  constructor(configName, resourceID, onConfigChange) {
@@ -1,5 +1,5 @@
1
1
  import { ObjectUtils } from '@sankhyalabs/core';
2
- import { R as ResourceFetcher } from './form-config-fetcher-aaaa79a6.js';
2
+ import { R as ResourceFetcher } from './form-config-fetcher-b69da2f1.js';
3
3
 
4
4
  class AuthFetcher extends ResourceFetcher {
5
5
  getData(resourceID) {
@@ -1,5 +1,5 @@
1
1
  import { DataUnit, StringUtils, DataType, DataUnitStorage, ChangeOperation } from '@sankhyalabs/core';
2
- import { d as dist, D as DataFetcher } from './DataFetcher-7e18aa30.js';
2
+ import { d as dist, D as DataFetcher } from './DataFetcher-e97b3942.js';
3
3
  import { DISTINCT_FILTER_NAME_PREFIX } from '@sankhyalabs/ezui/dist/collection/utils/constants';
4
4
  import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
5
5
 
@@ -1,4 +1,4 @@
1
- import { d as dist, D as DataFetcher } from './DataFetcher-7e18aa30.js';
1
+ import { d as dist, D as DataFetcher } from './DataFetcher-e97b3942.js';
2
2
  import { ObjectUtils } from '@sankhyalabs/core';
3
3
 
4
4
  class ResourceFetcher {