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,777 @@
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.Accordion = Accordion;
37
+ exports.AccordionItem = AccordionItem;
38
+ exports.AccordionTrigger = AccordionTrigger;
39
+ exports.AccordionContent = AccordionContent;
40
+ exports.AccordionIndicator = AccordionIndicator;
41
+ const jsx_runtime_1 = require("react/jsx-runtime");
42
+ const React = __importStar(require("react"));
43
+ const react_native_1 = require("react-native");
44
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
45
+ const zkit_tools_1 = require("zkit-tools");
46
+ const useTheme_1 = require("../../theme/useTheme");
47
+ const Text_1 = require("../Text");
48
+ const DEFAULT_DURATION = 220;
49
+ const DEFAULT_EASING = react_native_reanimated_1.Easing.out(react_native_reanimated_1.Easing.cubic);
50
+ const PRESS_IN_DURATION = 90;
51
+ const PRESS_OUT_DURATION = 140;
52
+ const SEMANTIC_COLORS = {
53
+ danger: '#DC2626',
54
+ error: '#DC2626',
55
+ info: '#2563EB',
56
+ success: '#16A34A',
57
+ warn: '#D97706',
58
+ warning: '#D97706',
59
+ };
60
+ const SIZE_TOKENS = {
61
+ sm: {
62
+ itemGap: 8,
63
+ itemRadius: 12,
64
+ triggerMinHeight: 44,
65
+ triggerPaddingHorizontal: 12,
66
+ triggerPaddingVertical: 10,
67
+ triggerGap: 8,
68
+ titleFontSize: 14,
69
+ titleLineHeight: 19,
70
+ descriptionFontSize: 12,
71
+ descriptionLineHeight: 17,
72
+ contentPaddingHorizontal: 12,
73
+ contentPaddingTop: 8,
74
+ contentPaddingBottom: 12,
75
+ contentOffset: 4,
76
+ indicatorSize: 20,
77
+ indicatorStrokeWidth: 2,
78
+ },
79
+ md: {
80
+ itemGap: 10,
81
+ itemRadius: 14,
82
+ triggerMinHeight: 46,
83
+ triggerPaddingHorizontal: 14,
84
+ triggerPaddingVertical: 12,
85
+ triggerGap: 10,
86
+ titleFontSize: 15,
87
+ titleLineHeight: 21,
88
+ descriptionFontSize: 13,
89
+ descriptionLineHeight: 18,
90
+ contentPaddingHorizontal: 14,
91
+ contentPaddingTop: 10,
92
+ contentPaddingBottom: 14,
93
+ contentOffset: 5,
94
+ indicatorSize: 22,
95
+ indicatorStrokeWidth: 2,
96
+ },
97
+ lg: {
98
+ itemGap: 12,
99
+ itemRadius: 16,
100
+ triggerMinHeight: 52,
101
+ triggerPaddingHorizontal: 16,
102
+ triggerPaddingVertical: 14,
103
+ triggerGap: 12,
104
+ titleFontSize: 16,
105
+ titleLineHeight: 23,
106
+ descriptionFontSize: 14,
107
+ descriptionLineHeight: 20,
108
+ contentPaddingHorizontal: 16,
109
+ contentPaddingTop: 12,
110
+ contentPaddingBottom: 16,
111
+ contentOffset: 6,
112
+ indicatorSize: 24,
113
+ indicatorStrokeWidth: 2.25,
114
+ },
115
+ };
116
+ const AccordionContext = React.createContext(null);
117
+ const AccordionItemContext = React.createContext(null);
118
+ function sameValue(a, b) {
119
+ return Object.is(a, b) || a === b;
120
+ }
121
+ function hasValue(values, value) {
122
+ return values.some((item) => sameValue(item, value));
123
+ }
124
+ function uniqueValues(values) {
125
+ const next = [];
126
+ for (const value of values) {
127
+ if (!hasValue(next, value))
128
+ next.push(value);
129
+ }
130
+ return next;
131
+ }
132
+ function areValuesEqual(a, b) {
133
+ if (a.length !== b.length)
134
+ return false;
135
+ for (let i = 0; i < a.length; i += 1) {
136
+ if (!sameValue(a[i], b[i]))
137
+ return false;
138
+ }
139
+ return true;
140
+ }
141
+ function normalizePropValues(type, value) {
142
+ if (type === 'multiple') {
143
+ return Array.isArray(value) ? uniqueValues(value) : [];
144
+ }
145
+ if (value == null || Array.isArray(value))
146
+ return [];
147
+ return [value];
148
+ }
149
+ function getNextValues(current, value, open, type, collapsible) {
150
+ const isOpen = hasValue(current, value);
151
+ if (type === 'single') {
152
+ if (open)
153
+ return isOpen ? current.slice() : [value];
154
+ if (!isOpen)
155
+ return current.slice();
156
+ return collapsible ? [] : current.slice();
157
+ }
158
+ if (open)
159
+ return isOpen ? current.slice() : [...current, value];
160
+ return isOpen ? current.filter((item) => !sameValue(item, value)) : current.slice();
161
+ }
162
+ function resolveDuration(duration) {
163
+ if (duration == null || !Number.isFinite(duration))
164
+ return DEFAULT_DURATION;
165
+ return Math.max(0, duration);
166
+ }
167
+ function resolveAnimation(animation) {
168
+ var _a, _b;
169
+ const duration = animation === false ? 0 : resolveDuration(animation === null || animation === void 0 ? void 0 : animation.duration);
170
+ const easing = animation === false ? DEFAULT_EASING : (_a = animation === null || animation === void 0 ? void 0 : animation.easing) !== null && _a !== void 0 ? _a : DEFAULT_EASING;
171
+ const reduceMotion = animation === false ? react_native_reanimated_1.ReduceMotion.Always : (_b = animation === null || animation === void 0 ? void 0 : animation.reduceMotion) !== null && _b !== void 0 ? _b : react_native_reanimated_1.ReduceMotion.System;
172
+ return {
173
+ duration,
174
+ easing,
175
+ timing: {
176
+ duration,
177
+ easing,
178
+ reduceMotion,
179
+ },
180
+ };
181
+ }
182
+ function resolveMetrics(size) {
183
+ var _a;
184
+ const token = (_a = SIZE_TOKENS[size]) !== null && _a !== void 0 ? _a : SIZE_TOKENS.md;
185
+ return {
186
+ itemGap: (0, zkit_tools_1.wp)(token.itemGap),
187
+ itemRadius: (0, zkit_tools_1.wp)(token.itemRadius),
188
+ triggerMinHeight: (0, zkit_tools_1.wp)(token.triggerMinHeight),
189
+ triggerPaddingHorizontal: (0, zkit_tools_1.wp)(token.triggerPaddingHorizontal),
190
+ triggerPaddingVertical: (0, zkit_tools_1.wp)(token.triggerPaddingVertical),
191
+ triggerGap: (0, zkit_tools_1.wp)(token.triggerGap),
192
+ titleFontSize: (0, zkit_tools_1.wp)(token.titleFontSize),
193
+ titleLineHeight: (0, zkit_tools_1.wp)(token.titleLineHeight),
194
+ descriptionFontSize: (0, zkit_tools_1.wp)(token.descriptionFontSize),
195
+ descriptionLineHeight: (0, zkit_tools_1.wp)(token.descriptionLineHeight),
196
+ contentPaddingHorizontal: (0, zkit_tools_1.wp)(token.contentPaddingHorizontal),
197
+ contentPaddingTop: (0, zkit_tools_1.wp)(token.contentPaddingTop),
198
+ contentPaddingBottom: (0, zkit_tools_1.wp)(token.contentPaddingBottom),
199
+ contentOffset: (0, zkit_tools_1.wp)(token.contentOffset),
200
+ indicatorSize: (0, zkit_tools_1.wp)(token.indicatorSize),
201
+ indicatorStrokeWidth: (0, zkit_tools_1.wp)(token.indicatorStrokeWidth),
202
+ borderWidth: (0, zkit_tools_1.wp)(1),
203
+ };
204
+ }
205
+ function isProcessableColor(color) {
206
+ return (0, react_native_1.processColor)(color) != null;
207
+ }
208
+ function colorToRgba(color, alpha) {
209
+ const processed = (0, react_native_1.processColor)(color);
210
+ if (typeof processed !== 'number')
211
+ return undefined;
212
+ const normalized = processed >>> 0;
213
+ const r = (normalized >> 16) & 255;
214
+ const g = (normalized >> 8) & 255;
215
+ const b = normalized & 255;
216
+ const a = Math.max(0, Math.min(1, alpha));
217
+ return `rgba(${r},${g},${b},${a})`;
218
+ }
219
+ function resolveColorToken(input, fallback, theme) {
220
+ var _a;
221
+ if (input == null)
222
+ return fallback;
223
+ const key = input.trim();
224
+ if (!key)
225
+ return fallback;
226
+ const resolved = key === 'primary'
227
+ ? theme.colors.primary
228
+ : key === 'onPrimary'
229
+ ? theme.colors.onPrimary
230
+ : key === 'secondary' || key === 'neutral'
231
+ ? theme.colors.secondary
232
+ : key === 'onSecondary'
233
+ ? theme.colors.onSecondary
234
+ : key === 'surface'
235
+ ? theme.colors.surface
236
+ : key === 'onSurface'
237
+ ? theme.colors.onSurface
238
+ : key === 'border'
239
+ ? theme.colors.border
240
+ : key === 'muted'
241
+ ? theme.colors.muted
242
+ : key === 'disabled'
243
+ ? theme.colors.disabled
244
+ : (_a = SEMANTIC_COLORS[key]) !== null && _a !== void 0 ? _a : key;
245
+ return isProcessableColor(resolved) ? resolved : fallback;
246
+ }
247
+ function resolveToneColor(tone, theme) {
248
+ if (tone === 'primary')
249
+ return theme.colors.primary;
250
+ if (tone === 'success')
251
+ return SEMANTIC_COLORS.success;
252
+ if (tone === 'warning')
253
+ return SEMANTIC_COLORS.warning;
254
+ if (tone === 'danger')
255
+ return SEMANTIC_COLORS.danger;
256
+ if (tone === 'info')
257
+ return SEMANTIC_COLORS.info;
258
+ return theme.colors.muted;
259
+ }
260
+ function resolveColors(variant, tone, color, theme) {
261
+ const accent = resolveColorToken(color, resolveToneColor(tone, theme), theme);
262
+ const accentSoft = colorToRgba(accent, 0.08);
263
+ const dividerSoft = colorToRgba(accent, 0.16);
264
+ if (variant === 'filled') {
265
+ return {
266
+ accent,
267
+ surface: tone === 'neutral' ? theme.colors.secondary : accentSoft !== null && accentSoft !== void 0 ? accentSoft : theme.colors.secondary,
268
+ border: 'transparent',
269
+ divider: dividerSoft !== null && dividerSoft !== void 0 ? dividerSoft : theme.colors.border,
270
+ title: theme.colors.onSurface,
271
+ description: theme.colors.muted,
272
+ disabled: theme.colors.disabled,
273
+ };
274
+ }
275
+ if (variant === 'plain') {
276
+ return {
277
+ accent,
278
+ surface: 'transparent',
279
+ border: 'transparent',
280
+ divider: theme.colors.border,
281
+ title: theme.colors.onSurface,
282
+ description: theme.colors.muted,
283
+ disabled: theme.colors.disabled,
284
+ };
285
+ }
286
+ return {
287
+ accent,
288
+ surface: theme.colors.surface,
289
+ border: theme.colors.border,
290
+ divider: theme.colors.border,
291
+ title: theme.colors.onSurface,
292
+ description: theme.colors.muted,
293
+ disabled: theme.colors.disabled,
294
+ };
295
+ }
296
+ function resolveSlot(slot, state) {
297
+ return typeof slot === 'function' ? slot(state) : slot;
298
+ }
299
+ function hasRenderableNode(node) {
300
+ return node !== null && node !== undefined && node !== false;
301
+ }
302
+ function isPrimitiveTextNode(node) {
303
+ return typeof node === 'string' || typeof node === 'number';
304
+ }
305
+ function sanitizeNativeId(input) {
306
+ return input.replace(/[^a-zA-Z0-9_-]/g, '');
307
+ }
308
+ function useAccordionContext() {
309
+ const ctx = React.useContext(AccordionContext);
310
+ if (!ctx) {
311
+ throw new Error('[zkit-ui] Accordion components must be wrapped in <Accordion />');
312
+ }
313
+ return ctx;
314
+ }
315
+ function useAccordionItemContext() {
316
+ const ctx = React.useContext(AccordionItemContext);
317
+ if (!ctx) {
318
+ throw new Error('[zkit-ui] AccordionTrigger/Content/Indicator must be wrapped in <AccordionItem />');
319
+ }
320
+ return ctx;
321
+ }
322
+ class AccordionStore {
323
+ constructor(initialValues) {
324
+ this.listeners = new Set();
325
+ this.subscribe = (listener) => {
326
+ this.listeners.add(listener);
327
+ return () => {
328
+ this.listeners.delete(listener);
329
+ };
330
+ };
331
+ this.getValues = () => this.values;
332
+ this.isOpen = (value) => hasValue(this.values, value);
333
+ this.setValues = (values) => {
334
+ const next = uniqueValues(values);
335
+ if (areValuesEqual(this.values, next))
336
+ return false;
337
+ this.values = next;
338
+ this.emit();
339
+ return true;
340
+ };
341
+ this.values = uniqueValues(initialValues);
342
+ }
343
+ emit() {
344
+ for (const listener of this.listeners)
345
+ listener();
346
+ }
347
+ }
348
+ function Accordion(props) {
349
+ var _a, _b;
350
+ const { children, disabled = false, variant = 'card', tone = 'neutral', size = 'md', color, animation, mountStrategy = 'eager', itemGap, itemStyle, style, ...viewProps } = props;
351
+ const theme = (0, useTheme_1.useTheme)();
352
+ const type = (_a = props.type) !== null && _a !== void 0 ? _a : 'single';
353
+ const collapsible = type === 'single' ? (_b = props.collapsible) !== null && _b !== void 0 ? _b : true : true;
354
+ const isControlled = props.value !== undefined;
355
+ const controlledValues = React.useMemo(() => (isControlled ? normalizePropValues(type, props.value) : []), [isControlled, props.value, type]);
356
+ const storeRef = React.useRef(null);
357
+ if (!storeRef.current) {
358
+ const initialValue = isControlled ? props.value : props.defaultValue;
359
+ storeRef.current = new AccordionStore(normalizePropValues(type, initialValue));
360
+ }
361
+ const store = storeRef.current;
362
+ const onChange = props.onChange;
363
+ React.useLayoutEffect(() => {
364
+ if (!isControlled)
365
+ return;
366
+ store.setValues(controlledValues);
367
+ }, [controlledValues, isControlled, store]);
368
+ React.useLayoutEffect(() => {
369
+ if (isControlled || type !== 'single')
370
+ return;
371
+ const current = store.getValues();
372
+ if (current.length > 1)
373
+ store.setValues(current.slice(0, 1));
374
+ }, [isControlled, store, type]);
375
+ const emitChange = React.useCallback((next) => {
376
+ var _a;
377
+ if (type === 'multiple') {
378
+ onChange === null || onChange === void 0 ? void 0 : onChange(next.slice());
379
+ return;
380
+ }
381
+ onChange === null || onChange === void 0 ? void 0 : onChange((_a = next[0]) !== null && _a !== void 0 ? _a : null);
382
+ }, [onChange, type]);
383
+ const setItemOpen = React.useCallback((value, open) => {
384
+ if (disabled)
385
+ return;
386
+ const current = store.getValues();
387
+ const next = getNextValues(current, value, open, type, collapsible);
388
+ if (areValuesEqual(current, next))
389
+ return;
390
+ if (!isControlled)
391
+ store.setValues(next);
392
+ emitChange(next);
393
+ }, [collapsible, disabled, emitChange, isControlled, store, type]);
394
+ const metrics = React.useMemo(() => {
395
+ const resolved = resolveMetrics(size);
396
+ return itemGap === undefined ? resolved : { ...resolved, itemGap };
397
+ }, [itemGap, size]);
398
+ const colors = React.useMemo(() => resolveColors(variant, tone, color, theme), [color, theme, tone, variant]);
399
+ const resolvedAnimation = React.useMemo(() => resolveAnimation(animation), [animation]);
400
+ const rootStyle = React.useMemo(() => [{ gap: metrics.itemGap }, style], [metrics.itemGap, style]);
401
+ const ctx = React.useMemo(() => ({
402
+ store,
403
+ type,
404
+ collapsible,
405
+ disabled,
406
+ variant,
407
+ size,
408
+ tone,
409
+ mountStrategy,
410
+ metrics,
411
+ colors,
412
+ animation: resolvedAnimation,
413
+ itemStyle,
414
+ setItemOpen,
415
+ }), [
416
+ store,
417
+ type,
418
+ collapsible,
419
+ disabled,
420
+ variant,
421
+ size,
422
+ tone,
423
+ mountStrategy,
424
+ metrics,
425
+ colors,
426
+ resolvedAnimation,
427
+ itemStyle,
428
+ setItemOpen,
429
+ ]);
430
+ return ((0, jsx_runtime_1.jsx)(AccordionContext.Provider, { value: ctx, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { ...viewProps, style: rootStyle, children: children }) }));
431
+ }
432
+ function AccordionItem({ value, disabled = false, style, children, accessibilityState, ...viewProps }) {
433
+ const accordion = useAccordionContext();
434
+ const reactId = React.useId();
435
+ const idBase = React.useMemo(() => `zkit-accordion-${sanitizeNativeId(reactId)}`, [reactId]);
436
+ const triggerId = `${idBase}-trigger`;
437
+ const contentId = `${idBase}-content`;
438
+ const getOpenSnapshot = React.useCallback(() => accordion.store.isOpen(value), [accordion.store, value]);
439
+ const open = React.useSyncExternalStore(accordion.store.subscribe, getOpenSnapshot, getOpenSnapshot);
440
+ const resolvedDisabled = accordion.disabled || disabled;
441
+ const openProgress = (0, react_native_reanimated_1.useSharedValue)(open ? 1 : 0);
442
+ React.useEffect(() => {
443
+ openProgress.value = (0, react_native_reanimated_1.withTiming)(open ? 1 : 0, accordion.animation.timing);
444
+ }, [accordion.animation, open, openProgress]);
445
+ const setOpen = React.useCallback((nextOpen) => {
446
+ if (resolvedDisabled)
447
+ return;
448
+ accordion.setItemOpen(value, nextOpen);
449
+ }, [accordion, resolvedDisabled, value]);
450
+ const toggle = React.useCallback(() => {
451
+ setOpen(!open);
452
+ }, [open, setOpen]);
453
+ const itemCtx = React.useMemo(() => ({
454
+ open,
455
+ disabled: resolvedDisabled,
456
+ value,
457
+ toggle,
458
+ setOpen,
459
+ openProgress,
460
+ metrics: accordion.metrics,
461
+ colors: accordion.colors,
462
+ animation: accordion.animation,
463
+ mountStrategy: accordion.mountStrategy,
464
+ triggerId,
465
+ contentId,
466
+ }), [
467
+ accordion.animation,
468
+ accordion.colors,
469
+ accordion.metrics,
470
+ accordion.mountStrategy,
471
+ contentId,
472
+ open,
473
+ openProgress,
474
+ resolvedDisabled,
475
+ setOpen,
476
+ toggle,
477
+ triggerId,
478
+ value,
479
+ ]);
480
+ const itemStyle = React.useMemo(() => [
481
+ styles.item,
482
+ {
483
+ backgroundColor: accordion.colors.surface,
484
+ borderColor: accordion.colors.border,
485
+ borderRadius: accordion.metrics.itemRadius,
486
+ borderWidth: accordion.variant === 'plain' ? 0 : accordion.metrics.borderWidth,
487
+ },
488
+ accordion.itemStyle,
489
+ style,
490
+ ], [
491
+ accordion.colors.border,
492
+ accordion.colors.surface,
493
+ accordion.itemStyle,
494
+ accordion.metrics.borderWidth,
495
+ accordion.metrics.itemRadius,
496
+ accordion.variant,
497
+ style,
498
+ ]);
499
+ return ((0, jsx_runtime_1.jsx)(AccordionItemContext.Provider, { value: itemCtx, children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { ...viewProps, accessibilityState: {
500
+ ...accessibilityState,
501
+ disabled: resolvedDisabled,
502
+ expanded: open,
503
+ }, style: itemStyle, children: children }) }));
504
+ }
505
+ function AccordionTrigger({ children, title, description, leading, trailing, indicator, disabled: disabledProp = false, pressEffect = 'opacity', titleNumberOfLines = 1, descriptionNumberOfLines = 2, style, contentStyle, textContainerStyle, titleStyle, descriptionStyle, onPress, onPressIn, onPressOut, accessibilityRole, accessibilityState, nativeID, ...pressableProps }) {
506
+ const item = useAccordionItemContext();
507
+ const disabled = item.disabled || disabledProp;
508
+ const pressSv = (0, react_native_reanimated_1.useSharedValue)(0);
509
+ const state = React.useMemo(() => ({
510
+ open: item.open,
511
+ disabled,
512
+ value: item.value,
513
+ toggle: item.toggle,
514
+ setOpen: item.setOpen,
515
+ }), [disabled, item.open, item.setOpen, item.toggle, item.value]);
516
+ const leadingNode = resolveSlot(leading, state);
517
+ const trailingNode = resolveSlot(trailing, state);
518
+ const indicatorNode = indicator === false
519
+ ? null
520
+ : resolveSlot(indicator === undefined ? (0, jsx_runtime_1.jsx)(AccordionIndicator, {}) : indicator, state);
521
+ const childNode = resolveSlot(children, state);
522
+ const titleNode = resolveSlot(title, state);
523
+ const descriptionNode = resolveSlot(description, state);
524
+ const hasCustomChildren = hasRenderableNode(childNode);
525
+ const pressInTiming = React.useMemo(() => ({
526
+ duration: PRESS_IN_DURATION,
527
+ easing: item.animation.easing,
528
+ reduceMotion: react_native_reanimated_1.ReduceMotion.System,
529
+ }), [item.animation.easing]);
530
+ const pressOutTiming = React.useMemo(() => ({
531
+ duration: PRESS_OUT_DURATION,
532
+ easing: item.animation.easing,
533
+ reduceMotion: react_native_reanimated_1.ReduceMotion.System,
534
+ }), [item.animation.easing]);
535
+ React.useEffect(() => {
536
+ if (!disabled)
537
+ return;
538
+ pressSv.value = (0, react_native_reanimated_1.withTiming)(0, pressOutTiming);
539
+ }, [disabled, pressOutTiming, pressSv]);
540
+ const animatedContentStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
541
+ const opacityEnabled = pressEffect === 'opacity' || pressEffect === 'scale-opacity';
542
+ const scaleEnabled = pressEffect === 'scale' || pressEffect === 'scale-opacity';
543
+ const opacity = disabled ? 0.52 : opacityEnabled ? (0, react_native_reanimated_1.interpolate)(pressSv.value, [0, 1], [1, 0.86]) : 1;
544
+ const scale = scaleEnabled ? (0, react_native_reanimated_1.interpolate)(pressSv.value, [0, 1], [1, 0.992]) : 1;
545
+ return {
546
+ opacity,
547
+ transform: [{ scale }],
548
+ };
549
+ }, [disabled, pressEffect]);
550
+ const renderedTitle = isPrimitiveTextNode(titleNode) ? ((0, jsx_runtime_1.jsx)(Text_1.Text, { numberOfLines: titleNumberOfLines, style: [
551
+ styles.title,
552
+ {
553
+ color: disabled ? item.colors.disabled : item.colors.title,
554
+ fontSize: item.metrics.titleFontSize,
555
+ lineHeight: item.metrics.titleLineHeight,
556
+ },
557
+ titleStyle,
558
+ ], children: titleNode })) : (titleNode);
559
+ const renderedDescription = isPrimitiveTextNode(descriptionNode) ? ((0, jsx_runtime_1.jsx)(Text_1.Text, { numberOfLines: descriptionNumberOfLines, style: [
560
+ styles.description,
561
+ {
562
+ color: disabled ? item.colors.disabled : item.colors.description,
563
+ fontSize: item.metrics.descriptionFontSize,
564
+ lineHeight: item.metrics.descriptionLineHeight,
565
+ },
566
+ descriptionStyle,
567
+ ], children: descriptionNode })) : (descriptionNode);
568
+ const renderedMain = hasCustomChildren ? (childNode) : ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [styles.textStack, textContainerStyle], children: [hasRenderableNode(renderedTitle) ? renderedTitle : null, hasRenderableNode(renderedDescription) ? renderedDescription : null] }));
569
+ const resolvedStyle = React.useCallback((stateArg) => {
570
+ const userStyle = typeof style === 'function' ? style(stateArg) : style;
571
+ return [
572
+ styles.trigger,
573
+ {
574
+ minHeight: item.metrics.triggerMinHeight,
575
+ paddingHorizontal: item.metrics.triggerPaddingHorizontal,
576
+ paddingVertical: item.metrics.triggerPaddingVertical,
577
+ borderBottomColor: item.open ? item.colors.divider : 'transparent',
578
+ borderBottomWidth: item.metrics.borderWidth,
579
+ },
580
+ userStyle,
581
+ ];
582
+ }, [
583
+ item.colors.divider,
584
+ item.metrics.borderWidth,
585
+ item.metrics.triggerMinHeight,
586
+ item.metrics.triggerPaddingHorizontal,
587
+ item.metrics.triggerPaddingVertical,
588
+ item.open,
589
+ style,
590
+ ]);
591
+ const handlePress = React.useCallback((event) => {
592
+ if (disabled)
593
+ return;
594
+ item.toggle();
595
+ onPress === null || onPress === void 0 ? void 0 : onPress(event);
596
+ }, [disabled, item, onPress]);
597
+ const handlePressIn = React.useCallback((event) => {
598
+ if (!disabled && pressEffect !== 'none') {
599
+ pressSv.value = (0, react_native_reanimated_1.withTiming)(1, pressInTiming);
600
+ }
601
+ onPressIn === null || onPressIn === void 0 ? void 0 : onPressIn(event);
602
+ }, [disabled, onPressIn, pressEffect, pressInTiming, pressSv]);
603
+ const handlePressOut = React.useCallback((event) => {
604
+ pressSv.value = (0, react_native_reanimated_1.withTiming)(0, pressOutTiming);
605
+ onPressOut === null || onPressOut === void 0 ? void 0 : onPressOut(event);
606
+ }, [onPressOut, pressOutTiming, pressSv]);
607
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { ...pressableProps, nativeID: nativeID !== null && nativeID !== void 0 ? nativeID : item.triggerId, accessibilityRole: accessibilityRole !== null && accessibilityRole !== void 0 ? accessibilityRole : 'button', accessibilityState: {
608
+ ...accessibilityState,
609
+ expanded: item.open,
610
+ disabled,
611
+ }, disabled: disabled, onPress: handlePress, onPressIn: handlePressIn, onPressOut: handlePressOut, style: resolvedStyle, children: (0, jsx_runtime_1.jsxs)(react_native_reanimated_1.default.View, { style: [
612
+ styles.triggerContent,
613
+ { gap: item.metrics.triggerGap },
614
+ animatedContentStyle,
615
+ contentStyle,
616
+ ], children: [hasRenderableNode(leadingNode) ? (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.leading, children: leadingNode }) : null, (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.main, children: renderedMain }), hasRenderableNode(trailingNode) ? (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.trailing, children: trailingNode }) : null, hasRenderableNode(indicatorNode) ? (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.indicatorSlot, children: indicatorNode }) : null] }) }));
617
+ }
618
+ function AccordionContent({ children, mountStrategy, style, containerStyle, nativeID, accessibilityElementsHidden, importantForAccessibility, onLayout, ...viewProps }) {
619
+ const item = useAccordionItemContext();
620
+ const strategy = mountStrategy !== null && mountStrategy !== void 0 ? mountStrategy : item.mountStrategy;
621
+ const measuredHeight = (0, react_native_reanimated_1.useSharedValue)(0);
622
+ const lastMeasuredHeightRef = React.useRef(0);
623
+ const [hasOpened, setHasOpened] = React.useState(item.open);
624
+ const [renderForExit, setRenderForExit] = React.useState(strategy === 'eager' || strategy === 'lazy' || item.open);
625
+ React.useEffect(() => {
626
+ if (item.open) {
627
+ setHasOpened(true);
628
+ setRenderForExit(true);
629
+ return undefined;
630
+ }
631
+ if (strategy === 'eager' || strategy === 'lazy') {
632
+ setRenderForExit(true);
633
+ return undefined;
634
+ }
635
+ if (item.animation.duration <= 0) {
636
+ setRenderForExit(false);
637
+ return undefined;
638
+ }
639
+ let cancelled = false;
640
+ const timeout = setTimeout(() => {
641
+ if (!cancelled)
642
+ setRenderForExit(false);
643
+ }, item.animation.duration);
644
+ return () => {
645
+ cancelled = true;
646
+ clearTimeout(timeout);
647
+ };
648
+ }, [item.animation.duration, item.open, strategy]);
649
+ const shouldRender = strategy === 'eager' ||
650
+ item.open ||
651
+ (strategy === 'lazy' && hasOpened) ||
652
+ (strategy === 'unmountOnExit' && renderForExit);
653
+ const animatedContainerStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
654
+ const progress = item.openProgress.value;
655
+ return {
656
+ height: measuredHeight.value * progress,
657
+ opacity: (0, react_native_reanimated_1.interpolate)(progress, [0, 0.2, 1], [0, 1, 1]),
658
+ };
659
+ }, []);
660
+ const animatedInnerStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
661
+ return {
662
+ transform: [
663
+ {
664
+ translateY: (0, react_native_reanimated_1.interpolate)(item.openProgress.value, [0, 1], [-item.metrics.contentOffset, 0]),
665
+ },
666
+ ],
667
+ };
668
+ }, [item.metrics.contentOffset]);
669
+ const handleLayout = React.useCallback((event) => {
670
+ const nextHeight = event.nativeEvent.layout.height;
671
+ const prevHeight = lastMeasuredHeightRef.current;
672
+ lastMeasuredHeightRef.current = nextHeight;
673
+ if (item.open && prevHeight > 0 && item.animation.duration > 0) {
674
+ measuredHeight.value = (0, react_native_reanimated_1.withTiming)(nextHeight, item.animation.timing);
675
+ }
676
+ else {
677
+ measuredHeight.value = nextHeight;
678
+ }
679
+ onLayout === null || onLayout === void 0 ? void 0 : onLayout(event);
680
+ }, [item.animation.duration, item.animation.timing, item.open, measuredHeight, onLayout]);
681
+ React.useEffect(() => {
682
+ if (shouldRender)
683
+ return;
684
+ lastMeasuredHeightRef.current = 0;
685
+ measuredHeight.value = 0;
686
+ }, [measuredHeight, shouldRender]);
687
+ if (!shouldRender)
688
+ return null;
689
+ const hidden = !item.open;
690
+ return ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: item.open ? 'auto' : 'none', style: [styles.contentContainer, animatedContainerStyle, containerStyle], children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [styles.contentInner, animatedInnerStyle], children: (0, jsx_runtime_1.jsx)(react_native_1.View, { ...viewProps, collapsable: false, nativeID: nativeID !== null && nativeID !== void 0 ? nativeID : item.contentId, accessibilityElementsHidden: accessibilityElementsHidden !== null && accessibilityElementsHidden !== void 0 ? accessibilityElementsHidden : hidden, importantForAccessibility: importantForAccessibility !== null && importantForAccessibility !== void 0 ? importantForAccessibility : (hidden ? 'no-hide-descendants' : 'auto'), onLayout: handleLayout, style: [
691
+ styles.content,
692
+ {
693
+ paddingBottom: item.metrics.contentPaddingBottom,
694
+ paddingHorizontal: item.metrics.contentPaddingHorizontal,
695
+ paddingTop: item.metrics.contentPaddingTop,
696
+ },
697
+ style,
698
+ ], children: children }) }) }));
699
+ }
700
+ function AccordionIndicator({ children, style, color, size, strokeWidth, closedRotation = -90, openRotation = 0, }) {
701
+ const item = useAccordionItemContext();
702
+ const resolvedSize = size !== null && size !== void 0 ? size : item.metrics.indicatorSize;
703
+ const resolvedStrokeWidth = strokeWidth !== null && strokeWidth !== void 0 ? strokeWidth : item.metrics.indicatorStrokeWidth;
704
+ const chevronSize = Math.max((0, zkit_tools_1.wp)(6), Math.round(resolvedSize * 0.34));
705
+ const resolvedColor = color !== null && color !== void 0 ? color : (item.disabled ? item.colors.disabled : item.colors.accent);
706
+ const animatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
707
+ const deg = closedRotation + (openRotation - closedRotation) * item.openProgress.value;
708
+ return {
709
+ transform: [{ rotateZ: `${deg}deg` }],
710
+ };
711
+ }, [closedRotation, openRotation]);
712
+ return ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: "none", style: [styles.indicator, { width: resolvedSize, height: resolvedSize }, animatedStyle, style], children: children !== null && children !== void 0 ? children : ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: [
713
+ styles.chevron,
714
+ {
715
+ width: chevronSize,
716
+ height: chevronSize,
717
+ borderRightWidth: resolvedStrokeWidth,
718
+ borderBottomWidth: resolvedStrokeWidth,
719
+ borderRightColor: resolvedColor,
720
+ borderBottomColor: resolvedColor,
721
+ },
722
+ ] })) }));
723
+ }
724
+ const styles = react_native_1.StyleSheet.create({
725
+ item: {
726
+ overflow: 'hidden',
727
+ },
728
+ trigger: {
729
+ justifyContent: 'center',
730
+ },
731
+ triggerContent: {
732
+ alignItems: 'center',
733
+ flexDirection: 'row',
734
+ },
735
+ leading: {
736
+ flexShrink: 0,
737
+ },
738
+ main: {
739
+ flex: 1,
740
+ minWidth: 0,
741
+ },
742
+ trailing: {
743
+ flexShrink: 0,
744
+ },
745
+ indicatorSlot: {
746
+ flexShrink: 0,
747
+ },
748
+ textStack: {
749
+ flexShrink: 1,
750
+ minWidth: 0,
751
+ },
752
+ title: {
753
+ fontWeight: '600',
754
+ includeFontPadding: false,
755
+ },
756
+ description: {
757
+ includeFontPadding: false,
758
+ marginTop: (0, zkit_tools_1.wp)(2),
759
+ },
760
+ contentContainer: {
761
+ overflow: 'hidden',
762
+ },
763
+ contentInner: {
764
+ left: 0,
765
+ position: 'absolute',
766
+ right: 0,
767
+ top: 0,
768
+ },
769
+ content: {},
770
+ indicator: {
771
+ alignItems: 'center',
772
+ justifyContent: 'center',
773
+ },
774
+ chevron: {
775
+ transform: [{ rotate: '45deg' }],
776
+ },
777
+ });