Files
chatkit/dist/react/hooks.d.ts
T
CatoandClaude 699e49d179 fix(composer): an empty box is one line, at any width it was measured (0.6.1) (#14)
Chromium counts a textarea's placeholder in scrollHeight. A composer
emptied while it was narrow (a sheet still opening, a layout settling)
read its wrapped placeholder as content and grew to its 240px maximum
with nothing typed, and it stayed that way because the height was keyed
only on the value. On Loki's phone chat that was half the screen of
blank composer after a send.

- An empty box takes its natural one-line height.
- The box re-measures when its width changes (width only, so the
  height it sets cannot loop the observer).
- Browser check: empty the composer while it is 60px wide, widen it, and
  it is one line again (fails at 240px before this change).


Claude-Session: https://claude.ai/code/session_011L2dmcydDLYAiNQwK4XcF4

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-09 06:59:06 -07:00

47 lines
2.4 KiB
TypeScript

import { type DependencyList, type RefObject } from "react";
/**
* Copy + a checkmark that resets. Failures are swallowed on purpose (insecure
* origin, denied permission): the text stays selectable, so a failed copy
* blocks nothing — `copied` simply never flips.
*/
export declare function useClipboard(resetMs?: number): {
copied: boolean;
copy: (text: string) => void;
};
/**
* Follow the conversation only while the reader is at the bottom, and offer a
* way back once they are not. Pinned in a layout effect so the view settles
* before the new token paints — in a passive effect the content lands first
* and the scroll catches up, which reads as a shudder on every chunk.
*
* `grew` should change when a NEW turn is added (message count): sending is an
* unambiguous "show me the reply", so it re-arms following.
*/
export declare function useStickToBottom(changes: DependencyList, grew: number): {
scrollRef: RefObject<HTMLDivElement | null>;
endRef: RefObject<HTMLDivElement | null>;
following: boolean;
onScroll: () => void;
jumpToBottom: () => void;
};
/**
* Publishes the VISUAL viewport height as `--ck-viewport-height`.
*
* `100dvh` does not shrink when the Android soft keyboard opens; only
* `visualViewport` does. A chat column sized `100dvh` keeps its height while
* the keyboard covers the bottom of it, so the composer ends up behind the
* keyboard (orangecat `ViewportHeightSync`, #1094). Rounded down: sub-pixel
* heights leave a 1px seam under the composer on some devices.
*/
export declare function useViewportHeight(target?: RefObject<HTMLElement | null>): void;
/** Grow a textarea to its content up to `max` px, keyed on the VALUE so a
* prefill, a dictated transcript or the clear after send resize it too.
*
* An EMPTY box is always one line. Chromium counts the placeholder in
* `scrollHeight`, so a box measured while it was narrow — mid-transition,
* inside a sheet still opening — read its wrapped placeholder as content and
* locked at `max` with nothing typed: half a phone screen of blank composer
* (Loki, 2026-10-09). And the box re-measures when its WIDTH changes, since a
* width measured once is wrong after the layout settles or the phone turns. */
export declare function useAutoGrow(ref: RefObject<HTMLTextAreaElement | null>, value: string, max?: number): void;
//# sourceMappingURL=hooks.d.ts.map