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