@dxos/react-ui-stack 0.8.4-main.c85a9c8dae → 0.8.4-main.cb12b3f963

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 (42) hide show
  1. package/dist/lib/browser/index.mjs +129 -172
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/browser/translations.mjs +23 -0
  5. package/dist/lib/browser/translations.mjs.map +7 -0
  6. package/dist/lib/node-esm/index.mjs +129 -172
  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/translations.mjs +25 -0
  10. package/dist/lib/node-esm/translations.mjs.map +7 -0
  11. package/dist/types/src/components/Stack/Stack.d.ts +2 -7
  12. package/dist/types/src/components/Stack/Stack.d.ts.map +1 -1
  13. package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -1
  14. package/dist/types/src/components/StackContext.d.ts +1 -1
  15. package/dist/types/src/components/StackContext.d.ts.map +1 -1
  16. package/dist/types/src/components/StackItem/StackItem.d.ts +4 -4
  17. package/dist/types/src/components/StackItem/StackItem.d.ts.map +1 -1
  18. package/dist/types/src/components/StackItem/StackItem.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/StackItem/StackItemDragHandle.d.ts.map +1 -1
  20. package/dist/types/src/components/StackItem/StackItemHeading.d.ts +1 -1
  21. package/dist/types/src/components/StackItem/StackItemHeading.d.ts.map +1 -1
  22. package/dist/types/src/components/StackItem/StackItemResizeHandle.d.ts.map +1 -1
  23. package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -1
  24. package/dist/types/src/index.d.ts +0 -1
  25. package/dist/types/src/index.d.ts.map +1 -1
  26. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
  27. package/dist/types/src/playwright/stack-manager.d.ts.map +1 -1
  28. package/dist/types/src/translations.d.ts +8 -8
  29. package/dist/types/src/translations.d.ts.map +1 -1
  30. package/dist/types/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +34 -35
  32. package/src/components/Stack/Stack.stories.tsx +8 -10
  33. package/src/components/Stack/Stack.tsx +193 -206
  34. package/src/components/StackContext.tsx +1 -1
  35. package/src/components/StackItem/StackItem.stories.tsx +1 -1
  36. package/src/components/StackItem/StackItem.tsx +13 -15
  37. package/src/components/StackItem/StackItemHeading.tsx +2 -2
  38. package/src/components/StackItem/StackItemResizeHandle.tsx +0 -1
  39. package/src/components/StackItem/StackItemSigil.tsx +2 -2
  40. package/src/hooks/useStackDropForElements.ts +2 -2
  41. package/src/index.ts +0 -1
  42. package/src/translations.ts +8 -8
