@xaui/native 0.2.8 → 0.9.1-alpha.1

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 (234) hide show
  1. package/dist/chunk-KFCORXWW.cjs +150 -0
  2. package/dist/chunk-M7P46XKI.cjs +100 -0
  3. package/dist/chunk-N357EQCZ.js +150 -0
  4. package/dist/chunk-NHPQQQ7P.cjs +734 -0
  5. package/dist/chunk-PBVPOX7D.js +734 -0
  6. package/dist/chunk-RBNCR5KB.js +100 -0
  7. package/dist/index.cjs +40 -1
  8. package/dist/index.d.cts +5 -2
  9. package/dist/index.d.ts +5 -2
  10. package/dist/index.js +40 -0
  11. package/dist/system/index.cjs +7 -0
  12. package/dist/system/index.d.cts +83 -0
  13. package/dist/system/index.d.ts +83 -0
  14. package/dist/system/index.js +7 -0
  15. package/dist/theme/index.cjs +36 -0
  16. package/dist/theme/index.d.cts +539 -0
  17. package/dist/theme/index.d.ts +539 -0
  18. package/dist/theme/index.js +36 -0
  19. package/dist/theme.type-B3ODSLbB.d.cts +153 -0
  20. package/dist/theme.type-B3ODSLbB.d.ts +153 -0
  21. package/package.json +30 -248
  22. package/README.md +0 -178
  23. package/dist/alert/index.cjs +0 -340
  24. package/dist/alert/index.d.cts +0 -46
  25. package/dist/alert/index.d.ts +0 -46
  26. package/dist/alert/index.js +0 -340
  27. package/dist/app-bar/index.cjs +0 -148
  28. package/dist/app-bar/index.d.cts +0 -59
  29. package/dist/app-bar/index.d.ts +0 -59
  30. package/dist/app-bar/index.js +0 -148
  31. package/dist/autocomplete/index.cjs +0 -1122
  32. package/dist/autocomplete/index.d.cts +0 -88
  33. package/dist/autocomplete/index.d.ts +0 -88
  34. package/dist/autocomplete/index.js +0 -1122
  35. package/dist/avatar/index.cjs +0 -281
  36. package/dist/avatar/index.d.cts +0 -123
  37. package/dist/avatar/index.d.ts +0 -123
  38. package/dist/avatar/index.js +0 -281
  39. package/dist/badge/index.cjs +0 -197
  40. package/dist/badge/index.d.cts +0 -94
  41. package/dist/badge/index.d.ts +0 -94
  42. package/dist/badge/index.js +0 -197
  43. package/dist/bottom-sheet/index.cjs +0 -9
  44. package/dist/bottom-sheet/index.d.cts +0 -84
  45. package/dist/bottom-sheet/index.d.ts +0 -84
  46. package/dist/bottom-sheet/index.js +0 -9
  47. package/dist/bottom-tab-bar/index.cjs +0 -497
  48. package/dist/bottom-tab-bar/index.d.cts +0 -211
  49. package/dist/bottom-tab-bar/index.d.ts +0 -211
  50. package/dist/bottom-tab-bar/index.js +0 -497
  51. package/dist/button/index.cjs +0 -392
  52. package/dist/button/index.d.cts +0 -174
  53. package/dist/button/index.d.ts +0 -174
  54. package/dist/button/index.js +0 -392
  55. package/dist/button.type-j1ZdkkSl.d.cts +0 -4
  56. package/dist/button.type-j1ZdkkSl.d.ts +0 -4
  57. package/dist/card/index.cjs +0 -338
  58. package/dist/card/index.d.cts +0 -191
  59. package/dist/card/index.d.ts +0 -191
  60. package/dist/card/index.js +0 -338
  61. package/dist/carousel/index.cjs +0 -381
  62. package/dist/carousel/index.d.cts +0 -147
  63. package/dist/carousel/index.d.ts +0 -147
  64. package/dist/carousel/index.js +0 -381
  65. package/dist/chart/index.cjs +0 -1026
  66. package/dist/chart/index.d.cts +0 -218
  67. package/dist/chart/index.d.ts +0 -218
  68. package/dist/chart/index.js +0 -1026
  69. package/dist/checkbox/index.cjs +0 -443
  70. package/dist/checkbox/index.d.cts +0 -73
  71. package/dist/checkbox/index.d.ts +0 -73
  72. package/dist/checkbox/index.js +0 -443
  73. package/dist/chip/index.cjs +0 -503
  74. package/dist/chip/index.d.cts +0 -195
  75. package/dist/chip/index.d.ts +0 -195
  76. package/dist/chip/index.js +0 -503
  77. package/dist/chunk-4JFWQ5XT.js +0 -368
  78. package/dist/chunk-56RPWZD2.cjs +0 -9
  79. package/dist/chunk-7UFBLUMV.cjs +0 -136
  80. package/dist/chunk-A45TVXU5.js +0 -337
  81. package/dist/chunk-BYWUAPC4.cjs +0 -368
  82. package/dist/chunk-DECMUMCI.js +0 -0
  83. package/dist/chunk-DHSTKO3K.cjs +0 -19
  84. package/dist/chunk-DJ4Q37UT.cjs +0 -75
  85. package/dist/chunk-EUQDGTST.cjs +0 -1
  86. package/dist/chunk-GBHQCAKW.js +0 -19
  87. package/dist/chunk-RBSA4NH4.js +0 -136
  88. package/dist/chunk-SHBDANQN.js +0 -9
  89. package/dist/chunk-UGEINZM7.cjs +0 -290
  90. package/dist/chunk-UU4HHBDN.js +0 -290
  91. package/dist/chunk-VSZEXOUN.js +0 -384
  92. package/dist/chunk-YIEUN3G5.cjs +0 -384
  93. package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
  94. package/dist/chunk-ZY7IUTAT.js +0 -75
  95. package/dist/color-picker/index.cjs +0 -457
  96. package/dist/color-picker/index.d.cts +0 -124
  97. package/dist/color-picker/index.d.ts +0 -124
  98. package/dist/color-picker/index.js +0 -457
  99. package/dist/core/index.cjs +0 -24
  100. package/dist/core/index.d.cts +0 -28
  101. package/dist/core/index.d.ts +0 -28
  102. package/dist/core/index.js +0 -24
  103. package/dist/datepicker/index.cjs +0 -1625
  104. package/dist/datepicker/index.d.cts +0 -45
  105. package/dist/datepicker/index.d.ts +0 -45
  106. package/dist/datepicker/index.js +0 -1625
  107. package/dist/dialog/index.cjs +0 -372
  108. package/dist/dialog/index.d.cts +0 -151
  109. package/dist/dialog/index.d.ts +0 -151
  110. package/dist/dialog/index.js +0 -372
  111. package/dist/divider/index.cjs +0 -8
  112. package/dist/divider/index.d.cts +0 -30
  113. package/dist/divider/index.d.ts +0 -30
  114. package/dist/divider/index.js +0 -8
  115. package/dist/drawer/index.cjs +0 -237
  116. package/dist/drawer/index.d.cts +0 -58
  117. package/dist/drawer/index.d.ts +0 -58
  118. package/dist/drawer/index.js +0 -237
  119. package/dist/expansion-panel/index.cjs +0 -441
  120. package/dist/expansion-panel/index.d.cts +0 -153
  121. package/dist/expansion-panel/index.d.ts +0 -153
  122. package/dist/expansion-panel/index.js +0 -441
  123. package/dist/fab/index.cjs +0 -9
  124. package/dist/fab/index.d.cts +0 -10
  125. package/dist/fab/index.d.ts +0 -10
  126. package/dist/fab/index.js +0 -9
  127. package/dist/fab-menu/index.cjs +0 -330
  128. package/dist/fab-menu/index.d.cts +0 -125
  129. package/dist/fab-menu/index.d.ts +0 -125
  130. package/dist/fab-menu/index.js +0 -330
  131. package/dist/fab.type-CkUHmXU_.d.ts +0 -86
  132. package/dist/fab.type-DN0vtAh6.d.cts +0 -86
  133. package/dist/feature-discovery/index.cjs +0 -464
  134. package/dist/feature-discovery/index.d.cts +0 -82
  135. package/dist/feature-discovery/index.d.ts +0 -82
  136. package/dist/feature-discovery/index.js +0 -464
  137. package/dist/indicator/index.cjs +0 -8
  138. package/dist/indicator/index.d.cts +0 -47
  139. package/dist/indicator/index.d.ts +0 -47
  140. package/dist/indicator/index.js +0 -8
  141. package/dist/input/index.cjs +0 -1462
  142. package/dist/input/index.d.cts +0 -522
  143. package/dist/input/index.d.ts +0 -522
  144. package/dist/input/index.js +0 -1462
  145. package/dist/input-trigger/index.cjs +0 -197
  146. package/dist/input-trigger/index.d.cts +0 -11
  147. package/dist/input-trigger/index.d.ts +0 -11
  148. package/dist/input-trigger/index.js +0 -197
  149. package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
  150. package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
  151. package/dist/list/index.cjs +0 -395
  152. package/dist/list/index.d.cts +0 -188
  153. package/dist/list/index.d.ts +0 -188
  154. package/dist/list/index.js +0 -395
  155. package/dist/menu/index.cjs +0 -316
  156. package/dist/menu/index.d.cts +0 -115
  157. package/dist/menu/index.d.ts +0 -115
  158. package/dist/menu/index.js +0 -316
  159. package/dist/menubox/index.cjs +0 -297
  160. package/dist/menubox/index.d.cts +0 -98
  161. package/dist/menubox/index.d.ts +0 -98
  162. package/dist/menubox/index.js +0 -297
  163. package/dist/pager/index.cjs +0 -205
  164. package/dist/pager/index.d.cts +0 -93
  165. package/dist/pager/index.d.ts +0 -93
  166. package/dist/pager/index.js +0 -205
  167. package/dist/picker/index.cjs +0 -244
  168. package/dist/picker/index.d.cts +0 -121
  169. package/dist/picker/index.d.ts +0 -121
  170. package/dist/picker/index.js +0 -244
  171. package/dist/progress/index.cjs +0 -219
  172. package/dist/progress/index.d.cts +0 -47
  173. package/dist/progress/index.d.ts +0 -47
  174. package/dist/progress/index.js +0 -219
  175. package/dist/radio/index.cjs +0 -465
  176. package/dist/radio/index.d.cts +0 -145
  177. package/dist/radio/index.d.ts +0 -145
  178. package/dist/radio/index.js +0 -465
  179. package/dist/refresh-control/index.cjs +0 -45
  180. package/dist/refresh-control/index.d.cts +0 -55
  181. package/dist/refresh-control/index.d.ts +0 -55
  182. package/dist/refresh-control/index.js +0 -45
  183. package/dist/segment-button/index.cjs +0 -405
  184. package/dist/segment-button/index.d.cts +0 -141
  185. package/dist/segment-button/index.d.ts +0 -141
  186. package/dist/segment-button/index.js +0 -405
  187. package/dist/select/index.cjs +0 -878
  188. package/dist/select/index.d.cts +0 -192
  189. package/dist/select/index.d.ts +0 -192
  190. package/dist/select/index.js +0 -878
  191. package/dist/skeleton/index.cjs +0 -89
  192. package/dist/skeleton/index.d.cts +0 -45
  193. package/dist/skeleton/index.d.ts +0 -45
  194. package/dist/skeleton/index.js +0 -89
  195. package/dist/slider/index.cjs +0 -576
  196. package/dist/slider/index.d.cts +0 -171
  197. package/dist/slider/index.d.ts +0 -171
  198. package/dist/slider/index.js +0 -576
  199. package/dist/snackbar/index.cjs +0 -436
  200. package/dist/snackbar/index.d.cts +0 -174
  201. package/dist/snackbar/index.d.ts +0 -174
  202. package/dist/snackbar/index.js +0 -436
  203. package/dist/snippet/index.cjs +0 -314
  204. package/dist/snippet/index.d.cts +0 -95
  205. package/dist/snippet/index.d.ts +0 -95
  206. package/dist/snippet/index.js +0 -314
  207. package/dist/stepper/index.cjs +0 -550
  208. package/dist/stepper/index.d.cts +0 -137
  209. package/dist/stepper/index.d.ts +0 -137
  210. package/dist/stepper/index.js +0 -550
  211. package/dist/switch/index.cjs +0 -358
  212. package/dist/switch/index.d.cts +0 -28
  213. package/dist/switch/index.d.ts +0 -28
  214. package/dist/switch/index.js +0 -358
  215. package/dist/tabs/index.cjs +0 -440
  216. package/dist/tabs/index.d.cts +0 -180
  217. package/dist/tabs/index.d.ts +0 -180
  218. package/dist/tabs/index.js +0 -440
  219. package/dist/timepicker/index.cjs +0 -823
  220. package/dist/timepicker/index.d.cts +0 -215
  221. package/dist/timepicker/index.d.ts +0 -215
  222. package/dist/timepicker/index.js +0 -823
  223. package/dist/toolbar/index.cjs +0 -333
  224. package/dist/toolbar/index.d.cts +0 -100
  225. package/dist/toolbar/index.d.ts +0 -100
  226. package/dist/toolbar/index.js +0 -333
  227. package/dist/typography/index.cjs +0 -238
  228. package/dist/typography/index.d.cts +0 -113
  229. package/dist/typography/index.d.ts +0 -113
  230. package/dist/typography/index.js +0 -238
  231. package/dist/view/index.cjs +0 -1361
  232. package/dist/view/index.d.cts +0 -833
  233. package/dist/view/index.d.ts +0 -833
  234. package/dist/view/index.js +0 -1361
