@hanzogui/toast 3.0.1 → 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.
Files changed (167) hide show
  1. package/package.json +42 -25
  2. package/src/Toast.tsx +5 -5
  3. package/src/ToastAnnounce.tsx +2 -2
  4. package/src/ToastComposable.tsx +1380 -0
  5. package/src/ToastImpl.tsx +19 -7
  6. package/src/ToastItemFrame.tsx +136 -0
  7. package/src/ToastPortal.tsx +2 -2
  8. package/src/ToastProvider.tsx +13 -6
  9. package/src/ToastState.ts +398 -0
  10. package/src/ToastViewport.tsx +11 -10
  11. package/src/Toaster.tsx +181 -0
  12. package/src/createNativeToast.native.tsx +4 -0
  13. package/src/createNativeToast.tsx +18 -24
  14. package/src/dispatchNativeToast.ts +43 -0
  15. package/src/useAnimatedDragGesture.native.ts +255 -0
  16. package/src/useAnimatedDragGesture.ts +319 -0
  17. package/src/useReducedMotion.ts +59 -0
  18. package/src/useToastAnimations.ts +377 -0
  19. package/src/v2.ts +31 -0
  20. package/types/Toast.d.ts +36 -36
  21. package/types/ToastAnnounce.d.ts +4 -4
  22. package/types/ToastComposable.d.ts +199 -0
  23. package/types/ToastImperative.d.ts +2 -2
  24. package/types/ToastImpl.d.ts +12 -12
  25. package/types/ToastItemFrame.d.ts +25 -0
  26. package/types/ToastProvider.d.ts +8 -8
  27. package/types/ToastState.d.ts +179 -0
  28. package/types/ToastViewport.d.ts +12 -12
  29. package/types/Toaster.d.ts +112 -0
  30. package/types/createNativeToast.d.ts +5 -0
  31. package/types/createNativeToast.native.d.ts +1 -0
  32. package/types/dispatchNativeToast.d.ts +12 -0
  33. package/types/useAnimatedDragGesture.d.ts +33 -0
  34. package/types/useAnimatedDragGesture.native.d.ts +33 -0
  35. package/types/useReducedMotion.d.ts +6 -0
  36. package/types/useToastAnimations.d.ts +50 -0
  37. package/types/v2.d.ts +10 -0
  38. package/v2/index.cjs +2 -0
  39. package/v2/index.js +2 -0
  40. package/v2/index.native.cjs +2 -0
  41. package/v2/index.native.js +2 -0
  42. package/LICENSE +0 -21
  43. package/dist/cjs/Toast.cjs +0 -170
  44. package/dist/cjs/Toast.native.js +0 -174
  45. package/dist/cjs/Toast.native.js.map +0 -1
  46. package/dist/cjs/ToastAnnounce.cjs +0 -97
  47. package/dist/cjs/ToastAnnounce.native.js +0 -105
  48. package/dist/cjs/ToastAnnounce.native.js.map +0 -1
  49. package/dist/cjs/ToastImperative.cjs +0 -100
  50. package/dist/cjs/ToastImperative.native.js +0 -122
  51. package/dist/cjs/ToastImperative.native.js.map +0 -1
  52. package/dist/cjs/ToastImpl.cjs +0 -292
  53. package/dist/cjs/ToastImpl.native.js +0 -326
  54. package/dist/cjs/ToastImpl.native.js.map +0 -1
  55. package/dist/cjs/ToastPortal.cjs +0 -44
  56. package/dist/cjs/ToastPortal.native.js +0 -47
  57. package/dist/cjs/ToastPortal.native.js.map +0 -1
  58. package/dist/cjs/ToastProvider.cjs +0 -146
  59. package/dist/cjs/ToastProvider.native.js +0 -159
  60. package/dist/cjs/ToastProvider.native.js.map +0 -1
  61. package/dist/cjs/ToastViewport.cjs +0 -278
  62. package/dist/cjs/ToastViewport.native.js +0 -315
  63. package/dist/cjs/ToastViewport.native.js.map +0 -1
  64. package/dist/cjs/constants.cjs +0 -28
  65. package/dist/cjs/constants.native.js +0 -31
  66. package/dist/cjs/constants.native.js.map +0 -1
  67. package/dist/cjs/createNativeToast.cjs +0 -51
  68. package/dist/cjs/createNativeToast.native.js +0 -48
  69. package/dist/cjs/createNativeToast.native.js.map +0 -1
  70. package/dist/cjs/index.cjs +0 -18
  71. package/dist/cjs/index.native.js +0 -21
  72. package/dist/cjs/index.native.js.map +0 -1
  73. package/dist/cjs/types.cjs +0 -16
  74. package/dist/cjs/types.native.js +0 -19
  75. package/dist/cjs/types.native.js.map +0 -1
  76. package/dist/esm/Toast.mjs +0 -131
  77. package/dist/esm/Toast.mjs.map +0 -1
  78. package/dist/esm/Toast.native.js +0 -132
  79. package/dist/esm/Toast.native.js.map +0 -1
  80. package/dist/esm/ToastAnnounce.mjs +0 -62
  81. package/dist/esm/ToastAnnounce.mjs.map +0 -1
  82. package/dist/esm/ToastAnnounce.native.js +0 -67
  83. package/dist/esm/ToastAnnounce.native.js.map +0 -1
  84. package/dist/esm/ToastImperative.mjs +0 -63
  85. package/dist/esm/ToastImperative.mjs.map +0 -1
  86. package/dist/esm/ToastImperative.native.js +0 -82
  87. package/dist/esm/ToastImperative.native.js.map +0 -1
  88. package/dist/esm/ToastImpl.mjs +0 -256
  89. package/dist/esm/ToastImpl.mjs.map +0 -1
  90. package/dist/esm/ToastImpl.native.js +0 -287
  91. package/dist/esm/ToastImpl.native.js.map +0 -1
  92. package/dist/esm/ToastPortal.mjs +0 -21
  93. package/dist/esm/ToastPortal.mjs.map +0 -1
  94. package/dist/esm/ToastPortal.native.js +0 -21
  95. package/dist/esm/ToastPortal.native.js.map +0 -1
  96. package/dist/esm/ToastProvider.mjs +0 -108
  97. package/dist/esm/ToastProvider.mjs.map +0 -1
  98. package/dist/esm/ToastProvider.native.js +0 -118
  99. package/dist/esm/ToastProvider.native.js.map +0 -1
  100. package/dist/esm/ToastViewport.mjs +0 -241
  101. package/dist/esm/ToastViewport.mjs.map +0 -1
  102. package/dist/esm/ToastViewport.native.js +0 -275
  103. package/dist/esm/ToastViewport.native.js.map +0 -1
  104. package/dist/esm/constants.mjs +0 -4
  105. package/dist/esm/constants.mjs.map +0 -1
  106. package/dist/esm/constants.native.js +0 -4
  107. package/dist/esm/constants.native.js.map +0 -1
  108. package/dist/esm/createNativeToast.mjs +0 -27
  109. package/dist/esm/createNativeToast.mjs.map +0 -1
  110. package/dist/esm/createNativeToast.native.js +0 -21
  111. package/dist/esm/createNativeToast.native.js.map +0 -1
  112. package/dist/esm/index.js +0 -2
  113. package/dist/esm/index.js.map +0 -1
  114. package/dist/esm/index.mjs +0 -2
  115. package/dist/esm/index.mjs.map +0 -1
  116. package/dist/esm/index.native.js +0 -2
  117. package/dist/esm/index.native.js.map +0 -1
  118. package/dist/esm/types.mjs +0 -2
  119. package/dist/esm/types.mjs.map +0 -1
  120. package/dist/esm/types.native.js +0 -2
  121. package/dist/esm/types.native.js.map +0 -1
  122. package/dist/jsx/Toast.mjs +0 -131
  123. package/dist/jsx/Toast.mjs.map +0 -1
  124. package/dist/jsx/Toast.native.js +0 -174
  125. package/dist/jsx/Toast.native.js.map +0 -1
  126. package/dist/jsx/ToastAnnounce.mjs +0 -62
  127. package/dist/jsx/ToastAnnounce.mjs.map +0 -1
  128. package/dist/jsx/ToastAnnounce.native.js +0 -105
  129. package/dist/jsx/ToastAnnounce.native.js.map +0 -1
  130. package/dist/jsx/ToastImperative.mjs +0 -63
  131. package/dist/jsx/ToastImperative.mjs.map +0 -1
  132. package/dist/jsx/ToastImperative.native.js +0 -122
  133. package/dist/jsx/ToastImperative.native.js.map +0 -1
  134. package/dist/jsx/ToastImpl.mjs +0 -256
  135. package/dist/jsx/ToastImpl.mjs.map +0 -1
  136. package/dist/jsx/ToastImpl.native.js +0 -326
  137. package/dist/jsx/ToastImpl.native.js.map +0 -1
  138. package/dist/jsx/ToastPortal.mjs +0 -21
  139. package/dist/jsx/ToastPortal.mjs.map +0 -1
  140. package/dist/jsx/ToastPortal.native.js +0 -47
  141. package/dist/jsx/ToastPortal.native.js.map +0 -1
  142. package/dist/jsx/ToastProvider.mjs +0 -108
  143. package/dist/jsx/ToastProvider.mjs.map +0 -1
  144. package/dist/jsx/ToastProvider.native.js +0 -159
  145. package/dist/jsx/ToastProvider.native.js.map +0 -1
  146. package/dist/jsx/ToastViewport.mjs +0 -241
  147. package/dist/jsx/ToastViewport.mjs.map +0 -1
  148. package/dist/jsx/ToastViewport.native.js +0 -315
  149. package/dist/jsx/ToastViewport.native.js.map +0 -1
  150. package/dist/jsx/constants.mjs +0 -4
  151. package/dist/jsx/constants.mjs.map +0 -1
  152. package/dist/jsx/constants.native.js +0 -31
  153. package/dist/jsx/constants.native.js.map +0 -1
  154. package/dist/jsx/createNativeToast.mjs +0 -27
  155. package/dist/jsx/createNativeToast.mjs.map +0 -1
  156. package/dist/jsx/createNativeToast.native.js +0 -48
  157. package/dist/jsx/createNativeToast.native.js.map +0 -1
  158. package/dist/jsx/index.js +0 -2
  159. package/dist/jsx/index.js.map +0 -1
  160. package/dist/jsx/index.mjs +0 -2
  161. package/dist/jsx/index.mjs.map +0 -1
  162. package/dist/jsx/index.native.js +0 -21
  163. package/dist/jsx/index.native.js.map +0 -1
  164. package/dist/jsx/types.mjs +0 -2
  165. package/dist/jsx/types.mjs.map +0 -1
  166. package/dist/jsx/types.native.js +0 -19
  167. package/dist/jsx/types.native.js.map +0 -1
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Toaster — drop-in all-in-one toast component.
3
+ * Thin wrapper around Toast + Toast.Viewport + Toast.List (composable API).
4
+ */
5
+ import type { HanzoguiElement } from '@hanzogui/core';
6
+ import * as React from 'react';
7
+ import type { ToastPosition } from './ToastComposable';
8
+ import type { SwipeDirection } from './ToastProvider';
9
+ import type { ExternalToast } from './ToastState';
10
+ import type { BurntToastOptions } from './types';
11
+ export type ToasterPosition = ToastPosition;
12
+ export interface ToasterProps {
13
+ /**
14
+ * Position of the toasts on screen
15
+ * @default 'bottom-right'
16
+ */
17
+ position?: ToasterPosition;
18
+ /**
19
+ * Expand toasts on hover to show all
20
+ * @default false
21
+ */
22
+ expand?: boolean;
23
+ /**
24
+ * Number of toasts visible at once
25
+ * @default 4
26
+ */
27
+ visibleToasts?: number;
28
+ /**
29
+ * Gap between toasts in pixels
30
+ * @default 14
31
+ */
32
+ gap?: number;
33
+ /**
34
+ * Default duration for toasts in ms
35
+ * @default 4000
36
+ */
37
+ duration?: number;
38
+ /**
39
+ * Offset from screen edge in pixels
40
+ * @default 24
41
+ */
42
+ offset?: number | {
43
+ top?: number;
44
+ right?: number;
45
+ bottom?: number;
46
+ left?: number;
47
+ };
48
+ /**
49
+ * Hotkey to focus toast viewport
50
+ * @default ['altKey', 'KeyT']
51
+ */
52
+ hotkey?: string[];
53
+ /**
54
+ * Direction(s) toasts can be swiped to dismiss.
55
+ * 'auto' detects based on position (swipe toward nearest edge).
56
+ * @default 'auto'
57
+ */
58
+ swipeDirection?: SwipeDirection;
59
+ /**
60
+ * Distance in pixels swipe must pass to dismiss
61
+ * @default 50
62
+ */
63
+ swipeThreshold?: number;
64
+ /**
65
+ * Show close button on toasts
66
+ * @default false
67
+ */
68
+ closeButton?: boolean;
69
+ /**
70
+ * Theme for toasts (auto-detected if not set)
71
+ */
72
+ theme?: 'light' | 'dark' | 'system';
73
+ /**
74
+ * Custom icons for toast types
75
+ */
76
+ icons?: {
77
+ success?: React.ReactNode;
78
+ error?: React.ReactNode;
79
+ warning?: React.ReactNode;
80
+ info?: React.ReactNode;
81
+ loading?: React.ReactNode;
82
+ close?: React.ReactNode;
83
+ };
84
+ /**
85
+ * Default toast options
86
+ */
87
+ toastOptions?: ExternalToast;
88
+ /**
89
+ * Container aria label for screen readers
90
+ * @default 'Notifications'
91
+ */
92
+ containerAriaLabel?: string;
93
+ /**
94
+ * When true, uses burnt native OS toasts on mobile instead of RN views.
95
+ * @default false
96
+ */
97
+ native?: boolean;
98
+ /**
99
+ * Options for burnt native toasts on mobile
100
+ */
101
+ burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>;
102
+ /**
103
+ * Options for web Notification API
104
+ */
105
+ notificationOptions?: NotificationOptions;
106
+ /**
107
+ * Force reduced motion mode (disables animations)
108
+ */
109
+ reducedMotion?: boolean;
110
+ }
111
+ export declare const Toaster: React.ForwardRefExoticComponent<ToasterProps & React.RefAttributes<HanzoguiElement>>;
112
+ //# sourceMappingURL=Toaster.d.ts.map
@@ -1,4 +1,9 @@
1
1
  import type { CreateNativeToastsFn, HideNativeToastsFn } from './types';
