@metamask-previews/design-system-react 0.20.0-preview.f515a62 → 0.22.0-preview.178e60f
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 +25 -1
- package/dist/components/AvatarGroup/AvatarGroup.cjs +18 -13
- package/dist/components/AvatarGroup/AvatarGroup.cjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.constants.cjs +16 -17
- package/dist/components/AvatarGroup/AvatarGroup.constants.cjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.constants.d.cts +1 -2
- package/dist/components/AvatarGroup/AvatarGroup.constants.d.cts.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.constants.d.mts +1 -2
- package/dist/components/AvatarGroup/AvatarGroup.constants.d.mts.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.constants.mjs +1 -2
- package/dist/components/AvatarGroup/AvatarGroup.constants.mjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.d.cts +8 -21
- package/dist/components/AvatarGroup/AvatarGroup.d.cts.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.d.mts +8 -21
- package/dist/components/AvatarGroup/AvatarGroup.d.mts.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.mjs +9 -4
- package/dist/components/AvatarGroup/AvatarGroup.mjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.types.cjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.types.d.cts +7 -24
- package/dist/components/AvatarGroup/AvatarGroup.types.d.cts.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.types.d.mts +7 -24
- package/dist/components/AvatarGroup/AvatarGroup.types.d.mts.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.types.mjs.map +1 -1
- package/dist/components/AvatarGroup/index.cjs +3 -3
- package/dist/components/AvatarGroup/index.cjs.map +1 -1
- package/dist/components/AvatarGroup/index.d.cts +1 -1
- package/dist/components/AvatarGroup/index.d.cts.map +1 -1
- package/dist/components/AvatarGroup/index.d.mts +1 -1
- package/dist/components/AvatarGroup/index.d.mts.map +1 -1
- package/dist/components/AvatarGroup/index.mjs +1 -1
- package/dist/components/AvatarGroup/index.mjs.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.d.cts +2 -4
- package/dist/components/BannerAlert/BannerAlert.d.cts.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.d.mts +2 -4
- package/dist/components/BannerAlert/BannerAlert.d.mts.map +1 -1
- package/dist/components/BannerBase/BannerBase.cjs +3 -3
- package/dist/components/BannerBase/BannerBase.cjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.d.cts +2 -4
- package/dist/components/BannerBase/BannerBase.d.cts.map +1 -1
- package/dist/components/BannerBase/BannerBase.d.mts +2 -4
- package/dist/components/BannerBase/BannerBase.d.mts.map +1 -1
- package/dist/components/BannerBase/BannerBase.mjs +3 -3
- package/dist/components/BannerBase/BannerBase.mjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.types.cjs.map +1 -1
- package/dist/components/BannerBase/BannerBase.types.d.cts +1 -5
- package/dist/components/BannerBase/BannerBase.types.d.cts.map +1 -1
- package/dist/components/BannerBase/BannerBase.types.d.mts +1 -5
- package/dist/components/BannerBase/BannerBase.types.d.mts.map +1 -1
- package/dist/components/BannerBase/BannerBase.types.mjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.cjs +26 -18
- package/dist/components/ButtonBase/ButtonBase.cjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.cjs +31 -1
- package/dist/components/ButtonBase/ButtonBase.constants.cjs.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.cts +6 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.cts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.mts +6 -1
- package/dist/components/ButtonBase/ButtonBase.constants.d.mts.map +1 -1
- package/dist/components/ButtonBase/ButtonBase.constants.mjs +29 -1
- package/dist/components/ButtonBase/ButtonBase.constants.mjs.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 +28 -20
- package/dist/components/ButtonBase/ButtonBase.mjs.map +1 -1
- package/dist/components/HeaderBase/HeaderBase.cjs +43 -0
- package/dist/components/HeaderBase/HeaderBase.cjs.map +1 -0
- package/dist/components/HeaderBase/HeaderBase.d.cts +4 -0
- package/dist/components/HeaderBase/HeaderBase.d.cts.map +1 -0
- package/dist/components/HeaderBase/HeaderBase.d.mts +4 -0
- package/dist/components/HeaderBase/HeaderBase.d.mts.map +1 -0
- package/dist/components/HeaderBase/HeaderBase.mjs +24 -0
- package/dist/components/HeaderBase/HeaderBase.mjs.map +1 -0
- package/dist/components/HeaderBase/HeaderBase.types.cjs +3 -0
- package/dist/components/HeaderBase/HeaderBase.types.cjs.map +1 -0
- package/dist/components/HeaderBase/HeaderBase.types.d.cts +51 -0
- package/dist/components/HeaderBase/HeaderBase.types.d.cts.map +1 -0
- package/dist/components/HeaderBase/HeaderBase.types.d.mts +51 -0
- package/dist/components/HeaderBase/HeaderBase.types.d.mts.map +1 -0
- package/dist/components/HeaderBase/HeaderBase.types.mjs +2 -0
- package/dist/components/HeaderBase/HeaderBase.types.mjs.map +1 -0
- package/dist/components/HeaderBase/index.cjs +6 -0
- package/dist/components/HeaderBase/index.cjs.map +1 -0
- package/dist/components/HeaderBase/index.d.cts +3 -0
- package/dist/components/HeaderBase/index.d.cts.map +1 -0
- package/dist/components/HeaderBase/index.d.mts +3 -0
- package/dist/components/HeaderBase/index.d.mts.map +1 -0
- package/dist/components/HeaderBase/index.mjs +2 -0
- package/dist/components/HeaderBase/index.mjs.map +1 -0
- package/dist/components/Icon/icons/Candlestick.cjs +1 -1
- package/dist/components/Icon/icons/Candlestick.cjs.map +1 -1
- package/dist/components/Icon/icons/Candlestick.mjs +1 -1
- package/dist/components/Icon/icons/Candlestick.mjs.map +1 -1
- package/dist/components/Icon/icons/Group.cjs +32 -0
- package/dist/components/Icon/icons/Group.cjs.map +1 -0
- package/dist/components/Icon/icons/Group.d.cts +4 -0
- package/dist/components/Icon/icons/Group.d.cts.map +1 -0
- package/dist/components/Icon/icons/Group.d.mts +4 -0
- package/dist/components/Icon/icons/Group.d.mts.map +1 -0
- package/dist/components/Icon/icons/Group.mjs +7 -0
- package/dist/components/Icon/icons/Group.mjs.map +1 -0
- package/dist/components/Icon/icons/ListArrow.cjs +32 -0
- package/dist/components/Icon/icons/ListArrow.cjs.map +1 -0
- package/dist/components/Icon/icons/ListArrow.d.cts +4 -0
- package/dist/components/Icon/icons/ListArrow.d.cts.map +1 -0
- package/dist/components/Icon/icons/ListArrow.d.mts +4 -0
- package/dist/components/Icon/icons/ListArrow.d.mts.map +1 -0
- package/dist/components/Icon/icons/ListArrow.mjs +7 -0
- package/dist/components/Icon/icons/ListArrow.mjs.map +1 -0
- package/dist/components/Icon/icons/Merge.cjs +32 -0
- package/dist/components/Icon/icons/Merge.cjs.map +1 -0
- package/dist/components/Icon/icons/Merge.d.cts +4 -0
- package/dist/components/Icon/icons/Merge.d.cts.map +1 -0
- package/dist/components/Icon/icons/Merge.d.mts +4 -0
- package/dist/components/Icon/icons/Merge.d.mts.map +1 -0
- package/dist/components/Icon/icons/Merge.mjs +7 -0
- package/dist/components/Icon/icons/Merge.mjs.map +1 -0
- package/dist/components/Icon/icons/Musd.cjs +32 -0
- package/dist/components/Icon/icons/Musd.cjs.map +1 -0
- package/dist/components/Icon/icons/Musd.d.cts +4 -0
- package/dist/components/Icon/icons/Musd.d.cts.map +1 -0
- package/dist/components/Icon/icons/Musd.d.mts +4 -0
- package/dist/components/Icon/icons/Musd.d.mts.map +1 -0
- package/dist/components/Icon/icons/Musd.mjs +7 -0
- package/dist/components/Icon/icons/Musd.mjs.map +1 -0
- package/dist/components/Icon/icons/MusdFilled.cjs +32 -0
- package/dist/components/Icon/icons/MusdFilled.cjs.map +1 -0
- package/dist/components/Icon/icons/MusdFilled.d.cts +4 -0
- package/dist/components/Icon/icons/MusdFilled.d.cts.map +1 -0
- package/dist/components/Icon/icons/MusdFilled.d.mts +4 -0
- package/dist/components/Icon/icons/MusdFilled.d.mts.map +1 -0
- package/dist/components/Icon/icons/MusdFilled.mjs +7 -0
- package/dist/components/Icon/icons/MusdFilled.mjs.map +1 -0
- package/dist/components/Icon/icons/PieChart.cjs +32 -0
- package/dist/components/Icon/icons/PieChart.cjs.map +1 -0
- package/dist/components/Icon/icons/PieChart.d.cts +4 -0
- package/dist/components/Icon/icons/PieChart.d.cts.map +1 -0
- package/dist/components/Icon/icons/PieChart.d.mts +4 -0
- package/dist/components/Icon/icons/PieChart.d.mts.map +1 -0
- package/dist/components/Icon/icons/PieChart.mjs +7 -0
- package/dist/components/Icon/icons/PieChart.mjs.map +1 -0
- package/dist/components/Icon/icons/Predictions.cjs +32 -0
- package/dist/components/Icon/icons/Predictions.cjs.map +1 -0
- package/dist/components/Icon/icons/Predictions.d.cts +4 -0
- package/dist/components/Icon/icons/Predictions.d.cts.map +1 -0
- package/dist/components/Icon/icons/Predictions.d.mts +4 -0
- package/dist/components/Icon/icons/Predictions.d.mts.map +1 -0
- package/dist/components/Icon/icons/Predictions.mjs +7 -0
- package/dist/components/Icon/icons/Predictions.mjs.map +1 -0
- package/dist/components/Icon/icons/index.cjs +14 -0
- package/dist/components/Icon/icons/index.cjs.map +1 -1
- package/dist/components/Icon/icons/index.d.cts +7 -0
- package/dist/components/Icon/icons/index.d.cts.map +1 -1
- package/dist/components/Icon/icons/index.d.mts +7 -0
- package/dist/components/Icon/icons/index.d.mts.map +1 -1
- package/dist/components/Icon/icons/index.mjs +14 -0
- package/dist/components/Icon/icons/index.mjs.map +1 -1
- package/dist/components/Input/Input.cjs +4 -3
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.d.cts +1 -5
- package/dist/components/Input/Input.d.cts.map +1 -1
- package/dist/components/Input/Input.d.mts +1 -5
- package/dist/components/Input/Input.d.mts.map +1 -1
- package/dist/components/Input/Input.mjs +4 -3
- package/dist/components/Input/Input.mjs.map +1 -1
- package/dist/components/Input/Input.types.cjs.map +1 -1
- package/dist/components/Input/Input.types.d.cts +2 -20
- package/dist/components/Input/Input.types.d.cts.map +1 -1
- package/dist/components/Input/Input.types.d.mts +2 -20
- package/dist/components/Input/Input.types.d.mts.map +1 -1
- package/dist/components/Input/Input.types.mjs.map +1 -1
- package/dist/components/Modal/Modal.cjs +49 -0
- package/dist/components/Modal/Modal.cjs.map +1 -0
- package/dist/components/Modal/Modal.context.cjs +14 -0
- package/dist/components/Modal/Modal.context.cjs.map +1 -0
- package/dist/components/Modal/Modal.context.d.cts +6 -0
- package/dist/components/Modal/Modal.context.d.cts.map +1 -0
- package/dist/components/Modal/Modal.context.d.mts +6 -0
- package/dist/components/Modal/Modal.context.d.mts.map +1 -0
- package/dist/components/Modal/Modal.context.mjs +10 -0
- package/dist/components/Modal/Modal.context.mjs.map +1 -0
- package/dist/components/Modal/Modal.d.cts +4 -0
- package/dist/components/Modal/Modal.d.cts.map +1 -0
- package/dist/components/Modal/Modal.d.mts +4 -0
- package/dist/components/Modal/Modal.d.mts.map +1 -0
- package/dist/components/Modal/Modal.mjs +30 -0
- package/dist/components/Modal/Modal.mjs.map +1 -0
- package/dist/components/Modal/Modal.types.cjs +3 -0
- package/dist/components/Modal/Modal.types.cjs.map +1 -0
- package/dist/components/Modal/Modal.types.d.cts +64 -0
- package/dist/components/Modal/Modal.types.d.cts.map +1 -0
- package/dist/components/Modal/Modal.types.d.mts +64 -0
- package/dist/components/Modal/Modal.types.d.mts.map +1 -0
- package/dist/components/Modal/Modal.types.mjs +2 -0
- package/dist/components/Modal/Modal.types.mjs.map +1 -0
- package/dist/components/Modal/index.cjs +8 -0
- package/dist/components/Modal/index.cjs.map +1 -0
- package/dist/components/Modal/index.d.cts +5 -0
- package/dist/components/Modal/index.d.cts.map +1 -0
- package/dist/components/Modal/index.d.mts +5 -0
- package/dist/components/Modal/index.d.mts.map +1 -0
- package/dist/components/Modal/index.mjs +3 -0
- package/dist/components/Modal/index.mjs.map +1 -0
- package/dist/components/ModalContent/ModalContent.cjs +73 -0
- package/dist/components/ModalContent/ModalContent.cjs.map +1 -0
- package/dist/components/ModalContent/ModalContent.constants.cjs +34 -0
- package/dist/components/ModalContent/ModalContent.constants.cjs.map +1 -0
- package/dist/components/ModalContent/ModalContent.constants.d.cts +31 -0
- package/dist/components/ModalContent/ModalContent.constants.d.cts.map +1 -0
- package/dist/components/ModalContent/ModalContent.constants.d.mts +31 -0
- package/dist/components/ModalContent/ModalContent.constants.d.mts.map +1 -0
- package/dist/components/ModalContent/ModalContent.constants.mjs +31 -0
- package/dist/components/ModalContent/ModalContent.constants.mjs.map +1 -0
- package/dist/components/ModalContent/ModalContent.d.cts +4 -0
- package/dist/components/ModalContent/ModalContent.d.cts.map +1 -0
- package/dist/components/ModalContent/ModalContent.d.mts +4 -0
- package/dist/components/ModalContent/ModalContent.d.mts.map +1 -0
- package/dist/components/ModalContent/ModalContent.mjs +54 -0
- package/dist/components/ModalContent/ModalContent.mjs.map +1 -0
- package/dist/components/ModalContent/ModalContent.types.cjs +15 -0
- package/dist/components/ModalContent/ModalContent.types.cjs.map +1 -0
- package/dist/components/ModalContent/ModalContent.types.d.cts +51 -0
- package/dist/components/ModalContent/ModalContent.types.d.cts.map +1 -0
- package/dist/components/ModalContent/ModalContent.types.d.mts +51 -0
- package/dist/components/ModalContent/ModalContent.types.d.mts.map +1 -0
- package/dist/components/ModalContent/ModalContent.types.mjs +12 -0
- package/dist/components/ModalContent/ModalContent.types.mjs.map +1 -0
- package/dist/components/ModalContent/index.cjs +10 -0
- package/dist/components/ModalContent/index.cjs.map +1 -0
- package/dist/components/ModalContent/index.d.cts +5 -0
- package/dist/components/ModalContent/index.d.cts.map +1 -0
- package/dist/components/ModalContent/index.d.mts +5 -0
- package/dist/components/ModalContent/index.d.mts.map +1 -0
- package/dist/components/ModalContent/index.mjs +4 -0
- package/dist/components/ModalContent/index.mjs.map +1 -0
- package/dist/components/ModalFocus/ModalFocus.cjs +56 -0
- package/dist/components/ModalFocus/ModalFocus.cjs.map +1 -0
- package/dist/components/ModalFocus/ModalFocus.d.cts +4 -0
- package/dist/components/ModalFocus/ModalFocus.d.cts.map +1 -0
- package/dist/components/ModalFocus/ModalFocus.d.mts +4 -0
- package/dist/components/ModalFocus/ModalFocus.d.mts.map +1 -0
- package/dist/components/ModalFocus/ModalFocus.mjs +34 -0
- package/dist/components/ModalFocus/ModalFocus.mjs.map +1 -0
- package/dist/components/ModalFocus/ModalFocus.types.cjs +3 -0
- package/dist/components/ModalFocus/ModalFocus.types.cjs.map +1 -0
- package/dist/components/ModalFocus/ModalFocus.types.d.cts +36 -0
- package/dist/components/ModalFocus/ModalFocus.types.d.cts.map +1 -0
- package/dist/components/ModalFocus/ModalFocus.types.d.mts +36 -0
- package/dist/components/ModalFocus/ModalFocus.types.d.mts.map +1 -0
- package/dist/components/ModalFocus/ModalFocus.types.mjs +2 -0
- package/dist/components/ModalFocus/ModalFocus.types.mjs.map +1 -0
- package/dist/components/ModalFocus/index.cjs +6 -0
- package/dist/components/ModalFocus/index.cjs.map +1 -0
- package/dist/components/ModalFocus/index.d.cts +3 -0
- package/dist/components/ModalFocus/index.d.cts.map +1 -0
- package/dist/components/ModalFocus/index.d.mts +3 -0
- package/dist/components/ModalFocus/index.d.mts.map +1 -0
- package/dist/components/ModalFocus/index.mjs +2 -0
- package/dist/components/ModalFocus/index.mjs.map +1 -0
- package/dist/components/ModalFooter/ModalFooter.cjs +44 -0
- package/dist/components/ModalFooter/ModalFooter.cjs.map +1 -0
- package/dist/components/ModalFooter/ModalFooter.d.cts +4 -0
- package/dist/components/ModalFooter/ModalFooter.d.cts.map +1 -0
- package/dist/components/ModalFooter/ModalFooter.d.mts +4 -0
- package/dist/components/ModalFooter/ModalFooter.d.mts.map +1 -0
- package/dist/components/ModalFooter/ModalFooter.mjs +25 -0
- package/dist/components/ModalFooter/ModalFooter.mjs.map +1 -0
- package/dist/components/ModalFooter/ModalFooter.types.cjs +14 -0
- package/dist/components/ModalFooter/ModalFooter.types.cjs.map +1 -0
- package/dist/components/ModalFooter/ModalFooter.types.d.cts +63 -0
- package/dist/components/ModalFooter/ModalFooter.types.d.cts.map +1 -0
- package/dist/components/ModalFooter/ModalFooter.types.d.mts +63 -0
- package/dist/components/ModalFooter/ModalFooter.types.d.mts.map +1 -0
- package/dist/components/ModalFooter/ModalFooter.types.mjs +11 -0
- package/dist/components/ModalFooter/ModalFooter.types.mjs.map +1 -0
- package/dist/components/ModalFooter/index.cjs +8 -0
- package/dist/components/ModalFooter/index.cjs.map +1 -0
- package/dist/components/ModalFooter/index.d.cts +4 -0
- package/dist/components/ModalFooter/index.d.cts.map +1 -0
- package/dist/components/ModalFooter/index.d.mts +4 -0
- package/dist/components/ModalFooter/index.d.mts.map +1 -0
- package/dist/components/ModalFooter/index.mjs +3 -0
- package/dist/components/ModalFooter/index.mjs.map +1 -0
- package/dist/components/Skeleton/Skeleton.cjs +46 -0
- package/dist/components/Skeleton/Skeleton.cjs.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.cts +4 -0
- package/dist/components/Skeleton/Skeleton.d.cts.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.mts +4 -0
- package/dist/components/Skeleton/Skeleton.d.mts.map +1 -0
- package/dist/components/Skeleton/Skeleton.mjs +27 -0
- package/dist/components/Skeleton/Skeleton.mjs.map +1 -0
- package/dist/components/Skeleton/Skeleton.types.cjs +3 -0
- package/dist/components/Skeleton/Skeleton.types.cjs.map +1 -0
- package/dist/components/Skeleton/Skeleton.types.d.cts +38 -0
- package/dist/components/Skeleton/Skeleton.types.d.cts.map +1 -0
- package/dist/components/Skeleton/Skeleton.types.d.mts +38 -0
- package/dist/components/Skeleton/Skeleton.types.d.mts.map +1 -0
- package/dist/components/Skeleton/Skeleton.types.mjs +2 -0
- package/dist/components/Skeleton/Skeleton.types.mjs.map +1 -0
- package/dist/components/Skeleton/index.cjs +6 -0
- package/dist/components/Skeleton/index.cjs.map +1 -0
- package/dist/components/Skeleton/index.d.cts +3 -0
- package/dist/components/Skeleton/index.d.cts.map +1 -0
- package/dist/components/Skeleton/index.d.mts +3 -0
- package/dist/components/Skeleton/index.d.mts.map +1 -0
- package/dist/components/Skeleton/index.mjs +2 -0
- package/dist/components/Skeleton/index.mjs.map +1 -0
- package/dist/components/index.cjs +18 -2
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +12 -0
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +12 -0
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +6 -0
- package/dist/components/index.mjs.map +1 -1
- package/dist/types/index.cjs +3 -15
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +0 -10
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +0 -10
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs +0 -11
- package/dist/types/index.mjs.map +1 -1
- package/package.json +5 -4
|
@@ -34,6 +34,13 @@ const ButtonBase_constants_1 = require("./ButtonBase.constants.cjs");
|
|
|
34
34
|
exports.ButtonBase = (0, react_1.forwardRef)(({ children, className, size = design_system_shared_1.ButtonBaseSize.Lg, isFullWidth, asChild, isDisabled, isLoading, loadingText, loadingIconProps, loadingTextProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, textProps, style, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, 'aria-pressed': ariaPressed, 'aria-expanded': ariaExpanded, 'aria-controls': ariaControls, 'aria-haspopup': ariaHaspopup, ...props }, ref) => {
|
|
35
35
|
const Component = asChild ? react_slot_1.Slot : 'button';
|
|
36
36
|
const isInteractive = !(isDisabled ?? isLoading);
|
|
37
|
+
const finalStartIconName = startIconName ?? startIconProps?.name;
|
|
38
|
+
const finalEndIconName = endIconName ?? endIconProps?.name;
|
|
39
|
+
const hasStart = Boolean(finalStartIconName || startAccessory);
|
|
40
|
+
const hasEnd = Boolean(finalEndIconName || endAccessory);
|
|
41
|
+
const hasAccessories = hasStart || hasEnd;
|
|
42
|
+
const iconSize = ButtonBase_constants_1.MAP_BUTTONBASE_SIZE_ICONSIZE[size];
|
|
43
|
+
const labelTextVariant = ButtonBase_constants_1.MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];
|
|
37
44
|
// Calculate tabIndex based on asChild and disabled state
|
|
38
45
|
const getTabIndex = () => {
|
|
39
46
|
if (asChild) {
|
|
@@ -41,41 +48,42 @@ exports.ButtonBase = (0, react_1.forwardRef)(({ children, className, size = desi
|
|
|
41
48
|
}
|
|
42
49
|
return isDisabled ? -1 : undefined;
|
|
43
50
|
};
|
|
51
|
+
const renderLabel = () => {
|
|
52
|
+
if (children && typeof children === 'string') {
|
|
53
|
+
return (react_1.default.createElement(Text_1.Text, { variant: labelTextVariant, fontWeight: Text_1.FontWeight.Medium, color: Text_1.TextColor.Inherit, asChild: true, ...textProps },
|
|
54
|
+
react_1.default.createElement("span", null, children)));
|
|
55
|
+
}
|
|
56
|
+
return children;
|
|
57
|
+
};
|
|
44
58
|
const renderLoadingState = () => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
45
|
-
react_1.default.createElement("span", { className: "absolute inline-flex items-center", "aria-hidden": "true" },
|
|
46
|
-
react_1.default.createElement(Icon_1.Icon, { name: design_system_shared_1.IconName.Loading, size:
|
|
47
|
-
react_1.default.createElement(Text_1.Text, { fontWeight: Text_1.FontWeight.Medium, color: Text_1.TextColor.Inherit, asChild: true, ...loadingTextProps },
|
|
59
|
+
react_1.default.createElement("span", { className: "absolute inline-flex items-center gap-x-1", "aria-hidden": "true" },
|
|
60
|
+
react_1.default.createElement(Icon_1.Icon, { name: design_system_shared_1.IconName.Loading, size: iconSize, className: (0, tw_merge_1.twMerge)('animate-spin text-inherit', loadingIconProps?.className), ...loadingIconProps }),
|
|
61
|
+
react_1.default.createElement(Text_1.Text, { variant: labelTextVariant, fontWeight: Text_1.FontWeight.Medium, color: Text_1.TextColor.Inherit, asChild: true, ...loadingTextProps },
|
|
48
62
|
react_1.default.createElement("span", null, loadingText))),
|
|
49
|
-
react_1.default.createElement("span", { className: "invisible inline-flex items-center" },
|
|
63
|
+
react_1.default.createElement("span", { className: "invisible inline-flex items-center", "aria-hidden": "true" }, renderLabel()),
|
|
50
64
|
react_1.default.createElement("span", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true" }, loadingText || 'Loading')));
|
|
51
65
|
const renderStartContent = () => {
|
|
52
|
-
if (
|
|
53
|
-
return (react_1.default.createElement(Icon_1.Icon, { name:
|
|
66
|
+
if (finalStartIconName) {
|
|
67
|
+
return (react_1.default.createElement(Icon_1.Icon, { name: finalStartIconName, size: iconSize, className: (0, tw_merge_1.twMerge)('shrink-0 text-inherit', startIconProps?.className), "aria-hidden": "true", ...startIconProps }));
|
|
54
68
|
}
|
|
55
69
|
if (startAccessory) {
|
|
56
|
-
return
|
|
70
|
+
return react_1.default.createElement("span", { "aria-hidden": "true" }, startAccessory);
|
|
57
71
|
}
|
|
58
72
|
return null;
|
|
59
73
|
};
|
|
60
74
|
const renderEndContent = () => {
|
|
61
|
-
if (
|
|
62
|
-
return (react_1.default.createElement(Icon_1.Icon, { name:
|
|
75
|
+
if (finalEndIconName) {
|
|
76
|
+
return (react_1.default.createElement(Icon_1.Icon, { name: finalEndIconName, size: iconSize, className: (0, tw_merge_1.twMerge)('shrink-0 text-inherit', endIconProps?.className), "aria-hidden": "true", ...endIconProps }));
|
|
63
77
|
}
|
|
64
78
|
if (endAccessory) {
|
|
65
|
-
return
|
|
79
|
+
return react_1.default.createElement("span", { "aria-hidden": "true" }, endAccessory);
|
|
66
80
|
}
|
|
67
81
|
return null;
|
|
68
82
|
};
|
|
69
|
-
const renderContent = () =>
|
|
70
|
-
if (children && typeof children === 'string') {
|
|
71
|
-
return (react_1.default.createElement(Text_1.Text, { fontWeight: Text_1.FontWeight.Medium, color: Text_1.TextColor.Inherit, asChild: true, ...textProps },
|
|
72
|
-
react_1.default.createElement("span", null, children)));
|
|
73
|
-
}
|
|
74
|
-
return children;
|
|
75
|
-
};
|
|
83
|
+
const renderContent = () => renderLabel();
|
|
76
84
|
const mergedClassName = (0, tw_merge_1.twMerge)(
|
|
77
85
|
// Base styles
|
|
78
|
-
'inline-flex items-center justify-center', '
|
|
86
|
+
'inline-flex items-center justify-center', (0, ButtonBase_constants_1.getButtonBaseBorderRadiusTwClass)(size), (0, ButtonBase_constants_1.getButtonBaseHorizontalPaddingTwClasses)(size, hasStart, hasEnd), hasAccessories && 'gap-x-1', 'font-medium text-default', 'bg-muted', 'overflow-hidden',
|
|
79
87
|
// Add relative positioning for loading state
|
|
80
88
|
'relative',
|
|
81
89
|
// Size
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kFAAmF;AACnF,qDAAuD;AACvD,+CAA0C;AAE1C,uDAA+C;AAC/C,4CAAyC;AACzC,4CAAsD;AAEtD,qEAA8E;AAGjE,QAAA,UAAU,GAAG,IAAA,kBAAU,EAClC,CACE,EACE,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,qCAAc,CAAC,EAAE,EACxB,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,YAAY,EAC7B,eAAe,EAAE,YAAY,EAC7B,eAAe,EAAE,YAAY,EAC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;QACb,qBAAqB;QACrB,2CAA2C;KAC5C;IACD,0DAA0D;IAC1D,CAAC,UAAU,IAAI,SAAS,CAAC,IAAI,oBAAoB,EACjD,UAAU,IAAI,YAAY;IAC1B,iBAAiB;IACjB,SAAS,CACV,CAAC;IAEF,OAAO,CACL,8BAAC,SAAS,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,SAAS,CAAC,mBAC1C,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,eACnC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,gBAC7B,SAAS,qBACJ,cAAc,sBACb,eAAe,kBACnB,WAAW,mBACV,YAAY,mBACZ,YAAY,mBACZ,YAAY,EAC3B,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACpC,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,KAAK,KACR,KAAK;QAER,kBAAkB,EAAE;QACrB,8BAAC,sBAAS,QACP,SAAS,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CACzC;QACX,gBAAgB,EAAE,CACT,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import { ButtonBaseSize, IconName } from '@metamask-previews/design-system-shared';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon, IconSize } from '../Icon';\nimport { Text, FontWeight, TextColor } from '../Text';\n\nimport { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from './ButtonBase.constants';\nimport type { ButtonBaseProps } from './ButtonBase.types';\n\nexport const ButtonBase = forwardRef<HTMLButtonElement, ButtonBaseProps>(\n (\n {\n children,\n className,\n size = ButtonBaseSize.Lg,\n isFullWidth,\n asChild,\n isDisabled,\n isLoading,\n loadingText,\n loadingIconProps,\n loadingTextProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n textProps,\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n 'aria-pressed': ariaPressed,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls,\n 'aria-haspopup': ariaHaspopup,\n ...props\n },\n ref,\n ) => {\n const Component = asChild ? Slot : 'button';\n const isInteractive = !(isDisabled ?? isLoading);\n\n // Calculate tabIndex based on asChild and disabled state\n const getTabIndex = () => {\n if (asChild) {\n return undefined;\n }\n return isDisabled ? -1 : undefined;\n };\n\n const renderLoadingState = () => (\n <>\n <span className=\"absolute inline-flex items-center\" aria-hidden=\"true\">\n <Icon\n name={IconName.Loading}\n size={IconSize.Sm}\n className={twMerge(\n 'mr-2 animate-spin text-inherit',\n loadingIconProps?.className,\n )}\n {...loadingIconProps}\n />\n <Text\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...loadingTextProps}\n >\n <span>{loadingText}</span>\n </Text>\n </span>\n <span className=\"invisible inline-flex items-center\">{children}</span>\n {/* Screen reader announcement for loading */}\n <span className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {loadingText || 'Loading'}\n </span>\n </>\n );\n\n const renderStartContent = () => {\n if (startIconName) {\n return (\n <Icon\n name={startIconName}\n size={IconSize.Sm}\n className={twMerge(\n 'mr-2 shrink-0 text-inherit',\n startIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...startIconProps}\n />\n );\n }\n if (startAccessory) {\n return (\n <span className=\"mr-2\" aria-hidden=\"true\">\n {startAccessory}\n </span>\n );\n }\n return null;\n };\n\n const renderEndContent = () => {\n if (endIconName) {\n return (\n <Icon\n name={endIconName}\n size={IconSize.Sm}\n className={twMerge(\n 'ml-2 shrink-0 text-inherit',\n endIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...endIconProps}\n />\n );\n }\n if (endAccessory) {\n return (\n <span className=\"ml-2\" aria-hidden=\"true\">\n {endAccessory}\n </span>\n );\n }\n return null;\n };\n\n const renderContent = () => {\n if (children && typeof children === 'string') {\n return (\n <Text\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...textProps}\n >\n <span>{children}</span>\n </Text>\n );\n }\n return children;\n };\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center',\n 'rounded-xl px-4',\n 'font-medium text-default',\n 'bg-muted',\n 'min-w-20 overflow-hidden',\n // Add relative positioning for loading state\n 'relative',\n // Size\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],\n // Full width\n isFullWidth && 'w-full',\n // Animation classes - only applied when interactive\n isInteractive && [\n 'transition-all',\n 'duration-100',\n 'ease-linear',\n 'active:scale-[0.97]',\n 'active:ease-[cubic-bezier(0.3,0.8,0.3,1)]',\n ],\n // Disabled state - apply to both isDisabled and isLoading\n (isDisabled || isLoading) && 'cursor-not-allowed',\n isDisabled && 'opacity-50',\n // Custom classes\n className,\n );\n\n return (\n <Component\n ref={ref}\n className={mergedClassName}\n disabled={asChild ? undefined : (isDisabled ?? isLoading)}\n aria-disabled={isDisabled ? 'true' : undefined}\n aria-busy={isLoading ? 'true' : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n aria-pressed={ariaPressed}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-haspopup={ariaHaspopup}\n role={asChild ? undefined : 'button'}\n tabIndex={getTabIndex()}\n style={style}\n {...props}\n >\n {renderStartContent()}\n <Slottable>\n {isLoading ? renderLoadingState() : renderContent()}\n </Slottable>\n {renderEndContent()}\n </Component>\n );\n },\n);\n\nButtonBase.displayName = 'ButtonBase';\n"]}
|
|
1
|
+
{"version":3,"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AgB;QAChB,cAAc;QACd,aAAa;QACb,qBAAqB;QACrB,2CAA2C;KAC5C;IACD,0DAA0D;IAC1D,CAAC,UAAU,IAAI,SAAS,CAAC,IAAI,oBAAoB,EACjD,UAAU,IAAI,YAAY;IAC1B,iBAAiB;IACjB,SAAS,CACV,CAAC;IAEF,OAAO,CACL,8BAAC,SAAS,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,SAAS,CAAC,mBAC1C,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,eACnC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,gBAC7B,SAAS,qBACJ,cAAc,sBACb,eAAe,kBACnB,WAAW,mBACV,YAAY,mBACZ,YAAY,mBACZ,YAAY,EAC3B,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACpC,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,KAAK,KACR,KAAK;QAER,kBAAkB,EAAE;QACrB,8BAAC,sBAAS,QACP,SAAS,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CACzC;QACX,gBAAgB,EAAE,CACT,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import { ButtonBaseSize, IconName } from '@metamask-previews/design-system-shared';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon } from '../Icon';\nimport { Text, FontWeight, TextColor } from '../Text';\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 = forwardRef<HTMLButtonElement, ButtonBaseProps>(\n (\n {\n children,\n className,\n size = ButtonBaseSize.Lg,\n isFullWidth,\n asChild,\n isDisabled,\n isLoading,\n loadingText,\n loadingIconProps,\n loadingTextProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n textProps,\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n 'aria-pressed': ariaPressed,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls,\n 'aria-haspopup': ariaHaspopup,\n ...props\n },\n ref,\n ) => {\n const Component = asChild ? Slot : 'button';\n const isInteractive = !(isDisabled ?? isLoading);\n\n const finalStartIconName = startIconName ?? startIconProps?.name;\n const finalEndIconName = endIconName ?? endIconProps?.name;\n const hasStart = Boolean(finalStartIconName || startAccessory);\n const hasEnd = Boolean(finalEndIconName || endAccessory);\n const hasAccessories = hasStart || hasEnd;\n const iconSize = MAP_BUTTONBASE_SIZE_ICONSIZE[size];\n const labelTextVariant = MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];\n\n // Calculate tabIndex based on asChild and disabled state\n const getTabIndex = () => {\n if (asChild) {\n return undefined;\n }\n return isDisabled ? -1 : undefined;\n };\n\n const renderLabel = () => {\n if (children && typeof children === 'string') {\n return (\n <Text\n variant={labelTextVariant}\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...textProps}\n >\n <span>{children}</span>\n </Text>\n );\n }\n return children;\n };\n\n const renderLoadingState = () => (\n <>\n <span\n className=\"absolute inline-flex items-center gap-x-1\"\n aria-hidden=\"true\"\n >\n <Icon\n name={IconName.Loading}\n size={iconSize}\n className={twMerge(\n 'animate-spin text-inherit',\n loadingIconProps?.className,\n )}\n {...loadingIconProps}\n />\n <Text\n variant={labelTextVariant}\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...loadingTextProps}\n >\n <span>{loadingText}</span>\n </Text>\n </span>\n <span className=\"invisible inline-flex items-center\" aria-hidden=\"true\">\n {renderLabel()}\n </span>\n {/* Screen reader announcement for loading */}\n <span className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {loadingText || 'Loading'}\n </span>\n </>\n );\n\n const renderStartContent = () => {\n if (finalStartIconName) {\n return (\n <Icon\n name={finalStartIconName}\n size={iconSize}\n className={twMerge(\n 'shrink-0 text-inherit',\n startIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...startIconProps}\n />\n );\n }\n if (startAccessory) {\n return <span aria-hidden=\"true\">{startAccessory}</span>;\n }\n return null;\n };\n\n const renderEndContent = () => {\n if (finalEndIconName) {\n return (\n <Icon\n name={finalEndIconName}\n size={iconSize}\n className={twMerge(\n 'shrink-0 text-inherit',\n endIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...endIconProps}\n />\n );\n }\n if (endAccessory) {\n return <span aria-hidden=\"true\">{endAccessory}</span>;\n }\n return null;\n };\n\n const renderContent = () => renderLabel();\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center',\n getButtonBaseBorderRadiusTwClass(size),\n getButtonBaseHorizontalPaddingTwClasses(size, hasStart, hasEnd),\n hasAccessories && 'gap-x-1',\n 'font-medium text-default',\n 'bg-muted',\n 'overflow-hidden',\n // Add relative positioning for loading state\n 'relative',\n // Size\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],\n // Full width\n isFullWidth && 'w-full',\n // Animation classes - only applied when interactive\n isInteractive && [\n 'transition-all',\n 'duration-100',\n 'ease-linear',\n 'active:scale-[0.97]',\n 'active:ease-[cubic-bezier(0.3,0.8,0.3,1)]',\n ],\n // Disabled state - apply to both isDisabled and isLoading\n (isDisabled || isLoading) && 'cursor-not-allowed',\n isDisabled && 'opacity-50',\n // Custom classes\n className,\n );\n\n return (\n <Component\n ref={ref}\n className={mergedClassName}\n disabled={asChild ? undefined : (isDisabled ?? isLoading)}\n aria-disabled={isDisabled ? 'true' : undefined}\n aria-busy={isLoading ? 'true' : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n aria-pressed={ariaPressed}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-haspopup={ariaHaspopup}\n role={asChild ? undefined : 'button'}\n tabIndex={getTabIndex()}\n style={style}\n {...props}\n >\n {renderStartContent()}\n <Slottable>\n {isLoading ? renderLoadingState() : renderContent()}\n </Slottable>\n {renderEndContent()}\n </Component>\n );\n },\n);\n\nButtonBase.displayName = 'ButtonBase';\n"]}
|
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION = void 0;
|
|
3
|
+
exports.getButtonBaseHorizontalPaddingTwClasses = exports.getButtonBaseBorderRadiusTwClass = exports.MAP_BUTTONBASE_SIZE_TEXT_VARIANT = exports.MAP_BUTTONBASE_SIZE_ICONSIZE = exports.TWCLASSMAP_BUTTONBASE_BORDER_RADIUS = exports.TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION = void 0;
|
|
4
4
|
const design_system_shared_1 = require("@metamask-previews/design-system-shared");
|
|
5
5
|
exports.TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION = {
|
|
6
6
|
[design_system_shared_1.ButtonBaseSize.Sm]: 'h-8',
|
|
7
7
|
[design_system_shared_1.ButtonBaseSize.Md]: 'h-10',
|
|
8
8
|
[design_system_shared_1.ButtonBaseSize.Lg]: 'h-12', // size (48px).
|
|
9
9
|
};
|
|
10
|
+
exports.TWCLASSMAP_BUTTONBASE_BORDER_RADIUS = {
|
|
11
|
+
[design_system_shared_1.ButtonBaseSize.Sm]: 'rounded-lg',
|
|
12
|
+
[design_system_shared_1.ButtonBaseSize.Md]: 'rounded-xl',
|
|
13
|
+
[design_system_shared_1.ButtonBaseSize.Lg]: 'rounded-xl', // 12px.
|
|
14
|
+
};
|
|
15
|
+
exports.MAP_BUTTONBASE_SIZE_ICONSIZE = {
|
|
16
|
+
[design_system_shared_1.ButtonBaseSize.Sm]: design_system_shared_1.IconSize.Sm,
|
|
17
|
+
[design_system_shared_1.ButtonBaseSize.Md]: design_system_shared_1.IconSize.Sm,
|
|
18
|
+
[design_system_shared_1.ButtonBaseSize.Lg]: design_system_shared_1.IconSize.Md,
|
|
19
|
+
};
|
|
20
|
+
exports.MAP_BUTTONBASE_SIZE_TEXT_VARIANT = {
|
|
21
|
+
[design_system_shared_1.ButtonBaseSize.Sm]: design_system_shared_1.TextVariant.BodySm,
|
|
22
|
+
[design_system_shared_1.ButtonBaseSize.Md]: design_system_shared_1.TextVariant.BodyMd,
|
|
23
|
+
[design_system_shared_1.ButtonBaseSize.Lg]: design_system_shared_1.TextVariant.BodyMd,
|
|
24
|
+
};
|
|
25
|
+
const getButtonBaseBorderRadiusTwClass = (size) => exports.TWCLASSMAP_BUTTONBASE_BORDER_RADIUS[size];
|
|
26
|
+
exports.getButtonBaseBorderRadiusTwClass = getButtonBaseBorderRadiusTwClass;
|
|
27
|
+
const getButtonBaseHorizontalPaddingTwClasses = (buttonSize, hasStart, hasEnd) => {
|
|
28
|
+
if (buttonSize !== design_system_shared_1.ButtonBaseSize.Lg || (hasStart && hasEnd)) {
|
|
29
|
+
return 'px-3';
|
|
30
|
+
}
|
|
31
|
+
if (!hasStart && !hasEnd) {
|
|
32
|
+
return 'px-4';
|
|
33
|
+
}
|
|
34
|
+
if (hasStart) {
|
|
35
|
+
return 'pl-3 pr-4';
|
|
36
|
+
}
|
|
37
|
+
return 'pl-4 pr-3';
|
|
38
|
+
};
|
|
39
|
+
exports.getButtonBaseHorizontalPaddingTwClasses = getButtonBaseHorizontalPaddingTwClasses;
|
|
10
40
|
//# sourceMappingURL=ButtonBase.constants.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.constants.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ButtonBase.constants.cjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":";;;AAAA,kFAIiD;AAEpC,QAAA,oCAAoC,GAG7C;IACF,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,KAAK;IAC1B,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,MAAM;IAC3B,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,eAAe;CAC7C,CAAC;AAEW,QAAA,mCAAmC,GAG5C;IACF,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,YAAY;IACjC,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,YAAY;IACjC,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,YAAY,EAAE,QAAQ;CAC5C,CAAC;AAEW,QAAA,4BAA4B,GAAqC;IAC5E,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,+BAAQ,CAAC,EAAE;IAChC,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,+BAAQ,CAAC,EAAE;IAChC,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,+BAAQ,CAAC,EAAE;CACjC,CAAC;AAEW,QAAA,gCAAgC,GAGzC;IACF,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,kCAAW,CAAC,MAAM;IACvC,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,kCAAW,CAAC,MAAM;IACvC,CAAC,qCAAc,CAAC,EAAE,CAAC,EAAE,kCAAW,CAAC,MAAM;CACxC,CAAC;AAEK,MAAM,gCAAgC,GAAG,CAC9C,IAAoB,EACZ,EAAE,CAAC,2CAAmC,CAAC,IAAI,CAAC,CAAC;AAF1C,QAAA,gCAAgC,oCAEU;AAEhD,MAAM,uCAAuC,GAAG,CACrD,UAA0B,EAC1B,QAAiB,EACjB,MAAe,EACP,EAAE;IACV,IAAI,UAAU,KAAK,qCAAc,CAAC,EAAE,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,EAAE;QAC5D,OAAO,MAAM,CAAC;KACf;IACD,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE;QACxB,OAAO,MAAM,CAAC;KACf;IACD,IAAI,QAAQ,EAAE;QACZ,OAAO,WAAW,CAAC;KACpB;IACD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAfW,QAAA,uCAAuC,2CAelD","sourcesContent":["import {\n ButtonBaseSize,\n IconSize,\n TextVariant,\n} from '@metamask-previews/design-system-shared';\n\nexport const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION: Record<\n ButtonBaseSize,\n string\n> = {\n [ButtonBaseSize.Sm]: 'h-8', // size (32px).\n [ButtonBaseSize.Md]: 'h-10', // size (40px).\n [ButtonBaseSize.Lg]: 'h-12', // size (48px).\n};\n\nexport const TWCLASSMAP_BUTTONBASE_BORDER_RADIUS: Record<\n ButtonBaseSize,\n string\n> = {\n [ButtonBaseSize.Sm]: 'rounded-lg', // 8px.\n [ButtonBaseSize.Md]: 'rounded-xl', // 12px.\n [ButtonBaseSize.Lg]: 'rounded-xl', // 12px.\n};\n\nexport const MAP_BUTTONBASE_SIZE_ICONSIZE: Record<ButtonBaseSize, IconSize> = {\n [ButtonBaseSize.Sm]: IconSize.Sm,\n [ButtonBaseSize.Md]: IconSize.Sm,\n [ButtonBaseSize.Lg]: IconSize.Md,\n};\n\nexport const MAP_BUTTONBASE_SIZE_TEXT_VARIANT: Record<\n ButtonBaseSize,\n TextVariant\n> = {\n [ButtonBaseSize.Sm]: TextVariant.BodySm,\n [ButtonBaseSize.Md]: TextVariant.BodyMd,\n [ButtonBaseSize.Lg]: TextVariant.BodyMd,\n};\n\nexport const getButtonBaseBorderRadiusTwClass = (\n size: ButtonBaseSize,\n): string => TWCLASSMAP_BUTTONBASE_BORDER_RADIUS[size];\n\nexport const getButtonBaseHorizontalPaddingTwClasses = (\n buttonSize: ButtonBaseSize,\n hasStart: boolean,\n hasEnd: boolean,\n): string => {\n if (buttonSize !== ButtonBaseSize.Lg || (hasStart && hasEnd)) {\n return 'px-3';\n }\n if (!hasStart && !hasEnd) {\n return 'px-4';\n }\n if (hasStart) {\n return 'pl-3 pr-4';\n }\n return 'pl-4 pr-3';\n};\n"]}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import { ButtonBaseSize } from "@metamask-previews/design-system-shared";
|
|
1
|
+
import { ButtonBaseSize, IconSize, TextVariant } from "@metamask-previews/design-system-shared";
|
|
2
2
|
export declare const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION: Record<ButtonBaseSize, string>;
|
|
3
|
+
export declare const TWCLASSMAP_BUTTONBASE_BORDER_RADIUS: Record<ButtonBaseSize, string>;
|
|
4
|
+
export declare const MAP_BUTTONBASE_SIZE_ICONSIZE: Record<ButtonBaseSize, IconSize>;
|
|
5
|
+
export declare const MAP_BUTTONBASE_SIZE_TEXT_VARIANT: Record<ButtonBaseSize, TextVariant>;
|
|
6
|
+
export declare const getButtonBaseBorderRadiusTwClass: (size: ButtonBaseSize) => string;
|
|
7
|
+
export declare const getButtonBaseHorizontalPaddingTwClasses: (buttonSize: ButtonBaseSize, hasStart: boolean, hasEnd: boolean) => string;
|
|
3
8
|
//# sourceMappingURL=ButtonBase.constants.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.constants.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ButtonBase.constants.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,QAAQ,EACR,WAAW,EACZ,gDAAgD;AAEjD,eAAO,MAAM,oCAAoC,EAAE,MAAM,CACvD,cAAc,EACd,MAAM,CAKP,CAAC;AAEF,eAAO,MAAM,mCAAmC,EAAE,MAAM,CACtD,cAAc,EACd,MAAM,CAKP,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,cAAc,EAAE,QAAQ,CAIzE,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,MAAM,CACnD,cAAc,EACd,WAAW,CAKZ,CAAC;AAEF,eAAO,MAAM,gCAAgC,SACrC,cAAc,KACnB,MAAmD,CAAC;AAEvD,eAAO,MAAM,uCAAuC,eACtC,cAAc,YAChB,OAAO,UACT,OAAO,KACd,MAWF,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import { ButtonBaseSize } from "@metamask-previews/design-system-shared";
|
|
1
|
+
import { ButtonBaseSize, IconSize, TextVariant } from "@metamask-previews/design-system-shared";
|
|
2
2
|
export declare const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION: Record<ButtonBaseSize, string>;
|
|
3
|
+
export declare const TWCLASSMAP_BUTTONBASE_BORDER_RADIUS: Record<ButtonBaseSize, string>;
|
|
4
|
+
export declare const MAP_BUTTONBASE_SIZE_ICONSIZE: Record<ButtonBaseSize, IconSize>;
|
|
5
|
+
export declare const MAP_BUTTONBASE_SIZE_TEXT_VARIANT: Record<ButtonBaseSize, TextVariant>;
|
|
6
|
+
export declare const getButtonBaseBorderRadiusTwClass: (size: ButtonBaseSize) => string;
|
|
7
|
+
export declare const getButtonBaseHorizontalPaddingTwClasses: (buttonSize: ButtonBaseSize, hasStart: boolean, hasEnd: boolean) => string;
|
|
3
8
|
//# sourceMappingURL=ButtonBase.constants.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.constants.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ButtonBase.constants.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,QAAQ,EACR,WAAW,EACZ,gDAAgD;AAEjD,eAAO,MAAM,oCAAoC,EAAE,MAAM,CACvD,cAAc,EACd,MAAM,CAKP,CAAC;AAEF,eAAO,MAAM,mCAAmC,EAAE,MAAM,CACtD,cAAc,EACd,MAAM,CAKP,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,cAAc,EAAE,QAAQ,CAIzE,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,MAAM,CACnD,cAAc,EACd,WAAW,CAKZ,CAAC;AAEF,eAAO,MAAM,gCAAgC,SACrC,cAAc,KACnB,MAAmD,CAAC;AAEvD,eAAO,MAAM,uCAAuC,eACtC,cAAc,YAChB,OAAO,UACT,OAAO,KACd,MAWF,CAAC"}
|
|
@@ -1,7 +1,35 @@
|
|
|
1
|
-
import { ButtonBaseSize } from "@metamask-previews/design-system-shared";
|
|
1
|
+
import { ButtonBaseSize, IconSize, TextVariant } from "@metamask-previews/design-system-shared";
|
|
2
2
|
export const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION = {
|
|
3
3
|
[ButtonBaseSize.Sm]: 'h-8',
|
|
4
4
|
[ButtonBaseSize.Md]: 'h-10',
|
|
5
5
|
[ButtonBaseSize.Lg]: 'h-12', // size (48px).
|
|
6
6
|
};
|
|
7
|
+
export const TWCLASSMAP_BUTTONBASE_BORDER_RADIUS = {
|
|
8
|
+
[ButtonBaseSize.Sm]: 'rounded-lg',
|
|
9
|
+
[ButtonBaseSize.Md]: 'rounded-xl',
|
|
10
|
+
[ButtonBaseSize.Lg]: 'rounded-xl', // 12px.
|
|
11
|
+
};
|
|
12
|
+
export const MAP_BUTTONBASE_SIZE_ICONSIZE = {
|
|
13
|
+
[ButtonBaseSize.Sm]: IconSize.Sm,
|
|
14
|
+
[ButtonBaseSize.Md]: IconSize.Sm,
|
|
15
|
+
[ButtonBaseSize.Lg]: IconSize.Md,
|
|
16
|
+
};
|
|
17
|
+
export const MAP_BUTTONBASE_SIZE_TEXT_VARIANT = {
|
|
18
|
+
[ButtonBaseSize.Sm]: TextVariant.BodySm,
|
|
19
|
+
[ButtonBaseSize.Md]: TextVariant.BodyMd,
|
|
20
|
+
[ButtonBaseSize.Lg]: TextVariant.BodyMd,
|
|
21
|
+
};
|
|
22
|
+
export const getButtonBaseBorderRadiusTwClass = (size) => TWCLASSMAP_BUTTONBASE_BORDER_RADIUS[size];
|
|
23
|
+
export const getButtonBaseHorizontalPaddingTwClasses = (buttonSize, hasStart, hasEnd) => {
|
|
24
|
+
if (buttonSize !== ButtonBaseSize.Lg || (hasStart && hasEnd)) {
|
|
25
|
+
return 'px-3';
|
|
26
|
+
}
|
|
27
|
+
if (!hasStart && !hasEnd) {
|
|
28
|
+
return 'px-4';
|
|
29
|
+
}
|
|
30
|
+
if (hasStart) {
|
|
31
|
+
return 'pl-3 pr-4';
|
|
32
|
+
}
|
|
33
|
+
return 'pl-4 pr-3';
|
|
34
|
+
};
|
|
7
35
|
//# sourceMappingURL=ButtonBase.constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.constants.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ButtonBase.constants.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,QAAQ,EACR,WAAW,EACZ,gDAAgD;AAEjD,MAAM,CAAC,MAAM,oCAAoC,GAG7C;IACF,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,KAAK;IAC1B,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,MAAM;IAC3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Content":["import {\n ButtonBaseSize,\n IconSize,\n TextVariant,\n} from '@metamask-previews/design-system-shared';\n\nexport const TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION: Record<\n ButtonBaseSize,\n string\n> = {\n [ButtonBaseSize.Sm]: 'h-8', // size (32px).\n [ButtonBaseSize.Md]: 'h-10', // size (40px).\n [ButtonBaseSize.Lg]: 'h-12', // size (48px).\n};\n\nexport const TWCLASSMAP_BUTTONBASE_BORDER_RADIUS: Record<\n ButtonBaseSize,\n string\n> = {\n [ButtonBaseSize.Sm]: 'rounded-lg', // 8px.\n [ButtonBaseSize.Md]: 'rounded-xl', // 12px.\n [ButtonBaseSize.Lg]: 'rounded-xl', // 12px.\n};\n\nexport const MAP_BUTTONBASE_SIZE_ICONSIZE: Record<ButtonBaseSize, IconSize> = {\n [ButtonBaseSize.Sm]: IconSize.Sm,\n [ButtonBaseSize.Md]: IconSize.Sm,\n [ButtonBaseSize.Lg]: IconSize.Md,\n};\n\nexport const MAP_BUTTONBASE_SIZE_TEXT_VARIANT: Record<\n ButtonBaseSize,\n TextVariant\n> = {\n [ButtonBaseSize.Sm]: TextVariant.BodySm,\n [ButtonBaseSize.Md]: TextVariant.BodyMd,\n [ButtonBaseSize.Lg]: TextVariant.BodyMd,\n};\n\nexport const getButtonBaseBorderRadiusTwClass = (\n size: ButtonBaseSize,\n): string => TWCLASSMAP_BUTTONBASE_BORDER_RADIUS[size];\n\nexport const getButtonBaseHorizontalPaddingTwClasses = (\n buttonSize: ButtonBaseSize,\n hasStart: boolean,\n hasEnd: boolean,\n): string => {\n if (buttonSize !== ButtonBaseSize.Lg || (hasStart && hasEnd)) {\n return 'px-3';\n }\n if (!hasStart && !hasEnd) {\n return 'px-4';\n }\n if (hasStart) {\n return 'pl-3 pr-4';\n }\n return 'pl-4 pr-3';\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqB,cAAc;
|
|
1
|
+
{"version":3,"file":"ButtonBase.d.cts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqB,cAAc;AAa1C,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,wGA4MtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqB,cAAc;
|
|
1
|
+
{"version":3,"file":"ButtonBase.d.mts","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqB,cAAc;AAa1C,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,wGA4MtB,CAAC"}
|
|
@@ -9,12 +9,19 @@ import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
|
9
9
|
import $React, { forwardRef } from "react";
|
|
10
10
|
const React = $importDefault($React);
|
|
11
11
|
import { twMerge } from "../../utils/tw-merge.mjs";
|
|
12
|
-
import { Icon
|
|
12
|
+
import { Icon } from "../Icon/index.mjs";
|
|
13
13
|
import { Text, FontWeight, TextColor } from "../Text/index.mjs";
|
|
14
|
-
import { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from "./ButtonBase.constants.mjs";
|
|
14
|
+
import { MAP_BUTTONBASE_SIZE_ICONSIZE, MAP_BUTTONBASE_SIZE_TEXT_VARIANT, getButtonBaseBorderRadiusTwClass, getButtonBaseHorizontalPaddingTwClasses, TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from "./ButtonBase.constants.mjs";
|
|
15
15
|
export const ButtonBase = forwardRef(({ children, className, size = ButtonBaseSize.Lg, isFullWidth, asChild, isDisabled, isLoading, loadingText, loadingIconProps, loadingTextProps, startIconName, startIconProps, startAccessory, endIconName, endIconProps, endAccessory, textProps, style, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, 'aria-pressed': ariaPressed, 'aria-expanded': ariaExpanded, 'aria-controls': ariaControls, 'aria-haspopup': ariaHaspopup, ...props }, ref) => {
|
|
16
16
|
const Component = asChild ? Slot : 'button';
|
|
17
17
|
const isInteractive = !(isDisabled ?? isLoading);
|
|
18
|
+
const finalStartIconName = startIconName ?? startIconProps?.name;
|
|
19
|
+
const finalEndIconName = endIconName ?? endIconProps?.name;
|
|
20
|
+
const hasStart = Boolean(finalStartIconName || startAccessory);
|
|
21
|
+
const hasEnd = Boolean(finalEndIconName || endAccessory);
|
|
22
|
+
const hasAccessories = hasStart || hasEnd;
|
|
23
|
+
const iconSize = MAP_BUTTONBASE_SIZE_ICONSIZE[size];
|
|
24
|
+
const labelTextVariant = MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];
|
|
18
25
|
// Calculate tabIndex based on asChild and disabled state
|
|
19
26
|
const getTabIndex = () => {
|
|
20
27
|
if (asChild) {
|
|
@@ -22,41 +29,42 @@ export const ButtonBase = forwardRef(({ children, className, size = ButtonBaseSi
|
|
|
22
29
|
}
|
|
23
30
|
return isDisabled ? -1 : undefined;
|
|
24
31
|
};
|
|
32
|
+
const renderLabel = () => {
|
|
33
|
+
if (children && typeof children === 'string') {
|
|
34
|
+
return (React.createElement(Text, { variant: labelTextVariant, fontWeight: FontWeight.Medium, color: TextColor.Inherit, asChild: true, ...textProps },
|
|
35
|
+
React.createElement("span", null, children)));
|
|
36
|
+
}
|
|
37
|
+
return children;
|
|
38
|
+
};
|
|
25
39
|
const renderLoadingState = () => (React.createElement(React.Fragment, null,
|
|
26
|
-
React.createElement("span", { className: "absolute inline-flex items-center", "aria-hidden": "true" },
|
|
27
|
-
React.createElement(Icon, { name: IconName.Loading, size:
|
|
28
|
-
React.createElement(Text, { fontWeight: FontWeight.Medium, color: TextColor.Inherit, asChild: true, ...loadingTextProps },
|
|
40
|
+
React.createElement("span", { className: "absolute inline-flex items-center gap-x-1", "aria-hidden": "true" },
|
|
41
|
+
React.createElement(Icon, { name: IconName.Loading, size: iconSize, className: twMerge('animate-spin text-inherit', loadingIconProps?.className), ...loadingIconProps }),
|
|
42
|
+
React.createElement(Text, { variant: labelTextVariant, fontWeight: FontWeight.Medium, color: TextColor.Inherit, asChild: true, ...loadingTextProps },
|
|
29
43
|
React.createElement("span", null, loadingText))),
|
|
30
|
-
React.createElement("span", { className: "invisible inline-flex items-center" },
|
|
44
|
+
React.createElement("span", { className: "invisible inline-flex items-center", "aria-hidden": "true" }, renderLabel()),
|
|
31
45
|
React.createElement("span", { className: "sr-only", "aria-live": "polite", "aria-atomic": "true" }, loadingText || 'Loading')));
|
|
32
46
|
const renderStartContent = () => {
|
|
33
|
-
if (
|
|
34
|
-
return (React.createElement(Icon, { name:
|
|
47
|
+
if (finalStartIconName) {
|
|
48
|
+
return (React.createElement(Icon, { name: finalStartIconName, size: iconSize, className: twMerge('shrink-0 text-inherit', startIconProps?.className), "aria-hidden": "true", ...startIconProps }));
|
|
35
49
|
}
|
|
36
50
|
if (startAccessory) {
|
|
37
|
-
return
|
|
51
|
+
return React.createElement("span", { "aria-hidden": "true" }, startAccessory);
|
|
38
52
|
}
|
|
39
53
|
return null;
|
|
40
54
|
};
|
|
41
55
|
const renderEndContent = () => {
|
|
42
|
-
if (
|
|
43
|
-
return (React.createElement(Icon, { name:
|
|
56
|
+
if (finalEndIconName) {
|
|
57
|
+
return (React.createElement(Icon, { name: finalEndIconName, size: iconSize, className: twMerge('shrink-0 text-inherit', endIconProps?.className), "aria-hidden": "true", ...endIconProps }));
|
|
44
58
|
}
|
|
45
59
|
if (endAccessory) {
|
|
46
|
-
return
|
|
60
|
+
return React.createElement("span", { "aria-hidden": "true" }, endAccessory);
|
|
47
61
|
}
|
|
48
62
|
return null;
|
|
49
63
|
};
|
|
50
|
-
const renderContent = () =>
|
|
51
|
-
if (children && typeof children === 'string') {
|
|
52
|
-
return (React.createElement(Text, { fontWeight: FontWeight.Medium, color: TextColor.Inherit, asChild: true, ...textProps },
|
|
53
|
-
React.createElement("span", null, children)));
|
|
54
|
-
}
|
|
55
|
-
return children;
|
|
56
|
-
};
|
|
64
|
+
const renderContent = () => renderLabel();
|
|
57
65
|
const mergedClassName = twMerge(
|
|
58
66
|
// Base styles
|
|
59
|
-
'inline-flex items-center justify-center', '
|
|
67
|
+
'inline-flex items-center justify-center', getButtonBaseBorderRadiusTwClass(size), getButtonBaseHorizontalPaddingTwClasses(size, hasStart, hasEnd), hasAccessories && 'gap-x-1', 'font-medium text-default', 'bg-muted', 'overflow-hidden',
|
|
60
68
|
// Add relative positioning for loading state
|
|
61
69
|
'relative',
|
|
62
70
|
// Size
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonBase.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gDAAgD;AACnF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,6BAA6B;AACvD,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,0BAAgB;AACzC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,0BAAgB;AAEtD,OAAO,EAAE,oCAAoC,EAAE,mCAA+B;AAG9E,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,cAAc,CAAC,EAAE,EACxB,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EAC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IAC1B,6CAA6C;IAC7C,UAAU;IACV,OAAO;IACP,oCAAoC,CAAC,IAAI,CAAC;IAC1C,aAAa;IACb,WAAW,IAAI,QAAQ;IACvB,oDAAoD;IACpD,aAAa,IAAI;QACf,gBAAgB;QAChB,cAAc;QACd,aAAa;QACb,qBAAqB;QACrB,2CAA2C;KAC5C;IACD,0DAA0D;IAC1D,CAAC,UAAU,IAAI,SAAS,CAAC,IAAI,oBAAoB,EACjD,UAAU,IAAI,YAAY;IAC1B,iBAAiB;IACjB,SAAS,CACV,CAAC;IAEF,OAAO,CACL,oBAAC,SAAS,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,IAAI,SAAS,CAAC,mBAC1C,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,eACnC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,gBAC7B,SAAS,qBACJ,cAAc,sBACb,eAAe,kBACnB,WAAW,mBACV,YAAY,mBACZ,YAAY,mBACZ,YAAY,EAC3B,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACpC,QAAQ,EAAE,WAAW,EAAE,EACvB,KAAK,EAAE,KAAK,KACR,KAAK;QAER,kBAAkB,EAAE;QACrB,oBAAC,SAAS,QACP,SAAS,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CACzC;QACX,gBAAgB,EAAE,CACT,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import { ButtonBaseSize, IconName } from '@metamask-previews/design-system-shared';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon, IconSize } from '../Icon';\nimport { Text, FontWeight, TextColor } from '../Text';\n\nimport { TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION } from './ButtonBase.constants';\nimport type { ButtonBaseProps } from './ButtonBase.types';\n\nexport const ButtonBase = forwardRef<HTMLButtonElement, ButtonBaseProps>(\n (\n {\n children,\n className,\n size = ButtonBaseSize.Lg,\n isFullWidth,\n asChild,\n isDisabled,\n isLoading,\n loadingText,\n loadingIconProps,\n loadingTextProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n textProps,\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n 'aria-pressed': ariaPressed,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls,\n 'aria-haspopup': ariaHaspopup,\n ...props\n },\n ref,\n ) => {\n const Component = asChild ? Slot : 'button';\n const isInteractive = !(isDisabled ?? isLoading);\n\n // Calculate tabIndex based on asChild and disabled state\n const getTabIndex = () => {\n if (asChild) {\n return undefined;\n }\n return isDisabled ? -1 : undefined;\n };\n\n const renderLoadingState = () => (\n <>\n <span className=\"absolute inline-flex items-center\" aria-hidden=\"true\">\n <Icon\n name={IconName.Loading}\n size={IconSize.Sm}\n className={twMerge(\n 'mr-2 animate-spin text-inherit',\n loadingIconProps?.className,\n )}\n {...loadingIconProps}\n />\n <Text\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...loadingTextProps}\n >\n <span>{loadingText}</span>\n </Text>\n </span>\n <span className=\"invisible inline-flex items-center\">{children}</span>\n {/* Screen reader announcement for loading */}\n <span className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {loadingText || 'Loading'}\n </span>\n </>\n );\n\n const renderStartContent = () => {\n if (startIconName) {\n return (\n <Icon\n name={startIconName}\n size={IconSize.Sm}\n className={twMerge(\n 'mr-2 shrink-0 text-inherit',\n startIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...startIconProps}\n />\n );\n }\n if (startAccessory) {\n return (\n <span className=\"mr-2\" aria-hidden=\"true\">\n {startAccessory}\n </span>\n );\n }\n return null;\n };\n\n const renderEndContent = () => {\n if (endIconName) {\n return (\n <Icon\n name={endIconName}\n size={IconSize.Sm}\n className={twMerge(\n 'ml-2 shrink-0 text-inherit',\n endIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...endIconProps}\n />\n );\n }\n if (endAccessory) {\n return (\n <span className=\"ml-2\" aria-hidden=\"true\">\n {endAccessory}\n </span>\n );\n }\n return null;\n };\n\n const renderContent = () => {\n if (children && typeof children === 'string') {\n return (\n <Text\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...textProps}\n >\n <span>{children}</span>\n </Text>\n );\n }\n return children;\n };\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center',\n 'rounded-xl px-4',\n 'font-medium text-default',\n 'bg-muted',\n 'min-w-20 overflow-hidden',\n // Add relative positioning for loading state\n 'relative',\n // Size\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],\n // Full width\n isFullWidth && 'w-full',\n // Animation classes - only applied when interactive\n isInteractive && [\n 'transition-all',\n 'duration-100',\n 'ease-linear',\n 'active:scale-[0.97]',\n 'active:ease-[cubic-bezier(0.3,0.8,0.3,1)]',\n ],\n // Disabled state - apply to both isDisabled and isLoading\n (isDisabled || isLoading) && 'cursor-not-allowed',\n isDisabled && 'opacity-50',\n // Custom classes\n className,\n );\n\n return (\n <Component\n ref={ref}\n className={mergedClassName}\n disabled={asChild ? undefined : (isDisabled ?? isLoading)}\n aria-disabled={isDisabled ? 'true' : undefined}\n aria-busy={isLoading ? 'true' : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n aria-pressed={ariaPressed}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-haspopup={ariaHaspopup}\n role={asChild ? undefined : 'button'}\n tabIndex={getTabIndex()}\n style={style}\n {...props}\n >\n {renderStartContent()}\n <Slottable>\n {isLoading ? renderLoadingState() : renderContent()}\n </Slottable>\n {renderEndContent()}\n </Component>\n );\n },\n);\n\nButtonBase.displayName = 'ButtonBase';\n"]}
|
|
1
|
+
{"version":3,"file":"ButtonBase.mjs","sourceRoot":"","sources":["../../../src/components/ButtonBase/ButtonBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,gDAAgD;AACnF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,6BAA6B;AACvD,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAC/B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,0BAAgB;AAEtD,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,uCAAuC,EACvC,oCAAoC,EACrC,mCAA+B;AAGhC,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,QAAQ,EACR,SAAS,EACT,IAAI,GAAG,cAAc,CAAC,EAAE,EACxB,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,YAAY,EAC7B,eAAe,EAAE,YAAY,EAC7B,eAAe,EAAE,YAAY,EAC7B,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CA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AAgB,EAAE,CACT,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import { ButtonBaseSize, IconName } from '@metamask-previews/design-system-shared';\nimport { Slot, Slottable } from '@radix-ui/react-slot';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Icon } from '../Icon';\nimport { Text, FontWeight, TextColor } from '../Text';\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 = forwardRef<HTMLButtonElement, ButtonBaseProps>(\n (\n {\n children,\n className,\n size = ButtonBaseSize.Lg,\n isFullWidth,\n asChild,\n isDisabled,\n isLoading,\n loadingText,\n loadingIconProps,\n loadingTextProps,\n startIconName,\n startIconProps,\n startAccessory,\n endIconName,\n endIconProps,\n endAccessory,\n textProps,\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n 'aria-describedby': ariaDescribedby,\n 'aria-pressed': ariaPressed,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls,\n 'aria-haspopup': ariaHaspopup,\n ...props\n },\n ref,\n ) => {\n const Component = asChild ? Slot : 'button';\n const isInteractive = !(isDisabled ?? isLoading);\n\n const finalStartIconName = startIconName ?? startIconProps?.name;\n const finalEndIconName = endIconName ?? endIconProps?.name;\n const hasStart = Boolean(finalStartIconName || startAccessory);\n const hasEnd = Boolean(finalEndIconName || endAccessory);\n const hasAccessories = hasStart || hasEnd;\n const iconSize = MAP_BUTTONBASE_SIZE_ICONSIZE[size];\n const labelTextVariant = MAP_BUTTONBASE_SIZE_TEXT_VARIANT[size];\n\n // Calculate tabIndex based on asChild and disabled state\n const getTabIndex = () => {\n if (asChild) {\n return undefined;\n }\n return isDisabled ? -1 : undefined;\n };\n\n const renderLabel = () => {\n if (children && typeof children === 'string') {\n return (\n <Text\n variant={labelTextVariant}\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...textProps}\n >\n <span>{children}</span>\n </Text>\n );\n }\n return children;\n };\n\n const renderLoadingState = () => (\n <>\n <span\n className=\"absolute inline-flex items-center gap-x-1\"\n aria-hidden=\"true\"\n >\n <Icon\n name={IconName.Loading}\n size={iconSize}\n className={twMerge(\n 'animate-spin text-inherit',\n loadingIconProps?.className,\n )}\n {...loadingIconProps}\n />\n <Text\n variant={labelTextVariant}\n fontWeight={FontWeight.Medium}\n color={TextColor.Inherit}\n asChild\n {...loadingTextProps}\n >\n <span>{loadingText}</span>\n </Text>\n </span>\n <span className=\"invisible inline-flex items-center\" aria-hidden=\"true\">\n {renderLabel()}\n </span>\n {/* Screen reader announcement for loading */}\n <span className=\"sr-only\" aria-live=\"polite\" aria-atomic=\"true\">\n {loadingText || 'Loading'}\n </span>\n </>\n );\n\n const renderStartContent = () => {\n if (finalStartIconName) {\n return (\n <Icon\n name={finalStartIconName}\n size={iconSize}\n className={twMerge(\n 'shrink-0 text-inherit',\n startIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...startIconProps}\n />\n );\n }\n if (startAccessory) {\n return <span aria-hidden=\"true\">{startAccessory}</span>;\n }\n return null;\n };\n\n const renderEndContent = () => {\n if (finalEndIconName) {\n return (\n <Icon\n name={finalEndIconName}\n size={iconSize}\n className={twMerge(\n 'shrink-0 text-inherit',\n endIconProps?.className,\n )}\n aria-hidden=\"true\"\n {...endIconProps}\n />\n );\n }\n if (endAccessory) {\n return <span aria-hidden=\"true\">{endAccessory}</span>;\n }\n return null;\n };\n\n const renderContent = () => renderLabel();\n\n const mergedClassName = twMerge(\n // Base styles\n 'inline-flex items-center justify-center',\n getButtonBaseBorderRadiusTwClass(size),\n getButtonBaseHorizontalPaddingTwClasses(size, hasStart, hasEnd),\n hasAccessories && 'gap-x-1',\n 'font-medium text-default',\n 'bg-muted',\n 'overflow-hidden',\n // Add relative positioning for loading state\n 'relative',\n // Size\n TWCLASSMAP_BUTTONBASE_SIZE_DIMENSION[size],\n // Full width\n isFullWidth && 'w-full',\n // Animation classes - only applied when interactive\n isInteractive && [\n 'transition-all',\n 'duration-100',\n 'ease-linear',\n 'active:scale-[0.97]',\n 'active:ease-[cubic-bezier(0.3,0.8,0.3,1)]',\n ],\n // Disabled state - apply to both isDisabled and isLoading\n (isDisabled || isLoading) && 'cursor-not-allowed',\n isDisabled && 'opacity-50',\n // Custom classes\n className,\n );\n\n return (\n <Component\n ref={ref}\n className={mergedClassName}\n disabled={asChild ? undefined : (isDisabled ?? isLoading)}\n aria-disabled={isDisabled ? 'true' : undefined}\n aria-busy={isLoading ? 'true' : undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n aria-pressed={ariaPressed}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-haspopup={ariaHaspopup}\n role={asChild ? undefined : 'button'}\n tabIndex={getTabIndex()}\n style={style}\n {...props}\n >\n {renderStartContent()}\n <Slottable>\n {isLoading ? renderLoadingState() : renderContent()}\n </Slottable>\n {renderEndContent()}\n </Component>\n );\n },\n);\n\nButtonBase.displayName = 'ButtonBase';\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.HeaderBase = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const tw_merge_1 = require("../../utils/tw-merge.cjs");
|
|
29
|
+
const Box_1 = require("../Box/index.cjs");
|
|
30
|
+
exports.HeaderBase = (0, react_1.forwardRef)(({ startAccessory, endAccessory, className, children, childrenWrapperProps, startAccessoryWrapperProps, endAccessoryWrapperProps, ...props }, ref) => (react_1.default.createElement("div", { ref: ref, className: (0, tw_merge_1.twMerge)(
|
|
31
|
+
// Three-column grid keeps the title horizontally centered: side
|
|
32
|
+
// columns each take an equal share of the remaining space, the title
|
|
33
|
+
// sits in the auto-sized center column. No JS measurement needed.
|
|
34
|
+
'grid grid-cols-[1fr_auto_1fr] items-center', className), ...props },
|
|
35
|
+
startAccessory && (react_1.default.createElement(Box_1.Box, { ...startAccessoryWrapperProps, className: (0, tw_merge_1.twMerge)('col-start-1 justify-self-start', startAccessoryWrapperProps?.className) }, startAccessory)),
|
|
36
|
+
children && (react_1.default.createElement(Box_1.Box, { ...childrenWrapperProps, className: (0, tw_merge_1.twMerge)(
|
|
37
|
+
// Always pin the title to column 2 so missing side accessories
|
|
38
|
+
// leave their empty `1fr` track in place and keep the title
|
|
39
|
+
// visually centered.
|
|
40
|
+
'col-start-2 col-end-3', childrenWrapperProps?.className) }, children)),
|
|
41
|
+
endAccessory && (react_1.default.createElement(Box_1.Box, { ...endAccessoryWrapperProps, className: (0, tw_merge_1.twMerge)('col-start-3 justify-self-end', endAccessoryWrapperProps?.className) }, endAccessory)))));
|
|
42
|
+
exports.HeaderBase.displayName = 'HeaderBase';
|
|
43
|
+
//# sourceMappingURL=HeaderBase.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeaderBase.cjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAE1C,uDAA+C;AAC/C,0CAA6B;AAIhB,QAAA,UAAU,GAAG,IAAA,kBAAU,EAClC,CACE,EACE,cAAc,EACd,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE,CAAC,CACH,uCACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAA,kBAAO;IAChB,gEAAgE;IAChE,qEAAqE;IACrE,kEAAkE;IAClE,4CAA4C,EAC5C,SAAS,CACV,KACG,KAAK;IAER,cAAc,IAAI,CACjB,8BAAC,SAAG,OACE,0BAA0B,EAC9B,SAAS,EAAE,IAAA,kBAAO,EAChB,gCAAgC,EAChC,0BAA0B,EAAE,SAAS,CACtC,IAEA,cAAc,CACX,CACP;IACA,QAAQ,IAAI,CACX,8BAAC,SAAG,OACE,oBAAoB,EACxB,SAAS,EAAE,IAAA,kBAAO;QAChB,+DAA+D;QAC/D,4DAA4D;QAC5D,qBAAqB;QACrB,uBAAuB,EACvB,oBAAoB,EAAE,SAAS,CAChC,IAEA,QAAQ,CACL,CACP;IACA,YAAY,IAAI,CACf,8BAAC,SAAG,OACE,wBAAwB,EAC5B,SAAS,EAAE,IAAA,kBAAO,EAChB,8BAA8B,EAC9B,wBAAwB,EAAE,SAAS,CACpC,IAEA,YAAY,CACT,CACP,CACG,CACP,CACF,CAAC;AAEF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Box } from '../Box';\n\nimport type { HeaderBaseProps } from './HeaderBase.types';\n\nexport const HeaderBase = forwardRef<HTMLDivElement, HeaderBaseProps>(\n (\n {\n startAccessory,\n endAccessory,\n className,\n children,\n childrenWrapperProps,\n startAccessoryWrapperProps,\n endAccessoryWrapperProps,\n ...props\n },\n ref,\n ) => (\n <div\n ref={ref}\n className={twMerge(\n // Three-column grid keeps the title horizontally centered: side\n // columns each take an equal share of the remaining space, the title\n // sits in the auto-sized center column. No JS measurement needed.\n 'grid grid-cols-[1fr_auto_1fr] items-center',\n className,\n )}\n {...props}\n >\n {startAccessory && (\n <Box\n {...startAccessoryWrapperProps}\n className={twMerge(\n 'col-start-1 justify-self-start',\n startAccessoryWrapperProps?.className,\n )}\n >\n {startAccessory}\n </Box>\n )}\n {children && (\n <Box\n {...childrenWrapperProps}\n className={twMerge(\n // Always pin the title to column 2 so missing side accessories\n // leave their empty `1fr` track in place and keep the title\n // visually centered.\n 'col-start-2 col-end-3',\n childrenWrapperProps?.className,\n )}\n >\n {children}\n </Box>\n )}\n {endAccessory && (\n <Box\n {...endAccessoryWrapperProps}\n className={twMerge(\n 'col-start-3 justify-self-end',\n endAccessoryWrapperProps?.className,\n )}\n >\n {endAccessory}\n </Box>\n )}\n </div>\n ),\n);\n\nHeaderBase.displayName = 'HeaderBase';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeaderBase.d.cts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,cAAc;AAK1C,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,qGA+DtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeaderBase.d.mts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,cAAc;AAK1C,OAAO,KAAK,EAAE,eAAe,EAAE,+BAA2B;AAE1D,eAAO,MAAM,UAAU,qGA+DtB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function $importDefault(module) {
|
|
2
|
+
if (module?.__esModule) {
|
|
3
|
+
return module.default;
|
|
4
|
+
}
|
|
5
|
+
return module;
|
|
6
|
+
}
|
|
7
|
+
import $React, { forwardRef } from "react";
|
|
8
|
+
const React = $importDefault($React);
|
|
9
|
+
import { twMerge } from "../../utils/tw-merge.mjs";
|
|
10
|
+
import { Box } from "../Box/index.mjs";
|
|
11
|
+
export const HeaderBase = forwardRef(({ startAccessory, endAccessory, className, children, childrenWrapperProps, startAccessoryWrapperProps, endAccessoryWrapperProps, ...props }, ref) => (React.createElement("div", { ref: ref, className: twMerge(
|
|
12
|
+
// Three-column grid keeps the title horizontally centered: side
|
|
13
|
+
// columns each take an equal share of the remaining space, the title
|
|
14
|
+
// sits in the auto-sized center column. No JS measurement needed.
|
|
15
|
+
'grid grid-cols-[1fr_auto_1fr] items-center', className), ...props },
|
|
16
|
+
startAccessory && (React.createElement(Box, { ...startAccessoryWrapperProps, className: twMerge('col-start-1 justify-self-start', startAccessoryWrapperProps?.className) }, startAccessory)),
|
|
17
|
+
children && (React.createElement(Box, { ...childrenWrapperProps, className: twMerge(
|
|
18
|
+
// Always pin the title to column 2 so missing side accessories
|
|
19
|
+
// leave their empty `1fr` track in place and keep the title
|
|
20
|
+
// visually centered.
|
|
21
|
+
'col-start-2 col-end-3', childrenWrapperProps?.className) }, children)),
|
|
22
|
+
endAccessory && (React.createElement(Box, { ...endAccessoryWrapperProps, className: twMerge('col-start-3 justify-self-end', endAccessoryWrapperProps?.className) }, endAccessory)))));
|
|
23
|
+
HeaderBase.displayName = 'HeaderBase';
|
|
24
|
+
//# sourceMappingURL=HeaderBase.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeaderBase.mjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EAAE,GAAG,EAAE,yBAAe;AAI7B,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,cAAc,EACd,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE,CAAC,CACH,6BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,OAAO;IAChB,gEAAgE;IAChE,qEAAqE;IACrE,kEAAkE;IAClE,4CAA4C,EAC5C,SAAS,CACV,KACG,KAAK;IAER,cAAc,IAAI,CACjB,oBAAC,GAAG,OACE,0BAA0B,EAC9B,SAAS,EAAE,OAAO,CAChB,gCAAgC,EAChC,0BAA0B,EAAE,SAAS,CACtC,IAEA,cAAc,CACX,CACP;IACA,QAAQ,IAAI,CACX,oBAAC,GAAG,OACE,oBAAoB,EACxB,SAAS,EAAE,OAAO;QAChB,+DAA+D;QAC/D,4DAA4D;QAC5D,qBAAqB;QACrB,uBAAuB,EACvB,oBAAoB,EAAE,SAAS,CAChC,IAEA,QAAQ,CACL,CACP;IACA,YAAY,IAAI,CACf,oBAAC,GAAG,OACE,wBAAwB,EAC5B,SAAS,EAAE,OAAO,CAChB,8BAA8B,EAC9B,wBAAwB,EAAE,SAAS,CACpC,IAEA,YAAY,CACT,CACP,CACG,CACP,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC","sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { Box } from '../Box';\n\nimport type { HeaderBaseProps } from './HeaderBase.types';\n\nexport const HeaderBase = forwardRef<HTMLDivElement, HeaderBaseProps>(\n (\n {\n startAccessory,\n endAccessory,\n className,\n children,\n childrenWrapperProps,\n startAccessoryWrapperProps,\n endAccessoryWrapperProps,\n ...props\n },\n ref,\n ) => (\n <div\n ref={ref}\n className={twMerge(\n // Three-column grid keeps the title horizontally centered: side\n // columns each take an equal share of the remaining space, the title\n // sits in the auto-sized center column. No JS measurement needed.\n 'grid grid-cols-[1fr_auto_1fr] items-center',\n className,\n )}\n {...props}\n >\n {startAccessory && (\n <Box\n {...startAccessoryWrapperProps}\n className={twMerge(\n 'col-start-1 justify-self-start',\n startAccessoryWrapperProps?.className,\n )}\n >\n {startAccessory}\n </Box>\n )}\n {children && (\n <Box\n {...childrenWrapperProps}\n className={twMerge(\n // Always pin the title to column 2 so missing side accessories\n // leave their empty `1fr` track in place and keep the title\n // visually centered.\n 'col-start-2 col-end-3',\n childrenWrapperProps?.className,\n )}\n >\n {children}\n </Box>\n )}\n {endAccessory && (\n <Box\n {...endAccessoryWrapperProps}\n className={twMerge(\n 'col-start-3 justify-self-end',\n endAccessoryWrapperProps?.className,\n )}\n >\n {endAccessory}\n </Box>\n )}\n </div>\n ),\n);\n\nHeaderBase.displayName = 'HeaderBase';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeaderBase.types.cjs","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport type { BoxProps } from '../Box';\n\n/**\n * Box prop bag for the three internal slot wrappers (start accessory, title,\n * end accessory). Mirrors the legacy `BoxProps<'div'>` typing but is bound to\n * the MMDS `BoxProps` shape and carries an explicit `data-*` index signature\n * so consumers can pass test ids and other dataset attributes through\n * `Partial`/`Omit` indirection.\n */\ntype SlotWrapperProps = Omit<BoxProps, 'children' | 'asChild'> & {\n [key: `data-${string}`]: string | undefined;\n};\n\nexport type HeaderBaseProps = Omit<ComponentProps<'div'>, 'children'> & {\n /**\n * Title content rendered in the centered column. The title stays\n * horizontally centered regardless of the side accessories' widths\n * (CSS Grid handles the equal-sidebar layout — no JS measurement needed).\n */\n children?: ReactNode;\n /**\n * Props forwarded to the `Box` wrapping `children`. Use this to add\n * `data-testid`, override layout, or apply Tailwind utilities via\n * `className`.\n */\n childrenWrapperProps?: SlotWrapperProps;\n /**\n * Content rendered in the start (left in LTR) column. Typically a back\n * `ButtonIcon` or similar leading affordance.\n */\n startAccessory?: ReactNode;\n /**\n * Props forwarded to the `Box` wrapping `startAccessory`.\n */\n startAccessoryWrapperProps?: SlotWrapperProps;\n /**\n * Content rendered in the end (right in LTR) column. Typically a close\n * `ButtonIcon` or similar trailing affordance.\n */\n endAccessory?: ReactNode;\n /**\n * Props forwarded to the `Box` wrapping `endAccessory`.\n */\n endAccessoryWrapperProps?: SlotWrapperProps;\n /**\n * Optional prop for additional CSS classes to be applied to the HeaderBase\n * root. Merged with the component's defaults via `twMerge`.\n */\n className?: string;\n};\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import type { BoxProps } from "../Box/index.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Box prop bag for the three internal slot wrappers (start accessory, title,
|
|
5
|
+
* end accessory). Mirrors the legacy `BoxProps<'div'>` typing but is bound to
|
|
6
|
+
* the MMDS `BoxProps` shape and carries an explicit `data-*` index signature
|
|
7
|
+
* so consumers can pass test ids and other dataset attributes through
|
|
8
|
+
* `Partial`/`Omit` indirection.
|
|
9
|
+
*/
|
|
10
|
+
type SlotWrapperProps = Omit<BoxProps, 'children' | 'asChild'> & {
|
|
11
|
+
[key: `data-${string}`]: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
export type HeaderBaseProps = Omit<ComponentProps<'div'>, 'children'> & {
|
|
14
|
+
/**
|
|
15
|
+
* Title content rendered in the centered column. The title stays
|
|
16
|
+
* horizontally centered regardless of the side accessories' widths
|
|
17
|
+
* (CSS Grid handles the equal-sidebar layout — no JS measurement needed).
|
|
18
|
+
*/
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Props forwarded to the `Box` wrapping `children`. Use this to add
|
|
22
|
+
* `data-testid`, override layout, or apply Tailwind utilities via
|
|
23
|
+
* `className`.
|
|
24
|
+
*/
|
|
25
|
+
childrenWrapperProps?: SlotWrapperProps;
|
|
26
|
+
/**
|
|
27
|
+
* Content rendered in the start (left in LTR) column. Typically a back
|
|
28
|
+
* `ButtonIcon` or similar leading affordance.
|
|
29
|
+
*/
|
|
30
|
+
startAccessory?: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* Props forwarded to the `Box` wrapping `startAccessory`.
|
|
33
|
+
*/
|
|
34
|
+
startAccessoryWrapperProps?: SlotWrapperProps;
|
|
35
|
+
/**
|
|
36
|
+
* Content rendered in the end (right in LTR) column. Typically a close
|
|
37
|
+
* `ButtonIcon` or similar trailing affordance.
|
|
38
|
+
*/
|
|
39
|
+
endAccessory?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Props forwarded to the `Box` wrapping `endAccessory`.
|
|
42
|
+
*/
|
|
43
|
+
endAccessoryWrapperProps?: SlotWrapperProps;
|
|
44
|
+
/**
|
|
45
|
+
* Optional prop for additional CSS classes to be applied to the HeaderBase
|
|
46
|
+
* root. Merged with the component's defaults via `twMerge`.
|
|
47
|
+
*/
|
|
48
|
+
className?: string;
|
|
49
|
+
};
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=HeaderBase.types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeaderBase.types.d.cts","sourceRoot":"","sources":["../../../src/components/HeaderBase/HeaderBase.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAe;AAEvC;;;;;;GAMG;AACH,KAAK,gBAAgB,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG;IAC/D,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG;IACtE;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,gBAAgB,CAAC;IACxC;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;OAEG;IACH,0BAA0B,CAAC,EAAE,gBAAgB,CAAC;IAC9C;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;OAEG;IACH,wBAAwB,CAAC,EAAE,gBAAgB,CAAC;IAC5C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|