@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,290 +0,0 @@
1
- import {
2
- ActivityIndicator
3
- } from "./chunk-VSZEXOUN.js";
4
- import {
5
- useXUITheme
6
- } from "./chunk-RBSA4NH4.js";
7
-
8
- // src/components/fab/fab.tsx
9
- import React from "react";
10
- import { Pressable, Text, View, Animated as Animated2 } from "react-native";
11
-
12
- // src/components/fab/fab.style.ts
13
- import { StyleSheet } from "react-native";
14
- var styles = StyleSheet.create({
15
- container: {
16
- alignSelf: "flex-start"
17
- },
18
- fab: {
19
- flexDirection: "row",
20
- alignItems: "center",
21
- justifyContent: "center",
22
- overflow: "hidden"
23
- },
24
- contentContainer: {
25
- flexDirection: "row",
26
- alignItems: "center",
27
- justifyContent: "center",
28
- gap: 12
29
- },
30
- label: {
31
- fontWeight: "500"
32
- },
33
- disabled: {
34
- opacity: 0.5
35
- }
36
- });
37
-
38
- // src/components/fab/fab.hook.ts
39
- import { useMemo } from "react";
40
- import { getSafeThemeColor } from "@xaui/core";
41
- function useFabSizeStyles(size) {
42
- const theme = useXUITheme();
43
- const sizeStyles = useMemo(() => {
44
- const sizes = {
45
- sm: {
46
- width: 40,
47
- height: 40,
48
- borderRadius: theme.borderRadius.lg,
49
- iconSize: 24,
50
- fontSize: theme.fontSizes.sm
51
- },
52
- md: {
53
- width: 56,
54
- height: 56,
55
- borderRadius: theme.borderRadius.xl,
56
- iconSize: 24,
57
- fontSize: theme.fontSizes.md
58
- },
59
- lg: {
60
- width: 96,
61
- height: 96,
62
- borderRadius: theme.borderRadius["2xl"],
63
- iconSize: 36,
64
- fontSize: theme.fontSizes.lg
65
- }
66
- };
67
- return sizes[size];
68
- }, [size, theme]);
69
- const extendedSizeStyles = useMemo(() => {
70
- const sizes = {
71
- sm: {
72
- height: 40,
73
- borderRadius: theme.borderRadius.lg,
74
- paddingHorizontal: theme.spacing.md,
75
- iconSize: 20,
76
- fontSize: theme.fontSizes.sm
77
- },
78
- md: {
79
- height: 56,
80
- borderRadius: theme.borderRadius.xl,
81
- paddingHorizontal: theme.spacing.lg,
82
- iconSize: 24,
83
- fontSize: theme.fontSizes.md
84
- },
85
- lg: {
86
- height: 80,
87
- borderRadius: theme.borderRadius["2xl"],
88
- paddingHorizontal: theme.spacing.xl,
89
- iconSize: 28,
90
- fontSize: theme.fontSizes.lg
91
- }
92
- };
93
- return sizes[size];
94
- }, [size, theme]);
95
- return { sizeStyles, extendedSizeStyles };
96
- }
97
- function useFabVariantStyles(themeColor, variant, elevation = 0) {
98
- const theme = useXUITheme();
99
- const safeThemeColor = getSafeThemeColor(themeColor);
100
- const colorScheme = theme.colors[safeThemeColor];
101
- const variantStyles = useMemo(() => {
102
- const variantMap = {
103
- solid: {
104
- backgroundColor: colorScheme.main,
105
- borderWidth: 0
106
- },
107
- flat: {
108
- backgroundColor: colorScheme.container,
109
- borderWidth: 0
110
- },
111
- outlined: {
112
- backgroundColor: "transparent",
113
- borderWidth: theme.borderWidth.md,
114
- borderColor: colorScheme.main
115
- }
116
- };
117
- const baseStyle = variantMap[variant];
118
- const shouldApplyElevation = variant !== "outlined";
119
- const shadowStyles = elevation === 0 ? {} : elevation === 1 ? theme.shadows.sm : elevation === 2 ? theme.shadows.md : elevation === 3 ? theme.shadows.lg : theme.shadows.xl;
120
- return {
121
- ...baseStyle,
122
- ...shouldApplyElevation ? shadowStyles : {},
123
- ...shouldApplyElevation && elevation > 0 ? { elevation } : {}
124
- };
125
- }, [variant, colorScheme, theme, elevation]);
126
- return variantStyles;
127
- }
128
- function useFabIconColor(themeColor, variant) {
129
- const theme = useXUITheme();
130
- const safeThemeColor = getSafeThemeColor(themeColor);
131
- const colorScheme = theme.colors[safeThemeColor];
132
- const iconColor = useMemo(() => {
133
- if (variant === "solid") {
134
- return colorScheme.onMain;
135
- }
136
- if (variant === "flat") {
137
- return colorScheme.onContainer;
138
- }
139
- return colorScheme.main;
140
- }, [variant, colorScheme]);
141
- return { iconColor };
142
- }
143
- function useFabRadiusValue(radius, fallback) {
144
- const theme = useXUITheme();
145
- return useMemo(() => {
146
- if (!radius) return fallback;
147
- const radiusMap = {
148
- none: theme.borderRadius.none,
149
- sm: theme.borderRadius.sm,
150
- md: theme.borderRadius.md,
151
- lg: theme.borderRadius.lg,
152
- full: theme.borderRadius.full
153
- };
154
- return radiusMap[radius];
155
- }, [fallback, radius, theme]);
156
- }
157
-
158
- // src/components/fab/fab.animation.ts
159
- import { Animated } from "react-native";
160
- var runFabPressInAnimation = (animatedScale, animatedOpacity) => {
161
- Animated.parallel([
162
- Animated.spring(animatedScale, {
163
- toValue: 0.92,
164
- useNativeDriver: true,
165
- speed: 50,
166
- bounciness: 0
167
- }),
168
- Animated.timing(animatedOpacity, {
169
- toValue: 0.85,
170
- duration: 100,
171
- useNativeDriver: true
172
- })
173
- ]).start();
174
- };
175
- var runFabPressOutAnimation = (animatedScale, animatedOpacity) => {
176
- Animated.parallel([
177
- Animated.spring(animatedScale, {
178
- toValue: 1,
179
- useNativeDriver: true,
180
- speed: 50,
181
- bounciness: 0
182
- }),
183
- Animated.timing(animatedOpacity, {
184
- toValue: 1,
185
- duration: 100,
186
- useNativeDriver: true
187
- })
188
- ]).start();
189
- };
190
-
191
- // src/components/fab/fab.tsx
192
- var Fab = ({
193
- icon,
194
- label,
195
- themeColor = "primary",
196
- variant = "solid",
197
- size = "md",
198
- radius,
199
- isDisabled = false,
200
- isLoading = false,
201
- elevation = 0,
202
- customAppearance,
203
- onPress,
204
- onLongPress,
205
- onPressIn,
206
- onPressOut
207
- }) => {
208
- const animatedScale = React.useRef(new Animated2.Value(1)).current;
209
- const animatedOpacity = React.useRef(new Animated2.Value(1)).current;
210
- const { sizeStyles, extendedSizeStyles } = useFabSizeStyles(size);
211
- const variantStyles = useFabVariantStyles(themeColor, variant, elevation);
212
- const { iconColor } = useFabIconColor(themeColor, variant);
213
- const isExtended = !!label;
214
- const resolvedRadius = useFabRadiusValue(
215
- radius,
216
- isExtended ? extendedSizeStyles.borderRadius : sizeStyles.borderRadius
217
- );
218
- const handlePressIn = (event) => {
219
- if (!isDisabled && !isLoading) {
220
- runFabPressInAnimation(animatedScale, animatedOpacity);
221
- }
222
- onPressIn?.(event);
223
- };
224
- const handlePressOut = (event) => {
225
- if (!isDisabled && !isLoading) {
226
- runFabPressOutAnimation(animatedScale, animatedOpacity);
227
- }
228
- onPressOut?.(event);
229
- };
230
- const fabDimensionStyles = isExtended ? {
231
- height: extendedSizeStyles.height,
232
- borderRadius: resolvedRadius,
233
- paddingHorizontal: extendedSizeStyles.paddingHorizontal
234
- } : {
235
- width: sizeStyles.width,
236
- height: sizeStyles.height,
237
- borderRadius: resolvedRadius
238
- };
239
- return /* @__PURE__ */ React.createElement(View, { style: [styles.container, customAppearance?.container] }, /* @__PURE__ */ React.createElement(
240
- Pressable,
241
- {
242
- onPress: isDisabled || isLoading ? void 0 : onPress,
243
- onLongPress: isDisabled || isLoading ? void 0 : onLongPress,
244
- onPressIn: handlePressIn,
245
- onPressOut: handlePressOut,
246
- disabled: isDisabled || isLoading
247
- },
248
- /* @__PURE__ */ React.createElement(
249
- Animated2.View,
250
- {
251
- style: [
252
- styles.fab,
253
- fabDimensionStyles,
254
- variantStyles,
255
- isDisabled && styles.disabled,
256
- {
257
- transform: [{ scale: animatedScale }],
258
- opacity: animatedOpacity
259
- },
260
- customAppearance?.fab
261
- ]
262
- },
263
- isLoading ? /* @__PURE__ */ React.createElement(
264
- ActivityIndicator,
265
- {
266
- variant: "circular",
267
- themeColor: variant === "solid" ? void 0 : themeColor,
268
- color: variant === "solid" ? iconColor : void 0,
269
- size: isExtended ? extendedSizeStyles.iconSize : sizeStyles.iconSize
270
- }
271
- ) : /* @__PURE__ */ React.createElement(View, { style: styles.contentContainer }, icon, isExtended && /* @__PURE__ */ React.createElement(
272
- Text,
273
- {
274
- style: [
275
- styles.label,
276
- {
277
- fontSize: isExtended ? extendedSizeStyles.fontSize : sizeStyles.fontSize,
278
- color: iconColor
279
- }
280
- ]
281
- },
282
- label
283
- ))
284
- )
285
- ));
286
- };
287
-
288
- export {
289
- Fab
290
- };
@@ -1,384 +0,0 @@
1
- import {
2
- useXUITheme
3
- } from "./chunk-RBSA4NH4.js";
4
-
5
- // src/components/indicator/indicator.tsx
6
- import React3 from "react";
7
- import { View as View3 } from "react-native";
8
-
9
- // src/components/indicator/circular-activity-indicator.tsx
10
- import React, { useEffect, useRef } from "react";
11
- import { Animated, Easing, Platform, View } from "react-native";
12
-
13
- // src/components/indicator/indicator.style.ts
14
- import { StyleSheet } from "react-native";
15
- var styles = StyleSheet.create({
16
- container: {
17
- flexShrink: 1,
18
- flexBasis: "auto",
19
- width: "100%",
20
- justifyContent: "center"
21
- },
22
- layer: {
23
- ...StyleSheet.absoluteFillObject,
24
- justifyContent: "center",
25
- alignItems: "center"
26
- },
27
- track: {
28
- width: "100%",
29
- overflow: "hidden"
30
- },
31
- progress: {
32
- height: "100%"
33
- }
34
- });
35
-
36
- // src/components/indicator/circular-activity-indicator.tsx
37
- import { getSafeThemeColor } from "@xaui/core";
38
- var DURATION = 1800;
39
- var CircularActivityIndicator = ({
40
- size = 40,
41
- themeColor = "primary",
42
- color,
43
- backgroundColor,
44
- disableAnimation = false,
45
- showTrack = true
46
- }) => {
47
- const theme = useXUITheme();
48
- const { current: timer } = useRef(new Animated.Value(0));
49
- const rotation = useRef(void 0);
50
- const startRotation = React.useCallback(() => {
51
- if (rotation.current) {
52
- timer.setValue(0);
53
- Animated.loop(rotation.current).start();
54
- }
55
- }, [timer]);
56
- const stopRotation = () => {
57
- if (rotation.current) rotation.current.stop();
58
- };
59
- useEffect(() => {
60
- if (rotation.current === void 0) {
61
- rotation.current = Animated.timing(timer, {
62
- duration: DURATION,
63
- easing: Easing.linear,
64
- useNativeDriver: Platform.OS !== "web",
65
- toValue: 1
66
- });
67
- }
68
- if (!disableAnimation) startRotation();
69
- else stopRotation();
70
- }, [disableAnimation, startRotation, timer]);
71
- const safeThemeColor = getSafeThemeColor(themeColor);
72
- const colorScheme = theme.colors[safeThemeColor];
73
- const mainColor = color || colorScheme.main;
74
- const trackColor = showTrack ? backgroundColor ?? colorScheme.container : "transparent";
75
- const strokeWidth = size * 0.1;
76
- const frames = 60 * DURATION / 1e3;
77
- const easing = Easing.bezier(0.4, 0, 0.7, 1);
78
- const containerStyle = {
79
- width: size,
80
- height: size / 2,
81
- overflow: "hidden"
82
- };
83
- return /* @__PURE__ */ React.createElement(View, { style: [styles.container, { width: size, height: size }] }, /* @__PURE__ */ React.createElement(
84
- View,
85
- {
86
- style: {
87
- width: size,
88
- height: size,
89
- borderRadius: size / 2,
90
- borderWidth: strokeWidth,
91
- borderColor: trackColor
92
- }
93
- }
94
- ), /* @__PURE__ */ React.createElement(
95
- View,
96
- {
97
- style: {
98
- width: size,
99
- height: size,
100
- position: "absolute"
101
- }
102
- },
103
- [0, 1].map((index) => {
104
- const inputRange = Array.from(
105
- new Array(frames),
106
- (_, frameIndex) => frameIndex / (frames - 1)
107
- );
108
- const outputRange = Array.from(new Array(frames), (_, frameIndex) => {
109
- let progress = 2 * frameIndex / (frames - 1);
110
- const rotationValue = index ? +(360 - 15) : -(180 - 15);
111
- if (progress > 1) {
112
- progress = 2 - progress;
113
- }
114
- const direction = index ? -1 : 1;
115
- return `${direction * (180 - 30) * easing(progress) + rotationValue}deg`;
116
- });
117
- const layerStyle = {
118
- width: size,
119
- height: size,
120
- transform: [
121
- {
122
- rotate: timer.interpolate({
123
- inputRange: [0, 1],
124
- outputRange: [`${0 + 30 + 15}deg`, `${2 * 360 + 30 + 15}deg`]
125
- })
126
- }
127
- ]
128
- };
129
- const viewportStyle = {
130
- width: size,
131
- height: size,
132
- transform: [
133
- { translateY: index ? -size / 2 : 0 },
134
- {
135
- rotate: timer.interpolate({ inputRange, outputRange })
136
- }
137
- ]
138
- };
139
- const offsetStyle = index ? { top: size / 2 } : null;
140
- const lineStyle = {
141
- width: size,
142
- height: size,
143
- borderColor: mainColor,
144
- borderWidth: strokeWidth,
145
- borderRadius: size / 2
146
- };
147
- return /* @__PURE__ */ React.createElement(Animated.View, { key: index, style: [styles.layer] }, /* @__PURE__ */ React.createElement(Animated.View, { style: layerStyle }, /* @__PURE__ */ React.createElement(
148
- Animated.View,
149
- {
150
- style: [containerStyle, offsetStyle],
151
- collapsable: false
152
- },
153
- /* @__PURE__ */ React.createElement(Animated.View, { style: viewportStyle }, /* @__PURE__ */ React.createElement(Animated.View, { style: containerStyle, collapsable: false }, /* @__PURE__ */ React.createElement(Animated.View, { style: lineStyle })))
154
- )));
155
- })
156
- ));
157
- };
158
-
159
- // src/components/indicator/linear-activity-indicator.tsx
160
- import React2 from "react";
161
- import { StyleSheet as StyleSheet2, View as View2 } from "react-native";
162
- import Animated2, { useAnimatedStyle } from "react-native-reanimated";
163
-
164
- // src/components/indicator/indicator.hook.ts
165
- import { useEffect as useEffect2 } from "react";
166
- import {
167
- Easing as Easing2,
168
- cancelAnimation,
169
- useSharedValue,
170
- withRepeat,
171
- withSequence,
172
- withTiming
173
- } from "react-native-reanimated";
174
- var useLinearActivityIndicatorAnimation = (disableAnimation) => {
175
- const primaryTranslateX = useSharedValue(0);
176
- const primaryScaleX = useSharedValue(0.08);
177
- const secondaryTranslateX = useSharedValue(0);
178
- const secondaryScaleX = useSharedValue(0.08);
179
- useEffect2(() => {
180
- if (disableAnimation) {
181
- cancelAnimation(primaryTranslateX);
182
- cancelAnimation(primaryScaleX);
183
- cancelAnimation(secondaryTranslateX);
184
- cancelAnimation(secondaryScaleX);
185
- return;
186
- }
187
- primaryTranslateX.value = withRepeat(
188
- withSequence(
189
- withTiming(0, { duration: 0 }),
190
- withTiming(0, { duration: 400, easing: Easing2.linear }),
191
- withTiming(0.836714, {
192
- duration: 783,
193
- easing: Easing2.bezier(0.5, 0, 0.701732, 0.495819)
194
- }),
195
- withTiming(2.00611, {
196
- duration: 817,
197
- easing: Easing2.bezier(0.302435, 0.381352, 0.55, 0.956352)
198
- })
199
- ),
200
- -1,
201
- false
202
- );
203
- primaryScaleX.value = withRepeat(
204
- withSequence(
205
- withTiming(0.08, { duration: 0 }),
206
- withTiming(0.08, { duration: 733, easing: Easing2.linear }),
207
- withTiming(0.661479, {
208
- duration: 650,
209
- easing: Easing2.bezier(0.334731, 0.12482, 0.785844, 1)
210
- }),
211
- withTiming(0.08, {
212
- duration: 617,
213
- easing: Easing2.bezier(0.06, 0.11, 0.6, 1)
214
- })
215
- ),
216
- -1,
217
- false
218
- );
219
- secondaryTranslateX.value = withRepeat(
220
- withSequence(
221
- withTiming(0, { duration: 0 }),
222
- withTiming(0.376519, {
223
- duration: 500,
224
- easing: Easing2.bezier(0.15, 0, 0.515058, 0.409685)
225
- }),
226
- withTiming(0.843862, {
227
- duration: 467,
228
- easing: Easing2.bezier(0.31033, 0.284058, 0.8, 0.733712)
229
- }),
230
- withTiming(1.60278, {
231
- duration: 1033,
232
- easing: Easing2.bezier(0.4, 0.627035, 0.6, 0.902026)
233
- })
234
- ),
235
- -1,
236
- false
237
- );
238
- secondaryScaleX.value = withRepeat(
239
- withSequence(
240
- withTiming(0.08, { duration: 0 }),
241
- withTiming(0.457104, {
242
- duration: 383,
243
- easing: Easing2.bezier(0.205028, 0.057051, 0.57661, 0.453971)
244
- }),
245
- withTiming(0.72796, {
246
- duration: 500,
247
- easing: Easing2.bezier(0.152313, 0.196432, 0.648374, 1.00432)
248
- }),
249
- withTiming(0.08, {
250
- duration: 1117,
251
- easing: Easing2.bezier(0.257759, -3163e-6, 0.211762, 1.38179)
252
- })
253
- ),
254
- -1,
255
- false
256
- );
257
- return () => {
258
- cancelAnimation(primaryTranslateX);
259
- cancelAnimation(primaryScaleX);
260
- cancelAnimation(secondaryTranslateX);
261
- cancelAnimation(secondaryScaleX);
262
- };
263
- }, [disableAnimation]);
264
- return {
265
- primaryTranslateX,
266
- primaryScaleX,
267
- secondaryTranslateX,
268
- secondaryScaleX
269
- };
270
- };
271
-
272
- // src/components/indicator/linear-activity-indicator.tsx
273
- var LinearActivityIndicator = ({
274
- size = 4,
275
- themeColor = "primary",
276
- color,
277
- backgroundColor,
278
- disableAnimation = false,
279
- borderRadius = 0,
280
- showTrack = true
281
- }) => {
282
- const theme = useXUITheme();
283
- const { primaryTranslateX, primaryScaleX, secondaryTranslateX, secondaryScaleX } = useLinearActivityIndicatorAnimation(disableAnimation);
284
- const colorScheme = theme.colors[themeColor];
285
- const mainColor = color || colorScheme.main;
286
- const trackColor = showTrack ? backgroundColor ?? colorScheme.container : "transparent";
287
- const barStyle = {
288
- ...StyleSheet2.absoluteFillObject,
289
- backgroundColor: mainColor,
290
- borderRadius
291
- };
292
- const primaryStyle = useAnimatedStyle(() => ({
293
- transform: [
294
- { translateX: `${(primaryTranslateX.value - 1.45167) * 100}%` },
295
- { scaleX: primaryScaleX.value }
296
- ]
297
- }));
298
- const secondaryStyle = useAnimatedStyle(() => ({
299
- transform: [
300
- { translateX: `${(secondaryTranslateX.value - 0.548889) * 100}%` },
301
- { scaleX: secondaryScaleX.value }
302
- ]
303
- }));
304
- return /* @__PURE__ */ React2.createElement(
305
- View2,
306
- {
307
- style: {
308
- height: size,
309
- width: "100%",
310
- borderRadius,
311
- backgroundColor: trackColor,
312
- overflow: "hidden"
313
- }
314
- },
315
- /* @__PURE__ */ React2.createElement(Animated2.View, { style: [barStyle, primaryStyle] }),
316
- /* @__PURE__ */ React2.createElement(Animated2.View, { style: [barStyle, secondaryStyle] })
317
- );
318
- };
319
-
320
- // src/components/indicator/indicator.tsx
321
- var ActivityIndicator = (props) => {
322
- const {
323
- variant = "circular",
324
- themeColor = "primary",
325
- color,
326
- backgroundColor,
327
- size,
328
- disableAnimation = false,
329
- borderRadius,
330
- showTrack
331
- } = props;
332
- const theme = useXUITheme();
333
- const colorScheme = theme.colors[themeColor];
334
- const mainColor = color ?? colorScheme.main;
335
- const trackColor = backgroundColor ?? (showTrack ? colorScheme.container : "transparent");
336
- if (variant === "circular") {
337
- const circleSize = size ?? 40;
338
- return /* @__PURE__ */ React3.createElement(
339
- View3,
340
- {
341
- style: [styles.container, { width: circleSize, height: circleSize }],
342
- accessible: true,
343
- accessibilityRole: "progressbar",
344
- accessibilityLabel: "Loading"
345
- },
346
- /* @__PURE__ */ React3.createElement(
347
- CircularActivityIndicator,
348
- {
349
- size: circleSize,
350
- themeColor,
351
- color: mainColor,
352
- backgroundColor: trackColor,
353
- disableAnimation
354
- }
355
- )
356
- );
357
- }
358
- const linearSize = size ?? 4;
359
- return /* @__PURE__ */ React3.createElement(
360
- View3,
361
- {
362
- style: styles.container,
363
- accessible: true,
364
- accessibilityRole: "progressbar",
365
- accessibilityLabel: "Loading"
366
- },
367
- /* @__PURE__ */ React3.createElement(
368
- LinearActivityIndicator,
369
- {
370
- size: linearSize,
371
- themeColor,
372
- color: mainColor,
373
- backgroundColor: trackColor,
374
- disableAnimation,
375
- borderRadius,
376
- showTrack
377
- }
378
- )
379
- );
380
- };
381
-
382
- export {
383
- ActivityIndicator
384
- };