@ztwoint/z-ui 0.1.70 → 0.1.71

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,20 +1,20 @@
1
- const v = (l, n) => {
2
- if (l.length !== n.length)
1
+ const v = (u, t) => {
2
+ if (u.length !== t.length)
3
3
  return !1;
4
- const u = [...l].sort((e, t) => e.field.localeCompare(t.field)), r = [...n].sort((e, t) => e.field.localeCompare(t.field));
5
- return u.every((e, t) => {
6
- const a = r[t];
7
- return e.field !== a.field || e.condition !== a.condition ? !1 : Array.isArray(e.value) && Array.isArray(a.value) ? e.value.length !== a.value.length ? !1 : e.value.every((i, s) => i === a.value[s]) : Array.isArray(e.value) || Array.isArray(a.value) ? !1 : e.value === a.value;
4
+ const i = [...u].sort((r, l) => r.field.localeCompare(l.field)), e = [...t].sort((r, l) => r.field.localeCompare(l.field));
5
+ return i.every((r, l) => {
6
+ const a = e[l];
7
+ return r.field !== a.field || r.condition !== a.condition ? !1 : Array.isArray(r.value) && Array.isArray(a.value) ? r.value.length !== a.value.length ? !1 : r.value.every((n, s) => n === a.value[s]) : Array.isArray(r.value) || Array.isArray(a.value) ? !1 : r.value === a.value;
8
8
  });
9
- }, o = (l, n) => {
10
- const u = l.filter((r) => Array.isArray(r.value) ? r.value.length > 0 : r.value !== "");
11
- return !v(u, n);
12
- }, f = (l, n, u) => {
13
- const r = n.find((a) => a.field === l), e = u.find((a) => a.field === l);
14
- return !r || !(Array.isArray(r.value) ? r.value.length > 0 : r.value !== "") ? !1 : !e || r.condition !== e.condition ? !0 : Array.isArray(r.value) && Array.isArray(e.value) ? r.value.length !== e.value.length ? !0 : !r.value.every((a, i) => a === e.value[i]) : Array.isArray(r.value) || Array.isArray(e.value) ? !0 : r.value !== e.value;
9
+ }, o = (u, t) => {
10
+ const i = u.filter((e) => Array.isArray(e.value) ? e.value.length > 0 : e.value !== "");
11
+ return !v(i, t);
12
+ }, y = (u, t, i) => {
13
+ const e = t.find((n) => n.field === u), r = i.find((n) => n.field === u), l = e && (Array.isArray(e.value) ? e.value.length > 0 : e.value !== ""), a = r && (Array.isArray(r.value) ? r.value.length > 0 : r.value !== "");
14
+ return !l && a || l && !a ? !0 : !l && !a ? !1 : l && a && e && r ? e.condition !== r.condition ? !0 : Array.isArray(e.value) && Array.isArray(r.value) ? e.value.length !== r.value.length ? !0 : !e.value.every((n, s) => n === r.value[s]) : Array.isArray(e.value) || Array.isArray(r.value) ? !0 : e.value !== r.value : !1;
15
15
  };
16
16
  export {
17
17
  v as areFiltersEqual,
18
18
  o as hasUnsavedFilterChanges,
19
- f as hasUnsavedFilterChangesForColumn
19
+ y as hasUnsavedFilterChangesForColumn
20
20
  };
@@ -1,73 +1,73 @@
1
1
  import { jsxs as l, jsx as t } from "react/jsx-runtime";
2
- import * as C from "react";
2
+ import * as y from "react";
3
3
  import * as m from "@radix-ui/react-popover";
4
4
  import { Button as u } from "../button/button.js";
5
- import { useTableFilterContext as I } from "./table-filter.context.js";
6
- import U from "./filters/text.js";
7
- import H from "./filters/boolean.js";
8
- import V from "./filters/number/number.js";
9
- import q from "./filters/checkbox.js";
10
- import E from "../assets/icons/circle-check-filled.js";
11
- import { SelectedFiltersDisplay as G } from "./selected-filters-display/selected-filters-display.js";
12
- import { createFilterDisplayItems as J, calculateTotalCount as L } from "./selected-filters-display/selected-filters-display.utils.js";
13
- import { FilterConfirmationDialog as M } from "./close-filter-confirm/filter-confirmation-dialog.js";
14
- import { hasUnsavedFilterChanges as F } from "./close-filter-confirm/filter-confirmation-dialog.utils.js";
15
- const ne = () => {
16
- const [N, a] = C.useState(!1), [x, n] = C.useState(!1), {
5
+ import { useTableFilterContext as U } from "./table-filter.context.js";
6
+ import H from "./filters/text.js";
7
+ import V from "./filters/boolean.js";
8
+ import q from "./filters/number/number.js";
9
+ import E from "./filters/checkbox.js";
10
+ import G from "../assets/icons/circle-check-filled.js";
11
+ import { SelectedFiltersDisplay as J } from "./selected-filters-display/selected-filters-display.js";
12
+ import { createFilterDisplayItems as L, calculateTotalCount as M } from "./selected-filters-display/selected-filters-display.utils.js";
13
+ import { FilterConfirmationDialog as Q } from "./close-filter-confirm/filter-confirmation-dialog.js";
14
+ import { hasUnsavedFilterChanges as C } from "./close-filter-confirm/filter-confirmation-dialog.utils.js";
15
+ const ae = () => {
16
+ const [F, a] = y.useState(!1), [x, n] = y.useState(!1), {
17
17
  selectedColumn: r,
18
- setSelectedColumn: k,
18
+ setSelectedColumn: N,
19
19
  getFilterForColumn: w,
20
- hasFilterForColumn: K,
21
- updateColumnFilter: j,
22
- clearAllFilters: A,
23
- resetToAppliedFilters: D,
24
- applyFilters: O,
20
+ hasFilterForColumn: k,
21
+ updateColumnFilter: K,
22
+ clearAllFilters: j,
23
+ resetToAppliedFilters: A,
24
+ applyFilters: D,
25
25
  hasActiveFilters: d,
26
26
  tempFilters: i,
27
27
  filterSchema: c,
28
- filter: h,
29
- filterComponents: p = {}
30
- } = I(), P = (e) => {
31
- !e && x ? F(i, h.value) ? a(!0) : n(!1) : n(e);
32
- }, g = () => {
33
- O(), n(!1);
34
- }, S = () => {
28
+ filter: p,
29
+ filterComponents: f = {}
30
+ } = U(), g = C(i, p.value), O = (e) => {
31
+ !e && x ? g ? a(!0) : n(!1) : n(e);
32
+ }, v = () => {
33
+ D(), n(!1);
34
+ }, P = () => {
35
35
  a(!1), n(!1);
36
+ }, S = () => {
37
+ A(), a(!1), n(!1);
36
38
  }, T = () => {
37
- D(), a(!1), n(!1);
38
- }, $ = () => {
39
39
  a(!1);
40
- }, R = J(i, c), v = L(R), z = () => {
40
+ }, $ = L(i, c), R = M($), z = () => {
41
41
  if (!r) return null;
42
- const e = c.find((s) => s.filterKey === r), b = {
43
- boolean: H,
44
- string: U,
45
- number: V,
46
- checkbox: q
47
- }, y = (e == null ? void 0 : e.type) && (p == null ? void 0 : p[e.type]) || b[(e == null ? void 0 : e.type) ?? "string"];
48
- if (!y)
42
+ const e = c.find((s) => s.filterKey === r), B = {
43
+ boolean: V,
44
+ string: H,
45
+ number: q,
46
+ checkbox: E
47
+ }, b = (e == null ? void 0 : e.type) && (f == null ? void 0 : f[e.type]) || B[(e == null ? void 0 : e.type) ?? "string"];
48
+ if (!b)
49
49
  return console.warn(
50
50
  `No filter component found for column "${e == null ? void 0 : e.filterKey}" with type "${e == null ? void 0 : e.type}". Provide a custom filter component or use supported types: "string", "number", "boolean", "checkbox".`
51
51
  ), null;
52
- const o = w(r), B = {
52
+ const o = w(r), I = {
53
53
  condition: (o == null ? void 0 : o.condition) || "",
54
54
  value: (o == null ? void 0 : o.value) || ""
55
55
  };
56
56
  return /* @__PURE__ */ t("div", { className: "flex-1 h-full", children: /* @__PURE__ */ t("div", { className: "mb-4 h-full", children: /* @__PURE__ */ t(
57
- y,
57
+ b,
58
58
  {
59
- value: B,
60
- onChange: ({ condition: s, value: f }) => j(r, s, f),
61
- filterOptions: e != null && e.options ? Object.entries(e.options).map(([s, f]) => ({
59
+ value: I,
60
+ onChange: ({ condition: s, value: h }) => K(r, s, h),
61
+ filterOptions: e != null && e.options ? Object.entries(e.options).map(([s, h]) => ({
62
62
  label: s,
63
63
  value: s,
64
- total: f
64
+ total: h
65
65
  })) : void 0
66
66
  },
67
67
  r
68
68
  ) }) });
69
69
  };
70
- return /* @__PURE__ */ l(m.Root, { open: x, onOpenChange: P, children: [
70
+ return /* @__PURE__ */ l(m.Root, { open: x, onOpenChange: O, children: [
71
71
  /* @__PURE__ */ t(m.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
72
72
  u,
73
73
  {
@@ -76,7 +76,7 @@ const ne = () => {
76
76
  size: "small",
77
77
  children: [
78
78
  "Filter ",
79
- d && `(${h.value.length})`
79
+ d && `(${p.value.length})`
80
80
  ]
81
81
  }
82
82
  ) }),
@@ -93,11 +93,11 @@ const ne = () => {
93
93
  c.map((e) => /* @__PURE__ */ l(
94
94
  "button",
95
95
  {
96
- onClick: () => k(e.filterKey),
96
+ onClick: () => N(e.filterKey),
97
97
  className: `w-full text-left p-2 text-sm flex items-center justify-between hover:bg-surface-neutral-hovered transition-colors rounded-lg ${r === e.filterKey ? "bg-surface-neutral-focused text-text-brand-primary" : "text-text-neutral-primary"}`,
98
98
  children: [
99
99
  /* @__PURE__ */ t("span", { className: "truncate", children: e.title }),
100
- K(e.filterKey) && /* @__PURE__ */ t(E, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
100
+ k(e.filterKey) && /* @__PURE__ */ t(G, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
101
101
  ]
102
102
  },
103
103
  e.filterKey
@@ -105,18 +105,19 @@ const ne = () => {
105
105
  ] }),
106
106
  /* @__PURE__ */ t("div", { className: "flex-1 flex flex-col", children: r ? z() : /* @__PURE__ */ t("div", { className: "flex-1 flex items-center justify-center text-text-neutral-muted", children: "Select a column to configure its filter" }) })
107
107
  ] }),
108
- !!v && /* @__PURE__ */ l("div", { className: "flex justify-between items-end p-4 border-t border-stroke-solid-medium min-h-[71px]", children: [
109
- /* @__PURE__ */ t(G, { selectedFilters: i, schema: c }),
108
+ g && /* @__PURE__ */ l("div", { className: "flex justify-between items-end p-4 border-t border-stroke-solid-medium min-h-[73px]", children: [
109
+ /* @__PURE__ */ t(J, { selectedFilters: i, schema: c }),
110
110
  /* @__PURE__ */ l("div", { className: "flex justify-end gap-2", children: [
111
- /* @__PURE__ */ t(u, { onClick: A, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
111
+ /* @__PURE__ */ t(u, { onClick: j, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
112
112
  /* @__PURE__ */ t(
113
113
  u,
114
114
  {
115
- onClick: g,
115
+ onClick: v,
116
116
  variant: "filled",
117
117
  shade: "neutral",
118
118
  size: "small",
119
- children: `Apply ${v || ""}`
119
+ className: "min-w-20",
120
+ children: `Apply ${R || ""}`
120
121
  }
121
122
  )
122
123
  ] })
@@ -124,18 +125,18 @@ const ne = () => {
124
125
  ]
125
126
  }
126
127
  ) }),
127
- N && /* @__PURE__ */ t(
128
- M,
128
+ F && /* @__PURE__ */ t(
129
+ Q,
129
130
  {
130
- onClose: $,
131
- onKeepChanges: S,
132
- onRevertChanges: T,
133
- onApplyChanges: g,
134
- hasUnsavedChanges: F(i, h.value)
131
+ onClose: T,
132
+ onKeepChanges: P,
133
+ onRevertChanges: S,
134
+ onApplyChanges: v,
135
+ hasUnsavedChanges: C(i, p.value)
135
136
  }
136
137
  )
137
138
  ] });
138
139
  };
139
140
  export {
140
- ne as TableFilterButton
141
+ ae as TableFilterButton
141
142
  };
@@ -1,77 +1,78 @@
1
- import { jsxs as a, jsx as l } from "react/jsx-runtime";
2
- import * as y from "react";
3
- import * as p from "@radix-ui/react-popover";
1
+ import { jsxs as i, jsx as l } from "react/jsx-runtime";
2
+ import * as x from "react";
3
+ import * as a from "@radix-ui/react-popover";
4
4
  import { Button as f } from "../button/button.js";
5
- import { useTableFilterContext as U } from "./table-filter.context.js";
6
- import I from "./filters/text.js";
7
- import V from "./filters/boolean.js";
8
- import q from "./filters/number/number.js";
9
- import E from "./filters/checkbox.js";
10
- import G from "../assets/icons/circle-check-filled.js";
11
- import { getFilterCount as H } from "./selected-filters-display/selected-filters-display.utils.js";
12
- import { FilterConfirmationDialog as J } from "./close-filter-confirm/filter-confirmation-dialog.js";
13
- import { hasUnsavedFilterChangesForColumn as x } from "./close-filter-confirm/filter-confirmation-dialog.utils.js";
14
- const te = ({ filterName: t }) => {
15
- const [k, r] = y.useState(!1), [u, s] = y.useState(!1), {
16
- getFilterForColumn: w,
17
- hasAppliedFilterForColumn: A,
5
+ import { useTableFilterContext as V } from "./table-filter.context.js";
6
+ import q from "./filters/text.js";
7
+ import E from "./filters/boolean.js";
8
+ import G from "./filters/number/number.js";
9
+ import H from "./filters/checkbox.js";
10
+ import J from "../assets/icons/circle-check-filled.js";
11
+ import { getFilterCount as L } from "./selected-filters-display/selected-filters-display.utils.js";
12
+ import { FilterConfirmationDialog as M } from "./close-filter-confirm/filter-confirmation-dialog.js";
13
+ import { hasUnsavedFilterChangesForColumn as w } from "./close-filter-confirm/filter-confirmation-dialog.utils.js";
14
+ const le = ({ filterName: n }) => {
15
+ const [k, r] = x.useState(!1), [u, s] = x.useState(!1), {
16
+ getFilterForColumn: A,
17
+ hasAppliedFilterForColumn: O,
18
18
  updateColumnFilter: C,
19
- applyFilters: d,
20
- resetToAppliedFilters: O,
21
- filterSchema: P,
22
- filterComponents: c = {},
19
+ applyFilters: p,
20
+ resetToAppliedFilters: P,
21
+ filterSchema: T,
22
+ filterComponents: d = {},
23
23
  tempFilters: g,
24
24
  filter: v
25
- } = U(), T = (o) => {
26
- !o && u ? x(t, g, v.value) ? r(!0) : s(!1) : s(o);
27
- }, $ = () => {
28
- d(), s(!1);
25
+ } = V(), c = w(n, g, v.value), $ = (o) => {
26
+ !o && u ? c ? r(!0) : s(!1) : s(o);
29
27
  }, j = () => {
30
- r(!1), s(!1);
28
+ p(), s(!1);
31
29
  }, D = () => {
32
- O(), r(!1), s(!1);
30
+ r(!1), s(!1);
33
31
  }, K = () => {
32
+ P(), r(!1), s(!1);
33
+ }, R = () => {
34
34
  r(!1);
35
- }, e = P.find((o) => o.filterKey === t);
36
- if (!e)
37
- return console.warn(`Column "${t}" not found in schema`), null;
38
- const R = {
39
- boolean: V,
40
- string: I,
41
- number: q,
42
- checkbox: E
43
- }, F = e.type && (c == null ? void 0 : c[e.type]) || R[e.type ?? "string"];
35
+ }, t = T.find((o) => o.filterKey === n);
36
+ if (!t)
37
+ return console.warn(`Column "${n}" not found in schema`), null;
38
+ const S = {
39
+ boolean: E,
40
+ string: q,
41
+ number: G,
42
+ checkbox: H
43
+ }, F = t.type && (d == null ? void 0 : d[t.type]) || S[t.type ?? "string"];
44
44
  if (!F)
45
45
  return console.warn(
46
- `No filter component found for column "${e.filterKey}" with type "${e.type}". Provide a custom filter component or use supported types: "string", "number", "boolean", "checkbox".`
46
+ `No filter component found for column "${t.filterKey}" with type "${t.type}". Provide a custom filter component or use supported types: "string", "number", "boolean", "checkbox".`
47
47
  ), null;
48
- const n = w(t), m = A(t), b = e.options ? Object.entries(e.options).map(([o, i]) => ({
48
+ const e = A(n), m = O(n), b = t.options ? Object.entries(t.options).map(([o, h]) => ({
49
49
  label: o,
50
50
  value: o,
51
- total: i
52
- })) : void 0, h = n ? H(n, b) : void 0, S = {
53
- condition: (n == null ? void 0 : n.condition) || "",
54
- value: (n == null ? void 0 : n.value) || ""
55
- }, z = () => {
56
- C(t, "", ""), d(), s(!1);
57
- }, B = () => {
58
- d(), s(!1);
51
+ total: h
52
+ })) : void 0, y = e ? L(e, b) : void 0, z = e != null && e.value ? Array.isArray(e.value) ? e.value.length : 1 : 0, B = {
53
+ condition: (e == null ? void 0 : e.condition) || "",
54
+ value: (e == null ? void 0 : e.value) || ""
55
+ }, I = () => {
56
+ const o = C(n, "", "");
57
+ p(o), s(!1);
58
+ }, U = () => {
59
+ p(), s(!1);
59
60
  };
60
- return /* @__PURE__ */ a(p.Root, { open: u, onOpenChange: T, children: [
61
- /* @__PURE__ */ l(p.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
61
+ return /* @__PURE__ */ i(a.Root, { open: u, onOpenChange: $, children: [
62
+ /* @__PURE__ */ l(a.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
62
63
  f,
63
64
  {
64
65
  variant: m ? "filled" : "stroke",
65
66
  shade: m ? "brand" : "neutral",
66
67
  size: "small",
67
- children: /* @__PURE__ */ a("span", { className: "flex items-center gap-2", children: [
68
- e.title,
69
- m && /* @__PURE__ */ l(G, { className: "w-4 h-4 text-white flex-shrink-0" })
68
+ children: /* @__PURE__ */ i("span", { className: "flex items-center gap-2", children: [
69
+ t.title,
70
+ m && /* @__PURE__ */ l(J, { className: "w-4 h-4 text-white flex-shrink-0" })
70
71
  ] })
71
72
  }
72
73
  ) }),
73
- /* @__PURE__ */ l(p.Portal, { children: /* @__PURE__ */ a(
74
- p.Content,
74
+ /* @__PURE__ */ l(a.Portal, { children: /* @__PURE__ */ i(
75
+ a.Content,
75
76
  {
76
77
  className: "w-80 bg-surface-neutral-default border border-stroke-solid-light rounded-2xl overflow-hidden shadow-lg",
77
78
  sideOffset: 8,
@@ -80,27 +81,27 @@ const te = ({ filterName: t }) => {
80
81
  /* @__PURE__ */ l(
81
82
  F,
82
83
  {
83
- value: S,
84
- onChange: ({ condition: o, value: i }) => C(t, o, i),
84
+ value: B,
85
+ onChange: ({ condition: o, value: h }) => C(n, o, h),
85
86
  filterOptions: b
86
87
  }
87
88
  ),
88
- !!h && /* @__PURE__ */ a("div", { className: "flex justify-between gap-2 p-3 border-t border-stroke-solid-medium", children: [
89
- /* @__PURE__ */ l(f, { onClick: z, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
90
- /* @__PURE__ */ l(f, { onClick: B, variant: "filled", shade: "neutral", size: "small", children: `Apply${h !== void 0 ? ` ${h}` : ""}` })
89
+ (c || !!z) && /* @__PURE__ */ i("div", { className: "flex justify-between gap-2 p-3 border-t border-stroke-solid-medium", children: [
90
+ /* @__PURE__ */ l(f, { onClick: I, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
91
+ c && /* @__PURE__ */ l(f, { onClick: U, variant: "filled", shade: "neutral", size: "small", children: `Apply${y !== void 0 ? ` ${y}` : ""}` })
91
92
  ] })
92
93
  ]
93
94
  }
94
95
  ) }),
95
96
  k && /* @__PURE__ */ l(
96
- J,
97
+ M,
97
98
  {
98
- onClose: K,
99
- onKeepChanges: j,
100
- onRevertChanges: D,
101
- onApplyChanges: $,
102
- hasUnsavedChanges: x(
103
- t,
99
+ onClose: R,
100
+ onKeepChanges: D,
101
+ onRevertChanges: K,
102
+ onApplyChanges: j,
103
+ hasUnsavedChanges: w(
104
+ n,
104
105
  g,
105
106
  v.value
106
107
  )
@@ -109,5 +110,5 @@ const te = ({ filterName: t }) => {
109
110
  ] });
110
111
  };
111
112
  export {
112
- te as TableFilterColumnButton
113
+ le as TableFilterColumnButton
113
114
  };
@@ -6,10 +6,10 @@ export interface TableFilterContextValue {
6
6
  getFilterForColumn: (columnKey: string) => FilterRule | undefined;
7
7
  hasFilterForColumn: (columnKey: string) => boolean;
8
8
  hasAppliedFilterForColumn: (columnKey: string) => boolean;
9
- updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) => void;
9
+ updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) => FilterRule[];
10
10
  clearAllFilters: () => void;
11
11
  resetToAppliedFilters: () => void;
12
- applyFilters: () => void;
12
+ applyFilters: (newFilters?: FilterRule[]) => void;
13
13
  hasActiveFilters: boolean;
14
14
  tempFilters: FilterRule[];
15
15
  filterSchema: FilterSchema;
@@ -6,10 +6,10 @@ declare const useTableFilter: ({ filter, filterSchema }: TableFilterProps) => {
6
6
  getFilterForColumn: (columnKey: string) => FilterRule | undefined;
7
7
  hasFilterForColumn: (columnKey: string) => boolean;
8
8
  hasAppliedFilterForColumn: (columnKey: string) => boolean;
9
- updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) => void;
9
+ updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) => FilterRule[];
10
10
  clearAllFilters: () => void;
11
11
  resetToAppliedFilters: () => void;
12
- applyFilters: () => void;
12
+ applyFilters: (newFilters?: FilterRule[]) => void;
13
13
  hasActiveFilters: boolean;
14
14
  tempFilters: FilterRule[];
15
15
  };
@@ -1,56 +1,57 @@
1
- import u from "react";
2
- const E = ({ filter: l, filterSchema: a }) => {
3
- const [i, c] = u.useState(null), [r, s] = u.useState(l.value);
4
- u.useEffect(() => {
5
- !i && a.length > 0 && c(a[0].filterKey);
6
- }, [i, a]);
7
- const d = (t) => r.find((e) => e.field === t), F = (t) => {
8
- const e = d(t);
1
+ import i from "react";
2
+ const E = ({ filter: l, filterSchema: o }) => {
3
+ const [d, c] = i.useState(null), [n, s] = i.useState(l.value);
4
+ i.useEffect(() => {
5
+ !d && o.length > 0 && c(o[0].filterKey);
6
+ }, [d, o]);
7
+ const f = (t) => n.find((e) => e.field === t), p = (t) => {
8
+ const e = f(t);
9
9
  return e ? Array.isArray(e.value) ? e.value.length > 0 : e.value !== "" : !1;
10
- }, p = (t) => l.value.find((e) => e.field === t), A = (t) => {
11
- const e = p(t);
10
+ }, A = (t) => l.value.find((e) => e.field === t), m = (t) => {
11
+ const e = A(t);
12
12
  return e ? Array.isArray(e.value) ? e.value.length > 0 : e.value !== "" : !1;
13
- }, g = (t, e, o) => {
14
- const f = r.findIndex((n) => n.field === t);
15
- if (f >= 0) {
16
- const n = r.map(
17
- (v, x) => x === f ? {
13
+ }, g = (t, e, r) => {
14
+ const F = n.findIndex((a) => a.field === t);
15
+ let u = [];
16
+ if (F >= 0)
17
+ u = n.map(
18
+ (v, T) => T === F ? {
18
19
  ...v,
19
20
  ...e !== void 0 ? { condition: e } : {},
20
- ...o !== void 0 ? { value: o } : {}
21
+ ...r !== void 0 ? { value: r } : {}
21
22
  } : v
22
23
  );
23
- s(n);
24
- } else {
25
- const n = {
24
+ else {
25
+ const a = {
26
26
  field: t,
27
27
  ...e ? { condition: e } : {},
28
- value: o || ""
28
+ value: r || ""
29
29
  };
30
- s([...r, n]);
30
+ u = [...n, a];
31
31
  }
32
- }, m = () => {
33
- s([]);
32
+ return s(u), u;
34
33
  }, C = () => {
35
- s(l.value);
34
+ s([]);
36
35
  }, h = () => {
37
- const t = r.filter((e) => Array.isArray(e.value) ? e.value.length > 0 : e.value !== "");
38
- l.onChange(t);
39
- }, y = l.value.length > 0;
40
- return u.useEffect(() => {
36
+ s(l.value);
37
+ }, y = (t) => {
38
+ const e = (t || n).filter((r) => Array.isArray(r.value) ? r.value.length > 0 : r.value !== "");
39
+ l.onChange(e);
40
+ }, x = l.value.length > 0;
41
+ return i.useEffect(() => {
41
42
  s(l.value);
42
43
  }, [l.value]), {
43
- selectedColumn: i,
44
+ selectedColumn: d,
44
45
  setSelectedColumn: c,
45
- getFilterForColumn: d,
46
- hasFilterForColumn: F,
47
- hasAppliedFilterForColumn: A,
46
+ getFilterForColumn: f,
47
+ hasFilterForColumn: p,
48
+ hasAppliedFilterForColumn: m,
48
49
  updateColumnFilter: g,
49
- clearAllFilters: m,
50
- resetToAppliedFilters: C,
51
- applyFilters: h,
52
- hasActiveFilters: y,
53
- tempFilters: r
50
+ clearAllFilters: C,
51
+ resetToAppliedFilters: h,
52
+ applyFilters: y,
53
+ hasActiveFilters: x,
54
+ tempFilters: n
54
55
  };
55
56
  };
56
57
  export {