@sankhyalabs/sankhyablocks 5.5.0 → 5.6.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 (122) hide show
  1. package/dist/cjs/{SnkMessageBuilder-26da04f7.js → SnkMessageBuilder-e64dce7f.js} +14 -0
  2. package/dist/cjs/index-8d94b7e0.js +7 -0
  3. package/dist/cjs/index-de79181a.js +201 -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 +1 -1
  7. package/dist/cjs/snk-attach.cjs.entry.js +2 -1
  8. package/dist/cjs/snk-crud.cjs.entry.js +2 -1
  9. package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
  10. package/dist/cjs/{snk-data-unit-c43df27b.js → snk-data-unit-85d6565e.js} +1 -1
  11. package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
  12. package/dist/cjs/snk-detail-view.cjs.entry.js +4 -3
  13. package/dist/cjs/snk-expression-item.cjs.entry.js +213 -0
  14. package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +435 -0
  15. package/dist/cjs/snk-grid.cjs.entry.js +3 -2
  16. package/dist/cjs/{snk-guides-viewer-e6a65393.js → snk-guides-viewer-9784c527.js} +1 -1
  17. package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -2
  18. package/dist/cjs/snk-personalized-filter.cjs.entry.js +126 -0
  19. package/dist/cjs/snk-simple-bar_2.cjs.entry.js +2 -1
  20. package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
  21. package/dist/cjs/taskbar-elements-bc2598f9.js +118 -0
  22. package/dist/collection/collection-manifest.json +2 -0
  23. package/dist/collection/components/snk-filter-field-search/snk-filter-field-search.js +62 -69
  24. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.css +4 -0
  25. package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +87 -0
  26. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/filter-operands/filter-operands.js +34 -0
  27. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.css +97 -0
  28. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.js +298 -0
  29. package/dist/collection/components/snk-personalized-filter/subcomponents/snk-filter-param-config/snk-filter-param-config.js +2 -2
  30. package/dist/collection/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.js +63 -0
  31. package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
  32. package/dist/collection/lib/message/resources/snk-personalized-filter.msg.js +12 -0
  33. package/dist/collection/lib/store/index.js +2 -1
  34. package/dist/components/SnkMessageBuilder.js +14 -0
  35. package/dist/components/index.d.ts +2 -0
  36. package/dist/components/index.js +2 -0
  37. package/dist/components/index2.js +1 -1
  38. package/dist/components/index3.js +199 -0
  39. package/dist/components/snk-data-exporter2.js +1 -1
  40. package/dist/components/snk-expression-item.d.ts +11 -0
  41. package/dist/components/snk-expression-item.js +6 -0
  42. package/dist/components/snk-expression-item2.js +241 -0
  43. package/dist/components/snk-filter-field-search.js +1 -200
  44. package/dist/{esm/snk-filter-field-search.entry.js → components/snk-filter-field-search2.js} +65 -38
  45. package/dist/components/snk-filter-param-config.js +1 -273
  46. package/dist/{esm/snk-filter-param-config.entry.js → components/snk-filter-param-config2.js} +35 -11
  47. package/dist/components/snk-grid2.js +2 -1
  48. package/dist/components/snk-personalized-filter.d.ts +11 -0
  49. package/dist/components/snk-personalized-filter.js +158 -0
  50. package/dist/components/snk-taskbar2.js +3 -197
  51. package/dist/esm/{SnkMessageBuilder-7a9392e6.js → SnkMessageBuilder-f3590f65.js} +14 -0
  52. package/dist/esm/{index-6519a79e.js → index-507e19ec.js} +1 -1
  53. package/dist/esm/index-620ac460.js +7 -0
  54. package/dist/esm/index-8efbf198.js +199 -0
  55. package/dist/esm/loader.js +1 -1
  56. package/dist/esm/sankhyablocks.js +1 -1
  57. package/dist/esm/snk-application.entry.js +1 -1
  58. package/dist/esm/snk-attach.entry.js +3 -2
  59. package/dist/esm/snk-crud.entry.js +3 -2
  60. package/dist/esm/snk-data-exporter.entry.js +3 -3
  61. package/dist/esm/{snk-data-unit-f9e4c694.js → snk-data-unit-50b1660c.js} +1 -1
  62. package/dist/esm/snk-data-unit.entry.js +2 -2
  63. package/dist/esm/snk-detail-view.entry.js +5 -4
  64. package/dist/esm/snk-expression-item.entry.js +209 -0
  65. package/dist/esm/snk-filter-field-search_2.entry.js +430 -0
  66. package/dist/esm/snk-grid.entry.js +3 -2
  67. package/dist/esm/{snk-guides-viewer-62a9f74d.js → snk-guides-viewer-4d12f268.js} +2 -2
  68. package/dist/esm/snk-guides-viewer.entry.js +4 -3
  69. package/dist/esm/snk-personalized-filter.entry.js +122 -0
  70. package/dist/esm/snk-simple-bar_2.entry.js +3 -2
  71. package/dist/esm/snk-taskbar.entry.js +3 -2
  72. package/dist/esm/taskbar-elements-e6af3e93.js +115 -0
  73. package/dist/sankhyablocks/p-1dcfd32a.entry.js +1 -0
  74. package/dist/sankhyablocks/p-27e264d9.entry.js +1 -0
  75. package/dist/sankhyablocks/p-343699ad.entry.js +1 -0
  76. package/dist/sankhyablocks/{p-f2223502.js → p-3d3263b4.js} +1 -1
  77. package/dist/sankhyablocks/{p-b2523981.entry.js → p-3fbe2d69.entry.js} +1 -1
  78. package/dist/sankhyablocks/p-433dfa63.entry.js +1 -0
  79. package/dist/sankhyablocks/{p-f132e371.js → p-4c2015a9.js} +1 -1
  80. package/dist/sankhyablocks/p-4eefe631.entry.js +1 -0
  81. package/dist/sankhyablocks/p-6a02e236.js +1 -0
  82. package/dist/sankhyablocks/p-8bdf5e57.entry.js +1 -0
  83. package/dist/sankhyablocks/{p-a412992c.entry.js → p-c4417efb.entry.js} +1 -1
  84. package/dist/sankhyablocks/{p-92a0fca4.js → p-c9477950.js} +1 -1
  85. package/dist/sankhyablocks/{p-aeffd219.js → p-ccd26e3a.js} +1 -1
  86. package/dist/sankhyablocks/p-d410f45a.js +1 -0
  87. package/dist/sankhyablocks/p-df8f13b4.entry.js +1 -0
  88. package/dist/sankhyablocks/p-e9f42525.entry.js +1 -0
  89. package/dist/sankhyablocks/p-f344b811.entry.js +1 -0
  90. package/dist/sankhyablocks/p-f4184ce7.js +1 -0
  91. package/dist/sankhyablocks/p-fd4ed40a.entry.js +1 -0
  92. package/dist/sankhyablocks/p-ff96b509.entry.js +27 -0
  93. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  94. package/dist/types/components/snk-filter-field-search/interfaces/index.d.ts +14 -4
  95. package/dist/types/components/snk-filter-field-search/snk-filter-field-search.d.ts +13 -10
  96. package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +20 -0
  97. package/dist/types/components/snk-personalized-filter/subcomponents/snk-expression-item/filter-operands/filter-operands.d.ts +9 -0
  98. package/dist/types/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.d.ts +54 -0
  99. package/dist/types/components/snk-personalized-filter/subcomponents/snk-filter-param-config/interfaces/IExpressionItem.d.ts +4 -2
  100. package/dist/types/components.d.ts +83 -9
  101. package/dist/types/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.d.ts +7 -0
  102. package/dist/types/lib/message/resources/snk-personalized-filter.msg.d.ts +1 -0
  103. package/dist/types/lib/store/index.d.ts +1 -0
  104. package/package.json +1 -1
  105. package/react/components.d.ts +2 -0
  106. package/react/components.js +2 -0
  107. package/react/components.js.map +1 -1
  108. package/dist/cjs/snk-filter-field-search.cjs.entry.js +0 -185
  109. package/dist/cjs/snk-filter-param-config.cjs.entry.js +0 -256
  110. package/dist/cjs/taskbar-elements-80285601.js +0 -313
  111. package/dist/esm/taskbar-elements-055ba1ad.js +0 -309
  112. package/dist/sankhyablocks/p-4512cc6c.entry.js +0 -1
  113. package/dist/sankhyablocks/p-5cbbe1f7.entry.js +0 -1
  114. package/dist/sankhyablocks/p-63d01871.entry.js +0 -1
  115. package/dist/sankhyablocks/p-741b00ef.entry.js +0 -1
  116. package/dist/sankhyablocks/p-79d22df0.entry.js +0 -1
  117. package/dist/sankhyablocks/p-93d8fe00.entry.js +0 -1
  118. package/dist/sankhyablocks/p-999d1953.entry.js +0 -1
  119. package/dist/sankhyablocks/p-c3efd4eb.entry.js +0 -1
  120. package/dist/sankhyablocks/p-ebe876f5.entry.js +0 -1
  121. package/dist/sankhyablocks/p-ed438690.js +0 -1
  122. package/dist/sankhyablocks/p-f3d0c744.entry.js +0 -1
