@aws-amplify/ui-react-core 2.0.0 → 2.1.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.
Files changed (46) hide show
  1. package/dist/esm/Authenticator/hooks/constants.js +26 -0
  2. package/dist/esm/Authenticator/hooks/useAuthenticator/constants.js +1 -13
  3. package/dist/esm/Authenticator/hooks/useAuthenticator/useAuthenticator.js +4 -3
  4. package/dist/esm/Authenticator/hooks/useAuthenticator/utils.js +23 -9
  5. package/dist/esm/Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.js +17 -0
  6. package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/constants.js +73 -0
  7. package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/useAuthenticatorRoute.js +52 -0
  8. package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/utils.js +89 -0
  9. package/dist/esm/Authenticator/hooks/utils.js +24 -0
  10. package/dist/esm/InAppMessaging/hooks/useMessage/useMessage.js +3 -3
  11. package/dist/esm/components/RenderNothing/RenderNothing.js +2 -2
  12. package/dist/esm/hooks/useHasValueUpdated.js +13 -0
  13. package/dist/esm/hooks/usePreviousValue.js +13 -0
  14. package/dist/esm/index.js +5 -0
  15. package/dist/index.js +322 -32
  16. package/dist/types/Authenticator/hooks/__mock__/components.d.ts +7 -0
  17. package/dist/types/Authenticator/hooks/__tests__/utils.spec.d.ts +1 -0
  18. package/dist/types/Authenticator/hooks/constants.d.ts +3 -0
  19. package/dist/types/Authenticator/hooks/index.d.ts +4 -0
  20. package/dist/types/Authenticator/hooks/types.d.ts +123 -0
  21. package/dist/types/Authenticator/hooks/useAuthenticator/__mock__/useAuthenticator.d.ts +4 -0
  22. package/dist/types/Authenticator/hooks/useAuthenticator/constants.d.ts +0 -2
  23. package/dist/types/Authenticator/hooks/useAuthenticator/index.d.ts +1 -1
  24. package/dist/types/Authenticator/hooks/useAuthenticator/types.d.ts +2 -2
  25. package/dist/types/Authenticator/hooks/useAuthenticator/useAuthenticator.d.ts +2 -2
  26. package/dist/types/Authenticator/hooks/useAuthenticator/utils.d.ts +7 -6
  27. package/dist/types/Authenticator/hooks/useAuthenticatorInitMachine/__tests__/useAuthenticatorInitMachine.spec.d.ts +1 -0
  28. package/dist/types/Authenticator/hooks/useAuthenticatorInitMachine/index.d.ts +1 -0
  29. package/dist/types/Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.d.ts +4 -0
  30. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/__tests__/useAuthenticatorRoute.spec.d.ts +1 -0
  31. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/__tests__/utils.spec.d.ts +1 -0
  32. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/constants.d.ts +4 -0
  33. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/index.d.ts +2 -0
  34. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/types.d.ts +38 -0
  35. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/useAuthenticatorRoute.d.ts +11 -0
  36. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/utils.d.ts +17 -0
  37. package/dist/types/Authenticator/hooks/utils.d.ts +4 -0
  38. package/dist/types/Authenticator/index.d.ts +3 -2
  39. package/dist/types/components/RenderNothing/RenderNothing.d.ts +1 -1
  40. package/dist/types/hooks/__tests__/useHasValueUpdated.spec.d.ts +1 -0
  41. package/dist/types/hooks/__tests__/usePreviousValue.spec.d.ts +1 -0
  42. package/dist/types/hooks/index.d.ts +2 -0
  43. package/dist/types/hooks/useHasValueUpdated.d.ts +1 -0
  44. package/dist/types/hooks/usePreviousValue.d.ts +1 -0
  45. package/dist/types/index.d.ts +2 -1
  46. package/package.json +5 -5
