@dxos/react-ui-stack 0.7.5-main.e9bb01b → 0.7.5-staging.2ff1350
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 +115 -124
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +161 -169
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +115 -124
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/MenuSignifier.d.ts +2 -3
- package/dist/types/src/components/MenuSignifier.d.ts.map +1 -1
- package/dist/types/src/components/Stack.d.ts +6 -1
- package/dist/types/src/components/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Stack.stories.d.ts +1 -2
- package/dist/types/src/components/Stack.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackContext.d.ts +2 -1
- package/dist/types/src/components/StackContext.d.ts.map +1 -1
- package/dist/types/src/components/StackItem.d.ts +4 -3
- package/dist/types/src/components/StackItem.d.ts.map +1 -1
- package/dist/types/src/components/StackItemContent.d.ts.map +1 -1
- package/dist/types/src/components/StackItemDragHandle.d.ts +2 -2
- package/dist/types/src/components/StackItemDragHandle.d.ts.map +1 -1
- package/dist/types/src/components/StackItemHeading.d.ts +1 -1
- package/dist/types/src/components/StackItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/StackItemResizeHandle.d.ts +1 -2
- package/dist/types/src/components/StackItemResizeHandle.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useStackDropForElements.d.ts +15 -0
- package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -0
- package/package.json +22 -20
- package/src/components/Stack.stories.tsx +1 -1
- package/src/components/Stack.tsx +44 -57
- package/src/components/StackContext.tsx +3 -1
- package/src/components/StackItem.tsx +28 -7
- package/src/components/StackItemContent.tsx +2 -0
- package/src/components/StackItemResizeHandle.tsx +10 -107
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useStackDropForElements.ts +73 -0
- package/dist/types/src/playwright/playwright.config.d.ts +0 -3
- package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
- /package/src/playwright/{playwright.config.ts → playwright.config.cts} +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// packages/ui/react-ui-stack/src/components/Stack.tsx
|
|
2
|
-
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
3
|
-
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
4
2
|
import { useArrowNavigationGroup } from "@fluentui/react-tabster";
|
|
5
3
|
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
6
|
-
import React, { Children, forwardRef,
|
|
4
|
+
import React, { Children, forwardRef, useState as useState2, useMemo } from "react";
|
|
7
5
|
import { ListItem } from "@dxos/react-ui";
|
|
8
6
|
import { mx } from "@dxos/react-ui-theme";
|
|
9
7
|
|
|
@@ -24,35 +22,28 @@ var StackItemContext = /* @__PURE__ */ createContext({
|
|
|
24
22
|
});
|
|
25
23
|
var useStackItem = () => useContext(StackItemContext);
|
|
26
24
|
|
|
27
|
-
// packages/ui/react-ui-stack/src/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
// packages/ui/react-ui-stack/src/hooks/useStackDropForElements.ts
|
|
26
|
+
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
27
|
+
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
28
|
+
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
|
29
|
+
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
30
|
+
import { useLayoutEffect, useState } from "react";
|
|
31
|
+
var useStackDropForElements = ({ element, selfDroppable, orientation, id, onRearrange }) => {
|
|
33
32
|
const [dropping, setDropping] = useState(false);
|
|
34
|
-
const arrowNavigationGroup = useArrowNavigationGroup({
|
|
35
|
-
axis: orientation
|
|
36
|
-
});
|
|
37
|
-
const styles = {
|
|
38
|
-
[orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content)`,
|
|
39
|
-
...style
|
|
40
|
-
};
|
|
41
|
-
const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
|
|
42
33
|
useLayoutEffect(() => {
|
|
43
|
-
if (!
|
|
34
|
+
if (!element || !selfDroppable) {
|
|
44
35
|
return;
|
|
45
36
|
}
|
|
46
37
|
const acceptSourceType = orientation === "horizontal" ? "column" : "card";
|
|
47
|
-
return dropTargetForElements({
|
|
48
|
-
element
|
|
49
|
-
getData: ({ input, element }) => {
|
|
38
|
+
return combine(dropTargetForElements({
|
|
39
|
+
element,
|
|
40
|
+
getData: ({ input, element: element2 }) => {
|
|
50
41
|
return attachClosestEdge({
|
|
51
|
-
id
|
|
42
|
+
id,
|
|
52
43
|
type: orientation === "horizontal" ? "card" : "column"
|
|
53
44
|
}, {
|
|
54
45
|
input,
|
|
55
|
-
element,
|
|
46
|
+
element: element2,
|
|
56
47
|
allowedEdges: [
|
|
57
48
|
orientation === "horizontal" ? "left" : "top"
|
|
58
49
|
]
|
|
@@ -68,17 +59,70 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
|
|
|
68
59
|
setDropping(true);
|
|
69
60
|
}
|
|
70
61
|
},
|
|
71
|
-
onDragLeave: () =>
|
|
62
|
+
onDragLeave: () => {
|
|
63
|
+
return setDropping(false);
|
|
64
|
+
},
|
|
72
65
|
onDrop: ({ self, source }) => {
|
|
73
66
|
setDropping(false);
|
|
74
|
-
if (source.data.type === acceptSourceType && selfDroppable) {
|
|
67
|
+
if (source.data.type === acceptSourceType && selfDroppable && onRearrange) {
|
|
75
68
|
onRearrange(source.data, self.data, extractClosestEdge(self.data));
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
|
-
})
|
|
71
|
+
}), autoScrollForElements({
|
|
72
|
+
element,
|
|
73
|
+
getAllowedAxis: () => orientation
|
|
74
|
+
}));
|
|
75
|
+
}, [
|
|
76
|
+
element,
|
|
77
|
+
selfDroppable,
|
|
78
|
+
orientation,
|
|
79
|
+
id,
|
|
80
|
+
onRearrange
|
|
81
|
+
]);
|
|
82
|
+
return {
|
|
83
|
+
dropping
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// packages/ui/react-ui-stack/src/components/Stack.tsx
|
|
88
|
+
var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
89
|
+
var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
90
|
+
var railGridHorizontalContainFitContent = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
|
|
91
|
+
var railGridVerticalContainFitContent = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
|
|
92
|
+
var autoScrollRootAttributes = {
|
|
93
|
+
"data-drag-autoscroll": "idle"
|
|
94
|
+
};
|
|
95
|
+
var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), ...props }, forwardedRef) => {
|
|
96
|
+
const [stackElement, stackRef] = useState2(null);
|
|
97
|
+
const composedItemRef = composeRefs(stackRef, forwardedRef);
|
|
98
|
+
const arrowNavigationGroup = useArrowNavigationGroup({
|
|
99
|
+
axis: orientation
|
|
100
|
+
});
|
|
101
|
+
const styles = {
|
|
102
|
+
[orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
|
|
103
|
+
...style
|
|
104
|
+
};
|
|
105
|
+
const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
|
|
106
|
+
const { dropping } = useStackDropForElements({
|
|
107
|
+
id: props.id,
|
|
108
|
+
element: stackElement,
|
|
109
|
+
selfDroppable,
|
|
110
|
+
orientation,
|
|
111
|
+
onRearrange
|
|
112
|
+
});
|
|
113
|
+
const gridClasses = useMemo(() => {
|
|
114
|
+
if (!rail) {
|
|
115
|
+
return orientation === "horizontal" ? "grid-rows-1 pli-1" : "grid-cols-1 plb-1";
|
|
116
|
+
}
|
|
117
|
+
if (orientation === "horizontal") {
|
|
118
|
+
return size === "contain-fit-content" ? railGridHorizontalContainFitContent : railGridHorizontal;
|
|
119
|
+
} else {
|
|
120
|
+
return size === "contain-fit-content" ? railGridVerticalContainFitContent : railGridVertical;
|
|
121
|
+
}
|
|
79
122
|
}, [
|
|
80
|
-
|
|
81
|
-
|
|
123
|
+
rail,
|
|
124
|
+
orientation,
|
|
125
|
+
size
|
|
82
126
|
]);
|
|
83
127
|
return /* @__PURE__ */ React.createElement(StackContext.Provider, {
|
|
84
128
|
value: {
|
|
@@ -90,26 +134,31 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
|
|
|
90
134
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
91
135
|
...props,
|
|
92
136
|
...arrowNavigationGroup,
|
|
93
|
-
className: mx("grid relative",
|
|
137
|
+
className: mx("grid relative", gridClasses, (size === "contain" || size === "contain-fit-content") && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 bs-full max-bs-full" : "overflow-y-auto min-is-0 is-full max-is-full"), classNames),
|
|
138
|
+
"data-rail": rail,
|
|
94
139
|
"aria-orientation": orientation,
|
|
95
140
|
style: styles,
|
|
96
141
|
ref: composedItemRef
|
|
97
142
|
}, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
|
|
143
|
+
lineInset: 8,
|
|
144
|
+
terminalInset: -8,
|
|
145
|
+
gap: -8,
|
|
98
146
|
edge: orientation === "horizontal" ? "left" : "top"
|
|
99
147
|
})));
|
|
100
148
|
});
|
|
101
149
|
|
|
102
150
|
// packages/ui/react-ui-stack/src/components/StackItem.tsx
|
|
103
|
-
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
104
|
-
import { draggable
|
|
151
|
+
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
152
|
+
import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
105
153
|
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
106
154
|
import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
|
|
107
155
|
import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
108
156
|
import { useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
|
|
109
157
|
import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
|
|
110
|
-
import React8, { forwardRef as forwardRef5, useLayoutEffect as
|
|
158
|
+
import React8, { forwardRef as forwardRef5, useLayoutEffect as useLayoutEffect2, useState as useState4, useCallback } from "react";
|
|
111
159
|
import { ListItem as ListItem2 } from "@dxos/react-ui";
|
|
112
|
-
import {
|
|
160
|
+
import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
|
|
161
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
113
162
|
|
|
114
163
|
// packages/ui/react-ui-stack/src/components/StackItemContent.tsx
|
|
115
164
|
import React2, { forwardRef as forwardRef2 } from "react";
|
|
@@ -176,94 +225,28 @@ var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related
|
|
|
176
225
|
});
|
|
177
226
|
|
|
178
227
|
// packages/ui/react-ui-stack/src/components/StackItemResizeHandle.tsx
|
|
179
|
-
import
|
|
180
|
-
import {
|
|
181
|
-
import { preventUnhandled } from "@atlaskit/pragmatic-drag-and-drop/prevent-unhandled";
|
|
182
|
-
import React5, { useLayoutEffect as useLayoutEffect2, useRef } from "react";
|
|
183
|
-
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
184
|
-
var REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
228
|
+
import React5 from "react";
|
|
229
|
+
import { ResizeHandle } from "@dxos/react-ui-dnd";
|
|
185
230
|
var MIN_WIDTH = 20;
|
|
186
231
|
var MIN_HEIGHT = 3;
|
|
187
|
-
var measureStackItem = (element) => {
|
|
188
|
-
const stackItemElement = element.closest("[data-dx-stack-item]");
|
|
189
|
-
return stackItemElement?.getBoundingClientRect() ?? {
|
|
190
|
-
width: DEFAULT_EXTRINSIC_SIZE,
|
|
191
|
-
height: DEFAULT_EXTRINSIC_SIZE
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
var getNextSize = (startSize, location, client) => {
|
|
195
|
-
return Math.max(client === "clientX" ? MIN_WIDTH : MIN_HEIGHT, startSize + (location.current.input[client] - location.initial.input[client]) / REM);
|
|
196
|
-
};
|
|
197
232
|
var StackItemResizeHandle = () => {
|
|
198
233
|
const { orientation } = useStack();
|
|
199
234
|
const { setSize, size } = useStackItem();
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
draggable({
|
|
208
|
-
element: buttonRef.current,
|
|
209
|
-
onGenerateDragPreview: ({ nativeSetDragImage }) => {
|
|
210
|
-
disableNativeDragPreview({
|
|
211
|
-
nativeSetDragImage
|
|
212
|
-
});
|
|
213
|
-
preventUnhandled.start();
|
|
214
|
-
},
|
|
215
|
-
onDragStart: () => {
|
|
216
|
-
dragStartSize.current = dragStartSize.current === "min-content" ? measureStackItem(buttonRef.current)[orientation === "horizontal" ? "width" : "height"] / REM : dragStartSize.current;
|
|
217
|
-
},
|
|
218
|
-
onDrag: ({ location }) => {
|
|
219
|
-
if (typeof dragStartSize.current !== "number") {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
setSize(getNextSize(dragStartSize.current, location, client));
|
|
223
|
-
},
|
|
224
|
-
onDrop: ({ location }) => {
|
|
225
|
-
if (typeof dragStartSize.current !== "number") {
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
const nextSize = getNextSize(dragStartSize.current, location, client);
|
|
229
|
-
setSize(nextSize, true);
|
|
230
|
-
dragStartSize.current = nextSize;
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
}, []);
|
|
234
|
-
return /* @__PURE__ */ React5.createElement("button", {
|
|
235
|
-
ref: buttonRef,
|
|
236
|
-
className: mx4("group absolute", orientation === "horizontal" ? "cursor-col-resize is-3 bs-full inline-end-[-1px] !border-lb-0 before:inset-block-0 before:inline-end-0 before:is-1" : "cursor-row-resize bs-3 is-full block-end-[-1px] !border-li-0 before:inset-inline-0 before:block-end-0 before:bs-1", "before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100", "before:absolute before:block before:bg-accentFocusIndicator")
|
|
237
|
-
}, /* @__PURE__ */ React5.createElement("div", {
|
|
238
|
-
role: "none",
|
|
239
|
-
className: mx4("absolute flex items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0", orientation === "horizontal" ? "block-start-0 inline-end-px bs-[--rail-size]" : "inline-start-0 block-end-px is-[--rail-size] flex justify-center")
|
|
240
|
-
}, /* @__PURE__ */ React5.createElement(DragHandleSignifier, {
|
|
241
|
-
orientation
|
|
242
|
-
})));
|
|
243
|
-
};
|
|
244
|
-
var DragHandleSignifier = ({ orientation }) => {
|
|
245
|
-
return /* @__PURE__ */ React5.createElement("svg", {
|
|
246
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
247
|
-
viewBox: "0 0 256 256",
|
|
248
|
-
fill: "currentColor",
|
|
249
|
-
className: mx4("shrink-0 bs-[1em] is-[1em] text-unAccent", orientation === "vertical" && "rotate-90")
|
|
250
|
-
}, /* @__PURE__ */ React5.createElement("path", {
|
|
251
|
-
d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
252
|
-
}), /* @__PURE__ */ React5.createElement("path", {
|
|
253
|
-
d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
254
|
-
}), /* @__PURE__ */ React5.createElement("path", {
|
|
255
|
-
d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
256
|
-
}), /* @__PURE__ */ React5.createElement("path", {
|
|
257
|
-
d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
258
|
-
}));
|
|
235
|
+
return /* @__PURE__ */ React5.createElement(ResizeHandle, {
|
|
236
|
+
side: orientation === "horizontal" ? "inline-end" : "block-end",
|
|
237
|
+
fallbackSize: DEFAULT_EXTRINSIC_SIZE,
|
|
238
|
+
minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
|
|
239
|
+
size,
|
|
240
|
+
onSizeChange: setSize
|
|
241
|
+
});
|
|
259
242
|
};
|
|
260
243
|
|
|
261
244
|
// packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
|
|
262
|
-
import React7, { Fragment, forwardRef as forwardRef4, useRef
|
|
245
|
+
import React7, { Fragment, forwardRef as forwardRef4, useRef, useState as useState3 } from "react";
|
|
263
246
|
import { keySymbols } from "@dxos/keyboard";
|
|
264
247
|
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
265
248
|
import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
266
|
-
import { descriptionText, mx as
|
|
249
|
+
import { descriptionText, mx as mx4 } from "@dxos/react-ui-theme";
|
|
267
250
|
import { getHostPlatform } from "@dxos/util";
|
|
268
251
|
|
|
269
252
|
// packages/ui/react-ui-stack/src/components/MenuSignifier.tsx
|
|
@@ -320,8 +303,8 @@ var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNam
|
|
|
320
303
|
});
|
|
321
304
|
var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
322
305
|
const { t } = useTranslation(translationKey);
|
|
323
|
-
const suppressNextTooltip =
|
|
324
|
-
const [optionsMenuOpen, setOptionsMenuOpen] =
|
|
306
|
+
const suppressNextTooltip = useRef(false);
|
|
307
|
+
const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
|
|
325
308
|
const hasActions = actionGroups && actionGroups.length > 0;
|
|
326
309
|
const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
|
|
327
310
|
attendableId,
|
|
@@ -387,7 +370,7 @@ var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAct
|
|
|
387
370
|
icon: "ph--check--regular",
|
|
388
371
|
size: 4
|
|
389
372
|
})), shortcut && /* @__PURE__ */ React7.createElement("span", {
|
|
390
|
-
className:
|
|
373
|
+
className: mx4("shrink-0", descriptionText)
|
|
391
374
|
}, keySymbols(shortcut).join("")));
|
|
392
375
|
}));
|
|
393
376
|
}), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
|
|
@@ -397,12 +380,12 @@ var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAct
|
|
|
397
380
|
var DEFAULT_HORIZONTAL_SIZE = 44;
|
|
398
381
|
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
399
382
|
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
400
|
-
var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, style, disableRearrange, ...props }, forwardedRef) => {
|
|
401
|
-
const [itemElement, itemRef] =
|
|
402
|
-
const [selfDragHandleElement, selfDragHandleRef] =
|
|
403
|
-
const [closestEdge, setEdge] =
|
|
383
|
+
var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
|
|
384
|
+
const [itemElement, itemRef] = useState4(null);
|
|
385
|
+
const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
|
|
386
|
+
const [closestEdge, setEdge] = useState4(null);
|
|
404
387
|
const { orientation, rail, onRearrange } = useStack();
|
|
405
|
-
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] =
|
|
388
|
+
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(propsSize);
|
|
406
389
|
const Root = role ?? "div";
|
|
407
390
|
const composedItemRef = composeRefs2(itemRef, forwardedRef);
|
|
408
391
|
const setSize = useCallback((nextSize, commit) => {
|
|
@@ -414,11 +397,11 @@ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, s
|
|
|
414
397
|
onSizeChange
|
|
415
398
|
]);
|
|
416
399
|
const type = orientation === "horizontal" ? "column" : "card";
|
|
417
|
-
|
|
400
|
+
useLayoutEffect2(() => {
|
|
418
401
|
if (!itemElement || !onRearrange || disableRearrange) {
|
|
419
402
|
return;
|
|
420
403
|
}
|
|
421
|
-
return
|
|
404
|
+
return combine2(draggable({
|
|
422
405
|
element: itemElement,
|
|
423
406
|
...selfDragHandleElement && {
|
|
424
407
|
dragHandle: selfDragHandleElement
|
|
@@ -442,6 +425,10 @@ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, s
|
|
|
442
425
|
},
|
|
443
426
|
onDragStart: () => {
|
|
444
427
|
document.body.removeAttribute("data-drag-preview");
|
|
428
|
+
itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
|
|
429
|
+
},
|
|
430
|
+
onDrop: () => {
|
|
431
|
+
itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
|
|
445
432
|
}
|
|
446
433
|
}), dropTargetForElements2({
|
|
447
434
|
element: itemElement,
|
|
@@ -499,12 +486,11 @@ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, s
|
|
|
499
486
|
...props,
|
|
500
487
|
tabIndex: 0,
|
|
501
488
|
...focusGroupAttrs,
|
|
502
|
-
className:
|
|
489
|
+
className: mx5("group/stack-item grid relative", focusIndicatorVariant === "over-all" ? "dx-focus-ring-inset-over-all" : orientation === "horizontal" ? "dx-focus-ring-group-x" : "dx-focus-ring-group-y", orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), classNames),
|
|
503
490
|
"data-dx-stack-item": true,
|
|
491
|
+
...resizeAttributes,
|
|
504
492
|
style: {
|
|
505
|
-
...size
|
|
506
|
-
[orientation === "horizontal" ? "inlineSize" : "blockSize"]: `${size}rem`
|
|
507
|
-
},
|
|
493
|
+
...sizeStyle(size, orientation),
|
|
508
494
|
...Number.isFinite(order) && {
|
|
509
495
|
[orientation === "horizontal" ? "gridColumn" : "gridRow"]: `${order}`
|
|
510
496
|
},
|
|
@@ -512,6 +498,8 @@ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, s
|
|
|
512
498
|
},
|
|
513
499
|
ref: composedItemRef
|
|
514
500
|
}, children, closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
|
|
501
|
+
lineInset: 8,
|
|
502
|
+
terminalInset: -8,
|
|
515
503
|
edge: closestEdge
|
|
516
504
|
})));
|
|
517
505
|
});
|
|
@@ -600,8 +588,11 @@ export {
|
|
|
600
588
|
StackContext,
|
|
601
589
|
StackItem,
|
|
602
590
|
StackItemContext,
|
|
591
|
+
autoScrollRootAttributes,
|
|
603
592
|
railGridHorizontal,
|
|
593
|
+
railGridHorizontalContainFitContent,
|
|
604
594
|
railGridVertical,
|
|
595
|
+
railGridVerticalContainFitContent,
|
|
605
596
|
translations_default as translations,
|
|
606
597
|
useStack,
|
|
607
598
|
useStackItem
|