@sankhyalabs/sankhyablocks 8.15.0-dev.66 → 8.15.0-dev.68

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 (68) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  3. package/dist/cjs/snk-attach.cjs.entry.js +15 -20
  4. package/dist/cjs/snk-crud.cjs.entry.js +50 -0
  5. package/dist/cjs/snk-detail-view.cjs.entry.js +41 -2
  6. package/dist/cjs/snk-form-view.cjs.entry.js +31 -0
  7. package/dist/cjs/snk-form.cjs.entry.js +26 -1
  8. package/dist/cjs/snk-grid.cjs.entry.js +46 -0
  9. package/dist/cjs/{snk-guides-viewer-545dd904.js → snk-guides-viewer-66dd6949.js} +19 -3
  10. package/dist/cjs/snk-guides-viewer.cjs.entry.js +1 -1
  11. package/dist/cjs/snk-simple-crud.cjs.entry.js +49 -1
  12. package/dist/collection/components/snk-attach/snk-attach.js +21 -29
  13. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
  14. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
  15. package/dist/collection/components/snk-crud/snk-crud.js +102 -0
  16. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
  17. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +82 -0
  18. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +73 -3
  19. package/dist/collection/components/snk-form/snk-form.js +52 -1
  20. package/dist/collection/components/snk-grid/snk-grid.js +104 -0
  21. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +101 -1
  22. package/dist/components/snk-attach2.js +15 -20
  23. package/dist/components/snk-crud.js +52 -0
  24. package/dist/components/snk-detail-view2.js +68 -5
  25. package/dist/components/snk-form-view2.js +33 -0
  26. package/dist/components/snk-form.js +27 -1
  27. package/dist/components/snk-grid2.js +48 -0
  28. package/dist/components/snk-simple-crud2.js +51 -1
  29. package/dist/esm/loader.js +1 -1
  30. package/dist/esm/sankhyablocks.js +1 -1
  31. package/dist/esm/snk-attach.entry.js +15 -20
  32. package/dist/esm/snk-crud.entry.js +50 -0
  33. package/dist/esm/snk-detail-view.entry.js +41 -2
  34. package/dist/esm/snk-form-view.entry.js +31 -0
  35. package/dist/esm/snk-form.entry.js +26 -1
  36. package/dist/esm/snk-grid.entry.js +46 -0
  37. package/dist/esm/{snk-guides-viewer-081bcf90.js → snk-guides-viewer-11cf8dc7.js} +19 -3
  38. package/dist/esm/snk-guides-viewer.entry.js +1 -1
  39. package/dist/esm/snk-simple-crud.entry.js +49 -1
  40. package/dist/sankhyablocks/p-188e1432.entry.js +1 -0
  41. package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
  42. package/dist/sankhyablocks/p-2c9ea7b6.entry.js +1 -0
  43. package/dist/sankhyablocks/p-50e72d6c.js +1 -0
  44. package/dist/sankhyablocks/p-5201ab24.entry.js +1 -0
  45. package/dist/sankhyablocks/{p-34935c5a.entry.js → p-8171e586.entry.js} +1 -1
  46. package/dist/sankhyablocks/p-a6c4b656.entry.js +1 -0
  47. package/dist/sankhyablocks/p-aa9c4099.entry.js +1 -0
  48. package/dist/sankhyablocks/{p-af3e1265.entry.js → p-b68918fc.entry.js} +1 -1
  49. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  50. package/dist/types/components/snk-attach/snk-attach.d.ts +9 -9
  51. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
  52. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
  53. package/dist/types/components/snk-crud/snk-crud.d.ts +14 -0
  54. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
  55. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +15 -2
  56. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +13 -0
  57. package/dist/types/components/snk-form/snk-form.d.ts +8 -0
  58. package/dist/types/components/snk-grid/snk-grid.d.ts +19 -0
  59. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +13 -2
  60. package/dist/types/components.d.ts +76 -0
  61. package/package.json +1 -1
  62. package/dist/sankhyablocks/p-1122030d.js +0 -1
  63. package/dist/sankhyablocks/p-24880828.entry.js +0 -1
  64. package/dist/sankhyablocks/p-33f695d6.entry.js +0 -1
  65. package/dist/sankhyablocks/p-39f8ebb3.entry.js +0 -1
  66. package/dist/sankhyablocks/p-e4e044cf.entry.js +0 -1
  67. package/dist/sankhyablocks/p-ecc666ef.entry.js +0 -1
  68. package/dist/sankhyablocks/p-ee1d9c09.entry.js +0 -1
