@aws-amplify/ui-react-core 2.1.9 → 2.1.11

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 (29) hide show
  1. package/dist/esm/Authenticator/context/{AuthenticatorContext.js → AuthenticatorContext.mjs} +0 -0
  2. package/dist/esm/Authenticator/context/{AuthenticatorProvider.js → AuthenticatorProvider.mjs} +3 -4
  3. package/dist/esm/Authenticator/hooks/{constants.js → constants.mjs} +0 -0
  4. package/dist/esm/Authenticator/hooks/useAuthenticator/{constants.js → constants.mjs} +0 -0
  5. package/dist/esm/Authenticator/hooks/useAuthenticator/{useAuthenticator.js → useAuthenticator.mjs} +11 -13
  6. package/dist/esm/Authenticator/hooks/useAuthenticator/{utils.js → utils.mjs} +5 -8
  7. package/dist/esm/Authenticator/hooks/useAuthenticatorInitMachine/{useAuthenticatorInitMachine.js → useAuthenticatorInitMachine.mjs} +1 -1
  8. package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/{constants.js → constants.mjs} +1 -0
  9. package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/{useAuthenticatorRoute.js → useAuthenticatorRoute.mjs} +2 -2
  10. package/dist/esm/Authenticator/hooks/useAuthenticatorRoute/{utils.js → utils.mjs} +6 -7
  11. package/dist/esm/Authenticator/hooks/{utils.js → utils.mjs} +1 -1
  12. package/dist/esm/InAppMessaging/context/InAppMessagingContext/{InAppMessagingContext.js → InAppMessagingContext.mjs} +0 -0
  13. package/dist/esm/InAppMessaging/context/InAppMessagingProvider/{InAppMessagingProvider.js → InAppMessagingProvider.mjs} +3 -4
  14. package/dist/esm/InAppMessaging/hooks/useInAppMessaging/{useInAppMessaging.js → useInAppMessaging.mjs} +1 -2
  15. package/dist/esm/InAppMessaging/hooks/useMessage/{useMessage.js → useMessage.mjs} +4 -4
  16. package/dist/esm/InAppMessaging/hooks/useMessage/{utils.js → utils.mjs} +1 -1
  17. package/dist/esm/InAppMessaging/utils/{handleMessageAction.js → handleMessageAction.mjs} +1 -1
  18. package/dist/esm/components/RenderNothing/{RenderNothing.js → RenderNothing.mjs} +0 -0
  19. package/dist/esm/hooks/{useHasValueUpdated.js → useHasValueUpdated.mjs} +2 -2
  20. package/dist/esm/hooks/{usePreviousValue.js → usePreviousValue.mjs} +0 -0
  21. package/dist/esm/{index.js → index.mjs} +14 -14
  22. package/dist/esm/node_modules/tslib/{tslib.es6.js → tslib.es6.mjs} +0 -0
  23. package/dist/esm/utils/{index.js → index.mjs} +3 -4
  24. package/dist/index.js +19 -29
  25. package/dist/types/Authenticator/hooks/types.d.ts +26 -26
  26. package/dist/types/Authenticator/hooks/useAuthenticator/types.d.ts +4 -3
  27. package/dist/types/Authenticator/hooks/useAuthenticatorRoute/utils.d.ts +1 -1
  28. package/dist/types/components/RenderNothing/RenderNothing.d.ts +1 -0
  29. package/package.json +4 -5
@@ -1,8 +1,7 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { useContext, useMemo, useEffect } from 'react';
1
+ import React, { useContext, useMemo, useEffect } from 'react';
3
2
  import { useInterpret } from '@xstate/react';
4
3
  import { createAuthenticatorMachine, listenToAuthHub } from '@aws-amplify/ui';
5
- import { AuthenticatorContext } from './AuthenticatorContext.js';
4
+ import { AuthenticatorContext } from './AuthenticatorContext.mjs';
6
5
 
