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