@aws-amplify/ui-react-core 1.0.5 → 2.1.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.
Files changed (98) hide show
  1. package/dist/esm/Authenticator/context/AuthenticatorContext.js +4 -1
  2. package/dist/esm/Authenticator/context/AuthenticatorProvider.js +8 -4
  3. package/dist/esm/Authenticator/hooks/constants.js +26 -0
  4. package/dist/esm/Authenticator/hooks/useAuthenticator/constants.js +3 -13
  5. package/dist/esm/Authenticator/hooks/useAuthenticator/useAuthenticator.js +13 -12
  6. package/dist/esm/Authenticator/hooks/useAuthenticator/utils.js +32 -15
  7. package/dist/esm/Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.js +17 -0
  8. package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/constants.js +73 -0
  9. package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/useAuthenticatorRoute.js +52 -0
  10. package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/utils.js +89 -0
  11. package/dist/esm/Authenticator/hooks/utils.js +24 -0
  12. package/dist/esm/InAppMessaging/context/InAppMessagingContext/InAppMessagingContext.js +5 -0
  13. package/dist/esm/InAppMessaging/context/InAppMessagingProvider/InAppMessagingProvider.js +26 -0
  14. package/dist/esm/InAppMessaging/hooks/useInAppMessaging/useInAppMessaging.js +19 -0
  15. package/dist/esm/InAppMessaging/hooks/useMessage/useMessage.js +78 -0
  16. package/dist/esm/InAppMessaging/hooks/useMessage/utils.js +43 -0
  17. package/dist/esm/InAppMessaging/utils/handleMessageAction.js +16 -0
  18. package/dist/esm/components/RenderNothing/RenderNothing.js +8 -0
  19. package/dist/esm/hooks/useHasValueUpdated.js +13 -0
  20. package/dist/esm/hooks/usePreviousValue.js +13 -0
  21. package/dist/esm/index.js +13 -1
  22. package/dist/esm/node_modules/tslib/tslib.es6.js +38 -0
  23. package/dist/esm/utils/index.js +5 -2
  24. package/dist/index.js +638 -6
  25. package/dist/{esm/Authenticator/hooks/useAuthenticator/types.js → types/Authenticator/context/__tests__/AuthenticatorProvider.test.d.ts} +0 -0
  26. package/dist/types/Authenticator/hooks/__mock__/components.d.ts +7 -0
  27. package/dist/types/Authenticator/hooks/__tests__/utils.spec.d.ts +1 -0
  28. package/dist/types/Authenticator/hooks/constants.d.ts +3 -0
  29. package/dist/types/Authenticator/hooks/index.d.ts +4 -0
  30. package/dist/types/Authenticator/hooks/types.d.ts +123 -0
  31. package/dist/types/Authenticator/hooks/useAuthenticator/__mock__/useAuthenticator.d.ts +4 -0
  32. package/dist/types/Authenticator/hooks/useAuthenticator/__tests__/useAuthenticator.spec.d.ts +1 -0
  33. package/dist/types/Authenticator/hooks/useAuthenticator/__tests__/utils.spec.d.ts +1 -0
  34. package/dist/types/Authenticator/hooks/useAuthenticator/constants.d.ts +0 -2
  35. package/dist/types/Authenticator/hooks/useAuthenticator/index.d.ts +1 -1
  36. package/dist/types/Authenticator/hooks/useAuthenticator/types.d.ts +3 -11
  37. package/dist/types/Authenticator/hooks/useAuthenticator/useAuthenticator.d.ts +2 -2
  38. package/dist/types/Authenticator/hooks/useAuthenticator/utils.d.ts +7 -6
  39. package/dist/types/Authenticator/hooks/useAuthenticatorInitMachine/__tests__/useAuthenticatorInitMachine.spec.d.ts +1 -0
  40. package/dist/types/Authenticator/hooks/useAuthenticatorInitMachine/index.d.ts +1 -0
  41. package/dist/types/Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.d.ts +4 -0
  42. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/__tests__/useAuthenticatorRoute.spec.d.ts +1 -0
  43. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/__tests__/utils.spec.d.ts +1 -0
  44. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/constants.d.ts +4 -0
  45. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/index.d.ts +2 -0
  46. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/types.d.ts +38 -0
  47. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/useAuthenticatorRoute.d.ts +11 -0
  48. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/utils.d.ts +17 -0
  49. package/dist/types/Authenticator/hooks/utils.d.ts +4 -0
  50. package/dist/types/Authenticator/index.d.ts +3 -2
  51. package/dist/types/InAppMessaging/context/InAppMessagingContext/InAppMessagingContext.d.ts +9 -0
  52. package/dist/types/InAppMessaging/context/InAppMessagingContext/index.d.ts +1 -0
  53. package/dist/types/InAppMessaging/context/InAppMessagingProvider/InAppMessagingProvider.d.ts +5 -0
  54. package/dist/types/InAppMessaging/context/InAppMessagingProvider/__tests__/InAppMessagingProvider.spec.d.ts +1 -0
  55. package/dist/types/InAppMessaging/context/InAppMessagingProvider/index.d.ts +1 -0
  56. package/dist/types/InAppMessaging/context/index.d.ts +2 -0
  57. package/dist/types/InAppMessaging/hooks/index.d.ts +2 -0
  58. package/dist/types/InAppMessaging/hooks/useInAppMessaging/__tests__/useInAppMessaging.spec.d.ts +1 -0
  59. package/dist/types/InAppMessaging/hooks/useInAppMessaging/index.d.ts +1 -0
  60. package/dist/types/InAppMessaging/hooks/useInAppMessaging/useInAppMessaging.d.ts +7 -0
  61. package/dist/types/InAppMessaging/hooks/useMessage/__tests__/useMessage.spec.d.ts +1 -0
  62. package/dist/types/InAppMessaging/hooks/useMessage/__tests__/utils.spec.d.ts +1 -0
  63. package/dist/types/InAppMessaging/hooks/useMessage/index.d.ts +1 -0
  64. package/dist/types/InAppMessaging/hooks/useMessage/types.d.ts +18 -0
  65. package/dist/types/InAppMessaging/hooks/useMessage/useMessage.d.ts +9 -0
  66. package/dist/types/InAppMessaging/hooks/useMessage/utils.d.ts +9 -0
  67. package/dist/{esm/Authenticator/index.js → types/InAppMessaging/index.d.ts} +3 -1
  68. package/dist/types/InAppMessaging/types.d.ts +52 -0
  69. package/dist/types/InAppMessaging/utils/__tests__/handleMessageAction.spec.d.ts +1 -0
  70. package/dist/types/InAppMessaging/utils/handleMessageAction.d.ts +9 -0
  71. package/dist/types/InAppMessaging/utils/index.d.ts +1 -0
  72. package/dist/types/__tests__/index.spec.d.ts +1 -0
  73. package/dist/types/components/RenderNothing/RenderNothing.d.ts +4 -0
  74. package/dist/types/components/RenderNothing/__tests__/RenderNothing.spec.d.ts +1 -0
  75. package/dist/types/components/RenderNothing/index.d.ts +1 -0
  76. package/dist/types/components/index.d.ts +1 -0
  77. package/dist/types/hooks/__tests__/useHasValueUpdated.spec.d.ts +1 -0
  78. package/dist/types/hooks/__tests__/usePreviousValue.spec.d.ts +1 -0
  79. package/dist/types/hooks/index.d.ts +2 -0
  80. package/dist/types/hooks/useHasValueUpdated.d.ts +1 -0
  81. package/dist/types/hooks/usePreviousValue.d.ts +1 -0
  82. package/dist/types/index.d.ts +3 -1
  83. package/dist/types/utils/__tests__/index.spec.d.ts +1 -0
  84. package/package.json +13 -8
  85. package/dist/Authenticator/context/AuthenticatorContext.js +0 -11
  86. package/dist/Authenticator/context/AuthenticatorProvider.js +0 -26
  87. package/dist/Authenticator/context/index.js +0 -10
  88. package/dist/Authenticator/hooks/index.js +0 -4
  89. package/dist/Authenticator/hooks/useAuthenticator/constants.js +0 -16
  90. package/dist/Authenticator/hooks/useAuthenticator/index.js +0 -8
  91. package/dist/Authenticator/hooks/useAuthenticator/types.js +0 -2
  92. package/dist/Authenticator/hooks/useAuthenticator/useAuthenticator.js +0 -38
  93. package/dist/Authenticator/hooks/useAuthenticator/utils.js +0 -53
  94. package/dist/Authenticator/index.js +0 -5
  95. package/dist/esm/Authenticator/context/index.js +0 -2
  96. package/dist/esm/Authenticator/hooks/index.js +0 -1
  97. package/dist/esm/Authenticator/hooks/useAuthenticator/index.js +0 -1
  98. package/dist/utils/index.js +0 -20
