@aws-amplify/ui-react-core 3.6.1 → 3.6.3

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.
package/dist/elements.js CHANGED
@@ -197,6 +197,7 @@ function defineBaseElementWithRef(input) {
197
197
  return Element;
198
198
  }
199
199
 
200
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
200
201
  /**
201
202
  * @internal @unstable
202
203
  *
@@ -212,13 +213,13 @@ function defineBaseElementWithRef(input) {
212
213
  * type InputElementPropKey = 'onChange' | 'type';
213
214
  *
214
215
  * // create `InputElement` base with `type` generic and extended `props` key
215
- * export const InputElement = defineBaseElementWithRef<"input", InputElementPropKey>({
216
+ * export const InputElement = withBaseElementProps<"input", InputElementPropKey>({
216
217
  * type: "input",
217
218
  * displayName: "Input",
218
219
  * });
219
220
  *
220
221
  * // extend base `InputElement` with default input `type` of `checkbox`
221
- * const CheckboxElement = withBaseElementProps(Input, {
222
+ * const CheckboxElement = withBaseElementProps(InputElement, {
222
223
  * className: 'submit-toggle__checkbox',
223
224
  * type: 'checkbox',
224
225
  * });
@@ -32,7 +32,7 @@ function AuthenticatorProvider({ children, }) {
32
32
  */
33
33
  const parentProviderVal = useContext(AuthenticatorContext);
34
34
  const service = useInterpret(createAuthenticatorMachine);
35
- const value = useMemo(() => (!parentProviderVal ? { authStatus, service } : parentProviderVal), [authStatus, parentProviderVal, service]);
35
+ const value = useMemo(() => parentProviderVal ?? { authStatus, service }, [authStatus, parentProviderVal, service]);
36
36
  const { service: activeService } = value;