7
6
  function AuthenticatorProvider({ children, }) {
8
7
  /**
@@ -20,7 +19,7 @@ function AuthenticatorProvider({ children, }) {
20
19
  const unsubscribe = listenToAuthHub(activeService);
21
20
  return unsubscribe;
22
21
  }, [activeService]);
23
- return (jsx(AuthenticatorContext.Provider, Object.assign({ value: value }, { children: children })));
22
+ return (React.createElement(AuthenticatorContext.Provider, { value: value }, children));
24
23
  }
25
24
 
26
25
  export { AuthenticatorProvider as default };
@@ -1,11 +1,10 @@
1
- import { __rest } from '../../../node_modules/tslib/tslib.es6.js';
2
- import React, { useCallback, useMemo } from 'react';
1
+ import { __rest } from '../../../node_modules/tslib/tslib.es6.mjs';
2
+ import React, { useCallback } from 'react';
3
3
  import { useSelector } from '@xstate/react';
4
4
  import { getServiceFacade } from '@aws-amplify/ui';
5
- import 'react/jsx-runtime';
6
- import { AuthenticatorContext } from '../../context/AuthenticatorContext.js';
7
- import { USE_AUTHENTICATOR_ERROR } from './constants.js';
8
- import { getQRFields, getMachineFields, getTotpSecretCodeCallback, getComparator, defaultComparator } from './utils.js';
5
+ import { AuthenticatorContext } from '../../context/AuthenticatorContext.mjs';
6
+ import { USE_AUTHENTICATOR_ERROR } from './constants.mjs';
7
+ import { getQRFields, getMachineFields, getTotpSecretCodeCallback, getComparator, defaultComparator } from './utils.mjs';
9
8
 
10
9
  /**
11
10
  * [📖 Docs](https://ui.docs.amplify.aws/react/connected-components/authenticator/headless#useauthenticator-hook)
@@ -20,21 +19,20 @@ function useAuthenticator(selector) {
20
19
  const xstateSelector = useCallback((state) => (Object.assign({}, getServiceFacade({ send, state }))), [send]);
21
20
  const comparator = selector ? getComparator(selector) : defaultComparator;
22
21
  const facade = useSelector(service, xstateSelector, comparator);
23
- const { route, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "unverifiedContactMethods", "user"]);
22
+ const { route, totpSecretCode, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "totpSecretCode", "unverifiedContactMethods", "user"]);
24
23
  // do not memoize output. `service.getSnapshot` reference remains stable preventing
25
24
  // `fields` from updating with current form state on value changes
26
25
  const serviceSnapshot = service.getSnapshot();
27
26
  // legacy `QRFields` values only used for SetupTOTP page to retrieve issuer information, will be removed in future
28
- const QRFields = useMemo(() => getQRFields(serviceSnapshot), [serviceSnapshot]);
27
+ const QRFields = route === 'setupTOTP' ? getQRFields(serviceSnapshot) : null;
29
28
  // legacy `formFields` values required until form state is removed from state machine
30
- const fields = useMemo(() => getMachineFields(route, serviceSnapshot, unverifiedContactMethods), [route, serviceSnapshot, unverifiedContactMethods]);
31
- return Object.assign(Object.assign({}, rest), { getTotpSecretCode: getTotpSecretCodeCallback(user), route,
29
+ const fields = getMachineFields(route, serviceSnapshot, unverifiedContactMethods);
30
+ return Object.assign(Object.assign({}, rest), { route,
31
+ totpSecretCode,
32
32
  unverifiedContactMethods,
33
33
  user,
34
34
  /** @deprecated For internal use only */
35
- fields,
36
- /** @deprecated For internal use only */
37
- QRFields });
35
+ fields, getTotpSecretCode: getTotpSecretCodeCallback(user), QRFields });
38
36
  }
39
37
 
40
38
  export { useAuthenticator as default };
@@ -1,9 +1,8 @@
1
- import { __awaiter } from '../../../node_modules/tslib/tslib.es6.js';
1
+ import { __awaiter } from '../../../node_modules/tslib/tslib.es6.mjs';
2
2
  import { Auth } from 'aws-amplify';
3
- import { getActorContext, getSortedFormFields } from '@aws-amplify/ui';
4
- import isString from 'lodash/isString';
5
- import { areEmptyArrays, areEmptyObjects } from '../../../utils/index.js';
6
- import { isComponentRouteKey } from '../utils.js';
3
+ import { getActorContext, getSortedFormFields, isString } from '@aws-amplify/ui';
4
+ import { areEmptyArrays, areEmptyObjects } from '../../../utils/index.mjs';
5
+ import { isComponentRouteKey } from '../utils.mjs';
7
6
 
8
7
  const defaultComparator = () => false;
