@dxos/react-ui-table 0.8.1-staging.391c573 → 0.8.1-staging.9eaf14f
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/{chunk-3FR6NHPD.mjs → chunk-YWNRUF4J.mjs} +8 -6
- package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +625 -225
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-NB3SFHGA.cjs → chunk-TGG6OZ54.cjs} +10 -8
- package/dist/lib/node/chunk-TGG6OZ54.cjs.map +7 -0
- package/dist/lib/node/index.cjs +618 -220
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +3 -3
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{chunk-RLVVOZW5.mjs → chunk-KKLP54L3.mjs} +8 -6
- package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +625 -225
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +24 -0
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -0
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +10 -0
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +1 -0
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +4 -3
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/index.d.ts +1 -0
- package/dist/types/src/components/Table/index.d.ts.map +1 -1
- package/dist/types/src/components/Table/relations.stories.d.ts +9 -0
- package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -0
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +7 -7
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useTableModel.d.ts +8 -9
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/model/index.d.ts +1 -0
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +6 -3
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +42 -16
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +4 -4
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts +2 -2
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +7 -32
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/dynamic-table.d.ts +31 -0
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts +2 -2
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/src/util/table.d.ts +5 -3
- package/dist/types/src/util/table.d.ts.map +1 -1
- package/package.json +37 -36
- package/src/components/Table/ColumnActionsMenu.tsx +6 -4
- package/src/components/Table/ColumnSettings.tsx +5 -6
- package/src/components/Table/CreateRefPanel.tsx +3 -3
- package/src/components/Table/DynamicTable.stories.tsx +155 -0
- package/src/components/Table/DynamicTable.tsx +104 -0
- package/src/components/Table/RefPanel.tsx +3 -3
- package/src/components/Table/RowActionsMenu.tsx +18 -3
- package/src/components/Table/Table.stories.tsx +170 -115
- package/src/components/Table/Table.tsx +71 -26
- package/src/components/Table/index.ts +1 -0
- package/src/components/Table/relations.stories.tsx +113 -0
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +15 -5
- package/src/components/TableCellEditor/TableCellEditor.tsx +102 -4
- package/src/components/testing.ts +0 -1
- package/src/hooks/useTableModel.ts +35 -14
- package/src/model/index.ts +1 -0
- package/src/model/selection-model.ts +12 -2
- package/src/model/table-model.test.ts +2 -2
- package/src/model/table-model.ts +117 -32
- package/src/model/table-presentation.test.ts +2 -2
- package/src/model/table-presentation.ts +94 -22
- package/src/model/table-sorting.ts +3 -2
- package/src/playwright/smoke.spec.ts +2 -3
- package/src/types/table.ts +9 -10
- package/src/util/dynamic-table.ts +103 -0
- package/src/util/index.ts +1 -0
- package/src/util/table-controls.ts +4 -4
- package/src/util/table.ts +68 -65
- package/dist/lib/browser/_deprecated/index.mjs +0 -1483
- package/dist/lib/browser/_deprecated/index.mjs.map +0 -7
- package/dist/lib/browser/chunk-3FR6NHPD.mjs.map +0 -7
- package/dist/lib/node/_deprecated/index.cjs +0 -1511
- package/dist/lib/node/_deprecated/index.cjs.map +0 -7
- package/dist/lib/node/chunk-NB3SFHGA.cjs.map +0 -7
- package/dist/lib/node-esm/_deprecated/index.mjs +0 -1485
- package/dist/lib/node-esm/_deprecated/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RLVVOZW5.mjs.map +0 -7
- package/dist/types/src/_deprecated/components/Cell/Cell.d.ts +0 -12
- package/dist/types/src/_deprecated/components/Cell/Cell.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Cell/CellCombobox.d.ts +0 -13
- package/dist/types/src/_deprecated/components/Cell/CellCombobox.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Cell/index.d.ts +0 -2
- package/dist/types/src/_deprecated/components/Cell/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.d.ts +0 -23
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts +0 -36
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnMenu.stories.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.d.ts +0 -15
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts +0 -84
- package/dist/types/src/_deprecated/components/ColumnMenu/ColumnSettings.stories.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/ColumnMenu/index.d.ts +0 -3
- package/dist/types/src/_deprecated/components/ColumnMenu/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/Table.d.ts +0 -20
- package/dist/types/src/_deprecated/components/Table/Table.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/Table.stories.d.ts +0 -116
- package/dist/types/src/_deprecated/components/Table/Table.stories.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/TableBody.d.ts +0 -12
- package/dist/types/src/_deprecated/components/Table/TableBody.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/TableContext.d.ts +0 -13
- package/dist/types/src/_deprecated/components/Table/TableContext.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/TableHead.d.ts +0 -9
- package/dist/types/src/_deprecated/components/Table/TableHead.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/TableRootContext.d.ts +0 -17
- package/dist/types/src/_deprecated/components/Table/TableRootContext.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/index.d.ts +0 -5
- package/dist/types/src/_deprecated/components/Table/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/Table/props.d.ts +0 -42
- package/dist/types/src/_deprecated/components/Table/props.d.ts.map +0 -1
- package/dist/types/src/_deprecated/components/index.d.ts +0 -4
- package/dist/types/src/_deprecated/components/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/helpers.d.ts +0 -91
- package/dist/types/src/_deprecated/helpers.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/index.d.ts +0 -5
- package/dist/types/src/_deprecated/hooks/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/useColumnSizing.d.ts +0 -12
- package/dist/types/src/_deprecated/hooks/useColumnSizing.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/useColumnSorting.d.ts +0 -15
- package/dist/types/src/_deprecated/hooks/useColumnSorting.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/usePinLastRow.d.ts +0 -3
- package/dist/types/src/_deprecated/hooks/usePinLastRow.d.ts.map +0 -1
- package/dist/types/src/_deprecated/hooks/useRowSelection.d.ts +0 -7
- package/dist/types/src/_deprecated/hooks/useRowSelection.d.ts.map +0 -1
- package/dist/types/src/_deprecated/index.d.ts +0 -8
- package/dist/types/src/_deprecated/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/schema/Schema.stories.d.ts +0 -11
- package/dist/types/src/_deprecated/schema/Schema.stories.d.ts.map +0 -1
- package/dist/types/src/_deprecated/schema/column-utils.d.ts +0 -7
- package/dist/types/src/_deprecated/schema/column-utils.d.ts.map +0 -1
- package/dist/types/src/_deprecated/schema/index.d.ts +0 -3
- package/dist/types/src/_deprecated/schema/index.d.ts.map +0 -1
- package/dist/types/src/_deprecated/schema/types.d.ts +0 -27
- package/dist/types/src/_deprecated/schema/types.d.ts.map +0 -1
- package/dist/types/src/_deprecated/theme.d.ts +0 -29
- package/dist/types/src/_deprecated/theme.d.ts.map +0 -1
- package/dist/types/src/_deprecated/translations.d.ts +0 -21
- package/dist/types/src/_deprecated/translations.d.ts.map +0 -1
- package/dist/types/src/_deprecated/types.d.ts +0 -26
- package/dist/types/src/_deprecated/types.d.ts.map +0 -1
- package/src/_deprecated/components/Cell/Cell.tsx +0 -88
- package/src/_deprecated/components/Cell/CellCombobox.tsx +0 -103
- package/src/_deprecated/components/Cell/index.ts +0 -5
- package/src/_deprecated/components/ColumnMenu/ColumnMenu.stories.tsx +0 -129
- package/src/_deprecated/components/ColumnMenu/ColumnMenu.tsx +0 -182
- package/src/_deprecated/components/ColumnMenu/ColumnSettings.stories.tsx +0 -108
- package/src/_deprecated/components/ColumnMenu/ColumnSettings.tsx +0 -207
- package/src/_deprecated/components/ColumnMenu/index.ts +0 -6
- package/src/_deprecated/components/Table/Table.stories.tsx +0 -508
- package/src/_deprecated/components/Table/Table.tsx +0 -301
- package/src/_deprecated/components/Table/TableBody.tsx +0 -82
- package/src/_deprecated/components/Table/TableContext.tsx +0 -34
- package/src/_deprecated/components/Table/TableHead.tsx +0 -78
- package/src/_deprecated/components/Table/TableRootContext.ts +0 -39
- package/src/_deprecated/components/Table/index.ts +0 -8
- package/src/_deprecated/components/Table/props.ts +0 -60
- package/src/_deprecated/components/index.ts +0 -7
- package/src/_deprecated/helpers.tsx +0 -526
- package/src/_deprecated/hooks/index.ts +0 -8
- package/src/_deprecated/hooks/useColumnSizing.ts +0 -46
- package/src/_deprecated/hooks/useColumnSorting.ts +0 -64
- package/src/_deprecated/hooks/usePinLastRow.ts +0 -47
- package/src/_deprecated/hooks/useRowSelection.ts +0 -40
- package/src/_deprecated/index.ts +0 -12
- package/src/_deprecated/schema/Schema.stories.tsx +0 -59
- package/src/_deprecated/schema/column-utils.ts +0 -54
- package/src/_deprecated/schema/index.ts +0 -6
- package/src/_deprecated/schema/types.ts +0 -40
- package/src/_deprecated/theme.ts +0 -82
- package/src/_deprecated/translations.ts +0 -26
- package/src/_deprecated/types.ts +0 -38
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
6
|
-
import { type OnChangeFn, type RowSelectionState } from '@tanstack/react-table';
|
|
7
|
-
import { useCallback } from 'react';
|
|
8
|
-
|
|
9
|
-
import { type TableProps } from '../components/Table';
|
|
10
|
-
|
|
11
|
-
export const useRowSelection = (
|
|
12
|
-
props: Pick<
|
|
13
|
-
TableProps<any>,
|
|
14
|
-
'rowsSelectable' | 'defaultRowSelection' | 'rowSelection' | 'onRowSelectionChange' | 'rowsSelectable'
|
|
15
|
-
>,
|
|
16
|
-
) => {
|
|
17
|
-
const [rowSelection = {}, setRowSelection] = useControllableState({
|
|
18
|
-
prop: props.rowSelection,
|
|
19
|
-
onChange: props.onRowSelectionChange,
|
|
20
|
-
defaultProp: props.defaultRowSelection,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// TODO(thure): Does @tanstack/react-table really need this intervention? It did seem necessary to enforce single-selection...
|
|
24
|
-
const handleRowSelectionChange = useCallback<OnChangeFn<RowSelectionState>>(
|
|
25
|
-
(updaterOrValue) => {
|
|
26
|
-
const nextRowSelection = typeof updaterOrValue === 'function' ? updaterOrValue(rowSelection) : updaterOrValue;
|
|
27
|
-
if (props.rowsSelectable === 'multi') {
|
|
28
|
-
setRowSelection(nextRowSelection);
|
|
29
|
-
} else if (props.rowsSelectable) {
|
|
30
|
-
const nextRowSelectionKey = Object.keys(nextRowSelection).filter((id) => !rowSelection[id])[0];
|
|
31
|
-
setRowSelection(nextRowSelectionKey ? { [nextRowSelectionKey]: true } : {});
|
|
32
|
-
} else {
|
|
33
|
-
setRowSelection({});
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
[props.rowsSelectable, setRowSelection, rowSelection],
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return { rowSelection, handleRowSelectionChange };
|
|
40
|
-
};
|
package/src/_deprecated/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2022 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
export { default as translations } from './translations';
|
|
6
|
-
|
|
7
|
-
export * from './components';
|
|
8
|
-
export * from './helpers';
|
|
9
|
-
export * from './hooks';
|
|
10
|
-
export * from './schema';
|
|
11
|
-
export * from './theme';
|
|
12
|
-
export * from './types';
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { Arbitrary } from 'effect';
|
|
8
|
-
import * as fc from 'fast-check';
|
|
9
|
-
import React from 'react';
|
|
10
|
-
|
|
11
|
-
import { S } from '@dxos/echo-schema';
|
|
12
|
-
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
13
|
-
|
|
14
|
-
import { schemaToColumnDefs } from './column-utils';
|
|
15
|
-
import { Table } from '../components';
|
|
16
|
-
|
|
17
|
-
export default {
|
|
18
|
-
title: 'ui/react-ui-table/deprecated/Schema',
|
|
19
|
-
decorators: [withTheme, withLayout()],
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const TestSchema = S.Struct({
|
|
23
|
-
field1: S.String,
|
|
24
|
-
field2: S.Number,
|
|
25
|
-
field3: S.Date,
|
|
26
|
-
field4: S.optional(S.String.pipe(S.length(10))),
|
|
27
|
-
field5: S.optional(
|
|
28
|
-
S.Struct({
|
|
29
|
-
innerField1: S.String,
|
|
30
|
-
innerField2: S.Number,
|
|
31
|
-
}),
|
|
32
|
-
),
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
type TestType = S.Schema.Type<typeof TestSchema>;
|
|
36
|
-
|
|
37
|
-
const columns = schemaToColumnDefs(TestSchema);
|
|
38
|
-
const items = fc.sample(Arbitrary.make(TestSchema), 10);
|
|
39
|
-
|
|
40
|
-
export const Default = {
|
|
41
|
-
render: () => {
|
|
42
|
-
return (
|
|
43
|
-
<Table.Root>
|
|
44
|
-
<Table.Viewport classNames='fixed inset-0'>
|
|
45
|
-
<Table.Main<TestType>
|
|
46
|
-
role='grid'
|
|
47
|
-
rowsSelectable='multi'
|
|
48
|
-
keyAccessor={(row) => JSON.stringify(row)}
|
|
49
|
-
columns={columns}
|
|
50
|
-
data={items}
|
|
51
|
-
fullWidth
|
|
52
|
-
stickyHeader
|
|
53
|
-
border
|
|
54
|
-
/>
|
|
55
|
-
</Table.Viewport>
|
|
56
|
-
</Table.Root>
|
|
57
|
-
);
|
|
58
|
-
},
|
|
59
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type ColumnDef } from '@tanstack/react-table';
|
|
6
|
-
|
|
7
|
-
import { TypeEnum, type S } from '@dxos/echo-schema';
|
|
8
|
-
import { FormatEnum } from '@dxos/echo-schema';
|
|
9
|
-
import { mapSchemaToFields } from '@dxos/schema';
|
|
10
|
-
|
|
11
|
-
import { createColumnBuilder } from '../helpers';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated
|
|
15
|
-
*/
|
|
16
|
-
export const schemaToColumnDefs = <T>(schema: S.Schema<T, any>): ColumnDef<T, any>[] => {
|
|
17
|
-
const { helper, builder } = createColumnBuilder<T>();
|
|
18
|
-
|
|
19
|
-
return mapSchemaToFields(schema).map(({ property, type, format }) => {
|
|
20
|
-
const propertyKey = property.toString();
|
|
21
|
-
|
|
22
|
-
if (!format) {
|
|
23
|
-
switch (type) {
|
|
24
|
-
case TypeEnum.String: {
|
|
25
|
-
return helper.accessor(
|
|
26
|
-
propertyKey as any,
|
|
27
|
-
builder.string({ label: propertyKey, classNames: [property === 'id' && 'font-mono'] }),
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
case TypeEnum.Number: {
|
|
31
|
-
return helper.accessor(propertyKey as any, builder.number({ label: propertyKey }));
|
|
32
|
-
}
|
|
33
|
-
case TypeEnum.Boolean: {
|
|
34
|
-
return helper.accessor(propertyKey as any, builder.switch({ label: propertyKey }));
|
|
35
|
-
}
|
|
36
|
-
default: {
|
|
37
|
-
throw new Error(`Unhandled scalar type: ${type}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
switch (format) {
|
|
43
|
-
case FormatEnum.Date: {
|
|
44
|
-
return helper.accessor(propertyKey as any, builder.date({ label: propertyKey }));
|
|
45
|
-
}
|
|
46
|
-
case FormatEnum.JSON: {
|
|
47
|
-
return helper.accessor(propertyKey as any, builder.json({ label: propertyKey, id: propertyKey }));
|
|
48
|
-
}
|
|
49
|
-
default: {
|
|
50
|
-
throw new Error(`Unhandled format: ${format}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type TypeEnum, type FormatEnum } from '@dxos/echo-schema';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*/
|
|
10
|
-
// TODO(burdon): Reconcile with @dxos/schema/View.
|
|
11
|
-
export type TableDef = {
|
|
12
|
-
id: string;
|
|
13
|
-
name?: string;
|
|
14
|
-
columns: ColumnDef[];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated
|
|
19
|
-
*/
|
|
20
|
-
// TODO(burdon): Reconcile with @dxos/schema/Field.
|
|
21
|
-
export type ColumnDef = {
|
|
22
|
-
id: string;
|
|
23
|
-
prop: string;
|
|
24
|
-
type: TypeEnum;
|
|
25
|
-
format?: FormatEnum;
|
|
26
|
-
size?: number;
|
|
27
|
-
label?: string;
|
|
28
|
-
|
|
29
|
-
// type = number
|
|
30
|
-
digits?: number;
|
|
31
|
-
|
|
32
|
-
// type = ref
|
|
33
|
-
refTable?: string;
|
|
34
|
-
refProp?: string;
|
|
35
|
-
|
|
36
|
-
// TODO(burdon): Move to meta.
|
|
37
|
-
fixed?: boolean;
|
|
38
|
-
editable?: boolean;
|
|
39
|
-
resizable?: boolean;
|
|
40
|
-
};
|
package/src/_deprecated/theme.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { focusRing, ghostSelected, ghostSelectedCurrent, mx } from '@dxos/react-ui-theme';
|
|
6
|
-
import { type ComponentFunction } from '@dxos/react-ui-types';
|
|
7
|
-
|
|
8
|
-
import { type TableContextValue, type TableFlags } from './components';
|
|
9
|
-
|
|
10
|
-
export const currentRow = '!bg-neutral-75 !dark:bg-neutral-850';
|
|
11
|
-
export const selectedRow = '!bg-primary-100 dark:!bg-primary-700';
|
|
12
|
-
export const flushPadding = 'pli-0 plb-0';
|
|
13
|
-
export const textPadding = 'pli-2 plb-0';
|
|
14
|
-
export const headPadding = 'pli-2 plb-0';
|
|
15
|
-
|
|
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';
|
|
20
|
-
|
|
21
|
-
export type TableStyleProps = Partial<TableContextValue<any>>;
|
|
22
|
-
|
|
23
|
-
export const tableRoot: ComponentFunction<TableStyleProps> = ({ fullWidth }, ...etc) =>
|
|
24
|
-
mx('table-fixed', 'text-neutral-800 dark:text-neutral-200', fullWidth && 'is-full', ...etc);
|
|
25
|
-
|
|
26
|
-
export const groupTh: ComponentFunction<TableStyleProps> = (_props, ...etc) =>
|
|
27
|
-
mx('text-start font-medium', flushPadding, ...etc);
|
|
28
|
-
|
|
29
|
-
export type TheadStyleProps = Partial<TableFlags>;
|
|
30
|
-
|
|
31
|
-
export const theadRoot: ComponentFunction<TheadStyleProps> = ({ header, stickyHeader }, ...etc) =>
|
|
32
|
-
mx(header ? stickyHeader && 'sticky block-start-[--sticky-top] z-[1]' : 'collapse', stickyRowColors, ...etc);
|
|
33
|
-
|
|
34
|
-
export const theadTr: ComponentFunction<TheadStyleProps> = (_props, ...etc) => mx('group', ...etc);
|
|
35
|
-
|
|
36
|
-
export const theadTh: ComponentFunction<TheadStyleProps> = ({ border }, ...etc) =>
|
|
37
|
-
mx(
|
|
38
|
-
'relative',
|
|
39
|
-
'text-start text-xs select-none truncate',
|
|
40
|
-
headPadding,
|
|
41
|
-
border && borderColors,
|
|
42
|
-
border && 'border-t border-b border-l last:border-r',
|
|
43
|
-
...etc,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
export const theadResizeRoot: ComponentFunction<{ isResizing: boolean }> = ({ isResizing }) => {
|
|
47
|
-
return mx(
|
|
48
|
-
'absolute h-full w-[4px] top-0 right-0',
|
|
49
|
-
'cursor-col-resize',
|
|
50
|
-
'user-select-none',
|
|
51
|
-
'touch-action-none',
|
|
52
|
-
'pointer-coarse:bg-neutral-100 dark:pointer-coarse:bg-neutral-800',
|
|
53
|
-
!isResizing && 'group-hover:bg-neutral-100 dark:group-hover:bg-neutral-800',
|
|
54
|
-
isResizing && 'bg-primary-500',
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export type TbodyStyleProps = Partial<TableContextValue<any>>;
|
|
59
|
-
export const tbodyRoot: ComponentFunction<TbodyStyleProps> = (_props, ...etc) => mx(...etc);
|
|
60
|
-
|
|
61
|
-
export type TbodyTrStyleProps = Partial<{ canBeCurrent?: boolean; isPinned?: boolean }>;
|
|
62
|
-
export const tbodyTr: ComponentFunction<TbodyTrStyleProps> = ({ canBeCurrent, isPinned }, ...etc) =>
|
|
63
|
-
mx(
|
|
64
|
-
'group',
|
|
65
|
-
canBeCurrent ? ghostSelectedCurrent : ghostSelected,
|
|
66
|
-
canBeCurrent && focusRing,
|
|
67
|
-
canBeCurrent && 'cursor-pointer',
|
|
68
|
-
isPinned && 'sticky z-1 block-end-0',
|
|
69
|
-
isPinned && stickyRowColors,
|
|
70
|
-
...etc,
|
|
71
|
-
);
|
|
72
|
-
|
|
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,26 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
export const translationKey = 'table';
|
|
6
|
-
|
|
7
|
-
export default [
|
|
8
|
-
{
|
|
9
|
-
'en-US': {
|
|
10
|
-
[translationKey]: {
|
|
11
|
-
'no selection label': ' ',
|
|
12
|
-
'number column type label': 'Number',
|
|
13
|
-
'boolean column type label': 'Boolean',
|
|
14
|
-
'date column type label': 'Date',
|
|
15
|
-
'string column type label': 'Text',
|
|
16
|
-
'ref column type label': 'Reference',
|
|
17
|
-
'digits label': 'Decimal places',
|
|
18
|
-
'save label': 'Save',
|
|
19
|
-
'delete label': 'Delete',
|
|
20
|
-
'column label label': 'Label',
|
|
21
|
-
'property key label': 'Property',
|
|
22
|
-
'column type label': 'Type',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
];
|
package/src/_deprecated/types.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type ColumnDef, type RowData } from '@tanstack/react-table';
|
|
6
|
-
|
|
7
|
-
import { type ClassNameValue } from '@dxos/react-ui-types';
|
|
8
|
-
|
|
9
|
-
import { type SearchListQueryModel, type ValueUpdater } from './helpers';
|
|
10
|
-
|
|
11
|
-
// Define custom meta definitions.
|
|
12
|
-
declare module '@tanstack/react-table' {
|
|
13
|
-
// Access via table.options.meta.
|
|
14
|
-
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
15
|
-
interface TableMeta<TData extends RowData> {}
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
18
|
-
interface ColumnMeta<TData extends RowData, TValue> {
|
|
19
|
-
expand?: boolean;
|
|
20
|
-
resizable?: boolean;
|
|
21
|
-
model?: SearchListQueryModel<TData>;
|
|
22
|
-
onUpdate?: ValueUpdater<TData, any>;
|
|
23
|
-
digits?: number;
|
|
24
|
-
header?: {
|
|
25
|
-
classNames?: ClassNameValue;
|
|
26
|
-
};
|
|
27
|
-
footer?: {
|
|
28
|
-
classNames?: ClassNameValue;
|
|
29
|
-
};
|
|
30
|
-
cell?: {
|
|
31
|
-
classNames?: ClassNameValue;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type KeyValue<TData extends RowData> = (row: TData) => string;
|
|
37
|
-
|
|
38
|
-
export type TableColumnDef<TData extends RowData, TValue = any> = ColumnDef<TData, TValue>;
|