@dxos/react-ui-stack 0.8.2-staging.7ac8446 → 0.8.2

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 (78) hide show
  1. package/dist/lib/browser/index.mjs +484 -421
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/testing/index.mjs.map +3 -3
  5. package/dist/lib/node/index.cjs +472 -410
  6. package/dist/lib/node/index.cjs.map +4 -4
  7. package/dist/lib/node/meta.json +1 -1
  8. package/dist/lib/node/testing/index.cjs.map +3 -3
  9. package/dist/lib/node-esm/index.mjs +484 -421
  10. package/dist/lib/node-esm/index.mjs.map +4 -4
  11. package/dist/lib/node-esm/meta.json +1 -1
  12. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  13. package/dist/types/src/components/{Stack.d.ts → Stack/Stack.d.ts} +4 -1
  14. package/dist/types/src/components/Stack/Stack.d.ts.map +1 -0
  15. package/dist/types/src/components/Stack/Stack.stories.d.ts +9 -0
  16. package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -0
  17. package/dist/types/src/components/Stack/index.d.ts +2 -0
  18. package/dist/types/src/components/Stack/index.d.ts.map +1 -0
  19. package/dist/types/src/components/StackContext.d.ts +14 -10
  20. package/dist/types/src/components/StackContext.d.ts.map +1 -1
  21. package/dist/types/src/components/StackItem/MenuSignifier.d.ts.map +1 -0
  22. package/dist/types/src/components/{StackItem.d.ts → StackItem/StackItem.d.ts} +14 -5
  23. package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -0
  24. package/dist/types/src/components/StackItem/StackItem.stories.d.ts +8 -0
  25. package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -0
  26. package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -0
  27. package/dist/types/src/components/StackItem/StackItemDragHandle.d.ts.map +1 -0
  28. package/dist/types/src/components/StackItem/StackItemHeading.d.ts.map +1 -0
  29. package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts.map +1 -0
  30. package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -0
  31. package/dist/types/src/components/StackItem/index.d.ts +2 -0
  32. package/dist/types/src/components/StackItem/index.d.ts.map +1 -0
  33. package/dist/types/src/components/defs.d.ts +18 -0
  34. package/dist/types/src/components/defs.d.ts.map +1 -0
  35. package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +1 -0
  36. package/dist/types/src/components/index.d.ts +1 -2
  37. package/dist/types/src/components/index.d.ts.map +1 -1
  38. package/dist/types/src/hooks/useStackDropForElements.d.ts +3 -4
  39. package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
  40. package/dist/types/src/testing/stack-manager.d.ts.map +1 -1
  41. package/dist/types/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +21 -20
  43. package/src/components/{Stack.stories.tsx → Stack/Stack.stories.tsx} +29 -17
  44. package/src/components/{Stack.tsx → Stack/Stack.tsx} +37 -5
  45. package/src/components/Stack/index.ts +5 -0
  46. package/src/components/StackContext.tsx +21 -13
  47. package/src/components/StackItem/StackItem.stories.tsx +49 -0
  48. package/src/components/{StackItem.tsx → StackItem/StackItem.tsx} +90 -11
  49. package/src/components/{StackItemContent.tsx → StackItem/StackItemContent.tsx} +2 -1
  50. package/src/components/{StackItemDragHandle.tsx → StackItem/StackItemDragHandle.tsx} +1 -1
  51. package/src/components/{StackItemHeading.tsx → StackItem/StackItemHeading.tsx} +3 -2
  52. package/src/components/{StackItemResizeHandle.tsx → StackItem/StackItemResizeHandle.tsx} +1 -1
  53. package/src/components/{StackItemSigil.tsx → StackItem/StackItemSigil.tsx} +3 -15
  54. package/src/components/StackItem/index.ts +5 -0
  55. package/src/components/defs.ts +26 -0
  56. package/src/components/{LayoutControls.tsx → deprecated/LayoutControls.tsx} +3 -23
  57. package/src/components/index.ts +2 -2
  58. package/src/hooks/useStackDropForElements.ts +3 -4
  59. package/src/testing/stack-manager.ts +6 -6
  60. package/dist/types/src/components/LayoutControls.d.ts.map +0 -1
  61. package/dist/types/src/components/MenuSignifier.d.ts.map +0 -1
  62. package/dist/types/src/components/Stack.d.ts.map +0 -1
  63. package/dist/types/src/components/Stack.stories.d.ts +0 -8
  64. package/dist/types/src/components/Stack.stories.d.ts.map +0 -1
  65. package/dist/types/src/components/StackItem.d.ts.map +0 -1
  66. package/dist/types/src/components/StackItemContent.d.ts.map +0 -1
  67. package/dist/types/src/components/StackItemDragHandle.d.ts.map +0 -1
  68. package/dist/types/src/components/StackItemHeading.d.ts.map +0 -1
  69. package/dist/types/src/components/StackItemResizeHandle.d.ts.map +0 -1
  70. package/dist/types/src/components/StackItemSigil.d.ts.map +0 -1
  71. /package/dist/types/src/components/{MenuSignifier.d.ts → StackItem/MenuSignifier.d.ts} +0 -0
  72. /package/dist/types/src/components/{StackItemContent.d.ts → StackItem/StackItemContent.d.ts} +0 -0
  73. /package/dist/types/src/components/{StackItemDragHandle.d.ts → StackItem/StackItemDragHandle.d.ts} +0 -0
  74. /package/dist/types/src/components/{StackItemHeading.d.ts → StackItem/StackItemHeading.d.ts} +0 -0
  75. /package/dist/types/src/components/{StackItemResizeHandle.d.ts → StackItem/StackItemResizeHandle.d.ts} +0 -0
  76. /package/dist/types/src/components/{StackItemSigil.d.ts → StackItem/StackItemSigil.d.ts} +0 -0
  77. /package/dist/types/src/components/{LayoutControls.d.ts → deprecated/LayoutControls.d.ts} +0 -0
  78. /package/src/components/{MenuSignifier.tsx → StackItem/MenuSignifier.tsx} +0 -0