9
8
  /**
@@ -31,9 +30,7 @@ const getComparator = (selector) => (currentFacade, nextFacade) => {
31
30
  };
32
31
  const getQRFields = (state) => {
33
32
  var _a, _b, _c;
34
- const fields = getActorContext(state);
35
- const QR = (_c = (_b = (_a = fields === null || fields === void 0 ? void 0 : fields.formFields) === null || _a === void 0 ? void 0 : _a.setupTOTP) === null || _b === void 0 ? void 0 : _b.QR) !== null && _c !== void 0 ? _c : {};
36
- return Object.assign({}, QR);
33
+ return (Object.assign({}, (_c = (_b = (_a = getActorContext(state)) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.setupTOTP) === null || _c === void 0 ? void 0 : _c.QR));
37
34
  };
38
35
  const getTotpSecretCodeCallback = (user) => function getTotpSecretCode() {
39
36
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import useAuthenticator from '../useAuthenticator/useAuthenticator.js';
2
+ import useAuthenticator from '../useAuthenticator/useAuthenticator.mjs';
3
3
 
4
4
  // only select `route` from machine context
5
5
  const routeSelector = ({ route }) => [route];
@@ -52,6 +52,7 @@ const SIGN_UP_MACHINE_KEYS = [
52
52
  const SETUP_TOTP_MACHINE_KEYS = [
53
53
  ...COMMON_ROUTE_MACHINE_KEYS,
54
54
  'toSignIn',
55
+ 'totpSecretCode',
55
56
  ];
56
57
  const VERIFY_USER_MACHINE_KEYS = [
57
58
  ...COMMON_ROUTE_MACHINE_KEYS,
@@ -1,6 +1,6 @@
1
1
  import { useMemo } from 'react';
2
- import useAuthenticator from '../useAuthenticator/useAuthenticator.js';
3
- import { getRouteMachineSelector, resolveDefault, resolveVerifyUserRoute, resolveSignUpRoute, resolveSignInRoute, resolveSetupTOTPRoute, resolveResetPasswordRoute, resolveForceNewPasswordRoute, resolveConfirmVerifyUserRoute, resolveConfirmSignUpRoute, resolveConfirmSignInRoute, resolveConfirmResetPasswordRoute, routeSelector } from './utils.js';
2
+ import useAuthenticator from '../useAuthenticator/useAuthenticator.mjs';
3
+ import { getRouteMachineSelector, resolveDefault, resolveVerifyUserRoute, resolveSignUpRoute, resolveSignInRoute, resolveSetupTOTPRoute, resolveResetPasswordRoute, resolveForceNewPasswordRoute, resolveConfirmVerifyUserRoute, resolveConfirmSignUpRoute, resolveConfirmSignInRoute, resolveConfirmResetPasswordRoute, routeSelector } from './utils.mjs';
4
4
 
5
5
  function useAuthenticatorRoute({ components, }) {
6
6
  const { route } = useAuthenticator(routeSelector);
@@ -1,7 +1,7 @@
1
- import { __rest } from '../../../node_modules/tslib/tslib.es6.js';
2
- import RenderNothing from '../../../components/RenderNothing/RenderNothing.js';
3
- import { isComponentRouteKey } from '../utils.js';
4
- import { MACHINE_PROP_KEYS, EVENT_HANDLER_KEY_MAP } from './constants.js';
1
+ import { __rest } from '../../../node_modules/tslib/tslib.es6.mjs';
2
+ import RenderNothing from '../../../components/RenderNothing/RenderNothing.mjs';
3
+ import { isComponentRouteKey } from '../utils.mjs';
4
+ import { MACHINE_PROP_KEYS, EVENT_HANDLER_KEY_MAP } from './constants.mjs';
5
5
 
6
6
  // only select `route` from machine context
7
7
  const routeSelector = ({ route }) => [route];
@@ -52,11 +52,10 @@ function resolveResetPasswordRoute(Component, props) {
52
52
  props: Object.assign(Object.assign({}, Component), getConvertedMachineProps('resetPassword', props)),
53
53
  };
54
54
  }
55
- function resolveSetupTOTPRoute(Component, _a) {
56
- var { getTotpSecretCode } = _a, props = __rest(_a, ["getTotpSecretCode"]);
55
+ function resolveSetupTOTPRoute(Component, props) {
57
56
  return {
58
57
  Component,
59
- props: Object.assign(Object.assign(Object.assign({}, Component), getConvertedMachineProps('setupTOTP', props)), { getTotpSecretCode }),
58
+ props: Object.assign(Object.assign({}, Component), getConvertedMachineProps('setupTOTP', props)),
60
59
  };
61
60
  }
62
61
  function resolveSignInRoute(Component, props) {
@@ -1,4 +1,4 @@
1
- import { COMPONENT_ROUTE_KEYS, COMPONENT_ROUTE_NAMES } from './constants.js';
1
+ import { COMPONENT_ROUTE_KEYS, COMPONENT_ROUTE_NAMES } from './constants.mjs';
2
2
 
3
3
  const isComponentRouteKey = (route) => COMPONENT_ROUTE_KEYS.some((componentRoute) => componentRoute === route);
4
4
  function resolveAuthenticatorComponents(defaults, overrides) {
@@ -1,7 +1,6 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { useState, useEffect, useCallback, useMemo } from 'react';
1
+ import React, { useState, useEffect, useCallback, useMemo } from 'react';
3
2
  import { Notifications } from '@aws-amplify/notifications';
4
- import InAppMessagingContext from '../InAppMessagingContext/InAppMessagingContext.js';
3
+ import InAppMessagingContext from '../InAppMessagingContext/InAppMessagingContext.mjs';
5
4
 
6
5
  const { InAppMessaging } = Notifications;
7
6
  function InAppMessagingProvider({ children, }) {
@@ -20,7 +19,7 @@ function InAppMessagingProvider({ children, }) {
20
19
  displayMessage: setMessage,
21
20
  message,
22
21
  }), [clearMessage, message]);
23
- return (jsx(InAppMessagingContext.Provider, Object.assign({ value: value }, { children: children })));
22
+ return (React.createElement(InAppMessagingContext.Provider, { value: value }, children));
24
23
  }
25
24
 
26
25
  export { InAppMessagingProvider as default };
@@ -1,6 +1,5 @@
1
1
  import { useContext } from 'react';
2
- import InAppMessagingContext from '../../context/InAppMessagingContext/InAppMessagingContext.js';
3
- import 'react/jsx-runtime';
2
+ import InAppMessagingContext from '../../context/InAppMessagingContext/InAppMessagingContext.mjs';
4
3
  import '@aws-amplify/notifications';
5
4
 
6
5
  /**
@@ -1,9 +1,9 @@
1
1
  import { ConsoleLogger } from '@aws-amplify/core';
2
2
  import { InAppMessageInteractionEvent, Notifications } from '@aws-amplify/notifications';
3
- import isNil from 'lodash/isNil';
4
- import RenderNothing from '../../../components/RenderNothing/RenderNothing.js';
5
- import useInAppMessaging from '../useInAppMessaging/useInAppMessaging.js';
6
- import { getContentProps, getPositionProp } from './utils.js';
3
+ import isNil from 'lodash/isNil.js';
4
+ import RenderNothing from '../../../components/RenderNothing/RenderNothing.mjs';
5
+ import useInAppMessaging from '../useInAppMessaging/useInAppMessaging.mjs';
6
+ import { getContentProps, getPositionProp } from './utils.mjs';
7
7
 
8
8
  const EMPTY_PROPS = Object.freeze({});
9
9
  const logger = new ConsoleLogger('Notifications.InAppMessaging');
@@ -1,4 +1,4 @@
1
- import { __rest } from '../../../node_modules/tslib/tslib.es6.js';
1
+ import { __rest } from '../../../node_modules/tslib/tslib.es6.mjs';
2
2
  import { ConsoleLogger } from '@aws-amplify/core';
3
3
 
4
4
  const logger = new ConsoleLogger('Notifications.InAppMessaging');
@@ -1,5 +1,5 @@
1
1
  import { ConsoleLogger } from '@aws-amplify/core';
2
- import isString from 'lodash/isString';
2
+ import { isString } from '@aws-amplify/ui';
3
3
 
4
4
  const logger = new ConsoleLogger('Notifications.InAppMessaging');
5
5
  const handleMessageAction = ({ action, handleMessageLinkAction, url, }) => {
@@ -1,5 +1,5 @@
1
- import usePreviousValue from './usePreviousValue.js';
2
- import isUndefined from 'lodash/isUndefined';
1
+ import { isUndefined } from '@aws-amplify/ui';
2
+ import usePreviousValue from './usePreviousValue.mjs';
3
3
 
4
4
  function useHasValueUpdated(value, ignoreFirstRender = false) {
5
5
  const previous = usePreviousValue(value);
@@ -1,14 +1,14 @@
1
- export { default as AuthenticatorProvider } from './Authenticator/context/AuthenticatorProvider.js';
2
- import './Authenticator/context/AuthenticatorContext.js';
3
- export { default as useAuthenticator } from './Authenticator/hooks/useAuthenticator/useAuthenticator.js';
4
- export { default as useAuthenticatorRoute } from './Authenticator/hooks/useAuthenticatorRoute/useAuthenticatorRoute.js';
5
- export { default as useAuthenticatorInitMachine } from './Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.js';
6
- export { isComponentRouteKey as isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents } from './Authenticator/hooks/utils.js';
7
- export { default as useInAppMessaging } from './InAppMessaging/hooks/useInAppMessaging/useInAppMessaging.js';
8
- export { default as useMessage } from './InAppMessaging/hooks/useMessage/useMessage.js';
9
- import './InAppMessaging/context/InAppMessagingContext/InAppMessagingContext.js';
10
- export { default as InAppMessagingProvider } from './InAppMessaging/context/InAppMessagingProvider/InAppMessagingProvider.js';
11
- export { default as handleMessageAction } from './InAppMessaging/utils/handleMessageAction.js';
12
- export { default as usePreviousValue } from './hooks/usePreviousValue.js';
13
- export { default as useHasValueUpdated } from './hooks/useHasValueUpdated.js';
14
- export { templateJoin } from './utils/index.js';
1
+ export { default as AuthenticatorProvider } from './Authenticator/context/AuthenticatorProvider.mjs';
2
+ import './Authenticator/context/AuthenticatorContext.mjs';
3
+ export { default as useAuthenticator } from './Authenticator/hooks/useAuthenticator/useAuthenticator.mjs';
4
+ export { default as useAuthenticatorRoute } from './Authenticator/hooks/useAuthenticatorRoute/useAuthenticatorRoute.mjs';
5
+ export { default as useAuthenticatorInitMachine } from './Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.mjs';
6
+ export { isComponentRouteKey as isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents } from './Authenticator/hooks/utils.mjs';
7
+ export { default as useInAppMessaging } from './InAppMessaging/hooks/useInAppMessaging/useInAppMessaging.mjs';
8
+ export { default as useMessage } from './InAppMessaging/hooks/useMessage/useMessage.mjs';
9
+ import './InAppMessaging/context/InAppMessagingContext/InAppMessagingContext.mjs';
10
+ export { default as InAppMessagingProvider } from './InAppMessaging/context/InAppMessagingProvider/InAppMessagingProvider.mjs';
11
+ export { default as handleMessageAction } from './InAppMessaging/utils/handleMessageAction.mjs';
12
+ export { default as usePreviousValue } from './hooks/usePreviousValue.mjs';
13
+ export { default as useHasValueUpdated } from './hooks/useHasValueUpdated.mjs';
14
+ export { templateJoin } from './utils/index.mjs';
@@ -1,6 +1,5 @@
1
- import isEmpty from 'lodash/isEmpty';
2
- import isObject from 'lodash/isObject';
3
- import isString from 'lodash/isString';
1
+ import isEmpty from 'lodash/isEmpty.js';
2
+ import { isString, isObject } from '@aws-amplify/ui';
4
3
 
5
4
  function isEmptyArray(value) {
6
5
  return Array.isArray(value) && isEmpty(value);
@@ -9,7 +8,7 @@ function areEmptyArrays(...values) {
9
8
  return values.every(isEmptyArray);
10
9
  }
11
10
  function isEmptyObject(value) {
12
- return isObject(value) && !Array.isArray(value) && isEmpty(value);
11
+ return isObject(value) && isEmpty(value);
13
12
  }
14
13
  function areEmptyObjects(...values) {
15
14
  return values.every(isEmptyObject);
package/dist/index.js CHANGED
@@ -2,27 +2,20 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var jsxRuntime = require('react/jsx-runtime');
6
5
  var React = require('react');
7
6
  var react = require('@xstate/react');
8
7
  var ui = require('@aws-amplify/ui');
9
8
  var awsAmplify = require('aws-amplify');
10
- var isString = require('lodash/isString');
11
- var isEmpty = require('lodash/isEmpty');
12
- var isObject = require('lodash/isObject');
9
+ var isEmpty = require('lodash/isEmpty.js');
13
10
  var notifications = require('@aws-amplify/notifications');
14
11
  var core = require('@aws-amplify/core');
15
- var isNil = require('lodash/isNil');
16
- var isUndefined = require('lodash/isUndefined');
12
+ var isNil = require('lodash/isNil.js');
17
13
 
18
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
15
 
20
16
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
21
- var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
22
17
  var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
23
- var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
24
18
  var isNil__default = /*#__PURE__*/_interopDefaultLegacy(isNil);