@@ -2,15 +2,15 @@ import { createRequire } from 'node:module';const require = createRequire(import
2
2
 
3
3
  // src/components/Stack/Stack.tsx
4
4
  import { composeRefs } from "@radix-ui/react-compose-refs";
5
- import React, { Children, forwardRef, useCallback, useEffect, useMemo, useState as useState2 } from "react";
5
+ import React, { Children, forwardRef, useCallback, useEffect, useState as useState2 } from "react";
6
6
  import { ListItem, useId } from "@dxos/react-ui";
7
7
  import { mx } from "@dxos/ui-theme";
8
8
 
9
9
  // src/hooks/useStackDropForElements.ts
10
- import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
11
- import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
12
10
  import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
13
11
  import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
12
+ import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
13
+ import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
14
14
  import { useLayoutEffect, useState } from "react";
15
15
  var noop = () => {
16
16
  };
@@ -97,11 +97,6 @@ var useStackItem = () => useContext(StackItemContext);
97
97
  // src/components/Stack/Stack.tsx
98
98
  var railGridHorizontal = "grid-rows-[[rail-start]_var(--dx-rail-size)_[content-start]_1fr_[content-end]]";
99
99
  var railGridVertical = "grid-cols-[[rail-start]_var(--dx-rail-size)_[content-start]_1fr_[content-end]]";
100
- var railGridHorizontalContainFitContent = "grid-rows-[[rail-start]_var(--dx-rail-size)_[content-start]_fit-content(calc(100%-var(--dx-rail-size)*2+2px))_[content-end]]";
101
- var railGridVerticalContainFitContent = "grid-cols-[[rail-start]_var(--dx-rail-size)_[content-start]_fit-content(calc(100%-var(--dx-rail-size)*2+2px))_[content-end]]";
102
- var autoScrollRootAttributes = {
103
- "data-drag-autoscroll": "idle"
104
- };
105
100
  var PERPENDICULAR_FOCUS_THRESHHOLD = 128;
106
101
  var scrollIntoViewAndFocus = (el, orientation) => {
107
102
  el.scrollIntoView({
@@ -110,18 +105,14 @@ var scrollIntoViewAndFocus = (el, orientation) => {
110
105
  });
111
106
  return el.focus();
112
107
  };
113
- var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), getDropElement, separatorOnScroll, circularFocus, ...props }, forwardedRef) => {
114
- const stackId = useId("stack", props.id);
108
+ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, id, style, orientation = "vertical", rail = true, size = "intrinsic", itemsCount = Children.count(children), circularFocus, separatorOnScroll, getDropElement, onBlur, onKeyDown, onRearrange, ...props }, forwardedRef) => {
109
+ const stackId = useId("stack", id);
115
110
  const [stackElement, stackRef] = useState2(null);
116
111
  const [lastFocusedItem, setLastFocusedItem] = useState2();
117
112
  const composedItemRef = composeRefs(stackRef, forwardedRef);
118
- const styles = {
119
- [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: size === "split" ? `repeat(${itemsCount}, 1fr)` : `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
120
- ...style
121
- };
122
- const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
113
+ const selfDroppable = !!(itemsCount < 1 && onRearrange && id);
123
114
  const { dropping } = useStackDropForElements({
124
- id: props.id,
115
+ id,
125
116
  element: getDropElement && stackElement ? getDropElement(stackElement) : stackElement,
126
117
  scrollElement: stackElement,
127
118
  selfDroppable,
@@ -152,116 +143,12 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
152
143
  setLastFocusedItem(closestStackItem?.getAttribute("data-dx-item-id") ?? void 0);
153
144
  }
154
145
  }
155
- props.onBlur?.(event);
156
- }, [
157
- stackId,
158
- props.onBlur
159
- ]);
160
- const handleKeyDown = useCallback((event) => {
161
- const target = event.target;
162
- 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)}"]`)) {
163
- const closestOwnedItem = target.closest(`[data-dx-stack-item="${stackId}"]`);
164
- const closestStack = target.closest("[data-dx-stack]");
165
- const closestStackItems = Array.from(closestStack?.querySelectorAll(`[data-dx-stack-item="${stackId}"]`) ?? []);
166
- const closestStackOrientation = closestStack?.getAttribute("aria-orientation");
167
- const ancestorStack = closestStack?.parentElement?.closest("[data-dx-stack]");
168
- if (closestOwnedItem && closestStack) {
169
- const ancestorOrientation = ancestorStack?.getAttribute("aria-orientation");
170
- const parallelDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowUp" : event.key === "ArrowLeft") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowDown" : event.key === "ArrowRight") ? 1 : 0;
171
- const perpendicularDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowLeft" : event.key === "ArrowUp") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowRight" : event.key === "ArrowDown") ? 1 : 0;
172
- if (parallelDelta !== 0) {
173
- const currentIndex = closestStackItems.indexOf(closestOwnedItem);
174
- const nextIndex = currentIndex + parallelDelta;
175
- let adjacentItem;
176
- if (circularFocus) {
177
- adjacentItem = closestStackItems[(nextIndex + closestStackItems.length) % closestStackItems.length];
178
- } else {
179
- if (nextIndex >= 0 && nextIndex < closestStackItems.length) {
180
- adjacentItem = closestStackItems[nextIndex];
181
- }
182
- }
183
- if (adjacentItem) {
184
- event.preventDefault();
185
- scrollIntoViewAndFocus(adjacentItem, closestStackOrientation);
186
- }
187
- }
188
- if (perpendicularDelta !== 0) {
189
- if (ancestorStack && ancestorOrientation !== closestStackOrientation) {
190
- const siblingStacks = Array.from(ancestorStack.querySelectorAll(`[data-dx-stack-item="${ancestorStack.getAttribute("data-dx-stack")}"] [data-dx-stack]`));
191
- const currentStackIndex = siblingStacks.indexOf(closestStack);
192
- const nextStackIndex = currentStackIndex + perpendicularDelta;
193
- let adjacentStack;
194
- if (ancestorStack.getAttribute("data-dx-stack-circular-focus") === "true") {
195
- adjacentStack = siblingStacks[(nextStackIndex + siblingStacks.length) % siblingStacks.length];
196
- } else {
197
- if (nextStackIndex >= 0 && nextStackIndex < siblingStacks.length) {
198
- adjacentStack = siblingStacks[nextStackIndex];
199
- }
200
- }
201
- const adjacentStackSelfItem = adjacentStack?.closest(`[data-dx-stack-item=${ancestorStack.getAttribute("data-dx-stack")}]`);
202
- const adjacentStackItems = adjacentStack ? Array.from(adjacentStack.querySelectorAll(`[data-dx-stack-item="${adjacentStack.getAttribute("data-dx-stack")}"]`)) : [];
203
- if (adjacentStack && adjacentStackItems.length > 0) {
204
- let closestItem = adjacentStackItems[0];
205
- const lastFocusedItem2 = adjacentStack.querySelector(`[data-dx-item-id="${adjacentStack.getAttribute("data-dx-last-focused-item") ?? "never"}"]`);
206
- if (lastFocusedItem2) {
207
- closestItem = lastFocusedItem2;
208
- } else {
209
- const ownedItemRect = closestOwnedItem.getBoundingClientRect();
210
- const targetPosition = closestStackOrientation === "vertical" ? ownedItemRect.top : ownedItemRect.left;
211
- let closestDistance = Infinity;
212
- for (const item of adjacentStackItems) {
213
- const itemRect = item.getBoundingClientRect();
214
- const itemPosition = closestStackOrientation === "vertical" ? itemRect.top : itemRect.left;
215
- const distance = Math.abs(itemPosition - targetPosition);
216
- if (distance < closestDistance) {
217
- closestDistance = distance;
218
- closestItem = item;
219
- }
220
- if (closestDistance <= PERPENDICULAR_FOCUS_THRESHHOLD) {
221
- break;
222
- }
223
- }
224
- }
225
- event.preventDefault();
226
- scrollIntoViewAndFocus(closestItem, closestStackOrientation);
227
- } else if (adjacentStackSelfItem) {
228
- event.preventDefault();
229
- scrollIntoViewAndFocus(adjacentStackSelfItem, ancestorOrientation);
230
- }
231
- } else if (closestOwnedItem) {
232
- const closestOwnedItemStack = closestOwnedItem.querySelector("[data-dx-stack]");
233
- const closestOwnedItemStackItems = closestOwnedItemStack ? Array.from(closestOwnedItemStack.querySelectorAll(`[data-dx-stack-item="${closestOwnedItemStack.getAttribute("data-dx-stack")}"]`)) : [];
234
- if (closestOwnedItemStackItems.length > 0) {
235
- event.preventDefault();
236
- scrollIntoViewAndFocus(closestOwnedItemStackItems[[
237
- "ArrowUp",
238
- "ArrowLeft"
239
- ].includes(event.key) ? closestOwnedItemStackItems.length - 1 : 0], closestOwnedItemStack?.getAttribute("aria-orientation"));
240
- }
241
- }
242
- }
243
- }
244
- }
245
- props.onKeyDown?.(event);
146
+ onBlur?.(event);
246
147
  }, [
247
- props.onKeyDown,
248
148
  stackId,
249
- circularFocus
250
- ]);
251
- const gridClasses = useMemo(() => {
252
- if (!rail) {
253
- return orientation === "horizontal" ? "grid-rows-1 px-(--stack-gap)" : "grid-cols-1 py-(--stack-gap)";
254
- }
255
- if (orientation === "horizontal") {
256
- return railGridHorizontal;
257
- } else {
258
- return railGridVertical;
259
- }
260
- }, [
261
- rail,
262
- orientation,
263
- size
149
+ onBlur
264
150
  ]);