@@ -0,0 +1,123 @@
1
+ import React from 'react';
2
+ import { AuthChallengeName, AuthenticatorServiceFacade, LegacyFormFieldOptions } from '@aws-amplify/ui';
3
+ export declare type AuthenticatorRouteComponentKey = 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'forceNewPassword' | 'resetPassword' | 'setupTOTP' | 'signIn' | 'signUp' | 'verifyUser';
4
+ export declare type AuthenticatorLegacyField = LegacyFormFieldOptions;
5
+ export declare type AuthenticatorLegacyFields = AuthenticatorLegacyField[];
6
+ /**
7
+ * These are the "facades" that we provide, which contains contexts respective
8
+ * to current authenticator state.
9
+ */
10
+ export declare type AuthenticatorMachineContext = AuthenticatorServiceFacade;
11
+ export declare type AuthenticatorMachineContextKey = keyof AuthenticatorMachineContext;
12
+ export declare type AuthenticatorRouteComponentName = Capitalize<AuthenticatorRouteComponentKey>;
13
+ export declare type GetTotpSecretCode = () => Promise<string>;
14
+ interface HeaderProps {
15
+ children?: React.ReactNode;
16
+ }
17
+ interface FooterProps {
18
+ children?: React.ReactNode;
19
+ }
20
+ declare type FormFieldsProps = {
21
+ isPending: AuthenticatorMachineContext['isPending'];
22
+ validationErrors?: AuthenticatorMachineContext['validationErrors'];
23
+ };
24
+ export declare type FooterComponent<Props = {}> = React.ComponentType<FooterProps & Props>;
25
+ export declare type FormFieldsComponent<FieldType, Props = {}> = React.ComponentType<FormFieldsProps & {
26
+ fields: FieldType[];
27
+ } & Props>;
28
+ export declare type HeaderComponent<Props = {}> = React.ComponentType<HeaderProps & Props>;
29
+ export interface ComponentSlots<FieldType = {}> {
30
+ Footer: FooterComponent;
31
+ Header: HeaderComponent;
32
+ FormFields: FormFieldsComponent<FieldType>;
33
+ }
34
+ /**
35
+ * Common component prop types used for both RWA and RNA implementations
36
+ */
37
+ export declare type CommonRouteProps = {
38
+ error?: AuthenticatorMachineContext['error'];
39
+ isPending: AuthenticatorMachineContext['isPending'];
40
+ handleBlur: AuthenticatorMachineContext['updateBlur'];
41
+ handleChange: AuthenticatorMachineContext['updateForm'];
42
+ handleSubmit: AuthenticatorMachineContext['submitForm'];
43
+ };
44
+ /**
45
+ * Base Route component props
46
+ */
47
+ export declare type ConfirmResetPasswordBaseProps<FieldType = {}> = {
48
+ resendCode: AuthenticatorMachineContext['resendCode'];
49
+ validationErrors?: AuthenticatorMachineContext['validationErrors'];
50
+ } & CommonRouteProps & ComponentSlots<FieldType>;
51
+ export declare type ConfirmSignInBaseProps<FieldType = {}> = {
52
+ challengeName: AuthChallengeName;
53
+ toSignIn: AuthenticatorMachineContext['toSignIn'];
54
+ } & CommonRouteProps & ComponentSlots<FieldType>;
55
+ export declare type ConfirmSignUpBaseProps<FieldType = {}> = {
56
+ codeDeliveryDetails: AuthenticatorMachineContext['codeDeliveryDetails'];
57
+ resendCode: AuthenticatorMachineContext['resendCode'];
58
+ } & CommonRouteProps & ComponentSlots<FieldType>;
59
+ export declare type ConfirmVerifyUserProps<FieldType = {}> = {
60
+ skipVerification: AuthenticatorMachineContext['skipVerification'];
61
+ } & CommonRouteProps & ComponentSlots<FieldType>;
62
+ export declare type ForceResetPasswordBaseProps<FieldType = {}> = {
63
+ toSignIn: AuthenticatorMachineContext['toSignIn'];
64
+ validationErrors?: AuthenticatorMachineContext['validationErrors'];
65
+ } & CommonRouteProps & ComponentSlots<FieldType>;
66
+ export declare type ResetPasswordBaseProps<FieldType = {}> = {
67
+ toSignIn: AuthenticatorMachineContext['toSignIn'];
68
+ } & CommonRouteProps & ComponentSlots<FieldType>;
69
+ export declare type SetupTOTPBaseProps<FieldType = {}> = {
70
+ getTotpSecretCode: GetTotpSecretCode;
71
+ toSignIn: AuthenticatorMachineContext['toSignIn'];
72
+ } & CommonRouteProps & ComponentSlots<FieldType>;
73
+ export declare type SignInBaseProps<FieldType = {}> = {
74
+ hideSignUp?: boolean;
75
+ toFederatedSignIn: AuthenticatorMachineContext['toFederatedSignIn'];
76
+ toResetPassword: AuthenticatorMachineContext['toResetPassword'];
77
+ toSignUp: AuthenticatorMachineContext['toSignUp'];
78
+ } & CommonRouteProps & ComponentSlots<FieldType>;
79
+ export declare type SignUpBaseProps<FieldType = {}> = {
80
+ hideSignIn?: boolean;
81
+ toFederatedSignIn: AuthenticatorMachineContext['toFederatedSignIn'];
82
+ toSignIn: AuthenticatorMachineContext['toSignIn'];
83
+ validationErrors?: AuthenticatorMachineContext['validationErrors'];
84
+ } & CommonRouteProps & ComponentSlots<FieldType>;
85
+ export declare type VerifyUserProps<FieldType = {}> = {
86
+ skipVerification: AuthenticatorMachineContext['skipVerification'];
87
+ } & CommonRouteProps & ComponentSlots<FieldType>;
88
+ export interface DefaultProps<FieldType = {}> {
89
+ ConfirmSignIn: ConfirmSignInBaseProps<FieldType>;
90
+ ConfirmSignUp: ConfirmSignUpBaseProps<FieldType>;
91
+ ConfirmResetPassword: ConfirmResetPasswordBaseProps<FieldType>;
92
+ ConfirmVerifyUser: ConfirmVerifyUserProps<FieldType>;
93
+ ForceNewPassword: ForceResetPasswordBaseProps<FieldType>;
94
+ ResetPassword: ResetPasswordBaseProps<FieldType>;
95
+ SetupTOTP: SetupTOTPBaseProps<FieldType>;
96
+ SignIn: SignInBaseProps<FieldType>;
97
+ SignUp: SignUpBaseProps<FieldType>;
98
+ VerifyUser: VerifyUserProps<FieldType>;
99
+ }
100
+ /**
101
+ * common types extended for default component types/implementations and override component types
102
+ */
103
+ declare type BaseComponent<ComponentRouteProps = {}, FieldType = {}, Props = {}> = React.ComponentType<ComponentSlots<FieldType> & ComponentRouteProps & {
104
+ fields: FieldType[];
105
+ } & Props>;
106
+ /**
107
+ * Authenticator Route Component Default types
108
+ */
109
+ export declare type Defaults<FieldType = {}, PlatformProps = {}> = {
110
+ [Key in AuthenticatorRouteComponentName]: BaseComponent<DefaultProps<FieldType>[Key], FieldType, PlatformProps> & ComponentSlots<FieldType>;
111
+ };
112
+ export declare type Overrides<FieldType = {}, PlatformProps = {}> = {
113
+ [Key in AuthenticatorRouteComponentName]?: BaseComponent<DefaultProps<FieldType>[Key], FieldType, PlatformProps>;
114
+ };
115
+ /**
116
+ * Default Route Component union type
117
+ */
118
+ export declare type DefaultComponentType<FieldType = {}> = Defaults<FieldType>[keyof Defaults<FieldType>];
119
+ /**
120
+ * Default Route Component union type
121
+ */
122
+ export declare type DefaultPropsType<FieldType = {}> = DefaultProps<FieldType>[keyof DefaultProps<FieldType>];
123
+ export {};
@@ -0,0 +1,4 @@
1
+ import { AuthenticatorMachineContext } from '../../types';
2
+ import { UseAuthenticator } from '../types';
3
+ export declare const mockMachineContext: AuthenticatorMachineContext;
4
+ export declare const mockUseAuthenticatorOutput: UseAuthenticator;
@@ -1,3 +1 @@
1
- import { AuthenticatorRouteComponentKey } from './types';
2
1
  export declare const USE_AUTHENTICATOR_ERROR = "`useAuthenticator` must be used inside an `Authenticator.Provider`.";