25
- var isUndefined__default = /*#__PURE__*/_interopDefaultLegacy(isUndefined);
26
19
 
27
20
  /**
28
21
  * AuthenticatorContext serves static reference to the auth machine service.
@@ -47,7 +40,7 @@ function AuthenticatorProvider({ children, }) {
47
40
  const unsubscribe = ui.listenToAuthHub(activeService);
48
41
  return unsubscribe;
49
42
  }, [activeService]);
50
- return (jsxRuntime.jsx(AuthenticatorContext.Provider, Object.assign({ value: value }, { children: children })));
43
+ return (React__default["default"].createElement(AuthenticatorContext.Provider, { value: value }, children));
51
44
  }
52
45
 
53
46
  /******************************************************************************
@@ -96,13 +89,13 @@ function areEmptyArrays(...values) {
96
89
  return values.every(isEmptyArray);
97
90
  }
98
91
  function isEmptyObject(value) {
99
- return isObject__default["default"](value) && !Array.isArray(value) && isEmpty__default["default"](value);
92
+ return ui.isObject(value) && isEmpty__default["default"](value);
100
93
  }
101
94
  function areEmptyObjects(...values) {
102
95
  return values.every(isEmptyObject);
103
96
  }
104
97
  function templateJoin(values, template) {
105
- return values.reduce((acc, curr) => `${acc}${isString__default["default"](curr) ? template(curr) : ''}`, '');
98
+ return values.reduce((acc, curr) => `${acc}${ui.isString(curr) ? template(curr) : ''}`, '');
106
99
  }
107
100
 
108
101
  const COMPONENT_ROUTE_KEYS = [
@@ -177,9 +170,7 @@ const getComparator = (selector) => (currentFacade, nextFacade) => {
177
170
  };
178
171
  const getQRFields = (state) => {
179
172
  var _a, _b, _c;
180
- const fields = ui.getActorContext(state);
181
- const QR = (_c = (_b = (_a = fields === null || fields === void 0 ? void 0 : fields.formFields) === null || _a === void 0 ? void 0 : _a.setupTOTP) === null || _b === void 0 ? void 0 : _b.QR) !== null && _c !== void 0 ? _c : {};
182
- return Object.assign({}, QR);
173
+ return (Object.assign({}, (_c = (_b = (_a = ui.getActorContext(state)) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.setupTOTP) === null || _c === void 0 ? void 0 : _c.QR));
183
174
  };
184
175
  const getTotpSecretCodeCallback = (user) => function getTotpSecretCode() {
185
176
  return __awaiter(this, void 0, void 0, function* () {
@@ -190,7 +181,7 @@ const flattenFormFields = (fields) => fields.flatMap(([name, options]) => (Objec
190
181
  const convertContactMethodsToFields = (unverifiedContactMethods) => {
191
182
  return (unverifiedContactMethods &&
192
183
  Object.entries(unverifiedContactMethods).map(([name, value]) => {
193
- const valueIsString = isString__default["default"](value);
184
+ const valueIsString = ui.isString(value);
194
185
  if (!valueIsString || !name) {
195
186
  return {};
196
187
  }
@@ -223,21 +214,20 @@ function useAuthenticator(selector) {
223
214
  const xstateSelector = React.useCallback((state) => (Object.assign({}, ui.getServiceFacade({ send, state }))), [send]);
224
215
  const comparator = selector ? getComparator(selector) : defaultComparator;
225
216
  const facade = react.useSelector(service, xstateSelector, comparator);
226
- const { route, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "unverifiedContactMethods", "user"]);
217
+ const { route, totpSecretCode, unverifiedContactMethods, user } = facade, rest = __rest(facade, ["route", "totpSecretCode", "unverifiedContactMethods", "user"]);
227
218
  // do not memoize output. `service.getSnapshot` reference remains stable preventing
228
219
  // `fields` from updating with current form state on value changes
229
220
  const serviceSnapshot = service.getSnapshot();
230
221
  // legacy `QRFields` values only used for SetupTOTP page to retrieve issuer information, will be removed in future
231
- const QRFields = React.useMemo(() => getQRFields(serviceSnapshot), [serviceSnapshot]);
222
+ const QRFields = route === 'setupTOTP' ? getQRFields(serviceSnapshot) : null;
232
223
  // legacy `formFields` values required until form state is removed from state machine
233
- const fields = React.useMemo(() => getMachineFields(route, serviceSnapshot, unverifiedContactMethods), [route, serviceSnapshot, unverifiedContactMethods]);
234
- return Object.assign(Object.assign({}, rest), { getTotpSecretCode: getTotpSecretCodeCallback(user), route,
224
+ const fields = getMachineFields(route, serviceSnapshot, unverifiedContactMethods);
225
+ return Object.assign(Object.assign({}, rest), { route,
226
+ totpSecretCode,
235
227
  unverifiedContactMethods,
236
228
  user,
237
229
  /** @deprecated For internal use only */
