@xaui/native 0.2.7 → 0.9.1-alpha.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 (224) hide show
  1. package/dist/chunk-JDS6KGCM.cjs +791 -0
  2. package/dist/chunk-T3ZI2PZ6.js +791 -0
  3. package/dist/index.cjs +32 -1
  4. package/dist/index.d.cts +2 -2
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +32 -0
  7. package/dist/theme/index.cjs +32 -0
  8. package/dist/theme/index.d.cts +669 -0
  9. package/dist/theme/index.d.ts +669 -0
  10. package/dist/theme/index.js +32 -0
  11. package/package.json +26 -249
  12. package/README.md +0 -178
  13. package/dist/alert/index.cjs +0 -356
  14. package/dist/alert/index.d.cts +0 -90
  15. package/dist/alert/index.d.ts +0 -90
  16. package/dist/alert/index.js +0 -356
  17. package/dist/app-bar/index.cjs +0 -148
  18. package/dist/app-bar/index.d.cts +0 -59
  19. package/dist/app-bar/index.d.ts +0 -59
  20. package/dist/app-bar/index.js +0 -148
  21. package/dist/autocomplete/index.cjs +0 -1122
  22. package/dist/autocomplete/index.d.cts +0 -88
  23. package/dist/autocomplete/index.d.ts +0 -88
  24. package/dist/autocomplete/index.js +0 -1122
  25. package/dist/avatar/index.cjs +0 -281
  26. package/dist/avatar/index.d.cts +0 -123
  27. package/dist/avatar/index.d.ts +0 -123
  28. package/dist/avatar/index.js +0 -281
  29. package/dist/badge/index.cjs +0 -197
  30. package/dist/badge/index.d.cts +0 -94
  31. package/dist/badge/index.d.ts +0 -94
  32. package/dist/badge/index.js +0 -197
  33. package/dist/bottom-sheet/index.cjs +0 -9
  34. package/dist/bottom-sheet/index.d.cts +0 -84
  35. package/dist/bottom-sheet/index.d.ts +0 -84
  36. package/dist/bottom-sheet/index.js +0 -9
  37. package/dist/bottom-tab-bar/index.cjs +0 -497
  38. package/dist/bottom-tab-bar/index.d.cts +0 -211
  39. package/dist/bottom-tab-bar/index.d.ts +0 -211
  40. package/dist/bottom-tab-bar/index.js +0 -497
  41. package/dist/button/index.cjs +0 -392
  42. package/dist/button/index.d.cts +0 -174
  43. package/dist/button/index.d.ts +0 -174
  44. package/dist/button/index.js +0 -392
  45. package/dist/button.type-j1ZdkkSl.d.cts +0 -4
  46. package/dist/button.type-j1ZdkkSl.d.ts +0 -4
  47. package/dist/card/index.cjs +0 -338
  48. package/dist/card/index.d.cts +0 -191
  49. package/dist/card/index.d.ts +0 -191
  50. package/dist/card/index.js +0 -338
  51. package/dist/carousel/index.cjs +0 -381
  52. package/dist/carousel/index.d.cts +0 -147
  53. package/dist/carousel/index.d.ts +0 -147
  54. package/dist/carousel/index.js +0 -381
  55. package/dist/chart/index.cjs +0 -1026
  56. package/dist/chart/index.d.cts +0 -218
  57. package/dist/chart/index.d.ts +0 -218
  58. package/dist/chart/index.js +0 -1026
  59. package/dist/checkbox/index.cjs +0 -443
  60. package/dist/checkbox/index.d.cts +0 -73
  61. package/dist/checkbox/index.d.ts +0 -73
  62. package/dist/checkbox/index.js +0 -443
  63. package/dist/chip/index.cjs +0 -503
  64. package/dist/chip/index.d.cts +0 -195
  65. package/dist/chip/index.d.ts +0 -195
  66. package/dist/chip/index.js +0 -503
  67. package/dist/chunk-4JFWQ5XT.js +0 -368
  68. package/dist/chunk-56RPWZD2.cjs +0 -9
  69. package/dist/chunk-7UFBLUMV.cjs +0 -136
  70. package/dist/chunk-A45TVXU5.js +0 -337
  71. package/dist/chunk-BYWUAPC4.cjs +0 -368
  72. package/dist/chunk-DECMUMCI.js +0 -0
  73. package/dist/chunk-DHSTKO3K.cjs +0 -19
  74. package/dist/chunk-DJ4Q37UT.cjs +0 -75
  75. package/dist/chunk-EUQDGTST.cjs +0 -1
  76. package/dist/chunk-GBHQCAKW.js +0 -19
  77. package/dist/chunk-RBSA4NH4.js +0 -136
  78. package/dist/chunk-SHBDANQN.js +0 -9
  79. package/dist/chunk-UGEINZM7.cjs +0 -290
  80. package/dist/chunk-UU4HHBDN.js +0 -290
  81. package/dist/chunk-VSZEXOUN.js +0 -384
  82. package/dist/chunk-YIEUN3G5.cjs +0 -384
  83. package/dist/chunk-ZH6ZSV2Q.cjs +0 -337
  84. package/dist/chunk-ZY7IUTAT.js +0 -75
  85. package/dist/color-picker/index.cjs +0 -457
  86. package/dist/color-picker/index.d.cts +0 -124
  87. package/dist/color-picker/index.d.ts +0 -124
  88. package/dist/color-picker/index.js +0 -457
  89. package/dist/core/index.cjs +0 -24
  90. package/dist/core/index.d.cts +0 -28
  91. package/dist/core/index.d.ts +0 -28
  92. package/dist/core/index.js +0 -24
  93. package/dist/datepicker/index.cjs +0 -1625
  94. package/dist/datepicker/index.d.cts +0 -45
  95. package/dist/datepicker/index.d.ts +0 -45
  96. package/dist/datepicker/index.js +0 -1625
  97. package/dist/dialog/index.cjs +0 -372
  98. package/dist/dialog/index.d.cts +0 -151
  99. package/dist/dialog/index.d.ts +0 -151
  100. package/dist/dialog/index.js +0 -372
  101. package/dist/divider/index.cjs +0 -8
  102. package/dist/divider/index.d.cts +0 -30
  103. package/dist/divider/index.d.ts +0 -30
  104. package/dist/divider/index.js +0 -8
  105. package/dist/drawer/index.cjs +0 -237
  106. package/dist/drawer/index.d.cts +0 -58
  107. package/dist/drawer/index.d.ts +0 -58
  108. package/dist/drawer/index.js +0 -237
  109. package/dist/expansion-panel/index.cjs +0 -441
  110. package/dist/expansion-panel/index.d.cts +0 -153
  111. package/dist/expansion-panel/index.d.ts +0 -153
  112. package/dist/expansion-panel/index.js +0 -441
  113. package/dist/fab/index.cjs +0 -9
  114. package/dist/fab/index.d.cts +0 -10
  115. package/dist/fab/index.d.ts +0 -10
  116. package/dist/fab/index.js +0 -9
  117. package/dist/fab-menu/index.cjs +0 -330
  118. package/dist/fab-menu/index.d.cts +0 -125
  119. package/dist/fab-menu/index.d.ts +0 -125
  120. package/dist/fab-menu/index.js +0 -330
  121. package/dist/fab.type-CkUHmXU_.d.ts +0 -86
  122. package/dist/fab.type-DN0vtAh6.d.cts +0 -86
  123. package/dist/feature-discovery/index.cjs +0 -464
  124. package/dist/feature-discovery/index.d.cts +0 -82
  125. package/dist/feature-discovery/index.d.ts +0 -82
  126. package/dist/feature-discovery/index.js +0 -464
  127. package/dist/indicator/index.cjs +0 -8
  128. package/dist/indicator/index.d.cts +0 -47
  129. package/dist/indicator/index.d.ts +0 -47
  130. package/dist/indicator/index.js +0 -8
  131. package/dist/input/index.cjs +0 -1462
  132. package/dist/input/index.d.cts +0 -522
  133. package/dist/input/index.d.ts +0 -522
  134. package/dist/input/index.js +0 -1462
  135. package/dist/input-trigger/index.cjs +0 -197
  136. package/dist/input-trigger/index.d.cts +0 -11
  137. package/dist/input-trigger/index.d.ts +0 -11
  138. package/dist/input-trigger/index.js +0 -197
  139. package/dist/input-trigger.type-Ba4bM3Qp.d.cts +0 -180
  140. package/dist/input-trigger.type-Ba4bM3Qp.d.ts +0 -180
  141. package/dist/list/index.cjs +0 -395
  142. package/dist/list/index.d.cts +0 -188
  143. package/dist/list/index.d.ts +0 -188
  144. package/dist/list/index.js +0 -395
  145. package/dist/menu/index.cjs +0 -316
  146. package/dist/menu/index.d.cts +0 -115
  147. package/dist/menu/index.d.ts +0 -115
  148. package/dist/menu/index.js +0 -316
  149. package/dist/menubox/index.cjs +0 -297
  150. package/dist/menubox/index.d.cts +0 -98
  151. package/dist/menubox/index.d.ts +0 -98
  152. package/dist/menubox/index.js +0 -297
  153. package/dist/pager/index.cjs +0 -205
  154. package/dist/pager/index.d.cts +0 -93
  155. package/dist/pager/index.d.ts +0 -93
  156. package/dist/pager/index.js +0 -205
  157. package/dist/picker/index.cjs +0 -244
  158. package/dist/picker/index.d.cts +0 -121
  159. package/dist/picker/index.d.ts +0 -121
  160. package/dist/picker/index.js +0 -244
  161. package/dist/progress/index.cjs +0 -219
  162. package/dist/progress/index.d.cts +0 -47
  163. package/dist/progress/index.d.ts +0 -47
  164. package/dist/progress/index.js +0 -219
  165. package/dist/radio/index.cjs +0 -465
  166. package/dist/radio/index.d.cts +0 -145
  167. package/dist/radio/index.d.ts +0 -145
  168. package/dist/radio/index.js +0 -465
  169. package/dist/refresh-control/index.cjs +0 -45
  170. package/dist/refresh-control/index.d.cts +0 -55
  171. package/dist/refresh-control/index.d.ts +0 -55
  172. package/dist/refresh-control/index.js +0 -45
  173. package/dist/segment-button/index.cjs +0 -405
  174. package/dist/segment-button/index.d.cts +0 -141
  175. package/dist/segment-button/index.d.ts +0 -141
  176. package/dist/segment-button/index.js +0 -405
  177. package/dist/select/index.cjs +0 -878
  178. package/dist/select/index.d.cts +0 -192
  179. package/dist/select/index.d.ts +0 -192
  180. package/dist/select/index.js +0 -878
  181. package/dist/skeleton/index.cjs +0 -89
  182. package/dist/skeleton/index.d.cts +0 -45
  183. package/dist/skeleton/index.d.ts +0 -45
  184. package/dist/skeleton/index.js +0 -89
  185. package/dist/slider/index.cjs +0 -576
  186. package/dist/slider/index.d.cts +0 -171
  187. package/dist/slider/index.d.ts +0 -171
  188. package/dist/slider/index.js +0 -576
  189. package/dist/snackbar/index.cjs +0 -436
  190. package/dist/snackbar/index.d.cts +0 -174
  191. package/dist/snackbar/index.d.ts +0 -174
  192. package/dist/snackbar/index.js +0 -436
  193. package/dist/snippet/index.cjs +0 -314
  194. package/dist/snippet/index.d.cts +0 -95
  195. package/dist/snippet/index.d.ts +0 -95
  196. package/dist/snippet/index.js +0 -314
  197. package/dist/stepper/index.cjs +0 -550
  198. package/dist/stepper/index.d.cts +0 -137
  199. package/dist/stepper/index.d.ts +0 -137
  200. package/dist/stepper/index.js +0 -550
  201. package/dist/switch/index.cjs +0 -358
  202. package/dist/switch/index.d.cts +0 -28
  203. package/dist/switch/index.d.ts +0 -28
  204. package/dist/switch/index.js +0 -358
  205. package/dist/tabs/index.cjs +0 -440
  206. package/dist/tabs/index.d.cts +0 -180
  207. package/dist/tabs/index.d.ts +0 -180
  208. package/dist/tabs/index.js +0 -440
  209. package/dist/timepicker/index.cjs +0 -823
  210. package/dist/timepicker/index.d.cts +0 -215
  211. package/dist/timepicker/index.d.ts +0 -215
  212. package/dist/timepicker/index.js +0 -823
  213. package/dist/toolbar/index.cjs +0 -333
  214. package/dist/toolbar/index.d.cts +0 -100
  215. package/dist/toolbar/index.d.ts +0 -100
  216. package/dist/toolbar/index.js +0 -333
  217. package/dist/typography/index.cjs +0 -238
  218. package/dist/typography/index.d.cts +0 -113
  219. package/dist/typography/index.d.ts +0 -113
  220. package/dist/typography/index.js +0 -238
  221. package/dist/view/index.cjs +0 -1361
  222. package/dist/view/index.d.cts +0 -833
  223. package/dist/view/index.d.ts +0 -833
  224. package/dist/view/index.js +0 -1361
