@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-47941.0 → 0.0.0-bugfix-dev-59880.1

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 (114) hide show
  1. package/dist/cjs/{IExporterProvider-d3a3ccd1.js → IExporterProvider-e286ef6a.js} +3 -3
  2. package/dist/cjs/{SnkFormConfigManager-dda10d75.js → SnkFormConfigManager-7b222c78.js} +2 -2
  3. package/dist/cjs/{dataunit-fetcher-e2109392.js → dataunit-fetcher-7a08e4dd.js} +6 -2
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  6. package/dist/cjs/snk-actions-button_4.cjs.entry.js +1 -1
  7. package/dist/cjs/snk-application.cjs.entry.js +1 -1
  8. package/dist/cjs/snk-attach.cjs.entry.js +16 -21
  9. package/dist/cjs/snk-crud.cjs.entry.js +54 -3
  10. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  11. package/dist/cjs/{snk-data-unit-dee38ccd.js → snk-data-unit-3718477f.js} +79 -23
  12. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-detail-view.cjs.entry.js +43 -4
  14. package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -1
  15. package/dist/cjs/snk-form-view.cjs.entry.js +31 -0
  16. package/dist/cjs/snk-form.cjs.entry.js +28 -3
  17. package/dist/cjs/snk-grid.cjs.entry.js +50 -3
  18. package/dist/cjs/{snk-guides-viewer-af4a6ae5.js → snk-guides-viewer-66dd6949.js} +21 -5
  19. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -3
  20. package/dist/cjs/snk-simple-crud.cjs.entry.js +64 -7
  21. package/dist/collection/components/snk-attach/snk-attach.js +21 -29
  22. package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
  23. package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
  24. package/dist/collection/components/snk-crud/snk-crud.js +122 -2
  25. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
  26. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +82 -0
  27. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +73 -3
  28. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +1 -1
  29. package/dist/collection/components/snk-data-unit/snk-data-unit.js +98 -23
  30. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
  31. package/dist/collection/components/snk-form/snk-form.js +53 -2
  32. package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +2 -2
  33. package/dist/collection/components/snk-grid/snk-grid.js +123 -1
  34. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +130 -4
  35. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +1 -1
  36. package/dist/collection/lib/dataUnit/InMemoryLoader.js +6 -2
  37. package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
  38. package/dist/components/IExporterProvider.js +2 -2
  39. package/dist/components/SnkFormConfigManager.js +2 -2
  40. package/dist/components/dataunit-fetcher.js +6 -2
  41. package/dist/components/snk-attach2.js +15 -20
  42. package/dist/components/snk-crud.js +56 -2
  43. package/dist/components/snk-data-unit2.js +80 -23
  44. package/dist/components/snk-detail-view2.js +68 -5
  45. package/dist/components/snk-filter-bar2.js +6 -1
  46. package/dist/components/snk-form-view2.js +33 -0
  47. package/dist/components/snk-form.js +28 -2
  48. package/dist/components/snk-grid2.js +51 -1
  49. package/dist/components/snk-simple-crud2.js +64 -4
  50. package/dist/esm/{IExporterProvider-640e1f6b.js → IExporterProvider-cf5a56ee.js} +3 -3
  51. package/dist/esm/{SnkFormConfigManager-87bd8082.js → SnkFormConfigManager-3bdb3e1f.js} +2 -2
  52. package/dist/esm/{dataunit-fetcher-87ecba4a.js → dataunit-fetcher-f3fa35b9.js} +6 -2
  53. package/dist/esm/loader.js +1 -1
  54. package/dist/esm/sankhyablocks.js +1 -1
  55. package/dist/esm/snk-actions-button_4.entry.js +1 -1
  56. package/dist/esm/snk-application.entry.js +1 -1
  57. package/dist/esm/snk-attach.entry.js +16 -21
  58. package/dist/esm/snk-crud.entry.js +54 -3
  59. package/dist/esm/snk-data-exporter.entry.js +2 -2
  60. package/dist/esm/{snk-data-unit-1132e40b.js → snk-data-unit-8d6afa43.js} +80 -24
  61. package/dist/esm/snk-data-unit.entry.js +2 -2
  62. package/dist/esm/snk-detail-view.entry.js +43 -4
  63. package/dist/esm/snk-filter-bar.entry.js +5 -1
  64. package/dist/esm/snk-form-view.entry.js +31 -0
  65. package/dist/esm/snk-form.entry.js +28 -3
  66. package/dist/esm/snk-grid.entry.js +50 -3
  67. package/dist/esm/{snk-guides-viewer-359e39a7.js → snk-guides-viewer-11cf8dc7.js} +21 -5
  68. package/dist/esm/snk-guides-viewer.entry.js +3 -3
  69. package/dist/esm/snk-simple-crud.entry.js +64 -7
  70. package/dist/sankhyablocks/p-0a28cb19.entry.js +1 -0
  71. package/dist/sankhyablocks/p-188e1432.entry.js +1 -0
  72. package/dist/sankhyablocks/p-1c6debe6.entry.js +1 -0
  73. package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
  74. package/dist/sankhyablocks/p-2cc2d8fd.entry.js +1 -0
  75. package/dist/sankhyablocks/{p-66a31d30.entry.js → p-3e4c2cfe.entry.js} +1 -1
  76. package/dist/sankhyablocks/{p-9c70f37e.entry.js → p-4a8a149d.entry.js} +1 -1
  77. package/dist/sankhyablocks/p-50e72d6c.js +1 -0
  78. package/dist/sankhyablocks/p-5bd78e4c.entry.js +1 -0
  79. package/dist/sankhyablocks/{p-b11921ca.entry.js → p-8171e586.entry.js} +1 -1
  80. package/dist/sankhyablocks/{p-d29a252c.js → p-a97060b0.js} +1 -1
  81. package/dist/sankhyablocks/p-b27114c4.js +1 -0
  82. package/dist/sankhyablocks/{p-83950924.entry.js → p-b643f746.entry.js} +1 -1
  83. package/dist/sankhyablocks/{p-d799aa7f.entry.js → p-b68918fc.entry.js} +1 -1
  84. package/dist/sankhyablocks/p-da7c81d6.entry.js +1 -0
  85. package/dist/sankhyablocks/{p-da6e3dcf.entry.js → p-e238279a.entry.js} +1 -1
  86. package/dist/sankhyablocks/p-eae66367.js +1 -0
  87. package/dist/sankhyablocks/{p-08fee6e8.js → p-fde91811.js} +1 -1
  88. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  89. package/dist/types/components/snk-attach/snk-attach.d.ts +9 -9
  90. package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
  91. package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
  92. package/dist/types/components/snk-crud/snk-crud.d.ts +18 -0
  93. package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
  94. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +15 -2
  95. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +13 -0
  96. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +16 -1
  97. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
  98. package/dist/types/components/snk-form/snk-form.d.ts +8 -0
  99. package/dist/types/components/snk-grid/snk-grid.d.ts +23 -0
  100. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +18 -2
  101. package/dist/types/components.d.ts +112 -0
  102. package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
  103. package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
  104. package/package.json +1 -1
  105. package/dist/sankhyablocks/p-0bcc6e83.js +0 -1
  106. package/dist/sankhyablocks/p-2eb90860.js +0 -1
  107. package/dist/sankhyablocks/p-33f695d6.entry.js +0 -1
  108. package/dist/sankhyablocks/p-3519a984.entry.js +0 -1
  109. package/dist/sankhyablocks/p-5c8a9e27.entry.js +0 -1
  110. package/dist/sankhyablocks/p-7ecaaea2.entry.js +0 -1
  111. package/dist/sankhyablocks/p-931343a1.entry.js +0 -1
  112. package/dist/sankhyablocks/p-cb91634d.js +0 -1
  113. package/dist/sankhyablocks/p-cf9d2d1e.entry.js +0 -1
  114. package/dist/sankhyablocks/p-f72e8835.entry.js +0 -1
