@elliemae/ds-utilities 3.0.0-next.36 → 3.0.0-next.39
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/compose.js.map +2 -2
- package/dist/cjs/deprecated/deprecatedMsg.js +35 -0
- package/dist/cjs/deprecated/deprecatedMsg.js.map +7 -0
- package/dist/cjs/deprecated/index.js +33 -0
- package/dist/cjs/deprecated/index.js.map +7 -0
- package/dist/cjs/deprecated/reactTypesUtility.js +60 -0
- package/dist/cjs/deprecated/reactTypesUtility.js.map +7 -0
- package/dist/cjs/{scrollingTimer.js → deprecated/scrollingTimer.js} +5 -3
- package/dist/cjs/deprecated/scrollingTimer.js.map +7 -0
- package/dist/cjs/{hooks → deprecated}/useParentElement.js +0 -0
- package/dist/cjs/deprecated/useParentElement.js.map +7 -0
- package/dist/cjs/{hooks → deprecated}/useSetRef.js +2 -0
- package/dist/cjs/deprecated/useSetRef.js.map +7 -0
- package/dist/cjs/deprecated/useUncontrolled.js +40 -0
- package/dist/cjs/deprecated/useUncontrolled.js.map +7 -0
- package/dist/cjs/{hooks → deprecated}/useWindowSize.js +6 -2
- package/dist/cjs/deprecated/useWindowSize.js.map +7 -0
- package/dist/cjs/getComponentFromProps.js +1 -1
- package/dist/cjs/getComponentFromProps.js.map +2 -2
- package/dist/cjs/hooks/index.js +1 -9
- package/dist/cjs/hooks/index.js.map +2 -2
- package/dist/cjs/hooks/useCallbackAfterRender.js.map +2 -2
- package/dist/cjs/hooks/useCancellableDelayedCallback.js.map +2 -2
- package/dist/cjs/hooks/useDerivedStateFromProps.js.map +2 -2
- package/dist/cjs/hooks/useExecutionTimer.js +4 -2
- package/dist/cjs/hooks/useExecutionTimer.js.map +2 -2
- package/dist/cjs/hooks/useExpandState.js.map +2 -2
- package/dist/cjs/hooks/useFocusTrap.js.map +2 -2
- package/dist/cjs/hooks/useHotkeys.js +1 -1
- package/dist/cjs/hooks/useHotkeys.js.map +2 -2
- package/dist/cjs/hooks/useHoverHandlersDelay.js +6 -4
- package/dist/cjs/hooks/useHoverHandlersDelay.js.map +2 -2
- package/dist/cjs/hooks/usePrevious.js.map +2 -2
- package/dist/cjs/hooks/useResizeObserver.js +3 -3
- package/dist/cjs/hooks/useResizeObserver.js.map +2 -2
- package/dist/cjs/hooks/useShouldRecalculate.js.map +2 -2
- package/dist/cjs/hooks/useWindowScrollerList.js +11 -9
- package/dist/cjs/hooks/useWindowScrollerList.js.map +2 -2
- package/dist/cjs/index.js +1 -11
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js +2 -2
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js.map +2 -2
- package/dist/cjs/operators.js.map +2 -2
- package/dist/cjs/props-helpers/validation/typescriptValidator.js +8 -7
- package/dist/cjs/props-helpers/validation/typescriptValidator.js.map +2 -2
- package/dist/cjs/reactTypesUtility.js +3 -24
- package/dist/cjs/reactTypesUtility.js.map +2 -2
- package/dist/cjs/system.js +5 -10
- package/dist/cjs/system.js.map +2 -2
- package/dist/cjs/timeUtils.js.map +2 -2
- package/dist/cjs/utils.js +6 -3
- package/dist/cjs/utils.js.map +2 -2
- package/dist/cjs/validations.js +4 -6
- package/dist/cjs/validations.js.map +2 -2
- package/dist/esm/compose.js.map +2 -2
- package/dist/esm/deprecated/deprecatedMsg.js +6 -0
- package/dist/esm/deprecated/deprecatedMsg.js.map +7 -0
- package/dist/esm/deprecated/index.js +8 -0
- package/dist/esm/deprecated/index.js.map +7 -0
- package/dist/esm/deprecated/reactTypesUtility.js +31 -0
- package/dist/esm/deprecated/reactTypesUtility.js.map +7 -0
- package/dist/esm/{scrollingTimer.js → deprecated/scrollingTimer.js} +5 -3
- package/dist/esm/deprecated/scrollingTimer.js.map +7 -0
- package/dist/esm/{hooks → deprecated}/useParentElement.js +0 -0
- package/dist/esm/deprecated/useParentElement.js.map +7 -0
- package/dist/esm/{hooks → deprecated}/useSetRef.js +2 -0
- package/dist/esm/deprecated/useSetRef.js.map +7 -0
- package/dist/esm/deprecated/useUncontrolled.js +11 -0
- package/dist/esm/deprecated/useUncontrolled.js.map +7 -0
- package/dist/esm/{hooks → deprecated}/useWindowSize.js +6 -2
- package/dist/esm/deprecated/useWindowSize.js.map +7 -0
- package/dist/esm/getComponentFromProps.js +1 -1
- package/dist/esm/getComponentFromProps.js.map +2 -2
- package/dist/esm/hooks/index.js +1 -9
- package/dist/esm/hooks/index.js.map +2 -2
- package/dist/esm/hooks/useCallbackAfterRender.js.map +2 -2
- package/dist/esm/hooks/useCancellableDelayedCallback.js.map +2 -2
- package/dist/esm/hooks/useDerivedStateFromProps.js.map +2 -2
- package/dist/esm/hooks/useExecutionTimer.js +4 -2
- package/dist/esm/hooks/useExecutionTimer.js.map +2 -2
- package/dist/esm/hooks/useExpandState.js.map +2 -2
- package/dist/esm/hooks/useFocusTrap.js.map +1 -1
- package/dist/esm/hooks/useHotkeys.js +1 -1
- package/dist/esm/hooks/useHotkeys.js.map +2 -2
- package/dist/esm/hooks/useHoverHandlersDelay.js +6 -4
- package/dist/esm/hooks/useHoverHandlersDelay.js.map +2 -2
- package/dist/esm/hooks/usePrevious.js.map +2 -2
- package/dist/esm/hooks/useResizeObserver.js +4 -4
- package/dist/esm/hooks/useResizeObserver.js.map +2 -2
- package/dist/esm/hooks/useShouldRecalculate.js.map +2 -2
- package/dist/esm/hooks/useWindowScrollerList.js +12 -10
- package/dist/esm/hooks/useWindowScrollerList.js.map +2 -2
- package/dist/esm/index.js +2 -23
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/onClickHandlerForNonInteractiveElements.js +2 -2
- package/dist/esm/onClickHandlerForNonInteractiveElements.js.map +2 -2
- package/dist/esm/operators.js.map +2 -2
- package/dist/esm/props-helpers/validation/typescriptValidator.js +9 -8
- package/dist/esm/props-helpers/validation/typescriptValidator.js.map +2 -2
- package/dist/esm/reactTypesUtility.js +3 -24
- package/dist/esm/reactTypesUtility.js.map +2 -2
- package/dist/esm/system.js +5 -10
- package/dist/esm/system.js.map +2 -2
- package/dist/esm/timeUtils.js.map +2 -2
- package/dist/esm/utils.js +6 -3
- package/dist/esm/utils.js.map +2 -2
- package/dist/esm/validations.js +4 -6
- package/dist/esm/validations.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/hooks/useParentElement.js.map +0 -7
- package/dist/cjs/hooks/useSetRef.js.map +0 -7
- package/dist/cjs/hooks/useWindowSize.js.map +0 -7
- package/dist/cjs/scrollingTimer.js.map +0 -7
- package/dist/esm/hooks/useParentElement.js.map +0 -7
- package/dist/esm/hooks/useSetRef.js.map +0 -7
- package/dist/esm/hooks/useWindowSize.js.map +0 -7
- package/dist/esm/scrollingTimer.js.map +0 -7
package/dist/cjs/validations.js
CHANGED
|
@@ -38,18 +38,16 @@ const isRequired = ({ value, help = "Field is Required" }) => ({
|
|
|
38
38
|
error: (0, import_operators.checkNotEmpty)(value)
|
|
39
39
|
});
|
|
40
40
|
const isGreaterThan = ({ value, help, comparator = 0 }) => {
|
|
41
|
-
|
|
42
|
-
help = `Max value ${comparator}`;
|
|
41
|
+
const helpMessage = help ?? `Max value ${comparator}`;
|
|
43
42
|
return {
|
|
44
|
-
payload:
|
|
43
|
+
payload: helpMessage,
|
|
45
44
|
error: (0, import_operators.greaterThan)(value, comparator)
|
|
46
45
|
};
|
|
47
46
|
};
|
|
48
47
|
const isValidDate = ({ value, help, format = "MM/DD/AAA" }) => {
|
|
49
|
-
|
|
50
|
-
help = `Valid Date is required ${format}`;
|
|
48
|
+
const helpMessage = help ?? `Valid Date is required ${format}`;
|
|
51
49
|
return {
|
|
52
|
-
payload:
|
|
50
|
+
payload: helpMessage,
|
|
53
51
|
error: !(0, import_operators.validDate)(value)
|
|
54
52
|
};
|
|
55
53
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/validations.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { checkNotEmpty, greaterThan, validDate } from './operators';\n\nexport const isRequired = ({ value, help = 'Field is Required' }) => ({\n payload: help,\n error: checkNotEmpty(value),\n});\n\nexport const isGreaterThan = ({ value, help, comparator = 0 }) => {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAsD;
|
|
4
|
+
"sourcesContent": ["import { checkNotEmpty, greaterThan, validDate } from './operators';\n\ninterface IsRequiredArg {\n value: unknown;\n help?: string;\n}\n\ninterface IsGreaterThanArg {\n value: number;\n help?: string;\n comparator?: number;\n}\n\ninterface IsValidDateArg {\n value: string;\n help?: string;\n format?: string;\n}\n\nexport const isRequired = ({ value, help = 'Field is Required' }: IsRequiredArg) => ({\n payload: help,\n error: checkNotEmpty(value),\n});\n\nexport const isGreaterThan = ({ value, help, comparator = 0 }: IsGreaterThanArg) => {\n const helpMessage = help ?? `Max value ${comparator}`;\n return {\n payload: helpMessage,\n error: greaterThan(value, comparator),\n };\n};\n\nexport const isValidDate = ({ value, help, format = 'MM/DD/AAA' }: IsValidDateArg) => {\n const helpMessage = help ?? `Valid Date is required ${format}`;\n return {\n payload: helpMessage,\n error: !validDate(value),\n };\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAsD;AAmB/C,MAAM,aAAa,CAAC,EAAE,OAAO,OAAO,0BAA0C;AAAA,EACnF,SAAS;AAAA,EACT,OAAO,oCAAc,KAAK;AAC5B;AAEO,MAAM,gBAAgB,CAAC,EAAE,OAAO,MAAM,aAAa,QAA0B;AAClF,QAAM,cAAc,QAAQ,aAAa;AACzC,SAAO;AAAA,IACL,SAAS;AAAA,IACT,OAAO,kCAAY,OAAO,UAAU;AAAA,EACtC;AACF;AAEO,MAAM,cAAc,CAAC,EAAE,OAAO,MAAM,SAAS,kBAAkC;AACpF,QAAM,cAAc,QAAQ,0BAA0B;AACtD,SAAO;AAAA,IACL,SAAS;AAAA,IACT,OAAO,CAAC,gCAAU,KAAK;AAAA,EACzB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/compose.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/compose.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/**\n * Composes single-argument functions from right to left. The rightmost\n * function can take multiple arguments as it provides the signature for\n * the resulting composite function. [From redux v4.0.5]\n *\n * @param {...Function} funcs The functions to compose.\n * @returns {Function} A function obtained by composing the argument functions\n * from right to left. For example, compose(f, g, h) is identical to doing\n * (...args) => f(g(h(...args))).\n */\n\nexport const compose = (...funcs) => {\n if (funcs.length === 0) {\n return (arg) => arg;\n }\n\n if (funcs.length === 1) {\n return funcs[0];\n }\n\n return funcs.reduce((a, b)
|
|
5
|
-
"mappings": "AAAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/**\n * Composes single-argument functions from right to left. The rightmost\n * function can take multiple arguments as it provides the signature for\n * the resulting composite function. [From redux v4.0.5]\n *\n * @param {...Function} funcs The functions to compose.\n * @returns {Function} A function obtained by composing the argument functions\n * from right to left. For example, compose(f, g, h) is identical to doing\n * (...args) => f(g(h(...args))).\n */\n\ntype UnknownFunctionT = (...args: unknown[]) => unknown;\n\nexport const compose = (...funcs: UnknownFunctionT[]): UnknownFunctionT => {\n if (funcs.length === 0) {\n return (arg) => arg;\n }\n\n if (funcs.length === 1) {\n return funcs[0];\n }\n\n return funcs.reduce(\n (a, b) =>\n (...args) =>\n a(b(...args)),\n );\n};\n\nexport default compose;\n"],
|
|
5
|
+
"mappings": "AAAA;ACaO,MAAM,UAAU,IAAI,UAAgD;AACzE,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO,CAAC,QAAQ;AAAA,EAClB;AAEA,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO,MAAM;AAAA,EACf;AAEA,SAAO,MAAM,OACX,CAAC,GAAG,MACF,IAAI,SACF,EAAE,EAAE,GAAG,IAAI,CAAC,CAClB;AACF;AAEA,IAAO,kBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/deprecatedMsg.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const deprecatedMsg = 'is going to be deprecated, please consider removing it from your project';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,gBAAgB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export * from "./reactTypesUtility";
|
|
3
|
+
export * from "./scrollingTimer";
|
|
4
|
+
export * from "./useParentElement";
|
|
5
|
+
export * from "./useSetRef";
|
|
6
|
+
export * from "./useUncontrolled";
|
|
7
|
+
export * from "./useWindowSize";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './reactTypesUtility';\nexport * from './scrollingTimer';\nexport * from './useParentElement';\nexport * from './useSetRef';\nexport * from './useUncontrolled';\nexport * from './useWindowSize';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { deprecatedMsg } from "./deprecatedMsg";
|
|
4
|
+
function isClassComponent(component) {
|
|
5
|
+
console.warn(`isClassComponent ${deprecatedMsg}`);
|
|
6
|
+
return !!(typeof component === "function" && !!component.prototype.isReactComponent);
|
|
7
|
+
}
|
|
8
|
+
function isFunctionComponent(component) {
|
|
9
|
+
console.warn(`isFunctionComponent ${deprecatedMsg}`);
|
|
10
|
+
return typeof component === "function" && String(component).includes("return React.createElement");
|
|
11
|
+
}
|
|
12
|
+
function isReactComponent(component) {
|
|
13
|
+
console.warn(`isReactComponent ${deprecatedMsg}`);
|
|
14
|
+
return !!(isClassComponent(component) || isFunctionComponent(component));
|
|
15
|
+
}
|
|
16
|
+
function isElement(element) {
|
|
17
|
+
console.warn(`isElement ${deprecatedMsg}`);
|
|
18
|
+
return React2.isValidElement(element);
|
|
19
|
+
}
|
|
20
|
+
function isCompositeTypeElement(element) {
|
|
21
|
+
console.warn(`isCompositeTypeElement ${deprecatedMsg}`);
|
|
22
|
+
return isElement(element) && typeof element?.type === "function";
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
isClassComponent,
|
|
26
|
+
isCompositeTypeElement,
|
|
27
|
+
isElement,
|
|
28
|
+
isFunctionComponent,
|
|
29
|
+
isReactComponent
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=reactTypesUtility.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/reactTypesUtility.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\nimport React from 'react';\nimport { deprecatedMsg } from './deprecatedMsg';\n\nexport function isClassComponent(component: any) {\n console.warn(`isClassComponent ${deprecatedMsg}`);\n return !!(typeof component === 'function' && !!component.prototype.isReactComponent);\n}\n\nexport function isFunctionComponent(component: any) {\n console.warn(`isFunctionComponent ${deprecatedMsg}`);\n return typeof component === 'function' && String(component).includes('return React.createElement');\n}\n\nexport function isReactComponent(component: any) {\n console.warn(`isReactComponent ${deprecatedMsg}`);\n return !!(isClassComponent(component) || isFunctionComponent(component));\n}\n\nexport function isElement(element: Record<string, unknown> | null | undefined) {\n console.warn(`isElement ${deprecatedMsg}`);\n return React.isValidElement(element);\n}\n\nexport function isCompositeTypeElement(element: Record<string, unknown> | null | undefined) {\n console.warn(`isCompositeTypeElement ${deprecatedMsg}`);\n return isElement(element) && typeof element?.type === 'function';\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACGA;AACA;AAEO,0BAA0B,WAAgB;AAC/C,UAAQ,KAAK,oBAAoB,eAAe;AAChD,SAAO,CAAC,CAAE,QAAO,cAAc,cAAc,CAAC,CAAC,UAAU,UAAU;AACrE;AAEO,6BAA6B,WAAgB;AAClD,UAAQ,KAAK,uBAAuB,eAAe;AACnD,SAAO,OAAO,cAAc,cAAc,OAAO,SAAS,EAAE,SAAS,4BAA4B;AACnG;AAEO,0BAA0B,WAAgB;AAC/C,UAAQ,KAAK,oBAAoB,eAAe;AAChD,SAAO,CAAC,CAAE,kBAAiB,SAAS,KAAK,oBAAoB,SAAS;AACxE;AAEO,mBAAmB,SAAqD;AAC7E,UAAQ,KAAK,aAAa,eAAe;AACzC,SAAO,OAAM,eAAe,OAAO;AACrC;AAEO,gCAAgC,SAAqD;AAC1F,UAAQ,KAAK,0BAA0B,eAAe;AACtD,SAAO,UAAU,OAAO,KAAK,OAAO,SAAS,SAAS;AACxD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { deprecatedMsg } from "./deprecatedMsg";
|
|
2
3
|
const resetTimer = (func) => {
|
|
4
|
+
console.warn(`resetTimer ${deprecatedMsg}`);
|
|
3
5
|
let timeout;
|
|
4
6
|
return function(...args) {
|
|
5
|
-
const context = this;
|
|
6
7
|
const lastCall = () => {
|
|
7
8
|
timeout = null;
|
|
8
|
-
func.apply(
|
|
9
|
+
func.apply(this, args);
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
+
if (timeout)
|
|
12
|
+
clearTimeout(timeout);
|
|
11
13
|
timeout = setTimeout(lastCall, 300);
|
|
12
14
|
};
|
|
13
15
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/scrollingTimer.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable func-names */\nimport { deprecatedMsg } from './deprecatedMsg';\n\nexport const resetTimer = (func: (...args: unknown[]) => unknown) => {\n console.warn(`resetTimer ${deprecatedMsg}`);\n let timeout: NodeJS.Timeout | null;\n return function (this: any, ...args: unknown[]) {\n const lastCall = () => {\n timeout = null;\n func.apply(this, args);\n };\n\n if (timeout) clearTimeout(timeout);\n timeout = setTimeout(lastCall, 300);\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACGA;AAEO,MAAM,aAAa,CAAC,SAA0C;AACnE,UAAQ,KAAK,cAAc,eAAe;AAC1C,MAAI;AACJ,SAAO,YAAwB,MAAiB;AAC9C,UAAM,WAAW,MAAM;AACrB,gBAAU;AACV,WAAK,MAAM,MAAM,IAAI;AAAA,IACvB;AAEA,QAAI;AAAS,mBAAa,OAAO;AACjC,cAAU,WAAW,UAAU,GAAG;AAAA,EACpC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/useParentElement.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useEffect, useState } from 'react';\n\nexport const useParentElement = (ref: React.RefObject<HTMLElement>) => {\n const [parent, setParent] = useState<ParentNode | null>(ref.current);\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useEffect(() => {\n if (ref.current) setParent(ref.current.parentNode);\n });\n return parent;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEO,MAAM,mBAAmB,CAAC,QAAsC;AACrE,QAAM,CAAC,QAAQ,aAAa,SAA4B,IAAI,OAAO;AAGnE,YAAU,MAAM;AACd,QAAI,IAAI;AAAS,gBAAU,IAAI,QAAQ,UAAU;AAAA,EACnD,CAAC;AACD,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useCallback, useRef } from "react";
|
|
3
|
+
import { deprecatedMsg } from "./deprecatedMsg";
|
|
3
4
|
const useSetRef = (initial) => {
|
|
5
|
+
console.warn(`useSetRef ${deprecatedMsg}`);
|
|
4
6
|
const ref = useRef(initial);
|
|
5
7
|
const setRef = useCallback((node) => {
|
|
6
8
|
ref.current = node;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/useSetRef.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-console */\nimport { useCallback, useRef } from 'react';\nimport { deprecatedMsg } from './deprecatedMsg';\n\nexport const useSetRef = (initial: unknown) => {\n console.warn(`useSetRef ${deprecatedMsg}`);\n const ref = useRef(initial);\n const setRef = useCallback((node) => {\n ref.current = node;\n }, []);\n return [ref, setRef];\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AACA;AAEO,MAAM,YAAY,CAAC,YAAqB;AAC7C,UAAQ,KAAK,aAAa,eAAe;AACzC,QAAM,MAAM,OAAO,OAAO;AAC1B,QAAM,SAAS,YAAY,CAAC,SAAS;AACnC,QAAI,UAAU;AAAA,EAChB,GAAG,CAAC,CAAC;AACL,SAAO,CAAC,KAAK,MAAM;AACrB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useUncontrolled as useUncontrolledImplementation } from "uncontrollable";
|
|
3
|
+
import { deprecatedMsg } from "./deprecatedMsg";
|
|
4
|
+
const useUncontrolled = (...args) => {
|
|
5
|
+
console.warn(`useUncontrolled ${deprecatedMsg}`);
|
|
6
|
+
return useUncontrolledImplementation(...args);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
useUncontrolled
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useUncontrolled.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/useUncontrolled.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-console */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-return */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useUncontrolled as useUncontrolledImplementation } from 'uncontrollable';\nimport { deprecatedMsg } from './deprecatedMsg';\n\nexport const useUncontrolled = (...args: any[]) => {\n console.warn(`useUncontrolled ${deprecatedMsg}`);\n return useUncontrolledImplementation(...args);\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACKA;AACA;AAEO,MAAM,kBAAkB,IAAI,SAAgB;AACjD,UAAQ,KAAK,mBAAmB,eAAe;AAC/C,SAAO,8BAA8B,GAAG,IAAI;AAC9C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useLayoutEffect, useState } from "react";
|
|
3
|
+
import { deprecatedMsg } from "./deprecatedMsg";
|
|
4
|
+
const noop = () => {
|
|
5
|
+
};
|
|
3
6
|
const useWindowSize = () => {
|
|
7
|
+
console.warn(`useWindowSize ${deprecatedMsg}`);
|
|
4
8
|
const [size, setSize] = useState([0, 0]);
|
|
5
9
|
useLayoutEffect(() => {
|
|
6
10
|
if (!window)
|
|
7
|
-
return
|
|
11
|
+
return noop;
|
|
8
12
|
function updateSize() {
|
|
9
13
|
setSize([window.innerWidth, window.innerHeight]);
|
|
10
14
|
}
|
|
@@ -17,7 +21,7 @@ const useWindowSize = () => {
|
|
|
17
21
|
};
|
|
18
22
|
}, []);
|
|
19
23
|
if (!window)
|
|
20
|
-
return
|
|
24
|
+
return noop;
|
|
21
25
|
return size;
|
|
22
26
|
};
|
|
23
27
|
var useWindowSize_default = useWindowSize;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/deprecated/useWindowSize.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-console */\nimport { useLayoutEffect, useState } from 'react';\nimport { deprecatedMsg } from './deprecatedMsg';\n\nconst noop = () => {};\n\nexport const useWindowSize = () => {\n console.warn(`useWindowSize ${deprecatedMsg}`);\n const [size, setSize] = useState([0, 0]);\n useLayoutEffect(() => {\n if (!window) return noop;\n function updateSize() {\n setSize([window.innerWidth, window.innerHeight]);\n }\n window.addEventListener('resize', updateSize);\n window.addEventListener('orientationchange', updateSize);\n updateSize();\n return () => {\n window.removeEventListener('resize', updateSize);\n window.removeEventListener('orientationchange', updateSize);\n };\n }, []);\n if (!window) return noop;\n return size;\n};\n\nexport default useWindowSize;\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AACA;AAEA,MAAM,OAAO,MAAM;AAAC;AAEb,MAAM,gBAAgB,MAAM;AACjC,UAAQ,KAAK,iBAAiB,eAAe;AAC7C,QAAM,CAAC,MAAM,WAAW,SAAS,CAAC,GAAG,CAAC,CAAC;AACvC,kBAAgB,MAAM;AACpB,QAAI,CAAC;AAAQ,aAAO;AACpB,0BAAsB;AACpB,cAAQ,CAAC,OAAO,YAAY,OAAO,WAAW,CAAC;AAAA,IACjD;AACA,WAAO,iBAAiB,UAAU,UAAU;AAC5C,WAAO,iBAAiB,qBAAqB,UAAU;AACvD,eAAW;AACX,WAAO,MAAM;AACX,aAAO,oBAAoB,UAAU,UAAU;AAC/C,aAAO,oBAAoB,qBAAqB,UAAU;AAAA,IAC5D;AAAA,EACF,GAAG,CAAC,CAAC;AACL,MAAI,CAAC;AAAQ,WAAO;AACpB,SAAO;AACT;AAEA,IAAO,wBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -19,7 +19,7 @@ import React2 from "react";
|
|
|
19
19
|
const getComponentFromProps = (Component, props, children = []) => {
|
|
20
20
|
if (!Component)
|
|
21
21
|
return null;
|
|
22
|
-
const componentChildren = Component.props ? Array.isArray(Component.props.children) ? Component.props.children : [Component.props.children] : null;
|
|
22
|
+
const componentChildren = typeof Component !== "function" && Component.props ? Array.isArray(Component.props.children) ? Component.props.children : [Component.props.children] : null;
|
|
23
23
|
return typeof Component === "function" ? /* @__PURE__ */ React2.createElement(Component, __spreadValues({}, props), children) : React2.cloneElement(Component, __spreadValues(__spreadValues({}, Component.props), props), componentChildren ? [...componentChildren, ...children] : [...children]);
|
|
24
24
|
};
|
|
25
25
|
var getComponentFromProps_default = getComponentFromProps;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/getComponentFromProps.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-nested-ternary */\nimport React from 'react';\n\nexport const getComponentFromProps = (Component
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACCA;AAEO,MAAM,wBAAwB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-nested-ternary */\nimport React, { PropsWithChildren } from 'react';\n\nexport const getComponentFromProps = (\n Component: React.ReactElement<PropsWithChildren<unknown>> | React.ComponentType<unknown>,\n props: Record<string, unknown>,\n children = [],\n) => {\n if (!Component) return null;\n const componentChildren =\n typeof Component !== 'function' && Component.props\n ? Array.isArray(Component.props.children)\n ? Component.props.children\n : [Component.props.children]\n : null;\n return typeof Component === 'function' ? (\n <Component {...props}>{children}</Component>\n ) : (\n React.cloneElement(\n Component,\n {\n ...Component.props,\n ...props,\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n componentChildren ? [...componentChildren, ...children] : [...children],\n )\n );\n};\n\nexport default getComponentFromProps;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACCA;AAEO,MAAM,wBAAwB,CACnC,WACA,OACA,WAAW,CAAC,MACT;AACH,MAAI,CAAC;AAAW,WAAO;AACvB,QAAM,oBACJ,OAAO,cAAc,cAAc,UAAU,QACzC,MAAM,QAAQ,UAAU,MAAM,QAAQ,IACpC,UAAU,MAAM,WAChB,CAAC,UAAU,MAAM,QAAQ,IAC3B;AACN,SAAO,OAAO,cAAc,aAC1B,qCAAC,8BAAc,QAAQ,QAAS,IAEhC,OAAM,aACJ,WACA,kCACK,UAAU,QACV,QAGL,oBAAoB,CAAC,GAAG,mBAAmB,GAAG,QAAQ,IAAI,CAAC,GAAG,QAAQ,CACxE;AAEJ;AAEA,IAAO,gCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import * as React from "react";
|
|
|
2
2
|
import { default as default2 } from "use-measure";
|
|
3
3
|
import { default as default3 } from "use-force-update";
|
|
4
4
|
import { default as default4 } from "use-onclickoutside";
|
|
5
|
-
import { useUncontrolled } from "uncontrollable";
|
|
6
5
|
import { useExecutionTimer } from "./useExecutionTimer";
|
|
7
6
|
import { useExpandState } from "./useExpandState";
|
|
8
7
|
import { useHotkeys } from "./useHotkeys";
|
|
@@ -10,12 +9,9 @@ import { useHoverHandlersDelay } from "./useHoverHandlersDelay";
|
|
|
10
9
|
import { useResizeObserver } from "./useResizeObserver";
|
|
11
10
|
import { useShouldRecalculate } from "./useShouldRecalculate";
|
|
12
11
|
import { useWindowScrollerList } from "./useWindowScrollerList";
|
|
13
|
-
import { useWindowSize } from "./useWindowSize";
|
|
14
12
|
import { usePrevious } from "./usePrevious";
|
|
15
13
|
import { useCancellableDelayedCallback } from "./useCancellableDelayedCallback";
|
|
16
14
|
import { useDerivedStateFromProps } from "./useDerivedStateFromProps";
|
|
17
|
-
import { useSetRef } from "./useSetRef";
|
|
18
|
-
import { useParentElement } from "./useParentElement";
|
|
19
15
|
import { useOnElementResize } from "./useOnElementResize";
|
|
20
16
|
import { useIsShowingEllipsis } from "./useIsShowingEllipsis";
|
|
21
17
|
import { useCallbackAfterRender } from "./useCallbackAfterRender";
|
|
@@ -37,13 +33,9 @@ export {
|
|
|
37
33
|
default2 as useMeasure,
|
|
38
34
|
default4 as useOnClickOutside,
|
|
39
35
|
useOnElementResize,
|
|
40
|
-
useParentElement,
|
|
41
36
|
usePrevious,
|
|
42
37
|
useResizeObserver,
|
|
43
|
-
useSetRef,
|
|
44
38
|
useShouldRecalculate,
|
|
45
|
-
|
|
46
|
-
useWindowScrollerList,
|
|
47
|
-
useWindowSize
|
|
39
|
+
useWindowScrollerList
|
|
48
40
|
};
|
|
49
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as useMeasure } from 'use-measure';\nexport { default as useForceUpdate } from 'use-force-update';\nexport { default as useOnClickOutside } from 'use-onclickoutside';\nexport {
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as useMeasure } from 'use-measure';\nexport { default as useForceUpdate } from 'use-force-update';\nexport { default as useOnClickOutside } from 'use-onclickoutside';\nexport { useExecutionTimer } from './useExecutionTimer';\nexport { useExpandState } from './useExpandState';\nexport { useHotkeys } from './useHotkeys';\nexport { useHoverHandlersDelay } from './useHoverHandlersDelay';\nexport { useResizeObserver } from './useResizeObserver';\nexport { useShouldRecalculate } from './useShouldRecalculate';\nexport { useWindowScrollerList } from './useWindowScrollerList';\nexport { usePrevious } from './usePrevious';\nexport { useCancellableDelayedCallback } from './useCancellableDelayedCallback';\nexport { useDerivedStateFromProps } from './useDerivedStateFromProps';\nexport { useOnElementResize } from './useOnElementResize';\nexport { useIsShowingEllipsis } from './useIsShowingEllipsis';\nexport { useCallbackAfterRender } from './useCallbackAfterRender';\nexport { useFocusTrap, UseFocusTrapWithSchema } from './useFocusTrap';\nexport { useIsMobile } from './useIsMobile';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useCallbackAfterRender.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef, useLayoutEffect } from 'react';\n\n// Inspired in https://github.com/ryuuji3/react-hooks/blob/4b183d61c30abf17efeab2240f8ff652a5dbb8e2/packages/use-callback-after-render/src/hooks/useCallbackAfterRender.ts\nexport const useCallbackAfterRender = (): Callback => {\n const lastRun = useRef<(() => void) | null>(null);\n\n useLayoutEffect(() => {\n lastRun.current?.();\n lastRun.current = null;\n });\n\n return (callback) => {\n lastRun.current = callback; // schedule callback after render\n };\n};\n
|
|
5
|
-
"mappings": "AAAA;ACAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef, useLayoutEffect } from 'react';\n\ntype Callback = (callback: () => void) => void;\n\n// Inspired in https://github.com/ryuuji3/react-hooks/blob/4b183d61c30abf17efeab2240f8ff652a5dbb8e2/packages/use-callback-after-render/src/hooks/useCallbackAfterRender.ts\nexport const useCallbackAfterRender = (): Callback => {\n const lastRun = useRef<(() => void) | null>(null);\n\n useLayoutEffect(() => {\n lastRun.current?.();\n lastRun.current = null;\n });\n\n return (callback) => {\n lastRun.current = callback; // schedule callback after render\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAKO,MAAM,yBAAyB,MAAgB;AACpD,QAAM,UAAU,OAA4B,IAAI;AAEhD,kBAAgB,MAAM;AACpB,YAAQ,UAAU;AAClB,YAAQ,UAAU;AAAA,EACpB,CAAC;AAED,SAAO,CAAC,aAAa;AACnB,YAAQ,UAAU;AAAA,EACpB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useCancellableDelayedCallback.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useRef } from 'react';\n\nexport const useCancellableDelayedCallback = (cb, delay) => {\n const timeoutRef = useRef();\n const cancel = useCallback(() => {\n const timeoutId = timeoutRef.current;\n if (timeoutId) {\n timeoutRef.current = undefined;\n clearTimeout(timeoutId);\n }\n }, [timeoutRef]);\n const delayedCb = useCallback(\n (...args) => {\n timeoutRef.current = setTimeout(() => cb(...args), delay);\n },\n [cb, delay],\n );\n\n return [delayedCb, cancel];\n};\n\nexport default useCancellableDelayedCallback;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useRef } from 'react';\n\ntype Callback = (...args: unknown[]) => unknown;\n\nexport const useCancellableDelayedCallback = (cb: Callback, delay: number) => {\n const timeoutRef = useRef<NodeJS.Timeout>();\n const cancel = useCallback(() => {\n const timeoutId = timeoutRef.current;\n if (timeoutId) {\n timeoutRef.current = undefined;\n clearTimeout(timeoutId);\n }\n }, [timeoutRef]);\n const delayedCb: Callback = useCallback(\n (...args) => {\n timeoutRef.current = setTimeout(() => cb(...args), delay);\n },\n [cb, delay],\n );\n\n return [delayedCb, cancel];\n};\n\nexport default useCancellableDelayedCallback;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAIO,MAAM,gCAAgC,CAAC,IAAc,UAAkB;AAC5E,QAAM,aAAa,OAAuB;AAC1C,QAAM,SAAS,YAAY,MAAM;AAC/B,UAAM,YAAY,WAAW;AAC7B,QAAI,WAAW;AACb,iBAAW,UAAU;AACrB,mBAAa,SAAS;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AACf,QAAM,YAAsB,YAC1B,IAAI,SAAS;AACX,eAAW,UAAU,WAAW,MAAM,GAAG,GAAG,IAAI,GAAG,KAAK;AAAA,EAC1D,GACA,CAAC,IAAI,KAAK,CACZ;AAEA,SAAO,CAAC,WAAW,MAAM;AAC3B;AAEA,IAAO,wCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useDerivedStateFromProps.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef, useState } from 'react';\nimport { isEqual, isFunction } from '../utils';\n\nconst defaultPropUpdateOnChange = prop => prop;\n\nfunction defaultShouldUpdate({ prop, prevProp, stateValue }) {\n return !isEqual(prop, prevProp) && !isEqual(prop, stateValue);\n}\n\nfunction setStateWithUpdate(onUpdate
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useRef, useState } from 'react';\nimport { isEqual, isFunction } from '../utils';\n\ninterface ShouldUpdateArg {\n prop: unknown;\n prevProp: unknown;\n stateValue: unknown;\n}\n\ntype OnUpdateT<T> = (prop: T, prevProp?: T | Record<string, never>) => T;\n\ninterface OptionsT<T> {\n onUpdate?: OnUpdateT<T>;\n shouldUpdate?: (arg: ShouldUpdateArg) => boolean;\n updateOnStateChange?: boolean;\n}\n\nconst defaultPropUpdateOnChange = <T,>(prop: T) => prop;\n\nfunction defaultShouldUpdate({ prop, prevProp, stateValue }: ShouldUpdateArg) {\n return !isEqual(prop, prevProp) && !isEqual(prop, stateValue);\n}\n\nfunction setStateWithUpdate<T>(onUpdate: OnUpdateT<T>, setState: React.Dispatch<React.SetStateAction<T>>) {\n return (state: React.SetStateAction<T>) => {\n setState((prevState: T) => onUpdate(isFunction(state) ? state(prevState) : state, prevState));\n };\n}\n\nexport const useDerivedStateFromProps = <T,>(\n prop: T,\n options: OptionsT<T> = {},\n): [T, React.Dispatch<React.SetStateAction<T>>] => {\n const {\n onUpdate = defaultPropUpdateOnChange as OnUpdateT<T>,\n shouldUpdate = defaultShouldUpdate,\n updateOnStateChange = false,\n } = options;\n\n const [stateValue, setState] = useState(onUpdate(prop, {}));\n const handleSetState = updateOnStateChange ? setStateWithUpdate(onUpdate, setState) : setState;\n const prevProp = useRef(prop);\n\n if (\n shouldUpdate({\n prop,\n prevProp: prevProp.current,\n stateValue,\n })\n ) {\n const nextProp = onUpdate(prop, prevProp.current);\n setState(nextProp);\n }\n prevProp.current = prop;\n return [stateValue, handleSetState];\n};\n\nexport default useDerivedStateFromProps;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAgBA,MAAM,4BAA4B,CAAK,SAAY;AAEnD,6BAA6B,EAAE,MAAM,UAAU,cAA+B;AAC5E,SAAO,CAAC,QAAQ,MAAM,QAAQ,KAAK,CAAC,QAAQ,MAAM,UAAU;AAC9D;AAEA,4BAA+B,UAAwB,UAAmD;AACxG,SAAO,CAAC,UAAmC;AACzC,aAAS,CAAC,cAAiB,SAAS,WAAW,KAAK,IAAI,MAAM,SAAS,IAAI,OAAO,SAAS,CAAC;AAAA,EAC9F;AACF;AAEO,MAAM,2BAA2B,CACtC,MACA,UAAuB,CAAC,MACyB;AACjD,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,eAAe;AAAA,IACf,sBAAsB;AAAA,MACpB;AAEJ,QAAM,CAAC,YAAY,YAAY,SAAS,SAAS,MAAM,CAAC,CAAC,CAAC;AAC1D,QAAM,iBAAiB,sBAAsB,mBAAmB,UAAU,QAAQ,IAAI;AACtF,QAAM,WAAW,OAAO,IAAI;AAE5B,MACE,aAAa;AAAA,IACX;AAAA,IACA,UAAU,SAAS;AAAA,IACnB;AAAA,EACF,CAAC,GACD;AACA,UAAM,WAAW,SAAS,MAAM,SAAS,OAAO;AAChD,aAAS,QAAQ;AAAA,EACnB;AACA,WAAS,UAAU;AACnB,SAAO,CAAC,YAAY,cAAc;AACpC;AAEA,IAAO,mCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,11 +4,13 @@ const useExecutionTimer = (startFn, cleanFn, delayTime) => {
|
|
|
4
4
|
const startTimer = useRef();
|
|
5
5
|
const closeTimer = useRef();
|
|
6
6
|
const startFunction = (...args) => {
|
|
7
|
-
|
|
7
|
+
if (closeTimer.current)
|
|
8
|
+
clearTimeout(closeTimer.current);
|
|
8
9
|
startTimer.current = setTimeout(() => startFn(...args), delayTime);
|
|
9
10
|
};
|
|
10
11
|
const cleanFunction = (...args) => {
|
|
11
|
-
|
|
12
|
+
if (startTimer.current)
|
|
13
|
+
clearTimeout(startTimer.current);
|
|
12
14
|
closeTimer.current = setTimeout(() => cleanFn(...args), 30);
|
|
13
15
|
};
|
|
14
16
|
return [startFunction, cleanFunction];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useExecutionTimer.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef } from 'react';\n\nexport const useExecutionTimer = (startFn, cleanFn, delayTime) => {\n const startTimer = useRef();\n const closeTimer = useRef();\n\n const startFunction = (...args) => {\n clearTimeout(closeTimer.current);\n startTimer.current = setTimeout(() => startFn(...args), delayTime);\n };\n\n const cleanFunction = (...args) => {\n clearTimeout(startTimer.current);\n closeTimer.current = setTimeout(() => cleanFn(...args), 30);\n };\n return [startFunction, cleanFunction];\n};\n\nexport default useExecutionTimer;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef } from 'react';\n\ntype Callback = (...args: unknown[]) => unknown;\n\nexport const useExecutionTimer = (startFn: Callback, cleanFn: Callback, delayTime: number) => {\n const startTimer = useRef<NodeJS.Timeout>();\n const closeTimer = useRef<NodeJS.Timeout>();\n\n const startFunction: Callback = (...args) => {\n if (closeTimer.current) clearTimeout(closeTimer.current);\n startTimer.current = setTimeout(() => startFn(...args), delayTime);\n };\n\n const cleanFunction: Callback = (...args) => {\n if (startTimer.current) clearTimeout(startTimer.current);\n closeTimer.current = setTimeout(() => cleanFn(...args), 30);\n };\n return [startFunction, cleanFunction];\n};\n\nexport default useExecutionTimer;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAIO,MAAM,oBAAoB,CAAC,SAAmB,SAAmB,cAAsB;AAC5F,QAAM,aAAa,OAAuB;AAC1C,QAAM,aAAa,OAAuB;AAE1C,QAAM,gBAA0B,IAAI,SAAS;AAC3C,QAAI,WAAW;AAAS,mBAAa,WAAW,OAAO;AACvD,eAAW,UAAU,WAAW,MAAM,QAAQ,GAAG,IAAI,GAAG,SAAS;AAAA,EACnE;AAEA,QAAM,gBAA0B,IAAI,SAAS;AAC3C,QAAI,WAAW;AAAS,mBAAa,WAAW,OAAO;AACvD,eAAW,UAAU,WAAW,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAE;AAAA,EAC5D;AACA,SAAO,CAAC,eAAe,aAAa;AACtC;AAEA,IAAO,4BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useExpandState.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport { isFunction } from '../utils';\nimport { useDerivedStateFromProps } from './useDerivedStateFromProps';\n\nconst toggleStateInObject = (obj, key, value) => {\n const nextObj = { ...obj };\n if (nextObj[key]) {\n delete nextObj[key];\n } else {\n nextObj[key] = value;\n }\n return nextObj;\n};\n\nconst noop = () => null;\n\nexport const useExpandState = ({\n items = [],\n itemKey = 'id',\n expanded: expandedProp = {},\n onExpand,\n onExpandChange = noop,\n onExpandAll = noop,\n onToggleExpand,\n onCollapse,\n}) => {\n const [expanded, setExpanded] = useDerivedStateFromProps(expandedProp);\n\n const isExpandedAll = useMemo(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport { isFunction } from '../utils';\nimport { useDerivedStateFromProps } from './useDerivedStateFromProps';\n\ntype ItemT = Record<string, string>;\ninterface UseExpandStateArg {\n items?: ItemT[];\n itemKey?: keyof ItemT;\n expanded?: Record<string, boolean>;\n onExpand: (item: ItemT) => void;\n onExpandChange: (nextState: Record<string, boolean>, item?: ItemT) => void;\n onExpandAll: (nextState: Record<string, boolean>) => void;\n onToggleExpand: (item: ItemT) => void;\n onCollapse: (item: ItemT) => void;\n}\n\nconst toggleStateInObject = <T,>(obj: Record<string, T>, key: string, value: T) => {\n const nextObj = { ...obj };\n if (nextObj[key]) {\n delete nextObj[key];\n } else {\n nextObj[key] = value;\n }\n return nextObj;\n};\n\nconst noop = () => null;\n\nexport const useExpandState = ({\n items = [],\n itemKey = 'id',\n expanded: expandedProp = {},\n onExpand,\n onExpandChange = noop,\n onExpandAll = noop,\n onToggleExpand,\n onCollapse,\n}: UseExpandStateArg) => {\n const [expanded, setExpanded] = useDerivedStateFromProps(expandedProp);\n\n const isExpandedAll = useMemo(() => Object.keys(expanded).length === items.length, [expanded, items]);\n\n const toggleExpandAll = (stateData = true) => {\n setExpanded(() => {\n const nextState: Record<string, boolean> = {};\n if (!isExpandedAll) {\n items.forEach((item) => {\n nextState[item[itemKey]] = stateData;\n });\n }\n onExpandChange(nextState);\n onExpandAll(nextState);\n return nextState;\n });\n };\n\n const expand = (item: ItemT, stateData = true) => {\n if (!item) return;\n if (isFunction(onExpand)) {\n onExpand(item);\n }\n setExpanded((prevState) => {\n const key = item[itemKey];\n const nextState = { ...prevState, [key]: stateData };\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n const toggleExpand = (item: ItemT, stateData = true) => {\n if (isFunction(onToggleExpand)) {\n onToggleExpand(item);\n }\n setExpanded((prevState) => {\n const key = item[itemKey];\n const nextState = toggleStateInObject(prevState, key, stateData);\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n const collapse = (item: ItemT) => {\n if (isFunction(onCollapse)) {\n onCollapse(item);\n }\n setExpanded((prevState) => {\n const nextState = { ...prevState };\n delete nextState[item[itemKey]];\n onExpandChange(nextState, item);\n return nextState;\n });\n };\n\n return {\n state: { expanded, isExpandedAll },\n actions: {\n expand,\n toggleExpandAll,\n toggleExpand,\n collapse,\n },\n setExpanded,\n };\n};\n\nexport default useExpandState;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACAA;AACA;AACA;AAcA,MAAM,sBAAsB,CAAK,KAAwB,KAAa,UAAa;AACjF,QAAM,UAAU,mBAAK;AACrB,MAAI,QAAQ,MAAM;AAChB,WAAO,QAAQ;AAAA,EACjB,OAAO;AACL,YAAQ,OAAO;AAAA,EACjB;AACA,SAAO;AACT;AAEA,MAAM,OAAO,MAAM;AAEZ,MAAM,iBAAiB,CAAC;AAAA,EAC7B,QAAQ,CAAC;AAAA,EACT,UAAU;AAAA,EACV,UAAU,eAAe,CAAC;AAAA,EAC1B;AAAA,EACA,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd;AAAA,EACA;AAAA,MACuB;AACvB,QAAM,CAAC,UAAU,eAAe,yBAAyB,YAAY;AAErE,QAAM,gBAAgB,QAAQ,MAAM,OAAO,KAAK,QAAQ,EAAE,WAAW,MAAM,QAAQ,CAAC,UAAU,KAAK,CAAC;AAEpG,QAAM,kBAAkB,CAAC,YAAY,SAAS;AAC5C,gBAAY,MAAM;AAChB,YAAM,YAAqC,CAAC;AAC5C,UAAI,CAAC,eAAe;AAClB,cAAM,QAAQ,CAAC,SAAS;AACtB,oBAAU,KAAK,YAAY;AAAA,QAC7B,CAAC;AAAA,MACH;AACA,qBAAe,SAAS;AACxB,kBAAY,SAAS;AACrB,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,QAAM,SAAS,CAAC,MAAa,YAAY,SAAS;AAChD,QAAI,CAAC;AAAM;AACX,QAAI,WAAW,QAAQ,GAAG;AACxB,eAAS,IAAI;AAAA,IACf;AACA,gBAAY,CAAC,cAAc;AACzB,YAAM,MAAM,KAAK;AACjB,YAAM,YAAY,iCAAK,YAAL,GAAiB,MAAM,UAAU;AACnD,qBAAe,WAAW,IAAI;AAC9B,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,QAAM,eAAe,CAAC,MAAa,YAAY,SAAS;AACtD,QAAI,WAAW,cAAc,GAAG;AAC9B,qBAAe,IAAI;AAAA,IACrB;AACA,gBAAY,CAAC,cAAc;AACzB,YAAM,MAAM,KAAK;AACjB,YAAM,YAAY,oBAAoB,WAAW,KAAK,SAAS;AAC/D,qBAAe,WAAW,IAAI;AAC9B,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,SAAgB;AAChC,QAAI,WAAW,UAAU,GAAG;AAC1B,iBAAW,IAAI;AAAA,IACjB;AACA,gBAAY,CAAC,cAAc;AACzB,YAAM,YAAY,mBAAK;AACvB,aAAO,UAAU,KAAK;AACtB,qBAAe,WAAW,IAAI;AAC9B,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,OAAO,EAAE,UAAU,cAAc;AAAA,IACjC,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEA,IAAO,yBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useFocusTrap.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback, useEffect } 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}
|
|
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 UseFocusTrapT = <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\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\nconst UseFocusTrapWithSchema = describe(useFocusTrap);\n\nUseFocusTrapWithSchema.propTypes = propTypes;\n\nexport { useFocusTrap, UseFocusTrapWithSchema };\n"],
|
|
5
5
|
"mappings": "AAAA;ACAA;AACA;AAEA,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,MACR,gDAAgD;AAAA;AAAA,cAEtC,gBAAgB,WAAW;AAAA,cAC3B,kBAAkB;AAAA,GAE9B;AACF;AAEA,MAAM,qBAAqB,CAAC,iBAA+B;AACzD,QAAM,IAAI,MACR,8BAA8B,+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,YAC9E,mDACF,EAAE;AAAA,EACF,gBAAgB,UAAU,UAAU,CAAC,UAAU,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,IAAI,CAAC,EAAE,YAC7E,oDACF,EAAE;AAAA,EACF,WAAW,UAAU,KAAK,YAAY,8BAA8B;AACtE;AAYA,MAAM,eAA8B,CAAC,UAAU;AAE7C,YAAU,MAAM,cAAc,KAAK,GAAG,CAAC,KAAK,CAAC;AAE7C,QAAM,EAAE,iBAAiB,gBAAgB,cAAc;AAEvD,SAAO,YACL,CAAC,MAAqB;AACpB,QAAI;AAAW,gBAAU,CAAC;AAI1B,QAAI,EAAE,QAAQ,SAAS,CAAC,EAAE,YAAY,EAAE,WAAW,eAAe,WAAW,gBAAgB,SAAS;AACpG,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAClB,sBAAgB,QAAQ,MAAM;AAAA,IAChC;AACA,QAAI,EAAE,QAAQ,SAAS,EAAE,YAAY,EAAE,WAAW,gBAAgB,WAAW,eAAe,SAAS;AACnG,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAClB,qBAAe,QAAQ,MAAM;AAAA,IAC/B;AAAA,EACF,GACA,CAAC,iBAAiB,gBAAgB,SAAS,CAC7C;AACF;AAEA,MAAM,yBAAyB,SAAS,YAAY;AAEpD,uBAAuB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,7 +6,7 @@ const useHotkeys = ({ keys, handler, options = {} }, deps = []) => {
|
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
hotkeys(keys, options, memoizedCallback);
|
|
8
8
|
return () => hotkeys.unbind(keys);
|
|
9
|
-
}, [memoizedCallback]);
|
|
9
|
+
}, [keys, memoizedCallback, options]);
|
|
10
10
|
};
|
|
11
11
|
var useHotkeys_default = useHotkeys;
|
|
12
12
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useHotkeys.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import hotkeys from 'hotkeys-js';\nimport { useCallback, useEffect } from 'react';\n\nexport const useHotkeys = ({ keys, handler, options = {} }, deps = []) => {\n const memoizedCallback = useCallback(handler, deps);\n\n useEffect(() => {\n hotkeys(keys, options, memoizedCallback);\n\n return () => hotkeys.unbind(keys);\n }, [memoizedCallback]);\n};\n\nexport default useHotkeys;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;
|
|
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;ACAA;AACA;AAeO,MAAM,aAAa,CAAC,EAAE,MAAM,SAAS,UAAU,CAAC,KAAoB,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
|
}
|
|
@@ -9,13 +9,15 @@ const useHoverHandlersDelay = ({
|
|
|
9
9
|
const hideTimer = useRef();
|
|
10
10
|
const showTimer = useRef();
|
|
11
11
|
const delayedHide = useCallback(() => {
|
|
12
|
-
|
|
12
|
+
if (showTimer.current)
|
|
13
|
+
clearTimeout(showTimer.current);
|
|
13
14
|
hideTimer.current = setTimeout(onMouseLeave, hideDelay);
|
|
14
|
-
}, []);
|
|
15
|
+
}, [hideDelay, onMouseLeave]);
|
|
15
16
|
const delayedShow = useCallback(() => {
|
|
16
|
-
|
|
17
|
+
if (hideTimer.current)
|
|
18
|
+
clearTimeout(hideTimer.current);
|
|
17
19
|
showTimer.current = setTimeout(onMouseOver, showDelay);
|
|
18
|
-
}, []);
|
|
20
|
+
}, [onMouseOver, showDelay]);
|
|
19
21
|
return {
|
|
20
22
|
onMouseOver: delayedShow,
|
|
21
23
|
onMouseLeave: delayedHide
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useHoverHandlersDelay.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useRef } from 'react';\n\nexport const useHoverHandlersDelay = ({\n onMouseOver,\n onMouseLeave,\n hideDelay = 300,\n showDelay = 300,\n}) => {\n const hideTimer = useRef();\n const showTimer = useRef();\n\n const delayedHide = useCallback(() => {\n clearTimeout(showTimer.current);\n hideTimer.current = setTimeout(onMouseLeave, hideDelay);\n }, []);\n\n const delayedShow = useCallback(() => {\n clearTimeout(hideTimer.current);\n showTimer.current = setTimeout(onMouseOver, showDelay);\n }, []);\n\n return {\n onMouseOver: delayedShow,\n onMouseLeave: delayedHide,\n };\n};\n\nexport default useHoverHandlersDelay;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;
|
|
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;ACAA;AASO,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AAAA,MACkB;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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/usePrevious.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useEffect, useRef } from 'react';\n\nexport const usePrevious = (value) => {\n const ref = useRef();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n};\n\nexport default usePrevious;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEO,MAAM,cAAc,CAAC,
|
|
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;ACAA;AAEO,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
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
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 = new ResizeObserver((entries) => {
|
|
7
|
+
const resizeObserver = useMemo(() => new ResizeObserver((entries) => {
|
|
8
8
|
if (!Array.isArray(entries))
|
|
9
9
|
return;
|
|
10
10
|
if (!entries.length)
|
|
@@ -14,13 +14,13 @@ const useResizeObserver = (handler, el) => {
|
|
|
14
14
|
width: entry.target.offsetWidth,
|
|
15
15
|
height: entry.target.offsetHeight
|
|
16
16
|
}, entry.target));
|
|
17
|
-
});
|
|
17
|
+
}), [handler]);
|
|
18
18
|
const htmlEl = el || node;
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
if (htmlEl)
|
|
21
21
|
resizeObserver.observe(htmlEl);
|
|
22
22
|
return () => htmlEl && resizeObserver.unobserve(htmlEl);
|
|
23
|
-
}, [htmlEl]);
|
|
23
|
+
}, [htmlEl, resizeObserver]);
|
|
24
24
|
return [setRef];
|
|
25
25
|
};
|
|
26
26
|
var useResizeObserver_default = useResizeObserver;
|