@xaui/native 0.0.21 → 0.0.24
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.
- package/README.md +195 -2
- package/dist/alert/index.js +1 -2
- package/dist/app-bar/index.cjs +217 -0
- package/dist/app-bar/index.d.cts +52 -0
- package/dist/app-bar/index.d.ts +52 -0
- package/dist/app-bar/index.js +142 -0
- package/dist/autocomplete/index.js +48 -36
- package/dist/avatar/index.js +1 -2
- package/dist/badge/index.js +1 -2
- package/dist/bottom-sheet/index.js +1 -2
- package/dist/bottom-tab-bar/index.cjs +571 -0
- package/dist/bottom-tab-bar/index.d.cts +211 -0
- package/dist/bottom-tab-bar/index.d.ts +211 -0
- package/dist/bottom-tab-bar/index.js +497 -0
- package/dist/button/index.d.cts +102 -5
- package/dist/button/index.d.ts +102 -5
- package/dist/button/index.js +2 -3
- package/dist/button.type-j1ZdkkSl.d.cts +4 -0
- package/dist/button.type-j1ZdkkSl.d.ts +4 -0
- package/dist/card/index.cjs +2 -0
- package/dist/card/index.d.cts +6 -1
- package/dist/card/index.d.ts +6 -1
- package/dist/card/index.js +4 -2
- package/dist/carousel/index.js +1 -1
- package/dist/chart/index.cjs +1067 -0
- package/dist/chart/index.d.cts +218 -0
- package/dist/chart/index.d.ts +218 -0
- package/dist/chart/index.js +1026 -0
- package/dist/checkbox/index.js +1 -2
- package/dist/chip/index.js +1 -2
- package/dist/chunk-3XSXTM3G.js +661 -0
- package/dist/chunk-4KSZLONZ.js +79 -0
- package/dist/{chunk-DXXNBF5P.js → chunk-CZFDZPAS.js} +0 -5
- package/dist/{chunk-LTKYHG5V.js → chunk-GHCVNQET.js} +12 -5
- package/dist/chunk-I4V5Y5GD.js +76 -0
- package/dist/{chunk-F7WH4DMG.js → chunk-UI5L26KD.js} +1 -1
- package/dist/{chunk-LUBWRVI2.js → chunk-ULJSCNPE.js} +1 -1
- package/dist/chunk-URBEEDFX.js +79 -0
- package/dist/core/index.js +3 -5
- package/dist/datepicker/index.js +1 -2
- package/dist/divider/index.js +2 -3
- package/dist/drawer/index.cjs +310 -0
- package/dist/drawer/index.d.cts +58 -0
- package/dist/drawer/index.d.ts +58 -0
- package/dist/drawer/index.js +236 -0
- package/dist/{accordion → expansion-panel}/index.cjs +45 -45
- package/dist/{accordion → expansion-panel}/index.d.cts +30 -30
- package/dist/{accordion → expansion-panel}/index.d.ts +30 -30
- package/dist/{accordion → expansion-panel}/index.js +40 -41
- package/dist/fab/index.d.cts +3 -3
- package/dist/fab/index.d.ts +3 -3
- package/dist/fab/index.js +3 -4
- package/dist/fab-menu/index.d.cts +2 -2
- package/dist/fab-menu/index.d.ts +2 -2
- package/dist/fab-menu/index.js +3 -4
- package/dist/{fab.type-Ba0QMprb.d.ts → fab.type-CgIYqQlT.d.ts} +1 -1
- package/dist/{fab.type-U09H8B7D.d.cts → fab.type-l2vjG8-p.d.cts} +1 -1
- package/dist/feature-discovery/index.cjs +531 -0
- package/dist/feature-discovery/index.d.cts +82 -0
- package/dist/feature-discovery/index.d.ts +82 -0
- package/dist/feature-discovery/index.js +464 -0
- package/dist/indicator/index.js +2 -3
- package/dist/input/index.cjs +258 -164
- package/dist/input/index.d.cts +15 -1
- package/dist/input/index.d.ts +15 -1
- package/dist/input/index.js +219 -126
- package/dist/list/index.js +1 -2
- package/dist/menu/index.js +2 -2
- package/dist/menubox/index.cjs +369 -0
- package/dist/menubox/index.d.cts +98 -0
- package/dist/menubox/index.d.ts +98 -0
- package/dist/menubox/index.js +296 -0
- package/dist/pager/index.cjs +243 -0
- package/dist/pager/index.d.cts +93 -0
- package/dist/pager/index.d.ts +93 -0
- package/dist/pager/index.js +205 -0
- package/dist/progress/index.js +1 -2
- package/dist/radio/index.cjs +537 -0
- package/dist/radio/index.d.cts +145 -0
- package/dist/radio/index.d.ts +145 -0
- package/dist/radio/index.js +464 -0
- package/dist/segment-button/index.js +2 -2
- package/dist/select/index.js +22 -10
- package/dist/skeleton/index.js +2 -2
- package/dist/slider/index.cjs +655 -0
- package/dist/slider/index.d.cts +171 -0
- package/dist/slider/index.d.ts +171 -0
- package/dist/slider/index.js +575 -0
- package/dist/stepper/index.cjs +624 -0
- package/dist/stepper/index.d.cts +137 -0
- package/dist/stepper/index.d.ts +137 -0
- package/dist/stepper/index.js +549 -0
- package/dist/switch/index.js +1 -2
- package/dist/tabs/index.cjs +523 -0
- package/dist/tabs/index.d.cts +176 -0
- package/dist/tabs/index.d.ts +176 -0
- package/dist/tabs/index.js +438 -0
- package/dist/timepicker/index.cjs +1280 -0
- package/dist/timepicker/index.d.cts +215 -0
- package/dist/timepicker/index.d.ts +215 -0
- package/dist/timepicker/index.js +1181 -0
- package/dist/toolbar/index.cjs +395 -0
- package/dist/toolbar/index.d.cts +100 -0
- package/dist/toolbar/index.d.ts +100 -0
- package/dist/toolbar/index.js +325 -0
- package/dist/typography/index.js +1 -2
- package/dist/view/index.cjs +16 -2
- package/dist/view/index.js +16 -2
- package/package.json +73 -8
- package/dist/button.type-D8tzEBo7.d.ts +0 -104
- package/dist/button.type-ikaWzhIg.d.cts +0 -104
- package/dist/chunk-GBHQCAKW.js +0 -19
- package/dist/chunk-JEGEPGVU.js +0 -287
package/dist/checkbox/index.js
CHANGED
package/dist/chip/index.js
CHANGED
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useXUITheme
|
|
3
|
+
} from "./chunk-I4V5Y5GD.js";
|
|
4
|
+
|
|
5
|
+
// src/components/fab/fab.tsx
|
|
6
|
+
import React4 from "react";
|
|
7
|
+
import { Pressable, Text, View as View4, Animated as Animated4 } from "react-native";
|
|
8
|
+
|
|
9
|
+
// src/components/indicator/indicator.tsx
|
|
10
|
+
import React3 from "react";
|
|
11
|
+
import { View as View3 } from "react-native";
|
|
12
|
+
|
|
13
|
+
// src/components/indicator/circular-activity-indicator.tsx
|
|
14
|
+
import React, { useEffect, useRef } from "react";
|
|
15
|
+
import { Animated, Easing, Platform, View } from "react-native";
|
|
16
|
+
|
|
17
|
+
// src/components/indicator/indicator.style.ts
|
|
18
|
+
import { StyleSheet } from "react-native";
|
|
19
|
+
var styles = StyleSheet.create({
|
|
20
|
+
container: {
|
|
21
|
+
flexShrink: 1,
|
|
22
|
+
flexBasis: "auto",
|
|
23
|
+
width: "100%",
|
|
24
|
+
justifyContent: "center"
|
|
25
|
+
},
|
|
26
|
+
layer: {
|
|
27
|
+
...StyleSheet.absoluteFillObject,
|
|
28
|
+
justifyContent: "center",
|
|
29
|
+
alignItems: "center"
|
|
30
|
+
},
|
|
31
|
+
track: {
|
|
32
|
+
width: "100%",
|
|
33
|
+
overflow: "hidden"
|
|
34
|
+
},
|
|
35
|
+
progress: {
|
|
36
|
+
height: "100%"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// src/components/indicator/circular-activity-indicator.tsx
|
|
41
|
+
import { getSafeThemeColor } from "@xaui/core";
|
|
42
|
+
var DURATION = 1800;
|
|
43
|
+
var CircularActivityIndicator = ({
|
|
44
|
+
size = 40,
|
|
45
|
+
themeColor = "primary",
|
|
46
|
+
color,
|
|
47
|
+
backgroundColor,
|
|
48
|
+
disableAnimation = false,
|
|
49
|
+
showTrack = true
|
|
50
|
+
}) => {
|
|
51
|
+
const theme = useXUITheme();
|
|
52
|
+
const { current: timer } = useRef(new Animated.Value(0));
|
|
53
|
+
const rotation = useRef(void 0);
|
|
54
|
+
const startRotation = React.useCallback(() => {
|
|
55
|
+
if (rotation.current) {
|
|
56
|
+
timer.setValue(0);
|
|
57
|
+
Animated.loop(rotation.current).start();
|
|
58
|
+
}
|
|
59
|
+
}, [timer]);
|
|
60
|
+
const stopRotation = () => {
|
|
61
|
+
if (rotation.current) rotation.current.stop();
|
|
62
|
+
};
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (rotation.current === void 0) {
|
|
65
|
+
rotation.current = Animated.timing(timer, {
|
|
66
|
+
duration: DURATION,
|
|
67
|
+
easing: Easing.linear,
|
|
68
|
+
useNativeDriver: Platform.OS !== "web",
|
|
69
|
+
toValue: 1
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (!disableAnimation) startRotation();
|
|
73
|
+
else stopRotation();
|
|
74
|
+
}, [disableAnimation, startRotation, timer]);
|
|
75
|
+
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
76
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
77
|
+
const mainColor = color || colorScheme.main;
|
|
78
|
+
const trackColor = showTrack ? backgroundColor ?? colorScheme.background : "transparent";
|
|
79
|
+
const strokeWidth = size * 0.1;
|
|
80
|
+
const frames = 60 * DURATION / 1e3;
|
|
81
|
+
const easing = Easing.bezier(0.4, 0, 0.7, 1);
|
|
82
|
+
const containerStyle = {
|
|
83
|
+
width: size,
|
|
84
|
+
height: size / 2,
|
|
85
|
+
overflow: "hidden"
|
|
86
|
+
};
|
|
87
|
+
return /* @__PURE__ */ React.createElement(View, { style: [styles.container, { width: size, height: size }] }, /* @__PURE__ */ React.createElement(
|
|
88
|
+
View,
|
|
89
|
+
{
|
|
90
|
+
style: {
|
|
91
|
+
width: size,
|
|
92
|
+
height: size,
|
|
93
|
+
borderRadius: size / 2,
|
|
94
|
+
borderWidth: strokeWidth,
|
|
95
|
+
borderColor: trackColor
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
), /* @__PURE__ */ React.createElement(
|
|
99
|
+
View,
|
|
100
|
+
{
|
|
101
|
+
style: {
|
|
102
|
+
width: size,
|
|
103
|
+
height: size,
|
|
104
|
+
position: "absolute"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
[0, 1].map((index) => {
|
|
108
|
+
const inputRange = Array.from(
|
|
109
|
+
new Array(frames),
|
|
110
|
+
(_, frameIndex) => frameIndex / (frames - 1)
|
|
111
|
+
);
|
|
112
|
+
const outputRange = Array.from(new Array(frames), (_, frameIndex) => {
|
|
113
|
+
let progress = 2 * frameIndex / (frames - 1);
|
|
114
|
+
const rotationValue = index ? +(360 - 15) : -(180 - 15);
|
|
115
|
+
if (progress > 1) {
|
|
116
|
+
progress = 2 - progress;
|
|
117
|
+
}
|
|
118
|
+
const direction = index ? -1 : 1;
|
|
119
|
+
return `${direction * (180 - 30) * easing(progress) + rotationValue}deg`;
|
|
120
|
+
});
|
|
121
|
+
const layerStyle = {
|
|
122
|
+
width: size,
|
|
123
|
+
height: size,
|
|
124
|
+
transform: [
|
|
125
|
+
{
|
|
126
|
+
rotate: timer.interpolate({
|
|
127
|
+
inputRange: [0, 1],
|
|
128
|
+
outputRange: [`${0 + 30 + 15}deg`, `${2 * 360 + 30 + 15}deg`]
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
]
|
|
132
|
+
};
|
|
133
|
+
const viewportStyle = {
|
|
134
|
+
width: size,
|
|
135
|
+
height: size,
|
|
136
|
+
transform: [
|
|
137
|
+
{ translateY: index ? -size / 2 : 0 },
|
|
138
|
+
{
|
|
139
|
+
rotate: timer.interpolate({ inputRange, outputRange })
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
};
|
|
143
|
+
const offsetStyle = index ? { top: size / 2 } : null;
|
|
144
|
+
const lineStyle = {
|
|
145
|
+
width: size,
|
|
146
|
+
height: size,
|
|
147
|
+
borderColor: mainColor,
|
|
148
|
+
borderWidth: strokeWidth,
|
|
149
|
+
borderRadius: size / 2
|
|
150
|
+
};
|
|
151
|
+
return /* @__PURE__ */ React.createElement(Animated.View, { key: index, style: [styles.layer] }, /* @__PURE__ */ React.createElement(Animated.View, { style: layerStyle }, /* @__PURE__ */ React.createElement(
|
|
152
|
+
Animated.View,
|
|
153
|
+
{
|
|
154
|
+
style: [containerStyle, offsetStyle],
|
|
155
|
+
collapsable: false
|
|
156
|
+
},
|
|
157
|
+
/* @__PURE__ */ React.createElement(Animated.View, { style: viewportStyle }, /* @__PURE__ */ React.createElement(Animated.View, { style: containerStyle, collapsable: false }, /* @__PURE__ */ React.createElement(Animated.View, { style: lineStyle })))
|
|
158
|
+
)));
|
|
159
|
+
})
|
|
160
|
+
));
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// src/components/indicator/linear-activity-indicator.tsx
|
|
164
|
+
import React2 from "react";
|
|
165
|
+
import { StyleSheet as StyleSheet2, View as View2 } from "react-native";
|
|
166
|
+
import Animated2, { useAnimatedStyle } from "react-native-reanimated";
|
|
167
|
+
|
|
168
|
+
// src/components/indicator/indicator.hook.ts
|
|
169
|
+
import { useEffect as useEffect2 } from "react";
|
|
170
|
+
import {
|
|
171
|
+
Easing as Easing2,
|
|
172
|
+
cancelAnimation,
|
|
173
|
+
useSharedValue,
|
|
174
|
+
withRepeat,
|
|
175
|
+
withSequence,
|
|
176
|
+
withTiming
|
|
177
|
+
} from "react-native-reanimated";
|
|
178
|
+
var useLinearActivityIndicatorAnimation = (disableAnimation) => {
|
|
179
|
+
const primaryTranslateX = useSharedValue(0);
|
|
180
|
+
const primaryScaleX = useSharedValue(0.08);
|
|
181
|
+
const secondaryTranslateX = useSharedValue(0);
|
|
182
|
+
const secondaryScaleX = useSharedValue(0.08);
|
|
183
|
+
useEffect2(() => {
|
|
184
|
+
if (disableAnimation) {
|
|
185
|
+
cancelAnimation(primaryTranslateX);
|
|
186
|
+
cancelAnimation(primaryScaleX);
|
|
187
|
+
cancelAnimation(secondaryTranslateX);
|
|
188
|
+
cancelAnimation(secondaryScaleX);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
primaryTranslateX.value = withRepeat(
|
|
192
|
+
withSequence(
|
|
193
|
+
withTiming(0, { duration: 0 }),
|
|
194
|
+
withTiming(0, { duration: 400, easing: Easing2.linear }),
|
|
195
|
+
withTiming(0.836714, {
|
|
196
|
+
duration: 783,
|
|
197
|
+
easing: Easing2.bezier(0.5, 0, 0.701732, 0.495819)
|
|
198
|
+
}),
|
|
199
|
+
withTiming(2.00611, {
|
|
200
|
+
duration: 817,
|
|
201
|
+
easing: Easing2.bezier(0.302435, 0.381352, 0.55, 0.956352)
|
|
202
|
+
})
|
|
203
|
+
),
|
|
204
|
+
-1,
|
|
205
|
+
false
|
|
206
|
+
);
|
|
207
|
+
primaryScaleX.value = withRepeat(
|
|
208
|
+
withSequence(
|
|
209
|
+
withTiming(0.08, { duration: 0 }),
|
|
210
|
+
withTiming(0.08, { duration: 733, easing: Easing2.linear }),
|
|
211
|
+
withTiming(0.661479, {
|
|
212
|
+
duration: 650,
|
|
213
|
+
easing: Easing2.bezier(0.334731, 0.12482, 0.785844, 1)
|
|
214
|
+
}),
|
|
215
|
+
withTiming(0.08, {
|
|
216
|
+
duration: 617,
|
|
217
|
+
easing: Easing2.bezier(0.06, 0.11, 0.6, 1)
|
|
218
|
+
})
|
|
219
|
+
),
|
|
220
|
+
-1,
|
|
221
|
+
false
|
|
222
|
+
);
|
|
223
|
+
secondaryTranslateX.value = withRepeat(
|
|
224
|
+
withSequence(
|
|
225
|
+
withTiming(0, { duration: 0 }),
|
|
226
|
+
withTiming(0.376519, {
|
|
227
|
+
duration: 500,
|
|
228
|
+
easing: Easing2.bezier(0.15, 0, 0.515058, 0.409685)
|
|
229
|
+
}),
|
|
230
|
+
withTiming(0.843862, {
|
|
231
|
+
duration: 467,
|
|
232
|
+
easing: Easing2.bezier(0.31033, 0.284058, 0.8, 0.733712)
|
|
233
|
+
}),
|
|
234
|
+
withTiming(1.60278, {
|
|
235
|
+
duration: 1033,
|
|
236
|
+
easing: Easing2.bezier(0.4, 0.627035, 0.6, 0.902026)
|
|
237
|
+
})
|
|
238
|
+
),
|
|
239
|
+
-1,
|
|
240
|
+
false
|
|
241
|
+
);
|
|
242
|
+
secondaryScaleX.value = withRepeat(
|
|
243
|
+
withSequence(
|
|
244
|
+
withTiming(0.08, { duration: 0 }),
|
|
245
|
+
withTiming(0.457104, {
|
|
246
|
+
duration: 383,
|
|
247
|
+
easing: Easing2.bezier(0.205028, 0.057051, 0.57661, 0.453971)
|
|
248
|
+
}),
|
|
249
|
+
withTiming(0.72796, {
|
|
250
|
+
duration: 500,
|
|
251
|
+
easing: Easing2.bezier(0.152313, 0.196432, 0.648374, 1.00432)
|
|
252
|
+
}),
|
|
253
|
+
withTiming(0.08, {
|
|
254
|
+
duration: 1117,
|
|
255
|
+
easing: Easing2.bezier(0.257759, -3163e-6, 0.211762, 1.38179)
|
|
256
|
+
})
|
|
257
|
+
),
|
|
258
|
+
-1,
|
|
259
|
+
false
|
|
260
|
+
);
|
|
261
|
+
return () => {
|
|
262
|
+
cancelAnimation(primaryTranslateX);
|
|
263
|
+
cancelAnimation(primaryScaleX);
|
|
264
|
+
cancelAnimation(secondaryTranslateX);
|
|
265
|
+
cancelAnimation(secondaryScaleX);
|
|
266
|
+
};
|
|
267
|
+
}, [disableAnimation]);
|
|
268
|
+
return {
|
|
269
|
+
primaryTranslateX,
|
|
270
|
+
primaryScaleX,
|
|
271
|
+
secondaryTranslateX,
|
|
272
|
+
secondaryScaleX
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// src/components/indicator/linear-activity-indicator.tsx
|
|
277
|
+
var LinearActivityIndicator = ({
|
|
278
|
+
size = 4,
|
|
279
|
+
themeColor = "primary",
|
|
280
|
+
color,
|
|
281
|
+
backgroundColor,
|
|
282
|
+
disableAnimation = false,
|
|
283
|
+
borderRadius = 0,
|
|
284
|
+
showTrack = true
|
|
285
|
+
}) => {
|
|
286
|
+
const theme = useXUITheme();
|
|
287
|
+
const { primaryTranslateX, primaryScaleX, secondaryTranslateX, secondaryScaleX } = useLinearActivityIndicatorAnimation(disableAnimation);
|
|
288
|
+
const colorScheme = theme.colors[themeColor];
|
|
289
|
+
const mainColor = color || colorScheme.main;
|
|
290
|
+
const trackColor = showTrack ? backgroundColor ?? colorScheme.background : "transparent";
|
|
291
|
+
const barStyle = {
|
|
292
|
+
...StyleSheet2.absoluteFillObject,
|
|
293
|
+
backgroundColor: mainColor,
|
|
294
|
+
borderRadius
|
|
295
|
+
};
|
|
296
|
+
const primaryStyle = useAnimatedStyle(() => ({
|
|
297
|
+
transform: [
|
|
298
|
+
{ translateX: `${(primaryTranslateX.value - 1.45167) * 100}%` },
|
|
299
|
+
{ scaleX: primaryScaleX.value }
|
|
300
|
+
]
|
|
301
|
+
}));
|
|
302
|
+
const secondaryStyle = useAnimatedStyle(() => ({
|
|
303
|
+
transform: [
|
|
304
|
+
{ translateX: `${(secondaryTranslateX.value - 0.548889) * 100}%` },
|
|
305
|
+
{ scaleX: secondaryScaleX.value }
|
|
306
|
+
]
|
|
307
|
+
}));
|
|
308
|
+
return /* @__PURE__ */ React2.createElement(
|
|
309
|
+
View2,
|
|
310
|
+
{
|
|
311
|
+
style: {
|
|
312
|
+
height: size,
|
|
313
|
+
width: "100%",
|
|
314
|
+
borderRadius,
|
|
315
|
+
backgroundColor: trackColor,
|
|
316
|
+
overflow: "hidden"
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
/* @__PURE__ */ React2.createElement(Animated2.View, { style: [barStyle, primaryStyle] }),
|
|
320
|
+
/* @__PURE__ */ React2.createElement(Animated2.View, { style: [barStyle, secondaryStyle] })
|
|
321
|
+
);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// src/components/indicator/indicator.tsx
|
|
325
|
+
var ActivityIndicator = (props) => {
|
|
326
|
+
const {
|
|
327
|
+
variant = "circular",
|
|
328
|
+
themeColor = "primary",
|
|
329
|
+
color,
|
|
330
|
+
backgroundColor,
|
|
331
|
+
size,
|
|
332
|
+
disableAnimation = false,
|
|
333
|
+
borderRadius,
|
|
334
|
+
showTrack
|
|
335
|
+
} = props;
|
|
336
|
+
const theme = useXUITheme();
|
|
337
|
+
const colorScheme = theme.colors[themeColor];
|
|
338
|
+
const mainColor = color ?? colorScheme.main;
|
|
339
|
+
const trackColor = backgroundColor ?? (showTrack ? colorScheme.background : "transparent");
|
|
340
|
+
if (variant === "circular") {
|
|
341
|
+
const circleSize = size ?? 40;
|
|
342
|
+
return /* @__PURE__ */ React3.createElement(
|
|
343
|
+
View3,
|
|
344
|
+
{
|
|
345
|
+
style: [styles.container, { width: circleSize, height: circleSize }],
|
|
346
|
+
accessible: true,
|
|
347
|
+
accessibilityRole: "progressbar",
|
|
348
|
+
accessibilityLabel: "Loading"
|
|
349
|
+
},
|
|
350
|
+
/* @__PURE__ */ React3.createElement(
|
|
351
|
+
CircularActivityIndicator,
|
|
352
|
+
{
|
|
353
|
+
size: circleSize,
|
|
354
|
+
themeColor,
|
|
355
|
+
color: mainColor,
|
|
356
|
+
backgroundColor: trackColor,
|
|
357
|
+
disableAnimation
|
|
358
|
+
}
|
|
359
|
+
)
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
const linearSize = size ?? 4;
|
|
363
|
+
return /* @__PURE__ */ React3.createElement(
|
|
364
|
+
View3,
|
|
365
|
+
{
|
|
366
|
+
style: styles.container,
|
|
367
|
+
accessible: true,
|
|
368
|
+
accessibilityRole: "progressbar",
|
|
369
|
+
accessibilityLabel: "Loading"
|
|
370
|
+
},
|
|
371
|
+
/* @__PURE__ */ React3.createElement(
|
|
372
|
+
LinearActivityIndicator,
|
|
373
|
+
{
|
|
374
|
+
size: linearSize,
|
|
375
|
+
themeColor,
|
|
376
|
+
color: mainColor,
|
|
377
|
+
backgroundColor: trackColor,
|
|
378
|
+
disableAnimation,
|
|
379
|
+
borderRadius,
|
|
380
|
+
showTrack
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
);
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// src/components/fab/fab.style.ts
|
|
387
|
+
import { StyleSheet as StyleSheet3 } from "react-native";
|
|
388
|
+
var styles2 = StyleSheet3.create({
|
|
389
|
+
container: {
|
|
390
|
+
alignSelf: "flex-start"
|
|
391
|
+
},
|
|
392
|
+
fab: {
|
|
393
|
+
flexDirection: "row",
|
|
394
|
+
alignItems: "center",
|
|
395
|
+
justifyContent: "center",
|
|
396
|
+
overflow: "hidden"
|
|
397
|
+
},
|
|
398
|
+
contentContainer: {
|
|
399
|
+
flexDirection: "row",
|
|
400
|
+
alignItems: "center",
|
|
401
|
+
justifyContent: "center",
|
|
402
|
+
gap: 12
|
|
403
|
+
},
|
|
404
|
+
label: {
|
|
405
|
+
fontWeight: "500"
|
|
406
|
+
},
|
|
407
|
+
disabled: {
|
|
408
|
+
opacity: 0.5
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// src/components/fab/fab.hook.ts
|
|
413
|
+
import { useMemo } from "react";
|
|
414
|
+
import { getSafeThemeColor as getSafeThemeColor2 } from "@xaui/core";
|
|
415
|
+
function useFabSizeStyles(size) {
|
|
416
|
+
const theme = useXUITheme();
|
|
417
|
+
const sizeStyles = useMemo(() => {
|
|
418
|
+
const sizes = {
|
|
419
|
+
sm: {
|
|
420
|
+
width: 40,
|
|
421
|
+
height: 40,
|
|
422
|
+
borderRadius: theme.borderRadius.lg,
|
|
423
|
+
iconSize: 24,
|
|
424
|
+
fontSize: theme.fontSizes.sm
|
|
425
|
+
},
|
|
426
|
+
md: {
|
|
427
|
+
width: 56,
|
|
428
|
+
height: 56,
|
|
429
|
+
borderRadius: theme.borderRadius.xl,
|
|
430
|
+
iconSize: 24,
|
|
431
|
+
fontSize: theme.fontSizes.md
|
|
432
|
+
},
|
|
433
|
+
lg: {
|
|
434
|
+
width: 96,
|
|
435
|
+
height: 96,
|
|
436
|
+
borderRadius: theme.borderRadius["2xl"],
|
|
437
|
+
iconSize: 36,
|
|
438
|
+
fontSize: theme.fontSizes.lg
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
return sizes[size];
|
|
442
|
+
}, [size, theme]);
|
|
443
|
+
const extendedSizeStyles = useMemo(() => {
|
|
444
|
+
const sizes = {
|
|
445
|
+
sm: {
|
|
446
|
+
height: 40,
|
|
447
|
+
borderRadius: theme.borderRadius.lg,
|
|
448
|
+
paddingHorizontal: theme.spacing.md,
|
|
449
|
+
iconSize: 20,
|
|
450
|
+
fontSize: theme.fontSizes.sm
|
|
451
|
+
},
|
|
452
|
+
md: {
|
|
453
|
+
height: 56,
|
|
454
|
+
borderRadius: theme.borderRadius.xl,
|
|
455
|
+
paddingHorizontal: theme.spacing.lg,
|
|
456
|
+
iconSize: 24,
|
|
457
|
+
fontSize: theme.fontSizes.md
|
|
458
|
+
},
|
|
459
|
+
lg: {
|
|
460
|
+
height: 80,
|
|
461
|
+
borderRadius: theme.borderRadius["2xl"],
|
|
462
|
+
paddingHorizontal: theme.spacing.xl,
|
|
463
|
+
iconSize: 28,
|
|
464
|
+
fontSize: theme.fontSizes.lg
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
return sizes[size];
|
|
468
|
+
}, [size, theme]);
|
|
469
|
+
return { sizeStyles, extendedSizeStyles };
|
|
470
|
+
}
|
|
471
|
+
function useFabVariantStyles(themeColor, variant, elevation = 0) {
|
|
472
|
+
const theme = useXUITheme();
|
|
473
|
+
const safeThemeColor = getSafeThemeColor2(themeColor);
|
|
474
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
475
|
+
const variantStyles = useMemo(() => {
|
|
476
|
+
const variantMap = {
|
|
477
|
+
solid: {
|
|
478
|
+
backgroundColor: colorScheme.main,
|
|
479
|
+
borderWidth: 0
|
|
480
|
+
},
|
|
481
|
+
flat: {
|
|
482
|
+
backgroundColor: colorScheme.background,
|
|
483
|
+
borderWidth: 0
|
|
484
|
+
},
|
|
485
|
+
outlined: {
|
|
486
|
+
backgroundColor: "transparent",
|
|
487
|
+
borderWidth: theme.borderWidth.md,
|
|
488
|
+
borderColor: colorScheme.main
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
const baseStyle = variantMap[variant];
|
|
492
|
+
const shouldApplyElevation = variant !== "outlined";
|
|
493
|
+
const shadowStyles = elevation === 0 ? {} : elevation === 1 ? theme.shadows.sm : elevation === 2 ? theme.shadows.md : elevation === 3 ? theme.shadows.lg : theme.shadows.xl;
|
|
494
|
+
return {
|
|
495
|
+
...baseStyle,
|
|
496
|
+
...shouldApplyElevation ? shadowStyles : {},
|
|
497
|
+
...shouldApplyElevation && elevation > 0 ? { elevation } : {}
|
|
498
|
+
};
|
|
499
|
+
}, [variant, colorScheme, theme, elevation]);
|
|
500
|
+
return variantStyles;
|
|
501
|
+
}
|
|
502
|
+
function useFabIconColor(themeColor, variant) {
|
|
503
|
+
const theme = useXUITheme();
|
|
504
|
+
const safeThemeColor = getSafeThemeColor2(themeColor);
|
|
505
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
506
|
+
const iconColor = useMemo(() => {
|
|
507
|
+
if (variant === "solid") {
|
|
508
|
+
return colorScheme.foreground;
|
|
509
|
+
}
|
|
510
|
+
return colorScheme.main;
|
|
511
|
+
}, [variant, colorScheme]);
|
|
512
|
+
return { iconColor };
|
|
513
|
+
}
|
|
514
|
+
function useFabRadiusValue(radius, fallback) {
|
|
515
|
+
const theme = useXUITheme();
|
|
516
|
+
return useMemo(() => {
|
|
517
|
+
if (!radius) return fallback;
|
|
518
|
+
const radiusMap = {
|
|
519
|
+
none: theme.borderRadius.none,
|
|
520
|
+
sm: theme.borderRadius.sm,
|
|
521
|
+
md: theme.borderRadius.md,
|
|
522
|
+
lg: theme.borderRadius.lg,
|
|
523
|
+
full: theme.borderRadius.full
|
|
524
|
+
};
|
|
525
|
+
return radiusMap[radius];
|
|
526
|
+
}, [fallback, radius, theme]);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// src/components/fab/fab.animation.ts
|
|
530
|
+
import { Animated as Animated3 } from "react-native";
|
|
531
|
+
var runFabPressInAnimation = (animatedScale, animatedOpacity) => {
|
|
532
|
+
Animated3.parallel([
|
|
533
|
+
Animated3.spring(animatedScale, {
|
|
534
|
+
toValue: 0.92,
|
|
535
|
+
useNativeDriver: true,
|
|
536
|
+
speed: 50,
|
|
537
|
+
bounciness: 0
|
|
538
|
+
}),
|
|
539
|
+
Animated3.timing(animatedOpacity, {
|
|
540
|
+
toValue: 0.85,
|
|
541
|
+
duration: 100,
|
|
542
|
+
useNativeDriver: true
|
|
543
|
+
})
|
|
544
|
+
]).start();
|
|
545
|
+
};
|
|
546
|
+
var runFabPressOutAnimation = (animatedScale, animatedOpacity) => {
|
|
547
|
+
Animated3.parallel([
|
|
548
|
+
Animated3.spring(animatedScale, {
|
|
549
|
+
toValue: 1,
|
|
550
|
+
useNativeDriver: true,
|
|
551
|
+
speed: 50,
|
|
552
|
+
bounciness: 0
|
|
553
|
+
}),
|
|
554
|
+
Animated3.timing(animatedOpacity, {
|
|
555
|
+
toValue: 1,
|
|
556
|
+
duration: 100,
|
|
557
|
+
useNativeDriver: true
|
|
558
|
+
})
|
|
559
|
+
]).start();
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
// src/components/fab/fab.tsx
|
|
563
|
+
var Fab = ({
|
|
564
|
+
icon,
|
|
565
|
+
label,
|
|
566
|
+
themeColor = "primary",
|
|
567
|
+
variant = "solid",
|
|
568
|
+
size = "md",
|
|
569
|
+
radius,
|
|
570
|
+
isDisabled = false,
|
|
571
|
+
isLoading = false,
|
|
572
|
+
elevation = 0,
|
|
573
|
+
customAppearance,
|
|
574
|
+
onPress,
|
|
575
|
+
onLongPress,
|
|
576
|
+
onPressIn,
|
|
577
|
+
onPressOut
|
|
578
|
+
}) => {
|
|
579
|
+
const animatedScale = React4.useRef(new Animated4.Value(1)).current;
|
|
580
|
+
const animatedOpacity = React4.useRef(new Animated4.Value(1)).current;
|
|
581
|
+
const { sizeStyles, extendedSizeStyles } = useFabSizeStyles(size);
|
|
582
|
+
const variantStyles = useFabVariantStyles(themeColor, variant, elevation);
|
|
583
|
+
const { iconColor } = useFabIconColor(themeColor, variant);
|
|
584
|
+
const isExtended = !!label;
|
|
585
|
+
const resolvedRadius = useFabRadiusValue(
|
|
586
|
+
radius,
|
|
587
|
+
isExtended ? extendedSizeStyles.borderRadius : sizeStyles.borderRadius
|
|
588
|
+
);
|
|
589
|
+
const handlePressIn = (event) => {
|
|
590
|
+
if (!isDisabled && !isLoading) {
|
|
591
|
+
runFabPressInAnimation(animatedScale, animatedOpacity);
|
|
592
|
+
}
|
|
593
|
+
onPressIn?.(event);
|
|
594
|
+
};
|
|
595
|
+
const handlePressOut = (event) => {
|
|
596
|
+
if (!isDisabled && !isLoading) {
|
|
597
|
+
runFabPressOutAnimation(animatedScale, animatedOpacity);
|
|
598
|
+
}
|
|
599
|
+
onPressOut?.(event);
|
|
600
|
+
};
|
|
601
|
+
const fabDimensionStyles = isExtended ? {
|
|
602
|
+
height: extendedSizeStyles.height,
|
|
603
|
+
borderRadius: resolvedRadius,
|
|
604
|
+
paddingHorizontal: extendedSizeStyles.paddingHorizontal
|
|
605
|
+
} : {
|
|
606
|
+
width: sizeStyles.width,
|
|
607
|
+
height: sizeStyles.height,
|
|
608
|
+
borderRadius: resolvedRadius
|
|
609
|
+
};
|
|
610
|
+
return /* @__PURE__ */ React4.createElement(View4, { style: [styles2.container, customAppearance?.container] }, /* @__PURE__ */ React4.createElement(
|
|
611
|
+
Pressable,
|
|
612
|
+
{
|
|
613
|
+
onPress: isDisabled || isLoading ? void 0 : onPress,
|
|
614
|
+
onLongPress: isDisabled || isLoading ? void 0 : onLongPress,
|
|
615
|
+
onPressIn: handlePressIn,
|
|
616
|
+
onPressOut: handlePressOut,
|
|
617
|
+
disabled: isDisabled || isLoading
|
|
618
|
+
},
|
|
619
|
+
/* @__PURE__ */ React4.createElement(
|
|
620
|
+
Animated4.View,
|
|
621
|
+
{
|
|
622
|
+
style: [
|
|
623
|
+
styles2.fab,
|
|
624
|
+
fabDimensionStyles,
|
|
625
|
+
variantStyles,
|
|
626
|
+
isDisabled && styles2.disabled,
|
|
627
|
+
{
|
|
628
|
+
transform: [{ scale: animatedScale }],
|
|
629
|
+
opacity: animatedOpacity
|
|
630
|
+
},
|
|
631
|
+
customAppearance?.fab
|
|
632
|
+
]
|
|
633
|
+
},
|
|
634
|
+
isLoading ? /* @__PURE__ */ React4.createElement(
|
|
635
|
+
ActivityIndicator,
|
|
636
|
+
{
|
|
637
|
+
variant: "circular",
|
|
638
|
+
themeColor: variant === "solid" ? void 0 : themeColor,
|
|
639
|
+
color: variant === "solid" ? iconColor : void 0,
|
|
640
|
+
size: isExtended ? extendedSizeStyles.iconSize : sizeStyles.iconSize
|
|
641
|
+
}
|
|
642
|
+
) : /* @__PURE__ */ React4.createElement(View4, { style: styles2.contentContainer }, icon, isExtended && /* @__PURE__ */ React4.createElement(
|
|
643
|
+
Text,
|
|
644
|
+
{
|
|
645
|
+
style: [
|
|
646
|
+
styles2.label,
|
|
647
|
+
{
|
|
648
|
+
fontSize: isExtended ? extendedSizeStyles.fontSize : sizeStyles.fontSize,
|
|
649
|
+
color: iconColor
|
|
650
|
+
}
|
|
651
|
+
]
|
|
652
|
+
},
|
|
653
|
+
label
|
|
654
|
+
))
|
|
655
|
+
)
|
|
656
|
+
));
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
export {
|
|
660
|
+
Fab
|
|
661
|
+
};
|