@sankhyalabs/sankhyablocks 10.1.0-dev.23 → 10.1.0-dev.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 (176) hide show
  1. package/dist/cjs/{ConfigStorage-a4e1e518.js → ConfigStorage-d9d24844.js} +2 -2
  2. package/dist/cjs/{DataFetcher-0b6aa084.js → DataFetcher-3a8ea521.js} +2 -2743
  3. package/dist/cjs/{ISave-2c455a77.js → ISave-a66bb65e.js} +1 -1
  4. package/dist/cjs/ImageUtils-5e3f406b.js +142 -0
  5. package/dist/cjs/{SnkFormConfigManager-b8c81493.js → SnkFormConfigManager-c88cf1e9.js} +2 -2
  6. package/dist/cjs/SnkMessageBuilder-d9558dba.js +2809 -0
  7. package/dist/cjs/{SnkMultiSelectionListDataSource-03b58f5a.js → SnkMultiSelectionListDataSource-a891430e.js} +4 -4
  8. package/dist/cjs/{auth-fetcher-7e7796c9.js → auth-fetcher-faa61f64.js} +1 -1
  9. package/dist/cjs/{dataunit-fetcher-8dffbcdf.js → dataunit-fetcher-4320f7ec.js} +3 -2
  10. package/dist/cjs/{form-config-fetcher-5516d68a.js → form-config-fetcher-72cf0e3d.js} +1 -1
  11. package/dist/cjs/index-1894343a.js +10 -2
  12. package/dist/cjs/loader.cjs.js +1 -1
  13. package/dist/cjs/pesquisa-grid_2.cjs.entry.js +5 -4
  14. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  15. package/dist/cjs/{snk-actions-button_9.cjs.entry.js → snk-actions-button_8.cjs.entry.js} +7 -56
  16. package/dist/cjs/snk-application.cjs.entry.js +8 -7
  17. package/dist/cjs/snk-attach.cjs.entry.js +7 -6
  18. package/dist/cjs/snk-crud.cjs.entry.js +7 -6
  19. package/dist/cjs/snk-data-exporter.cjs.entry.js +6 -5
  20. package/dist/cjs/{snk-data-unit-036ce58c.js → snk-data-unit-b54fdf9a.js} +11 -11
  21. package/dist/cjs/snk-data-unit.cjs.entry.js +4 -3
  22. package/dist/cjs/snk-detail-view.cjs.entry.js +15 -11
  23. package/dist/cjs/snk-filter-bar_4.cjs.entry.js +4 -3
  24. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +4 -3
  25. package/dist/cjs/snk-form-view.cjs.entry.js +72 -7
  26. package/dist/cjs/snk-form_2.cjs.entry.js +5 -4
  27. package/dist/cjs/snk-grid.cjs.entry.js +10 -7
  28. package/dist/cjs/{snk-guides-viewer-164c063e.js → snk-guides-viewer-4bbd697f.js} +10 -9
  29. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -7
  30. package/dist/cjs/snk-image-input.cjs.entry.js +148 -0
  31. package/dist/cjs/snk-layout-form-config.cjs.entry.js +72 -0
  32. package/dist/cjs/snk-personalized-filter.cjs.entry.js +4 -3
  33. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -4
  34. package/dist/cjs/snk-simple-crud.cjs.entry.js +8 -7
  35. package/dist/collection/collection-manifest.json +6 -0
  36. package/dist/collection/components/snk-application/snk-application.js +1 -1
  37. package/dist/collection/components/snk-crud/snk-crud.js +2 -2
  38. package/dist/collection/components/snk-crud/subcomponents/GuideBuilder.js +1 -1
  39. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +4 -1
  40. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +93 -8
  41. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +5 -4
  42. package/dist/collection/components/snk-grid/snk-grid.js +3 -1
  43. package/dist/collection/components/snk-image-input/snk-image-input.css +3 -0
  44. package/dist/collection/components/snk-image-input/snk-image-input.js +326 -0
  45. package/dist/collection/components/snk-image-input/utils/ImageUtils.js +133 -0
  46. package/dist/collection/components/snk-layout-form-config/snk-layout-form-config.js +1 -1
  47. package/dist/collection/components/snk-layout-form-config/snk-view-representation/snk-view-representation.js +1 -1
  48. package/dist/collection/lib/message/messageResourceEnUSUtils.js +2 -0
  49. package/dist/collection/lib/message/messageResourceEsESUtils.js +2 -0
  50. package/dist/collection/lib/message/messageResourcePtBRUtils.js +2 -0
  51. package/dist/collection/lib/message/resources/en-us/snk-crud.msg.js +1 -1
  52. package/dist/collection/lib/message/resources/en-us/snk-image-input.msg.js +11 -0
  53. package/dist/collection/lib/message/resources/en-us/snk-layout-form-config.msg.js +10 -2
  54. package/dist/collection/lib/message/resources/es-es/snk-crud.msg.js +1 -1
  55. package/dist/collection/lib/message/resources/es-es/snk-image-input.msg.js +11 -0
  56. package/dist/collection/lib/message/resources/es-es/snk-layout-form-config.msg.js +8 -0
  57. package/dist/collection/lib/message/resources/pt-br/snk-configurator.msg.js +1 -1
  58. package/dist/collection/lib/message/resources/pt-br/snk-crud.msg.js +1 -1
  59. package/dist/collection/lib/message/resources/pt-br/snk-image-input.msg.js +11 -0
  60. package/dist/collection/lib/message/resources/pt-br/snk-layout-form-config.msg.js +10 -2
  61. package/dist/components/DataFetcher.js +3 -2743
  62. package/dist/components/SnkMessageBuilder.js +2807 -0
  63. package/dist/components/dataunit-fetcher.js +2 -1
  64. package/dist/components/index.d.ts +1 -0
  65. package/dist/components/index.js +1 -0
  66. package/dist/components/snk-application2.js +2 -1
  67. package/dist/components/snk-attach2.js +2 -1
  68. package/dist/components/snk-crud.js +70 -64
  69. package/dist/components/snk-data-unit2.js +1 -1
  70. package/dist/components/snk-detail-view2.js +105 -89
  71. package/dist/components/snk-form-view2.js +82 -10
  72. package/dist/components/snk-grid2.js +3 -1
  73. package/dist/components/snk-image-input.d.ts +11 -0
  74. package/dist/components/snk-image-input.js +6 -0
  75. package/dist/components/snk-image-input2.js +302 -0
  76. package/dist/components/snk-layout-form-config2.js +1 -1
  77. package/dist/components/snk-view-representation2.js +1 -1
  78. package/dist/esm/{ConfigStorage-39ac8fef.js → ConfigStorage-d15d2014.js} +2 -2
  79. package/dist/esm/{DataFetcher-0b9da57d.js → DataFetcher-1dd7e8c0.js} +3 -2743
  80. package/dist/esm/{ISave-f1c9269b.js → ISave-498c4831.js} +1 -1
  81. package/dist/esm/ImageUtils-8fc8d905.js +136 -0
  82. package/dist/esm/{SnkFormConfigManager-a87566c8.js → SnkFormConfigManager-86befa68.js} +2 -2
  83. package/dist/esm/SnkMessageBuilder-c0bc4424.js +2807 -0
  84. package/dist/esm/{SnkMultiSelectionListDataSource-01b3744b.js → SnkMultiSelectionListDataSource-14633bf6.js} +4 -4
  85. package/dist/esm/{auth-fetcher-acdc1cb4.js → auth-fetcher-69cbda8d.js} +1 -1
  86. package/dist/esm/{dataunit-fetcher-4c312b43.js → dataunit-fetcher-3d5c4ae4.js} +2 -1
  87. package/dist/esm/{form-config-fetcher-7cda6254.js → form-config-fetcher-fcc7b62f.js} +1 -1
  88. package/dist/esm/index-04f73a26.js +10 -2
  89. package/dist/esm/loader.js +1 -1
  90. package/dist/esm/pesquisa-grid_2.entry.js +5 -4
  91. package/dist/esm/sankhyablocks.js +1 -1
  92. package/dist/esm/{snk-actions-button_9.entry.js → snk-actions-button_8.entry.js} +8 -56
  93. package/dist/esm/snk-application.entry.js +7 -6
  94. package/dist/esm/snk-attach.entry.js +6 -5
  95. package/dist/esm/snk-crud.entry.js +7 -6
  96. package/dist/esm/snk-data-exporter.entry.js +6 -5
  97. package/dist/esm/{snk-data-unit-130021b3.js → snk-data-unit-363c3551.js} +2 -2
  98. package/dist/esm/snk-data-unit.entry.js +4 -3
  99. package/dist/esm/snk-detail-view.entry.js +13 -9
  100. package/dist/esm/snk-filter-bar_4.entry.js +4 -3
  101. package/dist/esm/snk-filter-modal-item.entry.js +4 -3
  102. package/dist/esm/snk-form-view.entry.js +73 -8
  103. package/dist/esm/snk-form_2.entry.js +5 -4
  104. package/dist/esm/snk-grid.entry.js +10 -7
  105. package/dist/esm/{snk-guides-viewer-3fd18298.js → snk-guides-viewer-97708c80.js} +10 -9
  106. package/dist/esm/snk-guides-viewer.entry.js +8 -7
  107. package/dist/esm/snk-image-input.entry.js +144 -0
  108. package/dist/esm/snk-layout-form-config.entry.js +68 -0
  109. package/dist/esm/snk-personalized-filter.entry.js +4 -3
  110. package/dist/esm/snk-pesquisa.entry.js +5 -4
  111. package/dist/esm/snk-simple-crud.entry.js +8 -7
  112. package/dist/sankhyablocks/p-10cad767.entry.js +1 -0
  113. package/dist/sankhyablocks/p-18cc9111.entry.js +1 -0
  114. package/dist/sankhyablocks/{p-5e2dffc1.entry.js → p-1df34264.entry.js} +2 -2
  115. package/dist/sankhyablocks/p-27d6590e.js +1 -0
  116. package/dist/sankhyablocks/p-2a356340.entry.js +1 -0
  117. package/dist/sankhyablocks/{p-998a9d6f.js → p-2ccbbeec.js} +1 -1
  118. package/dist/sankhyablocks/p-30641d55.entry.js +1 -0
  119. package/dist/sankhyablocks/{p-48a5c311.js → p-32ad76cc.js} +2 -2
  120. package/dist/sankhyablocks/p-3b07c117.entry.js +1 -0
  121. package/dist/sankhyablocks/p-43d84207.entry.js +1 -0
  122. package/dist/sankhyablocks/p-48c580b9.entry.js +1 -0
  123. package/dist/sankhyablocks/p-4ff3b494.js +1 -0
  124. package/dist/sankhyablocks/p-685bc841.js +60 -0
  125. package/dist/sankhyablocks/{p-d714b6ca.js → p-7c4f4851.js} +1 -1
  126. package/dist/sankhyablocks/{p-2ac55a5d.js → p-7e9f8fa4.js} +1 -1
  127. package/dist/sankhyablocks/{p-1f310bc6.js → p-9114e869.js} +1 -1
  128. package/dist/sankhyablocks/p-a65559fe.entry.js +1 -0
  129. package/dist/sankhyablocks/{p-7ee6b1bf.js → p-a9839628.js} +1 -1
  130. package/dist/sankhyablocks/p-b2b56f04.js +1 -0
  131. package/dist/sankhyablocks/p-bb81a356.entry.js +1 -0
  132. package/dist/sankhyablocks/p-bdf0077f.js +1 -0
  133. package/dist/sankhyablocks/p-bf65dcc1.entry.js +1 -0
  134. package/dist/sankhyablocks/p-c6a97fda.entry.js +1 -0
  135. package/dist/sankhyablocks/p-c860552e.entry.js +1 -0
  136. package/dist/sankhyablocks/p-c9316c5d.entry.js +1 -0
  137. package/dist/sankhyablocks/p-e0a6818c.js +1 -0
  138. package/dist/sankhyablocks/p-e0e3914e.entry.js +1 -0
  139. package/dist/sankhyablocks/p-e973a5d4.entry.js +1 -0
  140. package/dist/sankhyablocks/p-ebce5394.entry.js +1 -0
  141. package/dist/sankhyablocks/p-fc5e95f4.entry.js +1 -0
  142. package/dist/sankhyablocks/p-fce86770.entry.js +1 -0
  143. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  144. package/dist/types/components/snk-application/snk-application.d.ts +1 -1
  145. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +12 -0
  146. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +1 -0
  147. package/dist/types/components/snk-image-input/snk-image-input.d.ts +56 -0
  148. package/dist/types/components/snk-image-input/utils/ImageUtils.d.ts +15 -0
  149. package/dist/types/components.d.ts +89 -0
  150. package/dist/types/lib/message/resources/en-us/snk-image-input.msg.d.ts +1 -0
  151. package/dist/types/lib/message/resources/es-es/snk-image-input.msg.d.ts +1 -0
  152. package/dist/types/lib/message/resources/pt-br/snk-image-input.msg.d.ts +1 -0
  153. package/package.json +1 -1
  154. package/react/components.d.ts +1 -0
  155. package/react/components.js +1 -0
  156. package/react/components.js.map +1 -1
  157. package/dist/sankhyablocks/p-12f595a6.entry.js +0 -1
  158. package/dist/sankhyablocks/p-18d66638.entry.js +0 -1
  159. package/dist/sankhyablocks/p-2a33d4cf.entry.js +0 -1
  160. package/dist/sankhyablocks/p-2c6be187.entry.js +0 -1
  161. package/dist/sankhyablocks/p-3a443150.entry.js +0 -1
  162. package/dist/sankhyablocks/p-3b6d8d33.entry.js +0 -1
  163. package/dist/sankhyablocks/p-3db72758.entry.js +0 -1
  164. package/dist/sankhyablocks/p-52691b42.js +0 -1
  165. package/dist/sankhyablocks/p-6768f176.js +0 -1
  166. package/dist/sankhyablocks/p-6d322b0a.js +0 -1
  167. package/dist/sankhyablocks/p-877d9614.entry.js +0 -1
  168. package/dist/sankhyablocks/p-94267a30.entry.js +0 -1
  169. package/dist/sankhyablocks/p-9e4555ab.js +0 -60
  170. package/dist/sankhyablocks/p-acd2ba28.entry.js +0 -1
  171. package/dist/sankhyablocks/p-b533edab.entry.js +0 -1
  172. package/dist/sankhyablocks/p-c2d33fc8.entry.js +0 -1
  173. package/dist/sankhyablocks/p-cd40c8cf.entry.js +0 -1
  174. package/dist/sankhyablocks/p-cd412add.entry.js +0 -1
  175. package/dist/sankhyablocks/p-d6dad5e4.entry.js +0 -1
  176. package/dist/sankhyablocks/p-f8c5395a.entry.js +0 -1
