@ztwoint/z-ui 0.1.79 → 0.1.80

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,12 @@
1
+ import { default as React } from 'react';
2
+ export interface ColumnVisibilitySelectProps {
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ className?: string;
6
+ options?: {
7
+ value: string;
8
+ label: string;
9
+ }[];
10
+ }
11
+ export declare const ColumnVisibilitySelect: React.FC<ColumnVisibilitySelectProps>;
12
+ export default ColumnVisibilitySelect;
@@ -0,0 +1,24 @@
1
+ import { ColumnType } from './column-reorder.type';
2
+ export type ColumnVisibilityValue = string;
3
+ export interface UseColumnVisibilityOptions {
4
+ /** Initial map of columnId -> visibility value */
5
+ initial?: Record<string, ColumnVisibilityValue>;
6
+ /** Default value to use when a column has no entry */
7
+ defaultValue?: ColumnVisibilityValue;
8
+ }
9
+ export interface UseColumnVisibilityResult {
10
+ /** Map of columnId -> visibility setting */
11
+ settings: Record<string, ColumnVisibilityValue>;
12
+ /** Read a column's visibility with default fallback */
13
+ get: (columnId: string) => ColumnVisibilityValue;
14
+ /** Update a column's visibility */
15
+ set: (columnId: string, value: ColumnVisibilityValue) => void;
16
+ /** Bulk set/reset settings (replaces entire state) */
17
+ setAll: (next: Record<string, ColumnVisibilityValue>) => void;
18
+ }
19
+ /**
20
+ * Manages per-column visibility settings with sensible defaults.
21
+ * Keeps UI concerns separate from state management.
22
+ */
23
+ export declare function useColumnVisibility(columns: ColumnType[], options?: UseColumnVisibilityOptions): UseColumnVisibilityResult;
24
+ export default useColumnVisibility;
@@ -1,4 +1,5 @@
1
1
  import { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
2
+ import { ReactNode } from 'react';
2
3
  import { ColumnType } from '../../column-reorder.type';
3
4
  export type ColumnItemState = {
4
5
  type: 'idle';
@@ -15,5 +16,5 @@ export interface ColumnItemProps {
15
16
  column: ColumnType;
16
17
  index: number;
17
18
  onRemove?: (columnId: string) => void;
18
- renderAction?: (column: ColumnType, onRemove?: (columnId: string) => void) => React.ReactNode;
19
+ renderAction?: (column: ColumnType, onRemove?: (columnId: string) => void) => ReactNode;
19
20
  }
@@ -1,9 +1,10 @@
1
1
  import { jsx as t, jsxs as s } from "react/jsx-runtime";
2
2
  import { useState as i, useEffect as f } from "react";
3
- import { Virtuoso as y } from "react-virtuoso";
4
- import { MagnifierIcon as k } from "../../assets/icons/magnifier-icon.js";
3
+ import { Virtuoso as k } from "react-virtuoso";
4
+ import { MagnifierIcon as y } from "../../assets/icons/magnifier-icon.js";
5
5
  import S from "../../assets/icons/x.js";
6
- const w = ["includesAny", "includesAll", "excludes"], B = ({ value: r, onChange: d, filterOptions: n = [] }) => {
6
+ import { Z2Checkbox as w } from "../../checkbox/checkbox.js";
7
+ const V = ["includesAny", "includesAll", "excludes"], I = ({ value: r, onChange: d, filterOptions: n = [] }) => {
7
8
  const [c, o] = i([]), [u, m] = i(""), [x, h] = i(n), p = (l) => {
8
9
  m(l.target.value);
9
10
  const e = n.filter(
@@ -12,23 +13,22 @@ const w = ["includesAny", "includesAll", "excludes"], B = ({ value: r, onChange:
12
13
  h(e);
13
14
  };
14
15
  f(() => {
15
- r.condition || d({ condition: w[0] });
16
+ r.condition || d({ condition: V[0] });
16
17
  }, []), f(() => {
17
18
  Array.isArray(r.value) ? o(r.value.filter(Boolean)) : o([]);
18
19
  }, [r.value]);
19
20
  const b = (l, e) => {
20
21
  let a;
21
- e ? a = [...c, l] : a = c.filter((C) => C !== l), o(a), d({ value: a });
22
+ e ? a = [...c, l] : a = c.filter((g) => g !== l), o(a), d({ value: a });
22
23
  }, v = () => {
23
24
  m(""), h(n);
24
- }, g = (l) => c.includes(l), N = (l, e) => /* @__PURE__ */ s("div", { className: "flex justify-between items-center py-2 px-3", children: [
25
+ }, C = (l) => c.includes(l), N = (l, e) => /* @__PURE__ */ s("div", { className: "flex justify-between items-center py-2 px-3", children: [
25
26
  /* @__PURE__ */ s("label", { className: "flex items-center space-x-2 cursor-pointer", children: [
26
27
  /* @__PURE__ */ t(
27
- "input",
28
+ w,
28
29
  {
29
- type: "checkbox",
30
- checked: g(e.value),
31
- onChange: (a) => b(e.value, a.target.checked)
30
+ checked: C(e.value),
31
+ onCheckedChange: (a) => b(e.value, a === !0)
32
32
  }
33
33
  ),
34
34
  /* @__PURE__ */ t("span", { className: "text-text-neutral-primary leading-none-medium-sm", children: e.label })
@@ -41,7 +41,7 @@ const w = ["includesAny", "includesAll", "excludes"], B = ({ value: r, onChange:
41
41
  ] });
42
42
  return n.length === 0 ? /* @__PURE__ */ t("div", { className: "text-text-neutral-muted text-sm p-4", children: "No filter options available for this column" }) : /* @__PURE__ */ s("div", { className: "flex flex-col h-full", children: [
43
43
  /* @__PURE__ */ s("div", { className: "relative border-b border-stroke-solid-medium", children: [
44
- /* @__PURE__ */ t(k, { className: "absolute left-3 top-3.5 text-text-neutral-muted" }),
44
+ /* @__PURE__ */ t(y, { className: "absolute left-3 top-3.5 text-text-neutral-muted" }),
45
45
  /* @__PURE__ */ t(
46
46
  "input",
47
47
  {
@@ -54,7 +54,7 @@ const w = ["includesAny", "includesAll", "excludes"], B = ({ value: r, onChange:
54
54
  u && /* @__PURE__ */ t("span", { className: "absolute right-3 top-3.5", onClick: v, children: /* @__PURE__ */ t(S, {}) })
55
55
  ] }),
56
56
  /* @__PURE__ */ t("div", { className: "flex-1", children: /* @__PURE__ */ t(
57
- y,
57
+ k,
58
58
  {
59
59
  data: x,
60
60
  itemContent: N,
@@ -66,5 +66,5 @@ const w = ["includesAny", "includesAll", "excludes"], B = ({ value: r, onChange:
66
66
  ] });
67
67
  };
68
68
  export {
69
- B as default
69
+ I as default
70
70
  };
@@ -8,7 +8,7 @@ const u = ({
8
8
  const l = d(r, s), n = o(l);
9
9
  return /* @__PURE__ */ e("div", { className: "flex flex-col gap-2.5 max-w-md", children: [
10
10
  n > 0 && /* @__PURE__ */ e("span", { className: "text-text-neutral-primary leading-none-medium-sm", children: [
11
- n,
11
+ n.toLocaleString(),
12
12
  " total"
13
13
  ] }),
14
14
  /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2.5 max-w-md", children: l.map((t, c) => /* @__PURE__ */ e(m.Fragment, { children: [
@@ -17,7 +17,7 @@ const u = ({
17
17
  " ",
18
18
  t.count !== void 0 && /* @__PURE__ */ e(i, { children: [
19
19
  "[",
20
- /* @__PURE__ */ a("span", { className: "text-text-neutral-secondary", children: t.count }),
20
+ /* @__PURE__ */ a("span", { className: "text-text-neutral-secondary", children: t.count.toLocaleString() }),
21
21
  "]"
22
22
  ] })
23
23
  ] }) }),
@@ -1,15 +1,15 @@
1
1
  import { jsxs as l, jsx as t } from "react/jsx-runtime";
2
2
  import * as F from "react";
3
- import * as m from "@radix-ui/react-popover";
3
+ import * as d from "@radix-ui/react-popover";
4
4
  import { Button as x } from "../button/button.js";
5
5
  import { useTableFilterContext as H } from "./table-filter.context.js";
6
- import U 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";
6
+ import L from "./filters/text.js";
7
+ import U 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 M } from "./selected-filters-display/selected-filters-display.utils.js";
13
13
  import { FilterConfirmationDialog as Q } from "./close-filter-confirm/filter-confirmation-dialog.js";
14
14
  import { hasUnsavedFilterChanges as N } from "./close-filter-confirm/filter-confirmation-dialog.utils.js";
15
15
  const ne = () => {
@@ -17,34 +17,34 @@ const ne = () => {
17
17
  selectedColumn: r,
18
18
  setSelectedColumn: k,
19
19
  getFilterForColumn: K,
20
- hasFilterForColumn: j,
21
- updateColumnFilter: A,
22
- clearAllFilters: D,
23
- resetToAppliedFilters: O,
24
- applyFilters: P,
25
- hasActiveFilters: d,
20
+ hasFilterForColumn: S,
21
+ updateColumnFilter: j,
22
+ clearAllFilters: A,
23
+ resetToAppliedFilters: D,
24
+ applyFilters: O,
25
+ hasActiveFilters: h,
26
26
  tempFilters: i,
27
27
  filterSchema: c,
28
- filter: h,
29
- filterComponents: p = {}
30
- } = H(), S = (e) => {
31
- !e && g ? N(i, h.value) ? a(!0) : n(!1) : n(e);
28
+ filter: p,
29
+ filterComponents: f = {}
30
+ } = H(), P = (e) => {
31
+ !e && g ? N(i, p.value) ? a(!0) : n(!1) : n(e);
32
32
  }, v = () => {
33
- P(), a(!1), n(!1);
33
+ O(), a(!1), n(!1);
34
34
  }, T = () => {
35
35
  a(!1), n(!1);
36
36
  }, $ = () => {
37
- O(), a(!1), n(!1);
37
+ D(), a(!1), n(!1);
38
38
  }, R = () => {
39
39
  a(!1);
40
- }, b = N(i, h.value), z = L(i, c), f = M(z), B = () => {
40
+ }, b = N(i, p.value), z = J(i, c), m = M(z), B = () => {
41
41
  if (!r) return null;
42
42
  const e = c.find((o) => o.filterKey === r), y = {
43
- boolean: V,
44
- string: U,
45
- number: q,
46
- checkbox: E
47
- }, C = (e == null ? void 0 : e.type) && (p == null ? void 0 : p[e.type]) || y[(e == null ? void 0 : e.type) ?? "string"];
43
+ boolean: U,
44
+ string: L,
45
+ number: V,
46
+ checkbox: q
47
+ }, C = (e == null ? void 0 : e.type) && (f == null ? void 0 : f[e.type]) || y[(e == null ? void 0 : e.type) ?? "string"];
48
48
  if (!C)
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".`
@@ -57,7 +57,7 @@ const ne = () => {
57
57
  C,
58
58
  {
59
59
  value: I,
60
- onChange: ({ condition: o, value: u }) => A(r, o, u),
60
+ onChange: ({ condition: o, value: u }) => j(r, o, u),
61
61
  filterOptions: e != null && e.options ? Object.entries(e.options).map(([o, u]) => ({
62
62
  label: o,
63
63
  value: o,
@@ -67,21 +67,21 @@ const ne = () => {
67
67
  r
68
68
  ) }) });
69
69
  };
70
- return /* @__PURE__ */ l(m.Root, { open: g, onOpenChange: S, children: [
71
- /* @__PURE__ */ t(m.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
70
+ return /* @__PURE__ */ l(d.Root, { open: g, onOpenChange: P, children: [
71
+ /* @__PURE__ */ t(d.Trigger, { asChild: !0, children: /* @__PURE__ */ l(
72
72
  x,
73
73
  {
74
- variant: d ? "filled" : "stroke",
75
- shade: d ? "brand" : "neutral",
74
+ variant: h ? "filled" : "stroke",
75
+ shade: h ? "brand" : "neutral",
76
76
  size: "small",
77
77
  children: [
78
78
  "Filters ",
79
- d && `(${h.value.length})`
79
+ h && `(${p.value.length})`
80
80
  ]
81
81
  }
82
82
  ) }),
83
- /* @__PURE__ */ t(m.Portal, { children: /* @__PURE__ */ l(
84
- m.Content,
83
+ /* @__PURE__ */ t(d.Portal, { children: /* @__PURE__ */ l(
84
+ d.Content,
85
85
  {
86
86
  className: "w-[512px] bg-surface-neutral-default border border-stroke-solid-light rounded-2xl overflow-hidden shadow-lg",
87
87
  sideOffset: 8,
@@ -97,7 +97,7 @@ const ne = () => {
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
- j(e.filterKey) && /* @__PURE__ */ t(G, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
100
+ S(e.filterKey) && /* @__PURE__ */ t(E, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
101
101
  ]
102
102
  },
103
103
  e.filterKey
@@ -105,10 +105,10 @@ const ne = () => {
105
105
  ] }),
106
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
- (!!f || b) && /* @__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 }),
108
+ (!!m || b) && /* @__PURE__ */ l("div", { className: "flex justify-between items-end p-4 border-t border-stroke-solid-medium min-h-[73px]", children: [
109
+ /* @__PURE__ */ t(G, { selectedFilters: i, schema: c }),
110
110
  /* @__PURE__ */ l("div", { className: "flex justify-end gap-2", children: [
111
- !!f && /* @__PURE__ */ t(x, { onClick: D, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
111
+ !!m && /* @__PURE__ */ t(x, { onClick: A, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
112
112
  /* @__PURE__ */ t(
113
113
  x,
114
114
  {
@@ -118,7 +118,7 @@ const ne = () => {
118
118
  size: "small",
119
119
  className: "min-w-20",
120
120
  disabled: !b,
121
- children: `Apply ${f || ""}`
121
+ children: `Apply ${m ? m.toLocaleString() : ""}`
122
122
  }
123
123
  )
124
124
  ] })