@@ -1,358 +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/switch/switch.tsx
7
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
8
- var _reactnative = require('react-native');
9
-
10
- // src/components/switch/switch.hook.ts
11
-
12
- var _core = require('@xaui/core');
13
- var useSwitchColorScheme = (themeColor) => {
14
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
15
- const safeThemeColor = _core.getSafeThemeColor.call(void 0, themeColor);
16
- return theme.colors[safeThemeColor];
17
- };
18
- var useSwitchSizeStyles = (variant, size) => {
19
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
20
- const sizeStyles = _react.useMemo.call(void 0, () => {
21
- if (variant === "overlap") {
22
- const sizes2 = {
23
- sm: {
24
- trackWidth: 40,
25
- trackHeight: 16,
26
- thumbSize: 22,
27
- fontSize: theme.fontSizes.sm,
28
- padding: 0
29
- },
30
- md: {
31
- trackWidth: 48,
32
- trackHeight: 18,
33
- thumbSize: 26,
34
- fontSize: theme.fontSizes.md,
35
- padding: 0
36
- },
37
- lg: {
38
- trackWidth: 56,
39
- trackHeight: 20,
40
- thumbSize: 30,
41
- fontSize: theme.fontSizes.lg,
42
- padding: 0
43
- }
44
- };
45
- return sizes2[size];
46
- }
47
- const sizes = {
48
- sm: {
49
- trackWidth: 40,
50
- trackHeight: 24,
51
- thumbSize: 18,
52
- fontSize: theme.fontSizes.sm,
53
- padding: 3
54
- },
55
- md: {
56
- trackWidth: 48,
57
- trackHeight: 28,
58
- thumbSize: 22,
59
- fontSize: theme.fontSizes.md,
60
- padding: 3
61
- },
62
- lg: {
63
- trackWidth: 56,
64
- trackHeight: 32,
65
- thumbSize: 26,
66
- fontSize: theme.fontSizes.lg,
67
- padding: 3
68
- }
69
- };
70
- return sizes[size];
71
- }, [size, theme, variant]);
72
- return sizeStyles;
73
- };
74
- var useSwitchRadiusStyles = (radius) => {
75
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
76
- const radiusStyles = _react.useMemo.call(void 0, () => {
77
- const radii = {
78
- none: theme.borderRadius.none,
79
- sm: theme.borderRadius.sm,
80
- md: theme.borderRadius.md,
81
- lg: theme.borderRadius.lg,
82
- full: theme.borderRadius.full
83
- };
84
- return { borderRadius: radii[radius] };
85
- }, [radius, theme]);
86
- const thumbRadius = _react.useMemo.call(void 0, () => {
87
- const radii = {
88
- none: theme.borderRadius.none,
89
- sm: theme.borderRadius.sm,
90
- md: theme.borderRadius.md,
91
- lg: theme.borderRadius.lg,
92
- full: theme.borderRadius.full
93
- };
94
- return radii[radius];
95
- }, [radius, theme]);
96
- return { radiusStyles, thumbRadius };
97
- };
98
- var useSwitchTrackStyles = ({
99
- colorScheme,
100
- isSelected,
101
- variant,
102
- sizeStyles,
103
- radiusStyles
104
- }) => {
105
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
106
- const trackStyles = _react.useMemo.call(void 0, () => {
107
- const backgroundColor = isSelected ? variant === "overlap" ? colorScheme.container : colorScheme.main : theme.colors.default.container;
108
- return {
109
- width: sizeStyles.trackWidth,
110
- height: sizeStyles.trackHeight,
111
- backgroundColor,
112
- paddingHorizontal: sizeStyles.padding,
113
- ...radiusStyles
114
- };
115
- }, [colorScheme, isSelected, radiusStyles, sizeStyles, theme, variant]);
116
- return trackStyles;
117
- };
118
- var useSwitchThumbStyles = ({
119
- colorScheme,
120
- isSelected,
121
- variant,
122
- sizeStyles,
123
- thumbRadius
124
- }) => {
125
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
126
- const thumbStyles = _react.useMemo.call(void 0, () => {
127
- const baseStyle = {
128
- width: sizeStyles.thumbSize,
129
- height: sizeStyles.thumbSize,
130
- borderRadius: thumbRadius,
131
- backgroundColor: variant === "overlap" && isSelected ? colorScheme.main : theme.colors.background
132
- };
133
- if (variant !== "overlap") return baseStyle;
134
- return {
135
- ...baseStyle,
136
- ...theme.shadows.sm
137
- };
138
- }, [colorScheme, isSelected, sizeStyles, theme, thumbRadius, variant]);
139
- return thumbStyles;
140
- };
141
- var useSwitchContainerStyles = (labelAlignment) => {
142
- const containerStyles = _react.useMemo.call(void 0, () => {
143
- const isJustified = labelAlignment === "justify-left" || labelAlignment === "justify-right";
144
- return {
145
- flexDirection: labelAlignment === "left" || labelAlignment === "justify-left" ? "row-reverse" : "row",
146
- justifyContent: isJustified ? "space-between" : "flex-start"
147
- };
148
- }, [labelAlignment]);
149
- return containerStyles;
150
- };
151
-
152
- // src/components/switch/switch.animation.ts
153
-
154
- var runThumbPositionAnimation = (thumbPosition, isSelected) => {
155
- _reactnative.Animated.spring(thumbPosition, {
156
- toValue: isSelected ? 1 : 0,
157
- useNativeDriver: true,
158
- damping: 15,
159
- stiffness: 150
160
- }).start();
161
- };
162
- var runSwitchPressInAnimation = (animatedScale, animatedThumbScale, isOverlap) => {
163
- _reactnative.Animated.parallel([
164
- _reactnative.Animated.spring(animatedScale, {
165
- toValue: 0.95,
166
- useNativeDriver: true
167
- }),
168
- _reactnative.Animated.spring(animatedThumbScale, {
169
- toValue: isOverlap ? 1.1 : 1.2,
170
- useNativeDriver: true
171
- })
172
- ]).start();
173
- };
174
- var runSwitchPressOutAnimation = (animatedScale, animatedThumbScale) => {
175
- _reactnative.Animated.parallel([
176
- _reactnative.Animated.spring(animatedScale, {
177
- toValue: 1,
178
- useNativeDriver: true
179
- }),
180
- _reactnative.Animated.spring(animatedThumbScale, {
181
- toValue: 1,
182
- useNativeDriver: true
183
- })
184
- ]).start();
185
- };
186
-
187
- // src/components/switch/switch.style.ts
188
-
189
- var styles = _reactnative.StyleSheet.create({
190
- container: {
191
- flexDirection: "row",
192
- alignItems: "center",
193
- gap: 8
194
- },
195
- fullWidth: {
196
- width: "100%"
197
- },
198
- track: {
199
- justifyContent: "center",
200
- position: "relative"
201
- },
202
- thumbContainer: {
203
- position: "relative",
204
- width: "100%",
205
- height: "100%",
206
- alignItems: "center",
207
- justifyContent: "center"
208
- },
209
- thumb: {
210
- position: "absolute",
211
- left: 0
212
- },
213
- label: {
214
- fontWeight: "400"
215
- },
216
- disabled: {
217
- opacity: 0.5
218
- },
219
- disabledText: {
220
- opacity: 0.7
221
- }
222
- });
223
-
224
- // src/components/switch/switch.tsx
225
- var Switch = ({
226
- label,
227
- labelAlignment = "right",
228
- themeColor = "primary",
229
- variant = "inside",
230
- size = "md",
231
- radius = "full",
232
- fullWidth = false,
233
- isSelected: isSelectedProp,
234
- isDisabled = false,
235
- labelStyle,
236
- style,
237
- onValueChange
238
- }) => {
239
- const theme = _chunk7UFBLUMVcjs.useXUITheme.call(void 0, );
240
- const isControlled = typeof isSelectedProp === "boolean";
241
- const [internalSelected, setInternalSelected] = _react.useState.call(void 0, _nullishCoalesce(isSelectedProp, () => ( false)));
242
- const isSelected = isControlled ? isSelectedProp : internalSelected;
243
- const scale = _react.useRef.call(void 0, new _reactnative.Animated.Value(1)).current;
244
- const thumbPosition = _react.useRef.call(void 0, new _reactnative.Animated.Value(isSelected ? 1 : 0)).current;
245
- const thumbScale = _react.useRef.call(void 0, new _reactnative.Animated.Value(1)).current;
246
- const colorScheme = useSwitchColorScheme(themeColor);
247
- const sizeStyles = useSwitchSizeStyles(variant, size);
248
- const { radiusStyles, thumbRadius } = useSwitchRadiusStyles(radius);
249
- const trackStyles = useSwitchTrackStyles({
250
- colorScheme,
251
- isSelected,
252
- variant,
253
- sizeStyles,
254
- radiusStyles
255
- });
256
- const thumbStyles = useSwitchThumbStyles({
257
- colorScheme,
258
- isSelected,
259
- variant,
260
- sizeStyles,
261
- thumbRadius
262
- });
263
- const containerStyles = useSwitchContainerStyles(labelAlignment);
264
- const maxTranslateX = _react.useMemo.call(void 0, () => {
265
- if (variant === "overlap") {
266
- return sizeStyles.trackWidth - sizeStyles.thumbSize;
267
- }
268
- return sizeStyles.trackWidth - sizeStyles.thumbSize - sizeStyles.padding * 2;
269
- }, [sizeStyles, variant]);
270
- const translateX = _react.useMemo.call(void 0,
271
- () => thumbPosition.interpolate({
272
- inputRange: [0, 1],
273
- outputRange: [0, maxTranslateX]
274
- }),
275
- [maxTranslateX, thumbPosition]
276
- );
277
- _react.useEffect.call(void 0, () => {
278
- runThumbPositionAnimation(thumbPosition, isSelected);
279
- }, [isSelected, thumbPosition]);
280
- const handlePress = () => {
281
- if (isDisabled) return;
282
- const nextValue = !isSelected;
283
- _optionalChain([onValueChange, 'optionalCall', _ => _(nextValue)]);
284
- if (!isControlled) {
285
- setInternalSelected(nextValue);
286
- }
287
- };
288
- const handlePressIn = () => {
289
- if (isDisabled) return;
290
- runSwitchPressInAnimation(scale, thumbScale, variant === "overlap");
291
- };
292
- const handlePressOut = () => {
293
- if (isDisabled) return;
294
- runSwitchPressOutAnimation(scale, thumbScale);
295
- };
296
- return /* @__PURE__ */ _react2.default.createElement(
297
- _reactnative.Pressable,
298
- {
299
- onPress: handlePress,
300
- onPressIn: handlePressIn,
301
- onPressOut: handlePressOut,
302
- disabled: isDisabled,
303
- accessible: true,
304
- accessibilityRole: "switch",
305
- accessibilityLabel: label,
306
- accessibilityState: {
307
- disabled: isDisabled,
308
- checked: isSelected
309
- },
310
- style: [
311
- styles.container,
312
- containerStyles,
313
- fullWidth && styles.fullWidth,
314
- isDisabled && styles.disabled,
315
- style
316
- ]
317
- },
318
- /* @__PURE__ */ _react2.default.createElement(
319
- _reactnative.Animated.View,
320
- {
321
- style: [
322
- styles.track,
323
- trackStyles,
324
- {
325
- transform: [{ scale }]
326
- }
327
- ]
328
- },
329
- /* @__PURE__ */ _react2.default.createElement(_reactnative.View, { style: styles.thumbContainer }, /* @__PURE__ */ _react2.default.createElement(
330
- _reactnative.Animated.View,
331
- {
332
- style: [
333
- styles.thumb,
334
- thumbStyles,
335
- {
336
- transform: [{ translateX }, { scale: thumbScale }]
337
- }
338
- ]
339
- }
340
- ))
341
- ),
342
- label && /* @__PURE__ */ _react2.default.createElement(
343
- _reactnative.Text,
344
- {
345
- style: [
346
- styles.label,
347
- { fontSize: sizeStyles.fontSize, color: theme.colors.foreground },
348
- isDisabled && styles.disabledText,
349
- labelStyle
350
- ]
351
- },
352
- label
353
- )
354
- );
355
- };
356
-
357
-
358
- exports.Switch = Switch;
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import { TextStyle, ViewStyle } from 'react-native';
3
- import { ThemeColor } from '@xaui/core/types';
4
-
5
- type SwitchVariant = 'inside' | 'overlap';
6
- type SwitchSize = 'sm' | 'md' | 'lg';
7
- type SwitchRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
8
- type SwitchLabelAlignment = 'left' | 'right' | 'justify-left' | 'justify-right';
9
- type SwitchEvents = {
10
- onValueChange?: (isSelected: boolean) => void;
11
- };
12
- type SwitchProps = {
13
- label?: string;
14
- labelAlignment?: SwitchLabelAlignment;
15
- themeColor?: ThemeColor;
16
- variant?: SwitchVariant;
17
- size?: SwitchSize;
18
- radius?: SwitchRadius;
19
- fullWidth?: boolean;
20
- isSelected?: boolean;
21
- isDisabled?: boolean;
22
- labelStyle?: TextStyle;
23
- style?: ViewStyle;
24
- } & SwitchEvents;
25
-
26
- declare const Switch: React.FC<SwitchProps>;
27
-
28
- export { Switch, type SwitchLabelAlignment, type SwitchProps, type SwitchRadius, type SwitchSize, type SwitchVariant };
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import { TextStyle, ViewStyle } from 'react-native';
3
- import { ThemeColor } from '@xaui/core/types';
4
-
5
- type SwitchVariant = 'inside' | 'overlap';
6
- type SwitchSize = 'sm' | 'md' | 'lg';
7
- type SwitchRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
8
- type SwitchLabelAlignment = 'left' | 'right' | 'justify-left' | 'justify-right';
9
- type SwitchEvents = {
10
- onValueChange?: (isSelected: boolean) => void;
11
- };
12
- type SwitchProps = {
13
- label?: string;
14
- labelAlignment?: SwitchLabelAlignment;
15
- themeColor?: ThemeColor;
16
- variant?: SwitchVariant;
17
- size?: SwitchSize;
18
- radius?: SwitchRadius;
19
- fullWidth?: boolean;
20
- isSelected?: boolean;
21
- isDisabled?: boolean;
22
- labelStyle?: TextStyle;
23
- style?: ViewStyle;
24
- } & SwitchEvents;
25
-
26
- declare const Switch: React.FC<SwitchProps>;
27
-
28
- export { Switch, type SwitchLabelAlignment, type SwitchProps, type SwitchRadius, type SwitchSize, type SwitchVariant };