@sankhyalabs/sankhyablocks 5.4.2 → 5.5.0

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 (181) hide show
  1. package/dist/cjs/{SnkMessageBuilder-115e8a80.js → SnkMessageBuilder-26da04f7.js} +35 -1
  2. package/dist/cjs/{constants-ae0ed870.js → constants-3787fa32.js} +1 -0
  3. package/dist/cjs/dataunit-fetcher-8f5ade55.js +319 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  6. package/dist/cjs/snk-application.cjs.entry.js +3 -315
  7. package/dist/cjs/snk-attach.cjs.entry.js +449 -0
  8. package/dist/cjs/snk-config-options.cjs.entry.js +1 -1
  9. package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
  10. package/dist/cjs/snk-crud.cjs.entry.js +22 -13
  11. package/dist/cjs/snk-data-exporter.cjs.entry.js +3 -3
  12. package/dist/cjs/{snk-data-unit-aa613f3b.js → snk-data-unit-c43df27b.js} +4 -1
  13. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  14. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -5
  15. package/dist/cjs/snk-field-config.cjs.entry.js +1 -1
  16. package/dist/cjs/snk-filter-bar.cjs.entry.js +1 -1
  17. package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
  18. package/dist/cjs/snk-grid-config.cjs.entry.js +1 -1
  19. package/dist/cjs/snk-grid.cjs.entry.js +11 -4
  20. package/dist/cjs/{snk-guides-viewer-7db960c2.js → snk-guides-viewer-e6a65393.js} +2 -2
  21. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -4
  22. package/dist/cjs/snk-select-box.cjs.entry.js +1 -1
  23. package/dist/cjs/{snk-simple-crud.cjs.entry.js → snk-simple-bar_2.cjs.entry.js} +47 -5
  24. package/dist/cjs/snk-tab-config.cjs.entry.js +1 -1
  25. package/dist/cjs/snk-taskbar.cjs.entry.js +5 -4
  26. package/dist/cjs/taskbar-elements-80285601.js +313 -0
  27. package/dist/collection/collection-manifest.json +2 -1
  28. package/dist/collection/components/snk-attach/interfaces/index.js +1 -0
  29. package/dist/collection/components/snk-attach/snk-attach.css +8 -0
  30. package/dist/collection/components/snk-attach/snk-attach.js +202 -0
  31. package/dist/collection/components/snk-attach/structure/crud-config-builder.js +37 -0
  32. package/dist/collection/components/snk-attach/structure/data-unit-builder.js +106 -0
  33. package/dist/collection/components/snk-attach/structure/index.js +3 -0
  34. package/dist/collection/components/snk-attach/structure/taskbar-builder.js +47 -0
  35. package/dist/collection/components/snk-configurator/snk-configurator.js +3 -3
  36. package/dist/collection/components/snk-crud/snk-crud.js +22 -11
  37. package/dist/collection/components/snk-data-unit/snk-data-unit.js +21 -0
  38. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +1 -1
  39. package/dist/collection/components/snk-grid/snk-grid.js +11 -3
  40. package/dist/collection/components/snk-simple-bar/snk-simple-bar.js +37 -2
  41. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +65 -2
  42. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +3 -0
  43. package/dist/collection/components/snk-taskbar/snk-taskbar.js +4 -2
  44. package/dist/collection/lib/http/data-fetcher/fetchers/attach-fetcher.js +136 -0
  45. package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.js +1 -0
  46. package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.js +1 -0
  47. package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/ISave.js +6 -0
  48. package/dist/collection/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/index.js +3 -0
  49. package/dist/collection/lib/message/SnkMessageBuilder.js +5 -1
  50. package/dist/collection/lib/message/resources/snk-attach.msg.js +27 -0
  51. package/dist/collection/lib/message/resources/snk-simple-bar.msg.js +3 -0
  52. package/dist/collection/lib/message/resources/snk-taskbar.msg.js +1 -0
  53. package/dist/collection/lib/utils/constants.js +1 -0
  54. package/dist/components/SnkMessageBuilder.js +35 -1
  55. package/dist/components/constants.js +1 -0
  56. package/dist/components/dataunit-fetcher.js +317 -0
  57. package/dist/components/index.d.ts +1 -0
  58. package/dist/components/index.js +1 -0
  59. package/dist/components/snk-application2.js +2 -314
  60. package/dist/components/snk-attach.d.ts +11 -0
  61. package/dist/components/snk-attach.js +6 -0
  62. package/dist/components/snk-attach2.js +498 -0
  63. package/dist/components/snk-crud.js +77 -48
  64. package/dist/components/snk-data-unit2.js +4 -0
  65. package/dist/components/snk-filter-bar2.js +1 -1
  66. package/dist/components/snk-grid2.js +11 -4
  67. package/dist/components/snk-simple-bar.js +1 -41
  68. package/dist/components/snk-simple-bar2.js +59 -0
  69. package/dist/components/snk-simple-crud.js +1 -328
  70. package/dist/{esm/snk-simple-crud.entry.js → components/snk-simple-crud2.js} +73 -18
  71. package/dist/components/snk-taskbar2.js +7 -2
  72. package/dist/esm/{SnkMessageBuilder-a15d22f8.js → SnkMessageBuilder-7a9392e6.js} +35 -1
  73. package/dist/esm/{constants-15617e7d.js → constants-e916ccc3.js} +1 -0
  74. package/dist/esm/dataunit-fetcher-d32c6a47.js +317 -0
  75. package/dist/esm/loader.js +1 -1
  76. package/dist/esm/sankhyablocks.js +1 -1
  77. package/dist/esm/snk-application.entry.js +3 -315
  78. package/dist/esm/snk-attach.entry.js +445 -0
  79. package/dist/esm/snk-config-options.entry.js +1 -1
  80. package/dist/esm/snk-configurator.entry.js +1 -1
  81. package/dist/esm/snk-crud.entry.js +23 -14
  82. package/dist/esm/snk-data-exporter.entry.js +3 -3
  83. package/dist/esm/{snk-data-unit-5ed93c0e.js → snk-data-unit-f9e4c694.js} +4 -1
  84. package/dist/esm/snk-data-unit.entry.js +2 -2
  85. package/dist/esm/snk-detail-view.entry.js +4 -5
  86. package/dist/esm/snk-field-config.entry.js +1 -1
  87. package/dist/esm/snk-filter-bar.entry.js +1 -1
  88. package/dist/esm/snk-form-config.entry.js +1 -1
  89. package/dist/esm/snk-grid-config.entry.js +1 -1
  90. package/dist/esm/snk-grid.entry.js +11 -4
  91. package/dist/esm/{snk-guides-viewer-1e7c21f6.js → snk-guides-viewer-62a9f74d.js} +2 -2
  92. package/dist/esm/snk-guides-viewer.entry.js +3 -4
  93. package/dist/esm/snk-select-box.entry.js +1 -1
  94. package/dist/esm/snk-simple-bar_2.entry.js +324 -0
  95. package/dist/esm/snk-tab-config.entry.js +1 -1
  96. package/dist/esm/snk-taskbar.entry.js +5 -4
  97. package/dist/esm/taskbar-elements-055ba1ad.js +309 -0
  98. package/dist/sankhyablocks/p-17375123.js +1 -0
  99. package/dist/sankhyablocks/{p-b80cf644.entry.js → p-1c0ee011.entry.js} +1 -1
  100. package/dist/sankhyablocks/p-4512cc6c.entry.js +1 -0
  101. package/dist/sankhyablocks/p-5cbbe1f7.entry.js +1 -0
  102. package/dist/sankhyablocks/p-63d01871.entry.js +1 -0
  103. package/dist/sankhyablocks/{p-0a1e7f75.entry.js → p-6ac29569.entry.js} +1 -1
  104. package/dist/sankhyablocks/{p-f4d36823.entry.js → p-6f0b3cc0.entry.js} +1 -1
  105. package/dist/sankhyablocks/p-741b00ef.entry.js +1 -0
  106. package/dist/sankhyablocks/{p-6516f35a.entry.js → p-86f75e7a.entry.js} +1 -1
  107. package/dist/sankhyablocks/{p-32599159.entry.js → p-8b02b276.entry.js} +1 -1
  108. package/dist/sankhyablocks/p-92a0fca4.js +1 -0
  109. package/dist/sankhyablocks/p-999d1953.entry.js +1 -0
  110. package/dist/sankhyablocks/{p-9bfa3cfb.entry.js → p-a412992c.entry.js} +1 -1
  111. package/dist/sankhyablocks/{p-703dddb9.js → p-aeffd219.js} +1 -1
  112. package/dist/sankhyablocks/p-b2523981.entry.js +11 -0
  113. package/dist/sankhyablocks/p-c3efd4eb.entry.js +1 -0
  114. package/dist/sankhyablocks/{p-3169584f.entry.js → p-e0b4aec3.entry.js} +1 -1
  115. package/dist/sankhyablocks/p-ebe876f5.entry.js +1 -0
  116. package/dist/sankhyablocks/p-ed438690.js +1 -0
  117. package/dist/sankhyablocks/p-f2223502.js +1 -0
  118. package/dist/sankhyablocks/p-f3d0c744.entry.js +1 -0
  119. package/dist/sankhyablocks/p-f821768b.js +74 -0
  120. package/dist/sankhyablocks/{p-f29caa0a.entry.js → p-f8c66aa3.entry.js} +1 -1
  121. package/dist/sankhyablocks/{p-adf50831.entry.js → p-fac37198.entry.js} +1 -1
  122. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  123. package/dist/types/components/snk-attach/interfaces/index.d.ts +10 -0
  124. package/dist/types/components/snk-attach/snk-attach.d.ts +45 -0
  125. package/dist/types/components/snk-attach/structure/crud-config-builder.d.ts +7 -0
  126. package/dist/types/components/snk-attach/structure/data-unit-builder.d.ts +16 -0
  127. package/dist/types/components/snk-attach/structure/index.d.ts +3 -0
  128. package/dist/types/components/snk-attach/structure/taskbar-builder.d.ts +8 -0
  129. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +5 -0
  130. package/dist/types/components/snk-simple-bar/snk-simple-bar.d.ts +14 -0
  131. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +2 -1
  132. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +1 -0
  133. package/dist/types/components.d.ts +67 -0
  134. package/dist/types/global.d.ts +9 -0
  135. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +8 -2
  136. package/dist/types/lib/http/data-fetcher/fetchers/attach-fetcher.d.ts +14 -0
  137. package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDelete.d.ts +9 -0
  138. package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/IDownloadKey.d.ts +13 -0
  139. package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/ISave.d.ts +26 -0
  140. package/dist/types/lib/http/data-fetcher/fetchers/fecthAttach/interfaces/index.d.ts +3 -0
  141. package/dist/types/lib/message/resources/snk-attach.msg.d.ts +2 -0
  142. package/dist/types/lib/message/resources/snk-simple-bar.msg.d.ts +1 -0
  143. package/dist/types/lib/utils/constants.d.ts +2 -1
  144. package/package.json +1 -1
  145. package/react/components.d.ts +1 -0
  146. package/react/components.js +1 -0
  147. package/react/components.js.map +1 -1
  148. package/dist/cjs/index-fc7ca86c.js +0 -200
  149. package/dist/cjs/snk-simple-bar.cjs.entry.js +0 -30
  150. package/dist/cjs/taskbar-elements-5e87cf44.js +0 -115
  151. package/dist/esm/index-e467ade5.js +0 -198
  152. package/dist/esm/snk-simple-bar.entry.js +0 -26
  153. package/dist/esm/taskbar-elements-10d80c79.js +0 -112
  154. package/dist/sankhyablocks/p-1393dc00.entry.js +0 -1
  155. package/dist/sankhyablocks/p-1c17eecf.entry.js +0 -1
  156. package/dist/sankhyablocks/p-2ecf14ff.js +0 -1
  157. package/dist/sankhyablocks/p-340d6fb0.entry.js +0 -84
  158. package/dist/sankhyablocks/p-74724fa7.js +0 -1
  159. package/dist/sankhyablocks/p-79f01b63.entry.js +0 -1
  160. package/dist/sankhyablocks/p-81e85890.entry.js +0 -1
  161. package/dist/sankhyablocks/p-94e6fc90.entry.js +0 -1
  162. package/dist/sankhyablocks/p-98f7f796.js +0 -1
  163. package/dist/sankhyablocks/p-b3e71248.entry.js +0 -1
  164. package/dist/sankhyablocks/p-bc281de0.js +0 -1
  165. package/dist/sankhyablocks/p-d61759a5.entry.js +0 -1
  166. package/dist/sankhyablocks/p-d65809d5.entry.js +0 -1
  167. package/dist/sankhyablocks/p-f587a454.js +0 -1
  168. package/dist/types/components/snk-application/snk-application.d.ts +0 -259
  169. package/dist/types/components/snk-crud/snk-crud.d.ts +0 -73
  170. package/dist/types/components/snk-data-exporter/exporter-email-sender/snk-exporter-email-sender.d.ts +0 -40
  171. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +0 -27
  172. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +0 -23
  173. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +0 -23
  174. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +0 -29
  175. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +0 -25
  176. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +0 -19
  177. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +0 -38
  178. package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +0 -74
  179. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +0 -53
  180. package/dist/types/components/snk-grid/snk-grid.d.ts +0 -95
  181. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +0 -59
