@elliemae/ds-utilities 2.2.0-next.3 → 2.3.0-alpha.1
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/cjs/capitalize.js +35 -7
- package/cjs/capitalize.js.map +7 -0
- package/cjs/compose.js +39 -32
- package/cjs/compose.js.map +7 -0
- package/cjs/getComponentFromProps.js +47 -29
- package/cjs/getComponentFromProps.js.map +7 -0
- package/cjs/hooks/index.js +68 -60
- package/cjs/hooks/index.js.map +7 -0
- package/cjs/hooks/useCancellableDelayedCallback.js +43 -18
- package/cjs/hooks/useCancellableDelayedCallback.js.map +7 -0
- package/cjs/hooks/useDerivedStateFromProps.js +47 -36
- package/cjs/hooks/useDerivedStateFromProps.js.map +7 -0
- package/cjs/hooks/useExecutionTimer.js +43 -24
- package/cjs/hooks/useExecutionTimer.js.map +7 -0
- package/cjs/hooks/useExpandState.js +69 -82
- package/cjs/hooks/useExpandState.js.map +7 -0
- package/cjs/hooks/useHotkeys.js +44 -24
- package/cjs/hooks/useHotkeys.js.map +7 -0
- package/cjs/hooks/useHoverHandlersDelay.js +48 -18
- package/cjs/hooks/useHoverHandlersDelay.js.map +7 -0
- package/cjs/hooks/useOnElementResize.js +44 -27
- package/cjs/hooks/useOnElementResize.js.map +7 -0
- package/cjs/hooks/useParentElement.js +40 -13
- package/cjs/hooks/useParentElement.js.map +7 -0
- package/cjs/hooks/usePrevious.js +41 -10
- package/cjs/hooks/usePrevious.js.map +7 -0
- package/cjs/hooks/useResizeObserver.js +52 -25
- package/cjs/hooks/useResizeObserver.js.map +7 -0
- package/cjs/hooks/useSetRef.js +38 -11
- package/cjs/hooks/useSetRef.js.map +7 -0
- package/cjs/hooks/useShouldRecalculate.js +41 -14
- package/cjs/hooks/useShouldRecalculate.js.map +7 -0
- package/cjs/hooks/useWindowScrollerList.js +51 -33
- package/cjs/hooks/useWindowScrollerList.js.map +7 -0
- package/cjs/hooks/useWindowSize.js +49 -19
- package/cjs/hooks/useWindowSize.js.map +7 -0
- package/cjs/index.js +145 -266
- package/cjs/index.js.map +7 -0
- package/cjs/onClickHandlerForNonInteractiveElements.js +46 -19
- package/cjs/onClickHandlerForNonInteractiveElements.js.map +7 -0
- package/cjs/operators.js +56 -51
- package/cjs/operators.js.map +7 -0
- package/cjs/platform.js +37 -9
- package/cjs/platform.js.map +7 -0
- package/cjs/reactTypesUtility.js +45 -22
- package/cjs/reactTypesUtility.js.map +7 -0
- package/cjs/scrollingTimer.js +37 -15
- package/cjs/scrollingTimer.js.map +7 -0
- package/cjs/system.js +47 -30
- package/cjs/system.js.map +7 -0
- package/cjs/timeUtils.js +42 -24
- package/cjs/timeUtils.js.map +7 -0
- package/cjs/utils.js +101 -237
- package/cjs/utils.js.map +7 -0
- package/cjs/validations.js +48 -35
- package/cjs/validations.js.map +7 -0
- package/esm/capitalize.js +6 -3
- package/esm/capitalize.js.map +7 -0
- package/esm/compose.js +11 -29
- package/esm/compose.js.map +7 -0
- package/esm/getComponentFromProps.js +18 -22
- package/esm/getComponentFromProps.js.map +7 -0
- package/esm/hooks/index.js +40 -18
- package/esm/hooks/index.js.map +7 -0
- package/esm/hooks/useCancellableDelayedCallback.js +12 -14
- package/esm/hooks/useCancellableDelayedCallback.js.map +7 -0
- package/esm/hooks/useDerivedStateFromProps.js +15 -31
- package/esm/hooks/useDerivedStateFromProps.js.map +7 -0
- package/esm/hooks/useExecutionTimer.js +12 -20
- package/esm/hooks/useExecutionTimer.js.map +7 -0
- package/esm/hooks/useExpandState.js +36 -72
- package/esm/hooks/useExpandState.js.map +7 -0
- package/esm/hooks/useHotkeys.js +11 -14
- package/esm/hooks/useHotkeys.js.map +7 -0
- package/esm/hooks/useHoverHandlersDelay.js +15 -12
- package/esm/hooks/useHoverHandlersDelay.js.map +7 -0
- package/esm/hooks/useOnElementResize.js +12 -20
- package/esm/hooks/useOnElementResize.js.map +7 -0
- package/esm/hooks/useParentElement.js +9 -7
- package/esm/hooks/useParentElement.js.map +7 -0
- package/esm/hooks/usePrevious.js +10 -6
- package/esm/hooks/usePrevious.js.map +7 -0
- package/esm/hooks/useResizeObserver.js +20 -15
- package/esm/hooks/useResizeObserver.js.map +7 -0
- package/esm/hooks/useSetRef.js +8 -6
- package/esm/hooks/useSetRef.js.map +7 -0
- package/esm/hooks/useShouldRecalculate.js +11 -11
- package/esm/hooks/useShouldRecalculate.js.map +7 -0
- package/esm/hooks/useWindowScrollerList.js +20 -29
- package/esm/hooks/useWindowScrollerList.js.map +7 -0
- package/esm/hooks/useWindowSize.js +18 -15
- package/esm/hooks/useWindowSize.js.map +7 -0
- package/esm/index.js +204 -31
- package/esm/index.js.map +7 -0
- package/esm/onClickHandlerForNonInteractiveElements.js +17 -17
- package/esm/onClickHandlerForNonInteractiveElements.js.map +7 -0
- package/esm/operators.js +27 -34
- package/esm/operators.js.map +7 -0
- package/esm/platform.js +8 -4
- package/esm/platform.js.map +7 -0
- package/esm/reactTypesUtility.js +16 -9
- package/esm/reactTypesUtility.js.map +7 -0
- package/esm/scrollingTimer.js +8 -11
- package/esm/scrollingTimer.js.map +7 -0
- package/esm/system.js +16 -22
- package/esm/system.js.map +7 -0
- package/esm/timeUtils.js +13 -19
- package/esm/timeUtils.js.map +7 -0
- package/esm/utils.js +109 -72
- package/esm/utils.js.map +7 -0
- package/esm/validations.js +18 -28
- package/esm/validations.js.map +7 -0
- package/package.json +1 -1
- package/types/compose.d.ts +2 -1
- package/types/getComponentFromProps.d.ts +2 -1
- package/types/hooks/index.d.ts +14 -14
- package/types/hooks/useCancellableDelayedCallback.d.ts +2 -1
- package/types/hooks/useDerivedStateFromProps.d.ts +2 -1
- package/types/hooks/useExecutionTimer.d.ts +2 -1
- package/types/hooks/useExpandState.d.ts +3 -2
- package/types/hooks/useHotkeys.d.ts +3 -2
- package/types/hooks/useHoverHandlersDelay.d.ts +3 -2
- package/types/hooks/usePrevious.d.ts +1 -1
- package/types/hooks/useResizeObserver.d.ts +2 -1
- package/types/hooks/useShouldRecalculate.d.ts +2 -1
- package/types/hooks/useWindowScrollerList.d.ts +3 -2
- package/types/hooks/useWindowSize.d.ts +2 -1
- package/types/index.d.ts +11 -11
- package/types/onClickHandlerForNonInteractiveElements.d.ts +7 -7
- package/types/scrollingTimer.d.ts +1 -1
package/esm/hooks/index.js
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { default as default2 } from "use-measure";
|
|
3
|
+
import { default as default3 } from "use-force-update";
|
|
4
|
+
import { default as default4 } from "use-onclickoutside";
|
|
5
|
+
import { useUncontrolled } from "uncontrollable";
|
|
6
|
+
import { useExecutionTimer } from "./useExecutionTimer";
|
|
7
|
+
import { useExpandState } from "./useExpandState";
|
|
8
|
+
import { useHotkeys } from "./useHotkeys";
|
|
9
|
+
import { useHoverHandlersDelay } from "./useHoverHandlersDelay";
|
|
10
|
+
import { useResizeObserver } from "./useResizeObserver";
|
|
11
|
+
import { useShouldRecalculate } from "./useShouldRecalculate";
|
|
12
|
+
import { useWindowScrollerList } from "./useWindowScrollerList";
|
|
13
|
+
import { useWindowSize } from "./useWindowSize";
|
|
14
|
+
import { usePrevious } from "./usePrevious";
|
|
15
|
+
import { useCancellableDelayedCallback } from "./useCancellableDelayedCallback";
|
|
16
|
+
import { useDerivedStateFromProps } from "./useDerivedStateFromProps";
|
|
17
|
+
import { useSetRef } from "./useSetRef";
|
|
18
|
+
import { useParentElement } from "./useParentElement";
|
|
19
|
+
import { useOnElementResize } from "./useOnElementResize";
|
|
20
|
+
export {
|
|
21
|
+
useCancellableDelayedCallback,
|
|
22
|
+
useDerivedStateFromProps,
|
|
23
|
+
useExecutionTimer,
|
|
24
|
+
useExpandState,
|
|
25
|
+
default3 as useForceUpdate,
|
|
26
|
+
useHotkeys,
|
|
27
|
+
useHoverHandlersDelay,
|
|
28
|
+
default2 as useMeasure,
|
|
29
|
+
default4 as useOnClickOutside,
|
|
30
|
+
useOnElementResize,
|
|
31
|
+
useParentElement,
|
|
32
|
+
usePrevious,
|
|
33
|
+
useResizeObserver,
|
|
34
|
+
useSetRef,
|
|
35
|
+
useShouldRecalculate,
|
|
36
|
+
useUncontrolled,
|
|
37
|
+
useWindowScrollerList,
|
|
38
|
+
useWindowSize
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 { useUncontrolled } from 'uncontrollable';\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 { useWindowSize } from './useWindowSize';\nexport { usePrevious } from './usePrevious';\nexport { useCancellableDelayedCallback } from './useCancellableDelayedCallback';\nexport { useDerivedStateFromProps } from './useDerivedStateFromProps';\nexport { useSetRef } from './useSetRef';\nexport { useParentElement } from './useParentElement';\nexport { useOnElementResize } from './useOnElementResize';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
function useCancellableDelayedCallback(cb, delay) {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
|
+
const useCancellableDelayedCallback = (cb, delay) => {
|
|
5
4
|
const timeoutRef = useRef();
|
|
6
5
|
const cancel = useCallback(() => {
|
|
7
6
|
const timeoutId = timeoutRef.current;
|
|
8
|
-
|
|
9
7
|
if (timeoutId) {
|
|
10
|
-
timeoutRef.current =
|
|
8
|
+
timeoutRef.current = void 0;
|
|
11
9
|
clearTimeout(timeoutId);
|
|
12
10
|
}
|
|
13
11
|
}, [timeoutRef]);
|
|
14
|
-
const delayedCb = useCallback(
|
|
15
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
-
args[_key] = arguments[_key];
|
|
17
|
-
}
|
|
18
|
-
|
|
12
|
+
const delayedCb = useCallback((...args) => {
|
|
19
13
|
timeoutRef.current = setTimeout(() => cb(...args), delay);
|
|
20
14
|
}, [cb, delay]);
|
|
21
15
|
return [delayedCb, cancel];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export {
|
|
16
|
+
};
|
|
17
|
+
var useCancellableDelayedCallback_default = useCancellableDelayedCallback;
|
|
18
|
+
export {
|
|
19
|
+
useCancellableDelayedCallback_default as default,
|
|
20
|
+
useCancellableDelayedCallback
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useCancellableDelayedCallback.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;AAEO,MAAM,gCAAgC,CAAC,IAAI,UAAU;AAC1D,QAAM,aAAa;AACnB,QAAM,SAAS,YAAY,MAAM;AAC/B,UAAM,YAAY,WAAW;AAC7B,QAAI,WAAW;AACb,iBAAW,UAAU;AACrB,mBAAa;AAAA;AAAA,KAEd,CAAC;AACJ,QAAM,YAAY,YAChB,IAAI,SAAS;AACX,eAAW,UAAU,WAAW,MAAM,GAAG,GAAG,OAAO;AAAA,KAErD,CAAC,IAAI;AAGP,SAAO,CAAC,WAAW;AAAA;AAGrB,IAAO,wCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
7
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
8
|
-
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
9
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
10
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
11
|
-
import { isFunction, isEqual } from 'lodash';
|
|
12
|
-
|
|
13
|
-
const defaultPropUpdateOnChange = prop => prop;
|
|
14
|
-
|
|
15
|
-
function defaultShouldUpdate(_ref) {
|
|
16
|
-
let {
|
|
17
|
-
prop,
|
|
18
|
-
prevProp,
|
|
19
|
-
stateValue
|
|
20
|
-
} = _ref;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { isEqual, isFunction } from "../utils";
|
|
4
|
+
const defaultPropUpdateOnChange = (prop) => prop;
|
|
5
|
+
function defaultShouldUpdate({ prop, prevProp, stateValue }) {
|
|
21
6
|
return !isEqual(prop, prevProp) && !isEqual(prop, stateValue);
|
|
22
7
|
}
|
|
23
|
-
|
|
24
8
|
function setStateWithUpdate(onUpdate, setState) {
|
|
25
|
-
return state => {
|
|
26
|
-
setState(prevState => onUpdate(isFunction(state) ? state(prevState) : state, prevState));
|
|
9
|
+
return (state) => {
|
|
10
|
+
setState((prevState) => onUpdate(isFunction(state) ? state(prevState) : state, prevState));
|
|
27
11
|
};
|
|
28
12
|
}
|
|
29
|
-
|
|
30
|
-
function useDerivedStateFromProp(prop) {
|
|
31
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
13
|
+
const useDerivedStateFromProps = (prop, options = {}) => {
|
|
32
14
|
const {
|
|
33
15
|
onUpdate = defaultPropUpdateOnChange,
|
|
34
16
|
shouldUpdate = defaultShouldUpdate,
|
|
@@ -37,7 +19,6 @@ function useDerivedStateFromProp(prop) {
|
|
|
37
19
|
const [stateValue, setState] = useState(onUpdate(prop, {}));
|
|
38
20
|
const handleSetState = updateOnStateChange ? setStateWithUpdate(onUpdate, setState) : setState;
|
|
39
21
|
const prevProp = useRef(prop);
|
|
40
|
-
|
|
41
22
|
if (shouldUpdate({
|
|
42
23
|
prop,
|
|
43
24
|
prevProp: prevProp.current,
|
|
@@ -46,9 +27,12 @@ function useDerivedStateFromProp(prop) {
|
|
|
46
27
|
const nextProp = onUpdate(prop, prevProp.current);
|
|
47
28
|
setState(nextProp);
|
|
48
29
|
}
|
|
49
|
-
|
|
50
30
|
prevProp.current = prop;
|
|
51
31
|
return [stateValue, handleSetState];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export {
|
|
32
|
+
};
|
|
33
|
+
var useDerivedStateFromProps_default = useDerivedStateFromProps;
|
|
34
|
+
export {
|
|
35
|
+
useDerivedStateFromProps_default as default,
|
|
36
|
+
useDerivedStateFromProps
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=useDerivedStateFromProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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, setState) {\n return state => {\n setState(prevState =>\n onUpdate(isFunction(state) ? state(prevState) : state, prevState),\n );\n };\n}\n\nexport const useDerivedStateFromProps = (prop, options = {}) => {\n const {\n onUpdate = defaultPropUpdateOnChange,\n shouldUpdate = defaultShouldUpdate,\n updateOnStateChange = false,\n } = options;\n\n const [stateValue, setState] = useState(onUpdate(prop, {}));\n const handleSetState = updateOnStateChange\n ? setStateWithUpdate(onUpdate, setState)\n : 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;AAEA,MAAM,4BAA4B,UAAQ;AAE1C,6BAA6B,EAAE,MAAM,UAAU,cAAc;AAC3D,SAAO,CAAC,QAAQ,MAAM,aAAa,CAAC,QAAQ,MAAM;AAAA;AAGpD,4BAA4B,UAAU,UAAU;AAC9C,SAAO,WAAS;AACd,aAAS,eACP,SAAS,WAAW,SAAS,MAAM,aAAa,OAAO;AAAA;AAAA;AAKtD,MAAM,2BAA2B,CAAC,MAAM,UAAU,OAAO;AAC9D,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,eAAe;AAAA,IACf,sBAAsB;AAAA,MACpB;AAEJ,QAAM,CAAC,YAAY,YAAY,SAAS,SAAS,MAAM;AACvD,QAAM,iBAAiB,sBACnB,mBAAmB,UAAU,YAC7B;AACJ,QAAM,WAAW,OAAO;AAExB,MACE,aAAa;AAAA,IACX;AAAA,IACA,UAAU,SAAS;AAAA,IACnB;AAAA,MAEF;AACA,UAAM,WAAW,SAAS,MAAM,SAAS;AACzC,aAAS;AAAA;AAEX,WAAS,UAAU;AACnB,SAAO,CAAC,YAAY;AAAA;AAGtB,IAAO,mCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRef } from
|
|
3
|
-
|
|
4
|
-
function useExecutionDelay(startFn, cleanFn, delayTime) {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
const useExecutionTimer = (startFn, cleanFn, delayTime) => {
|
|
5
4
|
const startTimer = useRef();
|
|
6
5
|
const closeTimer = useRef();
|
|
7
|
-
|
|
8
|
-
const startFunction = function () {
|
|
9
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10
|
-
args[_key] = arguments[_key];
|
|
11
|
-
}
|
|
12
|
-
|
|
6
|
+
const startFunction = (...args) => {
|
|
13
7
|
clearTimeout(closeTimer.current);
|
|
14
8
|
startTimer.current = setTimeout(() => startFn(...args), delayTime);
|
|
15
9
|
};
|
|
16
|
-
|
|
17
|
-
const cleanFunction = function () {
|
|
18
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
19
|
-
args[_key2] = arguments[_key2];
|
|
20
|
-
}
|
|
21
|
-
|
|
10
|
+
const cleanFunction = (...args) => {
|
|
22
11
|
clearTimeout(startTimer.current);
|
|
23
12
|
closeTimer.current = setTimeout(() => cleanFn(...args), 30);
|
|
24
13
|
};
|
|
25
|
-
|
|
26
14
|
return [startFunction, cleanFunction];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export {
|
|
15
|
+
};
|
|
16
|
+
var useExecutionTimer_default = useExecutionTimer;
|
|
17
|
+
export {
|
|
18
|
+
useExecutionTimer_default as default,
|
|
19
|
+
useExecutionTimer
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=useExecutionTimer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;AAEO,MAAM,oBAAoB,CAAC,SAAS,SAAS,cAAc;AAChE,QAAM,aAAa;AACnB,QAAM,aAAa;AAEnB,QAAM,gBAAgB,IAAI,SAAS;AACjC,iBAAa,WAAW;AACxB,eAAW,UAAU,WAAW,MAAM,QAAQ,GAAG,OAAO;AAAA;AAG1D,QAAM,gBAAgB,IAAI,SAAS;AACjC,iBAAa,WAAW;AACxB,eAAW,UAAU,WAAW,MAAM,QAAQ,GAAG,OAAO;AAAA;AAE1D,SAAO,CAAC,eAAe;AAAA;AAGzB,IAAO,4BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,119 +1,79 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
6
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
8
|
-
import { useMemo } from 'react';
|
|
9
|
-
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
10
|
-
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
11
|
-
import { isFunction } from 'lodash';
|
|
12
|
-
import useDerivedStateFromProp from './useDerivedStateFromProps.js';
|
|
13
|
-
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { isFunction } from "../utils";
|
|
4
|
+
import { useDerivedStateFromProps } from "./useDerivedStateFromProps";
|
|
18
5
|
const toggleStateInObject = (obj, key, value) => {
|
|
19
|
-
const nextObj =
|
|
20
|
-
|
|
6
|
+
const nextObj = { ...obj };
|
|
21
7
|
if (nextObj[key]) {
|
|
22
8
|
delete nextObj[key];
|
|
23
9
|
} else {
|
|
24
10
|
nextObj[key] = value;
|
|
25
11
|
}
|
|
26
|
-
|
|
27
12
|
return nextObj;
|
|
28
13
|
};
|
|
29
|
-
|
|
30
14
|
const noop = () => null;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} = _ref;
|
|
43
|
-
const [expanded, setExpanded] = useDerivedStateFromProp(expandedProp);
|
|
15
|
+
const useExpandState = ({
|
|
16
|
+
items = [],
|
|
17
|
+
itemKey = "id",
|
|
18
|
+
expanded: expandedProp = {},
|
|
19
|
+
onExpand,
|
|
20
|
+
onExpandChange = noop,
|
|
21
|
+
onExpandAll = noop,
|
|
22
|
+
onToggleExpand,
|
|
23
|
+
onCollapse
|
|
24
|
+
}) => {
|
|
25
|
+
const [expanded, setExpanded] = useDerivedStateFromProps(expandedProp);
|
|
44
26
|
const isExpandedAll = useMemo(() => Object.keys(expanded).length === items.length, [expanded, items]);
|
|
45
|
-
|
|
46
|
-
const toggleExpandAll = function () {
|
|
47
|
-
let stateData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
27
|
+
const toggleExpandAll = (stateData = true) => {
|
|
48
28
|
setExpanded(() => {
|
|
49
29
|
const nextState = {};
|
|
50
|
-
|
|
51
30
|
if (!isExpandedAll) {
|
|
52
|
-
items.forEach(item => {
|
|
31
|
+
items.forEach((item) => {
|
|
53
32
|
nextState[item[itemKey]] = stateData;
|
|
54
33
|
});
|
|
55
34
|
}
|
|
56
|
-
|
|
57
35
|
onExpandChange(nextState);
|
|
58
36
|
onExpandAll(nextState);
|
|
59
37
|
return nextState;
|
|
60
38
|
});
|
|
61
39
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (!item) return;
|
|
66
|
-
|
|
40
|
+
const expand = (item, stateData = true) => {
|
|
41
|
+
if (!item)
|
|
42
|
+
return;
|
|
67
43
|
if (isFunction(onExpand)) {
|
|
68
44
|
onExpand(item);
|
|
69
45
|
}
|
|
70
|
-
|
|
71
|
-
setExpanded(prevState => {
|
|
46
|
+
setExpanded((prevState) => {
|
|
72
47
|
const key = item[itemKey];
|
|
73
|
-
|
|
74
|
-
const nextState = _objectSpread(_objectSpread({}, prevState), {}, {
|
|
75
|
-
[key]: stateData
|
|
76
|
-
});
|
|
77
|
-
|
|
48
|
+
const nextState = { ...prevState, [key]: stateData };
|
|
78
49
|
onExpandChange(nextState, item);
|
|
79
50
|
return nextState;
|
|
80
51
|
});
|
|
81
52
|
};
|
|
82
|
-
|
|
83
|
-
const toggleExpand = function (item) {
|
|
84
|
-
let stateData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
85
|
-
|
|
53
|
+
const toggleExpand = (item, stateData = true) => {
|
|
86
54
|
if (isFunction(onToggleExpand)) {
|
|
87
55
|
onToggleExpand(item);
|
|
88
56
|
}
|
|
89
|
-
|
|
90
|
-
setExpanded(prevState => {
|
|
57
|
+
setExpanded((prevState) => {
|
|
91
58
|
const key = item[itemKey];
|
|
92
59
|
const nextState = toggleStateInObject(prevState, key, stateData);
|
|
93
60
|
onExpandChange(nextState, item);
|
|
94
61
|
return nextState;
|
|
95
62
|
});
|
|
96
63
|
};
|
|
97
|
-
|
|
98
|
-
const collapse = item => {
|
|
64
|
+
const collapse = (item) => {
|
|
99
65
|
if (isFunction(onCollapse)) {
|
|
100
66
|
onCollapse(item);
|
|
101
67
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const nextState = _objectSpread({}, prevState);
|
|
105
|
-
|
|
68
|
+
setExpanded((prevState) => {
|
|
69
|
+
const nextState = { ...prevState };
|
|
106
70
|
delete nextState[item[itemKey]];
|
|
107
71
|
onExpandChange(nextState, item);
|
|
108
72
|
return nextState;
|
|
109
73
|
});
|
|
110
74
|
};
|
|
111
|
-
|
|
112
75
|
return {
|
|
113
|
-
state: {
|
|
114
|
-
expanded,
|
|
115
|
-
isExpandedAll
|
|
116
|
-
},
|
|
76
|
+
state: { expanded, isExpandedAll },
|
|
117
77
|
actions: {
|
|
118
78
|
expand,
|
|
119
79
|
toggleExpandAll,
|
|
@@ -122,6 +82,10 @@ function useExpandState(_ref) {
|
|
|
122
82
|
},
|
|
123
83
|
setExpanded
|
|
124
84
|
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export {
|
|
85
|
+
};
|
|
86
|
+
var useExpandState_default = useExpandState;
|
|
87
|
+
export {
|
|
88
|
+
useExpandState_default as default,
|
|
89
|
+
useExpandState
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=useExpandState.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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(\n () => Object.keys(expanded).length === items.length,\n [expanded, items],\n );\n\n const toggleExpandAll = (stateData = true) => {\n setExpanded(() => {\n const nextState = {};\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, 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, 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 => {\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;AAEA,MAAM,sBAAsB,CAAC,KAAK,KAAK,UAAU;AAC/C,QAAM,UAAU,KAAK;AACrB,MAAI,QAAQ,MAAM;AAChB,WAAO,QAAQ;AAAA,SACV;AACL,YAAQ,OAAO;AAAA;AAEjB,SAAO;AAAA;AAGT,MAAM,OAAO,MAAM;AAEZ,MAAM,iBAAiB,CAAC;AAAA,EAC7B,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU,eAAe;AAAA,EACzB;AAAA,EACA,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd;AAAA,EACA;AAAA,MACI;AACJ,QAAM,CAAC,UAAU,eAAe,yBAAyB;AAEzD,QAAM,gBAAgB,QACpB,MAAM,OAAO,KAAK,UAAU,WAAW,MAAM,QAC7C,CAAC,UAAU;AAGb,QAAM,kBAAkB,CAAC,YAAY,SAAS;AAC5C,gBAAY,MAAM;AAChB,YAAM,YAAY;AAClB,UAAI,CAAC,eAAe;AAClB,cAAM,QAAQ,UAAQ;AACpB,oBAAU,KAAK,YAAY;AAAA;AAAA;AAG/B,qBAAe;AACf,kBAAY;AACZ,aAAO;AAAA;AAAA;AAIX,QAAM,SAAS,CAAC,MAAM,YAAY,SAAS;AACzC,QAAI,CAAC;AAAM;AACX,QAAI,WAAW,WAAW;AACxB,eAAS;AAAA;AAEX,gBAAY,eAAa;AACvB,YAAM,MAAM,KAAK;AACjB,YAAM,YAAY,KAAK,YAAY,MAAM;AACzC,qBAAe,WAAW;AAC1B,aAAO;AAAA;AAAA;AAIX,QAAM,eAAe,CAAC,MAAM,YAAY,SAAS;AAC/C,QAAI,WAAW,iBAAiB;AAC9B,qBAAe;AAAA;AAEjB,gBAAY,eAAa;AACvB,YAAM,MAAM,KAAK;AACjB,YAAM,YAAY,oBAAoB,WAAW,KAAK;AACtD,qBAAe,WAAW;AAC1B,aAAO;AAAA;AAAA;AAIX,QAAM,WAAW,UAAQ;AACvB,QAAI,WAAW,aAAa;AAC1B,iBAAW;AAAA;AAEb,gBAAY,eAAa;AACvB,YAAM,YAAY,KAAK;AACvB,aAAO,UAAU,KAAK;AACtB,qBAAe,WAAW;AAC1B,aAAO;AAAA;AAAA;AAIX,SAAO;AAAA,IACL,OAAO,EAAE,UAAU;AAAA,IACnB,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAEF;AAAA;AAAA;AAIJ,IAAO,yBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/hooks/useHotkeys.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import hotkeys from
|
|
3
|
-
import { useCallback, useEffect } from
|
|
4
|
-
|
|
5
|
-
function useHotkeys(_ref) {
|
|
6
|
-
let {
|
|
7
|
-
keys,
|
|
8
|
-
handler,
|
|
9
|
-
options = {}
|
|
10
|
-
} = _ref;
|
|
11
|
-
let deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import hotkeys from "hotkeys-js";
|
|
3
|
+
import { useCallback, useEffect } from "react";
|
|
4
|
+
const useHotkeys = ({ keys, handler, options = {} }, deps = []) => {
|
|
12
5
|
const memoizedCallback = useCallback(handler, deps);
|
|
13
6
|
useEffect(() => {
|
|
14
7
|
hotkeys(keys, options, memoizedCallback);
|
|
15
8
|
return () => hotkeys.unbind(keys);
|
|
16
9
|
}, [memoizedCallback]);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export {
|
|
10
|
+
};
|
|
11
|
+
var useHotkeys_default = useHotkeys;
|
|
12
|
+
export {
|
|
13
|
+
useHotkeys_default as default,
|
|
14
|
+
useHotkeys
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useHotkeys.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;AAEO,MAAM,aAAa,CAAC,EAAE,MAAM,SAAS,UAAU,MAAM,OAAO,OAAO;AACxE,QAAM,mBAAmB,YAAY,SAAS;AAE9C,YAAU,MAAM;AACd,YAAQ,MAAM,SAAS;AAEvB,WAAO,MAAM,QAAQ,OAAO;AAAA,KAC3B,CAAC;AAAA;AAGN,IAAO,qBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} = _ref;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
|
+
const useHoverHandlersDelay = ({
|
|
4
|
+
onMouseOver,
|
|
5
|
+
onMouseLeave,
|
|
6
|
+
hideDelay = 300,
|
|
7
|
+
showDelay = 300
|
|
8
|
+
}) => {
|
|
10
9
|
const hideTimer = useRef();
|
|
11
10
|
const showTimer = useRef();
|
|
12
11
|
const delayedHide = useCallback(() => {
|
|
@@ -21,6 +20,10 @@ function useHoverHandlersDelay(_ref) {
|
|
|
21
20
|
onMouseOver: delayedShow,
|
|
22
21
|
onMouseLeave: delayedHide
|
|
23
22
|
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export {
|
|
23
|
+
};
|
|
24
|
+
var useHoverHandlersDelay_default = useHoverHandlersDelay;
|
|
25
|
+
export {
|
|
26
|
+
useHoverHandlersDelay_default as default,
|
|
27
|
+
useHoverHandlersDelay
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=useHoverHandlersDelay.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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;AAEO,MAAM,wBAAwB,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AAAA,MACR;AACJ,QAAM,YAAY;AAClB,QAAM,YAAY;AAElB,QAAM,cAAc,YAAY,MAAM;AACpC,iBAAa,UAAU;AACvB,cAAU,UAAU,WAAW,cAAc;AAAA,KAC5C;AAEH,QAAM,cAAc,YAAY,MAAM;AACpC,iBAAa,UAAU;AACvB,cAAU,UAAU,WAAW,aAAa;AAAA,KAC3C;AAEH,SAAO;AAAA,IACL,aAAa;AAAA,IACb,cAAc;AAAA;AAAA;AAIlB,IAAO,gCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const useOnElementResize = targetRef => {
|
|
7
|
-
var _targetRef$current, _targetRef$current2;
|
|
8
|
-
|
|
9
|
-
const [width, setWidth] = useState(targetRef.current ? (_targetRef$current = targetRef.current) === null || _targetRef$current === void 0 ? void 0 : _targetRef$current.offsetWidth : 0);
|
|
10
|
-
const [height, setHeight] = useState(targetRef.current ? (_targetRef$current2 = targetRef.current) === null || _targetRef$current2 === void 0 ? void 0 : _targetRef$current2.offsetWidth : 0);
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useState, useEffect, useRef, useMemo } from "react";
|
|
3
|
+
const useOnElementResize = (targetRef) => {
|
|
4
|
+
const [width, setWidth] = useState(targetRef.current ? targetRef.current?.offsetWidth : 0);
|
|
5
|
+
const [height, setHeight] = useState(targetRef.current ? targetRef.current?.offsetWidth : 0);
|
|
11
6
|
const observer = useRef(null);
|
|
12
7
|
useEffect(() => {
|
|
13
8
|
function outputsize() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
setWidth((_targetRef$current3 = targetRef.current) === null || _targetRef$current3 === void 0 ? void 0 : _targetRef$current3.offsetWidth);
|
|
17
|
-
setHeight((_targetRef$current4 = targetRef.current) === null || _targetRef$current4 === void 0 ? void 0 : _targetRef$current4.offsetHeight);
|
|
9
|
+
setWidth(targetRef.current?.offsetWidth);
|
|
10
|
+
setHeight(targetRef.current?.offsetHeight);
|
|
18
11
|
}
|
|
19
|
-
|
|
20
12
|
observer.current = new ResizeObserver(outputsize).observe(targetRef.current);
|
|
21
13
|
return () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
(_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.disconnect();
|
|
14
|
+
observer.current?.disconnect();
|
|
25
15
|
};
|
|
26
16
|
}, [targetRef]);
|
|
27
17
|
return useMemo(() => ({
|
|
@@ -29,5 +19,7 @@ const useOnElementResize = targetRef => {
|
|
|
29
19
|
height
|
|
30
20
|
}), [width, height]);
|
|
31
21
|
};
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
export {
|
|
23
|
+
useOnElementResize
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useOnElementResize.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useOnElementResize.tsx"],
|
|
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 = (targetRef: React.RefObject<HTMLDivElement>): Record<'width' | 'height', number> => {\n const [width, setWidth] = useState(targetRef.current ? targetRef.current?.offsetWidth : 0);\n const [height, setHeight] = useState(targetRef.current ? targetRef.current?.offsetWidth : 0);\n const observer = useRef(null);\n\n useEffect(() => {\n function outputsize() {\n setWidth(targetRef.current?.offsetWidth);\n setHeight(targetRef.current?.offsetHeight);\n }\n\n observer.current = new ResizeObserver(outputsize).observe(targetRef.current);\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;ACAA;AAIO,MAAM,qBAAqB,CAAC,cAAmF;AACpH,QAAM,CAAC,OAAO,YAAY,SAAS,UAAU,UAAU,UAAU,SAAS,cAAc;AACxF,QAAM,CAAC,QAAQ,aAAa,SAAS,UAAU,UAAU,UAAU,SAAS,cAAc;AAC1F,QAAM,WAAW,OAAO;AAExB,YAAU,MAAM;AACd,0BAAsB;AACpB,eAAS,UAAU,SAAS;AAC5B,gBAAU,UAAU,SAAS;AAAA;AAG/B,aAAS,UAAU,IAAI,eAAe,YAAY,QAAQ,UAAU;AAEpE,WAAO,MAAM;AACX,eAAS,SAAS;AAAA;AAAA,KAEnB,CAAC;AAEJ,SAAO,QACL,MAAO;AAAA,IACL;AAAA,IACA;AAAA,MAEF,CAAC,OAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const useParentElement = ref => {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
const useParentElement = (ref) => {
|
|
5
4
|
const [parent, setParent] = useState(ref.current);
|
|
6
5
|
useEffect(() => {
|
|
7
|
-
if (ref.current)
|
|
6
|
+
if (ref.current)
|
|
7
|
+
setParent(ref.current.parentNode);
|
|
8
8
|
});
|
|
9
9
|
return parent;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
export {
|
|
12
|
+
useParentElement
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useParentElement.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useParentElement.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useEffect, useState } from 'react';\n\nexport const useParentElement = (ref) => {\n const [parent, setParent] = useState(ref.current);\n\n useEffect(() => {\n if (ref.current) setParent(ref.current.parentNode);\n });\n return parent;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEO,MAAM,mBAAmB,CAAC,QAAQ;AACvC,QAAM,CAAC,QAAQ,aAAa,SAAS,IAAI;AAEzC,YAAU,MAAM;AACd,QAAI,IAAI;AAAS,gBAAU,IAAI,QAAQ;AAAA;AAEzC,SAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/hooks/usePrevious.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
const usePrevious = (value) => {
|
|
4
4
|
const ref = useRef();
|
|
5
5
|
useEffect(() => {
|
|
6
6
|
ref.current = value;
|
|
7
7
|
}, [value]);
|
|
8
8
|
return ref.current;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export {
|
|
9
|
+
};
|
|
10
|
+
var usePrevious_default = usePrevious;
|
|
11
|
+
export {
|
|
12
|
+
usePrevious_default as default,
|
|
13
|
+
usePrevious
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=usePrevious.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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,UAAU;AACpC,QAAM,MAAM;AAEZ,YAAU,MAAM;AACd,QAAI,UAAU;AAAA,KACb,CAAC;AAEJ,SAAO,IAAI;AAAA;AAGb,IAAO,sBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|