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