@contember/react-utils 1.2.7 → 1.3.0-alpha.11
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/createNonNullableContextFactory.js.map +1 -1
- 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 +72 -0
- package/dist/development/debug-context/Context.cjs.map +1 -0
- package/dist/development/debug-context/Context.js +4 -3
- package/dist/development/debug-context/Context.js.map +1 -1
- 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/useCloseOnClickOutside.cjs +25 -0
- package/dist/development/hooks/useCloseOnClickOutside.cjs.map +1 -0
- package/dist/development/hooks/useCloseOnClickOutside.js +25 -0
- package/dist/development/hooks/useCloseOnClickOutside.js.map +1 -0
- package/dist/development/hooks/useCloseOnEscape.cjs +20 -0
- package/dist/development/hooks/useCloseOnEscape.cjs.map +1 -0
- package/dist/development/hooks/useCloseOnEscape.js +20 -0
- package/dist/development/hooks/useCloseOnEscape.js.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/useConstantLengthInvariant.js.map +1 -1
- package/dist/development/hooks/useConstantValueInvariant.cjs +15 -0
- package/dist/development/hooks/useConstantValueInvariant.cjs.map +1 -0
- package/dist/development/hooks/useConstantValueInvariant.js.map +1 -1
- 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/useId.js.map +1 -1
- 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 +116 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +4 -0
- package/dist/development/index.js.map +1 -1
- 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 +16 -0
- package/dist/development/theming/ColorSchemeProvider.cjs.map +1 -0
- package/dist/development/theming/ColorSchemeProvider.js +8 -10
- package/dist/development/theming/ColorSchemeProvider.js.map +1 -1
- 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/useClassName.js.map +1 -1
- package/dist/development/theming/useClassNameFactory.cjs +22 -0
- package/dist/development/theming/useClassNameFactory.cjs.map +1 -0
- package/dist/development/theming/useClassNameFactory.js.map +1 -1
- 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/development/theming/useThemedClassNameFactory.js.map +1 -1
- package/dist/production/context/createNonNullableContextFactory.cjs +17 -0
- package/dist/production/context/createNonNullableContextFactory.cjs.map +1 -0
- package/dist/production/context/createNonNullableContextFactory.js.map +1 -1
- 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 +68 -0
- package/dist/production/debug-context/Context.cjs.map +1 -0
- package/dist/production/debug-context/Context.js +3 -2
- package/dist/production/debug-context/Context.js.map +1 -1
- 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/useChildrenAsLabel.js.map +1 -1
- package/dist/production/hooks/useCloseOnClickOutside.cjs +25 -0
- package/dist/production/hooks/useCloseOnClickOutside.cjs.map +1 -0
- package/dist/production/hooks/useCloseOnClickOutside.js +25 -0
- package/dist/production/hooks/useCloseOnClickOutside.js.map +1 -0
- package/dist/production/hooks/useCloseOnEscape.cjs +20 -0
- package/dist/production/hooks/useCloseOnEscape.cjs.map +1 -0
- package/dist/production/hooks/useCloseOnEscape.js +20 -0
- package/dist/production/hooks/useCloseOnEscape.js.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/useId.js.map +1 -1
- 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 +116 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +4 -0
- package/dist/production/index.js.map +1 -1
- 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 +12 -0
- package/dist/production/theming/ColorSchemeProvider.cjs.map +1 -0
- package/dist/production/theming/ColorSchemeProvider.js +4 -6
- package/dist/production/theming/ColorSchemeProvider.js.map +1 -1
- 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/useClassName.js.map +1 -1
- package/dist/production/theming/useClassNameFactory.cjs +22 -0
- package/dist/production/theming/useClassNameFactory.cjs.map +1 -0
- package/dist/production/theming/useClassNameFactory.js.map +1 -1
- 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/production/theming/useThemedClassNameFactory.js.map +1 -1
- package/dist/types/debug-context/Context.d.ts.map +1 -1
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/useCloseOnClickOutside.d.ts +7 -0
- package/dist/types/hooks/useCloseOnClickOutside.d.ts.map +1 -0
- package/dist/types/hooks/useCloseOnEscape.d.ts +5 -0
- package/dist/types/hooks/useCloseOnEscape.d.ts.map +1 -0
- package/dist/types/theming/ColorSchemeProvider.d.ts +3 -4
- package/dist/types/theming/ColorSchemeProvider.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -3
- package/src/debug-context/Context.tsx +3 -3
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useCloseOnClickOutside.ts +27 -0
- package/src/hooks/useCloseOnEscape.ts +18 -0
- package/src/theming/ColorSchemeProvider.tsx +8 -11
|
@@ -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,116 @@
|
|
|
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 useCloseOnClickOutside = require("./hooks/useCloseOnClickOutside.cjs");
|
|
14
|
+
const useCloseOnEscape = require("./hooks/useCloseOnEscape.cjs");
|
|
15
|
+
const useComposeRef = require("./hooks/useComposeRef.cjs");
|
|
16
|
+
const useConstantLengthInvariant = require("./hooks/useConstantLengthInvariant.cjs");
|
|
17
|
+
const useConstantValueInvariant = require("./hooks/useConstantValueInvariant.cjs");
|
|
18
|
+
const useContainerWidth = require("./hooks/useContainerWidth.cjs");
|
|
19
|
+
const useDebounce = require("./hooks/useDebounce.cjs");
|
|
20
|
+
const useDebounceCallback = require("./hooks/useDebounceCallback.cjs");
|
|
21
|
+
const useDocumentTitle = require("./hooks/useDocumentTitle.cjs");
|
|
22
|
+
const useElementSize = require("./hooks/useElementSize.cjs");
|
|
23
|
+
const useElementTopOffset = require("./hooks/useElementTopOffset.cjs");
|
|
24
|
+
const useEventHandler = require("./hooks/useEventHandler.cjs");
|
|
25
|
+
const useExpectSameValueReference = require("./hooks/useExpectSameValueReference.cjs");
|
|
26
|
+
const useForceRender = require("./hooks/useForceRender.cjs");
|
|
27
|
+
const useId = require("./hooks/useId.cjs");
|
|
28
|
+
const useIsMounted = require("./hooks/useIsMounted.cjs");
|
|
29
|
+
const useObjectMemo = require("./hooks/useObjectMemo.cjs");
|
|
30
|
+
const useOnElementClickOutsideCallback = require("./hooks/useOnElementClickOutsideCallback.cjs");
|
|
31
|
+
const useOnElementMouseEnterDelayedCallback = require("./hooks/useOnElementMouseEnterDelayedCallback.cjs");
|
|
32
|
+
const useOnElementMutation = require("./hooks/useOnElementMutation.cjs");
|
|
33
|
+
const useOnElementResize = require("./hooks/useOnElementResize.cjs");
|
|
34
|
+
const useOnScrollWithin = require("./hooks/useOnScrollWithin.cjs");
|
|
35
|
+
const useOnWindowResize = require("./hooks/useOnWindowResize.cjs");
|
|
36
|
+
const usePreviousValue = require("./hooks/usePreviousValue.cjs");
|
|
37
|
+
const useScrollOffsets = require("./hooks/useScrollOffsets.cjs");
|
|
38
|
+
const useStoredState = require("./hooks/useStoredState.cjs");
|
|
39
|
+
const useUpdatedRef = require("./hooks/useUpdatedRef.cjs");
|
|
40
|
+
const useWindowSize = require("./hooks/useWindowSize.cjs");
|
|
41
|
+
const emptyArray = require("./referentiallyStable/emptyArray.cjs");
|
|
42
|
+
const emptyObject = require("./referentiallyStable/emptyObject.cjs");
|
|
43
|
+
const identityFunction = require("./referentiallyStable/identityFunction.cjs");
|
|
44
|
+
const noop = require("./referentiallyStable/noop.cjs");
|
|
45
|
+
const returnFalse = require("./referentiallyStable/returnFalse.cjs");
|
|
46
|
+
const returnTrue = require("./referentiallyStable/returnTrue.cjs");
|
|
47
|
+
const useReferentiallyStableCallback = require("./referentiallyStable/useReferentiallyStableCallback.cjs");
|
|
48
|
+
const ColorSchemeProvider = require("./theming/ColorSchemeProvider.cjs");
|
|
49
|
+
const GlobalClassNamePrefixContext = require("./theming/GlobalClassNamePrefixContext.cjs");
|
|
50
|
+
const contexts = require("./theming/contexts.cjs");
|
|
51
|
+
const useClassName = require("./theming/useClassName.cjs");
|
|
52
|
+
const useClassNameFactory = require("./theming/useClassNameFactory.cjs");
|
|
53
|
+
const useThemedClassName = require("./theming/useThemedClassName.cjs");
|
|
54
|
+
const useThemedClassNameFactory = require("./theming/useThemedClassNameFactory.cjs");
|
|
55
|
+
exports.createNonNullableContextFactory = createNonNullableContextFactory.createNonNullableContextFactory;
|
|
56
|
+
exports.createOptionalContextFactory = createOptionalContextFactory.createOptionalContextFactory;
|
|
57
|
+
exports.isNoopScopedConsole = Constants.isNoopScopedConsole;
|
|
58
|
+
exports.noopLog = Constants.noopLog;
|
|
59
|
+
exports.noopLogged = Constants.noopLogged;
|
|
60
|
+
exports.noopScopedConsole = Constants.noopScopedConsole;
|
|
61
|
+
exports.DebugChildren = Context.DebugChildren;
|
|
62
|
+
exports.ScopedConsoleContext = Context.ScopedConsoleContext;
|
|
63
|
+
exports.useScopedConsoleRef = Context.useScopedConsoleRef;
|
|
64
|
+
exports.unwrapRefValue = unwrapRefValue.unwrapRefValue;
|
|
65
|
+
exports.useAbortController = useAbortController.useAbortController;
|
|
66
|
+
exports.useAddClassNameDuringResize = useAddClassNameDuringResize.useAddClassNameDuringResize;
|
|
67
|
+
exports.useArrayMapMemo = useArrayMapMemo.useArrayMapMemo;
|
|
68
|
+
exports.useAutoHeightTextArea = useAutoHeightTextArea.useAutoHeightTextArea;
|
|
69
|
+
exports.getChildrenAsLabel = useChildrenAsLabel.getChildrenAsLabel;
|
|
70
|
+
exports.useChildrenAsLabel = useChildrenAsLabel.useChildrenAsLabel;
|
|
71
|
+
exports.useCloseOnClickOutside = useCloseOnClickOutside.useCloseOnClickOutside;
|
|
72
|
+
exports.useCloseOnEscape = useCloseOnEscape.useCloseOnEscape;
|
|
73
|
+
exports.useComposeRef = useComposeRef.useComposeRef;
|
|
74
|
+
exports.useConstantLengthInvariant = useConstantLengthInvariant.useConstantLengthInvariant;
|
|
75
|
+
exports.useConstantValueInvariant = useConstantValueInvariant.useConstantValueInvariant;
|
|
76
|
+
exports.ContainerWidthContext = useContainerWidth.ContainerWidthContext;
|
|
77
|
+
exports.useContainerWidth = useContainerWidth.useContainerWidth;
|
|
78
|
+
exports.useDebounce = useDebounce.useDebounce;
|
|
79
|
+
exports.useDebounceCallback = useDebounceCallback.useDebounceCallback;
|
|
80
|
+
exports.useDocumentTitle = useDocumentTitle.useDocumentTitle;
|
|
81
|
+
exports.useElementSize = useElementSize.useElementSize;
|
|
82
|
+
exports.useElementTopOffset = useElementTopOffset.useElementTopOffset;
|
|
83
|
+
exports.useEventHandler = useEventHandler.useEventHandler;
|
|
84
|
+
exports.useExpectSameValueReference = useExpectSameValueReference.useExpectSameValueReference;
|
|
85
|
+
exports.useForceRender = useForceRender.useForceRender;
|
|
86
|
+
exports.useId = useId.useId;
|
|
87
|
+
exports.useIsMounted = useIsMounted.useIsMounted;
|
|
88
|
+
exports.useObjectMemo = useObjectMemo.useObjectMemo;
|
|
89
|
+
exports.useOnElementClickOutsideCallback = useOnElementClickOutsideCallback.useOnElementClickOutsideCallback;
|
|
90
|
+
exports.useOnElementMouseEnterDelayedCallback = useOnElementMouseEnterDelayedCallback.useOnElementMouseEnterDelayedCallback;
|
|
91
|
+
exports.useOnElementMutation = useOnElementMutation.useOnElementMutation;
|
|
92
|
+
exports.useOnElementResize = useOnElementResize.useOnElementResize;
|
|
93
|
+
exports.useOnScrollWithin = useOnScrollWithin.useOnScrollWithin;
|
|
94
|
+
exports.useOnWindowResize = useOnWindowResize.useOnWindowResize;
|
|
95
|
+
exports.usePreviousValue = usePreviousValue.usePreviousValue;
|
|
96
|
+
exports.useScrollOffsets = useScrollOffsets.useScrollOffsets;
|
|
97
|
+
exports.useSessionStorageState = useStoredState.useSessionStorageState;
|
|
98
|
+
exports.useUpdatedRef = useUpdatedRef.useUpdatedRef;
|
|
99
|
+
exports.useWindowSize = useWindowSize.useWindowSize;
|
|
100
|
+
exports.emptyArray = emptyArray.emptyArray;
|
|
101
|
+
exports.emptyObject = emptyObject.emptyObject;
|
|
102
|
+
exports.identityFunction = identityFunction.identityFunction;
|
|
103
|
+
exports.noop = noop.noop;
|
|
104
|
+
exports.returnFalse = returnFalse.returnFalse;
|
|
105
|
+
exports.returnTrue = returnTrue.returnTrue;
|
|
106
|
+
exports.useReferentiallyStableCallback = useReferentiallyStableCallback.useReferentiallyStableCallback;
|
|
107
|
+
exports.ColorSchemeProvider = ColorSchemeProvider.ColorSchemeProvider;
|
|
108
|
+
exports.GlobalClassNamePrefixContext = GlobalClassNamePrefixContext.GlobalClassNamePrefixContext;
|
|
109
|
+
exports.ColorSchemeContext = contexts.ColorSchemeContext;
|
|
110
|
+
exports.DEFAULT_COLOR_SCHEME = contexts.DEFAULT_COLOR_SCHEME;
|
|
111
|
+
exports.useColorScheme = contexts.useColorScheme;
|
|
112
|
+
exports.useClassName = useClassName.useClassName;
|
|
113
|
+
exports.useClassNameFactory = useClassNameFactory.useClassNameFactory;
|
|
114
|
+
exports.useThemedClassName = useThemedClassName.useThemedClassName;
|
|
115
|
+
exports.useThemedClassNameFactory = useThemedClassNameFactory.useThemedClassNameFactory;
|
|
116
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -8,6 +8,8 @@ import { useAddClassNameDuringResize } from "./hooks/useAddClassNameDuringResize
|
|
|
8
8
|
import { useArrayMapMemo } from "./hooks/useArrayMapMemo.js";
|
|
9
9
|
import { useAutoHeightTextArea } from "./hooks/useAutoHeightTextArea.js";
|
|
10
10
|
import { getChildrenAsLabel, useChildrenAsLabel } from "./hooks/useChildrenAsLabel.js";
|
|
11
|
+
import { useCloseOnClickOutside } from "./hooks/useCloseOnClickOutside.js";
|
|
12
|
+
import { useCloseOnEscape } from "./hooks/useCloseOnEscape.js";
|
|
11
13
|
import { useComposeRef } from "./hooks/useComposeRef.js";
|
|
12
14
|
import { useConstantLengthInvariant } from "./hooks/useConstantLengthInvariant.js";
|
|
13
15
|
import { useConstantValueInvariant } from "./hooks/useConstantValueInvariant.js";
|
|
@@ -77,6 +79,8 @@ export {
|
|
|
77
79
|
useChildrenAsLabel,
|
|
78
80
|
useClassName,
|
|
79
81
|
useClassNameFactory,
|
|
82
|
+
useCloseOnClickOutside,
|
|
83
|
+
useCloseOnEscape,
|
|
80
84
|
useColorScheme,
|
|
81
85
|
useComposeRef,
|
|
82
86
|
useConstantLengthInvariant,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","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,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const contexts = require("./contexts.cjs");
|
|
6
|
+
const ColorSchemeProvider = react.memo(({ children, scheme }) => {
|
|
7
|
+
const inheritedColorScheme = contexts.useColorScheme();
|
|
8
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(contexts.ColorSchemeContext.Provider, { value: scheme ?? inheritedColorScheme, children }, void 0, false, {
|
|
9
|
+
fileName: "/__w/interface/interface/packages/react-utils/src/theming/ColorSchemeProvider.tsx",
|
|
10
|
+
lineNumber: 13,
|
|
11
|
+
columnNumber: 3
|
|
12
|
+
}, void 0);
|
|
13
|
+
});
|
|
14
|
+
ColorSchemeProvider.displayName = "Interface.ColorSchemeProvider";
|
|
15
|
+
exports.ColorSchemeProvider = ColorSchemeProvider;
|
|
16
|
+
//# sourceMappingURL=ColorSchemeProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorSchemeProvider.cjs","sources":["../../../src/theming/ColorSchemeProvider.tsx"],"sourcesContent":["import { memo } from 'react'\nimport { ColorSchemeContext, useColorScheme } from './contexts'\n\nexport type ColorSchemeProviderProps = {\n\tchildren: React.ReactNode\n\tscheme?: string\n}\n\nexport const ColorSchemeProvider = memo(({ children, scheme }: ColorSchemeProviderProps) => {\n\tconst inheritedColorScheme = useColorScheme()\n\n\treturn (\n\t\t<ColorSchemeContext.Provider value={scheme ?? inheritedColorScheme}>{children}</ColorSchemeContext.Provider>\n\t)\n})\nColorSchemeProvider.displayName = 'Interface.ColorSchemeProvider'\n"],"names":["memo","useColorScheme","ColorSchemeContext","this"],"mappings":";;;;;AAQO,MAAM,sBAAsBA,MAAAA,KAAK,CAAC,EAAE,UAAU,aAAuC;AAC3F,QAAM,uBAAuBC,SAAAA;AAE7B,8CACEC,SAAAA,mBAAmB,UAAnB,EAA4B,OAAO,UAAU,sBAAuB,SAArE,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA8E,GAAAC,MAAA;AAEhF,CAAC;AACD,oBAAoB,cAAc;;"}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { memo } from "react";
|
|
3
3
|
import { useColorScheme, ColorSchemeContext } from "./contexts.js";
|
|
4
|
-
const ColorSchemeProvider = memo(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
);
|
|
4
|
+
const ColorSchemeProvider = memo(({ children, scheme }) => {
|
|
5
|
+
const inheritedColorScheme = useColorScheme();
|
|
6
|
+
return /* @__PURE__ */ jsxDEV(ColorSchemeContext.Provider, { value: scheme ?? inheritedColorScheme, children }, void 0, false, {
|
|
7
|
+
fileName: "/__w/interface/interface/packages/react-utils/src/theming/ColorSchemeProvider.tsx",
|
|
8
|
+
lineNumber: 13,
|
|
9
|
+
columnNumber: 3
|
|
10
|
+
}, void 0);
|
|
11
|
+
});
|
|
14
12
|
ColorSchemeProvider.displayName = "Interface.ColorSchemeProvider";
|
|
15
13
|
export {
|
|
16
14
|
ColorSchemeProvider
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorSchemeProvider.js","sources":["../../../src/theming/ColorSchemeProvider.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ColorSchemeProvider.js","sources":["../../../src/theming/ColorSchemeProvider.tsx"],"sourcesContent":["import { memo } from 'react'\nimport { ColorSchemeContext, useColorScheme } from './contexts'\n\nexport type ColorSchemeProviderProps = {\n\tchildren: React.ReactNode\n\tscheme?: string\n}\n\nexport const ColorSchemeProvider = memo(({ children, scheme }: ColorSchemeProviderProps) => {\n\tconst inheritedColorScheme = useColorScheme()\n\n\treturn (\n\t\t<ColorSchemeContext.Provider value={scheme ?? inheritedColorScheme}>{children}</ColorSchemeContext.Provider>\n\t)\n})\nColorSchemeProvider.displayName = 'Interface.ColorSchemeProvider'\n"],"names":["this"],"mappings":";;;AAQO,MAAM,sBAAsB,KAAK,CAAC,EAAE,UAAU,aAAuC;AAC3F,QAAM,uBAAuB;AAE7B,gCACE,mBAAmB,UAAnB,EAA4B,OAAO,UAAU,sBAAuB,SAArE,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAA8E,GAAAA,MAAA;AAEhF,CAAC;AACD,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalClassNamePrefixContext.cjs","sources":["../../../src/theming/GlobalClassNamePrefixContext.ts"],"sourcesContent":["import { createContext } from 'react'\n\nexport const GlobalClassNamePrefixContext = createContext<string>('cui-')\n"],"names":["createContext"],"mappings":";;;AAEa,MAAA,+BAA+BA,oBAAsB,MAAM;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const createOptionalContextFactory = require("../context/createOptionalContextFactory.cjs");
|
|
4
|
+
const DEFAULT_COLOR_SCHEME = "system";
|
|
5
|
+
const [ColorSchemeContext, useColorScheme] = createOptionalContextFactory.createOptionalContextFactory(
|
|
6
|
+
"Interface.ColorScheme",
|
|
7
|
+
DEFAULT_COLOR_SCHEME
|
|
8
|
+
);
|
|
9
|
+
exports.ColorSchemeContext = ColorSchemeContext;
|
|
10
|
+
exports.DEFAULT_COLOR_SCHEME = DEFAULT_COLOR_SCHEME;
|
|
11
|
+
exports.useColorScheme = useColorScheme;
|
|
12
|
+
//# sourceMappingURL=contexts.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contexts.cjs","sources":["../../../src/theming/contexts.ts"],"sourcesContent":["import { createOptionalContextFactory } from '../context'\n\nexport const DEFAULT_COLOR_SCHEME = 'system'\n\n\n/**\n * @group UI\n *\n * @description\n * Provides the current color scheme, possible values are `'light'`, `'dark'` or `'system'`.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme\n *\n */\nexport const [ColorSchemeContext, useColorScheme] = createOptionalContextFactory<string>(\n\t'Interface.ColorScheme',\n\tDEFAULT_COLOR_SCHEME,\n)\n"],"names":["createOptionalContextFactory"],"mappings":";;;AAEO,MAAM,uBAAuB;AAYvB,MAAA,CAAC,oBAAoB,cAAc,IAAIA,6BAAA;AAAA,EACnD;AAAA,EACA;AACD;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const utilities = require("@contember/utilities");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const GlobalClassNamePrefixContext = require("./GlobalClassNamePrefixContext.cjs");
|
|
6
|
+
function useClassName(componentClassName, additionalClassName = null, prefixOverride) {
|
|
7
|
+
const contextPrefix = react.useContext(GlobalClassNamePrefixContext.GlobalClassNamePrefixContext);
|
|
8
|
+
const classNamePrefix = prefixOverride === null || prefixOverride === "" ? "" : prefixOverride || contextPrefix;
|
|
9
|
+
const componentClassNameList = utilities.flatClassNameList(componentClassName).map(
|
|
10
|
+
(componentClassName2) => `${classNamePrefix}${componentClassName2}`
|
|
11
|
+
);
|
|
12
|
+
return utilities.deduplicateClassName(componentClassNameList.concat(
|
|
13
|
+
utilities.flatClassNameList(additionalClassName)
|
|
14
|
+
)).join(" ");
|
|
15
|
+
}
|
|
16
|
+
exports.useClassName = useClassName;
|
|
17
|
+
//# sourceMappingURL=useClassName.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClassName.cjs","sources":["../../../src/theming/useClassName.ts"],"sourcesContent":["import { NestedClassName, deduplicateClassName, flatClassNameList } from '@contember/utilities'\nimport { useContext } from 'react'\nimport { GlobalClassNamePrefixContext } from './GlobalClassNamePrefixContext'\n\n/**\n * Hook for component class name accepting outer class name\n *\n * @param componentClassName - Component class name\n * @param additionalClassName - Additional class name\n * @param prefixOverride - Context component prefix override\n * @returns Prefixed component class name.\n */\nexport function useClassName (\n\tcomponentClassName: NestedClassName,\n\tadditionalClassName: NestedClassName = null,\n\tprefixOverride?: string | null | undefined,\n) {\n\tconst contextPrefix = useContext(GlobalClassNamePrefixContext)\n\tconst classNamePrefix: string = prefixOverride === null || prefixOverride === '' ? '' : prefixOverride || contextPrefix\n\n\tconst componentClassNameList: string[] = flatClassNameList(componentClassName).map(\n\t\tcomponentClassName => `${classNamePrefix}${componentClassName}`,\n\t)\n\n\treturn deduplicateClassName(componentClassNameList.concat(\n\t\tflatClassNameList(additionalClassName),\n\t)).join(' ')\n}\n"],"names":["useContext","GlobalClassNamePrefixContext","flatClassNameList","componentClassName","deduplicateClassName"],"mappings":";;;;;AAYO,SAAS,aACf,oBACA,sBAAuC,MACvC,gBACC;AACK,QAAA,gBAAgBA,iBAAWC,6BAAAA,4BAA4B;AAC7D,QAAM,kBAA0B,mBAAmB,QAAQ,mBAAmB,KAAK,KAAK,kBAAkB;AAEpG,QAAA,yBAAmCC,UAAAA,kBAAkB,kBAAkB,EAAE;AAAA,IAC9E,CAAAC,wBAAsB,GAAG,eAAe,GAAGA,mBAAkB;AAAA,EAAA;AAG9D,SAAOC,UAAAA,qBAAqB,uBAAuB;AAAA,IAClDF,UAAAA,kBAAkB,mBAAmB;AAAA,EAAA,CACrC,EAAE,KAAK,GAAG;AACZ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClassName.js","sources":["../../../src/theming/useClassName.ts"],"sourcesContent":["import { NestedClassName, deduplicateClassName, flatClassNameList } from '@contember/utilities'\nimport { useContext } from 'react'\nimport { GlobalClassNamePrefixContext } from './GlobalClassNamePrefixContext'\n\n/**\n * Hook for component class name accepting outer class name\n *\n * @param componentClassName - Component class name\n * @param additionalClassName - Additional class name\n * @param prefixOverride - Context component prefix override\n * @returns Prefixed component class name.\n */\nexport function useClassName (\n\tcomponentClassName: NestedClassName,\n\tadditionalClassName: NestedClassName = null,\n\tprefixOverride?: string | null | undefined,\n) {\n\tconst contextPrefix = useContext(GlobalClassNamePrefixContext)\n\tconst classNamePrefix: string = prefixOverride === null || prefixOverride === '' ? '' : prefixOverride || contextPrefix\n\n\tconst componentClassNameList: string[] = flatClassNameList(componentClassName).map(\n\t\tcomponentClassName => `${classNamePrefix}${componentClassName}`,\n\t)\n\n\treturn deduplicateClassName(componentClassNameList.concat(\n\t\tflatClassNameList(additionalClassName),\n\t)).join(' ')\n}\n"],"names":["componentClassName"],"mappings":";;;AAYO,SAAS,aACf,oBACA,sBAAuC,MACvC,gBACC;AACK,QAAA,gBAAgB,WAAW,4BAA4B;AAC7D,QAAM,kBAA0B,mBAAmB,QAAQ,mBAAmB,KAAK,KAAK,kBAAkB;AAEpG,QAAA,yBAAmC,kBAAkB,kBAAkB,EAAE;AAAA,IAC9E,CAAAA,wBAAsB,GAAG,
|
|
1
|
+
{"version":3,"file":"useClassName.js","sources":["../../../src/theming/useClassName.ts"],"sourcesContent":["import { NestedClassName, deduplicateClassName, flatClassNameList } from '@contember/utilities'\nimport { useContext } from 'react'\nimport { GlobalClassNamePrefixContext } from './GlobalClassNamePrefixContext'\n\n/**\n * Hook for component class name accepting outer class name\n *\n * @param componentClassName - Component class name\n * @param additionalClassName - Additional class name\n * @param prefixOverride - Context component prefix override\n * @returns Prefixed component class name.\n */\nexport function useClassName (\n\tcomponentClassName: NestedClassName,\n\tadditionalClassName: NestedClassName = null,\n\tprefixOverride?: string | null | undefined,\n) {\n\tconst contextPrefix = useContext(GlobalClassNamePrefixContext)\n\tconst classNamePrefix: string = prefixOverride === null || prefixOverride === '' ? '' : prefixOverride || contextPrefix\n\n\tconst componentClassNameList: string[] = flatClassNameList(componentClassName).map(\n\t\tcomponentClassName => `${classNamePrefix}${componentClassName}`,\n\t)\n\n\treturn deduplicateClassName(componentClassNameList.concat(\n\t\tflatClassNameList(additionalClassName),\n\t)).join(' ')\n}\n"],"names":["componentClassName"],"mappings":";;;AAYO,SAAS,aACf,oBACA,sBAAuC,MACvC,gBACC;AACK,QAAA,gBAAgB,WAAW,4BAA4B;AAC7D,QAAM,kBAA0B,mBAAmB,QAAQ,mBAAmB,KAAK,KAAK,kBAAkB;AAEpG,QAAA,yBAAmC,kBAAkB,kBAAkB,EAAE;AAAA,IAC9E,CAAAA,wBAAsB,GAAG,eAAe,GAAGA,mBAAkB;AAAA,EAAA;AAG9D,SAAO,qBAAqB,uBAAuB;AAAA,IAClD,kBAAkB,mBAAmB;AAAA,EAAA,CACrC,EAAE,KAAK,GAAG;AACZ;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const utilities = require("@contember/utilities");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const GlobalClassNamePrefixContext = require("./GlobalClassNamePrefixContext.cjs");
|
|
6
|
+
const useReferentiallyStableCallback = require("../referentiallyStable/useReferentiallyStableCallback.cjs");
|
|
7
|
+
function useClassNameFactory(componentClassName, glue = "-", prefixOverride) {
|
|
8
|
+
const contextPrefix = react.useContext(GlobalClassNamePrefixContext.GlobalClassNamePrefixContext);
|
|
9
|
+
const classNamePrefix = prefixOverride === null || prefixOverride === "" ? "" : prefixOverride || contextPrefix;
|
|
10
|
+
const componentClassNameList = utilities.flatClassNameList(componentClassName).map(
|
|
11
|
+
(componentClassName2) => `${classNamePrefix}${componentClassName2}`
|
|
12
|
+
);
|
|
13
|
+
function componentClassNameFor(suffix = null, additionalClassName = null) {
|
|
14
|
+
const classNameSuffix = suffix ?? "";
|
|
15
|
+
return utilities.deduplicateClassName((classNameSuffix ? classNameSuffix.match(/^[a-zA-Z0-9]/) ? componentClassNameList.map((componentClassName2) => `${componentClassName2}${glue}${classNameSuffix}`) : componentClassNameList.map((componentClassName2) => `${componentClassName2}${classNameSuffix}`) : componentClassNameList).concat(
|
|
16
|
+
utilities.flatClassNameList(additionalClassName)
|
|
17
|
+
)).join(" ");
|
|
18
|
+
}
|
|
19
|
+
return useReferentiallyStableCallback.useReferentiallyStableCallback(componentClassNameFor);
|
|
20
|
+
}
|
|
21
|
+
exports.useClassNameFactory = useClassNameFactory;
|
|
22
|
+
//# sourceMappingURL=useClassNameFactory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClassNameFactory.cjs","sources":["../../../src/theming/useClassNameFactory.ts"],"sourcesContent":["import { NestedClassName, deduplicateClassName, flatClassNameList } from '@contember/utilities'\nimport { useContext } from 'react'\nimport { useReferentiallyStableCallback } from '../referentiallyStable'\nimport { GlobalClassNamePrefixContext } from './GlobalClassNamePrefixContext'\n\n/**\n * Hook for component class name accepting outer class name\n *\n * Returns a reusable function almost that is handy for components\n * with many sub-component parts that should inherit the root component\n * name.\n *\n * Also, product of the factory is a function that can be used outside of rules of hooks.\n *\n * @param componentClassName - Component class name\n * @param glue - String to use to glue component and sub-component suffix\n * @param prefixOverride - Context component prefix override\n * @returns\n */\nexport function useClassNameFactory(\n\tcomponentClassName: NestedClassName,\n\tglue: string | null = '-',\n\tprefixOverride?: string | null | undefined,\n) {\n\tconst contextPrefix = useContext(GlobalClassNamePrefixContext)\n\tconst classNamePrefix: string = prefixOverride === null || prefixOverride === '' ? '' : prefixOverride || contextPrefix\n\n\tconst componentClassNameList: string[] = flatClassNameList(componentClassName).map(\n\t\tcomponentClassName => `${classNamePrefix}${componentClassName}`,\n\t)\n\n\tfunction componentClassNameFor(\n\t\tsuffix: string | null | undefined = null,\n\t\tadditionalClassName: NestedClassName = null,\n\t): string {\n\t\tconst classNameSuffix: string = suffix ?? ''\n\n\t\treturn deduplicateClassName((classNameSuffix\n\t\t\t? (classNameSuffix.match(/^[a-zA-Z0-9]/)\n\t\t\t\t? componentClassNameList.map(componentClassName => `${componentClassName}${glue}${classNameSuffix}`)\n\t\t\t\t: componentClassNameList.map(componentClassName => `${componentClassName}${classNameSuffix}`)\n\t\t\t)\n\t\t\t: componentClassNameList\n\t\t).concat(\n\t\t\tflatClassNameList(additionalClassName),\n\t\t)).join(' ')\n\t}\n\n\treturn useReferentiallyStableCallback(componentClassNameFor)\n}\n"],"names":["useContext","GlobalClassNamePrefixContext","flatClassNameList","componentClassName","deduplicateClassName","useReferentiallyStableCallback"],"mappings":";;;;;;AAmBO,SAAS,oBACf,oBACA,OAAsB,KACtB,gBACC;AACK,QAAA,gBAAgBA,iBAAWC,6BAAAA,4BAA4B;AAC7D,QAAM,kBAA0B,mBAAmB,QAAQ,mBAAmB,KAAK,KAAK,kBAAkB;AAEpG,QAAA,yBAAmCC,UAAAA,kBAAkB,kBAAkB,EAAE;AAAA,IAC9E,CAAAC,wBAAsB,GAAG,eAAe,GAAGA,mBAAkB;AAAA,EAAA;AAG9D,WAAS,sBACR,SAAoC,MACpC,sBAAuC,MAC9B;AACT,UAAM,kBAA0B,UAAU;AAE1C,WAAOC,UAAsB,sBAAA,kBACzB,gBAAgB,MAAM,cAAc,IACpC,uBAAuB,IAAI,CAAAD,wBAAsB,GAAGA,mBAAkB,GAAG,IAAI,GAAG,eAAe,EAAE,IACjG,uBAAuB,IAAI,CAAAA,wBAAsB,GAAGA,mBAAkB,GAAG,eAAe,EAAE,IAE3F,wBACD;AAAA,MACDD,UAAAA,kBAAkB,mBAAmB;AAAA,IAAA,CACrC,EAAE,KAAK,GAAG;AAAA,EACZ;AAEA,SAAOG,+BAAAA,+BAA+B,qBAAqB;AAC5D;;"}
|