@dxos/react-ui-stack 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33

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