@metamask-previews/design-system-react-native 0.5.1-preview.89a2095 → 0.6.0-preview.3dc70e1
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/CHANGELOG.md +8 -1
- package/dist/components/AvatarBase/AvatarBase.cjs +9 -11
- package/dist/components/AvatarBase/AvatarBase.cjs.map +1 -1
- package/dist/components/AvatarBase/AvatarBase.d.cts.map +1 -1
- package/dist/components/AvatarBase/AvatarBase.d.mts.map +1 -1
- package/dist/components/AvatarBase/AvatarBase.mjs +9 -11
- package/dist/components/AvatarBase/AvatarBase.mjs.map +1 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.cjs +2 -2
- package/dist/components/AvatarFavicon/AvatarFavicon.cjs.map +1 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.d.cts +1 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.d.cts.map +1 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.d.mts +1 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.d.mts.map +1 -1
- package/dist/components/AvatarFavicon/AvatarFavicon.mjs +2 -2
- package/dist/components/AvatarFavicon/AvatarFavicon.mjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.cjs +4 -5
- package/dist/components/AvatarGroup/AvatarGroup.cjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.d.cts.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.d.mts.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.mjs +4 -5
- package/dist/components/AvatarGroup/AvatarGroup.mjs.map +1 -1
- package/dist/components/AvatarIcon/AvatarIcon.cjs +5 -6
- package/dist/components/AvatarIcon/AvatarIcon.cjs.map +1 -1
- package/dist/components/AvatarIcon/AvatarIcon.d.cts.map +1 -1
- package/dist/components/AvatarIcon/AvatarIcon.d.mts.map +1 -1
- package/dist/components/AvatarIcon/AvatarIcon.mjs +5 -6
- package/dist/components/AvatarIcon/AvatarIcon.mjs.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.cjs +2 -2
- package/dist/components/AvatarNetwork/AvatarNetwork.cjs.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.d.cts +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.d.cts.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.d.mts +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.d.mts.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.mjs +2 -2
- package/dist/components/AvatarNetwork/AvatarNetwork.mjs.map +1 -1
- package/dist/components/AvatarToken/AvatarToken.cjs +2 -2
- package/dist/components/AvatarToken/AvatarToken.cjs.map +1 -1
- package/dist/components/AvatarToken/AvatarToken.d.cts +1 -1
- package/dist/components/AvatarToken/AvatarToken.d.cts.map +1 -1
- package/dist/components/AvatarToken/AvatarToken.d.mts +1 -1
- package/dist/components/AvatarToken/AvatarToken.d.mts.map +1 -1
- package/dist/components/AvatarToken/AvatarToken.mjs +2 -2
- package/dist/components/AvatarToken/AvatarToken.mjs.map +1 -1
- package/dist/components/BadgeCount/BadgeCount.cjs +5 -10
- package/dist/components/BadgeCount/BadgeCount.cjs.map +1 -1
- package/dist/components/BadgeCount/BadgeCount.d.cts.map +1 -1
- package/dist/components/BadgeCount/BadgeCount.d.mts.map +1 -1
- package/dist/components/BadgeCount/BadgeCount.mjs +5 -10
- package/dist/components/BadgeCount/BadgeCount.mjs.map +1 -1
- package/dist/components/BadgeIcon/BadgeIcon.cjs +5 -10
- package/dist/components/BadgeIcon/BadgeIcon.cjs.map +1 -1
- package/dist/components/BadgeIcon/BadgeIcon.d.cts.map +1 -1
- package/dist/components/BadgeIcon/BadgeIcon.d.mts.map +1 -1
- package/dist/components/BadgeIcon/BadgeIcon.mjs +5 -10
- package/dist/components/BadgeIcon/BadgeIcon.mjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.cjs +6 -6
- package/dist/components/BadgeStatus/BadgeStatus.cjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.cjs +8 -8
- package/dist/components/BadgeStatus/BadgeStatus.constants.cjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.d.cts +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.d.cts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.d.mts +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.d.mts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.mjs +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.mjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.d.cts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.d.mts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.mjs +6 -6
- package/dist/components/BadgeStatus/BadgeStatus.mjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.types.cjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.types.d.cts +5 -29
- package/dist/components/BadgeStatus/BadgeStatus.types.d.cts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.types.d.mts +5 -29
- package/dist/components/BadgeStatus/BadgeStatus.types.d.mts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.types.mjs.map +1 -1
- package/dist/components/BadgeStatus/index.cjs +4 -4
- package/dist/components/BadgeStatus/index.cjs.map +1 -1
- package/dist/components/BadgeStatus/index.d.cts +1 -1
- package/dist/components/BadgeStatus/index.d.cts.map +1 -1
- package/dist/components/BadgeStatus/index.d.mts +1 -1
- package/dist/components/BadgeStatus/index.d.mts.map +1 -1
- package/dist/components/BadgeStatus/index.mjs +1 -1
- package/dist/components/BadgeStatus/index.mjs.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.cjs +3 -3
- package/dist/components/BadgeWrapper/BadgeWrapper.cjs.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.d.cts.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.d.mts.map +1 -1
- package/dist/components/BadgeWrapper/BadgeWrapper.mjs +3 -3
- package/dist/components/BadgeWrapper/BadgeWrapper.mjs.map +1 -1
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.cjs +51 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.cjs.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.constants.cjs +7 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.constants.cjs.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.constants.d.cts +3 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.constants.d.cts.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.constants.d.mts +3 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.constants.d.mts.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.constants.mjs +4 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.constants.mjs.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.d.cts +4 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.d.cts.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.d.mts +4 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.d.mts.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.mjs +31 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.mjs.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.types.cjs +3 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.types.cjs.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.types.d.cts +20 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.types.d.cts.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.types.d.mts +20 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.types.d.mts.map +1 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.types.mjs +2 -0
- package/dist/components/BottomSheetOverlay/BottomSheetOverlay.types.mjs.map +1 -0
- package/dist/components/BottomSheetOverlay/index.cjs +6 -0
- package/dist/components/BottomSheetOverlay/index.cjs.map +1 -0
- package/dist/components/BottomSheetOverlay/index.d.cts +3 -0
- package/dist/components/BottomSheetOverlay/index.d.cts.map +1 -0
- package/dist/components/BottomSheetOverlay/index.d.mts +3 -0
- package/dist/components/BottomSheetOverlay/index.d.mts.map +1 -0
- package/dist/components/BottomSheetOverlay/index.mjs +2 -0
- package/dist/components/BottomSheetOverlay/index.mjs.map +1 -0
- package/dist/components/Box/Box.cjs +12 -27
- package/dist/components/Box/Box.cjs.map +1 -1
- package/dist/components/Box/Box.d.cts.map +1 -1
- package/dist/components/Box/Box.d.mts.map +1 -1
- package/dist/components/Box/Box.mjs +12 -27
- package/dist/components/Box/Box.mjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.cjs +50 -41
- package/dist/components/ButtonBase/ButtonBase.cjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.d.cts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.d.mts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.mjs +50 -41
- package/dist/components/ButtonBase/ButtonBase.mjs.map +1 -1
- package/dist/components/ButtonIcon/ButtonIcon.cjs +5 -10
- package/dist/components/ButtonIcon/ButtonIcon.cjs.map +1 -1
- package/dist/components/ButtonIcon/ButtonIcon.d.cts.map +1 -1
- package/dist/components/ButtonIcon/ButtonIcon.d.mts.map +1 -1
- package/dist/components/ButtonIcon/ButtonIcon.mjs +5 -10
- package/dist/components/ButtonIcon/ButtonIcon.mjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.cjs +4 -4
- package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.d.cts.map +1 -1
- package/dist/components/Checkbox/Checkbox.d.mts.map +1 -1
- package/dist/components/Checkbox/Checkbox.mjs +4 -4
- package/dist/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/components/Icon/Icon.cjs +4 -32
- package/dist/components/Icon/Icon.cjs.map +1 -1
- package/dist/components/Icon/Icon.d.cts.map +1 -1
- package/dist/components/Icon/Icon.d.mts.map +1 -1
- package/dist/components/Icon/Icon.mjs +2 -10
- package/dist/components/Icon/Icon.mjs.map +1 -1
- package/dist/components/Text/Text.cjs +9 -14
- package/dist/components/Text/Text.cjs.map +1 -1
- package/dist/components/Text/Text.d.cts.map +1 -1
- package/dist/components/Text/Text.d.mts.map +1 -1
- package/dist/components/Text/Text.mjs +10 -15
- package/dist/components/Text/Text.mjs.map +1 -1
- package/dist/components/index.cjs +4 -2
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -0
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +2 -0
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +1 -0
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.cjs +17 -9
- package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.cjs.map +1 -1
- package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.d.cts +1 -1
- package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.d.cts.map +1 -1
- package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.d.mts +1 -1
- package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.d.mts.map +1 -1
- package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.mjs +17 -6
- package/dist/components/temp-components/ButtonAnimated/ButtonAnimated.mjs.map +1 -1
- package/dist/components/temp-components/Spinner/Spinner.cjs +2 -2
- package/dist/components/temp-components/Spinner/Spinner.cjs.map +1 -1
- package/dist/components/temp-components/Spinner/Spinner.d.cts.map +1 -1
- package/dist/components/temp-components/Spinner/Spinner.d.mts.map +1 -1
- package/dist/components/temp-components/Spinner/Spinner.mjs +2 -2
- package/dist/components/temp-components/Spinner/Spinner.mjs.map +1 -1
- package/dist/types/index.cjs +16 -41
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +15 -38
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +15 -38
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs +15 -40
- package/dist/types/index.mjs.map +1 -1
- package/package.json +13 -9
- package/dist/components/Icon/Icon.utilities.cjs +0 -31
- package/dist/components/Icon/Icon.utilities.cjs.map +0 -1
- package/dist/components/Icon/Icon.utilities.d.cts +0 -22
- package/dist/components/Icon/Icon.utilities.d.cts.map +0 -1
- package/dist/components/Icon/Icon.utilities.d.mts +0 -22
- package/dist/components/Icon/Icon.utilities.d.mts.map +0 -1
- package/dist/components/Icon/Icon.utilities.mjs +0 -27
- package/dist/components/Icon/Icon.utilities.mjs.map +0 -1
- package/dist/components/Text/Text.utilities.cjs +0 -46
- package/dist/components/Text/Text.utilities.cjs.map +0 -1
- package/dist/components/Text/Text.utilities.d.cts +0 -32
- package/dist/components/Text/Text.utilities.d.cts.map +0 -1
- package/dist/components/Text/Text.utilities.d.mts +0 -32
- package/dist/components/Text/Text.utilities.d.mts.map +0 -1
- package/dist/components/Text/Text.utilities.mjs +0 -42
- package/dist/components/Text/Text.utilities.mjs.map +0 -1
|
@@ -9,34 +9,19 @@ import $React from "react";
|
|
|
9
9
|
const React = $importDefault($React);
|
|
10
10
|
import { View } from "react-native/index.js";
|
|
11
11
|
import { TWCLASSMAP_BOX_GAP, TWCLASSMAP_BOX_MARGIN, TWCLASSMAP_BOX_MARGIN_TOP, TWCLASSMAP_BOX_MARGIN_RIGHT, TWCLASSMAP_BOX_MARGIN_BOTTOM, TWCLASSMAP_BOX_MARGIN_LEFT, TWCLASSMAP_BOX_MARGIN_HORIZONTAL, TWCLASSMAP_BOX_MARGIN_VERTICAL, TWCLASSMAP_BOX_PADDING, TWCLASSMAP_BOX_PADDING_TOP, TWCLASSMAP_BOX_PADDING_RIGHT, TWCLASSMAP_BOX_PADDING_BOTTOM, TWCLASSMAP_BOX_PADDING_LEFT, TWCLASSMAP_BOX_PADDING_HORIZONTAL, TWCLASSMAP_BOX_PADDING_VERTICAL, TWCLASSMAP_BOX_BORDER_WIDTH } from "./Box.constants.mjs";
|
|
12
|
-
export const Box = ({ flexDirection, flexWrap, gap, alignItems, justifyContent, margin, marginTop, marginRight, marginBottom, marginLeft, marginHorizontal, marginVertical, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, paddingHorizontal, paddingVertical, borderWidth, borderColor, backgroundColor, twClassName
|
|
12
|
+
export const Box = ({ flexDirection, flexWrap, gap, alignItems, justifyContent, margin, marginTop, marginRight, marginBottom, marginLeft, marginHorizontal, marginVertical, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, paddingHorizontal, paddingVertical, borderWidth, borderColor, backgroundColor, twClassName, style, children, ...props }) => {
|
|
13
13
|
const tw = useTailwind();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
${marginLeft !== undefined ? TWCLASSMAP_BOX_MARGIN_LEFT[marginLeft] : ''}
|
|
26
|
-
${marginHorizontal !== undefined ? TWCLASSMAP_BOX_MARGIN_HORIZONTAL[marginHorizontal] : ''}
|
|
27
|
-
${marginVertical !== undefined ? TWCLASSMAP_BOX_MARGIN_VERTICAL[marginVertical] : ''}
|
|
28
|
-
${padding !== undefined ? TWCLASSMAP_BOX_PADDING[padding] : ''}
|
|
29
|
-
${paddingTop !== undefined ? TWCLASSMAP_BOX_PADDING_TOP[paddingTop] : ''}
|
|
30
|
-
${paddingRight !== undefined ? TWCLASSMAP_BOX_PADDING_RIGHT[paddingRight] : ''}
|
|
31
|
-
${paddingBottom !== undefined ? TWCLASSMAP_BOX_PADDING_BOTTOM[paddingBottom] : ''}
|
|
32
|
-
${paddingLeft !== undefined ? TWCLASSMAP_BOX_PADDING_LEFT[paddingLeft] : ''}
|
|
33
|
-
${paddingHorizontal !== undefined ? TWCLASSMAP_BOX_PADDING_HORIZONTAL[paddingHorizontal] : ''}
|
|
34
|
-
${paddingVertical !== undefined ? TWCLASSMAP_BOX_PADDING_VERTICAL[paddingVertical] : ''}
|
|
35
|
-
${borderWidth !== undefined ? TWCLASSMAP_BOX_BORDER_WIDTH[borderWidth] : ''}
|
|
36
|
-
${borderColor ?? ''}
|
|
37
|
-
${backgroundColor ?? ''}
|
|
38
|
-
${twClassName}`;
|
|
39
|
-
return (<View style={[twContainerClassNames, style]} {...props}>
|
|
14
|
+
return (<View {...props} style={[
|
|
15
|
+
tw.style('flex', flexDirection, flexWrap, gap !== undefined && TWCLASSMAP_BOX_GAP[gap], alignItems, justifyContent, margin !== undefined && TWCLASSMAP_BOX_MARGIN[margin], marginTop !== undefined && TWCLASSMAP_BOX_MARGIN_TOP[marginTop], marginRight !== undefined && TWCLASSMAP_BOX_MARGIN_RIGHT[marginRight], marginBottom !== undefined &&
|
|
16
|
+
TWCLASSMAP_BOX_MARGIN_BOTTOM[marginBottom], marginLeft !== undefined && TWCLASSMAP_BOX_MARGIN_LEFT[marginLeft], marginHorizontal !== undefined &&
|
|
17
|
+
TWCLASSMAP_BOX_MARGIN_HORIZONTAL[marginHorizontal], marginVertical !== undefined &&
|
|
18
|
+
TWCLASSMAP_BOX_MARGIN_VERTICAL[marginVertical], padding !== undefined && TWCLASSMAP_BOX_PADDING[padding], paddingTop !== undefined && TWCLASSMAP_BOX_PADDING_TOP[paddingTop], paddingRight !== undefined &&
|
|
19
|
+
TWCLASSMAP_BOX_PADDING_RIGHT[paddingRight], paddingBottom !== undefined &&
|
|
20
|
+
TWCLASSMAP_BOX_PADDING_BOTTOM[paddingBottom], paddingLeft !== undefined && TWCLASSMAP_BOX_PADDING_LEFT[paddingLeft], paddingHorizontal !== undefined &&
|
|
21
|
+
TWCLASSMAP_BOX_PADDING_HORIZONTAL[paddingHorizontal], paddingVertical !== undefined &&
|
|
22
|
+
TWCLASSMAP_BOX_PADDING_VERTICAL[paddingVertical], borderWidth !== undefined && TWCLASSMAP_BOX_BORDER_WIDTH[borderWidth], borderColor, backgroundColor, twClassName),
|
|
23
|
+
style,
|
|
24
|
+
]}>
|
|
40
25
|
{children}
|
|
41
26
|
</View>);
|
|
42
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.mjs","sourceRoot":"","sources":["../../../src/components/Box/Box.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,MAAK,cAAc;;AAC1B,OAAO,EAAE,IAAI,EAAE,8BAAqB;AAEpC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,gCAAgC,EAChC,8BAA8B,EAC9B,sBAAsB,EACtB,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC3B,iCAAiC,EACjC,+BAA+B,EAC/B,2BAA2B,EAC5B,4BAAwB;AAGzB,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAClB,aAAa,EACb,QAAQ,EACR,GAAG,EACH,UAAU,EACV,cAAc,EACd,MAAM,EACN,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,EACf,WAAW,
|
|
1
|
+
{"version":3,"file":"Box.mjs","sourceRoot":"","sources":["../../../src/components/Box/Box.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,MAAK,cAAc;;AAC1B,OAAO,EAAE,IAAI,EAAE,8BAAqB;AAEpC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cAAc,KAAK,SAAS;gBAC1B,8BAA8B,CAAC,cAAc,CAAC,EAChD,OAAO,KAAK,SAAS,IAAI,sBAAsB,CAAC,OAAO,CAAC,EACxD,UAAU,KAAK,SAAS,IAAI,0BAA0B,CAAC,UAAU,CAAC,EAClE,YAAY,KAAK,SAAS;gBACxB,4BAA4B,CAAC,YAAY,CAAC,EAC5C,aAAa,KAAK,SAAS;gBACzB,6BAA6B,CAAC,aAAa,CAAC,EAC9C,WAAW,KAAK,SAAS,IAAI,2BAA2B,CAAC,WAAW,CAAC,EACrE,iBAAiB,KAAK,SAAS;gBAC7B,iCAAiC,CAAC,iBAAiB,CAAC,EACtD,eAAe,KAAK,SAAS;gBAC3B,+BAA+B,CAAC,eAAe,CAAC,EAClD,WAAW,KAAK,SAAS,IAAI,2BAA2B,CAAC,WAAW,CAAC,EACrE,WAAW,EACX,eAAe,EACf,WAAW,CACZ;YACD,KAAK;SACN,CAAC,CAEF;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React from 'react';\nimport { View } from 'react-native';\n\nimport {\n TWCLASSMAP_BOX_GAP,\n TWCLASSMAP_BOX_MARGIN,\n TWCLASSMAP_BOX_MARGIN_TOP,\n TWCLASSMAP_BOX_MARGIN_RIGHT,\n TWCLASSMAP_BOX_MARGIN_BOTTOM,\n TWCLASSMAP_BOX_MARGIN_LEFT,\n TWCLASSMAP_BOX_MARGIN_HORIZONTAL,\n TWCLASSMAP_BOX_MARGIN_VERTICAL,\n TWCLASSMAP_BOX_PADDING,\n TWCLASSMAP_BOX_PADDING_TOP,\n TWCLASSMAP_BOX_PADDING_RIGHT,\n TWCLASSMAP_BOX_PADDING_BOTTOM,\n TWCLASSMAP_BOX_PADDING_LEFT,\n TWCLASSMAP_BOX_PADDING_HORIZONTAL,\n TWCLASSMAP_BOX_PADDING_VERTICAL,\n TWCLASSMAP_BOX_BORDER_WIDTH,\n} from './Box.constants';\nimport type { BoxProps } from './Box.types';\n\nexport const Box = ({\n flexDirection,\n flexWrap,\n gap,\n alignItems,\n justifyContent,\n margin,\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n marginHorizontal,\n marginVertical,\n padding,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n paddingHorizontal,\n paddingVertical,\n borderWidth,\n borderColor,\n backgroundColor,\n twClassName,\n style,\n children,\n ...props\n}: BoxProps) => {\n const tw = useTailwind();\n\n return (\n <View\n {...props}\n style={[\n tw.style(\n 'flex',\n flexDirection,\n flexWrap,\n gap !== undefined && TWCLASSMAP_BOX_GAP[gap],\n alignItems,\n justifyContent,\n margin !== undefined && TWCLASSMAP_BOX_MARGIN[margin],\n marginTop !== undefined && TWCLASSMAP_BOX_MARGIN_TOP[marginTop],\n marginRight !== undefined && TWCLASSMAP_BOX_MARGIN_RIGHT[marginRight],\n marginBottom !== undefined &&\n TWCLASSMAP_BOX_MARGIN_BOTTOM[marginBottom],\n marginLeft !== undefined && TWCLASSMAP_BOX_MARGIN_LEFT[marginLeft],\n marginHorizontal !== undefined &&\n TWCLASSMAP_BOX_MARGIN_HORIZONTAL[marginHorizontal],\n marginVertical !== undefined &&\n TWCLASSMAP_BOX_MARGIN_VERTICAL[marginVertical],\n padding !== undefined && TWCLASSMAP_BOX_PADDING[padding],\n paddingTop !== undefined && TWCLASSMAP_BOX_PADDING_TOP[paddingTop],\n paddingRight !== undefined &&\n TWCLASSMAP_BOX_PADDING_RIGHT[paddingRight],\n paddingBottom !== undefined &&\n TWCLASSMAP_BOX_PADDING_BOTTOM[paddingBottom],\n paddingLeft !== undefined && TWCLASSMAP_BOX_PADDING_LEFT[paddingLeft],\n paddingHorizontal !== undefined &&\n TWCLASSMAP_BOX_PADDING_HORIZONTAL[paddingHorizontal],\n paddingVertical !== undefined &&\n TWCLASSMAP_BOX_PADDING_VERTICAL[paddingVertical],\n borderWidth !== undefined && TWCLASSMAP_BOX_BORDER_WIDTH[borderWidth],\n borderColor,\n backgroundColor,\n twClassName,\n ),\n style,\n ]}\n >\n {children}\n </View>\n );\n};\n"]}
|
|
@@ -34,7 +34,7 @@ const Spinner_1 = require("../temp-components/Spinner/index.cjs");
|
|
|
34
34
|
const TextOrChildren_1 = require("../temp-components/TextOrChildren/TextOrChildren.cjs");
|
|
35
35
|
const Text_1 = require("../Text/index.cjs");
|
|
36
36
|
const ButtonBase_constants_1 = require("./ButtonBase.constants.cjs");
|
|
37
|
-
const ButtonBase = ({ children, textProps, size = types_1.ButtonBaseSize.Lg, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName
|
|
37
|
+
const ButtonBase = ({ children, textProps, size = types_1.ButtonBaseSize.Lg, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName, textClassName, iconClassName, style, accessibilityLabel, accessibilityHint, accessibilityRole = 'button', accessibilityActions, onAccessibilityAction, ...props }) => {
|
|
38
38
|
const tw = (0, design_system_twrnc_preset_1.useTailwind)();
|
|
39
39
|
const finalStartIconName = startIconName ?? startIconProps?.name;
|
|
40
40
|
const finalEndIconName = endIconName ?? endIconProps?.name;
|
|
@@ -75,53 +75,62 @@ const ButtonBase = ({ children, textProps, size = types_1.ButtonBaseSize.Lg, isL
|
|
|
75
75
|
return state;
|
|
76
76
|
}, [isDisabled, isLoading]);
|
|
77
77
|
return (<ButtonAnimated_1.ButtonAnimated disabled={isDisabled || isLoading} accessibilityRole={accessibilityRole} accessibilityLabel={finalAccessibilityLabel} accessibilityHint={finalAccessibilityHint} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} accessibilityState={accessibilityState} accessible style={({ pressed }) => {
|
|
78
|
-
|
|
78
|
+
// Evaluate custom className if it's a function
|
|
79
|
+
const customClassName = typeof twClassName === 'function'
|
|
79
80
|
? twClassName(pressed)
|
|
80
81
|
: twClassName;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
82
|
+
// Build button container styles
|
|
83
|
+
const buttonStyles = tw.style(
|
|
84
|
+
// Base layout - flex container for button content
|
|
85
|
+
'flex-row items-center justify-center gap-x-2',
|
|
86
|
+
// Visual styling
|
|
87
|
+
'rounded-xl bg-muted px-4 min-w-[80px] overflow-hidden',
|
|
88
|
+
// Size
|
|
89
|
+
ButtonBase_constants_1.TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],
|
|
90
|
+
// State-based opacity
|
|
91
|
+
isDisabled ? 'opacity-50' : 'opacity-100',
|
|
92
|
+
// Width - use self-start to prevent stretching when not full width
|
|
93
|
+
isFullWidth ? 'w-full' : 'self-start',
|
|
94
|
+
// Custom classes
|
|
95
|
+
customClassName);
|
|
96
|
+
// Merge with additional styles if provided
|
|
97
|
+
const computedStyle = [buttonStyles];
|
|
98
|
+
const additionalStyle = typeof style === 'function' ? style({ pressed }) : style;
|
|
99
|
+
if (additionalStyle) {
|
|
100
|
+
computedStyle.push(additionalStyle);
|
|
99
101
|
}
|
|
100
102
|
return computedStyle;
|
|
101
103
|
}} {...props}>
|
|
102
104
|
{({ pressed }) => (<>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
105
|
+
{/* Loading spinner overlay */}
|
|
106
|
+
{isLoading && (<react_native_1.View style={tw.style('absolute inset-0 flex items-center justify-center')} testID="spinner-container">
|
|
107
|
+
<Spinner_1.Spinner color={textClassName
|
|
108
|
+
? textClassName(pressed)
|
|
109
|
+
: Icon_1.IconColor.IconDefault} loadingText={loadingText} loadingTextProps={{
|
|
110
|
+
numberOfLines: 1,
|
|
111
|
+
twClassName: textClassName ? textClassName(pressed) : '',
|
|
112
|
+
...spinnerProps?.loadingTextProps,
|
|
113
|
+
}} {...spinnerProps}/>
|
|
114
|
+
</react_native_1.View>)}
|
|
115
|
+
|
|
116
|
+
{/* Button content - opacity controlled individually on each child */}
|
|
117
|
+
{finalStartIconName ? (<Icon_1.Icon name={finalStartIconName} size={Icon_1.IconSize.Sm} twClassName={`shrink-0 ${isLoading ? 'opacity-0' : ''} ${iconClassName ? iconClassName(pressed) : ''}`} {...startIconProps}/>) : (startAccessory && (<react_native_1.View style={tw.style(isLoading && 'opacity-0')}>
|
|
118
|
+
{startAccessory}
|
|
119
|
+
</react_native_1.View>))}
|
|
120
|
+
|
|
121
|
+
{typeof children === 'string' ? (<TextOrChildren_1.TextOrChildren textProps={{
|
|
122
|
+
variant: Text_1.TextVariant.BodyMd,
|
|
123
|
+
fontWeight: Text_1.FontWeight.Medium,
|
|
124
|
+
color: Text_1.TextColor.TextDefault,
|
|
125
|
+
twClassName: `shrink grow-0 flex-wrap text-center ${isLoading ? 'opacity-0' : ''} ${textClassName ? textClassName(pressed) : ''}`,
|
|
126
|
+
...textProps,
|
|
127
|
+
}}>
|
|
121
128
|
{children}
|
|
122
|
-
</TextOrChildren_1.TextOrChildren>
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
</TextOrChildren_1.TextOrChildren>) : (<react_native_1.View style={tw.style(isLoading && 'opacity-0')}>{children}</react_native_1.View>)}
|
|
130
|
+
|
|
131
|
+
{finalEndIconName ? (<Icon_1.Icon name={finalEndIconName} size={Icon_1.IconSize.Sm} twClassName={`shrink-0 ${isLoading ? 'opacity-0' : ''} ${iconClassName ? iconClassName(pressed) : ''}`} {...endIconProps}/>) : (endAccessory && (<react_native_1.View style={tw.style(isLoading && 'opacity-0')}>
|
|
132
|
+
{endAccessory}
|
|
133
|
+
</react_native_1.View>))}
|
|
125
134
|
</>)}
|
|
126
135
|
</ButtonAnimated_1.ButtonAnimated>);
|
|
127
136
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAA4E;AAC5E,+CAAuC;AACvC,wDAAoC;AAGpC,iDAA6C;AAC7C,4CAAoD;AACpD,gFAAmE;AACnE,kEAAqD;AACrD,yFAAkF;AAClF,4CAA6D;AAE7D,qEAA8E;AAGvE,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,sBAAc,CAAC,EAAE,EACxB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,GAAG,EAAE,EAChB,aAAa,EACb,aAAa,EACb,KAAK,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAAG,QAAQ,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,GAAG,KAAK,EACQ,EAAE,EAAE;IACpB,MAAM,EAAE,GAAG,IAAA,wCAAW,GAAE,CAAC;IAEzB,MAAM,kBAAkB,GAAG,aAAa,IAAI,cAAc,EAAE,IAAI,CAAC;IACjE,MAAM,gBAAgB,GAAG,WAAW,IAAI,YAAY,EAAE,IAAI,CAAC;IAE3D,+CAA+C;IAC/C,MAAM,uBAAuB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC3C,IAAI,kBAAkB,EAAE;YACtB,OAAO,kBAAkB,CAAC;SAC3B;QAED,6DAA6D;QAC7D,IAAI,SAAS,IAAI,WAAW,EA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,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACvE,IAAI,YAAY,CAAC,EACjB,CACH,CAAC,CAAC,CAAC,CACF,YAAY,CACb,CACH;UAAA,EAAE,mBAAI,CACR;QAAA,GAAG,CACJ,CACH;IAAA,EAAE,+BAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC;AAvLW,QAAA,UAAU,cAuLrB","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useMemo } from 'react';\nimport { View } from 'react-native';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { ButtonBaseSize } from '../../types';\nimport { Icon, IconColor, IconSize } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\nimport { TextOrChildren } from '../temp-components/TextOrChildren/TextOrChildren';\nimport { TextVariant, FontWeight, TextColor } from '../Text';\n\nimport { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from './ButtonBase.constants';\nimport type { ButtonBaseProps } from './ButtonBase.types';\n\nexport const ButtonBase = ({\n children,\n textProps,\n size = ButtonBaseSize.Lg,\n isLoading,\n loadingText,\n spinnerProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n isDisabled,\n isFullWidth,\n twClassName = '',\n textClassName,\n iconClassName,\n style,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n accessibilityActions,\n onAccessibilityAction,\n ...props\n}: ButtonBaseProps) => {\n const tw = useTailwind();\n\n const finalStartIconName = startIconName ?? startIconProps?.name;\n const finalEndIconName = endIconName ?? endIconProps?.name;\n\n // Generate accessibility label if not provided\n const finalAccessibilityLabel = useMemo(() => {\n if (accessibilityLabel) {\n return accessibilityLabel;\n }\n\n // For loading state with loadingText, prioritize loadingText\n if (isLoading && loadingText) {\n return loadingText;\n }\n\n // If children is a string, use it as the label\n if (typeof children === 'string') {\n return children;\n }\n\n return undefined;\n }, [accessibilityLabel, children, isLoading, loadingText]);\n\n // Generate accessibility hint for loading state if not provided\n const finalAccessibilityHint = useMemo(() => {\n if (accessibilityHint) {\n return accessibilityHint;\n }\n\n if (isLoading) {\n return 'Button is currently loading, please wait';\n }\n\n return undefined;\n }, [accessibilityHint, isLoading]);\n\n // Create accessibilityState object with only truthy values\n const accessibilityState = useMemo(() => {\n const state: { disabled?: boolean; busy?: boolean } = {};\n\n if (isDisabled || isLoading) {\n state.disabled = true;\n }\n\n if (isLoading) {\n state.busy = true;\n }\n\n return state;\n }, [isDisabled, isLoading]);\n\n return (\n <ButtonAnimated\n disabled={isDisabled || isLoading}\n accessibilityRole={accessibilityRole}\n accessibilityLabel={finalAccessibilityLabel}\n accessibilityHint={finalAccessibilityHint}\n accessibilityActions={accessibilityActions}\n onAccessibilityAction={onAccessibilityAction}\n accessibilityState={accessibilityState}\n accessible\n style={({ pressed }) => {\n const containerClassName =\n typeof twClassName === 'function'\n ? twClassName(pressed)\n : twClassName;\n\n const baseContainerClassNames = `\n flex-row items-center justify-center rounded-xl bg-muted px-4 min-w-[80px] overflow-hidden\n ${TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size]}\n ${isDisabled ? 'opacity-50' : 'opacity-100'}\n ${isFullWidth ? 'w-full' : 'w-auto'}\n ${containerClassName}\n `;\n\n const computedStyle: StyleProp<ViewStyle>[] = [\n tw`${baseContainerClassNames}`,\n ];\n if (typeof style === 'function') {\n const additionalStyle = style({ pressed });\n if (additionalStyle) {\n computedStyle.push(additionalStyle);\n }\n } else if (style) {\n computedStyle.push(style);\n }\n\n return computedStyle;\n }}\n {...props}\n >\n {({ pressed }) => (\n <>\n <View\n style={tw`absolute inset-0 flex items-center justify-center ${\n isLoading ? 'opacity-100' : 'opacity-0'\n }`}\n testID=\"spinner-container\"\n >\n <Spinner\n color={\n textClassName\n ? (textClassName(pressed) as IconColor)\n : IconColor.IconDefault\n }\n loadingText={loadingText}\n loadingTextProps={{\n numberOfLines: 1,\n twClassName: textClassName ? textClassName(pressed) : '',\n ...spinnerProps?.loadingTextProps,\n }}\n {...spinnerProps}\n />\n </View>\n <View\n style={tw`flex-row items-center justify-center gap-x-2 ${\n isLoading ? 'opacity-0' : 'opacity-100'\n }`}\n testID=\"content-container\"\n >\n {finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`}\n {...startIconProps}\n />\n ) : (\n startAccessory\n )}\n <TextOrChildren\n textProps={{\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n twClassName: `shrink grow-0 flex-wrap text-center ${textClassName ? textClassName(pressed) : ''}`,\n ...textProps,\n }}\n >\n {children}\n </TextOrChildren>\n {finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`}\n {...endIconProps}\n />\n ) : (\n endAccessory\n )}\n </View>\n </>\n )}\n </ButtonAnimated>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ButtonBase.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAA4E;AAC5E,+CAAuC;AACvC,wDAAoC;AAGpC,iDAA6C;AAC7C,4CAAoD;AACpD,gFAAmE;AACnE,kEAAqD;AACrD,yFAAkF;AAClF,4CAA6D;AAE7D,qEAA8E;AAGvE,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,sBAAc,CAAC,EAAE,EACxB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,KAAK,EACL,kBAAkB,EAClB,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CAAC,CAC9C;gBAAA,CAAC,YAAY,CACf;cAAA,EAAE,mBAAI,CAAC,CACR,CACF,CACH;QAAA,GAAG,CACJ,CACH;IAAA,EAAE,+BAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC;AA1MW,QAAA,UAAU,cA0MrB","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useMemo } from 'react';\nimport { View } from 'react-native';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { ButtonBaseSize } from '../../types';\nimport { Icon, IconColor, IconSize } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\nimport { TextOrChildren } from '../temp-components/TextOrChildren/TextOrChildren';\nimport { TextVariant, FontWeight, TextColor } from '../Text';\n\nimport { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from './ButtonBase.constants';\nimport type { ButtonBaseProps } from './ButtonBase.types';\n\nexport const ButtonBase = ({\n children,\n textProps,\n size = ButtonBaseSize.Lg,\n isLoading,\n loadingText,\n spinnerProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n isDisabled,\n isFullWidth,\n twClassName,\n textClassName,\n iconClassName,\n style,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n accessibilityActions,\n onAccessibilityAction,\n ...props\n}: ButtonBaseProps) => {\n const tw = useTailwind();\n\n const finalStartIconName = startIconName ?? startIconProps?.name;\n const finalEndIconName = endIconName ?? endIconProps?.name;\n\n // Generate accessibility label if not provided\n const finalAccessibilityLabel = useMemo(() => {\n if (accessibilityLabel) {\n return accessibilityLabel;\n }\n\n // For loading state with loadingText, prioritize loadingText\n if (isLoading && loadingText) {\n return loadingText;\n }\n\n // If children is a string, use it as the label\n if (typeof children === 'string') {\n return children;\n }\n\n return undefined;\n }, [accessibilityLabel, children, isLoading, loadingText]);\n\n // Generate accessibility hint for loading state if not provided\n const finalAccessibilityHint = useMemo(() => {\n if (accessibilityHint) {\n return accessibilityHint;\n }\n\n if (isLoading) {\n return 'Button is currently loading, please wait';\n }\n\n return undefined;\n }, [accessibilityHint, isLoading]);\n\n // Create accessibilityState object with only truthy values\n const accessibilityState = useMemo(() => {\n const state: { disabled?: boolean; busy?: boolean } = {};\n\n if (isDisabled || isLoading) {\n state.disabled = true;\n }\n\n if (isLoading) {\n state.busy = true;\n }\n\n return state;\n }, [isDisabled, isLoading]);\n\n return (\n <ButtonAnimated\n disabled={isDisabled || isLoading}\n accessibilityRole={accessibilityRole}\n accessibilityLabel={finalAccessibilityLabel}\n accessibilityHint={finalAccessibilityHint}\n accessibilityActions={accessibilityActions}\n onAccessibilityAction={onAccessibilityAction}\n accessibilityState={accessibilityState}\n accessible\n style={({ pressed }) => {\n // Evaluate custom className if it's a function\n const customClassName =\n typeof twClassName === 'function'\n ? twClassName(pressed)\n : twClassName;\n\n // Build button container styles\n const buttonStyles = tw.style(\n // Base layout - flex container for button content\n 'flex-row items-center justify-center gap-x-2',\n // Visual styling\n 'rounded-xl bg-muted px-4 min-w-[80px] overflow-hidden',\n // Size\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],\n // State-based opacity\n isDisabled ? 'opacity-50' : 'opacity-100',\n // Width - use self-start to prevent stretching when not full width\n isFullWidth ? 'w-full' : 'self-start',\n // Custom classes\n customClassName,\n );\n\n // Merge with additional styles if provided\n const computedStyle: StyleProp<ViewStyle>[] = [buttonStyles];\n\n const additionalStyle =\n typeof style === 'function' ? style({ pressed }) : style;\n\n if (additionalStyle) {\n computedStyle.push(additionalStyle);\n }\n\n return computedStyle;\n }}\n {...props}\n >\n {({ pressed }) => (\n <>\n {/* Loading spinner overlay */}\n {isLoading && (\n <View\n style={tw.style(\n 'absolute inset-0 flex items-center justify-center',\n )}\n testID=\"spinner-container\"\n >\n <Spinner\n color={\n textClassName\n ? (textClassName(pressed) as IconColor)\n : IconColor.IconDefault\n }\n loadingText={loadingText}\n loadingTextProps={{\n numberOfLines: 1,\n twClassName: textClassName ? textClassName(pressed) : '',\n ...spinnerProps?.loadingTextProps,\n }}\n {...spinnerProps}\n />\n </View>\n )}\n\n {/* Button content - opacity controlled individually on each child */}\n {finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${isLoading ? 'opacity-0' : ''} ${iconClassName ? iconClassName(pressed) : ''}`}\n {...startIconProps}\n />\n ) : (\n startAccessory && (\n <View style={tw.style(isLoading && 'opacity-0')}>\n {startAccessory}\n </View>\n )\n )}\n\n {typeof children === 'string' ? (\n <TextOrChildren\n textProps={{\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n twClassName: `shrink grow-0 flex-wrap text-center ${isLoading ? 'opacity-0' : ''} ${textClassName ? textClassName(pressed) : ''}`,\n ...textProps,\n }}\n >\n {children}\n </TextOrChildren>\n ) : (\n <View style={tw.style(isLoading && 'opacity-0')}>{children}</View>\n )}\n\n {finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${isLoading ? 'opacity-0' : ''} ${iconClassName ? iconClassName(pressed) : ''}`}\n {...endIconProps}\n />\n ) : (\n endAccessory && (\n <View style={tw.style(isLoading && 'opacity-0')}>\n {endAccessory}\n </View>\n )\n )}\n </>\n )}\n </ButtonAnimated>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,cAAc;AAYvC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,4VAyBpB,eAAe,
|
|
1
|
+
{"version":3,"file":"ButtonBase.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,cAAc;AAYvC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,4VAyBpB,eAAe,sBAiLjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,cAAc;AAYvC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,4VAyBpB,eAAe,
|
|
1
|
+
{"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,cAAc;AAYvC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,4VAyBpB,eAAe,sBAiLjB,CAAC"}
|
|
@@ -15,7 +15,7 @@ import { Spinner } from "../temp-components/Spinner/index.mjs";
|
|
|
15
15
|
import { TextOrChildren } from "../temp-components/TextOrChildren/TextOrChildren.mjs";
|
|
16
16
|
import { TextVariant, FontWeight, TextColor } from "../Text/index.mjs";
|
|
17
17
|
import { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from "./ButtonBase.constants.mjs";
|
|
18
|
-
export const ButtonBase = ({ children, textProps, size = ButtonBaseSize.Lg, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName
|
|
18
|
+
export const ButtonBase = ({ children, textProps, size = ButtonBaseSize.Lg, isLoading, loadingText, spinnerProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, isDisabled, isFullWidth, twClassName, textClassName, iconClassName, style, accessibilityLabel, accessibilityHint, accessibilityRole = 'button', accessibilityActions, onAccessibilityAction, ...props }) => {
|
|
19
19
|
const tw = useTailwind();
|
|
20
20
|
const finalStartIconName = startIconName ?? startIconProps?.name;
|
|
21
21
|
const finalEndIconName = endIconName ?? endIconProps?.name;
|
|
@@ -56,53 +56,62 @@ export const ButtonBase = ({ children, textProps, size = ButtonBaseSize.Lg, isLo
|
|
|
56
56
|
return state;
|
|
57
57
|
}, [isDisabled, isLoading]);
|
|
58
58
|
return (<ButtonAnimated disabled={isDisabled || isLoading} accessibilityRole={accessibilityRole} accessibilityLabel={finalAccessibilityLabel} accessibilityHint={finalAccessibilityHint} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} accessibilityState={accessibilityState} accessible style={({ pressed }) => {
|
|
59
|
-
|
|
59
|
+
// Evaluate custom className if it's a function
|
|
60
|
+
const customClassName = typeof twClassName === 'function'
|
|
60
61
|
? twClassName(pressed)
|
|
61
62
|
: twClassName;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
63
|
+
// Build button container styles
|
|
64
|
+
const buttonStyles = tw.style(
|
|
65
|
+
// Base layout - flex container for button content
|
|
66
|
+
'flex-row items-center justify-center gap-x-2',
|
|
67
|
+
// Visual styling
|
|
68
|
+
'rounded-xl bg-muted px-4 min-w-[80px] overflow-hidden',
|
|
69
|
+
// Size
|
|
70
|
+
TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],
|
|
71
|
+
// State-based opacity
|
|
72
|
+
isDisabled ? 'opacity-50' : 'opacity-100',
|
|
73
|
+
// Width - use self-start to prevent stretching when not full width
|
|
74
|
+
isFullWidth ? 'w-full' : 'self-start',
|
|
75
|
+
// Custom classes
|
|
76
|
+
customClassName);
|
|
77
|
+
// Merge with additional styles if provided
|
|
78
|
+
const computedStyle = [buttonStyles];
|
|
79
|
+
const additionalStyle = typeof style === 'function' ? style({ pressed }) : style;
|
|
80
|
+
if (additionalStyle) {
|
|
81
|
+
computedStyle.push(additionalStyle);
|
|
80
82
|
}
|
|
81
83
|
return computedStyle;
|
|
82
84
|
}} {...props}>
|
|
83
85
|
{({ pressed }) => (<>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
{/* Loading spinner overlay */}
|
|
87
|
+
{isLoading && (<View style={tw.style('absolute inset-0 flex items-center justify-center')} testID="spinner-container">
|
|
88
|
+
<Spinner color={textClassName
|
|
89
|
+
? textClassName(pressed)
|
|
90
|
+
: IconColor.IconDefault} loadingText={loadingText} loadingTextProps={{
|
|
91
|
+
numberOfLines: 1,
|
|
92
|
+
twClassName: textClassName ? textClassName(pressed) : '',
|
|
93
|
+
...spinnerProps?.loadingTextProps,
|
|
94
|
+
}} {...spinnerProps}/>
|
|
95
|
+
</View>)}
|
|
96
|
+
|
|
97
|
+
{/* Button content - opacity controlled individually on each child */}
|
|
98
|
+
{finalStartIconName ? (<Icon name={finalStartIconName} size={IconSize.Sm} twClassName={`shrink-0 ${isLoading ? 'opacity-0' : ''} ${iconClassName ? iconClassName(pressed) : ''}`} {...startIconProps}/>) : (startAccessory && (<View style={tw.style(isLoading && 'opacity-0')}>
|
|
99
|
+
{startAccessory}
|
|
100
|
+
</View>))}
|
|
101
|
+
|
|
102
|
+
{typeof children === 'string' ? (<TextOrChildren textProps={{
|
|
103
|
+
variant: TextVariant.BodyMd,
|
|
104
|
+
fontWeight: FontWeight.Medium,
|
|
105
|
+
color: TextColor.TextDefault,
|
|
106
|
+
twClassName: `shrink grow-0 flex-wrap text-center ${isLoading ? 'opacity-0' : ''} ${textClassName ? textClassName(pressed) : ''}`,
|
|
107
|
+
...textProps,
|
|
108
|
+
}}>
|
|
102
109
|
{children}
|
|
103
|
-
</TextOrChildren>
|
|
104
|
-
|
|
105
|
-
|
|
110
|
+
</TextOrChildren>) : (<View style={tw.style(isLoading && 'opacity-0')}>{children}</View>)}
|
|
111
|
+
|
|
112
|
+
{finalEndIconName ? (<Icon name={finalEndIconName} size={IconSize.Sm} twClassName={`shrink-0 ${isLoading ? 'opacity-0' : ''} ${iconClassName ? iconClassName(pressed) : ''}`} {...endIconProps}/>) : (endAccessory && (<View style={tw.style(isLoading && 'opacity-0')}>
|
|
113
|
+
{endAccessory}
|
|
114
|
+
</View>))}
|
|
106
115
|
</>)}
|
|
107
116
|
</ButtonAnimated>);
|
|
108
117
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,QAAO,EAAE,OAAO,EAAE,cAAc;;AACvC,OAAO,EAAE,IAAI,EAAE,8BAAqB;AAGpC,OAAO,EAAE,cAAc,EAAE,8BAAoB;AAC7C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,0BAAgB;AACpD,OAAO,EAAE,cAAc,EAAE,oDAA0C;AACnE,OAAO,EAAE,OAAO,EAAE,6CAAmC;AACrD,OAAO,EAAE,cAAc,EAAE,6DAAyD;AAClF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,0BAAgB;AAE7D,OAAO,EAAE,oCAAoC,EAAE,mCAA+B;AAG9E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,cAAc,CAAC,EAAE,EACxB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,WAAW,EACX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BACT,OAAO,EAAE,WAAW,CAAC,MAAM;gBAC3B,UAAU,EAAE,UAAU,CAAC,MAAM;gBAC7B,KAAK,EAAE,SAAS,CAAC,WAAW;gBAC5B,WAAW,EAAE,uCAAuC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;gBACjG,GAAG,SAAS;aACb,CAAC,CAEF;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,cAAc,CAChB;YAAA,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAClB,CAAC,IAAI,CACH,IAAI,CAAC,CAAC,gBAAgB,CAAC,CACvB,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAClB,WAAW,CAAC,CAAC,YAAY,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACvE,IAAI,YAAY,CAAC,EACjB,CACH,CAAC,CAAC,CAAC,CACF,YAAY,CACb,CACH;UAAA,EAAE,IAAI,CACR;QAAA,GAAG,CACJ,CACH;IAAA,EAAE,cAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useMemo } from 'react';\nimport { View } from 'react-native';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { ButtonBaseSize } from '../../types';\nimport { Icon, IconColor, IconSize } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\nimport { TextOrChildren } from '../temp-components/TextOrChildren/TextOrChildren';\nimport { TextVariant, FontWeight, TextColor } from '../Text';\n\nimport { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from './ButtonBase.constants';\nimport type { ButtonBaseProps } from './ButtonBase.types';\n\nexport const ButtonBase = ({\n children,\n textProps,\n size = ButtonBaseSize.Lg,\n isLoading,\n loadingText,\n spinnerProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n isDisabled,\n isFullWidth,\n twClassName = '',\n textClassName,\n iconClassName,\n style,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n accessibilityActions,\n onAccessibilityAction,\n ...props\n}: ButtonBaseProps) => {\n const tw = useTailwind();\n\n const finalStartIconName = startIconName ?? startIconProps?.name;\n const finalEndIconName = endIconName ?? endIconProps?.name;\n\n // Generate accessibility label if not provided\n const finalAccessibilityLabel = useMemo(() => {\n if (accessibilityLabel) {\n return accessibilityLabel;\n }\n\n // For loading state with loadingText, prioritize loadingText\n if (isLoading && loadingText) {\n return loadingText;\n }\n\n // If children is a string, use it as the label\n if (typeof children === 'string') {\n return children;\n }\n\n return undefined;\n }, [accessibilityLabel, children, isLoading, loadingText]);\n\n // Generate accessibility hint for loading state if not provided\n const finalAccessibilityHint = useMemo(() => {\n if (accessibilityHint) {\n return accessibilityHint;\n }\n\n if (isLoading) {\n return 'Button is currently loading, please wait';\n }\n\n return undefined;\n }, [accessibilityHint, isLoading]);\n\n // Create accessibilityState object with only truthy values\n const accessibilityState = useMemo(() => {\n const state: { disabled?: boolean; busy?: boolean } = {};\n\n if (isDisabled || isLoading) {\n state.disabled = true;\n }\n\n if (isLoading) {\n state.busy = true;\n }\n\n return state;\n }, [isDisabled, isLoading]);\n\n return (\n <ButtonAnimated\n disabled={isDisabled || isLoading}\n accessibilityRole={accessibilityRole}\n accessibilityLabel={finalAccessibilityLabel}\n accessibilityHint={finalAccessibilityHint}\n accessibilityActions={accessibilityActions}\n onAccessibilityAction={onAccessibilityAction}\n accessibilityState={accessibilityState}\n accessible\n style={({ pressed }) => {\n const containerClassName =\n typeof twClassName === 'function'\n ? twClassName(pressed)\n : twClassName;\n\n const baseContainerClassNames = `\n flex-row items-center justify-center rounded-xl bg-muted px-4 min-w-[80px] overflow-hidden\n ${TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size]}\n ${isDisabled ? 'opacity-50' : 'opacity-100'}\n ${isFullWidth ? 'w-full' : 'w-auto'}\n ${containerClassName}\n `;\n\n const computedStyle: StyleProp<ViewStyle>[] = [\n tw`${baseContainerClassNames}`,\n ];\n if (typeof style === 'function') {\n const additionalStyle = style({ pressed });\n if (additionalStyle) {\n computedStyle.push(additionalStyle);\n }\n } else if (style) {\n computedStyle.push(style);\n }\n\n return computedStyle;\n }}\n {...props}\n >\n {({ pressed }) => (\n <>\n <View\n style={tw`absolute inset-0 flex items-center justify-center ${\n isLoading ? 'opacity-100' : 'opacity-0'\n }`}\n testID=\"spinner-container\"\n >\n <Spinner\n color={\n textClassName\n ? (textClassName(pressed) as IconColor)\n : IconColor.IconDefault\n }\n loadingText={loadingText}\n loadingTextProps={{\n numberOfLines: 1,\n twClassName: textClassName ? textClassName(pressed) : '',\n ...spinnerProps?.loadingTextProps,\n }}\n {...spinnerProps}\n />\n </View>\n <View\n style={tw`flex-row items-center justify-center gap-x-2 ${\n isLoading ? 'opacity-0' : 'opacity-100'\n }`}\n testID=\"content-container\"\n >\n {finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`}\n {...startIconProps}\n />\n ) : (\n startAccessory\n )}\n <TextOrChildren\n textProps={{\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n twClassName: `shrink grow-0 flex-wrap text-center ${textClassName ? textClassName(pressed) : ''}`,\n ...textProps,\n }}\n >\n {children}\n </TextOrChildren>\n {finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${iconClassName ? iconClassName(pressed) : ''}`}\n {...endIconProps}\n />\n ) : (\n endAccessory\n )}\n </View>\n </>\n )}\n </ButtonAnimated>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ButtonBase.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"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AEF;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,cAAc,CAAC,CAClB,CAAC,CAAC,CAAC,CACF,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CACnE,CAED;;UAAA,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAClB,CAAC,IAAI,CACH,IAAI,CAAC,CAAC,gBAAgB,CAAC,CACvB,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAClB,WAAW,CAAC,CAAC,YAAY,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACvG,IAAI,YAAY,CAAC,EACjB,CACH,CAAC,CAAC,CAAC,CACF,YAAY,IAAI,CACd,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,IAAI,WAAW,CAAC,CAAC,CAC9C;gBAAA,CAAC,YAAY,CACf;cAAA,EAAE,IAAI,CAAC,CACR,CACF,CACH;QAAA,GAAG,CACJ,CACH;IAAA,EAAE,cAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useMemo } from 'react';\nimport { View } from 'react-native';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { ButtonBaseSize } from '../../types';\nimport { Icon, IconColor, IconSize } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\nimport { TextOrChildren } from '../temp-components/TextOrChildren/TextOrChildren';\nimport { TextVariant, FontWeight, TextColor } from '../Text';\n\nimport { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from './ButtonBase.constants';\nimport type { ButtonBaseProps } from './ButtonBase.types';\n\nexport const ButtonBase = ({\n children,\n textProps,\n size = ButtonBaseSize.Lg,\n isLoading,\n loadingText,\n spinnerProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n isDisabled,\n isFullWidth,\n twClassName,\n textClassName,\n iconClassName,\n style,\n accessibilityLabel,\n accessibilityHint,\n accessibilityRole = 'button',\n accessibilityActions,\n onAccessibilityAction,\n ...props\n}: ButtonBaseProps) => {\n const tw = useTailwind();\n\n const finalStartIconName = startIconName ?? startIconProps?.name;\n const finalEndIconName = endIconName ?? endIconProps?.name;\n\n // Generate accessibility label if not provided\n const finalAccessibilityLabel = useMemo(() => {\n if (accessibilityLabel) {\n return accessibilityLabel;\n }\n\n // For loading state with loadingText, prioritize loadingText\n if (isLoading && loadingText) {\n return loadingText;\n }\n\n // If children is a string, use it as the label\n if (typeof children === 'string') {\n return children;\n }\n\n return undefined;\n }, [accessibilityLabel, children, isLoading, loadingText]);\n\n // Generate accessibility hint for loading state if not provided\n const finalAccessibilityHint = useMemo(() => {\n if (accessibilityHint) {\n return accessibilityHint;\n }\n\n if (isLoading) {\n return 'Button is currently loading, please wait';\n }\n\n return undefined;\n }, [accessibilityHint, isLoading]);\n\n // Create accessibilityState object with only truthy values\n const accessibilityState = useMemo(() => {\n const state: { disabled?: boolean; busy?: boolean } = {};\n\n if (isDisabled || isLoading) {\n state.disabled = true;\n }\n\n if (isLoading) {\n state.busy = true;\n }\n\n return state;\n }, [isDisabled, isLoading]);\n\n return (\n <ButtonAnimated\n disabled={isDisabled || isLoading}\n accessibilityRole={accessibilityRole}\n accessibilityLabel={finalAccessibilityLabel}\n accessibilityHint={finalAccessibilityHint}\n accessibilityActions={accessibilityActions}\n onAccessibilityAction={onAccessibilityAction}\n accessibilityState={accessibilityState}\n accessible\n style={({ pressed }) => {\n // Evaluate custom className if it's a function\n const customClassName =\n typeof twClassName === 'function'\n ? twClassName(pressed)\n : twClassName;\n\n // Build button container styles\n const buttonStyles = tw.style(\n // Base layout - flex container for button content\n 'flex-row items-center justify-center gap-x-2',\n // Visual styling\n 'rounded-xl bg-muted px-4 min-w-[80px] overflow-hidden',\n // Size\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],\n // State-based opacity\n isDisabled ? 'opacity-50' : 'opacity-100',\n // Width - use self-start to prevent stretching when not full width\n isFullWidth ? 'w-full' : 'self-start',\n // Custom classes\n customClassName,\n );\n\n // Merge with additional styles if provided\n const computedStyle: StyleProp<ViewStyle>[] = [buttonStyles];\n\n const additionalStyle =\n typeof style === 'function' ? style({ pressed }) : style;\n\n if (additionalStyle) {\n computedStyle.push(additionalStyle);\n }\n\n return computedStyle;\n }}\n {...props}\n >\n {({ pressed }) => (\n <>\n {/* Loading spinner overlay */}\n {isLoading && (\n <View\n style={tw.style(\n 'absolute inset-0 flex items-center justify-center',\n )}\n testID=\"spinner-container\"\n >\n <Spinner\n color={\n textClassName\n ? (textClassName(pressed) as IconColor)\n : IconColor.IconDefault\n }\n loadingText={loadingText}\n loadingTextProps={{\n numberOfLines: 1,\n twClassName: textClassName ? textClassName(pressed) : '',\n ...spinnerProps?.loadingTextProps,\n }}\n {...spinnerProps}\n />\n </View>\n )}\n\n {/* Button content - opacity controlled individually on each child */}\n {finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${isLoading ? 'opacity-0' : ''} ${iconClassName ? iconClassName(pressed) : ''}`}\n {...startIconProps}\n />\n ) : (\n startAccessory && (\n <View style={tw.style(isLoading && 'opacity-0')}>\n {startAccessory}\n </View>\n )\n )}\n\n {typeof children === 'string' ? (\n <TextOrChildren\n textProps={{\n variant: TextVariant.BodyMd,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n twClassName: `shrink grow-0 flex-wrap text-center ${isLoading ? 'opacity-0' : ''} ${textClassName ? textClassName(pressed) : ''}`,\n ...textProps,\n }}\n >\n {children}\n </TextOrChildren>\n ) : (\n <View style={tw.style(isLoading && 'opacity-0')}>{children}</View>\n )}\n\n {finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={IconSize.Sm}\n twClassName={`shrink-0 ${isLoading ? 'opacity-0' : ''} ${iconClassName ? iconClassName(pressed) : ''}`}\n {...endIconProps}\n />\n ) : (\n endAccessory && (\n <View style={tw.style(isLoading && 'opacity-0')}>\n {endAccessory}\n </View>\n )\n )}\n </>\n )}\n </ButtonAnimated>\n );\n};\n"]}
|
|
@@ -30,10 +30,9 @@ const types_1 = require("../../types/index.cjs");
|
|
|
30
30
|
const Icon_1 = require("../Icon/index.cjs");
|
|
31
31
|
const ButtonAnimated_1 = require("../temp-components/ButtonAnimated/index.cjs");
|
|
32
32
|
const ButtonIcon_constants_1 = require("./ButtonIcon.constants.cjs");
|
|
33
|
-
const ButtonIcon = ({ size = types_1.ButtonIconSize.Md, iconName, iconProps, isDisabled = false, isInverse = false, isFloating = false, onPressIn, onPressOut, twClassName
|
|
33
|
+
const ButtonIcon = ({ size = types_1.ButtonIconSize.Md, iconName, iconProps, isDisabled = false, isInverse = false, isFloating = false, onPressIn, onPressOut, twClassName, style, ...props }) => {
|
|
34
34
|
const [isPressed, setIsPressed] = (0, react_1.useState)(false);
|
|
35
35
|
const tw = (0, design_system_twrnc_preset_1.useTailwind)();
|
|
36
|
-
// Determine background color based on state
|
|
37
36
|
let backgroundColor = 'bg-transparent';
|
|
38
37
|
if (isFloating) {
|
|
39
38
|
backgroundColor = 'bg-icon-default';
|
|
@@ -41,13 +40,6 @@ const ButtonIcon = ({ size = types_1.ButtonIconSize.Md, iconName, iconProps, isD
|
|
|
41
40
|
else if (isPressed) {
|
|
42
41
|
backgroundColor = 'bg-pressed';
|
|
43
42
|
}
|
|
44
|
-
const twContainerClassNames = `
|
|
45
|
-
items-center justify-center
|
|
46
|
-
${ButtonIcon_constants_1.TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size]}
|
|
47
|
-
${isFloating ? 'rounded-full' : 'rounded-lg'}
|
|
48
|
-
${backgroundColor}
|
|
49
|
-
${isDisabled ? 'opacity-50' : 'opacity-100'}
|
|
50
|
-
${twClassName}`;
|
|
51
43
|
const twIconColorClassNames = isInverse || isFloating ? 'text-primary-inverse' : 'text-icon-default';
|
|
52
44
|
const onPressInHandler = (event) => {
|
|
53
45
|
setIsPressed(true);
|
|
@@ -57,7 +49,10 @@ const ButtonIcon = ({ size = types_1.ButtonIconSize.Md, iconName, iconProps, isD
|
|
|
57
49
|
setIsPressed(false);
|
|
58
50
|
onPressOut?.(event);
|
|
59
51
|
};
|
|
60
|
-
return (<ButtonAnimated_1.ButtonAnimated disabled={isDisabled} onPressIn={onPressInHandler} onPressOut={onPressOutHandler} accessible
|
|
52
|
+
return (<ButtonAnimated_1.ButtonAnimated disabled={isDisabled} onPressIn={onPressInHandler} onPressOut={onPressOutHandler} accessible testID="button-icon" {...props} style={[
|
|
53
|
+
tw.style('items-center justify-center', ButtonIcon_constants_1.TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size], isFloating ? 'rounded-full' : 'rounded-lg', backgroundColor, isDisabled ? 'opacity-50' : 'opacity-100', twClassName),
|
|
54
|
+
style,
|
|
55
|
+
]}>
|
|
61
56
|
<Icon_1.Icon name={iconName} color={twIconColorClassNames} size={ButtonIcon_constants_1.MAP_BUTTONICON_SIZE_ICONSIZE[size]} {...iconProps}/>
|
|
62
57
|
</ButtonAnimated_1.ButtonAnimated>);
|
|
63
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.cjs","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAA4E;AAC5E,+CAAwC;AAGxC,iDAA6C;AAE7C,4CAA+B;AAC/B,gFAAmE;AAEnE,qEAGgC;AAGzB,MAAM,UAAU,GAAG,CAAC,EACzB,IAAI,GAAG,sBAAc,CAAC,EAAE,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;QACpB,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,+BAAc,CACb,QAAQ,CAAC,CAAC,UAAU,CAAC,CACrB,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAC5B,UAAU,CAAC,CAAC,iBAAiB,CAAC,CAC9B,UAAU,CACV,MAAM,CAAC,aAAa,CACpB,IAAI,KAAK,CAAC,CACV,KAAK,CAAC,CAAC;YACL,EAAE,CAAC,KAAK,CACN,6BAA6B,EAC7B,2DAAoC,CAAC,IAAI,CAAC,EAC1C,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,YAAY,EAC1C,eAAe,EACf,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,EACzC,WAAW,CACZ;YACD,KAAK;SACN,CAAC,CAEF;MAAA,CAAC,WAAI,CACH,IAAI,CAAC,CAAC,QAAQ,CAAC,CACf,KAAK,CAAC,CAAC,qBAAkC,CAAC,CAC1C,IAAI,CAAC,CAAC,mDAA4B,CAAC,IAAI,CAAC,CAAC,CACzC,IAAI,SAAS,CAAC,EAElB;IAAA,EAAE,+BAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC;AAhEW,QAAA,UAAU,cAgErB","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useState } from 'react';\nimport type { GestureResponderEvent } from 'react-native';\n\nimport { ButtonIconSize } from '../../types';\nimport type { IconColor } from '../Icon';\nimport { Icon } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\n\nimport {\n MAP_BUTTONICON_SIZE_ICONSIZE,\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION,\n} from './ButtonIcon.constants';\nimport type { ButtonIconProps } from './ButtonIcon.types';\n\nexport const ButtonIcon = ({\n size = ButtonIconSize.Md,\n iconName,\n iconProps,\n isDisabled = false,\n isInverse = false,\n isFloating = false,\n onPressIn,\n onPressOut,\n twClassName,\n style,\n ...props\n}: ButtonIconProps) => {\n const [isPressed, setIsPressed] = useState(false);\n const tw = useTailwind();\n\n let backgroundColor = 'bg-transparent';\n if (isFloating) {\n backgroundColor = 'bg-icon-default';\n } else if (isPressed) {\n backgroundColor = 'bg-pressed';\n }\n\n const twIconColorClassNames =\n isInverse || isFloating ? 'text-primary-inverse' : 'text-icon-default';\n\n const onPressInHandler = (event: GestureResponderEvent) => {\n setIsPressed(true);\n onPressIn?.(event);\n };\n\n const onPressOutHandler = (event: GestureResponderEvent) => {\n setIsPressed(false);\n onPressOut?.(event);\n };\n\n return (\n <ButtonAnimated\n disabled={isDisabled}\n onPressIn={onPressInHandler}\n onPressOut={onPressOutHandler}\n accessible\n testID=\"button-icon\"\n {...props}\n style={[\n tw.style(\n 'items-center justify-center',\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size],\n isFloating ? 'rounded-full' : 'rounded-lg',\n backgroundColor,\n isDisabled ? 'opacity-50' : 'opacity-100',\n twClassName,\n ),\n style,\n ]}\n >\n <Icon\n name={iconName}\n color={twIconColorClassNames as IconColor}\n size={MAP_BUTTONICON_SIZE_ICONSIZE[size]}\n {...iconProps}\n />\n </ButtonAnimated>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,cAAc;AAYxC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,0HAYpB,eAAe,
|
|
1
|
+
{"version":3,"file":"ButtonIcon.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,cAAc;AAYxC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,0HAYpB,eAAe,sBAoDjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,cAAc;AAYxC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,0HAYpB,eAAe,
|
|
1
|
+
{"version":3,"file":"ButtonIcon.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,cAAc;AAYxC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,0HAYpB,eAAe,sBAoDjB,CAAC"}
|
|
@@ -11,10 +11,9 @@ import { ButtonIconSize } from "../../types/index.mjs";
|
|
|
11
11
|
import { Icon } from "../Icon/index.mjs";
|
|
12
12
|
import { ButtonAnimated } from "../temp-components/ButtonAnimated/index.mjs";
|
|
13
13
|
import { MAP_BUTTONICON_SIZE_ICONSIZE, TWCLASSMAP_BUTTONICON_SIZE_DIMENSION } from "./ButtonIcon.constants.mjs";
|
|
14
|
-
export const ButtonIcon = ({ size = ButtonIconSize.Md, iconName, iconProps, isDisabled = false, isInverse = false, isFloating = false, onPressIn, onPressOut, twClassName
|
|
14
|
+
export const ButtonIcon = ({ size = ButtonIconSize.Md, iconName, iconProps, isDisabled = false, isInverse = false, isFloating = false, onPressIn, onPressOut, twClassName, style, ...props }) => {
|
|
15
15
|
const [isPressed, setIsPressed] = useState(false);
|
|
16
16
|
const tw = useTailwind();
|
|
17
|
-
// Determine background color based on state
|
|
18
17
|
let backgroundColor = 'bg-transparent';
|
|
19
18
|
if (isFloating) {
|
|
20
19
|
backgroundColor = 'bg-icon-default';
|
|
@@ -22,13 +21,6 @@ export const ButtonIcon = ({ size = ButtonIconSize.Md, iconName, iconProps, isDi
|
|
|
22
21
|
else if (isPressed) {
|
|
23
22
|
backgroundColor = 'bg-pressed';
|
|
24
23
|
}
|
|
25
|
-
const twContainerClassNames = `
|
|
26
|
-
items-center justify-center
|
|
27
|
-
${TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size]}
|
|
28
|
-
${isFloating ? 'rounded-full' : 'rounded-lg'}
|
|
29
|
-
${backgroundColor}
|
|
30
|
-
${isDisabled ? 'opacity-50' : 'opacity-100'}
|
|
31
|
-
${twClassName}`;
|
|
32
24
|
const twIconColorClassNames = isInverse || isFloating ? 'text-primary-inverse' : 'text-icon-default';
|
|
33
25
|
const onPressInHandler = (event) => {
|
|
34
26
|
setIsPressed(true);
|
|
@@ -38,7 +30,10 @@ export const ButtonIcon = ({ size = ButtonIconSize.Md, iconName, iconProps, isDi
|
|
|
38
30
|
setIsPressed(false);
|
|
39
31
|
onPressOut?.(event);
|
|
40
32
|
};
|
|
41
|
-
return (<ButtonAnimated disabled={isDisabled} onPressIn={onPressInHandler} onPressOut={onPressOutHandler} accessible
|
|
33
|
+
return (<ButtonAnimated disabled={isDisabled} onPressIn={onPressInHandler} onPressOut={onPressOutHandler} accessible testID="button-icon" {...props} style={[
|
|
34
|
+
tw.style('items-center justify-center', TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size], isFloating ? 'rounded-full' : 'rounded-lg', backgroundColor, isDisabled ? 'opacity-50' : 'opacity-100', twClassName),
|
|
35
|
+
style,
|
|
36
|
+
]}>
|
|
42
37
|
<Icon name={iconName} color={twIconColorClassNames} size={MAP_BUTTONICON_SIZE_ICONSIZE[size]} {...iconProps}/>
|
|
43
38
|
</ButtonAnimated>);
|
|
44
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.mjs","sourceRoot":"","sources":["../../../src/components/ButtonIcon/ButtonIcon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,sDAAsD;AAC5E,OAAO,QAAO,EAAE,QAAQ,EAAE,cAAc;;AAGxC,OAAO,EAAE,cAAc,EAAE,8B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AAG,YAAY,CAAC;KAChC;IAED,MAAM,qBAAqB,GACzB,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAEzE,MAAM,gBAAgB,GAAG,CAAC,KAA4B,EAAE,EAAE;QACxD,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,CAAC,KAA4B,EAAE,EAAE;QACzD,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,cAAc,CACb,QAAQ,CAAC,CAAC,UAAU,CAAC,CACrB,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAC5B,UAAU,CAAC,CAAC,iBAAiB,CAAC,CAC9B,UAAU,CACV,MAAM,CAAC,aAAa,CACpB,IAAI,KAAK,CAAC,CACV,KAAK,CAAC,CAAC;YACL,EAAE,CAAC,KAAK,CACN,6BAA6B,EAC7B,oCAAoC,CAAC,IAAI,CAAC,EAC1C,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,YAAY,EAC1C,eAAe,EACf,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,EACzC,WAAW,CACZ;YACD,KAAK;SACN,CAAC,CAEF;MAAA,CAAC,IAAI,CACH,IAAI,CAAC,CAAC,QAAQ,CAAC,CACf,KAAK,CAAC,CAAC,qBAAkC,CAAC,CAC1C,IAAI,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,CACzC,IAAI,SAAS,CAAC,EAElB;IAAA,EAAE,cAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useTailwind } from '@metamask-previews/design-system-twrnc-preset';\nimport React, { useState } from 'react';\nimport type { GestureResponderEvent } from 'react-native';\n\nimport { ButtonIconSize } from '../../types';\nimport type { IconColor } from '../Icon';\nimport { Icon } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\n\nimport {\n MAP_BUTTONICON_SIZE_ICONSIZE,\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION,\n} from './ButtonIcon.constants';\nimport type { ButtonIconProps } from './ButtonIcon.types';\n\nexport const ButtonIcon = ({\n size = ButtonIconSize.Md,\n iconName,\n iconProps,\n isDisabled = false,\n isInverse = false,\n isFloating = false,\n onPressIn,\n onPressOut,\n twClassName,\n style,\n ...props\n}: ButtonIconProps) => {\n const [isPressed, setIsPressed] = useState(false);\n const tw = useTailwind();\n\n let backgroundColor = 'bg-transparent';\n if (isFloating) {\n backgroundColor = 'bg-icon-default';\n } else if (isPressed) {\n backgroundColor = 'bg-pressed';\n }\n\n const twIconColorClassNames =\n isInverse || isFloating ? 'text-primary-inverse' : 'text-icon-default';\n\n const onPressInHandler = (event: GestureResponderEvent) => {\n setIsPressed(true);\n onPressIn?.(event);\n };\n\n const onPressOutHandler = (event: GestureResponderEvent) => {\n setIsPressed(false);\n onPressOut?.(event);\n };\n\n return (\n <ButtonAnimated\n disabled={isDisabled}\n onPressIn={onPressInHandler}\n onPressOut={onPressOutHandler}\n accessible\n testID=\"button-icon\"\n {...props}\n style={[\n tw.style(\n 'items-center justify-center',\n TWCLASSMAP_BUTTONICON_SIZE_DIMENSION[size],\n isFloating ? 'rounded-full' : 'rounded-lg',\n backgroundColor,\n isDisabled ? 'opacity-50' : 'opacity-100',\n twClassName,\n ),\n style,\n ]}\n >\n <Icon\n name={iconName}\n color={twIconColorClassNames as IconColor}\n size={MAP_BUTTONICON_SIZE_ICONSIZE[size]}\n {...iconProps}\n />\n </ButtonAnimated>\n );\n};\n"]}
|