@@ -1,36 +1,20 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
- // packages/ui/react-ui-stack/src/components/Stack.tsx
3
+ // packages/ui/react-ui-stack/src/components/Stack/Stack.tsx
4
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
4
5
  import { useArrowNavigationGroup } from "@fluentui/react-tabster";
5
6
  import { composeRefs } from "@radix-ui/react-compose-refs";
6
- import React, { Children, forwardRef, useState as useState2, useMemo } from "react";
7
+ import React, { Children, forwardRef, useState as useState2, useMemo, useCallback } from "react";
7
8
  import { ListItem } from "@dxos/react-ui";
8
9
  import { mx } from "@dxos/react-ui-theme";
9
10
 
10
- // packages/ui/react-ui-stack/src/components/StackContext.tsx
11
- import { createContext, useContext } from "react";
12
- var StackContext = /* @__PURE__ */ createContext({
13
- orientation: "vertical",
14
- rail: true,
15
- size: "intrinsic"
16
- });
17
- var useStack = () => useContext(StackContext);
18
- var StackItemContext = /* @__PURE__ */ createContext({
19
- selfDragHandleRef: () => {
20
- },
21
- size: "min-content",
22
- setSize: () => {
23
- }
24
- });
25
- var useStackItem = () => useContext(StackItemContext);
26
-
27
11
  // packages/ui/react-ui-stack/src/hooks/useStackDropForElements.ts
28
12
  import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
29
13
  import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
30
14
  import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
31
15
  import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
32
16
  import { useLayoutEffect, useState } from "react";
33
- var useStackDropForElements = ({ element, selfDroppable, orientation, id, onRearrange }) => {
17
+ var useStackDropForElements = ({ id, element, selfDroppable, orientation, onRearrange }) => {
34
18
  const [dropping, setDropping] = useState(false);
35
19
  useLayoutEffect(() => {
36
20
  if (!element || !selfDroppable) {
@@ -86,7 +70,30 @@ var useStackDropForElements = ({ element, selfDroppable, orientation, id, onRear
86
70
  };
87
71
  };
88
72
 
89
- // packages/ui/react-ui-stack/src/components/Stack.tsx
73
+ // packages/ui/react-ui-stack/src/components/StackContext.tsx
74
+ import { createContext, useContext } from "react";
75
+ var StackContext = /* @__PURE__ */ createContext({
76
+ orientation: "vertical",
77
+ rail: true,
78
+ size: "intrinsic"
79
+ });
80
+ var useStack = () => useContext(StackContext);
81
+ var idle = {
82
+ type: "idle"
83
+ };
84
+ var StackItemContext = /* @__PURE__ */ createContext({
85
+ selfDragHandleRef: () => {
86
+ },
87
+ size: "min-content",
88
+ setSize: () => {
89
+ },
90
+ state: idle,
91
+ setState: () => {
92
+ }
93
+ });
94
+ var useStackItem = () => useContext(StackItemContext);
95
+
96
+ // packages/ui/react-ui-stack/src/components/Stack/Stack.tsx
90
97
  var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
91
98
  var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
92
99
  var railGridHorizontalContainFitContent = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
@@ -94,182 +101,247 @@ var railGridVerticalContainFitContent = "grid-cols-[[rail-start]_var(--rail-size
94
101
  var autoScrollRootAttributes = {
95
102
  "data-drag-autoscroll": "idle"
96
103
  };
97
- var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), ...props }, forwardedRef) => {
98
- const [stackElement, stackRef] = useState2(null);
99
- const composedItemRef = composeRefs(stackRef, forwardedRef);
100
- const arrowNavigationAttrs = useArrowNavigationGroup({
101
- axis: orientation
102
- });
103
- const styles = {
104
- [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
105
- ...style
106
- };
107
- const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
108
- const { dropping } = useStackDropForElements({
109
- id: props.id,
110
- element: stackElement,
111
- selfDroppable,
112
- orientation,
113
- onRearrange
114
- });
115
- const gridClasses = useMemo(() => {
116
- if (!rail) {
117
- return orientation === "horizontal" ? "grid-rows-1 pli-1" : "grid-cols-1 plb-1";
118
- }
119
- if (orientation === "horizontal") {
120
- return size === "contain-fit-content" ? railGridHorizontalContainFitContent : railGridHorizontal;
121
- } else {
122
- return size === "contain-fit-content" ? railGridVerticalContainFitContent : railGridVertical;
123
- }
124
- }, [
125
- rail,
126
- orientation,
127
- size
128
- ]);
129
- return /* @__PURE__ */ React.createElement(StackContext.Provider, {
130
- value: {
104
+ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), getDropElement, separatorOnScroll, ...props }, forwardedRef) => {
105
+ var _effect = _useSignals();
106
+ try {
107
+ const [stackElement, stackRef] = useState2(null);
108
+ const composedItemRef = composeRefs(stackRef, forwardedRef);
109
+ const arrowNavigationAttrs = useArrowNavigationGroup({
110
+ axis: orientation
111
+ });
112
+ const styles = {
113
+ [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
114
+ ...style
115
+ };
116
+ const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
117
+ const { dropping } = useStackDropForElements({
118
+ id: props.id,
119
+ element: getDropElement && stackElement ? getDropElement(stackElement) : stackElement,
120
+ selfDroppable,
131
121
  orientation,
132
- rail,
133
- size,
134
122
  onRearrange
135
- }
136
- }, /* @__PURE__ */ React.createElement("div", {
137
- ...props,
138
- ...arrowNavigationAttrs,
139
- className: mx("grid relative", gridClasses, (size === "contain" || size === "contain-fit-content") && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 max-bs-full bs-full" : "overflow-y-auto min-is-0 max-is-full is-full"), classNames),
140
- "data-rail": rail,
141
- "aria-orientation": orientation,
142
- style: styles,
143
- ref: composedItemRef
144
- }, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
145
- lineInset: 8,
146
- terminalInset: -8,
147
- gap: -8,
148
- edge: orientation === "horizontal" ? "left" : "top"
149
- })));
123
+ });
124
+ const handleScroll = useCallback(() => {
125
+ if (stackElement && Number.isFinite(separatorOnScroll)) {
126
+ const scrollPosition = orientation === "horizontal" ? stackElement.scrollLeft : stackElement.scrollTop;
127
+ const scrollSize = orientation === "horizontal" ? stackElement.scrollWidth : stackElement.scrollHeight;
128
+ const clientSize = orientation === "horizontal" ? stackElement.clientWidth : stackElement.clientHeight;
129
+ const separatorHost = stackElement.closest("[data-scroll-separator]");
130
+ if (separatorHost) {
131
+ separatorHost.setAttribute("data-scroll-separator", String(scrollPosition > separatorOnScroll));
132
+ separatorHost.setAttribute("data-scroll-separator-end", String(scrollSize - (scrollPosition + clientSize) > separatorOnScroll));
133
+ }
134
+ }
135
+ }, [
136
+ stackElement,
137
+ separatorOnScroll,
138
+ orientation
139
+ ]);
140
+ const gridClasses = useMemo(() => {
141
+ if (!rail) {
142
+ return orientation === "horizontal" ? "grid-rows-1 pli-1" : "grid-cols-1 plb-1";
143
+ }
144
+ if (orientation === "horizontal") {
145
+ return size === "contain-fit-content" ? railGridHorizontalContainFitContent : railGridHorizontal;
146
+ } else {
147
+ return size === "contain-fit-content" ? railGridVerticalContainFitContent : railGridVertical;
148
+ }
149
+ }, [
150
+ rail,
151
+ orientation,
152
+ size
153
+ ]);
154
+ return /* @__PURE__ */ React.createElement(StackContext.Provider, {
155
+ value: {
156
+ orientation,
157
+ rail,
158
+ size,
159
+ onRearrange
160
+ }
161
+ }, /* @__PURE__ */ React.createElement("div", {
162
+ ...props,
163
+ ...arrowNavigationAttrs,
164
+ className: mx("grid relative", gridClasses, (size === "contain" || size === "contain-fit-content") && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 max-bs-full bs-full" : "overflow-y-auto min-is-0 max-is-full is-full"), classNames),
165
+ "data-rail": rail,
166
+ "aria-orientation": orientation,
167
+ style: styles,
168
+ ref: composedItemRef,
169
+ ...Number.isFinite(separatorOnScroll) && {
170
+ onScroll: handleScroll
171
+ }
172
+ }, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
173
+ lineInset: 8,
174
+ terminalInset: -8,
175
+ gap: -8,
176
+ edge: orientation === "horizontal" ? "left" : "top"
177
+ })));
178
+ } finally {
179
+ _effect.f();
180
+ }
150
181
  });
