@aws-amplify/ui 3.3.0 → 3.3.1
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/esm/index.js +21 -21
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +68 -52
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +1 -1
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,28 @@ import * as xstate from 'xstate';
|
|
|
4
4
|
import { Interpreter, State, Sender } from 'xstate';
|
|
5
5
|
import { PartialDeep } from 'type-fest';
|
|
6
6
|
|
|
7
|
+
/** Array of auth fields that we supply defaults with */
|
|
8
|
+
declare const signUpFieldsWithDefault: readonly ["birthdate", "email", "family_name", "given_name", "middle_name", "name", "nickname", "phone_number", "preferred_username", "profile", "website"];
|
|
9
|
+
/** Auth fields that we supply defaults with */
|
|
10
|
+
declare type SignUpFieldsWithDefaults = typeof signUpFieldsWithDefault[number];
|
|
11
|
+
/** Array of auth fields that we do not supply defaults with */
|
|
12
|
+
declare const signUpFieldsWithoutDefault: readonly ["address", "gender", "locale", "picture", "updated_at", "zoneinfo"];
|
|
13
|
+
/** Auth fields that we do not supply defaults with */
|
|
14
|
+
declare type SignUpFieldsWithoutDefaults = typeof signUpFieldsWithoutDefault[number];
|
|
15
|
+
/** All known auth fields */
|
|
16
|
+
declare type SignUpAttribute = SignUpFieldsWithDefaults | SignUpFieldsWithoutDefaults;
|
|
17
|
+
/** Fields that are common in all routes */
|
|
18
|
+
declare type CommonFields = 'username' | 'password' | 'confirm_password';
|
|
19
|
+
/** Array of known login mechanisms */
|
|
20
|
+
declare const LoginMechanismArray: readonly ["username", "email", "phone_number"];
|
|
21
|
+
/** Login mechanisms that can be used to sign in */
|
|
22
|
+
declare type LoginMechanism = typeof LoginMechanismArray[number];
|
|
23
|
+
/** List of social provider Authenticator supports */
|
|
24
|
+
declare type SocialProvider = 'amazon' | 'apple' | 'facebook' | 'google';
|
|
25
|
+
declare const authFieldsWithDefaults: readonly ["username", "email", "phone_number", "birthdate", "email", "family_name", "given_name", "middle_name", "name", "nickname", "phone_number", "preferred_username", "profile", "website", "confirmation_code", "password", "confirm_password"];
|
|
26
|
+
/** Input fields that we provide default fields with */
|
|
27
|
+
declare type AuthFieldsWithDefaults = typeof authFieldsWithDefaults[number];
|
|
28
|
+
|
|
7
29
|
/**
|
|
8
30
|
* Map of each input name to its value
|
|
9
31
|
*/
|
|
@@ -15,14 +37,14 @@ declare type FormFieldComponents = 'signIn' | 'signUp' | 'forceNewPassword' | 'c
|
|
|
15
37
|
/**
|
|
16
38
|
* Used to customize form field attributes for each authenticator screen.
|
|
17
39
|
*/
|
|
18
|
-
declare type
|
|
19
|
-
[key in FormFieldComponents]?:
|
|
40
|
+
declare type AuthFormFields = {
|
|
41
|
+
[key in FormFieldComponents]?: FormFields;
|
|
20
42
|
};
|
|
21
43
|
/**
|
|
22
44
|
* Override option for each screen. Maps each input to override options.
|
|
23
45
|
*/
|
|
24
|
-
interface
|
|
25
|
-
[
|
|
46
|
+
interface FormFields {
|
|
47
|
+
[field_name: string]: FormFieldOptions;
|
|
26
48
|
}
|
|
27
49
|
/**
|
|
28
50
|
* Override options for each field
|
|
@@ -50,7 +72,15 @@ interface FormFieldOptions {
|
|
|
50
72
|
dialCodeList?: Array<string>;
|
|
51
73
|
/** Integer that denotes where this field should be positioned in. */
|
|
52
74
|
order?: number;
|
|
75
|
+
/** Desired HTML input type */
|
|
76
|
+
type?: string;
|
|
77
|
+
/** Desired autocomplete HTML attribute */
|
|
78
|
+
autocomplete?: string;
|
|
53
79
|
}
|
|
80
|
+
/** Default formField values for each supported auth field */
|
|
81
|
+
declare type DefaultFormFieldOptions = Record<AuthFieldsWithDefaults, FormFieldOptions>;
|
|
82
|
+
/** Ordered list of formFields */
|
|
83
|
+
declare type FormFieldsArray = Array<[string, FormFieldOptions]>;
|
|
54
84
|
declare type PasswordPolicyRules = 'REQUIRES_LOWERCASE' | 'REQUIRES_NUMBERS' | 'REQUIRES_SYMBOLS' | 'REQUIRES_UPPERCASE';
|
|
55
85
|
interface PasswordSettings {
|
|
56
86
|
passwordPolicyMinLength: number;
|
|
@@ -101,36 +131,6 @@ declare type SignInResult = string;
|
|
|
101
131
|
declare type Validator = (formData: AuthFormData, touchData?: AuthFormData, passwordSettings?: PasswordSettings) => ValidatorResult | Promise<ValidatorResult>;
|
|
102
132
|
declare type SignInTypes = (user: string, code: string, mfaType: AuthChallengeNames.SMS_MFA | AuthChallengeNames.SOFTWARE_TOKEN_MFA) => SignInResult | Promise<SignInResult>;
|
|
103
133
|
|
|
104
|
-
/** Array of auth fields that we supply defaults with */
|
|
105
|
-
declare const signUpFieldsWithDefault: readonly ["birthdate", "email", "family_name", "given_name", "middle_name", "name", "nickname", "phone_number", "preferred_username", "profile", "website"];
|
|
106
|
-
/** Auth fields that we supply defaults with */
|
|
107
|
-
declare type SignUpFieldsWithDefaults = typeof signUpFieldsWithDefault[number];
|
|
108
|
-
/** Array of auth fields that we do not supply defaults with */
|
|
109
|
-
declare const signUpFieldsWithoutDefault: readonly ["address", "gender", "locale", "picture", "updated_at", "zoneinfo"];
|
|
110
|
-
/** Auth fields that we do not supply defaults with */
|
|
111
|
-
declare type SignUpFieldsWithoutDefaults = typeof signUpFieldsWithoutDefault[number];
|
|
112
|
-
/** All known auth fields */
|
|
113
|
-
declare type SignUpAttribute = SignUpFieldsWithDefaults | SignUpFieldsWithoutDefaults;
|
|
114
|
-
/** Fields that are common in all routes */
|
|
115
|
-
declare type CommonFields = 'username' | 'password' | 'confirm_password';
|
|
116
|
-
/** Array of known login mechanisms */
|
|
117
|
-
declare const LoginMechanismArray: readonly ["username", "email", "phone_number"];
|
|
118
|
-
/** Login mechanisms that can be used to sign in */
|
|
119
|
-
declare type LoginMechanism = typeof LoginMechanismArray[number];
|
|
120
|
-
/** List of social provider Authenticator supports */
|
|
121
|
-
declare type SocialProvider = 'amazon' | 'apple' | 'facebook' | 'google';
|
|
122
|
-
/** Input fields that we provide default fields with */
|
|
123
|
-
declare type AuthFieldsWithDefaults = LoginMechanism | SignUpFieldsWithDefaults | 'confirmation_code' | 'password';
|
|
124
|
-
/** Maps default attributes values for an input */
|
|
125
|
-
interface InputAttributeDefaults {
|
|
126
|
-
label: string;
|
|
127
|
-
type: string;
|
|
128
|
-
placeholder: string;
|
|
129
|
-
autocomplete?: string;
|
|
130
|
-
}
|
|
131
|
-
/** Maps default attribute values for each Auth Field */
|
|
132
|
-
declare type AuthInputAttributes = Record<AuthFieldsWithDefaults, InputAttributeDefaults>;
|
|
133
|
-
|
|
134
134
|
declare const defaultServices: {
|
|
135
135
|
getAmplifyConfig(): Promise<{}>;
|
|
136
136
|
getCurrentUser(): Promise<any>;
|
|
@@ -181,7 +181,7 @@ interface AuthContext {
|
|
|
181
181
|
loginMechanisms?: LoginMechanism[];
|
|
182
182
|
signUpAttributes?: SignUpAttribute[];
|
|
183
183
|
socialProviders?: SocialProvider[];
|
|
184
|
-
formFields?:
|
|
184
|
+
formFields?: AuthFormFields;
|
|
185
185
|
initialState?: 'signIn' | 'signUp' | 'resetPassword';
|
|
186
186
|
passwordSettings?: PasswordSettings;
|
|
187
187
|
};
|
|
@@ -225,7 +225,7 @@ interface BaseFormContext {
|
|
|
225
225
|
interface SignInContext extends BaseFormContext {
|
|
226
226
|
loginMechanisms: Required<AuthContext>['config']['loginMechanisms'];
|
|
227
227
|
socialProviders: Required<AuthContext>['config']['socialProviders'];
|
|
228
|
-
formFields?:
|
|
228
|
+
formFields?: AuthFormFields;
|
|
229
229
|
attributeToVerify?: string;
|
|
230
230
|
redirectIntent?: string;
|
|
231
231
|
unverifiedAttributes?: Record<string, string>;
|
|
@@ -233,20 +233,20 @@ interface SignInContext extends BaseFormContext {
|
|
|
233
233
|
interface SignUpContext extends BaseFormContext {
|
|
234
234
|
loginMechanisms: Required<AuthContext>['config']['loginMechanisms'];
|
|
235
235
|
socialProviders: Required<AuthContext>['config']['socialProviders'];
|
|
236
|
-
formFields:
|
|
236
|
+
formFields: AuthFormFields;
|
|
237
237
|
unverifiedAttributes?: Record<string, string>;
|
|
238
238
|
}
|
|
239
239
|
interface ResetPasswordContext extends BaseFormContext {
|
|
240
240
|
username?: string;
|
|
241
241
|
unverifiedAttributes?: Record<string, string>;
|
|
242
|
-
formFields?:
|
|
242
|
+
formFields?: AuthFormFields;
|
|
243
243
|
}
|
|
244
244
|
interface SignOutContext {
|
|
245
245
|
authAttributes?: Record<string, any>;
|
|
246
246
|
challengeName?: string;
|
|
247
247
|
unverifiedAttributes?: Record<string, string>;
|
|
248
248
|
user?: CognitoUserAmplify;
|
|
249
|
-
formFields?:
|
|
249
|
+
formFields?: AuthFormFields;
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
252
252
|
* Context for actors that have forms
|
|
@@ -311,16 +311,7 @@ declare const getActorState: (state: AuthMachineState) => AuthActorState;
|
|
|
311
311
|
*/
|
|
312
312
|
declare const getActorContext: (state: AuthMachineState) => AuthActorContext;
|
|
313
313
|
|
|
314
|
-
|
|
315
|
-
* Given xstate context from AuthMachine, this returns the input label, type,
|
|
316
|
-
* and error attributes of the configured login_mechanisms. An optional "alias"
|
|
317
|
-
* may be passed in to get info from context for that specific alias.
|
|
318
|
-
*/
|
|
319
|
-
declare const getAliasInfoFromContext: (context: AuthContext, alias?: LoginMechanism) => {
|
|
320
|
-
label: string;
|
|
321
|
-
type: string;
|
|
322
|
-
error: any;
|
|
323
|
-
};
|
|
314
|
+
declare const getPrimaryAlias: (state: AuthMachineState) => "email" | "phone_number" | "username";
|
|
324
315
|
/**
|
|
325
316
|
* Given xstate context from AuthMachine, returns the primaryAlias and
|
|
326
317
|
* secondaryAliases.
|
|
@@ -393,11 +384,14 @@ declare const getServiceFacade: ({ send, state }: {
|
|
|
393
384
|
* This file contains helpers related to forms and input attributes.
|
|
394
385
|
*/
|
|
395
386
|
|
|
396
|
-
declare const
|
|
387
|
+
declare const defaultFormFieldOptions: DefaultFormFieldOptions;
|
|
388
|
+
|
|
397
389
|
declare const getFormDataFromEvent: (event: Event) => {
|
|
398
390
|
[k: string]: FormDataEntryValue;
|
|
399
391
|
};
|
|
400
|
-
declare const setFormOrder: (formOverrides:
|
|
392
|
+
declare const setFormOrder: (formOverrides: FormFields, fieldNames: Array<SignUpAttribute | CommonFields>) => Array<string | number>;
|
|
393
|
+
declare const isAuthFieldWithDefaults: (field: string) => field is "birthdate" | "email" | "family_name" | "given_name" | "middle_name" | "name" | "nickname" | "phone_number" | "preferred_username" | "profile" | "website" | "username" | "password" | "confirm_password" | "confirmation_code";
|
|
394
|
+
declare const getErrors: (errors: string | string[]) => string[];
|
|
401
395
|
|
|
402
396
|
/**
|
|
403
397
|
* This file contains general helpers that state machine or authenticator
|
|
@@ -416,6 +410,28 @@ declare const censorPhoneNumber: (val: string) => string;
|
|
|
416
410
|
*/
|
|
417
411
|
declare const listenToAuthHub: (send: AuthMachineSend) => () => void;
|
|
418
412
|
|
|
413
|
+
/**
|
|
414
|
+
* This file contains helpers that generate default form fields, given the
|
|
415
|
+
* current Authenticator / Zero Config configuration.
|
|
416
|
+
*/
|
|
417
|
+
|
|
418
|
+
/** Gets the default formFields for given route/route */
|
|
419
|
+
declare const getDefaultFormFields: (route: FormFieldComponents, state: AuthMachineState) => FormFields;
|
|
420
|
+
/** Gets default formFields, then merges custom formFields into it */
|
|
421
|
+
declare const getFormFields: (route: FormFieldComponents, state: AuthMachineState) => FormFields;
|
|
422
|
+
/** Calls `getFormFields` above, then sorts it into an indexed array */
|
|
423
|
+
declare const getSortedFormFields: (route: FormFieldComponents, state: AuthMachineState) => FormFieldsArray;
|
|
424
|
+
|
|
425
|
+
/** Collect all the defaultFormFields getters */
|
|
426
|
+
declare const defaultFormFieldsGetters: Record<FormFieldComponents, (state: AuthMachineState) => FormFields>;
|
|
427
|
+
|
|
428
|
+
/** Applies translations to label and placeholder */
|
|
429
|
+
declare const applyTranslation: (formFields: FormFields) => FormFields;
|
|
430
|
+
/** Sorts formFields according to their `order`. */
|
|
431
|
+
declare const sortFormFields: (formFields: FormFields) => FormFieldsArray;
|
|
432
|
+
/** Applies defaultFormFields value into customFormFields */
|
|
433
|
+
declare const applyDefaults: (defaultFormFields: FormFields, customFormFields?: FormFields) => FormFields;
|
|
434
|
+
|
|
419
435
|
declare const countryDialCodes: string[];
|
|
420
436
|
|
|
421
437
|
/**
|
|
@@ -1003,4 +1019,4 @@ declare function createTheme(theme?: Theme, baseTheme?: BaseTheme): WebTheme;
|
|
|
1003
1019
|
|
|
1004
1020
|
declare const defaultTheme: WebTheme;
|
|
1005
1021
|
|
|
1006
|
-
export { ActorContextWithForms, ActorDoneData, AuthActorContext, AuthActorState, AuthChallengeNames, AuthContext, AuthEvent, AuthEventData, AuthEventTypes, AuthFieldsWithDefaults, AuthFormData,
|
|
1022
|
+
export { ActorContextWithForms, ActorDoneData, AuthActorContext, AuthActorState, AuthChallengeNames, AuthContext, AuthEvent, AuthEventData, AuthEventTypes, AuthFieldsWithDefaults, AuthFormData, AuthFormFields, AuthInterpreter, AuthMachineSend, AuthMachineState, AuthenticatorMachineOptions, BaseTheme, BorderWidthValue, CognitoAttributes, CognitoUserAmplify, ColorModeOverride, ColorValue, CommonFields, ContactMethod, DefaultFormFieldOptions, DefaultTexts, DesignToken, Dict, FederatedIdentityProviders, FontSizeValue, FontValue, FontWeightValue, FormFieldComponents, FormFieldOptions, FormFields, FormFieldsArray, InvokeActorEventTypes, LineHeightValue, LoginMechanism, LoginMechanismArray, MediaQueryOverride, NoInfer, OpacityValue, OutlineOffsetValue, OutlineWidthValue, Override, PasswordPolicyRules, PasswordSettings, Phrase, RadiusValue, ResetPasswordContext, ResetPasswordState, SelectorOverride, ShadowValue, SignInContext, SignInResult, SignInState, SignInTypes, SignOutContext, SignOutState, SignUpAttribute, SignUpContext, SignUpFieldsWithDefaults, SignUpFieldsWithoutDefaults, SignUpState, SocialProvider, SpaceValue, Theme, TimeValue, TransformValue, ValidationError, Validator, ValidatorResult, WebDesignToken, WebTheme, applyDefaults, applyTranslation, authFieldsWithDefaults, censorAllButFirstAndLast, censorPhoneNumber, countryDialCodes, createAuthenticatorMachine, createTheme, defaultFormFieldOptions, defaultFormFieldsGetters, defaultTheme, getActorContext, getActorState, getConfiguredAliases, getDefaultFormFields, getErrors, getFormDataFromEvent, getFormFields, getPrimaryAlias, getSendEventAliases, getServiceContextFacade, getServiceFacade, getSortedFormFields, hasTranslation, isAuthFieldWithDefaults, isDesignToken, listenToAuthHub, setFormOrder, signUpFieldsWithDefault, signUpFieldsWithoutDefault, sortFormFields, translate, translations };
|