@dxos/react-ui-stack 0.7.5-main.e9bb01b → 0.7.5-main.ff8607b
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 +28 -8
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +29 -8
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +28 -8
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Stack.d.ts +3 -0
- package/dist/types/src/components/Stack.d.ts.map +1 -1
- package/dist/types/src/components/StackItem.d.ts +1 -0
- package/dist/types/src/components/StackItem.d.ts.map +1 -1
- package/package.json +21 -20
- package/src/components/Stack.tsx +45 -30
- package/src/components/StackItem.tsx +25 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-stack",
|
|
3
|
-
"version": "0.7.5-main.
|
|
3
|
+
"version": "0.7.5-main.ff8607b",
|
|
4
4
|
"description": "A stack component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
|
|
39
|
+
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
39
40
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
|
|
40
41
|
"@effect/schema": "^0.75.5",
|
|
41
42
|
"@fluentui/react-tabster": "9.23.3",
|
|
@@ -46,12 +47,12 @@
|
|
|
46
47
|
"@radix-ui/react-slot": "1.1.2",
|
|
47
48
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
48
49
|
"react-resize-detector": "^11.0.1",
|
|
49
|
-
"@dxos/echo-schema": "0.7.5-main.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/react-ui-attention": "0.7.5-main.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/util": "0.7.5-main.
|
|
54
|
-
"@dxos/
|
|
50
|
+
"@dxos/echo-schema": "0.7.5-main.ff8607b",
|
|
51
|
+
"@dxos/live-object": "0.7.5-main.ff8607b",
|
|
52
|
+
"@dxos/react-ui-attention": "0.7.5-main.ff8607b",
|
|
53
|
+
"@dxos/react-ui-mosaic": "0.7.5-main.ff8607b",
|
|
54
|
+
"@dxos/util": "0.7.5-main.ff8607b",
|
|
55
|
+
"@dxos/keyboard": "0.7.5-main.ff8607b"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -60,24 +61,24 @@
|
|
|
60
61
|
"react": "~18.2.0",
|
|
61
62
|
"react-dom": "~18.2.0",
|
|
62
63
|
"vite": "5.4.7",
|
|
63
|
-
"@dxos/app-graph": "0.7.5-main.
|
|
64
|
-
"@dxos/client": "0.7.5-main.
|
|
65
|
-
"@dxos/echo-schema": "0.7.5-main.
|
|
66
|
-
"@dxos/random": "0.7.5-main.
|
|
67
|
-
"@dxos/react-ui
|
|
68
|
-
"@dxos/react-ui": "0.7.5-main.
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
64
|
+
"@dxos/app-graph": "0.7.5-main.ff8607b",
|
|
65
|
+
"@dxos/client": "0.7.5-main.ff8607b",
|
|
66
|
+
"@dxos/echo-schema": "0.7.5-main.ff8607b",
|
|
67
|
+
"@dxos/random": "0.7.5-main.ff8607b",
|
|
68
|
+
"@dxos/react-ui": "0.7.5-main.ff8607b",
|
|
69
|
+
"@dxos/react-ui-editor": "0.7.5-main.ff8607b",
|
|
70
|
+
"@dxos/storybook-utils": "0.7.5-main.ff8607b",
|
|
71
|
+
"@dxos/test-utils": "0.7.5-main.ff8607b",
|
|
72
|
+
"@dxos/react-ui-theme": "0.7.5-main.ff8607b"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
75
|
"@phosphor-icons/react": "^2.1.5",
|
|
75
76
|
"react": "~18.2.0",
|
|
76
77
|
"react-dom": "~18.2.0",
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/react-ui-theme": "0.7.5-main.
|
|
78
|
+
"@dxos/random": "0.7.5-main.ff8607b",
|
|
79
|
+
"@dxos/client": "0.7.5-main.ff8607b",
|
|
80
|
+
"@dxos/react-ui": "0.7.5-main.ff8607b",
|
|
81
|
+
"@dxos/react-ui-theme": "0.7.5-main.ff8607b"
|
|
81
82
|
},
|
|
82
83
|
"publishConfig": {
|
|
83
84
|
"access": "public"
|
package/src/components/Stack.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
//
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
|
+
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
4
5
|
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
6
|
+
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
5
7
|
import { attachClosestEdge, extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
6
8
|
import { useArrowNavigationGroup } from '@fluentui/react-tabster';
|
|
7
9
|
import { composeRefs } from '@radix-ui/react-compose-refs';
|
|
@@ -29,6 +31,8 @@ export const railGridHorizontal = 'grid-rows-[[rail-start]_var(--rail-size)_[con
|
|
|
29
31
|
|
|
30
32
|
export const railGridVertical = 'grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]';
|
|
31
33
|
|
|
34
|
+
export const autoScrollRootAttributes = { 'data-drag-autoscroll': 'idle' };
|
|
35
|
+
|
|
32
36
|
export const Stack = forwardRef<HTMLDivElement, StackProps>(
|
|
33
37
|
(
|
|
34
38
|
{
|
|
@@ -62,33 +66,36 @@ export const Stack = forwardRef<HTMLDivElement, StackProps>(
|
|
|
62
66
|
return;
|
|
63
67
|
}
|
|
64
68
|
const acceptSourceType = orientation === 'horizontal' ? 'column' : 'card';
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
69
|
+
return combine(
|
|
70
|
+
dropTargetForElements({
|
|
71
|
+
element: stackElement,
|
|
72
|
+
getData: ({ input, element }) => {
|
|
73
|
+
return attachClosestEdge(
|
|
74
|
+
{ id: props.id, type: orientation === 'horizontal' ? 'card' : 'column' },
|
|
75
|
+
{ input, element, allowedEdges: [orientation === 'horizontal' ? 'left' : 'top'] },
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
onDragEnter: ({ source }) => {
|
|
79
|
+
if (source.data.type === acceptSourceType) {
|
|
80
|
+
setDropping(true);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
onDrag: ({ source }) => {
|
|
84
|
+
if (source.data.type === acceptSourceType) {
|
|
85
|
+
setDropping(true);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
onDragLeave: () => setDropping(false),
|
|
89
|
+
onDrop: ({ self, source }) => {
|
|
90
|
+
setDropping(false);
|
|
91
|
+
if (source.data.type === acceptSourceType && selfDroppable) {
|
|
92
|
+
onRearrange(source.data as StackItemData, self.data as StackItemData, extractClosestEdge(self.data));
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
autoScrollForElements({ element: stackElement, getAllowedAxis: () => orientation }),
|
|
97
|
+
);
|
|
98
|
+
}, [stackElement, selfDroppable, orientation]);
|
|
92
99
|
|
|
93
100
|
return (
|
|
94
101
|
<StackContext.Provider value={{ orientation, rail, size, onRearrange }}>
|
|
@@ -102,20 +109,28 @@ export const Stack = forwardRef<HTMLDivElement, StackProps>(
|
|
|
102
109
|
? railGridHorizontal
|
|
103
110
|
: railGridVertical
|
|
104
111
|
: orientation === 'horizontal'
|
|
105
|
-
? 'grid-rows-1'
|
|
106
|
-
: 'grid-cols-1',
|
|
112
|
+
? 'grid-rows-1 pli-1'
|
|
113
|
+
: 'grid-cols-1 plb-1',
|
|
107
114
|
size === 'contain' &&
|
|
108
115
|
(orientation === 'horizontal'
|
|
109
116
|
? 'overflow-x-auto min-bs-0 bs-full max-bs-full'
|
|
110
117
|
: 'overflow-y-auto min-is-0 is-full max-is-full'),
|
|
111
118
|
classNames,
|
|
112
119
|
)}
|
|
120
|
+
data-rail={rail}
|
|
113
121
|
aria-orientation={orientation}
|
|
114
122
|
style={styles}
|
|
115
123
|
ref={composedItemRef}
|
|
116
124
|
>
|
|
117
125
|
{children}
|
|
118
|
-
{selfDroppable && dropping &&
|
|
126
|
+
{selfDroppable && dropping && (
|
|
127
|
+
<ListItem.DropIndicator
|
|
128
|
+
lineInset={8}
|
|
129
|
+
terminalInset={-8}
|
|
130
|
+
gap={-8}
|
|
131
|
+
edge={orientation === 'horizontal' ? 'left' : 'top'}
|
|
132
|
+
/>
|
|
133
|
+
)}
|
|
119
134
|
</div>
|
|
120
135
|
</StackContext.Provider>
|
|
121
136
|
);
|
|
@@ -47,11 +47,24 @@ export type StackItemRootProps = ThemedClassName<ComponentPropsWithRef<'div'>> &
|
|
|
47
47
|
onSizeChange?: (nextSize: StackItemSize) => void;
|
|
48
48
|
role?: 'article' | 'section';
|
|
49
49
|
disableRearrange?: boolean;
|
|
50
|
+
focusIndicatorVariant?: 'over-all' | 'group';
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
|
|
53
54
|
(
|
|
54
|
-
{
|
|
55
|
+
{
|
|
56
|
+
item,
|
|
57
|
+
children,
|
|
58
|
+
classNames,
|
|
59
|
+
size: propsSize,
|
|
60
|
+
onSizeChange,
|
|
61
|
+
role,
|
|
62
|
+
order,
|
|
63
|
+
style,
|
|
64
|
+
disableRearrange,
|
|
65
|
+
focusIndicatorVariant = 'over-all',
|
|
66
|
+
...props
|
|
67
|
+
},
|
|
55
68
|
forwardedRef,
|
|
56
69
|
) => {
|
|
57
70
|
const [itemElement, itemRef] = useState<HTMLDivElement | null>(null);
|
|
@@ -96,6 +109,10 @@ const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
|
|
|
96
109
|
},
|
|
97
110
|
onDragStart: () => {
|
|
98
111
|
document.body.removeAttribute('data-drag-preview');
|
|
112
|
+
itemElement?.closest('[data-drag-autoscroll]')?.setAttribute('data-drag-autoscroll', 'active');
|
|
113
|
+
},
|
|
114
|
+
onDrop: () => {
|
|
115
|
+
itemElement?.closest('[data-drag-autoscroll]')?.setAttribute('data-drag-autoscroll', 'idle');
|
|
99
116
|
},
|
|
100
117
|
}),
|
|
101
118
|
dropTargetForElements({
|
|
@@ -136,7 +153,12 @@ const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
|
|
|
136
153
|
tabIndex={0}
|
|
137
154
|
{...focusGroupAttrs}
|
|
138
155
|
className={mx(
|
|
139
|
-
'group/stack-item grid relative
|
|
156
|
+
'group/stack-item grid relative',
|
|
157
|
+
focusIndicatorVariant === 'over-all'
|
|
158
|
+
? 'dx-focus-ring-inset-over-all'
|
|
159
|
+
: orientation === 'horizontal'
|
|
160
|
+
? 'dx-focus-ring-group-x'
|
|
161
|
+
: 'dx-focus-ring-group-y',
|
|
140
162
|
size === 'min-content' && (orientation === 'horizontal' ? 'is-min' : 'bs-min'),
|
|
141
163
|
orientation === 'horizontal' ? 'grid-rows-subgrid' : 'grid-cols-subgrid',
|
|
142
164
|
rail && (orientation === 'horizontal' ? 'row-span-2' : 'col-span-2'),
|
|
@@ -155,7 +177,7 @@ const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
|
|
|
155
177
|
ref={composedItemRef}
|
|
156
178
|
>
|
|
157
179
|
{children}
|
|
158
|
-
{closestEdge && <ListItem.DropIndicator edge={closestEdge} />}
|
|
180
|
+
{closestEdge && <ListItem.DropIndicator lineInset={8} terminalInset={-8} edge={closestEdge} />}
|
|
159
181
|
</Root>
|
|
160
182
|
</StackItemContext.Provider>
|
|
161
183
|
);
|