@appdirect/design-system 0.0.17 → 0.0.18
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/bin/ad-sync-design-md.mjs +0 -0
- package/dist/ComplexComponents/DataTable/CellHoverReveal/CellHoverReveal.module.css +25 -0
- package/dist/ComplexComponents/DataTable/CellHoverReveal/index.js +24 -0
- package/dist/ComplexComponents/DataTable/CellHoverReveal/index.tsx +44 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/CustomBottomToolbar.module.css +7 -0
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +25 -77
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.tsx +101 -157
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.js +14 -7
- package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.ts +13 -7
- package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/CustomToolbarAlertBannerContent.module.css +4 -0
- package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.js +8 -20
- package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.tsx +40 -58
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/CustomTopToolbar.module.css +7 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/DateRangeSelectorFilter.module.css +3 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +50 -154
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.tsx +59 -205
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/utils.js +48 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/utils.ts +51 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.js +5 -25
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.tsx +7 -28
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount.js +16 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount.tsx +26 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +26 -28
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.tsx +38 -38
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.js +8 -18
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.module.css +3 -0
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.tsx +25 -37
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +67 -378
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.tsx +170 -711
- package/dist/ComplexComponents/DataTable/DataTable.js +74 -393
- package/dist/ComplexComponents/DataTable/DataTable.tsx +229 -546
- package/dist/ComplexComponents/DataTable/DataTableGrid/DataTableGrid.module.css +85 -0
- package/dist/ComplexComponents/DataTable/DataTableGrid/index.js +46 -0
- package/dist/ComplexComponents/DataTable/DataTableGrid/index.tsx +143 -0
- package/dist/ComplexComponents/DataTable/DataTableShell/DataTableShell.module.css +38 -0
- package/dist/ComplexComponents/DataTable/DataTableShell/index.js +9 -0
- package/dist/ComplexComponents/DataTable/DataTableShell/index.tsx +47 -0
- package/dist/ComplexComponents/DataTable/ErrorOverlay/index.js +6 -6
- package/dist/ComplexComponents/DataTable/ErrorOverlay/index.tsx +53 -24
- package/dist/ComplexComponents/DataTable/SelectCheckbox/index.js +33 -0
- package/dist/ComplexComponents/DataTable/SelectCheckbox/index.tsx +63 -0
- package/dist/ComplexComponents/DataTable/SortableHeaderCell/SortableHeaderCell.module.css +3 -0
- package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.js +43 -21
- package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.tsx +62 -38
- package/dist/ComplexComponents/DataTable/ToggleDensityButton/index.js +18 -0
- package/dist/ComplexComponents/DataTable/ToggleDensityButton/index.tsx +47 -0
- package/dist/ComplexComponents/DataTable/ToggleFullScreenButton/index.js +19 -0
- package/dist/ComplexComponents/DataTable/ToggleFullScreenButton/index.tsx +59 -0
- package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/ToolbarAlertBanner.module.css +15 -0
- package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/index.js +8 -0
- package/dist/ComplexComponents/DataTable/ToolbarAlertBanner/index.tsx +20 -0
- package/dist/ComplexComponents/DataTable/hooks/useClickOutside.js +27 -0
- package/dist/ComplexComponents/DataTable/hooks/useClickOutside.ts +39 -0
- package/dist/ComplexComponents/DataTable/index.js +5 -1
- package/dist/ComplexComponents/DataTable/index.ts +13 -2
- package/dist/ComplexComponents/DataTable/table.module.css +9 -0
- package/dist/ComplexComponents/DataTable/tableFeatures.js +6 -0
- package/dist/ComplexComponents/DataTable/tableFeatures.ts +7 -0
- package/dist/ComplexComponents/DataTable/translations/en.js +16 -4
- package/dist/ComplexComponents/DataTable/translations/en.ts +16 -4
- package/dist/ComplexComponents/DataTable/translations/index.js +5 -0
- package/dist/ComplexComponents/DataTable/translations/index.ts +11 -1
- package/dist/ComplexComponents/DataTable/types.js +5 -0
- package/dist/ComplexComponents/DataTable/types.ts +17 -0
- package/dist/ComplexComponents/DataTable/utils/parseCSSVarId.js +3 -0
- package/dist/ComplexComponents/DataTable/utils/parseCSSVarId.ts +4 -0
- package/dist/DESIGN.md +9 -10
- package/dist/contracts/DataTable.json +83 -6
- package/dist/contracts/index.json +1 -1
- package/dist/css/foundations.css +4 -0
- package/dist/css/mantine.css +1 -1
- package/dist/css/tokens.css +3145 -0
- package/dist/index.js +3 -0
- package/dist/index.ts +14 -1
- package/dist/stories/ComplexComponents/DataTable/DataTable.stories.tsx +216 -458
- package/dist/stories/index.json +13 -15
- package/package.json +5 -3
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.js +0 -31
- package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.tsx +0 -76
- package/dist/hooks/useTableHandlers.js +0 -136
- package/dist/hooks/useTableHandlers.ts +0 -179
- package/dist/hooks/useTableRenderFunctions.js +0 -164
- package/dist/hooks/useTableRenderFunctions.tsx +0 -283
- package/dist/hooks/useTableState.js +0 -70
- package/dist/hooks/useTableState.ts +0 -81
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
.rootGrid {
|
|
2
|
+
display: grid;
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.rootGrid:has(.emptyRow) {
|
|
7
|
+
flex: 1 1 auto;
|
|
8
|
+
min-height: 100%;
|
|
9
|
+
grid-template-rows: auto 1fr;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.body {
|
|
13
|
+
min-height: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.body:has(.emptyRow) {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.headRow {
|
|
22
|
+
background-color: var(--ad-table-header-bg);
|
|
23
|
+
display: flex;
|
|
24
|
+
position: sticky;
|
|
25
|
+
top: 0;
|
|
26
|
+
z-index: var(--ad-table-header-z-index);
|
|
27
|
+
box-shadow: var(--ad-table-header-shadow);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.bodyRow {
|
|
31
|
+
display: flex;
|
|
32
|
+
width: 100%;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.bodyRow[data-selected="true"],
|
|
37
|
+
.bodyRow[data-selected="true"] .bodyCell {
|
|
38
|
+
background-color: var(--ad-table-row-selected-bg);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.headCell,
|
|
42
|
+
.bodyCell {
|
|
43
|
+
align-items: center;
|
|
44
|
+
display: flex;
|
|
45
|
+
justify-content: flex-start;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
position: relative;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.bodyCell:has([data-cell-hover-reveal]) {
|
|
51
|
+
overflow: visible;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.emptyRow {
|
|
55
|
+
display: flex;
|
|
56
|
+
flex: 1 1 auto;
|
|
57
|
+
width: 100%;
|
|
58
|
+
min-height: var(--ad-table-grid-empty-min-height);
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.emptyCell {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex: 1 1 auto;
|
|
66
|
+
width: 100%;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
align-items: center;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Density drives Mantine's table spacing vars from the density tokens. */
|
|
72
|
+
.rootGrid[data-density="xs"] {
|
|
73
|
+
--table-horizontal-spacing: var(--ad-table-cell-density-xs-padding-x);
|
|
74
|
+
--table-vertical-spacing: var(--ad-table-cell-density-xs-padding-y);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.rootGrid[data-density="md"] {
|
|
78
|
+
--table-horizontal-spacing: var(--ad-table-cell-density-md-padding-x);
|
|
79
|
+
--table-vertical-spacing: var(--ad-table-cell-density-md-padding-y);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.rootGrid[data-density="xl"] {
|
|
83
|
+
--table-horizontal-spacing: var(--ad-table-cell-density-xl-padding-x);
|
|
84
|
+
--table-vertical-spacing: var(--ad-table-cell-density-xl-padding-y);
|
|
85
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client'; // DS-ADAPT: Next.js App Router
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Source of truth: micro-ui-ts/src/components/Table/DataTableGrid/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
|
|
4
|
+
import React, { useMemo } from "react";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { Skeleton, Table, TableTbody, TableTd, TableTh, TableThead, TableTr } from "@mantine/core";
|
|
7
|
+
import parseCSSVarId from "../utils/parseCSSVarId.js";
|
|
8
|
+
import rowStyles from "../table.module.css";
|
|
9
|
+
import styles from "./DataTableGrid.module.css";
|
|
10
|
+
/** Column sizes are CSS variables on the table. Width and flex are Mantine style props. */
|
|
11
|
+
const getCellSizeProps = (columnId, minSize = 40) => {
|
|
12
|
+
const size = `var(--col-${parseCSSVarId(columnId)}-size)`;
|
|
13
|
+
return {
|
|
14
|
+
miw: `max(calc(${size} * 1px), ${minSize}px)`,
|
|
15
|
+
w: `calc(${size} * 1px)`,
|
|
16
|
+
flex: `${size} 0 auto`,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const DataTableGrid = ({ table, density, rowSelection, isLoading, pageSize, emptyFallback, }) => {
|
|
20
|
+
const rows = table.getRowModel().rows;
|
|
21
|
+
const leafColumns = table.getAllLeafColumns();
|
|
22
|
+
const showSkeletons = isLoading && rows.length === 0;
|
|
23
|
+
const showEmpty = !isLoading && rows.length === 0;
|
|
24
|
+
const skeletonRowCount = Math.min(pageSize, 20);
|
|
25
|
+
const columnSizeVars = useMemo(() => {
|
|
26
|
+
const vars = {};
|
|
27
|
+
leafColumns.forEach(column => {
|
|
28
|
+
const size = column.getSize();
|
|
29
|
+
const parsedId = parseCSSVarId(column.id);
|
|
30
|
+
vars[`--header-${parsedId}-size`] = size;
|
|
31
|
+
vars[`--col-${parsedId}-size`] = size;
|
|
32
|
+
});
|
|
33
|
+
return vars;
|
|
34
|
+
}, [leafColumns, table.state.columnSizing]);
|
|
35
|
+
const renderBody = () => {
|
|
36
|
+
if (showSkeletons) {
|
|
37
|
+
return (_jsx(_Fragment, { children: Array.from({ length: skeletonRowCount }, (_, rowIndex) => (_jsx(TableTr, { className: styles.bodyRow, children: leafColumns.map(column => (_jsx(TableTd, { className: styles.bodyCell, ...getCellSizeProps(column.id, column.columnDef.minSize ?? 40), children: _jsx(Skeleton, { height: 20 }) }, `skeleton-${rowIndex}-${column.id}`))) }, `skeleton-${rowIndex}`))) }));
|
|
38
|
+
}
|
|
39
|
+
if (showEmpty) {
|
|
40
|
+
return (_jsx(TableTr, { className: clsx(styles.bodyRow, styles.emptyRow), children: _jsx(TableTd, { className: styles.emptyCell, colSpan: leafColumns.length, children: emptyFallback }) }));
|
|
41
|
+
}
|
|
42
|
+
return (_jsx(_Fragment, { children: rows.map(row => (_jsx(TableTr, { className: clsx(styles.bodyRow, rowStyles["table-row"]), "data-selected": rowSelection[row.id] ? "true" : undefined, children: row.getAllCells().map(cell => (_jsx(TableTd, { className: styles.bodyCell, ...getCellSizeProps(cell.column.id, cell.column.columnDef.minSize ?? 40), children: _jsx(table.FlexRender, { cell: cell }) }, cell.id))) }, row.id))) }));
|
|
43
|
+
};
|
|
44
|
+
return (_jsxs(Table, { className: styles.rootGrid, highlightOnHover: false, "data-density": density, withRowBorders: true, withTableBorder: false, __vars: columnSizeVars, children: [_jsx(TableThead, { children: table.getHeaderGroups().map(headerGroup => (_jsx(TableTr, { className: styles.headRow, children: headerGroup.headers.map(header => (_jsx(TableTh, { className: styles.headCell, ...getCellSizeProps(header.column.id, header.column.columnDef.minSize ?? 40), children: header.isPlaceholder ? null : _jsx(table.FlexRender, { header: header }) }, header.id))) }, headerGroup.id))) }), _jsx(TableTbody, { className: styles.body, children: renderBody() })] }));
|
|
45
|
+
};
|
|
46
|
+
export default DataTableGrid;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use client'; // DS-ADAPT: Next.js App Router
|
|
2
|
+
// Source of truth: micro-ui-ts/src/components/Table/DataTableGrid/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
|
|
3
|
+
import React, { useMemo, type ComponentProps, type ReactElement, type ReactNode } from "react";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
import { Skeleton, Table, TableTbody, TableTd, TableTh, TableThead, TableTr } from "@mantine/core";
|
|
6
|
+
import { type ReactTable, type RowData } from "@tanstack/react-table";
|
|
7
|
+
import { dataTableFeatures } from "../tableFeatures";
|
|
8
|
+
import { type DensityState, type RowSelectionState } from "../types";
|
|
9
|
+
import parseCSSVarId from "../utils/parseCSSVarId";
|
|
10
|
+
import rowStyles from "../table.module.css";
|
|
11
|
+
import styles from "./DataTableGrid.module.css";
|
|
12
|
+
|
|
13
|
+
interface DataTableGridProps<TData extends RowData> {
|
|
14
|
+
table: ReactTable<typeof dataTableFeatures, TData>;
|
|
15
|
+
density: DensityState;
|
|
16
|
+
rowSelection: RowSelectionState;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
pageSize: number;
|
|
19
|
+
emptyFallback?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Column sizes are CSS variables on the table. Width and flex are Mantine style props. */
|
|
23
|
+
const getCellSizeProps = (
|
|
24
|
+
columnId: string,
|
|
25
|
+
minSize = 40
|
|
26
|
+
): { miw: string; w: string; flex: string } => {
|
|
27
|
+
const size = `var(--col-${parseCSSVarId(columnId)}-size)`;
|
|
28
|
+
return {
|
|
29
|
+
miw: `max(calc(${size} * 1px), ${minSize}px)`,
|
|
30
|
+
w: `calc(${size} * 1px)`,
|
|
31
|
+
flex: `${size} 0 auto`,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const DataTableGrid = <TData extends RowData>({
|
|
36
|
+
table,
|
|
37
|
+
density,
|
|
38
|
+
rowSelection,
|
|
39
|
+
isLoading,
|
|
40
|
+
pageSize,
|
|
41
|
+
emptyFallback,
|
|
42
|
+
}: DataTableGridProps<TData>): ReactElement => {
|
|
43
|
+
const rows = table.getRowModel().rows;
|
|
44
|
+
const leafColumns = table.getAllLeafColumns();
|
|
45
|
+
const showSkeletons = isLoading && rows.length === 0;
|
|
46
|
+
const showEmpty = !isLoading && rows.length === 0;
|
|
47
|
+
const skeletonRowCount = Math.min(pageSize, 20);
|
|
48
|
+
|
|
49
|
+
const columnSizeVars = useMemo(() => {
|
|
50
|
+
const vars: Record<string, number> = {};
|
|
51
|
+
leafColumns.forEach(column => {
|
|
52
|
+
const size = column.getSize();
|
|
53
|
+
const parsedId = parseCSSVarId(column.id);
|
|
54
|
+
vars[`--header-${parsedId}-size`] = size;
|
|
55
|
+
vars[`--col-${parsedId}-size`] = size;
|
|
56
|
+
});
|
|
57
|
+
return vars;
|
|
58
|
+
}, [leafColumns, table.state.columnSizing]);
|
|
59
|
+
|
|
60
|
+
const renderBody = (): ReactElement => {
|
|
61
|
+
if (showSkeletons) {
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
{Array.from({ length: skeletonRowCount }, (_, rowIndex) => (
|
|
65
|
+
<TableTr key={`skeleton-${rowIndex}`} className={styles.bodyRow}>
|
|
66
|
+
{leafColumns.map(column => (
|
|
67
|
+
<TableTd
|
|
68
|
+
key={`skeleton-${rowIndex}-${column.id}`}
|
|
69
|
+
className={styles.bodyCell}
|
|
70
|
+
{...getCellSizeProps(column.id, column.columnDef.minSize ?? 40)}
|
|
71
|
+
>
|
|
72
|
+
<Skeleton height={20} />
|
|
73
|
+
</TableTd>
|
|
74
|
+
))}
|
|
75
|
+
</TableTr>
|
|
76
|
+
))}
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (showEmpty) {
|
|
82
|
+
return (
|
|
83
|
+
<TableTr className={clsx(styles.bodyRow, styles.emptyRow)}>
|
|
84
|
+
<TableTd className={styles.emptyCell} colSpan={leafColumns.length}>
|
|
85
|
+
{emptyFallback}
|
|
86
|
+
</TableTd>
|
|
87
|
+
</TableTr>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<>
|
|
93
|
+
{rows.map(row => (
|
|
94
|
+
<TableTr
|
|
95
|
+
key={row.id}
|
|
96
|
+
className={clsx(styles.bodyRow, rowStyles["table-row"])}
|
|
97
|
+
data-selected={rowSelection[row.id] ? "true" : undefined}
|
|
98
|
+
>
|
|
99
|
+
{row.getAllCells().map(cell => (
|
|
100
|
+
<TableTd
|
|
101
|
+
key={cell.id}
|
|
102
|
+
className={styles.bodyCell}
|
|
103
|
+
{...getCellSizeProps(cell.column.id, cell.column.columnDef.minSize ?? 40)}
|
|
104
|
+
>
|
|
105
|
+
<table.FlexRender cell={cell} />
|
|
106
|
+
</TableTd>
|
|
107
|
+
))}
|
|
108
|
+
</TableTr>
|
|
109
|
+
))}
|
|
110
|
+
</>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<Table
|
|
116
|
+
className={styles.rootGrid}
|
|
117
|
+
highlightOnHover={false}
|
|
118
|
+
data-density={density}
|
|
119
|
+
withRowBorders
|
|
120
|
+
withTableBorder={false}
|
|
121
|
+
__vars={columnSizeVars as unknown as ComponentProps<typeof Table>["__vars"]} // DS-ADAPT: Mantine 9 CssVarsProp typing
|
|
122
|
+
>
|
|
123
|
+
<TableThead>
|
|
124
|
+
{table.getHeaderGroups().map(headerGroup => (
|
|
125
|
+
<TableTr key={headerGroup.id} className={styles.headRow}>
|
|
126
|
+
{headerGroup.headers.map(header => (
|
|
127
|
+
<TableTh
|
|
128
|
+
key={header.id}
|
|
129
|
+
className={styles.headCell}
|
|
130
|
+
{...getCellSizeProps(header.column.id, header.column.columnDef.minSize ?? 40)}
|
|
131
|
+
>
|
|
132
|
+
{header.isPlaceholder ? null : <table.FlexRender header={header} />}
|
|
133
|
+
</TableTh>
|
|
134
|
+
))}
|
|
135
|
+
</TableTr>
|
|
136
|
+
))}
|
|
137
|
+
</TableThead>
|
|
138
|
+
<TableTbody className={styles.body}>{renderBody()}</TableTbody>
|
|
139
|
+
</Table>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export default DataTableGrid;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.shell {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.fullscreen {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
position: fixed;
|
|
11
|
+
inset: 0;
|
|
12
|
+
width: 100vw;
|
|
13
|
+
height: 100vh;
|
|
14
|
+
max-width: 100vw;
|
|
15
|
+
max-height: 100vh;
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
border: 0;
|
|
19
|
+
border-radius: 0;
|
|
20
|
+
z-index: var(--ad-table-shell-fullscreen-z-index);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.scrollContainer {
|
|
24
|
+
position: relative;
|
|
25
|
+
z-index: 0;
|
|
26
|
+
isolation: isolate;
|
|
27
|
+
max-height: var(--ad-table-shell-scroll-max-height);
|
|
28
|
+
overflow: auto;
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.scrollContainerFullscreen {
|
|
34
|
+
flex: 1 1 auto;
|
|
35
|
+
max-height: none;
|
|
36
|
+
min-height: 0;
|
|
37
|
+
overflow: auto;
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client'; // DS-ADAPT: Next.js App Router
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Source of truth: micro-ui-ts/src/components/Table/DataTableShell/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
|
|
4
|
+
import React from "react";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { LoadingOverlay, Paper } from "@mantine/core";
|
|
7
|
+
import styles from "./DataTableShell.module.css";
|
|
8
|
+
const DataTableShell = ({ isFullScreen, isLoading, topToolbar, bottomToolbar, children, }) => (_jsxs(Paper, { withBorder: !isFullScreen, className: clsx(styles.shell, isFullScreen && styles.fullscreen), "data-testid": "data-table-shell", "data-fullscreen": isFullScreen ? "true" : undefined, children: [topToolbar, _jsxs("div", { "aria-label": "data table", className: clsx(styles.scrollContainer, isFullScreen && styles.scrollContainerFullscreen), tabIndex: 0, children: [_jsx(LoadingOverlay, { visible: isLoading, zIndex: 1, loaderProps: { color: "gray.6" }, overlayProps: { radius: 0, blur: 2 } }), children] }), bottomToolbar] }));
|
|
9
|
+
export default DataTableShell;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client'; // DS-ADAPT: Next.js App Router
|
|
2
|
+
// Source of truth: micro-ui-ts/src/components/Table/DataTableShell/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
|
|
3
|
+
import React, { type ReactElement, type ReactNode } from "react";
|
|
4
|
+
import clsx from "clsx";
|
|
5
|
+
import { LoadingOverlay, Paper } from "@mantine/core";
|
|
6
|
+
import styles from "./DataTableShell.module.css";
|
|
7
|
+
|
|
8
|
+
interface DataTableShellProps {
|
|
9
|
+
isFullScreen: boolean;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
topToolbar: ReactNode;
|
|
12
|
+
bottomToolbar: ReactNode;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DataTableShell = ({
|
|
17
|
+
isFullScreen,
|
|
18
|
+
isLoading,
|
|
19
|
+
topToolbar,
|
|
20
|
+
bottomToolbar,
|
|
21
|
+
children,
|
|
22
|
+
}: DataTableShellProps): ReactElement => (
|
|
23
|
+
<Paper
|
|
24
|
+
withBorder={!isFullScreen}
|
|
25
|
+
className={clsx(styles.shell, isFullScreen && styles.fullscreen)}
|
|
26
|
+
data-testid="data-table-shell"
|
|
27
|
+
data-fullscreen={isFullScreen ? "true" : undefined}
|
|
28
|
+
>
|
|
29
|
+
{topToolbar}
|
|
30
|
+
<div
|
|
31
|
+
aria-label="data table"
|
|
32
|
+
className={clsx(styles.scrollContainer, isFullScreen && styles.scrollContainerFullscreen)}
|
|
33
|
+
tabIndex={0}
|
|
34
|
+
>
|
|
35
|
+
<LoadingOverlay
|
|
36
|
+
visible={isLoading}
|
|
37
|
+
zIndex={1}
|
|
38
|
+
loaderProps={{ color: "gray.6" }}
|
|
39
|
+
overlayProps={{ radius: 0, blur: 2 }}
|
|
40
|
+
/>
|
|
41
|
+
{children}
|
|
42
|
+
</div>
|
|
43
|
+
{bottomToolbar}
|
|
44
|
+
</Paper>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export default DataTableShell;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
'use client'; // DS-ADAPT: Next.js App Router
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Source of truth: micro-ui-ts/src/components/Table/ErrorOverlay/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
|
|
2
4
|
import React from "react";
|
|
3
|
-
import { Stack, Text } from "@mantine/core";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return (_jsxs(Stack, { align: "center", justify: "center", h: 200, children: [_jsx(Text, { size: "lg", fw: 500, children: translate("table.error.title") }), _jsx(Text, { size: "sm", c: "dimmed", children: error || translate("table.error.default") }), onRetry && (_jsx(Button, { variant: "default", onClick: onRetry, children: translate("table.error.retry") }))] }));
|
|
8
|
-
};
|
|
5
|
+
import { Button, Flex, Stack, Text, ThemeIcon, Title, } from "@mantine/core";
|
|
6
|
+
import { RiErrorWarningFill as ErrorWarningFillIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
|
|
7
|
+
const ErrorOverlay = ({ title, description, SVGIcon, actions, my, }) => (_jsxs(Stack, { "data-testid": "error-overlay", align: "center", my: my, children: [_jsx(ThemeIcon, { color: "black", variant: "white", size: "xl", children: (SVGIcon &&
|
|
8
|
+
(typeof SVGIcon === "function" ? (_jsx(SVGIcon, { "data-testid": "error-custom-warning-icon" })) : (React.cloneElement(SVGIcon)))) ?? _jsx(ErrorWarningFillIcon, { "data-testid": "error-default-warning-icon" }) }), _jsx(Title, { order: 1, children: title }), _jsx(Text, { size: "sm", children: description }), actions && (_jsx(Flex, { "data-testid": "error-actions-wrapper", gap: "md", children: actions.map(({ label, onClick, variant }) => (_jsx(Button, { onClick: onClick, variant: variant, children: label }, label))) }))] }));
|
|
9
9
|
export default ErrorOverlay;
|
|
@@ -1,29 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
'use client'; // DS-ADAPT: Next.js App Router
|
|
2
|
+
// Source of truth: micro-ui-ts/src/components/Table/ErrorOverlay/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
|
|
3
|
+
import React, { JSX, ReactElement } from "react";
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
ButtonProps,
|
|
7
|
+
Flex,
|
|
8
|
+
Stack,
|
|
9
|
+
StackProps,
|
|
10
|
+
Text,
|
|
11
|
+
ThemeIcon,
|
|
12
|
+
Title,
|
|
13
|
+
} from "@mantine/core";
|
|
14
|
+
import { RiErrorWarningFill as ErrorWarningFillIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
|
|
5
15
|
|
|
6
|
-
interface ErrorOverlayProps {
|
|
7
|
-
|
|
8
|
-
|
|
16
|
+
export interface ErrorOverlayProps {
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
SVGIcon?: React.FunctionComponent<React.SVGAttributes<SVGElement>> | ReactElement;
|
|
20
|
+
actions?: {
|
|
21
|
+
label: string;
|
|
22
|
+
onClick?: () => void;
|
|
23
|
+
variant?: ButtonProps["variant"];
|
|
24
|
+
}[];
|
|
25
|
+
my?: StackProps["my"];
|
|
9
26
|
}
|
|
10
27
|
|
|
11
|
-
const ErrorOverlay = ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
+
const ErrorOverlay = ({
|
|
29
|
+
title,
|
|
30
|
+
description,
|
|
31
|
+
SVGIcon,
|
|
32
|
+
actions,
|
|
33
|
+
my,
|
|
34
|
+
}: ErrorOverlayProps): JSX.Element => (
|
|
35
|
+
<Stack data-testid="error-overlay" align="center" my={my}>
|
|
36
|
+
<ThemeIcon color="black" variant="white" size="xl">
|
|
37
|
+
{(SVGIcon &&
|
|
38
|
+
(typeof SVGIcon === "function" ? (
|
|
39
|
+
<SVGIcon data-testid="error-custom-warning-icon" />
|
|
40
|
+
) : (
|
|
41
|
+
React.cloneElement(SVGIcon)
|
|
42
|
+
))) ?? <ErrorWarningFillIcon data-testid="error-default-warning-icon" />}
|
|
43
|
+
</ThemeIcon>
|
|
44
|
+
<Title order={1}>{title}</Title>
|
|
45
|
+
<Text size="sm">{description}</Text>
|
|
46
|
+
{actions && (
|
|
47
|
+
<Flex data-testid="error-actions-wrapper" gap="md">
|
|
48
|
+
{actions.map(({ label, onClick, variant }) => (
|
|
49
|
+
<Button key={label} onClick={onClick} variant={variant}>
|
|
50
|
+
{label}
|
|
51
|
+
</Button>
|
|
52
|
+
))}
|
|
53
|
+
</Flex>
|
|
54
|
+
)}
|
|
55
|
+
</Stack>
|
|
56
|
+
);
|
|
28
57
|
|
|
29
58
|
export default ErrorOverlay;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'; // DS-ADAPT: Next.js App Router
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
// Source of truth: micro-ui-ts/src/components/Table/SelectCheckbox/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
|
|
4
|
+
import React, { createContext, useContext } from "react";
|
|
5
|
+
import { Checkbox } from "@mantine/core";
|
|
6
|
+
export const RowSelectionContext = createContext({});
|
|
7
|
+
const SelectCheckbox = ({ table, row, }) => {
|
|
8
|
+
const rowSelection = useContext(RowSelectionContext);
|
|
9
|
+
const selectAll = !row;
|
|
10
|
+
const pageRows = table.getRowModel().rows;
|
|
11
|
+
const isChecked = selectAll
|
|
12
|
+
? pageRows.length > 0 && pageRows.every(pageRow => rowSelection[pageRow.id])
|
|
13
|
+
: Boolean(rowSelection[row.id]);
|
|
14
|
+
const isIndeterminate = selectAll && !isChecked && pageRows.some(pageRow => rowSelection[pageRow.id]);
|
|
15
|
+
const onChange = () => {
|
|
16
|
+
if (selectAll) {
|
|
17
|
+
table.toggleAllRowsSelected();
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
row.toggleSelected();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return (_jsx(Checkbox, { "aria-label": selectAll ? "Toggle select all" : "Toggle select row", checked: isChecked, indeterminate: isIndeterminate, onChange: onChange, onClick: (event) => event.stopPropagation(), size: "xs" }));
|
|
24
|
+
};
|
|
25
|
+
export const getSelectColumnDef = (columnHelper) => columnHelper.display({
|
|
26
|
+
id: "mrt-row-select",
|
|
27
|
+
size: 50,
|
|
28
|
+
minSize: 50,
|
|
29
|
+
maxSize: 50,
|
|
30
|
+
header: ({ table: tableInstance }) => _jsx(SelectCheckbox, { table: tableInstance }),
|
|
31
|
+
cell: ({ row, table: tableInstance }) => _jsx(SelectCheckbox, { table: tableInstance, row: row }),
|
|
32
|
+
});
|
|
33
|
+
export default SelectCheckbox;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client'; // DS-ADAPT: Next.js App Router
|
|
2
|
+
// Source of truth: micro-ui-ts/src/components/Table/SelectCheckbox/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
|
|
3
|
+
import React, { createContext, useContext, type ReactElement } from "react";
|
|
4
|
+
import { Checkbox } from "@mantine/core";
|
|
5
|
+
import { type ColumnHelper, type Row, type RowData, type Table } from "@tanstack/react-table";
|
|
6
|
+
import { dataTableFeatures } from "../tableFeatures";
|
|
7
|
+
import { type RowSelectionState } from "../types";
|
|
8
|
+
|
|
9
|
+
export const RowSelectionContext = createContext<RowSelectionState>({});
|
|
10
|
+
|
|
11
|
+
interface SelectCheckboxProps<TData extends RowData> {
|
|
12
|
+
table: Table<typeof dataTableFeatures, TData>;
|
|
13
|
+
row?: Row<typeof dataTableFeatures, TData>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const SelectCheckbox = <TData extends RowData>({
|
|
17
|
+
table,
|
|
18
|
+
row,
|
|
19
|
+
}: SelectCheckboxProps<TData>): ReactElement => {
|
|
20
|
+
const rowSelection = useContext(RowSelectionContext);
|
|
21
|
+
const selectAll = !row;
|
|
22
|
+
|
|
23
|
+
const pageRows = table.getRowModel().rows;
|
|
24
|
+
const isChecked = selectAll
|
|
25
|
+
? pageRows.length > 0 && pageRows.every(pageRow => rowSelection[pageRow.id])
|
|
26
|
+
: Boolean(rowSelection[row.id]);
|
|
27
|
+
|
|
28
|
+
const isIndeterminate =
|
|
29
|
+
selectAll && !isChecked && pageRows.some(pageRow => rowSelection[pageRow.id]);
|
|
30
|
+
|
|
31
|
+
const onChange = (): void => {
|
|
32
|
+
if (selectAll) {
|
|
33
|
+
table.toggleAllRowsSelected();
|
|
34
|
+
} else {
|
|
35
|
+
row.toggleSelected();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Checkbox
|
|
41
|
+
aria-label={selectAll ? "Toggle select all" : "Toggle select row"}
|
|
42
|
+
checked={isChecked}
|
|
43
|
+
indeterminate={isIndeterminate}
|
|
44
|
+
onChange={onChange}
|
|
45
|
+
onClick={(event): void => event.stopPropagation()}
|
|
46
|
+
size="xs"
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const getSelectColumnDef = <TData extends RowData>(
|
|
52
|
+
columnHelper: ColumnHelper<typeof dataTableFeatures, TData>
|
|
53
|
+
): ReturnType<ColumnHelper<typeof dataTableFeatures, TData>["display"]> =>
|
|
54
|
+
columnHelper.display({
|
|
55
|
+
id: "mrt-row-select",
|
|
56
|
+
size: 50,
|
|
57
|
+
minSize: 50,
|
|
58
|
+
maxSize: 50,
|
|
59
|
+
header: ({ table: tableInstance }) => <SelectCheckbox table={tableInstance} />,
|
|
60
|
+
cell: ({ row, table: tableInstance }) => <SelectCheckbox table={tableInstance} row={row} />,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export default SelectCheckbox;
|
|
@@ -1,27 +1,49 @@
|
|
|
1
|
+
'use client'; // DS-ADAPT: Next.js App Router
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Source of truth: micro-ui-ts/src/components/Table/SortableHeaderCell/index.tsx. Keep in sync; DS-only changes are marked DS-ADAPT.
|
|
2
4
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
import { Flex, rem, UnstyledButton } from "@mantine/core";
|
|
6
|
+
import { translate } from "../translations/index.js"; // DS-ADAPT: translate lives in DataTable/translations
|
|
7
|
+
import { RiSortAsc as SortAscIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
|
|
8
|
+
import { RiSortDesc as SortDescIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
|
|
9
|
+
import { RiArrowUpDownLine as UpDownIcon } from "@remixicon/react"; // DS-ADAPT: @remixicon/react instead of remixicon svg import
|
|
10
|
+
import styles from "./SortableHeaderCell.module.css";
|
|
11
|
+
export var SortDirection;
|
|
12
|
+
(function (SortDirection) {
|
|
13
|
+
SortDirection["ASC"] = "asc";
|
|
14
|
+
SortDirection["DESC"] = "desc";
|
|
15
|
+
SortDirection["DEFAULT"] = "default";
|
|
16
|
+
})(SortDirection || (SortDirection = {}));
|
|
17
|
+
const iconSize = {
|
|
18
|
+
width: rem(12),
|
|
19
|
+
height: rem(12),
|
|
20
|
+
};
|
|
21
|
+
const iconDirectionMap = {
|
|
22
|
+
[SortDirection.ASC]: (_jsx(SortAscIcon, { style: { color: "var(--ad-table-header-sort-active-fg)", ...iconSize } })),
|
|
23
|
+
[SortDirection.DESC]: (_jsx(SortDescIcon, { style: { color: "var(--ad-table-header-sort-active-fg)", ...iconSize } })),
|
|
24
|
+
[SortDirection.DEFAULT]: _jsx(UpDownIcon, { "data-testid": "default-sort-icon", style: iconSize }),
|
|
25
|
+
};
|
|
26
|
+
const SortableHeaderCell = ({ id, label, sortingState, onSort, }) => {
|
|
27
|
+
const sortDirection = sortingState.field === id ? sortingState.direction : SortDirection.DEFAULT;
|
|
28
|
+
const onSortClick = () => {
|
|
29
|
+
let newSortDirection;
|
|
30
|
+
if (sortDirection === SortDirection.DEFAULT) {
|
|
31
|
+
newSortDirection = SortDirection.ASC;
|
|
32
|
+
}
|
|
33
|
+
else if (sortDirection === SortDirection.ASC) {
|
|
34
|
+
newSortDirection = SortDirection.DESC;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
newSortDirection = SortDirection.DEFAULT;
|
|
18
38
|
}
|
|
39
|
+
onSort({ direction: newSortDirection, field: id });
|
|
19
40
|
};
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
// DS-ADAPT: keyboard-focusable button with a sort aria-label (a11y)
|
|
42
|
+
const nextDirectionLabel = {
|
|
43
|
+
[SortDirection.DEFAULT]: translate("table.sort.asc"),
|
|
44
|
+
[SortDirection.ASC]: translate("table.sort.desc"),
|
|
45
|
+
[SortDirection.DESC]: translate("table.sort.none"),
|
|
46
|
+
}[sortDirection];
|
|
47
|
+
return (_jsx(UnstyledButton, { type: "button", className: styles.header, onClick: onSortClick, "aria-label": translate("table.sort.aria", { column: label, direction: nextDirectionLabel }), children: _jsxs(Flex, { align: "center", justify: "center", gap: "xs", children: [label, iconDirectionMap[sortDirection]] }) }));
|
|
26
48
|
};
|
|
27
49
|
export default SortableHeaderCell;
|