@xaui/native 0.0.2 → 0.0.4
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/dist/button/index.cjs +92 -70
- package/dist/button/index.d.cts +3 -4
- package/dist/button/index.d.ts +3 -4
- package/dist/button/index.js +78 -69
- package/dist/checkbox/index.cjs +488 -0
- package/dist/checkbox/index.d.cts +73 -0
- package/dist/checkbox/index.d.ts +73 -0
- package/dist/checkbox/index.js +436 -0
- package/dist/{chunk-6ITFLLAM.js → chunk-52PIZF2Z.js} +1 -1
- package/dist/{chunk-SHT66VET.js → chunk-DNJWBME5.js} +17 -2
- package/dist/core/index.js +1 -1
- package/dist/index-BOw6tbkc.d.cts +5 -0
- package/dist/index-BOw6tbkc.d.ts +5 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/indicator/index.d.cts +1 -1
- package/dist/indicator/index.d.ts +1 -1
- package/dist/indicator/index.js +2 -2
- package/dist/progress/index.d.cts +1 -1
- package/dist/progress/index.d.ts +1 -1
- package/dist/progress/index.js +1 -1
- package/package.json +21 -12
- package/dist/theme-qvIXI4kF.d.cts +0 -3
- package/dist/theme-qvIXI4kF.d.ts +0 -3
package/dist/button/index.cjs
CHANGED
|
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(button_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/components/button/button.tsx
|
|
38
38
|
var import_react8 = __toESM(require("react"), 1);
|
|
39
|
-
var
|
|
39
|
+
var import_react_native9 = require("react-native");
|
|
40
40
|
|
|
41
41
|
// src/components/indicator/indicator.tsx
|
|
42
42
|
var import_react6 = __toESM(require("react"), 1);
|
|
@@ -58,6 +58,20 @@ function useXUITheme() {
|
|
|
58
58
|
}
|
|
59
59
|
return theme;
|
|
60
60
|
}
|
|
61
|
+
function useBorderRadiusStyles(radius) {
|
|
62
|
+
const theme = useXUITheme();
|
|
63
|
+
const borderRadius = (0, import_react2.useMemo)(() => {
|
|
64
|
+
const radiusMap = {
|
|
65
|
+
none: theme.borderRadius.none,
|
|
66
|
+
sm: theme.borderRadius.sm,
|
|
67
|
+
md: theme.borderRadius.md,
|
|
68
|
+
lg: theme.borderRadius.lg,
|
|
69
|
+
full: theme.borderRadius.full
|
|
70
|
+
};
|
|
71
|
+
return { borderRadius: radiusMap[radius] };
|
|
72
|
+
}, [radius, theme]);
|
|
73
|
+
return borderRadius;
|
|
74
|
+
}
|
|
61
75
|
|
|
62
76
|
// src/components/indicator/circular-activity-indicator.tsx
|
|
63
77
|
var import_react3 = __toESM(require("react"), 1);
|
|
@@ -458,10 +472,22 @@ var styles2 = import_react_native7.StyleSheet.create({
|
|
|
458
472
|
// src/components/button/button.hook.ts
|
|
459
473
|
var import_react7 = require("react");
|
|
460
474
|
var import_core6 = require("@xaui/core");
|
|
461
|
-
var
|
|
475
|
+
var useTextStyles = (themeColor, variant) => {
|
|
462
476
|
const theme = useXUITheme();
|
|
463
477
|
const safeThemeColor = (0, import_core6.getSafeThemeColor)(themeColor);
|
|
464
478
|
const colorScheme = theme.colors[safeThemeColor];
|
|
479
|
+
const textColor = (0, import_react7.useMemo)(() => {
|
|
480
|
+
if (variant === "solid" || variant === "elevated") {
|
|
481
|
+
return colorScheme.foreground;
|
|
482
|
+
}
|
|
483
|
+
return colorScheme.main;
|
|
484
|
+
}, [variant, colorScheme]);
|
|
485
|
+
return {
|
|
486
|
+
textColor
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
function useSizesStyles(size) {
|
|
490
|
+
const theme = useXUITheme();
|
|
465
491
|
const sizeStyles = (0, import_react7.useMemo)(() => {
|
|
466
492
|
const sizes = {
|
|
467
493
|
xs: {
|
|
@@ -491,16 +517,21 @@ var useButtonStyles = (themeColor, variant, size, radius) => {
|
|
|
491
517
|
};
|
|
492
518
|
return sizes[size];
|
|
493
519
|
}, [size, theme]);
|
|
494
|
-
const
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
sm:
|
|
498
|
-
md:
|
|
499
|
-
lg:
|
|
500
|
-
full: theme.borderRadius.full
|
|
520
|
+
const spinnerSize = (0, import_react7.useMemo)(() => {
|
|
521
|
+
const sizes = {
|
|
522
|
+
xs: 14,
|
|
523
|
+
sm: 16,
|
|
524
|
+
md: 18,
|
|
525
|
+
lg: 20
|
|
501
526
|
};
|
|
502
|
-
return
|
|
503
|
-
}, [
|
|
527
|
+
return sizes[size];
|
|
528
|
+
}, [size]);
|
|
529
|
+
return { sizeStyles, spinnerSize };
|
|
530
|
+
}
|
|
531
|
+
function useVariantSizesStyles(themeColor, variant) {
|
|
532
|
+
const theme = useXUITheme();
|
|
533
|
+
const safeThemeColor = (0, import_core6.getSafeThemeColor)(themeColor);
|
|
534
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
504
535
|
const variantStyles = (0, import_react7.useMemo)(() => {
|
|
505
536
|
const styles3 = {
|
|
506
537
|
solid: {
|
|
@@ -526,35 +557,47 @@ var useButtonStyles = (themeColor, variant, size, radius) => {
|
|
|
526
557
|
...theme.shadows.md
|
|
527
558
|
},
|
|
528
559
|
faded: {
|
|
529
|
-
backgroundColor: `${colorScheme.background}
|
|
560
|
+
backgroundColor: `${colorScheme.background}95`,
|
|
530
561
|
borderWidth: theme.borderWidth.md,
|
|
531
|
-
borderColor: colorScheme.main
|
|
562
|
+
borderColor: `${colorScheme.main}90`
|
|
532
563
|
}
|
|
533
564
|
};
|
|
534
565
|
return styles3[variant];
|
|
535
566
|
}, [variant, colorScheme, theme]);
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
567
|
+
return variantStyles;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// src/components/button/button.animation.ts
|
|
571
|
+
var import_react_native8 = require("react-native");
|
|
572
|
+
var runPressInAnimation = (animatedScale, animatedOpacity) => {
|
|
573
|
+
import_react_native8.Animated.parallel([
|
|
574
|
+
import_react_native8.Animated.spring(animatedScale, {
|
|
575
|
+
toValue: 0.965,
|
|
576
|
+
useNativeDriver: true,
|
|
577
|
+
speed: 50,
|
|
578
|
+
bounciness: 0
|
|
579
|
+
}),
|
|
580
|
+
import_react_native8.Animated.timing(animatedOpacity, {
|
|
581
|
+
toValue: 0.9,
|
|
582
|
+
duration: 100,
|
|
583
|
+
useNativeDriver: true
|
|
584
|
+
})
|
|
585
|
+
]).start();
|
|
586
|
+
};
|
|
587
|
+
var runPressOutAnimation = (animatedScale, animatedOpacity) => {
|
|
588
|
+
import_react_native8.Animated.parallel([
|
|
589
|
+
import_react_native8.Animated.spring(animatedScale, {
|
|
590
|
+
toValue: 1,
|
|
591
|
+
useNativeDriver: true,
|
|
592
|
+
speed: 50,
|
|
593
|
+
bounciness: 0
|
|
594
|
+
}),
|
|
595
|
+
import_react_native8.Animated.timing(animatedOpacity, {
|
|
596
|
+
toValue: 1,
|
|
597
|
+
duration: 100,
|
|
598
|
+
useNativeDriver: true
|
|
599
|
+
})
|
|
600
|
+
]).start();
|
|
558
601
|
};
|
|
559
602
|
|
|
560
603
|
// src/components/button/button.tsx
|
|
@@ -577,42 +620,21 @@ var Button = ({
|
|
|
577
620
|
onPressIn,
|
|
578
621
|
onPressOut
|
|
579
622
|
}) => {
|
|
580
|
-
const animatedScale = import_react8.default.useRef(new
|
|
581
|
-
const animatedOpacity = import_react8.default.useRef(new
|
|
582
|
-
const { sizeStyles,
|
|
623
|
+
const animatedScale = import_react8.default.useRef(new import_react_native9.Animated.Value(1)).current;
|
|
624
|
+
const animatedOpacity = import_react8.default.useRef(new import_react_native9.Animated.Value(1)).current;
|
|
625
|
+
const { sizeStyles, spinnerSize } = useSizesStyles(size);
|
|
626
|
+
const radiusStyles = useBorderRadiusStyles(radius);
|
|
627
|
+
const variantStyles = useVariantSizesStyles(themeColor, variant);
|
|
628
|
+
const { textColor } = useTextStyles(themeColor, variant);
|
|
583
629
|
const handlePressIn = (event) => {
|
|
584
630
|
if (!isDisabled && !isLoading) {
|
|
585
|
-
|
|
586
|
-
import_react_native8.Animated.spring(animatedScale, {
|
|
587
|
-
toValue: 0.975,
|
|
588
|
-
useNativeDriver: true,
|
|
589
|
-
speed: 50,
|
|
590
|
-
bounciness: 0
|
|
591
|
-
}),
|
|
592
|
-
import_react_native8.Animated.timing(animatedOpacity, {
|
|
593
|
-
toValue: 0.9,
|
|
594
|
-
duration: 100,
|
|
595
|
-
useNativeDriver: true
|
|
596
|
-
})
|
|
597
|
-
]).start();
|
|
631
|
+
runPressInAnimation(animatedScale, animatedOpacity);
|
|
598
632
|
}
|
|
599
633
|
onPressIn?.(event);
|
|
600
634
|
};
|
|
601
635
|
const handlePressOut = (event) => {
|
|
602
636
|
if (!isDisabled && !isLoading) {
|
|
603
|
-
|
|
604
|
-
import_react_native8.Animated.spring(animatedScale, {
|
|
605
|
-
toValue: 1,
|
|
606
|
-
useNativeDriver: true,
|
|
607
|
-
speed: 50,
|
|
608
|
-
bounciness: 0
|
|
609
|
-
}),
|
|
610
|
-
import_react_native8.Animated.timing(animatedOpacity, {
|
|
611
|
-
toValue: 1,
|
|
612
|
-
duration: 100,
|
|
613
|
-
useNativeDriver: true
|
|
614
|
-
})
|
|
615
|
-
]).start();
|
|
637
|
+
runPressOutAnimation(animatedScale, animatedOpacity);
|
|
616
638
|
}
|
|
617
639
|
onPressOut?.(event);
|
|
618
640
|
};
|
|
@@ -625,8 +647,8 @@ var Button = ({
|
|
|
625
647
|
size: spinnerSize
|
|
626
648
|
}
|
|
627
649
|
);
|
|
628
|
-
return /* @__PURE__ */ import_react8.default.createElement(
|
|
629
|
-
|
|
650
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_native9.View, { style: [fullWidth && styles2.fullWidth] }, /* @__PURE__ */ import_react8.default.createElement(
|
|
651
|
+
import_react_native9.Pressable,
|
|
630
652
|
{
|
|
631
653
|
onPress: isDisabled || isLoading ? void 0 : onPress,
|
|
632
654
|
onLongPress: isDisabled || isLoading ? void 0 : onLongPress,
|
|
@@ -635,7 +657,7 @@ var Button = ({
|
|
|
635
657
|
disabled: isDisabled || isLoading
|
|
636
658
|
},
|
|
637
659
|
/* @__PURE__ */ import_react8.default.createElement(
|
|
638
|
-
|
|
660
|
+
import_react_native9.Animated.View,
|
|
639
661
|
{
|
|
640
662
|
style: [
|
|
641
663
|
styles2.button,
|
|
@@ -651,8 +673,8 @@ var Button = ({
|
|
|
651
673
|
style
|
|
652
674
|
]
|
|
653
675
|
},
|
|
654
|
-
/* @__PURE__ */ import_react8.default.createElement(
|
|
655
|
-
|
|
676
|
+
/* @__PURE__ */ import_react8.default.createElement(import_react_native9.View, { style: styles2.contentContainer }, startContent && !isLoading && spinnerPlacement !== "start" && /* @__PURE__ */ import_react8.default.createElement(import_react_native9.View, { style: styles2.startContent }, startContent), isLoading && spinnerPlacement === "start" && /* @__PURE__ */ import_react8.default.createElement(import_react_native9.View, { style: styles2.spinner }, spinner), /* @__PURE__ */ import_react8.default.createElement(
|
|
677
|
+
import_react_native9.Text,
|
|
656
678
|
{
|
|
657
679
|
style: [
|
|
658
680
|
styles2.text,
|
|
@@ -662,7 +684,7 @@ var Button = ({
|
|
|
662
684
|
]
|
|
663
685
|
},
|
|
664
686
|
children
|
|
665
|
-
), isLoading && spinnerPlacement === "end" && /* @__PURE__ */ import_react8.default.createElement(
|
|
687
|
+
), isLoading && spinnerPlacement === "end" && /* @__PURE__ */ import_react8.default.createElement(import_react_native9.View, { style: styles2.spinner }, spinner), endContent && !isLoading && spinnerPlacement !== "end" && /* @__PURE__ */ import_react8.default.createElement(import_react_native9.View, { style: styles2.endContent }, endContent))
|
|
666
688
|
)
|
|
667
689
|
));
|
|
668
690
|
};
|
package/dist/button/index.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { TextStyle, ViewStyle, GestureResponderEvent } from 'react-native';
|
|
3
|
-
import { T as ThemeColor } from '../
|
|
3
|
+
import { T as ThemeColor, S as Size } from '../index-BOw6tbkc.cjs';
|
|
4
4
|
|
|
5
5
|
type ButtonVariant = 'solid' | 'outlined' | 'flat' | 'light' | 'elevated' | 'faded';
|
|
6
|
-
type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
7
6
|
type ButtonRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
8
7
|
type SpinnerPlacement = 'start' | 'end';
|
|
9
8
|
type ButtonProps = {
|
|
@@ -25,7 +24,7 @@ type ButtonProps = {
|
|
|
25
24
|
* The size of the button.
|
|
26
25
|
* @default 'md'
|
|
27
26
|
*/
|
|
28
|
-
size?:
|
|
27
|
+
size?: Size;
|
|
29
28
|
/**
|
|
30
29
|
* The border radius of the button.
|
|
31
30
|
* @default 'md'
|
|
@@ -87,4 +86,4 @@ type ButtonProps = {
|
|
|
87
86
|
|
|
88
87
|
declare const Button: React.FC<ButtonProps>;
|
|
89
88
|
|
|
90
|
-
export { Button, type ButtonProps, type ButtonRadius, type
|
|
89
|
+
export { Button, type ButtonProps, type ButtonRadius, type ButtonVariant, type SpinnerPlacement };
|
package/dist/button/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { TextStyle, ViewStyle, GestureResponderEvent } from 'react-native';
|
|
3
|
-
import { T as ThemeColor } from '../
|
|
3
|
+
import { T as ThemeColor, S as Size } from '../index-BOw6tbkc.js';
|
|
4
4
|
|
|
5
5
|
type ButtonVariant = 'solid' | 'outlined' | 'flat' | 'light' | 'elevated' | 'faded';
|
|
6
|
-
type ButtonSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
7
6
|
type ButtonRadius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
8
7
|
type SpinnerPlacement = 'start' | 'end';
|
|
9
8
|
type ButtonProps = {
|
|
@@ -25,7 +24,7 @@ type ButtonProps = {
|
|
|
25
24
|
* The size of the button.
|
|
26
25
|
* @default 'md'
|
|
27
26
|
*/
|
|
28
|
-
size?:
|
|
27
|
+
size?: Size;
|
|
29
28
|
/**
|
|
30
29
|
* The border radius of the button.
|
|
31
30
|
* @default 'md'
|
|
@@ -87,4 +86,4 @@ type ButtonProps = {
|
|
|
87
86
|
|
|
88
87
|
declare const Button: React.FC<ButtonProps>;
|
|
89
88
|
|
|
90
|
-
export { Button, type ButtonProps, type ButtonRadius, type
|
|
89
|
+
export { Button, type ButtonProps, type ButtonRadius, type ButtonVariant, type SpinnerPlacement };
|
package/dist/button/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ActivityIndicator
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-52PIZF2Z.js";
|
|
4
4
|
import {
|
|
5
|
+
useBorderRadiusStyles,
|
|
5
6
|
useXUITheme
|
|
6
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-DNJWBME5.js";
|
|
7
8
|
|
|
8
9
|
// src/components/button/button.tsx
|
|
9
10
|
import React from "react";
|
|
10
|
-
import { Pressable, Text, View, Animated } from "react-native";
|
|
11
|
+
import { Pressable, Text, View, Animated as Animated2 } from "react-native";
|
|
11
12
|
|
|
12
13
|
// src/components/button/button.style.ts
|
|
13
14
|
import { StyleSheet } from "react-native";
|
|
@@ -51,10 +52,22 @@ var styles = StyleSheet.create({
|
|
|
51
52
|
// src/components/button/button.hook.ts
|
|
52
53
|
import { useMemo } from "react";
|
|
53
54
|
import { getSafeThemeColor } from "@xaui/core";
|
|
54
|
-
var
|
|
55
|
+
var useTextStyles = (themeColor, variant) => {
|
|
55
56
|
const theme = useXUITheme();
|
|
56
57
|
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
57
58
|
const colorScheme = theme.colors[safeThemeColor];
|
|
59
|
+
const textColor = useMemo(() => {
|
|
60
|
+
if (variant === "solid" || variant === "elevated") {
|
|
61
|
+
return colorScheme.foreground;
|
|
62
|
+
}
|
|
63
|
+
return colorScheme.main;
|
|
64
|
+
}, [variant, colorScheme]);
|
|
65
|
+
return {
|
|
66
|
+
textColor
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
function useSizesStyles(size) {
|
|
70
|
+
const theme = useXUITheme();
|
|
58
71
|
const sizeStyles = useMemo(() => {
|
|
59
72
|
const sizes = {
|
|
60
73
|
xs: {
|
|
@@ -84,16 +97,21 @@ var useButtonStyles = (themeColor, variant, size, radius) => {
|
|
|
84
97
|
};
|
|
85
98
|
return sizes[size];
|
|
86
99
|
}, [size, theme]);
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
sm:
|
|
91
|
-
md:
|
|
92
|
-
lg:
|
|
93
|
-
full: theme.borderRadius.full
|
|
100
|
+
const spinnerSize = useMemo(() => {
|
|
101
|
+
const sizes = {
|
|
102
|
+
xs: 14,
|
|
103
|
+
sm: 16,
|
|
104
|
+
md: 18,
|
|
105
|
+
lg: 20
|
|
94
106
|
};
|
|
95
|
-
return
|
|
96
|
-
}, [
|
|
107
|
+
return sizes[size];
|
|
108
|
+
}, [size]);
|
|
109
|
+
return { sizeStyles, spinnerSize };
|
|
110
|
+
}
|
|
111
|
+
function useVariantSizesStyles(themeColor, variant) {
|
|
112
|
+
const theme = useXUITheme();
|
|
113
|
+
const safeThemeColor = getSafeThemeColor(themeColor);
|
|
114
|
+
const colorScheme = theme.colors[safeThemeColor];
|
|
97
115
|
const variantStyles = useMemo(() => {
|
|
98
116
|
const styles2 = {
|
|
99
117
|
solid: {
|
|
@@ -119,35 +137,47 @@ var useButtonStyles = (themeColor, variant, size, radius) => {
|
|
|
119
137
|
...theme.shadows.md
|
|
120
138
|
},
|
|
121
139
|
faded: {
|
|
122
|
-
backgroundColor: `${colorScheme.background}
|
|
140
|
+
backgroundColor: `${colorScheme.background}95`,
|
|
123
141
|
borderWidth: theme.borderWidth.md,
|
|
124
|
-
borderColor: colorScheme.main
|
|
142
|
+
borderColor: `${colorScheme.main}90`
|
|
125
143
|
}
|
|
126
144
|
};
|
|
127
145
|
return styles2[variant];
|
|
128
146
|
}, [variant, colorScheme, theme]);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
return variantStyles;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// src/components/button/button.animation.ts
|
|
151
|
+
import { Animated } from "react-native";
|
|
152
|
+
var runPressInAnimation = (animatedScale, animatedOpacity) => {
|
|
153
|
+
Animated.parallel([
|
|
154
|
+
Animated.spring(animatedScale, {
|
|
155
|
+
toValue: 0.965,
|
|
156
|
+
useNativeDriver: true,
|
|
157
|
+
speed: 50,
|
|
158
|
+
bounciness: 0
|
|
159
|
+
}),
|
|
160
|
+
Animated.timing(animatedOpacity, {
|
|
161
|
+
toValue: 0.9,
|
|
162
|
+
duration: 100,
|
|
163
|
+
useNativeDriver: true
|
|
164
|
+
})
|
|
165
|
+
]).start();
|
|
166
|
+
};
|
|
167
|
+
var runPressOutAnimation = (animatedScale, animatedOpacity) => {
|
|
168
|
+
Animated.parallel([
|
|
169
|
+
Animated.spring(animatedScale, {
|
|
170
|
+
toValue: 1,
|
|
171
|
+
useNativeDriver: true,
|
|
172
|
+
speed: 50,
|
|
173
|
+
bounciness: 0
|
|
174
|
+
}),
|
|
175
|
+
Animated.timing(animatedOpacity, {
|
|
176
|
+
toValue: 1,
|
|
177
|
+
duration: 100,
|
|
178
|
+
useNativeDriver: true
|
|
179
|
+
})
|
|
180
|
+
]).start();
|
|
151
181
|
};
|
|
152
182
|
|
|
153
183
|
// src/components/button/button.tsx
|
|
@@ -170,42 +200,21 @@ var Button = ({
|
|
|
170
200
|
onPressIn,
|
|
171
201
|
onPressOut
|
|
172
202
|
}) => {
|
|
173
|
-
const animatedScale = React.useRef(new
|
|
174
|
-
const animatedOpacity = React.useRef(new
|
|
175
|
-
const { sizeStyles,
|
|
203
|
+
const animatedScale = React.useRef(new Animated2.Value(1)).current;
|
|
204
|
+
const animatedOpacity = React.useRef(new Animated2.Value(1)).current;
|
|
205
|
+
const { sizeStyles, spinnerSize } = useSizesStyles(size);
|
|
206
|
+
const radiusStyles = useBorderRadiusStyles(radius);
|
|
207
|
+
const variantStyles = useVariantSizesStyles(themeColor, variant);
|
|
208
|
+
const { textColor } = useTextStyles(themeColor, variant);
|
|
176
209
|
const handlePressIn = (event) => {
|
|
177
210
|
if (!isDisabled && !isLoading) {
|
|
178
|
-
|
|
179
|
-
Animated.spring(animatedScale, {
|
|
180
|
-
toValue: 0.975,
|
|
181
|
-
useNativeDriver: true,
|
|
182
|
-
speed: 50,
|
|
183
|
-
bounciness: 0
|
|
184
|
-
}),
|
|
185
|
-
Animated.timing(animatedOpacity, {
|
|
186
|
-
toValue: 0.9,
|
|
187
|
-
duration: 100,
|
|
188
|
-
useNativeDriver: true
|
|
189
|
-
})
|
|
190
|
-
]).start();
|
|
211
|
+
runPressInAnimation(animatedScale, animatedOpacity);
|
|
191
212
|
}
|
|
192
213
|
onPressIn?.(event);
|
|
193
214
|
};
|
|
194
215
|
const handlePressOut = (event) => {
|
|
195
216
|
if (!isDisabled && !isLoading) {
|
|
196
|
-
|
|
197
|
-
Animated.spring(animatedScale, {
|
|
198
|
-
toValue: 1,
|
|
199
|
-
useNativeDriver: true,
|
|
200
|
-
speed: 50,
|
|
201
|
-
bounciness: 0
|
|
202
|
-
}),
|
|
203
|
-
Animated.timing(animatedOpacity, {
|
|
204
|
-
toValue: 1,
|
|
205
|
-
duration: 100,
|
|
206
|
-
useNativeDriver: true
|
|
207
|
-
})
|
|
208
|
-
]).start();
|
|
217
|
+
runPressOutAnimation(animatedScale, animatedOpacity);
|
|
209
218
|
}
|
|
210
219
|
onPressOut?.(event);
|
|
211
220
|
};
|
|
@@ -228,7 +237,7 @@ var Button = ({
|
|
|
228
237
|
disabled: isDisabled || isLoading
|
|
229
238
|
},
|
|
230
239
|
/* @__PURE__ */ React.createElement(
|
|
231
|
-
|
|
240
|
+
Animated2.View,
|
|
232
241
|
{
|
|
233
242
|
style: [
|
|
234
243
|
styles.button,
|
|
@@ -244,7 +253,7 @@ var Button = ({
|
|
|
244
253
|
style
|
|
245
254
|
]
|
|
246
255
|
},
|
|
247
|
-
/* @__PURE__ */ React.createElement(View, { style: styles.contentContainer }, startContent && !isLoading && /* @__PURE__ */ React.createElement(View, { style: styles.startContent }, startContent), isLoading && spinnerPlacement === "start" && /* @__PURE__ */ React.createElement(View, { style: styles.spinner }, spinner), /* @__PURE__ */ React.createElement(
|
|
256
|
+
/* @__PURE__ */ React.createElement(View, { style: styles.contentContainer }, startContent && !isLoading && spinnerPlacement !== "start" && /* @__PURE__ */ React.createElement(View, { style: styles.startContent }, startContent), isLoading && spinnerPlacement === "start" && /* @__PURE__ */ React.createElement(View, { style: styles.spinner }, spinner), /* @__PURE__ */ React.createElement(
|
|
248
257
|
Text,
|
|
249
258
|
{
|
|
250
259
|
style: [
|
|
@@ -255,7 +264,7 @@ var Button = ({
|
|
|
255
264
|
]
|
|
256
265
|
},
|
|
257
266
|
children
|
|
258
|
-
), isLoading && spinnerPlacement === "end" && /* @__PURE__ */ React.createElement(View, { style: styles.spinner }, spinner), endContent && !isLoading && /* @__PURE__ */ React.createElement(View, { style: styles.endContent }, endContent))
|
|
267
|
+
), isLoading && spinnerPlacement === "end" && /* @__PURE__ */ React.createElement(View, { style: styles.spinner }, spinner), endContent && !isLoading && spinnerPlacement !== "end" && /* @__PURE__ */ React.createElement(View, { style: styles.endContent }, endContent))
|
|
259
268
|
)
|
|
260
269
|
));
|
|
261
270
|
};
|