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