@@ -0,0 +1,317 @@
1
+ import { DataUnit, StringUtils, DataType, DataUnitStorage, ChangeOperation } from '@sankhyalabs/core';
2
+ import { d as dist, D as DataFetcher } from './DataFetcher.js';
3
+
4
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
5
+ var t = {};
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
7
+ t[p] = s[p];
8
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
9
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
10
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
11
+ t[p[i]] = s[p[i]];
12
+ }
13
+ return t;
14
+ };
15
+ class DataUnitFetcher {
16
+ constructor() {
17
+ this.templateByQuery = new Map();
18
+ this._loadDataTimeout = {};
19
+ this.buldTemplates();
20
+ }
21
+ buldTemplates() {
22
+ this.templateByQuery.set("fetchDataUnit", dist.gql `query($name: String!) {
23
+ $queryAlias$: fetchDataUnit(name: $name){
24
+ name
25
+ fields{
26
+ name
27
+ defaultValue
28
+ label
29
+ visible
30
+ readOnly
31
+ required
32
+ dataType
33
+ userInterface
34
+ calculated
35
+ group
36
+ order
37
+ properties{
38
+ name
39
+ value
40
+ }
41
+ dependencies{
42
+ masterFields
43
+ type
44
+ expression
45
+ }
46
+ }
47
+ children{
48
+ name
49
+ label
50
+ links{
51
+ source
52
+ target
53
+ }
54
+ }
55
+ }
56
+ }`);
57
+ this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!] $parentRecordId: String) {
58
+ $queryAlias$: fetchDataUnit(name: $dataunit){
59
+ data(limit: $limit offset: $offset filters: $filters sort: $sort parentRecordId: $parentRecordId){
60
+ limit
61
+ offset
62
+ total
63
+ hasMore
64
+ records{
65
+ id
66
+ label
67
+ fields {
68
+ name
69
+ value
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }`);
75
+ this.templateByQuery.set("saveData", dist.gql `mutation($changes: [InputBatchChange!]!) {
76
+ $queryAlias$: batchOperationDataUnit(changes: $changes){
77
+ oldId
78
+ id
79
+ label
80
+ ownerDataUnitName
81
+ fields {
82
+ name
83
+ value
84
+ }
85
+ }
86
+ }`);
87
+ this.templateByQuery.set("fetchDataRecord", dist.gql `query($dataunit: String! $recordID: [String!]) {
88
+ $queryAlias$: fetchDataUnit(name: $dataunit){
89
+ record(id: $recordID){
90
+ id
91
+ label
92
+ fields {
93
+ name
94
+ value
95
+ }
96
+ }
97
+ }
98
+ }`);
99
+ }
100
+ getDataUnit(entityName, resourceID, parentDataUnit) {
101
+ const dataUnit = parentDataUnit != undefined ? parentDataUnit.getChildDataunit(`dd://${entityName}/${resourceID}`) : new DataUnit(`dd://${entityName}/${resourceID}`);
102
+ dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
103
+ dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
104
+ dataUnit.saveLoader = (_dataUnit, changes) => this.saveData(dataUnit, changes);
105
+ dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
106
+ dataUnit.recordLoader = (dataUnit, recordIds) => this.loadRecord(dataUnit, recordIds);
107
+ return dataUnit;
108
+ }
109
+ loadMetadata(dataUnit) {
110
+ return new Promise((resolve, reject) => {
111
+ DataFetcher.get()
112
+ .callGraphQL({
113
+ values: { name: dataUnit.name },
114
+ query: this.templateByQuery.get("fetchDataUnit"),
115
+ })
116
+ .then((resp) => {
117
+ var _a;
118
+ const metadata = {
119
+ name: resp.name,
120
+ label: resp.name,
121
+ children: [...resp.children],
122
+ fields: []
123
+ };
124
+ (_a = resp.fields) === null || _a === void 0 ? void 0 : _a.forEach((source) => {
125
+ let properties = undefined;
126
+ if (Array.isArray(source.properties)) {
127
+ properties = {};
128
+ if (source.calculated) {
129
+ properties.gridHeaderTooltip = "Campos calculados não podem ser ordenados";
130
+ }
131
+ source.properties.forEach((prop) => (properties[prop.name] = prop.value));
132
+ }
133
+ metadata.fields.push(Object.assign(Object.assign({}, source), { properties }));
134
+ });
135
+ metadata.fields.sort((a, b) => a.order - b.order);
136
+ resolve(metadata);
137
+ })
138
+ .catch((error) => {
139
+ reject(error);
140
+ });
141
+ });
142
+ }
143
+ loadData(dataUnit, request) {
144
+ const duName = dataUnit.name;
145
+ if (this._loadDataTimeout[duName]) {
146
+ clearTimeout(this._loadDataTimeout[duName]);
147
+ delete this._loadDataTimeout[duName];
148
+ }
149
+ return new Promise((resolve, reject) => {
150
+ this._loadDataTimeout[duName] = setTimeout(() => {
151
+ delete this._loadDataTimeout[duName];
152
+ this.doLoadData(dataUnit, request)
153
+ .then(result => resolve(result))
154
+ .catch(reason => reject(reason));
155
+ }, 200);
156
+ });
157
+ }
158
+ doLoadData(dataUnit, request) {
159
+ return new Promise((resolve, reject) => {
160
+ var _a;
161
+ const { sort, filters, limit, offset, quickFilter } = request;
162
+ const variables = { dataunit: dataUnit.name, sort, filters };
163
+ variables.limit = limit;
164
+ variables.offset = offset;
165
+ variables.parentRecordId = request.parentRecordId;
166
+ if (!StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
167
+ if (variables.filter === undefined) {
168
+ variables.filter = [];
169
+ }
170
+ const quickFilterCriteria = {
171
+ name: "__QUICK_FILTER__",
172
+ expression: "__QUICK_FILTER__",
173
+ params: [{ name: "term", dataType: DataType.TEXT, value: quickFilter.term }]
174
+ };
175
+ if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
176
+ quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: quickFilter.fields });
177
+ }
178
+ variables.filter.push(quickFilterCriteria);
179
+ }
180
+ DataFetcher.get()
181
+ .callGraphQL({
182
+ values: variables,
183
+ query: this.templateByQuery.get("fetchData"),
184
+ })
185
+ .then((resp) => {
186
+ const { limit, offset, total, hasMore, records } = resp.data;
187
+ let paginationInfo;
188
+ if (limit) {
189
+ const firstRecord = total == 0 ? 0 : offset + 1;
190
+ const lastRecord = offset + Math.min(records.length, limit);
191
+ const currentPage = offset / limit;
192
+ paginationInfo = {
193
+ firstRecord,
194
+ lastRecord,
195
+ total,
196
+ currentPage,
197
+ hasMore
198
+ };
199
+ }
200
+ const processedRecords = [];
201
+ records.forEach((responseRecord) => {
202
+ const duRecord = { __record__id__: responseRecord.id, __record__label__: responseRecord.label };
203
+ responseRecord.fields.forEach(({ name, value }) => {
204
+ duRecord[name] = dataUnit.valueFromString(name, value);
205
+ });
206
+ processedRecords.push(duRecord);
207
+ });
208
+ resolve({
209
+ paginationInfo,
210
+ records: processedRecords
211
+ });
212
+ })
213
+ .catch((error) => {
214
+ reject(error);
215
+ });
216
+ });
217
+ }
218
+ saveData(dataUnit, duChanges) {
219
+ const changes = duChanges.map((change) => {
220
+ const { dataUnit: changeDU, record, updatingFields, operation } = change;
221
+ const dataUnitInstance = DataUnitStorage.get(changeDU);
222
+ let parsedUpdatingFields;
223
+ if (updatingFields) {
224
+ parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
225
+ const descriptor = dataUnitInstance.getField(fieldName);
226
+ const dataType = descriptor ? descriptor.dataType : DataType.TEXT;
227
+ return { fieldName, dataType, value: dataUnitInstance.valueToString(fieldName, value) };
228
+ });
229
+ }
230
+ const reqChange = { dataUnit: changeDU, fields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
231
+ if (change.sourceId) {
232
+ reqChange.sourceId = change.sourceId;
233
+ }
234
+ if (record.__parent__record__id__) {
235
+ reqChange.parentRecordId = record.__parent__record__id__;
236
+ }
237
+ return reqChange;
238
+ });
239
+ return new Promise((resolve, reject) => {
240
+ const changesFormatted = changes.map((_a) => {
241
+ var rest = __rest(_a, []);
242
+ return rest;
243
+ });
244
+ DataFetcher.get()
245
+ .callGraphQL({
246
+ values: { changes: changesFormatted },
247
+ query: this.templateByQuery.get("saveData"),
248
+ })
249
+ .then((resp) => {
250
+ const dataUnitRecords = [];
251
+ resp === null || resp === void 0 ? void 0 : resp.forEach((responseRecord) => {
252
+ const duRecord = {
253
+ __record__id__: responseRecord.id,
254
+ __record__label__: responseRecord.label,
255
+ __owner__dataunit__name__: responseRecord.ownerDataUnitName,
256
+ };
257
+ const dataUnitInstance = DataUnitStorage.get(duRecord.__owner__dataunit__name__) || dataUnit;
258
+ if (responseRecord.oldId) {
259
+ duRecord.__old__id__ = responseRecord.oldId;
260
+ }
261
+ responseRecord.fields.forEach(({ name, value }) => {
262
+ var _a;
263
+ duRecord[name] = ((_a = dataUnitInstance === null || dataUnitInstance === void 0 ? void 0 : dataUnitInstance.valueFromString) === null || _a === void 0 ? void 0 : _a.call(dataUnitInstance, name, value)) || value;
264
+ });
265
+ dataUnitRecords.push(duRecord);
266
+ });
267
+ resolve(dataUnitRecords);
268
+ })
269
+ .catch((error) => {
270
+ reject(error);
271
+ });
272
+ });
273
+ }
274
+ removeRecords(dataUnit, recordIds) {
275
+ const changes = recordIds.map((recordId) => {
276
+ return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
277
+ });
278
+ return new Promise((resolve, reject) => {
279
+ DataFetcher.get()
280
+ .callGraphQL({
281
+ values: { changes: changes },
282
+ query: this.templateByQuery.get("saveData"),
283
+ })
284
+ .then((_resp) => {
285
+ resolve(recordIds);
286
+ })
287
+ .catch((error) => {
288
+ reject(error);
289
+ });
290
+ });
291
+ }
292
+ loadRecord(dataUnit, recordIds) {
293
+ return new Promise((resolve, reject) => {
294
+ DataFetcher.get()
295
+ .callGraphQL({
296
+ values: { recordID: recordIds, dataunit: dataUnit.name },
297
+ query: this.templateByQuery.get("fetchDataRecord"),
298
+ })
299
+ .then((response) => {
300
+ const dataUnitRecords = [];
301
+ response.record.forEach(responseRecord => {
302
+ const duRecord = { __record__id__: responseRecord.id, __record__label__: responseRecord.label };
303
+ responseRecord.fields.forEach(({ name, value }) => {
304
+ duRecord[name] = dataUnit.valueFromString(name, value);
305
+ });
306
+ dataUnitRecords.push(duRecord);
307
+ });
308
+ resolve(dataUnitRecords);
309
+ })
310
+ .catch((error) => {
311
+ reject(error);
312
+ });
313
+ });
314
+ }
315
+ }
316
+
317
+ export { DataUnitFetcher as D };
@@ -1,5 +1,6 @@
1
1
  /* sankhyablocks custom elements */
