@dxos/react-ui-stack 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

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