panelui-native 0.2.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.
- package/README.md +258 -0
- package/lib/module/components/accordion/index.js +312 -0
- package/lib/module/components/accordion/index.js.map +1 -0
- package/lib/module/components/alert/index.js +106 -13
- package/lib/module/components/alert/index.js.map +1 -1
- package/lib/module/components/avatar/index.js +58 -17
- package/lib/module/components/avatar/index.js.map +1 -1
- package/lib/module/components/badge/index.js +29 -8
- package/lib/module/components/badge/index.js.map +1 -1
- package/lib/module/components/button/index.js +87 -26
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/checkbox/index.js +59 -18
- package/lib/module/components/checkbox/index.js.map +1 -1
- package/lib/module/components/empty-state/index.js +178 -0
- package/lib/module/components/empty-state/index.js.map +1 -0
- package/lib/module/components/frame/index.js +64 -13
- package/lib/module/components/frame/index.js.map +1 -1
- package/lib/module/components/input-group/index.js +132 -0
- package/lib/module/components/input-group/index.js.map +1 -0
- package/lib/module/components/label/index.js +117 -0
- package/lib/module/components/label/index.js.map +1 -0
- package/lib/module/components/progress/index.js +138 -0
- package/lib/module/components/progress/index.js.map +1 -0
- package/lib/module/components/steps/index.js +354 -0
- package/lib/module/components/steps/index.js.map +1 -0
- package/lib/module/components/tabs/index.js +9 -3
- package/lib/module/components/tabs/index.js.map +1 -1
- package/lib/module/components/timeline/index.js +633 -0
- package/lib/module/components/timeline/index.js.map +1 -0
- package/lib/module/components/toast/index.js +569 -0
- package/lib/module/components/toast/index.js.map +1 -0
- package/lib/module/components/toast/toast-store.js +81 -0
- package/lib/module/components/toast/toast-store.js.map +1 -0
- package/lib/module/components/typography/index.js +126 -0
- package/lib/module/components/typography/index.js.map +1 -0
- package/lib/module/icons/index.js +590 -8
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/providers/panel-ui-provider.js +2 -1
- package/lib/module/providers/panel-ui-provider.js.map +1 -1
- package/lib/module/theme/use-theme.js +90 -3
- package/lib/module/theme/use-theme.js.map +1 -1
- package/lib/typescript/src/components/accordion/index.d.ts +56 -0
- package/lib/typescript/src/components/accordion/index.d.ts.map +1 -0
- package/lib/typescript/src/components/alert/index.d.ts +56 -4
- package/lib/typescript/src/components/alert/index.d.ts.map +1 -1
- package/lib/typescript/src/components/avatar/index.d.ts +8 -1
- package/lib/typescript/src/components/avatar/index.d.ts.map +1 -1
- package/lib/typescript/src/components/badge/index.d.ts +38 -0
- package/lib/typescript/src/components/badge/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts +57 -0
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/checkbox/index.d.ts +50 -0
- package/lib/typescript/src/components/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/src/components/empty-state/index.d.ts +73 -0
- package/lib/typescript/src/components/empty-state/index.d.ts.map +1 -0
- package/lib/typescript/src/components/frame/index.d.ts +39 -5
- package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
- package/lib/typescript/src/components/input-group/index.d.ts +34 -0
- package/lib/typescript/src/components/input-group/index.d.ts.map +1 -0
- package/lib/typescript/src/components/label/index.d.ts +28 -0
- package/lib/typescript/src/components/label/index.d.ts.map +1 -0
- package/lib/typescript/src/components/progress/index.d.ts +132 -0
- package/lib/typescript/src/components/progress/index.d.ts.map +1 -0
- package/lib/typescript/src/components/steps/index.d.ts +62 -0
- package/lib/typescript/src/components/steps/index.d.ts.map +1 -0
- package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
- package/lib/typescript/src/components/timeline/index.d.ts +96 -0
- package/lib/typescript/src/components/timeline/index.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/index.d.ts +176 -0
- package/lib/typescript/src/components/toast/index.d.ts.map +1 -0
- package/lib/typescript/src/components/toast/toast-store.d.ts +65 -0
- package/lib/typescript/src/components/toast/toast-store.d.ts.map +1 -0
- package/lib/typescript/src/components/typography/index.d.ts +77 -0
- package/lib/typescript/src/components/typography/index.d.ts.map +1 -0
- package/lib/typescript/src/icons/index.d.ts +60 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +13 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/providers/panel-ui-provider.d.ts.map +1 -1
- package/lib/typescript/src/theme/use-theme.d.ts +64 -4
- package/lib/typescript/src/theme/use-theme.d.ts.map +1 -1
- package/package.json +22 -4
- package/src/components/accordion/index.tsx +344 -0
- package/src/components/alert/index.tsx +102 -16
- package/src/components/avatar/index.tsx +68 -20
- package/src/components/badge/index.tsx +38 -9
- package/src/components/button/index.tsx +102 -19
- package/src/components/checkbox/index.tsx +64 -12
- package/src/components/empty-state/index.tsx +136 -0
- package/src/components/frame/index.tsx +101 -31
- package/src/components/input-group/index.tsx +164 -0
- package/src/components/label/index.tsx +128 -0
- package/src/components/progress/index.tsx +147 -0
- package/src/components/steps/index.tsx +343 -0
- package/src/components/tabs/index.tsx +10 -2
- package/src/components/timeline/index.tsx +456 -0
- package/src/components/toast/index.tsx +568 -0
- package/src/components/toast/toast-store.ts +120 -0
- package/src/components/typography/index.tsx +121 -0
- package/src/icons/index.tsx +423 -7
- package/src/index.ts +114 -4
- package/src/providers/panel-ui-provider.tsx +3 -0
- package/src/theme/use-theme.ts +119 -4
- package/theme.css +330 -7
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Toast — transient notification.
|
|
5
|
+
*
|
|
6
|
+
* Adapted from: heroui-inc/heroui-native src/components/toast/
|
|
7
|
+
* (the three usage patterns — string, config object, custom component — the
|
|
8
|
+
* Title / Description / Action / Close anatomy, placement, and swipe-to-
|
|
9
|
+
* dismiss). Styled with Coss UI tokens and PanelUI's Alert status palette.
|
|
10
|
+
*
|
|
11
|
+
* The viewport is mounted for you by PanelUIProvider; `useToast()` works
|
|
12
|
+
* anywhere below it.
|
|
13
|
+
*/
|
|
14
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useSyncExternalStore } from 'react';
|
|
15
|
+
import { View } from 'react-native';
|
|
16
|
+
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
17
|
+
import Animated, { Easing, Extrapolation, FadeInDown, FadeInUp, Keyframe, interpolate, runOnJS, useAnimatedStyle, useSharedValue, withDecay, withSpring, withTiming } from 'react-native-reanimated';
|
|
18
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
19
|
+
import { tv } from 'tailwind-variants';
|
|
20
|
+
import { useCSSVariable } from 'uniwind';
|
|
21
|
+
import { Portal } from "../../primitives/portal.js";
|
|
22
|
+
import { Text } from "../../primitives/text.js";
|
|
23
|
+
import { cn } from "../../utils/cn.js";
|
|
24
|
+
import { AlertTriangleIcon, CheckCircleIcon, InfoIcon, XIcon } from "../../icons/index.js";
|
|
25
|
+
import { Button } from "../button/index.js";
|
|
26
|
+
import { toast, toastStore } from "./toast-store.js";
|
|
27
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
const SPRING = {
|
|
29
|
+
damping: 20,
|
|
30
|
+
stiffness: 260,
|
|
31
|
+
mass: 0.6
|
|
32
|
+
};
|
|
33
|
+
/** Drag distance past which a release dismisses. */
|
|
34
|
+
const DISMISS_DISTANCE = 50;
|
|
35
|
+
/** Fling speed past which a release dismisses regardless of distance. */
|
|
36
|
+
const DISMISS_VELOCITY = 500;
|
|
37
|
+
/** How far a toast can be dragged away from its edge before it stops moving. */
|
|
38
|
+
const RUBBER_BAND_LIMIT = 40;
|
|
39
|
+
/** How far a toast travels on entry. Short, so the spring has little to settle. */
|
|
40
|
+
const ENTER_OFFSET = 100;
|
|
41
|
+
/** Newest toasts only; older ones fade out rather than stacking off-screen. */
|
|
42
|
+
const MAX_VISIBLE = 3;
|
|
43
|
+
/** How far each toast behind the front one peeks out. */
|
|
44
|
+
const STACK_OFFSET = 10;
|
|
45
|
+
/** Scale of the toast one step back in the deck. */
|
|
46
|
+
const STACK_SCALE_STEP = 0.97;
|
|
47
|
+
/** Gap between the deck and the screen edges, on top of the safe-area inset. */
|
|
48
|
+
const EDGE_INSET = 16;
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* Entering/exiting animations, from heroui-inc/heroui-native
|
|
52
|
+
* src/components/toast/toast.animation.ts.
|
|
53
|
+
*
|
|
54
|
+
* `mass(3)` is doing the important work: a heavy spring settles without the
|
|
55
|
+
* visible overshoot a default-mass one gives. `withInitialValues` keeps
|
|
56
|
+
* opacity at 1 so the toast slides rather than fades, and starts it
|
|
57
|
+
* ENTER_OFFSET px away instead of off-screen.
|
|
58
|
+
*/
|
|
59
|
+
const enteringTop = FadeInUp.springify().withInitialValues({
|
|
60
|
+
opacity: 1,
|
|
61
|
+
transform: [{
|
|
62
|
+
translateY: -ENTER_OFFSET
|
|
63
|
+
}]
|
|
64
|
+
}).mass(3);
|
|
65
|
+
const enteringBottom = FadeInDown.springify().withInitialValues({
|
|
66
|
+
opacity: 1,
|
|
67
|
+
transform: [{
|
|
68
|
+
translateY: ENTER_OFFSET
|
|
69
|
+
}]
|
|
70
|
+
}).mass(3);
|
|
71
|
+
const exitKeyframe = offset => new Keyframe({
|
|
72
|
+
0: {
|
|
73
|
+
opacity: 1,
|
|
74
|
+
transform: [{
|
|
75
|
+
translateY: 0
|
|
76
|
+
}, {
|
|
77
|
+
scale: 1
|
|
78
|
+
}]
|
|
79
|
+
},
|
|
80
|
+
100: {
|
|
81
|
+
opacity: 0.5,
|
|
82
|
+
transform: [{
|
|
83
|
+
translateY: offset
|
|
84
|
+
}, {
|
|
85
|
+
scale: 0.97
|
|
86
|
+
}],
|
|
87
|
+
easing: Easing.bezier(0.4, 0, 1, 1)
|
|
88
|
+
}
|
|
89
|
+
}).duration(150);
|
|
90
|
+
const exitingTop = exitKeyframe(-ENTER_OFFSET);
|
|
91
|
+
const exitingBottom = exitKeyframe(ENTER_OFFSET);
|
|
92
|
+
const toastVariants = tv({
|
|
93
|
+
slots: {
|
|
94
|
+
root: 'w-full flex-row items-start gap-3 rounded-2xl border px-4 py-3.5 shadow-lg',
|
|
95
|
+
indicator: 'pt-px',
|
|
96
|
+
content: 'flex-1 gap-0.5',
|
|
97
|
+
title: 'text-sm font-medium',
|
|
98
|
+
description: 'text-sm text-muted-foreground'
|
|
99
|
+
},
|
|
100
|
+
variants: {
|
|
101
|
+
variant: {
|
|
102
|
+
default: {
|
|
103
|
+
root: 'border-border bg-popover',
|
|
104
|
+
title: 'text-popover-foreground'
|
|
105
|
+
},
|
|
106
|
+
info: {
|
|
107
|
+
root: 'border-info/32 bg-popover',
|
|
108
|
+
title: 'text-info-foreground'
|
|
109
|
+
},
|
|
110
|
+
success: {
|
|
111
|
+
root: 'border-success/32 bg-popover',
|
|
112
|
+
title: 'text-success-foreground'
|
|
113
|
+
},
|
|
114
|
+
warning: {
|
|
115
|
+
root: 'border-warning/32 bg-popover',
|
|
116
|
+
title: 'text-warning-foreground'
|
|
117
|
+
},
|
|
118
|
+
destructive: {
|
|
119
|
+
root: 'border-destructive/32 bg-popover',
|
|
120
|
+
title: 'text-destructive-foreground'
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
defaultVariants: {
|
|
125
|
+
variant: 'default'
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const INDICATOR_COLOR_VAR = {
|
|
129
|
+
default: '--color-muted-foreground',
|
|
130
|
+
info: '--color-info-foreground',
|
|
131
|
+
success: '--color-success-foreground',
|
|
132
|
+
warning: '--color-warning-foreground',
|
|
133
|
+
destructive: '--color-destructive-foreground'
|
|
134
|
+
};
|
|
135
|
+
const INDICATOR_ICON = {
|
|
136
|
+
default: InfoIcon,
|
|
137
|
+
info: InfoIcon,
|
|
138
|
+
success: CheckCircleIcon,
|
|
139
|
+
warning: AlertTriangleIcon,
|
|
140
|
+
destructive: AlertTriangleIcon
|
|
141
|
+
};
|
|
142
|
+
const ToastContext = /*#__PURE__*/createContext({
|
|
143
|
+
variant: 'default',
|
|
144
|
+
hide: () => {}
|
|
145
|
+
});
|
|
146
|
+
/**
|
|
147
|
+
* Presentational toast surface. Render it yourself only for custom toasts —
|
|
148
|
+
* `toast.show(...)` builds one for you from a config object.
|
|
149
|
+
*/
|
|
150
|
+
const ToastRoot = ({
|
|
151
|
+
className,
|
|
152
|
+
variant = 'default',
|
|
153
|
+
onHide,
|
|
154
|
+
children,
|
|
155
|
+
...props
|
|
156
|
+
}) => {
|
|
157
|
+
const context = useMemo(() => ({
|
|
158
|
+
variant,
|
|
159
|
+
hide: onHide ?? (() => {})
|
|
160
|
+
}), [variant, onHide]);
|
|
161
|
+
const {
|
|
162
|
+
root
|
|
163
|
+
} = toastVariants({
|
|
164
|
+
variant
|
|
165
|
+
});
|
|
166
|
+
return /*#__PURE__*/_jsx(ToastContext.Provider, {
|
|
167
|
+
value: context,
|
|
168
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
169
|
+
accessibilityRole: "alert",
|
|
170
|
+
accessibilityLiveRegion: "polite",
|
|
171
|
+
className: root({
|
|
172
|
+
className
|
|
173
|
+
}),
|
|
174
|
+
...props,
|
|
175
|
+
children: children
|
|
176
|
+
})
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
ToastRoot.displayName = 'Toast';
|
|
180
|
+
const ToastIndicator = ({
|
|
181
|
+
className,
|
|
182
|
+
iconProps,
|
|
183
|
+
children,
|
|
184
|
+
...props
|
|
185
|
+
}) => {
|
|
186
|
+
const {
|
|
187
|
+
variant
|
|
188
|
+
} = useContext(ToastContext);
|
|
189
|
+
const {
|
|
190
|
+
indicator
|
|
191
|
+
} = toastVariants({
|
|
192
|
+
variant
|
|
193
|
+
});
|
|
194
|
+
const themeColor = useCSSVariable(INDICATOR_COLOR_VAR[variant]);
|
|
195
|
+
const Icon = INDICATOR_ICON[variant];
|
|
196
|
+
const color = iconProps?.color ?? (typeof themeColor === 'string' ? themeColor : undefined);
|
|
197
|
+
return /*#__PURE__*/_jsx(View, {
|
|
198
|
+
className: indicator({
|
|
199
|
+
className
|
|
200
|
+
}),
|
|
201
|
+
...props,
|
|
202
|
+
children: children ?? /*#__PURE__*/_jsx(Icon, {
|
|
203
|
+
size: iconProps?.size ?? 18,
|
|
204
|
+
color: color
|
|
205
|
+
})
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
ToastIndicator.displayName = 'Toast.Indicator';
|
|
209
|
+
const ToastContent = ({
|
|
210
|
+
className,
|
|
211
|
+
...props
|
|
212
|
+
}) => {
|
|
213
|
+
const {
|
|
214
|
+
variant
|
|
215
|
+
} = useContext(ToastContext);
|
|
216
|
+
const {
|
|
217
|
+
content
|
|
218
|
+
} = toastVariants({
|
|
219
|
+
variant
|
|
220
|
+
});
|
|
221
|
+
return /*#__PURE__*/_jsx(View, {
|
|
222
|
+
className: content({
|
|
223
|
+
className
|
|
224
|
+
}),
|
|
225
|
+
...props
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
ToastContent.displayName = 'Toast.Content';
|
|
229
|
+
const ToastTitle = ({
|
|
230
|
+
className,
|
|
231
|
+
...props
|
|
232
|
+
}) => {
|
|
233
|
+
const {
|
|
234
|
+
variant
|
|
235
|
+
} = useContext(ToastContext);
|
|
236
|
+
const {
|
|
237
|
+
title
|
|
238
|
+
} = toastVariants({
|
|
239
|
+
variant
|
|
240
|
+
});
|
|
241
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
242
|
+
className: cn(title(), className),
|
|
243
|
+
...props
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
ToastTitle.displayName = 'Toast.Title';
|
|
247
|
+
const ToastDescription = ({
|
|
248
|
+
className,
|
|
249
|
+
...props
|
|
250
|
+
}) => {
|
|
251
|
+
const {
|
|
252
|
+
variant
|
|
253
|
+
} = useContext(ToastContext);
|
|
254
|
+
const {
|
|
255
|
+
description
|
|
256
|
+
} = toastVariants({
|
|
257
|
+
variant
|
|
258
|
+
});
|
|
259
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
260
|
+
className: cn(description(), className),
|
|
261
|
+
...props
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
ToastDescription.displayName = 'Toast.Description';
|
|
265
|
+
|
|
266
|
+
/** Trailing action button. Defaults to a subtle variant that reads on the popover surface. */
|
|
267
|
+
const ToastAction = ({
|
|
268
|
+
variant = 'secondary',
|
|
269
|
+
size = 'sm',
|
|
270
|
+
onPress,
|
|
271
|
+
...props
|
|
272
|
+
}) => {
|
|
273
|
+
const {
|
|
274
|
+
hide
|
|
275
|
+
} = useContext(ToastContext);
|
|
276
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
277
|
+
variant: variant,
|
|
278
|
+
size: size,
|
|
279
|
+
onPress: event => {
|
|
280
|
+
onPress?.(event);
|
|
281
|
+
hide();
|
|
282
|
+
},
|
|
283
|
+
...props
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
ToastAction.displayName = 'Toast.Action';
|
|
287
|
+
const ToastClose = ({
|
|
288
|
+
className,
|
|
289
|
+
...props
|
|
290
|
+
}) => {
|
|
291
|
+
const {
|
|
292
|
+
hide
|
|
293
|
+
} = useContext(ToastContext);
|
|
294
|
+
const color = useCSSVariable('--color-muted-foreground');
|
|
295
|
+
return /*#__PURE__*/_jsx(View, {
|
|
296
|
+
className: cn('pt-px', className),
|
|
297
|
+
...props,
|
|
298
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
299
|
+
variant: "ghost",
|
|
300
|
+
size: "icon",
|
|
301
|
+
accessibilityLabel: "Dismiss notification",
|
|
302
|
+
className: "h-6 w-6 rounded-full",
|
|
303
|
+
onPress: hide,
|
|
304
|
+
children: /*#__PURE__*/_jsx(XIcon, {
|
|
305
|
+
size: 14,
|
|
306
|
+
color: typeof color === 'string' ? color : undefined
|
|
307
|
+
})
|
|
308
|
+
})
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
ToastClose.displayName = 'Toast.Close';
|
|
312
|
+
export const Toast = Object.assign(ToastRoot, {
|
|
313
|
+
Indicator: ToastIndicator,
|
|
314
|
+
Content: ToastContent,
|
|
315
|
+
Title: ToastTitle,
|
|
316
|
+
Description: ToastDescription,
|
|
317
|
+
Action: ToastAction,
|
|
318
|
+
Close: ToastClose
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
/* -------------------------------------------------------------------------- */
|
|
322
|
+
/* Viewport */
|
|
323
|
+
/* -------------------------------------------------------------------------- */
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* One queued toast.
|
|
327
|
+
*
|
|
328
|
+
* The entering spring is deliberately heavy (`mass(3)`) and travels only
|
|
329
|
+
* ENTER_OFFSET px rather than the full screen height. A default-mass spring
|
|
330
|
+
* across that distance overshoots visibly — it reads as a bounce, and arrives
|
|
331
|
+
* too fast to follow.
|
|
332
|
+
*
|
|
333
|
+
* Swiping is vertical and direction-aware: dragging toward the screen edge the
|
|
334
|
+
* toast came from dismisses it, dragging the other way rubber-bands against a
|
|
335
|
+
* hard limit. Matches heroui-native's toast.animation.ts.
|
|
336
|
+
*/
|
|
337
|
+
function ToastSlot({
|
|
338
|
+
item,
|
|
339
|
+
index,
|
|
340
|
+
total,
|
|
341
|
+
frontId,
|
|
342
|
+
heights
|
|
343
|
+
}) {
|
|
344
|
+
const placement = item.placement ?? 'bottom';
|
|
345
|
+
const translateY = useSharedValue(0);
|
|
346
|
+
const scale = useSharedValue(1);
|
|
347
|
+
const hide = useCallback(() => toastStore.hide(item.id), [item.id]);
|
|
348
|
+
|
|
349
|
+
// Drop this toast's measurement when it leaves, so the map cannot grow
|
|
350
|
+
// without bound over a long session.
|
|
351
|
+
useEffect(() => () => {
|
|
352
|
+
heights.modify(value => {
|
|
353
|
+
'worklet';
|
|
354
|
+
|
|
355
|
+
const next = {
|
|
356
|
+
...value
|
|
357
|
+
};
|
|
358
|
+
delete next[item.id];
|
|
359
|
+
return next;
|
|
360
|
+
});
|
|
361
|
+
}, [heights, item.id]);
|
|
362
|
+
|
|
363
|
+
/** +1 when a downward drag dismisses (bottom), -1 when an upward one does. */
|
|
364
|
+
const dismissSign = placement === 'top' ? -1 : 1;
|
|
365
|
+
const pan = Gesture.Pan().activeOffsetY([-12, 12]).onBegin(() => {
|
|
366
|
+
scale.value = withTiming(0.995, {
|
|
367
|
+
duration: 120
|
|
368
|
+
});
|
|
369
|
+
}).onChange(event => {
|
|
370
|
+
const next = translateY.value + event.changeY;
|
|
371
|
+
// Toward the edge: follow the finger. Away from it: rubber-band, so the
|
|
372
|
+
// toast never detaches from where it belongs.
|
|
373
|
+
translateY.value = next * dismissSign > 0 ? next : interpolate(Math.abs(next), [0, 400], [0, RUBBER_BAND_LIMIT], Extrapolation.CLAMP) * -dismissSign;
|
|
374
|
+
}).onFinalize(event => {
|
|
375
|
+
scale.value = withTiming(1, {
|
|
376
|
+
duration: 120
|
|
377
|
+
});
|
|
378
|
+
const towardEdge = translateY.value * dismissSign > 0;
|
|
379
|
+
const shouldDismiss = towardEdge && (Math.abs(translateY.value) > DISMISS_DISTANCE || Math.abs(event.velocityY) > DISMISS_VELOCITY);
|
|
380
|
+
if (shouldDismiss) {
|
|
381
|
+
// Carry the flick's momentum instead of stopping dead, clamped so it
|
|
382
|
+
// can only continue toward the edge.
|
|
383
|
+
translateY.value = withDecay({
|
|
384
|
+
velocity: event.velocityY * 1.5,
|
|
385
|
+
clamp: dismissSign > 0 ? [0, Number.POSITIVE_INFINITY] : [Number.NEGATIVE_INFINITY, 0]
|
|
386
|
+
});
|
|
387
|
+
runOnJS(hide)();
|
|
388
|
+
} else {
|
|
389
|
+
translateY.value = withSpring(0, SPRING);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
/** Older toasts slide away from the edge the stack is pinned to. */
|
|
394
|
+
const stackSign = placement === 'top' ? 1 : -1;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Stack position plus the gesture transform.
|
|
398
|
+
*
|
|
399
|
+
* The whole deck takes the *newest* toast's height so the cards behind read
|
|
400
|
+
* as a uniform stack rather than a ragged pile — matching heroui-native.
|
|
401
|
+
*/
|
|
402
|
+
const stackStyle = useAnimatedStyle(() => {
|
|
403
|
+
// Fall back to this toast's own height until the front one is measured.
|
|
404
|
+
const frontHeight = heights.value[frontId] ?? heights.value[item.id];
|
|
405
|
+
|
|
406
|
+
// Newest sits at 0; each one behind steps back by STACK_OFFSET and shrinks.
|
|
407
|
+
const inputRange = [total - 1, total - 2];
|
|
408
|
+
const offset = interpolate(index, inputRange, [0, STACK_OFFSET * stackSign], {
|
|
409
|
+
extrapolateLeft: Extrapolation.CLAMP
|
|
410
|
+
});
|
|
411
|
+
const stackScale = interpolate(index, inputRange, [1, STACK_SCALE_STEP], {
|
|
412
|
+
extrapolateLeft: Extrapolation.CLAMP
|
|
413
|
+
});
|
|
414
|
+
// Anything past MAX_VISIBLE fades out rather than piling up forever.
|
|
415
|
+
const opacity = interpolate(index, [total - MAX_VISIBLE, total - MAX_VISIBLE - 1], [1, 0], Extrapolation.CLAMP);
|
|
416
|
+
return {
|
|
417
|
+
opacity,
|
|
418
|
+
height: frontHeight,
|
|
419
|
+
transform: [{
|
|
420
|
+
translateY: offset + translateY.value
|
|
421
|
+
}, {
|
|
422
|
+
scale: stackScale * scale.value
|
|
423
|
+
}]
|
|
424
|
+
};
|
|
425
|
+
});
|
|
426
|
+
const handle = {
|
|
427
|
+
id: item.id,
|
|
428
|
+
hide
|
|
429
|
+
};
|
|
430
|
+
const content = item.component ? item.component(handle) : /*#__PURE__*/_jsxs(Toast, {
|
|
431
|
+
variant: item.variant ?? 'default',
|
|
432
|
+
onHide: hide,
|
|
433
|
+
children: [item.icon === null ? null : /*#__PURE__*/_jsx(Toast.Indicator, {
|
|
434
|
+
children: item.icon ?? undefined
|
|
435
|
+
}), /*#__PURE__*/_jsxs(Toast.Content, {
|
|
436
|
+
children: [item.label ? /*#__PURE__*/_jsx(Toast.Title, {
|
|
437
|
+
children: item.label
|
|
438
|
+
}) : null, item.description ? /*#__PURE__*/_jsx(Toast.Description, {
|
|
439
|
+
children: item.description
|
|
440
|
+
}) : null]
|
|
441
|
+
}), item.actionLabel ? /*#__PURE__*/_jsx(Toast.Action, {
|
|
442
|
+
onPress: () => item.onActionPress?.(handle),
|
|
443
|
+
children: item.actionLabel
|
|
444
|
+
}) : null, item.closable ?? !item.actionLabel ? /*#__PURE__*/_jsx(Toast.Close, {}) : null]
|
|
445
|
+
});
|
|
446
|
+
return /*#__PURE__*/_jsxs(Animated.View, {
|
|
447
|
+
entering: placement === 'top' ? enteringTop : enteringBottom,
|
|
448
|
+
exiting: placement === 'top' ? exitingTop : exitingBottom,
|
|
449
|
+
pointerEvents: "box-none"
|
|
450
|
+
// Every toast is pinned to the same edge, so they overlap as a deck.
|
|
451
|
+
// Newest on top. Horizontal inset lives here rather than as padding on
|
|
452
|
+
// the anchor: Yoga positions absolute children against the border box,
|
|
453
|
+
// so padding on the parent would not move them.
|
|
454
|
+
,
|
|
455
|
+
className: "absolute",
|
|
456
|
+
style: {
|
|
457
|
+
left: EDGE_INSET,
|
|
458
|
+
right: EDGE_INSET,
|
|
459
|
+
[placement === 'top' ? 'top' : 'bottom']: 0,
|
|
460
|
+
zIndex: index
|
|
461
|
+
},
|
|
462
|
+
children: [/*#__PURE__*/_jsx(GestureDetector, {
|
|
463
|
+
gesture: pan,
|
|
464
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
465
|
+
style: stackStyle,
|
|
466
|
+
children: content
|
|
467
|
+
})
|
|
468
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
469
|
+
pointerEvents: "none",
|
|
470
|
+
accessibilityElementsHidden: true,
|
|
471
|
+
importantForAccessibility: "no-hide-descendants",
|
|
472
|
+
className: "absolute left-0 right-0 opacity-0",
|
|
473
|
+
onLayout: event => {
|
|
474
|
+
const measured = event.nativeEvent.layout.height;
|
|
475
|
+
heights.modify(value => {
|
|
476
|
+
'worklet';
|
|
477
|
+
|
|
478
|
+
if (value[item.id] === measured) return value;
|
|
479
|
+
return {
|
|
480
|
+
...value,
|
|
481
|
+
[item.id]: measured
|
|
482
|
+
};
|
|
483
|
+
});
|
|
484
|
+
},
|
|
485
|
+
children: content
|
|
486
|
+
})]
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* The deck for one edge of the screen.
|
|
492
|
+
*
|
|
493
|
+
* Toasts are not laid out in flow — each one is absolutely pinned to the same
|
|
494
|
+
* edge and offset by its stack position, so they overlap like a deck of cards
|
|
495
|
+
* with only the newest fully visible.
|
|
496
|
+
*/
|
|
497
|
+
function ToastStack({
|
|
498
|
+
items,
|
|
499
|
+
placement
|
|
500
|
+
}) {
|
|
501
|
+
const insets = useSafeAreaInsets();
|
|
502
|
+
// Natural heights, keyed by toast id. Written from the UI thread by each
|
|
503
|
+
// slot's hidden measuring copy.
|
|
504
|
+
const heights = useSharedValue({});
|
|
505
|
+
if (items.length === 0) return null;
|
|
506
|
+
|
|
507
|
+
// Keep a couple beyond MAX_VISIBLE mounted so the ones fading out still
|
|
508
|
+
// animate rather than popping.
|
|
509
|
+
const visible = items.slice(-(MAX_VISIBLE + 1));
|
|
510
|
+
const frontId = visible[visible.length - 1].id;
|
|
511
|
+
return (
|
|
512
|
+
/*#__PURE__*/
|
|
513
|
+
// A zero-height anchor sitting at the safe-area edge. The toasts hang off
|
|
514
|
+
// it — upward for bottom placement, downward for top — so the inset is
|
|
515
|
+
// part of the anchor's position rather than padding, which Yoga would
|
|
516
|
+
// ignore for absolutely positioned children.
|
|
517
|
+
_jsx(View, {
|
|
518
|
+
pointerEvents: "box-none",
|
|
519
|
+
className: "absolute left-0 right-0",
|
|
520
|
+
style: {
|
|
521
|
+
[placement === 'top' ? 'top' : 'bottom']: (placement === 'top' ? insets.top : insets.bottom) + EDGE_INSET,
|
|
522
|
+
height: 0
|
|
523
|
+
},
|
|
524
|
+
children: visible.map((item, index) => /*#__PURE__*/_jsx(ToastSlot, {
|
|
525
|
+
item: item,
|
|
526
|
+
index: index,
|
|
527
|
+
total: visible.length,
|
|
528
|
+
frontId: frontId,
|
|
529
|
+
heights: heights
|
|
530
|
+
}, item.id))
|
|
531
|
+
})
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Renders the toast queue. PanelUIProvider mounts this automatically — you
|
|
537
|
+
* only need it directly if you build your own provider.
|
|
538
|
+
*/
|
|
539
|
+
export function ToastViewport() {
|
|
540
|
+
const items = useSyncExternalStore(toastStore.subscribe, toastStore.getSnapshot);
|
|
541
|
+
if (items.length === 0) return null;
|
|
542
|
+
const top = items.filter(item => item.placement === 'top');
|
|
543
|
+
const bottom = items.filter(item => item.placement !== 'top');
|
|
544
|
+
return /*#__PURE__*/_jsxs(Portal, {
|
|
545
|
+
children: [/*#__PURE__*/_jsx(ToastStack, {
|
|
546
|
+
items: top,
|
|
547
|
+
placement: "top"
|
|
548
|
+
}), /*#__PURE__*/_jsx(ToastStack, {
|
|
549
|
+
items: bottom,
|
|
550
|
+
placement: "bottom"
|
|
551
|
+
})]
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Access the toast API.
|
|
557
|
+
*
|
|
558
|
+
* ```tsx
|
|
559
|
+
* const { toast } = useToast();
|
|
560
|
+
* toast.show({ variant: 'success', label: 'Saved' });
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
export function useToast() {
|
|
564
|
+
return {
|
|
565
|
+
toast
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
export { toast };
|
|
569
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useCallback","useContext","useEffect","useMemo","useSyncExternalStore","View","Gesture","GestureDetector","Animated","Easing","Extrapolation","FadeInDown","FadeInUp","Keyframe","interpolate","runOnJS","useAnimatedStyle","useSharedValue","withDecay","withSpring","withTiming","useSafeAreaInsets","tv","useCSSVariable","Portal","Text","cn","AlertTriangleIcon","CheckCircleIcon","InfoIcon","XIcon","Button","toast","toastStore","jsx","_jsx","jsxs","_jsxs","SPRING","damping","stiffness","mass","DISMISS_DISTANCE","DISMISS_VELOCITY","RUBBER_BAND_LIMIT","ENTER_OFFSET","MAX_VISIBLE","STACK_OFFSET","STACK_SCALE_STEP","EDGE_INSET","enteringTop","springify","withInitialValues","opacity","transform","translateY","enteringBottom","exitKeyframe","offset","scale","easing","bezier","duration","exitingTop","exitingBottom","toastVariants","slots","root","indicator","content","title","description","variants","variant","default","info","success","warning","destructive","defaultVariants","INDICATOR_COLOR_VAR","INDICATOR_ICON","ToastContext","hide","ToastRoot","className","onHide","children","props","context","Provider","value","accessibilityRole","accessibilityLiveRegion","displayName","ToastIndicator","iconProps","themeColor","Icon","color","undefined","size","ToastContent","ToastTitle","ToastDescription","ToastAction","onPress","event","ToastClose","accessibilityLabel","Toast","Object","assign","Indicator","Content","Title","Description","Action","Close","ToastSlot","item","index","total","frontId","heights","placement","id","modify","next","dismissSign","pan","Pan","activeOffsetY","onBegin","onChange","changeY","Math","abs","CLAMP","onFinalize","towardEdge","shouldDismiss","velocityY","velocity","clamp","Number","POSITIVE_INFINITY","NEGATIVE_INFINITY","stackSign","stackStyle","frontHeight","inputRange","extrapolateLeft","stackScale","height","handle","component","icon","label","actionLabel","onActionPress","closable","entering","exiting","pointerEvents","style","left","right","zIndex","gesture","accessibilityElementsHidden","importantForAccessibility","onLayout","measured","nativeEvent","layout","ToastStack","items","insets","length","visible","slice","top","bottom","map","ToastViewport","subscribe","getSnapshot","filter","useToast"],"sourceRoot":"../../../../src","sources":["components/toast/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,oBAAoB,QAEf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,UAAU,CAAC0J,WAAW,CAAC;EAEhF,IAAIV,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE,OAAO,IAAI;EAEnC,MAAMG,GAAG,GAAGL,KAAK,CAACW,MAAM,CAAEpE,IAAI,IAAKA,IAAI,CAACK,SAAS,KAAK,KAAK,CAAC;EAC5D,MAAM0D,MAAM,GAAGN,KAAK,CAACW,MAAM,CAAEpE,IAAI,IAAKA,IAAI,CAACK,SAAS,KAAK,KAAK,CAAC;EAE/D,oBACExF,KAAA,CAACb,MAAM;IAAA+D,QAAA,gBACLpD,IAAA,CAAC6I,UAAU;MAACC,KAAK,EAAEK,GAAI;MAACzD,SAAS,EAAC;IAAK,CAAE,CAAC,eAC1C1F,IAAA,CAAC6I,UAAU;MAACC,KAAK,EAAEM,MAAO;MAAC1D,SAAS,EAAC;IAAQ,CAAE,CAAC;EAAA,CAC1C,CAAC;AAEb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgE,QAAQA,CAAA,EAAG;EACzB,OAAO;IAAE7J;EAAM,CAAC;AAClB;AAEA,SAASA,KAAK","ignoreList":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Toast queue.
|
|
5
|
+
*
|
|
6
|
+
* A module-level store rather than React state, so `toast.show()` works from
|
|
7
|
+
* anywhere — event handlers, API clients, code outside the component tree —
|
|
8
|
+
* without threading a context through. The viewport subscribes with
|
|
9
|
+
* `useSyncExternalStore`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** Handle given to action callbacks so they can dismiss their own toast. */
|
|
13
|
+
|
|
14
|
+
const DEFAULT_DURATION = 4000;
|
|
15
|
+
let counter = 0;
|
|
16
|
+
class ToastStore {
|
|
17
|
+
items = [];
|
|
18
|
+
snapshot = this.items;
|
|
19
|
+
listeners = new Set();
|
|
20
|
+
timers = new Map();
|
|
21
|
+
subscribe = listener => {
|
|
22
|
+
this.listeners.add(listener);
|
|
23
|
+
return () => {
|
|
24
|
+
this.listeners.delete(listener);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
getSnapshot = () => this.snapshot;
|
|
28
|
+
show = options => {
|
|
29
|
+
const resolved = typeof options === 'string' ? {
|
|
30
|
+
label: options
|
|
31
|
+
} : options;
|
|
32
|
+
const id = `toast-${++counter}`;
|
|
33
|
+
this.items = [...this.items, {
|
|
34
|
+
...resolved,
|
|
35
|
+
id
|
|
36
|
+
}];
|
|
37
|
+
this.emit();
|
|
38
|
+
const duration = resolved.duration ?? DEFAULT_DURATION;
|
|
39
|
+
if (duration > 0) {
|
|
40
|
+
this.timers.set(id, setTimeout(() => this.hide(id), duration));
|
|
41
|
+
}
|
|
42
|
+
return id;
|
|
43
|
+
};
|
|
44
|
+
hide = id => {
|
|
45
|
+
const timer = this.timers.get(id);
|
|
46
|
+
if (timer) {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
this.timers.delete(id);
|
|
49
|
+
}
|
|
50
|
+
if (!this.items.some(item => item.id === id)) return;
|
|
51
|
+
this.items = this.items.filter(item => item.id !== id);
|
|
52
|
+
this.emit();
|
|
53
|
+
};
|
|
54
|
+
hideAll = () => {
|
|
55
|
+
this.timers.forEach(clearTimeout);
|
|
56
|
+
this.timers.clear();
|
|
57
|
+
if (this.items.length === 0) return;
|
|
58
|
+
this.items = [];
|
|
59
|
+
this.emit();
|
|
60
|
+
};
|
|
61
|
+
emit() {
|
|
62
|
+
this.snapshot = this.items;
|
|
63
|
+
this.listeners.forEach(listener => listener());
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export const toastStore = new ToastStore();
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Imperative toast API. Also returned from `useToast()`.
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* toast.show('Saved');
|
|
73
|
+
* toast.show({ variant: 'success', label: 'Deployed', actionLabel: 'View' });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export const toast = {
|
|
77
|
+
show: toastStore.show,
|
|
78
|
+
hide: toastStore.hide,
|
|
79
|
+
hideAll: toastStore.hideAll
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=toast-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_DURATION","counter","ToastStore","items","snapshot","listeners","Set","timers","Map","subscribe","listener","add","delete","getSnapshot","show","options","resolved","label","id","emit","duration","set","setTimeout","hide","timer","get","clearTimeout","some","item","filter","hideAll","forEach","clear","length","toastStore","toast"],"sourceRoot":"../../../../src","sources":["components/toast/toast-store.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;;AA6BA,MAAMA,gBAAgB,GAAG,IAAI;AAE7B,IAAIC,OAAO,GAAG,CAAC;AAEf,MAAMC,UAAU,CAAC;EACPC,KAAK,GAAgB,EAAE;EACvBC,QAAQ,GAAyB,IAAI,CAACD,KAAK;EAC3CE,SAAS,GAAG,IAAIC,GAAG,CAAa,CAAC;EACjCC,MAAM,GAAG,IAAIC,GAAG,CAAwC,CAAC;EAEjEC,SAAS,GAAIC,QAAoB,IAAK;IACpC,IAAI,CAACL,SAAS,CAACM,GAAG,CAACD,QAAQ,CAAC;IAC5B,OAAO,MAAM;MACX,IAAI,CAACL,SAAS,CAACO,MAAM,CAACF,QAAQ,CAAC;IACjC,CAAC;EACH,CAAC;EAEDG,WAAW,GAAGA,CAAA,KAA4B,IAAI,CAACT,QAAQ;EAEvDU,IAAI,GAAIC,OAA8B,IAAa;IACjD,MAAMC,QAAsB,GAC1B,OAAOD,OAAO,KAAK,QAAQ,GAAG;MAAEE,KAAK,EAAEF;IAAQ,CAAC,GAAGA,OAAO;IAC5D,MAAMG,EAAE,GAAG,SAAS,EAAEjB,OAAO,EAAE;IAE/B,IAAI,CAACE,KAAK,GAAG,CAAC,GAAG,IAAI,CAACA,KAAK,EAAE;MAAE,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