@@ -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
  }];
@@ -33,6 +33,8 @@ export class SnkGuidesViewer {
33
33
  this._formEditorConfigManager = undefined;
34
34
  this._formEditorDataUnit = undefined;
35
35
  this._fieldToGetFocus = undefined;
36
+ this._customEditors = undefined;
37
+ this._customRenders = undefined;
36
38
  this._fieldsProps = {};
37
39
  }
38
40
  observeDataUnit() {
@@ -64,6 +66,19 @@ export class SnkGuidesViewer {
64
66
  async findField() {
65
67
  await openFieldSearch(this._moreOptions, this._fieldSearch);
66
68
  }
69
+ /**
70
+ * Registra um editor customizado para campos da grade e formulário
71
+ */
72
+ async addCustomEditor(fieldName, customEditor) {
73
+ this._customEditors = Object.assign(Object.assign({}, this._customEditors), { [fieldName]: customEditor });
74
+ }
75
+ /**
76
+ * Registra um render customizado para colunas da grid.
77
+ */
78
+ async addGridCustomRender(fieldName, customRender) {
79
+ this._customRenders = Object.assign(Object.assign({}, this._customRenders), { [fieldName]: customRender });
80
+ }
81
+ ;
67
82
  /**
68
83
  * Altera/adiciona uma propriedade nos metadados do campo.
69
84
  */
@@ -215,7 +230,7 @@ export class SnkGuidesViewer {
215
230
  if (sheet == undefined) {
216
231
  return;
217
232
  }
218
- return 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 });
233
+ return 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 });
219
234
  })));
