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