@embeddable.com/remarkable-pro 0.3.4 → 0.3.5

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