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,827 @@
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.loading = void 0;
37
+ exports.LoadingProvider = LoadingProvider;
38
+ const jsx_runtime_1 = require("react/jsx-runtime");
39
+ /**
40
+ * @file LoadingService
41
+ *
42
+ * A global, service-driven loading HUD. The service owns scheduling and
43
+ * collision rules; the Provider only renders the current snapshot.
44
+ */
45
+ const React = __importStar(require("react"));
46
+ const vector_icons_1 = require("@expo/vector-icons");
47
+ const react_native_1 = require("react-native");
48
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
49
+ const react_native_worklets_1 = require("react-native-worklets");
50
+ const zkit_tools_1 = require("zkit-tools");
51
+ const useI18n_1 = require("../../i18n/useI18n");
52
+ const useTheme_1 = require("../../theme/useTheme");
53
+ const LoadingSpinner_1 = require("../../ui/LoadingSpinner");
54
+ const Text_1 = require("../../ui/Text");
55
+ // ============================================================================
56
+ // Defaults
57
+ // ============================================================================
58
+ const DEFAULT_LABELS = {
59
+ loading: 'Loading',
60
+ success: 'Done',
61
+ error: 'Failed',
62
+ };
63
+ const DEFAULTS = {
64
+ blocking: true,
65
+ loadingTimeout: 15000,
66
+ successDuration: 1200,
67
+ errorDuration: 1600,
68
+ accessibilityLiveRegion: 'polite',
69
+ labels: DEFAULT_LABELS,
70
+ colors: {
71
+ card: '#4d4d4d',
72
+ },
73
+ };
74
+ const EMPTY_SNAPSHOT = { item: null };
75
+ const DEFAULT_ID_PREFIX = 'loading';
76
+ const HOST_Z_INDEX = 9999;
77
+ const ENTER_DURATION = 170;
78
+ const EXIT_DURATION = 150;
79
+ const CONTENT_SWAP_DURATION = 130;
80
+ const HUD_MIN_WIDTH = (0, zkit_tools_1.wp)(116);
81
+ const HUD_MAX_WIDTH = (0, zkit_tools_1.wp)(260);
82
+ const HUD_MIN_HEIGHT = (0, zkit_tools_1.wp)(116);
83
+ const HUD_RADIUS = (0, zkit_tools_1.wp)(10);
84
+ const HUD_PADDING_HORIZONTAL = (0, zkit_tools_1.wp)(16);
85
+ const HUD_PADDING_VERTICAL = (0, zkit_tools_1.wp)(16);
86
+ const ICON_FRAME_SIZE = (0, zkit_tools_1.wp)(42);
87
+ const LOADING_ICON_SIZE = (0, zkit_tools_1.wp)(34);
88
+ const RESULT_ICON_SIZE = (0, zkit_tools_1.wp)(36);
89
+ const TITLE_MARGIN_TOP = (0, zkit_tools_1.wp)(8);
90
+ const DESCRIPTION_MARGIN_TOP = (0, zkit_tools_1.wp)(4);
91
+ const TITLE_MAX_WIDTH = (0, zkit_tools_1.wp)(214);
92
+ const IOS_SHADOW_OFFSET_Y = (0, zkit_tools_1.wp)(9);
93
+ const IOS_SHADOW_RADIUS = (0, zkit_tools_1.wp)(22);
94
+ const CONTENT_ENTER_OFFSET = (0, zkit_tools_1.wp)(3);
95
+ const HOST_BACKDROP = 'transparent';
96
+ const IS_IOS = react_native_1.Platform.OS === 'ios';
97
+ const IS_ANDROID = react_native_1.Platform.OS === 'android';
98
+ const IS_WEB = react_native_1.Platform.OS === 'web';
99
+ const ENTER_EASING = react_native_reanimated_1.Easing.bezier(0.22, 1, 0.36, 1);
100
+ const EXIT_EASING = react_native_reanimated_1.Easing.bezier(0.4, 0, 1, 1);
101
+ const CONTENT_EASING = react_native_reanimated_1.Easing.out(react_native_reanimated_1.Easing.cubic);
102
+ const ENTER_SPRING = {
103
+ damping: 18,
104
+ stiffness: 260,
105
+ mass: 0.72,
106
+ };
107
+ const webShadowStyle = IS_WEB
108
+ ? {
109
+ boxShadow: '0 18px 42px rgba(15, 23, 42, 0.24)',
110
+ }
111
+ : undefined;
112
+ // ============================================================================
113
+ // Normalizers
114
+ // ============================================================================
115
+ function isFiniteNumber(value) {
116
+ return typeof value === 'number' && Number.isFinite(value);
117
+ }
118
+ function normalizeMs(value, fallback) {
119
+ if (!isFiniteNumber(value))
120
+ return fallback;
121
+ return Math.max(0, value);
122
+ }
123
+ function normalizeLiveRegion(value, fallback) {
124
+ if (value === 'none' || value === 'polite' || value === 'assertive')
125
+ return value;
126
+ return fallback;
127
+ }
128
+ function normalizeStatus(value, fallback) {
129
+ if (value === 'loading' || value === 'success' || value === 'error')
130
+ return value;
131
+ return fallback;
132
+ }
133
+ function normalizeId(value) {
134
+ if (typeof value !== 'string')
135
+ return undefined;
136
+ const id = value.trim();
137
+ return id || undefined;
138
+ }
139
+ function normalizeNode(value) {
140
+ if (value == null || value === false || value === true)
141
+ return undefined;
142
+ if (value instanceof Error)
143
+ return value.message || String(value);
144
+ return value;
145
+ }
146
+ function isOptionsInput(value) {
147
+ if (!value || typeof value !== 'object' || Array.isArray(value) || React.isValidElement(value))
148
+ return false;
149
+ if (value instanceof Error)
150
+ return false;
151
+ return ('id' in value ||
152
+ 'status' in value ||
153
+ 'title' in value ||
154
+ 'description' in value ||
155
+ 'blocking' in value ||
156
+ 'duration' in value ||
157
+ 'timeout' in value ||
158
+ 'icon' in value ||
159
+ 'render' in value ||
160
+ 'colors' in value ||
161
+ 'accessibilityLabel' in value ||
162
+ 'accessibilityLiveRegion' in value ||
163
+ 'testID' in value ||
164
+ 'style' in value ||
165
+ 'onDismiss' in value ||
166
+ 'onOpenChange' in value);
167
+ }
168
+ function getTextFromNode(value) {
169
+ if (value == null || typeof value === 'boolean')
170
+ return '';
171
+ if (typeof value === 'string')
172
+ return value.trim();
173
+ if (typeof value === 'number')
174
+ return String(value);
175
+ if (Array.isArray(value))
176
+ return value.map(getTextFromNode).filter(Boolean).join(' ').trim();
177
+ if (React.isValidElement(value))
178
+ return getTextFromNode(value.props.children);
179
+ return '';
180
+ }
181
+ function createAccessibilityLabel(status, title, description, labels) {
182
+ const titleText = getTextFromNode(title);
183
+ const descriptionText = getTextFromNode(description);
184
+ const statusText = labels[status];
185
+ const text = [titleText, descriptionText].filter(Boolean).join(',');
186
+ if (!text || text === statusText)
187
+ return statusText;
188
+ return `${statusText},${text}`;
189
+ }
190
+ function getHandleId(idOrHandle) {
191
+ if (!idOrHandle)
192
+ return undefined;
193
+ if (typeof idOrHandle === 'string')
194
+ return normalizeId(idOrHandle);
195
+ return normalizeId(idOrHandle.id);
196
+ }
197
+ function getStatusDefaultDuration(status, defaults) {
198
+ if (status === 'success')
199
+ return defaults.successDuration;
200
+ if (status === 'error')
201
+ return defaults.errorDuration;
202
+ return 0;
203
+ }
204
+ function getStatusDefaultBlocking(status, defaults) {
205
+ return status === 'loading' ? defaults.blocking : false;
206
+ }
207
+ function mergeDefaults(base, patch) {
208
+ var _a, _b, _c;
209
+ if (!patch)
210
+ return base;
211
+ return {
212
+ blocking: (_a = patch.blocking) !== null && _a !== void 0 ? _a : base.blocking,
213
+ loadingTimeout: normalizeMs(patch.loadingTimeout, base.loadingTimeout),
214
+ successDuration: normalizeMs(patch.successDuration, base.successDuration),
215
+ errorDuration: normalizeMs(patch.errorDuration, base.errorDuration),
216
+ accessibilityLiveRegion: normalizeLiveRegion(patch.accessibilityLiveRegion, base.accessibilityLiveRegion),
217
+ labels: {
218
+ ...base.labels,
219
+ ...((_b = patch.labels) !== null && _b !== void 0 ? _b : {}),
220
+ },
221
+ colors: patch.colors ? { ...((_c = base.colors) !== null && _c !== void 0 ? _c : {}), ...patch.colors } : base.colors,
222
+ };
223
+ }
224
+ function warnMissingProvider() {
225
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
226
+ console.warn('[loading] LoadingProvider is not mounted.');
227
+ }
228
+ }
229
+ function createBusinessError(message, response, cause) {
230
+ const error = new Error(message || DEFAULT_LABELS.error);
231
+ error.response = response;
232
+ if (cause !== undefined)
233
+ error.cause = cause;
234
+ return error;
235
+ }
236
+ function coerceInputToOptions(input) {
237
+ if (isOptionsInput(input))
238
+ return input;
239
+ return { title: normalizeNode(input) };
240
+ }
241
+ function attachIdToInput(input, id) {
242
+ if (isOptionsInput(input))
243
+ return { ...input, id };
244
+ if (input === undefined)
245
+ return { id };
246
+ return { id, title: normalizeNode(input) };
247
+ }
248
+ function resolvePromiseResult(input, result) {
249
+ if (typeof input !== 'function')
250
+ return input;
251
+ try {
252
+ return input(result);
253
+ }
254
+ catch (error) {
255
+ console.error('[loading] success resolver failed', error);
256
+ return undefined;
257
+ }
258
+ }
259
+ function resolvePromiseError(input, error, result) {
260
+ if (typeof input !== 'function')
261
+ return input;
262
+ try {
263
+ return input(error, result);
264
+ }
265
+ catch (resolverError) {
266
+ console.error('[loading] error resolver failed', resolverError);
267
+ return undefined;
268
+ }
269
+ }
270
+ // ============================================================================
271
+ // Store
272
+ // ============================================================================
273
+ class LoadingStore {
274
+ constructor() {
275
+ this.defaults = DEFAULTS;
276
+ this.snapshot = EMPTY_SNAPSHOT;
277
+ this.listeners = new Set();
278
+ this.autoHideTimer = null;
279
+ this.timeoutTimer = null;
280
+ this.idSeed = 0;
281
+ this.hostCount = 0;
282
+ this.getSnapshot = () => this.snapshot;
283
+ this.subscribe = (listener) => {
284
+ this.listeners.add(listener);
285
+ this.hostCount += 1;
286
+ this.scheduleCurrent();
287
+ return () => {
288
+ this.listeners.delete(listener);
289
+ this.hostCount = Math.max(0, this.hostCount - 1);
290
+ if (this.hostCount === 0)
291
+ this.clearAll('provider-unmount');
292
+ };
293
+ };
294
+ }
295
+ configure(defaults) {
296
+ this.defaults = mergeDefaults(DEFAULTS, defaults);
297
+ }
298
+ getDefaults() {
299
+ return {
300
+ ...this.defaults,
301
+ labels: { ...this.defaults.labels },
302
+ colors: this.defaults.colors ? { ...this.defaults.colors } : undefined,
303
+ };
304
+ }
305
+ show(options) {
306
+ const item = this.resolveItem(options, 'loading');
307
+ return this.openItem(item);
308
+ }
309
+ success(options) {
310
+ const item = this.resolveItem(options, 'success');
311
+ return this.openItem(item);
312
+ }
313
+ error(options) {
314
+ const item = this.resolveItem(options, 'error');
315
+ return this.openItem(item);
316
+ }
317
+ async promise(promise, options = {}) {
318
+ const handle = options.loading === false ? null : this.show(options.loading);
319
+ let result;
320
+ try {
321
+ result = await promise;
322
+ }
323
+ catch (error) {
324
+ this.completePromiseFailure(handle, resolvePromiseError(options.error, error));
325
+ throw error;
326
+ }
327
+ let ok = true;
328
+ let successCheckError;
329
+ if (typeof options.isSuccess === 'function') {
330
+ try {
331
+ ok = Boolean(options.isSuccess(result));
332
+ }
333
+ catch (error) {
334
+ ok = false;
335
+ successCheckError = error;
336
+ }
337
+ }
338
+ if (ok) {
339
+ this.completePromiseSuccess(handle, resolvePromiseResult(options.success, result));
340
+ return result;
341
+ }
342
+ const errorInput = resolvePromiseError(options.error, successCheckError, result);
343
+ this.completePromiseFailure(handle, errorInput);
344
+ const errorOptions = coerceInputToOptions(errorInput === false ? undefined : errorInput);
345
+ const message = getTextFromNode(errorOptions.title) || this.defaults.labels.error;
346
+ throw createBusinessError(message, result, successCheckError);
347
+ }
348
+ update(idOrHandle, patch) {
349
+ const id = getHandleId(idOrHandle);
350
+ if (!id)
351
+ return false;
352
+ const current = this.snapshot.item;
353
+ if (!current || current.id !== id || !current.open)
354
+ return false;
355
+ const nextItem = this.applyPatch(current, patch);
356
+ this.setItem(nextItem);
357
+ this.callOpenChange(nextItem, true, 'update');
358
+ this.scheduleCurrent();
359
+ return true;
360
+ }
361
+ hide(idOrHandle, reason = 'api') {
362
+ var _a, _b;
363
+ const id = (_a = getHandleId(idOrHandle)) !== null && _a !== void 0 ? _a : (_b = this.snapshot.item) === null || _b === void 0 ? void 0 : _b.id;
364
+ if (!id)
365
+ return;
366
+ this.hideById(id, reason);
367
+ }
368
+ hideAll(reason = 'api') {
369
+ var _a;
370
+ const id = (_a = this.snapshot.item) === null || _a === void 0 ? void 0 : _a.id;
371
+ if (!id)
372
+ return;
373
+ this.hideById(id, reason);
374
+ }
375
+ isActive(idOrHandle) {
376
+ var _a;
377
+ const id = getHandleId(idOrHandle);
378
+ return Boolean(id && ((_a = this.snapshot.item) === null || _a === void 0 ? void 0 : _a.id) === id && this.snapshot.item.open);
379
+ }
380
+ completeExit(id) {
381
+ const current = this.snapshot.item;
382
+ if (!current || current.id !== id || current.open)
383
+ return;
384
+ this.setItem(null);
385
+ }
386
+ openItem(item) {
387
+ if (this.hostCount <= 0)
388
+ warnMissingProvider();
389
+ const current = this.snapshot.item;
390
+ if ((current === null || current === void 0 ? void 0 : current.id) === item.id) {
391
+ const nextItem = {
392
+ ...current,
393
+ ...item,
394
+ open: true,
395
+ createdAt: current.createdAt,
396
+ updatedAt: Date.now(),
397
+ dismissedReason: undefined,
398
+ };
399
+ this.setItem(nextItem);
400
+ this.callOpenChange(nextItem, true, current.open ? 'update' : 'show');
401
+ this.scheduleCurrent();
402
+ return this.createHandle(nextItem.id);
403
+ }
404
+ if (current) {
405
+ this.clearTimers();
406
+ if (current.open) {
407
+ this.callDismiss(current, 'replace');
408
+ this.callOpenChange(current, false, 'replace');
409
+ }
410
+ }
411
+ this.setItem(item);
412
+ this.callOpenChange(item, true, 'show');
413
+ this.scheduleCurrent();
414
+ return this.createHandle(item.id);
415
+ }
416
+ hideById(id, reason) {
417
+ const current = this.snapshot.item;
418
+ if (!current || current.id !== id || !current.open)
419
+ return;
420
+ this.clearTimers();
421
+ const nextItem = {
422
+ ...current,
423
+ open: false,
424
+ updatedAt: Date.now(),
425
+ dismissedReason: reason,
426
+ };
427
+ this.callDismiss(nextItem, reason);
428
+ this.callOpenChange(nextItem, false, reason);
429
+ this.setItem(nextItem);
430
+ }
431
+ clearAll(reason) {
432
+ this.clearTimers();
433
+ const current = this.snapshot.item;
434
+ if (current)
435
+ this.callDismiss(current, reason);
436
+ this.setItem(null);
437
+ }
438
+ resolveItem(input, defaultStatus) {
439
+ var _a, _b, _c, _d, _e;
440
+ const raw = coerceInputToOptions(input);
441
+ const status = normalizeStatus(raw.status, defaultStatus);
442
+ const now = Date.now();
443
+ const hasCustomBody = typeof raw.render === 'function';
444
+ const title = (_a = normalizeNode(raw.title)) !== null && _a !== void 0 ? _a : (hasCustomBody ? undefined : this.defaults.labels[status]);
445
+ const description = normalizeNode(raw.description);
446
+ const duration = normalizeMs(raw.duration, getStatusDefaultDuration(status, this.defaults));
447
+ const timeout = status === 'loading' ? normalizeMs(raw.timeout, this.defaults.loadingTimeout) : 0;
448
+ return {
449
+ id: (_b = normalizeId(raw.id)) !== null && _b !== void 0 ? _b : this.createId(),
450
+ status,
451
+ title,
452
+ description,
453
+ blocking: (_c = raw.blocking) !== null && _c !== void 0 ? _c : getStatusDefaultBlocking(status, this.defaults),
454
+ duration,
455
+ timeout,
456
+ icon: raw.icon,
457
+ render: raw.render,
458
+ colors: raw.colors ? { ...((_d = this.defaults.colors) !== null && _d !== void 0 ? _d : {}), ...raw.colors } : this.defaults.colors,
459
+ accessibilityLabel: (_e = raw.accessibilityLabel) !== null && _e !== void 0 ? _e : createAccessibilityLabel(status, title, description, this.defaults.labels),
460
+ accessibilityLiveRegion: normalizeLiveRegion(raw.accessibilityLiveRegion, this.defaults.accessibilityLiveRegion),
461
+ testID: raw.testID,
462
+ style: raw.style,
463
+ open: true,
464
+ createdAt: now,
465
+ updatedAt: now,
466
+ onDismiss: raw.onDismiss,
467
+ onOpenChange: raw.onOpenChange,
468
+ };
469
+ }
470
+ applyPatch(item, patch) {
471
+ var _a, _b, _c, _d, _e, _f;
472
+ const status = normalizeStatus(patch.status, item.status);
473
+ const title = 'title' in patch ? normalizeNode(patch.title) : item.title;
474
+ const description = 'description' in patch ? normalizeNode(patch.description) : item.description;
475
+ const duration = 'duration' in patch ? normalizeMs(patch.duration, getStatusDefaultDuration(status, this.defaults)) : item.duration;
476
+ const timeout = status === 'loading'
477
+ ? 'timeout' in patch
478
+ ? normalizeMs(patch.timeout, this.defaults.loadingTimeout)
479
+ : item.timeout
480
+ : 0;
481
+ return {
482
+ ...item,
483
+ status,
484
+ title,
485
+ description,
486
+ blocking: (_a = patch.blocking) !== null && _a !== void 0 ? _a : item.blocking,
487
+ duration,
488
+ timeout,
489
+ icon: 'icon' in patch ? patch.icon : item.icon,
490
+ render: 'render' in patch ? patch.render : item.render,
491
+ colors: patch.colors ? { ...((_b = item.colors) !== null && _b !== void 0 ? _b : {}), ...patch.colors } : item.colors,
492
+ accessibilityLabel: (_c = patch.accessibilityLabel) !== null && _c !== void 0 ? _c : createAccessibilityLabel(status, title, description, this.defaults.labels),
493
+ accessibilityLiveRegion: normalizeLiveRegion(patch.accessibilityLiveRegion, item.accessibilityLiveRegion),
494
+ testID: (_d = patch.testID) !== null && _d !== void 0 ? _d : item.testID,
495
+ style: 'style' in patch ? patch.style : item.style,
496
+ updatedAt: Date.now(),
497
+ onDismiss: (_e = patch.onDismiss) !== null && _e !== void 0 ? _e : item.onDismiss,
498
+ onOpenChange: (_f = patch.onOpenChange) !== null && _f !== void 0 ? _f : item.onOpenChange,
499
+ };
500
+ }
501
+ scheduleCurrent() {
502
+ this.clearTimers();
503
+ const current = this.snapshot.item;
504
+ if (!current || !current.open || this.hostCount <= 0)
505
+ return;
506
+ if (current.duration > 0) {
507
+ this.autoHideTimer = setTimeout(() => {
508
+ this.hideById(current.id, 'timeout');
509
+ }, current.duration);
510
+ }
511
+ if (current.status === 'loading' && current.timeout > 0) {
512
+ this.timeoutTimer = setTimeout(() => {
513
+ this.hideById(current.id, 'timeout');
514
+ }, current.timeout);
515
+ }
516
+ }
517
+ clearTimers() {
518
+ if (this.autoHideTimer) {
519
+ clearTimeout(this.autoHideTimer);
520
+ this.autoHideTimer = null;
521
+ }
522
+ if (this.timeoutTimer) {
523
+ clearTimeout(this.timeoutTimer);
524
+ this.timeoutTimer = null;
525
+ }
526
+ }
527
+ setItem(item) {
528
+ this.snapshot = item ? { item } : EMPTY_SNAPSHOT;
529
+ this.listeners.forEach((listener) => listener());
530
+ }
531
+ completePromiseSuccess(handle, input) {
532
+ if (input === false) {
533
+ handle === null || handle === void 0 ? void 0 : handle.hide();
534
+ return;
535
+ }
536
+ if (handle && !this.isActive(handle))
537
+ return;
538
+ this.success(handle ? attachIdToInput(input, handle.id) : input);
539
+ }
540
+ completePromiseFailure(handle, input) {
541
+ if (input === false) {
542
+ handle === null || handle === void 0 ? void 0 : handle.hide();
543
+ return;
544
+ }
545
+ if (handle && !this.isActive(handle))
546
+ return;
547
+ this.error(handle ? attachIdToInput(input, handle.id) : input);
548
+ }
549
+ createId() {
550
+ this.idSeed += 1;
551
+ return `${DEFAULT_ID_PREFIX}_${Date.now()}_${this.idSeed}`;
552
+ }
553
+ createHandle(id) {
554
+ return {
555
+ id,
556
+ hide: (reason = 'api') => this.hide(id, reason),
557
+ update: (patch) => {
558
+ this.update(id, patch);
559
+ },
560
+ success: (options) => {
561
+ this.success(attachIdToInput(options, id));
562
+ },
563
+ error: (options) => {
564
+ this.error(attachIdToInput(options, id));
565
+ },
566
+ isActive: () => this.isActive(id),
567
+ };
568
+ }
569
+ callDismiss(item, reason) {
570
+ var _a;
571
+ if (item.dismissedReason && item.dismissedReason !== reason)
572
+ return;
573
+ try {
574
+ (_a = item.onDismiss) === null || _a === void 0 ? void 0 : _a.call(item, reason, item.id);
575
+ }
576
+ catch (error) {
577
+ console.error('[loading] onDismiss failed', error);
578
+ }
579
+ }
580
+ callOpenChange(item, open, reason) {
581
+ var _a;
582
+ try {
583
+ (_a = item.onOpenChange) === null || _a === void 0 ? void 0 : _a.call(item, open, { id: item.id, open, reason, status: item.status });
584
+ }
585
+ catch (error) {
586
+ console.error('[loading] onOpenChange failed', error);
587
+ }
588
+ }
589
+ }
590
+ const loadingStore = new LoadingStore();
591
+ exports.loading = loadingStore;
592
+ // ============================================================================
593
+ // Provider
594
+ // ============================================================================
595
+ function useLoadingSnapshot() {
596
+ return React.useSyncExternalStore(loadingStore.subscribe, loadingStore.getSnapshot, loadingStore.getSnapshot);
597
+ }
598
+ function LoadingProvider({ children, defaults }) {
599
+ const snapshot = useLoadingSnapshot();
600
+ const { t } = (0, useI18n_1.useI18n)();
601
+ const providerDefaults = React.useMemo(() => {
602
+ var _a;
603
+ return ({
604
+ ...defaults,
605
+ labels: {
606
+ loading: t('loading.loading'),
607
+ success: t('loading.success'),
608
+ error: t('loading.error'),
609
+ ...((_a = defaults === null || defaults === void 0 ? void 0 : defaults.labels) !== null && _a !== void 0 ? _a : {}),
610
+ },
611
+ });
612
+ }, [defaults, t]);
613
+ React.useEffect(() => {
614
+ loadingStore.configure(providerDefaults);
615
+ }, [providerDefaults]);
616
+ const handleExited = React.useCallback((id) => {
617
+ loadingStore.completeExit(id);
618
+ }, []);
619
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [children, (0, jsx_runtime_1.jsx)(LoadingHost, { item: snapshot.item, onExited: handleExited })] }));
620
+ }
621
+ function LoadingHost({ item, onExited }) {
622
+ if (!item)
623
+ return null;
624
+ const pointerEvents = item.open ? (item.blocking ? 'auto' : 'none') : 'none';
625
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { pointerEvents: pointerEvents, style: styles.host, accessibilityElementsHidden: !item.open, importantForAccessibility: item.open ? 'yes' : 'no-hide-descendants', collapsable: false, children: (0, jsx_runtime_1.jsx)(LoadingCard, { item: item, onExited: onExited }) }));
626
+ }
627
+ function resolveColors(item, themeColors) {
628
+ var _a, _b, _c, _d, _e, _f, _g, _h;
629
+ return {
630
+ backdrop: (_b = (_a = item.colors) === null || _a === void 0 ? void 0 : _a.backdrop) !== null && _b !== void 0 ? _b : (item.blocking ? HOST_BACKDROP : 'transparent'),
631
+ card: (_d = (_c = item.colors) === null || _c === void 0 ? void 0 : _c.card) !== null && _d !== void 0 ? _d : themeColors.onSurface,
632
+ foreground: (_f = (_e = item.colors) === null || _e === void 0 ? void 0 : _e.foreground) !== null && _f !== void 0 ? _f : themeColors.surface,
633
+ shadow: (_h = (_g = item.colors) === null || _g === void 0 ? void 0 : _g.shadow) !== null && _h !== void 0 ? _h : '#000000',
634
+ };
635
+ }
636
+ function LoadingCard({ item, onExited }) {
637
+ const theme = (0, useTheme_1.useTheme)();
638
+ const colors = resolveColors(item, theme.colors);
639
+ const opacity = (0, react_native_reanimated_1.useSharedValue)(item.open ? 1 : 0);
640
+ const scale = (0, react_native_reanimated_1.useSharedValue)(item.open ? 1 : 0.965);
641
+ const translateY = (0, react_native_reanimated_1.useSharedValue)(item.open ? 0 : CONTENT_ENTER_OFFSET);
642
+ const contentProgress = (0, react_native_reanimated_1.useSharedValue)(item.open ? 1 : 0);
643
+ const previousIdRef = React.useRef(item.id);
644
+ React.useEffect(() => {
645
+ return () => {
646
+ (0, react_native_reanimated_1.cancelAnimation)(opacity);
647
+ (0, react_native_reanimated_1.cancelAnimation)(scale);
648
+ (0, react_native_reanimated_1.cancelAnimation)(translateY);
649
+ (0, react_native_reanimated_1.cancelAnimation)(contentProgress);
650
+ };
651
+ }, [contentProgress, opacity, scale, translateY]);
652
+ React.useEffect(() => {
653
+ const isNewItem = previousIdRef.current !== item.id;
654
+ previousIdRef.current = item.id;
655
+ (0, react_native_reanimated_1.cancelAnimation)(opacity);
656
+ (0, react_native_reanimated_1.cancelAnimation)(scale);
657
+ (0, react_native_reanimated_1.cancelAnimation)(translateY);
658
+ (0, react_native_reanimated_1.cancelAnimation)(contentProgress);
659
+ if (item.open) {
660
+ if (isNewItem || opacity.value <= 0.02) {
661
+ opacity.value = 0;
662
+ scale.value = 0.965;
663
+ translateY.value = CONTENT_ENTER_OFFSET;
664
+ contentProgress.value = 0;
665
+ }
666
+ opacity.value = (0, react_native_reanimated_1.withTiming)(1, {
667
+ duration: ENTER_DURATION,
668
+ easing: ENTER_EASING,
669
+ reduceMotion: react_native_reanimated_1.ReduceMotion.System,
670
+ });
671
+ scale.value = (0, react_native_reanimated_1.withSpring)(1, ENTER_SPRING);
672
+ translateY.value = (0, react_native_reanimated_1.withSpring)(0, ENTER_SPRING);
673
+ contentProgress.value = (0, react_native_reanimated_1.withTiming)(1, {
674
+ duration: CONTENT_SWAP_DURATION,
675
+ easing: CONTENT_EASING,
676
+ reduceMotion: react_native_reanimated_1.ReduceMotion.System,
677
+ });
678
+ return;
679
+ }
680
+ opacity.value = (0, react_native_reanimated_1.withTiming)(0, {
681
+ duration: EXIT_DURATION,
682
+ easing: EXIT_EASING,
683
+ reduceMotion: react_native_reanimated_1.ReduceMotion.System,
684
+ }, (finished) => {
685
+ if (finished)
686
+ (0, react_native_worklets_1.scheduleOnRN)(onExited, item.id);
687
+ });
688
+ scale.value = (0, react_native_reanimated_1.withTiming)(0.965, {
689
+ duration: EXIT_DURATION,
690
+ easing: EXIT_EASING,
691
+ reduceMotion: react_native_reanimated_1.ReduceMotion.System,
692
+ });
693
+ translateY.value = (0, react_native_reanimated_1.withTiming)(CONTENT_ENTER_OFFSET, {
694
+ duration: EXIT_DURATION,
695
+ easing: EXIT_EASING,
696
+ reduceMotion: react_native_reanimated_1.ReduceMotion.System,
697
+ });
698
+ contentProgress.value = (0, react_native_reanimated_1.withTiming)(0, {
699
+ duration: Math.min(EXIT_DURATION, CONTENT_SWAP_DURATION),
700
+ easing: EXIT_EASING,
701
+ reduceMotion: react_native_reanimated_1.ReduceMotion.System,
702
+ });
703
+ }, [contentProgress, item.id, item.open, onExited, opacity, scale, translateY]);
704
+ const backdropStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
705
+ opacity: opacity.value,
706
+ }));
707
+ const frameStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
708
+ const progress = opacity.value;
709
+ return {
710
+ opacity: progress,
711
+ transform: [{ translateY: translateY.value }, { scale: scale.value }],
712
+ ...(IS_IOS
713
+ ? {
714
+ shadowOpacity: (0, react_native_reanimated_1.interpolate)(progress, [0, 1], [0, 0.22]),
715
+ shadowRadius: (0, react_native_reanimated_1.interpolate)(progress, [0, 1], [0, IOS_SHADOW_RADIUS]),
716
+ }
717
+ : null),
718
+ };
719
+ });
720
+ const contentStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
721
+ opacity: (0, react_native_reanimated_1.interpolate)(contentProgress.value, [0, 1], [0.72, 1]),
722
+ transform: [{ translateY: (0, react_native_reanimated_1.interpolate)(contentProgress.value, [0, 1], [CONTENT_ENTER_OFFSET, 0]) }],
723
+ }));
724
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: "none", style: [styles.backdrop, { backgroundColor: colors.backdrop }, backdropStyle] }), (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: item.open && item.blocking ? 'auto' : 'none', renderToHardwareTextureAndroid: IS_ANDROID && item.open, style: [
725
+ styles.frame,
726
+ webShadowStyle,
727
+ IS_IOS ? { shadowColor: colors.shadow } : undefined,
728
+ frameStyle,
729
+ ], collapsable: false, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: [styles.card, item.style, { backgroundColor: colors.card }], testID: item.testID, children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { accessible: item.open, accessibilityLabel: item.accessibilityLabel, accessibilityLiveRegion: item.accessibilityLiveRegion, accessibilityViewIsModal: item.blocking, style: [styles.content, contentStyle], children: renderLoadingContent(item, colors) }) }) })] }));
730
+ }
731
+ function renderLoadingContent(item, colors) {
732
+ var _a;
733
+ const defaultIcon = renderDefaultIcon(item, colors);
734
+ const context = {
735
+ item,
736
+ id: item.id,
737
+ status: item.status,
738
+ title: item.title,
739
+ description: item.description,
740
+ open: item.open,
741
+ hide: (reason = 'api') => loadingStore.hide(item.id, reason),
742
+ update: (patch) => {
743
+ loadingStore.update(item.id, patch);
744
+ },
745
+ defaultIcon,
746
+ };
747
+ if (item.render) {
748
+ try {
749
+ return (_a = item.render(context)) !== null && _a !== void 0 ? _a : null;
750
+ }
751
+ catch (error) {
752
+ console.error('[loading] render failed', error);
753
+ }
754
+ }
755
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [defaultIcon, item.title ? ((0, jsx_runtime_1.jsx)(Text_1.Text, { align: "center", numberOfLines: 2, size: "sm", weight: "semibold", style: [styles.title, { color: colors.foreground }], children: item.title })) : null, item.description ? ((0, jsx_runtime_1.jsx)(Text_1.Text, { align: "center", numberOfLines: 3, size: "xs", weight: "regular", style: [styles.description, { color: colors.foreground }], children: item.description })) : null] }));
756
+ }
757
+ function renderDefaultIcon(item, colors) {
758
+ const color = colors.foreground;
759
+ const size = item.status === 'loading' ? LOADING_ICON_SIZE : RESULT_ICON_SIZE;
760
+ const iconContext = {
761
+ item,
762
+ status: item.status,
763
+ color,
764
+ size,
765
+ };
766
+ if (item.icon === false)
767
+ return null;
768
+ if (typeof item.icon === 'function')
769
+ return item.icon(iconContext);
770
+ if (item.icon)
771
+ return item.icon;
772
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.iconFrame, children: item.status === 'loading' ? ((0, jsx_runtime_1.jsx)(LoadingSpinner_1.LoadingSpinner, { size: LOADING_ICON_SIZE, color: colors.foreground, speed: 1.2, animating: item.open })) : ((0, jsx_runtime_1.jsx)(vector_icons_1.Feather, { name: item.status === 'success' ? 'check' : 'x', size: RESULT_ICON_SIZE, color: color })) }));
773
+ }
774
+ // ============================================================================
775
+ // Styles
776
+ // ============================================================================
777
+ const styles = react_native_1.StyleSheet.create({
778
+ host: {
779
+ ...react_native_1.StyleSheet.absoluteFillObject,
780
+ alignItems: 'center',
781
+ justifyContent: 'center',
782
+ zIndex: HOST_Z_INDEX,
783
+ },
784
+ backdrop: {
785
+ ...react_native_1.StyleSheet.absoluteFillObject,
786
+ },
787
+ frame: {
788
+ alignSelf: 'center',
789
+ borderRadius: HUD_RADIUS,
790
+ maxWidth: HUD_MAX_WIDTH,
791
+ ...react_native_1.Platform.select({
792
+ ios: {
793
+ shadowOffset: { width: (0, zkit_tools_1.wp)(0), height: IOS_SHADOW_OFFSET_Y },
794
+ },
795
+ }),
796
+ },
797
+ card: {
798
+ minWidth: HUD_MIN_WIDTH,
799
+ maxWidth: HUD_MAX_WIDTH,
800
+ minHeight: HUD_MIN_HEIGHT,
801
+ alignItems: 'center',
802
+ justifyContent: 'center',
803
+ borderRadius: HUD_RADIUS,
804
+ overflow: 'hidden',
805
+ paddingHorizontal: HUD_PADDING_HORIZONTAL,
806
+ paddingVertical: HUD_PADDING_VERTICAL,
807
+ },
808
+ content: {
809
+ alignItems: 'center',
810
+ justifyContent: 'center',
811
+ },
812
+ iconFrame: {
813
+ width: ICON_FRAME_SIZE,
814
+ height: ICON_FRAME_SIZE,
815
+ alignItems: 'center',
816
+ justifyContent: 'center',
817
+ },
818
+ title: {
819
+ maxWidth: TITLE_MAX_WIDTH,
820
+ marginTop: TITLE_MARGIN_TOP,
821
+ },
822
+ description: {
823
+ maxWidth: TITLE_MAX_WIDTH,
824
+ marginTop: DESCRIPTION_MARGIN_TOP,
825
+ opacity: 0.82,
826
+ },
827
+ });