@koine/react 1.1.5 → 1.1.7
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/Dialog/tw/bare.d.ts +6 -6
- package/Dialog/tw/elegant.d.ts +6 -6
- package/Dialog/tw/framer.d.ts +2 -2
- package/Dialog/tw/framerMaterial.d.ts +4 -4
- package/Dialog/tw/material.d.ts +6 -6
- 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/Tabs/tw/material.d.ts +6 -6
- package/hooks/useFixedOffset.d.ts +5 -1
- package/hooks/useFixedOffset.js +15 -12
- package/hooks/useMeasure.js +6 -6
- package/hooks/useScrollPosition.d.ts +1 -1
- package/hooks/useScrollPosition.js +9 -22
- package/hooks/useScrollThreshold.js +3 -3
- package/hooks/useSmoothScroll.d.ts +7 -1
- package/hooks/useSmoothScroll.js +19 -7
- package/hooks/useWindowSize.d.ts +11 -1
- package/hooks/useWindowSize.js +20 -7
- package/node/hooks/useFixedOffset.js +14 -11
- package/node/hooks/useMeasure.js +4 -4
- package/node/hooks/useScrollPosition.js +9 -22
- package/node/hooks/useScrollThreshold.js +2 -2
- package/node/hooks/useSmoothScroll.js +18 -6
- package/node/hooks/useWindowSize.js +19 -6
- package/package.json +3 -3
- package/Favicon/FaviconTags.d.ts +0 -18
- package/Favicon/FaviconTags.js +0 -15
- package/Favicon/index.d.ts +0 -1
- package/Favicon/index.js +0 -1
- package/Favicon/package.json +0 -6
- package/hooks/useId.d.ts +0 -5
- package/hooks/useId.js +0 -9
|
@@ -11,5 +11,5 @@ type ElementRef = React.MutableRefObject<HTMLElement | undefined>;
|
|
|
11
11
|
* - reused internal helper functions
|
|
12
12
|
* - compacted object arguments in functions as plain argument list to improve compression
|
|
13
13
|
*/
|
|
14
|
-
export declare const useScrollPosition: (effect: (currentPosition: Position, prevPosition: Position) => void, deps?: import("react").DependencyList, element?: ElementRef,
|
|
14
|
+
export declare const useScrollPosition: (effect: (currentPosition: Position, prevPosition: Position) => void, deps?: import("react").DependencyList, element?: ElementRef, boundingElement?: ElementRef, wait?: number) => void;
|
|
15
15
|
export default useScrollPosition;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { useRef } from "react";
|
|
2
2
|
import { isBrowser } from "@koine/utils";
|
|
3
3
|
import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
4
|
+
import { listenScroll } from "@koine/dom";
|
|
4
5
|
var zeroPosition = { x: 0, y: 0 };
|
|
5
6
|
var getClientRect = function (element) {
|
|
6
7
|
return element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
|
|
7
8
|
};
|
|
8
|
-
var getScrollPosition = function (element,
|
|
9
|
+
var getScrollPosition = function (element, boundingElement) {
|
|
9
10
|
if (!isBrowser) {
|
|
10
11
|
return zeroPosition;
|
|
11
12
|
}
|
|
12
|
-
if (
|
|
13
|
+
if (!boundingElement) {
|
|
13
14
|
return { x: window.scrollX, y: window.scrollY };
|
|
14
15
|
}
|
|
15
16
|
var targetPosition = getClientRect((element === null || element === void 0 ? void 0 : element.current) || document.body);
|
|
16
|
-
var containerPosition = getClientRect(boundingElement
|
|
17
|
+
var containerPosition = getClientRect(boundingElement.current);
|
|
17
18
|
if (!targetPosition) {
|
|
18
19
|
return zeroPosition;
|
|
19
20
|
}
|
|
@@ -31,18 +32,17 @@ var getScrollPosition = function (element, useWindow, boundingElement) {
|
|
|
31
32
|
* - reused internal helper functions
|
|
32
33
|
* - compacted object arguments in functions as plain argument list to improve compression
|
|
33
34
|
*/
|
|
34
|
-
export var useScrollPosition = function (effect, deps, element,
|
|
35
|
+
export var useScrollPosition = function (effect, deps, element, boundingElement, wait) {
|
|
35
36
|
if (deps === void 0) { deps = []; }
|
|
36
|
-
var position = useRef(getScrollPosition(null,
|
|
37
|
+
var position = useRef(getScrollPosition(null, boundingElement));
|
|
37
38
|
var throttleTimeout = null;
|
|
38
39
|
var callBack = function () {
|
|
39
|
-
var current = getScrollPosition(element,
|
|
40
|
+
var current = getScrollPosition(element, boundingElement);
|
|
40
41
|
effect(current, position.current);
|
|
41
42
|
position.current = current;
|
|
42
43
|
throttleTimeout = null;
|
|
43
44
|
};
|
|
44
45
|
useIsomorphicLayoutEffect(function () {
|
|
45
|
-
var _a;
|
|
46
46
|
if (!isBrowser) {
|
|
47
47
|
return undefined;
|
|
48
48
|
}
|
|
@@ -56,22 +56,9 @@ export var useScrollPosition = function (effect, deps, element, useWindow, wait,
|
|
|
56
56
|
callBack();
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
|
|
60
|
-
(_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.addEventListener("scroll", handleScroll, {
|
|
61
|
-
passive: true,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
66
|
-
}
|
|
59
|
+
var listener = listenScroll(handleScroll, boundingElement === null || boundingElement === void 0 ? void 0 : boundingElement.current);
|
|
67
60
|
return function () {
|
|
68
|
-
|
|
69
|
-
if (boundingElement) {
|
|
70
|
-
(_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("scroll", handleScroll);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
window.removeEventListener("scroll", handleScroll);
|
|
74
|
-
}
|
|
61
|
+
listener();
|
|
75
62
|
if (throttleTimeout) {
|
|
76
63
|
clearTimeout(throttleTimeout);
|
|
77
64
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from "react";
|
|
2
2
|
import { noop } from "@koine/utils";
|
|
3
|
-
import {
|
|
3
|
+
import { listenScroll } from "@koine/dom";
|
|
4
4
|
export var useScrollThreshold = function (threshold, callback) {
|
|
5
5
|
var _a = useState(false), isBelow = _a[0], setIsBelow = _a[1];
|
|
6
6
|
var handler = useCallback(function () {
|
|
@@ -16,8 +16,8 @@ export var useScrollThreshold = function (threshold, callback) {
|
|
|
16
16
|
}, [threshold, callback]);
|
|
17
17
|
useEffect(function () {
|
|
18
18
|
if (threshold) {
|
|
19
|
-
// const listener =
|
|
20
|
-
var listener =
|
|
19
|
+
// const listener = listenScrollThrottled(0, handler, 50);
|
|
20
|
+
var listener = listenScroll(handler);
|
|
21
21
|
handler();
|
|
22
22
|
return listener;
|
|
23
23
|
}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param disregardAutomaticFixedOffset When the `to` scroll argument is a DOM
|
|
4
|
+
* selector we will keep into account the _fixedOffset_ despite this option.
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function useSmoothScroll(disregardAutomaticFixedOffset?: boolean): (to?: number | string, customOffset?: number, callback?: () => void, fallbackTimeout?: number, behavior?: ScrollBehavior) => void;
|
|
2
8
|
export default useSmoothScroll;
|
package/hooks/useSmoothScroll.js
CHANGED
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
import { isNumber } from "@koine/utils";
|
|
3
|
-
import { scrollTo } from "@koine/dom";
|
|
3
|
+
import { getOffsetTopSlim, scrollTo } from "@koine/dom";
|
|
4
4
|
import { useFixedOffset } from "./useFixedOffset";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param disregardAutomaticFixedOffset When the `to` scroll argument is a DOM
|
|
8
|
+
* selector we will keep into account the _fixedOffset_ despite this option.
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export function useSmoothScroll(disregardAutomaticFixedOffset) {
|
|
6
12
|
var fixedOffset = useFixedOffset();
|
|
7
|
-
var scroll = useCallback(function (to,
|
|
8
|
-
if (offset === void 0) { offset = 0; }
|
|
13
|
+
var scroll = useCallback(function (to, customOffset, callback, fallbackTimeout, behavior) {
|
|
9
14
|
var top = undefined;
|
|
15
|
+
var toIsElement = false;
|
|
10
16
|
if (isNumber(to)) {
|
|
11
17
|
top = to;
|
|
12
18
|
}
|
|
13
19
|
else if (to) {
|
|
14
20
|
var el = document.getElementById(to);
|
|
15
21
|
if (el) {
|
|
16
|
-
top = el
|
|
22
|
+
top = getOffsetTopSlim(el) - fixedOffset.current;
|
|
23
|
+
toIsElement = true;
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
if (isNumber(top)) {
|
|
20
|
-
top =
|
|
27
|
+
top =
|
|
28
|
+
top +
|
|
29
|
+
(customOffset || 0) +
|
|
30
|
+
(disregardAutomaticFixedOffset || toIsElement
|
|
31
|
+
? 0
|
|
32
|
+
: fixedOffset.current);
|
|
21
33
|
scrollTo(top, callback, fallbackTimeout, behavior);
|
|
22
34
|
}
|
|
23
|
-
}, [
|
|
35
|
+
}, [disregardAutomaticFixedOffset, fixedOffset]);
|
|
24
36
|
return scroll;
|
|
25
37
|
}
|
|
26
38
|
export default useSmoothScroll;
|
package/hooks/useWindowSize.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { debounce } from "@koine/utils";
|
|
2
|
+
/**
|
|
3
|
+
* # Use `window` size
|
|
4
|
+
*
|
|
5
|
+
* @param args Optionally pass {@link debounce} arguments (`wait` and `immediate`)
|
|
6
|
+
*
|
|
7
|
+
* @returns An array with:
|
|
8
|
+
* 1) _width_: using `window.innerWidth`
|
|
9
|
+
* 2) _height_: using `window.innerHeight`
|
|
10
|
+
*/
|
|
11
|
+
export declare function useWindowSize(wait?: Parameters<typeof debounce>[1], immediate?: Parameters<typeof debounce>[2]): readonly [number, number];
|
|
2
12
|
export default useWindowSize;
|
package/hooks/useWindowSize.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { listenResize, listenResizeDebounced } from "@koine/dom";
|
|
3
|
+
/**
|
|
4
|
+
* # Use `window` size
|
|
5
|
+
*
|
|
6
|
+
* @param args Optionally pass {@link debounce} arguments (`wait` and `immediate`)
|
|
7
|
+
*
|
|
8
|
+
* @returns An array with:
|
|
9
|
+
* 1) _width_: using `window.innerWidth`
|
|
10
|
+
* 2) _height_: using `window.innerHeight`
|
|
11
|
+
*/
|
|
12
|
+
export function useWindowSize(wait, immediate) {
|
|
13
|
+
var _a = useState(0), width = _a[0], widthSet = _a[1];
|
|
14
|
+
var _b = useState(0), height = _b[0], heightSet = _b[1];
|
|
5
15
|
useEffect(function () {
|
|
6
16
|
function updateSize() {
|
|
7
|
-
|
|
17
|
+
widthSet(window.innerWidth);
|
|
18
|
+
heightSet(window.innerHeight);
|
|
8
19
|
}
|
|
9
|
-
var listener =
|
|
20
|
+
var listener = wait
|
|
21
|
+
? listenResizeDebounced(0, updateSize, wait, immediate)
|
|
22
|
+
: listenResize(updateSize);
|
|
10
23
|
updateSize();
|
|
11
24
|
return listener;
|
|
12
|
-
}, []);
|
|
13
|
-
return
|
|
25
|
+
}, [wait, immediate]);
|
|
26
|
+
return [width, height];
|
|
14
27
|
}
|
|
15
28
|
export default useWindowSize;
|
|
@@ -5,16 +5,19 @@ var react_1 = require("react");
|
|
|
5
5
|
var dom_1 = require("@koine/dom");
|
|
6
6
|
var utils_1 = require("@koine/utils");
|
|
7
7
|
var useIsomorphicLayoutEffect_1 = require("./useIsomorphicLayoutEffect");
|
|
8
|
-
var observer;
|
|
9
8
|
var inject = function (value) {
|
|
10
9
|
(0, dom_1.injectCss)("useFixedOffset", "html{scroll-padding-top: ".concat(value, "px}"));
|
|
11
10
|
};
|
|
12
11
|
/**
|
|
12
|
+
* # Use fixed offset
|
|
13
|
+
*
|
|
13
14
|
* Maybe use [ResizeObserver polyfill](https://github.com/juggle/resize-observer)
|
|
14
15
|
*
|
|
15
16
|
* @see https://web.dev/resize-observer/
|
|
17
|
+
*
|
|
18
|
+
* @param selector By default `[data-fixed]`: anyhting with the data attribute `data-fixed`
|
|
16
19
|
*/
|
|
17
|
-
function useFixedOffset() {
|
|
20
|
+
function useFixedOffset(selector) {
|
|
18
21
|
var fixedOffset = (0, react_1.useRef)(0);
|
|
19
22
|
(0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(function () {
|
|
20
23
|
var update = function () {
|
|
@@ -25,30 +28,30 @@ function useFixedOffset() {
|
|
|
25
28
|
inject(newFixedOffset);
|
|
26
29
|
};
|
|
27
30
|
update();
|
|
28
|
-
if (
|
|
31
|
+
if (ResizeObserver) {
|
|
29
32
|
// const elements = $$("[data-fixed]");
|
|
30
|
-
|
|
33
|
+
var observer_1 = new ResizeObserver(function (entries) {
|
|
31
34
|
var newFixedOffset = 0;
|
|
32
35
|
entries.forEach(function (entry) {
|
|
33
36
|
newFixedOffset += entry.contentRect.height;
|
|
34
37
|
});
|
|
35
38
|
fixedOffset.current = newFixedOffset;
|
|
36
|
-
var updateOnResize = (0, utils_1.debounce)(function () { return inject(newFixedOffset); }, 400);
|
|
39
|
+
var updateOnResize = (0, utils_1.debounce)(function () { return inject(newFixedOffset); }, 400, true);
|
|
37
40
|
updateOnResize();
|
|
38
41
|
});
|
|
39
|
-
(0, dom_1.$each)("[data-fixed]", function ($el) {
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
+
(0, dom_1.$each)(selector || "[data-fixed]", function ($el) {
|
|
43
|
+
if (observer_1)
|
|
44
|
+
observer_1.observe($el);
|
|
42
45
|
});
|
|
43
46
|
return function () {
|
|
44
|
-
|
|
47
|
+
observer_1 === null || observer_1 === void 0 ? void 0 : observer_1.disconnect();
|
|
45
48
|
};
|
|
46
49
|
}
|
|
47
50
|
else {
|
|
48
|
-
var listener = (0, dom_1.
|
|
51
|
+
var listener = (0, dom_1.listenResizeDebounced)(0, update);
|
|
49
52
|
return listener;
|
|
50
53
|
}
|
|
51
|
-
}, []);
|
|
54
|
+
}, [selector]);
|
|
52
55
|
return fixedOffset;
|
|
53
56
|
}
|
|
54
57
|
exports.useFixedOffset = useFixedOffset;
|
package/node/hooks/useMeasure.js
CHANGED
|
@@ -137,15 +137,15 @@ function useMeasure(options) {
|
|
|
137
137
|
// });
|
|
138
138
|
(0, react_1.useEffect)(function () {
|
|
139
139
|
if (scroll) {
|
|
140
|
-
var listener = (0, dom_1.
|
|
140
|
+
var listener = (0, dom_1.listenScrollDebounced)(0, forceRefresh, 100);
|
|
141
141
|
return listener;
|
|
142
142
|
}
|
|
143
|
-
return
|
|
143
|
+
return utils_1.noop;
|
|
144
144
|
}, [scroll, forceRefresh]);
|
|
145
145
|
(0, react_1.useEffect)(function () {
|
|
146
|
-
// const listener =
|
|
146
|
+
// const listener = listenResizeDebounced(onWindowResize);
|
|
147
147
|
// return listener;
|
|
148
|
-
var listener = (0, dom_1.
|
|
148
|
+
var listener = (0, dom_1.listenResizeDebounced)(0, forceRefresh, 100);
|
|
149
149
|
return listener;
|
|
150
150
|
}, [forceRefresh]);
|
|
151
151
|
// respond to changes that are relevant for the listeners
|
|
@@ -4,19 +4,20 @@ exports.useScrollPosition = void 0;
|
|
|
4
4
|
var react_1 = require("react");
|
|
5
5
|
var utils_1 = require("@koine/utils");
|
|
6
6
|
var useIsomorphicLayoutEffect_1 = require("./useIsomorphicLayoutEffect");
|
|
7
|
+
var dom_1 = require("@koine/dom");
|
|
7
8
|
var zeroPosition = { x: 0, y: 0 };
|
|
8
9
|
var getClientRect = function (element) {
|
|
9
10
|
return element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
|
|
10
11
|
};
|
|
11
|
-
var getScrollPosition = function (element,
|
|
12
|
+
var getScrollPosition = function (element, boundingElement) {
|
|
12
13
|
if (!utils_1.isBrowser) {
|
|
13
14
|
return zeroPosition;
|
|
14
15
|
}
|
|
15
|
-
if (
|
|
16
|
+
if (!boundingElement) {
|
|
16
17
|
return { x: window.scrollX, y: window.scrollY };
|
|
17
18
|
}
|
|
18
19
|
var targetPosition = getClientRect((element === null || element === void 0 ? void 0 : element.current) || document.body);
|
|
19
|
-
var containerPosition = getClientRect(boundingElement
|
|
20
|
+
var containerPosition = getClientRect(boundingElement.current);
|
|
20
21
|
if (!targetPosition) {
|
|
21
22
|
return zeroPosition;
|
|
22
23
|
}
|
|
@@ -34,18 +35,17 @@ var getScrollPosition = function (element, useWindow, boundingElement) {
|
|
|
34
35
|
* - reused internal helper functions
|
|
35
36
|
* - compacted object arguments in functions as plain argument list to improve compression
|
|
36
37
|
*/
|
|
37
|
-
var useScrollPosition = function (effect, deps, element,
|
|
38
|
+
var useScrollPosition = function (effect, deps, element, boundingElement, wait) {
|
|
38
39
|
if (deps === void 0) { deps = []; }
|
|
39
|
-
var position = (0, react_1.useRef)(getScrollPosition(null,
|
|
40
|
+
var position = (0, react_1.useRef)(getScrollPosition(null, boundingElement));
|
|
40
41
|
var throttleTimeout = null;
|
|
41
42
|
var callBack = function () {
|
|
42
|
-
var current = getScrollPosition(element,
|
|
43
|
+
var current = getScrollPosition(element, boundingElement);
|
|
43
44
|
effect(current, position.current);
|
|
44
45
|
position.current = current;
|
|
45
46
|
throttleTimeout = null;
|
|
46
47
|
};
|
|
47
48
|
(0, useIsomorphicLayoutEffect_1.useIsomorphicLayoutEffect)(function () {
|
|
48
|
-
var _a;
|
|
49
49
|
if (!utils_1.isBrowser) {
|
|
50
50
|
return undefined;
|
|
51
51
|
}
|
|
@@ -59,22 +59,9 @@ var useScrollPosition = function (effect, deps, element, useWindow, wait, boundi
|
|
|
59
59
|
callBack();
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
(_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.addEventListener("scroll", handleScroll, {
|
|
64
|
-
passive: true,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
69
|
-
}
|
|
62
|
+
var listener = (0, dom_1.listenScroll)(handleScroll, boundingElement === null || boundingElement === void 0 ? void 0 : boundingElement.current);
|
|
70
63
|
return function () {
|
|
71
|
-
|
|
72
|
-
if (boundingElement) {
|
|
73
|
-
(_a = boundingElement.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("scroll", handleScroll);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
window.removeEventListener("scroll", handleScroll);
|
|
77
|
-
}
|
|
64
|
+
listener();
|
|
78
65
|
if (throttleTimeout) {
|
|
79
66
|
clearTimeout(throttleTimeout);
|
|
80
67
|
}
|
|
@@ -19,8 +19,8 @@ var useScrollThreshold = function (threshold, callback) {
|
|
|
19
19
|
}, [threshold, callback]);
|
|
20
20
|
(0, react_1.useEffect)(function () {
|
|
21
21
|
if (threshold) {
|
|
22
|
-
// const listener =
|
|
23
|
-
var listener = (0, dom_1.
|
|
22
|
+
// const listener = listenScrollThrottled(0, handler, 50);
|
|
23
|
+
var listener = (0, dom_1.listenScroll)(handler);
|
|
24
24
|
handler();
|
|
25
25
|
return listener;
|
|
26
26
|
}
|
|
@@ -5,25 +5,37 @@ var react_1 = require("react");
|
|
|
5
5
|
var utils_1 = require("@koine/utils");
|
|
6
6
|
var dom_1 = require("@koine/dom");
|
|
7
7
|
var useFixedOffset_1 = require("./useFixedOffset");
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param disregardAutomaticFixedOffset When the `to` scroll argument is a DOM
|
|
11
|
+
* selector we will keep into account the _fixedOffset_ despite this option.
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
function useSmoothScroll(disregardAutomaticFixedOffset) {
|
|
9
15
|
var fixedOffset = (0, useFixedOffset_1.useFixedOffset)();
|
|
10
|
-
var scroll = (0, react_1.useCallback)(function (to,
|
|
11
|
-
if (offset === void 0) { offset = 0; }
|
|
16
|
+
var scroll = (0, react_1.useCallback)(function (to, customOffset, callback, fallbackTimeout, behavior) {
|
|
12
17
|
var top = undefined;
|
|
18
|
+
var toIsElement = false;
|
|
13
19
|
if ((0, utils_1.isNumber)(to)) {
|
|
14
20
|
top = to;
|
|
15
21
|
}
|
|
16
22
|
else if (to) {
|
|
17
23
|
var el = document.getElementById(to);
|
|
18
24
|
if (el) {
|
|
19
|
-
top =
|
|
25
|
+
top = (0, dom_1.getOffsetTopSlim)(el) - fixedOffset.current;
|
|
26
|
+
toIsElement = true;
|
|
20
27
|
}
|
|
21
28
|
}
|
|
22
29
|
if ((0, utils_1.isNumber)(top)) {
|
|
23
|
-
top =
|
|
30
|
+
top =
|
|
31
|
+
top +
|
|
32
|
+
(customOffset || 0) +
|
|
33
|
+
(disregardAutomaticFixedOffset || toIsElement
|
|
34
|
+
? 0
|
|
35
|
+
: fixedOffset.current);
|
|
24
36
|
(0, dom_1.scrollTo)(top, callback, fallbackTimeout, behavior);
|
|
25
37
|
}
|
|
26
|
-
}, [
|
|
38
|
+
}, [disregardAutomaticFixedOffset, fixedOffset]);
|
|
27
39
|
return scroll;
|
|
28
40
|
}
|
|
29
41
|
exports.useSmoothScroll = useSmoothScroll;
|
|
@@ -3,17 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useWindowSize = void 0;
|
|
4
4
|
var react_1 = require("react");
|
|
5
5
|
var dom_1 = require("@koine/dom");
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* # Use `window` size
|
|
8
|
+
*
|
|
9
|
+
* @param args Optionally pass {@link debounce} arguments (`wait` and `immediate`)
|
|
10
|
+
*
|
|
11
|
+
* @returns An array with:
|
|
12
|
+
* 1) _width_: using `window.innerWidth`
|
|
13
|
+
* 2) _height_: using `window.innerHeight`
|
|
14
|
+
*/
|
|
15
|
+
function useWindowSize(wait, immediate) {
|
|
16
|
+
var _a = (0, react_1.useState)(0), width = _a[0], widthSet = _a[1];
|
|
17
|
+
var _b = (0, react_1.useState)(0), height = _b[0], heightSet = _b[1];
|
|
8
18
|
(0, react_1.useEffect)(function () {
|
|
9
19
|
function updateSize() {
|
|
10
|
-
|
|
20
|
+
widthSet(window.innerWidth);
|
|
21
|
+
heightSet(window.innerHeight);
|
|
11
22
|
}
|
|
12
|
-
var listener =
|
|
23
|
+
var listener = wait
|
|
24
|
+
? (0, dom_1.listenResizeDebounced)(0, updateSize, wait, immediate)
|
|
25
|
+
: (0, dom_1.listenResize)(updateSize);
|
|
13
26
|
updateSize();
|
|
14
27
|
return listener;
|
|
15
|
-
}, []);
|
|
16
|
-
return
|
|
28
|
+
}, [wait, immediate]);
|
|
29
|
+
return [width, height];
|
|
17
30
|
}
|
|
18
31
|
exports.useWindowSize = useWindowSize;
|
|
19
32
|
exports.default = useWindowSize;
|
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"framer-motion": "8.5.5",
|
|
51
51
|
"react": "18.2.0",
|
|
52
52
|
"@mui/base": "5.0.0-alpha.115",
|
|
53
|
-
"@koine/utils": "1.1.
|
|
53
|
+
"@koine/utils": "1.1.7",
|
|
54
54
|
"ts-debounce": "4.0.0",
|
|
55
55
|
"type-fest": "3.5.3",
|
|
56
56
|
"react-icons": "4.7.1",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@tiptap/starter-kit": "2.0.0-beta.209",
|
|
61
61
|
"@kuus/yup": "1.0.0-beta.7",
|
|
62
62
|
"react-hook-form": "7.42.1",
|
|
63
|
-
"@koine/dom": "1.1.
|
|
63
|
+
"@koine/dom": "1.1.7",
|
|
64
64
|
"react-popper": "2.3.0",
|
|
65
65
|
"tslib": "2.5.0"
|
|
66
66
|
},
|
|
67
|
-
"version": "1.1.
|
|
67
|
+
"version": "1.1.7",
|
|
68
68
|
"module": "./index.js"
|
|
69
69
|
}
|
package/Favicon/FaviconTags.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type FaviconTagsProps = {
|
|
2
|
-
name: string;
|
|
3
|
-
color?: string;
|
|
4
|
-
safariTabColor?: string;
|
|
5
|
-
tileColor?: string;
|
|
6
|
-
themeColor?: string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Favicon tags.
|
|
10
|
-
*
|
|
11
|
-
* This component is meant to be wrapped in a `<head>` manager component.
|
|
12
|
-
*
|
|
13
|
-
* These tags have been produced by [realfavicongenerator.net](https://realfavicongenerator.net/)
|
|
14
|
-
* on _**16 Feb 2022**_.
|
|
15
|
-
*
|
|
16
|
-
* @see https://realfavicongenerator.net/
|
|
17
|
-
*/
|
|
18
|
-
export declare const FaviconTags: ({ name, color, safariTabColor, tileColor, themeColor, }: FaviconTagsProps) => JSX.Element;
|
package/Favicon/FaviconTags.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Favicon tags.
|
|
4
|
-
*
|
|
5
|
-
* This component is meant to be wrapped in a `<head>` manager component.
|
|
6
|
-
*
|
|
7
|
-
* These tags have been produced by [realfavicongenerator.net](https://realfavicongenerator.net/)
|
|
8
|
-
* on _**16 Feb 2022**_.
|
|
9
|
-
*
|
|
10
|
-
* @see https://realfavicongenerator.net/
|
|
11
|
-
*/
|
|
12
|
-
export var FaviconTags = function (_a) {
|
|
13
|
-
var name = _a.name, color = _a.color, safariTabColor = _a.safariTabColor, tileColor = _a.tileColor, themeColor = _a.themeColor;
|
|
14
|
-
return (_jsxs(_Fragment, { children: [_jsx("link", { rel: "shortcut icon", href: "/favicon.ico", type: "image/x-icon" }), _jsx("link", { rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" }), _jsx("link", { rel: "icon", type: "image/png", sizes: "32x32", href: "/favicon-32x32.png" }), _jsx("link", { rel: "icon", type: "image/png", sizes: "16x16", href: "/favicon-16x16.png" }), _jsx("link", { rel: "manifest", href: "/site.webmanifest" }), _jsx("link", { rel: "mask-icon", href: "/safari-pinned-tab.svg", color: safariTabColor || color }), _jsx("meta", { name: "apple-mobile-web-app-title", content: name }), _jsx("meta", { name: "application-name", content: name }), _jsx("meta", { name: "msapplication-TileColor", content: tileColor || color }), _jsx("meta", { name: "theme-color", content: themeColor || color })] }));
|
|
15
|
-
};
|
package/Favicon/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./FaviconTags";
|
package/Favicon/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./FaviconTags";
|
package/Favicon/package.json
DELETED
package/hooks/useId.d.ts
DELETED
package/hooks/useId.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { uid } from "@koine/utils";
|
|
2
|
-
/**
|
|
3
|
-
* FIXME: once we can move to react 18 just replace this import with `{ useId } from "react";`
|
|
4
|
-
*/
|
|
5
|
-
export function useId(prefix) {
|
|
6
|
-
if (prefix === void 0) { prefix = "uid"; }
|
|
7
|
-
return "".concat(prefix, "-").concat(uid());
|
|
8
|
-
}
|
|
9
|
-
export default useId;
|