@aws-amplify/ui-react-core 2.1.19 → 2.1.21

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.
@@ -1,9 +1,29 @@
1
+ import { __awaiter } from '../../node_modules/tslib/tslib.es6.mjs';
1
2
  import React, { useContext, useMemo, useEffect } from 'react';
2
3
  import { useInterpret } from '@xstate/react';
3
- import { createAuthenticatorMachine, listenToAuthHub } from '@aws-amplify/ui';
4
+ import { Auth } from 'aws-amplify';
5
+ import { createAuthenticatorMachine, listenToAuthHub, defaultAuthHubHandler } from '@aws-amplify/ui';
4
6
  import { AuthenticatorContext } from './AuthenticatorContext.mjs';
5
7
 
8
+ const createHubHandler = (options) => (data, service) => __awaiter(void 0, void 0, void 0, function* () {
9
+ yield defaultAuthHubHandler(data, service, options);
10
+ });
6
11
  function AuthenticatorProvider({ children, }) {
12
+ // `authStatus` is exposed by `useAuthenticator` but should not be derived directly from the
13
+ // state machine as the machine only updates on `Authenticator` initiated events, which
14
+ // leads to scenarios where the state machine `authStatus` gets "stuck". For exmample,
15
+ // if a user was to sign in using `Auth.signIn` directly rather than using `Authenticator`
16
+ const [authStatus, setAuthStatus] = React.useState('configuring');
17
+ // only run on first render
18
+ React.useEffect(() => {
19
+ Auth.currentAuthenticatedUser()
20
+ .then(() => {
21
+ setAuthStatus('authenticated');
22
+ })
23
+ .catch(() => {
24
+ setAuthStatus('unauthenticated');
25
+ });
26
+ }, []);
7
27
  /**
8
28
  * Based on use cases, developer might already have added another Provider
9
29
  * outside Authenticator. In that case, we sync the two providers by just
@@ -13,10 +33,16 @@ function AuthenticatorProvider({ children, }) {
13
33
  */
14
34
  const parentProviderVal = useContext(AuthenticatorContext);
15
35
  const service = useInterpret(createAuthenticatorMachine);
16
- const value = useMemo(() => (!parentProviderVal ? { service } : parentProviderVal), [parentProviderVal, service]);
36
+ const value = useMemo(() => (!parentProviderVal ? { authStatus, service } : parentProviderVal), [authStatus, parentProviderVal, service]);
17
37
  const { service: activeService } = value;
18
38
  useEffect(() => {
19
- const unsubscribe = listenToAuthHub(activeService);
39
+ const onSignIn = () => {
40
+ setAuthStatus('authenticated');
41
+ };
42
+ const onSignOut = () => {
43
+ setAuthStatus('unauthenticated');
44
+ };
45
+ const unsubscribe = listenToAuthHub(activeService, createHubHandler({ onSignIn, onSignOut }));
20
46
  return unsubscribe;
21
47
  }, [activeService]);
22
48
  return (React.createElement(AuthenticatorContext.Provider, { value: value }, children));
@@ -2,6 +2,7 @@ import { __rest } from '../../../node_modules/tslib/tslib.es6.mjs';
2
2
  import React, { useCallback } from 'react';
3
3
  import { useSelector } from '@xstate/react';
4
4
  import { getServiceFacade } from '@aws-amplify/ui';
5
+ import 'aws-amplify';
5
6
  import { AuthenticatorContext } from '../../context/AuthenticatorContext.mjs';
6
7
  import { USE_AUTHENTICATOR_ERROR } from './constants.mjs';
7
8
  import { getQRFields, getMachineFields, getTotpSecretCodeCallback, getComparator, defaultComparator } from './utils.mjs';
@@ -18,6 +19,9 @@ function useAuthenticator(selector) {
18
19
  const { send } = service;
19
20
  const xstateSelector = useCallback((state) => (Object.assign({}, getServiceFacade({ send, state }))), [send]);
20
21
  const comparator = selector ? getComparator(selector) : defaultComparator;
22
+ // the purpose of `context.authStatus`is to intentionally override `facade.authStatus`. `facade.authStatus` does
23
+ // not update on external sign in events (for example when a user is not using the `Authenticator`).
24
+ const { authStatus } = context;
21
25
  const facade = useSelector(service, xstateSelector, comparator);
22
26
  const { route, totpSecretCode, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "totpSecretCode", "unverifiedContactMethods", "user"]);
23
27
  // do not memoize output. `service.getSnapshot` reference remains stable preventing
@@ -27,7 +31,8 @@ function useAuthenticator(selector) {
27
31
  const QRFields = route === 'setupTOTP' ? getQRFields(serviceSnapshot) : null;
28
32
  // legacy `formFields` values required until form state is removed from state machine
29
33
  const fields = getMachineFields(route, serviceSnapshot, unverifiedContactMethods);
30
- return Object.assign(Object.assign({}, rest), { route,
34
+ return Object.assign(Object.assign({}, rest), { authStatus,
35
+ route,
31
36
  totpSecretCode,
32
37
  unverifiedContactMethods,
33
38
  user,
package/dist/index.js CHANGED
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
  var react = require('@xstate/react');
7
- var ui = require('@aws-amplify/ui');
8
7
  var awsAmplify = require('aws-amplify');
8
+ var ui = require('@aws-amplify/ui');
9
9
  var notifications = require('@aws-amplify/notifications');
10
10
  var core = require('@aws-amplify/core');
11
11
 
@@ -13,32 +13,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
13
13
 
14
14
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
15
15
 
16
- /**
17
- * AuthenticatorContext serves static reference to the auth machine service.
18
- *
19
- * https://xstate.js.org/docs/recipes/react.html#context-provider
20
- */
21
- const AuthenticatorContext = React__default["default"].createContext(null);
22
-
23
- function AuthenticatorProvider({ children, }) {
24
- /**
25
- * Based on use cases, developer might already have added another Provider
26
- * outside Authenticator. In that case, we sync the two providers by just
27
- * passing the parent value.
28
- *
29
- * TODO(BREAKING): enforce only one provider in App tree
30
- */
31
- const parentProviderVal = React.useContext(AuthenticatorContext);
32
- const service = react.useInterpret(ui.createAuthenticatorMachine);
33
- const value = React.useMemo(() => (!parentProviderVal ? { service } : parentProviderVal), [parentProviderVal, service]);
34
- const { service: activeService } = value;
35
- React.useEffect(() => {
36
- const unsubscribe = ui.listenToAuthHub(activeService);
37
- return unsubscribe;
38
- }, [activeService]);
39
- return (React__default["default"].createElement(AuthenticatorContext.Provider, { value: value }, children));
40
- }
41
-
42
16
  /******************************************************************************
43
17
  Copyright (c) Microsoft Corporation.
44
18
 
@@ -76,6 +50,56 @@ function __awaiter(thisArg, _arguments, P, generator) {
76
50
  });
77
51
  }
78
52
 
53
+ /**
54
+ * AuthenticatorContext serves static reference to the auth machine service.
55
+ *
56
+ * https://xstate.js.org/docs/recipes/react.html#context-provider
57
+ */
58
+ const AuthenticatorContext = React__default["default"].createContext(null);
59
+
60
+ const createHubHandler = (options) => (data, service) => __awaiter(void 0, void 0, void 0, function* () {
61
+ yield ui.defaultAuthHubHandler(data, service, options);
62
+ });
63
+ function AuthenticatorProvider({ children, }) {
64
+ // `authStatus` is exposed by `useAuthenticator` but should not be derived directly from the
65
+ // state machine as the machine only updates on `Authenticator` initiated events, which
66
+ // leads to scenarios where the state machine `authStatus` gets "stuck". For exmample,
67
+ // if a user was to sign in using `Auth.signIn` directly rather than using `Authenticator`
68
+ const [authStatus, setAuthStatus] = React__default["default"].useState('configuring');
69
+ // only run on first render
70
+ React__default["default"].useEffect(() => {
71
+ awsAmplify.Auth.currentAuthenticatedUser()
72
+ .then(() => {
73
+ setAuthStatus('authenticated');
74
+ })
75
+ .catch(() => {
76
+ setAuthStatus('unauthenticated');
77
+ });
78
+ }, []);
79
+ /**
80
+ * Based on use cases, developer might already have added another Provider
81
+ * outside Authenticator. In that case, we sync the two providers by just
82
+ * passing the parent value.
83
+ *
84
+ * TODO(BREAKING): enforce only one provider in App tree
85
+ */
86
+ const parentProviderVal = React.useContext(AuthenticatorContext);
87
+ const service = react.useInterpret(ui.createAuthenticatorMachine);
88
+ const value = React.useMemo(() => (!parentProviderVal ? { authStatus, service } : parentProviderVal), [authStatus, parentProviderVal, service]);
89
+ const { service: activeService } = value;
90
+ React.useEffect(() => {
91
+ const onSignIn = () => {
92
+ setAuthStatus('authenticated');
93
+ };
94
+ const onSignOut = () => {
95
+ setAuthStatus('unauthenticated');
96
+ };
97
+ const unsubscribe = ui.listenToAuthHub(activeService, createHubHandler({ onSignIn, onSignOut }));
98
+ return unsubscribe;
99
+ }, [activeService]);
100
+ return (React__default["default"].createElement(AuthenticatorContext.Provider, { value: value }, children));
101
+ }
102
+
79
103
  const USE_AUTHENTICATOR_ERROR = '`useAuthenticator` must be used inside an `Authenticator.Provider`.';
80
104
 
81
105
  const COMPONENT_ROUTE_KEYS = [
@@ -193,6 +217,9 @@ function useAuthenticator(selector) {
193
217
  const { send } = service;
194
218
  const xstateSelector = React.useCallback((state) => (Object.assign({}, ui.getServiceFacade({ send, state }))), [send]);
195
219
  const comparator = selector ? getComparator(selector) : defaultComparator;
220
+ // the purpose of `context.authStatus`is to intentionally override `facade.authStatus`. `facade.authStatus` does
221
+ // not update on external sign in events (for example when a user is not using the `Authenticator`).
222
+ const { authStatus } = context;
196
223
  const facade = react.useSelector(service, xstateSelector, comparator);
197
224
  const { route, totpSecretCode, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "totpSecretCode", "unverifiedContactMethods", "user"]);
198
225
  // do not memoize output. `service.getSnapshot` reference remains stable preventing
@@ -202,7 +229,8 @@ function useAuthenticator(selector) {
202
229
  const QRFields = route === 'setupTOTP' ? getQRFields(serviceSnapshot) : null;
203
230
  // legacy `formFields` values required until form state is removed from state machine
204
231
  const fields = getMachineFields(route, serviceSnapshot, unverifiedContactMethods);
205
- return Object.assign(Object.assign({}, rest), { route,
232
+ return Object.assign(Object.assign({}, rest), { authStatus,
233
+ route,
206
234
  totpSecretCode,
207
235
  unverifiedContactMethods,
208
236
  user,
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { AuthInterpreter } from '@aws-amplify/ui';
2
+ import { AuthInterpreter, AuthStatus } from '@aws-amplify/ui';
3
3
  /**
4
4
  * Authenticator React.Context type
5
5
  */
6
- declare type AuthenticatorContextType = {
6
+ type AuthenticatorContextType = {
7
7
  service: AuthInterpreter;
8
8
  };
9
9
  /**
@@ -11,5 +11,7 @@ declare type AuthenticatorContextType = {
11
11
  *
12
12
  * https://xstate.js.org/docs/recipes/react.html#context-provider
13
13
  */
14
- export declare const AuthenticatorContext: React.Context<AuthenticatorContextType | null>;
14
+ export declare const AuthenticatorContext: React.Context<(AuthenticatorContextType & {
15
+ authStatus: AuthStatus;
16
+ }) | null>;
15
17
  export {};
@@ -1,31 +1,31 @@
1
1
  import React from 'react';
2
2
  import { AuthChallengeName, AuthenticatorServiceFacade, LegacyFormFieldOptions } from '@aws-amplify/ui';
3
3
  import { UseAuthenticator } from './useAuthenticator';
4
- export declare type AuthenticatorRouteComponentKey = 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'forceNewPassword' | 'resetPassword' | 'setupTOTP' | 'signIn' | 'signUp' | 'verifyUser';
5
- export declare type AuthenticatorLegacyField = LegacyFormFieldOptions;
6
- export declare type AuthenticatorLegacyFields = AuthenticatorLegacyField[];
4
+ export type AuthenticatorRouteComponentKey = 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'forceNewPassword' | 'resetPassword' | 'setupTOTP' | 'signIn' | 'signUp' | 'verifyUser';
5
+ export type AuthenticatorLegacyField = LegacyFormFieldOptions;
6
+ export type AuthenticatorLegacyFields = AuthenticatorLegacyField[];
7
7
  /**
8
8
  * These are the "facades" that we provide, which contains contexts respective
9
9
  * to current authenticator state.
10
10
  */
11
- export declare type AuthenticatorMachineContext = AuthenticatorServiceFacade;
12
- export declare type AuthenticatorMachineContextKey = keyof AuthenticatorMachineContext;
13
- export declare type AuthenticatorRouteComponentName = Capitalize<AuthenticatorRouteComponentKey>;
11
+ export type AuthenticatorMachineContext = AuthenticatorServiceFacade;
12
+ export type AuthenticatorMachineContextKey = keyof AuthenticatorMachineContext;
13
+ export type AuthenticatorRouteComponentName = Capitalize<AuthenticatorRouteComponentKey>;
14
14
  interface HeaderProps {
15
15
  children?: React.ReactNode;
16
16
  }
17
17
  interface FooterProps {
18
18
  children?: React.ReactNode;
19
19
  }
20
- declare type FormFieldsProps = {
20
+ type FormFieldsProps = {
21
21
  isPending: UseAuthenticator['isPending'];
22
22
  validationErrors?: UseAuthenticator['validationErrors'];
23
23
  };
24
- export declare type FooterComponent<Props = {}> = React.ComponentType<FooterProps & Props>;
25
- export declare type FormFieldsComponent<FieldType, Props = {}> = React.ComponentType<FormFieldsProps & {
24
+ export type FooterComponent<Props = {}> = React.ComponentType<FooterProps & Props>;
25
+ export type FormFieldsComponent<FieldType, Props = {}> = React.ComponentType<FormFieldsProps & {
26
26
  fields: FieldType[];
27
27
  } & Props>;
28
- export declare type HeaderComponent<Props = {}> = React.ComponentType<HeaderProps & Props>;
28
+ export type HeaderComponent<Props = {}> = React.ComponentType<HeaderProps & Props>;
29
29
  export interface ComponentSlots<FieldType = {}> {
30
30
  Footer: FooterComponent;
31
31
  Header: HeaderComponent;
@@ -34,7 +34,7 @@ export interface ComponentSlots<FieldType = {}> {
34
34
  /**
35
35
  * Common component prop types used for both RWA and RNA implementations
36
36
  */
37
- export declare type CommonRouteProps = {
37
+ export type CommonRouteProps = {
38
38
  error?: UseAuthenticator['error'];
39
39
  isPending: UseAuthenticator['isPending'];
40
40
  handleBlur: UseAuthenticator['updateBlur'];
@@ -44,45 +44,45 @@ export declare type CommonRouteProps = {
44
44
  /**
45
45
  * Base Route component props
46
46
  */
47
- export declare type ConfirmResetPasswordBaseProps<FieldType = {}> = {
47
+ export type ConfirmResetPasswordBaseProps<FieldType = {}> = {
48
48
  resendCode: UseAuthenticator['resendCode'];
49
49
  validationErrors?: UseAuthenticator['validationErrors'];
50
50
  } & CommonRouteProps & ComponentSlots<FieldType>;
51
- export declare type ConfirmSignInBaseProps<FieldType = {}> = {
51
+ export type ConfirmSignInBaseProps<FieldType = {}> = {
52
52
  challengeName: AuthChallengeName;
53
53
  toSignIn: UseAuthenticator['toSignIn'];
54
54
  } & CommonRouteProps & ComponentSlots<FieldType>;
55
- export declare type ConfirmSignUpBaseProps<FieldType = {}> = {
55
+ export type ConfirmSignUpBaseProps<FieldType = {}> = {
56
56
  codeDeliveryDetails: UseAuthenticator['codeDeliveryDetails'];
57
57
  resendCode: UseAuthenticator['resendCode'];
58
58
  } & CommonRouteProps & ComponentSlots<FieldType>;
59
- export declare type ConfirmVerifyUserProps<FieldType = {}> = {
59
+ export type ConfirmVerifyUserProps<FieldType = {}> = {
60
60
  skipVerification: UseAuthenticator['skipVerification'];
61
61
  } & CommonRouteProps & ComponentSlots<FieldType>;
62
- export declare type ForceResetPasswordBaseProps<FieldType = {}> = {
62
+ export type ForceResetPasswordBaseProps<FieldType = {}> = {
63
63
  toSignIn: UseAuthenticator['toSignIn'];
64
64
  validationErrors?: UseAuthenticator['validationErrors'];
65
65
  } & CommonRouteProps & ComponentSlots<FieldType>;
66
- export declare type ResetPasswordBaseProps<FieldType = {}> = {
66
+ export type ResetPasswordBaseProps<FieldType = {}> = {
67
67
  toSignIn: UseAuthenticator['toSignIn'];
68
68
  } & CommonRouteProps & ComponentSlots<FieldType>;
69
- export declare type SetupTOTPBaseProps<FieldType = {}> = {
69
+ export type SetupTOTPBaseProps<FieldType = {}> = {
70
70
  toSignIn: UseAuthenticator['toSignIn'];
71
71
  totpSecretCode: UseAuthenticator['totpSecretCode'];
72
72
  } & CommonRouteProps & ComponentSlots<FieldType>;
73
- export declare type SignInBaseProps<FieldType = {}> = {
73
+ export type SignInBaseProps<FieldType = {}> = {
74
74
  hideSignUp?: boolean;
75
75
  toFederatedSignIn: UseAuthenticator['toFederatedSignIn'];
76
76
  toResetPassword: UseAuthenticator['toResetPassword'];
77
77
  toSignUp: UseAuthenticator['toSignUp'];
78
78
  } & CommonRouteProps & ComponentSlots<FieldType>;
79
- export declare type SignUpBaseProps<FieldType = {}> = {
79
+ export type SignUpBaseProps<FieldType = {}> = {
80
80
  hideSignIn?: boolean;
81
81
  toFederatedSignIn: UseAuthenticator['toFederatedSignIn'];
82
82
  toSignIn: UseAuthenticator['toSignIn'];
83
83
  validationErrors?: UseAuthenticator['validationErrors'];
84
84
  } & CommonRouteProps & ComponentSlots<FieldType>;
85
- export declare type VerifyUserProps<FieldType = {}> = {
85
+ export type VerifyUserProps<FieldType = {}> = {
86
86
  skipVerification: UseAuthenticator['skipVerification'];
87
87
  } & CommonRouteProps & ComponentSlots<FieldType>;
88
88
  export interface DefaultProps<FieldType = {}> {
@@ -100,24 +100,24 @@ export interface DefaultProps<FieldType = {}> {
100
100
  /**
101
101
  * common types extended for default component types/implementations and override component types
102
102
  */
103
- declare type BaseComponent<ComponentRouteProps = {}, FieldType = {}, Props = {}> = React.ComponentType<ComponentSlots<FieldType> & ComponentRouteProps & {
103
+ type BaseComponent<ComponentRouteProps = {}, FieldType = {}, Props = {}> = React.ComponentType<ComponentSlots<FieldType> & ComponentRouteProps & {
104
104
  fields: FieldType[];
105
105
  } & Props>;
106
106
  /**
107
107
  * Authenticator Route Component Default types
108
108
  */
109
- export declare type Defaults<FieldType = {}, PlatformProps = {}> = {
109
+ export type Defaults<FieldType = {}, PlatformProps = {}> = {
110
110
  [Key in AuthenticatorRouteComponentName]: BaseComponent<DefaultProps<FieldType>[Key], FieldType, PlatformProps> & ComponentSlots<FieldType>;
111
111
  };
112
- export declare type Overrides<FieldType = {}, PlatformProps = {}> = {
112
+ export type Overrides<FieldType = {}, PlatformProps = {}> = {
113
113
  [Key in AuthenticatorRouteComponentName]?: BaseComponent<DefaultProps<FieldType>[Key], FieldType, PlatformProps>;
114
114
  };
115
115
  /**
116
116
  * Default Route Component union type
117
117
  */
118
- export declare type DefaultComponentType<FieldType = {}> = Defaults<FieldType>[keyof Defaults<FieldType>];
118
+ export type DefaultComponentType<FieldType = {}> = Defaults<FieldType>[keyof Defaults<FieldType>];
119
119
  /**
120
120
  * Default Route Component union type
121
121
  */
122
- export declare type DefaultPropsType<FieldType = {}> = DefaultProps<FieldType>[keyof DefaultProps<FieldType>];
122
+ export type DefaultPropsType<FieldType = {}> = DefaultProps<FieldType>[keyof DefaultProps<FieldType>];
123
123
  export {};
@@ -3,17 +3,17 @@ import { AuthenticatorServiceFacade, LegacyFormFieldOptions } from '@aws-amplify
3
3
  * These are the "facades" that we provide, which contains contexts respective
4
4
  * to current authenticator state.
5
5
  */
6
- declare type AuthenticatorMachineContext = AuthenticatorServiceFacade;
7
- declare type AuthenticatorMachineContextKey = keyof AuthenticatorMachineContext;
8
- export declare type AuthenticatorRouteComponentKey = 'signIn' | 'signUp' | 'forceNewPassword' | 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'resetPassword' | 'setupTOTP' | 'verifyUser';
9
- export declare type AuthenticatorLegacyFields = LegacyFormFieldOptions[];
6
+ type AuthenticatorMachineContext = AuthenticatorServiceFacade;
7
+ type AuthenticatorMachineContextKey = keyof AuthenticatorMachineContext;
8
+ export type AuthenticatorRouteComponentKey = 'signIn' | 'signUp' | 'forceNewPassword' | 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'resetPassword' | 'setupTOTP' | 'verifyUser';
9
+ export type AuthenticatorLegacyFields = LegacyFormFieldOptions[];
10
10
  /**
11
11
  * Inspired from https://xstate.js.org/docs/packages/xstate-react/#useselector-actor-selector-compare-getsnapshot.
12
12
  *
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 UseAuthenticatorSelector = (context: AuthenticatorMachineContext) => AuthenticatorMachineContext[AuthenticatorMachineContextKey][];
16
+ export type UseAuthenticatorSelector = (context: AuthenticatorMachineContext) => AuthenticatorMachineContext[AuthenticatorMachineContextKey][];
17
17
  export interface UseAuthenticator extends AuthenticatorServiceFacade {
18
18
  /** @deprecated For internal use only */
19
19
  fields: AuthenticatorLegacyFields;
@@ -25,5 +25,5 @@ export interface UseAuthenticator extends AuthenticatorServiceFacade {
25
25
  totpUsername?: string;
26
26
  } | null;
27
27
  }
28
- export declare type Comparator = (currentMachineContext: AuthenticatorMachineContext, nextMachineContext: AuthenticatorMachineContext) => boolean;
28
+ export type Comparator = (currentMachineContext: AuthenticatorMachineContext, nextMachineContext: AuthenticatorMachineContext) => boolean;
29
29
  export {};
@@ -1,36 +1,36 @@
1
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> = {
2
+ export type UseAuthenticatorRouteParams<FieldType> = {
3
3
  components: Defaults<FieldType>;
4
4
  };
5
- export declare type UseAuthenticatorRoute<ComponentName extends AuthenticatorRouteComponentName, FieldType = {}> = {
5
+ export type UseAuthenticatorRoute<ComponentName extends AuthenticatorRouteComponentName, FieldType = {}> = {
6
6
  Component: Defaults<FieldType>[ComponentName];
7
7
  props: DefaultProps<FieldType>[ComponentName];
8
8
  };
9
- export declare type UseAuthenticatorRouteDefault<FieldType> = {
9
+ export type UseAuthenticatorRouteDefault<FieldType> = {
10
10
  Component: Defaults<FieldType>[AuthenticatorRouteComponentName];
11
11
  props: DefaultProps<FieldType>[AuthenticatorRouteComponentName];
12
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;
13
+ type ExtractMachineKey<RouteProps> = Extract<AuthenticatorMachineContextKey, keyof RouteProps>;
14
+ export type FormEventHandlerMachineKey = 'updateBlur' | 'updateForm' | 'submitForm';
15
+ export type FormEventHandlerPropKey = `handleBlur` | `handleChange` | `handleSubmit`;
16
+ export type CommonRouteMachineKey = ExtractMachineKey<CommonRouteProps> | FormEventHandlerMachineKey;
17
17
  /**
18
18
  * `route` sub-component machine selector key types
19
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;
20
+ export type ConfirmResetPasswordMachineKey = ExtractMachineKey<ConfirmResetPasswordBaseProps> | CommonRouteMachineKey;
21
+ export type ConfirmSignInMachineKey = ExtractMachineKey<ConfirmSignInBaseProps> | CommonRouteMachineKey | 'user';
22
+ export type ConfirmSignUpMachineKey = ExtractMachineKey<ConfirmSignUpBaseProps> | CommonRouteMachineKey;
23
+ export type ConfirmVerifyUserMachineKey = ExtractMachineKey<ConfirmVerifyUserProps> | CommonRouteMachineKey;
24
+ export type ForceNewPasswordMachineKey = ExtractMachineKey<ForceResetPasswordBaseProps> | CommonRouteMachineKey;
25
+ export type ResetPasswordMachineKey = ExtractMachineKey<ResetPasswordBaseProps> | CommonRouteMachineKey;
26
+ export type SetupTOTPMachineKey = ExtractMachineKey<SetupTOTPBaseProps> | CommonRouteMachineKey;
27
+ export type SignInMachineKey = ExtractMachineKey<SignInBaseProps> | CommonRouteMachineKey;
28
+ export type SignUpMachineKey = ExtractMachineKey<SignUpBaseProps> | CommonRouteMachineKey;
29
+ export type VerifyUserMachineKey = ExtractMachineKey<VerifyUserProps> | CommonRouteMachineKey;
30
30
  /**
31
31
  * machine values with machine form event handlers keys mapped to UI form event handlers
32
32
  */
33
- export declare type ConvertedMachineProps = Omit<AuthenticatorMachineContext, FormEventHandlerMachineKey> & {
33
+ export type ConvertedMachineProps = Omit<AuthenticatorMachineContext, FormEventHandlerMachineKey> & {
34
34
  handleBlur: AuthenticatorMachineContext['updateBlur'];
35
35
  handleChange: AuthenticatorMachineContext['updateForm'];
36
36
  handleSubmit: AuthenticatorMachineContext['submitForm'];
@@ -9,8 +9,8 @@ export interface UseMessageParams<PlatformStyleProps> {
9
9
  components: Components<PlatformStyleProps>;
10
10
  onMessageAction: OnMessageAction;
11
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>;
12
+ type MessageComponent<PlatformStyleProps> = BannerMessageComponent<PlatformStyleProps> | CarouselMessageComponent<PlatformStyleProps> | FullScreenMessageComponent<PlatformStyleProps> | ModalMessageComponent<PlatformStyleProps>;
13
+ type MessageProps<PlatformStyleProps> = BannerMessageCommonProps<PlatformStyleProps> | CarouselMessageCommonProps<PlatformStyleProps> | FullScreenMessageCommonProps<PlatformStyleProps> | ModalMessageCommonProps<PlatformStyleProps>;
14
14
  export interface UseMessage<PlatformStyleProps> {
15
15
  Component: MessageComponent<PlatformStyleProps>;
16
16
  props: MessageProps<PlatformStyleProps>;
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
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: {
3
+ export type Message = InAppMessage;
4
+ export type MessageAction = InAppMessageAction;
5
+ export type MessageButton = InAppMessageButton;
6
+ export type MessageContent = InAppMessageContent;
7
+ export type MessageImage = InAppMessageImage;
8
+ export type MessageLayout = InAppMessageLayout;
9
+ export type MessageStyle = InAppMessageStyle;
10
+ export type MessageTextAlign = InAppMessageTextAlign;
11
+ export type OnMessageAction = (params: {
12
12
  action: MessageAction;
13
13
  url?: string | undefined;
14
14
  }) => void;
@@ -27,8 +27,8 @@ export interface MessageCommonProps<PlatformStyleProps> {
27
27
  onDisplay?: () => void;
28
28
  style?: PlatformStyleProps;
29
29
  }
30
- export declare type BannerMessageLayouts = 'BOTTOM_BANNER' | 'MIDDLE_BANNER' | 'TOP_BANNER';
31
- export declare type MessageComponentPosition = 'bottom' | 'middle' | 'top';
30
+ export type BannerMessageLayouts = 'BOTTOM_BANNER' | 'MIDDLE_BANNER' | 'TOP_BANNER';
31
+ export type MessageComponentPosition = 'bottom' | 'middle' | 'top';
32
32
  export interface BannerMessageCommonProps<PlatformStyleProps> extends MessageCommonProps<PlatformStyleProps>, MessageContentProps {
33
33
  position?: MessageComponentPosition;
34
34
  }
@@ -46,7 +46,7 @@ export interface MessagePayloadStyle {
46
46
  primaryButton?: MessageStyle;
47
47
  secondaryButton?: MessageStyle;
48
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>>;
49
+ export type BannerMessageComponent<PlatformStyleProps> = React.ComponentType<BannerMessageCommonProps<PlatformStyleProps>>;
50
+ export type CarouselMessageComponent<PlatformStyleProps> = React.ComponentType<CarouselMessageCommonProps<PlatformStyleProps>>;
51
+ export type FullScreenMessageComponent<PlatformStyleProps> = React.ComponentType<FullScreenMessageCommonProps<PlatformStyleProps>>;
52
+ export type ModalMessageComponent<PlatformStyleProps> = React.ComponentType<ModalMessageCommonProps<PlatformStyleProps>>;
@@ -1,5 +1,5 @@
1
1
  import { MessageAction } from '../types';
2
- export declare type HandleMessageLinkAction = (url: string) => void | Promise<void>;
2
+ export type HandleMessageLinkAction = (url: string) => void | Promise<void>;
3
3
  interface HandleMessageActionParams {
4
4
  action: MessageAction;
5
5
  handleMessageLinkAction: HandleMessageLinkAction;
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-core",
3
- "version": "2.1.19",
3
+ "version": "2.1.21",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "react-native": "dist/index.js",
7
7
  "exports": {
8
8
  ".": {
9
9
  "import": "./dist/esm/index.mjs",
10
- "require": "./dist/index.js"
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/types/index.d.ts"
11
12
  },
12
13
  "./package.json": "./package.json"
13
14
  },
@@ -30,7 +31,7 @@
30
31
  "typecheck": "tsc --noEmit"
31
32
  },
32
33
  "dependencies": {
33
- "@aws-amplify/ui": "5.6.0",
34
+ "@aws-amplify/ui": "5.6.2",
34
35
  "@xstate/react": "3.0.1",
35
36
  "lodash": "4.17.21",
36
37
  "xstate": "^4.33.6"
@@ -40,6 +41,7 @@
40
41
  "react": ">= 16.14.0"
41
42
  },
42
43
  "devDependencies": {
44
+ "@aws-amplify/eslint-config-amplify-ui": "0.0.0",
43
45
  "@rollup/plugin-typescript": "^8.3.1",
44
46
  "@testing-library/react": "^12.0.0",
45
47
  "@testing-library/react-hooks": "^7.0.2",
@@ -48,7 +50,6 @@
48
50
  "@types/react-dom": "^17.0.13",
49
51
  "@types/react-test-renderer": "^17.0.1",
50
52
  "eslint": "^8.4.1",
51
- "eslint-config-amplify-ui": "0.0.0",
52
53
  "jest": "^27.0.4",
53
54
  "prettier": "2.4.1",
54
55
  "react": "^17.0.2",