@particle-network/ui-react 0.3.2-beta.2 → 0.4.0-beta.0
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/components/UXEmpty/index.js +3 -3
- package/dist/components/UXInput/index.d.ts +1 -1
- package/dist/components/UXInput/input.extend.d.ts +1 -1
- package/dist/components/UXThemeSwitch/index.d.ts +3 -0
- package/dist/components/UXThemeSwitch/index.js +3 -0
- package/dist/components/UXThemeSwitch/theme-data.d.ts +28 -0
- package/dist/components/UXThemeSwitch/theme-data.js +304 -0
- package/dist/components/UXThemeSwitch/theme-item.d.ts +7 -0
- package/dist/components/UXThemeSwitch/theme-item.js +136 -0
- package/dist/components/UXThemeSwitch/theme-switch.d.ts +5 -0
- package/dist/components/UXThemeSwitch/theme-switch.js +121 -0
- package/dist/components/UXThemeSwitch/use-theme-store.d.ts +40 -0
- package/dist/components/UXThemeSwitch/use-theme-store.js +25 -0
- package/dist/components/UXThemeSwitch/use-theme.d.ts +14 -0
- package/dist/components/UXThemeSwitch/use-theme.js +90 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/hooks/useI18n.d.ts +9 -0
- package/dist/hooks/useI18n.js +19 -1
- package/dist/icons/index.js +14 -3
- package/dist/utils/input-classes.d.ts +0 -32
- package/dist/utils/input-classes.js +5 -23
- package/package.json +5 -4
- package/tailwind-preset.js +804 -44
- package/dist/hooks/useKeyboard.d.ts +0 -13
- package/dist/hooks/useKeyboard.js +0 -34
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description
|
|
3
|
-
* 尝试获取移动端虚拟键盘的高度。
|
|
4
|
-
* 该方法主要依赖监听视口高度变化,在移动端(尤其 iOS)键盘弹出时,
|
|
5
|
-
* window.innerHeight 或 window.visualViewport.height 会减小。
|
|
6
|
-
*
|
|
7
|
-
* @returns {number} 键盘高度(像素值),如果键盘未弹出或无法确定则返回 0。
|
|
8
|
-
*/
|
|
9
|
-
declare const useKeyboard: () => {
|
|
10
|
-
keyboardHeight: number;
|
|
11
|
-
isKeyboardVisible: boolean;
|
|
12
|
-
};
|
|
13
|
-
export default useKeyboard;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
const useKeyboard = ()=>{
|
|
3
|
-
const [initialViewportHeight, setInitialViewportHeight] = useState(0);
|
|
4
|
-
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
5
|
-
useEffect(()=>{
|
|
6
|
-
const setInitialHeight = ()=>{
|
|
7
|
-
const height = window.visualViewport ? window.visualViewport.height : window.innerHeight;
|
|
8
|
-
if (height > 0) setInitialViewportHeight((prevHeight)=>Math.max(prevHeight, height));
|
|
9
|
-
};
|
|
10
|
-
requestAnimationFrame(setInitialHeight);
|
|
11
|
-
window.addEventListener('focusin', setInitialHeight);
|
|
12
|
-
const handleViewportChange = ()=>{
|
|
13
|
-
const currentHeight = window.visualViewport ? window.visualViewport.height : window.innerHeight;
|
|
14
|
-
if (0 === initialViewportHeight) return;
|
|
15
|
-
const calculatedHeight = Math.max(0, initialViewportHeight - currentHeight);
|
|
16
|
-
calculatedHeight > 50 ? setKeyboardHeight(calculatedHeight) : setKeyboardHeight(0);
|
|
17
|
-
};
|
|
18
|
-
window.addEventListener('resize', handleViewportChange);
|
|
19
|
-
if (window.visualViewport) window.visualViewport.addEventListener('resize', handleViewportChange);
|
|
20
|
-
return ()=>{
|
|
21
|
-
window.removeEventListener('focusin', setInitialHeight);
|
|
22
|
-
window.removeEventListener('resize', handleViewportChange);
|
|
23
|
-
if (window.visualViewport) window.visualViewport.removeEventListener('resize', handleViewportChange);
|
|
24
|
-
};
|
|
25
|
-
}, [
|
|
26
|
-
initialViewportHeight
|
|
27
|
-
]);
|
|
28
|
-
return {
|
|
29
|
-
keyboardHeight,
|
|
30
|
-
isKeyboardVisible: keyboardHeight > 0
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
const hooks_useKeyboard = useKeyboard;
|
|
34
|
-
export { hooks_useKeyboard as default };
|