151
182
 
152
- // packages/ui/react-ui-stack/src/components/StackItem.tsx
183
+ // packages/ui/react-ui-stack/src/components/StackItem/StackItem.tsx
184
+ import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
153
185
  import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
154
186
  import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
155
187
  import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
156
- import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
188
+ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
157
189
  import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
158
190
  import { useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
159
191
  import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
160
- import React8, { forwardRef as forwardRef5, useLayoutEffect as useLayoutEffect2, useState as useState4, useCallback } from "react";
192
+ import React8, { forwardRef as forwardRef5, useLayoutEffect as useLayoutEffect2, useState as useState4, useCallback as useCallback2 } from "react";
193
+ import { createPortal } from "react-dom";
161
194
  import { ListItem as ListItem2 } from "@dxos/react-ui";
162
195
  import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
163
196
  import { mx as mx5 } from "@dxos/react-ui-theme";
164
197
 
165
- // packages/ui/react-ui-stack/src/components/StackItemContent.tsx
198
+ // packages/ui/react-ui-stack/src/components/StackItem/StackItemContent.tsx
199
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
166
200
  import React2, { forwardRef as forwardRef2 } from "react";
167
201
  import { mx as mx2 } from "@dxos/react-ui-theme";
168
202
  var StackItemContent = /* @__PURE__ */ forwardRef2(({ children, toolbar, statusbar, classNames, size = "intrinsic", ...props }, forwardedRef) => {
169
- const { size: stackItemSize } = useStack();
170
- return /* @__PURE__ */ React2.createElement("div", {
171
- role: "none",
172
- ...props,
173
- className: mx2("group grid grid-cols-[100%]", stackItemSize === "contain" && "min-bs-0 overflow-hidden", size === "video" ? "aspect-video" : size === "square" && "aspect-square", classNames),
174
- style: {
175
- gridTemplateRows: [
176
- ...toolbar ? [
177
- "var(--rail-action)"
178
- ] : [],
179
- "1fr",
180
- ...statusbar ? [
181
- "var(--statusbar-size)"
182
- ] : []
183
- ].join(" ")
184
- },
185
- ref: forwardedRef
186
- }, children);
203
+ var _effect = _useSignals2();
204
+ try {
205
+ const { size: stackItemSize } = useStack();
206
+ return /* @__PURE__ */ React2.createElement("div", {
207
+ role: "none",
208
+ ...props,
209
+ className: mx2("group grid grid-cols-[100%]", stackItemSize === "contain" && "min-bs-0 overflow-hidden", size === "video" ? "aspect-video" : size === "square" && "aspect-square", classNames),
210
+ style: {
211
+ gridTemplateRows: [
212
+ ...toolbar ? [
213
+ "var(--rail-action)"
214
+ ] : [],
215
+ "1fr",
216
+ ...statusbar ? [
217
+ "var(--statusbar-size)"
218
+ ] : []
219
+ ].join(" ")
220
+ },
221
+ "data-popover-collision-boundary": true,
222
+ ref: forwardedRef
223
+ }, children);
224
+ } finally {
225
+ _effect.f();
226
+ }
187
227
  });
188
228
 
189
- // packages/ui/react-ui-stack/src/components/StackItemDragHandle.tsx
229
+ // packages/ui/react-ui-stack/src/components/StackItem/StackItemDragHandle.tsx
230
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
190
231
  import { Slot } from "@radix-ui/react-slot";
191
232
  import React3 from "react";
192
233
  var StackItemDragHandle = ({ asChild, children }) => {
193
- const { selfDragHandleRef } = useStackItem();
194
- const Root = asChild ? Slot : "div";
195
- return /* @__PURE__ */ React3.createElement(Root, {
196
- ref: selfDragHandleRef,
197
- role: "button"
198
- }, children);
234
+ var _effect = _useSignals3();
235
+ try {
236
+ const { selfDragHandleRef } = useStackItem();
237
+ const Root = asChild ? Slot : "div";
238
+ return /* @__PURE__ */ React3.createElement(Root, {
239
+ ref: selfDragHandleRef,
240
+ role: "button"
241
+ }, children);
242
+ } finally {
243
+ _effect.f();
244
+ }
199
245
  };
200
246
 
201
- // packages/ui/react-ui-stack/src/components/StackItemHeading.tsx
247
+ // packages/ui/react-ui-stack/src/components/StackItem/StackItemHeading.tsx
248
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
202
249
  import { useFocusableGroup } from "@fluentui/react-tabster";
203
250
  import React4, { forwardRef as forwardRef3 } from "react";
204
251
  import { useAttention } from "@dxos/react-ui-attention";
205
252
  import { mx as mx3 } from "@dxos/react-ui-theme";
206
253
  var StackItemHeading = ({ children, classNames, ...props }) => {
207
- const { orientation } = useStack();
208
- const focusableGroupAttrs = useFocusableGroup({
209
- tabBehavior: "limited"
210
- });
211
- return /* @__PURE__ */ React4.createElement("div", {
212
- role: "heading",
213
- ...props,
214
- tabIndex: 0,
215
- ...focusableGroupAttrs,
216
- className: mx3("flex items-center dx-focus-ring-inset-over-all relative !border-is-0", orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", classNames)
217
- }, children);
254
+ var _effect = _useSignals4();
255
+ try {
256
+ const { orientation } = useStack();
257
+ const focusableGroupAttrs = useFocusableGroup({
258
+ tabBehavior: "limited"
259
+ });
260
+ return /* @__PURE__ */ React4.createElement("div", {
261
+ role: "heading",
262
+ ...props,
263
+ tabIndex: 0,
264
+ ...focusableGroupAttrs,
265
+ className: mx3('flex items-center dx-focus-ring-inset-over-all relative !border-is-0 bg-headerSurface border-transparent [[data-scroll-separator="true"]_&]:border-subduedSeparator', orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", orientation === "horizontal" ? "border-be" : "border-ie", classNames)
266
+ }, children);
267
+ } finally {
268
+ _effect.f();
269
+ }
218
270
  };
219
271
  var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related, classNames, ...props }, forwardedRef) => {
220
- const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
221
- return /* @__PURE__ */ React4.createElement("h1", {
222
- ...props,
223
- "data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
224
- className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center", classNames),
225
- ref: forwardedRef
226
- });
272
+ var _effect = _useSignals4();
273
+ try {
274
+ const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
275
+ return /* @__PURE__ */ React4.createElement("h1", {
276
+ ...props,
277
+ "data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
278
+ className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center", classNames),
279
+ ref: forwardedRef
280
+ });
281
+ } finally {
282
+ _effect.f();
283
+ }
227
284
  });
