@aws-amplify/ui-react-core 2.1.24 → 2.1.25

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,10 +1,10 @@
1
- import React from 'react';
1
+ import React__default from 'react';
2
2
 
3
3
  /**
4
4
  * AuthenticatorContext serves static reference to the auth machine service.
5
5
  *
6
6
  * https://xstate.js.org/docs/recipes/react.html#context-provider
7
7
  */
8
- const AuthenticatorContext = React.createContext(null);
8
+ const AuthenticatorContext = React__default.createContext(null);
9
9
 
10
10
  export { AuthenticatorContext };
@@ -1,5 +1,5 @@
1
1
  import { __awaiter } from '../../node_modules/tslib/tslib.es6.mjs';
2
- import React, { useContext, useMemo, useEffect } from 'react';
2
+ import React__default, { useContext, useMemo, useEffect } from 'react';
3
3
  import { useInterpret } from '@xstate/react';
4
4
  import { Auth } from 'aws-amplify';
5
5
  import { createAuthenticatorMachine, listenToAuthHub, defaultAuthHubHandler } from '@aws-amplify/ui';
@@ -13,9 +13,9 @@ function AuthenticatorProvider({ children, }) {
13
13
  // state machine as the machine only updates on `Authenticator` initiated events, which
14
14
  // leads to scenarios where the state machine `authStatus` gets "stuck". For exmample,
15
15
  // if a user was to sign in using `Auth.signIn` directly rather than using `Authenticator`
16
- const [authStatus, setAuthStatus] = React.useState('configuring');
16
+ const [authStatus, setAuthStatus] = React__default.useState('configuring');
17
17
  // only run on first render
18
- React.useEffect(() => {
18
+ React__default.useEffect(() => {
19
19
  Auth.currentAuthenticatedUser()
20
20
  .then(() => {
21
21
  setAuthStatus('authenticated');
@@ -45,7 +45,7 @@ function AuthenticatorProvider({ children, }) {
45
45
  const unsubscribe = listenToAuthHub(activeService, createHubHandler({ onSignIn, onSignOut }));
46
46
  return unsubscribe;
47
47
  }, [activeService]);
48
- return (React.createElement(AuthenticatorContext.Provider, { value: value }, children));
48
+ return (React__default.createElement(AuthenticatorContext.Provider, { value: value }, children));
49
49
  }
50
50
 
51
51
  export { AuthenticatorProvider as default };
@@ -1,5 +1,5 @@
1
1
  import { __rest } from '../../../node_modules/tslib/tslib.es6.mjs';
2
- import React, { useCallback } from 'react';
2
+ import React__default, { useCallback } from 'react';
3
3
  import { useSelector } from '@xstate/react';
4
4
  import { getServiceFacade } from '@aws-amplify/ui';
5
5
  import 'aws-amplify';
@@ -11,7 +11,7 @@ import { getQRFields, getMachineFields, getTotpSecretCodeCallback, getComparator
11
11
  * [📖 Docs](https://ui.docs.amplify.aws/react/connected-components/authenticator/headless#useauthenticator-hook)
12
12
  */
13
13
  function useAuthenticator(selector) {
14
- const context = React.useContext(AuthenticatorContext);
14
+ const context = React__default.useContext(AuthenticatorContext);
15
15
  if (!context) {
16
16
  throw new Error(USE_AUTHENTICATOR_ERROR);
17
17
  }
@@ -1,12 +1,12 @@
1
- import React from 'react';
1
+ import React__default from 'react';
2
2
  import useAuthenticator from '../useAuthenticator/useAuthenticator.mjs';
3
3
 
4
4
  // only select `route` from machine context
5
5
  const routeSelector = ({ route }) => [route];
6
6
  function useAuthenticatorInitMachine(data) {
7
7
  const { route, initializeMachine } = useAuthenticator(routeSelector);
8
- const hasInitialized = React.useRef(false);
9
- React.useEffect(() => {
8
+ const hasInitialized = React__default.useRef(false);
9
+ React__default.useEffect(() => {
10
10
  if (!hasInitialized.current && route === 'setup') {
11
11
  initializeMachine(data);
12
12
  hasInitialized.current = true;
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Logs a deprecation warning message.
5
+ *
6
+ * @important Please use the React/React Native specific platform implementations.
7
+ * This version of the hook is a base implementation that the others extend from due
8
+ * to env differences between running in RN or the browser
9
+ */
10
+ const useDeprecationWarning = ({ shouldWarn, message, }) => {
11
+ React.useEffect(() => {
12
+ if (shouldWarn) {
13
+ // eslint-disable-next-line no-console
14
+ console.warn(message);
15
+ }
16
+ }, [shouldWarn, message]);
17
+ };
18
+
19
+ export { useDeprecationWarning as default };
@@ -5,6 +5,7 @@ export { default as useAuthenticatorRoute } from './Authenticator/hooks/useAuthe
5
5
  export { default as useAuthenticatorInitMachine } from './Authenticator/hooks/useAuthenticatorInitMachine/useAuthenticatorInitMachine.mjs';
6
6
  export { isComponentRouteKey as isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents } from './Authenticator/hooks/utils.mjs';
7
7
  export { default as RenderNothing } from './components/RenderNothing/RenderNothing.mjs';
8
- export { default as usePreviousValue } from './hooks/usePreviousValue.mjs';
8
+ export { default as useDeprecationWarning } from './hooks/useDeprecationWarning.mjs';
9
9
  export { default as useHasValueUpdated } from './hooks/useHasValueUpdated.mjs';
10
+ export { default as usePreviousValue } from './hooks/usePreviousValue.mjs';
10
11
  export { templateJoin } from './utils/index.mjs';
package/dist/index.js CHANGED
@@ -9,7 +9,26 @@ var ui = require('@aws-amplify/ui');
9
9
 
10
10
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
11
 
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n["default"] = e;
27
+ return Object.freeze(n);
28
+ }
29
+
12
30
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
31
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
13
32
 
14
33
  /******************************************************************************
15
34
  Copyright (c) Microsoft Corporation.
@@ -461,6 +480,22 @@ function useAuthenticatorInitMachine(data) {
461
480
  }, [initializeMachine, route, data]);
462
481
  }
463
482
 
483
+ /**
484
+ * Logs a deprecation warning message.
485
+ *
486
+ * @important Please use the React/React Native specific platform implementations.
487
+ * This version of the hook is a base implementation that the others extend from due
488
+ * to env differences between running in RN or the browser
489
+ */
490
+ const useDeprecationWarning = ({ shouldWarn, message, }) => {
491
+ React__namespace.useEffect(() => {
492
+ if (shouldWarn) {
493
+ // eslint-disable-next-line no-console
494
+ console.warn(message);
495
+ }
496
+ }, [shouldWarn, message]);
497
+ };
498
+
464
499
  function usePreviousValue(value) {
465
500
  const previous = React.useRef();
466
501
  // update ref post render
@@ -492,5 +527,6 @@ exports.templateJoin = templateJoin;
492
527
  exports.useAuthenticator = useAuthenticator;
493
528
  exports.useAuthenticatorInitMachine = useAuthenticatorInitMachine;
494
529
  exports.useAuthenticatorRoute = useAuthenticatorRoute;
530
+ exports.useDeprecationWarning = useDeprecationWarning;
495
531
  exports.useHasValueUpdated = useHasValueUpdated;
496
532
  exports.usePreviousValue = usePreviousValue;
@@ -1,2 +1,3 @@
1
- export { default as usePreviousValue } from './usePreviousValue';
1
+ export { default as useDeprecationWarning, UseDeprecationWarning, } from './useDeprecationWarning';
2
2
  export { default as useHasValueUpdated } from './useHasValueUpdated';
3
+ export { default as usePreviousValue } from './usePreviousValue';
@@ -0,0 +1,13 @@
1
+ export type UseDeprecationWarning = (params: {
2
+ shouldWarn: boolean;
3
+ message: string;
4
+ }) => void;
5
+ /**
6
+ * Logs a deprecation warning message.
7
+ *
8
+ * @important Please use the React/React Native specific platform implementations.
9
+ * This version of the hook is a base implementation that the others extend from due
10
+ * to env differences between running in RN or the browser
11
+ */
12
+ declare const useDeprecationWarning: UseDeprecationWarning;
13
+ export default useDeprecationWarning;
@@ -1,4 +1,4 @@
1
1
  export { AuthenticatorComponentDefaults, AuthenticatorComponentDefaultProps, AuthenticatorComponentOverrides, AuthenticatorFooterComponent, AuthenticatorFormFieldsComponent, AuthenticatorHeaderComponent, AuthenticatorLegacyField, AuthenticatorMachineContext, AuthenticatorProvider, AuthenticatorRouteComponentKey, AuthenticatorRouteComponentName, isAuthenticatorComponentRouteKey, resolveAuthenticatorComponents, useAuthenticator, useAuthenticatorRoute, UseAuthenticator, useAuthenticatorInitMachine, UseAuthenticatorRoute, } from './Authenticator';
2
2
  export { RenderNothing } from './components';
3
- export { useHasValueUpdated, usePreviousValue } from './hooks';
3
+ export { useDeprecationWarning, UseDeprecationWarning, useHasValueUpdated, usePreviousValue, } from './hooks';
4
4
  export { templateJoin } from './utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-core",
3
- "version": "2.1.24",
3
+ "version": "2.1.25",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "react-native": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "typecheck": "tsc --noEmit"
32
32
  },
33
33
  "dependencies": {
34
- "@aws-amplify/ui": "5.6.5",
34
+ "@aws-amplify/ui": "5.6.6",
35
35
  "@xstate/react": "3.0.1",
36
36
  "lodash": "4.17.21",
37
37
  "xstate": "^4.33.6"