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