@dxos/react-ui-stack 0.8.4-main.b97322e → 0.8.4-main.bc674ce

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 (107) hide show
  1. package/dist/lib/browser/index.mjs +923 -50
  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 +4 -0
  5. package/dist/lib/browser/playwright/index.mjs.map +2 -2
  6. package/dist/lib/node-esm/index.mjs +924 -50
  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 +4 -0
  10. package/dist/lib/node-esm/playwright/index.mjs.map +2 -2
  11. package/dist/types/src/{exemplars → components}/CardStack/CardStack.d.ts +20 -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 +15 -0
  14. package/dist/types/src/components/CardStack/CardStack.stories.d.ts.map +1 -0
  15. package/dist/types/src/{exemplars → components}/CardStack/CardStackDragPreview.d.ts +1 -1
  16. package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts.map +1 -0
  17. package/dist/types/src/components/CardStack/index.d.ts.map +1 -0
  18. package/dist/types/src/components/Stack/Stack.d.ts +15 -7
  19. package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
  20. package/dist/types/src/components/Stack/Stack.stories.d.ts +12 -3
  21. package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -1
  22. package/dist/types/src/components/StackContext.d.ts +2 -1
  23. package/dist/types/src/components/StackContext.d.ts.map +1 -1
  24. package/dist/types/src/components/StackItem/StackItem.d.ts +9 -12
  25. package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
  26. package/dist/types/src/components/StackItem/StackItem.stories.d.ts +13 -5
  27. package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/StackItem/StackItemContent.d.ts +4 -37
  29. package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
  30. package/dist/types/src/components/StackItem/StackItemHeading.d.ts +1 -1
  31. package/dist/types/src/components/StackItem/StackItemHeading.d.ts.map +1 -1
  32. package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts.map +1 -1
  33. package/dist/types/src/components/StackItem/StackItemSigil.d.ts +2 -2
  34. package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
  35. package/dist/types/src/components/deprecated/LayoutControls.d.ts +3 -0
  36. package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +1 -1
  37. package/dist/types/src/components/index.d.ts +2 -1
  38. package/dist/types/src/components/index.d.ts.map +1 -1
  39. package/dist/types/src/components/{defs.d.ts → types.d.ts} +1 -1
  40. package/dist/types/src/components/types.d.ts.map +1 -0
  41. package/dist/types/src/hooks/useStackDropForElements.d.ts +9 -7
  42. package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
  43. package/dist/types/src/index.d.ts +0 -1
  44. package/dist/types/src/index.d.ts.map +1 -1
  45. package/dist/types/src/translations.d.ts +2 -2
  46. package/dist/types/src/translations.d.ts.map +1 -1
  47. package/dist/types/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +41 -38
  49. package/src/{exemplars → components}/CardStack/CardStack.stories.tsx +19 -18
  50. package/src/{exemplars → components}/CardStack/CardStack.tsx +114 -54
  51. package/src/{exemplars → components}/CardStack/CardStackDragPreview.tsx +3 -3
  52. package/src/components/Stack/Stack.stories.tsx +8 -9
  53. package/src/components/Stack/Stack.tsx +225 -26
  54. package/src/components/StackContext.tsx +2 -1
  55. package/src/components/StackItem/StackItem.stories.tsx +19 -15
  56. package/src/components/StackItem/StackItem.tsx +49 -29
  57. package/src/components/StackItem/StackItemContent.tsx +18 -39
  58. package/src/components/StackItem/StackItemHeading.tsx +5 -9
  59. package/src/components/StackItem/StackItemResizeHandle.tsx +2 -1
  60. package/src/components/StackItem/StackItemSigil.tsx +5 -4
  61. package/src/components/deprecated/LayoutControls.tsx +3 -0
  62. package/src/components/index.ts +2 -1
  63. package/src/hooks/useStackDropForElements.ts +59 -45
  64. package/src/index.ts +0 -3
  65. package/src/playwright/playwright.config.ts +1 -1
  66. package/src/translations.ts +1 -1
  67. package/dist/lib/browser/chunk-P3TQV4BA.mjs +0 -1198
  68. package/dist/lib/browser/chunk-P3TQV4BA.mjs.map +0 -7
  69. package/dist/lib/browser/testing/index.mjs +0 -31
  70. package/dist/lib/browser/testing/index.mjs.map +0 -7
  71. package/dist/lib/node-esm/chunk-3WVEPAJ4.mjs +0 -1200
  72. package/dist/lib/node-esm/chunk-3WVEPAJ4.mjs.map +0 -7
  73. package/dist/lib/node-esm/testing/index.mjs +0 -32
  74. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  75. package/dist/types/src/components/defs.d.ts.map +0 -1
  76. package/dist/types/src/exemplars/Card/Card.d.ts +0 -58
  77. package/dist/types/src/exemplars/Card/Card.d.ts.map +0 -1
  78. package/dist/types/src/exemplars/Card/Card.stories.d.ts +0 -13
  79. package/dist/types/src/exemplars/Card/Card.stories.d.ts.map +0 -1
  80. package/dist/types/src/exemplars/Card/CardDragPreview.d.ts +0 -6
  81. package/dist/types/src/exemplars/Card/CardDragPreview.d.ts.map +0 -1
  82. package/dist/types/src/exemplars/Card/fragments.d.ts +0 -12
  83. package/dist/types/src/exemplars/Card/fragments.d.ts.map +0 -1
  84. package/dist/types/src/exemplars/Card/index.d.ts +0 -4
  85. package/dist/types/src/exemplars/Card/index.d.ts.map +0 -1
  86. package/dist/types/src/exemplars/CardStack/CardStack.d.ts.map +0 -1
  87. package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts +0 -9
  88. package/dist/types/src/exemplars/CardStack/CardStack.stories.d.ts.map +0 -1
  89. package/dist/types/src/exemplars/CardStack/CardStackDragPreview.d.ts.map +0 -1
  90. package/dist/types/src/exemplars/CardStack/index.d.ts.map +0 -1
  91. package/dist/types/src/exemplars/index.d.ts +0 -3
  92. package/dist/types/src/exemplars/index.d.ts.map +0 -1
  93. package/dist/types/src/testing/CardContainer.d.ts +0 -6
  94. package/dist/types/src/testing/CardContainer.d.ts.map +0 -1
  95. package/dist/types/src/testing/index.d.ts +0 -2
  96. package/dist/types/src/testing/index.d.ts.map +0 -1
  97. package/src/exemplars/Card/Card.stories.tsx +0 -78
  98. package/src/exemplars/Card/Card.tsx +0 -186
  99. package/src/exemplars/Card/CardDragPreview.tsx +0 -22
  100. package/src/exemplars/Card/fragments.ts +0 -23
  101. package/src/exemplars/Card/index.ts +0 -7
  102. package/src/exemplars/index.ts +0 -6
  103. package/src/testing/CardContainer.tsx +0 -34
  104. package/src/testing/index.ts +0 -5
  105. /package/dist/types/src/{exemplars → components}/CardStack/index.d.ts +0 -0
  106. /package/src/{exemplars → components}/CardStack/index.ts +0 -0
  107. /package/src/components/{defs.ts → types.ts} +0 -0
