tempest-react-sdk 0.2.0 → 0.3.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/index.d.ts +323 -4
- package/dist/styles.css +1 -1
- package/dist/tempest-react-sdk.cjs +3 -3
- package/dist/tempest-react-sdk.cjs.map +1 -1
- package/dist/tempest-react-sdk.js +2212 -1528
- package/dist/tempest-react-sdk.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,33 @@ import { UseFormProps } from 'react-hook-form';
|
|
|
28
28
|
import { UseFormReturn } from 'react-hook-form';
|
|
29
29
|
import { z } from 'zod';
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Accessible accordion. Each item collapses/expands its content. Single-mode by
|
|
33
|
+
* default — pass `multiple` to allow more than one item open at a time. Can be
|
|
34
|
+
* controlled via `value` + `onChange`, or uncontrolled via `defaultValue`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function Accordion({ items, multiple, value, defaultValue, onChange, className, }: AccordionProps): JSX.Element;
|
|
37
|
+
|
|
38
|
+
export declare interface AccordionItem {
|
|
39
|
+
/** Stable identifier. */
|
|
40
|
+
id: string;
|
|
41
|
+
title: ReactNode;
|
|
42
|
+
children: ReactNode;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare interface AccordionProps {
|
|
47
|
+
items: AccordionItem[];
|
|
48
|
+
/** When `true` multiple items can be open simultaneously. Default `false`. */
|
|
49
|
+
multiple?: boolean;
|
|
50
|
+
/** Controlled open ids. */
|
|
51
|
+
value?: string[];
|
|
52
|
+
/** Uncontrolled default open ids. */
|
|
53
|
+
defaultValue?: string[];
|
|
54
|
+
onChange?: (openIds: string[]) => void;
|
|
55
|
+
className?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
31
58
|
/**
|
|
32
59
|
* Inline alert / notice with tone (info/success/warning/danger) and appearance
|
|
33
60
|
* (soft/solid/outline). Accepts optional `icon`, `title`, `description` and
|
|
@@ -52,6 +79,10 @@ export declare interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
52
79
|
|
|
53
80
|
export declare type AlertVariant = "neutral" | "info" | "success" | "warning" | "danger";
|
|
54
81
|
|
|
82
|
+
declare type AnyEventTarget = EventTarget | {
|
|
83
|
+
current: EventTarget | null;
|
|
84
|
+
} | null | undefined;
|
|
85
|
+
|
|
55
86
|
export declare interface ApiClient {
|
|
56
87
|
request<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
57
88
|
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
@@ -88,6 +119,29 @@ export declare interface ApiError {
|
|
|
88
119
|
body?: unknown;
|
|
89
120
|
}
|
|
90
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Preserve a constant aspect ratio for media (images, video, embeds). The
|
|
124
|
+
* inner child stretches to fill the box. Uses the native `aspect-ratio`
|
|
125
|
+
* CSS property — works on all modern browsers (Safari 15+, Chrome 88+).
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* <AspectRatio ratio={16 / 9}>
|
|
129
|
+
* <img src="/cover.jpg" alt="" style={{ width: "100%", height: "100%", objectFit: "cover" }} />
|
|
130
|
+
* </AspectRatio>
|
|
131
|
+
*/
|
|
132
|
+
export declare function AspectRatio({ ratio, className, style, children, ...props }: AspectRatioProps): JSX.Element;
|
|
133
|
+
|
|
134
|
+
export declare interface AspectRatioProps extends HTMLAttributes<HTMLDivElement> {
|
|
135
|
+
/**
|
|
136
|
+
* Width-to-height ratio. Pass `16/9` for widescreen, `1` for square,
|
|
137
|
+
* `4/3` for SD video, `3/4` for portrait, etc. Default `16/9`.
|
|
138
|
+
*/
|
|
139
|
+
ratio?: number;
|
|
140
|
+
children?: ReactNode;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export declare type AsyncStatus = "idle" | "pending" | "success" | "error";
|
|
144
|
+
|
|
91
145
|
export declare interface AudioPlayer {
|
|
92
146
|
/** Play `src`. Returns the underlying element, or `null` when the browser blocked autoplay. */
|
|
93
147
|
play: (src: string, options?: PlayAudioOptions) => Promise<HTMLAudioElement | null>;
|
|
@@ -283,7 +337,31 @@ export declare interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
283
337
|
|
|
284
338
|
export declare type Catalog = Record<string, Messages>;
|
|
285
339
|
|
|
286
|
-
|
|
340
|
+
/**
|
|
341
|
+
* Center children horizontally, vertically, or both. Flex-based; works with
|
|
342
|
+
* any child size. Pair with `minHeight` (or set parent height) when
|
|
343
|
+
* centering vertically.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* <Center axis="both" minHeight="100vh">
|
|
347
|
+
* <Spinner />
|
|
348
|
+
* </Center>
|
|
349
|
+
*/
|
|
350
|
+
export declare function Center({ axis, minHeight, fullWidth, className, style, children, ...props }: CenterProps): JSX.Element;
|
|
351
|
+
|
|
352
|
+
export declare type CenterAxis = "both" | "horizontal" | "vertical";
|
|
353
|
+
|
|
354
|
+
export declare interface CenterProps extends HTMLAttributes<HTMLDivElement> {
|
|
355
|
+
/** Which axis to center on. Default `"both"`. */
|
|
356
|
+
axis?: CenterAxis;
|
|
357
|
+
/** Fixed height for the container. Numbers map to `${n}px`; strings pass through. Useful when centering inside an unsized parent. */
|
|
358
|
+
minHeight?: number | string;
|
|
359
|
+
/** When `true` (default), takes up `100%` width of the parent. */
|
|
360
|
+
fullWidth?: boolean;
|
|
361
|
+
children?: ReactNode;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export declare const CEPInput: ForwardRefExoticComponent<Omit<InputProps, "value" | "onChange"> & {
|
|
287
365
|
value: string;
|
|
288
366
|
onChange: (value: string) => void;
|
|
289
367
|
} & RefAttributes<HTMLInputElement>>;
|
|
@@ -332,11 +410,41 @@ declare type ClassValue = string | number | bigint | boolean | null | undefined
|
|
|
332
410
|
*/
|
|
333
411
|
export declare function cn(...values: ClassValue[]): string;
|
|
334
412
|
|
|
335
|
-
export declare const CNPJInput: ForwardRefExoticComponent<Omit<InputProps, "
|
|
413
|
+
export declare const CNPJInput: ForwardRefExoticComponent<Omit<InputProps, "value" | "onChange"> & {
|
|
336
414
|
value: string;
|
|
337
415
|
onChange: (value: string) => void;
|
|
338
416
|
} & RefAttributes<HTMLInputElement>>;
|
|
339
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Combobox — text input with a filterable dropdown of options.
|
|
420
|
+
*
|
|
421
|
+
* Selecting an option fires `onChange(value)`. Typing filters the list.
|
|
422
|
+
* Keyboard: ArrowUp/ArrowDown to navigate, Enter to select, Esc to close.
|
|
423
|
+
*/
|
|
424
|
+
export declare function Combobox({ options, value, onChange, label, placeholder, helperText, error, disabled, filter, emptyMessage, className, }: ComboboxProps): JSX.Element;
|
|
425
|
+
|
|
426
|
+
export declare interface ComboboxOption {
|
|
427
|
+
value: string;
|
|
428
|
+
label: string;
|
|
429
|
+
disabled?: boolean;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export declare interface ComboboxProps {
|
|
433
|
+
options: ComboboxOption[];
|
|
434
|
+
value: string;
|
|
435
|
+
onChange: (value: string) => void;
|
|
436
|
+
label?: string;
|
|
437
|
+
placeholder?: string;
|
|
438
|
+
helperText?: string;
|
|
439
|
+
error?: string;
|
|
440
|
+
disabled?: boolean;
|
|
441
|
+
/** Custom filter — return true to keep the option. Default is case-insensitive substring match on label. */
|
|
442
|
+
filter?: (option: ComboboxOption, query: string) => boolean;
|
|
443
|
+
/** Message shown when no option matches. */
|
|
444
|
+
emptyMessage?: string;
|
|
445
|
+
className?: string;
|
|
446
|
+
}
|
|
447
|
+
|
|
340
448
|
/**
|
|
341
449
|
* Quick confirmation prompt built on top of {@link Modal}. Use for destructive
|
|
342
450
|
* actions with `variant="danger"`.
|
|
@@ -376,7 +484,7 @@ export declare interface ContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
376
484
|
|
|
377
485
|
export declare type ContainerSize = "sm" | "md" | "lg" | "xl" | "full";
|
|
378
486
|
|
|
379
|
-
export declare const CPFInput: ForwardRefExoticComponent<Omit<InputProps, "
|
|
487
|
+
export declare const CPFInput: ForwardRefExoticComponent<Omit<InputProps, "value" | "onChange"> & {
|
|
380
488
|
value: string;
|
|
381
489
|
onChange: (value: string) => void;
|
|
382
490
|
} & RefAttributes<HTMLInputElement>>;
|
|
@@ -826,6 +934,46 @@ export declare interface DrawerProps {
|
|
|
826
934
|
showHandle?: boolean;
|
|
827
935
|
}
|
|
828
936
|
|
|
937
|
+
/**
|
|
938
|
+
* Dropdown menu — list of selectable actions anchored to a trigger.
|
|
939
|
+
*
|
|
940
|
+
* - Toggle on trigger click.
|
|
941
|
+
* - Close on outside click / Escape / item selection.
|
|
942
|
+
* - Arrow keys navigate, Enter activates focused item.
|
|
943
|
+
*/
|
|
944
|
+
export declare function DropdownMenu({ trigger, items, placement, className, }: DropdownMenuProps): JSX.Element;
|
|
945
|
+
|
|
946
|
+
export declare type DropdownMenuEntry = {
|
|
947
|
+
type: "item";
|
|
948
|
+
id: string;
|
|
949
|
+
label: ReactNode;
|
|
950
|
+
icon?: ReactNode;
|
|
951
|
+
danger?: boolean;
|
|
952
|
+
disabled?: boolean;
|
|
953
|
+
onSelect: () => void;
|
|
954
|
+
} | {
|
|
955
|
+
type: "separator";
|
|
956
|
+
id: string;
|
|
957
|
+
} | {
|
|
958
|
+
type: "label";
|
|
959
|
+
id: string;
|
|
960
|
+
label: ReactNode;
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
export declare type DropdownMenuPlacement = "bottom-start" | "bottom-end" | "top-start" | "top-end";
|
|
964
|
+
|
|
965
|
+
export declare interface DropdownMenuProps {
|
|
966
|
+
trigger: ReactElement<{
|
|
967
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
968
|
+
"aria-expanded"?: boolean;
|
|
969
|
+
"aria-controls"?: string;
|
|
970
|
+
"aria-haspopup"?: boolean | "menu";
|
|
971
|
+
}>;
|
|
972
|
+
items: DropdownMenuEntry[];
|
|
973
|
+
placement?: DropdownMenuPlacement;
|
|
974
|
+
className?: string;
|
|
975
|
+
}
|
|
976
|
+
|
|
829
977
|
export declare interface ElementSize {
|
|
830
978
|
width: number;
|
|
831
979
|
height: number;
|
|
@@ -1383,6 +1531,11 @@ export declare interface ListOptions<TItem> {
|
|
|
1383
1531
|
filter?: (item: TItem) => boolean;
|
|
1384
1532
|
}
|
|
1385
1533
|
|
|
1534
|
+
export declare type LocalStorageOptions<T> = {
|
|
1535
|
+
serialize?: (value: T) => string;
|
|
1536
|
+
deserialize?: (raw: string) => T;
|
|
1537
|
+
};
|
|
1538
|
+
|
|
1386
1539
|
export declare interface LogEntry {
|
|
1387
1540
|
level: LogLevel;
|
|
1388
1541
|
message: string;
|
|
@@ -1529,7 +1682,7 @@ export declare interface PaginationProps {
|
|
|
1529
1682
|
*/
|
|
1530
1683
|
export declare function parseResponse<TSchema extends z.ZodTypeAny>(schema: TSchema, raw: unknown, context: string): z.infer<TSchema>;
|
|
1531
1684
|
|
|
1532
|
-
export declare const PhoneInput: ForwardRefExoticComponent<Omit<InputProps, "
|
|
1685
|
+
export declare const PhoneInput: ForwardRefExoticComponent<Omit<InputProps, "value" | "onChange"> & {
|
|
1533
1686
|
value: string;
|
|
1534
1687
|
onChange: (value: string) => void;
|
|
1535
1688
|
} & RefAttributes<HTMLInputElement>>;
|
|
@@ -1556,6 +1709,37 @@ export declare interface PlayAudioOptions {
|
|
|
1556
1709
|
onError?: (error: unknown) => void;
|
|
1557
1710
|
}
|
|
1558
1711
|
|
|
1712
|
+
/**
|
|
1713
|
+
* Lightweight popover. Renders a positioned panel anchored to a trigger,
|
|
1714
|
+
* dismissed on outside click / Escape. Does NOT include collision detection
|
|
1715
|
+
* or smart positioning — pair with Floating UI if you need that.
|
|
1716
|
+
*/
|
|
1717
|
+
export declare function Popover({ trigger, children, placement, open, onOpenChange, defaultOpen, closeOnEsc, closeOnOutsideClick, className, }: PopoverProps): JSX.Element;
|
|
1718
|
+
|
|
1719
|
+
export declare type PopoverPlacement = "top" | "bottom" | "left" | "right";
|
|
1720
|
+
|
|
1721
|
+
export declare interface PopoverProps {
|
|
1722
|
+
/** Trigger element. Receives `onClick`/`aria-expanded`/`aria-controls`. */
|
|
1723
|
+
trigger: ReactElement<{
|
|
1724
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
1725
|
+
"aria-expanded"?: boolean;
|
|
1726
|
+
"aria-controls"?: string;
|
|
1727
|
+
}>;
|
|
1728
|
+
children: ReactNode;
|
|
1729
|
+
placement?: PopoverPlacement;
|
|
1730
|
+
/** Controlled open state. */
|
|
1731
|
+
open?: boolean;
|
|
1732
|
+
/** Called when the user toggles or dismisses. */
|
|
1733
|
+
onOpenChange?: (open: boolean) => void;
|
|
1734
|
+
/** Default open state for uncontrolled usage. */
|
|
1735
|
+
defaultOpen?: boolean;
|
|
1736
|
+
/** Close on Escape. Default true. */
|
|
1737
|
+
closeOnEsc?: boolean;
|
|
1738
|
+
/** Close on outside click. Default true. */
|
|
1739
|
+
closeOnOutsideClick?: boolean;
|
|
1740
|
+
className?: string;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1559
1743
|
/**
|
|
1560
1744
|
* Minimal subset of `posthog-js` used by the adapter. Pass either the real
|
|
1561
1745
|
* default export (`import posthog from "posthog-js"`) or a stubbed object
|
|
@@ -1662,6 +1846,51 @@ export declare interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputEl
|
|
|
1662
1846
|
wrapperClassName?: string;
|
|
1663
1847
|
}
|
|
1664
1848
|
|
|
1849
|
+
/**
|
|
1850
|
+
* Dual-thumb range slider. Built on two native `<input type="range">` so it
|
|
1851
|
+
* stays accessible and works with keyboards/screen readers without
|
|
1852
|
+
* heavyweight positioning libs. The active fill is positioned via percentages.
|
|
1853
|
+
*/
|
|
1854
|
+
export declare function RangeSlider({ value, onChange, min, max, step, label, helperText, disabled, formatValue, className, }: RangeSliderProps): JSX.Element;
|
|
1855
|
+
|
|
1856
|
+
export declare interface RangeSliderProps {
|
|
1857
|
+
value: RangeValue;
|
|
1858
|
+
onChange: (value: RangeValue) => void;
|
|
1859
|
+
min?: number;
|
|
1860
|
+
max?: number;
|
|
1861
|
+
step?: number;
|
|
1862
|
+
label?: string;
|
|
1863
|
+
helperText?: string;
|
|
1864
|
+
disabled?: boolean;
|
|
1865
|
+
/** Formatter for the value badge next to the label. Defaults to `min – max`. */
|
|
1866
|
+
formatValue?: (value: RangeValue) => string;
|
|
1867
|
+
className?: string;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
export declare type RangeValue = [number, number];
|
|
1871
|
+
|
|
1872
|
+
export declare type RatingSize = "sm" | "md" | "lg";
|
|
1873
|
+
|
|
1874
|
+
/**
|
|
1875
|
+
* Star rating control. Renders `max` stars, fills the first `value`. Click a
|
|
1876
|
+
* star to set rating (when not readonly). Hovering previews the value.
|
|
1877
|
+
*/
|
|
1878
|
+
export declare function RatingStars({ value, max, onChange, size, readonly, disabled, label, className, }: RatingStarsProps): JSX.Element;
|
|
1879
|
+
|
|
1880
|
+
export declare interface RatingStarsProps {
|
|
1881
|
+
/** Current selected value (1..max). 0 means none. */
|
|
1882
|
+
value: number;
|
|
1883
|
+
/** Total number of stars. Default 5. */
|
|
1884
|
+
max?: number;
|
|
1885
|
+
onChange?: (value: number) => void;
|
|
1886
|
+
size?: RatingSize;
|
|
1887
|
+
readonly?: boolean;
|
|
1888
|
+
disabled?: boolean;
|
|
1889
|
+
/** Accessible label for the rating group. */
|
|
1890
|
+
label?: string;
|
|
1891
|
+
className?: string;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1665
1894
|
/** Recommended refetch intervals (milliseconds). */
|
|
1666
1895
|
export declare const REFETCH_TIME: {
|
|
1667
1896
|
readonly REALTIME: number;
|
|
@@ -1881,6 +2110,26 @@ export declare interface SkeletonProps {
|
|
|
1881
2110
|
*/
|
|
1882
2111
|
export declare function skipWaiting(worker: ServiceWorker): void;
|
|
1883
2112
|
|
|
2113
|
+
/**
|
|
2114
|
+
* Flex spacer — pushes siblings apart inside a flex container. Equivalent
|
|
2115
|
+
* to `<div style={{ flex: 1 }}>` but typed and intent-revealing.
|
|
2116
|
+
*
|
|
2117
|
+
* @example
|
|
2118
|
+
* <Stack direction="horizontal">
|
|
2119
|
+
* <Button>Cancelar</Button>
|
|
2120
|
+
* <Spacer />
|
|
2121
|
+
* <Button variant="primary">Salvar</Button>
|
|
2122
|
+
* </Stack>
|
|
2123
|
+
*/
|
|
2124
|
+
export declare function Spacer({ axis, className, ...props }: SpacerProps): JSX.Element;
|
|
2125
|
+
|
|
2126
|
+
export declare type SpacerAxis = "both" | "x" | "y";
|
|
2127
|
+
|
|
2128
|
+
export declare interface SpacerProps extends HTMLAttributes<HTMLDivElement> {
|
|
2129
|
+
/** Axis to flex along. Default `"both"` (`flex: 1`). */
|
|
2130
|
+
axis?: SpacerAxis;
|
|
2131
|
+
}
|
|
2132
|
+
|
|
1884
2133
|
/** Loading spinner with preset sizes (xs..xl). Provide `label` for screen readers. */
|
|
1885
2134
|
export declare function Spinner({ size, className, label }: SpinnerProps): JSX.Element;
|
|
1886
2135
|
|
|
@@ -2158,6 +2407,13 @@ export declare interface ToastProviderProps {
|
|
|
2158
2407
|
|
|
2159
2408
|
export declare type ToastVariant = "success" | "warning" | "error" | "info";
|
|
2160
2409
|
|
|
2410
|
+
export declare interface ToggleHelpers {
|
|
2411
|
+
toggle: () => void;
|
|
2412
|
+
setTrue: () => void;
|
|
2413
|
+
setFalse: () => void;
|
|
2414
|
+
set: (next: boolean) => void;
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2161
2417
|
/**
|
|
2162
2418
|
* Lightweight tooltip. Shows on hover and on focus (keyboard-friendly). Wraps
|
|
2163
2419
|
* a single child element via `cloneElement`, so the trigger keeps its own ref
|
|
@@ -2237,6 +2493,34 @@ export declare interface UploadWithProgressOptions {
|
|
|
2237
2493
|
*/
|
|
2238
2494
|
export declare function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer>;
|
|
2239
2495
|
|
|
2496
|
+
/**
|
|
2497
|
+
* Run an async function and track its `idle/pending/success/error` state.
|
|
2498
|
+
*
|
|
2499
|
+
* - Discards results from stale runs (race-condition safe).
|
|
2500
|
+
* - `immediate` (default `false`) triggers the function on mount and when
|
|
2501
|
+
* `deps` change. With `false`, call `run()` manually.
|
|
2502
|
+
* - Returns a stable object so callers can destructure or pass around safely.
|
|
2503
|
+
*
|
|
2504
|
+
* For server data with caching, prefer React Query — `useAsync` is the
|
|
2505
|
+
* minimal one-shot primitive without dependencies.
|
|
2506
|
+
*/
|
|
2507
|
+
export declare function useAsync<T>(asyncFn: () => Promise<T>, deps?: ReadonlyArray<unknown>, options?: {
|
|
2508
|
+
immediate?: boolean;
|
|
2509
|
+
}): UseAsyncResult<T>;
|
|
2510
|
+
|
|
2511
|
+
export declare interface UseAsyncResult<T> {
|
|
2512
|
+
status: AsyncStatus;
|
|
2513
|
+
data: T | undefined;
|
|
2514
|
+
error: unknown;
|
|
2515
|
+
isPending: boolean;
|
|
2516
|
+
isSuccess: boolean;
|
|
2517
|
+
isError: boolean;
|
|
2518
|
+
/** Trigger the async function. Resolves with the new data or rejects. */
|
|
2519
|
+
run: () => Promise<T>;
|
|
2520
|
+
/** Reset state back to idle. */
|
|
2521
|
+
reset: () => void;
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2240
2524
|
/**
|
|
2241
2525
|
* Hook-managed audio player. Each component instance gets its own
|
|
2242
2526
|
* {@link AudioPlayer}, so unmounting cleanly stops playback. Useful for
|
|
@@ -2347,6 +2631,21 @@ export declare function useDocumentVisibility(): DocumentVisibility;
|
|
|
2347
2631
|
*/
|
|
2348
2632
|
export declare function useErrorHandler(): (error: unknown) => void;
|
|
2349
2633
|
|
|
2634
|
+
/**
|
|
2635
|
+
* Subscribe to a DOM event with React-friendly semantics.
|
|
2636
|
+
*
|
|
2637
|
+
* - Handler is stored in a ref so callers can pass inline functions without
|
|
2638
|
+
* resubscribing on every render.
|
|
2639
|
+
* - `target` defaults to `window`. Accepts a raw `EventTarget` (window, document,
|
|
2640
|
+
* element) OR a ref pointing at one.
|
|
2641
|
+
* - Returns nothing — cleanup is automatic on unmount or when `eventName`/`target` change.
|
|
2642
|
+
*/
|
|
2643
|
+
export declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, target?: AnyEventTarget, options?: AddEventListenerOptions | boolean): void;
|
|
2644
|
+
|
|
2645
|
+
export declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, target?: AnyEventTarget, options?: AddEventListenerOptions | boolean): void;
|
|
2646
|
+
|
|
2647
|
+
export declare function useEventListener<K extends keyof HTMLElementEventMap>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, target?: AnyEventTarget, options?: AddEventListenerOptions | boolean): void;
|
|
2648
|
+
|
|
2350
2649
|
/**
|
|
2351
2650
|
* React hook wrapper around {@link createEventStream}. Connection lifecycle is
|
|
2352
2651
|
* tied to the component (and the `url`/`enabled` dependencies); the stream
|
|
@@ -2447,6 +2746,18 @@ export declare interface UseKeyboardShortcutOptions {
|
|
|
2447
2746
|
ignoreInput?: boolean;
|
|
2448
2747
|
}
|
|
2449
2748
|
|
|
2749
|
+
/**
|
|
2750
|
+
* State synced with `localStorage`. SSR-safe — initial render returns the
|
|
2751
|
+
* provided default; the stored value is hydrated after mount. Updates to the
|
|
2752
|
+
* same key in other tabs are picked up via the `storage` event.
|
|
2753
|
+
*
|
|
2754
|
+
* @param key - localStorage key.
|
|
2755
|
+
* @param defaultValue - value used when nothing is stored or in SSR.
|
|
2756
|
+
* @param options - custom `serialize` / `deserialize` (default JSON).
|
|
2757
|
+
* @returns Tuple `[value, setValue, remove]`.
|
|
2758
|
+
*/
|
|
2759
|
+
export declare function useLocalStorage<T>(key: string, defaultValue: T, options?: LocalStorageOptions<T>): [T, (value: T | ((prev: T) => T)) => void, () => void];
|
|
2760
|
+
|
|
2450
2761
|
/**
|
|
2451
2762
|
* Subscribe to a CSS media query and re-render on match changes.
|
|
2452
2763
|
*
|
|
@@ -2574,6 +2885,14 @@ export declare function useTheme(): ThemeContextValue;
|
|
|
2574
2885
|
*/
|
|
2575
2886
|
export declare function useToast(): ToastApi;
|
|
2576
2887
|
|
|
2888
|
+
/**
|
|
2889
|
+
* Boolean state with `toggle`/`setTrue`/`setFalse` helpers.
|
|
2890
|
+
*
|
|
2891
|
+
* @param initial - initial value (default `false`).
|
|
2892
|
+
* @returns Tuple `[value, helpers]`.
|
|
2893
|
+
*/
|
|
2894
|
+
export declare function useToggle(initial?: boolean): [boolean, ToggleHelpers];
|
|
2895
|
+
|
|
2577
2896
|
/**
|
|
2578
2897
|
* Shortcut for components that only need the `t` function — avoids destructuring.
|
|
2579
2898
|
*/
|