@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
@@ -1,11 +1,24 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
2
+ import { Action, UserInterface, ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { DataBinder } from '@sankhyalabs/ezui/dist/collection/utils/form';
4
4
  import { focusOnFieldSerch, SEARCH_FIELD_FULL_WIDTH, FormLayout } from '@sankhyalabs/ezui/dist/collection/utils';
5
- import { d as defineCustomElement$1 } from './snk-form-summary2.js';
5
+ import { g as getPKs, d as defineCustomElement$1 } from './snk-image-input2.js';
6
+ import { d as defineCustomElement$2 } from './snk-form-summary2.js';
6
7
 
7
8
  const snkFormViewCss = ".sc-snk-form-view-h{display:flex;width:100%;--ez-form-card-summary-field-content-weight:700}.level-path.sc-snk-form-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.summary-wrapper.sc-snk-form-view{display:flex;overflow:hidden}.summary-header.sc-snk-form-view{border-bottom:1px solid var(--color--strokes);margin-bottom:var(--space--medium);padding-bottom:var(--space--medium)}.summary-container.sc-snk-form-view{display:flex;flex-direction:column}.summary-container.sc-snk-form-view{padding-right:calc(var(--space--extra-large) / 1.5)}.summary-field.sc-snk-form-view{min-width:30px;max-width:200px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.summary-field__title.sc-snk-form-view{color:var(--text--primary, #626e82);font-size:var(--title--small);white-space:nowrap;font-weight:var(--text-weight--medium)}.summary-field__content.sc-snk-form-view{color:var(--title--primary, #2b3a54);font-size:var(--text--large);font-weight:var(--ez-form-card-summary-field-content-weight)}";
8
9
 
10
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s)
13
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
9
22
  const SnkFormView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
10
23
  constructor() {
11
24
  super();
@@ -15,7 +28,23 @@ const SnkFormView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
15
28
  this.formItemsReady = createEvent(this, "formItemsReady", 7);
16
29
  this._customEditors = new Map();
17
30
  this._fieldProps = new Map();
31
+ this.dataUnitObserver = async (action) => {
32
+ if (action.type === Action.RECORDS_COPIED) {
33
+ const sourcePK = this.buildSourceRecordPK(action);
34
+ this.getImageField().forEach(async (field) => {
35
+ this.dataUnit.setFieldValue(field.name, JSON.stringify(sourcePK));
36
+ });
37
+ }
38
+ };
39
+ this.customUiBuilders = new Map([
40
+ [UserInterface.IMAGE, (_a) => {
41
+ var { name } = _a, props = __rest(_a, ["name"]);
42
+ return h("snk-image-input", Object.assign({ dataUnit: this.dataUnit, maxSize: Infinity, fieldName: name, entityName: this.entityPath }, props));
43
+ }
44
+ ]
45
+ ]);
18
46
  this._singleColumn = false;
47
+ this._currentFormLayout = undefined;
19
48
  this.levelPath = undefined;
20
49
  this.fieldSearch = undefined;
21
50
  this.label = undefined;
@@ -32,6 +61,7 @@ const SnkFormView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
32
61
  this.fieldToFocus = undefined;
33
62
  this.customEditors = undefined;
34
63
  this.fieldsProps = undefined;
64
+ this.entityPath = undefined;
35
65
  }
36
66
  async showUp() {
37
67
  if (this._formView) {
@@ -81,6 +111,11 @@ const SnkFormView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
81
111
  }
82
112
  }
83
113
  }
114
+ async observeDataUnit(newValue, oldValue) {
115
+ if (newValue !== oldValue && newValue) {
116
+ newValue.subscribe(this.dataUnitObserver);
117
+ }
118
+ }
84
119
  changeFix() {
85
120
  this.fixed = !this.fixed;
86
121
  this.emitEvent("fixed");
@@ -138,28 +173,41 @@ const SnkFormView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
138
173
  if (this._dataBinder != undefined) {
139
174
  this._dataBinder.onDisconnectedCallback();
140
175
  }
176
+ if (this.dataUnit) {
177
+ this.dataUnit.unsubscribe(this.dataUnitObserver);
178
+ }
179
+ }
180
+ async componentWillLoad() {
181
+ await this.initLayoutFormConfig();
182
+ }
183
+ async componentWillLoad() {
184
+ await this.initLayoutFormConfig();
141
185
  }