2
2
  export { SnkApplication as SnkApplication } from '../types/components/snk-application/snk-application';
3
+ export { SnkAttach as SnkAttach } from '../types/components/snk-attach/snk-attach';
3
4
  export { SnkConfigOptions as SnkConfigOptions } from '../types/components/snk-form/subcomponents/snk-config-options/snk-config-options';
4
5
  export { SnkConfigurator as SnkConfigurator } from '../types/components/snk-configurator/snk-configurator';
5
6
  export { SnkCrud as SnkCrud } from '../types/components/snk-crud/snk-crud';
@@ -1,5 +1,6 @@
1
1
  export { setAssetPath, setNonce, setPlatformOptions } from '@stencil/core/internal/client';
2
2
  export { SnkApplication, defineCustomElement as defineCustomElementSnkApplication } from './snk-application.js';
3
+ export { SnkAttach, defineCustomElement as defineCustomElementSnkAttach } from './snk-attach.js';
3
4
  export { SnkConfigOptions, defineCustomElement as defineCustomElementSnkConfigOptions } from './snk-config-options.js';
4
5
  export { SnkConfigurator, defineCustomElement as defineCustomElementSnkConfigurator } from './snk-configurator.js';
5
6
  export { SnkCrud, defineCustomElement as defineCustomElementSnkCrud } from './snk-crud.js';
