tempest-react-sdk 0.4.0 → 0.5.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.
@@ -550,6 +550,16 @@ export declare interface ChipInputProps {
550
550
  className?: string;
551
551
  }
552
552
 
553
+ /**
554
+ * Clamp `value` between `min` and `max` (inclusive).
555
+ *
556
+ * @example
557
+ * clamp(120, 0, 100); // 100
558
+ * clamp(-5, 0, 100); // 0
559
+ * clamp(42, 0, 100); // 42
560
+ */
561
+ export declare function clamp(value: number, min: number, max: number): number;
562
+
553
563
  declare type ClassValue = string | number | bigint | boolean | null | undefined | ClassValue[];
554
564
 
555
565
  /**
@@ -1205,6 +1215,8 @@ export declare interface ErrorStateProps {
1205
1215
  className?: string;
1206
1216
  }
1207
1217
 
1218
+ export declare function estimatePasswordStrength(value: string): PasswordStrength;
1219
+
1208
1220
  export declare interface EventStreamController {
1209
1221
  close: () => void;
1210
1222
  /** Force an immediate reconnect, resetting the retry counter. */
@@ -2049,6 +2061,38 @@ export declare interface PaginationProps {
2049
2061
  */
2050
2062
  export declare function parseResponse<TSchema extends z.ZodTypeAny>(schema: TSchema, raw: unknown, context: string): z.infer<TSchema>;
2051
2063
 
2064
+ /**
2065
+ * Password field with toggle-visibility button and optional strength meter.
2066
+ *
2067
+ * @example
2068
+ * <PasswordInput label="Senha" showStrength autoComplete="new-password" />
2069
+ */
2070
+ export declare const PasswordInput: ForwardRefExoticComponent<PasswordInputProps & RefAttributes<HTMLInputElement>>;
2071
+
2072
+ export declare interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size"> {
2073
+ /** Label rendered above the input. */
2074
+ label?: ReactNode;
2075
+ /** Helper text below — replaced by `error` when set. */
2076
+ helperText?: ReactNode;
2077
+ /** Error message. Adds `aria-invalid` + red border. */
2078
+ error?: string;
2079
+ /** Visual size of the input. */
2080
+ size?: "sm" | "md" | "lg";
2081
+ /** Show a strength meter below the field. Default `false`. */
2082
+ showStrength?: boolean;
2083
+ /** Override the automatic strength calc (0–4). */
2084
+ strength?: PasswordStrength;
2085
+ /** Custom labels per strength level (5 entries). */
2086
+ strengthLabels?: readonly [string, string, string, string, string];
2087
+ /** Custom toggle button labels for accessibility. */
2088
+ toggleLabels?: {
2089
+ show: string;
2090
+ hide: string;
2091
+ };
2092
+ }
2093
+
2094
+ export declare type PasswordStrength = 0 | 1 | 2 | 3 | 4;
2095
+
2052
2096
  export { Path }
2053
2097
 
2054
2098
  export declare const PhoneInput: ForwardRefExoticComponent<Omit<InputProps, "value" | "onChange"> & {
@@ -2056,6 +2100,51 @@ value: string;
2056
2100
  onChange: (value: string) => void;
2057
2101
  } & RefAttributes<HTMLInputElement>>;
2058
2102
 
