zkit-ui 1.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 (267) hide show
  1. package/README.md +267 -0
  2. package/dist/ComponentLibProvider.d.ts +15 -0
  3. package/dist/ComponentLibProvider.d.ts.map +1 -0
  4. package/dist/ComponentLibProvider.js +18 -0
  5. package/dist/assets/animations/spinner.json +1 -0
  6. package/dist/assets/icons/check.svg +4 -0
  7. package/dist/assets/icons/toast/error.webp +0 -0
  8. package/dist/assets/icons/toast/success.webp +0 -0
  9. package/dist/assets/icons/toast/warning.webp +0 -0
  10. package/dist/config.d.ts +16 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/config.js +42 -0
  13. package/dist/i18n/I18nProvider.d.ts +11 -0
  14. package/dist/i18n/I18nProvider.d.ts.map +1 -0
  15. package/dist/i18n/I18nProvider.js +84 -0
  16. package/dist/i18n/locale.d.ts +7 -0
  17. package/dist/i18n/locale.d.ts.map +1 -0
  18. package/dist/i18n/locale.js +87 -0
  19. package/dist/i18n/locales/de.d.ts +51 -0
  20. package/dist/i18n/locales/de.d.ts.map +1 -0
  21. package/dist/i18n/locales/de.js +62 -0
  22. package/dist/i18n/locales/en-US.d.ts +51 -0
  23. package/dist/i18n/locales/en-US.d.ts.map +1 -0
  24. package/dist/i18n/locales/en-US.js +62 -0
  25. package/dist/i18n/locales/index.d.ts +9 -0
  26. package/dist/i18n/locales/index.d.ts.map +1 -0
  27. package/dist/i18n/locales/index.js +23 -0
  28. package/dist/i18n/locales/ja.d.ts +51 -0
  29. package/dist/i18n/locales/ja.d.ts.map +1 -0
  30. package/dist/i18n/locales/ja.js +62 -0
  31. package/dist/i18n/locales/zh-CN.d.ts +51 -0
  32. package/dist/i18n/locales/zh-CN.d.ts.map +1 -0
  33. package/dist/i18n/locales/zh-CN.js +62 -0
  34. package/dist/i18n/locales/zh-TW.d.ts +51 -0
  35. package/dist/i18n/locales/zh-TW.d.ts.map +1 -0
  36. package/dist/i18n/locales/zh-TW.js +62 -0
  37. package/dist/i18n/types.d.ts +11 -0
  38. package/dist/i18n/types.d.ts.map +1 -0
  39. package/dist/i18n/types.js +2 -0
  40. package/dist/i18n/useI18n.d.ts +2 -0
  41. package/dist/i18n/useI18n.d.ts.map +1 -0
  42. package/dist/i18n/useI18n.js +41 -0
  43. package/dist/index.d.ts +57 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +90 -0
  46. package/dist/services/ActionDialogService/ActionDialog.d.ts +4 -0
  47. package/dist/services/ActionDialogService/ActionDialog.d.ts.map +1 -0
  48. package/dist/services/ActionDialogService/ActionDialog.js +531 -0
  49. package/dist/services/ActionDialogService/index.d.ts +4 -0
  50. package/dist/services/ActionDialogService/index.d.ts.map +1 -0
  51. package/dist/services/ActionDialogService/index.js +8 -0
  52. package/dist/services/ActionDialogService/service.d.ts +7 -0
  53. package/dist/services/ActionDialogService/service.d.ts.map +1 -0
  54. package/dist/services/ActionDialogService/service.js +309 -0
  55. package/dist/services/ActionDialogService/shared.d.ts +17 -0
  56. package/dist/services/ActionDialogService/shared.d.ts.map +1 -0
  57. package/dist/services/ActionDialogService/shared.js +167 -0
  58. package/dist/services/ActionDialogService/types.d.ts +160 -0
  59. package/dist/services/ActionDialogService/types.d.ts.map +1 -0
  60. package/dist/services/ActionDialogService/types.js +2 -0
  61. package/dist/services/CardToastService/index.d.ts +115 -0
  62. package/dist/services/CardToastService/index.d.ts.map +1 -0
  63. package/dist/services/CardToastService/index.js +899 -0
  64. package/dist/services/ImagePreviewService/index.d.ts +179 -0
  65. package/dist/services/ImagePreviewService/index.d.ts.map +1 -0
  66. package/dist/services/ImagePreviewService/index.js +1383 -0
  67. package/dist/services/LoadingService/index.d.ts +146 -0
  68. package/dist/services/LoadingService/index.d.ts.map +1 -0
  69. package/dist/services/LoadingService/index.js +827 -0
  70. package/dist/services/PermissionPurposeDialogService/index.d.ts +99 -0
  71. package/dist/services/PermissionPurposeDialogService/index.d.ts.map +1 -0
  72. package/dist/services/PermissionPurposeDialogService/index.js +360 -0
  73. package/dist/services/PickerService/index.d.ts +128 -0
  74. package/dist/services/PickerService/index.d.ts.map +1 -0
  75. package/dist/services/PickerService/index.js +250 -0
  76. package/dist/theme/ThemeProvider.d.ts +15 -0
  77. package/dist/theme/ThemeProvider.d.ts.map +1 -0
  78. package/dist/theme/ThemeProvider.js +61 -0
  79. package/dist/theme/defaultTheme.d.ts +3 -0
  80. package/dist/theme/defaultTheme.d.ts.map +1 -0
  81. package/dist/theme/defaultTheme.js +28 -0
  82. package/dist/theme/mergeTheme.d.ts +3 -0
  83. package/dist/theme/mergeTheme.d.ts.map +1 -0
  84. package/dist/theme/mergeTheme.js +19 -0
  85. package/dist/theme/types.d.ts +17 -0
  86. package/dist/theme/types.d.ts.map +1 -0
  87. package/dist/theme/types.js +2 -0
  88. package/dist/theme/useTheme.d.ts +2 -0
  89. package/dist/theme/useTheme.d.ts.map +1 -0
  90. package/dist/theme/useTheme.js +46 -0
  91. package/dist/ui/Accordion/index.d.ts +99 -0
  92. package/dist/ui/Accordion/index.d.ts.map +1 -0
  93. package/dist/ui/Accordion/index.js +777 -0
  94. package/dist/ui/AddressCascader/index.d.ts +58 -0
  95. package/dist/ui/AddressCascader/index.d.ts.map +1 -0
  96. package/dist/ui/AddressCascader/index.js +710 -0
  97. package/dist/ui/BetweenTime/index.d.ts +82 -0
  98. package/dist/ui/BetweenTime/index.d.ts.map +1 -0
  99. package/dist/ui/BetweenTime/index.js +702 -0
  100. package/dist/ui/Button/index.d.ts +93 -0
  101. package/dist/ui/Button/index.d.ts.map +1 -0
  102. package/dist/ui/Button/index.js +832 -0
  103. package/dist/ui/Checkbox/index.d.ts +103 -0
  104. package/dist/ui/Checkbox/index.d.ts.map +1 -0
  105. package/dist/ui/Checkbox/index.js +694 -0
  106. package/dist/ui/DatePicker/index.d.ts +5 -0
  107. package/dist/ui/DatePicker/index.d.ts.map +1 -0
  108. package/dist/ui/DatePicker/index.js +157 -0
  109. package/dist/ui/DatePicker/types.d.ts +99 -0
  110. package/dist/ui/DatePicker/types.d.ts.map +1 -0
  111. package/dist/ui/DatePicker/types.js +2 -0
  112. package/dist/ui/DatePicker/utils.d.ts +32 -0
  113. package/dist/ui/DatePicker/utils.d.ts.map +1 -0
  114. package/dist/ui/DatePicker/utils.js +316 -0
  115. package/dist/ui/LinkedScroll/index.d.ts +78 -0
  116. package/dist/ui/LinkedScroll/index.d.ts.map +1 -0
  117. package/dist/ui/LinkedScroll/index.js +470 -0
  118. package/dist/ui/LoadingSpinner/index.d.ts +8 -0
  119. package/dist/ui/LoadingSpinner/index.d.ts.map +1 -0
  120. package/dist/ui/LoadingSpinner/index.js +122 -0
  121. package/dist/ui/Picker/actionBar.d.ts +14 -0
  122. package/dist/ui/Picker/actionBar.d.ts.map +1 -0
  123. package/dist/ui/Picker/actionBar.js +28 -0
  124. package/dist/ui/Picker/index.d.ts +5 -0
  125. package/dist/ui/Picker/index.d.ts.map +1 -0
  126. package/dist/ui/Picker/index.js +412 -0
  127. package/dist/ui/Picker/types.d.ts +80 -0
  128. package/dist/ui/Picker/types.d.ts.map +1 -0
  129. package/dist/ui/Picker/types.js +2 -0
  130. package/dist/ui/Picker/utils.d.ts +27 -0
  131. package/dist/ui/Picker/utils.d.ts.map +1 -0
  132. package/dist/ui/Picker/utils.js +182 -0
  133. package/dist/ui/Radio/index.d.ts +95 -0
  134. package/dist/ui/Radio/index.d.ts.map +1 -0
  135. package/dist/ui/Radio/index.js +633 -0
  136. package/dist/ui/Sheet/index.d.ts +12 -0
  137. package/dist/ui/Sheet/index.d.ts.map +1 -0
  138. package/dist/ui/Sheet/index.js +832 -0
  139. package/dist/ui/Sheet/nativeBottom.d.ts +52 -0
  140. package/dist/ui/Sheet/nativeBottom.d.ts.map +1 -0
  141. package/dist/ui/Sheet/nativeBottom.js +442 -0
  142. package/dist/ui/Sheet/nativeBottom.web.d.ts +18 -0
  143. package/dist/ui/Sheet/nativeBottom.web.d.ts.map +1 -0
  144. package/dist/ui/Sheet/nativeBottom.web.js +46 -0
  145. package/dist/ui/Sheet/slots.d.ts +5 -0
  146. package/dist/ui/Sheet/slots.d.ts.map +1 -0
  147. package/dist/ui/Sheet/slots.js +40 -0
  148. package/dist/ui/Sheet/types.d.ts +131 -0
  149. package/dist/ui/Sheet/types.d.ts.map +1 -0
  150. package/dist/ui/Sheet/types.js +2 -0
  151. package/dist/ui/SliderCaptcha/index.d.ts +57 -0
  152. package/dist/ui/SliderCaptcha/index.d.ts.map +1 -0
  153. package/dist/ui/SliderCaptcha/index.js +586 -0
  154. package/dist/ui/Switch/index.d.ts +72 -0
  155. package/dist/ui/Switch/index.d.ts.map +1 -0
  156. package/dist/ui/Switch/index.js +671 -0
  157. package/dist/ui/Text/index.d.ts +41 -0
  158. package/dist/ui/Text/index.d.ts.map +1 -0
  159. package/dist/ui/Text/index.js +325 -0
  160. package/dist/ui/TextInput/TextInputPrimitive.d.ts +8 -0
  161. package/dist/ui/TextInput/TextInputPrimitive.d.ts.map +1 -0
  162. package/dist/ui/TextInput/TextInputPrimitive.js +54 -0
  163. package/dist/ui/TextInput/index.d.ts +89 -0
  164. package/dist/ui/TextInput/index.d.ts.map +1 -0
  165. package/dist/ui/TextInput/index.js +545 -0
  166. package/dist/ui/WheelColumn/ZKitWheelPickerNativeComponent.d.ts +39 -0
  167. package/dist/ui/WheelColumn/ZKitWheelPickerNativeComponent.d.ts.map +1 -0
  168. package/dist/ui/WheelColumn/ZKitWheelPickerNativeComponent.js +60 -0
  169. package/dist/ui/WheelColumn/constants.d.ts +2 -0
  170. package/dist/ui/WheelColumn/constants.d.ts.map +1 -0
  171. package/dist/ui/WheelColumn/constants.js +4 -0
  172. package/dist/ui/WheelColumn/index.d.ts +59 -0
  173. package/dist/ui/WheelColumn/index.d.ts.map +1 -0
  174. package/dist/ui/WheelColumn/index.js +547 -0
  175. package/ios/ZKitWheelPicker.h +18 -0
  176. package/ios/ZKitWheelPicker.mm +230 -0
  177. package/ios/ZKitWheelPickerLabel.h +10 -0
  178. package/ios/ZKitWheelPickerLabel.mm +31 -0
  179. package/ios/ZKitWheelPickerManager.h +5 -0
  180. package/ios/ZKitWheelPickerManager.mm +53 -0
  181. package/package.json +75 -0
  182. package/react-native.config.js +10 -0
  183. package/src/ComponentLibProvider.tsx +56 -0
  184. package/src/assets/animations/spinner.json +1 -0
  185. package/src/assets/icons/check.svg +4 -0
  186. package/src/assets/icons/toast/error.webp +0 -0
  187. package/src/assets/icons/toast/success.webp +0 -0
  188. package/src/assets/icons/toast/warning.webp +0 -0
  189. package/src/config.ts +65 -0
  190. package/src/i18n/I18nProvider.tsx +69 -0
  191. package/src/i18n/locale.ts +108 -0
  192. package/src/i18n/locales/de.ts +67 -0
  193. package/src/i18n/locales/en-US.ts +67 -0
  194. package/src/i18n/locales/index.ts +19 -0
  195. package/src/i18n/locales/ja.ts +67 -0
  196. package/src/i18n/locales/zh-CN.ts +67 -0
  197. package/src/i18n/locales/zh-TW.ts +67 -0
  198. package/src/i18n/types.ts +21 -0
  199. package/src/i18n/useI18n.ts +7 -0
  200. package/src/index.ts +395 -0
  201. package/src/services/ActionDialogService/ActionDialog.tsx +756 -0
  202. package/src/services/ActionDialogService/README.md +146 -0
  203. package/src/services/ActionDialogService/index.tsx +39 -0
  204. package/src/services/ActionDialogService/service.tsx +355 -0
  205. package/src/services/ActionDialogService/shared.ts +204 -0
  206. package/src/services/ActionDialogService/types.ts +197 -0
  207. package/src/services/CardToastService/README.md +128 -0
  208. package/src/services/CardToastService/index.tsx +1284 -0
  209. package/src/services/ImagePreviewService/README.md +67 -0
  210. package/src/services/ImagePreviewService/index.tsx +2148 -0
  211. package/src/services/LoadingService/README.md +128 -0
  212. package/src/services/LoadingService/index.tsx +1113 -0
  213. package/src/services/PermissionPurposeDialogService/README.md +80 -0
  214. package/src/services/PermissionPurposeDialogService/index.tsx +449 -0
  215. package/src/services/PickerService/README.md +154 -0
  216. package/src/services/PickerService/index.tsx +410 -0
  217. package/src/theme/ThemeProvider.tsx +40 -0
  218. package/src/theme/defaultTheme.ts +30 -0
  219. package/src/theme/mergeTheme.ts +16 -0
  220. package/src/theme/types.ts +36 -0
  221. package/src/theme/useTheme.ts +10 -0
  222. package/src/types/svg.d.ts +9 -0
  223. package/src/types/vant-area-data.d.ts +19 -0
  224. package/src/ui/Accordion/README.md +67 -0
  225. package/src/ui/Accordion/index.tsx +1221 -0
  226. package/src/ui/AddressCascader/README.md +144 -0
  227. package/src/ui/AddressCascader/index.tsx +1084 -0
  228. package/src/ui/BetweenTime/README.md +490 -0
  229. package/src/ui/BetweenTime/index.tsx +1001 -0
  230. package/src/ui/Button/README.md +186 -0
  231. package/src/ui/Button/index.tsx +1356 -0
  232. package/src/ui/Checkbox/README.md +211 -0
  233. package/src/ui/Checkbox/index.tsx +1231 -0
  234. package/src/ui/DatePicker/README.md +117 -0
  235. package/src/ui/DatePicker/index.tsx +295 -0
  236. package/src/ui/DatePicker/types.ts +115 -0
  237. package/src/ui/DatePicker/utils.ts +405 -0
  238. package/src/ui/LinkedScroll/README.md +55 -0
  239. package/src/ui/LinkedScroll/index.tsx +809 -0
  240. package/src/ui/LoadingSpinner/index.tsx +104 -0
  241. package/src/ui/Picker/README.md +190 -0
  242. package/src/ui/Picker/actionBar.tsx +70 -0
  243. package/src/ui/Picker/index.tsx +694 -0
  244. package/src/ui/Picker/types.ts +94 -0
  245. package/src/ui/Picker/utils.ts +239 -0
  246. package/src/ui/Radio/README.md +207 -0
  247. package/src/ui/Radio/index.tsx +1117 -0
  248. package/src/ui/Sheet/README.md +82 -0
  249. package/src/ui/Sheet/index.tsx +1163 -0
  250. package/src/ui/Sheet/nativeBottom.tsx +683 -0
  251. package/src/ui/Sheet/nativeBottom.web.tsx +40 -0
  252. package/src/ui/Sheet/slots.tsx +75 -0
  253. package/src/ui/Sheet/types.ts +195 -0
  254. package/src/ui/SliderCaptcha/README.md +61 -0
  255. package/src/ui/SliderCaptcha/index.tsx +816 -0
  256. package/src/ui/Switch/README.md +143 -0
  257. package/src/ui/Switch/index.tsx +1092 -0
  258. package/src/ui/Text/README.md +157 -0
  259. package/src/ui/Text/index.tsx +450 -0
  260. package/src/ui/TextInput/README.md +197 -0
  261. package/src/ui/TextInput/TextInputPrimitive.tsx +44 -0
  262. package/src/ui/TextInput/index.tsx +942 -0
  263. package/src/ui/WheelColumn/README.md +104 -0
  264. package/src/ui/WheelColumn/ZKitWheelPickerNativeComponent.tsx +68 -0
  265. package/src/ui/WheelColumn/constants.ts +1 -0
  266. package/src/ui/WheelColumn/index.tsx +826 -0
  267. package/zkit-ui.podspec +19 -0
