@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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode, RefObject } from "react";
|
|
2
|
+
import type { FocusableElement } from "../ModalFocus/ModalFocus.types.mjs";
|
|
3
|
+
export type ModalProps = Omit<ComponentProps<'div'>, 'children'> & {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the modal is open. When `false`, nothing is rendered (and the
|
|
6
|
+
* portal subtree is unmounted, releasing focus state).
|
|
7
|
+
*/
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Fired when the modal requests close — wire your state setter here.
|
|
11
|
+
* Triggered by the configured close-on-overlay-click and close-on-escape
|
|
12
|
+
* behaviors as well as any custom close affordances inside `children`.
|
|
13
|
+
*/
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* The modal subtree. Typically composed of `ModalOverlay` and
|
|
17
|
+
* `ModalContent` (which read shared behavior via `useModalContext`).
|
|
18
|
+
*/
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Optional prop for additional CSS classes to be applied to the Modal root.
|
|
22
|
+
* Merged with the component's defaults via `twMerge`.
|
|
23
|
+
*/
|
|
24
|
+
className?: string;
|
|
25
|
+
/**
|
|
26
|
+
* When `true`, clicking the overlay (outside the modal content) closes the
|
|
27
|
+
* modal.
|
|
28
|
+
*
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
isClosedOnOutsideClick?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* When `true`, pressing Escape closes the modal. When `false`, ensure the
|
|
34
|
+
* modal exposes a visible/keyboard-reachable close affordance for
|
|
35
|
+
* keyboard-only users.
|
|
36
|
+
*
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
isClosedOnEscapeKey?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* When `true`, the first focusable element within the modal subtree is
|
|
42
|
+
* focused on mount.
|
|
43
|
+
*
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
autoFocus?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The element to receive focus when the modal opens. Overrides `autoFocus`'s
|
|
49
|
+
* "first focusable" behavior.
|
|
50
|
+
*/
|
|
51
|
+
initialFocusRef?: RefObject<FocusableElement>;
|
|
52
|
+
/**
|
|
53
|
+
* The element to receive focus when the modal closes/unmounts.
|
|
54
|
+
*/
|
|
55
|
+
finalFocusRef?: RefObject<FocusableElement>;
|
|
56
|
+
/**
|
|
57
|
+
* When `true`, focus is restored to the element that opened the modal once
|
|
58
|
+
* the modal closes. Ignored when `finalFocusRef` is provided.
|
|
59
|
+
*
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
restoreFocus?: boolean;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=Modal.types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.types.d.mts","sourceRoot":"","sources":["../../../src/components/Modal/Modal.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,2CAAuC;AAEvE,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG;IACjE;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC9C;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC5C;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.types.mjs","sourceRoot":"","sources":["../../../src/components/Modal/Modal.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ReactNode, RefObject } from 'react';\n\nimport type { FocusableElement } from '../ModalFocus/ModalFocus.types';\n\nexport type ModalProps = Omit<ComponentProps<'div'>, 'children'> & {\n /**\n * Whether the modal is open. When `false`, nothing is rendered (and the\n * portal subtree is unmounted, releasing focus state).\n */\n isOpen: boolean;\n /**\n * Fired when the modal requests close — wire your state setter here.\n * Triggered by the configured close-on-overlay-click and close-on-escape\n * behaviors as well as any custom close affordances inside `children`.\n */\n onClose: () => void;\n /**\n * The modal subtree. Typically composed of `ModalOverlay` and\n * `ModalContent` (which read shared behavior via `useModalContext`).\n */\n children: ReactNode;\n /**\n * Optional prop for additional CSS classes to be applied to the Modal root.\n * Merged with the component's defaults via `twMerge`.\n */\n className?: string;\n /**\n * When `true`, clicking the overlay (outside the modal content) closes the\n * modal.\n *\n * @default true\n */\n isClosedOnOutsideClick?: boolean;\n /**\n * When `true`, pressing Escape closes the modal. When `false`, ensure the\n * modal exposes a visible/keyboard-reachable close affordance for\n * keyboard-only users.\n *\n * @default true\n */\n isClosedOnEscapeKey?: boolean;\n /**\n * When `true`, the first focusable element within the modal subtree is\n * focused on mount.\n *\n * @default true\n */\n autoFocus?: boolean;\n /**\n * The element to receive focus when the modal opens. Overrides `autoFocus`'s\n * \"first focusable\" behavior.\n */\n initialFocusRef?: RefObject<FocusableElement>;\n /**\n * The element to receive focus when the modal closes/unmounts.\n */\n finalFocusRef?: RefObject<FocusableElement>;\n /**\n * When `true`, focus is restored to the element that opened the modal once\n * the modal closes. Ignored when `finalFocusRef` is provided.\n *\n * @default false\n */\n restoreFocus?: boolean;\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useModalContext = exports.Modal = void 0;
|
|
4
|
+
var Modal_1 = require("./Modal.cjs");
|
|
5
|
+
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return Modal_1.Modal; } });
|
|
6
|
+
var Modal_context_1 = require("./Modal.context.cjs");
|
|
7
|
+
Object.defineProperty(exports, "useModalContext", { enumerable: true, get: function () { return Modal_context_1.useModalContext; } });
|
|
8
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/Modal/index.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,qDAAkD;AAAzC,gHAAA,eAAe,OAAA","sourcesContent":["export { Modal } from './Modal';\nexport { useModalContext } from './Modal.context';\nexport type { ModalContextType } from './Modal.context';\nexport type { ModalProps } from './Modal.types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,eAAe,EAAE,4BAAwB;AAClD,YAAY,EAAE,gBAAgB,EAAE,4BAAwB;AACxD,YAAY,EAAE,UAAU,EAAE,0BAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/Modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,eAAe,EAAE,4BAAwB;AAClD,YAAY,EAAE,gBAAgB,EAAE,4BAAwB;AACxD,YAAY,EAAE,UAAU,EAAE,0BAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/Modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAgB;AAChC,OAAO,EAAE,eAAe,EAAE,4BAAwB","sourcesContent":["export { Modal } from './Modal';\nexport { useModalContext } from './Modal.context';\nexport type { ModalContextType } from './Modal.context';\nexport type { ModalProps } from './Modal.types';\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
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.ModalContent = 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
|
+
const Modal_1 = require("../Modal/index.cjs");
|
|
31
|
+
const ModalFocus_1 = require("../ModalFocus/index.cjs");
|
|
32
|
+
const ModalContent_constants_1 = require("./ModalContent.constants.cjs");
|
|
33
|
+
const ModalContent_types_1 = require("./ModalContent.types.cjs");
|
|
34
|
+
exports.ModalContent = (0, react_1.forwardRef)(({ className, children, size = ModalContent_types_1.ModalContentSize.Sm, modalDialogProps, ...props }, ref) => {
|
|
35
|
+
const { onClose, isClosedOnEscapeKey, isClosedOnOutsideClick, initialFocusRef, finalFocusRef, restoreFocus, autoFocus, } = (0, Modal_1.useModalContext)();
|
|
36
|
+
const modalDialogRef = (0, react_1.useRef)(null);
|
|
37
|
+
(0, react_1.useEffect)(() => {
|
|
38
|
+
const handleEscKey = (event) => {
|
|
39
|
+
if (isClosedOnEscapeKey && event.key === 'Escape') {
|
|
40
|
+
onClose();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const handleClickOutside = (event) => {
|
|
44
|
+
if (!isClosedOnOutsideClick) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const target = event.target;
|
|
48
|
+
// Floating UI primitives (Popover, Tooltip, Select dropdown, etc.)
|
|
49
|
+
// that portal alongside the Modal but are part of the modal
|
|
50
|
+
// interaction can opt out of the outside-click handler by setting
|
|
51
|
+
// `data-mm-modal-ignore-outside-click` on their root element.
|
|
52
|
+
if (target?.closest(`[${ModalContent_constants_1.MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR}]`)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (modalDialogRef.current &&
|
|
56
|
+
!modalDialogRef.current.contains(target)) {
|
|
57
|
+
onClose();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
document.addEventListener('keydown', handleEscKey);
|
|
61
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
62
|
+
return () => {
|
|
63
|
+
document.removeEventListener('keydown', handleEscKey);
|
|
64
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
65
|
+
};
|
|
66
|
+
}, [isClosedOnEscapeKey, isClosedOnOutsideClick, onClose]);
|
|
67
|
+
return (react_1.default.createElement(ModalFocus_1.ModalFocus, { initialFocusRef: initialFocusRef, finalFocusRef: finalFocusRef, restoreFocus: restoreFocus, autoFocus: autoFocus },
|
|
68
|
+
react_1.default.createElement("div", { ref: ref, className: (0, tw_merge_1.twMerge)('fixed inset-0 z-[1050] flex items-start justify-center p-4 sm:py-8 md:py-12', '[@media(max-height:475px)]:p-2', className), ...props },
|
|
69
|
+
react_1.default.createElement(Box_1.Box, { ref: modalDialogRef, asChild: true, backgroundColor: Box_1.BoxBackgroundColor.BackgroundDefault, justifyContent: Box_1.BoxJustifyContent.Start, alignItems: Box_1.BoxAlignItems.Stretch, flexDirection: Box_1.BoxFlexDirection.Column, paddingTop: 4, paddingBottom: 4, ...modalDialogProps, className: (0, tw_merge_1.twMerge)('flex max-h-full w-full rounded-lg shadow-lg motion-safe:animate-slide-up', ModalContent_constants_1.TWCLASSMAP_MODAL_CONTENT_SIZE[size], modalDialogProps?.className) },
|
|
70
|
+
react_1.default.createElement("section", { role: "dialog", "aria-modal": "true" }, children)))));
|
|
71
|
+
});
|
|
72
|
+
exports.ModalContent.displayName = 'ModalContent';
|
|
73
|
+
//# sourceMappingURL=ModalContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.cjs","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA6D;AAE7D,uDAA+C;AAC/C,0CAMgB;AAChB,8CAA2C;AAC3C,wDAA2C;AAE3C,yEAGkC;AAElC,iEAAwD;AAE3C,QAAA,YAAY,GAAG,IAAA,kBAAU,EACpC,CACE,EACE,SAAS,EACT,QAAQ,EACR,IAAI,GAAG,qCAAgB,CAAC,EAAE,EAC1B,gBAAgB,EAChB,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,EACJ,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,SAAS,GACV,GAAG,IAAA,uBAAe,GAAE,CAAC;IACtB,MAAM,cAAc,GAAG,IAAA,cAAM,EAAc,IAAI,CAAC,CAAC;IAEjD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC5C,IAAI,mBAAmB,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;gBACjD,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC;QACF,MAAM,kBAAkB,GAAG,CAAC,KAAiB,EAAE,EAAE;YAC/C,IAAI,CAAC,sBAAsB,EAAE;gBAC3B,OAAO;aACR;YACD,MAAM,MAAM,GAAG,KAAK,CAAC,MAA4B,CAAC;YAClD,mEAAmE;YACnE,4DAA4D;YAC5D,kEAAkE;YAClE,8DAA8D;YAC9D,IAAI,MAAM,EAAE,OAAO,CAAC,IAAI,gEAAuC,GAAG,CAAC,EAAE;gBACnE,OAAO;aACR;YACD,IACE,cAAc,CAAC,OAAO;gBACtB,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAc,CAAC,EAChD;gBACA,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC;QAEF,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACnD,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QAE3D,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;YACtD,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QAChE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3D,OAAO,CACL,8BAAC,uBAAU,IACT,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS;QAEpB,uCACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,IAAA,kBAAO,EAChB,6EAA6E,EAC7E,gCAAgC,EAChC,SAAS,CACV,KACG,KAAK;YAET,8BAAC,SAAG,IACF,GAAG,EAAE,cAA2C,EAChD,OAAO,QACP,eAAe,EAAE,wBAAkB,CAAC,iBAAiB,EACrD,cAAc,EAAE,uBAAiB,CAAC,KAAK,EACvC,UAAU,EAAE,mBAAa,CAAC,OAAO,EACjC,aAAa,EAAE,sBAAgB,CAAC,MAAM,EACtC,UAAU,EAAE,CAAC,EACb,aAAa,EAAE,CAAC,KACZ,gBAAgB,EACpB,SAAS,EAAE,IAAA,kBAAO,EAChB,0EAA0E,EAC1E,sDAA6B,CAAC,IAAI,CAAC,EACnC,gBAAgB,EAAE,SAAS,CAC5B;gBAED,2CAAS,IAAI,EAAC,QAAQ,gBAAY,MAAM,IACrC,QAAQ,CACD,CACN,CACF,CACK,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,oBAAY,CAAC,WAAW,GAAG,cAAc,CAAC","sourcesContent":["import React, { forwardRef, useEffect, useRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport {\n Box,\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n BoxJustifyContent,\n} from '../Box';\nimport { useModalContext } from '../Modal';\nimport { ModalFocus } from '../ModalFocus';\n\nimport {\n MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR,\n TWCLASSMAP_MODAL_CONTENT_SIZE,\n} from './ModalContent.constants';\nimport type { ModalContentProps } from './ModalContent.types';\nimport { ModalContentSize } from './ModalContent.types';\n\nexport const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(\n (\n {\n className,\n children,\n size = ModalContentSize.Sm,\n modalDialogProps,\n ...props\n },\n ref,\n ) => {\n const {\n onClose,\n isClosedOnEscapeKey,\n isClosedOnOutsideClick,\n initialFocusRef,\n finalFocusRef,\n restoreFocus,\n autoFocus,\n } = useModalContext();\n const modalDialogRef = useRef<HTMLElement>(null);\n\n useEffect(() => {\n const handleEscKey = (event: KeyboardEvent) => {\n if (isClosedOnEscapeKey && event.key === 'Escape') {\n onClose();\n }\n };\n const handleClickOutside = (event: MouseEvent) => {\n if (!isClosedOnOutsideClick) {\n return;\n }\n const target = event.target as HTMLElement | null;\n // Floating UI primitives (Popover, Tooltip, Select dropdown, etc.)\n // that portal alongside the Modal but are part of the modal\n // interaction can opt out of the outside-click handler by setting\n // `data-mm-modal-ignore-outside-click` on their root element.\n if (target?.closest(`[${MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR}]`)) {\n return;\n }\n if (\n modalDialogRef.current &&\n !modalDialogRef.current.contains(target as Node)\n ) {\n onClose();\n }\n };\n\n document.addEventListener('keydown', handleEscKey);\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n document.removeEventListener('keydown', handleEscKey);\n document.removeEventListener('mousedown', handleClickOutside);\n };\n }, [isClosedOnEscapeKey, isClosedOnOutsideClick, onClose]);\n\n return (\n <ModalFocus\n initialFocusRef={initialFocusRef}\n finalFocusRef={finalFocusRef}\n restoreFocus={restoreFocus}\n autoFocus={autoFocus}\n >\n <div\n ref={ref}\n className={twMerge(\n 'fixed inset-0 z-[1050] flex items-start justify-center p-4 sm:py-8 md:py-12',\n '[@media(max-height:475px)]:p-2',\n className,\n )}\n {...props}\n >\n <Box\n ref={modalDialogRef as React.Ref<HTMLDivElement>}\n asChild\n backgroundColor={BoxBackgroundColor.BackgroundDefault}\n justifyContent={BoxJustifyContent.Start}\n alignItems={BoxAlignItems.Stretch}\n flexDirection={BoxFlexDirection.Column}\n paddingTop={4}\n paddingBottom={4}\n {...modalDialogProps}\n className={twMerge(\n 'flex max-h-full w-full rounded-lg shadow-lg motion-safe:animate-slide-up',\n TWCLASSMAP_MODAL_CONTENT_SIZE[size],\n modalDialogProps?.className,\n )}\n >\n <section role=\"dialog\" aria-modal=\"true\">\n {children}\n </section>\n </Box>\n </div>\n </ModalFocus>\n );\n },\n);\n\nModalContent.displayName = 'ModalContent';\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TWCLASSMAP_MODAL_CONTENT_SIZE = exports.MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Attribute consumers can set on a portal-rendered subtree to opt out of the
|
|
6
|
+
* ModalContent outside-click handler. Useful for floating UI primitives
|
|
7
|
+
* (popover, tooltip, dropdown) that render as siblings to the modal portal
|
|
8
|
+
* but are conceptually part of the modal interaction.
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <Box {...{ [MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR]: '' }}>
|
|
14
|
+
* {popoverContent}
|
|
15
|
+
* </Box>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Clicks whose target's `closest('[data-mm-modal-ignore-outside-click]')` is
|
|
19
|
+
* non-null are ignored by ModalContent's outside-click logic and will not
|
|
20
|
+
* trigger `onClose`.
|
|
21
|
+
*/
|
|
22
|
+
exports.MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR = 'data-mm-modal-ignore-outside-click';
|
|
23
|
+
/**
|
|
24
|
+
* ModalContent dialog max-width tokens, expressed as Tailwind utilities.
|
|
25
|
+
* - `Sm` → 360px
|
|
26
|
+
* - `Md` → 480px
|
|
27
|
+
* - `Lg` → 720px
|
|
28
|
+
*/
|
|
29
|
+
exports.TWCLASSMAP_MODAL_CONTENT_SIZE = {
|
|
30
|
+
sm: 'max-w-[360px]',
|
|
31
|
+
md: 'max-w-[480px]',
|
|
32
|
+
lg: 'max-w-[720px]',
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=ModalContent.constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.constants.cjs","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.constants.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,uCAAuC,GAClD,oCAAoC,CAAC;AAEvC;;;;;GAKG;AACU,QAAA,6BAA6B,GAAG;IAC3C,EAAE,EAAE,eAAe;IACnB,EAAE,EAAE,eAAe;IACnB,EAAE,EAAE,eAAe;CACX,CAAC","sourcesContent":["/**\n * Attribute consumers can set on a portal-rendered subtree to opt out of the\n * ModalContent outside-click handler. Useful for floating UI primitives\n * (popover, tooltip, dropdown) that render as siblings to the modal portal\n * but are conceptually part of the modal interaction.\n *\n * Example:\n *\n * ```tsx\n * <Box {...{ [MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR]: '' }}>\n * {popoverContent}\n * </Box>\n * ```\n *\n * Clicks whose target's `closest('[data-mm-modal-ignore-outside-click]')` is\n * non-null are ignored by ModalContent's outside-click logic and will not\n * trigger `onClose`.\n */\nexport const MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR =\n 'data-mm-modal-ignore-outside-click';\n\n/**\n * ModalContent dialog max-width tokens, expressed as Tailwind utilities.\n * - `Sm` → 360px\n * - `Md` → 480px\n * - `Lg` → 720px\n */\nexport const TWCLASSMAP_MODAL_CONTENT_SIZE = {\n sm: 'max-w-[360px]',\n md: 'max-w-[480px]',\n lg: 'max-w-[720px]',\n} as const;\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute consumers can set on a portal-rendered subtree to opt out of the
|
|
3
|
+
* ModalContent outside-click handler. Useful for floating UI primitives
|
|
4
|
+
* (popover, tooltip, dropdown) that render as siblings to the modal portal
|
|
5
|
+
* but are conceptually part of the modal interaction.
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <Box {...{ [MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR]: '' }}>
|
|
11
|
+
* {popoverContent}
|
|
12
|
+
* </Box>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Clicks whose target's `closest('[data-mm-modal-ignore-outside-click]')` is
|
|
16
|
+
* non-null are ignored by ModalContent's outside-click logic and will not
|
|
17
|
+
* trigger `onClose`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR = "data-mm-modal-ignore-outside-click";
|
|
20
|
+
/**
|
|
21
|
+
* ModalContent dialog max-width tokens, expressed as Tailwind utilities.
|
|
22
|
+
* - `Sm` → 360px
|
|
23
|
+
* - `Md` → 480px
|
|
24
|
+
* - `Lg` → 720px
|
|
25
|
+
*/
|
|
26
|
+
export declare const TWCLASSMAP_MODAL_CONTENT_SIZE: {
|
|
27
|
+
readonly sm: "max-w-[360px]";
|
|
28
|
+
readonly md: "max-w-[480px]";
|
|
29
|
+
readonly lg: "max-w-[720px]";
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=ModalContent.constants.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.constants.d.cts","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,uCAAuC,uCACd,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;;CAIhC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute consumers can set on a portal-rendered subtree to opt out of the
|
|
3
|
+
* ModalContent outside-click handler. Useful for floating UI primitives
|
|
4
|
+
* (popover, tooltip, dropdown) that render as siblings to the modal portal
|
|
5
|
+
* but are conceptually part of the modal interaction.
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <Box {...{ [MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR]: '' }}>
|
|
11
|
+
* {popoverContent}
|
|
12
|
+
* </Box>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Clicks whose target's `closest('[data-mm-modal-ignore-outside-click]')` is
|
|
16
|
+
* non-null are ignored by ModalContent's outside-click logic and will not
|
|
17
|
+
* trigger `onClose`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR = "data-mm-modal-ignore-outside-click";
|
|
20
|
+
/**
|
|
21
|
+
* ModalContent dialog max-width tokens, expressed as Tailwind utilities.
|
|
22
|
+
* - `Sm` → 360px
|
|
23
|
+
* - `Md` → 480px
|
|
24
|
+
* - `Lg` → 720px
|
|
25
|
+
*/
|
|
26
|
+
export declare const TWCLASSMAP_MODAL_CONTENT_SIZE: {
|
|
27
|
+
readonly sm: "max-w-[360px]";
|
|
28
|
+
readonly md: "max-w-[480px]";
|
|
29
|
+
readonly lg: "max-w-[720px]";
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=ModalContent.constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.constants.d.mts","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,uCAAuC,uCACd,CAAC;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;;CAIhC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute consumers can set on a portal-rendered subtree to opt out of the
|
|
3
|
+
* ModalContent outside-click handler. Useful for floating UI primitives
|
|
4
|
+
* (popover, tooltip, dropdown) that render as siblings to the modal portal
|
|
5
|
+
* but are conceptually part of the modal interaction.
|
|
6
|
+
*
|
|
7
|
+
* Example:
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <Box {...{ [MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR]: '' }}>
|
|
11
|
+
* {popoverContent}
|
|
12
|
+
* </Box>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Clicks whose target's `closest('[data-mm-modal-ignore-outside-click]')` is
|
|
16
|
+
* non-null are ignored by ModalContent's outside-click logic and will not
|
|
17
|
+
* trigger `onClose`.
|
|
18
|
+
*/
|
|
19
|
+
export const MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR = 'data-mm-modal-ignore-outside-click';
|
|
20
|
+
/**
|
|
21
|
+
* ModalContent dialog max-width tokens, expressed as Tailwind utilities.
|
|
22
|
+
* - `Sm` → 360px
|
|
23
|
+
* - `Md` → 480px
|
|
24
|
+
* - `Lg` → 720px
|
|
25
|
+
*/
|
|
26
|
+
export const TWCLASSMAP_MODAL_CONTENT_SIZE = {
|
|
27
|
+
sm: 'max-w-[360px]',
|
|
28
|
+
md: 'max-w-[480px]',
|
|
29
|
+
lg: 'max-w-[720px]',
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=ModalContent.constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.constants.mjs","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAClD,oCAAoC,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,EAAE,EAAE,eAAe;IACnB,EAAE,EAAE,eAAe;IACnB,EAAE,EAAE,eAAe;CACX,CAAC","sourcesContent":["/**\n * Attribute consumers can set on a portal-rendered subtree to opt out of the\n * ModalContent outside-click handler. Useful for floating UI primitives\n * (popover, tooltip, dropdown) that render as siblings to the modal portal\n * but are conceptually part of the modal interaction.\n *\n * Example:\n *\n * ```tsx\n * <Box {...{ [MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR]: '' }}>\n * {popoverContent}\n * </Box>\n * ```\n *\n * Clicks whose target's `closest('[data-mm-modal-ignore-outside-click]')` is\n * non-null are ignored by ModalContent's outside-click logic and will not\n * trigger `onClose`.\n */\nexport const MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR =\n 'data-mm-modal-ignore-outside-click';\n\n/**\n * ModalContent dialog max-width tokens, expressed as Tailwind utilities.\n * - `Sm` → 360px\n * - `Md` → 480px\n * - `Lg` → 720px\n */\nexport const TWCLASSMAP_MODAL_CONTENT_SIZE = {\n sm: 'max-w-[360px]',\n md: 'max-w-[480px]',\n lg: 'max-w-[720px]',\n} as const;\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ModalContentProps } from "./ModalContent.types.cjs";
|
|
3
|
+
export declare const ModalContent: React.ForwardRefExoticComponent<Omit<ModalContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
//# sourceMappingURL=ModalContent.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.d.cts","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,cAAc;AAiB7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,iCAA6B;AAG9D,eAAO,MAAM,YAAY,uGAiGxB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ModalContentProps } from "./ModalContent.types.mjs";
|
|
3
|
+
export declare const ModalContent: React.ForwardRefExoticComponent<Omit<ModalContentProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
//# sourceMappingURL=ModalContent.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.d.mts","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,cAAc;AAiB7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,iCAA6B;AAG9D,eAAO,MAAM,YAAY,uGAiGxB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function $importDefault(module) {
|
|
2
|
+
if (module?.__esModule) {
|
|
3
|
+
return module.default;
|
|
4
|
+
}
|
|
5
|
+
return module;
|
|
6
|
+
}
|
|
7
|
+
import $React, { forwardRef, useEffect, useRef } from "react";
|
|
8
|
+
const React = $importDefault($React);
|
|
9
|
+
import { twMerge } from "../../utils/tw-merge.mjs";
|
|
10
|
+
import { Box, BoxAlignItems, BoxBackgroundColor, BoxFlexDirection, BoxJustifyContent } from "../Box/index.mjs";
|
|
11
|
+
import { useModalContext } from "../Modal/index.mjs";
|
|
12
|
+
import { ModalFocus } from "../ModalFocus/index.mjs";
|
|
13
|
+
import { MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR, TWCLASSMAP_MODAL_CONTENT_SIZE } from "./ModalContent.constants.mjs";
|
|
14
|
+
import { ModalContentSize } from "./ModalContent.types.mjs";
|
|
15
|
+
export const ModalContent = forwardRef(({ className, children, size = ModalContentSize.Sm, modalDialogProps, ...props }, ref) => {
|
|
16
|
+
const { onClose, isClosedOnEscapeKey, isClosedOnOutsideClick, initialFocusRef, finalFocusRef, restoreFocus, autoFocus, } = useModalContext();
|
|
17
|
+
const modalDialogRef = useRef(null);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const handleEscKey = (event) => {
|
|
20
|
+
if (isClosedOnEscapeKey && event.key === 'Escape') {
|
|
21
|
+
onClose();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const handleClickOutside = (event) => {
|
|
25
|
+
if (!isClosedOnOutsideClick) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const target = event.target;
|
|
29
|
+
// Floating UI primitives (Popover, Tooltip, Select dropdown, etc.)
|
|
30
|
+
// that portal alongside the Modal but are part of the modal
|
|
31
|
+
// interaction can opt out of the outside-click handler by setting
|
|
32
|
+
// `data-mm-modal-ignore-outside-click` on their root element.
|
|
33
|
+
if (target?.closest(`[${MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR}]`)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (modalDialogRef.current &&
|
|
37
|
+
!modalDialogRef.current.contains(target)) {
|
|
38
|
+
onClose();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
document.addEventListener('keydown', handleEscKey);
|
|
42
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
43
|
+
return () => {
|
|
44
|
+
document.removeEventListener('keydown', handleEscKey);
|
|
45
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
46
|
+
};
|
|
47
|
+
}, [isClosedOnEscapeKey, isClosedOnOutsideClick, onClose]);
|
|
48
|
+
return (React.createElement(ModalFocus, { initialFocusRef: initialFocusRef, finalFocusRef: finalFocusRef, restoreFocus: restoreFocus, autoFocus: autoFocus },
|
|
49
|
+
React.createElement("div", { ref: ref, className: twMerge('fixed inset-0 z-[1050] flex items-start justify-center p-4 sm:py-8 md:py-12', '[@media(max-height:475px)]:p-2', className), ...props },
|
|
50
|
+
React.createElement(Box, { ref: modalDialogRef, asChild: true, backgroundColor: BoxBackgroundColor.BackgroundDefault, justifyContent: BoxJustifyContent.Start, alignItems: BoxAlignItems.Stretch, flexDirection: BoxFlexDirection.Column, paddingTop: 4, paddingBottom: 4, ...modalDialogProps, className: twMerge('flex max-h-full w-full rounded-lg shadow-lg motion-safe:animate-slide-up', TWCLASSMAP_MODAL_CONTENT_SIZE[size], modalDialogProps?.className) },
|
|
51
|
+
React.createElement("section", { role: "dialog", "aria-modal": "true" }, children)))));
|
|
52
|
+
});
|
|
53
|
+
ModalContent.displayName = 'ModalContent';
|
|
54
|
+
//# sourceMappingURL=ModalContent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.mjs","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc;;AAE7D,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EACL,GAAG,EACH,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EAClB,yBAAe;AAChB,OAAO,EAAE,eAAe,EAAE,2BAAiB;AAC3C,OAAO,EAAE,UAAU,EAAE,gCAAsB;AAE3C,OAAO,EACL,uCAAuC,EACvC,6BAA6B,EAC9B,qCAAiC;AAElC,OAAO,EAAE,gBAAgB,EAAE,iCAA6B;AAExD,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,CACE,EACE,SAAS,EACT,QAAQ,EACR,IAAI,GAAG,gBAAgB,CAAC,EAAE,EAC1B,gBAAgB,EAChB,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,EACJ,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,SAAS,GACV,GAAG,eAAe,EAAE,CAAC;IACtB,MAAM,cAAc,GAAG,MAAM,CAAc,IAAI,CAAC,CAAC;IAEjD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC5C,IAAI,mBAAmB,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;gBACjD,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC;QACF,MAAM,kBAAkB,GAAG,CAAC,KAAiB,EAAE,EAAE;YAC/C,IAAI,CAAC,sBAAsB,EAAE;gBAC3B,OAAO;aACR;YACD,MAAM,MAAM,GAAG,KAAK,CAAC,MAA4B,CAAC;YAClD,mEAAmE;YACnE,4DAA4D;YAC5D,kEAAkE;YAClE,8DAA8D;YAC9D,IAAI,MAAM,EAAE,OAAO,CAAC,IAAI,uCAAuC,GAAG,CAAC,EAAE;gBACnE,OAAO;aACR;YACD,IACE,cAAc,CAAC,OAAO;gBACtB,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAc,CAAC,EAChD;gBACA,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC;QAEF,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACnD,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QAE3D,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;YACtD,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QAChE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3D,OAAO,CACL,oBAAC,UAAU,IACT,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS;QAEpB,6BACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,OAAO,CAChB,6EAA6E,EAC7E,gCAAgC,EAChC,SAAS,CACV,KACG,KAAK;YAET,oBAAC,GAAG,IACF,GAAG,EAAE,cAA2C,EAChD,OAAO,QACP,eAAe,EAAE,kBAAkB,CAAC,iBAAiB,EACrD,cAAc,EAAE,iBAAiB,CAAC,KAAK,EACvC,UAAU,EAAE,aAAa,CAAC,OAAO,EACjC,aAAa,EAAE,gBAAgB,CAAC,MAAM,EACtC,UAAU,EAAE,CAAC,EACb,aAAa,EAAE,CAAC,KACZ,gBAAgB,EACpB,SAAS,EAAE,OAAO,CAChB,0EAA0E,EAC1E,6BAA6B,CAAC,IAAI,CAAC,EACnC,gBAAgB,EAAE,SAAS,CAC5B;gBAED,iCAAS,IAAI,EAAC,QAAQ,gBAAY,MAAM,IACrC,QAAQ,CACD,CACN,CACF,CACK,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC","sourcesContent":["import React, { forwardRef, useEffect, useRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport {\n Box,\n BoxAlignItems,\n BoxBackgroundColor,\n BoxFlexDirection,\n BoxJustifyContent,\n} from '../Box';\nimport { useModalContext } from '../Modal';\nimport { ModalFocus } from '../ModalFocus';\n\nimport {\n MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR,\n TWCLASSMAP_MODAL_CONTENT_SIZE,\n} from './ModalContent.constants';\nimport type { ModalContentProps } from './ModalContent.types';\nimport { ModalContentSize } from './ModalContent.types';\n\nexport const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(\n (\n {\n className,\n children,\n size = ModalContentSize.Sm,\n modalDialogProps,\n ...props\n },\n ref,\n ) => {\n const {\n onClose,\n isClosedOnEscapeKey,\n isClosedOnOutsideClick,\n initialFocusRef,\n finalFocusRef,\n restoreFocus,\n autoFocus,\n } = useModalContext();\n const modalDialogRef = useRef<HTMLElement>(null);\n\n useEffect(() => {\n const handleEscKey = (event: KeyboardEvent) => {\n if (isClosedOnEscapeKey && event.key === 'Escape') {\n onClose();\n }\n };\n const handleClickOutside = (event: MouseEvent) => {\n if (!isClosedOnOutsideClick) {\n return;\n }\n const target = event.target as HTMLElement | null;\n // Floating UI primitives (Popover, Tooltip, Select dropdown, etc.)\n // that portal alongside the Modal but are part of the modal\n // interaction can opt out of the outside-click handler by setting\n // `data-mm-modal-ignore-outside-click` on their root element.\n if (target?.closest(`[${MODAL_CONTENT_IGNORE_OUTSIDE_CLICK_ATTR}]`)) {\n return;\n }\n if (\n modalDialogRef.current &&\n !modalDialogRef.current.contains(target as Node)\n ) {\n onClose();\n }\n };\n\n document.addEventListener('keydown', handleEscKey);\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n document.removeEventListener('keydown', handleEscKey);\n document.removeEventListener('mousedown', handleClickOutside);\n };\n }, [isClosedOnEscapeKey, isClosedOnOutsideClick, onClose]);\n\n return (\n <ModalFocus\n initialFocusRef={initialFocusRef}\n finalFocusRef={finalFocusRef}\n restoreFocus={restoreFocus}\n autoFocus={autoFocus}\n >\n <div\n ref={ref}\n className={twMerge(\n 'fixed inset-0 z-[1050] flex items-start justify-center p-4 sm:py-8 md:py-12',\n '[@media(max-height:475px)]:p-2',\n className,\n )}\n {...props}\n >\n <Box\n ref={modalDialogRef as React.Ref<HTMLDivElement>}\n asChild\n backgroundColor={BoxBackgroundColor.BackgroundDefault}\n justifyContent={BoxJustifyContent.Start}\n alignItems={BoxAlignItems.Stretch}\n flexDirection={BoxFlexDirection.Column}\n paddingTop={4}\n paddingBottom={4}\n {...modalDialogProps}\n className={twMerge(\n 'flex max-h-full w-full rounded-lg shadow-lg motion-safe:animate-slide-up',\n TWCLASSMAP_MODAL_CONTENT_SIZE[size],\n modalDialogProps?.className,\n )}\n >\n <section role=\"dialog\" aria-modal=\"true\">\n {children}\n </section>\n </Box>\n </div>\n </ModalFocus>\n );\n },\n);\n\nModalContent.displayName = 'ModalContent';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModalContentSize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ModalContent dialog max-width.
|
|
6
|
+
* - `Sm` → 360px (default)
|
|
7
|
+
* - `Md` → 480px
|
|
8
|
+
* - `Lg` → 720px
|
|
9
|
+
*/
|
|
10
|
+
exports.ModalContentSize = {
|
|
11
|
+
Sm: 'sm',
|
|
12
|
+
Md: 'md',
|
|
13
|
+
Lg: 'lg',
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=ModalContent.types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.types.cjs","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.types.ts"],"names":[],"mappings":";;;AAIA;;;;;GAKG;AACU,QAAA,gBAAgB,GAAG;IAC9B,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;CACA,CAAC","sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport type { BoxProps } from '../Box';\n\n/**\n * ModalContent dialog max-width.\n * - `Sm` → 360px (default)\n * - `Md` → 480px\n * - `Lg` → 720px\n */\nexport const ModalContentSize = {\n Sm: 'sm',\n Md: 'md',\n Lg: 'lg',\n} as const;\nexport type ModalContentSize =\n (typeof ModalContentSize)[keyof typeof ModalContentSize];\n\n/**\n * Box prop bag used for the inner dialog `<section>`. Mirrors the legacy\n * `modalDialogProps` typing but is bound to the MMDS `BoxProps` shape and\n * carries an explicit `data-*` index signature so consumers can pass through\n * test ids and other dataset attributes through `Partial`/`Omit` indirection.\n */\ntype DialogBoxProps = Omit<BoxProps, 'children' | 'asChild'> & {\n [key: `data-${string}`]: string | undefined;\n};\n\nexport type ModalContentProps = Omit<ComponentProps<'div'>, 'children'> & {\n /**\n * Content rendered inside the dialog. Typically composed of `ModalHeader`,\n * `ModalBody`, and `ModalFooter`.\n */\n children: ReactNode;\n /**\n * Optional max-width for the inner dialog. Use one of `ModalContentSize`\n * tokens (Sm/Md/Lg → 360/480/720px). Override entirely via\n * `modalDialogProps.className=\"max-w-...\"` if you need a custom width.\n *\n * @default ModalContentSize.Sm\n */\n size?: ModalContentSize;\n /**\n * Props forwarded to the inner dialog `Box` (the `<section\n * role=\"dialog\">`). Use this to add `data-testid`, override layout, change\n * background, or apply Tailwind utilities via `className`.\n */\n modalDialogProps?: DialogBoxProps;\n /**\n * Optional prop for additional CSS classes applied to the outer\n * positioning element. 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
|
+
* ModalContent dialog max-width.
|
|
5
|
+
* - `Sm` → 360px (default)
|
|
6
|
+
* - `Md` → 480px
|
|
7
|
+
* - `Lg` → 720px
|
|
8
|
+
*/
|
|
9
|
+
export declare const ModalContentSize: {
|
|
10
|
+
readonly Sm: "sm";
|
|
11
|
+
readonly Md: "md";
|
|
12
|
+
readonly Lg: "lg";
|
|
13
|
+
};
|
|
14
|
+
export type ModalContentSize = (typeof ModalContentSize)[keyof typeof ModalContentSize];
|
|
15
|
+
/**
|
|
16
|
+
* Box prop bag used for the inner dialog `<section>`. Mirrors the legacy
|
|
17
|
+
* `modalDialogProps` typing but is bound to the MMDS `BoxProps` shape and
|
|
18
|
+
* carries an explicit `data-*` index signature so consumers can pass through
|
|
19
|
+
* test ids and other dataset attributes through `Partial`/`Omit` indirection.
|
|
20
|
+
*/
|
|
21
|
+
type DialogBoxProps = Omit<BoxProps, 'children' | 'asChild'> & {
|
|
22
|
+
[key: `data-${string}`]: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
export type ModalContentProps = Omit<ComponentProps<'div'>, 'children'> & {
|
|
25
|
+
/**
|
|
26
|
+
* Content rendered inside the dialog. Typically composed of `ModalHeader`,
|
|
27
|
+
* `ModalBody`, and `ModalFooter`.
|
|
28
|
+
*/
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Optional max-width for the inner dialog. Use one of `ModalContentSize`
|
|
32
|
+
* tokens (Sm/Md/Lg → 360/480/720px). Override entirely via
|
|
33
|
+
* `modalDialogProps.className="max-w-..."` if you need a custom width.
|
|
34
|
+
*
|
|
35
|
+
* @default ModalContentSize.Sm
|
|
36
|
+
*/
|
|
37
|
+
size?: ModalContentSize;
|
|
38
|
+
/**
|
|
39
|
+
* Props forwarded to the inner dialog `Box` (the `<section
|
|
40
|
+
* role="dialog">`). Use this to add `data-testid`, override layout, change
|
|
41
|
+
* background, or apply Tailwind utilities via `className`.
|
|
42
|
+
*/
|
|
43
|
+
modalDialogProps?: DialogBoxProps;
|
|
44
|
+
/**
|
|
45
|
+
* Optional prop for additional CSS classes applied to the outer
|
|
46
|
+
* positioning element. Merged with the component's defaults via `twMerge`.
|
|
47
|
+
*/
|
|
48
|
+
className?: string;
|
|
49
|
+
};
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=ModalContent.types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.types.d.cts","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAe;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AACX,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE3D;;;;;GAKG;AACH,KAAK,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG;IAC7D,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG;IACxE;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import type { BoxProps } from "../Box/index.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* ModalContent dialog max-width.
|
|
5
|
+
* - `Sm` → 360px (default)
|
|
6
|
+
* - `Md` → 480px
|
|
7
|
+
* - `Lg` → 720px
|
|
8
|
+
*/
|
|
9
|
+
export declare const ModalContentSize: {
|
|
10
|
+
readonly Sm: "sm";
|
|
11
|
+
readonly Md: "md";
|
|
12
|
+
readonly Lg: "lg";
|
|
13
|
+
};
|
|
14
|
+
export type ModalContentSize = (typeof ModalContentSize)[keyof typeof ModalContentSize];
|
|
15
|
+
/**
|
|
16
|
+
* Box prop bag used for the inner dialog `<section>`. Mirrors the legacy
|
|
17
|
+
* `modalDialogProps` typing but is bound to the MMDS `BoxProps` shape and
|
|
18
|
+
* carries an explicit `data-*` index signature so consumers can pass through
|
|
19
|
+
* test ids and other dataset attributes through `Partial`/`Omit` indirection.
|
|
20
|
+
*/
|
|
21
|
+
type DialogBoxProps = Omit<BoxProps, 'children' | 'asChild'> & {
|
|
22
|
+
[key: `data-${string}`]: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
export type ModalContentProps = Omit<ComponentProps<'div'>, 'children'> & {
|
|
25
|
+
/**
|
|
26
|
+
* Content rendered inside the dialog. Typically composed of `ModalHeader`,
|
|
27
|
+
* `ModalBody`, and `ModalFooter`.
|
|
28
|
+
*/
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Optional max-width for the inner dialog. Use one of `ModalContentSize`
|
|
32
|
+
* tokens (Sm/Md/Lg → 360/480/720px). Override entirely via
|
|
33
|
+
* `modalDialogProps.className="max-w-..."` if you need a custom width.
|
|
34
|
+
*
|
|
35
|
+
* @default ModalContentSize.Sm
|
|
36
|
+
*/
|
|
37
|
+
size?: ModalContentSize;
|
|
38
|
+
/**
|
|
39
|
+
* Props forwarded to the inner dialog `Box` (the `<section
|
|
40
|
+
* role="dialog">`). Use this to add `data-testid`, override layout, change
|
|
41
|
+
* background, or apply Tailwind utilities via `className`.
|
|
42
|
+
*/
|
|
43
|
+
modalDialogProps?: DialogBoxProps;
|
|
44
|
+
/**
|
|
45
|
+
* Optional prop for additional CSS classes applied to the outer
|
|
46
|
+
* positioning element. Merged with the component's defaults via `twMerge`.
|
|
47
|
+
*/
|
|
48
|
+
className?: string;
|
|
49
|
+
};
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=ModalContent.types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.types.d.mts","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAe;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;CAInB,CAAC;AACX,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAE3D;;;;;GAKG;AACH,KAAK,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG;IAC7D,CAAC,GAAG,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG;IACxE;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContent.types.mjs","sourceRoot":"","sources":["../../../src/components/ModalContent/ModalContent.types.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;IACR,EAAE,EAAE,IAAI;CACA,CAAC","sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport type { BoxProps } from '../Box';\n\n/**\n * ModalContent dialog max-width.\n * - `Sm` → 360px (default)\n * - `Md` → 480px\n * - `Lg` → 720px\n */\nexport const ModalContentSize = {\n Sm: 'sm',\n Md: 'md',\n Lg: 'lg',\n} as const;\nexport type ModalContentSize =\n (typeof ModalContentSize)[keyof typeof ModalContentSize];\n\n/**\n * Box prop bag used for the inner dialog `<section>`. Mirrors the legacy\n * `modalDialogProps` typing but is bound to the MMDS `BoxProps` shape and\n * carries an explicit `data-*` index signature so consumers can pass through\n * test ids and other dataset attributes through `Partial`/`Omit` indirection.\n */\ntype DialogBoxProps = Omit<BoxProps, 'children' | 'asChild'> & {\n [key: `data-${string}`]: string | undefined;\n};\n\nexport type ModalContentProps = Omit<ComponentProps<'div'>, 'children'> & {\n /**\n * Content rendered inside the dialog. Typically composed of `ModalHeader`,\n * `ModalBody`, and `ModalFooter`.\n */\n children: ReactNode;\n /**\n * Optional max-width for the inner dialog. Use one of `ModalContentSize`\n * tokens (Sm/Md/Lg → 360/480/720px). Override entirely via\n * `modalDialogProps.className=\"max-w-...\"` if you need a custom width.\n *\n * @default ModalContentSize.Sm\n */\n size?: ModalContentSize;\n /**\n * Props forwarded to the inner dialog `Box` (the `<section\n * role=\"dialog\">`). Use this to add `data-testid`, override layout, change\n * background, or apply Tailwind utilities via `className`.\n */\n modalDialogProps?: DialogBoxProps;\n /**\n * Optional prop for additional CSS classes applied to the outer\n * positioning element. Merged with the component's defaults via `twMerge`.\n */\n className?: string;\n};\n"]}
|