220
235
  }
221
236
  wrapDetail(levels, content) {
@@ -257,14 +272,14 @@ export class SnkGuidesViewer {
257
272
  else {
258
273
  detailBranch = this.selectedGuide;
259
274
  }
260
- content = this.wrapDetail(levels, 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 }));
275
+ content = this.wrapDetail(levels, 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 }));
261
276
  }
262
277
  else {
263
278
  const cardId = this.selectedGuide.id;
264
279
  const sheet = this._masterFormMetadata.getSheet(cardId);
265
280
  if (sheet) {
266
281
  const cardConfig = (_c = (_b = this.masterFormConfig) === null || _b === void 0 ? void 0 : _b.cardsState) === null || _c === void 0 ? void 0 : _c.get(cardId);
267
- content = 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 == PresentationMode.SECONDARY && this.buildTaskBar());
282
+ content = 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 == PresentationMode.SECONDARY && this.buildTaskBar());
268
283
  }
269
284
  }
270
285
  return content;
@@ -471,6 +486,7 @@ export class SnkGuidesViewer {
471
486
  recordsValidator: this.recordsValidator,
472
487
  fieldToFocus: this._fieldToGetFocus,
473
488
  onRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this),
489
+ propsCustomEditor: this._customEditors,
474
490
  fieldsProps: this._fieldsProps
475
491
  }), this.getContent())), 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 })));
476
492
  }
@@ -786,6 +802,8 @@ export class SnkGuidesViewer {
786
802
  "_formEditorConfigManager": {},
787
803
  "_formEditorDataUnit": {},
788
804
  "_fieldToGetFocus": {},
805
+ "_customEditors": {},
806
+ "_customRenders": {},
789
807
  "_fieldsProps": {}
790
808
  };
791
809
  }
@@ -887,6 +905,58 @@ export class SnkGuidesViewer {
887
905
  "tags": []
888
906
  }
889
907
  },
