@ztwoint/z-ui 0.1.84 → 0.1.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/components/assets/icons/index.d.ts +1 -0
  2. package/dist/components/assets/icons/vector_3.d.ts +6 -0
  3. package/dist/components/assets/icons/vector_3.js +34 -0
  4. package/dist/components/radio/z2-radio.js +72 -0
  5. package/dist/components/table/components/cell/avatar-cell.js +3 -2
  6. package/dist/components/table/table-provider.js +1 -0
  7. package/dist/components/table-card/table-card.js +38 -36
  8. package/dist/components/table-card/table-card.type.d.ts +2 -1
  9. package/dist/components/table-filter/filters/boolean.js +28 -32
  10. package/dist/components/table-filter/filters/checkbox.js +24 -26
  11. package/dist/components/table-filter/filters/number/number.hook.d.ts +2 -12
  12. package/dist/components/table-filter/filters/number/number.hook.js +18 -18
  13. package/dist/components/table-filter/filters/text.js +25 -28
  14. package/dist/components/table-filter/table-filter-column-button.js +36 -39
  15. package/dist/components/table-filter/table-filter-provider.js +10 -10
  16. package/dist/components/table-filter/table-filter.hook.js +46 -42
  17. package/dist/components/table-filter/table-filter.type.d.ts +3 -2
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +105 -99
  20. package/dist/types/components/assets/icons/index.d.ts +1 -0
  21. package/dist/types/components/assets/icons/vector_3.d.ts +6 -0
  22. package/dist/types/components/table-card/table-card.type.d.ts +2 -1
  23. package/dist/types/components/table-filter/filters/number/number.hook.d.ts +2 -12
  24. package/dist/types/components/table-filter/table-filter.type.d.ts +3 -2
  25. package/dist/types/index.d.ts +1 -0
  26. package/package.json +1 -1
