@dxos/react-ui-stack 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef

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