@ztwoint/z-ui 0.1.44 → 0.1.46

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 (63) hide show
  1. package/dist/components/avatar/avatar.d.ts +185 -0
  2. package/dist/components/avatar/avatar.js +55 -0
  3. package/dist/components/table/components/pagination/index.d.ts +1 -0
  4. package/dist/components/table/components/pagination/pagination.hook.d.ts +1 -1
  5. package/dist/components/table/components/pagination/pagination.hook.js +20 -16
  6. package/dist/components/table/components/table-filter/filters/checkbox.js +35 -51
  7. package/dist/components/table/components/table-filter/filters/text.js +41 -39
  8. package/dist/components/table/components/table-filter/index.d.ts +4 -1
  9. package/dist/components/table/components/table-filter/selected-filters-display/index.d.ts +2 -0
  10. package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.d.ts +3 -0
  11. package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.js +30 -0
  12. package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.type.d.ts +12 -0
  13. package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.d.ts +6 -0
  14. package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.js +26 -0
  15. package/dist/components/table/components/table-filter/table-filter-button.d.ts +2 -0
  16. package/dist/components/table/components/table-filter/table-filter-button.js +103 -0
  17. package/dist/components/table/components/table-filter/table-filter-column-button.d.ts +3 -0
  18. package/dist/components/table/components/table-filter/table-filter-column-button.js +78 -0
  19. package/dist/components/table/components/table-filter/table-filter-column-button.type.d.ts +3 -0
  20. package/dist/components/table/components/table-filter/table-filter-provider.d.ts +14 -0
  21. package/dist/components/table/components/table-filter/table-filter-provider.js +32 -0
  22. package/dist/components/table/components/table-filter/table-filter.context.d.ts +21 -0
  23. package/dist/components/table/components/table-filter/table-filter.context.js +13 -0
  24. package/dist/components/table/components/table-filter/table-filter.hook.d.ts +1 -2
  25. package/dist/components/table/components/table-filter/table-filter.hook.js +39 -37
  26. package/dist/components/table/index.d.ts +1 -2
  27. package/dist/components/table/table-provider.d.ts +1 -1
  28. package/dist/components/table/table-provider.js +13 -13
  29. package/dist/components/table/table.type.d.ts +2 -0
  30. package/dist/components/table/table.utils.d.ts +0 -1
  31. package/dist/components/table/table.utils.js +5 -3
  32. package/dist/components/table-card/table-card.js +69 -64
  33. package/dist/components/table-card/table-card.type.d.ts +7 -7
  34. package/dist/css/styles/tailwind.css +1 -1
  35. package/dist/hooks/useClickOutside.d.ts +1 -0
  36. package/dist/hooks/useClickOutside.js +14 -0
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.js +110 -110
  39. package/dist/types/components/avatar/avatar.d.ts +185 -0
  40. package/dist/types/components/table/components/pagination/index.d.ts +1 -0
  41. package/dist/types/components/table/components/pagination/pagination.hook.d.ts +1 -1
  42. package/dist/types/components/table/components/table-filter/index.d.ts +4 -1
  43. package/dist/types/components/table/components/table-filter/selected-filters-display/index.d.ts +2 -0
  44. package/dist/types/components/table/components/table-filter/selected-filters-display/selected-filters-display.d.ts +3 -0
  45. package/dist/types/components/table/components/table-filter/selected-filters-display/selected-filters-display.type.d.ts +12 -0
  46. package/dist/types/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.d.ts +6 -0
  47. package/dist/types/components/table/components/table-filter/table-filter-button.d.ts +2 -0
  48. package/dist/types/components/table/components/table-filter/table-filter-column-button.d.ts +3 -0
  49. package/dist/types/components/table/components/table-filter/table-filter-column-button.type.d.ts +3 -0
  50. package/dist/types/components/table/components/table-filter/table-filter-provider.d.ts +14 -0
  51. package/dist/types/components/table/components/table-filter/table-filter.context.d.ts +21 -0
  52. package/dist/types/components/table/components/table-filter/table-filter.hook.d.ts +1 -2
  53. package/dist/types/components/table/index.d.ts +1 -2
  54. package/dist/types/components/table/table-provider.d.ts +1 -1
  55. package/dist/types/components/table/table.type.d.ts +2 -0
  56. package/dist/types/components/table/table.utils.d.ts +0 -1
  57. package/dist/types/components/table-card/table-card.type.d.ts +7 -7
  58. package/dist/types/hooks/useClickOutside.d.ts +1 -0
  59. package/dist/types/index.d.ts +1 -0
  60. package/package.json +2 -1
  61. package/dist/components/table/components/table-filter/table-filter.d.ts +0 -9
  62. package/dist/components/table/components/table-filter/table-filter.js +0 -120
  63. package/dist/types/components/table/components/table-filter/table-filter.d.ts +0 -9
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Props for the Avatar Root component.
3
+ * @interface RootProps
4
+ */
5
+ interface RootProps {
6
+ /** Size variant of the avatar. Affects width, height, border radius, and text size */
7
+ size: 'xxs' | 'xs' | 'sm' | 'md';
8
+ /** Color theme of the avatar using design system color tokens */
9
+ color: 'orange' | 'purple' | 'green' | 'blue';
10
+ /** Child components, typically Avatar.Label or Avatar.Element */
11
+ children: React.ReactNode;
12
+ /** Additional CSS classes for custom styling */
13
+ className?: string;
14
+ /** Ref object for the root div element */
15
+ ref?: React.RefObject<HTMLDivElement>;
16
+ }
17
+ /**
18
+ * Avatar Root component - the container for avatar content.
19
+ *
20
+ * @param props - The component props
21
+ * @param props.size - Size variant (xxs: 18px, xs: 22px, sm: 26px, md: 30px)
22
+ * @param props.color - Color theme using design system tokens
23
+ * @param props.children - Child components (typically Avatar.Label)
24
+ * @param props.className - Additional CSS classes
25
+ * @param props.ref - Ref for the root div element
26
+ * @returns The rendered avatar container
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * <Avatar.Root size="sm" color="orange">
31
+ * <Avatar.Label label="JD" />
32
+ * </Avatar.Root>
33
+ * ```
34
+ */
35
+ declare function Root({ size, color, children, className, ref, ...props }: RootProps): import("react/jsx-runtime").JSX.Element;
36
+ /**
37
+ * Props for the Avatar Element component.
38
+ * @interface ElementProps
39
+ */
40
+ interface ElementProps {
41
+ /** Text content to display in the avatar (typically initials) */
42
+ label: string;
43
+ /** Additional CSS classes for custom styling */
44
+ className?: string;
45
+ /** Ref object for the span element */
46
+ ref?: React.RefObject<HTMLSpanElement>;
47
+ /** When true, merges props with the first child instead of rendering a span */
48
+ asChild?: boolean;
49
+ /** Child components (only used when asChild is true) */
50
+ children?: React.ReactNode;
51
+ }
52
+ /**
53
+ * Avatar Element component - flexible text/content renderer with asChild support.
54
+ *
55
+ * @param props - The component props
56
+ * @param props.label - Text to display (typically user initials)
57
+ * @param props.className - Additional CSS classes
58
+ * @param props.ref - Ref for the element
59
+ * @param props.asChild - When true, uses Radix Slot to merge with first child
60
+ * @param props.children - Child components (only when asChild is true)
61
+ * @returns The rendered element with avatar text styling
62
+ *
63
+ * @example
64
+ * ```tsx
65
+ * <Avatar.Element label="JD" />
66
+ *
67
+ * // With asChild for custom elements
68
+ * <Avatar.Element label="JD" asChild>
69
+ * <button>Custom Button</button>
70
+ * </Avatar.Element>
71
+ * ```
72
+ */
73
+ declare function Element({ label, className, ref, asChild, children, ...props }: ElementProps): import("react/jsx-runtime").JSX.Element;
74
+ /**
75
+ * Props for the Avatar Label component.
76
+ * @interface LabelProps
77
+ */
78
+ interface LabelProps {
79
+ /** Text content to display in the avatar (typically user initials) */
80
+ label: string;
81
+ /** Additional CSS classes for custom styling */
82
+ className?: string;
83
+ /** Ref object for the span element */
84
+ ref?: React.RefObject<HTMLSpanElement>;
85
+ }
86
+ /**
87
+ * Avatar Label component - simplified wrapper around Avatar.Element.
88
+ *
89
+ * @param props - The component props
90
+ * @param props.label - Text to display (typically user initials)
91
+ * @param props.className - Additional CSS classes
92
+ * @param props.ref - Ref for the span element
93
+ * @returns The rendered label with avatar text styling
94
+ *
95
+ * @example
96
+ * ```tsx
97
+ * <Avatar.Label label="JD" />
98
+ * <Avatar.Label label="AB" className="text-yellow-300" />
99
+ * ```
100
+ */
101
+ declare function Label({ label, className, ref, ...props }: LabelProps): import("react/jsx-runtime").JSX.Element;
102
+ /**
103
+ * Props for the AvatarWithLabel convenience component.
104
+ * @interface AvatarWithLabelProps
105
+ */
106
+ interface AvatarWithLabelProps {
107
+ /** Text content to display in the avatar (typically user initials) */
108
+ label: string;
109
+ /** Size variant of the avatar. Affects width, height, border radius, and text size */
110
+ size: 'xxs' | 'xs' | 'sm' | 'md';
111
+ /** Color theme of the avatar using design system color tokens */
112
+ color: 'orange' | 'purple' | 'green' | 'blue';
113
+ /** Additional CSS classes for custom styling */
114
+ className?: string;
115
+ /** Ref object for the root div element */
116
+ ref?: React.RefObject<HTMLDivElement>;
117
+ }
118
+ /**
119
+ * AvatarWithLabel - A convenience component that combines Avatar.Root and Avatar.Label.
120
+ * Perfect for simple use cases where you just need an avatar with text.
121
+ *
122
+ * @param props - The component props
123
+ * @param props.label - Text to display (typically user initials)
124
+ * @param props.size - Size variant (xxs: 18px, xs: 22px, sm: 26px, md: 30px)
125
+ * @param props.color - Color theme using design system tokens
126
+ * @param props.className - Additional CSS classes
127
+ * @param props.ref - Ref for the root div element
128
+ * @returns The rendered avatar with label
129
+ *
130
+ * @example
131
+ * ```tsx
132
+ * <AvatarWithLabel label="JD" size="sm" color="orange" />
133
+ * <AvatarWithLabel label="AB" size="md" color="blue" className="rounded-full" />
134
+ * ```
135
+ */
136
+ declare function AvatarWithLabel({ label, size, color, className, ref, ...props }: AvatarWithLabelProps): import("react/jsx-runtime").JSX.Element;
137
+ /**
138
+ * Avatar compound component with multiple variants for flexible usage.
139
+ *
140
+ * @namespace Avatar
141
+ * @property {React.ComponentType<RootProps>} Root - Container component for avatar content
142
+ * @property {React.ComponentType<ElementProps>} Element - Flexible text/content renderer with asChild support
143
+ * @property {React.ComponentType<LabelProps>} Label - Simplified text renderer (wrapper around Element)
144
+ *
145
+ * @example
146
+ * ```tsx
147
+ * // Basic usage
148
+ * <Avatar.Root size="sm" color="orange">
149
+ * <Avatar.Label label="JD" />
150
+ * </Avatar.Root>
151
+ *
152
+ * // With custom styling
153
+ * <Avatar.Root size="md" color="blue" className="rounded-full border-2 border-white">
154
+ * <Avatar.Label label="AB" className="text-yellow-300" />
155
+ * </Avatar.Root>
156
+ *
157
+ * // Using Element with asChild for custom components
158
+ * <Avatar.Root size="sm" color="green">
159
+ * <Avatar.Element label="CD" asChild>
160
+ * <button onClick={handleClick}>Clickable Avatar</button>
161
+ * </Avatar.Element>
162
+ * </Avatar.Root>
163
+ * ```
164
+ */
165
+ declare const Avatar: {
166
+ Root: typeof Root;
167
+ Element: typeof Element;
168
+ Label: typeof Label;
169
+ };
170
+ /**
171
+ * @fileoverview Avatar component library providing both compound and convenience components.
172
+ *
173
+ * This module exports:
174
+ * - Avatar: A compound component with Root, Element, and Label sub-components
175
+ * - AvatarWithLabel: A convenience component that combines Root and Label
176
+ *
177
+ * Features:
178
+ * - Multiple sizes (xxs, xs, sm, md) with responsive scaling
179
+ * - Color themes using design system tokens
180
+ * - Customizable styling via className
181
+ * - Radix Slot support for advanced composition
182
+ * - TypeScript support with comprehensive prop types
183
+ * - Optimized typography for readability at all sizes
184
+ */
185
+ export { Avatar, AvatarWithLabel, ElementProps, LabelProps, RootProps, AvatarWithLabelProps };
@@ -0,0 +1,55 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { cva as i } from "class-variance-authority";
3
+ import { cn as l } from "../../lib/utils.js";
4
+ import { Slot as f } from "@radix-ui/react-slot";
5
+ const d = i("px-[.375rem] aspect-square flex items-center justify-center", {
6
+ variants: {
7
+ size: {
8
+ xxs: "size-[1.125rem] rounded-[.3125rem] text-[8px]",
9
+ xs: "size-[1.375rem] rounded-md text-sm",
10
+ sm: "size-[1.625rem] rounded-lg text-sm",
11
+ md: "size-[1.875rem] rounded-[.625rem] text-base"
12
+ },
13
+ color: {
14
+ orange: "bg-[var(--surface-warning-default)]",
15
+ purple: "bg-[var(--surface-purple-default)]",
16
+ green: "bg-[var(--surface-success-default)]",
17
+ blue: "bg-[var(--surface-accent-default)]"
18
+ }
19
+ },
20
+ defaultVariants: {
21
+ size: "sm",
22
+ color: "orange"
23
+ }
24
+ });
25
+ function p({ size: t, color: a, children: r, className: e, ref: n, ...s }) {
26
+ const m = d({ size: t, color: a });
27
+ return /* @__PURE__ */ o("div", { "data-slot": "avatar-root", className: l(m, e), ref: n, ...s, children: r });
28
+ }
29
+ function u({ label: t, className: a, ref: r, asChild: e = !1, children: n, ...s }) {
30
+ return /* @__PURE__ */ o(
31
+ e ? f : "span",
32
+ {
33
+ "data-slot": "avatar-element",
34
+ className: l(e ? "" : "text-white text-center font-primary text-xs font-[450] leading-none tracking-[-0.0125rem] uppercase", a),
35
+ ref: r,
36
+ ...s,
37
+ children: e ? n : t
38
+ }
39
+ );
40
+ }
41
+ function x({ label: t, className: a, ref: r, ...e }) {
42
+ return /* @__PURE__ */ o(u, { label: t, className: a, ref: r, ...e });
43
+ }
44
+ function C({ label: t, size: a, color: r, className: e, ref: n, ...s }) {
45
+ return /* @__PURE__ */ o(c.Root, { size: a, color: r, className: e, ref: n, ...s, children: /* @__PURE__ */ o(c.Label, { label: t }) });
46
+ }
47
+ const c = {
48
+ Root: p,
49
+ Element: u,
50
+ Label: x
51
+ };
52
+ export {
53
+ c as Avatar,
54
+ C as AvatarWithLabel
55
+ };
@@ -1,4 +1,5 @@
1
1
  export { Pagination, default } from './pagination';