@@ -1,47 +1,44 @@
1
- import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
- import { useEffect as c } from "react";
3
- import s from "../../assets/icons/x.js";
4
- import { MagnifierIcon as u } from "../../assets/icons/magnifier-icon.js";
5
- import { Input as d } from "../../input/input.js";
6
- const o = [
1
+ import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
+ import i from "../../assets/icons/x.js";
3
+ import { MagnifierIcon as o } from "../../assets/icons/magnifier-icon.js";
4
+ import { Input as c } from "../../input/input.js";
5
+ const d = [
7
6
  { label: "Contains", value: "contains" },
8
7
  { label: "Does not equal", value: "notEqual" },
9
8
  { label: "Equals", value: "equals" }
10
- ], h = ({ value: t, onChange: a }) => {
11
- var i;
12
- const n = () => {
13
- a({ value: "" });
9
+ ], x = ({ value: e, onChange: n }) => {
10
+ var a;
11
+ const s = () => {
12
+ n({ value: "" });
14
13
  };
15
- return c(() => {
16
- t.condition || a({ condition: o[0].value });
17
- }, []), /* @__PURE__ */ l("div", { className: "flex flex-col gap-3", children: [
18
- /* @__PURE__ */ e("div", { className: "p-4 relative", children: /* @__PURE__ */ e(
19
- d,
14
+ return /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
15
+ /* @__PURE__ */ t("div", { className: "p-4 relative", children: /* @__PURE__ */ t(
16
+ c,
20
17
  {
21
- leftIcon: /* @__PURE__ */ e(u, {}),
18
+ leftIcon: /* @__PURE__ */ t(o, {}),
22
19
  size: "large",
23
20
  placeholder: "Search options",
24
- value: t.value,
25
- rightIcon: t.value ? /* @__PURE__ */ e(s, { onClick: n }) : null,
26
- onChange: (r) => a({ value: r.target.value }),
21
+ value: e == null ? void 0 : e.value,
22
+ rightIcon: e != null && e.value ? /* @__PURE__ */ t(i, { onClick: s }) : null,
23
+ onChange: (l) => n({ value: l.target.value }),
27
24
  className: ""
28
25
  }
29
26
  ) }),
30
- /* @__PURE__ */ e("div", { className: "flex flex-col gap-2 p-3", children: t.value && /* @__PURE__ */ l("div", { className: "flex items-center justify-center gap-2 px-3 py-2", children: [
31
- /* @__PURE__ */ e("span", { className: "text-text-neutral-muted text-xs font-medium uppercase tracking-wide", children: (i = o.find((r) => r.value === t.condition)) == null ? void 0 : i.label }),
32
- /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
33
- /* @__PURE__ */ l("span", { className: "text-text-neutral-primary text-sm font-medium px-2 py-1 bg-surface-neutral-default rounded border border-stroke-solid-medium", children: [
27
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-2 p-3", children: !!(e != null && e.value) && /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2 px-3 py-2", children: [
28
+ /* @__PURE__ */ t("span", { className: "text-text-neutral-muted text-xs font-medium uppercase tracking-wide", children: (a = d.find((l) => l.value === (e == null ? void 0 : e.condition))) == null ? void 0 : a.label }),
29
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
30
+ /* @__PURE__ */ r("span", { className: "text-text-neutral-primary text-sm font-medium px-2 py-1 bg-surface-neutral-default rounded border border-stroke-solid-medium", children: [
34
31
  "“",
35
- t.value,
32
+ e.value,
36
33
  "”"
37
34
  ] }),
38
- /* @__PURE__ */ e(
35
+ /* @__PURE__ */ t(
39
36
  "button",
40
37
  {
41
- onClick: n,
38
+ onClick: s,
42
39
  className: "flex items-center justify-center w-5 h-5 rounded-full bg-surface-neutral-hovered hover:bg-surface-neutral-pressed transition-colors",
43
40
  title: "Remove filter",
44
- children: /* @__PURE__ */ e(s, { className: "w-3 h-3 text-text-neutral-muted" })
41
+ children: /* @__PURE__ */ t(i, { className: "w-3 h-3 text-text-neutral-muted" })
45
42
  }
46
43
  )
47
44
  ] })
@@ -49,5 +46,5 @@ const o = [
49
46
  ] });
50
47
  };
51
48
  export {
52
- h as default
49
+ x as default
53
50
  };
@@ -1,8 +1,8 @@
1
1
  import { jsxs as a, jsx as l } from "react/jsx-runtime";
2
2
  import * as x from "react";
3
3
  import * as p from "@radix-ui/react-popover";
4
- import { Button as h } from "../button/button.js";
5
- import { useTableFilterContext as V } from "./table-filter.context.js";
4
+ import { Button as d } from "../button/button.js";
5
+ import { useTableFilterContext as U } from "./table-filter.context.js";
6
6
  import q from "./filters/text.js";
7
7
  import E from "./filters/boolean.js";
8
8
  import G from "./filters/number/number.js";
@@ -11,63 +11,60 @@ import J from "../assets/icons/circle-check-filled.js";
11
11
  import { getFilterCount as L } from "./selected-filters-display/selected-filters-display.utils.js";
12
12
  import { FilterConfirmationDialog as M } from "./close-filter-confirm/filter-confirmation-dialog.js";
13
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), {
14
+ const ne = ({ filterName: t }) => {
15
+ const [k, s] = x.useState(!1), [f, r] = x.useState(!1), {
16
16
  getFilterForColumn: A,
17
17
  hasAppliedFilterForColumn: O,
18
18
  updateColumnFilter: u,
19
19
  applyFilters: c,
20
20
  resetToAppliedFilters: P,
21
21
  filterSchema: T,
22
- filterComponents: d = {},
22
+ filterComponents: m = {},
23
23
  tempFilters: C,
24
24
  filter: g
25
- } = V(), $ = (o) => {
26
- !o && f ? w(n, C, g.value) ? r(!0) : s(!1) : s(o);
25
+ } = U(), $ = (e) => {
26
+ !e && f ? w(t, C, g.value) ? s(!0) : r(!1) : r(e);
27
27
  }, j = () => {
28
- c(), r(!1), s(!1);
28
+ c(), s(!1), r(!1);
29
29
  }, D = () => {
30
- r(!1), s(!1);
30
+ s(!1), r(!1);
31
31
  }, K = () => {
32
- P(), r(!1), s(!1);
32
+ P(), s(!1), r(!1);
33
33
  }, R = () => {
34
- r(!1);
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;
34
+ s(!1);
35
+ }, F = w(t, C, g.value), o = T.find((e) => e.filterKey === t);
36
+ if (!o)
37
+ return console.warn(`Column "${t}" not found in schema`), null;
38
38
  const S = {
39
39
  boolean: E,
40
40
  string: q,
41
41
  number: G,
42
42
  checkbox: H
43
- }, F = t.type && (d == null ? void 0 : d[t.type]) || S[t.type ?? "string"];
44
- if (!F)
43
+ }, v = o.type && (m == null ? void 0 : m[o.type]) || S[o.type ?? "string"];
44
+ if (!v)
45
45
  return console.warn(
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".`
46
+ `No filter component found for column "${o.filterKey}" with type "${o.type}". Provide a custom filter component or use supported types: "string", "number", "boolean", "checkbox".`
47
47
  ), null;
48
- const e = A(n), m = O(n), b = t.options ? Object.entries(t.options).map(([o, i]) => ({
49
- label: o,
50
- value: o,
48
+ const n = A(t), h = O(t), b = o.options ? Object.entries(o.options).map(([e, i]) => ({
49
+ label: e,
50
+ value: e,
51
51
  total: i
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) || ""
52
+ })) : void 0, y = n ? L(n, b) : void 0, z = n != null && n.value ? Array.isArray(n.value) ? n.value.length : 1 : 0, B = () => {
53
+ const e = u(t, "", "");
54
+ c(e), r(!1);
55
55
  }, I = () => {
56
- const o = u(n, "", "");
57
- c(o), s(!1);
58
- }, U = () => {
59
- c(), s(!1);
56
+ c(), r(!1);
60
57
  };
61
58
  return /* @__PURE__ */ a(p.Root, { open: f, onOpenChange: $, children: [
62
59
  /* @__PURE__ */ l(p.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
63
- h,
60
+ d,
64
61
  {
65
- variant: m ? "filled" : "stroke",
66
- shade: m ? "brand" : "neutral",
62
+ variant: h ? "filled" : "stroke",
63
+ shade: h ? "brand" : "neutral",
67
64
  size: "small",
68
65
  children: /* @__PURE__ */ a("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" })
66
+ o.title,
67
+ h && /* @__PURE__ */ l(J, { className: "w-4 h-4 text-white flex-shrink-0" })
71
68
  ] })
72
69
  }
73
70
  ) }),
@@ -79,16 +76,16 @@ const le = ({ filterName: n }) => {
79
76
  align: "start",
80
77
  children: [
81
78
  /* @__PURE__ */ l(
82
- F,
79
+ v,
83
80
  {
84
- value: B,
85
- onChange: ({ condition: o, value: i }) => u(n, o, i),
81
+ value: n,
82
+ onChange: ({ condition: e, value: i }) => u(t, e, i),
86
83
  filterOptions: b
87
84
  }
88
85
  ),
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}` : ""}` })
86
+ (F || !!z) && /* @__PURE__ */ a("div", { className: "flex justify-between gap-2 p-3 border-t border-stroke-solid-medium", children: [
87
+ /* @__PURE__ */ l(d, { onClick: B, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
88
+ F && /* @__PURE__ */ l(d, { onClick: I, variant: "filled", shade: "neutral", size: "small", children: `Apply${y !== void 0 ? ` ${y}` : ""}` })
92
89
  ] })
93
90
  ]
94
91
  }
@@ -105,5 +102,5 @@ const le = ({ filterName: n }) => {
105
102
  ] });
106
103
  };
107
104
  export {
108
- le as TableFilterColumnButton
105
+ ne as TableFilterColumnButton
109
106
  };
@@ -1,27 +1,27 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import i from "./table-filter.hook.js";
3
- import { TableFilterContext as a } from "./table-filter.context.js";
4
- const v = ({
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import a from "./table-filter.hook.js";
3
+ import { TableFilterContext as u } from "./table-filter.context.js";
4
+ const c = ({
5
5
  children: r,
6
6
  filterComponents: t = {},
7
7
  filterSchema: e,
8
8
  filter: o
9
9
  }) => {
10
- const l = i({
10
+ const n = a({
11
11
  filterSchema: e,
12
12
  filter: o || { value: [], onChange: () => {
13
- } }
13
+ }, onDynamicChange: void 0 }
14
14
  });
15
15
  if (!o)
16
16
  return null;
17
- const n = {
18
- ...l,
17
+ const l = {
18
+ ...n,
19
19
  filterSchema: e,
20
20
  filter: o,
21
21
  filterComponents: t
22
22
  };
23
- return /* @__PURE__ */ u(a.Provider, { value: n, children: r });
23
+ return /* @__PURE__ */ i(u.Provider, { value: l, children: r });
24
24
  };
25
25
  export {
26
- v as TableFilterProvider
26
+ c as TableFilterProvider
27
27
  };
@@ -1,59 +1,63 @@
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);
1
+ import o from "react";
2
+ const w = ({ filter: n, filterSchema: c }) => {
3
+ const [v, d] = o.useState(null), [l, i] = o.useState(n.value);
4
+ o.useEffect(() => {
5
+ !v && c.length > 0 && d(c[0].filterKey);
6
+ }, [v, c]);
7
+ const F = (t) => l.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
- }, A = (t) => l.value.find((e) => e.field === t), m = (t) => {
11
- const e = A(t);
10
+ }, g = (t) => n.value.find((e) => e.field === t), m = (t) => {
11
+ const e = g(t);
12
12
  return e ? Array.isArray(e.value) ? e.value.length > 0 : e.value !== "" : !1;
13
- }, g = (t, e, r) => {
14
- const F = n.findIndex((a) => a.field === t);
13
+ }, y = (t, e, a) => {
14
+ const f = l.findIndex((r) => r.field === t);
15
15
  let u = [];
16
- if (F >= 0)
17
- u = n.map(
18
- (v, T) => T === F ? {
19
- ...v,
16
+ if (f >= 0)
17
+ u = l.map(
18
+ (s, x) => x === f ? {
19
+ ...s,
20
20
  ...e !== void 0 ? { condition: e } : {},
21
- ...r !== void 0 ? { value: r } : {}
22
- } : v
21
+ ...a !== void 0 ? { value: a } : {}
22
+ } : s
23
23
  );
24
24
  else {
25
- const a = {
25
+ const r = {
26
26
  field: t,
27
27
  ...e ? { condition: e } : {},
28
- value: r || ""
28
+ value: a || ""
29
29
  };
30
- u = [...n, a];
30
+ u = [...l, r];
31
31
  }
32
- return s(u), u;
33
- }, C = () => {
34
- s([]);
32
+ if (i(u), n.onDynamicChange) {
33
+ const r = u.filter((s) => Array.isArray(s.value) ? s.value.length > 0 : s.value !== "");
34
+ n.onDynamicChange(r);
35
+ }
36
+ return u;
35
37
  }, h = () => {
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(() => {
42
- s(l.value);
43
- }, [l.value]), {
44
- selectedColumn: d,
45
- setSelectedColumn: c,
46
- getFilterForColumn: f,
38
+ i([]), n.onDynamicChange && n.onDynamicChange([]);
39
+ }, C = () => {
40
+ i(n.value), n.onDynamicChange && n.onDynamicChange(n.value);
41
+ }, A = (t) => {
42
+ const e = (t || l).filter((a) => Array.isArray(a.value) ? a.value.length > 0 : a.value !== "");
43
+ n.onChange(e);
44
+ }, D = n.value.length > 0;
45
+ return o.useEffect(() => {
46
+ i(n.value);
47
+ }, [n.value]), {
48
+ selectedColumn: v,
49
+ setSelectedColumn: d,
50
+ getFilterForColumn: F,
47
51
  hasFilterForColumn: p,
48
52
  hasAppliedFilterForColumn: m,
49
- updateColumnFilter: g,
50
- clearAllFilters: C,
51
- resetToAppliedFilters: h,
52
- applyFilters: y,
53
- hasActiveFilters: x,
54
- tempFilters: n
53
+ updateColumnFilter: y,
54
+ clearAllFilters: h,
55
+ resetToAppliedFilters: C,
56
+ applyFilters: A,
57
+ hasActiveFilters: D,
58
+ tempFilters: l
55
59
  };
56
60
  };
57
61
  export {
58
- E as default
62
+ w as default
59
63
  };
@@ -21,6 +21,7 @@ export type FilterSchema = FilterSchemaField[];
21
21
  export type TableFilter = {
22
22
  value: FilterRule[];
23
23
  onChange: (filters: FilterRule[]) => void;
24
+ onDynamicChange?: (filters: FilterRule[]) => void;
24
25
  };
25
26
  export interface TableFilterProps {
26
27
  filterSchema: FilterSchema;
@@ -32,9 +33,9 @@ export type FilterComponentProps = {
32
33
  condition?: string;
33
34
  value?: string | string[];
34
35
  }) => void;
35
- value: {
36
+ value?: {
36
37
  condition?: string;
37
- value: string | string[];
38
+ value?: string | string[];
38
39
  };
39
40
  filterOptions?: FilterOption[];
40
41
  };
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export * from './components/text-preset/text-preset';
22
22
  export * from './components/column-reorder';
23
23
  export * from './components/tree-checkbox-select';
24
24
  export * from './components/breadcrumb/z2-breadcrumb';
25
+ export * from './components/radio/z2-radio';
25
26
  export * from './components/assets/icons';
26
27
  export * from './lib/theme.hook';
27
28
  export * from './lib/utils';