37
37
  useEffect(() => {
38
38
  const onSignIn = () => {
@@ -4,7 +4,7 @@ import { getServiceFacade } from '@aws-amplify/ui';
4
4
  import 'aws-amplify/auth';
5
5
  import { AuthenticatorContext } from '../../context/AuthenticatorContext.mjs';
6
6
  import { USE_AUTHENTICATOR_ERROR } from './constants.mjs';
7
- import { getComparator, defaultComparator, getQRFields, getMachineFields } from './utils.mjs';
7
+ import { defaultComparator, getQRFields, getMachineFields, getComparator } from './utils.mjs';
8
8
 
9
9
  /**
10
10
  * [📖 Docs](https://ui.docs.amplify.aws/react/connected-components/authenticator/headless#useauthenticator-hook)
@@ -1,4 +1,4 @@
1
- import { getActorContext, getSortedFormFields, areEmptyArrays, areEmptyObjects, isString, authenticatorTextUtil } from '@aws-amplify/ui';
1
+ import { getActorContext, getSortedFormFields, isString, authenticatorTextUtil, areEmptyArrays, areEmptyObjects } from '@aws-amplify/ui';
2
2
  import { isComponentRouteKey } from '../utils.mjs';
3
3
 
4
4
  const defaultComparator = () => false;
@@ -1,5 +1,6 @@
1
1
  import React__default from 'react';
2
2
 
3
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
3
4
  /**
4
5
  * @internal @unstable
5
6
  *
@@ -15,13 +16,13 @@ import React__default from 'react';
15
16
  * type InputElementPropKey = 'onChange' | 'type';
16
17
  *
17
18
  * // create `InputElement` base with `type` generic and extended `props` key
18
- * export const InputElement = defineBaseElementWithRef<"input", InputElementPropKey>({
19
+ * export const InputElement = withBaseElementProps<"input", InputElementPropKey>({
19
20
  * type: "input",
20
21
  * displayName: "Input",
21
22
  * });
22
23
  *
23
24
  * // extend base `InputElement` with default input `type` of `checkbox`
24
- * const CheckboxElement = withBaseElementProps(Input, {
25
+ * const CheckboxElement = withBaseElementProps(InputElement, {
25
26
  * className: 'submit-toggle__checkbox',
26
27
  * type: 'checkbox',
27
28
  * });
@@ -17,9 +17,7 @@ function useControlledReducer(reducer, initialState, options) {
17
17
  onStateChange?.(uncontrolledState);
18
18
  }
19
19
  }, [hasUncontrolledStateChanged, onStateChange, uncontrolledState]);
20
- const state = controlledStateRef.current
21
- ? controlledStateRef.current
22
- : uncontrolledState;
20
+ const state = controlledStateRef.current ?? uncontrolledState;
23
21
  return React__default.useMemo(() => [state, dispatch], [state]);
24
22
  }
25
23
 
@@ -13,7 +13,8 @@ const readAllDirectoryEntries = async (dirReader) => {
13
13
  try {
14
14
  dirReader.readEntries(resolve, reject);
15
15
  }
16
- catch (error) {
16
+ catch (e) {
17
+ const error = e;
17
18
  reject(error);
18
19
  }
19
20
  });
package/dist/index.js CHANGED
@@ -64,7 +64,7 @@ function AuthenticatorProvider({ children, }) {
64
64
  */
65
65
  const parentProviderVal = React.useContext(AuthenticatorContext);
66
66
  const service = react.useInterpret(ui.createAuthenticatorMachine);
67
- const value = React.useMemo(() => (!parentProviderVal ? { authStatus, service } : parentProviderVal), [authStatus, parentProviderVal, service]);
67
+ const value = React.useMemo(() => parentProviderVal ?? { authStatus, service }, [authStatus, parentProviderVal, service]);
68
68
  const { service: activeService } = value;
69
69
  React.useEffect(() => {
70
70
  const onSignIn = () => {
@@ -652,9 +652,7 @@ function useControlledReducer(reducer, initialState, options) {
652
652
  onStateChange?.(uncontrolledState);
653
653
  }
654
654
  }, [hasUncontrolledStateChanged, onStateChange, uncontrolledState]);
655
- const state = controlledStateRef.current
656
- ? controlledStateRef.current
657
- : uncontrolledState;
655
+ const state = controlledStateRef.current ?? uncontrolledState;
658
656
  return React__namespace["default"].useMemo(() => [state, dispatch], [state]);
659
657
  }
660
658
 
@@ -706,7 +704,8 @@ const readAllDirectoryEntries = async (dirReader) => {
706
704
  try {
707
705
  dirReader.readEntries(resolve, reject);
708
706
  }
709
- catch (error) {
707
+ catch (e) {
708
+ const error = e;
710
709
  reject(error);
711
710
  }
712
711
  });
@@ -2,4 +2,4 @@ export * from './useAuthenticator';
2
2
  export * from './useAuthenticatorRoute';
3
3
  export * from './useAuthenticatorInitMachine';
4
4
  export * from './utils';
5
- export * from './types';
5
+ export type * from './types';
@@ -1,2 +1,2 @@
1
1
  export { default as useAuthenticatorRoute } from './useAuthenticatorRoute';
2
- export * from './types';
2
+ export type * from './types';
@@ -3,4 +3,4 @@ export { defineBaseElement, defineBaseElementWithRef, } from './defineBaseElemen
3
3
  export { default as withBaseElementProps } from './withBaseElementProps';
4
4
  export { ElementsProvider } from './ElementsContext';
5
5
  export { isComponent, isForwardRefExoticComponent } from './utils';
6
- export * from './types';
6
+ export type * from './types';
@@ -15,13 +15,13 @@ import type { BaseElementWithRef, ElementRefType } from './types';
15
15
  * type InputElementPropKey = 'onChange' | 'type';
16
16
  *
17
17
  * // create `InputElement` base with `type` generic and extended `props` key
18
- * export const InputElement = defineBaseElementWithRef<"input", InputElementPropKey>({
18
+ * export const InputElement = withBaseElementProps<"input", InputElementPropKey>({
19
19
  * type: "input",
20
20
  * displayName: "Input",
21
21
  * });
22
22
  *
23
23
  * // extend base `InputElement` with default input `type` of `checkbox`
24
- * const CheckboxElement = withBaseElementProps(Input, {
24
+ * const CheckboxElement = withBaseElementProps(InputElement, {
25
25
  * className: 'submit-toggle__checkbox',
26
26
  * type: 'checkbox',
27
27
  * });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-core",
3
- "version": "3.6.1",
3
+ "version": "3.6.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "react-native": "src/index.ts",
@@ -40,9 +40,9 @@
40
40
  "typecheck": "tsc --noEmit"
41
41
  },
42
42
  "dependencies": {
43
- "@aws-amplify/ui": "6.15.1",
43
+ "@aws-amplify/ui": "6.15.3",
44
44
  "@xstate/react": "^3.2.2",
45
- "lodash": "4.17.23",
45
+ "lodash": "4.18.1",
46
46
  "react-hook-form": "7.53.2",
47
47
  "xstate": "^4.33.6"
48
48
  },
@@ -53,7 +53,7 @@ export default function AuthenticatorProvider({
53
53
  const service = useInterpret(createAuthenticatorMachine);
54
54
 
55
55
  const value = useMemo(
56
- () => (!parentProviderVal ? { authStatus, service } : parentProviderVal),
56
+ () => parentProviderVal ?? { authStatus, service },
57
57
  [authStatus, parentProviderVal, service]
58
58
  );
59
59
 
@@ -2,4 +2,4 @@ export * from './useAuthenticator';
2
2
  export * from './useAuthenticatorRoute';
3
3
  export * from './useAuthenticatorInitMachine';
4
4
  export * from './utils';
5
- export * from './types';
5
+ export type * from './types';
@@ -1,2 +1,2 @@
1
1
  export { default as useAuthenticatorRoute } from './useAuthenticatorRoute';
2
- export * from './types';
2
+ export type * from './types';
@@ -6,4 +6,4 @@ export {
6
6
  export { default as withBaseElementProps } from './withBaseElementProps';
7
7
  export { ElementsProvider } from './ElementsContext';
8
8
  export { isComponent, isForwardRefExoticComponent } from './utils';
9
- export * from './types';
9
+ export type * from './types';
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { BaseElementWithRef, ElementRefType } from './types';
3
3
 
4
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
4
5
  /**
5
6
  * @internal @unstable
6
7
  *
@@ -16,13 +17,13 @@ import type { BaseElementWithRef, ElementRefType } from './types';
16
17
  * type InputElementPropKey = 'onChange' | 'type';
17
18
  *
18
19
  * // create `InputElement` base with `type` generic and extended `props` key
19
- * export const InputElement = defineBaseElementWithRef<"input", InputElementPropKey>({
20
+ * export const InputElement = withBaseElementProps<"input", InputElementPropKey>({
20
21
  * type: "input",
21
22
  * displayName: "Input",
22
23
  * });
23
24
  *
24
25
  * // extend base `InputElement` with default input `type` of `checkbox`
25
- * const CheckboxElement = withBaseElementProps(Input, {
26
+ * const CheckboxElement = withBaseElementProps(InputElement, {
26
27
  * className: 'submit-toggle__checkbox',
27
28
  * type: 'checkbox',
28
29
  * });
@@ -73,7 +73,7 @@ export default function useAsyncReducer<T, K>(
73
73
  }));
74
74
 
75
75
  const prevValue = React.useRef(initialValue);
76
- const pendingId = React.useRef<Symbol | undefined>();
76
+ const pendingId = React.useRef<symbol | undefined>();
77
77
 
78
78
  const { onSuccess, onError } = options ?? {};
79
79
 
@@ -38,9 +38,7 @@ export default function useControlledReducer<
38
38
  }
39
39
  }, [hasUncontrolledStateChanged, onStateChange, uncontrolledState]);
40
40
 
41
- const state = controlledStateRef.current
42
- ? controlledStateRef.current
43
- : uncontrolledState;
41
+ const state = controlledStateRef.current ?? uncontrolledState;
44
42
 
45
43
  return React.useMemo(() => [state, dispatch], [state]);
46
44
  }
@@ -16,7 +16,8 @@ const readAllDirectoryEntries = async (
16
16
  readBatch = await new Promise<FileSystemEntry[]>((resolve, reject) => {
17
17
  try {
18
18
  dirReader.readEntries(resolve, reject);
19
- } catch (error) {
19
+ } catch (e) {
20
+ const error = e as Error;
20
21
  reject(error);
21
22
  }
22
23
  });