@dxos/react-ui-stack 0.7.4 → 0.7.5-main.9cb18ac

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