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