2
2
  export declare const createNativeToast: CreateNativeToastsFn;
3
3
  export declare const hideNativeToast: HideNativeToastsFn;
4
+ /**
5
+ * Request notification permission from the browser.
6
+ * Must be called from a user gesture (click/tap handler).
7
+ */
8
+ export declare function requestNotificationPermission(): Promise<NotificationPermission | null>;
4
9
  //# sourceMappingURL=createNativeToast.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import type { CreateNativeToastsFn, HideNativeToastsFn } from './types';
2
2
  export declare const createNativeToast: CreateNativeToastsFn;
3
3
  export declare const hideNativeToast: HideNativeToastsFn;
4
+ export declare function requestNotificationPermission(): Promise<null>;
4
5
  //# sourceMappingURL=createNativeToast.native.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { ToastT } from './ToastState';
2
+ import type { BurntToastOptions } from './types';
3
+ /**
4
+ * Attempts to dispatch a toast via native platform API (Burnt on mobile, Notification on web).
5
+ * Returns true if the toast was handled natively, false if it should fall through to in-app.
6
+ */
7
+ export declare function dispatchNativeToast(toast: ToastT, opts: {
8
+ duration: number;
9
+ burntOptions?: Omit<BurntToastOptions, 'title' | 'message' | 'duration'>;
10
+ notificationOptions?: NotificationOptions;
11
+ }): boolean;
12
+ //# sourceMappingURL=dispatchNativeToast.d.ts.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Web implementation of drag gesture handling with animation driver integration.
3
+ * Uses pointer events for smooth drag tracking, animation driver for transforms.
4
+ */
5
+ import * as React from 'react';
6
+ import type { SwipeDirection } from './ToastProvider';
7
+ export interface UseAnimatedDragGestureOptions {
8
+ direction: SwipeDirection;
9
+ threshold: number;
10
+ disabled?: boolean;
11
+ /** when collapsed, allow drag in all directions with resistance except exit direction */
12
+ expanded?: boolean;
13
+ /** called during drag with offset values */
14
+ onDragMove: (x: number, y: number) => void;
15
+ /** called when drag starts */
16
+ onDragStart?: () => void;
17
+ /** called when drag ends with successful dismiss - includes exit direction and velocity */
18
+ onDismiss: (exitDirection: 'left' | 'right' | 'up' | 'down', velocity: number) => void;
19
+ /** called when drag ends without dismiss - spring back */
20
+ onCancel: () => void;
21
+ }
22
+ export declare function useAnimatedDragGesture(options: UseAnimatedDragGestureOptions): {
23
+ isDragging: boolean;
24
+ gestureHandlers: {
25
+ onPointerDown: (event: React.PointerEvent) => void;
26
+ onPointerMove: (event: React.PointerEvent) => void;
27
+ onPointerUp: (event: React.PointerEvent) => void;
28
+ onPointerCancel: (event: React.PointerEvent) => void;
29
+ onLostPointerCapture: () => void;
30
+ };
31
+ gesture: any;
32
+ };
33
+ //# sourceMappingURL=useAnimatedDragGesture.d.ts.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Native drag gesture handling for toast swipe-to-dismiss.
3
+ *
4
+ * Uses react-native-gesture-handler (RNGH) when available for proper gesture
5
+ * coordination with ScrollView and navigation. Falls back to PanResponder.
6
+ *
7
+ * Pattern: same as Sheet — RNGH is accessed through @hanzogui/native global
8
+ * registry, never imported directly. The gesture is created in useMemo and
9
+ * returns null when RNGH is not set up.
10
+ */
11
+ import type { SwipeDirection } from './ToastProvider';
12
+ export interface UseAnimatedDragGestureOptions {
13
+ direction: SwipeDirection;
14
+ threshold: number;
15
+ disabled?: boolean;
16
+ expanded?: boolean;
17
+ onDragMove: (x: number, y: number) => void;
18
+ onDragStart?: () => void;
19
+ onDismiss: (exitDirection: 'left' | 'right' | 'up' | 'down', velocity: number) => void;
20
+ onCancel: () => void;
21
+ }
22
+ /**
23
+ * Single hook — always calls the same hooks in the same order.
24
+ * Creates RNGH gesture in useMemo (returns null if unavailable).
25
+ * Creates PanResponder in useMemo (returns null if RNGH is used).
26
+ * Consumer checks `gesture` to decide whether to wrap with GestureDetector.
27
+ */
28
+ export declare function useAnimatedDragGesture(options: UseAnimatedDragGestureOptions): {
29
+ isDragging: boolean;
30
+ gestureHandlers: import("react-native").GestureResponderHandlers;
31
+ gesture: any;
32
+ };
33
+ //# sourceMappingURL=useAnimatedDragGesture.native.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Hook to detect reduced motion preference.
3
+ * Returns true if user prefers reduced motion (via system settings or forced).
4
+ */
5
+ export declare function useReducedMotion(forceReducedMotion?: boolean): boolean;
6
+ //# sourceMappingURL=useReducedMotion.d.ts.map
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Hook for cross-animation-driver toast drag animations.
3
+ *
4
+ * Animation strategy (all cross-driver):
5
+ * - AnimatePresence => enter/exit styles
6
+ * - transition prop => non-interactive styles (stacking, scale, opacity)
7
+ * - useAnimatedNumber/Style => interactive styles (drag gestures only)
8
+ *
9
+ * This hook handles ONLY the drag gesture animations.
10
+ * Uses the same pattern as Sheet for universal animation support.
11
+ *
12
+ * NOTE: For CSS driver, we use a ref-based approach with direct DOM manipulation
13
+ * because CSS driver's useAnimatedNumberStyle doesn't reactively update.
14
+ * For Motion/Reanimated drivers, we use the AnimatedView + motionValue pattern.
15
+ */
16
+ import * as React from 'react';
17
+ import type { Animated } from 'react-native';
18
+ export interface UseToastAnimationsOptions {
19
+ /**
20
+ * Called when exit animation completes
21
+ */
22
+ onExitComplete?: () => void;
23
+ /**
24
+ * When true, animations complete instantly (accessibility)
25
+ */
26
+ reducedMotion?: boolean;
27
+ /**
28
+ * Primary swipe axis — determines which animated value is tracked for style updates.
29
+ * 'horizontal' tracks translateX, 'vertical' tracks translateY.
30
+ */
31
+ swipeAxis?: 'horizontal' | 'vertical';
32
+ }
33
+ export interface ToastAnimationValues {
34
+ /** set drag offset directly (no animation, for gesture moves) */
35
+ setDragOffset: (x: number, y: number) => void;
36
+ /** spring back to origin after cancelled drag */
37
+ springBack: (onComplete?: () => void) => void;
38
+ /** animate out in a direction after successful swipe, with optional velocity for smooth continuation */
39
+ animateOut: (direction: 'left' | 'right' | 'up' | 'down', velocity?: number, onComplete?: () => void) => void;
40
+ /** stop any running animations */
41
+ stop: () => void;
42
+ /** the animated style to spread on the AnimatedView (for motion/reanimated drivers) */
43
+ animatedStyle: any;
44
+ /** the animated view component from the driver */
45
+ AnimatedView: typeof Animated.View;
46
+ /** ref to attach to the drag wrapper element (for CSS driver direct DOM updates) */
47
+ dragRef: React.RefObject<HTMLDivElement | null>;
48
+ }
49
+ export declare function useToastAnimations(options?: UseToastAnimationsOptions): ToastAnimationValues;
50
+ //# sourceMappingURL=useToastAnimations.d.ts.map
package/types/v2.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export { Toast, useToasts, useToastItem } from './ToastComposable';
2
+ export type { ToastRootProps, ToastViewportProps, ToastItemProps, ToastItemRenderProps, ToastListProps, ToastPosition, ToastIcons, } from './ToastComposable';
3
+ export { toast } from './ToastState';
4
+ export type { ToastT, ToastType, ToastToDismiss, ExternalToast, PromiseT, PromiseData, ToastAction, } from './ToastState';
5
+ export { Toaster } from './Toaster';
6
+ export type { ToasterProps, ToasterPosition } from './Toaster';
7
+ export type { SwipeDirection } from './ToastProvider';
8
+ export type { BurntToastOptions, CreateNativeToastOptions, NativeToastRef } from './types';
9
+ export { requestNotificationPermission } from './createNativeToast';
10
+ //# sourceMappingURL=v2.d.ts.map
package/v2/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ // compat with hanzogui static compiler
2
+ Object.assign(module.exports, require('../dist/cjs/v2.cjs'))
package/v2/index.js ADDED
@@ -0,0 +1,2 @@
1
+ // compat with metro without package exports
2
+ Object.assign(module.exports, require('../dist/cjs/v2.cjs'))
@@ -0,0 +1,2 @@
1
+ // compat with hanzogui static compiler
2
+ Object.assign(module.exports, require('../dist/cjs/v2.native.js'))
@@ -0,0 +1,2 @@
1
+ // compat with metro without package exports
2
+ Object.assign(module.exports, require('../dist/cjs/v2.native.js'))
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 WorkOS and Tamagui
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,170 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
32
- var Toast_exports = {};
33
- __export(Toast_exports, {
34
- Toast: () => Toast2,
35
- ToastProvider: () => import_ToastProvider.ToastProvider,
36
- ToastViewport: () => import_ToastViewport.ToastViewport,
37
- useToast: () => import_ToastImperative.useToast,
38
- useToastController: () => import_ToastImperative.useToastController,
39
- useToastState: () => import_ToastImperative.useToastState
40
- });
41
- module.exports = __toCommonJS(Toast_exports);
42
- var import_gui_animate_presence = require("@hanzogui/animate-presence"),
43
- import_gui_core = require("@hanzogui/core"),
44
- import_gui_helpers = require("@hanzogui/helpers"),
45
- import_gui_stacks = require("@hanzogui/stacks"),
46
- import_gui_text = require("@hanzogui/text"),
47
- import_gui_use_controllable_state = require("@hanzogui/use-controllable-state"),
48
- React = __toESM(require("react"), 1),
49
- import_ToastAnnounce = require("./ToastAnnounce.cjs"),
50
- import_ToastImperative = require("./ToastImperative.cjs"),
51
- import_ToastImpl = require("./ToastImpl.cjs"),
52
- import_ToastProvider = require("./ToastProvider.cjs"),
53
- import_ToastViewport = require("./ToastViewport.cjs"),
54
- import_jsx_runtime = require("react/jsx-runtime");
55
- const TITLE_NAME = "ToastTitle",
56
- ToastTitle = (0, import_gui_core.styled)(import_gui_text.SizableText, {
57
- name: TITLE_NAME,
58
- variants: {
59
- unstyled: {
60
- false: {
61
- color: "$color",
62
- size: "$4"
63
- }
64
- }
65
- },
66
- defaultVariants: {
67
- unstyled: process.env.HANZO_GUI_HEADLESS === "1"
68
- }
69
- }),
70
- DESCRIPTION_NAME = "ToastDescription",
71
- ToastDescription = (0, import_gui_core.styled)(import_gui_text.SizableText, {
72
- name: DESCRIPTION_NAME,
73
- variants: {
74
- unstyled: {
75
- false: {
76
- color: "$color11",
77
- size: "$1"
78
- }
79
- }
80
- },
81
- defaultVariants: {
82
- unstyled: process.env.HANZO_GUI_HEADLESS === "1"
83
- }
84
- }),
85
- ACTION_NAME = "ToastAction",
86
- ToastAction = React.forwardRef(function (props, forwardedRef) {
87
- const {
88
- altText,
89
- ...actionProps
90
- } = props;
91
- return altText ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastAnnounce.ToastAnnounceExclude, {
92
- altText,
93
- asChild: !0,
94
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastClose, {
95
- ...actionProps,
96
- ref: forwardedRef
97
- })
98
- }) : null;
99
- });
100
- ToastAction.propTypes = {
101
- altText(props) {
102
- return props.altText ? null : new Error(`Missing prop \`altText\` expected on \`${ACTION_NAME}\``);
103
- }
104
- };
105
- const CLOSE_NAME = "ToastClose",
106
- ToastCloseFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
107
- name: CLOSE_NAME,
108
- render: "button"
109
- }),
110
- ToastClose = React.forwardRef(function (props, forwardedRef) {
111
- const {
112
- scope,
113
- ...closeProps
114
- } = props,
115
- interactiveContext = (0, import_ToastImpl.useToastInteractiveContext)(scope);
116
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastAnnounce.ToastAnnounceExclude, {
117
- asChild: !0,
118
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastCloseFrame, {
119
- "aria-label": "Close",
120
- ...closeProps,
121
- ref: forwardedRef,
122
- onPress: (0, import_gui_helpers.composeEventHandlers)(props.onPress, interactiveContext.onClose)
123
- })
124
- });
125
- }),
126
- ToastComponent = import_ToastImpl.ToastImplFrame.styleable(function (props, forwardedRef) {
127
- const {
128
- forceMount,
129
- open: openProp,
130
- defaultOpen,
131
- onOpenChange,
132
- ...toastProps
133
- } = props,
134
- [open, setOpen] = (0, import_gui_use_controllable_state.useControllableState)({
135
- prop: openProp,
136
- defaultProp: defaultOpen ?? !0,
137
- onChange: onOpenChange,
138
- strategy: "most-recent-wins"
139
- }),
140
- currentToast = (0, import_ToastImperative.useToastState)(),
141
- {
142
- hide
143
- } = (0, import_ToastImperative.useToastController)(),
144
- id = React.useId(),
145
- onPause = (0, import_gui_core.useEvent)(props.onPause),
146
- onResume = (0, import_gui_core.useEvent)(props.onResume),
147
- isHide = currentToast?.hide === !0;
148
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_animate_presence.AnimatePresence, {
149
- children: (forceMount || open) && !isHide ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastImpl.ToastImpl, {
150
- id,
151
- open,
152
- ...toastProps,
153
- ref: forwardedRef,
154
- onClose: () => {
155
- setOpen(!1), hide();
156
- },
157
- onPause,
158
- onResume,
159
- onSwipeEnd: (0, import_gui_helpers.composeEventHandlers)(props.onSwipeEnd, event => {
160
- setOpen(!1);
161
- })
162
- }) : null
163
- }, id);
164
- }),
165
- Toast2 = (0, import_gui_helpers.withStaticProperties)(ToastComponent, {
166
- Title: ToastTitle,
167
- Description: ToastDescription,
168
- Action: ToastAction,
169
- Close: ToastClose
170
- });
@@ -1,174 +0,0 @@
1
- "use strict";
2
-
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf,
8
- __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
17
- get: () => from[key],
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
34
- var Toast_exports = {};
35
- __export(Toast_exports, {
36
- Toast: () => Toast2,
37
- ToastProvider: () => import_ToastProvider.ToastProvider,
38
- ToastViewport: () => import_ToastViewport.ToastViewport,
39
- useToast: () => import_ToastImperative.useToast,
40
- useToastController: () => import_ToastImperative.useToastController,
41
- useToastState: () => import_ToastImperative.useToastState
42
- });
43
- module.exports = __toCommonJS(Toast_exports);
44
- var import_jsx_runtime = require("react/jsx-runtime"),
45
- import_gui_animate_presence = require("@hanzogui/animate-presence"),
46
- import_gui_core = require("@hanzogui/core"),
47
- import_gui_helpers = require("@hanzogui/helpers"),
48
- import_gui_stacks = require("@hanzogui/stacks"),
49
- import_gui_text = require("@hanzogui/text"),
50
- import_gui_use_controllable_state = require("@hanzogui/use-controllable-state"),
51
- React = __toESM(require("react"), 1),
52
- import_ToastAnnounce = require("./ToastAnnounce.native.js"),
53
- import_ToastImperative = require("./ToastImperative.native.js"),
54
- import_ToastImpl = require("./ToastImpl.native.js"),
55
- import_ToastProvider = require("./ToastProvider.native.js"),
56
- import_ToastViewport = require("./ToastViewport.native.js"),
57
- TITLE_NAME = "ToastTitle",
58
- ToastTitle = (0, import_gui_core.styled)(import_gui_text.SizableText, {
59
- name: TITLE_NAME,
60
- variants: {
61
- unstyled: {
62
- false: {
63
- color: "$color",
64
- size: "$4"
65
- }
66
- }
67
- },
68
- defaultVariants: {
69
- unstyled: process.env.HANZO_GUI_HEADLESS === "1"
70
- }
71
- }),
72
- DESCRIPTION_NAME = "ToastDescription",
73
- ToastDescription = (0, import_gui_core.styled)(import_gui_text.SizableText, {
74
- name: DESCRIPTION_NAME,
75
- variants: {
76
- unstyled: {
77
- false: {
78
- color: "$color11",
79
- size: "$1"
80
- }
81
- }
82
- },
83
- defaultVariants: {
84
- unstyled: process.env.HANZO_GUI_HEADLESS === "1"
85
- }
86
- }),
87
- ACTION_NAME = "ToastAction",
88
- ToastAction = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
89
- var {
90
- altText,
91
- ...actionProps
92
- } = props;
93
- return altText ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastAnnounce.ToastAnnounceExclude, {
94
- altText,
95
- asChild: !0,
96
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastClose, {
97
- ...actionProps,
98
- ref: forwardedRef
99
- })
100
- }) : null;
101
- });
102
- ToastAction.propTypes = {
103
- altText(props) {
104
- return props.altText ? null : new Error(`Missing prop \`altText\` expected on \`${ACTION_NAME}\``);
105
- }
106
- };
107
- var CLOSE_NAME = "ToastClose",
108
- ToastCloseFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
109
- name: CLOSE_NAME,
110
- render: "button"
111
- }),
112
- ToastClose = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
113
- var {
114
- scope,
115
- ...closeProps
116
- } = props,
117
- interactiveContext = (0, import_ToastImpl.useToastInteractiveContext)(scope);
118
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastAnnounce.ToastAnnounceExclude, {
119
- asChild: !0,
120
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(ToastCloseFrame, {
121
- "aria-label": "Close",
122
- ...closeProps,
123
- ref: forwardedRef,
124
- onPress: (0, import_gui_helpers.composeEventHandlers)(props.onPress, interactiveContext.onClose)
125
- })
126
- });
127
- }),
128
- ToastComponent = import_ToastImpl.ToastImplFrame.styleable(function (props, forwardedRef) {
129
- var {
130
- forceMount,
131
- open: openProp,
132
- defaultOpen,
133
- onOpenChange,
134
- ...toastProps
135
- } = props,
136
- [open, setOpen] = (0, import_gui_use_controllable_state.useControllableState)({
137
- prop: openProp,
138
- defaultProp: defaultOpen ?? !0,
139
- onChange: onOpenChange,
140
- strategy: "most-recent-wins"
141
- }),
142
- currentToast = (0, import_ToastImperative.useToastState)(),
143
- {
144
- hide
145
- } = (0, import_ToastImperative.useToastController)(),
146
- id = React.useId(),
147
- onPause = (0, import_gui_core.useEvent)(props.onPause),
148
- onResume = (0, import_gui_core.useEvent)(props.onResume),
149
- isHide = currentToast?.hide === !0,
150
- shouldShow = (forceMount || open) && !isHide;
151
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_animate_presence.AnimatePresence, {
152
- children: shouldShow ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_ToastImpl.ToastImpl, {
153
- id,
154
- open,
155
- ...toastProps,
156
- ref: forwardedRef,
157
- onClose: function () {
158
- setOpen(!1), hide();
159
- },
160
- onPause,
161
- onResume,
162
- onSwipeEnd: (0, import_gui_helpers.composeEventHandlers)(props.onSwipeEnd, function (event) {
163
- setOpen(!1);
164
- })
165
- }) : null
166
- }, id);
167
- }),
168
- Toast2 = (0, import_gui_helpers.withStaticProperties)(ToastComponent, {
169
- Title: ToastTitle,
170
- Description: ToastDescription,
171
- Action: ToastAction,
172
- Close: ToastClose
173
- });
174
- //# sourceMappingURL=Toast.native.js.map