@sankhyalabs/sankhyablocks 8.15.0-dev.67 → 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 (62) 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-crud.cjs.entry.js +50 -0
  4. package/dist/cjs/snk-detail-view.cjs.entry.js +41 -2
  5. package/dist/cjs/snk-form-view.cjs.entry.js +31 -0
  6. package/dist/cjs/snk-form.cjs.entry.js +26 -1
  7. package/dist/cjs/snk-grid.cjs.entry.js +46 -0
  8. package/dist/cjs/{snk-guides-viewer-545dd904.js → snk-guides-viewer-66dd6949.js} +19 -3
  9. package/dist/cjs/snk-guides-viewer.cjs.entry.js +1 -1
  10. package/dist/cjs/snk-simple-crud.cjs.entry.js +49 -1
  11. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
  12. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
  13. package/dist/collection/components/snk-crud/snk-crud.js +102 -0
  14. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
  15. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +82 -0
  16. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +73 -3
  17. package/dist/collection/components/snk-form/snk-form.js +52 -1
  18. package/dist/collection/components/snk-grid/snk-grid.js +104 -0
  19. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +101 -1
  20. package/dist/components/snk-crud.js +52 -0
  21. package/dist/components/snk-detail-view2.js +68 -5
  22. package/dist/components/snk-form-view2.js +33 -0
  23. package/dist/components/snk-form.js +27 -1
  24. package/dist/components/snk-grid2.js +48 -0
  25. package/dist/components/snk-simple-crud2.js +51 -1
  26. package/dist/esm/loader.js +1 -1
  27. package/dist/esm/sankhyablocks.js +1 -1
  28. package/dist/esm/snk-crud.entry.js +50 -0
  29. package/dist/esm/snk-detail-view.entry.js +41 -2
  30. package/dist/esm/snk-form-view.entry.js +31 -0
  31. package/dist/esm/snk-form.entry.js +26 -1
  32. package/dist/esm/snk-grid.entry.js +46 -0
  33. package/dist/esm/{snk-guides-viewer-081bcf90.js → snk-guides-viewer-11cf8dc7.js} +19 -3
  34. package/dist/esm/snk-guides-viewer.entry.js +1 -1
  35. package/dist/esm/snk-simple-crud.entry.js +49 -1
  36. package/dist/sankhyablocks/p-188e1432.entry.js +1 -0
  37. package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
  38. package/dist/sankhyablocks/p-2c9ea7b6.entry.js +1 -0
  39. package/dist/sankhyablocks/p-50e72d6c.js +1 -0
  40. package/dist/sankhyablocks/p-5201ab24.entry.js +1 -0
  41. package/dist/sankhyablocks/p-a6c4b656.entry.js +1 -0
  42. package/dist/sankhyablocks/p-aa9c4099.entry.js +1 -0
  43. package/dist/sankhyablocks/{p-af3e1265.entry.js → p-b68918fc.entry.js} +1 -1
  44. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  45. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
  46. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
  47. package/dist/types/components/snk-crud/snk-crud.d.ts +14 -0
  48. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
  49. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +15 -2
  50. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +13 -0
  51. package/dist/types/components/snk-form/snk-form.d.ts +8 -0
  52. package/dist/types/components/snk-grid/snk-grid.d.ts +19 -0
  53. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +13 -2
  54. package/dist/types/components.d.ts +76 -0
  55. package/package.json +1 -1
  56. package/dist/sankhyablocks/p-1122030d.js +0 -1
  57. package/dist/sankhyablocks/p-24880828.entry.js +0 -1
  58. package/dist/sankhyablocks/p-33f695d6.entry.js +0 -1
  59. package/dist/sankhyablocks/p-39f8ebb3.entry.js +0 -1
  60. package/dist/sankhyablocks/p-e4e044cf.entry.js +0 -1
  61. package/dist/sankhyablocks/p-ecc666ef.entry.js +0 -1
  62. package/dist/sankhyablocks/p-ee1d9c09.entry.js +0 -1
