@dxos/react-ui-stack 0.8.3 → 0.8.4-main.1068cf700f

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 (111) hide show
  1. package/dist/lib/browser/index.mjs +767 -1016
  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 → playwright}/index.mjs +5 -1
  5. package/dist/lib/browser/{testing → playwright}/index.mjs.map +3 -3
  6. package/dist/lib/node-esm/index.mjs +767 -1016
  7. package/dist/lib/node-esm/index.mjs.map +4 -4
  8. package/dist/lib/node-esm/meta.json +1 -1
  9. package/dist/lib/node-esm/{testing → playwright}/index.mjs +5 -1
  10. package/dist/lib/node-esm/{testing → playwright}/index.mjs.map +3 -3
  11. package/dist/types/src/{exemplars → components}/CardStack/CardStack.d.ts +24 -11
  12. package/dist/types/src/components/CardStack/CardStack.d.ts.map +1 -0
  13. package/dist/types/src/components/CardStack/CardStack.stories.d.ts +15 -0
  14. package/dist/types/src/components/CardStack/CardStack.stories.d.ts.map +1 -0
  15. package/dist/types/src/{exemplars → components}/CardStack/CardStackDragPreview.d.ts +4 -1
  16. package/dist/types/src/components/CardStack/CardStackDragPreview.d.ts.map +1 -0
  17. package/dist/types/src/components/CardStack/index.d.ts.map +1 -0
  18. package/dist/types/src/components/Stack/Stack.d.ts +15 -7
  19. package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
  20. package/dist/types/src/components/Stack/Stack.stories.d.ts +12 -3
  21. package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -1
  22. package/dist/types/src/components/StackContext.d.ts +2 -1
  23. package/dist/types/src/components/StackContext.d.ts.map +1 -1
  24. package/dist/types/src/components/StackItem/StackItem.d.ts +9 -12
  25. package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
  26. package/dist/types/src/components/StackItem/StackItem.stories.d.ts +13 -5
  27. package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/StackItem/StackItemContent.d.ts +4 -37
  29. package/dist/types/src/components/StackItem/StackItemContent.d.ts.map +1 -1
  30. package/dist/types/src/components/StackItem/StackItemHeading.d.ts +1 -1
  31. package/dist/types/src/components/StackItem/StackItemHeading.d.ts.map +1 -1
  32. package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts.map +1 -1
  33. package/dist/types/src/components/StackItem/StackItemSigil.d.ts +2 -2
  34. package/dist/types/src/components/StackItem/StackItemSigil.d.ts.map +1 -1
  35. package/dist/types/src/components/deprecated/LayoutControls.d.ts +3 -0
  36. package/dist/types/src/components/deprecated/LayoutControls.d.ts.map +1 -1
  37. package/dist/types/src/components/index.d.ts +2 -1
  38. package/dist/types/src/components/index.d.ts.map +1 -1
  39. package/dist/types/src/components/{defs.d.ts → types.d.ts} +1 -1
  40. package/dist/types/src/components/types.d.ts.map +1 -0
  41. package/dist/types/src/hooks/useStackDropForElements.d.ts +9 -7
  42. package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
  43. package/dist/types/src/index.d.ts +1 -2
  44. package/dist/types/src/index.d.ts.map +1 -1
  45. package/dist/types/src/playwright/index.d.ts.map +1 -0
  46. package/dist/types/src/playwright/playwright.config.d.ts +3 -0
  47. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
  48. package/dist/types/src/playwright/stack-manager.d.ts.map +1 -0
  49. package/dist/types/src/translations.d.ts +13 -14
  50. package/dist/types/src/translations.d.ts.map +1 -1
  51. package/dist/types/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +48 -41
  53. package/src/components/CardStack/CardStack.stories.tsx +173 -0
  54. package/src/{exemplars → components}/CardStack/CardStack.tsx +115 -39
  55. package/src/{exemplars → components}/CardStack/CardStackDragPreview.tsx +12 -9
  56. package/src/components/Stack/Stack.stories.tsx +9 -10
  57. package/src/components/Stack/Stack.tsx +225 -26
  58. package/src/components/StackContext.tsx +2 -1
  59. package/src/components/StackItem/StackItem.stories.tsx +21 -17
  60. package/src/components/StackItem/StackItem.tsx +49 -29
  61. package/src/components/StackItem/StackItemContent.tsx +23 -42
  62. package/src/components/StackItem/StackItemHeading.tsx +5 -9
  63. package/src/components/StackItem/StackItemResizeHandle.tsx +2 -1
  64. package/src/components/StackItem/StackItemSigil.tsx +5 -4
  65. package/src/components/deprecated/LayoutControls.tsx +3 -0
  66. package/src/components/index.ts +2 -1
  67. package/src/hooks/useStackDropForElements.ts +59 -42
  68. package/src/index.ts +1 -5
  69. package/src/{testing → playwright}/index.ts +1 -1
  70. package/src/playwright/playwright.config.ts +17 -0
  71. package/src/playwright/smoke.spec.ts +7 -5
  72. package/src/translations.ts +5 -3
  73. package/dist/lib/node/index.cjs +0 -1220
  74. package/dist/lib/node/index.cjs.map +0 -7
  75. package/dist/lib/node/meta.json +0 -1
  76. package/dist/lib/node/testing/index.cjs +0 -81
  77. package/dist/lib/node/testing/index.cjs.map +0 -7
  78. package/dist/types/src/components/defs.d.ts.map +0 -1
  79. package/dist/types/src/exemplars/Card/Card.d.ts +0 -62
  80. package/dist/types/src/exemplars/Card/Card.d.ts.map +0 -1
  81. package/dist/types/src/exemplars/Card/Card.stories-todo.d.ts +0 -1
  82. package/dist/types/src/exemplars/Card/Card.stories-todo.d.ts.map +0 -1
  83. package/dist/types/src/exemplars/Card/CardDragPreview.d.ts +0 -6
  84. package/dist/types/src/exemplars/Card/CardDragPreview.d.ts.map +0 -1
  85. package/dist/types/src/exemplars/Card/fragments.d.ts +0 -13
  86. package/dist/types/src/exemplars/Card/fragments.d.ts.map +0 -1
  87. package/dist/types/src/exemplars/Card/index.d.ts +0 -4
  88. package/dist/types/src/exemplars/Card/index.d.ts.map +0 -1
  89. package/dist/types/src/exemplars/CardStack/CardStack.d.ts.map +0 -1
  90. package/dist/types/src/exemplars/CardStack/CardStack.stories-todo.d.ts +0 -1
  91. package/dist/types/src/exemplars/CardStack/CardStack.stories-todo.d.ts.map +0 -1
  92. package/dist/types/src/exemplars/CardStack/CardStackDragPreview.d.ts.map +0 -1
  93. package/dist/types/src/exemplars/CardStack/index.d.ts.map +0 -1
  94. package/dist/types/src/exemplars/index.d.ts +0 -3
  95. package/dist/types/src/exemplars/index.d.ts.map +0 -1
  96. package/dist/types/src/testing/index.d.ts.map +0 -1
  97. package/dist/types/src/testing/stack-manager.d.ts.map +0 -1
  98. package/src/exemplars/Card/Card.stories-todo.tsx +0 -135
  99. package/src/exemplars/Card/Card.tsx +0 -182
  100. package/src/exemplars/Card/CardDragPreview.tsx +0 -22
  101. package/src/exemplars/Card/fragments.ts +0 -25
  102. package/src/exemplars/Card/index.ts +0 -7
  103. package/src/exemplars/CardStack/CardStack.stories-todo.tsx +0 -80
  104. package/src/exemplars/index.ts +0 -6
  105. package/src/playwright/playwright.config.cts +0 -18
  106. /package/dist/types/src/{exemplars → components}/CardStack/index.d.ts +0 -0
  107. /package/dist/types/src/{testing → playwright}/index.d.ts +0 -0
  108. /package/dist/types/src/{testing → playwright}/stack-manager.d.ts +0 -0
  109. /package/src/{exemplars → components}/CardStack/index.ts +0 -0
  110. /package/src/components/{defs.ts → types.ts} +0 -0
  111. /package/src/{testing → playwright}/stack-manager.ts +0 -0
@@ -1,27 +1,33 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
- // packages/ui/react-ui-stack/src/components/Stack/Stack.tsx
4
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
5
- import { useArrowNavigationGroup } from "@fluentui/react-tabster";
3
+ // src/components/CardStack/CardStack.tsx
4
+ import { Slot } from "@radix-ui/react-slot";
5
+ import React2, { forwardRef as forwardRef2 } from "react";
6
+ import { Card } from "@dxos/react-ui-mosaic";
7
+ import { cardDefaultInlineSize, mx as mx2 } from "@dxos/ui-theme";
8
+
9
+ // src/components/Stack/Stack.tsx
6
10
  import { composeRefs } from "@radix-ui/react-compose-refs";
7
- import React, { Children, forwardRef, useState as useState2, useMemo, useCallback, useEffect } from "react";
8
- import { ListItem } from "@dxos/react-ui";
9
- import { mx } from "@dxos/react-ui-theme";
11
+ import React, { Children, forwardRef, useCallback, useEffect, useMemo, useState as useState2 } from "react";
12
+ import { ListItem, useId } from "@dxos/react-ui";
13
+ import { mx } from "@dxos/ui-theme";
10
14
 
11
- // packages/ui/react-ui-stack/src/hooks/useStackDropForElements.ts
15
+ // src/hooks/useStackDropForElements.ts
12
16
  import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
13
17
  import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
14
18
  import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
15
19
  import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
16
20
  import { useLayoutEffect, useState } from "react";
