@xaui/native 0.0.26 → 0.0.28

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 (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -228
  3. package/dist/alert/index.cjs +92 -166
  4. package/dist/alert/index.js +2 -1
  5. package/dist/app-bar/index.cjs +24 -98
  6. package/dist/app-bar/index.js +2 -1
  7. package/dist/autocomplete/index.cjs +192 -281
  8. package/dist/autocomplete/index.js +36 -48
  9. package/dist/avatar/index.cjs +59 -133
  10. package/dist/avatar/index.js +2 -1
  11. package/dist/badge/index.cjs +26 -99
  12. package/dist/badge/index.js +2 -1
  13. package/dist/bottom-sheet/index.cjs +5 -456
  14. package/dist/bottom-sheet/index.js +4 -363
  15. package/dist/bottom-tab-bar/index.cjs +93 -167
  16. package/dist/bottom-tab-bar/index.js +2 -2
  17. package/dist/button/index.cjs +73 -525
  18. package/dist/button/index.js +3 -2
  19. package/dist/card/index.cjs +76 -169
  20. package/dist/card/index.js +2 -2
  21. package/dist/carousel/index.cjs +68 -145
  22. package/dist/carousel/index.js +1 -1
  23. package/dist/chart/index.cjs +132 -173
  24. package/dist/checkbox/index.cjs +70 -143
  25. package/dist/checkbox/index.js +2 -1
  26. package/dist/chip/index.cjs +89 -164
  27. package/dist/chip/index.js +2 -1
  28. package/dist/chunk-BD72HIPR.cjs +75 -0
  29. package/dist/chunk-DHSTKO3K.cjs +19 -0
  30. package/dist/{chunk-CZFDZPAS.js → chunk-DXXNBF5P.js} +5 -0
  31. package/dist/{chunk-UI5L26KD.js → chunk-F7WH4DMG.js} +1 -1
  32. package/dist/chunk-GBHQCAKW.js +19 -0
  33. package/dist/chunk-HC2SSHNU.js +368 -0
  34. package/dist/chunk-HSPTLUFA.cjs +7 -0
  35. package/dist/chunk-JEGEPGVU.js +287 -0
  36. package/dist/chunk-KTLGDLCB.cjs +287 -0
  37. package/dist/{chunk-GHCVNQET.js → chunk-LTKYHG5V.js} +5 -12
  38. package/dist/{chunk-ULJSCNPE.js → chunk-LUBWRVI2.js} +1 -1
  39. package/dist/chunk-OQ2BLOOG.cjs +138 -0
  40. package/dist/chunk-QMYWIWSX.cjs +384 -0
  41. package/dist/chunk-XFPPR2VB.cjs +368 -0
  42. package/dist/core/index.cjs +22 -168
  43. package/dist/core/index.d.cts +1 -1
  44. package/dist/core/index.d.ts +1 -1
  45. package/dist/core/index.js +5 -3
  46. package/dist/datepicker/index.cjs +239 -320
  47. package/dist/datepicker/index.js +2 -1
  48. package/dist/divider/index.cjs +5 -145
  49. package/dist/divider/index.js +3 -2
  50. package/dist/drawer/index.cjs +39 -112
  51. package/dist/drawer/index.js +2 -1
  52. package/dist/expansion-panel/index.cjs +91 -230
  53. package/dist/expansion-panel/index.js +3 -2
  54. package/dist/fab/index.cjs +6 -722
  55. package/dist/fab/index.js +4 -3
  56. package/dist/fab-menu/index.cjs +81 -814
  57. package/dist/fab-menu/index.js +4 -3
  58. package/dist/feature-discovery/index.cjs +72 -139
  59. package/dist/feature-discovery/index.js +2 -2
  60. package/dist/index.cjs +1 -18
  61. package/dist/indicator/index.cjs +5 -445
  62. package/dist/indicator/index.js +3 -2
  63. package/dist/input/index.cjs +214 -282
  64. package/dist/input/index.js +2 -2
  65. package/dist/list/index.cjs +71 -146
  66. package/dist/list/index.js +2 -1
  67. package/dist/menu/index.cjs +59 -127
  68. package/dist/menu/index.js +2 -2
  69. package/dist/menubox/index.cjs +60 -132
  70. package/dist/menubox/index.js +2 -1
  71. package/dist/pager/index.cjs +42 -80
  72. package/dist/progress/index.cjs +43 -114
  73. package/dist/progress/index.js +2 -1
  74. package/dist/radio/index.cjs +82 -154
  75. package/dist/radio/index.js +2 -1
  76. package/dist/segment-button/index.cjs +60 -147
  77. package/dist/segment-button/index.js +2 -2
  78. package/dist/select/index.cjs +149 -224
  79. package/dist/select/index.js +10 -22
  80. package/dist/skeleton/index.cjs +23 -94
  81. package/dist/skeleton/index.js +2 -2
  82. package/dist/slider/index.cjs +77 -156
  83. package/dist/slider/index.js +2 -1
  84. package/dist/snackbar/index.cjs +420 -0
  85. package/dist/snackbar/index.d.cts +175 -0
  86. package/dist/snackbar/index.d.ts +175 -0
  87. package/dist/snackbar/index.js +420 -0
  88. package/dist/stepper/index.cjs +121 -195
  89. package/dist/stepper/index.js +2 -1
  90. package/dist/switch/index.cjs +48 -121
  91. package/dist/switch/index.js +2 -1
  92. package/dist/tabs/index.cjs +67 -151
  93. package/dist/tabs/index.js +2 -1
  94. package/dist/timepicker/index.cjs +135 -593
  95. package/dist/timepicker/index.js +24 -383
  96. package/dist/toolbar/index.cjs +59 -128
  97. package/dist/toolbar/index.js +2 -1
  98. package/dist/typography/index.cjs +37 -92
  99. package/dist/typography/index.d.cts +1 -1
  100. package/dist/typography/index.d.ts +1 -1
  101. package/dist/typography/index.js +20 -1
  102. package/dist/view/index.cjs +178 -223
  103. package/package.json +7 -1
  104. package/dist/chunk-3XSXTM3G.js +0 -661
  105. package/dist/chunk-4KSZLONZ.js +0 -79
  106. package/dist/chunk-I4V5Y5GD.js +0 -76
  107. package/dist/chunk-URBEEDFX.js +0 -79
@@ -0,0 +1,175 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { ViewStyle, TextStyle } from 'react-native';
3
+
4
+ type ThemeColor = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'success' | 'default';
5
+
6
+ type SnackbarPosition = 'top' | 'bottom';
7
+ type SnackbarCustomAppearance = {
8
+ /**
9
+ * Custom style for the snackbar surface.
10
+ */
11
+ container?: ViewStyle;
12
+ /**
13
+ * Custom style for the message text.
14
+ */
15
+ message?: TextStyle;
16
+ /**
17
+ * Custom style for the action label text.
18
+ */
19
+ action?: TextStyle;
20
+ /**
21
+ * Custom style for the close affordance button.
22
+ */
23
+ closeButton?: ViewStyle;
24
+ };
25
+ type SnackbarBaseProps = {
26
+ /**
27
+ * Message content shown inside the snackbar.
28
+ */
29
+ message: ReactNode;
30
+ /**
31
+ * Action content displayed at the end of the snackbar.
32
+ */
33
+ actionLabel?: ReactNode;
34
+ /**
35
+ * Callback fired when the action is pressed.
36
+ */
37
+ onActionPress?: () => void;
38
+ /**
39
+ * If true, pressing the action also dismisses the snackbar.
40
+ * @default true
41
+ */
42
+ closeOnActionPress?: boolean;
43
+ /**
44
+ * If true, shows the close affordance icon button.
45
+ * @default false
46
+ */
47
+ showCloseAffordance?: boolean;
48
+ /**
49
+ * Theme color for the snackbar. The default uses Material 3 inverse surface styling.
50
+ * @default 'default'
51
+ */
52
+ themeColor?: ThemeColor;
53
+ /**
54
+ * Number of lines for the message text.
55
+ * @default 2
56
+ */
57
+ numberOfLines?: number;
58
+ /**
59
+ * Custom appearance styles for snackbar parts.
60
+ */
61
+ customAppearance?: SnackbarCustomAppearance;
62
+ };
63
+ type SnackbarProps = SnackbarBaseProps & {
64
+ /**
65
+ * Controls snackbar visibility. If omitted, snackbar is shown by default.
66
+ * @default true
67
+ */
68
+ isVisible?: boolean;
69
+ /**
70
+ * Duration in milliseconds before auto-dismiss. Set to 0 or a negative value to disable.
71
+ * @default 4000
72
+ */
73
+ duration?: number;
74
+ /**
75
+ * Callback fired when the snackbar is dismissed.
76
+ */
77
+ onClose?: () => void;
78
+ /**
79
+ * Callback fired when visibility changes.
80
+ */
81
+ onVisibleChange?: (isVisible: boolean) => void;
82
+ /**
83
+ * Position of the snackbar on screen.
84
+ * @default 'bottom'
85
+ */
86
+ position?: SnackbarPosition;
87
+ /**
88
+ * Horizontal inset from screen edges.
89
+ * @default 16
90
+ */
91
+ insetHorizontal?: number;
92
+ /**
93
+ * Vertical inset from screen edge according to position.
94
+ * @default 16
95
+ */
96
+ insetVertical?: number;
97
+ /**
98
+ * Maximum width of the snackbar surface.
99
+ * @default 640
100
+ */
101
+ maxWidth?: number;
102
+ /**
103
+ * Render snackbar in a portal overlay.
104
+ * @default true
105
+ */
106
+ usePortal?: boolean;
107
+ };
108
+ type SnackbarItem = SnackbarBaseProps & {
109
+ /**
110
+ * Unique identifier for the snackbar item in the stack.
111
+ */
112
+ id: string;
113
+ /**
114
+ * Item-specific auto-dismiss duration in milliseconds.
115
+ * Set to 0 or a negative value to disable.
116
+ */
117
+ duration?: number;
118
+ };
119
+ type SnackbarStackProps = {
120
+ /**
121
+ * Snackbar items to render in a vertical stack.
122
+ */
123
+ items: SnackbarItem[];
124
+ /**
125
+ * Called when an item requests dismissal.
126
+ */
127
+ onDismiss?: (id: string) => void;
128
+ /**
129
+ * Position of the stacked snackbars on screen.
130
+ * @default 'bottom'
131
+ */
132
+ position?: SnackbarPosition;
133
+ /**
134
+ * Space between stacked snackbars.
135
+ * @default 8
136
+ */
137
+ spacing?: number;
138
+ /**
139
+ * Horizontal inset from screen edges.
140
+ * @default 16
141
+ */
142
+ insetHorizontal?: number;
143
+ /**
144
+ * Vertical inset from screen edge according to position.
145
+ * @default 16
146
+ */
147
+ insetVertical?: number;
148
+ /**
149
+ * Maximum width of each snackbar surface.
150
+ * @default 640
151
+ */
152
+ maxWidth?: number;
153
+ /**
154
+ * Default auto-dismiss duration for items without `duration`.
155
+ * @default 4000
156
+ */
157
+ defaultDuration?: number;
158
+ /**
159
+ * Render stack in a portal overlay.
160
+ * @default true
161
+ */
162
+ usePortal?: boolean;
163
+ /**
164
+ * Custom styles for stack containers.
165
+ */
166
+ customAppearance?: {
167
+ container?: ViewStyle;
168
+ content?: ViewStyle;
169
+ };
170
+ };
171
+
172
+ declare const SnackbarStack: React.FC<SnackbarStackProps>;
173
+ declare const Snackbar: React.FC<SnackbarProps>;
174
+
175
+ export { Snackbar, type SnackbarItem, type SnackbarPosition, type SnackbarProps, SnackbarStack, type SnackbarStackProps };
@@ -0,0 +1,420 @@
1
+ import "../chunk-DXXNBF5P.js";
2
+ import {
3
+ Portal,
4
+ useXUITheme
5
+ } from "../chunk-LTKYHG5V.js";
6
+
7
+ // src/components/snackbar/snackbar.tsx
8
+ import React, {
9
+ isValidElement,
10
+ useCallback,
11
+ useEffect,
12
+ useMemo as useMemo2,
13
+ useRef,
14
+ useState
15
+ } from "react";
16
+ import { Animated, Easing, Pressable, Text, View } from "react-native";
17
+
18
+ // src/components/snackbar/snackbar.style.ts
19
+ import { StyleSheet } from "react-native";
20
+ var SNACKBAR_DEFAULT_DURATION = 4e3;
21
+ var SNACKBAR_DEFAULT_HORIZONTAL_INSET = 16;
22
+ var SNACKBAR_DEFAULT_VERTICAL_INSET = 16;
23
+ var SNACKBAR_DEFAULT_SPACING = 8;
24
+ var SNACKBAR_DEFAULT_MAX_WIDTH = 640;
25
+ var styles = StyleSheet.create({
26
+ stackContainer: {
27
+ position: "absolute",
28
+ left: 0,
29
+ right: 0,
30
+ zIndex: 999
31
+ },
32
+ stackContent: {
33
+ width: "100%",
34
+ alignSelf: "center"
35
+ },
36
+ surface: {
37
+ width: "100%",
38
+ minHeight: 48,
39
+ borderRadius: 4,
40
+ flexDirection: "row",
41
+ alignItems: "center",
42
+ paddingLeft: 16,
43
+ shadowColor: "#000000",
44
+ shadowOffset: { width: 0, height: 1 },
45
+ shadowOpacity: 0.3,
46
+ shadowRadius: 3,
47
+ elevation: 4
48
+ },
49
+ surfaceWithoutActions: {
50
+ paddingRight: 16
51
+ },
52
+ messageWrapper: {
53
+ flex: 1,
54
+ minWidth: 0,
55
+ justifyContent: "center",
56
+ paddingRight: 8
57
+ },
58
+ messageWrapperMultiline: {
59
+ paddingVertical: 14
60
+ },
61
+ messageText: {
62
+ fontSize: 14,
63
+ lineHeight: 20,
64
+ letterSpacing: 0.25,
65
+ fontWeight: "400"
66
+ },
67
+ trailingActions: {
68
+ flexDirection: "row",
69
+ alignItems: "center",
70
+ gap: 4
71
+ },
72
+ actionButton: {
73
+ paddingHorizontal: 12,
74
+ paddingVertical: 10,
75
+ borderRadius: 9999,
76
+ minHeight: 40,
77
+ justifyContent: "center",
78
+ alignItems: "center"
79
+ },
80
+ actionText: {
81
+ fontSize: 14,
82
+ lineHeight: 20,
83
+ letterSpacing: 0.1,
84
+ fontWeight: "500"
85
+ },
86
+ closeButton: {
87
+ width: 48,
88
+ height: 48,
89
+ borderRadius: 9999,
90
+ justifyContent: "center",
91
+ alignItems: "center"
92
+ }
93
+ });
94
+
95
+ // src/components/snackbar/snackbar.hook.ts
96
+ import { useMemo } from "react";
97
+ import { getSafeThemeColor, withOpacity } from "@xaui/core";
98
+ var M3_LIGHT_INVERSE_SURFACE = "#322F35";
99
+ var M3_LIGHT_INVERSE_ON_SURFACE = "#F5EFF7";
100
+ var M3_LIGHT_INVERSE_PRIMARY = "#D0BCFF";
101
+ var M3_DARK_INVERSE_SURFACE = "#E6E1E5";
102
+ var M3_DARK_INVERSE_ON_SURFACE = "#322F35";
103
+ var M3_DARK_INVERSE_PRIMARY = "#6750A4";
104
+ var useSnackbarColors = (themeColor = "default") => {
105
+ const theme = useXUITheme();
106
+ const safeThemeColor = getSafeThemeColor(themeColor);
107
+ return useMemo(() => {
108
+ if (safeThemeColor === "default") {
109
+ const isDarkMode = theme.mode === "dark";
110
+ const containerColor = isDarkMode ? M3_DARK_INVERSE_SURFACE : M3_LIGHT_INVERSE_SURFACE;
111
+ const textColor = isDarkMode ? M3_DARK_INVERSE_ON_SURFACE : M3_LIGHT_INVERSE_ON_SURFACE;
112
+ const actionColor = isDarkMode ? M3_DARK_INVERSE_PRIMARY : M3_LIGHT_INVERSE_PRIMARY;
113
+ return {
114
+ containerColor,
115
+ textColor,
116
+ actionColor,
117
+ pressedOverlayColor: withOpacity(textColor, 0.16)
118
+ };
119
+ }
120
+ const colorScheme = theme.colors[safeThemeColor];
121
+ return {
122
+ containerColor: colorScheme.main,
123
+ textColor: colorScheme.foreground,
124
+ actionColor: withOpacity(colorScheme.foreground, 0.82),
125
+ pressedOverlayColor: withOpacity(colorScheme.foreground, 0.16)
126
+ };
127
+ }, [safeThemeColor, theme]);
128
+ };
129
+ var useSnackbarStackPositionStyles = (position, insetHorizontal, insetVertical, maxWidth) => {
130
+ return useMemo(
131
+ () => ({
132
+ container: position === "top" ? {
133
+ top: insetVertical,
134
+ paddingHorizontal: insetHorizontal
135
+ } : {
136
+ bottom: insetVertical,
137
+ paddingHorizontal: insetHorizontal
138
+ },
139
+ content: {
140
+ maxWidth
141
+ }
142
+ }),
143
+ [position, insetHorizontal, insetVertical, maxWidth]
144
+ );
145
+ };
146
+
147
+ // src/components/snackbar/snackbar.tsx
148
+ import { CloseIcon } from "@xaui/icons/close";
149
+ var ENTER_ANIMATION_DURATION = 220;
150
+ var EXIT_ANIMATION_DURATION = 180;
151
+ var ENTER_INITIAL_SCALE = 0.92;
152
+ var SnackbarSurface = ({ item, duration, onDismiss }) => {
153
+ const {
154
+ id,
155
+ message,
156
+ actionLabel,
157
+ onActionPress,
158
+ closeOnActionPress = true,
159
+ showCloseAffordance = false,
160
+ themeColor = "default",
161
+ numberOfLines = 2,
162
+ customAppearance
163
+ } = item;
164
+ const { containerColor, textColor, actionColor, pressedOverlayColor } = useSnackbarColors(themeColor);
165
+ const opacity = useRef(new Animated.Value(0)).current;
166
+ const scale = useRef(new Animated.Value(ENTER_INITIAL_SCALE)).current;
167
+ const exitAnimationStartedRef = useRef(false);
168
+ const dismissTimeoutRef = useRef(null);
169
+ const clearDismissTimer = useCallback(() => {
170
+ if (!dismissTimeoutRef.current) return;
171
+ clearTimeout(dismissTimeoutRef.current);
172
+ dismissTimeoutRef.current = null;
173
+ }, []);
174
+ const runExitAnimation = useCallback(() => {
175
+ if (exitAnimationStartedRef.current) return;
176
+ exitAnimationStartedRef.current = true;
177
+ clearDismissTimer();
178
+ Animated.parallel([
179
+ Animated.timing(opacity, {
180
+ toValue: 0,
181
+ duration: EXIT_ANIMATION_DURATION,
182
+ easing: Easing.bezier(0.4, 0, 0.2, 1),
183
+ useNativeDriver: true
184
+ }),
185
+ Animated.timing(scale, {
186
+ toValue: ENTER_INITIAL_SCALE,
187
+ duration: EXIT_ANIMATION_DURATION,
188
+ easing: Easing.bezier(0.4, 0, 0.2, 1),
189
+ useNativeDriver: true
190
+ })
191
+ ]).start(({ finished }) => {
192
+ if (!finished) return;
193
+ onDismiss?.(id);
194
+ });
195
+ }, [clearDismissTimer, id, onDismiss, opacity, scale]);
196
+ useEffect(() => {
197
+ opacity.setValue(0);
198
+ scale.setValue(ENTER_INITIAL_SCALE);
199
+ exitAnimationStartedRef.current = false;
200
+ Animated.parallel([
201
+ Animated.timing(opacity, {
202
+ toValue: 1,
203
+ duration: ENTER_ANIMATION_DURATION,
204
+ easing: Easing.bezier(0.2, 0, 0, 1),
205
+ useNativeDriver: true
206
+ }),
207
+ Animated.timing(scale, {
208
+ toValue: 1,
209
+ duration: ENTER_ANIMATION_DURATION,
210
+ easing: Easing.bezier(0.2, 0, 0, 1),
211
+ useNativeDriver: true
212
+ })
213
+ ]).start();
214
+ }, [opacity, scale]);
215
+ useEffect(() => {
216
+ clearDismissTimer();
217
+ if (duration <= 0) return;
218
+ dismissTimeoutRef.current = globalThis.setTimeout(() => {
219
+ runExitAnimation();
220
+ }, duration);
221
+ return clearDismissTimer;
222
+ }, [clearDismissTimer, duration, runExitAnimation]);
223
+ useEffect(() => {
224
+ return () => {
225
+ clearDismissTimer();
226
+ opacity.stopAnimation();
227
+ scale.stopAnimation();
228
+ };
229
+ }, [clearDismissTimer, opacity, scale]);
230
+ const handleDismiss = useCallback(() => {
231
+ runExitAnimation();
232
+ }, [runExitAnimation]);
233
+ const handleActionPress = useCallback(() => {
234
+ onActionPress?.();
235
+ if (closeOnActionPress) {
236
+ handleDismiss();
237
+ }
238
+ }, [onActionPress, closeOnActionPress, handleDismiss]);
239
+ const messageNode = useMemo2(() => {
240
+ if (typeof message === "string" || typeof message === "number") {
241
+ return /* @__PURE__ */ React.createElement(
242
+ Text,
243
+ {
244
+ style: [styles.messageText, { color: textColor }, customAppearance?.message],
245
+ numberOfLines
246
+ },
247
+ message
248
+ );
249
+ }
250
+ return message;
251
+ }, [customAppearance?.message, message, numberOfLines, textColor]);
252
+ const actionNode = useMemo2(() => {
253
+ if (actionLabel === null || actionLabel === void 0) return null;
254
+ if (typeof actionLabel === "string" || typeof actionLabel === "number") {
255
+ return /* @__PURE__ */ React.createElement(Text, { style: [styles.actionText, { color: actionColor }, customAppearance?.action] }, actionLabel);
256
+ }
257
+ if (isValidElement(actionLabel)) {
258
+ return actionLabel;
259
+ }
260
+ return null;
261
+ }, [actionColor, actionLabel, customAppearance?.action]);
262
+ const hasActions = Boolean(actionNode || showCloseAffordance);
263
+ const isMultiline = numberOfLines > 1;
264
+ return /* @__PURE__ */ React.createElement(
265
+ Animated.View,
266
+ {
267
+ accessibilityRole: "alert",
268
+ style: [
269
+ styles.surface,
270
+ { backgroundColor: containerColor },
271
+ !hasActions && styles.surfaceWithoutActions,
272
+ customAppearance?.container,
273
+ {
274
+ opacity,
275
+ transform: [{ scale }]
276
+ }
277
+ ]
278
+ },
279
+ /* @__PURE__ */ React.createElement(
280
+ View,
281
+ {
282
+ style: [
283
+ styles.messageWrapper,
284
+ isMultiline && styles.messageWrapperMultiline
285
+ ]
286
+ },
287
+ messageNode
288
+ ),
289
+ hasActions && /* @__PURE__ */ React.createElement(View, { style: styles.trailingActions }, actionNode && /* @__PURE__ */ React.createElement(
290
+ Pressable,
291
+ {
292
+ accessibilityRole: "button",
293
+ onPress: handleActionPress,
294
+ style: ({ pressed }) => [
295
+ styles.actionButton,
296
+ pressed && { backgroundColor: pressedOverlayColor }
297
+ ]
298
+ },
299
+ actionNode
300
+ ), showCloseAffordance && /* @__PURE__ */ React.createElement(
301
+ Pressable,
302
+ {
303
+ accessibilityRole: "button",
304
+ accessibilityLabel: "Close snackbar",
305
+ onPress: handleDismiss,
306
+ style: ({ pressed }) => [
307
+ styles.closeButton,
308
+ pressed && { backgroundColor: pressedOverlayColor },
309
+ customAppearance?.closeButton
310
+ ]
311
+ },
312
+ /* @__PURE__ */ React.createElement(CloseIcon, { size: 20, color: textColor })
313
+ ))
314
+ );
315
+ };
316
+ var SnackbarStack = ({
317
+ items,
318
+ onDismiss,
319
+ position = "bottom",
320
+ spacing = SNACKBAR_DEFAULT_SPACING,
321
+ insetHorizontal = SNACKBAR_DEFAULT_HORIZONTAL_INSET,
322
+ insetVertical = SNACKBAR_DEFAULT_VERTICAL_INSET,
323
+ maxWidth = SNACKBAR_DEFAULT_MAX_WIDTH,
324
+ defaultDuration = SNACKBAR_DEFAULT_DURATION,
325
+ usePortal = true,
326
+ customAppearance
327
+ }) => {
328
+ const stackPositionStyles = useSnackbarStackPositionStyles(
329
+ position,
330
+ insetHorizontal,
331
+ insetVertical,
332
+ maxWidth
333
+ );
334
+ if (!items.length) return null;
335
+ const itemsToRender = position === "top" ? [...items].reverse() : items;
336
+ const stackNode = /* @__PURE__ */ React.createElement(
337
+ View,
338
+ {
339
+ pointerEvents: "box-none",
340
+ style: [
341
+ styles.stackContainer,
342
+ stackPositionStyles.container,
343
+ customAppearance?.container
344
+ ]
345
+ },
346
+ /* @__PURE__ */ React.createElement(
347
+ View,
348
+ {
349
+ pointerEvents: "box-none",
350
+ style: [
351
+ styles.stackContent,
352
+ stackPositionStyles.content,
353
+ { gap: spacing },
354
+ customAppearance?.content
355
+ ]
356
+ },
357
+ itemsToRender.map((item) => /* @__PURE__ */ React.createElement(
358
+ SnackbarSurface,
359
+ {
360
+ key: item.id,
361
+ item,
362
+ duration: item.duration ?? defaultDuration,
363
+ onDismiss
364
+ }
365
+ ))
366
+ )
367
+ );
368
+ return usePortal ? /* @__PURE__ */ React.createElement(Portal, null, stackNode) : stackNode;
369
+ };
370
+ var Snackbar = ({
371
+ isVisible,
372
+ duration = SNACKBAR_DEFAULT_DURATION,
373
+ onClose,
374
+ onVisibleChange,
375
+ position = "bottom",
376
+ insetHorizontal = SNACKBAR_DEFAULT_HORIZONTAL_INSET,
377
+ insetVertical = SNACKBAR_DEFAULT_VERTICAL_INSET,
378
+ maxWidth = SNACKBAR_DEFAULT_MAX_WIDTH,
379
+ usePortal = true,
380
+ ...itemProps
381
+ }) => {
382
+ const [internalVisible, setInternalVisible] = useState(isVisible ?? true);
383
+ const isControlled = typeof isVisible === "boolean";
384
+ const visible = isControlled ? isVisible : internalVisible;
385
+ const idRef = useRef(`snackbar-${Date.now()}-${Math.random().toString(16).slice(2)}`);
386
+ const dismiss = useCallback(() => {
387
+ if (!isControlled) {
388
+ setInternalVisible(false);
389
+ }
390
+ onVisibleChange?.(false);
391
+ onClose?.();
392
+ }, [isControlled, onClose, onVisibleChange]);
393
+ const items = useMemo2(
394
+ () => visible ? [
395
+ {
396
+ id: idRef.current,
397
+ duration,
398
+ ...itemProps
399
+ }
400
+ ] : [],
401
+ [duration, itemProps, visible]
402
+ );
403
+ return /* @__PURE__ */ React.createElement(
404
+ SnackbarStack,
405
+ {
406
+ items,
407
+ onDismiss: dismiss,
408
+ position,
409
+ insetHorizontal,
410
+ insetVertical,
411
+ maxWidth,
412
+ defaultDuration: duration,
413
+ usePortal
414
+ }
415
+ );
416
+ };
417
+ export {
418
+ Snackbar,
419
+ SnackbarStack
420
+ };