@koine/react 1.1.11 → 1.1.14
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/Carousel/CarouselCss.d.ts +6 -1
- package/Details/Details.d.ts +298 -13
- package/Dialog/DialogMui.d.ts +328 -19
- package/Dialog/css/bare.d.ts +352 -43
- package/Dialog/m/bare.d.ts +322 -13
- package/Dialog/sc/bare.d.ts +325 -17
- package/Dialog/sc/framer.d.ts +316 -7
- package/Dialog/sc/framerMaterial.d.ts +316 -7
- package/Dialog/sc/material.d.ts +325 -16
- package/Dialog/tw/bare.d.ts +358 -49
- package/Dialog/tw/elegant.d.ts +379 -70
- package/Dialog/tw/framer.d.ts +340 -31
- package/Dialog/tw/framerMaterial.d.ts +356 -47
- package/Dialog/tw/material.d.ts +379 -70
- package/Form/Form.d.ts +45 -19
- package/Form/sc/bare.d.ts +33 -8
- package/Forms/Checkbox/Checkbox.d.ts +1 -1
- package/Forms/Input/Input.d.ts +1 -1
- package/Forms/Password/Password.d.ts +1 -1
- package/Forms/Radio/Radio.d.ts +1 -1
- package/Forms/Switch/Switch.d.ts +1 -1
- package/Forms/Textarea/Textarea.d.ts +1 -1
- package/Forms/Textarea/TextareaRich.d.ts +1 -1
- package/Link/Link.d.ts +1 -1
- package/Menu/MenuMui.d.ts +0 -35
- package/Menu/MenuMui.js +164 -77
- package/Menu/MenuMui.mjs +165 -75
- package/MenuItem/MenuItemMui.d.ts +0 -6
- package/MenuItem/MenuItemMui.js +31 -17
- package/MenuItem/MenuItemMui.mjs +32 -15
- package/Tabs/TabsMui.d.ts +287 -55
- package/Tabs/tw/bare.d.ts +311 -80
- package/Tabs/tw/material.d.ts +326 -136
- package/hooks/index.d.ts +1 -2
- package/hooks/index.js +1 -2
- package/hooks/index.mjs +1 -2
- package/hooks/useFocus.js +3 -3
- package/hooks/useFocus.mjs +3 -3
- package/hooks/useIsomorphicLayoutEffect.d.ts +1 -1
- package/hooks/useIsomorphicLayoutEffect.js +1 -1
- package/hooks/useIsomorphicLayoutEffect.mjs +1 -1
- package/hooks/useSpinDelay.d.ts +14 -0
- package/hooks/useSpinDelay.js +54 -0
- package/hooks/useSpinDelay.mjs +50 -0
- package/package.json +25 -22
- package/styles/theme--vanilla.d.ts +0 -1
- package/styles/theme--vanilla.js +15 -15
- package/styles/theme--vanilla.mjs +15 -14
package/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./useAsyncFn";
|
|
2
2
|
export * from "./useDateLocale";
|
|
3
|
-
export * from "./useEffectOnce";
|
|
4
3
|
export * from "./useFirstMountState";
|
|
5
4
|
export * from "./useFixedOffset";
|
|
6
5
|
export * from "./useFocus";
|
|
@@ -8,7 +7,6 @@ export * from "./useInterval";
|
|
|
8
7
|
export * from "./useIsomorphicLayoutEffect";
|
|
9
8
|
export * from "./useKeyUp";
|
|
10
9
|
export * from "./useMeasure";
|
|
11
|
-
export * from "./useMount";
|
|
12
10
|
export * from "./useMountedState";
|
|
13
11
|
export * from "./useNavigateAway";
|
|
14
12
|
export * from "./usePrevious";
|
|
@@ -16,6 +14,7 @@ export * from "./usePreviousRef";
|
|
|
16
14
|
export * from "./useScrollPosition";
|
|
17
15
|
export * from "./useScrollThreshold";
|
|
18
16
|
export * from "./useSmoothScroll";
|
|
17
|
+
export * from "./useSpinDelay";
|
|
19
18
|
export * from "./useTraceUpdate";
|
|
20
19
|
export * from "./useUpdateEffect";
|
|
21
20
|
export * from "./useWindowSize";
|
package/hooks/index.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./useAsyncFn"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./useDateLocale"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./useEffectOnce"), exports);
|
|
7
6
|
tslib_1.__exportStar(require("./useFirstMountState"), exports);
|
|
8
7
|
tslib_1.__exportStar(require("./useFixedOffset"), exports);
|
|
9
8
|
tslib_1.__exportStar(require("./useFocus"), exports);
|
|
@@ -11,7 +10,6 @@ tslib_1.__exportStar(require("./useInterval"), exports);
|
|
|
11
10
|
tslib_1.__exportStar(require("./useIsomorphicLayoutEffect"), exports);
|
|
12
11
|
tslib_1.__exportStar(require("./useKeyUp"), exports);
|
|
13
12
|
tslib_1.__exportStar(require("./useMeasure"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./useMount"), exports);
|
|
15
13
|
tslib_1.__exportStar(require("./useMountedState"), exports);
|
|
16
14
|
tslib_1.__exportStar(require("./useNavigateAway"), exports);
|
|
17
15
|
tslib_1.__exportStar(require("./usePrevious"), exports);
|
|
@@ -20,6 +18,7 @@ tslib_1.__exportStar(require("./useScrollPosition"), exports);
|
|
|
20
18
|
tslib_1.__exportStar(require("./useScrollThreshold"), exports);
|
|
21
19
|
// export * from "./useScrollTo";
|
|
22
20
|
tslib_1.__exportStar(require("./useSmoothScroll"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./useSpinDelay"), exports);
|
|
23
22
|
tslib_1.__exportStar(require("./useTraceUpdate"), exports);
|
|
24
23
|
tslib_1.__exportStar(require("./useUpdateEffect"), exports);
|
|
25
24
|
tslib_1.__exportStar(require("./useWindowSize"), exports);
|
package/hooks/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./useAsyncFn";
|
|
2
2
|
export * from "./useDateLocale";
|
|
3
|
-
export * from "./useEffectOnce";
|
|
4
3
|
export * from "./useFirstMountState";
|
|
5
4
|
export * from "./useFixedOffset";
|
|
6
5
|
export * from "./useFocus";
|
|
@@ -8,7 +7,6 @@ export * from "./useInterval";
|
|
|
8
7
|
export * from "./useIsomorphicLayoutEffect";
|
|
9
8
|
export * from "./useKeyUp";
|
|
10
9
|
export * from "./useMeasure";
|
|
11
|
-
export * from "./useMount";
|
|
12
10
|
export * from "./useMountedState";
|
|
13
11
|
export * from "./useNavigateAway";
|
|
14
12
|
export * from "./usePrevious";
|
|
@@ -17,6 +15,7 @@ export * from "./useScrollPosition";
|
|
|
17
15
|
export * from "./useScrollThreshold";
|
|
18
16
|
// export * from "./useScrollTo";
|
|
19
17
|
export * from "./useSmoothScroll";
|
|
18
|
+
export * from "./useSpinDelay";
|
|
20
19
|
export * from "./useTraceUpdate";
|
|
21
20
|
export * from "./useUpdateEffect";
|
|
22
21
|
export * from "./useWindowSize";
|
package/hooks/useFocus.js
CHANGED
|
@@ -6,11 +6,11 @@ var react_1 = require("react");
|
|
|
6
6
|
* @see https://stackoverflow.com/a/54159564/1938970
|
|
7
7
|
*/
|
|
8
8
|
var useFocus = function () {
|
|
9
|
-
var
|
|
9
|
+
var elementRef = (0, react_1.useRef)(null);
|
|
10
10
|
var setFocus = function () {
|
|
11
|
-
|
|
11
|
+
elementRef.current && elementRef.current.focus();
|
|
12
12
|
};
|
|
13
|
-
return [
|
|
13
|
+
return [elementRef, setFocus];
|
|
14
14
|
};
|
|
15
15
|
exports.useFocus = useFocus;
|
|
16
16
|
exports.default = exports.useFocus;
|
package/hooks/useFocus.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import { useRef } from "react";
|
|
|
3
3
|
* @see https://stackoverflow.com/a/54159564/1938970
|
|
4
4
|
*/
|
|
5
5
|
export var useFocus = function () {
|
|
6
|
-
var
|
|
6
|
+
var elementRef = useRef(null);
|
|
7
7
|
var setFocus = function () {
|
|
8
|
-
|
|
8
|
+
elementRef.current && elementRef.current.focus();
|
|
9
9
|
};
|
|
10
|
-
return [
|
|
10
|
+
return [elementRef, setFocus];
|
|
11
11
|
};
|
|
12
12
|
export default useFocus;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
/**
|
|
3
|
-
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/
|
|
3
|
+
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts)
|
|
4
4
|
*/
|
|
5
5
|
export declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
6
6
|
export default useIsomorphicLayoutEffect;
|
|
@@ -5,7 +5,7 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var react_1 = require("react");
|
|
6
6
|
var isBrowser_1 = tslib_1.__importDefault(require("@koine/utils/isBrowser"));
|
|
7
7
|
/**
|
|
8
|
-
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/
|
|
8
|
+
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts)
|
|
9
9
|
*/
|
|
10
10
|
exports.useIsomorphicLayoutEffect = isBrowser_1.default
|
|
11
11
|
? react_1.useLayoutEffect
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect } from "react";
|
|
2
2
|
import isBrowser from "@koine/utils/isBrowser";
|
|
3
3
|
/**
|
|
4
|
-
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/
|
|
4
|
+
* @borrows [streamich/react-use](https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts)
|
|
5
5
|
*/
|
|
6
6
|
export var useIsomorphicLayoutEffect = isBrowser
|
|
7
7
|
? useLayoutEffect
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps your booleans only returning true after the `delay`, and for a minimum
|
|
3
|
+
* time of `minDuration`. This way you're sure that you don't show unnecessary
|
|
4
|
+
* or very short living spinners.
|
|
5
|
+
*
|
|
6
|
+
* @borrows [smeijer/spin-delay](https://github.com/smeijer/spin-delay)
|
|
7
|
+
*
|
|
8
|
+
* - Smaller footprint and options object as argument
|
|
9
|
+
*
|
|
10
|
+
* @param delay [500]
|
|
11
|
+
* @param minDuration [200]
|
|
12
|
+
*/
|
|
13
|
+
export declare function useSpinDelay(loading: boolean, delay?: number, minDuration?: number): boolean;
|
|
14
|
+
export default useSpinDelay;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSpinDelay = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var State;
|
|
6
|
+
(function (State) {
|
|
7
|
+
State[State["IDLE"] = 0] = "IDLE";
|
|
8
|
+
State[State["DELAY"] = 1] = "DELAY";
|
|
9
|
+
State[State["DISPLAY"] = 2] = "DISPLAY";
|
|
10
|
+
State[State["EXPIRE"] = 3] = "EXPIRE";
|
|
11
|
+
})(State || (State = {}));
|
|
12
|
+
/**
|
|
13
|
+
* Wraps your booleans only returning true after the `delay`, and for a minimum
|
|
14
|
+
* time of `minDuration`. This way you're sure that you don't show unnecessary
|
|
15
|
+
* or very short living spinners.
|
|
16
|
+
*
|
|
17
|
+
* @borrows [smeijer/spin-delay](https://github.com/smeijer/spin-delay)
|
|
18
|
+
*
|
|
19
|
+
* - Smaller footprint and options object as argument
|
|
20
|
+
*
|
|
21
|
+
* @param delay [500]
|
|
22
|
+
* @param minDuration [200]
|
|
23
|
+
*/
|
|
24
|
+
function useSpinDelay(loading, delay, minDuration) {
|
|
25
|
+
if (delay === void 0) { delay = 500; }
|
|
26
|
+
if (minDuration === void 0) { minDuration = 200; }
|
|
27
|
+
var _a = (0, react_1.useState)(State.IDLE), state = _a[0], setState = _a[1];
|
|
28
|
+
var timeout = (0, react_1.useRef)();
|
|
29
|
+
(0, react_1.useEffect)(function () {
|
|
30
|
+
if (loading && state === State.IDLE) {
|
|
31
|
+
clearTimeout(timeout.current);
|
|
32
|
+
timeout.current = setTimeout(function () {
|
|
33
|
+
if (!loading) {
|
|
34
|
+
return setState(State.IDLE);
|
|
35
|
+
}
|
|
36
|
+
timeout.current = setTimeout(function () {
|
|
37
|
+
setState(State.EXPIRE);
|
|
38
|
+
}, minDuration);
|
|
39
|
+
setState(State.DISPLAY);
|
|
40
|
+
}, delay);
|
|
41
|
+
setState(State.DELAY);
|
|
42
|
+
}
|
|
43
|
+
if (!loading && state !== State.DISPLAY) {
|
|
44
|
+
clearTimeout(timeout.current);
|
|
45
|
+
setState(State.IDLE);
|
|
46
|
+
}
|
|
47
|
+
}, [loading, state, delay, minDuration]);
|
|
48
|
+
(0, react_1.useEffect)(function () {
|
|
49
|
+
return function () { return clearTimeout(timeout.current); };
|
|
50
|
+
}, []);
|
|
51
|
+
return state === State.DISPLAY || state === State.EXPIRE;
|
|
52
|
+
}
|
|
53
|
+
exports.useSpinDelay = useSpinDelay;
|
|
54
|
+
exports.default = useSpinDelay;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useEffect, useState, useRef } from "react";
|
|
2
|
+
var State;
|
|
3
|
+
(function (State) {
|
|
4
|
+
State[State["IDLE"] = 0] = "IDLE";
|
|
5
|
+
State[State["DELAY"] = 1] = "DELAY";
|
|
6
|
+
State[State["DISPLAY"] = 2] = "DISPLAY";
|
|
7
|
+
State[State["EXPIRE"] = 3] = "EXPIRE";
|
|
8
|
+
})(State || (State = {}));
|
|
9
|
+
/**
|
|
10
|
+
* Wraps your booleans only returning true after the `delay`, and for a minimum
|
|
11
|
+
* time of `minDuration`. This way you're sure that you don't show unnecessary
|
|
12
|
+
* or very short living spinners.
|
|
13
|
+
*
|
|
14
|
+
* @borrows [smeijer/spin-delay](https://github.com/smeijer/spin-delay)
|
|
15
|
+
*
|
|
16
|
+
* - Smaller footprint and options object as argument
|
|
17
|
+
*
|
|
18
|
+
* @param delay [500]
|
|
19
|
+
* @param minDuration [200]
|
|
20
|
+
*/
|
|
21
|
+
export function useSpinDelay(loading, delay, minDuration) {
|
|
22
|
+
if (delay === void 0) { delay = 500; }
|
|
23
|
+
if (minDuration === void 0) { minDuration = 200; }
|
|
24
|
+
var _a = useState(State.IDLE), state = _a[0], setState = _a[1];
|
|
25
|
+
var timeout = useRef();
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
if (loading && state === State.IDLE) {
|
|
28
|
+
clearTimeout(timeout.current);
|
|
29
|
+
timeout.current = setTimeout(function () {
|
|
30
|
+
if (!loading) {
|
|
31
|
+
return setState(State.IDLE);
|
|
32
|
+
}
|
|
33
|
+
timeout.current = setTimeout(function () {
|
|
34
|
+
setState(State.EXPIRE);
|
|
35
|
+
}, minDuration);
|
|
36
|
+
setState(State.DISPLAY);
|
|
37
|
+
}, delay);
|
|
38
|
+
setState(State.DELAY);
|
|
39
|
+
}
|
|
40
|
+
if (!loading && state !== State.DISPLAY) {
|
|
41
|
+
clearTimeout(timeout.current);
|
|
42
|
+
setState(State.IDLE);
|
|
43
|
+
}
|
|
44
|
+
}, [loading, state, delay, minDuration]);
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
return function () { return clearTimeout(timeout.current); };
|
|
47
|
+
}, []);
|
|
48
|
+
return state === State.DISPLAY || state === State.EXPIRE;
|
|
49
|
+
}
|
|
50
|
+
export default useSpinDelay;
|
package/package.json
CHANGED
|
@@ -45,29 +45,32 @@
|
|
|
45
45
|
"optional": true
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
"
|
|
49
|
-
"types": "./index.d.ts",
|
|
50
|
-
"dependencies": {},
|
|
51
|
-
"peerDependencies": {
|
|
52
|
-
"styled-components": "5.3.6",
|
|
53
|
-
"framer-motion": "8.5.5",
|
|
54
|
-
"react": "18.2.0",
|
|
55
|
-
"@mui/base": "5.0.0-alpha.115",
|
|
56
|
-
"@koine/utils": "1.1.11",
|
|
57
|
-
"react-icons": "4.7.1",
|
|
58
|
-
"date-fns": "2.29.3",
|
|
59
|
-
"react-swipeable": "7.0.0",
|
|
60
|
-
"clsx": "1.2.1",
|
|
61
|
-
"ts-debounce": "4.0.0",
|
|
62
|
-
"type-fest": "3.5.3",
|
|
63
|
-
"@tiptap/react": "2.0.0-beta.209",
|
|
64
|
-
"@tiptap/starter-kit": "2.0.0-beta.209",
|
|
48
|
+
"dependencies": {
|
|
65
49
|
"@kuus/yup": "1.0.0-beta.7",
|
|
66
|
-
"
|
|
67
|
-
"@mui/utils": "5.11.
|
|
68
|
-
"react
|
|
69
|
-
"
|
|
50
|
+
"@mui/base": "5.0.0-alpha.118",
|
|
51
|
+
"@mui/utils": "5.11.9",
|
|
52
|
+
"@tiptap/react": "2.0.0-beta.217",
|
|
53
|
+
"@tiptap/starter-kit": "2.0.0-beta.217",
|
|
54
|
+
"clsx": "1.2.1",
|
|
55
|
+
"date-fns": "^2.29.3",
|
|
56
|
+
"framer-motion": "^9.0.4",
|
|
57
|
+
"next": "^13.1.6",
|
|
58
|
+
"react": "^18.2.0",
|
|
59
|
+
"react-dom": "^18.2.0",
|
|
60
|
+
"react-hook-form": "^7.43.1",
|
|
61
|
+
"react-icons": "^4.7.1",
|
|
62
|
+
"react-is": "^18.2.0",
|
|
63
|
+
"react-swipeable": "^7.0.0",
|
|
64
|
+
"styled-components": "^5.3.6",
|
|
65
|
+
"ts-debounce": "^4.0.0",
|
|
66
|
+
"tslib": "^2.5.0",
|
|
67
|
+
"type-fest": "^3.5.7"
|
|
70
68
|
},
|
|
71
|
-
"
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"@koine/utils": "1.1.14"
|
|
71
|
+
},
|
|
72
|
+
"main": "./index.js",
|
|
73
|
+
"types": "./index.d.ts",
|
|
74
|
+
"version": "1.1.14",
|
|
72
75
|
"module": "./index.mjs"
|
|
73
76
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const THEME_KEY = "theme";
|
|
3
3
|
export declare const THEME_DEFAULT: ThemeVanillaValue;
|
|
4
|
-
export declare const getInitialThemeFromRequest: (cookie?: string) => ThemeVanillaValue;
|
|
5
4
|
export declare const getInitialThemeFromClient: () => ThemeVanillaValue;
|
|
6
5
|
export type ThemeCookie = {
|
|
7
6
|
[THEME_KEY]: ThemeVanillaValue;
|
package/styles/theme--vanilla.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ThemeVanillaProvider = exports.ThemeVanillaContext = exports.getInitialThemeFromClient = exports.
|
|
3
|
+
exports.ThemeVanillaProvider = exports.ThemeVanillaContext = exports.getInitialThemeFromClient = exports.THEME_DEFAULT = exports.THEME_KEY = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
var react_1 = require("react");
|
|
7
7
|
var isBrowser_1 = tslib_1.__importDefault(require("@koine/utils/isBrowser"));
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var useMount_1 = tslib_1.__importDefault(require("../hooks/useMount"));
|
|
8
|
+
// import setCookie from "@koine/utils/setCookie";
|
|
9
|
+
// import parseCookie from "@koine/utils/parseCookie";
|
|
11
10
|
var useUpdateEffect_1 = tslib_1.__importDefault(require("../hooks/useUpdateEffect"));
|
|
12
11
|
exports.THEME_KEY = "theme";
|
|
13
12
|
exports.THEME_DEFAULT = "light";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
13
|
+
// export const getInitialThemeFromRequest = (
|
|
14
|
+
// cookie?: string
|
|
15
|
+
// ): ThemeVanillaValue => {
|
|
16
|
+
// if (cookie) {
|
|
17
|
+
// const parsed = parseCookie<ThemeCookie>(cookie);
|
|
18
|
+
// return parsed?.theme;
|
|
19
|
+
// }
|
|
20
|
+
// return THEME_DEFAULT;
|
|
21
|
+
// };
|
|
22
22
|
var getInitialThemeFromClient = function () {
|
|
23
23
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
24
24
|
var storedPrefs = window.localStorage.getItem(exports.THEME_KEY);
|
|
@@ -49,13 +49,13 @@ var ThemeVanillaProvider = function (_a) {
|
|
|
49
49
|
root.classList.remove(isDark ? "light" : "dark");
|
|
50
50
|
root.classList.add(rawTheme);
|
|
51
51
|
localStorage.setItem(exports.THEME_KEY, rawTheme);
|
|
52
|
-
|
|
52
|
+
// setCookie(THEME_KEY, rawTheme);
|
|
53
53
|
};
|
|
54
|
-
(0,
|
|
54
|
+
(0, react_1.useEffect)(function () {
|
|
55
55
|
var theme = (0, exports.getInitialThemeFromClient)();
|
|
56
56
|
setTheme(theme);
|
|
57
57
|
rawSetTheme(theme);
|
|
58
|
-
});
|
|
58
|
+
}, []);
|
|
59
59
|
(0, useUpdateEffect_1.default)(function () {
|
|
60
60
|
rawSetTheme(theme);
|
|
61
61
|
}, [theme]);
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { __assign } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useState } from "react";
|
|
3
|
+
import { createContext, useEffect, useState } from "react";
|
|
4
4
|
import isBrowser from "@koine/utils/isBrowser";
|
|
5
|
-
import setCookie from "@koine/utils/setCookie";
|
|
6
|
-
import parseCookie from "@koine/utils/parseCookie";
|
|
7
|
-
import useMount from "../hooks/useMount";
|
|
5
|
+
// import setCookie from "@koine/utils/setCookie";
|
|
6
|
+
// import parseCookie from "@koine/utils/parseCookie";
|
|
8
7
|
import useUpdateEffect from "../hooks/useUpdateEffect";
|
|
9
8
|
export var THEME_KEY = "theme";
|
|
10
9
|
export var THEME_DEFAULT = "light";
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
10
|
+
// export const getInitialThemeFromRequest = (
|
|
11
|
+
// cookie?: string
|
|
12
|
+
// ): ThemeVanillaValue => {
|
|
13
|
+
// if (cookie) {
|
|
14
|
+
// const parsed = parseCookie<ThemeCookie>(cookie);
|
|
15
|
+
// return parsed?.theme;
|
|
16
|
+
// }
|
|
17
|
+
// return THEME_DEFAULT;
|
|
18
|
+
// };
|
|
18
19
|
export var getInitialThemeFromClient = function () {
|
|
19
20
|
if (typeof window !== "undefined" && window.localStorage) {
|
|
20
21
|
var storedPrefs = window.localStorage.getItem(THEME_KEY);
|
|
@@ -44,13 +45,13 @@ export var ThemeVanillaProvider = function (_a) {
|
|
|
44
45
|
root.classList.remove(isDark ? "light" : "dark");
|
|
45
46
|
root.classList.add(rawTheme);
|
|
46
47
|
localStorage.setItem(THEME_KEY, rawTheme);
|
|
47
|
-
setCookie(THEME_KEY, rawTheme);
|
|
48
|
+
// setCookie(THEME_KEY, rawTheme);
|
|
48
49
|
};
|
|
49
|
-
|
|
50
|
+
useEffect(function () {
|
|
50
51
|
var theme = getInitialThemeFromClient();
|
|
51
52
|
setTheme(theme);
|
|
52
53
|
rawSetTheme(theme);
|
|
53
|
-
});
|
|
54
|
+
}, []);
|
|
54
55
|
useUpdateEffect(function () {
|
|
55
56
|
rawSetTheme(theme);
|
|
56
57
|
}, [theme]);
|