@@ -1,9 +1,10 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { WaitingChangeException, WarningException, ErrorException, ObjectUtils, DataUnit, StringUtils, DataType, DataUnitStorage, ChangeOperation, DateUtils, DependencyType, ElementIDUtils, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
2
+ import { WaitingChangeException, WarningException, ErrorException, ObjectUtils, DateUtils, StringUtils, DependencyType, ElementIDUtils, ApplicationContext, ErrorTracking, DataType } from '@sankhyalabs/core';
3
3
  import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher.js';
4
4
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
5
5
  import { P as PesquisaFetcher } from './pesquisa-fetcher.js';
6
6
  import { G as GridConfigFetcher, C as ConfigStorage } from './ConfigStorage.js';
7
+ import { D as DataUnitFetcher } from './dataunit-fetcher.js';
7
8
  import { R as ResourceFetcher } from './form-config-fetcher.js';
8
9
  import { S as SnkMessageBuilder } from './SnkMessageBuilder.js';
9
10
  import { d as defineCustomElement$1 } from './snk-pesquisa2.js';
@@ -116,319 +117,6 @@ class TotalsFetcher {
116
117
  }
117
118
  }
118
119
 
119
- var __rest = (undefined && undefined.__rest) || function (s, e) {
120
- var t = {};
121
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
122
- t[p] = s[p];
123
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
124
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
125
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
126
- t[p[i]] = s[p[i]];
127
- }
128
- return t;
129
- };
130
- class DataUnitFetcher {
131
- constructor() {
132
- this.templateByQuery = new Map();
133
- this._loadDataTimeout = {};
134
- this.buldTemplates();
135
- }
136
- buldTemplates() {
137
- this.templateByQuery.set("fetchDataUnit", dist.gql `query($name: String!) {
138
- $queryAlias$: fetchDataUnit(name: $name){
139
- name
140
- fields{
141
- name
142
- defaultValue
143
- label
144
- visible
145
- readOnly
146
- required
147
- dataType
148
- userInterface
149
- calculated
150
- group
151
- order
152
- properties{
153
- name
154
- value
155
- }
156
- dependencies{
157
- masterFields
158
- type
159
- expression
160
- }
161
- }
162
- children{
163
- name
164
- label
165
- links{
166
- source
167
- target
168
- }
169
- }
170
- }
171
- }`);
172
- this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!] $parentRecordId: String) {
173
- $queryAlias$: fetchDataUnit(name: $dataunit){
174
- data(limit: $limit offset: $offset filters: $filters sort: $sort parentRecordId: $parentRecordId){
175
- limit
176
- offset
177
- total
178
- hasMore
179
- records{
180
- id
181
- label
182
- fields {
183
- name
184
- value
185
- }
186
- }
187
- }
188
- }
189
- }`);
190
- this.templateByQuery.set("saveData", dist.gql `mutation($changes: [InputBatchChange!]!) {
191
- $queryAlias$: batchOperationDataUnit(changes: $changes){
192
- oldId
193
- id
194
- label
195
- ownerDataUnitName
196
- fields {
197
- name
198
- value
199
- }
200
- }
201
- }`);
202
- this.templateByQuery.set("fetchDataRecord", dist.gql `query($dataunit: String! $recordID: [String!]) {
203
- $queryAlias$: fetchDataUnit(name: $dataunit){
204
- record(id: $recordID){
205
- id
206
- label
207
- fields {
208
- name
209
- value
210
- }
211
- }
212
- }
213
- }`);
214
- }
215
- getDataUnit(entityName, resourceID, parentDataUnit) {
216
- const dataUnit = parentDataUnit != undefined ? parentDataUnit.getChildDataunit(`dd://${entityName}/${resourceID}`) : new DataUnit(`dd://${entityName}/${resourceID}`);
217
- dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
218
- dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
219
- dataUnit.saveLoader = (_dataUnit, changes) => this.saveData(dataUnit, changes);
220
- dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
221
- dataUnit.recordLoader = (dataUnit, recordIds) => this.loadRecord(dataUnit, recordIds);
222
- return dataUnit;
223
- }
224
- loadMetadata(dataUnit) {
225
- return new Promise((resolve, reject) => {
226
- DataFetcher.get()
227
- .callGraphQL({
228
- values: { name: dataUnit.name },
229
- query: this.templateByQuery.get("fetchDataUnit"),
230
- })
231
- .then((resp) => {
232
- var _a;
233
- const metadata = {
234
- name: resp.name,
235
- label: resp.name,
236
- children: [...resp.children],
237
- fields: []
238
- };
239
- (_a = resp.fields) === null || _a === void 0 ? void 0 : _a.forEach((source) => {
240
- let properties = undefined;
241
- if (Array.isArray(source.properties)) {
242
- properties = {};
243
- if (source.calculated) {
244
- properties.gridHeaderTooltip = "Campos calculados não podem ser ordenados";
245
- }
246
- source.properties.forEach((prop) => (properties[prop.name] = prop.value));
247
- }
248
- metadata.fields.push(Object.assign(Object.assign({}, source), { properties }));
249
- });
250
- metadata.fields.sort((a, b) => a.order - b.order);
251
- resolve(metadata);
252
- })
253
- .catch((error) => {
254
- reject(error);
255
- });
256
- });
257
- }
258
- loadData(dataUnit, request) {
259
- const duName = dataUnit.name;
260
- if (this._loadDataTimeout[duName]) {
261
- clearTimeout(this._loadDataTimeout[duName]);
262
- delete this._loadDataTimeout[duName];
263
- }
264
- return new Promise((resolve, reject) => {
265
- this._loadDataTimeout[duName] = setTimeout(() => {
266
- delete this._loadDataTimeout[duName];
267
- this.doLoadData(dataUnit, request)
268
- .then(result => resolve(result))
269
- .catch(reason => reject(reason));
270
- }, 200);
271
- });
272
- }
273
- doLoadData(dataUnit, request) {
274
- return new Promise((resolve, reject) => {
275
- var _a;
276
- const { sort, filters, limit, offset, quickFilter } = request;
277
- const variables = { dataunit: dataUnit.name, sort, filters };
278
- variables.limit = limit;
279
- variables.offset = offset;
280
- variables.parentRecordId = request.parentRecordId;
281
- if (!StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
282
- if (variables.filter === undefined) {
283
- variables.filter = [];
284
- }
285
- const quickFilterCriteria = {
286
- name: "__QUICK_FILTER__",
287
- expression: "__QUICK_FILTER__",
288
- params: [{ name: "term", dataType: DataType.TEXT, value: quickFilter.term }]
289
- };
290
- if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
291
- quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: quickFilter.fields });
292
- }
293
- variables.filter.push(quickFilterCriteria);
294
- }
295
- DataFetcher.get()
296
- .callGraphQL({
297
- values: variables,
298
- query: this.templateByQuery.get("fetchData"),
299
- })
300
- .then((resp) => {
301
- const { limit, offset, total, hasMore, records } = resp.data;
302
- let paginationInfo;
303
- if (limit) {
304
- const firstRecord = total == 0 ? 0 : offset + 1;
305
- const lastRecord = offset + Math.min(records.length, limit);
306
- const currentPage = offset / limit;
307
- paginationInfo = {
308
- firstRecord,
309
- lastRecord,
310
- total,
311
- currentPage,
312
- hasMore
313
- };
314
- }
315
- const processedRecords = [];
316
- records.forEach((responseRecord) => {
317
- const duRecord = { __record__id__: responseRecord.id, __record__label__: responseRecord.label };
318
- responseRecord.fields.forEach(({ name, value }) => {
319
- duRecord[name] = dataUnit.valueFromString(name, value);
320
- });
321
- processedRecords.push(duRecord);
322
- });
323
- resolve({
324
- paginationInfo,
325
- records: processedRecords
326
- });
327
- })
328
- .catch((error) => {
329
- reject(error);
330
- });
331
- });
332
- }
333
- saveData(dataUnit, duChanges) {
334
- const changes = duChanges.map((change) => {
335
- const { dataUnit: changeDU, record, updatingFields, operation } = change;
336
- const dataUnitInstance = DataUnitStorage.get(changeDU);
337
- let parsedUpdatingFields;
338
- if (updatingFields) {
339
- parsedUpdatingFields = Object.entries(updatingFields).map(([fieldName, value]) => {
340
- const descriptor = dataUnitInstance.getField(fieldName);
341
- const dataType = descriptor ? descriptor.dataType : DataType.TEXT;
342
- return { fieldName, dataType, value: dataUnitInstance.valueToString(fieldName, value) };
343
- });
344
- }
345
- const reqChange = { dataUnit: changeDU, fields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
346
- if (change.sourceId) {
347
- reqChange.sourceId = change.sourceId;
348
- }
349
- if (record.__parent__record__id__) {
350
- reqChange.parentRecordId = record.__parent__record__id__;
351
- }
352
- return reqChange;
353
- });
354
- return new Promise((resolve, reject) => {
355
- const changesFormatted = changes.map((_a) => {
356
- var rest = __rest(_a, []);
357
- return rest;
358
- });
359
- DataFetcher.get()
360
- .callGraphQL({
361
- values: { changes: changesFormatted },
362
- query: this.templateByQuery.get("saveData"),
363
- })
364
- .then((resp) => {
365
- const dataUnitRecords = [];
366
- resp === null || resp === void 0 ? void 0 : resp.forEach((responseRecord) => {
367
- const duRecord = {
368
- __record__id__: responseRecord.id,
369
- __record__label__: responseRecord.label,
370
- __owner__dataunit__name__: responseRecord.ownerDataUnitName,
371
- };
372
- const dataUnitInstance = DataUnitStorage.get(duRecord.__owner__dataunit__name__) || dataUnit;
373
- if (responseRecord.oldId) {
374
- duRecord.__old__id__ = responseRecord.oldId;
375
- }
376
- responseRecord.fields.forEach(({ name, value }) => {
377
- var _a;
378
- duRecord[name] = ((_a = dataUnitInstance === null || dataUnitInstance === void 0 ? void 0 : dataUnitInstance.valueFromString) === null || _a === void 0 ? void 0 : _a.call(dataUnitInstance, name, value)) || value;
379
- });
380
- dataUnitRecords.push(duRecord);
381
- });
382
- resolve(dataUnitRecords);
383
- })
384
- .catch((error) => {
385
- reject(error);
386
- });
387
- });
388
- }
389
- removeRecords(dataUnit, recordIds) {
390
- const changes = recordIds.map((recordId) => {
391
- return { dataUnit: dataUnit.name, operation: ChangeOperation.DELETE, recordId };
392
- });
393
- return new Promise((resolve, reject) => {
394
- DataFetcher.get()
395
- .callGraphQL({
396
- values: { changes: changes },
397
- query: this.templateByQuery.get("saveData"),
398
- })
399
- .then((_resp) => {
400
- resolve(recordIds);
401
- })
402
- .catch((error) => {
403
- reject(error);
404
- });
405
- });
406
- }
407
- loadRecord(dataUnit, recordIds) {
408
- return new Promise((resolve, reject) => {
409
- DataFetcher.get()
410
- .callGraphQL({
411
- values: { recordID: recordIds, dataunit: dataUnit.name },
412
- query: this.templateByQuery.get("fetchDataRecord"),
413
- })
414
- .then((response) => {
415
- const dataUnitRecords = [];
416
- response.record.forEach(responseRecord => {
417
- const duRecord = { __record__id__: responseRecord.id, __record__label__: responseRecord.label };
418
- responseRecord.fields.forEach(({ name, value }) => {
419
- duRecord[name] = dataUnit.valueFromString(name, value);
420
- });
421
- dataUnitRecords.push(duRecord);
422
- });
423
- resolve(dataUnitRecords);
424
- })
425
- .catch((error) => {
426
- reject(error);
427
- });
428
- });
429
- }
430
- }
431
-
432
120
  var _a;
433
121
  class Workspace {
434
122
  static openAppActivity(resourceId, pkObject) {
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SnkAttach extends Components.SnkAttach, HTMLElement {}
4
+ export const SnkAttach: {
5
+ prototype: SnkAttach;
6
+ new (): SnkAttach;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { S as SnkAttach$1, d as defineCustomElement$1 } from './snk-attach2.js';
2
+
3
+ const SnkAttach = SnkAttach$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { SnkAttach, defineCustomElement };