@robert-stackflow/oneui 0.6.42 → 0.6.44
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 +11 -0
- package/README.md +2 -2
- package/components/IconButton.d.ts +3 -1
- package/components/IconButton.js +2 -1
- package/components/Lightbox.js +39 -6
- package/components/Lightbox.module.css +5 -0
- package/components/TableOfContents.d.ts +3 -1
- package/components/TableOfContents.js +3 -2
- package/components/TableOfContents.module.css +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## 0.6.44
|
|
2
|
+
|
|
3
|
+
- Lightbox 按图片真实宽高比与可用画布尺寸显示加载骨架;窗口变化时同步适配。未提供有效尺寸时使用紧凑加载指示。
|
|
4
|
+
- 修正加载失败后点击重试可能被误判为滑动切图的问题。
|
|
5
|
+
- IconButton 支持 tooltip={false},保留可访问名称并避免紧凑浮层内重复弹出提示。
|
|
6
|
+
|
|
7
|
+
## 0.6.43
|
|
8
|
+
|
|
9
|
+
- Lightbox 加载骨架保持矩形,避免百分比圆角形成椭圆。
|
|
10
|
+
- TableOfContents 新增 scrollable 属性,支持容器统一管理滚动区域。
|
|
11
|
+
|
|
1
12
|
## 0.6.42
|
|
2
13
|
|
|
3
14
|
- Toast 采用轻叠卡片,支持数量按钮、悬停、键盘展开和 Escape 收起;展开按实际高度排列,保留独立关闭、原位更新与异步重试。
|
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ Section 支持 headingLevel(2–6,默认 2)和 contentLayout="settings";
|
|
|
89
89
|
|
|
90
90
|
## 阅读与反馈(0.6.13 候选)
|
|
91
91
|
|
|
92
|
-
`TableOfContents`
|
|
92
|
+
`TableOfContents` 可通过 `scrollable={false}` 交由外层容器滚动,避免嵌套滚动条。使用 `contentRef` 发现标题,或接收 `{id,label,level?}[]`。`variant="tree"` 使用层级路径、高亮可见标题范围和沿路径移动的定位点;几何只在尺寸变化时测量,滚动由 IntersectionObserver 更新状态。设计参考 [Fumadocs TOC](https://github.com/fuma-nama/fumadocs/blob/dev/packages/base-ui/src/components/toc/default.tsx)。`variant="rail"` 是独立的沉浸式样式,只标记当前阅读位置,短线 hover 有局部伸展,旁边的卡片使用无层级、无编号的平面目录。短线本身是可点击的原生锚点链接。`hoverMode="single" | "nearby" | "all"` 控制悬浮卡片展示当前标题与摘要、附近目录或全部目录,`previewCount`(默认 5)控制附近目录的总条数,`depthBasedLength` 可按层级改变短线基准长度。显式 items 可提供 `description`,自动发现时提取标题后的段落摘要。浮层跟随当前 hover 的短线定位,支持自动定位、键盘焦点、Escape、视口翻转及全局滚动条;不会接管正文之外的滚动。
|
|
93
93
|
|
|
94
94
|
`Table`、`DataTable`、`TreeTable`、`TableMarkup` 共用 `TableAppearance`:`striped`、`density="comfortable" | "compact"`、`hoverable`、`bordered`、`stickyHeader`。选中行优先于交替行和 hover,层级表格只保留一层外框。
|
|
95
95
|
|
|
@@ -328,7 +328,7 @@ Menu 支持 iconOnly:`<Menu iconOnly label="更多操作" items={items} />`
|
|
|
328
328
|
|
|
329
329
|
### Lightbox
|
|
330
330
|
|
|
331
|
-
`Lightbox` is a controlled image viewer: pass `open`, `items`, `index`, `onIndexChange` and `onClose`. Each item has a stable `id`, `src`, `alt` and optional `caption`, `thumbnailSrc`, `width` and `height`. The optional `sourceElement(item)` resolves the original image for Hero motion; `onLocate(item)` runs after exit and scroll unlocking. Supply `labels` for localization.
|
|
331
|
+
`Lightbox` is a controlled image viewer: pass `open`, `items`, `index`, `onIndexChange` and `onClose`. Each item has a stable `id`, `src`, `alt` and optional `caption`, `thumbnailSrc`, `width` and `height`. The optional `sourceElement(item)` resolves the original image for Hero motion; `onLocate(item)` runs after exit and scroll unlocking. Supply `labels` for localization. Provide valid `width` and `height` for an aspect-correct loading skeleton fitted to the canvas; images without known dimensions use a compact loading indicator.
|
|
332
332
|
|
|
333
333
|
The viewer uses an opaque black canvas with light controls independently of the document color mode. It supports captions, thumbnail navigation, non-wrapping previous/next, arrow keys, Escape, original-size zoom, bounded dragging, touch pinch/swipe and manual retry of the original URL. A single image hides navigation. Only adjacent full images are preloaded. It uses native modal isolation and shared OneUI focus, scroll lock and motion; reduced motion and missing/offscreen source elements use a quiet fallback. Keep the component mounted through exit and retain the selected index. Resolve resource permissions and document anchors in the host, not inside OneUI.
|
|
334
334
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
-
export declare function IconButton({ label, loading, children, text, variant, size, disclosure, ...props }: ComponentPropsWithRef<"button"> & {
|
|
2
|
+
export declare function IconButton({ label, loading, children, text, variant, size, disclosure, tooltip, ...props }: ComponentPropsWithRef<"button"> & {
|
|
3
3
|
label: string;
|
|
4
4
|
loading?: boolean;
|
|
5
5
|
/** Visible text or count inside the same hover, focus and click target as the icon. */
|
|
@@ -8,4 +8,6 @@ export declare function IconButton({ label, loading, children, text, variant, si
|
|
|
8
8
|
size?: "small" | "normal";
|
|
9
9
|
/** Add a spaced disclosure chevron, driven by aria-expanded. */
|
|
10
10
|
disclosure?: boolean;
|
|
11
|
+
/** Keep the accessible label while omitting redundant hover text in compact surfaces. */
|
|
12
|
+
tooltip?: boolean;
|
|
11
13
|
}): import("react").JSX.Element;
|
package/components/IconButton.js
CHANGED
|
@@ -12,9 +12,10 @@ function IconButton({
|
|
|
12
12
|
variant = "ghost",
|
|
13
13
|
size = "normal",
|
|
14
14
|
disclosure = false,
|
|
15
|
+
tooltip = true,
|
|
15
16
|
...props
|
|
16
17
|
}) {
|
|
17
|
-
return /* @__PURE__ */ jsx(Tooltip, { content: label, children: /* @__PURE__ */ jsxs(
|
|
18
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: label, disabled: !tooltip, children: /* @__PURE__ */ jsxs(
|
|
18
19
|
"button",
|
|
19
20
|
{
|
|
20
21
|
type: "button",
|
package/components/Lightbox.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from "lucide-react";
|
|
20
20
|
import { IconButton } from "./IconButton.js";
|
|
21
21
|
import { Skeleton } from "./Skeleton.js";
|
|
22
|
+
import { Spinner } from "./Spinner.js";
|
|
22
23
|
import { usePortalRoot } from "./usePortalRoot.js";
|
|
23
24
|
import { useModalScrollLock } from "./useModalScrollLock.js";
|
|
24
25
|
import { useModalFocus } from "./useModalFocus.js";
|
|
@@ -70,6 +71,34 @@ function Lightbox(props) {
|
|
|
70
71
|
const [closing, setClosing] = useState(false), [status, setStatus] = useState("loading");
|
|
71
72
|
const [zoom, setZoom] = useState(1), [pan, setPan] = useState({ x: 0, y: 0 });
|
|
72
73
|
const itemKey = item ? item.id + item.src : "";
|
|
74
|
+
const [loadingSize, setLoadingSize] = useState(null);
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
const stage = stageRef.current;
|
|
77
|
+
const width = item?.width, height = item?.height;
|
|
78
|
+
if (!open || !stage || !width || !height || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
79
|
+
setLoadingSize(null);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const measure = () => {
|
|
83
|
+
const scale = Math.min(
|
|
84
|
+
1,
|
|
85
|
+
stage.clientWidth / width,
|
|
86
|
+
stage.clientHeight / height
|
|
87
|
+
);
|
|
88
|
+
const next = {
|
|
89
|
+
key: itemKey,
|
|
90
|
+
width: width * scale,
|
|
91
|
+
height: height * scale
|
|
92
|
+
};
|
|
93
|
+
setLoadingSize(
|
|
94
|
+
(previous) => previous?.key === next.key && previous.width === next.width && previous.height === next.height ? previous : next
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
measure();
|
|
98
|
+
const observer = new ResizeObserver(measure);
|
|
99
|
+
observer.observe(stage);
|
|
100
|
+
return () => observer.disconnect();
|
|
101
|
+
}, [open, portal, itemKey, item?.width, item?.height]);
|
|
73
102
|
const [slide, setSlide] = useState({ key: itemKey, index, current: item, direction: 0 });
|
|
74
103
|
if (slide.key !== itemKey)
|
|
75
104
|
setSlide({
|
|
@@ -370,6 +399,7 @@ function Lightbox(props) {
|
|
|
370
399
|
);
|
|
371
400
|
};
|
|
372
401
|
const pointerEnd = (event) => {
|
|
402
|
+
if (!pointers.current.has(event.pointerId)) return;
|
|
373
403
|
const start = gesture.current, dx = event.clientX - start.x, dy = event.clientY - start.y;
|
|
374
404
|
pointers.current.delete(event.pointerId);
|
|
375
405
|
if (event.type !== "pointercancel" && !start.multi && zoom === 1 && Math.abs(dx) > 64 && Math.abs(dx) > Math.abs(dy) * 1.2)
|
|
@@ -501,14 +531,17 @@ function Lightbox(props) {
|
|
|
501
531
|
);
|
|
502
532
|
}
|
|
503
533
|
),
|
|
504
|
-
status === "loading" && /* @__PURE__ */ jsx("div", { className: s.feedback, role: "status", "aria-label": t.loading, children: /* @__PURE__ */ jsx(
|
|
505
|
-
|
|
534
|
+
status === "loading" && /* @__PURE__ */ jsx("div", { className: s.feedback, role: "status", "aria-label": t.loading, children: loadingSize?.key === itemKey ? /* @__PURE__ */ jsx(
|
|
535
|
+
"div",
|
|
506
536
|
{
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
537
|
+
className: s.loadingImage,
|
|
538
|
+
style: {
|
|
539
|
+
width: loadingSize.width,
|
|
540
|
+
height: loadingSize.height
|
|
541
|
+
},
|
|
542
|
+
children: /* @__PURE__ */ jsx(Skeleton, { width: "100%", height: "100%" })
|
|
510
543
|
}
|
|
511
|
-
) }),
|
|
544
|
+
) : /* @__PURE__ */ jsx(Spinner, { size: 22, decorative: true }) }),
|
|
512
545
|
status === "error" && /* @__PURE__ */ jsxs("div", { className: s.feedback, role: "status", children: [
|
|
513
546
|
/* @__PURE__ */ jsx("span", { children: t.error }),
|
|
514
547
|
/* @__PURE__ */ jsx(
|
|
@@ -20,6 +20,8 @@ export type TableOfContentsProps = {
|
|
|
20
20
|
onActiveChange?(id: string): void;
|
|
21
21
|
maxLevel?: number;
|
|
22
22
|
scrollOffset?: number;
|
|
23
|
+
/** Disable internal scrolling when a containing panel owns the scroll area. */
|
|
24
|
+
scrollable?: boolean;
|
|
23
25
|
className?: string;
|
|
24
26
|
};
|
|
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;
|
|
27
|
+
export declare function TableOfContents({ items, contentRef, variant, hoverMode, railLayout, popoverSide, previewCount, depthBasedLength, label, activeId, onActiveChange, maxLevel, scrollOffset, scrollable, className, }: TableOfContentsProps): import("react").JSX.Element | null;
|
|
@@ -31,6 +31,7 @@ function TableOfContents({
|
|
|
31
31
|
onActiveChange,
|
|
32
32
|
maxLevel = 4,
|
|
33
33
|
scrollOffset = 24,
|
|
34
|
+
scrollable = true,
|
|
34
35
|
className = ""
|
|
35
36
|
}) {
|
|
36
37
|
const id = useId();
|
|
@@ -276,7 +277,7 @@ function TableOfContents({
|
|
|
276
277
|
/* @__PURE__ */ jsx(ListFilter, { size: 16, "aria-hidden": "true" }),
|
|
277
278
|
label
|
|
278
279
|
] }),
|
|
279
|
-
/* @__PURE__ */ jsx("div", { className: s.scroll
|
|
280
|
+
/* @__PURE__ */ jsx("div", { className: `${s.scroll} ${scrollable ? "" : s.unconstrained}`, children: /* @__PURE__ */ jsx("div", { ref: list, className: s.flatList, children: previewEntries.map((entry) => /* @__PURE__ */ jsx(
|
|
280
281
|
"a",
|
|
281
282
|
{
|
|
282
283
|
className: s.flatLink,
|
|
@@ -305,7 +306,7 @@ function TableOfContents({
|
|
|
305
306
|
/* @__PURE__ */ jsx(ListFilter, { size: 16, "aria-hidden": "true" }),
|
|
306
307
|
label
|
|
307
308
|
] }),
|
|
308
|
-
/* @__PURE__ */ jsx("div", { className: s.scroll
|
|
309
|
+
/* @__PURE__ */ jsx("div", { className: `${s.scroll} ${scrollable ? "" : s.unconstrained}`, children: /* @__PURE__ */ jsxs("div", { className: s.list, ref: list, children: [
|
|
309
310
|
/* @__PURE__ */ jsx(
|
|
310
311
|
"svg",
|
|
311
312
|
{
|