908
+ "addCustomEditor": {
909
+ "complexType": {
910
+ "signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
911
+ "parameters": [{
912
+ "tags": [],
913
+ "text": ""
914
+ }, {
915
+ "tags": [],
916
+ "text": ""
917
+ }],
918
+ "references": {
919
+ "Promise": {
920
+ "location": "global"
921
+ },
922
+ "ICustomEditor": {
923
+ "location": "import",
924
+ "path": "@sankhyalabs/ezui/dist/types/utils"
925
+ }
926
+ },
927
+ "return": "Promise<void>"
928
+ },
929
+ "docs": {
930
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio",
931
+ "tags": []
932
+ }
933
+ },
934
+ "addGridCustomRender": {
935
+ "complexType": {
936
+ "signature": "(fieldName: string, customRender: ICustomRender) => Promise<void>",
937
+ "parameters": [{
938
+ "tags": [],
939
+ "text": ""
940
+ }, {
941
+ "tags": [],
942
+ "text": ""
943
+ }],
944
+ "references": {
945
+ "Promise": {
946
+ "location": "global"
947
+ },
948
+ "ICustomRender": {
949
+ "location": "import",
950
+ "path": "@sankhyalabs/ezui/dist/types/utils"
951
+ }
952
+ },
953
+ "return": "Promise<void>"
954
+ },
955
+ "docs": {
956
+ "text": "Registra um render customizado para colunas da grid.",
957
+ "tags": []
958
+ }
959
+ },
890
960
  "setFieldProp": {
891
961
  "complexType": {
892
962
  "signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
@@ -7,7 +7,7 @@ export class CommonsExporter {
7
7
  }
8
8
  async getColumnsMetadata() {
9
9
  var _a;
10
- this.columnsState = await ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.getColumnsState());
10
+ this.columnsState = await ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.getColumnsState()) || [];
11
11
  return await this.buildColumnsMetadata(this.columnsState);
12
12
  }
13
13
  getColumnsState() {
@@ -1,5 +1,5 @@
1
1
  import { Host, h } from '@stencil/core';
2
- import { Action, ApplicationContext, DataUnitAction, ObjectUtils } from '@sankhyalabs/core';
2
+ import { Action, ApplicationContext, DataUnitAction, ObjectUtils, StringUtils } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { OperationMap, SnkMessageBuilder } from '../../lib/message/SnkMessageBuilder';
5
5
  import { DatasetStrategy } from '../../lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy';
@@ -13,6 +13,7 @@ export class SnkDataUnit {
13
13
  this._fieldsWithRmPrecision = [];
14
14
  this._metadataByRow = new Map();
15
15
  this._rowMetadataCache = new Map();
16
+ this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
16
17
  this._dataUnitObserver = async (action) => {
17
18
  const duState = this.buildDataState(action.type);
18
19
  this.dataState = duState;
@@ -35,6 +36,7 @@ export class SnkDataUnit {
35
36
  break;
36
37
  }
37
38
  };
39
+ this.fieldsToLink = [];
38
40
  this.dataState = undefined;
39
41
  this.messagesBuilder = undefined;
40
42
  this.dataUnitName = undefined;
@@ -224,23 +226,14 @@ export class SnkDataUnit {
224
226
  ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
225
227
  return;
226
228
  }
227
- return action;
229
+ return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
228
230
  }
229
231
  interceptRecordsCopied(action) {
230
232
  if (!this.isAllowed("CLONE")) {
231
233
  ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
232
234
  return;
233
235
  }
234
- const cleanFields = this.getCleanOnCopyFields();
235
- if (cleanFields.length > 0) {
236
- const records = action.payload;
237
- action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
238
- const newRecord = Object.assign({}, record);
239
- cleanFields.forEach(fieldName => delete newRecord[fieldName]);
240
- return newRecord;
241
- }));
242
- }
243
- return action;
236
+ return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
244
237
  }