228
285
 
229
- // packages/ui/react-ui-stack/src/components/StackItemResizeHandle.tsx
286
+ // packages/ui/react-ui-stack/src/components/StackItem/StackItemResizeHandle.tsx
287
+ import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
230
288
  import React5 from "react";
231
289
  import { ResizeHandle } from "@dxos/react-ui-dnd";
232
290
  var MIN_WIDTH = 20;
233
291
  var MIN_HEIGHT = 3;
234
292
  var StackItemResizeHandle = () => {
235
- const { orientation } = useStack();
236
- const { setSize, size } = useStackItem();
237
- return /* @__PURE__ */ React5.createElement(ResizeHandle, {
238
- side: orientation === "horizontal" ? "inline-end" : "block-end",
239
- fallbackSize: DEFAULT_EXTRINSIC_SIZE,
240
- minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
241
- size,
242
- onSizeChange: setSize
243
- });
293
+ var _effect = _useSignals5();
294
+ try {
295
+ const { orientation } = useStack();
296
+ const { setSize, size } = useStackItem();
297
+ return /* @__PURE__ */ React5.createElement(ResizeHandle, {
298
+ side: orientation === "horizontal" ? "inline-end" : "block-end",
299
+ fallbackSize: DEFAULT_EXTRINSIC_SIZE,
300
+ minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
301
+ size,
302
+ onSizeChange: setSize
303
+ });
304
+ } finally {
305
+ _effect.f();
306
+ }
244
307
  };
245
308
 
246
- // packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
247
- import React7, { Fragment, forwardRef as forwardRef4, useRef, useState as useState3 } from "react";
309
+ // packages/ui/react-ui-stack/src/components/StackItem/StackItemSigil.tsx
310
+ import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
311
+ import React7, { Fragment, forwardRef as forwardRef4, useState as useState3 } from "react";
248
312
  import { keySymbols } from "@dxos/keyboard";
249
313
  import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
250
314
  import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
251
315
  import { descriptionText, mx as mx4 } from "@dxos/react-ui-theme";
252
316
  import { getHostPlatform } from "@dxos/util";
253
317
 
254
- // packages/ui/react-ui-stack/src/components/MenuSignifier.tsx
318
+ // packages/ui/react-ui-stack/src/components/StackItem/MenuSignifier.tsx
319
+ import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
255
320
  import React6 from "react";
