@tempots/beatui 0.12.0 → 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/dist/beatui.css +1 -1
- package/dist/{de-O2DMrfiH.js → de-C_Zm61s8.js} +0 -1
- package/dist/{es-CsNVN5AY.js → es-Br-Gawkv.js} +0 -1
- package/dist/{fr-CJjx2YoL.js → fr-TsXahdgA.js} +0 -1
- package/dist/index.es.js +3990 -3755
- package/dist/index.umd.js +12 -12
- package/dist/{it-BKzoVost.js → it-CkmN7du_.js} +0 -1
- package/dist/{ja-ZBFmK5Uj.js → ja-C81oj42G.js} +0 -1
- package/dist/{pt-DumIX3mi.js → pt-DtslyWAl.js} +0 -1
- package/dist/{ru-_EKfu_bO.js → ru-BIqAHQQ4.js} +0 -1
- package/dist/types/auth-i18n/default.d.ts +0 -1
- package/dist/types/auth-i18n/locales/de.d.ts +0 -1
- package/dist/types/auth-i18n/locales/en.d.ts +0 -1
- package/dist/types/auth-i18n/locales/es.d.ts +0 -1
- package/dist/types/auth-i18n/locales/fr.d.ts +0 -1
- package/dist/types/auth-i18n/locales/it.d.ts +0 -1
- package/dist/types/auth-i18n/locales/ja.d.ts +0 -1
- package/dist/types/auth-i18n/locales/pt.d.ts +0 -1
- package/dist/types/auth-i18n/locales/ru.d.ts +0 -1
- package/dist/types/auth-i18n/locales/zh.d.ts +0 -1
- package/dist/types/auth-i18n/translations.d.ts +0 -1
- package/dist/types/components/auth/auth-container.d.ts +1 -4
- package/dist/types/components/auth/auth-email-prop.d.ts +1 -0
- package/dist/types/components/auth/reset-password-form.d.ts +1 -1
- package/dist/types/components/auth/schemas.d.ts +20 -10
- package/dist/types/components/auth/signin-form.d.ts +1 -1
- package/dist/types/components/auth/signup-form.d.ts +1 -1
- package/dist/types/components/auth/social-login-button.d.ts +2 -4
- package/dist/types/components/auth/social-providers.d.ts +2 -0
- package/dist/types/components/auth/types.d.ts +75 -93
- package/dist/types/components/auth/utils.d.ts +6 -4
- package/dist/types/components/form/controller/controller-validation.d.ts +8 -0
- package/dist/types/components/form/controller/controller.d.ts +22 -20
- package/dist/types/components/form/controller/index.d.ts +1 -1
- package/dist/types/components/form/schema/schema-utils.d.ts +2 -2
- package/dist/types/components/form/use-form.d.ts +44 -11
- package/dist/{zh-DEZH0fdq.js → zh-Cy7W0TAv.js} +0 -1
- package/package.json +1 -1
- package/dist/types/components/form/controller/validation-result.d.ts +0 -13
|
@@ -22,7 +22,6 @@ export declare const AuthI18n: import("@tempots/dom").Provider<import("..").Reac
|
|
|
22
22
|
passwordStrengthGood: () => string;
|
|
23
23
|
passwordStrengthStrong: () => string;
|
|
24
24
|
orDivider: () => string;
|
|
25
|
-
loading: () => string;
|
|
26
25
|
error: () => string;
|
|
27
26
|
required: () => string;
|
|
28
27
|
}>, object>;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { TNode, Value } from '@tempots/dom';
|
|
2
2
|
import { AuthContainerOptions } from './index';
|
|
3
|
-
export declare function AuthContainer({ mode: initialMode, className, socialProviders, passwordRules, showRememberMe, showSocialDivider,
|
|
3
|
+
export declare function AuthContainer({ mode: initialMode, className, socialProviders, passwordRules, showRememberMe, showSocialDivider, showPasswordStrength, labels, onSignIn, onSignUp, onResetPassword, onModeChange, }: AuthContainerOptions): TNode;
|
|
4
4
|
export declare function AuthModal({ isOpen, onClose, ...authOptions }: AuthContainerOptions & {
|
|
5
5
|
isOpen: Value<boolean>;
|
|
6
6
|
onClose?: () => void;
|
|
7
7
|
}): TNode;
|
|
8
|
-
export declare function SignInContainer(options: Omit<AuthContainerOptions, 'initialMode'>): TNode;
|
|
9
|
-
export declare function SignUpContainer(options: Omit<AuthContainerOptions, 'initialMode'>): TNode;
|
|
10
|
-
export declare function ResetPasswordContainer(options: Omit<AuthContainerOptions, 'initialMode'>): TNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAuthEmailProp: () => import("@tempots/dom").Prop<string | null>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TNode } from '@tempots/dom';
|
|
2
2
|
import { ResetPasswordFormOptions } from './index';
|
|
3
|
-
export declare function ResetPasswordForm({
|
|
3
|
+
export declare function ResetPasswordForm({ onResetPassword, labels, }: ResetPasswordFormOptions): TNode;
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import { StringValidator } from '../form/schema/custom-validation';
|
|
1
|
+
import { StringValidator, SafeParseResult } from '../form/schema/custom-validation';
|
|
2
2
|
import { StandardSchemaV1 } from '../form/schema/standard-schema-v1';
|
|
3
|
-
import { PasswordRules,
|
|
3
|
+
import { PasswordRules, ResetPasswordData, SignInFormData, SignUpFormData } from './types';
|
|
4
4
|
export declare function createPasswordSchema(rules?: PasswordRules): StringValidator;
|
|
5
5
|
export declare const emailSchema: StringValidator;
|
|
6
|
-
export declare function createSignInSchema(passwordRules?: PasswordRules): StandardSchemaV1<
|
|
6
|
+
export declare function createSignInSchema(passwordRules?: PasswordRules): StandardSchemaV1<SignInFormData> & {
|
|
7
|
+
safeParse: (value: unknown) => SafeParseResult<SignInFormData>;
|
|
8
|
+
};
|
|
7
9
|
export declare function createSignUpSchema(passwordRules?: PasswordRules, options?: {
|
|
8
10
|
showNameField?: boolean;
|
|
9
11
|
showConfirmPassword?: boolean;
|
|
10
12
|
showAcceptTermsAndConditions?: boolean;
|
|
11
|
-
}): StandardSchemaV1<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare const
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
}): StandardSchemaV1<SignUpFormData> & {
|
|
14
|
+
safeParse: (value: unknown) => SafeParseResult<SignUpFormData>;
|
|
15
|
+
};
|
|
16
|
+
export declare const resetPasswordSchema: StandardSchemaV1<ResetPasswordData> & {
|
|
17
|
+
safeParse: (value: unknown) => SafeParseResult<ResetPasswordData>;
|
|
18
|
+
};
|
|
19
|
+
export declare const defaultSignInSchema: StandardSchemaV1<import("./types").SignInData, import("./types").SignInData> & {
|
|
20
|
+
safeParse: (value: unknown) => SafeParseResult<SignInFormData>;
|
|
21
|
+
};
|
|
22
|
+
export declare const defaultSignUpSchema: StandardSchemaV1<SignUpFormData, SignUpFormData> & {
|
|
23
|
+
safeParse: (value: unknown) => SafeParseResult<SignUpFormData>;
|
|
24
|
+
};
|
|
17
25
|
export type ResetPasswordFormData = ResetPasswordData;
|
|
18
26
|
export declare const authSchemas: {
|
|
19
27
|
signIn: typeof createSignInSchema;
|
|
20
28
|
signUp: typeof createSignUpSchema;
|
|
21
|
-
resetPassword: () => StandardSchemaV1<ResetPasswordData, ResetPasswordData
|
|
29
|
+
resetPassword: () => StandardSchemaV1<ResetPasswordData, ResetPasswordData> & {
|
|
30
|
+
safeParse: (value: unknown) => SafeParseResult<ResetPasswordData>;
|
|
31
|
+
};
|
|
22
32
|
};
|
|
23
33
|
export declare function validateEmail(email: string): string | null;
|
|
24
34
|
export declare function validatePassword(password: string, rules?: PasswordRules): string | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TNode } from '@tempots/dom';
|
|
2
2
|
import { SignInFormOptions } from './index';
|
|
3
|
-
export declare function SignInForm({
|
|
3
|
+
export declare function SignInForm({ onSignIn, passwordRules, labels, showRememberMe, }: SignInFormOptions): TNode;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TNode } from '@tempots/dom';
|
|
2
2
|
import { SignUpFormOptions } from './index';
|
|
3
|
-
export declare function SignUpForm({
|
|
3
|
+
export declare function SignUpForm({ passwordRules, labels, showPasswordStrength, onSignUp, showNameField, showConfirmPassword, showAcceptTermsAndConditions, termsAndConditions, }: SignUpFormOptions): TNode;
|
|
@@ -2,16 +2,14 @@ import { TNode, Value } from '@tempots/dom';
|
|
|
2
2
|
import { SocialLoginButtonOptions, AuthProviderName } from './index';
|
|
3
3
|
import { ControlSize } from '../theme';
|
|
4
4
|
import { ThemeColorName } from '@/tokens';
|
|
5
|
-
export declare function SocialLoginButton({ provider, onClick,
|
|
5
|
+
export declare function SocialLoginButton({ provider, onClick, size, name, icon, color, flow, labels, }: SocialLoginButtonOptions): TNode;
|
|
6
6
|
export type AuthProviderInfo = {
|
|
7
7
|
provider: AuthProviderName;
|
|
8
8
|
flow?: 'redirect' | 'popup';
|
|
9
9
|
};
|
|
10
|
-
export declare function SocialLoginButtons({ providers, onProviderClick,
|
|
10
|
+
export declare function SocialLoginButtons({ providers, onProviderClick, size, className, }: {
|
|
11
11
|
providers: Value<Array<AuthProviderInfo>>;
|
|
12
12
|
onProviderClick?: (provider: AuthProviderName) => Promise<void>;
|
|
13
|
-
loading?: Value<boolean>;
|
|
14
|
-
disabled?: Value<boolean>;
|
|
15
13
|
size?: Value<ControlSize>;
|
|
16
14
|
className?: Value<string>;
|
|
17
15
|
}): TNode;
|
|
@@ -9,12 +9,14 @@ export type PasswordStrength = 'weak' | 'fair' | 'good' | 'strong';
|
|
|
9
9
|
export interface SignInData {
|
|
10
10
|
email: string;
|
|
11
11
|
password: string;
|
|
12
|
-
rememberMe?: boolean;
|
|
13
12
|
}
|
|
13
|
+
export type SignInFormData = SignInData;
|
|
14
14
|
export interface SignUpData {
|
|
15
15
|
name?: string;
|
|
16
16
|
email: string;
|
|
17
17
|
password: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SignUpFormData extends SignUpData {
|
|
18
20
|
confirmPassword: string;
|
|
19
21
|
acceptTerms: boolean;
|
|
20
22
|
}
|
|
@@ -38,116 +40,96 @@ export interface PasswordRules {
|
|
|
38
40
|
requireSymbols?: boolean;
|
|
39
41
|
customValidation?: (password: string) => string | null;
|
|
40
42
|
}
|
|
43
|
+
export interface AuthContainerLabels {
|
|
44
|
+
signInTitle?: () => string;
|
|
45
|
+
emailLabel?: () => string;
|
|
46
|
+
passwordLabel?: () => string;
|
|
47
|
+
rememberMeLabel?: () => string;
|
|
48
|
+
signInButton?: () => string;
|
|
49
|
+
forgotPasswordLink?: () => string;
|
|
50
|
+
noAccountLink?: () => string;
|
|
51
|
+
acceptTermsLabel?: () => string;
|
|
52
|
+
confirmPasswordLabel?: () => string;
|
|
53
|
+
signUpTitle?: () => string;
|
|
54
|
+
signUpButton?: () => string;
|
|
55
|
+
nameLabel?: () => string;
|
|
56
|
+
hasAccountLink?: () => string;
|
|
57
|
+
resetPasswordTitle?: () => string;
|
|
58
|
+
resetPasswordButton?: () => string;
|
|
59
|
+
resetPasswordDescription?: () => string;
|
|
60
|
+
backToSignInLink?: () => string;
|
|
61
|
+
}
|
|
41
62
|
export interface AuthContainerOptions {
|
|
42
63
|
mode?: Value<AuthMode>;
|
|
43
64
|
className?: Value<string>;
|
|
44
|
-
socialProviders?:
|
|
65
|
+
socialProviders?: AuthProviderInfo[];
|
|
45
66
|
passwordRules?: PasswordRules;
|
|
46
|
-
showRememberMe?:
|
|
47
|
-
showSocialDivider?:
|
|
48
|
-
allowSignUp?:
|
|
49
|
-
allowPasswordReset?:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
passwordLabel?: () => string;
|
|
55
|
-
rememberMeLabel?: () => string;
|
|
56
|
-
loading?: () => string;
|
|
57
|
-
signInButton?: () => string;
|
|
58
|
-
forgotPasswordLink?: () => string;
|
|
59
|
-
noAccountLink?: () => string;
|
|
60
|
-
acceptTermsLabel?: () => string;
|
|
61
|
-
confirmPasswordLabel?: () => string;
|
|
62
|
-
signUpTitle?: () => string;
|
|
63
|
-
signUpButton?: () => string;
|
|
64
|
-
nameLabel?: () => string;
|
|
65
|
-
hasAccountLink?: () => string;
|
|
66
|
-
resetPasswordTitle?: () => string;
|
|
67
|
-
resetPasswordButton?: () => string;
|
|
68
|
-
resetPasswordDescription?: () => string;
|
|
69
|
-
backToSignInLink?: () => string;
|
|
70
|
-
};
|
|
71
|
-
onSignIn?: (data: SignInData) => Promise<void>;
|
|
72
|
-
onSignUp?: (data: SignUpData) => Promise<void>;
|
|
73
|
-
onResetPassword?: (data: ResetPasswordData) => Promise<void>;
|
|
67
|
+
showRememberMe?: boolean;
|
|
68
|
+
showSocialDivider?: boolean;
|
|
69
|
+
allowSignUp?: boolean;
|
|
70
|
+
allowPasswordReset?: boolean;
|
|
71
|
+
labels?: AuthContainerLabels;
|
|
72
|
+
onSignIn?: (data: SignInData) => Promise<string | null>;
|
|
73
|
+
onSignUp?: (data: SignUpData) => Promise<string | null>;
|
|
74
|
+
onResetPassword?: (data: ResetPasswordData) => Promise<string | null>;
|
|
74
75
|
onModeChange?: (mode: AuthMode) => void;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
showPasswordStrength?: boolean;
|
|
77
|
+
showAlreadyHaveAccountLink?: boolean;
|
|
78
|
+
showNameField?: boolean;
|
|
79
|
+
showConfirmPassword?: boolean;
|
|
80
|
+
showAcceptTermsAndConditions?: boolean;
|
|
81
|
+
termsAndConditions?: TNode;
|
|
82
|
+
}
|
|
83
|
+
export interface SocialProvidersOptions {
|
|
84
|
+
providers: AuthProviderInfo[];
|
|
85
|
+
}
|
|
86
|
+
export interface SignInFormLabels {
|
|
87
|
+
emailLabel?: () => string;
|
|
88
|
+
passwordLabel?: () => string;
|
|
89
|
+
rememberMeLabel?: () => string;
|
|
90
|
+
signInButton?: () => string;
|
|
91
|
+
forgotPasswordLink?: () => string;
|
|
92
|
+
noAccountLink?: () => string;
|
|
79
93
|
}
|
|
80
94
|
export interface SignInFormOptions {
|
|
81
|
-
|
|
82
|
-
onModeChange?: (mode: AuthMode) => void;
|
|
83
|
-
onSignIn?: (data: SignInData) => Promise<void>;
|
|
84
|
-
onSocialLogin?: (provider: AuthProviderName) => Promise<void>;
|
|
85
|
-
loading?: Value<boolean>;
|
|
86
|
-
error?: Value<string | null>;
|
|
95
|
+
onSignIn?: (data: SignInData) => Promise<string | null>;
|
|
87
96
|
passwordRules?: PasswordRules;
|
|
88
|
-
labels?:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
showSocialDivider?: Value<boolean>;
|
|
100
|
-
showRememberMe?: Value<boolean>;
|
|
101
|
-
allowPasswordReset?: Value<boolean>;
|
|
102
|
-
allowSignUp?: Value<boolean>;
|
|
97
|
+
labels?: SignInFormLabels;
|
|
98
|
+
showRememberMe?: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface SignUpFormLabels {
|
|
101
|
+
nameLabel?: () => string;
|
|
102
|
+
emailLabel?: () => string;
|
|
103
|
+
passwordLabel?: () => string;
|
|
104
|
+
confirmPasswordLabel?: () => string;
|
|
105
|
+
acceptTermsLabel?: () => string;
|
|
106
|
+
signUpButton?: () => string;
|
|
107
|
+
hasAccountLink?: () => string;
|
|
103
108
|
}
|
|
104
109
|
export interface SignUpFormOptions {
|
|
105
|
-
onSubmit?: (data: SignUpData) => Promise<void>;
|
|
106
|
-
onModeChange?: (mode: AuthMode) => void;
|
|
107
|
-
loading?: Value<boolean>;
|
|
108
|
-
error?: Value<string | null>;
|
|
109
110
|
passwordRules?: PasswordRules;
|
|
110
|
-
labels?:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
loading?: () => string;
|
|
118
|
-
signUpButton?: () => string;
|
|
119
|
-
hasAccountLink?: () => string;
|
|
120
|
-
};
|
|
121
|
-
socialProviders?: Value<AuthProviderInfo[]>;
|
|
122
|
-
showSocialDivider?: Value<boolean>;
|
|
123
|
-
showPasswordStrength?: Value<boolean>;
|
|
124
|
-
onSignUp?: (data: SignUpData) => Promise<void>;
|
|
125
|
-
onSocialLogin?: (provider: AuthProviderName) => Promise<void>;
|
|
126
|
-
showAlreadyHaveAccountLink?: Value<boolean>;
|
|
127
|
-
showNameField?: Value<boolean>;
|
|
128
|
-
showConfirmPassword?: Value<boolean>;
|
|
129
|
-
showAcceptTermsAndConditions?: Value<boolean>;
|
|
111
|
+
labels?: SignUpFormLabels;
|
|
112
|
+
onSignUp?: (data: SignUpData) => Promise<string | null>;
|
|
113
|
+
showPasswordStrength?: boolean;
|
|
114
|
+
showAlreadyHaveAccountLink?: boolean;
|
|
115
|
+
showNameField?: boolean;
|
|
116
|
+
showConfirmPassword?: boolean;
|
|
117
|
+
showAcceptTermsAndConditions?: boolean;
|
|
130
118
|
termsAndConditions?: TNode;
|
|
131
119
|
}
|
|
120
|
+
export interface ResetPasswordFormLabels {
|
|
121
|
+
resetPasswordButton?: () => string;
|
|
122
|
+
resetPasswordDescription?: () => string;
|
|
123
|
+
emailLabel?: () => string;
|
|
124
|
+
backToSignInLink?: () => string;
|
|
125
|
+
}
|
|
132
126
|
export interface ResetPasswordFormOptions {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
onResetPassword?: (data: ResetPasswordData) => Promise<void>;
|
|
136
|
-
loading?: Value<boolean>;
|
|
137
|
-
error?: Value<string | null>;
|
|
138
|
-
labels?: {
|
|
139
|
-
resetPasswordTitle?: () => string;
|
|
140
|
-
resetPasswordButton?: () => string;
|
|
141
|
-
resetPasswordDescription?: () => string;
|
|
142
|
-
emailLabel?: () => string;
|
|
143
|
-
loading?: () => string;
|
|
144
|
-
backToSignInLink?: () => string;
|
|
145
|
-
};
|
|
127
|
+
onResetPassword?: (data: ResetPasswordData) => Promise<string | null>;
|
|
128
|
+
labels?: ResetPasswordFormLabels;
|
|
146
129
|
}
|
|
147
130
|
export interface SocialLoginButtonOptions {
|
|
148
131
|
provider: Value<AuthProviderName>;
|
|
149
132
|
onClick?: () => Promise<void>;
|
|
150
|
-
loading?: Value<boolean>;
|
|
151
133
|
disabled?: Value<boolean>;
|
|
152
134
|
size?: Value<ControlSize>;
|
|
153
135
|
flow?: Value<'redirect' | 'popup' | undefined>;
|
|
@@ -16,8 +16,10 @@ export declare function createSocialLoginUrl(provider: AuthProviderName, clientI
|
|
|
16
16
|
export declare function openSocialLoginPopup<T>(url: string, provider: AuthProviderName, onSuccess?: (result: T) => void, onError?: (error: Error) => void): void;
|
|
17
17
|
export declare function formatAuthError(error: unknown): string;
|
|
18
18
|
export declare function isBrowser(): boolean;
|
|
19
|
-
export declare const REMEMBER_EMAIL_KEY = "bui_auth_remember_email";
|
|
20
|
-
export declare function saveRememberMe(email: string): void;
|
|
21
|
-
export declare function getRememberedEmail(): string | null;
|
|
22
|
-
export declare function clearRememberedEmail(): void;
|
|
23
19
|
export declare function functionOrReactiveMessage<T extends Value<unknown>[]>(fn: undefined | ((...args: GetValueTypes<T>) => string), reactiveFn: (...args: T) => Signal<string>, ...args: T): Signal<string>;
|
|
20
|
+
export declare function requestToControllerValidation<T>({ task, message, onStart, onEnd, }: {
|
|
21
|
+
task: undefined | ((value: T) => Promise<string | null>);
|
|
22
|
+
message: string;
|
|
23
|
+
onStart?: () => void;
|
|
24
|
+
onEnd?: () => void;
|
|
25
|
+
}): (value: T) => Promise<import("../form").ControllerValidation>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Validation } from '@tempots/std';
|
|
2
|
+
import { PathSegment } from './path';
|
|
3
|
+
export type ControllerError = {
|
|
4
|
+
message?: string;
|
|
5
|
+
dependencies?: Record<PathSegment, ControllerError>;
|
|
6
|
+
};
|
|
7
|
+
export type ControllerValidation = Validation<ControllerError>;
|
|
8
|
+
export declare function makeMapValidation(fields: PathSegment[]): (status: ControllerValidation) => ControllerValidation;
|
|
@@ -1,49 +1,51 @@
|
|
|
1
1
|
import { Signal } from '@tempots/dom';
|
|
2
2
|
import { Path, PathSegment } from './path';
|
|
3
|
-
import {
|
|
4
|
-
export declare class Controller<
|
|
3
|
+
import { ControllerError, ControllerValidation } from './controller-validation';
|
|
4
|
+
export declare class Controller<T> {
|
|
5
5
|
#private;
|
|
6
6
|
readonly path: Path;
|
|
7
|
-
readonly change: (value:
|
|
8
|
-
readonly value: Signal<
|
|
9
|
-
readonly status: Signal<
|
|
7
|
+
readonly change: (value: T) => void;
|
|
8
|
+
readonly value: Signal<T>;
|
|
9
|
+
readonly status: Signal<ControllerValidation>;
|
|
10
10
|
readonly error: Signal<undefined | string>;
|
|
11
11
|
readonly hasError: Signal<boolean>;
|
|
12
|
-
readonly dependencyErrors: Signal<undefined | Record<string | number,
|
|
12
|
+
readonly dependencyErrors: Signal<undefined | Record<string | number, ControllerError>>;
|
|
13
13
|
protected readonly parent: {
|
|
14
14
|
disabled: Signal<boolean>;
|
|
15
15
|
};
|
|
16
16
|
readonly disabled: Signal<boolean>;
|
|
17
|
-
|
|
17
|
+
readonly disabledOrHasErrors: Signal<boolean>;
|
|
18
|
+
constructor(path: Path, change: (value: T) => void, value: Signal<T>, status: Signal<ControllerValidation>, parent: {
|
|
18
19
|
disabled: Signal<boolean>;
|
|
19
20
|
});
|
|
20
21
|
get name(): string;
|
|
21
22
|
readonly onDispose: (callback: () => void) => void;
|
|
22
23
|
readonly dispose: () => void;
|
|
24
|
+
readonly setDisabled: (disabled: boolean) => void;
|
|
23
25
|
readonly disable: () => void;
|
|
24
26
|
readonly enable: () => void;
|
|
25
|
-
readonly array: (equals?: (a:
|
|
26
|
-
readonly object: (equals?: (a:
|
|
27
|
-
readonly transform: <Out>(transform: (value:
|
|
27
|
+
readonly array: (equals?: (a: T, b: T) => boolean) => ArrayController<T extends any[] ? T : never>;
|
|
28
|
+
readonly object: (equals?: (a: T, b: T) => boolean) => ObjectController<T extends Record<string, any> ? T : never>;
|
|
29
|
+
readonly transform: <Out>(transform: (value: T) => Out, untransform: (value: Out) => T, subpath?: PathSegment[], equals?: (a: Out, b: Out) => boolean) => Controller<Out>;
|
|
28
30
|
}
|
|
29
|
-
export declare class ObjectController<
|
|
31
|
+
export declare class ObjectController<T extends Record<keyof T, T[keyof T]>> extends Controller<T> {
|
|
30
32
|
#private;
|
|
31
|
-
constructor(path: Path, change: (value:
|
|
33
|
+
constructor(path: Path, change: (value: T) => void, value: Signal<T>, status: Signal<ControllerValidation>, parent: {
|
|
32
34
|
disabled: Signal<boolean>;
|
|
33
|
-
}, equals: (a:
|
|
34
|
-
readonly field: <K extends keyof
|
|
35
|
+
}, equals: (a: T, b: T) => boolean);
|
|
36
|
+
readonly field: <K extends keyof T & string>(field: K) => Controller<T[K]>;
|
|
35
37
|
}
|
|
36
|
-
export declare class ArrayController<
|
|
38
|
+
export declare class ArrayController<T extends unknown[]> extends Controller<T> {
|
|
37
39
|
#private;
|
|
38
40
|
readonly length: Signal<number>;
|
|
39
|
-
constructor(path: Path, change: (value:
|
|
41
|
+
constructor(path: Path, change: (value: T) => void, value: Signal<T>, status: Signal<ControllerValidation>, parent: {
|
|
40
42
|
disabled: Signal<boolean>;
|
|
41
|
-
}, equals: (a:
|
|
42
|
-
readonly item: (index: number) => Controller<
|
|
43
|
-
readonly push: (...value:
|
|
43
|
+
}, equals: (a: T, b: T) => boolean);
|
|
44
|
+
readonly item: (index: number) => Controller<T[number]>;
|
|
45
|
+
readonly push: (...value: T[number][]) => void;
|
|
44
46
|
readonly pop: () => void;
|
|
45
47
|
readonly shift: () => void;
|
|
46
|
-
readonly unshift: (...value:
|
|
48
|
+
readonly unshift: (...value: T) => void;
|
|
47
49
|
readonly removeAt: (index: number) => void;
|
|
48
50
|
readonly splice: (start: number, deleteCount?: number) => void;
|
|
49
51
|
readonly move: (from: number, to: number, length?: number) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ControllerError } from '../controller/controller-validation';
|
|
2
2
|
import { StandardSchemaV1 } from './standard-schema-v1';
|
|
3
3
|
export declare function convertStandardSchemaPathToPath(path: ReadonlyArray<PropertyKey | StandardSchemaV1.PathSegment>): (string | number)[];
|
|
4
|
-
export declare function convertStandardSchemaIssues(issues: readonly StandardSchemaV1.Issue[]):
|
|
4
|
+
export declare function convertStandardSchemaIssues(issues: readonly StandardSchemaV1.Issue[]): ControllerError;
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from './schema/standard-schema-v1';
|
|
2
|
-
import {
|
|
3
|
-
export interface UseFormOptions<
|
|
4
|
-
schema: StandardSchemaV1<
|
|
5
|
-
defaultValue?:
|
|
2
|
+
import { ControllerValidation, Controller, ObjectController } from './controller';
|
|
3
|
+
export interface UseFormOptions<T> {
|
|
4
|
+
schema: StandardSchemaV1<T, T>;
|
|
5
|
+
defaultValue?: T;
|
|
6
|
+
submit?: (value: T) => Promise<ControllerValidation>;
|
|
6
7
|
}
|
|
7
|
-
export interface UseControllerOptions<
|
|
8
|
-
defaultValue:
|
|
9
|
-
onChange?: (value:
|
|
10
|
-
validate?: (value:
|
|
8
|
+
export interface UseControllerOptions<T> {
|
|
9
|
+
defaultValue: T;
|
|
10
|
+
onChange?: (value: T) => void;
|
|
11
|
+
validate?: (value: T) => Promise<ControllerValidation> | ControllerValidation;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* Creates a Controller instance with automatic resource cleanup.
|
|
14
15
|
* The controller will be automatically disposed when the component unmounts.
|
|
15
16
|
*/
|
|
16
|
-
export declare function useController<
|
|
17
|
+
export declare function useController<T>({ defaultValue, onChange, validate, }: UseControllerOptions<T>): {
|
|
18
|
+
controller: Controller<T>;
|
|
19
|
+
setStatus: (result: ControllerValidation) => void;
|
|
20
|
+
};
|
|
17
21
|
export declare function connectCommonAttributes<T>(value: Controller<T>): import("@tempots/dom").Renderable<import("@tempots/dom").DOMContext>;
|
|
18
22
|
export declare function connectStringInput(value: Controller<string>, { triggerOn, }?: {
|
|
19
23
|
triggerOn?: 'change' | 'input';
|
|
@@ -21,5 +25,34 @@ export declare function connectStringInput(value: Controller<string>, { triggerO
|
|
|
21
25
|
export declare function connectNumberInput(value: Controller<number>, { triggerOn, }?: {
|
|
22
26
|
triggerOn?: 'change' | 'input';
|
|
23
27
|
}): import("@tempots/dom").Renderable<import("@tempots/dom").DOMContext>;
|
|
24
|
-
export declare function
|
|
25
|
-
|
|
28
|
+
export declare function standardSchemaResultToValidation<Out>(result: StandardSchemaV1.Result<Out>): ControllerValidation;
|
|
29
|
+
/**
|
|
30
|
+
* Wraps an async operation and converts any thrown errors into a ControllerValidation.
|
|
31
|
+
* This is useful for form submission handlers that need to convert async operations
|
|
32
|
+
* into the ControllerValidation format expected by the form system.
|
|
33
|
+
*
|
|
34
|
+
* @param task - The async operation to execute
|
|
35
|
+
* @param errorMessage - Optional custom error message. If not provided, uses the error's message or a default message
|
|
36
|
+
* @param errorPath - Optional path for the error. Defaults to ['root']
|
|
37
|
+
* @returns A Promise that resolves to a ControllerValidation
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const result = await taskToValidation(
|
|
42
|
+
* () => signUpUser(userData),
|
|
43
|
+
* 'Sign up failed'
|
|
44
|
+
* )
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function taskToValidation<T>({ task, errorMessage, errorPath, validation, }: {
|
|
48
|
+
task: () => Promise<T>;
|
|
49
|
+
errorMessage?: string;
|
|
50
|
+
errorPath?: string[];
|
|
51
|
+
validation?: (result: T) => ControllerValidation;
|
|
52
|
+
}): Promise<ControllerValidation>;
|
|
53
|
+
export type UseFormResult<T> = {
|
|
54
|
+
controller: ObjectController<T>;
|
|
55
|
+
setStatus: (result: ControllerValidation) => void;
|
|
56
|
+
onSubmit: (e: Event) => Promise<void>;
|
|
57
|
+
};
|
|
58
|
+
export declare function useForm<T>({ defaultValue, schema, submit, }: UseFormOptions<T>): UseFormResult<T>;
|