@dxos/react-ui-stack 0.7.4-staging.f7e8224 → 0.7.5-main.499c70c

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