@@ -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 {
@@ -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() {
@@ -3,6 +3,7 @@ import { Host, h } from "@stencil/core";
3
3
  import { DataBinder } from "@sankhyalabs/ezui/dist/collection/utils/form";
4
4
  export class SnkFormView {
5
5
  constructor() {
6
+ this._customEditors = new Map();
6
7
  this._fieldProps = new Map();
7
8
  this.levelPath = undefined;
8
9
  this.label = undefined;
@@ -17,6 +18,7 @@ export class SnkFormView {
17
18
  this.canFix = true;
18
19
  this.recordsValidator = undefined;
19
20
  this.fieldToFocus = undefined;
21
+ this.customEditors = undefined;
20
22
  this.fieldsProps = undefined;
21
23
  }
22
24
  async showUp() {
@@ -24,6 +26,23 @@ export class SnkFormView {
24
26
  this._formView.showUp();
25
27
  }
26
28
  }
29
+ /**
30
+ * Registra um editor customizado para campos da grade e formulário
31
+ */
32
+ async addCustomEditor(fieldName, customEditor, detailContext) {
33
+ if (this._formView) {
34
+ this._formView.addCustomEditor(fieldName, customEditor, detailContext);
35
+ return;
36
+ }
37
+ const newCustomEditors = new Map(this._customEditors);
38
+ newCustomEditors.set(fieldName, { customEditor, detailContext });
39
+ this._customEditors = newCustomEditors;
40
+ }
41
+ observePropsCustomEditor(newValue) {
42
+ for (const fieldName in newValue) {
43
+ this.addCustomEditor(fieldName, newValue[fieldName]);
44
+ }
45
+ }
27
46
  /**
28
47
  * Altera/adiciona uma propriedade nos metadados do campo.
29
48
  */
@@ -99,9 +118,11 @@ export class SnkFormView {
99
118
  }
100
119
  }
101
120
  componentDidLoad() {
121
+ this.observePropsCustomEditor(this.customEditors);
102
122
  this.observeFieldsProps(this.fieldsProps);
103
123
  }
104
124
  componentDidRender() {
125
+ this.setCustomEditors();
105
126
  this.setFieldProps();
106
127
  if (this.fieldToFocus == undefined) {
107
128
  return;
@@ -114,6 +135,15 @@ export class SnkFormView {
114
135
  this.snkRequestClearFieldToFocus.emit();
115
136
  });
116
137
  }
138
+ setCustomEditors() {
139
+ if (!this._formView) {
140
+ return;
141
+ }
142
+ for (const [fieldName, customEditorProps] of this._customEditors) {
143
+ this._formView.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
144
+ this._customEditors.delete(fieldName);
145
+ }
146
+ }
117
147
  setFieldProps() {
118
148
  if (!this._formView) {
119
149
  return;
@@ -395,6 +425,26 @@ export class SnkFormView {
395
425
  "attribute": "field-to-focus",
396
426
  "reflect": false
397
427
  },
428
+ "customEditors": {
429
+ "type": "unknown",
430
+ "mutable": false,
431
+ "complexType": {
432
+ "original": "PropsCustomEditor",
433
+ "resolved": "PropsCustomEditor",
434
+ "references": {
435
+ "PropsCustomEditor": {
436
+ "location": "import",
437
+ "path": "../interfaces/PropsCustomEditor"
438
+ }
439
+ }
440
+ },
441
+ "required": false,
442
+ "optional": false,
443
+ "docs": {
444
+ "tags": [],
445
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio."
446
+ }
447
+ },
398
448
  "fieldsProps": {
399
449
  "type": "unknown",
400
450
  "mutable": false,
@@ -490,6 +540,35 @@ export class SnkFormView {
490
540
  "tags": []
491
541
  }
492
542
  },
543
+ "addCustomEditor": {
544
+ "complexType": {
545
+ "signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
546
+ "parameters": [{
547
+ "tags": [],
548
+ "text": ""
549
+ }, {
550
+ "tags": [],
551
+ "text": ""
552
+ }, {
553
+ "tags": [],
554
+ "text": ""
555
+ }],
556
+ "references": {
557
+ "Promise": {
558
+ "location": "global"
559
+ },
560
+ "ICustomEditor": {
561
+ "location": "import",
562
+ "path": "@sankhyalabs/ezui/dist/types/utils/customEditor/interfaces/ICustomEditor"
563
+ }
564
+ },
565
+ "return": "Promise<void>"
566
+ },
567
+ "docs": {
568
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio",
569
+ "tags": []
570
+ }
571
+ },
493
572
  "setFieldProp": {
494
573
  "complexType": {
495
574
  "signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
@@ -519,6 +598,9 @@ export class SnkFormView {
519
598
  }
520
599
  static get watchers() {
521
600
  return [{
601
+ "propName": "customEditors",
602
+ "methodName": "observePropsCustomEditor"
603
+ }, {
522
604
  "propName": "fieldsProps",
523
605
  "methodName": "observeFieldsProps"
524
606
  }];