3
- export declare const COMPONENT_ROUTE_KEYS: AuthenticatorRouteComponentKey[];
@@ -1,2 +1,2 @@
1
1
  export { default as useAuthenticator } from './useAuthenticator';
2
- export { UseAuthenticator } from './types';
2
+ export { UseAuthenticator, UseAuthenticatorSelector } from './types';
@@ -1,4 +1,4 @@
1
- import { AuthMachineSend, AuthMachineState, AuthenticatorServiceFacade, LegacyFormFieldOptions } from '@aws-amplify/ui';
1
+ import { AuthenticatorServiceFacade, LegacyFormFieldOptions } from '@aws-amplify/ui';
2
2
  /**
3
3
  * These are the "facades" that we provide, which contains contexts respective
4
4
  * to current authenticator state.
@@ -13,19 +13,11 @@ export declare type AuthenticatorLegacyFields = LegacyFormFieldOptions[];
13
13
  * Selector accepts current facade values and returns an array of
14
14
  * desired value(s) that should trigger re-render.
15
15
  */
16
- export declare type Selector = (context: AuthenticatorMachineContext) => AuthenticatorMachineContext[AuthenticatorMachineContextKey][];
17
- declare type InternalAuthenticatorContext = {
18
- _state: AuthMachineState;
19
- _send: AuthMachineSend;
20
- };
16
+ export declare type UseAuthenticatorSelector = (context: AuthenticatorMachineContext) => AuthenticatorMachineContext[AuthenticatorMachineContextKey][];
21
17
  export interface UseAuthenticator extends AuthenticatorServiceFacade {
22
18
  getTotpSecretCode: () => Promise<string>;
23
19
  /** @deprecated For internal use only */
24
20
  fields: AuthenticatorLegacyFields;
25
- /** @deprecated For internal use only */
26
- _send: InternalAuthenticatorContext['_send'];
27
- /** @deprecated For internal use only */
28
- _state: InternalAuthenticatorContext['_state'];
29
21
  }
