@dxos/react-ui-stack 0.7.4 → 0.7.5-labs.071a3e2
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 +228 -130
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +229 -129
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +228 -130
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/LayoutControls.d.ts.map +1 -1
- package/dist/types/src/components/Stack.d.ts +3 -0
- package/dist/types/src/components/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Stack.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackContext.d.ts +9 -4
- package/dist/types/src/components/StackContext.d.ts.map +1 -1
- package/dist/types/src/components/StackItem.d.ts +14 -9
- 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 +6 -0
- package/dist/types/src/components/StackItemDragHandle.d.ts.map +1 -0
- package/dist/types/src/components/StackItemHeading.d.ts.map +1 -1
- package/dist/types/src/components/StackItemResizeHandle.d.ts +1 -0
- 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/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +28 -26
- package/src/components/LayoutControls.tsx +1 -3
- package/src/components/Stack.stories.tsx +5 -4
- package/src/components/Stack.tsx +73 -10
- package/src/components/StackContext.tsx +13 -4
- package/src/components/StackItem.tsx +49 -16
- package/src/components/StackItemContent.tsx +48 -33
- package/src/components/StackItemDragHandle.tsx +22 -0
- package/src/components/StackItemHeading.tsx +3 -5
- package/src/components/StackItemResizeHandle.tsx +27 -15
- package/src/components/StackItemSigil.tsx +90 -103
- package/src/components/index.ts +1 -0
- 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
|
@@ -1,8 +1,14 @@
|
|
|
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 { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
5
|
+
import { dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
6
|
+
import { autoScrollForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
|
|
7
|
+
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
4
8
|
import { useArrowNavigationGroup } from "@fluentui/react-tabster";
|
|
5
|
-
import
|
|
9
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
10
|
+
import React, { Children, forwardRef, useLayoutEffect, useState } from "react";
|
|
11
|
+
import { ListItem } from "@dxos/react-ui";
|
|
6
12
|
import { mx } from "@dxos/react-ui-theme";
|
|
7
13
|
|
|
8
14
|
// packages/ui/react-ui-stack/src/components/StackContext.tsx
|
|
@@ -10,8 +16,7 @@ import { createContext, useContext } from "react";
|
|
|
10
16
|
var StackContext = /* @__PURE__ */ createContext({
|
|
11
17
|
orientation: "vertical",
|
|
12
18
|
rail: true,
|
|
13
|
-
size: "intrinsic"
|
|
14
|
-
separators: true
|
|
19
|
+
size: "intrinsic"
|
|
15
20
|
});
|
|
16
21
|
var useStack = () => useContext(StackContext);
|
|
17
22
|
var StackItemContext = /* @__PURE__ */ createContext({
|
|
@@ -26,7 +31,13 @@ var useStackItem = () => useContext(StackItemContext);
|
|
|
26
31
|
// packages/ui/react-ui-stack/src/components/Stack.tsx
|
|
27
32
|
var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
28
33
|
var railGridVertical = "grid-cols-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
29
|
-
var
|
|
34
|
+
var autoScrollRootAttributes = {
|
|
35
|
+
"data-drag-autoscroll": "idle"
|
|
36
|
+
};
|
|
37
|
+
var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientation = "vertical", rail = true, size = "intrinsic", onRearrange, itemsCount = Children.count(children), ...props }, forwardedRef) => {
|
|
38
|
+
const [stackElement, stackRef] = useState(null);
|
|
39
|
+
const composedItemRef = composeRefs(stackRef, forwardedRef);
|
|
40
|
+
const [dropping, setDropping] = useState(false);
|
|
30
41
|
const arrowNavigationGroup = useArrowNavigationGroup({
|
|
31
42
|
axis: orientation
|
|
32
43
|
});
|
|
@@ -34,41 +45,96 @@ var Stack = /* @__PURE__ */ forwardRef(({ children, classNames, style, orientati
|
|
|
34
45
|
[orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content)`,
|
|
35
46
|
...style
|
|
36
47
|
};
|
|
48
|
+
const selfDroppable = !!(itemsCount < 1 && onRearrange && props.id);
|
|
49
|
+
useLayoutEffect(() => {
|
|
50
|
+
if (!stackElement || !selfDroppable) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const acceptSourceType = orientation === "horizontal" ? "column" : "card";
|
|
54
|
+
return combine(dropTargetForElements({
|
|
55
|
+
element: stackElement,
|
|
56
|
+
getData: ({ input, element }) => {
|
|
57
|
+
return attachClosestEdge({
|
|
58
|
+
id: props.id,
|
|
59
|
+
type: orientation === "horizontal" ? "card" : "column"
|
|
60
|
+
}, {
|
|
61
|
+
input,
|
|
62
|
+
element,
|
|
63
|
+
allowedEdges: [
|
|
64
|
+
orientation === "horizontal" ? "left" : "top"
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
onDragEnter: ({ source }) => {
|
|
69
|
+
if (source.data.type === acceptSourceType) {
|
|
70
|
+
setDropping(true);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
onDrag: ({ source }) => {
|
|
74
|
+
if (source.data.type === acceptSourceType) {
|
|
75
|
+
setDropping(true);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
onDragLeave: () => setDropping(false),
|
|
79
|
+
onDrop: ({ self, source }) => {
|
|
80
|
+
setDropping(false);
|
|
81
|
+
if (source.data.type === acceptSourceType && selfDroppable) {
|
|
82
|
+
onRearrange(source.data, self.data, extractClosestEdge(self.data));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}), autoScrollForElements({
|
|
86
|
+
element: stackElement,
|
|
87
|
+
getAllowedAxis: () => orientation
|
|
88
|
+
}));
|
|
89
|
+
}, [
|
|
90
|
+
stackElement,
|
|
91
|
+
selfDroppable,
|
|
92
|
+
orientation
|
|
93
|
+
]);
|
|
37
94
|
return /* @__PURE__ */ React.createElement(StackContext.Provider, {
|
|
38
95
|
value: {
|
|
39
96
|
orientation,
|
|
40
97
|
rail,
|
|
41
98
|
size,
|
|
42
|
-
|
|
99
|
+
onRearrange
|
|
43
100
|
}
|
|
44
101
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
45
102
|
...props,
|
|
46
103
|
...arrowNavigationGroup,
|
|
47
|
-
className: mx("grid relative", rail ? orientation === "horizontal" ? railGridHorizontal : railGridVertical : orientation === "horizontal" ? "grid-rows-1" : "grid-cols-1", size === "contain" && (orientation === "horizontal" ? "overflow-x-auto min-bs-0 bs-full max-bs-full" : "overflow-y-auto min-is-0 is-full max-is-full"),
|
|
104
|
+
className: mx("grid relative", rail ? orientation === "horizontal" ? railGridHorizontal : railGridVertical : orientation === "horizontal" ? "grid-rows-1 pli-1" : "grid-cols-1 plb-1", size === "contain" && (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),
|
|
105
|
+
"data-rail": rail,
|
|
48
106
|
"aria-orientation": orientation,
|
|
49
107
|
style: styles,
|
|
50
|
-
ref:
|
|
51
|
-
}, children
|
|
108
|
+
ref: composedItemRef
|
|
109
|
+
}, children, selfDroppable && dropping && /* @__PURE__ */ React.createElement(ListItem.DropIndicator, {
|
|
110
|
+
lineInset: 8,
|
|
111
|
+
terminalInset: -8,
|
|
112
|
+
gap: -8,
|
|
113
|
+
edge: orientation === "horizontal" ? "left" : "top"
|
|
114
|
+
})));
|
|
52
115
|
});
|
|
53
116
|
|
|
54
117
|
// packages/ui/react-ui-stack/src/components/StackItem.tsx
|
|
55
|
-
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
56
|
-
import { draggable as draggable2, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
57
|
-
import {
|
|
118
|
+
import { combine as combine2 } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
119
|
+
import { draggable as draggable2, dropTargetForElements as dropTargetForElements2 } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
120
|
+
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
121
|
+
import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
|
|
122
|
+
import { attachClosestEdge as attachClosestEdge2, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
58
123
|
import { useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
|
|
59
|
-
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
60
|
-
import
|
|
124
|
+
import { composeRefs as composeRefs2 } from "@radix-ui/react-compose-refs";
|
|
125
|
+
import React8, { forwardRef as forwardRef5, useLayoutEffect as useLayoutEffect3, useState as useState3, useCallback } from "react";
|
|
126
|
+
import { ListItem as ListItem2 } from "@dxos/react-ui";
|
|
61
127
|
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
62
128
|
|
|
63
129
|
// packages/ui/react-ui-stack/src/components/StackItemContent.tsx
|
|
64
|
-
import React2 from "react";
|
|
130
|
+
import React2, { forwardRef as forwardRef2 } from "react";
|
|
65
131
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
66
|
-
var StackItemContent = ({ children, toolbar
|
|
67
|
-
const { size
|
|
132
|
+
var StackItemContent = /* @__PURE__ */ forwardRef2(({ children, toolbar, statusbar, classNames, size = "intrinsic", ...props }, forwardedRef) => {
|
|
133
|
+
const { size: stackItemSize } = useStack();
|
|
68
134
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
69
135
|
role: "none",
|
|
70
136
|
...props,
|
|
71
|
-
className: mx2("group grid grid-cols-[100%]",
|
|
137
|
+
className: mx2("group grid grid-cols-[100%]", stackItemSize === "contain" && "min-bs-0 overflow-hidden", size === "video" ? "aspect-video" : size === "square" && "aspect-square", classNames),
|
|
72
138
|
style: {
|
|
73
139
|
gridTemplateRows: [
|
|
74
140
|
...toolbar ? [
|
|
@@ -79,36 +145,47 @@ var StackItemContent = ({ children, toolbar = true, statusbar, classNames, ...pr
|
|
|
79
145
|
"var(--statusbar-size)"
|
|
80
146
|
] : []
|
|
81
147
|
].join(" ")
|
|
82
|
-
}
|
|
148
|
+
},
|
|
149
|
+
ref: forwardedRef
|
|
150
|
+
}, children);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// packages/ui/react-ui-stack/src/components/StackItemDragHandle.tsx
|
|
154
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
155
|
+
import React3 from "react";
|
|
156
|
+
var StackItemDragHandle = ({ asChild, children }) => {
|
|
157
|
+
const { selfDragHandleRef } = useStackItem();
|
|
158
|
+
const Root = asChild ? Slot : "div";
|
|
159
|
+
return /* @__PURE__ */ React3.createElement(Root, {
|
|
160
|
+
ref: selfDragHandleRef,
|
|
161
|
+
role: "button"
|
|
83
162
|
}, children);
|
|
84
163
|
};
|
|
85
164
|
|
|
86
165
|
// packages/ui/react-ui-stack/src/components/StackItemHeading.tsx
|
|
87
166
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
|
88
|
-
import
|
|
167
|
+
import React4, { forwardRef as forwardRef3 } from "react";
|
|
89
168
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
90
169
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
91
170
|
var StackItemHeading = ({ children, classNames, ...props }) => {
|
|
92
171
|
const { orientation } = useStack();
|
|
93
|
-
const { selfDragHandleRef } = useStackItem();
|
|
94
172
|
const focusableGroupAttrs = useFocusableGroup({
|
|
95
173
|
tabBehavior: "limited"
|
|
96
174
|
});
|
|
97
|
-
return /* @__PURE__ */
|
|
175
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
98
176
|
role: "heading",
|
|
99
177
|
...props,
|
|
100
178
|
tabIndex: 0,
|
|
101
179
|
...focusableGroupAttrs,
|
|
102
|
-
className: mx3("flex items-center
|
|
103
|
-
ref: selfDragHandleRef
|
|
180
|
+
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)
|
|
104
181
|
}, children);
|
|
105
182
|
};
|
|
106
|
-
var StackItemHeadingLabel = /* @__PURE__ */
|
|
183
|
+
var StackItemHeadingLabel = /* @__PURE__ */ forwardRef3(({ attendableId, related, classNames, ...props }, forwardedRef) => {
|
|
107
184
|
const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
|
|
108
|
-
return /* @__PURE__ */
|
|
185
|
+
return /* @__PURE__ */ React4.createElement("h1", {
|
|
109
186
|
...props,
|
|
110
187
|
"data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
|
|
111
|
-
className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText", classNames),
|
|
188
|
+
className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText self-center", classNames),
|
|
112
189
|
ref: forwardedRef
|
|
113
190
|
});
|
|
114
191
|
});
|
|
@@ -117,10 +194,11 @@ var StackItemHeadingLabel = /* @__PURE__ */ forwardRef2(({ attendableId, related
|
|
|
117
194
|
import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
118
195
|
import { disableNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview";
|
|
119
196
|
import { preventUnhandled } from "@atlaskit/pragmatic-drag-and-drop/prevent-unhandled";
|
|
120
|
-
import
|
|
197
|
+
import React5, { useLayoutEffect as useLayoutEffect2, useRef } from "react";
|
|
121
198
|
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
122
199
|
var REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
123
|
-
var
|
|
200
|
+
var MIN_WIDTH = 20;
|
|
201
|
+
var MIN_HEIGHT = 3;
|
|
124
202
|
var measureStackItem = (element) => {
|
|
125
203
|
const stackItemElement = element.closest("[data-dx-stack-item]");
|
|
126
204
|
return stackItemElement?.getBoundingClientRect() ?? {
|
|
@@ -129,7 +207,7 @@ var measureStackItem = (element) => {
|
|
|
129
207
|
};
|
|
130
208
|
};
|
|
131
209
|
var getNextSize = (startSize, location, client) => {
|
|
132
|
-
return Math.max(
|
|
210
|
+
return Math.max(client === "clientX" ? MIN_WIDTH : MIN_HEIGHT, startSize + (location.current.input[client] - location.initial.input[client]) / REM);
|
|
133
211
|
};
|
|
134
212
|
var StackItemResizeHandle = () => {
|
|
135
213
|
const { orientation } = useStack();
|
|
@@ -137,7 +215,7 @@ var StackItemResizeHandle = () => {
|
|
|
137
215
|
const buttonRef = useRef(null);
|
|
138
216
|
const dragStartSize = useRef(size);
|
|
139
217
|
const client = orientation === "horizontal" ? "clientX" : "clientY";
|
|
140
|
-
|
|
218
|
+
useLayoutEffect2(() => {
|
|
141
219
|
if (!buttonRef.current || buttonRef.current.hasAttribute("draggable")) {
|
|
142
220
|
return;
|
|
143
221
|
}
|
|
@@ -168,49 +246,51 @@ var StackItemResizeHandle = () => {
|
|
|
168
246
|
}
|
|
169
247
|
});
|
|
170
248
|
}, []);
|
|
171
|
-
return /* @__PURE__ */
|
|
249
|
+
return /* @__PURE__ */ React5.createElement("button", {
|
|
172
250
|
ref: buttonRef,
|
|
173
|
-
className: mx4(orientation === "horizontal" ? "cursor-col-resize" : "cursor-row-resize
|
|
174
|
-
}, /* @__PURE__ */
|
|
251
|
+
className: mx4("group absolute", orientation === "horizontal" ? "cursor-col-resize is-3 bs-full inline-end-[-1px] !border-lb-0 before:inset-block-0 before:inline-end-0 before:is-1" : "cursor-row-resize bs-3 is-full block-end-[-1px] !border-li-0 before:inset-inline-0 before:block-end-0 before:bs-1", "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:bg-accentFocusIndicator")
|
|
252
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
175
253
|
role: "none",
|
|
176
|
-
className: "absolute
|
|
177
|
-
}, /* @__PURE__ */
|
|
254
|
+
className: mx4("absolute flex items-center group-hover:opacity-0 group-focus-visible:opacity-0 group-active:opacity-0", orientation === "horizontal" ? "block-start-0 inline-end-px bs-[--rail-size]" : "inline-start-0 block-end-px is-[--rail-size] flex justify-center")
|
|
255
|
+
}, /* @__PURE__ */ React5.createElement(DragHandleSignifier, {
|
|
256
|
+
orientation
|
|
257
|
+
})));
|
|
178
258
|
};
|
|
179
|
-
var DragHandleSignifier = () => {
|
|
180
|
-
return /* @__PURE__ */
|
|
259
|
+
var DragHandleSignifier = ({ orientation }) => {
|
|
260
|
+
return /* @__PURE__ */ React5.createElement("svg", {
|
|
181
261
|
xmlns: "http://www.w3.org/2000/svg",
|
|
182
262
|
viewBox: "0 0 256 256",
|
|
183
263
|
fill: "currentColor",
|
|
184
|
-
className: "shrink-0 bs-[1em] is-[1em] text-unAccent"
|
|
185
|
-
}, /* @__PURE__ */
|
|
264
|
+
className: mx4("shrink-0 bs-[1em] is-[1em] text-unAccent", orientation === "vertical" && "rotate-90")
|
|
265
|
+
}, /* @__PURE__ */ React5.createElement("path", {
|
|
186
266
|
d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
187
|
-
}), /* @__PURE__ */
|
|
267
|
+
}), /* @__PURE__ */ React5.createElement("path", {
|
|
188
268
|
d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
189
|
-
}), /* @__PURE__ */
|
|
269
|
+
}), /* @__PURE__ */ React5.createElement("path", {
|
|
190
270
|
d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
191
|
-
}), /* @__PURE__ */
|
|
271
|
+
}), /* @__PURE__ */ React5.createElement("path", {
|
|
192
272
|
d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
193
273
|
}));
|
|
194
274
|
};
|
|
195
275
|
|
|
196
276
|
// packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
|
|
197
|
-
import
|
|
277
|
+
import React7, { Fragment, forwardRef as forwardRef4, useRef as useRef2, useState as useState2 } from "react";
|
|
198
278
|
import { keySymbols } from "@dxos/keyboard";
|
|
199
|
-
import { Button, DropdownMenu, Icon, toLocalizedString,
|
|
279
|
+
import { Button, DropdownMenu, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
200
280
|
import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
201
281
|
import { descriptionText, mx as mx5 } from "@dxos/react-ui-theme";
|
|
202
282
|
import { getHostPlatform } from "@dxos/util";
|
|
203
283
|
|
|
204
284
|
// packages/ui/react-ui-stack/src/components/MenuSignifier.tsx
|
|
205
|
-
import
|
|
206
|
-
var MenuSignifierHorizontal = () => /* @__PURE__ */
|
|
285
|
+
import React6 from "react";
|
|
286
|
+
var MenuSignifierHorizontal = () => /* @__PURE__ */ React6.createElement("svg", {
|
|
207
287
|
className: "absolute block-end-[7px]",
|
|
208
288
|
width: 20,
|
|
209
289
|
height: 2,
|
|
210
290
|
viewBox: "0 0 20 2",
|
|
211
291
|
stroke: "currentColor",
|
|
212
292
|
opacity: 0.5
|
|
213
|
-
}, /* @__PURE__ */
|
|
293
|
+
}, /* @__PURE__ */ React6.createElement("line", {
|
|
214
294
|
x1: 0.5,
|
|
215
295
|
y1: 0.75,
|
|
216
296
|
x2: 19,
|
|
@@ -240,35 +320,40 @@ var translations_default = [
|
|
|
240
320
|
];
|
|
241
321
|
|
|
242
322
|
// packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
|
|
243
|
-
var StackItemSigilButton = /* @__PURE__ */
|
|
323
|
+
var StackItemSigilButton = /* @__PURE__ */ forwardRef4(({ attendableId, classNames, related, children, ...props }, forwardedRef) => {
|
|
244
324
|
const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
|
|
245
325
|
const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
|
|
246
|
-
return /* @__PURE__ */
|
|
326
|
+
return /* @__PURE__ */ React7.createElement(Button, {
|
|
247
327
|
...props,
|
|
248
328
|
variant,
|
|
249
329
|
classNames: [
|
|
250
|
-
"
|
|
330
|
+
"shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative app-no-drag",
|
|
251
331
|
classNames
|
|
252
332
|
],
|
|
253
333
|
ref: forwardedRef
|
|
254
|
-
}, /* @__PURE__ */
|
|
334
|
+
}, /* @__PURE__ */ React7.createElement(MenuSignifierHorizontal, null), children);
|
|
255
335
|
});
|
|
256
|
-
var StackItemSigil = /* @__PURE__ */
|
|
336
|
+
var StackItemSigil = /* @__PURE__ */ forwardRef4(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
257
337
|
const { t } = useTranslation(translationKey);
|
|
258
338
|
const suppressNextTooltip = useRef2(false);
|
|
259
|
-
const [optionsMenuOpen, setOptionsMenuOpen] =
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
339
|
+
const [optionsMenuOpen, setOptionsMenuOpen] = useState2(false);
|
|
340
|
+
const hasActions = actionGroups && actionGroups.length > 0;
|
|
341
|
+
const button = /* @__PURE__ */ React7.createElement(StackItemSigilButton, {
|
|
342
|
+
attendableId,
|
|
343
|
+
related,
|
|
344
|
+
// TODO(wittjosiah): Better disabling of interactive styles when no action are available.
|
|
345
|
+
// Remove underscore icon when no actions are available?
|
|
346
|
+
classNames: !hasActions && "cursor-default"
|
|
347
|
+
}, /* @__PURE__ */ React7.createElement("span", {
|
|
348
|
+
className: "sr-only"
|
|
349
|
+
}, triggerLabel), /* @__PURE__ */ React7.createElement(Icon, {
|
|
350
|
+
icon,
|
|
351
|
+
size: 5
|
|
352
|
+
}));
|
|
353
|
+
if (!hasActions) {
|
|
354
|
+
return button;
|
|
355
|
+
}
|
|
356
|
+
return /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
|
|
272
357
|
open: optionsMenuOpen,
|
|
273
358
|
onOpenChange: (nextOpen) => {
|
|
274
359
|
if (!nextOpen) {
|
|
@@ -276,30 +361,20 @@ var StackItemSigil = /* @__PURE__ */ forwardRef3(({ actions: actionGroups, onAct
|
|
|
276
361
|
}
|
|
277
362
|
return setOptionsMenuOpen(nextOpen);
|
|
278
363
|
}
|
|
279
|
-
}, /* @__PURE__ */
|
|
280
|
-
asChild: true
|
|
281
|
-
}, /* @__PURE__ */ React6.createElement(DropdownMenu.Trigger, {
|
|
364
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
282
365
|
asChild: true,
|
|
283
366
|
ref: forwardedRef
|
|
284
|
-
}, /* @__PURE__ */
|
|
285
|
-
attendableId,
|
|
286
|
-
related
|
|
287
|
-
}, /* @__PURE__ */ React6.createElement("span", {
|
|
288
|
-
className: "sr-only"
|
|
289
|
-
}, triggerLabel), /* @__PURE__ */ React6.createElement(Icon, {
|
|
290
|
-
icon,
|
|
291
|
-
size: 5
|
|
292
|
-
})))), /* @__PURE__ */ React6.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React6.createElement(DropdownMenu.Content, {
|
|
367
|
+
}, button), /* @__PURE__ */ React7.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Content, {
|
|
293
368
|
classNames: "z-[31]"
|
|
294
|
-
}, /* @__PURE__ */
|
|
295
|
-
const separator = index > 0 ? /* @__PURE__ */
|
|
296
|
-
return /* @__PURE__ */
|
|
369
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
|
|
370
|
+
const separator = index > 0 ? /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null) : null;
|
|
371
|
+
return /* @__PURE__ */ React7.createElement(Fragment, {
|
|
297
372
|
key: index
|
|
298
373
|
}, separator, actions.map((action) => {
|
|
299
374
|
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
|
|
300
375
|
const menuItemType = action.properties.menuItemType;
|
|
301
376
|
const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
|
|
302
|
-
return /* @__PURE__ */
|
|
377
|
+
return /* @__PURE__ */ React7.createElement(Root, {
|
|
303
378
|
key: action.id,
|
|
304
379
|
onClick: (event) => {
|
|
305
380
|
if (action.properties.disabled) {
|
|
@@ -316,40 +391,35 @@ var StackItemSigil = /* @__PURE__ */ forwardRef3(({ actions: actionGroups, onAct
|
|
|
316
391
|
...action.properties?.testId && {
|
|
317
392
|
"data-testid": action.properties.testId
|
|
318
393
|
}
|
|
319
|
-
}, /* @__PURE__ */
|
|
394
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
320
395
|
icon: action.properties.icon ?? "ph--placeholder--regular",
|
|
321
396
|
size: 4
|
|
322
|
-
}), /* @__PURE__ */
|
|
397
|
+
}), /* @__PURE__ */ React7.createElement("span", {
|
|
323
398
|
className: "grow truncate"
|
|
324
|
-
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */
|
|
399
|
+
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React7.createElement(DropdownMenu.ItemIndicator, {
|
|
325
400
|
asChild: true
|
|
326
|
-
}, /* @__PURE__ */
|
|
401
|
+
}, /* @__PURE__ */ React7.createElement(Icon, {
|
|
327
402
|
icon: "ph--check--regular",
|
|
328
403
|
size: 4
|
|
329
|
-
})), shortcut && /* @__PURE__ */
|
|
404
|
+
})), shortcut && /* @__PURE__ */ React7.createElement("span", {
|
|
330
405
|
className: mx5("shrink-0", descriptionText)
|
|
331
406
|
}, keySymbols(shortcut).join("")));
|
|
332
407
|
}));
|
|
333
|
-
}), children), /* @__PURE__ */
|
|
334
|
-
style: {
|
|
335
|
-
zIndex: 70
|
|
336
|
-
},
|
|
337
|
-
side: "bottom"
|
|
338
|
-
}, triggerLabel, /* @__PURE__ */ React6.createElement(Tooltip.Arrow, null))));
|
|
408
|
+
}), children), /* @__PURE__ */ React7.createElement(DropdownMenu.Arrow, null))));
|
|
339
409
|
});
|
|
340
410
|
|
|
341
411
|
// packages/ui/react-ui-stack/src/components/StackItem.tsx
|
|
342
412
|
var DEFAULT_HORIZONTAL_SIZE = 44;
|
|
343
413
|
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
344
414
|
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
345
|
-
var StackItemRoot = /* @__PURE__ */
|
|
346
|
-
const [itemElement, itemRef] =
|
|
347
|
-
const [selfDragHandleElement, selfDragHandleRef] =
|
|
348
|
-
const [
|
|
349
|
-
const { orientation, rail,
|
|
350
|
-
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] =
|
|
415
|
+
var StackItemRoot = /* @__PURE__ */ forwardRef5(({ item, children, classNames, size: propsSize, onSizeChange, role, order, style, disableRearrange, focusIndicatorVariant = "over-all", ...props }, forwardedRef) => {
|
|
416
|
+
const [itemElement, itemRef] = useState3(null);
|
|
417
|
+
const [selfDragHandleElement, selfDragHandleRef] = useState3(null);
|
|
418
|
+
const [closestEdge, setEdge] = useState3(null);
|
|
419
|
+
const { orientation, rail, onRearrange } = useStack();
|
|
420
|
+
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState3(propsSize);
|
|
351
421
|
const Root = role ?? "div";
|
|
352
|
-
const composedItemRef =
|
|
422
|
+
const composedItemRef = composeRefs2(itemRef, forwardedRef);
|
|
353
423
|
const setSize = useCallback((nextSize, commit) => {
|
|
354
424
|
setInternalSize(nextSize);
|
|
355
425
|
if (commit) {
|
|
@@ -359,11 +429,11 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
|
|
|
359
429
|
onSizeChange
|
|
360
430
|
]);
|
|
361
431
|
const type = orientation === "horizontal" ? "column" : "card";
|
|
362
|
-
|
|
363
|
-
if (!itemElement || !onRearrange) {
|
|
432
|
+
useLayoutEffect3(() => {
|
|
433
|
+
if (!itemElement || !onRearrange || disableRearrange) {
|
|
364
434
|
return;
|
|
365
435
|
}
|
|
366
|
-
return
|
|
436
|
+
return combine2(draggable2({
|
|
367
437
|
element: itemElement,
|
|
368
438
|
...selfDragHandleElement && {
|
|
369
439
|
dragHandle: selfDragHandleElement
|
|
@@ -371,11 +441,31 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
|
|
|
371
441
|
getInitialData: () => ({
|
|
372
442
|
id: item.id,
|
|
373
443
|
type
|
|
374
|
-
})
|
|
375
|
-
|
|
444
|
+
}),
|
|
445
|
+
onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
|
|
446
|
+
document.body.setAttribute("data-drag-preview", "true");
|
|
447
|
+
scrollJustEnoughIntoView({
|
|
448
|
+
element: source.element
|
|
449
|
+
});
|
|
450
|
+
const { x, y } = preserveOffsetOnSource({
|
|
451
|
+
element: source.element,
|
|
452
|
+
input: location.current.input
|
|
453
|
+
})({
|
|
454
|
+
container: source.element.offsetParent ?? document.body
|
|
455
|
+
});
|
|
456
|
+
nativeSetDragImage?.(source.element, x, y);
|
|
457
|
+
},
|
|
458
|
+
onDragStart: () => {
|
|
459
|
+
document.body.removeAttribute("data-drag-preview");
|
|
460
|
+
itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
|
|
461
|
+
},
|
|
462
|
+
onDrop: () => {
|
|
463
|
+
itemElement?.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
|
|
464
|
+
}
|
|
465
|
+
}), dropTargetForElements2({
|
|
376
466
|
element: itemElement,
|
|
377
467
|
getData: ({ input, element }) => {
|
|
378
|
-
return
|
|
468
|
+
return attachClosestEdge2({
|
|
379
469
|
id: item.id,
|
|
380
470
|
type
|
|
381
471
|
}, {
|
|
@@ -392,19 +482,19 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
|
|
|
392
482
|
},
|
|
393
483
|
onDragEnter: ({ self, source }) => {
|
|
394
484
|
if (source.data.type === self.data.type) {
|
|
395
|
-
setEdge(
|
|
485
|
+
setEdge(extractClosestEdge2(self.data));
|
|
396
486
|
}
|
|
397
487
|
},
|
|
398
488
|
onDrag: ({ self, source }) => {
|
|
399
489
|
if (source.data.type === self.data.type) {
|
|
400
|
-
setEdge(
|
|
490
|
+
setEdge(extractClosestEdge2(self.data));
|
|
401
491
|
}
|
|
402
492
|
},
|
|
403
493
|
onDragLeave: () => setEdge(null),
|
|
404
494
|
onDrop: ({ self, source }) => {
|
|
405
495
|
setEdge(null);
|
|
406
496
|
if (source.data.type === self.data.type) {
|
|
407
|
-
onRearrange(source.data, self.data,
|
|
497
|
+
onRearrange(source.data, self.data, extractClosestEdge2(self.data));
|
|
408
498
|
}
|
|
409
499
|
}
|
|
410
500
|
}));
|
|
@@ -418,17 +508,17 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
|
|
|
418
508
|
const focusGroupAttrs = useFocusableGroup2({
|
|
419
509
|
tabBehavior: "limited"
|
|
420
510
|
});
|
|
421
|
-
return /* @__PURE__ */
|
|
511
|
+
return /* @__PURE__ */ React8.createElement(StackItemContext.Provider, {
|
|
422
512
|
value: {
|
|
423
513
|
selfDragHandleRef,
|
|
424
514
|
size,
|
|
425
515
|
setSize
|
|
426
516
|
}
|
|
427
|
-
}, /* @__PURE__ */
|
|
517
|
+
}, /* @__PURE__ */ React8.createElement(Root, {
|
|
428
518
|
...props,
|
|
429
519
|
tabIndex: 0,
|
|
430
520
|
...focusGroupAttrs,
|
|
431
|
-
className: mx6("group/stack-item grid relative
|
|
521
|
+
className: mx6("group/stack-item grid relative", focusIndicatorVariant === "over-all" ? "dx-focus-ring-inset-over-all" : orientation === "horizontal" ? "dx-focus-ring-group-x" : "dx-focus-ring-group-y", size === "min-content" && (orientation === "horizontal" ? "is-min" : "bs-min"), orientation === "horizontal" ? "grid-rows-subgrid" : "grid-cols-subgrid", rail && (orientation === "horizontal" ? "row-span-2" : "col-span-2"), classNames),
|
|
432
522
|
"data-dx-stack-item": true,
|
|
433
523
|
style: {
|
|
434
524
|
...size !== "min-content" && {
|
|
@@ -440,7 +530,11 @@ var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, o
|
|
|
440
530
|
...style
|
|
441
531
|
},
|
|
442
532
|
ref: composedItemRef
|
|
443
|
-
}, children
|
|
533
|
+
}, children, closestEdge && /* @__PURE__ */ React8.createElement(ListItem2.DropIndicator, {
|
|
534
|
+
lineInset: 8,
|
|
535
|
+
terminalInset: -8,
|
|
536
|
+
edge: closestEdge
|
|
537
|
+
})));
|
|
444
538
|
});
|
|
445
539
|
var StackItem = {
|
|
446
540
|
Root: StackItemRoot,
|
|
@@ -448,55 +542,55 @@ var StackItem = {
|
|
|
448
542
|
Heading: StackItemHeading,
|
|
449
543
|
HeadingLabel: StackItemHeadingLabel,
|
|
450
544
|
ResizeHandle: StackItemResizeHandle,
|
|
545
|
+
DragHandle: StackItemDragHandle,
|
|
451
546
|
Sigil: StackItemSigil,
|
|
452
547
|
SigilButton: StackItemSigilButton
|
|
453
548
|
};
|
|
454
549
|
|
|
455
550
|
// packages/ui/react-ui-stack/src/components/LayoutControls.tsx
|
|
456
|
-
import
|
|
457
|
-
import { Button as Button2, ButtonGroup, Icon as Icon2, Tooltip
|
|
551
|
+
import React9, { forwardRef as forwardRef6 } from "react";
|
|
552
|
+
import { Button as Button2, ButtonGroup, Icon as Icon2, Tooltip, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
458
553
|
var LayoutControl = ({ icon, label, ...props }) => {
|
|
459
|
-
return /* @__PURE__ */
|
|
554
|
+
return /* @__PURE__ */ React9.createElement(Tooltip.Root, null, /* @__PURE__ */ React9.createElement(Tooltip.Trigger, {
|
|
460
555
|
asChild: true
|
|
461
|
-
}, /* @__PURE__ */
|
|
556
|
+
}, /* @__PURE__ */ React9.createElement(Button2, {
|
|
462
557
|
variant: "ghost",
|
|
463
558
|
...props
|
|
464
|
-
}, /* @__PURE__ */
|
|
559
|
+
}, /* @__PURE__ */ React9.createElement("span", {
|
|
465
560
|
className: "sr-only"
|
|
466
|
-
}, label), /* @__PURE__ */
|
|
561
|
+
}, label), /* @__PURE__ */ React9.createElement(Icon2, {
|
|
467
562
|
icon
|
|
468
|
-
}))), /* @__PURE__ */
|
|
469
|
-
side: "bottom"
|
|
470
|
-
classNames: "z-[70]"
|
|
563
|
+
}))), /* @__PURE__ */ React9.createElement(Tooltip.Portal, null, /* @__PURE__ */ React9.createElement(Tooltip.Content, {
|
|
564
|
+
side: "bottom"
|
|
471
565
|
}, label)));
|
|
472
566
|
};
|
|
473
|
-
var LayoutControls = /* @__PURE__ */
|
|
567
|
+
var LayoutControls = /* @__PURE__ */ forwardRef6(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
|
|
474
568
|
const { t } = useTranslation2(translationKey);
|
|
475
569
|
const buttonClassNames = variant === "hide-disabled" ? "disabled:hidden !p-1" : "!p-1";
|
|
476
|
-
return /* @__PURE__ */
|
|
570
|
+
return /* @__PURE__ */ React9.createElement(ButtonGroup, {
|
|
477
571
|
...props,
|
|
478
572
|
ref: forwardedRef
|
|
479
573
|
}, pin && !isSolo && [
|
|
480
574
|
"both",
|
|
481
575
|
"start"
|
|
482
|
-
].includes(pin) && /* @__PURE__ */
|
|
576
|
+
].includes(pin) && /* @__PURE__ */ React9.createElement(LayoutControl, {
|
|
483
577
|
label: t("pin start label"),
|
|
484
578
|
variant: "ghost",
|
|
485
579
|
classNames: buttonClassNames,
|
|
486
580
|
onClick: () => onClick?.("pin-start"),
|
|
487
581
|
icon: "ph--caret-line-left--regular"
|
|
488
|
-
}), can.solo && /* @__PURE__ */
|
|
582
|
+
}), can.solo && /* @__PURE__ */ React9.createElement(LayoutControl, {
|
|
489
583
|
label: t("solo layout label"),
|
|
490
584
|
classNames: buttonClassNames,
|
|
491
585
|
onClick: () => onClick?.("solo"),
|
|
492
586
|
icon: isSolo ? "ph--arrows-in--regular" : "ph--arrows-out--regular"
|
|
493
|
-
}), !isSolo && can.solo && /* @__PURE__ */
|
|
587
|
+
}), !isSolo && can.solo && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(LayoutControl, {
|
|
494
588
|
label: t("increment start label"),
|
|
495
589
|
disabled: !can.incrementStart,
|
|
496
590
|
classNames: buttonClassNames,
|
|
497
591
|
onClick: () => onClick?.("increment-start"),
|
|
498
592
|
icon: "ph--caret-left--regular"
|
|
499
|
-
}), /* @__PURE__ */
|
|
593
|
+
}), /* @__PURE__ */ React9.createElement(LayoutControl, {
|
|
500
594
|
label: t("increment end label"),
|
|
501
595
|
disabled: !can.incrementEnd,
|
|
502
596
|
classNames: buttonClassNames,
|
|
@@ -505,12 +599,12 @@ var LayoutControls = /* @__PURE__ */ forwardRef5(({ onClick, variant = "default"
|
|
|
505
599
|
})), pin && !isSolo && [
|
|
506
600
|
"both",
|
|
507
601
|
"end"
|
|
508
|
-
].includes(pin) && /* @__PURE__ */
|
|
602
|
+
].includes(pin) && /* @__PURE__ */ React9.createElement(LayoutControl, {
|
|
509
603
|
label: t("pin end label"),
|
|
510
604
|
classNames: buttonClassNames,
|
|
511
605
|
onClick: () => onClick?.("pin-end"),
|
|
512
606
|
icon: "ph--caret-line-right--regular"
|
|
513
|
-
}), close && !isSolo && /* @__PURE__ */
|
|
607
|
+
}), close && !isSolo && /* @__PURE__ */ React9.createElement(LayoutControl, {
|
|
514
608
|
label: t(`${typeof close === "string" ? "minify" : "close"} label`),
|
|
515
609
|
classNames: buttonClassNames,
|
|
516
610
|
onClick: () => onClick?.("close"),
|
|
@@ -526,8 +620,12 @@ export {
|
|
|
526
620
|
Stack,
|
|
527
621
|
StackContext,
|
|
528
622
|
StackItem,
|
|
623
|
+
StackItemContext,
|
|
624
|
+
autoScrollRootAttributes,
|
|
529
625
|
railGridHorizontal,
|
|
530
626
|
railGridVertical,
|
|
531
|
-
translations_default as translations
|
|
627
|
+
translations_default as translations,
|
|
628
|
+
useStack,
|
|
629
|
+
useStackItem
|
|
532
630
|
};
|
|
533
631
|
//# sourceMappingURL=index.mjs.map
|