@metamask/design-system-react-native 0.34.0 → 0.36.0
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 +37 -1
- package/dist/components/ActionListItem/ActionListItem.cjs +1 -1
- package/dist/components/ActionListItem/ActionListItem.cjs.map +1 -1
- package/dist/components/ActionListItem/ActionListItem.mjs +1 -1
- package/dist/components/ActionListItem/ActionListItem.mjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.cjs +8 -6
- package/dist/components/BannerBase/BannerBase.cjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.d.cts.map +1 -1
- package/dist/components/BannerBase/BannerBase.d.mts.map +1 -1
- package/dist/components/BannerBase/BannerBase.mjs +9 -7
- package/dist/components/BannerBase/BannerBase.mjs.map +1 -1
- package/dist/components/BannerBase/index.cjs +3 -1
- package/dist/components/BannerBase/index.cjs.map +1 -1
- package/dist/components/BannerBase/index.d.cts +1 -0
- package/dist/components/BannerBase/index.d.cts.map +1 -1
- package/dist/components/BannerBase/index.d.mts +1 -0
- package/dist/components/BannerBase/index.d.mts.map +1 -1
- package/dist/components/BannerBase/index.mjs +1 -0
- package/dist/components/BannerBase/index.mjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.cjs +1 -1
- 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 +1 -1
- package/dist/components/ButtonBase/ButtonBase.mjs.map +1 -1
- package/dist/components/Content/Content.cjs +27 -13
- package/dist/components/Content/Content.cjs.map +1 -1
- package/dist/components/Content/Content.d.cts.map +1 -1
- package/dist/components/Content/Content.d.mts.map +1 -1
- package/dist/components/Content/Content.mjs +28 -14
- package/dist/components/Content/Content.mjs.map +1 -1
- package/dist/components/Content/index.cjs +3 -3
- package/dist/components/Content/index.cjs.map +1 -1
- package/dist/components/Content/index.d.cts +1 -1
- package/dist/components/Content/index.d.cts.map +1 -1
- package/dist/components/Content/index.d.mts +1 -1
- package/dist/components/Content/index.d.mts.map +1 -1
- package/dist/components/Content/index.mjs +1 -1
- package/dist/components/Content/index.mjs.map +1 -1
- package/dist/components/FilterButton/FilterButton.cjs +24 -36
- package/dist/components/FilterButton/FilterButton.cjs.map +1 -1
- package/dist/components/FilterButton/FilterButton.d.cts.map +1 -1
- package/dist/components/FilterButton/FilterButton.d.mts.map +1 -1
- package/dist/components/FilterButton/FilterButton.mjs +25 -37
- package/dist/components/FilterButton/FilterButton.mjs.map +1 -1
- package/dist/components/ListItem/ListItem.cjs +19 -8
- package/dist/components/ListItem/ListItem.cjs.map +1 -1
- package/dist/components/ListItem/ListItem.d.cts.map +1 -1
- package/dist/components/ListItem/ListItem.d.mts.map +1 -1
- package/dist/components/ListItem/ListItem.mjs +20 -9
- package/dist/components/ListItem/ListItem.mjs.map +1 -1
- package/dist/components/ListItem/index.cjs +3 -3
- package/dist/components/ListItem/index.cjs.map +1 -1
- package/dist/components/ListItem/index.d.cts +1 -1
- package/dist/components/ListItem/index.d.cts.map +1 -1
- package/dist/components/ListItem/index.d.mts +1 -1
- package/dist/components/ListItem/index.d.mts.map +1 -1
- package/dist/components/ListItem/index.mjs +1 -1
- package/dist/components/ListItem/index.mjs.map +1 -1
- package/dist/components/Slider/Slider.cjs +152 -0
- package/dist/components/Slider/Slider.cjs.map +1 -0
- package/dist/components/Slider/Slider.constants.cjs +41 -0
- package/dist/components/Slider/Slider.constants.cjs.map +1 -0
- package/dist/components/Slider/Slider.constants.d.cts +33 -0
- package/dist/components/Slider/Slider.constants.d.cts.map +1 -0
- package/dist/components/Slider/Slider.constants.d.mts +33 -0
- package/dist/components/Slider/Slider.constants.d.mts.map +1 -0
- package/dist/components/Slider/Slider.constants.mjs +38 -0
- package/dist/components/Slider/Slider.constants.mjs.map +1 -0
- package/dist/components/Slider/Slider.d.cts +7 -0
- package/dist/components/Slider/Slider.d.cts.map +1 -0
- package/dist/components/Slider/Slider.d.mts +7 -0
- package/dist/components/Slider/Slider.d.mts.map +1 -0
- package/dist/components/Slider/Slider.mjs +129 -0
- package/dist/components/Slider/Slider.mjs.map +1 -0
- package/dist/components/Slider/Slider.types.cjs +3 -0
- package/dist/components/Slider/Slider.types.cjs.map +1 -0
- package/dist/components/Slider/Slider.types.d.cts +133 -0
- package/dist/components/Slider/Slider.types.d.cts.map +1 -0
- package/dist/components/Slider/Slider.types.d.mts +133 -0
- package/dist/components/Slider/Slider.types.d.mts.map +1 -0
- package/dist/components/Slider/Slider.types.mjs +2 -0
- package/dist/components/Slider/Slider.types.mjs.map +1 -0
- package/dist/components/Slider/Slider.utilities.cjs +287 -0
- package/dist/components/Slider/Slider.utilities.cjs.map +1 -0
- package/dist/components/Slider/Slider.utilities.d.cts +157 -0
- package/dist/components/Slider/Slider.utilities.d.cts.map +1 -0
- package/dist/components/Slider/Slider.utilities.d.mts +157 -0
- package/dist/components/Slider/Slider.utilities.d.mts.map +1 -0
- package/dist/components/Slider/Slider.utilities.mjs +266 -0
- package/dist/components/Slider/Slider.utilities.mjs.map +1 -0
- package/dist/components/Slider/index.cjs +10 -0
- package/dist/components/Slider/index.cjs.map +1 -0
- package/dist/components/Slider/index.d.cts +6 -0
- package/dist/components/Slider/index.d.cts.map +1 -0
- package/dist/components/Slider/index.d.mts +6 -0
- package/dist/components/Slider/index.d.mts.map +1 -0
- package/dist/components/Slider/index.mjs +4 -0
- package/dist/components/Slider/index.mjs.map +1 -0
- package/dist/components/Slider/useSliderGesture.cjs +252 -0
- package/dist/components/Slider/useSliderGesture.cjs.map +1 -0
- package/dist/components/Slider/useSliderGesture.d.cts +17 -0
- package/dist/components/Slider/useSliderGesture.d.cts.map +1 -0
- package/dist/components/Slider/useSliderGesture.d.mts +17 -0
- package/dist/components/Slider/useSliderGesture.d.mts.map +1 -0
- package/dist/components/Slider/useSliderGesture.mjs +248 -0
- package/dist/components/Slider/useSliderGesture.mjs.map +1 -0
- package/dist/components/index.cjs +10 -5
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +5 -3
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +5 -3
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +4 -3
- package/dist/components/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/components/Content/Content.constants.cjs +0 -9
- package/dist/components/Content/Content.constants.cjs.map +0 -1
- package/dist/components/Content/Content.constants.d.cts +0 -3
- package/dist/components/Content/Content.constants.d.cts.map +0 -1
- package/dist/components/Content/Content.constants.d.mts +0 -3
- package/dist/components/Content/Content.constants.d.mts.map +0 -1
- package/dist/components/Content/Content.constants.mjs +0 -6
- package/dist/components/Content/Content.constants.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.36.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Added `actionButtonLayout` to `BannerBase` (inherited by `BannerAlert`) with `BannerBaseActionButtonLayout.Below` (default) and `BannerBaseActionButtonLayout.End` to place the action button beside the body, left of close ([#1386](https://github.com/MetaMask/metamask-design-system/pull/1386))
|
|
15
|
+
- Added `SliderMarkColor` for themed `Slider` mark colors that interpolate with the thumb ([#1385](https://github.com/MetaMask/metamask-design-system/pull/1385))
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **BREAKING:** Replaced `verticalAlignment` / `ContentVerticalAlignment` / `ListItemVerticalAlignment` on `Content` and `ListItem` with `variant` / `ContentVariant` / `ListItemVariant` (`OneLine`, `TwoLines`, `MultiLine`) for preset row heights, alignment, and secondary-slot gating ([#1384](https://github.com/MetaMask/metamask-design-system/pull/1384))
|
|
20
|
+
- See [Migration Guide](./MIGRATION.md#content-and-listitem-verticalalignment-replaced-by-variant)
|
|
21
|
+
- **BREAKING:** Consolidated `Slider` mark configuration into a single `marks` prop; removed `rangeLabelSteps`, `formatStepLabel`, `stepToValue`, `tickThresholds`, `DEFAULT_RANGE_LABEL_STEPS`, and `DEFAULT_TICK_THRESHOLDS` ([#1385](https://github.com/MetaMask/metamask-design-system/pull/1385))
|
|
22
|
+
- See [Migration Guide](./MIGRATION.md#slider-mark-api-consolidation)
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- Fixed `Slider` drag jerking when the controlled `value` updates mid-gesture ([#1385](https://github.com/MetaMask/metamask-design-system/pull/1385))
|
|
27
|
+
|
|
28
|
+
## [0.35.0]
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- Added `Slider` for controlled range input with pan/tap gestures, optional range dots and labels, and hooks for non-linear scales ([#1372](https://github.com/MetaMask/metamask-design-system/pull/1372))
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- Updated `FilterButton` to compose from `ButtonPrimary`, `ButtonSecondary`, and `ButtonTertiary` instead of hand-rolled styles, so selected-state text and icon colors stay consistent with button variants ([#1379](https://github.com/MetaMask/metamask-design-system/pull/1379))
|
|
37
|
+
- Updated `ButtonBase` to merge `startIconProps.twClassName` and `endIconProps.twClassName` last, matching the existing `textProps.twClassName` pattern ([#1379](https://github.com/MetaMask/metamask-design-system/pull/1379))
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- Fixed `ActionListItem` painting `bg-default` on elevated surfaces in pure-black mode; rows now inherit the parent background and use `bg-pressed` on press ([#1374](https://github.com/MetaMask/metamask-design-system/pull/1374))
|
|
42
|
+
- Fixed `FilterButton` selected-state text appearing invisible (white-on-white) in dark mode ([#1379](https://github.com/MetaMask/metamask-design-system/pull/1379))
|
|
43
|
+
|
|
10
44
|
## [0.34.0]
|
|
11
45
|
|
|
12
46
|
### Added
|
|
@@ -573,7 +607,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
573
607
|
- Full TypeScript support with type definitions and enums
|
|
574
608
|
- React Native integration with TWRNC preset support
|
|
575
609
|
|
|
576
|
-
[Unreleased]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.
|
|
610
|
+
[Unreleased]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.36.0...HEAD
|
|
611
|
+
[0.36.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.35.0...@metamask/design-system-react-native@0.36.0
|
|
612
|
+
[0.35.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.34.0...@metamask/design-system-react-native@0.35.0
|
|
577
613
|
[0.34.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.33.0...@metamask/design-system-react-native@0.34.0
|
|
578
614
|
[0.33.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.32.0...@metamask/design-system-react-native@0.33.0
|
|
579
615
|
[0.32.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react-native@0.31.0...@metamask/design-system-react-native@0.32.0
|
|
@@ -63,7 +63,7 @@ const ActionListItem = ({ label, description, startAccessory, endAccessory, icon
|
|
|
63
63
|
return null;
|
|
64
64
|
};
|
|
65
65
|
const getPressableStyle = (0, react_1.useCallback)(({ pressed }) => {
|
|
66
|
-
const baseStyle = tw.style('
|
|
66
|
+
const baseStyle = tw.style('px-4 py-3', pressed && !isDisabled && 'bg-pressed', isDisabled && 'opacity-50', twClassName);
|
|
67
67
|
return style ? [baseStyle, style] : baseStyle;
|
|
68
68
|
}, [tw, isDisabled, twClassName, style]);
|
|
69
69
|
return (<react_native_1.Pressable onPress={onPress} disabled={isDisabled} style={getPressableStyle} {...pressableProps} {...props}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionListItem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AO,cAAc,CAAC;SACvB;QAED,IAAI,QAAQ,EAAE;YACZ,OAAO,CACL,CAAC,SAAG,CACF,UAAU,CAAC,CAAC,mBAAa,CAAC,MAAM,CAAC,CACjC,cAAc,CAAC,CAAC,uBAAiB,CAAC,MAAM,CAAC,CACzC,WAAW,CAAC,KAAK,CAEjB;UAAA,CAAC,WAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,eAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,SAAS,CAAC,EACzD;QAAA,EAAE,SAAG,CAAC,CACP,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,IAAA,mBAAW,EACnC,CAAC,EAAE,OAAO,EAAwB,EAAE,EAAE;QACpC,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,CACxB,
|
|
1
|
+
{"version":3,"file":"ActionListItem.cjs","sourceRoot":"","sources":["../../../src/components/ActionListItem/ActionListItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAmE;AACnE,+CAA2C;AAC3C,+CAAyC;AAEzC,0CAKgB;AAChB,4CAAyC;AACzC,4CAAuD;AAIhD,MAAM,cAAc,GAAkC,CAAC,EAC5D,KAAK,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,SAAS,EACT,UAAU,GAAG,KAAK,EAClB,OAAO,EACP,cAAc,EACd,WAAW,EACX,KAAK,EACL,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,IAAA,wCAAW,GAAE,CAAC;IAEzB,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CACL,CAAC,WAAI,CAAC,OAAO,CAAC,CAAC,kBAAW,CAAC,MAAM,CAAC,CAAC,IAAI,cAAc,CAAC,CACp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-twrnc-preset';\nimport React, { useCallback } from 'react';\nimport { Pressable } from 'react-native';\n\nimport {\n Box,\n BoxAlignItems,\n BoxFlexDirection,\n BoxJustifyContent,\n} from '../Box';\nimport { Icon, IconSize } from '../Icon';\nimport { Text, TextColor, TextVariant } from '../Text';\n\nimport type { ActionListItemProps } from './ActionListItem.types';\n\nexport const ActionListItem: React.FC<ActionListItemProps> = ({\n label,\n description,\n startAccessory,\n endAccessory,\n iconName,\n labelTextProps,\n descriptionTextProps,\n iconProps,\n isDisabled = false,\n onPress,\n pressableProps,\n twClassName,\n style,\n ...props\n}) => {\n const tw = useTailwind();\n\n const renderLabel = () => {\n if (typeof label === 'string') {\n return (\n <Text variant={TextVariant.BodyMd} {...labelTextProps}>\n {label}\n </Text>\n );\n }\n return label;\n };\n\n const renderDescription = () => {\n if (!description) {\n return null;\n }\n\n if (typeof description === 'string') {\n return (\n <Text\n variant={TextVariant.BodySm}\n color={TextColor.TextAlternative}\n {...descriptionTextProps}\n >\n {description}\n </Text>\n );\n }\n return description;\n };\n\n const renderStartContent = () => {\n if (startAccessory) {\n return startAccessory;\n }\n\n if (iconName) {\n return (\n <Box\n alignItems={BoxAlignItems.Center}\n justifyContent={BoxJustifyContent.Center}\n twClassName=\"h-6\"\n >\n <Icon name={iconName} size={IconSize.Md} {...iconProps} />\n </Box>\n );\n }\n\n return null;\n };\n\n const getPressableStyle = useCallback(\n ({ pressed }: { pressed: boolean }) => {\n const baseStyle = tw.style(\n 'px-4 py-3',\n pressed && !isDisabled && 'bg-pressed',\n isDisabled && 'opacity-50',\n twClassName,\n );\n\n return style ? [baseStyle, style] : baseStyle;\n },\n [tw, isDisabled, twClassName, style],\n );\n\n return (\n <Pressable\n onPress={onPress}\n disabled={isDisabled}\n style={getPressableStyle}\n {...pressableProps}\n {...props}\n >\n <Box\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Center}\n justifyContent={BoxJustifyContent.Between}\n gap={4}\n >\n {/* Left side content (start accessory/icon + label/description) */}\n <Box\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Start}\n twClassName=\"flex-1\"\n gap={4}\n >\n {renderStartContent()}\n <Box twClassName=\"flex-1\">\n {renderLabel()}\n {renderDescription()}\n </Box>\n </Box>\n\n {/* End accessory */}\n {endAccessory && <Box>{endAccessory}</Box>}\n </Box>\n </Pressable>\n );\n};\n"]}
|
|
@@ -44,7 +44,7 @@ export const ActionListItem = ({ label, description, startAccessory, endAccessor
|
|
|
44
44
|
return null;
|
|
45
45
|
};
|
|
46
46
|
const getPressableStyle = useCallback(({ pressed }) => {
|
|
47
|
-
const baseStyle = tw.style('
|
|
47
|
+
const baseStyle = tw.style('px-4 py-3', pressed && !isDisabled && 'bg-pressed', isDisabled && 'opacity-50', twClassName);
|
|
48
48
|
return style ? [baseStyle, style] : baseStyle;
|
|
49
49
|
}, [tw, isDisabled, twClassName, style]);
|
|
50
50
|
return (<Pressable onPress={onPress} disabled={isDisabled} style={getPressableStyle} {...pressableProps} {...props}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionListItem.mjs","sourceRoot":"","sources":["../../../src/components/ActionListItem/ActionListItem.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,6CAA6C;AACnE,OAAO,QAAO,EAAE,WAAW,EAAE,cAAc;;AAC3C,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,EACL,GAAG,EACH,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,yBAAe;AAChB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,0BAAgB;AACzC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,0BAAgB;AAIvD,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAC5D,KAAK,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,SAAS,EACT,UAAU,GAAG,KAAK,E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E,GAAG,CAAC,CACP,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAC,EAAE,OAAO,EAAwB,EAAE,EAAE;QACpC,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,CACxB,
|
|
1
|
+
{"version":3,"file":"ActionListItem.mjs","sourceRoot":"","sources":["../../../src/components/ActionListItem/ActionListItem.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,6CAA6C;AACnE,OAAO,QAAO,EAAE,WAAW,EAAE,cAAc;;AAC3C,OAAO,EAAE,SAAS,EAAE,qBAAqB;AAEzC,OAAO,EACL,GAAG,EACH,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,yBAAe;AAChB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,0BAAgB;AACzC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,0BAAgB;AAIvD,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAC5D,KAAK,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,SAAS,EACT,UAAU,GAAG,KAAK,EAClB,OAAO,EACP,cAAc,EACd,WAAW,EACX,KAAK,EACL,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IAEzB,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CACL,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,cAAc,CAAC,CACpD;UAAA,CAAC,KAAK,CACR;QAAA,EAAE,IAAI,CAAC,CACR,CAAC;SACH;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,GAAG,EAAE;QAC7B,IAA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ACrC,CAAC;IAEF,OAAO,CACL,CAAC,SAAS,CACR,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,QAAQ,CAAC,CAAC,UAAU,CAAC,CACrB,KAAK,CAAC,CAAC,iBAAiB,CAAC,CACzB,IAAI,cAAc,CAAC,CACnB,IAAI,KAAK,CAAC,CAEV;MAAA,CAAC,GAAG,CACF,aAAa,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CACpC,UAAU,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CACjC,cAAc,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAC1C,GAAG,CAAC,CAAC,CAAC,CAAC,CAEP;QAAA,CAAC,kEAAkE,CACnE;QAAA,CAAC,GAAG,CACF,aAAa,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CACpC,UAAU,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAChC,WAAW,CAAC,QAAQ,CACpB,GAAG,CAAC,CAAC,CAAC,CAAC,CAEP;UAAA,CAAC,kBAAkB,EAAE,CACrB;UAAA,CAAC,GAAG,CAAC,WAAW,CAAC,QAAQ,CACvB;YAAA,CAAC,WAAW,EAAE,CACd;YAAA,CAAC,iBAAiB,EAAE,CACtB;UAAA,EAAE,GAAG,CACP;QAAA,EAAE,GAAG,CAEL;;QAAA,CAAC,mBAAmB,CACpB;QAAA,CAAC,YAAY,IAAI,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAC5C;MAAA,EAAE,GAAG,CACP;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport React, { useCallback } from 'react';\nimport { Pressable } from 'react-native';\n\nimport {\n Box,\n BoxAlignItems,\n BoxFlexDirection,\n BoxJustifyContent,\n} from '../Box';\nimport { Icon, IconSize } from '../Icon';\nimport { Text, TextColor, TextVariant } from '../Text';\n\nimport type { ActionListItemProps } from './ActionListItem.types';\n\nexport const ActionListItem: React.FC<ActionListItemProps> = ({\n label,\n description,\n startAccessory,\n endAccessory,\n iconName,\n labelTextProps,\n descriptionTextProps,\n iconProps,\n isDisabled = false,\n onPress,\n pressableProps,\n twClassName,\n style,\n ...props\n}) => {\n const tw = useTailwind();\n\n const renderLabel = () => {\n if (typeof label === 'string') {\n return (\n <Text variant={TextVariant.BodyMd} {...labelTextProps}>\n {label}\n </Text>\n );\n }\n return label;\n };\n\n const renderDescription = () => {\n if (!description) {\n return null;\n }\n\n if (typeof description === 'string') {\n return (\n <Text\n variant={TextVariant.BodySm}\n color={TextColor.TextAlternative}\n {...descriptionTextProps}\n >\n {description}\n </Text>\n );\n }\n return description;\n };\n\n const renderStartContent = () => {\n if (startAccessory) {\n return startAccessory;\n }\n\n if (iconName) {\n return (\n <Box\n alignItems={BoxAlignItems.Center}\n justifyContent={BoxJustifyContent.Center}\n twClassName=\"h-6\"\n >\n <Icon name={iconName} size={IconSize.Md} {...iconProps} />\n </Box>\n );\n }\n\n return null;\n };\n\n const getPressableStyle = useCallback(\n ({ pressed }: { pressed: boolean }) => {\n const baseStyle = tw.style(\n 'px-4 py-3',\n pressed && !isDisabled && 'bg-pressed',\n isDisabled && 'opacity-50',\n twClassName,\n );\n\n return style ? [baseStyle, style] : baseStyle;\n },\n [tw, isDisabled, twClassName, style],\n );\n\n return (\n <Pressable\n onPress={onPress}\n disabled={isDisabled}\n style={getPressableStyle}\n {...pressableProps}\n {...props}\n >\n <Box\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Center}\n justifyContent={BoxJustifyContent.Between}\n gap={4}\n >\n {/* Left side content (start accessory/icon + label/description) */}\n <Box\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Start}\n twClassName=\"flex-1\"\n gap={4}\n >\n {renderStartContent()}\n <Box twClassName=\"flex-1\">\n {renderLabel()}\n {renderDescription()}\n </Box>\n </Box>\n\n {/* End accessory */}\n {endAccessory && <Box>{endAccessory}</Box>}\n </Box>\n </Pressable>\n );\n};\n"]}
|
|
@@ -12,11 +12,15 @@ const ButtonIcon_1 = require("../ButtonIcon/index.cjs");
|
|
|
12
12
|
const Text_1 = require("../Text/index.cjs");
|
|
13
13
|
const isTextContent = (content) => typeof content === 'string' || typeof content === 'number';
|
|
14
14
|
const hasContent = (content) => content !== null && content !== undefined;
|
|
15
|
-
const BannerBase = ({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnPress, actionButtonProps, startAccessory, onClose, closeButtonProps, twClassName, ...props }) => {
|
|
15
|
+
const BannerBase = ({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnPress, actionButtonProps, actionButtonLayout = design_system_shared_1.BannerBaseActionButtonLayout.Below, startAccessory, onClose, closeButtonProps, twClassName, ...props }) => {
|
|
16
16
|
const resolvedActionButtonProps = actionButtonProps ?? {};
|
|
17
17
|
const { accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner', twClassName: closeButtonTwClassName, ...resolvedCloseButtonProps } = closeButtonProps ?? {};
|
|
18
18
|
const shouldShowCloseButton = Boolean(onClose);
|
|
19
19
|
const shouldShowActionButton = Boolean(actionButtonOnPress);
|
|
20
|
+
const isActionButtonLayoutEnd = actionButtonLayout === design_system_shared_1.BannerBaseActionButtonLayout.End;
|
|
21
|
+
const actionButton = shouldShowActionButton ? (<Button_1.Button size={design_system_shared_1.ButtonSize.Md} onPress={actionButtonOnPress} {...resolvedActionButtonProps} variant={design_system_shared_1.ButtonVariant.Secondary}>
|
|
22
|
+
{actionButtonLabel}
|
|
23
|
+
</Button_1.Button>) : null;
|
|
20
24
|
return (<Box_1.Box flexDirection={design_system_shared_1.BoxFlexDirection.Row} alignItems={design_system_shared_1.BoxAlignItems.Start} gap={4} backgroundColor={design_system_shared_1.BoxBackgroundColor.BackgroundDefault} paddingVertical={3} paddingHorizontal={4} twClassName={(0, design_system_shared_1.mergeTwClassName)('rounded-xl', twClassName)} {...props}>
|
|
21
25
|
{startAccessory}
|
|
22
26
|
|
|
@@ -37,13 +41,11 @@ const BannerBase = ({ title, titleProps, description, descriptionProps, children
|
|
|
37
41
|
{children}
|
|
38
42
|
</Text_1.Text>) : (children))}
|
|
39
43
|
|
|
40
|
-
{shouldShowActionButton && (<Box_1.Box twClassName="mt-2">
|
|
41
|
-
<Button_1.Button size={design_system_shared_1.ButtonSize.Md} onPress={actionButtonOnPress} {...resolvedActionButtonProps} variant={design_system_shared_1.ButtonVariant.Secondary}>
|
|
42
|
-
{actionButtonLabel}
|
|
43
|
-
</Button_1.Button>
|
|
44
|
-
</Box_1.Box>)}
|
|
44
|
+
{shouldShowActionButton && !isActionButtonLayoutEnd && (<Box_1.Box twClassName="mt-2">{actionButton}</Box_1.Box>)}
|
|
45
45
|
</Box_1.Box>
|
|
46
46
|
|
|
47
|
+
{shouldShowActionButton && isActionButtonLayoutEnd && actionButton}
|
|
48
|
+
|
|
47
49
|
{shouldShowCloseButton && (<ButtonIcon_1.ButtonIcon twClassName={(0, design_system_shared_1.mergeTwClassName)('-mt-1', closeButtonTwClassName)} iconName={design_system_shared_1.IconName.Close} size={design_system_shared_1.ButtonIconSize.Md} accessibilityLabel={closeButtonAccessibilityLabel} onPress={onClose} {...resolvedCloseButtonProps}/>)}
|
|
48
50
|
</Box_1.Box>);
|
|
49
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"BannerBase.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;AAAA,yEAYwC;AACxC,kDAA0B;AAE1B,0CAA6B;AAC7B,gDAAmC;AACnC,wDAA2C;AAC3C,4CAA+B;AAI/B,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAA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,oBAAoB,CAAC,CAC1D;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,WAAI,CAAC,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CAAC,CAEJ;;QAAA,CAAC,sBAAsB,IAAI,CAAC,uBAAuB,IAAI,CACrD,CAAC,SAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,EAAE,SAAG,CAAC,CAC7C,CACH;MAAA,EAAE,SAAG,CAEL;;MAAA,CAAC,sBAAsB,IAAI,uBAAuB,IAAI,YAAY,CAElE;;MAAA,CAAC,qBAAqB,IAAI,CACxB,CAAC,uBAAU,CACT,WAAW,CAAC,CAAC,IAAA,uCAAgB,EAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAC/D,QAAQ,CAAC,CAAC,+BAAQ,CAAC,KAAK,CAAC,CACzB,IAAI,CAAC,CAAC,qCAAc,CAAC,EAAE,CAAC,CACxB,kBAAkB,CAAC,CAAC,6BAA6B,CAAC,CAClD,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,IAAI,wBAAwB,CAAC,EAC7B,CACH,CACH;IAAA,EAAE,SAAG,CAAC,CACP,CAAC;AACJ,CAAC,CAAC;AA5GW,QAAA,UAAU,cA4GrB","sourcesContent":["import {\n BannerBaseActionButtonLayout,\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n ButtonIconSize,\n ButtonSize,\n ButtonVariant,\n FontWeight,\n IconName,\n mergeTwClassName,\n TextVariant,\n} from '@metamask/design-system-shared';\nimport React from 'react';\n\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Text } from '../Text';\n\nimport type { BannerBaseProps } from './BannerBase.types';\n\nconst isTextContent = (content: React.ReactNode): content is string | number =>\n typeof content === 'string' || typeof content === 'number';\n\nconst hasContent = (content: React.ReactNode) =>\n content !== null && content !== undefined;\n\nexport const BannerBase: React.FC<BannerBaseProps> = ({\n title,\n titleProps,\n description,\n descriptionProps,\n children,\n childrenWrapperProps,\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps,\n actionButtonLayout = BannerBaseActionButtonLayout.Below,\n startAccessory,\n onClose,\n closeButtonProps,\n twClassName,\n ...props\n}) => {\n const resolvedActionButtonProps = actionButtonProps ?? {};\n\n const {\n accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner',\n twClassName: closeButtonTwClassName,\n ...resolvedCloseButtonProps\n } = closeButtonProps ?? {};\n\n const shouldShowCloseButton = Boolean(onClose);\n const shouldShowActionButton = Boolean(actionButtonOnPress);\n const isActionButtonLayoutEnd =\n actionButtonLayout === BannerBaseActionButtonLayout.End;\n\n const actionButton = shouldShowActionButton ? (\n <Button\n size={ButtonSize.Md}\n onPress={actionButtonOnPress}\n {...resolvedActionButtonProps}\n variant={ButtonVariant.Secondary}\n >\n {actionButtonLabel}\n </Button>\n ) : null;\n\n return (\n <Box\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Start}\n gap={4}\n backgroundColor={BoxBackgroundColor.BackgroundDefault}\n paddingVertical={3}\n paddingHorizontal={4}\n twClassName={mergeTwClassName('rounded-xl', twClassName)}\n {...props}\n >\n {startAccessory}\n\n <Box twClassName=\"flex-1\">\n {hasContent(title) &&\n (isTextContent(title) ? (\n <Text\n variant={TextVariant.BodyMd}\n fontWeight={FontWeight.Medium}\n {...titleProps}\n >\n {title}\n </Text>\n ) : (\n title\n ))}\n\n {hasContent(description) && (\n <Box>\n {isTextContent(description) ? (\n <Text variant={TextVariant.BodySm} {...descriptionProps}>\n {description}\n </Text>\n ) : (\n description\n )}\n </Box>\n )}\n\n {hasContent(children) &&\n (isTextContent(children) ? (\n <Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>\n {children}\n </Text>\n ) : (\n children\n ))}\n\n {shouldShowActionButton && !isActionButtonLayoutEnd && (\n <Box twClassName=\"mt-2\">{actionButton}</Box>\n )}\n </Box>\n\n {shouldShowActionButton && isActionButtonLayoutEnd && actionButton}\n\n {shouldShowCloseButton && (\n <ButtonIcon\n twClassName={mergeTwClassName('-mt-1', closeButtonTwClassName)}\n iconName={IconName.Close}\n size={ButtonIconSize.Md}\n accessibilityLabel={closeButtonAccessibilityLabel}\n onPress={onClose}\n {...resolvedCloseButtonProps}\n />\n )}\n </Box>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BannerBase.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,cAAc;AAO1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAQ1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA4GhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BannerBase.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,cAAc;AAO1B,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAQ1D,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA4GhD,CAAC"}
|
|
@@ -4,7 +4,7 @@ function $importDefault(module) {
|
|
|
4
4
|
}
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
|
-
import { BoxAlignItems, BoxBackgroundColor, BoxFlexDirection, ButtonIconSize, ButtonSize, ButtonVariant, FontWeight, IconName, mergeTwClassName, TextVariant } from "@metamask/design-system-shared";
|
|
7
|
+
import { BannerBaseActionButtonLayout, BoxAlignItems, BoxBackgroundColor, BoxFlexDirection, ButtonIconSize, ButtonSize, ButtonVariant, FontWeight, IconName, mergeTwClassName, TextVariant } from "@metamask/design-system-shared";
|
|
8
8
|
import $React from "react";
|
|
9
9
|
const React = $importDefault($React);
|
|
10
10
|
import { Box } from "../Box/index.mjs";
|
|
@@ -13,11 +13,15 @@ import { ButtonIcon } from "../ButtonIcon/index.mjs";
|
|
|
13
13
|
import { Text } from "../Text/index.mjs";
|
|
14
14
|
const isTextContent = (content) => typeof content === 'string' || typeof content === 'number';
|
|
15
15
|
const hasContent = (content) => content !== null && content !== undefined;
|
|
16
|
-
export const BannerBase = ({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnPress, actionButtonProps, startAccessory, onClose, closeButtonProps, twClassName, ...props }) => {
|
|
16
|
+
export const BannerBase = ({ title, titleProps, description, descriptionProps, children, childrenWrapperProps, actionButtonLabel, actionButtonOnPress, actionButtonProps, actionButtonLayout = BannerBaseActionButtonLayout.Below, startAccessory, onClose, closeButtonProps, twClassName, ...props }) => {
|
|
17
17
|
const resolvedActionButtonProps = actionButtonProps ?? {};
|
|
18
18
|
const { accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner', twClassName: closeButtonTwClassName, ...resolvedCloseButtonProps } = closeButtonProps ?? {};
|
|
19
19
|
const shouldShowCloseButton = Boolean(onClose);
|
|
20
20
|
const shouldShowActionButton = Boolean(actionButtonOnPress);
|
|
21
|
+
const isActionButtonLayoutEnd = actionButtonLayout === BannerBaseActionButtonLayout.End;
|
|
22
|
+
const actionButton = shouldShowActionButton ? (<Button size={ButtonSize.Md} onPress={actionButtonOnPress} {...resolvedActionButtonProps} variant={ButtonVariant.Secondary}>
|
|
23
|
+
{actionButtonLabel}
|
|
24
|
+
</Button>) : null;
|
|
21
25
|
return (<Box flexDirection={BoxFlexDirection.Row} alignItems={BoxAlignItems.Start} gap={4} backgroundColor={BoxBackgroundColor.BackgroundDefault} paddingVertical={3} paddingHorizontal={4} twClassName={mergeTwClassName('rounded-xl', twClassName)} {...props}>
|
|
22
26
|
{startAccessory}
|
|
23
27
|
|
|
@@ -38,13 +42,11 @@ export const BannerBase = ({ title, titleProps, description, descriptionProps, c
|
|
|
38
42
|
{children}
|
|
39
43
|
</Text>) : (children))}
|
|
40
44
|
|
|
41
|
-
{shouldShowActionButton && (<Box twClassName="mt-2">
|
|
42
|
-
<Button size={ButtonSize.Md} onPress={actionButtonOnPress} {...resolvedActionButtonProps} variant={ButtonVariant.Secondary}>
|
|
43
|
-
{actionButtonLabel}
|
|
44
|
-
</Button>
|
|
45
|
-
</Box>)}
|
|
45
|
+
{shouldShowActionButton && !isActionButtonLayoutEnd && (<Box twClassName="mt-2">{actionButton}</Box>)}
|
|
46
46
|
</Box>
|
|
47
47
|
|
|
48
|
+
{shouldShowActionButton && isActionButtonLayoutEnd && actionButton}
|
|
49
|
+
|
|
48
50
|
{shouldShowCloseButton && (<ButtonIcon twClassName={mergeTwClassName('-mt-1', closeButtonTwClassName)} iconName={IconName.Close} size={ButtonIconSize.Md} accessibilityLabel={closeButtonAccessibilityLabel} onPress={onClose} {...resolvedCloseButtonProps}/>)}
|
|
49
51
|
</Box>);
|
|
50
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerBase.mjs","sourceRoot":"","sources":["../../../src/components/BannerBase/BannerBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,aAAa,EACb,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACZ,uCAAuC;AACxC,OAAO,MAAK,cAAc;;AAE1B,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,MAAM,EAAE,4BAAkB;AACnC,OAAO,EAAE,UAAU,EAAE,gCAAsB;AAC3C,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAI/B,MAAM,aAAa,GAAG,CAAC,OAAwB,EAA8B,EAAE,CAC7E,OAAO,OAAO,KAAK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,CAC1D;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CAAC,CAEJ;;QAAA,CAAC,sBAAsB,IAAI,CAAC,uBAAuB,IAAI,CACrD,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAC7C,CACH;MAAA,EAAE,GAAG,CAEL;;MAAA,CAAC,sBAAsB,IAAI,uBAAuB,IAAI,YAAY,CAElE;;MAAA,CAAC,qBAAqB,IAAI,CACxB,CAAC,UAAU,CACT,WAAW,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAC/D,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzB,IAAI,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,CACxB,kBAAkB,CAAC,CAAC,6BAA6B,CAAC,CAClD,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,IAAI,wBAAwB,CAAC,EAC7B,CACH,CACH;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n BannerBaseActionButtonLayout,\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n ButtonIconSize,\n ButtonSize,\n ButtonVariant,\n FontWeight,\n IconName,\n mergeTwClassName,\n TextVariant,\n} from '@metamask/design-system-shared';\nimport React from 'react';\n\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { Text } from '../Text';\n\nimport type { BannerBaseProps } from './BannerBase.types';\n\nconst isTextContent = (content: React.ReactNode): content is string | number =>\n typeof content === 'string' || typeof content === 'number';\n\nconst hasContent = (content: React.ReactNode) =>\n content !== null && content !== undefined;\n\nexport const BannerBase: React.FC<BannerBaseProps> = ({\n title,\n titleProps,\n description,\n descriptionProps,\n children,\n childrenWrapperProps,\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps,\n actionButtonLayout = BannerBaseActionButtonLayout.Below,\n startAccessory,\n onClose,\n closeButtonProps,\n twClassName,\n ...props\n}) => {\n const resolvedActionButtonProps = actionButtonProps ?? {};\n\n const {\n accessibilityLabel: closeButtonAccessibilityLabel = 'Close banner',\n twClassName: closeButtonTwClassName,\n ...resolvedCloseButtonProps\n } = closeButtonProps ?? {};\n\n const shouldShowCloseButton = Boolean(onClose);\n const shouldShowActionButton = Boolean(actionButtonOnPress);\n const isActionButtonLayoutEnd =\n actionButtonLayout === BannerBaseActionButtonLayout.End;\n\n const actionButton = shouldShowActionButton ? (\n <Button\n size={ButtonSize.Md}\n onPress={actionButtonOnPress}\n {...resolvedActionButtonProps}\n variant={ButtonVariant.Secondary}\n >\n {actionButtonLabel}\n </Button>\n ) : null;\n\n return (\n <Box\n flexDirection={BoxFlexDirection.Row}\n alignItems={BoxAlignItems.Start}\n gap={4}\n backgroundColor={BoxBackgroundColor.BackgroundDefault}\n paddingVertical={3}\n paddingHorizontal={4}\n twClassName={mergeTwClassName('rounded-xl', twClassName)}\n {...props}\n >\n {startAccessory}\n\n <Box twClassName=\"flex-1\">\n {hasContent(title) &&\n (isTextContent(title) ? (\n <Text\n variant={TextVariant.BodyMd}\n fontWeight={FontWeight.Medium}\n {...titleProps}\n >\n {title}\n </Text>\n ) : (\n title\n ))}\n\n {hasContent(description) && (\n <Box>\n {isTextContent(description) ? (\n <Text variant={TextVariant.BodySm} {...descriptionProps}>\n {description}\n </Text>\n ) : (\n description\n )}\n </Box>\n )}\n\n {hasContent(children) &&\n (isTextContent(children) ? (\n <Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>\n {children}\n </Text>\n ) : (\n children\n ))}\n\n {shouldShowActionButton && !isActionButtonLayoutEnd && (\n <Box twClassName=\"mt-2\">{actionButton}</Box>\n )}\n </Box>\n\n {shouldShowActionButton && isActionButtonLayoutEnd && actionButton}\n\n {shouldShowCloseButton && (\n <ButtonIcon\n twClassName={mergeTwClassName('-mt-1', closeButtonTwClassName)}\n iconName={IconName.Close}\n size={ButtonIconSize.Md}\n accessibilityLabel={closeButtonAccessibilityLabel}\n onPress={onClose}\n {...resolvedCloseButtonProps}\n />\n )}\n </Box>\n );\n};\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BannerBase = void 0;
|
|
3
|
+
exports.BannerBase = exports.BannerBaseActionButtonLayout = void 0;
|
|
4
|
+
var design_system_shared_1 = require("@metamask/design-system-shared");
|
|
5
|
+
Object.defineProperty(exports, "BannerBaseActionButtonLayout", { enumerable: true, get: function () { return design_system_shared_1.BannerBaseActionButtonLayout; } });
|
|
4
6
|
var BannerBase_1 = require("./BannerBase.cjs");
|
|
5
7
|
Object.defineProperty(exports, "BannerBase", { enumerable: true, get: function () { return BannerBase_1.BannerBase; } });
|
|
6
8
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/index.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAAjC,wGAAA,UAAU,OAAA","sourcesContent":["export { BannerBase } from './BannerBase';\nexport type { BannerBaseProps } from './BannerBase.types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/BannerBase/index.ts"],"names":[],"mappings":";;;AAAA,uEAA8E;AAArE,oIAAA,4BAA4B,OAAA;AAErC,+CAA0C;AAAjC,wGAAA,UAAU,OAAA","sourcesContent":["export { BannerBaseActionButtonLayout } from '@metamask/design-system-shared';\n\nexport { BannerBase } from './BannerBase';\nexport type { BannerBaseProps } from './BannerBase.types';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAqB;AAC1C,YAAY,EAAE,eAAe,EAAE,+BAA2B"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/BannerBase/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,uCAAuC;AAE9E,OAAO,EAAE,UAAU,EAAE,yBAAqB;AAC1C,YAAY,EAAE,eAAe,EAAE,+BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAqB;AAC1C,YAAY,EAAE,eAAe,EAAE,+BAA2B"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/BannerBase/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,uCAAuC;AAE9E,OAAO,EAAE,UAAU,EAAE,yBAAqB;AAC1C,YAAY,EAAE,eAAe,EAAE,+BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/BannerBase/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAqB","sourcesContent":["export { BannerBase } from './BannerBase';\nexport type { BannerBaseProps } from './BannerBase.types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/BannerBase/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,uCAAuC;AAE9E,OAAO,EAAE,UAAU,EAAE,yBAAqB","sourcesContent":["export { BannerBaseActionButtonLayout } from '@metamask/design-system-shared';\n\nexport { BannerBase } from './BannerBase';\nexport type { BannerBaseProps } from './BannerBase.types';\n"]}
|
|
@@ -128,7 +128,7 @@ const ButtonBase = ({ children, textProps, size = design_system_shared_1.ButtonB
|
|
|
128
128
|
|
|
129
129
|
<BoxRow_1.BoxRow {...restContentWrapper} twClassName={isLoading
|
|
130
130
|
? (0, design_system_shared_1.mergeTwClassName)('opacity-0', contentWrapperTw)
|
|
131
|
-
: contentWrapperTw} gap={hasAccessories ? 1 : 0} startAccessory={finalStartIconName ? (<Icon_1.Icon name={finalStartIconName} size={iconSize} twClassName={(0, design_system_shared_1.mergeTwClassName)('shrink-0', iconClassName ? iconClassName(pressed) : undefined)
|
|
131
|
+
: contentWrapperTw} gap={hasAccessories ? 1 : 0} startAccessory={finalStartIconName ? (<Icon_1.Icon name={finalStartIconName} size={iconSize} {...startIconProps} twClassName={(0, design_system_shared_1.mergeTwClassName)((0, design_system_shared_1.mergeTwClassName)('shrink-0', iconClassName ? iconClassName(pressed) : undefined), startIconProps?.twClassName)}/>) : (startAccessory)} endAccessory={finalEndIconName ? (<Icon_1.Icon name={finalEndIconName} size={iconSize} {...endIconProps} twClassName={(0, design_system_shared_1.mergeTwClassName)((0, design_system_shared_1.mergeTwClassName)('shrink-0', iconClassName ? iconClassName(pressed) : undefined), endIconProps?.twClassName)}/>) : (endAccessory)} textProps={{
|
|
132
132
|
variant: labelTextVariant,
|
|
133
133
|
fontWeight: design_system_shared_1.FontWeight.Medium,
|
|
134
134
|
color: design_system_shared_1.TextColor.TextDefault,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAKwC;AACxC,qFAAmE;AACnE,+CAAuC;AAGvC,0CAA6B;AAC7B,gDAAmC;AACnC,4CAA0C;AAC1C,gFAAmE;AACnE,kEAAqD;AAErD,qEAMgC;AAGzB,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,qCAAc,CAAC,EAAE,EACxB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB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UAAU,EACV,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CACnD,CAAC,CACF,IAAI,YAAY,CAAC,EACjB,CACH,CAAC,CAAC,CAAC,CACF,YAAY,CACb,CACF,CACD,SAAS,CAAC,CAAC;oBACT,OAAO,EAAE,gBAAgB;oBACzB,UAAU,EAAE,iCAAU,CAAC,MAAM;oBAC7B,KAAK,EAAE,gCAAS,CAAC,WAAW;oBAC5B,aAAa,EAAE,CAAC;oBAChB,aAAa,EAAE,MAAM;oBACrB,GAAG,SAAS;oBACZ,WAAW,EAAE,IAAA,uCAAgB,EAC3B,IAAA,uCAAgB,EACd,qCAAqC,EACrC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CACnD,EACD,SAAS,EAAE,WAAW,CACvB;iBACF,CAAC,CAEF;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,eAAM,CACV;UAAA,GAAG,CACJ,CAAC;QACJ,CAAC,CACH;IAAA,EAAE,+BAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC;AA7OW,QAAA,UAAU,cA6OrB","sourcesContent":["import {\n ButtonBaseSize,\n FontWeight,\n mergeTwClassName,\n TextColor,\n} from '@metamask/design-system-shared';\nimport { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport React, { useMemo } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { Box } from '../Box';\nimport { BoxRow } from '../BoxRow';\nimport { Icon, IconColor } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\n\nimport {\n MAP_BUTTONBASE_SIZE_ICONSIZE,\n MAP_BUTTONBASE_SIZE_TEXT_VARIANT,\n getButtonBaseBorderRadiusTwClass,\n getButtonBaseHorizontalPaddingTwClasses,\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION,\n} 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 loadingWrapperProps,\n contentWrapperProps,\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 const hasStart = Boolean(finalStartIconName || startAccessory);\n const hasEnd = Boolean(finalEndIconName || endAccessory);\n const hasAccessories = hasStart || hasEnd;\n\n const iconSize = MAP_BUTTONBASE_SIZE_ICONSIZE[size];\n const labelTextVariant = MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];\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',\n // Visual styling\n 'bg-muted overflow-hidden',\n // Conditional Border Radius and Horizontal Spacing based on requirements\n getButtonBaseBorderRadiusTwClass(size),\n getButtonBaseHorizontalPaddingTwClasses(size, hasStart, hasEnd),\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 const { twClassName: loadingWrapperTw, ...restLoadingWrapper } =\n loadingWrapperProps ?? {};\n const { twClassName: contentWrapperTw, ...restContentWrapper } =\n contentWrapperProps ?? {};\n\n return (\n <>\n {/* Loading spinner overlay */}\n {isLoading && (\n <Box\n {...restLoadingWrapper}\n twClassName={mergeTwClassName(\n 'absolute inset-0 flex items-center justify-center',\n loadingWrapperTw,\n )}\n >\n <Spinner\n color={\n textClassName\n ? (textClassName(pressed) as IconColor)\n : IconColor.IconDefault\n }\n loadingText={loadingText}\n {...spinnerProps}\n spinnerIconProps={{\n size: iconSize,\n ...spinnerProps?.spinnerIconProps,\n }}\n loadingTextProps={{\n numberOfLines: 1,\n variant: labelTextVariant,\n twClassName: textClassName ? textClassName(pressed) : '',\n ...spinnerProps?.loadingTextProps,\n }}\n />\n </Box>\n )}\n\n <BoxRow\n {...restContentWrapper}\n twClassName={\n isLoading\n ? mergeTwClassName('opacity-0', contentWrapperTw)\n : contentWrapperTw\n }\n gap={hasAccessories ? 1 : 0}\n startAccessory={\n finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={iconSize}\n twClassName={mergeTwClassName(\n 'shrink-0',\n iconClassName ? iconClassName(pressed) : undefined,\n )}\n {...startIconProps}\n />\n ) : (\n startAccessory\n )\n }\n endAccessory={\n finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={iconSize}\n twClassName={mergeTwClassName(\n 'shrink-0',\n iconClassName ? iconClassName(pressed) : undefined,\n )}\n {...endIconProps}\n />\n ) : (\n endAccessory\n )\n }\n textProps={{\n variant: labelTextVariant,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n numberOfLines: 1,\n ellipsizeMode: 'clip',\n ...textProps,\n twClassName: mergeTwClassName(\n mergeTwClassName(\n 'shrink grow-0 flex-wrap text-center',\n textClassName ? textClassName(pressed) : undefined,\n ),\n textProps?.twClassName,\n ),\n }}\n >\n {children}\n </BoxRow>\n </>\n );\n }}\n </ButtonAnimated>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ButtonBase.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAKwC;AACxC,qFAAmE;AACnE,+CAAuC;AAGvC,0CAA6B;AAC7B,gDAAmC;AACnC,4CAA0C;AAC1C,gFAAmE;AACnE,kEAAqD;AAErD,qEAMgC;AAGzB,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,qCAAc,CAAC,EAAE,EACxB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAA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AC,IAAA,uCAAgB,EAC3B,IAAA,uCAAgB,EACd,UAAU,EACV,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CACnD,EACD,YAAY,EAAE,WAAW,CAC1B,CAAC,EACF,CACH,CAAC,CAAC,CAAC,CACF,YAAY,CACb,CACF,CACD,SAAS,CAAC,CAAC;oBACT,OAAO,EAAE,gBAAgB;oBACzB,UAAU,EAAE,iCAAU,CAAC,MAAM;oBAC7B,KAAK,EAAE,gCAAS,CAAC,WAAW;oBAC5B,aAAa,EAAE,CAAC;oBAChB,aAAa,EAAE,MAAM;oBACrB,GAAG,SAAS;oBACZ,WAAW,EAAE,IAAA,uCAAgB,EAC3B,IAAA,uCAAgB,EACd,qCAAqC,EACrC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CACnD,EACD,SAAS,EAAE,WAAW,CACvB;iBACF,CAAC,CAEF;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,eAAM,CACV;UAAA,GAAG,CACJ,CAAC;QACJ,CAAC,CACH;IAAA,EAAE,+BAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC;AAnPW,QAAA,UAAU,cAmPrB","sourcesContent":["import {\n ButtonBaseSize,\n FontWeight,\n mergeTwClassName,\n TextColor,\n} from '@metamask/design-system-shared';\nimport { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport React, { useMemo } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { Box } from '../Box';\nimport { BoxRow } from '../BoxRow';\nimport { Icon, IconColor } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\n\nimport {\n MAP_BUTTONBASE_SIZE_ICONSIZE,\n MAP_BUTTONBASE_SIZE_TEXT_VARIANT,\n getButtonBaseBorderRadiusTwClass,\n getButtonBaseHorizontalPaddingTwClasses,\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION,\n} 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 loadingWrapperProps,\n contentWrapperProps,\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 const hasStart = Boolean(finalStartIconName || startAccessory);\n const hasEnd = Boolean(finalEndIconName || endAccessory);\n const hasAccessories = hasStart || hasEnd;\n\n const iconSize = MAP_BUTTONBASE_SIZE_ICONSIZE[size];\n const labelTextVariant = MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];\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',\n // Visual styling\n 'bg-muted overflow-hidden',\n // Conditional Border Radius and Horizontal Spacing based on requirements\n getButtonBaseBorderRadiusTwClass(size),\n getButtonBaseHorizontalPaddingTwClasses(size, hasStart, hasEnd),\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 const { twClassName: loadingWrapperTw, ...restLoadingWrapper } =\n loadingWrapperProps ?? {};\n const { twClassName: contentWrapperTw, ...restContentWrapper } =\n contentWrapperProps ?? {};\n\n return (\n <>\n {/* Loading spinner overlay */}\n {isLoading && (\n <Box\n {...restLoadingWrapper}\n twClassName={mergeTwClassName(\n 'absolute inset-0 flex items-center justify-center',\n loadingWrapperTw,\n )}\n >\n <Spinner\n color={\n textClassName\n ? (textClassName(pressed) as IconColor)\n : IconColor.IconDefault\n }\n loadingText={loadingText}\n {...spinnerProps}\n spinnerIconProps={{\n size: iconSize,\n ...spinnerProps?.spinnerIconProps,\n }}\n loadingTextProps={{\n numberOfLines: 1,\n variant: labelTextVariant,\n twClassName: textClassName ? textClassName(pressed) : '',\n ...spinnerProps?.loadingTextProps,\n }}\n />\n </Box>\n )}\n\n <BoxRow\n {...restContentWrapper}\n twClassName={\n isLoading\n ? mergeTwClassName('opacity-0', contentWrapperTw)\n : contentWrapperTw\n }\n gap={hasAccessories ? 1 : 0}\n startAccessory={\n finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={iconSize}\n {...startIconProps}\n twClassName={mergeTwClassName(\n mergeTwClassName(\n 'shrink-0',\n iconClassName ? iconClassName(pressed) : undefined,\n ),\n startIconProps?.twClassName,\n )}\n />\n ) : (\n startAccessory\n )\n }\n endAccessory={\n finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={iconSize}\n {...endIconProps}\n twClassName={mergeTwClassName(\n mergeTwClassName(\n 'shrink-0',\n iconClassName ? iconClassName(pressed) : undefined,\n ),\n endIconProps?.twClassName,\n )}\n />\n ) : (\n endAccessory\n )\n }\n textProps={{\n variant: labelTextVariant,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n numberOfLines: 1,\n ellipsizeMode: 'clip',\n ...textProps,\n twClassName: mergeTwClassName(\n mergeTwClassName(\n 'shrink grow-0 flex-wrap text-center',\n textClassName ? textClassName(pressed) : undefined,\n ),\n textProps?.twClassName,\n ),\n }}\n >\n {children}\n </BoxRow>\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":"AAOA,OAAO,KAAkB,cAAc;AAgBvC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,sYA2BpB,eAAe,
|
|
1
|
+
{"version":3,"file":"ButtonBase.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAkB,cAAc;AAgBvC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,sYA2BpB,eAAe,sBAwNjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAkB,cAAc;AAgBvC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,sYA2BpB,eAAe,
|
|
1
|
+
{"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAkB,cAAc;AAgBvC,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,sYA2BpB,eAAe,sBAwNjB,CAAC"}
|
|
@@ -109,7 +109,7 @@ export const ButtonBase = ({ children, textProps, size = ButtonBaseSize.Lg, isLo
|
|
|
109
109
|
|
|
110
110
|
<BoxRow {...restContentWrapper} twClassName={isLoading
|
|
111
111
|
? mergeTwClassName('opacity-0', contentWrapperTw)
|
|
112
|
-
: contentWrapperTw} gap={hasAccessories ? 1 : 0} startAccessory={finalStartIconName ? (<Icon name={finalStartIconName} size={iconSize} twClassName={mergeTwClassName('shrink-0', iconClassName ? iconClassName(pressed) : undefined)
|
|
112
|
+
: contentWrapperTw} gap={hasAccessories ? 1 : 0} startAccessory={finalStartIconName ? (<Icon name={finalStartIconName} size={iconSize} {...startIconProps} twClassName={mergeTwClassName(mergeTwClassName('shrink-0', iconClassName ? iconClassName(pressed) : undefined), startIconProps?.twClassName)}/>) : (startAccessory)} endAccessory={finalEndIconName ? (<Icon name={finalEndIconName} size={iconSize} {...endIconProps} twClassName={mergeTwClassName(mergeTwClassName('shrink-0', iconClassName ? iconClassName(pressed) : undefined), endIconProps?.twClassName)}/>) : (endAccessory)} textProps={{
|
|
113
113
|
variant: labelTextVariant,
|
|
114
114
|
fontWeight: FontWeight.Medium,
|
|
115
115
|
color: TextColor.TextDefault,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,SAAS,EACV,uCAAuC;AACxC,OAAO,EAAE,WAAW,EAAE,6CAA6C;AACnE,OAAO,QAAO,EAAE,OAAO,EAAE,cAAc;;AAGvC,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,MAAM,EAAE,4BAAkB;AACnC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,0BAAgB;AAC1C,OAAO,EAAE,cAAc,EAAE,oDAA0C;AACnE,OAAO,EAAE,OAAO,EAAE,6CAAmC;AAErD,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,uCAAuC,EACvC,oCAAoC,EACrC,mCAA+B;AAGhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,cAAc,CAAC,EAAE,EACxB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,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,iBAAiB,EACjB,iBAAiB,GAAG,QAAQ,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,GAAG,KAAK,EACQ,EAAE,EAAE;IACpB,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IAEzB,MAAM,kBAAkB,GAAG,aAAa,IAAI,cAAc,EAAE,IAAI,CAAC;IACjE,MAAM,gBAAgB,GAAG,W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,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CACnD,EACD,SAAS,EAAE,WAAW,CACvB;iBACF,CAAC,CAEF;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,MAAM,CACV;UAAA,GAAG,CACJ,CAAC;QACJ,CAAC,CACH;IAAA,EAAE,cAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n ButtonBaseSize,\n FontWeight,\n mergeTwClassName,\n TextColor,\n} from '@metamask/design-system-shared';\nimport { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport React, { useMemo } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { Box } from '../Box';\nimport { BoxRow } from '../BoxRow';\nimport { Icon, IconColor } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\n\nimport {\n MAP_BUTTONBASE_SIZE_ICONSIZE,\n MAP_BUTTONBASE_SIZE_TEXT_VARIANT,\n getButtonBaseBorderRadiusTwClass,\n getButtonBaseHorizontalPaddingTwClasses,\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION,\n} 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 loadingWrapperProps,\n contentWrapperProps,\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 const hasStart = Boolean(finalStartIconName || startAccessory);\n const hasEnd = Boolean(finalEndIconName || endAccessory);\n const hasAccessories = hasStart || hasEnd;\n\n const iconSize = MAP_BUTTONBASE_SIZE_ICONSIZE[size];\n const labelTextVariant = MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];\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',\n // Visual styling\n 'bg-muted overflow-hidden',\n // Conditional Border Radius and Horizontal Spacing based on requirements\n getButtonBaseBorderRadiusTwClass(size),\n getButtonBaseHorizontalPaddingTwClasses(size, hasStart, hasEnd),\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 const { twClassName: loadingWrapperTw, ...restLoadingWrapper } =\n loadingWrapperProps ?? {};\n const { twClassName: contentWrapperTw, ...restContentWrapper } =\n contentWrapperProps ?? {};\n\n return (\n <>\n {/* Loading spinner overlay */}\n {isLoading && (\n <Box\n {...restLoadingWrapper}\n twClassName={mergeTwClassName(\n 'absolute inset-0 flex items-center justify-center',\n loadingWrapperTw,\n )}\n >\n <Spinner\n color={\n textClassName\n ? (textClassName(pressed) as IconColor)\n : IconColor.IconDefault\n }\n loadingText={loadingText}\n {...spinnerProps}\n spinnerIconProps={{\n size: iconSize,\n ...spinnerProps?.spinnerIconProps,\n }}\n loadingTextProps={{\n numberOfLines: 1,\n variant: labelTextVariant,\n twClassName: textClassName ? textClassName(pressed) : '',\n ...spinnerProps?.loadingTextProps,\n }}\n />\n </Box>\n )}\n\n <BoxRow\n {...restContentWrapper}\n twClassName={\n isLoading\n ? mergeTwClassName('opacity-0', contentWrapperTw)\n : contentWrapperTw\n }\n gap={hasAccessories ? 1 : 0}\n startAccessory={\n finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={iconSize}\n twClassName={mergeTwClassName(\n 'shrink-0',\n iconClassName ? iconClassName(pressed) : undefined,\n )}\n {...startIconProps}\n />\n ) : (\n startAccessory\n )\n }\n endAccessory={\n finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={iconSize}\n twClassName={mergeTwClassName(\n 'shrink-0',\n iconClassName ? iconClassName(pressed) : undefined,\n )}\n {...endIconProps}\n />\n ) : (\n endAccessory\n )\n }\n textProps={{\n variant: labelTextVariant,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n numberOfLines: 1,\n ellipsizeMode: 'clip',\n ...textProps,\n twClassName: mergeTwClassName(\n mergeTwClassName(\n 'shrink grow-0 flex-wrap text-center',\n textClassName ? textClassName(pressed) : undefined,\n ),\n textProps?.twClassName,\n ),\n }}\n >\n {children}\n </BoxRow>\n </>\n );\n }}\n </ButtonAnimated>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ButtonBase.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,SAAS,EACV,uCAAuC;AACxC,OAAO,EAAE,WAAW,EAAE,6CAA6C;AACnE,OAAO,QAAO,EAAE,OAAO,EAAE,cAAc;;AAGvC,OAAO,EAAE,GAAG,EAAE,yBAAe;AAC7B,OAAO,EAAE,MAAM,EAAE,4BAAkB;AACnC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,0BAAgB;AAC1C,OAAO,EAAE,cAAc,EAAE,oDAA0C;AACnE,OAAO,EAAE,OAAO,EAAE,6CAAmC;AAErD,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,uCAAuC,EACvC,oCAAoC,EACrC,mCAA+B;AAGhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,cAAc,CAAC,EAAE,EACxB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,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,iBAAiB,EACjB,iBAAiB,GAAG,QAAQ,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,GAAG,K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E,gBAAgB;oBACzB,UAAU,EAAE,UAAU,CAAC,MAAM;oBAC7B,KAAK,EAAE,SAAS,CAAC,WAAW;oBAC5B,aAAa,EAAE,CAAC;oBAChB,aAAa,EAAE,MAAM;oBACrB,GAAG,SAAS;oBACZ,WAAW,EAAE,gBAAgB,CAC3B,gBAAgB,CACd,qCAAqC,EACrC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CACnD,EACD,SAAS,EAAE,WAAW,CACvB;iBACF,CAAC,CAEF;cAAA,CAAC,QAAQ,CACX;YAAA,EAAE,MAAM,CACV;UAAA,GAAG,CACJ,CAAC;QACJ,CAAC,CACH;IAAA,EAAE,cAAc,CAAC,CAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n ButtonBaseSize,\n FontWeight,\n mergeTwClassName,\n TextColor,\n} from '@metamask/design-system-shared';\nimport { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport React, { useMemo } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { Box } from '../Box';\nimport { BoxRow } from '../BoxRow';\nimport { Icon, IconColor } from '../Icon';\nimport { ButtonAnimated } from '../temp-components/ButtonAnimated';\nimport { Spinner } from '../temp-components/Spinner';\n\nimport {\n MAP_BUTTONBASE_SIZE_ICONSIZE,\n MAP_BUTTONBASE_SIZE_TEXT_VARIANT,\n getButtonBaseBorderRadiusTwClass,\n getButtonBaseHorizontalPaddingTwClasses,\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION,\n} 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 loadingWrapperProps,\n contentWrapperProps,\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 const hasStart = Boolean(finalStartIconName || startAccessory);\n const hasEnd = Boolean(finalEndIconName || endAccessory);\n const hasAccessories = hasStart || hasEnd;\n\n const iconSize = MAP_BUTTONBASE_SIZE_ICONSIZE[size];\n const labelTextVariant = MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];\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',\n // Visual styling\n 'bg-muted overflow-hidden',\n // Conditional Border Radius and Horizontal Spacing based on requirements\n getButtonBaseBorderRadiusTwClass(size),\n getButtonBaseHorizontalPaddingTwClasses(size, hasStart, hasEnd),\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 const { twClassName: loadingWrapperTw, ...restLoadingWrapper } =\n loadingWrapperProps ?? {};\n const { twClassName: contentWrapperTw, ...restContentWrapper } =\n contentWrapperProps ?? {};\n\n return (\n <>\n {/* Loading spinner overlay */}\n {isLoading && (\n <Box\n {...restLoadingWrapper}\n twClassName={mergeTwClassName(\n 'absolute inset-0 flex items-center justify-center',\n loadingWrapperTw,\n )}\n >\n <Spinner\n color={\n textClassName\n ? (textClassName(pressed) as IconColor)\n : IconColor.IconDefault\n }\n loadingText={loadingText}\n {...spinnerProps}\n spinnerIconProps={{\n size: iconSize,\n ...spinnerProps?.spinnerIconProps,\n }}\n loadingTextProps={{\n numberOfLines: 1,\n variant: labelTextVariant,\n twClassName: textClassName ? textClassName(pressed) : '',\n ...spinnerProps?.loadingTextProps,\n }}\n />\n </Box>\n )}\n\n <BoxRow\n {...restContentWrapper}\n twClassName={\n isLoading\n ? mergeTwClassName('opacity-0', contentWrapperTw)\n : contentWrapperTw\n }\n gap={hasAccessories ? 1 : 0}\n startAccessory={\n finalStartIconName ? (\n <Icon\n name={finalStartIconName}\n size={iconSize}\n {...startIconProps}\n twClassName={mergeTwClassName(\n mergeTwClassName(\n 'shrink-0',\n iconClassName ? iconClassName(pressed) : undefined,\n ),\n startIconProps?.twClassName,\n )}\n />\n ) : (\n startAccessory\n )\n }\n endAccessory={\n finalEndIconName ? (\n <Icon\n name={finalEndIconName}\n size={iconSize}\n {...endIconProps}\n twClassName={mergeTwClassName(\n mergeTwClassName(\n 'shrink-0',\n iconClassName ? iconClassName(pressed) : undefined,\n ),\n endIconProps?.twClassName,\n )}\n />\n ) : (\n endAccessory\n )\n }\n textProps={{\n variant: labelTextVariant,\n fontWeight: FontWeight.Medium,\n color: TextColor.TextDefault,\n numberOfLines: 1,\n ellipsizeMode: 'clip',\n ...textProps,\n twClassName: mergeTwClassName(\n mergeTwClassName(\n 'shrink grow-0 flex-wrap text-center',\n textClassName ? textClassName(pressed) : undefined,\n ),\n textProps?.twClassName,\n ),\n }}\n >\n {children}\n </BoxRow>\n </>\n );\n }}\n </ButtonAnimated>\n );\n};\n"]}
|