@contember/react-utils 1.2.0-rc.16 → 1.2.0-rc.18
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/development/hooks/useAutoHeightTextArea.js +41 -0
- package/dist/development/hooks/useAutoHeightTextArea.js.map +1 -0
- package/dist/development/hooks/useExpectSameValueReference.js +1 -1
- package/dist/development/hooks/useExpectSameValueReference.js.map +1 -1
- package/dist/development/hooks/useId.js +2 -2
- package/dist/development/hooks/useId.js.map +1 -1
- package/dist/development/hooks/useOnElementClickOutsideCallback.js +20 -0
- package/dist/development/hooks/useOnElementClickOutsideCallback.js.map +1 -0
- package/dist/development/hooks/useOnElementMouseEnterDelayedCallback.js +33 -0
- package/dist/development/hooks/useOnElementMouseEnterDelayedCallback.js.map +1 -0
- package/dist/development/hooks/useOnElementMutation.js +1 -1
- package/dist/development/hooks/useOnElementMutation.js.map +1 -1
- package/dist/development/hooks/useOnElementResize.js +28 -26
- package/dist/development/hooks/useOnElementResize.js.map +1 -1
- package/dist/development/hooks/useOnScrollWithin.js +33 -31
- package/dist/development/hooks/useOnScrollWithin.js.map +1 -1
- package/dist/development/index.js +6 -0
- package/dist/development/index.js.map +1 -1
- package/dist/production/hooks/useAutoHeightTextArea.js +41 -0
- package/dist/production/hooks/useAutoHeightTextArea.js.map +1 -0
- package/dist/production/hooks/useExpectSameValueReference.js +1 -1
- package/dist/production/hooks/useExpectSameValueReference.js.map +1 -1
- package/dist/production/hooks/useId.js +2 -2
- package/dist/production/hooks/useId.js.map +1 -1
- package/dist/production/hooks/useOnElementClickOutsideCallback.js +20 -0
- package/dist/production/hooks/useOnElementClickOutsideCallback.js.map +1 -0
- package/dist/production/hooks/useOnElementMouseEnterDelayedCallback.js +33 -0
- package/dist/production/hooks/useOnElementMouseEnterDelayedCallback.js.map +1 -0
- package/dist/production/hooks/useOnElementMutation.js +1 -1
- package/dist/production/hooks/useOnElementMutation.js.map +1 -1
- package/dist/production/hooks/useOnElementResize.js +28 -26
- package/dist/production/hooks/useOnElementResize.js.map +1 -1
- package/dist/production/hooks/useOnScrollWithin.js +33 -31
- package/dist/production/hooks/useOnScrollWithin.js.map +1 -1
- package/dist/production/index.js +6 -0
- package/dist/production/index.js.map +1 -1
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/useAutoHeightTextArea.d.ts +3 -0
- package/dist/types/hooks/useAutoHeightTextArea.d.ts.map +1 -0
- package/dist/types/hooks/useOnElementClickOutsideCallback.d.ts +3 -0
- package/dist/types/hooks/useOnElementClickOutsideCallback.d.ts.map +1 -0
- package/dist/types/hooks/useOnElementMouseEnterDelayedCallback.d.ts +14 -0
- package/dist/types/hooks/useOnElementMouseEnterDelayedCallback.d.ts.map +1 -0
- package/dist/types/hooks/useOnElementResize.d.ts.map +1 -1
- package/dist/types/hooks/useOnScrollWithin.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useAutoHeightTextArea.ts +51 -0
- package/src/hooks/useExpectSameValueReference.ts +1 -1
- package/src/hooks/useId.ts +2 -2
- package/src/hooks/useOnElementClickOutsideCallback.ts +23 -0
- package/src/hooks/useOnElementMouseEnterDelayedCallback.ts +54 -0
- package/src/hooks/useOnElementMutation.ts +1 -1
- package/src/hooks/useOnElementResize.ts +34 -31
- package/src/hooks/useOnScrollWithin.ts +32 -31
|
@@ -4,39 +4,41 @@ import { useScopedConsoleRef } from "../debug-context/Context.js";
|
|
|
4
4
|
function useOnElementResize(refOrElement, callback, options = {}, timeout = 300) {
|
|
5
5
|
const scopedConsoleRef = useScopedConsoleRef("useOnElementResize");
|
|
6
6
|
const { box = "border-box" } = options;
|
|
7
|
-
const element = unwrapRefValue(refOrElement);
|
|
8
7
|
const callbackRef = useRef(callback);
|
|
9
8
|
callbackRef.current = callback;
|
|
10
9
|
const lastTimeStamp = useRef(0);
|
|
11
10
|
useLayoutEffect(() => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const element = unwrapRefValue(refOrElement);
|
|
12
|
+
if (element) {
|
|
13
|
+
if (element instanceof HTMLElement) {
|
|
14
|
+
let debouncedOnChange = function([entry]) {
|
|
15
|
+
const timeStamp = Date.now();
|
|
16
|
+
const delta = timeStamp - lastTimeStamp.current;
|
|
17
|
+
if (delta > timeout) {
|
|
18
|
+
scopedConsoleRef.current.warned("element.resize:immediate", null);
|
|
19
|
+
callbackRef.current(entry);
|
|
20
|
+
lastTimeStamp.current = timeStamp;
|
|
21
|
+
} else {
|
|
22
|
+
clearTimeout(timeoutID);
|
|
23
|
+
timeoutID = setTimeout(() => {
|
|
24
|
+
scopedConsoleRef.current.warned("element.resize:debounced", null);
|
|
25
|
+
callbackRef.current(entry);
|
|
26
|
+
lastTimeStamp.current = timeStamp;
|
|
27
|
+
}, timeout);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
let timeoutID = void 0;
|
|
31
|
+
const resizeObserver = new ResizeObserver(debouncedOnChange);
|
|
32
|
+
resizeObserver.observe(element, { box });
|
|
33
|
+
return () => {
|
|
34
|
+
clearTimeout(timeoutID);
|
|
35
|
+
resizeObserver.unobserve(element);
|
|
36
|
+
};
|
|
20
37
|
} else {
|
|
21
|
-
|
|
22
|
-
timeoutID = setTimeout(() => {
|
|
23
|
-
scopedConsoleRef.current.warned("element.resize:debounced", null);
|
|
24
|
-
callbackRef.current(entry);
|
|
25
|
-
lastTimeStamp.current = timeStamp;
|
|
26
|
-
}, timeout);
|
|
38
|
+
throw new Error("Exhaustive error: Expecting element to be instance of HTMLElement");
|
|
27
39
|
}
|
|
28
40
|
}
|
|
29
|
-
|
|
30
|
-
const resizeObserver = new ResizeObserver(debouncedOnChange);
|
|
31
|
-
resizeObserver.observe(element, { box });
|
|
32
|
-
return () => {
|
|
33
|
-
clearTimeout(timeoutID);
|
|
34
|
-
resizeObserver.unobserve(element);
|
|
35
|
-
};
|
|
36
|
-
} else if (element) {
|
|
37
|
-
throw new Error("Exhaustive error: Expecting element to be instance of HTMLElement");
|
|
38
|
-
}
|
|
39
|
-
}, [box, element, scopedConsoleRef, timeout]);
|
|
41
|
+
}, [box, refOrElement, scopedConsoleRef, timeout]);
|
|
40
42
|
}
|
|
41
43
|
export {
|
|
42
44
|
useOnElementResize
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnElementResize.js","sources":["../../../src/hooks/useOnElementResize.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\n\nexport function useOnElementResize(\n\trefOrElement: RefObjectOrElement<HTMLElement | null> | null,\n\tcallback: (entries: ResizeObserverEntry) => void,\n\toptions: ResizeObserverOptions = {},\n\ttimeout: number = 300,\n): void {\n\tconst scopedConsoleRef = useScopedConsoleRef('useOnElementResize')\n\n\tconst { box = 'border-box' } = options\n\tconst
|
|
1
|
+
{"version":3,"file":"useOnElementResize.js","sources":["../../../src/hooks/useOnElementResize.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\n\nexport function useOnElementResize(\n\trefOrElement: RefObjectOrElement<HTMLElement | null> | null,\n\tcallback: (entries: ResizeObserverEntry) => void,\n\toptions: ResizeObserverOptions = {},\n\ttimeout: number = 300,\n): void {\n\tconst scopedConsoleRef = useScopedConsoleRef('useOnElementResize')\n\n\tconst { box = 'border-box' } = options\n\tconst callbackRef = useRef(callback); callbackRef.current = callback\n\tconst lastTimeStamp = useRef<number>(0)\n\n\tuseLayoutEffect(() => {\n\t\tconst element = unwrapRefValue(refOrElement)\n\n\t\tif (element) {\n\t\t\tif (element instanceof HTMLElement) {\n\t\t\t\tlet timeoutID: number | undefined = undefined\n\n\t\t\t\tfunction debouncedOnChange([entry]: ResizeObserverEntry[]) {\n\t\t\t\t\tconst timeStamp = Date.now()\n\t\t\t\t\tconst delta = timeStamp - lastTimeStamp.current\n\n\t\t\t\t\tif (delta > timeout) {\n\t\t\t\t\t\tscopedConsoleRef.current.warned('element.resize:immediate', null)\n\t\t\t\t\t\tcallbackRef.current(entry)\n\t\t\t\t\t\tlastTimeStamp.current = timeStamp\n\t\t\t\t\t} else {\n\t\t\t\t\t\tclearTimeout(timeoutID)\n\t\t\t\t\t\ttimeoutID = setTimeout(() => {\n\t\t\t\t\t\t\tscopedConsoleRef.current.warned('element.resize:debounced', null)\n\t\t\t\t\t\t\tcallbackRef.current(entry)\n\t\t\t\t\t\t\tlastTimeStamp.current = timeStamp\n\t\t\t\t\t\t}, timeout)\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst resizeObserver = new ResizeObserver(debouncedOnChange)\n\n\t\t\t\tresizeObserver.observe(element, { box })\n\n\t\t\t\treturn () => {\n\t\t\t\t\tclearTimeout(timeoutID)\n\t\t\t\t\tresizeObserver.unobserve(element)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new Error('Exhaustive error: Expecting element to be instance of HTMLElement')\n\t\t\t}\n\t\t}\n\t}, [box, refOrElement, scopedConsoleRef, timeout])\n}\n"],"names":[],"mappings":";;;AAIO,SAAS,mBACf,cACA,UACA,UAAiC,CAAC,GAClC,UAAkB,KACX;AACD,QAAA,mBAAmB,oBAAoB,oBAAoB;AAE3D,QAAA,EAAE,MAAM,aAAiB,IAAA;AACzB,QAAA,cAAc,OAAO,QAAQ;AAAG,cAAY,UAAU;AACtD,QAAA,gBAAgB,OAAe,CAAC;AAEtC,kBAAgB,MAAM;AACf,UAAA,UAAU,eAAe,YAAY;AAE3C,QAAI,SAAS;AACZ,UAAI,mBAAmB,aAAa;AAGnC,YAAS,oBAAT,SAA2B,CAAC,KAAK,GAA0B;AACpD,gBAAA,YAAY,KAAK;AACjB,gBAAA,QAAQ,YAAY,cAAc;AAExC,cAAI,QAAQ,SAAS;AACH,6BAAA,QAAQ,OAAO,4BAA4B,IAAI;AAChE,wBAAY,QAAQ,KAAK;AACzB,0BAAc,UAAU;AAAA,UAAA,OAClB;AACN,yBAAa,SAAS;AACtB,wBAAY,WAAW,MAAM;AACX,+BAAA,QAAQ,OAAO,4BAA4B,IAAI;AAChE,0BAAY,QAAQ,KAAK;AACzB,4BAAc,UAAU;AAAA,eACtB,OAAO;AAAA,UACX;AAAA,QAAA;AAjBD,YAAI,YAAgC;AAoB9B,cAAA,iBAAiB,IAAI,eAAe,iBAAiB;AAE3D,uBAAe,QAAQ,SAAS,EAAE,IAAK,CAAA;AAEvC,eAAO,MAAM;AACZ,uBAAa,SAAS;AACtB,yBAAe,UAAU,OAAO;AAAA,QAAA;AAAA,MACjC,OACM;AACA,cAAA,IAAI,MAAM,mEAAmE;AAAA,MACpF;AAAA,IACD;AAAA,KACE,CAAC,KAAK,cAAc,kBAAkB,OAAO,CAAC;AAClD;"}
|
|
@@ -6,43 +6,45 @@ function useOnScrollWithin(refOrElement, callback, interval = 1e3 / 60) {
|
|
|
6
6
|
const callbackRef = useRef(callback);
|
|
7
7
|
callbackRef.current = callback;
|
|
8
8
|
const lastTimeStamp = useRef(0);
|
|
9
|
-
const element = unwrapRefValue(refOrElement);
|
|
10
9
|
useLayoutEffect(() => {
|
|
10
|
+
const element = unwrapRefValue(refOrElement);
|
|
11
11
|
let timeoutID = void 0;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
lastTimeStamp.current = event.timeStamp;
|
|
20
|
-
} else {
|
|
21
|
-
timeoutID = setTimeout(() => {
|
|
22
|
-
scopedConsoleRef.current.warned("event:element.scroll:debounced", event);
|
|
23
|
-
lastTimeStamp.current = event.timeStamp;
|
|
12
|
+
if (element) {
|
|
13
|
+
let debouncedHandler = function(event) {
|
|
14
|
+
clearTimeout(timeoutID);
|
|
15
|
+
const delta = event.timeStamp - lastTimeStamp.current;
|
|
16
|
+
scopedConsoleRef.current.logged("event:element.scroll:delta", delta);
|
|
17
|
+
if (delta > interval) {
|
|
18
|
+
scopedConsoleRef.current.warned("event:element.scroll:immediately", event);
|
|
24
19
|
callbackRef.current(event);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
lastTimeStamp.current = event.timeStamp;
|
|
21
|
+
} else {
|
|
22
|
+
timeoutID = setTimeout(() => {
|
|
23
|
+
scopedConsoleRef.current.warned("event:element.scroll:debounced", event);
|
|
24
|
+
lastTimeStamp.current = event.timeStamp;
|
|
25
|
+
callbackRef.current(event);
|
|
26
|
+
}, interval);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
if (element instanceof HTMLElement) {
|
|
30
|
+
if (element instanceof HTMLBodyElement || element instanceof HTMLHtmlElement) {
|
|
31
|
+
window.addEventListener("scroll", debouncedHandler, { capture: true, passive: true });
|
|
32
|
+
window.addEventListener("resize", debouncedHandler);
|
|
33
|
+
return () => {
|
|
34
|
+
window.removeEventListener("scroll", debouncedHandler);
|
|
35
|
+
window.removeEventListener("resize", debouncedHandler);
|
|
36
|
+
};
|
|
37
|
+
} else {
|
|
38
|
+
element.addEventListener("scroll", debouncedHandler, { passive: true, capture: true });
|
|
39
|
+
return () => {
|
|
40
|
+
element.removeEventListener("scroll", debouncedHandler);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
|
-
} else
|
|
44
|
+
} else {
|
|
43
45
|
throw new Error("Exhaustive error: Expecting element to be instance of HTMLElement");
|
|
44
46
|
}
|
|
45
|
-
}, [
|
|
47
|
+
}, [interval, refOrElement, scopedConsoleRef]);
|
|
46
48
|
}
|
|
47
49
|
export {
|
|
48
50
|
useOnScrollWithin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnScrollWithin.js","sources":["../../../src/hooks/useOnScrollWithin.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\n\n/**\n * Invokes callback on scroll event within the scroll container\n *\n * @param refOrElement - Scroll container\n * @param callback - Callback that is invoked on scroll event\n * @param interval - Specifies how often should scroll event invoke callback\n */\nexport function useOnScrollWithin(\n\trefOrElement: RefObjectOrElement<HTMLElement | null> | null,\n\tcallback: (event: Event) => void,\n\tinterval: number = 1000 / 60,\n) {\n\tconst scopedConsoleRef = useScopedConsoleRef('useOnScrollWithin')\n\n\tconst callbackRef = useRef(callback); callbackRef.current = callback\n\tconst lastTimeStamp = useRef<number>(0)\n\n\tconst element = unwrapRefValue(refOrElement)\n\n\
|
|
1
|
+
{"version":3,"file":"useOnScrollWithin.js","sources":["../../../src/hooks/useOnScrollWithin.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\n\n/**\n * Invokes callback on scroll event within the scroll container\n *\n * @param refOrElement - Scroll container\n * @param callback - Callback that is invoked on scroll event\n * @param interval - Specifies how often should scroll event invoke callback\n */\nexport function useOnScrollWithin(\n\trefOrElement: RefObjectOrElement<HTMLElement | null> | null,\n\tcallback: (event: Event) => void,\n\tinterval: number = 1000 / 60,\n) {\n\tconst scopedConsoleRef = useScopedConsoleRef('useOnScrollWithin')\n\n\tconst callbackRef = useRef(callback); callbackRef.current = callback\n\tconst lastTimeStamp = useRef<number>(0)\n\n\tuseLayoutEffect(() => {\n\t\tconst element = unwrapRefValue(refOrElement)\n\n\t\tlet timeoutID: number | undefined = undefined\n\n\t\tif (element) {\n\t\t\tfunction debouncedHandler(event: Event) {\n\t\t\t\tclearTimeout(timeoutID)\n\n\t\t\t\tconst delta = event.timeStamp - lastTimeStamp.current\n\t\t\t\tscopedConsoleRef.current.logged('event:element.scroll:delta', delta)\n\n\t\t\t\tif (delta > interval) {\n\t\t\t\t\tscopedConsoleRef.current.warned('event:element.scroll:immediately', event)\n\t\t\t\t\tcallbackRef.current(event)\n\t\t\t\t\tlastTimeStamp.current = event.timeStamp\n\t\t\t\t} else {\n\t\t\t\t\ttimeoutID = setTimeout(() => {\n\t\t\t\t\t\tscopedConsoleRef.current.warned('event:element.scroll:debounced', event)\n\t\t\t\t\t\tlastTimeStamp.current = event.timeStamp\n\t\t\t\t\t\tcallbackRef.current(event)\n\t\t\t\t\t}, interval)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (element instanceof HTMLElement) {\n\t\t\t\tif (element instanceof HTMLBodyElement || element instanceof HTMLHtmlElement) {\n\t\t\t\t\twindow.addEventListener('scroll', debouncedHandler, { capture: true, passive: true })\n\t\t\t\t\twindow.addEventListener('resize', debouncedHandler)\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\twindow.removeEventListener('scroll', debouncedHandler)\n\t\t\t\t\t\twindow.removeEventListener('resize', debouncedHandler)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\telement.addEventListener('scroll', debouncedHandler, { passive: true, capture: true })\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\telement.removeEventListener('scroll', debouncedHandler)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error('Exhaustive error: Expecting element to be instance of HTMLElement')\n\t\t}\n\t}, [interval, refOrElement, scopedConsoleRef])\n}\n"],"names":[],"mappings":";;;AAWO,SAAS,kBACf,cACA,UACA,WAAmB,MAAO,IACzB;AACK,QAAA,mBAAmB,oBAAoB,mBAAmB;AAE1D,QAAA,cAAc,OAAO,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|
|
6
6
|
import { useAbortController } from "./hooks/useAbortController.js";
|
|
7
7
|
import { useAddClassNameDuringResize } from "./hooks/useAddClassNameDuringResize.js";
|
|
8
8
|
import { useArrayMapMemo } from "./hooks/useArrayMapMemo.js";
|
|
9
|
+
import { useAutoHeightTextArea } from "./hooks/useAutoHeightTextArea.js";
|
|
9
10
|
import { useComposeRef } from "./hooks/useComposeRef.js";
|
|
10
11
|
import { useConstantLengthInvariant } from "./hooks/useConstantLengthInvariant.js";
|
|
11
12
|
import { useConstantValueInvariant } from "./hooks/useConstantValueInvariant.js";
|
|
@@ -21,6 +22,8 @@ import { useForceRender } from "./hooks/useForceRender.js";
|
|
|
21
22
|
import { useId } from "./hooks/useId.js";
|
|
22
23
|
import { useIsMounted } from "./hooks/useIsMounted.js";
|
|
23
24
|
import { useObjectMemo } from "./hooks/useObjectMemo.js";
|
|
25
|
+
import { useOnElementClickOutsideCallback } from "./hooks/useOnElementClickOutsideCallback.js";
|
|
26
|
+
import { useOnElementMouseEnterDelayedCallback } from "./hooks/useOnElementMouseEnterDelayedCallback.js";
|
|
24
27
|
import { useOnElementMutation } from "./hooks/useOnElementMutation.js";
|
|
25
28
|
import { useOnElementResize } from "./hooks/useOnElementResize.js";
|
|
26
29
|
import { useOnWindowResize } from "./hooks/useOnWindowResize.js";
|
|
@@ -67,6 +70,7 @@ export {
|
|
|
67
70
|
useAbortController,
|
|
68
71
|
useAddClassNameDuringResize,
|
|
69
72
|
useArrayMapMemo,
|
|
73
|
+
useAutoHeightTextArea,
|
|
70
74
|
useClassName,
|
|
71
75
|
useClassNameFactory,
|
|
72
76
|
useColorScheme,
|
|
@@ -85,6 +89,8 @@ export {
|
|
|
85
89
|
useId,
|
|
86
90
|
useIsMounted,
|
|
87
91
|
useObjectMemo,
|
|
92
|
+
useOnElementClickOutsideCallback,
|
|
93
|
+
useOnElementMouseEnterDelayedCallback,
|
|
88
94
|
useOnElementMutation,
|
|
89
95
|
useOnElementResize,
|
|
90
96
|
useOnWindowResize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,6 +2,7 @@ export * from './unwrapRefValue';
|
|
|
2
2
|
export * from './useAbortController';
|
|
3
3
|
export * from './useAddClassNameDuringResize';
|
|
4
4
|
export * from './useArrayMapMemo';
|
|
5
|
+
export * from './useAutoHeightTextArea';
|
|
5
6
|
export * from './useComposeRef';
|
|
6
7
|
export * from './useConstantLengthInvariant';
|
|
7
8
|
export * from './useConstantValueInvariant';
|
|
@@ -17,6 +18,8 @@ export * from './useForceRender';
|
|
|
17
18
|
export * from './useId';
|
|
18
19
|
export * from './useIsMounted';
|
|
19
20
|
export * from './useObjectMemo';
|
|
21
|
+
export * from './useOnElementClickOutsideCallback';
|
|
22
|
+
export * from './useOnElementMouseEnterDelayedCallback';
|
|
20
23
|
export * from './useOnElementMutation';
|
|
21
24
|
export * from './useOnElementResize';
|
|
22
25
|
export * from './useOnWindowResize';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,+B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1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutoHeightTextArea.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAutoHeightTextArea.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,kBAAkB,CAAA;AAGrE,eAAO,MAAM,qBAAqB,gBACpB,mBAAmB,mBAAmB,CAAC,SAC7C,MAAM,WACJ,MAAM,WACN,MAAM,SAyCf,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnElementClickOutsideCallback.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOnElementClickOutsideCallback.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,kBAAkB,CAAA;AAErE,wBAAgB,gCAAgC,CAC/C,YAAY,EAAE,kBAAkB,CAAC,WAAW,CAAC,EAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GACnC,IAAI,CAgBN"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RefObjectOrElement } from './unwrapRefValue';
|
|
2
|
+
/**
|
|
3
|
+
* Calls the callback when the mouse enters the element, but only after a timeout, e.g. for tooltips or dropdown menus.
|
|
4
|
+
*
|
|
5
|
+
* Calls the callback immediately if the mouse is pressed down with `event.type` of `mousedown`. This is useful for
|
|
6
|
+
* dropdown menus, where the user may click on the menu item before the callback is called resulting in the menu
|
|
7
|
+
* opening and closing immediately.
|
|
8
|
+
*
|
|
9
|
+
* @param refOrElement - The element or ref to the element to attach the event listener to.
|
|
10
|
+
* @param callback - The callback to call when the mouse enters the element.
|
|
11
|
+
* @param timeoutMs - The timeout in milliseconds to wait before calling the callback.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useOnElementMouseEnterDelayedCallback(refOrElement: RefObjectOrElement<HTMLElement>, callback: (event: MouseEvent) => void, timeoutMs?: number): void;
|
|
14
|
+
//# sourceMappingURL=useOnElementMouseEnterDelayedCallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnElementMouseEnterDelayedCallback.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOnElementMouseEnterDelayedCallback.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,kBAAkB,CAAA;AAErE;;;;;;;;;;GAUG;AACH,wBAAgB,qCAAqC,CACpD,YAAY,EAAE,kBAAkB,CAAC,WAAW,CAAC,EAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,EACrC,SAAS,GAAE,MAAY,GACrB,IAAI,CAmCN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnElementResize.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOnElementResize.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,kBAAkB,CAAA;AAErE,wBAAgB,kBAAkB,CACjC,YAAY,EAAE,kBAAkB,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,EAC3D,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,EAChD,OAAO,GAAE,qBAA0B,EACnC,OAAO,GAAE,MAAY,GACnB,IAAI,
|
|
1
|
+
{"version":3,"file":"useOnElementResize.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOnElementResize.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,kBAAkB,CAAA;AAErE,wBAAgB,kBAAkB,CACjC,YAAY,EAAE,kBAAkB,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,EAC3D,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,EAChD,OAAO,GAAE,qBAA0B,EACnC,OAAO,GAAE,MAAY,GACnB,IAAI,CA6CN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnScrollWithin.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOnScrollWithin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,kBAAkB,CAAA;AAErE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,kBAAkB,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,EAC3D,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAChC,QAAQ,GAAE,MAAkB,
|
|
1
|
+
{"version":3,"file":"useOnScrollWithin.d.ts","sourceRoot":"","sources":["../../../src/hooks/useOnScrollWithin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,kBAAkB,CAAA;AAErE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,EAAE,kBAAkB,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,EAC3D,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAChC,QAAQ,GAAE,MAAkB,QAqD5B"}
|