musae 1.3.1-beta.1 → 1.3.1-beta.2
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/__test__/table.test.d.ts +1 -0
- package/dist/components/table/body.cjs +11 -20
- package/dist/components/table/body.mjs +12 -21
- package/dist/components/table/context.cjs +6 -1
- package/dist/components/table/context.d.ts +4 -0
- package/dist/components/table/context.mjs +6 -2
- package/dist/components/table/header/cell.cjs +7 -23
- package/dist/components/table/header/cell.mjs +7 -23
- package/dist/components/table/header/header.cjs +3 -31
- package/dist/components/table/header/header.mjs +4 -32
- package/dist/components/table/hooks.cjs +31 -9
- package/dist/components/table/hooks.d.ts +3 -2
- package/dist/components/table/hooks.mjs +31 -9
- package/dist/components/table/styles.cjs +99 -0
- package/dist/components/table/styles.d.ts +84 -0
- package/dist/components/table/styles.mjs +95 -0
- package/dist/components/table/table.cjs +49 -7
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.mjs +51 -9
- package/dist/styles.css +4 -0
- package/dist/types/table.d.ts +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var context = require('./context.cjs');
|
|
7
8
|
var reactTable = require('@tanstack/react-table');
|
|
@@ -11,23 +12,8 @@ var empty = require('../empty/empty.cjs');
|
|
|
11
12
|
var className = require('@aiszlab/relax/class-name');
|
|
12
13
|
var theme = require('../theme/theme.cjs');
|
|
13
14
|
var useThemeColorVars = require('../../hooks/use-theme-color-vars.cjs');
|
|
15
|
+
var styles = require('./styles.cjs');
|
|
14
16
|
|
|
15
|
-
var styles = {
|
|
16
|
-
cell: {
|
|
17
|
-
kjGldf: "musaex-aafj1c",
|
|
18
|
-
kEafiO: "musaex-1ndz9a0",
|
|
19
|
-
kg3NbH: "musaex-1g3a7fl",
|
|
20
|
-
k8WAf4: "musaex-s7sbuz",
|
|
21
|
-
kVAM5u: "musaex-axmpxa",
|
|
22
|
-
ksu8eU: "musaex-1y0btm7",
|
|
23
|
-
kt9PQ7: "musaex-d1xpcx",
|
|
24
|
-
$$css: true
|
|
25
|
-
},
|
|
26
|
-
bordered: {
|
|
27
|
-
kjGldf: "musaex-imutj9",
|
|
28
|
-
$$css: true
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
17
|
var Body = function Body() {
|
|
32
18
|
var _useTable = context.useTable(),
|
|
33
19
|
table = _useTable.table,
|
|
@@ -35,7 +21,7 @@ var Body = function Body() {
|
|
|
35
21
|
classNames = _useTable.classNames;
|
|
36
22
|
var _themeColorVars = useThemeColorVars.useThemeColorVars(["outline-variant"]);
|
|
37
23
|
if (!table) return null;
|
|
38
|
-
var styled = stylex.props(styles.
|
|
24
|
+
var styled = stylex.props(styles.default.bodyCell["default"], bordered && styles.default.bodyCell.bordered, theme.$body.small);
|
|
39
25
|
var rows = table.getRowModel().rows;
|
|
40
26
|
var _isEmpty = relax.isEmpty(rows);
|
|
41
27
|
return /*#__PURE__*/React.createElement("tbody", {
|
|
@@ -45,12 +31,17 @@ var Body = function Body() {
|
|
|
45
31
|
colSpan: table.getAllColumns().length
|
|
46
32
|
}, /*#__PURE__*/React.createElement(empty.default, null)))), !_isEmpty && table.getRowModel().rows.map(function (row) {
|
|
47
33
|
return /*#__PURE__*/React.createElement("tr", {
|
|
48
|
-
key: row.id
|
|
34
|
+
key: row.id,
|
|
35
|
+
className: className.stringify(row.getCanExpand() && classNames.expandableRow, row.depth > 0 && classNames.childRow)
|
|
49
36
|
}, row.getVisibleCells().map(function (cell) {
|
|
37
|
+
var isFirstChildDataCell = row.depth > 0 && cell.column.id !== context.EXPAND_COLUMN_ID && cell.column.getIndex() === 1;
|
|
38
|
+
var cellStyled = stylex.props(isFirstChildDataCell && styles.default.bodyCell.child);
|
|
50
39
|
return /*#__PURE__*/React.createElement("td", {
|
|
51
40
|
key: cell.id,
|
|
52
|
-
className: className.stringify(styled.className),
|
|
53
|
-
style: styled.style
|
|
41
|
+
className: className.stringify(styled.className, cellStyled.className, cell.column.id === context.EXPAND_COLUMN_ID && classNames.expandColumn),
|
|
42
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, styled.style), cellStyled.style), isFirstChildDataCell && {
|
|
43
|
+
"--depth": row.depth
|
|
44
|
+
})
|
|
54
45
|
}, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()));
|
|
55
46
|
}));
|
|
56
47
|
}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import { useTable } from './context.mjs';
|
|
3
|
+
import { useTable, EXPAND_COLUMN_ID } from './context.mjs';
|
|
3
4
|
import { flexRender } from '@tanstack/react-table';
|
|
4
5
|
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
5
6
|
import { isEmpty } from '@aiszlab/relax';
|
|
@@ -7,23 +8,8 @@ import Empty from '../empty/empty.mjs';
|
|
|
7
8
|
import { stringify } from '@aiszlab/relax/class-name';
|
|
8
9
|
import { $body } from '../theme/theme.mjs';
|
|
9
10
|
import { useThemeColorVars } from '../../hooks/use-theme-color-vars.mjs';
|
|
11
|
+
import styles from './styles.mjs';
|
|
10
12
|
|
|
11
|
-
var styles = {
|
|
12
|
-
cell: {
|
|
13
|
-
kjGldf: "musaex-aafj1c",
|
|
14
|
-
kEafiO: "musaex-1ndz9a0",
|
|
15
|
-
kg3NbH: "musaex-1g3a7fl",
|
|
16
|
-
k8WAf4: "musaex-s7sbuz",
|
|
17
|
-
kVAM5u: "musaex-axmpxa",
|
|
18
|
-
ksu8eU: "musaex-1y0btm7",
|
|
19
|
-
kt9PQ7: "musaex-d1xpcx",
|
|
20
|
-
$$css: true
|
|
21
|
-
},
|
|
22
|
-
bordered: {
|
|
23
|
-
kjGldf: "musaex-imutj9",
|
|
24
|
-
$$css: true
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
13
|
var Body = function Body() {
|
|
28
14
|
var _useTable = useTable(),
|
|
29
15
|
table = _useTable.table,
|
|
@@ -31,7 +17,7 @@ var Body = function Body() {
|
|
|
31
17
|
classNames = _useTable.classNames;
|
|
32
18
|
var _themeColorVars = useThemeColorVars(["outline-variant"]);
|
|
33
19
|
if (!table) return null;
|
|
34
|
-
var styled = props(styles.
|
|
20
|
+
var styled = props(styles.bodyCell["default"], bordered && styles.bodyCell.bordered, $body.small);
|
|
35
21
|
var rows = table.getRowModel().rows;
|
|
36
22
|
var _isEmpty = isEmpty(rows);
|
|
37
23
|
return /*#__PURE__*/React.createElement("tbody", {
|
|
@@ -41,12 +27,17 @@ var Body = function Body() {
|
|
|
41
27
|
colSpan: table.getAllColumns().length
|
|
42
28
|
}, /*#__PURE__*/React.createElement(Empty, null)))), !_isEmpty && table.getRowModel().rows.map(function (row) {
|
|
43
29
|
return /*#__PURE__*/React.createElement("tr", {
|
|
44
|
-
key: row.id
|
|
30
|
+
key: row.id,
|
|
31
|
+
className: stringify(row.getCanExpand() && classNames.expandableRow, row.depth > 0 && classNames.childRow)
|
|
45
32
|
}, row.getVisibleCells().map(function (cell) {
|
|
33
|
+
var isFirstChildDataCell = row.depth > 0 && cell.column.id !== EXPAND_COLUMN_ID && cell.column.getIndex() === 1;
|
|
34
|
+
var cellStyled = props(isFirstChildDataCell && styles.bodyCell.child);
|
|
46
35
|
return /*#__PURE__*/React.createElement("td", {
|
|
47
36
|
key: cell.id,
|
|
48
|
-
className: stringify(styled.className),
|
|
49
|
-
style: styled.style
|
|
37
|
+
className: stringify(styled.className, cellStyled.className, cell.column.id === EXPAND_COLUMN_ID && classNames.expandColumn),
|
|
38
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, styled.style), cellStyled.style), isFirstChildDataCell && {
|
|
39
|
+
"--depth": row.depth
|
|
40
|
+
})
|
|
50
41
|
}, flexRender(cell.column.columnDef.cell, cell.getContext()));
|
|
51
42
|
}));
|
|
52
43
|
}));
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
|
|
5
|
+
var EXPAND_COLUMN_ID = "__table_expand";
|
|
5
6
|
var CLASS_NAMES = {
|
|
6
7
|
table: "table",
|
|
7
8
|
header: "table__header",
|
|
8
|
-
body: "table__body"
|
|
9
|
+
body: "table__body",
|
|
10
|
+
expandColumn: "table__expand-column",
|
|
11
|
+
expandableRow: "table__row--expandable",
|
|
12
|
+
childRow: "table__row--child"
|
|
9
13
|
};
|
|
10
14
|
var Context = /*#__PURE__*/React.createContext({
|
|
11
15
|
bordered: false,
|
|
@@ -22,4 +26,5 @@ var useTable = function useTable() {
|
|
|
22
26
|
|
|
23
27
|
exports.CLASS_NAMES = CLASS_NAMES;
|
|
24
28
|
exports.Context = Context;
|
|
29
|
+
exports.EXPAND_COLUMN_ID = EXPAND_COLUMN_ID;
|
|
25
30
|
exports.useTable = useTable;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { ContextValue } from "../../types/table";
|
|
2
|
+
export declare const EXPAND_COLUMN_ID = "__table_expand";
|
|
2
3
|
export declare const CLASS_NAMES: {
|
|
3
4
|
readonly table: "table";
|
|
4
5
|
readonly header: "table__header";
|
|
5
6
|
readonly body: "table__body";
|
|
7
|
+
readonly expandColumn: "table__expand-column";
|
|
8
|
+
readonly expandableRow: "table__row--expandable";
|
|
9
|
+
readonly childRow: "table__row--child";
|
|
6
10
|
};
|
|
7
11
|
declare const Context: import("react").Context<ContextValue<unknown> & {
|
|
8
12
|
classNames: typeof CLASS_NAMES;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
2
|
|
|
3
|
+
var EXPAND_COLUMN_ID = "__table_expand";
|
|
3
4
|
var CLASS_NAMES = {
|
|
4
5
|
table: "table",
|
|
5
6
|
header: "table__header",
|
|
6
|
-
body: "table__body"
|
|
7
|
+
body: "table__body",
|
|
8
|
+
expandColumn: "table__expand-column",
|
|
9
|
+
expandableRow: "table__row--expandable",
|
|
10
|
+
childRow: "table__row--child"
|
|
7
11
|
};
|
|
8
12
|
var Context = /*#__PURE__*/createContext({
|
|
9
13
|
bordered: false,
|
|
@@ -18,4 +22,4 @@ var useTable = function useTable() {
|
|
|
18
22
|
return useContext(Context);
|
|
19
23
|
};
|
|
20
24
|
|
|
21
|
-
export { CLASS_NAMES, Context, useTable };
|
|
25
|
+
export { CLASS_NAMES, Context, EXPAND_COLUMN_ID, useTable };
|
|
@@ -5,8 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var relax = require('@aiszlab/relax');
|
|
8
|
+
var stylex = require('../../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.cjs');
|
|
8
9
|
var context = require('../context.cjs');
|
|
9
10
|
var useThemeColorVars = require('../../../hooks/use-theme-color-vars.cjs');
|
|
11
|
+
var styles = require('../styles.cjs');
|
|
10
12
|
var unfoldMore = require('../../icon/icons/navigation/unfold-more.cjs');
|
|
11
13
|
|
|
12
14
|
var Cell = function Cell(_ref) {
|
|
@@ -45,29 +47,11 @@ var Cell = function Cell(_ref) {
|
|
|
45
47
|
return children;
|
|
46
48
|
}
|
|
47
49
|
var styled = {
|
|
48
|
-
cell:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
sort: {
|
|
55
|
-
className: "musaex-1n2onr6 musaex-1ypdohk"
|
|
56
|
-
},
|
|
57
|
-
fullSort: {
|
|
58
|
-
0: {},
|
|
59
|
-
1: {
|
|
60
|
-
className: "musaex-14qql8p"
|
|
61
|
-
}
|
|
62
|
-
}[!!(sort === "descending") << 0],
|
|
63
|
-
halfSort: {
|
|
64
|
-
0: {
|
|
65
|
-
className: "musaex-10l6tqk musaex-13vifvy musaex-1o0tod musaex-11g3na9 musaex-b3r6kr"
|
|
66
|
-
},
|
|
67
|
-
1: {
|
|
68
|
-
className: "musaex-10l6tqk musaex-13vifvy musaex-1o0tod musaex-11g3na9 musaex-b3r6kr musaex-14qql8p"
|
|
69
|
-
}
|
|
70
|
-
}[!!(sort === "ascending") << 0]
|
|
50
|
+
cell: stylex.props(styles.default.headerContent["default"]),
|
|
51
|
+
handlers: stylex.props(styles.default.headerContent.handlers),
|
|
52
|
+
sort: stylex.props(styles.default.sort["default"]),
|
|
53
|
+
fullSort: stylex.props(sort === "descending" && styles.default.sort.checked),
|
|
54
|
+
halfSort: stylex.props(styles.default.sort.half, sort === "ascending" && styles.default.sort.checked)
|
|
71
55
|
};
|
|
72
56
|
return /*#__PURE__*/React.createElement("div", {
|
|
73
57
|
className: styled.cell.className,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import { toFunction, useEvent } from '@aiszlab/relax';
|
|
4
|
+
import { props } from '../../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
4
5
|
import { useTable } from '../context.mjs';
|
|
5
6
|
import { useThemeColorVars } from '../../../hooks/use-theme-color-vars.mjs';
|
|
7
|
+
import styles from '../styles.mjs';
|
|
6
8
|
import IconUnfoldMore from '../../icon/icons/navigation/unfold-more.mjs';
|
|
7
9
|
|
|
8
10
|
var Cell = function Cell(_ref) {
|
|
@@ -41,29 +43,11 @@ var Cell = function Cell(_ref) {
|
|
|
41
43
|
return children;
|
|
42
44
|
}
|
|
43
45
|
var styled = {
|
|
44
|
-
cell:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
sort: {
|
|
51
|
-
className: "musaex-1n2onr6 musaex-1ypdohk"
|
|
52
|
-
},
|
|
53
|
-
fullSort: {
|
|
54
|
-
0: {},
|
|
55
|
-
1: {
|
|
56
|
-
className: "musaex-14qql8p"
|
|
57
|
-
}
|
|
58
|
-
}[!!(sort === "descending") << 0],
|
|
59
|
-
halfSort: {
|
|
60
|
-
0: {
|
|
61
|
-
className: "musaex-10l6tqk musaex-13vifvy musaex-1o0tod musaex-11g3na9 musaex-b3r6kr"
|
|
62
|
-
},
|
|
63
|
-
1: {
|
|
64
|
-
className: "musaex-10l6tqk musaex-13vifvy musaex-1o0tod musaex-11g3na9 musaex-b3r6kr musaex-14qql8p"
|
|
65
|
-
}
|
|
66
|
-
}[!!(sort === "ascending") << 0]
|
|
46
|
+
cell: props(styles.headerContent["default"]),
|
|
47
|
+
handlers: props(styles.headerContent.handlers),
|
|
48
|
+
sort: props(styles.sort["default"]),
|
|
49
|
+
fullSort: props(sort === "descending" && styles.sort.checked),
|
|
50
|
+
halfSort: props(styles.sort.half, sort === "ascending" && styles.sort.checked)
|
|
67
51
|
};
|
|
68
52
|
return /*#__PURE__*/React.createElement("div", {
|
|
69
53
|
className: styled.cell.className,
|
|
@@ -10,36 +10,8 @@ var stylex = require('../../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_m
|
|
|
10
10
|
var className = require('@aiszlab/relax/class-name');
|
|
11
11
|
var theme = require('../../theme/theme.cjs');
|
|
12
12
|
var useThemeColorVars = require('../../../hooks/use-theme-color-vars.cjs');
|
|
13
|
+
var styles = require('../styles.cjs');
|
|
13
14
|
|
|
14
|
-
var styles = {
|
|
15
|
-
cell: {
|
|
16
|
-
kMzoRj: "musaex-k59kd",
|
|
17
|
-
kWkggS: "musaex-k7eln3",
|
|
18
|
-
kVAM5u: "musaex-axmpxa",
|
|
19
|
-
k9WMMc: "musaex-1yc453h",
|
|
20
|
-
kVAEAm: "musaex-1n2onr6",
|
|
21
|
-
kg3NbH: "musaex-1g3a7fl",
|
|
22
|
-
k8WAf4: "musaex-s7sbuz",
|
|
23
|
-
ksu8eU: "musaex-1y0btm7",
|
|
24
|
-
kt9PQ7: "musaex-d1xpcx",
|
|
25
|
-
$$css: true
|
|
26
|
-
},
|
|
27
|
-
unbordered: {
|
|
28
|
-
kI9HWG: "musaex-x7gz8e",
|
|
29
|
-
ko2eyy: "musaex-no41pc",
|
|
30
|
-
kqR9dF: "musaex-1o8gf8",
|
|
31
|
-
kpPfZE: "musaex-1rvbi93",
|
|
32
|
-
kOSWPn: "musaex-8l2ero",
|
|
33
|
-
kQUujV: "musaex-11jkr13",
|
|
34
|
-
knGBE: "musaex-1kmnipp",
|
|
35
|
-
kpnlHG: "musaex-192i3sz",
|
|
36
|
-
$$css: true
|
|
37
|
-
},
|
|
38
|
-
bordered: {
|
|
39
|
-
kMzoRj: "musaex-1iyq3db",
|
|
40
|
-
$$css: true
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
15
|
var Header = function Header(props) {
|
|
44
16
|
var _useTable = context.useTable(),
|
|
45
17
|
table = _useTable.table,
|
|
@@ -48,7 +20,7 @@ var Header = function Header(props) {
|
|
|
48
20
|
var _themeColorVars = useThemeColorVars.useThemeColorVars(["surface", "outline-variant"]);
|
|
49
21
|
if (!table) return null;
|
|
50
22
|
var headerGroups = table.getHeaderGroups();
|
|
51
|
-
var styled = stylex.props(styles.
|
|
23
|
+
var styled = stylex.props(styles.default.headerCell["default"], theme.$label.small, bordered && styles.default.headerCell.bordered, !bordered && styles.default.headerCell.unbordered);
|
|
52
24
|
return /*#__PURE__*/React.createElement("thead", {
|
|
53
25
|
className: className.stringify(classNames.header, props.className),
|
|
54
26
|
style: _objectSpread(_objectSpread({}, styled.style), _themeColorVars)
|
|
@@ -58,7 +30,7 @@ var Header = function Header(props) {
|
|
|
58
30
|
}, headerGroup.headers.map(function (header) {
|
|
59
31
|
return /*#__PURE__*/React.createElement("th", {
|
|
60
32
|
key: header.id,
|
|
61
|
-
className: className.stringify(styled.className),
|
|
33
|
+
className: className.stringify(styled.className, header.column.id === context.EXPAND_COLUMN_ID && classNames.expandColumn),
|
|
62
34
|
style: styled.style
|
|
63
35
|
}, header.isPlaceholder ? null : reactTable.flexRender(header.column.columnDef.header, header.getContext()));
|
|
64
36
|
}));
|
|
@@ -1,41 +1,13 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { useTable } from '../context.mjs';
|
|
3
|
+
import { useTable, EXPAND_COLUMN_ID } from '../context.mjs';
|
|
4
4
|
import { flexRender } from '@tanstack/react-table';
|
|
5
5
|
import { props } from '../../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
6
6
|
import { stringify } from '@aiszlab/relax/class-name';
|
|
7
7
|
import { $label } from '../../theme/theme.mjs';
|
|
8
8
|
import { useThemeColorVars } from '../../../hooks/use-theme-color-vars.mjs';
|
|
9
|
+
import styles from '../styles.mjs';
|
|
9
10
|
|
|
10
|
-
var styles = {
|
|
11
|
-
cell: {
|
|
12
|
-
kMzoRj: "musaex-k59kd",
|
|
13
|
-
kWkggS: "musaex-k7eln3",
|
|
14
|
-
kVAM5u: "musaex-axmpxa",
|
|
15
|
-
k9WMMc: "musaex-1yc453h",
|
|
16
|
-
kVAEAm: "musaex-1n2onr6",
|
|
17
|
-
kg3NbH: "musaex-1g3a7fl",
|
|
18
|
-
k8WAf4: "musaex-s7sbuz",
|
|
19
|
-
ksu8eU: "musaex-1y0btm7",
|
|
20
|
-
kt9PQ7: "musaex-d1xpcx",
|
|
21
|
-
$$css: true
|
|
22
|
-
},
|
|
23
|
-
unbordered: {
|
|
24
|
-
kI9HWG: "musaex-x7gz8e",
|
|
25
|
-
ko2eyy: "musaex-no41pc",
|
|
26
|
-
kqR9dF: "musaex-1o8gf8",
|
|
27
|
-
kpPfZE: "musaex-1rvbi93",
|
|
28
|
-
kOSWPn: "musaex-8l2ero",
|
|
29
|
-
kQUujV: "musaex-11jkr13",
|
|
30
|
-
knGBE: "musaex-1kmnipp",
|
|
31
|
-
kpnlHG: "musaex-192i3sz",
|
|
32
|
-
$$css: true
|
|
33
|
-
},
|
|
34
|
-
bordered: {
|
|
35
|
-
kMzoRj: "musaex-1iyq3db",
|
|
36
|
-
$$css: true
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
11
|
var Header = function Header(props$1) {
|
|
40
12
|
var _useTable = useTable(),
|
|
41
13
|
table = _useTable.table,
|
|
@@ -44,7 +16,7 @@ var Header = function Header(props$1) {
|
|
|
44
16
|
var _themeColorVars = useThemeColorVars(["surface", "outline-variant"]);
|
|
45
17
|
if (!table) return null;
|
|
46
18
|
var headerGroups = table.getHeaderGroups();
|
|
47
|
-
var styled = props(styles.
|
|
19
|
+
var styled = props(styles.headerCell["default"], $label.small, bordered && styles.headerCell.bordered, !bordered && styles.headerCell.unbordered);
|
|
48
20
|
return /*#__PURE__*/React.createElement("thead", {
|
|
49
21
|
className: stringify(classNames.header, props$1.className),
|
|
50
22
|
style: _objectSpread(_objectSpread({}, styled.style), _themeColorVars)
|
|
@@ -54,7 +26,7 @@ var Header = function Header(props$1) {
|
|
|
54
26
|
}, headerGroup.headers.map(function (header) {
|
|
55
27
|
return /*#__PURE__*/React.createElement("th", {
|
|
56
28
|
key: header.id,
|
|
57
|
-
className: stringify(styled.className),
|
|
29
|
+
className: stringify(styled.className, header.column.id === EXPAND_COLUMN_ID && classNames.expandColumn),
|
|
58
30
|
style: styled.style
|
|
59
31
|
}, header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()));
|
|
60
32
|
}));
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
4
5
|
var reactTable = require('@tanstack/react-table');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var cell = require('./header/cell.cjs');
|
|
7
8
|
var relax = require('@aiszlab/relax');
|
|
9
|
+
var context = require('./context.cjs');
|
|
10
|
+
var button = require('../button/button.cjs');
|
|
11
|
+
var expandLess = require('../icon/icons/navigation/expand-less.cjs');
|
|
12
|
+
var expandMore = require('../icon/icons/navigation/expand-more.cjs');
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* @description
|
|
11
16
|
* use columns
|
|
12
17
|
*/
|
|
13
18
|
var useColumns = function useColumns(_ref) {
|
|
14
|
-
var columns = _ref.columns
|
|
19
|
+
var columns = _ref.columns,
|
|
20
|
+
_ref$expandable = _ref.expandable,
|
|
21
|
+
expandable = _ref$expandable === void 0 ? false : _ref$expandable;
|
|
15
22
|
var helper = React.useRef(reactTable.createColumnHelper());
|
|
16
23
|
return React.useMemo(function () {
|
|
17
|
-
|
|
24
|
+
var dataColumns = columns.map(function (_ref2, index) {
|
|
18
25
|
var _ref3;
|
|
19
26
|
var key = _ref2.key,
|
|
20
27
|
render = _ref2.render,
|
|
@@ -41,19 +48,34 @@ var useColumns = function useColumns(_ref) {
|
|
|
41
48
|
}
|
|
42
49
|
});
|
|
43
50
|
});
|
|
44
|
-
|
|
51
|
+
if (!expandable) return dataColumns;
|
|
52
|
+
return [helper.current.display({
|
|
53
|
+
id: context.EXPAND_COLUMN_ID,
|
|
54
|
+
header: null,
|
|
55
|
+
cell: function cell(_ref4) {
|
|
56
|
+
var row = _ref4.row;
|
|
57
|
+
return row.getCanExpand() ? (/*#__PURE__*/React.createElement(button.Button, {
|
|
58
|
+
variant: "text",
|
|
59
|
+
size: "small",
|
|
60
|
+
"aria-label": row.getIsExpanded() ? "收起" : "展开",
|
|
61
|
+
"aria-expanded": row.getIsExpanded(),
|
|
62
|
+
onClick: row.getToggleExpandedHandler()
|
|
63
|
+
}, row.getIsExpanded() ? /*#__PURE__*/React.createElement(expandLess.default, null) : /*#__PURE__*/React.createElement(expandMore.default, null))) : null;
|
|
64
|
+
}
|
|
65
|
+
})].concat(_toConsumableArray(dataColumns));
|
|
66
|
+
}, [columns, expandable]);
|
|
45
67
|
};
|
|
46
68
|
/**
|
|
47
69
|
* @author murukal
|
|
48
70
|
* @description
|
|
49
71
|
* for context value
|
|
50
72
|
*/
|
|
51
|
-
var useContextValue = function useContextValue(
|
|
52
|
-
var _table =
|
|
53
|
-
bordered =
|
|
54
|
-
_sortDescriptor =
|
|
55
|
-
_onSortChange =
|
|
56
|
-
classNames =
|
|
73
|
+
var useContextValue = function useContextValue(_ref5) {
|
|
74
|
+
var _table = _ref5.table,
|
|
75
|
+
bordered = _ref5.bordered,
|
|
76
|
+
_sortDescriptor = _ref5.sortDescriptor,
|
|
77
|
+
_onSortChange = _ref5.onSortChange,
|
|
78
|
+
classNames = _ref5.classNames;
|
|
57
79
|
var _useControlledState = relax.useControlledState(_sortDescriptor),
|
|
58
80
|
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
59
81
|
sortDescriptor = _useControlledState2[0],
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type ColumnDef, type DeepValue, type DeepKeys } from "@tanstack/react-table";
|
|
2
2
|
import type { Column, ContextValue, SortDescriptor } from "../../types/table";
|
|
3
|
-
import type
|
|
3
|
+
import { type CLASS_NAMES } from "./context";
|
|
4
4
|
/**
|
|
5
5
|
* @description
|
|
6
6
|
* use columns
|
|
7
7
|
*/
|
|
8
|
-
export declare const useColumns: <T>({ columns }: {
|
|
8
|
+
export declare const useColumns: <T>({ columns, expandable, }: {
|
|
9
9
|
columns: Column<T>[];
|
|
10
|
+
expandable?: boolean;
|
|
10
11
|
}) => ColumnDef<T, DeepValue<T, DeepKeys<T>>>[];
|
|
11
12
|
/**
|
|
12
13
|
* @author murukal
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
3
|
import { createColumnHelper } from '@tanstack/react-table';
|
|
3
4
|
import React, { useRef, useMemo } from 'react';
|
|
4
5
|
import Cell from './header/cell.mjs';
|
|
5
6
|
import { useControlledState, useEvent } from '@aiszlab/relax';
|
|
7
|
+
import { EXPAND_COLUMN_ID } from './context.mjs';
|
|
8
|
+
import { Button } from '../button/button.mjs';
|
|
9
|
+
import IconExpandLess from '../icon/icons/navigation/expand-less.mjs';
|
|
10
|
+
import IconExpandMore from '../icon/icons/navigation/expand-more.mjs';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* @description
|
|
9
14
|
* use columns
|
|
10
15
|
*/
|
|
11
16
|
var useColumns = function useColumns(_ref) {
|
|
12
|
-
var columns = _ref.columns
|
|
17
|
+
var columns = _ref.columns,
|
|
18
|
+
_ref$expandable = _ref.expandable,
|
|
19
|
+
expandable = _ref$expandable === void 0 ? false : _ref$expandable;
|
|
13
20
|
var helper = useRef(createColumnHelper());
|
|
14
21
|
return useMemo(function () {
|
|
15
|
-
|
|
22
|
+
var dataColumns = columns.map(function (_ref2, index) {
|
|
16
23
|
var _ref3;
|
|
17
24
|
var key = _ref2.key,
|
|
18
25
|
render = _ref2.render,
|
|
@@ -39,19 +46,34 @@ var useColumns = function useColumns(_ref) {
|
|
|
39
46
|
}
|
|
40
47
|
});
|
|
41
48
|
});
|
|
42
|
-
|
|
49
|
+
if (!expandable) return dataColumns;
|
|
50
|
+
return [helper.current.display({
|
|
51
|
+
id: EXPAND_COLUMN_ID,
|
|
52
|
+
header: null,
|
|
53
|
+
cell: function cell(_ref4) {
|
|
54
|
+
var row = _ref4.row;
|
|
55
|
+
return row.getCanExpand() ? (/*#__PURE__*/React.createElement(Button, {
|
|
56
|
+
variant: "text",
|
|
57
|
+
size: "small",
|
|
58
|
+
"aria-label": row.getIsExpanded() ? "收起" : "展开",
|
|
59
|
+
"aria-expanded": row.getIsExpanded(),
|
|
60
|
+
onClick: row.getToggleExpandedHandler()
|
|
61
|
+
}, row.getIsExpanded() ? /*#__PURE__*/React.createElement(IconExpandLess, null) : /*#__PURE__*/React.createElement(IconExpandMore, null))) : null;
|
|
62
|
+
}
|
|
63
|
+
})].concat(_toConsumableArray(dataColumns));
|
|
64
|
+
}, [columns, expandable]);
|
|
43
65
|
};
|
|
44
66
|
/**
|
|
45
67
|
* @author murukal
|
|
46
68
|
* @description
|
|
47
69
|
* for context value
|
|
48
70
|
*/
|
|
49
|
-
var useContextValue = function useContextValue(
|
|
50
|
-
var _table =
|
|
51
|
-
bordered =
|
|
52
|
-
_sortDescriptor =
|
|
53
|
-
_onSortChange =
|
|
54
|
-
classNames =
|
|
71
|
+
var useContextValue = function useContextValue(_ref5) {
|
|
72
|
+
var _table = _ref5.table,
|
|
73
|
+
bordered = _ref5.bordered,
|
|
74
|
+
_sortDescriptor = _ref5.sortDescriptor,
|
|
75
|
+
_onSortChange = _ref5.onSortChange,
|
|
76
|
+
classNames = _ref5.classNames;
|
|
55
77
|
var _useControlledState = useControlledState(_sortDescriptor),
|
|
56
78
|
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
57
79
|
sortDescriptor = _useControlledState2[0],
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styles = {
|
|
6
|
+
table: {
|
|
7
|
+
"default": {
|
|
8
|
+
kzqmXN: "musaex-h8yej3",
|
|
9
|
+
kLvRdT: "musaex-1mwwwfo",
|
|
10
|
+
$$css: true
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
bodyCell: {
|
|
14
|
+
"default": {
|
|
15
|
+
kjGldf: "musaex-aafj1c",
|
|
16
|
+
kEafiO: "musaex-1ndz9a0",
|
|
17
|
+
kg3NbH: "musaex-1g3a7fl",
|
|
18
|
+
k8WAf4: "musaex-s7sbuz",
|
|
19
|
+
kVAM5u: "musaex-axmpxa",
|
|
20
|
+
ksu8eU: "musaex-1y0btm7",
|
|
21
|
+
kt9PQ7: "musaex-d1xpcx",
|
|
22
|
+
$$css: true
|
|
23
|
+
},
|
|
24
|
+
bordered: {
|
|
25
|
+
kjGldf: "musaex-imutj9",
|
|
26
|
+
$$css: true
|
|
27
|
+
},
|
|
28
|
+
child: {
|
|
29
|
+
kZCmMZ: "musaex-1sznsej",
|
|
30
|
+
$$css: true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
headerCell: {
|
|
34
|
+
"default": {
|
|
35
|
+
kMzoRj: "musaex-k59kd",
|
|
36
|
+
kWkggS: "musaex-k7eln3",
|
|
37
|
+
kVAM5u: "musaex-axmpxa",
|
|
38
|
+
k9WMMc: "musaex-1yc453h",
|
|
39
|
+
kVAEAm: "musaex-1n2onr6",
|
|
40
|
+
kg3NbH: "musaex-1g3a7fl",
|
|
41
|
+
k8WAf4: "musaex-s7sbuz",
|
|
42
|
+
ksu8eU: "musaex-1y0btm7",
|
|
43
|
+
kt9PQ7: "musaex-d1xpcx",
|
|
44
|
+
$$css: true
|
|
45
|
+
},
|
|
46
|
+
unbordered: {
|
|
47
|
+
kI9HWG: "musaex-x7gz8e",
|
|
48
|
+
ko2eyy: "musaex-no41pc",
|
|
49
|
+
kqR9dF: "musaex-1o8gf8",
|
|
50
|
+
kpPfZE: "musaex-1rvbi93",
|
|
51
|
+
kOSWPn: "musaex-8l2ero",
|
|
52
|
+
kQUujV: "musaex-11jkr13",
|
|
53
|
+
knGBE: "musaex-1kmnipp",
|
|
54
|
+
kpnlHG: "musaex-192i3sz",
|
|
55
|
+
$$css: true
|
|
56
|
+
},
|
|
57
|
+
bordered: {
|
|
58
|
+
kMzoRj: "musaex-1iyq3db",
|
|
59
|
+
$$css: true
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
headerContent: {
|
|
63
|
+
"default": {
|
|
64
|
+
k1xSpc: "musaex-78zum5",
|
|
65
|
+
kjj79g: "musaex-1qughib",
|
|
66
|
+
kGNEyG: "musaex-6s0dn4",
|
|
67
|
+
$$css: true
|
|
68
|
+
},
|
|
69
|
+
handlers: {
|
|
70
|
+
k1xSpc: "musaex-3nfvp2",
|
|
71
|
+
kXwgrk: "musaex-1q0g3np",
|
|
72
|
+
kOIVth: "musaex-15wobh7",
|
|
73
|
+
kMwMTN: "musaex-14kusyn",
|
|
74
|
+
kfSwDN: "musaex-87ps6o",
|
|
75
|
+
$$css: true
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
sort: {
|
|
79
|
+
"default": {
|
|
80
|
+
kVAEAm: "musaex-1n2onr6",
|
|
81
|
+
kkrTdU: "musaex-1ypdohk",
|
|
82
|
+
$$css: true
|
|
83
|
+
},
|
|
84
|
+
half: {
|
|
85
|
+
kVAEAm: "musaex-10l6tqk",
|
|
86
|
+
k87sOh: "musaex-13vifvy",
|
|
87
|
+
kLqNvP: "musaex-1o0tod",
|
|
88
|
+
kZKoxP: "musaex-11g3na9",
|
|
89
|
+
kVQacm: "musaex-b3r6kr",
|
|
90
|
+
$$css: true
|
|
91
|
+
},
|
|
92
|
+
checked: {
|
|
93
|
+
kMwMTN: "musaex-14qql8p",
|
|
94
|
+
$$css: true
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.default = styles;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
declare const styles: {
|
|
2
|
+
table: Readonly<{
|
|
3
|
+
readonly default: Readonly<{
|
|
4
|
+
readonly width: import("@stylexjs/stylex").StyleXClassNameFor<"width", "100%">;
|
|
5
|
+
readonly borderCollapse: import("@stylexjs/stylex").StyleXClassNameFor<"borderCollapse", "collapse">;
|
|
6
|
+
}>;
|
|
7
|
+
}>;
|
|
8
|
+
bodyCell: Readonly<{
|
|
9
|
+
readonly default: Readonly<{
|
|
10
|
+
readonly borderInlineWidth: import("@stylexjs/stylex").StyleXClassNameFor<"borderInlineWidth", string>;
|
|
11
|
+
readonly borderBlockStartWidth: import("@stylexjs/stylex").StyleXClassNameFor<"borderBlockStartWidth", string>;
|
|
12
|
+
readonly paddingInline: import("@stylexjs/stylex").StyleXClassNameFor<"paddingInline", string>;
|
|
13
|
+
readonly paddingBlock: import("@stylexjs/stylex").StyleXClassNameFor<"paddingBlock", string>;
|
|
14
|
+
readonly borderColor: import("@stylexjs/stylex").StyleXClassNameFor<"borderColor", "var(--color-outline-variant)">;
|
|
15
|
+
readonly borderStyle: import("@stylexjs/stylex").StyleXClassNameFor<"borderStyle", "solid">;
|
|
16
|
+
readonly borderBlockEndWidth: import("@stylexjs/stylex").StyleXClassNameFor<"borderBlockEndWidth", string>;
|
|
17
|
+
}>;
|
|
18
|
+
readonly bordered: Readonly<{
|
|
19
|
+
readonly borderInlineWidth: import("@stylexjs/stylex").StyleXClassNameFor<"borderInlineWidth", string>;
|
|
20
|
+
}>;
|
|
21
|
+
readonly child: Readonly<{
|
|
22
|
+
readonly paddingInlineStart: import("@stylexjs/stylex").StyleXClassNameFor<"paddingInlineStart", `calc(var(--depth) * ${import("@stylexjs/stylex").StyleXVar<string>})`>;
|
|
23
|
+
}>;
|
|
24
|
+
}>;
|
|
25
|
+
headerCell: Readonly<{
|
|
26
|
+
readonly default: Readonly<{
|
|
27
|
+
readonly borderWidth: import("@stylexjs/stylex").StyleXClassNameFor<"borderWidth", string>;
|
|
28
|
+
readonly backgroundColor: import("@stylexjs/stylex").StyleXClassNameFor<"backgroundColor", "var(--color-surface)">;
|
|
29
|
+
readonly borderColor: import("@stylexjs/stylex").StyleXClassNameFor<"borderColor", "var(--color-outline-variant)">;
|
|
30
|
+
readonly textAlign: import("@stylexjs/stylex").StyleXClassNameFor<"textAlign", "start">;
|
|
31
|
+
readonly position: import("@stylexjs/stylex").StyleXClassNameFor<"position", "relative">;
|
|
32
|
+
readonly paddingInline: import("@stylexjs/stylex").StyleXClassNameFor<"paddingInline", string>;
|
|
33
|
+
readonly paddingBlock: import("@stylexjs/stylex").StyleXClassNameFor<"paddingBlock", string>;
|
|
34
|
+
readonly borderStyle: import("@stylexjs/stylex").StyleXClassNameFor<"borderStyle", "solid">;
|
|
35
|
+
readonly borderBottomWidth: import("@stylexjs/stylex").StyleXClassNameFor<"borderBottomWidth", string>;
|
|
36
|
+
}>;
|
|
37
|
+
readonly unbordered: Readonly<{
|
|
38
|
+
readonly ":not(:last-of-type)::after": import("@stylexjs/stylex").StyleXClassNameFor<":not(:last-of-type)::after", {
|
|
39
|
+
readonly content: "\"\"";
|
|
40
|
+
readonly position: "absolute";
|
|
41
|
+
readonly top: "50%";
|
|
42
|
+
readonly width: import("@stylexjs/stylex").StyleXVar<string>;
|
|
43
|
+
readonly height: import("@stylexjs/stylex").StyleXVar<string>;
|
|
44
|
+
readonly backgroundColor: "var(--color-outline-variant)";
|
|
45
|
+
readonly transform: "translateY(-50%)";
|
|
46
|
+
readonly insetInlineEnd: 0;
|
|
47
|
+
}>;
|
|
48
|
+
}>;
|
|
49
|
+
readonly bordered: Readonly<{
|
|
50
|
+
readonly borderWidth: import("@stylexjs/stylex").StyleXClassNameFor<"borderWidth", string>;
|
|
51
|
+
}>;
|
|
52
|
+
}>;
|
|
53
|
+
headerContent: Readonly<{
|
|
54
|
+
readonly default: Readonly<{
|
|
55
|
+
readonly display: import("@stylexjs/stylex").StyleXClassNameFor<"display", "flex">;
|
|
56
|
+
readonly justifyContent: import("@stylexjs/stylex").StyleXClassNameFor<"justifyContent", "space-between">;
|
|
57
|
+
readonly alignItems: import("@stylexjs/stylex").StyleXClassNameFor<"alignItems", "center">;
|
|
58
|
+
}>;
|
|
59
|
+
readonly handlers: Readonly<{
|
|
60
|
+
readonly display: import("@stylexjs/stylex").StyleXClassNameFor<"display", "inline-flex">;
|
|
61
|
+
readonly flexDirection: import("@stylexjs/stylex").StyleXClassNameFor<"flexDirection", "row">;
|
|
62
|
+
readonly gap: import("@stylexjs/stylex").StyleXClassNameFor<"gap", string>;
|
|
63
|
+
readonly color: import("@stylexjs/stylex").StyleXClassNameFor<"color", "var(--color-surface-container-highest)">;
|
|
64
|
+
readonly userSelect: import("@stylexjs/stylex").StyleXClassNameFor<"userSelect", "none">;
|
|
65
|
+
}>;
|
|
66
|
+
}>;
|
|
67
|
+
sort: Readonly<{
|
|
68
|
+
readonly default: Readonly<{
|
|
69
|
+
readonly position: import("@stylexjs/stylex").StyleXClassNameFor<"position", "relative">;
|
|
70
|
+
readonly cursor: import("@stylexjs/stylex").StyleXClassNameFor<"cursor", "pointer">;
|
|
71
|
+
}>;
|
|
72
|
+
readonly half: Readonly<{
|
|
73
|
+
readonly position: import("@stylexjs/stylex").StyleXClassNameFor<"position", "absolute">;
|
|
74
|
+
readonly insetBlockStart: import("@stylexjs/stylex").StyleXClassNameFor<"insetBlockStart", 0>;
|
|
75
|
+
readonly insetInlineStart: import("@stylexjs/stylex").StyleXClassNameFor<"insetInlineStart", 0>;
|
|
76
|
+
readonly height: import("@stylexjs/stylex").StyleXClassNameFor<"height", string>;
|
|
77
|
+
readonly overflow: import("@stylexjs/stylex").StyleXClassNameFor<"overflow", "hidden">;
|
|
78
|
+
}>;
|
|
79
|
+
readonly checked: Readonly<{
|
|
80
|
+
readonly color: import("@stylexjs/stylex").StyleXClassNameFor<"color", "var(--color-primary)">;
|
|
81
|
+
}>;
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
export default styles;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
table: {
|
|
3
|
+
"default": {
|
|
4
|
+
kzqmXN: "musaex-h8yej3",
|
|
5
|
+
kLvRdT: "musaex-1mwwwfo",
|
|
6
|
+
$$css: true
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
bodyCell: {
|
|
10
|
+
"default": {
|
|
11
|
+
kjGldf: "musaex-aafj1c",
|
|
12
|
+
kEafiO: "musaex-1ndz9a0",
|
|
13
|
+
kg3NbH: "musaex-1g3a7fl",
|
|
14
|
+
k8WAf4: "musaex-s7sbuz",
|
|
15
|
+
kVAM5u: "musaex-axmpxa",
|
|
16
|
+
ksu8eU: "musaex-1y0btm7",
|
|
17
|
+
kt9PQ7: "musaex-d1xpcx",
|
|
18
|
+
$$css: true
|
|
19
|
+
},
|
|
20
|
+
bordered: {
|
|
21
|
+
kjGldf: "musaex-imutj9",
|
|
22
|
+
$$css: true
|
|
23
|
+
},
|
|
24
|
+
child: {
|
|
25
|
+
kZCmMZ: "musaex-1sznsej",
|
|
26
|
+
$$css: true
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
headerCell: {
|
|
30
|
+
"default": {
|
|
31
|
+
kMzoRj: "musaex-k59kd",
|
|
32
|
+
kWkggS: "musaex-k7eln3",
|
|
33
|
+
kVAM5u: "musaex-axmpxa",
|
|
34
|
+
k9WMMc: "musaex-1yc453h",
|
|
35
|
+
kVAEAm: "musaex-1n2onr6",
|
|
36
|
+
kg3NbH: "musaex-1g3a7fl",
|
|
37
|
+
k8WAf4: "musaex-s7sbuz",
|
|
38
|
+
ksu8eU: "musaex-1y0btm7",
|
|
39
|
+
kt9PQ7: "musaex-d1xpcx",
|
|
40
|
+
$$css: true
|
|
41
|
+
},
|
|
42
|
+
unbordered: {
|
|
43
|
+
kI9HWG: "musaex-x7gz8e",
|
|
44
|
+
ko2eyy: "musaex-no41pc",
|
|
45
|
+
kqR9dF: "musaex-1o8gf8",
|
|
46
|
+
kpPfZE: "musaex-1rvbi93",
|
|
47
|
+
kOSWPn: "musaex-8l2ero",
|
|
48
|
+
kQUujV: "musaex-11jkr13",
|
|
49
|
+
knGBE: "musaex-1kmnipp",
|
|
50
|
+
kpnlHG: "musaex-192i3sz",
|
|
51
|
+
$$css: true
|
|
52
|
+
},
|
|
53
|
+
bordered: {
|
|
54
|
+
kMzoRj: "musaex-1iyq3db",
|
|
55
|
+
$$css: true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
headerContent: {
|
|
59
|
+
"default": {
|
|
60
|
+
k1xSpc: "musaex-78zum5",
|
|
61
|
+
kjj79g: "musaex-1qughib",
|
|
62
|
+
kGNEyG: "musaex-6s0dn4",
|
|
63
|
+
$$css: true
|
|
64
|
+
},
|
|
65
|
+
handlers: {
|
|
66
|
+
k1xSpc: "musaex-3nfvp2",
|
|
67
|
+
kXwgrk: "musaex-1q0g3np",
|
|
68
|
+
kOIVth: "musaex-15wobh7",
|
|
69
|
+
kMwMTN: "musaex-14kusyn",
|
|
70
|
+
kfSwDN: "musaex-87ps6o",
|
|
71
|
+
$$css: true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
sort: {
|
|
75
|
+
"default": {
|
|
76
|
+
kVAEAm: "musaex-1n2onr6",
|
|
77
|
+
kkrTdU: "musaex-1ypdohk",
|
|
78
|
+
$$css: true
|
|
79
|
+
},
|
|
80
|
+
half: {
|
|
81
|
+
kVAEAm: "musaex-10l6tqk",
|
|
82
|
+
k87sOh: "musaex-13vifvy",
|
|
83
|
+
kLqNvP: "musaex-1o0tod",
|
|
84
|
+
kZKoxP: "musaex-11g3na9",
|
|
85
|
+
kVQacm: "musaex-b3r6kr",
|
|
86
|
+
$$css: true
|
|
87
|
+
},
|
|
88
|
+
checked: {
|
|
89
|
+
kMwMTN: "musaex-14qql8p",
|
|
90
|
+
$$css: true
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { styles as default };
|
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
6
7
|
var reactTable = require('@tanstack/react-table');
|
|
7
8
|
var React = require('react');
|
|
8
9
|
var hooks = require('./hooks.cjs');
|
|
9
10
|
var header = require('./header/header.cjs');
|
|
10
11
|
var context = require('./context.cjs');
|
|
11
12
|
var body = require('./body.cjs');
|
|
13
|
+
var stylex = require('../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.cjs');
|
|
12
14
|
var className = require('@aiszlab/relax/class-name');
|
|
13
15
|
var useClassNames = require('../../hooks/use-class-names.cjs');
|
|
14
16
|
var loading = require('../loading/loading.cjs');
|
|
17
|
+
var styles = require('./styles.cjs');
|
|
18
|
+
var relax = require('@aiszlab/relax');
|
|
15
19
|
|
|
16
20
|
var Table = function Table(_ref) {
|
|
17
21
|
var _ref$bordered = _ref.bordered,
|
|
@@ -25,16 +29,56 @@ var Table = function Table(_ref) {
|
|
|
25
29
|
className$1 = _ref.className,
|
|
26
30
|
style = _ref.style,
|
|
27
31
|
_ref$loading = _ref.loading,
|
|
28
|
-
loading$1 = _ref$loading === void 0 ? false : _ref$loading
|
|
32
|
+
loading$1 = _ref$loading === void 0 ? false : _ref$loading,
|
|
33
|
+
_ref$expandable = _ref.expandable,
|
|
34
|
+
expandable = _ref$expandable === void 0 ? false : _ref$expandable,
|
|
35
|
+
expandedKeys = _ref.expandedKeys,
|
|
36
|
+
_ref$defaultExpandedK = _ref.defaultExpandedKeys,
|
|
37
|
+
defaultExpandedKeys = _ref$defaultExpandedK === void 0 ? [] : _ref$defaultExpandedK,
|
|
38
|
+
onExpandedKeysChange = _ref.onExpandedKeysChange,
|
|
39
|
+
rowKey = _ref.rowKey;
|
|
29
40
|
var classNames = useClassNames.useClassNames(context.CLASS_NAMES);
|
|
30
41
|
var columns = hooks.useColumns({
|
|
31
|
-
columns: _columns
|
|
42
|
+
columns: _columns,
|
|
43
|
+
expandable: expandable
|
|
32
44
|
});
|
|
33
|
-
var
|
|
45
|
+
var _useState = React.useState(function () {
|
|
46
|
+
return Object.fromEntries(defaultExpandedKeys.map(function (key) {
|
|
47
|
+
return [String(key), true];
|
|
48
|
+
}));
|
|
49
|
+
}),
|
|
50
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
51
|
+
uncontrolledExpanded = _useState2[0],
|
|
52
|
+
setUncontrolledExpanded = _useState2[1];
|
|
53
|
+
var expanded = React.useMemo(function () {
|
|
54
|
+
return relax.isUndefined(expandedKeys) ? uncontrolledExpanded : Object.fromEntries(expandedKeys.map(function (key) {
|
|
55
|
+
return [String(key), true];
|
|
56
|
+
}));
|
|
57
|
+
}, [expandedKeys, uncontrolledExpanded]);
|
|
58
|
+
var table = reactTable.useReactTable(_objectSpread(_objectSpread({
|
|
34
59
|
columns: columns,
|
|
35
60
|
data: dataSource,
|
|
36
61
|
getCoreRowModel: reactTable.getCoreRowModel()
|
|
37
|
-
}
|
|
62
|
+
}, expandable && {
|
|
63
|
+
getSubRows: function getSubRows(record) {
|
|
64
|
+
return record.children;
|
|
65
|
+
},
|
|
66
|
+
getExpandedRowModel: reactTable.getExpandedRowModel(),
|
|
67
|
+
state: {
|
|
68
|
+
expanded: expanded
|
|
69
|
+
},
|
|
70
|
+
onExpandedChange: function onExpandedChange(updater) {
|
|
71
|
+
var next = relax.isFunction(updater) ? updater(expanded) : updater;
|
|
72
|
+
if (relax.isUndefined(expandedKeys)) setUncontrolledExpanded(next);
|
|
73
|
+
onExpandedKeysChange === null || onExpandedKeysChange === void 0 || onExpandedKeysChange(next === true ? table.getRowModel().flatRows.map(function (row) {
|
|
74
|
+
return row.id;
|
|
75
|
+
}) : Object.keys(next));
|
|
76
|
+
}
|
|
77
|
+
}), rowKey && {
|
|
78
|
+
getRowId: function getRowId(record, index, parent) {
|
|
79
|
+
return String(relax.isFunction(rowKey) ? rowKey(record, index, parent === null || parent === void 0 ? void 0 : parent.original) : record[rowKey]);
|
|
80
|
+
}
|
|
81
|
+
}));
|
|
38
82
|
var contextValue = hooks.useContextValue({
|
|
39
83
|
table: table,
|
|
40
84
|
bordered: bordered,
|
|
@@ -42,9 +86,7 @@ var Table = function Table(_ref) {
|
|
|
42
86
|
onSortChange: onSortChange,
|
|
43
87
|
classNames: classNames
|
|
44
88
|
});
|
|
45
|
-
var styled =
|
|
46
|
-
className: "musaex-h8yej3 musaex-1mwwwfo"
|
|
47
|
-
};
|
|
89
|
+
var styled = stylex.props(styles.default.table["default"]);
|
|
48
90
|
return /*#__PURE__*/React.createElement(context.Context.Provider, {
|
|
49
91
|
value: contextValue
|
|
50
92
|
}, /*#__PURE__*/React.createElement(loading.default, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { TableProps } from "../../types/table";
|
|
3
|
-
declare const Table: <T>({ bordered, dataSource, columns: _columns, sortDescriptor, onSortChange, className, style, loading, }: TableProps<T>) => React.JSX.Element;
|
|
3
|
+
declare const Table: <T>({ bordered, dataSource, columns: _columns, sortDescriptor, onSortChange, className, style, loading, expandable, expandedKeys, defaultExpandedKeys, onExpandedKeysChange, rowKey, }: TableProps<T>) => React.JSX.Element;
|
|
4
4
|
export default Table;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
+
import { useReactTable, getCoreRowModel, getExpandedRowModel } from '@tanstack/react-table';
|
|
4
|
+
import React, { useState, useMemo } from 'react';
|
|
4
5
|
import { useColumns, useContextValue } from './hooks.mjs';
|
|
5
6
|
import Header from './header/header.mjs';
|
|
6
7
|
import { Context, CLASS_NAMES } from './context.mjs';
|
|
7
8
|
import Body from './body.mjs';
|
|
9
|
+
import { props } from '../../node_modules/.pnpm/@stylexjs_stylex@0.19.0/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
8
10
|
import { stringify } from '@aiszlab/relax/class-name';
|
|
9
11
|
import { useClassNames } from '../../hooks/use-class-names.mjs';
|
|
10
12
|
import Loading from '../loading/loading.mjs';
|
|
13
|
+
import styles from './styles.mjs';
|
|
14
|
+
import { isUndefined, isFunction } from '@aiszlab/relax';
|
|
11
15
|
|
|
12
16
|
var Table = function Table(_ref) {
|
|
13
17
|
var _ref$bordered = _ref.bordered,
|
|
@@ -21,16 +25,56 @@ var Table = function Table(_ref) {
|
|
|
21
25
|
className = _ref.className,
|
|
22
26
|
style = _ref.style,
|
|
23
27
|
_ref$loading = _ref.loading,
|
|
24
|
-
loading = _ref$loading === void 0 ? false : _ref$loading
|
|
28
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
29
|
+
_ref$expandable = _ref.expandable,
|
|
30
|
+
expandable = _ref$expandable === void 0 ? false : _ref$expandable,
|
|
31
|
+
expandedKeys = _ref.expandedKeys,
|
|
32
|
+
_ref$defaultExpandedK = _ref.defaultExpandedKeys,
|
|
33
|
+
defaultExpandedKeys = _ref$defaultExpandedK === void 0 ? [] : _ref$defaultExpandedK,
|
|
34
|
+
onExpandedKeysChange = _ref.onExpandedKeysChange,
|
|
35
|
+
rowKey = _ref.rowKey;
|
|
25
36
|
var classNames = useClassNames(CLASS_NAMES);
|
|
26
37
|
var columns = useColumns({
|
|
27
|
-
columns: _columns
|
|
38
|
+
columns: _columns,
|
|
39
|
+
expandable: expandable
|
|
28
40
|
});
|
|
29
|
-
var
|
|
41
|
+
var _useState = useState(function () {
|
|
42
|
+
return Object.fromEntries(defaultExpandedKeys.map(function (key) {
|
|
43
|
+
return [String(key), true];
|
|
44
|
+
}));
|
|
45
|
+
}),
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
uncontrolledExpanded = _useState2[0],
|
|
48
|
+
setUncontrolledExpanded = _useState2[1];
|
|
49
|
+
var expanded = useMemo(function () {
|
|
50
|
+
return isUndefined(expandedKeys) ? uncontrolledExpanded : Object.fromEntries(expandedKeys.map(function (key) {
|
|
51
|
+
return [String(key), true];
|
|
52
|
+
}));
|
|
53
|
+
}, [expandedKeys, uncontrolledExpanded]);
|
|
54
|
+
var table = useReactTable(_objectSpread(_objectSpread({
|
|
30
55
|
columns: columns,
|
|
31
56
|
data: dataSource,
|
|
32
57
|
getCoreRowModel: getCoreRowModel()
|
|
33
|
-
}
|
|
58
|
+
}, expandable && {
|
|
59
|
+
getSubRows: function getSubRows(record) {
|
|
60
|
+
return record.children;
|
|
61
|
+
},
|
|
62
|
+
getExpandedRowModel: getExpandedRowModel(),
|
|
63
|
+
state: {
|
|
64
|
+
expanded: expanded
|
|
65
|
+
},
|
|
66
|
+
onExpandedChange: function onExpandedChange(updater) {
|
|
67
|
+
var next = isFunction(updater) ? updater(expanded) : updater;
|
|
68
|
+
if (isUndefined(expandedKeys)) setUncontrolledExpanded(next);
|
|
69
|
+
onExpandedKeysChange === null || onExpandedKeysChange === void 0 || onExpandedKeysChange(next === true ? table.getRowModel().flatRows.map(function (row) {
|
|
70
|
+
return row.id;
|
|
71
|
+
}) : Object.keys(next));
|
|
72
|
+
}
|
|
73
|
+
}), rowKey && {
|
|
74
|
+
getRowId: function getRowId(record, index, parent) {
|
|
75
|
+
return String(isFunction(rowKey) ? rowKey(record, index, parent === null || parent === void 0 ? void 0 : parent.original) : record[rowKey]);
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
34
78
|
var contextValue = useContextValue({
|
|
35
79
|
table: table,
|
|
36
80
|
bordered: bordered,
|
|
@@ -38,9 +82,7 @@ var Table = function Table(_ref) {
|
|
|
38
82
|
onSortChange: onSortChange,
|
|
39
83
|
classNames: classNames
|
|
40
84
|
});
|
|
41
|
-
var styled =
|
|
42
|
-
className: "musaex-h8yej3 musaex-1mwwwfo"
|
|
43
|
-
};
|
|
85
|
+
var styled = props(styles.table["default"]);
|
|
44
86
|
return /*#__PURE__*/React.createElement(Context.Provider, {
|
|
45
87
|
value: contextValue
|
|
46
88
|
}, /*#__PURE__*/React.createElement(Loading, {
|
package/dist/styles.css
CHANGED
|
@@ -1400,6 +1400,10 @@
|
|
|
1400
1400
|
padding-inline-end: var(--musaex-1vpnstl);
|
|
1401
1401
|
}
|
|
1402
1402
|
|
|
1403
|
+
.musaex-1sznsej {
|
|
1404
|
+
padding-inline-start: calc(var(--depth) * var(--musaex-14eq97i));
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1403
1407
|
.musaex-4qvwnj {
|
|
1404
1408
|
padding-inline-start: calc(var(--musaex-16suft8) / 2 - var(--musaex-1035pbm));
|
|
1405
1409
|
}
|
package/dist/types/table.d.ts
CHANGED
|
@@ -85,6 +85,23 @@ export type TableProps<T> = ComponentProps & {
|
|
|
85
85
|
* @default false
|
|
86
86
|
*/
|
|
87
87
|
loading?: boolean;
|
|
88
|
+
/** Enable hierarchical rows. Records are read from their `children` property. @default false */
|
|
89
|
+
expandable?: boolean;
|
|
90
|
+
/** Stable identifiers of expanded rows (controlled). */
|
|
91
|
+
expandedKeys?: Key[];
|
|
92
|
+
/** Initially expanded row identifiers (uncontrolled). */
|
|
93
|
+
defaultExpandedKeys?: Key[];
|
|
94
|
+
/** Called whenever the expanded row identifiers change. */
|
|
95
|
+
onExpandedKeysChange?: (keys: Key[]) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Stable row identifier. Hierarchical tables should always provide this rather than relying on
|
|
98
|
+
* TanStack Table's positional row ids.
|
|
99
|
+
*/
|
|
100
|
+
rowKey?: DeepKeys<T> | ((record: T, index: number, parent?: T) => Key);
|
|
101
|
+
};
|
|
102
|
+
/** Recursive record shape used by the built-in hierarchical-row reader. */
|
|
103
|
+
export type ExpandableRecord<T> = T & {
|
|
104
|
+
children?: ExpandableRecord<T>[];
|
|
88
105
|
};
|
|
89
106
|
/**
|
|
90
107
|
* @author murukal
|