@moneyforward/mfui-components 3.6.0 → 3.8.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/src/DataGrid/index.d.ts +16 -8
- package/dist/src/DataGrid/index.js +9 -1
- package/dist/src/{DataGrid/DataGrid.d.ts → DataTable/DataTable.d.ts} +94 -82
- package/dist/src/{DataGrid/DataGrid.js → DataTable/DataTable.js} +120 -97
- package/dist/src/{DataGrid/DataGrid.types.d.ts → DataTable/DataTable.types.d.ts} +11 -11
- package/dist/src/DataTable/DataTableBody/DataTableBody.d.ts +1 -0
- package/dist/src/DataTable/DataTableBody/DataTableBody.js +19 -0
- package/dist/src/{DataGrid/DataGridBody/DataGridBody.types.d.ts → DataTable/DataTableBody/DataTableBody.types.d.ts} +2 -2
- package/dist/src/DataTable/DataTableBody/index.d.ts +2 -0
- package/dist/src/DataTable/DataTableBody/index.js +1 -0
- package/dist/src/DataTable/DataTableCell/DataTableCell.d.ts +2 -0
- package/dist/src/{DataGrid/DataGridCell/DataGridCell.js → DataTable/DataTableCell/DataTableCell.js} +20 -13
- package/dist/src/{DataGrid/DataGridCell/DataGridCell.types.d.ts → DataTable/DataTableCell/DataTableCell.types.d.ts} +8 -8
- package/dist/src/DataTable/DataTableCell/index.d.ts +2 -0
- package/dist/src/DataTable/DataTableCell/index.js +1 -0
- package/dist/src/DataTable/DataTableHeader/DataTableHeader.d.ts +1 -0
- package/dist/src/DataTable/DataTableHeader/DataTableHeader.js +12 -0
- package/dist/src/{DataGrid/DataGridHeader/DataGridHeader.types.d.ts → DataTable/DataTableHeader/DataTableHeader.types.d.ts} +2 -2
- package/dist/src/DataTable/DataTableHeader/index.d.ts +2 -0
- package/dist/src/DataTable/DataTableHeader/index.js +1 -0
- package/dist/src/DataTable/DataTableHeaderCell/DataTableHeaderCell.d.ts +2 -0
- package/dist/src/DataTable/DataTableHeaderCell/DataTableHeaderCell.js +58 -0
- package/dist/src/{DataGrid/DataGridHeaderCell/DataGridHeaderCell.types.d.ts → DataTable/DataTableHeaderCell/DataTableHeaderCell.types.d.ts} +6 -6
- package/dist/src/DataTable/DataTableHeaderCell/index.d.ts +2 -0
- package/dist/src/DataTable/DataTableHeaderCell/index.js +1 -0
- package/dist/src/DataTable/DataTableHeaderRow/DataTableHeaderRow.d.ts +2 -0
- package/dist/src/DataTable/DataTableHeaderRow/DataTableHeaderRow.js +31 -0
- package/dist/src/{DataGrid/DataGridHeaderRow/DataGridHeaderRow.types.d.ts → DataTable/DataTableHeaderRow/DataTableHeaderRow.types.d.ts} +3 -3
- package/dist/src/DataTable/DataTableHeaderRow/index.d.ts +2 -0
- package/dist/src/DataTable/DataTableHeaderRow/index.js +1 -0
- package/dist/src/DataTable/DataTableProvider.d.ts +27 -0
- package/dist/src/{DataGrid/DataGridProvider.js → DataTable/DataTableProvider.js} +9 -9
- package/dist/src/DataTable/DataTableRow/DataTableRow.d.ts +2 -0
- package/dist/src/{DataGrid/DataGridRow/DataGridRow.js → DataTable/DataTableRow/DataTableRow.js} +11 -10
- package/dist/src/{DataGrid/DataGridRow/DataGridRow.types.d.ts → DataTable/DataTableRow/DataTableRow.types.d.ts} +5 -5
- package/dist/src/DataTable/DataTableRow/index.d.ts +2 -0
- package/dist/src/DataTable/DataTableRow/index.js +1 -0
- package/dist/src/DataTable/index.d.ts +8 -0
- package/dist/src/DataTable/index.js +1 -0
- package/dist/src/MainNavigation/BaseMainNavigation.js +25 -10
- package/dist/src/MainNavigation/MainNavigation.types.d.ts +49 -1
- package/dist/src/MainNavigation/NarrowViewportMainNavigation.js +17 -2
- package/dist/src/StatusLabel/StatusLabel.d.ts +1 -0
- package/dist/src/StatusLabel/StatusLabel.js +2 -2
- package/dist/src/StatusLabel/StatusLabel.types.d.ts +6 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/utilities/dom/useFixedColumns.d.ts +1 -1
- package/dist/src/utilities/dom/useFixedColumns.js +1 -1
- package/dist/src/utilities/react/isComponentOrWrapped.d.ts +7 -7
- package/dist/src/utilities/react/isComponentOrWrapped.js +7 -7
- package/dist/styled-system/jsx/is-valid-prop.js +1 -1
- package/dist/styled-system/patterns/divider.d.ts +1 -1
- package/dist/styled-system/patterns/float.d.ts +1 -1
- package/dist/styled-system/recipes/base-main-navigation-slot-recipe.d.ts +1 -1
- package/dist/styled-system/recipes/base-main-navigation-slot-recipe.js +12 -0
- package/dist/styled-system/recipes/data-table-body-slot-recipe.d.ts +33 -0
- package/dist/styled-system/recipes/data-table-body-slot-recipe.js +28 -0
- package/dist/styled-system/recipes/data-table-cell-slot-recipe.d.ts +38 -0
- package/dist/styled-system/recipes/data-table-cell-slot-recipe.js +77 -0
- package/dist/styled-system/recipes/data-table-header-cell-slot-recipe.d.ts +37 -0
- package/dist/styled-system/recipes/data-table-header-cell-slot-recipe.js +73 -0
- package/dist/styled-system/recipes/data-table-header-row-slot-recipe.d.ts +33 -0
- package/dist/styled-system/recipes/data-table-header-row-slot-recipe.js +28 -0
- package/dist/styled-system/recipes/data-table-header-slot-recipe.d.ts +33 -0
- package/dist/styled-system/recipes/data-table-header-slot-recipe.js +35 -0
- package/dist/styled-system/recipes/data-table-row-slot-recipe.d.ts +36 -0
- package/dist/styled-system/recipes/{data-grid-row-slot-recipe.js → data-table-row-slot-recipe.js} +13 -13
- package/dist/styled-system/recipes/data-table-slot-recipe.d.ts +36 -0
- package/dist/styled-system/recipes/data-table-slot-recipe.js +45 -0
- package/dist/styled-system/recipes/index.d.ts +7 -7
- package/dist/styled-system/recipes/index.js +7 -7
- package/dist/styled-system/recipes/narrow-viewport-main-navigation-slot-recipe.d.ts +1 -1
- package/dist/styled-system/recipes/narrow-viewport-main-navigation-slot-recipe.js +12 -0
- package/dist/styled-system/recipes/status-label-slot-recipe.d.ts +4 -0
- package/dist/styled-system/recipes/status-label-slot-recipe.js +9 -1
- package/dist/styled-system/tokens/index.js +117 -117
- package/dist/styled-system/tokens/tokens.d.ts +2 -2
- package/dist/styled-system/types/csstype.d.ts +6405 -5133
- package/dist/styled-system/types/style-props.d.ts +2748 -2163
- package/dist/styled-system/types/system-types.d.ts +14 -132
- package/dist/styles.css +222 -515
- package/dist/theme-orange.css +3 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/dist/src/DataGrid/DataGridBody/DataGridBody.d.ts +0 -1
- package/dist/src/DataGrid/DataGridBody/DataGridBody.js +0 -17
- package/dist/src/DataGrid/DataGridBody/index.d.ts +0 -2
- package/dist/src/DataGrid/DataGridBody/index.js +0 -1
- package/dist/src/DataGrid/DataGridCell/DataGridCell.d.ts +0 -2
- package/dist/src/DataGrid/DataGridCell/index.d.ts +0 -2
- package/dist/src/DataGrid/DataGridCell/index.js +0 -1
- package/dist/src/DataGrid/DataGridHeader/DataGridHeader.d.ts +0 -1
- package/dist/src/DataGrid/DataGridHeader/DataGridHeader.js +0 -11
- package/dist/src/DataGrid/DataGridHeader/index.d.ts +0 -2
- package/dist/src/DataGrid/DataGridHeader/index.js +0 -1
- package/dist/src/DataGrid/DataGridHeaderCell/DataGridHeaderCell.d.ts +0 -2
- package/dist/src/DataGrid/DataGridHeaderCell/DataGridHeaderCell.js +0 -50
- package/dist/src/DataGrid/DataGridHeaderCell/index.d.ts +0 -2
- package/dist/src/DataGrid/DataGridHeaderCell/index.js +0 -1
- package/dist/src/DataGrid/DataGridHeaderRow/DataGridHeaderRow.d.ts +0 -2
- package/dist/src/DataGrid/DataGridHeaderRow/DataGridHeaderRow.js +0 -30
- package/dist/src/DataGrid/DataGridHeaderRow/index.d.ts +0 -2
- package/dist/src/DataGrid/DataGridHeaderRow/index.js +0 -1
- package/dist/src/DataGrid/DataGridProvider.d.ts +0 -27
- package/dist/src/DataGrid/DataGridRow/DataGridRow.d.ts +0 -2
- package/dist/src/DataGrid/DataGridRow/index.d.ts +0 -2
- package/dist/src/DataGrid/DataGridRow/index.js +0 -1
- package/dist/styled-system/recipes/data-grid-body-slot-recipe.d.ts +0 -33
- package/dist/styled-system/recipes/data-grid-body-slot-recipe.js +0 -28
- package/dist/styled-system/recipes/data-grid-cell-slot-recipe.d.ts +0 -38
- package/dist/styled-system/recipes/data-grid-cell-slot-recipe.js +0 -77
- package/dist/styled-system/recipes/data-grid-header-cell-slot-recipe.d.ts +0 -37
- package/dist/styled-system/recipes/data-grid-header-cell-slot-recipe.js +0 -73
- package/dist/styled-system/recipes/data-grid-header-row-slot-recipe.d.ts +0 -33
- package/dist/styled-system/recipes/data-grid-header-row-slot-recipe.js +0 -28
- package/dist/styled-system/recipes/data-grid-header-slot-recipe.d.ts +0 -33
- package/dist/styled-system/recipes/data-grid-header-slot-recipe.js +0 -35
- package/dist/styled-system/recipes/data-grid-row-slot-recipe.d.ts +0 -36
- package/dist/styled-system/recipes/data-grid-slot-recipe.d.ts +0 -36
- package/dist/styled-system/recipes/data-grid-slot-recipe.js +0 -45
- /package/dist/src/{DataGrid/DataGrid.types.js → DataTable/DataTable.types.js} +0 -0
- /package/dist/src/{DataGrid/DataGridBody/DataGridBody.types.js → DataTable/DataTableBody/DataTableBody.types.js} +0 -0
- /package/dist/src/{DataGrid/DataGridCell/DataGridCell.types.js → DataTable/DataTableCell/DataTableCell.types.js} +0 -0
- /package/dist/src/{DataGrid/DataGridHeader/DataGridHeader.types.js → DataTable/DataTableHeader/DataTableHeader.types.js} +0 -0
- /package/dist/src/{DataGrid/DataGridHeaderCell/DataGridHeaderCell.types.js → DataTable/DataTableHeaderCell/DataTableHeaderCell.types.js} +0 -0
- /package/dist/src/{DataGrid/DataGridHeaderRow/DataGridHeaderRow.types.js → DataTable/DataTableHeaderRow/DataTableHeaderRow.types.js} +0 -0
- /package/dist/src/{DataGrid/DataGridRow/DataGridRow.types.js → DataTable/DataTableRow/DataTableRow.types.js} +0 -0
- /package/dist/src/{DataGrid → DataTable}/utils/handleCheckbox.d.ts +0 -0
- /package/dist/src/{DataGrid → DataTable}/utils/handleCheckbox.js +0 -0
|
@@ -1,75 +1,90 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Children, isValidElement, useMemo, forwardRef } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
4
|
+
import { DataTableProvider } from './DataTableProvider';
|
|
5
|
+
import { dataTableSlotRecipe } from '../../styled-system/recipes';
|
|
6
|
+
import { DataTableBody } from './DataTableBody';
|
|
7
|
+
import { DataTableCell } from './DataTableCell';
|
|
8
|
+
import { DataTableHeader } from './DataTableHeader';
|
|
9
|
+
import { DataTableHeaderCell } from './DataTableHeaderCell';
|
|
10
|
+
import { DataTableHeaderRow } from './DataTableHeaderRow';
|
|
11
|
+
import { DataTableRow } from './DataTableRow';
|
|
12
12
|
import { cx } from '../../styled-system/css';
|
|
13
13
|
import { isComponentOrWrapped } from '../utilities/react/isComponentOrWrapped';
|
|
14
14
|
const Base = forwardRef(({ className, size = 'medium', enableRowSelection = false, fixedHeader = false, leftFixedColumnIndex, rightFixedColumnIndex, layout = 'default', wrapperProps, loading = false, emptyStateSlot, children, ...props }, ref) => {
|
|
15
|
-
const classes =
|
|
16
|
-
// Check if
|
|
15
|
+
const classes = dataTableSlotRecipe({ layout });
|
|
16
|
+
// Check if DataTable has any rows by looking for DataTable.Body with DataTable.Row children
|
|
17
17
|
const hasRows = useMemo(() => {
|
|
18
18
|
if (loading)
|
|
19
19
|
return true; // When loading, we don't show empty state
|
|
20
|
-
const bodyElement = Children.toArray(children).find((child) => isValidElement(child) &&
|
|
20
|
+
const bodyElement = Children.toArray(children).find((child) => isValidElement(child) &&
|
|
21
|
+
(isComponentOrWrapped(child, DataTableBody) ||
|
|
22
|
+
(typeof child.type !== 'string' &&
|
|
23
|
+
'displayName' in child.type &&
|
|
24
|
+
child.type.displayName === 'DataGridBody')));
|
|
21
25
|
if (!bodyElement || !isValidElement(bodyElement))
|
|
22
26
|
return false;
|
|
23
27
|
// Type guard to ensure bodyElement has props with children
|
|
24
28
|
if (typeof bodyElement.props === 'object' && bodyElement.props !== null && 'children' in bodyElement.props) {
|
|
25
29
|
const bodyChildren = Children.toArray(bodyElement.props.children);
|
|
26
|
-
return bodyChildren.some((child) => isValidElement(child) &&
|
|
30
|
+
return bodyChildren.some((child) => isValidElement(child) &&
|
|
31
|
+
(isComponentOrWrapped(child, DataTableRow) ||
|
|
32
|
+
(typeof child.type !== 'string' &&
|
|
33
|
+
'displayName' in child.type &&
|
|
34
|
+
child.type.displayName === 'DataGridRow')));
|
|
27
35
|
}
|
|
28
36
|
return false;
|
|
29
37
|
}, [children, loading]);
|
|
30
38
|
const shouldShowEmptyState = !hasRows && !!emptyStateSlot && !loading;
|
|
31
|
-
return (_jsx(
|
|
39
|
+
return (_jsx(DataTableProvider, { size: size, enableRowSelection: enableRowSelection, fixedHeader: fixedHeader, leftFixedColumnIndex: leftFixedColumnIndex, rightFixedColumnIndex: rightFixedColumnIndex, loading: loading, layout: layout, children: _jsxs("div", { ...wrapperProps, className: cx(classes.wrapper, 'mfui-DataTable__wrapper',
|
|
40
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGrid__wrapper', wrapperProps?.className), children: [_jsx("table", { ref: ref, className: cx(classes.table, 'mfui-DataTable__table',
|
|
41
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGrid__table', className), ...props, children: children }), shouldShowEmptyState ? (_jsx("div", { className: cx(classes.emptyState, 'mfui-DataTable__emptyState',
|
|
42
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGrid__emptyState'), role: "status", "aria-live": "polite", children: emptyStateSlot })) : null] }) }));
|
|
32
43
|
});
|
|
33
|
-
Base.displayName = '
|
|
44
|
+
Base.displayName = 'DataTable';
|
|
34
45
|
/**
|
|
35
|
-
* The `
|
|
46
|
+
* The `DataTable` component.
|
|
36
47
|
*
|
|
37
48
|
* It renders a `table` element.
|
|
38
49
|
*
|
|
39
|
-
* This component should be used as a wrapper for all
|
|
40
|
-
* The composition components are provided as sub-components of
|
|
50
|
+
* This component should be used as a wrapper for all DataTable composition components.
|
|
51
|
+
* The composition components are provided as sub-components of DataTable.
|
|
52
|
+
*
|
|
53
|
+
* > **Migration note**: `DataGrid` has been renamed to `DataTable`.
|
|
54
|
+
* > Please migrate to `DataTable`. `DataGrid` will be removed in a future major version (v5.0.0).
|
|
55
|
+
*
|
|
41
56
|
* You can use them as follows:
|
|
42
57
|
*
|
|
43
58
|
* @example
|
|
44
59
|
* ```jsx
|
|
45
|
-
* <
|
|
46
|
-
* <
|
|
47
|
-
* <
|
|
48
|
-
* <
|
|
49
|
-
* </
|
|
50
|
-
* </
|
|
51
|
-
* <
|
|
52
|
-
* <
|
|
53
|
-
* <
|
|
54
|
-
* </
|
|
55
|
-
* </
|
|
56
|
-
* </
|
|
60
|
+
* <DataTable>
|
|
61
|
+
* <DataTable.Header>
|
|
62
|
+
* <DataTable.HeaderRow>
|
|
63
|
+
* <DataTable.HeaderCell>Header 1</DataTable.HeaderCell>
|
|
64
|
+
* </DataTable.HeaderRow>
|
|
65
|
+
* </DataTable.Header>
|
|
66
|
+
* <DataTable.Body>
|
|
67
|
+
* <DataTable.Row>
|
|
68
|
+
* <DataTable.Cell>Cell 1</DataTable.Cell>
|
|
69
|
+
* </DataTable.Row>
|
|
70
|
+
* </DataTable.Body>
|
|
71
|
+
* </DataTable>
|
|
57
72
|
* ```
|
|
58
73
|
*/
|
|
59
|
-
export const
|
|
74
|
+
export const DataTable = Object.assign(Base, {
|
|
60
75
|
/**
|
|
61
|
-
* The `
|
|
62
|
-
* This component should be used inside the `
|
|
76
|
+
* The `DataTableBody` component.
|
|
77
|
+
* This component should be used inside the `DataTable` component.
|
|
63
78
|
*
|
|
64
79
|
* It renders and extends the props of `tbody` element.
|
|
65
80
|
*
|
|
66
|
-
* **Important**: When wrapping this component with a custom component, you must inherit `
|
|
81
|
+
* **Important**: When wrapping this component with a custom component, you must inherit `DataTableBodyProps` to ensure proper type checking.
|
|
67
82
|
* The parent component uses type checking to identify this component, and wrapping without proper props inheritance may cause issues.
|
|
68
83
|
*
|
|
69
84
|
* **CRITICAL: When wrapping with React hooks, you MUST set displayName:**
|
|
70
85
|
*
|
|
71
86
|
* If you create a wrapper component that uses React hooks (useState, useEffect, etc.),
|
|
72
|
-
* you must set `displayName = '
|
|
87
|
+
* you must set `displayName = 'DataTableBody'` to prevent React Rules of Hooks violations.
|
|
73
88
|
*
|
|
74
89
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody
|
|
75
90
|
*
|
|
@@ -78,41 +93,45 @@ export const DataGrid = Object.assign(Base, {
|
|
|
78
93
|
* @example
|
|
79
94
|
*
|
|
80
95
|
* ```tsx
|
|
81
|
-
* // ✅ Correct: Inherit
|
|
82
|
-
* const CustomBody = (props:
|
|
96
|
+
* // ✅ Correct: Inherit DataTableBodyProps
|
|
97
|
+
* const CustomBody = (props: DataTableBodyProps) => <DataTable.Body {...props} />;
|
|
83
98
|
*
|
|
84
|
-
* // ❌ Incorrect: Not inheriting
|
|
85
|
-
* const CustomBody = (props: ComponentPropsWithRef<'tbody'>) => <
|
|
99
|
+
* // ❌ Incorrect: Not inheriting DataTableBodyProps
|
|
100
|
+
* const CustomBody = (props: ComponentPropsWithRef<'tbody'>) => <DataTable.Body {...props} />;
|
|
86
101
|
*
|
|
87
102
|
* // ✅ CORRECT: Wrapper with hooks must set displayName
|
|
88
103
|
* const Body = ({ data }: BodyProps) => {
|
|
89
104
|
* const { user } = useUser(); // Using hooks
|
|
90
|
-
* return <
|
|
105
|
+
* return <DataTable.Body>{data.map(...)}</DataTable.Body>;
|
|
91
106
|
* };
|
|
92
|
-
* Body.displayName = '
|
|
107
|
+
* Body.displayName = 'DataTableBody'; // MUST match 'DataTableBody' exactly
|
|
108
|
+
*
|
|
109
|
+
* // ⚠️ Migration: 'DataGridBody' is still accepted but will stop working in v5.0.0.
|
|
110
|
+
* // Please update to 'DataTableBody'.
|
|
111
|
+
* Body.displayName = 'DataGridBody'; // TODO: Migrate to 'DataTableBody'
|
|
93
112
|
*
|
|
94
113
|
* // ❌ WRONG: Don't use custom names
|
|
95
114
|
* Body.displayName = 'MyBody'; // Will cause hooks violation
|
|
96
|
-
* Body.displayName = '
|
|
115
|
+
* Body.displayName = 'CustomDataTableBody'; // Will cause hooks violation
|
|
97
116
|
* ```
|
|
98
117
|
*/
|
|
99
|
-
Body:
|
|
118
|
+
Body: DataTableBody,
|
|
100
119
|
/**
|
|
101
|
-
* The `
|
|
102
|
-
* This component should be used inside the `
|
|
120
|
+
* The `DataTableCell` component.
|
|
121
|
+
* This component should be used inside the `DataTable` component.
|
|
103
122
|
*
|
|
104
123
|
* It renders and extends the props of `td` element.
|
|
105
124
|
*
|
|
106
125
|
* When the `onClickCell` prop is provided, the cell is rendered as an interactive cell.
|
|
107
126
|
* Otherwise, the cell is rendered as a default cell.
|
|
108
127
|
*
|
|
109
|
-
* **Important**: When wrapping this component with a custom component, you must inherit `
|
|
128
|
+
* **Important**: When wrapping this component with a custom component, you must inherit `DataTableCellProps` to ensure proper type checking.
|
|
110
129
|
* The parent component uses type checking to identify this component, and wrapping without proper props inheritance may cause issues.
|
|
111
130
|
*
|
|
112
131
|
* **CRITICAL: When wrapping with React hooks, you MUST set displayName:**
|
|
113
132
|
*
|
|
114
133
|
* If you create a wrapper component that uses React hooks (useState, useEffect, etc.),
|
|
115
|
-
* you must set `displayName = '
|
|
134
|
+
* you must set `displayName = 'DataTableCell'` to prevent React Rules of Hooks violations.
|
|
116
135
|
*
|
|
117
136
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td
|
|
118
137
|
*
|
|
@@ -121,37 +140,37 @@ export const DataGrid = Object.assign(Base, {
|
|
|
121
140
|
* @example
|
|
122
141
|
*
|
|
123
142
|
* ```tsx
|
|
124
|
-
* // ✅ Correct: Inherit
|
|
125
|
-
* const CustomCell = (props:
|
|
143
|
+
* // ✅ Correct: Inherit DataTableCellProps
|
|
144
|
+
* const CustomCell = (props: DataTableCellProps) => <DataTable.Cell {...props} />;
|
|
126
145
|
*
|
|
127
|
-
* // ❌ Incorrect: Not inheriting
|
|
128
|
-
* const CustomCell = (props: ComponentPropsWithRef<'td'>) => <
|
|
146
|
+
* // ❌ Incorrect: Not inheriting DataTableCellProps
|
|
147
|
+
* const CustomCell = (props: ComponentPropsWithRef<'td'>) => <DataTable.Cell {...props} />;
|
|
129
148
|
*
|
|
130
149
|
* // ✅ CORRECT: Wrapper with hooks must set displayName
|
|
131
150
|
* const Cell = ({ value }: CellProps) => {
|
|
132
151
|
* const { formatter } = useFormatter(); // Using hooks
|
|
133
|
-
* return <
|
|
152
|
+
* return <DataTable.Cell>{formatter(value)}</DataTable.Cell>;
|
|
134
153
|
* };
|
|
135
|
-
* Cell.displayName = '
|
|
154
|
+
* Cell.displayName = 'DataTableCell'; // MUST match 'DataTableCell' exactly
|
|
136
155
|
*
|
|
137
156
|
* // ❌ WRONG: Don't use custom names
|
|
138
157
|
* Cell.displayName = 'MyCell'; // Will cause hooks violation
|
|
139
|
-
* Cell.displayName = '
|
|
158
|
+
* Cell.displayName = 'CustomDataTableCell'; // Will cause hooks violation
|
|
140
159
|
* ```
|
|
141
160
|
*/
|
|
142
|
-
Cell:
|
|
161
|
+
Cell: DataTableCell,
|
|
143
162
|
/**
|
|
144
|
-
* The `
|
|
145
|
-
* This component should be used inside the `
|
|
163
|
+
* The `DataTableHeader` component.
|
|
164
|
+
* This component should be used inside the `DataTable` component.
|
|
146
165
|
*
|
|
147
166
|
* It renders and extends the props of `thead` element.
|
|
148
167
|
*
|
|
149
|
-
* If the `fixedHeader` prop of the `
|
|
168
|
+
* If the `fixedHeader` prop of the `DataTable` component is `true`, it will be sticky on the top of the table while scrolling.
|
|
150
169
|
*
|
|
151
170
|
* **CRITICAL: When wrapping with React hooks, you MUST set displayName:**
|
|
152
171
|
*
|
|
153
172
|
* If you create a wrapper component that uses React hooks (useState, useEffect, etc.),
|
|
154
|
-
* you must set `displayName = '
|
|
173
|
+
* you must set `displayName = 'DataTableHeader'` to prevent React Rules of Hooks violations.
|
|
155
174
|
*
|
|
156
175
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/thead
|
|
157
176
|
*
|
|
@@ -163,19 +182,19 @@ export const DataGrid = Object.assign(Base, {
|
|
|
163
182
|
* // ✅ CORRECT: Wrapper with hooks must set displayName
|
|
164
183
|
* const Header = ({ columns }: HeaderProps) => {
|
|
165
184
|
* const { sortConfig } = useSortConfig(); // Using hooks
|
|
166
|
-
* return <
|
|
185
|
+
* return <DataTable.Header>{columns.map(...)}</DataTable.Header>;
|
|
167
186
|
* };
|
|
168
|
-
* Header.displayName = '
|
|
187
|
+
* Header.displayName = 'DataTableHeader'; // MUST match 'DataTableHeader' exactly
|
|
169
188
|
*
|
|
170
189
|
* // ❌ WRONG: Don't use custom names
|
|
171
190
|
* Header.displayName = 'MyHeader'; // Will cause hooks violation
|
|
172
|
-
* Header.displayName = '
|
|
191
|
+
* Header.displayName = 'CustomDataTableHeader'; // Will cause hooks violation
|
|
173
192
|
* ```
|
|
174
193
|
*/
|
|
175
|
-
Header:
|
|
194
|
+
Header: DataTableHeader,
|
|
176
195
|
/**
|
|
177
|
-
* The `
|
|
178
|
-
* This component should be used inside the `
|
|
196
|
+
* The `DataTableHeaderCell` component.
|
|
197
|
+
* This component should be used inside the `DataTable` component.
|
|
179
198
|
*
|
|
180
199
|
* It renders and extends the props of `th` element.
|
|
181
200
|
*
|
|
@@ -185,13 +204,13 @@ export const DataGrid = Object.assign(Base, {
|
|
|
185
204
|
* When the `sortButtonProps.onClick` prop is provided, it renders a sort button.
|
|
186
205
|
* It renders `SortAscending` or `SortDescending` icon based on the `sortOrder` prop.
|
|
187
206
|
*
|
|
188
|
-
* **Important**: When wrapping this component with a custom component, you must inherit `
|
|
207
|
+
* **Important**: When wrapping this component with a custom component, you must inherit `DataTableHeaderCellProps` to ensure proper type checking.
|
|
189
208
|
* The parent component uses type checking to identify this component, and wrapping without proper props inheritance may cause issues.
|
|
190
209
|
*
|
|
191
210
|
* **CRITICAL: When wrapping with React hooks, you MUST set displayName:**
|
|
192
211
|
*
|
|
193
212
|
* If you create a wrapper component that uses React hooks (useState, useEffect, etc.),
|
|
194
|
-
* you must set `displayName = '
|
|
213
|
+
* you must set `displayName = 'DataTableHeaderCell'` to prevent React Rules of Hooks violations.
|
|
195
214
|
*
|
|
196
215
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th
|
|
197
216
|
*
|
|
@@ -200,40 +219,40 @@ export const DataGrid = Object.assign(Base, {
|
|
|
200
219
|
* @example
|
|
201
220
|
*
|
|
202
221
|
* ```tsx
|
|
203
|
-
* // ✅ Correct: Inherit
|
|
204
|
-
* const CustomHeaderCell = (props:
|
|
222
|
+
* // ✅ Correct: Inherit DataTableHeaderCellProps
|
|
223
|
+
* const CustomHeaderCell = (props: DataTableHeaderCellProps) => <DataTable.HeaderCell {...props} />;
|
|
205
224
|
*
|
|
206
|
-
* // ❌ Incorrect: Not inheriting
|
|
207
|
-
* const CustomHeaderCell = (props: ComponentPropsWithRef<'th'>) => <
|
|
225
|
+
* // ❌ Incorrect: Not inheriting DataTableHeaderCellProps
|
|
226
|
+
* const CustomHeaderCell = (props: ComponentPropsWithRef<'th'>) => <DataTable.HeaderCell {...props} />;
|
|
208
227
|
*
|
|
209
228
|
* // ✅ CORRECT: Wrapper with hooks must set displayName
|
|
210
229
|
* const HeaderCell = ({ label }: HeaderCellProps) => {
|
|
211
230
|
* const { sortOrder } = useSorting(); // Using hooks
|
|
212
|
-
* return <
|
|
231
|
+
* return <DataTable.HeaderCell sortOrder={sortOrder}>{label}</DataTable.HeaderCell>;
|
|
213
232
|
* };
|
|
214
|
-
* HeaderCell.displayName = '
|
|
233
|
+
* HeaderCell.displayName = 'DataTableHeaderCell'; // MUST match 'DataTableHeaderCell' exactly
|
|
215
234
|
*
|
|
216
235
|
* // ❌ WRONG: Don't use custom names
|
|
217
236
|
* HeaderCell.displayName = 'MyHeaderCell'; // Will cause hooks violation
|
|
218
237
|
* HeaderCell.displayName = 'CustomCell'; // Will cause hooks violation
|
|
219
238
|
* ```
|
|
220
239
|
*/
|
|
221
|
-
HeaderCell:
|
|
240
|
+
HeaderCell: DataTableHeaderCell,
|
|
222
241
|
/**
|
|
223
|
-
* The `
|
|
224
|
-
* This component should be used inside the `
|
|
242
|
+
* The `DataTableHeaderRow` component.
|
|
243
|
+
* This component should be used inside the `DataTable` component.
|
|
225
244
|
*
|
|
226
245
|
* It renders and extends the props of `tr` element.
|
|
227
246
|
*
|
|
228
|
-
* If the `selectable` prop of the `
|
|
247
|
+
* If the `selectable` prop of the `DataTable` component is `true`, it renders a `Checkbox` component inside the first cell.
|
|
229
248
|
*
|
|
230
|
-
* **Important**: When wrapping this component with a custom component, you must inherit `
|
|
249
|
+
* **Important**: When wrapping this component with a custom component, you must inherit `DataTableHeaderRowProps` to ensure proper type checking.
|
|
231
250
|
* The parent component uses type checking to identify this component, and wrapping without proper props inheritance may cause issues.
|
|
232
251
|
*
|
|
233
252
|
* **CRITICAL: When wrapping with React hooks, you MUST set displayName:**
|
|
234
253
|
*
|
|
235
254
|
* If you create a wrapper component that uses React hooks (useState, useEffect, etc.),
|
|
236
|
-
* you must set `displayName = '
|
|
255
|
+
* you must set `displayName = 'DataTableHeaderRow'` to prevent React Rules of Hooks violations.
|
|
237
256
|
*
|
|
238
257
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr
|
|
239
258
|
*
|
|
@@ -242,38 +261,38 @@ export const DataGrid = Object.assign(Base, {
|
|
|
242
261
|
* @example
|
|
243
262
|
*
|
|
244
263
|
* ```tsx
|
|
245
|
-
* // ✅ Correct: Inherit
|
|
246
|
-
* const CustomHeaderRow = (props:
|
|
264
|
+
* // ✅ Correct: Inherit DataTableHeaderRowProps
|
|
265
|
+
* const CustomHeaderRow = (props: DataTableHeaderRowProps) => <DataTable.HeaderRow {...props} />;
|
|
247
266
|
*
|
|
248
|
-
* // ❌ Incorrect: Not inheriting
|
|
249
|
-
* const CustomHeaderRow = (props: ComponentPropsWithRef<'tr'>) => <
|
|
267
|
+
* // ❌ Incorrect: Not inheriting DataTableHeaderRowProps
|
|
268
|
+
* const CustomHeaderRow = (props: ComponentPropsWithRef<'tr'>) => <DataTable.HeaderRow {...props} />;
|
|
250
269
|
*
|
|
251
270
|
* // ✅ CORRECT: Wrapper with hooks must set displayName
|
|
252
271
|
* const HeaderRow = ({ columns }: HeaderRowProps) => {
|
|
253
272
|
* const { visibleColumns } = useColumns(); // Using hooks
|
|
254
|
-
* return <
|
|
273
|
+
* return <DataTable.HeaderRow>{visibleColumns.map(...)}</DataTable.HeaderRow>;
|
|
255
274
|
* };
|
|
256
|
-
* HeaderRow.displayName = '
|
|
275
|
+
* HeaderRow.displayName = 'DataTableHeaderRow'; // MUST match 'DataTableHeaderRow' exactly
|
|
257
276
|
*
|
|
258
277
|
* // ❌ WRONG: Don't use custom names
|
|
259
278
|
* HeaderRow.displayName = 'MyHeaderRow'; // Will cause hooks violation
|
|
260
279
|
* HeaderRow.displayName = 'CustomRow'; // Will cause hooks violation
|
|
261
280
|
* ```
|
|
262
281
|
*/
|
|
263
|
-
HeaderRow:
|
|
282
|
+
HeaderRow: DataTableHeaderRow,
|
|
264
283
|
/**
|
|
265
|
-
* The `
|
|
266
|
-
* This component should be used inside the `
|
|
284
|
+
* The `DataTableRow` component.
|
|
285
|
+
* This component should be used inside the `DataTable` component.
|
|
267
286
|
*
|
|
268
287
|
* It renders and extends the props of `tr` element.
|
|
269
288
|
*
|
|
270
|
-
* **Important**: When wrapping this component with a custom component, you must inherit `
|
|
289
|
+
* **Important**: When wrapping this component with a custom component, you must inherit `DataTableRowProps` to ensure proper type checking.
|
|
271
290
|
* The parent component uses type checking to identify this component, and wrapping without proper props inheritance may cause issues.
|
|
272
291
|
*
|
|
273
292
|
* **CRITICAL: When wrapping with React hooks, you MUST set displayName:**
|
|
274
293
|
*
|
|
275
294
|
* If you create a wrapper component that uses React hooks (useState, useEffect, etc.),
|
|
276
|
-
* you must set `displayName = '
|
|
295
|
+
* you must set `displayName = 'DataTableRow'` to prevent React Rules of Hooks violations.
|
|
277
296
|
*
|
|
278
297
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr
|
|
279
298
|
*
|
|
@@ -282,23 +301,27 @@ export const DataGrid = Object.assign(Base, {
|
|
|
282
301
|
* @example
|
|
283
302
|
*
|
|
284
303
|
* ```tsx
|
|
285
|
-
* // ✅ Correct: Inherit
|
|
286
|
-
* const CustomRow = (props:
|
|
304
|
+
* // ✅ Correct: Inherit DataTableRowProps
|
|
305
|
+
* const CustomRow = (props: DataTableRowProps) => <DataTable.Row {...props} />;
|
|
287
306
|
*
|
|
288
|
-
* // ❌ Incorrect: Not inheriting
|
|
289
|
-
* const CustomRow = (props: ComponentPropsWithRef<'tr'>) => <
|
|
307
|
+
* // ❌ Incorrect: Not inheriting DataTableRowProps
|
|
308
|
+
* const CustomRow = (props: ComponentPropsWithRef<'tr'>) => <DataTable.Row {...props} />;
|
|
290
309
|
*
|
|
291
310
|
* // ✅ CORRECT: Wrapper with hooks must set displayName
|
|
292
311
|
* const Row = ({ item }: RowProps) => {
|
|
293
312
|
* const { isSelected } = useSelection(item.id); // Using hooks
|
|
294
|
-
* return <
|
|
313
|
+
* return <DataTable.Row selected={isSelected}>...</DataTable.Row>;
|
|
295
314
|
* };
|
|
296
|
-
* Row.displayName = '
|
|
315
|
+
* Row.displayName = 'DataTableRow'; // MUST match 'DataTableRow' exactly
|
|
316
|
+
*
|
|
317
|
+
* // ⚠️ Migration: 'DataGridRow' is still accepted but will stop working in v5.0.0.
|
|
318
|
+
* // Please update to 'DataTableRow'.
|
|
319
|
+
* Row.displayName = 'DataGridRow'; // TODO: Migrate to 'DataTableRow'
|
|
297
320
|
*
|
|
298
321
|
* // ❌ WRONG: Don't use custom names
|
|
299
322
|
* Row.displayName = 'MyRow'; // Will cause hooks violation
|
|
300
|
-
* Row.displayName = '
|
|
323
|
+
* Row.displayName = 'CustomDataTableRow'; // Will cause hooks violation
|
|
301
324
|
* ```
|
|
302
325
|
*/
|
|
303
|
-
Row:
|
|
326
|
+
Row: DataTableRow,
|
|
304
327
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComponentPropsWithRef, type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
|
2
|
-
import { type
|
|
3
|
-
import { type
|
|
2
|
+
import { type DataTableSize } from './DataTableProvider';
|
|
3
|
+
import { type DataTableSlotRecipeVariant } from '../../styled-system/recipes';
|
|
4
4
|
/**
|
|
5
5
|
* The type of cell data.
|
|
6
6
|
* Used for determining how to render and align cell content.
|
|
@@ -10,20 +10,20 @@ import { type DataGridSlotRecipeVariant } from '../../styled-system/recipes';
|
|
|
10
10
|
*/
|
|
11
11
|
export type CellDataType = 'text' | 'amount';
|
|
12
12
|
/**
|
|
13
|
-
* The props for the `
|
|
13
|
+
* The props for the `DataTable` component.
|
|
14
14
|
*
|
|
15
15
|
* It extends the general attributes of `table` element.
|
|
16
16
|
*
|
|
17
17
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table
|
|
18
18
|
*/
|
|
19
|
-
export type
|
|
19
|
+
export type DataTableProps = {
|
|
20
20
|
/**
|
|
21
21
|
* The size of the data header cell and data cell.
|
|
22
22
|
* It accepts `small` or `medium`.
|
|
23
23
|
*
|
|
24
24
|
* @default 'medium'
|
|
25
25
|
*/
|
|
26
|
-
size?:
|
|
26
|
+
size?: DataTableSize;
|
|
27
27
|
/**
|
|
28
28
|
* Whether the table rows are selectable.
|
|
29
29
|
* If `true`, the checkbox cell will be added to the first column of header and each row.
|
|
@@ -39,18 +39,18 @@ export type DataGridProps = {
|
|
|
39
39
|
*/
|
|
40
40
|
fixedHeader?: boolean;
|
|
41
41
|
/**
|
|
42
|
-
* The layout of the data
|
|
42
|
+
* The layout of the data table.
|
|
43
43
|
* It accepts `default` or `edge-to-edge`.
|
|
44
44
|
*
|
|
45
45
|
* @default 'default'
|
|
46
46
|
*/
|
|
47
|
-
layout?:
|
|
47
|
+
layout?: DataTableSlotRecipeVariant['layout'];
|
|
48
48
|
/**
|
|
49
49
|
* The index of the column to fix on the left side.
|
|
50
50
|
* It should be started from 0.
|
|
51
51
|
*
|
|
52
52
|
* If the fixed column width might be changed with any interaction, such as disclosure, removing row or translating,
|
|
53
|
-
* please add `table-layout: fixed` to the
|
|
53
|
+
* please add `table-layout: fixed` to the DataTable and specify the width of the each column.
|
|
54
54
|
*
|
|
55
55
|
* @default undefined
|
|
56
56
|
*/
|
|
@@ -60,7 +60,7 @@ export type DataGridProps = {
|
|
|
60
60
|
* It should be started from 0.
|
|
61
61
|
*
|
|
62
62
|
* If the fixed column width might be changed with any interaction, such as disclosure, removing row or translating,
|
|
63
|
-
* please add `table-layout: fixed` to the
|
|
63
|
+
* please add `table-layout: fixed` to the DataTable and specify the width of the each column.
|
|
64
64
|
*
|
|
65
65
|
* @default undefined
|
|
66
66
|
*/
|
|
@@ -68,7 +68,7 @@ export type DataGridProps = {
|
|
|
68
68
|
/**
|
|
69
69
|
* The props for the wrapper element of the table.
|
|
70
70
|
*
|
|
71
|
-
* The
|
|
71
|
+
* The DataTable component is wrapped with a `div` element.
|
|
72
72
|
*
|
|
73
73
|
* ```tsx
|
|
74
74
|
* <div {...wrapperProps}>
|
|
@@ -91,7 +91,7 @@ export type DataGridProps = {
|
|
|
91
91
|
*/
|
|
92
92
|
loading?: boolean;
|
|
93
93
|
/**
|
|
94
|
-
* The content to display when the data
|
|
94
|
+
* The content to display when the data table has no rows.
|
|
95
95
|
* This can be a string message, icon, illustration, or any React component.
|
|
96
96
|
* The content will be displayed below the table header with proper spacing and centering.
|
|
97
97
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DataTableBody: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & import("react").RefAttributes<HTMLTableSectionElement>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { dataTableBodySlotRecipe } from '../../../styled-system/recipes';
|
|
4
|
+
import { cx } from '../../../styled-system/css';
|
|
5
|
+
import { useDataTableContext } from '../DataTableProvider';
|
|
6
|
+
import { DataTableRow } from '../DataTableRow';
|
|
7
|
+
import { DataTableCell } from '../DataTableCell';
|
|
8
|
+
const NUMBER_OF_LOADING_ROWS = 4;
|
|
9
|
+
export const DataTableBody = forwardRef(({ className, ...props }, ref) => {
|
|
10
|
+
const { numberColumns, loading } = useDataTableContext();
|
|
11
|
+
const classes = dataTableBodySlotRecipe();
|
|
12
|
+
if (loading) {
|
|
13
|
+
return (_jsx("tbody", { className: cx(classes.root, 'mfui-DataTableBody__root',
|
|
14
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridBody__root', className), ...props, ref: ref, children: Array.from({ length: NUMBER_OF_LOADING_ROWS }).map((_, rowIndex) => (_jsx(DataTableRow, { children: Array.from({ length: numberColumns }).map((_, colIndex) => (_jsx(DataTableCell, {}, colIndex))) }, rowIndex))) }));
|
|
15
|
+
}
|
|
16
|
+
return (_jsx("tbody", { className: cx(classes.root, 'mfui-DataTableBody__root',
|
|
17
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridBody__root', className), ...props, ref: ref }));
|
|
18
|
+
});
|
|
19
|
+
DataTableBody.displayName = 'DataTableBody';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ComponentPropsWithRef } from 'react';
|
|
2
2
|
/**
|
|
3
|
-
* The props for the `
|
|
3
|
+
* The props for the `DataTableBody` component.
|
|
4
4
|
*
|
|
5
5
|
* It extends the general attributes of `tbody` element.
|
|
6
6
|
*
|
|
7
7
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tbody
|
|
8
8
|
*/
|
|
9
|
-
export type
|
|
9
|
+
export type DataTableBodyProps = ComponentPropsWithRef<'tbody'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataTableBody } from './DataTableBody';
|
package/dist/src/{DataGrid/DataGridCell/DataGridCell.js → DataTable/DataTableCell/DataTableCell.js}
RENAMED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { DisclosureBasicCollapsed, DisclosureBasicExpanded, DisclosureNestedCollapsed, DisclosureNestedExpanded, } from '@moneyforward/mfui-icons-react';
|
|
4
|
-
import {
|
|
4
|
+
import { dataTableCellSlotRecipe } from '../../../styled-system/recipes';
|
|
5
5
|
import { FocusIndicator } from '../../FocusIndicator';
|
|
6
6
|
import { Typography } from '../../Typography';
|
|
7
7
|
import { Skeleton } from '../../Skeleton';
|
|
8
|
-
import {
|
|
8
|
+
import { useDataTableContext } from '../DataTableProvider';
|
|
9
9
|
import { cx } from '../../../styled-system/css';
|
|
10
10
|
import { useFixedColumns } from '../../utilities/dom/useFixedColumns';
|
|
11
11
|
import { handleCheckboxCellClick } from '../utils/handleCheckbox';
|
|
12
12
|
import { mergeRefs } from '../../utilities/dom/mergeRefs';
|
|
13
|
-
export const
|
|
14
|
-
const { size, leftFixedColumnIndex, rightFixedColumnIndex, loading, enableRowSelection } =
|
|
13
|
+
export const DataTableCell = forwardRef(({ onClickCell, children, type = 'text', className, isRowHighlighted, disabled = false, depth = 0, columnIndex, disclosureIconProps: nestingIconProps, style, ...props }, ref) => {
|
|
14
|
+
const { size, leftFixedColumnIndex, rightFixedColumnIndex, loading, enableRowSelection } = useDataTableContext();
|
|
15
15
|
const { cellRef, isFixedColumn, isEdgeFixedColumn, fixedPositionStyles } = useFixedColumns({
|
|
16
16
|
enableRowSelection,
|
|
17
17
|
columnIndex,
|
|
18
18
|
leftFixedColumnIndex,
|
|
19
19
|
rightFixedColumnIndex,
|
|
20
20
|
});
|
|
21
|
-
const classes =
|
|
21
|
+
const classes = dataTableCellSlotRecipe({
|
|
22
22
|
size,
|
|
23
23
|
type,
|
|
24
24
|
rowHighlighted: isRowHighlighted,
|
|
@@ -32,23 +32,29 @@ export const DataGridCell = forwardRef(({ onClickCell, children, type = 'text',
|
|
|
32
32
|
const isCheckboxCell = enableRowSelection && columnIndex === 0;
|
|
33
33
|
const cellContent = (() => {
|
|
34
34
|
if (loading) {
|
|
35
|
-
return (_jsx("div", { className: cx(classes.skeletonCell, 'mfui-
|
|
35
|
+
return (_jsx("div", { className: cx(classes.skeletonCell, 'mfui-DataTableCell__skeletonCell',
|
|
36
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__skeletonCell'), children: _jsx(Skeleton, {}) }));
|
|
36
37
|
}
|
|
37
38
|
if (onClickCell) {
|
|
38
|
-
return (_jsx(FocusIndicator, { position: "inside", children: _jsx("button", { type: "button", className: cx(classes.interactiveCell, 'mfui-
|
|
39
|
+
return (_jsx(FocusIndicator, { position: "inside", children: _jsx("button", { type: "button", className: cx(classes.interactiveCell, 'mfui-DataTableCell__interactiveCell',
|
|
40
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__interactiveCell'), onClick: handleClick, children: _jsx(CellContent, { depth: depth, disclosureIconProps: nestingIconProps, classes: classes, children: children }) }) }));
|
|
39
41
|
}
|
|
40
42
|
if (isCheckboxCell) {
|
|
41
|
-
return (_jsx(FocusIndicator, { position: "inside", children: _jsx("div", { className: cx(classes.defaultCell, 'mfui-
|
|
43
|
+
return (_jsx(FocusIndicator, { position: "inside", children: _jsx("div", { className: cx(classes.defaultCell, 'mfui-DataTableCell__defaultCell',
|
|
44
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__defaultCell'), ...(disabled && { 'data-disabled': true, 'aria-disabled': true }), onClick: disabled ? undefined : handleCheckboxCellClick, children: _jsx(CellContent, { depth: depth, disclosureIconProps: nestingIconProps, classes: classes, children: children }) }) }));
|
|
42
45
|
}
|
|
43
|
-
return (_jsx("div", { className: cx(classes.defaultCell, 'mfui-
|
|
46
|
+
return (_jsx("div", { className: cx(classes.defaultCell, 'mfui-DataTableCell__defaultCell',
|
|
47
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__defaultCell'), children: _jsx(CellContent, { depth: depth, disclosureIconProps: nestingIconProps, classes: classes, children: children }) }));
|
|
44
48
|
})();
|
|
45
|
-
return (_jsx("td", { ref: mergeRefs(ref, cellRef), className: cx(classes.root, 'mfui-
|
|
49
|
+
return (_jsx("td", { ref: mergeRefs(ref, cellRef), className: cx(classes.root, 'mfui-DataTableCell__root',
|
|
50
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__root', className), style: { ...style, ...fixedPositionStyles, zIndex: isFixedColumn ? 1 : undefined }, ...props, children: cellContent }));
|
|
46
51
|
});
|
|
47
|
-
|
|
52
|
+
DataTableCell.displayName = 'DataTableCell';
|
|
48
53
|
function CellContent({ children, depth, disclosureIconProps, classes, }) {
|
|
49
54
|
const isStringChild = typeof children === 'string';
|
|
50
55
|
return (_jsxs(_Fragment, { children: [depth > 0
|
|
51
|
-
? Array.from({ length: depth }).map((_, index) => (_jsx("div", { className: cx(classes.disclosureSpacing, 'mfui-
|
|
56
|
+
? Array.from({ length: depth }).map((_, index) => (_jsx("div", { className: cx(classes.disclosureSpacing, 'mfui-DataTableCell__disclosureSpacing',
|
|
57
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__disclosureSpacing') }, index)))
|
|
52
58
|
: null, _jsx(DisclosureIcon, { classes: classes, disclosureIconProps: disclosureIconProps }), isStringChild ? _jsx(Typography, { variant: "body", children: children }) : children] }));
|
|
53
59
|
}
|
|
54
60
|
function DisclosureIcon({ disclosureIconProps, classes, }) {
|
|
@@ -61,5 +67,6 @@ function DisclosureIcon({ disclosureIconProps, classes, }) {
|
|
|
61
67
|
}
|
|
62
68
|
return disclosureIconProps.isOpen ? _jsx(DisclosureNestedExpanded, {}) : _jsx(DisclosureNestedCollapsed, {});
|
|
63
69
|
})();
|
|
64
|
-
return (_jsx("div", { className: cx(classes.disclosureIconWrapper, 'mfui-
|
|
70
|
+
return (_jsx("div", { className: cx(classes.disclosureIconWrapper, 'mfui-DataTableCell__disclosureIconWrapper',
|
|
71
|
+
/* TODO: Remove in v5.0.0 */ 'mfui-DataGridCell__disclosureIconWrapper'), children: disclosureIcon }));
|
|
65
72
|
}
|