@@ -0,0 +1,4 @@
1
+ import { AuthenticatorMachineContextKey, AuthenticatorRouteComponentKey } from '../types';
2
+ import { FormEventHandlerMachineKey, FormEventHandlerPropKey } from './types';
3
+ export declare const EVENT_HANDLER_KEY_MAP: Record<FormEventHandlerMachineKey, FormEventHandlerPropKey>;
4
+ export declare const MACHINE_PROP_KEYS: Record<AuthenticatorRouteComponentKey, AuthenticatorMachineContextKey[]>;
@@ -0,0 +1,2 @@
1
+ export { default as useAuthenticatorRoute } from './useAuthenticatorRoute';
2
+ export * from './types';
@@ -0,0 +1,38 @@
1
+ import { AuthenticatorMachineContext, AuthenticatorMachineContextKey, AuthenticatorRouteComponentName, CommonRouteProps, ConfirmResetPasswordBaseProps, ConfirmSignInBaseProps, ConfirmSignUpBaseProps, Defaults, DefaultProps, ForceResetPasswordBaseProps, ResetPasswordBaseProps, SetupTOTPBaseProps, SignInBaseProps, SignUpBaseProps, VerifyUserProps, ConfirmVerifyUserProps } from '../types';
2
+ export declare type UseAuthenticatorRouteParams<FieldType> = {
3
+ components: Defaults<FieldType>;
4
+ };
5
+ export declare type UseAuthenticatorRoute<ComponentName extends AuthenticatorRouteComponentName, FieldType = {}> = {
6
+ Component: Defaults<FieldType>[ComponentName];
7
+ props: DefaultProps<FieldType>[ComponentName];
8
+ };
9
+ export declare type UseAuthenticatorRouteDefault<FieldType> = {
10
+ Component: Defaults<FieldType>[AuthenticatorRouteComponentName];
11
+ props: DefaultProps<FieldType>[AuthenticatorRouteComponentName];
12
+ };
13
+ declare type ExtractMachineKey<RouteProps> = Extract<AuthenticatorMachineContextKey, keyof RouteProps>;
14
+ export declare type FormEventHandlerMachineKey = 'updateBlur' | 'updateForm' | 'submitForm';
15
+ export declare type FormEventHandlerPropKey = `handleBlur` | `handleChange` | `handleSubmit`;
16
+ export declare type CommonRouteMachineKey = ExtractMachineKey<CommonRouteProps> | FormEventHandlerMachineKey;
17
+ /**
18
+ * `route` sub-component machine selector key types
19
+ */
20
+ export declare type ConfirmResetPasswordMachineKey = ExtractMachineKey<ConfirmResetPasswordBaseProps> | CommonRouteMachineKey;
21
+ export declare type ConfirmSignInMachineKey = ExtractMachineKey<ConfirmSignInBaseProps> | CommonRouteMachineKey | 'user';
22
+ export declare type ConfirmSignUpMachineKey = ExtractMachineKey<ConfirmSignUpBaseProps> | CommonRouteMachineKey;
23
+ export declare type ConfirmVerifyUserMachineKey = ExtractMachineKey<ConfirmVerifyUserProps> | CommonRouteMachineKey;
24
+ export declare type ForceNewPasswordMachineKey = ExtractMachineKey<ForceResetPasswordBaseProps> | CommonRouteMachineKey;
25
+ export declare type ResetPasswordMachineKey = ExtractMachineKey<ResetPasswordBaseProps> | CommonRouteMachineKey;
26
+ export declare type SetupTOTPMachineKey = ExtractMachineKey<SetupTOTPBaseProps> | CommonRouteMachineKey;
27
+ export declare type SignInMachineKey = ExtractMachineKey<SignInBaseProps> | CommonRouteMachineKey;
28
+ export declare type SignUpMachineKey = ExtractMachineKey<SignUpBaseProps> | CommonRouteMachineKey;
29
+ export declare type VerifyUserMachineKey = ExtractMachineKey<VerifyUserProps> | CommonRouteMachineKey;
30
+ /**
31
+ * machine values with machine form event handlers keys mapped to UI form event handlers
32
+ */
33
+ export declare type ConvertedMachineProps = Omit<AuthenticatorMachineContext, FormEventHandlerMachineKey> & {
34
+ handleBlur: AuthenticatorMachineContext['updateBlur'];
35
+ handleChange: AuthenticatorMachineContext['updateForm'];
36
+ handleSubmit: AuthenticatorMachineContext['submitForm'];
37
+ };
38
+ export {};
@@ -0,0 +1,11 @@
1
+ import { UseAuthenticatorRoute, UseAuthenticatorRouteParams } from './types';
2
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'ConfirmResetPassword'>;
3
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'ConfirmSignIn'>;
4
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'ConfirmSignUp'>;
5
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'ConfirmVerifyUser'>;
6
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'ForceNewPassword'>;
7
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'ResetPassword'>;
8
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'SetupTOTP'>;
9
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'SignIn'>;
10
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'SignUp'>;
11
+ export default function useAuthenticatorRoute<FieldType>(params: UseAuthenticatorRouteParams<FieldType>): UseAuthenticatorRoute<'VerifyUser'>;
@@ -0,0 +1,17 @@
1
+ import { AuthenticatorRoute } from '@aws-amplify/ui';
2
+ import { Defaults } from '../types';
3
+ import { UseAuthenticator, UseAuthenticatorSelector } from '../useAuthenticator';
4
+ import { UseAuthenticatorRoute, UseAuthenticatorRouteDefault } from './types';
5
+ export declare const routeSelector: UseAuthenticatorSelector;
6
+ export declare const getRouteMachineSelector: (route: AuthenticatorRoute) => UseAuthenticatorSelector;
7
+ export declare function resolveConfirmResetPasswordRoute<FieldType = {}>(Component: Defaults<FieldType>['ConfirmResetPassword'], props: UseAuthenticator): UseAuthenticatorRoute<'ConfirmResetPassword', FieldType>;
8
+ export declare function resolveConfirmSignInRoute<FieldType = {}>(Component: Defaults<FieldType>['ConfirmSignIn'], props: UseAuthenticator): UseAuthenticatorRoute<'ConfirmSignIn', FieldType>;
9
+ export declare function resolveConfirmSignUpRoute<FieldType = {}>(Component: Defaults<FieldType>['ConfirmSignUp'], props: UseAuthenticator): UseAuthenticatorRoute<'ConfirmSignUp', FieldType>;
10
+ export declare function resolveConfirmVerifyUserRoute<FieldType = {}>(Component: Defaults<FieldType>['ConfirmVerifyUser'], props: UseAuthenticator): UseAuthenticatorRoute<'ConfirmVerifyUser', FieldType>;
11
+ export declare function resolveForceNewPasswordRoute<FieldType = {}>(Component: Defaults<FieldType>['ForceNewPassword'], props: UseAuthenticator): UseAuthenticatorRoute<'ForceNewPassword', FieldType>;
12
+ export declare function resolveResetPasswordRoute<FieldType = {}>(Component: Defaults<FieldType>['ResetPassword'], props: UseAuthenticator): UseAuthenticatorRoute<'ResetPassword', FieldType>;
13
+ export declare function resolveSetupTOTPRoute<FieldType = {}>(Component: Defaults<FieldType>['SetupTOTP'], { getTotpSecretCode, ...props }: UseAuthenticator): UseAuthenticatorRoute<'SetupTOTP', FieldType>;
14
+ export declare function resolveSignInRoute<FieldType = {}>(Component: Defaults<FieldType>['SignIn'], props: UseAuthenticator): UseAuthenticatorRoute<'SignIn', FieldType>;
15
+ export declare function resolveSignUpRoute<FieldType = {}>(Component: Defaults<FieldType>['SignUp'], props: UseAuthenticator): UseAuthenticatorRoute<'SignUp', FieldType>;
16
+ export declare function resolveVerifyUserRoute<FieldType = {}>(Component: Defaults<FieldType>['VerifyUser'], props: UseAuthenticator): UseAuthenticatorRoute<'VerifyUser', FieldType>;
17
+ export declare function resolveDefault<FieldType = {}>(): UseAuthenticatorRouteDefault<FieldType>;
@@ -0,0 +1,4 @@
1
+ import { AuthenticatorRoute } from '@aws-amplify/ui';
2
+ import { AuthenticatorRouteComponentKey, Defaults, Overrides } from './types';
3
+ export declare const isComponentRouteKey: (route: AuthenticatorRoute) => route is AuthenticatorRouteComponentKey;
4
+ export declare function resolveAuthenticatorComponents<FieldType>(defaults: Defaults<FieldType>, overrides?: Overrides<FieldType>): Defaults<FieldType>;
@@ -1,2 +1,3 @@
1
- export * from './context';
2
- export * from './hooks';
1
+ export { AuthenticatorProvider, AuthenticatorContext } from './context';
2
+ export { resolveAuthenticatorComponents, useAuthenticator, useAuthenticatorRoute, UseAuthenticator, useAuthenticatorInitMachine, UseAuthenticatorRoute, } from './hooks';
3
+ export { Overrides as AuthenticatorComponentOverrides, Defaults as AuthenticatorComponentDefaults, DefaultProps as AuthenticatorComponentDefaultProps, FooterComponent as AuthenticatorFooterComponent, FormFieldsComponent as AuthenticatorFormFieldsComponent, HeaderComponent as AuthenticatorHeaderComponent, isComponentRouteKey as isAuthenticatorComponentRouteKey, AuthenticatorRouteComponentKey, AuthenticatorRouteComponentName, AuthenticatorLegacyField, AuthenticatorMachineContext, FormFieldsComponent, } from './hooks';
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Utility component for rendering nothing.
3
3
  */