@@ -0,0 +1,899 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.toast = void 0;
37
+ exports.ToastProvider = ToastProvider;
38
+ const jsx_runtime_1 = require("react/jsx-runtime");
39
+ /**
40
+ * @file CardToastService
41
+ * @description A service-driven toast viewport for lightweight global feedback.
42
+ */
43
+ const React = __importStar(require("react"));
44
+ const vector_icons_1 = require("@expo/vector-icons");
45
+ const expo_image_1 = require("expo-image");
46
+ const react_native_1 = require("react-native");
47
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
48
+ const react_native_safe_area_context_1 = require("react-native-safe-area-context");
49
+ const react_native_worklets_1 = require("react-native-worklets");
50
+ const zkit_tools_1 = require("zkit-tools");
51
+ const useTheme_1 = require("../../theme/useTheme");
52
+ const Text_1 = require("../../ui/Text");
53
+ // ============================================================================
54
+ // Defaults
55
+ // ============================================================================
56
+ const DEFAULT_DURATION = 2400;
57
+ const DEFAULT_OFFSET = 35;
58
+ const DEFAULT_PLACEMENT = 'top';
59
+ const DEFAULT_STRATEGY = 'replace';
60
+ const DEFAULT_MAX_VISIBLE = 3;
61
+ const DEFAULT_CLOSE_BUTTON = false;
62
+ const DEFAULT_LIVE_REGION = 'polite';
63
+ const MAX_VISIBLE_TOASTS = 5;
64
+ const MAX_PENDING_TOASTS = 20;
65
+ const TOAST_HOST_Z_INDEX = 9200;
66
+ const DEFAULT_TOAST_ID_PREFIX = 'toast';
67
+ const EMPTY_SNAPSHOT = { items: [] };
68
+ const TOAST_ICON_SUCCESS = require('../../assets/icons/toast/success.webp');
69
+ const TOAST_ICON_ERROR = require('../../assets/icons/toast/error.webp');
70
+ const TOAST_ICON_WARNING = require('../../assets/icons/toast/warning.webp');
71
+ const IOS_TOAST_ENTER_OFFSET = (0, zkit_tools_1.wp)(22);
72
+ const IOS_TOAST_EXIT_OFFSET = (0, zkit_tools_1.wp)(14);
73
+ const IOS_TOAST_CONTENT_OFFSET = (0, zkit_tools_1.wp)(6);
74
+ const IOS_TOAST_SHADOW_RADIUS = (0, zkit_tools_1.wp)(18);
75
+ const IOS_TOAST_ENTER_EASING = react_native_reanimated_1.Easing.bezier(0.22, 1, 0.36, 1);
76
+ const IOS_TOAST_EXIT_EASING = react_native_reanimated_1.Easing.bezier(0.4, 0, 1, 1);
77
+ const IOS_TOAST_ENTER_SPRING = {
78
+ damping: 18,
79
+ stiffness: 260,
80
+ mass: 0.78,
81
+ };
82
+ const IOS_TOAST_SCALE_SPRING = {
83
+ damping: 16,
84
+ stiffness: 280,
85
+ mass: 0.72,
86
+ };
87
+ const IOS_TOAST_SQUASH_SPRING = {
88
+ damping: 15,
89
+ stiffness: 240,
90
+ mass: 0.68,
91
+ };
92
+ const DEFAULTS = {
93
+ duration: DEFAULT_DURATION,
94
+ placement: DEFAULT_PLACEMENT,
95
+ offset: DEFAULT_OFFSET,
96
+ strategy: DEFAULT_STRATEGY,
97
+ maxVisible: DEFAULT_MAX_VISIBLE,
98
+ closeButton: DEFAULT_CLOSE_BUTTON,
99
+ accessibilityLiveRegion: DEFAULT_LIVE_REGION,
100
+ };
101
+ // ============================================================================
102
+ // Normalizers
103
+ // ============================================================================
104
+ function isPromiseLike(value) {
105
+ return Boolean(value && typeof value.then === 'function');
106
+ }
107
+ function normalizeId(value) {
108
+ if (typeof value !== 'string')
109
+ return undefined;
110
+ const id = value.trim();
111
+ return id || undefined;
112
+ }
113
+ function normalizeTone(value) {
114
+ if (value === 'success' || value === 'error' || value === 'warning' || value === 'info' || value === 'neutral') {
115
+ return value;
116
+ }
117
+ return undefined;
118
+ }
119
+ function normalizePlacement(value) {
120
+ if (value === 'top' || value === 'bottom')
121
+ return value;
122
+ return undefined;
123
+ }
124
+ function normalizeStrategy(value) {
125
+ if (value === 'replace' || value === 'queue' || value === 'stack')
126
+ return value;
127
+ return undefined;
128
+ }
129
+ function normalizeDuration(value, fallback) {
130
+ if (typeof value !== 'number' || !Number.isFinite(value))
131
+ return fallback;
132
+ return Math.max(0, Math.round(value));
133
+ }
134
+ function normalizeOffset(value, fallback) {
135
+ if (typeof value !== 'number' || !Number.isFinite(value))
136
+ return fallback;
137
+ return Math.max(0, value);
138
+ }
139
+ function normalizeMaxVisible(value, fallback) {
140
+ if (typeof value !== 'number' || !Number.isFinite(value))
141
+ return fallback;
142
+ return Math.max(1, Math.min(MAX_VISIBLE_TOASTS, Math.round(value)));
143
+ }
144
+ function normalizeLiveRegion(value, fallback) {
145
+ if (value === 'none' || value === 'polite' || value === 'assertive')
146
+ return value;
147
+ return fallback;
148
+ }
149
+ function normalizeNode(value) {
150
+ if (value == null || value === false || value === true)
151
+ return undefined;
152
+ if (value instanceof Error)
153
+ return value.message || String(value);
154
+ return value;
155
+ }
156
+ function getTextFromNode(value) {
157
+ if (value == null || typeof value === 'boolean')
158
+ return '';
159
+ if (typeof value === 'string')
160
+ return value.trim();
161
+ if (typeof value === 'number')
162
+ return String(value);
163
+ if (Array.isArray(value))
164
+ return value.map(getTextFromNode).filter(Boolean).join(' ').trim();
165
+ if (React.isValidElement(value))
166
+ return getTextFromNode(value.props.children);
167
+ return '';
168
+ }
169
+ function createAccessibilityLabel(title, description) {
170
+ const titleText = getTextFromNode(title);
171
+ const descriptionText = getTextFromNode(description);
172
+ if (titleText && descriptionText)
173
+ return `${titleText},${descriptionText}`;
174
+ return titleText || descriptionText || 'Notification';
175
+ }
176
+ function getHandleId(idOrHandle) {
177
+ if (!idOrHandle)
178
+ return undefined;
179
+ if (typeof idOrHandle === 'string')
180
+ return normalizeId(idOrHandle);
181
+ return normalizeId(idOrHandle.id);
182
+ }
183
+ function warnInvalidToast() {
184
+ if (typeof console === 'undefined')
185
+ return;
186
+ console.warn('[toast] show() requires title, description, or render.');
187
+ }
188
+ // ============================================================================
189
+ // Store
190
+ // ============================================================================
191
+ class ToastStore {
192
+ constructor() {
193
+ this.defaults = { ...DEFAULTS };
194
+ this.snapshot = EMPTY_SNAPSHOT;
195
+ this.pending = [];
196
+ this.listeners = new Set();
197
+ this.timers = new Map();
198
+ this.idSeed = 0;
199
+ this.hostCount = 0;
200
+ this.subscribe = (listener) => {
201
+ this.listeners.add(listener);
202
+ this.hostCount += 1;
203
+ this.scheduleVisibleToasts();
204
+ return () => {
205
+ this.listeners.delete(listener);
206
+ this.hostCount = Math.max(0, this.hostCount - 1);
207
+ if (this.hostCount === 0)
208
+ this.clearAll('provider-unmount');
209
+ };
210
+ };
211
+ this.getSnapshot = () => this.snapshot;
212
+ }
213
+ configure(defaults) {
214
+ var _a, _b, _c;
215
+ if (!defaults)
216
+ return;
217
+ this.defaults = {
218
+ duration: normalizeDuration(defaults.duration, this.defaults.duration),
219
+ placement: (_a = normalizePlacement(defaults.placement)) !== null && _a !== void 0 ? _a : this.defaults.placement,
220
+ offset: normalizeOffset(defaults.offset, this.defaults.offset),
221
+ strategy: (_b = normalizeStrategy(defaults.strategy)) !== null && _b !== void 0 ? _b : this.defaults.strategy,
222
+ maxVisible: normalizeMaxVisible(defaults.maxVisible, this.defaults.maxVisible),
223
+ closeButton: (_c = defaults.closeButton) !== null && _c !== void 0 ? _c : this.defaults.closeButton,
224
+ accessibilityLiveRegion: normalizeLiveRegion(defaults.accessibilityLiveRegion, this.defaults.accessibilityLiveRegion),
225
+ };
226
+ }
227
+ getDefaults() {
228
+ return { ...this.defaults };
229
+ }
230
+ show(options) {
231
+ const item = this.resolveToast(options);
232
+ if (!item)
233
+ return this.createHandle('');
234
+ this.enqueue(item);
235
+ return this.createHandle(item.id);
236
+ }
237
+ custom(render, options = {}) {
238
+ return this.show({ ...options, render });
239
+ }
240
+ success(title, options) {
241
+ return this.showShortcut('success', title, options);
242
+ }
243
+ error(title, options) {
244
+ return this.showShortcut('error', title, options);
245
+ }
246
+ warning(title, options) {
247
+ return this.showShortcut('warning', title, options);
248
+ }
249
+ info(title, options) {
250
+ return this.showShortcut('info', title, options);
251
+ }
252
+ neutral(title, options) {
253
+ return this.showShortcut('neutral', title, options);
254
+ }
255
+ update(idOrHandle, patch) {
256
+ const id = getHandleId(idOrHandle);
257
+ if (!id)
258
+ return false;
259
+ const pendingIndex = this.pending.findIndex((item) => item.id === id);
260
+ if (pendingIndex >= 0) {
261
+ this.pending[pendingIndex] = this.applyPatch(this.pending[pendingIndex], patch);
262
+ return true;
263
+ }
264
+ const index = this.snapshot.items.findIndex((item) => item.id === id);
265
+ if (index < 0)
266
+ return false;
267
+ const nextItems = [...this.snapshot.items];
268
+ const nextItem = this.applyPatch(nextItems[index], patch);
269
+ nextItems[index] = nextItem;
270
+ this.setItems(nextItems);
271
+ if (nextItem.open)
272
+ this.schedule(nextItem);
273
+ this.callOpenChange(nextItem, true, 'update');
274
+ return true;
275
+ }
276
+ dismiss(idOrHandle, reason = 'api') {
277
+ var _a;
278
+ const id = (_a = getHandleId(idOrHandle)) !== null && _a !== void 0 ? _a : this.getLatestOpenId();
279
+ if (!id)
280
+ return;
281
+ this.dismissByIds([id], reason);
282
+ }
283
+ dismissAll(reason = 'api') {
284
+ const openIds = this.snapshot.items.filter((item) => item.open).map((item) => item.id);
285
+ this.pending.forEach((item) => this.callDismiss(item, reason));
286
+ this.pending = [];
287
+ this.dismissByIds(openIds, reason);
288
+ }
289
+ isActive(idOrHandle) {
290
+ const id = getHandleId(idOrHandle);
291
+ if (!id)
292
+ return false;
293
+ return this.snapshot.items.some((item) => item.id === id && item.open) || this.pending.some((item) => item.id === id);
294
+ }
295
+ completeExit(id) {
296
+ if (!this.snapshot.items.some((item) => item.id === id && !item.open))
297
+ return;
298
+ this.setItems(this.snapshot.items.filter((item) => item.id !== id));
299
+ this.promoteQueuedToast();
300
+ }
301
+ showShortcut(tone, title, options = {}) {
302
+ return this.show({ ...options, title, tone });
303
+ }
304
+ resolveToast(options) {
305
+ var _a, _b, _c, _d, _e, _f;
306
+ const title = normalizeNode(options.title);
307
+ const description = normalizeNode(options.description);
308
+ if (!title && !description && !options.render) {
309
+ warnInvalidToast();
310
+ return null;
311
+ }
312
+ const now = Date.now();
313
+ const tone = (_a = normalizeTone(options.tone)) !== null && _a !== void 0 ? _a : 'info';
314
+ const duration = normalizeDuration(options.duration, this.defaults.duration);
315
+ const closeButton = ((_b = options.closeButton) !== null && _b !== void 0 ? _b : this.defaults.closeButton) || duration <= 0;
316
+ return {
317
+ id: (_c = normalizeId(options.id)) !== null && _c !== void 0 ? _c : this.createId(),
318
+ tone,
319
+ title,
320
+ description,
321
+ duration,
322
+ placement: (_d = normalizePlacement(options.placement)) !== null && _d !== void 0 ? _d : this.defaults.placement,
323
+ offset: normalizeOffset(options.offset, this.defaults.offset),
324
+ strategy: (_e = normalizeStrategy(options.strategy)) !== null && _e !== void 0 ? _e : this.defaults.strategy,
325
+ maxVisible: normalizeMaxVisible(options.maxVisible, this.defaults.maxVisible),
326
+ action: options.action,
327
+ closeButton,
328
+ icon: options.icon,
329
+ render: options.render,
330
+ accessibilityLabel: (_f = options.accessibilityLabel) !== null && _f !== void 0 ? _f : createAccessibilityLabel(title, description),
331
+ accessibilityLiveRegion: normalizeLiveRegion(options.accessibilityLiveRegion, tone === 'error' ? 'assertive' : this.defaults.accessibilityLiveRegion),
332
+ testID: options.testID,
333
+ style: options.style,
334
+ open: true,
335
+ createdAt: now,
336
+ updatedAt: now,
337
+ onDismiss: options.onDismiss,
338
+ onOpenChange: options.onOpenChange,
339
+ };
340
+ }
341
+ applyPatch(item, patch) {
342
+ var _a, _b, _c, _d, _e, _f, _g, _h;
343
+ const title = 'title' in patch ? normalizeNode(patch.title) : item.title;
344
+ const description = 'description' in patch ? normalizeNode(patch.description) : item.description;
345
+ const tone = (_a = normalizeTone(patch.tone)) !== null && _a !== void 0 ? _a : item.tone;
346
+ const duration = 'duration' in patch ? normalizeDuration(patch.duration, item.duration) : item.duration;
347
+ const closeButton = 'closeButton' in patch ? (_b = patch.closeButton) !== null && _b !== void 0 ? _b : item.closeButton : item.closeButton || duration <= 0;
348
+ return {
349
+ ...item,
350
+ tone,
351
+ title,
352
+ description,
353
+ duration,
354
+ placement: (_c = normalizePlacement(patch.placement)) !== null && _c !== void 0 ? _c : item.placement,
355
+ offset: normalizeOffset(patch.offset, item.offset),
356
+ action: 'action' in patch ? patch.action : item.action,
357
+ closeButton,
358
+ icon: 'icon' in patch ? patch.icon : item.icon,
359
+ render: 'render' in patch ? patch.render : item.render,
360
+ accessibilityLabel: (_e = (_d = patch.accessibilityLabel) !== null && _d !== void 0 ? _d : item.accessibilityLabel) !== null && _e !== void 0 ? _e : createAccessibilityLabel(title, description),
361
+ accessibilityLiveRegion: normalizeLiveRegion(patch.accessibilityLiveRegion, item.accessibilityLiveRegion),
362
+ testID: (_f = patch.testID) !== null && _f !== void 0 ? _f : item.testID,
363
+ style: 'style' in patch ? patch.style : item.style,
364
+ onDismiss: (_g = patch.onDismiss) !== null && _g !== void 0 ? _g : item.onDismiss,
365
+ onOpenChange: (_h = patch.onOpenChange) !== null && _h !== void 0 ? _h : item.onOpenChange,
366
+ updatedAt: Date.now(),
367
+ };
368
+ }
369
+ enqueue(item) {
370
+ if (item.strategy === 'queue' && this.snapshot.items.length > 0) {
371
+ this.pending.push(item);
372
+ this.trimPendingQueue();
373
+ return;
374
+ }
375
+ if (item.strategy === 'replace') {
376
+ this.pending.forEach((pendingItem) => this.callDismiss(pendingItem, 'replace'));
377
+ this.pending = [];
378
+ this.snapshot.items.forEach((currentItem) => {
379
+ this.clearTimer(currentItem.id);
380
+ if (currentItem.open) {
381
+ this.callDismiss(currentItem, 'replace');
382
+ this.callOpenChange(currentItem, false, 'replace');
383
+ }
384
+ });
385
+ this.setItems([item]);
386
+ this.callOpenChange(item, true, 'show');
387
+ this.schedule(item);
388
+ return;
389
+ }
390
+ const openInPlacement = this.snapshot.items
391
+ .filter((toastItem) => toastItem.open && toastItem.placement === item.placement)
392
+ .sort((a, b) => a.createdAt - b.createdAt);
393
+ let nextItems = this.snapshot.items;
394
+ if (openInPlacement.length >= item.maxVisible) {
395
+ const overflowItem = openInPlacement[0];
396
+ nextItems = this.closeItems(nextItems, 'overflow', [overflowItem.id]);
397
+ }
398
+ this.setItems([...nextItems, item]);
399
+ this.callOpenChange(item, true, 'show');
400
+ this.schedule(item);
401
+ }
402
+ closeItems(items, reason, ids) {
403
+ const idSet = ids ? new Set(ids) : undefined;
404
+ return items.map((item) => {
405
+ if (!item.open || (idSet && !idSet.has(item.id)))
406
+ return item;
407
+ this.clearTimer(item.id);
408
+ const nextItem = {
409
+ ...item,
410
+ open: false,
411
+ updatedAt: Date.now(),
412
+ dismissedReason: reason,
413
+ };
414
+ this.callDismiss(nextItem, reason);
415
+ this.callOpenChange(nextItem, false, reason);
416
+ return nextItem;
417
+ });
418
+ }
419
+ dismissByIds(ids, reason) {
420
+ if (!ids.length)
421
+ return;
422
+ const nextItems = this.closeItems(this.snapshot.items, reason, ids);
423
+ this.setItems(nextItems);
424
+ this.promoteQueuedToast();
425
+ }
426
+ promoteQueuedToast() {
427
+ if (this.snapshot.items.length > 0)
428
+ return;
429
+ const nextItem = this.pending.shift();
430
+ if (!nextItem)
431
+ return;
432
+ this.setItems([...this.snapshot.items, nextItem]);
433
+ this.callOpenChange(nextItem, true, 'show');
434
+ this.schedule(nextItem);
435
+ }
436
+ trimPendingQueue() {
437
+ while (this.pending.length > MAX_PENDING_TOASTS) {
438
+ const dropped = this.pending.shift();
439
+ if (dropped)
440
+ this.callDismiss(dropped, 'overflow');
441
+ }
442
+ }
443
+ scheduleVisibleToasts() {
444
+ this.snapshot.items.forEach((item) => {
445
+ if (item.open)
446
+ this.schedule(item);
447
+ });
448
+ }
449
+ schedule(item) {
450
+ this.clearTimer(item.id);
451
+ if (this.hostCount <= 0 || !item.open || item.duration <= 0)
452
+ return;
453
+ this.timers.set(item.id, setTimeout(() => {
454
+ this.dismiss(item.id, 'timeout');
455
+ }, item.duration));
456
+ }
457
+ clearTimer(id) {
458
+ const timer = this.timers.get(id);
459
+ if (!timer)
460
+ return;
461
+ clearTimeout(timer);
462
+ this.timers.delete(id);
463
+ }
464
+ clearAll(reason) {
465
+ this.timers.forEach((timer) => clearTimeout(timer));
466
+ this.timers.clear();
467
+ [...this.snapshot.items, ...this.pending].forEach((item) => {
468
+ const internalItem = item;
469
+ if (internalItem.open || !internalItem.dismissedReason)
470
+ this.callDismiss(internalItem, reason);
471
+ });
472
+ this.pending = [];
473
+ this.setItems([]);
474
+ }
475
+ setItems(items) {
476
+ this.snapshot = items.length ? { items } : EMPTY_SNAPSHOT;
477
+ this.listeners.forEach((listener) => listener());
478
+ }
479
+ getLatestOpenId() {
480
+ var _a;
481
+ const openItems = this.snapshot.items.filter((item) => item.open);
482
+ return (_a = openItems.sort((a, b) => b.createdAt - a.createdAt)[0]) === null || _a === void 0 ? void 0 : _a.id;
483
+ }
484
+ createId() {
485
+ this.idSeed += 1;
486
+ return `${DEFAULT_TOAST_ID_PREFIX}_${Date.now()}_${this.idSeed}`;
487
+ }
488
+ createHandle(id) {
489
+ return {
490
+ id,
491
+ dismiss: (reason = 'api') => this.dismiss(id, reason),
492
+ update: (patch) => {
493
+ this.update(id, patch);
494
+ },
495
+ };
496
+ }
497
+ callDismiss(item, reason) {
498
+ var _a;
499
+ if (item.dismissedReason && item.dismissedReason !== reason)
500
+ return;
501
+ try {
502
+ (_a = item.onDismiss) === null || _a === void 0 ? void 0 : _a.call(item, reason, item.id);
503
+ }
504
+ catch (error) {
505
+ console.error('[toast] onDismiss failed', error);
506
+ }
507
+ }
508
+ callOpenChange(item, open, reason) {
509
+ var _a;
510
+ try {
511
+ (_a = item.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(item, open, { id: item.id, open, reason });
512
+ }
513
+ catch (error) {
514
+ console.error('[toast] onOpenChange failed', error);
515
+ }
516
+ }
517
+ }
518
+ const toastStore = new ToastStore();
519
+ exports.toast = toastStore;
520
+ // ============================================================================
521
+ // Provider
522
+ // ============================================================================
523
+ function useToastSnapshot() {
524
+ return React.useSyncExternalStore(toastStore.subscribe, toastStore.getSnapshot, toastStore.getSnapshot);
525
+ }
526
+ function ToastProvider({ children, defaults }) {
527
+ const snapshot = useToastSnapshot();
528
+ const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
529
+ React.useEffect(() => {
530
+ toastStore.configure(defaults);
531
+ }, [defaults]);
532
+ const topItems = React.useMemo(() => snapshot.items
533
+ .filter((item) => item.placement === 'top')
534
+ .sort((a, b) => b.createdAt - a.createdAt), [snapshot.items]);
535
+ const bottomItems = React.useMemo(() => snapshot.items
536
+ .filter((item) => item.placement === 'bottom')
537
+ .sort((a, b) => b.createdAt - a.createdAt), [snapshot.items]);
538
+ const handleExited = React.useCallback((id) => {
539
+ toastStore.completeExit(id);
540
+ }, []);
541
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [children, (0, jsx_runtime_1.jsx)(ToastViewport, { insets: insets, items: topItems, placement: "top", onExited: handleExited }), (0, jsx_runtime_1.jsx)(ToastViewport, { insets: insets, items: bottomItems, placement: "bottom", onExited: handleExited })] }));
542
+ }
543
+ function pickToneConfig(tone) {
544
+ if (tone === 'success') {
545
+ return {
546
+ bgColor: '#EEF7F2',
547
+ borderColor: '#CFE1D9',
548
+ accentColor: '#16A34A',
549
+ iconSource: TOAST_ICON_SUCCESS,
550
+ };
551
+ }
552
+ if (tone === 'error') {
553
+ return {
554
+ bgColor: '#FBEEF0',
555
+ borderColor: '#E7D1D8',
556
+ accentColor: '#DC2626',
557
+ iconSource: TOAST_ICON_ERROR,
558
+ };
559
+ }
560
+ return {
561
+ bgColor: '#FDF7ED',
562
+ borderColor: '#F7E0B3',
563
+ accentColor: '#D97706',
564
+ iconSource: TOAST_ICON_WARNING,
565
+ };
566
+ }
567
+ function getDisplayContent(item) {
568
+ if (item.title && item.description) {
569
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [item.title, " ", item.description] }));
570
+ }
571
+ return item.title || item.description;
572
+ }
573
+ function useToastActionContext(id) {
574
+ return React.useMemo(() => ({
575
+ id,
576
+ dismiss: (reason = 'api') => toastStore.dismiss(id, reason),
577
+ update: (patch) => {
578
+ toastStore.update(id, patch);
579
+ },
580
+ }), [id]);
581
+ }
582
+ function ToastViewport({ insets, items, placement, onExited }) {
583
+ var _a, _b;
584
+ if (!items.length)
585
+ return null;
586
+ const edgeOffset = (_b = (_a = items[0]) === null || _a === void 0 ? void 0 : _a.offset) !== null && _b !== void 0 ? _b : DEFAULT_OFFSET;
587
+ const edgeInset = placement === 'top' ? insets.top : insets.bottom;
588
+ const viewportStyle = placement === 'top'
589
+ ? { top: edgeInset + (0, zkit_tools_1.wp)(edgeOffset) }
590
+ : { bottom: edgeInset + (0, zkit_tools_1.wp)(edgeOffset), flexDirection: 'column-reverse' };
591
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { pointerEvents: "box-none", style: [styles.viewport, viewportStyle], children: items.map((item, index) => {
592
+ const stackStyle = index === 0
593
+ ? undefined
594
+ : placement === 'top'
595
+ ? { marginTop: (0, zkit_tools_1.wp)(8) }
596
+ : { marginBottom: (0, zkit_tools_1.wp)(8) };
597
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { pointerEvents: "box-none", style: stackStyle, children: (0, jsx_runtime_1.jsx)(ToastCard, { item: item, placement: placement, onExited: onExited }) }, item.id));
598
+ }) }));
599
+ }
600
+ function ToastCardBody({ item, actionContext, toneConfig, style, children }) {
601
+ const theme = (0, useTheme_1.useTheme)();
602
+ const message = getDisplayContent(item);
603
+ return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [styles.toastContent, style, { backgroundColor: toneConfig.bgColor, borderColor: toneConfig.borderColor }], children: [children, (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.row, children: [renderToastIcon(item, toneConfig), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.content, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { style: [styles.message, { color: theme.colors.onSurface }], numberOfLines: 3, children: message }), item.action ? ((0, jsx_runtime_1.jsx)(ToastActionButton, { action: item.action, context: actionContext, toneConfig: toneConfig })) : null] }), item.closeButton ? ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { accessibilityLabel: "Dismiss notification", accessibilityRole: "button", hitSlop: (0, zkit_tools_1.wp)(8), onPress: () => actionContext.dismiss('close-button'), style: ({ pressed }) => [styles.closeButton, { opacity: pressed ? 0.62 : 1 }], children: (0, jsx_runtime_1.jsx)(vector_icons_1.Feather, { name: "x", size: (0, zkit_tools_1.wp)(15), color: theme.colors.muted }) })) : null] })] }));
604
+ }
605
+ function IOSToastCard({ item, placement, onExited }) {
606
+ const actionContext = useToastActionContext(item.id);
607
+ const toneConfig = pickToneConfig(item.tone);
608
+ const direction = placement === 'top' ? -1 : 1;
609
+ const enterOffset = direction * IOS_TOAST_ENTER_OFFSET;
610
+ const exitOffset = direction * IOS_TOAST_EXIT_OFFSET;
611
+ const opacity = (0, react_native_reanimated_1.useSharedValue)(item.open ? 1 : 0);
612
+ const translateY = (0, react_native_reanimated_1.useSharedValue)(item.open ? 0 : exitOffset);
613
+ const scale = (0, react_native_reanimated_1.useSharedValue)(item.open ? 1 : 0.975);
614
+ const squash = (0, react_native_reanimated_1.useSharedValue)(0);
615
+ const contentProgress = (0, react_native_reanimated_1.useSharedValue)(item.open ? 1 : 0);
616
+ const sheenOpacity = (0, react_native_reanimated_1.useSharedValue)(item.open ? 0.08 : 0);
617
+ const isInteractive = Boolean(item.action || item.closeButton || item.render);
618
+ React.useEffect(() => {
619
+ return () => {
620
+ (0, react_native_reanimated_1.cancelAnimation)(opacity);
621
+ (0, react_native_reanimated_1.cancelAnimation)(translateY);
622
+ (0, react_native_reanimated_1.cancelAnimation)(scale);
623
+ (0, react_native_reanimated_1.cancelAnimation)(squash);
624
+ (0, react_native_reanimated_1.cancelAnimation)(contentProgress);
625
+ (0, react_native_reanimated_1.cancelAnimation)(sheenOpacity);
626
+ };
627
+ }, [contentProgress, opacity, scale, sheenOpacity, squash, translateY]);
628
+ React.useEffect(() => {
629
+ (0, react_native_reanimated_1.cancelAnimation)(opacity);
630
+ (0, react_native_reanimated_1.cancelAnimation)(translateY);
631
+ (0, react_native_reanimated_1.cancelAnimation)(scale);
632
+ (0, react_native_reanimated_1.cancelAnimation)(squash);
633
+ (0, react_native_reanimated_1.cancelAnimation)(contentProgress);
634
+ (0, react_native_reanimated_1.cancelAnimation)(sheenOpacity);
635
+ if (item.open) {
636
+ opacity.value = 0;
637
+ translateY.value = enterOffset;
638
+ scale.value = 0.955;
639
+ squash.value = 1;
640
+ contentProgress.value = 0;
641
+ sheenOpacity.value = 0.14;
642
+ opacity.value = (0, react_native_reanimated_1.withTiming)(1, { duration: 220, easing: IOS_TOAST_ENTER_EASING });
643
+ translateY.value = (0, react_native_reanimated_1.withSpring)(0, IOS_TOAST_ENTER_SPRING);
644
+ scale.value = (0, react_native_reanimated_1.withSpring)(1, IOS_TOAST_SCALE_SPRING);
645
+ squash.value = (0, react_native_reanimated_1.withSpring)(0, IOS_TOAST_SQUASH_SPRING);
646
+ contentProgress.value = (0, react_native_reanimated_1.withTiming)(1, { duration: 260, easing: IOS_TOAST_ENTER_EASING });
647
+ sheenOpacity.value = (0, react_native_reanimated_1.withTiming)(0.06, { duration: 340, easing: IOS_TOAST_ENTER_EASING });
648
+ return;
649
+ }
650
+ opacity.value = (0, react_native_reanimated_1.withTiming)(0, { duration: 160, easing: IOS_TOAST_EXIT_EASING }, (finished) => {
651
+ if (finished)
652
+ (0, react_native_worklets_1.scheduleOnRN)(onExited, item.id);
653
+ });
654
+ translateY.value = (0, react_native_reanimated_1.withTiming)(exitOffset, { duration: 180, easing: IOS_TOAST_EXIT_EASING });
655
+ scale.value = (0, react_native_reanimated_1.withTiming)(0.975, { duration: 180, easing: IOS_TOAST_EXIT_EASING });
656
+ squash.value = (0, react_native_reanimated_1.withTiming)(0.32, { duration: 120, easing: IOS_TOAST_EXIT_EASING });
657
+ contentProgress.value = (0, react_native_reanimated_1.withTiming)(0, { duration: 120, easing: IOS_TOAST_EXIT_EASING });
658
+ sheenOpacity.value = (0, react_native_reanimated_1.withTiming)(0, { duration: 110, easing: IOS_TOAST_EXIT_EASING });
659
+ }, [
660
+ contentProgress,
661
+ enterOffset,
662
+ exitOffset,
663
+ item.id,
664
+ item.open,
665
+ onExited,
666
+ opacity,
667
+ scale,
668
+ sheenOpacity,
669
+ squash,
670
+ translateY,
671
+ ]);
672
+ const animatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
673
+ const scaleX = scale.value * (0, react_native_reanimated_1.interpolate)(squash.value, [0, 1], [1, 1.028]);
674
+ const scaleY = scale.value * (0, react_native_reanimated_1.interpolate)(squash.value, [0, 1], [1, 0.942]);
675
+ return {
676
+ opacity: opacity.value,
677
+ transform: [{ translateY: translateY.value }, { scaleX }, { scaleY }],
678
+ shadowOpacity: (0, react_native_reanimated_1.interpolate)(opacity.value, [0, 1], [0, 0.16]),
679
+ shadowRadius: (0, react_native_reanimated_1.interpolate)(opacity.value, [0, 1], [0, IOS_TOAST_SHADOW_RADIUS]),
680
+ };
681
+ });
682
+ const contentAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
683
+ opacity: (0, react_native_reanimated_1.interpolate)(contentProgress.value, [0, 1], [0.7, 1]),
684
+ transform: [
685
+ { translateY: (0, react_native_reanimated_1.interpolate)(contentProgress.value, [0, 1], [direction * IOS_TOAST_CONTENT_OFFSET, 0]) },
686
+ { scale: (0, react_native_reanimated_1.interpolate)(contentProgress.value, [0, 1], [0.985, 1]) },
687
+ ],
688
+ }));
689
+ const sheenAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
690
+ opacity: sheenOpacity.value,
691
+ }));
692
+ if (item.render) {
693
+ return ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: isInteractive ? 'auto' : 'none', accessible: !isInteractive, accessibilityRole: "alert", accessibilityLabel: item.accessibilityLabel, accessibilityLiveRegion: item.accessibilityLiveRegion, shouldRasterizeIOS: true, style: [styles.toast, styles.toastIOS, animatedStyle, item.style], testID: item.testID, children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: contentAnimatedStyle, children: item.render({ ...actionContext, toast: item }) }) }));
694
+ }
695
+ return ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: isInteractive ? 'auto' : 'none', accessible: !isInteractive, accessibilityRole: "alert", accessibilityLabel: item.accessibilityLabel, accessibilityLiveRegion: item.accessibilityLiveRegion, shouldRasterizeIOS: true, style: [
696
+ styles.toast,
697
+ styles.toastIOS,
698
+ styles.toastSurface,
699
+ { backgroundColor: toneConfig.bgColor },
700
+ animatedStyle,
701
+ item.style,
702
+ ], testID: item.testID, children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: contentAnimatedStyle, children: (0, jsx_runtime_1.jsx)(ToastCardBody, { item: item, actionContext: actionContext, toneConfig: toneConfig, style: styles.toastContentIOS, children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: "none", style: [styles.toastSheen, sheenAnimatedStyle] }) }) }) }));
703
+ }
704
+ function DefaultToastCard({ item, placement, onExited }) {
705
+ const actionContext = useToastActionContext(item.id);
706
+ const toneConfig = pickToneConfig(item.tone);
707
+ const direction = placement === 'top' ? -1 : 1;
708
+ const anim = React.useRef(new react_native_1.Animated.Value(0)).current;
709
+ const lastVisibleRef = React.useRef(false);
710
+ const isInteractive = Boolean(item.action || item.closeButton || item.render);
711
+ React.useEffect(() => {
712
+ return () => {
713
+ anim.stopAnimation();
714
+ };
715
+ }, [anim]);
716
+ React.useEffect(() => {
717
+ if (item.open && !lastVisibleRef.current) {
718
+ anim.stopAnimation();
719
+ anim.setValue(0);
720
+ react_native_1.Animated.timing(anim, {
721
+ toValue: 1,
722
+ duration: 160,
723
+ easing: react_native_1.Easing.out(react_native_1.Easing.cubic),
724
+ useNativeDriver: true,
725
+ }).start();
726
+ lastVisibleRef.current = true;
727
+ return;
728
+ }
729
+ if (!item.open && lastVisibleRef.current) {
730
+ anim.stopAnimation();
731
+ react_native_1.Animated.timing(anim, {
732
+ toValue: 0,
733
+ duration: 140,
734
+ easing: react_native_1.Easing.out(react_native_1.Easing.cubic),
735
+ useNativeDriver: true,
736
+ }).start(() => {
737
+ lastVisibleRef.current = false;
738
+ onExited(item.id);
739
+ });
740
+ }
741
+ }, [anim, item.id, item.open, onExited]);
742
+ const animatedStyle = React.useMemo(() => ({
743
+ opacity: anim,
744
+ transform: [
745
+ {
746
+ translateY: anim.interpolate({
747
+ inputRange: [0, 1],
748
+ outputRange: [direction * (0, zkit_tools_1.wp)(6), 0],
749
+ }),
750
+ },
751
+ ],
752
+ }), [anim, direction]);
753
+ if (item.render) {
754
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Animated.View, { renderToHardwareTextureAndroid: react_native_1.Platform.OS === 'android', shouldRasterizeIOS: react_native_1.Platform.OS === 'ios', pointerEvents: isInteractive ? 'auto' : 'none', accessible: !isInteractive, accessibilityRole: "alert", accessibilityLabel: item.accessibilityLabel, accessibilityLiveRegion: item.accessibilityLiveRegion, style: [styles.toast, animatedStyle, item.style], testID: item.testID, children: item.render({ ...actionContext, toast: item }) }));
755
+ }
756
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Animated.View, { renderToHardwareTextureAndroid: react_native_1.Platform.OS === 'android', shouldRasterizeIOS: react_native_1.Platform.OS === 'ios', pointerEvents: isInteractive ? 'auto' : 'none', accessible: !isInteractive, accessibilityRole: "alert", accessibilityLabel: item.accessibilityLabel, accessibilityLiveRegion: item.accessibilityLiveRegion, style: [
757
+ styles.toast,
758
+ styles.toastSurface,
759
+ { backgroundColor: toneConfig.bgColor },
760
+ animatedStyle,
761
+ item.style,
762
+ ], testID: item.testID, children: (0, jsx_runtime_1.jsx)(ToastCardBody, { item: item, actionContext: actionContext, toneConfig: toneConfig }) }));
763
+ }
764
+ function ToastCard(props) {
765
+ if (react_native_1.Platform.OS === 'ios')
766
+ return (0, jsx_runtime_1.jsx)(IOSToastCard, { ...props });
767
+ return (0, jsx_runtime_1.jsx)(DefaultToastCard, { ...props });
768
+ }
769
+ function renderToastIcon(item, toneConfig) {
770
+ if (item.icon === false)
771
+ return null;
772
+ const icon = typeof item.icon === 'function'
773
+ ? item.icon({ toast: item, tone: item.tone, color: toneConfig.accentColor, size: (0, zkit_tools_1.wp)(24) })
774
+ : item.icon;
775
+ if (icon)
776
+ return (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.iconSlot, children: icon });
777
+ return (0, jsx_runtime_1.jsx)(expo_image_1.Image, { source: toneConfig.iconSource, style: styles.iconImage, contentFit: "contain" });
778
+ }
779
+ function ToastActionButton({ action, context, toneConfig }) {
780
+ const handlePress = React.useCallback(() => {
781
+ var _a, _b;
782
+ const closeOnPress = (_a = action.closeOnPress) !== null && _a !== void 0 ? _a : true;
783
+ const closeIfNeeded = (result) => {
784
+ if (closeOnPress && result !== false)
785
+ context.dismiss('action');
786
+ };
787
+ try {
788
+ const result = (_b = action.onPress) === null || _b === void 0 ? void 0 : _b.call(action, context);
789
+ if (isPromiseLike(result)) {
790
+ result.then(closeIfNeeded).catch((error) => {
791
+ console.error('[toast] action failed', error);
792
+ if (closeOnPress)
793
+ context.dismiss('action');
794
+ });
795
+ return;
796
+ }
797
+ closeIfNeeded(result);
798
+ }
799
+ catch (error) {
800
+ console.error('[toast] action failed', error);
801
+ if (closeOnPress)
802
+ context.dismiss('action');
803
+ }
804
+ }, [action, context]);
805
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { accessibilityLabel: action.accessibilityLabel, accessibilityRole: "button", onPress: handlePress, style: ({ pressed }) => [
806
+ styles.actionButton,
807
+ {
808
+ borderColor: toneConfig.borderColor,
809
+ opacity: pressed ? 0.72 : 1,
810
+ },
811
+ ], testID: action.testID, children: (0, jsx_runtime_1.jsx)(Text_1.Text, { color: toneConfig.accentColor, numberOfLines: 1, size: "xs", weight: "semibold", children: action.label }) }));
812
+ }
813
+ const styles = react_native_1.StyleSheet.create({
814
+ viewport: {
815
+ position: 'absolute',
816
+ left: (0, zkit_tools_1.wp)(0),
817
+ right: (0, zkit_tools_1.wp)(0),
818
+ alignItems: 'center',
819
+ zIndex: TOAST_HOST_Z_INDEX,
820
+ elevation: react_native_1.Platform.OS === 'android' ? TOAST_HOST_Z_INDEX : 0,
821
+ },
822
+ toast: {
823
+ width: (0, zkit_tools_1.wp)(320),
824
+ maxWidth: '92%',
825
+ alignSelf: 'center',
826
+ shadowColor: '#000000',
827
+ shadowOffset: { width: (0, zkit_tools_1.wp)(0), height: (0, zkit_tools_1.wp)(2) },
828
+ shadowOpacity: 0.1,
829
+ shadowRadius: (0, zkit_tools_1.wp)(8),
830
+ elevation: (0, zkit_tools_1.wp)(3),
831
+ },
832
+ toastSurface: {
833
+ borderRadius: (0, zkit_tools_1.wp)(10),
834
+ },
835
+ toastIOS: {
836
+ borderRadius: (0, zkit_tools_1.wp)(10),
837
+ shadowOffset: { width: (0, zkit_tools_1.wp)(0), height: (0, zkit_tools_1.wp)(10) },
838
+ shadowOpacity: 0.16,
839
+ shadowRadius: (0, zkit_tools_1.wp)(20),
840
+ },
841
+ toastContent: {
842
+ borderRadius: (0, zkit_tools_1.wp)(10),
843
+ padding: (0, zkit_tools_1.wp)(12),
844
+ borderWidth: (0, zkit_tools_1.wp)(1),
845
+ },
846
+ toastContentIOS: {
847
+ borderRadius: (0, zkit_tools_1.wp)(10),
848
+ overflow: 'hidden',
849
+ },
850
+ toastSheen: {
851
+ ...react_native_1.StyleSheet.absoluteFillObject,
852
+ backgroundColor: '#FFFFFF',
853
+ borderRadius: (0, zkit_tools_1.wp)(10),
854
+ },
855
+ row: {
856
+ flexDirection: 'row',
857
+ alignItems: 'center',
858
+ columnGap: (0, zkit_tools_1.wp)(10),
859
+ },
860
+ iconImage: {
861
+ width: (0, zkit_tools_1.wp)(24),
862
+ height: (0, zkit_tools_1.wp)(24),
863
+ flexShrink: 0,
864
+ },
865
+ iconSlot: {
866
+ width: (0, zkit_tools_1.wp)(24),
867
+ height: (0, zkit_tools_1.wp)(24),
868
+ alignItems: 'center',
869
+ justifyContent: 'center',
870
+ flexShrink: 0,
871
+ },
872
+ content: {
873
+ flex: 1,
874
+ },
875
+ message: {
876
+ fontSize: (0, zkit_tools_1.wp)(13),
877
+ lineHeight: (0, zkit_tools_1.wp)(18),
878
+ },
879
+ actionButton: {
880
+ alignSelf: 'flex-start',
881
+ alignItems: 'center',
882
+ justifyContent: 'center',
883
+ minHeight: (0, zkit_tools_1.wp)(28),
884
+ marginTop: (0, zkit_tools_1.wp)(8),
885
+ paddingHorizontal: (0, zkit_tools_1.wp)(10),
886
+ borderRadius: (0, zkit_tools_1.wp)(14),
887
+ borderWidth: (0, zkit_tools_1.wp)(1),
888
+ backgroundColor: '#FFFFFF66',
889
+ },
890
+ closeButton: {
891
+ width: (0, zkit_tools_1.wp)(28),
892
+ height: (0, zkit_tools_1.wp)(28),
893
+ borderRadius: (0, zkit_tools_1.wp)(14),
894
+ alignItems: 'center',
895
+ justifyContent: 'center',
896
+ flexShrink: 0,
897
+ marginLeft: (0, zkit_tools_1.wp)(2),
898
+ },
899
+ });