256
- var MenuSignifierHorizontal = () => /* @__PURE__ */ React6.createElement("svg", {
257
- className: "absolute block-end-[7px]",
258
- width: 20,
259
- height: 2,
260
- viewBox: "0 0 20 2",
261
- stroke: "currentColor",
262
- opacity: 0.5
263
- }, /* @__PURE__ */ React6.createElement("line", {
264
- x1: 0.5,
265
- y1: 0.75,
266
- x2: 19,
267
- y2: 0.75,
268
- strokeWidth: 1.25,
269
- strokeLinecap: "round",
270
- strokeDasharray: "6 20",
271
- strokeDashoffset: "-6.5"
272
- }));
321
+ var MenuSignifierHorizontal = () => {
322
+ var _effect = _useSignals6();
323
+ try {
324
+ return /* @__PURE__ */ React6.createElement("svg", {
325
+ className: "absolute block-end-[7px]",
326
+ width: 20,
327
+ height: 2,
328
+ viewBox: "0 0 20 2",
329
+ stroke: "currentColor",
330
+ opacity: 0.5
331
+ }, /* @__PURE__ */ React6.createElement("line", {
332
+ x1: 0.5,
333
+ y1: 0.75,
334
+ x2: 19,
335
+ y2: 0.75,
336
+ strokeWidth: 1.25,
337
+ strokeLinecap: "round",
338
+ strokeDasharray: "6 20",
339
+ strokeDashoffset: "-6.5"
340
+ }));
341
+ } finally {
342
+ _effect.f();
343
+ }
344
+ };
273
345
 
274
346
  // packages/ui/react-ui-stack/src/translations.ts
275
347
  var translationKey = "stack";
@@ -289,223 +361,282 @@ var translations_default = [
289
361
  }
290
362
  ];
291
363
 
292
- // packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
364
+ // packages/ui/react-ui-stack/src/components/StackItem/StackItemSigil.tsx
293
365
  var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNames, related, isMenu = true, children, ...props }, forwardedRef) => {
294
- const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
295
- const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
296
- return /* @__PURE__ */ React7.createElement(Button, {
297
- ...props,
298
- variant,
299
- classNames: [
300
- "shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative app-no-drag",
301
- classNames
302
- ],
303
- ref: forwardedRef
304
- }, isMenu && /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
366
+ var _effect = _useSignals7();
367
+ try {
368
+ const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
369
+ const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
370
+ return /* @__PURE__ */ React7.createElement(Button, {
371
+ ...props,
372
+ variant,
373
+ classNames: [
374
+ "shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative app-no-drag",
375
+ classNames
376
+ ],
377
+ ref: forwardedRef
378
+ }, isMenu && /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
379
+ } finally {
380
+ _effect.f();
381
+ }
305
382
  });
306
383
  var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
307
- const { t } = useTranslation(translationKey);
308
- const suppressNextTooltip = useRef(false);
309
- const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
310
- const hasActions = actionGroups && actionGroups.length > 0;
311
- const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
312
- attendableId,
313
- related,
314
- isMenu: hasActions,
315
- // TODO(wittjosiah): Better disabling of interactive styles when no action are available.
316
- // Remove underscore icon when no actions are available?
317
- classNames: !hasActions && "cursor-default"
318
- }, /* @__PURE__ */ React7.createElement("span", {
319
- className: "sr-only"
320
- }, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
321
- icon,
322
- size: 5
323
- }));
324
- if (!hasActions) {
325
- return button;
326
- }
327
- return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
328
- open: optionsMenuOpen,
329
- onOpenChange: (nextOpen) => {
330
- if (!nextOpen) {
331
- suppressNextTooltip.current = true;
332
- }
333
- return setOptionsMenuOpen(nextOpen);
384
+ var _effect = _useSignals7();
385
+ try {
386
+ const { t } = useTranslation(translationKey);
387
+ const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
388
+ const hasActions = actionGroups && actionGroups.length > 0;
389
+ const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
390
+ attendableId,
391
+ related,
392
+ isMenu: hasActions,
393
+ // TODO(wittjosiah): Better disabling of interactive styles when no action are available.
394
+ // Remove underscore icon when no actions are available?
395
+ classNames: !hasActions && "cursor-default"
396
+ }, /* @__PURE__ */ React7.createElement("span", {
397
+ className: "sr-only"
398
+ }, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
399
+ icon,
400
+ size: 5
401
+ }));
402
+ if (!hasActions) {
403
+ return button;
334
404
  }
