@dxos/react-ui-grid 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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 +135 -157
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/CellEditor/CellEditor.d.ts +3 -2
- package/dist/types/src/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/CellEditor/CellEditor.stories.d.ts +1 -1
- package/dist/types/src/Grid/Grid.d.ts +2 -2
- package/dist/types/src/Grid/Grid.d.ts.map +1 -1
- package/dist/types/src/Grid/Grid.stories.d.ts +2 -1
- package/dist/types/src/Grid/Grid.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -19
- package/src/CellEditor/CellEditor.stories.tsx +1 -1
- package/src/CellEditor/CellEditor.tsx +4 -5
- package/src/Grid/Grid.stories.tsx +57 -22
- package/src/Grid/Grid.tsx +5 -3
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-grid",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.bc674ce",
|
|
4
4
|
"description": "React component which manages a `dx-grid` Lit web component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
|
-
"sideEffects":
|
|
13
|
+
"sideEffects": false,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
@@ -28,31 +32,31 @@
|
|
|
28
32
|
"@codemirror/state": "^6.5.2",
|
|
29
33
|
"@codemirror/view": "^6.38.4",
|
|
30
34
|
"@lit/react": "^1.0.8",
|
|
31
|
-
"@preact-signals/safe-react": "^0.9.0",
|
|
32
35
|
"@radix-ui/react-context": "1.1.1",
|
|
33
36
|
"@radix-ui/react-popper": "1.2.2",
|
|
34
37
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
35
|
-
"@dxos/lit-grid": "0.8.4-main.
|
|
36
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
37
|
-
"@dxos/
|
|
38
|
+
"@dxos/lit-grid": "0.8.4-main.bc674ce",
|
|
39
|
+
"@dxos/react-ui-editor": "0.8.4-main.bc674ce",
|
|
40
|
+
"@dxos/ui-editor": "0.8.4-main.bc674ce",
|
|
41
|
+
"@dxos/util": "0.8.4-main.bc674ce"
|
|
38
42
|
},
|
|
39
43
|
"devDependencies": {
|
|
40
|
-
"@types/react": "~19.2.
|
|
41
|
-
"@types/react-dom": "~19.2.
|
|
42
|
-
"react": "~19.2.
|
|
43
|
-
"react-dom": "~19.2.
|
|
44
|
+
"@types/react": "~19.2.7",
|
|
45
|
+
"@types/react-dom": "~19.2.3",
|
|
46
|
+
"react": "~19.2.3",
|
|
47
|
+
"react-dom": "~19.2.3",
|
|
44
48
|
"vite": "7.1.9",
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
49
|
+
"@dxos/random": "0.8.4-main.bc674ce",
|
|
50
|
+
"@dxos/react-ui": "0.8.4-main.bc674ce",
|
|
51
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.bc674ce",
|
|
52
|
+
"@dxos/storybook-utils": "0.8.4-main.bc674ce",
|
|
53
|
+
"@dxos/ui-theme": "0.8.4-main.bc674ce"
|
|
50
54
|
},
|
|
51
55
|
"peerDependencies": {
|
|
52
|
-
"react": "
|
|
53
|
-
"react-dom": "
|
|
54
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
55
|
-
"@dxos/
|
|
56
|
+
"react": "~19.2.3",
|
|
57
|
+
"react-dom": "~19.2.3",
|
|
58
|
+
"@dxos/react-ui": "0.8.4-main.bc674ce",
|
|
59
|
+
"@dxos/ui-theme": "0.8.4-main.bc674ce"
|
|
56
60
|
},
|
|
57
61
|
"publishConfig": {
|
|
58
62
|
"access": "public"
|
|
@@ -47,7 +47,7 @@ const DefaultStory = (props: CellEditorProps) => {
|
|
|
47
47
|
<div className='text-sm'>
|
|
48
48
|
Last action: <span className='font-mono'>{lastAction}</span>
|
|
49
49
|
</div>
|
|
50
|
-
<div className='relative border border-separator
|
|
50
|
+
<div className='relative border border-separator bs-[100px] is-[300px]'>
|
|
51
51
|
<CellEditor
|
|
52
52
|
value={value}
|
|
53
53
|
extensions={extensions}
|
|
@@ -8,15 +8,14 @@ import { EditorView, keymap } from '@codemirror/view';
|
|
|
8
8
|
import React, { type KeyboardEvent } from 'react';
|
|
9
9
|
|
|
10
10
|
import { useThemeContext } from '@dxos/react-ui';
|
|
11
|
+
import { type UseTextEditorProps, useTextEditor } from '@dxos/react-ui-editor';
|
|
11
12
|
import {
|
|
12
13
|
type ThemeExtensionsOptions,
|
|
13
|
-
type UseTextEditorProps,
|
|
14
14
|
createBasicExtensions,
|
|
15
15
|
createThemeExtensions,
|
|
16
16
|
filterChars,
|
|
17
|
-
|
|
18
|
-
} from '@dxos/
|
|
19
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
17
|
+
} from '@dxos/ui-editor';
|
|
18
|
+
import { mx } from '@dxos/ui-theme';
|
|
20
19
|
|
|
21
20
|
import { type GridEditBox } from '../Grid';
|
|
22
21
|
|
|
@@ -123,7 +122,7 @@ export type CellEditorProps = {
|
|
|
123
122
|
} & Pick<UseTextEditorProps, 'autoFocus'> &
|
|
124
123
|
Pick<ThemeExtensionsOptions, 'slots'>;
|
|
125
124
|
|
|
126
|
-
export const CellEditor = ({ value, extensions, box, gridId,
|
|
125
|
+
export const CellEditor = ({ value, extensions, box, gridId, autoFocus, slots, onBlur }: CellEditorProps) => {
|
|
127
126
|
const { themeMode } = useThemeContext();
|
|
128
127
|
const { parentRef } = useTextEditor(() => {
|
|
129
128
|
return {
|
|
@@ -6,10 +6,12 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import React, { type MouseEvent, type MutableRefObject, useCallback, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { defaultRowSize } from '@dxos/lit-grid';
|
|
9
|
+
import { type DxGridPlaneCells } from '@dxos/lit-grid';
|
|
9
10
|
import { faker } from '@dxos/random';
|
|
10
11
|
import { DropdownMenu } from '@dxos/react-ui';
|
|
11
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
12
|
-
import {
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
import { toPlaneCellIndex } from '@dxos/react-ui-grid';
|
|
14
|
+
import { Combobox, type ComboboxRootProps, useSearchListResults } from '@dxos/react-ui-searchlist';
|
|
13
15
|
|
|
14
16
|
import { Grid, type GridContentProps, type GridEditing, type GridRootProps } from './Grid';
|
|
15
17
|
|
|
@@ -62,7 +64,7 @@ const GridStory = ({ initialCells, ...props }: GridStoryProps) => {
|
|
|
62
64
|
}, []);
|
|
63
65
|
|
|
64
66
|
return (
|
|
65
|
-
<div role='none' className='
|
|
67
|
+
<div role='none' className='contents'>
|
|
66
68
|
<Grid.Root id='story' editing={editing} onEditingChange={handleEditingChange}>
|
|
67
69
|
{/* TODO(burdon): Why is this property not just "cells" or "values" */}
|
|
68
70
|
<Grid.Content {...props} initialCells={cells} onClick={handleClick} />
|
|
@@ -85,24 +87,34 @@ const GridStory = ({ initialCells, ...props }: GridStoryProps) => {
|
|
|
85
87
|
onValueChange={setMultiselectValue}
|
|
86
88
|
>
|
|
87
89
|
<Combobox.VirtualTrigger virtualRef={triggerRef} />
|
|
88
|
-
<
|
|
89
|
-
<Combobox.Input placeholder='Search...' />
|
|
90
|
-
<Combobox.List>
|
|
91
|
-
{storybookItems.map((value) => (
|
|
92
|
-
<Combobox.Item key={value}>{value}</Combobox.Item>
|
|
93
|
-
))}
|
|
94
|
-
</Combobox.List>
|
|
95
|
-
<Combobox.Arrow />
|
|
96
|
-
</Combobox.Content>
|
|
90
|
+
<ComboboxContentWithFiltering />
|
|
97
91
|
</Combobox.Root>
|
|
98
92
|
</div>
|
|
99
93
|
);
|
|
100
94
|
};
|
|
101
95
|
|
|
96
|
+
const ComboboxContentWithFiltering = () => {
|
|
97
|
+
const { results, handleSearch } = useSearchListResults({
|
|
98
|
+
items: storybookItems,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Combobox.Content onSearch={handleSearch}>
|
|
103
|
+
<Combobox.Input placeholder='Search...' />
|
|
104
|
+
<Combobox.List>
|
|
105
|
+
{results.map((value) => (
|
|
106
|
+
<Combobox.Item key={value} value={value} label={value} />
|
|
107
|
+
))}
|
|
108
|
+
</Combobox.List>
|
|
109
|
+
<Combobox.Arrow />
|
|
110
|
+
</Combobox.Content>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
102
114
|
const meta = {
|
|
103
115
|
title: 'ui/react-ui-grid/Grid',
|
|
104
116
|
component: GridStory,
|
|
105
|
-
decorators: [withTheme],
|
|
117
|
+
decorators: [withTheme, withLayout({ layout: 'column' })],
|
|
106
118
|
parameters: {
|
|
107
119
|
layout: 'fullscreen',
|
|
108
120
|
},
|
|
@@ -112,6 +124,8 @@ export default meta;
|
|
|
112
124
|
|
|
113
125
|
type Story = StoryObj<typeof meta>;
|
|
114
126
|
|
|
127
|
+
export const Default: Story = {};
|
|
128
|
+
|
|
115
129
|
export const Basic: Story = {
|
|
116
130
|
args: {
|
|
117
131
|
id: 'story',
|
|
@@ -158,26 +172,47 @@ export const Basic: Story = {
|
|
|
158
172
|
},
|
|
159
173
|
};
|
|
160
174
|
|
|
161
|
-
|
|
162
|
-
|
|
175
|
+
const cellSize = 40;
|
|
176
|
+
|
|
177
|
+
// TODO(burdon): Calendar.
|
|
178
|
+
export const Calendar: Story = {
|
|
163
179
|
args: {
|
|
164
180
|
id: 'story',
|
|
165
|
-
limitColumns:
|
|
181
|
+
limitColumns: 7,
|
|
166
182
|
columnDefault: {
|
|
167
183
|
grid: {
|
|
168
|
-
size:
|
|
184
|
+
size: cellSize,
|
|
185
|
+
resizeable: false,
|
|
169
186
|
},
|
|
170
187
|
},
|
|
171
188
|
rowDefault: {
|
|
172
189
|
grid: {
|
|
173
|
-
size:
|
|
190
|
+
size: cellSize,
|
|
174
191
|
resizeable: false,
|
|
175
192
|
},
|
|
176
193
|
},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
194
|
+
getCells: (range, plane) => {
|
|
195
|
+
const cells: DxGridPlaneCells = {};
|
|
196
|
+
if (plane === 'grid') {
|
|
197
|
+
for (let col = range.start.col; col <= range.end.col; col++) {
|
|
198
|
+
for (let row = range.start.row; row <= range.end.row; row++) {
|
|
199
|
+
// TODO(burdon): Formatting changes when cell is selected.
|
|
200
|
+
cells[toPlaneCellIndex({ col, row })] = {
|
|
201
|
+
readonly: true,
|
|
202
|
+
accessoryHtml: '<div class="flex bs-full is-full justify-center items-center overflow-hidden">0</div>',
|
|
203
|
+
className: '',
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return cells;
|
|
181
209
|
},
|
|
182
210
|
},
|
|
211
|
+
render: (args) => (
|
|
212
|
+
<div className='bs-full flex justify-center'>
|
|
213
|
+
<div className='bs-full is-[288px] border-x border-separator'>
|
|
214
|
+
<GridStory {...args} />
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
),
|
|
183
218
|
};
|
package/src/Grid/Grid.tsx
CHANGED
|
@@ -63,7 +63,9 @@ const [createGridContext, createGridScope] = createContextScope(GRID_NAME, []);
|
|
|
63
63
|
const [GridProvider, useGridContext] = createGridContext<GridContextValue>(GRID_NAME);
|
|
64
64
|
|
|
65
65
|
type GridRootProps = PropsWithChildren<
|
|
66
|
-
{
|
|
66
|
+
{
|
|
67
|
+
id: string;
|
|
68
|
+
} & Partial<{
|
|
67
69
|
editing: GridEditing;
|
|
68
70
|
defaultEditing: GridEditing;
|
|
69
71
|
onEditingChange: (nextEditing: GridEditing) => void;
|
|
@@ -71,12 +73,12 @@ type GridRootProps = PropsWithChildren<
|
|
|
71
73
|
>;
|
|
72
74
|
|
|
73
75
|
const GridRoot = ({
|
|
76
|
+
__gridScope,
|
|
77
|
+
children,
|
|
74
78
|
id,
|
|
75
79
|
editing: propsEditing,
|
|
76
80
|
defaultEditing,
|
|
77
81
|
onEditingChange,
|
|
78
|
-
children,
|
|
79
|
-
__gridScope,
|
|
80
82
|
}: GridScopedProps<GridRootProps>) => {
|
|
81
83
|
const [editing = null, setEditing] = useControllableState({
|
|
82
84
|
prop: propsEditing,
|