@@ -479,7 +479,7 @@ export class SnkGrid {
479
479
  return disabledButtons;
480
480
  }
481
481
  getInvisibleButtons() {
482
- var _a, _b;
482
+ var _a, _b, _c;
483
483
  let invisibleButtons = [];
484
484
  if (!this._dataUnit || this._dataUnit.records.length === 0)
485
485
  invisibleButtons.push(TaskbarElement.DATA_EXPORTER);
@@ -487,6 +487,8 @@ export class SnkGrid {
487
487
  invisibleButtons.push(TaskbarElement.ACTIONS_BUTTON);
488
488
  if (((_b = this._dataState) === null || _b === void 0 ? void 0 : _b.selectionInfo.length) === 1)
489
489
  invisibleButtons.push(TaskbarElement.UPDATE_MULTIPLE);
490
+ if (!((_c = this._dataState) === null || _c === void 0 ? void 0 : _c.selectionInfo.length))
491
+ invisibleButtons.push(TaskbarElement.FORM_MODE);
490
492
  return invisibleButtons;
491
493
  }
492
494
  componentWillRender() {
@@ -0,0 +1,3 @@
1
+ :host {
2
+ display: block;
3
+ }
@@ -0,0 +1,326 @@
1
+ import { ApplicationContext } from '@sankhyalabs/core';
2
+ import { h, Host } from '@stencil/core';
3
+ import { SnkMessageBuilder } from '../../lib/message/SnkMessageBuilder';
4
+ import { base64ToBlob, buildFileKey, downloadImage, getPKs, sessionFileUpload } from './utils/ImageUtils';
5
+ import { Action } from '@sankhyalabs/core';
6
+ export class SnkImageInput {
7
+ constructor() {
8
+ this.dataUnitObserver = async (action) => {
9
+ var _a;
10
+ const actionsMoveSelection = [Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
11
+ if (actionsMoveSelection.includes(action.type)) {
12
+ await this.loadImage();
13
+ return;
14
+ }
15
+ const selection = ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.selection) || [];
16
+ if (action.type === Action.SELECTION_CHANGED && selection.length > 0) {
17
+ await this.loadImage();
18
+ return;
19
+ }
20
+ if (action.type === Action.RECORDS_ADDED) {
21
+ await this.clearImage();
22
+ return;
23
+ }
24
+ };
25
+ this.dataUnit = undefined;
26
+ this.fieldName = undefined;
27
+ this.entityName = undefined;
28
+ this.enabled = true;
29
+ this.acceptType = undefined;
30
+ this.maxSize = undefined;
31
+ this.label = undefined;
32
+ this.imageValue = undefined;
33
+ this.loading = true;
34
+ }
35
+ /**
36
+ * Força o reload da imagem
37
+ */
38
+ async reloadImage(pks) {
39
+ await this.loadImage(pks);
40
+ }
41
+ getMessage(key, params) {
42
+ if (!this.messagesBuilder) {
43
+ this.messagesBuilder = new SnkMessageBuilder();
44
+ }
45
+ return this.messagesBuilder.getMessage(key, params);
46
+ }
47
+ async clearImage() {
48
+ this.imageValue = undefined;
49
+ }
50
+ async handleImageChange(event) {
51
+ const base64 = event.detail;
52
+ if (!base64) {
53
+ await this.clearImage();
54
+ await this.updatedataUnitField(true);
55
+ return;
56
+ }
57
+ const blob = await base64ToBlob(base64);
58
+ if (this.maxSize && blob.size > this.maxSize * 1024) {
59
+ const errorMsg = this.getMessage('snkImageInput.errorImageSize') + this.maxSize + '(KB)';
60
+ this.imageError.emit(errorMsg);
61
+ if (this.application) {
62
+ await this.application.error(this.getMessage('snkImageInput.errorTitle'), errorMsg);
63
+ }
64
+ return;
65
+ }
66
+ this.imageValue = base64;
67
+ await sessionFileUpload(blob, this.entityName, this.fieldName);
68
+ await this.updatedataUnitField();
69
+ }
70
+ async updatedataUnitField(deleted = false) {
71
+ if (!this.dataUnit || !this.dataUnit.getSelectedRecord()) {
72
+ return;
73
+ }
74
+ if (deleted) {
75
+ await this.dataUnit.setFieldValue(this.fieldName, 'deletado');
76
+ }
77
+ else {
78
+ await this.dataUnit.setFieldValue(this.fieldName, `$file.session.key{${buildFileKey(this.entityName, this.fieldName)}}`);
79
+ }
80
+ }
81
+ async handleImageError(event) {
82
+ this.imageError.emit(event.detail);
83
+ if (this.application) {
84
+ await this.application.error(this.getMessage('snkImageInput.errorTitle'), event.detail);
85
+ }
86
+ }
87
+ getPksFromDataUnit() {
88
+ if (!this.dataUnit) {
89
+ return undefined;
90
+ }
91
+ const selectedRecord = this.dataUnit.getSelectedRecord();
92
+ if (!selectedRecord) {
93
+ return undefined;
94
+ }
95
+ const fieldValue = selectedRecord[this.fieldName];
96
+ if (!fieldValue) {
97
+ return undefined;
98
+ }
99
+ try {
100
+ const pk = JSON.parse(fieldValue);
101
+ return pk;
102
+ }
103
+ catch (error) {
104
+ console.error('Error parsing PK from data unit field:', error);
105
+ return undefined;
106
+ }
107
+ }
108
+ async loadImage(pks) {
109
+ var _a;
110
+ this.loading = true;
111
+ if (this.dataUnit && this.entityName) {
112
+ pks = (_a = pks !== null && pks !== void 0 ? pks : this.getPksFromDataUnit()) !== null && _a !== void 0 ? _a : getPKs(this.dataUnit);
113
+ this.imageValue = await downloadImage(pks, this.fieldName, this.entityName);
114
+ }
115
+ this.loading = false;
116
+ }
117
+ async componentWillLoad() {
118
+ this.application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
119
+ if (!this.messagesBuilder) {
120
+ this.messagesBuilder = new SnkMessageBuilder();
121
+ }
122
+ if (this.dataUnit) {
123
+ this.dataUnit.subscribe(this.dataUnitObserver);
124
+ }
125
+ }
126
+ disconnectedCallback() {
127
+ if (this.dataUnit) {
128
+ this.dataUnit.unsubscribe(this.dataUnitObserver);
129
+ }
130
+ }
131
+ async componentDidLoad() {
132
+ await this.loadImage();
133
+ }
134
+ render() {
135
+ return (h(Host, null, h("ez-image-input", { enabled: this.enabled, label: this.label, name: this.fieldName, value: this.imageValue, maxFileSize: this.maxSize ? this.maxSize * 1024 : undefined, accept: this.acceptType || 'image/png,image/jpeg,image/gif', onEzChange: (e) => this.handleImageChange(e), onEzError: (e) => this.handleImageError(e), loading: this.loading })));
136
+ }
137
+ static get is() { return "snk-image-input"; }
138
+ static get encapsulation() { return "shadow"; }
139
+ static get originalStyleUrls() {
140
+ return {
141
+ "$": ["snk-image-input.css"]
142
+ };
143
+ }
144
+ static get styleUrls() {
145
+ return {
146
+ "$": ["snk-image-input.css"]
147
+ };
148
+ }
149
+ static get properties() {
150
+ return {
151
+ "dataUnit": {
152
+ "type": "unknown",
153
+ "mutable": false,
154
+ "complexType": {
155
+ "original": "DataUnit",
156
+ "resolved": "DataUnit",
157
+ "references": {
158
+ "DataUnit": {
159
+ "location": "import",
160
+ "path": "@sankhyalabs/core"
161
+ }
162
+ }
163
+ },
164
+ "required": false,
165
+ "optional": true,
166
+ "docs": {
167
+ "tags": [],
168
+ "text": "DataUnit associado ao componente"
169
+ }
170
+ },
171
+ "fieldName": {
172
+ "type": "string",
173
+ "mutable": false,
174
+ "complexType": {
175
+ "original": "string",
176
+ "resolved": "string",
177
+ "references": {}
178
+ },
179
+ "required": false,
180
+ "optional": false,
181
+ "docs": {
182
+ "tags": [],
183
+ "text": "Nome do campo no DataUnit"
184
+ },
185
+ "attribute": "field-name",
186
+ "reflect": false
187
+ },
188
+ "entityName": {
189
+ "type": "string",
190
+ "mutable": false,
191
+ "complexType": {
192
+ "original": "string",
193
+ "resolved": "string",
194
+ "references": {}
195
+ },
196
+ "required": false,
197
+ "optional": true,
198
+ "docs": {
199
+ "tags": [],
200
+ "text": "Nome da entidade (usado quando n\u00E3o h\u00E1 DataUnit)"
201
+ },
202
+ "attribute": "entity-name",
203
+ "reflect": false
204
+ },
205
+ "enabled": {
206
+ "type": "boolean",
207
+ "mutable": false,
208
+ "complexType": {
209
+ "original": "boolean",
210
+ "resolved": "boolean",
211
+ "references": {}
212
+ },
213
+ "required": false,
214
+ "optional": false,
215
+ "docs": {
216
+ "tags": [],
217
+ "text": "Define se est\u00E1 habilitado"
218
+ },
219
+ "attribute": "enabled",
220
+ "reflect": false,
221
+ "defaultValue": "true"
222
+ },
223
+ "acceptType": {
224
+ "type": "string",
225
+ "mutable": false,
226
+ "complexType": {
227
+ "original": "string",
228
+ "resolved": "string",
229
+ "references": {}
230
+ },
231
+ "required": false,
232
+ "optional": true,
233
+ "docs": {
234
+ "tags": [],
235
+ "text": "Tipos MIME aceitos (separados por v\u00EDrgula)"
236
+ },
237
+ "attribute": "accept-type",
238
+ "reflect": false
239
+ },
240
+ "maxSize": {
241
+ "type": "number",
242
+ "mutable": false,
243
+ "complexType": {
244
+ "original": "number",
245
+ "resolved": "number",
246
+ "references": {}
247
+ },
248
+ "required": false,
249
+ "optional": true,
250
+ "docs": {
251
+ "tags": [],
252
+ "text": "Tamanho m\u00E1ximo do arquivo em KB"
253
+ },
254
+ "attribute": "max-size",
255
+ "reflect": false
256
+ },
257
+ "label": {
258
+ "type": "string",
259
+ "mutable": false,
260
+ "complexType": {
261
+ "original": "string",
262
+ "resolved": "string",
263
+ "references": {}
264
+ },
265
+ "required": false,
266
+ "optional": true,
267
+ "docs": {
268
+ "tags": [],
269
+ "text": "Label do componente"
270
+ },
271
+ "attribute": "label",
272
+ "reflect": false
273
+ }
274
+ };
275
+ }
276
+ static get states() {
277
+ return {
278
+ "imageValue": {},
279
+ "loading": {}
280
+ };
281
+ }
282
+ static get events() {
283
+ return [{
284
+ "method": "imageError",
285
+ "name": "imageError",
286
+ "bubbles": true,
287
+ "cancelable": true,
288
+ "composed": true,
289
+ "docs": {
290
+ "tags": [],
291
+ "text": "Evento disparado quando h\u00E1 erro"
292
+ },
293
+ "complexType": {
294
+ "original": "string",
295
+ "resolved": "string",
296
+ "references": {}
297
+ }
298
+ }];
299
+ }
300
+ static get methods() {
301
+ return {
302
+ "reloadImage": {
303
+ "complexType": {
304
+ "signature": "(pks?: Record<string, any>) => Promise<void>",
305
+ "parameters": [{
306
+ "tags": [],
307
+ "text": ""
308
+ }],
309
+ "references": {
310
+ "Promise": {
311
+ "location": "global"
312
+ },
313
+ "Record": {
314
+ "location": "global"
315
+ }
316
+ },
317
+ "return": "Promise<void>"
318
+ },
319
+ "docs": {
320
+ "text": "For\u00E7a o reload da imagem",
321
+ "tags": []
322
+ }
323
+ }
324
+ };
325
+ }
326
+ }
@@ -0,0 +1,133 @@
1
+ import { ApplicationContext } from "@sankhyalabs/core";
2
+ export async function base64ToBlob(base64) {
3
+ const response = await fetch(base64);
4
+ return await response.blob();
5
+ }
6
+ export function buildFileKey(entityName, fieldName) {
7
+ if (entityName) {
8
+ return `${entityName}_${fieldName}`;
9
+ }
10
+ else {
11
+ return fieldName;
12
+ }
13
+ }
14
+ function hasSpecialCharacters(value) {
15
+ const specialChars = /[ !@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?]/;
16
+ return specialChars.test(value);
17
+ }
18
+ /**
19
+ * Gera a URL base para upload de sessão
20
+ */
21
+ function getSessionUploadBaseUrl(fileKey, context = 'mge') {
22
+ let url = `/${context}/sessionUpload.${context}?sessionkey=${fileKey}`;
23
+ // Verifica se precisa processar caracteres especiais
24
+ if (canProcessSpecialKeys(context) && hasSpecialCharacters(fileKey)) {
25
+ url += `&encodedKey=${btoa(encodeURI(fileKey))}`;
26
+ }
27
+ return url;
28
+ }
29
+ /**
30
+ * Verifica se pode processar chaves especiais
31
+ * Baseado no método canProcessSpecialKeys do sessionfileupload.service.js
32
+ */
33
+ async function canProcessSpecialKeys(context) {
34
+ var _a;
35
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
36
+ if (!application)
37
+ return false;
38
+ const resourceId = await ((_a = application.getResourceID) === null || _a === void 0 ? void 0 : _a.call(application)) || '';
39
+ const adPrefix = "br.com.sankhya.menu.adicional";
40
+ return context === 'mge' && resourceId.startsWith(adPrefix);
41
+ }
42
+ /**
43
+ * Constrói a URL de upload
44
+ * Baseado no método buildUploadURL do sessionfileupload.service.js
45
+ */
46
+ function buildUploadURL(fileKey) {
47
+ let url = getSessionUploadBaseUrl(fileKey);
48
+ url += "&fitem=S&salvar=S&useCache=N";
49
+ return url;
50
+ }
51
+ /**
52
+ * Faz upload de arquivo para a sessão usando XMLHttpRequest
53
+ * Baseado no método uploadSessionFile do sessionfileupload.service.js
54
+ */
55
+ export async function sessionFileUpload(blob, entityName, fieldName, onProgress) {
56
+ const fileKey = buildFileKey(entityName, fieldName);
57
+ const uploadUrl = buildUploadURL(fileKey);
58
+ return new Promise((resolve, reject) => {
59
+ const formData = new FormData();
60
+ formData.append('arquivo', blob);
61
+ const http = new XMLHttpRequest();
62
+ http.addEventListener("load", () => {
63
+ if (http.status >= 200 && http.status < 300) {
64
+ resolve(`/mge/UPLOADING_${fileKey}.dbimage`);
65
+ }
66
+ else {
67
+ reject(new Error(`Upload failed: ${http.statusText}`));
68
+ }
69
+ });
70
+ http.addEventListener("error", () => {
71
+ reject(new Error('Upload error'));
72
+ });
73
+ if (onProgress) {
74
+ http.upload.addEventListener("progress", onProgress);
75
+ }
76
+ http.open("POST", uploadUrl);
77
+ http.send(formData);
78
+ });
79
+ }
80
+ export function getUrlBase() {
81
+ return window.location.origin;
82
+ }
83
+ export function getBaseUrl(pk, entityName, fieldName) {
84
+ if (!pk)
85
+ return undefined;
86
+ const baseUrl = getUrlBase();
87
+ let url = `${baseUrl}/mge/${entityName}@${fieldName}`;
88
+ for (const pkField in pk) {
89
+ url += `@${pkField}=${pk[pkField]}`;
90
+ }
91
+ url += '.dbimage';
92
+ return url;
93
+ }
94
+ export function getPKs(dataUnit) {
95
+ if (!dataUnit) {
96
+ return undefined;
97
+ }
98
+ const pk = {};
99
+ const fields = dataUnit.metadata.fields;
100
+ const selectedRecord = dataUnit.getSelectedRecord();
101
+ fields.forEach((field) => {
102
+ if (field.properties['isPrimaryKey']) {
103
+ pk[field.name] = selectedRecord[field.name];
104
+ }
105
+ });
106
+ return pk;
107
+ }
108
+ export async function imageBlobToBase64(blob) {
109
+ return new Promise((resolve, reject) => {
110
+ const reader = new FileReader();
111
+ reader.onloadend = () => {
112
+ resolve(reader.result);
113
+ };
114
+ reader.onerror = reject;
115
+ reader.readAsDataURL(blob);
116
+ });
117
+ }
118
+ export async function downloadImage(pks, fieldName, entityName) {
119
+ const uploadUrl = getBaseUrl(pks, entityName, fieldName);
120
+ if (!uploadUrl) {
121
+ return;
122
+ }
123
+ try {
124
+ const response = await fetch(uploadUrl);
125
+ if (response.ok) {
126
+ const blob = await response.blob();
127
+ return await imageBlobToBase64(blob);
128
+ }
129
+ }
130
+ catch (error) {
131
+ console.error('Error downloading image:', error);
132
+ }
133
+ }
@@ -43,7 +43,7 @@ export class SnkLayoutFormConfig {
43
43
  return (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, params);
44
44
  }
45
45
  render() {
46
- return (h("div", { class: "ez-flex ez-flex--column" }, h("div", { class: "ez-margin-bottom--small" }, h("ez-check", { label: this.getMessage('snkLayoutFormConfig.cascadeLayout.label'), class: "ez-margin-bottom--small", onEzChange: () => this.toggleLayout(FormLayout.CASCADE), value: this.layoutType === FormLayout.CASCADE }), h("snk-view-representation", { mode: FormLayout.CASCADE }), h("label", { class: "ez-label ez-margin--small ez-flex ez-text--medium" }, this.getMessage('snkLayoutFormConfig.cascadeLayout.description'))), h("div", null, h("ez-check", { label: this.getMessage('snkLayoutFormConfig.sideBySideLayout.label'), class: "ez-margin-bottom--small", onEzChange: () => this.toggleLayout(FormLayout.SIDE_BY_SIDE), value: this.layoutType === FormLayout.SIDE_BY_SIDE }), h("snk-view-representation", { mode: FormLayout.SIDE_BY_SIDE }), h("label", { class: "ez-label ez-margin--small ez-flex ez-text--medium" }, this.getMessage('snkLayoutFormConfig.sideBySideLayout.description')))));
46
+ return (h("div", { class: "ez-flex ez-flex--column" }, h("div", { class: "ez-margin-bottom--small" }, h("ez-check", { label: this.getMessage('snkLayoutFormConfig.cascadeLayout.label'), class: "ez-margin-bottom--small", onEzChange: () => this.toggleLayout(FormLayout.CASCADE), value: this.layoutType === FormLayout.CASCADE }), h("snk-view-representation", { mode: FormLayout.CASCADE }), h("label", { class: "ez-label ez-margin--small ez-flex ez-text--medium" }, this.getMessage('snkLayoutFormConfig.cascadeLayout.description'))), h("div", { class: "ez-margin-bottom--small" }, h("ez-check", { label: this.getMessage('snkLayoutFormConfig.classicCascadeLayout.label'), class: "ez-margin-bottom--small", onEzChange: () => this.toggleLayout(FormLayout.CLASSIC_CASCADE), value: this.layoutType === FormLayout.CLASSIC_CASCADE }), h("snk-view-representation", { mode: FormLayout.CLASSIC_CASCADE }), h("label", { class: "ez-label ez-margin--small ez-flex ez-text--medium" }, this.getMessage('snkLayoutFormConfig.classicCascadeLayout.description'))), h("div", { class: "ez-margin-bottom--small" }, h("ez-check", { label: this.getMessage('snkLayoutFormConfig.sideBySideLayout.label'), class: "ez-margin-bottom--small", onEzChange: () => this.toggleLayout(FormLayout.SIDE_BY_SIDE), value: this.layoutType === FormLayout.SIDE_BY_SIDE }), h("snk-view-representation", { mode: FormLayout.SIDE_BY_SIDE }), h("label", { class: "ez-label ez-margin--small ez-flex ez-text--medium" }, this.getMessage('snkLayoutFormConfig.sideBySideLayout.description'))), h("div", null, h("ez-check", { label: this.getMessage('snkLayoutFormConfig.classicSideBySideLayout.label'), class: "ez-margin-bottom--small", onEzChange: () => this.toggleLayout(FormLayout.CLASSIC_SIDE_BY_SIDE), value: this.layoutType === FormLayout.CLASSIC_SIDE_BY_SIDE }), h("snk-view-representation", { mode: FormLayout.CLASSIC_SIDE_BY_SIDE }), h("label", { class: "ez-label ez-margin--small ez-flex ez-text--medium" }, this.getMessage('snkLayoutFormConfig.classicSideBySideLayout.description')))));
47
47
  }
48
48
  static get is() { return "snk-layout-form-config"; }
49
49
  static get encapsulation() { return "scoped"; }
@@ -11,7 +11,7 @@ export class SnkViewRepresentation {
11
11
  return (h("div", { class: "svg-container__inline" }, [...Array(2)].map(() => this.renderCascadeLayout())));
12
12
  }
13
13
  render() {
14
- return (h("div", { class: "svg-container ez-margin-left--small" }, h("div", { class: "svg-container__background" }, h("div", { class: "svg-container__header" }, h("div", { class: "svg-container__circle svg-container__circle--red" }), h("div", { class: "svg-container__circle svg-container__circle--yellow" }), h("div", { class: "svg-container__circle svg-container__circle--green" })), this.mode === FormLayout.CASCADE
14
+ return (h("div", { class: "svg-container ez-margin-left--small" }, h("div", { class: "svg-container__background" }, h("div", { class: "svg-container__header" }, h("div", { class: "svg-container__circle svg-container__circle--red" }), h("div", { class: "svg-container__circle svg-container__circle--yellow" }), h("div", { class: "svg-container__circle svg-container__circle--green" })), (this.mode === FormLayout.CASCADE || this.mode === FormLayout.CLASSIC_CASCADE)
15
15
  ? this.renderCascadeLayout()
16
16
  : this.renderSideBySideLayout())));
17
17
  }
@@ -26,6 +26,7 @@ import { snkSimpleBarMessages } from './resources/en-us/snk-simple-bar.msg';
26
26
  import { snkSimpleCrudMessages } from "./resources/en-us/snk-simple-crud.msg";
27
27
  import { snkSimpleFormConfigMessages } from "./resources/en-us/snk-simple-form-config.msg";
28
28
  import { snkTaskbarMessages } from "./resources/en-us/snk-taskbar.msg";
29
+ import { snkImageInputMessages } from "./resources/en-us/snk-image-input.msg";
29
30
 
30
31
  import {
31
32
  snkGridConfigMessages,
@@ -61,6 +62,7 @@ const messageResourcePtBR = {
61
62
  snkFilterFieldSearch: snkFilterFieldSearchMessages,
62
63
  snkSimpleBar: snkSimpleBarMessages,
63
64
  snkAttach: snkAttachMessages,
65
+ snkImageInput: snkImageInputMessages,
64
66
  snkPersonalizedFilter: snkPersonalizedFilterMessages,
65
67
  snkEntityList: snkEntityListMessages,
66
68
  snkActionsButton: snkActionsButtonMessages,
@@ -26,6 +26,7 @@ import { snkSimpleBarMessages } from './resources/es-es/snk-simple-bar.msg';
26
26
  import { snkSimpleCrudMessages } from "./resources/es-es/snk-simple-crud.msg";
27
27
  import { snkSimpleFormConfigMessages } from "./resources/es-es/snk-simple-form-config.msg";
28
28
  import { snkTaskbarMessages } from "./resources/es-es/snk-taskbar.msg";
29
+ import { snkImageInputMessages } from "./resources/es-es/snk-image-input.msg";
29
30
 
30
31
  import {
31
32
  snkGridConfigMessages,
@@ -61,6 +62,7 @@ const messageResourcePtBR = {
61
62
  snkFilterFieldSearch: snkFilterFieldSearchMessages,
62
63
  snkSimpleBar: snkSimpleBarMessages,
63
64
  snkAttach: snkAttachMessages,
65
+ snkImageInput: snkImageInputMessages,
64
66
  snkPersonalizedFilter: snkPersonalizedFilterMessages,
65
67
  snkEntityList: snkEntityListMessages,
66
68
  snkActionsButton: snkActionsButtonMessages,
@@ -26,6 +26,7 @@ import { snkSimpleBarMessages } from './resources/pt-br/snk-simple-bar.msg';
26
26
  import { snkSimpleCrudMessages } from "./resources/pt-br/snk-simple-crud.msg";
27
27
  import { snkSimpleFormConfigMessages } from "./resources/pt-br/snk-simple-form-config.msg";
28
28
  import { snkTaskbarMessages } from "./resources/pt-br/snk-taskbar.msg";
29
+ import { snkImageInputMessages } from "./resources/pt-br/snk-image-input.msg";
29
30
 
30
31
  import {
31
32
  snkGridConfigMessages,
@@ -61,6 +62,7 @@ const messageResourcePtBR = {
61
62
  snkFilterFieldSearch: snkFilterFieldSearchMessages,
62
63
  snkSimpleBar: snkSimpleBarMessages,
63
64
  snkAttach: snkAttachMessages,
65
+ snkImageInput: snkImageInputMessages,
64
66
  snkPersonalizedFilter: snkPersonalizedFilterMessages,
65
67
  snkEntityList: snkEntityListMessages,
66
68
  snkActionsButton: snkActionsButtonMessages,
@@ -4,8 +4,8 @@ export const snkCrudMessages = {
4
4
  insert: "Register record",
5
5
  update: "Update record",
6
6
  clean: "{{ENTITY_NAME}}",
7
- newRecord: "New Record"
8
7
  },
8
+ newRecord: "New Record",
9
9
  findColumn: "Search fields (Ctrl+F)",
10
10
  goBackTitle: "Back",
11
11
  guide: {
@@ -0,0 +1,11 @@
1
+ export const snkImageInputMessages = {
2
+ msgTipoImage: "Invalid file type. Accepted types: ",
3
+ errorImageSize: "File size exceeds the maximum allowed: ",
4
+ defaultLabel: "Click or drag to upload an image",
5
+ removeImage: "Remove image",
6
+ imageAlt: "Preview image",
7
+ imagePreview: "Image Preview",
8
+ uploadError: "Error uploading file",
9
+ downloadError: "Error downloading image",
10
+ errorTitle: "Error"
11
+ };
@@ -1,10 +1,18 @@
1
1
  export const snkLayoutFormConfigMessages = {
2
2
  cascadeLayout: {
3
- label: "Cascade layout",
3
+ label: "Cascade compact layout",
4
4
  description: "All fields will be organized in a single column."
5
5
  },
6
+ classicCascadeLayout: {
7
+ label: "Classic cascade layout",
8
+ description: "All fields will be organized in a single column with classic style."
9
+ },
6
10
  sideBySideLayout: {
7
- label: "Side by side layout",
11
+ label: "Side by side compact layout",
8
12
  description: "All fields will be arranged side by side, automatically adjusting to the screen width."
13
+ },
14
+ classicSideBySideLayout: {
15
+ label: "Classic side by side layout",
16
+ description: "All fields will be arranged side by side with classic style, automatically adjusting to the screen width."
9
17
  }
10
18
  };
@@ -4,8 +4,8 @@ export const snkCrudMessages = {
4
4
  insert: "Registrar nuevo",
5
5
  update: "Modificar registro",
6
6
  clean: "{{ENTITY_NAME}}",
7
- newRecord: "Nuevo Registro"
8
7
  },
8
+ newRecord: "Nuevo Registro",
9
9
  findColumn: "Buscar campos (Ctrl+F)",
10
10
  goBackTitle: "Volver",
11
11
  guide: {
@@ -0,0 +1,11 @@
1
+ export const snkImageInputMessages = {
2
+ msgTipoImage: "Tipo de archivo inválido. Tipos aceptados: ",
3
+ errorImageSize: "El tamaño del archivo excede el máximo permitido: ",
4
+ defaultLabel: "Haga clic o arrastre para cargar una imagen",
5
+ removeImage: "Eliminar imagen",
6
+ imageAlt: "Vista previa de la imagen",
7
+ imagePreview: "Vista previa de la imagen",
8
+ uploadError: "Error al cargar el archivo",
9
+ downloadError: "Error al descargar la imagen",
10
+ errorTitle: "Error"
11
+ };
@@ -3,8 +3,16 @@ export const snkLayoutFormConfigMessages = {
3
3
  label: "Diseño en cascada",
4
4
  description: "Todos los campos se organizarán en una única columna."
5
5
  },
6
+ classicCascadeLayout: {
7
+ label: "Diseño clásico en cascada",
8
+ description: "Todos los campos se organizarán en una única columna con estilo clásico."
9
+ },
6
10
  sideBySideLayout: {
7
11
  label: "Diseño lado a lado",
8
12
  description: "Todos los campos se dispondrán lado a lado, ajustándose automáticamente al ancho de la pantalla."
13
+ },
14
+ classicSideBySideLayout: {
15
+ label: "Diseño clásico lado a lado",
16
+ description: "Todos los campos se dispondrán lado a lado con estilo clásico, ajustándose automáticamente al ancho de la pantalla."
9
17
  }
10
18
  };
@@ -9,6 +9,6 @@ export const snkConfiguratorMessages = {
9
9
  labelNumberingConfig: "Configuração de numeração",
10
10
  buttons: {
11
11
  cancel: "Cancelar",
12
- save: "Guardar"
12
+ save: "Salvar"
13
13
  }
14
14
  };
@@ -4,8 +4,8 @@ export const snkCrudMessages = {
4
4
  insert: "Cadastrar registro",
5
5
  update: "Alterar registro",
6
6
  clean: "{{ENTITY_NAME}}",
7
- newRecord: "Novo Registro"
8
7
  },
8
+ newRecord: "Novo Registro",
9
9
  findColumn: "Buscar campos (Ctrl+F)",
10
10
  goBackTitle: "Voltar",
11
11
  guide: {
@@ -0,0 +1,11 @@
1
+ export const snkImageInputMessages = {
2
+ msgTipoImage: "Tipo de arquivo inválido. Tipos aceitos: ",
3
+ errorImageSize: "O tamanho do arquivo excede o máximo permitido: ",
4
+ defaultLabel: "Clique ou arraste para fazer upload de uma imagem",
5
+ removeImage: "Remover imagem",
6
+ imageAlt: "Visualização da imagem",
7
+ imagePreview: "Visualização da Imagem",
8
+ uploadError: "Erro ao fazer upload do arquivo",
9
+ downloadError: "Erro ao baixar imagem",
10
+ errorTitle: "Erro"
11
+ };