30
- export declare type Comparator = (currentFacade: AuthenticatorServiceFacade, nextFacade: AuthenticatorServiceFacade) => boolean;
22
+ export declare type Comparator = (currentMachineContext: AuthenticatorMachineContext, nextMachineContext: AuthenticatorMachineContext) => boolean;
31
23
  export {};
@@ -1,5 +1,5 @@
1
- import { Selector, UseAuthenticator } from './types';
1
+ import { UseAuthenticatorSelector, UseAuthenticator } from './types';
2
2
  /**
3
3
  * [📖 Docs](https://ui.docs.amplify.aws/react/connected-components/authenticator/headless#useauthenticator-hook)
4
4
  */
5
- export default function useAuthenticator(selector?: Selector): UseAuthenticator;
5
+ export default function useAuthenticator(selector?: UseAuthenticatorSelector): UseAuthenticator;
@@ -1,15 +1,16 @@
1
- import { AmplifyUser, AuthenticatorRoute, AuthMachineState } from '@aws-amplify/ui';
2
- import { AuthenticatorRouteComponentKey, AuthenticatorLegacyFields, Comparator, Selector } from './types';
1
+ import { AmplifyUser, AuthenticatorRoute, AuthMachineState, UnverifiedContactMethods } from '@aws-amplify/ui';
2
+ import { AuthenticatorLegacyFields } from '../types';
3
+ import { Comparator, UseAuthenticatorSelector } from './types';
3
4
  export declare const defaultComparator: () => false;