245
238
  async interceptDataChange(action) {
246
239
  if (this.isAllowed("UPDATE")) {
@@ -322,7 +315,7 @@ export class SnkDataUnit {
322
315
  interceptMetadataLoaded(action) {
323
316
  this.fillFieldsWithRmp(action.payload);
324
317
  this.fillFieldsWithRmPrecision(action.payload);
325
- return action;
318
+ return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
326
319
  }
327
320
  async interceptAction(action) {
328
321
  switch (action.type) {
@@ -381,6 +374,47 @@ export class SnkDataUnit {
381
374
  return Object.assign({}, response._rmd);
382
375
  }
383
376
  }
377
+ handleDULinksOnMetadataLoaded(payload) {
378
+ const metadata = Object.assign({}, payload);
379
+ this.processLinks(metadata);
380
+ return metadata;
381
+ }
382
+ handleRecordsCopied(initialRecords) {
383
+ let records = [...initialRecords];
384
+ records = this.handleCleanOnCopy(records);
385
+ return this.handleLinksWithParent(records);
386
+ }
387
+ handleLinksWithParent(records) {
388
+ var _a, _b;
389
+ const parentDataUnit = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
390
+ if (!parentDataUnit)
391
+ return records;
392
+ const parentSelectedRecord = parentDataUnit.getSelectedRecord();
393
+ const selfInfo = parentDataUnit === null || parentDataUnit === void 0 ? void 0 : parentDataUnit.getChildInfo(this.getCleanDataUnitName());
394
+ const { links } = selfInfo;
395
+ if (!links || links.length === 0)
396
+ return records;
397
+ return records.map(record => {
398
+ return this.buildRecordWithLinkedFields(record, links, parentSelectedRecord);
399
+ });
400
+ }
401
+ buildRecordWithLinkedFields(record, links, parentSelectedRecord) {
402
+ const newRecord = Object.assign({}, record);
403
+ links.forEach(link => newRecord[link.target] = parentSelectedRecord[link.source]);
404
+ return newRecord;
405
+ }
406
+ handleCleanOnCopy(records) {
407
+ const cleanFields = this.getCleanOnCopyFields();
408
+ if (cleanFields.length > 0) {
409
+ records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
410
+ }
411
+ return records;
412
+ }
413
+ buildCopyWithCleanedFields(record, cleanFields) {
414
+ const newRecord = Object.assign({}, record);
415
+ cleanFields.forEach(fieldName => delete newRecord[fieldName]);
416
+ return newRecord;
417
+ }
384
418
  showSuccessMessage(message) {
385
419
  ApplicationUtils.info(message, { iconName: "check" });
386
420
  }
@@ -524,20 +558,40 @@ export class SnkDataUnit {
524
558
  return;
525
559
  }
526
560
  handlerLinkFields() {
527
- var _a, _b;
528
- const metadata = Object.assign({}, this.dataUnit.metadata);
529
- if (!this._parentDataUnit)
561
+ var _a, _b, _c, _d;
562
+ const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
563
+ if (!parentDU)
530
564
  return;
531
- const child = this._parentDataUnit.getChildInfo(this.entityName);
565
+ const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
566
+ const child = parentDU.getChildInfo(childName);
532
567
  if (!child)
533
568
  return;
534
- const fieldsLink = (_a = child === null || child === void 0 ? void 0 : child.links) === null || _a === void 0 ? void 0 : _a.map(link => link.target);
535
- (_b = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _b === void 0 ? void 0 : _b.forEach(field => {
536
- if (fieldsLink === null || fieldsLink === void 0 ? void 0 : fieldsLink.includes(field.name)) {
569
+ const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
570
+ this.handleDUWithLinks(links);
571
+ }
572
+ handleDUWithLinks(fieldsToLink) {
573
+ this.fieldsToLink = fieldsToLink;
574
+ const metadata = Object.assign({}, this.dataUnit.metadata);
575
+ this.processLinks(metadata);
576
+ this.dataUnit.metadata = metadata;
577
+ this.dataUnitFieldsHidded.emit();
578
+ }
579
+ processLinks(metadata) {
580
+ var _a;
581
+ (_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
582
+ var _a;
583
+ if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
537
584
  field.visible = false;
538
585
  }
539
586
  });
540
- this.dataUnit.metadata = metadata;
587
+ }
588
+ getCleanDataUnitName() {
589
+ var _a;
590
+ const uri = this.dataUnit.name;
591
+ if (StringUtils.isEmpty(uri))
592
+ return uri;
593
+ const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
594
+ return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
541
595
  }
542
596
  static getNearestInstance(element) {
543
597
  let parent = element.parentElement;
@@ -564,8 +618,9 @@ export class SnkDataUnit {
564
618
  this.dataUnit.releaseCallbacks();
565
619
  }
566
620
  }
567
- componentDidLoad() {
568
- this.loadDataUnit();
621
+ async componentDidLoad() {
622
+ await this.loadDataUnit();
623
+ this.handlerLinkFields();
569
624
  }
570
625
  render() {
571
626
  return (h(Host, null));
@@ -799,6 +854,11 @@ export class SnkDataUnit {
799
854
  }
800
855
  };
801
856
  }
857
+ static get states() {
858
+ return {
859
+ "fieldsToLink": {}
860
+ };
861
+ }
802
862
  static get events() {
803
863
  return [{
804
864
  "method": "dataStateChange",
@@ -859,6 +919,21 @@ export class SnkDataUnit {
859
919
  }
860
920
  }
861
921
  }
922
+ }, {
923
+ "method": "dataUnitFieldsHidded",
924
+ "name": "dataUnitFieldsHidded",
925
+ "bubbles": true,
926
+ "cancelable": true,
927
+ "composed": true,
928
+ "docs": {
929
+ "tags": [],
930
+ "text": "Emitido quando h\u00E1 campos no DataUnit que devem ser ocultados."
931
+ },
932
+ "complexType": {
933
+ "original": "void",
934
+ "resolved": "void",
935
+ "references": {}
936
+ }
862
937
  }, {
863
938
  "method": "insertionMode",
864
939
  "name": "insertionMode",
@@ -36,6 +36,7 @@ export class SnkFilterBar {
36
36
  this.messagesBuilder = undefined;
37
37
  this.disablePersonalizedFilter = undefined;
38
38
  this.filterBarLegacyConfigName = undefined;
39
+ this.autoLoad = undefined;
39
40
  this.allowDefault = undefined;
40
41
  this.scrollerLocked = false;
41
42
  this.showPersonalizedFilter = false;
@@ -183,7 +184,10 @@ export class SnkFilterBar {
183
184
  }
184
185
  async doLoadData(forceReload = false) {
185
186
  try {
186
- if (this._firstLoad && !forceReload) {
187
+ if (this._firstLoad && this.autoLoad === false) {
188
+ return;
189
+ }
190
+ if (this._firstLoad && !forceReload && this.autoLoad === undefined) {
187
191
  let autoLoad = await this._application.getBooleanParam("global.carregar.registros.iniciar.tela");
188
192
  if (!autoLoad) {
189
193
  return;
@@ -630,6 +634,23 @@ export class SnkFilterBar {
630
634
  },
631
635
  "attribute": "filter-bar-legacy-config-name",
632
636
  "reflect": false
637
+ },
638
+ "autoLoad": {
639
+ "type": "boolean",
640
+ "mutable": false,
641
+ "complexType": {
642
+ "original": "boolean",
643
+ "resolved": "boolean",
644
+ "references": {}
645
+ },
646
+ "required": false,
647
+ "optional": true,
648
+ "docs": {
649
+ "tags": [],
650
+ "text": "Define se a carga dos dados ser\u00E1 feita assim que o componente for carregado."
651
+ },
652
+ "attribute": "auto-load",
653
+ "reflect": false
633
654
  }
634
655
  };
635
656
  }
@@ -4,6 +4,7 @@ import { SnkFormConfigManager } from '../snk-form-config/SnkFormConfigManager';
4
4
  import ResourceIDUtils from '../../lib/resourceid/ResourceIDUtils';
5
5
  export class SnkForm {
6
6
  constructor() {
7
+ this._customEditors = new Map();
7
8
  this._dataUnit = undefined;
8
9
  this._dataState = undefined;
9
10
  this._showFormConfig = false;
@@ -26,6 +27,18 @@ export class SnkForm {
26
27
  async hideConfig() {
27
28
  this._showFormConfig = false;
28
29
  }
30
+ /**
31
+ * Registra um editor customizado para campos da grade e formulário.
32
+ */
33
+ async addCustomEditor(fieldName, customEditor) {
34
+ if (this._form) {
35
+ this._form.addCustomEditor(fieldName, customEditor);
36
+ return;
37
+ }
38
+ const newCustomEditors = new Map(this._customEditors);
39
+ newCustomEditors.set(fieldName, customEditor);
40
+ this._customEditors = newCustomEditors;
41
+ }
29
42
  /**
30
43
  * Altera/adiciona uma propriedade nos metadados do campo.
31
44
  */
@@ -39,6 +52,18 @@ export class SnkForm {
39
52
  const dataInfo = { dataUnit: this._dataUnit };
40
53
  ElementIDUtils.addIDInfo(this._element, null, dataInfo);
41
54
  }
55
+ setCustomEditors() {
56
+ if (!this._form) {
57
+ return;
58
+ }
59
+ for (const [fieldName, customEditor] of this._customEditors) {
60
+ this._form.addCustomEditor(fieldName, customEditor);
61
+ this._customEditors.delete(fieldName);
62
+ }
63
+ }
64
+ async componentDidRender() {
65
+ this.setCustomEditors();
66
+ }
42
67
  async componentWillLoad() {
43
68
  let parent = this._element.parentElement;
44
69
  while (parent) {
@@ -75,7 +100,7 @@ export class SnkForm {
75
100
  continue;
76
101
  }
77
102
  const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
78
- if (!rmPrecision) {
103
+ if (!rmPrecision && rmPrecision !== 0) {
79
104
  continue;
80
105
  }
81
106
  await this.setFieldProp(field, 'precision', rmPrecision);
@@ -92,7 +117,7 @@ export class SnkForm {
92
117
  if (!this._dataUnit || !this._dataState) {
93
118
  return undefined;
94
119
  }
95
- return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: ref => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
120
+ return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
96
121
  h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
97
122
  }
98
123
  static get is() { return "snk-form"; }
@@ -299,6 +324,32 @@ export class SnkForm {
299
324
  "tags": []
300
325
  }
301
326
  },
327
+ "addCustomEditor": {
328
+ "complexType": {
329
+ "signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
330
+ "parameters": [{
331
+ "tags": [],
332
+ "text": ""
333
+ }, {
334
+ "tags": [],
335
+ "text": ""
336
+ }],
337
+ "references": {
338
+ "Promise": {
339
+ "location": "global"
340
+ },
341
+ "ICustomEditor": {
342
+ "location": "import",
343
+ "path": "@sankhyalabs/ezui/dist/types/utils"
344
+ }
345
+ },
346
+ "return": "Promise<void>"
347
+ },
348
+ "docs": {
349
+ "text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
350
+ "tags": []
351
+ }
352
+ },
302
353
  "setFieldProp": {
303
354
  "complexType": {
304
355
  "signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
@@ -71,11 +71,11 @@ export class SnkFormConfigManager {
71
71
  var _a;
72
72
  const fields = (_a = this._config) === null || _a === void 0 ? void 0 : _a.fields;
73
73
  if (fields != undefined && fields.length > 0) {
74
- return fields.map(({ label, name, readOnly }) => {
74
+ return fields.map(({ label, name, readOnly, visible }) => {
75
75
  if (label == undefined) {
76
76
  return dataUnit.getField(name);
77
77
  }
78
- return { name, label, readOnly };
78
+ return { name, label, readOnly, visible };
79
79
  })
80
80
  .filter(field => this.isFieldVisible(field, descriptionFilter));
81
81
  }