@hanzogui/toast 3.0.2 → 7.0.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/package.json +42 -25
- package/src/Toast.tsx +5 -5
- package/src/ToastAnnounce.tsx +2 -2
- package/src/ToastComposable.tsx +1380 -0
- package/src/ToastImpl.tsx +19 -7
- package/src/ToastItemFrame.tsx +136 -0
- package/src/ToastPortal.tsx +2 -2
- package/src/ToastProvider.tsx +13 -6
- package/src/ToastState.ts +398 -0
- package/src/ToastViewport.tsx +11 -10
- package/src/Toaster.tsx +181 -0
- package/src/createNativeToast.native.tsx +4 -0
- package/src/createNativeToast.tsx +18 -24
- package/src/dispatchNativeToast.ts +43 -0
- package/src/useAnimatedDragGesture.native.ts +255 -0
- package/src/useAnimatedDragGesture.ts +319 -0
- package/src/useReducedMotion.ts +59 -0
- package/src/useToastAnimations.ts +377 -0
- package/src/v2.ts +31 -0
- package/types/Toast.d.ts +36 -36
- package/types/ToastAnnounce.d.ts +4 -4
- package/types/ToastComposable.d.ts +199 -0
- package/types/ToastImperative.d.ts +2 -2
- package/types/ToastImpl.d.ts +12 -12
- package/types/ToastItemFrame.d.ts +25 -0
- package/types/ToastProvider.d.ts +8 -8
- package/types/ToastState.d.ts +179 -0
- package/types/ToastViewport.d.ts +12 -12
- package/types/Toaster.d.ts +112 -0
- package/types/createNativeToast.d.ts +5 -0
- package/types/createNativeToast.native.d.ts +1 -0
- package/types/dispatchNativeToast.d.ts +12 -0
- package/types/useAnimatedDragGesture.d.ts +33 -0
- package/types/useAnimatedDragGesture.native.d.ts +33 -0
- package/types/useReducedMotion.d.ts +6 -0
- package/types/useToastAnimations.d.ts +50 -0
- package/types/v2.d.ts +10 -0
- package/v2/index.cjs +2 -0
- package/v2/index.js +2 -0
- package/v2/index.native.cjs +2 -0
- package/v2/index.native.js +2 -0
- package/LICENSE +0 -21
- package/dist/cjs/Toast.cjs +0 -170
- package/dist/cjs/Toast.native.js +0 -174
- package/dist/cjs/Toast.native.js.map +0 -1
- package/dist/cjs/ToastAnnounce.cjs +0 -97
- package/dist/cjs/ToastAnnounce.native.js +0 -105
- package/dist/cjs/ToastAnnounce.native.js.map +0 -1
- package/dist/cjs/ToastImperative.cjs +0 -100
- package/dist/cjs/ToastImperative.native.js +0 -122
- package/dist/cjs/ToastImperative.native.js.map +0 -1
- package/dist/cjs/ToastImpl.cjs +0 -292
- package/dist/cjs/ToastImpl.native.js +0 -326
- package/dist/cjs/ToastImpl.native.js.map +0 -1
- package/dist/cjs/ToastPortal.cjs +0 -44
- package/dist/cjs/ToastPortal.native.js +0 -47
- package/dist/cjs/ToastPortal.native.js.map +0 -1
- package/dist/cjs/ToastProvider.cjs +0 -146
- package/dist/cjs/ToastProvider.native.js +0 -159
- package/dist/cjs/ToastProvider.native.js.map +0 -1
- package/dist/cjs/ToastViewport.cjs +0 -278
- package/dist/cjs/ToastViewport.native.js +0 -315
- package/dist/cjs/ToastViewport.native.js.map +0 -1
- package/dist/cjs/constants.cjs +0 -28
- package/dist/cjs/constants.native.js +0 -31
- package/dist/cjs/constants.native.js.map +0 -1
- package/dist/cjs/createNativeToast.cjs +0 -51
- package/dist/cjs/createNativeToast.native.js +0 -48
- package/dist/cjs/createNativeToast.native.js.map +0 -1
- package/dist/cjs/index.cjs +0 -18
- package/dist/cjs/index.native.js +0 -21
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/cjs/types.cjs +0 -16
- package/dist/cjs/types.native.js +0 -19
- package/dist/cjs/types.native.js.map +0 -1
- package/dist/esm/Toast.mjs +0 -131
- package/dist/esm/Toast.mjs.map +0 -1
- package/dist/esm/Toast.native.js +0 -132
- package/dist/esm/Toast.native.js.map +0 -1
- package/dist/esm/ToastAnnounce.mjs +0 -62
- package/dist/esm/ToastAnnounce.mjs.map +0 -1
- package/dist/esm/ToastAnnounce.native.js +0 -67
- package/dist/esm/ToastAnnounce.native.js.map +0 -1
- package/dist/esm/ToastImperative.mjs +0 -63
- package/dist/esm/ToastImperative.mjs.map +0 -1
- package/dist/esm/ToastImperative.native.js +0 -82
- package/dist/esm/ToastImperative.native.js.map +0 -1
- package/dist/esm/ToastImpl.mjs +0 -256
- package/dist/esm/ToastImpl.mjs.map +0 -1
- package/dist/esm/ToastImpl.native.js +0 -287
- package/dist/esm/ToastImpl.native.js.map +0 -1
- package/dist/esm/ToastPortal.mjs +0 -21
- package/dist/esm/ToastPortal.mjs.map +0 -1
- package/dist/esm/ToastPortal.native.js +0 -21
- package/dist/esm/ToastPortal.native.js.map +0 -1
- package/dist/esm/ToastProvider.mjs +0 -108
- package/dist/esm/ToastProvider.mjs.map +0 -1
- package/dist/esm/ToastProvider.native.js +0 -118
- package/dist/esm/ToastProvider.native.js.map +0 -1
- package/dist/esm/ToastViewport.mjs +0 -241
- package/dist/esm/ToastViewport.mjs.map +0 -1
- package/dist/esm/ToastViewport.native.js +0 -275
- package/dist/esm/ToastViewport.native.js.map +0 -1
- package/dist/esm/constants.mjs +0 -4
- package/dist/esm/constants.mjs.map +0 -1
- package/dist/esm/constants.native.js +0 -4
- package/dist/esm/constants.native.js.map +0 -1
- package/dist/esm/createNativeToast.mjs +0 -27
- package/dist/esm/createNativeToast.mjs.map +0 -1
- package/dist/esm/createNativeToast.native.js +0 -21
- package/dist/esm/createNativeToast.native.js.map +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs +0 -2
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -2
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js +0 -2
- package/dist/esm/types.native.js.map +0 -1
- package/dist/jsx/Toast.mjs +0 -131
- package/dist/jsx/Toast.mjs.map +0 -1
- package/dist/jsx/Toast.native.js +0 -174
- package/dist/jsx/Toast.native.js.map +0 -1
- package/dist/jsx/ToastAnnounce.mjs +0 -62
- package/dist/jsx/ToastAnnounce.mjs.map +0 -1
- package/dist/jsx/ToastAnnounce.native.js +0 -105
- package/dist/jsx/ToastAnnounce.native.js.map +0 -1
- package/dist/jsx/ToastImperative.mjs +0 -63
- package/dist/jsx/ToastImperative.mjs.map +0 -1
- package/dist/jsx/ToastImperative.native.js +0 -122
- package/dist/jsx/ToastImperative.native.js.map +0 -1
- package/dist/jsx/ToastImpl.mjs +0 -256
- package/dist/jsx/ToastImpl.mjs.map +0 -1
- package/dist/jsx/ToastImpl.native.js +0 -326
- package/dist/jsx/ToastImpl.native.js.map +0 -1
- package/dist/jsx/ToastPortal.mjs +0 -21
- package/dist/jsx/ToastPortal.mjs.map +0 -1
- package/dist/jsx/ToastPortal.native.js +0 -47
- package/dist/jsx/ToastPortal.native.js.map +0 -1
- package/dist/jsx/ToastProvider.mjs +0 -108
- package/dist/jsx/ToastProvider.mjs.map +0 -1
- package/dist/jsx/ToastProvider.native.js +0 -159
- package/dist/jsx/ToastProvider.native.js.map +0 -1
- package/dist/jsx/ToastViewport.mjs +0 -241
- package/dist/jsx/ToastViewport.mjs.map +0 -1
- package/dist/jsx/ToastViewport.native.js +0 -315
- package/dist/jsx/ToastViewport.native.js.map +0 -1
- package/dist/jsx/constants.mjs +0 -4
- package/dist/jsx/constants.mjs.map +0 -1
- package/dist/jsx/constants.native.js +0 -31
- package/dist/jsx/constants.native.js.map +0 -1
- package/dist/jsx/createNativeToast.mjs +0 -27
- package/dist/jsx/createNativeToast.mjs.map +0 -1
- package/dist/jsx/createNativeToast.native.js +0 -48
- package/dist/jsx/createNativeToast.native.js.map +0 -1
- package/dist/jsx/index.js +0 -2
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs +0 -2
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/index.native.js +0 -21
- package/dist/jsx/index.native.js.map +0 -1
- package/dist/jsx/types.mjs +0 -2
- package/dist/jsx/types.mjs.map +0 -1
- package/dist/jsx/types.native.js +0 -19
- package/dist/jsx/types.native.js.map +0 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { GetProps, HanzoguiElement } from '@hanzogui/core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { SwipeDirection } from './ToastProvider';
|
|
4
|
+
import type { ExternalToast, ToastT } from './ToastState';
|
|
5
|
+
import type { BurntToastOptions } from './types';
|
|
6
|
+
import { ToastItemFrame } from './ToastItemFrame';
|
|
7
|
+
export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
8
|
+
interface ToastItemContextValue {
|
|
9
|
+
toast: ToastT;
|
|
10
|
+
handleClose: () => void;
|
|
11
|
+
}
|
|
12
|
+
export interface ToastIcons {
|
|
13
|
+
success?: React.ReactNode;
|
|
14
|
+
error?: React.ReactNode;
|
|
15
|
+
warning?: React.ReactNode;
|
|
16
|
+
info?: React.ReactNode;
|
|
17
|
+
loading?: React.ReactNode;
|
|
18
|
+
close?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export interface ToastRootProps {
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Position of the toasts on screen
|
|
24
|
+
* @default 'bottom-right'
|
|
25
|
+
*/
|
|
26
|
+
position?: ToastPosition;
|
|
27
|
+
/**
|
|
28
|
+
* Default duration for toasts in ms
|
|
29
|
+
* @default 4000
|
|
30
|
+
*/
|
|
31
|
+
duration?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Gap between toasts in pixels
|
|
34
|
+
* @default 14
|
|
35
|
+
*/
|
|
36
|
+
gap?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Number of toasts visible at once
|
|
39
|
+
* @default 4
|
|
40
|
+
*/
|
|
41
|
+
visibleToasts?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Direction toasts can be swiped to dismiss
|
|
44
|
+
* @default 'auto'
|
|
45
|
+
*/
|
|
46
|
+
swipeDirection?: SwipeDirection;
|
|
47
|
+
/**
|
|
48
|
+
* Distance in pixels swipe must pass to dismiss
|
|
49
|
+
* @default 50
|
|
50
|
+
*/
|
|
51
|
+
swipeThreshold?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Fixed toast height in pixels for native stacking calculations.
|
|
54
|
+
* On web, heights are measured dynamically.
|
|
55
|
+
* @default 56
|
|
56
|
+
*/
|
|
57
|
+
toastHeight?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Show close button on toasts
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
closeButton?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* When true, toasts are always expanded (fanned out) instead of stacked.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
expand?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Theme for toasts
|
|
70
|
+
*/
|
|
71
|
+
theme?: 'light' | 'dark' | 'system';
|
|
72
|
+
/**
|
|
73
|
+
* Force reduced motion mode
|
|
74
|
+
*/
|
|
75
|
+
reducedMotion?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* When true, uses burnt native OS toasts on mobile instead of RN views.
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
80
|
+
native?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Options for burnt native toasts on mobile
|
|
83
|
+
*/
|
|
84
|
+
burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>;
|
|
85
|
+
/**
|
|
86
|
+
* Options for web Notification API when native is true on web
|
|
87
|
+
*/
|
|
88
|
+
notificationOptions?: NotificationOptions;
|
|
89
|
+
/**
|
|
90
|
+
* Custom icons for toast types
|
|
91
|
+
*/
|
|
92
|
+
icons?: ToastIcons;
|
|
93
|
+
}
|
|
94
|
+
declare const ToastViewportFrame: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").TamaDefer, HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
95
|
+
unstyled?: boolean | undefined;
|
|
96
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
97
|
+
export interface ToastViewportProps extends GetProps<typeof ToastViewportFrame> {
|
|
98
|
+
/**
|
|
99
|
+
* Offset from screen edge
|
|
100
|
+
* @default 24
|
|
101
|
+
*/
|
|
102
|
+
offset?: number | {
|
|
103
|
+
top?: number;
|
|
104
|
+
right?: number;
|
|
105
|
+
bottom?: number;
|
|
106
|
+
left?: number;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Hotkey to focus viewport
|
|
110
|
+
*/
|
|
111
|
+
hotkey?: string[];
|
|
112
|
+
/**
|
|
113
|
+
* Aria label
|
|
114
|
+
* @default 'Notifications'
|
|
115
|
+
*/
|
|
116
|
+
label?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Portal to root
|
|
119
|
+
* @default true
|
|
120
|
+
*/
|
|
121
|
+
portalToRoot?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* z-index for the portal container when portalToRoot is true
|
|
124
|
+
* @default Number.MAX_SAFE_INTEGER
|
|
125
|
+
*/
|
|
126
|
+
portalZIndex?: number;
|
|
127
|
+
}
|
|
128
|
+
export interface ToastItemRenderProps {
|
|
129
|
+
toast: ToastT;
|
|
130
|
+
index: number;
|
|
131
|
+
handleClose: () => void;
|
|
132
|
+
}
|
|
133
|
+
export interface ToastListProps {
|
|
134
|
+
/**
|
|
135
|
+
* Custom render function for each toast item
|
|
136
|
+
*/
|
|
137
|
+
renderItem?: (props: ToastItemRenderProps) => React.ReactNode;
|
|
138
|
+
}
|
|
139
|
+
declare function ToastList({ renderItem }: ToastListProps): import("react/jsx-runtime").JSX.Element;
|
|
140
|
+
export interface ToastItemProps extends GetProps<typeof ToastItemFrame> {
|
|
141
|
+
toast: ToastT;
|
|
142
|
+
index: number;
|
|
143
|
+
children: React.ReactNode;
|
|
144
|
+
}
|
|
145
|
+
declare function ToastIcon(props: {
|
|
146
|
+
children?: React.ReactNode;
|
|
147
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
148
|
+
export declare function useToasts(): {
|
|
149
|
+
toasts: ToastT[];
|
|
150
|
+
expanded: boolean;
|
|
151
|
+
position: ToastPosition;
|
|
152
|
+
};
|
|
153
|
+
export declare function useToastItem(): ToastItemContextValue;
|
|
154
|
+
export declare const Toast: React.ForwardRefExoticComponent<ToastRootProps & React.RefAttributes<HanzoguiElement>> & {
|
|
155
|
+
Viewport: import("@hanzogui/core").HanzoguiComponent<Omit<import("@hanzogui/core").GetFinalProps<import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
156
|
+
unstyled?: boolean | undefined;
|
|
157
|
+
}>, keyof ToastViewportProps> & ToastViewportProps, HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps & ToastViewportProps, import("@hanzogui/core").StackStyleBase, {
|
|
158
|
+
unstyled?: boolean | undefined;
|
|
159
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
160
|
+
List: typeof ToastList;
|
|
161
|
+
Item: import("@hanzogui/core").HanzoguiComponent<Omit<import("@hanzogui/core").GetFinalProps<import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
162
|
+
unstyled?: boolean | undefined;
|
|
163
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
164
|
+
fullscreen?: boolean | undefined;
|
|
165
|
+
}>, keyof ToastItemProps> & ToastItemProps, HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps & ToastItemProps, import("@hanzogui/core").StackStyleBase, {
|
|
166
|
+
unstyled?: boolean | undefined;
|
|
167
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
168
|
+
fullscreen?: boolean | undefined;
|
|
169
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
170
|
+
Title: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").TamaDefer, import("@hanzogui/core").HanzoguiTextElement, import("@hanzogui/core").TextNonStyleProps, import("@hanzogui/core").TextStylePropsBase, {
|
|
171
|
+
unstyled?: boolean | undefined;
|
|
172
|
+
size?: import("@hanzogui/core").FontSizeTokens | undefined;
|
|
173
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
174
|
+
Description: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").TamaDefer, import("@hanzogui/core").HanzoguiTextElement, import("@hanzogui/core").TextNonStyleProps, import("@hanzogui/core").TextStylePropsBase, {
|
|
175
|
+
unstyled?: boolean | undefined;
|
|
176
|
+
size?: import("@hanzogui/core").FontSizeTokens | undefined;
|
|
177
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
178
|
+
Close: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").GetFinalProps<import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
179
|
+
unstyled?: boolean | undefined;
|
|
180
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
181
|
+
fullscreen?: boolean | undefined;
|
|
182
|
+
}>, HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps & void, import("@hanzogui/core").StackStyleBase, {
|
|
183
|
+
unstyled?: boolean | undefined;
|
|
184
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
185
|
+
fullscreen?: boolean | undefined;
|
|
186
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
187
|
+
Action: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").GetFinalProps<import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
188
|
+
unstyled?: boolean | undefined;
|
|
189
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
190
|
+
fullscreen?: boolean | undefined;
|
|
191
|
+
}>, HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps & void, import("@hanzogui/core").StackStyleBase, {
|
|
192
|
+
unstyled?: boolean | undefined;
|
|
193
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
194
|
+
fullscreen?: boolean | undefined;
|
|
195
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
196
|
+
Icon: typeof ToastIcon;
|
|
197
|
+
};
|
|
198
|
+
export type { ToastT, ExternalToast };
|
|
199
|
+
//# sourceMappingURL=ToastComposable.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NativePlatform, NativeValue } from '@
|
|
1
|
+
import type { NativePlatform, NativeValue } from '@hanzogui/core';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { CreateNativeToastOptions, NativeToastRef } from './types';
|
|
4
4
|
export interface ToastImperativeOptions extends Omit<CreateNativeToastOptions, 'message'> {
|
|
@@ -12,7 +12,7 @@ export interface ToastImperativeOptions extends Omit<CreateNativeToastOptions, '
|
|
|
12
12
|
*
|
|
13
13
|
* e.g.
|
|
14
14
|
* ```ts
|
|
15
|
-
* declare module '@
|
|
15
|
+
* declare module '@hanzogui/toast' {
|
|
16
16
|
* interface CustomData {
|
|
17
17
|
* preset: 'error' | 'success'
|
|
18
18
|
* isUrgent: true
|
package/types/ToastImpl.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { GetProps,
|
|
2
|
-
import type { DismissableProps } from '@
|
|
1
|
+
import type { GetProps, HanzoguiElement } from '@hanzogui/core';
|
|
2
|
+
import type { DismissableProps } from '@hanzogui/dismissable';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import type { GestureResponderEvent } from 'react-native';
|
|
5
5
|
import type { ScopedProps } from './ToastProvider';
|
|
6
|
-
declare const ToastImplFrame: import("@
|
|
6
|
+
declare const ToastImplFrame: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").TamaDefer, HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
7
7
|
unstyled?: boolean | undefined;
|
|
8
|
-
elevation?: number | import("@
|
|
8
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
9
9
|
fullscreen?: boolean | undefined;
|
|
10
|
-
}, import("@
|
|
10
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
11
11
|
type ToastProps = Omit<ToastImplProps, keyof ToastImplPrivateProps>;
|
|
12
12
|
type SwipeEvent = GestureResponderEvent;
|
|
13
13
|
declare const useToastInteractiveContext: (scope?: string) => {
|
|
@@ -89,21 +89,21 @@ export type ToastExtraProps = {
|
|
|
89
89
|
id?: string;
|
|
90
90
|
};
|
|
91
91
|
type ToastImplProps = ScopedProps<ToastImplPrivateProps & ToastImplFrameProps & ToastExtraProps>;
|
|
92
|
-
declare const ToastImpl: React.ForwardRefExoticComponent<Omit<ToastImplPrivateProps & Omit<import("@
|
|
92
|
+
declare const ToastImpl: React.ForwardRefExoticComponent<Omit<ToastImplPrivateProps & Omit<import("@hanzogui/core").RNHanzoguiViewNonStyleProps, "unstyled" | "elevation" | keyof import("@hanzogui/core").StackStyleBase | "fullscreen"> & import("@hanzogui/core").WithThemeValues<import("@hanzogui/core").StackStyleBase> & {
|
|
93
93
|
unstyled?: boolean | undefined;
|
|
94
|
-
elevation?: number | import("@
|
|
94
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
95
95
|
fullscreen?: boolean | undefined;
|
|
96
|
-
} & import("@
|
|
96
|
+
} & import("@hanzogui/core").WithShorthands<import("@hanzogui/core").WithThemeValues<import("@hanzogui/core").StackStyleBase>> & import("@hanzogui/core").WithPseudoProps<import("@hanzogui/core").WithThemeValues<import("@hanzogui/core").StackStyleBase> & {
|
|
97
97
|
unstyled?: boolean | undefined;
|
|
98
|
-
elevation?: number | import("@
|
|
98
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
99
99
|
fullscreen?: boolean | undefined;
|
|
100
|
-
} & import("@
|
|
100
|
+
} & import("@hanzogui/core").WithShorthands<import("@hanzogui/core").WithThemeValues<import("@hanzogui/core").StackStyleBase>>> & import("@hanzogui/core").WithMediaProps<import("@hanzogui/core").WithThemeShorthandsAndPseudos<import("@hanzogui/core").StackStyleBase, {
|
|
101
101
|
unstyled?: boolean | undefined;
|
|
102
|
-
elevation?: number | import("@
|
|
102
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
103
103
|
fullscreen?: boolean | undefined;
|
|
104
104
|
}>> & ToastExtraProps, "scope"> & {
|
|
105
105
|
scope?: import("./ToastProvider").ToastScopes;
|
|
106
|
-
} & React.RefAttributes<
|
|
106
|
+
} & React.RefAttributes<HanzoguiElement>>;
|
|
107
107
|
export { ToastImpl, ToastImplFrame, useToastInteractiveContext, type ToastImplProps };
|
|
108
108
|
export type { ToastProps };
|
|
109
109
|
//# sourceMappingURL=ToastImpl.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared visual styled components for toast items.
|
|
3
|
+
* Shared across web and native — imported by ToastComposable.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ToastPositionWrapper: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").TamaDefer, import("@hanzogui/core").HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
6
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
7
|
+
fullscreen?: boolean | undefined;
|
|
8
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
9
|
+
export declare const ToastItemFrame: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").TamaDefer, import("@hanzogui/core").HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
10
|
+
unstyled?: boolean | undefined;
|
|
11
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
12
|
+
fullscreen?: boolean | undefined;
|
|
13
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
14
|
+
export declare const ToastCloseFrame: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").TamaDefer, import("@hanzogui/core").HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
15
|
+
unstyled?: boolean | undefined;
|
|
16
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
17
|
+
fullscreen?: boolean | undefined;
|
|
18
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
19
|
+
export declare const ToastActionFrame: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").TamaDefer, import("@hanzogui/core").HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
20
|
+
unstyled?: boolean | undefined;
|
|
21
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
22
|
+
fullscreen?: boolean | undefined;
|
|
23
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
24
|
+
export declare const DefaultCloseIcon: () => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=ToastItemFrame.d.ts.map
|
package/types/ToastProvider.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NativeValue,
|
|
1
|
+
import type { NativeValue, HanzoguiElement } from '@hanzogui/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { ToastImperativeOptions } from './ToastImperative';
|
|
4
4
|
import type { BurntToastOptions } from './types';
|
|
@@ -8,18 +8,18 @@ declare const Collection: {
|
|
|
8
8
|
} & {
|
|
9
9
|
scope?: any;
|
|
10
10
|
}>;
|
|
11
|
-
readonly Slot: React.ForwardRefExoticComponent<import("@
|
|
11
|
+
readonly Slot: React.ForwardRefExoticComponent<import("@hanzogui/collection").CollectionProps & {
|
|
12
12
|
scope?: any;
|
|
13
|
-
} & React.RefAttributes<
|
|
13
|
+
} & React.RefAttributes<HanzoguiElement | undefined>>;
|
|
14
14
|
readonly ItemSlot: React.ForwardRefExoticComponent<{
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
} & {
|
|
17
17
|
scope?: any;
|
|
18
|
-
} & React.RefAttributes<
|
|
18
|
+
} & React.RefAttributes<HanzoguiElement | undefined>>;
|
|
19
19
|
}, useCollection: (scope: string) => () => {
|
|
20
|
-
ref: React.RefObject<
|
|
20
|
+
ref: React.RefObject<HanzoguiElement | undefined>;
|
|
21
21
|
}[];
|
|
22
|
-
export type SwipeDirection = 'vertical' | 'up' | 'down' | 'horizontal' | 'left' | 'right';
|
|
22
|
+
export type SwipeDirection = 'vertical' | 'up' | 'down' | 'horizontal' | 'left' | 'right' | 'auto';
|
|
23
23
|
export type ToastProviderContextValue = {
|
|
24
24
|
id: string;
|
|
25
25
|
toastScope: string;
|
|
@@ -28,8 +28,8 @@ export type ToastProviderContextValue = {
|
|
|
28
28
|
swipeDirection: SwipeDirection;
|
|
29
29
|
swipeThreshold: number;
|
|
30
30
|
toastCount: number;
|
|
31
|
-
viewports: Record<string,
|
|
32
|
-
onViewportChange(name: string, viewport:
|
|
31
|
+
viewports: Record<string, HanzoguiElement | null>;
|
|
32
|
+
onViewportChange(name: string, viewport: HanzoguiElement): void;
|
|
33
33
|
onToastAdd(): void;
|
|
34
34
|
onToastRemove(): void;
|
|
35
35
|
isFocusedToastEscapeKeyDownRef: React.MutableRefObject<boolean>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { CreateNativeToastOptions, NativeToastRef } from './types';
|
|
3
|
+
export type ToastType = 'default' | 'success' | 'error' | 'warning' | 'info' | 'loading';
|
|
4
|
+
export interface ToastT {
|
|
5
|
+
id: string | number;
|
|
6
|
+
title: React.ReactNode | (() => React.ReactNode);
|
|
7
|
+
description?: React.ReactNode | (() => React.ReactNode);
|
|
8
|
+
type?: ToastType;
|
|
9
|
+
icon?: React.ReactNode;
|
|
10
|
+
jsx?: React.ReactElement;
|
|
11
|
+
dismissible?: boolean;
|
|
12
|
+
duration?: number;
|
|
13
|
+
promise?: PromiseT;
|
|
14
|
+
action?: ToastAction;
|
|
15
|
+
cancel?: ToastAction;
|
|
16
|
+
closeButton?: boolean;
|
|
17
|
+
onDismiss?: (toast: ToastT) => void;
|
|
18
|
+
onAutoClose?: (toast: ToastT) => void;
|
|
19
|
+
delete?: boolean;
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
className?: string;
|
|
22
|
+
burntOptions?: CreateNativeToastOptions['burntOptions'];
|
|
23
|
+
notificationOptions?: CreateNativeToastOptions['notificationOptions'];
|
|
24
|
+
/** Custom user data */
|
|
25
|
+
data?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface ToastAction {
|
|
28
|
+
label: string;
|
|
29
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
30
|
+
}
|
|
31
|
+
export interface ToastToDismiss {
|
|
32
|
+
id: string | number;
|
|
33
|
+
dismiss: true;
|
|
34
|
+
}
|
|
35
|
+
export type ExternalToast = Omit<ToastT, 'id' | 'title' | 'type' | 'delete' | 'promise'> & {
|
|
36
|
+
id?: string | number;
|
|
37
|
+
};
|
|
38
|
+
export type PromiseT<Data = any> = Promise<Data> | (() => Promise<Data>);
|
|
39
|
+
export interface PromiseData<Data = any> {
|
|
40
|
+
loading?: React.ReactNode | (() => React.ReactNode);
|
|
41
|
+
success?: React.ReactNode | ((data: Data) => React.ReactNode);
|
|
42
|
+
error?: React.ReactNode | ((error: any) => React.ReactNode);
|
|
43
|
+
description?: React.ReactNode | ((data: any) => React.ReactNode);
|
|
44
|
+
finally?: () => void;
|
|
45
|
+
}
|
|
46
|
+
type TitleT = React.ReactNode | (() => React.ReactNode);
|
|
47
|
+
/**
|
|
48
|
+
* Observer class that manages toast state globally.
|
|
49
|
+
* Follows the pattern from Sonner for a clean, decoupled architecture.
|
|
50
|
+
*/
|
|
51
|
+
declare class Observer {
|
|
52
|
+
subscribers: Array<(toast: ToastT | ToastToDismiss) => void>;
|
|
53
|
+
toasts: ToastT[];
|
|
54
|
+
dismissedToasts: Set<string | number>;
|
|
55
|
+
/**
|
|
56
|
+
* Subscribe to toast state changes.
|
|
57
|
+
* Returns an unsubscribe function.
|
|
58
|
+
*/
|
|
59
|
+
subscribe: (subscriber: (toast: ToastT | ToastToDismiss) => void) => () => void;
|
|
60
|
+
/**
|
|
61
|
+
* Publish a toast to all subscribers
|
|
62
|
+
*/
|
|
63
|
+
publish: (data: ToastT) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Add a new toast to the internal array and publish to subscribers
|
|
66
|
+
*/
|
|
67
|
+
addToast: (data: ToastT) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Create or update a toast
|
|
70
|
+
*/
|
|
71
|
+
create: (data: ExternalToast & {
|
|
72
|
+
title?: TitleT;
|
|
73
|
+
type?: ToastType;
|
|
74
|
+
promise?: PromiseT;
|
|
75
|
+
jsx?: React.ReactElement;
|
|
76
|
+
}) => string | number;
|
|
77
|
+
/**
|
|
78
|
+
* Dismiss a toast by id, or all toasts if no id provided
|
|
79
|
+
*/
|
|
80
|
+
dismiss: (id?: string | number) => string | number | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Show a basic toast message
|
|
83
|
+
*/
|
|
84
|
+
message: (title: TitleT, data?: ExternalToast) => string | number;
|
|
85
|
+
/**
|
|
86
|
+
* Show a success toast
|
|
87
|
+
*/
|
|
88
|
+
success: (title: TitleT, data?: ExternalToast) => string | number;
|
|
89
|
+
/**
|
|
90
|
+
* Show an error toast
|
|
91
|
+
*/
|
|
92
|
+
error: (title: TitleT, data?: ExternalToast) => string | number;
|
|
93
|
+
/**
|
|
94
|
+
* Show a warning toast
|
|
95
|
+
*/
|
|
96
|
+
warning: (title: TitleT, data?: ExternalToast) => string | number;
|
|
97
|
+
/**
|
|
98
|
+
* Show an info toast
|
|
99
|
+
*/
|
|
100
|
+
info: (title: TitleT, data?: ExternalToast) => string | number;
|
|
101
|
+
/**
|
|
102
|
+
* Show a loading toast
|
|
103
|
+
*/
|
|
104
|
+
loading: (title: TitleT, data?: ExternalToast) => string | number;
|
|
105
|
+
/**
|
|
106
|
+
* Show a toast for a promise, automatically transitioning through
|
|
107
|
+
* loading -> success/error states
|
|
108
|
+
*/
|
|
109
|
+
promise: <ToastData>(promise: PromiseT<ToastData>, data?: PromiseData<ToastData>) => (string & {
|
|
110
|
+
unwrap: () => Promise<ToastData>;
|
|
111
|
+
}) | (number & {
|
|
112
|
+
unwrap: () => Promise<ToastData>;
|
|
113
|
+
}) | {
|
|
114
|
+
unwrap: () => Promise<ToastData>;
|
|
115
|
+
} | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Show a custom JSX toast
|
|
118
|
+
*/
|
|
119
|
+
custom: (jsx: (id: string | number) => React.ReactElement, data?: ExternalToast) => string | number;
|
|
120
|
+
/**
|
|
121
|
+
* Get all active (non-dismissed) toasts
|
|
122
|
+
*/
|
|
123
|
+
getActiveToasts: () => ToastT[];
|
|
124
|
+
/**
|
|
125
|
+
* Get full toast history
|
|
126
|
+
*/
|
|
127
|
+
getHistory: () => ToastT[];
|
|
128
|
+
}
|
|
129
|
+
export declare const ToastState: Observer;
|
|
130
|
+
/**
|
|
131
|
+
* Main toast API - call directly or use methods like toast.success()
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* // basic usage
|
|
135
|
+
* toast('Hello world')
|
|
136
|
+
*
|
|
137
|
+
* // with type
|
|
138
|
+
* toast.success('Saved!')
|
|
139
|
+
* toast.error('Something went wrong')
|
|
140
|
+
*
|
|
141
|
+
* // with options
|
|
142
|
+
* toast('Hello', { duration: 5000 })
|
|
143
|
+
*
|
|
144
|
+
* // promise toast
|
|
145
|
+
* toast.promise(fetch('/api'), {
|
|
146
|
+
* loading: 'Loading...',
|
|
147
|
+
* success: 'Done!',
|
|
148
|
+
* error: 'Failed'
|
|
149
|
+
* })
|
|
150
|
+
*
|
|
151
|
+
* // custom JSX
|
|
152
|
+
* toast.custom((id) => <MyToast id={id} />)
|
|
153
|
+
*
|
|
154
|
+
* // dismiss
|
|
155
|
+
* const id = toast('Hello')
|
|
156
|
+
* toast.dismiss(id)
|
|
157
|
+
* toast.dismiss() // dismiss all
|
|
158
|
+
*/
|
|
159
|
+
export declare const toast: ((title: TitleT, data?: ExternalToast) => string | number) & {
|
|
160
|
+
success: (title: TitleT, data?: ExternalToast) => string | number;
|
|
161
|
+
error: (title: TitleT, data?: ExternalToast) => string | number;
|
|
162
|
+
warning: (title: TitleT, data?: ExternalToast) => string | number;
|
|
163
|
+
info: (title: TitleT, data?: ExternalToast) => string | number;
|
|
164
|
+
loading: (title: TitleT, data?: ExternalToast) => string | number;
|
|
165
|
+
promise: <ToastData>(promise: PromiseT<ToastData>, data?: PromiseData<ToastData> | undefined) => (string & {
|
|
166
|
+
unwrap: () => Promise<ToastData>;
|
|
167
|
+
}) | (number & {
|
|
168
|
+
unwrap: () => Promise<ToastData>;
|
|
169
|
+
}) | {
|
|
170
|
+
unwrap: () => Promise<ToastData>;
|
|
171
|
+
} | undefined;
|
|
172
|
+
custom: (jsx: (id: string | number) => React.ReactElement, data?: ExternalToast) => string | number;
|
|
173
|
+
dismiss: (id?: string | number) => string | number | undefined;
|
|
174
|
+
message: (title: TitleT, data?: ExternalToast) => string | number;
|
|
175
|
+
getHistory: () => ToastT[];
|
|
176
|
+
getToasts: () => ToastT[];
|
|
177
|
+
};
|
|
178
|
+
export type { NativeToastRef };
|
|
179
|
+
//# sourceMappingURL=ToastState.d.ts.map
|
package/types/ToastViewport.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { GetProps,
|
|
1
|
+
import type { GetProps, HanzoguiElement } from '@hanzogui/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
declare const VIEWPORT_DEFAULT_HOTKEY: string[];
|
|
4
4
|
declare const VIEWPORT_PAUSE = "toast.viewportPause";
|
|
5
5
|
declare const VIEWPORT_RESUME = "toast.viewportResume";
|
|
6
|
-
declare const ToastViewportFrame: import("@
|
|
6
|
+
declare const ToastViewportFrame: import("@hanzogui/core").HanzoguiComponent<import("@hanzogui/core").TamaDefer, HanzoguiElement, import("@hanzogui/core").RNHanzoguiViewNonStyleProps, import("@hanzogui/core").StackStyleBase, {
|
|
7
7
|
unstyled?: boolean | undefined;
|
|
8
|
-
elevation?: number | import("@
|
|
8
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
9
9
|
fullscreen?: boolean | undefined;
|
|
10
|
-
}, import("@
|
|
10
|
+
}, import("@hanzogui/core").StaticConfigPublic>;
|
|
11
11
|
type ToastViewportFrameProps = GetProps<typeof ToastViewportFrame>;
|
|
12
12
|
type ToastViewportProps = ToastViewportFrameProps & {
|
|
13
13
|
/**
|
|
@@ -30,21 +30,21 @@ type ToastViewportProps = ToastViewportFrameProps & {
|
|
|
30
30
|
*/
|
|
31
31
|
multipleToasts?: boolean;
|
|
32
32
|
/**
|
|
33
|
-
* When true, uses a portal to render at the very top of the root
|
|
33
|
+
* When true, uses a portal to render at the very top of the root HanzoguiProvider.
|
|
34
34
|
*/
|
|
35
35
|
portalToRoot?: boolean;
|
|
36
36
|
};
|
|
37
|
-
declare const ToastViewport: React.NamedExoticComponent<Omit<import("@
|
|
37
|
+
declare const ToastViewport: React.NamedExoticComponent<Omit<import("@hanzogui/core").RNHanzoguiViewNonStyleProps, "unstyled" | "elevation" | keyof import("@hanzogui/core").StackStyleBase | "fullscreen"> & import("@hanzogui/core").WithThemeValues<import("@hanzogui/core").StackStyleBase> & {
|
|
38
38
|
unstyled?: boolean | undefined;
|
|
39
|
-
elevation?: number | import("@
|
|
39
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
40
40
|
fullscreen?: boolean | undefined;
|
|
41
|
-
} & import("@
|
|
41
|
+
} & import("@hanzogui/core").WithShorthands<import("@hanzogui/core").WithThemeValues<import("@hanzogui/core").StackStyleBase>> & import("@hanzogui/core").WithPseudoProps<import("@hanzogui/core").WithThemeValues<import("@hanzogui/core").StackStyleBase> & {
|
|
42
42
|
unstyled?: boolean | undefined;
|
|
43
|
-
elevation?: number | import("@
|
|
43
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
44
44
|
fullscreen?: boolean | undefined;
|
|
45
|
-
} & import("@
|
|
45
|
+
} & import("@hanzogui/core").WithShorthands<import("@hanzogui/core").WithThemeValues<import("@hanzogui/core").StackStyleBase>>> & import("@hanzogui/core").WithMediaProps<import("@hanzogui/core").WithThemeShorthandsAndPseudos<import("@hanzogui/core").StackStyleBase, {
|
|
46
46
|
unstyled?: boolean | undefined;
|
|
47
|
-
elevation?: number | import("@
|
|
47
|
+
elevation?: number | import("@hanzogui/core").SizeTokens | undefined;
|
|
48
48
|
fullscreen?: boolean | undefined;
|
|
49
49
|
}>> & {
|
|
50
50
|
/**
|
|
@@ -67,7 +67,7 @@ declare const ToastViewport: React.NamedExoticComponent<Omit<import("@gui/core")
|
|
|
67
67
|
*/
|
|
68
68
|
multipleToasts?: boolean;
|
|
69
69
|
/**
|
|
70
|
-
* When true, uses a portal to render at the very top of the root
|
|
70
|
+
* When true, uses a portal to render at the very top of the root HanzoguiProvider.
|
|
71
71
|
*/
|
|
72
72
|
portalToRoot?: boolean;
|
|
73
73
|
} & React.RefAttributes<HTMLDivElement>>;
|