@dxos/react-ui-stack 0.8.4-main.ead640a → 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.
Files changed (108) hide show
  1. package/dist/lib/browser/index.mjs +920 -57
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/playwright/index.mjs +10 -23
  5. package/dist/lib/browser/playwright/index.mjs.map +2 -2
  6. package/dist/lib/node-esm/index.mjs +921 -57
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/lib/node-esm/playwright/index.mjs +10 -23
  10. package/dist/lib/node-esm/playwright/index.mjs.map +2 -2
  11. package/dist/types/src/{exemplars → components}/CardStack/CardStack.d.ts +18 -13
  12. package/dist/types/src/components/CardStack/CardStack.d.ts.map +1 -0
  13. package/dist/types/src/components/CardStack/CardStack.stories.d.ts.map +1 -0
  14. package/dist/types/src/{exemplars → components}/CardStack/CardStackDragPreview.d.ts +4 -1
  15. package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts.map +1 -0
  16. package/dist/types/src/components/CardStack/index.d.ts.map +1 -0
  17. package/dist/types/src/components/Stack/Stack.d.ts +7 -7
  18. package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
  19. package/dist/types/src/components/StackContext.d.ts +1 -1
  20. package/dist/types/src/components/StackContext.d.ts.map +1 -1
  21. package/dist/types/src/components/StackItem/StackItem.d.ts +5 -9
  22. package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
  23. package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -1
  24. package/dist/types/src/components/StackItem/StackItemContent.d.ts +2 -45
  25. package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
  26. package/dist/types/src/components/StackItem/StackItemSigil.d.ts +2 -2
  27. package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
  28. package/dist/types/src/components/deprecated/LayoutControls.d.ts +3 -0
  29. package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +1 -1
  30. package/dist/types/src/components/index.d.ts +2 -2
  31. package/dist/types/src/components/index.d.ts.map +1 -1
  32. package/dist/types/src/components/{defs.d.ts → types.d.ts} +1 -1
  33. package/dist/types/src/components/types.d.ts.map +1 -0
  34. package/dist/types/src/hooks/useStackDropForElements.d.ts +8 -6
  35. package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
  36. package/dist/types/src/index.d.ts +0 -1
  37. package/dist/types/src/index.d.ts.map +1 -1
  38. package/dist/types/src/translations.d.ts +2 -2
  39. package/dist/types/src/translations.d.ts.map +1 -1
  40. package/dist/types/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +40 -37
  42. package/src/{exemplars → components}/CardStack/CardStack.stories.tsx +10 -10
  43. package/src/{exemplars → components}/CardStack/CardStack.tsx +113 -57
  44. package/src/{exemplars → components}/CardStack/CardStackDragPreview.tsx +12 -9
  45. package/src/components/Stack/Stack.stories.tsx +2 -2
  46. package/src/components/Stack/Stack.tsx +19 -17
  47. package/src/components/StackContext.tsx +1 -1
  48. package/src/components/StackItem/StackItem.stories.tsx +6 -4
  49. package/src/components/StackItem/StackItem.tsx +24 -12
  50. package/src/components/StackItem/StackItemContent.tsx +19 -50
  51. package/src/components/StackItem/StackItemHeading.tsx +1 -1
  52. package/src/components/StackItem/StackItemSigil.tsx +3 -3
  53. package/src/components/deprecated/LayoutControls.tsx +3 -0
  54. package/src/components/index.ts +2 -2
  55. package/src/hooks/useStackDropForElements.ts +58 -44
  56. package/src/index.ts +0 -3
  57. package/src/playwright/playwright.config.ts +1 -1
  58. package/src/translations.ts +1 -1
  59. package/dist/lib/browser/chunk-T4ZCIFCF.mjs +0 -1448
  60. package/dist/lib/browser/chunk-T4ZCIFCF.mjs.map +0 -7
  61. package/dist/lib/browser/testing/index.mjs +0 -31
  62. package/dist/lib/browser/testing/index.mjs.map +0 -7
  63. package/dist/lib/node-esm/chunk-G2QYUH52.mjs +0 -1450
  64. package/dist/lib/node-esm/chunk-G2QYUH52.mjs.map +0 -7
  65. package/dist/lib/node-esm/testing/index.mjs +0 -32
  66. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  67. package/dist/types/src/components/Image/Image.d.ts +0 -14
  68. package/dist/types/src/components/Image/Image.d.ts.map +0 -1
  69. package/dist/types/src/components/Image/Image.stories.d.ts +0 -32
  70. package/dist/types/src/components/Image/Image.stories.d.ts.map +0 -1
  71. package/dist/types/src/components/Image/index.d.ts +0 -2
  72. package/dist/types/src/components/Image/index.d.ts.map +0 -1
  73. package/dist/types/src/components/defs.d.ts.map +0 -1
  74. package/dist/types/src/exemplars/Card/Card.d.ts +0 -66
  75. package/dist/types/src/exemplars/Card/Card.d.ts.map +0 -1
  76. package/dist/types/src/exemplars/Card/Card.stories.d.ts +0 -21
  77. package/dist/types/src/exemplars/Card/Card.stories.d.ts.map +0 -1
  78. package/dist/types/src/exemplars/Card/CardDragPreview.d.ts +0 -6
  79. package/dist/types/src/exemplars/Card/CardDragPreview.d.ts.map +0 -1
  80. package/dist/types/src/exemplars/Card/fragments.d.ts +0 -13
  81. package/dist/types/src/exemplars/Card/fragments.d.ts.map +0 -1
  82. package/dist/types/src/exemplars/Card/index.d.ts +0 -4
  83. package/dist/types/src/exemplars/Card/index.d.ts.map +0 -1
  84. package/dist/types/src/exemplars/CardStack/CardStack.d.ts.map +0 -1
  85. package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts.map +0 -1
  86. package/dist/types/src/exemplars/CardStack/CardStackDragPreview.d.ts.map +0 -1
  87. package/dist/types/src/exemplars/CardStack/index.d.ts.map +0 -1
  88. package/dist/types/src/exemplars/index.d.ts +0 -3
  89. package/dist/types/src/exemplars/index.d.ts.map +0 -1
  90. package/dist/types/src/testing/CardContainer.d.ts +0 -6
  91. package/dist/types/src/testing/CardContainer.d.ts.map +0 -1
  92. package/dist/types/src/testing/index.d.ts +0 -2
  93. package/dist/types/src/testing/index.d.ts.map +0 -1
  94. package/src/components/Image/Image.stories.tsx +0 -78
  95. package/src/components/Image/Image.tsx +0 -192
  96. package/src/components/Image/index.ts +0 -5
  97. package/src/exemplars/Card/Card.stories.tsx +0 -64
  98. package/src/exemplars/Card/Card.tsx +0 -204
  99. package/src/exemplars/Card/CardDragPreview.tsx +0 -22
  100. package/src/exemplars/Card/fragments.ts +0 -24
  101. package/src/exemplars/Card/index.ts +0 -7
  102. package/src/exemplars/index.ts +0 -6
  103. package/src/testing/CardContainer.tsx +0 -37
  104. package/src/testing/index.ts +0 -5
  105. /package/dist/types/src/{exemplars → components}/CardStack/CardStack.stories.d.ts +0 -0
  106. /package/dist/types/src/{exemplars → components}/CardStack/index.d.ts +0 -0
  107. /package/src/{exemplars → components}/CardStack/index.ts +0 -0
  108. /package/src/components/{defs.ts → types.ts} +0 -0
