@dxos/react-ui-stack 0.8.4-main.e8ec1fe → 0.8.4-main.ef1bc66f44
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 +920 -57
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +921 -57
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/{exemplars → components}/CardStack/CardStack.d.ts +18 -13
- package/dist/types/src/components/CardStack/CardStack.d.ts.map +1 -0
- package/dist/types/src/components/CardStack/CardStack.stories.d.ts.map +1 -0
- package/dist/types/src/{exemplars → components}/CardStack/CardStackDragPreview.d.ts +4 -1
- package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts.map +1 -0
- package/dist/types/src/components/CardStack/index.d.ts.map +1 -0
- package/dist/types/src/components/Stack/Stack.d.ts +1 -1
- package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
- package/dist/types/src/components/StackContext.d.ts +1 -1
- package/dist/types/src/components/StackContext.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItem.d.ts +5 -9
- package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemContent.d.ts +2 -45
- package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
- package/dist/types/src/components/StackItem/StackItemSigil.d.ts +2 -2
- package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/LayoutControls.d.ts +3 -0
- package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/{defs.d.ts → types.d.ts} +1 -1
- package/dist/types/src/components/types.d.ts.map +1 -0
- package/dist/types/src/hooks/useStackDropForElements.d.ts +7 -5
- package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -37
- package/src/{exemplars → components}/CardStack/CardStack.stories.tsx +10 -10
- package/src/{exemplars → components}/CardStack/CardStack.tsx +113 -57
- package/src/{exemplars → components}/CardStack/CardStackDragPreview.tsx +12 -9
- package/src/components/Stack/Stack.stories.tsx +2 -2
- package/src/components/Stack/Stack.tsx +5 -3
- package/src/components/StackContext.tsx +1 -1
- package/src/components/StackItem/StackItem.stories.tsx +5 -3
- package/src/components/StackItem/StackItem.tsx +24 -12
- package/src/components/StackItem/StackItemContent.tsx +19 -50
- package/src/components/StackItem/StackItemHeading.tsx +1 -1
- package/src/components/StackItem/StackItemSigil.tsx +3 -3
- package/src/components/deprecated/LayoutControls.tsx +3 -0
- package/src/components/index.ts +2 -2
- package/src/hooks/useStackDropForElements.ts +17 -10
- package/src/index.ts +0 -3
- package/src/playwright/playwright.config.ts +1 -1
- package/src/translations.ts +1 -1
- package/dist/lib/browser/chunk-3F2KBXLP.mjs +0 -1482
- package/dist/lib/browser/chunk-3F2KBXLP.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -31
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SYKFLQGK.mjs +0 -1484
- package/dist/lib/node-esm/chunk-SYKFLQGK.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -32
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/components/Image/Image.d.ts +0 -14
- package/dist/types/src/components/Image/Image.d.ts.map +0 -1
- package/dist/types/src/components/Image/Image.stories.d.ts +0 -33
- package/dist/types/src/components/Image/Image.stories.d.ts.map +0 -1
- package/dist/types/src/components/Image/index.d.ts +0 -2
- package/dist/types/src/components/Image/index.d.ts.map +0 -1
- package/dist/types/src/components/defs.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/Card.d.ts +0 -69
- package/dist/types/src/exemplars/Card/Card.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/Card.stories.d.ts +0 -21
- package/dist/types/src/exemplars/Card/Card.stories.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/CardDragPreview.d.ts +0 -6
- package/dist/types/src/exemplars/Card/CardDragPreview.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/fragments.d.ts +0 -13
- package/dist/types/src/exemplars/Card/fragments.d.ts.map +0 -1
- package/dist/types/src/exemplars/Card/index.d.ts +0 -4
- package/dist/types/src/exemplars/Card/index.d.ts.map +0 -1
- package/dist/types/src/exemplars/CardStack/CardStack.d.ts.map +0 -1
- package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts.map +0 -1
- package/dist/types/src/exemplars/CardStack/CardStackDragPreview.d.ts.map +0 -1
- package/dist/types/src/exemplars/CardStack/index.d.ts.map +0 -1
- package/dist/types/src/exemplars/index.d.ts +0 -3
- package/dist/types/src/exemplars/index.d.ts.map +0 -1
- package/dist/types/src/testing/CardContainer.d.ts +0 -6
- package/dist/types/src/testing/CardContainer.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/src/components/Image/Image.stories.tsx +0 -84
- package/src/components/Image/Image.tsx +0 -222
- package/src/components/Image/index.ts +0 -5
- package/src/exemplars/Card/Card.stories.tsx +0 -64
- package/src/exemplars/Card/Card.tsx +0 -210
- package/src/exemplars/Card/CardDragPreview.tsx +0 -22
- package/src/exemplars/Card/fragments.ts +0 -24
- package/src/exemplars/Card/index.ts +0 -7
- package/src/exemplars/index.ts +0 -6
- package/src/testing/CardContainer.tsx +0 -37
- package/src/testing/index.ts +0 -5
- /package/dist/types/src/{exemplars → components}/CardStack/CardStack.stories.d.ts +0 -0
- /package/dist/types/src/{exemplars → components}/CardStack/index.d.ts +0 -0
- /package/src/{exemplars → components}/CardStack/index.ts +0 -0
- /package/src/components/{defs.ts → types.ts} +0 -0
|
@@ -26,10 +26,10 @@ import { createPortal } from 'react-dom';
|
|
|
26
26
|
|
|
27
27
|
import { ListItem, type ThemedClassName } from '@dxos/react-ui';
|
|
28
28
|
import { resizeAttributes, sizeStyle } from '@dxos/react-ui-dnd';
|
|
29
|
-
import { mx } from '@dxos/
|
|
29
|
+
import { mx } from '@dxos/ui-theme';
|
|
30
30
|
|
|
31
|
-
import { type StackItemData, type StackItemSize } from '../defs';
|
|
32
31
|
import { type ItemDragState, StackItemContext, idle, useStack, useStackItem } from '../StackContext';
|
|
32
|
+
import { type StackItemData, type StackItemSize } from '../types';
|
|
33
33
|
|
|
34
34
|
import { StackItemContent, type StackItemContentProps } from './StackItemContent';
|
|
35
35
|
import { StackItemDragHandle, type StackItemDragHandleProps } from './StackItemDragHandle';
|
|
@@ -54,6 +54,10 @@ export const DEFAULT_HORIZONTAL_SIZE = 48 satisfies StackItemSize;
|
|
|
54
54
|
export const DEFAULT_VERTICAL_SIZE = 'min-content' satisfies StackItemSize;
|
|
55
55
|
export const DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE satisfies StackItemSize;
|
|
56
56
|
|
|
57
|
+
//
|
|
58
|
+
// StackItemRoot
|
|
59
|
+
//
|
|
60
|
+
|
|
57
61
|
type StackItemRootProps = ThemedClassName<ComponentPropsWithRef<'div'>> & {
|
|
58
62
|
item: Omit<StackItemData, 'type'>;
|
|
59
63
|
order?: number;
|
|
@@ -86,6 +90,7 @@ const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
|
|
|
86
90
|
forwardedRef,
|
|
87
91
|
) => {
|
|
88
92
|
const [itemElement, itemRef] = useState<HTMLDivElement | null>(null);
|
|
93
|
+
const composedItemRef = composeRefs<HTMLDivElement>(itemRef, forwardedRef);
|
|
89
94
|
const [selfDragHandleElement, selfDragHandleRef] = useState<HTMLDivElement | null>(null);
|
|
90
95
|
const [closestEdge, setEdge] = useState<Edge | null>(null);
|
|
91
96
|
const [sourceId, setSourceId] = useState<string | null>(null);
|
|
@@ -96,8 +101,6 @@ const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
|
|
|
96
101
|
|
|
97
102
|
const Root = role ?? 'div';
|
|
98
103
|
|
|
99
|
-
const composedItemRef = composeRefs<HTMLDivElement>(itemRef, forwardedRef);
|
|
100
|
-
|
|
101
104
|
const setSize = useCallback(
|
|
102
105
|
(nextSize: StackItemSize, commit?: boolean) => {
|
|
103
106
|
setInternalSize(nextSize);
|
|
@@ -110,6 +113,7 @@ const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
|
|
|
110
113
|
|
|
111
114
|
const type = orientation === 'horizontal' ? 'column' : 'card';
|
|
112
115
|
|
|
116
|
+
// TODO(burdon): Factor out?
|
|
113
117
|
useLayoutEffect(() => {
|
|
114
118
|
if (!itemElement || !onRearrange || disableRearrange) {
|
|
115
119
|
return;
|
|
@@ -183,18 +187,18 @@ const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
|
|
|
183
187
|
|
|
184
188
|
const focusableGroupAttrs = useFocusableGroup({ tabBehavior: 'limited' });
|
|
185
189
|
|
|
186
|
-
// Determine if the drop would result in any changes
|
|
190
|
+
// Determine if the drop would result in any changes.
|
|
187
191
|
const shouldShowDropIndicator = () => {
|
|
188
192
|
if (!closestEdge || !sourceId) {
|
|
189
193
|
return false;
|
|
190
194
|
}
|
|
191
195
|
|
|
192
|
-
// Don't show indicator when dragged item is over itself
|
|
196
|
+
// Don't show indicator when dragged item is over itself.
|
|
193
197
|
if (sourceId === item.id) {
|
|
194
198
|
return false;
|
|
195
199
|
}
|
|
196
200
|
|
|
197
|
-
// Don't show indicator when dragged item is over the trailing edge of its previous sibling
|
|
201
|
+
// Don't show indicator when dragged item is over the trailing edge of its previous sibling.
|
|
198
202
|
const isTrailingEdgeOfPrevSibling =
|
|
199
203
|
prevSiblingId !== undefined &&
|
|
200
204
|
sourceId === prevSiblingId &&
|
|
@@ -268,37 +272,45 @@ const StackItemRoot = forwardRef<HTMLDivElement, StackItemRootProps>(
|
|
|
268
272
|
},
|
|
269
273
|
);
|
|
270
274
|
|
|
275
|
+
//
|
|
276
|
+
// StackItemDragPreview
|
|
277
|
+
//
|
|
278
|
+
|
|
271
279
|
type StackItemDragPreviewProps = {
|
|
272
280
|
children: ({ item }: { item: any }) => ReactNode;
|
|
273
281
|
};
|
|
274
282
|
|
|
275
|
-
|
|
283
|
+
const StackItemDragPreview = ({ children }: StackItemDragPreviewProps) => {
|
|
276
284
|
const { state } = useStackItem();
|
|
277
285
|
return state?.type === 'preview' ? createPortal(children({ item: state.item }), state.container) : null;
|
|
278
286
|
};
|
|
279
287
|
|
|
288
|
+
//
|
|
289
|
+
// StackItem
|
|
290
|
+
//
|
|
291
|
+
|
|
280
292
|
export const StackItem = {
|
|
281
293
|
Root: StackItemRoot,
|
|
282
294
|
Content: StackItemContent,
|
|
295
|
+
DragHandle: StackItemDragHandle,
|
|
296
|
+
DragPreview: StackItemDragPreview,
|
|
283
297
|
Heading: StackItemHeading,
|
|
284
298
|
HeadingLabel: StackItemHeadingLabel,
|
|
285
299
|
HeadingStickyContent: StackItemHeadingStickyContent,
|
|
286
300
|
ResizeHandle: StackItemResizeHandle,
|
|
287
|
-
DragHandle: StackItemDragHandle,
|
|
288
301
|
Sigil: StackItemSigil,
|
|
289
302
|
SigilButton: StackItemSigilButton,
|
|
290
|
-
DragPreview: StackItemDragPreview,
|
|
291
303
|
};
|
|
292
304
|
|
|
293
305
|
export type {
|
|
294
306
|
StackItemRootProps,
|
|
295
307
|
StackItemContentProps,
|
|
308
|
+
StackItemDragHandleProps,
|
|
309
|
+
StackItemDragPreviewProps,
|
|
296
310
|
StackItemHeadingProps,
|
|
297
311
|
StackItemHeadingLabelProps,
|
|
298
312
|
StackItemResizeHandleProps,
|
|
299
|
-
StackItemDragHandleProps,
|
|
300
313
|
StackItemSigilProps,
|
|
301
314
|
StackItemSigilButtonProps,
|
|
302
315
|
StackItemSigilAction,
|
|
303
|
-
StackItemDragPreviewProps,
|
|
304
316
|
};
|
|
@@ -5,82 +5,49 @@
|
|
|
5
5
|
import React, { type ComponentPropsWithoutRef, forwardRef, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
-
import { mx } from '@dxos/
|
|
8
|
+
import { mx } from '@dxos/ui-theme';
|
|
9
9
|
|
|
10
10
|
import { useStack, useStackItem } from '../StackContext';
|
|
11
11
|
|
|
12
|
-
// TODO(burdon): Add prop for container-max-width?
|
|
13
12
|
export type StackItemContentProps = ThemedClassName<Omit<ComponentPropsWithoutRef<'div'>, 'role' | 'scrollable'>> & {
|
|
14
|
-
/**
|
|
15
|
-
* This flag is required in order to clarify a developer experience that seemed like it needed extra boilerplate
|
|
16
|
-
* (`row-span-2`) or was buggy. See the description of the StackItem.Content component itself for more information.
|
|
17
|
-
*/
|
|
18
13
|
toolbar?: boolean;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Whether to provide for the layout of a statusbar after the content.
|
|
22
|
-
*/
|
|
23
14
|
statusbar?: boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Whether to support y-axis scrolling.
|
|
27
|
-
*/
|
|
28
|
-
scrollable?: boolean;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Whether to set a certain aspect ratio on the content, including the toolbar and statusbar.
|
|
32
|
-
* This is provided for convenience and consistency; it can instead be specified by the `classNames` or `style` props as needed.
|
|
33
|
-
*/
|
|
34
|
-
size?: 'intrinsic' | 'video' | 'square';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Whether the consumer intends to do something custom and typical affordances should not apply.
|
|
38
|
-
* @deprecated Replace with override for gridTempateRows.
|
|
39
|
-
*/
|
|
40
|
-
layoutManaged?: boolean;
|
|
41
15
|
};
|
|
42
16
|
|
|
43
17
|
/**
|
|
44
|
-
* This component should be used by plugins for rendering content within a stack item
|
|
45
|
-
* The `toolbar` flag must be provided since this component provides for the layout of content with the toolbar.
|
|
18
|
+
* This component should be used by plugins for rendering content within a stack item (i.e., a “plank” or “section”).
|
|
46
19
|
*/
|
|
47
20
|
export const StackItemContent = forwardRef<HTMLDivElement, StackItemContentProps>(
|
|
48
|
-
(
|
|
49
|
-
{ children, toolbar, statusbar, layoutManaged, classNames, size = 'intrinsic', scrollable, ...props },
|
|
50
|
-
forwardedRef,
|
|
51
|
-
) => {
|
|
21
|
+
({ classNames, children, toolbar, statusbar, ...props }, forwardedRef) => {
|
|
52
22
|
const { size: stackItemSize } = useStack();
|
|
53
23
|
const { role } = useStackItem();
|
|
54
24
|
const style = useMemo(
|
|
55
|
-
() =>
|
|
56
|
-
|
|
57
|
-
?
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
[toolbar, statusbar, layoutManaged],
|
|
25
|
+
() => ({
|
|
26
|
+
gridTemplateRows: [
|
|
27
|
+
toolbar && role === 'section' ? 'calc(var(--toolbar-size) - 1px)' : 'var(--toolbar-size)',
|
|
28
|
+
'1fr',
|
|
29
|
+
statusbar && 'var(--statusbar-size)',
|
|
30
|
+
]
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.join(' '),
|
|
33
|
+
}),
|
|
34
|
+
[toolbar, statusbar],
|
|
66
35
|
);
|
|
67
36
|
|
|
68
37
|
return (
|
|
69
38
|
<div
|
|
70
|
-
role='none'
|
|
71
39
|
{...props}
|
|
40
|
+
role='none'
|
|
41
|
+
style={style}
|
|
72
42
|
className={mx(
|
|
73
43
|
'group grid grid-cols-[100%] density-coarse',
|
|
74
|
-
size === 'video' ? 'aspect-video' : size === 'square' && 'aspect-square',
|
|
75
44
|
stackItemSize === 'contain' && 'min-bs-0 overflow-hidden',
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
toolbar &&
|
|
45
|
+
toolbar &&
|
|
46
|
+
role === 'section' &&
|
|
79
47
|
'[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:block-start-0 [&_.dx-toolbar]:-mbe-px [&_.dx-toolbar]:min-is-0',
|
|
80
48
|
toolbar && '[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-be [&>.dx-toolbar]:border-subduedSeparator',
|
|
81
49
|
classNames,
|
|
82
50
|
)}
|
|
83
|
-
style={style}
|
|
84
51
|
data-popover-collision-boundary={true}
|
|
85
52
|
ref={forwardedRef}
|
|
86
53
|
>
|
|
@@ -89,3 +56,5 @@ export const StackItemContent = forwardRef<HTMLDivElement, StackItemContentProps
|
|
|
89
56
|
);
|
|
90
57
|
},
|
|
91
58
|
);
|
|
59
|
+
|
|
60
|
+
StackItemContent.displayName = 'StackItemContent';
|
|
@@ -12,7 +12,7 @@ import React, {
|
|
|
12
12
|
|
|
13
13
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
14
14
|
import { type AttendableId, type Related, useAttention } from '@dxos/react-ui-attention';
|
|
15
|
-
import { mx } from '@dxos/
|
|
15
|
+
import { mx } from '@dxos/ui-theme';
|
|
16
16
|
|
|
17
17
|
import { useStack } from '../StackContext';
|
|
18
18
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { Fragment, type PropsWithChildren, forwardRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
8
|
import { keySymbols } from '@dxos/keyboard';
|
|
9
9
|
import { Button, type ButtonProps, DropdownMenu, Icon, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { type AttendableId, type Related, useAttention } from '@dxos/react-ui-attention';
|
|
11
|
-
import { descriptionText, mx } from '@dxos/
|
|
11
|
+
import { descriptionText, mx } from '@dxos/ui-theme';
|
|
12
12
|
import { getHostPlatform } from '@dxos/util';
|
|
13
13
|
|
|
14
14
|
import { translationKey } from '../../translations';
|
|
@@ -23,7 +23,7 @@ export type KeyBinding = {
|
|
|
23
23
|
unknown?: string;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export type StackItemSigilAction = Pick<ActionLike, 'id' | 'properties' | 'data'>;
|
|
26
|
+
export type StackItemSigilAction = Pick<Node.ActionLike, 'id' | 'properties' | 'data'>;
|
|
27
27
|
|
|
28
28
|
export type StackItemSigilButtonProps = Omit<ButtonProps, 'variant'> &
|
|
29
29
|
AttendableId &
|
|
@@ -30,6 +30,9 @@ const LayoutControl = ({ icon, label, ...props }: Omit<ButtonProps, 'children'>
|
|
|
30
30
|
return <IconButton iconOnly icon={icon} label={label} tooltipSide='bottom' variant='ghost' {...props} />;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated
|
|
35
|
+
*/
|
|
33
36
|
export const LayoutControls = forwardRef<HTMLDivElement, LayoutControlsProps>(
|
|
34
37
|
(
|
|
35
38
|
{ onClick, variant = 'default', capabilities: can, isSolo, pin, close = false, children, ...props },
|
package/src/components/index.ts
CHANGED
|
@@ -12,8 +12,21 @@ import { type Orientation, type StackItemData, type StackItemRearrangeHandler }
|
|
|
12
12
|
|
|
13
13
|
const noop = () => {};
|
|
14
14
|
|
|
15
|
+
export type UseStackDropForElementsProps = {
|
|
16
|
+
id?: string;
|
|
17
|
+
element: HTMLDivElement | null;
|
|
18
|
+
scrollElement?: HTMLDivElement | null;
|
|
19
|
+
orientation: Orientation;
|
|
20
|
+
selfDroppable: boolean;
|
|
21
|
+
onRearrange?: StackItemRearrangeHandler;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type UseStackDropForElements = {
|
|
25
|
+
dropping: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
15
28
|
/**
|
|
16
|
-
* Hook to handle drag
|
|
29
|
+
* Hook to handle drag-and-drop functionality for Stack components.
|
|
17
30
|
*/
|
|
18
31
|
export const useStackDropForElements = ({
|
|
19
32
|
id,
|
|
@@ -22,14 +35,7 @@ export const useStackDropForElements = ({
|
|
|
22
35
|
orientation,
|
|
23
36
|
selfDroppable,
|
|
24
37
|
onRearrange,
|
|
25
|
-
}: {
|
|
26
|
-
id?: string;
|
|
27
|
-
element: HTMLDivElement | null;
|
|
28
|
-
scrollElement?: HTMLDivElement | null;
|
|
29
|
-
orientation: Orientation;
|
|
30
|
-
selfDroppable: boolean;
|
|
31
|
-
onRearrange?: StackItemRearrangeHandler;
|
|
32
|
-
}) => {
|
|
38
|
+
}: UseStackDropForElementsProps): UseStackDropForElements => {
|
|
33
39
|
const [dropping, setDropping] = useState(false);
|
|
34
40
|
|
|
35
41
|
useLayoutEffect(() => {
|
|
@@ -39,6 +45,7 @@ export const useStackDropForElements = ({
|
|
|
39
45
|
|
|
40
46
|
const acceptSourceType = orientation === 'horizontal' ? 'column' : 'card';
|
|
41
47
|
|
|
48
|
+
// TODO(burdon): Use monitor?
|
|
42
49
|
return combine(
|
|
43
50
|
selfDroppable
|
|
44
51
|
? dropTargetForElements({
|
|
@@ -78,7 +85,7 @@ export const useStackDropForElements = ({
|
|
|
78
85
|
})
|
|
79
86
|
: noop,
|
|
80
87
|
);
|
|
81
|
-
}, [element, scrollElement, selfDroppable, orientation,
|
|
88
|
+
}, [id, element, scrollElement, selfDroppable, orientation, onRearrange]);
|
|
82
89
|
|
|
83
90
|
return { dropping };
|
|
84
91
|
};
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export default defineConfig({
|
|
|
10
10
|
...e2ePreset(import.meta.dirname),
|
|
11
11
|
// TODO(wittjosiah): Avoid hard-coding ports.
|
|
12
12
|
webServer: {
|
|
13
|
-
command: 'moon run storybook:serve-e2e -- --port=9003',
|
|
13
|
+
command: 'moon run storybook-react:serve-e2e -- --port=9003',
|
|
14
14
|
port: 9003,
|
|
15
15
|
reuseExistingServer: false,
|
|
16
16
|
},
|