@@ -87,6 +87,8 @@ const SnkGrid = class {
87
87
  index.registerInstance(this, hostRef);
88
88
  this.actionClick = index.createEvent(this, "actionClick", 7);
89
89
  this.gridDoubleClick = index.createEvent(this, "gridDoubleClick", 7);
90
+ this._customEditors = new Map();
91
+ this._customRenders = new Map();
90
92
  this._topTaskbarProcessor = new fieldSearch.TaskbarProcessor({
91
93
  "snkGridTopTaskbar.regular": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
92
94
  "snkGridTopTaskbar.regular.secondary": ["FORM_MODE", "CONFIGURATOR", "INSERT"],
@@ -185,6 +187,30 @@ const SnkGrid = class {
185
187
  async findColumn() {
186
188
  await fieldSearch.openFieldSearch(this._moreOptions, this._columnSearch);
187
189
  }
190
+ /**
191
+ * Registra um editor customizado para campos da grade e formulário
192
+ */
193
+ async addCustomEditor(fieldName, customEditor, detailContext) {
194
+ if (this._grid) {
195
+ this._grid.addCustomEditor(fieldName, customEditor, detailContext);
196
+ return;
197
+ }
198
+ const newCustomEditors = new Map(this._customEditors);
199
+ newCustomEditors.set(fieldName, { customEditor, detailContext });
200
+ this._customEditors = newCustomEditors;
201
+ }
202
+ /**
203
+ * Registra um render customizado para colunas da grid.
204
+ */
205
+ async addGridCustomRender(fieldName, customRender, detailContext) {
206
+ if (this._grid) {
207
+ this._grid.addGridCustomRender(fieldName, customRender, detailContext);
208
+ return;
209
+ }
210
+ const newCustomRenders = new Map(this._customRenders);
211
+ newCustomRenders.set(fieldName, { customRender, detailContext });
212
+ this._customRenders = newCustomRenders;
213
+ }
188
214
  /**
189
215
  * Registra um formatador de valores para uma coluna da grid.
190
216
  */
@@ -283,6 +309,24 @@ const SnkGrid = class {
283
309
  this.columnFilterDataSource.setDataUnit(this._dataUnit);
284
310
  }
285
311
  }
312
+ setCustomRenders() {
313
+ if (!this._grid) {
314
+ return;
315
+ }
316
+ for (const [fieldName, customRenderProps] of this._customRenders) {
317
+ this._grid.addGridCustomRender(fieldName, customRenderProps.customRender, customRenderProps.detailContext);
318
+ this._customRenders.delete(fieldName);
319
+ }
320
+ }
321
+ setCustomEditors() {
322
+ if (!this._grid) {
323
+ return;
324
+ }
325
+ for (const [fieldName, customEditorProps] of this._customEditors) {
326
+ this._grid.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
327
+ this._customEditors.delete(fieldName);
328
+ }
329
+ }
286
330
  componentWillLoad() {
287
331
  this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
288
332
  //TODO: substituir pelo metodo nativo closest
@@ -320,6 +364,8 @@ const SnkGrid = class {
320
364
  componentDidRender() {
321
365
  this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
322
366
  this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
367
+ this.setCustomRenders();
368
+ this.setCustomEditors();
323
369
  }
324
370
  async handleDataStateChange(evt) {
325
371
  this._dataState = evt.detail;
@@ -49,6 +49,8 @@ const SnkGuidesViewer = class {
49
49
  this._formEditorConfigManager = undefined;
50
50
  this._formEditorDataUnit = undefined;
51
51
  this._fieldToGetFocus = undefined;
52
+ this._customEditors = undefined;
53
+ this._customRenders = undefined;
52
54
  this._fieldsProps = {};
53
55
  }
54
56
  observeDataUnit() {
@@ -80,6 +82,19 @@ const SnkGuidesViewer = class {
80
82
  async findField() {
81
83
  await fieldSearch.openFieldSearch(this._moreOptions, this._fieldSearch);
82
84
  }
85
+ /**
86
+ * Registra um editor customizado para campos da grade e formulário
87
+ */
88
+ async addCustomEditor(fieldName, customEditor) {
89
+ this._customEditors = Object.assign(Object.assign({}, this._customEditors), { [fieldName]: customEditor });
90
+ }
91
+ /**
92
+ * Registra um render customizado para colunas da grid.
93
+ */
94
+ async addGridCustomRender(fieldName, customRender) {
95
+ this._customRenders = Object.assign(Object.assign({}, this._customRenders), { [fieldName]: customRender });
96
+ }
97
+ ;
83
98
  /**
84
99
  * Altera/adiciona uma propriedade nos metadados do campo.
85
100
  */
@@ -231,7 +246,7 @@ const SnkGuidesViewer = class {
231
246
  if (sheet == undefined) {
232
247
  return;
233
248
  }
234
- return index.h("snk-form-view", { levelPath: params.levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: params.formMetadata, dataUnit: params.dataUnit, recordsValidator: params.recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_b = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.summary) === null || _b === void 0 ? void 0 : _b.get(formName), fieldToFocus: params.fieldToFocus, key: formName, onSnkRequestClearFieldToFocus: _ => { var _a; return (_a = params.onRequestClearFieldToFocus) === null || _a === void 0 ? void 0 : _a.call(params); }, fieldsProps: params.fieldsProps });
249
+ return index.h("snk-form-view", { levelPath: params.levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: params.formMetadata, dataUnit: params.dataUnit, recordsValidator: params.recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_b = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.summary) === null || _b === void 0 ? void 0 : _b.get(formName), fieldToFocus: params.fieldToFocus, key: formName, onSnkRequestClearFieldToFocus: _ => { var _a; return (_a = params.onRequestClearFieldToFocus) === null || _a === void 0 ? void 0 : _a.call(params); }, customEditors: params.propsCustomEditor, fieldsProps: params.fieldsProps });
235
250
  })));
236
251
  }
237
252
  wrapDetail(levels, content) {
@@ -273,14 +288,14 @@ const SnkGuidesViewer = class {
273
288
  else {
274
289
  detailBranch = this.selectedGuide;
275
290
  }
276
- content = this.wrapDetail(levels, index.h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId }));
291
+ content = this.wrapDetail(levels, index.h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId, customEditors: this._customEditors, customRenders: this._customRenders }));
277
292
  }
