@sankhyalabs/sankhyablocks 5.9.2 → 5.10.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 (128) hide show
  1. package/dist/cjs/{ConfigStorage-91adf3fe.js → ConfigStorage-f68c3607.js} +5 -71
  2. package/dist/cjs/{SnkFormConfigManager-e1a10283.js → SnkFormConfigManager-69df3f74.js} +2 -2
  3. package/dist/cjs/{SnkMessageBuilder-1760d2c9.js → SnkMessageBuilder-cf80308c.js} +6 -1
  4. package/dist/cjs/filter-bar-config-fetcher-a14536bf.js +115 -0
  5. package/dist/cjs/{form-config-fetcher-fa19680a.js → form-config-fetcher-92bc8fe7.js} +2 -65
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/resource-fetcher-2979b54b.js +68 -0
  8. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  9. package/dist/cjs/snk-application.cjs.entry.js +7 -4
  10. package/dist/cjs/snk-data-exporter.cjs.entry.js +4 -4
  11. package/dist/cjs/{snk-data-unit-f27603c9.js → snk-data-unit-bd271acd.js} +1 -1
  12. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-detail-view.cjs.entry.js +8 -5
  14. package/dist/cjs/snk-entity-list.cjs.entry.js +111 -0
  15. package/dist/cjs/snk-filter-bar.cjs.entry.js +4 -2
  16. package/dist/cjs/snk-filter-detail.cjs.entry.js +44 -3
  17. package/dist/cjs/snk-filter-item.cjs.entry.js +9 -4
  18. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +30 -2
  19. package/dist/cjs/snk-filter-modal.cjs.entry.js +26 -3
  20. package/dist/cjs/snk-form-config.cjs.entry.js +2 -1
  21. package/dist/cjs/snk-form.cjs.entry.js +6 -3
  22. package/dist/cjs/snk-grid-config.cjs.entry.js +5 -2
  23. package/dist/cjs/snk-grid.cjs.entry.js +12 -8
  24. package/dist/cjs/{snk-guides-viewer-5f2eb52b.js → snk-guides-viewer-b2d40bc4.js} +1 -1
  25. package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -4
  26. package/dist/collection/collection-manifest.json +1 -0
  27. package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +2 -2
  28. package/dist/collection/components/snk-entity-list/snk-entity-list.css +35 -0
  29. package/dist/collection/components/snk-entity-list/snk-entity-list.js +250 -0
  30. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +45 -4
  31. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +9 -4
  32. package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +26 -3
  33. package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +28 -3
  34. package/dist/collection/components/snk-grid/snk-grid.js +7 -6
  35. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +48 -5
  36. package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
  37. package/dist/collection/lib/message/resources/snk-entity-list.msg.js +3 -0
  38. package/dist/components/ConfigStorage.js +3 -69
  39. package/dist/components/SnkMessageBuilder.js +6 -1
  40. package/dist/components/filter-bar-config-fetcher.js +113 -0
  41. package/dist/components/form-config-fetcher.js +2 -64
  42. package/dist/components/index.d.ts +1 -0
  43. package/dist/components/index.js +1 -0
  44. package/dist/components/resource-fetcher.js +66 -0
  45. package/dist/components/snk-application2.js +1 -1
  46. package/dist/components/snk-data-exporter2.js +2 -2
  47. package/dist/components/snk-entity-list.d.ts +11 -0
  48. package/dist/components/snk-entity-list.js +131 -0
  49. package/dist/components/snk-filter-detail2.js +42 -4
  50. package/dist/components/snk-filter-item2.js +9 -4
  51. package/dist/components/snk-filter-modal-item2.js +28 -3
  52. package/dist/components/snk-filter-modal.js +26 -3
  53. package/dist/components/snk-grid2.js +7 -6
  54. package/dist/esm/{ConfigStorage-ac77ff39.js → ConfigStorage-e6c17998.js} +3 -69
  55. package/dist/esm/{SnkFormConfigManager-40609500.js → SnkFormConfigManager-e60367a0.js} +2 -2
  56. package/dist/esm/{SnkMessageBuilder-4caf8b4f.js → SnkMessageBuilder-1a169545.js} +6 -1
  57. package/dist/esm/filter-bar-config-fetcher-edc48f4b.js +113 -0
  58. package/dist/esm/{form-config-fetcher-018e7e73.js → form-config-fetcher-cac8cd96.js} +2 -64
  59. package/dist/esm/loader.js +1 -1
  60. package/dist/esm/resource-fetcher-02642924.js +66 -0
  61. package/dist/esm/sankhyablocks.js +1 -1
  62. package/dist/esm/snk-application.entry.js +6 -3
  63. package/dist/esm/snk-data-exporter.entry.js +4 -4
  64. package/dist/esm/{snk-data-unit-640399b3.js → snk-data-unit-476024e9.js} +1 -1
  65. package/dist/esm/snk-data-unit.entry.js +2 -2
  66. package/dist/esm/snk-detail-view.entry.js +8 -5
  67. package/dist/esm/snk-entity-list.entry.js +107 -0
  68. package/dist/esm/snk-filter-bar.entry.js +4 -2
  69. package/dist/esm/snk-filter-detail.entry.js +45 -4
  70. package/dist/esm/snk-filter-item.entry.js +9 -4
  71. package/dist/esm/snk-filter-modal-item.entry.js +31 -3
  72. package/dist/esm/snk-filter-modal.entry.js +26 -3
  73. package/dist/esm/snk-form-config.entry.js +2 -1
  74. package/dist/esm/snk-form.entry.js +6 -3
  75. package/dist/esm/snk-grid-config.entry.js +5 -2
  76. package/dist/esm/snk-grid.entry.js +12 -8
  77. package/dist/esm/{snk-guides-viewer-11ca46dc.js → snk-guides-viewer-11a02781.js} +1 -1
  78. package/dist/esm/snk-guides-viewer.entry.js +7 -4
  79. package/dist/sankhyablocks/p-0409d41b.entry.js +1 -0
  80. package/dist/sankhyablocks/p-1c5d5e5c.entry.js +1 -0
  81. package/dist/sankhyablocks/p-1c836fad.entry.js +1 -0
  82. package/dist/sankhyablocks/p-1e6a95f5.entry.js +1 -0
  83. package/dist/sankhyablocks/p-2ea933b2.js +17 -0
  84. package/dist/sankhyablocks/{p-6981c03e.js → p-3e17b147.js} +1 -1
  85. package/dist/sankhyablocks/p-471568c7.entry.js +1 -0
  86. package/dist/sankhyablocks/p-4eae2812.entry.js +1 -0
  87. package/dist/sankhyablocks/p-554e2f83.entry.js +1 -0
  88. package/dist/sankhyablocks/p-587bd851.entry.js +1 -0
  89. package/dist/sankhyablocks/p-656eab86.entry.js +1 -0
  90. package/dist/sankhyablocks/p-6c2c71ca.js +1 -0
  91. package/dist/sankhyablocks/p-78de64fb.entry.js +1 -0
  92. package/dist/sankhyablocks/p-79f78e10.js +10 -0
  93. package/dist/sankhyablocks/{p-7f2e267a.js → p-7f0afee1.js} +1 -1
  94. package/dist/sankhyablocks/p-b1c02726.js +1 -0
  95. package/dist/sankhyablocks/{p-e0aa5838.js → p-b25450ab.js} +1 -1
  96. package/dist/sankhyablocks/p-c20dd153.entry.js +1 -0
  97. package/dist/sankhyablocks/{p-29c1889f.js → p-c74fca58.js} +1 -1
  98. package/dist/sankhyablocks/p-c8095917.entry.js +1 -0
  99. package/dist/sankhyablocks/p-c842c6f1.entry.js +1 -0
  100. package/dist/sankhyablocks/p-e642bf7a.entry.js +1 -0
  101. package/dist/sankhyablocks/{p-57b74971.entry.js → p-f5e607e7.entry.js} +3 -3
  102. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  103. package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +1 -1
  104. package/dist/types/components/snk-entity-list/snk-entity-list.d.ts +48 -0
  105. package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +2 -0
  106. package/dist/types/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.d.ts +6 -0
  107. package/dist/types/components.d.ts +54 -2
  108. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +1 -0
  109. package/dist/types/lib/message/resources/snk-entity-list.msg.d.ts +1 -0
  110. package/package.json +1 -1
  111. package/react/components.d.ts +1 -0
  112. package/react/components.js +1 -0
  113. package/react/components.js.map +1 -1
  114. package/dist/sankhyablocks/p-08779202.entry.js +0 -1
  115. package/dist/sankhyablocks/p-0bb49e4a.entry.js +0 -1
  116. package/dist/sankhyablocks/p-0d81236c.js +0 -26
  117. package/dist/sankhyablocks/p-355e7ab0.entry.js +0 -1
  118. package/dist/sankhyablocks/p-3794686e.entry.js +0 -1
  119. package/dist/sankhyablocks/p-4181c36d.entry.js +0 -1
  120. package/dist/sankhyablocks/p-52ed2a18.js +0 -1
  121. package/dist/sankhyablocks/p-59705471.entry.js +0 -1
  122. package/dist/sankhyablocks/p-6f0b3cc0.entry.js +0 -1
  123. package/dist/sankhyablocks/p-747ea2c3.entry.js +0 -1
  124. package/dist/sankhyablocks/p-7621806d.entry.js +0 -1
  125. package/dist/sankhyablocks/p-86f75e7a.entry.js +0 -1
  126. package/dist/sankhyablocks/p-9043c45f.entry.js +0 -1
  127. package/dist/sankhyablocks/p-b9fb86fe.entry.js +0 -1
  128. package/dist/sankhyablocks/p-c7ee03cd.entry.js +0 -1
