@kazee-ds/react 0.4.0 → 0.5.1

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.
@@ -0,0 +1,32 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type ToastEntry, type ToastManager, type ToastPlacement } from './toast-model.js';
3
+ export interface ToastProviderProps {
4
+ children?: ReactNode;
5
+ manager?: ToastManager;
6
+ placement?: ToastPlacement;
7
+ label?: string;
8
+ closeLabel?: string;
9
+ /** Modifier names followed by a key. An empty array disables the shortcut. */
10
+ hotkey?: readonly string[];
11
+ dir?: 'ltr' | 'rtl';
12
+ showProgress?: boolean;
13
+ /** Show the dismiss button. Hidden by default; timers and keyboard dismissal still work. */
14
+ showCloseButton?: boolean;
15
+ swipeThreshold?: number;
16
+ /** Customize presentation with the exported Toast component, retaining region behavior. */
17
+ renderToast?: (entry: ToastEntry) => ReactNode;
18
+ }
19
+ export declare function ToastProvider({ children, manager: suppliedManager, placement, label, closeLabel, hotkey, dir, showProgress, showCloseButton, swipeThreshold, renderToast, }: ToastProviderProps): import("react").JSX.Element;
20
+ export declare function useToast(): ToastManager;
21
+ export interface ToastProps {
22
+ entry: ToastEntry;
23
+ /** Override the provider's close button visibility for this toast. */
24
+ showCloseButton?: boolean;
25
+ /** Override the provider's progress visibility for this toast. */
26
+ showProgress?: boolean;
27
+ indicator?: ReactNode;
28
+ children?: ReactNode;
29
+ /** Additional class appended to the shared toast class. */
30
+ className?: string;
31
+ }
32
+ export declare function Toast({ entry, indicator, children, className, showCloseButton: closeOverride, showProgress: progressOverride, }: ToastProps): import("react").JSX.Element;
@@ -81,3 +81,7 @@ export type { DateRangePickerProps } from './DateRangePicker.js';
81
81
  export { createDateRangePresets } from './date-range-model.js';
82
82
  export { rangeText as formatDateRange } from './date-range-model.js';
83
83
  export type { DateRange, DateRangePreset, DateRangeLabels, DateRangeSize, DateRangeVariant, } from './date-range-model.js';
84
+ export { ToastProvider, Toast, useToast } from './Toast.js';
85
+ export type { ToastProviderProps, ToastProps } from './Toast.js';
86
+ export { createToastManager } from './toast-model.js';
87
+ export type { ToastTone, ToastPlacement, ToastCloseReason, ToastAction, ToastOptions, ToastEntry, ToastManagerOptions, ToastPromiseMessages, ToastManager, } from './toast-model.js';
@@ -0,0 +1,64 @@
1
+ export type ToastTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
2
+ export type ToastPlacement = 'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end';
3
+ export type ToastCloseReason = 'timeout' | 'dismiss' | 'action' | 'cancel' | 'swipe' | 'clear' | 'unmount';
4
+ export interface ToastAction {
5
+ label: string;
6
+ altText: string;
7
+ onAction: () => void;
8
+ dismiss?: boolean;
9
+ }
10
+ export interface ToastOptions {
11
+ id?: string;
12
+ title: string;
13
+ description?: string;
14
+ tone?: ToastTone;
15
+ duration?: number;
16
+ isLoading?: boolean;
17
+ action?: ToastAction;
18
+ cancel?: ToastAction;
19
+ onClose?: (reason: ToastCloseReason) => void;
20
+ }
21
+ export interface ToastEntry extends Readonly<ToastOptions> {
22
+ readonly id: string;
23
+ readonly tone: ToastTone;
24
+ readonly duration: number;
25
+ readonly isLoading: boolean;
26
+ readonly generation: number;
27
+ readonly state: 'open' | 'closing';
28
+ readonly createdAt: number;
29
+ readonly visibleAt: number | null;
30
+ readonly remaining: number;
31
+ readonly paused: boolean;
32
+ }
33
+ export interface ToastManagerOptions {
34
+ maxVisible?: number;
35
+ maxPending?: number;
36
+ duration?: number;
37
+ exitDuration?: number;
38
+ }
39
+ type ToastMessage = string | ToastOptions;
40
+ export interface ToastPromiseMessages<T> {
41
+ loading: ToastMessage;
42
+ success: ToastMessage | ((value: T) => ToastMessage);
43
+ error: ToastMessage | ((error: unknown) => ToastMessage);
44
+ }
45
+ export interface ToastManager {
46
+ add(options: ToastOptions): string | null;
47
+ update(id: string, options: Partial<ToastOptions>): boolean;
48
+ dismiss(id: string, reason?: ToastCloseReason): void;
49
+ clear(reason?: ToastCloseReason): void;
50
+ pause(reason: string): void;
51
+ resume(reason: string): void;
52
+ attach(): () => void;
53
+ dispose(): void;
54
+ subscribe(listener: () => void): () => void;
55
+ getSnapshot(): readonly ToastEntry[];
56
+ getServerSnapshot(): readonly ToastEntry[];
57
+ promise<T>(promise: Promise<T>, messages: ToastPromiseMessages<T>, options?: Partial<ToastOptions>): {
58
+ id: string | null;
59
+ promise: Promise<T>;
60
+ };
61
+ }
62
+ /** Create per application/provider; no browser globals or timers are used until attached. */
63
+ export declare function createToastManager(options?: ToastManagerOptions): ToastManager;
64
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kazee-ds/react",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {