@xaui/native 0.2.8 → 0.9.1-alpha.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 (224) hide show
  1. package/dist/chunk-JDS6KGCM.cjs +791 -0
  2. package/dist/chunk-T3ZI2PZ6.js +791 -0
  3. package/dist/index.cjs +32 -1
  4. package/dist/index.d.cts +2 -2
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +32 -0
  7. package/dist/theme/index.cjs +32 -0
  8. package/dist/theme/index.d.cts +669 -0
  9. package/dist/theme/index.d.ts +669 -0
  10. package/dist/theme/index.js +32 -0
  11. package/package.json +26 -249
  12. package/README.md +0 -178
  13. package/dist/alert/index.cjs +0 -340
  14. package/dist/alert/index.d.cts +0 -46
  15. package/dist/alert/index.d.ts +0 -46
  16. package/dist/alert/index.js +0 -340
  17. package/dist/app-bar/index.cjs +0 -148
  18. package/dist/app-bar/index.d.cts +0 -59
  19. package/dist/app-bar/index.d.ts +0 -59
  20. package/dist/app-bar/index.js +0 -148
  21. package/dist/autocomplete/index.cjs +0 -1122
  22. package/dist/autocomplete/index.d.cts +0 -88
  23. package/dist/autocomplete/index.d.ts +0 -88
  24. package/dist/autocomplete/index.js +0 -1122
  25. package/dist/avatar/index.cjs +0 -281
  26. package/dist/avatar/index.d.cts +0 -123
  27. package/dist/avatar/index.d.ts +0 -123
  28. package/dist/avatar/index.js +0 -281
  29. package/dist/badge/index.cjs +0 -197
  30. package/dist/badge/index.d.cts +0 -94
  31. package/dist/badge/index.d.ts +0 -94
  32. package/dist/badge/index.js +0 -197
  33. package/dist/bottom-sheet/index.cjs +0 -9
  34. package/dist/bottom-sheet/index.d.cts +0 -84
  35. package/dist/bottom-sheet/index.d.ts +0 -84
  36. package/dist/bottom-sheet/index.js +0 -9
  37. package/dist/bottom-tab-bar/index.cjs +0 -497
  38. package/dist/bottom-tab-bar/index.d.cts +0 -211
  39. package/dist/bottom-tab-bar/index.d.ts +0 -211
  40. package/dist/bottom-tab-bar/index.js +0 -497
  41. package/dist/button/index.cjs +0 -392
  42. package/dist/button/index.d.cts +0 -174
  43. package/dist/button/index.d.ts +0 -174
  44. package/dist/button/index.js +0 -392
  45. package/dist/button.type-j1ZdkkSl.d.cts +0 -4
  46. package/dist/button.type-j1ZdkkSl.d.ts +0 -4
  47. package/dist/card/index.cjs +0 -338
  48. package/dist/card/index.d.cts +0 -191
  49. package/dist/card/index.d.ts +0 -191
  50. package/dist/card/index.js +0 -338
  51. package/dist/carousel/index.cjs +0 -381
  52. package/dist/carousel/index.d.cts +0 -147
  53. package/dist/carousel/index.d.ts +0 -147
  54. package/dist/carousel/index.js +0 -381
  55. package/dist/chart/index.cjs +0 -1026
  56. package/dist/chart/index.d.cts +0 -218
  57. package/dist/chart/index.d.ts +0 -218
  58. package/dist/chart/index.js +0 -1026
  59. package/dist/checkbox/index.cjs +0 -443
  60. package/dist/checkbox/index.d.cts +0 -73
  61. package/dist/checkbox/index.d.ts +0 -73
  62. package/dist/checkbox/index.js +0 -443
  63. package/dist/chip/index.cjs +0 -503
  64. package/dist/chip/index.d.cts +0 -195
  65. package/dist/chip/index.d.ts +0 -195
  66. package/dist/chip/index.js +0 -503
  67. package/dist/chunk-4JFWQ5XT.js +0 -368
  68. package/dist/chunk-56RPWZD2.cjs +0 -9
  69. package/dist/chunk-7UFBLUMV.cjs +0 -136
  70. package/dist/chunk-A45TVXU5.js +0 -337
  71. package/dist/chunk-BYWUAPC4.cjs +0 -368
  72. package/dist/chunk-DECMUMCI.js +0 -0
  73. package/dist/chunk-DHSTKO3K.cjs +0 -19
  74. package/dist/chunk-DJ4Q37UT.cjs +0 -75
  75. package/dist/chunk-EUQDGTST.cjs +0 -1
  76. package/dist/chunk-GBHQCAKW.js +0 -19
  77. package/dist/chunk-RBSA4NH4.js +0 -136
  78. package/dist/chunk-SHBDANQN.js +0 -9
  79. package/dist/chunk-UGEINZM7.cjs +0 -290
  80. package/dist/chunk-UU4HHBDN.js +0 -290
  81. package/dist/chunk-VSZEXOUN.js +0 -384
  82. package/dist/chunk-YIEUN3G5.cjs +0 -384
  83. package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
  84. package/dist/chunk-ZY7IUTAT.js +0 -75
  85. package/dist/color-picker/index.cjs +0 -457
  86. package/dist/color-picker/index.d.cts +0 -124
  87. package/dist/color-picker/index.d.ts +0 -124
  88. package/dist/color-picker/index.js +0 -457
  89. package/dist/core/index.cjs +0 -24
  90. package/dist/core/index.d.cts +0 -28
  91. package/dist/core/index.d.ts +0 -28
  92. package/dist/core/index.js +0 -24
  93. package/dist/datepicker/index.cjs +0 -1625
  94. package/dist/datepicker/index.d.cts +0 -45
  95. package/dist/datepicker/index.d.ts +0 -45
  96. package/dist/datepicker/index.js +0 -1625
  97. package/dist/dialog/index.cjs +0 -372
  98. package/dist/dialog/index.d.cts +0 -151
  99. package/dist/dialog/index.d.ts +0 -151
  100. package/dist/dialog/index.js +0 -372
  101. package/dist/divider/index.cjs +0 -8
  102. package/dist/divider/index.d.cts +0 -30
  103. package/dist/divider/index.d.ts +0 -30
  104. package/dist/divider/index.js +0 -8
  105. package/dist/drawer/index.cjs +0 -237
  106. package/dist/drawer/index.d.cts +0 -58
  107. package/dist/drawer/index.d.ts +0 -58
  108. package/dist/drawer/index.js +0 -237
  109. package/dist/expansion-panel/index.cjs +0 -441
  110. package/dist/expansion-panel/index.d.cts +0 -153
  111. package/dist/expansion-panel/index.d.ts +0 -153
  112. package/dist/expansion-panel/index.js +0 -441
  113. package/dist/fab/index.cjs +0 -9
  114. package/dist/fab/index.d.cts +0 -10
  115. package/dist/fab/index.d.ts +0 -10
  116. package/dist/fab/index.js +0 -9
  117. package/dist/fab-menu/index.cjs +0 -330
  118. package/dist/fab-menu/index.d.cts +0 -125
  119. package/dist/fab-menu/index.d.ts +0 -125
  120. package/dist/fab-menu/index.js +0 -330
  121. package/dist/fab.type-CkUHmXU_.d.ts +0 -86
  122. package/dist/fab.type-DN0vtAh6.d.cts +0 -86
  123. package/dist/feature-discovery/index.cjs +0 -464
  124. package/dist/feature-discovery/index.d.cts +0 -82
  125. package/dist/feature-discovery/index.d.ts +0 -82
  126. package/dist/feature-discovery/index.js +0 -464
  127. package/dist/indicator/index.cjs +0 -8
  128. package/dist/indicator/index.d.cts +0 -47
  129. package/dist/indicator/index.d.ts +0 -47
  130. package/dist/indicator/index.js +0 -8
  131. package/dist/input/index.cjs +0 -1462
  132. package/dist/input/index.d.cts +0 -522
  133. package/dist/input/index.d.ts +0 -522
  134. package/dist/input/index.js +0 -1462
  135. package/dist/input-trigger/index.cjs +0 -197
  136. package/dist/input-trigger/index.d.cts +0 -11
  137. package/dist/input-trigger/index.d.ts +0 -11
  138. package/dist/input-trigger/index.js +0 -197
  139. package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
  140. package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
  141. package/dist/list/index.cjs +0 -395
  142. package/dist/list/index.d.cts +0 -188
  143. package/dist/list/index.d.ts +0 -188
  144. package/dist/list/index.js +0 -395
  145. package/dist/menu/index.cjs +0 -316
  146. package/dist/menu/index.d.cts +0 -115
  147. package/dist/menu/index.d.ts +0 -115
  148. package/dist/menu/index.js +0 -316
  149. package/dist/menubox/index.cjs +0 -297
  150. package/dist/menubox/index.d.cts +0 -98
  151. package/dist/menubox/index.d.ts +0 -98
  152. package/dist/menubox/index.js +0 -297
  153. package/dist/pager/index.cjs +0 -205
  154. package/dist/pager/index.d.cts +0 -93
  155. package/dist/pager/index.d.ts +0 -93
  156. package/dist/pager/index.js +0 -205
  157. package/dist/picker/index.cjs +0 -244
  158. package/dist/picker/index.d.cts +0 -121
  159. package/dist/picker/index.d.ts +0 -121
  160. package/dist/picker/index.js +0 -244
  161. package/dist/progress/index.cjs +0 -219
  162. package/dist/progress/index.d.cts +0 -47
  163. package/dist/progress/index.d.ts +0 -47
  164. package/dist/progress/index.js +0 -219
  165. package/dist/radio/index.cjs +0 -465
  166. package/dist/radio/index.d.cts +0 -145
  167. package/dist/radio/index.d.ts +0 -145
  168. package/dist/radio/index.js +0 -465
  169. package/dist/refresh-control/index.cjs +0 -45
  170. package/dist/refresh-control/index.d.cts +0 -55
  171. package/dist/refresh-control/index.d.ts +0 -55
  172. package/dist/refresh-control/index.js +0 -45
  173. package/dist/segment-button/index.cjs +0 -405
  174. package/dist/segment-button/index.d.cts +0 -141
  175. package/dist/segment-button/index.d.ts +0 -141
  176. package/dist/segment-button/index.js +0 -405
  177. package/dist/select/index.cjs +0 -878
  178. package/dist/select/index.d.cts +0 -192
  179. package/dist/select/index.d.ts +0 -192
  180. package/dist/select/index.js +0 -878
  181. package/dist/skeleton/index.cjs +0 -89
  182. package/dist/skeleton/index.d.cts +0 -45
  183. package/dist/skeleton/index.d.ts +0 -45
  184. package/dist/skeleton/index.js +0 -89
  185. package/dist/slider/index.cjs +0 -576
  186. package/dist/slider/index.d.cts +0 -171
  187. package/dist/slider/index.d.ts +0 -171
  188. package/dist/slider/index.js +0 -576
  189. package/dist/snackbar/index.cjs +0 -436
  190. package/dist/snackbar/index.d.cts +0 -174
  191. package/dist/snackbar/index.d.ts +0 -174
  192. package/dist/snackbar/index.js +0 -436
  193. package/dist/snippet/index.cjs +0 -314
  194. package/dist/snippet/index.d.cts +0 -95
  195. package/dist/snippet/index.d.ts +0 -95
  196. package/dist/snippet/index.js +0 -314
  197. package/dist/stepper/index.cjs +0 -550
  198. package/dist/stepper/index.d.cts +0 -137
  199. package/dist/stepper/index.d.ts +0 -137
  200. package/dist/stepper/index.js +0 -550
  201. package/dist/switch/index.cjs +0 -358
  202. package/dist/switch/index.d.cts +0 -28
  203. package/dist/switch/index.d.ts +0 -28
  204. package/dist/switch/index.js +0 -358
  205. package/dist/tabs/index.cjs +0 -440
  206. package/dist/tabs/index.d.cts +0 -180
  207. package/dist/tabs/index.d.ts +0 -180
  208. package/dist/tabs/index.js +0 -440
  209. package/dist/timepicker/index.cjs +0 -823
  210. package/dist/timepicker/index.d.cts +0 -215
  211. package/dist/timepicker/index.d.ts +0 -215
  212. package/dist/timepicker/index.js +0 -823
  213. package/dist/toolbar/index.cjs +0 -333
  214. package/dist/toolbar/index.d.cts +0 -100
  215. package/dist/toolbar/index.d.ts +0 -100
  216. package/dist/toolbar/index.js +0 -333
  217. package/dist/typography/index.cjs +0 -238
  218. package/dist/typography/index.d.cts +0 -113
  219. package/dist/typography/index.d.ts +0 -113
  220. package/dist/typography/index.js +0 -238
  221. package/dist/view/index.cjs +0 -1361
  222. package/dist/view/index.d.cts +0 -833
  223. package/dist/view/index.d.ts +0 -833
  224. package/dist/view/index.js +0 -1361
