@ztwoint/z-ui 0.1.27 → 0.1.28
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/chevron-left.d.ts +7 -0
- package/dist/components/assets/icons/chevron-left.js +20 -0
- package/dist/components/assets/icons/chevron-right.js +30 -0
- package/dist/components/assets/icons/double-chevron-left.d.ts +7 -0
- package/dist/components/assets/icons/double-chevron-left.js +24 -0
- package/dist/components/assets/icons/double-chevron-right.d.ts +7 -0
- package/dist/components/assets/icons/double-chevron-right.js +24 -0
- package/dist/components/assets/icons/info-icon.js +16 -0
- package/dist/components/assets/icons/magnifier-icon.js +16 -0
- package/dist/components/assets/icons/sub-nav-indicator.d.ts +3 -2
- package/dist/components/assets/icons/sub-nav-indicator.js +26 -41
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +45 -30
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-content.js +16 -16
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-footer.js +1 -1
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-group.js +24 -16
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-header.js +60 -54
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-item.js +61 -62
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-provider.js +23 -23
- package/dist/components/collapsible-side-nav-bar/side-nav-bar.d.ts +1 -1
- package/dist/components/collapsible-side-nav-bar/side-nav-bar.js +14 -14
- package/dist/components/dialog/dialog.js +1 -1
- package/dist/components/dropdown-menu/z2-dropdown-menu.js +255 -0
- package/dist/components/nav-header/nav-header.js +7 -7
- package/dist/components/table/components/cell/boolean-cell.d.ts +7 -0
- package/dist/components/table/components/cell/boolean-cell.js +7 -0
- package/dist/components/table/components/cell/index.d.ts +3 -0
- package/dist/components/table/components/cell/number-cell.d.ts +7 -0
- package/dist/components/table/components/cell/number-cell.js +5 -0
- package/dist/components/table/components/cell/text-cell.d.ts +7 -0
- package/dist/components/table/components/cell/text-cell.js +5 -0
- package/dist/components/table/components/index.d.ts +11 -0
- package/dist/components/table/components/pagination/components/index.d.ts +3 -0
- package/dist/components/table/components/pagination/components/pagination-info.d.ts +4 -0
- package/dist/components/table/components/pagination/components/pagination-info.js +27 -0
- package/dist/components/table/components/pagination/components/pagination-quick-jumper.d.ts +4 -0
- package/dist/components/table/components/pagination/components/pagination-quick-jumper.hook.d.ts +6 -0
- package/dist/components/table/components/pagination/components/pagination-quick-jumper.hook.js +24 -0
- package/dist/components/table/components/pagination/components/pagination-quick-jumper.js +35 -0
- package/dist/components/table/components/pagination/index.d.ts +6 -0
- package/dist/components/table/components/pagination/pagination.const.d.ts +26 -0
- package/dist/components/table/components/pagination/pagination.const.js +22 -0
- package/dist/components/table/components/pagination/pagination.d.ts +4 -0
- package/dist/components/table/components/pagination/pagination.hook.d.ts +5 -0
- package/dist/components/table/components/pagination/pagination.hook.js +22 -0
- package/dist/components/table/components/pagination/pagination.js +112 -0
- package/dist/components/table/components/pagination/pagination.type.d.ts +33 -0
- package/dist/components/table/components/pagination/pagination.utils.d.ts +7 -0
- package/dist/components/table/components/pagination/pagination.utils.js +35 -0
- package/dist/components/table/components/table-cell.d.ts +15 -0
- package/dist/components/table/components/table-cell.js +45 -0
- package/dist/components/table/components/table-empty-state.d.ts +7 -0
- package/dist/components/table/components/table-empty-state.js +6 -0
- package/dist/components/table/components/table-filter/filters/boolean.d.ts +3 -0
- package/dist/components/table/components/table-filter/filters/boolean.js +31 -0
- package/dist/components/table/components/table-filter/filters/index.d.ts +3 -0
- package/dist/components/table/components/table-filter/filters/number.d.ts +3 -0
- package/dist/components/table/components/table-filter/filters/number.js +28 -0
- package/dist/components/table/components/table-filter/filters/text.d.ts +3 -0
- package/dist/components/table/components/table-filter/filters/text.js +28 -0
- package/dist/components/table/components/table-filter/index.d.ts +1 -0
- package/dist/components/table/components/table-filter/table-filter.d.ts +9 -0
- package/dist/components/table/components/table-filter/table-filter.hook.d.ts +15 -0
- package/dist/components/table/components/table-filter/table-filter.hook.js +34 -0
- package/dist/components/table/components/table-filter/table-filter.js +105 -0
- package/dist/components/table/components/table-filter/table-filter.type.d.ts +18 -0
- package/dist/components/table/components/table-footer-content.d.ts +7 -0
- package/dist/components/table/components/table-footer-content.js +9 -0
- package/dist/components/table/components/table-footer.d.ts +7 -0
- package/dist/components/table/components/table-footer.js +6 -0
- package/dist/components/table/components/table-header/index.d.ts +2 -0
- package/dist/components/table/components/table-header/table-header.d.ts +9 -0
- package/dist/components/table/components/table-header/table-header.js +27 -0
- package/dist/components/table/components/table-header/table-header.utils.d.ts +5 -0
- package/dist/components/table/components/table-header/table-header.utils.js +15 -0
- package/dist/components/table/components/table-header/table-sort-icon.d.ts +8 -0
- package/dist/components/table/components/table-header/table-sort-icon.js +13 -0
- package/dist/components/table/components/table-header-content.d.ts +7 -0
- package/dist/components/table/components/table-header-content.js +9 -0
- package/dist/components/table/components/table-header-wrapper.d.ts +7 -0
- package/dist/components/table/components/table-header-wrapper.js +9 -0
- package/dist/components/table/components/table-loading-state.d.ts +7 -0
- package/dist/components/table/components/table-loading-state.js +9 -0
- package/dist/components/table/components/table-row.d.ts +11 -0
- package/dist/components/table/components/table-row.js +23 -0
- package/dist/components/table/index.d.ts +9 -0
- package/dist/components/table/table-provider.d.ts +26 -0
- package/dist/components/table/table-provider.js +45 -0
- package/dist/components/table/table.const.d.ts +24 -0
- package/dist/components/table/table.const.js +27 -0
- package/dist/components/table/table.context.d.ts +7 -0
- package/dist/components/table/table.context.js +11 -0
- package/dist/components/table/table.d.ts +4 -0
- package/dist/components/table/table.js +39 -0
- package/dist/components/table/table.type.d.ts +63 -0
- package/dist/components/table/table.utils.d.ts +3 -0
- package/dist/components/table/table.utils.js +5 -0
- package/dist/css/config/colors/components/select.css +1 -1
- package/dist/css/config/colors/defaults.css +378 -137
- package/dist/css/config/colors/semantic-colors.css +356 -0
- package/dist/css/config/components/button.css +152 -0
- package/dist/css/config/components/index.css +1 -0
- package/dist/css/config/config-deprecated.css +41 -0
- package/dist/css/config/config.css +4 -18
- package/dist/css/config/typography/2xl.css +7 -0
- package/dist/css/config/typography/3xl.css +7 -0
- package/dist/css/config/typography/4xl.css +7 -0
- package/dist/css/config/typography/base.css +7 -0
- package/dist/css/config/typography/lg.css +7 -0
- package/dist/css/config/typography/sm.css +7 -0
- package/dist/css/config/typography/xl.css +7 -0
- package/dist/css/config/typography/xs.css +7 -0
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/devComponents/navigation/index.d.ts +1 -0
- package/dist/devComponents/navigation/navigation.d.ts +1 -0
- package/dist/index.d.ts +41 -8
- package/dist/index.js +176 -102
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/theme.hook.d.ts +8 -0
- package/dist/lib/theme.hook.js +50 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js +26 -0
- package/dist/routes/default.d.ts +2 -0
- package/dist/routes/index.d.ts +2 -0
- package/dist/routes/table.d.ts +2 -0
- package/dist/sample/text-cell.d.ts +3 -0
- package/dist/types/components/assets/icons/chevron-left.d.ts +7 -0
- package/dist/types/components/assets/icons/double-chevron-left.d.ts +7 -0
- package/dist/types/components/assets/icons/double-chevron-right.d.ts +7 -0
- package/dist/types/components/assets/icons/sub-nav-indicator.d.ts +3 -2
- package/dist/types/components/button/button.d.ts +1 -1
- package/dist/types/components/collapsible-side-nav-bar/side-nav-bar.d.ts +1 -1
- package/dist/types/components/table/components/cell/boolean-cell.d.ts +7 -0
- package/dist/types/components/table/components/cell/index.d.ts +3 -0
- package/dist/types/components/table/components/cell/number-cell.d.ts +7 -0
- package/dist/types/components/table/components/cell/text-cell.d.ts +7 -0
- package/dist/types/components/table/components/index.d.ts +11 -0
- package/dist/types/components/table/components/pagination/components/index.d.ts +3 -0
- package/dist/types/components/table/components/pagination/components/pagination-info.d.ts +4 -0
- package/dist/types/components/table/components/pagination/components/pagination-quick-jumper.d.ts +4 -0
- package/dist/types/components/table/components/pagination/components/pagination-quick-jumper.hook.d.ts +6 -0
- package/dist/types/components/table/components/pagination/index.d.ts +6 -0
- package/dist/types/components/table/components/pagination/pagination.const.d.ts +26 -0
- package/dist/types/components/table/components/pagination/pagination.d.ts +4 -0
- package/dist/types/components/table/components/pagination/pagination.hook.d.ts +5 -0
- package/dist/types/components/table/components/pagination/pagination.type.d.ts +33 -0
- package/dist/types/components/table/components/pagination/pagination.utils.d.ts +7 -0
- package/dist/types/components/table/components/table-cell.d.ts +15 -0
- package/dist/types/components/table/components/table-empty-state.d.ts +7 -0
- package/dist/types/components/table/components/table-filter/filters/boolean.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/filters/index.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/filters/number.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/filters/text.d.ts +3 -0
- package/dist/types/components/table/components/table-filter/index.d.ts +1 -0
- package/dist/types/components/table/components/table-filter/table-filter.d.ts +9 -0
- package/dist/types/components/table/components/table-filter/table-filter.hook.d.ts +15 -0
- package/dist/types/components/table/components/table-filter/table-filter.type.d.ts +18 -0
- package/dist/types/components/table/components/table-footer-content.d.ts +7 -0
- package/dist/types/components/table/components/table-footer.d.ts +7 -0
- package/dist/types/components/table/components/table-header/index.d.ts +2 -0
- package/dist/types/components/table/components/table-header/table-header.d.ts +10 -0
- package/dist/types/components/table/components/table-header/table-header.utils.d.ts +5 -0
- package/dist/types/components/table/components/table-header/table-sort-icon.d.ts +8 -0
- package/dist/types/components/table/components/table-header-content.d.ts +7 -0
- package/dist/types/components/table/components/table-header-wrapper.d.ts +7 -0
- package/dist/types/components/table/components/table-loading-state.d.ts +7 -0
- package/dist/types/components/table/components/table-row.d.ts +11 -0
- package/dist/types/components/table/index.d.ts +9 -0
- package/dist/types/components/table/table-provider.d.ts +26 -0
- package/dist/types/components/table/table.const.d.ts +24 -0
- package/dist/types/components/table/table.context.d.ts +7 -0
- package/dist/types/components/table/table.d.ts +4 -0
- package/dist/types/components/table/table.type.d.ts +63 -0
- package/dist/types/components/table/table.utils.d.ts +3 -0
- package/dist/types/devComponents/navigation/index.d.ts +1 -0
- package/dist/types/devComponents/navigation/navigation.d.ts +1 -0
- package/dist/types/index.d.ts +41 -8
- package/dist/types/lib/index.d.ts +3 -0
- package/dist/types/lib/theme.hook.d.ts +8 -0
- package/dist/types/routes/default.d.ts +2 -0
- package/dist/types/routes/index.d.ts +2 -0
- package/dist/types/routes/table.d.ts +2 -0
- package/dist/types/sample/text-cell.d.ts +3 -0
- package/package.json +3 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const i = (n, t) => {
|
|
2
|
+
if (!t) return null;
|
|
3
|
+
const e = t.sortedColumns.find((r) => r.field === n);
|
|
4
|
+
return (e == null ? void 0 : e.direction) || null;
|
|
5
|
+
}, o = (n) => n === null ? "asc" : n === "asc" ? "desc" : null, c = (n, t) => t ? t.sortedColumns.some((e) => e.field === n && e.direction !== null) : !1, u = (n, t) => {
|
|
6
|
+
if (!t) return;
|
|
7
|
+
const e = i(n, t), r = o(e);
|
|
8
|
+
t.onSort(n, r);
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
i as getCurrentSortDirection,
|
|
12
|
+
o as getNextSortDirection,
|
|
13
|
+
u as handleSortClick,
|
|
14
|
+
c as isSortActive
|
|
15
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as e, Fragment as a, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronUpIcon as n } from "../../../assets/icons/chevron-up-icon.js";
|
|
3
|
+
import o from "../../../assets/icons/chevron-down.js";
|
|
4
|
+
const f = ({ direction: r, isActive: s }) => {
|
|
5
|
+
const t = () => s ? "ml-2 w-4 h-4 text-gray-600" : "ml-2 w-4 h-4 text-gray-400";
|
|
6
|
+
return /* @__PURE__ */ e(a, { children: r === "asc" ? /* @__PURE__ */ e(n, { className: t() }) : r === "desc" ? /* @__PURE__ */ e(o, { className: t() }) : /* @__PURE__ */ c("div", { className: "ml-2 w-4 h-4 flex flex-col justify-center items-center", children: [
|
|
7
|
+
/* @__PURE__ */ e(n, { className: "w-3 h-2 text-gray-300" }),
|
|
8
|
+
/* @__PURE__ */ e(o, { className: "w-3 h-2 text-gray-300 -mt-1" })
|
|
9
|
+
] }) });
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
f as TableSortIcon
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { TABLE_CSS_CLASSES as d } from "../table.const.js";
|
|
3
|
+
const n = ({
|
|
4
|
+
colSpan: o,
|
|
5
|
+
message: t = "Loading..."
|
|
6
|
+
}) => /* @__PURE__ */ r("tbody", { children: /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", { colSpan: o, className: d.loading, children: t }) }) });
|
|
7
|
+
export {
|
|
8
|
+
n as TableLoadingState
|
|
9
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CellRenderer, TableProps, TableSchemaColumn } from '../table.type';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
interface TableRowProps {
|
|
4
|
+
record: Record<string, unknown>;
|
|
5
|
+
index: number;
|
|
6
|
+
schema: TableSchemaColumn[];
|
|
7
|
+
customCells?: Record<string, CellRenderer>;
|
|
8
|
+
cell: TableProps['cell'];
|
|
9
|
+
}
|
|
10
|
+
export declare const TableRow: React.FC<TableRowProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { extractCellValue as c } from "../table.utils.js";
|
|
3
|
+
import { TABLE_CSS_CLASSES as i } from "../table.const.js";
|
|
4
|
+
import { TableCell as s } from "./table-cell.js";
|
|
5
|
+
const C = ({ record: r, index: t, schema: a, customCells: o, cell: p }) => /* @__PURE__ */ l("tr", { className: i.row, children: a.map((e) => {
|
|
6
|
+
const m = c(r, e);
|
|
7
|
+
return /* @__PURE__ */ l(
|
|
8
|
+
s,
|
|
9
|
+
{
|
|
10
|
+
value: m,
|
|
11
|
+
cellType: e.cellType,
|
|
12
|
+
cellRenderer: e.cellRenderer,
|
|
13
|
+
record: r,
|
|
14
|
+
index: t,
|
|
15
|
+
customCells: o,
|
|
16
|
+
cell: p
|
|
17
|
+
},
|
|
18
|
+
e.key
|
|
19
|
+
);
|
|
20
|
+
}) });
|
|
21
|
+
export {
|
|
22
|
+
C as TableRow
|
|
23
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Table as default, Table, TableProvider } from './table-provider';
|
|
2
|
+
export { TableBody } from './table';
|
|
3
|
+
export type { TableProps, TableSchema, TableSchemaColumn, CellType, CellValue, CellRenderer, CellRendererProps, FilterRule, FilterCondition, TableFilter as TableFilterType, TablePaginationConfig, SortDirection, SortColumn, TableSort, } from './table.type';
|
|
4
|
+
export { getNestedValue, extractCellValue } from './table.utils';
|
|
5
|
+
export { DEFAULT_EMPTY_MESSAGE, TABLE_CSS_CLASSES } from './table.const';
|
|
6
|
+
export { TableContext, useTableContext } from './table.context';
|
|
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
|
+
export { PaginationInfo, PaginationQuickJumper } from './components/pagination/components';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TableProps } from './table.type';
|
|
2
|
+
import { TableBody } from './table';
|
|
3
|
+
import { TableFilter } from './components/table-filter';
|
|
4
|
+
import { Pagination } from './components/pagination';
|
|
5
|
+
import { TableHeaderWrapper, TableHeaderContent, TableFooter, TableFooterContent } from './components';
|
|
6
|
+
import { PaginationInfo, PaginationQuickJumper } from './components/pagination/components';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
export interface TableProviderProps extends TableProps {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
declare const TableProvider: React.FC<TableProviderProps>;
|
|
12
|
+
interface TableCompoundComponent extends React.FC<TableProviderProps> {
|
|
13
|
+
Body: typeof TableBody;
|
|
14
|
+
Filter: typeof TableFilter;
|
|
15
|
+
Pagination: typeof Pagination;
|
|
16
|
+
PaginationInfo: typeof PaginationInfo;
|
|
17
|
+
PaginationQuickJumper: typeof PaginationQuickJumper;
|
|
18
|
+
Provider: typeof TableProvider;
|
|
19
|
+
Header: typeof TableHeaderWrapper;
|
|
20
|
+
HeaderContent: typeof TableHeaderContent;
|
|
21
|
+
Footer: typeof TableFooter;
|
|
22
|
+
FooterContent: typeof TableFooterContent;
|
|
23
|
+
}
|
|
24
|
+
export declare const Table: TableCompoundComponent;
|
|
25
|
+
export { TableProvider };
|
|
26
|
+
export default Table;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import * as a from "react";
|
|
3
|
+
import { TableContext as m } from "./table.context.js";
|
|
4
|
+
import { TableBody as p } from "./table.js";
|
|
5
|
+
import { TableFilter as f } from "./components/table-filter/table-filter.js";
|
|
6
|
+
import { Pagination as l } from "./components/pagination/pagination.js";
|
|
7
|
+
import "clsx";
|
|
8
|
+
import "tailwind-merge";
|
|
9
|
+
import { TableHeaderWrapper as s } from "./components/table-header-wrapper.js";
|
|
10
|
+
import { TableHeaderContent as d } from "./components/table-header-content.js";
|
|
11
|
+
import { TableFooter as T } from "./components/table-footer.js";
|
|
12
|
+
import { TableFooterContent as b } from "./components/table-footer-content.js";
|
|
13
|
+
import { PaginationInfo as u } from "./components/pagination/components/pagination-info.js";
|
|
14
|
+
import { PaginationQuickJumper as c } from "./components/pagination/components/pagination-quick-jumper.js";
|
|
15
|
+
const r = ({
|
|
16
|
+
children: e,
|
|
17
|
+
pagination: P,
|
|
18
|
+
sort: C,
|
|
19
|
+
filter: F,
|
|
20
|
+
filterComponents: v,
|
|
21
|
+
...t
|
|
22
|
+
}) => {
|
|
23
|
+
const i = a.useMemo(
|
|
24
|
+
() => ({
|
|
25
|
+
...t
|
|
26
|
+
}),
|
|
27
|
+
[t]
|
|
28
|
+
);
|
|
29
|
+
return /* @__PURE__ */ n(m.Provider, { value: i, children: e });
|
|
30
|
+
}, g = r, o = g;
|
|
31
|
+
o.Body = p;
|
|
32
|
+
o.Filter = f;
|
|
33
|
+
o.Pagination = l;
|
|
34
|
+
o.PaginationInfo = u;
|
|
35
|
+
o.PaginationQuickJumper = c;
|
|
36
|
+
o.Provider = r;
|
|
37
|
+
o.Header = s;
|
|
38
|
+
o.HeaderContent = d;
|
|
39
|
+
o.Footer = T;
|
|
40
|
+
o.FooterContent = b;
|
|
41
|
+
export {
|
|
42
|
+
o as Table,
|
|
43
|
+
r as TableProvider,
|
|
44
|
+
o as default
|
|
45
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const DEFAULT_EMPTY_MESSAGE = "No data available";
|
|
2
|
+
export declare const TABLE_CSS_CLASSES: {
|
|
3
|
+
readonly table: "w-full";
|
|
4
|
+
readonly header: "bg-neutral-25 text-text-neutral-secondary";
|
|
5
|
+
readonly cell: {
|
|
6
|
+
readonly default: "px-4 py-3 text-sm";
|
|
7
|
+
readonly cellHeight: {
|
|
8
|
+
readonly small: "p-3";
|
|
9
|
+
readonly large: "p-4";
|
|
10
|
+
};
|
|
11
|
+
readonly hasBorder: {
|
|
12
|
+
readonly true: "border border-stroke-solid-light";
|
|
13
|
+
readonly false: "border-b border-stroke-solid-light";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
readonly headerCell: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wider";
|
|
17
|
+
readonly sortableHeaderCell: "p-3 text-left text-xs font-medium uppercase tracking-wider cursor-pointer transition-colors duration-200";
|
|
18
|
+
readonly headerCellContent: "flex items-center justify-between";
|
|
19
|
+
readonly sortIcon: "ml-2 w-4 h-4 text-gray-400";
|
|
20
|
+
readonly sortIconActive: "ml-2 w-4 h-4 text-gray-600";
|
|
21
|
+
readonly row: "hover:bg-surface-neutral-hover transition-colors duration-200 text-text-neutral-primary";
|
|
22
|
+
readonly emptyState: "px-4 py-8 text-center text-gray-500";
|
|
23
|
+
readonly loading: "px-4 py-8 text-center text-gray-500";
|
|
24
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const e = "No data available", t = {
|
|
2
|
+
table: "w-full",
|
|
3
|
+
header: "bg-neutral-25 text-text-neutral-secondary",
|
|
4
|
+
cell: {
|
|
5
|
+
default: "px-4 py-3 text-sm",
|
|
6
|
+
cellHeight: {
|
|
7
|
+
small: "p-3",
|
|
8
|
+
large: "p-4"
|
|
9
|
+
},
|
|
10
|
+
hasBorder: {
|
|
11
|
+
true: "border border-stroke-solid-light",
|
|
12
|
+
false: "border-b border-stroke-solid-light"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
headerCell: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wider",
|
|
16
|
+
sortableHeaderCell: "p-3 text-left text-xs font-medium uppercase tracking-wider cursor-pointer transition-colors duration-200",
|
|
17
|
+
headerCellContent: "flex items-center justify-between",
|
|
18
|
+
sortIcon: "ml-2 w-4 h-4 text-gray-400",
|
|
19
|
+
sortIconActive: "ml-2 w-4 h-4 text-gray-600",
|
|
20
|
+
row: "hover:bg-surface-neutral-hover transition-colors duration-200 text-text-neutral-primary",
|
|
21
|
+
emptyState: "px-4 py-8 text-center text-gray-500",
|
|
22
|
+
loading: "px-4 py-8 text-center text-gray-500"
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
e as DEFAULT_EMPTY_MESSAGE,
|
|
26
|
+
t as TABLE_CSS_CLASSES
|
|
27
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TableProps } from './table.type';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export interface TableContextValue extends TableProps {
|
|
4
|
+
updateSort?: (sort: TableProps['sort']) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const TableContext: React.Context<TableContextValue | null>;
|
|
7
|
+
export declare const useTableContext: () => TableContextValue;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
const o = e.createContext(null), n = () => {
|
|
3
|
+
const t = e.useContext(o);
|
|
4
|
+
if (!t)
|
|
5
|
+
throw new Error("useTableContext must be used within a TableProvider");
|
|
6
|
+
return t;
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
o as TableContext,
|
|
10
|
+
n as useTableContext
|
|
11
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs as S, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import * as d from "react";
|
|
3
|
+
import { DEFAULT_EMPTY_MESSAGE as b, TABLE_CSS_CLASSES as T } from "./table.const.js";
|
|
4
|
+
import { TableHeader as u } from "./components/table-header/table-header.js";
|
|
5
|
+
import { TableRow as g } from "./components/table-row.js";
|
|
6
|
+
import { TableEmptyState as h } from "./components/table-empty-state.js";
|
|
7
|
+
import { TableLoadingState as E } from "./components/table-loading-state.js";
|
|
8
|
+
import { TableContext as x } from "./table.context.js";
|
|
9
|
+
const j = ({
|
|
10
|
+
cell: r = { cellHeight: "small", hasBorder: !0 },
|
|
11
|
+
sort: l,
|
|
12
|
+
...m
|
|
13
|
+
}) => {
|
|
14
|
+
const s = d.useContext(x), {
|
|
15
|
+
dataSource: o = [],
|
|
16
|
+
schema: t = [],
|
|
17
|
+
loading: n = !1,
|
|
18
|
+
emptyMessage: c = b,
|
|
19
|
+
customCells: i
|
|
20
|
+
} = s || m, p = () => n ? /* @__PURE__ */ e(E, { colSpan: t.length }) : !o || o.length === 0 ? /* @__PURE__ */ e(h, { colSpan: t.length, message: c }) : /* @__PURE__ */ e("tbody", { children: o.map((f, a) => /* @__PURE__ */ e(
|
|
21
|
+
g,
|
|
22
|
+
{
|
|
23
|
+
record: f,
|
|
24
|
+
index: a,
|
|
25
|
+
schema: t,
|
|
26
|
+
customCells: i,
|
|
27
|
+
cell: r
|
|
28
|
+
},
|
|
29
|
+
a
|
|
30
|
+
)) });
|
|
31
|
+
return /* @__PURE__ */ S("table", { className: T.table, children: [
|
|
32
|
+
/* @__PURE__ */ e(u, { schema: t, sort: l, cell: r }),
|
|
33
|
+
p()
|
|
34
|
+
] });
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
j as TableBody,
|
|
38
|
+
j as default
|
|
39
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FilterComponentType } from './components/table-filter/table-filter.type';
|
|
3
|
+
export type CellType = 'text' | 'number' | 'boolean';
|
|
4
|
+
export type CellValue = string | number | boolean | null | undefined;
|
|
5
|
+
export type CellRendererProps = {
|
|
6
|
+
value: CellValue;
|
|
7
|
+
record: Record<string, unknown>;
|
|
8
|
+
index: number;
|
|
9
|
+
};
|
|
10
|
+
export type CellRenderer = FC<CellRendererProps>;
|
|
11
|
+
export type FilterCondition = 'contains' | 'notEqual' | 'equal' | '>' | '<' | '=' | '!=';
|
|
12
|
+
export type FilterRule = {
|
|
13
|
+
field: string;
|
|
14
|
+
condition?: string;
|
|
15
|
+
value: string;
|
|
16
|
+
};
|
|
17
|
+
export type TableFilter = {
|
|
18
|
+
value: FilterRule[];
|
|
19
|
+
onChange: (filters: FilterRule[]) => void;
|
|
20
|
+
};
|
|
21
|
+
export type TablePaginationConfig = {
|
|
22
|
+
currentPage: number;
|
|
23
|
+
totalPage: number;
|
|
24
|
+
onChange: (page: number) => void;
|
|
25
|
+
itemsPerPage?: number;
|
|
26
|
+
totalItems?: number;
|
|
27
|
+
showQuickJumper?: boolean;
|
|
28
|
+
showTotal?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type SortDirection = 'asc' | 'desc' | null;
|
|
31
|
+
export type SortColumn = {
|
|
32
|
+
field: string;
|
|
33
|
+
direction: SortDirection;
|
|
34
|
+
};
|
|
35
|
+
export type TableSort = {
|
|
36
|
+
sortedColumns: SortColumn[];
|
|
37
|
+
onSort: (field: string, direction: SortDirection) => void;
|
|
38
|
+
};
|
|
39
|
+
export type TableSchemaColumn = {
|
|
40
|
+
key: string;
|
|
41
|
+
title: string;
|
|
42
|
+
cellType: CellType;
|
|
43
|
+
cellRenderer?: CellRenderer;
|
|
44
|
+
filterable?: boolean;
|
|
45
|
+
hideable?: boolean;
|
|
46
|
+
sortable?: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type TableSchema = TableSchemaColumn[];
|
|
49
|
+
export type TableProps = {
|
|
50
|
+
cell?: {
|
|
51
|
+
hasBorder?: boolean;
|
|
52
|
+
cellHeight?: 'small' | 'large';
|
|
53
|
+
};
|
|
54
|
+
dataSource: Record<string, unknown>[];
|
|
55
|
+
schema: TableSchema;
|
|
56
|
+
loading?: boolean;
|
|
57
|
+
emptyMessage?: string;
|
|
58
|
+
filter?: TableFilter;
|
|
59
|
+
filterComponents?: Record<string, FilterComponentType>;
|
|
60
|
+
pagination?: TablePaginationConfig;
|
|
61
|
+
sort?: TableSort;
|
|
62
|
+
customCells?: Record<string, CellRenderer>;
|
|
63
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CellValue, TableSchemaColumn } from './table.type';
|
|
2
|
+
export declare const getNestedValue: (object: Record<string, unknown>, path: string) => CellValue;
|
|
3
|
+
export declare const extractCellValue: (record: Record<string, unknown>, column: TableSchemaColumn) => CellValue;
|