17
- var useStackDropForElements = ({ id, element, scrollElement = element, selfDroppable, orientation, onRearrange }) => {
21
+ var noop = () => {
22
+ };
23
+ var useStackDropForElements = ({ id, element, scrollElement = element, orientation, selfDroppable, onRearrange }) => {
18
24
  const [dropping, setDropping] = useState(false);
19
25
  useLayoutEffect(() => {
20
- if (!element || !selfDroppable) {
26
+ if (!element) {
21
27
  return;
22
28
  }
23
29
  const acceptSourceType = orientation === "horizontal" ? "column" : "card";
24
- return combine(dropTargetForElements({
30
+ return combine(selfDroppable ? dropTargetForElements({
25
31
  element,
26
32
  getData: ({ input, element: element2 }) => {
27
33
  return attachClosestEdge({
@@ -54,16 +60,16 @@ var useStackDropForElements = ({ id, element, scrollElement = element, selfDropp
54
60
  onRearrange(source.data, self.data, extractClosestEdge(self.data));
55
61
  }
56
62
  }
57
- }), autoScrollForElements({
63
+ }) : noop, scrollElement ? autoScrollForElements({
58
64
  element: scrollElement,
59
65
  getAllowedAxis: () => orientation
60
- }));
66
+ }) : noop);
61
67
  }, [
68
+ id,
62
69
  element,
63
70
  scrollElement,
64
71
  selfDroppable,
65
72
  orientation,
66
- id,
67
73
  onRearrange
68
74
  ]);
69
75
  return {
@@ -71,7 +77,7 @@ var useStackDropForElements = ({ id, element, scrollElement = element, selfDropp
71
77
  };
72
78
  };
73
79
 
74
- // packages/ui/react-ui-stack/src/components/StackContext.tsx
80
+ // src/components/StackContext.tsx
75
81
  import { createContext, useContext } from "react";
76
82
  var StackContext = /* @__PURE__ */ createContext({
77
83
  orientation: "vertical",
@@ -94,7 +100,7 @@ var StackItemContext = /* @__PURE__ */ createContext({
94
100
  });
95
101
  var useStackItem = () => useContext(StackItemContext);
96
102
 
97
- // packages/ui/react-ui-stack/src/components/Stack/Stack.tsx
103
+ // src/components/Stack/Stack.tsx
98
104
  var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
99
105
  var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
100
106
  var railGridHorizontalContainFitContent = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
@@ -102,583 +108,799 @@ var railGridVerticalContainFitContent = "grid-cols-[[rail-start]_var(--rail-size
102
108
  var autoScrollRootAttributes = {
103
109
  "data-drag-autoscroll": "idle"
104
110
  };
105
- var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), getDropElement, separatorOnScroll, ...props }, forwardedRef) => {
106
- var _effect = _useSignals();
107
- try {
108
- const [stackElement, stackRef] = useState2(null);
109
- const composedItemRef = composeRefs(stackRef, forwardedRef);
110
- const arrowNavigationAttrs = useArrowNavigationGroup({
111
- axis: orientation
112
- });
113
- const styles = {
114
- [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
115
- ...style
116
- };
117
- const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
118
- const { dropping } = useStackDropForElements({
119
- id: props.id,
120
- element: getDropElement && stackElement ? getDropElement(stackElement) : stackElement,
121
- scrollElement: stackElement,
122
- selfDroppable,
123
- orientation,
124
- onRearrange
125
- });
126
- const handleScroll = useCallback(() => {
127
- if (stackElement && Number.isFinite(separatorOnScroll)) {
128
- const scrollPosition = orientation === "horizontal" ? stackElement.scrollLeft : stackElement.scrollTop;
129
- const scrollSize = orientation === "horizontal" ? stackElement.scrollWidth : stackElement.scrollHeight;
130
- const clientSize = orientation === "horizontal" ? stackElement.clientWidth : stackElement.clientHeight;
131
- const separatorHost = stackElement.closest("[data-scroll-separator]");
132
- if (separatorHost) {
133
- separatorHost.setAttribute("data-scroll-separator", String(scrollPosition > separatorOnScroll));
134
- separatorHost.setAttribute("data-scroll-separator-end", String(scrollSize - (scrollPosition + clientSize) > separatorOnScroll));
135
- }
111
+ var PERPENDICULAR_FOCUS_THRESHHOLD = 128;
112
+ var scrollIntoViewAndFocus = (el, orientation) => {
113
+ el.scrollIntoView({
114
+ behavior: "instant",
115
+ [orientation === "vertical" ? "block" : "inline"]: "center"
116
+ });
117
+ return el.focus();
118
+ };
119
+ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), getDropElement, separatorOnScroll, circularFocus, ...props }, forwardedRef) => {
120
+ const stackId = useId("stack", props.id);
121
+ const [stackElement, stackRef] = useState2(null);
122
+ const [lastFocusedItem, setLastFocusedItem] = useState2();
123
+ const composedItemRef = composeRefs(stackRef, forwardedRef);
124
+ const styles = {
125
+ [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: size === "split" ? `repeat(${itemsCount}, 1fr)` : `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
126
+ ...style
127
+ };
128
+ const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
129
+ const { dropping } = useStackDropForElements({
130
+ id: props.id,
131
+ element: getDropElement && stackElement ? getDropElement(stackElement) : stackElement,
132
+ scrollElement: stackElement,
133
+ selfDroppable,
134
+ orientation,
135
+ onRearrange
136
+ });
137
+ const handleScroll = useCallback(() => {
138
+ if (stackElement && Number.isFinite(separatorOnScroll)) {
139
+ const scrollPosition = orientation === "horizontal" ? stackElement.scrollLeft : stackElement.scrollTop;
140
+ const scrollSize = orientation === "horizontal" ? stackElement.scrollWidth : stackElement.scrollHeight;
141
+ const clientSize = orientation === "horizontal" ? stackElement.clientWidth : stackElement.clientHeight;
142
+ const separatorHost = stackElement.closest("[data-scroll-separator]");
143
+ if (separatorHost) {
144
+ separatorHost.setAttribute("data-scroll-separator", String(scrollPosition > separatorOnScroll));
145
+ separatorHost.setAttribute("data-scroll-separator-end", String(scrollSize - (scrollPosition + clientSize) > separatorOnScroll));
136
146
  }
137
- }, [
138
- stackElement,
139
- separatorOnScroll,
140
- orientation
141
- ]);
142
- const gridClasses = useMemo(() => {
143
- if (!rail) {
144
- return orientation === "horizontal" ? "grid-rows-1 pli-1" : "grid-cols-1 plb-1";
147
+ }
148
+ }, [
149
+ stackElement,
150
+ separatorOnScroll,
151
+ orientation
152
+ ]);
153
+ const handleBlur = useCallback((event) => {
154
+ if (event.target) {
155
+ const target = event.target;
156
+ const closestStackItem = target.closest(`[data-dx-item-id]`);
157
+ if (closestStackItem?.closest(`[data-dx-stack="${stackId}"]`)) {
158
+ setLastFocusedItem(closestStackItem?.getAttribute("data-dx-item-id") ?? void 0);
145
159
  }
146
- if (orientation === "horizontal") {
147
- return size === "contain-fit-content" ? railGridHorizontalContainFitContent : railGridHorizontal;
148
- } else {
149
- return size === "contain-fit-content" ? railGridVerticalContainFitContent : railGridVertical;
160
+ }
161
+ props.onBlur?.(event);
162
+ }, [
163
+ stackId,
164
+ props.onBlur
165
+ ]);
166
+ const handleKeyDown = useCallback((event) => {
167
+ const target = event.target;
168
+ if (event.key.startsWith("Arrow") && !target.closest(`input, textarea, [role="textbox"], [data-tabster*="mover"], [data-arrow-keys="all"], [data-arrow-keys~="${event.key.toLowerCase().slice(5)}"]`)) {
169
+ const closestOwnedItem = target.closest(`[data-dx-stack-item="${stackId}"]`);
170
+ const closestStack = target.closest("[data-dx-stack]");
171
+ const closestStackItems = Array.from(closestStack?.querySelectorAll(`[data-dx-stack-item="${stackId}"]`) ?? []);
172
+ const closestStackOrientation = closestStack?.getAttribute("aria-orientation");
173
+ const ancestorStack = closestStack?.parentElement?.closest("[data-dx-stack]");
174
+ if (closestOwnedItem && closestStack) {
175
+ const ancestorOrientation = ancestorStack?.getAttribute("aria-orientation");
176
+ const parallelDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowUp" : event.key === "ArrowLeft") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowDown" : event.key === "ArrowRight") ? 1 : 0;
177
+ const perpendicularDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowLeft" : event.key === "ArrowUp") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowRight" : event.key === "ArrowDown") ? 1 : 0;
178
+ if (parallelDelta !== 0) {
179
+ const currentIndex = closestStackItems.indexOf(closestOwnedItem);
180
+ const nextIndex = currentIndex + parallelDelta;
181
+ let adjacentItem;
182
+ if (circularFocus) {
183
+ adjacentItem = closestStackItems[(nextIndex + closestStackItems.length) % closestStackItems.length];
184
+ } else {
185
+ if (nextIndex >= 0 && nextIndex < closestStackItems.length) {
186
+ adjacentItem = closestStackItems[nextIndex];
187
+ }
188
+ }
189
+ if (adjacentItem) {
190
+ event.preventDefault();
191
+ scrollIntoViewAndFocus(adjacentItem, closestStackOrientation);
192
+ }
193
+ }
194
+ if (perpendicularDelta !== 0) {
195
+ if (ancestorStack && ancestorOrientation !== closestStackOrientation) {
196
+ const siblingStacks = Array.from(ancestorStack.querySelectorAll(`[data-dx-stack-item="${ancestorStack.getAttribute("data-dx-stack")}"] [data-dx-stack]`));
197
+ const currentStackIndex = siblingStacks.indexOf(closestStack);
198
+ const nextStackIndex = currentStackIndex + perpendicularDelta;
199
+ let adjacentStack;
200
+ if (ancestorStack.getAttribute("data-dx-stack-circular-focus") === "true") {
201
+ adjacentStack = siblingStacks[(nextStackIndex + siblingStacks.length) % siblingStacks.length];
202
+ } else {
203
+ if (nextStackIndex >= 0 && nextStackIndex < siblingStacks.length) {
204
+ adjacentStack = siblingStacks[nextStackIndex];
205
+ }
206
+ }
207
+ const adjacentStackSelfItem = adjacentStack?.closest(`[data-dx-stack-item=${ancestorStack.getAttribute("data-dx-stack")}]`);
208
+ const adjacentStackItems = adjacentStack ? Array.from(adjacentStack.querySelectorAll(`[data-dx-stack-item="${adjacentStack.getAttribute("data-dx-stack")}"]`)) : [];
209
+ if (adjacentStack && adjacentStackItems.length > 0) {
210
+ let closestItem = adjacentStackItems[0];
211
+ const lastFocusedItem2 = adjacentStack.querySelector(`[data-dx-item-id="${adjacentStack.getAttribute("data-dx-last-focused-item") ?? "never"}"]`);
212
+ if (lastFocusedItem2) {
213
+ closestItem = lastFocusedItem2;
214
+ } else {
215
+ const ownedItemRect = closestOwnedItem.getBoundingClientRect();
216
+ const targetPosition = closestStackOrientation === "vertical" ? ownedItemRect.top : ownedItemRect.left;
217
+ let closestDistance = Infinity;
218
+ for (const item of adjacentStackItems) {
219
+ const itemRect = item.getBoundingClientRect();
220
+ const itemPosition = closestStackOrientation === "vertical" ? itemRect.top : itemRect.left;
221
+ const distance = Math.abs(itemPosition - targetPosition);
222
+ if (distance < closestDistance) {
223
+ closestDistance = distance;
224
+ closestItem = item;
225
+ }
226
+ if (closestDistance <= PERPENDICULAR_FOCUS_THRESHHOLD) {
227
+ break;
228
+ }
229
+ }
230
+ }
231
+ event.preventDefault();
232
+ scrollIntoViewAndFocus(closestItem, closestStackOrientation);
233
+ } else if (adjacentStackSelfItem) {
234
+ event.preventDefault();
235
+ scrollIntoViewAndFocus(adjacentStackSelfItem, ancestorOrientation);
236
+ }
237
+ } else if (closestOwnedItem) {
238
+ const closestOwnedItemStack = closestOwnedItem.querySelector("[data-dx-stack]");
239
+ const closestOwnedItemStackItems = closestOwnedItemStack ? Array.from(closestOwnedItemStack.querySelectorAll(`[data-dx-stack-item="${closestOwnedItemStack.getAttribute("data-dx-stack")}"]`)) : [];
240
+ if (closestOwnedItemStackItems.length > 0) {
241
+ event.preventDefault();
242
+ scrollIntoViewAndFocus(closestOwnedItemStackItems[[
243
+ "ArrowUp",
244
+ "ArrowLeft"
245
+ ].includes(event.key) ? closestOwnedItemStackItems.length - 1 : 0], closestOwnedItemStack?.getAttribute("aria-orientation"));
246
+ }
247
+ }
248
+ }
150
249
  }
151
- }, [
152
- rail,
250
+ }
251
+ props.onKeyDown?.(event);
252
+ }, [
253
+ props.onKeyDown,
254
+ stackId,
255
+ circularFocus
256
+ ]);
257
+ const gridClasses = useMemo(() => {
258
+ if (!rail) {
259
+ return orientation === "horizontal" ? "grid-rows-1 pli-[--stack-gap]" : "grid-cols-1 plb-[--stack-gap]";
260
+ }
261
+ if (orientation === "horizontal") {
262
+ return railGridHorizontal;
263
+ } else {
264
+ return railGridVertical;
265
+ }
266
+ }, [
267
+ rail,
268
+ orientation,
269
+ size
270
+ ]);
271
+ useEffect(() => {
272
+ if (!(stackElement && Number.isFinite(separatorOnScroll))) {
273
+ return;
274
+ }
275
+ const observer = new MutationObserver(() => {
276
+ handleScroll();
277
+ });
278
+ observer.observe(stackElement, {
279
+ childList: true,
280
+ subtree: true
281
+ });
282
+ return () => {
283
+ observer.disconnect();
284
+ };
285
+ }, [
286
+ stackElement,
287
+ handleScroll
288
+ ]);
289
+ return /* @__PURE__ */ React.createElement(StackContext.Provider, {
290
+ value: {
153
291
  orientation,
154
- size
155
- ]);
156
- useEffect(() => {
157
- if (!(stackElement && Number.isFinite(separatorOnScroll))) {
158
- return;
159
- }
160
- const observer = new MutationObserver(() => {
161
- handleScroll();
162
- });
163
- observer.observe(stackElement, {
164
- childList: true,
165
- subtree: true
166
- });
167
- return () => {
168
- observer.disconnect();
169
- };
170
- }, [
171
- stackElement,
172
- handleScroll
173
- ]);
174
- return /* @__PURE__ */ React.createElement(StackContext.Provider, {
175
- value: {
176
- orientation,
177
- rail,
178
- size,
179
- onRearrange
180
- }
181
- }, /* @__PURE__ */ React.createElement("div", {
182
- ...props,
183
- ...arrowNavigationAttrs,
184
- className: mx("grid relative", gridClasses, (size === "contain" || size === "contain-fit-content") && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 max-bs-full bs-full" : "overflow-y-auto min-is-0 max-is-full is-full"), classNames),
185
- "data-rail": rail,
186
- "aria-orientation": orientation,
187
- style: styles,
188
- ref: composedItemRef,
189
- ...Number.isFinite(separatorOnScroll) && {
190
- onScroll: handleScroll
292
+ rail,
293
+ size,
294
+ onRearrange,
295
+ stackId
296
+ }
297
+ }, /* @__PURE__ */ React.createElement("div", {
298
+ ...props,
299
+ className: mx("grid relative [--stack-gap:var(--dx-trimXs)]", gridClasses, size === "contain" && (orientation === "horizontal" ? "overflow-x-auto overscroll-x-contain min-bs-0 max-bs-full bs-full" : "overflow-y-auto min-is-0 max-is-full is-full"), classNames),
300
+ onKeyDown: handleKeyDown,
301
+ onBlur: handleBlur,
302
+ "data-dx-stack": stackId,
303
+ "data-dx-stack-circular-focus": circularFocus,
304
+ "data-dx-last-focused-item": lastFocusedItem,
305
+ "data-rail": rail,
306
+ "aria-orientation": orientation,
307
+ style: styles,
308
+ ref: composedItemRef,
309
+ ...Number.isFinite(separatorOnScroll) && {
310
+ onScroll: handleScroll
311
+ }
312
+ }, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
313
+ lineInset: 8,
314
+ terminalInset: -8,
315
+ gap: -8,
316
+ edge: orientation === "horizontal" ? "left" : "top"
317
+ })));
318
+ });
319
+
320
+ // src/components/CardStack/CardStack.tsx
321
+ var cardStackDefaultInlineSizeRem = cardDefaultInlineSize + 2.125;
322
+ var cardStackRoot = "flex flex-col";
323
+ var CardStackRoot = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
324
+ const Root = asChild ? Slot : "div";
325
+ const rootProps = asChild ? {
326
+ classNames: [
327
+ cardStackRoot,
328
+ classNames
329
+ ]
330
+ } : {
331
+ className: mx2(cardStackRoot, classNames),
332
+ role
333
+ };
334
+ return /* @__PURE__ */ React2.createElement(Root, {
335
+ ...props,
336
+ ...rootProps,
337
+ ref: forwardedRef
338
+ }, children);
339
+ });
340
+ var cardStackContent = "shrink min-bs-0 grid dx-focus-ring-group-x-indicator bg-baseSurface";
341
+ var CardStackContent = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "none", footer, ...props }, forwardedRef) => {
342
+ const Root = asChild ? Slot : "div";
343
+ const baseClassNames = footer ? [
344
+ cardStackContent,
345
+ railGridHorizontalContainFitContent
346
+ ] : [
347
+ cardStackContent
348
+ ];
349
+ const rootProps = asChild ? {
350
+ classNames: [
351
+ ...baseClassNames,
352
+ classNames
353
+ ]
354
+ } : {
355
+ className: mx2(...baseClassNames, classNames),
356
+ role
357
+ };
358
+ return /* @__PURE__ */ React2.createElement(Root, {
359
+ ...props,
360
+ ...rootProps,
361
+ "data-scroll-separator": "false",
362
+ ref: forwardedRef
363
+ }, children);
364
+ });
365
+ var CardStackStack = /* @__PURE__ */ forwardRef2(({ children, classNames, itemsCount = 0, ...props }, forwardedRef) => {
366
+ return /* @__PURE__ */ React2.createElement(Stack, {
367
+ orientation: "vertical",
368
+ size: "contain",
369
+ rail: false,
370
+ classNames: (
371
+ /* NOTE(thure): Do not let this element have zero intrinsic size, otherwise the drop indicator will not display. See #9035. */
372
+ [
373
+ "plb-2",
374
+ classNames
375
+ ]
376
+ ),
377
+ itemsCount,
378
+ separatorOnScroll: 9,
379
+ "data-density": "fine",
380
+ ...props,
381
+ ref: forwardedRef
382
+ }, children);
383
+ });
384
+ var cardStackItem = "contain-layout pli-2 plb-1 first-of-type:pbs-0 last-of-type:pbe-0";
385
+ var CardStackItem = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
386
+ const Root = asChild ? Slot : "div";
387
+ const rootProps = asChild ? {
388
+ classNames: [
389
+ cardStackItem,
390
+ classNames
391
+ ]
392
+ } : {
393
+ className: mx2(cardStackItem, classNames),
394
+ role
395
+ };
396
+ return /* @__PURE__ */ React2.createElement(Root, {
397
+ ...props,
398
+ ...rootProps,
399
+ ref: forwardedRef
400
+ }, children);
401
+ });
402
+ var cardStackHeading = "mli-2 order-first bg-transparent rounded-bs-md flex items-center";
403
+ var CardStackHeading = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "heading", ...props }, forwardedRef) => {
404
+ const Root = asChild ? Slot : "div";
405
+ const rootProps = asChild ? {
406
+ classNames: [
407
+ cardStackHeading,
408
+ classNames
409
+ ]
410
+ } : {
411
+ className: mx2(cardStackHeading, classNames),
412
+ role
413
+ };
414
+ return /* @__PURE__ */ React2.createElement(Root, {
415
+ ...props,
416
+ ...rootProps,
417
+ ref: forwardedRef
418
+ }, children);
419
+ });
420
+ var cardStackFooter = 'plb-2 mli-2 border-bs border-transparent [[data-scroll-separator-end="true"]_&]:border-subduedSeparator';
421
+ var CardStackFooter = /* @__PURE__ */ forwardRef2(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
422
+ const Root = asChild ? Slot : "div";
423
+ const rootProps = asChild ? {
424
+ classNames: [
425
+ cardStackFooter,
426
+ classNames
427
+ ]
428
+ } : {
429
+ className: mx2(cardStackFooter, classNames),
430
+ role
431
+ };
432
+ return /* @__PURE__ */ React2.createElement(Root, {
433
+ ...props,
434
+ ...rootProps,
435
+ ref: forwardedRef
436
+ }, children);
437
+ });
438
+ var CardStackDragHandle = Card.DragHandle;
439
+ var CardStack = {
440
+ Root: CardStackRoot,
441
+ Content: CardStackContent,
442
+ Stack: CardStackStack,
443
+ Heading: CardStackHeading,
444
+ Footer: CardStackFooter,
445
+ DragHandle: CardStackDragHandle,
446
+ Item: CardStackItem
447
+ };
448
+
449
+ // src/components/CardStack/CardStackDragPreview.tsx
450
+ import React3 from "react";
451
+ import { IconButton, ScrollArea, useTranslation } from "@dxos/react-ui";
452
+ import { mx as mx3 } from "@dxos/ui-theme";
453
+
454
+ // src/translations.ts
455
+ var translationKey = "@dxos/react-ui-stack";
456
+ var translations = [
457
+ {
458
+ "en-US": {
459
+ [translationKey]: {
460
+ "resize label": "Drag to resize",
461
+ "drag handle label": "Drag to rearrange",
462
+ "pin start label": "Pin to the left sidebar",
463
+ "pin end label": "Pin to the right sidebar",
464
+ "increment start label": "Move to the left",
465
+ "increment end label": "Move to the right",
466
+ "close label": "Close",
467
+ "minify label": "Minify"
191
468
  }
192
- }, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
193
- lineInset: 8,
194
- terminalInset: -8,
195
- gap: -8,
196
- edge: orientation === "horizontal" ? "left" : "top"
197
- })));
198
- } finally {
199
- _effect.f();
469
+ }
200
470
  }
201
- });
471
+ ];
202
472
 
203
- // packages/ui/react-ui-stack/src/components/StackItem/StackItem.tsx
204
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
473
+ // src/components/CardStack/CardStackDragPreview.tsx
474
+ var CardStackDragPreviewRoot = ({ children }) => {
475
+ return /* @__PURE__ */ React3.createElement("div", {
476
+ className: "p-2"
477
+ }, /* @__PURE__ */ React3.createElement("div", {
478
+ className: "rounded-md max-bs-[calc(100dvh-1rem)] overflow-hidden bg-baseSurface border border-separator ring-focusLine ring-neutralFocusIndicator flex flex-col"
479
+ }, children));
480
+ };
481
+ var CardStackDragPreviewHeading = ({ children }) => {
482
+ const { t } = useTranslation(translationKey);
483
+ return /* @__PURE__ */ React3.createElement("div", {
484
+ className: "flex items-center p-2"
485
+ }, /* @__PURE__ */ React3.createElement(IconButton, {
486
+ iconOnly: true,
487
+ icon: "ph--dots-six-vertical--regular",
488
+ variant: "ghost",
489
+ label: t("column drag handle label"),
490
+ classNames: "pli-2"
491
+ }), children);
492
+ };
493
+ var CardStackDragPreviewContent = ({ children, itemsCount = 0 }) => {
494
+ return /* @__PURE__ */ React3.createElement(ScrollArea.Root, {
495
+ orientation: "vertical"
496
+ }, /* @__PURE__ */ React3.createElement(ScrollArea.Viewport, {
497
+ classNames: mx3("pli-2 plb-1 gap-2", itemsCount > 0 ? "plb-2" : "plb-1")
498
+ }, children));
499
+ };
500
+ var CardStackDragPreviewFooter = ({ children }) => {
501
+ return /* @__PURE__ */ React3.createElement("div", {
502
+ className: "p-2 border-bs border-separator"
503
+ }, children);
504
+ };
505
+ var CardStackDragPreview = {
506
+ Root: CardStackDragPreviewRoot,
507
+ Heading: CardStackDragPreviewHeading,
508
+ Content: CardStackDragPreviewContent,
509
+ Footer: CardStackDragPreviewFooter
510
+ };
511
+
512
+ // src/components/StackItem/StackItem.tsx
205
513
  import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
206
514
  import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
207
515
  import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
208
516
  import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
209
517
  import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
210
- import { useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
518
+ import { useFocusableGroup } from "@fluentui/react-tabster";
211
519
  import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
212
- import React8, { forwardRef as forwardRef5, useLayoutEffect as useLayoutEffect2, useState as useState4, useCallback as useCallback2, useMemo as useMemo3 } from "react";
520
+ import React10, { forwardRef as forwardRef6, useCallback as useCallback2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useState as useState4 } from "react";
213
521
  import { createPortal } from "react-dom";
214
522
  import { ListItem as ListItem2 } from "@dxos/react-ui";
215
523
  import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
216
- import { mx as mx5 } from "@dxos/react-ui-theme";
524
+ import { mx as mx7 } from "@dxos/ui-theme";
217
525
 
218
- // packages/ui/react-ui-stack/src/components/StackItem/StackItemContent.tsx
219
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
220
- import React2, { forwardRef as forwardRef2, useMemo as useMemo2 } from "react";
221
- import { mx as mx2 } from "@dxos/react-ui-theme";
222
- var StackItemContent = /* @__PURE__ */ forwardRef2(({ children, toolbar, statusbar, layoutManaged, classNames, size = "intrinsic", ...props }, forwardedRef) => {
223
- var _effect = _useSignals2();
224
- try {
225
- const { size: stackItemSize } = useStack();
226
- const { role } = useStackItem();
227
- const style = useMemo2(() => layoutManaged ? {} : {
228
- gridTemplateRows: [
229
- ...toolbar ? [
230
- role === "section" ? "calc(var(--toolbar-size) - 1px)" : "var(--toolbar-size)"
231
- ] : [],
232
- "1fr",
233
- ...statusbar ? [
234
- "var(--statusbar-size)"
235
- ] : []
236
- ].join(" ")
237
- }, [
238
- toolbar,
239
- statusbar,
240
- layoutManaged
241
- ]);
242
- return /* @__PURE__ */ React2.createElement("div", {
243
- role: "none",
244
- ...props,
245
- className: mx2("group grid grid-cols-[100%]", stackItemSize === "contain" && "min-bs-0 overflow-hidden", size === "video" ? "aspect-video" : size === "square" && "aspect-square", toolbar && "[&_.dx-toolbar]:relative [&_.dx-toolbar]:border-be [&_.dx-toolbar]:border-subduedSeparator", role === "section" && toolbar && "[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:block-start-0 [&_.dx-toolbar]:-mbe-px [&_.dx-toolbar]:min-is-0", classNames),
246
- style,
247
- "data-popover-collision-boundary": true,
248
- ref: forwardedRef
249
- }, children);
250
- } finally {
251
- _effect.f();
252
- }
526
+ // src/components/StackItem/StackItemContent.tsx
527
+ import React4, { forwardRef as forwardRef3, useMemo as useMemo2 } from "react";
528
+ import { mx as mx4 } from "@dxos/ui-theme";
529
+ var StackItemContent = /* @__PURE__ */ forwardRef3(({ classNames, children, toolbar, statusbar, ...props }, forwardedRef) => {
530
+ const { size: stackItemSize } = useStack();
531
+ const { role } = useStackItem();
532
+ const style = useMemo2(() => ({
533
+ gridTemplateRows: [
534
+ toolbar && role === "section" ? "calc(var(--toolbar-size) - 1px)" : "var(--toolbar-size)",
535
+ "1fr",
536
+ statusbar && "var(--statusbar-size)"
537
+ ].filter(Boolean).join(" ")
538
+ }), [
539
+ toolbar,
540
+ statusbar
541
+ ]);
542
+ return /* @__PURE__ */ React4.createElement("div", {
543
+ ...props,
544
+ role: "none",
545
+ style,
546
+ className: mx4("group grid grid-cols-[100%] density-coarse", stackItemSize === "contain" && "min-bs-0 overflow-hidden", toolbar && role === "section" && "[&_.dx-toolbar]:sticky [&_.dx-toolbar]:z-[1] [&_.dx-toolbar]:block-start-0 [&_.dx-toolbar]:-mbe-px [&_.dx-toolbar]:min-is-0", toolbar && "[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-be [&>.dx-toolbar]:border-subduedSeparator", classNames),
547
+ "data-popover-collision-boundary": true,
548
+ ref: forwardedRef
549
+ }, children);
253
550
  });
551
+ StackItemContent.displayName = "StackItemContent";
254
552
 
255
- // packages/ui/react-ui-stack/src/components/StackItem/StackItemDragHandle.tsx
256
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
257
- import { Slot } from "@radix-ui/react-slot";
258
- import React3 from "react";
553
+ // src/components/StackItem/StackItemDragHandle.tsx
554
+ import { Slot as Slot2 } from "@radix-ui/react-slot";
555
+ import React5 from "react";
259
556
  var StackItemDragHandle = ({ asChild, children }) => {
260
- var _effect = _useSignals3();
261
- try {
262
- const { selfDragHandleRef } = useStackItem();
263
- const Root = asChild ? Slot : "div";
264
- return /* @__PURE__ */ React3.createElement(Root, {
265
- ref: selfDragHandleRef,
266
- role: "button"
267
- }, children);
268
- } finally {
269
- _effect.f();
270
- }
557
+ const { selfDragHandleRef } = useStackItem();
558
+ const Root = asChild ? Slot2 : "div";
559
+ return /* @__PURE__ */ React5.createElement(Root, {
560
+ ref: selfDragHandleRef,
561
+ role: "button"
562
+ }, children);
271
563
  };
272
564
 
273
- // packages/ui/react-ui-stack/src/components/StackItem/StackItemHeading.tsx
274
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
275
- import { useFocusableGroup } from "@fluentui/react-tabster";
276
- import { Slot as Slot2 } from "@radix-ui/react-slot";
277
- import React4, { forwardRef as forwardRef3 } from "react";
565
+ // src/components/StackItem/StackItemHeading.tsx
566
+ import { Slot as Slot3 } from "@radix-ui/react-slot";
567
+ import React6, { forwardRef as forwardRef4 } from "react";
278
568
  import { useAttention } from "@dxos/react-ui-attention";
279
- import { mx as mx3 } from "@dxos/react-ui-theme";
569
+ import { mx as mx5 } from "@dxos/ui-theme";
280
570
  var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, ...props }) => {
281
- var _effect = _useSignals4();
282
- try {
283
- const { orientation } = useStack();
284
- const focusableGroupAttrs = useFocusableGroup({
285
- tabBehavior: "limited"
286
- });
287
- const Root = asChild ? Slot2 : "div";
288
- return /* @__PURE__ */ React4.createElement(Root, {
289
- role: "heading",
290
- ...props,
291
- tabIndex: 0,
292
- ...focusableGroupAttrs,
293
- className: mx3("flex items-center dx-focus-ring-inset-over-all relative !border-is-0 bg-headerSurface", separateOnScroll ? 'border-transparent [[data-scroll-separator="true"]_&]:border-subduedSeparator' : "border-subduedSeparator", orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", orientation === "horizontal" ? "border-be" : "border-ie", classNames)
294
- }, children);
295
- } finally {
296
- _effect.f();
297
- }
571
+ const { orientation } = useStack();
572
+ const Root = asChild ? Slot3 : "div";
573
+ return /* @__PURE__ */ React6.createElement(Root, {
574
+ role: "heading",
575
+ ...props,
576
+ className: mx5("flex items-center !border-is-0 bg-headerSurface", separateOnScroll ? 'border-transparent [[data-scroll-separator="true"]_&]:border-subduedSeparator' : "border-subduedSeparator", orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", orientation === "horizontal" ? "border-be" : "border-ie", classNames)
577
+ }, children);
298
578
  };
299
579
  var StackItemHeadingStickyContent = ({ children }) => {
300
- var _effect = _useSignals4();
301
- try {
302
- return /* @__PURE__ */ React4.createElement("div", {
303
- role: "none",
304
- className: "sticky block-start-0 bg-[--sticky-bg] p-1 is-full"
305
- }, children);
306
- } finally {
307
- _effect.f();
308
- }
580
+ return /* @__PURE__ */ React6.createElement("div", {
581
+ role: "none",
582
+ className: "sticky block-start-0 bg-[--sticky-bg] p-1 is-full"
583
+ }, children);
309
584
  };
310
- var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related, classNames, ...props }, forwardedRef) => {
311
- var _effect = _useSignals4();
312
- try {
313
- const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
314
- return /* @__PURE__ */ React4.createElement("h1", {
315
- ...props,
316
- "data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
317
- className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center", classNames),
318
- ref: forwardedRef
319
- });
320
- } finally {
321
- _effect.f();
322
- }
585
+ var StackItemHeadingLabel = /* @__PURE__ */ forwardRef4(({ attendableId, related, classNames, ...props }, forwardedRef) => {
586
+ const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
587
+ return /* @__PURE__ */ React6.createElement("h1", {
588
+ ...props,
589
+ "data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
590
+ className: mx5("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center", classNames),
591
+ ref: forwardedRef
592
+ });
323
593
  });
324
594
 
325
- // packages/ui/react-ui-stack/src/components/StackItem/StackItemResizeHandle.tsx
326
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
327
- import React5 from "react";
595
+ // src/components/StackItem/StackItemResizeHandle.tsx
596
+ import React7 from "react";
328
597
  import { ResizeHandle } from "@dxos/react-ui-dnd";
329
598
  var MIN_WIDTH = 20;
330
599
  var MIN_HEIGHT = 3;
331
600
  var StackItemResizeHandle = () => {
332
- var _effect = _useSignals5();
333
- try {
334
- const { orientation } = useStack();
335
- const { setSize, size } = useStackItem();
336
- return /* @__PURE__ */ React5.createElement(ResizeHandle, {
337
- side: orientation === "horizontal" ? "inline-end" : "block-end",
338
- fallbackSize: DEFAULT_EXTRINSIC_SIZE,
339
- minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
340
- size,
341
- onSizeChange: setSize
342
- });
343
- } finally {
344
- _effect.f();
345
- }
601
+ const { orientation } = useStack();
602
+ const { setSize, size } = useStackItem();
603
+ return /* @__PURE__ */ React7.createElement(ResizeHandle, {
604
+ side: orientation === "horizontal" ? "inline-end" : "block-end",
605
+ fallbackSize: DEFAULT_EXTRINSIC_SIZE,
606
+ minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
607
+ size,
608
+ onSizeChange: setSize
609
+ });
346
610
  };
347
611
 
348
- // packages/ui/react-ui-stack/src/components/StackItem/StackItemSigil.tsx
349
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
350
- import React7, { Fragment, forwardRef as forwardRef4, useState as useState3 } from "react";
612
+ // src/components/StackItem/StackItemSigil.tsx
613
+ import React9, { Fragment, forwardRef as forwardRef5, useState as useState3 } from "react";
351
614
  import { keySymbols } from "@dxos/keyboard";
352
- import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
615
+ import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
353
616
  import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
354
- import { descriptionText, mx as mx4 } from "@dxos/react-ui-theme";
617
+ import { descriptionText, mx as mx6 } from "@dxos/ui-theme";
355
618
  import { getHostPlatform } from "@dxos/util";
356
619
 
357
- // packages/ui/react-ui-stack/src/components/StackItem/MenuSignifier.tsx
358
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
359
- import React6 from "react";
360
- var MenuSignifierHorizontal = () => {
361
- var _effect = _useSignals6();
362
- try {
363
- return /* @__PURE__ */ React6.createElement("svg", {
364
- className: "absolute block-end-[7px]",
365
- width: 20,
366
- height: 2,
367
- viewBox: "0 0 20 2",
368
- stroke: "currentColor",
369
- opacity: 0.5
370
- }, /* @__PURE__ */ React6.createElement("line", {
371
- x1: 0.5,
372
- y1: 0.75,
373
- x2: 19,
374
- y2: 0.75,
375
- strokeWidth: 1.25,
376
- strokeLinecap: "round",
377
- strokeDasharray: "6 20",
378
- strokeDashoffset: "-6.5"
379
- }));
380
- } finally {
381
- _effect.f();
382
- }
383
- };
384
-
385
- // packages/ui/react-ui-stack/src/translations.ts
386
- var translationKey = "stack";
387
- var translations_default = [
388
- {
389
- "en-US": {
390
- [translationKey]: {
391
- "resize label": "Drag to resize",
392
- "drag handle label": "Drag to rearrange",
393
- "pin start label": "Pin to the left sidebar",
394
- "pin end label": "Pin to the right sidebar",
395
- "increment start label": "Move to the left",
396
- "increment end label": "Move to the right",
397
- "close label": "Close",
398
- "minify label": "Minify"
399
- }
400
- }
401
- }
402
- ];
620
+ // src/components/StackItem/MenuSignifier.tsx
621
+ import React8 from "react";
622
+ var MenuSignifierHorizontal = () => /* @__PURE__ */ React8.createElement("svg", {
623
+ className: "absolute block-end-[7px]",
624
+ width: 20,
625
+ height: 2,
626
+ viewBox: "0 0 20 2",
627
+ stroke: "currentColor",
628
+ opacity: 0.5
629
+ }, /* @__PURE__ */ React8.createElement("line", {
630
+ x1: 0.5,
631
+ y1: 0.75,
632
+ x2: 19,
633
+ y2: 0.75,
634
+ strokeWidth: 1.25,
635
+ strokeLinecap: "round",
636
+ strokeDasharray: "6 20",
637
+ strokeDashoffset: "-6.5"
638
+ }));
403
639
 
404
- // packages/ui/react-ui-stack/src/components/StackItem/StackItemSigil.tsx
405
- var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNames, related, isMenu = true, children, ...props }, forwardedRef) => {
406
- var _effect = _useSignals7();
407
- try {
408
- const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
409
- const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
410
- return /* @__PURE__ */ React7.createElement(Button, {
411
- ...props,
412
- variant,
413
- classNames: [
414
- "shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative app-no-drag",
415
- classNames
416
- ],
417
- ref: forwardedRef
418
- }, isMenu && /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
419
- } finally {
420
- _effect.f();
421
- }
640
+ // src/components/StackItem/StackItemSigil.tsx
641
+ var StackItemSigilButton = /* @__PURE__ */ forwardRef5(({ attendableId, classNames, related, isMenu = true, children, ...props }, forwardedRef) => {
642
+ const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
643
+ const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
644
+ return /* @__PURE__ */ React9.createElement(Button, {
645
+ ...props,
646
+ variant,
647
+ classNames: [
648
+ "shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative app-no-drag",
649
+ classNames
650
+ ],
651
+ ref: forwardedRef
652
+ }, isMenu && /* @__PURE__ */ React9.createElement(MenuSignifierHorizontal, null), children);
422
653
  });
423
- var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
424
- var _effect = _useSignals7();
425
- try {
426
- const { t } = useTranslation(translationKey);
427
- const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
428
- const hasActions = actionGroups && actionGroups.length > 0;
429
- const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
430
- attendableId,
431
- related,
432
- isMenu: hasActions,
433
- // TODO(wittjosiah): Better disabling of interactive styles when no action are available.
434
- // Remove underscore icon when no actions are available?
435
- classNames: !hasActions && "cursor-default"
436
- }, /* @__PURE__ */ React7.createElement("span", {
437
- className: "sr-only"
438
- }, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
439
- icon,
440
- size: 5
441
- }));
442
- if (!hasActions) {
443
- return button;
444
- }
445
- return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
446
- open: optionsMenuOpen,
447
- onOpenChange: setOptionsMenuOpen
448
- }, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
449
- asChild: true,
450
- ref: forwardedRef
451
- }, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
452
- classNames: "z-[31]"
453
- }, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
454
- const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
455
- return /* @__PURE__ */ React7.createElement(Fragment, {
456
- key: index
457
- }, separator, actions.map((action) => {
458
- const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
459
- const menuItemType = action.properties.menuItemType;
460
- const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
461
- return /* @__PURE__ */ React7.createElement(Root, {
462
- key: action.id,
463
- onClick: (event) => {
464
- if (action.properties.disabled) {
465
- return;
466
- }
467
- event.stopPropagation();
468
- setOptionsMenuOpen(false);
469
- onAction?.(action);
470
- },
471
- classNames: "gap-2",
472
- disabled: action.properties.disabled,
473
- checked: menuItemType === "toggle" ? action.properties.isChecked : void 0,
474
- ...action.properties?.testId && {
475
- "data-testid": action.properties.testId
654
+ var StackItemSigil = /* @__PURE__ */ forwardRef5(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
655
+ const { t } = useTranslation2(translationKey);
656
+ const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
657
+ const hasActions = actionGroups && actionGroups.length > 0;
658
+ const button = /* @__PURE__ */ React9.createElement(StackItemSigilButton, {
659
+ attendableId,
660
+ related,
661
+ isMenu: hasActions,
662
+ // TODO(wittjosiah): Better disabling of interactive styles when no action are available.
663
+ // Remove underscore icon when no actions are available?
664
+ classNames: !hasActions && "cursor-default"
665
+ }, /* @__PURE__ */ React9.createElement("span", {
666
+ className: "sr-only"
667
+ }, triggerLabel), /* @__PURE__ */ React9.createElement(Icon, {
668
+ icon,
669
+ size: 5
670
+ }));
671
+ if (!hasActions) {
672
+ return button;
673
+ }
674
+ return /* @__PURE__ */ React9.createElement(DropdownMenu.Root, {
675
+ open: optionsMenuOpen,
676
+ onOpenChange: setOptionsMenuOpen
677
+ }, /* @__PURE__ */ React9.createElement(DropdownMenu.Trigger, {
678
+ asChild: true,
679
+ ref: forwardedRef
680
+ }, button), /* @__PURE__ */ React9.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React9.createElement(DropdownMenu.Content, {
681
+ classNames: "z-[31]"
682
+ }, /* @__PURE__ */ React9.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
683
+ const separator = index > 0 ? /* @__PURE__ */ React9.createElement(DropdownMenu.Separator, null) : null;
684
+ return /* @__PURE__ */ React9.createElement(Fragment, {
685
+ key: index
686
+ }, separator, actions.map((action) => {
687
+ const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
688
+ const menuItemType = action.properties.menuItemType;
689
+ const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
690
+ return /* @__PURE__ */ React9.createElement(Root, {
691
+ key: action.id,
692
+ onClick: (event) => {
693
+ if (action.properties.disabled) {
694
+ return;
476
695
  }
477
- }, /* @__PURE__ */ React7.createElement(Icon, {
478
- icon: action.properties.icon ?? "ph--placeholder--regular",
479
- size: 4
480
- }), /* @__PURE__ */ React7.createElement("span", {
481
- className: "grow truncate"
482
- }, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React7.createElement(DropdownMenu.ItemIndicator, {
483
- asChild: true
484
- }, /* @__PURE__ */ React7.createElement(Icon, {
485
- icon: "ph--check--regular",
486
- size: 4
487
- })), shortcut && /* @__PURE__ */ React7.createElement("span", {
488
- className: mx4("shrink-0", descriptionText)
489
- }, keySymbols(shortcut).join("")));
490
- }));
491
- }), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
492
- } finally {
493
- _effect.f();
494
- }
696
+ event.stopPropagation();
697
+ setOptionsMenuOpen(false);
698
+ onAction?.(action);
699
+ },
700
+ classNames: "gap-2",
701
+ disabled: action.properties.disabled,
702
+ checked: menuItemType === "toggle" ? action.properties.isChecked : void 0,
703
+ ...action.properties?.testId && {
704
+ "data-testid": action.properties.testId
705
+ }
706
+ }, /* @__PURE__ */ React9.createElement(Icon, {
707
+ icon: action.properties.icon ?? "ph--placeholder--regular",
708
+ size: 4
709
+ }), /* @__PURE__ */ React9.createElement("span", {
710
+ className: "grow truncate"
711
+ }, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React9.createElement(DropdownMenu.ItemIndicator, {
712
+ asChild: true
713
+ }, /* @__PURE__ */ React9.createElement(Icon, {
714
+ icon: "ph--check--regular",
715
+ size: 4
716
+ })), shortcut && /* @__PURE__ */ React9.createElement("span", {
717
+ className: mx6("shrink-0", descriptionText)
718
+ }, keySymbols(shortcut).join("")));
719
+ }));
720
+ }), children), /* @__PURE__ */ React9.createElement(DropdownMenu.Arrow, null))));
495
721
  });
496
722
 
497
- // packages/ui/react-ui-stack/src/components/StackItem/StackItem.tsx
723
+ // src/components/StackItem/StackItem.tsx
498
724
  var DEFAULT_HORIZONTAL_SIZE = 48;
499
725
  var DEFAULT_VERTICAL_SIZE = "min-content";
500
726
  var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
501
- var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, prevSiblingId, nextSiblingId, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
502
- var _effect = _useSignals8();
503
- try {
504
- const [itemElement, itemRef] = useState4(null);
505
- const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
506
- const [closestEdge, setEdge] = useState4(null);
507
- const [sourceId, setSourceId] = useState4(null);
508
- const [dragState, setDragState] = useState4(idle);
509
- const { orientation, rail, onRearrange } = useStack();
510
- const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(propsSize);
511
- const Root = role ?? "div";
512
- const composedItemRef = composeRefs2(itemRef, forwardedRef);
513
- const setSize = useCallback2((nextSize, commit) => {
514
- setInternalSize(nextSize);
515
- if (commit) {
516
- onSizeChange?.(nextSize);
517
- }
518
- }, [
519
- onSizeChange
520
- ]);
521
- const type = orientation === "horizontal" ? "column" : "card";
522
- useLayoutEffect2(() => {
523
- if (!itemElement || !onRearrange || disableRearrange) {
524
- return;
727
+ var StackItemRoot = /* @__PURE__ */ forwardRef6(({ item, children, classNames, size: propsSize, onSizeChange, role, order, prevSiblingId, nextSiblingId, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
728
+ const [itemElement, itemRef] = useState4(null);
729
+ const composedItemRef = composeRefs2(itemRef, forwardedRef);
730
+ const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
731
+ const [closestEdge, setEdge] = useState4(null);
732
+ const [sourceId, setSourceId] = useState4(null);
733
+ const [dragState, setDragState] = useState4(idle);
734
+ const { orientation, rail, onRearrange, size: stackSize, stackId } = useStack();
735
+ const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(propsSize);
736
+ const Root = role ?? "div";
737
+ const setSize = useCallback2((nextSize, commit) => {
738
+ setInternalSize(nextSize);
739
+ if (commit) {
740
+ onSizeChange?.(nextSize);
741
+ }
742
+ }, [
743
+ onSizeChange
744
+ ]);
745
+ const type = orientation === "horizontal" ? "column" : "card";
746
+ useLayoutEffect2(() => {
747
+ if (!itemElement || !onRearrange || disableRearrange) {
748
+ return;
749
+ }
750
+ return combine2(draggable({
751
+ element: itemElement,
752
+ ...selfDragHandleElement && {
753
+ dragHandle: selfDragHandleElement
754
+ },
755
+ getInitialData: () => ({
756
+ id: item.id,
757
+ type
758
+ }),
759
+ onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
760
+ document.body.setAttribute("data-drag-preview", "true");
761
+ const offsetFn = preserveOffsetOnSource({
762
+ element: source.element,
763
+ input: location.current.input
764
+ });
765
+ const rect = source.element.getBoundingClientRect();
766
+ setCustomNativeDragPreview({
767
+ nativeSetDragImage,
768
+ getOffset: ({ container }) => {
769
+ return offsetFn({
770
+ container
771
+ });
772
+ },
773
+ render: ({ container }) => {
774
+ container.style.width = rect.width + "px";
775
+ setDragState({
776
+ type: "preview",
777
+ container,
778
+ item
779
+ });
780
+ return () => {
781
+ };
782
+ }
783
+ });
784
+ },
785
+ onDragStart: () => {
786
+ document.body.removeAttribute("data-drag-preview");
787
+ itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
788
+ setDragState({
789
+ type: "is-dragging",
790
+ item
791
+ });
792
+ },
793
+ onDrop: () => {
794
+ itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
795
+ setDragState(idle);
525
796
  }
526
- return combine2(draggable({
527
- element: itemElement,
528
- ...selfDragHandleElement && {
529
- dragHandle: selfDragHandleElement
530
- },
531
- getInitialData: () => ({
797
+ }), dropTargetForElements2({
798
+ element: itemElement,
799
+ getData: ({ input, element }) => {
800
+ return attachClosestEdge2({
532
801
  id: item.id,
533
802
  type
534
- }),
535
- onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
536
- document.body.setAttribute("data-drag-preview", "true");
537
- const offsetFn = preserveOffsetOnSource({
538
- element: source.element,
539
- input: location.current.input
540
- });
541
- const rect = source.element.getBoundingClientRect();
542
- setCustomNativeDragPreview({
543
- nativeSetDragImage,
544
- getOffset: ({ container }) => {
545
- return offsetFn({
546
- container
547
- });
548
- },
549
- render: ({ container }) => {
550
- container.style.width = rect.width + "px";
551
- setDragState({
552
- type: "preview",
553
- container,
554
- item
555
- });
556
- return () => {
557
- };
558
- }
559
- });
560
- },
561
- onDragStart: () => {
562
- document.body.removeAttribute("data-drag-preview");
563
- itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
564
- setDragState({
565
- type: "is-dragging",
566
- item
567
- });
568
- },
569
- onDrop: () => {
570
- itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
571
- setDragState(idle);
803
+ }, {
804
+ input,
805
+ element,
806
+ allowedEdges: orientation === "horizontal" ? [
807
+ "left",
808
+ "right"
809
+ ] : [
810
+ "top",
811
+ "bottom"
812
+ ]
813
+ });
814
+ },
815
+ onDragEnter: ({ self, source }) => {
816
+ if (source.data.type === self.data.type) {
817
+ setEdge(extractClosestEdge2(self.data));
818
+ setSourceId(source.data.id);
572
819
  }
573
- }), dropTargetForElements2({
574
- element: itemElement,
575
- getData: ({ input, element }) => {
576
- return attachClosestEdge2({
577
- id: item.id,
578
- type
579
- }, {
580
- input,
581
- element,
582
- allowedEdges: orientation === "horizontal" ? [
583
- "left",
584
- "right"
585
- ] : [
586
- "top",
587
- "bottom"
588
- ]
589
- });
590
- },
591
- onDragEnter: ({ self, source }) => {
592
- if (source.data.type === self.data.type) {
593
- setEdge(extractClosestEdge2(self.data));
594
- setSourceId(source.data.id);
595
- }
596
- },
597
- onDrag: ({ self, source }) => {
598
- if (source.data.type === self.data.type) {
599
- setEdge(extractClosestEdge2(self.data));
600
- setSourceId(source.data.id);
601
- }
602
- },
603
- onDragLeave: () => {
604
- setEdge(null);
605
- setSourceId(null);
606
- },
607
- onDrop: ({ self, source }) => {
608
- setEdge(null);
609
- setSourceId(null);
610
- if (source.data.type === self.data.type) {
611
- onRearrange(source.data, self.data, extractClosestEdge2(self.data));
612
- }
820
+ },
821
+ onDrag: ({ self, source }) => {
822
+ if (source.data.type === self.data.type) {
823
+ setEdge(extractClosestEdge2(self.data));
824
+ setSourceId(source.data.id);
825
+ }
826
+ },
827
+ onDragLeave: () => {
828
+ setEdge(null);
829
+ setSourceId(null);
830
+ },
831
+ onDrop: ({ self, source }) => {
832
+ setEdge(null);
833
+ setSourceId(null);
834
+ if (source.data.type === self.data.type) {
835
+ onRearrange(source.data, self.data, extractClosestEdge2(self.data));
613
836
  }
614
- }));
615
- }, [
616
- orientation,
617
- item,
618
- onRearrange,
619
- selfDragHandleElement,
620
- itemElement
621
- ]);
622
- const focusableGroupAttrs = useFocusableGroup2({
623
- tabBehavior: "limited"
624
- });
625
- const shouldShowDropIndicator = () => {
626
- if (!closestEdge || !sourceId) {
627
- return false;
628
- }
629
- if (sourceId === item.id) {
630
- return false;
631
- }
632
- const isTrailingEdgeOfPrevSibling = prevSiblingId !== void 0 && sourceId === prevSiblingId && (orientation === "horizontal" && closestEdge === "left" || orientation === "vertical" && closestEdge === "top");
633
- if (isTrailingEdgeOfPrevSibling) {
634
- return false;
635
- }
636
- const isLeadingEdgeOfNextSibling = nextSiblingId !== void 0 && sourceId === nextSiblingId && (orientation === "horizontal" && closestEdge === "right" || orientation === "vertical" && closestEdge === "bottom");
637
- if (isLeadingEdgeOfNextSibling) {
638
- return false;
639
837
  }
640
- return true;
641
- };
642
- const stackItemContextValue = useMemo3(() => ({
643
- selfDragHandleRef,
644
- size,
645
- setSize,
646
- state: dragState,
647
- setState: setDragState,
648
- role
649
- }), [
650
- selfDragHandleRef,
651
- size,
652
- setSize,
653
- dragState,
654
- setDragState,
655
- role
656
- ]);
657
- return /* @__PURE__ */ React8.createElement(StackItemContext.Provider, {
658
- value: stackItemContextValue
659
- }, /* @__PURE__ */ React8.createElement(Root, {
660
- ...props,
661
- tabIndex: 0,
662
- ...focusableGroupAttrs,
663
- className: mx5("group/stack-item grid relative", focusIndicatorVariant === "over-all" ? "dx-focus-ring-inset-over-all" : orientation === "horizontal" ? "dx-focus-ring-group-x" : "dx-focus-ring-group-y", orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), role === "section" && orientation !== "horizontal" && "border-be border-subduedSeparator", classNames),
664
- "data-dx-stack-item": true,
665
- ...resizeAttributes,
666
- style: {
667
- ...sizeStyle(size, orientation),
668
- ...Number.isFinite(order) && {
669
- [orientation === "horizontal" ? "gridColumn" : "gridRow"]: `${order}`
670
- },
671
- ...style
838
+ }));
839
+ }, [
840
+ orientation,
841
+ item,
842
+ onRearrange,
843
+ selfDragHandleElement,
844
+ itemElement
845
+ ]);
846
+ const focusableGroupAttrs = useFocusableGroup({
847
+ tabBehavior: "limited"
848
+ });
849
+ const shouldShowDropIndicator = () => {
850
+ if (!closestEdge || !sourceId) {
851
+ return false;
852
+ }
853
+ if (sourceId === item.id) {
854
+ return false;
855
+ }
856
+ const isTrailingEdgeOfPrevSibling = prevSiblingId !== void 0 && sourceId === prevSiblingId && (orientation === "horizontal" && closestEdge === "left" || orientation === "vertical" && closestEdge === "top");
857
+ if (isTrailingEdgeOfPrevSibling) {
858
+ return false;
859
+ }
860
+ const isLeadingEdgeOfNextSibling = nextSiblingId !== void 0 && sourceId === nextSiblingId && (orientation === "horizontal" && closestEdge === "right" || orientation === "vertical" && closestEdge === "bottom");
861
+ if (isLeadingEdgeOfNextSibling) {
862
+ return false;
863
+ }
864
+ return true;
865
+ };
866
+ const stackItemContextValue = useMemo3(() => ({
867
+ selfDragHandleRef,
868
+ size,
869
+ setSize,
870
+ state: dragState,
871
+ setState: setDragState,
872
+ role
873
+ }), [
874
+ selfDragHandleRef,
875
+ size,
876
+ setSize,
877
+ dragState,
878
+ setDragState,
879
+ role
880
+ ]);
881
+ return /* @__PURE__ */ React10.createElement(StackItemContext.Provider, {
882
+ value: stackItemContextValue
883
+ }, /* @__PURE__ */ React10.createElement(Root, {
884
+ ...props,
885
+ tabIndex: 0,
886
+ ...focusableGroupAttrs,
887
+ className: mx7("group/stack-item grid relative", focusIndicatorVariant === "over-all" ? "dx-focus-ring-inset-over-all" : focusIndicatorVariant === "over-all-always" ? "dx-focus-ring-inset-over-all-always" : orientation === "horizontal" ? focusIndicatorVariant === "group-always" ? "dx-focus-ring-group-x-always" : "dx-focus-ring-group-x" : focusIndicatorVariant === "group-always" ? "dx-focus-ring-group-y-always" : "dx-focus-ring-group-y", orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), role === "section" && orientation !== "horizontal" && "border-be border-subduedSeparator", classNames),
888
+ "data-dx-stack-item": stackId,
889
+ "data-dx-item-id": item.id,
890
+ ...resizeAttributes,
891
+ style: {
892
+ ...stackSize !== "split" && sizeStyle(size, orientation),
893
+ ...Number.isFinite(order) && {
894
+ [orientation === "horizontal" ? "gridColumn" : "gridRow"]: `${order}`
672
895
  },
673
- ref: composedItemRef
674
- }, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
675
- lineInset: 8,
676
- terminalInset: -8,
677
- edge: closestEdge
678
- })));
679
- } finally {
680
- _effect.f();
681
- }
896
+ ...style
897
+ },
898
+ ref: composedItemRef
899
+ }, children, shouldShowDropIndicator() && closestEdge && /* @__PURE__ */ React10.createElement(ListItem2.DropIndicator, {
900
+ lineInset: 8,
901
+ terminalInset: -8,
902
+ edge: closestEdge
903
+ })));
682
904
  });
683
905
  var StackItemDragPreview = ({ children }) => {
684
906
  const { state } = useStackItem();
@@ -689,477 +911,16 @@ var StackItemDragPreview = ({ children }) => {
689
911
  var StackItem = {
690
912
  Root: StackItemRoot,
691
913
  Content: StackItemContent,
914
+ DragHandle: StackItemDragHandle,
915
+ DragPreview: StackItemDragPreview,
692
916
  Heading: StackItemHeading,
693
917
  HeadingLabel: StackItemHeadingLabel,
694
918
  HeadingStickyContent: StackItemHeadingStickyContent,
695
919
  ResizeHandle: StackItemResizeHandle,
696
- DragHandle: StackItemDragHandle,
697
920
  Sigil: StackItemSigil,
698
- SigilButton: StackItemSigilButton,
699
- DragPreview: StackItemDragPreview
700
- };
701
-
702
- // packages/ui/react-ui-stack/src/exemplars/Card/Card.tsx
703
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
704
- import { Primitive } from "@radix-ui/react-primitive";
705
- import { Slot as Slot3 } from "@radix-ui/react-slot";
706
- import React9, { forwardRef as forwardRef6 } from "react";
707
- import { Icon as Icon2, IconButton, Toolbar, useTranslation as useTranslation2 } from "@dxos/react-ui";
708
- import { hoverableControls, mx as mx6 } from "@dxos/react-ui-theme";
709
-
710
- // packages/ui/react-ui-stack/src/exemplars/Card/fragments.ts
711
- var cardRoot = "contain-layout pli-2 plb-1 first-of-type:pbs-0 last-of-type:pbe-0";
712
- var cardContent = "rounded overflow-hidden bg-cardSurface border border-separator dark:border-subduedSeparator dx-focus-ring-group-y-indicator relative min-bs-[--rail-item] group/card";
713
- var cardSpacing = "pli-cardSpacingInline mlb-cardSpacingBlock";
714
- var labelSpacing = "mbs-inputSpacingBlock mbe-labelSpacingBlock";
715
- var cardDialogContent = "p-0 bs-content min-bs-[8rem] max-bs-full md:max-is-[32rem] overflow-hidden";
716
- var cardDialogHeader = "pli-cardSpacingInline mbs-cardSpacingBlock flex justify-between";
717
- var cardDialogOverflow = "overflow-y-auto min-bs-0 flex-1";
718
- var cardDialogPaddedOverflow = `${cardDialogOverflow} plb-cardSpacingBlock`;
719
- var cardDialogSearchListRoot = "pli-cardSpacingInline pbs-cardSpacingBlock [&>input]:mbe-0 min-bs-0 flex-1 flex flex-col";
720
- var cardText = cardSpacing;
721
- var cardHeading = "text-lg font-medium line-clamp-2";
722
- var cardChrome = "pli-[--dx-cardSpacingChrome] mlb-[--dx-cardSpacingChrome] [&_.dx-button]:text-start [&_.dx-button]:is-full";
723
-
724
- // packages/ui/react-ui-stack/src/exemplars/Card/Card.tsx
725
- var CardRoot = /* @__PURE__ */ forwardRef6(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
726
- var _effect = _useSignals9();
727
- try {
728
- const Root = asChild ? Slot3 : "div";
729
- const rootProps = asChild ? {
730
- classNames: [
731
- cardRoot,
732
- classNames
733
- ]
734
- } : {
735
- className: mx6(cardRoot, classNames),
736
- role
737
- };
738
- return /* @__PURE__ */ React9.createElement(Root, {
739
- ...props,
740
- ...rootProps,
741
- ref: forwardedRef
742
- }, children);
743
- } finally {
744
- _effect.f();
745
- }
746
- });
747
- var CardContent = /* @__PURE__ */ forwardRef6(({ children, classNames, asChild, role = "group", ...props }, forwardedRef) => {
748
- var _effect = _useSignals9();
749
- try {
750
- const Root = asChild ? Slot3 : "div";
751
- const rootProps = asChild ? {
752
- classNames: [
753
- cardContent,
754
- classNames
755
- ]
756
- } : {
757
- className: mx6(cardContent, classNames),
758
- role
759
- };
760
- return /* @__PURE__ */ React9.createElement(Root, {
761
- ...props,
762
- ...rootProps,
763
- ref: forwardedRef
764
- }, children);
765
- } finally {
766
- _effect.f();
767
- }
768
- });
769
- var CardConditionalContent = ({ role, children }) => {
770
- var _effect = _useSignals9();
771
- try {
772
- if ([
773
- "popover",
774
- "card--kanban"
775
- ].includes(role ?? "never")) {
776
- return /* @__PURE__ */ React9.createElement("div", {
777
- className: role === "popover" ? "popover-card-width" : role === "card--kanban" ? "contents" : ""
778
- }, children);
779
- } else {
780
- return /* @__PURE__ */ React9.createElement(CardContent, role === "card--document" && {
781
- classNames: [
782
- "mlb-[1em]",
783
- hoverableControls
784
- ]
785
- }, children);
786
- }
787
- } finally {
788
- _effect.f();
789
- }
790
- };
791
- var CardHeading = /* @__PURE__ */ forwardRef6(({ children, classNames, asChild, role = "heading", ...props }, forwardedRef) => {
792
- var _effect = _useSignals9();
793
- try {
794
- const Root = asChild ? Slot3 : "div";
795
- const rootProps = asChild ? {
796
- classNames: [
797
- cardHeading,
798
- cardText,
799
- classNames
800
- ]
801
- } : {
802
- className: mx6(cardHeading, cardText, classNames),
803
- role
804
- };
805
- return /* @__PURE__ */ React9.createElement(Root, {
806
- ...props,
807
- ...rootProps,
808
- ref: forwardedRef
809
- }, children);
810
- } finally {
811
- _effect.f();
812
- }
813
- });
814
- var CardToolbar = /* @__PURE__ */ forwardRef6(({ children, classNames, ...props }, forwardedRef) => {
815
- var _effect = _useSignals9();
816
- try {
817
- return /* @__PURE__ */ React9.createElement(Toolbar.Root, {
818
- ...props,
819
- classNames: [
820
- "bg-transparent",
821
- classNames
822
- ],
823
- ref: forwardedRef
824
- }, children);
825
- } finally {
826
- _effect.f();
827
- }
828
- });
829
- var CardToolbarIconButton = Toolbar.IconButton;
830
- var CardToolbarSeparator = Toolbar.Separator;
831
- var CardDragHandle = /* @__PURE__ */ forwardRef6(({ toolbarItem }, forwardedRef) => {
832
- var _effect = _useSignals9();
833
- try {
834
- const { t } = useTranslation2(translationKey);
835
- const Root = toolbarItem ? Toolbar.IconButton : IconButton;
836
- return /* @__PURE__ */ React9.createElement(Root, {
837
- iconOnly: true,
838
- icon: "ph--dots-six-vertical--regular",
839
- variant: "ghost",
840
- label: t("card drag handle label"),
841
- classNames: "pli-2",
842
- ref: forwardedRef
843
- });
844
- } finally {
845
- _effect.f();
846
- }
847
- });
848
- var CardDragPreview = StackItem.DragPreview;
849
- var CardMenu = Primitive.div;
850
- var CardPoster = (props) => {
851
- var _effect = _useSignals9();
852
- try {
853
- const aspect = props.aspect === "auto" ? "aspect-auto" : "aspect-video";
854
- if (props.image) {
855
- return /* @__PURE__ */ React9.createElement("img", {
856
- className: `dx-card__poster ${aspect} object-cover is-full bs-auto`,
857
- src: props.image,
858
- alt: props.alt
859
- });
860
- }
861
- if (props.icon) {
862
- return /* @__PURE__ */ React9.createElement("div", {
863
- role: "image",
864
- className: `dx-card__poster grid ${aspect} place-items-center bg-inputSurface text-subdued`,
865
- "aria-label": props.alt
866
- }, /* @__PURE__ */ React9.createElement(Icon2, {
867
- icon: props.icon,
868
- size: 10
869
- }));
870
- }
871
- } finally {
872
- _effect.f();
873
- }
874
- };
875
- var CardChrome = /* @__PURE__ */ forwardRef6(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
876
- var _effect = _useSignals9();
877
- try {
878
- const Root = asChild ? Slot3 : "div";
879
- const rootProps = asChild ? {
880
- classNames: [
881
- cardChrome,
882
- classNames
883
- ]
884
- } : {
885
- className: mx6(cardChrome, classNames),
886
- role
887
- };
888
- return /* @__PURE__ */ React9.createElement(Root, {
889
- ...props,
890
- ...rootProps,
891
- ref: forwardedRef
892
- }, children);
893
- } finally {
894
- _effect.f();
895
- }
896
- });
897
- var CardText = /* @__PURE__ */ forwardRef6(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
898
- var _effect = _useSignals9();
899
- try {
900
- const Root = asChild ? Slot3 : "p";
901
- const rootProps = asChild ? {
902
- classNames: [
903
- cardText,
904
- classNames
905
- ]
906
- } : {
907
- className: mx6(cardText, classNames),
908
- role
909
- };
910
- return /* @__PURE__ */ React9.createElement(Root, {
911
- ...props,
912
- ...rootProps,
913
- ref: forwardedRef
914
- }, children);
915
- } finally {
916
- _effect.f();
917
- }
918
- });
919
- var Card = {
920
- Root: CardRoot,
921
- Content: CardContent,
922
- Container: CardConditionalContent,
923
- Heading: CardHeading,
924
- Toolbar: CardToolbar,
925
- ToolbarIconButton: CardToolbarIconButton,
926
- ToolbarSeparator: CardToolbarSeparator,
927
- DragHandle: CardDragHandle,
928
- DragPreview: CardDragPreview,
929
- Menu: CardMenu,
930
- Poster: CardPoster,
931
- Chrome: CardChrome,
932
- Text: CardText
933
- };
934
-
935
- // packages/ui/react-ui-stack/src/exemplars/Card/CardDragPreview.tsx
936
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
937
- import React10 from "react";
938
- import { mx as mx7 } from "@dxos/react-ui-theme";
939
- var CardDragPreviewRoot = ({ children }) => {
940
- var _effect = _useSignals10();
941
- try {
942
- return /* @__PURE__ */ React10.createElement("div", {
943
- className: "p-2"
944
- }, children);
945
- } finally {
946
- _effect.f();
947
- }
948
- };
949
- var CardDragPreviewContent = ({ children }) => {
950
- var _effect = _useSignals10();
951
- try {
952
- return /* @__PURE__ */ React10.createElement("div", {
953
- className: mx7(cardContent, "ring-focusLine ring-neutralFocusIndicator")
954
- }, children);
955
- } finally {
956
- _effect.f();
957
- }
958
- };
959
- var CardDragPreview2 = {
960
- Root: CardDragPreviewRoot,
961
- Content: CardDragPreviewContent
962
- };
963
-
964
- // packages/ui/react-ui-stack/src/exemplars/CardStack/CardStack.tsx
965
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
966
- import { Slot as Slot4 } from "@radix-ui/react-slot";
967
- import React11, { forwardRef as forwardRef7 } from "react";
968
- import { mx as mx8 } from "@dxos/react-ui-theme";
969
- var CardStackStack = /* @__PURE__ */ forwardRef7(({ children, classNames, itemsCount = 0, ...props }, forwardedRef) => {
970
- var _effect = _useSignals11();
971
- try {
972
- return /* @__PURE__ */ React11.createElement(Stack, {
973
- orientation: "vertical",
974
- size: "contain",
975
- rail: false,
976
- classNames: (
977
- /* NOTE(thure): Do not let this element have zero intrinsic size, otherwise the drop indicator will not display. See #9035. */
978
- [
979
- "plb-1",
980
- itemsCount > 0 && "plb-2",
981
- classNames
982
- ]
983
- ),
984
- itemsCount,
985
- separatorOnScroll: 9,
986
- "data-density": "fine",
987
- ...props,
988
- ref: forwardedRef
989
- }, children);
990
- } finally {
991
- _effect.f();
992
- }
993
- });
994
- var CardStackDragHandle = Card.DragHandle;
995
- var cardStackHeading = "mli-2 order-first bg-transparent rounded-bs-md flex items-center";
996
- var CardStackHeading = /* @__PURE__ */ forwardRef7(({ children, classNames, asChild, role = "heading", ...props }, forwardedRef) => {
997
- var _effect = _useSignals11();
998
- try {
999
- const Root = asChild ? Slot4 : "div";
1000
- const rootProps = asChild ? {
1001
- classNames: [
1002
- cardStackHeading,
1003
- classNames
1004
- ]
1005
- } : {
1006
- className: mx8(cardStackHeading, classNames),
1007
- role
1008
- };
1009
- return /* @__PURE__ */ React11.createElement(Root, {
1010
- ...props,
1011
- ...rootProps,
1012
- ref: forwardedRef
1013
- }, children);
1014
- } finally {
1015
- _effect.f();
1016
- }
1017
- });
1018
- var cardStackFooter = 'plb-2 mli-2 border-bs border-transparent [[data-scroll-separator-end="true"]_&]:border-subduedSeparator';
1019
- var CardStackFooter = /* @__PURE__ */ forwardRef7(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
1020
- var _effect = _useSignals11();
1021
- try {
1022
- const Root = asChild ? Slot4 : "div";
1023
- const rootProps = asChild ? {
1024
- classNames: [
1025
- cardStackFooter,
1026
- classNames
1027
- ]
1028
- } : {
1029
- className: mx8(cardStackFooter, classNames),
1030
- role
1031
- };
1032
- return /* @__PURE__ */ React11.createElement(Root, {
1033
- ...props,
1034
- ...rootProps,
1035
- ref: forwardedRef
1036
- }, children);
1037
- } finally {
1038
- _effect.f();
1039
- }
1040
- });
1041
- var cardStackContent = [
1042
- "shrink min-bs-0 bg-baseSurface border border-separator rounded-md grid dx-focus-ring-group-x-indicator kanban-drop",
1043
- railGridHorizontalContainFitContent
1044
- ];
1045
- var CardStackContent = /* @__PURE__ */ forwardRef7(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
1046
- var _effect = _useSignals11();
1047
- try {
1048
- const Root = asChild ? Slot4 : "div";
1049
- const rootProps = asChild ? {
1050
- classNames: [
1051
- ...cardStackContent,
1052
- classNames
1053
- ]
1054
- } : {
1055
- className: mx8(...cardStackContent, classNames),
1056
- role
1057
- };
1058
- return /* @__PURE__ */ React11.createElement(Root, {
1059
- ...props,
1060
- ...rootProps,
1061
- "data-scroll-separator": "false",
1062
- ref: forwardedRef
1063
- }, children);
1064
- } finally {
1065
- _effect.f();
1066
- }
1067
- });
1068
- var cardStackRoot = "flex flex-col pli-2 plb-2";
1069
- var CardStackRoot = /* @__PURE__ */ forwardRef7(({ children, classNames, asChild, role = "none", ...props }, forwardedRef) => {
1070
- var _effect = _useSignals11();
1071
- try {
1072
- const Root = asChild ? Slot4 : "div";
1073
- const rootProps = asChild ? {
1074
- classNames: [
1075
- cardStackRoot,
1076
- classNames
1077
- ]
1078
- } : {
1079
- className: mx8(cardStackRoot, classNames),
1080
- role
1081
- };
1082
- return /* @__PURE__ */ React11.createElement(Root, {
1083
- ...props,
1084
- ...rootProps,
1085
- ref: forwardedRef
1086
- }, children);
1087
- } finally {
1088
- _effect.f();
1089
- }
1090
- });
1091
- var CardStack = {
1092
- Root: CardStackRoot,
1093
- Content: CardStackContent,
1094
- Stack: CardStackStack,
1095
- Heading: CardStackHeading,
1096
- Footer: CardStackFooter,
1097
- DragHandle: CardStackDragHandle
1098
- };
1099
-
1100
- // packages/ui/react-ui-stack/src/exemplars/CardStack/CardStackDragPreview.tsx
1101
- import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1102
- import React12 from "react";
1103
- import { IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
1104
- import { mx as mx9 } from "@dxos/react-ui-theme";
1105
- var CardStackDragPreviewRoot = ({ children }) => {
1106
- var _effect = _useSignals12();
1107
- try {
1108
- return /* @__PURE__ */ React12.createElement("div", {
1109
- className: "p-2"
1110
- }, /* @__PURE__ */ React12.createElement("div", {
1111
- className: "rounded-md max-bs-[calc(100dvh-1rem)] overflow-hidden bg-baseSurface border border-separator ring-focusLine ring-neutralFocusIndicator flex flex-col"
1112
- }, children));
1113
- } finally {
1114
- _effect.f();
1115
- }
1116
- };
1117
- var CardStackDragPreviewHeading = ({ children }) => {
1118
- var _effect = _useSignals12();
1119
- try {
1120
- const { t } = useTranslation3(translationKey);
1121
- return /* @__PURE__ */ React12.createElement("div", {
1122
- className: "flex items-center p-2"
1123
- }, /* @__PURE__ */ React12.createElement(IconButton2, {
1124
- iconOnly: true,
1125
- icon: "ph--dots-six-vertical--regular",
1126
- variant: "ghost",
1127
- label: t("column drag handle label"),
1128
- classNames: "pli-2"
1129
- }), children);
1130
- } finally {
1131
- _effect.f();
1132
- }
1133
- };
1134
- var CardStackDragPreviewContent = ({ children, itemsCount = 0 }) => {
1135
- var _effect = _useSignals12();
1136
- try {
1137
- return /* @__PURE__ */ React12.createElement("div", {
1138
- className: mx9("overflow-y-auto flex-1 pli-2 flex flex-col gap-2", "plb-1", itemsCount > 0 ? "plb-2" : "plb-1")
1139
- }, children);
1140
- } finally {
1141
- _effect.f();
1142
- }
1143
- };
1144
- var CardStackDragPreviewFooter = ({ children }) => {
1145
- var _effect = _useSignals12();
1146
- try {
1147
- return /* @__PURE__ */ React12.createElement("div", {
1148
- className: "p-2 border-t border-separator"
1149
- }, children);
1150
- } finally {
1151
- _effect.f();
1152
- }
1153
- };
1154
- var CardStackDragPreview = {
1155
- Root: CardStackDragPreviewRoot,
1156
- Heading: CardStackDragPreviewHeading,
1157
- Content: CardStackDragPreviewContent,
1158
- Footer: CardStackDragPreviewFooter
921
+ SigilButton: StackItemSigilButton
1159
922
  };
1160
923
  export {
1161
- Card,
1162
- CardDragPreview2 as CardDragPreview,
1163
924
  CardStack,
1164
925
  CardStackDragPreview,
1165
926
  DEFAULT_EXTRINSIC_SIZE,
@@ -1168,28 +929,18 @@ export {
1168
929
  Stack,
1169
930
  StackContext,
1170
931
  StackItem,
1171
- StackItemDragPreview,
1172
932
  autoScrollRootAttributes,
1173
- cardChrome,
1174
- cardContent,
1175
- cardDialogContent,
1176
- cardDialogHeader,
1177
- cardDialogOverflow,
1178
- cardDialogPaddedOverflow,
1179
- cardDialogSearchListRoot,
1180
- cardHeading,
1181
- cardRoot,
1182
- cardSpacing,
1183
933
  cardStackContent,
934
+ cardStackDefaultInlineSizeRem,
1184
935
  cardStackFooter,
1185
936
  cardStackHeading,
937
+ cardStackItem,
1186
938
  cardStackRoot,
1187
- cardText,
1188
- labelSpacing,
1189
939
  railGridHorizontal,
1190
940
  railGridHorizontalContainFitContent,
1191
941
  railGridVertical,
1192
942
  railGridVerticalContainFitContent,
1193
- translations_default as translations
943
+ translationKey,
944
+ translations
1194
945
  };
1195
946
  //# sourceMappingURL=index.mjs.map