seam-react 0.12.3 → 0.13.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 +2 -1
- package/dist/FormComponent.d.ts +12 -6
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3522 -3485
- package/dist/index.js.map +1 -1
- package/dist/styles.cjs +113 -4
- package/dist/styles.cjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.js +114 -5
- package/dist/styles.js.map +1 -1
- package/dist/valibot.cjs +2 -0
- package/dist/valibot.cjs.map +1 -0
- package/dist/valibot.d.ts +13 -0
- package/dist/valibot.js +19 -0
- package/dist/valibot.js.map +1 -0
- package/package.json +14 -2
package/README.md
CHANGED
|
@@ -35,13 +35,14 @@ export function Root() {
|
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
组件包含:Button、Input、Switch、Tabs、Dialog、Toast、Tooltip、Sidebar。
|
|
38
|
+
组件包含:Button、Input、Form、Switch、Tabs、Dialog、Toast、Tooltip、Sidebar。
|
|
39
39
|
|
|
40
40
|
- Tabs 支持方向键切换、ARIA 关联与 fluid 指示器。
|
|
41
41
|
- Switch 支持点击、键盘和拖拽 spring。
|
|
42
42
|
- Dialog 提供 Root / Trigger / Content 与语义化内容层,自带 Motion 进出场、焦点陷阱、Esc 关闭与滚动锁定。
|
|
43
43
|
- Toast 提供 `useToast` 状态队列与 `ToastStack` 呈现层,支持六向定位、自动关闭、状态图标、操作和拖拽关闭。
|
|
44
44
|
- Tooltip 提供延迟显示、键盘与触屏访问、视口翻转/避让,以及可让相邻触发器共享并连续移动表面的 Group / Item 组合。
|
|
45
|
+
- Form 提供组合式字段、同步/异步规则、服务端错误和失败聚焦;安装 `valibot` 后可通过 `seam-react/valibot` 接入 schema 校验。
|
|
45
46
|
- Sidebar 提供可折叠 Group、可配置分组间距,以及互斥的轨道与背景 hover 模式。
|
|
46
47
|
|
|
47
48
|
完整文档:[chenhaojie9527.github.io/ui-kit](https://chenhaojie9527.github.io/ui-kit/)
|
package/dist/FormComponent.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type FormHTMLAttributes, type HTMLAttributes, type LabelHTMLAttributes, type ReactElement, type ReactNode } from "react";
|
|
1
|
+
import { type FormHTMLAttributes, type HTMLAttributes, type LabelHTMLAttributes, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
2
|
export type FormErrors<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
3
3
|
[K in keyof T]?: string;
|
|
4
4
|
} & Record<string, string | undefined>;
|
|
5
|
+
export type FormValidationTrigger = "submit" | "focus" | "change" | "blur" | "pointerleave";
|
|
5
6
|
export type FieldRule<T = unknown> = {
|
|
6
7
|
required: boolean;
|
|
7
8
|
message?: string;
|
|
@@ -79,6 +80,7 @@ export interface FormContextValue<T = Record<string, unknown>> {
|
|
|
79
80
|
}) => void;
|
|
80
81
|
setFieldTouched: (name: string, touched: boolean) => void;
|
|
81
82
|
setFieldFocused: (name: string, focused: boolean) => void;
|
|
83
|
+
handleFieldInteraction: (name: string, trigger: Exclude<FormValidationTrigger, "submit">) => void;
|
|
82
84
|
registerField: (name: string, config: FieldConfig) => void;
|
|
83
85
|
unregisterField: (name: string) => void;
|
|
84
86
|
validateField: (name: string) => Promise<boolean>;
|
|
@@ -90,8 +92,8 @@ export interface FormContextValue<T = Record<string, unknown>> {
|
|
|
90
92
|
setFormError: (error: string | null) => void;
|
|
91
93
|
clearErrors: (fields?: string[]) => void;
|
|
92
94
|
focusFirstError: () => void;
|
|
93
|
-
validateOn:
|
|
94
|
-
revalidateOn:
|
|
95
|
+
validateOn: FormValidationTrigger;
|
|
96
|
+
revalidateOn: Exclude<FormValidationTrigger, "submit">;
|
|
95
97
|
validateDebounce: number;
|
|
96
98
|
}
|
|
97
99
|
interface FieldConfig {
|
|
@@ -110,11 +112,12 @@ export interface FormRootProps<T extends Record<string, unknown> = Record<string
|
|
|
110
112
|
onValuesChange?: (values: T, changedField?: keyof T) => void;
|
|
111
113
|
onSubmit?: (values: T) => void | Promise<void>;
|
|
112
114
|
onSubmitFailed?: (errors: FormErrors<T>) => void;
|
|
113
|
-
validateOn?:
|
|
114
|
-
revalidateOn?:
|
|
115
|
+
validateOn?: FormValidationTrigger;
|
|
116
|
+
revalidateOn?: Exclude<FormValidationTrigger, "submit">;
|
|
115
117
|
validateDebounce?: number;
|
|
116
118
|
noValidate?: boolean;
|
|
117
119
|
validate?: (values: T) => FormErrors<T> | Promise<FormErrors<T>>;
|
|
120
|
+
layout?: "vertical" | "inline" | "horizontal";
|
|
118
121
|
children: ReactNode;
|
|
119
122
|
}
|
|
120
123
|
export interface FormFieldProps<T = unknown> {
|
|
@@ -132,6 +135,7 @@ export interface FormFieldProps<T = unknown> {
|
|
|
132
135
|
}
|
|
133
136
|
export interface FormLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
134
137
|
required?: boolean;
|
|
138
|
+
labelWrap?: boolean;
|
|
135
139
|
children: ReactNode;
|
|
136
140
|
}
|
|
137
141
|
export interface FormControlProps {
|
|
@@ -149,7 +153,9 @@ export interface FormActionsProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
149
153
|
export declare function useFormContext<T = Record<string, unknown>>(): FormContextValue<T>;
|
|
150
154
|
export declare function useFieldState(name: string): FieldState;
|
|
151
155
|
export declare function useWatch<T = unknown>(name: string | string[]): T;
|
|
152
|
-
declare const FormRoot:
|
|
156
|
+
declare const FormRoot: <T extends Record<string, unknown> = Record<string, unknown>>(props: FormRootProps<T> & {
|
|
157
|
+
ref?: Ref<FormRef>;
|
|
158
|
+
}) => ReactElement | null;
|
|
153
159
|
declare function FormField({ name, defaultValue, rules, transform, disabled, readOnly, hidden, preserveOnUnmount, dependencies, children, className, }: FormFieldProps): ReactElement | null;
|
|
154
160
|
declare const FormLabel: import("react").ForwardRefExoticComponent<FormLabelProps & import("react").RefAttributes<HTMLLabelElement>>;
|
|
155
161
|
declare function FormControl({ children }: FormControlProps): ReactElement;
|