diff --git a/.changeset/browser-hook-return-shapes.md b/.changeset/browser-hook-return-shapes.md new file mode 100644 index 00000000..54a12c06 --- /dev/null +++ b/.changeset/browser-hook-return-shapes.md @@ -0,0 +1,5 @@ +--- +'react-simplikit': major +--- + +`useKeyboardHeight`, `useVisualViewport`, and `useAvoidKeyboard` now return their single value directly instead of wrapping it in an object. diff --git a/AGENTS.md b/AGENTS.md index 4e92374c..2957bc36 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -118,7 +118,7 @@ Never initialize state with browser API calls (causes hydration mismatch). - **Single value**: `useDebounce(value, delay): T` - **Tuple** (2 items): `useToggle(init): [boolean, () => void]` - **Object** (3+ items): `usePagination(): { page, nextPage, prevPage }` -- **Object** also when the shape is expected to grow: `useKeyboardHeight(): { keyboardHeight }` +- **Single value** for browser measurements: `useKeyboardHeight(): number` ## Testing diff --git a/CLAUDE.md b/CLAUDE.md index 2809c868..a85581a3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -91,7 +91,7 @@ Never initialize state with browser API calls (causes hydration mismatch). - **Single value**: `useDebounce(value, delay): T` - **Tuple** (state + action, 2 items): `useToggle(init): [boolean, () => void]` - **Object** (3+ items): `usePagination(): { page, nextPage, prevPage }` -- **Object** also when the shape is expected to grow: browser measurements such as `useKeyboardHeight(): { keyboardHeight }` +- **Single value** for browser measurements: `useKeyboardHeight(): number` ### Performance Patterns diff --git a/README-es.md b/README-es.md index 453cd87b..d8504889 100644 --- a/README-es.md +++ b/README-es.md @@ -66,7 +66,7 @@ Aplica el estilo que devuelve `useAvoidKeyboard` para mover un campo de entrada import { useAvoidKeyboard } from 'react-simplikit'; function ChatInput() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
diff --git a/README-ja_jp.md b/README-ja_jp.md index db011d3a..860aa283 100644 --- a/README-ja_jp.md +++ b/README-ja_jp.md @@ -66,7 +66,7 @@ function SearchInput() { import { useAvoidKeyboard } from 'react-simplikit'; function ChatInput() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
diff --git a/README-ko_kr.md b/README-ko_kr.md index ddf50d89..bca8dc52 100644 --- a/README-ko_kr.md +++ b/README-ko_kr.md @@ -66,7 +66,7 @@ function SearchInput() { import { useAvoidKeyboard } from 'react-simplikit'; function ChatInput() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
diff --git a/README-zh_hans.md b/README-zh_hans.md index cd39697c..e0e3ead2 100644 --- a/README-zh_hans.md +++ b/README-zh_hans.md @@ -66,7 +66,7 @@ function SearchInput() { import { useAvoidKeyboard } from 'react-simplikit'; function ChatInput() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
diff --git a/README.md b/README.md index 5f317b5e..b6c4b2bd 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Use the style returned by `useAvoidKeyboard` to move a fixed input above the on- import { useAvoidKeyboard } from 'react-simplikit'; function ChatInput() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
diff --git a/docs/es/mobile-web.md b/docs/es/mobile-web.md index 4684f0e1..7e3c9b2a 100644 --- a/docs/es/mobile-web.md +++ b/docs/es/mobile-web.md @@ -34,7 +34,7 @@ Este ejemplo mantiene un botón fijado en la parte inferior por encima del tecla import { useAvoidKeyboard } from 'react-simplikit'; function FixedBottomCTA() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
Not supported
; @@ -28,7 +28,7 @@ function CustomLayout() { }`; export function UseVisualViewportDemo() { - const { viewport } = useVisualViewport(); + const viewport = useVisualViewport(); const [inputValue, setInputValue] = useState(''); if (!viewport) { diff --git a/packages/plugin/skills/react-simplikit/references/useAvoidKeyboard.md b/packages/plugin/skills/react-simplikit/references/useAvoidKeyboard.md index 9f3cc571..927842b5 100644 --- a/packages/plugin/skills/react-simplikit/references/useAvoidKeyboard.md +++ b/packages/plugin/skills/react-simplikit/references/useAvoidKeyboard.md @@ -7,9 +7,7 @@ to smoothly move them above the keyboard when it appears. ## Interface ```ts -function useAvoidKeyboard( - options?: UseAvoidKeyboardOptions -): UseAvoidKeyboardResult; +function useAvoidKeyboard(options?: UseAvoidKeyboardOptions): CSSProperties; ``` ### Parameters @@ -55,24 +53,15 @@ function useAvoidKeyboard( ## Example ```tsx function FixedBottomCTA() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
## Example ```tsx function ChatInput() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
@@ -62,7 +51,7 @@ function ChatInput() { ```tsx function KeyboardStatus() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
diff --git a/packages/plugin/skills/react-simplikit/references/useVisualViewport.md b/packages/plugin/skills/react-simplikit/references/useVisualViewport.md index ad328709..7581371e 100644 --- a/packages/plugin/skills/react-simplikit/references/useVisualViewport.md +++ b/packages/plugin/skills/react-simplikit/references/useVisualViewport.md @@ -7,7 +7,7 @@ the keyboard appears or the user zooms/scrolls. ## Interface ```ts -function useVisualViewport(): { viewport: VisualViewportState | null }; +function useVisualViewport(): VisualViewportState | null; ``` ### Parameters @@ -18,44 +18,37 @@ This function does not accept any parameters. ## Ejemplo ```tsx function FixedBottomCTA() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
## 使用例 ```tsx function FixedBottomCTA() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
## 예시 ```tsx function FixedBottomCTA() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
## Example ```tsx function FixedBottomCTA() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
({ - useKeyboardHeight: vi.fn(() => ({ keyboardHeight: 0 })), + useKeyboardHeight: vi.fn(() => 0), })); // Get reference to the mocked function @@ -14,7 +14,7 @@ const mockUseKeyboardHeight = vi.mocked(useKeyboardHeight); describe('useAvoidKeyboard', () => { beforeEach(() => { - mockUseKeyboardHeight.mockReturnValue({ keyboardHeight: 0 }); + mockUseKeyboardHeight.mockReturnValue(0); }); afterEach(() => { @@ -25,7 +25,7 @@ describe('useAvoidKeyboard', () => { it('should return initial style with keyboard hidden', () => { const { result } = renderHook(() => useAvoidKeyboard()); - expect(result.current.style).toEqual({ + expect(result.current).toEqual({ transform: 'translateY(0px)', transition: 'transform 200ms ease-out', }); @@ -34,22 +34,22 @@ describe('useAvoidKeyboard', () => { describe('style generation', () => { it('should generate correct transform when keyboard is visible', () => { - mockUseKeyboardHeight.mockReturnValue({ keyboardHeight: 300 }); + mockUseKeyboardHeight.mockReturnValue(300); const { result } = renderHook(() => useAvoidKeyboard()); - expect(result.current.style).toEqual({ + expect(result.current).toEqual({ transform: 'translateY(-300px)', transition: 'transform 200ms ease-out', }); }); it('should include safeAreaBottom in transform calculation', () => { - mockUseKeyboardHeight.mockReturnValue({ keyboardHeight: 300 }); + mockUseKeyboardHeight.mockReturnValue(300); const { result } = renderHook(() => useAvoidKeyboard({ safeAreaBottom: 20 })); - expect(result.current.style).toEqual({ + expect(result.current).toEqual({ transform: 'translateY(-320px)', transition: 'transform 200ms ease-out', }); @@ -58,7 +58,7 @@ describe('useAvoidKeyboard', () => { it('should apply custom transition duration', () => { const { result } = renderHook(() => useAvoidKeyboard({ transitionDuration: 300 })); - expect(result.current.style.transition).toBe('transform 300ms ease-out'); + expect(result.current.transition).toBe('transform 300ms ease-out'); }); it('should apply custom transition timing function', () => { @@ -66,11 +66,11 @@ describe('useAvoidKeyboard', () => { useAvoidKeyboard({ transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)' }) ); - expect(result.current.style.transition).toBe('transform 200ms cubic-bezier(0.4, 0, 0.2, 1)'); + expect(result.current.transition).toBe('transform 200ms cubic-bezier(0.4, 0, 0.2, 1)'); }); it('should apply all custom options together', () => { - mockUseKeyboardHeight.mockReturnValue({ keyboardHeight: 250 }); + mockUseKeyboardHeight.mockReturnValue(250); const { result } = renderHook(() => useAvoidKeyboard({ @@ -80,7 +80,7 @@ describe('useAvoidKeyboard', () => { }) ); - expect(result.current.style).toEqual({ + expect(result.current).toEqual({ transform: 'translateY(-280px)', transition: 'transform 150ms linear', }); @@ -91,17 +91,17 @@ describe('useAvoidKeyboard', () => { it('should update style when keyboard height changes', () => { const { result, rerender } = renderHook(() => useAvoidKeyboard()); - expect(result.current.style.transform).toBe('translateY(0px)'); + expect(result.current.transform).toBe('translateY(0px)'); - mockUseKeyboardHeight.mockReturnValue({ keyboardHeight: 350 }); + mockUseKeyboardHeight.mockReturnValue(350); rerender(); - expect(result.current.style.transform).toBe('translateY(-350px)'); + expect(result.current.transform).toBe('translateY(-350px)'); - mockUseKeyboardHeight.mockReturnValue({ keyboardHeight: 0 }); + mockUseKeyboardHeight.mockReturnValue(0); rerender(); - expect(result.current.style.transform).toBe('translateY(0px)'); + expect(result.current.transform).toBe('translateY(0px)'); }); }); @@ -121,7 +121,7 @@ describe('useAvoidKeyboard', () => { describe('use cases', () => { it('should provide style for fixed bottom CTA', () => { - mockUseKeyboardHeight.mockReturnValue({ keyboardHeight: 300 }); + mockUseKeyboardHeight.mockReturnValue(300); const { result } = renderHook(() => useAvoidKeyboard()); @@ -130,7 +130,7 @@ describe('useAvoidKeyboard', () => { bottom: 0, left: 0, right: 0, - ...result.current.style, + ...result.current, }; expect(elementStyle.transform).toBe('translateY(-300px)'); @@ -138,11 +138,11 @@ describe('useAvoidKeyboard', () => { }); it('should handle safe area with safeAreaBottom', () => { - mockUseKeyboardHeight.mockReturnValue({ keyboardHeight: 300 }); + mockUseKeyboardHeight.mockReturnValue(300); const { result } = renderHook(() => useAvoidKeyboard({ safeAreaBottom: 34 })); - expect(result.current.style.transform).toBe('translateY(-334px)'); + expect(result.current.transform).toBe('translateY(-334px)'); }); }); @@ -150,22 +150,22 @@ describe('useAvoidKeyboard', () => { it('should return same style object when values do not change', () => { const { result, rerender } = renderHook(() => useAvoidKeyboard()); - const firstStyle = result.current.style; + const firstStyle = result.current; rerender(); - expect(result.current.style).toBe(firstStyle); + expect(result.current).toBe(firstStyle); }); it('should return new style object when keyboard height changes', () => { const { result, rerender } = renderHook(() => useAvoidKeyboard()); - const firstStyle = result.current.style; + const firstStyle = result.current; - mockUseKeyboardHeight.mockReturnValue({ keyboardHeight: 100 }); + mockUseKeyboardHeight.mockReturnValue(100); rerender(); - expect(result.current.style).not.toBe(firstStyle); + expect(result.current).not.toBe(firstStyle); }); }); }); diff --git a/packages/react-simplikit/src/hooks/useAvoidKeyboard/useAvoidKeyboard.ts b/packages/react-simplikit/src/hooks/useAvoidKeyboard/useAvoidKeyboard.ts index bb9d8736..7e6a6305 100644 --- a/packages/react-simplikit/src/hooks/useAvoidKeyboard/useAvoidKeyboard.ts +++ b/packages/react-simplikit/src/hooks/useAvoidKeyboard/useAvoidKeyboard.ts @@ -26,14 +26,6 @@ type UseAvoidKeyboardOptions = { immediate?: boolean; }; -type UseAvoidKeyboardResult = { - /** - * CSS style object to apply to the fixed bottom element. - * Contains transform and transition properties. - */ - style: CSSProperties; -}; - /** * @description * `useAvoidKeyboard` is a React hook that helps fixed-bottom elements avoid the on-screen keyboard. @@ -46,12 +38,11 @@ type UseAvoidKeyboardResult = { * @param {CSSProperties['transitionTimingFunction']} [options.transitionTimingFunction='ease-out'] - Transition timing function for the animation. * @param {boolean} [options.immediate=true] - If true, gets the initial keyboard height on mount. * - * @returns {UseAvoidKeyboardResult} An object containing the CSS style for keyboard avoidance. - * - style `CSSProperties` - CSS style object to apply to the fixed bottom element. Contains `transform` and `transition` properties; + * @returns {CSSProperties} The CSS style to apply to the fixed bottom element. Contains `transform` and `transition` properties. * * @example * function FixedBottomCTA() { - * const { style } = useAvoidKeyboard(); + * const style = useAvoidKeyboard(); * * return ( *
(() => { const translateY = keyboardHeight > 0 ? -(keyboardHeight + safeAreaBottom) : 0; @@ -107,5 +98,5 @@ export function useAvoidKeyboard(options: UseAvoidKeyboardOptions = {}): UseAvoi }; }, [keyboardHeight, safeAreaBottom, transitionDuration, transitionTimingFunction]); - return { style }; + return style; } diff --git a/packages/react-simplikit/src/hooks/useAvoidKeyboard/zh-Hans/useAvoidKeyboard.md b/packages/react-simplikit/src/hooks/useAvoidKeyboard/zh-Hans/useAvoidKeyboard.md index 86bb71d1..f5f2feb1 100644 --- a/packages/react-simplikit/src/hooks/useAvoidKeyboard/zh-Hans/useAvoidKeyboard.md +++ b/packages/react-simplikit/src/hooks/useAvoidKeyboard/zh-Hans/useAvoidKeyboard.md @@ -5,9 +5,7 @@ ## 接口 ```ts -function useAvoidKeyboard( - options?: UseAvoidKeyboardOptions -): UseAvoidKeyboardResult; +function useAvoidKeyboard(options?: UseAvoidKeyboardOptions): CSSProperties; ``` ### 参数 @@ -53,24 +51,15 @@ function useAvoidKeyboard( ## 示例 ```tsx function FixedBottomCTA() { - const { style } = useAvoidKeyboard(); + const style = useAvoidKeyboard(); return (
## Ejemplo ```tsx function ChatInput() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
@@ -62,7 +51,7 @@ function ChatInput() { ```tsx function KeyboardStatus() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
diff --git a/packages/react-simplikit/src/hooks/useKeyboardHeight/ja/useKeyboardHeight.md b/packages/react-simplikit/src/hooks/useKeyboardHeight/ja/useKeyboardHeight.md index e97c3152..8f517342 100644 --- a/packages/react-simplikit/src/hooks/useKeyboardHeight/ja/useKeyboardHeight.md +++ b/packages/react-simplikit/src/hooks/useKeyboardHeight/ja/useKeyboardHeight.md @@ -7,9 +7,7 @@ ## インターフェース ```ts -function useKeyboardHeight( - options?: UseKeyboardHeightOptions -): UseKeyboardHeightResult; +function useKeyboardHeight(options?: UseKeyboardHeightOptions): number; ``` ### パラメータ @@ -33,24 +31,15 @@ function useKeyboardHeight( ## 使用例 ```tsx function ChatInput() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
@@ -62,7 +51,7 @@ function ChatInput() { ```tsx function KeyboardStatus() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
diff --git a/packages/react-simplikit/src/hooks/useKeyboardHeight/ko/useKeyboardHeight.md b/packages/react-simplikit/src/hooks/useKeyboardHeight/ko/useKeyboardHeight.md index cc941d67..93ea82c7 100644 --- a/packages/react-simplikit/src/hooks/useKeyboardHeight/ko/useKeyboardHeight.md +++ b/packages/react-simplikit/src/hooks/useKeyboardHeight/ko/useKeyboardHeight.md @@ -5,9 +5,7 @@ ## 인터페이스 ```ts -function useKeyboardHeight( - options?: UseKeyboardHeightOptions -): UseKeyboardHeightResult; +function useKeyboardHeight(options?: UseKeyboardHeightOptions): number; ``` ### 파라미터 @@ -32,23 +30,15 @@ function useKeyboardHeight( ## 예시 ```tsx function ChatInput() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
@@ -60,7 +50,7 @@ function ChatInput() { ```tsx function KeyboardStatus() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
diff --git a/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.md b/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.md index 09d3618a..47fd8ddb 100644 --- a/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.md +++ b/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.md @@ -7,9 +7,7 @@ when the keyboard appears, disappears, or changes size. ## Interface ```ts -function useKeyboardHeight( - options?: UseKeyboardHeightOptions -): UseKeyboardHeightResult; +function useKeyboardHeight(options?: UseKeyboardHeightOptions): number; ``` ### Parameters @@ -33,24 +31,15 @@ function useKeyboardHeight( ## Example ```tsx function ChatInput() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
@@ -62,7 +51,7 @@ function ChatInput() { ```tsx function KeyboardStatus() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
diff --git a/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.test.ts b/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.test.ts index 694d367d..546f6b18 100644 --- a/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.test.ts +++ b/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.test.ts @@ -27,7 +27,7 @@ describe('useKeyboardHeight', () => { it('should return 0 as initial keyboard height', () => { const { result } = renderHook(() => useKeyboardHeight()); - expect(result.current.keyboardHeight).toBe(0); + expect(result.current).toBe(0); }); }); @@ -58,7 +58,7 @@ describe('useKeyboardHeight', () => { const { result } = renderHook(() => useKeyboardHeight()); - expect(result.current.keyboardHeight).toBe(300); + expect(result.current).toBe(300); }); }); @@ -98,19 +98,19 @@ describe('useKeyboardHeight', () => { const { result } = renderHook(() => useKeyboardHeight()); - expect(result.current.keyboardHeight).toBe(0); + expect(result.current).toBe(0); await act(async () => { capturedCallback?.(250); }); - expect(result.current.keyboardHeight).toBe(250); + expect(result.current).toBe(250); await act(async () => { capturedCallback?.(0); }); - expect(result.current.keyboardHeight).toBe(0); + expect(result.current).toBe(0); }); it('should handle various keyboard heights', () => { @@ -124,7 +124,7 @@ describe('useKeyboardHeight', () => { const { result } = renderHook(() => useKeyboardHeight()); - expect(result.current.keyboardHeight).toBe(expectedHeight); + expect(result.current).toBe(expectedHeight); } }); }); @@ -138,7 +138,7 @@ describe('useKeyboardHeight', () => { const { result } = renderHook(() => useKeyboardHeight()); - const paddingBottom = `${result.current.keyboardHeight}px`; + const paddingBottom = `${result.current}px`; expect(paddingBottom).toBe('300px'); }); @@ -150,7 +150,7 @@ describe('useKeyboardHeight', () => { const { result } = renderHook(() => useKeyboardHeight()); - const isKeyboardVisible = result.current.keyboardHeight > 0; + const isKeyboardVisible = result.current > 0; expect(isKeyboardVisible).toBe(true); }); @@ -162,7 +162,7 @@ describe('useKeyboardHeight', () => { const { result } = renderHook(() => useKeyboardHeight()); - const isKeyboardVisible = result.current.keyboardHeight > 0; + const isKeyboardVisible = result.current > 0; expect(isKeyboardVisible).toBe(false); }); }); @@ -190,8 +190,8 @@ describe('useKeyboardHeight', () => { callback2?.(200); }); - expect(result1.current.keyboardHeight).toBe(200); - expect(result2.current.keyboardHeight).toBe(200); + expect(result1.current).toBe(200); + expect(result2.current).toBe(200); }); }); }); diff --git a/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.ts b/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.ts index c5b501b3..1cd21559 100644 --- a/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.ts +++ b/packages/react-simplikit/src/hooks/useKeyboardHeight/useKeyboardHeight.ts @@ -10,13 +10,6 @@ type UseKeyboardHeightOptions = { immediate?: boolean; }; -type UseKeyboardHeightResult = { - /** - * The current keyboard height in pixels. - */ - keyboardHeight: number; -}; - /** * @description * `useKeyboardHeight` is a React hook that tracks the on-screen keyboard height. @@ -26,12 +19,11 @@ type UseKeyboardHeightResult = { * @param {UseKeyboardHeightOptions} [options] - Configuration options. * @param {boolean} [options.immediate=true] - If true, gets the initial keyboard height on mount. * - * @returns {UseKeyboardHeightResult} An object containing the current keyboard height. - * - keyboardHeight `number` - The current keyboard height in pixels. 0 when the keyboard is hidden; + * @returns {number} The current keyboard height in pixels. 0 when the keyboard is hidden. * * @example * function ChatInput() { - * const { keyboardHeight } = useKeyboardHeight(); + * const keyboardHeight = useKeyboardHeight(); * * return ( *
@@ -42,7 +34,7 @@ type UseKeyboardHeightResult = { * * @example * function KeyboardStatus() { - * const { keyboardHeight } = useKeyboardHeight(); + * const keyboardHeight = useKeyboardHeight(); * * return ( *
@@ -53,7 +45,7 @@ type UseKeyboardHeightResult = { * ); * } */ -export function useKeyboardHeight(options: UseKeyboardHeightOptions = {}): UseKeyboardHeightResult { +export function useKeyboardHeight(options: UseKeyboardHeightOptions = {}): number { const { immediate = true } = options; const [keyboardHeight, setKeyboardHeight] = useState(0); @@ -70,5 +62,5 @@ export function useKeyboardHeight(options: UseKeyboardHeightOptions = {}): UseKe [immediate] ); - return { keyboardHeight }; + return keyboardHeight; } diff --git a/packages/react-simplikit/src/hooks/useKeyboardHeight/zh-Hans/useKeyboardHeight.md b/packages/react-simplikit/src/hooks/useKeyboardHeight/zh-Hans/useKeyboardHeight.md index 5ad41445..1705a16c 100644 --- a/packages/react-simplikit/src/hooks/useKeyboardHeight/zh-Hans/useKeyboardHeight.md +++ b/packages/react-simplikit/src/hooks/useKeyboardHeight/zh-Hans/useKeyboardHeight.md @@ -5,9 +5,7 @@ ## 接口 ```ts -function useKeyboardHeight( - options?: UseKeyboardHeightOptions -): UseKeyboardHeightResult; +function useKeyboardHeight(options?: UseKeyboardHeightOptions): number; ``` ### 参数 @@ -31,24 +29,15 @@ function useKeyboardHeight( ## 示例 ```tsx function ChatInput() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
@@ -60,7 +49,7 @@ function ChatInput() { ```tsx function KeyboardStatus() { - const { keyboardHeight } = useKeyboardHeight(); + const keyboardHeight = useKeyboardHeight(); return (
diff --git a/packages/react-simplikit/src/hooks/useVisualViewport/es/useVisualViewport.md b/packages/react-simplikit/src/hooks/useVisualViewport/es/useVisualViewport.md index 10742913..1638fd24 100644 --- a/packages/react-simplikit/src/hooks/useVisualViewport/es/useVisualViewport.md +++ b/packages/react-simplikit/src/hooks/useVisualViewport/es/useVisualViewport.md @@ -7,7 +7,7 @@ aparece el teclado o el usuario ajusta el zoom o se desplaza. ## Interfaz ```ts -function useVisualViewport(): { viewport: VisualViewportState | null }; +function useVisualViewport(): VisualViewportState | null; ``` ### Parámetros @@ -18,44 +18,37 @@ Esta función no acepta parámetros.