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,694 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Checkbox = void 0;
40
+ exports.CheckboxIndicator = CheckboxIndicator;
41
+ exports.CheckboxGroup = CheckboxGroup;
42
+ const jsx_runtime_1 = require("react/jsx-runtime");
43
+ const React = __importStar(require("react"));
44
+ const react_native_1 = require("react-native");
45
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
46
+ const zkit_tools_1 = require("zkit-tools");
47
+ const check_svg_1 = __importDefault(require("../../assets/icons/check.svg"));
48
+ const useTheme_1 = require("../../theme/useTheme");
49
+ const Text_1 = require("../Text");
50
+ const CheckboxIndicatorContext = React.createContext(null);
51
+ const noopSubscribe = () => () => { };
52
+ class CheckboxGroupStore {
53
+ constructor(initialValues) {
54
+ this.listeners = new Set();
55
+ this.subscribe = (listener) => {
56
+ this.listeners.add(listener);
57
+ return () => {
58
+ this.listeners.delete(listener);
59
+ };
60
+ };
61
+ this.has = (value) => this.values.has(value);
62
+ this.getToggledValues = (value) => {
63
+ const next = new Set(this.values);
64
+ if (next.has(value))
65
+ next.delete(value);
66
+ else
67
+ next.add(value);
68
+ return Array.from(next);
69
+ };
70
+ this.setValues = (values) => {
71
+ const next = new Set(values);
72
+ if (next.size === this.values.size) {
73
+ let same = true;
74
+ for (const value of next) {
75
+ if (!this.values.has(value)) {
76
+ same = false;
77
+ break;
78
+ }
79
+ }
80
+ if (same)
81
+ return false;
82
+ }
83
+ this.values = next;
84
+ this.emit();
85
+ return true;
86
+ };
87
+ this.values = new Set(initialValues);
88
+ }
89
+ emit() {
90
+ for (const listener of this.listeners)
91
+ listener();
92
+ }
93
+ }
94
+ const CheckboxGroupContext = React.createContext(null);
95
+ const SEMANTIC_COLORS = {
96
+ danger: '#DC2626',
97
+ error: '#DC2626',
98
+ info: '#2563EB',
99
+ success: '#16A34A',
100
+ warn: '#D97706',
101
+ warning: '#D97706',
102
+ };
103
+ const SIZE_TOKENS = {
104
+ sm: {
105
+ indicatorSize: 18,
106
+ indicatorRadius: 4,
107
+ indicatorBorderWidth: 1.5,
108
+ indicatorIconSize: 12,
109
+ gap: 8,
110
+ },
111
+ md: {
112
+ indicatorSize: 20,
113
+ indicatorRadius: 5,
114
+ indicatorBorderWidth: 1.5,
115
+ indicatorIconSize: 14,
116
+ gap: 10,
117
+ },
118
+ lg: {
119
+ indicatorSize: 24,
120
+ indicatorRadius: 6,
121
+ indicatorBorderWidth: 1.5,
122
+ indicatorIconSize: 16,
123
+ gap: 12,
124
+ },
125
+ };
126
+ const DISABLED_OPACITY = 0.48;
127
+ const PRESSED_OPACITY = 0.86;
128
+ const PRESSED_SCALE = 0.965;
129
+ const VALUE_TIMING_DURATION = 170;
130
+ const PRESS_IN_DURATION = 90;
131
+ const PRESS_OUT_DURATION = 140;
132
+ const FOCUS_DURATION = 120;
133
+ function useCheckboxIndicatorContext() {
134
+ const context = React.useContext(CheckboxIndicatorContext);
135
+ if (!context) {
136
+ throw new Error('[zkit-ui] CheckboxIndicator must be rendered inside <Checkbox />.');
137
+ }
138
+ return context;
139
+ }
140
+ function isProcessableColor(color) {
141
+ return (0, react_native_1.processColor)(color) != null;
142
+ }
143
+ function colorToRgba(color, alpha) {
144
+ const processed = (0, react_native_1.processColor)(color);
145
+ if (typeof processed !== 'number')
146
+ return undefined;
147
+ const normalized = processed >>> 0;
148
+ const r = (normalized >> 16) & 255;
149
+ const g = (normalized >> 8) & 255;
150
+ const b = normalized & 255;
151
+ const a = Math.max(0, Math.min(1, alpha));
152
+ return `rgba(${r},${g},${b},${a})`;
153
+ }
154
+ function resolveColorToken(input, fallback, theme) {
155
+ var _a;
156
+ if (input == null)
157
+ return fallback;
158
+ const key = input.trim();
159
+ if (!key)
160
+ return fallback;
161
+ const resolved = key === 'default' || key === 'neutral' || key === 'onSurface'
162
+ ? theme.colors.onSurface
163
+ : key === 'primary'
164
+ ? theme.colors.primary
165
+ : key === 'onPrimary' || key === 'inverse'
166
+ ? theme.colors.onPrimary
167
+ : key === 'secondary'
168
+ ? theme.colors.secondary
169
+ : key === 'onSecondary'
170
+ ? theme.colors.onSecondary
171
+ : key === 'surface'
172
+ ? theme.colors.surface
173
+ : key === 'border'
174
+ ? theme.colors.border
175
+ : key === 'muted'
176
+ ? theme.colors.muted
177
+ : key === 'disabled' || key === 'subtle'
178
+ ? theme.colors.disabled
179
+ : (_a = SEMANTIC_COLORS[key]) !== null && _a !== void 0 ? _a : key;
180
+ return isProcessableColor(resolved) ? resolved : fallback;
181
+ }
182
+ function resolveTonePalette(tone, theme) {
183
+ if (tone === 'neutral') {
184
+ return {
185
+ accent: theme.colors.onSurface,
186
+ onAccent: theme.colors.surface,
187
+ };
188
+ }
189
+ if (tone === 'success') {
190
+ return {
191
+ accent: SEMANTIC_COLORS.success,
192
+ onAccent: '#FFFFFF',
193
+ };
194
+ }
195
+ if (tone === 'warning') {
196
+ return {
197
+ accent: SEMANTIC_COLORS.warning,
198
+ onAccent: '#FFFFFF',
199
+ };
200
+ }
201
+ if (tone === 'danger') {
202
+ return {
203
+ accent: SEMANTIC_COLORS.danger,
204
+ onAccent: '#FFFFFF',
205
+ };
206
+ }
207
+ if (tone === 'info') {
208
+ return {
209
+ accent: SEMANTIC_COLORS.info,
210
+ onAccent: '#FFFFFF',
211
+ };
212
+ }
213
+ return {
214
+ accent: theme.colors.primary,
215
+ onAccent: theme.colors.onPrimary,
216
+ };
217
+ }
218
+ function resolveVariantColors(variant, accent, onAccent, colors, theme, scheme) {
219
+ var _a, _b, _c;
220
+ const softAlpha = scheme === 'dark' ? 0.24 : 0.14;
221
+ const fallbackSoftBackground = (_a = colorToRgba(accent, softAlpha)) !== null && _a !== void 0 ? _a : theme.colors.secondary;
222
+ const fallbackUncheckedBorder = (_b = colorToRgba(theme.colors.onSurface, scheme === 'dark' ? 0.28 : 0.18)) !== null && _b !== void 0 ? _b : theme.colors.border;
223
+ const checkedBackground = variant === 'solid'
224
+ ? accent
225
+ : variant === 'soft'
226
+ ? fallbackSoftBackground
227
+ : theme.colors.surface;
228
+ const checkedIndicator = variant === 'solid' ? onAccent : accent;
229
+ const resolvedCheckedBackground = resolveColorToken(colors === null || colors === void 0 ? void 0 : colors.checkedBackground, checkedBackground, theme);
230
+ const resolvedCheckedBorder = resolveColorToken(colors === null || colors === void 0 ? void 0 : colors.checkedBorder, accent, theme);
231
+ const resolvedCheckedIndicator = resolveColorToken(colors === null || colors === void 0 ? void 0 : colors.checkedIndicator, checkedIndicator, theme);
232
+ return {
233
+ checkedBackground: resolvedCheckedBackground,
234
+ checkedBorder: resolvedCheckedBorder,
235
+ checkedIndicator: resolvedCheckedIndicator,
236
+ indeterminateBackground: resolveColorToken(colors === null || colors === void 0 ? void 0 : colors.indeterminateBackground, resolvedCheckedBackground, theme),
237
+ indeterminateBorder: resolveColorToken(colors === null || colors === void 0 ? void 0 : colors.indeterminateBorder, resolvedCheckedBorder, theme),
238
+ indeterminateIndicator: resolveColorToken(colors === null || colors === void 0 ? void 0 : colors.indeterminateIndicator, resolvedCheckedIndicator, theme),
239
+ uncheckedBackground: resolveColorToken(colors === null || colors === void 0 ? void 0 : colors.uncheckedBackground, theme.colors.surface, theme),
240
+ uncheckedBorder: resolveColorToken(colors === null || colors === void 0 ? void 0 : colors.uncheckedBorder, fallbackUncheckedBorder, theme),
241
+ focusRing: resolveColorToken(colors === null || colors === void 0 ? void 0 : colors.focusRing, (_c = colorToRgba(accent, scheme === 'dark' ? 0.36 : 0.28)) !== null && _c !== void 0 ? _c : accent, theme),
242
+ };
243
+ }
244
+ function resolveCheckboxMetrics(size, shape, layout) {
245
+ var _a;
246
+ const token = (_a = SIZE_TOKENS[size]) !== null && _a !== void 0 ? _a : SIZE_TOKENS.md;
247
+ const indicatorSize = resolvePositiveNumber(layout === null || layout === void 0 ? void 0 : layout.indicatorSize, (0, zkit_tools_1.wp)(token.indicatorSize));
248
+ const fallbackRadius = shape === 'circle' ? indicatorSize / 2 : shape === 'square' ? 0 : (0, zkit_tools_1.wp)(token.indicatorRadius);
249
+ return {
250
+ indicatorSize,
251
+ indicatorRadius: resolveNonNegativeNumber(layout === null || layout === void 0 ? void 0 : layout.indicatorRadius, fallbackRadius),
252
+ indicatorBorderWidth: resolvePositiveNumber(layout === null || layout === void 0 ? void 0 : layout.indicatorBorderWidth, (0, zkit_tools_1.wp)(token.indicatorBorderWidth)),
253
+ indicatorIconSize: resolvePositiveNumber(layout === null || layout === void 0 ? void 0 : layout.indicatorIconSize, (0, zkit_tools_1.wp)(token.indicatorIconSize)),
254
+ gap: resolveNonNegativeNumber(layout === null || layout === void 0 ? void 0 : layout.gap, (0, zkit_tools_1.wp)(token.gap)),
255
+ minTouchTarget: resolvePositiveNumber(layout === null || layout === void 0 ? void 0 : layout.minTouchTarget, (0, zkit_tools_1.wp)(44)),
256
+ focusRingWidth: resolvePositiveNumber(layout === null || layout === void 0 ? void 0 : layout.focusRingWidth, (0, zkit_tools_1.wp)(2)),
257
+ focusRingOffset: resolveNonNegativeNumber(layout === null || layout === void 0 ? void 0 : layout.focusRingOffset, (0, zkit_tools_1.wp)(3)),
258
+ };
259
+ }
260
+ function resolvePositiveNumber(value, fallback) {
261
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback;
262
+ }
263
+ function resolveNonNegativeNumber(value, fallback) {
264
+ return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? value : fallback;
265
+ }
266
+ function resolveDuration(duration) {
267
+ if (duration == null || !Number.isFinite(duration))
268
+ return VALUE_TIMING_DURATION;
269
+ return Math.max(0, duration);
270
+ }
271
+ function toTimingConfig(duration) {
272
+ return {
273
+ duration,
274
+ easing: react_native_reanimated_1.Easing.out(react_native_reanimated_1.Easing.cubic),
275
+ reduceMotion: react_native_reanimated_1.ReduceMotion.System,
276
+ };
277
+ }
278
+ function resolveHitSlop(width, height, minTouchTarget) {
279
+ const vertical = Math.max(0, (minTouchTarget - height) / 2);
280
+ const horizontal = Math.max(0, (minTouchTarget - width) / 2);
281
+ if (vertical === 0 && horizontal === 0)
282
+ return undefined;
283
+ return {
284
+ top: vertical,
285
+ bottom: vertical,
286
+ left: horizontal,
287
+ right: horizontal,
288
+ };
289
+ }
290
+ function resolveWebCursorStyle(disabled) {
291
+ if (react_native_1.Platform.OS !== 'web')
292
+ return undefined;
293
+ return { cursor: disabled ? 'not-allowed' : 'pointer' };
294
+ }
295
+ function isPrimitiveText(node) {
296
+ return typeof node === 'string' || typeof node === 'number';
297
+ }
298
+ function isRenderProp(children) {
299
+ return typeof children === 'function';
300
+ }
301
+ function isIndicatorRenderProp(indicator) {
302
+ return typeof indicator === 'function';
303
+ }
304
+ function getNextCheckedState(current) {
305
+ if (current === 'indeterminate')
306
+ return true;
307
+ return !current;
308
+ }
309
+ function resolveAlignItems(align) {
310
+ if (align === 'center')
311
+ return 'center';
312
+ if (align === 'end')
313
+ return 'flex-end';
314
+ if (align === 'stretch')
315
+ return 'stretch';
316
+ return 'flex-start';
317
+ }
318
+ function CheckboxImpl({ value, checked: checkedProp, defaultChecked = false, onChange, disabled = false, size: sizeProp, tone: toneProp, variant: variantProp, shape: shapeProp, duration, color: colorProp, colors: colorsProp, layout: layoutProp, label, description, labelPlacement = 'end', children, showIndicator = true, indicator, style, contentStyle, indicatorStyle, labelStyle, descriptionStyle, accessibilityLabel, accessibilityState, hitSlop, onPress, onPressIn, onPressOut, onFocus, onBlur, testID, ...pressableProps }, ref) {
319
+ var _a, _b, _c, _d, _e;
320
+ const theme = (0, useTheme_1.useTheme)();
321
+ const scheme = (0, react_native_1.useColorScheme)();
322
+ const { width: viewportWidth } = (0, react_native_1.useWindowDimensions)();
323
+ const group = React.useContext(CheckboxGroupContext);
324
+ const isRTL = react_native_1.I18nManager.isRTL;
325
+ const isStandaloneControlled = checkedProp !== undefined;
326
+ const isGroupItem = group != null && value !== undefined && !isStandaloneControlled;
327
+ const [uncontrolledChecked, setUncontrolledChecked] = React.useState(() => defaultChecked);
328
+ const getGroupCheckedSnapshot = React.useCallback(() => (group && value !== undefined ? group.store.has(value) : false), [group, value]);
329
+ const groupChecked = React.useSyncExternalStore((_a = group === null || group === void 0 ? void 0 : group.store.subscribe) !== null && _a !== void 0 ? _a : noopSubscribe, getGroupCheckedSnapshot, getGroupCheckedSnapshot);
330
+ const state = isGroupItem
331
+ ? groupChecked
332
+ : isStandaloneControlled
333
+ ? checkedProp
334
+ : uncontrolledChecked;
335
+ const checked = state === true;
336
+ const indeterminate = state === 'indeterminate';
337
+ const active = state !== false;
338
+ const resolvedDisabled = disabled || Boolean(group === null || group === void 0 ? void 0 : group.disabled);
339
+ const interactive = !resolvedDisabled;
340
+ const size = (_b = sizeProp !== null && sizeProp !== void 0 ? sizeProp : group === null || group === void 0 ? void 0 : group.size) !== null && _b !== void 0 ? _b : 'md';
341
+ const tone = (_c = toneProp !== null && toneProp !== void 0 ? toneProp : group === null || group === void 0 ? void 0 : group.tone) !== null && _c !== void 0 ? _c : 'primary';
342
+ const variant = (_d = variantProp !== null && variantProp !== void 0 ? variantProp : group === null || group === void 0 ? void 0 : group.variant) !== null && _d !== void 0 ? _d : 'solid';
343
+ const shape = (_e = shapeProp !== null && shapeProp !== void 0 ? shapeProp : group === null || group === void 0 ? void 0 : group.shape) !== null && _e !== void 0 ? _e : 'rounded';
344
+ const color = colorProp !== null && colorProp !== void 0 ? colorProp : group === null || group === void 0 ? void 0 : group.color;
345
+ const colors = React.useMemo(() => (group === null || group === void 0 ? void 0 : group.colors) || colorsProp
346
+ ? {
347
+ ...group === null || group === void 0 ? void 0 : group.colors,
348
+ ...colorsProp,
349
+ }
350
+ : undefined, [colorsProp, group === null || group === void 0 ? void 0 : group.colors]);
351
+ const layout = React.useMemo(() => (group === null || group === void 0 ? void 0 : group.layout) || layoutProp
352
+ ? {
353
+ ...group === null || group === void 0 ? void 0 : group.layout,
354
+ ...layoutProp,
355
+ }
356
+ : undefined, [group === null || group === void 0 ? void 0 : group.layout, layoutProp]);
357
+ const metrics = React.useMemo(() => resolveCheckboxMetrics(size, shape, layout), [layout, shape, size, viewportWidth]);
358
+ const tonePalette = React.useMemo(() => resolveTonePalette(tone, theme), [theme, tone]);
359
+ const accent = React.useMemo(() => resolveColorToken(color, tonePalette.accent, theme), [color, theme, tonePalette.accent]);
360
+ const resolvedColors = React.useMemo(() => resolveVariantColors(variant, accent, tonePalette.onAccent, colors, theme, scheme), [accent, colors, scheme, theme, tonePalette.onAccent, variant]);
361
+ const webCursorStyle = React.useMemo(() => resolveWebCursorStyle(resolvedDisabled), [resolvedDisabled]);
362
+ const resolvedDuration = resolveDuration(duration);
363
+ const valueTiming = React.useMemo(() => toTimingConfig(resolvedDuration), [resolvedDuration]);
364
+ const pressInTiming = React.useMemo(() => toTimingConfig(PRESS_IN_DURATION), []);
365
+ const pressOutTiming = React.useMemo(() => toTimingConfig(PRESS_OUT_DURATION), []);
366
+ const focusTiming = React.useMemo(() => toTimingConfig(FOCUS_DURATION), []);
367
+ const defaultHitSlop = React.useMemo(() => resolveHitSlop(metrics.indicatorSize, metrics.indicatorSize, metrics.minTouchTarget), [metrics.indicatorSize, metrics.minTouchTarget]);
368
+ const checkedSv = (0, react_native_reanimated_1.useSharedValue)(active ? 1 : 0);
369
+ const indeterminateSv = (0, react_native_reanimated_1.useSharedValue)(indeterminate ? 1 : 0);
370
+ const pressSv = (0, react_native_reanimated_1.useSharedValue)(0);
371
+ const focusSv = (0, react_native_reanimated_1.useSharedValue)(0);
372
+ const stateRef = React.useRef(state);
373
+ stateRef.current = state;
374
+ const groupCheckedRef = React.useRef(groupChecked);
375
+ groupCheckedRef.current = groupChecked;
376
+ React.useEffect(() => {
377
+ if (!isStandaloneControlled && !isGroupItem)
378
+ return;
379
+ checkedSv.value = (0, react_native_reanimated_1.withTiming)(active ? 1 : 0, valueTiming);
380
+ indeterminateSv.value = (0, react_native_reanimated_1.withTiming)(indeterminate ? 1 : 0, valueTiming);
381
+ }, [
382
+ active,
383
+ checkedSv,
384
+ indeterminate,
385
+ indeterminateSv,
386
+ isGroupItem,
387
+ isStandaloneControlled,
388
+ valueTiming,
389
+ ]);
390
+ React.useEffect(() => {
391
+ if (interactive)
392
+ return;
393
+ pressSv.value = (0, react_native_reanimated_1.withTiming)(0, pressOutTiming);
394
+ focusSv.value = (0, react_native_reanimated_1.withTiming)(0, focusTiming);
395
+ }, [focusSv, focusTiming, interactive, pressOutTiming, pressSv]);
396
+ const commitStandaloneState = React.useCallback((next) => {
397
+ if (!isStandaloneControlled) {
398
+ stateRef.current = next;
399
+ checkedSv.value = (0, react_native_reanimated_1.withTiming)(next !== false ? 1 : 0, valueTiming);
400
+ indeterminateSv.value = (0, react_native_reanimated_1.withTiming)(next === 'indeterminate' ? 1 : 0, valueTiming);
401
+ setUncontrolledChecked(next);
402
+ }
403
+ onChange === null || onChange === void 0 ? void 0 : onChange(next);
404
+ }, [checkedSv, indeterminateSv, isStandaloneControlled, onChange, valueTiming]);
405
+ const toggle = React.useCallback(() => {
406
+ if (!interactive)
407
+ return;
408
+ if (isGroupItem && group && value !== undefined) {
409
+ const next = !groupCheckedRef.current;
410
+ if (!group.isControlled) {
411
+ checkedSv.value = (0, react_native_reanimated_1.withTiming)(next ? 1 : 0, valueTiming);
412
+ indeterminateSv.value = (0, react_native_reanimated_1.withTiming)(0, valueTiming);
413
+ }
414
+ group.toggleValue(value);
415
+ onChange === null || onChange === void 0 ? void 0 : onChange(next);
416
+ return;
417
+ }
418
+ commitStandaloneState(getNextCheckedState(stateRef.current));
419
+ }, [
420
+ checkedSv,
421
+ commitStandaloneState,
422
+ group,
423
+ indeterminateSv,
424
+ interactive,
425
+ isGroupItem,
426
+ onChange,
427
+ value,
428
+ valueTiming,
429
+ ]);
430
+ const handlePress = React.useCallback((event) => {
431
+ if (interactive)
432
+ toggle();
433
+ onPress === null || onPress === void 0 ? void 0 : onPress(event);
434
+ }, [interactive, onPress, toggle]);
435
+ const handlePressIn = React.useCallback((event) => {
436
+ if (interactive) {
437
+ pressSv.value = (0, react_native_reanimated_1.withTiming)(1, pressInTiming);
438
+ }
439
+ onPressIn === null || onPressIn === void 0 ? void 0 : onPressIn(event);
440
+ }, [interactive, onPressIn, pressInTiming, pressSv]);
441
+ const handlePressOut = React.useCallback((event) => {
442
+ pressSv.value = (0, react_native_reanimated_1.withTiming)(0, pressOutTiming);
443
+ onPressOut === null || onPressOut === void 0 ? void 0 : onPressOut(event);
444
+ }, [onPressOut, pressOutTiming, pressSv]);
445
+ const handleFocus = React.useCallback((event) => {
446
+ if (interactive) {
447
+ focusSv.value = (0, react_native_reanimated_1.withTiming)(1, focusTiming);
448
+ }
449
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
450
+ }, [focusSv, focusTiming, interactive, onFocus]);
451
+ const handleBlur = React.useCallback((event) => {
452
+ focusSv.value = (0, react_native_reanimated_1.withTiming)(0, focusTiming);
453
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
454
+ }, [focusSv, focusTiming, onBlur]);
455
+ const slot = React.useMemo(() => ({
456
+ checked,
457
+ indeterminate,
458
+ state,
459
+ value,
460
+ disabled: resolvedDisabled,
461
+ interactive,
462
+ size,
463
+ tone,
464
+ variant,
465
+ toggle,
466
+ }), [checked, indeterminate, interactive, resolvedDisabled, size, state, tone, toggle, value, variant]);
467
+ const renderedContent = React.useMemo(() => {
468
+ if (isRenderProp(children))
469
+ return children(slot);
470
+ if (children != null)
471
+ return children;
472
+ if (label == null && description == null)
473
+ return null;
474
+ return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.copy, children: [label != null ? (isPrimitiveText(label) ? ((0, jsx_runtime_1.jsx)(Text_1.Text, { numberOfLines: 1, variant: "label", style: labelStyle, children: label })) : (label)) : null, description != null ? (isPrimitiveText(description) ? ((0, jsx_runtime_1.jsx)(Text_1.Text, { numberOfLines: 2, tone: "muted", variant: "caption", style: descriptionStyle, children: description })) : (description)) : null] }));
475
+ }, [children, description, descriptionStyle, label, labelStyle, resolvedDisabled, slot]);
476
+ const defaultIcon = React.useMemo(() => ((0, jsx_runtime_1.jsx)(check_svg_1.default, { width: metrics.indicatorIconSize, height: metrics.indicatorIconSize, color: resolvedColors.checkedIndicator })), [metrics.indicatorIconSize, resolvedColors.checkedIndicator]);
477
+ const indicatorContext = React.useMemo(() => ({
478
+ checkedSv,
479
+ indeterminateSv,
480
+ boxSize: metrics.indicatorSize,
481
+ slot,
482
+ indeterminateIndicatorColor: resolvedColors.indeterminateIndicator,
483
+ defaultIcon,
484
+ customIndicator: indicator,
485
+ }), [
486
+ checkedSv,
487
+ defaultIcon,
488
+ indicator,
489
+ indeterminateSv,
490
+ metrics.indicatorSize,
491
+ resolvedColors.indeterminateIndicator,
492
+ slot,
493
+ ]);
494
+ const rootAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
495
+ const opacity = resolvedDisabled
496
+ ? DISABLED_OPACITY
497
+ : (0, react_native_reanimated_1.interpolate)(pressSv.value, [0, 1], [1, PRESSED_OPACITY]);
498
+ return { opacity };
499
+ }, [resolvedDisabled]);
500
+ const indicatorPressAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
501
+ const scale = (0, react_native_reanimated_1.interpolate)(pressSv.value, [0, 1], [1, PRESSED_SCALE]);
502
+ return { transform: [{ scale }] };
503
+ });
504
+ const focusRingAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
505
+ return {
506
+ opacity: focusSv.value,
507
+ transform: [{ scale: (0, react_native_reanimated_1.interpolate)(focusSv.value, [0, 1], [0.96, 1]) }],
508
+ };
509
+ });
510
+ const indicatorAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
511
+ const activeBackground = (0, react_native_reanimated_1.interpolateColor)(indeterminateSv.value, [0, 1], [resolvedColors.checkedBackground, resolvedColors.indeterminateBackground]);
512
+ const activeBorder = (0, react_native_reanimated_1.interpolateColor)(indeterminateSv.value, [0, 1], [resolvedColors.checkedBorder, resolvedColors.indeterminateBorder]);
513
+ return {
514
+ backgroundColor: (0, react_native_reanimated_1.interpolateColor)(checkedSv.value, [0, 1], [resolvedColors.uncheckedBackground, activeBackground]),
515
+ borderColor: (0, react_native_reanimated_1.interpolateColor)(checkedSv.value, [0, 1], [resolvedColors.uncheckedBorder, activeBorder]),
516
+ };
517
+ }, [resolvedColors]);
518
+ const indicatorFrameStyle = React.useMemo(() => ({
519
+ width: metrics.indicatorSize,
520
+ height: metrics.indicatorSize,
521
+ borderRadius: metrics.indicatorRadius,
522
+ borderWidth: metrics.indicatorBorderWidth,
523
+ }), [metrics.indicatorBorderWidth, metrics.indicatorRadius, metrics.indicatorSize]);
524
+ const indicatorNode = showIndicator ? ((0, jsx_runtime_1.jsxs)(react_native_reanimated_1.default.View, { style: [
525
+ styles.indicatorFrame,
526
+ indicatorFrameStyle,
527
+ indicatorPressAnimatedStyle,
528
+ indicatorAnimatedStyle,
529
+ indicatorStyle,
530
+ ], children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: "none", style: [
531
+ styles.focusRing,
532
+ {
533
+ top: -metrics.focusRingOffset,
534
+ bottom: -metrics.focusRingOffset,
535
+ left: -metrics.focusRingOffset,
536
+ right: -metrics.focusRingOffset,
537
+ borderRadius: metrics.indicatorRadius + metrics.focusRingOffset,
538
+ borderWidth: metrics.focusRingWidth,
539
+ borderColor: resolvedColors.focusRing,
540
+ },
541
+ focusRingAnimatedStyle,
542
+ ] }), (0, jsx_runtime_1.jsx)(CheckboxIndicator, {})] })) : null;
543
+ const hasContent = renderedContent != null;
544
+ const contentBeforeIndicator = (labelPlacement === 'start' && !isRTL) || (labelPlacement === 'end' && isRTL);
545
+ const contentNode = hasContent ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: [styles.content, contentStyle], children: contentBeforeIndicator ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: [styles.contentSlot, showIndicator ? { marginEnd: metrics.gap } : null], children: renderedContent }), indicatorNode] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [indicatorNode, (0, jsx_runtime_1.jsx)(react_native_1.View, { style: [styles.contentSlot, showIndicator ? { marginStart: metrics.gap } : null], children: renderedContent })] })) })) : (indicatorNode);
546
+ const inferredAccessibilityLabel = isPrimitiveText(label) ? String(label) : undefined;
547
+ const resolvedStyle = React.useCallback((stateArg) => {
548
+ const userStyle = typeof style === 'function' ? style(stateArg) : style;
549
+ return [styles.root, webCursorStyle, userStyle];
550
+ }, [style, webCursorStyle]);
551
+ return ((0, jsx_runtime_1.jsx)(CheckboxIndicatorContext.Provider, { value: indicatorContext, children: (0, jsx_runtime_1.jsx)(react_native_1.Pressable, { ...pressableProps, ref: ref, accessibilityLabel: accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : inferredAccessibilityLabel, accessibilityRole: "checkbox", accessibilityState: {
552
+ ...accessibilityState,
553
+ checked: indeterminate ? 'mixed' : checked,
554
+ disabled: Boolean(resolvedDisabled),
555
+ }, disabled: resolvedDisabled, hitSlop: hitSlop !== null && hitSlop !== void 0 ? hitSlop : defaultHitSlop, onBlur: handleBlur, onFocus: handleFocus, onPress: handlePress, onPressIn: handlePressIn, onPressOut: handlePressOut, style: resolvedStyle, testID: testID, children: (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [styles.visual, rootAnimatedStyle], children: contentNode }) }) }));
556
+ }
557
+ const CheckboxWithRef = React.forwardRef(CheckboxImpl);
558
+ CheckboxWithRef.displayName = 'Checkbox';
559
+ exports.Checkbox = React.memo(CheckboxWithRef);
560
+ exports.Checkbox.displayName = 'Checkbox';
561
+ function CheckboxIndicator({ children, style }) {
562
+ const context = useCheckboxIndicatorContext();
563
+ const customIndicator = children !== null && children !== void 0 ? children : context.customIndicator;
564
+ const checkedIconAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
565
+ const opacity = context.checkedSv.value * (1 - context.indeterminateSv.value);
566
+ const scale = (0, react_native_reanimated_1.interpolate)(context.checkedSv.value, [0, 1], [0.78, 1]);
567
+ return { opacity, transform: [{ scale }] };
568
+ });
569
+ const indeterminateAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
570
+ const opacity = context.checkedSv.value * context.indeterminateSv.value;
571
+ const scale = (0, react_native_reanimated_1.interpolate)(context.indeterminateSv.value, [0, 1], [0.82, 1]);
572
+ return { opacity, transform: [{ scale }] };
573
+ });
574
+ const customIndicatorAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
575
+ const opacity = context.checkedSv.value;
576
+ const scale = (0, react_native_reanimated_1.interpolate)(context.checkedSv.value, [0, 1], [0.78, 1]);
577
+ return { opacity, transform: [{ scale }] };
578
+ });
579
+ const indeterminateWidth = Math.max((0, zkit_tools_1.wp)(8), Math.round(context.boxSize * 0.56));
580
+ const indeterminateHeight = Math.max((0, zkit_tools_1.wp)(2), Math.round(context.boxSize * 0.11));
581
+ const resolvedCustomIndicator = isIndicatorRenderProp(customIndicator)
582
+ ? customIndicator(context.slot)
583
+ : customIndicator;
584
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { pointerEvents: "none", style: [
585
+ styles.indicatorLayer,
586
+ {
587
+ width: context.boxSize,
588
+ height: context.boxSize,
589
+ },
590
+ style,
591
+ ], children: resolvedCustomIndicator != null ? ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: customIndicatorAnimatedStyle, children: resolvedCustomIndicator })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: indeterminateAnimatedStyle, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { style: {
592
+ width: indeterminateWidth,
593
+ height: indeterminateHeight,
594
+ borderRadius: indeterminateHeight / 2,
595
+ backgroundColor: context.indeterminateIndicatorColor,
596
+ } }) }), (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [styles.iconLayer, checkedIconAnimatedStyle], children: context.defaultIcon })] })) }));
597
+ }
598
+ function CheckboxGroup({ value, defaultValue, onChange, disabled = false, orientation = 'horizontal', align = 'start', wrap = false, gap, rowGap, columnGap, size, tone, variant, shape, color, colors, layout, style, children, ...viewProps }) {
599
+ var _a;
600
+ const { width: viewportWidth } = (0, react_native_1.useWindowDimensions)();
601
+ const isControlled = value !== undefined;
602
+ const storeRef = React.useRef(null);
603
+ if (!storeRef.current) {
604
+ storeRef.current = new CheckboxGroupStore((_a = value !== null && value !== void 0 ? value : defaultValue) !== null && _a !== void 0 ? _a : []);
605
+ }
606
+ React.useLayoutEffect(() => {
607
+ if (!isControlled)
608
+ return;
609
+ storeRef.current.setValues(value !== null && value !== void 0 ? value : []);
610
+ }, [isControlled, value]);
611
+ const toggleValue = React.useCallback((nextValue) => {
612
+ const next = storeRef.current.getToggledValues(nextValue);
613
+ if (!isControlled)
614
+ storeRef.current.setValues(next);
615
+ onChange === null || onChange === void 0 ? void 0 : onChange(next);
616
+ }, [isControlled, onChange]);
617
+ const context = React.useMemo(() => ({
618
+ store: storeRef.current,
619
+ disabled,
620
+ isControlled,
621
+ toggleValue,
622
+ size,
623
+ tone,
624
+ variant,
625
+ shape,
626
+ color,
627
+ colors,
628
+ layout,
629
+ }), [
630
+ color,
631
+ colors,
632
+ disabled,
633
+ isControlled,
634
+ layout,
635
+ shape,
636
+ size,
637
+ tone,
638
+ toggleValue,
639
+ variant,
640
+ ]);
641
+ const defaultGap = React.useMemo(() => (0, zkit_tools_1.wp)(12), [viewportWidth]);
642
+ const resolvedGap = resolveNonNegativeNumber(gap, defaultGap);
643
+ const resolvedRowGap = resolveNonNegativeNumber(rowGap, resolvedGap);
644
+ const resolvedColumnGap = resolveNonNegativeNumber(columnGap, resolvedGap);
645
+ const layoutStyle = React.useMemo(() => ({
646
+ alignItems: resolveAlignItems(align),
647
+ columnGap: resolvedColumnGap,
648
+ flexDirection: orientation === 'vertical' ? 'column' : 'row',
649
+ flexWrap: wrap ? 'wrap' : 'nowrap',
650
+ rowGap: resolvedRowGap,
651
+ }), [align, orientation, resolvedColumnGap, resolvedRowGap, wrap]);
652
+ return ((0, jsx_runtime_1.jsx)(CheckboxGroupContext.Provider, { value: context, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { ...viewProps, style: [layoutStyle, style], children: children }) }));
653
+ }
654
+ const styles = react_native_1.StyleSheet.create({
655
+ root: {
656
+ alignSelf: 'flex-start',
657
+ },
658
+ visual: {
659
+ alignItems: 'center',
660
+ flexDirection: 'row',
661
+ minWidth: 0,
662
+ },
663
+ content: {
664
+ alignItems: 'center',
665
+ flexDirection: 'row',
666
+ minWidth: 0,
667
+ },
668
+ contentSlot: {
669
+ flexShrink: 1,
670
+ minWidth: 0,
671
+ },
672
+ copy: {
673
+ flexShrink: 1,
674
+ minWidth: 0,
675
+ },
676
+ indicatorFrame: {
677
+ alignItems: 'center',
678
+ flexShrink: 0,
679
+ justifyContent: 'center',
680
+ overflow: 'visible',
681
+ },
682
+ focusRing: {
683
+ position: 'absolute',
684
+ },
685
+ indicatorLayer: {
686
+ alignItems: 'center',
687
+ justifyContent: 'center',
688
+ },
689
+ iconLayer: {
690
+ ...react_native_1.StyleSheet.absoluteFillObject,
691
+ alignItems: 'center',
692
+ justifyContent: 'center',
693
+ },
694
+ });