@@ -1,219 +0,0 @@
1
- import "../chunk-SHBDANQN.js";
2
- import {
3
- useXUITheme
4
- } from "../chunk-RBSA4NH4.js";
5
-
6
- // src/components/progress/progress.tsx
7
- import React3 from "react";
8
- import { View as View3 } from "react-native";
9
-
10
- // src/components/progress/circular-progress-indicator.tsx
11
- import React from "react";
12
- import { View } from "react-native";
13
- import Animated, { useAnimatedProps } from "react-native-reanimated";
14
- import Svg, { Circle } from "react-native-svg";
15
-
16
- // src/components/progress/progress.hook.ts
17
- import { useEffect } from "react";
18
- import { Easing, useSharedValue, withTiming } from "react-native-reanimated";
19
- var MIN_VALUE = 0;
20
- var MAX_VALUE = 1;
21
- var clampProgress = (value) => Math.max(MIN_VALUE, Math.min(MAX_VALUE, value));
22
- var useProgressAnimation = (value, disableAnimation) => {
23
- const progressAnim = useSharedValue(clampProgress(value));
24
- useEffect(() => {
25
- const clampedValue = clampProgress(value);
26
- if (disableAnimation) {
27
- progressAnim.value = clampedValue;
28
- return;
29
- }
30
- progressAnim.value = withTiming(clampedValue, {
31
- duration: 500,
32
- easing: Easing.bezier(0, 0, 0.2, 1)
33
- });
34
- }, [value, disableAnimation, progressAnim]);
35
- return progressAnim;
36
- };
37
-
38
- // src/components/progress/progress.style.ts
39
- import { StyleSheet } from "react-native";
40
- var styles = StyleSheet.create({
41
- container: {
42
- flexShrink: 1,
43
- flexBasis: "auto",
44
- width: "100%"
45
- },
46
- track: {
47
- width: "100%",
48
- overflow: "hidden"
49
- },
50
- progress: {
51
- height: "100%"
52
- },
53
- circleContainer: {
54
- justifyContent: "center",
55
- alignItems: "center"
56
- }
57
- });
58
-
59
- // src/components/progress/circular-progress-indicator.tsx
60
- var AnimatedCircle = Animated.createAnimatedComponent(Circle);
61
- var CircularProgressIndicator = ({
62
- size = 40,
63
- color,
64
- backgroundColor,
65
- value,
66
- borderRadius,
67
- disableAnimation
68
- }) => {
69
- const progressAnim = useProgressAnimation(value, disableAnimation);
70
- const strokeWidth = size * 0.1;
71
- const radius = (size - strokeWidth) / 2;
72
- const circumference = 2 * Math.PI * radius;
73
- const center = size / 2;
74
- const strokeCap = borderRadius && borderRadius > 0 ? "round" : "butt";
75
- const animatedProps = useAnimatedProps(() => ({
76
- strokeDashoffset: circumference * (1 - progressAnim.value)
77
- }));
78
- return /* @__PURE__ */ React.createElement(View, { style: [styles.circleContainer, { width: size, height: size }] }, /* @__PURE__ */ React.createElement(Svg, { width: size, height: size, style: { transform: [{ rotate: "-90deg" }] } }, /* @__PURE__ */ React.createElement(
79
- Circle,
80
- {
81
- cx: center,
82
- cy: center,
83
- r: radius,
84
- stroke: backgroundColor,
85
- strokeWidth,
86
- fill: "none"
87
- }
88
- ), /* @__PURE__ */ React.createElement(
89
- AnimatedCircle,
90
- {
91
- cx: center,
92
- cy: center,
93
- r: radius,
94
- stroke: color,
95
- strokeWidth,
96
- strokeLinecap: strokeCap,
97
- strokeDasharray: circumference,
98
- animatedProps,
99
- fill: "none"
100
- }
101
- )));
102
- };
103
-
104
- // src/components/progress/linear-progress-indicator.tsx
105
- import React2 from "react";
106
- import { View as View2 } from "react-native";
107
- import Animated2, { useAnimatedStyle } from "react-native-reanimated";
108
- var LinearProgressIndicator = ({
109
- size = 4,
110
- color,
111
- backgroundColor,
112
- value,
113
- borderRadius,
114
- disableAnimation
115
- }) => {
116
- const progressAnim = useProgressAnimation(value, disableAnimation);
117
- const radius = Math.max(0, Math.min(size / 2, borderRadius ?? 0));
118
- const animatedStyle = useAnimatedStyle(() => ({
119
- width: `${progressAnim.value * 100}%`
120
- }));
121
- return /* @__PURE__ */ React2.createElement(
122
- View2,
123
- {
124
- style: [
125
- styles.track,
126
- {
127
- height: size,
128
- backgroundColor,
129
- borderRadius: radius
130
- }
131
- ]
132
- },
133
- /* @__PURE__ */ React2.createElement(
134
- Animated2.View,
135
- {
136
- style: [
137
- styles.progress,
138
- animatedStyle,
139
- {
140
- backgroundColor: color,
141
- borderRadius: radius
142
- }
143
- ]
144
- }
145
- )
146
- );
147
- };
148
-
149
- // src/components/progress/progress.tsx
150
- var Progress = (props) => {
151
- const {
152
- variant = "linear",
153
- themeColor = "primary",
154
- value,
155
- color,
156
- backgroundColor,
157
- size,
158
- disableAnimation = false
159
- } = props;
160
- const theme = useXUITheme();
161
- const colorScheme = theme.colors[themeColor];
162
- const mainColor = color ?? colorScheme.main;
163
- const trackColor = backgroundColor ?? colorScheme.container;
164
- const clampedValue = clampProgress(value);
165
- const accessibilityValue = {
166
- min: 0,
167
- max: 100,
168
- now: clampedValue * 100
169
- };
170
- if (variant === "circular") {
171
- const circleSize = size ?? 40;
172
- const borderRadius2 = "borderRadius" in props ? props.borderRadius : void 0;
173
- return /* @__PURE__ */ React3.createElement(
174
- View3,
175
- {
176
- style: [styles.circleContainer, { width: circleSize, height: circleSize }],
177
- accessible: true,
178
- accessibilityRole: "progressbar",
179
- accessibilityValue
180
- },
181
- /* @__PURE__ */ React3.createElement(
182
- CircularProgressIndicator,
183
- {
184
- size: circleSize,
185
- color: mainColor,
186
- backgroundColor: trackColor,
187
- value: clampedValue,
188
- borderRadius: borderRadius2,
189
- disableAnimation
190
- }
191
- )
192
- );
193
- }
194
- const linearSize = size ?? 4;
195
- const borderRadius = "borderRadius" in props ? props.borderRadius : void 0;
196
- return /* @__PURE__ */ React3.createElement(
197
- View3,
198
- {
199
- style: styles.container,
200
- accessible: true,
201
- accessibilityRole: "progressbar",
202
- accessibilityValue
203
- },
204
- /* @__PURE__ */ React3.createElement(
205
- LinearProgressIndicator,
206
- {
207
- size: linearSize,
208
- color: mainColor,
209
- backgroundColor: trackColor,
210
- value: clampedValue,
211
- borderRadius,
212
- disableAnimation
213
- }
214
- )
215
- );
216
- };
217
- export {
218
- Progress
219
- };
@@ -1,465 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('../chunk-56RPWZD2.cjs');
2
-
3
-
4
- var _chunk7UFBLUMVcjs = require('../chunk-7UFBLUMV.cjs');
5
-
6
- // src/components/radio/radio.tsx
7
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
8
- var _reactnative = require('react-native');
9
- var _core = require('@xaui/core');
10
-
11
- // src/components/radio/radio-context.ts
12
-
13
- var RadioGroupContext = _react2.default.createContext(
14
- null
15
- );
16
-
17
- // src/components/radio/radio.hook.ts
18
-
19
-
20
- function useSizeStyles(size, variant) {
21
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
22
- const sizeStyles = _react.useMemo.call(void 0, () => {
23
- const sizes = {
24
- xs: {
25
- radioSize: 14,
26
- fontSize: theme.fontSizes.xs,
27
- dotSize: variant === "light" ? 5 : 4
28
- },
29
- sm: {
30
- radioSize: 18,
31
- fontSize: theme.fontSizes.sm,
32
- dotSize: variant === "light" ? 7 : 6
33
- },
34
- md: {
35
- radioSize: 22,
36
- fontSize: theme.fontSizes.md,
37
- dotSize: variant === "light" ? 9 : 8
38
- },
39
- lg: {
40
- radioSize: 26,
41
- fontSize: theme.fontSizes.lg,
42
- dotSize: variant === "light" ? 11 : 10
43
- }
44
- };
45
- return sizes[size];
46
- }, [size, theme, variant]);
47
- return sizeStyles;
48
- }
49
- function useRadiusStyles(radius) {
50
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
51
- const radiusStyles = _react.useMemo.call(void 0, () => {
52
- const radii = {
53
- none: theme.borderRadius.none,
54
- sm: theme.borderRadius.sm,
55
- md: theme.borderRadius.md,
56
- lg: theme.borderRadius.lg,
57
- full: theme.borderRadius.full
58
- };
59
- return { borderRadius: radii[radius] };
60
- }, [radius, theme]);
61
- return radiusStyles;
62
- }
63
- function useDotColors(themeColor, variant, isActive) {
64
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
65
- const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
66
- const colorScheme = theme.colors[safeThemeColor];
67
- const dotColors = _react.useMemo.call(void 0, () => {
68
- if (!isActive) {
69
- return {
70
- checked: "transparent"
71
- };
72
- }
73
- if (variant === "filled") {
74
- return {
75
- checked: colorScheme.onMain
76
- };
77
- }
78
- return {
79
- checked: colorScheme.main
80
- };
81
- }, [colorScheme, isActive, variant]);
82
- return dotColors;
83
- }
84
- function useVariantStyles(themeColor, variant, isActive) {
85
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
86
- const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
87
- const colorScheme = theme.colors[safeThemeColor];
88
- const variantStyles = _react.useMemo.call(void 0, () => {
89
- if (variant === "filled") {
90
- return {
91
- backgroundColor: isActive ? colorScheme.main : "transparent",
92
- borderWidth: isActive ? 0 : theme.borderWidth.md,
93
- borderColor: isActive ? "transparent" : colorScheme.main
94
- };
95
- }
96
- return {
97
- backgroundColor: "transparent",
98
- borderWidth: theme.borderWidth.md,
99
- borderColor: colorScheme.main
100
- };
101
- }, [colorScheme.main, isActive, theme.borderWidth.md, variant]);
102
- return variantStyles;
103
- }
104
- function useContainerStyles(labelAlignment) {
105
- const containerStyles = _react.useMemo.call(void 0, () => {
106
- const isJustified = labelAlignment === "justify-left" || labelAlignment === "justify-right";
107
- return {
108
- flexDirection: labelAlignment === "left" || labelAlignment === "justify-left" ? "row-reverse" : "row",
109
- justifyContent: isJustified ? "space-between" : "flex-start"
110
- };
111
- }, [labelAlignment]);
112
- return containerStyles;
113
- }
114
-
115
- // src/components/radio/radio.style.ts
116
-
117
- var styles = _reactnative.StyleSheet.create({
118
- group: {
119
- width: "100%"
120
- },
121
- container: {
122
- flexDirection: "row",
123
- alignItems: "center",
124
- gap: 10
125
- },
126
- fullWidth: {
127
- flexShrink: 1,
128
- flexBasis: "auto",
129
- width: "100%"
130
- },
131
- radio: {
132
- alignItems: "center",
133
- justifyContent: "center",
134
- overflow: "hidden",
135
- position: "relative"
136
- },
137
- background: {
138
- position: "absolute",
139
- width: "100%",
140
- height: "100%"
141
- },
142
- dot: {
143
- zIndex: 10
144
- },
145
- label: {
146
- fontWeight: "400"
147
- },
148
- disabled: {
149
- opacity: 0.5
150
- },
151
- disabledText: {
152
- opacity: 0.7
153
- }
154
- });
155
-
156
- // src/components/radio/radio.animation.ts
157
-
158
- var runDotInAnimation = (dotScale, dotOpacity) => {
159
- _reactnative.Animated.parallel([
160
- _reactnative.Animated.spring(dotScale, {
161
- toValue: 1,
162
- useNativeDriver: true,
163
- tension: 90,
164
- friction: 9
165
- }),
166
- _reactnative.Animated.timing(dotOpacity, {
167
- toValue: 1,
168
- duration: 180,
169
- useNativeDriver: true
170
- })
171
- ]).start();
172
- };
173
- var runDotOutAnimation = (dotScale, dotOpacity) => {
174
- _reactnative.Animated.parallel([
175
- _reactnative.Animated.spring(dotScale, {
176
- toValue: 0,
177
- useNativeDriver: true,
178
- tension: 90,
179
- friction: 9
180
- }),
181
- _reactnative.Animated.timing(dotOpacity, {
182
- toValue: 0,
183
- duration: 140,
184
- useNativeDriver: true
185
- })
186
- ]).start();
187
- };
188
- var runBackgroundInAnimation = (backgroundScale, backgroundOpacity) => {
189
- _reactnative.Animated.parallel([
190
- _reactnative.Animated.timing(backgroundScale, {
191
- toValue: 1,
192
- duration: 200,
193
- useNativeDriver: true
194
- }),
195
- _reactnative.Animated.timing(backgroundOpacity, {
196
- toValue: 1,
197
- duration: 200,
198
- useNativeDriver: true
199
- })
200
- ]).start();
201
- };
202
- var runBackgroundOutAnimation = (backgroundScale, backgroundOpacity) => {
203
- _reactnative.Animated.parallel([
204
- _reactnative.Animated.timing(backgroundScale, {
205
- toValue: 0.5,
206
- duration: 200,
207
- useNativeDriver: true
208
- }),
209
- _reactnative.Animated.timing(backgroundOpacity, {
210
- toValue: 0,
211
- duration: 200,
212
- useNativeDriver: true
213
- })
214
- ]).start();
215
- };
216
- var runPressInAnimation = (scale) => {
217
- _reactnative.Animated.spring(scale, {
218
- toValue: 0.95,
219
- useNativeDriver: true
220
- }).start();
221
- };
222
- var runPressOutAnimation = (scale) => {
223
- _reactnative.Animated.spring(scale, {
224
- toValue: 1,
225
- useNativeDriver: true
226
- }).start();
227
- };
228
-
229
- // src/components/radio/radio.tsx
230
- var Radio = ({
231
- label,
232
- value,
233
- labelAlignment,
234
- themeColor,
235
- variant,
236
- size,
237
- radius,
238
- fullWidth,
239
- isChecked: isCheckedProp,
240
- defaultChecked = false,
241
- isDisabled,
242
- labelStyle,
243
- style,
244
- onValueChange
245
- }) => {
246
- const group = _react.useContext.call(void 0, RadioGroupContext);
247
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
248
- const resolvedLabelAlignment = _nullishCoalesce(_nullishCoalesce(labelAlignment, () => ( _optionalChain([group, 'optionalAccess', _ => _.labelAlignment]))), () => ( "right"));
249
- const resolvedThemeColor = _nullishCoalesce(_nullishCoalesce(themeColor, () => ( _optionalChain([group, 'optionalAccess', _2 => _2.themeColor]))), () => ( "primary"));
250
- const resolvedVariant = _nullishCoalesce(_nullishCoalesce(variant, () => ( _optionalChain([group, 'optionalAccess', _3 => _3.variant]))), () => ( "filled"));
251
- const resolvedSize = _nullishCoalesce(_nullishCoalesce(size, () => ( _optionalChain([group, 'optionalAccess', _4 => _4.size]))), () => ( "md"));
252
- const resolvedRadius = _nullishCoalesce(_nullishCoalesce(radius, () => ( _optionalChain([group, 'optionalAccess', _5 => _5.radius]))), () => ( "full"));
253
- const resolvedFullWidth = _nullishCoalesce(_nullishCoalesce(fullWidth, () => ( _optionalChain([group, 'optionalAccess', _6 => _6.fullWidth]))), () => ( false));
254
- const resolvedDisabled = !!(isDisabled || _optionalChain([group, 'optionalAccess', _7 => _7.isDisabled]));
255
- const isInGroup = !!group && typeof value === "string";
256
- const isControlledStandalone = typeof isCheckedProp === "boolean";
257
- const [internalChecked, setInternalChecked] = _react.useState.call(void 0, defaultChecked);
258
- const groupChecked = isInGroup ? group.selectedValue === value : false;
259
- const isChecked = isInGroup ? groupChecked : isControlledStandalone ? isCheckedProp : internalChecked;
260
- const colorScheme = theme.colors[_core.getSafeThemeColor.call(void 0, resolvedThemeColor)];
261
- const scale = _react.useRef.call(void 0, new _reactnative.Animated.Value(1)).current;
262
- const backgroundScale = _react.useRef.call(void 0, new _reactnative.Animated.Value(0.5)).current;
263
- const backgroundOpacity = _react.useRef.call(void 0, new _reactnative.Animated.Value(0)).current;
264
- const dotScale = _react.useRef.call(void 0, new _reactnative.Animated.Value(isChecked ? 1 : 0)).current;
265
- const dotOpacity = _react.useRef.call(void 0, new _reactnative.Animated.Value(isChecked ? 1 : 0)).current;
266
- const sizeStyles = useSizeStyles(resolvedSize, resolvedVariant);
267
- const radiusStyles = useRadiusStyles(resolvedRadius);
268
- const dotColors = useDotColors(resolvedThemeColor, resolvedVariant, isChecked);
269
- const variantStyles = useVariantStyles(
270
- resolvedThemeColor,
271
- resolvedVariant,
272
- isChecked
273
- );
274
- const containerStyles = useContainerStyles(resolvedLabelAlignment);
275
- _react.useEffect.call(void 0, () => {
276
- if (resolvedVariant !== "filled") return;
277
- if (isChecked) {
278
- runBackgroundInAnimation(backgroundScale, backgroundOpacity);
279
- } else {
280
- runBackgroundOutAnimation(backgroundScale, backgroundOpacity);
281
- }
282
- }, [backgroundOpacity, backgroundScale, isChecked, resolvedVariant]);
283
- _react.useEffect.call(void 0, () => {
284
- if (isChecked) {
285
- runDotInAnimation(dotScale, dotOpacity);
286
- } else {
287
- runDotOutAnimation(dotScale, dotOpacity);
288
- }
289
- }, [dotOpacity, dotScale, isChecked]);
290
- const handlePress = () => {
291
- if (resolvedDisabled || isChecked) return;
292
- if (isInGroup && value) {
293
- _optionalChain([group, 'access', _8 => _8.onValueChange, 'optionalCall', _9 => _9(value)]);
294
- _optionalChain([onValueChange, 'optionalCall', _10 => _10(true)]);
295
- return;
296
- }
297
- if (!isControlledStandalone) {
298
- setInternalChecked(true);
299
- }
300
- _optionalChain([onValueChange, 'optionalCall', _11 => _11(true)]);
301
- };
302
- const handlePressIn = () => {
303
- if (resolvedDisabled) return;
304
- runPressInAnimation(scale);
305
- };
306
- const handlePressOut = () => {
307
- if (resolvedDisabled) return;
308
- runPressOutAnimation(scale);
309
- };
310
- return /* @__PURE__ */ _react2.default.createElement(
311
- _reactnative.Pressable,
312
- {
313
- onPress: handlePress,
314
- onPressIn: handlePressIn,
315
- onPressOut: handlePressOut,
316
- disabled: resolvedDisabled,
317
- accessible: true,
318
- accessibilityRole: "radio",
319
- accessibilityLabel: label,
320
- accessibilityState: {
321
- disabled: resolvedDisabled,
322
- checked: !!isChecked
323
- },
324
- style: [
325
- styles.container,
326
- containerStyles,
327
- resolvedFullWidth && styles.fullWidth,
328
- resolvedDisabled && styles.disabled,
329
- style
330
- ]
331
- },
332
- /* @__PURE__ */ _react2.default.createElement(
333
- _reactnative.Animated.View,
334
- {
335
- style: [
336
- styles.radio,
337
- {
338
- width: sizeStyles.radioSize,
339
- height: sizeStyles.radioSize,
340
- ...radiusStyles,
341
- ...variantStyles
342
- },
343
- {
344
- transform: [{ scale }]
345
- }
346
- ]
347
- },
348
- resolvedVariant === "filled" && /* @__PURE__ */ _react2.default.createElement(
349
- _reactnative.Animated.View,
350
- {
351
- style: [
352
- styles.background,
353
- radiusStyles,
354
- {
355
- backgroundColor: colorScheme.main,
356
- transform: [{ scale: backgroundScale }],
357
- opacity: backgroundOpacity
358
- }
359
- ]
360
- }
361
- ),
362
- /* @__PURE__ */ _react2.default.createElement(
363
- _reactnative.Animated.View,
364
- {
365
- style: [
366
- styles.dot,
367
- {
368
- width: sizeStyles.dotSize,
369
- height: sizeStyles.dotSize,
370
- borderRadius: sizeStyles.dotSize / 2,
371
- backgroundColor: dotColors.checked,
372
- opacity: dotOpacity,
373
- transform: [{ scale: dotScale }]
374
- }
375
- ]
376
- }
377
- )
378
- ),
379
- label && /* @__PURE__ */ _react2.default.createElement(
380
- _reactnative.Text,
381
- {
382
- style: [
383
- styles.label,
384
- { fontSize: sizeStyles.fontSize, color: theme.colors.foreground },
385
- resolvedDisabled && styles.disabledText,
386
- labelStyle
387
- ]
388
- },
389
- label
390
- )
391
- );
392
- };
393
-
394
- // src/components/radio/radio-group.tsx
395
-
396
-
397
- var RadioGroup = ({
398
- children,
399
- value,
400
- defaultValue,
401
- onValueChange,
402
- isDisabled = false,
403
- themeColor = "primary",
404
- variant = "filled",
405
- size = "md",
406
- radius = "full",
407
- labelAlignment = "right",
408
- fullWidth = false,
409
- orientation = "vertical",
410
- gap,
411
- style
412
- }) => {
413
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
414
- const isControlled = typeof value === "string";
415
- const [internalValue, setInternalValue] = _react.useState.call(void 0, defaultValue);
416
- const selectedValue = isControlled ? value : internalValue;
417
- const handleValueChange = (nextValue) => {
418
- if (nextValue === selectedValue) return;
419
- if (!isControlled) {
420
- setInternalValue(nextValue);
421
- }
422
- _optionalChain([onValueChange, 'optionalCall', _12 => _12(nextValue)]);
423
- };
424
- const contextValue = _react.useMemo.call(void 0,
425
- () => ({
426
- selectedValue,
427
- isDisabled,
428
- themeColor,
429
- variant,
430
- size,
431
- radius,
432
- labelAlignment,
433
- fullWidth,
434
- onValueChange: handleValueChange
435
- }),
436
- [
437
- fullWidth,
438
- isDisabled,
439
- labelAlignment,
440
- radius,
441
- selectedValue,
442
- size,
443
- themeColor,
444
- variant
445
- ]
446
- );
447
- return /* @__PURE__ */ _react2.default.createElement(RadioGroupContext.Provider, { value: contextValue }, /* @__PURE__ */ _react2.default.createElement(
448
- _reactnative.View,
449
- {
450
- style: [
451
- styles.group,
452
- {
453
- flexDirection: orientation === "horizontal" ? "row" : "column",
454
- gap: _nullishCoalesce(gap, () => ( theme.spacing.sm))
455
- },
456
- style
457
- ]
458
- },
459
- children
460
- ));
461
- };
462
-
463
-
464
-
465
- exports.Radio = Radio; exports.RadioGroup = RadioGroup;