@dxos/react-ui-stack 0.7.4 → 0.7.5-labs.071a3e2

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 (43) hide show
  1. package/dist/lib/browser/index.mjs +228 -130
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +229 -129
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +228 -130
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/LayoutControls.d.ts.map +1 -1
  11. package/dist/types/src/components/Stack.d.ts +3 -0
  12. package/dist/types/src/components/Stack.d.ts.map +1 -1
  13. package/dist/types/src/components/Stack.stories.d.ts.map +1 -1
  14. package/dist/types/src/components/StackContext.d.ts +9 -4
  15. package/dist/types/src/components/StackContext.d.ts.map +1 -1
  16. package/dist/types/src/components/StackItem.d.ts +14 -9
  17. package/dist/types/src/components/StackItem.d.ts.map +1 -1
  18. package/dist/types/src/components/StackItemContent.d.ts +35 -2
  19. package/dist/types/src/components/StackItemContent.d.ts.map +1 -1
  20. package/dist/types/src/components/StackItemDragHandle.d.ts +6 -0
  21. package/dist/types/src/components/StackItemDragHandle.d.ts.map +1 -0
  22. package/dist/types/src/components/StackItemHeading.d.ts.map +1 -1
  23. package/dist/types/src/components/StackItemResizeHandle.d.ts +1 -0
  24. package/dist/types/src/components/StackItemResizeHandle.d.ts.map +1 -1
  25. package/dist/types/src/components/StackItemSigil.d.ts.map +1 -1
  26. package/dist/types/src/components/index.d.ts +1 -0
  27. package/dist/types/src/components/index.d.ts.map +1 -1
  28. package/dist/types/tsconfig.tsbuildinfo +1 -0
  29. package/package.json +28 -26
  30. package/src/components/LayoutControls.tsx +1 -3
  31. package/src/components/Stack.stories.tsx +5 -4
  32. package/src/components/Stack.tsx +73 -10
  33. package/src/components/StackContext.tsx +13 -4
  34. package/src/components/StackItem.tsx +49 -16
  35. package/src/components/StackItemContent.tsx +48 -33
  36. package/src/components/StackItemDragHandle.tsx +22 -0
  37. package/src/components/StackItemHeading.tsx +3 -5
  38. package/src/components/StackItemResizeHandle.tsx +27 -15
  39. package/src/components/StackItemSigil.tsx +90 -103
  40. package/src/components/index.ts +1 -0
  41. package/dist/types/src/testing/EditorContent.d.ts +0 -8
  42. package/dist/types/src/testing/EditorContent.d.ts.map +0 -1
  43. package/src/testing/EditorContent.tsx +0 -60
@@ -1,6 +1,12 @@
1
1
  // packages/ui/react-ui-stack/src/components/Stack.tsx
2
+ import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
3
+ import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
4
+ import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
5
+ import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
2
6
  import { useArrowNavigationGroup } from "@fluentui/react-tabster";
3
- import React, { Children, forwardRef } from "react";
7
+ import { composeRefs } from "@radix-ui/react-compose-refs";
8
+ import React, { Children, forwardRef, useLayoutEffect, useState } from "react";
9
+ import { ListItem } from "@dxos/react-ui";
4
10
  import { mx } from "@dxos/react-ui-theme";
5
11
 
6
12
  // packages/ui/react-ui-stack/src/components/StackContext.tsx
@@ -8,8 +14,7 @@ import { createContext, useContext } from "react";
8
14
  var StackContext = /* @__PURE__ */ createContext({
9
15
  orientation: "vertical",
10
16
  rail: true,
11
- size: "intrinsic",
12
- separators: true
17
+ size: "intrinsic"
13
18
  });
14
19
  var useStack = () => useContext(StackContext);
