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,832 @@
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.Sheet = exports.SheetHeader = exports.SheetFooter = exports.SheetContent = void 0;
37
+ const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const React = __importStar(require("react"));
39
+ const react_native_1 = require("react-native");
40
+ const react_native_gesture_handler_1 = require("react-native-gesture-handler");
41
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
42
+ const react_native_safe_area_context_1 = require("react-native-safe-area-context");
43
+ const react_native_worklets_1 = require("react-native-worklets");
44
+ const zkit_tools_1 = require("zkit-tools");
45
+ const useTheme_1 = require("../../theme/useTheme");
46
+ const nativeBottom_1 = require("./nativeBottom");
47
+ const slots_1 = require("./slots");
48
+ var slots_2 = require("./slots");
49
+ Object.defineProperty(exports, "SheetContent", { enumerable: true, get: function () { return slots_2.SheetContent; } });
50
+ Object.defineProperty(exports, "SheetFooter", { enumerable: true, get: function () { return slots_2.SheetFooter; } });
51
+ Object.defineProperty(exports, "SheetHeader", { enumerable: true, get: function () { return slots_2.SheetHeader; } });
52
+ const DEFAULT_BACKDROP_OPACITY = 0.42;
53
+ const DEFAULT_DISMISSIBLE = true;
54
+ const DEFAULT_DRAGGABLE = true;
55
+ const DEFAULT_HANDLE_VISIBLE = true;
56
+ const DEFAULT_OPEN_DURATION = 260;
57
+ const DEFAULT_CLOSE_DURATION = 210;
58
+ const DEFAULT_EASING = react_native_reanimated_1.Easing.out(react_native_reanimated_1.Easing.cubic);
59
+ const DEFAULT_SIDE_SIZE_RATIO = 0.86;
60
+ const DEFAULT_TOP_MAX_RATIO = 0.82;
61
+ const DEFAULT_DRAG_VELOCITY = 900;
62
+ const BOTTOM_HANDLE_RESERVE = (0, zkit_tools_1.wp)(36);
63
+ const TOP_HANDLE_RESERVE = (0, zkit_tools_1.wp)(20);
64
+ const SIDE_HANDLE_RESERVE = (0, zkit_tools_1.wp)(24);
65
+ const SIDE_HANDLE_INSET = (0, zkit_tools_1.wp)(4);
66
+ const SIDE_HANDLE_WIDTH = (0, zkit_tools_1.wp)(16);
67
+ function clampNumber(value, min, max) {
68
+ if (!Number.isFinite(value))
69
+ return min;
70
+ return Math.max(min, Math.min(max, value));
71
+ }
72
+ function resolveDuration(duration, fallback) {
73
+ if (duration == null || !Number.isFinite(duration))
74
+ return fallback;
75
+ return Math.max(0, duration);
76
+ }
77
+ function resolveAnimation(animation) {
78
+ var _a, _b, _c, _d;
79
+ if (animation === false) {
80
+ return {
81
+ openTiming: {
82
+ duration: 0,
83
+ easing: DEFAULT_EASING,
84
+ reduceMotion: react_native_reanimated_1.ReduceMotion.Always,
85
+ },
86
+ closeTiming: {
87
+ duration: 0,
88
+ easing: DEFAULT_EASING,
89
+ reduceMotion: react_native_reanimated_1.ReduceMotion.Always,
90
+ },
91
+ };
92
+ }
93
+ const easing = (_a = animation === null || animation === void 0 ? void 0 : animation.easing) !== null && _a !== void 0 ? _a : DEFAULT_EASING;
94
+ const reduceMotion = (_b = animation === null || animation === void 0 ? void 0 : animation.reduceMotion) !== null && _b !== void 0 ? _b : react_native_reanimated_1.ReduceMotion.System;
95
+ const duration = animation === null || animation === void 0 ? void 0 : animation.duration;
96
+ return {
97
+ openTiming: {
98
+ duration: resolveDuration((_c = animation === null || animation === void 0 ? void 0 : animation.openDuration) !== null && _c !== void 0 ? _c : duration, DEFAULT_OPEN_DURATION),
99
+ easing,
100
+ reduceMotion,
101
+ },
102
+ closeTiming: {
103
+ duration: resolveDuration((_d = animation === null || animation === void 0 ? void 0 : animation.closeDuration) !== null && _d !== void 0 ? _d : duration, DEFAULT_CLOSE_DURATION),
104
+ easing,
105
+ reduceMotion,
106
+ },
107
+ };
108
+ }
109
+ function resolveBackdrop(backdrop) {
110
+ var _a, _b;
111
+ if (backdrop === false) {
112
+ return {
113
+ visible: false,
114
+ dismissOnPress: false,
115
+ color: '#000000',
116
+ opacity: 0,
117
+ };
118
+ }
119
+ if (backdrop && typeof backdrop === 'object') {
120
+ return {
121
+ visible: backdrop.visible !== false,
122
+ dismissOnPress: backdrop.dismissOnPress !== false,
123
+ color: (_a = backdrop.color) !== null && _a !== void 0 ? _a : '#000000',
124
+ opacity: (_b = backdrop.opacity) !== null && _b !== void 0 ? _b : DEFAULT_BACKDROP_OPACITY,
125
+ };
126
+ }
127
+ return {
128
+ visible: true,
129
+ dismissOnPress: true,
130
+ color: '#000000',
131
+ opacity: DEFAULT_BACKDROP_OPACITY,
132
+ };
133
+ }
134
+ function renderSlot(slot, context) {
135
+ if (typeof slot === 'function') {
136
+ return slot(context);
137
+ }
138
+ return slot;
139
+ }
140
+ function normalizeDetentIndex(index, length) {
141
+ if (!Number.isFinite(index))
142
+ return 0;
143
+ return clampNumber(Math.round(index !== null && index !== void 0 ? index : 0), 0, Math.max(0, length - 1));
144
+ }
145
+ function detentsFromSize(size) {
146
+ if (size == null || size === 'auto' || typeof size === 'number')
147
+ return undefined;
148
+ if (size === 'sm')
149
+ return ['content'];
150
+ if (size === 'md')
151
+ return ['medium'];
152
+ if (size === 'lg')
153
+ return ['large'];
154
+ if (size === 'full')
155
+ return ['full'];
156
+ return [size];
157
+ }
158
+ function parsePercent(input) {
159
+ if (!input.endsWith('%'))
160
+ return undefined;
161
+ const percent = Number.parseFloat(input.slice(0, -1));
162
+ if (!Number.isFinite(percent) || percent <= 0)
163
+ return undefined;
164
+ return clampNumber(percent / 100, 0.1, 1);
165
+ }
166
+ function resolveAxisSize(size, axisLength, fallback, maxSize) {
167
+ const resolvedMax = Math.max((0, zkit_tools_1.wp)(64), maxSize !== null && maxSize !== void 0 ? maxSize : axisLength);
168
+ if (typeof size === 'number')
169
+ return clampNumber(size, (0, zkit_tools_1.wp)(64), resolvedMax);
170
+ if (typeof size === 'string') {
171
+ const percent = parsePercent(size);
172
+ if (percent != null)
173
+ return clampNumber(axisLength * percent, (0, zkit_tools_1.wp)(64), resolvedMax);
174
+ if (size === 'sm')
175
+ return clampNumber((0, zkit_tools_1.wp)(280), (0, zkit_tools_1.wp)(64), resolvedMax);
176
+ if (size === 'md')
177
+ return clampNumber((0, zkit_tools_1.wp)(320), (0, zkit_tools_1.wp)(64), resolvedMax);
178
+ if (size === 'lg')
179
+ return clampNumber((0, zkit_tools_1.wp)(380), (0, zkit_tools_1.wp)(64), resolvedMax);
180
+ if (size === 'full')
181
+ return resolvedMax;
182
+ }
183
+ return clampNumber(fallback, (0, zkit_tools_1.wp)(64), resolvedMax);
184
+ }
185
+ function resolveTopHeight(size, windowHeight, maxHeight) {
186
+ if (size == null || size === 'auto')
187
+ return undefined;
188
+ return resolveAxisSize(size, windowHeight, windowHeight * DEFAULT_TOP_MAX_RATIO, maxHeight);
189
+ }
190
+ function resolveBottomHeight(detents, detentIndex, windowHeight, maxHeight) {
191
+ var _a;
192
+ const detent = (_a = detents === null || detents === void 0 ? void 0 : detents[normalizeDetentIndex(detentIndex, detents.length)]) !== null && _a !== void 0 ? _a : 'auto';
193
+ if (detent === 'content' || detent === 'auto')
194
+ return undefined;
195
+ const resolvedMax = Math.max((0, zkit_tools_1.wp)(64), maxHeight !== null && maxHeight !== void 0 ? maxHeight : windowHeight);
196
+ if (detent === 'medium')
197
+ return clampNumber(windowHeight * 0.5, (0, zkit_tools_1.wp)(64), resolvedMax);
198
+ if (detent === 'large')
199
+ return clampNumber(windowHeight * 0.9, (0, zkit_tools_1.wp)(64), resolvedMax);
200
+ if (detent === 'full')
201
+ return resolvedMax;
202
+ if (typeof detent === 'string') {
203
+ const percent = parsePercent(detent);
204
+ if (percent != null)
205
+ return clampNumber(windowHeight * percent, (0, zkit_tools_1.wp)(64), resolvedMax);
206
+ }
207
+ if (typeof detent === 'number' && Number.isFinite(detent) && detent > 0) {
208
+ return clampNumber(windowHeight * clampNumber(detent, 0.1, 1), (0, zkit_tools_1.wp)(64), resolvedMax);
209
+ }
210
+ return undefined;
211
+ }
212
+ function getCloseDirection(placement) {
213
+ if (placement === 'left' || placement === 'top')
214
+ return -1;
215
+ return 1;
216
+ }
217
+ function getClosedOffset(placement, width, height) {
218
+ if (placement === 'left')
219
+ return -width;
220
+ if (placement === 'right')
221
+ return width;
222
+ if (placement === 'top')
223
+ return -height;
224
+ return height;
225
+ }
226
+ function resolveSafeAreaEdges(safeArea, placement) {
227
+ if (safeArea === false)
228
+ return {};
229
+ if (safeArea && typeof safeArea === 'object')
230
+ return safeArea;
231
+ if (placement === 'top')
232
+ return { top: true, left: true, right: true };
233
+ if (placement === 'left')
234
+ return { top: true, left: true, bottom: true };
235
+ if (placement === 'right')
236
+ return { top: true, right: true, bottom: true };
237
+ return { left: true, right: true, bottom: true };
238
+ }
239
+ function toCloseReason(reason) {
240
+ return reason === 'api' ? 'api' : reason;
241
+ }
242
+ function resolveDetentIndexForDetails(placement, detentIndex) {
243
+ return placement === 'bottom' ? detentIndex : null;
244
+ }
245
+ function getDocument() {
246
+ return globalThis.document;
247
+ }
248
+ const SheetRoot = React.forwardRef(function Sheet({ placement = 'bottom', open: openProp, defaultOpen = false, onOpenChange, onOpenComplete, onCloseComplete, disabled = false, dismissible = DEFAULT_DISMISSIBLE, draggable = DEFAULT_DRAGGABLE, backdrop, title, description, header, footer, children, size, safeArea = true, detents, detentIndex, defaultDetentIndex, onDetentChange, nativeProps, backgroundColor, cornerRadius, maxHeight, maxWidth, handle = DEFAULT_HANDLE_VISIBLE, animation, dragCloseThreshold, dragVelocityThreshold = DEFAULT_DRAG_VELOCITY, style, headerStyle, footerStyle, testID, accessibilityLabel, backdropAccessibilityLabel = 'Close sheet', }, ref) {
249
+ var _a, _b, _c, _d, _e, _f, _g;
250
+ const theme = (0, useTheme_1.useTheme)();
251
+ const insets = (0, react_native_safe_area_context_1.useSafeAreaInsets)();
252
+ const windowSize = (0, react_native_1.useWindowDimensions)();
253
+ const isBottomPlacement = placement === 'bottom';
254
+ const usesNativeBottom = isBottomPlacement && react_native_1.Platform.OS !== 'web';
255
+ const nativeBottomRef = React.useRef(null);
256
+ const isOpenControlled = openProp !== undefined;
257
+ const [innerOpen, setInnerOpen] = React.useState(defaultOpen);
258
+ const isOpen = isOpenControlled ? !!openProp : innerOpen;
259
+ const [sheetState, setSheetState] = React.useState(isOpen ? 'opening' : 'closed');
260
+ const [shellMounted, setShellMounted] = React.useState(isOpen);
261
+ const [surfaceReady, setSurfaceReady] = React.useState(false);
262
+ const [layoutSize, setLayoutSize] = React.useState({ width: 0, height: 0 });
263
+ const bottomDetents = React.useMemo(() => detents !== null && detents !== void 0 ? detents : detentsFromSize(size), [detents, size]);
264
+ const bottomDetentCount = (_a = bottomDetents === null || bottomDetents === void 0 ? void 0 : bottomDetents.length) !== null && _a !== void 0 ? _a : 1;
265
+ const initialDetentIndex = normalizeDetentIndex(detentIndex !== null && detentIndex !== void 0 ? detentIndex : defaultDetentIndex, bottomDetentCount);
266
+ const [customDetentIndex, setCustomDetentIndex] = React.useState(initialDetentIndex);
267
+ const progress = (0, react_native_reanimated_1.useSharedValue)(0);
268
+ const gestureClosePending = (0, react_native_reanimated_1.useSharedValue)(false);
269
+ const isOpenRef = React.useRef(isOpen);
270
+ const previousOpenRef = React.useRef(isOpen);
271
+ const closeIntentRef = React.useRef(false);
272
+ const activeLifecycleRef = React.useRef(isOpen);
273
+ const stateRef = React.useRef(sheetState);
274
+ const requestedDetentIndexRef = React.useRef(initialDetentIndex);
275
+ const animationRef = React.useRef(resolveAnimation(animation));
276
+ const closeReasonRef = React.useRef('system');
277
+ const presentAnimatedRef = React.useRef(true);
278
+ const dismissAnimatedRef = React.useRef(true);
279
+ const openAnimationFrameRef = React.useRef(null);
280
+ const openAnimationStartedRef = React.useRef(false);
281
+ const controlledGestureResetFrameRef = React.useRef(null);
282
+ const backdropConfig = React.useMemo(() => resolveBackdrop(backdrop), [backdrop]);
283
+ const resolvedAnimation = React.useMemo(() => resolveAnimation(animation), [animation]);
284
+ const cancelOpenAnimationFrame = React.useCallback(() => {
285
+ if (openAnimationFrameRef.current == null)
286
+ return;
287
+ cancelAnimationFrame(openAnimationFrameRef.current);
288
+ openAnimationFrameRef.current = null;
289
+ }, []);
290
+ React.useEffect(() => {
291
+ animationRef.current = resolvedAnimation;
292
+ }, [resolvedAnimation]);
293
+ React.useEffect(() => {
294
+ isOpenRef.current = isOpen;
295
+ }, [isOpen]);
296
+ React.useEffect(() => {
297
+ stateRef.current = sheetState;
298
+ }, [sheetState]);
299
+ React.useEffect(() => {
300
+ const wasOpen = previousOpenRef.current;
301
+ if (wasOpen && !isOpen) {
302
+ if (!closeIntentRef.current) {
303
+ closeReasonRef.current = 'system';
304
+ }
305
+ closeIntentRef.current = false;
306
+ }
307
+ if (!wasOpen && isOpen) {
308
+ closeIntentRef.current = false;
309
+ }
310
+ previousOpenRef.current = isOpen;
311
+ }, [isOpen]);
312
+ React.useEffect(() => {
313
+ if (detentIndex == null)
314
+ return;
315
+ const nextIndex = normalizeDetentIndex(detentIndex, bottomDetentCount);
316
+ requestedDetentIndexRef.current = nextIndex;
317
+ setCustomDetentIndex(nextIndex);
318
+ }, [bottomDetentCount, detentIndex]);
319
+ React.useEffect(() => {
320
+ setCustomDetentIndex((currentIndex) => {
321
+ const nextIndex = normalizeDetentIndex(currentIndex, bottomDetentCount);
322
+ requestedDetentIndexRef.current = nextIndex;
323
+ return nextIndex;
324
+ });
325
+ }, [bottomDetentCount]);
326
+ React.useEffect(() => () => {
327
+ cancelOpenAnimationFrame();
328
+ if (controlledGestureResetFrameRef.current != null) {
329
+ cancelAnimationFrame(controlledGestureResetFrameRef.current);
330
+ controlledGestureResetFrameRef.current = null;
331
+ }
332
+ }, [cancelOpenAnimationFrame]);
333
+ const emitOpenChange = React.useCallback((nextOpen, reason, detentIndex) => {
334
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(nextOpen, {
335
+ reason,
336
+ placement,
337
+ detentIndex: resolveDetentIndexForDetails(placement, normalizeDetentIndex(detentIndex !== null && detentIndex !== void 0 ? detentIndex : requestedDetentIndexRef.current, bottomDetentCount)),
338
+ });
339
+ }, [bottomDetentCount, onOpenChange, placement]);
340
+ const requestOpenChange = React.useCallback((nextOpen, reason, detentIndex) => {
341
+ if (disabled && nextOpen)
342
+ return;
343
+ if (detentIndex != null) {
344
+ const nextIndex = normalizeDetentIndex(detentIndex, bottomDetentCount);
345
+ requestedDetentIndexRef.current = nextIndex;
346
+ if (!usesNativeBottom)
347
+ setCustomDetentIndex(nextIndex);
348
+ }
349
+ if (nextOpen === isOpenRef.current)
350
+ return;
351
+ if (nextOpen) {
352
+ activeLifecycleRef.current = true;
353
+ presentAnimatedRef.current = true;
354
+ }
355
+ else {
356
+ closeReasonRef.current = toCloseReason(reason);
357
+ closeIntentRef.current = true;
358
+ dismissAnimatedRef.current = true;
359
+ }
360
+ if (!isOpenControlled) {
361
+ setInnerOpen(nextOpen);
362
+ }
363
+ emitOpenChange(nextOpen, reason, requestedDetentIndexRef.current);
364
+ }, [bottomDetentCount, disabled, emitOpenChange, isOpenControlled, usesNativeBottom]);
365
+ const finishClosedLifecycle = React.useCallback(() => {
366
+ if (isOpenRef.current)
367
+ return;
368
+ setSheetState('closed');
369
+ progress.value = 0;
370
+ gestureClosePending.value = false;
371
+ presentAnimatedRef.current = true;
372
+ dismissAnimatedRef.current = true;
373
+ openAnimationStartedRef.current = false;
374
+ setSurfaceReady(false);
375
+ setShellMounted(false);
376
+ if (activeLifecycleRef.current) {
377
+ activeLifecycleRef.current = false;
378
+ onCloseComplete === null || onCloseComplete === void 0 ? void 0 : onCloseComplete({
379
+ reason: closeReasonRef.current,
380
+ placement,
381
+ detentIndex: resolveDetentIndexForDetails(placement, requestedDetentIndexRef.current),
382
+ });
383
+ }
384
+ }, [gestureClosePending, onCloseComplete, placement, progress]);
385
+ const finishOpenLifecycle = React.useCallback(() => {
386
+ if (!isOpenRef.current)
387
+ return;
388
+ setSheetState('open');
389
+ gestureClosePending.value = false;
390
+ onOpenComplete === null || onOpenComplete === void 0 ? void 0 : onOpenComplete({
391
+ placement,
392
+ detentIndex: resolveDetentIndexForDetails(placement, requestedDetentIndexRef.current),
393
+ });
394
+ }, [gestureClosePending, onOpenComplete, placement]);
395
+ const openSheet = React.useCallback(async (options) => {
396
+ var _a;
397
+ const targetIndex = normalizeDetentIndex((_a = options === null || options === void 0 ? void 0 : options.detentIndex) !== null && _a !== void 0 ? _a : requestedDetentIndexRef.current, bottomDetentCount);
398
+ requestedDetentIndexRef.current = targetIndex;
399
+ presentAnimatedRef.current = (options === null || options === void 0 ? void 0 : options.animated) !== false;
400
+ if (usesNativeBottom) {
401
+ const bottomRef = nativeBottomRef.current;
402
+ if (bottomRef) {
403
+ await bottomRef.open({ detentIndex: targetIndex, animated: options === null || options === void 0 ? void 0 : options.animated });
404
+ return;
405
+ }
406
+ }
407
+ setCustomDetentIndex(targetIndex);
408
+ requestOpenChange(true, 'api', targetIndex);
409
+ }, [bottomDetentCount, requestOpenChange, usesNativeBottom]);
410
+ const closeSheet = React.useCallback(async (options) => {
411
+ dismissAnimatedRef.current = (options === null || options === void 0 ? void 0 : options.animated) !== false;
412
+ if (usesNativeBottom) {
413
+ const bottomRef = nativeBottomRef.current;
414
+ if (bottomRef) {
415
+ await bottomRef.close({ animated: options === null || options === void 0 ? void 0 : options.animated });
416
+ return;
417
+ }
418
+ }
419
+ requestOpenChange(false, 'api', requestedDetentIndexRef.current);
420
+ }, [requestOpenChange, usesNativeBottom]);
421
+ const snapTo = React.useCallback(async (detentIndex) => {
422
+ var _a;
423
+ const targetIndex = normalizeDetentIndex(detentIndex, bottomDetentCount);
424
+ requestedDetentIndexRef.current = targetIndex;
425
+ setCustomDetentIndex(targetIndex);
426
+ if (usesNativeBottom) {
427
+ await ((_a = nativeBottomRef.current) === null || _a === void 0 ? void 0 : _a.snapTo(targetIndex));
428
+ }
429
+ }, [bottomDetentCount, usesNativeBottom]);
430
+ React.useImperativeHandle(ref, () => ({
431
+ open: openSheet,
432
+ close: closeSheet,
433
+ snapTo,
434
+ getState: () => { var _a, _b; return (usesNativeBottom ? (_b = (_a = nativeBottomRef.current) === null || _a === void 0 ? void 0 : _a.getState()) !== null && _b !== void 0 ? _b : stateRef.current : stateRef.current); },
435
+ }), [closeSheet, openSheet, snapTo, usesNativeBottom]);
436
+ React.useEffect(() => {
437
+ if (usesNativeBottom || !isOpen)
438
+ return undefined;
439
+ activeLifecycleRef.current = true;
440
+ openAnimationStartedRef.current = false;
441
+ cancelOpenAnimationFrame();
442
+ progress.value = 0;
443
+ gestureClosePending.value = false;
444
+ setLayoutSize({ width: 0, height: 0 });
445
+ setSurfaceReady(false);
446
+ setShellMounted(true);
447
+ setSheetState('opening');
448
+ return undefined;
449
+ }, [cancelOpenAnimationFrame, gestureClosePending, isOpen, progress, usesNativeBottom]);
450
+ React.useEffect(() => {
451
+ if (usesNativeBottom || !isOpen || !shellMounted || !surfaceReady || openAnimationStartedRef.current) {
452
+ return undefined;
453
+ }
454
+ const frame = requestAnimationFrame(() => {
455
+ openAnimationFrameRef.current = null;
456
+ if (!isOpenRef.current)
457
+ return;
458
+ openAnimationStartedRef.current = true;
459
+ progress.value = (0, react_native_reanimated_1.withTiming)(1, presentAnimatedRef.current ? animationRef.current.openTiming : { ...animationRef.current.openTiming, duration: 0 }, (finished) => {
460
+ if (finished)
461
+ (0, react_native_worklets_1.scheduleOnRN)(finishOpenLifecycle);
462
+ });
463
+ });
464
+ openAnimationFrameRef.current = frame;
465
+ return () => {
466
+ if (openAnimationFrameRef.current !== frame)
467
+ return;
468
+ cancelAnimationFrame(frame);
469
+ openAnimationFrameRef.current = null;
470
+ };
471
+ }, [finishOpenLifecycle, isOpen, progress, shellMounted, surfaceReady, usesNativeBottom]);
472
+ React.useEffect(() => {
473
+ if (usesNativeBottom || isOpen)
474
+ return undefined;
475
+ if (!shellMounted || stateRef.current === 'closed')
476
+ return undefined;
477
+ cancelOpenAnimationFrame();
478
+ openAnimationStartedRef.current = false;
479
+ setSurfaceReady(false);
480
+ setSheetState('closing');
481
+ progress.value = (0, react_native_reanimated_1.withTiming)(0, dismissAnimatedRef.current ? animationRef.current.closeTiming : { ...animationRef.current.closeTiming, duration: 0 }, (finished) => {
482
+ if (finished)
483
+ (0, react_native_worklets_1.scheduleOnRN)(finishClosedLifecycle);
484
+ });
485
+ return undefined;
486
+ }, [cancelOpenAnimationFrame, finishClosedLifecycle, isOpen, progress, shellMounted, usesNativeBottom]);
487
+ const requestBackdropClose = React.useCallback(() => {
488
+ if (disabled || !dismissible || !backdropConfig.dismissOnPress || !isOpenRef.current)
489
+ return;
490
+ requestOpenChange(false, 'backdrop', requestedDetentIndexRef.current);
491
+ }, [backdropConfig.dismissOnPress, disabled, dismissible, requestOpenChange]);
492
+ const requestBackClose = React.useCallback(() => {
493
+ if (disabled || !dismissible || !isOpenRef.current)
494
+ return;
495
+ requestOpenChange(false, 'back', requestedDetentIndexRef.current);
496
+ }, [disabled, dismissible, requestOpenChange]);
497
+ const requestGestureClose = React.useCallback(() => {
498
+ if (disabled || !dismissible || !draggable || !isOpenRef.current)
499
+ return;
500
+ requestOpenChange(false, 'gesture', requestedDetentIndexRef.current);
501
+ if (!isOpenControlled)
502
+ return;
503
+ if (controlledGestureResetFrameRef.current != null) {
504
+ cancelAnimationFrame(controlledGestureResetFrameRef.current);
505
+ }
506
+ controlledGestureResetFrameRef.current = requestAnimationFrame(() => {
507
+ controlledGestureResetFrameRef.current = null;
508
+ if (!isOpenRef.current)
509
+ return;
510
+ gestureClosePending.value = false;
511
+ progress.value = (0, react_native_reanimated_1.withTiming)(1, animationRef.current.openTiming);
512
+ });
513
+ }, [disabled, dismissible, draggable, gestureClosePending, isOpenControlled, progress, requestOpenChange]);
514
+ React.useEffect(() => {
515
+ if (usesNativeBottom || react_native_1.Platform.OS !== 'web' || !isOpen || disabled || !dismissible)
516
+ return undefined;
517
+ const documentRef = getDocument();
518
+ if (!documentRef)
519
+ return undefined;
520
+ const handleKeyDown = (event) => {
521
+ var _a;
522
+ if (event.key !== 'Escape')
523
+ return;
524
+ (_a = event.preventDefault) === null || _a === void 0 ? void 0 : _a.call(event);
525
+ requestBackClose();
526
+ };
527
+ documentRef.addEventListener('keydown', handleKeyDown);
528
+ return () => documentRef.removeEventListener('keydown', handleKeyDown);
529
+ }, [disabled, dismissible, isOpen, requestBackClose, usesNativeBottom]);
530
+ const context = React.useMemo(() => ({
531
+ isOpen,
532
+ state: sheetState,
533
+ placement,
534
+ detentIndex: resolveDetentIndexForDetails(placement, customDetentIndex),
535
+ open: openSheet,
536
+ close: closeSheet,
537
+ snapTo,
538
+ }), [closeSheet, customDetentIndex, isOpen, openSheet, placement, sheetState, snapTo]);
539
+ const handleBottomOpenChange = React.useCallback((nextOpen, meta) => {
540
+ const reason = meta.reason;
541
+ requestedDetentIndexRef.current = normalizeDetentIndex(meta.detentIndex, bottomDetentCount);
542
+ if (!nextOpen) {
543
+ closeReasonRef.current = toCloseReason(reason);
544
+ closeIntentRef.current = true;
545
+ }
546
+ else {
547
+ activeLifecycleRef.current = true;
548
+ }
549
+ if (!isOpenControlled) {
550
+ setInnerOpen(nextOpen);
551
+ }
552
+ emitOpenChange(nextOpen, reason, requestedDetentIndexRef.current);
553
+ }, [bottomDetentCount, emitOpenChange, isOpenControlled]);
554
+ const horizontal = placement === 'left' || placement === 'right';
555
+ const fallbackWidth = resolveAxisSize(size, windowSize.width, Math.min((0, zkit_tools_1.wp)(360), windowSize.width * DEFAULT_SIDE_SIZE_RATIO), maxWidth);
556
+ const resolvedHeight = isBottomPlacement
557
+ ? resolveBottomHeight(bottomDetents, customDetentIndex, windowSize.height, maxHeight)
558
+ : resolveTopHeight(size, windowSize.height, maxHeight);
559
+ const fallbackHeight = resolvedHeight !== null && resolvedHeight !== void 0 ? resolvedHeight : (isBottomPlacement
560
+ ? Math.min(windowSize.height, maxHeight !== null && maxHeight !== void 0 ? maxHeight : windowSize.height)
561
+ : Math.min(windowSize.height * DEFAULT_TOP_MAX_RATIO, maxHeight !== null && maxHeight !== void 0 ? maxHeight : windowSize.height));
562
+ const animatedWidth = horizontal ? fallbackWidth : windowSize.width;
563
+ const animatedHeight = horizontal ? windowSize.height : layoutSize.height || fallbackHeight;
564
+ const closedOffset = getClosedOffset(placement, animatedWidth, animatedHeight);
565
+ const closedDistance = Math.abs(closedOffset);
566
+ const closeDirection = getCloseDirection(placement);
567
+ const closeThreshold = dragCloseThreshold !== null && dragCloseThreshold !== void 0 ? dragCloseThreshold : Math.min(closedDistance * 0.36, (0, zkit_tools_1.wp)(156));
568
+ const safeAreaEdges = resolveSafeAreaEdges(safeArea, placement);
569
+ const handleConfig = handle && typeof handle === 'object' ? handle : {};
570
+ const handleVisible = handle !== false;
571
+ const handleCanDrag = handleVisible && draggable && dismissible && !disabled;
572
+ const usesBottomInlineHandle = handleVisible && isBottomPlacement;
573
+ const usesTopInlineHandle = handleVisible && placement === 'top';
574
+ const usesOverlayHandle = handleVisible && horizontal;
575
+ const topHandleReserve = usesTopInlineHandle ? TOP_HANDLE_RESERVE : 0;
576
+ const dragResetTiming = resolvedAnimation.openTiming;
577
+ const dragCloseTiming = resolvedAnimation.closeTiming;
578
+ const surfaceColor = backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : theme.colors.surface;
579
+ const resolvedCornerRadius = cornerRadius !== null && cornerRadius !== void 0 ? cornerRadius : (0, zkit_tools_1.wp)(22);
580
+ const topMaxHeight = Math.min(windowSize.height, (maxHeight !== null && maxHeight !== void 0 ? maxHeight : windowSize.height * DEFAULT_TOP_MAX_RATIO) + topHandleReserve);
581
+ const surfaceLayoutStyle = horizontal
582
+ ? {
583
+ bottom: 0,
584
+ top: 0,
585
+ width: fallbackWidth,
586
+ maxWidth,
587
+ [placement]: -animatedWidth,
588
+ }
589
+ : isBottomPlacement
590
+ ? {
591
+ bottom: -animatedHeight,
592
+ left: 0,
593
+ right: 0,
594
+ height: resolvedHeight,
595
+ maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : windowSize.height,
596
+ }
597
+ : {
598
+ left: 0,
599
+ right: 0,
600
+ top: -animatedHeight,
601
+ height: resolvedHeight,
602
+ maxHeight: topMaxHeight,
603
+ };
604
+ const surfaceInsetStyle = {
605
+ paddingTop: (safeAreaEdges.top ? insets.top : 0) ||
606
+ undefined,
607
+ paddingRight: (safeAreaEdges.right ? insets.right : 0) +
608
+ (placement === 'left' && usesOverlayHandle ? SIDE_HANDLE_RESERVE : 0) ||
609
+ undefined,
610
+ paddingBottom: (safeAreaEdges.bottom ? insets.bottom : 0) ||
611
+ undefined,
612
+ paddingLeft: (safeAreaEdges.left ? insets.left : 0) +
613
+ (placement === 'right' && usesOverlayHandle ? SIDE_HANDLE_RESERVE : 0) ||
614
+ undefined,
615
+ };
616
+ const cornerStyle = placement === 'left'
617
+ ? {
618
+ borderTopRightRadius: resolvedCornerRadius,
619
+ borderBottomRightRadius: resolvedCornerRadius,
620
+ }
621
+ : placement === 'right'
622
+ ? {
623
+ borderTopLeftRadius: resolvedCornerRadius,
624
+ borderBottomLeftRadius: resolvedCornerRadius,
625
+ }
626
+ : placement === 'bottom'
627
+ ? {
628
+ borderTopLeftRadius: resolvedCornerRadius,
629
+ borderTopRightRadius: resolvedCornerRadius,
630
+ }
631
+ : {
632
+ borderBottomLeftRadius: resolvedCornerRadius,
633
+ borderBottomRightRadius: resolvedCornerRadius,
634
+ };
635
+ const animatedSurfaceStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
636
+ const translate = -closedOffset * progress.value;
637
+ if (horizontal)
638
+ return { transform: [{ translateX: translate }] };
639
+ return { transform: [{ translateY: translate }] };
640
+ }, [closedOffset, horizontal]);
641
+ const animatedBackdropStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => ({
642
+ opacity: backdropConfig.opacity * progress.value,
643
+ }), [backdropConfig.opacity]);
644
+ const panGesture = React.useMemo(() => {
645
+ if (!handleCanDrag)
646
+ return react_native_gesture_handler_1.Gesture.Pan().enabled(false);
647
+ const baseGesture = react_native_gesture_handler_1.Gesture.Pan().enabled(handleCanDrag);
648
+ const directionalGesture = horizontal
649
+ ? baseGesture.activeOffsetX([-(0, zkit_tools_1.wp)(8), (0, zkit_tools_1.wp)(8)])
650
+ : baseGesture.activeOffsetY([-(0, zkit_tools_1.wp)(8), (0, zkit_tools_1.wp)(8)]);
651
+ return directionalGesture
652
+ .onBegin(() => {
653
+ 'worklet';
654
+ gestureClosePending.value = false;
655
+ })
656
+ .onUpdate((event) => {
657
+ 'worklet';
658
+ const rawDrag = placement === 'left'
659
+ ? Math.min(event.translationX, 0)
660
+ : placement === 'right'
661
+ ? Math.max(event.translationX, 0)
662
+ : placement === 'top'
663
+ ? Math.min(event.translationY, 0)
664
+ : Math.max(event.translationY, 0);
665
+ const boundedDrag = closeDirection > 0
666
+ ? Math.min(rawDrag, closedDistance)
667
+ : Math.max(rawDrag, -closedDistance);
668
+ progress.value = closedDistance <= 0 ? 1 : 1 - Math.abs(boundedDrag) / closedDistance;
669
+ })
670
+ .onEnd((event) => {
671
+ 'worklet';
672
+ const velocity = horizontal ? event.velocityX : event.velocityY;
673
+ const distance = closedDistance * (1 - progress.value);
674
+ const shouldClose = distance >= closeThreshold ||
675
+ velocity * closeDirection >= dragVelocityThreshold;
676
+ if (shouldClose) {
677
+ gestureClosePending.value = true;
678
+ progress.value = (0, react_native_reanimated_1.withTiming)(0, dragCloseTiming);
679
+ (0, react_native_worklets_1.scheduleOnRN)(requestGestureClose);
680
+ }
681
+ })
682
+ .onFinalize(() => {
683
+ 'worklet';
684
+ if (gestureClosePending.value)
685
+ return;
686
+ progress.value = (0, react_native_reanimated_1.withTiming)(1, dragResetTiming);
687
+ });
688
+ }, [
689
+ closeDirection,
690
+ closedDistance,
691
+ closeThreshold,
692
+ dragCloseTiming,
693
+ dragResetTiming,
694
+ dragVelocityThreshold,
695
+ gestureClosePending,
696
+ handleCanDrag,
697
+ horizontal,
698
+ placement,
699
+ progress,
700
+ requestGestureClose,
701
+ ]);
702
+ const handleIndicator = handleVisible ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: [
703
+ horizontal ? styles.verticalHandle : styles.horizontalHandle,
704
+ {
705
+ backgroundColor: (_b = handleConfig.color) !== null && _b !== void 0 ? _b : theme.colors.border,
706
+ borderRadius: (_c = handleConfig.radius) !== null && _c !== void 0 ? _c : (0, zkit_tools_1.wp)(2),
707
+ height: horizontal ? (_d = handleConfig.width) !== null && _d !== void 0 ? _d : (0, zkit_tools_1.wp)(36) : (_e = handleConfig.height) !== null && _e !== void 0 ? _e : (0, zkit_tools_1.wp)(4),
708
+ width: horizontal ? (_f = handleConfig.height) !== null && _f !== void 0 ? _f : (0, zkit_tools_1.wp)(4) : (_g = handleConfig.width) !== null && _g !== void 0 ? _g : (0, zkit_tools_1.wp)(36),
709
+ },
710
+ ] })) : null;
711
+ const inlineHandle = usesBottomInlineHandle ? ((0, jsx_runtime_1.jsx)(react_native_gesture_handler_1.GestureDetector, { gesture: panGesture, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityRole: handleCanDrag ? 'adjustable' : undefined, style: styles.inlineHandleHost, children: handleIndicator }) })) : null;
712
+ const topInlineHandle = usesTopInlineHandle ? ((0, jsx_runtime_1.jsx)(react_native_gesture_handler_1.GestureDetector, { gesture: panGesture, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityRole: handleCanDrag ? 'adjustable' : undefined, style: styles.topHandleHost, children: handleIndicator }) })) : null;
713
+ const overlayHandle = usesOverlayHandle ? ((0, jsx_runtime_1.jsx)(react_native_gesture_handler_1.GestureDetector, { gesture: panGesture, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { accessibilityRole: handleCanDrag ? 'adjustable' : undefined, style: [
714
+ styles.handleHost,
715
+ placement === 'left' ? styles.handleHostRight : styles.handleHostLeft,
716
+ ], children: handleIndicator }) })) : null;
717
+ if (usesNativeBottom) {
718
+ return ((0, jsx_runtime_1.jsx)(nativeBottom_1.NativeBottomSheet, { ref: nativeBottomRef, open: isOpen, onOpenChange: handleBottomOpenChange, onOpenComplete: (payload) => {
719
+ requestedDetentIndexRef.current = payload.index;
720
+ onOpenComplete === null || onOpenComplete === void 0 ? void 0 : onOpenComplete({
721
+ placement: 'bottom',
722
+ detentIndex: payload.index,
723
+ });
724
+ }, onCloseComplete: (details) => {
725
+ closeReasonRef.current = details.reason;
726
+ requestedDetentIndexRef.current = details.detentIndex;
727
+ onCloseComplete === null || onCloseComplete === void 0 ? void 0 : onCloseComplete({
728
+ reason: details.reason,
729
+ placement: 'bottom',
730
+ detentIndex: details.detentIndex,
731
+ });
732
+ }, detents: bottomDetents, detentIndex: detentIndex, defaultDetentIndex: defaultDetentIndex, onDetentChange: (index, payload) => {
733
+ requestedDetentIndexRef.current = index;
734
+ onDetentChange === null || onDetentChange === void 0 ? void 0 : onDetentChange(index, payload);
735
+ }, disabled: disabled, dismissible: dismissible, draggable: draggable, backdrop: backdrop, title: title, description: description, header: header === undefined
736
+ ? undefined
737
+ : (bottomContext) => renderSlot(header, bottomContext), footer: footer === undefined
738
+ ? undefined
739
+ : (bottomContext) => renderSlot(footer, bottomContext), backgroundColor: backgroundColor, cornerRadius: cornerRadius, maxHeight: maxHeight, maxWidth: maxWidth, handle: handle, style: style, headerStyle: headerStyle, footerStyle: footerStyle, testID: testID, accessibilityLabel: accessibilityLabel, backdropAccessibilityLabel: backdropAccessibilityLabel, nativeProps: nativeProps, children: children === undefined
740
+ ? undefined
741
+ : (bottomContext) => renderSlot(children, bottomContext) }));
742
+ }
743
+ if (!shellMounted)
744
+ return null;
745
+ const resolvedHeader = header !== undefined || title != null || description != null ? (header !== undefined ? (renderSlot(header, context)) : ((0, jsx_runtime_1.jsx)(slots_1.SheetHeader, { title: title, description: description, style: headerStyle }))) : null;
746
+ const resolvedFooter = footer !== undefined ? renderSlot(footer, context) : null;
747
+ const resolvedChildren = renderSlot(children, context);
748
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Modal, { visible: true, transparent: true, animationType: "none", statusBarTranslucent: true, presentationStyle: "overFullScreen", onRequestClose: requestBackClose, children: (0, jsx_runtime_1.jsx)(react_native_gesture_handler_1.GestureHandlerRootView, { style: styles.modalRoot, children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.modalRoot, pointerEvents: "box-none", children: [backdropConfig.visible ? ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { accessibilityRole: "button", accessibilityLabel: backdropAccessibilityLabel, disabled: disabled || !dismissible || !backdropConfig.dismissOnPress, onPress: requestBackdropClose, style: react_native_1.StyleSheet.absoluteFill, children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: "none", style: [
749
+ react_native_1.StyleSheet.absoluteFill,
750
+ { backgroundColor: backdropConfig.color },
751
+ styles.closedBackdrop,
752
+ animatedBackdropStyle,
753
+ ] }) })) : null, (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { testID: testID, accessibilityLabel: accessibilityLabel, accessibilityViewIsModal: true, importantForAccessibility: "yes", onLayout: (event) => {
754
+ const { width, height } = event.nativeEvent.layout;
755
+ const sizeChanged = width !== layoutSize.width || height !== layoutSize.height;
756
+ if (sizeChanged)
757
+ setLayoutSize({ width, height });
758
+ if (!surfaceReady)
759
+ setSurfaceReady(true);
760
+ }, style: [
761
+ styles.surface,
762
+ surfaceLayoutStyle,
763
+ cornerStyle,
764
+ surfaceInsetStyle,
765
+ { backgroundColor: surfaceColor, borderColor: theme.colors.border },
766
+ style,
767
+ animatedSurfaceStyle,
768
+ ], children: usesTopInlineHandle ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.topContentHost, children: [resolvedHeader, resolvedChildren, resolvedFooter != null ? (0, jsx_runtime_1.jsx)(react_native_1.View, { style: footerStyle, children: resolvedFooter }) : null] }), topInlineHandle] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [inlineHandle, overlayHandle, resolvedHeader, resolvedChildren, resolvedFooter != null ? (0, jsx_runtime_1.jsx)(react_native_1.View, { style: footerStyle, children: resolvedFooter }) : null] })) })] }) }) }));
769
+ });
770
+ exports.Sheet = Object.assign(SheetRoot, {
771
+ Header: slots_1.SheetHeader,
772
+ Content: slots_1.SheetContent,
773
+ Footer: slots_1.SheetFooter,
774
+ });
775
+ const styles = react_native_1.StyleSheet.create({
776
+ modalRoot: {
777
+ ...react_native_1.StyleSheet.absoluteFillObject,
778
+ },
779
+ surface: {
780
+ borderWidth: react_native_1.StyleSheet.hairlineWidth,
781
+ overflow: 'hidden',
782
+ position: 'absolute',
783
+ },
784
+ closedBackdrop: {
785
+ opacity: 0,
786
+ },
787
+ handleHost: {
788
+ alignItems: 'center',
789
+ justifyContent: 'center',
790
+ position: 'absolute',
791
+ zIndex: 2,
792
+ },
793
+ handleHostLeft: {
794
+ bottom: 0,
795
+ left: SIDE_HANDLE_INSET,
796
+ top: 0,
797
+ width: SIDE_HANDLE_WIDTH,
798
+ },
799
+ handleHostRight: {
800
+ bottom: 0,
801
+ right: SIDE_HANDLE_INSET,
802
+ top: 0,
803
+ width: SIDE_HANDLE_WIDTH,
804
+ },
805
+ inlineHandleHost: {
806
+ alignItems: 'center',
807
+ flexShrink: 0,
808
+ height: BOTTOM_HANDLE_RESERVE,
809
+ justifyContent: 'center',
810
+ },
811
+ topContentHost: {
812
+ flexShrink: 1,
813
+ marginBottom: TOP_HANDLE_RESERVE,
814
+ overflow: 'hidden',
815
+ },
816
+ topHandleHost: {
817
+ alignItems: 'center',
818
+ bottom: 0,
819
+ height: TOP_HANDLE_RESERVE,
820
+ justifyContent: 'center',
821
+ left: 0,
822
+ position: 'absolute',
823
+ right: 0,
824
+ zIndex: 2,
825
+ },
826
+ horizontalHandle: {
827
+ flexShrink: 0,
828
+ },
829
+ verticalHandle: {
830
+ flexShrink: 0,
831
+ },
832
+ });