4
5
  /**
5
6
  * Does an ordering and shallow comparison of each array value,
6
7
  * plus a value equality check for empty objects and arrays.
7
8
  */
8
9
  export declare function areSelectorDepsEqual<T>(currentDeps: T[], nextDeps: T[]): boolean;
9
- export declare const getComparator: (selector: Selector) => Comparator;
10
+ export declare const getComparator: (selector: UseAuthenticatorSelector) => Comparator;
10
11
  export declare const getTotpSecretCodeCallback: (user: AmplifyUser) => () => Promise<string>;
11
- export declare const isComponentRouteKey: (route: AuthenticatorRoute) => route is AuthenticatorRouteComponentKey;
12
12
  /**
13
- * Retrieves legacy form field values from state machine for routes that have fields
13
+ * Retrieves default and custom (RWA only, to be updated) form field values from state machine
14
+ * for subcomponent routes that render fields
14
15
  */
15
- export declare const getLegacyFields: (route: AuthenticatorRoute, state: AuthMachineState) => AuthenticatorLegacyFields;
16
+ export declare const getMachineFields: (route: AuthenticatorRoute, state: AuthMachineState, unverifiedContactMethods: UnverifiedContactMethods) => AuthenticatorLegacyFields;
@@ -0,0 +1 @@
1
+ export { default as useAuthenticatorInitMachine } from './useAuthenticatorInitMachine';
@@ -0,0 +1,4 @@
1
+ import { AuthenticatorMachineOptions } from '@aws-amplify/ui';
2
+ import { UseAuthenticatorSelector } from '../useAuthenticator';
3
+ export declare const routeSelector: UseAuthenticatorSelector;
4
+ export default function useAuthenticatorInitMachine(data: AuthenticatorMachineOptions): void;
@@ -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';
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { Message } from '../../types';
3
+ export interface InAppMessagingContextType {
4
+ clearMessage: () => void;
5
+ displayMessage: (message: Message) => void;
6
+ message: Message | null;
7
+ }
8
+ declare const InAppMessagingContext: import("react").Context<InAppMessagingContextType | null>;
9
+ export default InAppMessagingContext;
@@ -0,0 +1 @@
1
+ export { default as InAppMessagingContext, InAppMessagingContextType, } from './InAppMessagingContext';
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ export interface InAppMessagingProviderProps {
3
+ children: ReactNode;
4
+ }
5
+ export default function InAppMessagingProvider({ children, }: InAppMessagingProviderProps): JSX.Element;
@@ -0,0 +1 @@
1
+ export { default as InAppMessagingProvider } from './InAppMessagingProvider';
@@ -0,0 +1,2 @@
1
+ export * from './InAppMessagingContext';
2
+ export * from './InAppMessagingProvider';
@@ -0,0 +1,2 @@
1
+ export * from './useInAppMessaging';
2
+ export * from './useMessage';
@@ -0,0 +1 @@
1
+ export { default as useInAppMessaging } from './useInAppMessaging';
@@ -0,0 +1,7 @@
1
+ import { InAppMessagingContextType } from '../../context';
2
+ /**
3
+ * Utility hook used to access the InAppMessagingContext values
4
+ *
5
+ * @returns {InAppMessagingContextType} InAppMessaging context values
6
+ */
7
+ export default function useInAppMessaging(): InAppMessagingContextType;
@@ -0,0 +1 @@
1
+ export { default as useMessage } from './useMessage';
@@ -0,0 +1,18 @@
1
+ import { BannerMessageCommonProps, BannerMessageComponent, CarouselMessageCommonProps, CarouselMessageComponent, FullScreenMessageCommonProps, FullScreenMessageComponent, ModalMessageCommonProps, ModalMessageComponent, OnMessageAction } from '../../types';
2
+ interface Components<PlatformStyleProps> {
3
+ BannerMessage: BannerMessageComponent<PlatformStyleProps>;
4
+ CarouselMessage: CarouselMessageComponent<PlatformStyleProps>;
5
+ FullScreenMessage: FullScreenMessageComponent<PlatformStyleProps>;
6
+ ModalMessage: ModalMessageComponent<PlatformStyleProps>;
7
+ }
8
+ export interface UseMessageParams<PlatformStyleProps> {
9
+ components: Components<PlatformStyleProps>;
10
+ onMessageAction: OnMessageAction;
11
+ }
12
+ declare type MessageComponent<PlatformStyleProps> = BannerMessageComponent<PlatformStyleProps> | CarouselMessageComponent<PlatformStyleProps> | FullScreenMessageComponent<PlatformStyleProps> | ModalMessageComponent<PlatformStyleProps>;
13
+ declare type MessageProps<PlatformStyleProps> = BannerMessageCommonProps<PlatformStyleProps> | CarouselMessageCommonProps<PlatformStyleProps> | FullScreenMessageCommonProps<PlatformStyleProps> | ModalMessageCommonProps<PlatformStyleProps>;
14
+ export interface UseMessage<PlatformStyleProps> {
15
+ Component: MessageComponent<PlatformStyleProps>;
16
+ props: MessageProps<PlatformStyleProps>;
17
+ }
18
+ export {};
@@ -0,0 +1,9 @@
1
+ import { UseMessage, UseMessageParams } from './types';
2
+ export declare const EMPTY_PROPS: Readonly<{}>;
3
+ /**
4
+ * Utility hook for parsing a message and retrieving its corresponding UI component and props
5
+ *
6
+ * @param {UseMessageParams} props - platform specific UI components, action handler, and styles
7
+ * @returns {UseMessage} message UI component and props
8
+ */
9
+ export default function useMessage<PlatformStyleProps>({ components, onMessageAction, }: UseMessageParams<PlatformStyleProps>): UseMessage<PlatformStyleProps>;
@@ -0,0 +1,9 @@
1
+ import { BannerMessageLayouts, MessageAction, MessageComponentPosition, MessageContent, MessageContentProps, OnMessageAction } from '../../types';
2
+ export declare const getPositionProp: (layout: BannerMessageLayouts) => MessageComponentPosition;
3
+ export declare const getActionHandler: (actionParams: {
4
+ action: MessageAction;
5
+ url?: string;
6
+ }, onMessageAction: OnMessageAction, onActionCallback: () => void) => {
7
+ onAction: () => void;
8
+ };
9
+ export declare const getContentProps: (content: MessageContent, onMessageAction: OnMessageAction, onActionCallback: () => void) => MessageContentProps;
@@ -1,2 +1,4 @@
1
- export * from './context';
2
1
  export * from './hooks';
