@elliemae/ds-utilities 3.4.3-rc.1 → 3.4.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/cjs/capitalize.js +4 -1
- package/dist/cjs/capitalize.js.map +1 -1
- package/dist/cjs/compose.js +7 -2
- package/dist/cjs/compose.js.map +1 -1
- package/dist/cjs/deprecated/deprecatedMsg.js +4 -1
- package/dist/cjs/deprecated/deprecatedMsg.js.map +1 -1
- package/dist/cjs/deprecated/index.js +4 -1
- package/dist/cjs/deprecated/index.js.map +1 -1
- package/dist/cjs/deprecated/reactTypesUtility.js +4 -1
- package/dist/cjs/deprecated/reactTypesUtility.js.map +2 -2
- package/dist/cjs/deprecated/scrollingTimer.js +4 -1
- package/dist/cjs/deprecated/scrollingTimer.js.map +1 -1
- package/dist/cjs/deprecated/useParentElement.js +4 -1
- package/dist/cjs/deprecated/useParentElement.js.map +1 -1
- package/dist/cjs/deprecated/useSetRef.js +4 -1
- package/dist/cjs/deprecated/useSetRef.js.map +1 -1
- package/dist/cjs/deprecated/useUncontrolled.js +4 -1
- package/dist/cjs/deprecated/useUncontrolled.js.map +2 -2
- package/dist/cjs/deprecated/useWindowSize.js +4 -1
- package/dist/cjs/deprecated/useWindowSize.js.map +1 -1
- package/dist/cjs/getComponentFromProps.js +16 -7
- package/dist/cjs/getComponentFromProps.js.map +2 -2
- package/dist/cjs/hooks/index.js +4 -1
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useCallbackAfterRender.js +4 -1
- package/dist/cjs/hooks/useCallbackAfterRender.js.map +1 -1
- package/dist/cjs/hooks/useCancellableDelayedCallback.js +10 -4
- package/dist/cjs/hooks/useCancellableDelayedCallback.js.map +1 -1
- package/dist/cjs/hooks/useDerivedStateFromProps.js +4 -1
- package/dist/cjs/hooks/useDerivedStateFromProps.js.map +1 -1
- package/dist/cjs/hooks/useExecutionTimer.js +4 -1
- package/dist/cjs/hooks/useExecutionTimer.js.map +1 -1
- package/dist/cjs/hooks/useExpandState.js +4 -1
- package/dist/cjs/hooks/useExpandState.js.map +1 -1
- package/dist/cjs/hooks/useFocusTrap.js +34 -20
- package/dist/cjs/hooks/useFocusTrap.js.map +1 -1
- package/dist/cjs/hooks/useHotkeys.js +4 -1
- package/dist/cjs/hooks/useHotkeys.js.map +2 -2
- package/dist/cjs/hooks/useHoverHandlersDelay.js +4 -1
- package/dist/cjs/hooks/useHoverHandlersDelay.js.map +1 -1
- package/dist/cjs/hooks/useIsMobile.js +4 -1
- package/dist/cjs/hooks/useIsMobile.js.map +1 -1
- package/dist/cjs/hooks/useIsShowingEllipsis.js +14 -8
- package/dist/cjs/hooks/useIsShowingEllipsis.js.map +1 -1
- package/dist/cjs/hooks/useOnBlurOut.js +15 -9
- package/dist/cjs/hooks/useOnBlurOut.js.map +1 -1
- package/dist/cjs/hooks/useOnElementResize.js +11 -5
- package/dist/cjs/hooks/useOnElementResize.js.map +1 -1
- package/dist/cjs/hooks/useOnFirstFocusIn.js +35 -23
- package/dist/cjs/hooks/useOnFirstFocusIn.js.map +1 -1
- package/dist/cjs/hooks/useOnSpecificFocus.js +15 -7
- package/dist/cjs/hooks/useOnSpecificFocus.js.map +1 -1
- package/dist/cjs/hooks/usePrevious.js +4 -1
- package/dist/cjs/hooks/usePrevious.js.map +1 -1
- package/dist/cjs/hooks/useResizeObserver.js +23 -12
- package/dist/cjs/hooks/useResizeObserver.js.map +2 -2
- package/dist/cjs/hooks/useShouldRecalculate.js +4 -1
- package/dist/cjs/hooks/useShouldRecalculate.js.map +1 -1
- package/dist/cjs/hooks/useWindowScrollerList.js +20 -14
- package/dist/cjs/hooks/useWindowScrollerList.js.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/objectUtilities.js +4 -1
- package/dist/cjs/objectUtilities.js.map +1 -1
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js +4 -1
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js.map +1 -1
- package/dist/cjs/operators.js +4 -1
- package/dist/cjs/operators.js.map +1 -1
- package/dist/cjs/platform.js +4 -1
- package/dist/cjs/platform.js.map +1 -1
- package/dist/cjs/props-helpers/defaultProps/index.js +4 -1
- package/dist/cjs/props-helpers/defaultProps/index.js.map +1 -1
- package/dist/cjs/props-helpers/defaultProps/useMemoMergePropsWithDefault.js +4 -1
- package/dist/cjs/props-helpers/defaultProps/useMemoMergePropsWithDefault.js.map +2 -2
- package/dist/cjs/props-helpers/getProps/index.js +4 -1
- package/dist/cjs/props-helpers/getProps/index.js.map +1 -1
- package/dist/cjs/props-helpers/globalProps/constants.js +7 -2
- package/dist/cjs/props-helpers/globalProps/constants.js.map +1 -1
- package/dist/cjs/props-helpers/globalProps/getGlobalAttributes.js +4 -1
- package/dist/cjs/props-helpers/globalProps/getGlobalAttributes.js.map +1 -1
- package/dist/cjs/props-helpers/globalProps/globalAttributesPropTypes.js +4 -1
- package/dist/cjs/props-helpers/globalProps/globalAttributesPropTypes.js.map +1 -1
- package/dist/cjs/props-helpers/globalProps/index.js +4 -1
- package/dist/cjs/props-helpers/globalProps/index.js.map +1 -1
- package/dist/cjs/props-helpers/globalProps/useGetGlobalAttributes.js +8 -2
- package/dist/cjs/props-helpers/globalProps/useGetGlobalAttributes.js.map +1 -1
- package/dist/cjs/props-helpers/index.js +4 -1
- package/dist/cjs/props-helpers/index.js.map +1 -1
- package/dist/cjs/props-helpers/propTypes/PropTypes.js +4 -1
- package/dist/cjs/props-helpers/propTypes/PropTypes.js.map +1 -1
- package/dist/cjs/props-helpers/propTypes/customPropTypes.js +4 -1
- package/dist/cjs/props-helpers/propTypes/customPropTypes.js.map +1 -1
- package/dist/cjs/props-helpers/propTypes/describe.js +4 -1
- package/dist/cjs/props-helpers/propTypes/describe.js.map +2 -2
- package/dist/cjs/props-helpers/propTypes/describeConversions.js +17 -4
- package/dist/cjs/props-helpers/propTypes/describeConversions.js.map +2 -2
- package/dist/cjs/props-helpers/propTypes/describeGuards.js +4 -1
- package/dist/cjs/props-helpers/propTypes/describeGuards.js.map +1 -1
- package/dist/cjs/props-helpers/propTypes/index.js +4 -1
- package/dist/cjs/props-helpers/propTypes/index.js.map +2 -2
- package/dist/cjs/props-helpers/propTypes/toTypescript.js +4 -1
- package/dist/cjs/props-helpers/propTypes/toTypescript.js.map +1 -1
- package/dist/cjs/props-helpers/propTypes/types.js +4 -1
- package/dist/cjs/props-helpers/propTypes/types.js.map +1 -1
- package/dist/cjs/props-helpers/tests/globalProps/TestComponent.js +9 -4
- package/dist/cjs/props-helpers/tests/globalProps/TestComponent.js.map +1 -1
- package/dist/cjs/props-helpers/tests/validation/test.schema.js +4 -1
- package/dist/cjs/props-helpers/tests/validation/test.schema.js.map +1 -1
- package/dist/cjs/props-helpers/tests/xstyledProps/TestComponent.js +9 -4
- package/dist/cjs/props-helpers/tests/xstyledProps/TestComponent.js.map +1 -1
- package/dist/cjs/props-helpers/useDeprecateComponent/index.js +4 -1
- package/dist/cjs/props-helpers/useDeprecateComponent/index.js.map +1 -1
- package/dist/cjs/props-helpers/validation/errorTemplates.js +12 -5
- package/dist/cjs/props-helpers/validation/errorTemplates.js.map +1 -1
- package/dist/cjs/props-helpers/validation/index.js +4 -1
- package/dist/cjs/props-helpers/validation/index.js.map +1 -1
- package/dist/cjs/props-helpers/validation/typescriptGuards.js +4 -1
- package/dist/cjs/props-helpers/validation/typescriptGuards.js.map +1 -1
- package/dist/cjs/props-helpers/validation/typescriptParsers.js +4 -1
- package/dist/cjs/props-helpers/validation/typescriptParsers.js.map +1 -1
- package/dist/cjs/props-helpers/validation/typescriptValidator.js +20 -3
- package/dist/cjs/props-helpers/validation/typescriptValidator.js.map +1 -1
- package/dist/cjs/props-helpers/xstyledProps/constants.js +7 -2
- package/dist/cjs/props-helpers/xstyledProps/constants.js.map +1 -1
- package/dist/cjs/props-helpers/xstyledProps/index.js +4 -1
- package/dist/cjs/props-helpers/xstyledProps/index.js.map +1 -1
- package/dist/cjs/props-helpers/xstyledProps/useGetXstyledProps.js +4 -1
- package/dist/cjs/props-helpers/xstyledProps/useGetXstyledProps.js.map +1 -1
- package/dist/cjs/props-helpers/xstyledProps/xstyledPropTypes.js +4 -1
- package/dist/cjs/props-helpers/xstyledProps/xstyledPropTypes.js.map +1 -1
- package/dist/cjs/reactTypesUtility.js +4 -1
- package/dist/cjs/reactTypesUtility.js.map +2 -2
- package/dist/cjs/system.js +4 -1
- package/dist/cjs/system.js.map +1 -1
- package/dist/cjs/timeUtils.js +4 -1
- package/dist/cjs/timeUtils.js.map +1 -1
- package/dist/cjs/utils.js +4 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/validations.js +4 -1
- package/dist/cjs/validations.js.map +1 -1
- package/dist/esm/capitalize.js.map +1 -1
- package/dist/esm/compose.js +3 -1
- package/dist/esm/compose.js.map +1 -1
- package/dist/esm/deprecated/deprecatedMsg.js.map +1 -1
- package/dist/esm/deprecated/index.js.map +1 -1
- package/dist/esm/deprecated/reactTypesUtility.js.map +2 -2
- package/dist/esm/deprecated/scrollingTimer.js.map +1 -1
- package/dist/esm/deprecated/useParentElement.js.map +1 -1
- package/dist/esm/deprecated/useSetRef.js.map +1 -1
- package/dist/esm/deprecated/useUncontrolled.js.map +1 -1
- package/dist/esm/deprecated/useWindowSize.js.map +1 -1
- package/dist/esm/getComponentFromProps.js +12 -6
- package/dist/esm/getComponentFromProps.js.map +2 -2
- package/dist/esm/hooks/index.js.map +2 -2
- package/dist/esm/hooks/useCallbackAfterRender.js.map +1 -1
- package/dist/esm/hooks/useCancellableDelayedCallback.js +6 -3
- package/dist/esm/hooks/useCancellableDelayedCallback.js.map +1 -1
- package/dist/esm/hooks/useDerivedStateFromProps.js.map +1 -1
- package/dist/esm/hooks/useExecutionTimer.js.map +1 -1
- package/dist/esm/hooks/useExpandState.js.map +1 -1
- package/dist/esm/hooks/useFocusTrap.js +30 -19
- package/dist/esm/hooks/useFocusTrap.js.map +1 -1
- package/dist/esm/hooks/useHotkeys.js.map +1 -1
- package/dist/esm/hooks/useHoverHandlersDelay.js.map +1 -1
- package/dist/esm/hooks/useIsMobile.js.map +1 -1
- package/dist/esm/hooks/useIsShowingEllipsis.js +10 -7
- package/dist/esm/hooks/useIsShowingEllipsis.js.map +1 -1
- package/dist/esm/hooks/useOnBlurOut.js +11 -8
- package/dist/esm/hooks/useOnBlurOut.js.map +1 -1
- package/dist/esm/hooks/useOnElementResize.js +7 -4
- package/dist/esm/hooks/useOnElementResize.js.map +1 -1
- package/dist/esm/hooks/useOnFirstFocusIn.js +31 -22
- package/dist/esm/hooks/useOnFirstFocusIn.js.map +1 -1
- package/dist/esm/hooks/useOnSpecificFocus.js +11 -6
- package/dist/esm/hooks/useOnSpecificFocus.js.map +1 -1
- package/dist/esm/hooks/usePrevious.js.map +1 -1
- package/dist/esm/hooks/useResizeObserver.js +19 -11
- package/dist/esm/hooks/useResizeObserver.js.map +1 -1
- package/dist/esm/hooks/useShouldRecalculate.js.map +1 -1
- package/dist/esm/hooks/useWindowScrollerList.js +16 -13
- package/dist/esm/hooks/useWindowScrollerList.js.map +1 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/objectUtilities.js.map +1 -1
- package/dist/esm/onClickHandlerForNonInteractiveElements.js.map +1 -1
- package/dist/esm/operators.js.map +1 -1
- package/dist/esm/platform.js.map +1 -1
- package/dist/esm/props-helpers/defaultProps/index.js.map +1 -1
- package/dist/esm/props-helpers/defaultProps/useMemoMergePropsWithDefault.js.map +1 -1
- package/dist/esm/props-helpers/getProps/index.js.map +1 -1
- package/dist/esm/props-helpers/globalProps/constants.js +3 -1
- package/dist/esm/props-helpers/globalProps/constants.js.map +1 -1
- package/dist/esm/props-helpers/globalProps/getGlobalAttributes.js.map +1 -1
- package/dist/esm/props-helpers/globalProps/globalAttributesPropTypes.js.map +1 -1
- package/dist/esm/props-helpers/globalProps/index.js.map +1 -1
- package/dist/esm/props-helpers/globalProps/useGetGlobalAttributes.js +4 -1
- package/dist/esm/props-helpers/globalProps/useGetGlobalAttributes.js.map +1 -1
- package/dist/esm/props-helpers/index.js.map +1 -1
- package/dist/esm/props-helpers/propTypes/PropTypes.js.map +1 -1
- package/dist/esm/props-helpers/propTypes/customPropTypes.js.map +1 -1
- package/dist/esm/props-helpers/propTypes/describe.js.map +1 -1
- package/dist/esm/props-helpers/propTypes/describeConversions.js +13 -3
- package/dist/esm/props-helpers/propTypes/describeConversions.js.map +1 -1
- package/dist/esm/props-helpers/propTypes/describeGuards.js.map +1 -1
- package/dist/esm/props-helpers/propTypes/index.js.map +1 -1
- package/dist/esm/props-helpers/propTypes/toTypescript.js.map +1 -1
- package/dist/esm/props-helpers/propTypes/types.js.map +1 -1
- package/dist/esm/props-helpers/tests/globalProps/TestComponent.js +5 -3
- package/dist/esm/props-helpers/tests/globalProps/TestComponent.js.map +2 -2
- package/dist/esm/props-helpers/tests/validation/test.schema.js.map +1 -1
- package/dist/esm/props-helpers/tests/xstyledProps/TestComponent.js +5 -3
- package/dist/esm/props-helpers/tests/xstyledProps/TestComponent.js.map +2 -2
- package/dist/esm/props-helpers/useDeprecateComponent/index.js.map +1 -1
- package/dist/esm/props-helpers/validation/errorTemplates.js +8 -4
- package/dist/esm/props-helpers/validation/errorTemplates.js.map +1 -1
- package/dist/esm/props-helpers/validation/index.js.map +1 -1
- package/dist/esm/props-helpers/validation/typescriptGuards.js.map +1 -1
- package/dist/esm/props-helpers/validation/typescriptParsers.js.map +1 -1
- package/dist/esm/props-helpers/validation/typescriptValidator.js +16 -2
- package/dist/esm/props-helpers/validation/typescriptValidator.js.map +1 -1
- package/dist/esm/props-helpers/xstyledProps/constants.js +3 -1
- package/dist/esm/props-helpers/xstyledProps/constants.js.map +1 -1
- package/dist/esm/props-helpers/xstyledProps/index.js.map +1 -1
- package/dist/esm/props-helpers/xstyledProps/useGetXstyledProps.js.map +1 -1
- package/dist/esm/props-helpers/xstyledProps/xstyledPropTypes.js.map +1 -1
- package/dist/esm/reactTypesUtility.js.map +2 -2
- package/dist/esm/system.js.map +1 -1
- package/dist/esm/timeUtils.js.map +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/validations.js.map +1 -1
- package/package.json +2 -2
|
@@ -16,14 +16,18 @@ const getVariableType = (arg) => {
|
|
|
16
16
|
return typeof arg;
|
|
17
17
|
};
|
|
18
18
|
const throwTypeError = (validPropKey, invalidProp) => {
|
|
19
|
-
throw new Error(
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Warning: You are trying to pass a not valid "${validPropKey}" property to use a useFocusTrap hook, please provide a valid type.
|
|
20
21
|
|
|
21
22
|
Received: ${getVariableType(invalidProp)}
|
|
22
23
|
Expected: ${useFocusTrapProps[validPropKey]}
|
|
23
|
-
`
|
|
24
|
+
`
|
|
25
|
+
);
|
|
24
26
|
};
|
|
25
27
|
const throwRequiredError = (validPropKey) => {
|
|
26
|
-
throw new Error(
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Warning: Please provide a "${validPropKey}" property to use a useFocusTrap hook, this property is required.`
|
|
30
|
+
);
|
|
27
31
|
};
|
|
28
32
|
const validateProps = (componentProps) => {
|
|
29
33
|
if (componentProps.firstElementRef === void 0) {
|
|
@@ -43,27 +47,34 @@ const validateProps = (componentProps) => {
|
|
|
43
47
|
}
|
|
44
48
|
};
|
|
45
49
|
const propTypes = {
|
|
46
|
-
firstElementRef: PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.node]).description(
|
|
47
|
-
|
|
50
|
+
firstElementRef: PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.node]).description(
|
|
51
|
+
"Reference to the first element in the focus trap."
|
|
52
|
+
).isRequired,
|
|
53
|
+
lastElementRef: PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.node]).description(
|
|
54
|
+
"Reference to the second element in the focus trap."
|
|
55
|
+
).isRequired,
|
|
48
56
|
onKeyDown: PropTypes.func.description("Optional onKeyDown callback.")
|
|
49
57
|
};
|
|
50
58
|
const useFocusTrap = (props) => {
|
|
51
59
|
useEffect(() => validateProps(props), [props]);
|
|
52
60
|
const { firstElementRef, lastElementRef, onKeyDown } = props;
|
|
53
|
-
return useCallback(
|
|
54
|
-
|
|
55
|
-
onKeyDown
|
|
56
|
-
|
|
57
|
-
e.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
e.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
return useCallback(
|
|
62
|
+
(e) => {
|
|
63
|
+
if (onKeyDown)
|
|
64
|
+
onKeyDown(e);
|
|
65
|
+
if (e.key === "Tab" && !e.shiftKey && e.target === lastElementRef.current && firstElementRef.current) {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
firstElementRef.current.focus();
|
|
69
|
+
}
|
|
70
|
+
if (e.key === "Tab" && e.shiftKey && e.target === firstElementRef.current && lastElementRef.current) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
lastElementRef.current.focus();
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
[firstElementRef, lastElementRef, onKeyDown]
|
|
77
|
+
);
|
|
67
78
|
};
|
|
68
79
|
useFocusTrap.displayName = "useFocusTrap";
|
|
69
80
|
const UseFocusTrapWithSchema = describe(useFocusTrap);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useFocusTrap.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useEffect, WeakValidationMap } from 'react';\nimport { describe, PropTypes } from '../props-helpers';\n\nconst useFocusTrapProps: { [index: string]: string } = {\n firstElementRef: 'object',\n lastElementRef: 'object',\n onKeyDown: 'function',\n};\n\nconst getVariableType = (arg: unknown): string => {\n if (Array.isArray(arg)) return 'array';\n if (arg === null) return 'null';\n if (arg === undefined) return 'undefined';\n return typeof arg;\n};\n\nconst throwTypeError = (validPropKey: string, invalidProp: unknown): void => {\n throw new Error(\n `Warning: You are trying to pass a not valid \"${validPropKey}\" property to use a useFocusTrap hook, please provide a valid type.\n\n Received: ${getVariableType(invalidProp)}\n Expected: ${useFocusTrapProps[validPropKey]}\n `,\n );\n};\n\nconst throwRequiredError = (validPropKey: string): void => {\n throw new Error(\n `Warning: Please provide a \"${validPropKey}\" property to use a useFocusTrap hook, this property is required.`,\n );\n};\n\nconst validateProps = (componentProps: Record<string, unknown>): void => {\n if (componentProps.firstElementRef === undefined) {\n throwRequiredError('firstElementRef');\n }\n if (componentProps.lastElementRef === undefined) {\n throwRequiredError('lastElementRef');\n }\n if (componentProps.firstElementRef && typeof componentProps.firstElementRef !== 'object') {\n throwTypeError('firstElementRef', componentProps.firstElementRef);\n }\n if (componentProps.lastElementRef && typeof componentProps.lastElementRef !== 'object') {\n throwTypeError('lastElementRef', componentProps.lastElementRef);\n }\n if (componentProps.onKeyDown && typeof componentProps.onKeyDown !== 'function') {\n throwTypeError('onKeyDown', componentProps.onKeyDown);\n }\n};\n\nconst propTypes = {\n firstElementRef: PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.node]).description(\n 'Reference to the first element in the focus trap.',\n ).isRequired,\n lastElementRef: PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.node]).description(\n 'Reference to the second element in the focus trap.',\n ).isRequired,\n onKeyDown: PropTypes.func.description('Optional onKeyDown callback.'),\n} as WeakValidationMap<unknown>;\n\ntype UseFocusTrapFunctionT = <T extends HTMLElement = HTMLElement, K extends HTMLElement = HTMLElement>({\n firstElementRef,\n lastElementRef,\n onKeyDown,\n}: {\n firstElementRef: React.MutableRefObject<T | null>;\n lastElementRef: React.MutableRefObject<K | null>;\n onKeyDown?: (e: KeyboardEvent) => void;\n}) => (e: KeyboardEvent) => void;\n\ninterface UseFocusTrapT extends UseFocusTrapFunctionT {\n displayName: 'useFocusTrap';\n}\n\nconst useFocusTrap: UseFocusTrapT = (props) => {\n // We need to investigate how to validate references with useValidateTypescriptPropTypes.\n useEffect(() => validateProps(props), [props]);\n\n const { firstElementRef, lastElementRef, onKeyDown } = props;\n\n return useCallback(\n (e: KeyboardEvent) => {\n if (onKeyDown) onKeyDown(e);\n // we need to check all the condition before preventing default\n // because we want last-element/first-element tab/shift-tab to keep working\n\n if (e.key === 'Tab' && !e.shiftKey && e.target === lastElementRef.current && firstElementRef.current) {\n e.preventDefault();\n e.stopPropagation();\n firstElementRef.current.focus();\n }\n if (e.key === 'Tab' && e.shiftKey && e.target === firstElementRef.current && lastElementRef.current) {\n e.preventDefault();\n e.stopPropagation();\n lastElementRef.current.focus();\n }\n },\n [firstElementRef, lastElementRef, onKeyDown],\n );\n};\n\nuseFocusTrap.displayName = 'useFocusTrap';\nconst UseFocusTrapWithSchema = describe(useFocusTrap);\n\nUseFocusTrapWithSchema.propTypes = propTypes;\n\nexport { useFocusTrap, UseFocusTrapWithSchema };\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAgB,aAAa,iBAAoC;AACjE,SAAS,UAAU,iBAAiB;AAEpC,MAAM,oBAAiD;AAAA,EACrD,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,WAAW;AACb;AAEA,MAAM,kBAAkB,CAAC,QAAyB;AAChD,MAAI,MAAM,QAAQ,GAAG;AAAG,WAAO;AAC/B,MAAI,QAAQ;AAAM,WAAO;AACzB,MAAI,QAAQ;AAAW,WAAO;AAC9B,SAAO,OAAO;AAChB;AAEA,MAAM,iBAAiB,CAAC,cAAsB,gBAA+B;AAC3E,QAAM,IAAI;AAAA,IACR,gDAAgD;AAAA;AAAA,cAEtC,gBAAgB,WAAW;AAAA,cAC3B,kBAAkB;AAAA;AAAA,EAE9B;AACF;AAEA,MAAM,qBAAqB,CAAC,iBAA+B;AACzD,QAAM,IAAI;AAAA,IACR,8BAA8B;AAAA,EAChC;AACF;AAEA,MAAM,gBAAgB,CAAC,mBAAkD;AACvE,MAAI,eAAe,oBAAoB,QAAW;AAChD,uBAAmB,iBAAiB;AAAA,EACtC;AACA,MAAI,eAAe,mBAAmB,QAAW;AAC/C,uBAAmB,gBAAgB;AAAA,EACrC;AACA,MAAI,eAAe,mBAAmB,OAAO,eAAe,oBAAoB,UAAU;AACxF,mBAAe,mBAAmB,eAAe,eAAe;AAAA,EAClE;AACA,MAAI,eAAe,kBAAkB,OAAO,eAAe,mBAAmB,UAAU;AACtF,mBAAe,kBAAkB,eAAe,cAAc;AAAA,EAChE;AACA,MAAI,eAAe,aAAa,OAAO,eAAe,cAAc,YAAY;AAC9E,mBAAe,aAAa,eAAe,SAAS;AAAA,EACtD;AACF;AAEA,MAAM,YAAY;AAAA,EAChB,iBAAiB,UAAU,UAAU,CAAC,UAAU,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,IAAI,CAAC,EAAE;AAAA,IAC9E;AAAA,EACF,EAAE;AAAA,EACF,gBAAgB,UAAU,UAAU,CAAC,UAAU,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,IAAI,CAAC,EAAE;AAAA,IAC7E;AAAA,EACF,EAAE;AAAA,EACF,WAAW,UAAU,KAAK,YAAY,8BAA8B;AACtE;AAgBA,MAAM,eAA8B,CAAC,UAAU;AAE7C,YAAU,MAAM,cAAc,KAAK,GAAG,CAAC,KAAK,CAAC;AAE7C,QAAM,EAAE,iBAAiB,gBAAgB,UAAU,IAAI;AAEvD,SAAO;AAAA,IACL,CAAC,MAAqB;AACpB,UAAI;AAAW,kBAAU,CAAC;AAI1B,UAAI,EAAE,QAAQ,SAAS,CAAC,EAAE,YAAY,EAAE,WAAW,eAAe,WAAW,gBAAgB,SAAS;AACpG,UAAE,eAAe;AACjB,UAAE,gBAAgB;AAClB,wBAAgB,QAAQ,MAAM;AAAA,MAChC;AACA,UAAI,EAAE,QAAQ,SAAS,EAAE,YAAY,EAAE,WAAW,gBAAgB,WAAW,eAAe,SAAS;AACnG,UAAE,eAAe;AACjB,UAAE,gBAAgB;AAClB,uBAAe,QAAQ,MAAM;AAAA,MAC/B;AAAA,IACF;AAAA,IACA,CAAC,iBAAiB,gBAAgB,SAAS;AAAA,EAC7C;AACF;AAEA,aAAa,cAAc;AAC3B,MAAM,yBAAyB,SAAS,YAAY;AAEpD,uBAAuB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useHotkeys.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import hotkeys, { KeyHandler } from 'hotkeys-js';\nimport { useCallback, useEffect } from 'react';\n\ntype Options = {\n scope?: string;\n element?: HTMLElement | null;\n keyup?: boolean | null;\n keydown?: boolean | null;\n splitKey?: string;\n};\ninterface UseHotKeysArg {\n keys: string;\n options?: Options;\n handler: KeyHandler;\n}\n\nexport const useHotkeys = ({ keys, handler, options = {} }: UseHotKeysArg, deps: unknown[] = []) => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const memoizedCallback = useCallback(handler, deps);\n\n useEffect(() => {\n hotkeys(keys, options, memoizedCallback);\n\n return () => hotkeys.unbind(keys);\n }, [keys, memoizedCallback, options]);\n};\n\nexport default useHotkeys;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAO,aAA6B;AACpC,SAAS,aAAa,iBAAiB;AAehC,MAAM,aAAa,CAAC,EAAE,MAAM,SAAS,UAAU,CAAC,EAAE,GAAkB,OAAkB,CAAC,MAAM;AAElG,QAAM,mBAAmB,YAAY,SAAS,IAAI;AAElD,YAAU,MAAM;AACd,YAAQ,MAAM,SAAS,gBAAgB;AAEvC,WAAO,MAAM,QAAQ,OAAO,IAAI;AAAA,EAClC,GAAG,CAAC,MAAM,kBAAkB,OAAO,CAAC;AACtC;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useHoverHandlersDelay.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useRef } from 'react';\n\ninterface UseHoverHandlersDelayArg {\n onMouseOver: () => void;\n onMouseLeave: () => void;\n hideDelay?: number;\n showDelay?: number;\n}\n\nexport const useHoverHandlersDelay = ({\n onMouseOver,\n onMouseLeave,\n hideDelay = 300,\n showDelay = 300,\n}: UseHoverHandlersDelayArg) => {\n const hideTimer = useRef<NodeJS.Timeout>();\n const showTimer = useRef<NodeJS.Timeout>();\n\n const delayedHide = useCallback(() => {\n if (showTimer.current) clearTimeout(showTimer.current);\n hideTimer.current = setTimeout(onMouseLeave, hideDelay);\n }, [hideDelay, onMouseLeave]);\n\n const delayedShow = useCallback(() => {\n if (hideTimer.current) clearTimeout(hideTimer.current);\n showTimer.current = setTimeout(onMouseOver, showDelay);\n }, [onMouseOver, showDelay]);\n\n return {\n onMouseOver: delayedShow,\n onMouseLeave: delayedHide,\n };\n};\n\nexport default useHoverHandlersDelay;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,aAAa,cAAc;AAS7B,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AACd,MAAgC;AAC9B,QAAM,YAAY,OAAuB;AACzC,QAAM,YAAY,OAAuB;AAEzC,QAAM,cAAc,YAAY,MAAM;AACpC,QAAI,UAAU;AAAS,mBAAa,UAAU,OAAO;AACrD,cAAU,UAAU,WAAW,cAAc,SAAS;AAAA,EACxD,GAAG,CAAC,WAAW,YAAY,CAAC;AAE5B,QAAM,cAAc,YAAY,MAAM;AACpC,QAAI,UAAU;AAAS,mBAAa,UAAU,OAAO;AACrD,cAAU,UAAU,WAAW,aAAa,SAAS;AAAA,EACvD,GAAG,CAAC,aAAa,SAAS,CAAC;AAE3B,SAAO;AAAA,IACL,aAAa;AAAA,IACb,cAAc;AAAA,EAChB;AACF;AAEA,IAAO,gCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useIsMobile.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useState, useEffect } from 'react';\nimport { getDefaultTheme } from '@elliemae/pui-theme';\nimport type { Theme } from '@elliemae/pui-theme';\n\nconst theme = getDefaultTheme() as Theme;\n\nconst isMobile = (): boolean => {\n if (!window) return false;\n return Number(theme.breakpoints.medium.split('px')[0]) - window.innerWidth >= 0;\n};\n\nexport const useIsMobile = (): boolean => {\n const [mobile, setMobile] = useState<boolean>(isMobile());\n\n useEffect(() => {\n function handleResize() {\n setMobile(isMobile());\n }\n window?.addEventListener('resize', handleResize);\n return () => {\n window?.removeEventListener('resize', handleResize);\n };\n }, []);\n\n if (!window) return false;\n return mobile;\n};\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,UAAU,iBAAiB;AACpC,SAAS,uBAAuB;AAGhC,MAAM,QAAQ,gBAAgB;AAE9B,MAAM,WAAW,MAAe;AAC9B,MAAI,CAAC;AAAQ,WAAO;AACpB,SAAO,OAAO,MAAM,YAAY,OAAO,MAAM,IAAI,EAAE,EAAE,IAAI,OAAO,cAAc;AAChF;AAEO,MAAM,cAAc,MAAe;AACxC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAkB,SAAS,CAAC;AAExD,YAAU,MAAM;AACd,aAAS,eAAe;AACtB,gBAAU,SAAS,CAAC;AAAA,IACtB;AACA,YAAQ,iBAAiB,UAAU,YAAY;AAC/C,WAAO,MAAM;AACX,cAAQ,oBAAoB,UAAU,YAAY;AAAA,IACpD;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,MAAI,CAAC;AAAQ,WAAO;AACpB,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,13 +3,16 @@ import { useEffect, useState, useMemo } from "react";
|
|
|
3
3
|
const useIsShowingEllipsis = () => {
|
|
4
4
|
const [element, setElement] = useState();
|
|
5
5
|
const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);
|
|
6
|
-
const resizeObserver = useMemo(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const resizeObserver = useMemo(
|
|
7
|
+
() => new ResizeObserver((entries) => {
|
|
8
|
+
if (entries.length) {
|
|
9
|
+
const [textWrapperEntry] = entries;
|
|
10
|
+
const el = textWrapperEntry.target;
|
|
11
|
+
setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);
|
|
12
|
+
}
|
|
13
|
+
}),
|
|
14
|
+
[]
|
|
15
|
+
);
|
|
13
16
|
useEffect(() => {
|
|
14
17
|
if (element) {
|
|
15
18
|
setIsShowingEllipsis(element.scrollWidth > element.clientWidth);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useIsShowingEllipsis.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useEffect, useState, useMemo } from 'react';\n\nexport const useIsShowingEllipsis = <T extends HTMLElement | null = HTMLElement | null>() => {\n const [element, setElement] = useState<T>();\n\n const [isShowingEllipsis, setIsShowingEllipsis] = useState(false);\n\n const resizeObserver = useMemo(\n () =>\n new ResizeObserver((entries) => {\n if (entries.length) {\n const [textWrapperEntry] = entries;\n const el = textWrapperEntry.target;\n setIsShowingEllipsis(el?.scrollWidth > el?.clientWidth);\n }\n }),\n [],\n );\n\n useEffect(() => {\n if (element) {\n setIsShowingEllipsis(element.scrollWidth > element.clientWidth);\n resizeObserver.observe(element);\n }\n return () => {\n if (element) {\n resizeObserver.unobserve(element);\n }\n };\n }, [resizeObserver, element]);\n\n return { setElement, isShowingEllipsis };\n};\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,WAAW,UAAU,eAAe;AAEtC,MAAM,uBAAuB,MAAyD;AAC3F,QAAM,CAAC,SAAS,UAAU,IAAI,SAAY;AAE1C,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAS,KAAK;AAEhE,QAAM,iBAAiB;AAAA,IACrB,MACE,IAAI,eAAe,CAAC,YAAY;AAC9B,UAAI,QAAQ,QAAQ;AAClB,cAAM,CAAC,gBAAgB,IAAI;AAC3B,cAAM,KAAK,iBAAiB;AAC5B,6BAAqB,IAAI,cAAc,IAAI,WAAW;AAAA,MACxD;AAAA,IACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,YAAU,MAAM;AACd,QAAI,SAAS;AACX,2BAAqB,QAAQ,cAAc,QAAQ,WAAW;AAC9D,qBAAe,QAAQ,OAAO;AAAA,IAChC;AACA,WAAO,MAAM;AACX,UAAI,SAAS;AACX,uBAAe,UAAU,OAAO;AAAA,MAClC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,gBAAgB,OAAO,CAAC;AAE5B,SAAO,EAAE,YAAY,kBAAkB;AACzC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,14 +4,17 @@ import { describe, PropTypes } from "../props-helpers";
|
|
|
4
4
|
const propTypes = {
|
|
5
5
|
onBlur: PropTypes.func.description("The function to be invoked when focus exits the wrapping container").signature("((e: React.FocusEvent, ...args: unknown[]) => void)").isRequired
|
|
6
6
|
};
|
|
7
|
-
const useOnBlurOut = ({ onBlur }) => useCallback(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
7
|
+
const useOnBlurOut = ({ onBlur }) => useCallback(
|
|
8
|
+
(e, ...args) => {
|
|
9
|
+
const { currentTarget } = e;
|
|
10
|
+
requestAnimationFrame(() => {
|
|
11
|
+
if (!currentTarget.contains(document.activeElement)) {
|
|
12
|
+
onBlur(e, ...args);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
[onBlur]
|
|
17
|
+
);
|
|
15
18
|
const UseOnBlurOutWithSchema = describe(useOnBlurOut);
|
|
16
19
|
UseOnBlurOutWithSchema.propTypes = propTypes;
|
|
17
20
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useOnBlurOut.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, WeakValidationMap } from 'react';\nimport { describe, PropTypes } from '../props-helpers';\n\nconst propTypes = {\n onBlur: PropTypes.func\n .description('The function to be invoked when focus exits the wrapping container')\n .signature('((e: React.FocusEvent, ...args: unknown[]) => void)').isRequired,\n} as WeakValidationMap<unknown>;\n\ntype OnBlurCb = (e: React.FocusEvent, ...args: unknown[]) => void;\ntype UseOnBlurOut = ({ onBlur }: { onBlur: OnBlurCb }) => OnBlurCb;\nconst useOnBlurOut: UseOnBlurOut = ({ onBlur }) =>\n useCallback<OnBlurCb>(\n (e, ...args) => {\n const { currentTarget } = e;\n // Give browser time to focus the next element\n requestAnimationFrame(() => {\n // Check if the new focused element is a child of the original container\n if (!currentTarget.contains(document.activeElement)) {\n onBlur(e, ...args);\n }\n });\n },\n [onBlur],\n );\n\nconst UseOnBlurOutWithSchema = describe(useOnBlurOut);\nUseOnBlurOutWithSchema.propTypes = propTypes;\n\nexport { useOnBlurOut, UseOnBlurOutWithSchema };\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAgB,mBAAsC;AACtD,SAAS,UAAU,iBAAiB;AAEpC,MAAM,YAAY;AAAA,EAChB,QAAQ,UAAU,KACf,YAAY,oEAAoE,EAChF,UAAU,qDAAqD,EAAE;AACtE;AAIA,MAAM,eAA6B,CAAC,EAAE,OAAO,MAC3C;AAAA,EACE,CAAC,MAAM,SAAS;AACd,UAAM,EAAE,cAAc,IAAI;AAE1B,0BAAsB,MAAM;AAE1B,UAAI,CAAC,cAAc,SAAS,SAAS,aAAa,GAAG;AACnD,eAAO,GAAG,GAAG,IAAI;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EACA,CAAC,MAAM;AACT;AAEF,MAAM,yBAAyB,SAAS,YAAY;AACpD,uBAAuB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -15,10 +15,13 @@ const useOnElementResize = (targetRef) => {
|
|
|
15
15
|
observer.current?.disconnect();
|
|
16
16
|
};
|
|
17
17
|
}, [targetRef]);
|
|
18
|
-
return useMemo(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
return useMemo(
|
|
19
|
+
() => ({
|
|
20
|
+
width,
|
|
21
|
+
height
|
|
22
|
+
}),
|
|
23
|
+
[width, height]
|
|
24
|
+
);
|
|
22
25
|
};
|
|
23
26
|
export {
|
|
24
27
|
useOnElementResize
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useOnElementResize.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect, useRef, useMemo } from 'react';\n\n// Custom hook to track dimension of a component\n// Taken and modified from https://stackoverflow.com/a/60218754\nexport const useOnElementResize = <T extends HTMLElement>(\n targetRef: React.RefObject<T>,\n): Record<'width' | 'height', number> => {\n const [width, setWidth] = useState(targetRef.current?.offsetWidth ?? 0);\n const [height, setHeight] = useState(targetRef.current?.offsetHeight ?? 0);\n const observer = useRef<ResizeObserver>();\n\n useEffect(() => {\n function outputsize() {\n setWidth(targetRef.current?.offsetWidth ?? 0);\n setHeight(targetRef.current?.offsetHeight ?? 0);\n }\n\n observer.current = new ResizeObserver(outputsize);\n observer.current.observe(targetRef.current as Element);\n\n return () => {\n observer.current?.disconnect();\n };\n }, [targetRef]);\n\n return useMemo(\n () => ({\n width,\n height,\n }),\n [width, height],\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAgB,UAAU,WAAW,QAAQ,eAAe;AAIrD,MAAM,qBAAqB,CAChC,cACuC;AACvC,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,UAAU,SAAS,eAAe,CAAC;AACtE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,UAAU,SAAS,gBAAgB,CAAC;AACzE,QAAM,WAAW,OAAuB;AAExC,YAAU,MAAM;AACd,aAAS,aAAa;AACpB,eAAS,UAAU,SAAS,eAAe,CAAC;AAC5C,gBAAU,UAAU,SAAS,gBAAgB,CAAC;AAAA,IAChD;AAEA,aAAS,UAAU,IAAI,eAAe,UAAU;AAChD,aAAS,QAAQ,QAAQ,UAAU,OAAkB;AAErD,WAAO,MAAM;AACX,eAAS,SAAS,WAAW;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,SAAS,CAAC;AAEd,SAAO;AAAA,IACL,OAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,OAAO,MAAM;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,28 +7,37 @@ const propTypes = {
|
|
|
7
7
|
};
|
|
8
8
|
const useOnFirstFocusIn = ({ onFirstFocus, onBlur }) => {
|
|
9
9
|
const mutableDidChildBlur = useRef(false);
|
|
10
|
-
const onFirstFocusHelper = useCallback(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
const onFirstFocusHelper = useCallback(
|
|
11
|
+
(e, ...args) => {
|
|
12
|
+
const { currentTarget } = e;
|
|
13
|
+
requestAnimationFrame(() => {
|
|
14
|
+
const isChildFocus = currentTarget.contains(document.activeElement);
|
|
15
|
+
const isFirstFocus = isChildFocus && !mutableDidChildBlur.current;
|
|
16
|
+
if (isFirstFocus) {
|
|
17
|
+
onFirstFocus(e, ...args);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
[onFirstFocus]
|
|
22
|
+
);
|
|
23
|
+
const onBlurHelper = useCallback(
|
|
24
|
+
(e, ...args) => {
|
|
25
|
+
onBlur?.(e, ...args);
|
|
26
|
+
const { currentTarget } = e;
|
|
27
|
+
requestAnimationFrame(() => {
|
|
28
|
+
const isChildBlur = currentTarget.contains(document.activeElement);
|
|
29
|
+
mutableDidChildBlur.current = isChildBlur;
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
[onBlur]
|
|
33
|
+
);
|
|
34
|
+
return useMemo(
|
|
35
|
+
() => ({
|
|
36
|
+
onFirstFocus: onFirstFocusHelper,
|
|
37
|
+
onBlur: onBlurHelper
|
|
38
|
+
}),
|
|
39
|
+
[onFirstFocusHelper, onBlurHelper]
|
|
40
|
+
);
|
|
32
41
|
};
|
|
33
42
|
const UseOnFirstFocusInWithSchema = describe(useOnFirstFocusIn);
|
|
34
43
|
UseOnFirstFocusInWithSchema.propTypes = propTypes;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useOnFirstFocusIn.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useMemo, useRef, WeakValidationMap } from 'react';\nimport { describe, PropTypes } from '../props-helpers';\n\nconst propTypes = {\n onFirstFocusCb: PropTypes.func\n .description('The function to be invoked when focus enters the wrapping container for the first time')\n .signature('((e: React.FocusEvent, ...args: unknown[]) => void)').isRequired,\n onBlurCb: PropTypes.func\n .description('Optional onBlur function to be invoked along the returned onBlur handler')\n .signature('((e: React.FocusEvent, ...args: unknown[]) => void)'),\n} as WeakValidationMap<unknown>;\n\ntype OnBlurCb = (e: React.FocusEvent, ...args: unknown[]) => void;\ntype OnFirstFocusCb = (e: React.FocusEvent, ...args: unknown[]) => void;\ntype UseFirstFocusIn = ({ onFirstFocus, onBlur }: { onFirstFocus: OnFirstFocusCb; onBlur: OnBlurCb }) => {\n onFirstFocus: OnFirstFocusCb;\n onBlur: OnBlurCb;\n};\n\nconst useOnFirstFocusIn: UseFirstFocusIn = ({ onFirstFocus, onBlur }) => {\n const mutableDidChildBlur = useRef(false);\n const onFirstFocusHelper = useCallback<OnFirstFocusCb>(\n (e, ...args) => {\n const { currentTarget } = e;\n // Give browser time to focus the next element\n requestAnimationFrame(() => {\n const isChildFocus = currentTarget.contains(document.activeElement);\n const isFirstFocus = isChildFocus && !mutableDidChildBlur.current;\n if (isFirstFocus) {\n onFirstFocus(e, ...args);\n }\n });\n },\n [onFirstFocus],\n );\n const onBlurHelper = useCallback<OnBlurCb>(\n (e, ...args) => {\n onBlur?.(e, ...args);\n const { currentTarget } = e;\n // Give browser time to focus the next element\n requestAnimationFrame(() => {\n const isChildBlur = currentTarget.contains(document.activeElement);\n mutableDidChildBlur.current = isChildBlur;\n });\n },\n [onBlur],\n );\n return useMemo(\n () => ({\n onFirstFocus: onFirstFocusHelper,\n onBlur: onBlurHelper,\n }),\n [onFirstFocusHelper, onBlurHelper],\n );\n};\n\nconst UseOnFirstFocusInWithSchema = describe(useOnFirstFocusIn);\nUseOnFirstFocusInWithSchema.propTypes = propTypes;\n\nexport { useOnFirstFocusIn, UseOnFirstFocusInWithSchema };\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAgB,aAAa,SAAS,cAAiC;AACvE,SAAS,UAAU,iBAAiB;AAEpC,MAAM,YAAY;AAAA,EAChB,gBAAgB,UAAU,KACvB,YAAY,wFAAwF,EACpG,UAAU,qDAAqD,EAAE;AAAA,EACpE,UAAU,UAAU,KACjB,YAAY,0EAA0E,EACtF,UAAU,qDAAqD;AACpE;AASA,MAAM,oBAAqC,CAAC,EAAE,cAAc,OAAO,MAAM;AACvE,QAAM,sBAAsB,OAAO,KAAK;AACxC,QAAM,qBAAqB;AAAA,IACzB,CAAC,MAAM,SAAS;AACd,YAAM,EAAE,cAAc,IAAI;AAE1B,4BAAsB,MAAM;AAC1B,cAAM,eAAe,cAAc,SAAS,SAAS,aAAa;AAClE,cAAM,eAAe,gBAAgB,CAAC,oBAAoB;AAC1D,YAAI,cAAc;AAChB,uBAAa,GAAG,GAAG,IAAI;AAAA,QACzB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AACA,QAAM,eAAe;AAAA,IACnB,CAAC,MAAM,SAAS;AACd,eAAS,GAAG,GAAG,IAAI;AACnB,YAAM,EAAE,cAAc,IAAI;AAE1B,4BAAsB,MAAM;AAC1B,cAAM,cAAc,cAAc,SAAS,SAAS,aAAa;AACjE,4BAAoB,UAAU;AAAA,MAChC,CAAC;AAAA,IACH;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AACA,SAAO;AAAA,IACL,OAAO;AAAA,MACL,cAAc;AAAA,MACd,QAAQ;AAAA,IACV;AAAA,IACA,CAAC,oBAAoB,YAAY;AAAA,EACnC;AACF;AAEA,MAAM,8BAA8B,SAAS,iBAAiB;AAC9D,4BAA4B,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,13 +2,18 @@ import * as React from "react";
|
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { describe, PropTypes } from "../props-helpers";
|
|
4
4
|
const propTypes = {
|
|
5
|
-
onFocus: PropTypes.func.description(
|
|
5
|
+
onFocus: PropTypes.func.description(
|
|
6
|
+
"The function to be invoked when focusing specifically the element attached to (ignoring child focus events)"
|
|
7
|
+
).signature("((e: React.FocusEvent, ...args: unknown[]) => void)").isRequired
|
|
6
8
|
};
|
|
7
|
-
const useOnSpecificFocus = ({ onFocus }) => useCallback(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const useOnSpecificFocus = ({ onFocus }) => useCallback(
|
|
10
|
+
(e, ...args) => {
|
|
11
|
+
const { currentTarget, target } = e;
|
|
12
|
+
if (currentTarget === target && document.activeElement === currentTarget)
|
|
13
|
+
onFocus(e, ...args);
|
|
14
|
+
},
|
|
15
|
+
[onFocus]
|
|
16
|
+
);
|
|
12
17
|
const UseOnSpecificFocusWithSchema = describe(useOnSpecificFocus);
|
|
13
18
|
UseOnSpecificFocusWithSchema.propTypes = propTypes;
|
|
14
19
|
export {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useOnSpecificFocus.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, WeakValidationMap } from 'react';\nimport { describe, PropTypes } from '../props-helpers';\n\nconst propTypes = {\n onFocus: PropTypes.func\n .description(\n 'The function to be invoked when focusing specifically the element attached to (ignoring child focus events)',\n )\n .signature('((e: React.FocusEvent, ...args: unknown[]) => void)').isRequired,\n} as WeakValidationMap<unknown>;\n\ntype OnFocusCb = (e: React.FocusEvent, ...args: unknown[]) => void;\ntype UseOnBlurOut = ({ onFocus }: { onFocus: OnFocusCb }) => OnFocusCb;\nconst useOnSpecificFocus: UseOnBlurOut = ({ onFocus }) =>\n useCallback<OnFocusCb>(\n (e, ...args) => {\n const { currentTarget, target } = e;\n if (currentTarget === target && document.activeElement === currentTarget) onFocus(e, ...args);\n },\n [onFocus],\n );\nconst UseOnSpecificFocusWithSchema = describe(useOnSpecificFocus);\nUseOnSpecificFocusWithSchema.propTypes = propTypes;\n\nexport { useOnSpecificFocus, UseOnSpecificFocusWithSchema };\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAgB,mBAAsC;AACtD,SAAS,UAAU,iBAAiB;AAEpC,MAAM,YAAY;AAAA,EAChB,SAAS,UAAU,KAChB;AAAA,IACC;AAAA,EACF,EACC,UAAU,qDAAqD,EAAE;AACtE;AAIA,MAAM,qBAAmC,CAAC,EAAE,QAAQ,MAClD;AAAA,EACE,CAAC,MAAM,SAAS;AACd,UAAM,EAAE,eAAe,OAAO,IAAI;AAClC,QAAI,kBAAkB,UAAU,SAAS,kBAAkB;AAAe,cAAQ,GAAG,GAAG,IAAI;AAAA,EAC9F;AAAA,EACA,CAAC,OAAO;AACV;AACF,MAAM,+BAA+B,SAAS,kBAAkB;AAChE,6BAA6B,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/usePrevious.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useEffect, useRef } from 'react';\n\nexport const usePrevious = (value: unknown) => {\n const ref = useRef<unknown>();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n};\n\nexport default usePrevious;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,WAAW,cAAc;AAE3B,MAAM,cAAc,CAAC,UAAmB;AAC7C,QAAM,MAAM,OAAgB;AAE5B,YAAU,MAAM;AACd,QAAI,UAAU;AAAA,EAChB,GAAG,CAAC,KAAK,CAAC;AAEV,SAAO,IAAI;AACb;AAEA,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,17 +4,25 @@ import raf from "raf";
|
|
|
4
4
|
import ResizeObserver from "resize-observer-polyfill";
|
|
5
5
|
const useResizeObserver = (handler, el) => {
|
|
6
6
|
const [node, setRef] = useState(el);
|
|
7
|
-
const resizeObserver = useMemo(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
const resizeObserver = useMemo(
|
|
8
|
+
() => new ResizeObserver((entries) => {
|
|
9
|
+
if (!Array.isArray(entries))
|
|
10
|
+
return;
|
|
11
|
+
if (!entries.length)
|
|
12
|
+
return;
|
|
13
|
+
const entry = entries[0];
|
|
14
|
+
raf(
|
|
15
|
+
() => handler(
|
|
16
|
+
{
|
|
17
|
+
width: entry.target.offsetWidth,
|
|
18
|
+
height: entry.target.offsetHeight
|
|
19
|
+
},
|
|
20
|
+
entry.target
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
}),
|
|
24
|
+
[handler]
|
|
25
|
+
);
|
|
18
26
|
const htmlEl = el || node;
|
|
19
27
|
useEffect(() => {
|
|
20
28
|
if (htmlEl)
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useResizeObserver.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useEffect, useMemo, useState } from 'react';\nimport raf from 'raf';\nimport ResizeObserver from 'resize-observer-polyfill';\n\ntype HandlerT = (measures: { width: number; height: number }, element: Element) => void;\n\nexport const useResizeObserver = (handler: HandlerT, el: HTMLElement) => {\n const [node, setRef] = useState(el);\n\n const resizeObserver = useMemo(\n () =>\n new ResizeObserver((entries) => {\n if (!Array.isArray(entries)) return;\n if (!entries.length) return;\n const entry = entries[0];\n\n // execute on the next animation frame\n raf(() =>\n handler(\n {\n width: (entry.target as HTMLElement).offsetWidth,\n height: (entry.target as HTMLElement).offsetHeight,\n },\n entry.target,\n ),\n );\n }),\n [handler],\n );\n\n const htmlEl = el || node;\n\n useEffect(() => {\n if (htmlEl) resizeObserver.observe(htmlEl);\n return () => htmlEl && resizeObserver.unobserve(htmlEl);\n }, [htmlEl, resizeObserver]);\n\n return [setRef];\n};\n\nexport default useResizeObserver;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,WAAW,SAAS,gBAAgB;AAC7C,OAAO,SAAS;AAChB,OAAO,oBAAoB;AAIpB,MAAM,oBAAoB,CAAC,SAAmB,OAAoB;AACvE,QAAM,CAAC,MAAM,MAAM,IAAI,SAAS,EAAE;AAElC,QAAM,iBAAiB;AAAA,IACrB,MACE,IAAI,eAAe,CAAC,YAAY;AAC9B,UAAI,CAAC,MAAM,QAAQ,OAAO;AAAG;AAC7B,UAAI,CAAC,QAAQ;AAAQ;AACrB,YAAM,QAAQ,QAAQ;AAGtB;AAAA,QAAI,MACF;AAAA,UACE;AAAA,YACE,OAAQ,MAAM,OAAuB;AAAA,YACrC,QAAS,MAAM,OAAuB;AAAA,UACxC;AAAA,UACA,MAAM;AAAA,QACR;AAAA,MACF;AAAA,IACF,CAAC;AAAA,IACH,CAAC,OAAO;AAAA,EACV;AAEA,QAAM,SAAS,MAAM;AAErB,YAAU,MAAM;AACd,QAAI;AAAQ,qBAAe,QAAQ,MAAM;AACzC,WAAO,MAAM,UAAU,eAAe,UAAU,MAAM;AAAA,EACxD,GAAG,CAAC,QAAQ,cAAc,CAAC;AAE3B,SAAO,CAAC,MAAM;AAChB;AAEA,IAAO,4BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useShouldRecalculate.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef } from 'react';\n\nexport const useShouldRecalculate = (bool: boolean) => {\n const prevValueRef = useRef(0);\n if (!bool) {\n // If we need to recalculate, change the value we return\n prevValueRef.current += 1;\n } // else we return the same value as the previous render, which won't trigger a recalculation\n return prevValueRef.current;\n};\n\nexport default useShouldRecalculate;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,cAAc;AAEhB,MAAM,uBAAuB,CAAC,SAAkB;AACrD,QAAM,eAAe,OAAO,CAAC;AAC7B,MAAI,CAAC,MAAM;AAET,iBAAa,WAAW;AAAA,EAC1B;AACA,SAAO,aAAa;AACtB;AAEA,IAAO,+BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -26,19 +26,22 @@ const useWindowScrollerList = ({ listInstance, outerListRef }) => {
|
|
|
26
26
|
listOffset.current = getPositionOffset(outerListRef.current, scrollableParent.current);
|
|
27
27
|
}
|
|
28
28
|
}, [outerListRef]);
|
|
29
|
-
const handleScroll = useCallback(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
listInstance.current
|
|
41
|
-
|
|
29
|
+
const handleScroll = useCallback(
|
|
30
|
+
(e) => {
|
|
31
|
+
if (!scrollableParent.current) {
|
|
32
|
+
const containerTarget = e.target === document ? document.body : e.target;
|
|
33
|
+
scrollableParent.current = isParent(containerTarget, outerListRef.current) && containerTarget;
|
|
34
|
+
}
|
|
35
|
+
if (!scrollableParent.current)
|
|
36
|
+
return;
|
|
37
|
+
getElementOffset();
|
|
38
|
+
const scrollOffset = getScrollOffset(scrollableParent.current);
|
|
39
|
+
const scrollTop = Math.max(0, scrollOffset.top - (listOffset.current?.top ?? 0));
|
|
40
|
+
if (listInstance.current)
|
|
41
|
+
listInstance.current.scrollTo({ top: scrollTop });
|
|
42
|
+
},
|
|
43
|
+
[getElementOffset, listInstance, outerListRef]
|
|
44
|
+
);
|
|
42
45
|
useEffect(() => {
|
|
43
46
|
window.addEventListener("scroll", handleScroll, true);
|
|
44
47
|
window.addEventListener("resize", getElementOffset, true);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useWindowScrollerList.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useEffect, useRef } from 'react';\n\ninterface UseWindowScrollerListArg {\n listInstance: React.RefObject<HTMLElement>;\n outerListRef: React.RefObject<HTMLElement>;\n}\n\nfunction getScrollOffset(element = { scrollTop: 0, scrollLeft: 0 }) {\n return {\n top: element.scrollTop,\n left: element.scrollLeft,\n };\n}\n\nfunction getPositionOffset(listEl: HTMLElement, scrollableEl: HTMLElement) {\n const scrollOffset = getScrollOffset(scrollableEl);\n const elementRect = listEl.getBoundingClientRect();\n const containerRect = scrollableEl.getBoundingClientRect();\n return {\n top: elementRect.top + scrollOffset.top - containerRect.top,\n left: elementRect.left + scrollOffset.top - containerRect.left,\n };\n}\n\nfunction isParent(parentNode: EventTarget | null, childNode: HTMLElement | null): boolean {\n return (\n childNode?.parentNode === (parentNode as ParentNode) ||\n (!!childNode?.parentNode && isParent(parentNode, childNode.parentNode as HTMLElement))\n );\n}\n\nexport const useWindowScrollerList = ({ listInstance, outerListRef }: UseWindowScrollerListArg) => {\n const scrollableParent = useRef<HTMLElement | false>();\n const listOffset = useRef<ReturnType<typeof getPositionOffset>>();\n\n const getElementOffset = useCallback(() => {\n if (outerListRef.current && scrollableParent.current) {\n listOffset.current = getPositionOffset(outerListRef.current, scrollableParent.current);\n }\n }, [outerListRef]);\n\n const handleScroll: EventListener = useCallback(\n (e) => {\n if (!scrollableParent.current) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const containerTarget = e.target === document ? document.body : e.target;\n scrollableParent.current = isParent(containerTarget, outerListRef.current) && (containerTarget as HTMLElement);\n }\n\n if (!scrollableParent.current) return;\n\n getElementOffset();\n\n const scrollOffset = getScrollOffset(scrollableParent.current);\n const scrollTop = Math.max(0, scrollOffset.top - (listOffset.current?.top ?? 0));\n if (listInstance.current) listInstance.current.scrollTo({ top: scrollTop });\n },\n [getElementOffset, listInstance, outerListRef],\n );\n\n useEffect(() => {\n window.addEventListener('scroll', handleScroll, true);\n window.addEventListener('resize', getElementOffset, true);\n return () => {\n window.removeEventListener('scroll', handleScroll, true);\n window.removeEventListener('resize', getElementOffset, true);\n };\n }, [getElementOffset, handleScroll]);\n};\n\nexport default useWindowScrollerList;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAgB,aAAa,WAAW,cAAc;AAOtD,SAAS,gBAAgB,UAAU,EAAE,WAAW,GAAG,YAAY,EAAE,GAAG;AAClE,SAAO;AAAA,IACL,KAAK,QAAQ;AAAA,IACb,MAAM,QAAQ;AAAA,EAChB;AACF;AAEA,SAAS,kBAAkB,QAAqB,cAA2B;AACzE,QAAM,eAAe,gBAAgB,YAAY;AACjD,QAAM,cAAc,OAAO,sBAAsB;AACjD,QAAM,gBAAgB,aAAa,sBAAsB;AACzD,SAAO;AAAA,IACL,KAAK,YAAY,MAAM,aAAa,MAAM,cAAc;AAAA,IACxD,MAAM,YAAY,OAAO,aAAa,MAAM,cAAc;AAAA,EAC5D;AACF;AAEA,SAAS,SAAS,YAAgC,WAAwC;AACxF,SACE,WAAW,eAAgB,cAC1B,CAAC,CAAC,WAAW,cAAc,SAAS,YAAY,UAAU,UAAyB;AAExF;AAEO,MAAM,wBAAwB,CAAC,EAAE,cAAc,aAAa,MAAgC;AACjG,QAAM,mBAAmB,OAA4B;AACrD,QAAM,aAAa,OAA6C;AAEhE,QAAM,mBAAmB,YAAY,MAAM;AACzC,QAAI,aAAa,WAAW,iBAAiB,SAAS;AACpD,iBAAW,UAAU,kBAAkB,aAAa,SAAS,iBAAiB,OAAO;AAAA,IACvF;AAAA,EACF,GAAG,CAAC,YAAY,CAAC;AAEjB,QAAM,eAA8B;AAAA,IAClC,CAAC,MAAM;AACL,UAAI,CAAC,iBAAiB,SAAS;AAE7B,cAAM,kBAAkB,EAAE,WAAW,WAAW,SAAS,OAAO,EAAE;AAClE,yBAAiB,UAAU,SAAS,iBAAiB,aAAa,OAAO,KAAM;AAAA,MACjF;AAEA,UAAI,CAAC,iBAAiB;AAAS;AAE/B,uBAAiB;AAEjB,YAAM,eAAe,gBAAgB,iBAAiB,OAAO;AAC7D,YAAM,YAAY,KAAK,IAAI,GAAG,aAAa,OAAO,WAAW,SAAS,OAAO,EAAE;AAC/E,UAAI,aAAa;AAAS,qBAAa,QAAQ,SAAS,EAAE,KAAK,UAAU,CAAC;AAAA,IAC5E;AAAA,IACA,CAAC,kBAAkB,cAAc,YAAY;AAAA,EAC/C;AAEA,YAAU,MAAM;AACd,WAAO,iBAAiB,UAAU,cAAc,IAAI;AACpD,WAAO,iBAAiB,UAAU,kBAAkB,IAAI;AACxD,WAAO,MAAM;AACX,aAAO,oBAAoB,UAAU,cAAc,IAAI;AACvD,aAAO,oBAAoB,UAAU,kBAAkB,IAAI;AAAA,IAC7D;AAAA,EACF,GAAG,CAAC,kBAAkB,YAAY,CAAC;AACrC;AAEA,IAAO,gCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as getComponentFromProps } from './getComponentFromProps';\nexport { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements';\nexport { capitalize } from './capitalize';\nexport { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities';\nexport {\n checkNotEmpty,\n checkEmpty,\n greaterThan,\n validDate,\n equal,\n notEqual,\n isNull,\n isNotNull,\n isIn,\n isNotIn,\n greaterThanOrEquals,\n lessThanOrEquals,\n startsWith,\n contains,\n} from './operators';\nexport {\n cx,\n runAll,\n hashArray,\n safeCall,\n removeUndefinedProperties,\n isObject,\n curry,\n arrayMove,\n uniq,\n filter,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n cloneDeep,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n pull,\n sortBy,\n sumBy,\n transform,\n isFunction,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n toggleInObject,\n toggleInArray,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n addOrRemove,\n isEqualWith,\n isBoolean,\n} from './utils';\nexport { setRef, mergeRefs, setMultipleRefs, logger } from './system';\nexport {\n useMeasure,\n useForceUpdate,\n useOnClickOutside,\n useExecutionTimer,\n useExpandState,\n useHotkeys,\n useHoverHandlersDelay,\n useResizeObserver,\n useShouldRecalculate,\n useWindowScrollerList,\n usePrevious,\n useCancellableDelayedCallback,\n useDerivedStateFromProps,\n useOnElementResize,\n useIsShowingEllipsis,\n useCallbackAfterRender,\n useFocusTrap,\n UseFocusTrapWithSchema,\n useIsMobile,\n useOnBlurOut,\n UseOnBlurOutWithSchema,\n useOnFirstFocusIn,\n UseOnFirstFocusInWithSchema,\n useOnSpecificFocus,\n UseOnSpecificFocusWithSchema,\n} from './hooks';\nexport { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils';\nexport { compose } from './compose';\nexport { DOCUMENT, WINDOW } from './platform';\nexport { isDOMTypeElement } from './reactTypesUtility';\nexport { isRequired, isGreaterThan, isValidDate } from './validations';\n\n// TODO -- REMOVE WHEN READY\nexport * from './deprecated';\nexport * from './props-helpers';\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAoB,WAAXA,gBAAwC;AACjD,SAAoB,WAAXA,gBAA0D;AACnE,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB,4BAA4B;AAC7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QAAQ,WAAW,iBAAiB,cAAc;AAC3D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB,uBAAuB;AACxD,SAAS,eAAe;AACxB,SAAS,UAAU,cAAc;AACjC,SAAS,wBAAwB;AACjC,SAAS,YAAY,eAAe,mBAAmB;AAGvD,cAAc;AACd,cAAc;",
|
|
6
|
+
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/objectUtilities.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "const JSONKeyValueRegExp = /\"(.+?)\": \"(.+?)\",?$/gm;\nconst prettyStringfy = (obj: Record<string, unknown>): string => JSON.stringify(obj, null, 2);\nfunction getFirstGroup(regexp: RegExp, str: string) {\n const array = [...str.matchAll(regexp)];\n const firstGroup = array.map((m) => m[1]).filter((v) => v !== undefined);\n if (firstGroup.length > 0) return firstGroup;\n return null;\n}\nfunction getSecondGroup(regexp: RegExp, str: string) {\n const array = [...str.matchAll(regexp)];\n const secondGroup = array.map((m) => m[2]).filter((v) => v !== undefined);\n if (secondGroup.length > 0) return secondGroup;\n return null;\n}\nexport const getObjectValuesToArray = (obj: Record<string, unknown>): string[] | null =>\n getSecondGroup(JSONKeyValueRegExp, prettyStringfy(obj));\n\nexport const getObjectKeysToArray = (obj: Record<string, unknown>): string[] | null =>\n getFirstGroup(JSONKeyValueRegExp, prettyStringfy(obj));"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,MAAM,qBAAqB;AAC3B,MAAM,iBAAiB,CAAC,QAAyC,KAAK,UAAU,KAAK,MAAM,CAAC;AAC5F,SAAS,cAAc,QAAgB,KAAa;AAClD,QAAM,QAAQ,CAAC,GAAG,IAAI,SAAS,MAAM,CAAC;AACtC,QAAM,aAAa,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,MAAM,MAAS;AACvE,MAAI,WAAW,SAAS;AAAG,WAAO;AAClC,SAAO;AACT;AACA,SAAS,eAAe,QAAgB,KAAa;AACnD,QAAM,QAAQ,CAAC,GAAG,IAAI,SAAS,MAAM,CAAC;AACtC,QAAM,cAAc,MAAM,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,MAAM,MAAS;AACxE,MAAI,YAAY,SAAS;AAAG,WAAO;AACnC,SAAO;AACT;AACO,MAAM,yBAAyB,CAAC,QACrC,eAAe,oBAAoB,eAAe,GAAG,CAAC;AAEjD,MAAM,uBAAuB,CAAC,QACnC,cAAc,oBAAoB,eAAe,GAAG,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/onClickHandlerForNonInteractiveElements.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\n\nexport const onClickHandlerForNonInteractiveElements = (\n onClickHandler: React.MouseEventHandler & React.KeyboardEventHandler,\n) => ({\n role: 'button',\n tabIndex: '0',\n onClick: onClickHandler,\n onKeyPress: (event: React.KeyboardEvent) => {\n event.stopPropagation();\n const { keyCode, key } = event;\n if (key === 'Enter') onClickHandler(event);\n else if (keyCode === 13) onClickHandler(event);\n },\n});\n\nexport default onClickHandlerForNonInteractiveElements;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEhB,MAAM,0CAA0C,CACrD,oBACI;AAAA,EACJ,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY,CAAC,UAA+B;AAC1C,UAAM,gBAAgB;AACtB,UAAM,EAAE,SAAS,IAAI,IAAI;AACzB,QAAI,QAAQ;AAAS,qBAAe,KAAK;AAAA,aAChC,YAAY;AAAI,qBAAe,KAAK;AAAA,EAC/C;AACF;AAEA,IAAO,kDAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/operators.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { isEmpty } from 'lodash';\n\n// Check if the value is empty\nexport const checkNotEmpty = (value: unknown) =>\n // eslint-disable-next-line eqeqeq\n value === '' || value === undefined || value == [] || value === null || isEmpty(value);\n\n// Check if the value is not empty\nexport const checkEmpty = (value: unknown) => !isEmpty(value);\n\nexport const greaterThan = (value: number, comparator: number) => value > comparator;\n\n// Check if a valid date with format MM/DD/YYYY\nexport const validDate = (value: string) => {\n const dateValidationRegex = /^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$/;\n if (!dateValidationRegex.test(value)) return false;\n const [m, d, y] = value.split('/').map((n) => Number(n));\n return m === Number(new Date(y, m - 1, d).getMonth()) + 1 && d === Number(new Date(y, m - 1, d).getDate());\n};\n\nexport const equal = (a: unknown, b: unknown) => a === b;\n\nexport const notEqual = (a: unknown, b: unknown) => !equal(a, b);\n\nexport const isNull = (a: unknown) => checkNotEmpty(a);\n\nexport const isNotNull = (a: unknown) => !isNull(a);\n\nexport const isIn = <T,>(a: T, b: T[]) => b.indexOf(a) > -1;\n\nexport const isNotIn = <T,>(a: T, b: T[]) => !isIn(a, b);\n\nexport const greaterThanOrEquals = (value: number, comparator: number) => value >= comparator;\nexport const lessThanOrEquals = (value: number, comparator: number) => value <= comparator;\nexport const startsWith = (value: unknown, comparator: string) => String(value).startsWith(comparator);\nexport const contains = (value: unknown, comparator: string) => String(value).includes(comparator);\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe;AAGjB,MAAM,gBAAgB,CAAC,UAE5B,UAAU,MAAM,UAAU,UAAa,SAAS,CAAC,KAAK,UAAU,QAAQ,QAAQ,KAAK;AAGhF,MAAM,aAAa,CAAC,UAAmB,CAAC,QAAQ,KAAK;AAErD,MAAM,cAAc,CAAC,OAAe,eAAuB,QAAQ;AAGnE,MAAM,YAAY,CAAC,UAAkB;AAC1C,QAAM,sBAAsB;AAC5B,MAAI,CAAC,oBAAoB,KAAK,KAAK;AAAG,WAAO;AAC7C,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI,MAAM,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,OAAO,CAAC,CAAC;AACvD,SAAO,MAAM,OAAO,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,SAAS,CAAC,IAAI,KAAK,MAAM,OAAO,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,QAAQ,CAAC;AAC3G;AAEO,MAAM,QAAQ,CAAC,GAAY,MAAe,MAAM;AAEhD,MAAM,WAAW,CAAC,GAAY,MAAe,CAAC,MAAM,GAAG,CAAC;AAExD,MAAM,SAAS,CAAC,MAAe,cAAc,CAAC;AAE9C,MAAM,YAAY,CAAC,MAAe,CAAC,OAAO,CAAC;AAE3C,MAAM,OAAO,CAAK,GAAM,MAAW,EAAE,QAAQ,CAAC,IAAI;AAElD,MAAM,UAAU,CAAK,GAAM,MAAW,CAAC,KAAK,GAAG,CAAC;AAEhD,MAAM,sBAAsB,CAAC,OAAe,eAAuB,SAAS;AAC5E,MAAM,mBAAmB,CAAC,OAAe,eAAuB,SAAS;AACzE,MAAM,aAAa,CAAC,OAAgB,eAAuB,OAAO,KAAK,EAAE,WAAW,UAAU;AAC9F,MAAM,WAAW,CAAC,OAAgB,eAAuB,OAAO,KAAK,EAAE,SAAS,UAAU;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/platform.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/platform.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DOCUMENT = typeof document !== 'undefined' ? document : null;\nexport const WINDOW = typeof window !== 'undefined' ? window : null;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAhB,MAAM,WAAW,OAAO,aAAa,cAAc,WAAW;AAC9D,MAAM,SAAS,OAAO,WAAW,cAAc,SAAS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/defaultProps/index.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './useMemoMergePropsWithDefault';\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/defaultProps/useMemoMergePropsWithDefault.ts"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef } from 'react';\nimport deepequal from 'fast-deep-equal/react';\n\n// Hook\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst useMemoCompare = <T = any>(next: T, compare: (prevToCompare: T, nextToCompare: T) => boolean): T => {\n // Ref for storing previous value\n const previousRef = useRef(next);\n const previous = previousRef.current;\n // Pass previous and next value to compare function\n // to determine whether to consider them equal.\n const isEqual = compare(previous, next);\n // If not equal update previousRef to next value.\n // We only update if not equal so that this hook continues to return\n // the same old value if compare keeps returning true.\n if (!isEqual) previousRef.current = next;\n // Finally, if equal then return the previous value\n return isEqual ? previous : next;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useMemoMergePropsWithDefault = <T = Record<string, any>>(\n props: Partial<T>,\n defaultProps: Partial<T>,\n compare = deepequal,\n): T => {\n const mergedProps = { ...defaultProps, ...props } as T;\n\n return useMemoCompare<T>(mergedProps, compare);\n};\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,cAAc;AACvB,OAAO,eAAe;AAItB,MAAM,iBAAiB,CAAU,MAAS,YAAgE;AAExG,QAAM,cAAc,OAAO,IAAI;AAC/B,QAAM,WAAW,YAAY;AAG7B,QAAM,UAAU,QAAQ,UAAU,IAAI;AAItC,MAAI,CAAC;AAAS,gBAAY,UAAU;AAEpC,SAAO,UAAU,WAAW;AAC9B;AAGO,MAAM,+BAA+B,CAC1C,OACA,cACA,UAAU,cACJ;AACN,QAAM,cAAc,EAAE,GAAG,cAAc,GAAG,MAAM;AAEhD,SAAO,eAAkB,aAAa,OAAO;AAC/C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|