@sankhyalabs/sankhyablocks 8.15.0-dev.61 → 8.15.0-dev.63

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 (169) hide show
  1. package/dist/cjs/{ConfigStorage-7df9d3bb.js → ConfigStorage-9a53a42c.js} +12 -11
  2. package/dist/cjs/{form-config-fetcher-3c4daeb5.js → DataFetcher-515bda03.js} +0 -251
  3. package/dist/cjs/{IExporterProvider-c307e2b1.js → IExporterProvider-98a012a4.js} +55 -12
  4. package/dist/cjs/{SnkFormConfigManager-4259edbe.js → SnkFormConfigManager-dda10d75.js} +2 -2
  5. package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-4a95fe86.js} +6 -12
  6. package/dist/cjs/{auth-fetcher-e6112be7.js → auth-fetcher-5acb0335.js} +1 -1
  7. package/dist/cjs/{pesquisa-fetcher-cbdaba63.js → dataunit-fetcher-e2109392.js} +68 -173
  8. package/dist/cjs/form-config-fetcher-3f430aee.js +256 -0
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/pesquisa-fetcher-916a935c.js +166 -0
  11. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  12. package/dist/cjs/snk-actions-button_4.cjs.entry.js +10 -8
  13. package/dist/cjs/snk-application.cjs.entry.js +49 -39
  14. package/dist/cjs/snk-attach.cjs.entry.js +19 -17
  15. package/dist/cjs/snk-crud.cjs.entry.js +43 -9
  16. package/dist/cjs/snk-data-exporter.cjs.entry.js +9 -7
  17. package/dist/cjs/snk-data-unit-dee38ccd.js +614 -0
  18. package/dist/cjs/snk-data-unit.cjs.entry.js +10 -2
  19. package/dist/cjs/snk-detail-view.cjs.entry.js +8 -6
  20. package/dist/cjs/snk-filter-bar.cjs.entry.js +3 -2
  21. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -2
  22. package/dist/cjs/snk-form-config.cjs.entry.js +2 -1
  23. package/dist/cjs/snk-form-view.cjs.entry.js +36 -0
  24. package/dist/cjs/snk-form.cjs.entry.js +28 -7
  25. package/dist/cjs/snk-grid.cjs.entry.js +55 -10
  26. package/dist/cjs/{snk-guides-viewer-b0c44e0c.js → snk-guides-viewer-af4a6ae5.js} +19 -6
  27. package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
  28. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -2
  29. package/dist/cjs/snk-simple-crud.cjs.entry.js +96 -14
  30. package/dist/collection/collection-manifest.json +1 -1
  31. package/dist/collection/components/snk-application/snk-application.js +37 -17
  32. package/dist/collection/components/snk-crud/snk-crud.js +109 -6
  33. package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +79 -0
  34. package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +41 -4
  35. package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +14 -8
  36. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +5 -0
  37. package/dist/collection/components/snk-data-unit/snk-data-unit.js +413 -165
  38. package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
  39. package/dist/collection/components/snk-form/snk-form.js +50 -4
  40. package/dist/collection/components/snk-grid/snk-grid.js +96 -7
  41. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +156 -8
  42. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
  43. package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
  44. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
  45. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
  46. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +51 -1
  47. package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
  48. package/dist/collection/lib/message/SnkMessageBuilder.js +25 -32
  49. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
  50. package/dist/components/ConfigStorage.js +2 -1
  51. package/dist/components/DataFetcher.js +7024 -0
  52. package/dist/components/IExporterProvider.js +54 -12
  53. package/dist/components/SnkMessageBuilder.js +6 -12
  54. package/dist/components/dataunit-fetcher.js +58 -164
  55. package/dist/components/form-config-fetcher.js +3 -7023
  56. package/dist/components/pesquisa-fetcher.js +164 -0
  57. package/dist/components/snk-actions-button2.js +4 -2
  58. package/dist/components/snk-application2.js +26 -17
  59. package/dist/components/snk-attach2.js +4 -2
  60. package/dist/components/snk-crud.js +46 -9
  61. package/dist/components/snk-data-exporter2.js +4 -2
  62. package/dist/components/snk-data-unit2.js +356 -166
  63. package/dist/components/snk-detail-view2.js +21 -6
  64. package/dist/components/snk-form-config2.js +1 -1
  65. package/dist/components/snk-form-view2.js +39 -1
  66. package/dist/components/snk-form.js +26 -5
  67. package/dist/components/snk-grid2.js +58 -11
  68. package/dist/components/snk-simple-crud2.js +96 -10
  69. package/dist/esm/{ConfigStorage-928c3bf4.js → ConfigStorage-174101b9.js} +2 -1
  70. package/dist/esm/{form-config-fetcher-e3094014.js → DataFetcher-4b4b7beb.js} +1 -250
  71. package/dist/esm/{IExporterProvider-e2a1195d.js → IExporterProvider-8f085554.js} +54 -12
  72. package/dist/esm/{SnkFormConfigManager-a87ade7a.js → SnkFormConfigManager-87bd8082.js} +2 -2
  73. package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-3a767111.js} +6 -12
  74. package/dist/esm/{auth-fetcher-e1cb288f.js → auth-fetcher-9f86c346.js} +1 -1
  75. package/dist/esm/{pesquisa-fetcher-6d8e50bb.js → dataunit-fetcher-87ecba4a.js} +57 -163
  76. package/dist/esm/form-config-fetcher-5d72aaf1.js +253 -0
  77. package/dist/esm/loader.js +1 -1
  78. package/dist/esm/pesquisa-fetcher-9cfab836.js +164 -0
  79. package/dist/esm/sankhyablocks.js +1 -1
  80. package/dist/esm/snk-actions-button_4.entry.js +5 -3
  81. package/dist/esm/snk-application.entry.js +30 -20
  82. package/dist/esm/snk-attach.entry.js +5 -3
  83. package/dist/esm/snk-crud.entry.js +43 -9
  84. package/dist/esm/snk-data-exporter.entry.js +6 -4
  85. package/dist/esm/snk-data-unit-1132e40b.js +612 -0
  86. package/dist/esm/snk-data-unit.entry.js +10 -2
  87. package/dist/esm/snk-detail-view.entry.js +8 -6
  88. package/dist/esm/snk-filter-bar.entry.js +3 -2
  89. package/dist/esm/snk-filter-modal-item.entry.js +3 -2
  90. package/dist/esm/snk-form-config.entry.js +2 -1
  91. package/dist/esm/snk-form-view.entry.js +36 -0
  92. package/dist/esm/snk-form.entry.js +28 -7
  93. package/dist/esm/snk-grid.entry.js +56 -11
  94. package/dist/esm/{snk-guides-viewer-1fd41a25.js → snk-guides-viewer-359e39a7.js} +19 -6
  95. package/dist/esm/snk-guides-viewer.entry.js +8 -6
  96. package/dist/esm/snk-personalized-filter.entry.js +3 -2
  97. package/dist/esm/snk-simple-crud.entry.js +95 -13
  98. package/dist/sankhyablocks/p-00a7ede4.entry.js +1 -0
  99. package/dist/sankhyablocks/p-010d475f.js +1 -0
  100. package/dist/sankhyablocks/p-08fee6e8.js +60 -0
  101. package/dist/sankhyablocks/p-0bcc6e83.js +1 -0
  102. package/dist/sankhyablocks/p-2a84e45b.entry.js +1 -0
  103. package/dist/sankhyablocks/{p-0e8702f0.js → p-2eb90860.js} +1 -1
  104. package/dist/sankhyablocks/p-33f695d6.entry.js +1 -0
  105. package/dist/sankhyablocks/p-4ce73e88.js +1 -0
  106. package/dist/sankhyablocks/p-4ef47eb8.entry.js +1 -0
  107. package/dist/sankhyablocks/{p-e27496ed.js → p-566f5f50.js} +6 -6
  108. package/dist/sankhyablocks/p-59dccb7a.entry.js +1 -0
  109. package/dist/sankhyablocks/p-66a31d30.entry.js +11 -0
  110. package/dist/sankhyablocks/p-6b2be902.js +6 -0
  111. package/dist/sankhyablocks/p-7ecaaea2.entry.js +1 -0
  112. package/dist/sankhyablocks/p-80031650.js +1 -0
  113. package/dist/sankhyablocks/p-83950924.entry.js +1 -0
  114. package/dist/sankhyablocks/p-873d2e6a.entry.js +1 -0
  115. package/dist/sankhyablocks/p-931343a1.entry.js +1 -0
  116. package/dist/sankhyablocks/p-a6dfa396.js +1 -0
  117. package/dist/sankhyablocks/p-aa854fa8.entry.js +1 -0
  118. package/dist/sankhyablocks/p-b11921ca.entry.js +1 -0
  119. package/dist/sankhyablocks/p-cb91634d.js +1 -0
  120. package/dist/sankhyablocks/p-cf9d2d1e.entry.js +1 -0
  121. package/dist/sankhyablocks/p-d799aa7f.entry.js +1 -0
  122. package/dist/sankhyablocks/p-da6e3dcf.entry.js +1 -0
  123. package/dist/sankhyablocks/p-e0c27486.js +26 -0
  124. package/dist/sankhyablocks/p-f72e8835.entry.js +1 -0
  125. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  126. package/dist/types/components/snk-application/snk-application.d.ts +6 -2
  127. package/dist/types/components/snk-crud/snk-crud.d.ts +14 -1
  128. package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +13 -1
  129. package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +6 -0
  130. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +3 -0
  131. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +45 -1
  132. package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
  133. package/dist/types/components/snk-form/snk-form.d.ts +6 -0
  134. package/dist/types/components/snk-grid/snk-grid.d.ts +19 -3
  135. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +22 -0
  136. package/dist/types/components.d.ts +68 -4
  137. package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
  138. package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
  139. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
  140. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
  141. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
  142. package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
  143. package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +2 -0
  144. package/package.json +1 -1
  145. package/dist/cjs/snk-data-unit-abd2113f.js +0 -427
  146. package/dist/esm/snk-data-unit-29eba11a.js +0 -425
  147. package/dist/sankhyablocks/p-029bfc09.js +0 -1
  148. package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
  149. package/dist/sankhyablocks/p-07825198.js +0 -1
  150. package/dist/sankhyablocks/p-13ea113d.entry.js +0 -1
  151. package/dist/sankhyablocks/p-314e2d1a.entry.js +0 -1
  152. package/dist/sankhyablocks/p-32556aa6.js +0 -1
  153. package/dist/sankhyablocks/p-3357af48.js +0 -1
  154. package/dist/sankhyablocks/p-3c2a1f4d.js +0 -65
  155. package/dist/sankhyablocks/p-3e7167dd.js +0 -1
  156. package/dist/sankhyablocks/p-536eeb16.js +0 -26
  157. package/dist/sankhyablocks/p-587f9dcf.entry.js +0 -1
  158. package/dist/sankhyablocks/p-61984566.entry.js +0 -1
  159. package/dist/sankhyablocks/p-65b6dba3.entry.js +0 -1
  160. package/dist/sankhyablocks/p-6a7bc5c8.entry.js +0 -1
  161. package/dist/sankhyablocks/p-6c9edfd8.entry.js +0 -1
  162. package/dist/sankhyablocks/p-89bde7d3.entry.js +0 -1
  163. package/dist/sankhyablocks/p-91dceecf.entry.js +0 -1
  164. package/dist/sankhyablocks/p-a40cbad8.entry.js +0 -1
  165. package/dist/sankhyablocks/p-b86ea293.entry.js +0 -1
  166. package/dist/sankhyablocks/p-d8ddb2a4.entry.js +0 -11
  167. package/dist/sankhyablocks/p-df73ac00.entry.js +0 -1
  168. package/dist/sankhyablocks/p-f92f1f5f.entry.js +0 -1
  169. package/dist/sankhyablocks/p-fa84e72f.entry.js +0 -1
