@ztwoint/z-ui 0.1.45 → 0.1.47
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/assets/icons/check.d.ts +8 -0
- package/dist/components/assets/icons/check.js +17 -0
- package/dist/components/assets/icons/x-mark.d.ts +8 -0
- package/dist/components/assets/icons/x-mark.js +17 -0
- package/dist/components/table/components/cell/avatar-cell.d.ts +15 -0
- package/dist/components/table/components/cell/avatar-cell.js +74 -0
- package/dist/components/table/components/cell/boolean-cell.d.ts +1 -2
- package/dist/components/table/components/cell/boolean-cell.js +5 -5
- package/dist/components/table/components/cell/description-cell.d.ts +7 -0
- package/dist/components/table/components/cell/description-cell.js +16 -0
- package/dist/components/table/components/cell/index.d.ts +10 -1
- package/dist/components/table/components/cell/label-cell.d.ts +10 -0
- package/dist/components/table/components/cell/label-cell.js +47 -0
- package/dist/components/table/components/cell/link-cell.d.ts +10 -0
- package/dist/components/table/components/cell/link-cell.js +35 -0
- package/dist/components/table/components/cell/number-cell.d.ts +5 -3
- package/dist/components/table/components/cell/number-cell.js +40 -3
- package/dist/components/table/components/index.d.ts +1 -1
- 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-cell.d.ts +1 -1
- package/dist/components/table/components/table-cell.js +41 -32
- package/dist/components/table/components/table-filter/filters/boolean.js +52 -44
- 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 +113 -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 +79 -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/components/table-header/stories/basic-header.d.ts +1 -1
- package/dist/components/table/components/table-header/table-header.js +10 -10
- package/dist/components/table/index.d.ts +2 -3
- package/dist/components/table/table-provider.d.ts +1 -1
- package/dist/components/table/table-provider.js +50 -21
- package/dist/components/table/table.const.d.ts +10 -8
- package/dist/components/table/table.const.js +10 -8
- package/dist/components/table/table.js +1 -7
- package/dist/components/table/table.type.d.ts +37 -4
- package/dist/components/table/table.utils.d.ts +1 -2
- package/dist/components/table/table.utils.js +7 -3
- package/dist/components/table-card/table-card.js +113 -81
- 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.js +106 -111
- package/dist/types/components/assets/icons/check.d.ts +8 -0
- package/dist/types/components/assets/icons/x-mark.d.ts +8 -0
- package/dist/types/components/table/components/cell/avatar-cell.d.ts +15 -0
- package/dist/types/components/table/components/cell/boolean-cell.d.ts +1 -2
- package/dist/types/components/table/components/cell/description-cell.d.ts +7 -0
- package/dist/types/components/table/components/cell/index.d.ts +10 -1
- package/dist/types/components/table/components/cell/label-cell.d.ts +10 -0
- package/dist/types/components/table/components/cell/link-cell.d.ts +10 -0
- package/dist/types/components/table/components/cell/number-cell.d.ts +5 -3
- package/dist/types/components/table/components/index.d.ts +1 -1
- 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-cell.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/components/table-header/stories/basic-header.d.ts +1 -1
- package/dist/types/components/table/index.d.ts +2 -3
- package/dist/types/components/table/table-provider.d.ts +1 -1
- package/dist/types/components/table/table.const.d.ts +10 -8
- package/dist/types/components/table/table.type.d.ts +37 -4
- package/dist/types/components/table/table.utils.d.ts +1 -2
- package/dist/types/components/table-card/table-card.type.d.ts +7 -7
- package/dist/types/hooks/useClickOutside.d.ts +1 -0
- package/package.json +2 -1
- package/dist/components/table/components/cell/text-cell.d.ts +0 -7
- package/dist/components/table/components/cell/text-cell.js +0 -5
- 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/node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js +0 -26
- package/dist/node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js +0 -26
- package/dist/types/components/table/components/cell/text-cell.d.ts +0 -7
- package/dist/types/components/table/components/table-filter/table-filter.d.ts +0 -9
|
@@ -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,3 +1,3 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react';
|
|
2
|
-
export declare const basicHeaderUsageCode = "import { Table, TableHeader } from '@/components/table';\n\nconst schema = [\n {\n key: 'id',\n title: 'ID',\n cellType: 'number',\n sortable: true,\n },\n {\n key: 'name',\n title: 'Name',\n cellType: '
|
|
2
|
+
export declare const basicHeaderUsageCode = "import { Table, TableHeader } from '@/components/table';\n\nconst schema = [\n {\n key: 'id',\n title: 'ID',\n cellType: 'number',\n sortable: true,\n },\n {\n key: 'name',\n title: 'Name',\n cellType: 'label',\n sortable: true,\n },\n];\n\nconst data = [\n { id: 1, name: 'John Doe' },\n { id: 2, name: 'Jane Smith' },\n];\n\nfunction MyTable() {\n return (\n <Table dataSource={data} schema={schema}>\n <table className=\"w-full\">\n <TableHeader \n schema={schema}\n cell={{ hasBorder: true }}\n />\n {/* Table body goes here */}\n </table>\n </Table>\n );\n}";
|
|
3
3
|
export declare const BasicHeader: StoryObj;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { jsx as r, jsxs as c } from "react/jsx-runtime";
|
|
2
2
|
import { TABLE_CSS_CLASSES as t } from "../../table.const.js";
|
|
3
|
-
import { TableSortIcon as
|
|
4
|
-
import { getCurrentSortDirection as
|
|
3
|
+
import { TableSortIcon as h } from "./table-sort-icon.js";
|
|
4
|
+
import { getCurrentSortDirection as n, isSortActive as p, handleSortClick as C } from "./table-header.utils.js";
|
|
5
5
|
import "react";
|
|
6
6
|
import { cn as S } from "../../../../lib/utils.js";
|
|
7
7
|
const x = ({
|
|
8
|
-
schema:
|
|
9
|
-
sort:
|
|
8
|
+
schema: i,
|
|
9
|
+
sort: a,
|
|
10
10
|
cell: o,
|
|
11
11
|
stickyHeader: s = !1
|
|
12
12
|
}) => /* @__PURE__ */ r(
|
|
13
13
|
"thead",
|
|
14
14
|
{
|
|
15
15
|
className: `${t.header} ${s ? "sticky top-[-1.5px] z-1" : ""}`,
|
|
16
|
-
children: /* @__PURE__ */ r("tr", { children:
|
|
17
|
-
const l =
|
|
16
|
+
children: /* @__PURE__ */ r("tr", { children: i.map((e) => {
|
|
17
|
+
const l = n(e.key, a), d = p(e.key, a);
|
|
18
18
|
return /* @__PURE__ */ r(
|
|
19
19
|
"th",
|
|
20
20
|
{
|
|
21
21
|
className: S(
|
|
22
|
-
e.sortable ? t.sortableHeaderCell : t.headerCell,
|
|
23
|
-
t.
|
|
22
|
+
e.sortable ? t.sortableHeaderCell : t.headerCell.default,
|
|
23
|
+
t.headerCell.hasBorder[o.hasBorder ? "true" : "false"]
|
|
24
24
|
),
|
|
25
|
-
onClick: e.sortable ? () => C(e.key,
|
|
25
|
+
onClick: e.sortable ? () => C(e.key, a) : void 0,
|
|
26
26
|
children: /* @__PURE__ */ c("div", { className: t.headerCellContent, children: [
|
|
27
27
|
/* @__PURE__ */ r("span", { children: e.title }),
|
|
28
|
-
e.sortable && /* @__PURE__ */ r(
|
|
28
|
+
e.sortable && /* @__PURE__ */ r(h, { direction: l, isActive: d })
|
|
29
29
|
] })
|
|
30
30
|
},
|
|
31
31
|
e.key
|
|
@@ -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
|
-
export { TableCell, TableHeader, TableRow, TableEmptyState, TableLoadingState, TablePagination,
|
|
8
|
-
export { TableFilter } from './components/table-filter';
|
|
7
|
+
export { TableCell, TableHeader, TableRow, TableEmptyState, TableLoadingState, TablePagination, NumberCell, BooleanCell, TableHeaderWrapper, TableHeaderContent, TableFooter, TableFooterContent, } from './components';
|
|
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';
|
|
@@ -1,45 +1,74 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { TableContext as
|
|
4
|
-
import { TableBody as
|
|
5
|
-
import { TableFilter as f } from "./components/table-filter/table-filter.js";
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import * as p from "react";
|
|
3
|
+
import { TableContext as a } from "./table.context.js";
|
|
4
|
+
import { TableBody as n } from "./table.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
|
-
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
12
|
+
/* empty css */
|
|
13
|
+
import "../alert/alert.const.js";
|
|
14
|
+
import "../button/button.js";
|
|
15
|
+
import "../collapsible-side-nav-bar/side-nav-bar-provider.js";
|
|
16
|
+
import "../collapsible-side-nav-bar/side-nav-bar.js";
|
|
17
|
+
import "../collapsible-side-nav-bar/side-nav-bar-header.js";
|
|
18
|
+
import "../collapsible-side-nav-bar/side-nav-bar-content.js";
|
|
19
|
+
import "../collapsible-side-nav-bar/side-nav-bar-footer.js";
|
|
20
|
+
import "../collapsible-side-nav-bar/side-nav-bar-group.js";
|
|
21
|
+
import "../collapsible-side-nav-bar/side-nav-bar-item.js";
|
|
22
|
+
import "../collapsible-side-nav-bar/side-nav-bar-separator.js";
|
|
23
|
+
import "../collapsible-side-nav-bar/context.js";
|
|
24
|
+
import "../collapsible-side-nav-bar/popover/popover.js";
|
|
25
|
+
import "react-country-flag";
|
|
26
|
+
import "classnames";
|
|
27
|
+
import "@radix-ui/react-dialog";
|
|
28
|
+
import "../dropdown/z2-dropdown.js";
|
|
29
|
+
import "@radix-ui/react-dropdown-menu";
|
|
30
|
+
import "lucide-react";
|
|
31
|
+
import "../input/input.js";
|
|
32
|
+
import "../nav-header/nav-header.js";
|
|
33
|
+
import "../nav-header/nav-item/nav-item.js";
|
|
34
|
+
import "@radix-ui/react-select";
|
|
35
|
+
import "../stepper/stepper.js";
|
|
36
|
+
import "../stepper-item/stepper-item.js";
|
|
37
|
+
import "@radix-ui/react-tabs";
|
|
38
|
+
import "../tooltip/tooltip.js";
|
|
39
|
+
import "../badge/badge.js";
|
|
40
|
+
import "../avatar/avatar.js";
|
|
41
|
+
import { TableHeaderWrapper as c } from "./components/table-header-wrapper.js";
|
|
42
|
+
import { TableHeaderContent as d } from "./components/table-header-content.js";
|
|
43
|
+
import { TableFooter as u } from "./components/table-footer.js";
|
|
44
|
+
import { TableFooterContent as g } from "./components/table-footer-content.js";
|
|
16
45
|
const t = ({
|
|
17
|
-
children:
|
|
46
|
+
children: i,
|
|
18
47
|
pagination: C,
|
|
19
48
|
sort: F,
|
|
20
49
|
filter: v,
|
|
21
50
|
filterComponents: x,
|
|
22
51
|
...r
|
|
23
52
|
}) => {
|
|
24
|
-
const
|
|
53
|
+
const m = p.useMemo(
|
|
25
54
|
() => ({
|
|
26
55
|
...r
|
|
27
56
|
}),
|
|
28
57
|
[r]
|
|
29
58
|
);
|
|
30
|
-
return /* @__PURE__ */ a
|
|
59
|
+
return /* @__PURE__ */ e(a.Provider, { value: m, children: i });
|
|
31
60
|
}, P = t, o = P;
|
|
32
|
-
o.Body =
|
|
61
|
+
o.Body = n;
|
|
33
62
|
o.Filter = f;
|
|
34
63
|
o.Search = l;
|
|
35
64
|
o.Pagination = s;
|
|
36
|
-
o.PaginationInfo =
|
|
37
|
-
o.PaginationQuickJumper =
|
|
65
|
+
o.PaginationInfo = T;
|
|
66
|
+
o.PaginationQuickJumper = b;
|
|
38
67
|
o.Provider = t;
|
|
39
|
-
o.Header =
|
|
40
|
-
o.HeaderContent =
|
|
41
|
-
o.Footer =
|
|
42
|
-
o.FooterContent =
|
|
68
|
+
o.Header = c;
|
|
69
|
+
o.HeaderContent = d;
|
|
70
|
+
o.Footer = u;
|
|
71
|
+
o.FooterContent = g;
|
|
43
72
|
export {
|
|
44
73
|
o as Table,
|
|
45
74
|
t as TableProvider,
|
|
@@ -3,22 +3,24 @@ export declare const TABLE_CSS_CLASSES: {
|
|
|
3
3
|
readonly table: "w-full";
|
|
4
4
|
readonly header: "bg-background-neutral-medium text-text-neutral-secondary";
|
|
5
5
|
readonly cell: {
|
|
6
|
-
readonly default: "
|
|
7
|
-
readonly cellHeight: {
|
|
8
|
-
readonly small: "p-3";
|
|
9
|
-
readonly large: "p-4";
|
|
10
|
-
};
|
|
6
|
+
readonly default: "p-0 align-middle relative h-4";
|
|
11
7
|
readonly hasBorder: {
|
|
12
|
-
readonly true: "border border-stroke-solid-light";
|
|
8
|
+
readonly true: "border-r border-b border-stroke-solid-light";
|
|
13
9
|
readonly false: "border-b border-stroke-solid-light";
|
|
14
10
|
};
|
|
15
11
|
};
|
|
16
|
-
readonly headerCell:
|
|
12
|
+
readonly headerCell: {
|
|
13
|
+
readonly default: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wider";
|
|
14
|
+
readonly hasBorder: {
|
|
15
|
+
readonly true: "border-none [box-shadow:inset_-1px_0_0_0_var(--color-stroke-solid-light),_inset_0_-1px_0_0_var(--color-stroke-solid-light)]";
|
|
16
|
+
readonly false: "border-none [box-shadow:inset_0_-1px_0_0_var(--color-stroke-solid-light)]";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
17
19
|
readonly sortableHeaderCell: "p-3 text-left text-xs font-medium uppercase tracking-wider cursor-pointer transition-colors duration-200";
|
|
18
20
|
readonly headerCellContent: "flex items-center justify-between";
|
|
19
21
|
readonly sortIcon: "ml-2 w-4 h-4 text-gray-400";
|
|
20
22
|
readonly sortIconActive: "ml-2 w-4 h-4 text-gray-600";
|
|
21
|
-
readonly row: "
|
|
23
|
+
readonly row: " transition-colors duration-200 text-text-neutral-primary";
|
|
22
24
|
readonly emptyState: "px-4 py-8 text-center text-gray-500";
|
|
23
25
|
readonly loading: "px-4 py-8 text-center text-gray-500";
|
|
24
26
|
};
|
|
@@ -2,22 +2,24 @@ const e = "No data available", t = {
|
|
|
2
2
|
table: "w-full",
|
|
3
3
|
header: "bg-background-neutral-medium text-text-neutral-secondary",
|
|
4
4
|
cell: {
|
|
5
|
-
default: "
|
|
6
|
-
cellHeight: {
|
|
7
|
-
small: "p-3",
|
|
8
|
-
large: "p-4"
|
|
9
|
-
},
|
|
5
|
+
default: "p-0 align-middle relative h-4",
|
|
10
6
|
hasBorder: {
|
|
11
|
-
true: "border border-stroke-solid-light",
|
|
7
|
+
true: "border-r border-b border-stroke-solid-light",
|
|
12
8
|
false: "border-b border-stroke-solid-light"
|
|
13
9
|
}
|
|
14
10
|
},
|
|
15
|
-
headerCell:
|
|
11
|
+
headerCell: {
|
|
12
|
+
default: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wider",
|
|
13
|
+
hasBorder: {
|
|
14
|
+
true: "border-none [box-shadow:inset_-1px_0_0_0_var(--color-stroke-solid-light),_inset_0_-1px_0_0_var(--color-stroke-solid-light)]",
|
|
15
|
+
false: "border-none [box-shadow:inset_0_-1px_0_0_var(--color-stroke-solid-light)]"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
16
18
|
sortableHeaderCell: "p-3 text-left text-xs font-medium uppercase tracking-wider cursor-pointer transition-colors duration-200",
|
|
17
19
|
headerCellContent: "flex items-center justify-between",
|
|
18
20
|
sortIcon: "ml-2 w-4 h-4 text-gray-400",
|
|
19
21
|
sortIconActive: "ml-2 w-4 h-4 text-gray-600",
|
|
20
|
-
row: "
|
|
22
|
+
row: " transition-colors duration-200 text-text-neutral-primary",
|
|
21
23
|
emptyState: "px-4 py-8 text-center text-gray-500",
|
|
22
24
|
loading: "px-4 py-8 text-center text-gray-500"
|
|
23
25
|
};
|
|
@@ -6,13 +6,7 @@ import { TableRow as E } from "./components/table-row.js";
|
|
|
6
6
|
import { TableEmptyState as y } from "./components/table-empty-state.js";
|
|
7
7
|
import { TableLoadingState as x } from "./components/table-loading-state.js";
|
|
8
8
|
import { TableContext as C } from "./table.context.js";
|
|
9
|
-
const w = ({
|
|
10
|
-
cell: r = { cellHeight: "small", hasBorder: !0 },
|
|
11
|
-
sort: l,
|
|
12
|
-
className: m,
|
|
13
|
-
stickyHeader: s = !1,
|
|
14
|
-
...n
|
|
15
|
-
}) => {
|
|
9
|
+
const w = ({ cell: r = { hasBorder: !0 }, sort: l, className: m, stickyHeader: s = !1, ...n }) => {
|
|
16
10
|
const c = u.useContext(C), {
|
|
17
11
|
dataSource: o = [],
|
|
18
12
|
schema: t = [],
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { FilterComponentType } from './components/table-filter/table-filter.type';
|
|
3
|
-
|
|
3
|
+
import { NumberCellProps } from './components/cell/number-cell';
|
|
4
|
+
import { BooleanCellProps } from './components/cell/boolean-cell';
|
|
5
|
+
import { LinkCellProps } from './components/cell/link-cell';
|
|
6
|
+
import { AvatarCellProps } from './components/cell/avatar-cell';
|
|
7
|
+
import { LabelCellProps } from './components/cell/label-cell';
|
|
8
|
+
import { DescriptionCellProps } from './components/cell/description-cell';
|
|
9
|
+
export type CellType = 'number' | 'boolean' | 'checkbox' | 'link' | 'avatar' | 'label' | 'description' | 'text';
|
|
4
10
|
export type CellValue = string | number | boolean | null | undefined;
|
|
5
11
|
export type CellRendererProps = {
|
|
6
12
|
value: CellValue;
|
|
@@ -17,6 +23,7 @@ export type FilterRule = {
|
|
|
17
23
|
export type FilterOption = {
|
|
18
24
|
label: string;
|
|
19
25
|
value: string;
|
|
26
|
+
total?: number;
|
|
20
27
|
};
|
|
21
28
|
export type TableFilter = {
|
|
22
29
|
value: FilterRule[];
|
|
@@ -45,21 +52,46 @@ export type TableSort = {
|
|
|
45
52
|
sortedColumns: SortColumn[];
|
|
46
53
|
onSort: (field: string, direction: SortDirection) => void;
|
|
47
54
|
};
|
|
48
|
-
|
|
55
|
+
type CellPropsByType = {
|
|
56
|
+
number: Omit<NumberCellProps, 'value'>;
|
|
57
|
+
boolean: Omit<BooleanCellProps, 'value'>;
|
|
58
|
+
checkbox: Omit<BooleanCellProps, 'value'>;
|
|
59
|
+
link: Omit<LinkCellProps, 'value' | 'href'> & {
|
|
60
|
+
href: string;
|
|
61
|
+
};
|
|
62
|
+
avatar: Omit<AvatarCellProps, 'value'>;
|
|
63
|
+
label: Omit<LabelCellProps, 'value'>;
|
|
64
|
+
description: Omit<DescriptionCellProps, 'value'>;
|
|
65
|
+
};
|
|
66
|
+
type ColumnBase<T extends CellType> = {
|
|
49
67
|
key: string;
|
|
50
68
|
title: string;
|
|
51
|
-
cellType:
|
|
69
|
+
cellType: T;
|
|
52
70
|
cellRenderer?: CellRenderer;
|
|
53
71
|
filterable?: boolean;
|
|
54
72
|
hideable?: boolean;
|
|
55
73
|
sortable?: boolean;
|
|
56
74
|
filterOptions?: FilterOption[];
|
|
57
75
|
};
|
|
76
|
+
export type TableSchemaColumn = (ColumnBase<'number'> & {
|
|
77
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['number'];
|
|
78
|
+
}) | (ColumnBase<'boolean'> & {
|
|
79
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['boolean'];
|
|
80
|
+
}) | (ColumnBase<'checkbox'> & {
|
|
81
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['checkbox'];
|
|
82
|
+
}) | (ColumnBase<'link'> & {
|
|
83
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['link'];
|
|
84
|
+
}) | (ColumnBase<'avatar'> & {
|
|
85
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['avatar'];
|
|
86
|
+
}) | (ColumnBase<'label'> & {
|
|
87
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['label'];
|
|
88
|
+
}) | (ColumnBase<'description'> & {
|
|
89
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellPropsByType['description'];
|
|
90
|
+
});
|
|
58
91
|
export type TableSchema = TableSchemaColumn[];
|
|
59
92
|
export type TableProps = {
|
|
60
93
|
cell?: {
|
|
61
94
|
hasBorder?: boolean;
|
|
62
|
-
cellHeight?: 'small' | 'large';
|
|
63
95
|
};
|
|
64
96
|
dataSource: Record<string, unknown>[];
|
|
65
97
|
schema: TableSchema;
|
|
@@ -71,3 +103,4 @@ export type TableProps = {
|
|
|
71
103
|
sort?: TableSort;
|
|
72
104
|
customCells?: Record<string, CellRenderer>;
|
|
73
105
|
};
|
|
106
|
+
export {};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { CellValue, TableSchemaColumn } from './table.type';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const extractCellValue: (record: Record<string, unknown>, column: TableSchemaColumn) => CellValue;
|
|
2
|
+
export declare const extractCellValue: (record: Record<string, unknown>, column: TableSchemaColumn) => CellValue | Record<string, unknown>;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = (r, e) => {
|
|
2
|
+
if (e.valueGetter)
|
|
3
|
+
return e.valueGetter(r);
|
|
4
|
+
const t = r[e.key];
|
|
5
|
+
return t != null ? t ?? void 0 : void 0;
|
|
6
|
+
};
|
|
2
7
|
export {
|
|
3
|
-
|
|
4
|
-
s as getNestedValue
|
|
8
|
+
a as extractCellValue
|
|
5
9
|
};
|