seam-react 0.9.2 → 0.10.0
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/README.md +10 -2
- package/dist/Toast.d.ts +68 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +40584 -1567
- package/dist/index.js.map +1 -1
- package/dist/styles.cjs +226 -2
- package/dist/styles.cjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.js +224 -0
- package/dist/styles.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -15,7 +15,14 @@ npm install seam-react
|
|
|
15
15
|
## 使用
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
Button,
|
|
20
|
+
Tabs,
|
|
21
|
+
Dialog,
|
|
22
|
+
Sidebar,
|
|
23
|
+
ToastStack,
|
|
24
|
+
useToast,
|
|
25
|
+
} from "seam-react";
|
|
19
26
|
import { SeamStyles } from "seam-react/styles";
|
|
20
27
|
|
|
21
28
|
export function Root() {
|
|
@@ -28,11 +35,12 @@ export function Root() {
|
|
|
28
35
|
}
|
|
29
36
|
```
|
|
30
37
|
|
|
31
|
-
组件包含:Button、Input、Switch、Tabs、Dialog、Tooltip、Sidebar。
|
|
38
|
+
组件包含:Button、Input、Switch、Tabs、Dialog、Toast、Tooltip、Sidebar。
|
|
32
39
|
|
|
33
40
|
- Tabs 支持方向键切换、ARIA 关联与 fluid 指示器。
|
|
34
41
|
- Switch 支持点击、键盘和拖拽 spring。
|
|
35
42
|
- Dialog 提供 Root / Trigger / Content 与语义化内容层,自带 Motion 进出场、焦点陷阱、Esc 关闭与滚动锁定。
|
|
43
|
+
- Toast 提供 `useToast` 状态队列与 `ToastStack` 呈现层,支持六向定位、自动关闭、状态图标、操作和拖拽关闭。
|
|
36
44
|
- Tooltip 提供延迟显示、键盘与触屏访问、视口翻转/避让,以及可让相邻触发器共享并连续移动表面的 Group / Item 组合。
|
|
37
45
|
- Sidebar 提供可折叠 Group、可配置分组间距,以及互斥的轨道与背景 hover 模式。
|
|
38
46
|
|
package/dist/Toast.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type HTMLMotionProps } from "motion/react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export type ToastStatus = "neutral" | "info" | "loading" | "success" | "error";
|
|
4
|
+
export type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
5
|
+
export type ToastAction = {
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
onClick: (toast: Toast) => void;
|
|
8
|
+
};
|
|
9
|
+
export type Toast = {
|
|
10
|
+
id: string;
|
|
11
|
+
title: ReactNode;
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
status?: ToastStatus;
|
|
14
|
+
action?: ToastAction;
|
|
15
|
+
duration?: number;
|
|
16
|
+
dismissible?: boolean;
|
|
17
|
+
createdAt?: number;
|
|
18
|
+
};
|
|
19
|
+
export type ToastInput = Omit<Toast, "id" | "createdAt"> & {
|
|
20
|
+
id?: string;
|
|
21
|
+
};
|
|
22
|
+
export type UseToastOptions = {
|
|
23
|
+
initialToasts?: ToastInput[];
|
|
24
|
+
defaultDuration?: number;
|
|
25
|
+
limit?: number;
|
|
26
|
+
};
|
|
27
|
+
export type ToastPlacement = "static" | "absolute" | "fixed";
|
|
28
|
+
export type ToastClassNames = {
|
|
29
|
+
root?: string;
|
|
30
|
+
item?: string;
|
|
31
|
+
surface?: string;
|
|
32
|
+
iconWrap?: string;
|
|
33
|
+
content?: string;
|
|
34
|
+
title?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
action?: string;
|
|
37
|
+
close?: string;
|
|
38
|
+
};
|
|
39
|
+
export type ToastIcons = Partial<Record<ToastStatus, ReactNode>>;
|
|
40
|
+
export type ToastStackProps = Omit<HTMLMotionProps<"ol">, "children"> & {
|
|
41
|
+
toasts: Toast[];
|
|
42
|
+
onDismiss?: (id: string) => void;
|
|
43
|
+
onPauseToast?: (id: string) => void;
|
|
44
|
+
onResumeToast?: (id: string) => void;
|
|
45
|
+
position?: ToastPosition;
|
|
46
|
+
placement?: ToastPlacement;
|
|
47
|
+
portal?: boolean;
|
|
48
|
+
portalRoot?: Element | null;
|
|
49
|
+
maxVisible?: number;
|
|
50
|
+
className?: string;
|
|
51
|
+
classNames?: ToastClassNames;
|
|
52
|
+
icons?: ToastIcons;
|
|
53
|
+
renderToast?: (toast: Toast) => ReactNode;
|
|
54
|
+
};
|
|
55
|
+
type ManagedToast = Toast & {
|
|
56
|
+
pausedAt?: number;
|
|
57
|
+
};
|
|
58
|
+
export declare function useToast({ initialToasts, defaultDuration, limit, }?: UseToastOptions): {
|
|
59
|
+
toasts: ManagedToast[];
|
|
60
|
+
showToast: (input: ToastInput) => string;
|
|
61
|
+
updateToast: (id: string, patch: Partial<ToastInput>) => void;
|
|
62
|
+
dismissToast: (id: string) => void;
|
|
63
|
+
clearToasts: () => void;
|
|
64
|
+
pauseToast: (id: string) => void;
|
|
65
|
+
resumeToast: (id: string) => void;
|
|
66
|
+
};
|
|
67
|
+
export declare function ToastStack({ toasts, onDismiss, onPauseToast, onResumeToast, position, placement, portal, portalRoot, maxVisible, className, classNames, icons, renderToast, ...listProps }: ToastStackProps): import("react").JSX.Element | null;
|
|
68
|
+
export {};
|