@kivid/native-components 1.0.0-alpha.14 → 1.0.0-alpha.16
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/commonjs/components/ActionButton/assets/class-variants.js.map +1 -1
- package/dist/commonjs/components/ActionButton/index.js +35 -48
- package/dist/commonjs/components/ActionButton/index.js.map +1 -1
- package/dist/commonjs/components/Toast/index.js +27 -12
- package/dist/commonjs/components/Toast/index.js.map +1 -1
- package/dist/module/components/ActionButton/assets/class-variants.js.map +1 -1
- package/dist/module/components/ActionButton/index.js +35 -30
- package/dist/module/components/ActionButton/index.js.map +1 -1
- package/dist/module/components/Toast/index.js +27 -12
- package/dist/module/components/Toast/index.js.map +1 -1
- package/dist/typescript/components/ActionButton/index.d.ts +0 -1
- package/dist/typescript/components/ActionButton/types.d.ts +15 -24
- package/package.json +5 -5
- package/src/components/ActionButton/assets/class-variants.ts +3 -12
- package/src/components/ActionButton/index.tsx +55 -41
- package/src/components/ActionButton/types.ts +15 -24
- package/src/components/Toast/index.tsx +52 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classVarianceAuthority","require","_index","menuCardVariants","exports","cva","variants","variant","grape","java","pear","tangerine","blackberry","chia","outline","corners","CornersEnum","SMALL","MEDIUM","LARGE","defaultVariants","textVariants"],"sourceRoot":"../../../../../src","sources":["components/ActionButton/assets/class-variants.ts"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAAE,2BAAG,EACjC,CACE,sCAAsC,EACtC,UAAU,EACV,eAAe,EACf,UAAU,EACV,iBAAiB,CAClB,EACD;EACEC,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,KAAK,EAAE,CAAC,cAAc,EAAE,uBAAuB,CAAC;MAChDC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,SAAS,EAAE,
|
|
1
|
+
{"version":3,"names":["_classVarianceAuthority","require","_index","menuCardVariants","exports","cva","variants","variant","grape","java","pear","tangerine","blackberry","chia","outline","corners","CornersEnum","SMALL","MEDIUM","LARGE","defaultVariants","textVariants"],"sourceRoot":"../../../../../src","sources":["components/ActionButton/assets/class-variants.ts"],"mappings":";;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAAE,2BAAG,EACjC,CACE,sCAAsC,EACtC,UAAU,EACV,eAAe,EACf,UAAU,EACV,iBAAiB,CAClB,EACD;EACEC,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,KAAK,EAAE,CAAC,cAAc,EAAE,uBAAuB,CAAC;MAChDC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,SAAS,EAAE,CAAC,kBAAkB,EAAE,2BAA2B,CAAC;MAC5DC,UAAU,EAAE,CAAC,mBAAmB,EAAE,4BAA4B,CAAC;MAC/DC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,OAAO,EAAE,CAAC,4BAA4B,EAAE,0BAA0B;IACpE,CAAC;IACDC,OAAO,EAAE;MACP,CAACC,kBAAW,CAACC,KAAK,GAAG,aAAa;MAClC,CAACD,kBAAW,CAACE,MAAM,GAAG,gBAAgB;MACtC,CAACF,kBAAW,CAACG,KAAK,GAAG;IACvB;EACF,CAAC;EACDC,eAAe,EAAE;IACfb,OAAO,EAAE,OAAO;IAChBQ,OAAO,EAAEC,kBAAW,CAACE;EACvB;AACF,CACF,CAAC;AAEM,MAAMG,YAAY,GAAAjB,OAAA,CAAAiB,YAAA,GAAG,IAAAhB,2BAAG,EAAC,EAAE,EAAE;EAClCC,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,KAAK,EAAE,eAAe;MACtBC,IAAI,EAAE,eAAe;MACrBC,IAAI,EAAE,eAAe;MACrBC,SAAS,EAAE,eAAe;MAC1BC,UAAU,EAAE,eAAe;MAC3BC,IAAI,EAAE,eAAe;MACrBC,OAAO,EAAE;IACX;EACF,CAAC;EACDM,eAAe,EAAE;IACfb,OAAO,EAAE;EACX;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,24 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ActionButton = ActionButton;
|
|
7
|
-
Object.defineProperty(exports, "ActionButtonCorners", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _types.ActionButtonCorners;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "ActionButtonProps", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _types.ActionButtonProps;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "ActionButtonVariant", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _types.ActionButtonVariant;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
7
|
var _tailwindPreset = require("@kivid/tailwind-preset");
|
|
26
8
|
var _react = _interopRequireDefault(require("react"));
|
|
27
9
|
var _reactNative = require("react-native");
|
|
@@ -29,22 +11,19 @@ var _index = require("../../enums/index.js");
|
|
|
29
11
|
var _index2 = require("../Typography/index.js");
|
|
30
12
|
var _classVariants = require("./assets/class-variants.js");
|
|
31
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
32
|
-
var _types = require("./types.js");
|
|
33
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
34
15
|
function ActionButton(props) {
|
|
35
16
|
const {
|
|
36
17
|
icon,
|
|
37
|
-
|
|
38
|
-
|
|
18
|
+
primaryText,
|
|
19
|
+
secondaryText,
|
|
20
|
+
primaryTextProps = {},
|
|
21
|
+
secondaryTextProps = {},
|
|
39
22
|
variant = "grape",
|
|
40
23
|
corners = _index.CornersEnum.MEDIUM,
|
|
41
24
|
disabled = false,
|
|
42
25
|
className,
|
|
43
|
-
|
|
44
|
-
labelClassName,
|
|
45
|
-
subtitleClassName,
|
|
46
|
-
labelWeight = _index.FontWeightEnum.MEDIUM,
|
|
47
|
-
subtitleWeight = _index.FontWeightEnum.MEDIUM,
|
|
26
|
+
iconContainerClassName,
|
|
48
27
|
onPress,
|
|
49
28
|
accessibilityLabel,
|
|
50
29
|
ref,
|
|
@@ -68,25 +47,22 @@ function ActionButton(props) {
|
|
|
68
47
|
variant,
|
|
69
48
|
corners
|
|
70
49
|
}), isPressed && !disabled && pressedColorMap[variant], className);
|
|
71
|
-
const textStyle = (0, _tailwindPreset.merge)((0, _classVariants.textVariants)({
|
|
72
|
-
variant
|
|
73
|
-
}));
|
|
74
50
|
|
|
75
51
|
// Define icon colors based on variant
|
|
76
52
|
const iconColorMap = {
|
|
77
|
-
grape: "
|
|
53
|
+
grape: "text-chia-100",
|
|
78
54
|
// chia-100
|
|
79
|
-
java: "
|
|
80
|
-
pear: "
|
|
81
|
-
tangerine: "
|
|
82
|
-
blackberry: "
|
|
83
|
-
chia: "
|
|
84
|
-
outline: "
|
|
55
|
+
java: "text-chia-100",
|
|
56
|
+
pear: "text-chia-100",
|
|
57
|
+
tangerine: "text-chia-100",
|
|
58
|
+
blackberry: "text-chia-100",
|
|
59
|
+
chia: "text-chia-100",
|
|
60
|
+
outline: "text-chia-900" // chia-900
|
|
85
61
|
};
|
|
86
62
|
|
|
87
63
|
// Clone icon element to pass color prop
|
|
88
64
|
const iconWithColor = /*#__PURE__*/_react.default.isValidElement(icon) ? /*#__PURE__*/_react.default.cloneElement(icon, {
|
|
89
|
-
|
|
65
|
+
className: (0, _tailwindPreset.merge)(iconColorMap[variant], icon.props?.className || "")
|
|
90
66
|
}) : icon;
|
|
91
67
|
const handlePressIn = event => {
|
|
92
68
|
setIsPressed(true);
|
|
@@ -96,6 +72,21 @@ function ActionButton(props) {
|
|
|
96
72
|
setIsPressed(false);
|
|
97
73
|
onPressOut?.(event);
|
|
98
74
|
};
|
|
75
|
+
const textStyle = (0, _tailwindPreset.merge)((0, _classVariants.textVariants)({
|
|
76
|
+
variant
|
|
77
|
+
}));
|
|
78
|
+
const mergedPrimaryTextProps = {
|
|
79
|
+
variant: "label_large",
|
|
80
|
+
weight: _index.FontWeightEnum.MEDIUM,
|
|
81
|
+
...primaryTextProps,
|
|
82
|
+
className: (0, _tailwindPreset.merge)(textStyle, disabled && "opacity-60", primaryTextProps.className)
|
|
83
|
+
};
|
|
84
|
+
const mergedSecondaryTextProps = {
|
|
85
|
+
variant: "label_large",
|
|
86
|
+
weight: _index.FontWeightEnum.BOLD,
|
|
87
|
+
...secondaryTextProps,
|
|
88
|
+
className: (0, _tailwindPreset.merge)(textStyle, disabled && "opacity-60", secondaryTextProps.className)
|
|
89
|
+
};
|
|
99
90
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
100
91
|
ref: ref,
|
|
101
92
|
disabled: disabled,
|
|
@@ -104,27 +95,23 @@ function ActionButton(props) {
|
|
|
104
95
|
onPressIn: handlePressIn,
|
|
105
96
|
onPressOut: handlePressOut,
|
|
106
97
|
accessibilityRole: "button",
|
|
107
|
-
accessibilityLabel: accessibilityLabel || `${
|
|
98
|
+
accessibilityLabel: accessibilityLabel || `${primaryText}${secondaryText ? ` ${secondaryText}` : ""}`,
|
|
108
99
|
accessibilityState: {
|
|
109
100
|
disabled: disabled
|
|
110
101
|
},
|
|
111
102
|
pointerEvents: disabled ? "none" : "auto",
|
|
112
103
|
...rest,
|
|
113
104
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
114
|
-
className: (0, _tailwindPreset.merge)("flex items-start shrink-0", disabled && "opacity-60",
|
|
105
|
+
className: (0, _tailwindPreset.merge)("flex items-start shrink-0", disabled && "opacity-60", iconContainerClassName),
|
|
115
106
|
children: iconWithColor
|
|
116
107
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
117
108
|
className: "shrink-0",
|
|
118
109
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Typography, {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
variant: "label_large",
|
|
125
|
-
weight: subtitleWeight,
|
|
126
|
-
className: (0, _tailwindPreset.merge)(textStyle, disabled && "opacity-60", subtitleClassName),
|
|
127
|
-
children: subtitle
|
|
110
|
+
...mergedPrimaryTextProps,
|
|
111
|
+
children: primaryText
|
|
112
|
+
}), secondaryText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.Typography, {
|
|
113
|
+
...mergedSecondaryTextProps,
|
|
114
|
+
children: secondaryText
|
|
128
115
|
})]
|
|
129
116
|
})]
|
|
130
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_tailwindPreset","require","_react","_interopRequireDefault","_reactNative","_index","_index2","_classVariants","_jsxRuntime","
|
|
1
|
+
{"version":3,"names":["_tailwindPreset","require","_react","_interopRequireDefault","_reactNative","_index","_index2","_classVariants","_jsxRuntime","e","__esModule","default","ActionButton","props","icon","primaryText","secondaryText","primaryTextProps","secondaryTextProps","variant","corners","CornersEnum","MEDIUM","disabled","className","iconContainerClassName","onPress","accessibilityLabel","ref","onPressIn","onPressOut","rest","isPressed","setIsPressed","React","useState","pressedColorMap","grape","java","pear","tangerine","blackberry","chia","outline","containerStyle","merge","menuCardVariants","iconColorMap","iconWithColor","isValidElement","cloneElement","handlePressIn","event","handlePressOut","textStyle","textVariants","mergedPrimaryTextProps","weight","FontWeightEnum","mergedSecondaryTextProps","BOLD","jsxs","Pressable","accessibilityRole","accessibilityState","pointerEvents","children","jsx","View","Typography","displayName"],"sourceRoot":"../../../../src","sources":["components/ActionButton/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AAAyE,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAE,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGlE,SAASG,YAAYA,CAACC,KAAwB,EAAE;EACrD,MAAM;IACJC,IAAI;IACJC,WAAW;IACXC,aAAa;IACbC,gBAAgB,GAAG,CAAC,CAAC;IACrBC,kBAAkB,GAAG,CAAC,CAAC;IACvBC,OAAO,GAAG,OAAO;IACjBC,OAAO,GAAGC,kBAAW,CAACC,MAAM;IAC5BC,QAAQ,GAAG,KAAK;IAChBC,SAAS;IACTC,sBAAsB;IACtBC,OAAO;IACPC,kBAAkB;IAClBC,GAAG;IACHC,SAAS;IACTC,UAAU;IACV,GAAGC;EACL,CAAC,GAAGlB,KAAK;EAET,MAAM,CAACmB,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;;EAEvD;EACA,MAAMC,eAA+C,GAAG;IACtDC,KAAK,EAAE,cAAc;IACrBC,IAAI,EAAE,aAAa;IACnBC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,kBAAkB;IAC7BC,UAAU,EAAE,mBAAmB;IAC/BC,IAAI,EAAE,aAAa;IACnBC,OAAO,EAAE;EACX,CAAC;EAED,MAAMC,cAAc,GAAG,IAAAC,qBAAK,EAC1B,IAAAC,+BAAgB,EAAC;IACf3B,OA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B;QAAAO,QAAA,EAAGlD;MAAa,CAAa,CACtE;IAAA,CACG,CAAC;EAAA,CACE,CAAC;AAEhB;AAEAJ,YAAY,CAAC0D,WAAW,GAAG,cAAc","ignoreList":[]}
|
|
@@ -29,8 +29,10 @@ function Toast(props) {
|
|
|
29
29
|
} = props;
|
|
30
30
|
const animatedValue = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
|
|
31
31
|
const timerRef = (0, _react.useRef)(null);
|
|
32
|
+
const isClosingRef = (0, _react.useRef)(false);
|
|
32
33
|
(0, _react.useEffect)(() => {
|
|
33
34
|
if (!isToastOpen) return;
|
|
35
|
+
isClosingRef.current = false;
|
|
34
36
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
35
37
|
_reactNative.Animated.timing(animatedValue, {
|
|
36
38
|
toValue: 1,
|
|
@@ -38,6 +40,8 @@ function Toast(props) {
|
|
|
38
40
|
useNativeDriver: true
|
|
39
41
|
}).start();
|
|
40
42
|
timerRef.current = setTimeout(() => {
|
|
43
|
+
if (isClosingRef.current) return;
|
|
44
|
+
isClosingRef.current = true;
|
|
41
45
|
_reactNative.Animated.timing(animatedValue, {
|
|
42
46
|
toValue: 0,
|
|
43
47
|
duration: 200,
|
|
@@ -52,8 +56,16 @@ function Toast(props) {
|
|
|
52
56
|
}, [isToastOpen]);
|
|
53
57
|
if (!isToastOpen) return null;
|
|
54
58
|
function handleClose() {
|
|
55
|
-
|
|
59
|
+
if (isClosingRef.current) return;
|
|
60
|
+
isClosingRef.current = true;
|
|
56
61
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
62
|
+
_reactNative.Animated.timing(animatedValue, {
|
|
63
|
+
toValue: 0,
|
|
64
|
+
duration: 200,
|
|
65
|
+
useNativeDriver: true
|
|
66
|
+
}).start(() => {
|
|
67
|
+
onCloseToast(false);
|
|
68
|
+
});
|
|
57
69
|
}
|
|
58
70
|
const toastStyle = (0, _classVariants.toastVariants)({
|
|
59
71
|
variant
|
|
@@ -76,32 +88,35 @@ function Toast(props) {
|
|
|
76
88
|
})
|
|
77
89
|
};
|
|
78
90
|
const Icon = iconMap[variant];
|
|
91
|
+
const animatedStyle = {
|
|
92
|
+
opacity: animatedValue,
|
|
93
|
+
transform: [{
|
|
94
|
+
translateY: animatedValue.interpolate({
|
|
95
|
+
inputRange: [0, 1],
|
|
96
|
+
outputRange: [-20, 0]
|
|
97
|
+
})
|
|
98
|
+
}]
|
|
99
|
+
};
|
|
79
100
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
80
101
|
className: containerStyle,
|
|
102
|
+
style: animatedStyle,
|
|
81
103
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
82
104
|
className: (0, _tailwindPreset.merge)(toastStyle, className),
|
|
83
105
|
style: {
|
|
84
106
|
boxShadow: _index5.elevationDown100
|
|
85
107
|
},
|
|
86
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
87
|
-
className: "
|
|
88
|
-
children:
|
|
89
|
-
className: "flex items-center gap-8",
|
|
90
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.default, {
|
|
91
|
-
className: (0, _tailwindPreset.merge)("title_small font-bold text-chia-100", descriptionClassName),
|
|
92
|
-
children: description
|
|
93
|
-
})
|
|
94
|
-
})]
|
|
108
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index2.default, {
|
|
109
|
+
className: (0, _tailwindPreset.merge)("title_small font-bold text-chia-100 truncate flex-1", descriptionClassName),
|
|
110
|
+
children: description
|
|
95
111
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
96
112
|
className: "cursor-pointer",
|
|
97
113
|
onPress: handleClose,
|
|
98
114
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_native.Close, {
|
|
99
|
-
|
|
115
|
+
className: "text-chia-100",
|
|
100
116
|
size: 30
|
|
101
117
|
})
|
|
102
118
|
})]
|
|
103
119
|
})
|
|
104
120
|
});
|
|
105
121
|
}
|
|
106
|
-
;
|
|
107
122
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_index","_classVariants","_native","_index2","_interopRequireDefault","_tailwindPreset","_index3","_index4","_index5","_jsxRuntime","e","__esModule","default","Toast","props","description","isToastOpen","onCloseToast","className","descriptionClassName","durationInMilliSeconds","position","ToastPositionEnum","TOP","variant","ToastVariantEnum","SUCCESS","animatedValue","useRef","Animated","Value","current","timerRef","useEffect","clearTimeout","timing","toValue","duration","useNativeDriver","start","setTimeout","handleClose","toastStyle","toastVariants","containerStyle","containerVariants","iconMap","jsx","Seal","SealVariantEnum","inverted","ERROR","WARNING","ALERT","Icon","View","children","jsxs","merge","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_index","_classVariants","_native","_index2","_interopRequireDefault","_tailwindPreset","_index3","_index4","_index5","_jsxRuntime","e","__esModule","default","Toast","props","description","isToastOpen","onCloseToast","className","descriptionClassName","durationInMilliSeconds","position","ToastPositionEnum","TOP","variant","ToastVariantEnum","SUCCESS","animatedValue","useRef","Animated","Value","current","timerRef","isClosingRef","useEffect","clearTimeout","timing","toValue","duration","useNativeDriver","start","setTimeout","handleClose","toastStyle","toastVariants","containerStyle","containerVariants","iconMap","jsx","Seal","SealVariantEnum","inverted","ERROR","WARNING","ALERT","Icon","animatedStyle","opacity","transform","translateY","interpolate","inputRange","outputRange","View","style","children","jsxs","merge","boxShadow","elevationDown100","Pressable","onPress","Close","size"],"sourceRoot":"../../../../src","sources":["components/Toast/index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,O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WAAA,CAAAuC,GAAA,EAACjD,YAAA,CAAAuE,SAAS;QAACpD,SAAS,EAAC,gBAAgB;QAACqD,OAAO,EAAE7B,WAAY;QAAAuB,QAAA,eACzD,IAAAxD,WAAA,CAAAuC,GAAA,EAAC9C,OAAA,CAAAsE,KAAK;UAACtD,SAAS,EAAC,eAAe;UAACuD,IAAI,EAAE;QAAG,CAAE;MAAC,CACpC,CAAC;IAAA,CACR;EAAC,CACM,CAAC;AAEpB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["cva","CornersEnum","menuCardVariants","variants","variant","grape","java","pear","tangerine","blackberry","chia","outline","corners","SMALL","MEDIUM","LARGE","defaultVariants","textVariants"],"sourceRoot":"../../../../../src","sources":["components/ActionButton/assets/class-variants.ts"],"mappings":";;AAAA,SAASA,GAAG,QAAQ,0BAA0B;AAC9C,SAASC,WAAW,QAAQ,yBAAgB;AAE5C,OAAO,MAAMC,gBAAgB,GAAGF,GAAG,CACjC,CACE,sCAAsC,EACtC,UAAU,EACV,eAAe,EACf,UAAU,EACV,iBAAiB,CAClB,EACD;EACEG,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,KAAK,EAAE,CAAC,cAAc,EAAE,uBAAuB,CAAC;MAChDC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,SAAS,EAAE,
|
|
1
|
+
{"version":3,"names":["cva","CornersEnum","menuCardVariants","variants","variant","grape","java","pear","tangerine","blackberry","chia","outline","corners","SMALL","MEDIUM","LARGE","defaultVariants","textVariants"],"sourceRoot":"../../../../../src","sources":["components/ActionButton/assets/class-variants.ts"],"mappings":";;AAAA,SAASA,GAAG,QAAQ,0BAA0B;AAC9C,SAASC,WAAW,QAAQ,yBAAgB;AAE5C,OAAO,MAAMC,gBAAgB,GAAGF,GAAG,CACjC,CACE,sCAAsC,EACtC,UAAU,EACV,eAAe,EACf,UAAU,EACV,iBAAiB,CAClB,EACD;EACEG,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,KAAK,EAAE,CAAC,cAAc,EAAE,uBAAuB,CAAC;MAChDC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,SAAS,EAAE,CAAC,kBAAkB,EAAE,2BAA2B,CAAC;MAC5DC,UAAU,EAAE,CAAC,mBAAmB,EAAE,4BAA4B,CAAC;MAC/DC,IAAI,EAAE,CAAC,aAAa,EAAE,sBAAsB,CAAC;MAC7CC,OAAO,EAAE,CAAC,4BAA4B,EAAE,0BAA0B;IACpE,CAAC;IACDC,OAAO,EAAE;MACP,CAACX,WAAW,CAACY,KAAK,GAAG,aAAa;MAClC,CAACZ,WAAW,CAACa,MAAM,GAAG,gBAAgB;MACtC,CAACb,WAAW,CAACc,KAAK,GAAG;IACvB;EACF,CAAC;EACDC,eAAe,EAAE;IACfZ,OAAO,EAAE,OAAO;IAChBQ,OAAO,EAAEX,WAAW,CAACa;EACvB;AACF,CACF,CAAC;AAED,OAAO,MAAMG,YAAY,GAAGjB,GAAG,CAAC,EAAE,EAAE;EAClCG,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,KAAK,EAAE,eAAe;MACtBC,IAAI,EAAE,eAAe;MACrBC,IAAI,EAAE,eAAe;MACrBC,SAAS,EAAE,eAAe;MAC1BC,UAAU,EAAE,eAAe;MAC3BC,IAAI,EAAE,eAAe;MACrBC,OAAO,EAAE;IACX;EACF,CAAC;EACDK,eAAe,EAAE;IACfZ,OAAO,EAAE;EACX;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -10,17 +10,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
export function ActionButton(props) {
|
|
11
11
|
const {
|
|
12
12
|
icon,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
primaryText,
|
|
14
|
+
secondaryText,
|
|
15
|
+
primaryTextProps = {},
|
|
16
|
+
secondaryTextProps = {},
|
|
15
17
|
variant = "grape",
|
|
16
18
|
corners = CornersEnum.MEDIUM,
|
|
17
19
|
disabled = false,
|
|
18
20
|
className,
|
|
19
|
-
|
|
20
|
-
labelClassName,
|
|
21
|
-
subtitleClassName,
|
|
22
|
-
labelWeight = FontWeightEnum.MEDIUM,
|
|
23
|
-
subtitleWeight = FontWeightEnum.MEDIUM,
|
|
21
|
+
iconContainerClassName,
|
|
24
22
|
onPress,
|
|
25
23
|
accessibilityLabel,
|
|
26
24
|
ref,
|
|
@@ -44,25 +42,22 @@ export function ActionButton(props) {
|
|
|
44
42
|
variant,
|
|
45
43
|
corners
|
|
46
44
|
}), isPressed && !disabled && pressedColorMap[variant], className);
|
|
47
|
-
const textStyle = merge(textVariants({
|
|
48
|
-
variant
|
|
49
|
-
}));
|
|
50
45
|
|
|
51
46
|
// Define icon colors based on variant
|
|
52
47
|
const iconColorMap = {
|
|
53
|
-
grape: "
|
|
48
|
+
grape: "text-chia-100",
|
|
54
49
|
// chia-100
|
|
55
|
-
java: "
|
|
56
|
-
pear: "
|
|
57
|
-
tangerine: "
|
|
58
|
-
blackberry: "
|
|
59
|
-
chia: "
|
|
60
|
-
outline: "
|
|
50
|
+
java: "text-chia-100",
|
|
51
|
+
pear: "text-chia-100",
|
|
52
|
+
tangerine: "text-chia-100",
|
|
53
|
+
blackberry: "text-chia-100",
|
|
54
|
+
chia: "text-chia-100",
|
|
55
|
+
outline: "text-chia-900" // chia-900
|
|
61
56
|
};
|
|
62
57
|
|
|
63
58
|
// Clone icon element to pass color prop
|
|
64
59
|
const iconWithColor = /*#__PURE__*/React.isValidElement(icon) ? /*#__PURE__*/React.cloneElement(icon, {
|
|
65
|
-
|
|
60
|
+
className: merge(iconColorMap[variant], icon.props?.className || "")
|
|
66
61
|
}) : icon;
|
|
67
62
|
const handlePressIn = event => {
|
|
68
63
|
setIsPressed(true);
|
|
@@ -72,6 +67,21 @@ export function ActionButton(props) {
|
|
|
72
67
|
setIsPressed(false);
|
|
73
68
|
onPressOut?.(event);
|
|
74
69
|
};
|
|
70
|
+
const textStyle = merge(textVariants({
|
|
71
|
+
variant
|
|
72
|
+
}));
|
|
73
|
+
const mergedPrimaryTextProps = {
|
|
74
|
+
variant: "label_large",
|
|
75
|
+
weight: FontWeightEnum.MEDIUM,
|
|
76
|
+
...primaryTextProps,
|
|
77
|
+
className: merge(textStyle, disabled && "opacity-60", primaryTextProps.className)
|
|
78
|
+
};
|
|
79
|
+
const mergedSecondaryTextProps = {
|
|
80
|
+
variant: "label_large",
|
|
81
|
+
weight: FontWeightEnum.BOLD,
|
|
82
|
+
...secondaryTextProps,
|
|
83
|
+
className: merge(textStyle, disabled && "opacity-60", secondaryTextProps.className)
|
|
84
|
+
};
|
|
75
85
|
return /*#__PURE__*/_jsxs(Pressable, {
|
|
76
86
|
ref: ref,
|
|
77
87
|
disabled: disabled,
|
|
@@ -80,31 +90,26 @@ export function ActionButton(props) {
|
|
|
80
90
|
onPressIn: handlePressIn,
|
|
81
91
|
onPressOut: handlePressOut,
|
|
82
92
|
accessibilityRole: "button",
|
|
83
|
-
accessibilityLabel: accessibilityLabel || `${
|
|
93
|
+
accessibilityLabel: accessibilityLabel || `${primaryText}${secondaryText ? ` ${secondaryText}` : ""}`,
|
|
84
94
|
accessibilityState: {
|
|
85
95
|
disabled: disabled
|
|
86
96
|
},
|
|
87
97
|
pointerEvents: disabled ? "none" : "auto",
|
|
88
98
|
...rest,
|
|
89
99
|
children: [/*#__PURE__*/_jsx(View, {
|
|
90
|
-
className: merge("flex items-start shrink-0", disabled && "opacity-60",
|
|
100
|
+
className: merge("flex items-start shrink-0", disabled && "opacity-60", iconContainerClassName),
|
|
91
101
|
children: iconWithColor
|
|
92
102
|
}), /*#__PURE__*/_jsxs(View, {
|
|
93
103
|
className: "shrink-0",
|
|
94
104
|
children: [/*#__PURE__*/_jsx(Typography, {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
variant: "label_large",
|
|
101
|
-
weight: subtitleWeight,
|
|
102
|
-
className: merge(textStyle, disabled && "opacity-60", subtitleClassName),
|
|
103
|
-
children: subtitle
|
|
105
|
+
...mergedPrimaryTextProps,
|
|
106
|
+
children: primaryText
|
|
107
|
+
}), secondaryText && /*#__PURE__*/_jsx(Typography, {
|
|
108
|
+
...mergedSecondaryTextProps,
|
|
109
|
+
children: secondaryText
|
|
104
110
|
})]
|
|
105
111
|
})]
|
|
106
112
|
});
|
|
107
113
|
}
|
|
108
114
|
ActionButton.displayName = "ActionButton";
|
|
109
|
-
export { ActionButtonCorners, ActionButtonProps, ActionButtonVariant } from "./types.js";
|
|
110
115
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["merge","React","Pressable","View","CornersEnum","FontWeightEnum","Typography","menuCardVariants","textVariants","jsx","_jsx","jsxs","_jsxs","ActionButton","props","icon","
|
|
1
|
+
{"version":3,"names":["merge","React","Pressable","View","CornersEnum","FontWeightEnum","Typography","menuCardVariants","textVariants","jsx","_jsx","jsxs","_jsxs","ActionButton","props","icon","primaryText","secondaryText","primaryTextProps","secondaryTextProps","variant","corners","MEDIUM","disabled","className","iconContainerClassName","onPress","accessibilityLabel","ref","onPressIn","onPressOut","rest","isPressed","setIsPressed","useState","pressedColorMap","grape","java","pear","tangerine","blackberry","chia","outline","containerStyle","iconColorMap","iconWithColor","isValidElement","cloneElement","handlePressIn","event","handlePressOut","textStyle","mergedPrimaryTextProps","weight","mergedSecondaryTextProps","BOLD","accessibilityRole","accessibilityState","pointerEvents","children","displayName"],"sourceRoot":"../../../../src","sources":["components/ActionButton/index.tsx"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,wBAAwB;AAC9C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS,EAAEC,IAAI,QAAQ,cAAc;AAC9C,SAAS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;IACjBG,SAAS,EAAEmB,aAAc;IACzBlB,UAAU,EAAEoB,cAAe;IAC3BM,iBAAiB,EAAC,QAAQ;IAC1B7B,kBAAkB,EAChBA,kBAAkB,IAClB,GAAGX,WAAW,GAAGC,aAAa,GAAG,IAAIA,aAAa,EAAE,GAAG,EAAE,EAC1D;IACDwC,kBAAkB,EAAE;MAClBlC,QAAQ,EAAEA;IACZ,CAAE;IACFmC,aAAa,EAAEnC,QAAQ,GAAG,MAAM,GAAG,MAAO;IAAA,GACtCQ,IAAI;IAAA4B,QAAA,gBAGRjD,IAAA,CAACP,IAAI;MACHqB,SAAS,EAAExB,KAAK,CACd,2BAA2B,EAC3BuB,QAAQ,IAAI,YAAY,EACxBE,sBACF,CAAE;MAAAkC,QAAA,EAEDd;IAAa,CACV,CAAC,eAGPjC,KAAA,CAACT,IAAI;MAACqB,SAAS,EAAC,UAAU;MAAAmC,QAAA,gBACxBjD,IAAA,CAACJ,UAAU;QAAA,GAAK8C,sBAAsB;QAAAO,QAAA,EAAG3C;MAAW,CAAa,CAAC,EACjEC,aAAa,iBACZP,IAAA,CAACJ,UAAU;QAAA,GAAKgD,wBAAwB;QAAAK,QAAA,EAAG1C;MAAa,CAAa,CACtE;IAAA,CACG,CAAC;EAAA,CACE,CAAC;AAEhB;AAEAJ,YAAY,CAAC+C,WAAW,GAAG,cAAc","ignoreList":[]}
|
|
@@ -24,8 +24,10 @@ export function Toast(props) {
|
|
|
24
24
|
} = props;
|
|
25
25
|
const animatedValue = useRef(new Animated.Value(0)).current;
|
|
26
26
|
const timerRef = useRef(null);
|
|
27
|
+
const isClosingRef = useRef(false);
|
|
27
28
|
useEffect(() => {
|
|
28
29
|
if (!isToastOpen) return;
|
|
30
|
+
isClosingRef.current = false;
|
|
29
31
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
30
32
|
Animated.timing(animatedValue, {
|
|
31
33
|
toValue: 1,
|
|
@@ -33,6 +35,8 @@ export function Toast(props) {
|
|
|
33
35
|
useNativeDriver: true
|
|
34
36
|
}).start();
|
|
35
37
|
timerRef.current = setTimeout(() => {
|
|
38
|
+
if (isClosingRef.current) return;
|
|
39
|
+
isClosingRef.current = true;
|
|
36
40
|
Animated.timing(animatedValue, {
|
|
37
41
|
toValue: 0,
|
|
38
42
|
duration: 200,
|
|
@@ -47,8 +51,16 @@ export function Toast(props) {
|
|
|
47
51
|
}, [isToastOpen]);
|
|
48
52
|
if (!isToastOpen) return null;
|
|
49
53
|
function handleClose() {
|
|
50
|
-
|
|
54
|
+
if (isClosingRef.current) return;
|
|
55
|
+
isClosingRef.current = true;
|
|
51
56
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
57
|
+
Animated.timing(animatedValue, {
|
|
58
|
+
toValue: 0,
|
|
59
|
+
duration: 200,
|
|
60
|
+
useNativeDriver: true
|
|
61
|
+
}).start(() => {
|
|
62
|
+
onCloseToast(false);
|
|
63
|
+
});
|
|
52
64
|
}
|
|
53
65
|
const toastStyle = toastVariants({
|
|
54
66
|
variant
|
|
@@ -71,32 +83,35 @@ export function Toast(props) {
|
|
|
71
83
|
})
|
|
72
84
|
};
|
|
73
85
|
const Icon = iconMap[variant];
|
|
86
|
+
const animatedStyle = {
|
|
87
|
+
opacity: animatedValue,
|
|
88
|
+
transform: [{
|
|
89
|
+
translateY: animatedValue.interpolate({
|
|
90
|
+
inputRange: [0, 1],
|
|
91
|
+
outputRange: [-20, 0]
|
|
92
|
+
})
|
|
93
|
+
}]
|
|
94
|
+
};
|
|
74
95
|
return /*#__PURE__*/_jsx(Animated.View, {
|
|
75
96
|
className: containerStyle,
|
|
97
|
+
style: animatedStyle,
|
|
76
98
|
children: /*#__PURE__*/_jsxs(View, {
|
|
77
99
|
className: merge(toastStyle, className),
|
|
78
100
|
style: {
|
|
79
101
|
boxShadow: elevationDown100
|
|
80
102
|
},
|
|
81
|
-
children: [/*#__PURE__*/
|
|
82
|
-
className: "
|
|
83
|
-
children:
|
|
84
|
-
className: "flex items-center gap-8",
|
|
85
|
-
children: /*#__PURE__*/_jsx(Typography, {
|
|
86
|
-
className: merge("title_small font-bold text-chia-100", descriptionClassName),
|
|
87
|
-
children: description
|
|
88
|
-
})
|
|
89
|
-
})]
|
|
103
|
+
children: [/*#__PURE__*/_jsx(Icon, {}), /*#__PURE__*/_jsx(Typography, {
|
|
104
|
+
className: merge("title_small font-bold text-chia-100 truncate flex-1", descriptionClassName),
|
|
105
|
+
children: description
|
|
90
106
|
}), /*#__PURE__*/_jsx(Pressable, {
|
|
91
107
|
className: "cursor-pointer",
|
|
92
108
|
onPress: handleClose,
|
|
93
109
|
children: /*#__PURE__*/_jsx(Close, {
|
|
94
|
-
|
|
110
|
+
className: "text-chia-100",
|
|
95
111
|
size: 30
|
|
96
112
|
})
|
|
97
113
|
})]
|
|
98
114
|
})
|
|
99
115
|
});
|
|
100
116
|
}
|
|
101
|
-
;
|
|
102
117
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","View","Animated","Pressable","ToastPositionEnum","ToastVariantEnum","containerVariants","toastVariants","Close","Typography","merge","Seal","SealVariantEnum","elevationDown100","jsx","_jsx","jsxs","_jsxs","Toast","props","description","isToastOpen","onCloseToast","className","descriptionClassName","durationInMilliSeconds","position","TOP","variant","SUCCESS","animatedValue","Value","current","timerRef","clearTimeout","timing","toValue","duration","useNativeDriver","start","setTimeout","handleClose","toastStyle","containerStyle","iconMap","inverted","ERROR","WARNING","ALERT","Icon","
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","View","Animated","Pressable","ToastPositionEnum","ToastVariantEnum","containerVariants","toastVariants","Close","Typography","merge","Seal","SealVariantEnum","elevationDown100","jsx","_jsx","jsxs","_jsxs","Toast","props","description","isToastOpen","onCloseToast","className","descriptionClassName","durationInMilliSeconds","position","TOP","variant","SUCCESS","animatedValue","Value","current","timerRef","isClosingRef","clearTimeout","timing","toValue","duration","useNativeDriver","start","setTimeout","handleClose","toastStyle","containerStyle","iconMap","inverted","ERROR","WARNING","ALERT","Icon","animatedStyle","opacity","transform","translateY","interpolate","inputRange","outputRange","style","children","boxShadow","onPress","size"],"sourceRoot":"../../../../src","sources":["components/Toast/index.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,cAAc;AAExD,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,kBAAS;AAC7D,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,4BAAyB;AAE1E,SAASC,KAAK,QAAQ,qBAAqB;AAC3C,OAAOC,UAAU,MAAM,wBAAe;AACtC,SAASC,KAAK,QAAQ,wBAAwB;AAC9C,SAASC,IAAI,QAAQ,kBAAS;AAC9B,SAASC,eAAe,QAAQ,wBAAe;AAC/C,SAASC,gBAAgB,QAAQ,sCAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE/D,OAAO,SAASC,KAAKA,CAACC,KAAiB,EAAE;EACvC,MAAM;IACJC,WAAW;IACXC,WAAW;IACXC,YAAY;IACZC,SAAS;IACTC,oBAAoB;IACpBC,sBAAsB,GAAG,IAAI;IAC7BC,QAAQ,GAAGtB,iBAAiB,CAACuB,GAAG;IAChCC,OAAO,GAAGvB,gBAAgB,CAACwB;EAC7B,CAAC,GAAGV,KAAK;EAET,MAAMW,aAAa,GAAG9B,MAAM,CAAC,IAAIE,QAAQ,CAAC6B,KAAK,CAAC,CAAC,CAAC,CAAC,CAACC,OAAO;EAC3D,MAAMC,QAAQ,GAAGjC,MAAM,CAAwB,IAAI,CAAC;EACpD,MAAMkC,YAAY,GAAGlC,MAAM,CAAC,KAAK,CAAC;EAElCD,SAAS,CAAC,MAAM;IACd,IAAI,CAACsB,WAAW,EAAE;IAElBa,YAAY,CAACF,OAAO,GAAG,KAAK;IAE5B,IAAIC,QAAQ,CAACD,OAAO,EAAEG,YAAY,CAACF,QAAQ,CA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C;MAAW,CACF,CAAC,eAEbL,IAAA,CAACZ,SAAS;QAACoB,SAAS,EAAC,gBAAgB;QAACsC,OAAO,EAAEnB,WAAY;QAAAiB,QAAA,eACzD5C,IAAA,CAACP,KAAK;UAACe,SAAS,EAAC,eAAe;UAACuC,IAAI,EAAE;QAAG,CAAE;MAAC,CACpC,CAAC;IAAA,CACR;EAAC,CACM,CAAC;AAEpB","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { VariantProps } from "class-variance-authority";
|
|
2
2
|
import { PressableProps, View } from "react-native";
|
|
3
|
-
import { CornersEnum
|
|
3
|
+
import { CornersEnum } from "../../enums";
|
|
4
|
+
import { TypographyProps } from "../Typography/types";
|
|
4
5
|
import { menuCardVariants } from "./assets/class-variants";
|
|
5
6
|
export type ActionButtonVariant = "grape" | "java" | "pear" | "tangerine" | "blackberry" | "chia" | "outline";
|
|
6
7
|
export type ActionButtonCorners = CornersEnum.SMALL | CornersEnum.MEDIUM | CornersEnum.LARGE;
|
|
@@ -10,13 +11,21 @@ export interface ActionButtonProps extends VariantProps<typeof menuCardVariants>
|
|
|
10
11
|
*/
|
|
11
12
|
icon: React.ReactNode;
|
|
12
13
|
/**
|
|
13
|
-
* The main label
|
|
14
|
+
* The primary text (main label)
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
primaryText: string;
|
|
16
17
|
/**
|
|
17
|
-
* The
|
|
18
|
+
* The secondary text below the primary text
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
secondaryText?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Props to pass to the primary text Typography component
|
|
23
|
+
*/
|
|
24
|
+
primaryTextProps?: Omit<TypographyProps, "children">;
|
|
25
|
+
/**
|
|
26
|
+
* Props to pass to the secondary text Typography component
|
|
27
|
+
*/
|
|
28
|
+
secondaryTextProps?: Omit<TypographyProps, "children">;
|
|
20
29
|
/**
|
|
21
30
|
* Visual style variant of the card
|
|
22
31
|
*/
|
|
@@ -36,25 +45,7 @@ export interface ActionButtonProps extends VariantProps<typeof menuCardVariants>
|
|
|
36
45
|
/**
|
|
37
46
|
* Additional class names for the icon container
|
|
38
47
|
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Additional class names for the label text
|
|
42
|
-
*/
|
|
43
|
-
labelClassName?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Additional class names for the subtitle text
|
|
46
|
-
*/
|
|
47
|
-
subtitleClassName?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Font weight for the label text
|
|
50
|
-
* @default FontWeightEnum.MEDIUM
|
|
51
|
-
*/
|
|
52
|
-
labelWeight?: FontWeightEnum;
|
|
53
|
-
/**
|
|
54
|
-
* Font weight for the subtitle text
|
|
55
|
-
* @default FontWeightEnum.MEDIUM
|
|
56
|
-
*/
|
|
57
|
-
subtitleWeight?: FontWeightEnum;
|
|
48
|
+
iconContainerClassName?: string;
|
|
58
49
|
/**
|
|
59
50
|
* Callback when card is pressed
|
|
60
51
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kivid/native-components",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.16",
|
|
4
4
|
"description": "A React Native component library for the Butterfly Design System.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"react": "19.0.0",
|
|
80
80
|
"ts-jest": "^29.2.5",
|
|
81
81
|
"typescript": "~5.8.3",
|
|
82
|
-
"@kivid/
|
|
83
|
-
"@kivid/
|
|
82
|
+
"@kivid/tailwind-preset": "1.0.0-alpha.16",
|
|
83
|
+
"@kivid/icons": "1.0.0-alpha.16"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@lottiefiles/dotlottie-react": "^0.15.1",
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"react-native-svg": "^15.12.0",
|
|
91
91
|
"react-native": "0.79.5",
|
|
92
92
|
"react": "19.0.0",
|
|
93
|
-
"@kivid/
|
|
94
|
-
"@kivid/
|
|
93
|
+
"@kivid/tailwind-preset": "1.0.0-alpha.16",
|
|
94
|
+
"@kivid/icons": "1.0.0-alpha.16"
|
|
95
95
|
},
|
|
96
96
|
"eslintIgnore": [
|
|
97
97
|
"node_modules/",
|
|
@@ -15,19 +15,10 @@ export const menuCardVariants = cva(
|
|
|
15
15
|
grape: ["bg-grape-500", "disabled:bg-grape-200"],
|
|
16
16
|
java: ["bg-java-500", "disabled:bg-java-200"],
|
|
17
17
|
pear: ["bg-pear-500", "disabled:bg-pear-200"],
|
|
18
|
-
tangerine: [
|
|
19
|
-
|
|
20
|
-
"disabled:bg-tangerine-200",
|
|
21
|
-
],
|
|
22
|
-
blackberry: [
|
|
23
|
-
"bg-blackberry-500",
|
|
24
|
-
"disabled:bg-blackberry-200",
|
|
25
|
-
],
|
|
18
|
+
tangerine: ["bg-tangerine-500", "disabled:bg-tangerine-200"],
|
|
19
|
+
blackberry: ["bg-blackberry-500", "disabled:bg-blackberry-200"],
|
|
26
20
|
chia: ["bg-chia-700", "disabled:bg-chia-400"],
|
|
27
|
-
outline: [
|
|
28
|
-
"border-100 border-chia-400",
|
|
29
|
-
"disabled:border-chia-300",
|
|
30
|
-
],
|
|
21
|
+
outline: ["border-100 border-chia-400", "disabled:border-chia-300"],
|
|
31
22
|
},
|
|
32
23
|
corners: {
|
|
33
24
|
[CornersEnum.SMALL]: "rounded-700",
|
|
@@ -3,26 +3,21 @@ import React from "react";
|
|
|
3
3
|
import { Pressable, View } from "react-native";
|
|
4
4
|
import { CornersEnum, FontWeightEnum } from "../../enums";
|
|
5
5
|
import { Typography } from "../Typography";
|
|
6
|
-
import {
|
|
7
|
-
menuCardVariants,
|
|
8
|
-
textVariants,
|
|
9
|
-
} from "./assets/class-variants";
|
|
6
|
+
import { menuCardVariants, textVariants } from "./assets/class-variants";
|
|
10
7
|
import type { ActionButtonProps } from "./types";
|
|
11
8
|
|
|
12
9
|
export function ActionButton(props: ActionButtonProps) {
|
|
13
10
|
const {
|
|
14
11
|
icon,
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
primaryText,
|
|
13
|
+
secondaryText,
|
|
14
|
+
primaryTextProps = {},
|
|
15
|
+
secondaryTextProps = {},
|
|
17
16
|
variant = "grape",
|
|
18
17
|
corners = CornersEnum.MEDIUM,
|
|
19
18
|
disabled = false,
|
|
20
19
|
className,
|
|
21
|
-
|
|
22
|
-
labelClassName,
|
|
23
|
-
subtitleClassName,
|
|
24
|
-
labelWeight = FontWeightEnum.MEDIUM,
|
|
25
|
-
subtitleWeight = FontWeightEnum.MEDIUM,
|
|
20
|
+
iconContainerClassName,
|
|
26
21
|
onPress,
|
|
27
22
|
accessibilityLabel,
|
|
28
23
|
ref,
|
|
@@ -53,23 +48,24 @@ export function ActionButton(props: ActionButtonProps) {
|
|
|
53
48
|
className
|
|
54
49
|
);
|
|
55
50
|
|
|
56
|
-
const textStyle = merge(textVariants({ variant }));
|
|
57
|
-
|
|
58
51
|
// Define icon colors based on variant
|
|
59
52
|
const iconColorMap = {
|
|
60
|
-
grape: "
|
|
61
|
-
java: "
|
|
62
|
-
pear: "
|
|
63
|
-
tangerine: "
|
|
64
|
-
blackberry: "
|
|
65
|
-
chia: "
|
|
66
|
-
outline: "
|
|
53
|
+
grape: "text-chia-100", // chia-100
|
|
54
|
+
java: "text-chia-100",
|
|
55
|
+
pear: "text-chia-100",
|
|
56
|
+
tangerine: "text-chia-100",
|
|
57
|
+
blackberry: "text-chia-100",
|
|
58
|
+
chia: "text-chia-100",
|
|
59
|
+
outline: "text-chia-900", // chia-900
|
|
67
60
|
};
|
|
68
61
|
|
|
69
62
|
// Clone icon element to pass color prop
|
|
70
63
|
const iconWithColor = React.isValidElement(icon)
|
|
71
64
|
? React.cloneElement(icon as React.ReactElement<any>, {
|
|
72
|
-
|
|
65
|
+
className: merge(
|
|
66
|
+
iconColorMap[variant],
|
|
67
|
+
(icon as React.ReactElement<any>).props?.className || ""
|
|
68
|
+
),
|
|
73
69
|
})
|
|
74
70
|
: icon;
|
|
75
71
|
|
|
@@ -83,6 +79,30 @@ export function ActionButton(props: ActionButtonProps) {
|
|
|
83
79
|
onPressOut?.(event);
|
|
84
80
|
};
|
|
85
81
|
|
|
82
|
+
const textStyle = merge(textVariants({ variant }));
|
|
83
|
+
|
|
84
|
+
const mergedPrimaryTextProps = {
|
|
85
|
+
variant: "label_large" as const,
|
|
86
|
+
weight: FontWeightEnum.MEDIUM as const,
|
|
87
|
+
...primaryTextProps,
|
|
88
|
+
className: merge(
|
|
89
|
+
textStyle,
|
|
90
|
+
disabled && "opacity-60",
|
|
91
|
+
primaryTextProps.className
|
|
92
|
+
),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const mergedSecondaryTextProps = {
|
|
96
|
+
variant: "label_large" as const,
|
|
97
|
+
weight: FontWeightEnum.BOLD as const,
|
|
98
|
+
...secondaryTextProps,
|
|
99
|
+
className: merge(
|
|
100
|
+
textStyle,
|
|
101
|
+
disabled && "opacity-60",
|
|
102
|
+
secondaryTextProps.className
|
|
103
|
+
),
|
|
104
|
+
};
|
|
105
|
+
|
|
86
106
|
return (
|
|
87
107
|
<Pressable
|
|
88
108
|
ref={ref}
|
|
@@ -92,7 +112,10 @@ export function ActionButton(props: ActionButtonProps) {
|
|
|
92
112
|
onPressIn={handlePressIn}
|
|
93
113
|
onPressOut={handlePressOut}
|
|
94
114
|
accessibilityRole="button"
|
|
95
|
-
accessibilityLabel={
|
|
115
|
+
accessibilityLabel={
|
|
116
|
+
accessibilityLabel ||
|
|
117
|
+
`${primaryText}${secondaryText ? ` ${secondaryText}` : ""}`
|
|
118
|
+
}
|
|
96
119
|
accessibilityState={{
|
|
97
120
|
disabled: disabled,
|
|
98
121
|
}}
|
|
@@ -100,27 +123,21 @@ export function ActionButton(props: ActionButtonProps) {
|
|
|
100
123
|
{...rest}
|
|
101
124
|
>
|
|
102
125
|
{/* Icon Container */}
|
|
103
|
-
<View
|
|
126
|
+
<View
|
|
127
|
+
className={merge(
|
|
128
|
+
"flex items-start shrink-0",
|
|
129
|
+
disabled && "opacity-60",
|
|
130
|
+
iconContainerClassName
|
|
131
|
+
)}
|
|
132
|
+
>
|
|
104
133
|
{iconWithColor}
|
|
105
134
|
</View>
|
|
106
135
|
|
|
107
136
|
{/* Label Container */}
|
|
108
137
|
<View className="shrink-0">
|
|
109
|
-
<Typography
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
className={merge(textStyle, disabled && "opacity-60", labelClassName)}
|
|
113
|
-
>
|
|
114
|
-
{label}
|
|
115
|
-
</Typography>
|
|
116
|
-
{subtitle && (
|
|
117
|
-
<Typography
|
|
118
|
-
variant="label_large"
|
|
119
|
-
weight={subtitleWeight as any}
|
|
120
|
-
className={merge(textStyle, disabled && "opacity-60", subtitleClassName)}
|
|
121
|
-
>
|
|
122
|
-
{subtitle}
|
|
123
|
-
</Typography>
|
|
138
|
+
<Typography {...mergedPrimaryTextProps}>{primaryText}</Typography>
|
|
139
|
+
{secondaryText && (
|
|
140
|
+
<Typography {...mergedSecondaryTextProps}>{secondaryText}</Typography>
|
|
124
141
|
)}
|
|
125
142
|
</View>
|
|
126
143
|
</Pressable>
|
|
@@ -128,6 +145,3 @@ export function ActionButton(props: ActionButtonProps) {
|
|
|
128
145
|
}
|
|
129
146
|
|
|
130
147
|
ActionButton.displayName = "ActionButton";
|
|
131
|
-
|
|
132
|
-
export { ActionButtonCorners, ActionButtonProps, ActionButtonVariant } from "./types";
|
|
133
|
-
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { VariantProps } from "class-variance-authority";
|
|
2
2
|
import { PressableProps, View } from "react-native";
|
|
3
|
-
import { CornersEnum
|
|
3
|
+
import { CornersEnum } from "../../enums";
|
|
4
|
+
import { TypographyProps } from "../Typography/types";
|
|
4
5
|
import { menuCardVariants } from "./assets/class-variants";
|
|
5
6
|
|
|
6
7
|
export type ActionButtonVariant =
|
|
@@ -25,13 +26,21 @@ export interface ActionButtonProps
|
|
|
25
26
|
*/
|
|
26
27
|
icon: React.ReactNode;
|
|
27
28
|
/**
|
|
28
|
-
* The main label
|
|
29
|
+
* The primary text (main label)
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
primaryText: string;
|
|
31
32
|
/**
|
|
32
|
-
* The
|
|
33
|
+
* The secondary text below the primary text
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
+
secondaryText?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Props to pass to the primary text Typography component
|
|
38
|
+
*/
|
|
39
|
+
primaryTextProps?: Omit<TypographyProps, "children">;
|
|
40
|
+
/**
|
|
41
|
+
* Props to pass to the secondary text Typography component
|
|
42
|
+
*/
|
|
43
|
+
secondaryTextProps?: Omit<TypographyProps, "children">;
|
|
35
44
|
/**
|
|
36
45
|
* Visual style variant of the card
|
|
37
46
|
*/
|
|
@@ -51,25 +60,7 @@ export interface ActionButtonProps
|
|
|
51
60
|
/**
|
|
52
61
|
* Additional class names for the icon container
|
|
53
62
|
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Additional class names for the label text
|
|
57
|
-
*/
|
|
58
|
-
labelClassName?: string;
|
|
59
|
-
/**
|
|
60
|
-
* Additional class names for the subtitle text
|
|
61
|
-
*/
|
|
62
|
-
subtitleClassName?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Font weight for the label text
|
|
65
|
-
* @default FontWeightEnum.MEDIUM
|
|
66
|
-
*/
|
|
67
|
-
labelWeight?: FontWeightEnum;
|
|
68
|
-
/**
|
|
69
|
-
* Font weight for the subtitle text
|
|
70
|
-
* @default FontWeightEnum.MEDIUM
|
|
71
|
-
*/
|
|
72
|
-
subtitleWeight?: FontWeightEnum;
|
|
63
|
+
iconContainerClassName?: string;
|
|
73
64
|
/**
|
|
74
65
|
* Callback when card is pressed
|
|
75
66
|
*/
|
|
@@ -11,7 +11,6 @@ import { Seal } from "../Seal";
|
|
|
11
11
|
import { SealVariantEnum } from "../Seal/enums";
|
|
12
12
|
import { elevationDown100 } from "../../styles/mixins/shadows";
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
export function Toast(props: ToastProps) {
|
|
16
15
|
const {
|
|
17
16
|
description,
|
|
@@ -21,15 +20,18 @@ export function Toast(props: ToastProps) {
|
|
|
21
20
|
descriptionClassName,
|
|
22
21
|
durationInMilliSeconds = 3000,
|
|
23
22
|
position = ToastPositionEnum.TOP,
|
|
24
|
-
variant = ToastVariantEnum.SUCCESS
|
|
23
|
+
variant = ToastVariantEnum.SUCCESS,
|
|
25
24
|
} = props;
|
|
26
25
|
|
|
27
26
|
const animatedValue = useRef(new Animated.Value(0)).current;
|
|
28
27
|
const timerRef = useRef<NodeJS.Timeout | null>(null);
|
|
28
|
+
const isClosingRef = useRef(false);
|
|
29
29
|
|
|
30
30
|
useEffect(() => {
|
|
31
31
|
if (!isToastOpen) return;
|
|
32
32
|
|
|
33
|
+
isClosingRef.current = false;
|
|
34
|
+
|
|
33
35
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
34
36
|
|
|
35
37
|
Animated.timing(animatedValue, {
|
|
@@ -39,6 +41,9 @@ export function Toast(props: ToastProps) {
|
|
|
39
41
|
}).start();
|
|
40
42
|
|
|
41
43
|
timerRef.current = setTimeout(() => {
|
|
44
|
+
if (isClosingRef.current) return;
|
|
45
|
+
|
|
46
|
+
isClosingRef.current = true;
|
|
42
47
|
Animated.timing(animatedValue, {
|
|
43
48
|
toValue: 0,
|
|
44
49
|
duration: 200,
|
|
@@ -56,47 +61,71 @@ export function Toast(props: ToastProps) {
|
|
|
56
61
|
if (!isToastOpen) return null;
|
|
57
62
|
|
|
58
63
|
function handleClose() {
|
|
59
|
-
|
|
64
|
+
if (isClosingRef.current) return;
|
|
65
|
+
|
|
66
|
+
isClosingRef.current = true;
|
|
60
67
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
68
|
+
|
|
69
|
+
Animated.timing(animatedValue, {
|
|
70
|
+
toValue: 0,
|
|
71
|
+
duration: 200,
|
|
72
|
+
useNativeDriver: true,
|
|
73
|
+
}).start(() => {
|
|
74
|
+
onCloseToast(false);
|
|
75
|
+
});
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
const toastStyle = toastVariants({ variant });
|
|
64
79
|
const containerStyle = containerVariants({ position });
|
|
65
80
|
|
|
66
81
|
const iconMap = {
|
|
67
|
-
[ToastVariantEnum.SUCCESS]: () =>
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
[ToastVariantEnum.SUCCESS]: () => (
|
|
83
|
+
<Seal variant={SealVariantEnum.SUCCESS} inverted />
|
|
84
|
+
),
|
|
85
|
+
[ToastVariantEnum.ERROR]: () => (
|
|
86
|
+
<Seal variant={SealVariantEnum.ERROR} inverted />
|
|
87
|
+
),
|
|
88
|
+
[ToastVariantEnum.WARNING]: () => (
|
|
89
|
+
<Seal variant={SealVariantEnum.ALERT} inverted />
|
|
90
|
+
),
|
|
70
91
|
};
|
|
71
92
|
|
|
72
93
|
const Icon = iconMap[variant];
|
|
73
94
|
|
|
95
|
+
const animatedStyle = {
|
|
96
|
+
opacity: animatedValue,
|
|
97
|
+
transform: [
|
|
98
|
+
{
|
|
99
|
+
translateY: animatedValue.interpolate({
|
|
100
|
+
inputRange: [0, 1],
|
|
101
|
+
outputRange: [-20, 0],
|
|
102
|
+
}),
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
|
|
74
107
|
return (
|
|
75
|
-
<Animated.View
|
|
76
|
-
className={containerStyle}
|
|
77
|
-
>
|
|
108
|
+
<Animated.View className={containerStyle} style={animatedStyle}>
|
|
78
109
|
<View
|
|
79
110
|
className={merge(toastStyle, className)}
|
|
80
111
|
style={{
|
|
81
|
-
boxShadow: elevationDown100
|
|
112
|
+
boxShadow: elevationDown100,
|
|
82
113
|
}}
|
|
83
114
|
>
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</View>
|
|
94
|
-
</View>
|
|
115
|
+
<Icon />
|
|
116
|
+
<Typography
|
|
117
|
+
className={merge(
|
|
118
|
+
"title_small font-bold text-chia-100 truncate flex-1",
|
|
119
|
+
descriptionClassName
|
|
120
|
+
)}
|
|
121
|
+
>
|
|
122
|
+
{description}
|
|
123
|
+
</Typography>
|
|
95
124
|
|
|
96
125
|
<Pressable className="cursor-pointer" onPress={handleClose}>
|
|
97
|
-
<Close
|
|
126
|
+
<Close className="text-chia-100" size={30} />
|
|
98
127
|
</Pressable>
|
|
99
128
|
</View>
|
|
100
129
|
</Animated.View>
|
|
101
130
|
);
|
|
102
|
-
}
|
|
131
|
+
}
|