@@ -0,0 +1,164 @@
1
+ import { DataType, ApplicationContext } from '@sankhyalabs/core';
2
+ import { d as dist, D as DataFetcher } from './DataFetcher.js';
3
+
4
+ class PesquisaFetcher {
5
+ constructor() {
6
+ this._defaultPageSize = 100;
7
+ this._templateByQuery = new Map();
8
+ this._searchListenersByDataUnit = new Map();
9
+ this.buldTemplates();
10
+ }
11
+ buldTemplates() {
12
+ this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
13
+ $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
14
+ value
15
+ label
16
+ }
17
+ }`);
18
+ }
19
+ loadSearchOptions(entityName, argument, criteria, options) {
20
+ var _a;
21
+ const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
22
+ argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
23
+ criteria === null || criteria === void 0 ? void 0 : criteria.params.forEach(param => {
24
+ if (param.dataType === DataType.OBJECT) {
25
+ param.value = JSON.stringify(param.value);
26
+ }
27
+ });
28
+ const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
29
+ const values = {
30
+ argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
31
+ entityName,
32
+ criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
33
+ options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
34
+ };
35
+ if (values.options) {
36
+ (_a = values.options) === null || _a === void 0 ? true : delete _a.dataUnitId;
37
+ }
38
+ return new Promise((resolve, reject) => {
39
+ DataFetcher.get()
40
+ .callGraphQL({
41
+ values,
42
+ query: this._templateByQuery.get("search"),
43
+ })
44
+ .then((result) => {
45
+ resolve(result);
46
+ })
47
+ .catch((error) => {
48
+ reject(error);
49
+ });
50
+ });
51
+ }
52
+ loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
53
+ var _a, _b, _c, _d, _e;
54
+ const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
55
+ const values = {
56
+ argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
57
+ criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
58
+ searchOptions: Object.assign(Object.assign({}, searchOptions), listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions),
59
+ };
60
+ const serviceName = "PesquisaSP.getSuggestion";
61
+ const externalCriteria = {
62
+ query: {
63
+ $: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
64
+ }
65
+ };
66
+ if (((_c = (_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.length) > 0) {
67
+ externalCriteria.params = {
68
+ param: values.criteria.params.map(param => {
69
+ let value = param.value;
70
+ if (typeof value === "string") {
71
+ const match = /CTX\{([^}]+)\}/.exec(value);
72
+ if (match) {
73
+ value = ApplicationContext.getContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${match[1]})__`);
74
+ }
75
+ }
76
+ let type = param.dataType;
77
+ if (type === DataType.OBJECT) {
78
+ value = value.value;
79
+ type = "S";
80
+ }
81
+ else {
82
+ type = convertParamType(param.dataType);
83
+ }
84
+ return { $: value, type };
85
+ })
86
+ };
87
+ }
88
+ const options = searchOptions != undefined
89
+ ? Object.assign(Object.assign({}, values === null || values === void 0 ? void 0 : values.searchOptions), { "pkFieldName": searchOptions.codeFieldName, "label": searchOptions.descriptionFieldName, "fieldName": searchOptions.codeFieldName, "useDescriptionOptions": false, "enableRowsCounter": true }) : undefined;
90
+ const reqBody = {
91
+ "serviceName": serviceName,
92
+ "requestBody": {
93
+ "criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": (_d = options === null || options === void 0 ? void 0 : options.ignoreEntityCriteria) !== null && _d !== void 0 ? _d : false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_e = values.searchOptions) === null || _e === void 0 ? void 0 : _e.rootEntity }, { options }),
94
+ "clientEventList": {
95
+ "clientEvent": []
96
+ }
97
+ }
98
+ };
99
+ return new Promise((resolve, reject) => {
100
+ DataFetcher.get()
101
+ .callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
102
+ .then(result => resolve(result))
103
+ .catch(error => reject(error));
104
+ });
105
+ }
106
+ addSearchListener(entityName, dataUnitID, listener) {
107
+ var _a;
108
+ const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
109
+ const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
110
+ if (!entityListener) {
111
+ this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
112
+ }
113
+ else {
114
+ for (const type of Object.keys(listener)) {
115
+ if (type in entityListener.listener) {
116
+ const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
117
+ if (listenerFunctionIsEquals)
118
+ continue;
119
+ entityListener.listener[type] = listener[type];
120
+ }
121
+ }
122
+ }
123
+ return () => {
124
+ const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
125
+ if (!newListeners.length) {
126
+ this._searchListenersByDataUnit.delete(dataUnitID);
127
+ return;
128
+ }
129
+ this._searchListenersByDataUnit.set(dataUnitID, newListeners);
130
+ };
131
+ }
132
+ applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
133
+ var _a;
134
+ const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
135
+ if (!dataUnitId)
136
+ return;
137
+ const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
138
+ if (!entityListener)
139
+ return;
140
+ const { listener } = entityListener;
141
+ if (!(listenerType in listener))
142
+ return;
143
+ return listener[listenerType]({ argument, criteria, searchOptions });
144
+ }
145
+ }
146
+ function convertParamType(dataType) {
147
+ //Alerta: Cuidado pra não contaminar o DataType com a implementação
148
+ //atual da pesquisa... em geral, somente inteiros,
149
+ //data (com ou sem hora) e string são realmente relevantes
150
+ switch (dataType) {
151
+ case DataType.NUMBER:
152
+ return "I";
153
+ case DataType.DATE:
154
+ return "D";
155
+ default:
156
+ return "S";
157
+ }
158
+ }
159
+ var SearchListenerType;
160
+ (function (SearchListenerType) {
161
+ SearchListenerType["beforeSearch"] = "beforeSearch";
162
+ })(SearchListenerType || (SearchListenerType = {}));
163
+
164
+ export { PesquisaFetcher as P };
@@ -1,12 +1,14 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
2
  import { ApplicationContext, StringUtils, ErrorException, WarningException, ObjectUtils, DateUtils, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
3
- import { D as DataFetcher } from './form-config-fetcher.js';
3
+ import { D as DataFetcher } from './DataFetcher.js';
4
4
  import { P as ParamType } from './ParamType.js';
5
- import './dataunit-fetcher.js';
5
+ import './pesquisa-fetcher.js';
6
6
  import './ISave.js';
7
7
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
8
8
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
9
+ import './dataunit-fetcher.js';
9
10
  import './filter-item-type.enum.js';
11
+ import './form-config-fetcher.js';
10
12
  import { R as ResourceIDUtils } from './ResourceIDUtils.js';
11
13
 
12
14
  const SERVICE_ACTION_EXECUTE_JAVA = 'ActionButtonsSP.executeJava';
@@ -2,9 +2,10 @@ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/i
2
2
  import { DateUtils, StringUtils, ObjectUtils, WaitingChangeException, WarningException, ErrorException, KeyboardManager, OnboardingUtils, DependencyType, ArrayUtils, SearchUtils, ElementIDUtils, ApplicationContext, DataType, ErrorTracking } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { C as ConfigStorage } from './ConfigStorage.js';
5
- import { d as dist, D as DataFetcher, U as UrlUtils } from './form-config-fetcher.js';
5
+ import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher.js';
6
6
  import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher.js';
7
- import { D as DataUnitFetcher, P as PesquisaFetcher } from './dataunit-fetcher.js';
7
+ import { D as DataUnitFetcher } from './dataunit-fetcher.js';
8
+ import { P as PesquisaFetcher } from './pesquisa-fetcher.js';
8
9
  import { S as SnkMessageBuilder } from './SnkMessageBuilder.js';
9
10
  import { d as defineCustomElement$1 } from './snk-pesquisa2.js';
10
11
 
@@ -606,7 +607,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
606
607
  * Cria o DataUnit a partir do nome da entidade. É possível armazená-lo no cache
607
608
  * passando o dataUnitName, assim, se mais de uma chamada for feita, o mesmo DataUnit será usado.
608
609
  */
609
- async createDataunit(entityName, dataUnitName, parentDataUnit, configName, resourceID) {
610
+ async createDataunit(entityName, dataUnitName, parentDataUnit, configName, resourceID, options) {
610
611
  if (resourceID == undefined) {
611
612
  resourceID = this.applicationResourceID;
612
613
  }
@@ -616,21 +617,29 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
616
617
  duPromisses.push(new PendingPromise(resolve, reject));
617
618
  if (!waitingDu) {
618
619
  const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, resourceID, parentDataUnit, configName);
619
- dataUnit.loadMetadata().then(() => {
620
- if (dataUnitName) {
621
- this.updateDataunitCache(undefined, dataUnitName, dataUnit);
622
- }
623
- while (duPromisses.length > 0) {
624
- duPromisses.pop().resolve(dataUnit);
625
- }
626
- }).catch(reason => {
627
- while (duPromisses.length > 0) {
628
- duPromisses.pop().reject(reason);
629
- }
630
- });
620
+ if (options === null || options === void 0 ? void 0 : options.skipLoadMetadata) {
621
+ this.processResolveDataUnit(dataUnit, dataUnitName, duPromisses);
622
+ }
623
+ else {
624
+ dataUnit.loadMetadata().then(() => {
625
+ this.processResolveDataUnit(dataUnit, dataUnitName, duPromisses);
626
+ }).catch(reason => {
627
+ while (duPromisses.length > 0) {
628
+ duPromisses.pop().reject(reason);
629
+ }
630
+ });
631
+ }
631
632
  }
632
633
  });
