@iclips/ui 4.1.3 → 4.2.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.
@@ -1,15 +1,17 @@
1
- import { jsxs as u, jsx as l, Fragment as H } from "react/jsx-runtime";
2
- import k from "react";
3
- import { cn as b } from "../utils.js";
4
- import { Button as v } from "../primitives/button.js";
5
- import { Plus as j, Search as B, X as P } from "lucide-react";
6
- import { Popover as y, PopoverTrigger as w, PopoverContent as S } from "../overlays/popover.js";
7
- import { Badge as I } from "../primitives/badge.js";
8
- import { Input as R } from "../forms/input.js";
9
- import { Checkbox as M } from "../forms/checkbox.js";
10
- import { Label as L } from "../primitives/label.js";
11
- import { DatePicker as D } from "../forms/date-picker.js";
12
- const T = [
1
+ import { jsxs as c, jsx as r, Fragment as L } from "react/jsx-runtime";
2
+ import w from "react";
3
+ import { cn as S } from "../utils.js";
4
+ import { Button as f } from "../primitives/button.js";
5
+ import { Plus as W, Search as Z, X as j } from "lucide-react";
6
+ import { Popover as A, PopoverTrigger as P, PopoverContent as k, PopoverAnchor as U } from "../overlays/popover.js";
7
+ import { Badge as F } from "../primitives/badge.js";
8
+ import { Input as E } from "../forms/input.js";
9
+ import { Checkbox as ee } from "../forms/checkbox.js";
10
+ import { Label as X } from "../primitives/label.js";
11
+ import { DatePicker as ae } from "../forms/date-picker.js";
12
+ import { DateRangePicker as le } from "../forms/date-range-picker.js";
13
+ import { MonthRangePicker as re } from "../forms/month-range-picker.js";
14
+ const C = [
13
15
  { value: "is", label: "é", multiSelect: !1 },
14
16
  { value: "is_not", label: "não é", multiSelect: !1 },
15
17
  { value: "is_any_of", label: "é qualquer um de", multiSelect: !0 },
@@ -20,68 +22,94 @@ const T = [
20
22
  { value: "greater_than_or_equal", label: "maior ou igual a", multiSelect: !1 },
21
23
  { value: "less_than", label: "menor que", multiSelect: !1 },
22
24
  { value: "less_than_or_equal", label: "menor ou igual a", multiSelect: !1 },
25
+ { value: "between", label: "está entre", multiSelect: !1 },
23
26
  { value: "is_empty", label: "está vazio", multiSelect: !1 },
24
27
  { value: "is_not_empty", label: "não está vazio", multiSelect: !1 }
25
- ];
26
- function ee({
27
- conditions: r,
28
- onConditionsChange: d,
29
- fields: x,
30
- className: n
28
+ ], Y = "between";
29
+ function G(a) {
30
+ var o;
31
+ return $(a) ? C.filter((s) => s.value === Y) : (o = a == null ? void 0 : a.operators) != null && o.length ? a.operators.map((s) => C.find((u) => u.value === s)).filter((s) => !!s) : C.filter((s) => s.value !== Y);
32
+ }
33
+ function M(a) {
34
+ var o;
35
+ return ((o = G(a)[0]) == null ? void 0 : o.value) ?? "is";
36
+ }
37
+ function H(a, o, s) {
38
+ const u = new Set(o.filter((i) => i.id !== s).map((i) => i.field));
39
+ return a.filter((i) => !(i.unique && u.has(i.value)));
40
+ }
41
+ function $(a) {
42
+ return (a == null ? void 0 : a.type) === "dateRange" || (a == null ? void 0 : a.type) === "monthRange";
43
+ }
44
+ function D(a) {
45
+ const o = String(a.getMonth() + 1).padStart(2, "0"), s = String(a.getDate()).padStart(2, "0");
46
+ return `${a.getFullYear()}-${o}-${s}`;
47
+ }
48
+ function z(a) {
49
+ return /* @__PURE__ */ new Date(`${a}T00:00:00`);
50
+ }
51
+ function be({
52
+ conditions: a,
53
+ onConditionsChange: o,
54
+ fields: s,
55
+ className: u
31
56
  }) {
32
- const _ = () => {
33
- var m;
34
- const s = {
57
+ const i = H(s, a).find(
58
+ (m) => !a.some((h) => h.field === m.value)
59
+ ) ?? H(s, a)[0], l = () => {
60
+ if (!i) return;
61
+ const m = {
35
62
  id: Math.random().toString(36).substr(2, 9),
36
- field: ((m = x[0]) == null ? void 0 : m.value) || "",
37
- operator: "is",
38
- value: ""
63
+ field: i.value,
64
+ operator: M(i),
65
+ value: i.multiSelect || $(i) ? [] : ""
39
66
  };
40
- d([...r, s]);
41
- }, a = (s) => {
42
- d(r.filter((m) => m.id !== s));
43
- }, h = (s, m) => {
44
- d(
45
- r.map((c) => c.id === s ? { ...c, ...m } : c)
67
+ o([...a, m]);
68
+ }, d = (m) => {
69
+ o(a.filter((h) => h.id !== m));
70
+ }, v = (m, h) => {
71
+ o(
72
+ a.map((g) => g.id === m ? { ...g, ...h } : g)
46
73
  );
47
74
  };
48
- return /* @__PURE__ */ u("div", { className: b("space-y-3", n), children: [
49
- r.length === 0 ? /* @__PURE__ */ l("div", { className: "text-center py-8 text-muted-foreground text-sm", children: 'Nenhuma condição de filtro. Clique em "Adicionar condição" para começar.' }) : r.map((s, m) => /* @__PURE__ */ l(
50
- E,
75
+ return /* @__PURE__ */ c("div", { className: S("space-y-3", u), children: [
76
+ a.length === 0 ? /* @__PURE__ */ r("div", { className: "text-center py-8 text-muted-foreground text-sm", children: 'Nenhuma condição de filtro. Clique em "Adicionar condição" para começar.' }) : a.map((m, h) => /* @__PURE__ */ r(
77
+ te,
51
78
  {
52
- condition: s,
53
- fields: x,
54
- index: m,
55
- onUpdate: (c) => h(s.id, c),
56
- onRemove: () => a(s.id)
79
+ condition: m,
80
+ fields: H(s, a, m.id),
81
+ index: h,
82
+ onUpdate: (g) => v(m.id, g),
83
+ onRemove: () => d(m.id)
57
84
  },
58
- s.id
85
+ m.id
59
86
  )),
60
- /* @__PURE__ */ u(
61
- v,
87
+ /* @__PURE__ */ c(
88
+ f,
62
89
  {
63
90
  type: "button",
64
91
  variant: "outline",
65
92
  size: "sm",
66
- onClick: _,
93
+ onClick: l,
94
+ disabled: !i,
67
95
  className: "gap-2",
68
96
  children: [
69
- /* @__PURE__ */ l(j, { className: "h-4 w-4" }),
97
+ /* @__PURE__ */ r(W, { className: "h-4 w-4" }),
70
98
  "Adicionar condição"
71
99
  ]
72
100
  }
73
101
  )
74
102
  ] });
75
103
  }
76
- function E({
77
- condition: r,
78
- fields: d,
79
- index: x,
80
- onUpdate: n,
81
- onRemove: _
104
+ function te({
105
+ condition: a,
106
+ fields: o,
107
+ index: s,
108
+ onUpdate: u,
109
+ onRemove: i
82
110
  }) {
83
- var q;
84
- const a = d.find((e) => e.value === r.field), h = T.find((e) => e.value === r.operator), s = (a == null ? void 0 : a.multiSelect) || (h == null ? void 0 : h.multiSelect) || !1, m = !["is_empty", "is_not_empty"].includes(r.operator), [c, A] = k.useState(""), p = k.useMemo(() => a != null && a.groups ? a.groups.flatMap((e) => [
111
+ var B;
112
+ const l = o.find((e) => e.value === a.field), d = C.find((e) => e.value === a.operator), v = (l == null ? void 0 : l.multiSelect) || (d == null ? void 0 : d.multiSelect) || !1, m = !["is_empty", "is_not_empty"].includes(a.operator), h = $(l), g = G(l), x = Array.isArray(a.value) ? a.value : [], [_, O] = w.useState(""), T = w.useRef(null), [I, J] = w.useState(null), N = w.useMemo(() => l != null && l.groups ? l.groups.flatMap((e) => [
85
113
  {
86
114
  value: e.value ?? `__label__${e.label}`,
87
115
  label: e.label,
@@ -95,88 +123,93 @@ function E({
95
123
  selecionavel: !0,
96
124
  isFilho: !0
97
125
  }))
98
- ]) : ((a == null ? void 0 : a.options) ?? []).map((e) => ({
126
+ ]) : ((l == null ? void 0 : l.options) ?? []).map((e) => ({
99
127
  value: e.value,
100
128
  label: e.label,
101
129
  isHeader: !1,
102
130
  selecionavel: !0
103
- })), [a == null ? void 0 : a.options, a == null ? void 0 : a.groups]), z = k.useMemo(() => {
104
- if (!c) return p;
105
- const e = c.toLowerCase(), t = (o) => o.label.toLowerCase().includes(e) || o.value.toLowerCase().includes(e);
106
- if (!(a != null && a.groups)) return p.filter(t);
107
- const i = [];
108
- let f = null, C = !1, N = !1;
109
- for (const o of p) {
110
- if (o.isHeader) {
111
- f = o, C = t(o), N = !1, C && (i.push(o), N = !0);
131
+ })), [l == null ? void 0 : l.options, l == null ? void 0 : l.groups]), V = w.useMemo(() => {
132
+ if (!_) return N;
133
+ const e = _.toLowerCase(), t = (p) => p.label.toLowerCase().includes(e) || p.value.toLowerCase().includes(e);
134
+ if (!(l != null && l.groups)) return N.filter(t);
135
+ const n = [];
136
+ let b = null, q = !1, R = !1;
137
+ for (const p of N) {
138
+ if (p.isHeader) {
139
+ b = p, q = t(p), R = !1, q && (n.push(p), R = !0);
112
140
  continue;
113
141
  }
114
- (C || t(o)) && (!N && f && (i.push(f), N = !0), i.push(o));
142
+ (q || t(p)) && (!R && b && (n.push(b), R = !0), n.push(p));
115
143
  }
116
- return i;
117
- }, [p, c, a == null ? void 0 : a.groups]), g = Array.isArray(r.value) ? r.value : r.value ? [r.value] : [], V = (e) => {
118
- if (!s) {
119
- n({ value: e });
144
+ return n;
145
+ }, [N, _, l == null ? void 0 : l.groups]), y = Array.isArray(a.value) ? a.value : a.value ? [a.value] : [], K = (e) => {
146
+ if (!v) {
147
+ u({ value: e });
120
148
  return;
121
149
  }
122
- const t = Array.isArray(r.value) ? r.value : [], i = t.includes(e) ? t.filter((f) => f !== e) : [...t, e];
123
- n({ value: i });
124
- }, $ = (e) => {
125
- if (!s) return;
126
- const t = Array.isArray(r.value) ? r.value : [];
127
- n({ value: t.filter((i) => i !== e) });
150
+ const t = Array.isArray(a.value) ? a.value : [], n = t.includes(e) ? t.filter((b) => b !== e) : [...t, e];
151
+ u({ value: n });
152
+ }, Q = (e) => {
153
+ if (!v) return;
154
+ const t = Array.isArray(a.value) ? a.value : [];
155
+ u({ value: t.filter((n) => n !== e) });
128
156
  };
129
- return /* @__PURE__ */ u("div", { className: "flex items-start gap-2 group", children: [
130
- /* @__PURE__ */ l("div", { className: "flex items-center h-9 px-2 text-sm text-muted-foreground", children: x === 0 ? "Onde" : "E" }),
131
- /* @__PURE__ */ u("div", { className: "flex-1 flex items-center gap-2 flex-wrap p-2 border rounded-lg bg-background", children: [
132
- /* @__PURE__ */ u(y, { children: [
133
- /* @__PURE__ */ l(w, { asChild: !0, children: /* @__PURE__ */ l(
134
- v,
157
+ return /* @__PURE__ */ c("div", { className: "flex items-start gap-2 group", children: [
158
+ /* @__PURE__ */ r("div", { className: "flex items-center h-9 px-2 text-sm text-muted-foreground", children: s === 0 ? "Onde" : "E" }),
159
+ /* @__PURE__ */ c("div", { className: "flex-1 flex items-center gap-2 flex-wrap p-2 border rounded-lg bg-background", children: [
160
+ /* @__PURE__ */ c(A, { children: [
161
+ /* @__PURE__ */ r(P, { asChild: !0, children: /* @__PURE__ */ r(
162
+ f,
135
163
  {
136
164
  variant: "ghost",
137
165
  size: "sm",
138
166
  className: "h-7 px-2 font-normal hover:bg-muted",
139
- children: (a == null ? void 0 : a.label) || "Selecionar campo"
167
+ children: (l == null ? void 0 : l.label) || "Selecionar campo"
140
168
  }
141
169
  ) }),
142
- /* @__PURE__ */ l(S, { className: "w-[200px] p-2", align: "start", children: /* @__PURE__ */ l("div", { className: "space-y-1", children: d.map((e) => /* @__PURE__ */ l(
143
- v,
170
+ /* @__PURE__ */ r(k, { className: "w-[200px] p-2", align: "start", children: /* @__PURE__ */ r("div", { className: "space-y-1", children: o.map((e) => /* @__PURE__ */ r(
171
+ f,
144
172
  {
145
173
  variant: "ghost",
146
174
  size: "sm",
147
- className: b(
175
+ className: S(
148
176
  "w-full justify-start",
149
- r.field === e.value && "bg-muted"
177
+ a.field === e.value && "bg-muted"
150
178
  ),
151
- onClick: () => n({
152
- field: e.value,
153
- value: e.multiSelect ? [] : ""
154
- }),
179
+ onClick: () => {
180
+ var t;
181
+ return u({
182
+ field: e.value,
183
+ // O operador volta ao inicial do novo campo (restrito por `operators` ou período)
184
+ operator: M(e),
185
+ value: e.multiSelect || $(e) || (t = C.find((n) => n.value === M(e))) != null && t.multiSelect ? [] : ""
186
+ });
187
+ },
155
188
  children: e.label
156
189
  },
157
190
  e.value
158
191
  )) }) })
159
192
  ] }),
160
- /* @__PURE__ */ u(y, { children: [
161
- /* @__PURE__ */ l(w, { asChild: !0, children: /* @__PURE__ */ l(
162
- v,
193
+ /* @__PURE__ */ c(A, { children: [
194
+ /* @__PURE__ */ r(P, { asChild: !0, children: /* @__PURE__ */ r(
195
+ f,
163
196
  {
164
197
  variant: "ghost",
165
198
  size: "sm",
166
199
  className: "h-7 px-2 font-normal hover:bg-muted text-muted-foreground",
167
- children: (h == null ? void 0 : h.label) || "is"
200
+ children: (d == null ? void 0 : d.label) || "is"
168
201
  }
169
202
  ) }),
170
- /* @__PURE__ */ l(S, { className: "w-[200px] p-2", align: "start", children: /* @__PURE__ */ l("div", { className: "space-y-1", children: T.map((e) => /* @__PURE__ */ l(
171
- v,
203
+ /* @__PURE__ */ r(k, { className: "w-[200px] p-2", align: "start", children: /* @__PURE__ */ r("div", { className: "space-y-1", children: g.map((e) => /* @__PURE__ */ r(
204
+ f,
172
205
  {
173
206
  variant: "ghost",
174
207
  size: "sm",
175
- className: b(
208
+ className: S(
176
209
  "w-full justify-start",
177
- r.operator === e.value && "bg-muted"
210
+ a.operator === e.value && "bg-muted"
178
211
  ),
179
- onClick: () => n({
212
+ onClick: () => u({
180
213
  operator: e.value,
181
214
  value: e.multiSelect ? [] : ""
182
215
  }),
@@ -185,120 +218,150 @@ function E({
185
218
  e.value
186
219
  )) }) })
187
220
  ] }),
188
- m && /* @__PURE__ */ u(H, { children: [
189
- a != null && a.options || a != null && a.groups ? (
221
+ m && /* @__PURE__ */ c(L, { children: [
222
+ h ? (l == null ? void 0 : l.type) === "monthRange" ? /* @__PURE__ */ r(
223
+ re,
224
+ {
225
+ value: x.length === 2 ? { from: z(x[0]), to: z(x[1]) } : void 0,
226
+ onChange: (e) => u({ value: e ? [D(e.from), D(e.to)] : [] }),
227
+ className: "h-7 text-sm"
228
+ }
229
+ ) : /* @__PURE__ */ r(
230
+ le,
231
+ {
232
+ value: x.length === 2 ? { from: z(x[0]), to: z(x[1]) } : void 0,
233
+ onChange: (e) => u({
234
+ value: e != null && e.from && (e != null && e.to) ? [D(e.from), D(e.to)] : []
235
+ }),
236
+ className: "h-7 text-sm"
237
+ }
238
+ ) : l != null && l.options || l != null && l.groups ? (
190
239
  // Select field with options
191
- /* @__PURE__ */ u(y, { onOpenChange: (e) => !e && A(""), children: [
192
- /* @__PURE__ */ l(w, { asChild: !0, children: /* @__PURE__ */ l(
193
- v,
194
- {
195
- variant: "ghost",
196
- size: "sm",
197
- className: "h-7 px-2 font-normal hover:bg-muted",
198
- children: s && g.length > 0 ? /* @__PURE__ */ u("span", { className: "flex items-center gap-1", children: [
199
- g.length,
200
- " selecionado",
201
- g.length > 1 ? "s" : ""
202
- ] }) : !s && r.value && ((q = p.find((e) => e.value === r.value)) == null ? void 0 : q.label) || "Selecionar valor"
203
- }
204
- ) }),
205
- /* @__PURE__ */ l(
206
- S,
207
- {
208
- className: "w-80 max-w-[calc(100vw-2rem)] p-3",
209
- align: "start",
210
- collisionPadding: 8,
211
- children: /* @__PURE__ */ u("div", { className: "space-y-2", children: [
212
- /* @__PURE__ */ l(L, { className: "text-xs text-muted-foreground", children: s ? "Selecionar valores" : "Selecionar valor" }),
213
- /* @__PURE__ */ u("div", { className: "relative", children: [
214
- /* @__PURE__ */ l(B, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
215
- /* @__PURE__ */ l(
216
- R,
217
- {
218
- type: "text",
219
- placeholder: "Buscar...",
220
- value: c,
221
- onChange: (e) => A(e.target.value),
222
- className: "h-9 pl-8",
223
- autoFocus: !0
224
- }
225
- )
226
- ] }),
227
- /* @__PURE__ */ l("div", { className: "space-y-2 max-h-[320px] overflow-y-auto overflow-x-hidden", children: z.length === 0 ? /* @__PURE__ */ l("div", { className: "text-sm text-muted-foreground text-center py-4", children: "Nenhum resultado encontrado" }) : z.map((e) => {
228
- if (e.isHeader && !e.selecionavel)
229
- return /* @__PURE__ */ l(
230
- "div",
231
- {
232
- title: e.label,
233
- className: "truncate pt-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
234
- children: e.label
235
- },
236
- e.value
237
- );
238
- const t = s ? g.includes(e.value) : r.value === e.value;
239
- return /* @__PURE__ */ l(
240
- "div",
241
- {
242
- className: b(
243
- "flex min-w-0 items-center space-x-2",
244
- e.isFilho && "pl-4"
245
- ),
246
- children: s ? /* @__PURE__ */ u(H, { children: [
247
- /* @__PURE__ */ l(
248
- M,
249
- {
250
- id: `${r.id}-${e.value}`,
251
- checked: t,
252
- onCheckedChange: () => V(e.value)
253
- }
254
- ),
255
- /* @__PURE__ */ l(
256
- "label",
240
+ /* @__PURE__ */ c(
241
+ A,
242
+ {
243
+ onOpenChange: (e) => {
244
+ var n;
245
+ e || O("");
246
+ const t = (n = T.current) == null ? void 0 : n.closest('[data-slot="popover-content"]');
247
+ e && J(t ? { current: t } : null);
248
+ },
249
+ children: [
250
+ I && /* @__PURE__ */ r(U, { virtualRef: I }),
251
+ /* @__PURE__ */ r(P, { asChild: !0, children: /* @__PURE__ */ r(
252
+ f,
253
+ {
254
+ ref: T,
255
+ variant: "ghost",
256
+ size: "sm",
257
+ className: "h-7 px-2 font-normal hover:bg-muted",
258
+ children: v && y.length > 0 ? /* @__PURE__ */ c("span", { className: "flex items-center gap-1", children: [
259
+ y.length,
260
+ " selecionado",
261
+ y.length > 1 ? "s" : ""
262
+ ] }) : !v && a.value && ((B = N.find((e) => e.value === a.value)) == null ? void 0 : B.label) || "Selecionar valor"
263
+ }
264
+ ) }),
265
+ /* @__PURE__ */ r(
266
+ k,
267
+ {
268
+ className: "w-80 max-w-[calc(100vw-2rem)] p-3 data-[state=closed]:pointer-events-none",
269
+ align: "start",
270
+ collisionPadding: 8,
271
+ ...I ? { side: "right", sideOffset: 8 } : {},
272
+ children: /* @__PURE__ */ c("div", { className: "space-y-2", children: [
273
+ /* @__PURE__ */ r(X, { className: "text-xs text-muted-foreground", children: v ? "Selecionar valores" : "Selecionar valor" }),
274
+ /* @__PURE__ */ c("div", { className: "relative", children: [
275
+ /* @__PURE__ */ r(Z, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
276
+ /* @__PURE__ */ r(
277
+ E,
278
+ {
279
+ type: "text",
280
+ placeholder: "Buscar...",
281
+ value: _,
282
+ onChange: (e) => O(e.target.value),
283
+ className: "h-9 pl-8",
284
+ autoFocus: !0
285
+ }
286
+ )
287
+ ] }),
288
+ /* @__PURE__ */ r("div", { className: "space-y-2 max-h-[320px] overflow-y-auto overflow-x-hidden", children: V.length === 0 ? /* @__PURE__ */ r("div", { className: "text-sm text-muted-foreground text-center py-4", children: "Nenhum resultado encontrado" }) : V.map((e) => {
289
+ if (e.isHeader && !e.selecionavel)
290
+ return /* @__PURE__ */ r(
291
+ "div",
257
292
  {
258
- htmlFor: `${r.id}-${e.value}`,
259
293
  title: e.label,
260
- className: b(
261
- "min-w-0 flex-1 cursor-pointer truncate text-sm",
262
- e.isHeader && "font-semibold uppercase tracking-wide"
263
- ),
294
+ className: "truncate pt-1 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
264
295
  children: e.label
265
- }
266
- )
267
- ] }) : /* @__PURE__ */ l(
268
- v,
296
+ },
297
+ e.value
298
+ );
299
+ const t = v ? y.includes(e.value) : a.value === e.value;
300
+ return /* @__PURE__ */ r(
301
+ "div",
269
302
  {
270
- variant: "ghost",
271
- size: "sm",
272
- title: e.label,
273
- className: b(
274
- "w-full min-w-0 justify-start",
275
- e.isHeader && "font-semibold uppercase tracking-wide",
276
- t && "bg-muted"
303
+ className: S(
304
+ "flex min-w-0 items-center space-x-2",
305
+ e.isFilho && "pl-4"
277
306
  ),
278
- onClick: () => n({ value: e.value }),
279
- children: /* @__PURE__ */ l("span", { className: "truncate", children: e.label })
280
- }
281
- )
282
- },
283
- e.value
284
- );
285
- }) })
286
- ] })
287
- }
288
- )
289
- ] })
290
- ) : (a == null ? void 0 : a.type) === "date" ? (
307
+ children: v ? /* @__PURE__ */ c(L, { children: [
308
+ /* @__PURE__ */ r(
309
+ ee,
310
+ {
311
+ id: `${a.id}-${e.value}`,
312
+ checked: t,
313
+ onCheckedChange: () => K(e.value)
314
+ }
315
+ ),
316
+ /* @__PURE__ */ r(
317
+ "label",
318
+ {
319
+ htmlFor: `${a.id}-${e.value}`,
320
+ title: e.label,
321
+ className: S(
322
+ "min-w-0 flex-1 cursor-pointer truncate text-sm",
323
+ e.isHeader && "font-semibold uppercase tracking-wide"
324
+ ),
325
+ children: e.label
326
+ }
327
+ )
328
+ ] }) : /* @__PURE__ */ r(
329
+ f,
330
+ {
331
+ variant: "ghost",
332
+ size: "sm",
333
+ title: e.label,
334
+ className: S(
335
+ "w-full min-w-0 justify-start",
336
+ e.isHeader && "font-semibold uppercase tracking-wide",
337
+ t && "bg-muted"
338
+ ),
339
+ onClick: () => u({ value: e.value }),
340
+ children: /* @__PURE__ */ r("span", { className: "truncate", children: e.label })
341
+ }
342
+ )
343
+ },
344
+ e.value
345
+ );
346
+ }) })
347
+ ] })
348
+ }
349
+ )
350
+ ]
351
+ }
352
+ )
353
+ ) : (l == null ? void 0 : l.type) === "date" ? (
291
354
  // Date picker
292
- /* @__PURE__ */ l(
293
- D,
355
+ /* @__PURE__ */ r(
356
+ ae,
294
357
  {
295
- value: r.value ? /* @__PURE__ */ new Date(r.value + "T00:00:00") : void 0,
358
+ value: a.value ? /* @__PURE__ */ new Date(a.value + "T00:00:00") : void 0,
296
359
  onChange: (e) => {
297
360
  if (e) {
298
361
  const t = e.toISOString().split("T")[0];
299
- n({ value: t });
362
+ u({ value: t });
300
363
  } else
301
- n({ value: "" });
364
+ u({ value: "" });
302
365
  },
303
366
  placeholder: "Selecionar data",
304
367
  className: "h-7 text-sm"
@@ -306,24 +369,24 @@ function E({
306
369
  )
307
370
  ) : (
308
371
  // Text/Number input
309
- /* @__PURE__ */ u(y, { children: [
310
- /* @__PURE__ */ l(w, { asChild: !0, children: /* @__PURE__ */ l(
311
- v,
372
+ /* @__PURE__ */ c(A, { children: [
373
+ /* @__PURE__ */ r(P, { asChild: !0, children: /* @__PURE__ */ r(
374
+ f,
312
375
  {
313
376
  variant: "ghost",
314
377
  size: "sm",
315
378
  className: "h-7 px-2 font-normal hover:bg-muted max-w-[200px] truncate",
316
- children: r.value || "Inserir valor"
379
+ children: a.value || "Inserir valor"
317
380
  }
318
381
  ) }),
319
- /* @__PURE__ */ l(S, { className: "w-[240px] p-3", align: "start", children: /* @__PURE__ */ u("div", { className: "space-y-2", children: [
320
- /* @__PURE__ */ l(L, { className: "text-xs text-muted-foreground", children: "Inserir valor" }),
321
- /* @__PURE__ */ l(
322
- R,
382
+ /* @__PURE__ */ r(k, { className: "w-[240px] p-3", align: "start", children: /* @__PURE__ */ c("div", { className: "space-y-2", children: [
383
+ /* @__PURE__ */ r(X, { className: "text-xs text-muted-foreground", children: "Inserir valor" }),
384
+ /* @__PURE__ */ r(
385
+ E,
323
386
  {
324
- type: (a == null ? void 0 : a.type) === "number" ? "number" : "text",
325
- value: Array.isArray(r.value) ? "" : r.value,
326
- onChange: (e) => n({ value: e.target.value }),
387
+ type: (l == null ? void 0 : l.type) === "number" ? "number" : "text",
388
+ value: Array.isArray(a.value) ? "" : a.value,
389
+ onChange: (e) => u({ value: e.target.value }),
327
390
  placeholder: "Digite o valor...",
328
391
  autoFocus: !0
329
392
  }
@@ -331,24 +394,24 @@ function E({
331
394
  ] }) })
332
395
  ] })
333
396
  ),
334
- s && g.length > 0 && /* @__PURE__ */ l("div", { className: "flex items-center gap-1 flex-wrap", children: g.map((e) => {
335
- var i;
336
- const t = ((i = p.find((f) => f.value === e)) == null ? void 0 : i.label) || e;
337
- return /* @__PURE__ */ u(
338
- I,
397
+ v && y.length > 0 && /* @__PURE__ */ r("div", { className: "flex items-center gap-1 flex-wrap", children: y.map((e) => {
398
+ var n;
399
+ const t = ((n = N.find((b) => b.value === e)) == null ? void 0 : n.label) || e;
400
+ return /* @__PURE__ */ c(
401
+ F,
339
402
  {
340
403
  variant: "secondary",
341
404
  className: "gap-1 h-6 text-xs",
342
405
  children: [
343
406
  t,
344
- /* @__PURE__ */ l(
407
+ /* @__PURE__ */ r(
345
408
  "button",
346
409
  {
347
410
  type: "button",
348
- onClick: () => $(e),
411
+ onClick: () => Q(e),
349
412
  className: "ml-1 rounded-sm hover:bg-muted p-0.5 transition-colors",
350
413
  "aria-label": `Remover ${t}`,
351
- children: /* @__PURE__ */ l(P, { className: "h-3 w-3" })
414
+ children: /* @__PURE__ */ r(j, { className: "h-3 w-3" })
352
415
  }
353
416
  )
354
417
  ]
@@ -358,21 +421,21 @@ function E({
358
421
  }) })
359
422
  ] })
360
423
  ] }),
361
- /* @__PURE__ */ l(
362
- v,
424
+ /* @__PURE__ */ r(
425
+ f,
363
426
  {
364
427
  type: "button",
365
428
  variant: "ghost",
366
429
  size: "sm",
367
- onClick: _,
430
+ onClick: i,
368
431
  className: "h-9 w-9 p-0 opacity-100 md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100 transition-opacity",
369
432
  "aria-label": "Remover condição",
370
- children: /* @__PURE__ */ l(P, { className: "h-4 w-4" })
433
+ children: /* @__PURE__ */ r(j, { className: "h-4 w-4" })
371
434
  }
372
435
  )
373
436
  ] });
374
437
  }
375
438
  export {
376
- ee as FilterBuilder
439
+ be as FilterBuilder
377
440
  };
378
441
  //# sourceMappingURL=filter-builder.js.map