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