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

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