@embeddable.com/remarkable-pro 0.3.0 → 0.3.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 (88) hide show
  1. package/dist/ComparisonPeriodSelectFieldPro.js +1 -1
  2. package/dist/DonutChartPro.js +1 -1
  3. package/dist/DonutLabelChartPro.js +1 -1
  4. package/dist/FilterBuilderPro.js +6 -599
  5. package/dist/FilterBuilderPro.js.map +1 -1
  6. package/dist/KpiChartNumberComparisonPro.js +1 -1
  7. package/dist/KpiChartNumberPro.js +1 -1
  8. package/dist/LineChartComparisonDefaultPro.js +1 -1
  9. package/dist/LineChartComparisonWithKpiTabsPro.js +1 -1
  10. package/dist/LineChartWithKpiTabsPro.js +1 -1
  11. package/dist/PieChartPro.js +1 -1
  12. package/dist/components/charts/kpis/KpiChartNumberComparisonPro/KpiChartNumberComparisonPro.emb.d.ts +3 -1
  13. package/dist/components/charts/kpis/KpiChartNumberComparisonPro/KpiChartNumberComparisonPro.emb.d.ts.map +1 -1
  14. package/dist/components/charts/kpis/KpiChartNumberComparisonPro/definition.d.ts +6 -2
  15. package/dist/components/charts/kpis/KpiChartNumberComparisonPro/definition.d.ts.map +1 -1
  16. package/dist/components/charts/kpis/KpiChartNumberPro/KpiChartNumberPro.emb.d.ts +2 -0
  17. package/dist/components/charts/kpis/KpiChartNumberPro/KpiChartNumberPro.emb.d.ts.map +1 -1
  18. package/dist/components/charts/kpis/KpiChartNumberPro/definition.d.ts +4 -0
  19. package/dist/components/charts/kpis/KpiChartNumberPro/definition.d.ts.map +1 -1
  20. package/dist/components/charts/lines/LineChartComparisonDefaultPro/LineChartComparisonDefaultPro.emb.d.ts +1 -1
  21. package/dist/components/charts/lines/LineChartComparisonDefaultPro/definition.d.ts +2 -2
  22. package/dist/components/charts/lines/LineChartComparisonDefaultPro/definition.d.ts.map +1 -1
  23. package/dist/components/charts/lines/LineChartComparisonWithKpiTabsPro/LineChartComparisonWithKpiTabsPro.emb.d.ts +3 -1
  24. package/dist/components/charts/lines/LineChartComparisonWithKpiTabsPro/LineChartComparisonWithKpiTabsPro.emb.d.ts.map +1 -1
  25. package/dist/components/charts/lines/LineChartComparisonWithKpiTabsPro/definition.d.ts +10 -6
  26. package/dist/components/charts/lines/LineChartComparisonWithKpiTabsPro/definition.d.ts.map +1 -1
  27. package/dist/components/charts/lines/LineChartWithKpiTabsPro/LineChartWithKpiTabsPro.emb.d.ts +2 -0
  28. package/dist/components/charts/lines/LineChartWithKpiTabsPro/LineChartWithKpiTabsPro.emb.d.ts.map +1 -1
  29. package/dist/components/charts/lines/LineChartWithKpiTabsPro/definition.d.ts +4 -0
  30. package/dist/components/charts/lines/LineChartWithKpiTabsPro/definition.d.ts.map +1 -1
  31. package/dist/components/charts/pies/DonutChartPro/DonutChartPro.emb.d.ts +2 -0
  32. package/dist/components/charts/pies/DonutChartPro/DonutChartPro.emb.d.ts.map +1 -1
  33. package/dist/components/charts/pies/DonutChartPro/definition.d.ts +4 -0
  34. package/dist/components/charts/pies/DonutChartPro/definition.d.ts.map +1 -1
  35. package/dist/components/charts/pies/DonutLabelChartPro/DonutLabelChartPro.emb.d.ts +2 -0
  36. package/dist/components/charts/pies/DonutLabelChartPro/DonutLabelChartPro.emb.d.ts.map +1 -1
  37. package/dist/components/charts/pies/DonutLabelChartPro/definition.d.ts +4 -0
  38. package/dist/components/charts/pies/DonutLabelChartPro/definition.d.ts.map +1 -1
  39. package/dist/components/charts/pies/PieChartPro/PieChartPro.emb.d.ts +2 -0
  40. package/dist/components/charts/pies/PieChartPro/PieChartPro.emb.d.ts.map +1 -1
  41. package/dist/components/charts/pies/PieChartPro/definition.d.ts +4 -0
  42. package/dist/components/charts/pies/PieChartPro/definition.d.ts.map +1 -1
  43. package/dist/components/editors/ComparisonPeriodSelectFieldPro/ComparisonPeriodSelectFieldPro.emb.d.ts +1 -1
  44. package/dist/components/editors/ComparisonPeriodSelectFieldPro/definition.d.ts +3 -3
  45. package/dist/{definition-BPveF-o0.js → definition-9Sm_nFEr.js} +27 -25
  46. package/dist/definition-9Sm_nFEr.js.map +1 -0
  47. package/dist/{definition-BR7yIGzM.js → definition-BdoMwDGX.js} +32 -30
  48. package/dist/definition-BdoMwDGX.js.map +1 -0
  49. package/dist/{definition-BVvy48Df.js → definition-BiIMsrRD.js} +31 -29
  50. package/dist/definition-BiIMsrRD.js.map +1 -0
  51. package/dist/{definition-DvjcMLKk.js → definition-CaY0LXUV.js} +45 -45
  52. package/dist/definition-CaY0LXUV.js.map +1 -0
  53. package/dist/{definition-C-9Q3Ivg.js → definition-CavPpbuT.js} +3 -1
  54. package/dist/definition-CavPpbuT.js.map +1 -0
  55. package/dist/{definition-BZ7Wtvg5.js → definition-CyVZRIeo.js} +14 -14
  56. package/dist/{definition-BZ7Wtvg5.js.map → definition-CyVZRIeo.js.map} +1 -1
  57. package/dist/{definition-CJuA3KVA.js → definition-FRpWLnQJ.js} +20 -18
  58. package/dist/definition-FRpWLnQJ.js.map +1 -0
  59. package/dist/{definition-Vo_CL9pX.js → definition-RwKqVDfv.js} +31 -29
  60. package/dist/definition-RwKqVDfv.js.map +1 -0
  61. package/dist/definition-es5n86g4.js +604 -0
  62. package/dist/definition-es5n86g4.js.map +1 -0
  63. package/dist/{definition-DQdIv_3r.js → definition-xgUWvTDV.js} +25 -23
  64. package/dist/definition-xgUWvTDV.js.map +1 -0
  65. package/dist/embeddable-components.json +54 -54
  66. package/dist/index.d.ts +3 -0
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +50 -47
  69. package/dist/index.js.map +1 -1
  70. package/dist/meta/ComparisonPeriodSelectFieldPro.meta.json +1 -1
  71. package/dist/meta/DonutChartPro.meta.json +2 -0
  72. package/dist/meta/DonutLabelChartPro.meta.json +2 -0
  73. package/dist/meta/KpiChartNumberComparisonPro.meta.json +3 -1
  74. package/dist/meta/KpiChartNumberPro.meta.json +2 -0
  75. package/dist/meta/LineChartComparisonDefaultPro.meta.json +1 -1
  76. package/dist/meta/LineChartComparisonWithKpiTabsPro.meta.json +4 -2
  77. package/dist/meta/LineChartWithKpiTabsPro.meta.json +3 -1
  78. package/dist/meta/PieChartPro.meta.json +2 -0
  79. package/dist/meta/index.json +1 -1
  80. package/package.json +1 -1
  81. package/dist/definition-BPveF-o0.js.map +0 -1
  82. package/dist/definition-BR7yIGzM.js.map +0 -1
  83. package/dist/definition-BVvy48Df.js.map +0 -1
  84. package/dist/definition-C-9Q3Ivg.js.map +0 -1
  85. package/dist/definition-CJuA3KVA.js.map +0 -1
  86. package/dist/definition-DQdIv_3r.js.map +0 -1
  87. package/dist/definition-DvjcMLKk.js.map +0 -1
  88. package/dist/definition-Vo_CL9pX.js.map +0 -1
