@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.
- package/dist/components/avatar/avatar.d.ts +185 -0
- package/dist/components/avatar/avatar.js +55 -0
- package/dist/components/table/components/pagination/index.d.ts +1 -0
- package/dist/components/table/components/pagination/pagination.hook.d.ts +1 -1
- package/dist/components/table/components/pagination/pagination.hook.js +20 -16
- package/dist/components/table/components/table-filter/filters/checkbox.js +35 -51
- package/dist/components/table/components/table-filter/filters/text.js +41 -39
- package/dist/components/table/components/table-filter/index.d.ts +4 -1
- package/dist/components/table/components/table-filter/selected-filters-display/index.d.ts +2 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.d.ts +3 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.js +30 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.type.d.ts +12 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.d.ts +6 -0
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.js +26 -0
- package/dist/components/table/components/table-filter/table-filter-button.d.ts +2 -0
- package/dist/components/table/components/table-filter/table-filter-button.js +103 -0
- package/dist/components/table/components/table-filter/table-filter-column-button.d.ts +3 -0
- package/dist/components/table/components/table-filter/table-filter-column-button.js +78 -0
- package/dist/components/table/components/table-filter/table-filter-column-button.type.d.ts +3 -0
- package/dist/components/table/components/table-filter/table-filter-provider.d.ts +14 -0
- package/dist/components/table/components/table-filter/table-filter-provider.js +32 -0
- package/dist/components/table/components/table-filter/table-filter.context.d.ts +21 -0
- package/dist/components/table/components/table-filter/table-filter.context.js +13 -0
- package/dist/components/table/components/table-filter/table-filter.hook.d.ts +1 -2
- package/dist/components/table/components/table-filter/table-filter.hook.js +39 -37
- package/dist/components/table/index.d.ts +1 -2
- package/dist/components/table/table-provider.d.ts +1 -1
- package/dist/components/table/table-provider.js +13 -13
- package/dist/components/table/table.type.d.ts +2 -0
- package/dist/components/table/table.utils.d.ts +0 -1
- package/dist/components/table/table.utils.js +5 -3
- package/dist/components/table-card/table-card.js +69 -64
- package/dist/components/table-card/table-card.type.d.ts +7 -7
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/hooks/useClickOutside.d.ts +1 -0
- package/dist/hooks/useClickOutside.js +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +110 -110
- package/dist/types/components/avatar/avatar.d.ts +185 -0
- package/dist/types/components/table/components/pagination/index.d.ts +1 -0
- package/dist/types/components/table/components/pagination/pagination.hook.d.ts +1 -1
- package/dist/types/components/table/components/table-filter/index.d.ts +4 -1
- package/dist/types/components/table/components/table-filter/selected-filters-display/index.d.ts +2 -0
- package/dist/types/components/table/components/table-filter/selected-filters-display/selected-filters-display.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/selected-filters-display/selected-filters-display.type.d.ts +12 -0
- package/dist/types/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.d.ts +6 -0
- package/dist/types/components/table/components/table-filter/table-filter-button.d.ts +2 -0
- package/dist/types/components/table/components/table-filter/table-filter-column-button.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/table-filter-column-button.type.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/table-filter-provider.d.ts +14 -0
- package/dist/types/components/table/components/table-filter/table-filter.context.d.ts +21 -0
- package/dist/types/components/table/components/table-filter/table-filter.hook.d.ts +1 -2
- package/dist/types/components/table/index.d.ts +1 -2
- package/dist/types/components/table/table-provider.d.ts +1 -1
- package/dist/types/components/table/table.type.d.ts +2 -0
- package/dist/types/components/table/table.utils.d.ts +0 -1
- package/dist/types/components/table-card/table-card.type.d.ts +7 -7
- package/dist/types/hooks/useClickOutside.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +2 -1
- package/dist/components/table/components/table-filter/table-filter.d.ts +0 -9
- package/dist/components/table/components/table-filter/table-filter.js +0 -120
- package/dist/types/components/table/components/table-filter/table-filter.d.ts +0 -9
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as f from "react";
|
|
3
|
+
import { Button as c } from "../../../button/button.js";
|
|
4
|
+
import { useTableFilterContext as O } from "./table-filter.context.js";
|
|
5
|
+
import z from "./filters/text.js";
|
|
6
|
+
import S from "./filters/boolean.js";
|
|
7
|
+
import $ from "./filters/number/number.js";
|
|
8
|
+
import B from "./filters/checkbox.js";
|
|
9
|
+
import R from "../../../assets/icons/circle-check-filled.js";
|
|
10
|
+
import { SelectedFiltersDisplay as P } from "./selected-filters-display/selected-filters-display.js";
|
|
11
|
+
import { useClickOutside as D } from "../../../../hooks/useClickOutside.js";
|
|
12
|
+
const Q = () => {
|
|
13
|
+
const [d, o] = f.useState(!1), m = f.useRef(null), {
|
|
14
|
+
selectedColumn: r,
|
|
15
|
+
setSelectedColumn: h,
|
|
16
|
+
getFilterForColumn: x,
|
|
17
|
+
hasFilterForColumn: b,
|
|
18
|
+
updateColumnFilter: v,
|
|
19
|
+
clearAllFilters: y,
|
|
20
|
+
applyFilters: F,
|
|
21
|
+
hasActiveFilters: i,
|
|
22
|
+
filterableFields: k,
|
|
23
|
+
tempFilters: N,
|
|
24
|
+
schema: p,
|
|
25
|
+
filter: g,
|
|
26
|
+
filterComponents: n = {}
|
|
27
|
+
} = O();
|
|
28
|
+
D(m, () => o(!1));
|
|
29
|
+
const w = () => {
|
|
30
|
+
F(), o(!1);
|
|
31
|
+
}, C = () => {
|
|
32
|
+
if (!r) return null;
|
|
33
|
+
const e = p.find((a) => a.key === r), T = {
|
|
34
|
+
boolean: S,
|
|
35
|
+
text: z,
|
|
36
|
+
number: $,
|
|
37
|
+
checkbox: B
|
|
38
|
+
}, u = (n == null ? void 0 : n[(e == null ? void 0 : e.cellType) || ""]) || T[(e == null ? void 0 : e.cellType) || "text"];
|
|
39
|
+
if (!u)
|
|
40
|
+
return console.warn(
|
|
41
|
+
`No filter component found for column "${e == null ? void 0 : e.key}" with cellType "${e == null ? void 0 : e.cellType}". Provide a custom filter component or use supported types: "text", "number", "boolean", "checkbox".`
|
|
42
|
+
), null;
|
|
43
|
+
const s = x(r), j = {
|
|
44
|
+
condition: (s == null ? void 0 : s.condition) || "",
|
|
45
|
+
value: (s == null ? void 0 : s.value) || ""
|
|
46
|
+
};
|
|
47
|
+
return /* @__PURE__ */ t("div", { className: "flex-1", children: /* @__PURE__ */ t("div", { className: "mb-4", children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ t(
|
|
48
|
+
u,
|
|
49
|
+
{
|
|
50
|
+
value: j,
|
|
51
|
+
onChange: ({ condition: a, value: A }) => v(r, a, A),
|
|
52
|
+
filterOptions: e == null ? void 0 : e.filterOptions
|
|
53
|
+
}
|
|
54
|
+
) }) }) });
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ l("div", { className: "relative", ref: m, children: [
|
|
57
|
+
/* @__PURE__ */ l(
|
|
58
|
+
c,
|
|
59
|
+
{
|
|
60
|
+
onClick: (e) => {
|
|
61
|
+
e.stopPropagation(), o(!d);
|
|
62
|
+
},
|
|
63
|
+
variant: i ? "filled" : "stroke",
|
|
64
|
+
shade: i ? "brand" : "neutral",
|
|
65
|
+
size: "small",
|
|
66
|
+
children: [
|
|
67
|
+
"Filter ",
|
|
68
|
+
i && `(${g.value.length})`
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
d && /* @__PURE__ */ l("div", { className: "absolute top-full left-0 mt-2 w-[512px] bg-surface-neutral-default border border-stroke-solid-light rounded-2xl z-10 overflow-hidden shadow-lg", children: [
|
|
73
|
+
/* @__PURE__ */ l("div", { className: "flex min-h-[442px]", children: [
|
|
74
|
+
/* @__PURE__ */ l("div", { className: "w-48 border-r border-stroke-solid-light p-2 flex flex-col gap-1.5", children: [
|
|
75
|
+
/* @__PURE__ */ t("div", { className: "p-2 pb-1", children: /* @__PURE__ */ t("h3", { className: "leading-none-medium-sm text-text-neutral-secondary", children: "Filters" }) }),
|
|
76
|
+
k.map((e) => /* @__PURE__ */ l(
|
|
77
|
+
"button",
|
|
78
|
+
{
|
|
79
|
+
onClick: () => h(e.key),
|
|
80
|
+
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.key ? "bg-surface-neutral-focused text-text-brand-primary" : "text-text-neutral-primary"}`,
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: e.title }),
|
|
83
|
+
b(e.key) && /* @__PURE__ */ t(R, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
e.key
|
|
87
|
+
))
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ t("div", { className: "flex-1 flex flex-col", children: r ? C() : /* @__PURE__ */ t("div", { className: "flex-1 flex items-center justify-center text-text-neutral-muted", children: "Select a column to configure its filter" }) })
|
|
90
|
+
] }),
|
|
91
|
+
/* @__PURE__ */ l("div", { className: "flex justify-between items-end p-4 border-t border-stroke-solid-medium", children: [
|
|
92
|
+
/* @__PURE__ */ t(P, { selectedFilters: N, schema: p }),
|
|
93
|
+
/* @__PURE__ */ l("div", { className: "flex justify-end gap-2", children: [
|
|
94
|
+
/* @__PURE__ */ t(c, { onClick: y, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
|
|
95
|
+
/* @__PURE__ */ t(c, { onClick: w, variant: "filled", shade: "neutral", size: "small", children: "Apply" })
|
|
96
|
+
] })
|
|
97
|
+
] })
|
|
98
|
+
] })
|
|
99
|
+
] });
|
|
100
|
+
};
|
|
101
|
+
export {
|
|
102
|
+
Q as TableFilterButton
|
|
103
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as h from "react";
|
|
3
|
+
import { Button as c } from "../../../button/button.js";
|
|
4
|
+
import { useTableFilterContext as g } from "./table-filter.context.js";
|
|
5
|
+
import T from "./filters/text.js";
|
|
6
|
+
import A from "./filters/boolean.js";
|
|
7
|
+
import O from "./filters/number/number.js";
|
|
8
|
+
import z from "./filters/checkbox.js";
|
|
9
|
+
import $ from "../../../assets/icons/circle-check-filled.js";
|
|
10
|
+
import { useClickOutside as j } from "../../../../hooks/useClickOutside.js";
|
|
11
|
+
const E = ({ filterName: l }) => {
|
|
12
|
+
const [d, n] = h.useState(!1), u = h.useRef(null);
|
|
13
|
+
j(u, () => n(!1));
|
|
14
|
+
const {
|
|
15
|
+
getFilterForColumn: b,
|
|
16
|
+
hasAppliedFilterForColumn: C,
|
|
17
|
+
updateColumnFilter: m,
|
|
18
|
+
applyFilters: p,
|
|
19
|
+
schema: x,
|
|
20
|
+
filterComponents: i = {}
|
|
21
|
+
} = g(), e = x.find((a) => a.key === l);
|
|
22
|
+
if (!e)
|
|
23
|
+
return console.warn(`Column "${l}" not found in schema`), null;
|
|
24
|
+
if (e.filterable === !1)
|
|
25
|
+
return console.warn(`Column "${l}" is not filterable`), null;
|
|
26
|
+
const k = {
|
|
27
|
+
boolean: A,
|
|
28
|
+
text: T,
|
|
29
|
+
number: O,
|
|
30
|
+
checkbox: z
|
|
31
|
+
}, f = (i == null ? void 0 : i[e.cellType || ""]) || k[e.cellType || "text"];
|
|
32
|
+
if (!f)
|
|
33
|
+
return console.warn(
|
|
34
|
+
`No filter component found for column "${e.key}" with cellType "${e.cellType}". Provide a custom filter component or use supported types: "text", "number", "boolean", "checkbox".`
|
|
35
|
+
), null;
|
|
36
|
+
const o = b(l), s = C(l), F = {
|
|
37
|
+
condition: (o == null ? void 0 : o.condition) || "",
|
|
38
|
+
value: (o == null ? void 0 : o.value) || ""
|
|
39
|
+
}, v = () => {
|
|
40
|
+
m(l, "", ""), p(), n(!1);
|
|
41
|
+
}, w = () => {
|
|
42
|
+
p(), n(!1);
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ r("div", { className: "relative", ref: u, children: [
|
|
45
|
+
/* @__PURE__ */ t(
|
|
46
|
+
c,
|
|
47
|
+
{
|
|
48
|
+
onClick: () => {
|
|
49
|
+
n(!d);
|
|
50
|
+
},
|
|
51
|
+
variant: s ? "filled" : "stroke",
|
|
52
|
+
shade: s ? "brand" : "neutral",
|
|
53
|
+
size: "small",
|
|
54
|
+
children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
|
|
55
|
+
e.title,
|
|
56
|
+
s && /* @__PURE__ */ t($, { className: "w-4 h-4 text-white flex-shrink-0" })
|
|
57
|
+
] })
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
d && /* @__PURE__ */ r("div", { className: "absolute top-full left-0 mt-2 w-80 bg-surface-neutral-default border border-stroke-solid-light rounded-2xl z-10 overflow-hidden shadow-lg", children: [
|
|
61
|
+
/* @__PURE__ */ t(
|
|
62
|
+
f,
|
|
63
|
+
{
|
|
64
|
+
value: F,
|
|
65
|
+
onChange: ({ condition: a, value: y }) => m(l, a, y),
|
|
66
|
+
filterOptions: e.filterOptions
|
|
67
|
+
}
|
|
68
|
+
),
|
|
69
|
+
/* @__PURE__ */ r("div", { className: "flex justify-between gap-2 p-3 border-t border-stroke-solid-medium", children: [
|
|
70
|
+
/* @__PURE__ */ t(c, { onClick: v, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
|
|
71
|
+
/* @__PURE__ */ t(c, { onClick: w, variant: "filled", shade: "neutral", size: "small", children: "Apply" })
|
|
72
|
+
] })
|
|
73
|
+
] })
|
|
74
|
+
] });
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
E as TableFilterColumnButton
|
|
78
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TableFilterProps } from './table-filter.type';
|
|
2
|
+
import { TableFilterButton } from './table-filter-button';
|
|
3
|
+
import { TableFilterColumnButton } from './table-filter-column-button';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
export interface TableFilterProviderProps extends TableFilterProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const TableFilterProvider: React.FC<TableFilterProviderProps>;
|
|
9
|
+
interface TableFilterCompoundComponent extends React.FC<TableFilterProviderProps> {
|
|
10
|
+
FilterButton: typeof TableFilterButton;
|
|
11
|
+
FilterColumnButton: typeof TableFilterColumnButton;
|
|
12
|
+
}
|
|
13
|
+
export declare const TableFilter: TableFilterCompoundComponent;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import m from "./table-filter.hook.js";
|
|
3
|
+
import { TableFilterContext as a } from "./table-filter.context.js";
|
|
4
|
+
import { TableFilterButton as F } from "./table-filter-button.js";
|
|
5
|
+
import { TableFilterColumnButton as b } from "./table-filter-column-button.js";
|
|
6
|
+
const p = ({
|
|
7
|
+
children: e,
|
|
8
|
+
filterComponents: l = {},
|
|
9
|
+
schema: o,
|
|
10
|
+
filter: t
|
|
11
|
+
}) => {
|
|
12
|
+
const n = m({
|
|
13
|
+
schema: o,
|
|
14
|
+
filter: t || { value: [], onChange: () => {
|
|
15
|
+
} }
|
|
16
|
+
});
|
|
17
|
+
if (!t)
|
|
18
|
+
return null;
|
|
19
|
+
const i = {
|
|
20
|
+
...n,
|
|
21
|
+
schema: o,
|
|
22
|
+
filter: t,
|
|
23
|
+
filterComponents: l
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ u(a.Provider, { value: i, children: e });
|
|
26
|
+
}, r = p;
|
|
27
|
+
r.FilterButton = F;
|
|
28
|
+
r.FilterColumnButton = b;
|
|
29
|
+
export {
|
|
30
|
+
r as TableFilter,
|
|
31
|
+
p as TableFilterProvider
|
|
32
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TableSchema, TableFilter as TableFilterType, FilterRule } from '../../table.type';
|
|
2
|
+
import { FilterComponentType } from './table-filter.type';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export interface TableFilterContextValue {
|
|
5
|
+
selectedColumn: string | null;
|
|
6
|
+
setSelectedColumn: (column: string | null) => void;
|
|
7
|
+
getFilterForColumn: (columnKey: string) => FilterRule | undefined;
|
|
8
|
+
hasFilterForColumn: (columnKey: string) => boolean;
|
|
9
|
+
hasAppliedFilterForColumn: (columnKey: string) => boolean;
|
|
10
|
+
updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) => void;
|
|
11
|
+
clearAllFilters: () => void;
|
|
12
|
+
applyFilters: () => void;
|
|
13
|
+
hasActiveFilters: boolean;
|
|
14
|
+
filterableFields: TableSchema;
|
|
15
|
+
tempFilters: FilterRule[];
|
|
16
|
+
schema: TableSchema;
|
|
17
|
+
filter: TableFilterType;
|
|
18
|
+
filterComponents?: Record<string, FilterComponentType>;
|
|
19
|
+
}
|
|
20
|
+
export declare const TableFilterContext: React.Context<TableFilterContextValue | undefined>;
|
|
21
|
+
export declare const useTableFilterContext: () => TableFilterContextValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
const o = e.createContext(
|
|
3
|
+
void 0
|
|
4
|
+
), r = () => {
|
|
5
|
+
const t = e.useContext(o);
|
|
6
|
+
if (t === void 0)
|
|
7
|
+
throw new Error("useTableFilterContext must be used within a TableFilterProvider");
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
o as TableFilterContext,
|
|
12
|
+
r as useTableFilterContext
|
|
13
|
+
};
|
|
@@ -2,16 +2,15 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { TableFilterProps } from './table-filter.type';
|
|
3
3
|
import { FilterRule } from '../../table.type';
|
|
4
4
|
declare const useTableFilter: ({ filter, schema }: TableFilterProps) => {
|
|
5
|
-
isOpen: boolean;
|
|
6
5
|
selectedColumn: string | null;
|
|
7
6
|
setSelectedColumn: React.Dispatch<React.SetStateAction<string | null>>;
|
|
8
7
|
getFilterForColumn: (columnKey: string) => FilterRule | undefined;
|
|
9
8
|
hasFilterForColumn: (columnKey: string) => boolean;
|
|
9
|
+
hasAppliedFilterForColumn: (columnKey: string) => boolean;
|
|
10
10
|
updateColumnFilter: (columnKey: string, condition?: string, value?: string | string[]) => void;
|
|
11
11
|
clearAllFilters: () => void;
|
|
12
12
|
applyFilters: () => void;
|
|
13
13
|
hasActiveFilters: boolean;
|
|
14
|
-
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
15
14
|
tempFilters: FilterRule[];
|
|
16
15
|
filterableFields: import('../../table.type').TableSchemaColumn[];
|
|
17
16
|
};
|
|
@@ -1,54 +1,56 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
const [
|
|
4
|
-
|
|
5
|
-
!i &&
|
|
6
|
-
}, [i,
|
|
7
|
-
const
|
|
8
|
-
const e =
|
|
1
|
+
import u from "react";
|
|
2
|
+
const S = ({ filter: l, schema: v }) => {
|
|
3
|
+
const [i, f] = u.useState(null), [r, n] = u.useState(l.value), a = v.filter((t) => t.filterable !== !1);
|
|
4
|
+
u.useEffect(() => {
|
|
5
|
+
!i && a.length > 0 && f(a[0].key);
|
|
6
|
+
}, [i, a]);
|
|
7
|
+
const c = (t) => r.find((e) => e.field === t), p = (t) => {
|
|
8
|
+
const e = c(t);
|
|
9
9
|
return e ? Array.isArray(e.value) ? e.value.length > 0 : e.value !== "" : !1;
|
|
10
|
-
},
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
}, m = (t) => l.value.find((e) => e.field === t), A = (t) => {
|
|
11
|
+
const e = m(t);
|
|
12
|
+
return e ? Array.isArray(e.value) ? e.value.length > 0 : e.value !== "" : !1;
|
|
13
|
+
}, g = (t, e, o) => {
|
|
14
|
+
const d = r.findIndex((s) => s.field === t);
|
|
15
|
+
if (d >= 0) {
|
|
16
|
+
const s = r.map(
|
|
17
|
+
(F, x) => x === d ? {
|
|
18
|
+
...F,
|
|
16
19
|
...e !== void 0 ? { condition: e } : {},
|
|
17
|
-
...
|
|
18
|
-
} :
|
|
20
|
+
...o !== void 0 ? { value: o } : {}
|
|
21
|
+
} : F
|
|
19
22
|
);
|
|
20
|
-
n(
|
|
23
|
+
n(s);
|
|
21
24
|
} else {
|
|
22
|
-
const
|
|
25
|
+
const s = {
|
|
23
26
|
field: t,
|
|
24
27
|
...e ? { condition: e } : {},
|
|
25
|
-
value:
|
|
28
|
+
value: o || ""
|
|
26
29
|
};
|
|
27
|
-
n([...
|
|
30
|
+
n([...r, s]);
|
|
28
31
|
}
|
|
29
|
-
},
|
|
32
|
+
}, h = () => {
|
|
30
33
|
n([]);
|
|
31
34
|
}, C = () => {
|
|
32
|
-
const t =
|
|
33
|
-
|
|
34
|
-
}, y =
|
|
35
|
-
return
|
|
36
|
-
n(
|
|
37
|
-
}, [
|
|
38
|
-
isOpen: m,
|
|
35
|
+
const t = r.filter((e) => Array.isArray(e.value) ? e.value.length > 0 : e.value !== "");
|
|
36
|
+
l.onChange(t);
|
|
37
|
+
}, y = l.value.length > 0;
|
|
38
|
+
return u.useEffect(() => {
|
|
39
|
+
n(l.value);
|
|
40
|
+
}, [l.value]), {
|
|
39
41
|
selectedColumn: i,
|
|
40
|
-
setSelectedColumn:
|
|
41
|
-
getFilterForColumn:
|
|
42
|
-
hasFilterForColumn:
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
setSelectedColumn: f,
|
|
43
|
+
getFilterForColumn: c,
|
|
44
|
+
hasFilterForColumn: p,
|
|
45
|
+
hasAppliedFilterForColumn: A,
|
|
46
|
+
updateColumnFilter: g,
|
|
47
|
+
clearAllFilters: h,
|
|
45
48
|
applyFilters: C,
|
|
46
49
|
hasActiveFilters: y,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
filterableFields: u
|
|
50
|
+
tempFilters: r,
|
|
51
|
+
filterableFields: a
|
|
50
52
|
};
|
|
51
53
|
};
|
|
52
54
|
export {
|
|
53
|
-
|
|
55
|
+
S as default
|
|
54
56
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { Table as default, Table, TableProvider } from './table-provider';
|
|
2
2
|
export { TableBody } from './table';
|
|
3
3
|
export type { TableProps, TableSchema, TableSchemaColumn, CellType, CellValue, CellRenderer, CellRendererProps, FilterRule, FilterCondition, FilterOption, TableFilter as TableFilterType, TablePaginationConfig, SortDirection, SortColumn, TableSort, } from './table.type';
|
|
4
|
-
export {
|
|
4
|
+
export { extractCellValue } from './table.utils';
|
|
5
5
|
export { DEFAULT_EMPTY_MESSAGE, TABLE_CSS_CLASSES } from './table.const';
|
|
6
6
|
export { TableContext, useTableContext } from './table.context';
|
|
7
7
|
export { TableCell, TableHeader, TableRow, TableEmptyState, TableLoadingState, TablePagination, TextCell, NumberCell, BooleanCell, TableHeaderWrapper, TableHeaderContent, TableFooter, TableFooterContent, } from './components';
|
|
8
|
-
export { TableFilter } from './components/table-filter';
|
|
9
8
|
export { PaginationInfo, PaginationQuickJumper } from './components/pagination/components';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableProps } from './table.type';
|
|
2
2
|
import { TableBody } from './table';
|
|
3
|
-
import { TableFilter } from './components/table-filter';
|
|
3
|
+
import { TableFilter } from './components/table-filter/table-filter-provider';
|
|
4
4
|
import { TableSearch } from './components/table-search';
|
|
5
5
|
import { Pagination } from './components/pagination';
|
|
6
6
|
import { TableHeaderWrapper, TableHeaderContent, TableFooter, TableFooterContent } from './components';
|
|
@@ -2,17 +2,17 @@ import { jsx as a } from "react/jsx-runtime";
|
|
|
2
2
|
import * as n from "react";
|
|
3
3
|
import { TableContext as m } from "./table.context.js";
|
|
4
4
|
import { TableBody as p } from "./table.js";
|
|
5
|
-
import { TableFilter as f } from "./components/table-filter/table-filter.js";
|
|
5
|
+
import { TableFilter as f } from "./components/table-filter/table-filter-provider.js";
|
|
6
6
|
import { TableSearch as l } from "./components/table-search/table-search.js";
|
|
7
7
|
import { Pagination as s } from "./components/pagination/pagination.js";
|
|
8
|
+
import { PaginationInfo as T } from "./components/pagination/components/pagination-info.js";
|
|
9
|
+
import { PaginationQuickJumper as b } from "./components/pagination/components/pagination-quick-jumper.js";
|
|
8
10
|
import "clsx";
|
|
9
11
|
import "tailwind-merge";
|
|
10
|
-
import { TableHeaderWrapper as
|
|
11
|
-
import { TableHeaderContent as
|
|
12
|
-
import { TableFooter as
|
|
13
|
-
import { TableFooterContent as
|
|
14
|
-
import { PaginationInfo as u } from "./components/pagination/components/pagination-info.js";
|
|
15
|
-
import { PaginationQuickJumper as g } from "./components/pagination/components/pagination-quick-jumper.js";
|
|
12
|
+
import { TableHeaderWrapper as c } from "./components/table-header-wrapper.js";
|
|
13
|
+
import { TableHeaderContent as d } from "./components/table-header-content.js";
|
|
14
|
+
import { TableFooter as u } from "./components/table-footer.js";
|
|
15
|
+
import { TableFooterContent as g } from "./components/table-footer-content.js";
|
|
16
16
|
const t = ({
|
|
17
17
|
children: e,
|
|
18
18
|
pagination: C,
|
|
@@ -33,13 +33,13 @@ o.Body = p;
|
|
|
33
33
|
o.Filter = f;
|
|
34
34
|
o.Search = l;
|
|
35
35
|
o.Pagination = s;
|
|
36
|
-
o.PaginationInfo =
|
|
37
|
-
o.PaginationQuickJumper =
|
|
36
|
+
o.PaginationInfo = T;
|
|
37
|
+
o.PaginationQuickJumper = b;
|
|
38
38
|
o.Provider = t;
|
|
39
|
-
o.Header =
|
|
40
|
-
o.HeaderContent =
|
|
41
|
-
o.Footer =
|
|
42
|
-
o.FooterContent =
|
|
39
|
+
o.Header = c;
|
|
40
|
+
o.HeaderContent = d;
|
|
41
|
+
o.Footer = u;
|
|
42
|
+
o.FooterContent = g;
|
|
43
43
|
export {
|
|
44
44
|
o as Table,
|
|
45
45
|
t as TableProvider,
|
|
@@ -17,6 +17,7 @@ export type FilterRule = {
|
|
|
17
17
|
export type FilterOption = {
|
|
18
18
|
label: string;
|
|
19
19
|
value: string;
|
|
20
|
+
total?: number;
|
|
20
21
|
};
|
|
21
22
|
export type TableFilter = {
|
|
22
23
|
value: FilterRule[];
|
|
@@ -47,6 +48,7 @@ export type TableSort = {
|
|
|
47
48
|
};
|
|
48
49
|
export type TableSchemaColumn = {
|
|
49
50
|
key: string;
|
|
51
|
+
valueGetter?: (record: Record<string, any>) => string | number | boolean | null | undefined;
|
|
50
52
|
title: string;
|
|
51
53
|
cellType: CellType;
|
|
52
54
|
cellRenderer?: CellRenderer;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { CellValue, TableSchemaColumn } from './table.type';
|
|
2
|
-
export declare const getNestedValue: (object: Record<string, unknown>, path: string) => CellValue;
|
|
3
2
|
export declare const extractCellValue: (record: Record<string, unknown>, column: TableSchemaColumn) => CellValue;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = (t, e) => {
|
|
2
|
+
var r;
|
|
3
|
+
return e.valueGetter ? e.valueGetter(t) : (r = t[e.key]) == null ? void 0 : r.toString();
|
|
4
|
+
};
|
|
2
5
|
export {
|
|
3
|
-
|
|
4
|
-
s as getNestedValue
|
|
6
|
+
a as extractCellValue
|
|
5
7
|
};
|