278
293
  else {
279
294
  const cardId = this.selectedGuide.id;
280
295
  const sheet = this._masterFormMetadata.getSheet(cardId);
281
296
  if (sheet) {
282
297
  const cardConfig = (_c = (_b = this.masterFormConfig) === null || _b === void 0 ? void 0 : _b.cardsState) === null || _c === void 0 ? void 0 : _c.get(cardId);
283
- content = index.h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, fieldToFocus: this._fieldToGetFocus, key: guideId, onSnkRequestClearFieldToFocus: _ => this.clearFieldToFocusHandler(), fieldsProps: this._fieldsProps }, this.presentationMode == index$1.PresentationMode.SECONDARY && this.buildTaskBar());
298
+ content = index.h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, fieldToFocus: this._fieldToGetFocus, key: guideId, onSnkRequestClearFieldToFocus: _ => this.clearFieldToFocusHandler(), customEditors: this._customEditors, fieldsProps: this._fieldsProps }, this.presentationMode == index$1.PresentationMode.SECONDARY && this.buildTaskBar());
284
299
  }
285
300
  }
286
301
  return content;
@@ -487,6 +502,7 @@ const SnkGuidesViewer = class {
487
502
  recordsValidator: this.recordsValidator,
488
503
  fieldToFocus: this._fieldToGetFocus,
489
504
  onRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this),
505
+ propsCustomEditor: this._customEditors,
490
506
  fieldsProps: this._fieldsProps
491
507
  }), this.getContent())), index.h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this.getConfigViewMode(), onConfigSelected: (evt) => this.changeConfigViewMode(evt.detail), messagesBuilder: this.messagesBuilder, onOpenConfig: (evt) => this.openConfig(evt.detail), resourceID: this.resourceID })));
492
508
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const snkGuidesViewer = require('./snk-guides-viewer-545dd904.js');
5
+ const snkGuidesViewer = require('./snk-guides-viewer-66dd6949.js');
6
6
  require('./index-f9e81701.js');
7
7
  require('@sankhyalabs/core');
