@veritone-ce/design-system 2.3.13 → 2.4.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/cjs/StatusChip/index.js +65 -0
- package/dist/cjs/StatusChip/styles.module.scss.js +7 -0
- package/dist/cjs/Table/AutoTable/common.js +144 -0
- package/dist/cjs/Table/AutoTable/controlled.js +102 -0
- package/dist/cjs/Table/AutoTable/index.js +110 -0
- package/dist/cjs/Table/AutoTable/virtual.js +177 -0
- package/dist/cjs/Table/TableCell/index.js +50 -0
- package/dist/cjs/Table/TableCell/styles.module.scss.js +7 -0
- package/dist/cjs/Table/TableRow/index.js +34 -0
- package/dist/cjs/Table/TableRow/styles.module.scss.js +7 -0
- package/dist/cjs/Table/index.js +76 -0
- package/dist/cjs/Table/styles.module.scss.js +7 -0
- package/dist/cjs/Tooltip/index.js +38 -26
- package/dist/cjs/Tooltip/styles.module.scss.js +1 -1
- package/dist/cjs/Typography/index.js +4 -2
- package/dist/cjs/Typography/variants.module.scss.js +1 -1
- package/dist/cjs/index.js +27 -10
- package/dist/cjs/styles/createPalette.js +24 -4
- package/dist/cjs/styles/typography.js +9 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/StatusChip/index.js +61 -0
- package/dist/esm/StatusChip/styles.module.scss.js +3 -0
- package/dist/esm/Table/AutoTable/common.js +138 -0
- package/dist/esm/Table/AutoTable/controlled.js +98 -0
- package/dist/esm/Table/AutoTable/index.js +106 -0
- package/dist/esm/Table/AutoTable/virtual.js +172 -0
- package/dist/esm/Table/TableCell/index.js +46 -0
- package/dist/esm/Table/TableCell/styles.module.scss.js +3 -0
- package/dist/esm/Table/TableRow/index.js +30 -0
- package/dist/esm/Table/TableRow/styles.module.scss.js +3 -0
- package/dist/esm/Table/index.js +69 -0
- package/dist/esm/Table/styles.module.scss.js +3 -0
- package/dist/esm/Tooltip/index.js +38 -26
- package/dist/esm/Tooltip/styles.module.scss.js +1 -1
- package/dist/esm/Typography/index.js +4 -2
- package/dist/esm/Typography/variants.module.scss.js +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/styles/createPalette.js +24 -4
- package/dist/esm/styles/scss/theme.generated.scss +83 -17
- package/dist/esm/styles/typography.js +9 -1
- package/dist/esm/styles.css +1 -1
- package/dist/types/Checkbox/index.d.ts +2 -0
- package/dist/types/Dialog/components.d.ts +50 -6
- package/dist/types/Drawer/components.d.ts +50 -5
- package/dist/types/StatusChip/index.d.ts +12 -0
- package/dist/types/Table/AutoTable/common.d.ts +31 -0
- package/dist/types/Table/AutoTable/controlled.d.ts +13 -0
- package/dist/types/Table/AutoTable/index.d.ts +47 -0
- package/dist/types/Table/AutoTable/types.d.ts +106 -0
- package/dist/types/Table/AutoTable/virtual.d.ts +23 -0
- package/dist/types/Table/TableCell/index.d.ts +14 -0
- package/dist/types/Table/TableRow/index.d.ts +10 -0
- package/dist/types/Table/index.d.ts +68 -0
- package/dist/types/Typography/index.d.ts +11 -3
- package/dist/types/index.d.ts +10 -0
- package/dist/types/styles/createPalette.d.ts +2 -0
- package/dist/types/styles/palette.d.ts +2 -0
- package/dist/types/styles/typography.d.ts +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
'use client';
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
|
+
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var styles_module = require('./styles.module.scss.js');
|
|
9
|
+
require('@capsizecss/core');
|
|
10
|
+
require('color2k');
|
|
11
|
+
require('../styles/css-vars.js');
|
|
12
|
+
var cx = require('../styles/cx.js');
|
|
13
|
+
var defaultTheme = require('../styles/defaultTheme.js');
|
|
14
|
+
require('react');
|
|
15
|
+
require('@mui/system');
|
|
16
|
+
require('../Box/index.js');
|
|
17
|
+
require('../styles/styled.js');
|
|
18
|
+
require('@mui/utils');
|
|
19
|
+
require('../Button/index.js');
|
|
20
|
+
require('../IconButton/index.js');
|
|
21
|
+
require('../Icon/internal.js');
|
|
22
|
+
var index = require('../Typography/index.js');
|
|
23
|
+
require('../Checkbox/index.js');
|
|
24
|
+
require('../Chip/index.js');
|
|
25
|
+
require('../DatePicker/index.js');
|
|
26
|
+
require('../FormControl/index.js');
|
|
27
|
+
require('../Dialog/components.js');
|
|
28
|
+
require('../Drawer/components.js');
|
|
29
|
+
require('../Icon/factory.js');
|
|
30
|
+
require('../Input/index.js');
|
|
31
|
+
require('../Menu/controlled.js');
|
|
32
|
+
require('@mui/material/usePagination');
|
|
33
|
+
require('../RadioButton/index.js');
|
|
34
|
+
require('../Select/controlled.js');
|
|
35
|
+
require('@mui/material');
|
|
36
|
+
require('../Table/AutoTable/virtual.js');
|
|
37
|
+
require('@tanstack/react-table');
|
|
38
|
+
require('../Table/TableRow/index.js');
|
|
39
|
+
require('../Table/TableCell/index.js');
|
|
40
|
+
require('../Textarea/index.js');
|
|
41
|
+
require('../Toast/hook.js');
|
|
42
|
+
require('@floating-ui/react');
|
|
43
|
+
|
|
44
|
+
const StatusChip = ({
|
|
45
|
+
children,
|
|
46
|
+
palette = defaultTheme.defaultThemeCssVariableUsages.palette.indicator.info,
|
|
47
|
+
...props
|
|
48
|
+
}) => {
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
"data-testid": props["data-testid"],
|
|
53
|
+
style: {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
"--vt-ce-status-chip-base-surface": palette.base.surface,
|
|
56
|
+
"--vt-ce-status-chip-base-on": palette.base.on,
|
|
57
|
+
...props.style
|
|
58
|
+
},
|
|
59
|
+
className: cx.cx(styles_module.default.statusChip, props.className),
|
|
60
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(index.default, { variant: "statusChip", color: "inherit", leadingTrim: true, children })
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.default = StatusChip;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var reactTable = require('@tanstack/react-table');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var index = require('../TableCell/index.js');
|
|
8
|
+
var material = require('@mui/material');
|
|
9
|
+
|
|
10
|
+
function createColumnHelper() {
|
|
11
|
+
return {
|
|
12
|
+
accessor: (accessor, column) => {
|
|
13
|
+
return typeof accessor === "function" ? {
|
|
14
|
+
...column,
|
|
15
|
+
accessorFn: accessor
|
|
16
|
+
} : {
|
|
17
|
+
...column,
|
|
18
|
+
accessorKey: accessor
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
display: (column) => column
|
|
22
|
+
// group: column => column
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function useAutoTable(options) {
|
|
26
|
+
const columnsProp = options.columns;
|
|
27
|
+
const mappedColumns = React.useMemo(
|
|
28
|
+
() => mapColumnDefs(columnsProp),
|
|
29
|
+
[columnsProp]
|
|
30
|
+
);
|
|
31
|
+
return reactTable.useReactTable({
|
|
32
|
+
data: options.data,
|
|
33
|
+
columns: mappedColumns,
|
|
34
|
+
manualSorting: options.manualSorting,
|
|
35
|
+
manualPagination: options.manualPagination,
|
|
36
|
+
enableSorting: options.enableSorting,
|
|
37
|
+
enableRowSelection: options.enableRowSelection,
|
|
38
|
+
meta: options.meta,
|
|
39
|
+
getRowId: options.getRowId,
|
|
40
|
+
defaultColumn: {
|
|
41
|
+
cell: (info) => /* @__PURE__ */ jsxRuntime.jsx(index.default, { children: info.renderValue() })
|
|
42
|
+
},
|
|
43
|
+
initialState: {
|
|
44
|
+
pagination: {
|
|
45
|
+
pageSize: options.pagination.pageSize
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
state: {
|
|
49
|
+
pagination: options.pagination,
|
|
50
|
+
sorting: options.sorting,
|
|
51
|
+
rowSelection: options.rowSelection
|
|
52
|
+
},
|
|
53
|
+
onSortingChange: (updater) => {
|
|
54
|
+
const value = typeof updater === "function" ? updater(options.sorting) : updater;
|
|
55
|
+
options.onSortingChange(value);
|
|
56
|
+
},
|
|
57
|
+
onRowSelectionChange: (updater) => {
|
|
58
|
+
const value = typeof updater === "function" ? updater(options.rowSelection) : updater;
|
|
59
|
+
options.onRowSelectionChange(value);
|
|
60
|
+
},
|
|
61
|
+
onPaginationChange: () => {
|
|
62
|
+
},
|
|
63
|
+
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
64
|
+
getSortedRowModel: reactTable.getSortedRowModel(),
|
|
65
|
+
getPaginationRowModel: reactTable.getPaginationRowModel()
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function mapColumnDefs(columnDefs) {
|
|
69
|
+
return columnDefs.map(mapColumnDef);
|
|
70
|
+
}
|
|
71
|
+
function mapColumnDef(columnDef) {
|
|
72
|
+
const meta = {
|
|
73
|
+
noVerticalPadding: columnDef.noVerticalPadding
|
|
74
|
+
};
|
|
75
|
+
const mappedDef = {
|
|
76
|
+
id: columnDef.id,
|
|
77
|
+
accessorFn: columnDef.accessorFn,
|
|
78
|
+
accessorKey: columnDef.accessorKey,
|
|
79
|
+
meta,
|
|
80
|
+
getUniqueValues: columnDef.getUniqueValues,
|
|
81
|
+
header: columnDef.header !== void 0 ? makeHeaderMappingComponent(columnDef.header) : void 0,
|
|
82
|
+
cell: columnDef.cell !== void 0 ? makeCellMappingComponent(columnDef.cell) : void 0,
|
|
83
|
+
enableMultiSort: columnDef.enableMultiSort,
|
|
84
|
+
enableSorting: columnDef.enableSorting,
|
|
85
|
+
invertSorting: columnDef.invertSorting,
|
|
86
|
+
sortDescFirst: columnDef.sortDescFirst,
|
|
87
|
+
sortingFn: columnDef.sortingFn,
|
|
88
|
+
sortUndefined: columnDef.sortUndefined
|
|
89
|
+
};
|
|
90
|
+
Object.keys(mappedDef).forEach((key) => {
|
|
91
|
+
const k = key;
|
|
92
|
+
if (mappedDef[k] === void 0) {
|
|
93
|
+
delete mappedDef[k];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return mappedDef;
|
|
97
|
+
}
|
|
98
|
+
function makeHeaderMappingComponent(header) {
|
|
99
|
+
if (typeof header === "string") {
|
|
100
|
+
return header;
|
|
101
|
+
}
|
|
102
|
+
return (props) => header({
|
|
103
|
+
column: props.column,
|
|
104
|
+
header: props.header,
|
|
105
|
+
table: props.table,
|
|
106
|
+
meta: props.table.options.meta
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function makeCellMappingComponent(cell) {
|
|
110
|
+
if (typeof cell === "string") {
|
|
111
|
+
return cell;
|
|
112
|
+
}
|
|
113
|
+
return (props) => cell({
|
|
114
|
+
cell: props.cell,
|
|
115
|
+
column: props.column,
|
|
116
|
+
getValue: props.getValue,
|
|
117
|
+
renderValue: props.renderValue,
|
|
118
|
+
row: props.row,
|
|
119
|
+
table: props.table,
|
|
120
|
+
meta: props.table.options.meta
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const DefaultErrorContainer = () => {
|
|
124
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
125
|
+
material.Box,
|
|
126
|
+
{
|
|
127
|
+
sx: {
|
|
128
|
+
width: "100%",
|
|
129
|
+
display: "flex",
|
|
130
|
+
justifyContent: "center",
|
|
131
|
+
alignItems: "center",
|
|
132
|
+
paddingTop: "10px",
|
|
133
|
+
paddingBottom: "10px"
|
|
134
|
+
},
|
|
135
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Some error message" })
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
exports.DefaultErrorContainer = DefaultErrorContainer;
|
|
141
|
+
exports.createColumnHelper = createColumnHelper;
|
|
142
|
+
exports.mapColumnDef = mapColumnDef;
|
|
143
|
+
exports.mapColumnDefs = mapColumnDefs;
|
|
144
|
+
exports.useAutoTable = useAutoTable;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
'use client';
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
|
+
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var reactTable = require('@tanstack/react-table');
|
|
9
|
+
var index = require('../index.js');
|
|
10
|
+
var index$1 = require('../TableRow/index.js');
|
|
11
|
+
var index$2 = require('../TableCell/index.js');
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var utils = require('@mui/utils');
|
|
14
|
+
var common = require('./common.js');
|
|
15
|
+
var index$4 = require('../../TablePagination/index.js');
|
|
16
|
+
var index$3 = require('../../CircularProgress/index.js');
|
|
17
|
+
|
|
18
|
+
function ControlledAutoTable({
|
|
19
|
+
stickyHeader,
|
|
20
|
+
loading,
|
|
21
|
+
zeroStateMessage,
|
|
22
|
+
error,
|
|
23
|
+
ErrorContainer = common.DefaultErrorContainer,
|
|
24
|
+
className,
|
|
25
|
+
...options
|
|
26
|
+
}) {
|
|
27
|
+
const table = common.useAutoTable(options);
|
|
28
|
+
const rows = options.data;
|
|
29
|
+
const manualRowCount = options.manualRowCount ?? rows.length;
|
|
30
|
+
const showMessage = error || loading || rows.length === 0;
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
32
|
+
index.Table,
|
|
33
|
+
{
|
|
34
|
+
sx: {
|
|
35
|
+
borderCollapse: "separate",
|
|
36
|
+
...stickyHeader ? {
|
|
37
|
+
"& th": {
|
|
38
|
+
position: "sticky",
|
|
39
|
+
top: typeof stickyHeader === "object" ? stickyHeader.offset : 0,
|
|
40
|
+
zIndex: 2,
|
|
41
|
+
backgroundColor: (theme) => theme.palette.background.default
|
|
42
|
+
}
|
|
43
|
+
} : {}
|
|
44
|
+
},
|
|
45
|
+
children: [
|
|
46
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxRuntime.jsx(index$1.default, { children: headerGroup.headers.map((header) => {
|
|
47
|
+
const isSorted = header.column.getIsSorted();
|
|
48
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index$2.default, { variant: "header", children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
49
|
+
index.TableSortLabel,
|
|
50
|
+
{
|
|
51
|
+
active: isSorted !== false,
|
|
52
|
+
direction: isSorted !== false ? isSorted : "asc",
|
|
53
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
54
|
+
children: [
|
|
55
|
+
reactTable.flexRender(
|
|
56
|
+
header.column.columnDef.header,
|
|
57
|
+
header.getContext()
|
|
58
|
+
),
|
|
59
|
+
isSorted !== false ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: utils.visuallyHidden, children: isSorted === "desc" ? "sorted descending" : "sorted ascending" }) : null
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
) : reactTable.flexRender(
|
|
63
|
+
header.column.columnDef.header,
|
|
64
|
+
header.getContext()
|
|
65
|
+
) }, header.id);
|
|
66
|
+
}) }, headerGroup.id)) }),
|
|
67
|
+
showMessage ? /* @__PURE__ */ jsxRuntime.jsx(index.TableBody, { children: /* @__PURE__ */ jsxRuntime.jsx(index$1.default, { children: /* @__PURE__ */ jsxRuntime.jsx(index$2.default, { colSpan: table.getAllFlatColumns().length, children: error ? /* @__PURE__ */ jsxRuntime.jsx(ErrorContainer, { error }) : loading ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
style: {
|
|
71
|
+
display: "flex",
|
|
72
|
+
justifyContent: "center",
|
|
73
|
+
paddingTop: "10px",
|
|
74
|
+
paddingBottom: "10px"
|
|
75
|
+
},
|
|
76
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(index$3.default, {})
|
|
77
|
+
}
|
|
78
|
+
) : rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(index.TableMessage, { children: zeroStateMessage ?? "No data found" }) : null }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(index.TableBody, { children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsxRuntime.jsx(index$1.default, { children: row.getAllCells().map((cell) => /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)) }, row.id)) }),
|
|
79
|
+
options.enablePagination && (options.manualPagination ? manualRowCount : options.data.length) > table.initialState.pagination.pageSize && /* @__PURE__ */ jsxRuntime.jsx(index.TableFooter, { children: /* @__PURE__ */ jsxRuntime.jsx(index$1.default, { children: /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: table.getAllFlatColumns().length, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
80
|
+
index$4.default,
|
|
81
|
+
{
|
|
82
|
+
count: options.manualPagination ? manualRowCount : table.getFilteredRowModel().rows.length,
|
|
83
|
+
rowsPerPage: table.getState().pagination.pageSize,
|
|
84
|
+
page: table.getState().pagination.pageIndex + 1,
|
|
85
|
+
onChangePage: (newPage) => {
|
|
86
|
+
table.setPageIndex(newPage - 1);
|
|
87
|
+
options.onPageChange(newPage - 1);
|
|
88
|
+
},
|
|
89
|
+
rowsPerPageOptions: [10, 25, 50, 100],
|
|
90
|
+
onRowsPerPageChange: (rowsPerPage) => {
|
|
91
|
+
const size = rowsPerPage ?? 10;
|
|
92
|
+
table.setPageSize(size);
|
|
93
|
+
options.onRowsPerPageChange(size);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
) }) }) })
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
) });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
exports.default = ControlledAutoTable;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
'use client';
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
|
+
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var virtual = require('./virtual.js');
|
|
10
|
+
var controlled = require('./controlled.js');
|
|
11
|
+
require('@tanstack/react-table');
|
|
12
|
+
require('../TableCell/index.js');
|
|
13
|
+
require('@mui/material');
|
|
14
|
+
|
|
15
|
+
function AutoTable(props) {
|
|
16
|
+
const enableSorting = props.enableSorting ?? true;
|
|
17
|
+
const [managedSorting, setManagedSorting] = useManagedStateSwitch(
|
|
18
|
+
props.sorting,
|
|
19
|
+
props.onSortingChange,
|
|
20
|
+
props.defaultSorting ?? []
|
|
21
|
+
);
|
|
22
|
+
const enableRowSelection = props.enableRowSelection ?? props.rowSelection !== void 0;
|
|
23
|
+
const [managedRowSelection, setManagedRowSelection] = useManagedStateSwitch(
|
|
24
|
+
props.rowSelection,
|
|
25
|
+
props.onRowSelectionChange,
|
|
26
|
+
{}
|
|
27
|
+
);
|
|
28
|
+
const enablePagination = props.enablePagination ?? true;
|
|
29
|
+
const [managedPage, setManagedPage] = useManagedStateSwitch(
|
|
30
|
+
props.page,
|
|
31
|
+
props.onPageChange,
|
|
32
|
+
0
|
|
33
|
+
);
|
|
34
|
+
const [managedRowsPerPage, setManagedRowsPerPage] = useManagedStateSwitch(
|
|
35
|
+
props.rowsPerPage,
|
|
36
|
+
props.onRowsPerPageChange,
|
|
37
|
+
10
|
|
38
|
+
);
|
|
39
|
+
const options = {
|
|
40
|
+
data: props.data,
|
|
41
|
+
columns: props.columns,
|
|
42
|
+
meta: props.meta,
|
|
43
|
+
getRowId: props.getRowId,
|
|
44
|
+
// sorting
|
|
45
|
+
sorting: managedSorting,
|
|
46
|
+
enableSorting,
|
|
47
|
+
onSortingChange: setManagedSorting,
|
|
48
|
+
manualSorting: props.manualSorting,
|
|
49
|
+
// selection
|
|
50
|
+
rowSelection: managedRowSelection,
|
|
51
|
+
enableRowSelection,
|
|
52
|
+
onRowSelectionChange: setManagedRowSelection,
|
|
53
|
+
// pagination
|
|
54
|
+
pagination: {
|
|
55
|
+
pageIndex: managedPage,
|
|
56
|
+
pageSize: enablePagination ? managedRowsPerPage : props.data.length
|
|
57
|
+
},
|
|
58
|
+
enablePagination,
|
|
59
|
+
onPageChange: setManagedPage,
|
|
60
|
+
onRowsPerPageChange: setManagedRowsPerPage,
|
|
61
|
+
manualPagination: props.manualRowCount !== void 0,
|
|
62
|
+
manualRowCount: props.manualRowCount
|
|
63
|
+
};
|
|
64
|
+
if (props.virtualizer) {
|
|
65
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
66
|
+
virtual.default,
|
|
67
|
+
{
|
|
68
|
+
...options,
|
|
69
|
+
...props.virtualizer,
|
|
70
|
+
stickyHeader: props.stickyHeader,
|
|
71
|
+
loading: props.loading,
|
|
72
|
+
zeroStateMessage: props.zeroStateMessage,
|
|
73
|
+
error: props.error,
|
|
74
|
+
ErrorContainer: props.ErrorContainer,
|
|
75
|
+
sx: props.sx,
|
|
76
|
+
className: props.className
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
81
|
+
controlled.default,
|
|
82
|
+
{
|
|
83
|
+
...options,
|
|
84
|
+
stickyHeader: props.stickyHeader,
|
|
85
|
+
loading: props.loading,
|
|
86
|
+
zeroStateMessage: props.zeroStateMessage,
|
|
87
|
+
error: props.error,
|
|
88
|
+
ErrorContainer: props.ErrorContainer,
|
|
89
|
+
className: props.className
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function useManagedStateSwitch(controlled, setControlled, uncontrolledDefault) {
|
|
94
|
+
const [uncontrolled, setUncontrolled] = React.useState(uncontrolledDefault);
|
|
95
|
+
const [managed, setManaged] = controlled !== void 0 ? [
|
|
96
|
+
controlled,
|
|
97
|
+
(u) => {
|
|
98
|
+
setControlled?.(u);
|
|
99
|
+
}
|
|
100
|
+
] : [
|
|
101
|
+
uncontrolled,
|
|
102
|
+
(u) => {
|
|
103
|
+
setUncontrolled(u);
|
|
104
|
+
setControlled?.(u);
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
return [managed, setManaged];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
exports.default = AutoTable;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
'use client';
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
|
+
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var reactTable = require('@tanstack/react-table');
|
|
9
|
+
var index = require('../index.js');
|
|
10
|
+
var index$1 = require('../TableRow/index.js');
|
|
11
|
+
var index$2 = require('../TableCell/index.js');
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var material = require('@mui/material');
|
|
14
|
+
var utils = require('@mui/utils');
|
|
15
|
+
var common = require('./common.js');
|
|
16
|
+
var reactVirtual = require('@tanstack/react-virtual');
|
|
17
|
+
var isPropValid = require('@emotion/is-prop-valid');
|
|
18
|
+
|
|
19
|
+
const TableMessageMaxHeight = 100;
|
|
20
|
+
const TableContainer = material.styled(material.Box, {
|
|
21
|
+
shouldForwardProp: (prop) => isPropValid(prop)
|
|
22
|
+
})(({ virtualizerTotalHeight }) => ({
|
|
23
|
+
height: `${virtualizerTotalHeight}px`
|
|
24
|
+
}));
|
|
25
|
+
function VirtualControlledAutoTable({
|
|
26
|
+
stickyHeader,
|
|
27
|
+
loading,
|
|
28
|
+
zeroStateMessage,
|
|
29
|
+
error,
|
|
30
|
+
ErrorContainer = common.DefaultErrorContainer,
|
|
31
|
+
scrollOffset,
|
|
32
|
+
getScrollElement,
|
|
33
|
+
renderWhenNotVisible = true,
|
|
34
|
+
rowSize,
|
|
35
|
+
headerSize = 50,
|
|
36
|
+
overscan,
|
|
37
|
+
debug,
|
|
38
|
+
sx,
|
|
39
|
+
className,
|
|
40
|
+
...options
|
|
41
|
+
}) {
|
|
42
|
+
const table = common.useAutoTable(options);
|
|
43
|
+
const { rows } = table.getRowModel();
|
|
44
|
+
const offsetFromScrollEl = scrollOffset ?? 0;
|
|
45
|
+
const virtualizer = reactVirtual.useVirtualizer({
|
|
46
|
+
getScrollElement,
|
|
47
|
+
scrollMargin: offsetFromScrollEl,
|
|
48
|
+
count: rows.length,
|
|
49
|
+
overscan: overscan ?? 10,
|
|
50
|
+
estimateSize: () => rowSize
|
|
51
|
+
});
|
|
52
|
+
const showMessage = error || loading || rows.length === 0;
|
|
53
|
+
const rowsHeight = rows.length * rowSize;
|
|
54
|
+
const totalHeight = headerSize + (showMessage ? TableMessageMaxHeight : rowsHeight);
|
|
55
|
+
const visibilityOverscan = virtualizer.options.overscan * rowSize;
|
|
56
|
+
const visibilityBounds = {
|
|
57
|
+
lower: offsetFromScrollEl - visibilityOverscan,
|
|
58
|
+
upper: offsetFromScrollEl + totalHeight + visibilityOverscan
|
|
59
|
+
};
|
|
60
|
+
const tableIsVisible = renderWhenNotVisible || virtualizer.scrollOffset + virtualizer.scrollRect.height >= visibilityBounds.lower && virtualizer.scrollOffset <= visibilityBounds.upper;
|
|
61
|
+
const virtualItems = virtualizer.getVirtualItems();
|
|
62
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
63
|
+
TableContainer,
|
|
64
|
+
{
|
|
65
|
+
virtualizerTotalHeight: totalHeight,
|
|
66
|
+
sx,
|
|
67
|
+
className,
|
|
68
|
+
children: [
|
|
69
|
+
debug && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { position: "relative" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
style: {
|
|
73
|
+
position: "absolute",
|
|
74
|
+
top: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
color: "red",
|
|
77
|
+
zIndex: 100,
|
|
78
|
+
fontSize: 10
|
|
79
|
+
},
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginRight: 5 }, children: virtualizer.scrollOffset }),
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginRight: 5 }, children: virtualizer.scrollOffset + virtualizer.scrollRect.height }),
|
|
83
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginRight: 5 }, children: offsetFromScrollEl }),
|
|
84
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginRight: 5 }, children: visibilityBounds.lower }),
|
|
85
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginRight: 5 }, children: visibilityBounds.upper })
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
) }),
|
|
89
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
90
|
+
index.Table,
|
|
91
|
+
{
|
|
92
|
+
sx: {
|
|
93
|
+
borderCollapse: "separate",
|
|
94
|
+
...stickyHeader ? {
|
|
95
|
+
"& th": {
|
|
96
|
+
position: "sticky",
|
|
97
|
+
top: typeof stickyHeader === "object" ? stickyHeader.offset : 0,
|
|
98
|
+
zIndex: 2,
|
|
99
|
+
backgroundColor: (theme) => theme.palette.background.default
|
|
100
|
+
}
|
|
101
|
+
} : {}
|
|
102
|
+
},
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ jsxRuntime.jsx(index.TableHead, { sx: { height: headerSize }, children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxRuntime.jsx(index$1.default, { children: headerGroup.headers.map((header) => {
|
|
105
|
+
const isSorted = header.column.getIsSorted();
|
|
106
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index$2.default, { variant: "header", children: header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
107
|
+
index.TableSortLabel,
|
|
108
|
+
{
|
|
109
|
+
active: isSorted !== false,
|
|
110
|
+
direction: isSorted !== false ? isSorted : "asc",
|
|
111
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
112
|
+
children: [
|
|
113
|
+
reactTable.flexRender(
|
|
114
|
+
header.column.columnDef.header,
|
|
115
|
+
header.getContext()
|
|
116
|
+
),
|
|
117
|
+
isSorted !== false ? /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: "span", sx: utils.visuallyHidden, children: isSorted === "desc" ? "sorted descending" : "sorted ascending" }) : null
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
) : reactTable.flexRender(
|
|
121
|
+
header.column.columnDef.header,
|
|
122
|
+
header.getContext()
|
|
123
|
+
) }, header.id);
|
|
124
|
+
}) }, headerGroup.id)) }),
|
|
125
|
+
showMessage ? /* @__PURE__ */ jsxRuntime.jsx(index.TableBody, { children: /* @__PURE__ */ jsxRuntime.jsx(index$1.default, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
126
|
+
index$2.default,
|
|
127
|
+
{
|
|
128
|
+
colSpan: table.getAllFlatColumns().length,
|
|
129
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { children: error ? /* @__PURE__ */ jsxRuntime.jsx(ErrorContainer, { error }) : loading ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
130
|
+
material.Box,
|
|
131
|
+
{
|
|
132
|
+
sx: {
|
|
133
|
+
display: "flex",
|
|
134
|
+
justifyContent: "center",
|
|
135
|
+
paddingTop: "10px",
|
|
136
|
+
paddingBottom: "10px"
|
|
137
|
+
},
|
|
138
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, {})
|
|
139
|
+
}
|
|
140
|
+
) : rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(index.TableMessage, { children: zeroStateMessage ?? "No data found" }) : null })
|
|
141
|
+
}
|
|
142
|
+
) }) }) : tableIsVisible && /* @__PURE__ */ jsxRuntime.jsx(
|
|
143
|
+
index.TableBody,
|
|
144
|
+
{
|
|
145
|
+
sx: {
|
|
146
|
+
"&::after": {
|
|
147
|
+
display: "block",
|
|
148
|
+
content: "''",
|
|
149
|
+
// this ensures the table takes up as much size as the total elements by adding padding to the end
|
|
150
|
+
height: `${(rows.length - virtualItems.length) * rowSize}px`
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
children: virtualItems.map((virtualRow) => {
|
|
154
|
+
const row = rows[virtualRow.index];
|
|
155
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
156
|
+
index$1.default,
|
|
157
|
+
{
|
|
158
|
+
children: row.getAllCells().map((cell) => /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: reactTable.flexRender(
|
|
159
|
+
cell.column.columnDef.cell,
|
|
160
|
+
cell.getContext()
|
|
161
|
+
) }, cell.id))
|
|
162
|
+
},
|
|
163
|
+
row.id
|
|
164
|
+
);
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
exports.TableMessageMaxHeight = TableMessageMaxHeight;
|
|
177
|
+
exports.default = VirtualControlledAutoTable;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
'use client';
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
6
|
+
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var styles_module = require('./styles.module.scss.js');
|
|
10
|
+
require('@capsizecss/core');
|
|
11
|
+
require('color2k');
|
|
12
|
+
require('../../styles/css-vars.js');
|
|
13
|
+
var cx = require('../../styles/cx.js');
|
|
14
|
+
require('../../styles/defaultTheme.js');
|
|
15
|
+
require('@mui/system');
|
|
16
|
+
require('../../Box/index.js');
|
|
17
|
+
require('../../styles/styled.js');
|
|
18
|
+
|
|
19
|
+
const TableCell = React.forwardRef(
|
|
20
|
+
({
|
|
21
|
+
children,
|
|
22
|
+
"data-testid": dataTestId,
|
|
23
|
+
noVerticalPadding,
|
|
24
|
+
variant = "data",
|
|
25
|
+
className,
|
|
26
|
+
style,
|
|
27
|
+
...props
|
|
28
|
+
}, ref) => {
|
|
29
|
+
const Tag = React.useMemo(
|
|
30
|
+
() => variant === "header" ? "th" : "td",
|
|
31
|
+
[variant]
|
|
32
|
+
);
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
34
|
+
Tag,
|
|
35
|
+
{
|
|
36
|
+
ref,
|
|
37
|
+
...props,
|
|
38
|
+
"data-testid": dataTestId,
|
|
39
|
+
className: cx.cx(styles_module.default.tableCell, className),
|
|
40
|
+
style: {
|
|
41
|
+
padding: `${noVerticalPadding ? "0px" : "14.25px"} ${"16px"}`,
|
|
42
|
+
...style
|
|
43
|
+
},
|
|
44
|
+
children
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
exports.default = TableCell;
|