@contember/react-utils 1.2.6 → 1.3.0-alpha.2
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/context/createNonNullableContextFactory.cjs +17 -0
- package/dist/development/context/createNonNullableContextFactory.cjs.map +1 -0
- package/dist/development/context/createOptionalContextFactory.cjs +13 -0
- package/dist/development/context/createOptionalContextFactory.cjs.map +1 -0
- package/dist/development/debug-context/Constants.cjs +25 -0
- package/dist/development/debug-context/Constants.cjs.map +1 -0
- package/dist/development/debug-context/Context.cjs +71 -0
- package/dist/development/debug-context/Context.cjs.map +1 -0
- package/dist/development/hooks/unwrapRefValue.cjs +11 -0
- package/dist/development/hooks/unwrapRefValue.cjs.map +1 -0
- package/dist/development/hooks/useAbortController.cjs +17 -0
- package/dist/development/hooks/useAbortController.cjs.map +1 -0
- package/dist/development/hooks/useAddClassNameDuringResize.cjs +32 -0
- package/dist/development/hooks/useAddClassNameDuringResize.cjs.map +1 -0
- package/dist/development/hooks/useArrayMapMemo.cjs +11 -0
- package/dist/development/hooks/useArrayMapMemo.cjs.map +1 -0
- package/dist/development/hooks/useAutoHeightTextArea.cjs +41 -0
- package/dist/development/hooks/useAutoHeightTextArea.cjs.map +1 -0
- package/dist/development/hooks/useChildrenAsLabel.cjs +53 -0
- package/dist/development/hooks/useChildrenAsLabel.cjs.map +1 -0
- package/dist/development/hooks/useComposeRef.cjs +31 -0
- package/dist/development/hooks/useComposeRef.cjs.map +1 -0
- package/dist/development/hooks/useConstantLengthInvariant.cjs +15 -0
- package/dist/development/hooks/useConstantLengthInvariant.cjs.map +1 -0
- package/dist/development/hooks/useConstantValueInvariant.cjs +15 -0
- package/dist/development/hooks/useConstantValueInvariant.cjs.map +1 -0
- package/dist/development/hooks/useContainerWidth.cjs +14 -0
- package/dist/development/hooks/useContainerWidth.cjs.map +1 -0
- package/dist/development/hooks/useDebounce.cjs +15 -0
- package/dist/development/hooks/useDebounce.cjs.map +1 -0
- package/dist/development/hooks/useDebounceCallback.cjs +19 -0
- package/dist/development/hooks/useDebounceCallback.cjs.map +1 -0
- package/dist/development/hooks/useDocumentTitle.cjs +22 -0
- package/dist/development/hooks/useDocumentTitle.cjs.map +1 -0
- package/dist/development/hooks/useElementSize.cjs +37 -0
- package/dist/development/hooks/useElementSize.cjs.map +1 -0
- package/dist/development/hooks/useElementTopOffset.cjs +29 -0
- package/dist/development/hooks/useElementTopOffset.cjs.map +1 -0
- package/dist/development/hooks/useEventHandler.cjs +19 -0
- package/dist/development/hooks/useEventHandler.cjs.map +1 -0
- package/dist/development/hooks/useExpectSameValueReference.cjs +24 -0
- package/dist/development/hooks/useExpectSameValueReference.cjs.map +1 -0
- package/dist/development/hooks/useForceRender.cjs +9 -0
- package/dist/development/hooks/useForceRender.cjs.map +1 -0
- package/dist/development/hooks/useId.cjs +13 -0
- package/dist/development/hooks/useId.cjs.map +1 -0
- package/dist/development/hooks/useIsMounted.cjs +18 -0
- package/dist/development/hooks/useIsMounted.cjs.map +1 -0
- package/dist/development/hooks/useObjectMemo.cjs +27 -0
- package/dist/development/hooks/useObjectMemo.cjs.map +1 -0
- package/dist/development/hooks/useOnElementClickOutsideCallback.cjs +20 -0
- package/dist/development/hooks/useOnElementClickOutsideCallback.cjs.map +1 -0
- package/dist/development/hooks/useOnElementMouseEnterDelayedCallback.cjs +33 -0
- package/dist/development/hooks/useOnElementMouseEnterDelayedCallback.cjs.map +1 -0
- package/dist/development/hooks/useOnElementMutation.cjs +35 -0
- package/dist/development/hooks/useOnElementMutation.cjs.map +1 -0
- package/dist/development/hooks/useOnElementResize.cjs +42 -0
- package/dist/development/hooks/useOnElementResize.cjs.map +1 -0
- package/dist/development/hooks/useOnScrollWithin.cjs +52 -0
- package/dist/development/hooks/useOnScrollWithin.cjs.map +1 -0
- package/dist/development/hooks/useOnWindowResize.cjs +36 -0
- package/dist/development/hooks/useOnWindowResize.cjs.map +1 -0
- package/dist/development/hooks/usePreviousValue.cjs +12 -0
- package/dist/development/hooks/usePreviousValue.cjs.map +1 -0
- package/dist/development/hooks/useScrollOffsets.cjs +67 -0
- package/dist/development/hooks/useScrollOffsets.cjs.map +1 -0
- package/dist/development/hooks/useStoredState.cjs +23 -0
- package/dist/development/hooks/useStoredState.cjs.map +1 -0
- package/dist/development/hooks/useUpdatedRef.cjs +10 -0
- package/dist/development/hooks/useUpdatedRef.cjs.map +1 -0
- package/dist/development/hooks/useWindowSize.cjs +20 -0
- package/dist/development/hooks/useWindowSize.cjs.map +1 -0
- package/dist/development/index.cjs +112 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/referentiallyStable/emptyArray.cjs +5 -0
- package/dist/development/referentiallyStable/emptyArray.cjs.map +1 -0
- package/dist/development/referentiallyStable/emptyObject.cjs +5 -0
- package/dist/development/referentiallyStable/emptyObject.cjs.map +1 -0
- package/dist/development/referentiallyStable/identityFunction.cjs +5 -0
- package/dist/development/referentiallyStable/identityFunction.cjs.map +1 -0
- package/dist/development/referentiallyStable/noop.cjs +5 -0
- package/dist/development/referentiallyStable/noop.cjs.map +1 -0
- package/dist/development/referentiallyStable/returnFalse.cjs +5 -0
- package/dist/development/referentiallyStable/returnFalse.cjs.map +1 -0
- package/dist/development/referentiallyStable/returnTrue.cjs +5 -0
- package/dist/development/referentiallyStable/returnTrue.cjs.map +1 -0
- package/dist/development/referentiallyStable/useReferentiallyStableCallback.cjs +12 -0
- package/dist/development/referentiallyStable/useReferentiallyStableCallback.cjs.map +1 -0
- package/dist/development/theming/ColorSchemeProvider.cjs +18 -0
- package/dist/development/theming/ColorSchemeProvider.cjs.map +1 -0
- package/dist/development/theming/GlobalClassNamePrefixContext.cjs +6 -0
- package/dist/development/theming/GlobalClassNamePrefixContext.cjs.map +1 -0
- package/dist/development/theming/contexts.cjs +12 -0
- package/dist/development/theming/contexts.cjs.map +1 -0
- package/dist/development/theming/useClassName.cjs +17 -0
- package/dist/development/theming/useClassName.cjs.map +1 -0
- package/dist/development/theming/useClassNameFactory.cjs +22 -0
- package/dist/development/theming/useClassNameFactory.cjs.map +1 -0
- package/dist/development/theming/useThemedClassName.cjs +17 -0
- package/dist/development/theming/useThemedClassName.cjs.map +1 -0
- package/dist/development/theming/useThemedClassNameFactory.cjs +29 -0
- package/dist/development/theming/useThemedClassNameFactory.cjs.map +1 -0
- package/dist/production/context/createNonNullableContextFactory.cjs +17 -0
- package/dist/production/context/createNonNullableContextFactory.cjs.map +1 -0
- package/dist/production/context/createOptionalContextFactory.cjs +13 -0
- package/dist/production/context/createOptionalContextFactory.cjs.map +1 -0
- package/dist/production/debug-context/Constants.cjs +25 -0
- package/dist/production/debug-context/Constants.cjs.map +1 -0
- package/dist/production/debug-context/Context.cjs +67 -0
- package/dist/production/debug-context/Context.cjs.map +1 -0
- package/dist/production/hooks/unwrapRefValue.cjs +11 -0
- package/dist/production/hooks/unwrapRefValue.cjs.map +1 -0
- package/dist/production/hooks/useAbortController.cjs +17 -0
- package/dist/production/hooks/useAbortController.cjs.map +1 -0
- package/dist/production/hooks/useAddClassNameDuringResize.cjs +32 -0
- package/dist/production/hooks/useAddClassNameDuringResize.cjs.map +1 -0
- package/dist/production/hooks/useArrayMapMemo.cjs +9 -0
- package/dist/production/hooks/useArrayMapMemo.cjs.map +1 -0
- package/dist/production/hooks/useAutoHeightTextArea.cjs +41 -0
- package/dist/production/hooks/useAutoHeightTextArea.cjs.map +1 -0
- package/dist/production/hooks/useChildrenAsLabel.cjs +52 -0
- package/dist/production/hooks/useChildrenAsLabel.cjs.map +1 -0
- package/dist/production/hooks/useComposeRef.cjs +31 -0
- package/dist/production/hooks/useComposeRef.cjs.map +1 -0
- package/dist/production/hooks/useConstantLengthInvariant.cjs +6 -0
- package/dist/production/hooks/useConstantLengthInvariant.cjs.map +1 -0
- package/dist/production/hooks/useConstantValueInvariant.cjs +6 -0
- package/dist/production/hooks/useConstantValueInvariant.cjs.map +1 -0
- package/dist/production/hooks/useContainerWidth.cjs +14 -0
- package/dist/production/hooks/useContainerWidth.cjs.map +1 -0
- package/dist/production/hooks/useDebounce.cjs +15 -0
- package/dist/production/hooks/useDebounce.cjs.map +1 -0
- package/dist/production/hooks/useDebounceCallback.cjs +19 -0
- package/dist/production/hooks/useDebounceCallback.cjs.map +1 -0
- package/dist/production/hooks/useDocumentTitle.cjs +22 -0
- package/dist/production/hooks/useDocumentTitle.cjs.map +1 -0
- package/dist/production/hooks/useElementSize.cjs +37 -0
- package/dist/production/hooks/useElementSize.cjs.map +1 -0
- package/dist/production/hooks/useElementTopOffset.cjs +29 -0
- package/dist/production/hooks/useElementTopOffset.cjs.map +1 -0
- package/dist/production/hooks/useEventHandler.cjs +19 -0
- package/dist/production/hooks/useEventHandler.cjs.map +1 -0
- package/dist/production/hooks/useExpectSameValueReference.cjs +15 -0
- package/dist/production/hooks/useExpectSameValueReference.cjs.map +1 -0
- package/dist/production/hooks/useForceRender.cjs +9 -0
- package/dist/production/hooks/useForceRender.cjs.map +1 -0
- package/dist/production/hooks/useId.cjs +13 -0
- package/dist/production/hooks/useId.cjs.map +1 -0
- package/dist/production/hooks/useIsMounted.cjs +18 -0
- package/dist/production/hooks/useIsMounted.cjs.map +1 -0
- package/dist/production/hooks/useObjectMemo.cjs +27 -0
- package/dist/production/hooks/useObjectMemo.cjs.map +1 -0
- package/dist/production/hooks/useOnElementClickOutsideCallback.cjs +20 -0
- package/dist/production/hooks/useOnElementClickOutsideCallback.cjs.map +1 -0
- package/dist/production/hooks/useOnElementMouseEnterDelayedCallback.cjs +33 -0
- package/dist/production/hooks/useOnElementMouseEnterDelayedCallback.cjs.map +1 -0
- package/dist/production/hooks/useOnElementMutation.cjs +35 -0
- package/dist/production/hooks/useOnElementMutation.cjs.map +1 -0
- package/dist/production/hooks/useOnElementResize.cjs +42 -0
- package/dist/production/hooks/useOnElementResize.cjs.map +1 -0
- package/dist/production/hooks/useOnScrollWithin.cjs +52 -0
- package/dist/production/hooks/useOnScrollWithin.cjs.map +1 -0
- package/dist/production/hooks/useOnWindowResize.cjs +36 -0
- package/dist/production/hooks/useOnWindowResize.cjs.map +1 -0
- package/dist/production/hooks/usePreviousValue.cjs +12 -0
- package/dist/production/hooks/usePreviousValue.cjs.map +1 -0
- package/dist/production/hooks/useScrollOffsets.cjs +67 -0
- package/dist/production/hooks/useScrollOffsets.cjs.map +1 -0
- package/dist/production/hooks/useStoredState.cjs +23 -0
- package/dist/production/hooks/useStoredState.cjs.map +1 -0
- package/dist/production/hooks/useUpdatedRef.cjs +10 -0
- package/dist/production/hooks/useUpdatedRef.cjs.map +1 -0
- package/dist/production/hooks/useWindowSize.cjs +20 -0
- package/dist/production/hooks/useWindowSize.cjs.map +1 -0
- package/dist/production/index.cjs +112 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/referentiallyStable/emptyArray.cjs +5 -0
- package/dist/production/referentiallyStable/emptyArray.cjs.map +1 -0
- package/dist/production/referentiallyStable/emptyObject.cjs +5 -0
- package/dist/production/referentiallyStable/emptyObject.cjs.map +1 -0
- package/dist/production/referentiallyStable/identityFunction.cjs +5 -0
- package/dist/production/referentiallyStable/identityFunction.cjs.map +1 -0
- package/dist/production/referentiallyStable/noop.cjs +5 -0
- package/dist/production/referentiallyStable/noop.cjs.map +1 -0
- package/dist/production/referentiallyStable/returnFalse.cjs +5 -0
- package/dist/production/referentiallyStable/returnFalse.cjs.map +1 -0
- package/dist/production/referentiallyStable/returnTrue.cjs +5 -0
- package/dist/production/referentiallyStable/returnTrue.cjs.map +1 -0
- package/dist/production/referentiallyStable/useReferentiallyStableCallback.cjs +12 -0
- package/dist/production/referentiallyStable/useReferentiallyStableCallback.cjs.map +1 -0
- package/dist/production/theming/ColorSchemeProvider.cjs +14 -0
- package/dist/production/theming/ColorSchemeProvider.cjs.map +1 -0
- package/dist/production/theming/GlobalClassNamePrefixContext.cjs +6 -0
- package/dist/production/theming/GlobalClassNamePrefixContext.cjs.map +1 -0
- package/dist/production/theming/contexts.cjs +12 -0
- package/dist/production/theming/contexts.cjs.map +1 -0
- package/dist/production/theming/useClassName.cjs +17 -0
- package/dist/production/theming/useClassName.cjs.map +1 -0
- package/dist/production/theming/useClassNameFactory.cjs +22 -0
- package/dist/production/theming/useClassNameFactory.cjs.map +1 -0
- package/dist/production/theming/useThemedClassName.cjs +17 -0
- package/dist/production/theming/useThemedClassName.cjs.map +1 -0
- package/dist/production/theming/useThemedClassNameFactory.cjs +29 -0
- package/dist/production/theming/useThemedClassNameFactory.cjs.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnElementMouseEnterDelayedCallback.cjs","sources":["../../../src/hooks/useOnElementMouseEnterDelayedCallback.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\n\n/**\n * Calls the callback when the mouse enters the element, but only after a timeout, e.g. for tooltips or dropdown menus.\n *\n * Calls the callback immediately if the mouse is pressed down with `event.type` of `mousedown`. This is useful for\n * dropdown menus, where the user may click on the menu item before the callback is called resulting in the menu\n * opening and closing immediately.\n *\n * @param refOrElement - The element or ref to the element to attach the event listener to.\n * @param callback - The callback to call when the mouse enters the element.\n * @param timeoutMs - The timeout in milliseconds to wait before calling the callback.\n */\nexport function useOnElementMouseEnterDelayedCallback(\n\trefOrElement: RefObjectOrElement<HTMLElement>,\n\tcallback: (event: MouseEvent) => void,\n\ttimeoutMs: number = 300,\n): void {\n\tuseEffect(() => {\n\t\tconst refValue = unwrapRefValue(refOrElement)\n\n\t\tif (refValue) {\n\t\t\tlet timeoutID: ReturnType<typeof setTimeout> | undefined = undefined\n\n\t\t\tfunction handleMouseEnter(event: MouseEvent) {\n\t\t\t\tclearTimeout(timeoutID)\n\n\t\t\t\ttimeoutID = setTimeout(() => {\n\t\t\t\t\tcallback(event)\n\t\t\t\t}, timeoutMs)\n\t\t\t}\n\n\t\t\tfunction handleMouseLeave() {\n\t\t\t\tclearTimeout(timeoutID)\n\t\t\t}\n\n\t\t\tfunction handleMouseDown(event: MouseEvent) {\n\t\t\t\tclearTimeout(timeoutID)\n\t\t\t\tcallback(event)\n\t\t\t}\n\n\t\t\trefValue.addEventListener('mouseenter', handleMouseEnter)\n\t\t\trefValue.addEventListener('mouseleave', handleMouseLeave)\n\t\t\trefValue.addEventListener('mousedown', handleMouseDown)\n\n\t\t\treturn () => {\n\t\t\t\trefValue.removeEventListener('mouseover', handleMouseEnter)\n\t\t\t\trefValue.removeEventListener('mouseleave', handleMouseLeave)\n\t\t\t\trefValue.removeEventListener('mousedown', handleMouseDown)\n\t\t\t}\n\t\t}\n\t}, [callback, refOrElement, timeoutMs])\n}\n"],"names":["useEffect","unwrapRefValue"],"mappings":";;;;AAcO,SAAS,sCACf,cACA,UACA,YAAoB,KACb;AACPA,QAAAA,UAAU,MAAM;AACT,UAAA,WAAWC,8BAAe,YAAY;AAE5C,QAAI,UAAU;AAGJ,UAAA,mBAAT,SAA0B,OAAmB;AAC5C,qBAAa,SAAS;AAEtB,oBAAY,WAAW,MAAM;AAC5B,mBAAS,KAAK;AAAA,WACZ,SAAS;AAAA,MACb,GAES,mBAAT,WAA4B;AAC3B,qBAAa,SAAS;AAAA,MAAA,GAGd,kBAAT,SAAyB,OAAmB;AAC3C,qBAAa,SAAS;AACtB,iBAAS,KAAK;AAAA,MAAA;AAhBf,UAAI,YAAuD;AAmBlD,eAAA,iBAAiB,cAAc,gBAAgB;AAC/C,eAAA,iBAAiB,cAAc,gBAAgB;AAC/C,eAAA,iBAAiB,aAAa,eAAe;AAEtD,aAAO,MAAM;AACH,iBAAA,oBAAoB,aAAa,gBAAgB;AACjD,iBAAA,oBAAoB,cAAc,gBAAgB;AAClD,iBAAA,oBAAoB,aAAa,eAAe;AAAA,MAAA;AAAA,IAE3D;AAAA,EACE,GAAA,CAAC,UAAU,cAAc,SAAS,CAAC;AACvC;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const deepEqual = require("fast-deep-equal/es6/index.js");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const unwrapRefValue = require("./unwrapRefValue.cjs");
|
|
6
|
+
const Context = require("../debug-context/Context.cjs");
|
|
7
|
+
function useOnElementMutation(refOrElement, callback, options = { attributes: true, childList: true, subtree: true }) {
|
|
8
|
+
const scopedConsoleRef = Context.useScopedConsoleRef("useOnElementMutation");
|
|
9
|
+
const callbackRef = react.useRef(callback);
|
|
10
|
+
callbackRef.current = callback;
|
|
11
|
+
const optionsRef = react.useRef(options);
|
|
12
|
+
optionsRef.current = options;
|
|
13
|
+
const [optionsState, setOptionsState] = react.useState(options);
|
|
14
|
+
react.useEffect(() => {
|
|
15
|
+
if (!deepEqual(optionsRef.current, options)) {
|
|
16
|
+
setOptionsState(options);
|
|
17
|
+
}
|
|
18
|
+
}, [options]);
|
|
19
|
+
react.useLayoutEffect(() => {
|
|
20
|
+
const element = unwrapRefValue.unwrapRefValue(refOrElement);
|
|
21
|
+
if (element) {
|
|
22
|
+
let handler = function(mutations, observer2) {
|
|
23
|
+
scopedConsoleRef.current.logged("element.mutations", mutations);
|
|
24
|
+
callbackRef.current(mutations, observer2);
|
|
25
|
+
};
|
|
26
|
+
const observer = new MutationObserver(handler);
|
|
27
|
+
observer.observe(element, optionsState);
|
|
28
|
+
return () => {
|
|
29
|
+
observer.disconnect();
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}, [optionsState, refOrElement, scopedConsoleRef]);
|
|
33
|
+
}
|
|
34
|
+
exports.useOnElementMutation = useOnElementMutation;
|
|
35
|
+
//# sourceMappingURL=useOnElementMutation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnElementMutation.cjs","sources":["../../../src/hooks/useOnElementMutation.ts"],"sourcesContent":["import deepEqual from 'fast-deep-equal/es6/index.js'\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\n\nexport function useOnElementMutation(\n\trefOrElement: RefObjectOrElement<HTMLElement | undefined>,\n\tcallback: MutationCallback,\n\toptions: MutationObserverInit = { attributes: true, childList: true, subtree: true },\n) {\n\tconst scopedConsoleRef = useScopedConsoleRef('useOnElementMutation')\n\n\tconst callbackRef = useRef(callback); callbackRef.current = callback\n\tconst optionsRef = useRef<MutationObserverInit>(options); optionsRef.current = options\n\n\tconst [optionsState, setOptionsState] = useState<MutationObserverInit>(options)\n\n\tuseEffect(() => {\n\t\tif (!deepEqual(optionsRef.current, options)) {\n\t\t\tsetOptionsState(options)\n\t\t}\n\t}, [options])\n\n\tuseLayoutEffect(() => {\n\t\tconst element = unwrapRefValue(refOrElement)\n\n\t\tif (element) {\n\t\t\tfunction handler(mutations: MutationRecord[], observer: MutationObserver) {\n\t\t\t\tscopedConsoleRef.current.logged('element.mutations', mutations)\n\t\t\t\tcallbackRef.current(mutations, observer)\n\t\t\t}\n\n\t\t\tconst observer = new MutationObserver(handler)\n\n\t\t\tobserver.observe(element, optionsState)\n\n\t\t\treturn () => {\n\t\t\t\tobserver.disconnect()\n\t\t\t}\n\t\t}\n\t}, [optionsState, refOrElement, scopedConsoleRef])\n}\n"],"names":["useScopedConsoleRef","useRef","useState","useEffect","useLayoutEffect","unwrapRefValue","observer"],"mappings":";;;;;;AAKgB,SAAA,qBACf,cACA,UACA,UAAgC,EAAE,YAAY,MAAM,WAAW,MAAM,SAAS,KAAA,GAC7E;AACK,QAAA,mBAAmBA,4BAAoB,sBAAsB;AAE7D,QAAA,cAAcC,aAAO,QAAQ;AAAG,cAAY,UAAU;AACtD,QAAA,aAAaA,aAA6B,OAAO;AAAG,aAAW,UAAU;AAE/E,QAAM,CAAC,cAAc,eAAe,IAAIC,eAA+B,OAAO;AAE9EC,QAAAA,UAAU,MAAM;AACf,QAAI,CAAC,UAAU,WAAW,SAAS,OAAO,GAAG;AAC5C,sBAAgB,OAAO;AAAA,IACxB;AAAA,EAAA,GACE,CAAC,OAAO,CAAC;AAEZC,QAAAA,gBAAgB,MAAM;AACf,UAAA,UAAUC,8BAAe,YAAY;AAE3C,QAAI,SAAS;AACH,UAAA,UAAT,SAAiB,WAA6BC,WAA4B;AACxD,yBAAA,QAAQ,OAAO,qBAAqB,SAAS;AAClD,oBAAA,QAAQ,WAAWA,SAAQ;AAAA,MAAA;AAGlC,YAAA,WAAW,IAAI,iBAAiB,OAAO;AAEpC,eAAA,QAAQ,SAAS,YAAY;AAEtC,aAAO,MAAM;AACZ,iBAAS,WAAW;AAAA,MAAA;AAAA,IAEtB;AAAA,EACE,GAAA,CAAC,cAAc,cAAc,gBAAgB,CAAC;AAClD;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const unwrapRefValue = require("./unwrapRefValue.cjs");
|
|
5
|
+
const Context = require("../debug-context/Context.cjs");
|
|
6
|
+
function useOnElementResize(refOrElement, callback, options = {}, timeout = 300) {
|
|
7
|
+
const scopedConsoleRef = Context.useScopedConsoleRef("useOnElementResize");
|
|
8
|
+
const { box = "border-box" } = options;
|
|
9
|
+
const callbackRef = react.useRef(callback);
|
|
10
|
+
callbackRef.current = callback;
|
|
11
|
+
const lastTimeStamp = react.useRef(0);
|
|
12
|
+
react.useLayoutEffect(() => {
|
|
13
|
+
const element = unwrapRefValue.unwrapRefValue(refOrElement);
|
|
14
|
+
if (!element) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!(element instanceof HTMLElement)) {
|
|
18
|
+
throw new Error("Exhaustive error: Expecting element to be instance of HTMLElement");
|
|
19
|
+
}
|
|
20
|
+
let timeoutID = void 0;
|
|
21
|
+
function debouncedOnChange([entry]) {
|
|
22
|
+
const timeStamp = Date.now();
|
|
23
|
+
const delta = timeStamp - lastTimeStamp.current;
|
|
24
|
+
clearTimeout(timeoutID);
|
|
25
|
+
const timeoutFinal = delta > timeout ? 0 : timeout;
|
|
26
|
+
timeoutID = setTimeout(() => {
|
|
27
|
+
const message = timeoutFinal > 0 ? "element.resize:debounced" : "element.resize:immediate";
|
|
28
|
+
scopedConsoleRef.current.warned(message, null);
|
|
29
|
+
callbackRef.current(entry);
|
|
30
|
+
lastTimeStamp.current = timeStamp;
|
|
31
|
+
}, timeoutFinal);
|
|
32
|
+
}
|
|
33
|
+
const resizeObserver = new ResizeObserver(debouncedOnChange);
|
|
34
|
+
resizeObserver.observe(element, { box });
|
|
35
|
+
return () => {
|
|
36
|
+
clearTimeout(timeoutID);
|
|
37
|
+
resizeObserver.unobserve(element);
|
|
38
|
+
};
|
|
39
|
+
}, [box, refOrElement, scopedConsoleRef, timeout]);
|
|
40
|
+
}
|
|
41
|
+
exports.useOnElementResize = useOnElementResize;
|
|
42
|
+
//# sourceMappingURL=useOnElementResize.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnElementResize.cjs","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\t\tif (!element) {\n\t\t\treturn\n\t\t}\n\t\tif (!(element instanceof HTMLElement)) {\n\t\t\tthrow new Error('Exhaustive error: Expecting element to be instance of HTMLElement')\n\t\t}\n\n\t\tlet timeoutID: number | undefined = undefined\n\n\t\tfunction debouncedOnChange([entry]: ResizeObserverEntry[]) {\n\t\t\tconst timeStamp = Date.now()\n\t\t\tconst delta = timeStamp - lastTimeStamp.current\n\n\t\t\tclearTimeout(timeoutID)\n\t\t\tconst timeoutFinal = delta > timeout ? 0 : timeout\n\n\t\t\ttimeoutID = setTimeout(() => {\n\t\t\t\tconst message = timeoutFinal > 0 ? 'element.resize:debounced' : 'element.resize:immediate'\n\t\t\t\tscopedConsoleRef.current.warned(message, null)\n\t\t\t\tcallbackRef.current(entry)\n\t\t\t\tlastTimeStamp.current = timeStamp\n\t\t\t}, timeoutFinal)\n\t\t}\n\n\t\tconst resizeObserver = new ResizeObserver(debouncedOnChange)\n\n\t\tresizeObserver.observe(element, { box })\n\n\t\treturn () => {\n\t\t\tclearTimeout(timeoutID)\n\t\t\tresizeObserver.unobserve(element)\n\t\t}\n\t}, [box, refOrElement, scopedConsoleRef, timeout])\n}\n"],"names":["useScopedConsoleRef","useRef","useLayoutEffect","unwrapRefValue"],"mappings":";;;;;AAIO,SAAS,mBACf,cACA,UACA,UAAiC,CAAC,GAClC,UAAkB,KACX;AACD,QAAA,mBAAmBA,4BAAoB,oBAAoB;AAE3D,QAAA,EAAE,MAAM,aAAiB,IAAA;AACzB,QAAA,cAAcC,aAAO,QAAQ;AAAG,cAAY,UAAU;AACtD,QAAA,gBAAgBA,aAAe,CAAC;AAEtCC,QAAAA,gBAAgB,MAAM;AACf,UAAA,UAAUC,8BAAe,YAAY;AAC3C,QAAI,CAAC,SAAS;AACb;AAAA,IACD;AACI,QAAA,EAAE,mBAAmB,cAAc;AAChC,YAAA,IAAI,MAAM,mEAAmE;AAAA,IACpF;AAEA,QAAI,YAAgC;AAE3B,aAAA,kBAAkB,CAAC,KAAK,GAA0B;AACpD,YAAA,YAAY,KAAK;AACjB,YAAA,QAAQ,YAAY,cAAc;AAExC,mBAAa,SAAS;AAChB,YAAA,eAAe,QAAQ,UAAU,IAAI;AAE3C,kBAAY,WAAW,MAAM;AACtB,cAAA,UAAU,eAAe,IAAI,6BAA6B;AAC/C,yBAAA,QAAQ,OAAO,SAAS,IAAI;AAC7C,oBAAY,QAAQ,KAAK;AACzB,sBAAc,UAAU;AAAA,SACtB,YAAY;AAAA,IAChB;AAEM,UAAA,iBAAiB,IAAI,eAAe,iBAAiB;AAE3D,mBAAe,QAAQ,SAAS,EAAE,IAAK,CAAA;AAEvC,WAAO,MAAM;AACZ,mBAAa,SAAS;AACtB,qBAAe,UAAU,OAAO;AAAA,IAAA;AAAA,KAE/B,CAAC,KAAK,cAAc,kBAAkB,OAAO,CAAC;AAClD;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const unwrapRefValue = require("./unwrapRefValue.cjs");
|
|
5
|
+
const Context = require("../debug-context/Context.cjs");
|
|
6
|
+
function useOnScrollWithin(refOrElement, callback, interval = 1e3 / 60) {
|
|
7
|
+
const scopedConsoleRef = Context.useScopedConsoleRef("useOnScrollWithin");
|
|
8
|
+
const callbackRef = react.useRef(callback);
|
|
9
|
+
callbackRef.current = callback;
|
|
10
|
+
const lastTimeStamp = react.useRef(0);
|
|
11
|
+
react.useLayoutEffect(() => {
|
|
12
|
+
const element = unwrapRefValue.unwrapRefValue(refOrElement);
|
|
13
|
+
let timeoutID = void 0;
|
|
14
|
+
if (element) {
|
|
15
|
+
let debouncedHandler = function(event) {
|
|
16
|
+
clearTimeout(timeoutID);
|
|
17
|
+
const delta = event.timeStamp - lastTimeStamp.current;
|
|
18
|
+
scopedConsoleRef.current.logged("event:element.scroll:delta", delta);
|
|
19
|
+
if (delta > interval) {
|
|
20
|
+
scopedConsoleRef.current.warned("event:element.scroll:immediately", event);
|
|
21
|
+
callbackRef.current(event);
|
|
22
|
+
lastTimeStamp.current = event.timeStamp;
|
|
23
|
+
} else {
|
|
24
|
+
timeoutID = setTimeout(() => {
|
|
25
|
+
scopedConsoleRef.current.warned("event:element.scroll:debounced", event);
|
|
26
|
+
lastTimeStamp.current = event.timeStamp;
|
|
27
|
+
callbackRef.current(event);
|
|
28
|
+
}, interval);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (element instanceof HTMLElement) {
|
|
32
|
+
if (element instanceof HTMLBodyElement || element instanceof HTMLHtmlElement) {
|
|
33
|
+
window.addEventListener("scroll", debouncedHandler, { capture: true, passive: true });
|
|
34
|
+
window.addEventListener("resize", debouncedHandler);
|
|
35
|
+
return () => {
|
|
36
|
+
window.removeEventListener("scroll", debouncedHandler);
|
|
37
|
+
window.removeEventListener("resize", debouncedHandler);
|
|
38
|
+
};
|
|
39
|
+
} else {
|
|
40
|
+
element.addEventListener("scroll", debouncedHandler, { passive: true, capture: true });
|
|
41
|
+
return () => {
|
|
42
|
+
element.removeEventListener("scroll", debouncedHandler);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
throw new Error("Exhaustive error: Expecting element to be instance of HTMLElement");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, [interval, refOrElement, scopedConsoleRef]);
|
|
50
|
+
}
|
|
51
|
+
exports.useOnScrollWithin = useOnScrollWithin;
|
|
52
|
+
//# sourceMappingURL=useOnScrollWithin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnScrollWithin.cjs","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} 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}, [interval, refOrElement, scopedConsoleRef])\n}\n"],"names":["useScopedConsoleRef","useRef","useLayoutEffect","unwrapRefValue"],"mappings":";;;;;AAWO,SAAS,kBACf,cACA,UACA,WAAmB,MAAO,IACzB;AACK,QAAA,mBAAmBA,4BAAoB,mBAAmB;AAE1D,QAAA,cAAcC,aAAO,QAAQ;AAAG,cAAY,UAAU;AACtD,QAAA,gBAAgBA,aAAe,CAAC;AAEtCC,QAAAA,gBAAgB,MAAM;AACf,UAAA,UAAUC,8BAAe,YAAY;AAE3C,QAAI,YAAgC;AAEpC,QAAI,SAAS;AACH,UAAA,mBAAT,SAA0B,OAAc;AACvC,qBAAa,SAAS;AAEhB,cAAA,QAAQ,MAAM,YAAY,cAAc;AAC7B,yBAAA,QAAQ,OAAO,8BAA8B,KAAK;AAEnE,YAAI,QAAQ,UAAU;AACJ,2BAAA,QAAQ,OAAO,oCAAoC,KAAK;AACzE,sBAAY,QAAQ,KAAK;AACzB,wBAAc,UAAU,MAAM;AAAA,QAAA,OACxB;AACN,sBAAY,WAAW,MAAM;AACX,6BAAA,QAAQ,OAAO,kCAAkC,KAAK;AACvE,0BAAc,UAAU,MAAM;AAC9B,wBAAY,QAAQ,KAAK;AAAA,aACvB,QAAQ;AAAA,QACZ;AAAA,MAAA;AAGD,UAAI,mBAAmB,aAAa;AAC/B,YAAA,mBAAmB,mBAAmB,mBAAmB,iBAAiB;AACtE,iBAAA,iBAAiB,UAAU,kBAAkB,EAAE,SAAS,MAAM,SAAS,MAAM;AAC7E,iBAAA,iBAAiB,UAAU,gBAAgB;AAElD,iBAAO,MAAM;AACL,mBAAA,oBAAoB,UAAU,gBAAgB;AAC9C,mBAAA,oBAAoB,UAAU,gBAAgB;AAAA,UAAA;AAAA,QACtD,OACM;AACE,kBAAA,iBAAiB,UAAU,kBAAkB,EAAE,SAAS,MAAM,SAAS,MAAM;AAErF,iBAAO,MAAM;AACJ,oBAAA,oBAAoB,UAAU,gBAAgB;AAAA,UAAA;AAAA,QAExD;AAAA,MAAA,OACM;AACA,cAAA,IAAI,MAAM,mEAAmE;AAAA,MACpF;AAAA,IACD;AAAA,EACE,GAAA,CAAC,UAAU,cAAc,gBAAgB,CAAC;AAC9C;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const Context = require("../debug-context/Context.cjs");
|
|
5
|
+
function useOnWindowResize(callback, interval = 300) {
|
|
6
|
+
const scopedConsoleRef = Context.useScopedConsoleRef("useOnWindowResize");
|
|
7
|
+
const callbackRef = react.useRef(callback);
|
|
8
|
+
callbackRef.current = callback;
|
|
9
|
+
const lastTimeStamp = react.useRef(0);
|
|
10
|
+
react.useLayoutEffect(() => {
|
|
11
|
+
let timeoutID = void 0;
|
|
12
|
+
function debouncedHandler(event) {
|
|
13
|
+
clearTimeout(timeoutID);
|
|
14
|
+
const delta = event.timeStamp - lastTimeStamp.current;
|
|
15
|
+
scopedConsoleRef.current.logged("window.resize:delta", delta);
|
|
16
|
+
if (delta > interval) {
|
|
17
|
+
scopedConsoleRef.current.warned("event:window.resize:immediately", null);
|
|
18
|
+
callbackRef.current(event);
|
|
19
|
+
lastTimeStamp.current = event.timeStamp;
|
|
20
|
+
} else {
|
|
21
|
+
timeoutID = setTimeout(() => {
|
|
22
|
+
scopedConsoleRef.current.warned("event:window.resize:debounced", null);
|
|
23
|
+
lastTimeStamp.current = event.timeStamp;
|
|
24
|
+
callbackRef.current(event);
|
|
25
|
+
}, interval);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
window.addEventListener("resize", debouncedHandler);
|
|
29
|
+
return () => {
|
|
30
|
+
clearTimeout(timeoutID);
|
|
31
|
+
window.removeEventListener("resize", debouncedHandler);
|
|
32
|
+
};
|
|
33
|
+
}, [callbackRef, interval, scopedConsoleRef]);
|
|
34
|
+
}
|
|
35
|
+
exports.useOnWindowResize = useOnWindowResize;
|
|
36
|
+
//# sourceMappingURL=useOnWindowResize.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnWindowResize.cjs","sources":["../../../src/hooks/useOnWindowResize.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\n\nexport function useOnWindowResize(\n\tcallback: (event: Event) => void,\n\tinterval: number = 300,\n) {\n\tconst scopedConsoleRef = useScopedConsoleRef('useOnWindowResize')\n\n\tconst callbackRef = useRef(callback); callbackRef.current = callback\n\tconst lastTimeStamp = useRef<number>(0)\n\n\tuseLayoutEffect(() => {\n\t\tlet timeoutID: number | undefined = undefined\n\n\t\tfunction debouncedHandler(event: Event) {\n\t\t\tclearTimeout(timeoutID)\n\n\t\t\tconst delta = event.timeStamp - lastTimeStamp.current\n\t\t\tscopedConsoleRef.current.logged('window.resize:delta', delta)\n\n\t\t\tif (delta > interval) {\n\t\t\t\tscopedConsoleRef.current.warned('event:window.resize:immediately', null)\n\t\t\t\tcallbackRef.current(event)\n\t\t\t\tlastTimeStamp.current = event.timeStamp\n\t\t\t} else {\n\t\t\t\ttimeoutID = setTimeout(() => {\n\t\t\t\t\tscopedConsoleRef.current.warned('event:window.resize:debounced', null)\n\t\t\t\t\tlastTimeStamp.current = event.timeStamp\n\t\t\t\t\tcallbackRef.current(event)\n\t\t\t\t}, interval)\n\t\t\t}\n\t\t}\n\n\t\twindow.addEventListener('resize', debouncedHandler)\n\n\t\treturn () => {\n\t\t\tclearTimeout(timeoutID)\n\t\t\twindow.removeEventListener('resize', debouncedHandler)\n\t\t}\n\t}, [callbackRef, interval, scopedConsoleRef])\n}\n"],"names":["useScopedConsoleRef","useRef","useLayoutEffect"],"mappings":";;;;AAGgB,SAAA,kBACf,UACA,WAAmB,KAClB;AACK,QAAA,mBAAmBA,4BAAoB,mBAAmB;AAE1D,QAAA,cAAcC,aAAO,QAAQ;AAAG,cAAY,UAAU;AACtD,QAAA,gBAAgBA,aAAe,CAAC;AAEtCC,QAAAA,gBAAgB,MAAM;AACrB,QAAI,YAAgC;AAEpC,aAAS,iBAAiB,OAAc;AACvC,mBAAa,SAAS;AAEhB,YAAA,QAAQ,MAAM,YAAY,cAAc;AAC7B,uBAAA,QAAQ,OAAO,uBAAuB,KAAK;AAE5D,UAAI,QAAQ,UAAU;AACJ,yBAAA,QAAQ,OAAO,mCAAmC,IAAI;AACvE,oBAAY,QAAQ,KAAK;AACzB,sBAAc,UAAU,MAAM;AAAA,MAAA,OACxB;AACN,oBAAY,WAAW,MAAM;AACX,2BAAA,QAAQ,OAAO,iCAAiC,IAAI;AACrE,wBAAc,UAAU,MAAM;AAC9B,sBAAY,QAAQ,KAAK;AAAA,WACvB,QAAQ;AAAA,MACZ;AAAA,IACD;AAEO,WAAA,iBAAiB,UAAU,gBAAgB;AAElD,WAAO,MAAM;AACZ,mBAAa,SAAS;AACf,aAAA,oBAAoB,UAAU,gBAAgB;AAAA,IAAA;AAAA,EAEpD,GAAA,CAAC,aAAa,UAAU,gBAAgB,CAAC;AAC7C;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const usePreviousValue = (value) => {
|
|
5
|
+
const ref = react.useRef(value);
|
|
6
|
+
react.useEffect(() => {
|
|
7
|
+
ref.current = value;
|
|
8
|
+
});
|
|
9
|
+
return ref.current;
|
|
10
|
+
};
|
|
11
|
+
exports.usePreviousValue = usePreviousValue;
|
|
12
|
+
//# sourceMappingURL=usePreviousValue.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePreviousValue.cjs","sources":["../../../src/hooks/usePreviousValue.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nexport const usePreviousValue = <Value>(value: Value) => {\n\tconst ref = useRef<Value>(value)\n\tuseEffect(() => {\n\t\tref.current = value\n\t})\n\treturn ref.current\n}\n"],"names":["useRef","useEffect"],"mappings":";;;AAEa,MAAA,mBAAmB,CAAQ,UAAiB;AAClD,QAAA,MAAMA,aAAc,KAAK;AAC/BC,QAAAA,UAAU,MAAM;AACf,QAAI,UAAU;AAAA,EAAA,CACd;AACD,SAAO,IAAI;AACZ;;"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const utilities = require("@contember/utilities");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const unwrapRefValue = require("./unwrapRefValue.cjs");
|
|
6
|
+
const useOnScrollWithin = require("./useOnScrollWithin.cjs");
|
|
7
|
+
const useOnWindowResize = require("./useOnWindowResize.cjs");
|
|
8
|
+
const Context = require("../debug-context/Context.cjs");
|
|
9
|
+
const useReferentiallyStableCallback = require("../referentiallyStable/useReferentiallyStableCallback.cjs");
|
|
10
|
+
function useScrollOffsets(refOrElement, interval = 1e3 / 60) {
|
|
11
|
+
const { logged } = Context.useScopedConsoleRef("useScrollOffsets").current;
|
|
12
|
+
const [top, setTop] = react.useState(0);
|
|
13
|
+
const [bottom, setBottom] = react.useState(0);
|
|
14
|
+
const [left, setLeft] = react.useState(0);
|
|
15
|
+
const [right, setRight] = react.useState(0);
|
|
16
|
+
const updateScrollOffsetsState = useReferentiallyStableCallback.useReferentiallyStableCallback((offsets) => {
|
|
17
|
+
logged("Update the offsets:", {
|
|
18
|
+
previous: { bottom, left, right, top },
|
|
19
|
+
next: offsets
|
|
20
|
+
});
|
|
21
|
+
if (offsets.bottom !== bottom)
|
|
22
|
+
setBottom(offsets.bottom);
|
|
23
|
+
if (offsets.left !== left)
|
|
24
|
+
setLeft(offsets.left);
|
|
25
|
+
if (offsets.right !== right)
|
|
26
|
+
setRight(offsets.right);
|
|
27
|
+
if (offsets.top !== top)
|
|
28
|
+
setTop(offsets.top);
|
|
29
|
+
});
|
|
30
|
+
const handler = useReferentiallyStableCallback.useReferentiallyStableCallback(() => {
|
|
31
|
+
const maybeScrollContent = unwrapRefValue.unwrapRefValue(refOrElement) ?? document;
|
|
32
|
+
if (maybeScrollContent) {
|
|
33
|
+
getElementScrollOffsets(maybeScrollContent).then(updateScrollOffsetsState);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
useOnScrollWithin.useOnScrollWithin(refOrElement, handler, interval);
|
|
37
|
+
useOnWindowResize.useOnWindowResize(handler);
|
|
38
|
+
react.useLayoutEffect(handler, [handler]);
|
|
39
|
+
return react.useMemo(() => ({ bottom, left, right, top }), [bottom, left, right, top]);
|
|
40
|
+
}
|
|
41
|
+
function isIntrinsicScrollElement(element) {
|
|
42
|
+
return element instanceof HTMLBodyElement || element instanceof HTMLHtmlElement || element instanceof DocumentType || element instanceof Document || element instanceof HTMLDocument;
|
|
43
|
+
}
|
|
44
|
+
function getIntrinsicScrollContainer(element) {
|
|
45
|
+
const html = document.body.parentElement;
|
|
46
|
+
utilities.assert("HTML element exists", html, (value) => value instanceof HTMLElement);
|
|
47
|
+
if (isIntrinsicScrollElement(element)) {
|
|
48
|
+
return html;
|
|
49
|
+
} else {
|
|
50
|
+
return element;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function getElementScrollOffsets(element) {
|
|
54
|
+
const isIntrinsicScrolling = isIntrinsicScrollElement(element);
|
|
55
|
+
const scrollContainer = getIntrinsicScrollContainer(element);
|
|
56
|
+
const { scrollLeft, scrollTop, scrollHeight, scrollWidth } = scrollContainer;
|
|
57
|
+
const { height: scrollContainerHeight, width: scrollContainerWidth } = await utilities.getElementDimensions(scrollContainer);
|
|
58
|
+
const height = isIntrinsicScrolling ? window.innerHeight : scrollContainerHeight;
|
|
59
|
+
const width = isIntrinsicScrolling ? window.innerWidth : scrollContainerWidth;
|
|
60
|
+
const left = Math.round(scrollLeft);
|
|
61
|
+
const top = Math.round(scrollTop);
|
|
62
|
+
const right = Math.round(scrollWidth - width - left);
|
|
63
|
+
const bottom = Math.round(scrollHeight - height - top);
|
|
64
|
+
return { bottom, left, right, top };
|
|
65
|
+
}
|
|
66
|
+
exports.useScrollOffsets = useScrollOffsets;
|
|
67
|
+
//# sourceMappingURL=useScrollOffsets.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollOffsets.cjs","sources":["../../../src/hooks/useScrollOffsets.ts"],"sourcesContent":["import { assert, getElementDimensions } from '@contember/utilities'\nimport { useLayoutEffect, useMemo, useState } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\nimport { useReferentiallyStableCallback } from '../referentiallyStable'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\nimport { useOnScrollWithin } from './useOnScrollWithin'\nimport { useOnWindowResize } from './useOnWindowResize'\n\nexport type Offsets = {\n\tbottom: number;\n\tleft: number;\n\tright: number;\n\ttop: number;\n}\n\nexport function useScrollOffsets(refOrElement: RefObjectOrElement<HTMLElement | null> | null, interval: number = 1000 / 60) {\n\tconst { logged } = useScopedConsoleRef('useScrollOffsets').current\n\n\tconst [top, setTop] = useState(0)\n\tconst [bottom, setBottom] = useState(0)\n\tconst [left, setLeft] = useState(0)\n\tconst [right, setRight] = useState(0)\n\n\tconst updateScrollOffsetsState = useReferentiallyStableCallback((offsets: Offsets) => {\n\t\tlogged('Update the offsets:', {\n\t\t\tprevious: { bottom, left, right, top },\n\t\t\tnext: offsets,\n\t\t})\n\n\t\tif (offsets.bottom !== bottom) setBottom(offsets.bottom)\n\t\tif (offsets.left !== left) setLeft(offsets.left)\n\t\tif (offsets.right !== right) setRight(offsets.right)\n\t\tif (offsets.top !== top) setTop(offsets.top)\n\t})\n\n\tconst handler = useReferentiallyStableCallback(() => {\n\t\tconst maybeScrollContent = unwrapRefValue(refOrElement) ?? document\n\n\t\tif (maybeScrollContent) {\n\t\t\tgetElementScrollOffsets(maybeScrollContent).then(updateScrollOffsetsState)\n\t\t}\n\t})\n\n\tuseOnScrollWithin(refOrElement, handler, interval)\n\tuseOnWindowResize(handler)\n\tuseLayoutEffect(handler, [handler])\n\n\treturn useMemo(() => ({ bottom, left, right, top }), [bottom, left, right, top])\n}\n\nfunction isIntrinsicScrollElement(element: unknown): element is Document {\n\treturn element instanceof HTMLBodyElement\n\t\t|| element instanceof HTMLHtmlElement\n\t\t|| element instanceof DocumentType\n\t\t|| element instanceof Document\n\t\t|| element instanceof HTMLDocument\n}\n\nfunction getIntrinsicScrollContainer(element: HTMLElement | Document): HTMLElement {\n\tconst html = document.body.parentElement\n\tassert('HTML element exists', html, (value): value is HTMLElement => value instanceof HTMLElement)\n\n\tif (isIntrinsicScrollElement(element)) {\n\t\treturn html\n\t} else {\n\t\treturn element\n\t}\n}\n\nasync function getElementScrollOffsets(element: HTMLElement | Document): Promise<Offsets> {\n\tconst isIntrinsicScrolling = isIntrinsicScrollElement(element)\n\tconst scrollContainer = getIntrinsicScrollContainer(element)\n\n\tconst { scrollLeft, scrollTop, scrollHeight, scrollWidth } = scrollContainer\n\tconst { height: scrollContainerHeight, width: scrollContainerWidth } = await getElementDimensions(scrollContainer)\n\n\tconst height = isIntrinsicScrolling ? window.innerHeight : scrollContainerHeight\n\tconst width = isIntrinsicScrolling ? window.innerWidth : scrollContainerWidth\n\n\tconst left = Math.round(scrollLeft)\n\tconst top = Math.round(scrollTop)\n\n\tconst right = Math.round(scrollWidth - width - left)\n\tconst bottom = Math.round(scrollHeight - height - top)\n\n\treturn { bottom, left, right, top }\n}\n"],"names":["useScopedConsoleRef","useState","useReferentiallyStableCallback","unwrapRefValue","useOnScrollWithin","useOnWindowResize","useLayoutEffect","useMemo","assert","getElementDimensions"],"mappings":";;;;;;;;;AAeO,SAAS,iBAAiB,cAA6D,WAAmB,MAAO,IAAI;AAC3H,QAAM,EAAE,OAAW,IAAAA,QAAA,oBAAoB,kBAAkB,EAAE;AAE3D,QAAM,CAAC,KAAK,MAAM,IAAIC,eAAS,CAAC;AAChC,QAAM,CAAC,QAAQ,SAAS,IAAIA,eAAS,CAAC;AACtC,QAAM,CAAC,MAAM,OAAO,IAAIA,eAAS,CAAC;AAClC,QAAM,CAAC,OAAO,QAAQ,IAAIA,eAAS,CAAC;AAE9B,QAAA,2BAA2BC,8DAA+B,CAAC,YAAqB;AACrF,WAAO,uBAAuB;AAAA,MAC7B,UAAU,EAAE,QAAQ,MAAM,OAAO,IAAI;AAAA,MACrC,MAAM;AAAA,IAAA,CACN;AAED,QAAI,QAAQ,WAAW;AAAQ,gBAAU,QAAQ,MAAM;AACvD,QAAI,QAAQ,SAAS;AAAM,cAAQ,QAAQ,IAAI;AAC/C,QAAI,QAAQ,UAAU;AAAO,eAAS,QAAQ,KAAK;AACnD,QAAI,QAAQ,QAAQ;AAAK,aAAO,QAAQ,GAAG;AAAA,EAAA,CAC3C;AAEK,QAAA,UAAUA,+BAAAA,+BAA+B,MAAM;AAC9C,UAAA,qBAAqBC,eAAAA,eAAe,YAAY,KAAK;AAE3D,QAAI,oBAAoB;AACC,8BAAA,kBAAkB,EAAE,KAAK,wBAAwB;AAAA,IAC1E;AAAA,EAAA,CACA;AAEiBC,oBAAAA,kBAAA,cAAc,SAAS,QAAQ;AACjDC,oBAAA,kBAAkB,OAAO;AACTC,QAAAA,gBAAA,SAAS,CAAC,OAAO,CAAC;AAElC,SAAOC,MAAQ,QAAA,OAAO,EAAE,QAAQ,MAAM,OAAO,QAAQ,CAAC,QAAQ,MAAM,OAAO,GAAG,CAAC;AAChF;AAEA,SAAS,yBAAyB,SAAuC;AACjE,SAAA,mBAAmB,mBACtB,mBAAmB,mBACnB,mBAAmB,gBACnB,mBAAmB,YACnB,mBAAmB;AACxB;AAEA,SAAS,4BAA4B,SAA8C;AAC5E,QAAA,OAAO,SAAS,KAAK;AAC3BC,YAAA,OAAO,uBAAuB,MAAM,CAAC,UAAgC,iBAAiB,WAAW;AAE7F,MAAA,yBAAyB,OAAO,GAAG;AAC/B,WAAA;AAAA,EAAA,OACD;AACC,WAAA;AAAA,EACR;AACD;AAEA,eAAe,wBAAwB,SAAmD;AACnF,QAAA,uBAAuB,yBAAyB,OAAO;AACvD,QAAA,kBAAkB,4BAA4B,OAAO;AAE3D,QAAM,EAAE,YAAY,WAAW,cAAc,gBAAgB;AACvD,QAAA,EAAE,QAAQ,uBAAuB,OAAO,yBAAyB,MAAMC,UAAAA,qBAAqB,eAAe;AAE3G,QAAA,SAAS,uBAAuB,OAAO,cAAc;AACrD,QAAA,QAAQ,uBAAuB,OAAO,aAAa;AAEnD,QAAA,OAAO,KAAK,MAAM,UAAU;AAC5B,QAAA,MAAM,KAAK,MAAM,SAAS;AAEhC,QAAM,QAAQ,KAAK,MAAM,cAAc,QAAQ,IAAI;AACnD,QAAM,SAAS,KAAK,MAAM,eAAe,SAAS,GAAG;AAErD,SAAO,EAAE,QAAQ,MAAM,OAAO,IAAI;AACnC;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const createStoredStateHook = (getStorage) => {
|
|
5
|
+
return (key, initializeValue) => {
|
|
6
|
+
const storage = getStorage();
|
|
7
|
+
const [value, setValue] = react.useState(() => {
|
|
8
|
+
const value2 = storage.getItem(key);
|
|
9
|
+
const parsedValue = value2 !== null ? JSON.parse(value2) : void 0;
|
|
10
|
+
return initializeValue(parsedValue);
|
|
11
|
+
});
|
|
12
|
+
return [value, react.useCallback((value2) => {
|
|
13
|
+
setValue((current) => {
|
|
14
|
+
const newValue = typeof value2 === "function" ? value2(current) : value2;
|
|
15
|
+
storage.setItem(key, JSON.stringify(newValue));
|
|
16
|
+
return newValue;
|
|
17
|
+
});
|
|
18
|
+
}, [key, storage])];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const useSessionStorageState = createStoredStateHook(() => sessionStorage);
|
|
22
|
+
exports.useSessionStorageState = useSessionStorageState;
|
|
23
|
+
//# sourceMappingURL=useStoredState.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStoredState.cjs","sources":["../../../src/hooks/useStoredState.ts"],"sourcesContent":["import { useCallback, useState } from 'react'\nimport { Serializable } from '../types'\n\nexport type SetState<V extends Serializable> = (value: V | ((current: V) => V)) => void;\nexport type ValueInitializer<V extends Serializable> = (storedValue: V | undefined) => V;\n\nconst createStoredStateHook = (getStorage: () => Storage) => {\n\treturn <V extends Serializable>(key: string, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\t\tconst storage = getStorage()\n\t\tconst [value, setValue] = useState<V>(() => {\n\t\t\tconst value = storage.getItem(key)\n\t\t\tconst parsedValue: V | undefined = value !== null ? JSON.parse(value) : undefined\n\t\t\treturn initializeValue(parsedValue)\n\t\t})\n\t\treturn [value, useCallback(value => {\n\t\t\tsetValue(current => {\n\t\t\t\tconst newValue = typeof value === 'function' ? (value as (current: V) => V)(current) : value\n\t\t\t\tstorage.setItem(key, JSON.stringify(newValue))\n\t\t\t\treturn newValue\n\t\t\t})\n\t\t}, [key, storage])]\n\t}\n\n}\n\nexport const useSessionStorageState = createStoredStateHook(() => sessionStorage)\n"],"names":["useState","value","useCallback"],"mappings":";;;AAMA,MAAM,wBAAwB,CAAC,eAA8B;AACrD,SAAA,CAAyB,KAAa,oBAA2D;AACvG,UAAM,UAAU;AAChB,UAAM,CAAC,OAAO,QAAQ,IAAIA,eAAY,MAAM;AACrCC,YAAAA,SAAQ,QAAQ,QAAQ,GAAG;AACjC,YAAM,cAA6BA,WAAU,OAAO,KAAK,MAAMA,MAAK,IAAI;AACxE,aAAO,gBAAgB,WAAW;AAAA,IAAA,CAClC;AACD,WAAO,CAAC,OAAOC,kBAAY,CAAAD,WAAS;AACnC,eAAS,CAAW,YAAA;AACnB,cAAM,WAAW,OAAOA,WAAU,aAAcA,OAA4B,OAAO,IAAIA;AACvF,gBAAQ,QAAQ,KAAK,KAAK,UAAU,QAAQ,CAAC;AACtC,eAAA;AAAA,MAAA,CACP;AAAA,IACC,GAAA,CAAC,KAAK,OAAO,CAAC,CAAC;AAAA,EAAA;AAGpB;AAEa,MAAA,yBAAyB,sBAAsB,MAAM,cAAc;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
function useUpdatedRef(value) {
|
|
5
|
+
const ref = react.useRef(value);
|
|
6
|
+
ref.current = value;
|
|
7
|
+
return ref;
|
|
8
|
+
}
|
|
9
|
+
exports.useUpdatedRef = useUpdatedRef;
|
|
10
|
+
//# sourceMappingURL=useUpdatedRef.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUpdatedRef.cjs","sources":["../../../src/hooks/useUpdatedRef.ts"],"sourcesContent":["import { useRef } from 'react'\n\n/**\n * Returns a stable mutable object with value that is updated upon each call\n *\n * @param value - Value that could update after initial call\n * @returns Mutable ref object with updated value\n */\nexport function useUpdatedRef<T>(value: T) {\n\tconst ref = useRef(value)\n\tref.current = value\n\n\treturn ref\n}\n"],"names":["useRef"],"mappings":";;;AAQO,SAAS,cAAiB,OAAU;AACpC,QAAA,MAAMA,aAAO,KAAK;AACxB,MAAI,UAAU;AAEP,SAAA;AACR;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const useOnWindowResize = require("./useOnWindowResize.cjs");
|
|
5
|
+
function useWindowSize() {
|
|
6
|
+
const [width, setWidth] = react.useState(window.innerWidth);
|
|
7
|
+
const [height, setHeight] = react.useState(window.innerHeight);
|
|
8
|
+
useOnWindowResize.useOnWindowResize(() => {
|
|
9
|
+
const { innerHeight, innerWidth } = window;
|
|
10
|
+
if (innerHeight !== height) {
|
|
11
|
+
setHeight(innerHeight);
|
|
12
|
+
}
|
|
13
|
+
if (innerWidth !== width) {
|
|
14
|
+
setWidth(innerWidth);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return react.useMemo(() => ({ height, width }), [height, width]);
|
|
18
|
+
}
|
|
19
|
+
exports.useWindowSize = useWindowSize;
|
|
20
|
+
//# sourceMappingURL=useWindowSize.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWindowSize.cjs","sources":["../../../src/hooks/useWindowSize.ts"],"sourcesContent":["import { useMemo, useState } from 'react'\nimport { useOnWindowResize } from './useOnWindowResize'\n\nexport function useWindowSize() {\n const [width, setWidth] = useState(window.innerWidth)\n const [height, setHeight] = useState(window.innerHeight)\n\n useOnWindowResize(() => {\n const { innerHeight, innerWidth } = window\n if (innerHeight !== height) {\n setHeight(innerHeight)\n }\n\n if (innerWidth !== width) {\n setWidth(innerWidth)\n }\n })\n\n return useMemo(() => ({ height, width }), [height, width])\n}\n"],"names":["useState","useOnWindowResize","useMemo"],"mappings":";;;;AAGO,SAAS,gBAAgB;AAC9B,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAS,OAAO,UAAU;AACpD,QAAM,CAAC,QAAQ,SAAS,IAAIA,MAAAA,SAAS,OAAO,WAAW;AAEvDC,oBAAAA,kBAAkB,MAAM;AAChB,UAAA,EAAE,aAAa,WAAe,IAAA;AACpC,QAAI,gBAAgB,QAAQ;AAC1B,gBAAU,WAAW;AAAA,IACvB;AAEA,QAAI,eAAe,OAAO;AACxB,eAAS,UAAU;AAAA,IACrB;AAAA,EAAA,CACD;AAEM,SAAAC,MAAA,QAAQ,OAAO,EAAE,QAAQ,MAAU,IAAA,CAAC,QAAQ,KAAK,CAAC;AAC3D;;"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const createNonNullableContextFactory = require("./context/createNonNullableContextFactory.cjs");
|
|
4
|
+
const createOptionalContextFactory = require("./context/createOptionalContextFactory.cjs");
|
|
5
|
+
const Constants = require("./debug-context/Constants.cjs");
|
|
6
|
+
const Context = require("./debug-context/Context.cjs");
|
|
7
|
+
const unwrapRefValue = require("./hooks/unwrapRefValue.cjs");
|
|
8
|
+
const useAbortController = require("./hooks/useAbortController.cjs");
|
|
9
|
+
const useAddClassNameDuringResize = require("./hooks/useAddClassNameDuringResize.cjs");
|
|
10
|
+
const useArrayMapMemo = require("./hooks/useArrayMapMemo.cjs");
|
|
11
|
+
const useAutoHeightTextArea = require("./hooks/useAutoHeightTextArea.cjs");
|
|
12
|
+
const useChildrenAsLabel = require("./hooks/useChildrenAsLabel.cjs");
|
|
13
|
+
const useComposeRef = require("./hooks/useComposeRef.cjs");
|
|
14
|
+
const useConstantLengthInvariant = require("./hooks/useConstantLengthInvariant.cjs");
|
|
15
|
+
const useConstantValueInvariant = require("./hooks/useConstantValueInvariant.cjs");
|
|
16
|
+
const useContainerWidth = require("./hooks/useContainerWidth.cjs");
|
|
17
|
+
const useDebounce = require("./hooks/useDebounce.cjs");
|
|
18
|
+
const useDebounceCallback = require("./hooks/useDebounceCallback.cjs");
|
|
19
|
+
const useDocumentTitle = require("./hooks/useDocumentTitle.cjs");
|
|
20
|
+
const useElementSize = require("./hooks/useElementSize.cjs");
|
|
21
|
+
const useElementTopOffset = require("./hooks/useElementTopOffset.cjs");
|
|
22
|
+
const useEventHandler = require("./hooks/useEventHandler.cjs");
|
|
23
|
+
const useExpectSameValueReference = require("./hooks/useExpectSameValueReference.cjs");
|
|
24
|
+
const useForceRender = require("./hooks/useForceRender.cjs");
|
|
25
|
+
const useId = require("./hooks/useId.cjs");
|
|
26
|
+
const useIsMounted = require("./hooks/useIsMounted.cjs");
|
|
27
|
+
const useObjectMemo = require("./hooks/useObjectMemo.cjs");
|
|
28
|
+
const useOnElementClickOutsideCallback = require("./hooks/useOnElementClickOutsideCallback.cjs");
|
|
29
|
+
const useOnElementMouseEnterDelayedCallback = require("./hooks/useOnElementMouseEnterDelayedCallback.cjs");
|
|
30
|
+
const useOnElementMutation = require("./hooks/useOnElementMutation.cjs");
|
|
31
|
+
const useOnElementResize = require("./hooks/useOnElementResize.cjs");
|
|
32
|
+
const useOnScrollWithin = require("./hooks/useOnScrollWithin.cjs");
|
|
33
|
+
const useOnWindowResize = require("./hooks/useOnWindowResize.cjs");
|
|
34
|
+
const usePreviousValue = require("./hooks/usePreviousValue.cjs");
|
|
35
|
+
const useScrollOffsets = require("./hooks/useScrollOffsets.cjs");
|
|
36
|
+
const useStoredState = require("./hooks/useStoredState.cjs");
|
|
37
|
+
const useUpdatedRef = require("./hooks/useUpdatedRef.cjs");
|
|
38
|
+
const useWindowSize = require("./hooks/useWindowSize.cjs");
|
|
39
|
+
const emptyArray = require("./referentiallyStable/emptyArray.cjs");
|
|
40
|
+
const emptyObject = require("./referentiallyStable/emptyObject.cjs");
|
|
41
|
+
const identityFunction = require("./referentiallyStable/identityFunction.cjs");
|
|
42
|
+
const noop = require("./referentiallyStable/noop.cjs");
|
|
43
|
+
const returnFalse = require("./referentiallyStable/returnFalse.cjs");
|
|
44
|
+
const returnTrue = require("./referentiallyStable/returnTrue.cjs");
|
|
45
|
+
const useReferentiallyStableCallback = require("./referentiallyStable/useReferentiallyStableCallback.cjs");
|
|
46
|
+
const ColorSchemeProvider = require("./theming/ColorSchemeProvider.cjs");
|
|
47
|
+
const GlobalClassNamePrefixContext = require("./theming/GlobalClassNamePrefixContext.cjs");
|
|
48
|
+
const contexts = require("./theming/contexts.cjs");
|
|
49
|
+
const useClassName = require("./theming/useClassName.cjs");
|
|
50
|
+
const useClassNameFactory = require("./theming/useClassNameFactory.cjs");
|
|
51
|
+
const useThemedClassName = require("./theming/useThemedClassName.cjs");
|
|
52
|
+
const useThemedClassNameFactory = require("./theming/useThemedClassNameFactory.cjs");
|
|
53
|
+
exports.createNonNullableContextFactory = createNonNullableContextFactory.createNonNullableContextFactory;
|
|
54
|
+
exports.createOptionalContextFactory = createOptionalContextFactory.createOptionalContextFactory;
|
|
55
|
+
exports.isNoopScopedConsole = Constants.isNoopScopedConsole;
|
|
56
|
+
exports.noopLog = Constants.noopLog;
|
|
57
|
+
exports.noopLogged = Constants.noopLogged;
|
|
58
|
+
exports.noopScopedConsole = Constants.noopScopedConsole;
|
|
59
|
+
exports.DebugChildren = Context.DebugChildren;
|
|
60
|
+
exports.ScopedConsoleContext = Context.ScopedConsoleContext;
|
|
61
|
+
exports.useScopedConsoleRef = Context.useScopedConsoleRef;
|
|
62
|
+
exports.unwrapRefValue = unwrapRefValue.unwrapRefValue;
|
|
63
|
+
exports.useAbortController = useAbortController.useAbortController;
|
|
64
|
+
exports.useAddClassNameDuringResize = useAddClassNameDuringResize.useAddClassNameDuringResize;
|
|
65
|
+
exports.useArrayMapMemo = useArrayMapMemo.useArrayMapMemo;
|
|
66
|
+
exports.useAutoHeightTextArea = useAutoHeightTextArea.useAutoHeightTextArea;
|
|
67
|
+
exports.getChildrenAsLabel = useChildrenAsLabel.getChildrenAsLabel;
|
|
68
|
+
exports.useChildrenAsLabel = useChildrenAsLabel.useChildrenAsLabel;
|
|
69
|
+
exports.useComposeRef = useComposeRef.useComposeRef;
|
|
70
|
+
exports.useConstantLengthInvariant = useConstantLengthInvariant.useConstantLengthInvariant;
|
|
71
|
+
exports.useConstantValueInvariant = useConstantValueInvariant.useConstantValueInvariant;
|
|
72
|
+
exports.ContainerWidthContext = useContainerWidth.ContainerWidthContext;
|
|
73
|
+
exports.useContainerWidth = useContainerWidth.useContainerWidth;
|
|
74
|
+
exports.useDebounce = useDebounce.useDebounce;
|
|
75
|
+
exports.useDebounceCallback = useDebounceCallback.useDebounceCallback;
|
|
76
|
+
exports.useDocumentTitle = useDocumentTitle.useDocumentTitle;
|
|
77
|
+
exports.useElementSize = useElementSize.useElementSize;
|
|
78
|
+
exports.useElementTopOffset = useElementTopOffset.useElementTopOffset;
|
|
79
|
+
exports.useEventHandler = useEventHandler.useEventHandler;
|
|
80
|
+
exports.useExpectSameValueReference = useExpectSameValueReference.useExpectSameValueReference;
|
|
81
|
+
exports.useForceRender = useForceRender.useForceRender;
|
|
82
|
+
exports.useId = useId.useId;
|
|
83
|
+
exports.useIsMounted = useIsMounted.useIsMounted;
|
|
84
|
+
exports.useObjectMemo = useObjectMemo.useObjectMemo;
|
|
85
|
+
exports.useOnElementClickOutsideCallback = useOnElementClickOutsideCallback.useOnElementClickOutsideCallback;
|
|
86
|
+
exports.useOnElementMouseEnterDelayedCallback = useOnElementMouseEnterDelayedCallback.useOnElementMouseEnterDelayedCallback;
|
|
87
|
+
exports.useOnElementMutation = useOnElementMutation.useOnElementMutation;
|
|
88
|
+
exports.useOnElementResize = useOnElementResize.useOnElementResize;
|
|
89
|
+
exports.useOnScrollWithin = useOnScrollWithin.useOnScrollWithin;
|
|
90
|
+
exports.useOnWindowResize = useOnWindowResize.useOnWindowResize;
|
|
91
|
+
exports.usePreviousValue = usePreviousValue.usePreviousValue;
|
|
92
|
+
exports.useScrollOffsets = useScrollOffsets.useScrollOffsets;
|
|
93
|
+
exports.useSessionStorageState = useStoredState.useSessionStorageState;
|
|
94
|
+
exports.useUpdatedRef = useUpdatedRef.useUpdatedRef;
|
|
95
|
+
exports.useWindowSize = useWindowSize.useWindowSize;
|
|
96
|
+
exports.emptyArray = emptyArray.emptyArray;
|
|
97
|
+
exports.emptyObject = emptyObject.emptyObject;
|
|
98
|
+
exports.identityFunction = identityFunction.identityFunction;
|
|
99
|
+
exports.noop = noop.noop;
|
|
100
|
+
exports.returnFalse = returnFalse.returnFalse;
|
|
101
|
+
exports.returnTrue = returnTrue.returnTrue;
|
|
102
|
+
exports.useReferentiallyStableCallback = useReferentiallyStableCallback.useReferentiallyStableCallback;
|
|
103
|
+
exports.ColorSchemeProvider = ColorSchemeProvider.ColorSchemeProvider;
|
|
104
|
+
exports.GlobalClassNamePrefixContext = GlobalClassNamePrefixContext.GlobalClassNamePrefixContext;
|
|
105
|
+
exports.ColorSchemeContext = contexts.ColorSchemeContext;
|
|
106
|
+
exports.DEFAULT_COLOR_SCHEME = contexts.DEFAULT_COLOR_SCHEME;
|
|
107
|
+
exports.useColorScheme = contexts.useColorScheme;
|
|
108
|
+
exports.useClassName = useClassName.useClassName;
|
|
109
|
+
exports.useClassNameFactory = useClassNameFactory.useClassNameFactory;
|
|
110
|
+
exports.useThemedClassName = useThemedClassName.useThemedClassName;
|
|
111
|
+
exports.useThemedClassNameFactory = useThemedClassNameFactory.useThemedClassNameFactory;
|
|
112
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emptyArray.cjs","sources":["../../../src/referentiallyStable/emptyArray.ts"],"sourcesContent":["export const emptyArray = Object.freeze<any>([]) as any[]\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa,OAAO,OAAY,CAAE,CAAA;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emptyObject.cjs","sources":["../../../src/referentiallyStable/emptyObject.ts"],"sourcesContent":["export const emptyObject = Object.freeze({})\n"],"names":[],"mappings":";;AAAO,MAAM,cAAc,OAAO,OAAO,CAAE,CAAA;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityFunction.cjs","sources":["../../../src/referentiallyStable/identityFunction.ts"],"sourcesContent":["export const identityFunction = <Value>(value: Value) => value\n"],"names":[],"mappings":";;AAAa,MAAA,mBAAmB,CAAQ,UAAiB;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.cjs","sources":["../../../src/referentiallyStable/noop.ts"],"sourcesContent":["export const noop = () => undefined\n"],"names":[],"mappings":";;AAAO,MAAM,OAAO,MAAM;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returnFalse.cjs","sources":["../../../src/referentiallyStable/returnFalse.ts"],"sourcesContent":["export const returnFalse = () => false\n"],"names":[],"mappings":";;AAAO,MAAM,cAAc,MAAM;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"returnTrue.cjs","sources":["../../../src/referentiallyStable/returnTrue.ts"],"sourcesContent":["export const returnTrue = () => true\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa,MAAM;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const useReferentiallyStableCallback = (callback) => {
|
|
5
|
+
const ref = react.useRef(callback);
|
|
6
|
+
ref.current = callback;
|
|
7
|
+
return react.useCallback((...args) => {
|
|
8
|
+
return ref.current(...args);
|
|
9
|
+
}, []);
|
|
10
|
+
};
|
|
11
|
+
exports.useReferentiallyStableCallback = useReferentiallyStableCallback;
|
|
12
|
+
//# sourceMappingURL=useReferentiallyStableCallback.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferentiallyStableCallback.cjs","sources":["../../../src/referentiallyStable/useReferentiallyStableCallback.ts"],"sourcesContent":["import { useCallback, useRef } from 'react'\n\n// TODO: Should be possible to remove when React.useEvent() lands\nexport const useReferentiallyStableCallback = <T extends (...args: any[]) => any>(callback: T): T => {\n\tconst ref = useRef(callback)\n\tref.current = callback\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\treturn useCallback<T>(((...args: any[]) => {\n\t\treturn ref.current(...args)\n\t}) as T, [])\n}\n"],"names":["useRef","useCallback"],"mappings":";;;AAGa,MAAA,iCAAiC,CAAoC,aAAmB;AAC9F,QAAA,MAAMA,aAAO,QAAQ;AAC3B,MAAI,UAAU;AAEP,SAAAC,MAAA,YAAgB,IAAI,SAAgB;AACnC,WAAA,IAAI,QAAQ,GAAG,IAAI;AAAA,EAC3B,GAAS,CAAE,CAAA;AACZ;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const contexts = require("./contexts.cjs");
|
|
6
|
+
const ColorSchemeProvider = react.memo(
|
|
7
|
+
({ children, scheme }) => {
|
|
8
|
+
const inheritedColorScheme = contexts.useColorScheme();
|
|
9
|
+
return /* @__PURE__ */ jsxRuntime.jsx(contexts.ColorSchemeContext.Provider, { value: scheme ?? inheritedColorScheme, children });
|
|
10
|
+
}
|
|
11
|
+
);
|
|
12
|
+
ColorSchemeProvider.displayName = "Interface.ColorSchemeProvider";
|
|
13
|
+
exports.ColorSchemeProvider = ColorSchemeProvider;
|
|
14
|
+
//# sourceMappingURL=ColorSchemeProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSchemeProvider.cjs","sources":["../../../src/theming/ColorSchemeProvider.tsx"],"sourcesContent":["import { KebabCase } from '@contember/utilities'\nimport { memo } from 'react'\nimport { ColorSchemeContext, useColorScheme } from './contexts'\n\nexport type ColorSchemeProviderProps<T extends KebabCase<string>> = {\n\tchildren: React.ReactNode\n\tscheme?: T\n}\n\nexport const ColorSchemeProvider = memo(\n\t<T extends KebabCase<string>>({ children, scheme }: ColorSchemeProviderProps<T>) => {\n\t\tconst inheritedColorScheme = useColorScheme()\n\n\t\treturn (\n\t\t\t<ColorSchemeContext.Provider value={scheme ?? inheritedColorScheme}>{children}</ColorSchemeContext.Provider>\n\t\t)\n\t},\n)\nColorSchemeProvider.displayName = 'Interface.ColorSchemeProvider'\n"],"names":["memo","useColorScheme","ColorSchemeContext"],"mappings":";;;;;AASO,MAAM,sBAAsBA,MAAA;AAAA,EAClC,CAA8B,EAAE,UAAU,aAA0C;AACnF,UAAM,uBAAuBC,SAAAA;AAE7B,0CACEC,SAAmB,mBAAA,UAAnB,EAA4B,OAAO,UAAU,sBAAuB,SAAS,CAAA;AAAA,EAEhF;AACD;AACA,oBAAoB,cAAc;;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const GlobalClassNamePrefixContext = react.createContext("cui-");
|
|
5
|
+
exports.GlobalClassNamePrefixContext = GlobalClassNamePrefixContext;
|
|
6
|
+
//# sourceMappingURL=GlobalClassNamePrefixContext.cjs.map
|