238
- fields,
239
- /** @deprecated For internal use only */
240
- QRFields });
230
+ fields, getTotpSecretCode: getTotpSecretCodeCallback(user), QRFields });
241
231
  }
242
232
 
243
233
  /**
@@ -301,6 +291,7 @@ const SIGN_UP_MACHINE_KEYS = [
301
291
  const SETUP_TOTP_MACHINE_KEYS = [
302
292
  ...COMMON_ROUTE_MACHINE_KEYS,
303
293
  'toSignIn',
294
+ 'totpSecretCode',
304
295
  ];
305
296
  const VERIFY_USER_MACHINE_KEYS = [
306
297
  ...COMMON_ROUTE_MACHINE_KEYS,
@@ -368,11 +359,10 @@ function resolveResetPasswordRoute(Component, props) {
368
359
  props: Object.assign(Object.assign({}, Component), getConvertedMachineProps('resetPassword', props)),
369
360
  };
370
361
  }
371
- function resolveSetupTOTPRoute(Component, _a) {
372
- var { getTotpSecretCode } = _a, props = __rest(_a, ["getTotpSecretCode"]);
362
+ function resolveSetupTOTPRoute(Component, props) {
373
363
  return {
374
364
  Component,
375
- props: Object.assign(Object.assign(Object.assign({}, Component), getConvertedMachineProps('setupTOTP', props)), { getTotpSecretCode }),
365
+ props: Object.assign(Object.assign({}, Component), getConvertedMachineProps('setupTOTP', props)),
376
366
  };
377
367
  }
378
368
  function resolveSignInRoute(Component, props) {
@@ -481,7 +471,7 @@ function InAppMessagingProvider({ children, }) {
481
471
  displayMessage: setMessage,
482
472
  message,
483
473
  }), [clearMessage, message]);
484
- return (jsxRuntime.jsx(InAppMessagingContext.Provider, Object.assign({ value: value }, { children: children })));
474
+ return (React__default["default"].createElement(InAppMessagingContext.Provider, { value: value }, children));
485
475
  }
486
476
 
487
477
  /**
@@ -610,7 +600,7 @@ const logger = new core.ConsoleLogger('Notifications.InAppMessaging');
610
600
  const handleMessageAction = ({ action, handleMessageLinkAction, url, }) => {
611
601
  logger.info(`Handle action: ${action}`);
612
602
  if (action === 'LINK' || action === 'DEEP_LINK') {
613
- if (!isString__default["default"](url)) {
603
+ if (!ui.isString(url)) {
614
604
  logger.warn(`url must be of type string. Received: ${url}`);
615
605
  return;
616
606
  }
@@ -630,7 +620,7 @@ function usePreviousValue(value) {
630
620
 
631
621
  function useHasValueUpdated(value, ignoreFirstRender = false) {
632
622
  const previous = usePreviousValue(value);
633
- const shouldIgnoreChange = isUndefined__default["default"](previous) && ignoreFirstRender;
623
+ const shouldIgnoreChange = ui.isUndefined(previous) && ignoreFirstRender;
634
624
  if (shouldIgnoreChange) {
635
625
  return false;
636
626
  }
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { AuthChallengeName, AuthenticatorServiceFacade, LegacyFormFieldOptions } from '@aws-amplify/ui';
3
+ import { UseAuthenticator } from './useAuthenticator';
3
4
  export declare type AuthenticatorRouteComponentKey = 'confirmResetPassword' | 'confirmSignIn' | 'confirmSignUp' | 'confirmVerifyUser' | 'forceNewPassword' | 'resetPassword' | 'setupTOTP' | 'signIn' | 'signUp' | 'verifyUser';
4
5
  export declare type AuthenticatorLegacyField = LegacyFormFieldOptions;
5
6
  export declare type AuthenticatorLegacyFields = AuthenticatorLegacyField[];
@@ -10,7 +11,6 @@ export declare type AuthenticatorLegacyFields = AuthenticatorLegacyField[];
10
11
  export declare type AuthenticatorMachineContext = AuthenticatorServiceFacade;
11
12
  export declare type AuthenticatorMachineContextKey = keyof AuthenticatorMachineContext;
12
13
  export declare type AuthenticatorRouteComponentName = Capitalize<AuthenticatorRouteComponentKey>;
13
- export declare type GetTotpSecretCode = () => Promise<string>;
14
14
  interface HeaderProps {
15
15
  children?: React.ReactNode;
16
16
  }
@@ -18,8 +18,8 @@ interface FooterProps {
18
18
  children?: React.ReactNode;
19
19
  }
20
20
  declare type FormFieldsProps = {
21
- isPending: AuthenticatorMachineContext['isPending'];
22
- validationErrors?: AuthenticatorMachineContext['validationErrors'];
21
+ isPending: UseAuthenticator['isPending'];
22
+ validationErrors?: UseAuthenticator['validationErrors'];
23
23
  };
24
24
  export declare type FooterComponent<Props = {}> = React.ComponentType<FooterProps & Props>;
25
25
  export declare type FormFieldsComponent<FieldType, Props = {}> = React.ComponentType<FormFieldsProps & {
@@ -35,55 +35,55 @@ export interface ComponentSlots<FieldType = {}> {
35
35
  * Common component prop types used for both RWA and RNA implementations
36
36
  */
