@caspeco/casper-ui-library 5.6.1 → 6.0.0
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/table/index.d.ts +2 -3
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/table-cell.d.ts +11 -6
- package/dist/components/table/table-cell.d.ts.map +1 -1
- package/dist/components/table/table-cell.js +118 -69
- package/dist/components/table/table-content.d.ts +4 -4
- package/dist/components/table/table-content.d.ts.map +1 -1
- package/dist/components/table/table-content.js +17 -20
- package/dist/components/table/table-context-provider.d.ts +57 -0
- package/dist/components/table/table-context-provider.d.ts.map +1 -0
- package/dist/components/table/table-context-provider.js +115 -0
- package/dist/components/table/table-context.d.ts +4 -54
- package/dist/components/table/table-context.d.ts.map +1 -1
- package/dist/components/table/table-context.js +10 -108
- package/dist/components/table/table-header-dropdown.d.ts +6 -4
- package/dist/components/table/table-header-dropdown.d.ts.map +1 -1
- package/dist/components/table/table-header-dropdown.js +98 -103
- package/dist/components/table/table-header-row.d.ts +5 -3
- package/dist/components/table/table-header-row.d.ts.map +1 -1
- package/dist/components/table/table-header-row.js +32 -33
- package/dist/components/table/table-row-expand-toggle-button.d.ts +2 -2
- package/dist/components/table/table-row-expand-toggle-button.d.ts.map +1 -1
- package/dist/components/table/table-row-expand-toggle-button.js +14 -13
- package/dist/components/table/table-row.d.ts +6 -6
- package/dist/components/table/table-row.d.ts.map +1 -1
- package/dist/components/table/table-row.js +41 -43
- package/dist/components/table/table-toolbar.d.ts +2 -3
- package/dist/components/table/table-toolbar.d.ts.map +1 -1
- package/dist/components/table/table-toolbar.js +38 -40
- package/dist/components/table/table.composition.d.ts +3 -3
- package/dist/components/table/table.composition.d.ts.map +1 -1
- package/dist/components/table/table.d.ts +2 -2
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +20 -18
- package/dist/components/table/translations.d.ts +5 -0
- package/dist/components/table/translations.d.ts.map +1 -1
- package/dist/components/table/translations.js +8 -4
- package/dist/components/table/types.d.ts +29 -11
- package/dist/components/table/types.d.ts.map +1 -1
- package/dist/index.js +26 -24
- package/package.json +7 -6
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { createColumnHelper } from '@tanstack/react-table';
|
|
2
2
|
export { Table } from './table.js';
|
|
3
3
|
export { TableContent } from './table-content.js';
|
|
4
|
+
export { useTableContext } from './table-context.js';
|
|
4
5
|
export { TableToolbar } from './table-toolbar.js';
|
|
5
|
-
export type { TableContentProps } from './
|
|
6
|
-
export type { TableToolbarProps } from './table-toolbar.js';
|
|
7
|
-
export type { CellContext, ColumnDef, ExpandedState, Row, RowSelectionState, TableDataType, TableProps, TableSubrows, VisibilityState, } from './types.js';
|
|
6
|
+
export type { CellContext, ColumnDef, ExpandedState, Row, RowSelectionState, TableContentProps, TableProps, TableRow, TableToolbarProps, VisibilityState, } from './types.js';
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/table/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,YAAY,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,GAAG,EACH,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,eAAe,GACf,MAAM,SAAS,CAAC"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { Cell, Row } from '@tanstack/react-table';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { Locales } from './translations.js';
|
|
4
|
+
import { TableData, TableRow } from './types.js';
|
|
5
|
+
type TableCellProps<TData extends TableData> = {
|
|
6
|
+
cell: Cell<TableRow<TData>, unknown>;
|
|
7
|
+
visibleCells: Cell<TableRow<TData>, unknown>[];
|
|
8
|
+
row: Row<TableRow<TData>>;
|
|
6
9
|
rowIsExpanded: boolean;
|
|
7
10
|
breakingContentState: Record<string, boolean>;
|
|
8
|
-
localeString:
|
|
11
|
+
localeString: Locales;
|
|
12
|
+
actionMenu?: ReactNode;
|
|
9
13
|
};
|
|
10
|
-
|
|
14
|
+
declare const TableCellComponent: <TData extends TableData>({ cell, row, rowIsExpanded, visibleCells, breakingContentState, localeString, actionMenu, }: TableCellProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const TableCell: typeof TableCellComponent;
|
|
11
16
|
export {};
|
|
12
17
|
//# sourceMappingURL=table-cell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-cell.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-cell.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,IAAI,EAAE,KAAK,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"table-cell.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-cell.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,IAAI,EAAE,KAAK,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAkD,KAAK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33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
hidden: !m,
|
|
59
|
-
rowIsExpanded: c
|
|
60
|
-
}
|
|
61
|
-
) : /* @__PURE__ */ o(b, {}),
|
|
62
|
-
h && x,
|
|
63
|
-
/* @__PURE__ */ o("div", { style: f, children: y(t.columnDef.cell, n.getContext()) })
|
|
64
|
-
] })
|
|
65
|
-
},
|
|
66
|
-
n.id
|
|
67
|
-
);
|
|
1
|
+
import { jsx as i, jsxs as g, Fragment as I } from "react/jsx-runtime";
|
|
2
|
+
import { Divider as R, Td as S, Flex as B, Box as b } from "@chakra-ui/react";
|
|
3
|
+
import { flexRender as $ } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
|
+
import { memo as F, useMemo as d, useCallback as k } from "react";
|
|
5
|
+
import { useTableContext as z } from "./table-context.js";
|
|
6
|
+
import { TableRowExpandToggleButton as E } from "./table-row-expand-toggle-button.js";
|
|
7
|
+
import { translations as V } from "./translations.js";
|
|
8
|
+
import { Menu as A } from "../menu/menu.js";
|
|
9
|
+
import { MenuIconButton as N } from "../menu/menu-icon-button.js";
|
|
10
|
+
import { Icons as j } from "../icon/types.js";
|
|
11
|
+
import { ThemeColorVariable as M, ThemeSpaceVariable as _ } from "../../theme/theme-types.js";
|
|
12
|
+
const K = ({
|
|
13
|
+
cell: r,
|
|
14
|
+
row: n,
|
|
15
|
+
rowIsExpanded: x,
|
|
16
|
+
visibleCells: v,
|
|
17
|
+
breakingContentState: c,
|
|
18
|
+
localeString: m,
|
|
19
|
+
actionMenu: l
|
|
20
|
+
}) => {
|
|
21
|
+
const C = z(), { column: t } = r, y = V[m], T = d(() => {
|
|
22
|
+
const e = {
|
|
23
|
+
width: "100%"
|
|
24
|
+
};
|
|
25
|
+
return c[t.id] || (e.overflow = "hidden", e.whiteSpace = "nowrap"), e;
|
|
26
|
+
}, [c]), p = d(() => t.getIndex() === 0, []), u = n.getCanExpand(), s = v[0].id === r.id, f = u && s, h = l || p && !!C.getRowActions, w = d(() => {
|
|
27
|
+
const e = [];
|
|
28
|
+
for (let o = 0; o < n.depth; o += 1) {
|
|
29
|
+
let a = `${o * 2 + 0.7}rem`;
|
|
30
|
+
h && (a = `calc(${a} + 24px)`), e.push(
|
|
31
|
+
/* @__PURE__ */ i(
|
|
32
|
+
R,
|
|
33
|
+
{
|
|
34
|
+
orientation: "vertical",
|
|
35
|
+
position: "absolute",
|
|
36
|
+
top: "0",
|
|
37
|
+
left: a
|
|
38
|
+
},
|
|
39
|
+
`nestedTableDivider${o}`
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return e;
|
|
44
|
+
}, []), P = k(() => {
|
|
45
|
+
const e = t.getIsPinned();
|
|
46
|
+
return {
|
|
47
|
+
position: e ? "sticky" : "relative",
|
|
48
|
+
left: e ? `${t.getStart("left")}px` : void 0,
|
|
49
|
+
backgroundColor: e ? M.Background : void 0,
|
|
50
|
+
zIndex: e ? 1 : void 0,
|
|
51
|
+
width: t.getSize(),
|
|
52
|
+
maxWidth: t.getSize()
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
55
|
+
function D() {
|
|
56
|
+
const e = n.depth && s || f ? `${n.depth * 2}rem` : _.Small;
|
|
57
|
+
return h ? `calc(${e} + 24px)` : e;
|
|
68
58
|
}
|
|
69
|
-
|
|
59
|
+
return /* @__PURE__ */ i(
|
|
60
|
+
S,
|
|
61
|
+
{
|
|
62
|
+
id: r.id,
|
|
63
|
+
isNumeric: t.columnDef.meta?.isNumeric,
|
|
64
|
+
style: {
|
|
65
|
+
...P(),
|
|
66
|
+
borderBottom: 0,
|
|
67
|
+
paddingLeft: D()
|
|
68
|
+
},
|
|
69
|
+
children: /* @__PURE__ */ g(B, { w: "100%", align: "center", children: [
|
|
70
|
+
l && /* @__PURE__ */ i(A, { children: ({ isOpen: e }) => /* @__PURE__ */ g(
|
|
71
|
+
b,
|
|
72
|
+
{
|
|
73
|
+
display: "contents",
|
|
74
|
+
onClick: (o) => o.stopPropagation(),
|
|
75
|
+
onKeyDown: (o) => o.stopPropagation(),
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ i(
|
|
78
|
+
b,
|
|
79
|
+
{
|
|
80
|
+
className: "action-menu-button",
|
|
81
|
+
position: "absolute",
|
|
82
|
+
left: "0",
|
|
83
|
+
opacity: e ? 1 : 0,
|
|
84
|
+
_hover: { opacity: 1 },
|
|
85
|
+
_focusVisible: { opacity: 1 },
|
|
86
|
+
sx: { "&:has(:focus-visible)": { opacity: 1 } },
|
|
87
|
+
children: /* @__PURE__ */ i(
|
|
88
|
+
N,
|
|
89
|
+
{
|
|
90
|
+
icon: j.MoreVertical,
|
|
91
|
+
variant: "ghost",
|
|
92
|
+
size: "sm",
|
|
93
|
+
"aria-label": y.moreActions,
|
|
94
|
+
borderRadius: "0"
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
l
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
) }),
|
|
103
|
+
f || n.depth > 0 && s ? /* @__PURE__ */ i(
|
|
104
|
+
E,
|
|
105
|
+
{
|
|
106
|
+
row: n,
|
|
107
|
+
localeString: m,
|
|
108
|
+
hidden: !u,
|
|
109
|
+
rowIsExpanded: x
|
|
110
|
+
}
|
|
111
|
+
) : /* @__PURE__ */ i(I, {}),
|
|
112
|
+
p && w,
|
|
113
|
+
/* @__PURE__ */ i("div", { style: T, children: $(t.columnDef.cell, r.getContext()) })
|
|
114
|
+
] })
|
|
115
|
+
},
|
|
116
|
+
r.id
|
|
117
|
+
);
|
|
118
|
+
}, Z = F(K);
|
|
70
119
|
export {
|
|
71
|
-
|
|
120
|
+
Z as TableCell
|
|
72
121
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ThemeStyleProps } from '../../theme/index.js';
|
|
2
|
-
import {
|
|
3
|
-
export interface TableContentProps<
|
|
2
|
+
import { TableData, TableRow as TableRowType } from './types.js';
|
|
3
|
+
export interface TableContentProps<TData extends TableData = TableData> {
|
|
4
4
|
/**
|
|
5
5
|
* Returns the data of clicked row. Not applicable to header row.
|
|
6
6
|
*/
|
|
7
|
-
onClickRow?: (row:
|
|
7
|
+
onClickRow?: (row: TableRowType<TData>, event: React.MouseEvent<HTMLTableRowElement> | React.KeyboardEvent<HTMLTableRowElement>) => void;
|
|
8
8
|
/**
|
|
9
9
|
* Use to allow a indication that the row has been clicked by changing its background color
|
|
10
10
|
*/
|
|
@@ -23,7 +23,7 @@ export interface TableContentProps<J extends TableSubrows<J>> {
|
|
|
23
23
|
*/
|
|
24
24
|
stickyHeaders?: boolean;
|
|
25
25
|
}
|
|
26
|
-
declare const TableContentInner: <
|
|
26
|
+
declare const TableContentInner: <TData extends TableData>({ onClickRow, onRowClickIndication, hideTableHeaderDropdown, showRowHoverStyle, stickyHeaders, ...props }: TableContentProps<TData> & ThemeStyleProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
27
|
export declare const TableContent: typeof TableContentInner;
|
|
28
28
|
export {};
|
|
29
29
|
//# sourceMappingURL=table-content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-content.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-content.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"table-content.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-content.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAM/C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnE,MAAM,WAAW,iBAAiB,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS;IACrE;;OAEG;IACH,UAAU,CAAC,EAAE,CACZ,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,EACxB,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,mBAAmB,CAAC,KACnF,IAAI,CAAC;IAEV;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,QAAA,MAAM,iBAAiB,GAAI,KAAK,SAAS,SAAS,EAAE,2GAOjD,iBAAiB,CAAC,KAAK,CAAC,GAAG,eAAe,4CAqD5C,CAAC;AAEF,eAAO,MAAM,YAAY,EAA8B,OAAO,iBAAiB,CAAC"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import { jsxs as p, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { Table as
|
|
3
|
-
import { memo as
|
|
4
|
-
import {
|
|
2
|
+
import { Table as u, Thead as T, Tbody as f } from "@chakra-ui/react";
|
|
3
|
+
import { memo as g, useMemo as r } from "react";
|
|
4
|
+
import { useTableContext as x } from "./table-context.js";
|
|
5
5
|
import { TableHeaderRow as y } from "./table-header-row.js";
|
|
6
|
-
import { TableRow as
|
|
7
|
-
const
|
|
8
|
-
onClickRow:
|
|
9
|
-
onRowClickIndication:
|
|
6
|
+
import { TableRow as C } from "./table-row.js";
|
|
7
|
+
const R = ({
|
|
8
|
+
onClickRow: i,
|
|
9
|
+
onRowClickIndication: n,
|
|
10
10
|
hideTableHeaderDropdown: l,
|
|
11
11
|
showRowHoverStyle: s = !0,
|
|
12
12
|
stickyHeaders: a,
|
|
13
13
|
...m
|
|
14
14
|
}) => {
|
|
15
|
-
const e =
|
|
16
|
-
if (!e)
|
|
17
|
-
throw new Error("No table context");
|
|
18
|
-
const b = r(() => a ? {
|
|
15
|
+
const e = x(), d = r(() => a ? {
|
|
19
16
|
position: "sticky",
|
|
20
17
|
top: 0,
|
|
21
18
|
zIndex: 1
|
|
22
|
-
} : {}, []),
|
|
19
|
+
} : {}, []), b = r(
|
|
23
20
|
() => e.table.getRowModel().rows,
|
|
24
21
|
[
|
|
25
22
|
e.expanded,
|
|
@@ -29,8 +26,8 @@ const h = ({
|
|
|
29
26
|
e.data
|
|
30
27
|
]
|
|
31
28
|
);
|
|
32
|
-
return /* @__PURE__ */ p(
|
|
33
|
-
/* @__PURE__ */ o(
|
|
29
|
+
return /* @__PURE__ */ p(u, { ...m, id: e.id, children: [
|
|
30
|
+
/* @__PURE__ */ o(T, { style: d, children: e.table.getHeaderGroups().map((t) => /* @__PURE__ */ o(
|
|
34
31
|
y,
|
|
35
32
|
{
|
|
36
33
|
headerGroup: t,
|
|
@@ -38,22 +35,22 @@ const h = ({
|
|
|
38
35
|
},
|
|
39
36
|
t.id
|
|
40
37
|
)) }),
|
|
41
|
-
/* @__PURE__ */ o(
|
|
38
|
+
/* @__PURE__ */ o(f, { children: b.map((t) => {
|
|
42
39
|
const c = t.getVisibleCells();
|
|
43
40
|
return /* @__PURE__ */ o(
|
|
44
|
-
|
|
41
|
+
C,
|
|
45
42
|
{
|
|
46
43
|
row: t,
|
|
47
44
|
visibleCells: c,
|
|
48
|
-
onClickRow:
|
|
49
|
-
onRowClickIndication:
|
|
45
|
+
onClickRow: i,
|
|
46
|
+
onRowClickIndication: n,
|
|
50
47
|
showRowHoverStyle: s
|
|
51
48
|
},
|
|
52
49
|
t.id
|
|
53
50
|
);
|
|
54
51
|
}) })
|
|
55
52
|
] });
|
|
56
|
-
},
|
|
53
|
+
}, I = g(R);
|
|
57
54
|
export {
|
|
58
|
-
|
|
55
|
+
I as TableContent
|
|
59
56
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Column, ColumnDef, ExpandedState, Row, RowSelectionState, SortingState, Table, VisibilityState } from '@tanstack/react-table';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { MenuList } from '../menu/index.js';
|
|
4
|
+
import { Locales } from './translations.js';
|
|
5
|
+
import { TableData, TableRow } from './types.js';
|
|
6
|
+
interface TableProviderInterface<TData extends TableData> extends PropsWithChildren {
|
|
7
|
+
data: TableRow<TData>[];
|
|
8
|
+
columns: ColumnDef<TableRow<TData>>[];
|
|
9
|
+
localeString: Locales;
|
|
10
|
+
initialBreakingContentState?: Record<string, boolean>;
|
|
11
|
+
initialColumnVisibilityState?: VisibilityState;
|
|
12
|
+
columnVisibilityState?: VisibilityState;
|
|
13
|
+
onColumnVisibilityChange?: (state: VisibilityState) => void;
|
|
14
|
+
onExpandedChange?: (state: ExpandedState) => void;
|
|
15
|
+
getRowId?: (originalRow: TableRow<TData>, index: number, parent?: Row<TableRow<TData>>) => string;
|
|
16
|
+
getRowActions?: (row: TableRow<TData>) => React.ReactElement<React.ComponentProps<typeof MenuList>, typeof MenuList> | null | undefined | false;
|
|
17
|
+
onBreakingContentChange?: (breakingContentState: Record<string, boolean>) => void;
|
|
18
|
+
onFilterColumn?: (clickedColumn: Column<TableRow<TData>, unknown>) => void;
|
|
19
|
+
expandedState?: ExpandedState;
|
|
20
|
+
initialExpandedState?: ExpandedState;
|
|
21
|
+
id?: string;
|
|
22
|
+
customRowIndication?: RowSelectionState;
|
|
23
|
+
onSortingChange?: (state: SortingState) => void;
|
|
24
|
+
initialSortingState?: SortingState;
|
|
25
|
+
sortingState?: SortingState;
|
|
26
|
+
}
|
|
27
|
+
export interface TableContextInterface<TData extends TableData = TableData> {
|
|
28
|
+
data: TableRow<TData>[];
|
|
29
|
+
table: Table<TableRow<TData>>;
|
|
30
|
+
initialExpandedState?: ExpandedState;
|
|
31
|
+
initialBreakingContentState?: Record<string, boolean>;
|
|
32
|
+
breakingContentState: Record<string, boolean>;
|
|
33
|
+
setBreakingContentState: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
34
|
+
localeString: Locales;
|
|
35
|
+
initialColumnVisibilityState?: VisibilityState;
|
|
36
|
+
columnVisibilityState?: VisibilityState;
|
|
37
|
+
onColumnVisibilityChange?: (state: VisibilityState) => void;
|
|
38
|
+
onBreakingContentChange?: (breakingContentState: Record<string, boolean>) => void;
|
|
39
|
+
onFilterColumn?: (clickedColumn: Column<TableRow<TData>, unknown>) => void;
|
|
40
|
+
onExpandedChange?: (state: ExpandedState) => void;
|
|
41
|
+
getRowId?: (originalRow: TableRow<TData>, index: number, parent?: Row<TableRow<TData>>) => string;
|
|
42
|
+
getRowActions?: (row: TableRow<TData>) => React.ReactElement<React.ComponentProps<typeof MenuList>, typeof MenuList> | null | undefined | false;
|
|
43
|
+
expanded: ExpandedState;
|
|
44
|
+
sorting: SortingState;
|
|
45
|
+
setSorting: (value: SortingState) => void;
|
|
46
|
+
setExpanded: React.Dispatch<React.SetStateAction<ExpandedState>>;
|
|
47
|
+
id?: string;
|
|
48
|
+
setRowSelection: React.Dispatch<React.SetStateAction<RowSelectionState>>;
|
|
49
|
+
rowSelection?: RowSelectionState | undefined;
|
|
50
|
+
columnVisibility: VisibilityState;
|
|
51
|
+
onSortingChange?: (state: SortingState) => void;
|
|
52
|
+
initialSortingState?: SortingState;
|
|
53
|
+
sortingState?: SortingState;
|
|
54
|
+
}
|
|
55
|
+
export declare const TableProvider: <TData extends TableData>({ data, columns, children, expandedState, localeString, initialExpandedState, initialBreakingContentState, initialColumnVisibilityState, columnVisibilityState, onColumnVisibilityChange, onExpandedChange, getRowId, getRowActions, onBreakingContentChange, onFilterColumn, id, customRowIndication, onSortingChange, initialSortingState, sortingState, }: TableProviderInterface<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=table-context-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-context-provider.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-context-provider.tsx"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,aAAa,EAKlB,KAAK,GAAG,EACR,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,KAAK,EAGV,KAAK,eAAe,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,UAAU,sBAAsB,CAAC,KAAK,SAAS,SAAS,CAAE,SAAQ,iBAAiB;IAClF,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IACxB,OAAO,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;IACtC,YAAY,EAAE,OAAO,CAAC;IACtB,2BAA2B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtD,4BAA4B,CAAC,EAAE,eAAe,CAAC;IAC/C,qBAAqB,CAAC,EAAE,eAAe,CAAC;IACxC,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5D,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,G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zE,YAAY,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC7C,gBAAgB,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,mBAAmB,CAAC,EAAE,YAAY,CAAC;IACnC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,SAAS,EAAE,8VAqBpD,sBAAsB,CAAC,KAAK,CAAC,4CAyH/B,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx as J } from "react/jsx-runtime";
|
|
2
|
+
import { useControllableState as i } from "@chakra-ui/react";
|
|
3
|
+
import { useReactTable as K } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
|
|
4
|
+
import { useState as R, useEffect as L, useCallback as s } from "react";
|
|
5
|
+
import { TableContext as N } from "./table-context.js";
|
|
6
|
+
import { getFilteredRowModel as Q, getSortedRowModel as U, getExpandedRowModel as W, getCoreRowModel as X } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
|
|
7
|
+
const ee = ({
|
|
8
|
+
data: a,
|
|
9
|
+
columns: p,
|
|
10
|
+
children: h,
|
|
11
|
+
expandedState: M,
|
|
12
|
+
localeString: v,
|
|
13
|
+
initialExpandedState: r = {},
|
|
14
|
+
initialBreakingContentState: d = {},
|
|
15
|
+
initialColumnVisibilityState: x = {},
|
|
16
|
+
columnVisibilityState: y,
|
|
17
|
+
onColumnVisibilityChange: E,
|
|
18
|
+
onExpandedChange: u,
|
|
19
|
+
getRowId: f,
|
|
20
|
+
getRowActions: V,
|
|
21
|
+
onBreakingContentChange: T,
|
|
22
|
+
onFilterColumn: k,
|
|
23
|
+
id: F,
|
|
24
|
+
customRowIndication: n,
|
|
25
|
+
onSortingChange: b,
|
|
26
|
+
initialSortingState: P = [],
|
|
27
|
+
sortingState: c
|
|
28
|
+
}) => {
|
|
29
|
+
const [t, g] = i({
|
|
30
|
+
value: M,
|
|
31
|
+
onChange: u,
|
|
32
|
+
defaultValue: r
|
|
33
|
+
}), [l, j] = i({
|
|
34
|
+
value: y,
|
|
35
|
+
onChange: E,
|
|
36
|
+
defaultValue: x
|
|
37
|
+
}), [m, C] = i({
|
|
38
|
+
value: c,
|
|
39
|
+
onChange: b,
|
|
40
|
+
defaultValue: P
|
|
41
|
+
}), [q, z] = R(
|
|
42
|
+
d || {}
|
|
43
|
+
), [S, w] = R({});
|
|
44
|
+
L(() => {
|
|
45
|
+
n && w(n);
|
|
46
|
+
}, [n]);
|
|
47
|
+
const A = s(
|
|
48
|
+
(e) => {
|
|
49
|
+
let o;
|
|
50
|
+
typeof e == "function" ? o = e(l) : o = e, j(o);
|
|
51
|
+
},
|
|
52
|
+
[l]
|
|
53
|
+
), B = s(
|
|
54
|
+
(e) => {
|
|
55
|
+
let o;
|
|
56
|
+
typeof e == "function" ? o = e(t) : o = e, g(o);
|
|
57
|
+
},
|
|
58
|
+
[t]
|
|
59
|
+
), D = s(
|
|
60
|
+
(e) => {
|
|
61
|
+
C(e);
|
|
62
|
+
},
|
|
63
|
+
[C]
|
|
64
|
+
), G = K({
|
|
65
|
+
columns: p,
|
|
66
|
+
data: a,
|
|
67
|
+
getCoreRowModel: X(),
|
|
68
|
+
getExpandedRowModel: W(),
|
|
69
|
+
getSortedRowModel: U(),
|
|
70
|
+
getFilteredRowModel: Q(),
|
|
71
|
+
onColumnVisibilityChange: A,
|
|
72
|
+
onExpandedChange: B,
|
|
73
|
+
getSubRows: (e) => e.subRows,
|
|
74
|
+
getRowId: f,
|
|
75
|
+
enableSubRowSelection: !0,
|
|
76
|
+
enableMultiRowSelection: !1,
|
|
77
|
+
enableRowSelection: !0,
|
|
78
|
+
state: {
|
|
79
|
+
sorting: m,
|
|
80
|
+
columnVisibility: l,
|
|
81
|
+
expanded: t,
|
|
82
|
+
rowSelection: S
|
|
83
|
+
},
|
|
84
|
+
manualSorting: c !== void 0
|
|
85
|
+
}), H = {
|
|
86
|
+
data: a,
|
|
87
|
+
table: G,
|
|
88
|
+
initialExpandedState: r,
|
|
89
|
+
initialBreakingContentState: d,
|
|
90
|
+
localeString: v,
|
|
91
|
+
onExpandedChange: u,
|
|
92
|
+
expanded: t,
|
|
93
|
+
sorting: m,
|
|
94
|
+
setSorting: D,
|
|
95
|
+
setExpanded: g,
|
|
96
|
+
getRowId: f,
|
|
97
|
+
getRowActions: V,
|
|
98
|
+
breakingContentState: q,
|
|
99
|
+
setBreakingContentState: z,
|
|
100
|
+
onBreakingContentChange: T,
|
|
101
|
+
onFilterColumn: k,
|
|
102
|
+
id: F,
|
|
103
|
+
setRowSelection: w,
|
|
104
|
+
rowSelection: S,
|
|
105
|
+
columnVisibility: l,
|
|
106
|
+
onSortingChange: b
|
|
107
|
+
};
|
|
108
|
+
return (
|
|
109
|
+
// This is correct but there's no easy way to type the context statically with generics
|
|
110
|
+
/* @__PURE__ */ J(N.Provider, { value: H, children: h })
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
ee as TableProvider
|
|
115
|
+
};
|
|
@@ -1,55 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
interface TableProviderInterface<I extends TableSubrows<I>> extends PropsWithChildren {
|
|
6
|
-
data: TableDataType<I>[];
|
|
7
|
-
columns: ColumnDef<TableDataType<I>, any>[];
|
|
8
|
-
localeString: Locales;
|
|
9
|
-
initialBreakingContentState?: Record<string, boolean>;
|
|
10
|
-
initialColumnVisibilityState?: VisibilityState;
|
|
11
|
-
columnVisibilityState?: VisibilityState;
|
|
12
|
-
onColumnVisibilityChange?: (state: VisibilityState) => void;
|
|
13
|
-
onExpandedChange?: (state: ExpandedState) => void;
|
|
14
|
-
getRowId?: (originalRow: TableDataType<I>, index: number, parent?: Row<TableDataType<I>>) => string;
|
|
15
|
-
onBreakingContentChange?: (breakingContentState: Record<string, boolean>) => void;
|
|
16
|
-
onFilterColumn?: <K extends TableSubrows<K>>(clickedColumn: Column<TableDataType<K>, unknown>) => void;
|
|
17
|
-
expandedState?: ExpandedState;
|
|
18
|
-
initialExpandedState?: ExpandedState;
|
|
19
|
-
id?: string;
|
|
20
|
-
customRowIndication?: RowSelectionState;
|
|
21
|
-
onSortingChange?: (state: SortingState) => void;
|
|
22
|
-
initialSortingState?: SortingState;
|
|
23
|
-
sortingState?: SortingState;
|
|
24
|
-
}
|
|
25
|
-
interface TableContextInterface<I extends TableSubrows<I>> {
|
|
26
|
-
data: TableDataType<I>[];
|
|
27
|
-
table: Table<TableDataType<I>>;
|
|
28
|
-
initialExpandedState?: ExpandedState;
|
|
29
|
-
initialBreakingContentState?: Record<string, boolean>;
|
|
30
|
-
breakingContentState: Record<string, boolean>;
|
|
31
|
-
setBreakingContentState: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
32
|
-
localeString: Locales;
|
|
33
|
-
initialColumnVisibilityState?: VisibilityState;
|
|
34
|
-
columnVisibilityState?: VisibilityState;
|
|
35
|
-
onColumnVisibilityChange?: (state: VisibilityState) => void;
|
|
36
|
-
onBreakingContentChange?: (breakingContentState: Record<string, boolean>) => void;
|
|
37
|
-
onFilterColumn?: <K extends TableSubrows<K>>(clickedColumn: Column<TableDataType<K>, unknown>) => void;
|
|
38
|
-
onExpandedChange?: (state: ExpandedState) => void;
|
|
39
|
-
getRowId?: (originalRow: TableDataType<I>, index: number, parent?: Row<TableDataType<I>>) => string;
|
|
40
|
-
expanded: ExpandedState;
|
|
41
|
-
sorting: SortingState;
|
|
42
|
-
setSorting: (value: SortingState) => void;
|
|
43
|
-
setExpanded: React.Dispatch<React.SetStateAction<ExpandedState>>;
|
|
44
|
-
id?: string;
|
|
45
|
-
setRowSelection: React.Dispatch<React.SetStateAction<{}>>;
|
|
46
|
-
rowSelection?: RowSelectionState | undefined;
|
|
47
|
-
columnVisibility: VisibilityState;
|
|
48
|
-
onSortingChange?: (state: SortingState) => void;
|
|
49
|
-
initialSortingState?: SortingState;
|
|
50
|
-
sortingState?: SortingState;
|
|
51
|
-
}
|
|
52
|
-
export declare const TableContext: import('react').Context<TableContextInterface<any> | null>;
|
|
53
|
-
export declare const TableProvider: <T extends TableSubrows<T>>({ data, columns, children, expandedState, localeString, initialExpandedState, initialBreakingContentState, initialColumnVisibilityState, columnVisibilityState, onColumnVisibilityChange, onExpandedChange, getRowId, onBreakingContentChange, onFilterColumn, id, customRowIndication, onSortingChange, initialSortingState, sortingState, }: TableProviderInterface<T>) => import("react/jsx-runtime").JSX.Element;
|
|
54
|
-
export {};
|
|
1
|
+
import { TableContextInterface } from './table-context-provider.js';
|
|
2
|
+
import { TableData } from './types.js';
|
|
3
|
+
export declare const TableContext: import('react').Context<TableContextInterface<object> | null>;
|
|
4
|
+
export declare function useTableContext<TData extends TableData>(): TableContextInterface<TData>;
|
|
55
5
|
//# sourceMappingURL=table-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-context.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-context.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"table-context.d.ts","sourceRoot":"","sources":["../../../lib/components/table/table-context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,eAAO,MAAM,YAAY,+DAA+D,CAAC;AAEzF,wBAAgB,eAAe,CAAC,KAAK,SAAS,SAAS,KAAK,qBAAqB,CAAC,KAAK,CAAC,CASvF"}
|