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

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