633
634
  }
635
+ processResolveDataUnit(dataUnit, dataUnitName, duPromisses) {
636
+ if (dataUnitName) {
637
+ this.updateDataunitCache(undefined, dataUnitName, dataUnit);
638
+ }
639
+ while (duPromisses.length > 0) {
640
+ duPromisses.pop().resolve(dataUnit);
641
+ }
642
+ }
634
643
  /**
635
644
  * Atualiza o cache de dataunits da aplicação.
636
645
  * @param oldName - Nome do dataunit que está em cache.
@@ -646,14 +655,14 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
646
655
  /**
647
656
  * Obtem um DataUnit do cache ou cria um caso ainda não tenha sido criado.
648
657
  */
649
- async getDataUnit(entityName, dataUnitName, parentDataUnit, configName, resourceID) {
658
+ async getDataUnit(entityName, dataUnitName, parentDataUnit, configName, resourceID, options) {
650
659
  return new Promise((resolve, reject) => {
651
660
  const dataUnit = this._duCache.get(dataUnitName);
652
661
  if (dataUnit) {
653
662
  resolve(dataUnit);
654
663
  }
655
664
  else {
656
- this.createDataunit(entityName, dataUnitName, parentDataUnit, configName, resourceID).then(dataUnit => {
665
+ this.createDataunit(entityName, dataUnitName, parentDataUnit, configName, resourceID, options).then(dataUnit => {
657
666
  resolve(dataUnit);
658
667
  }).catch(reason => reject(reason));
659
668
  }
@@ -1,9 +1,11 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataUnit } from '@sankhyalabs/core';
3
- import { D as DataFetcher } from './form-config-fetcher.js';
4
- import { a as PreloadManager, b as applyFilter, c as applySorting, d as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher.js';
3
+ import { D as DataFetcher } from './DataFetcher.js';
4
+ import './pesquisa-fetcher.js';
5
5
  import { S as SaveErrorsEnum } from './ISave.js';
6
+ import { P as PreloadManager, a as applyFilter, b as applySorting, c as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher.js';
6
7
  import './filter-item-type.enum.js';
8
+ import './form-config-fetcher.js';
7
9
  import { V as VIEW_MODE } from './constants.js';
8
10
  import { A as AutorizationType } from './auth-fetcher.js';
9
11
  import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
@@ -1,12 +1,14 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
  import { StringUtils, ElementIDUtils, ApplicationContext, JSUtils, FloatingManager } from '@sankhyalabs/core';
3
3
  import { T as TaskbarElement, d as defineCustomElement$3 } from './snk-taskbar2.js';
4
- import './form-config-fetcher.js';
5
- import './dataunit-fetcher.js';
4
+ import './DataFetcher.js';
5
+ import './pesquisa-fetcher.js';
6
6
  import { P as PresentationMode } from './ISave.js';
7
7
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
8
8
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
9
+ import './dataunit-fetcher.js';
9
10
  import './filter-item-type.enum.js';
11
+ import './form-config-fetcher.js';
10
12
  import { V as VIEW_MODE } from './constants.js';
11
13
  import { A as AutorizationType } from './auth-fetcher.js';
12
14
  import { d as defineCustomElement$w } from './snk-actions-button2.js';
@@ -108,6 +110,24 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
108
110
  async getFilterBar() {
109
111
  return await this._snkGrid.getFilterBar();
110
112
  }
113
+ /**
114
+ * Registra um formatador de valores para uma coluna da grid.
115
+ */
116
+ async addCustomValueFormatter(columnName, customFormatter) {
117
+ this._snkGrid.addCustomValueFormatter(columnName, customFormatter);
118
+ }
119
+ /**
120
+ * Remove o formatador de valores de uma coluna da grid.
121
+ */
122
+ async removeCustomValueFormatter(columnName) {
123
+ this._snkGrid.removeCustomValueFormatter(columnName);
124
+ }
125
+ /**
126
+ * Altera/adiciona uma propriedade nos metadados do campo.
127
+ */
128
+ async setFieldProp(fieldName, propName, value) {
129
+ await this._guidesViewer.setFieldProp(fieldName, propName, value);
130
+ }
111
131
  currentViewModeWatcher(currentView) {
112
132
  this._viewHistory = [...this._viewHistory.slice(-1), currentView];
113
133
  }
@@ -183,12 +203,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
183
203
  else {
184
204
  this.initDataUnit();
185
205
  }
186
- this._snkDataUnit.addEventListener("dataStateChange", async ({ detail: dataState }) => {
187
- this._dataState = dataState;
188
- if (dataState.selectedRecord !== undefined) {
189
- this.attachmentRegisterKey = await this.getAttachmentRegisterKey();
190
- }
191
- });
206
+ this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
192
207
  break;
193
208
  }
194
209
  parent = parent.parentElement;
@@ -204,6 +219,25 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
204
219
  this.removeShortcuts();
205
220
  window.removeEventListener("keydown", this._keyDownHandler);
206
221
  }
222
+ async handleDataStateChange(evt) {
223
+ var _a;
224
+ this._dataState = evt.detail;
225
+ if (this._dataState.selectedRecord !== undefined) {
226
+ this.attachmentRegisterKey = await this.getAttachmentRegisterKey();
227
+ }
228
+ const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
229
+ for (const field of fieldsWithRmPrecision || []) {
230
+ if (!field) {
231
+ continue;
232
+ }
233
+ const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
234
+ if (!rmPrecision) {
235
+ continue;
236
+ }
237
+ await this.setFieldProp(field, 'precision', rmPrecision);
238
+ await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
239
+ }
240
+ }
207
241
  async initKeyboardManager() {
208
242
  var _a;
209
243
  const keyboardManager = await ((_a = this._application) === null || _a === void 0 ? void 0 : _a.getKeyboardManager());
@@ -358,7 +392,10 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
358
392
  "openConfigurator": [64],
359
393
  "closeConfigurator": [64],
360
394
  "reloadFilterBar": [64],
361
- "getFilterBar": [64]
395
+ "getFilterBar": [64],
396
+ "addCustomValueFormatter": [64],
397
+ "removeCustomValueFormatter": [64],
398
+ "setFieldProp": [64]
362
399
  }]);
363
400
  function defineCustomElement$1() {
364
401
  if (typeof customElements === "undefined") {
@@ -3,12 +3,14 @@ import { ApplicationContext, ObjectUtils, UserInterface, DataType, ElementIDUtil
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { D as DataExporterOption, a as DataExporterFormat, b as DataExporterType } from './ISave.js';
5
5
  import { R as REPORT_LAUNCHER_RESOURCE_ID } from './constants.js';
6
- import { D as DataFetcher } from './form-config-fetcher.js';
6
+ import { D as DataFetcher } from './DataFetcher.js';
7
7
  import { S as SnkDataUnit } from './snk-data-unit2.js';
8
- import './dataunit-fetcher.js';
8
+ import './pesquisa-fetcher.js';
9
9
  import '@sankhyalabs/ezui/dist/collection/utils/constants';
10
10
  import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
11
+ import './dataunit-fetcher.js';
11
12
  import './filter-item-type.enum.js';
13
+ import './form-config-fetcher.js';
12
14
  import { d as defineCustomElement$1 } from './snk-exporter-email-sender2.js';
13
15
 
14
16
  class ItemBuilder {