151
+ const handleKeyDown = useKeyDown(stackId, circularFocus, onKeyDown);
265
152
  useEffect(() => {
266
153
  if (!(stackElement && Number.isFinite(separatorOnScroll))) {
267
154
  return;
@@ -282,27 +169,30 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
282
169
  ]);
283
170
  return /* @__PURE__ */ React.createElement(StackContext.Provider, {
284
171
  value: {
172
+ stackId,
285
173
  orientation,
286
174
  rail,
287
175
  size,
288
- onRearrange,
289
- stackId
176
+ onRearrange
290
177
  }
291
178
  }, /* @__PURE__ */ React.createElement("div", {
292
179
  ...props,
293
- className: mx("grid relative [--stack-gap:var(--spacing-trim-xs)]", gridClasses, size === "contain" && (orientation === "horizontal" ? "overflow-x-auto overscroll-x-contain min-h-0 max-h-full h-full" : "overflow-y-auto min-w-0 max-w-full w-full"), classNames),
294
- onKeyDown: handleKeyDown,
295
- onBlur: handleBlur,
180
+ ...Number.isFinite(separatorOnScroll) && {
181
+ onScroll: handleScroll
182
+ },
183
+ className: mx("relative grid [--stack-gap:var(--spacing-trim-xs)]", size === "contain" && (orientation === "horizontal" ? "overflow-x-auto overscroll-x-contain min-h-0 max-h-full h-full" : "overflow-y-auto min-w-0 max-w-full w-full"), rail ? orientation === "horizontal" ? railGridHorizontal : railGridVertical : orientation === "horizontal" ? "grid-rows-1 px-(--stack-gap)" : "grid-cols-1 py-(--stack-gap)", classNames),
184
+ style: {
185
+ [orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: size === "split" ? `repeat(${itemsCount}, 1fr)` : `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
186
+ ...style
187
+ },
188
+ "aria-orientation": orientation,
296
189
  "data-dx-stack": stackId,
297
190
  "data-dx-stack-circular-focus": circularFocus,
298
191
  "data-dx-last-focused-item": lastFocusedItem,
299
192
  "data-rail": rail,
300
- "aria-orientation": orientation,
301
- style: styles,
302
- ref: composedItemRef,
303
- ...Number.isFinite(separatorOnScroll) && {
304
- onScroll: handleScroll
305
- }
193
+ onBlur: handleBlur,
194
+ onKeyDown: handleKeyDown,
195
+ ref: composedItemRef
306
196
  }, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
307
197
  lineInset: 8,
308
198
  terminalInset: -8,
@@ -310,28 +200,119 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
310
200
  edge: orientation === "horizontal" ? "left" : "top"
311
201
  })));
312
202
  });
203
+ var useKeyDown = (stackId, circularFocus, onKeyDown) => useCallback((event) => {
204
+ const target = event.target;
205
+ 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)}"]`)) {
206
+ const closestOwnedItem = target.closest(`[data-dx-stack-item="${stackId}"]`);
207
+ const closestStack = target.closest("[data-dx-stack]");
208
+ const closestStackItems = Array.from(closestStack?.querySelectorAll(`[data-dx-stack-item="${stackId}"]`) ?? []);
209
+ const closestStackOrientation = closestStack?.getAttribute("aria-orientation");
210
+ const ancestorStack = closestStack?.parentElement?.closest("[data-dx-stack]");
211
+ if (closestOwnedItem && closestStack) {
212
+ const ancestorOrientation = ancestorStack?.getAttribute("aria-orientation");
213
+ const parallelDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowUp" : event.key === "ArrowLeft") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowDown" : event.key === "ArrowRight") ? 1 : 0;
214
+ const perpendicularDelta = (closestStackOrientation === "vertical" ? event.key === "ArrowLeft" : event.key === "ArrowUp") ? -1 : (closestStackOrientation === "vertical" ? event.key === "ArrowRight" : event.key === "ArrowDown") ? 1 : 0;
215
+ if (parallelDelta !== 0) {
216
+ const currentIndex = closestStackItems.indexOf(closestOwnedItem);
217
+ const nextIndex = currentIndex + parallelDelta;
218
+ let adjacentItem;
219
+ if (circularFocus) {
220
+ adjacentItem = closestStackItems[(nextIndex + closestStackItems.length) % closestStackItems.length];
221
+ } else {
222
+ if (nextIndex >= 0 && nextIndex < closestStackItems.length) {
223
+ adjacentItem = closestStackItems[nextIndex];
224
+ }
225
+ }
226
+ if (adjacentItem) {
227
+ event.preventDefault();
228
+ scrollIntoViewAndFocus(adjacentItem, closestStackOrientation);
229
+ }
230
+ }
231
+ if (perpendicularDelta !== 0) {
232
+ if (ancestorStack && ancestorOrientation !== closestStackOrientation) {
233
+ const siblingStacks = Array.from(ancestorStack.querySelectorAll(`[data-dx-stack-item="${ancestorStack.getAttribute("data-dx-stack")}"] [data-dx-stack]`));
234
+ const currentStackIndex = siblingStacks.indexOf(closestStack);
235
+ const nextStackIndex = currentStackIndex + perpendicularDelta;
236
+ let adjacentStack;
237
+ if (ancestorStack.getAttribute("data-dx-stack-circular-focus") === "true") {
238
+ adjacentStack = siblingStacks[(nextStackIndex + siblingStacks.length) % siblingStacks.length];
239
+ } else {
240
+ if (nextStackIndex >= 0 && nextStackIndex < siblingStacks.length) {
241
+ adjacentStack = siblingStacks[nextStackIndex];
242
+ }
243
+ }
244
+ const adjacentStackSelfItem = adjacentStack?.closest(`[data-dx-stack-item=${ancestorStack.getAttribute("data-dx-stack")}]`);
245
+ const adjacentStackItems = adjacentStack ? Array.from(adjacentStack.querySelectorAll(`[data-dx-stack-item="${adjacentStack.getAttribute("data-dx-stack")}"]`)) : [];
246
+ if (adjacentStack && adjacentStackItems.length > 0) {
247
+ let closestItem = adjacentStackItems[0];
248
+ const lastFocusedItem = adjacentStack.querySelector(`[data-dx-item-id="${adjacentStack.getAttribute("data-dx-last-focused-item") ?? "never"}"]`);
249
+ if (lastFocusedItem) {
250
+ closestItem = lastFocusedItem;
251
+ } else {
252
+ const ownedItemRect = closestOwnedItem.getBoundingClientRect();
253
+ const targetPosition = closestStackOrientation === "vertical" ? ownedItemRect.top : ownedItemRect.left;
254
+ let closestDistance = Infinity;
255
+ for (const item of adjacentStackItems) {
256
+ const itemRect = item.getBoundingClientRect();
257
+ const itemPosition = closestStackOrientation === "vertical" ? itemRect.top : itemRect.left;
258
+ const distance = Math.abs(itemPosition - targetPosition);
259
+ if (distance < closestDistance) {
260
+ closestDistance = distance;
261
+ closestItem = item;
262
+ }
263
+ if (closestDistance <= PERPENDICULAR_FOCUS_THRESHHOLD) {
264
+ break;
265
+ }
266
+ }
267
+ }
268
+ event.preventDefault();
269
+ scrollIntoViewAndFocus(closestItem, closestStackOrientation);
270
+ } else if (adjacentStackSelfItem) {
271
+ event.preventDefault();
272
+ scrollIntoViewAndFocus(adjacentStackSelfItem, ancestorOrientation);
273
+ }
274
+ } else if (closestOwnedItem) {
275
+ const closestOwnedItemStack = closestOwnedItem.querySelector("[data-dx-stack]");
276
+ const closestOwnedItemStackItems = closestOwnedItemStack ? Array.from(closestOwnedItemStack.querySelectorAll(`[data-dx-stack-item="${closestOwnedItemStack.getAttribute("data-dx-stack")}"]`)) : [];
277
+ if (closestOwnedItemStackItems.length > 0) {
278
+ event.preventDefault();
279
+ scrollIntoViewAndFocus(closestOwnedItemStackItems[[
280
+ "ArrowUp",
281
+ "ArrowLeft"
282
+ ].includes(event.key) ? closestOwnedItemStackItems.length - 1 : 0], closestOwnedItemStack?.getAttribute("aria-orientation"));
283
+ }
284
+ }
285
+ }
286
+ }
287
+ }
288
+ onKeyDown?.(event);
289
+ }, [
290
+ onKeyDown,
291
+ stackId,
292
+ circularFocus
293
+ ]);
313
294
 
314
295
  // src/components/StackItem/StackItem.tsx
296
+ import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
315
297
  import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
316
298
  import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
317
299
  import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
318
300
  import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
319
- import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
320
301
  import { useFocusableGroup } from "@fluentui/react-tabster";
321
302
  import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
322
- import React8, { forwardRef as forwardRef5, useCallback as useCallback2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useState as useState4 } from "react";
303
+ import React8, { forwardRef as forwardRef5, useCallback as useCallback2, useLayoutEffect as useLayoutEffect2, useMemo as useMemo2, useState as useState4 } from "react";
323
304
  import { createPortal } from "react-dom";
324
305
  import { ListItem as ListItem2 } from "@dxos/react-ui";
325
306
  import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
326
307
  import { mx as mx5 } from "@dxos/ui-theme";
327
308
 
328
309
  // src/components/StackItem/StackItemContent.tsx
329
- import React2, { forwardRef as forwardRef2, useMemo as useMemo2 } from "react";
310
+ import React2, { forwardRef as forwardRef2, useMemo } from "react";
330
311
  import { mx as mx2 } from "@dxos/ui-theme";
331
312
  var StackItemContent = /* @__PURE__ */ forwardRef2(({ classNames, children, toolbar, statusbar, ...props }, forwardedRef) => {
332
313
  const { size: stackItemSize } = useStack();
333
314
  const { role } = useStackItem();
334
- const style = useMemo2(() => ({
315
+ const style = useMemo(() => ({
335
316
  gridTemplateRows: [
336
317
  toolbar && role === "section" ? "calc(var(--dx-toolbar-size) - 1px)" : "var(--dx-toolbar-size)",
337
318
  "1fr",
@@ -371,12 +352,12 @@ import { Slot as Slot2 } from "@radix-ui/react-slot";
371
352
  import React4, { forwardRef as forwardRef3 } from "react";
372
353
  import { useAttention } from "@dxos/react-ui-attention";
373
354
  import { mx as mx3 } from "@dxos/ui-theme";
374
- var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, ...props }) => {
355
+ var StackItemHeading = ({ children, classNames, asChild, separateOnScroll, role, ...props }) => {
375
356
  const { orientation } = useStack();
376
357
  const Comp = asChild ? Slot2 : Primitive2.div;
377
358
  return /* @__PURE__ */ React4.createElement(Comp, {
378
- role: "heading",
379
359
  ...props,
360
+ role: role ?? "heading",
380
361
  className: mx3("flex items-center border-x-0! bg-header-surface", separateOnScroll ? 'border-transparent [[data-scroll-separator="true"]_&]:border-subdued-separator' : "border-subdued-separator", orientation === "horizontal" ? "h-(--dx-rail-size)" : "w-(--dx-rail-size) flex-col", orientation === "horizontal" ? "border-b" : "border-e", classNames)
381
362
  }, children);
382
363
  };
@@ -420,25 +401,7 @@ import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@
420
401
  import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
421
402
  import { mx as mx4 } from "@dxos/ui-theme";
422
403
  import { getHostPlatform } from "@dxos/util";
423
-
424
- // src/translations.ts
425
- var translationKey = "@dxos/react-ui-stack";
426
- var translations = [
427
- {
428
- "en-US": {
429
- [translationKey]: {
430
- "resize label": "Drag to resize",
431
- "drag handle label": "Drag to rearrange",
432
- "pin start label": "Pin to the left sidebar",
433
- "pin end label": "Pin to the right sidebar",
434
- "increment start label": "Move to the left",
435
- "increment end label": "Move to the right",
436
- "close label": "Close",
437
- "minify label": "Minify"
438
- }
439
- }
440
- }
441
- ];
404
+ import { translationKey } from "#translations";
442
405
 
443
406
  // src/components/StackItem/MenuSignifier.tsx
444
407
  import React6 from "react";
@@ -488,8 +451,7 @@ var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAct
488
451
  }, /* @__PURE__ */ React7.createElement("span", {
489
452
  className: "sr-only"
490
453
  }, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
491
- icon,
492
- size: 5
454
+ icon
493
455
  }));
494
456
  if (!hasActions) {
495
457
  return button;
@@ -544,10 +506,10 @@ var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAct
544
506
  });
545
507
 
546
508
  // src/components/StackItem/StackItem.tsx
547
- var DEFAULT_HORIZONTAL_SIZE = 48;
548
509
  var DEFAULT_VERTICAL_SIZE = "min-content";
510
+ var DEFAULT_HORIZONTAL_SIZE = 50;
549
511
  var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
550
- var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, prevSiblingId, nextSiblingId, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
512
+ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ classNames, children, style, role, item, order, prevSiblingId, nextSiblingId, size: sizeProp, onSizeChange, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
551
513
  const [itemElement, itemRef] = useState4(null);
552
514
  const composedItemRef = composeRefs2(itemRef, forwardedRef);
553
515
  const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
@@ -555,7 +517,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, s
555
517
  const [sourceId, setSourceId] = useState4(null);
556
518
  const [dragState, setDragState] = useState4(idle);
557
519
  const { orientation, rail, onRearrange, size: stackSize, stackId } = useStack();
558
- const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(propsSize);
520
+ const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(sizeProp);
559
521
  const Root = role ?? "div";
560
522
  const setSize = useCallback2((nextSize, commit) => {
561
523
  setInternalSize(nextSize);
@@ -609,7 +571,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, s
609
571
  document.body.removeAttribute("data-drag-preview");
610
572
  itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
611
573
  setDragState({
612
- type: "w-dragging",
574
+ type: "is-dragging",
613
575
  item
614
576
  });
615
577
  },
@@ -686,7 +648,7 @@ var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, s
686
648
  }
687
649
  return true;
688
650
  };
689
- const stackItemContextValue = useMemo3(() => ({
651
+ const stackItemContextValue = useMemo2(() => ({
690
652
  selfDragHandleRef,
691
653
  size,
692
654
  setSize,
@@ -750,12 +712,7 @@ export {
750
712
  Stack,
751
713
  StackContext,
752
714
  StackItem,
753
- autoScrollRootAttributes,
754
715
  railGridHorizontal,
755
- railGridHorizontalContainFitContent,
756
- railGridVertical,
757
- railGridVerticalContainFitContent,
758
- translationKey,
759
- translations
716
+ railGridVertical
760
717
  };
761
718
  //# sourceMappingURL=index.mjs.map