@robert-stackflow/oneui 0.6.28 → 0.6.30
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.6.30
|
|
2
|
+
|
|
3
|
+
- Add an optional compact full hierarchy for immersive TableOfContents rail popups, stable anchoring, outward placement and a shared animated arrow. Existing flat previews keep their defaults.
|
|
4
|
+
|
|
5
|
+
## 0.6.29
|
|
6
|
+
|
|
7
|
+
- Keep one password visibility control in Edge by suppressing the duplicate native reveal button inside PasswordField.
|
|
8
|
+
|
|
1
9
|
## 0.6.28
|
|
2
10
|
|
|
3
11
|
- Keep Dialog headers and footer actions visible while long content scrolls inside the body, including narrow viewports and nested modals.
|
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
React 组件、应用外壳和两套可互换的主题。无 Electron、React Router、账户 API 或持久化存储依赖。
|
|
4
4
|
|
|
5
|
+
## 密码输入(0.6.29)
|
|
6
|
+
|
|
7
|
+
`PasswordField` 统一提供显示/隐藏密码操作,在 Edge 中隐藏重复的原生显示按钮。应用无需为该输入框覆盖浏览器伪元素样式。
|
|
8
|
+
|
|
5
9
|
## 长表单弹窗(0.6.28)
|
|
6
10
|
|
|
7
11
|
`Dialog` 的标题、关闭按钮和 `footer` 操作保持可见,超高内容在正文内部滚动。将主操作放入 `footer`,不要在应用侧为弹窗叠加高度、固定定位或滚动样式。闭合的原生弹窗仍保持隐藏,嵌套弹窗沿用统一焦点与进退场规则。
|
|
@@ -10,6 +10,9 @@ export type TableOfContentsProps = {
|
|
|
10
10
|
contentRef?: RefObject<HTMLElement | null>;
|
|
11
11
|
variant?: "tree" | "rail";
|
|
12
12
|
hoverMode?: "single" | "nearby" | "all";
|
|
13
|
+
/** Display the full compact hierarchy in a rail popup. */
|
|
14
|
+
railLayout?: "preview" | "outline";
|
|
15
|
+
popoverSide?: "left" | "right";
|
|
13
16
|
previewCount?: number;
|
|
14
17
|
depthBasedLength?: boolean;
|
|
15
18
|
label?: string;
|
|
@@ -19,4 +22,4 @@ export type TableOfContentsProps = {
|
|
|
19
22
|
scrollOffset?: number;
|
|
20
23
|
className?: string;
|
|
21
24
|
};
|
|
22
|
-
export declare function TableOfContents({ items, contentRef, variant, hoverMode, previewCount, depthBasedLength, label, activeId, onActiveChange, maxLevel, scrollOffset, className, }: TableOfContentsProps): import("react").JSX.Element | null;
|
|
25
|
+
export declare function TableOfContents({ items, contentRef, variant, hoverMode, railLayout, popoverSide, previewCount, depthBasedLength, label, activeId, onActiveChange, maxLevel, scrollOffset, className, }: TableOfContentsProps): import("react").JSX.Element | null;
|
|
@@ -22,6 +22,8 @@ function TableOfContents({
|
|
|
22
22
|
contentRef,
|
|
23
23
|
variant = "tree",
|
|
24
24
|
hoverMode = "nearby",
|
|
25
|
+
railLayout = "preview",
|
|
26
|
+
popoverSide = "left",
|
|
25
27
|
previewCount = 5,
|
|
26
28
|
depthBasedLength = false,
|
|
27
29
|
label = "\u672C\u9875\u76EE\u5F55",
|
|
@@ -58,9 +60,9 @@ function TableOfContents({
|
|
|
58
60
|
);
|
|
59
61
|
const popupAnchor = useMemo(
|
|
60
62
|
() => ({
|
|
61
|
-
current: lineNodes.current.get(entries[previewIndex]?.id ?? "") ?? railRoot.current
|
|
63
|
+
current: railLayout === "outline" ? railRoot.current : lineNodes.current.get(entries[previewIndex]?.id ?? "") ?? railRoot.current
|
|
62
64
|
}),
|
|
63
|
-
[previewIndex, entries, open]
|
|
65
|
+
[previewIndex, entries, open, railLayout]
|
|
64
66
|
);
|
|
65
67
|
const count = Number.isFinite(previewCount) ? Math.max(1, Math.floor(previewCount)) : 5;
|
|
66
68
|
const windowStart = Math.max(
|
|
@@ -156,7 +158,7 @@ function TableOfContents({
|
|
|
156
158
|
}, [entries, scrollOffset]);
|
|
157
159
|
useLayoutEffect(() => {
|
|
158
160
|
const node = list.current;
|
|
159
|
-
if (!node || variant === "rail") return;
|
|
161
|
+
if (!node || variant === "rail" && railLayout === "preview") return;
|
|
160
162
|
const measure = () => {
|
|
161
163
|
const links = [...node.querySelectorAll("a")];
|
|
162
164
|
if (!links.length || !node.offsetWidth) return;
|
|
@@ -197,7 +199,7 @@ function TableOfContents({
|
|
|
197
199
|
const observer = new ResizeObserver(measure);
|
|
198
200
|
observer.observe(node);
|
|
199
201
|
return () => observer.disconnect();
|
|
200
|
-
}, [entries, open, variant]);
|
|
202
|
+
}, [entries, open, variant, railLayout]);
|
|
201
203
|
const indices = entries.flatMap(
|
|
202
204
|
(entry, index) => active.includes(entry.id) ? [index] : []
|
|
203
205
|
);
|
|
@@ -207,14 +209,15 @@ function TableOfContents({
|
|
|
207
209
|
const distance = first && last ? up ? first.distance : last.distance + last.bottom - last.top : 0;
|
|
208
210
|
useLayoutEffect(() => {
|
|
209
211
|
const node = list.current;
|
|
210
|
-
if (!node || variant !== "tree" || !diagram.path)
|
|
212
|
+
if (!node || variant !== "tree" && railLayout !== "outline" || !diagram.path)
|
|
213
|
+
return;
|
|
211
214
|
if (!node.dataset.ready || measuredPath.current !== diagram.path) {
|
|
212
215
|
node.dataset.ready = "false";
|
|
213
216
|
node.getBoundingClientRect();
|
|
214
217
|
node.dataset.ready = "true";
|
|
215
218
|
measuredPath.current = diagram.path;
|
|
216
219
|
}
|
|
217
|
-
}, [diagram.path, variant]);
|
|
220
|
+
}, [diagram.path, variant, railLayout]);
|
|
218
221
|
useLayoutEffect(() => {
|
|
219
222
|
const node = list.current, viewport = node?.parentElement;
|
|
220
223
|
if (!viewport || !first || !last || !open && variant === "rail") return;
|
|
@@ -230,7 +233,7 @@ function TableOfContents({
|
|
|
230
233
|
});
|
|
231
234
|
}, [first, last, open, variant]);
|
|
232
235
|
useLayoutEffect(() => {
|
|
233
|
-
if (variant !== "rail" || !open) return;
|
|
236
|
+
if (variant !== "rail" || railLayout !== "preview" || !open) return;
|
|
234
237
|
const node = list.current, viewport = node?.parentElement;
|
|
235
238
|
const selected = node?.querySelector(
|
|
236
239
|
'[data-preview-target="true"]'
|
|
@@ -240,7 +243,7 @@ function TableOfContents({
|
|
|
240
243
|
viewport.scrollTop = selected.offsetTop;
|
|
241
244
|
else if (selected.offsetTop + selected.offsetHeight > viewport.scrollTop + viewport.clientHeight)
|
|
242
245
|
viewport.scrollTop = selected.offsetTop + selected.offsetHeight - viewport.clientHeight;
|
|
243
|
-
}, [current, open, variant, previewIndex, hoverMode]);
|
|
246
|
+
}, [current, open, variant, previewIndex, hoverMode, railLayout]);
|
|
244
247
|
useEffect(() => () => clearTimeout(timer.current), []);
|
|
245
248
|
const keepOpen = () => clearTimeout(timer.current);
|
|
246
249
|
const closeSoon = () => {
|
|
@@ -261,7 +264,7 @@ function TableOfContents({
|
|
|
261
264
|
});
|
|
262
265
|
setOpen(false);
|
|
263
266
|
};
|
|
264
|
-
const contents = () => variant === "rail" ? /* @__PURE__ */ jsxs(
|
|
267
|
+
const contents = () => variant === "rail" && railLayout === "preview" ? /* @__PURE__ */ jsxs(
|
|
265
268
|
"nav",
|
|
266
269
|
{
|
|
267
270
|
className: s.flatMenu,
|
|
@@ -295,7 +298,7 @@ function TableOfContents({
|
|
|
295
298
|
) : /* @__PURE__ */ jsxs(
|
|
296
299
|
"nav",
|
|
297
300
|
{
|
|
298
|
-
className: `${s.tree} ${variant === "tree" ? className : ""}`,
|
|
301
|
+
className: `${s.tree} ${railLayout === "outline" && variant === "rail" ? s.outlineTree : ""} ${variant === "tree" ? className : ""}`,
|
|
299
302
|
"aria-label": label,
|
|
300
303
|
children: [
|
|
301
304
|
/* @__PURE__ */ jsxs("div", { className: s.title, children: [
|
|
@@ -430,7 +433,7 @@ function TableOfContents({
|
|
|
430
433
|
});
|
|
431
434
|
},
|
|
432
435
|
anchor: popupAnchor,
|
|
433
|
-
side:
|
|
436
|
+
side: popoverSide,
|
|
434
437
|
align: "start",
|
|
435
438
|
label,
|
|
436
439
|
width: hoverMode === "single" ? 320 : 290,
|
|
@@ -438,6 +441,7 @@ function TableOfContents({
|
|
|
438
441
|
maxHeight: Infinity,
|
|
439
442
|
scrollable: false,
|
|
440
443
|
autoFocus: false,
|
|
444
|
+
arrow: railLayout === "outline",
|
|
441
445
|
children: /* @__PURE__ */ jsx(
|
|
442
446
|
"div",
|
|
443
447
|
{
|
|
@@ -130,6 +130,16 @@
|
|
|
130
130
|
.card .scroll {
|
|
131
131
|
max-height: min(440px, calc(100dvh - 110px));
|
|
132
132
|
}
|
|
133
|
+
.outlineTree .scroll {
|
|
134
|
+
max-height: min(480px, 60dvh, calc(100dvh - 96px));
|
|
135
|
+
}
|
|
136
|
+
.outlineTree .title {
|
|
137
|
+
margin-bottom: 6px;
|
|
138
|
+
}
|
|
139
|
+
.outlineTree .link {
|
|
140
|
+
line-height: 1.5;
|
|
141
|
+
min-height: 32px;
|
|
142
|
+
}
|
|
133
143
|
@media (prefers-reduced-motion: reduce) {
|
|
134
144
|
.activeGuide,
|
|
135
145
|
.thumb,
|