@@ -1,436 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('../chunk-56RPWZD2.cjs');
2
-
3
-
4
-
5
- var _chunk7UFBLUMVcjs = require('../chunk-7UFBLUMV.cjs');
6
-
7
- // src/components/snackbar/snackbar.tsx
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
16
- var _reactnative = require('react-native');
17
-
18
- // src/components/snackbar/snackbar.style.ts
19
-
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 = _reactnative.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
-
97
- var _core = require('@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 = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
106
- const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
107
- return _react.useMemo.call(void 0, () => {
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: _core.withOpacity.call(void 0, textColor, 0.16)
118
- };
119
- }
120
- const colorScheme = theme.colors[safeThemeColor];
121
- return {
122
- containerColor: colorScheme.main,
123
- textColor: colorScheme.onMain,
124
- actionColor: _core.withOpacity.call(void 0, colorScheme.onMain, 0.82),
125
- pressedOverlayColor: _core.withOpacity.call(void 0, colorScheme.onMain, 0.16)
126
- };
127
- }, [safeThemeColor, theme]);
128
- };
129
- var useSnackbarStackPositionStyles = (position, insetHorizontal, insetVertical, maxWidth) => {
130
- return _react.useMemo.call(void 0,
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
- var _close = require('@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 = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
166
- const scale = _react.useRef.call(void 0, new _reactnative.Animated.Value(ENTER_INITIAL_SCALE)).current;
167
- const exitAnimationStartedRef = _react.useRef.call(void 0, false);
168
- const dismissTimeoutRef = _react.useRef.call(void 0, null);
169
- const clearDismissTimer = _react.useCallback.call(void 0, () => {
170
- if (!dismissTimeoutRef.current) return;
171
- clearTimeout(dismissTimeoutRef.current);
172
- dismissTimeoutRef.current = null;
173
- }, []);
174
- const runExitAnimation = _react.useCallback.call(void 0, () => {
175
- if (exitAnimationStartedRef.current) return;
176
- exitAnimationStartedRef.current = true;
177
- clearDismissTimer();
178
- _reactnative.Animated.parallel([
179
- _reactnative.Animated.timing(opacity, {
180
- toValue: 0,
181
- duration: EXIT_ANIMATION_DURATION,
182
- easing: _reactnative.Easing.bezier(0.4, 0, 0.2, 1),
183
- useNativeDriver: true
184
- }),
185
- _reactnative.Animated.timing(scale, {
186
- toValue: ENTER_INITIAL_SCALE,
187
- duration: EXIT_ANIMATION_DURATION,
188
- easing: _reactnative.Easing.bezier(0.4, 0, 0.2, 1),
189
- useNativeDriver: true
190
- })
191
- ]).start(({ finished }) => {
192
- if (!finished) return;
193
- _optionalChain([onDismiss, 'optionalCall', _ => _(id)]);
194
- });
195
- }, [clearDismissTimer, id, onDismiss, opacity, scale]);
196
- _react.useEffect.call(void 0, () => {
197
- opacity.setValue(0);
198
- scale.setValue(ENTER_INITIAL_SCALE);
199
- exitAnimationStartedRef.current = false;
200
- _reactnative.Animated.parallel([
201
- _reactnative.Animated.timing(opacity, {
202
- toValue: 1,
203
- duration: ENTER_ANIMATION_DURATION,
204
- easing: _reactnative.Easing.bezier(0.2, 0, 0, 1),
205
- useNativeDriver: true
206
- }),
207
- _reactnative.Animated.timing(scale, {
208
- toValue: 1,
209
- duration: ENTER_ANIMATION_DURATION,
210
- easing: _reactnative.Easing.bezier(0.2, 0, 0, 1),
211
- useNativeDriver: true
212
- })
213
- ]).start();
214
- }, [opacity, scale]);
215
- _react.useEffect.call(void 0, () => {
216
- clearDismissTimer();
217
- if (duration <= 0) return;
218
- dismissTimeoutRef.current = globalThis.setTimeout(() => {
219
- runExitAnimation();
220
- }, duration);
221
- return clearDismissTimer;
222
- }, [clearDismissTimer, duration, runExitAnimation]);
223
- _react.useEffect.call(void 0, () => {
224
- return () => {
225
- clearDismissTimer();
226
- opacity.stopAnimation();
227
- scale.stopAnimation();
228
- };
229
- }, [clearDismissTimer, opacity, scale]);
230
- const handleDismiss = _react.useCallback.call(void 0, () => {
231
- runExitAnimation();
232
- }, [runExitAnimation]);
233
- const handleActionPress = _react.useCallback.call(void 0, () => {
234
- _optionalChain([onActionPress, 'optionalCall', _2 => _2()]);
235
- if (closeOnActionPress) {
236
- handleDismiss();
237
- }
238
- }, [onActionPress, closeOnActionPress, handleDismiss]);
239
- const messageNode = _react.useMemo.call(void 0, () => {
240
- if (typeof message === "string" || typeof message === "number") {
241
- return /* @__PURE__ */ _react2.default.createElement(
242
- _reactnative.Text,
243
- {
244
- style: [
245
- styles.messageText,
246
- { color: textColor },
247
- _optionalChain([customAppearance, 'optionalAccess', _3 => _3.message])
248
- ],
249
- numberOfLines
250
- },
251
- message
252
- );
253
- }
254
- return message;
255
- }, [_optionalChain([customAppearance, 'optionalAccess', _4 => _4.message]), message, numberOfLines, textColor]);
256
- const actionNode = _react.useMemo.call(void 0, () => {
257
- if (actionLabel === null || actionLabel === void 0) return null;
258
- if (typeof actionLabel === "string" || typeof actionLabel === "number") {
259
- return /* @__PURE__ */ _react2.default.createElement(
260
- _reactnative.Text,
261
- {
262
- style: [
263
- styles.actionText,
264
- { color: actionColor },
265
- _optionalChain([customAppearance, 'optionalAccess', _5 => _5.action])
266
- ]
267
- },
268
- actionLabel
269
- );
270
- }
271
- if (_react.isValidElement.call(void 0, actionLabel)) {
272
- return actionLabel;
273
- }
274
- return null;
275
- }, [actionColor, actionLabel, _optionalChain([customAppearance, 'optionalAccess', _6 => _6.action])]);
276
- const hasActions = Boolean(actionNode || showCloseAffordance);
277
- const isMultiline = numberOfLines > 1;
278
- return /* @__PURE__ */ _react2.default.createElement(
279
- _reactnative.Animated.View,
280
- {
281
- accessibilityRole: "alert",
282
- style: [
283
- styles.surface,
284
- { backgroundColor: containerColor },
285
- !hasActions && styles.surfaceWithoutActions,
286
- _optionalChain([customAppearance, 'optionalAccess', _7 => _7.container]),
287
- {
288
- opacity,
289
- transform: [{ scale }]
290
- }
291
- ]
292
- },
293
- /* @__PURE__ */ _react2.default.createElement(
294
- _reactnative.View,
295
- {
296
- style: [
297
- styles.messageWrapper,
298
- isMultiline && styles.messageWrapperMultiline
299
- ]
300
- },
301
- messageNode
302
- ),
303
- hasActions && /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.trailingActions }, actionNode && /* @__PURE__ */ _react2.default.createElement(
304
- _reactnative.Pressable,
305
- {
306
- accessibilityRole: "button",
307
- onPress: handleActionPress,
308
- style: ({ pressed }) => [
309
- styles.actionButton,
310
- pressed && { backgroundColor: pressedOverlayColor }
311
- ]
312
- },
313
- actionNode
314
- ), showCloseAffordance && /* @__PURE__ */ _react2.default.createElement(
315
- _reactnative.Pressable,
316
- {
317
- accessibilityRole: "button",
318
- accessibilityLabel: "Close snackbar",
319
- onPress: handleDismiss,
320
- style: ({ pressed }) => [
321
- styles.closeButton,
322
- pressed && { backgroundColor: pressedOverlayColor },
323
- _optionalChain([customAppearance, 'optionalAccess', _8 => _8.closeButton])
324
- ]
325
- },
326
- /* @__PURE__ */ _react2.default.createElement(_close.CloseIcon, { size: 20, color: textColor })
327
- ))
328
- );
329
- };
330
- var SnackbarStack = ({
331
- items,
332
- onDismiss,
333
- position = "bottom",
334
- spacing = SNACKBAR_DEFAULT_SPACING,
335
- insetHorizontal = SNACKBAR_DEFAULT_HORIZONTAL_INSET,
336
- insetVertical = SNACKBAR_DEFAULT_VERTICAL_INSET,
337
- maxWidth = SNACKBAR_DEFAULT_MAX_WIDTH,
338
- defaultDuration = SNACKBAR_DEFAULT_DURATION,
339
- usePortal = true,
340
- customAppearance
341
- }) => {
342
- const stackPositionStyles = useSnackbarStackPositionStyles(
343
- position,
344
- insetHorizontal,
345
- insetVertical,
346
- maxWidth
347
- );
348
- if (!items.length) return null;
349
- const itemsToRender = position === "top" ? [...items].reverse() : items;
350
- const stackNode = /* @__PURE__ */ _react2.default.createElement(
351
- _reactnative.View,
352
- {
353
- pointerEvents: "box-none",
354
- style: [
355
- styles.stackContainer,
356
- stackPositionStyles.container,
357
- _optionalChain([customAppearance, 'optionalAccess', _9 => _9.container])
358
- ]
359
- },
360
- /* @__PURE__ */ _react2.default.createElement(
361
- _reactnative.View,
362
- {
363
- pointerEvents: "box-none",
364
- style: [
365
- styles.stackContent,
366
- stackPositionStyles.content,
367
- { gap: spacing },
368
- _optionalChain([customAppearance, 'optionalAccess', _10 => _10.content])
369
- ]
370
- },
371
- itemsToRender.map((item) => /* @__PURE__ */ _react2.default.createElement(
372
- SnackbarSurface,
373
- {
374
- key: item.id,
375
- item,
376
- duration: _nullishCoalesce(item.duration, () => ( defaultDuration)),
377
- onDismiss
378
- }
379
- ))
380
- )
381
- );
382
- return usePortal ? /* @__PURE__ */ _react2.default.createElement(_chunk7UFBLUMVcjs.Portal, null, stackNode) : stackNode;
383
- };
384
- var Snackbar = ({
385
- isVisible,
386
- duration = SNACKBAR_DEFAULT_DURATION,
387
- onClose,
388
- onVisibleChange,
389
- position = "bottom",
390
- insetHorizontal = SNACKBAR_DEFAULT_HORIZONTAL_INSET,
391
- insetVertical = SNACKBAR_DEFAULT_VERTICAL_INSET,
392
- maxWidth = SNACKBAR_DEFAULT_MAX_WIDTH,
393
- usePortal = true,
394
- ...itemProps
395
- }) => {
396
- const [internalVisible, setInternalVisible] = _react.useState.call(void 0, _nullishCoalesce(isVisible, () => ( true)));
397
- const isControlled = typeof isVisible === "boolean";
398
- const visible = isControlled ? isVisible : internalVisible;
399
- const idRef = _react.useRef.call(void 0,
400
- `snackbar-${Date.now()}-${Math.random().toString(16).slice(2)}`
401
- );
402
- const dismiss = _react.useCallback.call(void 0, () => {
403
- if (!isControlled) {
404
- setInternalVisible(false);
405
- }
406
- _optionalChain([onVisibleChange, 'optionalCall', _11 => _11(false)]);
407
- _optionalChain([onClose, 'optionalCall', _12 => _12()]);
408
- }, [isControlled, onClose, onVisibleChange]);
409
- const items = _react.useMemo.call(void 0,
410
- () => visible ? [
411
- {
412
- id: idRef.current,
413
- duration,
414
- ...itemProps
415
- }
416
- ] : [],
417
- [duration, itemProps, visible]
418
- );
419
- return /* @__PURE__ */ _react2.default.createElement(
420
- SnackbarStack,
421
- {
422
- items,
423
- onDismiss: dismiss,
424
- position,
425
- insetHorizontal,
426
- insetVertical,
427
- maxWidth,
428
- defaultDuration: duration,
429
- usePortal
430
- }
431
- );
432
- };
433
-
434
-
435
-
436
- exports.Snackbar = Snackbar; exports.SnackbarStack = SnackbarStack;
@@ -1,174 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- import { ViewStyle, TextStyle } from 'react-native';
3
- import { ThemeColor } from '@xaui/core/types';
4
-
5
- type SnackbarPosition = 'top' | 'bottom';
6
- type SnackbarCustomAppearance = {
7
- /**
8
- * Custom style for the snackbar surface.
9
- */
10
- container?: ViewStyle;
11
- /**
12
- * Custom style for the message text.
13
- */
14
- message?: TextStyle;
15
- /**
16
- * Custom style for the action label text.
17
- */
18
- action?: TextStyle;
19
- /**
20
- * Custom style for the close affordance button.
21
- */
22
- closeButton?: ViewStyle;
23
- };
24
- type SnackbarBaseProps = {
25
- /**
26
- * Message content shown inside the snackbar.
27
- */
28
- message: ReactNode;
29
- /**
30
- * Action content displayed at the end of the snackbar.
31
- */
32
- actionLabel?: ReactNode;
33
- /**
34
- * Callback fired when the action is pressed.
35
- */
36
- onActionPress?: () => void;
37
- /**
38
- * If true, pressing the action also dismisses the snackbar.
39
- * @default true
40
- */
41
- closeOnActionPress?: boolean;
42
- /**
43
- * If true, shows the close affordance icon button.
44
- * @default false
45
- */
46
- showCloseAffordance?: boolean;
47
- /**
48
- * Theme color for the snackbar. The default uses Material 3 inverse surface styling.
49
- * @default 'default'
50
- */
51
- themeColor?: ThemeColor;
52
- /**
53
- * Number of lines for the message text.
54
- * @default 2
55
- */
56
- numberOfLines?: number;
57
- /**
58
- * Custom appearance styles for snackbar parts.
59
- */
60
- customAppearance?: SnackbarCustomAppearance;
61
- };
62
- type SnackbarProps = SnackbarBaseProps & {
63
- /**
64
- * Controls snackbar visibility. If omitted, snackbar is shown by default.
65
- * @default true
66
- */
67
- isVisible?: boolean;
68
- /**
69
- * Duration in milliseconds before auto-dismiss. Set to 0 or a negative value to disable.
70
- * @default 4000
71
- */
72
- duration?: number;
73
- /**
74
- * Callback fired when the snackbar is dismissed.
75
- */
76
- onClose?: () => void;
77
- /**
78
- * Callback fired when visibility changes.
79
- */
80
- onVisibleChange?: (isVisible: boolean) => void;
81
- /**
82
- * Position of the snackbar on screen.
83
- * @default 'bottom'
84
- */
85
- position?: SnackbarPosition;
86
- /**
87
- * Horizontal inset from screen edges.
88
- * @default 16
89
- */
90
- insetHorizontal?: number;
91
- /**
92
- * Vertical inset from screen edge according to position.
93
- * @default 16
94
- */
95
- insetVertical?: number;
96
- /**
97
- * Maximum width of the snackbar surface.
98
- * @default 640
99
- */
100
- maxWidth?: number;
101
- /**
102
- * Render snackbar in a portal overlay.
103
- * @default true
104
- */
105
- usePortal?: boolean;
106
- };
107
- type SnackbarItem = SnackbarBaseProps & {
108
- /**
109
- * Unique identifier for the snackbar item in the stack.
110
- */
111
- id: string;
112
- /**
113
- * Item-specific auto-dismiss duration in milliseconds.
114
- * Set to 0 or a negative value to disable.
115
- */
116
- duration?: number;
117
- };
118
- type SnackbarStackProps = {
119
- /**
120
- * Snackbar items to render in a vertical stack.
121
- */
122
- items: SnackbarItem[];
123
- /**
124
- * Called when an item requests dismissal.
125
- */
126
- onDismiss?: (id: string) => void;
127
- /**
128
- * Position of the stacked snackbars on screen.
129
- * @default 'bottom'
130
- */
131
- position?: SnackbarPosition;
132
- /**
133
- * Space between stacked snackbars.
134
- * @default 8
135
- */
136
- spacing?: number;
137
- /**
138
- * Horizontal inset from screen edges.
139
- * @default 16
140
- */
141
- insetHorizontal?: number;
142
- /**
143
- * Vertical inset from screen edge according to position.
144
- * @default 16
145
- */
146
- insetVertical?: number;
147
- /**
148
- * Maximum width of each snackbar surface.
149
- * @default 640
150
- */
151
- maxWidth?: number;
152
- /**
153
- * Default auto-dismiss duration for items without `duration`.
154
- * @default 4000
155
- */
156
- defaultDuration?: number;
157
- /**
158
- * Render stack in a portal overlay.
159
- * @default true
160
- */
161
- usePortal?: boolean;
162
- /**
163
- * Custom styles for stack containers.
164
- */
165
- customAppearance?: {
166
- container?: ViewStyle;
167
- content?: ViewStyle;
168
- };
169
- };
170
-
171
- declare const SnackbarStack: React.FC<SnackbarStackProps>;
172
- declare const Snackbar: React.FC<SnackbarProps>;
173
-
174
- export { Snackbar, type SnackbarItem, type SnackbarPosition, type SnackbarProps, SnackbarStack, type SnackbarStackProps };