335
- }, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
336
- asChild: true,
337
- ref: forwardedRef
338
- }, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
339
- classNames: "z-[31]"
340
- }, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
341
- const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
342
- return /* @__PURE__ */ React7.createElement(Fragment, {
343
- key: index
344
- }, separator, actions.map((action) => {
345
- const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
346
- const menuItemType = action.properties.menuItemType;
347
- const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
348
- return /* @__PURE__ */ React7.createElement(Root, {
349
- key: action.id,
350
- onClick: (event) => {
351
- if (action.properties.disabled) {
352
- return;
405
+ return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
406
+ open: optionsMenuOpen,
407
+ onOpenChange: setOptionsMenuOpen
408
+ }, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
409
+ asChild: true,
410
+ ref: forwardedRef
411
+ }, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
412
+ classNames: "z-[31]"
413
+ }, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
414
+ const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
415
+ return /* @__PURE__ */ React7.createElement(Fragment, {
416
+ key: index
417
+ }, separator, actions.map((action) => {
418
+ const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
419
+ const menuItemType = action.properties.menuItemType;
420
+ const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
421
+ return /* @__PURE__ */ React7.createElement(Root, {
422
+ key: action.id,
423
+ onClick: (event) => {
424
+ if (action.properties.disabled) {
425
+ return;
426
+ }
427
+ event.stopPropagation();
428
+ setOptionsMenuOpen(false);
429
+ onAction?.(action);
430
+ },
431
+ classNames: "gap-2",
432
+ disabled: action.properties.disabled,
433
+ checked: menuItemType === "toggle" ? action.properties.isChecked : void 0,
434
+ ...action.properties?.testId && {
435
+ "data-testid": action.properties.testId
353
436
  }
354
- event.stopPropagation();
355
- suppressNextTooltip.current = true;
356
- setOptionsMenuOpen(false);
357
- onAction?.(action);
358
- },
359
- classNames: "gap-2",
360
- disabled: action.properties.disabled,
361
- checked: menuItemType === "toggle" ? action.properties.isChecked : void 0,
362
- ...action.properties?.testId && {
363
- "data-testid": action.properties.testId
364
- }
365
- }, /* @__PURE__ */ React7.createElement(Icon, {
366
- icon: action.properties.icon ?? "ph--placeholder--regular",
367
- size: 4
368
- }), /* @__PURE__ */ React7.createElement("span", {
369
- className: "grow truncate"
370
- }, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React7.createElement(DropdownMenu.ItemIndicator, {
371
- asChild: true
372
- }, /* @__PURE__ */ React7.createElement(Icon, {
373
- icon: "ph--check--regular",
374
- size: 4
375
- })), shortcut && /* @__PURE__ */ React7.createElement("span", {
376
- className: mx4("shrink-0", descriptionText)
377
- }, keySymbols(shortcut).join("")));
378
- }));
379
- }), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
437
+ }, /* @__PURE__ */ React7.createElement(Icon, {
438
+ icon: action.properties.icon ?? "ph--placeholder--regular",
439
+ size: 4
440
+ }), /* @__PURE__ */ React7.createElement("span", {
441
+ className: "grow truncate"
442
+ }, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React7.createElement(DropdownMenu.ItemIndicator, {
443
+ asChild: true
444
+ }, /* @__PURE__ */ React7.createElement(Icon, {
445
+ icon: "ph--check--regular",
446
+ size: 4
447
+ })), shortcut && /* @__PURE__ */ React7.createElement("span", {
448
+ className: mx4("shrink-0", descriptionText)
449
+ }, keySymbols(shortcut).join("")));
450
+ }));
451
+ }), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
452
+ } finally {
453
+ _effect.f();
454
+ }
380
455
  });
381
456
 
382
- // packages/ui/react-ui-stack/src/components/StackItem.tsx
457
+ // packages/ui/react-ui-stack/src/components/StackItem/StackItem.tsx
383
458
  var DEFAULT_HORIZONTAL_SIZE = 48;
384
459
  var DEFAULT_VERTICAL_SIZE = "min-content";
385
460
  var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
