@dxos/react-ui-grid 0.8.4-main.dedc0f3 → 0.8.4-main.e8ec1fe
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 +2 -2
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/CellEditor/CellEditor.stories.d.ts +0 -1
- package/dist/types/src/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/Grid/Grid.d.ts +1 -1
- package/dist/types/src/Grid/Grid.d.ts.map +1 -1
- package/dist/types/src/Grid/Grid.stories.d.ts +2 -2
- package/dist/types/src/Grid/Grid.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/src/CellEditor/CellEditor.stories.tsx +2 -4
- package/src/CellEditor/CellEditor.tsx +2 -2
- package/src/Grid/Grid.stories.tsx +52 -27
- package/src/Grid/Grid.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-grid",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.e8ec1fe",
|
|
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",
|
|
@@ -24,35 +24,35 @@
|
|
|
24
24
|
"src"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@codemirror/autocomplete": "^6.
|
|
27
|
+
"@codemirror/autocomplete": "^6.19.0",
|
|
28
28
|
"@codemirror/state": "^6.5.2",
|
|
29
|
-
"@codemirror/view": "^6.38.
|
|
30
|
-
"@lit/react": "^1.0.
|
|
29
|
+
"@codemirror/view": "^6.38.4",
|
|
30
|
+
"@lit/react": "^1.0.8",
|
|
31
31
|
"@preact-signals/safe-react": "^0.9.0",
|
|
32
32
|
"@radix-ui/react-context": "1.1.1",
|
|
33
33
|
"@radix-ui/react-popper": "1.2.2",
|
|
34
34
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/util": "0.8.4-main.
|
|
35
|
+
"@dxos/lit-grid": "0.8.4-main.e8ec1fe",
|
|
36
|
+
"@dxos/react-ui-editor": "0.8.4-main.e8ec1fe",
|
|
37
|
+
"@dxos/util": "0.8.4-main.e8ec1fe"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/react": "~
|
|
41
|
-
"@types/react-dom": "~
|
|
42
|
-
"react": "~
|
|
43
|
-
"react-dom": "~
|
|
44
|
-
"vite": "7.1.
|
|
45
|
-
"@dxos/random": "0.8.4-main.
|
|
46
|
-
"@dxos/react-ui-searchlist": "0.8.4-main.
|
|
47
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
40
|
+
"@types/react": "~19.2.2",
|
|
41
|
+
"@types/react-dom": "~19.2.2",
|
|
42
|
+
"react": "~19.2.0",
|
|
43
|
+
"react-dom": "~19.2.0",
|
|
44
|
+
"vite": "7.1.9",
|
|
45
|
+
"@dxos/random": "0.8.4-main.e8ec1fe",
|
|
46
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.e8ec1fe",
|
|
47
|
+
"@dxos/react-ui-theme": "0.8.4-main.e8ec1fe",
|
|
48
|
+
"@dxos/react-ui": "0.8.4-main.e8ec1fe",
|
|
49
|
+
"@dxos/storybook-utils": "0.8.4-main.e8ec1fe"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"react": "
|
|
53
|
-
"react-dom": "
|
|
54
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
55
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
52
|
+
"react": "^19.0.0",
|
|
53
|
+
"react-dom": "^19.0.0",
|
|
54
|
+
"@dxos/react-ui": "0.8.4-main.e8ec1fe",
|
|
55
|
+
"@dxos/react-ui-theme": "0.8.4-main.e8ec1fe"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useState } from 'react';
|
|
9
7
|
|
|
10
|
-
import { withTheme } from '@dxos/
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
9
|
|
|
12
10
|
import { CellEditor, type CellEditorProps, type EditorKeyEvent, editorKeys } from './CellEditor';
|
|
13
11
|
|
|
@@ -49,7 +47,7 @@ const DefaultStory = (props: CellEditorProps) => {
|
|
|
49
47
|
<div className='text-sm'>
|
|
50
48
|
Last action: <span className='font-mono'>{lastAction}</span>
|
|
51
49
|
</div>
|
|
52
|
-
<div className='relative border border-separator
|
|
50
|
+
<div className='relative border border-separator bs-[100px] is-[300px]'>
|
|
53
51
|
<CellEditor
|
|
54
52
|
value={value}
|
|
55
53
|
extensions={extensions}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type UseTextEditorProps,
|
|
14
14
|
createBasicExtensions,
|
|
15
15
|
createThemeExtensions,
|
|
16
|
-
|
|
16
|
+
filterChars,
|
|
17
17
|
useTextEditor,
|
|
18
18
|
} from '@dxos/react-ui-editor';
|
|
19
19
|
import { mx } from '@dxos/react-ui-theme';
|
|
@@ -132,7 +132,7 @@ export const CellEditor = ({ value, extensions, box, gridId, onBlur, autoFocus,
|
|
|
132
132
|
selection: { anchor: value?.length ?? 0 },
|
|
133
133
|
extensions: [
|
|
134
134
|
extensions ?? [],
|
|
135
|
-
|
|
135
|
+
filterChars(/[\n\r]+/),
|
|
136
136
|
EditorView.focusChangeEffect.of((state, focusing) => {
|
|
137
137
|
if (!focusing) {
|
|
138
138
|
onBlur?.(state.doc.toString());
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { type MouseEvent, type MutableRefObject, useCallback, useRef, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { defaultRowSize } from '@dxos/lit-grid';
|
|
9
|
+
import { type DxGridPlaneCells } from '@dxos/lit-grid';
|
|
11
10
|
import { faker } from '@dxos/random';
|
|
12
11
|
import { DropdownMenu } from '@dxos/react-ui';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
import { toPlaneCellIndex } from '@dxos/react-ui-grid';
|
|
14
|
+
import { Combobox, type ComboboxRootProps } from '@dxos/react-ui-searchlist';
|
|
15
15
|
|
|
16
16
|
import { Grid, type GridContentProps, type GridEditing, type GridRootProps } from './Grid';
|
|
17
17
|
|
|
@@ -33,7 +33,7 @@ const GridStory = ({ initialCells, ...props }: GridStoryProps) => {
|
|
|
33
33
|
// Multiselect
|
|
34
34
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
|
35
35
|
const [multiSelectValue, setInternalMultiselectValue] = useState('');
|
|
36
|
-
const setMultiselectValue = useCallback<NonNullable<
|
|
36
|
+
const setMultiselectValue = useCallback<NonNullable<ComboboxRootProps['onValueChange']>>((nextValue) => {
|
|
37
37
|
setInternalMultiselectValue(nextValue);
|
|
38
38
|
setCells((cells) => {
|
|
39
39
|
// TODO(burdon): How can we get the cell address to update?
|
|
@@ -64,7 +64,7 @@ const GridStory = ({ initialCells, ...props }: GridStoryProps) => {
|
|
|
64
64
|
}, []);
|
|
65
65
|
|
|
66
66
|
return (
|
|
67
|
-
<div role='none' className='
|
|
67
|
+
<div role='none' className='contents'>
|
|
68
68
|
<Grid.Root id='story' editing={editing} onEditingChange={handleEditingChange}>
|
|
69
69
|
{/* TODO(burdon): Why is this property not just "cells" or "values" */}
|
|
70
70
|
<Grid.Content {...props} initialCells={cells} onClick={handleClick} />
|
|
@@ -80,23 +80,23 @@ const GridStory = ({ initialCells, ...props }: GridStoryProps) => {
|
|
|
80
80
|
</DropdownMenu.Root>
|
|
81
81
|
|
|
82
82
|
{/* Multiselect */}
|
|
83
|
-
<
|
|
83
|
+
<Combobox.Root
|
|
84
84
|
open={popoverOpen}
|
|
85
85
|
onOpenChange={setPopoverOpen}
|
|
86
86
|
value={multiSelectValue}
|
|
87
87
|
onValueChange={setMultiselectValue}
|
|
88
88
|
>
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
<
|
|
89
|
+
<Combobox.VirtualTrigger virtualRef={triggerRef} />
|
|
90
|
+
<Combobox.Content filter={(value, search) => (value.includes(search) ? 1 : 0)}>
|
|
91
|
+
<Combobox.Input placeholder='Search...' />
|
|
92
|
+
<Combobox.List>
|
|
93
93
|
{storybookItems.map((value) => (
|
|
94
|
-
<
|
|
94
|
+
<Combobox.Item key={value}>{value}</Combobox.Item>
|
|
95
95
|
))}
|
|
96
|
-
</
|
|
97
|
-
<
|
|
98
|
-
</
|
|
99
|
-
</
|
|
96
|
+
</Combobox.List>
|
|
97
|
+
<Combobox.Arrow />
|
|
98
|
+
</Combobox.Content>
|
|
99
|
+
</Combobox.Root>
|
|
100
100
|
</div>
|
|
101
101
|
);
|
|
102
102
|
};
|
|
@@ -104,14 +104,18 @@ const GridStory = ({ initialCells, ...props }: GridStoryProps) => {
|
|
|
104
104
|
const meta = {
|
|
105
105
|
title: 'ui/react-ui-grid/Grid',
|
|
106
106
|
component: GridStory,
|
|
107
|
-
decorators: [withTheme],
|
|
108
|
-
parameters: {
|
|
107
|
+
decorators: [withTheme, withLayout({ container: 'column' })],
|
|
108
|
+
parameters: {
|
|
109
|
+
layout: 'fullscreen',
|
|
110
|
+
},
|
|
109
111
|
} satisfies Meta<typeof GridStory>;
|
|
110
112
|
|
|
111
113
|
export default meta;
|
|
112
114
|
|
|
113
115
|
type Story = StoryObj<typeof meta>;
|
|
114
116
|
|
|
117
|
+
export const Default: Story = {};
|
|
118
|
+
|
|
115
119
|
export const Basic: Story = {
|
|
116
120
|
args: {
|
|
117
121
|
id: 'story',
|
|
@@ -158,26 +162,47 @@ export const Basic: Story = {
|
|
|
158
162
|
},
|
|
159
163
|
};
|
|
160
164
|
|
|
161
|
-
|
|
162
|
-
|
|
165
|
+
const cellSize = 40;
|
|
166
|
+
|
|
167
|
+
// TODO(burdon): Calendar.
|
|
168
|
+
export const Calendar: Story = {
|
|
163
169
|
args: {
|
|
164
170
|
id: 'story',
|
|
165
|
-
limitColumns:
|
|
171
|
+
limitColumns: 7,
|
|
166
172
|
columnDefault: {
|
|
167
173
|
grid: {
|
|
168
|
-
size:
|
|
174
|
+
size: cellSize,
|
|
175
|
+
resizeable: false,
|
|
169
176
|
},
|
|
170
177
|
},
|
|
171
178
|
rowDefault: {
|
|
172
179
|
grid: {
|
|
173
|
-
size:
|
|
180
|
+
size: cellSize,
|
|
174
181
|
resizeable: false,
|
|
175
182
|
},
|
|
176
183
|
},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
184
|
+
getCells: (range, plane) => {
|
|
185
|
+
const cells: DxGridPlaneCells = {};
|
|
186
|
+
if (plane === 'grid') {
|
|
187
|
+
for (let col = range.start.col; col <= range.end.col; col++) {
|
|
188
|
+
for (let row = range.start.row; row <= range.end.row; row++) {
|
|
189
|
+
// TODO(burdon): Formatting changes when cell is selected.
|
|
190
|
+
cells[toPlaneCellIndex({ col, row })] = {
|
|
191
|
+
readonly: true,
|
|
192
|
+
accessoryHtml: '<div class="flex bs-full is-full justify-center items-center overflow-hidden">0</div>',
|
|
193
|
+
className: '',
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return cells;
|
|
181
199
|
},
|
|
182
200
|
},
|
|
201
|
+
render: (args) => (
|
|
202
|
+
<div className='bs-full flex justify-center'>
|
|
203
|
+
<div className='bs-full is-[288px] border-x border-separator'>
|
|
204
|
+
<GridStory {...args} />
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
),
|
|
183
208
|
};
|
package/src/Grid/Grid.tsx
CHANGED
|
@@ -102,13 +102,13 @@ const GridRoot = ({
|
|
|
102
102
|
|
|
103
103
|
GridRoot.displayName = GRID_NAME;
|
|
104
104
|
|
|
105
|
+
const GRID_CONTENT_NAME = 'GridContent';
|
|
106
|
+
|
|
105
107
|
type GridContentProps = Omit<ComponentProps<typeof DxGrid>, 'onEdit'> & {
|
|
106
108
|
getCells?: NaturalDxGrid['getCells'];
|
|
107
109
|
activeRefs?: string;
|
|
108
110
|
};
|
|
109
111
|
|
|
110
|
-
const GRID_CONTENT_NAME = 'GridContent';
|
|
111
|
-
|
|
112
112
|
const GridContent = forwardRef<NaturalDxGrid, GridScopedProps<GridContentProps>>((props, forwardedRef) => {
|
|
113
113
|
const { id, editing, setEditBox, setEditing } = useGridContext(GRID_CONTENT_NAME, props.__gridScope);
|
|
114
114
|
const [dxGrid, setDxGridInternal] = useState<NaturalDxGrid | null>(null);
|
|
@@ -166,7 +166,7 @@ export const Grid = {
|
|
|
166
166
|
Content: GridContent,
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
export { GridRoot, GridContent,
|
|
169
|
+
export { GridRoot, GridContent, createGridScope, gridSeparatorInlineEnd, gridSeparatorBlockEnd, useGridContext };
|
|
170
170
|
|
|
171
171
|
export type { GridRootProps, GridContentProps, GridEditing, GridEditBox, GridScopedProps, DxGridElement };
|
|
172
172
|
|