@dxos/react-ui-grid 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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 +137 -159
- 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 +4 -4
- 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 +24 -20
- package/src/CellEditor/CellEditor.stories.tsx +1 -1
- package/src/CellEditor/CellEditor.tsx +8 -9
- package/src/Grid/Grid.stories.tsx +62 -27
- package/src/Grid/Grid.tsx +9 -6
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.c85a9c8dae",
|
|
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/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
+
"@dxos/lit-grid": "0.8.4-main.c85a9c8dae",
|
|
39
|
+
"@dxos/react-ui-editor": "0.8.4-main.c85a9c8dae",
|
|
40
|
+
"@dxos/ui-editor": "0.8.4-main.c85a9c8dae",
|
|
41
|
+
"@dxos/util": "0.8.4-main.c85a9c8dae"
|
|
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
|
-
"vite": "7.1.
|
|
45
|
-
"@dxos/random": "0.8.4-main.
|
|
46
|
-
"@dxos/react-ui-searchlist": "0.8.4-main.
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
44
|
+
"@types/react": "~19.2.7",
|
|
45
|
+
"@types/react-dom": "~19.2.3",
|
|
46
|
+
"react": "~19.2.3",
|
|
47
|
+
"react-dom": "~19.2.3",
|
|
48
|
+
"vite": "^7.1.11",
|
|
49
|
+
"@dxos/random": "0.8.4-main.c85a9c8dae",
|
|
50
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.c85a9c8dae",
|
|
51
|
+
"@dxos/storybook-utils": "0.8.4-main.c85a9c8dae",
|
|
52
|
+
"@dxos/ui-theme": "0.8.4-main.c85a9c8dae",
|
|
53
|
+
"@dxos/react-ui": "0.8.4-main.c85a9c8dae"
|
|
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.c85a9c8dae",
|
|
59
|
+
"@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
|
|
56
60
|
},
|
|
57
61
|
"publishConfig": {
|
|
58
62
|
"access": "public"
|
|
@@ -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 {
|
|
@@ -145,18 +144,18 @@ export const CellEditor = ({ value, extensions, box, gridId, onBlur, autoFocus,
|
|
|
145
144
|
slots: {
|
|
146
145
|
editor: {
|
|
147
146
|
className: mx(
|
|
148
|
-
'
|
|
147
|
+
'min-w-full! w-min! !max-w-(--dx-grid-cell-editor-max-w-size) min-h-full! !max-h-(--dx-grid-cell-editor-max-h-size)',
|
|
149
148
|
slots?.editor?.className,
|
|
150
149
|
),
|
|
151
150
|
},
|
|
152
151
|
scroll: {
|
|
153
152
|
className: mx(
|
|
154
|
-
'
|
|
153
|
+
'overflow-x-hidden! !py-[max(0,calc(var(--dx-grid-cell-editor-padding-block)-1px))] pe-0! !pl-(--dx-grid-cell-editor-padding-inline)',
|
|
155
154
|
slots?.scroll?.className,
|
|
156
155
|
),
|
|
157
156
|
},
|
|
158
157
|
content: {
|
|
159
|
-
className: mx('
|
|
158
|
+
className: mx('break-normal!', slots?.content?.className),
|
|
160
159
|
},
|
|
161
160
|
},
|
|
162
161
|
}),
|
|
@@ -174,7 +173,7 @@ export const CellEditor = ({ value, extensions, box, gridId, onBlur, autoFocus,
|
|
|
174
173
|
insetBlockStart: box?.insetBlockStart ?? '0px',
|
|
175
174
|
minInlineSize: box?.inlineSize ?? '180px',
|
|
176
175
|
minBlockSize: box?.blockSize ?? '30px',
|
|
177
|
-
...{ '--dx-
|
|
176
|
+
...{ '--dx-grid-cell-width': `${box?.inlineSize ?? 200}px` },
|
|
178
177
|
}}
|
|
179
178
|
{...(gridId && { 'data-grid': gridId })}
|
|
180
179
|
/>
|
|
@@ -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
|
|
|
@@ -31,7 +33,7 @@ const GridStory = ({ initialCells, ...props }: GridStoryProps) => {
|
|
|
31
33
|
// Multiselect
|
|
32
34
|
const [popoverOpen, setPopoverOpen] = useState(false);
|
|
33
35
|
const [multiSelectValue, setInternalMultiselectValue] = useState('');
|
|
34
|
-
const setMultiselectValue = useCallback<NonNullable<
|
|
36
|
+
const setMultiselectValue = useCallback<NonNullable<ComboboxRootProps['onValueChange']>>((nextValue) => {
|
|
35
37
|
setInternalMultiselectValue(nextValue);
|
|
36
38
|
setCells((cells) => {
|
|
37
39
|
// TODO(burdon): How can we get the cell address to update?
|
|
@@ -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} />
|
|
@@ -78,31 +80,41 @@ const GridStory = ({ initialCells, ...props }: GridStoryProps) => {
|
|
|
78
80
|
</DropdownMenu.Root>
|
|
79
81
|
|
|
80
82
|
{/* Multiselect */}
|
|
81
|
-
<
|
|
83
|
+
<Combobox.Root
|
|
82
84
|
open={popoverOpen}
|
|
83
85
|
onOpenChange={setPopoverOpen}
|
|
84
86
|
value={multiSelectValue}
|
|
85
87
|
onValueChange={setMultiselectValue}
|
|
86
88
|
>
|
|
87
|
-
<
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
<PopoverCombobox.List>
|
|
91
|
-
{storybookItems.map((value) => (
|
|
92
|
-
<PopoverCombobox.Item key={value}>{value}</PopoverCombobox.Item>
|
|
93
|
-
))}
|
|
94
|
-
</PopoverCombobox.List>
|
|
95
|
-
<PopoverCombobox.Arrow />
|
|
96
|
-
</PopoverCombobox.Content>
|
|
97
|
-
</PopoverCombobox.Root>
|
|
89
|
+
<Combobox.VirtualTrigger virtualRef={triggerRef} />
|
|
90
|
+
<ComboboxContentWithFiltering />
|
|
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',
|
|
@@ -141,7 +155,7 @@ export const Basic: Story = {
|
|
|
141
155
|
'1,1': {
|
|
142
156
|
value: 'Demo decoration',
|
|
143
157
|
accessoryHtml: `
|
|
144
|
-
<button class="dx-button
|
|
158
|
+
<button class="dx-button w-6 px-0.5 min-h-0 absolute inset-y-1 right-1" data-story-action="menu">
|
|
145
159
|
<svg><use href="/icons.svg#ph--arrow-right--regular"/></svg>
|
|
146
160
|
</button>
|
|
147
161
|
`,
|
|
@@ -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 h-full w-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='h-full flex justify-center'>
|
|
213
|
+
<div className='h-full w-[288px] border-x border-separator'>
|
|
214
|
+
<GridStory {...args} />
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
),
|
|
183
218
|
};
|
package/src/Grid/Grid.tsx
CHANGED
|
@@ -63,20 +63,23 @@ 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;
|
|
70
72
|
}>
|
|
71
73
|
>;
|
|
72
74
|
|
|
75
|
+
// TODO(burdon): Make headless.
|
|
73
76
|
const GridRoot = ({
|
|
77
|
+
__gridScope,
|
|
78
|
+
children,
|
|
74
79
|
id,
|
|
75
80
|
editing: propsEditing,
|
|
76
81
|
defaultEditing,
|
|
77
82
|
onEditingChange,
|
|
78
|
-
children,
|
|
79
|
-
__gridScope,
|
|
80
83
|
}: GridScopedProps<GridRootProps>) => {
|
|
81
84
|
const [editing = null, setEditing] = useControllableState({
|
|
82
85
|
prop: propsEditing,
|
|
@@ -150,12 +153,12 @@ GridContent.displayName = GRID_CONTENT_NAME;
|
|
|
150
153
|
// Fragments
|
|
151
154
|
//
|
|
152
155
|
|
|
153
|
-
// NOTE(Zan): These fragments add border to
|
|
156
|
+
// NOTE(Zan): These fragments add border to w-end and h-end of the grid using pseudo-elements.
|
|
154
157
|
// These are offset by 1px to avoid double borders in planks.
|
|
155
158
|
const gridSeparatorInlineEnd =
|
|
156
|
-
'[&>.dx-grid]:relative [&>.dx-grid]:after:absolute [&>.dx-grid]:after:inset-
|
|
159
|
+
'[&>.dx-grid]:relative [&>.dx-grid]:after:absolute [&>.dx-grid]:after:inset-y-0 [&>.dx-grid]:after:-right-px [&>.dx-grid]:after:w-px [&>.dx-grid]:after:bg-subdued-separator';
|
|
157
160
|
const gridSeparatorBlockEnd =
|
|
158
|
-
'[&>.dx-grid]:relative [&>.dx-grid]:before:absolute [&>.dx-grid]:before:inset-
|
|
161
|
+
'[&>.dx-grid]:relative [&>.dx-grid]:before:absolute [&>.dx-grid]:before:inset-x-0 [&>.dx-grid]:before:-bottom-px [&>.dx-grid]:before:h-px [&>.dx-grid]:before:bg-subdued-separator';
|
|
159
162
|
|
|
160
163
|
//
|
|
161
164
|
// Exports
|