386
- var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
387
- const [itemElement, itemRef] = useState4(null);
388
- const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
389
- const [closestEdge, setEdge] = useState4(null);
390
- const { orientation, rail, onRearrange } = useStack();
391
- const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(propsSize);
392
- const Root = role ?? "div";
393
- const composedItemRef = composeRefs2(itemRef, forwardedRef);
394
- const setSize = useCallback((nextSize, commit) => {
395
- setInternalSize(nextSize);
396
- if (commit) {
397
- onSizeChange?.(nextSize);
398
- }
399
- }, [
400
- onSizeChange
401
- ]);
402
- const type = orientation === "horizontal" ? "column" : "card";
403
- useLayoutEffect2(() => {
404
- if (!itemElement || !onRearrange || disableRearrange) {
405
- return;
406
- }
407
- return combine2(draggable({
408
- element: itemElement,
409
- ...selfDragHandleElement && {
410
- dragHandle: selfDragHandleElement
411
- },
412
- getInitialData: () => ({
413
- id: item.id,
414
- type
415
- }),
416
- onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
417
- document.body.setAttribute("data-drag-preview", "true");
418
- scrollJustEnoughIntoView({
419
- element: source.element
420
- });
421
- const { x, y } = preserveOffsetOnSource({
422
- element: source.element,
423
- input: location.current.input
424
- })({
425
- container: source.element.offsetParent ?? document.body
426
- });
427
- nativeSetDragImage?.(source.element, x, y);
428
- },
429
- onDragStart: () => {
430
- document.body.removeAttribute("data-drag-preview");
431
- itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
432
- },
433
- onDrop: () => {
434
- itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
461
+ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, prevSiblingId, nextSiblingId, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
462
+ var _effect = _useSignals8();
463
+ try {
464
+ const [itemElement, itemRef] = useState4(null);
465
+ const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
466
+ const [closestEdge, setEdge] = useState4(null);
467
+ const [sourceId, setSourceId] = useState4(null);
468
+ const [dragState, setDragState] = useState4(idle);
469
+ const { orientation, rail, onRearrange } = useStack();
470
+ const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(propsSize);
471
+ const Root = role ?? "div";
472
+ const composedItemRef = composeRefs2(itemRef, forwardedRef);
473
+ const setSize = useCallback2((nextSize, commit) => {
474
+ setInternalSize(nextSize);
475
+ if (commit) {
476
+ onSizeChange?.(nextSize);
435
477
  }
436
- }), dropTargetForElements2({
437
- element: itemElement,
438
- getData: ({ input, element }) => {
439
- return attachClosestEdge2({
478
+ }, [
479
+ onSizeChange
480
+ ]);
481
+ const type = orientation === "horizontal" ? "column" : "card";
482
+ useLayoutEffect2(() => {
483
+ if (!itemElement || !onRearrange || disableRearrange) {
484
+ return;
485
+ }
486
+ return combine2(draggable({
487
+ element: itemElement,
488
+ ...selfDragHandleElement && {
489
+ dragHandle: selfDragHandleElement
490
+ },
491
+ getInitialData: () => ({
440
492
  id: item.id,
441
493
  type
442
- }, {
443
- input,
444
- element,
445
- allowedEdges: orientation === "horizontal" ? [
446
- "left",
447
- "right"
448
- ] : [
449
- "top",
450
- "bottom"
451
- ]
452
- });
453
- },
454
- onDragEnter: ({ self, source }) => {
455
- if (source.data.type === self.data.type) {
456
- setEdge(extractClosestEdge2(self.data));
457
- }
458
- },
459
- onDrag: ({ self, source }) => {
460
- if (source.data.type === self.data.type) {
461
- setEdge(extractClosestEdge2(self.data));
494
+ }),
495
+ onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
496
+ document.body.setAttribute("data-drag-preview", "true");
497
+ const offsetFn = preserveOffsetOnSource({
498
+ element: source.element,
499
+ input: location.current.input
500
+ });
501
+ const rect = source.element.getBoundingClientRect();
502
+ setCustomNativeDragPreview({
503
+ nativeSetDragImage,
504
+ getOffset: ({ container }) => {
505
+ return offsetFn({
506
+ container
507
+ });
508
+ },
509
+ render: ({ container }) => {
510
+ container.style.width = rect.width + "px";
511
+ setDragState({
512
+ type: "preview",
513
+ container,
514
+ item
515
+ });
516
+ return () => {
517
+ };
518
+ }
519
+ });
520
+ },
521
+ onDragStart: () => {
522
+ document.body.removeAttribute("data-drag-preview");
523
+ itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
524
+ setDragState({
525
+ type: "is-dragging",
526
+ item
527
+ });
528
+ },
529
+ onDrop: () => {
530
+ itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
531
+ setDragState(idle);
462
532
  }
463
- },
464
- onDragLeave: () => setEdge(null),
465
- onDrop: ({ self, source }) => {
466
- setEdge(null);
467
- if (source.data.type === self.data.type) {
468
- onRearrange(source.data, self.data, extractClosestEdge2(self.data));
533
+ }), dropTargetForElements2({
534
+ element: itemElement,
535
+ getData: ({ input, element }) => {
536
+ return attachClosestEdge2({
537
+ id: item.id,
538
+ type
539
+ }, {
540
+ input,
541
+ element,
542
+ allowedEdges: orientation === "horizontal" ? [
543
+ "left",
544
+ "right"
545
+ ] : [
546
+ "top",
547
+ "bottom"
548
+ ]
549
+ });
550
+ },
551
+ onDragEnter: ({ self, source }) => {
552
+ if (source.data.type === self.data.type) {
553
+ setEdge(extractClosestEdge2(self.data));
554
+ setSourceId(source.data.id);
555
+ }
556
+ },
557
+ onDrag: ({ self, source }) => {
558
+ if (source.data.type === self.data.type) {
559
+ setEdge(extractClosestEdge2(self.data));
560
+ setSourceId(source.data.id);
561
+ }
562
+ },
563
+ onDragLeave: () => {
564
+ setEdge(null);
565
+ setSourceId(null);
566
+ },
567
+ onDrop: ({ self, source }) => {
568
+ setEdge(null);
569
+ setSourceId(null);
570
+ if (source.data.type === self.data.type) {
571
+ onRearrange(source.data, self.data, extractClosestEdge2(self.data));
572
+ }
469
573
  }
574
+ }));
575
+ }, [
576
+ orientation,
577
+ item,
578
+ onRearrange,
579
+ selfDragHandleElement,
580
+ itemElement
581
+ ]);
582
+ const focusableGroupAttrs = useFocusableGroup2({
583
+ tabBehavior: "limited"
584
+ });
585
+ const shouldShowDropIndicator = () => {
586
+ if (!closestEdge || !sourceId) {
587
+ return false;
470
588
  }
471
- }));
472
- }, [
473
- orientation,
474
- item,
475
- onRearrange,
476
- selfDragHandleElement,
477
- itemElement
478
- ]);
479
- const focusableGroupAttrs = useFocusableGroup2({
480
- tabBehavior: "limited"
481
- });
482
- return /* @__PURE__ */ React8.createElement(StackItemContext.Provider, {
483
- value: {
484
- selfDragHandleRef,
485
- size,
486
- setSize
487
- }
488
- }, /* @__PURE__ */ React8.createElement(Root, {
489
- ...props,
490
- tabIndex: 0,
491
- ...focusableGroupAttrs,
492
- className: mx5("group/stack-item grid relative", focusIndicatorVariant === "over-all" ? "dx-focus-ring-inset-over-all" : orientation === "horizontal" ? "dx-focus-ring-group-x" : "dx-focus-ring-group-y", orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), classNames),
493
- "data-dx-stack-item": true,
494
- ...resizeAttributes,
495
- style: {
496
- ...sizeStyle(size, orientation),
497
- ...Number.isFinite(order) && {
498
- [orientation === "horizontal" ? "gridColumn" : "gridRow"]: `${order}`
589
+ if (sourceId === item.id) {
590
+ return false;
591
+ }
592
+ const isTrailingEdgeOfPrevSibling = prevSiblingId !== void 0 && sourceId === prevSiblingId && (orientation === "horizontal" && closestEdge === "left" || orientation === "vertical" && closestEdge === "top");
593
+ if (isTrailingEdgeOfPrevSibling) {
594
+ return false;
595
+ }
596
+ const isLeadingEdgeOfNextSibling = nextSiblingId !== void 0 && sourceId === nextSiblingId && (orientation === "horizontal" && closestEdge === "right" || orientation === "vertical" && closestEdge === "bottom");
597
+ if (isLeadingEdgeOfNextSibling) {
598
+ return false;
599
+ }
600
+ return true;
601
+ };
602
+ return /* @__PURE__ */ React8.createElement(StackItemContext.Provider, {
603
+ value: {
604
+ selfDragHandleRef,
605
+ size,
606
+ setSize,
607
+ state: dragState,
608
+ setState: setDragState
609
+ }
610
+ }, /* @__PURE__ */ React8.createElement(Root, {
611
+ ...props,
612
+ tabIndex: 0,
613
+ ...focusableGroupAttrs,
614
+ className: mx5("group/stack-item grid relative", focusIndicatorVariant === "over-all" ? "dx-focus-ring-inset-over-all" : orientation === "horizontal" ? "dx-focus-ring-group-x" : "dx-focus-ring-group-y", orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), classNames),
615
+ "data-dx-stack-item": true,
616
+ ...resizeAttributes,
617
+ style: {
618
+ ...sizeStyle(size, orientation),
619
+ ...Number.isFinite(order) && {
620
+ [orientation === "horizontal" ? "gridColumn" : "gridRow"]: `${order}`
621
+ },
622
+ ...style
499
623
  },
500
- ...style
501
- },
502
- ref: composedItemRef
503
- }, children, closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
504
- lineInset: 8,
505
- terminalInset: -8,
506
- edge: closestEdge
507
- })));
624
+ ref: composedItemRef
625
+ }, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
626
+ lineInset: 8,
627
+ terminalInset: -8,
628
+ edge: closestEdge
629
+ })));
630
+ } finally {
631
+ _effect.f();
632
+ }
508
633
  });