@@ -0,0 +1,604 @@
1
+ import { useTheme as ge, definePreview as he } from "@embeddable.com/react";
2
+ import { X as ve, ae as te, a7 as s, N as x, F as m, t as Oe, E as W, n as Be, o as ne, W as _e, I as Ne, m as ye, A as Fe, V as be, a8 as Ce } from "./index-Cddhb628.js";
3
+ import je, { useState as T, useRef as q, useEffect as C, useCallback as xe } from "react";
4
+ import { g as J } from "./dimensionsAndMeasures.utils-SAlbbzn4.js";
5
+ import { a as h, i as Me, r as Te } from "./component.utils-oQMZT7TK.js";
6
+ import { b as Ae } from "./formatter.utils-Dm_mQlX1.js";
7
+ import { E as Se } from "./EditorCard-DOCprGOC.js";
8
+ import { i as S } from "./component.inputs.constants-BFlnzCwS.js";
9
+ /**
10
+ * @license @tabler/icons-react v3.44.0 - MIT
11
+ *
12
+ * This source code is licensed under the MIT license.
13
+ * See the LICENSE file in the root directory of this source tree.
14
+ */
15
+ const Ie = [["path", { d: "M12 5l0 14", key: "svg-0" }], ["path", { d: "M5 12l14 0", key: "svg-1" }]], oe = ve("outline", "plus", "Plus", Ie), Re = "_container_2pz3g_1", qe = "_scroll_2pz3g_13", we = "_filter_2pz3g_26", De = "_addButton_2pz3g_32", ze = "_memberButton_2pz3g_60", Le = "_deleteButton_2pz3g_83", Ve = "_operatorButton_2pz3g_114", Ee = "_valueButton_2pz3g_138", Pe = "_loadingSpinner_2pz3g_175", ke = "_valueButtonEmpty_2pz3g_183", We = "_clearButton_2pz3g_187", $e = "_scrollRightButton_2pz3g_207", Je = "_scrollLeftButton_2pz3g_240", Ue = "_valueInput_2pz3g_273", O = {
16
+ container: Re,
17
+ scroll: qe,
18
+ filter: we,
19
+ addButton: De,
20
+ memberButton: ze,
21
+ deleteButton: Le,
22
+ operatorButton: Ve,
23
+ valueButton: Ee,
24
+ loadingSpinner: Pe,
25
+ valueButtonEmpty: ke,
26
+ clearButton: We,
27
+ scrollRightButton: $e,
28
+ scrollLeftButton: Je,
29
+ valueInput: Ue
30
+ }, $ = (e) => e.target.value === "" ? null : Number(e.target.value), Xe = ({
31
+ filter: e,
32
+ onSelectValue: r
33
+ }) => {
34
+ const [o, f] = T((e == null ? void 0 : e.value) ?? null), [u, c] = T(
35
+ Array.isArray(e.value) ? e.value[0] ?? null : null
36
+ ), [n, i] = T(
37
+ Array.isArray(e.value) ? e.value[1] ?? null : null
38
+ ), p = q(null), d = te((v) => {
39
+ r(v);
40
+ });
41
+ return C(() => {
42
+ u != null && n != null && d([u, n]);
43
+ }, [u, n, d]), C(() => {
44
+ o != null && d(o);
45
+ }, [o, d]), C(() => {
46
+ setTimeout(() => {
47
+ var v;
48
+ (v = p.current) == null || v.focus();
49
+ }, 100);
50
+ }, [e.operator]), e.operator === "between" ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
51
+ /* @__PURE__ */ s.jsx(
52
+ "input",
53
+ {
54
+ ref: p,
55
+ type: "number",
56
+ className: O.valueInput,
57
+ value: u ?? "",
58
+ onChange: (v) => c($(v))
59
+ }
60
+ ),
61
+ /* @__PURE__ */ s.jsx("button", { disabled: !0, className: O.operatorButton, children: h.t("editors.filterBuilder.betweenAnd") }),
62
+ /* @__PURE__ */ s.jsx(
63
+ "input",
64
+ {
65
+ type: "number",
66
+ className: O.valueInput,
67
+ value: n ?? "",
68
+ onChange: (v) => i($(v))
69
+ }
70
+ )
71
+ ] }) : /* @__PURE__ */ s.jsx(
72
+ "input",
73
+ {
74
+ ref: p,
75
+ type: "number",
76
+ className: O.valueInput,
77
+ value: o ?? "",
78
+ onChange: (v) => f($(v))
79
+ }
80
+ );
81
+ }, He = ({
82
+ filter: e,
83
+ onSelectValue: r
84
+ }) => {
85
+ const [o, f] = T((e == null ? void 0 : e.value) ?? ""), u = q(null), c = te((n) => {
86
+ r(n);
87
+ });
88
+ return C(() => {
89
+ c(o || null);
90
+ }, [o, c]), C(() => {
91
+ setTimeout(() => {
92
+ var n;
93
+ (n = u.current) == null || n.focus();
94
+ }, 100);
95
+ }, [e.operator]), /* @__PURE__ */ s.jsx(
96
+ "input",
97
+ {
98
+ ref: u,
99
+ type: "text",
100
+ className: O.valueInput,
101
+ value: o,
102
+ onChange: (n) => f(n.target.value)
103
+ }
104
+ );
105
+ }, g = {
106
+ is: "is",
107
+ isNot: "isNot",
108
+ isOneOf: "isOneOf",
109
+ isNotOneOf: "isNotOneOf",
110
+ contains: "contains"
111
+ }, Ke = {
112
+ [g.is]: m.equals,
113
+ [g.isNot]: m.notEquals,
114
+ [g.isOneOf]: m.contains,
115
+ [g.isNotOneOf]: m.notContains,
116
+ [g.contains]: m.contains
117
+ }, y = {
118
+ equals: m.equals,
119
+ notEquals: m.notEquals,
120
+ gte: m.gte,
121
+ lte: m.lte,
122
+ between: "between"
123
+ }, Ye = {
124
+ [y.equals]: m.equals,
125
+ [y.notEquals]: m.notEquals,
126
+ [y.gte]: m.gte,
127
+ [y.lte]: m.lte
128
+ }, U = {
129
+ AND: "and"
130
+ }, Ge = [
131
+ x.string,
132
+ x.boolean,
133
+ x.number
134
+ ], se = (e) => e.filter(
135
+ (r) => Ge.includes(r.nativeType)
136
+ ), Qe = (e) => {
137
+ var o;
138
+ if (e.operator === y.between && ((o = e.dimensionOrMeasure) == null ? void 0 : o.nativeType) === x.number) {
139
+ const [f, u] = e.value;
140
+ return [
141
+ {
142
+ operator: U.AND,
143
+ clauses: [
144
+ { property: e.dimensionOrMeasure.name, operator: m.gte, value: f },
145
+ { property: e.dimensionOrMeasure.name, operator: m.lte, value: u }
146
+ ]
147
+ }
148
+ ];
149
+ }
150
+ const r = Ke[e.operator] ?? Ye[e.operator];
151
+ return [{ property: e.dimensionOrMeasure.name, operator: r, value: e.value }];
152
+ }, Ze = (e, r) => {
153
+ const o = r.filter((f) => f.dimensionOrMeasure && f.operator && f.value != null).flatMap(Qe);
154
+ return o.length === 0 ? null : { operator: e, clauses: o };
155
+ }, et = (e, r, o) => {
156
+ if ("clauses" in e) {
157
+ const p = e.clauses[0], d = e.clauses[1];
158
+ if (e.operator === U.AND && e.clauses.length === 2 && p != null && d != null && "property" in p && "property" in d && p.property === d.property && p.operator === m.gte && d.operator === m.lte) {
159
+ const v = r.find((M) => M.name === p.property) ?? null;
160
+ return {
161
+ id: o,
162
+ dimensionOrMeasure: v,
163
+ search: "",
164
+ operator: y.between,
165
+ value: [p.value, d.value]
166
+ };
167
+ }
168
+ return null;
169
+ }
170
+ const { property: f, operator: u, value: c } = e, n = r.find((p) => p.name === f) ?? null;
171
+ let i = null;
172
+ return (n == null ? void 0 : n.nativeType) === x.number ? i = {
173
+ [m.equals]: y.equals,
174
+ [m.notEquals]: y.notEquals,
175
+ [m.gte]: y.gte,
176
+ [m.lte]: y.lte
177
+ }[u] ?? null : u === m.contains ? i = Array.isArray(c) ? g.isOneOf : g.contains : i = {
178
+ [m.equals]: g.is,
179
+ [m.notEquals]: g.isNot,
180
+ [m.notContains]: g.isNotOneOf
181
+ }[u] ?? null, { id: o, dimensionOrMeasure: n, search: "", operator: i, value: c };
182
+ }, tt = (e, r) => {
183
+ if (!e) return [];
184
+ if (!("clauses" in e)) return [];
185
+ const o = [];
186
+ return e.clauses.forEach((f, u) => {
187
+ const c = et(f, r, u + 1);
188
+ c && o.push(c);
189
+ }), o.length ? o : [];
190
+ }, nt = (e) => Array.isArray(e) ? e : e == null ? [] : [e], ot = (e, r) => [
191
+ ...e.filter((o) => r.includes(o.value)),
192
+ ...e.filter((o) => !r.includes(o.value))
193
+ ], st = (e, r) => e.length === 0 ? "..." : e.length > 2 ? `${e.length} selected` : e.map(r).join(", "), ee = ({
194
+ hasValue: e,
195
+ isLoading: r,
196
+ displayValue: o,
197
+ showClearIcon: f,
198
+ onClear: u,
199
+ ...c
200
+ }) => /* @__PURE__ */ s.jsxs("button", { className: _e(O.valueButton, !e && O.valueButtonEmpty), ...c, children: [
201
+ r ? /* @__PURE__ */ s.jsx(Be, { className: O.loadingSpinner }) : o,
202
+ f && /* @__PURE__ */ s.jsx(ne, { onClick: u })
203
+ ] }), rt = ({
204
+ filter: e,
205
+ dimensionOrMeasure: r,
206
+ results: o,
207
+ theme: f,
208
+ onSelectValue: u,
209
+ onSearchValue: c
210
+ }) => {
211
+ var L, V;
212
+ const n = Ae(f), i = q({}), p = ((L = o == null ? void 0 : o.data) == null ? void 0 : L.map((_) => ({
213
+ value: _[r.name],
214
+ label: n.data(r, _[r.name])
215
+ }))) ?? [];
216
+ p.forEach(({ value: _, label: B }) => {
217
+ _ != null && (i.current[_] = B);
218
+ });
219
+ const d = (_) => i.current[_] ?? _, v = nt(e.value), M = ot(p, v), b = o == null ? void 0 : o.isLoading, I = !b && (((V = o == null ? void 0 : o.data) == null ? void 0 : V.length) ?? 0) === 0;
220
+ if (r.nativeType === x.number)
221
+ return /* @__PURE__ */ s.jsx(Xe, { filter: e, onSelectValue: u });
222
+ if (r.nativeType === x.string && e.operator === g.contains)
223
+ return /* @__PURE__ */ s.jsx(He, { filter: e, onSelectValue: u });
224
+ const F = e.operator === g.isOneOf || e.operator === g.isNotOneOf, j = e.value != null, A = !b && j;
225
+ if (F) {
226
+ const _ = e.value ?? [], B = st(_, d);
227
+ return /* @__PURE__ */ s.jsx(
228
+ Oe,
229
+ {
230
+ triggerComponent: /* @__PURE__ */ s.jsx(
231
+ ee,
232
+ {
233
+ hasValue: j,
234
+ isLoading: b,
235
+ displayValue: B,
236
+ showClearIcon: A,
237
+ onClear: () => u(null)
238
+ }
239
+ ),
240
+ isSearchable: !0,
241
+ isClearable: !0,
242
+ isLoading: b,
243
+ values: _,
244
+ options: M,
245
+ onChange: (E) => u(E.length === 0 ? null : E),
246
+ onSearch: c,
247
+ avoidCollisions: !1,
248
+ noOptionsMessage: I ? h.t("common.noOptionsFound") : void 0
249
+ }
250
+ );
251
+ }
252
+ if (e.operator === g.is || e.operator === g.isNot) {
253
+ const _ = e.value != null ? d(e.value) : "...";
254
+ return /* @__PURE__ */ s.jsx(
255
+ W,
256
+ {
257
+ triggerComponent: /* @__PURE__ */ s.jsx(
258
+ ee,
259
+ {
260
+ hasValue: j,
261
+ isLoading: b,
262
+ displayValue: _,
263
+ showClearIcon: A,
264
+ onClear: () => u(null)
265
+ }
266
+ ),
267
+ searchable: !0,
268
+ clearable: !0,
269
+ isLoading: b,
270
+ value: e.value,
271
+ options: M,
272
+ onChange: u,
273
+ onSearch: c,
274
+ avoidCollisions: !1,
275
+ noOptionsMessage: I ? h.t("common.noOptionsFound") : void 0
276
+ }
277
+ );
278
+ }
279
+ return null;
280
+ }, lt = () => [
281
+ { value: g.is, label: h.t("editors.filterBuilder.is") },
282
+ { value: g.isNot, label: h.t("editors.filterBuilder.isNot") },
283
+ { value: g.isOneOf, label: h.t("editors.filterBuilder.isOneOf") },
284
+ { value: g.isNotOneOf, label: h.t("editors.filterBuilder.isNotOneOf") },
285
+ { value: g.contains, label: h.t("editors.filterBuilder.contains") }
286
+ ], it = () => [
287
+ { value: g.is, label: h.t("editors.filterBuilder.is") },
288
+ { value: g.isNot, label: h.t("editors.filterBuilder.isNot") },
289
+ { value: g.isOneOf, label: h.t("editors.filterBuilder.isOneOf") },
290
+ { value: g.isNotOneOf, label: h.t("editors.filterBuilder.isNotOneOf") }
291
+ ], at = () => [
292
+ { value: y.equals, label: h.t("editors.filterBuilder.equals") },
293
+ { value: y.notEquals, label: h.t("editors.filterBuilder.doesNotEqual") },
294
+ { value: y.gte, label: h.t("editors.filterBuilder.greaterThanOrEqualTo") },
295
+ { value: y.lte, label: h.t("editors.filterBuilder.lessThanOrEqualTo") },
296
+ { value: y.between, label: h.t("editors.filterBuilder.between") }
297
+ ], ut = ({
298
+ dimensionOrMeasure: e,
299
+ filter: r,
300
+ results: o,
301
+ theme: f,
302
+ onSelectOperator: u,
303
+ onSelectValue: c,
304
+ onSearchValue: n
305
+ }) => {
306
+ var p;
307
+ let i;
308
+ return e.nativeType === x.number ? i = at() : e.nativeType === x.boolean ? i = it() : i = lt(), C(() => {
309
+ r.operator || u(i[0].value);
310
+ }), /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
311
+ /* @__PURE__ */ s.jsx(
312
+ W,
313
+ {
314
+ triggerComponent: /* @__PURE__ */ s.jsx("button", { className: O.operatorButton, children: (p = i.find((d) => d.value === r.operator)) == null ? void 0 : p.label }),
315
+ value: r.operator,
316
+ options: i,
317
+ onChange: u,
318
+ avoidCollisions: !1
319
+ }
320
+ ),
321
+ /* @__PURE__ */ s.jsx(
322
+ rt,
323
+ {
324
+ filter: r,
325
+ dimensionOrMeasure: e,
326
+ results: o,
327
+ theme: f,
328
+ onSelectValue: c,
329
+ onSearchValue: n
330
+ }
331
+ )
332
+ ] });
333
+ }, ct = ({
334
+ filter: e,
335
+ dimensionsAndMeasures: r,
336
+ results: o,
337
+ theme: f,
338
+ onSelectDimensionOrMeasure: u,
339
+ onSelectOperator: c,
340
+ onSelectValue: n,
341
+ onSearchValue: i,
342
+ onDelete: p
343
+ }) => {
344
+ var j;
345
+ const { dimensionOrMeasure: d } = e, [v, M] = T(""), b = se(r), I = J({
346
+ dimensionsAndMeasures: b,
347
+ theme: f
348
+ }), D = J({
349
+ dimensionsAndMeasures: b,
350
+ searchValue: v,
351
+ theme: f
352
+ }), z = (j = I.find(
353
+ (A) => A.value === (d == null ? void 0 : d.name)
354
+ )) == null ? void 0 : j.label, F = () => d ? /* @__PURE__ */ s.jsx("button", { className: O.memberButton, children: z }) : /* @__PURE__ */ s.jsxs("button", { className: O.addButton, children: [
355
+ /* @__PURE__ */ s.jsx(oe, {}),
356
+ /* @__PURE__ */ s.jsx("span", { children: h.t("editors.filterBuilder.addFilter") })
357
+ ] });
358
+ return /* @__PURE__ */ s.jsxs("div", { className: O.filter, children: [
359
+ /* @__PURE__ */ s.jsx(
360
+ W,
361
+ {
362
+ triggerComponent: F(),
363
+ searchable: !0,
364
+ value: d == null ? void 0 : d.name,
365
+ onChange: u,
366
+ onSearch: M,
367
+ options: D,
368
+ avoidCollisions: !1,
369
+ noOptionsMessage: h.t("common.noOptionsFound")
370
+ }
371
+ ),
372
+ d && /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
373
+ /* @__PURE__ */ s.jsx(
374
+ ut,
375
+ {
376
+ dimensionOrMeasure: d,
377
+ filter: e,
378
+ results: o,
379
+ theme: f,
380
+ onSelectOperator: c,
381
+ onSelectValue: n,
382
+ onSearchValue: i
383
+ }
384
+ ),
385
+ /* @__PURE__ */ s.jsx("button", { className: O.deleteButton, onClick: p, children: /* @__PURE__ */ s.jsx(ne, {}) })
386
+ ] })
387
+ ] });
388
+ }, X = (e) => {
389
+ var H, K, Y, G, Q, Z;
390
+ const r = ge();
391
+ Me(r);
392
+ const { title: o, description: f, tooltip: u } = Te(e), {
393
+ dimensionsAndMeasures: c = [],
394
+ setEmbeddableState: n,
395
+ embeddableState: i,
396
+ onChange: p,
397
+ defaultFilters: d
398
+ } = e, [v, M] = T(""), [b, I] = T(!1), [D, z] = T(!1), F = q(null), j = q(void 0), A = q(!0);
399
+ C(() => {
400
+ if (!d || !(c != null && c.length))
401
+ return;
402
+ const t = tt(d, c);
403
+ t.length > 0 && (n == null || n((l) => {
404
+ var a;
405
+ return (a = l == null ? void 0 : l.filters) != null && a.length ? l : { ...l, filters: t };
406
+ })), setTimeout(() => {
407
+ A.current = !1;
408
+ }, 100);
409
+ }, [d, c]);
410
+ const R = xe(() => {
411
+ const t = F.current;
412
+ t && (z(t.scrollLeft > 1), I(t.scrollLeft + t.clientWidth < t.scrollWidth - 1));
413
+ }, []), L = () => {
414
+ var t;
415
+ (t = F.current) == null || t.scrollBy({ left: 200, behavior: "smooth" });
416
+ }, V = () => {
417
+ var t;
418
+ (t = F.current) == null || t.scrollBy({ left: -200, behavior: "smooth" });
419
+ };
420
+ C(() => {
421
+ const t = F.current;
422
+ if (!t) return;
423
+ const l = new ResizeObserver(R);
424
+ return l.observe(t), t.addEventListener("scroll", R), R(), () => {
425
+ l.disconnect(), t.removeEventListener("scroll", R);
426
+ };
427
+ }, [R, i == null ? void 0 : i.filters]);
428
+ const _ = ((K = (H = i == null ? void 0 : i.filters) == null ? void 0 : H[i.filters.length - 1]) == null ? void 0 : K.id) ?? 0, B = (Y = i == null ? void 0 : i.filters) == null ? void 0 : Y[i.filters.length - 1], E = `${B == null ? void 0 : B.id}-${(G = B == null ? void 0 : B.dimensionOrMeasure) == null ? void 0 : G.name}-${B == null ? void 0 : B.operator}-${JSON.stringify(B == null ? void 0 : B.value)}`;
429
+ C(() => {
430
+ A.current || setTimeout(() => {
431
+ var t;
432
+ (t = F.current) == null || t.scrollTo({ left: F.current.scrollWidth, behavior: "smooth" });
433
+ }, 100);
434
+ }, [E]);
435
+ const P = (t = null) => {
436
+ const l = c.find((a) => a.name === t) ?? null;
437
+ return { id: _ + 1, dimensionOrMeasure: l, search: "", operator: null, value: null };
438
+ }, w = (Q = i == null ? void 0 : i.filters) != null && Q.length ? i.filters : [P()], re = (t, l) => {
439
+ n == null || n((a) => {
440
+ const N = [...(a == null ? void 0 : a.filters) ?? []], k = N[t];
441
+ return N[t] = {
442
+ ...P(l),
443
+ ...k != null && k.id ? { id: k.id } : {}
444
+ }, { ...a, filters: N };
445
+ });
446
+ }, le = (t, l) => {
447
+ n == null || n((a) => {
448
+ const N = [...(a == null ? void 0 : a.filters) ?? []];
449
+ return N[t] = { ...N[t], operator: l, value: null }, { ...a, filters: N };
450
+ });
451
+ }, ie = (t, l) => {
452
+ n == null || n((a) => {
453
+ const N = [...(a == null ? void 0 : a.filters) ?? []];
454
+ return N[t] = { ...N[t], value: l }, { ...a, filters: N };
455
+ });
456
+ }, ae = (t, l) => {
457
+ n == null || n((a) => {
458
+ const N = [...(a == null ? void 0 : a.filters) ?? []];
459
+ return N[t] = { ...N[t], search: l }, { ...a, filters: N };
460
+ });
461
+ }, ue = (t) => {
462
+ n == null || n((l) => {
463
+ const a = [...(l == null ? void 0 : l.filters) ?? []];
464
+ return a.splice(t, 1), { ...l, filters: a };
465
+ });
466
+ }, ce = (t) => {
467
+ n == null || n((l) => {
468
+ const a = [...(l == null ? void 0 : l.filters) ?? [], P(t)];
469
+ return { ...l, filters: a };
470
+ }), setTimeout(() => {
471
+ var l;
472
+ (l = F.current) == null || l.scrollTo({ left: F.current.scrollWidth, behavior: "smooth" });
473
+ }, 0);
474
+ };
475
+ C(() => {
476
+ const t = Ze(U.AND, w);
477
+ JSON.stringify(t) !== JSON.stringify(j.current) && (j.current = t, p == null || p(t));
478
+ }, [w]);
479
+ const de = se(c), pe = J({
480
+ dimensionsAndMeasures: de,
481
+ searchValue: v,
482
+ theme: r
483
+ }), fe = w.some((t) => t.dimensionOrMeasure && t.operator && t.value != null), me = () => {
484
+ n == null || n((t) => ({ ...t, filters: [P()] }));
485
+ };
486
+ return /* @__PURE__ */ s.jsx(Se, { title: o, description: f, tooltip: u, children: /* @__PURE__ */ s.jsxs("div", { className: O.container, children: [
487
+ D && /* @__PURE__ */ s.jsx("button", { className: O.scrollLeftButton, onClick: V, children: /* @__PURE__ */ s.jsx(Ne, {}) }),
488
+ /* @__PURE__ */ s.jsx("div", { className: O.scroll, ref: F, children: w.map((t, l) => /* @__PURE__ */ s.jsx(je.Fragment, { children: /* @__PURE__ */ s.jsx(
489
+ ct,
490
+ {
491
+ filter: t,
492
+ dimensionsAndMeasures: c,
493
+ results: e[`filterResults${t.id}`],
494
+ theme: r,
495
+ onSelectDimensionOrMeasure: (a) => re(l, a),
496
+ onSelectOperator: (a) => le(l, a),
497
+ onSelectValue: (a) => ie(l, a),
498
+ onSearchValue: (a) => ae(l, a),
499
+ onDelete: () => ue(l)
500
+ }
501
+ ) }, t.id)) }),
502
+ b && /* @__PURE__ */ s.jsx("button", { className: O.scrollRightButton, onClick: L, children: /* @__PURE__ */ s.jsx(ye, {}) }),
503
+ ((Z = w[0]) == null ? void 0 : Z.dimensionOrMeasure) && /* @__PURE__ */ s.jsx(
504
+ W,
505
+ {
506
+ triggerComponent: /* @__PURE__ */ s.jsx(Fe, { icon: oe }),
507
+ searchable: !0,
508
+ onChange: (t) => ce(t),
509
+ onSearch: M,
510
+ options: pe,
511
+ avoidCollisions: !1,
512
+ noOptionsMessage: h.t("common.noOptionsFound")
513
+ }
514
+ ),
515
+ fe && /* @__PURE__ */ s.jsx("button", { className: O.clearButton, onClick: me, children: h.t("editors.filterBuilder.clearAll") })
516
+ ] }) });
517
+ }, Ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
518
+ __proto__: null,
519
+ default: X
520
+ }, Symbol.toStringTag, { value: "Module" })), dt = {
521
+ name: "FilterBuilderPro",
522
+ label: "Filter Builder",
523
+ description: "Free-form filter builder that lets end users compose member/operator/value clauses. Use to expose ad-hoc filtering on a dataset.",
524
+ category: "Filters",
525
+ defaultWidth: 600,
526
+ defaultHeight: 120,
527
+ inputs: [
528
+ S.dataset,
529
+ {
530
+ ...S.dimensionsAndMeasures,
531
+ config: {
532
+ ...S.dimensionsAndMeasures.config,
533
+ supportedTypes: ["string", "number", "boolean"]
534
+ }
535
+ },
536
+ {
537
+ ...S.filters,
538
+ name: "defaultFilters",
539
+ label: "Default filters",
540
+ defaultValue: null
541
+ },
542
+ S.title,
543
+ S.description,
544
+ S.tooltip
545
+ ],
546
+ events: [
547
+ {
548
+ name: "onChange",
549
+ label: "Filter value updated",
550
+ properties: [
551
+ {
552
+ name: "value",
553
+ type: "filters"
554
+ }
555
+ ]
556
+ }
557
+ ],
558
+ variables: [
559
+ {
560
+ name: "filter value",
561
+ type: "filters",
562
+ defaultValue: {},
563
+ inputs: ["defaultFilters"],
564
+ events: [{ name: "onChange", property: "value" }]
565
+ }
566
+ ]
567
+ }, pt = he(X, {}), ft = (e, [r, o]) => {
568
+ var u;
569
+ const f = (u = r == null ? void 0 : r.filters) == null ? void 0 : u.reduce((c, n) => {
570
+ var d;
571
+ if (((d = n.dimensionOrMeasure) == null ? void 0 : d.__type__) !== "dimension" || !n.operator)
572
+ return c;
573
+ const { dimensionOrMeasure: i } = n, p = i.nativeType === "string" ? m.contains : m.equals;
574
+ return c[`filterResults${n.id}`] = Ce({
575
+ from: e.dataset,
576
+ select: [n.dimensionOrMeasure],
577
+ filters: n.search ? [{ operator: p, property: i, value: n.search }] : void 0
578
+ }), c;
579
+ }, {});
580
+ return {
581
+ ...e,
582
+ embeddableState: r,
583
+ setEmbeddableState: o,
584
+ dimensionsAndMeasures: e.dimensionsAndMeasures ?? [],
585
+ ...f
586
+ };
587
+ }, mt = {
588
+ onChange: (e) => ({
589
+ value: e ?? be.noFilter()
590
+ })
591
+ }, bt = {
592
+ Component: X,
593
+ meta: dt,
594
+ preview: pt,
595
+ config: {
596
+ props: ft,
597
+ events: mt
598
+ }
599
+ };
600
+ export {
601
+ bt as f,
602
+ Ft as i
603
+ };
604
+ //# sourceMappingURL=definition-es5n86g4.js.map