4
- export default function RenderNothng<Props>(_: Props): JSX.Element | null;
4
+ export default function RenderNothing<Props>(_: Props): JSX.Element | null;
@@ -0,0 +1,2 @@
1
+ export { default as usePreviousValue } from './usePreviousValue';
2
+ export { default as useHasValueUpdated } from './useHasValueUpdated';
@@ -0,0 +1 @@
1
+ export default function useHasValueUpdated<Value>(value: Value, ignoreFirstRender?: boolean): boolean;
@@ -0,0 +1 @@
1
+ export default function usePreviousValue<Value>(value: Value): Value | undefined;
@@ -1,2 +1,3 @@
1
- export { AuthenticatorProvider, useAuthenticator, UseAuthenticator, } from './Authenticator';
1
+ export { AuthenticatorComponentDefaults, AuthenticatorComponentDefaultProps, AuthenticatorComponentOverrides, AuthenticatorFooterComponent, AuthenticatorFormFieldsComponent, AuthenticatorHeaderComponent, AuthenticatorLegacyField, AuthenticatorMachineContext, AuthenticatorProvider, AuthenticatorRouteComponentKey, AuthenticatorRouteComponentName, isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents, useAuthenticator, useAuthenticatorRoute, UseAuthenticator, useAuthenticatorInitMachine, UseAuthenticatorRoute, } from './Authenticator';
2
2
  export { BannerMessageCommonProps, BannerMessageComponent, CarouselMessageCommonProps, CarouselMessageComponent, FullScreenMessageCommonProps, FullScreenMessageComponent, handleMessageAction, HandleMessageLinkAction, InAppMessagingProvider, MessageButtonProps, MessageCommonProps, MessageComponentBaseProps, MessageContentProps, MessageImage, MessageLayout, MessagePayloadStyle, MessageTextAlign, ModalMessageCommonProps, ModalMessageComponent, OnMessageAction, useInAppMessaging, useMessage, } from './InAppMessaging';
3
+ export { useHasValueUpdated, usePreviousValue } from './hooks';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-core",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "react-native": "dist/index.js",
@@ -21,21 +21,21 @@
21
21
  "clean": "rimraf dist node_modules",
22
22
  "prebuild": "rimraf dist",
23
23
  "build": "rollup --config",
24
+ "build:esm": "tsc --project tsconfig.esm.json",
24
25
  "dev": "yarn build:esm --watch",
25
26
  "lint": "tsc --noEmit && eslint src",
26
27
  "test": "jest --coverage --verbose",
27
28
  "test:watch": "yarn test --watch"
28
29
  },
29
30
  "dependencies": {
30
- "@aws-amplify/ui": "5.0.0",
31
+ "@aws-amplify/ui": "5.1.1",
31
32
  "@xstate/react": "3.0.1",
32
33
  "lodash": "4.17.21",
33
34
  "xstate": "^4.33.6"
34
35
  },
35
36
  "peerDependencies": {
36
- "aws-amplify": "5.x.x",
37
- "react": ">= 16.14.0",
38
- "react-dom": ">= 16.14.0"
37
+ "aws-amplify": ">= 5.0.1",
38
+ "react": ">= 16.14.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@rollup/plugin-commonjs": "^22.0.1",