2
+ export { PaginationInfo, PaginationQuickJumper } from './components';
2
3
  export type { PaginationProps, PaginationInfoProps, PaginationQuickJumperProps, } from './pagination.type';
3
4
  export { usePagination } from './pagination.hook';
4
5
  export { usePaginationQuickJumper } from './components/pagination-quick-jumper.hook';
@@ -1,5 +1,5 @@
1
1
  import { PaginationHookProps, PaginationHookReturn } from './pagination.type';
2
- export declare const usePagination: (props: PaginationHookProps) => PaginationHookReturn & {
2
+ export declare const usePagination: ({ currentPage, totalPage, maxVisiblePages, }: PaginationHookProps) => PaginationHookReturn & {
3
3
  goToPage: (page: number) => boolean;
4
4
  canGoToPage: (page: number) => boolean;
5
5
  };
@@ -1,22 +1,26 @@
1
- import { useMemo as i, useCallback as o } from "react";
2
- import { calculateVisiblePages as l, isValidPageNumber as P } from "./pagination.utils.js";
3
- const u = (a) => {
4
- const n = i(
5
- () => l(a),
6
- [a.currentPage, a.totalPage, a.maxVisiblePages]
7
- ), e = o(
8
- (t) => P(t, a.totalPage),
9
- [a.totalPage]
10
- ), g = o(
11
- (t) => e(t),
12
- [e]
1
+ import { useMemo as u, useCallback as s } from "react";
2
+ import { calculateVisiblePages as a, isValidPageNumber as m } from "./pagination.utils.js";
3
+ const f = ({
4
+ currentPage: e,
5
+ totalPage: o,
6
+ maxVisiblePages: i
7
+ }) => {
8
+ const t = u(
9
+ () => a({ currentPage: e, totalPage: o, maxVisiblePages: i }),
10
+ [e, o, i]
11
+ ), n = s(
12
+ (r) => m(r, o),
13
+ [o]
14
+ ), c = s(
15
+ (r) => n(r),
16
+ [n]
13
17
  );
14
18
  return {
15
- ...n,
16
- goToPage: g,
17
- canGoToPage: e
19
+ ...t,
20
+ goToPage: c,
21
+ canGoToPage: n
18
22
  };
19
23
  };
20
24
  export {
21
- u as usePagination
25
+ f as usePagination
22
26
  };
@@ -1,74 +1,58 @@
1
- import { jsx as t, jsxs as r } from "react/jsx-runtime";
2
- import { useState as o, useEffect as f } from "react";
3
- import { MagnifierIcon as k } from "../../../../assets/icons/magnifier-icon.js";
1
+ import { jsx as t, jsxs as s } from "react/jsx-runtime";
2
+ import { useState as i, useEffect as h } from "react";
3
+ import { MagnifierIcon as y } from "../../../../assets/icons/magnifier-icon.js";
4
4
  import C from "../../../../assets/icons/x.js";
5
- const h = ["includesAny", "includesAll", "excludes"], j = ({ value: s, onChange: d, filterOptions: c = [] }) => {
6
- const [n, u] = o([]), [i, m] = o(""), [p, x] = o(c), b = (e) => {
5
+ const k = ["includesAny", "includesAll", "excludes"], j = ({ value: r, onChange: d, filterOptions: c = [] }) => {
6
+ const [n, o] = i([]), [u, m] = i(""), [x, f] = i(c), p = (e) => {
7
7
  m(e.target.value);
8
- const l = c.filter(
9
- (a) => a.label.toLowerCase().includes(e.target.value.toLowerCase())
8
+ const a = c.filter(
9
+ (l) => l.label.toLowerCase().includes(e.target.value.toLowerCase())
10
10
  );
11
- x(l);
11
+ f(a);
12
12
  };
13
- f(() => {
14
- s.condition || d({ condition: h[0] });
15
- }, []), f(() => {
16
- Array.isArray(s.value) ? u(s.value.filter(Boolean)) : u([]);
17
- }, [s.value]);
18
- const v = (e, l) => {
19
- let a;
20
- l ? a = [...n, e] : a = n.filter((y) => y !== e), u(a), d({ value: a });
21
- }, g = () => {
22
- m(""), x(c);
13
+ h(() => {
14
+ r.condition || d({ condition: k[0] });
15
+ }, []), h(() => {
16
+ Array.isArray(r.value) ? o(r.value.filter(Boolean)) : o([]);
17
+ }, [r.value]);
18
+ const v = (e, a) => {
19
+ let l;
20
+ a ? l = [...n, e] : l = n.filter((g) => g !== e), o(l), d({ value: l });
21
+ }, b = () => {
22
+ m(""), f(c);
23
23
  }, N = (e) => n.includes(e);
24
- return c.length === 0 ? /* @__PURE__ */ t("div", { className: "text-text-neutral-muted text-sm", children: "No filter options available for this column" }) : /* @__PURE__ */ r("div", { className: "flex flex-col", children: [
25
- /* @__PURE__ */ r("div", { className: "relative border-b border-stroke-solid-medium", children: [
26
- /* @__PURE__ */ t(k, { className: "absolute left-3 top-3.5 text-text-neutral-muted" }),
24
+ return c.length === 0 ? /* @__PURE__ */ t("div", { className: "text-text-neutral-muted text-sm", children: "No filter options available for this column" }) : /* @__PURE__ */ s("div", { className: "flex flex-col", children: [
25
+ /* @__PURE__ */ s("div", { className: "relative border-b border-stroke-solid-medium", children: [
26
+ /* @__PURE__ */ t(y, { className: "absolute left-3 top-3.5 text-text-neutral-muted" }),
27
27
  /* @__PURE__ */ t(
28
28
  "input",
29
29
  {
30
30
  placeholder: "Search options",
31
- value: i,
32
- onChange: b,
33
- className: "border-none outline-none bg-surface-neutral-default text-text-neutral-primary rounded p-3 pl-10 text-sm w-full"
31
+ value: u,
32
+ onChange: p,
33
+ className: "border-none outline-none bg-surface-neutral-default text-text-neutral-primary rounded p-3 pl-8 leading-none-medium-sm w-full"
34
34
  }
35
35
  ),
36
- i && /* @__PURE__ */ t("span", { className: "absolute right-3 top-3.5", onClick: g, children: /* @__PURE__ */ t(C, {}) })
36
+ u && /* @__PURE__ */ t("span", { className: "absolute right-3 top-3.5", onClick: b, children: /* @__PURE__ */ t(C, {}) })
37
37
  ] }),
38
- /* @__PURE__ */ r("div", { className: "flex flex-col gap-2 p-3", children: [
39
- /* @__PURE__ */ t(
40
- "select",
41
- {
42
- value: s.condition,
43
- onChange: (e) => d({ condition: e.target.value }),
44
- className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm mb-3",
45
- children: h.map((e) => /* @__PURE__ */ r("option", { value: e, children: [
46
- e === "includesAny" && "Includes any of",
47
- e === "includesAll" && "Includes all of",
48
- e === "excludes" && "Excludes"
49
- ] }, e))
50
- }
51
- ),
52
- /* @__PURE__ */ t("div", { className: "space-y-2 max-h-48 overflow-y-auto", children: p.map((e) => /* @__PURE__ */ r("label", { className: "flex items-center space-x-2 cursor-pointer", children: [
38
+ /* @__PURE__ */ t("div", { className: "flex flex-col p-3", children: /* @__PURE__ */ t("div", { className: "space-y-5 h-full overflow-y-auto", children: x.map((e) => /* @__PURE__ */ s("div", { className: "flex justify-between items-center", children: [
39
+ /* @__PURE__ */ s("label", { className: "flex items-center space-x-2 cursor-pointer", children: [
53
40
  /* @__PURE__ */ t(
54
41
  "input",
55
42
  {
56
43
  type: "checkbox",
57
44
  checked: N(e.value),
58
- onChange: (l) => v(e.value, l.target.checked),
59
- className: "rounded border-stroke-solid-medium text-text-neutral-primary focus:ring-2 focus:ring-blue-500"
45
+ onChange: (a) => v(e.value, a.target.checked)
60
46
  }
61
47
  ),
62
- /* @__PURE__ */ t("span", { className: "text-text-neutral-primary text-sm", children: e.label })
63
- ] }, e.value)) }),
64
- n.length > 0 && /* @__PURE__ */ r("div", { className: "mt-3 p-2 bg-surface-neutral-muted rounded text-sm", children: [
65
- /* @__PURE__ */ t("div", { className: "text-text-neutral-muted mb-1", children: "Selected:" }),
66
- /* @__PURE__ */ t("div", { className: "text-text-neutral-primary", children: n.map((e) => {
67
- const l = c.find((a) => a.value === e);
68
- return (l == null ? void 0 : l.label) || e;
69
- }).join(", ") })
48
+ /* @__PURE__ */ t("span", { className: "text-text-neutral-primary leading-none-medium-sm", children: e.label })
49
+ ] }),
50
+ e.total && /* @__PURE__ */ s("span", { className: "text-text-neutral-muted text-sm", children: [
51
+ "[",
52
+ e.total,
53
+ "]"
70
54
  ] })
71
- ] })
55
+ ] }, e.value)) }) })
72
56
  ] });
73
57
  };
74
58
  export {
@@ -1,51 +1,53 @@
1
- import { jsxs as r, jsx as l } from "react/jsx-runtime";
2
- import { useEffect as s } from "react";
3
- import u from "../../../../assets/icons/x.js";
4
- import { MagnifierIcon as c } from "../../../../assets/icons/magnifier-icon.js";
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";
5
6
  const o = [
6
7
  { label: "Contains", value: "contains" },
7
8
  { label: "Does not equal", value: "notEqual" },
8
9
  { label: "Equals", value: "equals" }
9
- ], f = ({ value: t, onChange: a }) => {
10
- var n;
11
- const i = () => {
10
+ ], h = ({ value: t, onChange: a }) => {
11
+ var i;
12
+ const n = () => {
12
13
  a({ value: "" });
13
14
  };
14
- return s(() => {
15
+ return c(() => {
15
16
  t.condition || a({ condition: o[0].value });
16
- }, []), /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
17
- /* @__PURE__ */ r("div", { className: "relative border-b border-stroke-solid-medium", children: [
18
- /* @__PURE__ */ l(c, { className: "absolute left-3 top-3.5 text-text-neutral-muted" }),
19
- /* @__PURE__ */ l(
20
- "input",
21
- {
22
- placeholder: "Search options",
23
- value: t.value,
24
- onChange: (e) => a({ value: e.target.value }),
25
- className: "border-none outline-none bg-surface-neutral-default text-text-neutral-primary rounded p-3 pl-10 text-sm w-full"
26
- }
27
- ),
28
- t.value && /* @__PURE__ */ l("span", { className: "absolute right-3 top-3.5", onClick: i, children: /* @__PURE__ */ l(u, {}) })
29
- ] }),
30
- /* @__PURE__ */ r("div", { className: "flex flex-col gap-2 p-3", children: [
31
- /* @__PURE__ */ l(
32
- "select",
33
- {
34
- value: t.condition,
35
- onChange: (e) => a({ condition: e.target.value }),
36
- className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm",
37
- children: o.map((e) => /* @__PURE__ */ l("option", { value: e.value, children: e.label }, e.value))
38
- }
39
- ),
40
- t.value && /* @__PURE__ */ r("div", { className: "text-text-neutral-primary text-sm text-center", children: [
41
- (n = o.find((e) => e.value === t.condition)) == null ? void 0 : n.label,
42
- ":",
43
- " ",
44
- t.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,
20
+ {
21
+ leftIcon: /* @__PURE__ */ e(u, {}),
22
+ size: "large",
23
+ 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 }),
27
+ className: ""
28
+ }
29
+ ) }),
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: [
34
+ "“",
35
+ t.value,
36
+ "”"
37
+ ] }),
38
+ /* @__PURE__ */ e(
39
+ "button",
40
+ {
41
+ onClick: n,
42
+ className: "flex items-center justify-center w-5 h-5 rounded-full bg-surface-neutral-hovered hover:bg-surface-neutral-pressed transition-colors",
43
+ title: "Remove filter",
44
+ children: /* @__PURE__ */ e(s, { className: "w-3 h-3 text-text-neutral-muted" })
45
+ }
46
+ )
45
47
  ] })
46
- ] })
48
+ ] }) })
47
49
  ] });
48
50
  };
49
51
  export {
50
- f as default
52
+ h as default
51
53
  };
@@ -1 +1,4 @@
1
- export { TableFilter } from './table-filter';
1
+ export { TableFilterProvider, TableFilter } from './table-filter-provider';
2
+ export { TableFilterButton } from './table-filter-button';
3
+ export { TableFilterColumnButton } from './table-filter-column-button';
4
+ export { useTableFilterContext } from './table-filter.context';
@@ -0,0 +1,2 @@
1
+ export { SelectedFiltersDisplay } from './selected-filters-display';
2
+ export type { SelectedFilterDisplayProps, FilterDisplayItem, } from './selected-filters-display.type';
@@ -0,0 +1,3 @@
1
+ import { SelectedFilterDisplayProps } from './selected-filters-display.type';
2
+ import * as React from 'react';
3
+ export declare const SelectedFiltersDisplay: React.FC<SelectedFilterDisplayProps>;
@@ -0,0 +1,30 @@
1
+ import { jsxs as e, jsx as a, Fragment as i } from "react/jsx-runtime";
2
+ import * as m from "react";
3
+ import { createFilterDisplayItems as d, calculateTotalCount as o } from "./selected-filters-display.utils.js";
4
+ const u = ({
5
+ selectedFilters: r,
6
+ schema: s
7
+ }) => {
8
+ const l = d(r, s), n = o(l);
9
+ return /* @__PURE__ */ e("div", { className: "flex flex-col gap-2.5 max-w-md", children: [
10
+ n > 0 && /* @__PURE__ */ e("span", { className: "text-text-neutral-primary leading-none-medium-sm", children: [
11
+ n,
12
+ " total"
13
+ ] }),
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: [
15
+ /* @__PURE__ */ a("div", { className: "inline-flex items-center text-text-neutral-secondary rounded-md leading-none-regular-sm", children: /* @__PURE__ */ e("span", { className: "text-text-neutral-muted", children: [
16
+ t.fieldTitle,
17
+ " ",
18
+ t.count !== void 0 && /* @__PURE__ */ e(i, { children: [
19
+ "[",
20
+ /* @__PURE__ */ a("span", { className: "text-text-neutral-secondary", children: t.count }),
21
+ "]"
22
+ ] })
23
+ ] }) }),
24
+ c < l.length - 1 && /* @__PURE__ */ a("span", { className: "text-text-neutral-muted", children: "•" })
25
+ ] }, t.field)) })
26
+ ] });
27
+ };
28
+ export {
29
+ u as SelectedFiltersDisplay
30
+ };
@@ -0,0 +1,12 @@
1
+ import { FilterRule, TableSchema } from '../../../table.type';
2
+ export interface SelectedFilterDisplayProps {
3
+ selectedFilters: FilterRule[];
4
+ schema: TableSchema;
5
+ }
6
+ export interface FilterDisplayItem {
7
+ field: string;
8
+ fieldTitle: string;
9
+ value: string | string[];
10
+ condition?: string;
11
+ count?: number;
12
+ }
@@ -0,0 +1,6 @@
1
+ import { FilterRule, TableSchema, FilterOption } from '../../../table.type';
2
+ import { FilterDisplayItem } from './selected-filters-display.type';
3
+ export declare const formatFilterValue: (value: string | string[]) => string;
4
+ export declare const getFilterCount: (filterRule: FilterRule, filterOptions?: FilterOption[]) => number | undefined;
5
+ export declare const createFilterDisplayItems: (selectedFilters: FilterRule[], schema: TableSchema) => FilterDisplayItem[];
6
+ export declare const calculateTotalCount: (filterDisplayItems: FilterDisplayItem[]) => number;
@@ -0,0 +1,26 @@
1
+ const a = (r, n) => {
2
+ if (!(!n || n.length === 0))
3
+ if (Array.isArray(r.value)) {
4
+ const t = n.filter(
5
+ (u) => r.value.includes(u.value)
6
+ ).reduce((u, o) => u + (o.total || 0), 0);
7
+ return t > 0 ? t : void 0;
8
+ } else {
9
+ const e = n.find((t) => t.value === r.value);
10
+ return e == null ? void 0 : e.total;
11
+ }
12
+ }, l = (r, n) => r.filter((e) => Array.isArray(e.value) ? e.value.length > 0 : e.value !== "").map((e) => {
13
+ const t = n.find((o) => o.key === e.field), u = a(e, t == null ? void 0 : t.filterOptions);
14
+ return {
15
+ field: e.field,
16
+ fieldTitle: (t == null ? void 0 : t.title) || e.field,
17
+ value: e.value,
18
+ condition: e.condition,
19
+ count: u
20
+ };
21
+ }), c = (r) => r.reduce((n, e) => n + (e.count || 0), 0);
22
+ export {
23
+ c as calculateTotalCount,
24
+ l as createFilterDisplayItems,
25
+ a as getFilterCount
26
+ };
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare const TableFilterButton: React.FC;