@contember/react-utils 1.3.0-alpha.9 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/context/createContext.cjs +10 -0
- package/dist/development/context/createContext.cjs.map +1 -0
- package/dist/development/context/createContext.js +10 -0
- package/dist/development/context/createContext.js.map +1 -0
- package/dist/development/context/{createNonNullableContextFactory.cjs → createRequiredContext.cjs} +6 -5
- package/dist/development/context/createRequiredContext.cjs.map +1 -0
- package/dist/development/context/{createNonNullableContextFactory.js → createRequiredContext.js} +6 -5
- package/dist/development/context/createRequiredContext.js.map +1 -0
- package/dist/development/hooks/useAutoHeightTextArea.cjs +1 -1
- package/dist/development/hooks/useAutoHeightTextArea.cjs.map +1 -1
- package/dist/development/hooks/useAutoHeightTextArea.js +1 -1
- package/dist/development/hooks/useAutoHeightTextArea.js.map +1 -1
- package/dist/development/hooks/useStoredState.cjs +89 -12
- package/dist/development/hooks/useStoredState.cjs.map +1 -1
- package/dist/development/hooks/useStoredState.js +91 -14
- package/dist/development/hooks/useStoredState.js.map +1 -1
- package/dist/development/index.cjs +11 -41
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +12 -42
- package/dist/development/index.js.map +1 -1
- package/dist/production/context/createContext.cjs +10 -0
- package/dist/production/context/createContext.cjs.map +1 -0
- package/dist/production/context/createContext.js +10 -0
- package/dist/production/context/createContext.js.map +1 -0
- package/dist/production/context/{createNonNullableContextFactory.cjs → createRequiredContext.cjs} +6 -5
- package/dist/production/context/createRequiredContext.cjs.map +1 -0
- package/dist/production/context/{createNonNullableContextFactory.js → createRequiredContext.js} +6 -5
- package/dist/production/context/createRequiredContext.js.map +1 -0
- package/dist/production/hooks/useAutoHeightTextArea.cjs +1 -1
- package/dist/production/hooks/useAutoHeightTextArea.cjs.map +1 -1
- package/dist/production/hooks/useAutoHeightTextArea.js +1 -1
- package/dist/production/hooks/useAutoHeightTextArea.js.map +1 -1
- package/dist/production/hooks/useStoredState.cjs +89 -12
- package/dist/production/hooks/useStoredState.cjs.map +1 -1
- package/dist/production/hooks/useStoredState.js +91 -14
- package/dist/production/hooks/useStoredState.js.map +1 -1
- package/dist/production/index.cjs +11 -41
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +12 -42
- package/dist/production/index.js.map +1 -1
- package/dist/types/context/createContext.d.ts +3 -0
- package/dist/types/context/createContext.d.ts.map +1 -0
- package/dist/types/context/createRequiredContext.d.ts +3 -0
- package/dist/types/context/createRequiredContext.d.ts.map +1 -0
- package/dist/types/context/index.d.ts +2 -2
- package/dist/types/context/index.d.ts.map +1 -1
- package/dist/types/hooks/index.d.ts +0 -10
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/useArrayMapMemo.d.ts.map +1 -1
- package/dist/types/hooks/useConstantLengthInvariant.d.ts.map +1 -1
- package/dist/types/hooks/useConstantValueInvariant.d.ts.map +1 -1
- package/dist/types/hooks/useDebounce.d.ts.map +1 -1
- package/dist/types/hooks/useObjectMemo.d.ts.map +1 -1
- package/dist/types/hooks/usePreviousValue.d.ts.map +1 -1
- package/dist/types/hooks/useStoredState.d.ts +14 -1
- package/dist/types/hooks/useStoredState.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/referentiallyStable/identityFunction.d.ts.map +1 -1
- package/dist/types/referentiallyStable/useReferentiallyStableCallback.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/context/createContext.ts +9 -0
- package/src/context/{createNonNullableContextFactory.ts → createRequiredContext.ts} +6 -4
- package/src/context/index.ts +2 -2
- package/src/hooks/index.ts +0 -10
- package/src/hooks/useAutoHeightTextArea.ts +1 -1
- package/src/hooks/useStoredState.ts +103 -14
- package/src/index.ts +0 -1
- package/dist/development/context/createNonNullableContextFactory.cjs.map +0 -1
- package/dist/development/context/createNonNullableContextFactory.js.map +0 -1
- package/dist/development/context/createOptionalContextFactory.cjs +0 -13
- package/dist/development/context/createOptionalContextFactory.cjs.map +0 -1
- package/dist/development/context/createOptionalContextFactory.js +0 -13
- package/dist/development/context/createOptionalContextFactory.js.map +0 -1
- package/dist/development/hooks/useAddClassNameDuringResize.cjs +0 -32
- package/dist/development/hooks/useAddClassNameDuringResize.cjs.map +0 -1
- package/dist/development/hooks/useAddClassNameDuringResize.js +0 -32
- package/dist/development/hooks/useAddClassNameDuringResize.js.map +0 -1
- package/dist/development/hooks/useCloseOnClickOutside.cjs +0 -25
- package/dist/development/hooks/useCloseOnClickOutside.cjs.map +0 -1
- package/dist/development/hooks/useCloseOnClickOutside.js +0 -25
- package/dist/development/hooks/useCloseOnClickOutside.js.map +0 -1
- package/dist/development/hooks/useCloseOnEscape.cjs +0 -20
- package/dist/development/hooks/useCloseOnEscape.cjs.map +0 -1
- package/dist/development/hooks/useCloseOnEscape.js +0 -20
- package/dist/development/hooks/useCloseOnEscape.js.map +0 -1
- package/dist/development/hooks/useContainerWidth.cjs +0 -14
- package/dist/development/hooks/useContainerWidth.cjs.map +0 -1
- package/dist/development/hooks/useContainerWidth.js +0 -14
- package/dist/development/hooks/useContainerWidth.js.map +0 -1
- package/dist/development/hooks/useElementSize.cjs +0 -37
- package/dist/development/hooks/useElementSize.cjs.map +0 -1
- package/dist/development/hooks/useElementSize.js +0 -37
- package/dist/development/hooks/useElementSize.js.map +0 -1
- package/dist/development/hooks/useElementTopOffset.cjs +0 -29
- package/dist/development/hooks/useElementTopOffset.cjs.map +0 -1
- package/dist/development/hooks/useElementTopOffset.js +0 -29
- package/dist/development/hooks/useElementTopOffset.js.map +0 -1
- package/dist/development/hooks/useEventHandler.cjs +0 -19
- package/dist/development/hooks/useEventHandler.cjs.map +0 -1
- package/dist/development/hooks/useEventHandler.js +0 -19
- package/dist/development/hooks/useEventHandler.js.map +0 -1
- package/dist/development/hooks/useOnElementMutation.cjs +0 -35
- package/dist/development/hooks/useOnElementMutation.cjs.map +0 -1
- package/dist/development/hooks/useOnElementMutation.js +0 -35
- package/dist/development/hooks/useOnElementMutation.js.map +0 -1
- package/dist/development/hooks/useOnScrollWithin.cjs +0 -52
- package/dist/development/hooks/useOnScrollWithin.cjs.map +0 -1
- package/dist/development/hooks/useOnScrollWithin.js +0 -52
- package/dist/development/hooks/useOnScrollWithin.js.map +0 -1
- package/dist/development/hooks/useScrollOffsets.cjs +0 -67
- package/dist/development/hooks/useScrollOffsets.cjs.map +0 -1
- package/dist/development/hooks/useScrollOffsets.js +0 -67
- package/dist/development/hooks/useScrollOffsets.js.map +0 -1
- package/dist/development/theming/ColorSchemeProvider.cjs +0 -16
- package/dist/development/theming/ColorSchemeProvider.cjs.map +0 -1
- package/dist/development/theming/ColorSchemeProvider.js +0 -16
- package/dist/development/theming/ColorSchemeProvider.js.map +0 -1
- package/dist/development/theming/GlobalClassNamePrefixContext.cjs +0 -6
- package/dist/development/theming/GlobalClassNamePrefixContext.cjs.map +0 -1
- package/dist/development/theming/GlobalClassNamePrefixContext.js +0 -6
- package/dist/development/theming/GlobalClassNamePrefixContext.js.map +0 -1
- package/dist/development/theming/contexts.cjs +0 -12
- package/dist/development/theming/contexts.cjs.map +0 -1
- package/dist/development/theming/contexts.js +0 -12
- package/dist/development/theming/contexts.js.map +0 -1
- package/dist/development/theming/useClassName.cjs +0 -17
- package/dist/development/theming/useClassName.cjs.map +0 -1
- package/dist/development/theming/useClassName.js +0 -17
- package/dist/development/theming/useClassName.js.map +0 -1
- package/dist/development/theming/useClassNameFactory.cjs +0 -22
- package/dist/development/theming/useClassNameFactory.cjs.map +0 -1
- package/dist/development/theming/useClassNameFactory.js +0 -22
- package/dist/development/theming/useClassNameFactory.js.map +0 -1
- package/dist/development/theming/useThemedClassName.cjs +0 -17
- package/dist/development/theming/useThemedClassName.cjs.map +0 -1
- package/dist/development/theming/useThemedClassName.js +0 -17
- package/dist/development/theming/useThemedClassName.js.map +0 -1
- package/dist/development/theming/useThemedClassNameFactory.cjs +0 -29
- package/dist/development/theming/useThemedClassNameFactory.cjs.map +0 -1
- package/dist/development/theming/useThemedClassNameFactory.js +0 -29
- package/dist/development/theming/useThemedClassNameFactory.js.map +0 -1
- package/dist/production/context/createNonNullableContextFactory.cjs.map +0 -1
- package/dist/production/context/createNonNullableContextFactory.js.map +0 -1
- package/dist/production/context/createOptionalContextFactory.cjs +0 -13
- package/dist/production/context/createOptionalContextFactory.cjs.map +0 -1
- package/dist/production/context/createOptionalContextFactory.js +0 -13
- package/dist/production/context/createOptionalContextFactory.js.map +0 -1
- package/dist/production/hooks/useAddClassNameDuringResize.cjs +0 -32
- package/dist/production/hooks/useAddClassNameDuringResize.cjs.map +0 -1
- package/dist/production/hooks/useAddClassNameDuringResize.js +0 -32
- package/dist/production/hooks/useAddClassNameDuringResize.js.map +0 -1
- package/dist/production/hooks/useCloseOnClickOutside.cjs +0 -25
- package/dist/production/hooks/useCloseOnClickOutside.cjs.map +0 -1
- package/dist/production/hooks/useCloseOnClickOutside.js +0 -25
- package/dist/production/hooks/useCloseOnClickOutside.js.map +0 -1
- package/dist/production/hooks/useCloseOnEscape.cjs +0 -20
- package/dist/production/hooks/useCloseOnEscape.cjs.map +0 -1
- package/dist/production/hooks/useCloseOnEscape.js +0 -20
- package/dist/production/hooks/useCloseOnEscape.js.map +0 -1
- package/dist/production/hooks/useContainerWidth.cjs +0 -14
- package/dist/production/hooks/useContainerWidth.cjs.map +0 -1
- package/dist/production/hooks/useContainerWidth.js +0 -14
- package/dist/production/hooks/useContainerWidth.js.map +0 -1
- package/dist/production/hooks/useElementSize.cjs +0 -37
- package/dist/production/hooks/useElementSize.cjs.map +0 -1
- package/dist/production/hooks/useElementSize.js +0 -37
- package/dist/production/hooks/useElementSize.js.map +0 -1
- package/dist/production/hooks/useElementTopOffset.cjs +0 -29
- package/dist/production/hooks/useElementTopOffset.cjs.map +0 -1
- package/dist/production/hooks/useElementTopOffset.js +0 -29
- package/dist/production/hooks/useElementTopOffset.js.map +0 -1
- package/dist/production/hooks/useEventHandler.cjs +0 -19
- package/dist/production/hooks/useEventHandler.cjs.map +0 -1
- package/dist/production/hooks/useEventHandler.js +0 -19
- package/dist/production/hooks/useEventHandler.js.map +0 -1
- package/dist/production/hooks/useOnElementMutation.cjs +0 -35
- package/dist/production/hooks/useOnElementMutation.cjs.map +0 -1
- package/dist/production/hooks/useOnElementMutation.js +0 -35
- package/dist/production/hooks/useOnElementMutation.js.map +0 -1
- package/dist/production/hooks/useOnScrollWithin.cjs +0 -52
- package/dist/production/hooks/useOnScrollWithin.cjs.map +0 -1
- package/dist/production/hooks/useOnScrollWithin.js +0 -52
- package/dist/production/hooks/useOnScrollWithin.js.map +0 -1
- package/dist/production/hooks/useScrollOffsets.cjs +0 -67
- package/dist/production/hooks/useScrollOffsets.cjs.map +0 -1
- package/dist/production/hooks/useScrollOffsets.js +0 -67
- package/dist/production/hooks/useScrollOffsets.js.map +0 -1
- package/dist/production/theming/ColorSchemeProvider.cjs +0 -12
- package/dist/production/theming/ColorSchemeProvider.cjs.map +0 -1
- package/dist/production/theming/ColorSchemeProvider.js +0 -12
- package/dist/production/theming/ColorSchemeProvider.js.map +0 -1
- package/dist/production/theming/GlobalClassNamePrefixContext.cjs +0 -6
- package/dist/production/theming/GlobalClassNamePrefixContext.cjs.map +0 -1
- package/dist/production/theming/GlobalClassNamePrefixContext.js +0 -6
- package/dist/production/theming/GlobalClassNamePrefixContext.js.map +0 -1
- package/dist/production/theming/contexts.cjs +0 -12
- package/dist/production/theming/contexts.cjs.map +0 -1
- package/dist/production/theming/contexts.js +0 -12
- package/dist/production/theming/contexts.js.map +0 -1
- package/dist/production/theming/useClassName.cjs +0 -17
- package/dist/production/theming/useClassName.cjs.map +0 -1
- package/dist/production/theming/useClassName.js +0 -17
- package/dist/production/theming/useClassName.js.map +0 -1
- package/dist/production/theming/useClassNameFactory.cjs +0 -22
- package/dist/production/theming/useClassNameFactory.cjs.map +0 -1
- package/dist/production/theming/useClassNameFactory.js +0 -22
- package/dist/production/theming/useClassNameFactory.js.map +0 -1
- package/dist/production/theming/useThemedClassName.cjs +0 -17
- package/dist/production/theming/useThemedClassName.cjs.map +0 -1
- package/dist/production/theming/useThemedClassName.js +0 -17
- package/dist/production/theming/useThemedClassName.js.map +0 -1
- package/dist/production/theming/useThemedClassNameFactory.cjs +0 -29
- package/dist/production/theming/useThemedClassNameFactory.cjs.map +0 -1
- package/dist/production/theming/useThemedClassNameFactory.js +0 -29
- package/dist/production/theming/useThemedClassNameFactory.js.map +0 -1
- package/dist/types/context/createNonNullableContextFactory.d.ts +0 -3
- package/dist/types/context/createNonNullableContextFactory.d.ts.map +0 -1
- package/dist/types/context/createOptionalContextFactory.d.ts +0 -3
- package/dist/types/context/createOptionalContextFactory.d.ts.map +0 -1
- package/dist/types/hooks/useAddClassNameDuringResize.d.ts +0 -13
- package/dist/types/hooks/useAddClassNameDuringResize.d.ts.map +0 -1
- package/dist/types/hooks/useCloseOnClickOutside.d.ts +0 -7
- package/dist/types/hooks/useCloseOnClickOutside.d.ts.map +0 -1
- package/dist/types/hooks/useCloseOnEscape.d.ts +0 -5
- package/dist/types/hooks/useCloseOnEscape.d.ts.map +0 -1
- package/dist/types/hooks/useContainerWidth.d.ts +0 -4
- package/dist/types/hooks/useContainerWidth.d.ts.map +0 -1
- package/dist/types/hooks/useElementSize.d.ts +0 -16
- package/dist/types/hooks/useElementSize.d.ts.map +0 -1
- package/dist/types/hooks/useElementTopOffset.d.ts +0 -3
- package/dist/types/hooks/useElementTopOffset.d.ts.map +0 -1
- package/dist/types/hooks/useEventHandler.d.ts +0 -10
- package/dist/types/hooks/useEventHandler.d.ts.map +0 -1
- package/dist/types/hooks/useOnElementMutation.d.ts +0 -3
- package/dist/types/hooks/useOnElementMutation.d.ts.map +0 -1
- package/dist/types/hooks/useOnScrollWithin.d.ts +0 -10
- package/dist/types/hooks/useOnScrollWithin.d.ts.map +0 -1
- package/dist/types/hooks/useScrollOffsets.d.ts +0 -14
- package/dist/types/hooks/useScrollOffsets.d.ts.map +0 -1
- package/dist/types/theming/ColorSchemeProvider.d.ts +0 -6
- package/dist/types/theming/ColorSchemeProvider.d.ts.map +0 -1
- package/dist/types/theming/GlobalClassNamePrefixContext.d.ts +0 -2
- package/dist/types/theming/GlobalClassNamePrefixContext.d.ts.map +0 -1
- package/dist/types/theming/contexts.d.ts +0 -12
- package/dist/types/theming/contexts.d.ts.map +0 -1
- package/dist/types/theming/index.d.ts +0 -8
- package/dist/types/theming/index.d.ts.map +0 -1
- package/dist/types/theming/useClassName.d.ts +0 -11
- package/dist/types/theming/useClassName.d.ts.map +0 -1
- package/dist/types/theming/useClassNameFactory.d.ts +0 -17
- package/dist/types/theming/useClassNameFactory.d.ts.map +0 -1
- package/dist/types/theming/useThemedClassName.d.ts +0 -39
- package/dist/types/theming/useThemedClassName.d.ts.map +0 -1
- package/dist/types/theming/useThemedClassNameFactory.d.ts +0 -3
- package/dist/types/theming/useThemedClassNameFactory.d.ts.map +0 -1
- package/src/context/createOptionalContextFactory.ts +0 -13
- package/src/hooks/useAddClassNameDuringResize.ts +0 -56
- package/src/hooks/useCloseOnClickOutside.ts +0 -27
- package/src/hooks/useCloseOnEscape.ts +0 -18
- package/src/hooks/useContainerWidth.ts +0 -13
- package/src/hooks/useElementSize.ts +0 -56
- package/src/hooks/useElementTopOffset.ts +0 -35
- package/src/hooks/useEventHandler.ts +0 -24
- package/src/hooks/useOnElementMutation.ts +0 -42
- package/src/hooks/useOnScrollWithin.ts +0 -68
- package/src/hooks/useScrollOffsets.ts +0 -87
- package/src/theming/ColorSchemeProvider.tsx +0 -16
- package/src/theming/GlobalClassNamePrefixContext.ts +0 -3
- package/src/theming/contexts.ts +0 -18
- package/src/theming/index.ts +0 -7
- package/src/theming/useClassName.ts +0 -28
- package/src/theming/useClassNameFactory.ts +0 -50
- package/src/theming/useThemedClassName.ts +0 -54
- package/src/theming/useThemedClassNameFactory.ts +0 -44
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
function createContext(name, initialValue) {
|
|
5
|
+
const OptionalContext = react.createContext(initialValue);
|
|
6
|
+
OptionalContext.displayName = name;
|
|
7
|
+
return [OptionalContext, () => react.useContext(OptionalContext)];
|
|
8
|
+
}
|
|
9
|
+
exports.createContext = createContext;
|
|
10
|
+
//# sourceMappingURL=createContext.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContext.cjs","sources":["../../../src/context/createContext.ts"],"sourcesContent":["import type { Context } from 'react'\nimport { createContext as baseCreateContext, useContext } from 'react'\n\nexport function createContext<T>(name: string, initialValue: T): [Context<T>, () => T] {\n const OptionalContext = baseCreateContext<T>(initialValue)\n OptionalContext.displayName = name\n\n return [OptionalContext, () => useContext(OptionalContext)]\n}\n"],"names":["baseCreateContext","useContext"],"mappings":";;;AAGgB,SAAA,cAAiB,MAAc,cAAwC;AAC/E,QAAA,kBAAkBA,oBAAqB,YAAY;AACzD,kBAAgB,cAAc;AAE9B,SAAO,CAAC,iBAAiB,MAAMC,iBAAW,eAAe,CAAC;AAC5D;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext as createContext$1, useContext } from "react";
|
|
2
|
+
function createContext(name, initialValue) {
|
|
3
|
+
const OptionalContext = createContext$1(initialValue);
|
|
4
|
+
OptionalContext.displayName = name;
|
|
5
|
+
return [OptionalContext, () => useContext(OptionalContext)];
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
createContext
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=createContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContext.js","sources":["../../../src/context/createContext.ts"],"sourcesContent":["import type { Context } from 'react'\nimport { createContext as baseCreateContext, useContext } from 'react'\n\nexport function createContext<T>(name: string, initialValue: T): [Context<T>, () => T] {\n const OptionalContext = baseCreateContext<T>(initialValue)\n OptionalContext.displayName = name\n\n return [OptionalContext, () => useContext(OptionalContext)]\n}\n"],"names":["baseCreateContext"],"mappings":";AAGgB,SAAA,cAAiB,MAAc,cAAwC;AAC/E,QAAA,kBAAkBA,gBAAqB,YAAY;AACzD,kBAAgB,cAAc;AAE9B,SAAO,CAAC,iBAAiB,MAAM,WAAW,eAAe,CAAC;AAC5D;"}
|
package/dist/development/context/{createNonNullableContextFactory.cjs → createRequiredContext.cjs}
RENAMED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const react = require("react");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const EmptyContextSymbol = Symbol("EmptyContextSymbol");
|
|
5
|
+
function createRequiredContext(displayName) {
|
|
6
|
+
const RequiredContext = react.createContext(EmptyContextSymbol);
|
|
6
7
|
RequiredContext.displayName = displayName;
|
|
7
8
|
const useRequiredContext = () => {
|
|
8
9
|
const context = react.useContext(RequiredContext);
|
|
9
|
-
if (context
|
|
10
|
+
if (context === EmptyContextSymbol) {
|
|
10
11
|
throw new Error(`use${displayName} must be used within a ${displayName} provider`);
|
|
11
12
|
}
|
|
12
13
|
return context;
|
|
13
14
|
};
|
|
14
15
|
return [RequiredContext, useRequiredContext];
|
|
15
16
|
}
|
|
16
|
-
exports.
|
|
17
|
-
//# sourceMappingURL=
|
|
17
|
+
exports.createRequiredContext = createRequiredContext;
|
|
18
|
+
//# sourceMappingURL=createRequiredContext.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRequiredContext.cjs","sources":["../../../src/context/createRequiredContext.ts"],"sourcesContent":["import type { Context } from 'react'\nimport { createContext, useContext } from 'react'\n\nconst EmptyContextSymbol = Symbol('EmptyContextSymbol')\n\nexport function createRequiredContext<T>(displayName: string): [Context<T>, () => T] {\n const RequiredContext = createContext<T>(EmptyContextSymbol as T)\n RequiredContext.displayName = displayName\n\n const useRequiredContext = (): T => {\n const context = useContext(RequiredContext)\n\n if (context === EmptyContextSymbol) {\n throw new Error(`use${displayName} must be used within a ${displayName} provider`)\n }\n\n return context\n }\n\n return [RequiredContext, useRequiredContext]\n}\n"],"names":["createContext","useContext"],"mappings":";;;AAGA,MAAM,qBAAqB,OAAO,oBAAoB;AAE/C,SAAS,sBAAyB,aAA4C;AAC7E,QAAA,kBAAkBA,oBAAiB,kBAAuB;AAChE,kBAAgB,cAAc;AAE9B,QAAM,qBAAqB,MAAS;AAC5B,UAAA,UAAUC,iBAAW,eAAe;AAE1C,QAAI,YAAY,oBAAoB;AAClC,YAAM,IAAI,MAAM,MAAM,WAAW,0BAA0B,WAAW,WAAW;AAAA,IACnF;AAEO,WAAA;AAAA,EAAA;AAGF,SAAA,CAAC,iBAAiB,kBAAkB;AAC7C;;"}
|
package/dist/development/context/{createNonNullableContextFactory.js → createRequiredContext.js}
RENAMED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const EmptyContextSymbol = Symbol("EmptyContextSymbol");
|
|
3
|
+
function createRequiredContext(displayName) {
|
|
4
|
+
const RequiredContext = createContext(EmptyContextSymbol);
|
|
4
5
|
RequiredContext.displayName = displayName;
|
|
5
6
|
const useRequiredContext = () => {
|
|
6
7
|
const context = useContext(RequiredContext);
|
|
7
|
-
if (context
|
|
8
|
+
if (context === EmptyContextSymbol) {
|
|
8
9
|
throw new Error(`use${displayName} must be used within a ${displayName} provider`);
|
|
9
10
|
}
|
|
10
11
|
return context;
|
|
@@ -12,6 +13,6 @@ function createNonNullableContextFactory(displayName, initialValue) {
|
|
|
12
13
|
return [RequiredContext, useRequiredContext];
|
|
13
14
|
}
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
+
createRequiredContext
|
|
16
17
|
};
|
|
17
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=createRequiredContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRequiredContext.js","sources":["../../../src/context/createRequiredContext.ts"],"sourcesContent":["import type { Context } from 'react'\nimport { createContext, useContext } from 'react'\n\nconst EmptyContextSymbol = Symbol('EmptyContextSymbol')\n\nexport function createRequiredContext<T>(displayName: string): [Context<T>, () => T] {\n const RequiredContext = createContext<T>(EmptyContextSymbol as T)\n RequiredContext.displayName = displayName\n\n const useRequiredContext = (): T => {\n const context = useContext(RequiredContext)\n\n if (context === EmptyContextSymbol) {\n throw new Error(`use${displayName} must be used within a ${displayName} provider`)\n }\n\n return context\n }\n\n return [RequiredContext, useRequiredContext]\n}\n"],"names":[],"mappings":";AAGA,MAAM,qBAAqB,OAAO,oBAAoB;AAE/C,SAAS,sBAAyB,aAA4C;AAC7E,QAAA,kBAAkB,cAAiB,kBAAuB;AAChE,kBAAgB,cAAc;AAE9B,QAAM,qBAAqB,MAAS;AAC5B,UAAA,UAAU,WAAW,eAAe;AAE1C,QAAI,YAAY,oBAAoB;AAClC,YAAM,IAAI,MAAM,MAAM,WAAW,0BAA0B,WAAW,WAAW;AAAA,IACnF;AAEO,WAAA;AAAA,EAAA;AAGF,SAAA,CAAC,iBAAiB,kBAAkB;AAC7C;"}
|
|
@@ -12,7 +12,7 @@ const useAutoHeightTextArea = (textAreaRef, value, minRows, maxRows) => {
|
|
|
12
12
|
ref.style.minHeight = "";
|
|
13
13
|
ref.style.maxHeight = "";
|
|
14
14
|
if (minRows2 !== maxRows2) {
|
|
15
|
-
const height = ref.scrollHeight;
|
|
15
|
+
const height = ref.scrollHeight - ref.clientHeight + ref.offsetHeight;
|
|
16
16
|
let minHeight;
|
|
17
17
|
let maxHeight;
|
|
18
18
|
ref.rows = minRows2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoHeightTextArea.cjs","sources":["../../../src/hooks/useAutoHeightTextArea.ts"],"sourcesContent":["import { px } from '@contember/utilities'\nimport { useCallback, useLayoutEffect } from 'react'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\nimport { useOnElementResize } from './useOnElementResize'\n\nexport const useAutoHeightTextArea = (\n\ttextAreaRef: RefObjectOrElement<HTMLTextAreaElement>,\n\tvalue: string,\n\tminRows: number,\n\tmaxRows: number,\n) => {\n\tconst measure = useCallback(async (ref: HTMLTextAreaElement | null, minRows: number, maxRows: number) => {\n\t\tif (ref) {\n\t\t\tconst rowsAttribute = ref.rows\n\n\t\t\tref.style.height = ''\n\t\t\tref.style.minHeight = ''\n\t\t\tref.style.maxHeight = ''\n\n\t\t\tif (minRows !== maxRows) {\n\t\t\t\tconst height = ref.scrollHeight\n\t\t\t\tlet minHeight: number\n\t\t\t\tlet maxHeight: number\n\n\t\t\t\tref.rows = minRows\n\t\t\t\tminHeight = await ref.getBoundingClientRect().height\n\n\t\t\t\tif (maxRows === Infinity) {\n\t\t\t\t\tmaxHeight = Infinity\n\t\t\t\t} else {\n\t\t\t\t\tref.rows = maxRows\n\t\t\t\t\tmaxHeight = await ref.getBoundingClientRect().height\n\t\t\t\t}\n\n\t\t\t\tref.style.height = px(height)\n\t\t\t\tref.style.minHeight = px(minHeight)\n\t\t\t\tref.style.maxHeight = px(maxHeight)\n\t\t\t}\n\n\t\t\tref.rows = rowsAttribute\n\t\t}\n\t}, [])\n\n\tuseOnElementResize(textAreaRef, () => {\n\t\tmeasure(unwrapRefValue(textAreaRef), minRows, maxRows)\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tmeasure(unwrapRefValue(textAreaRef), minRows, maxRows)\n\t}, [maxRows, measure, minRows, textAreaRef, value])\n}\n"],"names":["useCallback","minRows","maxRows","px","useOnElementResize","unwrapRefValue","useLayoutEffect"],"mappings":";;;;;;AAKO,MAAM,wBAAwB,CACpC,aACA,OACA,SACA,YACI;AACJ,QAAM,UAAUA,MAAA,YAAY,OAAO,KAAiCC,UAAiBC,aAAoB;AACxG,QAAI,KAAK;AACR,YAAM,gBAAgB,IAAI;AAE1B,UAAI,MAAM,SAAS;AACnB,UAAI,MAAM,YAAY;AACtB,UAAI,MAAM,YAAY;AAEtB,UAAID,aAAYC,UAAS;AACxB,cAAM,SAAS,IAAI;
|
|
1
|
+
{"version":3,"file":"useAutoHeightTextArea.cjs","sources":["../../../src/hooks/useAutoHeightTextArea.ts"],"sourcesContent":["import { px } from '@contember/utilities'\nimport { useCallback, useLayoutEffect } from 'react'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\nimport { useOnElementResize } from './useOnElementResize'\n\nexport const useAutoHeightTextArea = (\n\ttextAreaRef: RefObjectOrElement<HTMLTextAreaElement>,\n\tvalue: string,\n\tminRows: number,\n\tmaxRows: number,\n) => {\n\tconst measure = useCallback(async (ref: HTMLTextAreaElement | null, minRows: number, maxRows: number) => {\n\t\tif (ref) {\n\t\t\tconst rowsAttribute = ref.rows\n\n\t\t\tref.style.height = ''\n\t\t\tref.style.minHeight = ''\n\t\t\tref.style.maxHeight = ''\n\n\t\t\tif (minRows !== maxRows) {\n\t\t\t\tconst height = ref.scrollHeight - ref.clientHeight + ref.offsetHeight\n\t\t\t\tlet minHeight: number\n\t\t\t\tlet maxHeight: number\n\n\t\t\t\tref.rows = minRows\n\t\t\t\tminHeight = await ref.getBoundingClientRect().height\n\n\t\t\t\tif (maxRows === Infinity) {\n\t\t\t\t\tmaxHeight = Infinity\n\t\t\t\t} else {\n\t\t\t\t\tref.rows = maxRows\n\t\t\t\t\tmaxHeight = await ref.getBoundingClientRect().height\n\t\t\t\t}\n\n\t\t\t\tref.style.height = px(height)\n\t\t\t\tref.style.minHeight = px(minHeight)\n\t\t\t\tref.style.maxHeight = px(maxHeight)\n\t\t\t}\n\n\t\t\tref.rows = rowsAttribute\n\t\t}\n\t}, [])\n\n\tuseOnElementResize(textAreaRef, () => {\n\t\tmeasure(unwrapRefValue(textAreaRef), minRows, maxRows)\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tmeasure(unwrapRefValue(textAreaRef), minRows, maxRows)\n\t}, [maxRows, measure, minRows, textAreaRef, value])\n}\n"],"names":["useCallback","minRows","maxRows","px","useOnElementResize","unwrapRefValue","useLayoutEffect"],"mappings":";;;;;;AAKO,MAAM,wBAAwB,CACpC,aACA,OACA,SACA,YACI;AACJ,QAAM,UAAUA,MAAA,YAAY,OAAO,KAAiCC,UAAiBC,aAAoB;AACxG,QAAI,KAAK;AACR,YAAM,gBAAgB,IAAI;AAE1B,UAAI,MAAM,SAAS;AACnB,UAAI,MAAM,YAAY;AACtB,UAAI,MAAM,YAAY;AAEtB,UAAID,aAAYC,UAAS;AACxB,cAAM,SAAS,IAAI,eAAe,IAAI,eAAe,IAAI;AACrD,YAAA;AACA,YAAA;AAEJ,YAAI,OAAOD;AACC,oBAAA,MAAM,IAAI,sBAAA,EAAwB;AAE9C,YAAIC,aAAY,UAAU;AACb,sBAAA;AAAA,QAAA,OACN;AACN,cAAI,OAAOA;AACC,sBAAA,MAAM,IAAI,sBAAA,EAAwB;AAAA,QAC/C;AAEI,YAAA,MAAM,SAASC,UAAA,GAAG,MAAM;AACxB,YAAA,MAAM,YAAYA,UAAA,GAAG,SAAS;AAC9B,YAAA,MAAM,YAAYA,UAAA,GAAG,SAAS;AAAA,MACnC;AAEA,UAAI,OAAO;AAAA,IACZ;AAAA,EACD,GAAG,CAAE,CAAA;AAELC,qBAAA,mBAAmB,aAAa,MAAM;AACrC,YAAQC,eAAAA,eAAe,WAAW,GAAG,SAAS,OAAO;AAAA,EAAA,CACrD;AAEDC,QAAAA,gBAAgB,MAAM;AACrB,YAAQD,eAAAA,eAAe,WAAW,GAAG,SAAS,OAAO;AAAA,EAAA,GACnD,CAAC,SAAS,SAAS,SAAS,aAAa,KAAK,CAAC;AACnD;;"}
|
|
@@ -10,7 +10,7 @@ const useAutoHeightTextArea = (textAreaRef, value, minRows, maxRows) => {
|
|
|
10
10
|
ref.style.minHeight = "";
|
|
11
11
|
ref.style.maxHeight = "";
|
|
12
12
|
if (minRows2 !== maxRows2) {
|
|
13
|
-
const height = ref.scrollHeight;
|
|
13
|
+
const height = ref.scrollHeight - ref.clientHeight + ref.offsetHeight;
|
|
14
14
|
let minHeight;
|
|
15
15
|
let maxHeight;
|
|
16
16
|
ref.rows = minRows2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoHeightTextArea.js","sources":["../../../src/hooks/useAutoHeightTextArea.ts"],"sourcesContent":["import { px } from '@contember/utilities'\nimport { useCallback, useLayoutEffect } from 'react'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\nimport { useOnElementResize } from './useOnElementResize'\n\nexport const useAutoHeightTextArea = (\n\ttextAreaRef: RefObjectOrElement<HTMLTextAreaElement>,\n\tvalue: string,\n\tminRows: number,\n\tmaxRows: number,\n) => {\n\tconst measure = useCallback(async (ref: HTMLTextAreaElement | null, minRows: number, maxRows: number) => {\n\t\tif (ref) {\n\t\t\tconst rowsAttribute = ref.rows\n\n\t\t\tref.style.height = ''\n\t\t\tref.style.minHeight = ''\n\t\t\tref.style.maxHeight = ''\n\n\t\t\tif (minRows !== maxRows) {\n\t\t\t\tconst height = ref.scrollHeight\n\t\t\t\tlet minHeight: number\n\t\t\t\tlet maxHeight: number\n\n\t\t\t\tref.rows = minRows\n\t\t\t\tminHeight = await ref.getBoundingClientRect().height\n\n\t\t\t\tif (maxRows === Infinity) {\n\t\t\t\t\tmaxHeight = Infinity\n\t\t\t\t} else {\n\t\t\t\t\tref.rows = maxRows\n\t\t\t\t\tmaxHeight = await ref.getBoundingClientRect().height\n\t\t\t\t}\n\n\t\t\t\tref.style.height = px(height)\n\t\t\t\tref.style.minHeight = px(minHeight)\n\t\t\t\tref.style.maxHeight = px(maxHeight)\n\t\t\t}\n\n\t\t\tref.rows = rowsAttribute\n\t\t}\n\t}, [])\n\n\tuseOnElementResize(textAreaRef, () => {\n\t\tmeasure(unwrapRefValue(textAreaRef), minRows, maxRows)\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tmeasure(unwrapRefValue(textAreaRef), minRows, maxRows)\n\t}, [maxRows, measure, minRows, textAreaRef, value])\n}\n"],"names":["minRows","maxRows"],"mappings":";;;;AAKO,MAAM,wBAAwB,CACpC,aACA,OACA,SACA,YACI;AACJ,QAAM,UAAU,YAAY,OAAO,KAAiCA,UAAiBC,aAAoB;AACxG,QAAI,KAAK;AACR,YAAM,gBAAgB,IAAI;AAE1B,UAAI,MAAM,SAAS;AACnB,UAAI,MAAM,YAAY;AACtB,UAAI,MAAM,YAAY;AAEtB,UAAID,aAAYC,UAAS;AACxB,cAAM,SAAS,IAAI;
|
|
1
|
+
{"version":3,"file":"useAutoHeightTextArea.js","sources":["../../../src/hooks/useAutoHeightTextArea.ts"],"sourcesContent":["import { px } from '@contember/utilities'\nimport { useCallback, useLayoutEffect } from 'react'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\nimport { useOnElementResize } from './useOnElementResize'\n\nexport const useAutoHeightTextArea = (\n\ttextAreaRef: RefObjectOrElement<HTMLTextAreaElement>,\n\tvalue: string,\n\tminRows: number,\n\tmaxRows: number,\n) => {\n\tconst measure = useCallback(async (ref: HTMLTextAreaElement | null, minRows: number, maxRows: number) => {\n\t\tif (ref) {\n\t\t\tconst rowsAttribute = ref.rows\n\n\t\t\tref.style.height = ''\n\t\t\tref.style.minHeight = ''\n\t\t\tref.style.maxHeight = ''\n\n\t\t\tif (minRows !== maxRows) {\n\t\t\t\tconst height = ref.scrollHeight - ref.clientHeight + ref.offsetHeight\n\t\t\t\tlet minHeight: number\n\t\t\t\tlet maxHeight: number\n\n\t\t\t\tref.rows = minRows\n\t\t\t\tminHeight = await ref.getBoundingClientRect().height\n\n\t\t\t\tif (maxRows === Infinity) {\n\t\t\t\t\tmaxHeight = Infinity\n\t\t\t\t} else {\n\t\t\t\t\tref.rows = maxRows\n\t\t\t\t\tmaxHeight = await ref.getBoundingClientRect().height\n\t\t\t\t}\n\n\t\t\t\tref.style.height = px(height)\n\t\t\t\tref.style.minHeight = px(minHeight)\n\t\t\t\tref.style.maxHeight = px(maxHeight)\n\t\t\t}\n\n\t\t\tref.rows = rowsAttribute\n\t\t}\n\t}, [])\n\n\tuseOnElementResize(textAreaRef, () => {\n\t\tmeasure(unwrapRefValue(textAreaRef), minRows, maxRows)\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tmeasure(unwrapRefValue(textAreaRef), minRows, maxRows)\n\t}, [maxRows, measure, minRows, textAreaRef, value])\n}\n"],"names":["minRows","maxRows"],"mappings":";;;;AAKO,MAAM,wBAAwB,CACpC,aACA,OACA,SACA,YACI;AACJ,QAAM,UAAU,YAAY,OAAO,KAAiCA,UAAiBC,aAAoB;AACxG,QAAI,KAAK;AACR,YAAM,gBAAgB,IAAI;AAE1B,UAAI,MAAM,SAAS;AACnB,UAAI,MAAM,YAAY;AACtB,UAAI,MAAM,YAAY;AAEtB,UAAID,aAAYC,UAAS;AACxB,cAAM,SAAS,IAAI,eAAe,IAAI,eAAe,IAAI;AACrD,YAAA;AACA,YAAA;AAEJ,YAAI,OAAOD;AACC,oBAAA,MAAM,IAAI,sBAAA,EAAwB;AAE9C,YAAIC,aAAY,UAAU;AACb,sBAAA;AAAA,QAAA,OACN;AACN,cAAI,OAAOA;AACC,sBAAA,MAAM,IAAI,sBAAA,EAAwB;AAAA,QAC/C;AAEI,YAAA,MAAM,SAAS,GAAG,MAAM;AACxB,YAAA,MAAM,YAAY,GAAG,SAAS;AAC9B,YAAA,MAAM,YAAY,GAAG,SAAS;AAAA,MACnC;AAEA,UAAI,OAAO;AAAA,IACZ;AAAA,EACD,GAAG,CAAE,CAAA;AAEL,qBAAmB,aAAa,MAAM;AACrC,YAAQ,eAAe,WAAW,GAAG,SAAS,OAAO;AAAA,EAAA,CACrD;AAED,kBAAgB,MAAM;AACrB,YAAQ,eAAe,WAAW,GAAG,SAAS,OAAO;AAAA,EAAA,GACnD,CAAC,SAAS,SAAS,SAAS,aAAa,KAAK,CAAC;AACnD;"}
|
|
@@ -1,23 +1,100 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const react = require("react");
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
const urlStateStorage = {
|
|
5
|
+
getItem(key) {
|
|
6
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
7
|
+
const value = searchParams.get(key[1]);
|
|
8
|
+
return value !== null && value !== void 0 ? JSON.parse(value) : null;
|
|
9
|
+
},
|
|
10
|
+
setItem(key, value) {
|
|
11
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
12
|
+
searchParams.set(key[1], JSON.stringify(value));
|
|
13
|
+
const newUrl = `${window.location.pathname}?${searchParams.toString()}`;
|
|
14
|
+
window.history.replaceState({}, "", newUrl);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const createStateStorageFromNativeStorage = (getStorage) => {
|
|
18
|
+
return {
|
|
19
|
+
getItem(key) {
|
|
20
|
+
const value = getStorage().getItem(key.join("-"));
|
|
21
|
+
return value !== null ? JSON.parse(value) : null;
|
|
22
|
+
},
|
|
23
|
+
setItem(key, value) {
|
|
24
|
+
getStorage().setItem(key.join("-"), JSON.stringify(value));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const sessionStateStorage = createStateStorageFromNativeStorage(() => sessionStorage);
|
|
29
|
+
const localStateStorage = createStateStorageFromNativeStorage(() => localStorage);
|
|
30
|
+
const nullStorage = {
|
|
31
|
+
getItem() {
|
|
32
|
+
return null;
|
|
33
|
+
},
|
|
34
|
+
setItem() {
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const builtInStorages = {
|
|
38
|
+
url: urlStateStorage,
|
|
39
|
+
session: sessionStateStorage,
|
|
40
|
+
local: localStateStorage,
|
|
41
|
+
null: nullStorage
|
|
42
|
+
};
|
|
43
|
+
const useStoredState = (storageOrName, key, initializeValue) => {
|
|
44
|
+
const storage = react.useMemo(() => {
|
|
45
|
+
return getStateStorage(storageOrName);
|
|
46
|
+
}, [storageOrName]);
|
|
47
|
+
const [value, setValue] = react.useState(() => {
|
|
48
|
+
const value2 = storage.getItem(key);
|
|
49
|
+
return initializeValue(value2);
|
|
50
|
+
});
|
|
51
|
+
return [
|
|
52
|
+
value,
|
|
53
|
+
react.useCallback((value2) => {
|
|
13
54
|
setValue((current) => {
|
|
14
55
|
const newValue = typeof value2 === "function" ? value2(current) : value2;
|
|
15
|
-
storage.setItem(key,
|
|
56
|
+
storage.setItem(key, newValue);
|
|
16
57
|
return newValue;
|
|
17
58
|
});
|
|
18
|
-
}, [key, storage])
|
|
59
|
+
}, [key, storage])
|
|
60
|
+
];
|
|
61
|
+
};
|
|
62
|
+
const useSessionStorageState = (key, initializeValue) => {
|
|
63
|
+
return useStoredState(sessionStateStorage, key, initializeValue);
|
|
64
|
+
};
|
|
65
|
+
const useLocalStorageState = (key, initializeValue) => {
|
|
66
|
+
return useStoredState(localStateStorage, key, initializeValue);
|
|
67
|
+
};
|
|
68
|
+
const getStateStorage = (storageOrName) => {
|
|
69
|
+
if (Array.isArray(storageOrName)) {
|
|
70
|
+
return createFallbackStorage(storageOrName.map((it) => typeof it === "string" ? builtInStorages[it] : it));
|
|
71
|
+
}
|
|
72
|
+
return typeof storageOrName === "string" ? builtInStorages[storageOrName] : storageOrName;
|
|
73
|
+
};
|
|
74
|
+
const createFallbackStorage = (storageTypes) => {
|
|
75
|
+
return {
|
|
76
|
+
getItem(key) {
|
|
77
|
+
for (const storage of storageTypes) {
|
|
78
|
+
const value = storage.getItem(key);
|
|
79
|
+
if (value !== null) {
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
},
|
|
85
|
+
setItem(key, value) {
|
|
86
|
+
for (const storage of storageTypes) {
|
|
87
|
+
storage.setItem(key, value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
19
90
|
};
|
|
20
91
|
};
|
|
21
|
-
|
|
92
|
+
exports.getStateStorage = getStateStorage;
|
|
93
|
+
exports.localStateStorage = localStateStorage;
|
|
94
|
+
exports.nullStorage = nullStorage;
|
|
95
|
+
exports.sessionStateStorage = sessionStateStorage;
|
|
96
|
+
exports.urlStateStorage = urlStateStorage;
|
|
97
|
+
exports.useLocalStorageState = useLocalStorageState;
|
|
22
98
|
exports.useSessionStorageState = useSessionStorageState;
|
|
99
|
+
exports.useStoredState = useStoredState;
|
|
23
100
|
//# sourceMappingURL=useStoredState.cjs.map
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"useStoredState.cjs","sources":["../../../src/hooks/useStoredState.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react'\nimport { Serializable } from '../types'\n\nexport type SetState<V extends Serializable> = (value: V | ((current: V) => V)) => void;\nexport type StateStorageKey = [uniquePrefix: string, key: string]\n\nexport type ValueInitializer<V extends Serializable> = (storedValue: V | undefined) => V;\n\nexport interface StateStorage {\n\tgetItem(key: StateStorageKey): Serializable\n\n\tsetItem(key: StateStorageKey, value: Serializable): void\n}\n\n\nexport const urlStateStorage: StateStorage = {\n\tgetItem(key) {\n\t\tconst searchParams = new URLSearchParams(window.location.search)\n\t\tconst value = searchParams.get(key[1])\n\t\treturn value !== null && value !== undefined ? JSON.parse(value) : null\n\t},\n\tsetItem(key, value) {\n\t\tconst searchParams = new URLSearchParams(window.location.search)\n\t\tsearchParams.set(key[1], JSON.stringify(value))\n\t\tconst newUrl = `${window.location.pathname}?${searchParams.toString()}`\n\t\twindow.history.replaceState({}, '', newUrl)\n\t},\n}\n\nconst createStateStorageFromNativeStorage = (getStorage: () => Storage): StateStorage => {\n\treturn {\n\t\tgetItem(key) {\n\t\t\tconst value = getStorage().getItem(key.join('-'))\n\t\t\treturn value !== null ? JSON.parse(value) : null\n\t\t},\n\t\tsetItem(key, value) {\n\t\t\tgetStorage().setItem(key.join('-'), JSON.stringify(value))\n\t\t},\n\t}\n}\n\nexport const sessionStateStorage = createStateStorageFromNativeStorage(() => sessionStorage)\nexport const localStateStorage = createStateStorageFromNativeStorage(() => localStorage)\nexport const nullStorage: StateStorage = {\n\tgetItem() {\n\t\treturn null\n\t},\n\tsetItem() {\n\t},\n}\n\nconst builtInStorages = {\n\turl: urlStateStorage,\n\tsession: sessionStateStorage,\n\tlocal: localStateStorage,\n\tnull: nullStorage,\n}\n\nexport type StateStorageOrName = StateStorage | 'url' | 'session' | 'local' | 'null'\n\nexport const useStoredState = <V extends Serializable>(storageOrName: StateStorageOrName | StateStorageOrName[], key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\tconst storage = useMemo(() => {\n\t\treturn getStateStorage(storageOrName)\n\t}, [storageOrName])\n\n\tconst [value, setValue] = useState<V>(() => {\n\t\tconst value = storage.getItem(key)\n\t\treturn initializeValue(value as V)\n\t})\n\treturn [\n\t\tvalue,\n\t\tuseCallback(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, newValue)\n\t\t\t\treturn newValue\n\t\t\t})\n\t\t}, [key, storage]),\n\t]\n}\n\nexport const useSessionStorageState = <V extends Serializable>(key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\treturn useStoredState<V>(sessionStateStorage, key, initializeValue)\n}\n\nexport const useLocalStorageState = <V extends Serializable>(key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\treturn useStoredState<V>(localStateStorage, key, initializeValue)\n}\n\nexport const getStateStorage = (storageOrName: StateStorageOrName | StateStorageOrName[]) => {\n\tif (Array.isArray(storageOrName)) {\n\t\treturn createFallbackStorage(storageOrName.map(it => typeof it === 'string' ? builtInStorages[it] : it))\n\t}\n\treturn typeof storageOrName === 'string' ? builtInStorages[storageOrName] : storageOrName\n}\n\n\nconst createFallbackStorage = (storageTypes: StateStorage[]): StateStorage => {\n\treturn {\n\t\tgetItem(key) {\n\t\t\tfor (const storage of storageTypes) {\n\t\t\t\tconst value = storage.getItem(key)\n\t\t\t\tif (value !== null) {\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\tsetItem(key, value) {\n\t\t\tfor (const storage of storageTypes) {\n\t\t\t\tstorage.setItem(key, value)\n\t\t\t}\n\t\t},\n\t}\n}\n"],"names":["useMemo","useState","value","useCallback"],"mappings":";;;AAeO,MAAM,kBAAgC;AAAA,EAC5C,QAAQ,KAAK;AACZ,UAAM,eAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC/D,UAAM,QAAQ,aAAa,IAAI,IAAI,CAAC,CAAC;AACrC,WAAO,UAAU,QAAQ,UAAU,SAAY,KAAK,MAAM,KAAK,IAAI;AAAA,EACpE;AAAA,EACA,QAAQ,KAAK,OAAO;AACnB,UAAM,eAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC/D,iBAAa,IAAI,IAAI,CAAC,GAAG,KAAK,UAAU,KAAK,CAAC;AACxC,UAAA,SAAS,GAAG,OAAO,SAAS,QAAQ,IAAI,aAAa,SAAU,CAAA;AACrE,WAAO,QAAQ,aAAa,CAAC,GAAG,IAAI,MAAM;AAAA,EAC3C;AACD;AAEA,MAAM,sCAAsC,CAAC,eAA4C;AACjF,SAAA;AAAA,IACN,QAAQ,KAAK;AACZ,YAAM,QAAQ,aAAa,QAAQ,IAAI,KAAK,GAAG,CAAC;AAChD,aAAO,UAAU,OAAO,KAAK,MAAM,KAAK,IAAI;AAAA,IAC7C;AAAA,IACA,QAAQ,KAAK,OAAO;AACR,iBAAA,EAAE,QAAQ,IAAI,KAAK,GAAG,GAAG,KAAK,UAAU,KAAK,CAAC;AAAA,IAC1D;AAAA,EAAA;AAEF;AAEa,MAAA,sBAAsB,oCAAoC,MAAM,cAAc;AAC9E,MAAA,oBAAoB,oCAAoC,MAAM,YAAY;AAChF,MAAM,cAA4B;AAAA,EACxC,UAAU;AACF,WAAA;AAAA,EACR;AAAA,EACA,UAAU;AAAA,EACV;AACD;AAEA,MAAM,kBAAkB;AAAA,EACvB,KAAK;AAAA,EACL,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AACP;AAIO,MAAM,iBAAiB,CAAyB,eAA0D,KAAsB,oBAA2D;AAC3L,QAAA,UAAUA,MAAAA,QAAQ,MAAM;AAC7B,WAAO,gBAAgB,aAAa;AAAA,EAAA,GAClC,CAAC,aAAa,CAAC;AAElB,QAAM,CAAC,OAAO,QAAQ,IAAIC,eAAY,MAAM;AACrCC,UAAAA,SAAQ,QAAQ,QAAQ,GAAG;AACjC,WAAO,gBAAgBA,MAAU;AAAA,EAAA,CACjC;AACM,SAAA;AAAA,IACN;AAAA,IACAC,MAAA,YAAY,CAAAD,WAAS;AACpB,eAAS,CAAW,YAAA;AACnB,cAAM,WAAW,OAAOA,WAAU,aAAcA,OAA4B,OAAO,IAAIA;AAC/E,gBAAA,QAAQ,KAAK,QAAQ;AACtB,eAAA;AAAA,MAAA,CACP;AAAA,IAAA,GACC,CAAC,KAAK,OAAO,CAAC;AAAA,EAAA;AAEnB;AAEa,MAAA,yBAAyB,CAAyB,KAAsB,oBAA2D;AACxI,SAAA,eAAkB,qBAAqB,KAAK,eAAe;AACnE;AAEa,MAAA,uBAAuB,CAAyB,KAAsB,oBAA2D;AACtI,SAAA,eAAkB,mBAAmB,KAAK,eAAe;AACjE;AAEa,MAAA,kBAAkB,CAAC,kBAA6D;AACxF,MAAA,MAAM,QAAQ,aAAa,GAAG;AAC1B,WAAA,sBAAsB,cAAc,IAAI,CAAM,OAAA,OAAO,OAAO,WAAW,gBAAgB,EAAE,IAAI,EAAE,CAAC;AAAA,EACxG;AACA,SAAO,OAAO,kBAAkB,WAAW,gBAAgB,aAAa,IAAI;AAC7E;AAGA,MAAM,wBAAwB,CAAC,iBAA+C;AACtE,SAAA;AAAA,IACN,QAAQ,KAAK;AACZ,iBAAW,WAAW,cAAc;AAC7B,cAAA,QAAQ,QAAQ,QAAQ,GAAG;AACjC,YAAI,UAAU,MAAM;AACZ,iBAAA;AAAA,QACR;AAAA,MACD;AACO,aAAA;AAAA,IACR;AAAA,IACA,QAAQ,KAAK,OAAO;AACnB,iBAAW,WAAW,cAAc;AAC3B,gBAAA,QAAQ,KAAK,KAAK;AAAA,MAC3B;AAAA,IACD;AAAA,EAAA;AAEF;;;;;;;;;"}
|
|
@@ -1,23 +1,100 @@
|
|
|
1
|
-
import { useState, useCallback } from "react";
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { useMemo, useState, useCallback } from "react";
|
|
2
|
+
const urlStateStorage = {
|
|
3
|
+
getItem(key) {
|
|
4
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
5
|
+
const value = searchParams.get(key[1]);
|
|
6
|
+
return value !== null && value !== void 0 ? JSON.parse(value) : null;
|
|
7
|
+
},
|
|
8
|
+
setItem(key, value) {
|
|
9
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
10
|
+
searchParams.set(key[1], JSON.stringify(value));
|
|
11
|
+
const newUrl = `${window.location.pathname}?${searchParams.toString()}`;
|
|
12
|
+
window.history.replaceState({}, "", newUrl);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const createStateStorageFromNativeStorage = (getStorage) => {
|
|
16
|
+
return {
|
|
17
|
+
getItem(key) {
|
|
18
|
+
const value = getStorage().getItem(key.join("-"));
|
|
19
|
+
return value !== null ? JSON.parse(value) : null;
|
|
20
|
+
},
|
|
21
|
+
setItem(key, value) {
|
|
22
|
+
getStorage().setItem(key.join("-"), JSON.stringify(value));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const sessionStateStorage = createStateStorageFromNativeStorage(() => sessionStorage);
|
|
27
|
+
const localStateStorage = createStateStorageFromNativeStorage(() => localStorage);
|
|
28
|
+
const nullStorage = {
|
|
29
|
+
getItem() {
|
|
30
|
+
return null;
|
|
31
|
+
},
|
|
32
|
+
setItem() {
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const builtInStorages = {
|
|
36
|
+
url: urlStateStorage,
|
|
37
|
+
session: sessionStateStorage,
|
|
38
|
+
local: localStateStorage,
|
|
39
|
+
null: nullStorage
|
|
40
|
+
};
|
|
41
|
+
const useStoredState = (storageOrName, key, initializeValue) => {
|
|
42
|
+
const storage = useMemo(() => {
|
|
43
|
+
return getStateStorage(storageOrName);
|
|
44
|
+
}, [storageOrName]);
|
|
45
|
+
const [value, setValue] = useState(() => {
|
|
46
|
+
const value2 = storage.getItem(key);
|
|
47
|
+
return initializeValue(value2);
|
|
48
|
+
});
|
|
49
|
+
return [
|
|
50
|
+
value,
|
|
51
|
+
useCallback((value2) => {
|
|
11
52
|
setValue((current) => {
|
|
12
53
|
const newValue = typeof value2 === "function" ? value2(current) : value2;
|
|
13
|
-
storage.setItem(key,
|
|
54
|
+
storage.setItem(key, newValue);
|
|
14
55
|
return newValue;
|
|
15
56
|
});
|
|
16
|
-
}, [key, storage])
|
|
57
|
+
}, [key, storage])
|
|
58
|
+
];
|
|
59
|
+
};
|
|
60
|
+
const useSessionStorageState = (key, initializeValue) => {
|
|
61
|
+
return useStoredState(sessionStateStorage, key, initializeValue);
|
|
62
|
+
};
|
|
63
|
+
const useLocalStorageState = (key, initializeValue) => {
|
|
64
|
+
return useStoredState(localStateStorage, key, initializeValue);
|
|
65
|
+
};
|
|
66
|
+
const getStateStorage = (storageOrName) => {
|
|
67
|
+
if (Array.isArray(storageOrName)) {
|
|
68
|
+
return createFallbackStorage(storageOrName.map((it) => typeof it === "string" ? builtInStorages[it] : it));
|
|
69
|
+
}
|
|
70
|
+
return typeof storageOrName === "string" ? builtInStorages[storageOrName] : storageOrName;
|
|
71
|
+
};
|
|
72
|
+
const createFallbackStorage = (storageTypes) => {
|
|
73
|
+
return {
|
|
74
|
+
getItem(key) {
|
|
75
|
+
for (const storage of storageTypes) {
|
|
76
|
+
const value = storage.getItem(key);
|
|
77
|
+
if (value !== null) {
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
},
|
|
83
|
+
setItem(key, value) {
|
|
84
|
+
for (const storage of storageTypes) {
|
|
85
|
+
storage.setItem(key, value);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
17
88
|
};
|
|
18
89
|
};
|
|
19
|
-
const useSessionStorageState = createStoredStateHook(() => sessionStorage);
|
|
20
90
|
export {
|
|
21
|
-
|
|
91
|
+
getStateStorage,
|
|
92
|
+
localStateStorage,
|
|
93
|
+
nullStorage,
|
|
94
|
+
sessionStateStorage,
|
|
95
|
+
urlStateStorage,
|
|
96
|
+
useLocalStorageState,
|
|
97
|
+
useSessionStorageState,
|
|
98
|
+
useStoredState
|
|
22
99
|
};
|
|
23
100
|
//# sourceMappingURL=useStoredState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStoredState.js","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
|
|
1
|
+
{"version":3,"file":"useStoredState.js","sources":["../../../src/hooks/useStoredState.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react'\nimport { Serializable } from '../types'\n\nexport type SetState<V extends Serializable> = (value: V | ((current: V) => V)) => void;\nexport type StateStorageKey = [uniquePrefix: string, key: string]\n\nexport type ValueInitializer<V extends Serializable> = (storedValue: V | undefined) => V;\n\nexport interface StateStorage {\n\tgetItem(key: StateStorageKey): Serializable\n\n\tsetItem(key: StateStorageKey, value: Serializable): void\n}\n\n\nexport const urlStateStorage: StateStorage = {\n\tgetItem(key) {\n\t\tconst searchParams = new URLSearchParams(window.location.search)\n\t\tconst value = searchParams.get(key[1])\n\t\treturn value !== null && value !== undefined ? JSON.parse(value) : null\n\t},\n\tsetItem(key, value) {\n\t\tconst searchParams = new URLSearchParams(window.location.search)\n\t\tsearchParams.set(key[1], JSON.stringify(value))\n\t\tconst newUrl = `${window.location.pathname}?${searchParams.toString()}`\n\t\twindow.history.replaceState({}, '', newUrl)\n\t},\n}\n\nconst createStateStorageFromNativeStorage = (getStorage: () => Storage): StateStorage => {\n\treturn {\n\t\tgetItem(key) {\n\t\t\tconst value = getStorage().getItem(key.join('-'))\n\t\t\treturn value !== null ? JSON.parse(value) : null\n\t\t},\n\t\tsetItem(key, value) {\n\t\t\tgetStorage().setItem(key.join('-'), JSON.stringify(value))\n\t\t},\n\t}\n}\n\nexport const sessionStateStorage = createStateStorageFromNativeStorage(() => sessionStorage)\nexport const localStateStorage = createStateStorageFromNativeStorage(() => localStorage)\nexport const nullStorage: StateStorage = {\n\tgetItem() {\n\t\treturn null\n\t},\n\tsetItem() {\n\t},\n}\n\nconst builtInStorages = {\n\turl: urlStateStorage,\n\tsession: sessionStateStorage,\n\tlocal: localStateStorage,\n\tnull: nullStorage,\n}\n\nexport type StateStorageOrName = StateStorage | 'url' | 'session' | 'local' | 'null'\n\nexport const useStoredState = <V extends Serializable>(storageOrName: StateStorageOrName | StateStorageOrName[], key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\tconst storage = useMemo(() => {\n\t\treturn getStateStorage(storageOrName)\n\t}, [storageOrName])\n\n\tconst [value, setValue] = useState<V>(() => {\n\t\tconst value = storage.getItem(key)\n\t\treturn initializeValue(value as V)\n\t})\n\treturn [\n\t\tvalue,\n\t\tuseCallback(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, newValue)\n\t\t\t\treturn newValue\n\t\t\t})\n\t\t}, [key, storage]),\n\t]\n}\n\nexport const useSessionStorageState = <V extends Serializable>(key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\treturn useStoredState<V>(sessionStateStorage, key, initializeValue)\n}\n\nexport const useLocalStorageState = <V extends Serializable>(key: StateStorageKey, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\treturn useStoredState<V>(localStateStorage, key, initializeValue)\n}\n\nexport const getStateStorage = (storageOrName: StateStorageOrName | StateStorageOrName[]) => {\n\tif (Array.isArray(storageOrName)) {\n\t\treturn createFallbackStorage(storageOrName.map(it => typeof it === 'string' ? builtInStorages[it] : it))\n\t}\n\treturn typeof storageOrName === 'string' ? builtInStorages[storageOrName] : storageOrName\n}\n\n\nconst createFallbackStorage = (storageTypes: StateStorage[]): StateStorage => {\n\treturn {\n\t\tgetItem(key) {\n\t\t\tfor (const storage of storageTypes) {\n\t\t\t\tconst value = storage.getItem(key)\n\t\t\t\tif (value !== null) {\n\t\t\t\t\treturn value\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\tsetItem(key, value) {\n\t\t\tfor (const storage of storageTypes) {\n\t\t\t\tstorage.setItem(key, value)\n\t\t\t}\n\t\t},\n\t}\n}\n"],"names":["value"],"mappings":";AAeO,MAAM,kBAAgC;AAAA,EAC5C,QAAQ,KAAK;AACZ,UAAM,eAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC/D,UAAM,QAAQ,aAAa,IAAI,IAAI,CAAC,CAAC;AACrC,WAAO,UAAU,QAAQ,UAAU,SAAY,KAAK,MAAM,KAAK,IAAI;AAAA,EACpE;AAAA,EACA,QAAQ,KAAK,OAAO;AACnB,UAAM,eAAe,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC/D,iBAAa,IAAI,IAAI,CAAC,GAAG,KAAK,UAAU,KAAK,CAAC;AACxC,UAAA,SAAS,GAAG,OAAO,SAAS,QAAQ,IAAI,aAAa,SAAU,CAAA;AACrE,WAAO,QAAQ,aAAa,CAAC,GAAG,IAAI,MAAM;AAAA,EAC3C;AACD;AAEA,MAAM,sCAAsC,CAAC,eAA4C;AACjF,SAAA;AAAA,IACN,QAAQ,KAAK;AACZ,YAAM,QAAQ,aAAa,QAAQ,IAAI,KAAK,GAAG,CAAC;AAChD,aAAO,UAAU,OAAO,KAAK,MAAM,KAAK,IAAI;AAAA,IAC7C;AAAA,IACA,QAAQ,KAAK,OAAO;AACR,iBAAA,EAAE,QAAQ,IAAI,KAAK,GAAG,GAAG,KAAK,UAAU,KAAK,CAAC;AAAA,IAC1D;AAAA,EAAA;AAEF;AAEa,MAAA,sBAAsB,oCAAoC,MAAM,cAAc;AAC9E,MAAA,oBAAoB,oCAAoC,MAAM,YAAY;AAChF,MAAM,cAA4B;AAAA,EACxC,UAAU;AACF,WAAA;AAAA,EACR;AAAA,EACA,UAAU;AAAA,EACV;AACD;AAEA,MAAM,kBAAkB;AAAA,EACvB,KAAK;AAAA,EACL,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AACP;AAIO,MAAM,iBAAiB,CAAyB,eAA0D,KAAsB,oBAA2D;AAC3L,QAAA,UAAU,QAAQ,MAAM;AAC7B,WAAO,gBAAgB,aAAa;AAAA,EAAA,GAClC,CAAC,aAAa,CAAC;AAElB,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAY,MAAM;AACrCA,UAAAA,SAAQ,QAAQ,QAAQ,GAAG;AACjC,WAAO,gBAAgBA,MAAU;AAAA,EAAA,CACjC;AACM,SAAA;AAAA,IACN;AAAA,IACA,YAAY,CAAAA,WAAS;AACpB,eAAS,CAAW,YAAA;AACnB,cAAM,WAAW,OAAOA,WAAU,aAAcA,OAA4B,OAAO,IAAIA;AAC/E,gBAAA,QAAQ,KAAK,QAAQ;AACtB,eAAA;AAAA,MAAA,CACP;AAAA,IAAA,GACC,CAAC,KAAK,OAAO,CAAC;AAAA,EAAA;AAEnB;AAEa,MAAA,yBAAyB,CAAyB,KAAsB,oBAA2D;AACxI,SAAA,eAAkB,qBAAqB,KAAK,eAAe;AACnE;AAEa,MAAA,uBAAuB,CAAyB,KAAsB,oBAA2D;AACtI,SAAA,eAAkB,mBAAmB,KAAK,eAAe;AACjE;AAEa,MAAA,kBAAkB,CAAC,kBAA6D;AACxF,MAAA,MAAM,QAAQ,aAAa,GAAG;AAC1B,WAAA,sBAAsB,cAAc,IAAI,CAAM,OAAA,OAAO,OAAO,WAAW,gBAAgB,EAAE,IAAI,EAAE,CAAC;AAAA,EACxG;AACA,SAAO,OAAO,kBAAkB,WAAW,gBAAgB,aAAa,IAAI;AAC7E;AAGA,MAAM,wBAAwB,CAAC,iBAA+C;AACtE,SAAA;AAAA,IACN,QAAQ,KAAK;AACZ,iBAAW,WAAW,cAAc;AAC7B,cAAA,QAAQ,QAAQ,QAAQ,GAAG;AACjC,YAAI,UAAU,MAAM;AACZ,iBAAA;AAAA,QACR;AAAA,MACD;AACO,aAAA;AAAA,IACR;AAAA,IACA,QAAQ,KAAK,OAAO;AACnB,iBAAW,WAAW,cAAc;AAC3B,gBAAA,QAAQ,KAAK,KAAK;AAAA,MAC3B;AAAA,IACD;AAAA,EAAA;AAEF;"}
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const createRequiredContext = require("./context/createRequiredContext.cjs");
|
|
4
|
+
const createContext = require("./context/createContext.cjs");
|
|
5
5
|
const Constants = require("./debug-context/Constants.cjs");
|
|
6
6
|
const Context = require("./debug-context/Context.cjs");
|
|
7
7
|
const unwrapRefValue = require("./hooks/unwrapRefValue.cjs");
|
|
8
8
|
const useAbortController = require("./hooks/useAbortController.cjs");
|
|
9
|
-
const useAddClassNameDuringResize = require("./hooks/useAddClassNameDuringResize.cjs");
|
|
10
9
|
const useArrayMapMemo = require("./hooks/useArrayMapMemo.cjs");
|
|
11
10
|
const useAutoHeightTextArea = require("./hooks/useAutoHeightTextArea.cjs");
|
|
12
11
|
const useChildrenAsLabel = require("./hooks/useChildrenAsLabel.cjs");
|
|
13
|
-
const useCloseOnClickOutside = require("./hooks/useCloseOnClickOutside.cjs");
|
|
14
|
-
const useCloseOnEscape = require("./hooks/useCloseOnEscape.cjs");
|
|
15
12
|
const useComposeRef = require("./hooks/useComposeRef.cjs");
|
|
16
13
|
const useConstantLengthInvariant = require("./hooks/useConstantLengthInvariant.cjs");
|
|
17
14
|
const useConstantValueInvariant = require("./hooks/useConstantValueInvariant.cjs");
|
|
18
|
-
const useContainerWidth = require("./hooks/useContainerWidth.cjs");
|
|
19
15
|
const useDebounce = require("./hooks/useDebounce.cjs");
|
|
20
16
|
const useDebounceCallback = require("./hooks/useDebounceCallback.cjs");
|
|
21
17
|
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
18
|
const useExpectSameValueReference = require("./hooks/useExpectSameValueReference.cjs");
|
|
26
19
|
const useForceRender = require("./hooks/useForceRender.cjs");
|
|
27
20
|
const useId = require("./hooks/useId.cjs");
|
|
@@ -29,12 +22,9 @@ const useIsMounted = require("./hooks/useIsMounted.cjs");
|
|
|
29
22
|
const useObjectMemo = require("./hooks/useObjectMemo.cjs");
|
|
30
23
|
const useOnElementClickOutsideCallback = require("./hooks/useOnElementClickOutsideCallback.cjs");
|
|
31
24
|
const useOnElementMouseEnterDelayedCallback = require("./hooks/useOnElementMouseEnterDelayedCallback.cjs");
|
|
32
|
-
const useOnElementMutation = require("./hooks/useOnElementMutation.cjs");
|
|
33
25
|
const useOnElementResize = require("./hooks/useOnElementResize.cjs");
|
|
34
|
-
const useOnScrollWithin = require("./hooks/useOnScrollWithin.cjs");
|
|
35
26
|
const useOnWindowResize = require("./hooks/useOnWindowResize.cjs");
|
|
36
27
|
const usePreviousValue = require("./hooks/usePreviousValue.cjs");
|
|
37
|
-
const useScrollOffsets = require("./hooks/useScrollOffsets.cjs");
|
|
38
28
|
const useStoredState = require("./hooks/useStoredState.cjs");
|
|
39
29
|
const useUpdatedRef = require("./hooks/useUpdatedRef.cjs");
|
|
40
30
|
const useWindowSize = require("./hooks/useWindowSize.cjs");
|
|
@@ -45,15 +35,8 @@ const noop = require("./referentiallyStable/noop.cjs");
|
|
|
45
35
|
const returnFalse = require("./referentiallyStable/returnFalse.cjs");
|
|
46
36
|
const returnTrue = require("./referentiallyStable/returnTrue.cjs");
|
|
47
37
|
const useReferentiallyStableCallback = require("./referentiallyStable/useReferentiallyStableCallback.cjs");
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
|
38
|
+
exports.createRequiredContext = createRequiredContext.createRequiredContext;
|
|
39
|
+
exports.createContext = createContext.createContext;
|
|
57
40
|
exports.isNoopScopedConsole = Constants.isNoopScopedConsole;
|
|
58
41
|
exports.noopLog = Constants.noopLog;
|
|
59
42
|
exports.noopLogged = Constants.noopLogged;
|
|
@@ -63,24 +46,16 @@ exports.ScopedConsoleContext = Context.ScopedConsoleContext;
|
|
|
63
46
|
exports.useScopedConsoleRef = Context.useScopedConsoleRef;
|
|
64
47
|
exports.unwrapRefValue = unwrapRefValue.unwrapRefValue;
|
|
65
48
|
exports.useAbortController = useAbortController.useAbortController;
|
|
66
|
-
exports.useAddClassNameDuringResize = useAddClassNameDuringResize.useAddClassNameDuringResize;
|
|
67
49
|
exports.useArrayMapMemo = useArrayMapMemo.useArrayMapMemo;
|
|
68
50
|
exports.useAutoHeightTextArea = useAutoHeightTextArea.useAutoHeightTextArea;
|
|
69
51
|
exports.getChildrenAsLabel = useChildrenAsLabel.getChildrenAsLabel;
|
|
70
52
|
exports.useChildrenAsLabel = useChildrenAsLabel.useChildrenAsLabel;
|
|
71
|
-
exports.useCloseOnClickOutside = useCloseOnClickOutside.useCloseOnClickOutside;
|
|
72
|
-
exports.useCloseOnEscape = useCloseOnEscape.useCloseOnEscape;
|
|
73
53
|
exports.useComposeRef = useComposeRef.useComposeRef;
|
|
74
54
|
exports.useConstantLengthInvariant = useConstantLengthInvariant.useConstantLengthInvariant;
|
|
75
55
|
exports.useConstantValueInvariant = useConstantValueInvariant.useConstantValueInvariant;
|
|
76
|
-
exports.ContainerWidthContext = useContainerWidth.ContainerWidthContext;
|
|
77
|
-
exports.useContainerWidth = useContainerWidth.useContainerWidth;
|
|
78
56
|
exports.useDebounce = useDebounce.useDebounce;
|
|
79
57
|
exports.useDebounceCallback = useDebounceCallback.useDebounceCallback;
|
|
80
58
|
exports.useDocumentTitle = useDocumentTitle.useDocumentTitle;
|
|
81
|
-
exports.useElementSize = useElementSize.useElementSize;
|
|
82
|
-
exports.useElementTopOffset = useElementTopOffset.useElementTopOffset;
|
|
83
|
-
exports.useEventHandler = useEventHandler.useEventHandler;
|
|
84
59
|
exports.useExpectSameValueReference = useExpectSameValueReference.useExpectSameValueReference;
|
|
85
60
|
exports.useForceRender = useForceRender.useForceRender;
|
|
86
61
|
exports.useId = useId.useId;
|
|
@@ -88,13 +63,17 @@ exports.useIsMounted = useIsMounted.useIsMounted;
|
|
|
88
63
|
exports.useObjectMemo = useObjectMemo.useObjectMemo;
|
|
89
64
|
exports.useOnElementClickOutsideCallback = useOnElementClickOutsideCallback.useOnElementClickOutsideCallback;
|
|
90
65
|
exports.useOnElementMouseEnterDelayedCallback = useOnElementMouseEnterDelayedCallback.useOnElementMouseEnterDelayedCallback;
|
|
91
|
-
exports.useOnElementMutation = useOnElementMutation.useOnElementMutation;
|
|
92
66
|
exports.useOnElementResize = useOnElementResize.useOnElementResize;
|
|
93
|
-
exports.useOnScrollWithin = useOnScrollWithin.useOnScrollWithin;
|
|
94
67
|
exports.useOnWindowResize = useOnWindowResize.useOnWindowResize;
|
|
95
68
|
exports.usePreviousValue = usePreviousValue.usePreviousValue;
|
|
96
|
-
exports.
|
|
69
|
+
exports.getStateStorage = useStoredState.getStateStorage;
|
|
70
|
+
exports.localStateStorage = useStoredState.localStateStorage;
|
|
71
|
+
exports.nullStorage = useStoredState.nullStorage;
|
|
72
|
+
exports.sessionStateStorage = useStoredState.sessionStateStorage;
|
|
73
|
+
exports.urlStateStorage = useStoredState.urlStateStorage;
|
|
74
|
+
exports.useLocalStorageState = useStoredState.useLocalStorageState;
|
|
97
75
|
exports.useSessionStorageState = useStoredState.useSessionStorageState;
|
|
76
|
+
exports.useStoredState = useStoredState.useStoredState;
|
|
98
77
|
exports.useUpdatedRef = useUpdatedRef.useUpdatedRef;
|
|
99
78
|
exports.useWindowSize = useWindowSize.useWindowSize;
|
|
100
79
|
exports.emptyArray = emptyArray.emptyArray;
|
|
@@ -104,13 +83,4 @@ exports.noop = noop.noop;
|
|
|
104
83
|
exports.returnFalse = returnFalse.returnFalse;
|
|
105
84
|
exports.returnTrue = returnTrue.returnTrue;
|
|
106
85
|
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
86
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|