@@ -1,42 +1,926 @@
1
- import {
2
- Card,
3
- CardDragPreview,
4
- CardStack,
5
- CardStackDragPreview,
6
- DEFAULT_EXTRINSIC_SIZE,
7
- DEFAULT_HORIZONTAL_SIZE,
8
- DEFAULT_VERTICAL_SIZE,
9
- Stack,
10
- StackContext,
11
- StackItem,
12
- StackItemDragPreview,
13
- autoScrollRootAttributes,
14
- cardChrome,
15
- cardDialogContent,
16
- cardDialogHeader,
17
- cardDialogOverflow,
18
- cardDialogPaddedOverflow,
19
- cardDialogSearchListRoot,
20
- cardHeading,
21
- cardRoot,
22
- cardSpacing,
23
- cardStackContent,
24
- cardStackFooter,
25
- cardStackHeading,
26
- cardStackItem,
27
- cardStackRoot,
28
- cardText,
29
- labelSpacing,
30
- railGridHorizontal,
31
- railGridHorizontalContainFitContent,
32
- railGridVertical,
33
- railGridVerticalContainFitContent,
34
- translationKey,
35
- translations
36
- } from "./chunk-P3TQV4BA.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, 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("div", {
493
+ className: mx3("overflow-y-auto flex-1 pli-2 flex flex-col gap-2", "plb-1", itemsCount > 0 ? "plb-2" : "plb-1")
494
+ }, children);
495
+ };
496
+ var CardStackDragPreviewFooter = ({ children }) => {
497
+ return /* @__PURE__ */ React3.createElement("div", {
498
+ className: "p-2 border-bs border-separator"
499
+ }, children);
500
+ };
501
+ var CardStackDragPreview = {
502
+ Root: CardStackDragPreviewRoot,
503
+ Heading: CardStackDragPreviewHeading,
504
+ Content: CardStackDragPreviewContent,
505
+ Footer: CardStackDragPreviewFooter
506
+ };
507
+
508
+ // src/components/StackItem/StackItem.tsx
509
+ import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
510
+ import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
511
+ import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
512
+ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
513
+ import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
514
+ import { useFocusableGroup } from "@fluentui/react-tabster";
515
+ import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
516
+ import React10, { forwardRef as forwardRef6, useCallback as useCallback2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useState as useState4 } from "react";
517
+ import { createPortal } from "react-dom";
518
+ import { ListItem as ListItem2 } from "@dxos/react-ui";
519
+ import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
520
+ import { mx as mx7 } from "@dxos/ui-theme";
521
+
522
+ // src/components/StackItem/StackItemContent.tsx
523
+ import React4, { forwardRef as forwardRef3, useMemo as useMemo2 } from "react";
524
+ import { mx as mx4 } from "@dxos/ui-theme";
525
+ var StackItemContent = /* @__PURE__ */ forwardRef3(({ classNames, children, toolbar, statusbar, ...props }, forwardedRef) => {
526
+ const { size: stackItemSize } = useStack();
527
+ const { role } = useStackItem();
528
+ const style = useMemo2(() => ({
529
+ gridTemplateRows: [
530
+ ...toolbar ? [
531
+ role === "section" ? "calc(var(--toolbar-size) - 1px)" : "var(--toolbar-size)"
532
+ ] : [],
533
+ "1fr",
534
+ ...statusbar ? [
535
+ "var(--statusbar-size)"
536
+ ] : []
537
+ ].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", role === "section" && toolbar && "[&_.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
+ };
37
923
  export {
38
- Card,
39
- CardDragPreview,
40
924
  CardStack,
41
925
  CardStackDragPreview,
42
926
  DEFAULT_EXTRINSIC_SIZE,
@@ -45,24 +929,13 @@ export {
45
929
  Stack,
46
930
  StackContext,
47
931
  StackItem,
48
- StackItemDragPreview,
49
932
  autoScrollRootAttributes,
50
- cardChrome,
51
- cardDialogContent,
52
- cardDialogHeader,
53
- cardDialogOverflow,
54
- cardDialogPaddedOverflow,
55
- cardDialogSearchListRoot,
56
- cardHeading,
57
- cardRoot,
58
- cardSpacing,
59
933
  cardStackContent,
934
+ cardStackDefaultInlineSizeRem,
60
935
  cardStackFooter,
61
936
  cardStackHeading,
62
937
  cardStackItem,
63
938
  cardStackRoot,
64
- cardText,
65
- labelSpacing,
66
939
  railGridHorizontal,
67
940
  railGridHorizontalContainFitContent,
68
941
  railGridVertical,