8
8
  require('./SnkFormConfigManager-7b222c78.js');
@@ -100,6 +100,8 @@ const SnkSimpleCrud = class {
100
100
  this._multiSelectionListDataSource = new IExporterProvider.SnkMultiSelectionListDataSource();
101
101
  this._keyDownHandler = (event) => this.keyDownListener(event);
102
102
  this._formConfigFetcher = new formConfigFetcher.FormConfigFetcher();
103
+ this._customEditors = new Map();
104
+ this._customRenders = new Map();
103
105
  this._taskbarProcessor = new fieldSearch.TaskbarProcessor({
104
106
  "snkSimpleCrudTaskbar.form_regular": this.getButtons(false, [taskbarElements.TaskbarElement.GRID_MODE]),
105
107
  "snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [taskbarElements.TaskbarElement.DATA_EXPORTER, taskbarElements.TaskbarElement.FORM_MODE]),
@@ -136,6 +138,31 @@ const SnkSimpleCrud = class {
136
138
  this.ignoreReadOnlyFormFields = false;
137
139
  this.autoLoad = undefined;
138
140
  }
141
+ /**
142
+ * Registra um editor customizado para campos da grade e formulário.
143
+ */
144
+ async addCustomEditor(fieldName, customEditor) {
145
+ if (this._grid && this._form) {
146
+ this._grid.addCustomEditor(fieldName, customEditor);
147
+ this._form.addCustomEditor(fieldName, customEditor);
148
+ return;
149
+ }
150
+ const newCustomEditors = new Map(this._customEditors);
151
+ newCustomEditors.set(fieldName, customEditor);
152
+ this._customEditors = newCustomEditors;
153
+ }
154
+ /**
155
+ * Registra um render customizado para colunas da grid.
156
+ */
157
+ async addGridCustomRender(fieldName, customRender) {
158
+ if (this._grid) {
159
+ this._grid.addGridCustomRender(fieldName, customRender);
160
+ return;
161
+ }
162
+ const newCustomRenders = new Map(this._customRenders);
163
+ newCustomRenders.set(fieldName, customRender);
164
+ this._customRenders = newCustomRenders;
165
+ }
139
166
  handleResourceIDChanged(newValue, oldValue) {
140
167
  if (core.StringUtils.isEmpty(newValue)) {
141
168
  return;
@@ -363,6 +390,8 @@ const SnkSimpleCrud = class {
363
390
  this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
364
391
  this.addGridCustomValueFormattters();
365
392
  this.setFieldsProps();
393
+ this.setCustomRenders();
394
+ this.setCustomEditors();
366
395
  }
367
396
  componentWillLoad() {
368
397
  this.processMetadata();
@@ -373,6 +402,25 @@ const SnkSimpleCrud = class {
373
402
  componentDidLoad() {
374
403
  utils.CSSVarsUtils.applyVarsGrid(this._element, this._grid);
375
404
  }
405
+ setCustomRenders() {
406
+ if (!this._grid) {
407
+ return;
408
+ }
409
+ for (const [fieldName, customRender] of this._customRenders) {
410
+ this._grid.addGridCustomRender(fieldName, customRender);
411
+ this._customRenders.delete(fieldName);
412
+ }
413
+ }
414
+ setCustomEditors() {
415
+ if (!this._grid || !this._form) {
416
+ return;
417
+ }
418
+ for (const [fieldName, customEditor] of this._customEditors) {
419
+ this._grid.addCustomEditor(fieldName, customEditor);
420
+ this._form.addCustomEditor(fieldName, customEditor);
421
+ this._customEditors.delete(fieldName);
422
+ }
423
+ }
376
424
  configDatasource() {
377
425
  this._multiSelectionListDataSource.setApplication(this.application);
378
426
  this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
@@ -723,7 +771,7 @@ const SnkSimpleCrud = class {
723
771
  }
724
772
  return (index$1.h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(constants.VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === constants.VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this) }, index$1.h("header", null, index$1.h("slot", { name: "snkSimpleCrudHeader" })), index$1.h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, index$1.h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: index.PresentationMode.SECONDARY }, index$1.h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), index$1.h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, index$1.h("stack-item", null, index$1.h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(constants.VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(dataunitFetcher.InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
725
773
  ? undefined
726
- : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, index$1.h("div", { slot: "footer" }, index$1.h("slot", { name: "snkSimpleCrudFooter" })))), index$1.h("stack-item", null, index$1.h("ez-form", { ref: ref => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && index$1.h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && index$1.h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), index$1.h("div", { id: `${this._customContainerId}` }, index$1.h("slot", { name: "SnkConfigContainerSlot" }))), index$1.h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, index$1.h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
774
+ : this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, index$1.h("div", { slot: "footer" }, index$1.h("slot", { name: "snkSimpleCrudFooter" })))), index$1.h("stack-item", null, index$1.h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && index$1.h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && index$1.h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), index$1.h("div", { id: `${this._customContainerId}` }, index$1.h("slot", { name: "SnkConfigContainerSlot" }))), index$1.h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, index$1.h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
727
775
  }
728
776
  get _element() { return index$1.getElement(this); }
729
777
  static get watchers() { return {
@@ -1,9 +1,9 @@
1
- import { h } from "@stencil/core";
2
- import { DataUnit, ApplicationContext, Action } from "@sankhyalabs/core";
3
- import { AnexoSistemaFetcher, AttachFetcher, DataUnitFetcher } from "../../lib";
4
- import { VIEW_MODE } from "../../lib/utils/constants";
5
- import { AnexoSistemaDataUnitFactory, AttachFetcherDataUnitFactory, buildTaskBarManager, anexoSistemaCrudConfig, attachCrudConfig } from "./structure";
6
- import InMemoryLoader from "../../lib/dataUnit/InMemoryLoader";
1
+ import { h } from '@stencil/core';
2
+ import { Action, ApplicationContext, DataUnit } from '@sankhyalabs/core';
3
+ import { AnexoSistemaFetcher, AttachFetcher, DataUnitFetcher } from '../../lib';
4
+ import { VIEW_MODE } from '../../lib/utils/constants';
5
+ import { anexoSistemaCrudConfig, AnexoSistemaDataUnitFactory, attachCrudConfig, AttachFetcherDataUnitFactory, buildTaskBarManager, } from './structure';
6
+ import InMemoryLoader from '../../lib/dataUnit/InMemoryLoader';
7
7
  const RESOURCE_ID = 'AnexoSistema';
8
8
  const DATA_UNIT_NAME = 'br.com.sankhya.core.v3.anexoSistema';
9
9
  export class SnkAttach {
@@ -40,25 +40,22 @@ export class SnkAttach {
40
40
  this._currentDataUnit = undefined;
41
41
  this.crudConfig = undefined;
42
42
  }
43
- registerKeyWatcher(newRegisterKey, oldRegisterKey) {
43
+ async initAttach() {
44
44
  var _a, _b, _c, _d, _e, _f;
45
- if (!this._currentDataUnit) {
46
- this.loadAttachmentDataUnit();
45
+ await this.loadAttachmentDataUnit();
46
+ this.returnToGridMode();
47
+ if (this.fetcherType === "AnexoSistema") {
48
+ this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
49
+ (_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
50
+ await ((_c = this._currentDataUnit) === null || _c === void 0 ? void 0 : _c.loadData());
51
+ return;
47
52
  }
48
- if (oldRegisterKey !== newRegisterKey) {
49
- this.returnToGridMode();
50
- if (this.fetcherType === "AnexoSistema") {
51
- this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
52
- (_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
53
- return (_c = this._currentDataUnit) === null || _c === void 0 ? void 0 : _c.loadData();
54
- }
55
- if (this.fetcherType === "Attach") {
56
- const hasMoreOneItem = ((_d = this.registerKey) === null || _d === void 0 ? void 0 : _d.split("_").length) > 1;
57
- if (hasMoreOneItem)
58
- return;
59
- }
60
- return (_f = (_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadMetadata()) === null || _f === void 0 ? void 0 : _f.then(this._currentDataUnit.loadData.bind(undefined, undefined, true, this.registerKey));
53
+ if (this.fetcherType === "Attach") {
54
+ const hasMoreOneItem = ((_d = this.registerKey) === null || _d === void 0 ? void 0 : _d.split("_").length) > 1;
55
+ if (hasMoreOneItem)
56
+ return;
61
57
  }
58
+ (_f = (_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadMetadata()) === null || _f === void 0 ? void 0 : _f.then(this._currentDataUnit.loadData.bind(undefined, undefined, true, this.registerKey));
62
59
  }
63
60
  /**
64
61
  * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
@@ -180,8 +177,9 @@ export class SnkAttach {
180
177
  }
181
178
  });
182
179
  }
183
- componentWillLoad() {
180
+ async componentWillLoad() {
184
181
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
182
+ await this.initAttach();
185
183
  }
186
184
  componentWillRender() {
187
185
  if (!this.fetcherType) {
@@ -386,10 +384,4 @@ export class SnkAttach {
386
384
  }
387
385
  }];
388
386
  }
389
- static get watchers() {
390
- return [{
391
- "propName": "registerKey",
392
- "methodName": "registerKeyWatcher"
393
- }];
394
- }
395
387
  }
@@ -13,6 +13,8 @@ export class SnkCrud {
13
13
  constructor() {
14
14
  this._keyDownHandler = async (event) => this.keyDownListener(event);
15
15
  this._viewHistory = [];
16
+ this._customEditors = new Map();
17
+ this._customRenders = new Map();
16
18
  this._dataUnit = undefined;
17
19
  this._dataState = undefined;
18
20
  this.attachmentRegisterKey = undefined;
@@ -71,6 +73,31 @@ export class SnkCrud {
71
73
  async getFilterBar() {
72
74
  return await this._snkGrid.getFilterBar();
73
75
  }
76
+ /**
77
+ * Registra um editor customizado para campos da grade e formulário.
78
+ */
79
+ async addCustomEditor(fieldName, customEditor) {
80
+ if (this._guidesViewer && this._snkGrid) {
81
+ this._guidesViewer.addCustomEditor(fieldName, customEditor);
82
+ this._snkGrid.addCustomEditor(fieldName, customEditor);
83
+ return;
84
+ }
85
+ const newCustomEditors = new Map(this._customEditors);
86
+ newCustomEditors.set(fieldName, customEditor);
87
+ this._customEditors = newCustomEditors;
88
+ }
89
+ /**
90
+ * Registra um render customizado para colunas da grid.
91
+ */
92
+ async addGridCustomRender(fieldName, customRender) {
93
+ if (this._snkGrid) {
94
+ this._snkGrid.addGridCustomRender(fieldName, customRender);
95
+ return;
96
+ }
97
+ const newCustomRenders = new Map(this._customRenders);
98
+ newCustomRenders.set(fieldName, customRender);
99
+ this._customRenders = newCustomRenders;
100
+ }
74
101
  /**
75
102
  * Registra um formatador de valores para uma coluna da grid.
76
103
  */
@@ -142,6 +169,29 @@ export class SnkCrud {
142
169
  const joinedPrimaryKeys = recordCriteria.map(({ value }) => value).join('_');
143
170
  return joinedPrimaryKeys;
144
171
  }
172
+ setCustomRenders() {
173
+ if (!this._snkGrid) {
174
+ return;
175
+ }
176
+ for (const [fieldName, customRender] of this._customRenders) {
177
+ this._snkGrid.addGridCustomRender(fieldName, customRender);
178
+ this._customRenders.delete(fieldName);
179
+ }
180
+ }
181
+ setCustomEditors() {
182
+ if (!this._snkGrid || !this._guidesViewer) {
183
+ return;
184
+ }
185
+ for (const [fieldName, customEditor] of this._customEditors) {
186
+ this._guidesViewer.addCustomEditor(fieldName, customEditor);
187
+ this._snkGrid.addCustomEditor(fieldName, customEditor);
188
+ this._customEditors.delete(fieldName);
189
+ }
190
+ }
191
+ componentDidRender() {
192
+ this.setCustomRenders();
193
+ this.setCustomEditors();
194
+ }
145
195
  componentWillLoad() {
146
196
  this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
147
197
  let parent = this._element.parentElement;
@@ -829,6 +879,58 @@ export class SnkCrud {
829
879
  "tags": []
830
880
  }
831
881
  },
882
+ "addCustomEditor": {
883
+ "complexType": {
884
+ "signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
885
+ "parameters": [{
886
+ "tags": [],
887
+ "text": ""
888
+ }, {
889
+ "tags": [],
890
+ "text": ""
891
+ }],
892
+ "references": {
893
+ "Promise": {
894
+ "location": "global"
895
+ },
896
+ "ICustomEditor": {
897
+ "location": "import",
898
+ "path": "@sankhyalabs/ezui/dist/types/utils"
899
+ }
900
+ },
901
+ "return": "Promise<void>"
902
+ },
903
+ "docs": {
904
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
905
+ "tags": []
906
+ }
907
+ },
908
+ "addGridCustomRender": {
909
+ "complexType": {
910
+ "signature": "(fieldName: string, customRender: ICustomRender) => Promise<void>",
911
+ "parameters": [{
912
+ "tags": [],
913
+ "text": ""
914
+ }, {
915
+ "tags": [],
916
+ "text": ""
917
+ }],
918
+ "references": {
919
+ "Promise": {
920
+ "location": "global"
921
+ },
922
+ "ICustomRender": {
923
+ "location": "import",
924
+ "path": "@sankhyalabs/ezui/dist/types/utils"
925
+ }
926
+ },
927
+ "return": "Promise<void>"
928
+ },
929
+ "docs": {
930
+ "text": "Registra um render customizado para colunas da grid.",
931
+ "tags": []
932
+ }
933
+ },
832
934
  "addCustomValueFormatter": {
833
935
  "complexType": {
834
936
  "signature": "(columnName: string, customFormatter: ICustomFormatter) => Promise<void>",
@@ -26,6 +26,8 @@ export class SnkDetailView {
26
26
  this.branchGuide = undefined;
27
27
  this.canEdit = true;
28
28
  this.taskbarCustomContainerId = undefined;
29
+ this.customEditors = undefined;
30
+ this.customRenders = undefined;
29
31
  }
30
32
  observeDataUnit(newDataUnit, oldDataUnit) {
31
33
  newDataUnit === null || newDataUnit === void 0 ? void 0 : newDataUnit.subscribe(this.dataUnitActionHandler.bind(this));
@@ -93,10 +95,38 @@ export class SnkDetailView {
93
95
  this._snkGrid.scrollIntoView({ behavior: "smooth", block: "start" });
94
96
  }
95
97
  }
98
+ /**
99
+ * Registra um editor customizado para campos da grade e formulário.
100
+ */
101
+ async addCustomEditor(fieldName, customEditor) {
102
+ var _a;
103
+ const detailContext = this.normalizeBranchGuideId((_a = this.branchGuide) === null || _a === void 0 ? void 0 : _a.id);
104
+ this._snkGrid.addCustomEditor(fieldName, customEditor, detailContext);
105
+ this._snkFormView.addCustomEditor(fieldName, customEditor, detailContext);
106
+ }
107
+ async observerPropsCustomEditor(newValue) {
108
+ for (const fieldName in newValue) {
109
+ await this.addCustomEditor(fieldName, newValue[fieldName]);
110
+ }
111
+ }
112
+ /**
113
+ * Registra um render customizado para colunas da grid.
114
+ */
115
+ async addGridCustomRender(fieldName, customRender) {
116
+ var _a;
117
+ const detailContext = this.normalizeBranchGuideId((_a = this.branchGuide) === null || _a === void 0 ? void 0 : _a.id);
118
+ await this._snkGrid.addGridCustomRender(fieldName, customRender, detailContext);
119
+ }
96
120
  onContentCardChanged(evt) {
97
121
  SnkGuidesViewer.updateContentCard(evt.detail.formName, evt.detail.cardConfig, evt.detail.propertyChanged, this.formConfigManager).then(() => forceUpdate(this));
98
122
  evt.stopPropagation();
99
123
  }
124
+ async observeCustomRenders(newValue) {
125
+ for (const field in newValue) {
126
+ const customRender = newValue[field];
127
+ await this.addGridCustomRender(field, customRender);
128
+ }
129
+ }
100
130
  updateLabel() {
101
131
  const guideItemPathSize = this.guideItemPath ? this.guideItemPath.length : 0;
102
132
  if (guideItemPathSize > 0) {
@@ -199,6 +229,10 @@ export class SnkDetailView {
199
229
  this.messagesBuilder = new SnkMessageBuilder(this.entityName);
200
230
  }
201
231
  }
232
+ async componentDidLoad() {
233
+ await this.observerPropsCustomEditor(this.customEditors);
234
+ await this.observeCustomRenders(this.customRenders);
235
+ }
202
236
  async dataUnitActionHandler(action) {
203
237
  if (action.type === Action.FIELD_INVALIDATED) {
204
238
  this.addErrorBadgeToBranchGuide();
@@ -208,6 +242,9 @@ export class SnkDetailView {
208
242
  this.branchGuide = Object.assign(Object.assign({}, this.branchGuide), { badge: 'error' });
209
243
  this.snkDetailGuidesChange.emit(new GuideBuilder(this.branchGuide, this._formMetadata, this.dataUnit));
210
244
  }
245
+ normalizeBranchGuideId(id) {
246
+ return id === null || id === void 0 ? void 0 : id.replace(/child\[(.*?)\]/g, '$1').replace(/::/g, '>');
247
+ }
211
248
  render() {
212
249
  this.updateLabel();
213
250
  //const cardConfig: IFormCardConfig = this._cardsState?.get(this.selectedForm);
@@ -469,6 +506,46 @@ export class SnkDetailView {
469
506
  },
470
507
  "attribute": "taskbar-custom-container-id",
471
508
  "reflect": false
509
+ },
510
+ "customEditors": {
511
+ "type": "unknown",
512
+ "mutable": false,
513
+ "complexType": {
514
+ "original": "PropsCustomEditor",
515
+ "resolved": "PropsCustomEditor",
516
+ "references": {
517
+ "PropsCustomEditor": {
518
+ "location": "import",
519
+ "path": "../../interfaces/PropsCustomEditor"
520
+ }
521
+ }
522
+ },
523
+ "required": false,
524
+ "optional": false,
525
+ "docs": {
526
+ "tags": [],
527
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio."
528
+ }
529
+ },
530
+ "customRenders": {
531
+ "type": "unknown",
532
+ "mutable": false,
533
+ "complexType": {
534
+ "original": "PropsCustomRender",
535
+ "resolved": "PropsCustomRender",
536
+ "references": {
537
+ "PropsCustomRender": {
538
+ "location": "import",
539
+ "path": "../../interfaces/PropsCustomRender"
540
+ }
541
+ }
542
+ },
543
+ "required": false,
544
+ "optional": false,
545
+ "docs": {
546
+ "tags": [],
547
+ "text": "Render customizados da grade."
548
+ }
472
549
  }
473
550
  };
474
551
  }
@@ -601,6 +678,58 @@ export class SnkDetailView {
601
678
  "text": "",
602
679
  "tags": []
603
680
  }
681
+ },
682
+ "addCustomEditor": {
683
+ "complexType": {
684
+ "signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
685
+ "parameters": [{
686
+ "tags": [],
687
+ "text": ""
688
+ }, {
689
+ "tags": [],
690
+ "text": ""
691
+ }],
692
+ "references": {
693
+ "Promise": {
694
+ "location": "global"
695
+ },
696
+ "ICustomEditor": {
697
+ "location": "import",
698
+ "path": "@sankhyalabs/ezui/dist/types/utils"
699
+ }
700
+ },
701
+ "return": "Promise<void>"
702
+ },
703
+ "docs": {
704
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
705
+ "tags": []
706
+ }
707
+ },
708
+ "addGridCustomRender": {
709
+ "complexType": {
710
+ "signature": "(fieldName: string, customRender: ICustomRender) => Promise<void>",
711
+ "parameters": [{
712
+ "tags": [],
713
+ "text": ""
714
+ }, {
715
+ "tags": [],
716
+ "text": ""
717
+ }],
718
+ "references": {
719
+ "Promise": {
720
+ "location": "global"
721
+ },
722
+ "ICustomRender": {
723
+ "location": "import",
724
+ "path": "@sankhyalabs/ezui/dist/types/utils"
725
+ }
726
+ },
727
+ "return": "Promise<void>"
728
+ },
729
+ "docs": {
730
+ "text": "Registra um render customizado para colunas da grid.",
731
+ "tags": []
732
+ }
604
733
  }
605
734
  };
606
735
  }
@@ -611,6 +740,12 @@ export class SnkDetailView {
611
740
  }, {
612
741
  "propName": "dataState",
613
742
  "methodName": "observerDataState"
743
+ }, {
744
+ "propName": "customEditors",
745
+ "methodName": "observerPropsCustomEditor"
746
+ }, {
747
+ "propName": "customRenders",
748
+ "methodName": "observeCustomRenders"
614
749
  }];
615
750
  }
616
751
  static get listeners() {