@dxos/react-ui-table 0.6.7-staging.e9eb1ed → 0.6.8-main.046e6cf
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/lib/browser/index.mjs +189 -213
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Cell/Cell.d.ts +2 -2
- package/dist/types/src/components/Cell/Cell.d.ts.map +1 -1
- package/dist/types/src/components/Cell/CellCombobox.d.ts +3 -3
- package/dist/types/src/components/Cell/CellCombobox.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnMenu.d.ts +3 -3
- package/dist/types/src/components/ColumnMenu/ColumnMenu.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnMenu.stories.d.ts +3 -3
- package/dist/types/src/components/ColumnMenu/ColumnMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.d.ts +2 -2
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.stories.d.ts +63 -0
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/Table.d.ts +6 -5
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +9 -9
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableBody.d.ts +2 -2
- package/dist/types/src/components/Table/TableBody.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContext.d.ts +2 -2
- package/dist/types/src/components/Table/TableContext.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableHead.d.ts +2 -2
- package/dist/types/src/components/Table/TableHead.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableRootContext.d.ts +0 -1
- package/dist/types/src/components/Table/TableRootContext.d.ts.map +1 -1
- package/dist/types/src/components/Table/props.d.ts +0 -1
- package/dist/types/src/components/Table/props.d.ts.map +1 -1
- package/dist/types/src/helpers.d.ts +1 -1
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/hooks/useColumnSizing.d.ts +0 -1
- package/dist/types/src/hooks/useColumnSizing.d.ts.map +1 -1
- package/dist/types/src/hooks/useColumnSorting.d.ts.map +1 -1
- package/dist/types/src/hooks/usePinLastRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useRowSelection.d.ts +1 -1
- package/dist/types/src/hooks/useRowSelection.d.ts.map +1 -1
- package/dist/types/src/schema/SchemaToTable.stories.d.ts +2 -1
- package/dist/types/src/schema/SchemaToTable.stories.d.ts.map +1 -1
- package/dist/types/src/schema/schema.d.ts.map +1 -1
- package/dist/types/src/schema/schemaToColumns.d.ts.map +1 -1
- package/dist/types/src/theme.d.ts +6 -10
- package/dist/types/src/theme.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/components/Cell/Cell.tsx +46 -4
- package/src/components/ColumnMenu/ColumnMenu.tsx +6 -8
- package/src/components/ColumnMenu/ColumnSettingsForm.stories.tsx +104 -0
- package/src/components/ColumnMenu/ColumnSettingsForm.tsx +60 -73
- package/src/components/Table/Table.stories.tsx +2 -2
- package/src/components/Table/Table.tsx +12 -7
- package/src/components/Table/TableBody.tsx +2 -1
- package/src/components/Table/TableContext.tsx +1 -1
- package/src/components/Table/TableHead.tsx +3 -4
- package/src/components/Table/props.ts +0 -1
- package/src/helpers.tsx +2 -0
- package/src/hooks/usePinLastRow.ts +1 -18
- package/src/theme.ts +28 -55
- package/dist/types/src/components/Table/TableFooter.d.ts +0 -9
- package/dist/types/src/components/Table/TableFooter.d.ts.map +0 -1
- package/src/components/Table/TableFooter.tsx +0 -45
|
@@ -41,6 +41,7 @@ const TableBody = ({ rows }: TableBodyProps) => {
|
|
|
41
41
|
key={keyAccessor ? keyAccessor(row.original) : row.id}
|
|
42
42
|
className={classNames}
|
|
43
43
|
data-index={row.index}
|
|
44
|
+
data-testid={'table.data-row'}
|
|
44
45
|
ref={virtualizer.measureElement}
|
|
45
46
|
{...(isCurrent && { 'aria-current': 'location' })}
|
|
46
47
|
{...(isSelected && { 'aria-selected': 'true' })}
|
|
@@ -61,7 +62,7 @@ const TableBody = ({ rows }: TableBodyProps) => {
|
|
|
61
62
|
{row.getVisibleCells().map((cell) => {
|
|
62
63
|
return (
|
|
63
64
|
<Cell key={cell.id} cell={cell}>
|
|
64
|
-
{flexRender(cell.column.columnDef.cell, {
|
|
65
|
+
{flexRender(cell.column.columnDef.cell, { ...cell.getContext() })}
|
|
65
66
|
</Cell>
|
|
66
67
|
);
|
|
67
68
|
})}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type RowData } from '@tanstack/react-table';
|
|
6
|
-
import React, { useContext, createContext, type ReactNode, type FC, type Context } from 'react';
|
|
6
|
+
import React, { useContext, createContext, type JSX, type ReactNode, type FC, type Context } from 'react';
|
|
7
7
|
|
|
8
8
|
import { type TableContextValue } from './props';
|
|
9
9
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { flexRender } from '@tanstack/react-table';
|
|
@@ -37,10 +37,9 @@ const TableHead = (_props: TableHeadProps) => {
|
|
|
37
37
|
return (
|
|
38
38
|
<th
|
|
39
39
|
key={header.id}
|
|
40
|
-
style={{
|
|
41
|
-
width: header.getSize(),
|
|
42
|
-
}}
|
|
40
|
+
style={{ width: header.getSize() }}
|
|
43
41
|
className={theadTh(tableContext, header.column.columnDef.meta?.header?.classNames)}
|
|
42
|
+
data-testid='table.header-cell'
|
|
44
43
|
>
|
|
45
44
|
{!header || header.isPlaceholder
|
|
46
45
|
? null
|
package/src/helpers.tsx
CHANGED
|
@@ -144,6 +144,7 @@ const StringBuilderCell = <TData extends RowData>(cellContext: CellContext<TData
|
|
|
144
144
|
onBlur={handleSave}
|
|
145
145
|
onChange={(event) => setValue(event.target.value)}
|
|
146
146
|
onKeyDown={(event) => (event.key === 'Enter' && handleSave()) || (event.key === 'Escape' && handleCancel())}
|
|
147
|
+
autoComplete='off'
|
|
147
148
|
/>
|
|
148
149
|
</Input.Root>
|
|
149
150
|
);
|
|
@@ -208,6 +209,7 @@ const NumberBuilderCell = <TData extends RowData>(cellContext: CellContext<TData
|
|
|
208
209
|
// TODO(thure): `Escape` is reserved for blurring the input and moving focus to the cell
|
|
209
210
|
return /* (event.key === 'Escape' && handleCancel()) || */ event.key === 'Enter' && handleSave();
|
|
210
211
|
}}
|
|
212
|
+
autoComplete='off'
|
|
211
213
|
/>
|
|
212
214
|
</Input.Root>
|
|
213
215
|
);
|
|
@@ -5,22 +5,9 @@
|
|
|
5
5
|
import { type Row, type Table } from '@tanstack/react-table';
|
|
6
6
|
import { useCallback, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useTableRootContext } from '../components';
|
|
9
|
-
|
|
10
8
|
export const usePinLastRow = (pinLastRow: boolean | undefined, table: Table<any>, data: any[]) => {
|
|
11
|
-
const { scrollContextRef } = useTableRootContext();
|
|
12
9
|
const [pinnedRowKey, setPinnedRowKey] = useState<string>();
|
|
13
10
|
|
|
14
|
-
// Scrolls to the bottom of a scrollable element.
|
|
15
|
-
const scrollToBottom = useCallback(() => {
|
|
16
|
-
const element = scrollContextRef.current;
|
|
17
|
-
const scrollHeight = element?.scrollHeight;
|
|
18
|
-
|
|
19
|
-
if (element && scrollHeight) {
|
|
20
|
-
requestAnimationFrame(() => element.scrollTo({ top: scrollHeight }));
|
|
21
|
-
}
|
|
22
|
-
}, []);
|
|
23
|
-
|
|
24
11
|
const pinRow = useCallback(
|
|
25
12
|
(rowToPin: Row<any>) => {
|
|
26
13
|
table.resetRowPinning();
|
|
@@ -49,11 +36,7 @@ export const usePinLastRow = (pinLastRow: boolean | undefined, table: Table<any>
|
|
|
49
36
|
}
|
|
50
37
|
|
|
51
38
|
pinRow(lastRow);
|
|
52
|
-
|
|
53
|
-
if (pinnedRowKey !== undefined) {
|
|
54
|
-
scrollToBottom();
|
|
55
|
-
}
|
|
56
|
-
}, [table, scrollToBottom, pinnedRowKey]);
|
|
39
|
+
}, [table, pinnedRowKey]);
|
|
57
40
|
|
|
58
41
|
// Effect to handle pinning logic when data changes.
|
|
59
42
|
useEffect(() => {
|
package/src/theme.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { modalSurface, focusRing, ghostSelected, ghostSelectedCurrent, groupBorder, mx } from '@dxos/react-ui-theme';
|
|
5
|
+
import { focusRing, ghostSelected, ghostSelectedCurrent, mx } from '@dxos/react-ui-theme';
|
|
8
6
|
import { type ComponentFunction } from '@dxos/react-ui-types';
|
|
9
7
|
|
|
10
8
|
import { type TableContextValue, type TableFlags } from './components';
|
|
@@ -12,46 +10,36 @@ import { type TableContextValue, type TableFlags } from './components';
|
|
|
12
10
|
export const currentRow = '!bg-neutral-75 !dark:bg-neutral-850';
|
|
13
11
|
export const selectedRow = '!bg-primary-100 dark:!bg-primary-700';
|
|
14
12
|
export const flushPadding = 'pli-0 plb-0';
|
|
15
|
-
export const textPadding = 'pli-2 plb-0
|
|
16
|
-
export const headPadding = 'pli-2 plb-
|
|
17
|
-
|
|
18
|
-
export const gridCellFocusRing = 'focus-within:outline outline-2 outline-primary-500 dark:outline-primary-400';
|
|
13
|
+
export const textPadding = 'pli-2 plb-0';
|
|
14
|
+
export const headPadding = 'pli-2 plb-0';
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
export const gridCellFocusRing =
|
|
17
|
+
'relative focus-within:outline focus-within:outline-1 outline-primary-500 outline-offset-[-1px]';
|
|
18
|
+
const borderColors = 'border-neutral-200 dark:border-neutral-700';
|
|
19
|
+
const stickyRowColors = 'bg-neutral-50 dark:bg-neutral-800';
|
|
23
20
|
|
|
24
21
|
export type TableStyleProps = Partial<TableContextValue<any>>;
|
|
25
22
|
|
|
26
23
|
export const tableRoot: ComponentFunction<TableStyleProps> = ({ fullWidth }, ...etc) =>
|
|
27
|
-
mx('table-fixed', fullWidth && 'is-full', ...etc);
|
|
24
|
+
mx('table-fixed', 'text-neutral-800 dark:text-neutral-200', fullWidth && 'is-full', ...etc);
|
|
28
25
|
|
|
29
26
|
export const groupTh: ComponentFunction<TableStyleProps> = (_props, ...etc) =>
|
|
30
27
|
mx('text-start font-medium', flushPadding, ...etc);
|
|
31
28
|
|
|
32
|
-
//
|
|
33
|
-
// thead
|
|
34
|
-
//
|
|
35
|
-
|
|
36
29
|
export type TheadStyleProps = Partial<TableFlags>;
|
|
37
30
|
|
|
38
31
|
export const theadRoot: ComponentFunction<TheadStyleProps> = ({ header, stickyHeader }, ...etc) =>
|
|
39
|
-
mx(
|
|
40
|
-
header ? stickyHeader && 'sticky block-start-[--sticky-top] z-[1]' : 'collapse',
|
|
41
|
-
header && 'base-surface',
|
|
42
|
-
'drop-shadow-sm',
|
|
43
|
-
...etc,
|
|
44
|
-
);
|
|
32
|
+
mx(header ? stickyHeader && 'sticky block-start-[--sticky-top] z-[1]' : 'collapse', stickyRowColors, ...etc);
|
|
45
33
|
|
|
46
34
|
export const theadTr: ComponentFunction<TheadStyleProps> = (_props, ...etc) => mx('group', ...etc);
|
|
47
35
|
|
|
48
36
|
export const theadTh: ComponentFunction<TheadStyleProps> = ({ border }, ...etc) =>
|
|
49
37
|
mx(
|
|
50
38
|
'relative',
|
|
51
|
-
'text-start
|
|
39
|
+
'text-start text-xs select-none truncate',
|
|
52
40
|
headPadding,
|
|
53
|
-
border &&
|
|
54
|
-
border && 'border
|
|
41
|
+
border && borderColors,
|
|
42
|
+
border && 'border-t border-b border-l last:border-r',
|
|
55
43
|
...etc,
|
|
56
44
|
);
|
|
57
45
|
|
|
@@ -61,16 +49,12 @@ export const theadResizeRoot: ComponentFunction<{ isResizing: boolean }> = ({ is
|
|
|
61
49
|
'cursor-col-resize',
|
|
62
50
|
'user-select-none',
|
|
63
51
|
'touch-action-none',
|
|
64
|
-
!isResizing && 'group-hover:bg-neutral-100 dark:group-hover:bg-neutral-800',
|
|
65
52
|
'pointer-coarse:bg-neutral-100 dark:pointer-coarse:bg-neutral-800',
|
|
66
|
-
isResizing && 'bg-
|
|
53
|
+
!isResizing && 'group-hover:bg-neutral-100 dark:group-hover:bg-neutral-800',
|
|
54
|
+
isResizing && 'bg-primary-500',
|
|
67
55
|
);
|
|
68
56
|
};
|
|
69
57
|
|
|
70
|
-
//
|
|
71
|
-
// tbody
|
|
72
|
-
//
|
|
73
|
-
|
|
74
58
|
export type TbodyStyleProps = Partial<TableContextValue<any>>;
|
|
75
59
|
export const tbodyRoot: ComponentFunction<TbodyStyleProps> = (_props, ...etc) => mx(...etc);
|
|
76
60
|
|
|
@@ -80,30 +64,19 @@ export const tbodyTr: ComponentFunction<TbodyTrStyleProps> = ({ canBeCurrent, is
|
|
|
80
64
|
'group',
|
|
81
65
|
canBeCurrent ? ghostSelectedCurrent : ghostSelected,
|
|
82
66
|
canBeCurrent && focusRing,
|
|
83
|
-
canBeCurrent && 'cursor-pointer
|
|
84
|
-
isPinned && 'sticky z-1
|
|
67
|
+
canBeCurrent && 'cursor-pointer',
|
|
68
|
+
isPinned && 'sticky z-1 block-end-0',
|
|
69
|
+
isPinned && stickyRowColors,
|
|
85
70
|
...etc,
|
|
86
71
|
);
|
|
87
72
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// tfoot
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
export type TfootStyleProps = Partial<TableContextValue<any>>;
|
|
102
|
-
|
|
103
|
-
export const tfootRoot: ComponentFunction<TfootStyleProps> = (_props, ...etc) =>
|
|
104
|
-
mx('sticky block-end-0 z-10', modalSurface, ...etc);
|
|
105
|
-
|
|
106
|
-
export const tfootTr: ComponentFunction<TfootStyleProps> = (_props, ...etc) => mx(...etc);
|
|
107
|
-
|
|
108
|
-
export const tfootTh: ComponentFunction<TfootStyleProps> = ({ border }, ...etc) =>
|
|
109
|
-
mx(textPadding, modalSurface, border && groupBorder, ...etc);
|
|
73
|
+
export const tdRoot: ComponentFunction<TbodyStyleProps & { pinned?: boolean }> = ({ border, isGrid, pinned }, ...etc) =>
|
|
74
|
+
mx(
|
|
75
|
+
'relative',
|
|
76
|
+
'focus-within:!bg-neutral-50 dark:focus-within:!bg-neutral-900',
|
|
77
|
+
flushPadding,
|
|
78
|
+
border && 'border-b border-l last:border-r border-neutral-200 dark:border-neutral-700',
|
|
79
|
+
pinned && 'border-t',
|
|
80
|
+
isGrid && gridCellFocusRing,
|
|
81
|
+
...etc,
|
|
82
|
+
);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
type TableFooterProps = {};
|
|
3
|
-
declare const TableFooter: {
|
|
4
|
-
(props: TableFooterProps): JSX.Element;
|
|
5
|
-
displayName: string;
|
|
6
|
-
};
|
|
7
|
-
export { TableFooter };
|
|
8
|
-
export type { TableFooterProps };
|
|
9
|
-
//# sourceMappingURL=TableFooter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableFooter.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/TableFooter.tsx"],"names":[],"mappings":";AAUA,KAAK,gBAAgB,GAAG,EAAE,CAAC;AAI3B,QAAA,MAAM,WAAW;YAAW,gBAAgB;;CAwB3C,CAAC;AAIF,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { flexRender } from '@tanstack/react-table';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
|
|
8
|
-
import { useTableContext } from './TableContext';
|
|
9
|
-
import { tfootRoot, tfootTr, tfootTh } from '../../theme';
|
|
10
|
-
|
|
11
|
-
type TableFooterProps = {};
|
|
12
|
-
|
|
13
|
-
const TABLE_FOOT_NAME = 'TableFooter';
|
|
14
|
-
|
|
15
|
-
const TableFooter = (props: TableFooterProps) => {
|
|
16
|
-
const tableContext = useTableContext();
|
|
17
|
-
const { table, expand, debug } = tableContext;
|
|
18
|
-
const footers = table.getFooterGroups();
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<tfoot className={tfootRoot(props)}>
|
|
22
|
-
{footers.map((footerGroup) => (
|
|
23
|
-
<tr key={footerGroup.id} className={tfootTr(tableContext)}>
|
|
24
|
-
{debug && <th />}
|
|
25
|
-
|
|
26
|
-
{footerGroup.headers.map((footer) => {
|
|
27
|
-
return (
|
|
28
|
-
<th key={footer.id} className={tfootTh(tableContext, footer.column.columnDef.meta?.footer?.classNames)}>
|
|
29
|
-
{footer.isPlaceholder ? null : flexRender(footer.column.columnDef.footer, footer.getContext())}
|
|
30
|
-
</th>
|
|
31
|
-
);
|
|
32
|
-
})}
|
|
33
|
-
|
|
34
|
-
{expand && <th />}
|
|
35
|
-
</tr>
|
|
36
|
-
))}
|
|
37
|
-
</tfoot>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
TableFooter.displayName = TABLE_FOOT_NAME;
|
|
42
|
-
|
|
43
|
-
export { TableFooter };
|
|
44
|
-
|
|
45
|
-
export type { TableFooterProps };
|