37
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'];
38
+ error?: UseAuthenticator['error'];
39
+ isPending: UseAuthenticator['isPending'];
40
+ handleBlur: UseAuthenticator['updateBlur'];
41
+ handleChange: UseAuthenticator['updateForm'];
42
+ handleSubmit: UseAuthenticator['submitForm'];
43
43
  };
44
44
  /**
45
45
  * Base Route component props
46
46
  */
47
47
  export declare type ConfirmResetPasswordBaseProps<FieldType = {}> = {
48
- resendCode: AuthenticatorMachineContext['resendCode'];
49
- validationErrors?: AuthenticatorMachineContext['validationErrors'];
48
+ resendCode: UseAuthenticator['resendCode'];
49
+ validationErrors?: UseAuthenticator['validationErrors'];
50
50
  } & CommonRouteProps & ComponentSlots<FieldType>;
51
51
  export declare type ConfirmSignInBaseProps<FieldType = {}> = {
52
52
  challengeName: AuthChallengeName;
53
- toSignIn: AuthenticatorMachineContext['toSignIn'];
53
+ toSignIn: UseAuthenticator['toSignIn'];
54
54
  } & CommonRouteProps & ComponentSlots<FieldType>;
55
55
  export declare type ConfirmSignUpBaseProps<FieldType = {}> = {
56
- codeDeliveryDetails: AuthenticatorMachineContext['codeDeliveryDetails'];
57
- resendCode: AuthenticatorMachineContext['resendCode'];
56
+ codeDeliveryDetails: UseAuthenticator['codeDeliveryDetails'];
57
+ resendCode: UseAuthenticator['resendCode'];
58
58
  } & CommonRouteProps & ComponentSlots<FieldType>;
