@dxos/react-ui-stack 0.6.14-staging.934c9de → 0.6.14-staging.9b873ce
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 +494 -335
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +3 -6
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +478 -326
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +3 -6
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +494 -335
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +3 -6
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/components/LayoutControls.d.ts +19 -0
- package/dist/types/src/components/LayoutControls.d.ts.map +1 -0
- package/dist/types/src/components/MenuSignifier.d.ts +4 -0
- package/dist/types/src/components/MenuSignifier.d.ts.map +1 -0
- package/dist/types/src/components/Stack.d.ts +12 -12
- package/dist/types/src/components/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Stack.stories.d.ts +6 -83
- package/dist/types/src/components/Stack.stories.d.ts.map +1 -1
- package/dist/types/src/components/StackContext.d.ts +19 -0
- package/dist/types/src/components/StackContext.d.ts.map +1 -0
- package/dist/types/src/components/StackItem.d.ts +41 -0
- package/dist/types/src/components/StackItem.d.ts.map +1 -0
- package/dist/types/src/components/StackItemContent.d.ts +9 -0
- package/dist/types/src/components/StackItemContent.d.ts.map +1 -0
- package/dist/types/src/components/StackItemHeading.d.ts +8 -0
- package/dist/types/src/components/StackItemHeading.d.ts.map +1 -0
- package/dist/types/src/components/StackItemResizeHandle.d.ts +3 -0
- package/dist/types/src/components/StackItemResizeHandle.d.ts.map +1 -0
- package/dist/types/src/components/StackItemSigil.d.ts +31 -0
- package/dist/types/src/components/StackItemSigil.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/testing/EditorContent.d.ts +2 -2
- package/dist/types/src/testing/EditorContent.d.ts.map +1 -1
- package/dist/types/src/testing/stack-manager.d.ts +0 -1
- package/dist/types/src/testing/stack-manager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -8
- package/package.json +19 -20
- package/src/components/LayoutControls.tsx +131 -0
- package/src/components/MenuSignifier.tsx +33 -0
- package/src/components/Stack.stories.tsx +109 -182
- package/src/components/Stack.tsx +61 -156
- package/src/components/StackContext.tsx +38 -0
- package/src/components/StackItem.tsx +173 -0
- package/src/components/StackItemContent.tsx +49 -0
- package/src/components/StackItemHeading.tsx +55 -0
- package/src/components/StackItemResizeHandle.tsx +115 -0
- package/src/components/StackItemSigil.tsx +170 -0
- package/src/components/index.ts +3 -2
- package/src/playwright/smoke.spec.ts +3 -3
- package/src/testing/EditorContent.tsx +4 -4
- package/src/testing/stack-manager.ts +3 -7
- package/src/translations.ts +8 -8
- package/dist/types/src/components/CaretDownUp.d.ts +0 -4
- package/dist/types/src/components/CaretDownUp.d.ts.map +0 -1
- package/dist/types/src/components/ContentTypes.stories.d.ts +0 -96
- package/dist/types/src/components/ContentTypes.stories.d.ts.map +0 -1
- package/dist/types/src/components/Deck.stories.d.ts +0 -19
- package/dist/types/src/components/Deck.stories.d.ts.map +0 -1
- package/dist/types/src/components/Section.d.ts +0 -53
- package/dist/types/src/components/Section.d.ts.map +0 -1
- package/dist/types/src/components/Section.stories.d.ts +0 -36
- package/dist/types/src/components/Section.stories.d.ts.map +0 -1
- package/dist/types/src/components/style-fragments.d.ts +0 -2
- package/dist/types/src/components/style-fragments.d.ts.map +0 -1
- package/dist/types/src/next/Stack.d.ts +0 -9
- package/dist/types/src/next/Stack.d.ts.map +0 -1
- package/dist/types/src/next/Stack.stories.d.ts +0 -8
- package/dist/types/src/next/Stack.stories.d.ts.map +0 -1
- package/dist/types/src/next/StackItem.d.ts +0 -14
- package/dist/types/src/next/StackItem.d.ts.map +0 -1
- package/dist/types/src/next/index.d.ts +0 -2
- package/dist/types/src/next/index.d.ts.map +0 -1
- package/dist/types/src/testing/TableContent.d.ts +0 -20
- package/dist/types/src/testing/TableContent.d.ts.map +0 -1
- package/src/components/CaretDownUp.tsx +0 -31
- package/src/components/ContentTypes.stories.tsx +0 -104
- package/src/components/Deck.stories.tsx +0 -362
- package/src/components/Section.stories.tsx +0 -50
- package/src/components/Section.tsx +0 -378
- package/src/components/style-fragments.ts +0 -5
- package/src/next/Stack.stories.tsx +0 -148
- package/src/next/Stack.tsx +0 -30
- package/src/next/StackItem.tsx +0 -78
- package/src/next/index.ts +0 -5
- package/src/testing/TableContent.tsx +0 -119
|
@@ -1,52 +1,224 @@
|
|
|
1
1
|
// packages/ui/react-ui-stack/src/components/Stack.tsx
|
|
2
|
-
import { useArrowNavigationGroup
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { List as List2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
6
|
-
import { Mosaic, Path, useContainer, useItemsWithPreview, useMosaic as useMosaic2 } from "@dxos/react-ui-mosaic";
|
|
7
|
-
import { dropRingInner } from "@dxos/react-ui-theme";
|
|
2
|
+
import { useArrowNavigationGroup } from "@fluentui/react-tabster";
|
|
3
|
+
import React, { Children, forwardRef } from "react";
|
|
4
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
8
5
|
|
|
9
|
-
// packages/ui/react-ui-stack/src/components/
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
// packages/ui/react-ui-stack/src/components/StackContext.tsx
|
|
7
|
+
import { createContext, useContext } from "react";
|
|
8
|
+
var StackContext = /* @__PURE__ */ createContext({
|
|
9
|
+
orientation: "vertical",
|
|
10
|
+
rail: true,
|
|
11
|
+
size: "intrinsic",
|
|
12
|
+
separators: true
|
|
13
|
+
});
|
|
14
|
+
var useStack = () => useContext(StackContext);
|
|
15
|
+
var StackItemContext = /* @__PURE__ */ createContext({
|
|
16
|
+
selfDragHandleRef: () => {
|
|
17
|
+
},
|
|
18
|
+
size: "min-content",
|
|
19
|
+
setSize: () => {
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var useStackItem = () => useContext(StackItemContext);
|
|
19
23
|
|
|
20
|
-
// packages/ui/react-ui-stack/src/components/
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
+
// packages/ui/react-ui-stack/src/components/Stack.tsx
|
|
25
|
+
var railGridHorizontal = "grid-rows-[[rail-start]_var(--rail-size)_[content-start]_1fr_[content-end]]";
|
|
26
|
+
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, separators = true, size = "intrinsic", itemsCount = Children.count(children), ...props }, forwardedRef) => {
|
|
28
|
+
const arrowNavigationGroup = useArrowNavigationGroup({
|
|
29
|
+
axis: orientation
|
|
30
|
+
});
|
|
31
|
+
const styles = {
|
|
32
|
+
[orientation === "horizontal" ? "gridTemplateColumns" : "gridTemplateRows"]: `repeat(${itemsCount}, min-content)`,
|
|
33
|
+
...style
|
|
34
|
+
};
|
|
35
|
+
return /* @__PURE__ */ React.createElement(StackContext.Provider, {
|
|
36
|
+
value: {
|
|
37
|
+
orientation,
|
|
38
|
+
rail,
|
|
39
|
+
size,
|
|
40
|
+
separators
|
|
41
|
+
}
|
|
42
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
43
|
+
...props,
|
|
44
|
+
...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"), separators && (orientation === "horizontal" ? "divide-separator divide-x" : "divide-separator divide-y"), classNames),
|
|
46
|
+
"aria-orientation": orientation,
|
|
47
|
+
style: styles,
|
|
48
|
+
ref: forwardedRef
|
|
49
|
+
}, children));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// packages/ui/react-ui-stack/src/components/StackItem.tsx
|
|
53
|
+
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 { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
56
|
+
import { DropIndicator } from "@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box";
|
|
57
|
+
import { useFocusableGroup as useFocusableGroup2 } from "@fluentui/react-tabster";
|
|
58
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
59
|
+
import React7, { forwardRef as forwardRef4, useLayoutEffect as useLayoutEffect2, useState as useState2, useCallback } from "react";
|
|
60
|
+
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
61
|
+
|
|
62
|
+
// packages/ui/react-ui-stack/src/components/StackItemContent.tsx
|
|
63
|
+
import React2 from "react";
|
|
64
|
+
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
65
|
+
var StackItemContent = ({ children, toolbar = true, statusbar, contentSize = "cover", classNames, ...props }) => {
|
|
66
|
+
const { size, separators } = useStack();
|
|
67
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
68
|
+
role: "none",
|
|
69
|
+
...props,
|
|
70
|
+
className: mx2("group grid grid-cols-[100%]", size === "contain" && "min-bs-0 overflow-hidden", separators && "divide-separator divide-y", classNames),
|
|
71
|
+
style: {
|
|
72
|
+
gridTemplateRows: [
|
|
73
|
+
...toolbar ? [
|
|
74
|
+
"var(--rail-action)"
|
|
75
|
+
] : [],
|
|
76
|
+
"1fr",
|
|
77
|
+
...statusbar ? [
|
|
78
|
+
"var(--statusbar-size)"
|
|
79
|
+
] : []
|
|
80
|
+
].join(" ")
|
|
81
|
+
}
|
|
82
|
+
}, children);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// packages/ui/react-ui-stack/src/components/StackItemHeading.tsx
|
|
86
|
+
import { useFocusableGroup } from "@fluentui/react-tabster";
|
|
87
|
+
import React3, { forwardRef as forwardRef2 } from "react";
|
|
88
|
+
import { useAttention } from "@dxos/react-ui-attention";
|
|
89
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
90
|
+
var StackItemHeading = ({ children, classNames, ...props }) => {
|
|
91
|
+
const { orientation } = useStack();
|
|
92
|
+
const { selfDragHandleRef } = useStackItem();
|
|
93
|
+
const focusableGroupAttrs = useFocusableGroup({
|
|
94
|
+
tabBehavior: "limited"
|
|
95
|
+
});
|
|
96
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
97
|
+
role: "heading",
|
|
98
|
+
...props,
|
|
99
|
+
tabIndex: 0,
|
|
100
|
+
...focusableGroupAttrs,
|
|
101
|
+
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
|
+
ref: selfDragHandleRef
|
|
103
|
+
}, children);
|
|
104
|
+
};
|
|
105
|
+
var StackItemHeadingLabel = /* @__PURE__ */ forwardRef2(({ attendableId, related, classNames, ...props }, forwardedRef) => {
|
|
106
|
+
const { hasAttention, isAncestor, isRelated } = useAttention(attendableId);
|
|
107
|
+
return /* @__PURE__ */ React3.createElement("h1", {
|
|
108
|
+
...props,
|
|
109
|
+
"data-attention": (related && isRelated || hasAttention || isAncestor).toString(),
|
|
110
|
+
className: mx3("pli-1 min-is-0 is-0 grow truncate font-medium text-baseText data-[attention=true]:text-accentText", classNames),
|
|
111
|
+
ref: forwardedRef
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// packages/ui/react-ui-stack/src/components/StackItemResizeHandle.tsx
|
|
116
|
+
import { draggable } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
117
|
+
import { disableNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/disable-native-drag-preview";
|
|
118
|
+
import { preventUnhandled } from "@atlaskit/pragmatic-drag-and-drop/prevent-unhandled";
|
|
119
|
+
import React4, { useLayoutEffect, useRef } from "react";
|
|
120
|
+
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
121
|
+
var REM = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
122
|
+
var MIN_SIZE = 20;
|
|
123
|
+
var measureStackItem = (element) => {
|
|
124
|
+
const stackItemElement = element.closest("[data-dx-stack-item]");
|
|
125
|
+
return stackItemElement?.getBoundingClientRect() ?? {
|
|
126
|
+
width: DEFAULT_EXTRINSIC_SIZE,
|
|
127
|
+
height: DEFAULT_EXTRINSIC_SIZE
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
var getNextSize = (startSize, location, client) => {
|
|
131
|
+
return Math.max(MIN_SIZE, startSize + (location.current.input[client] - location.initial.input[client]) / REM);
|
|
132
|
+
};
|
|
133
|
+
var StackItemResizeHandle = () => {
|
|
134
|
+
const { orientation } = useStack();
|
|
135
|
+
const { setSize, size } = useStackItem();
|
|
136
|
+
const buttonRef = useRef(null);
|
|
137
|
+
const dragStartSize = useRef(size);
|
|
138
|
+
const client = orientation === "horizontal" ? "clientX" : "clientY";
|
|
139
|
+
useLayoutEffect(() => {
|
|
140
|
+
if (!buttonRef.current || buttonRef.current.hasAttribute("draggable")) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
draggable({
|
|
144
|
+
element: buttonRef.current,
|
|
145
|
+
onGenerateDragPreview: ({ nativeSetDragImage }) => {
|
|
146
|
+
disableNativeDragPreview({
|
|
147
|
+
nativeSetDragImage
|
|
148
|
+
});
|
|
149
|
+
preventUnhandled.start();
|
|
150
|
+
},
|
|
151
|
+
onDragStart: () => {
|
|
152
|
+
dragStartSize.current = dragStartSize.current === "min-content" ? measureStackItem(buttonRef.current)[orientation === "horizontal" ? "width" : "height"] / REM : dragStartSize.current;
|
|
153
|
+
},
|
|
154
|
+
onDrag: ({ location }) => {
|
|
155
|
+
if (typeof dragStartSize.current !== "number") {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
setSize(getNextSize(dragStartSize.current, location, client));
|
|
159
|
+
},
|
|
160
|
+
onDrop: ({ location }) => {
|
|
161
|
+
if (typeof dragStartSize.current !== "number") {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const nextSize = getNextSize(dragStartSize.current, location, client);
|
|
165
|
+
setSize(nextSize, true);
|
|
166
|
+
dragStartSize.current = nextSize;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}, []);
|
|
170
|
+
return /* @__PURE__ */ React4.createElement("button", {
|
|
171
|
+
ref: buttonRef,
|
|
172
|
+
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")
|
|
173
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
174
|
+
role: "none",
|
|
175
|
+
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"
|
|
176
|
+
}, /* @__PURE__ */ React4.createElement(DragHandleSignifier, null)));
|
|
177
|
+
};
|
|
178
|
+
var DragHandleSignifier = () => {
|
|
179
|
+
return /* @__PURE__ */ React4.createElement("svg", {
|
|
24
180
|
xmlns: "http://www.w3.org/2000/svg",
|
|
25
181
|
viewBox: "0 0 256 256",
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
strokeWidth: "16"
|
|
38
|
-
}), /* @__PURE__ */ React.createElement("polyline", {
|
|
39
|
-
points: "80 32 128 80 176 32",
|
|
40
|
-
fill: "none",
|
|
41
|
-
stroke: "currentColor",
|
|
42
|
-
strokeLinecap: "round",
|
|
43
|
-
strokeLinejoin: "round",
|
|
44
|
-
strokeWidth: "16"
|
|
45
|
-
}), children);
|
|
182
|
+
fill: "currentColor",
|
|
183
|
+
className: "shrink-0 bs-[1em] is-[1em] text-unAccent"
|
|
184
|
+
}, /* @__PURE__ */ React4.createElement("path", {
|
|
185
|
+
d: "M256,64c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
186
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
187
|
+
d: "M256,120c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
188
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
189
|
+
d: "M256,176c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
190
|
+
}), /* @__PURE__ */ React4.createElement("path", {
|
|
191
|
+
d: "M256,232c-8.8,0-16-7.2-16-16s7.2-16,16-16v32Z"
|
|
192
|
+
}));
|
|
46
193
|
};
|
|
47
194
|
|
|
48
|
-
// packages/ui/react-ui-stack/src/components/
|
|
49
|
-
|
|
195
|
+
// packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
|
|
196
|
+
import React6, { Fragment, forwardRef as forwardRef3, useRef as useRef2, useState } from "react";
|
|
197
|
+
import { keySymbols } from "@dxos/keyboard";
|
|
198
|
+
import { Button, DropdownMenu, Icon, toLocalizedString, Tooltip, useTranslation } from "@dxos/react-ui";
|
|
199
|
+
import { useAttention as useAttention2 } from "@dxos/react-ui-attention";
|
|
200
|
+
import { descriptionText, mx as mx5 } from "@dxos/react-ui-theme";
|
|
201
|
+
import { getHostPlatform } from "@dxos/util";
|
|
202
|
+
|
|
203
|
+
// packages/ui/react-ui-stack/src/components/MenuSignifier.tsx
|
|
204
|
+
import React5 from "react";
|
|
205
|
+
var MenuSignifierHorizontal = () => /* @__PURE__ */ React5.createElement("svg", {
|
|
206
|
+
className: "absolute block-end-[7px]",
|
|
207
|
+
width: 20,
|
|
208
|
+
height: 2,
|
|
209
|
+
viewBox: "0 0 20 2",
|
|
210
|
+
stroke: "currentColor",
|
|
211
|
+
opacity: 0.5
|
|
212
|
+
}, /* @__PURE__ */ React5.createElement("line", {
|
|
213
|
+
x1: 0.5,
|
|
214
|
+
y1: 0.75,
|
|
215
|
+
x2: 19,
|
|
216
|
+
y2: 0.75,
|
|
217
|
+
strokeWidth: 1.25,
|
|
218
|
+
strokeLinecap: "round",
|
|
219
|
+
strokeDasharray: "6 20",
|
|
220
|
+
strokeDashoffset: "-6.5"
|
|
221
|
+
}));
|
|
50
222
|
|
|
51
223
|
// packages/ui/react-ui-stack/src/translations.ts
|
|
52
224
|
var translationKey = "stack";
|
|
@@ -54,323 +226,310 @@ var translations_default = [
|
|
|
54
226
|
{
|
|
55
227
|
"en-US": {
|
|
56
228
|
[translationKey]: {
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
229
|
+
"resize label": "Drag to resize",
|
|
230
|
+
"pin start label": "Pin to the left sidebar",
|
|
231
|
+
"pin end label": "Pin to the right sidebar",
|
|
232
|
+
"increment start label": "Move to the left",
|
|
233
|
+
"increment end label": "Move to the right",
|
|
234
|
+
"solo plank label": "Toggle solo mode",
|
|
235
|
+
"close label": "Close",
|
|
236
|
+
"minify label": "Minify"
|
|
65
237
|
}
|
|
66
238
|
}
|
|
67
239
|
}
|
|
68
240
|
];
|
|
69
241
|
|
|
70
|
-
// packages/ui/react-ui-stack/src/components/
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
|
|
242
|
+
// packages/ui/react-ui-stack/src/components/StackItemSigil.tsx
|
|
243
|
+
var StackItemSigilButton = /* @__PURE__ */ forwardRef3(({ attendableId, classNames, related, children, ...props }, forwardedRef) => {
|
|
244
|
+
const { hasAttention, isAncestor, isRelated } = useAttention2(attendableId);
|
|
245
|
+
const variant = related && isRelated || hasAttention || isAncestor ? "primary" : "ghost";
|
|
246
|
+
return /* @__PURE__ */ React6.createElement(Button, {
|
|
247
|
+
...props,
|
|
248
|
+
variant,
|
|
249
|
+
classNames: [
|
|
250
|
+
"m-1 shrink-0 pli-0 min-bs-0 is-[--rail-action] bs-[--rail-action] relative",
|
|
251
|
+
classNames
|
|
252
|
+
],
|
|
253
|
+
ref: forwardedRef
|
|
254
|
+
}, /* @__PURE__ */ React6.createElement(MenuSignifierHorizontal, null), children);
|
|
255
|
+
});
|
|
256
|
+
var StackItemSigil = /* @__PURE__ */ forwardRef3(({ actions: actionGroups, onAction, triggerLabel, attendableId, icon, related, children }, forwardedRef) => {
|
|
74
257
|
const { t } = useTranslation(translationKey);
|
|
258
|
+
const suppressNextTooltip = useRef2(false);
|
|
75
259
|
const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
260
|
+
const [triggerTooltipOpen, setTriggerTooltipOpen] = useState(false);
|
|
261
|
+
return /* @__PURE__ */ React6.createElement(Tooltip.Root, {
|
|
262
|
+
open: triggerTooltipOpen,
|
|
263
|
+
onOpenChange: (nextOpen) => {
|
|
264
|
+
if (suppressNextTooltip.current) {
|
|
265
|
+
setTriggerTooltipOpen(false);
|
|
266
|
+
suppressNextTooltip.current = false;
|
|
267
|
+
} else {
|
|
268
|
+
setTriggerTooltipOpen(nextOpen);
|
|
269
|
+
}
|
|
83
270
|
}
|
|
84
|
-
}
|
|
85
|
-
const sectionContentGroup = useFocusableGroup({});
|
|
86
|
-
const attendableAttrs = useAttendableAttributes(id);
|
|
87
|
-
return /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Root, {
|
|
88
|
-
asChild: true,
|
|
89
|
-
open: !collapsed,
|
|
90
|
-
onOpenChange: (nextOpen) => onCollapseSection?.(id, !nextOpen)
|
|
91
|
-
}, /* @__PURE__ */ React2.createElement(ListItem.Root, {
|
|
92
|
-
ref: forwardedRef,
|
|
93
|
-
id,
|
|
94
|
-
...attendableAttrs,
|
|
95
|
-
classNames: [
|
|
96
|
-
"grid col-span-2 group/section",
|
|
97
|
-
active === "overlay" ? stackColumns : "grid-cols-subgrid snap-start"
|
|
98
|
-
],
|
|
99
|
-
style: draggableStyle
|
|
100
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
101
|
-
role: "none",
|
|
102
|
-
className: mx("grid col-span-2 grid-cols-subgrid", "bg-base attention-surface", hoverableControls, hoverableFocusedWithinControls, (active === "origin" || active === "rearrange" || active === "destination") && "opacity-0")
|
|
103
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
104
|
-
role: "toolbar",
|
|
105
|
-
"aria-orientation": "vertical",
|
|
106
|
-
"aria-label": t("section controls label"),
|
|
107
|
-
...!active && {
|
|
108
|
-
tabIndex: 0
|
|
109
|
-
},
|
|
110
|
-
...!active && sectionActionsToolbar,
|
|
111
|
-
className: mx("grid grid-cols-subgrid ch-focus-ring rounded-sm grid-rows-[min-content_min-content_1fr] m-1", "group-has-[[role=toolbar][aria-orientation=horizontal]]/section:pbs-[--rail-action]")
|
|
112
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
113
|
-
role: "none",
|
|
114
|
-
className: "sticky -block-start-px bg-[--sticky-bg]"
|
|
115
|
-
}, /* @__PURE__ */ React2.createElement(DropdownMenu.Root, {
|
|
271
|
+
}, /* @__PURE__ */ React6.createElement(DropdownMenu.Root, {
|
|
116
272
|
open: optionsMenuOpen,
|
|
117
|
-
onOpenChange:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
...draggableProps
|
|
123
|
-
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
124
|
-
icon,
|
|
125
|
-
size: 5,
|
|
126
|
-
classNames: "transition-opacity"
|
|
127
|
-
})), /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, collapsed ? /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
128
|
-
onClick: onNavigate,
|
|
129
|
-
"data-testid": "section.navigate-to"
|
|
130
|
-
}, /* @__PURE__ */ React2.createElement(ArrowSquareOut, {
|
|
131
|
-
className: mx(getSize(5), "mr-2")
|
|
132
|
-
}), /* @__PURE__ */ React2.createElement("span", {
|
|
133
|
-
className: "grow"
|
|
134
|
-
}, t("navigate to section label"))) : /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
|
|
135
|
-
asChild: true
|
|
136
|
-
}, /* @__PURE__ */ React2.createElement(DropdownMenu.Item, null, /* @__PURE__ */ React2.createElement(CaretDownUp, {
|
|
137
|
-
className: mx(getSize(5), "mr-2")
|
|
138
|
-
}), /* @__PURE__ */ React2.createElement("span", {
|
|
139
|
-
className: "grow"
|
|
140
|
-
}, t("collapse label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
141
|
-
onClick: onAddBefore,
|
|
142
|
-
"data-testid": "section.add-before"
|
|
143
|
-
}, /* @__PURE__ */ React2.createElement(ArrowLineUp, {
|
|
144
|
-
className: mx(getSize(5), "mr-2")
|
|
145
|
-
}), /* @__PURE__ */ React2.createElement("span", {
|
|
146
|
-
className: "grow"
|
|
147
|
-
}, t("add section before label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
148
|
-
onClick: onAddAfter,
|
|
149
|
-
"data-testid": "section.add-after"
|
|
150
|
-
}, /* @__PURE__ */ React2.createElement(ArrowLineDown, {
|
|
151
|
-
className: mx(getSize(5), "mr-2")
|
|
152
|
-
}), /* @__PURE__ */ React2.createElement("span", {
|
|
153
|
-
className: "grow"
|
|
154
|
-
}, t("add section after label"))), /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
|
|
155
|
-
onClick: () => onDelete?.(),
|
|
156
|
-
"data-testid": "section.remove"
|
|
157
|
-
}, /* @__PURE__ */ React2.createElement(Trash, {
|
|
158
|
-
className: mx(getSize(5), "mr-2")
|
|
159
|
-
}), /* @__PURE__ */ React2.createElement("span", {
|
|
160
|
-
className: "grow"
|
|
161
|
-
}, t("remove section label")))), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null)))), collapsed ? /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Trigger, {
|
|
162
|
-
asChild: true
|
|
163
|
-
}, /* @__PURE__ */ React2.createElement(Button, {
|
|
164
|
-
variant: "ghost",
|
|
165
|
-
classNames: sectionActionDimensions
|
|
166
|
-
}, /* @__PURE__ */ React2.createElement("span", {
|
|
167
|
-
className: "sr-only"
|
|
168
|
-
}, t("expand label")), /* @__PURE__ */ React2.createElement(CaretUpDown, {
|
|
169
|
-
className: getSize(4)
|
|
170
|
-
}))) : /* @__PURE__ */ React2.createElement(Button, {
|
|
171
|
-
variant: "ghost",
|
|
172
|
-
classNames: sectionActionDimensions,
|
|
173
|
-
onClick: onNavigate,
|
|
174
|
-
"data-testid": "section.navigate-to"
|
|
175
|
-
}, /* @__PURE__ */ React2.createElement(ArrowSquareOut, {
|
|
176
|
-
className: mx(getSize(4))
|
|
177
|
-
}), /* @__PURE__ */ React2.createElement("span", {
|
|
178
|
-
className: "sr-only"
|
|
179
|
-
}, t("navigate to section label"))))), /* @__PURE__ */ React2.createElement(ListItem.Heading, {
|
|
180
|
-
classNames: collapsed ? [
|
|
181
|
-
"grid grid-rows-subgrid grid-cols-subgrid items-center",
|
|
182
|
-
focusRing
|
|
183
|
-
] : "sr-only",
|
|
184
|
-
...collapsed && {
|
|
185
|
-
...sectionContentGroup,
|
|
186
|
-
tabIndex: 0
|
|
273
|
+
onOpenChange: (nextOpen) => {
|
|
274
|
+
if (!nextOpen) {
|
|
275
|
+
suppressNextTooltip.current = true;
|
|
276
|
+
}
|
|
277
|
+
return setOptionsMenuOpen(nextOpen);
|
|
187
278
|
}
|
|
188
|
-
}, /* @__PURE__ */
|
|
189
|
-
className: "truncate"
|
|
190
|
-
}, title)), size === "intrinsic" ? /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Content, {
|
|
191
|
-
...!collapsed && {
|
|
192
|
-
...sectionContentGroup,
|
|
193
|
-
tabIndex: 0
|
|
194
|
-
},
|
|
195
|
-
// TODO(burdon): Add margin to fragment?
|
|
196
|
-
className: mx(focusRing, "m-[2px]")
|
|
197
|
-
}, children) : /* @__PURE__ */ React2.createElement(CollapsiblePrimitive.Content, {
|
|
279
|
+
}, /* @__PURE__ */ React6.createElement(Tooltip.Trigger, {
|
|
198
280
|
asChild: true
|
|
199
|
-
}, /* @__PURE__ */
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}, /* @__PURE__ */ React2.createElement(ScrollArea.Viewport, null, children), /* @__PURE__ */ React2.createElement(ScrollArea.Scrollbar, {
|
|
207
|
-
orientation: "horizontal",
|
|
208
|
-
variant: "coarse",
|
|
209
|
-
classNames: "hidden has-[div]:flex !inline-end-[max(.25rem,var(--radix-scroll-area-corner-width))]"
|
|
210
|
-
}, /* @__PURE__ */ React2.createElement(ScrollArea.Thumb, null)), /* @__PURE__ */ React2.createElement(ScrollArea.Scrollbar, {
|
|
211
|
-
orientation: "vertical",
|
|
212
|
-
variant: "coarse",
|
|
213
|
-
classNames: "hidden has-[div]:flex"
|
|
214
|
-
}, /* @__PURE__ */ React2.createElement(ScrollArea.Thumb, null)), /* @__PURE__ */ React2.createElement(ScrollArea.Corner, null)))), isResizable && !collapsed && /* @__PURE__ */ React2.createElement("button", {
|
|
215
|
-
className: resizeHandleStyles
|
|
216
|
-
}, /* @__PURE__ */ React2.createElement("span", {
|
|
281
|
+
}, /* @__PURE__ */ React6.createElement(DropdownMenu.Trigger, {
|
|
282
|
+
asChild: true,
|
|
283
|
+
ref: forwardedRef
|
|
284
|
+
}, /* @__PURE__ */ React6.createElement(StackItemSigilButton, {
|
|
285
|
+
attendableId,
|
|
286
|
+
related
|
|
287
|
+
}, /* @__PURE__ */ React6.createElement("span", {
|
|
217
288
|
className: "sr-only"
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}));
|
|
269
|
-
return active === "overlay" ? /* @__PURE__ */ React2.createElement(List, null, section) : section;
|
|
289
|
+
}, triggerLabel), /* @__PURE__ */ React6.createElement(Icon, {
|
|
290
|
+
icon,
|
|
291
|
+
size: 5
|
|
292
|
+
})))), /* @__PURE__ */ React6.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React6.createElement(DropdownMenu.Content, {
|
|
293
|
+
classNames: "z-[31]"
|
|
294
|
+
}, /* @__PURE__ */ React6.createElement(DropdownMenu.Viewport, null, actionGroups?.map((actions, index) => {
|
|
295
|
+
const separator = index > 0 ? /* @__PURE__ */ React6.createElement(DropdownMenu.Separator, null) : null;
|
|
296
|
+
return /* @__PURE__ */ React6.createElement(Fragment, {
|
|
297
|
+
key: index
|
|
298
|
+
}, separator, actions.map((action) => {
|
|
299
|
+
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
|
|
300
|
+
const menuItemType = action.properties.menuItemType;
|
|
301
|
+
const Root = menuItemType === "toggle" ? DropdownMenu.CheckboxItem : DropdownMenu.Item;
|
|
302
|
+
return /* @__PURE__ */ React6.createElement(Root, {
|
|
303
|
+
key: action.id,
|
|
304
|
+
onClick: (event) => {
|
|
305
|
+
if (action.properties.disabled) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
event.stopPropagation();
|
|
309
|
+
suppressNextTooltip.current = true;
|
|
310
|
+
setOptionsMenuOpen(false);
|
|
311
|
+
onAction?.(action);
|
|
312
|
+
},
|
|
313
|
+
classNames: "gap-2",
|
|
314
|
+
disabled: action.properties.disabled,
|
|
315
|
+
checked: menuItemType === "toggle" ? action.properties.isChecked : void 0,
|
|
316
|
+
...action.properties?.testId && {
|
|
317
|
+
"data-testid": action.properties.testId
|
|
318
|
+
}
|
|
319
|
+
}, /* @__PURE__ */ React6.createElement(Icon, {
|
|
320
|
+
icon: action.properties.icon ?? "ph--placeholder--regular",
|
|
321
|
+
size: 4
|
|
322
|
+
}), /* @__PURE__ */ React6.createElement("span", {
|
|
323
|
+
className: "grow truncate"
|
|
324
|
+
}, toLocalizedString(action.properties.label ?? "", t)), menuItemType === "toggle" && /* @__PURE__ */ React6.createElement(DropdownMenu.ItemIndicator, {
|
|
325
|
+
asChild: true
|
|
326
|
+
}, /* @__PURE__ */ React6.createElement(Icon, {
|
|
327
|
+
icon: "ph--check--regular",
|
|
328
|
+
size: 4
|
|
329
|
+
})), shortcut && /* @__PURE__ */ React6.createElement("span", {
|
|
330
|
+
className: mx5("shrink-0", descriptionText)
|
|
331
|
+
}, keySymbols(shortcut).join("")));
|
|
332
|
+
}));
|
|
333
|
+
}), children), /* @__PURE__ */ React6.createElement(DropdownMenu.Arrow, null)))), /* @__PURE__ */ React6.createElement(Tooltip.Portal, null, /* @__PURE__ */ React6.createElement(Tooltip.Content, {
|
|
334
|
+
style: {
|
|
335
|
+
zIndex: 70
|
|
336
|
+
},
|
|
337
|
+
side: "bottom"
|
|
338
|
+
}, triggerLabel, /* @__PURE__ */ React6.createElement(Tooltip.Arrow, null))));
|
|
270
339
|
});
|
|
271
340
|
|
|
272
|
-
// packages/ui/react-ui-stack/src/components/
|
|
273
|
-
var
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
341
|
+
// packages/ui/react-ui-stack/src/components/StackItem.tsx
|
|
342
|
+
var DEFAULT_HORIZONTAL_SIZE = 44;
|
|
343
|
+
var DEFAULT_VERTICAL_SIZE = "min-content";
|
|
344
|
+
var DEFAULT_EXTRINSIC_SIZE = DEFAULT_HORIZONTAL_SIZE;
|
|
345
|
+
var StackItemRoot = /* @__PURE__ */ forwardRef4(({ item, children, classNames, onRearrange, size: propsSize, onSizeChange, role, order, style, ...props }, forwardedRef) => {
|
|
346
|
+
const [itemElement, itemRef] = useState2(null);
|
|
347
|
+
const [selfDragHandleElement, selfDragHandleRef] = useState2(null);
|
|
348
|
+
const [closestEdge, setEdge] = useState2(null);
|
|
349
|
+
const { orientation, rail, separators } = useStack();
|
|
350
|
+
const [size = orientation === "horizontal" ? DEFAULT_HORIZONTAL_SIZE : DEFAULT_VERTICAL_SIZE, setInternalSize] = useState2(propsSize);
|
|
351
|
+
const Root = role ?? "div";
|
|
352
|
+
const composedItemRef = composeRefs(itemRef, forwardedRef);
|
|
353
|
+
const setSize = useCallback((nextSize, commit) => {
|
|
354
|
+
setInternalSize(nextSize);
|
|
355
|
+
if (commit) {
|
|
356
|
+
onSizeChange?.(nextSize);
|
|
357
|
+
}
|
|
358
|
+
}, [
|
|
359
|
+
onSizeChange
|
|
287
360
|
]);
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
361
|
+
const type = orientation === "horizontal" ? "column" : "card";
|
|
362
|
+
useLayoutEffect2(() => {
|
|
363
|
+
if (!itemElement || !onRearrange) {
|
|
364
|
+
return;
|
|
292
365
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
366
|
+
return combine(draggable2({
|
|
367
|
+
element: itemElement,
|
|
368
|
+
...selfDragHandleElement && {
|
|
369
|
+
dragHandle: selfDragHandleElement
|
|
370
|
+
},
|
|
371
|
+
getInitialData: () => ({
|
|
372
|
+
id: item.id,
|
|
373
|
+
type
|
|
374
|
+
})
|
|
375
|
+
}), dropTargetForElements({
|
|
376
|
+
element: itemElement,
|
|
377
|
+
getData: ({ input, element }) => {
|
|
378
|
+
return attachClosestEdge({
|
|
379
|
+
id: item.id,
|
|
380
|
+
type
|
|
381
|
+
}, {
|
|
382
|
+
input,
|
|
383
|
+
element,
|
|
384
|
+
allowedEdges: orientation === "horizontal" ? [
|
|
385
|
+
"left",
|
|
386
|
+
"right"
|
|
387
|
+
] : [
|
|
388
|
+
"top",
|
|
389
|
+
"bottom"
|
|
390
|
+
]
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
onDragEnter: ({ self, source }) => {
|
|
394
|
+
if (source.data.type === self.data.type) {
|
|
395
|
+
setEdge(extractClosestEdge(self.data));
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
onDrag: ({ self, source }) => {
|
|
399
|
+
if (source.data.type === self.data.type) {
|
|
400
|
+
setEdge(extractClosestEdge(self.data));
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
onDragLeave: () => setEdge(null),
|
|
404
|
+
onDrop: ({ self, source }) => {
|
|
405
|
+
setEdge(null);
|
|
406
|
+
if (source.data.type === self.data.type) {
|
|
407
|
+
onRearrange(source.data, self.data, extractClosestEdge(self.data));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}));
|
|
411
|
+
}, [
|
|
412
|
+
orientation,
|
|
413
|
+
item,
|
|
414
|
+
onRearrange,
|
|
415
|
+
selfDragHandleElement,
|
|
416
|
+
itemElement
|
|
296
417
|
]);
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
418
|
+
const focusGroupAttrs = useFocusableGroup2({
|
|
419
|
+
tabBehavior: "limited"
|
|
420
|
+
});
|
|
421
|
+
return /* @__PURE__ */ React7.createElement(StackItemContext.Provider, {
|
|
422
|
+
value: {
|
|
423
|
+
selfDragHandleRef,
|
|
424
|
+
size,
|
|
425
|
+
setSize
|
|
300
426
|
}
|
|
301
|
-
|
|
302
|
-
}, []);
|
|
303
|
-
return /* @__PURE__ */ React3.createElement(Mosaic.Container, {
|
|
304
|
-
id,
|
|
305
|
-
type,
|
|
306
|
-
Component: SectionTile,
|
|
307
|
-
getOverlayStyle,
|
|
308
|
-
getOverlayProps,
|
|
309
|
-
onOver,
|
|
310
|
-
onDrop,
|
|
311
|
-
modifier: stackModifier
|
|
312
|
-
}, /* @__PURE__ */ React3.createElement(Mosaic.DroppableTile, {
|
|
313
|
-
path: id,
|
|
314
|
-
type,
|
|
315
|
-
item: {
|
|
316
|
-
id,
|
|
317
|
-
items: itemsWithPreview
|
|
318
|
-
},
|
|
319
|
-
// TODO(wittjosiah): Should this actually be a context?
|
|
320
|
-
itemContext: {
|
|
321
|
-
separation,
|
|
322
|
-
transform,
|
|
323
|
-
onDeleteSection,
|
|
324
|
-
onNavigateToSection,
|
|
325
|
-
onAddSection,
|
|
326
|
-
onCollapseSection,
|
|
327
|
-
SectionContent
|
|
328
|
-
},
|
|
329
|
-
isOver: overItem && !!overItem.path && Path.hasRoot(overItem.path, id) && (operation === "copy" || operation === "transfer"),
|
|
330
|
-
Component: StackTile,
|
|
427
|
+
}, /* @__PURE__ */ React7.createElement(Root, {
|
|
331
428
|
...props,
|
|
332
|
-
|
|
333
|
-
|
|
429
|
+
tabIndex: 0,
|
|
430
|
+
...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"), separators && (orientation === "horizontal" ? "divide-separator divide-y" : "divide-separator divide-x"), classNames),
|
|
432
|
+
"data-dx-stack-item": true,
|
|
433
|
+
style: {
|
|
434
|
+
...size !== "min-content" && {
|
|
435
|
+
[orientation === "horizontal" ? "inlineSize" : "blockSize"]: `${size}rem`
|
|
436
|
+
},
|
|
437
|
+
...Number.isFinite(order) && {
|
|
438
|
+
[orientation === "horizontal" ? "gridColumn" : "gridRow"]: `${order}`
|
|
439
|
+
},
|
|
440
|
+
...style
|
|
441
|
+
},
|
|
442
|
+
ref: composedItemRef
|
|
443
|
+
}, children, closestEdge && /* @__PURE__ */ React7.createElement(DropIndicator, {
|
|
444
|
+
edge: closestEdge
|
|
445
|
+
})));
|
|
446
|
+
});
|
|
447
|
+
var StackItem = {
|
|
448
|
+
Root: StackItemRoot,
|
|
449
|
+
Content: StackItemContent,
|
|
450
|
+
Heading: StackItemHeading,
|
|
451
|
+
HeadingLabel: StackItemHeadingLabel,
|
|
452
|
+
ResizeHandle: StackItemResizeHandle,
|
|
453
|
+
Sigil: StackItemSigil,
|
|
454
|
+
SigilButton: StackItemSigilButton
|
|
334
455
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
ref: forwardedRef,
|
|
345
|
-
classNames: [
|
|
346
|
-
"grid relative",
|
|
347
|
-
stackColumns,
|
|
348
|
-
isOver && dropRingInner,
|
|
349
|
-
classNames
|
|
350
|
-
],
|
|
351
|
-
...!activeItem && domAttributes,
|
|
456
|
+
|
|
457
|
+
// packages/ui/react-ui-stack/src/components/LayoutControls.tsx
|
|
458
|
+
import React8, { forwardRef as forwardRef5 } from "react";
|
|
459
|
+
import { Button as Button2, ButtonGroup, Icon as Icon2, Tooltip as Tooltip2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
460
|
+
var LayoutControl = ({ icon, label, ...props }) => {
|
|
461
|
+
return /* @__PURE__ */ React8.createElement(Tooltip2.Root, null, /* @__PURE__ */ React8.createElement(Tooltip2.Trigger, {
|
|
462
|
+
asChild: true
|
|
463
|
+
}, /* @__PURE__ */ React8.createElement(Button2, {
|
|
464
|
+
variant: "ghost",
|
|
352
465
|
...props
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
466
|
+
}, /* @__PURE__ */ React8.createElement("span", {
|
|
467
|
+
className: "sr-only"
|
|
468
|
+
}, label), /* @__PURE__ */ React8.createElement(Icon2, {
|
|
469
|
+
icon
|
|
470
|
+
}))), /* @__PURE__ */ React8.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React8.createElement(Tooltip2.Content, {
|
|
471
|
+
side: "bottom",
|
|
472
|
+
classNames: "z-[70]"
|
|
473
|
+
}, label)));
|
|
474
|
+
};
|
|
475
|
+
var LayoutControls = /* @__PURE__ */ forwardRef5(({ onClick, variant = "default", capabilities: can, isSolo, pin, close = false, children, ...props }, forwardedRef) => {
|
|
476
|
+
const { t } = useTranslation2(translationKey);
|
|
477
|
+
const buttonClassNames = variant === "hide-disabled" ? "disabled:hidden !p-1" : "!p-1";
|
|
478
|
+
return /* @__PURE__ */ React8.createElement(ButtonGroup, {
|
|
479
|
+
...props,
|
|
480
|
+
ref: forwardedRef
|
|
481
|
+
}, pin && !isSolo && [
|
|
482
|
+
"both",
|
|
483
|
+
"start"
|
|
484
|
+
].includes(pin) && /* @__PURE__ */ React8.createElement(LayoutControl, {
|
|
485
|
+
label: t("pin start label"),
|
|
486
|
+
variant: "ghost",
|
|
487
|
+
classNames: buttonClassNames,
|
|
488
|
+
onClick: () => onClick?.("pin-start"),
|
|
489
|
+
icon: "ph--caret-line-left--regular"
|
|
490
|
+
}), can.solo && /* @__PURE__ */ React8.createElement(LayoutControl, {
|
|
491
|
+
label: t("solo layout label"),
|
|
492
|
+
classNames: buttonClassNames,
|
|
493
|
+
onClick: () => onClick?.("solo"),
|
|
494
|
+
icon: isSolo ? "ph--arrows-in--regular" : "ph--arrows-out--regular"
|
|
495
|
+
}), !isSolo && can.solo && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(LayoutControl, {
|
|
496
|
+
label: t("increment start label"),
|
|
497
|
+
disabled: !can.incrementStart,
|
|
498
|
+
classNames: buttonClassNames,
|
|
499
|
+
onClick: () => onClick?.("increment-start"),
|
|
500
|
+
icon: "ph--caret-left--regular"
|
|
501
|
+
}), /* @__PURE__ */ React8.createElement(LayoutControl, {
|
|
502
|
+
label: t("increment end label"),
|
|
503
|
+
disabled: !can.incrementEnd,
|
|
504
|
+
classNames: buttonClassNames,
|
|
505
|
+
onClick: () => onClick?.("increment-end"),
|
|
506
|
+
icon: "ph--caret-right--regular"
|
|
507
|
+
})), pin && !isSolo && [
|
|
508
|
+
"both",
|
|
509
|
+
"end"
|
|
510
|
+
].includes(pin) && /* @__PURE__ */ React8.createElement(LayoutControl, {
|
|
511
|
+
label: t("pin end label"),
|
|
512
|
+
classNames: buttonClassNames,
|
|
513
|
+
onClick: () => onClick?.("pin-end"),
|
|
514
|
+
icon: "ph--caret-line-right--regular"
|
|
515
|
+
}), close && !isSolo && /* @__PURE__ */ React8.createElement(LayoutControl, {
|
|
516
|
+
label: t(`${typeof close === "string" ? "minify" : "close"} label`),
|
|
517
|
+
classNames: buttonClassNames,
|
|
518
|
+
onClick: () => onClick?.("close"),
|
|
519
|
+
"data-testid": "layoutHeading.close",
|
|
520
|
+
icon: close === "minify-start" ? "ph--caret-line-left--regular" : close === "minify-end" ? "ph--caret-line-right--regular" : "ph--minus--regular"
|
|
521
|
+
}), children);
|
|
368
522
|
});
|
|
369
523
|
export {
|
|
370
|
-
|
|
371
|
-
|
|
524
|
+
DEFAULT_EXTRINSIC_SIZE,
|
|
525
|
+
DEFAULT_HORIZONTAL_SIZE,
|
|
526
|
+
DEFAULT_VERTICAL_SIZE,
|
|
527
|
+
LayoutControls,
|
|
372
528
|
Stack,
|
|
373
|
-
|
|
529
|
+
StackContext,
|
|
530
|
+
StackItem,
|
|
531
|
+
railGridHorizontal,
|
|
532
|
+
railGridVertical,
|
|
374
533
|
translations_default as translations
|
|
375
534
|
};
|
|
376
535
|
//# sourceMappingURL=index.mjs.map
|