@reactuses/core 4.0.9 → 4.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +541 -213
- package/dist/index.d.ts +12 -2
- package/dist/index.mjs +341 -14
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var require$$0 = require('react');
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
10
10
|
|
|
11
11
|
function usePrevious(state) {
|
|
12
|
-
const ref =
|
|
13
|
-
|
|
12
|
+
const ref = require$$0.useRef();
|
|
13
|
+
require$$0.useEffect(() => {
|
|
14
14
|
ref.current = state;
|
|
15
15
|
});
|
|
16
16
|
return ref.current;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function useLatest(value) {
|
|
20
|
-
const ref =
|
|
21
|
-
|
|
20
|
+
const ref = require$$0.useRef(value);
|
|
21
|
+
require$$0.useEffect(() => {
|
|
22
22
|
ref.current = value;
|
|
23
23
|
}, [value]);
|
|
24
24
|
return ref;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function useFirstMountState() {
|
|
28
|
-
const isFirst =
|
|
28
|
+
const isFirst = require$$0.useRef(true);
|
|
29
29
|
if (isFirst.current) {
|
|
30
30
|
isFirst.current = false;
|
|
31
31
|
return true;
|
|
@@ -42,9 +42,9 @@ const createUpdateEffect = (hook) => (effect, deps) => {
|
|
|
42
42
|
}, deps);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
var useUpdateEffect = createUpdateEffect(
|
|
45
|
+
var useUpdateEffect = createUpdateEffect(require$$0.useEffect);
|
|
46
46
|
|
|
47
|
-
var index$3 = createUpdateEffect(
|
|
47
|
+
var index$3 = createUpdateEffect(require$$0.useLayoutEffect);
|
|
48
48
|
|
|
49
49
|
var _a;
|
|
50
50
|
const isFunction$1 = (val) => typeof val === "function";
|
|
@@ -55,13 +55,13 @@ const isNavigator = typeof navigator !== "undefined";
|
|
|
55
55
|
const noop = () => {
|
|
56
56
|
};
|
|
57
57
|
const isIOS = isBrowser && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
58
|
-
!
|
|
58
|
+
!require$$0__default["default"].useId;
|
|
59
59
|
|
|
60
60
|
function guessSerializerType(rawInit) {
|
|
61
61
|
return rawInit == null || rawInit === void 0 ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : Array.isArray(rawInit) ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
const useIsomorphicLayoutEffect = isBrowser ?
|
|
64
|
+
const useIsomorphicLayoutEffect = isBrowser ? require$$0.useLayoutEffect : require$$0.useEffect;
|
|
65
65
|
|
|
66
66
|
function useEvent(fn) {
|
|
67
67
|
if (isDev) {
|
|
@@ -71,11 +71,11 @@ function useEvent(fn) {
|
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
const handlerRef =
|
|
74
|
+
const handlerRef = require$$0.useRef(fn);
|
|
75
75
|
useIsomorphicLayoutEffect(() => {
|
|
76
76
|
handlerRef.current = fn;
|
|
77
77
|
}, [fn]);
|
|
78
|
-
return
|
|
78
|
+
return require$$0.useCallback((...args) => {
|
|
79
79
|
const fn2 = handlerRef.current;
|
|
80
80
|
return fn2(...args);
|
|
81
81
|
}, []);
|
|
@@ -150,14 +150,14 @@ function useStorage(key, defaultValue, getStorage = () => isBrowser ? sessionSto
|
|
|
150
150
|
onError(err);
|
|
151
151
|
}
|
|
152
152
|
const type = guessSerializerType(defaultValue);
|
|
153
|
-
const serializer =
|
|
153
|
+
const serializer = require$$0.useMemo(() => {
|
|
154
154
|
var _a;
|
|
155
155
|
return (_a = options.serializer) != null ? _a : StorageSerializers[type];
|
|
156
156
|
}, [options.serializer, type]);
|
|
157
|
-
const [state, setState] =
|
|
157
|
+
const [state, setState] = require$$0.useState(
|
|
158
158
|
getInitialState$4(key, defaultValue, storage, serializer, onError)
|
|
159
159
|
);
|
|
160
|
-
|
|
160
|
+
require$$0.useEffect(() => {
|
|
161
161
|
const data = csrData ? isFunction$1(csrData) ? csrData() : csrData : defaultValue;
|
|
162
162
|
const getStoredValue = () => {
|
|
163
163
|
try {
|
|
@@ -212,13 +212,13 @@ function useSessionStorage(key, defaultValue, options = defaultOptions$1) {
|
|
|
212
212
|
|
|
213
213
|
const toggleReducer = (state, nextValue) => typeof nextValue === "boolean" ? nextValue : !state;
|
|
214
214
|
function useToggle(initialValue) {
|
|
215
|
-
return
|
|
215
|
+
return require$$0.useReducer(toggleReducer, initialValue);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
function useInterval(callback, delay, options = defaultOptions$1) {
|
|
219
219
|
const immediate = options.immediate;
|
|
220
220
|
const savedCallback = useLatest(callback);
|
|
221
|
-
|
|
221
|
+
require$$0.useEffect(() => {
|
|
222
222
|
if (immediate) {
|
|
223
223
|
savedCallback.current();
|
|
224
224
|
}
|
|
@@ -251,7 +251,7 @@ function useDarkMode(options) {
|
|
|
251
251
|
csrData: value
|
|
252
252
|
}
|
|
253
253
|
);
|
|
254
|
-
|
|
254
|
+
require$$0.useEffect(() => {
|
|
255
255
|
const element = window == null ? void 0 : window.document.querySelector(selector);
|
|
256
256
|
if (!element) {
|
|
257
257
|
return;
|
|
@@ -294,8 +294,8 @@ const getInitialState$3 = (query, defaultState) => {
|
|
|
294
294
|
return false;
|
|
295
295
|
};
|
|
296
296
|
function useMediaQuery(query, defaultState) {
|
|
297
|
-
const [state, setState] =
|
|
298
|
-
|
|
297
|
+
const [state, setState] = require$$0.useState(getInitialState$3(query, defaultState));
|
|
298
|
+
require$$0.useEffect(() => {
|
|
299
299
|
var _a;
|
|
300
300
|
let mounted = true;
|
|
301
301
|
const mql = window.matchMedia(query);
|
|
@@ -336,7 +336,7 @@ function useMount(fn) {
|
|
|
336
336
|
);
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
|
|
339
|
+
require$$0.useEffect(() => {
|
|
340
340
|
fn == null ? void 0 : fn();
|
|
341
341
|
}, []);
|
|
342
342
|
}
|
|
@@ -350,7 +350,7 @@ function useUnmount(fn) {
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
const fnRef = useLatest(fn);
|
|
353
|
-
|
|
353
|
+
require$$0.useEffect(
|
|
354
354
|
() => () => {
|
|
355
355
|
fnRef.current();
|
|
356
356
|
},
|
|
@@ -2773,7 +2773,7 @@ function useThrottleFn(fn, wait, options) {
|
|
|
2773
2773
|
}
|
|
2774
2774
|
}
|
|
2775
2775
|
const fnRef = useLatest(fn);
|
|
2776
|
-
const throttled =
|
|
2776
|
+
const throttled = require$$0.useMemo(
|
|
2777
2777
|
() => throttle(
|
|
2778
2778
|
(...args) => {
|
|
2779
2779
|
return fnRef.current(...args);
|
|
@@ -2794,7 +2794,7 @@ function useThrottleFn(fn, wait, options) {
|
|
|
2794
2794
|
}
|
|
2795
2795
|
|
|
2796
2796
|
function useThrottle(value, wait, options) {
|
|
2797
|
-
const [throttled, setThrottled] =
|
|
2797
|
+
const [throttled, setThrottled] = require$$0.useState(value);
|
|
2798
2798
|
const { run } = useThrottleFn(
|
|
2799
2799
|
() => {
|
|
2800
2800
|
setThrottled(value);
|
|
@@ -2802,7 +2802,7 @@ function useThrottle(value, wait, options) {
|
|
|
2802
2802
|
wait,
|
|
2803
2803
|
options
|
|
2804
2804
|
);
|
|
2805
|
-
|
|
2805
|
+
require$$0.useEffect(() => {
|
|
2806
2806
|
run();
|
|
2807
2807
|
}, [run, value]);
|
|
2808
2808
|
return throttled;
|
|
@@ -2817,7 +2817,7 @@ function useDebounceFn(fn, wait, options) {
|
|
|
2817
2817
|
}
|
|
2818
2818
|
}
|
|
2819
2819
|
const fnRef = useLatest(fn);
|
|
2820
|
-
const debounced =
|
|
2820
|
+
const debounced = require$$0.useMemo(
|
|
2821
2821
|
() => debounce(
|
|
2822
2822
|
(...args) => {
|
|
2823
2823
|
return fnRef.current(...args);
|
|
@@ -2838,7 +2838,7 @@ function useDebounceFn(fn, wait, options) {
|
|
|
2838
2838
|
}
|
|
2839
2839
|
|
|
2840
2840
|
function useDebounce(value, wait, options) {
|
|
2841
|
-
const [debounced, setDebounced] =
|
|
2841
|
+
const [debounced, setDebounced] = require$$0.useState(value);
|
|
2842
2842
|
const { run } = useDebounceFn(
|
|
2843
2843
|
() => {
|
|
2844
2844
|
setDebounced(value);
|
|
@@ -2846,16 +2846,16 @@ function useDebounce(value, wait, options) {
|
|
|
2846
2846
|
wait,
|
|
2847
2847
|
options
|
|
2848
2848
|
);
|
|
2849
|
-
|
|
2849
|
+
require$$0.useEffect(() => {
|
|
2850
2850
|
run();
|
|
2851
2851
|
}, [run, value]);
|
|
2852
2852
|
return debounced;
|
|
2853
2853
|
}
|
|
2854
2854
|
|
|
2855
2855
|
function useRafState(initialState) {
|
|
2856
|
-
const frame =
|
|
2857
|
-
const [state, setState] =
|
|
2858
|
-
const setRafState =
|
|
2856
|
+
const frame = require$$0.useRef(0);
|
|
2857
|
+
const [state, setState] = require$$0.useState(initialState);
|
|
2858
|
+
const setRafState = require$$0.useCallback((value) => {
|
|
2859
2859
|
cancelAnimationFrame(frame.current);
|
|
2860
2860
|
frame.current = requestAnimationFrame(() => {
|
|
2861
2861
|
setState(value);
|
|
@@ -2869,15 +2869,15 @@ function useRafState(initialState) {
|
|
|
2869
2869
|
|
|
2870
2870
|
const updateReducer = (num) => (num + 1) % 1e6;
|
|
2871
2871
|
function useUpdate() {
|
|
2872
|
-
const [, update] =
|
|
2872
|
+
const [, update] = require$$0.useReducer(updateReducer, 0);
|
|
2873
2873
|
return update;
|
|
2874
2874
|
}
|
|
2875
2875
|
|
|
2876
2876
|
function useTimeoutFn(cb, interval, options = defaultOptions$1) {
|
|
2877
2877
|
const { immediate = true } = options;
|
|
2878
|
-
const [pending, setPending] =
|
|
2878
|
+
const [pending, setPending] = require$$0.useState(false);
|
|
2879
2879
|
const savedCallback = useLatest(cb);
|
|
2880
|
-
const timer =
|
|
2880
|
+
const timer = require$$0.useRef();
|
|
2881
2881
|
const stop = useEvent(() => {
|
|
2882
2882
|
setPending(false);
|
|
2883
2883
|
if (timer.current) {
|
|
@@ -2894,7 +2894,7 @@ function useTimeoutFn(cb, interval, options = defaultOptions$1) {
|
|
|
2894
2894
|
}, interval);
|
|
2895
2895
|
setPending(true);
|
|
2896
2896
|
});
|
|
2897
|
-
|
|
2897
|
+
require$$0.useEffect(() => {
|
|
2898
2898
|
if (immediate) {
|
|
2899
2899
|
start();
|
|
2900
2900
|
}
|
|
@@ -2909,9 +2909,9 @@ function useTimeout(ms = 0, options = {}) {
|
|
|
2909
2909
|
}
|
|
2910
2910
|
|
|
2911
2911
|
function useMountedState() {
|
|
2912
|
-
const mountedRef =
|
|
2913
|
-
const get =
|
|
2914
|
-
|
|
2912
|
+
const mountedRef = require$$0.useRef(false);
|
|
2913
|
+
const get = require$$0.useCallback(() => mountedRef.current, []);
|
|
2914
|
+
require$$0.useEffect(() => {
|
|
2915
2915
|
mountedRef.current = true;
|
|
2916
2916
|
return () => {
|
|
2917
2917
|
mountedRef.current = false;
|
|
@@ -2954,10 +2954,10 @@ function getTargetElement(target, defaultElement) {
|
|
|
2954
2954
|
return targetElement;
|
|
2955
2955
|
}
|
|
2956
2956
|
function useLatestElement(target, defaultElement) {
|
|
2957
|
-
const [latestElement, setLatestElement] =
|
|
2957
|
+
const [latestElement, setLatestElement] = require$$0.useState(
|
|
2958
2958
|
getTargetElement(target, defaultElement)
|
|
2959
2959
|
);
|
|
2960
|
-
|
|
2960
|
+
require$$0.useEffect(() => {
|
|
2961
2961
|
setLatestElement(getTargetElement(target, defaultElement));
|
|
2962
2962
|
}, [target, defaultElement]);
|
|
2963
2963
|
return latestElement;
|
|
@@ -2966,7 +2966,7 @@ function useLatestElement(target, defaultElement) {
|
|
|
2966
2966
|
function useEventListener(eventName, handler, element, options = defaultOptions$1) {
|
|
2967
2967
|
const savedHandler = useLatest(handler);
|
|
2968
2968
|
const targetElement = useLatestElement(element, defaultWindow);
|
|
2969
|
-
|
|
2969
|
+
require$$0.useEffect(() => {
|
|
2970
2970
|
if (!(targetElement && targetElement.addEventListener)) {
|
|
2971
2971
|
return;
|
|
2972
2972
|
}
|
|
@@ -2999,7 +2999,7 @@ function useCounter(initialValue = 0, max = null, min = null) {
|
|
|
2999
2999
|
}
|
|
3000
3000
|
return init;
|
|
3001
3001
|
};
|
|
3002
|
-
const [value, setValue] =
|
|
3002
|
+
const [value, setValue] = require$$0.useState(initFunc);
|
|
3003
3003
|
const set = useEvent(
|
|
3004
3004
|
(newState) => {
|
|
3005
3005
|
setValue((v) => {
|
|
@@ -3027,10 +3027,10 @@ function useCounter(initialValue = 0, max = null, min = null) {
|
|
|
3027
3027
|
}
|
|
3028
3028
|
|
|
3029
3029
|
function useRafFn(callback, initiallyActive = true) {
|
|
3030
|
-
const raf =
|
|
3031
|
-
const rafActivity =
|
|
3030
|
+
const raf = require$$0.useRef(null);
|
|
3031
|
+
const rafActivity = require$$0.useRef(false);
|
|
3032
3032
|
const rafCallback = useLatest(callback);
|
|
3033
|
-
const step =
|
|
3033
|
+
const step = require$$0.useCallback(
|
|
3034
3034
|
(time) => {
|
|
3035
3035
|
if (rafActivity.current) {
|
|
3036
3036
|
rafCallback.current(time);
|
|
@@ -3039,7 +3039,7 @@ function useRafFn(callback, initiallyActive = true) {
|
|
|
3039
3039
|
},
|
|
3040
3040
|
[rafCallback]
|
|
3041
3041
|
);
|
|
3042
|
-
const result =
|
|
3042
|
+
const result = require$$0.useMemo(
|
|
3043
3043
|
() => [
|
|
3044
3044
|
() => {
|
|
3045
3045
|
if (rafActivity.current) {
|
|
@@ -3058,7 +3058,7 @@ function useRafFn(callback, initiallyActive = true) {
|
|
|
3058
3058
|
],
|
|
3059
3059
|
[step]
|
|
3060
3060
|
);
|
|
3061
|
-
|
|
3061
|
+
require$$0.useEffect(() => {
|
|
3062
3062
|
if (initiallyActive) {
|
|
3063
3063
|
result[1]();
|
|
3064
3064
|
}
|
|
@@ -3068,9 +3068,9 @@ function useRafFn(callback, initiallyActive = true) {
|
|
|
3068
3068
|
}
|
|
3069
3069
|
|
|
3070
3070
|
function useEventEmitter() {
|
|
3071
|
-
const listeners =
|
|
3072
|
-
const _disposed =
|
|
3073
|
-
const _event =
|
|
3071
|
+
const listeners = require$$0.useRef([]);
|
|
3072
|
+
const _disposed = require$$0.useRef(false);
|
|
3073
|
+
const _event = require$$0.useRef((listener) => {
|
|
3074
3074
|
listeners.current.push(listener);
|
|
3075
3075
|
const disposable = {
|
|
3076
3076
|
dispose: () => {
|
|
@@ -3105,7 +3105,7 @@ function useEventEmitter() {
|
|
|
3105
3105
|
}
|
|
3106
3106
|
|
|
3107
3107
|
function useFavicon(href, baseUrl = "", rel = "icon") {
|
|
3108
|
-
|
|
3108
|
+
require$$0.useEffect(() => {
|
|
3109
3109
|
const url = `${baseUrl}${href}`;
|
|
3110
3110
|
const element = document.head.querySelectorAll(
|
|
3111
3111
|
`link[rel*="${rel}"]`
|
|
@@ -3122,14 +3122,14 @@ function useFavicon(href, baseUrl = "", rel = "icon") {
|
|
|
3122
3122
|
|
|
3123
3123
|
function useMutationObserver(callback, target, options = defaultOptions$1) {
|
|
3124
3124
|
const callbackRef = useLatest(callback);
|
|
3125
|
-
const observerRef =
|
|
3125
|
+
const observerRef = require$$0.useRef();
|
|
3126
3126
|
const element = useLatestElement(target);
|
|
3127
|
-
const stop =
|
|
3127
|
+
const stop = require$$0.useCallback(() => {
|
|
3128
3128
|
if (observerRef.current) {
|
|
3129
3129
|
observerRef.current.disconnect();
|
|
3130
3130
|
}
|
|
3131
3131
|
}, []);
|
|
3132
|
-
|
|
3132
|
+
require$$0.useEffect(() => {
|
|
3133
3133
|
if (!element) {
|
|
3134
3134
|
return;
|
|
3135
3135
|
}
|
|
@@ -3159,11 +3159,11 @@ function useCustomCompareEffect(effect, deps, depsEqual) {
|
|
|
3159
3159
|
);
|
|
3160
3160
|
}
|
|
3161
3161
|
}
|
|
3162
|
-
const ref =
|
|
3162
|
+
const ref = require$$0.useRef(void 0);
|
|
3163
3163
|
if (!ref.current || !depsEqual(deps, ref.current)) {
|
|
3164
3164
|
ref.current = deps;
|
|
3165
3165
|
}
|
|
3166
|
-
|
|
3166
|
+
require$$0.useEffect(effect, ref.current);
|
|
3167
3167
|
}
|
|
3168
3168
|
|
|
3169
3169
|
const isPrimitive = (val) => val !== Object(val);
|
|
@@ -3184,7 +3184,7 @@ function useDeepCompareEffect(effect, deps) {
|
|
|
3184
3184
|
}
|
|
3185
3185
|
|
|
3186
3186
|
function useTitle(title) {
|
|
3187
|
-
|
|
3187
|
+
require$$0.useEffect(() => {
|
|
3188
3188
|
document.title = title;
|
|
3189
3189
|
}, [title]);
|
|
3190
3190
|
}
|
|
@@ -3201,9 +3201,9 @@ function useScriptTag(src, onLoaded = noop, options = defaultOptions$1) {
|
|
|
3201
3201
|
defer,
|
|
3202
3202
|
attrs = {}
|
|
3203
3203
|
} = options;
|
|
3204
|
-
const scriptTag =
|
|
3205
|
-
const _promise =
|
|
3206
|
-
const [status, setStatus] =
|
|
3204
|
+
const scriptTag = require$$0.useRef(null);
|
|
3205
|
+
const _promise = require$$0.useRef(null);
|
|
3206
|
+
const [status, setStatus] = require$$0.useState(src ? "loading" : "idle");
|
|
3207
3207
|
const loadScript = (waitForScriptLoad) => new Promise((resolve, reject) => {
|
|
3208
3208
|
const resolveWithElement = (el2) => {
|
|
3209
3209
|
scriptTag.current = el2;
|
|
@@ -3304,8 +3304,8 @@ function useScriptTag(src, onLoaded = noop, options = defaultOptions$1) {
|
|
|
3304
3304
|
}
|
|
3305
3305
|
|
|
3306
3306
|
function usePermission(permissionDesc) {
|
|
3307
|
-
const [state, setState] =
|
|
3308
|
-
|
|
3307
|
+
const [state, setState] = require$$0.useState("");
|
|
3308
|
+
require$$0.useEffect(() => {
|
|
3309
3309
|
var _a;
|
|
3310
3310
|
const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc;
|
|
3311
3311
|
let mounted = true;
|
|
@@ -3345,9 +3345,9 @@ const preventDefault$1 = (ev) => {
|
|
|
3345
3345
|
}
|
|
3346
3346
|
};
|
|
3347
3347
|
function useLongPress(callback, { isPreventDefault = true, delay = 300 } = defaultOptions$1) {
|
|
3348
|
-
const timeout =
|
|
3349
|
-
const target =
|
|
3350
|
-
const start =
|
|
3348
|
+
const timeout = require$$0.useRef();
|
|
3349
|
+
const target = require$$0.useRef();
|
|
3350
|
+
const start = require$$0.useCallback(
|
|
3351
3351
|
(event) => {
|
|
3352
3352
|
if (isPreventDefault && event.target) {
|
|
3353
3353
|
on(event.target, "touchend", preventDefault$1, { passive: false });
|
|
@@ -3357,7 +3357,7 @@ function useLongPress(callback, { isPreventDefault = true, delay = 300 } = defau
|
|
|
3357
3357
|
},
|
|
3358
3358
|
[callback, delay, isPreventDefault]
|
|
3359
3359
|
);
|
|
3360
|
-
const clear =
|
|
3360
|
+
const clear = require$$0.useCallback(() => {
|
|
3361
3361
|
timeout.current && clearTimeout(timeout.current);
|
|
3362
3362
|
if (isPreventDefault && target.current) {
|
|
3363
3363
|
off(target.current, "touchend", preventDefault$1);
|
|
@@ -3373,8 +3373,8 @@ function useLongPress(callback, { isPreventDefault = true, delay = 300 } = defau
|
|
|
3373
3373
|
}
|
|
3374
3374
|
|
|
3375
3375
|
function useObjectUrl(object) {
|
|
3376
|
-
const [url, setUrl] =
|
|
3377
|
-
|
|
3376
|
+
const [url, setUrl] = require$$0.useState();
|
|
3377
|
+
require$$0.useEffect(() => {
|
|
3378
3378
|
if (object) {
|
|
3379
3379
|
setUrl(URL.createObjectURL(object));
|
|
3380
3380
|
}
|
|
@@ -3397,8 +3397,8 @@ const defaultEvents$1 = [
|
|
|
3397
3397
|
];
|
|
3398
3398
|
const oneMinute = 6e4;
|
|
3399
3399
|
function useIdle(ms = oneMinute, initialState = false, events = defaultEvents$1) {
|
|
3400
|
-
const [state, setState] =
|
|
3401
|
-
|
|
3400
|
+
const [state, setState] = require$$0.useState(initialState);
|
|
3401
|
+
require$$0.useEffect(() => {
|
|
3402
3402
|
let mounted = true;
|
|
3403
3403
|
let timeout;
|
|
3404
3404
|
let localState = state;
|
|
@@ -3437,8 +3437,8 @@ function useIdle(ms = oneMinute, initialState = false, events = defaultEvents$1)
|
|
|
3437
3437
|
}
|
|
3438
3438
|
|
|
3439
3439
|
function useSupported(callback, sync = false) {
|
|
3440
|
-
const [supported, setSupported] =
|
|
3441
|
-
const effect = sync ? useIsomorphicLayoutEffect :
|
|
3440
|
+
const [supported, setSupported] = require$$0.useState(false);
|
|
3441
|
+
const effect = sync ? useIsomorphicLayoutEffect : require$$0.useEffect;
|
|
3442
3442
|
effect(() => {
|
|
3443
3443
|
setSupported(Boolean(callback()));
|
|
3444
3444
|
}, []);
|
|
@@ -3468,13 +3468,13 @@ var __async$5 = (__this, __arguments, generator) => {
|
|
|
3468
3468
|
const defaultConstints = { audio: true, video: true };
|
|
3469
3469
|
function useMediaDevices(options = {}) {
|
|
3470
3470
|
const { requestPermissions, constraints = defaultConstints } = options;
|
|
3471
|
-
const [state, setState] =
|
|
3471
|
+
const [state, setState] = require$$0.useState({ devices: [] });
|
|
3472
3472
|
const isSupported = useSupported(
|
|
3473
3473
|
() => navigator && navigator.mediaDevices && navigator.mediaDevices.enumerateDevices
|
|
3474
3474
|
);
|
|
3475
|
-
const permissionGranted =
|
|
3476
|
-
const stream =
|
|
3477
|
-
const onChange =
|
|
3475
|
+
const permissionGranted = require$$0.useRef(false);
|
|
3476
|
+
const stream = require$$0.useRef(null);
|
|
3477
|
+
const onChange = require$$0.useCallback(() => {
|
|
3478
3478
|
navigator.mediaDevices.enumerateDevices().then((devices) => {
|
|
3479
3479
|
if (stream.current) {
|
|
3480
3480
|
stream.current.getTracks().forEach((t) => t.stop());
|
|
@@ -3490,7 +3490,7 @@ function useMediaDevices(options = {}) {
|
|
|
3490
3490
|
});
|
|
3491
3491
|
}).catch(noop);
|
|
3492
3492
|
}, []);
|
|
3493
|
-
const ensurePermissions =
|
|
3493
|
+
const ensurePermissions = require$$0.useCallback(() => __async$5(this, null, function* () {
|
|
3494
3494
|
if (!isSupported) {
|
|
3495
3495
|
return false;
|
|
3496
3496
|
}
|
|
@@ -3514,7 +3514,7 @@ function useMediaDevices(options = {}) {
|
|
|
3514
3514
|
}
|
|
3515
3515
|
return permissionGranted.current;
|
|
3516
3516
|
}), [onChange, isSupported, constraints]);
|
|
3517
|
-
|
|
3517
|
+
require$$0.useEffect(() => {
|
|
3518
3518
|
if (!isSupported) {
|
|
3519
3519
|
return;
|
|
3520
3520
|
}
|
|
@@ -3540,7 +3540,7 @@ function useTextDirection(options = defaultOptions$1) {
|
|
|
3540
3540
|
return initialValue;
|
|
3541
3541
|
}
|
|
3542
3542
|
};
|
|
3543
|
-
const [value, setValue] =
|
|
3543
|
+
const [value, setValue] = require$$0.useState(getValue());
|
|
3544
3544
|
const set = (value2) => {
|
|
3545
3545
|
var _a, _b;
|
|
3546
3546
|
if (!isBrowser) {
|
|
@@ -3609,10 +3609,10 @@ function useMouse(target) {
|
|
|
3609
3609
|
|
|
3610
3610
|
function useFps(options = defaultOptions$1) {
|
|
3611
3611
|
var _a;
|
|
3612
|
-
const [fps, setFps] =
|
|
3612
|
+
const [fps, setFps] = require$$0.useState(0);
|
|
3613
3613
|
const every = (_a = options.every) != null ? _a : 10;
|
|
3614
|
-
const last =
|
|
3615
|
-
const ticks =
|
|
3614
|
+
const last = require$$0.useRef(performance.now());
|
|
3615
|
+
const ticks = require$$0.useRef(0);
|
|
3616
3616
|
useRafFn(() => {
|
|
3617
3617
|
ticks.current += 1;
|
|
3618
3618
|
if (ticks.current >= every) {
|
|
@@ -3643,20 +3643,20 @@ function useGeolocation(options = defaultOptions$1) {
|
|
|
3643
3643
|
maximumAge = 3e4,
|
|
3644
3644
|
timeout = 27e3
|
|
3645
3645
|
} = options;
|
|
3646
|
-
const [coordinates, setCoordinates] =
|
|
3647
|
-
const [locatedAt, setLocatedAt] =
|
|
3648
|
-
const [error, setError] =
|
|
3649
|
-
const updatePosition =
|
|
3646
|
+
const [coordinates, setCoordinates] = require$$0.useState(initCoord);
|
|
3647
|
+
const [locatedAt, setLocatedAt] = require$$0.useState(null);
|
|
3648
|
+
const [error, setError] = require$$0.useState(null);
|
|
3649
|
+
const updatePosition = require$$0.useCallback((position) => {
|
|
3650
3650
|
setCoordinates(position.coords);
|
|
3651
3651
|
setLocatedAt(position.timestamp);
|
|
3652
3652
|
setError(null);
|
|
3653
3653
|
}, []);
|
|
3654
|
-
const updateError =
|
|
3654
|
+
const updateError = require$$0.useCallback((err) => {
|
|
3655
3655
|
setCoordinates(initCoord);
|
|
3656
3656
|
setLocatedAt(null);
|
|
3657
3657
|
setError(err);
|
|
3658
3658
|
}, []);
|
|
3659
|
-
|
|
3659
|
+
require$$0.useEffect(() => {
|
|
3660
3660
|
navigator.geolocation.getCurrentPosition(updatePosition, updateError);
|
|
3661
3661
|
const watchId = navigator.geolocation.watchPosition(
|
|
3662
3662
|
updatePosition,
|
|
@@ -3865,7 +3865,7 @@ var screenfull = screenfull$1.exports;
|
|
|
3865
3865
|
|
|
3866
3866
|
function useFullscreen(target, options = defaultOptions$1) {
|
|
3867
3867
|
const { onExit, onEnter } = options;
|
|
3868
|
-
const [state, setState] =
|
|
3868
|
+
const [state, setState] = require$$0.useState(false);
|
|
3869
3869
|
const onChange = () => {
|
|
3870
3870
|
if (screenfull.isEnabled) {
|
|
3871
3871
|
const { isFullscreen } = screenfull;
|
|
@@ -3938,8 +3938,8 @@ function getConnectionState(previousState) {
|
|
|
3938
3938
|
};
|
|
3939
3939
|
}
|
|
3940
3940
|
function useNetwork() {
|
|
3941
|
-
const [state, setState] =
|
|
3942
|
-
|
|
3941
|
+
const [state, setState] = require$$0.useState(getConnectionState);
|
|
3942
|
+
require$$0.useEffect(() => {
|
|
3943
3943
|
const handleStateChange = () => {
|
|
3944
3944
|
setState(getConnectionState);
|
|
3945
3945
|
};
|
|
@@ -3969,8 +3969,8 @@ const defaultState$1 = {
|
|
|
3969
3969
|
type: "landscape-primary"
|
|
3970
3970
|
};
|
|
3971
3971
|
function useOrientation(initialState = defaultState$1) {
|
|
3972
|
-
const [state, setState] =
|
|
3973
|
-
|
|
3972
|
+
const [state, setState] = require$$0.useState(initialState);
|
|
3973
|
+
require$$0.useEffect(() => {
|
|
3974
3974
|
const screen = window.screen;
|
|
3975
3975
|
let mounted = true;
|
|
3976
3976
|
const onChange = () => {
|
|
@@ -4017,14 +4017,14 @@ function useOrientation(initialState = defaultState$1) {
|
|
|
4017
4017
|
|
|
4018
4018
|
function useIntersectionObserver(target, callback, options = defaultOptions$1) {
|
|
4019
4019
|
const savedCallback = useLatest(callback);
|
|
4020
|
-
const observerRef =
|
|
4020
|
+
const observerRef = require$$0.useRef();
|
|
4021
4021
|
const element = useLatestElement(target);
|
|
4022
|
-
const stop =
|
|
4022
|
+
const stop = require$$0.useCallback(() => {
|
|
4023
4023
|
if (observerRef.current) {
|
|
4024
4024
|
observerRef.current.disconnect();
|
|
4025
4025
|
}
|
|
4026
4026
|
}, []);
|
|
4027
|
-
|
|
4027
|
+
require$$0.useEffect(() => {
|
|
4028
4028
|
if (!element) {
|
|
4029
4029
|
return;
|
|
4030
4030
|
}
|
|
@@ -4039,7 +4039,7 @@ function useIntersectionObserver(target, callback, options = defaultOptions$1) {
|
|
|
4039
4039
|
}
|
|
4040
4040
|
|
|
4041
4041
|
function usePageLeave() {
|
|
4042
|
-
const [isLeft, setIsLeft] =
|
|
4042
|
+
const [isLeft, setIsLeft] = require$$0.useState(false);
|
|
4043
4043
|
const handler = (event) => {
|
|
4044
4044
|
if (!window)
|
|
4045
4045
|
return;
|
|
@@ -4068,7 +4068,7 @@ const getInitialState$2 = (defaultValue) => {
|
|
|
4068
4068
|
return "visible";
|
|
4069
4069
|
};
|
|
4070
4070
|
function useDocumentVisibility(defaultValue) {
|
|
4071
|
-
const [visible, setVisible] =
|
|
4071
|
+
const [visible, setVisible] = require$$0.useState(
|
|
4072
4072
|
getInitialState$2(defaultValue)
|
|
4073
4073
|
);
|
|
4074
4074
|
useEventListener(
|
|
@@ -4078,7 +4078,7 @@ function useDocumentVisibility(defaultValue) {
|
|
|
4078
4078
|
},
|
|
4079
4079
|
() => document
|
|
4080
4080
|
);
|
|
4081
|
-
|
|
4081
|
+
require$$0.useEffect(() => {
|
|
4082
4082
|
setVisible(document.visibilityState);
|
|
4083
4083
|
}, []);
|
|
4084
4084
|
return visible;
|
|
@@ -4086,14 +4086,14 @@ function useDocumentVisibility(defaultValue) {
|
|
|
4086
4086
|
|
|
4087
4087
|
function useResizeObserver(target, callback, options = defaultOptions$1) {
|
|
4088
4088
|
const savedCallback = useLatest(callback);
|
|
4089
|
-
const observerRef =
|
|
4089
|
+
const observerRef = require$$0.useRef();
|
|
4090
4090
|
const element = useLatestElement(target);
|
|
4091
|
-
const stop =
|
|
4091
|
+
const stop = require$$0.useCallback(() => {
|
|
4092
4092
|
if (observerRef.current) {
|
|
4093
4093
|
observerRef.current.disconnect();
|
|
4094
4094
|
}
|
|
4095
4095
|
}, []);
|
|
4096
|
-
|
|
4096
|
+
require$$0.useEffect(() => {
|
|
4097
4097
|
if (!element) {
|
|
4098
4098
|
return;
|
|
4099
4099
|
}
|
|
@@ -4105,8 +4105,8 @@ function useResizeObserver(target, callback, options = defaultOptions$1) {
|
|
|
4105
4105
|
}
|
|
4106
4106
|
|
|
4107
4107
|
function useDropZone(target, onDrop) {
|
|
4108
|
-
const [over, setOver] =
|
|
4109
|
-
const counter =
|
|
4108
|
+
const [over, setOver] = require$$0.useState(false);
|
|
4109
|
+
const counter = require$$0.useRef(0);
|
|
4110
4110
|
useEventListener(
|
|
4111
4111
|
"dragenter",
|
|
4112
4112
|
(event) => {
|
|
@@ -4170,9 +4170,9 @@ const DEFAULT_OPTIONS = {
|
|
|
4170
4170
|
accept: "*"
|
|
4171
4171
|
};
|
|
4172
4172
|
function useFileDialog(options = defaultOptions$1) {
|
|
4173
|
-
const [files, setFiles] =
|
|
4174
|
-
const inputRef =
|
|
4175
|
-
const initFn =
|
|
4173
|
+
const [files, setFiles] = require$$0.useState(null);
|
|
4174
|
+
const inputRef = require$$0.useRef();
|
|
4175
|
+
const initFn = require$$0.useCallback(() => {
|
|
4176
4176
|
if (typeof document === "undefined") {
|
|
4177
4177
|
return void 0;
|
|
4178
4178
|
}
|
|
@@ -4223,16 +4223,16 @@ function useScroll(target, options = defaultOptions$1) {
|
|
|
4223
4223
|
},
|
|
4224
4224
|
eventListenerOptions = defaultListerOptions
|
|
4225
4225
|
} = options;
|
|
4226
|
-
const [x, setX] =
|
|
4227
|
-
const [y, setY] =
|
|
4228
|
-
const [isScrolling, setIsScrolling] =
|
|
4229
|
-
const [arrivedState, setArrivedState] =
|
|
4226
|
+
const [x, setX] = require$$0.useState(0);
|
|
4227
|
+
const [y, setY] = require$$0.useState(0);
|
|
4228
|
+
const [isScrolling, setIsScrolling] = require$$0.useState(false);
|
|
4229
|
+
const [arrivedState, setArrivedState] = require$$0.useState({
|
|
4230
4230
|
left: true,
|
|
4231
4231
|
right: false,
|
|
4232
4232
|
top: true,
|
|
4233
4233
|
bottom: false
|
|
4234
4234
|
});
|
|
4235
|
-
const [directions, setDirections] =
|
|
4235
|
+
const [directions, setDirections] = require$$0.useState({
|
|
4236
4236
|
left: false,
|
|
4237
4237
|
right: false,
|
|
4238
4238
|
top: false,
|
|
@@ -4354,7 +4354,7 @@ const defaultEvents = [
|
|
|
4354
4354
|
];
|
|
4355
4355
|
function useKeyModifier(modifier, options = defaultOptions$1) {
|
|
4356
4356
|
const { events = defaultEvents, initial = false } = options;
|
|
4357
|
-
const [state, setState] =
|
|
4357
|
+
const [state, setState] = require$$0.useState(initial);
|
|
4358
4358
|
useMount(() => {
|
|
4359
4359
|
events.forEach((listenEvent) => {
|
|
4360
4360
|
on(document, listenEvent, (evt) => {
|
|
@@ -4379,24 +4379,24 @@ function useKeyModifier(modifier, options = defaultOptions$1) {
|
|
|
4379
4379
|
const listenerOptions$2 = { passive: true };
|
|
4380
4380
|
function useMousePressed(target, options = defaultOptions$1) {
|
|
4381
4381
|
const { touch = true, drag = true, initialValue = false } = options;
|
|
4382
|
-
const [pressed, setPressed] =
|
|
4383
|
-
const [sourceType, setSourceType] =
|
|
4382
|
+
const [pressed, setPressed] = require$$0.useState(initialValue);
|
|
4383
|
+
const [sourceType, setSourceType] = require$$0.useState(null);
|
|
4384
4384
|
const element = useLatestElement(target);
|
|
4385
|
-
const onPressed =
|
|
4385
|
+
const onPressed = require$$0.useCallback(
|
|
4386
4386
|
(srcType) => () => {
|
|
4387
4387
|
setPressed(true);
|
|
4388
4388
|
setSourceType(srcType);
|
|
4389
4389
|
},
|
|
4390
4390
|
[]
|
|
4391
4391
|
);
|
|
4392
|
-
const onReleased =
|
|
4392
|
+
const onReleased = require$$0.useCallback(() => {
|
|
4393
4393
|
setPressed(false);
|
|
4394
4394
|
setSourceType(null);
|
|
4395
4395
|
}, []);
|
|
4396
4396
|
useEventListener("mousedown", onPressed("mouse"), target, listenerOptions$2);
|
|
4397
4397
|
useEventListener("mouseleave", onReleased, () => window, listenerOptions$2);
|
|
4398
4398
|
useEventListener("mouseup", onReleased, () => window, listenerOptions$2);
|
|
4399
|
-
|
|
4399
|
+
require$$0.useEffect(() => {
|
|
4400
4400
|
if (drag) {
|
|
4401
4401
|
element == null ? void 0 : element.addEventListener(
|
|
4402
4402
|
"dragstart",
|
|
@@ -4442,10 +4442,10 @@ function preventDefault(rawEvent) {
|
|
|
4442
4442
|
return false;
|
|
4443
4443
|
}
|
|
4444
4444
|
function useScrollLock(target, initialState = false) {
|
|
4445
|
-
const [locked, setLocked] =
|
|
4446
|
-
const initialOverflowRef =
|
|
4445
|
+
const [locked, setLocked] = require$$0.useState(initialState);
|
|
4446
|
+
const initialOverflowRef = require$$0.useRef("scroll");
|
|
4447
4447
|
const element = useLatestElement(target);
|
|
4448
|
-
|
|
4448
|
+
require$$0.useEffect(() => {
|
|
4449
4449
|
if (element) {
|
|
4450
4450
|
initialOverflowRef.current = element.style.overflow;
|
|
4451
4451
|
if (locked) {
|
|
@@ -4486,8 +4486,8 @@ function useScrollLock(target, initialState = false) {
|
|
|
4486
4486
|
|
|
4487
4487
|
function useElementSize(target, options = defaultOptions$1) {
|
|
4488
4488
|
const { box = "content-box" } = options;
|
|
4489
|
-
const [width, setWidth] =
|
|
4490
|
-
const [height, setHeight] =
|
|
4489
|
+
const [width, setWidth] = require$$0.useState(0);
|
|
4490
|
+
const [height, setHeight] = require$$0.useState(0);
|
|
4491
4491
|
useResizeObserver(
|
|
4492
4492
|
target,
|
|
4493
4493
|
([entry]) => {
|
|
@@ -4506,11 +4506,11 @@ function useElementSize(target, options = defaultOptions$1) {
|
|
|
4506
4506
|
}
|
|
4507
4507
|
|
|
4508
4508
|
function useVirtualList(list = [], options) {
|
|
4509
|
-
const containerRef =
|
|
4509
|
+
const containerRef = require$$0.useRef(null);
|
|
4510
4510
|
const [width, height] = useElementSize(containerRef);
|
|
4511
|
-
const [currentList, setCurrentList] =
|
|
4511
|
+
const [currentList, setCurrentList] = require$$0.useState([]);
|
|
4512
4512
|
const { itemHeight, overscan = 5, containerHeight = 300 } = options;
|
|
4513
|
-
const state =
|
|
4513
|
+
const state = require$$0.useRef({ start: 0, end: 10 });
|
|
4514
4514
|
const getViewCapacity = (containerHeight2) => {
|
|
4515
4515
|
if (typeof itemHeight === "number") {
|
|
4516
4516
|
return Math.ceil(containerHeight2 / itemHeight);
|
|
@@ -4563,16 +4563,16 @@ function useVirtualList(list = [], options) {
|
|
|
4563
4563
|
);
|
|
4564
4564
|
}
|
|
4565
4565
|
});
|
|
4566
|
-
|
|
4566
|
+
require$$0.useEffect(() => {
|
|
4567
4567
|
calculateRange();
|
|
4568
4568
|
}, [width, height, list]);
|
|
4569
|
-
const totalHeight =
|
|
4569
|
+
const totalHeight = require$$0.useMemo(() => {
|
|
4570
4570
|
if (typeof itemHeight === "number") {
|
|
4571
4571
|
return list.length * itemHeight;
|
|
4572
4572
|
}
|
|
4573
4573
|
return list.reduce((sum, _, index) => sum + itemHeight(index), 0);
|
|
4574
4574
|
}, [itemHeight, list]);
|
|
4575
|
-
const getDistanceTop =
|
|
4575
|
+
const getDistanceTop = require$$0.useCallback(
|
|
4576
4576
|
(index) => {
|
|
4577
4577
|
if (typeof itemHeight === "number") {
|
|
4578
4578
|
const height3 = index * itemHeight;
|
|
@@ -4584,7 +4584,7 @@ function useVirtualList(list = [], options) {
|
|
|
4584
4584
|
[itemHeight, list]
|
|
4585
4585
|
);
|
|
4586
4586
|
const offsetTop = getDistanceTop(state.current.start);
|
|
4587
|
-
const wrapperProps =
|
|
4587
|
+
const wrapperProps = require$$0.useMemo(() => {
|
|
4588
4588
|
return {
|
|
4589
4589
|
style: {
|
|
4590
4590
|
width: "100%",
|
|
@@ -4599,7 +4599,7 @@ function useVirtualList(list = [], options) {
|
|
|
4599
4599
|
calculateRange();
|
|
4600
4600
|
}
|
|
4601
4601
|
};
|
|
4602
|
-
const containerStyle =
|
|
4602
|
+
const containerStyle = require$$0.useMemo(() => {
|
|
4603
4603
|
return { overflowY: "auto", height: containerHeight };
|
|
4604
4604
|
}, [containerHeight]);
|
|
4605
4605
|
return {
|
|
@@ -4636,8 +4636,8 @@ function usePreferredContrast(defaultState) {
|
|
|
4636
4636
|
}
|
|
4637
4637
|
|
|
4638
4638
|
function useActiveElement() {
|
|
4639
|
-
const [active, setActive] =
|
|
4640
|
-
const listener =
|
|
4639
|
+
const [active, setActive] = require$$0.useState(null);
|
|
4640
|
+
const listener = require$$0.useCallback(() => {
|
|
4641
4641
|
setActive(window == null ? void 0 : window.document.activeElement);
|
|
4642
4642
|
}, []);
|
|
4643
4643
|
useEventListener("blur", listener, () => window, true);
|
|
@@ -4649,14 +4649,14 @@ function useDraggable(target, options = {}) {
|
|
|
4649
4649
|
var _a, _b;
|
|
4650
4650
|
const draggingElement = options.draggingElement;
|
|
4651
4651
|
const draggingHandle = (_a = options.handle) != null ? _a : target;
|
|
4652
|
-
const [position, setPositon] =
|
|
4652
|
+
const [position, setPositon] = require$$0.useState(
|
|
4653
4653
|
(_b = options.initialValue) != null ? _b : { x: 0, y: 0 }
|
|
4654
4654
|
);
|
|
4655
|
-
|
|
4655
|
+
require$$0.useEffect(() => {
|
|
4656
4656
|
var _a2;
|
|
4657
4657
|
setPositon((_a2 = options.initialValue) != null ? _a2 : { x: 0, y: 0 });
|
|
4658
4658
|
}, [options.initialValue]);
|
|
4659
|
-
const [pressedDelta, setPressedDelta] =
|
|
4659
|
+
const [pressedDelta, setPressedDelta] = require$$0.useState();
|
|
4660
4660
|
const filterEvent = (e) => {
|
|
4661
4661
|
if (options.pointerTypes) {
|
|
4662
4662
|
return options.pointerTypes.includes(e.pointerType);
|
|
@@ -4731,14 +4731,14 @@ function useElementBounding(target, options = defaultOptions$1) {
|
|
|
4731
4731
|
windowScroll = true,
|
|
4732
4732
|
immediate = true
|
|
4733
4733
|
} = options;
|
|
4734
|
-
const [height, setHeight] =
|
|
4735
|
-
const [bottom, setBottom] =
|
|
4736
|
-
const [left, setLeft] =
|
|
4737
|
-
const [right, setRight] =
|
|
4738
|
-
const [top, setTop] =
|
|
4739
|
-
const [width, setWidth] =
|
|
4740
|
-
const [x, setX] =
|
|
4741
|
-
const [y, setY] =
|
|
4734
|
+
const [height, setHeight] = require$$0.useState(0);
|
|
4735
|
+
const [bottom, setBottom] = require$$0.useState(0);
|
|
4736
|
+
const [left, setLeft] = require$$0.useState(0);
|
|
4737
|
+
const [right, setRight] = require$$0.useState(0);
|
|
4738
|
+
const [top, setTop] = require$$0.useState(0);
|
|
4739
|
+
const [width, setWidth] = require$$0.useState(0);
|
|
4740
|
+
const [x, setX] = require$$0.useState(0);
|
|
4741
|
+
const [y, setY] = require$$0.useState(0);
|
|
4742
4742
|
const update = useEvent(() => {
|
|
4743
4743
|
const element = getTargetElement(target);
|
|
4744
4744
|
if (!element) {
|
|
@@ -4765,12 +4765,12 @@ function useElementBounding(target, options = defaultOptions$1) {
|
|
|
4765
4765
|
setY(rect.y);
|
|
4766
4766
|
});
|
|
4767
4767
|
useResizeObserver(target, update);
|
|
4768
|
-
|
|
4768
|
+
require$$0.useEffect(() => {
|
|
4769
4769
|
if (immediate) {
|
|
4770
4770
|
update();
|
|
4771
4771
|
}
|
|
4772
4772
|
}, [immediate, update]);
|
|
4773
|
-
|
|
4773
|
+
require$$0.useEffect(() => {
|
|
4774
4774
|
if (windowScroll) {
|
|
4775
4775
|
window.addEventListener("scroll", update, { passive: true });
|
|
4776
4776
|
}
|
|
@@ -4800,8 +4800,8 @@ function useElementBounding(target, options = defaultOptions$1) {
|
|
|
4800
4800
|
}
|
|
4801
4801
|
|
|
4802
4802
|
function useElementVisibility(target, options = defaultOptions$1) {
|
|
4803
|
-
const [visible, setVisible] =
|
|
4804
|
-
const callback =
|
|
4803
|
+
const [visible, setVisible] = require$$0.useState(false);
|
|
4804
|
+
const callback = require$$0.useCallback((entries) => {
|
|
4805
4805
|
const rect = entries[0].boundingClientRect;
|
|
4806
4806
|
setVisible(
|
|
4807
4807
|
rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.left <= (window.innerWidth || document.documentElement.clientWidth) && rect.bottom >= 0 && rect.right >= 0
|
|
@@ -4812,8 +4812,8 @@ function useElementVisibility(target, options = defaultOptions$1) {
|
|
|
4812
4812
|
}
|
|
4813
4813
|
|
|
4814
4814
|
function useWindowsFocus(defauleValue = false) {
|
|
4815
|
-
const [focused, setFocused] =
|
|
4816
|
-
|
|
4815
|
+
const [focused, setFocused] = require$$0.useState(defauleValue);
|
|
4816
|
+
require$$0.useEffect(() => {
|
|
4817
4817
|
setFocused(window.document.hasFocus());
|
|
4818
4818
|
}, []);
|
|
4819
4819
|
useEventListener("blur", () => {
|
|
@@ -4825,22 +4825,333 @@ function useWindowsFocus(defauleValue = false) {
|
|
|
4825
4825
|
return focused;
|
|
4826
4826
|
}
|
|
4827
4827
|
|
|
4828
|
+
var shim = {exports: {}};
|
|
4829
|
+
|
|
4830
|
+
var useSyncExternalStoreShim_production_min = {};
|
|
4831
|
+
|
|
4832
|
+
/**
|
|
4833
|
+
* @license React
|
|
4834
|
+
* use-sync-external-store-shim.production.min.js
|
|
4835
|
+
*
|
|
4836
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4837
|
+
*
|
|
4838
|
+
* This source code is licensed under the MIT license found in the
|
|
4839
|
+
* LICENSE file in the root directory of this source tree.
|
|
4840
|
+
*/
|
|
4841
|
+
|
|
4842
|
+
var hasRequiredUseSyncExternalStoreShim_production_min;
|
|
4843
|
+
|
|
4844
|
+
function requireUseSyncExternalStoreShim_production_min () {
|
|
4845
|
+
if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
|
|
4846
|
+
hasRequiredUseSyncExternalStoreShim_production_min = 1;
|
|
4847
|
+
var e=require$$0__default["default"];function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
|
|
4848
|
+
function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;useSyncExternalStoreShim_production_min.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
|
|
4849
|
+
return useSyncExternalStoreShim_production_min;
|
|
4850
|
+
}
|
|
4851
|
+
|
|
4852
|
+
var useSyncExternalStoreShim_development = {};
|
|
4853
|
+
|
|
4854
|
+
/**
|
|
4855
|
+
* @license React
|
|
4856
|
+
* use-sync-external-store-shim.development.js
|
|
4857
|
+
*
|
|
4858
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4859
|
+
*
|
|
4860
|
+
* This source code is licensed under the MIT license found in the
|
|
4861
|
+
* LICENSE file in the root directory of this source tree.
|
|
4862
|
+
*/
|
|
4863
|
+
|
|
4864
|
+
var hasRequiredUseSyncExternalStoreShim_development;
|
|
4865
|
+
|
|
4866
|
+
function requireUseSyncExternalStoreShim_development () {
|
|
4867
|
+
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
4868
|
+
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
4869
|
+
|
|
4870
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4871
|
+
(function() {
|
|
4872
|
+
|
|
4873
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
4874
|
+
if (
|
|
4875
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
4876
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
4877
|
+
'function'
|
|
4878
|
+
) {
|
|
4879
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
4880
|
+
}
|
|
4881
|
+
var React = require$$0__default["default"];
|
|
4882
|
+
|
|
4883
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
4884
|
+
|
|
4885
|
+
function error(format) {
|
|
4886
|
+
{
|
|
4887
|
+
{
|
|
4888
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
4889
|
+
args[_key2 - 1] = arguments[_key2];
|
|
4890
|
+
}
|
|
4891
|
+
|
|
4892
|
+
printWarning('error', format, args);
|
|
4893
|
+
}
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4896
|
+
|
|
4897
|
+
function printWarning(level, format, args) {
|
|
4898
|
+
// When changing this logic, you might want to also
|
|
4899
|
+
// update consoleWithStackDev.www.js as well.
|
|
4900
|
+
{
|
|
4901
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
4902
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
4903
|
+
|
|
4904
|
+
if (stack !== '') {
|
|
4905
|
+
format += '%s';
|
|
4906
|
+
args = args.concat([stack]);
|
|
4907
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
4908
|
+
|
|
4909
|
+
|
|
4910
|
+
var argsWithFormat = args.map(function (item) {
|
|
4911
|
+
return String(item);
|
|
4912
|
+
}); // Careful: RN currently depends on this prefix
|
|
4913
|
+
|
|
4914
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
4915
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
4916
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
4917
|
+
|
|
4918
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4921
|
+
|
|
4922
|
+
/**
|
|
4923
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
4924
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
4925
|
+
*/
|
|
4926
|
+
function is(x, y) {
|
|
4927
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
4928
|
+
;
|
|
4929
|
+
}
|
|
4930
|
+
|
|
4931
|
+
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
4932
|
+
|
|
4933
|
+
// dispatch for CommonJS interop named imports.
|
|
4934
|
+
|
|
4935
|
+
var useState = React.useState,
|
|
4936
|
+
useEffect = React.useEffect,
|
|
4937
|
+
useLayoutEffect = React.useLayoutEffect,
|
|
4938
|
+
useDebugValue = React.useDebugValue;
|
|
4939
|
+
var didWarnOld18Alpha = false;
|
|
4940
|
+
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
|
|
4941
|
+
// because of a very particular set of implementation details and assumptions
|
|
4942
|
+
// -- change any one of them and it will break. The most important assumption
|
|
4943
|
+
// is that updates are always synchronous, because concurrent rendering is
|
|
4944
|
+
// only available in versions of React that also have a built-in
|
|
4945
|
+
// useSyncExternalStore API. And we only use this shim when the built-in API
|
|
4946
|
+
// does not exist.
|
|
4947
|
+
//
|
|
4948
|
+
// Do not assume that the clever hacks used by this hook also work in general.
|
|
4949
|
+
// The point of this shim is to replace the need for hacks by other libraries.
|
|
4950
|
+
|
|
4951
|
+
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
4952
|
+
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
4953
|
+
// will need to track that themselves and return the correct value
|
|
4954
|
+
// from `getSnapshot`.
|
|
4955
|
+
getServerSnapshot) {
|
|
4956
|
+
{
|
|
4957
|
+
if (!didWarnOld18Alpha) {
|
|
4958
|
+
if (React.startTransition !== undefined) {
|
|
4959
|
+
didWarnOld18Alpha = true;
|
|
4960
|
+
|
|
4961
|
+
error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
} // Read the current snapshot from the store on every render. Again, this
|
|
4965
|
+
// breaks the rules of React, and only works here because of specific
|
|
4966
|
+
// implementation details, most importantly that updates are
|
|
4967
|
+
// always synchronous.
|
|
4968
|
+
|
|
4969
|
+
|
|
4970
|
+
var value = getSnapshot();
|
|
4971
|
+
|
|
4972
|
+
{
|
|
4973
|
+
if (!didWarnUncachedGetSnapshot) {
|
|
4974
|
+
var cachedValue = getSnapshot();
|
|
4975
|
+
|
|
4976
|
+
if (!objectIs(value, cachedValue)) {
|
|
4977
|
+
error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
4978
|
+
|
|
4979
|
+
didWarnUncachedGetSnapshot = true;
|
|
4980
|
+
}
|
|
4981
|
+
}
|
|
4982
|
+
} // Because updates are synchronous, we don't queue them. Instead we force a
|
|
4983
|
+
// re-render whenever the subscribed state changes by updating an some
|
|
4984
|
+
// arbitrary useState hook. Then, during render, we call getSnapshot to read
|
|
4985
|
+
// the current value.
|
|
4986
|
+
//
|
|
4987
|
+
// Because we don't actually use the state returned by the useState hook, we
|
|
4988
|
+
// can save a bit of memory by storing other stuff in that slot.
|
|
4989
|
+
//
|
|
4990
|
+
// To implement the early bailout, we need to track some things on a mutable
|
|
4991
|
+
// object. Usually, we would put that in a useRef hook, but we can stash it in
|
|
4992
|
+
// our useState hook instead.
|
|
4993
|
+
//
|
|
4994
|
+
// To force a re-render, we call forceUpdate({inst}). That works because the
|
|
4995
|
+
// new object always fails an equality check.
|
|
4996
|
+
|
|
4997
|
+
|
|
4998
|
+
var _useState = useState({
|
|
4999
|
+
inst: {
|
|
5000
|
+
value: value,
|
|
5001
|
+
getSnapshot: getSnapshot
|
|
5002
|
+
}
|
|
5003
|
+
}),
|
|
5004
|
+
inst = _useState[0].inst,
|
|
5005
|
+
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
|
|
5006
|
+
// in the layout phase so we can access it during the tearing check that
|
|
5007
|
+
// happens on subscribe.
|
|
5008
|
+
|
|
5009
|
+
|
|
5010
|
+
useLayoutEffect(function () {
|
|
5011
|
+
inst.value = value;
|
|
5012
|
+
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
|
|
5013
|
+
// commit phase if there was an interleaved mutation. In concurrent mode
|
|
5014
|
+
// this can happen all the time, but even in synchronous mode, an earlier
|
|
5015
|
+
// effect may have mutated the store.
|
|
5016
|
+
|
|
5017
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
5018
|
+
// Force a re-render.
|
|
5019
|
+
forceUpdate({
|
|
5020
|
+
inst: inst
|
|
5021
|
+
});
|
|
5022
|
+
}
|
|
5023
|
+
}, [subscribe, value, getSnapshot]);
|
|
5024
|
+
useEffect(function () {
|
|
5025
|
+
// Check for changes right before subscribing. Subsequent changes will be
|
|
5026
|
+
// detected in the subscription handler.
|
|
5027
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
5028
|
+
// Force a re-render.
|
|
5029
|
+
forceUpdate({
|
|
5030
|
+
inst: inst
|
|
5031
|
+
});
|
|
5032
|
+
}
|
|
5033
|
+
|
|
5034
|
+
var handleStoreChange = function () {
|
|
5035
|
+
// TODO: Because there is no cross-renderer API for batching updates, it's
|
|
5036
|
+
// up to the consumer of this library to wrap their subscription event
|
|
5037
|
+
// with unstable_batchedUpdates. Should we try to detect when this isn't
|
|
5038
|
+
// the case and print a warning in development?
|
|
5039
|
+
// The store changed. Check if the snapshot changed since the last time we
|
|
5040
|
+
// read from the store.
|
|
5041
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
5042
|
+
// Force a re-render.
|
|
5043
|
+
forceUpdate({
|
|
5044
|
+
inst: inst
|
|
5045
|
+
});
|
|
5046
|
+
}
|
|
5047
|
+
}; // Subscribe to the store and return a clean-up function.
|
|
5048
|
+
|
|
5049
|
+
|
|
5050
|
+
return subscribe(handleStoreChange);
|
|
5051
|
+
}, [subscribe]);
|
|
5052
|
+
useDebugValue(value);
|
|
5053
|
+
return value;
|
|
5054
|
+
}
|
|
5055
|
+
|
|
5056
|
+
function checkIfSnapshotChanged(inst) {
|
|
5057
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
5058
|
+
var prevValue = inst.value;
|
|
5059
|
+
|
|
5060
|
+
try {
|
|
5061
|
+
var nextValue = latestGetSnapshot();
|
|
5062
|
+
return !objectIs(prevValue, nextValue);
|
|
5063
|
+
} catch (error) {
|
|
5064
|
+
return true;
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
|
|
5068
|
+
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
5069
|
+
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
5070
|
+
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
5071
|
+
// will need to track that themselves and return the correct value
|
|
5072
|
+
// from `getSnapshot`.
|
|
5073
|
+
return getSnapshot();
|
|
5074
|
+
}
|
|
5075
|
+
|
|
5076
|
+
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
|
|
5077
|
+
|
|
5078
|
+
var isServerEnvironment = !canUseDOM;
|
|
5079
|
+
|
|
5080
|
+
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
5081
|
+
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
|
|
5082
|
+
|
|
5083
|
+
useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
|
|
5084
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
5085
|
+
if (
|
|
5086
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
5087
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
5088
|
+
'function'
|
|
5089
|
+
) {
|
|
5090
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
5091
|
+
}
|
|
5092
|
+
|
|
5093
|
+
})();
|
|
5094
|
+
}
|
|
5095
|
+
return useSyncExternalStoreShim_development;
|
|
5096
|
+
}
|
|
5097
|
+
|
|
5098
|
+
(function (module) {
|
|
5099
|
+
|
|
5100
|
+
if (process.env.NODE_ENV === 'production') {
|
|
5101
|
+
module.exports = requireUseSyncExternalStoreShim_production_min();
|
|
5102
|
+
} else {
|
|
5103
|
+
module.exports = requireUseSyncExternalStoreShim_development();
|
|
5104
|
+
}
|
|
5105
|
+
} (shim));
|
|
5106
|
+
|
|
5107
|
+
const subscribe$1 = (callback) => {
|
|
5108
|
+
window.addEventListener("resize", callback);
|
|
5109
|
+
return () => {
|
|
5110
|
+
window.removeEventListener("resize", callback);
|
|
5111
|
+
};
|
|
5112
|
+
};
|
|
4828
5113
|
function useWindowSize() {
|
|
4829
|
-
const
|
|
5114
|
+
const stateDependencies = require$$0.useRef({}).current;
|
|
5115
|
+
const previous = require$$0.useRef({
|
|
4830
5116
|
width: 0,
|
|
4831
5117
|
height: 0
|
|
4832
5118
|
});
|
|
4833
|
-
const
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
5119
|
+
const isEqual = (prev, current) => {
|
|
5120
|
+
for (const _ in stateDependencies) {
|
|
5121
|
+
const t = _;
|
|
5122
|
+
if (current[t] !== prev[t]) {
|
|
5123
|
+
return false;
|
|
5124
|
+
}
|
|
5125
|
+
}
|
|
5126
|
+
return true;
|
|
5127
|
+
};
|
|
5128
|
+
const cached = shim.exports.useSyncExternalStore(
|
|
5129
|
+
subscribe$1,
|
|
5130
|
+
() => {
|
|
5131
|
+
const data = {
|
|
5132
|
+
width: window.innerWidth,
|
|
5133
|
+
height: window.innerHeight
|
|
5134
|
+
};
|
|
5135
|
+
if (!isEqual(previous.current, data)) {
|
|
5136
|
+
previous.current = data;
|
|
5137
|
+
return data;
|
|
5138
|
+
}
|
|
5139
|
+
return previous.current;
|
|
5140
|
+
},
|
|
5141
|
+
() => {
|
|
5142
|
+
return previous.current;
|
|
5143
|
+
}
|
|
5144
|
+
);
|
|
5145
|
+
return {
|
|
5146
|
+
get width() {
|
|
5147
|
+
stateDependencies.width = true;
|
|
5148
|
+
return cached.width;
|
|
5149
|
+
},
|
|
5150
|
+
get height() {
|
|
5151
|
+
stateDependencies.height = true;
|
|
5152
|
+
return cached.height;
|
|
5153
|
+
}
|
|
4838
5154
|
};
|
|
4839
|
-
useEventListener("resize", handleSize);
|
|
4840
|
-
useIsomorphicLayoutEffect(() => {
|
|
4841
|
-
handleSize();
|
|
4842
|
-
}, []);
|
|
4843
|
-
return windowSize;
|
|
4844
5155
|
}
|
|
4845
5156
|
|
|
4846
5157
|
const listenerOptions$1 = {
|
|
@@ -4883,15 +5194,15 @@ var __async$3 = (__this, __arguments, generator) => {
|
|
|
4883
5194
|
});
|
|
4884
5195
|
};
|
|
4885
5196
|
function useClipBorad() {
|
|
4886
|
-
const [text, setText] =
|
|
4887
|
-
const updateText =
|
|
5197
|
+
const [text, setText] = require$$0.useState("");
|
|
5198
|
+
const updateText = require$$0.useCallback(() => {
|
|
4888
5199
|
window.navigator.clipboard.readText().then((value) => {
|
|
4889
5200
|
setText(value);
|
|
4890
5201
|
});
|
|
4891
5202
|
}, []);
|
|
4892
5203
|
useEventListener("copy", updateText);
|
|
4893
5204
|
useEventListener("cut", updateText);
|
|
4894
|
-
const copy =
|
|
5205
|
+
const copy = require$$0.useCallback((txt) => __async$3(this, null, function* () {
|
|
4895
5206
|
setText(txt);
|
|
4896
5207
|
yield window.navigator.clipboard.writeText(txt);
|
|
4897
5208
|
}), []);
|
|
@@ -4919,7 +5230,7 @@ function useClickOutside(target, handler) {
|
|
|
4919
5230
|
}
|
|
4920
5231
|
|
|
4921
5232
|
function useCycleList(list, i = 0) {
|
|
4922
|
-
const [index, setIndex] =
|
|
5233
|
+
const [index, setIndex] = require$$0.useState(i);
|
|
4923
5234
|
const set = (i2) => {
|
|
4924
5235
|
const length = list.length;
|
|
4925
5236
|
const nextIndex = ((index + i2) % length + length) % length;
|
|
@@ -4935,7 +5246,7 @@ function useCycleList(list, i = 0) {
|
|
|
4935
5246
|
}
|
|
4936
5247
|
|
|
4937
5248
|
function useFocus(target, initialValue = false) {
|
|
4938
|
-
const [focus, innerSetFocus] =
|
|
5249
|
+
const [focus, innerSetFocus] = require$$0.useState(initialValue);
|
|
4939
5250
|
useEventListener("focus", () => innerSetFocus(true), target);
|
|
4940
5251
|
useEventListener("blur", () => innerSetFocus(false), target);
|
|
4941
5252
|
const setFocus = (value) => {
|
|
@@ -4961,10 +5272,10 @@ function useControlled(props) {
|
|
|
4961
5272
|
defaultValue: void 0,
|
|
4962
5273
|
state: "value"
|
|
4963
5274
|
};
|
|
4964
|
-
const { current: isControlled } =
|
|
4965
|
-
const [valueState, setValue] =
|
|
5275
|
+
const { current: isControlled } = require$$0.useRef(controlled !== void 0);
|
|
5276
|
+
const [valueState, setValue] = require$$0.useState(defaultProp);
|
|
4966
5277
|
const value = isControlled ? controlled : valueState;
|
|
4967
|
-
|
|
5278
|
+
require$$0.useEffect(() => {
|
|
4968
5279
|
if (isControlled !== (controlled !== void 0)) {
|
|
4969
5280
|
console.error(
|
|
4970
5281
|
[
|
|
@@ -4977,7 +5288,7 @@ function useControlled(props) {
|
|
|
4977
5288
|
);
|
|
4978
5289
|
}
|
|
4979
5290
|
}, [state, controlled]);
|
|
4980
|
-
const setValueIfUncontrolled =
|
|
5291
|
+
const setValueIfUncontrolled = require$$0.useCallback((newValue) => {
|
|
4981
5292
|
if (!isControlled) {
|
|
4982
5293
|
setValue(newValue);
|
|
4983
5294
|
}
|
|
@@ -4999,9 +5310,9 @@ const createOnceEffect = (hook) => (effect, deps) => {
|
|
|
4999
5310
|
}, deps);
|
|
5000
5311
|
};
|
|
5001
5312
|
|
|
5002
|
-
var index$1 = createOnceEffect(
|
|
5313
|
+
var index$1 = createOnceEffect(require$$0.useEffect);
|
|
5003
5314
|
|
|
5004
|
-
var index = createOnceEffect(
|
|
5315
|
+
var index = createOnceEffect(require$$0.useLayoutEffect);
|
|
5005
5316
|
|
|
5006
5317
|
function useReducedMotion(defaultState) {
|
|
5007
5318
|
return useMediaQuery("(prefers-reduced-motion: reduce)", defaultState);
|
|
@@ -5136,9 +5447,9 @@ function useScrollIntoView(targetElement, {
|
|
|
5136
5447
|
cancelable = true,
|
|
5137
5448
|
isList = false
|
|
5138
5449
|
} = defaultOptions$1, scrollElement) {
|
|
5139
|
-
const frameID =
|
|
5140
|
-
const startTime =
|
|
5141
|
-
const shouldStop =
|
|
5450
|
+
const frameID = require$$0.useRef(0);
|
|
5451
|
+
const startTime = require$$0.useRef(0);
|
|
5452
|
+
const shouldStop = require$$0.useRef(false);
|
|
5142
5453
|
const reducedMotion = useReducedMotion(false);
|
|
5143
5454
|
const cancel = () => {
|
|
5144
5455
|
if (frameID.current) {
|
|
@@ -5195,7 +5506,7 @@ function useScrollIntoView(targetElement, {
|
|
|
5195
5506
|
};
|
|
5196
5507
|
useEventListener("wheel", handleStop, null, listenerOptions);
|
|
5197
5508
|
useEventListener("touchmove", handleStop, null, listenerOptions);
|
|
5198
|
-
|
|
5509
|
+
require$$0.useEffect(() => cancel, []);
|
|
5199
5510
|
return {
|
|
5200
5511
|
scrollIntoView,
|
|
5201
5512
|
cancel
|
|
@@ -5203,7 +5514,7 @@ function useScrollIntoView(targetElement, {
|
|
|
5203
5514
|
}
|
|
5204
5515
|
|
|
5205
5516
|
const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement) => {
|
|
5206
|
-
const [isSticky, setSticky] =
|
|
5517
|
+
const [isSticky, setSticky] = require$$0.useState(false);
|
|
5207
5518
|
const element = useLatestElement(targetElement);
|
|
5208
5519
|
const { run: scrollHandler } = useThrottleFn(() => {
|
|
5209
5520
|
if (!element) {
|
|
@@ -5216,7 +5527,7 @@ const useSticky = (targetElement, { axis = "y", nav = 0 }, scrollElement) => {
|
|
|
5216
5527
|
setSticky((rect == null ? void 0 : rect.left) <= nav);
|
|
5217
5528
|
}
|
|
5218
5529
|
}, 50);
|
|
5219
|
-
|
|
5530
|
+
require$$0.useEffect(() => {
|
|
5220
5531
|
const scrollParent = getTargetElement(scrollElement) || getScrollParent(axis, element);
|
|
5221
5532
|
if (!element || !scrollParent) {
|
|
5222
5533
|
return;
|
|
@@ -5252,7 +5563,7 @@ var __async$2 = (__this, __arguments, generator) => {
|
|
|
5252
5563
|
};
|
|
5253
5564
|
function useAsyncEffect(effect, cleanup = noop, deps) {
|
|
5254
5565
|
const mounted = useMountedState();
|
|
5255
|
-
|
|
5566
|
+
require$$0.useEffect(() => {
|
|
5256
5567
|
const execute = () => __async$2(this, null, function* () {
|
|
5257
5568
|
if (!mounted()) {
|
|
5258
5569
|
return;
|
|
@@ -5282,8 +5593,8 @@ const getHMSTime = (timeDiff) => {
|
|
|
5282
5593
|
return [padZero(hour), padZero(minute), padZero(second)];
|
|
5283
5594
|
};
|
|
5284
5595
|
const useCountDown = (time, format = getHMSTime, callback) => {
|
|
5285
|
-
const [remainTime, setRemainTime] =
|
|
5286
|
-
const [delay, setDelay] =
|
|
5596
|
+
const [remainTime, setRemainTime] = require$$0.useState(time);
|
|
5597
|
+
const [delay, setDelay] = require$$0.useState(1e3);
|
|
5287
5598
|
useInterval(() => {
|
|
5288
5599
|
if (remainTime <= 0) {
|
|
5289
5600
|
setDelay(null);
|
|
@@ -5291,7 +5602,7 @@ const useCountDown = (time, format = getHMSTime, callback) => {
|
|
|
5291
5602
|
}
|
|
5292
5603
|
setRemainTime(remainTime - 1);
|
|
5293
5604
|
}, delay);
|
|
5294
|
-
|
|
5605
|
+
require$$0.useEffect(() => {
|
|
5295
5606
|
if (time > 0 && remainTime <= 0) {
|
|
5296
5607
|
callback && callback();
|
|
5297
5608
|
}
|
|
@@ -5301,14 +5612,14 @@ const useCountDown = (time, format = getHMSTime, callback) => {
|
|
|
5301
5612
|
};
|
|
5302
5613
|
|
|
5303
5614
|
function useTextSelection() {
|
|
5304
|
-
const [selection, setSelection] =
|
|
5615
|
+
const [selection, setSelection] = require$$0.useState(null);
|
|
5305
5616
|
const forceUpdate = useUpdate();
|
|
5306
5617
|
const handleSelectionChange = () => {
|
|
5307
5618
|
setSelection(document.getSelection());
|
|
5308
5619
|
forceUpdate();
|
|
5309
5620
|
};
|
|
5310
5621
|
useEventListener("selectionchange", handleSelectionChange, () => document);
|
|
5311
|
-
|
|
5622
|
+
require$$0.useEffect(() => {
|
|
5312
5623
|
setSelection(document.getSelection());
|
|
5313
5624
|
}, []);
|
|
5314
5625
|
return selection;
|
|
@@ -5339,7 +5650,7 @@ function useEyeDropper() {
|
|
|
5339
5650
|
() => typeof window !== "undefined" && "EyeDropper" in window,
|
|
5340
5651
|
true
|
|
5341
5652
|
);
|
|
5342
|
-
const open =
|
|
5653
|
+
const open = require$$0.useCallback(
|
|
5343
5654
|
(..._0) => __async$1(this, [..._0], function* (options = {}) {
|
|
5344
5655
|
if (!isSupported) {
|
|
5345
5656
|
return {
|
|
@@ -5501,10 +5812,10 @@ const getInitialState$1 = (key, defaultValue) => {
|
|
|
5501
5812
|
return "";
|
|
5502
5813
|
};
|
|
5503
5814
|
function useCookie(key, options = defaultOptions$1, defaultValue) {
|
|
5504
|
-
const [cookieValue, setCookieValue] =
|
|
5815
|
+
const [cookieValue, setCookieValue] = require$$0.useState(
|
|
5505
5816
|
getInitialState$1(key, defaultValue)
|
|
5506
5817
|
);
|
|
5507
|
-
|
|
5818
|
+
require$$0.useEffect(() => {
|
|
5508
5819
|
const getStoredValue = () => {
|
|
5509
5820
|
const raw = api.get(key);
|
|
5510
5821
|
if (raw !== void 0 && raw !== null) {
|
|
@@ -5520,7 +5831,7 @@ function useCookie(key, options = defaultOptions$1, defaultValue) {
|
|
|
5520
5831
|
};
|
|
5521
5832
|
setCookieValue(getStoredValue());
|
|
5522
5833
|
}, [defaultValue, key, options]);
|
|
5523
|
-
const updateCookie =
|
|
5834
|
+
const updateCookie = require$$0.useCallback(
|
|
5524
5835
|
(newValue) => {
|
|
5525
5836
|
const value = isFunction$1(newValue) ? newValue(cookieValue) : newValue;
|
|
5526
5837
|
if (value === void 0) {
|
|
@@ -5532,7 +5843,7 @@ function useCookie(key, options = defaultOptions$1, defaultValue) {
|
|
|
5532
5843
|
},
|
|
5533
5844
|
[key, cookieValue, options]
|
|
5534
5845
|
);
|
|
5535
|
-
const refreshCookie =
|
|
5846
|
+
const refreshCookie = require$$0.useCallback(() => {
|
|
5536
5847
|
const cookieValue2 = api.get(key);
|
|
5537
5848
|
if (isString(cookieValue2)) {
|
|
5538
5849
|
setCookieValue(cookieValue2);
|
|
@@ -5550,7 +5861,7 @@ function useDoubleClick({
|
|
|
5550
5861
|
}
|
|
5551
5862
|
}) {
|
|
5552
5863
|
const element = useLatestElement(target);
|
|
5553
|
-
const handle =
|
|
5864
|
+
const handle = require$$0.useCallback(
|
|
5554
5865
|
(onSingleClick2, onDoubleClick2) => {
|
|
5555
5866
|
let count = 0;
|
|
5556
5867
|
return (e) => {
|
|
@@ -5594,8 +5905,8 @@ var __spreadValues = (a, b) => {
|
|
|
5594
5905
|
return a;
|
|
5595
5906
|
};
|
|
5596
5907
|
function useSetState(initialState) {
|
|
5597
|
-
const [state, _setState] =
|
|
5598
|
-
const setState =
|
|
5908
|
+
const [state, _setState] = require$$0.useState(initialState);
|
|
5909
|
+
const setState = require$$0.useCallback(
|
|
5599
5910
|
(statePartial) => _setState((current) => __spreadValues(__spreadValues({}, current), typeof statePartial === "function" ? statePartial(current) : statePartial)),
|
|
5600
5911
|
[]
|
|
5601
5912
|
);
|
|
@@ -5613,7 +5924,7 @@ const defaultState = {
|
|
|
5613
5924
|
right: 0
|
|
5614
5925
|
};
|
|
5615
5926
|
function useMeasure(target, options = defaultOptions$1) {
|
|
5616
|
-
const [rect, setRect] =
|
|
5927
|
+
const [rect, setRect] = require$$0.useState(defaultState);
|
|
5617
5928
|
const stop = useResizeObserver(
|
|
5618
5929
|
target,
|
|
5619
5930
|
(entries) => {
|
|
@@ -5628,9 +5939,9 @@ function useMeasure(target, options = defaultOptions$1) {
|
|
|
5628
5939
|
}
|
|
5629
5940
|
|
|
5630
5941
|
function useHover(target) {
|
|
5631
|
-
const [hovered, setHovered] =
|
|
5632
|
-
const onMouseEnter =
|
|
5633
|
-
const onMouseLeave =
|
|
5942
|
+
const [hovered, setHovered] = require$$0.useState(false);
|
|
5943
|
+
const onMouseEnter = require$$0.useCallback(() => setHovered(true), []);
|
|
5944
|
+
const onMouseLeave = require$$0.useCallback(() => setHovered(false), []);
|
|
5634
5945
|
useEventListener("mouseenter", onMouseEnter, target);
|
|
5635
5946
|
useEventListener("mouseleave", onMouseLeave, target);
|
|
5636
5947
|
return hovered;
|
|
@@ -5655,12 +5966,12 @@ const getInitialState = (defaultValue) => {
|
|
|
5655
5966
|
};
|
|
5656
5967
|
function useCssVar(prop, target, defaultValue, options = defaultOptions) {
|
|
5657
5968
|
const { observe } = options;
|
|
5658
|
-
const [variable, setVariable] =
|
|
5969
|
+
const [variable, setVariable] = require$$0.useState(
|
|
5659
5970
|
getInitialState(defaultValue)
|
|
5660
5971
|
);
|
|
5661
5972
|
const element = useLatestElement(target);
|
|
5662
|
-
const observerRef =
|
|
5663
|
-
const set =
|
|
5973
|
+
const observerRef = require$$0.useRef();
|
|
5974
|
+
const set = require$$0.useCallback(
|
|
5664
5975
|
(v) => {
|
|
5665
5976
|
if (element == null ? void 0 : element.style) {
|
|
5666
5977
|
element == null ? void 0 : element.style.setProperty(prop, v);
|
|
@@ -5669,14 +5980,14 @@ function useCssVar(prop, target, defaultValue, options = defaultOptions) {
|
|
|
5669
5980
|
},
|
|
5670
5981
|
[element, prop]
|
|
5671
5982
|
);
|
|
5672
|
-
const updateCssVar =
|
|
5983
|
+
const updateCssVar = require$$0.useCallback(() => {
|
|
5673
5984
|
var _a;
|
|
5674
5985
|
if (element) {
|
|
5675
5986
|
const value = (_a = window.getComputedStyle(element).getPropertyValue(prop)) == null ? void 0 : _a.trim();
|
|
5676
5987
|
setVariable(value);
|
|
5677
5988
|
}
|
|
5678
5989
|
}, [element, prop]);
|
|
5679
|
-
|
|
5990
|
+
require$$0.useEffect(() => {
|
|
5680
5991
|
var _a;
|
|
5681
5992
|
if (!element) {
|
|
5682
5993
|
return;
|
|
@@ -5709,10 +6020,10 @@ const bottomVarName = "--reactuse-safe-area-bottom";
|
|
|
5709
6020
|
const leftVarName = "--reactuse-safe-area-left";
|
|
5710
6021
|
const defaultElement = () => document.documentElement;
|
|
5711
6022
|
function useScreenSafeArea() {
|
|
5712
|
-
const top =
|
|
5713
|
-
const right =
|
|
5714
|
-
const bottom =
|
|
5715
|
-
const left =
|
|
6023
|
+
const top = require$$0.useRef("");
|
|
6024
|
+
const right = require$$0.useRef("");
|
|
6025
|
+
const bottom = require$$0.useRef("");
|
|
6026
|
+
const left = require$$0.useRef("");
|
|
5716
6027
|
const forceUpdate = useUpdate();
|
|
5717
6028
|
useCssVar(topVarName, defaultElement, "env(safe-area-inset-top, 0px)");
|
|
5718
6029
|
useCssVar(rightVarName, defaultElement, "env(safe-area-inset-right, 0px)");
|
|
@@ -5725,7 +6036,7 @@ function useScreenSafeArea() {
|
|
|
5725
6036
|
left.current = getValue(leftVarName);
|
|
5726
6037
|
forceUpdate();
|
|
5727
6038
|
});
|
|
5728
|
-
|
|
6039
|
+
require$$0.useEffect(() => {
|
|
5729
6040
|
update();
|
|
5730
6041
|
}, [update]);
|
|
5731
6042
|
useEventListener("resize", update);
|
|
@@ -5763,8 +6074,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
5763
6074
|
};
|
|
5764
6075
|
function useWebNotification(requestPermissions = false) {
|
|
5765
6076
|
const isSupported = useSupported(() => !!window && "Notification" in window);
|
|
5766
|
-
const permissionGranted =
|
|
5767
|
-
const notificationRef =
|
|
6077
|
+
const permissionGranted = require$$0.useRef(false);
|
|
6078
|
+
const notificationRef = require$$0.useRef(null);
|
|
5768
6079
|
const show = (title, options = defaultOptions$1) => {
|
|
5769
6080
|
if (!isSupported && !permissionGranted.current) {
|
|
5770
6081
|
return;
|
|
@@ -5772,16 +6083,16 @@ function useWebNotification(requestPermissions = false) {
|
|
|
5772
6083
|
notificationRef.current = new Notification(title || "", options);
|
|
5773
6084
|
return notificationRef.current;
|
|
5774
6085
|
};
|
|
5775
|
-
const close =
|
|
6086
|
+
const close = require$$0.useCallback(() => {
|
|
5776
6087
|
if (notificationRef.current) {
|
|
5777
6088
|
notificationRef.current.close();
|
|
5778
6089
|
}
|
|
5779
6090
|
notificationRef.current = null;
|
|
5780
6091
|
}, []);
|
|
5781
|
-
|
|
6092
|
+
require$$0.useEffect(() => {
|
|
5782
6093
|
permissionGranted.current = isSupported && "permission" in Notification && Notification.permission === "granted";
|
|
5783
6094
|
}, [isSupported]);
|
|
5784
|
-
const ensurePermissions =
|
|
6095
|
+
const ensurePermissions = require$$0.useCallback(() => __async(this, null, function* () {
|
|
5785
6096
|
if (!isSupported)
|
|
5786
6097
|
return;
|
|
5787
6098
|
if (!permissionGranted.current && Notification.permission !== "denied") {
|
|
@@ -5791,7 +6102,7 @@ function useWebNotification(requestPermissions = false) {
|
|
|
5791
6102
|
}
|
|
5792
6103
|
return permissionGranted.current;
|
|
5793
6104
|
}), [isSupported]);
|
|
5794
|
-
|
|
6105
|
+
require$$0.useEffect(() => {
|
|
5795
6106
|
if (requestPermissions) {
|
|
5796
6107
|
ensurePermissions();
|
|
5797
6108
|
}
|
|
@@ -5806,6 +6117,22 @@ function useWebNotification(requestPermissions = false) {
|
|
|
5806
6117
|
};
|
|
5807
6118
|
}
|
|
5808
6119
|
|
|
6120
|
+
function subscribe(callback) {
|
|
6121
|
+
window.addEventListener("popstate", callback);
|
|
6122
|
+
window.addEventListener("hashchange", callback);
|
|
6123
|
+
return () => {
|
|
6124
|
+
window.removeEventListener("popstate", callback);
|
|
6125
|
+
window.removeEventListener("hashchange", callback);
|
|
6126
|
+
};
|
|
6127
|
+
}
|
|
6128
|
+
function useLocationSelector(selector, fallback) {
|
|
6129
|
+
return shim.exports.useSyncExternalStore(
|
|
6130
|
+
subscribe,
|
|
6131
|
+
() => selector(location),
|
|
6132
|
+
() => fallback
|
|
6133
|
+
);
|
|
6134
|
+
}
|
|
6135
|
+
|
|
5809
6136
|
exports.getHMSTime = getHMSTime;
|
|
5810
6137
|
exports.useActiveElement = useActiveElement;
|
|
5811
6138
|
exports.useAsyncEffect = useAsyncEffect;
|
|
@@ -5849,6 +6176,7 @@ exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
|
5849
6176
|
exports.useKeyModifier = useKeyModifier;
|
|
5850
6177
|
exports.useLatest = useLatest;
|
|
5851
6178
|
exports.useLocalStorage = useLocalStorage;
|
|
6179
|
+
exports.useLocationSelector = useLocationSelector;
|
|
5852
6180
|
exports.useLongPress = useLongPress;
|
|
5853
6181
|
exports.useMeasure = useMeasure;
|
|
5854
6182
|
exports.useMediaDevices = useMediaDevices;
|