634
+ var StackItemDragPreview = ({ children }) => {
635
+ const { state } = useStackItem();
636
+ return state?.type === "preview" ? /* @__PURE__ */ createPortal(children({
637
+ item: state.item
638
+ }), state.container) : null;
639
+ };
509
640
  var StackItem = {
510
641
  Root: StackItemRoot,
511
642
  Content: StackItemContent,
@@ -514,90 +645,22 @@ var StackItem = {
514
645
  ResizeHandle: StackItemResizeHandle,
515
646
  DragHandle: StackItemDragHandle,
516
647
  Sigil: StackItemSigil,
517
- SigilButton: StackItemSigilButton
648
+ SigilButton: StackItemSigilButton,
649
+ DragPreview: StackItemDragPreview
518
650
  };
519
-
520
- // packages/ui/react-ui-stack/src/components/LayoutControls.tsx
521
- import React9, { forwardRef as forwardRef6 } from "react";
522
- import { Button as Button2, ButtonGroup, Icon as Icon2, Tooltip, useTranslation as useTranslation2 } from "@dxos/react-ui";
523
- var LayoutControl = ({ icon, label, ...props }) => {
524
- return /* @__PURE__ */ React9.createElement(Tooltip.Root, null, /* @__PURE__ */ React9.createElement(Tooltip.Trigger, {
525
- asChild: true
526
- }, /* @__PURE__ */ React9.createElement(Button2, {
527
- variant: "ghost",
528
- ...props
529
- }, /* @__PURE__ */ React9.createElement("span", {
530
- className: "sr-only"
531
- }, label), /* @__PURE__ */ React9.createElement(Icon2, {
532
- icon
533
- }))), /* @__PURE__ */ React9.createElement(Tooltip.Portal, null, /* @__PURE__ */ React9.createElement(Tooltip.Content, {
534
- side: "bottom"
535
- }, label)));
536
- };
537
- var LayoutControls = /* @__PURE__ */ forwardRef6(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
538
- const { t } = useTranslation2(translationKey);
539
- const buttonClassNames = variant === "hide-disabled" ? "disabled:hidden !p-1" : "!p-1";
540
- return /* @__PURE__ */ React9.createElement(ButtonGroup, {
541
- ...props,
542
- ref: forwardedRef
543
- }, pin && !isSolo && [
544
- "both",
545
- "start"
546
- ].includes(pin) && /* @__PURE__ */ React9.createElement(LayoutControl, {
547
- label: t("pin start label"),
548
- variant: "ghost",
549
- classNames: buttonClassNames,
550
- onClick: () => onClick?.("pin-start"),
551
- icon: "ph--caret-line-left--regular"
552
- }), can.solo && /* @__PURE__ */ React9.createElement(LayoutControl, {
553
- label: t("solo layout label"),
554
- classNames: buttonClassNames,
555
- onClick: () => onClick?.("solo"),
556
- icon: isSolo ? "ph--arrows-in--regular" : "ph--arrows-out--regular"
557
- }), !isSolo && can.solo && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(LayoutControl, {
558
- label: t("increment start label"),
559
- disabled: !can.incrementStart,
560
- classNames: buttonClassNames,
561
- onClick: () => onClick?.("increment-start"),
562
- icon: "ph--caret-left--regular"
563
- }), /* @__PURE__ */ React9.createElement(LayoutControl, {
564
- label: t("increment end label"),
565
- disabled: !can.incrementEnd,
566
- classNames: buttonClassNames,
567
- onClick: () => onClick?.("increment-end"),
568
- icon: "ph--caret-right--regular"
569
- })), pin && !isSolo && [
570
- "both",
571
- "end"
572
- ].includes(pin) && /* @__PURE__ */ React9.createElement(LayoutControl, {
573
- label: t("pin end label"),
574
- classNames: buttonClassNames,
575
- onClick: () => onClick?.("pin-end"),
576
- icon: "ph--caret-line-right--regular"
577
- }), close && !isSolo && /* @__PURE__ */ React9.createElement(LayoutControl, {
578
- label: t(`${typeof close === "string" ? "minify" : "close"} label`),
579
- classNames: buttonClassNames,
580
- onClick: () => onClick?.("close"),
581
- "data-testid": "layoutHeading.close",
582
- icon: close === "minify-start" ? "ph--caret-line-left--regular" : close === "minify-end" ? "ph--caret-line-right--regular" : "ph--x--regular"
583
- }), children);
584
- });
585
651
  export {
586
652
  DEFAULT_EXTRINSIC_SIZE,
587
653
  DEFAULT_HORIZONTAL_SIZE,
588
654
  DEFAULT_VERTICAL_SIZE,
589
- LayoutControls,
590
655
  Stack,
591
656
  StackContext,
592
657
  StackItem,
593
- StackItemContext,
658
+ StackItemDragPreview,
594
659
  autoScrollRootAttributes,
595
660
  railGridHorizontal,
596
661
  railGridHorizontalContainFitContent,
597
662
  railGridVertical,
598
663
  railGridVerticalContainFitContent,
599
- translations_default as translations,
600
- useStack,
601
- useStackItem
664
+ translations_default as translations
602
665
  };
603
666
  //# sourceMappingURL=index.mjs.map