2103
+ /**
2104
+ * One-time-password style input — N independent cells, paste support, auto-
2105
+ * advance on input, backspace flows back, arrow keys navigate.
2106
+ *
2107
+ * @example
2108
+ * <PinInput length={6} type="numeric" onComplete={(otp) => verify(otp)} />
2109
+ */
2110
+ export declare const PinInput: ForwardRefExoticComponent<PinInputProps & RefAttributes<HTMLDivElement>>;
2111
+
2112
+ export declare interface PinInputProps {
2113
+ /** Number of cells. Default `6`. */
2114
+ length?: number;
2115
+ /** Allowed character set. `numeric` (default) rejects letters, `alphanumeric` allows both. */
2116
+ type?: PinInputType;
2117
+ /** Visual size. Default `"md"`. */
2118
+ size?: PinInputSize;
2119
+ /** Controlled value. */
2120
+ value?: string;
2121
+ /** Initial value (uncontrolled mode). */
2122
+ defaultValue?: string;
2123
+ /** Fires on every change with the current concatenated value. */
2124
+ onChange?: (value: string) => void;
2125
+ /** Fires when the user fills the last cell. */
2126
+ onComplete?: (value: string) => void;
2127
+ /** Show characters obscured (`*`). Default `false`. */
2128
+ masked?: boolean;
2129
+ /** Label rendered above the cells. */
2130
+ label?: string;
2131
+ /** Helper text below the cells. */
2132
+ helperText?: string;
2133
+ /** Error message — turns cells red and replaces helperText. */
2134
+ error?: string;
2135
+ /** Disable all cells. */
2136
+ disabled?: boolean;
2137
+ /** Auto-focus the first cell on mount. Default `false`. */
2138
+ autoFocus?: boolean;
2139
+ /** id for the wrapping group label association. */
2140
+ id?: string;
2141
+ className?: string;
2142
+ }
2143
+
2144
+ export declare type PinInputSize = "sm" | "md" | "lg";
2145
+
2146
+ export declare type PinInputType = "numeric" | "alphanumeric";
2147
+
2059
2148
  /**
2060
2149
  * Convenience wrapper around a shared {@link AudioPlayer}. Use this for
2061
2150
  * one-off notification sounds. For more complex flows (e.g. several
@@ -2296,6 +2385,21 @@ export declare interface RegisterServiceWorkerOptions {
2296
2385
  onError?: (error: unknown) => void;
2297
2386
  }
2298
2387
 
2388
+ /**
2389
+ * Render a `Date` / ISO string as a relative-time string. Supports past and
2390
+ * future, PT-BR (default) and English.
2391
+ *
2392
+ * @example
2393
+ * relativeTime(new Date(Date.now() - 90_000)); // "1 min atrás"
2394
+ * relativeTime("2026-05-17T10:00:00Z", { locale: "en" }); // "5h ago"
2395
+ */
2396
+ export declare function relativeTime(input: Date | string | number, options?: {
2397
+ locale?: RelativeTimeLocale;
2398
+ now?: Date | number;
2399
+ }): string;
2400
+
2401
+ export declare type RelativeTimeLocale = "pt-BR" | "en";
2402
+
2299
2403
  export declare interface RequestOptions extends Omit<RequestInit, "body"> {
2300
2404
  body?: unknown;
2301
2405
  params?: Record<string, string | number | boolean | undefined | null>;
@@ -2395,6 +2499,44 @@ export declare interface SearchBarProps extends Omit<InputHTMLAttributes<HTMLInp
2395
2499
  wrapperClassName?: string;
2396
2500
  }
2397
2501
 
2502
+ /**
2503
+ * iOS-style segmented control. Two-to-five mutually-exclusive options
2504
+ * rendered as a single connected pill bar.
2505
+ *
2506
+ * @example
2507
+ * <SegmentedControl
2508
+ * value={view}
2509
+ * onChange={setView}
2510
+ * options={[
2511
+ * { value: "list", label: "Lista" },
2512
+ * { value: "grid", label: "Grade" },
2513
+ * ]}
2514
+ * />
2515
+ */
2516
+ export declare function SegmentedControl<TValue extends string = string>({ options, value, onChange, size, fullWidth, className, "aria-label": ariaLabel, ...props }: SegmentedControlProps<TValue>): JSX.Element;
2517
+
2518
+ export declare interface SegmentedControlOption<TValue extends string = string> {
2519
+ value: TValue;
2520
+ label: ReactNode;
2521
+ icon?: ReactNode;
2522
+ disabled?: boolean;
2523
+ }
2524
+
2525
+ export declare interface SegmentedControlProps<TValue extends string = string> extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
2526
+ /** Available segments. */
2527
+ options: SegmentedControlOption<TValue>[];
2528
+ /** Selected value. */
2529
+ value: TValue;
2530
+ /** Fires with the new value when a segment is selected. */
2531
+ onChange: (value: TValue) => void;
2532
+ /** Visual size. Default `"md"`. */
2533
+ size?: "sm" | "md" | "lg";
2534
+ /** Stretch to full width of container. Default `false`. */
2535
+ fullWidth?: boolean;
2536
+ /** Group label for screen readers. */
2537
+ "aria-label"?: string;
2538
+ }
2539
+
2398
2540
  /**
2399
2541
  * Native `<select>` wrapper with label/helper/error slots. Either provide
2400
2542
  * `options` for a quick render, or pass `<option>` children directly.
@@ -2546,6 +2688,19 @@ export declare interface SkeletonProps {
2546
2688
  */
