@reactuses/core 5.0.18 → 5.0.19-beta.2
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/README.md +13 -13
- package/dist/index.cjs +251 -14
- package/dist/index.d.cts +180 -1
- package/dist/index.d.mts +180 -1
- package/dist/index.d.ts +180 -1
- package/dist/index.mjs +245 -12
- package/dist/useQRCode.cjs +95 -0
- package/dist/useQRCode.d.cts +36 -0
- package/dist/useQRCode.d.mts +36 -0
- package/dist/useQRCode.mjs +88 -0
- package/package.json +19 -1
- package/dist/index-client-DJgtg2U_.cjs +0 -30
- package/dist/index-client-Qon46B4S.js +0 -28
package/README.md
CHANGED
|
@@ -56,19 +56,6 @@ Refer to [documentations](https://reactuse.com/) for more details.
|
|
|
56
56
|
|
|
57
57
|
<hr/>
|
|
58
58
|
|
|
59
|
-
## Sponsor Me
|
|
60
|
-
|
|
61
|
-
If my work has helped you, consider buying me a cup of coffee. Thank you very much🥰!.
|
|
62
|
-
|
|
63
|
-
[Buy me a coffee](https://www.buymeacoffee.com/lianwenwu)
|
|
64
|
-
|
|
65
|
-
### For Chinese User
|
|
66
|
-
|
|
67
|
-
<p float="left">
|
|
68
|
-
<img src="https://d21002cb.images-f3o.pages.dev/images/wechat.jpg" alt="Wechat Pay" width="200" />
|
|
69
|
-
<img src="https://d21002cb.images-f3o.pages.dev/images/ali.jpg" alt="Ali Pay" width="200" />
|
|
70
|
-
</p>
|
|
71
|
-
|
|
72
59
|
## Feedback
|
|
73
60
|
|
|
74
61
|
You can submit an [issue](https://github.com/childrentime/reactuse/issues) or provide feedback on [Discord](https://discord.gg/HMsq6cFkKp).
|
|
@@ -94,3 +81,16 @@ This project is heavily inspired by the following awesome projects.
|
|
|
94
81
|
- [vueuse](https://github.com/vueuse/vueuse)
|
|
95
82
|
|
|
96
83
|
<hr/>
|
|
84
|
+
|
|
85
|
+
## Sponsor Me
|
|
86
|
+
|
|
87
|
+
If my work has helped you, consider buying me a cup of coffee. Thank you very much🥰!.
|
|
88
|
+
|
|
89
|
+
[Buy me a coffee](https://www.buymeacoffee.com/lianwenwu)
|
|
90
|
+
|
|
91
|
+
### For Chinese User
|
|
92
|
+
|
|
93
|
+
<p float="left">
|
|
94
|
+
<img src="https://d21002cb.images-f3o.pages.dev/images/wechat.jpg" alt="Wechat Pay" width="200" />
|
|
95
|
+
<img src="https://d21002cb.images-f3o.pages.dev/images/ali.jpg" alt="Ali Pay" width="200" />
|
|
96
|
+
</p>
|
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,6 @@ var lodashEs = require('lodash-es');
|
|
|
5
5
|
var Cookies = require('js-cookie');
|
|
6
6
|
var screenfull = require('screenfull');
|
|
7
7
|
var index_js = require('use-sync-external-store/shim/index.js');
|
|
8
|
-
var indexClient = require('./index-client-DJgtg2U_.cjs');
|
|
9
8
|
|
|
10
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
10
|
|
|
@@ -207,7 +206,7 @@ const useClickOutside = (target, handler, enabled = true)=>{
|
|
|
207
206
|
useEventListener('touchstart', listener, defaultWindow, listerOptions);
|
|
208
207
|
};
|
|
209
208
|
|
|
210
|
-
function getInitialState$
|
|
209
|
+
function getInitialState$5(key, defaultValue) {
|
|
211
210
|
// Prevent a React hydration mismatch when a default value is provided.
|
|
212
211
|
if (defaultValue !== undefined) {
|
|
213
212
|
return defaultValue;
|
|
@@ -221,7 +220,7 @@ function getInitialState$4(key, defaultValue) {
|
|
|
221
220
|
return '';
|
|
222
221
|
}
|
|
223
222
|
const useCookie = (key, options = defaultOptions$1, defaultValue)=>{
|
|
224
|
-
const [cookieValue, setCookieValue] = React.useState(getInitialState$
|
|
223
|
+
const [cookieValue, setCookieValue] = React.useState(getInitialState$5(key, defaultValue));
|
|
225
224
|
React.useEffect(()=>{
|
|
226
225
|
const getStoredValue = ()=>{
|
|
227
226
|
const raw = Cookies__default.default.get(key);
|
|
@@ -442,7 +441,7 @@ const defaultOptions = {
|
|
|
442
441
|
observe: false
|
|
443
442
|
};
|
|
444
443
|
|
|
445
|
-
function getInitialState$
|
|
444
|
+
function getInitialState$4(defaultValue) {
|
|
446
445
|
// Prevent a React hydration mismatch when a default value is provided.
|
|
447
446
|
if (defaultValue !== undefined) {
|
|
448
447
|
return defaultValue;
|
|
@@ -457,7 +456,7 @@ function getInitialState$3(defaultValue) {
|
|
|
457
456
|
}
|
|
458
457
|
const useCssVar = (prop, target, defaultValue, options = defaultOptions)=>{
|
|
459
458
|
const { observe } = options;
|
|
460
|
-
const [variable, setVariable] = React.useState(getInitialState$
|
|
459
|
+
const [variable, setVariable] = React.useState(getInitialState$4(defaultValue));
|
|
461
460
|
const observerRef = React.useRef();
|
|
462
461
|
const set = React.useCallback((v)=>{
|
|
463
462
|
const element = getTargetElement(target);
|
|
@@ -579,7 +578,7 @@ const StorageSerializers = {
|
|
|
579
578
|
write: (v)=>v.toISOString()
|
|
580
579
|
}
|
|
581
580
|
};
|
|
582
|
-
function getInitialState$
|
|
581
|
+
function getInitialState$3(key, defaultValue, storage, serializer, onError) {
|
|
583
582
|
// Prevent a React hydration mismatch when a default value is provided.
|
|
584
583
|
if (defaultValue !== undefined) {
|
|
585
584
|
return defaultValue;
|
|
@@ -612,7 +611,7 @@ function useStorage(key, defaultValue, getStorage = ()=>isBrowser ? sessionStora
|
|
|
612
611
|
const type = guessSerializerType(defaultValue);
|
|
613
612
|
var _options_serializer;
|
|
614
613
|
const serializer = (_options_serializer = options.serializer) != null ? _options_serializer : StorageSerializers[type];
|
|
615
|
-
const [state, setState] = React.useState(getInitialState$
|
|
614
|
+
const [state, setState] = React.useState(getInitialState$3(key, defaultValue, storage, serializer, onError));
|
|
616
615
|
useDeepCompareEffect(()=>{
|
|
617
616
|
var _ref;
|
|
618
617
|
const data = (_ref = effectStorageValue ? isFunction(effectStorageValue) ? effectStorageValue() : effectStorageValue : defaultValue) != null ? _ref : null;
|
|
@@ -755,7 +754,7 @@ const useDebounce = (value, wait, options)=>{
|
|
|
755
754
|
return debounced;
|
|
756
755
|
};
|
|
757
756
|
|
|
758
|
-
function getInitialState$
|
|
757
|
+
function getInitialState$2(defaultValue) {
|
|
759
758
|
// Prevent a React hydration mismatch when a default value is provided.
|
|
760
759
|
if (defaultValue !== undefined) {
|
|
761
760
|
return defaultValue;
|
|
@@ -769,7 +768,7 @@ function getInitialState$1(defaultValue) {
|
|
|
769
768
|
return 'visible';
|
|
770
769
|
}
|
|
771
770
|
function useDocumentVisibility(defaultValue) {
|
|
772
|
-
const [visible, setVisible] = React.useState(getInitialState$
|
|
771
|
+
const [visible, setVisible] = React.useState(getInitialState$2(defaultValue));
|
|
773
772
|
useEventListener('visibilitychange', ()=>{
|
|
774
773
|
setVisible(document.visibilityState);
|
|
775
774
|
}, ()=>document);
|
|
@@ -2035,7 +2034,7 @@ const useMediaDevices = (options = {})=>{
|
|
|
2035
2034
|
];
|
|
2036
2035
|
};
|
|
2037
2036
|
|
|
2038
|
-
function getInitialState(query, defaultState) {
|
|
2037
|
+
function getInitialState$1(query, defaultState) {
|
|
2039
2038
|
// Prevent a React hydration mismatch when a default value is provided by not defaulting to window.matchMedia(query).matches.
|
|
2040
2039
|
if (defaultState !== undefined) {
|
|
2041
2040
|
return defaultState;
|
|
@@ -2050,7 +2049,7 @@ function getInitialState(query, defaultState) {
|
|
|
2050
2049
|
return false;
|
|
2051
2050
|
}
|
|
2052
2051
|
const useMediaQuery = (query, defaultState)=>{
|
|
2053
|
-
const [state, setState] = React.useState(getInitialState(query, defaultState));
|
|
2052
|
+
const [state, setState] = React.useState(getInitialState$1(query, defaultState));
|
|
2054
2053
|
React.useEffect(()=>{
|
|
2055
2054
|
let mounted = true;
|
|
2056
2055
|
const mql = window.matchMedia(query);
|
|
@@ -3502,6 +3501,30 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
|
|
|
3502
3501
|
};
|
|
3503
3502
|
};
|
|
3504
3503
|
|
|
3504
|
+
function assignRef(ref, value) {
|
|
3505
|
+
if (ref == null) return;
|
|
3506
|
+
if (typeof ref === 'function') {
|
|
3507
|
+
ref(value);
|
|
3508
|
+
return;
|
|
3509
|
+
}
|
|
3510
|
+
try {
|
|
3511
|
+
ref.current = value;
|
|
3512
|
+
} catch (error) {
|
|
3513
|
+
throw new Error(`Cannot assign value '${value}' to ref '${ref}'`);
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
function mergeRefs(...refs) {
|
|
3517
|
+
return (node)=>{
|
|
3518
|
+
refs.forEach((ref)=>{
|
|
3519
|
+
assignRef(ref, node);
|
|
3520
|
+
});
|
|
3521
|
+
};
|
|
3522
|
+
}
|
|
3523
|
+
function useMergedRefs(...refs) {
|
|
3524
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3525
|
+
return React.useMemo(()=>mergeRefs(...refs), refs);
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3505
3528
|
/**
|
|
3506
3529
|
* @description copy from swr
|
|
3507
3530
|
*/ const use = React__default.default.use || ((thenable)=>{
|
|
@@ -3525,13 +3548,223 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
|
|
|
3525
3548
|
}
|
|
3526
3549
|
});
|
|
3527
3550
|
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3551
|
+
function getInitialState(defaultState) {
|
|
3552
|
+
// Prevent a React hydration mismatch when a default value is provided by not defaulting to window.matchMedia(query).matches.
|
|
3553
|
+
if (defaultState !== undefined) {
|
|
3554
|
+
return defaultState;
|
|
3555
|
+
}
|
|
3556
|
+
if (isBrowser) {
|
|
3557
|
+
const navigator1 = window.navigator;
|
|
3558
|
+
return navigator1.languages;
|
|
3559
|
+
}
|
|
3560
|
+
// A default value has not been provided, and you are rendering on the server, warn of a possible hydration mismatch when defaulting to false.
|
|
3561
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3562
|
+
console.warn('`usePreferredLanguage` When server side rendering, defaultState should be defined to prevent a hydration mismatches.');
|
|
3563
|
+
}
|
|
3564
|
+
return [
|
|
3565
|
+
'en'
|
|
3566
|
+
];
|
|
3567
|
+
}
|
|
3568
|
+
const usePreferredLanguages = (defaultLanguages)=>{
|
|
3569
|
+
const [state, setState] = React.useState(getInitialState(defaultLanguages));
|
|
3570
|
+
useEventListener('languagechange', ()=>{
|
|
3571
|
+
setState(navigator.languages);
|
|
3572
|
+
});
|
|
3573
|
+
return state;
|
|
3574
|
+
};
|
|
3575
|
+
|
|
3576
|
+
const useBroadcastChannel = (options)=>{
|
|
3577
|
+
const { name } = options;
|
|
3578
|
+
const isSupported = useSupported(()=>window && 'BroadcastChannel' in window);
|
|
3579
|
+
const [isClosed, setIsClosed] = React.useState(false);
|
|
3580
|
+
const [data, setData] = React.useState();
|
|
3581
|
+
const [error, setError] = React.useState(null);
|
|
3582
|
+
const [timeStamp, setTimeStamp] = React.useState(0);
|
|
3583
|
+
const channelRef = React.useRef();
|
|
3584
|
+
const post = React.useCallback((data)=>{
|
|
3585
|
+
if (channelRef.current) {
|
|
3586
|
+
channelRef.current.postMessage(data);
|
|
3587
|
+
}
|
|
3588
|
+
}, []);
|
|
3589
|
+
const close = React.useCallback(()=>{
|
|
3590
|
+
if (channelRef.current) {
|
|
3591
|
+
channelRef.current.close();
|
|
3592
|
+
}
|
|
3593
|
+
setIsClosed(true);
|
|
3594
|
+
}, []);
|
|
3595
|
+
React.useEffect(()=>{
|
|
3596
|
+
if (isSupported) {
|
|
3597
|
+
channelRef.current = new BroadcastChannel(name);
|
|
3598
|
+
setError(null);
|
|
3599
|
+
const handleMessage = (e)=>{
|
|
3600
|
+
setData(e.data);
|
|
3601
|
+
// avoid data is same between two messages
|
|
3602
|
+
setTimeStamp(Date.now());
|
|
3603
|
+
};
|
|
3604
|
+
const handleError = (e)=>{
|
|
3605
|
+
setError(e);
|
|
3606
|
+
};
|
|
3607
|
+
const handleClose = ()=>{
|
|
3608
|
+
setIsClosed(true);
|
|
3609
|
+
};
|
|
3610
|
+
channelRef.current.addEventListener('message', handleMessage, {
|
|
3611
|
+
passive: true
|
|
3612
|
+
});
|
|
3613
|
+
channelRef.current.addEventListener('messageerror', handleError, {
|
|
3614
|
+
passive: true
|
|
3615
|
+
});
|
|
3616
|
+
channelRef.current.addEventListener('close', handleClose);
|
|
3617
|
+
return ()=>{
|
|
3618
|
+
if (channelRef.current) {
|
|
3619
|
+
channelRef.current.removeEventListener('message', handleMessage);
|
|
3620
|
+
channelRef.current.removeEventListener('messageerror', handleError);
|
|
3621
|
+
channelRef.current.removeEventListener('close', handleClose);
|
|
3622
|
+
close();
|
|
3623
|
+
}
|
|
3624
|
+
};
|
|
3625
|
+
}
|
|
3626
|
+
return close;
|
|
3627
|
+
}, [
|
|
3628
|
+
isSupported,
|
|
3629
|
+
name,
|
|
3630
|
+
close
|
|
3631
|
+
]);
|
|
3632
|
+
return {
|
|
3633
|
+
isSupported,
|
|
3634
|
+
channel: channelRef.current,
|
|
3635
|
+
data,
|
|
3636
|
+
post,
|
|
3637
|
+
close,
|
|
3638
|
+
error,
|
|
3639
|
+
isClosed,
|
|
3640
|
+
timeStamp
|
|
3641
|
+
};
|
|
3642
|
+
};
|
|
3643
|
+
|
|
3644
|
+
const useDevicePixelRatio = ()=>{
|
|
3645
|
+
const [pixelRatio, setPixelRatio] = React.useState(1);
|
|
3646
|
+
const observe = React.useCallback(()=>{
|
|
3647
|
+
if (!window) return;
|
|
3648
|
+
setPixelRatio(window.devicePixelRatio);
|
|
3649
|
+
const media = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
3650
|
+
const handleChange = ()=>{
|
|
3651
|
+
observe();
|
|
3652
|
+
};
|
|
3653
|
+
media.addEventListener('change', handleChange, {
|
|
3654
|
+
once: true
|
|
3655
|
+
});
|
|
3656
|
+
return ()=>{
|
|
3657
|
+
media.removeEventListener('change', handleChange);
|
|
3658
|
+
};
|
|
3659
|
+
}, []);
|
|
3660
|
+
React.useEffect(()=>{
|
|
3661
|
+
const cleanup = observe();
|
|
3662
|
+
return cleanup;
|
|
3663
|
+
}, [
|
|
3664
|
+
observe
|
|
3665
|
+
]);
|
|
3666
|
+
return {
|
|
3667
|
+
pixelRatio
|
|
3668
|
+
};
|
|
3669
|
+
};
|
|
3670
|
+
|
|
3671
|
+
const useElementByPoint = (options)=>{
|
|
3672
|
+
const { x, y, document: doc = typeof document !== 'undefined' ? document : null, multiple = false, interval = 'requestAnimationFrame', immediate = true } = options;
|
|
3673
|
+
const isSupported = useSupported(()=>{
|
|
3674
|
+
if (multiple) return doc && 'elementsFromPoint' in doc;
|
|
3675
|
+
return doc && 'elementFromPoint' in doc;
|
|
3676
|
+
});
|
|
3677
|
+
const [element, setElement] = React.useState(null);
|
|
3678
|
+
const [isActive, setIsActive] = React.useState(immediate);
|
|
3679
|
+
const rafIdRef = React.useRef(null);
|
|
3680
|
+
const intervalIdRef = React.useRef(null);
|
|
3681
|
+
const getXY = React.useCallback(()=>{
|
|
3682
|
+
// 需要判断 NaN
|
|
3683
|
+
const currentX = typeof x === 'function' ? x() : x;
|
|
3684
|
+
const currentY = typeof y === 'function' ? y() : y;
|
|
3685
|
+
return {
|
|
3686
|
+
x: Number.isNaN(currentX) ? 0 : currentX,
|
|
3687
|
+
y: Number.isNaN(currentY) ? 0 : currentY
|
|
3688
|
+
};
|
|
3689
|
+
}, [
|
|
3690
|
+
x,
|
|
3691
|
+
y
|
|
3692
|
+
]);
|
|
3693
|
+
const cb = React.useCallback(()=>{
|
|
3694
|
+
const { x: currentX, y: currentY } = getXY();
|
|
3695
|
+
var _doc_elementsFromPoint, _doc_elementFromPoint;
|
|
3696
|
+
setElement(multiple ? (_doc_elementsFromPoint = doc == null ? void 0 : doc.elementsFromPoint(currentX, currentY)) != null ? _doc_elementsFromPoint : [] : (_doc_elementFromPoint = doc == null ? void 0 : doc.elementFromPoint(currentX, currentY)) != null ? _doc_elementFromPoint : null);
|
|
3697
|
+
}, [
|
|
3698
|
+
doc,
|
|
3699
|
+
multiple,
|
|
3700
|
+
getXY
|
|
3701
|
+
]);
|
|
3702
|
+
const cleanup = React.useCallback(()=>{
|
|
3703
|
+
if (rafIdRef.current !== null) {
|
|
3704
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
3705
|
+
rafIdRef.current = null;
|
|
3706
|
+
}
|
|
3707
|
+
if (intervalIdRef.current !== null) {
|
|
3708
|
+
clearInterval(intervalIdRef.current);
|
|
3709
|
+
intervalIdRef.current = null;
|
|
3710
|
+
}
|
|
3711
|
+
}, []);
|
|
3712
|
+
const pause = React.useCallback(()=>{
|
|
3713
|
+
setIsActive(false);
|
|
3714
|
+
cleanup();
|
|
3715
|
+
}, [
|
|
3716
|
+
cleanup
|
|
3717
|
+
]);
|
|
3718
|
+
const resume = React.useCallback(()=>{
|
|
3719
|
+
setIsActive(true);
|
|
3720
|
+
}, []);
|
|
3721
|
+
React.useEffect(()=>{
|
|
3722
|
+
if (!isActive) {
|
|
3723
|
+
return;
|
|
3724
|
+
}
|
|
3725
|
+
if (interval === 'requestAnimationFrame') {
|
|
3726
|
+
const runRaf = ()=>{
|
|
3727
|
+
cb();
|
|
3728
|
+
rafIdRef.current = requestAnimationFrame(runRaf);
|
|
3729
|
+
};
|
|
3730
|
+
runRaf();
|
|
3731
|
+
} else {
|
|
3732
|
+
cb();
|
|
3733
|
+
intervalIdRef.current = setInterval(cb, interval);
|
|
3734
|
+
}
|
|
3735
|
+
return cleanup;
|
|
3736
|
+
}, [
|
|
3737
|
+
isActive,
|
|
3738
|
+
interval,
|
|
3739
|
+
cb,
|
|
3740
|
+
cleanup
|
|
3741
|
+
]);
|
|
3742
|
+
React.useEffect(()=>{
|
|
3743
|
+
if (immediate) {
|
|
3744
|
+
resume();
|
|
3745
|
+
}
|
|
3746
|
+
return pause;
|
|
3747
|
+
}, [
|
|
3748
|
+
immediate,
|
|
3749
|
+
resume,
|
|
3750
|
+
pause
|
|
3751
|
+
]);
|
|
3752
|
+
return {
|
|
3753
|
+
isSupported,
|
|
3754
|
+
element,
|
|
3755
|
+
pause,
|
|
3756
|
+
resume,
|
|
3757
|
+
isActive
|
|
3758
|
+
};
|
|
3759
|
+
};
|
|
3760
|
+
|
|
3761
|
+
exports.assignRef = assignRef;
|
|
3531
3762
|
exports.defaultOptions = defaultOptions;
|
|
3763
|
+
exports.mergeRefs = mergeRefs;
|
|
3532
3764
|
exports.use = use;
|
|
3533
3765
|
exports.useActiveElement = useActiveElement;
|
|
3534
3766
|
exports.useAsyncEffect = useAsyncEffect;
|
|
3767
|
+
exports.useBroadcastChannel = useBroadcastChannel;
|
|
3535
3768
|
exports.useClickOutside = useClickOutside;
|
|
3536
3769
|
exports.useClipboard = useClipboard;
|
|
3537
3770
|
exports.useControlled = useControlled;
|
|
@@ -3545,12 +3778,14 @@ exports.useDarkMode = useDarkMode;
|
|
|
3545
3778
|
exports.useDebounce = useDebounce;
|
|
3546
3779
|
exports.useDebounceFn = useDebounceFn;
|
|
3547
3780
|
exports.useDeepCompareEffect = useDeepCompareEffect;
|
|
3781
|
+
exports.useDevicePixelRatio = useDevicePixelRatio;
|
|
3548
3782
|
exports.useDisclosure = useDisclosure;
|
|
3549
3783
|
exports.useDocumentVisibility = useDocumentVisibility;
|
|
3550
3784
|
exports.useDoubleClick = useDoubleClick;
|
|
3551
3785
|
exports.useDraggable = useDraggable;
|
|
3552
3786
|
exports.useDropZone = useDropZone;
|
|
3553
3787
|
exports.useElementBounding = useElementBounding;
|
|
3788
|
+
exports.useElementByPoint = useElementByPoint;
|
|
3554
3789
|
exports.useElementSize = useElementSize;
|
|
3555
3790
|
exports.useElementVisibility = useElementVisibility;
|
|
3556
3791
|
exports.useEvent = useEvent;
|
|
@@ -3579,6 +3814,7 @@ exports.useLongPress = useLongPress;
|
|
|
3579
3814
|
exports.useMeasure = useMeasure;
|
|
3580
3815
|
exports.useMediaDevices = useMediaDevices;
|
|
3581
3816
|
exports.useMediaQuery = useMediaQuery;
|
|
3817
|
+
exports.useMergedRefs = useMergedRefs;
|
|
3582
3818
|
exports.useMobileLandscape = useMobileLandscape;
|
|
3583
3819
|
exports.useMount = useMount;
|
|
3584
3820
|
exports.useMountedState = useMountedState;
|
|
@@ -3597,6 +3833,7 @@ exports.usePlatform = usePlatform;
|
|
|
3597
3833
|
exports.usePreferredColorScheme = usePreferredColorScheme;
|
|
3598
3834
|
exports.usePreferredContrast = usePreferredContrast;
|
|
3599
3835
|
exports.usePreferredDark = usePreferredDark;
|
|
3836
|
+
exports.usePreferredLanguages = usePreferredLanguages;
|
|
3600
3837
|
exports.usePrevious = usePrevious;
|
|
3601
3838
|
exports.useRafFn = useRafFn;
|
|
3602
3839
|
exports.useRafState = useRafState;
|
package/dist/index.d.cts
CHANGED
|
@@ -446,6 +446,26 @@ interface Position {
|
|
|
446
446
|
x: number;
|
|
447
447
|
y: number;
|
|
448
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* @title Pausable
|
|
451
|
+
*/
|
|
452
|
+
interface Pausable$1 {
|
|
453
|
+
/**
|
|
454
|
+
* @en A ref indicate whether a pausable instance is active
|
|
455
|
+
* @zh 一个 ref,表示一个 pausable 实例是否处于激活状态
|
|
456
|
+
*/
|
|
457
|
+
isActive: boolean;
|
|
458
|
+
/**
|
|
459
|
+
* @en Temporary pause the effect from executing
|
|
460
|
+
* @zh 暂时暂停效果的执行
|
|
461
|
+
*/
|
|
462
|
+
pause: Fn;
|
|
463
|
+
/**
|
|
464
|
+
* @en Resume the effects
|
|
465
|
+
* @zh 恢复效果
|
|
466
|
+
*/
|
|
467
|
+
resume: Fn;
|
|
468
|
+
}
|
|
449
469
|
|
|
450
470
|
/**
|
|
451
471
|
* @title useDraggable
|
|
@@ -2838,6 +2858,165 @@ declare function useMergedRefs<T>(...refs: PossibleRef<T>[]): (node: T | null) =
|
|
|
2838
2858
|
*/
|
|
2839
2859
|
declare const use: any;
|
|
2840
2860
|
|
|
2861
|
+
/**
|
|
2862
|
+
* @title UsePreferredLanguages
|
|
2863
|
+
* @returns 语言偏好
|
|
2864
|
+
* @returns_en preferred languages
|
|
2865
|
+
*/
|
|
2866
|
+
type UsePreferredLanguages = (
|
|
2867
|
+
/**
|
|
2868
|
+
* @zh 默认值
|
|
2869
|
+
* @en defaule value
|
|
2870
|
+
*/ defaultLanguages?: string[]) => string[];
|
|
2871
|
+
|
|
2872
|
+
declare const usePreferredLanguages: UsePreferredLanguages;
|
|
2873
|
+
|
|
2874
|
+
/**
|
|
2875
|
+
* @title UseBroadcastChannelOptions
|
|
2876
|
+
*/
|
|
2877
|
+
interface UseBroadcastChannelOptions {
|
|
2878
|
+
/**
|
|
2879
|
+
* @zh 频道名称
|
|
2880
|
+
* @en channel name
|
|
2881
|
+
*/
|
|
2882
|
+
name: string;
|
|
2883
|
+
}
|
|
2884
|
+
/**
|
|
2885
|
+
* @title UseBroadcastChannel
|
|
2886
|
+
*/
|
|
2887
|
+
type UseBroadcastChannel = <D, P>(
|
|
2888
|
+
/**
|
|
2889
|
+
* @zh 选项
|
|
2890
|
+
* @en options
|
|
2891
|
+
*/
|
|
2892
|
+
options: UseBroadcastChannelOptions) => UseBroadcastChannelReturn<D, P>;
|
|
2893
|
+
/**
|
|
2894
|
+
* @title UseBroadcastChannelReturn
|
|
2895
|
+
*/
|
|
2896
|
+
interface UseBroadcastChannelReturn<D, P> {
|
|
2897
|
+
/**
|
|
2898
|
+
* @zh 是否支持
|
|
2899
|
+
* @en is supported
|
|
2900
|
+
*/
|
|
2901
|
+
readonly isSupported: boolean;
|
|
2902
|
+
/**
|
|
2903
|
+
* @zh 频道
|
|
2904
|
+
* @en channel
|
|
2905
|
+
*/
|
|
2906
|
+
readonly channel: BroadcastChannel | undefined;
|
|
2907
|
+
/**
|
|
2908
|
+
* @zh 数据
|
|
2909
|
+
* @en data
|
|
2910
|
+
*/
|
|
2911
|
+
readonly data: D | undefined;
|
|
2912
|
+
/**
|
|
2913
|
+
* @zh 发送数据
|
|
2914
|
+
* @en post data
|
|
2915
|
+
*/
|
|
2916
|
+
readonly post: (data: P) => void;
|
|
2917
|
+
/**
|
|
2918
|
+
* @zh 关闭
|
|
2919
|
+
* @en close
|
|
2920
|
+
*/
|
|
2921
|
+
readonly close: () => void;
|
|
2922
|
+
/**
|
|
2923
|
+
* @zh 错误
|
|
2924
|
+
* @en error
|
|
2925
|
+
*/
|
|
2926
|
+
readonly error: Event | null;
|
|
2927
|
+
/**
|
|
2928
|
+
* @zh 是否关闭
|
|
2929
|
+
* @en is closed
|
|
2930
|
+
*/
|
|
2931
|
+
readonly isClosed: boolean;
|
|
2932
|
+
/**
|
|
2933
|
+
* @zh 时间戳
|
|
2934
|
+
* @en timestamp
|
|
2935
|
+
*/
|
|
2936
|
+
readonly timeStamp: number;
|
|
2937
|
+
}
|
|
2938
|
+
|
|
2939
|
+
declare const useBroadcastChannel: UseBroadcastChannel;
|
|
2940
|
+
|
|
2941
|
+
/**
|
|
2942
|
+
* @title UseDevicePixelRatio
|
|
2943
|
+
*/
|
|
2944
|
+
type UseDevicePixelRatio = () => UseDevicePixelRatioReturn;
|
|
2945
|
+
/**
|
|
2946
|
+
* @title UseDevicePixelRatioReturn
|
|
2947
|
+
*/
|
|
2948
|
+
interface UseDevicePixelRatioReturn {
|
|
2949
|
+
/**
|
|
2950
|
+
* @zh 像素比率
|
|
2951
|
+
* @en Pixel ratio
|
|
2952
|
+
*/
|
|
2953
|
+
pixelRatio: number;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
declare const useDevicePixelRatio: UseDevicePixelRatio;
|
|
2957
|
+
|
|
2958
|
+
/**
|
|
2959
|
+
* @title UseElementByPoint
|
|
2960
|
+
*/
|
|
2961
|
+
type UseElementByPoint = <M extends boolean = false>(
|
|
2962
|
+
/**
|
|
2963
|
+
* @en options
|
|
2964
|
+
* @zh 配置项
|
|
2965
|
+
*/
|
|
2966
|
+
options: UseElementByPointOptions<M>) => UseElementByPointReturn<M>;
|
|
2967
|
+
/**
|
|
2968
|
+
* @title UseElementByPointOptions
|
|
2969
|
+
*/
|
|
2970
|
+
interface UseElementByPointOptions<M extends boolean = false> {
|
|
2971
|
+
/**
|
|
2972
|
+
* @en The x coordinate of the point
|
|
2973
|
+
* @zh 点的 x 坐标
|
|
2974
|
+
*/
|
|
2975
|
+
x: number | (() => number);
|
|
2976
|
+
/**
|
|
2977
|
+
* @en The y coordinate of the point
|
|
2978
|
+
* @zh 点的 y 坐标
|
|
2979
|
+
*/
|
|
2980
|
+
y: number | (() => number);
|
|
2981
|
+
/**
|
|
2982
|
+
* @en The document to query
|
|
2983
|
+
* @zh 要查询的文档
|
|
2984
|
+
*/
|
|
2985
|
+
document?: Document | null;
|
|
2986
|
+
/**
|
|
2987
|
+
* @en Whether to query multiple elements
|
|
2988
|
+
* @zh 是否查询多个元素
|
|
2989
|
+
*/
|
|
2990
|
+
multiple?: M;
|
|
2991
|
+
/**
|
|
2992
|
+
* @en The interval to query the element
|
|
2993
|
+
* @zh 查询元素的间隔
|
|
2994
|
+
*/
|
|
2995
|
+
interval?: number | 'requestAnimationFrame';
|
|
2996
|
+
/**
|
|
2997
|
+
* @en Whether to query the element immediately
|
|
2998
|
+
* @zh 是否立即查询元素
|
|
2999
|
+
*/
|
|
3000
|
+
immediate?: boolean;
|
|
3001
|
+
}
|
|
3002
|
+
/**
|
|
3003
|
+
* @title UseElementByPointReturn
|
|
3004
|
+
*/
|
|
3005
|
+
interface UseElementByPointReturn<M extends boolean> extends Pausable$1 {
|
|
3006
|
+
/**
|
|
3007
|
+
* @en Whether the feature is supported
|
|
3008
|
+
* @zh 功能是否支持
|
|
3009
|
+
*/
|
|
3010
|
+
isSupported: boolean;
|
|
3011
|
+
/**
|
|
3012
|
+
* @en The queried element
|
|
3013
|
+
* @zh 查询到的元素
|
|
3014
|
+
*/
|
|
3015
|
+
element: M extends true ? Element[] : Element | null;
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
declare const useElementByPoint: UseElementByPoint;
|
|
3019
|
+
|
|
2841
3020
|
/**
|
|
2842
3021
|
* @title useDocumentVisiblity
|
|
2843
3022
|
* @returns_en document visibility
|
|
@@ -3221,4 +3400,4 @@ type Use = <T>(
|
|
|
3221
3400
|
*/
|
|
3222
3401
|
usable: Usable<T>) => T;
|
|
3223
3402
|
|
|
3224
|
-
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventSourceStatus, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Pausable, type Platform, type PossibleRef, type Use, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseControlled, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDisclosure, type UseDisclosureProps, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEventSource, type UseEventSourceAutoReconnectOptions, type UseEventSourceOptions, type UseEventSourceReturn, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMergedRef, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useControlled, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDisclosure, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEventSource, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMergedRefs, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
|
3403
|
+
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventSourceStatus, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type Pausable, type Platform, type PossibleRef, type Use, type UseActiveElement, type UseAsyncEffect, type UseBroadcastChannel, type UseBroadcastChannelOptions, type UseBroadcastChannelReturn, type UseClickOutside, type UseClipboard, type UseControlled, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDevicePixelRatio, type UseDevicePixelRatioReturn, type UseDisclosure, type UseDisclosureProps, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementByPoint, type UseElementByPointOptions, type UseElementByPointReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEventSource, type UseEventSourceAutoReconnectOptions, type UseEventSourceOptions, type UseEventSourceReturn, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseMergedRef, type UseMobileLandscape, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePlatform, type UsePlatformProps, type UsePlatformReturn, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePreferredLanguages, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useBroadcastChannel, useClickOutside, useClipboard, useControlled, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDevicePixelRatio, useDisclosure, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEventSource, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMergedRefs, useMobileLandscape, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePlatform, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|