@@ -1,76 +1,939 @@
1
- import {
2
- Card,
3
- CardDragPreview,
4
- CardStack,
5
- CardStackDragPreview,
6
- DEFAULT_EXTRINSIC_SIZE,
7
- DEFAULT_HORIZONTAL_SIZE,
8
- DEFAULT_VERTICAL_SIZE,
9
- Image,
10
- Stack,
11
- StackContext,
12
- StackItem,
13
- StackItemDragPreview,
14
- autoScrollRootAttributes,
15
- cardChrome,
16
- cardDefaultInlineSize,
17
- cardDialogContent,
18
- cardDialogHeader,
19
- cardDialogOverflow,
20
- cardDialogPaddedOverflow,
21
- cardDialogSearchListRoot,
22
- cardHeading,
23
- cardNoSpacing,
24
- cardRoot,
25
- cardSpacing,
26
- cardStackContent,
27
- cardStackDefaultInlineSizeRem,
28
- cardStackFooter,
29
- cardStackHeading,
30
- cardStackItem,
31
- cardStackRoot,
32
- cardText,
33
- labelSpacing,
34
- railGridHorizontal,
35
- railGridHorizontalContainFitContent,
36
- railGridVertical,
37
- railGridVerticalContainFitContent,
38
- translationKey,
39
- translations
40
- } from "./chunk-T4ZCIFCF.mjs";
1
+ // src/components/CardStack/CardStack.tsx
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import React2, { forwardRef as forwardRef2 } from "react";
4
+ import { Card } from "@dxos/react-ui-mosaic";
5
+ import { cardDefaultInlineSize, mx as mx2 } from "@dxos/ui-theme";
6
+
7
+ // src/components/Stack/Stack.tsx
8
+ import { composeRefs } from "@radix-ui/react-compose-refs";
9
+ import React, { Children, forwardRef, useCallback, useEffect, useMemo, useState as useState2 } from "react";
10
+ import { ListItem, useId } from "@dxos/react-ui";
11
+ import { mx } from "@dxos/ui-theme";
12
+
13
+ // src/hooks/useStackDropForElements.ts
14
+ import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
15
+ import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
16
+ import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
17
+ import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
18
+ import { useLayoutEffect, useState } from "react";
19
+ var noop = () => {
20
+ };
21
+ var useStackDropForElements = ({ id, element, scrollElement = element, orientation, selfDroppable, onRearrange }) => {
22
+ const [dropping, setDropping] = useState(false);
23
+ useLayoutEffect(() => {
24
+ if (!element) {
25
+ return;
26
+ }
27
+ const acceptSourceType = orientation === "horizontal" ? "column" : "card";
28
+ return combine(selfDroppable ? dropTargetForElements({
29
+ element,
30
+ getData: ({ input, element: element2 }) => {
31
+ return attachClosestEdge({
32
+ id,
33
+ type: orientation === "horizontal" ? "card" : "column"
34
+ }, {
35
+ input,
36
+ element: element2,
37
+ allowedEdges: [
38
+ orientation === "horizontal" ? "left" : "top"
39
+ ]
40
+ });
41
+ },
42
+ onDragEnter: ({ source }) => {
43
+ if (source.data.type === acceptSourceType) {
44
+ setDropping(true);
45
+ }
46
+ },
47
+ onDrag: ({ source }) => {
48
+ if (source.data.type === acceptSourceType) {
49
+ setDropping(true);
50
+ }
51
+ },
52
+ onDragLeave: () => {
53
+ return setDropping(false);
54
+ },
55
+ onDrop: ({ self, source }) => {
56
+ setDropping(false);
57
+ if (source.data.type === acceptSourceType && selfDroppable && onRearrange) {
58
+ onRearrange(source.data, self.data, extractClosestEdge(self.data));
59
+ }
60
+ }
61
+ }) : noop, scrollElement ? autoScrollForElements({
62
+ element: scrollElement,
63
+ getAllowedAxis: () => orientation
64
+ }) : noop);
65
+ }, [
66
+ id,
67
+ element,
68
+ scrollElement,
69
+ selfDroppable,
70
+ orientation,
71
+ onRearrange
72
+ ]);
73
+ return {
74
+ dropping
75
+ };
76
+ };
77
+
78
+ // src/components/StackContext.tsx
79
+ import { createContext, useContext } from "react";
80
+ var StackContext = /* @__PURE__ */ createContext({
81
+ orientation: "vertical",
82
+ rail: true,
83
+ size: "intrinsic"
84
+ });
85
+ var useStack = () => useContext(StackContext);
86
+ var idle = {
87
+ type: "idle"
88
+ };
89
+ var StackItemContext = /* @__PURE__ */ createContext({
90
+ selfDragHandleRef: () => {
91
+ },
92
+ size: "min-content",
93
+ setSize: () => {
94
+ },
95
+ state: idle,
96
+ setState: () => {
97
+ }
98
+ });
99
+ var useStackItem = () => useContext(StackItemContext);
100
+
101
+ // src/components/Stack/Stack.tsx
102
+ var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
103
+ var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
104
+ var railGridHorizontalContainFitContent = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
105
+ var railGridVerticalContainFitContent = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
106
+ var autoScrollRootAttributes = {
107
+ "data-drag-autoscroll": "idle"
108
+ };
109
+ var PERPENDICULAR_FOCUS_THRESHHOLD = 128;
110
+ var scrollIntoViewAndFocus = (el, orientation) => {
111
+ el.scrollIntoView({
112
+ behavior: "instant",
113
+ [orientation === "vertical" ? "block" : "inline"]: "center"
114
+ });
115
+ return el.focus();
116
+ };
117
+ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), getDropElement, separatorOnScroll, circularFocus, ...props }, forwardedRef) => {
118
+ const stackId = useId("stack", props.id);
119
+ const [stackElement, stackRef] = useState2(null);
120
+ const [lastFocusedItem, setLastFocusedItem] = useState2();
121
+ const composedItemRef = composeRefs(stackRef, forwardedRef);
122
+ const styles = {
123
+ [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: size === "split" ? `repeat(${itemsCount}, 1fr)` : `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
124
+ ...style
125
+ };
126
+ const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
127
+ const { dropping } = useStackDropForElements({
128
+ id: props.id,
129
+ element: getDropElement && stackElement ? getDropElement(stackElement) : stackElement,
130
+ scrollElement: stackElement,
131
+ selfDroppable,
132
+ orientation,
133
+ onRearrange
134
+ });
135
+ const handleScroll = useCallback(() => {
136
+ if (stackElement && Number.isFinite(separatorOnScroll)) {
137
+ const scrollPosition = orientation === "horizontal" ? stackElement.scrollLeft : stackElement.scrollTop;
138
+ const scrollSize = orientation === "horizontal" ? stackElement.scrollWidth : stackElement.scrollHeight;
139
+ const clientSize = orientation === "horizontal" ? stackElement.clientWidth : stackElement.clientHeight;
140
+ const separatorHost = stackElement.closest("[data-scroll-separator]");
141
+ if (separatorHost) {
142
+ separatorHost.setAttribute("data-scroll-separator", String(scrollPosition > separatorOnScroll));
143
+ separatorHost.setAttribute("data-scroll-separator-end", String(scrollSize - (scrollPosition + clientSize) > separatorOnScroll));
144
+ }
145
+ }
146
+ }, [
147
+ stackElement,
148
+ separatorOnScroll,
149
+ orientation
150
+ ]);
151
+ const handleBlur = useCallback((event) => {
152
+ if (event.target) {
153
+ const target = event.target;
154
+ const closestStackItem = target.closest(`[data-dx-item-id]`);
155
+ if (closestStackItem?.closest(`[data-dx-stack="${stackId}"]`)) {
156
+ setLastFocusedItem(closestStackItem?.getAttribute("data-dx-item-id") ?? void 0);
157
+ }
158
+ }
159
+ props.onBlur?.(event);
160
+ }, [
161
+ stackId,
162
+ props.onBlur
163
+ ]);
164
+ const handleKeyDown = useCallback((event) => {
165
+ const target = event.target;
166
+ if (event.key.startsWith("Arrow") && !target.closest(`input, textarea, [role="textbox"], [data-tabster*="mover"], [data-arrow-keys="all"], [data-arrow-keys~="${event.key.toLowerCase().slice(5)}"]`)) {
167
+ const closestOwnedItem = target.closest(`[data-dx-stack-item="${stackId}"]`);
168
+ const closestStack = target.closest("[data-dx-stack]");
169
+ const closestStackItems = Array.from(closestStack?.querySelectorAll(`[data-dx-stack-item="${stackId}"]`) ?? []);
170
+ const closestStackOrientation = closestStack?.getAttribute("aria-orientation");
171
+ const ancestorStack = closestStack?.parentElement?.closest("[data-dx-stack]");
172
+ if (closestOwnedItem && closestStack) {
173
+ const ancestorOrientation = ancestorStack?.getAttribute("aria-orientation");
174
+ const parallelDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowUp" : event.key === "ArrowLeft") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowDown" : event.key === "ArrowRight") ? 1 : 0;
175
+ const perpendicularDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowLeft" : event.key === "ArrowUp") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowRight" : event.key === "ArrowDown") ? 1 : 0;
176
+ if (parallelDelta !== 0) {
177
+ const currentIndex = closestStackItems.indexOf(closestOwnedItem);
178
+ const nextIndex = currentIndex + parallelDelta;
179
+ let adjacentItem;
180
+ if (circularFocus) {
181
+ adjacentItem = closestStackItems[(nextIndex + closestStackItems.length) % closestStackItems.length];
182
+ } else {
183
+ if (nextIndex >= 0 && nextIndex < closestStackItems.length) {
184
+ adjacentItem = closestStackItems[nextIndex];
185
+ }
186
+ }
187
+ if (adjacentItem) {
188
+ event.preventDefault();
189
+ scrollIntoViewAndFocus(adjacentItem, closestStackOrientation);
190
+ }
191
+ }
192
+ if (perpendicularDelta !== 0) {
193
+ if (ancestorStack && ancestorOrientation !== closestStackOrientation) {
194
+ const siblingStacks = Array.from(ancestorStack.querySelectorAll(`[data-dx-stack-item="${ancestorStack.getAttribute("data-dx-stack")}"] [data-dx-stack]`));
195
+ const currentStackIndex = siblingStacks.indexOf(closestStack);
196
+ const nextStackIndex = currentStackIndex + perpendicularDelta;
197
+ let adjacentStack;
198
+ if (ancestorStack.getAttribute("data-dx-stack-circular-focus") === "true") {
199
+ adjacentStack = siblingStacks[(nextStackIndex + siblingStacks.length) % siblingStacks.length];
200
+ } else {
201
+ if (nextStackIndex >= 0 && nextStackIndex < siblingStacks.length) {
202
+ adjacentStack = siblingStacks[nextStackIndex];
203
+ }
204
+ }
205
+ const adjacentStackSelfItem = adjacentStack?.closest(`[data-dx-stack-item=${ancestorStack.getAttribute("data-dx-stack")}]`);
206
+ const adjacentStackItems = adjacentStack ? Array.from(adjacentStack.querySelectorAll(`[data-dx-stack-item="${adjacentStack.getAttribute("data-dx-stack")}"]`)) : [];
207
+ if (adjacentStack && adjacentStackItems.length > 0) {
208
+ let closestItem = adjacentStackItems[0];
209
+ const lastFocusedItem2 = adjacentStack.querySelector(`[data-dx-item-id="${adjacentStack.getAttribute("data-dx-last-focused-item") ?? "never"}"]`);
210
+ if (lastFocusedItem2) {
211
+ closestItem = lastFocusedItem2;
212
+ } else {
213
+ const ownedItemRect = closestOwnedItem.getBoundingClientRect();
214
+ const targetPosition = closestStackOrientation === "vertical" ? ownedItemRect.top : ownedItemRect.left;
215
+ let closestDistance = Infinity;
216
+ for (const item of adjacentStackItems) {
217
+ const itemRect = item.getBoundingClientRect();
218
+ const itemPosition = closestStackOrientation === "vertical" ? itemRect.top : itemRect.left;
219
+ const distance = Math.abs(itemPosition - targetPosition);
220
+ if (distance < closestDistance) {
221
+ closestDistance = distance;
222
+ closestItem = item;
223
+ }
224
+ if (closestDistance <= PERPENDICULAR_FOCUS_THRESHHOLD) {
225
+ break;
226
+ }
227
+ }
228
+ }
229
+ event.preventDefault();
230
+ scrollIntoViewAndFocus(closestItem, closestStackOrientation);
231
+ } else if (adjacentStackSelfItem) {
232
+ event.preventDefault();
233
+ scrollIntoViewAndFocus(adjacentStackSelfItem, ancestorOrientation);
234
+ }
235
+ } else if (closestOwnedItem) {
236
+ const closestOwnedItemStack = closestOwnedItem.querySelector("[data-dx-stack]");
237
+ const closestOwnedItemStackItems = closestOwnedItemStack ? Array.from(closestOwnedItemStack.querySelectorAll(`[data-dx-stack-item="${closestOwnedItemStack.getAttribute("data-dx-stack")}"]`)) : [];
238
+ if (closestOwnedItemStackItems.length > 0) {
239
+ event.preventDefault();
240
+ scrollIntoViewAndFocus(closestOwnedItemStackItems[[
241
+ "ArrowUp",
242
+ "ArrowLeft"
243
+ ].includes(event.key) ? closestOwnedItemStackItems.length - 1 : 0], closestOwnedItemStack?.getAttribute("aria-orientation"));
244
+ }
245
+ }
246
+ }
247
+ }
248
+ }
249
+ props.onKeyDown?.(event);
250
+ }, [
251
+ props.onKeyDown,
252
+ stackId,
253
+ circularFocus
254
+ ]);
255
+ const gridClasses = useMemo(() => {
256
+ if (!rail) {
257
+ return orientation === "horizontal" ? "grid-rows-1 pli-[--stack-gap]" : "grid-cols-1 plb-[--stack-gap]";
258
+ }
259
+ if (orientation === "horizontal") {
260
+ return railGridHorizontal;
261
+ } else {
262
+ return railGridVertical;
263
+ }
264
+ }, [
265
+ rail,
266
+ orientation,
267
+ size
268
+ ]);
269
+ useEffect(() => {
270
+ if (!(stackElement && Number.isFinite(separatorOnScroll))) {
271
+ return;
272
+ }
273
+ const observer = new MutationObserver(() => {
274
+ handleScroll();
275
+ });
276
+ observer.observe(stackElement, {
277
+ childList: true,
278
+ subtree: true
279
+ });
280
+ return () => {
281
+ observer.disconnect();
282
+ };
283
+ }, [
284
+ stackElement,
285
+ handleScroll
286
+ ]);
287
+ return /* @__PURE__ */ React.createElement(StackContext.Provider, {
288
+ value: {
289
+ orientation,
290
+ rail,
291
+ size,
292
+ onRearrange,
293
+ stackId
294
+ }
295
+ }, /* @__PURE__ */ React.createElement("div", {
296
+ ...props,
297
+ className: mx("grid relative [--stack-gap:var(--dx-trimXs)]", gridClasses, size === "contain" && (orientation === "horizontal" ? "overflow-x-auto overscroll-x-contain min-bs-0 max-bs-full bs-full" : "overflow-y-auto min-is-0 max-is-full is-full"), classNames),
298
+ onKeyDown: handleKeyDown,
299
+ onBlur: handleBlur,
300
+ "data-dx-stack": stackId,
301
+ "data-dx-stack-circular-focus": circularFocus,
302
+ "data-dx-last-focused-item": lastFocusedItem,
303
+ "data-rail": rail,
304
+ "aria-orientation": orientation,
305
+ style: styles,
306
+ ref: composedItemRef,
307
+ ...Number.isFinite(separatorOnScroll) && {
308
+ onScroll: handleScroll
309
+ }
310
+ }, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
311
+ lineInset: 8,
312
+ terminalInset: -8,
313
+ gap: -8,
314
+ edge: orientation === "horizontal" ? "left" : "top"
315
+ })));
316
+ });
317
+
318
+ // src/components/CardStack/CardStack.tsx
319
+ var cardStackDefaultInlineSizeRem = cardDefaultInlineSize + 2.125;
320
+ var cardStackRoot = "flex flex-col";
321
+ var CardStackRoot = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
322
+ const Root = asChild ? Slot : "div";
323
+ const rootProps = asChild ? {
324
+ classNames: [
325
+ cardStackRoot,
326
+ classNames
327
+ ]
328
+ } : {
329
+ className: mx2(cardStackRoot, classNames),
330
+ role
331
+ };
332
+ return /* @__PURE__ */ React2.createElement(Root, {
333
+ ...props,
334
+ ...rootProps,
335
+ ref: forwardedRef
336
+ }, children);
337
+ });
338
+ var cardStackContent = "shrink min-bs-0 grid dx-focus-ring-group-x-indicator bg-baseSurface";
339
+ var CardStackContent = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "none", footer, ...props }, forwardedRef) => {
340
+ const Root = asChild ? Slot : "div";
341
+ const baseClassNames = footer ? [
342
+ cardStackContent,
343
+ railGridHorizontalContainFitContent
344
+ ] : [
345
+ cardStackContent
346
+ ];
347
+ const rootProps = asChild ? {
348
+ classNames: [
349
+ ...baseClassNames,
350
+ classNames
351
+ ]
352
+ } : {
353
+ className: mx2(...baseClassNames, classNames),
354
+ role
355
+ };
356
+ return /* @__PURE__ */ React2.createElement(Root, {
357
+ ...props,
358
+ ...rootProps,
359
+ "data-scroll-separator": "false",
360
+ ref: forwardedRef
361
+ }, children);
362
+ });
363
+ var CardStackStack = /* @__PURE__ */ forwardRef2(({ children, classNames, itemsCount = 0, ...props }, forwardedRef) => {
364
+ return /* @__PURE__ */ React2.createElement(Stack, {
365
+ orientation: "vertical",
366
+ size: "contain",
367
+ rail: false,
368
+ classNames: (
369
+ /* NOTE(thure): Do not let this element have zero intrinsic size, otherwise the drop indicator will not display. See #9035. */
370
+ [
371
+ "plb-2",
372
+ classNames
373
+ ]
374
+ ),
375
+ itemsCount,
376
+ separatorOnScroll: 9,
377
+ "data-density": "fine",
378
+ ...props,
379
+ ref: forwardedRef
380
+ }, children);
381
+ });
382
+ var cardStackItem = "contain-layout pli-2 plb-1 first-of-type:pbs-0 last-of-type:pbe-0";
383
+ var CardStackItem = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
384
+ const Root = asChild ? Slot : "div";
385
+ const rootProps = asChild ? {
386
+ classNames: [
387
+ cardStackItem,
388
+ classNames
389
+ ]
390
+ } : {
391
+ className: mx2(cardStackItem, classNames),
392
+ role
393
+ };
394
+ return /* @__PURE__ */ React2.createElement(Root, {
395
+ ...props,
396
+ ...rootProps,
397
+ ref: forwardedRef
398
+ }, children);
399
+ });
400
+ var cardStackHeading = "mli-2 order-first bg-transparent rounded-bs-md flex items-center";
401
+ var CardStackHeading = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "heading", ...props }, forwardedRef) => {
402
+ const Root = asChild ? Slot : "div";
403
+ const rootProps = asChild ? {
404
+ classNames: [
405
+ cardStackHeading,
406
+ classNames
407
+ ]
408
+ } : {
409
+ className: mx2(cardStackHeading, classNames),
410
+ role
411
+ };
412
+ return /* @__PURE__ */ React2.createElement(Root, {
413
+ ...props,
414
+ ...rootProps,
415
+ ref: forwardedRef
416
+ }, children);
417
+ });
418
+ var cardStackFooter = 'plb-2 mli-2 border-bs border-transparent [[data-scroll-separator-end="true"]_&]:border-subduedSeparator';
419
+ var CardStackFooter = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
420
+ const Root = asChild ? Slot : "div";
421
+ const rootProps = asChild ? {
422
+ classNames: [
423
+ cardStackFooter,
424
+ classNames
425
+ ]
426
+ } : {
427
+ className: mx2(cardStackFooter, classNames),
428
+ role
429
+ };
430
+ return /* @__PURE__ */ React2.createElement(Root, {
431
+ ...props,
432
+ ...rootProps,
433
+ ref: forwardedRef
434
+ }, children);
435
+ });
436
+ var CardStackDragHandle = Card.DragHandle;
437
+ var CardStack = {
438
+ Root: CardStackRoot,
439
+ Content: CardStackContent,
440
+ Stack: CardStackStack,
441
+ Heading: CardStackHeading,
442
+ Footer: CardStackFooter,
443
+ DragHandle: CardStackDragHandle,
444
+ Item: CardStackItem
445
+ };
446
+
447
+ // src/components/CardStack/CardStackDragPreview.tsx
448
+ import React3 from "react";
449
+ import { IconButton, ScrollArea, useTranslation } from "@dxos/react-ui";
450
+ import { mx as mx3 } from "@dxos/ui-theme";
451
+
452
+ // src/translations.ts
453
+ var translationKey = "@dxos/react-ui-stack";
454
+ var translations = [
455
+ {
456
+ "en-US": {
457
+ [translationKey]: {
458
+ "resize label": "Drag to resize",
459
+ "drag handle label": "Drag to rearrange",
460
+ "pin start label": "Pin to the left sidebar",
461
+ "pin end label": "Pin to the right sidebar",
462
+ "increment start label": "Move to the left",
463
+ "increment end label": "Move to the right",
464
+ "close label": "Close",
465
+ "minify label": "Minify"
466
+ }
467
+ }
468
+ }
469
+ ];
470
+
471
+ // src/components/CardStack/CardStackDragPreview.tsx
472
+ var CardStackDragPreviewRoot = ({ children }) => {
473
+ return /* @__PURE__ */ React3.createElement("div", {
474
+ className: "p-2"
475
+ }, /* @__PURE__ */ React3.createElement("div", {
476
+ className: "rounded-md max-bs-[calc(100dvh-1rem)] overflow-hidden bg-baseSurface border border-separator ring-focusLine ring-neutralFocusIndicator flex flex-col"
477
+ }, children));
478
+ };
479
+ var CardStackDragPreviewHeading = ({ children }) => {
480
+ const { t } = useTranslation(translationKey);
481
+ return /* @__PURE__ */ React3.createElement("div", {
482
+ className: "flex items-center p-2"
483
+ }, /* @__PURE__ */ React3.createElement(IconButton, {
484
+ iconOnly: true,
485
+ icon: "ph--dots-six-vertical--regular",
486
+ variant: "ghost",
487
+ label: t("column drag handle label"),
488
+ classNames: "pli-2"
489
+ }), children);
490
+ };
491
+ var CardStackDragPreviewContent = ({ children, itemsCount = 0 }) => {
492
+ return /* @__PURE__ */ React3.createElement(ScrollArea.Root, {
493
+ orientation: "vertical"
494
+ }, /* @__PURE__ */ React3.createElement(ScrollArea.Viewport, {
495
+ classNames: mx3("pli-2 plb-1 gap-2", itemsCount > 0 ? "plb-2" : "plb-1")
496
+ }, children));
497
+ };
498
+ var CardStackDragPreviewFooter = ({ children }) => {
499
+ return /* @__PURE__ */ React3.createElement("div", {
500
+ className: "p-2 border-bs border-separator"
501
+ }, children);
502
+ };
503
+ var CardStackDragPreview = {
504
+ Root: CardStackDragPreviewRoot,
505
+ Heading: CardStackDragPreviewHeading,
506
+ Content: CardStackDragPreviewContent,
507
+ Footer: CardStackDragPreviewFooter
508
+ };
509
+
510
+ // src/components/StackItem/StackItem.tsx
511
+ import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
512
+ import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
513
+ import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
514
+ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
515
+ import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
516
+ import { useFocusableGroup } from "@fluentui/react-tabster";
517
+ import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
518
+ import React10, { forwardRef as forwardRef6, useCallback as useCallback2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useState as useState4 } from "react";
519
+ import { createPortal } from "react-dom";
520
+ import { ListItem as ListItem2 } from "@dxos/react-ui";
521
+ import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
522
+ import { mx as mx7 } from "@dxos/ui-theme";
523
+
524
+ // src/components/StackItem/StackItemContent.tsx
525
+ import React4, { forwardRef as forwardRef3, useMemo as useMemo2 } from "react";
526
+ import { mx as mx4 } from "@dxos/ui-theme";
527
+ var StackItemContent = /* @__PURE__ */ forwardRef3(({ classNames, children, toolbar, statusbar, ...props }, forwardedRef) => {
528
+ const { size: stackItemSize } = useStack();
529
+ const { role } = useStackItem();
530
+ const style = useMemo2(() => ({
531
+ gridTemplateRows: [
532
+ toolbar && role === "section" ? "calc(var(--toolbar-size) - 1px)" : "var(--toolbar-size)",
533
+ "1fr",
534
+ statusbar && "var(--statusbar-size)"
535
+ ].filter(Boolean).join(" ")
536
+ }), [
537
+ toolbar,
538
+ statusbar
539
+ ]);
540
+ return /* @__PURE__ */ React4.createElement("div", {
541
+ ...props,
542
+ role: "none",
543
+ style,
544
+ className: mx4("group grid grid-cols-[100%] density-coarse", stackItemSize === "contain" && "min-bs-0 overflow-hidden", toolbar && role === "section" && "[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:block-start-0 [&_.dx-toolbar]:-mbe-px [&_.dx-toolbar]:min-is-0", toolbar && "[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-be [&>.dx-toolbar]:border-subduedSeparator", classNames),
545
+ "data-popover-collision-boundary": true,
546
+ ref: forwardedRef
547
+ }, children);
548
+ });
549
+ StackItemContent.displayName = "StackItemContent";
550
+
551
+ // src/components/StackItem/StackItemDragHandle.tsx
552
+ import { Slot as Slot2 } from "@radix-ui/react-slot";
553
+ import React5 from "react";
554
+ var StackItemDragHandle = ({ asChild, children }) => {
555
+ const { selfDragHandleRef } = useStackItem();
556
+ const Root = asChild ? Slot2 : "div";
557
+ return /* @__PURE__ */ React5.createElement(Root, {
558
+ ref: selfDragHandleRef,
559
+ role: "button"
560
+ }, children);
561
+ };
562
+
563
+ // src/components/StackItem/StackItemHeading.tsx
564
+ import { Slot as Slot3 } from "@radix-ui/react-slot";
565
+ import React6, { forwardRef as forwardRef4 } from "react";
566
+ import { useAttention } from "@dxos/react-ui-attention";
567
+ import { mx as mx5 } from "@dxos/ui-theme";
568
+ var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, ...props }) => {
569
+ const { orientation } = useStack();
570
+ const Root = asChild ? Slot3 : "div";
571
+ return /* @__PURE__ */ React6.createElement(Root, {
572
+ role: "heading",
573
+ ...props,
574
+ className: mx5("flex items-center !border-is-0 bg-headerSurface", separateOnScroll ? 'border-transparent [[data-scroll-separator="true"]_&]:border-subduedSeparator' : "border-subduedSeparator", orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", orientation === "horizontal" ? "border-be" : "border-ie", classNames)
575
+ }, children);
576
+ };
577
+ var StackItemHeadingStickyContent = ({ children }) => {
578
+ return /* @__PURE__ */ React6.createElement("div", {
579
+ role: "none",
580
+ className: "sticky block-start-0 bg-[--sticky-bg] p-1 is-full"
581
+ }, children);
582
+ };
583
+ var StackItemHeadingLabel = /* @__PURE__ */ forwardRef4(({ attendableId, related, classNames, ...props }, forwardedRef) => {
584
+ const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
585
+ return /* @__PURE__ */ React6.createElement("h1", {
586
+ ...props,
587
+ "data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
588
+ className: mx5("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center", classNames),
589
+ ref: forwardedRef
590
+ });
591
+ });
592
+
593
+ // src/components/StackItem/StackItemResizeHandle.tsx
594
+ import React7 from "react";
595
+ import { ResizeHandle } from "@dxos/react-ui-dnd";
596
+ var MIN_WIDTH = 20;
597
+ var MIN_HEIGHT = 3;
598
+ var StackItemResizeHandle = () => {
599
+ const { orientation } = useStack();
600
+ const { setSize, size } = useStackItem();
601
+ return /* @__PURE__ */ React7.createElement(ResizeHandle, {
602
+ side: orientation === "horizontal" ? "inline-end" : "block-end",
603
+ fallbackSize: DEFAULT_EXTRINSIC_SIZE,
604
+ minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
605
+ size,
606
+ onSizeChange: setSize
607
+ });
608
+ };
609
+
610
+ // src/components/StackItem/StackItemSigil.tsx
611
+ import React9, { Fragment, forwardRef as forwardRef5, useState as useState3 } from "react";
612
+ import { keySymbols } from "@dxos/keyboard";
613
+ import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
614
+ import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
615
+ import { descriptionText, mx as mx6 } from "@dxos/ui-theme";
616
+ import { getHostPlatform } from "@dxos/util";
617
+
618
+ // src/components/StackItem/MenuSignifier.tsx
619
+ import React8 from "react";
620
+ var MenuSignifierHorizontal = () => /* @__PURE__ */ React8.createElement("svg", {
621
+ className: "absolute block-end-[7px]",
622
+ width: 20,
623
+ height: 2,
624
+ viewBox: "0 0 20 2",
625
+ stroke: "currentColor",
626
+ opacity: 0.5
627
+ }, /* @__PURE__ */ React8.createElement("line", {
628
+ x1: 0.5,
629
+ y1: 0.75,
630
+ x2: 19,
631
+ y2: 0.75,
632
+ strokeWidth: 1.25,
633
+ strokeLinecap: "round",
634
+ strokeDasharray: "6 20",
635
+ strokeDashoffset: "-6.5"
636
+ }));
637
+
638
+ // src/components/StackItem/StackItemSigil.tsx
639
+ var StackItemSigilButton = /* @__PURE__ */ forwardRef5(({ attendableId, classNames, related, isMenu = true, children, ...props }, forwardedRef) => {
640
+ const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
641
+ const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
642
+ return /* @__PURE__ */ React9.createElement(Button, {
643
+ ...props,
644
+ variant,
645
+ classNames: [
646
+ "shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative app-no-drag",
647
+ classNames
648
+ ],
649
+ ref: forwardedRef
650
+ }, isMenu && /* @__PURE__ */ React9.createElement(MenuSignifierHorizontal, null), children);
651
+ });
652
+ var StackItemSigil = /* @__PURE__ */ forwardRef5(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
653
+ const { t } = useTranslation2(translationKey);
654
+ const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
655
+ const hasActions = actionGroups && actionGroups.length > 0;
656
+ const button = /* @__PURE__ */ React9.createElement(StackItemSigilButton, {
657
+ attendableId,
658
+ related,
659
+ isMenu: hasActions,
660
+ // TODO(wittjosiah): Better disabling of interactive styles when no action are available.
661
+ // Remove underscore icon when no actions are available?
662
+ classNames: !hasActions && "cursor-default"
663
+ }, /* @__PURE__ */ React9.createElement("span", {
664
+ className: "sr-only"
665
+ }, triggerLabel), /* @__PURE__ */ React9.createElement(Icon, {
666
+ icon,
667
+ size: 5
668
+ }));
669
+ if (!hasActions) {
670
+ return button;
671
+ }
672
+ return /* @__PURE__ */ React9.createElement(DropdownMenu.Root, {
673
+ open: optionsMenuOpen,
674
+ onOpenChange: setOptionsMenuOpen
675
+ }, /* @__PURE__ */ React9.createElement(DropdownMenu.Trigger, {
676
+ asChild: true,
677
+ ref: forwardedRef
678
+ }, button), /* @__PURE__ */ React9.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React9.createElement(DropdownMenu.Content, {
679
+ classNames: "z-[31]"
680
+ }, /* @__PURE__ */ React9.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
681
+ const separator = index > 0 ? /* @__PURE__ */ React9.createElement(DropdownMenu.Separator, null) : null;
682
+ return /* @__PURE__ */ React9.createElement(Fragment, {
683
+ key: index
684
+ }, separator, actions.map((action) => {
685
+ const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
686
+ const menuItemType = action.properties.menuItemType;
687
+ const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
688
+ return /* @__PURE__ */ React9.createElement(Root, {
689
+ key: action.id,
690
+ onClick: (event) => {
691
+ if (action.properties.disabled) {
692
+ return;
693
+ }
694
+ event.stopPropagation();
695
+ setOptionsMenuOpen(false);
696
+ onAction?.(action);
697
+ },
698
+ classNames: "gap-2",
699
+ disabled: action.properties.disabled,
700
+ checked: menuItemType === "toggle" ? action.properties.isChecked : void 0,
701
+ ...action.properties?.testId && {
702
+ "data-testid": action.properties.testId
703
+ }
704
+ }, /* @__PURE__ */ React9.createElement(Icon, {
705
+ icon: action.properties.icon ?? "ph--placeholder--regular",
706
+ size: 4
707
+ }), /* @__PURE__ */ React9.createElement("span", {
708
+ className: "grow truncate"
709
+ }, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React9.createElement(DropdownMenu.ItemIndicator, {
710
+ asChild: true
711
+ }, /* @__PURE__ */ React9.createElement(Icon, {
712
+ icon: "ph--check--regular",
713
+ size: 4
714
+ })), shortcut && /* @__PURE__ */ React9.createElement("span", {
715
+ className: mx6("shrink-0", descriptionText)
716
+ }, keySymbols(shortcut).join("")));
717
+ }));
718
+ }), children), /* @__PURE__ */ React9.createElement(DropdownMenu.Arrow, null))));
719
+ });
720
+
721
+ // src/components/StackItem/StackItem.tsx
722
+ var DEFAULT_HORIZONTAL_SIZE = 48;
723
+ var DEFAULT_VERTICAL_SIZE = "min-content";
724
+ var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
725
+ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, size: propsSize, onSizeChange, role, order, prevSiblingId, nextSiblingId, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
726
+ const [itemElement, itemRef] = useState4(null);
727
+ const composedItemRef = composeRefs2(itemRef, forwardedRef);
728
+ const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
729
+ const [closestEdge, setEdge] = useState4(null);
730
+ const [sourceId, setSourceId] = useState4(null);
731
+ const [dragState, setDragState] = useState4(idle);
732
+ const { orientation, rail, onRearrange, size: stackSize, stackId } = useStack();
733
+ const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(propsSize);
734
+ const Root = role ?? "div";
735
+ const setSize = useCallback2((nextSize, commit) => {
736
+ setInternalSize(nextSize);
737
+ if (commit) {
738
+ onSizeChange?.(nextSize);
739
+ }
740
+ }, [
741
+ onSizeChange
742
+ ]);
743
+ const type = orientation === "horizontal" ? "column" : "card";
744
+ useLayoutEffect2(() => {
745
+ if (!itemElement || !onRearrange || disableRearrange) {
746
+ return;
747
+ }
748
+ return combine2(draggable({
749
+ element: itemElement,
750
+ ...selfDragHandleElement && {
751
+ dragHandle: selfDragHandleElement
752
+ },
753
+ getInitialData: () => ({
754
+ id: item.id,
755
+ type
756
+ }),
757
+ onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
758
+ document.body.setAttribute("data-drag-preview", "true");
759
+ const offsetFn = preserveOffsetOnSource({
760
+ element: source.element,
761
+ input: location.current.input
762
+ });
763
+ const rect = source.element.getBoundingClientRect();
764
+ setCustomNativeDragPreview({
765
+ nativeSetDragImage,
766
+ getOffset: ({ container }) => {
767
+ return offsetFn({
768
+ container
769
+ });
770
+ },
771
+ render: ({ container }) => {
772
+ container.style.width = rect.width + "px";
773
+ setDragState({
774
+ type: "preview",
775
+ container,
776
+ item
777
+ });
778
+ return () => {
779
+ };
780
+ }
781
+ });
782
+ },
783
+ onDragStart: () => {
784
+ document.body.removeAttribute("data-drag-preview");
785
+ itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
786
+ setDragState({
787
+ type: "is-dragging",
788
+ item
789
+ });
790
+ },
791
+ onDrop: () => {
792
+ itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
793
+ setDragState(idle);
794
+ }
795
+ }), dropTargetForElements2({
796
+ element: itemElement,
797
+ getData: ({ input, element }) => {
798
+ return attachClosestEdge2({
799
+ id: item.id,
800
+ type
801
+ }, {
802
+ input,
803
+ element,
804
+ allowedEdges: orientation === "horizontal" ? [
805
+ "left",
806
+ "right"
807
+ ] : [
808
+ "top",
809
+ "bottom"
810
+ ]
811
+ });
812
+ },
813
+ onDragEnter: ({ self, source }) => {
814
+ if (source.data.type === self.data.type) {
815
+ setEdge(extractClosestEdge2(self.data));
816
+ setSourceId(source.data.id);
817
+ }
818
+ },
819
+ onDrag: ({ self, source }) => {
820
+ if (source.data.type === self.data.type) {
821
+ setEdge(extractClosestEdge2(self.data));
822
+ setSourceId(source.data.id);
823
+ }
824
+ },
825
+ onDragLeave: () => {
826
+ setEdge(null);
827
+ setSourceId(null);
828
+ },
829
+ onDrop: ({ self, source }) => {
830
+ setEdge(null);
831
+ setSourceId(null);
832
+ if (source.data.type === self.data.type) {
833
+ onRearrange(source.data, self.data, extractClosestEdge2(self.data));
834
+ }
835
+ }
836
+ }));
837
+ }, [
838
+ orientation,
839
+ item,
840
+ onRearrange,
841
+ selfDragHandleElement,
842
+ itemElement
843
+ ]);
844
+ const focusableGroupAttrs = useFocusableGroup({
845
+ tabBehavior: "limited"
846
+ });
847
+ const shouldShowDropIndicator = () => {
848
+ if (!closestEdge || !sourceId) {
849
+ return false;
850
+ }
851
+ if (sourceId === item.id) {
852
+ return false;
853
+ }
854
+ const isTrailingEdgeOfPrevSibling = prevSiblingId !== void 0 && sourceId === prevSiblingId && (orientation === "horizontal" && closestEdge === "left" || orientation === "vertical" && closestEdge === "top");
855
+ if (isTrailingEdgeOfPrevSibling) {
856
+ return false;
857
+ }
858
+ const isLeadingEdgeOfNextSibling = nextSiblingId !== void 0 && sourceId === nextSiblingId && (orientation === "horizontal" && closestEdge === "right" || orientation === "vertical" && closestEdge === "bottom");
859
+ if (isLeadingEdgeOfNextSibling) {
860
+ return false;
861
+ }
862
+ return true;
863
+ };
864
+ const stackItemContextValue = useMemo3(() => ({
865
+ selfDragHandleRef,
866
+ size,
867
+ setSize,
868
+ state: dragState,
869
+ setState: setDragState,
870
+ role
871
+ }), [
872
+ selfDragHandleRef,
873
+ size,
874
+ setSize,
875
+ dragState,
876
+ setDragState,
877
+ role
878
+ ]);
879
+ return /* @__PURE__ */ React10.createElement(StackItemContext.Provider, {
880
+ value: stackItemContextValue
881
+ }, /* @__PURE__ */ React10.createElement(Root, {
882
+ ...props,
883
+ tabIndex: 0,
884
+ ...focusableGroupAttrs,
885
+ className: mx7("group/stack-item grid relative", focusIndicatorVariant === "over-all" ? "dx-focus-ring-inset-over-all" : focusIndicatorVariant === "over-all-always" ? "dx-focus-ring-inset-over-all-always" : orientation === "horizontal" ? focusIndicatorVariant === "group-always" ? "dx-focus-ring-group-x-always" : "dx-focus-ring-group-x" : focusIndicatorVariant === "group-always" ? "dx-focus-ring-group-y-always" : "dx-focus-ring-group-y", orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), role === "section" && orientation !== "horizontal" && "border-be border-subduedSeparator", classNames),
886
+ "data-dx-stack-item": stackId,
887
+ "data-dx-item-id": item.id,
888
+ ...resizeAttributes,
889
+ style: {
890
+ ...stackSize !== "split" && sizeStyle(size, orientation),
891
+ ...Number.isFinite(order) && {
892
+ [orientation === "horizontal" ? "gridColumn" : "gridRow"]: `${order}`
893
+ },
894
+ ...style
895
+ },
896
+ ref: composedItemRef
897
+ }, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */ React10.createElement(ListItem2.DropIndicator, {
898
+ lineInset: 8,
899
+ terminalInset: -8,
900
+ edge: closestEdge
901
+ })));
902
+ });
903
+ var StackItemDragPreview = ({ children }) => {
904
+ const { state } = useStackItem();
905
+ return state?.type === "preview" ? /* @__PURE__ */ createPortal(children({
906
+ item: state.item
907
+ }), state.container) : null;
908
+ };
909
+ var StackItem = {
910
+ Root: StackItemRoot,
911
+ Content: StackItemContent,
912
+ DragHandle: StackItemDragHandle,
913
+ DragPreview: StackItemDragPreview,
914
+ Heading: StackItemHeading,
915
+ HeadingLabel: StackItemHeadingLabel,
916
+ HeadingStickyContent: StackItemHeadingStickyContent,
917
+ ResizeHandle: StackItemResizeHandle,
918
+ Sigil: StackItemSigil,
919
+ SigilButton: StackItemSigilButton
920
+ };
41
921
  export {
42
- Card,
43
- CardDragPreview,
44
922
  CardStack,
45
923
  CardStackDragPreview,
46
924
  DEFAULT_EXTRINSIC_SIZE,
47
925
  DEFAULT_HORIZONTAL_SIZE,
48
926
  DEFAULT_VERTICAL_SIZE,
49
- Image,
50
927
  Stack,
51
928
  StackContext,
52
929
  StackItem,
53
- StackItemDragPreview,
54
930
  autoScrollRootAttributes,
55
- cardChrome,
56
- cardDefaultInlineSize,
57
- cardDialogContent,
58
- cardDialogHeader,
59
- cardDialogOverflow,
60
- cardDialogPaddedOverflow,
61
- cardDialogSearchListRoot,
62
- cardHeading,
63
- cardNoSpacing,
64
- cardRoot,
65
- cardSpacing,
66
931
  cardStackContent,
67
932
  cardStackDefaultInlineSizeRem,
68
933
  cardStackFooter,
69
934
  cardStackHeading,
70
935
  cardStackItem,
71
936
  cardStackRoot,
72
- cardText,
73
- labelSpacing,
74
937
  railGridHorizontal,
75
938
  railGridHorizontalContainFitContent,
76
939
  railGridVertical,