@@ -1,5 +1,7 @@
1
1
  import { ApplicationContext } from '@sankhyalabs/core';
2
- import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher.js';
2
+ import { F as FormConfigFetcher } from './form-config-fetcher.js';
3
+ import { R as ResourceFetcher } from './resource-fetcher.js';
4
+ import { F as FilterBarConfigFetcher } from './filter-bar-config-fetcher.js';
3
5
 
4
6
  class GridConfigFetcher extends ResourceFetcher {
5
7
  constructor() {
@@ -41,74 +43,6 @@ class GridConfigFetcher extends ResourceFetcher {
41
43
  }
42
44
  }
43
45
 
44
- function normalizeValue(value) {
45
- if (value == undefined) {
46
- return value;
47
- }
48
- if (value instanceof Date) {
49
- return value.toISOString();
50
- }
51
- if (typeof value === "object") {
52
- if (value instanceof Array) {
53
- return value.map(item => normalizeValue(item));
54
- }
55
- else {
56
- const normalized = Object.assign({}, value);
57
- Object.keys(value).forEach(prop => {
58
- if (value[prop]) {
59
- normalized[prop] = normalizeValue(value[prop]);
60
- }
61
- else {
62
- delete normalized[prop];
63
- }
64
- });
65
- return normalized;
66
- }
67
- }
68
- return value;
69
- }
70
- class FilterBarConfigFetcher extends ResourceFetcher {
71
- saveConfig(items, resourceID, configName) {
72
- const state = items.map(item => {
73
- const { id, value, fixed, visible } = item;
74
- const stateItem = { id };
75
- if (value) {
76
- stateItem["value"] = normalizeValue(value);
77
- }
78
- if (fixed) {
79
- stateItem["fixed"] = fixed;
80
- }
81
- if (visible) {
82
- stateItem["visible"] = true;
83
- }
84
- return stateItem;
85
- });
86
- return this.saveResource(state, this.getPath(resourceID, configName));
87
- }
88
- getConfig(resourceID, configName) {
89
- return new Promise((accept, reject) => {
90
- this.loadResource(this.getPath(resourceID, configName))
91
- .then((configAsString) => {
92
- let fieldsList;
93
- if (configAsString) {
94
- const filterBarConfig = JSON.parse(configAsString);
95
- fieldsList = filterBarConfig.items;
96
- }
97
- accept(fieldsList || []);
98
- })
99
- .catch((error) => {
100
- reject(error);
101
- });
102
- });
103
- }
104
- getPath(resourceID, name) {
105
- if (name) {
106
- return `cfg://filter/FilterBarState:${resourceID}/${name}`;
107
- }
108
- return `cfg://filter/FilterBarState:${resourceID}`;
109
- }
110
- }
111
-
112
46
  const CONFIG_SOURCE = {
113
47
  form: "form",
114
48
  grid: "grid",
@@ -338,6 +338,10 @@ const snkPersonalizedFilterMessages = {
338
338
  }
339
339
  };
340
340
 
341
+ const snkEntityListMessages = {
342
+ selected: "Selecionados:"
343
+ };
344
+
341
345
  class SnkMessageBuilder {
342
346
  constructor(domainName) {
343
347
  this._defaults = {
@@ -360,7 +364,8 @@ class SnkMessageBuilder {
360
364
  snkFilterFieldSearch: snkFilterFieldSearchMessages,
361
365
  snkSimpleBar: snkSimpleBarMessages,
362
366
  snkAttach: snkAttachMessages,
363
- snkPersonalizedFilter: snkPersonalizedFilterMessages
367
+ snkPersonalizedFilter: snkPersonalizedFilterMessages,
368
+ snkEntityList: snkEntityListMessages
364
369
  };
365
370
  this._currentOperation = OperationMap.CLEAN;
366
371
  this._domainName = domainName;
@@ -0,0 +1,113 @@
1
+ import { F as FilterItemType } from './filter-item-type.enum.js';
2
+ import { R as ResourceFetcher } from './resource-fetcher.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
+ function normalizeValue(value, type) {
16
+ if (value == undefined) {
17
+ return value;
18
+ }
19
+ if (value instanceof Date) {
20
+ return value.toISOString();
21
+ }
22
+ if (typeof value === "object") {
23
+ if (value instanceof Array) {
24
+ return value.map(item => {
25
+ if (FilterItemType.MULTI_LIST === type) {
26
+ const values = __rest(item, ["label"]);
27
+ return normalizeValue(values);
28
+ }
29
+ return normalizeValue(item);
30
+ });
31
+ }
32
+ else {
33
+ const normalized = Object.assign({}, value);
34
+ Object.keys(value).forEach(prop => {
35
+ if (value[prop]) {
36
+ normalized[prop] = normalizeValue(value[prop], type);
37
+ }
38
+ else {
39
+ delete normalized[prop];
40
+ }
41
+ });
42
+ return normalized;
43
+ }
44
+ }
45
+ return value;
46
+ }
47
+ class FilterBarConfigFetcher extends ResourceFetcher {
48
+ saveConfig(items, resourceID, configName) {
49
+ const state = items.map(item => {
50
+ const { id, value, fixed, visible, type } = item;
51
+ const stateItem = { id };
52
+ if (value) {
53
+ stateItem["value"] = normalizeValue(value, type);
54
+ }
55
+ if (fixed) {
56
+ stateItem["fixed"] = fixed;
57
+ }
58
+ if (visible) {
59
+ stateItem["visible"] = true;
60
+ }
61
+ return stateItem;
62
+ });
63
+ return this.saveResource(state, this.getPath(resourceID, configName));
64
+ }
65
+ getConfig(resourceID, configName) {
66
+ return new Promise((accept, reject) => {
67
+ this.loadResource(this.getPath(resourceID, configName))
68
+ .then((configAsString) => {
69
+ let fieldsList;
70
+ if (configAsString) {
71
+ const filterBarConfig = JSON.parse(configAsString);
72
+ fieldsList = filterBarConfig.items;
73
+ }
74
+ accept(fieldsList || []);
75
+ })
76
+ .catch((error) => {
77
+ reject(error);
78
+ });
79
+ });
80
+ }
81
+ saveEntityListConfig(item, resourceID, configName) {
82
+ return new Promise((accept, reject) => {
83
+ this.getConfig(resourceID, configName).then(config => {
84
+ const state = config.map(({ id, value, fixed, visible, type }) => {
85
+ return Object.assign(Object.assign(Object.assign({ id }, (value && { value: normalizeValue(value, type) })), (fixed && { fixed })), (visible && { visible: true }));
86
+ });
87
+ const index = state.findIndex(({ id }) => id === item.id);
88
+ const newItem = { id: item.id, value: normalizeValue(item.value, item.type), fixed: item.fixed, visible: true };
89
+ if (index > -1) {
90
+ state[index] = newItem;
91
+ }
92
+ else {
93
+ state.push(newItem);
94
+ }
95
+ this.saveResource(state, this.getPath(resourceID, configName)).then(resp => {
96
+ accept(resp);
97
+ }).catch(exception => {
98
+ reject(exception);
99
+ });
100
+ }).catch(exception => {
101
+ reject(exception);
102
+ });
103
+ });
104
+ }
105
+ getPath(resourceID, name) {
106
+ if (name) {
107
+ return `cfg://filter/FilterBarState:${resourceID}/${name}`;
108
+ }
109
+ return `cfg://filter/FilterBarState:${resourceID}`;
110
+ }
111
+ }
112
+
113
+ export { FilterBarConfigFetcher as F };
@@ -1,68 +1,6 @@
1
1
  import { d as dist, D as DataFetcher } from './DataFetcher.js';
2
2
  import { ObjectUtils } from '@sankhyalabs/core';
3
-
4
- class ResourceFetcher {
5
- constructor() {
6
- this.templateByQuery = new Map();
7
- this.buldTemplates();
8
- }
9
- buldTemplates() {
10
- this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
11
- $queryAlias$: fetchResource(name: $name){
12
- resource
13
- }
14
- }`);
15
- this.templateByQuery.set("saveResource", dist.gql `mutation($resource: InputResource!) {
16
- $queryAlias$: saveResource(resource: $resource){
17
- name
18
- resource
19
- }
20
- }`);
21
- }
22
- loadResource(name) {
23
- if (ResourceFetcher._loadingResource.has(name)) {
24
- return ResourceFetcher._loadingResource.get(name);
25
- }
26
- const promiseLoadResource = new Promise((resolve, reject) => {
27
- DataFetcher.get()
28
- .callGraphQL({
29
- values: { name },
30
- query: this.templateByQuery.get("fetchResource"),
31
- })
32
- .then((result) => {
33
- resolve(result === null || result === void 0 ? void 0 : result.resource);
34
- ResourceFetcher._loadingResource.delete(name);
35
- })
36
- .catch((error) => {
37
- reject(error);
38
- ResourceFetcher._loadingResource.delete(name);
39
- });
40
- });
41
- ResourceFetcher._loadingResource.set(name, promiseLoadResource);
42
- return promiseLoadResource;
43
- }
44
- saveResource(resource, name) {
45
- return new Promise((resolve, reject) => {
46
- DataFetcher.get()
47
- .callGraphQL({
48
- values: {
49
- resource: {
50
- name: name,
51
- resource: JSON.stringify(resource)
52
- }
53
- },
54
- query: this.templateByQuery.get("saveResource")
55
- })
56
- .then((resp) => {
57
- resolve(resp);
58
- })
59
- .catch((error) => {
60
- reject(error);
61
- });
62
- });
63
- }
64
- }
65
- ResourceFetcher._loadingResource = new Map();
3
+ import { R as ResourceFetcher } from './resource-fetcher.js';
66
4
 
67
5
  class FormConfigFetcher extends ResourceFetcher {
68
6
  constructor() {
@@ -238,4 +176,4 @@ var UserConfigType;
238
176
  UserConfigType["SHARED"] = "SHARED";
239
177
  })(UserConfigType || (UserConfigType = {}));
240
178
 
241
- export { FormConfigFetcher as F, ResourceFetcher as R, UserConfigType as U };
179
+ export { FormConfigFetcher as F, UserConfigType as U };
@@ -7,6 +7,7 @@ export { SnkCrud as SnkCrud } from '../types/components/snk-crud/snk-crud';
7
7
  export { SnkDataExporter as SnkDataExporter } from '../types/components/snk-data-exporter/snk-data-exporter';
8
8
  export { SnkDataUnit as SnkDataUnit } from '../types/components/snk-data-unit/snk-data-unit';
9
9
  export { SnkDetailView as SnkDetailView } from '../types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view';
10
+ export { SnkEntityList as SnkEntityList } from '../types/components/snk-entity-list/snk-entity-list';
10
11
  export { SnkExporterEmailSender as SnkExporterEmailSender } from '../types/components/snk-data-exporter/exporter-email-sender/snk-exporter-email-sender';
11
12
  export { SnkExpressionItem as SnkExpressionItem } from '../types/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item';
12
13
  export { SnkFieldConfig as SnkFieldConfig } from '../types/components/snk-form/subcomponents/snk-field-config/snk-field-config';
@@ -7,6 +7,7 @@ export { SnkCrud, defineCustomElement as defineCustomElementSnkCrud } from './sn
7
7
  export { SnkDataExporter, defineCustomElement as defineCustomElementSnkDataExporter } from './snk-data-exporter.js';
8
8
  export { SnkDataUnit, defineCustomElement as defineCustomElementSnkDataUnit } from './snk-data-unit.js';
9
9
  export { SnkDetailView, defineCustomElement as defineCustomElementSnkDetailView } from './snk-detail-view.js';
10
+ export { SnkEntityList, defineCustomElement as defineCustomElementSnkEntityList } from './snk-entity-list.js';
10
11
  export { SnkExporterEmailSender, defineCustomElement as defineCustomElementSnkExporterEmailSender } from './snk-exporter-email-sender.js';
11
12
  export { SnkExpressionItem, defineCustomElement as defineCustomElementSnkExpressionItem } from './snk-expression-item.js';
12
13
  export { SnkFieldConfig, defineCustomElement as defineCustomElementSnkFieldConfig } from './snk-field-config.js';
@@ -0,0 +1,66 @@
1
+ import { d as dist, D as DataFetcher } from './DataFetcher.js';
2
+
3
+ class ResourceFetcher {
4
+ constructor() {
5
+ this.templateByQuery = new Map();
6
+ this.buldTemplates();
7
+ }
8
+ buldTemplates() {
9
+ this.templateByQuery.set("fetchResource", dist.gql `query($name: String!) {
10
+ $queryAlias$: fetchResource(name: $name){
11
+ resource
12
+ }
13
+ }`);
14
+ this.templateByQuery.set("saveResource", dist.gql `mutation($resource: InputResource!) {
15
+ $queryAlias$: saveResource(resource: $resource){
16
+ name
17
+ resource
18
+ }
19
+ }`);
20
+ }
21
+ loadResource(name) {
22
+ if (ResourceFetcher._loadingResource.has(name)) {
23
+ return ResourceFetcher._loadingResource.get(name);
24
+ }
25
+ const promiseLoadResource = new Promise((resolve, reject) => {
26
+ DataFetcher.get()
27
+ .callGraphQL({
28
+ values: { name },
29
+ query: this.templateByQuery.get("fetchResource"),
30
+ })
31
+ .then((result) => {
32
+ resolve(result === null || result === void 0 ? void 0 : result.resource);
33
+ ResourceFetcher._loadingResource.delete(name);
34
+ })
35
+ .catch((error) => {
36
+ reject(error);
37
+ ResourceFetcher._loadingResource.delete(name);
38
+ });
39
+ });
40
+ ResourceFetcher._loadingResource.set(name, promiseLoadResource);
41
+ return promiseLoadResource;
42
+ }
43
+ saveResource(resource, name) {
44
+ return new Promise((resolve, reject) => {
45
+ DataFetcher.get()
46
+ .callGraphQL({
47
+ values: {
48
+ resource: {
49
+ name: name,
50
+ resource: JSON.stringify(resource)
51
+ }
52
+ },
53
+ query: this.templateByQuery.get("saveResource")
54
+ })
55
+ .then((resp) => {
56
+ resolve(resp);
57
+ })
58
+ .catch((error) => {
59
+ reject(error);
60
+ });
61
+ });
62
+ }
63
+ }
64
+ ResourceFetcher._loadingResource = new Map();
65
+
66
+ export { ResourceFetcher as R };
@@ -5,7 +5,7 @@ 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
7
  import { D as DataUnitFetcher } from './dataunit-fetcher.js';
8
- import { R as ResourceFetcher } from './form-config-fetcher.js';
8
+ import { R as ResourceFetcher } from './resource-fetcher.js';
9
9
  import { S as SnkMessageBuilder } from './SnkMessageBuilder.js';
10
10
  import { d as defineCustomElement$1 } from './snk-pesquisa2.js';
11
11
 
@@ -305,12 +305,12 @@ const SnkDataExporter = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
305
305
  controlDropdown() {
306
306
  this._showDropdown = !this._showDropdown;
307
307
  }
308
- resolveExporter(resolveProps, callbackResolver) {
308
+ async resolveExporter(resolveProps, callbackResolver) {
309
309
  if (this.provider == undefined || resolveProps == undefined || callbackResolver == undefined) {
310
310
  return;
311
311
  }
312
312
  const filters = this.provider.getFilters();
313
- const columns = this.provider.getColumnsMetadata();
313
+ const columns = await this.provider.getColumnsMetadata();
314
314
  const sort = this.provider.getOrders();
315
315
  const resourceURI = this.provider.getResourceURI();
316
316
  const selectedIDs = this.provider.getSelectedIDs();
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SnkEntityList extends Components.SnkEntityList, HTMLElement {}
4
+ export const SnkEntityList: {
5
+ prototype: SnkEntityList;
6
+ new (): SnkEntityList;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,131 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { ApplicationContext } from '@sankhyalabs/core';
3
+
4
+ const snkEntityListCss = ".sc-snk-entity-list-h{--snk-entity-list--label--font-size:var(--text--medium, 14px);--snk-entity-list--label--font-family:var(--font-pattern, Arial);--snk-entity-list--label--color:var(--title--primary, #000);--snk-entity-list--label--disabled--color:var(--text--disable, #AFB6C0)}.label.sc-snk-entity-list{flex-shrink:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--snk-entity-list--label--color);font-size:var(--snk-entity-list--label--font-size);font-family:var(--snk-entity-list--label--font-family);cursor:default;padding-left:var(--space--small);padding-bottom:var(--space--extra-small)}.snk-entity-list--overflow.sc-snk-entity-list{overflow:auto}.snk-entity-list--overflow.sc-snk-entity-list::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";
5
+
6
+ const SnkEntityList$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this.__registerHost();
10
+ this.valueChanged = createEvent(this, "valueChanged", 7);
11
+ this.saveConfig = createEvent(this, "saveConfig", 7);
12
+ this._searchValue = undefined;
13
+ this._ezListSource = [];
14
+ this.config = undefined;
15
+ this.rightListSlotBuilder = undefined;
16
+ this.maxHeightList = "";
17
+ }
18
+ async reloadList() {
19
+ this.loadListSource();
20
+ this.saveConfig.emit(this.config);
21
+ }
22
+ observeConfig() {
23
+ var _a, _b;
24
+ (_b = (_a = this._searchElement) === null || _a === void 0 ? void 0 : _a['clearValue']) === null || _b === void 0 ? void 0 : _b.call(_a);
25
+ }
26
+ ezListChangeListener(evt) {
27
+ var _a, _b, _c, _d;
28
+ (_c = ((_a = this.config.value) !== null && _a !== void 0 ? _a : (_b = this.config.value) === null || _b === void 0 ? void 0 : _b.elements)) === null || _c === void 0 ? void 0 : _c.forEach(value => {
29
+ var _a, _b;
30
+ if (value && value.id === ((_a = evt.detail) === null || _a === void 0 ? void 0 : _a.id)) {
31
+ value.check = (_b = evt.detail) === null || _b === void 0 ? void 0 : _b.check;
32
+ }
33
+ });
34
+ this.saveConfig.emit(this.config);
35
+ this.valueChanged.emit((_d = this.config) === null || _d === void 0 ? void 0 : _d.value);
36
+ }
37
+ loadListSource() {
38
+ var _a, _b, _c, _d, _e, _f, _g, _h;
39
+ this._ezListSource = [];
40
+ (_h = ((_e = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : (_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.elements) !== null && _e !== void 0 ? _e : (_g = (_f = this.config) === null || _f === void 0 ? void 0 : _f.value) === null || _g === void 0 ? void 0 : _g.members)) === null || _h === void 0 ? void 0 : _h.forEach(value => {
41
+ if (value) {
42
+ this._ezListSource.push({
43
+ label: `${value.id} - ${value.label}`,
44
+ check: value.check,
45
+ id: value.id
46
+ });
47
+ }
48
+ });
49
+ }
50
+ componentDidLoad() {
51
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
52
+ let configValue = (_f = (_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.elements) !== null && _c !== void 0 ? _c : (_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.value) === null || _e === void 0 ? void 0 : _e.members) !== null && _f !== void 0 ? _f : (_g = this.config) === null || _g === void 0 ? void 0 : _g.value;
53
+ let configValueArray = [];
54
+ if (Array.isArray(configValue)) {
55
+ configValueArray = configValue;
56
+ }
57
+ else {
58
+ configValueArray.push((_j = (_h = this.config) === null || _h === void 0 ? void 0 : _h.value) === null || _j === void 0 ? void 0 : _j.members);
59
+ }
60
+ this.config.value = configValueArray;
61
+ this._entityName = (_m = (_l = (_k = this.config) === null || _k === void 0 ? void 0 : _k.props) === null || _l === void 0 ? void 0 : _l.searchContext) === null || _m === void 0 ? void 0 : _m.entity;
62
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
63
+ this.loadListSource();
64
+ }
65
+ optionLoader({ mode, argument }) {
66
+ var _a, _b, _c, _d;
67
+ if (this._application === undefined) {
68
+ return;
69
+ }
70
+ const searchOptions = (_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.searchContext) === null || _c === void 0 ? void 0 : _c.searchOptions;
71
+ const options = {
72
+ entityDescription: (_d = this.config) === null || _d === void 0 ? void 0 : _d.label,
73
+ entity: this._entityName,
74
+ searchOptions: searchOptions
75
+ };
76
+ return this._application.executePreparedSearch(mode, argument, options);
77
+ }
78
+ onEzSearchChange(evt) {
79
+ var _a, _b, _c, _d, _e, _f, _g, _h;
80
+ if (evt.detail != undefined && ((_e = ((_c = (_a = this.config.value) !== null && _a !== void 0 ? _a : (_b = this.config.value) === null || _b === void 0 ? void 0 : _b.elements) !== null && _c !== void 0 ? _c : (_d = this.config.value) === null || _d === void 0 ? void 0 : _d.members)) === null || _e === void 0 ? void 0 : _e.find(i => { var _a; return (i === null || i === void 0 ? void 0 : i.id) == ((_a = evt.detail) === null || _a === void 0 ? void 0 : _a.value); })) === undefined) {
81
+ this.config = Object.assign(Object.assign({}, this.config), { value: [
82
+ ...((_g = (_f = this.config) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : []),
83
+ {
84
+ id: evt.detail.value,
85
+ check: true,
86
+ label: evt.detail.label
87
+ }
88
+ ] });
89
+ this.loadListSource();
90
+ this.saveConfig.emit(this.config);
91
+ this.valueChanged.emit((_h = this.config) === null || _h === void 0 ? void 0 : _h.value);
92
+ }
93
+ }
94
+ getMessage(key, params) {
95
+ var _a;
96
+ return (_a = this._application) === null || _a === void 0 ? void 0 : _a.messagesBuilder.getMessage(key, params);
97
+ }
98
+ render() {
99
+ var _a;
100
+ return (h(Host, null, h("ez-search", { ref: elem => this._searchElement = elem, optionLoader: argument => this.optionLoader(argument), value: this._searchValue, label: (_a = this.config) === null || _a === void 0 ? void 0 : _a.label, onEzChange: evt => this.onEzSearchChange(evt) }), h("label", { class: "label" }, this.getMessage("snkEntityList.selected")), h("div", { style: this.maxHeightList ? { 'max-height': this.maxHeightList } : {}, class: { "snk-entity-list--overflow": !!this.maxHeightList } }, h("ez-list", { ref: (el) => this._ezList = el, id: "snkEntityList", listMode: "check", dataSource: this._ezListSource, hoverFeedback: true, itemSlotBuilder: this.rightListSlotBuilder, onEzCheckChange: evt => this.ezListChangeListener(evt) }))));
101
+ }
102
+ static get watchers() { return {
103
+ "config": ["observeConfig"]
104
+ }; }
105
+ static get style() { return snkEntityListCss; }
106
+ }, [2, "snk-entity-list", {
107
+ "config": [1040],
108
+ "rightListSlotBuilder": [1040],
109
+ "maxHeightList": [1, "max-height-list"],
110
+ "_searchValue": [32],
111
+ "_ezListSource": [32],
112
+ "reloadList": [64]
113
+ }]);
114
+ function defineCustomElement$1() {
115
+ if (typeof customElements === "undefined") {
116
+ return;
117
+ }
118
+ const components = ["snk-entity-list"];
119
+ components.forEach(tagName => { switch (tagName) {
120
+ case "snk-entity-list":
121
+ if (!customElements.get(tagName)) {
122
+ customElements.define(tagName, SnkEntityList$1);
123
+ }
124
+ break;
125
+ } });
126
+ }
127
+
128
+ const SnkEntityList = SnkEntityList$1;
129
+ const defineCustomElement = defineCustomElement$1;
130
+
131
+ export { SnkEntityList, defineCustomElement };
@@ -1,7 +1,8 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Fragment, Host } from '@stencil/core/internal/client';
2
2
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
3
3
  import { F as FilterItemType } from './filter-item-type.enum.js';
4
- import { ElementIDUtils, DataType } from '@sankhyalabs/core';
4
+ import { ApplicationContext, ElementIDUtils, DataType } from '@sankhyalabs/core';
5
+ import { F as FilterBarConfigFetcher } from './filter-bar-config-fetcher.js';
5
6
 
6
7
  const SnkFilterDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
8
  constructor() {
@@ -16,10 +17,15 @@ const SnkFilterDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
16
17
  */
17
18
  async show() {
18
19
  var _a, _b;
19
- (_b = (_a = this._editor)["show"]) === null || _b === void 0 ? void 0 : _b.call(_a);
20
+ (_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a["show"]) === null || _b === void 0 ? void 0 : _b.call(_a);
21
+ }
22
+ observeConfig() {
23
+ var _a, _b;
24
+ (_b = (_a = this._editor) === null || _a === void 0 ? void 0 : _a["reloadList"]) === null || _b === void 0 ? void 0 : _b.call(_a);
20
25
  }
21
26
  componentDidLoad() {
22
27
  if (this._element) {
28
+ this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
23
29
  ElementIDUtils.addIDInfo(this._element);
24
30
  const dataElementIdDoFilterItem = this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
25
31
  this._idContentEditor = `${dataElementIdDoFilterItem}_${this.config.id}`;
@@ -42,6 +48,8 @@ const SnkFilterDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
42
48
  return "snk-filter-number";
43
49
  case FilterItemType.PERSONALIZED:
44
50
  return "snk-filter-personalized";
51
+ case FilterItemType.MULTI_LIST:
52
+ return "snk-entity-list";
45
53
  }
46
54
  return "snk-filter-text";
47
55
  }
@@ -112,18 +120,48 @@ const SnkFilterDetail = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
112
120
  }
113
121
  /* WARNING: Temporário.*/
114
122
  clear() {
115
- this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined }));
123
+ var _a, _b;
124
+ if (FilterItemType.MULTI_LIST === this.config.type) {
125
+ (_a = this.config.value) === null || _a === void 0 ? void 0 : _a.forEach(value => {
126
+ if (!!value)
127
+ value.check = false;
128
+ });
129
+ (_b = this._editor) === null || _b === void 0 ? void 0 : _b['reloadList']();
130
+ }
131
+ else {
132
+ this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined }));
133
+ }
116
134
  }
117
135
  onKeyDonwListener(event) {
118
136
  if (event.key === "Enter") {
119
137
  this._applyButton.setFocus().then(() => this.apply());
120
138
  }
121
139
  }
140
+ buildRightSlot(item) {
141
+ return h("ez-icon", { iconName: "delete", onClick: () => this.removeValueFromConfig(item) });
142
+ }
143
+ removeValueFromConfig(item) {
144
+ var _a, _b, _c, _d, _e, _f;
145
+ const index = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.findIndex(i => (i === null || i === void 0 ? void 0 : i.id) === item.id);
146
+ (_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.splice(index, 1);
147
+ (_f = (_e = this._editor) === null || _e === void 0 ? void 0 : _e["reloadList"]) === null || _f === void 0 ? void 0 : _f.call(_e);
148
+ }
149
+ saveConfig(newConfig) {
150
+ var _a;
151
+ (_a = this._application) === null || _a === void 0 ? void 0 : _a.getResourceID().then(resourceId => {
152
+ const fetcher = new FilterBarConfigFetcher();
153
+ fetcher.saveEntityListConfig(newConfig, resourceId, this._application.configName);
154
+ this.config = newConfig;
155
+ });
156
+ }
122
157
  render() {
123
158
  const ContentEditor = this.getContentEditor();
124
- return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header" }, this.config.detailTitle), this.getPopUpHeaderButtons()), h(ContentEditor, { ref: ref => this._editor = ref, value: this.config.value, config: this.config, onKeyDown: evt => this.onKeyDonwListener(evt), "data-element-id": this._idContentEditor, getMessage: this.getMessage }), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.clear(), size: "small" }), h("ez-button", { ref: ref => this._applyButton = ref, label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.apply(), size: "small", class: "ez-button--primary ez-padding-left--medium" }))));
159
+ return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("div", { class: "ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header" }, this.config.detailTitle), this.getPopUpHeaderButtons()), h(ContentEditor, { maxHeightList: '240px', ref: ref => this._editor = ref, value: this.config.value, config: this.config, onKeyDown: evt => this.onKeyDonwListener(evt), "data-element-id": this._idContentEditor, getMessage: this.getMessage, onSaveConfig: evt => this.saveConfig(evt.detail), rightListSlotBuilder: item => this.buildRightSlot(item) }), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.clear(), size: "small" }), h("ez-button", { ref: ref => this._applyButton = ref, label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.apply(), size: "small", class: "ez-button--primary ez-padding-left--medium" }))));
125
160
  }
126
161
  get _element() { return this; }
162
+ static get watchers() { return {
163
+ "config": ["observeConfig"]
164
+ }; }
127
165
  }, [0, "snk-filter-detail", {
128
166
  "config": [1040],
129
167
  "getMessage": [16],