@reactuses/core 6.1.1 → 6.1.3
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 +8 -9
- package/dist/index.cjs +135 -9
- package/dist/index.d.cts +605 -9
- package/dist/index.d.mts +605 -9
- package/dist/index.d.ts +605 -9
- package/dist/index.mjs +135 -10
- package/dist/useQRCode.d.cts +4 -0
- package/dist/useQRCode.d.mts +4 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1393,8 +1393,8 @@ function _async_to_generator$5(fn) {
|
|
|
1393
1393
|
});
|
|
1394
1394
|
};
|
|
1395
1395
|
}
|
|
1396
|
-
function _extends$
|
|
1397
|
-
_extends$
|
|
1396
|
+
function _extends$4() {
|
|
1397
|
+
_extends$4 = Object.assign || function(target) {
|
|
1398
1398
|
for(var i = 1; i < arguments.length; i++){
|
|
1399
1399
|
var source = arguments[i];
|
|
1400
1400
|
for(var key in source){
|
|
@@ -1405,7 +1405,7 @@ function _extends$3() {
|
|
|
1405
1405
|
}
|
|
1406
1406
|
return target;
|
|
1407
1407
|
};
|
|
1408
|
-
return _extends$
|
|
1408
|
+
return _extends$4.apply(this, arguments);
|
|
1409
1409
|
}
|
|
1410
1410
|
const DEFAULT_OPTIONS = {
|
|
1411
1411
|
multiple: true,
|
|
@@ -1434,7 +1434,7 @@ const useFileDialog = (options = defaultOptions$1)=>{
|
|
|
1434
1434
|
if (!inputRef.current) {
|
|
1435
1435
|
return;
|
|
1436
1436
|
}
|
|
1437
|
-
const _options = _extends$
|
|
1437
|
+
const _options = _extends$4({}, DEFAULT_OPTIONS, options, localOptions);
|
|
1438
1438
|
inputRef.current.multiple = _options.multiple;
|
|
1439
1439
|
inputRef.current.accept = _options.accept;
|
|
1440
1440
|
// Only set capture attribute if it's explicitly provided
|
|
@@ -1872,8 +1872,8 @@ function _async_to_generator$4(fn) {
|
|
|
1872
1872
|
});
|
|
1873
1873
|
};
|
|
1874
1874
|
}
|
|
1875
|
-
function _extends$
|
|
1876
|
-
_extends$
|
|
1875
|
+
function _extends$3() {
|
|
1876
|
+
_extends$3 = Object.assign || function(target) {
|
|
1877
1877
|
for(var i = 1; i < arguments.length; i++){
|
|
1878
1878
|
var source = arguments[i];
|
|
1879
1879
|
for(var key in source){
|
|
@@ -1884,15 +1884,15 @@ function _extends$2() {
|
|
|
1884
1884
|
}
|
|
1885
1885
|
return target;
|
|
1886
1886
|
};
|
|
1887
|
-
return _extends$
|
|
1887
|
+
return _extends$3.apply(this, arguments);
|
|
1888
1888
|
}
|
|
1889
1889
|
const useInfiniteScroll = (target, onLoadMore, options = defaultOptions$1)=>{
|
|
1890
1890
|
const savedLoadMore = useLatest(onLoadMore);
|
|
1891
1891
|
var _options_direction;
|
|
1892
1892
|
const direction = (_options_direction = options.direction) != null ? _options_direction : 'bottom';
|
|
1893
1893
|
var _options_distance;
|
|
1894
|
-
const state = useScroll(target, _extends$
|
|
1895
|
-
offset: _extends$
|
|
1894
|
+
const state = useScroll(target, _extends$3({}, options, {
|
|
1895
|
+
offset: _extends$3({
|
|
1896
1896
|
[direction]: (_options_distance = options.distance) != null ? _options_distance : 0
|
|
1897
1897
|
}, options.offset)
|
|
1898
1898
|
}));
|
|
@@ -2619,6 +2619,131 @@ function getValue(position) {
|
|
|
2619
2619
|
return getComputedStyle(document.documentElement).getPropertyValue(position);
|
|
2620
2620
|
}
|
|
2621
2621
|
|
|
2622
|
+
function _extends$2() {
|
|
2623
|
+
_extends$2 = Object.assign || function(target) {
|
|
2624
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2625
|
+
var source = arguments[i];
|
|
2626
|
+
for(var key in source){
|
|
2627
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2628
|
+
target[key] = source[key];
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
return target;
|
|
2633
|
+
};
|
|
2634
|
+
return _extends$2.apply(this, arguments);
|
|
2635
|
+
}
|
|
2636
|
+
const initialState = {
|
|
2637
|
+
isScratching: false
|
|
2638
|
+
};
|
|
2639
|
+
const useScratch = (target, options = {})=>{
|
|
2640
|
+
const { disabled = false } = options;
|
|
2641
|
+
const [state, setState] = useRafState(initialState);
|
|
2642
|
+
const optionsRef = useLatest(options);
|
|
2643
|
+
const refState = useRef(state);
|
|
2644
|
+
const refScratching = useRef(false);
|
|
2645
|
+
const refAnimationFrame = useRef(null);
|
|
2646
|
+
const onMoveEvent = (docX, docY)=>{
|
|
2647
|
+
if (!refScratching.current) {
|
|
2648
|
+
return;
|
|
2649
|
+
}
|
|
2650
|
+
const el = getTargetElement(target);
|
|
2651
|
+
if (!el) {
|
|
2652
|
+
return;
|
|
2653
|
+
}
|
|
2654
|
+
if (refAnimationFrame.current !== null) {
|
|
2655
|
+
cancelAnimationFrame(refAnimationFrame.current);
|
|
2656
|
+
}
|
|
2657
|
+
refAnimationFrame.current = requestAnimationFrame(()=>{
|
|
2658
|
+
const { left, top } = el.getBoundingClientRect();
|
|
2659
|
+
const elX = left + window.scrollX;
|
|
2660
|
+
const elY = top + window.scrollY;
|
|
2661
|
+
const x = docX - elX;
|
|
2662
|
+
const y = docY - elY;
|
|
2663
|
+
setState((oldState)=>{
|
|
2664
|
+
const newState = _extends$2({}, oldState, {
|
|
2665
|
+
x,
|
|
2666
|
+
y,
|
|
2667
|
+
dx: x - (oldState.x || 0),
|
|
2668
|
+
dy: y - (oldState.y || 0),
|
|
2669
|
+
end: Date.now(),
|
|
2670
|
+
isScratching: true
|
|
2671
|
+
});
|
|
2672
|
+
refState.current = newState;
|
|
2673
|
+
(optionsRef.current.onScratch || noop)(newState);
|
|
2674
|
+
return newState;
|
|
2675
|
+
});
|
|
2676
|
+
});
|
|
2677
|
+
};
|
|
2678
|
+
const stopScratching = ()=>{
|
|
2679
|
+
if (!refScratching.current) {
|
|
2680
|
+
return;
|
|
2681
|
+
}
|
|
2682
|
+
refScratching.current = false;
|
|
2683
|
+
const endState = _extends$2({}, refState.current, {
|
|
2684
|
+
isScratching: false
|
|
2685
|
+
});
|
|
2686
|
+
refState.current = endState;
|
|
2687
|
+
(optionsRef.current.onScratchEnd || noop)(endState);
|
|
2688
|
+
setState(endState);
|
|
2689
|
+
};
|
|
2690
|
+
const startScratching = (docX, docY)=>{
|
|
2691
|
+
const el = getTargetElement(target);
|
|
2692
|
+
if (disabled || !el) {
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
refScratching.current = true;
|
|
2696
|
+
const { left, top } = el.getBoundingClientRect();
|
|
2697
|
+
const elX = left + window.scrollX;
|
|
2698
|
+
const elY = top + window.scrollY;
|
|
2699
|
+
const x = docX - elX;
|
|
2700
|
+
const y = docY - elY;
|
|
2701
|
+
const time = Date.now();
|
|
2702
|
+
const newState = {
|
|
2703
|
+
isScratching: true,
|
|
2704
|
+
start: time,
|
|
2705
|
+
end: time,
|
|
2706
|
+
docX,
|
|
2707
|
+
docY,
|
|
2708
|
+
x,
|
|
2709
|
+
y,
|
|
2710
|
+
dx: 0,
|
|
2711
|
+
dy: 0,
|
|
2712
|
+
elH: el.offsetHeight,
|
|
2713
|
+
elW: el.offsetWidth,
|
|
2714
|
+
elX,
|
|
2715
|
+
elY,
|
|
2716
|
+
posX: elX,
|
|
2717
|
+
posY: elY
|
|
2718
|
+
};
|
|
2719
|
+
refState.current = newState;
|
|
2720
|
+
(optionsRef.current.onScratchStart || noop)(newState);
|
|
2721
|
+
setState(newState);
|
|
2722
|
+
};
|
|
2723
|
+
useEventListener('mousedown', (event)=>{
|
|
2724
|
+
event.preventDefault();
|
|
2725
|
+
startScratching(event.pageX || event.clientX, event.pageY || event.clientY);
|
|
2726
|
+
}, target);
|
|
2727
|
+
useEventListener('touchstart', (event)=>{
|
|
2728
|
+
event.preventDefault();
|
|
2729
|
+
startScratching(event.changedTouches[0].pageX || event.changedTouches[0].clientX, event.changedTouches[0].pageY || event.changedTouches[0].clientY);
|
|
2730
|
+
}, target);
|
|
2731
|
+
useEventListener('mousemove', (event)=>{
|
|
2732
|
+
onMoveEvent(event.pageX || event.clientX, event.pageY || event.clientY);
|
|
2733
|
+
}, defaultWindow);
|
|
2734
|
+
useEventListener('touchmove', (event)=>{
|
|
2735
|
+
onMoveEvent(event.changedTouches[0].pageX || event.changedTouches[0].clientX, event.changedTouches[0].pageY || event.changedTouches[0].clientY);
|
|
2736
|
+
}, defaultWindow);
|
|
2737
|
+
useEventListener('mouseup', stopScratching, defaultWindow);
|
|
2738
|
+
useEventListener('touchend', stopScratching, defaultWindow);
|
|
2739
|
+
useUnmount(()=>{
|
|
2740
|
+
if (refAnimationFrame.current !== null) {
|
|
2741
|
+
cancelAnimationFrame(refAnimationFrame.current);
|
|
2742
|
+
}
|
|
2743
|
+
});
|
|
2744
|
+
return state;
|
|
2745
|
+
};
|
|
2746
|
+
|
|
2622
2747
|
const useScriptTag = (src, onLoaded = noop, options = defaultOptions$1)=>{
|
|
2623
2748
|
const { immediate = true, manual = false, type = 'text/javascript', async = true, crossOrigin, referrerPolicy, noModule, defer, attrs = {} } = options;
|
|
2624
2749
|
const scriptTag = useRef(null);
|
|
@@ -4302,4 +4427,4 @@ const useSpeechRecognition = (options = {})=>{
|
|
|
4302
4427
|
};
|
|
4303
4428
|
};
|
|
4304
4429
|
|
|
4305
|
-
export { assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useBoolean, useBroadcastChannel, useClickOutside as useClickAway, useClickOutside, useClipboard, useColorMode, useControlled, useCookie, useClipboard as useCopyToClipboard, 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, useFetchEventSource, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMap, 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, useSpeechRecognition, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
|
4430
|
+
export { assignRef, defaultOptions, mergeRefs, use, useActiveElement, useAsyncEffect, useBoolean, useBroadcastChannel, useClickOutside as useClickAway, useClickOutside, useClipboard, useColorMode, useControlled, useCookie, useClipboard as useCopyToClipboard, 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, useFetchEventSource, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMap, 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, useScratch, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSpeechRecognition, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|
package/dist/useQRCode.d.cts
CHANGED
|
@@ -6,11 +6,13 @@ import QRCode, { QRCodeToDataURLOptions } from 'qrcode';
|
|
|
6
6
|
type UseQRCode = (
|
|
7
7
|
/**
|
|
8
8
|
* @zh 文本
|
|
9
|
+
* @zh-Hant 文本
|
|
9
10
|
* @en Text
|
|
10
11
|
*/
|
|
11
12
|
text: string,
|
|
12
13
|
/**
|
|
13
14
|
* @zh 传递给 `QRCode.toDataURL` 的选项
|
|
15
|
+
* @zh-Hant 傳遞給 `QRCode.toDataURL` 的選項
|
|
14
16
|
* @en Options passed to `QRCode.toDataURL`
|
|
15
17
|
*/
|
|
16
18
|
options?: QRCodeToDataURLOptions) => UseQRCodeReturn;
|
|
@@ -20,11 +22,13 @@ options?: QRCodeToDataURLOptions) => UseQRCodeReturn;
|
|
|
20
22
|
interface UseQRCodeReturn {
|
|
21
23
|
/**
|
|
22
24
|
* @zh 生成的二维码
|
|
25
|
+
* @zh-Hant 生成的二維碼
|
|
23
26
|
* @en Generated QR code
|
|
24
27
|
*/
|
|
25
28
|
qrCode: string;
|
|
26
29
|
/**
|
|
27
30
|
* @zh 错误
|
|
31
|
+
* @zh-Hant 錯誤
|
|
28
32
|
* @en Error
|
|
29
33
|
*/
|
|
30
34
|
error: unknown;
|
package/dist/useQRCode.d.mts
CHANGED
|
@@ -6,11 +6,13 @@ import QRCode, { QRCodeToDataURLOptions } from 'qrcode';
|
|
|
6
6
|
type UseQRCode = (
|
|
7
7
|
/**
|
|
8
8
|
* @zh 文本
|
|
9
|
+
* @zh-Hant 文本
|
|
9
10
|
* @en Text
|
|
10
11
|
*/
|
|
11
12
|
text: string,
|
|
12
13
|
/**
|
|
13
14
|
* @zh 传递给 `QRCode.toDataURL` 的选项
|
|
15
|
+
* @zh-Hant 傳遞給 `QRCode.toDataURL` 的選項
|
|
14
16
|
* @en Options passed to `QRCode.toDataURL`
|
|
15
17
|
*/
|
|
16
18
|
options?: QRCodeToDataURLOptions) => UseQRCodeReturn;
|
|
@@ -20,11 +22,13 @@ options?: QRCodeToDataURLOptions) => UseQRCodeReturn;
|
|
|
20
22
|
interface UseQRCodeReturn {
|
|
21
23
|
/**
|
|
22
24
|
* @zh 生成的二维码
|
|
25
|
+
* @zh-Hant 生成的二維碼
|
|
23
26
|
* @en Generated QR code
|
|
24
27
|
*/
|
|
25
28
|
qrCode: string;
|
|
26
29
|
/**
|
|
27
30
|
* @zh 错误
|
|
31
|
+
* @zh-Hant 錯誤
|
|
28
32
|
* @en Error
|
|
29
33
|
*/
|
|
30
34
|
error: unknown;
|