@spark-web/data-table 0.2.0 → 0.3.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @spark-web/data-table
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#497](https://github.com/brighte-labs/spark-web/pull/497)
|
|
8
|
+
[`281829c`](https://github.com/brighte-labs/spark-web/commit/281829cfadbc85ef7ab9f942877aa92f4de1112e)
|
|
9
|
+
Thanks [@ralcoriza-brighte](https://github.com/ralcoriza-brighte)! - Introduce
|
|
10
|
+
support for expanding rows
|
|
11
|
+
|
|
12
|
+
## 0.2.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#456](https://github.com/brighte-labs/spark-web/pull/456)
|
|
17
|
+
[`5faf8fe`](https://github.com/brighte-labs/spark-web/commit/5faf8fe3f0aebefe6cae4b4904d6d4613f8c5d8a)
|
|
18
|
+
Thanks [@michtntbrighte](https://github.com/michtntbrighte)! - feat: allow
|
|
19
|
+
custom row id
|
|
20
|
+
|
|
3
21
|
## 0.2.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -15,7 +15,8 @@ Currently supported features from `@tanstack/react-table` are the following:
|
|
|
15
15
|
|
|
16
16
|
1. Row selection
|
|
17
17
|
2. Multi-row selection
|
|
18
|
-
3.
|
|
18
|
+
3. Row expansion
|
|
19
|
+
4. Column visibility
|
|
19
20
|
|
|
20
21
|
However, certain defaults have been set for the component:
|
|
21
22
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type DataAttributeMap } from '@spark-web/utils/internal';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { ColumnDef, ColumnHelper, Row, Table, TableOptions } from '@tanstack/react-table';
|
|
3
|
+
import { createColumnHelper } from '@tanstack/react-table';
|
|
4
|
+
import type { HTMLAttributes, ReactElement } from 'react';
|
|
4
5
|
/**
|
|
5
6
|
* DataTable
|
|
6
7
|
*
|
|
7
8
|
* @see https://spark.brighte.com.au/package/data-table
|
|
8
9
|
*/
|
|
9
|
-
declare function DataTable<T>({ data, items, className, columns, enableHiding, enableMultiRowSelection, enableClickableRow, headerClassName, footerClassName, showBottomSpinner: showSpinner, onBottomSpinnerShown, onRowSelectionChange, ...tableOptions }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function DataTable<T>({ data, items, className, columns, enableExpanding, enableHiding, enableMultiRowSelection, enableClickableRow, headerClassName, footerClassName, showBottomSpinner: showSpinner, expandedRowComponent, onBottomSpinnerShown, onRowClick, onRowSelectionChange, ...tableOptions }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
declare type TableSubsetAttributes = Pick<HTMLAttributes<HTMLTableElement>, 'className'>;
|
|
11
|
-
declare type TableSubsetOptions<T> = Pick<TableOptions<T>, 'columns' | 'enableHiding' | 'enableMultiRowSelection' | 'state' | 'onStateChange' | 'onRowSelectionChange'>;
|
|
12
|
+
declare type TableSubsetOptions<T> = Pick<TableOptions<T>, 'columns' | 'enableExpanding' | 'enableHiding' | 'enableMultiRowSelection' | 'state' | 'onStateChange' | 'onExpandedChange' | 'onRowSelectionChange' | 'getRowId'>;
|
|
12
13
|
declare type DataTableProps<T> = TableSubsetAttributes & TableSubsetOptions<T> & {
|
|
13
14
|
headerClassName?: string;
|
|
14
15
|
footerClassName?: string;
|
|
@@ -17,7 +18,9 @@ declare type DataTableProps<T> = TableSubsetAttributes & TableSubsetOptions<T> &
|
|
|
17
18
|
items: Array<T>;
|
|
18
19
|
enableClickableRow?: boolean;
|
|
19
20
|
showBottomSpinner?: boolean;
|
|
21
|
+
expandedRowComponent?: (row: Row<T>, table?: Table<T>) => ReactElement<T>;
|
|
20
22
|
onBottomSpinnerShown?: (isInView: boolean) => void;
|
|
23
|
+
onRowClick?: (row: Row<T>) => void;
|
|
21
24
|
};
|
|
22
25
|
export { createColumnHelper, DataTable };
|
|
23
|
-
export type { ColumnDef, ColumnHelper, DataTableProps };
|
|
26
|
+
export type { ColumnDef, ColumnHelper, DataTableProps, Row };
|
|
@@ -10,15 +10,22 @@ var spinner = require('@spark-web/spinner');
|
|
|
10
10
|
var theme = require('@spark-web/theme');
|
|
11
11
|
var internal = require('@spark-web/utils/internal');
|
|
12
12
|
var reactTable = require('@tanstack/react-table');
|
|
13
|
+
var React = require('react');
|
|
13
14
|
var reactIntersectionObserver = require('react-intersection-observer');
|
|
14
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
20
|
+
|
|
21
|
+
var _excluded = ["data", "items", "className", "columns", "enableExpanding", "enableHiding", "enableMultiRowSelection", "enableClickableRow", "headerClassName", "footerClassName", "showBottomSpinner", "expandedRowComponent", "onBottomSpinnerShown", "onRowClick", "onRowSelectionChange"];
|
|
17
22
|
function DataTable(_ref) {
|
|
18
23
|
var data = _ref.data,
|
|
19
24
|
items = _ref.items,
|
|
20
25
|
className = _ref.className,
|
|
21
26
|
columns = _ref.columns,
|
|
27
|
+
_ref$enableExpanding = _ref.enableExpanding,
|
|
28
|
+
enableExpanding = _ref$enableExpanding === void 0 ? false : _ref$enableExpanding,
|
|
22
29
|
_ref$enableHiding = _ref.enableHiding,
|
|
23
30
|
enableHiding = _ref$enableHiding === void 0 ? true : _ref$enableHiding,
|
|
24
31
|
_ref$enableMultiRowSe = _ref.enableMultiRowSelection,
|
|
@@ -27,22 +34,30 @@ function DataTable(_ref) {
|
|
|
27
34
|
headerClassName = _ref.headerClassName,
|
|
28
35
|
footerClassName = _ref.footerClassName,
|
|
29
36
|
showSpinner = _ref.showBottomSpinner,
|
|
37
|
+
expandedRowComponent = _ref.expandedRowComponent,
|
|
30
38
|
onBottomSpinnerShown = _ref.onBottomSpinnerShown,
|
|
39
|
+
onRowClick = _ref.onRowClick,
|
|
31
40
|
onRowSelectionChange = _ref.onRowSelectionChange,
|
|
32
41
|
tableOptions = _objectWithoutProperties(_ref, _excluded);
|
|
33
42
|
var theme$1 = theme.useTheme();
|
|
43
|
+
var enableRowSelection = !!onRowSelectionChange;
|
|
34
44
|
var table = reactTable.useReactTable(_objectSpread(_objectSpread({
|
|
35
45
|
data: items,
|
|
46
|
+
enableExpanding: enableExpanding,
|
|
36
47
|
enableMultiRowSelection: enableMultiRowSelection,
|
|
37
48
|
enableHiding: enableHiding,
|
|
38
|
-
enableRowSelection:
|
|
49
|
+
enableRowSelection: enableRowSelection,
|
|
39
50
|
onRowSelectionChange: onRowSelectionChange,
|
|
40
51
|
columns: columns
|
|
41
52
|
}, tableOptions), {}, {
|
|
42
|
-
getCoreRowModel: reactTable.getCoreRowModel()
|
|
53
|
+
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
54
|
+
getExpandedRowModel: enableExpanding ? reactTable.getCoreRowModel() : undefined
|
|
43
55
|
}));
|
|
44
56
|
var headerGroups = table.getHeaderGroups();
|
|
45
57
|
var footerGroups = table.getFooterGroups();
|
|
58
|
+
var defaultOnRowClick = function defaultOnRowClick(row) {
|
|
59
|
+
return row.toggleSelected();
|
|
60
|
+
};
|
|
46
61
|
return /*#__PURE__*/jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread({
|
|
47
62
|
as: "table"
|
|
48
63
|
}, data ? internal.buildDataAttributes(data) : undefined), {}, {
|
|
@@ -78,35 +93,38 @@ function DataTable(_ref) {
|
|
|
78
93
|
}) : null, /*#__PURE__*/jsxRuntime.jsxs(box.Box, {
|
|
79
94
|
as: "tbody",
|
|
80
95
|
children: [table.getRowModel().rows.map(function (row) {
|
|
81
|
-
return /*#__PURE__*/jsxRuntime.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
return /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
|
|
97
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
98
|
+
as: "tr",
|
|
99
|
+
className: css.css({
|
|
100
|
+
'&[data-is-selected="true"],&[data-is-expanded="true"]': {
|
|
101
|
+
background: theme$1.color.background.primaryMuted
|
|
102
|
+
},
|
|
103
|
+
':hover': {
|
|
104
|
+
background: theme$1.backgroundInteractions.neutralHover,
|
|
105
|
+
cursor: enableClickableRow ? 'pointer' : undefined
|
|
106
|
+
}
|
|
107
|
+
}),
|
|
108
|
+
onClick: function onClick() {
|
|
109
|
+
return enableClickableRow && (onRowClick ? onRowClick(row) : defaultOnRowClick(row));
|
|
86
110
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
verticalAlign: 'middle',
|
|
105
|
-
textAlign: 'left'
|
|
106
|
-
}),
|
|
107
|
-
children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
108
|
-
}, cell.id);
|
|
109
|
-
})
|
|
111
|
+
"data-is-selected": row.getIsSelected(),
|
|
112
|
+
"data-is-expanded": row.getIsExpanded(),
|
|
113
|
+
children: row.getVisibleCells().map(function (cell) {
|
|
114
|
+
return /*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
115
|
+
as: "td",
|
|
116
|
+
padding: "large",
|
|
117
|
+
className: css.css({
|
|
118
|
+
borderBottom: '1px',
|
|
119
|
+
borderBottomStyle: 'solid',
|
|
120
|
+
borderColor: theme$1.border.color.standard,
|
|
121
|
+
verticalAlign: 'middle',
|
|
122
|
+
textAlign: 'left'
|
|
123
|
+
}),
|
|
124
|
+
children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
125
|
+
}, cell.id);
|
|
126
|
+
})
|
|
127
|
+
}), enableExpanding && row.getIsExpanded() && expandedRowComponent && expandedRowComponent(row, table)]
|
|
110
128
|
}, row.id);
|
|
111
129
|
}), showSpinner && /*#__PURE__*/jsxRuntime.jsx(reactIntersectionObserver.InView, {
|
|
112
130
|
as: "tr",
|
|
@@ -10,15 +10,22 @@ var spinner = require('@spark-web/spinner');
|
|
|
10
10
|
var theme = require('@spark-web/theme');
|
|
11
11
|
var internal = require('@spark-web/utils/internal');
|
|
12
12
|
var reactTable = require('@tanstack/react-table');
|
|
13
|
+
var React = require('react');
|
|
13
14
|
var reactIntersectionObserver = require('react-intersection-observer');
|
|
14
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
20
|
+
|
|
21
|
+
var _excluded = ["data", "items", "className", "columns", "enableExpanding", "enableHiding", "enableMultiRowSelection", "enableClickableRow", "headerClassName", "footerClassName", "showBottomSpinner", "expandedRowComponent", "onBottomSpinnerShown", "onRowClick", "onRowSelectionChange"];
|
|
17
22
|
function DataTable(_ref) {
|
|
18
23
|
var data = _ref.data,
|
|
19
24
|
items = _ref.items,
|
|
20
25
|
className = _ref.className,
|
|
21
26
|
columns = _ref.columns,
|
|
27
|
+
_ref$enableExpanding = _ref.enableExpanding,
|
|
28
|
+
enableExpanding = _ref$enableExpanding === void 0 ? false : _ref$enableExpanding,
|
|
22
29
|
_ref$enableHiding = _ref.enableHiding,
|
|
23
30
|
enableHiding = _ref$enableHiding === void 0 ? true : _ref$enableHiding,
|
|
24
31
|
_ref$enableMultiRowSe = _ref.enableMultiRowSelection,
|
|
@@ -27,22 +34,30 @@ function DataTable(_ref) {
|
|
|
27
34
|
headerClassName = _ref.headerClassName,
|
|
28
35
|
footerClassName = _ref.footerClassName,
|
|
29
36
|
showSpinner = _ref.showBottomSpinner,
|
|
37
|
+
expandedRowComponent = _ref.expandedRowComponent,
|
|
30
38
|
onBottomSpinnerShown = _ref.onBottomSpinnerShown,
|
|
39
|
+
onRowClick = _ref.onRowClick,
|
|
31
40
|
onRowSelectionChange = _ref.onRowSelectionChange,
|
|
32
41
|
tableOptions = _objectWithoutProperties(_ref, _excluded);
|
|
33
42
|
var theme$1 = theme.useTheme();
|
|
43
|
+
var enableRowSelection = !!onRowSelectionChange;
|
|
34
44
|
var table = reactTable.useReactTable(_objectSpread(_objectSpread({
|
|
35
45
|
data: items,
|
|
46
|
+
enableExpanding: enableExpanding,
|
|
36
47
|
enableMultiRowSelection: enableMultiRowSelection,
|
|
37
48
|
enableHiding: enableHiding,
|
|
38
|
-
enableRowSelection:
|
|
49
|
+
enableRowSelection: enableRowSelection,
|
|
39
50
|
onRowSelectionChange: onRowSelectionChange,
|
|
40
51
|
columns: columns
|
|
41
52
|
}, tableOptions), {}, {
|
|
42
|
-
getCoreRowModel: reactTable.getCoreRowModel()
|
|
53
|
+
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
54
|
+
getExpandedRowModel: enableExpanding ? reactTable.getCoreRowModel() : undefined
|
|
43
55
|
}));
|
|
44
56
|
var headerGroups = table.getHeaderGroups();
|
|
45
57
|
var footerGroups = table.getFooterGroups();
|
|
58
|
+
var defaultOnRowClick = function defaultOnRowClick(row) {
|
|
59
|
+
return row.toggleSelected();
|
|
60
|
+
};
|
|
46
61
|
return /*#__PURE__*/jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread({
|
|
47
62
|
as: "table"
|
|
48
63
|
}, data ? internal.buildDataAttributes(data) : undefined), {}, {
|
|
@@ -78,35 +93,38 @@ function DataTable(_ref) {
|
|
|
78
93
|
}) : null, /*#__PURE__*/jsxRuntime.jsxs(box.Box, {
|
|
79
94
|
as: "tbody",
|
|
80
95
|
children: [table.getRowModel().rows.map(function (row) {
|
|
81
|
-
return /*#__PURE__*/jsxRuntime.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
return /*#__PURE__*/jsxRuntime.jsxs(React__default["default"].Fragment, {
|
|
97
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
98
|
+
as: "tr",
|
|
99
|
+
className: css.css({
|
|
100
|
+
'&[data-is-selected="true"],&[data-is-expanded="true"]': {
|
|
101
|
+
background: theme$1.color.background.primaryMuted
|
|
102
|
+
},
|
|
103
|
+
':hover': {
|
|
104
|
+
background: theme$1.backgroundInteractions.neutralHover,
|
|
105
|
+
cursor: enableClickableRow ? 'pointer' : undefined
|
|
106
|
+
}
|
|
107
|
+
}),
|
|
108
|
+
onClick: function onClick() {
|
|
109
|
+
return enableClickableRow && (onRowClick ? onRowClick(row) : defaultOnRowClick(row));
|
|
86
110
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
verticalAlign: 'middle',
|
|
105
|
-
textAlign: 'left'
|
|
106
|
-
}),
|
|
107
|
-
children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
108
|
-
}, cell.id);
|
|
109
|
-
})
|
|
111
|
+
"data-is-selected": row.getIsSelected(),
|
|
112
|
+
"data-is-expanded": row.getIsExpanded(),
|
|
113
|
+
children: row.getVisibleCells().map(function (cell) {
|
|
114
|
+
return /*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
115
|
+
as: "td",
|
|
116
|
+
padding: "large",
|
|
117
|
+
className: css.css({
|
|
118
|
+
borderBottom: '1px',
|
|
119
|
+
borderBottomStyle: 'solid',
|
|
120
|
+
borderColor: theme$1.border.color.standard,
|
|
121
|
+
verticalAlign: 'middle',
|
|
122
|
+
textAlign: 'left'
|
|
123
|
+
}),
|
|
124
|
+
children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
125
|
+
}, cell.id);
|
|
126
|
+
})
|
|
127
|
+
}), enableExpanding && row.getIsExpanded() && expandedRowComponent && expandedRowComponent(row, table)]
|
|
110
128
|
}, row.id);
|
|
111
129
|
}), showSpinner && /*#__PURE__*/jsxRuntime.jsx(reactIntersectionObserver.InView, {
|
|
112
130
|
as: "tr",
|
|
@@ -7,15 +7,18 @@ import { useTheme } from '@spark-web/theme';
|
|
|
7
7
|
import { buildDataAttributes } from '@spark-web/utils/internal';
|
|
8
8
|
import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
9
9
|
export { createColumnHelper } from '@tanstack/react-table';
|
|
10
|
+
import React from 'react';
|
|
10
11
|
import { InView } from 'react-intersection-observer';
|
|
11
12
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
13
|
|
|
13
|
-
var _excluded = ["data", "items", "className", "columns", "enableHiding", "enableMultiRowSelection", "enableClickableRow", "headerClassName", "footerClassName", "showBottomSpinner", "onBottomSpinnerShown", "onRowSelectionChange"];
|
|
14
|
+
var _excluded = ["data", "items", "className", "columns", "enableExpanding", "enableHiding", "enableMultiRowSelection", "enableClickableRow", "headerClassName", "footerClassName", "showBottomSpinner", "expandedRowComponent", "onBottomSpinnerShown", "onRowClick", "onRowSelectionChange"];
|
|
14
15
|
function DataTable(_ref) {
|
|
15
16
|
var data = _ref.data,
|
|
16
17
|
items = _ref.items,
|
|
17
18
|
className = _ref.className,
|
|
18
19
|
columns = _ref.columns,
|
|
20
|
+
_ref$enableExpanding = _ref.enableExpanding,
|
|
21
|
+
enableExpanding = _ref$enableExpanding === void 0 ? false : _ref$enableExpanding,
|
|
19
22
|
_ref$enableHiding = _ref.enableHiding,
|
|
20
23
|
enableHiding = _ref$enableHiding === void 0 ? true : _ref$enableHiding,
|
|
21
24
|
_ref$enableMultiRowSe = _ref.enableMultiRowSelection,
|
|
@@ -24,22 +27,30 @@ function DataTable(_ref) {
|
|
|
24
27
|
headerClassName = _ref.headerClassName,
|
|
25
28
|
footerClassName = _ref.footerClassName,
|
|
26
29
|
showSpinner = _ref.showBottomSpinner,
|
|
30
|
+
expandedRowComponent = _ref.expandedRowComponent,
|
|
27
31
|
onBottomSpinnerShown = _ref.onBottomSpinnerShown,
|
|
32
|
+
onRowClick = _ref.onRowClick,
|
|
28
33
|
onRowSelectionChange = _ref.onRowSelectionChange,
|
|
29
34
|
tableOptions = _objectWithoutProperties(_ref, _excluded);
|
|
30
35
|
var theme = useTheme();
|
|
36
|
+
var enableRowSelection = !!onRowSelectionChange;
|
|
31
37
|
var table = useReactTable(_objectSpread(_objectSpread({
|
|
32
38
|
data: items,
|
|
39
|
+
enableExpanding: enableExpanding,
|
|
33
40
|
enableMultiRowSelection: enableMultiRowSelection,
|
|
34
41
|
enableHiding: enableHiding,
|
|
35
|
-
enableRowSelection:
|
|
42
|
+
enableRowSelection: enableRowSelection,
|
|
36
43
|
onRowSelectionChange: onRowSelectionChange,
|
|
37
44
|
columns: columns
|
|
38
45
|
}, tableOptions), {}, {
|
|
39
|
-
getCoreRowModel: getCoreRowModel()
|
|
46
|
+
getCoreRowModel: getCoreRowModel(),
|
|
47
|
+
getExpandedRowModel: enableExpanding ? getCoreRowModel() : undefined
|
|
40
48
|
}));
|
|
41
49
|
var headerGroups = table.getHeaderGroups();
|
|
42
50
|
var footerGroups = table.getFooterGroups();
|
|
51
|
+
var defaultOnRowClick = function defaultOnRowClick(row) {
|
|
52
|
+
return row.toggleSelected();
|
|
53
|
+
};
|
|
43
54
|
return /*#__PURE__*/jsxs(Box, _objectSpread(_objectSpread({
|
|
44
55
|
as: "table"
|
|
45
56
|
}, data ? buildDataAttributes(data) : undefined), {}, {
|
|
@@ -75,35 +86,38 @@ function DataTable(_ref) {
|
|
|
75
86
|
}) : null, /*#__PURE__*/jsxs(Box, {
|
|
76
87
|
as: "tbody",
|
|
77
88
|
children: [table.getRowModel().rows.map(function (row) {
|
|
78
|
-
return /*#__PURE__*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
return /*#__PURE__*/jsxs(React.Fragment, {
|
|
90
|
+
children: [/*#__PURE__*/jsx(Box, {
|
|
91
|
+
as: "tr",
|
|
92
|
+
className: css({
|
|
93
|
+
'&[data-is-selected="true"],&[data-is-expanded="true"]': {
|
|
94
|
+
background: theme.color.background.primaryMuted
|
|
95
|
+
},
|
|
96
|
+
':hover': {
|
|
97
|
+
background: theme.backgroundInteractions.neutralHover,
|
|
98
|
+
cursor: enableClickableRow ? 'pointer' : undefined
|
|
99
|
+
}
|
|
100
|
+
}),
|
|
101
|
+
onClick: function onClick() {
|
|
102
|
+
return enableClickableRow && (onRowClick ? onRowClick(row) : defaultOnRowClick(row));
|
|
83
103
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
verticalAlign: 'middle',
|
|
102
|
-
textAlign: 'left'
|
|
103
|
-
}),
|
|
104
|
-
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
105
|
-
}, cell.id);
|
|
106
|
-
})
|
|
104
|
+
"data-is-selected": row.getIsSelected(),
|
|
105
|
+
"data-is-expanded": row.getIsExpanded(),
|
|
106
|
+
children: row.getVisibleCells().map(function (cell) {
|
|
107
|
+
return /*#__PURE__*/jsx(Box, {
|
|
108
|
+
as: "td",
|
|
109
|
+
padding: "large",
|
|
110
|
+
className: css({
|
|
111
|
+
borderBottom: '1px',
|
|
112
|
+
borderBottomStyle: 'solid',
|
|
113
|
+
borderColor: theme.border.color.standard,
|
|
114
|
+
verticalAlign: 'middle',
|
|
115
|
+
textAlign: 'left'
|
|
116
|
+
}),
|
|
117
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
118
|
+
}, cell.id);
|
|
119
|
+
})
|
|
120
|
+
}), enableExpanding && row.getIsExpanded() && expandedRowComponent && expandedRowComponent(row, table)]
|
|
107
121
|
}, row.id);
|
|
108
122
|
}), showSpinner && /*#__PURE__*/jsx(InView, {
|
|
109
123
|
as: "tr",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-web/data-table",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"homepage": "https://github.com/brighte-labs/spark-web#readme",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@babel/runtime": "^7.
|
|
19
|
+
"@babel/runtime": "^7.25.0",
|
|
20
20
|
"@emotion/css": "^11.11.2",
|
|
21
21
|
"@spark-web/a11y": "^1.4.0",
|
|
22
22
|
"@spark-web/box": "^1.0.9",
|