2
+ export * from './context';
3
+ export * from './types';
4
+ export * from './utils';
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { InAppMessage, InAppMessageAction, InAppMessageButton, InAppMessageContent, InAppMessageImage, InAppMessageLayout, InAppMessageStyle, InAppMessageTextAlign } from '@aws-amplify/notifications';
3
+ export declare type Message = InAppMessage;
4
+ export declare type MessageAction = InAppMessageAction;
5
+ export declare type MessageButton = InAppMessageButton;
6
+ export declare type MessageContent = InAppMessageContent;
7
+ export declare type MessageImage = InAppMessageImage;
8
+ export declare type MessageLayout = InAppMessageLayout;
9
+ export declare type MessageStyle = InAppMessageStyle;
10
+ export declare type MessageTextAlign = InAppMessageTextAlign;
11
+ export declare type OnMessageAction = (params: {
12
+ action: MessageAction;
13
+ url?: string | undefined;
14
+ }) => void;
15
+ export interface MessageButtonProps extends Omit<MessageButton, 'action' | 'url'> {
16
+ onAction: () => void;
17
+ }
18
+ export interface MessageContentProps extends Omit<MessageContent, 'primaryButton' | 'secondaryButton'> {
19
+ primaryButton?: MessageButtonProps;
20
+ secondaryButton?: MessageButtonProps;
21
+ }
22
+ export interface MessageComponentBaseProps<Style = unknown> extends MessageCommonProps<Style>, MessageContentProps {
23
+ }
24
+ export interface MessageCommonProps<PlatformStyleProps> {
25
+ layout: MessageLayout;
26
+ onClose?: () => void;
27
+ onDisplay?: () => void;
28
+ style?: PlatformStyleProps;
29
+ }
30
+ export declare type BannerMessageLayouts = 'BOTTOM_BANNER' | 'MIDDLE_BANNER' | 'TOP_BANNER';
31
+ export declare type MessageComponentPosition = 'bottom' | 'middle' | 'top';
32
+ export interface BannerMessageCommonProps<PlatformStyleProps> extends MessageCommonProps<PlatformStyleProps>, MessageContentProps {
33
+ position?: MessageComponentPosition;
34
+ }
35
+ export interface CarouselMessageCommonProps<PlatformStyleProps> extends MessageCommonProps<PlatformStyleProps> {
36
+ data?: MessageContentProps[];
37
+ }
38
+ export interface FullScreenMessageCommonProps<PlatformStyleProps> extends MessageCommonProps<PlatformStyleProps>, MessageContentProps {
39
+ }
40
+ export interface ModalMessageCommonProps<PlatformStyleProps> extends MessageCommonProps<PlatformStyleProps>, MessageContentProps {
41
+ }
42
+ export interface MessagePayloadStyle {
43
+ body?: MessageStyle;
44
+ container?: MessageStyle;
45
+ header?: MessageStyle;
46
+ primaryButton?: MessageStyle;
47
+ secondaryButton?: MessageStyle;
48
+ }
49
+ export declare type BannerMessageComponent<PlatformStyleProps> = React.ComponentType<BannerMessageCommonProps<PlatformStyleProps>>;
50
+ export declare type CarouselMessageComponent<PlatformStyleProps> = React.ComponentType<CarouselMessageCommonProps<PlatformStyleProps>>;
51
+ export declare type FullScreenMessageComponent<PlatformStyleProps> = React.ComponentType<FullScreenMessageCommonProps<PlatformStyleProps>>;
52
+ export declare type ModalMessageComponent<PlatformStyleProps> = React.ComponentType<ModalMessageCommonProps<PlatformStyleProps>>;
@@ -0,0 +1,9 @@
1
+ import { MessageAction } from '../types';
2
+ export declare type HandleMessageLinkAction = (url: string) => void | Promise<void>;
3
+ interface HandleMessageActionParams {
4
+ action: MessageAction;
5
+ handleMessageLinkAction: HandleMessageLinkAction;
6
+ url: string | undefined;
7
+ }
8
+ declare const handleMessageAction: ({ action, handleMessageLinkAction, url, }: HandleMessageActionParams) => void;
9
+ export default handleMessageAction;
@@ -0,0 +1 @@
1
+ export { default as handleMessageAction, HandleMessageLinkAction, } from './handleMessageAction';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Utility component for rendering nothing.
3
+ */
4
+ export default function RenderNothing<Props>(_: Props): JSX.Element | null;
@@ -0,0 +1 @@
1
+ export { default as RenderNothing } from './RenderNothing';
@@ -0,0 +1 @@
1
+ export { RenderNothing } from './RenderNothing';
@@ -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 +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
+ 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';
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-core",
3
- "version": "1.0.5",
3
+ "version": "2.1.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.js",
6
+ "react-native": "dist/index.js",
6
7
  "exports": {
7
8
  ".": {
8
9
  "import": "./dist/esm/index.js",
@@ -19,8 +20,7 @@
19
20
  "scripts": {
20
21
  "clean": "rimraf dist node_modules",
21
22
  "prebuild": "rimraf dist",
22
- "build": "yarn build:cjs && yarn build:esm",
23
- "build:cjs": "tsc --project tsconfig.cjs.json",
23
+ "build": "rollup --config",
24
24
  "build:esm": "tsc --project tsconfig.esm.json",
25
25
  "dev": "yarn build:esm --watch",
26
26
  "lint": "tsc --noEmit && eslint src",
@@ -28,16 +28,18 @@
28
28
  "test:watch": "yarn test --watch"
29
29
  },
30
30
  "dependencies": {
31
- "@aws-amplify/ui": "4.1.0",
31
+ "@aws-amplify/ui": "5.1.0",
32
32
  "@xstate/react": "3.0.1",
33
+ "lodash": "4.17.21",
33
34
  "xstate": "^4.33.6"
34
35
  },
35
36
  "peerDependencies": {
36
- "aws-amplify": "3.x.x || 4.x.x",
37
- "react": ">= 16.8.0",
38
- "react-dom": ">= 16.8.0"
37
+ "aws-amplify": ">= 5.0.1",
38
+ "react": ">= 16.14.0"
39
39
  },
40
40
  "devDependencies": {
41
+ "@rollup/plugin-commonjs": "^22.0.1",
42
+ "@rollup/plugin-typescript": "^8.3.1",
41
43
  "@testing-library/react": "^12.0.0",
42
44
  "@testing-library/react-hooks": "^7.0.2",
43
45
  "@types/jest": "^26.0.23",
@@ -60,8 +62,11 @@
60
62
  "react-dom": "^17.0.2",
61
63
  "react-test-renderer": "^17.0.2",
62
64
  "rimraf": "^3.0.2",
65
+ "rollup": "^2.70.0",
66
+ "rollup-plugin-node-externals": "^4.1.1",
63
67
  "ts-jest": "^27.1.3",
64
68
  "ts-node": "^10.2.1",
65
69
  "typescript": "^4.3.2"
66
- }
70
+ },
71
+ "sideEffects": false
67
72
  }