@dxos/react-ui-stack 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8
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 +173 -176
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +201 -203
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +173 -176
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/MenuSignifier.d.ts +2 -3
- package/dist/types/src/components/MenuSignifier.d.ts.map +1 -1
- package/dist/types/src/components/Stack.d.ts +6 -1
- package/dist/types/src/components/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Stack.stories.d.ts +1 -2
- package/dist/types/src/components/Stack.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackContext.d.ts +2 -1
- package/dist/types/src/components/StackContext.d.ts.map +1 -1
- package/dist/types/src/components/StackItem.d.ts +13 -5
- package/dist/types/src/components/StackItem.d.ts.map +1 -1
- package/dist/types/src/components/StackItemContent.d.ts +35 -2
- package/dist/types/src/components/StackItemContent.d.ts.map +1 -1
- package/dist/types/src/components/StackItemDragHandle.d.ts +2 -2
- package/dist/types/src/components/StackItemDragHandle.d.ts.map +1 -1
- package/dist/types/src/components/StackItemHeading.d.ts +1 -1
- package/dist/types/src/components/StackItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/StackItemResizeHandle.d.ts +1 -2
- package/dist/types/src/components/StackItemResizeHandle.d.ts.map +1 -1
- package/dist/types/src/components/StackItemSigil.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useStackDropForElements.d.ts +15 -0
- package/dist/types/src/hooks/useStackDropForElements.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -27
- package/src/components/Stack.stories.tsx +1 -1
- package/src/components/Stack.tsx +44 -57
- package/src/components/StackContext.tsx +3 -1
- package/src/components/StackItem.tsx +45 -14
- package/src/components/StackItemContent.tsx +48 -28
- package/src/components/StackItemHeading.tsx +2 -2
- package/src/components/StackItemResizeHandle.tsx +12 -98
- package/src/components/StackItemSigil.tsx +90 -103
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useStackDropForElements.ts +73 -0
- package/dist/types/src/playwright/playwright.config.d.ts +0 -3
- package/dist/types/src/playwright/playwright.config.d.ts.map +0 -1
- package/dist/types/src/testing/EditorContent.d.ts +0 -8
- package/dist/types/src/testing/EditorContent.d.ts.map +0 -1
- package/src/testing/EditorContent.tsx +0 -60
- /package/src/playwright/{playwright.config.ts → playwright.config.cts} +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// packages/ui/react-ui-stack/src/components/Stack.tsx
|
|
2
|
-
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
3
|
-
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
4
2
|
import { useArrowNavigationGroup } from "@fluentui/react-tabster";
|
|
5
3
|
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
6
|
-
import React, { Children, forwardRef,
|
|
4
|
+
import React, { Children, forwardRef, useState as useState2, useMemo } from "react";
|
|
7
5
|
import { ListItem } from "@dxos/react-ui";
|
|
8
6
|
import { mx } from "@dxos/react-ui-theme";
|
|
9
7
|
|
|
@@ -24,35 +22,28 @@ var StackItemContext = /* @__PURE__ */ createContext({
|
|
|
24
22
|
});
|
|
25
23
|
var useStackItem = () => useContext(StackItemContext);
|
|
26
24
|
|
|
27
|
-
// packages/ui/react-ui-stack/src/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
// packages/ui/react-ui-stack/src/hooks/useStackDropForElements.ts
|
|
26
|
+
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
27
|
+
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
28
|
+
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
|
29
|
+
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
30
|
+
import { useLayoutEffect, useState } from "react";
|
|
31
|
+
var useStackDropForElements = ({ element, selfDroppable, orientation, id, onRearrange }) => {
|
|
33
32
|
const [dropping, setDropping] = useState(false);
|
|
34
|
-
const arrowNavigationGroup = useArrowNavigationGroup({
|
|
35
|
-
axis: orientation
|
|
36
|
-
});
|
|
37
|
-
const styles = {
|
|
38
|
-
[orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content)`,
|
|
39
|
-
...style
|
|
40
|
-
};
|
|
41
|
-
const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
|
|
42
33
|
useLayoutEffect(() => {
|
|
43
|
-
if (!
|
|
34
|
+
if (!element || !selfDroppable) {
|
|
44
35
|
return;
|
|
45
36
|
}
|
|
46
37
|
const acceptSourceType = orientation === "horizontal" ? "column" : "card";
|
|
47
|
-
return dropTargetForElements({
|
|
48
|
-
element
|
|
49
|
-
getData: ({ input, element }) => {
|
|
38
|
+
return combine(dropTargetForElements({
|
|
39
|
+
element,
|
|
40
|
+
getData: ({ input, element: element2 }) => {
|
|
50
41
|
return attachClosestEdge({
|
|
51
|
-
id
|
|
42
|
+
id,
|
|
52
43
|
type: orientation === "horizontal" ? "card" : "column"
|
|
53
44
|
}, {
|
|
54
45
|
input,
|
|
55
|
-
element,
|
|
46
|
+
element: element2,
|
|
56
47
|
allowedEdges: [
|
|
57
48
|
orientation === "horizontal" ? "left" : "top"
|
|
58
49
|
]
|
|
@@ -68,17 +59,70 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
|
|
|
68
59
|
setDropping(true);
|
|
69
60
|
}
|
|
70
61
|
},
|
|
71
|
-
onDragLeave: () =>
|
|
62
|
+
onDragLeave: () => {
|
|
63
|
+
return setDropping(false);
|
|
64
|
+
},
|
|
72
65
|
onDrop: ({ self, source }) => {
|
|
73
66
|
setDropping(false);
|
|
74
|
-
if (source.data.type === acceptSourceType && selfDroppable) {
|
|
67
|
+
if (source.data.type === acceptSourceType && selfDroppable && onRearrange) {
|
|
75
68
|
onRearrange(source.data, self.data, extractClosestEdge(self.data));
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
|
-
})
|
|
71
|
+
}), autoScrollForElements({
|
|
72
|
+
element,
|
|
73
|
+
getAllowedAxis: () => orientation
|
|
74
|
+
}));
|
|
79
75
|
}, [
|
|
80
|
-
|
|
81
|
-
selfDroppable
|
|
76
|
+
element,
|
|
77
|
+
selfDroppable,
|
|
78
|
+
orientation,
|
|
79
|
+
id,
|
|
80
|
+
onRearrange
|
|
81
|
+
]);
|
|
82
|
+
return {
|
|
83
|
+
dropping
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// packages/ui/react-ui-stack/src/components/Stack.tsx
|
|
88
|
+
var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
89
|
+
var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
90
|
+
var railGridHorizontalContainFitContent = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
|
|
91
|
+
var railGridVerticalContainFitContent = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_fit-content(calc(100%-var(--rail-size)*2+2px))_[content-end]]";
|
|
92
|
+
var autoScrollRootAttributes = {
|
|
93
|
+
"data-drag-autoscroll": "idle"
|
|
94
|
+
};
|
|
95
|
+
var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), ...props }, forwardedRef) => {
|
|
96
|
+
const [stackElement, stackRef] = useState2(null);
|
|
97
|
+
const composedItemRef = composeRefs(stackRef, forwardedRef);
|
|
98
|
+
const arrowNavigationGroup = useArrowNavigationGroup({
|
|
99
|
+
axis: orientation
|
|
100
|
+
});
|
|
101
|
+
const styles = {
|
|
102
|
+
[orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content) [tabster-dummies] 0`,
|
|
103
|
+
...style
|
|
104
|
+
};
|
|
105
|
+
const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
|
|
106
|
+
const { dropping } = useStackDropForElements({
|
|
107
|
+
id: props.id,
|
|
108
|
+
element: stackElement,
|
|
109
|
+
selfDroppable,
|
|
110
|
+
orientation,
|
|
111
|
+
onRearrange
|
|
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
|
|
82
126
|
]);
|
|
83
127
|
return /* @__PURE__ */ React.createElement(StackContext.Provider, {
|
|
84
128
|
value: {
|
|
@@ -90,36 +134,41 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
|
|
|
90
134
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
91
135
|
...props,
|
|
92
136
|
...arrowNavigationGroup,
|
|
93
|
-
className: mx("grid relative",
|
|
137
|
+
className: mx("grid relative", gridClasses, (size === "contain" || size === "contain-fit-content") && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 bs-full max-bs-full" : "overflow-y-auto min-is-0 is-full max-is-full"), classNames),
|
|
138
|
+
"data-rail": rail,
|
|
94
139
|
"aria-orientation": orientation,
|
|
95
140
|
style: styles,
|
|
96
141
|
ref: composedItemRef
|
|
97
142
|
}, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
|
|
143
|
+
lineInset: 8,
|
|
144
|
+
terminalInset: -8,
|
|
145
|
+
gap: -8,
|
|
98
146
|
edge: orientation === "horizontal" ? "left" : "top"
|
|
99
147
|
})));
|
|
100
148
|
});
|
|
101
149
|
|
|
102
150
|
// packages/ui/react-ui-stack/src/components/StackItem.tsx
|
|
103
|
-
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
104
|
-
import { draggable
|
|
105
|
-
import {
|
|
106
|
-
import {
|
|
151
|
+
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
152
|
+
import { draggable, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
153
|
+
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
154
|
+
import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
|
|
107
155
|
import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
108
156
|
import { useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
|
|
109
157
|
import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
|
|
110
|
-
import React8, { forwardRef as
|
|
158
|
+
import React8, { forwardRef as forwardRef5, useLayoutEffect as useLayoutEffect2, useState as useState4, useCallback } from "react";
|
|
111
159
|
import { ListItem as ListItem2 } from "@dxos/react-ui";
|
|
112
|
-
import {
|
|
160
|
+
import { resizeAttributes, sizeStyle } from "@dxos/react-ui-dnd";
|
|
161
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
113
162
|
|
|
114
163
|
// packages/ui/react-ui-stack/src/components/StackItemContent.tsx
|
|
115
|
-
import React2 from "react";
|
|
164
|
+
import React2, { forwardRef as forwardRef2 } from "react";
|
|
116
165
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
117
|
-
var StackItemContent = ({ children, toolbar
|
|
118
|
-
const { size } = useStack();
|
|
166
|
+
var StackItemContent = /* @__PURE__ */ forwardRef2(({ children, toolbar, statusbar, classNames, size = "intrinsic", ...props }, forwardedRef) => {
|
|
167
|
+
const { size: stackItemSize } = useStack();
|
|
119
168
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
120
169
|
role: "none",
|
|
121
170
|
...props,
|
|
122
|
-
className: mx2("group grid grid-cols-[100%]",
|
|
171
|
+
className: mx2("group grid grid-cols-[100%]", stackItemSize === "contain" && "min-bs-0 overflow-hidden", size === "video" ? "aspect-video" : size === "square" && "aspect-square", classNames),
|
|
123
172
|
style: {
|
|
124
173
|
gridTemplateRows: [
|
|
125
174
|
...toolbar ? [
|
|
@@ -130,9 +179,10 @@ var StackItemContent = ({ children, toolbar = true, statusbar, classNames, ...pr
|
|
|
130
179
|
"var(--statusbar-size)"
|
|
131
180
|
] : []
|
|
132
181
|
].join(" ")
|
|
133
|
-
}
|
|
182
|
+
},
|
|
183
|
+
ref: forwardedRef
|
|
134
184
|
}, children);
|
|
135
|
-
};
|
|
185
|
+
});
|
|
136
186
|
|
|
137
187
|
// packages/ui/react-ui-stack/src/components/StackItemDragHandle.tsx
|
|
138
188
|
import { Slot } from "@radix-ui/react-slot";
|
|
@@ -148,7 +198,7 @@ var StackItemDragHandle = ({ asChild, children }) => {
|
|
|
148
198
|
|
|
149
199
|
// packages/ui/react-ui-stack/src/components/StackItemHeading.tsx
|
|
150
200
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
|
151
|
-
import React4, { forwardRef as
|
|
201
|
+
import React4, { forwardRef as forwardRef3 } from "react";
|
|
152
202
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
153
203
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
154
204
|
var StackItemHeading = ({ children, classNames, ...props }) => {
|
|
@@ -161,105 +211,42 @@ var StackItemHeading = ({ children, classNames, ...props }) => {
|
|
|
161
211
|
...props,
|
|
162
212
|
tabIndex: 0,
|
|
163
213
|
...focusableGroupAttrs,
|
|
164
|
-
className: mx3("flex items-center
|
|
214
|
+
className: mx3("flex items-center dx-focus-ring-inset-over-all relative !border-is-0", orientation === "horizontal" ? "bs-[--rail-size]" : "is-[--rail-size] flex-col", classNames)
|
|
165
215
|
}, children);
|
|
166
216
|
};
|
|
167
|
-
var StackItemHeadingLabel = /* @__PURE__ */
|
|
217
|
+
var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related, classNames, ...props }, forwardedRef) => {
|
|
168
218
|
const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
|
|
169
219
|
return /* @__PURE__ */ React4.createElement("h1", {
|
|
170
220
|
...props,
|
|
171
221
|
"data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
|
|
172
|
-
className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText", classNames),
|
|
222
|
+
className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center", classNames),
|
|
173
223
|
ref: forwardedRef
|
|
174
224
|
});
|
|
175
225
|
});
|
|
176
226
|
|
|
177
227
|
// packages/ui/react-ui-stack/src/components/StackItemResizeHandle.tsx
|
|
178
|
-
import
|
|
179
|
-
import {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
183
|
-
var REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
184
|
-
var MIN_SIZE = 20;
|
|
185
|
-
var measureStackItem = (element) => {
|
|
186
|
-
const stackItemElement = element.closest("[data-dx-stack-item]");
|
|
187
|
-
return stackItemElement?.getBoundingClientRect() ?? {
|
|
188
|
-
width: DEFAULT_EXTRINSIC_SIZE,
|
|
189
|
-
height: DEFAULT_EXTRINSIC_SIZE
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
var getNextSize = (startSize, location, client) => {
|
|
193
|
-
return Math.max(MIN_SIZE, startSize + (location.current.input[client] - location.initial.input[client]) / REM);
|
|
194
|
-
};
|
|
228
|
+
import React5 from "react";
|
|
229
|
+
import { ResizeHandle } from "@dxos/react-ui-dnd";
|
|
230
|
+
var MIN_WIDTH = 20;
|
|
231
|
+
var MIN_HEIGHT = 3;
|
|
195
232
|
var StackItemResizeHandle = () => {
|
|
196
233
|
const { orientation } = useStack();
|
|
197
234
|
const { setSize, size } = useStackItem();
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
draggable({
|
|
206
|
-
element: buttonRef.current,
|
|
207
|
-
onGenerateDragPreview: ({ nativeSetDragImage }) => {
|
|
208
|
-
disableNativeDragPreview({
|
|
209
|
-
nativeSetDragImage
|
|
210
|
-
});
|
|
211
|
-
preventUnhandled.start();
|
|
212
|
-
},
|
|
213
|
-
onDragStart: () => {
|
|
214
|
-
dragStartSize.current = dragStartSize.current === "min-content" ? measureStackItem(buttonRef.current)[orientation === "horizontal" ? "width" : "height"] / REM : dragStartSize.current;
|
|
215
|
-
},
|
|
216
|
-
onDrag: ({ location }) => {
|
|
217
|
-
if (typeof dragStartSize.current !== "number") {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
setSize(getNextSize(dragStartSize.current, location, client));
|
|
221
|
-
},
|
|
222
|
-
onDrop: ({ location }) => {
|
|
223
|
-
if (typeof dragStartSize.current !== "number") {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
const nextSize = getNextSize(dragStartSize.current, location, client);
|
|
227
|
-
setSize(nextSize, true);
|
|
228
|
-
dragStartSize.current = nextSize;
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
}, []);
|
|
232
|
-
return /* @__PURE__ */ React5.createElement("button", {
|
|
233
|
-
ref: buttonRef,
|
|
234
|
-
className: mx4(orientation === "horizontal" ? "cursor-col-resize" : "cursor-row-resize", "group absolute is-3 bs-full inline-end-[-1px] !border-lb-0", "before:transition-opacity before:duration-100 before:ease-in-out before:opacity-0 hover:before:opacity-100 focus-visible:before:opacity-100 active:before:opacity-100", "before:absolute before:block before:inset-block-0 before:inline-end-0 before:is-1 before:bg-accentFocusIndicator")
|
|
235
|
-
}, /* @__PURE__ */ React5.createElement("div", {
|
|
236
|
-
role: "none",
|
|
237
|
-
className: "absolute block-start-0 inline-end-[1px] bs-[--rail-size] flex items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0"
|
|
238
|
-
}, /* @__PURE__ */ React5.createElement(DragHandleSignifier, null)));
|
|
239
|
-
};
|
|
240
|
-
var DragHandleSignifier = () => {
|
|
241
|
-
return /* @__PURE__ */ React5.createElement("svg", {
|
|
242
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
243
|
-
viewBox: "0 0 256 256",
|
|
244
|
-
fill: "currentColor",
|
|
245
|
-
className: "shrink-0 bs-[1em] is-[1em] text-unAccent"
|
|
246
|
-
}, /* @__PURE__ */ React5.createElement("path", {
|
|
247
|
-
d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
248
|
-
}), /* @__PURE__ */ React5.createElement("path", {
|
|
249
|
-
d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
250
|
-
}), /* @__PURE__ */ React5.createElement("path", {
|
|
251
|
-
d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
252
|
-
}), /* @__PURE__ */ React5.createElement("path", {
|
|
253
|
-
d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
254
|
-
}));
|
|
235
|
+
return /* @__PURE__ */ React5.createElement(ResizeHandle, {
|
|
236
|
+
side: orientation === "horizontal" ? "inline-end" : "block-end",
|
|
237
|
+
fallbackSize: DEFAULT_EXTRINSIC_SIZE,
|
|
238
|
+
minSize: orientation === "horizontal" ? MIN_WIDTH : MIN_HEIGHT,
|
|
239
|
+
size,
|
|
240
|
+
onSizeChange: setSize
|
|
241
|
+
});
|
|
255
242
|
};
|
|
256
243
|
|
|
257
244
|
// packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
|
|
258
|
-
import React7, { Fragment, forwardRef as
|
|
245
|
+
import React7, { Fragment, forwardRef as forwardRef4, useRef, useState as useState3 } from "react";
|
|
259
246
|
import { keySymbols } from "@dxos/keyboard";
|
|
260
|
-
import { Button, DropdownMenu, Icon, toLocalizedString,
|
|
247
|
+
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
261
248
|
import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
262
|
-
import { descriptionText, mx as
|
|
249
|
+
import { descriptionText, mx as mx4 } from "@dxos/react-ui-theme";
|
|
263
250
|
import { getHostPlatform } from "@dxos/util";
|
|
264
251
|
|
|
265
252
|
// packages/ui/react-ui-stack/src/components/MenuSignifier.tsx
|
|
@@ -301,35 +288,40 @@ var translations_default = [
|
|
|
301
288
|
];
|
|
302
289
|
|
|
303
290
|
// packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
|
|
304
|
-
var StackItemSigilButton = /* @__PURE__ */
|
|
291
|
+
var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNames, related, children, ...props }, forwardedRef) => {
|
|
305
292
|
const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
|
|
306
293
|
const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
|
|
307
294
|
return /* @__PURE__ */ React7.createElement(Button, {
|
|
308
295
|
...props,
|
|
309
296
|
variant,
|
|
310
297
|
classNames: [
|
|
311
|
-
"
|
|
298
|
+
"shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative app-no-drag",
|
|
312
299
|
classNames
|
|
313
300
|
],
|
|
314
301
|
ref: forwardedRef
|
|
315
302
|
}, /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
|
|
316
303
|
});
|
|
317
|
-
var StackItemSigil = /* @__PURE__ */
|
|
304
|
+
var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
318
305
|
const { t } = useTranslation(translationKey);
|
|
319
|
-
const suppressNextTooltip =
|
|
320
|
-
const [optionsMenuOpen, setOptionsMenuOpen] =
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
306
|
+
const suppressNextTooltip = useRef(false);
|
|
307
|
+
const [optionsMenuOpen, setOptionsMenuOpen] = useState3(false);
|
|
308
|
+
const hasActions = actionGroups && actionGroups.length > 0;
|
|
309
|
+
const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
|
|
310
|
+
attendableId,
|
|
311
|
+
related,
|
|
312
|
+
// TODO(wittjosiah): Better disabling of interactive styles when no action are available.
|
|
313
|
+
// Remove underscore icon when no actions are available?
|
|
314
|
+
classNames: !hasActions && "cursor-default"
|
|
315
|
+
}, /* @__PURE__ */ React7.createElement("span", {
|
|
316
|
+
className: "sr-only"
|
|
317
|
+
}, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
|
|
318
|
+
icon,
|
|
319
|
+
size: 5
|
|
320
|
+
}));
|
|
321
|
+
if (!hasActions) {
|
|
322
|
+
return button;
|
|
323
|
+
}
|
|
324
|
+
return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
|
|
333
325
|
open: optionsMenuOpen,
|
|
334
326
|
onOpenChange: (nextOpen) => {
|
|
335
327
|
if (!nextOpen) {
|
|
@@ -337,20 +329,10 @@ var StackItemSigil = /* @__PURE__ */ forwardRef3(({ actions: actionGroups, onAct
|
|
|
337
329
|
}
|
|
338
330
|
return setOptionsMenuOpen(nextOpen);
|
|
339
331
|
}
|
|
340
|
-
}, /* @__PURE__ */ React7.createElement(Tooltip.Trigger, {
|
|
341
|
-
asChild: true
|
|
342
332
|
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
343
333
|
asChild: true,
|
|
344
334
|
ref: forwardedRef
|
|
345
|
-
}, /* @__PURE__ */ React7.createElement(
|
|
346
|
-
attendableId,
|
|
347
|
-
related
|
|
348
|
-
}, /* @__PURE__ */ React7.createElement("span", {
|
|
349
|
-
className: "sr-only"
|
|
350
|
-
}, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
|
|
351
|
-
icon,
|
|
352
|
-
size: 5
|
|
353
|
-
})))), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
|
|
335
|
+
}, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
|
|
354
336
|
classNames: "z-[31]"
|
|
355
337
|
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
|
|
356
338
|
const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
|
|
@@ -388,24 +370,22 @@ var StackItemSigil = /* @__PURE__ */ forwardRef3(({ actions: actionGroups, onAct
|
|
|
388
370
|
icon: "ph--check--regular",
|
|
389
371
|
size: 4
|
|
390
372
|
})), shortcut && /* @__PURE__ */ React7.createElement("span", {
|
|
391
|
-
className:
|
|
373
|
+
className: mx4("shrink-0", descriptionText)
|
|
392
374
|
}, keySymbols(shortcut).join("")));
|
|
393
375
|
}));
|
|
394
|
-
}), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))))
|
|
395
|
-
side: "bottom"
|
|
396
|
-
}, triggerLabel, /* @__PURE__ */ React7.createElement(Tooltip.Arrow, null))));
|
|
376
|
+
}), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
|
|
397
377
|
});
|
|
398
378
|
|
|
399
379
|
// packages/ui/react-ui-stack/src/components/StackItem.tsx
|
|
400
380
|
var DEFAULT_HORIZONTAL_SIZE = 44;
|
|
401
381
|
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
402
382
|
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
403
|
-
var StackItemRoot = /* @__PURE__ */
|
|
404
|
-
const [itemElement, itemRef] =
|
|
405
|
-
const [selfDragHandleElement, selfDragHandleRef] =
|
|
406
|
-
const [closestEdge, setEdge] =
|
|
383
|
+
var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
|
|
384
|
+
const [itemElement, itemRef] = useState4(null);
|
|
385
|
+
const [selfDragHandleElement, selfDragHandleRef] = useState4(null);
|
|
386
|
+
const [closestEdge, setEdge] = useState4(null);
|
|
407
387
|
const { orientation, rail, onRearrange } = useStack();
|
|
408
|
-
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] =
|
|
388
|
+
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState4(propsSize);
|
|
409
389
|
const Root = role ?? "div";
|
|
410
390
|
const composedItemRef = composeRefs2(itemRef, forwardedRef);
|
|
411
391
|
const setSize = useCallback((nextSize, commit) => {
|
|
@@ -417,11 +397,11 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, s
|
|
|
417
397
|
onSizeChange
|
|
418
398
|
]);
|
|
419
399
|
const type = orientation === "horizontal" ? "column" : "card";
|
|
420
|
-
|
|
421
|
-
if (!itemElement || !onRearrange) {
|
|
400
|
+
useLayoutEffect2(() => {
|
|
401
|
+
if (!itemElement || !onRearrange || disableRearrange) {
|
|
422
402
|
return;
|
|
423
403
|
}
|
|
424
|
-
return
|
|
404
|
+
return combine2(draggable({
|
|
425
405
|
element: itemElement,
|
|
426
406
|
...selfDragHandleElement && {
|
|
427
407
|
dragHandle: selfDragHandleElement
|
|
@@ -430,12 +410,25 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, s
|
|
|
430
410
|
id: item.id,
|
|
431
411
|
type
|
|
432
412
|
}),
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
413
|
+
onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
|
|
414
|
+
document.body.setAttribute("data-drag-preview", "true");
|
|
415
|
+
scrollJustEnoughIntoView({
|
|
416
|
+
element: source.element
|
|
437
417
|
});
|
|
438
|
-
|
|
418
|
+
const { x, y } = preserveOffsetOnSource({
|
|
419
|
+
element: source.element,
|
|
420
|
+
input: location.current.input
|
|
421
|
+
})({
|
|
422
|
+
container: source.element.offsetParent ?? document.body
|
|
423
|
+
});
|
|
424
|
+
nativeSetDragImage?.(source.element, x, y);
|
|
425
|
+
},
|
|
426
|
+
onDragStart: () => {
|
|
427
|
+
document.body.removeAttribute("data-drag-preview");
|
|
428
|
+
itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
|
|
429
|
+
},
|
|
430
|
+
onDrop: () => {
|
|
431
|
+
itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
|
|
439
432
|
}
|
|
440
433
|
}), dropTargetForElements2({
|
|
441
434
|
element: itemElement,
|
|
@@ -493,12 +486,11 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, s
|
|
|
493
486
|
...props,
|
|
494
487
|
tabIndex: 0,
|
|
495
488
|
...focusGroupAttrs,
|
|
496
|
-
className:
|
|
489
|
+
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),
|
|
497
490
|
"data-dx-stack-item": true,
|
|
491
|
+
...resizeAttributes,
|
|
498
492
|
style: {
|
|
499
|
-
...size
|
|
500
|
-
[orientation === "horizontal" ? "inlineSize" : "blockSize"]: `${size}rem`
|
|
501
|
-
},
|
|
493
|
+
...sizeStyle(size, orientation),
|
|
502
494
|
...Number.isFinite(order) && {
|
|
503
495
|
[orientation === "horizontal" ? "gridColumn" : "gridRow"]: `${order}`
|
|
504
496
|
},
|
|
@@ -506,6 +498,8 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, s
|
|
|
506
498
|
},
|
|
507
499
|
ref: composedItemRef
|
|
508
500
|
}, children, closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
|
|
501
|
+
lineInset: 8,
|
|
502
|
+
terminalInset: -8,
|
|
509
503
|
edge: closestEdge
|
|
510
504
|
})));
|
|
511
505
|
});
|
|
@@ -521,10 +515,10 @@ var StackItem = {
|
|
|
521
515
|
};
|
|
522
516
|
|
|
523
517
|
// packages/ui/react-ui-stack/src/components/LayoutControls.tsx
|
|
524
|
-
import React9, { forwardRef as
|
|
525
|
-
import { Button as Button2, ButtonGroup, Icon as Icon2, Tooltip
|
|
518
|
+
import React9, { forwardRef as forwardRef6 } from "react";
|
|
519
|
+
import { Button as Button2, ButtonGroup, Icon as Icon2, Tooltip, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
526
520
|
var LayoutControl = ({ icon, label, ...props }) => {
|
|
527
|
-
return /* @__PURE__ */ React9.createElement(
|
|
521
|
+
return /* @__PURE__ */ React9.createElement(Tooltip.Root, null, /* @__PURE__ */ React9.createElement(Tooltip.Trigger, {
|
|
528
522
|
asChild: true
|
|
529
523
|
}, /* @__PURE__ */ React9.createElement(Button2, {
|
|
530
524
|
variant: "ghost",
|
|
@@ -533,11 +527,11 @@ var LayoutControl = ({ icon, label, ...props }) => {
|
|
|
533
527
|
className: "sr-only"
|
|
534
528
|
}, label), /* @__PURE__ */ React9.createElement(Icon2, {
|
|
535
529
|
icon
|
|
536
|
-
}))), /* @__PURE__ */ React9.createElement(
|
|
530
|
+
}))), /* @__PURE__ */ React9.createElement(Tooltip.Portal, null, /* @__PURE__ */ React9.createElement(Tooltip.Content, {
|
|
537
531
|
side: "bottom"
|
|
538
532
|
}, label)));
|
|
539
533
|
};
|
|
540
|
-
var LayoutControls = /* @__PURE__ */
|
|
534
|
+
var LayoutControls = /* @__PURE__ */ forwardRef6(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
|
|
541
535
|
const { t } = useTranslation2(translationKey);
|
|
542
536
|
const buttonClassNames = variant === "hide-disabled" ? "disabled:hidden !p-1" : "!p-1";
|
|
543
537
|
return /* @__PURE__ */ React9.createElement(ButtonGroup, {
|
|
@@ -594,8 +588,11 @@ export {
|
|
|
594
588
|
StackContext,
|
|
595
589
|
StackItem,
|
|
596
590
|
StackItemContext,
|
|
591
|
+
autoScrollRootAttributes,
|
|
597
592
|
railGridHorizontal,
|
|
593
|
+
railGridHorizontalContainFitContent,
|
|
598
594
|
railGridVertical,
|
|
595
|
+
railGridVerticalContainFitContent,
|
|
599
596
|
translations_default as translations,
|
|
600
597
|
useStack,
|
|
601
598
|
useStackItem
|