142
186
  componentDidLoad() {
143
187
  this.observePropsCustomEditor(this.customEditors);
144
188
  this.observeFieldsProps(this.fieldsProps);
145
- this.initLayoutFormConfig();
146
189
  }
147
190
  async initLayoutFormConfig() {
148
- const _application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
149
- const layoutFormConfig = await (_application === null || _application === void 0 ? void 0 : _application.getLayoutFormConfig());
191
+ var _a;
192
+ if (!this._application) {
193
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
194
+ }
195
+ const layoutFormConfig = await ((_a = this._application) === null || _a === void 0 ? void 0 : _a.getLayoutFormConfig());
150
196
  if (layoutFormConfig) {
151
197
  this.setSingleColumn(layoutFormConfig);
152
198
  this.registerNotifyListeners(layoutFormConfig);
153
199
  }
154
200
  }
155
201
  setSingleColumn(layoutFormConfig) {
156
- this._singleColumn = (layoutFormConfig === null || layoutFormConfig === void 0 ? void 0 : layoutFormConfig.config) === FormLayout.CASCADE;
202
+ this._singleColumn = (layoutFormConfig === null || layoutFormConfig === void 0 ? void 0 : layoutFormConfig.config) === FormLayout.CASCADE || (layoutFormConfig === null || layoutFormConfig === void 0 ? void 0 : layoutFormConfig.config) === FormLayout.CLASSIC_CASCADE;
203
+ this._currentFormLayout = layoutFormConfig === null || layoutFormConfig === void 0 ? void 0 : layoutFormConfig.config;
157
204
  }
158
205
  registerNotifyListeners(layoutFormConfig) {
159
206
  if (!layoutFormConfig)
160
207
  return;
161
208
  layoutFormConfig.onConfigChange((config) => {
162
- this._singleColumn = (config === FormLayout.CASCADE);
209
+ this._singleColumn = (config === FormLayout.CASCADE || config === FormLayout.CLASSIC_CASCADE);
210
+ this._currentFormLayout = config;
163
211
  });
164
212
  }
165
213
  componentDidRender() {
@@ -196,6 +244,22 @@ const SnkFormView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
196
244
  });
197
245
  }
198
246
  }
247
+ buildSourceRecordPK(action) {
248
+ var _a, _b;
249
+ const currentRecord = ((_a = action.payload) === null || _a === void 0 ? void 0 : _a[0]) || {};
250
+ const sourceBase64 = currentRecord["__record__source__id__"];
251
+ const sourceRecord = JSON.parse(atob(sourceBase64 || ''));
252
+ delete sourceRecord["__DATA_UNIT_NAME__"];
253
+ const pkFields = Object.keys(getPKs(this.dataUnit));
254
+ const filteredSourceRecord = {};
255
+ for (const pkField of pkFields) {
256
+ filteredSourceRecord[pkField] = (_b = sourceRecord[pkField]) === null || _b === void 0 ? void 0 : _b.value;
257
+ }
258
+ return filteredSourceRecord;
259
+ }
260
+ getImageField() {
261
+ return this.dataUnit.metadata.fields.filter(field => field.userInterface === UserInterface.IMAGE);
262
+ }
199
263
  render() {
200
264
  return (h(Host, { class: "ez-box__container" }, h("div", { class: "summary-header ez-flex ez-size-width--full", ref: ref => this._headerContainer = ref }, h("div", { class: "ez-flex ez-text ez-title--primary ez-text--bold ez-flex--justify-start ez-flex--align-items-center ez-col--sd-9" }, this.levelPath ? h("span", { class: "level-path" }, this.levelPath + " /") : undefined, this.label), h("div", { class: "ez-flex ez-flex--justify-end ez-col--sd-3" }, this.canFix &&
201
265
  h("ez-button", { class: "ez-padding-left--medium", mode: "icon", size: "small", iconName: this.fixed ? "un-pin" : "push-pin", "data-element-id": ElementIDUtils.getInternalIDInfo("toggleFixed_ezFormCard"), onClick: () => this.changeFix(), title: this.fixed ? "Desafixar" : "Fixar" }), this.canExpand &&
@@ -203,11 +267,12 @@ const SnkFormView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
203
267
  ?
204
268
  h("snk-form-summary", { summary: this.getCardSummary() })
205
269
  :
206
- h("ez-form-view", { ref: ref => this._formView = ref, fields: this.fields, onEzContentReady: evt => this.bindFields(evt.detail), onFormItemsReady: (event) => this.handleFormItemsReady(event), singleColumn: this._singleColumn }), this.fieldSearch && h("ez-popover", { ref: elem => (this._ezPopoverFieldColumn = elem), overlayType: "none" }, this.fieldSearch)));
270
+ h("ez-form-view", { ref: ref => this._formView = ref, fields: this.fields, onEzContentReady: evt => this.bindFields(evt.detail), onFormItemsReady: (event) => this.handleFormItemsReady(event), singleColumn: this._singleColumn, customUiBuilders: this.customUiBuilders, formLayout: this._currentFormLayout }), this.fieldSearch && h("ez-popover", { ref: elem => (this._ezPopoverFieldColumn = elem), overlayType: "none" }, this.fieldSearch)));
207
271
  }