@@ -0,0 +1,199 @@
1
+ import { getRenderingRef, forceUpdate } from '@stencil/core/internal/client';
2
+
3
+ const appendToMap = (map, propName, value) => {
4
+ const items = map.get(propName);
5
+ if (!items) {
6
+ map.set(propName, [value]);
7
+ }
8
+ else if (!items.includes(value)) {
9
+ items.push(value);
10
+ }
11
+ };
12
+ const debounce = (fn, ms) => {
13
+ let timeoutId;
14
+ return (...args) => {
15
+ if (timeoutId) {
16
+ clearTimeout(timeoutId);
17
+ }
18
+ timeoutId = setTimeout(() => {
19
+ timeoutId = 0;
20
+ fn(...args);
21
+ }, ms);
22
+ };
23
+ };
24
+
25
+ /**
26
+ * Check if a possible element isConnected.
27
+ * The property might not be there, so we check for it.
28
+ *
29
+ * We want it to return true if isConnected is not a property,
30
+ * otherwise we would remove these elements and would not update.
31
+ *
32
+ * Better leak in Edge than to be useless.
33
+ */
34
+ const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
35
+ const cleanupElements = debounce((map) => {
36
+ for (let key of map.keys()) {
37
+ map.set(key, map.get(key).filter(isConnected));
38
+ }
39
+ }, 2000);
40
+ const stencilSubscription = () => {
41
+ if (typeof getRenderingRef !== 'function') {
42
+ // If we are not in a stencil project, we do nothing.
43
+ // This function is not really exported by @stencil/core.
44
+ return {};
45
+ }
46
+ const elmsToUpdate = new Map();
47
+ return {
48
+ dispose: () => elmsToUpdate.clear(),
49
+ get: (propName) => {
50
+ const elm = getRenderingRef();
51
+ if (elm) {
52
+ appendToMap(elmsToUpdate, propName, elm);
53
+ }
54
+ },
55
+ set: (propName) => {
56
+ const elements = elmsToUpdate.get(propName);
57
+ if (elements) {
58
+ elmsToUpdate.set(propName, elements.filter(forceUpdate));
59
+ }
60
+ cleanupElements(elmsToUpdate);
61
+ },
62
+ reset: () => {
63
+ elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
64
+ cleanupElements(elmsToUpdate);
65
+ },
66
+ };
67
+ };
68
+
69
+ const unwrap = (val) => (typeof val === 'function' ? val() : val);
70
+ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
71
+ const unwrappedState = unwrap(defaultState);
72
+ let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
73
+ const handlers = {
74
+ dispose: [],
75
+ get: [],
76
+ set: [],
77
+ reset: [],
78
+ };
79
+ const reset = () => {
80
+ var _a;
81
+ // When resetting the state, the default state may be a function - unwrap it to invoke it.
82
+ // otherwise, the state won't be properly reset
83
+ states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
84
+ handlers.reset.forEach((cb) => cb());
85
+ };
86
+ const dispose = () => {
87
+ // Call first dispose as resetting the state would
88
+ // cause less updates ;)
89
+ handlers.dispose.forEach((cb) => cb());
90
+ reset();
91
+ };
92
+ const get = (propName) => {
93
+ handlers.get.forEach((cb) => cb(propName));
94
+ return states.get(propName);
95
+ };
96
+ const set = (propName, value) => {
97
+ const oldValue = states.get(propName);
98
+ if (shouldUpdate(value, oldValue, propName)) {
99
+ states.set(propName, value);
100
+ handlers.set.forEach((cb) => cb(propName, value, oldValue));
101
+ }
102
+ };
103
+ const state = (typeof Proxy === 'undefined'
104
+ ? {}
105
+ : new Proxy(unwrappedState, {
106
+ get(_, propName) {
107
+ return get(propName);
108
+ },
109
+ ownKeys(_) {
110
+ return Array.from(states.keys());
111
+ },
112
+ getOwnPropertyDescriptor() {
113
+ return {
114
+ enumerable: true,
115
+ configurable: true,
116
+ };
117
+ },
118
+ has(_, propName) {
119
+ return states.has(propName);
120
+ },
121
+ set(_, propName, value) {
122
+ set(propName, value);
123
+ return true;
124
+ },
125
+ }));
126
+ const on = (eventName, callback) => {
127
+ handlers[eventName].push(callback);
128
+ return () => {
129
+ removeFromArray(handlers[eventName], callback);
130
+ };
131
+ };
132
+ const onChange = (propName, cb) => {
133
+ const unSet = on('set', (key, newValue) => {
134
+ if (key === propName) {
135
+ cb(newValue);
136
+ }
137
+ });
138
+ // We need to unwrap the defaultState because it might be a function.
139
+ // Otherwise we might not be sending the right reset value.
140
+ const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
141
+ return () => {
142
+ unSet();
143
+ unReset();
144
+ };
145
+ };
146
+ const use = (...subscriptions) => {
147
+ const unsubs = subscriptions.reduce((unsubs, subscription) => {
148
+ if (subscription.set) {
149
+ unsubs.push(on('set', subscription.set));
150
+ }
151
+ if (subscription.get) {
152
+ unsubs.push(on('get', subscription.get));
153
+ }
154
+ if (subscription.reset) {
155
+ unsubs.push(on('reset', subscription.reset));
156
+ }
157
+ if (subscription.dispose) {
158
+ unsubs.push(on('dispose', subscription.dispose));
159
+ }
160
+ return unsubs;
161
+ }, []);
162
+ return () => unsubs.forEach((unsub) => unsub());
163
+ };
164
+ const forceUpdate = (key) => {
165
+ const oldValue = states.get(key);
166
+ handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
167
+ };
168
+ return {
169
+ state,
170
+ get,
171
+ set,
172
+ on,
173
+ onChange,
174
+ use,
175
+ dispose,
176
+ reset,
177
+ forceUpdate,
178
+ };
179
+ };
180
+ const removeFromArray = (array, item) => {
181
+ const index = array.indexOf(item);
182
+ if (index >= 0) {
183
+ array[index] = array[array.length - 1];
184
+ array.length--;
185
+ }
186
+ };
187
+
188
+ const createStore = (defaultState, shouldUpdate) => {
189
+ const map = createObservableMap(defaultState, shouldUpdate);
190
+ map.use(stencilSubscription());
191
+ return map;
192
+ };
193
+
194
+ const store = createStore({
195
+ exporterProviders: {},
196
+ filterFieldsDataSource: undefined
197
+ });
198
+
199
+ export { store as s };
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
2
  import { ObjectUtils, ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
- import { D as DataExporterOption, d as DataExporterFormat, e as DataExporterType } from './index2.js';
4
+ import { D as DataExporterOption, b as DataExporterFormat, c as DataExporterType } from './index2.js';
5
5
  import { K as KEY_PORT_EXPORT, W as WEB_CONNECTION, R as REPORT_LAUNCHER_RESOURCE_ID } from './constants.js';
6
6
  import { D as DataFetcher } from './DataFetcher.js';
7
7
  import { S as SnkDataUnit } from './snk-data-unit2.js';
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SnkExpressionItem extends Components.SnkExpressionItem, HTMLElement {}
4
+ export const SnkExpressionItem: {
5
+ prototype: SnkExpressionItem;
6
+ new (): SnkExpressionItem;
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 SnkExpressionItem$1, d as defineCustomElement$1 } from './snk-expression-item2.js';
2
+
3
+ const SnkExpressionItem = SnkExpressionItem$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { SnkExpressionItem, defineCustomElement };
@@ -0,0 +1,241 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
+ import { UserInterface, ApplicationContext } from '@sankhyalabs/core';
3
+ import { a as SelectedItemType, d as defineCustomElement$2 } from './snk-filter-field-search2.js';
4
+ import { ApplicationUtils, CheckMode } from '@sankhyalabs/ezui/dist/collection/utils';
5
+ import { fieldBuilder } from '@sankhyalabs/ezui/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder';
6
+ import { a as FilterOperand } from './index2.js';
7
+ import { s as store } from './index3.js';
8
+ import { d as defineCustomElement$1 } from './snk-filter-param-config2.js';
9
+
10
+ const FilterOperandDefault = [
11
+ { value: FilterOperand.EQUAL, label: "Igual (=)" },
12
+ { value: FilterOperand.DIFFERENT, label: "Diferente (<>)" },
13
+ { value: FilterOperand.LIKE, label: "Contendo (LIKE)" },
14
+ { value: FilterOperand.IN, label: "Contido em (IN)" },
15
+ { value: FilterOperand.START_WITH, label: "Iniciado com (%?)" },
16
+ { value: FilterOperand.FINISHED_WITH, label: "Terminado com (?%)" },
17
+ { value: FilterOperand.NULL, label: "Vazio (NULL)" },
18
+ { value: FilterOperand.NOT_NULL, label: "Não Vazio (NOT NULL)" },
19
+ { value: FilterOperand.LARGER, label: "Maior (>)" },
20
+ { value: FilterOperand.LARGER_EQUAL, label: "Maior ou Igual (>=)" },
21
+ { value: FilterOperand.SMALLER, label: "Menor (<)" },
22
+ { value: FilterOperand.SMALLER_EQUAL, label: "Menor ou Igual (<=)" }
23
+ ];
24
+ const FilterOperandTypeTextSearch = [
25
+ { value: FilterOperand.EQUAL, label: "Igual (=)" },
26
+ { value: FilterOperand.DIFFERENT, label: "Diferente (<>)" },
27
+ { value: FilterOperand.LIKE, label: "Contendo (LIKE)" },
28
+ { value: FilterOperand.IN, label: "Contido em (IN)" },
29
+ { value: FilterOperand.START_WITH, label: "Iniciado com (%?)" },
30
+ { value: FilterOperand.FINISHED_WITH, label: "Terminado com (?%)" },
31
+ { value: FilterOperand.NULL, label: "Vazio (NULL)" },
32
+ { value: FilterOperand.NOT_NULL, label: "Não Vazio (NOT NULL)" }
33
+ ];
34
+ const FIELD_TYPE_SEARCH_AND_TEXT = [
35
+ UserInterface.SEARCH,
36
+ UserInterface.SHORTTEXT,
37
+ UserInterface.PASSWORD,
38
+ UserInterface.MASKEDTEXT,
39
+ UserInterface.LONGTEXT,
40
+ UserInterface.HTML
41
+ ];
42
+
43
+ const snkExpressionItemCss = ".sc-snk-expression-item-h{display:flex;width:100%;--snk-expression-item--background-color:var(--background--xlight, #fff);--snk-expression-item__itens--padding:var(--space--small, 6px);--snk-expression-item__width--input-operator:220px;--snk-expression-item__width--input-value:240px;--snk-expression-item__width--input-value-variable:176px;--snk-expression-item--border-radius:var(--border--radius-medium, 12px);--snk-expression-item--border-color:var(--color--strokes, #DCE0E8);--snk-expression-item--border-style:var(--border--small, 1px solid)}.box.sc-snk-expression-item{width:100%;height:100%;background:var(--snk-expression-item--background-color);margin:var(--space--small, 6px);border:var(--snk-expression-item--border-color) var(--snk-expression-item--border-style);border-radius:var(--snk-expression-item--border-radius)}.box__container.sc-snk-expression-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap;margin:var(--space--small, 6px)}.box__container--input-filter.sc-snk-expression-item{width:100%}.box__container--input-operator.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-operator);min-width:var(--snk-expression-item__width--input-operator)}.box__container--input-value.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-value);min-width:var(--snk-expression-item__width--input-value)}.box__container--input-value-variable.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-value-variable);min-width:var(--snk-expression-item__width--input-value-variable)}.box__container--button-delete.sc-snk-expression-item{display:flex}.box__container.sc-snk-expression-item>div.sc-snk-expression-item{padding-left:var(--snk-expression-item__itens--padding);padding-right:var(--snk-expression-item__itens--padding)}.box__container--button-delete--icon.sc-snk-expression-item{width:42px;min-width:42px}.box__container--input-value-variable--icon.sc-snk-expression-item{cursor:pointer}";
44
+
45
+ const SnkExpressionItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
46
+ constructor() {
47
+ super();
48
+ this.__registerHost();
49
+ this.ezFilterItemChange = createEvent(this, "ezFilterItemChange", 7);
50
+ this.ezFilterItemRemove = createEvent(this, "ezFilterItemRemove", 7);
51
+ this.application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
52
+ this.filterOperandDefault = FilterOperandDefault;
53
+ this.filterOperandTypeTextSearch = FilterOperandTypeTextSearch;
54
+ this._showValueVariable = false;
55
+ this._fieldSelected = undefined;
56
+ this._optionNotNull = false;
57
+ this.expression = undefined;
58
+ this.canRemove = true;
59
+ this.messagesBuilder = undefined;
60
+ }
61
+ expressionChanged(newValue, oldValue) {
62
+ if (newValue !== oldValue) {
63
+ this.ezFilterItemChange.emit(newValue);
64
+ }
65
+ }
66
+ componentWillLoad() {
67
+ this._dataSourceFetcher = store.get("filterFieldsDataSource");
68
+ store.onChange('filterFieldsDataSource', () => {
69
+ this._dataSourceFetcher = store.get("filterFieldsDataSource");
70
+ });
71
+ }
72
+ setValueExpression(key, value) {
73
+ this.expression[key] = value;
74
+ this.expressionChanged(this.expression);
75
+ }
76
+ getMessage(key, params) {
77
+ return this.application.messagesBuilder.getMessage(key, params);
78
+ }
79
+ handleSelectItem(filterField) {
80
+ if (filterField.type === SelectedItemType.FIELD) {
81
+ const field = filterField;
82
+ this._fieldSelected = field;
83
+ this.setValueExpression("fieldName", field.name);
84
+ }
85
+ }
86
+ handleFocus() {
87
+ if (this._elFilterFieldSearch)
88
+ this._elFilterFieldSearch.show();
89
+ }
90
+ handleChangeFilterInput(evt) {
91
+ this._elFilterFieldSearch.applyFilter(evt.detail);
92
+ }
93
+ handleChangeValueVariable(showValueVariable) {
94
+ this._showValueVariable = showValueVariable;
95
+ if (this._elFieldDynamic) {
96
+ this._elFieldDynamic.value = undefined;
97
+ this._elFieldDynamic.enabled = !showValueVariable;
98
+ }
99
+ }
100
+ openSnkFilterParamConfig() {
101
+ var _a;
102
+ (_a = this._elFilterParamConfigRef) === null || _a === void 0 ? void 0 : _a.open(this.expression).then(this.onOpenPromiseReady.bind(this)).catch(error => {
103
+ console.error(error);
104
+ });
105
+ }
106
+ onOpenPromiseReady(changes) {
107
+ this.expression = changes;
108
+ }
109
+ buildOptionsOperator() {
110
+ var _a;
111
+ if (FIELD_TYPE_SEARCH_AND_TEXT.includes((_a = this._fieldSelected) === null || _a === void 0 ? void 0 : _a.userInterface)) {
112
+ return this.filterOperandTypeTextSearch;
113
+ }
114
+ else {
115
+ return this.filterOperandDefault;
116
+ }
117
+ }
118
+ handleChangeOperator(optionSelected) {
119
+ this.checkOptionIsNull(optionSelected);
120
+ this.setValueExpression("operand", optionSelected);
121
+ }
122
+ checkOptionIsNull(optionSelected) {
123
+ if (optionSelected === FilterOperand.NULL || optionSelected === FilterOperand.NOT_NULL) {
124
+ this._optionNotNull = true;
125
+ if (this._elFieldDynamic) {
126
+ this._elFieldDynamic.enabled = false;
127
+ this._elFieldDynamic.value = undefined;
128
+ }
129
+ }
130
+ else {
131
+ this._optionNotNull = false;
132
+ if (this._elFieldDynamic) {
133
+ this._elFieldDynamic.enabled = this._showValueVariable ? false : true;
134
+ }
135
+ }
136
+ }
137
+ confirmRemove(evt) {
138
+ evt.preventDefault();
139
+ evt.stopPropagation();
140
+ ApplicationUtils.confirm(this.getMessage("snkPersonalizedFilter.confirm.title"), this.getMessage("snkPersonalizedFilter.confirm.description"))
141
+ .then((canRemove) => {
142
+ if (canRemove) {
143
+ this.ezFilterItemRemove.emit(this.expression);
144
+ }
145
+ });
146
+ }
147
+ buildFieldByType() {
148
+ var _a, _b;
149
+ if (!this._fieldSelected)
150
+ return;
151
+ const inputFieldData = (_a = fieldBuilder(this.configureFieldByType())) === null || _a === void 0 ? void 0 : _a.$children$.shift();
152
+ if (this._optionNotNull && inputFieldData || ((_b = this._elValueVariable) === null || _b === void 0 ? void 0 : _b.value) && inputFieldData) {
153
+ inputFieldData.$attrs$.enabled = false;
154
+ }
155
+ return h(inputFieldData.$tag$, Object.assign(Object.assign({}, inputFieldData.$attrs$), { ref: (el) => {
156
+ this._elFieldDynamic = el;
157
+ } }));
158
+ }
159
+ configureFieldByType() {
160
+ const field = {
161
+ userInterface: this._fieldSelected.userInterface,
162
+ name: this._fieldSelected.name,
163
+ label: this._fieldSelected.label,
164
+ canShowError: false
165
+ };
166
+ switch (field.userInterface) {
167
+ case UserInterface.OPTIONSELECTOR:
168
+ field.props = {
169
+ options: this._fieldSelected.properties.map(option => ({
170
+ value: option.value,
171
+ label: option.name,
172
+ })),
173
+ };
174
+ break;
175
+ case UserInterface.LONGTEXT:
176
+ field.rows = 1;
177
+ break;
178
+ case UserInterface.SEARCH:
179
+ field.optionLoader = searchArgument => this.setCriteriaSearch(searchArgument, this.application);
180
+ break;
181
+ }
182
+ return field;
183
+ }
184
+ setCriteriaSearch({ mode, argument }, application) {
185
+ if (application == undefined)
186
+ return;
187
+ const searchOptions = {
188
+ showInactives: false
189
+ };
190
+ const options = {
191
+ entity: this._fieldSelected.properties.ENTITYNAME,
192
+ searchOptions: searchOptions,
193
+ entityDescription: this._fieldSelected.label
194
+ };
195
+ return application.executePreparedSearch(mode, argument, options);
196
+ }
197
+ render() {
198
+ var _a;
199
+ return (h(Host, null, h("div", { class: "box" }, h("div", { class: "box__container" }, h("div", { class: "box__container--input-filter" }, h("ez-filter-input", { value: (_a = this._fieldSelected) === null || _a === void 0 ? void 0 : _a.path, label: this.getMessage("snkPersonalizedFilter.info.labelSearchField"), canShowError: false, onEzChange: (evt) => this.handleChangeFilterInput(evt), onFocus: () => this.handleFocus() }), h("snk-filter-field-search", { ref: ref => this._elFilterFieldSearch = ref, searchable: false, onEzSelectFilterItem: (ev) => this.handleSelectItem(ev.detail), fieldsDataSource: this._dataSourceFetcher })), h("div", { class: "box__container--input-operator" }, h("ez-combo-box", { label: this.getMessage("snkPersonalizedFilter.info.labelOperator"), canShowError: false, options: this.buildOptionsOperator(), onEzChange: (evt) => this.handleChangeOperator(evt.detail.value), suppressEmptyOption: true })), h("div", { class: "box__container--input-value" }, !this._fieldSelected ?
200
+ h("ez-number-input", { label: "Valor", canShowError: false, enabled: (!this._showValueVariable && !this._optionNotNull) }) :
201
+ this.buildFieldByType()), h("div", { class: "box__container--input-value-variable", title: this.getMessage("snkPersonalizedFilter.info.titleTooltip") }, !this._optionNotNull &&
202
+ h("ez-check", { ref: ref => this._elValueVariable = ref, label: this.getMessage("snkPersonalizedFilter.info.labelValueVarible"), mode: CheckMode.SWITCH, onEzChange: (evt) => this.handleChangeValueVariable(evt.detail) }), (this._showValueVariable && !this._optionNotNull) &&
203
+ h("ez-icon", { class: "box__container--input-value-variable--icon", size: "large", iconName: "settings-inverted", onClick: () => this.openSnkFilterParamConfig() }), h("snk-filter-param-config", { ref: (el) => this._elFilterParamConfigRef = el, messagesBuilder: this.messagesBuilder })), h("div", { class: "box__container--button-delete" }, h("div", { class: "box__container--button-delete--icon" }, this.canRemove && h("ez-button", { mode: "icon", iconName: "delete", onClick: (evt) => this.confirmRemove(evt) })))))));
204
+ }
205
+ static get watchers() { return {
206
+ "expression": ["expressionChanged"]
207
+ }; }
208
+ static get style() { return snkExpressionItemCss; }
209
+ }, [2, "snk-expression-item", {
210
+ "expression": [16],
211
+ "canRemove": [516, "can-remove"],
212
+ "messagesBuilder": [1040],
213
+ "_showValueVariable": [32],
214
+ "_fieldSelected": [32],
215
+ "_optionNotNull": [32]
216
+ }]);
217
+ function defineCustomElement() {
218
+ if (typeof customElements === "undefined") {
219
+ return;
220
+ }
221
+ const components = ["snk-expression-item", "snk-filter-field-search", "snk-filter-param-config"];
222
+ components.forEach(tagName => { switch (tagName) {
223
+ case "snk-expression-item":
224
+ if (!customElements.get(tagName)) {
225
+ customElements.define(tagName, SnkExpressionItem);
226
+ }
227
+ break;
228
+ case "snk-filter-field-search":
229
+ if (!customElements.get(tagName)) {
230
+ defineCustomElement$2();
231
+ }
232
+ break;
233
+ case "snk-filter-param-config":
234
+ if (!customElements.get(tagName)) {
235
+ defineCustomElement$1();
236
+ }
237
+ break;
238
+ } });
239
+ }
240
+
241
+ export { SnkExpressionItem as S, defineCustomElement as d };
@@ -1,203 +1,4 @@
1
- import { h, proxyCustomElement, HTMLElement, createEvent } from '@stencil/core/internal/client';
2
- import { UserInterface, JSUtils, ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
3
-
4
- var SelectedItemType;
5
- (function (SelectedItemType) {
6
- SelectedItemType["LINK"] = "LINK";
7
- SelectedItemType["FIELD"] = "FIELD";
8
- })(SelectedItemType || (SelectedItemType = {}));
9
-
10
- const ICON_MODES = {
11
- [UserInterface.SHORTTEXT]: 'text',
12
- [UserInterface.LONGTEXT]: 'text',
13
- [UserInterface.INTEGERNUMBER]: 'number',
14
- [UserInterface.DECIMALNUMBER]: 'number',
15
- [UserInterface.DATE]: 'calendar',
16
- [UserInterface.DATETIME]: 'calendar',
17
- [UserInterface.SWITCH]: 'boolean',
18
- [UserInterface.CHECKBOX]: 'check-circle-inverted',
19
- [UserInterface.OPTIONSELECTOR]: 'list',
20
- [UserInterface.SEARCH]: 'search',
21
- [UserInterface.HTML]: 'tag_code',
22
- [UserInterface.IMAGE]: 'png',
23
- [UserInterface.FILE]: 'edit-file',
24
- [UserInterface.TIME]: 'timer-outline',
25
- [UserInterface.ELAPSEDTIME]: 'timer',
26
- [UserInterface.MASKEDTEXT]: 'text',
27
- [UserInterface.PASSWORD]: 'email',
28
- };
29
- const ListItem = ({ userInterface, description }) => {
30
- return (h("ez-icon", { iconName: ICON_MODES[userInterface], className: "ez-padding-left--small", title: description }));
31
- };
32
-
33
- const snkFilterFieldSearchCss = ".sc-snk-filter-field-search-h{--snk-filter-field-search--container-width:468px;--snk-filter-field-search--container-height:322px}.snk-filter-field-search__container.sc-snk-filter-field-search{display:flex;flex-direction:column;padding:var(--space--medium);width:var(--snk-filter-field-search--container-width);height:var(--snk-filter-field-search--container-height)}.snk-filter-field-search__section.sc-snk-filter-field-search{display:grid;grid-template-columns:1fr 1fr;place-items:flex-start;overflow:hidden;gap:var(--space--small)}.snk-filter-field-search__input.sc-snk-filter-field-search{margin-bottom:var(--space--medium)}.snk-filter-field-search__list_container.sc-snk-filter-field-search{display:flex;flex-direction:column}.snk-filter-field-search__list.sc-snk-filter-field-search{overflow-y:auto}";
34
-
35
- const SNK_CONTEXT_KEY = "__SNK__APPLICATION__";
36
- const SnkFilterFieldSearch$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
37
- constructor() {
38
- super();
39
- this.__registerHost();
40
- this.ezSelectFilterItem = createEvent(this, "ezSelectFilterItem", 7);
41
- this._filterMetadataStorage = new Map();
42
- this._dataSource = null;
43
- this._filterText = "";
44
- this._isLoading = false;
45
- this.searchable = true;
46
- this.breadcrumbItems = [];
47
- this.linkItems = [];
48
- this.fieldItems = [];
49
- }
50
- /**
51
- * Define a fonte de dados do componente.
52
- * @param {IFilterLink} currentLink - Link atual da entidade.
53
- * @param {IFilterMetadata} fetchData - callback que executa a busca de dados.
54
- * @throws {Error} - Quando os metadados não forem válidos.
55
- * @throws {Error} - Quando o link atual não for do tipo link.
56
- */
57
- async setDataSource(currentLink, fetchData) {
58
- var _a;
59
- this._isLoading = true;
60
- let metadata = this._filterMetadataStorage.get(currentLink.uri);
61
- if (!metadata) {
62
- metadata = await fetchData(currentLink);
63
- this._filterMetadataStorage.set(currentLink.uri, metadata);
64
- }
65
- const { fields, links } = metadata || {};
66
- if (!Array.isArray(fields) || !Array.isArray(links))
67
- throw new Error('Invalid metadata');
68
- if (currentLink.type !== SelectedItemType.LINK)
69
- throw new Error('The current link must be a link type');
70
- this._dataSource = metadata;
71
- this._currentLink = currentLink;
72
- this.mapDataSourceToLinkItems();
73
- this.mapDataSourceToFieldItems();
74
- this._isLoading = false;
75
- (_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.show();
76
- this._ezFieldList.scrollToTop();
77
- this._ezLinkList.scrollToTop();
78
- }
79
- /**
80
- * Filtra a fonte de dados do componente.
81
- * @param {string} filterText - Texto para filtrar a fonte de dados.
82
- * @throws {Error} - Quando o componente estiver com a propriedade searchable como true.
83
- */
84
- async filterDataSource(filterText) {
85
- if (this.searchable)
86
- throw new Error('This method is not available when searchable is true');
87
- this.handleFilterChange(filterText);
88
- }
89
- mapDataSourceToLinkItems() {
90
- var _a;
91
- const { links } = this._dataSource;
92
- const filterLinkLabelMessage = this.getMessage('snkFilterFieldSearch.linkLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
93
- const items = links.map(link => (Object.assign({ label: link.description }, link)));
94
- this.linkItems = [{
95
- group: filterLinkLabelMessage,
96
- items
97
- }];
98
- if (this.breadcrumbItems.length === 0) {
99
- this.breadcrumbItems = [Object.assign({ id: JSUtils.generateUUID(), label: this._currentLink.description }, this._currentLink)];
100
- }
101
- }
102
- mapDataSourceToFieldItems() {
103
- var _a;
104
- const { fields } = this._dataSource;
105
- const filterFieldLabelMessage = this.getMessage('snkFilterFieldSearch.fieldLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
106
- const filteredFields = fields.filter(field => {
107
- if (!this._currentLink)
108
- return true;
109
- const searchableByDescription = field.description.toLowerCase().includes(this._filterText.toLowerCase());
110
- const searchableByName = field.name.toLowerCase().includes(this._filterText.toLowerCase());
111
- return searchableByDescription || searchableByName;
112
- });
113
- const items = filteredFields.map(field => (Object.assign({ label: field.description }, field)));
114
- this.fieldItems = [{
115
- group: filterFieldLabelMessage,
116
- items
117
- }];
118
- }
119
- handleFilterChange(filterText) {
120
- if (this._isLoading)
121
- return;
122
- this._filterText = filterText;
123
- this.mapDataSourceToFieldItems();
124
- }
125
- handleSelectLink({ detail: item }) {
126
- if (this._isLoading)
127
- return;
128
- const breadcrumbByIndex = this.breadcrumbItems.findIndex(breadcrumbItem => breadcrumbItem.id === item.id);
129
- item.cache = this._filterMetadataStorage.has(item.uri);
130
- if (breadcrumbByIndex > -1) {
131
- this.breadcrumbItems = this.breadcrumbItems.slice(0, (breadcrumbByIndex + 1));
132
- }
133
- else {
134
- this.breadcrumbItems = [...this.breadcrumbItems, Object.assign({ id: JSUtils.generateUUID(), label: item.description }, item)];
135
- }
136
- this.ezSelectFilterItem.emit(Object.assign(Object.assign({}, item), { type: SelectedItemType.LINK }));
137
- }
138
- handleSelectField({ detail: item }) {
139
- var _a;
140
- const breadcrumbPath = this.breadcrumbItems.map(breadcrumbItem => breadcrumbItem.label).join('>>');
141
- const selectedField = Object.assign(Object.assign({}, item), { type: SelectedItemType.FIELD, path: `${breadcrumbPath} >> ${item.description}` });
142
- this.ezSelectFilterItem.emit(selectedField);
143
- (_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.hide();
144
- }
145
- getElementID(sufix) {
146
- return {
147
- [ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: ElementIDUtils.getInternalIDInfo(sufix)
148
- };
149
- }
150
- /**
151
- * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
152
- * através de um pequeno modulo na estrutura da aplicação:
153
- * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
154
- * Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-field-search.msg.ts"
155
- */
156
- getMessage(key, params) {
157
- var _a, _b, _c;
158
- if (!this._application)
159
- this._application = ApplicationContext.getContextValue(SNK_CONTEXT_KEY);
160
- return (_c = (_b = (_a = this._application) === null || _a === void 0 ? void 0 : _a.messagesBuilder) === null || _b === void 0 ? void 0 : _b.getMessage) === null || _c === void 0 ? void 0 : _c.call(_b, key, params);
161
- }
162
- ;
163
- componentWillLoad() {
164
- this._application = ApplicationContext.getContextValue(SNK_CONTEXT_KEY);
165
- }
166
- componentDidLoad() {
167
- ElementIDUtils.addIDInfoIfNotExists(this._ezPopover, 'popover');
168
- }
169
- disconnectedCallback() {
170
- var _a;
171
- this._filterMetadataStorage.clear();
172
- (_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.hide();
173
- }
174
- render() {
175
- var _a;
176
- const searchLabelMessage = this.getMessage('snkFilterFieldSearch.searchLabel');
177
- return (h("ez-popover", Object.assign({ ref: (el) => this._ezPopover = el, role: "dialog", "aria-hidden": !((_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.opened) }, this.getElementID('EzPopover')), h("div", { class: "snk-filter-field-search__container" }, h("header", { class: "snk-filter-field-search__header" }, this.searchable && !!searchLabelMessage && (h("ez-filter-input", Object.assign({ class: "snk-filter-field-search__input", label: searchLabelMessage, asyncSearch: true, canShowError: false, onEzSearching: (event) => this.handleFilterChange.bind(this)(event.detail), "aria-label": searchLabelMessage, "aria-required": "false", "aria-invalid": "false" }, this.getElementID('EzFilterInput')))), this.breadcrumbItems.length > 0 && (h("ez-breadcrumb", Object.assign({ items: this.breadcrumbItems, onSelectedItem: this.handleSelectLink.bind(this), role: "navigation", "aria-current": "step" }, this.getElementID('EzBreadcrumb')))), h("hr", { class: "ez-divider-horizontal ez-margin-vertical--medium" })), h("section", { class: "snk-filter-field-search__section" }, h("ez-list", Object.assign({ ref: (el) => this._ezLinkList = el, class: "snk-filter-field-search__list", id: "filterLinkList", useGroups: true, dataSource: this.linkItems, onEzSelectItem: this.handleSelectLink.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ({ fieldCount }) => h("ez-badge", { label: fieldCount }), "aria-describedby": "filterLinkLabel" }, this.getElementID('EzListLinks'))), h("ez-list", Object.assign({ ref: (el) => this._ezFieldList = el, class: "snk-filter-field-search__list", id: "filterFieldList", useGroups: true, dataSource: this.fieldItems, onEzSelectItem: this.handleSelectField.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ListItem, "aria-describedby": "filterFieldLabel" }, this.getElementID('EzListFields')))))));
178
- }
179
- static get style() { return snkFilterFieldSearchCss; }
180
- }, [2, "snk-filter-field-search", {
181
- "searchable": [4],
182
- "breadcrumbItems": [32],
183
- "linkItems": [32],
184
- "fieldItems": [32],
185
- "setDataSource": [64],
186
- "filterDataSource": [64]
187
- }]);
188
- function defineCustomElement$1() {
189
- if (typeof customElements === "undefined") {
190
- return;
191
- }
192
- const components = ["snk-filter-field-search"];
193
- components.forEach(tagName => { switch (tagName) {
194
- case "snk-filter-field-search":
195
- if (!customElements.get(tagName)) {
196
- customElements.define(tagName, SnkFilterFieldSearch$1);
197
- }
198
- break;
199
- } });
200
- }
1
+ import { S as SnkFilterFieldSearch$1, d as defineCustomElement$1 } from './snk-filter-field-search2.js';
201
2
 
202
3
  const SnkFilterFieldSearch = SnkFilterFieldSearch$1;
203
4
  const defineCustomElement = defineCustomElement$1;