59
59
  export declare type ConfirmVerifyUserProps<FieldType = {}> = {
60
- skipVerification: AuthenticatorMachineContext['skipVerification'];
60
+ skipVerification: UseAuthenticator['skipVerification'];
61
61
  } & CommonRouteProps & ComponentSlots<FieldType>;
62
62
  export declare type ForceResetPasswordBaseProps<FieldType = {}> = {
63
- toSignIn: AuthenticatorMachineContext['toSignIn'];
64
- validationErrors?: AuthenticatorMachineContext['validationErrors'];
63
+ toSignIn: UseAuthenticator['toSignIn'];
64
+ validationErrors?: UseAuthenticator['validationErrors'];
65
65
  } & CommonRouteProps & ComponentSlots<FieldType>;
66
66
  export declare type ResetPasswordBaseProps<FieldType = {}> = {
67
- toSignIn: AuthenticatorMachineContext['toSignIn'];
67
+ toSignIn: UseAuthenticator['toSignIn'];
68
68
  } & CommonRouteProps & ComponentSlots<FieldType>;
69
69
  export declare type SetupTOTPBaseProps<FieldType = {}> = {
70
- getTotpSecretCode: GetTotpSecretCode;
71
- toSignIn: AuthenticatorMachineContext['toSignIn'];
70
+ toSignIn: UseAuthenticator['toSignIn'];
71
+ totpSecretCode: UseAuthenticator['totpSecretCode'];
72
72
  } & CommonRouteProps & ComponentSlots<FieldType>;
73
73
  export declare type SignInBaseProps<FieldType = {}> = {
74
74
  hideSignUp?: boolean;
75
- toFederatedSignIn: AuthenticatorMachineContext['toFederatedSignIn'];
76
- toResetPassword: AuthenticatorMachineContext['toResetPassword'];
77
- toSignUp: AuthenticatorMachineContext['toSignUp'];
75
+ toFederatedSignIn: UseAuthenticator['toFederatedSignIn'];
76
+ toResetPassword: UseAuthenticator['toResetPassword'];
77
+ toSignUp: UseAuthenticator['toSignUp'];
78
78
  } & CommonRouteProps & ComponentSlots<FieldType>;