208
272
  static get watchers() { return {
209
273
  "customEditors": ["observePropsCustomEditor"],
210
- "fieldsProps": ["observeFieldsProps"]
274
+ "fieldsProps": ["observeFieldsProps"],
275
+ "dataUnit": ["observeDataUnit"]
211
276
  }; }
212
277
  static get style() { return snkFormViewCss; }
213
278
  }, [6, "snk-form-view", {
@@ -227,7 +292,9 @@ const SnkFormView = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
227
292
  "fieldToFocus": [1, "field-to-focus"],
228
293
  "customEditors": [16],
229
294
  "fieldsProps": [16],
295
+ "entityPath": [1, "entity-path"],
230
296
  "_singleColumn": [32],
297
+ "_currentFormLayout": [32],
231
298
  "showUp": [64],
232
299
  "addCustomEditor": [64],
233
300
  "setFieldProp": [64],
@@ -237,7 +304,7 @@ function defineCustomElement() {
237
304
  if (typeof customElements === "undefined") {
238
305
  return;
239
306
  }
240
- const components = ["snk-form-view", "snk-form-summary"];
307
+ const components = ["snk-form-view", "snk-form-summary", "snk-image-input"];
241
308
  components.forEach(tagName => { switch (tagName) {
242
309
  case "snk-form-view":
243
310
  if (!customElements.get(tagName)) {
@@ -245,6 +312,11 @@ function defineCustomElement() {
245
312
  }
246
313
  break;
247
314
  case "snk-form-summary":
315
+ if (!customElements.get(tagName)) {
316
+ defineCustomElement$2();
317
+ }
318
+ break;
319
+ case "snk-image-input":
248
320
  if (!customElements.get(tagName)) {
249
321
  defineCustomElement$1();
250
322
  }
@@ -563,7 +563,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
563
563
  return disabledButtons;
564
564
  }
565
565
  getInvisibleButtons() {
566
- var _a, _b;
566
+ var _a, _b, _c;
567
567
  let invisibleButtons = [];
568
568
  if (!this._dataUnit || this._dataUnit.records.length === 0)
569
569
  invisibleButtons.push(TaskbarElement.DATA_EXPORTER);
@@ -571,6 +571,8 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
571
571
  invisibleButtons.push(TaskbarElement.ACTIONS_BUTTON);
572
572
  if (((_b = this._dataState) === null || _b === void 0 ? void 0 : _b.selectionInfo.length) === 1)
573
573
  invisibleButtons.push(TaskbarElement.UPDATE_MULTIPLE);
574
+ if (!((_c = this._dataState) === null || _c === void 0 ? void 0 : _c.selectionInfo.length))
575
+ invisibleButtons.push(TaskbarElement.FORM_MODE);
574
576
  return invisibleButtons;
575
577
  }
576
578
  componentWillRender() {
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SnkImageInput extends Components.SnkImageInput, HTMLElement {}
4
+ export const SnkImageInput: {
5
+ prototype: SnkImageInput;
6
+ new (): SnkImageInput;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { S as SnkImageInput$1, d as defineCustomElement$1 } from './snk-image-input2.js';
2
+
3
+ const SnkImageInput = SnkImageInput$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { SnkImageInput, defineCustomElement };
@@ -0,0 +1,302 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { ApplicationContext, Action } from '@sankhyalabs/core';
3
+ import { S as SnkMessageBuilder } from './SnkMessageBuilder.js';
4
+
5
+ async function base64ToBlob(base64) {
6
+ const response = await fetch(base64);
7
+ return await response.blob();
8
+ }
9
+ function buildFileKey(entityName, fieldName) {
10
+ if (entityName) {
11
+ return `${entityName}_${fieldName}`;
12
+ }
13
+ else {
14
+ return fieldName;
15
+ }
16
+ }
17
+ function hasSpecialCharacters(value) {
18
+ const specialChars = /[ !@#$%^&*()+\-=\[\]{};':"\\|,.<>\/?]/;
19
+ return specialChars.test(value);
20
+ }
21
+ /**
22
+ * Gera a URL base para upload de sessão
23
+ */
24
+ function getSessionUploadBaseUrl(fileKey, context = 'mge') {
25
+ let url = `/${context}/sessionUpload.${context}?sessionkey=${fileKey}`;
26
+ // Verifica se precisa processar caracteres especiais
27
+ if (canProcessSpecialKeys(context) && hasSpecialCharacters(fileKey)) {
28
+ url += `&encodedKey=${btoa(encodeURI(fileKey))}`;
29
+ }
30
+ return url;
31
+ }
32
+ /**
33
+ * Verifica se pode processar chaves especiais
34
+ * Baseado no método canProcessSpecialKeys do sessionfileupload.service.js
35
+ */
36
+ async function canProcessSpecialKeys(context) {
37
+ var _a;
38
+ const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
39
+ if (!application)
40
+ return false;
41
+ const resourceId = await ((_a = application.getResourceID) === null || _a === void 0 ? void 0 : _a.call(application)) || '';
42
+ const adPrefix = "br.com.sankhya.menu.adicional";
43
+ return context === 'mge' && resourceId.startsWith(adPrefix);
44
+ }
45
+ /**
46
+ * Constrói a URL de upload
47
+ * Baseado no método buildUploadURL do sessionfileupload.service.js
48
+ */
49
+ function buildUploadURL(fileKey) {
50
+ let url = getSessionUploadBaseUrl(fileKey);
51
+ url += "&fitem=S&salvar=S&useCache=N";
52
+ return url;
53
+ }
54
+ /**
55
+ * Faz upload de arquivo para a sessão usando XMLHttpRequest
56
+ * Baseado no método uploadSessionFile do sessionfileupload.service.js
57
+ */
58
+ async function sessionFileUpload(blob, entityName, fieldName, onProgress) {
59
+ const fileKey = buildFileKey(entityName, fieldName);
60
+ const uploadUrl = buildUploadURL(fileKey);
61
+ return new Promise((resolve, reject) => {
62
+ const formData = new FormData();
63
+ formData.append('arquivo', blob);
64
+ const http = new XMLHttpRequest();
65
+ http.addEventListener("load", () => {
66
+ if (http.status >= 200 && http.status < 300) {
67
+ resolve(`/mge/UPLOADING_${fileKey}.dbimage`);
68
+ }
69
+ else {
70
+ reject(new Error(`Upload failed: ${http.statusText}`));
71
+ }
72
+ });
73
+ http.addEventListener("error", () => {
74
+ reject(new Error('Upload error'));
75
+ });
76
+ if (onProgress) {
77
+ http.upload.addEventListener("progress", onProgress);
78
+ }
79
+ http.open("POST", uploadUrl);
80
+ http.send(formData);
81
+ });
82
+ }
83
+ function getUrlBase() {
84
+ return window.location.origin;
85
+ }
86
+ function getBaseUrl(pk, entityName, fieldName) {
87
+ if (!pk)
88
+ return undefined;
89
+ const baseUrl = getUrlBase();
90
+ let url = `${baseUrl}/mge/${entityName}@${fieldName}`;
91
+ for (const pkField in pk) {
92
+ url += `@${pkField}=${pk[pkField]}`;
93
+ }
94
+ url += '.dbimage';
95
+ return url;
96
+ }
97
+ function getPKs(dataUnit) {
98
+ if (!dataUnit) {
99
+ return undefined;
100
+ }
101
+ const pk = {};
102
+ const fields = dataUnit.metadata.fields;
103
+ const selectedRecord = dataUnit.getSelectedRecord();
104
+ fields.forEach((field) => {
105
+ if (field.properties['isPrimaryKey']) {
106
+ pk[field.name] = selectedRecord[field.name];
107
+ }
108
+ });
109
+ return pk;
110
+ }
111
+ async function imageBlobToBase64(blob) {
112
+ return new Promise((resolve, reject) => {
113
+ const reader = new FileReader();
114
+ reader.onloadend = () => {
115
+ resolve(reader.result);
116
+ };
117
+ reader.onerror = reject;
118
+ reader.readAsDataURL(blob);
119
+ });
120
+ }
121
+ async function downloadImage(pks, fieldName, entityName) {
122
+ const uploadUrl = getBaseUrl(pks, entityName, fieldName);
123
+ if (!uploadUrl) {
124
+ return;
125
+ }
126
+ try {
127
+ const response = await fetch(uploadUrl);
128
+ if (response.ok) {
129
+ const blob = await response.blob();
130
+ return await imageBlobToBase64(blob);
131
+ }
132
+ }
133
+ catch (error) {
134
+ console.error('Error downloading image:', error);
135
+ }
136
+ }
137
+
138
+ const snkImageInputCss = ":host{display:block}";
139
+
140
+ const SnkImageInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
141
+ constructor() {
142
+ super();
143
+ this.__registerHost();
144
+ this.__attachShadow();
145
+ this.imageError = createEvent(this, "imageError", 7);
146
+ this.dataUnitObserver = async (action) => {
147
+ var _a;
148
+ const actionsMoveSelection = [Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
149
+ if (actionsMoveSelection.includes(action.type)) {
150
+ await this.loadImage();
151
+ return;
152
+ }
153
+ const selection = ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.selection) || [];
154
+ if (action.type === Action.SELECTION_CHANGED && selection.length > 0) {
155
+ await this.loadImage();
156
+ return;
157
+ }
158
+ if (action.type === Action.RECORDS_ADDED) {
159
+ await this.clearImage();
160
+ return;
161
+ }
162
+ };
163
+ this.dataUnit = undefined;
164
+ this.fieldName = undefined;
165
+ this.entityName = undefined;
166
+ this.enabled = true;
167
+ this.acceptType = undefined;
168
+ this.maxSize = undefined;
169
+ this.label = undefined;
170
+ this.imageValue = undefined;
171
+ this.loading = true;
172
+ }
173
+ /**
174
+ * Força o reload da imagem
175
+ */
176
+ async reloadImage(pks) {
177
+ await this.loadImage(pks);
178
+ }
179
+ getMessage(key, params) {
180
+ if (!this.messagesBuilder) {
181
+ this.messagesBuilder = new SnkMessageBuilder();
182
+ }
183
+ return this.messagesBuilder.getMessage(key, params);
184
+ }
185
+ async clearImage() {
186
+ this.imageValue = undefined;
187
+ }
188
+ async handleImageChange(event) {
189
+ const base64 = event.detail;
190
+ if (!base64) {
191
+ await this.clearImage();
192
+ await this.updatedataUnitField(true);
193
+ return;
194
+ }
195
+ const blob = await base64ToBlob(base64);
196
+ if (this.maxSize && blob.size > this.maxSize * 1024) {
197
+ const errorMsg = this.getMessage('snkImageInput.errorImageSize') + this.maxSize + '(KB)';
198
+ this.imageError.emit(errorMsg);
199
+ if (this.application) {
200
+ await this.application.error(this.getMessage('snkImageInput.errorTitle'), errorMsg);
201
+ }
202
+ return;
203
+ }
204
+ this.imageValue = base64;
205
+ await sessionFileUpload(blob, this.entityName, this.fieldName);
206
+ await this.updatedataUnitField();
207
+ }
208
+ async updatedataUnitField(deleted = false) {
209
+ if (!this.dataUnit || !this.dataUnit.getSelectedRecord()) {
210
+ return;
211
+ }
212
+ if (deleted) {
213
+ await this.dataUnit.setFieldValue(this.fieldName, 'deletado');
214
+ }
215
+ else {
216
+ await this.dataUnit.setFieldValue(this.fieldName, `$file.session.key{${buildFileKey(this.entityName, this.fieldName)}}`);
217
+ }
218
+ }
219
+ async handleImageError(event) {
220
+ this.imageError.emit(event.detail);
221
+ if (this.application) {
222
+ await this.application.error(this.getMessage('snkImageInput.errorTitle'), event.detail);
223
+ }
224
+ }
225
+ getPksFromDataUnit() {
226
+ if (!this.dataUnit) {
227
+ return undefined;
228
+ }
229
+ const selectedRecord = this.dataUnit.getSelectedRecord();
230
+ if (!selectedRecord) {
231
+ return undefined;
232
+ }
233
+ const fieldValue = selectedRecord[this.fieldName];
234
+ if (!fieldValue) {
235
+ return undefined;
236
+ }
237
+ try {
238
+ const pk = JSON.parse(fieldValue);
239
+ return pk;
240
+ }
241
+ catch (error) {
242
+ console.error('Error parsing PK from data unit field:', error);
243
+ return undefined;
244
+ }
245
+ }
246
+ async loadImage(pks) {
247
+ var _a;
248
+ this.loading = true;
249
+ if (this.dataUnit && this.entityName) {
250
+ pks = (_a = pks !== null && pks !== void 0 ? pks : this.getPksFromDataUnit()) !== null && _a !== void 0 ? _a : getPKs(this.dataUnit);
251
+ this.imageValue = await downloadImage(pks, this.fieldName, this.entityName);
252
+ }
253
+ this.loading = false;
254
+ }
255
+ async componentWillLoad() {
256
+ this.application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
257
+ if (!this.messagesBuilder) {
258
+ this.messagesBuilder = new SnkMessageBuilder();
259
+ }
260
+ if (this.dataUnit) {
261
+ this.dataUnit.subscribe(this.dataUnitObserver);
262
+ }
263
+ }
264
+ disconnectedCallback() {
265
+ if (this.dataUnit) {
266
+ this.dataUnit.unsubscribe(this.dataUnitObserver);
267
+ }
268
+ }
269
+ async componentDidLoad() {
270
+ await this.loadImage();
271
+ }
272
+ render() {
273
+ 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 })));
274
+ }
275
+ static get style() { return snkImageInputCss; }
276
+ }, [1, "snk-image-input", {
277
+ "dataUnit": [16],
278
+ "fieldName": [1, "field-name"],
279
+ "entityName": [1, "entity-name"],
280
+ "enabled": [4],
281
+ "acceptType": [1, "accept-type"],
282
+ "maxSize": [2, "max-size"],
283
+ "label": [1],
284
+ "imageValue": [32],
285
+ "loading": [32],
286
+ "reloadImage": [64]
287
+ }]);
288
+ function defineCustomElement() {
289
+ if (typeof customElements === "undefined") {
290
+ return;
291
+ }
292
+ const components = ["snk-image-input"];
293
+ components.forEach(tagName => { switch (tagName) {
294
+ case "snk-image-input":
295
+ if (!customElements.get(tagName)) {
296
+ customElements.define(tagName, SnkImageInput);
297
+ }
298
+ break;
299
+ } });
300
+ }
301
+
302
+ export { SnkImageInput as S, defineCustomElement as d, getPKs as g };
@@ -56,7 +56,7 @@ const SnkLayoutFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLE
56
56
  return (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, params);
57
57
  }
58
58
  render() {
59
- 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')))));
59
+ 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')))));
60
60
  }
61
61
  static get style() { return snkLayoutFormConfigCss; }
62
62
  }, [2, "snk-layout-form-config", {
@@ -16,7 +16,7 @@ const SnkViewRepresentation = /*@__PURE__*/ proxyCustomElement(class extends HTM
16
16
  return (h("div", { class: "svg-container__inline" }, [...Array(2)].map(() => this.renderCascadeLayout())));
17
17
  }
18
18
  render() {
19
- 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
19
+ 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)
20
20
  ? this.renderCascadeLayout()
21
21
  : this.renderSideBySideLayout())));
22
22
  }
@@ -1,5 +1,5 @@
1
- import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-7cda6254.js';
2
- import { D as DataFetcher, d as dist } from './DataFetcher-0b9da57d.js';
1
+ import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-fcc7b62f.js';
2
+ import { D as DataFetcher, d as dist } from './DataFetcher-1dd7e8c0.js';
3
3
  import { F as FilterItemType } from './filter-item-type.enum-d45e026f.js';
4
4
  import { ObjectUtils } from '@sankhyalabs/core';
5
5