2547
2689
  export declare function skipWaiting(worker: ServiceWorker): void;
2548
2690
 
2691
+ /**
2692
+ * Convert a string into a URL-safe slug.
2693
+ *
2694
+ * - Strips accents/diacritics.
2695
+ * - Lowercases.
2696
+ * - Replaces non-alphanumeric runs with `-`.
2697
+ * - Trims leading/trailing separators.
2698
+ *
2699
+ * @example
2700
+ * slugify("São Paulo / Centro"); // "sao-paulo-centro"
2701
+ */
2702
+ export declare function slugify(input: string): string;
2703
+
2549
2704
  /**
2550
2705
  * Flex spacer — pushes siblings apart inside a flex container. Equivalent
2551
2706
  * to `<div style={{ flex: 1 }}>` but typed and intent-revealing.
@@ -2642,6 +2797,42 @@ export declare interface StepItem {
2642
2797
  */
2643
2798
  export declare function Stepper({ steps, current, orientation, className }: StepperProps): JSX.Element;
2644
2799
 
2800
+ /**
2801
+ * Numeric +/− stepper. Common in checkout quantity selectors and admin
2802
+ * forms. Clamps to `[min, max]` and emits already-bounded values.
2803
+ *
2804
+ * @example
2805
+ * <StepperInput value={qty} onChange={setQty} min={1} max={10} />
2806
+ */
2807
+ export declare const StepperInput: ForwardRefExoticComponent<StepperInputProps & RefAttributes<HTMLDivElement>>;
2808
+
2809
+ export declare interface StepperInputProps {
2810
+ /** Current value. */
2811
+ value: number;
2812
+ /** Fires with the new value (already clamped to min/max). */
2813
+ onChange: (value: number) => void;
2814
+ /** Lower bound. Default `0`. */
2815
+ min?: number;
2816
+ /** Upper bound. Default `Number.POSITIVE_INFINITY`. */
2817
+ max?: number;
2818
+ /** Increment per click. Default `1`. */
2819
+ step?: number;
2820
+ /** Visual size. Default `"md"`. */
2821
+ size?: "sm" | "md" | "lg";
2822
+ /** Disable the whole control. */
2823
+ disabled?: boolean;
2824
+ /** Optional label rendered above. */
2825
+ label?: ReactNode;
2826
+ /** Optional formatter for the displayed value. */
2827
+ format?: (value: number) => string;
2828
+ /** Custom button labels for accessibility. */
2829
+ labels?: {
2830
+ decrement: string;
2831
+ increment: string;
2832
+ };
2833
+ className?: string;
2834
+ }
2835
+
2645
2836
  export declare interface StepperProps {
2646
2837
  steps: StepItem[];
2647
2838
  /** Index of the currently active step (0-based). */
@@ -2863,6 +3054,43 @@ export declare interface ThemeProviderProps {
2863
3054
  attribute?: string;
2864
3055
  }
2865
3056
 
3057
+ /**
3058
+ * Vertical event timeline — activity feeds, order trackers, audit logs.
3059
+ * Each entry has a marker (color or custom icon), title, optional
3060
+ * description and right-aligned meta column.
3061
+ *
3062
+ * @example
3063
+ * <Timeline items={[
3064
+ * { id: "1", title: "Pedido criado", meta: "10:24", marker: "primary" },
3065
+ * { id: "2", title: "Aprovação", meta: "10:25", marker: "success" },
3066
+ * { id: "3", title: "Saiu pra entrega", meta: "11:00", marker: "warning" },
3067
+ * ]} />
3068
+ */
3069
+ export declare function Timeline({ items, connector, className, ...props }: TimelineProps): JSX.Element;
3070
+
3071
+ export declare interface TimelineItem {
3072
+ /** Stable identifier (used as React key). */
3073
+ id: string;
3074
+ /** Title rendered as the entry headline. */
3075
+ title: ReactNode;
3076
+ /** Optional subtitle / description below the title. */
3077
+ description?: ReactNode;
3078
+ /** Right-aligned meta column (timestamps, durations). */
3079
+ meta?: ReactNode;
3080
+ /** Optional custom icon rendered inside the marker. */
3081
+ icon?: ReactNode;
3082
+ /** Marker color. Default `"primary"`. */
3083
+ marker?: TimelineMarker;
3084
+ }
3085
+
3086
+ export declare type TimelineMarker = "primary" | "success" | "warning" | "danger" | "neutral";
3087
+
3088
+ export declare interface TimelineProps extends HTMLAttributes<HTMLOListElement> {
3089
+ items: TimelineItem[];
3090
+ /** Show the connecting line between markers. Default `true`. */
3091
+ connector?: boolean;
3092
+ }
3093
+
2866
3094
  export declare interface ToastApi {
2867
3095
  show: (options: ToastOptions) => string;
2868
3096
  dismiss: (id: string) => void;
@@ -2927,6 +3155,16 @@ export declare interface TooltipProps {
2927
3155
  openDelay?: number;
2928
3156
  }
2929
3157
 
3158
+ /**
3159
+ * Truncate a string to `max` characters, appending `suffix` when cut.
3160
+ * Returns the original when shorter than (or equal to) `max`.
3161
+ *
3162
+ * @example
3163
+ * truncate("The quick brown fox", 12); // "The quick…"
3164
+ * truncate("The quick brown fox", 12, " (more)"); // "The qu (more)"
3165
+ */
3166
+ export declare function truncate(input: string, max: number, suffix?: string): string;
3167
+
2930
3168
  /** Strip any masking and return only digits. */
2931
3169
  export declare function unmask(value: string): string;
2932
3170
 
@@ -3211,6 +3449,17 @@ export declare interface UseGeolocationOptions extends PositionOptions {
3211
3449
  disabled?: boolean;
3212
3450
  }
3213
3451
 
3452
+ /**
3453
+ * Track whether the pointer is hovering over the referenced element.
3454
+ * Returns `false` on touch-only devices (no pointer hover).
3455
+ *
3456
+ * @example
3457
+ * const ref = useRef<HTMLDivElement>(null);
3458
+ * const hovered = useHover(ref);
3459
+ * return <div ref={ref}>{hovered ? "✨" : ""}</div>;
3460
+ */
3461
+ export declare function useHover<T extends HTMLElement>(ref: RefObject<T | null>): boolean;
3462
+
3214
3463
  /**
3215
3464
  * Access translation helpers. Must be used inside an {@link I18nProvider}.
3216
3465
  */
@@ -3235,6 +3484,15 @@ export declare interface UseIntersectionObserverOptions extends IntersectionObse
3235
3484
  once?: boolean;
3236
3485
  }
3237
3486
 
3487
+ /**
3488
+ * Reactive `setInterval`. Pass `null` as `delay` to pause. `fn` is stored in
3489
+ * a ref so inline callbacks don't reset the interval on every render.
3490
+ *
3491
+ * @example
3492
+ * useInterval(() => poll(), enabled ? 5000 : null);
3493
+ */
3494
+ export declare function useInterval(fn: () => void, delay: number | null): void;
3495
+
3238
3496
  /**
3239
3497
  * Bind a global keyboard shortcut. Supports modifier combinations and a
3240
3498
  * cross-OS `mod` key (Ctrl on Windows/Linux, Cmd on macOS).
@@ -3265,6 +3523,24 @@ export declare interface UseKeyboardShortcutOptions {
3265
3523
  */
3266
3524
  export declare function useLocalStorage<T>(key: string, defaultValue: T, options?: LocalStorageOptions<T>): [T, (value: T | ((prev: T) => T)) => void, () => void];
3267
3525
 
3526
+ /**
3527
+ * Detect long-press / long-tap gestures. Fires `fn` after `delay` ms
3528
+ * while the element is held. Cancels on move beyond `moveThreshold` or
3529
+ * pointer up before `delay`.
3530
+ *
3531
+ * @example
3532
+ * const ref = useRef<HTMLDivElement>(null);
3533
+ * useLongPress(ref, () => openContextMenu(), { delay: 600 });
3534
+ */
3535
+ export declare function useLongPress<T extends HTMLElement>(ref: RefObject<T | null>, fn: () => void, options?: UseLongPressOptions): void;
3536
+
3537
+ export declare interface UseLongPressOptions {
3538
+ /** Press duration in ms. Default `500`. */
3539
+ delay?: number;
3540
+ /** Pixel threshold — finger/mouse movement beyond this cancels the press. Default `10`. */
3541
+ moveThreshold?: number;
3542
+ }
3543
+
3268
3544
  /**
3269
3545
  * Subscribe to a CSS media query and re-render on match changes.
3270
3546
  *
@@ -3371,6 +3647,19 @@ export declare interface UsePollResult<T> {
3371
3647
  start: () => void;
3372
3648
  }
3373
3649
 
3650
+ /**
3651
+ * Return the value from the previous render. `undefined` on the first render.
3652
+ *
3653
+ * @example
3654
+ * const previousCount = usePrevious(count);
3655
+ * useEffect(() => {
3656
+ * if (previousCount !== undefined && previousCount !== count) {
3657
+ * analytics.track("count.changed", { from: previousCount, to: count });
3658
+ * }
3659
+ * }, [count, previousCount]);
3660
+ */
3661
+ export declare function usePrevious<T>(value: T): T | undefined;
3662
+
3374
3663
  /**
3375
3664
  * React hook around {@link WebPushClient}. Tracks subscription, permission and
3376
3665
  * loading state; exposes imperative `subscribe`/`unsubscribe` actions.
@@ -3434,6 +3723,25 @@ export declare function useTelemetry(): TelemetryAdapter | null;
3434
3723
  */
3435
3724
  export declare function useTheme(): ThemeContextValue;
3436
3725
 
3726
+ /**
3727
+ * Return a value that updates at most once every `delay` ms. Complements
3728
+ * `useDebounce` — throttle emits on the leading edge and again after the
3729
+ * interval; debounce only emits after a period of stillness.
3730
+ *
3731
+ * @example
3732
+ * const throttledScroll = useThrottle(scrollY, 100);
3733
+ */
3734
+ export declare function useThrottle<T>(value: T, delay: number): T;
3735
+
3736
+ /**
3737
+ * Run a callback after `delay` ms. Pass `null` to disable. Resets when
3738
+ * `delay` changes; the callback ref always points at the latest closure.
3739
+ *
3740
+ * @example
3741
+ * useTimeout(() => setShow(false), show ? 3000 : null);
3742
+ */
3743
+ export declare function useTimeout(fn: () => void, delay: number | null): void;
3744
+
3437
3745
  /**
3438
3746
  * Access the toast API. Must be used inside a {@link ToastProvider}.
3439
3747
  *
@@ -3493,6 +3801,16 @@ export declare interface UseWebSocketResult<T> {
3493
3801
  reconnect: () => void;
3494
3802
  }
3495
3803
 
3804
+ /**
3805
+ * Reactive window dimensions. SSR-safe — returns `{ width: 0, height: 0 }`
3806
+ * until the first client render.
3807
+ *
3808
+ * @example
3809
+ * const { width, height } = useWindowSize();
3810
+ * const columns = width < 640 ? 1 : width < 1024 ? 2 : 3;
3811
+ */
3812
+ export declare function useWindowSize(): WindowSize;
3813
+
3496
3814
  /**
3497
3815
  * Convenience wrapper around `react-hook-form`'s `useForm` that wires a zod
3498
3816
  * resolver and infers the form's value type from the schema.
@@ -3672,6 +3990,11 @@ export declare interface WebSocketMessage<T> {
3672
3990
 
3673
3991
  export declare type WebSocketStatus = "idle" | "connecting" | "open" | "closing" | "closed" | "error";
3674
3992
 
3993
+ export declare interface WindowSize {
3994
+ width: number;
3995
+ height: number;
3996
+ }
3997
+
3675
3998
  /**
3676
3999
  * Minimal `react-hook-form` resolver built on top of zod. Mirrors the shape
3677
4000
  * produced by `@hookform/resolvers/zod` so it can be passed straight to