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