79
79
  export declare type SignUpBaseProps<FieldType = {}> = {
80
80
  hideSignIn?: boolean;
81
- toFederatedSignIn: AuthenticatorMachineContext['toFederatedSignIn'];
82
- toSignIn: AuthenticatorMachineContext['toSignIn'];
83
- validationErrors?: AuthenticatorMachineContext['validationErrors'];
81
+ toFederatedSignIn: UseAuthenticator['toFederatedSignIn'];
82
+ toSignIn: UseAuthenticator['toSignIn'];
83
+ validationErrors?: UseAuthenticator['validationErrors'];
84
84
  } & CommonRouteProps & ComponentSlots<FieldType>;
85
85
  export declare type VerifyUserProps<FieldType = {}> = {
86
- skipVerification: AuthenticatorMachineContext['skipVerification'];
86
+ skipVerification: UseAuthenticator['skipVerification'];
87
87
  } & CommonRouteProps & ComponentSlots<FieldType>;
88
88
  export interface DefaultProps<FieldType = {}> {
89
89
  ConfirmSignIn: ConfirmSignInBaseProps<FieldType>;
@@ -15,14 +15,15 @@ export declare type AuthenticatorLegacyFields = LegacyFormFieldOptions[];
15
15
  */
16
16
  export declare type UseAuthenticatorSelector = (context: AuthenticatorMachineContext) => AuthenticatorMachineContext[AuthenticatorMachineContextKey][];
17
17
  export interface UseAuthenticator extends AuthenticatorServiceFacade {
18
+ /** @deprecated For internal use only */
19
+ fields: AuthenticatorLegacyFields;
20
+ /** @deprecated For internal use only */
18
21
  getTotpSecretCode: () => Promise<string>;
19
22
  /** @deprecated For internal use only */
20
23
  QRFields: {
21
24
  totpIssuer?: string;
22
25
  totpUsername?: string;
23
- };
24
- /** @deprecated For internal use only */
25
- fields: AuthenticatorLegacyFields;
26
+ } | null;
26
27
  }
27
28
  export declare type Comparator = (currentMachineContext: AuthenticatorMachineContext, nextMachineContext: AuthenticatorMachineContext) => boolean;
28
29
  export {};
@@ -10,7 +10,7 @@ export declare function resolveConfirmSignUpRoute<FieldType = {}>(Component: Def
10
10
  export declare function resolveConfirmVerifyUserRoute<FieldType = {}>(Component: Defaults<FieldType>['ConfirmVerifyUser'], props: UseAuthenticator): UseAuthenticatorRoute<'ConfirmVerifyUser', FieldType>;
11
11
  export declare function resolveForceNewPasswordRoute<FieldType = {}>(Component: Defaults<FieldType>['ForceNewPassword'], props: UseAuthenticator): UseAuthenticatorRoute<'ForceNewPassword', FieldType>;
12
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>;
13
+ export declare function resolveSetupTOTPRoute<FieldType = {}>(Component: Defaults<FieldType>['SetupTOTP'], props: UseAuthenticator): UseAuthenticatorRoute<'SetupTOTP', FieldType>;
14
14
  export declare function resolveSignInRoute<FieldType = {}>(Component: Defaults<FieldType>['SignIn'], props: UseAuthenticator): UseAuthenticatorRoute<'SignIn', FieldType>;
15
15
  export declare function resolveSignUpRoute<FieldType = {}>(Component: Defaults<FieldType>['SignUp'], props: UseAuthenticator): UseAuthenticatorRoute<'SignUp', FieldType>;
16
16
  export declare function resolveVerifyUserRoute<FieldType = {}>(Component: Defaults<FieldType>['VerifyUser'], props: UseAuthenticator): UseAuthenticatorRoute<'VerifyUser', FieldType>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  /**
2
3
  * Utility component for rendering nothing.
3
4
  */
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-core",
3
- "version": "2.1.9",
3
+ "version": "2.1.11",
4
4
  "main": "dist/index.js",
5
- "module": "dist/esm/index.js",
5
+ "module": "dist/esm/index.mjs",
6
6
  "react-native": "dist/index.js",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./dist/esm/index.js",
9
+ "import": "./dist/esm/index.mjs",
10
10
  "require": "./dist/index.js"
11
11
  },
12
12
  "./package.json": "./package.json"
@@ -28,7 +28,7 @@
28
28
  "test:watch": "yarn test --watch"
29
29
  },
30
30
  "dependencies": {
31
- "@aws-amplify/ui": "5.5.1",
31
+ "@aws-amplify/ui": "5.5.3",
32
32
  "@xstate/react": "3.0.1",
33
33
  "lodash": "4.17.21",
34
34
  "xstate": "^4.33.6"
@@ -38,7 +38,6 @@
38
38
  "react": ">= 16.14.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@rollup/plugin-commonjs": "^22.0.1",
42
41
  "@rollup/plugin-typescript": "^8.3.1",
43
42
  "@testing-library/react": "^12.0.0",
44
43
  "@testing-library/react-hooks": "^7.0.2",