@kivid/native-components 1.0.0-alpha.15 → 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/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/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
|
@@ -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,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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,SAASC,WAAW,EAAEC,cAAc,QAAQ,sBAAa;AACzD,SAASC,UAAU,QAAQ,wBAAe;AAC1C,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,4BAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAGzE,OAAO,SAASC,YAAYA,CAACC,KAAwB,EAAE;EACrD,MAAM;IACJC,IAAI;IACJC,WAAW;IACXC,aAAa;IACbC,gBAAgB,GAAG,CAAC,CAAC;IACrBC,kBAA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tCQ,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":[]}
|
|
@@ -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/tailwind-preset": "1.0.0-alpha.
|
|
83
|
-
"@kivid/icons": "1.0.0-alpha.
|
|
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/tailwind-preset": "1.0.0-alpha.
|
|
94
|
-
"@kivid/icons": "1.0.0-alpha.
|
|
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
|
*/
|