@dxos/react-ui-mosaic 0.8.4-main.bc674ce → 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/chunk-7S4PIFKU.mjs +953 -0
- package/dist/lib/browser/chunk-7S4PIFKU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +596 -70
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/playwright/index.mjs +138 -0
- package/dist/lib/browser/playwright/index.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +61 -232
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-MK6KU66S.mjs +955 -0
- package/dist/lib/node-esm/chunk-MK6KU66S.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +596 -70
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/playwright/index.mjs +140 -0
- package/dist/lib/node-esm/playwright/index.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +61 -232
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/components/Board/Board.d.ts +81 -0
- package/dist/types/src/components/Board/Board.d.ts.map +1 -0
- package/dist/types/src/components/{Mosaic/Mosaic.stories.d.ts → Board/Board.stories.d.ts} +15 -1
- package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -0
- package/dist/types/src/components/Board/Column.d.ts +40 -0
- package/dist/types/src/components/Board/Column.d.ts.map +1 -0
- package/dist/types/src/components/Board/Item.d.ts +9 -0
- package/dist/types/src/components/Board/Item.d.ts.map +1 -0
- package/dist/types/src/components/Board/index.d.ts +2 -0
- package/dist/types/src/components/Board/index.d.ts.map +1 -0
- package/dist/types/src/components/Focus/Focus.d.ts +5 -4
- package/dist/types/src/components/Focus/Focus.d.ts.map +1 -1
- package/dist/types/src/components/Focus/index.d.ts +0 -1
- package/dist/types/src/components/Focus/index.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Container.d.ts +42 -0
- package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Mosaic.d.ts +35 -118
- package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Placeholder.d.ts +21 -0
- package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Root.d.ts +36 -0
- package/dist/types/src/components/Mosaic/Root.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Stack.d.ts +23 -0
- package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -0
- package/dist/types/src/components/{Stack → Mosaic}/Stack.stories.d.ts +2 -2
- package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Tile.d.ts +48 -0
- package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/styles.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/types.d.ts +9 -2
- package/dist/types/src/components/Mosaic/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts +15 -0
- package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useEventHandlerAdapter.d.ts +1 -1
- package/dist/types/src/hooks/useEventHandlerAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useVisibleItems.d.ts +2 -2
- package/dist/types/src/hooks/useVisibleItems.d.ts.map +1 -1
- package/dist/types/src/playwright/board-manager.d.ts +45 -0
- package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/index.d.ts +9 -0
- package/dist/types/src/playwright/index.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
- package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
- package/dist/types/src/testing/CardContainer.d.ts +5 -4
- package/dist/types/src/testing/CardContainer.d.ts.map +1 -1
- package/dist/types/src/testing/DefaultStackTile.d.ts +2 -2
- package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/types.d.ts +21 -0
- package/dist/types/src/testing/types.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +5 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +43 -28
- package/src/components/Board/Board.stories.tsx +273 -0
- package/src/components/Board/Board.tsx +191 -0
- package/src/components/Board/Column.tsx +300 -0
- package/src/components/Board/Item.tsx +116 -0
- package/src/components/{Layout → Board}/index.ts +1 -1
- package/src/components/Focus/Focus.tsx +26 -17
- package/src/components/Focus/index.ts +0 -2
- package/src/components/Mosaic/Container.tsx +289 -0
- package/src/components/Mosaic/Mosaic.tsx +35 -913
- package/src/components/Mosaic/Placeholder.tsx +133 -0
- package/src/components/Mosaic/Root.tsx +292 -0
- package/src/components/{Stack → Mosaic}/Stack.stories.tsx +30 -26
- package/src/components/Mosaic/Stack.tsx +246 -0
- package/src/components/Mosaic/Tile.tsx +242 -0
- package/src/components/Mosaic/extension.ts +1 -1
- package/src/components/Mosaic/styles.ts +9 -8
- package/src/components/Mosaic/types.ts +15 -3
- package/src/components/index.ts +1 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useContainerDebug.tsx +4 -2
- package/src/hooks/useDefaultColumnEventHandler.ts +35 -0
- package/src/hooks/useEventHandlerAdapter.ts +15 -6
- package/src/hooks/useVisibleItems.ts +7 -2
- package/src/playwright/board-manager.ts +154 -0
- package/src/playwright/index.ts +13 -0
- package/src/playwright/playwright.config.ts +17 -0
- package/src/playwright/smoke.spec.ts +138 -0
- package/src/testing/CardContainer.tsx +30 -18
- package/src/testing/DefaultStackTile.tsx +27 -16
- package/src/testing/index.ts +1 -1
- package/src/testing/types.ts +38 -0
- package/src/translations.ts +5 -1
- package/dist/lib/browser/chunk-UMBPEG4F.mjs +0 -1637
- package/dist/lib/browser/chunk-UMBPEG4F.mjs.map +0 -7
- package/dist/lib/browser/index.css +0 -13
- package/dist/lib/browser/index.css.map +0 -7
- package/dist/lib/browser/testing/index.css +0 -13
- package/dist/lib/browser/testing/index.css.map +0 -7
- package/dist/lib/node-esm/chunk-X6GV7SMK.mjs +0 -1639
- package/dist/lib/node-esm/chunk-X6GV7SMK.mjs.map +0 -7
- package/dist/lib/node-esm/index.css +0 -13
- package/dist/lib/node-esm/index.css.map +0 -7
- package/dist/lib/node-esm/testing/index.css +0 -13
- package/dist/lib/node-esm/testing/index.css.map +0 -7
- package/dist/types/src/components/Card/Card.d.ts +0 -121
- package/dist/types/src/components/Card/Card.d.ts.map +0 -1
- package/dist/types/src/components/Card/Card.stories.d.ts +0 -21
- package/dist/types/src/components/Card/Card.stories.d.ts.map +0 -1
- package/dist/types/src/components/Card/CardDragPreview.d.ts +0 -6
- package/dist/types/src/components/Card/CardDragPreview.d.ts.map +0 -1
- package/dist/types/src/components/Card/index.d.ts +0 -4
- package/dist/types/src/components/Card/index.d.ts.map +0 -1
- package/dist/types/src/components/Card/styles.d.ts +0 -13
- package/dist/types/src/components/Card/styles.d.ts.map +0 -1
- package/dist/types/src/components/Focus/styles.d.ts +0 -6
- package/dist/types/src/components/Focus/styles.d.ts.map +0 -1
- 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/Layout/Layout.d.ts +0 -33
- package/dist/types/src/components/Layout/Layout.d.ts.map +0 -1
- package/dist/types/src/components/Layout/Layout.stories.d.ts +0 -10
- package/dist/types/src/components/Layout/Layout.stories.d.ts.map +0 -1
- package/dist/types/src/components/Layout/index.d.ts +0 -2
- package/dist/types/src/components/Layout/index.d.ts.map +0 -1
- package/dist/types/src/components/Mosaic/Mosaic.stories.d.ts.map +0 -1
- package/dist/types/src/components/Scrollable/Scrollable.d.ts +0 -24
- package/dist/types/src/components/Scrollable/Scrollable.d.ts.map +0 -1
- package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts +0 -10
- package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts.map +0 -1
- package/dist/types/src/components/Scrollable/index.d.ts +0 -2
- package/dist/types/src/components/Scrollable/index.d.ts.map +0 -1
- package/dist/types/src/components/Stack/Stack.d.ts +0 -22
- package/dist/types/src/components/Stack/Stack.d.ts.map +0 -1
- package/dist/types/src/components/Stack/Stack.stories.d.ts.map +0 -1
- package/dist/types/src/components/Stack/index.d.ts +0 -2
- package/dist/types/src/components/Stack/index.d.ts.map +0 -1
- package/dist/types/src/testing/Board.d.ts +0 -45
- package/dist/types/src/testing/Board.d.ts.map +0 -1
- package/dist/types/src/testing/Slot.stories.d.ts +0 -14
- package/dist/types/src/testing/Slot.stories.d.ts.map +0 -1
- package/dist/types/src/testing/Virtualizer.stories.d.ts +0 -12
- package/dist/types/src/testing/Virtualizer.stories.d.ts.map +0 -1
- package/src/components/Card/Card.stories.tsx +0 -148
- package/src/components/Card/Card.tsx +0 -458
- package/src/components/Card/CardDragPreview.tsx +0 -23
- package/src/components/Card/index.ts +0 -8
- package/src/components/Card/styles.ts +0 -23
- package/src/components/Focus/styles.ts +0 -24
- package/src/components/Image/Image.stories.tsx +0 -86
- package/src/components/Image/Image.tsx +0 -223
- package/src/components/Image/index.ts +0 -5
- package/src/components/Layout/Layout.stories.tsx +0 -59
- package/src/components/Layout/Layout.tsx +0 -108
- package/src/components/Mosaic/Mosaic.stories.tsx +0 -113
- package/src/components/Scrollable/Scrollable.stories.tsx +0 -59
- package/src/components/Scrollable/Scrollable.tsx +0 -88
- package/src/components/Scrollable/index.ts +0 -5
- package/src/components/Scrollable/scrollable.css +0 -20
- package/src/components/Stack/Stack.tsx +0 -210
- package/src/components/Stack/index.ts +0 -5
- package/src/testing/Board.tsx +0 -278
- package/src/testing/Slot.stories.tsx +0 -101
- package/src/testing/Virtualizer.stories.tsx +0 -133
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
6
|
+
import { dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
7
|
+
import { autoScrollForElements } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
|
|
8
|
+
import { useComposedRefs } from '@radix-ui/react-compose-refs';
|
|
9
|
+
import { createContext } from '@radix-ui/react-context';
|
|
10
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
11
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
12
|
+
import { bind } from 'bind-event-listener';
|
|
13
|
+
import React, {
|
|
14
|
+
type CSSProperties,
|
|
15
|
+
type PropsWithChildren,
|
|
16
|
+
type ReactNode,
|
|
17
|
+
forwardRef,
|
|
18
|
+
useEffect,
|
|
19
|
+
useMemo,
|
|
20
|
+
useRef,
|
|
21
|
+
useState,
|
|
22
|
+
} from 'react';
|
|
23
|
+
|
|
24
|
+
import { type AllowedAxis, type ComposableProps } from '@dxos/react-ui';
|
|
25
|
+
import { mx } from '@dxos/ui-theme';
|
|
26
|
+
import { isTruthy } from '@dxos/util';
|
|
27
|
+
|
|
28
|
+
import { useFocus } from '../Focus';
|
|
29
|
+
|
|
30
|
+
import { type MosaicDraggingState, useMosaicRootContext } from './Root';
|
|
31
|
+
import {
|
|
32
|
+
type LocationType,
|
|
33
|
+
type MosaicContainerData,
|
|
34
|
+
type MosaicEventHandler,
|
|
35
|
+
type MosaicTileData,
|
|
36
|
+
getSourceData,
|
|
37
|
+
} from './types';
|
|
38
|
+
|
|
39
|
+
//
|
|
40
|
+
// Container
|
|
41
|
+
//
|
|
42
|
+
|
|
43
|
+
const MOSAIC_CONTAINER_NAME = 'Mosaic.Container';
|
|
44
|
+
|
|
45
|
+
type MosaicContainerState = { type: 'idle' } | { type: 'active'; bounds?: DOMRect };
|
|
46
|
+
|
|
47
|
+
type MosaicContainerContextValue<TData = any, Location = LocationType> = {
|
|
48
|
+
id: string;
|
|
49
|
+
eventHandler: MosaicEventHandler<TData>;
|
|
50
|
+
orientation?: AllowedAxis;
|
|
51
|
+
dragging?: MosaicDraggingState;
|
|
52
|
+
scrolling?: boolean;
|
|
53
|
+
state: MosaicContainerState;
|
|
54
|
+
|
|
55
|
+
/** Active drop location. */
|
|
56
|
+
activeLocation?: Location;
|
|
57
|
+
setActiveLocation: (location: Location | undefined) => void;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const [MosaicContainerContextProvider, useMosaicContainerContext] =
|
|
61
|
+
createContext<MosaicContainerContextValue>('MosaicContainer');
|
|
62
|
+
|
|
63
|
+
// State attribute: [&:has(>_[data-mosaic-container-state=active])]
|
|
64
|
+
const MOSAIC_CONTAINER_STATE_ATTR = 'mosaic-container-state';
|
|
65
|
+
|
|
66
|
+
// CSS variables: [var(--mosaic-placeholder-xxx)]
|
|
67
|
+
const MOSAIC_CONTAINER_PLACEHOLDER_WIDTH = '--mosaic-placeholder-width';
|
|
68
|
+
const MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT = '--mosaic-placeholder-height';
|
|
69
|
+
|
|
70
|
+
let counter = 0;
|
|
71
|
+
|
|
72
|
+
type MosaicContainerProps = ComposableProps<
|
|
73
|
+
PropsWithChildren<
|
|
74
|
+
Partial<Pick<MosaicContainerContextValue, 'eventHandler' | 'orientation'>> & {
|
|
75
|
+
asChild?: boolean;
|
|
76
|
+
autoScroll?: HTMLElement | null;
|
|
77
|
+
withFocus?: boolean;
|
|
78
|
+
debug?: () => ReactNode;
|
|
79
|
+
}
|
|
80
|
+
>
|
|
81
|
+
>;
|
|
82
|
+
|
|
83
|
+
// TODO(burdon): Make generic.
|
|
84
|
+
const MosaicContainer = forwardRef<HTMLDivElement, MosaicContainerProps>(
|
|
85
|
+
(
|
|
86
|
+
{
|
|
87
|
+
classNames,
|
|
88
|
+
className,
|
|
89
|
+
children,
|
|
90
|
+
eventHandler: eventHandlerProp,
|
|
91
|
+
orientation = 'vertical',
|
|
92
|
+
asChild,
|
|
93
|
+
autoScroll: autoscrollElement,
|
|
94
|
+
withFocus,
|
|
95
|
+
debug,
|
|
96
|
+
...props
|
|
97
|
+
}: MosaicContainerProps,
|
|
98
|
+
forwardedRef,
|
|
99
|
+
) => {
|
|
100
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
101
|
+
const composedRef = useComposedRefs<HTMLDivElement>(rootRef, forwardedRef);
|
|
102
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
103
|
+
|
|
104
|
+
// Handler.
|
|
105
|
+
const eventHandler = useMemo(
|
|
106
|
+
() =>
|
|
107
|
+
eventHandlerProp ?? {
|
|
108
|
+
id: `mosaic-container-${counter++}`,
|
|
109
|
+
},
|
|
110
|
+
[eventHandlerProp],
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// State.
|
|
114
|
+
const { dragging } = useMosaicRootContext(MOSAIC_CONTAINER_NAME);
|
|
115
|
+
const [state, setState] = useState<MosaicContainerState>({ type: 'idle' });
|
|
116
|
+
const [activeLocation, setActiveLocation] = useState<LocationType | undefined>();
|
|
117
|
+
const [scrolling, setScrolling] = useState(false);
|
|
118
|
+
|
|
119
|
+
// Focus container.
|
|
120
|
+
const { setFocus } = useFocus();
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (withFocus) {
|
|
123
|
+
setFocus?.(state.type === 'active' ? 'active' : undefined);
|
|
124
|
+
}
|
|
125
|
+
}, [setFocus, withFocus, state]);
|
|
126
|
+
|
|
127
|
+
// Register handler.
|
|
128
|
+
const { addContainer, removeContainer } = useMosaicRootContext(eventHandler.id);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
addContainer(eventHandler);
|
|
131
|
+
return () => removeContainer(eventHandler.id);
|
|
132
|
+
}, [eventHandler]);
|
|
133
|
+
|
|
134
|
+
const data = useMemo<MosaicContainerData>(
|
|
135
|
+
() =>
|
|
136
|
+
({
|
|
137
|
+
type: 'container',
|
|
138
|
+
id: eventHandler.id,
|
|
139
|
+
}) satisfies MosaicContainerData,
|
|
140
|
+
[eventHandler.id],
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (!rootRef.current) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Determine if scrolling (pause drag/drop handlers).
|
|
149
|
+
let timeout: ReturnType<typeof setTimeout>;
|
|
150
|
+
const handleScroll = () => {
|
|
151
|
+
setScrolling(true);
|
|
152
|
+
clearTimeout(timeout);
|
|
153
|
+
timeout = setTimeout(() => {
|
|
154
|
+
setScrolling(false);
|
|
155
|
+
}, 500);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
return combine(
|
|
159
|
+
...[
|
|
160
|
+
/**
|
|
161
|
+
* Custom event for dragging cancellation.
|
|
162
|
+
*/
|
|
163
|
+
bind(rootRef.current, {
|
|
164
|
+
type: 'dnd:cancel',
|
|
165
|
+
listener: () => {
|
|
166
|
+
setState({ type: 'idle' });
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
169
|
+
|
|
170
|
+
// Target.
|
|
171
|
+
dropTargetForElements({
|
|
172
|
+
element: rootRef.current,
|
|
173
|
+
getData: () => data,
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Test if permitted to drop here.
|
|
177
|
+
* NOTE: Contained Tile and Placeholder elements do the same.
|
|
178
|
+
*/
|
|
179
|
+
canDrop: ({ source }) => {
|
|
180
|
+
const data = getSourceData(source);
|
|
181
|
+
return (data && eventHandler.canDrop?.({ source: data })) || false;
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
// TODO(burdon): Provide semantic intent to onDrop.
|
|
185
|
+
// getDropEffect: () => {
|
|
186
|
+
// return 'move';
|
|
187
|
+
// },
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Dragging started in this container.
|
|
191
|
+
*/
|
|
192
|
+
onDragStart: ({ source }) => {
|
|
193
|
+
const sourceData = source.data as MosaicTileData;
|
|
194
|
+
setState({ type: 'active', bounds: sourceData.bounds });
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* Dragging entered this container.
|
|
198
|
+
*/
|
|
199
|
+
onDragEnter: ({ source }) => {
|
|
200
|
+
const sourceData = source.data as MosaicTileData;
|
|
201
|
+
setState({ type: 'active', bounds: sourceData.bounds });
|
|
202
|
+
},
|
|
203
|
+
/**
|
|
204
|
+
* Dragging left this container.
|
|
205
|
+
* NOTE: If the container isn't full-height, then when the dragged item is temporarily removed the container will shrink,
|
|
206
|
+
* triggering `onDragLeave`, which then causes the item to be added and removed continually (flickering).
|
|
207
|
+
*/
|
|
208
|
+
onDragLeave: ({ source }) => {
|
|
209
|
+
const sourceData = source.data as MosaicTileData;
|
|
210
|
+
if (sourceData.containerId !== eventHandler.id) {
|
|
211
|
+
setState({ type: 'idle' });
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
/**
|
|
215
|
+
* Dropped in this container.
|
|
216
|
+
*/
|
|
217
|
+
onDrop: () => {
|
|
218
|
+
setState({ type: 'idle' });
|
|
219
|
+
},
|
|
220
|
+
}),
|
|
221
|
+
|
|
222
|
+
// Autoscroll.
|
|
223
|
+
// NOTE: When used with Scrollable we get a spurious warning (in dev mode).
|
|
224
|
+
// "Auto scrolling has been attached to an element that appears not to be scrollable."
|
|
225
|
+
autoscrollElement && [
|
|
226
|
+
autoScrollForElements({
|
|
227
|
+
element: autoscrollElement,
|
|
228
|
+
// canScroll: ({ element: _ }) => {
|
|
229
|
+
// return true;
|
|
230
|
+
// },
|
|
231
|
+
getAllowedAxis: () => orientation,
|
|
232
|
+
getConfiguration: () => ({
|
|
233
|
+
maxScrollSpeed: 'fast',
|
|
234
|
+
}),
|
|
235
|
+
}),
|
|
236
|
+
|
|
237
|
+
bind(autoscrollElement, {
|
|
238
|
+
type: 'scroll',
|
|
239
|
+
listener: handleScroll,
|
|
240
|
+
}),
|
|
241
|
+
|
|
242
|
+
() => setScrolling(false),
|
|
243
|
+
],
|
|
244
|
+
]
|
|
245
|
+
.filter(isTruthy)
|
|
246
|
+
.flatMap((x) => x),
|
|
247
|
+
);
|
|
248
|
+
}, [rootRef, eventHandler, data, autoscrollElement]);
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<MosaicContainerContextProvider
|
|
252
|
+
id={eventHandler.id}
|
|
253
|
+
eventHandler={eventHandler}
|
|
254
|
+
orientation={orientation}
|
|
255
|
+
state={state}
|
|
256
|
+
dragging={state.type === 'active' ? dragging : undefined}
|
|
257
|
+
scrolling={scrolling}
|
|
258
|
+
activeLocation={activeLocation}
|
|
259
|
+
setActiveLocation={setActiveLocation}
|
|
260
|
+
>
|
|
261
|
+
<Comp
|
|
262
|
+
className={mx('h-full', className, classNames)}
|
|
263
|
+
style={
|
|
264
|
+
{
|
|
265
|
+
[MOSAIC_CONTAINER_PLACEHOLDER_WIDTH]:
|
|
266
|
+
state.type === 'active' && state.bounds ? `${state.bounds.width}px` : '0px',
|
|
267
|
+
[MOSAIC_CONTAINER_PLACEHOLDER_HEIGHT]:
|
|
268
|
+
state.type === 'active' && state.bounds ? `${state.bounds.height}px` : '0px',
|
|
269
|
+
} as CSSProperties
|
|
270
|
+
}
|
|
271
|
+
{...props}
|
|
272
|
+
{...{
|
|
273
|
+
[`data-${MOSAIC_CONTAINER_STATE_ATTR}`]: state.type,
|
|
274
|
+
}}
|
|
275
|
+
ref={composedRef}
|
|
276
|
+
>
|
|
277
|
+
{children}
|
|
278
|
+
</Comp>
|
|
279
|
+
{debug?.()}
|
|
280
|
+
</MosaicContainerContextProvider>
|
|
281
|
+
);
|
|
282
|
+
},
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
MosaicContainer.displayName = MOSAIC_CONTAINER_NAME;
|
|
286
|
+
|
|
287
|
+
export { MosaicContainer, useMosaicContainerContext };
|
|
288
|
+
|
|
289
|
+
export type { MosaicContainerProps, MosaicContainerState };
|