15
20
  var StackItemContext = /* @__PURE__ */ createContext({
@@ -24,7 +29,13 @@ var useStackItem = () => useContext(StackItemContext);
24
29
  // packages/ui/react-ui-stack/src/components/Stack.tsx
25
30
  var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
26
31
  var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
27
- var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, separators = true, size = "intrinsic", itemsCount = Children.count(children), ...props }, forwardedRef) => {
32
+ var autoScrollRootAttributes = {
33
+ "data-drag-autoscroll": "idle"
34
+ };
35
+ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), ...props }, forwardedRef) => {
36
+ const [stackElement, stackRef] = useState(null);
37
+ const composedItemRef = composeRefs(stackRef, forwardedRef);
38
+ const [dropping, setDropping] = useState(false);
28
39
  const arrowNavigationGroup = useArrowNavigationGroup({
29
40
  axis: orientation
30
41
  });
@@ -32,41 +43,96 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
32
43
  [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content)`,
33
44
  ...style
34
45
  };
46
+ const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
47
+ useLayoutEffect(() => {
48
+ if (!stackElement || !selfDroppable) {
49
+ return;
50
+ }
51
+ const acceptSourceType = orientation === "horizontal" ? "column" : "card";
52
+ return combine(dropTargetForElements({
53
+ element: stackElement,
54
+ getData: ({ input, element }) => {
55
+ return attachClosestEdge({
56
+ id: props.id,
57
+ type: orientation === "horizontal" ? "card" : "column"
58
+ }, {
59
+ input,
60
+ element,
61
+ allowedEdges: [
62
+ orientation === "horizontal" ? "left" : "top"
63
+ ]
64
+ });
65
+ },
66
+ onDragEnter: ({ source }) => {
67
+ if (source.data.type === acceptSourceType) {
68
+ setDropping(true);
69
+ }
70
+ },
71
+ onDrag: ({ source }) => {
72
+ if (source.data.type === acceptSourceType) {
73
+ setDropping(true);
74
+ }
75
+ },
76
+ onDragLeave: () => setDropping(false),
77
+ onDrop: ({ self, source }) => {
78
+ setDropping(false);
79
+ if (source.data.type === acceptSourceType && selfDroppable) {
80
+ onRearrange(source.data, self.data, extractClosestEdge(self.data));
81
+ }
82
+ }
83
+ }), autoScrollForElements({
84
+ element: stackElement,
85
+ getAllowedAxis: () => orientation
86
+ }));
87
+ }, [
88
+ stackElement,
89
+ selfDroppable,
90
+ orientation
91
+ ]);
35
92
  return /* @__PURE__ */ React.createElement(StackContext.Provider, {
36
93
  value: {
37
94
  orientation,
38
95
  rail,
39
96
  size,
40
- separators
97
+ onRearrange
41
98
  }
42
99
  }, /* @__PURE__ */ React.createElement("div", {
43
100
  ...props,
44
101
  ...arrowNavigationGroup,
45
- className: mx("grid relative", rail ? orientation === "horizontal" ? railGridHorizontal : railGridVertical : orientation === "horizontal" ? "grid-rows-1" : "grid-cols-1", size === "contain" && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 bs-full max-bs-full" : "overflow-y-auto min-is-0 is-full max-is-full"), separators && (orientation === "horizontal" ? "divide-separator divide-x" : "divide-separator divide-y"), classNames),
102
+ className: mx("grid relative", rail ? orientation === "horizontal" ? railGridHorizontal : railGridVertical : orientation === "horizontal" ? "grid-rows-1 pli-1" : "grid-cols-1 plb-1", size === "contain" && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 bs-full max-bs-full" : "overflow-y-auto min-is-0 is-full max-is-full"), classNames),
103
+ "data-rail": rail,
46
104
  "aria-orientation": orientation,
47
105
  style: styles,
48
- ref: forwardedRef
49
- }, children));
106
+ ref: composedItemRef
107
+ }, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
108
+ lineInset: 8,
109
+ terminalInset: -8,
110
+ gap: -8,
111
+ edge: orientation === "horizontal" ? "left" : "top"
112
+ })));
50
113
  });
51
114
 
52
115
  // packages/ui/react-ui-stack/src/components/StackItem.tsx
53
- import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
54
- import { draggable as draggable2, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
55
- import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
116
+ import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
117
+ import { draggable as draggable2, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
118
+ import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
119
+ import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
120
+ import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
56
121
  import { useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
57
- import { composeRefs } from "@radix-ui/react-compose-refs";
58
- import React7, { forwardRef as forwardRef4, useLayoutEffect as useLayoutEffect2, useState as useState2, useCallback } from "react";
122
+ import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
123
+ import React8, { forwardRef as forwardRef5, useLayoutEffect as useLayoutEffect3, useState as useState3, useCallback } from "react";
124
+ import { ListItem as ListItem2 } from "@dxos/react-ui";
59
125
  import { mx as mx6 } from "@dxos/react-ui-theme";
60
126
 
61
127
  // packages/ui/react-ui-stack/src/components/StackItemContent.tsx
62
- import React2 from "react";
128
+ import React2, { forwardRef as forwardRef2 } from "react";
63
129
  import { mx as mx2 } from "@dxos/react-ui-theme";
64
- var StackItemContent = ({ children, toolbar = true, statusbar, classNames, ...props }) => {
65
- const { size, separators } = useStack();
130
+ var StackItemContent = /* @__PURE__ */ forwardRef2(({ children, toolbar, statusbar, classNames, size = "intrinsic", ...props }, forwardedRef) => {
131
+ const { size: stackItemSize } = useStack();
66
132
  return /* @__PURE__ */ React2.createElement("div", {
67
133
  role: "none",
68
134
  ...props,
69
- className: mx2("group grid grid-cols-[100%]", size === "contain" && "min-bs-0 overflow-hidden", separators && "divide-separator divide-y", classNames),
135
+ className: mx2("group grid grid-cols-[100%]", stackItemSize === "contain" && "min-bs-0 overflow-hidden", size === "video" ? "aspect-video" : size === "square" && "aspect-square", classNames),
70
136
  style: {
71
137
  gridTemplateRows: [
72
138
  ...toolbar ? [
@@ -77,36 +143,47 @@ var StackItemContent = ({ children, toolbar = true, statusbar, classNames, ...pr
77
143
  "var(--statusbar-size)"
78
144
  ] : []
79
145
  ].join(" ")
80
- }
146
+ },
147
+ ref: forwardedRef
148
+ }, children);
149
+ });
150
+
151
+ // packages/ui/react-ui-stack/src/components/StackItemDragHandle.tsx
152
+ import { Slot } from "@radix-ui/react-slot";
153
+ import React3 from "react";
154
+ var StackItemDragHandle = ({ asChild, children }) => {
155
+ const { selfDragHandleRef } = useStackItem();
156
+ const Root = asChild ? Slot : "div";
157
+ return /* @__PURE__ */ React3.createElement(Root, {
158
+ ref: selfDragHandleRef,
159
+ role: "button"
81
160
  }, children);
82
161
  };
83
162
 
84
163
  // packages/ui/react-ui-stack/src/components/StackItemHeading.tsx
85
164
  import { useFocusableGroup } from "@fluentui/react-tabster";
86
- import React3, { forwardRef as forwardRef2 } from "react";
165
+ import React4, { forwardRef as forwardRef3 } from "react";
87
166
  import { useAttention } from "@dxos/react-ui-attention";
88
167
  import { mx as mx3 } from "@dxos/react-ui-theme";
89
168
  var StackItemHeading = ({ children, classNames, ...props }) => {
90
169
  const { orientation } = useStack();
91
- const { selfDragHandleRef } = useStackItem();
92
170
  const focusableGroupAttrs = useFocusableGroup({
93
171
  tabBehavior: "limited"
94
172
  });
95
- return /* @__PURE__ */ React3.createElement("div", {
173
+ return /* @__PURE__ */ React4.createElement("div", {
96
174
  role: "heading",
97
175
  ...props,
98
176
  tabIndex: 0,
99
177
  ...focusableGroupAttrs,
100
- className: mx3("flex items-center ch-focus-ring-inset-over-all relative !border-is-0", orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", classNames),
101
- ref: selfDragHandleRef
178
+ 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)
102
179
  }, children);
103
180
  };
104
- var StackItemHeadingLabel = /* @__PURE__ */ forwardRef2(({ attendableId, related, classNames, ...props }, forwardedRef) => {
181
+ var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related, classNames, ...props }, forwardedRef) => {
105
182
  const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
106
- return /* @__PURE__ */ React3.createElement("h1", {
183
+ return /* @__PURE__ */ React4.createElement("h1", {
107
184
  ...props,
108
185
  "data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
109
- className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText", classNames),
186
+ className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center", classNames),
110
187
  ref: forwardedRef
111
188
  });
112
189
  });
@@ -115,10 +192,11 @@ var StackItemHeadingLabel = /* @__PURE__ */ forwardRef2(({ attendableId, related
115
192
  import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
116
193
  import { disableNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview";
117
194
  import { preventUnhandled } from "@atlaskit/pragmatic-drag-and-drop/prevent-unhandled";
118
- import React4, { useLayoutEffect, useRef } from "react";
195
+ import React5, { useLayoutEffect as useLayoutEffect2, useRef } from "react";
119
196
  import { mx as mx4 } from "@dxos/react-ui-theme";
120
197
  var REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
121
- var MIN_SIZE = 20;
198
+ var MIN_WIDTH = 20;
199
+ var MIN_HEIGHT = 3;
122
200
  var measureStackItem = (element) => {
123
201
  const stackItemElement = element.closest("[data-dx-stack-item]");
124
202
  return stackItemElement?.getBoundingClientRect() ?? {
@@ -127,7 +205,7 @@ var measureStackItem = (element) => {
127
205
  };
128
206
  };
129
207
  var getNextSize = (startSize, location, client) => {
130
- return Math.max(MIN_SIZE, startSize + (location.current.input[client] - location.initial.input[client]) / REM);
208
+ return Math.max(client === "clientX" ? MIN_WIDTH : MIN_HEIGHT, startSize + (location.current.input[client] - location.initial.input[client]) / REM);
131
209
  };
132
210
  var StackItemResizeHandle = () => {
133
211
  const { orientation } = useStack();
@@ -135,7 +213,7 @@ var StackItemResizeHandle = () => {
135
213
  const buttonRef = useRef(null);
136
214
  const dragStartSize = useRef(size);
137
215
  const client = orientation === "horizontal" ? "clientX" : "clientY";
138
- useLayoutEffect(() => {
216
+ useLayoutEffect2(() => {
139
217
  if (!buttonRef.current || buttonRef.current.hasAttribute("draggable")) {
140
218
  return;
141
219
  }
@@ -166,49 +244,51 @@ var StackItemResizeHandle = () => {
166
244
  }
167
245
  });
168
246
  }, []);
169
- return /* @__PURE__ */ React4.createElement("button", {
247
+ return /* @__PURE__ */ React5.createElement("button", {
170
248
  ref: buttonRef,
171
- className: mx4(orientation === "horizontal" ? "cursor-col-resize" : "cursor-row-resize", "group absolute is-3 bs-full inline-end-[-1px] !border-lb-0", "before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100", "before:absolute before:block before:inset-block-0 before:inline-end-0 before:is-1 before:bg-accentFocusIndicator")
172
- }, /* @__PURE__ */ React4.createElement("div", {
249
+ className: mx4("group absolute", orientation === "horizontal" ? "cursor-col-resize is-3 bs-full inline-end-[-1px] !border-lb-0 before:inset-block-0 before:inline-end-0 before:is-1" : "cursor-row-resize bs-3 is-full block-end-[-1px] !border-li-0 before:inset-inline-0 before:block-end-0 before:bs-1", "before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100", "before:absolute before:block before:bg-accentFocusIndicator")
250
+ }, /* @__PURE__ */ React5.createElement("div", {
173
251
  role: "none",
174
- className: "absolute block-start-0 inline-end-[1px] bs-[--rail-size] flex items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0"
175
- }, /* @__PURE__ */ React4.createElement(DragHandleSignifier, null)));
252
+ className: mx4("absolute flex items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0", orientation === "horizontal" ? "block-start-0 inline-end-px bs-[--rail-size]" : "inline-start-0 block-end-px is-[--rail-size] flex justify-center")
253
+ }, /* @__PURE__ */ React5.createElement(DragHandleSignifier, {
254
+ orientation
255
+ })));
176
256
  };
177
- var DragHandleSignifier = () => {
178
- return /* @__PURE__ */ React4.createElement("svg", {
257
+ var DragHandleSignifier = ({ orientation }) => {
258
+ return /* @__PURE__ */ React5.createElement("svg", {
179
259
  xmlns: "http://www.w3.org/2000/svg",
180
260
  viewBox: "0 0 256 256",
181
261
  fill: "currentColor",
182
- className: "shrink-0 bs-[1em] is-[1em] text-unAccent"
183
- }, /* @__PURE__ */ React4.createElement("path", {
262
+ className: mx4("shrink-0 bs-[1em] is-[1em] text-unAccent", orientation === "vertical" && "rotate-90")
263
+ }, /* @__PURE__ */ React5.createElement("path", {
184
264
  d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
185
- }), /* @__PURE__ */ React4.createElement("path", {
265
+ }), /* @__PURE__ */ React5.createElement("path", {
186
266
  d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
187
- }), /* @__PURE__ */ React4.createElement("path", {
267
+ }), /* @__PURE__ */ React5.createElement("path", {
188
268
  d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
189
- }), /* @__PURE__ */ React4.createElement("path", {
269
+ }), /* @__PURE__ */ React5.createElement("path", {
190
270
  d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
191
271
  }));
192
272
  };
193
273
 
194
274
  // packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
195
- import React6, { Fragment, forwardRef as forwardRef3, useRef as useRef2, useState } from "react";
275
+ import React7, { Fragment, forwardRef as forwardRef4, useRef as useRef2, useState as useState2 } from "react";
196
276
  import { keySymbols } from "@dxos/keyboard";
197
- import { Button, DropdownMenu, Icon, toLocalizedString, Tooltip, useTranslation } from "@dxos/react-ui";
277
+ import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
198
278
  import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
199
279
  import { descriptionText, mx as mx5 } from "@dxos/react-ui-theme";
200
280
  import { getHostPlatform } from "@dxos/util";
201
281
 
202
282
  // packages/ui/react-ui-stack/src/components/MenuSignifier.tsx
203
- import React5 from "react";
204
- var MenuSignifierHorizontal = () => /* @__PURE__ */ React5.createElement("svg", {
283
+ import React6 from "react";
284
+ var MenuSignifierHorizontal = () => /* @__PURE__ */ React6.createElement("svg", {
205
285
  className: "absolute block-end-[7px]",
206
286
  width: 20,
207
287
  height: 2,
208
288
  viewBox: "0 0 20 2",
209
289
  stroke: "currentColor",
210
290
  opacity: 0.5
211
- }, /* @__PURE__ */ React5.createElement("line", {
291
+ }, /* @__PURE__ */ React6.createElement("line", {
212
292
  x1: 0.5,
213
293
  y1: 0.75,
214
294
  x2: 19,
@@ -238,35 +318,40 @@ var translations_default = [
238
318
  ];
239
319
 
240
320
  // packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
241
- var StackItemSigilButton = /* @__PURE__ */ forwardRef3(({ attendableId, classNames, related, children, ...props }, forwardedRef) => {
321
+ var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNames, related, children, ...props }, forwardedRef) => {
242
322
  const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
243
323
  const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
244
- return /* @__PURE__ */ React6.createElement(Button, {
324
+ return /* @__PURE__ */ React7.createElement(Button, {
245
325
  ...props,
246
326
  variant,
247
327
  classNames: [
248
- "m-1 shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative",
328
+ "shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative app-no-drag",
249
329
  classNames
250
330
  ],
251
331
  ref: forwardedRef
252
- }, /* @__PURE__ */ React6.createElement(MenuSignifierHorizontal, null), children);
332
+ }, /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
253
333
  });
254
- var StackItemSigil = /* @__PURE__ */ forwardRef3(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
334
+ var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
255
335
  const { t } = useTranslation(translationKey);
256
336
  const suppressNextTooltip = useRef2(false);
257
- const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
258
- const [triggerTooltipOpen, setTriggerTooltipOpen] = useState(false);
259
- return /* @__PURE__ */ React6.createElement(Tooltip.Root, {
260
- open: triggerTooltipOpen,
261
- onOpenChange: (nextOpen) => {
262
- if (suppressNextTooltip.current) {
263
- setTriggerTooltipOpen(false);
264
- suppressNextTooltip.current = false;
265
- } else {
266
- setTriggerTooltipOpen(nextOpen);
267
- }
268
- }
269
- }, /* @__PURE__ */ React6.createElement(DropdownMenu.Root, {
337
+ const [optionsMenuOpen, setOptionsMenuOpen] = useState2(false);
338
+ const hasActions = actionGroups && actionGroups.length > 0;
339
+ const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
340
+ attendableId,
341
+ related,
342
+ // TODO(wittjosiah): Better disabling of interactive styles when no action are available.
343
+ // Remove underscore icon when no actions are available?
344
+ classNames: !hasActions && "cursor-default"
345
+ }, /* @__PURE__ */ React7.createElement("span", {
346
+ className: "sr-only"
347
+ }, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
348
+ icon,
349
+ size: 5
350
+ }));
351
+ if (!hasActions) {
352
+ return button;
353
+ }
354
+ return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
270
355
  open: optionsMenuOpen,
271
356
  onOpenChange: (nextOpen) => {
272
357
  if (!nextOpen) {
@@ -274,30 +359,20 @@ var StackItemSigil = /* @__PURE__ */ forwardRef3(({ actions: actionGroups, onAct
274
359
  }
275
360
  return setOptionsMenuOpen(nextOpen);
276
361
  }
277
- }, /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
278
- asChild: true
279
- }, /* @__PURE__ */ React6.createElement(DropdownMenu.Trigger, {
362
+ }, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
280
363
  asChild: true,
281
364
  ref: forwardedRef
282
- }, /* @__PURE__ */ React6.createElement(StackItemSigilButton, {
283
- attendableId,
284
- related
285
- }, /* @__PURE__ */ React6.createElement("span", {
286
- className: "sr-only"
287
- }, triggerLabel), /* @__PURE__ */ React6.createElement(Icon, {
288
- icon,
289
- size: 5
290
- })))), /* @__PURE__ */ React6.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React6.createElement(DropdownMenu.Content, {
365
+ }, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
291
366
  classNames: "z-[31]"
292
- }, /* @__PURE__ */ React6.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
293
- const separator = index > 0 ? /* @__PURE__ */ React6.createElement(DropdownMenu.Separator, null) : null;
294
- return /* @__PURE__ */ React6.createElement(Fragment, {
367
+ }, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
368
+ const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
369
+ return /* @__PURE__ */ React7.createElement(Fragment, {
295
370
  key: index
296
371
  }, separator, actions.map((action) => {
297
372
  const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
298
373
  const menuItemType = action.properties.menuItemType;
299
374
  const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
300
- return /* @__PURE__ */ React6.createElement(Root, {
375
+ return /* @__PURE__ */ React7.createElement(Root, {
301
376
  key: action.id,
302
377
  onClick: (event) => {
303
378
  if (action.properties.disabled) {
@@ -314,40 +389,35 @@ var StackItemSigil = /* @__PURE__ */ forwardRef3(({ actions: actionGroups, onAct
314
389
  ...action.properties?.testId && {
315
390
  "data-testid": action.properties.testId
316
391
  }
317
- }, /* @__PURE__ */ React6.createElement(Icon, {
392
+ }, /* @__PURE__ */ React7.createElement(Icon, {
318
393
  icon: action.properties.icon ?? "ph--placeholder--regular",
319
394
  size: 4
320
- }), /* @__PURE__ */ React6.createElement("span", {
395
+ }), /* @__PURE__ */ React7.createElement("span", {
321
396
  className: "grow truncate"
322
- }, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React6.createElement(DropdownMenu.ItemIndicator, {
397
+ }, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React7.createElement(DropdownMenu.ItemIndicator, {
323
398
  asChild: true
324
- }, /* @__PURE__ */ React6.createElement(Icon, {
399
+ }, /* @__PURE__ */ React7.createElement(Icon, {
325
400
  icon: "ph--check--regular",
326
401
  size: 4
327
- })), shortcut && /* @__PURE__ */ React6.createElement("span", {
402
+ })), shortcut && /* @__PURE__ */ React7.createElement("span", {
328
403
  className: mx5("shrink-0", descriptionText)
329
404
  }, keySymbols(shortcut).join("")));
330
405
  }));
331
- }), children), /* @__PURE__ */ React6.createElement(DropdownMenu.Arrow, null)))), /* @__PURE__ */ React6.createElement(Tooltip.Portal, null, /* @__PURE__ */ React6.createElement(Tooltip.Content, {
332
- style: {
333
- zIndex: 70
334
- },
335
- side: "bottom"
336
- }, triggerLabel, /* @__PURE__ */ React6.createElement(Tooltip.Arrow, null))));
406
+ }), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
337
407
  });
338
408
 
339
409
  // packages/ui/react-ui-stack/src/components/StackItem.tsx
340
410
  var DEFAULT_HORIZONTAL_SIZE = 44;
341
411
  var DEFAULT_VERTICAL_SIZE = "min-content";
342
412
  var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
343
- var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, onRearrange, size: propsSize, onSizeChange, role, order, style, ...props }, forwardedRef) => {
344
- const [itemElement, itemRef] = useState2(null);
345
- const [selfDragHandleElement, selfDragHandleRef] = useState2(null);
346
- const [_closestEdge, setEdge] = useState2(null);
347
- const { orientation, rail, separators } = useStack();
348
- const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState2(propsSize);
413
+ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
414
+ const [itemElement, itemRef] = useState3(null);
415
+ const [selfDragHandleElement, selfDragHandleRef] = useState3(null);
416
+ const [closestEdge, setEdge] = useState3(null);
417
+ const { orientation, rail, onRearrange } = useStack();
418
+ const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState3(propsSize);
349
419
  const Root = role ?? "div";
350
- const composedItemRef = composeRefs(itemRef, forwardedRef);
420
+ const composedItemRef = composeRefs2(itemRef, forwardedRef);
351
421
  const setSize = useCallback((nextSize, commit) => {
352
422
  setInternalSize(nextSize);
353
423
  if (commit) {
@@ -357,11 +427,11 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
357
427
  onSizeChange
358
428
  ]);
359
429
  const type = orientation === "horizontal" ? "column" : "card";
360
- useLayoutEffect2(() => {
361
- if (!itemElement || !onRearrange) {
430
+ useLayoutEffect3(() => {
431
+ if (!itemElement || !onRearrange || disableRearrange) {
362
432
  return;
363
433
  }
364
- return combine(draggable2({
434
+ return combine2(draggable2({
365
435
  element: itemElement,
366
436
  ...selfDragHandleElement && {
367
437
  dragHandle: selfDragHandleElement
@@ -369,11 +439,31 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
369
439
  getInitialData: () => ({
370
440
  id: item.id,
371
441
  type
372
- })
373
- }), dropTargetForElements({
442
+ }),
443
+ onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
444
+ document.body.setAttribute("data-drag-preview", "true");
445
+ scrollJustEnoughIntoView({
446
+ element: source.element
447
+ });
448
+ const { x, y } = preserveOffsetOnSource({
449
+ element: source.element,
450
+ input: location.current.input
451
+ })({
452
+ container: source.element.offsetParent ?? document.body
453
+ });
454
+ nativeSetDragImage?.(source.element, x, y);
455
+ },
456
+ onDragStart: () => {
457
+ document.body.removeAttribute("data-drag-preview");
458
+ itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
459
+ },
460
+ onDrop: () => {
461
+ itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
462
+ }
463
+ }), dropTargetForElements2({
374
464
  element: itemElement,
375
465
  getData: ({ input, element }) => {
376
- return attachClosestEdge({
466
+ return attachClosestEdge2({
377
467
  id: item.id,
378
468
  type
379
469
  }, {
@@ -390,19 +480,19 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
390
480
  },
391
481
  onDragEnter: ({ self, source }) => {
392
482
  if (source.data.type === self.data.type) {
393
- setEdge(extractClosestEdge(self.data));
483
+ setEdge(extractClosestEdge2(self.data));
394
484
  }
395
485
  },
396
486
  onDrag: ({ self, source }) => {
397
487
  if (source.data.type === self.data.type) {
398
- setEdge(extractClosestEdge(self.data));
488
+ setEdge(extractClosestEdge2(self.data));
399
489
  }
400
490
  },
401
491
  onDragLeave: () => setEdge(null),
402
492
  onDrop: ({ self, source }) => {
403
493
  setEdge(null);
404
494
  if (source.data.type === self.data.type) {
405
- onRearrange(source.data, self.data, extractClosestEdge(self.data));
495
+ onRearrange(source.data, self.data, extractClosestEdge2(self.data));
406
496
  }
407
497
  }
408
498
  }));
@@ -416,17 +506,17 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
416
506
  const focusGroupAttrs = useFocusableGroup2({
417
507
  tabBehavior: "limited"
418
508
  });
419
- return /* @__PURE__ */ React7.createElement(StackItemContext.Provider, {
509
+ return /* @__PURE__ */ React8.createElement(StackItemContext.Provider, {
420
510
  value: {
421
511
  selfDragHandleRef,
422
512
  size,
423
513
  setSize
424
514
  }
425
- }, /* @__PURE__ */ React7.createElement(Root, {
515
+ }, /* @__PURE__ */ React8.createElement(Root, {
426
516
  ...props,
427
517
  tabIndex: 0,
428
518
  ...focusGroupAttrs,
429
- className: mx6("group/stack-item grid relative ch-focus-ring-inset-over-all", size === "min-content" && (orientation === "horizontal" ? "is-min" : "bs-min"), orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), separators && (orientation === "horizontal" ? "divide-separator divide-y" : "divide-separator divide-x"), classNames),
519
+ className: mx6("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", size === "min-content" && (orientation === "horizontal" ? "is-min" : "bs-min"), orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), classNames),
430
520
  "data-dx-stack-item": true,
431
521
  style: {
432
522
  ...size !== "min-content" && {
@@ -438,7 +528,11 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
438
528
  ...style
439
529
  },
440
530
  ref: composedItemRef
441
- }, children));
531
+ }, children, closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
532
+ lineInset: 8,
533
+ terminalInset: -8,
534
+ edge: closestEdge
535
+ })));
442
536
  });
443
537
  var StackItem = {
444
538
  Root: StackItemRoot,
@@ -446,55 +540,55 @@ var StackItem = {
446
540
  Heading: StackItemHeading,
447
541
  HeadingLabel: StackItemHeadingLabel,
448
542
  ResizeHandle: StackItemResizeHandle,
543
+ DragHandle: StackItemDragHandle,
449
544
  Sigil: StackItemSigil,
450
545
  SigilButton: StackItemSigilButton
451
546
  };
452
547
 
453
548
  // packages/ui/react-ui-stack/src/components/LayoutControls.tsx
454
- import React8, { forwardRef as forwardRef5 } from "react";
455
- import { Button as Button2, ButtonGroup, Icon as Icon2, Tooltip as Tooltip2, useTranslation as useTranslation2 } from "@dxos/react-ui";
549
+ import React9, { forwardRef as forwardRef6 } from "react";
550
+ import { Button as Button2, ButtonGroup, Icon as Icon2, Tooltip, useTranslation as useTranslation2 } from "@dxos/react-ui";
456
551
  var LayoutControl = ({ icon, label, ...props }) => {
457
- return /* @__PURE__ */ React8.createElement(Tooltip2.Root, null, /* @__PURE__ */ React8.createElement(Tooltip2.Trigger, {
552
+ return /* @__PURE__ */ React9.createElement(Tooltip.Root, null, /* @__PURE__ */ React9.createElement(Tooltip.Trigger, {
458
553
  asChild: true
459
- }, /* @__PURE__ */ React8.createElement(Button2, {
554
+ }, /* @__PURE__ */ React9.createElement(Button2, {
460
555
  variant: "ghost",
461
556
  ...props
462
- }, /* @__PURE__ */ React8.createElement("span", {
557
+ }, /* @__PURE__ */ React9.createElement("span", {
463
558
  className: "sr-only"
464
- }, label), /* @__PURE__ */ React8.createElement(Icon2, {
559
+ }, label), /* @__PURE__ */ React9.createElement(Icon2, {
465
560
  icon
466
- }))), /* @__PURE__ */ React8.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React8.createElement(Tooltip2.Content, {
467
- side: "bottom",
468
- classNames: "z-[70]"
561
+ }))), /* @__PURE__ */ React9.createElement(Tooltip.Portal, null, /* @__PURE__ */ React9.createElement(Tooltip.Content, {
562
+ side: "bottom"
469
563
  }, label)));
470
564
  };
471
- var LayoutControls = /* @__PURE__ */ forwardRef5(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
565
+ var LayoutControls = /* @__PURE__ */ forwardRef6(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
472
566
  const { t } = useTranslation2(translationKey);
473
567
  const buttonClassNames = variant === "hide-disabled" ? "disabled:hidden !p-1" : "!p-1";
474
- return /* @__PURE__ */ React8.createElement(ButtonGroup, {
568
+ return /* @__PURE__ */ React9.createElement(ButtonGroup, {
475
569
  ...props,
476
570
  ref: forwardedRef
477
571
  }, pin && !isSolo && [
478
572
  "both",
479
573
  "start"
480
- ].includes(pin) && /* @__PURE__ */ React8.createElement(LayoutControl, {
574
+ ].includes(pin) && /* @__PURE__ */ React9.createElement(LayoutControl, {
481
575
  label: t("pin start label"),
482
576
  variant: "ghost",
483
577
  classNames: buttonClassNames,
484
578
  onClick: () => onClick?.("pin-start"),
485
579
  icon: "ph--caret-line-left--regular"
486
- }), can.solo && /* @__PURE__ */ React8.createElement(LayoutControl, {
580
+ }), can.solo && /* @__PURE__ */ React9.createElement(LayoutControl, {
487
581
  label: t("solo layout label"),
488
582
  classNames: buttonClassNames,
489
583
  onClick: () => onClick?.("solo"),
490
584
  icon: isSolo ? "ph--arrows-in--regular" : "ph--arrows-out--regular"
491
- }), !isSolo && can.solo && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(LayoutControl, {
585
+ }), !isSolo && can.solo && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(LayoutControl, {
492
586
  label: t("increment start label"),
493
587
  disabled: !can.incrementStart,
494
588
  classNames: buttonClassNames,
495
589
  onClick: () => onClick?.("increment-start"),
496
590
  icon: "ph--caret-left--regular"
497
- }), /* @__PURE__ */ React8.createElement(LayoutControl, {
591
+ }), /* @__PURE__ */ React9.createElement(LayoutControl, {
498
592
  label: t("increment end label"),
499
593
  disabled: !can.incrementEnd,
500
594
  classNames: buttonClassNames,
@@ -503,12 +597,12 @@ var LayoutControls = /* @__PURE__ */ forwardRef5(({ onClick, variant = "default"
503
597
  })), pin && !isSolo && [
504
598
  "both",
505
599
  "end"
506
- ].includes(pin) && /* @__PURE__ */ React8.createElement(LayoutControl, {
600
+ ].includes(pin) && /* @__PURE__ */ React9.createElement(LayoutControl, {
507
601
  label: t("pin end label"),
508
602
  classNames: buttonClassNames,
509
603
  onClick: () => onClick?.("pin-end"),
510
604
  icon: "ph--caret-line-right--regular"
511
- }), close && !isSolo && /* @__PURE__ */ React8.createElement(LayoutControl, {
605
+ }), close && !isSolo && /* @__PURE__ */ React9.createElement(LayoutControl, {
512
606
  label: t(`${typeof close === "string" ? "minify" : "close"} label`),
513
607
  classNames: buttonClassNames,
514
608
  onClick: () => onClick?.("close"),
@@ -524,8 +618,12 @@ export {
524
618
  Stack,
525
619
  StackContext,
526
620
  StackItem,
621
+ StackItemContext,
622
+ autoScrollRootAttributes,
527
623
  railGridHorizontal,
528
624
  railGridVertical,
529
- translations_default as translations
625
+ translations_default as translations,
626
+ useStack,
627
+ useStackItem
530
628
  };
531
629
  //# sourceMappingURL=index.mjs.map