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

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