@ztwoint/z-ui 0.1.70 → 0.1.72

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.
@@ -4,7 +4,6 @@ interface FilterConfirmationDialogProps {
4
4
  onKeepChanges: () => void;
5
5
  onRevertChanges: () => void;
6
6
  onApplyChanges: () => void;
7
- hasUnsavedChanges: boolean;
8
7
  }
9
8
  export declare const FilterConfirmationDialog: React.FC<FilterConfirmationDialogProps>;
10
9
  export {};
@@ -1,33 +1,32 @@
1
1
  import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
- import { Button as l } from "../../button/button.js";
3
- import { Z2Dialog as s, Z2DialogContent as d, Z2DialogHeader as h, Z2DialogTitle as c, Z2DialogDescription as g, Z2DialogFooter as m } from "../../dialog/dialog.js";
4
- const v = ({
5
- onClose: r,
6
- onKeepChanges: i,
7
- onRevertChanges: o,
8
- onApplyChanges: a,
9
- hasUnsavedChanges: t
10
- }) => t ? /* @__PURE__ */ e(s, { open: !0, onOpenChange: r, children: /* @__PURE__ */ n(d, { className: "max-w-md p-4 rounded-2xl", children: [
11
- /* @__PURE__ */ n(h, { children: [
2
+ import { Button as i } from "../../button/button.js";
3
+ import { Z2Dialog as t, Z2DialogContent as s, Z2DialogHeader as d, Z2DialogTitle as h, Z2DialogDescription as c, Z2DialogFooter as g } from "../../dialog/dialog.js";
4
+ const f = ({
5
+ onClose: l,
6
+ onKeepChanges: o,
7
+ onRevertChanges: r,
8
+ onApplyChanges: a
9
+ }) => /* @__PURE__ */ e(t, { open: !0, onOpenChange: l, children: /* @__PURE__ */ n(s, { className: "max-w-md p-4 rounded-2xl", children: [
10
+ /* @__PURE__ */ n(d, { children: [
12
11
  /* @__PURE__ */ n("div", { className: "flex justify-between", children: [
13
- /* @__PURE__ */ e(c, { children: "Unsaved Filter Changes" }),
12
+ /* @__PURE__ */ e(h, { children: "Unsaved Filter Changes" }),
14
13
  /* @__PURE__ */ e(
15
- l,
14
+ i,
16
15
  {
17
16
  "aria-label": "Close",
18
17
  className: "ml-4 p-2 text-xl leading-none font-bold bg-transparent border-none shadow-none hover:bg-gray-100 min-w-0 min-h-0",
19
- onClick: i,
18
+ onClick: o,
20
19
  children: "×"
21
20
  }
22
21
  )
23
22
  ] }),
24
- /* @__PURE__ */ e(g, { children: "You have unsaved filter changes. Would you like to keep these changes or revert to the previous state?" })
23
+ /* @__PURE__ */ e(c, { children: "You have unsaved filter changes. Would you like to keep these changes or revert to the previous state?" })
25
24
  ] }),
26
- /* @__PURE__ */ n(m, { children: [
27
- /* @__PURE__ */ e(l, { onClick: o, variant: "stroke", shade: "danger", size: "small", children: "Discard" }),
28
- /* @__PURE__ */ e(l, { onClick: a, variant: "filled", shade: "brand", size: "small", children: "Apply Changes" })
25
+ /* @__PURE__ */ n(g, { children: [
26
+ /* @__PURE__ */ e(i, { onClick: r, variant: "stroke", shade: "danger", size: "small", children: "Discard" }),
27
+ /* @__PURE__ */ e(i, { onClick: a, variant: "filled", shade: "brand", size: "small", children: "Apply Changes" })
29
28
  ] })
30
- ] }) }) : null;
29
+ ] }) });
31
30
  export {
32
- v as FilterConfirmationDialog
31
+ f as FilterConfirmationDialog
33
32
  };
@@ -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";
5
+ import { useTableFilterContext as H } from "./table-filter.context.js";
6
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";
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
15
  const ne = () => {
16
- const [N, a] = C.useState(!1), [x, n] = C.useState(!1), {
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
28
  filter: h,
29
29
  filterComponents: p = {}
30
- } = I(), P = (e) => {
31
- !e && x ? F(i, h.value) ? a(!0) : n(!1) : n(e);
30
+ } = H(), O = (e) => {
31
+ !e && x ? C(i, h.value) ? a(!0) : n(!1) : n(e);
32
32
  }, g = () => {
33
- O(), n(!1);
34
- }, S = () => {
33
+ D(), a(!1), 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
+ }, $ = C(i, h.value), R = L(i, c), z = M(R), B = () => {
41
41
  if (!r) return null;
42
- const e = c.find((s) => s.filterKey === r), b = {
43
- boolean: H,
42
+ const e = c.find((o) => o.filterKey === r), v = {
43
+ boolean: V,
44
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)
45
+ number: q,
46
+ checkbox: E
47
+ }, b = (e == null ? void 0 : e.type) && (p == null ? void 0 : p[e.type]) || v[(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 = {
53
- condition: (o == null ? void 0 : o.condition) || "",
54
- value: (o == null ? void 0 : o.value) || ""
52
+ const s = w(r), I = {
53
+ condition: (s == null ? void 0 : s.condition) || "",
54
+ value: (s == null ? void 0 : s.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]) => ({
62
- label: s,
63
- value: s,
59
+ value: I,
60
+ onChange: ({ condition: o, value: f }) => K(r, o, f),
61
+ filterOptions: e != null && e.options ? Object.entries(e.options).map(([o, f]) => ({
62
+ label: o,
63
+ value: o,
64
64
  total: f
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
  {
@@ -93,22 +93,22 @@ 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
104
104
  ))
105
105
  ] }),
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" }) })
106
+ /* @__PURE__ */ t("div", { className: "flex-1 flex flex-col", children: r ? B() : /* @__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
+ $ && /* @__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
  {
@@ -116,7 +116,8 @@ const ne = () => {
116
116
  variant: "filled",
117
117
  shade: "neutral",
118
118
  size: "small",
119
- children: `Apply ${v || ""}`
119
+ className: "min-w-20",
120
+ children: `Apply ${z || ""}`
120
121
  }
121
122
  )
122
123
  ] })
@@ -124,14 +125,13 @@ 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: g
135
135
  }
136
136
  )
137
137
  ] });
@@ -1,72 +1,73 @@
1
1
  import { jsxs as a, jsx as l } from "react/jsx-runtime";
2
- import * as y from "react";
2
+ import * as x from "react";
3
3
  import * as p from "@radix-ui/react-popover";
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,
18
- updateColumnFilter: C,
19
- applyFilters: d,
20
- resetToAppliedFilters: O,
21
- filterSchema: P,
22
- filterComponents: c = {},
23
- tempFilters: g,
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);
4
+ import { Button as h } from "../button/button.js";
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), [f, s] = x.useState(!1), {
16
+ getFilterForColumn: A,
17
+ hasAppliedFilterForColumn: O,
18
+ updateColumnFilter: u,
19
+ applyFilters: c,
20
+ resetToAppliedFilters: P,
21
+ filterSchema: T,
22
+ filterComponents: d = {},
23
+ tempFilters: C,
24
+ filter: g
25
+ } = V(), $ = (o) => {
26
+ !o && f ? w(n, C, g.value) ? r(!0) : s(!1) : s(o);
29
27
  }, j = () => {
30
- r(!1), s(!1);
28
+ c(), r(!1), 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
+ }, v = w(n, C, g.value), 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, i]) => ({
49
49
  label: o,
50
50
  value: o,
51
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);
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 = u(n, "", "");
57
+ c(o), s(!1);
58
+ }, U = () => {
59
+ c(), s(!1);
59
60
  };
60
- return /* @__PURE__ */ a(p.Root, { open: u, onOpenChange: T, children: [
61
+ return /* @__PURE__ */ a(p.Root, { open: f, onOpenChange: $, children: [
61
62
  /* @__PURE__ */ l(p.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
62
- f,
63
+ h,
63
64
  {
64
65
  variant: m ? "filled" : "stroke",
65
66
  shade: m ? "brand" : "neutral",
66
67
  size: "small",
67
68
  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" })
69
+ t.title,
70
+ m && /* @__PURE__ */ l(J, { className: "w-4 h-4 text-white flex-shrink-0" })
70
71
  ] })
71
72
  }
72
73
  ) }),
@@ -80,34 +81,29 @@ 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: i }) => u(n, o, i),
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
+ (v || !!z) && /* @__PURE__ */ a("div", { className: "flex justify-between gap-2 p-3 border-t border-stroke-solid-medium", children: [
90
+ /* @__PURE__ */ l(h, { onClick: I, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
91
+ v && /* @__PURE__ */ l(h, { 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,
104
- g,
105
- v.value
106
- )
99
+ onClose: R,
100
+ onKeepChanges: D,
101
+ onRevertChanges: K,
102
+ onApplyChanges: j
107
103
  }
108
104
  )
109
105
  ] });
110
106
  };
111
107
  export {
112
- te as TableFilterColumnButton
108
+ le as TableFilterColumnButton
113
109
  };
@@ -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 {