@sproutsocial/seeds-react-modal 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +23 -23
- package/CHANGELOG.md +175 -0
- package/dist/ModalAction-BB7qJtQj.d.mts +445 -0
- package/dist/ModalAction-BB7qJtQj.d.ts +445 -0
- package/dist/esm/chunk-ETVICNHP.js +1353 -0
- package/dist/esm/chunk-ETVICNHP.js.map +1 -0
- package/dist/esm/index.js +11 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/v2/index.js +12 -20
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1154 -546
- package/dist/index.js.map +1 -1
- package/dist/v2/index.d.mts +4 -11
- package/dist/v2/index.d.ts +4 -11
- package/dist/v2/index.js +1152 -545
- package/dist/v2/index.js.map +1 -1
- package/package.json +8 -7
- package/src/index.ts +11 -12
- package/src/shared/constants.ts +11 -7
- package/src/v2/Modal.tsx +169 -0
- package/src/v2/ModalTypes.ts +343 -0
- package/src/v2/ModalV2.stories.tsx +413 -128
- package/src/v2/MotionConfig.ts +185 -0
- package/src/v2/components/ModalAction.tsx +94 -0
- package/src/v2/components/ModalBody.tsx +54 -0
- package/src/v2/components/ModalCloseWrapper.tsx +35 -0
- package/src/v2/components/ModalContent.tsx +288 -11
- package/src/v2/components/ModalDescription.tsx +14 -2
- package/src/v2/components/ModalFooter.tsx +94 -13
- package/src/v2/components/ModalHeader.tsx +77 -34
- package/src/v2/components/ModalOverlay.tsx +52 -0
- package/src/v2/components/ModalRail.tsx +35 -99
- package/src/v2/components/index.ts +11 -7
- package/src/v2/index.ts +13 -16
- package/dist/ModalRail-5PeilhW7.d.mts +0 -186
- package/dist/ModalRail-5PeilhW7.d.ts +0 -186
- package/dist/esm/chunk-4ITF4DBY.js +0 -717
- package/dist/esm/chunk-4ITF4DBY.js.map +0 -1
- package/src/v2/ModalV2.tsx +0 -388
- package/src/v2/ModalV2Styles.tsx +0 -180
- package/src/v2/ModalV2Types.ts +0 -154
- package/src/v2/components/ModalClose.tsx +0 -29
- package/src/v2/components/ModalCloseButton.tsx +0 -100
- package/src/v2/components/ModalTrigger.tsx +0 -39
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/v2/ModalV2.tsx","../../src/v2/ModalV2Styles.tsx","../../src/shared/constants.ts","../../src/v2/components/ModalHeader.tsx","../../src/v2/components/ModalCloseButton.tsx","../../src/v2/components/ModalFooter.tsx","../../src/v2/components/ModalContent.tsx","../../src/v2/components/ModalDescription.tsx","../../src/v2/components/ModalTrigger.tsx","../../src/v2/components/ModalClose.tsx","../../src/v2/components/ModalRail.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport { StyledOverlay, StyledContent } from \"./ModalV2Styles\";\nimport {\n ModalHeader,\n ModalDescription,\n ModalTrigger,\n ModalRail,\n ModalAction,\n} from \"./components\";\nimport {\n DEFAULT_MODAL_WIDTH,\n DEFAULT_MODAL_BG,\n DEFAULT_MODAL_Z_INDEX,\n MODAL_SIZE_PRESETS,\n MODAL_PRIORITY_Z_INDEX,\n} from \"../shared/constants\";\nimport type { TypeModalV2Props } from \"./ModalV2Types\";\n\ninterface DraggableModalContentProps {\n children: React.ReactNode;\n computedWidth: any;\n bg: any;\n computedZIndex: number;\n label?: string;\n dataAttributes: Record<string, string>;\n draggable?: boolean;\n rest: any;\n railProps?: Partial<TypeModalV2Props[\"railProps\"]>;\n}\n\n// Context to share drag state between modal content and header\ninterface DragContextValue {\n position: { x: number; y: number };\n isDragging: boolean;\n onHeaderMouseDown: (e: React.MouseEvent) => void;\n contentRef: React.RefObject<HTMLDivElement>;\n draggable: boolean;\n}\n\nconst DragContext = React.createContext<DragContextValue | null>(null);\n\nexport const useDragContext = () => {\n const context = React.useContext(DragContext);\n return context;\n};\n\nconst DraggableModalContent: React.FC<DraggableModalContentProps> = ({\n children,\n computedWidth,\n bg,\n computedZIndex,\n label,\n dataAttributes,\n draggable,\n rest,\n railProps,\n}) => {\n const [position, setPosition] = React.useState({ x: 0, y: 0 });\n const [isDragging, setIsDragging] = React.useState(false);\n const contentRef = React.useRef<HTMLDivElement>(null);\n\n // Calculate rail dimensions for boundary constraints\n const railSize = railProps?.size ?? 44;\n const railOffset = railProps?.offset ?? 12;\n const railSide = railProps?.side ?? \"right\";\n\n // Total extra space needed on the side with the rail\n // (only when viewport is wider than 400px breakpoint)\n const railExtraSpace = railSize + railOffset;\n\n const handleHeaderMouseDown = React.useCallback(\n (e: React.MouseEvent) => {\n if (!draggable) return;\n\n // Only allow dragging from header (not interactive elements)\n const target = e.target as HTMLElement;\n if (\n target.tagName === \"BUTTON\" ||\n target.tagName === \"INPUT\" ||\n target.closest(\"button\")\n ) {\n return;\n }\n\n e.preventDefault();\n setIsDragging(true);\n\n const rect = contentRef.current?.getBoundingClientRect();\n if (!rect) return;\n\n // Calculate offset from mouse to current modal position\n const offsetX = e.clientX - rect.left;\n const offsetY = e.clientY - rect.top;\n\n const handleMouseMove = (e: MouseEvent) => {\n e.preventDefault();\n\n // Calculate new position based on mouse position minus offset\n const newX = e.clientX - offsetX;\n const newY = e.clientY - offsetY;\n\n // Determine if rail is on the side (viewport > 400px) or above (viewport <= 400px)\n const isRailOnSide = window.innerWidth > 400;\n\n // Constrain to viewport bounds (keeping modal AND rail fully visible)\n const modalWidth = rect.width;\n const modalHeight = rect.height;\n\n // Adjust boundaries to account for rail position\n let maxX = window.innerWidth - modalWidth;\n let minX = 0;\n let maxY = window.innerHeight - modalHeight;\n let minY = 0;\n\n if (isRailOnSide) {\n // Rail is positioned on the side of the modal\n if (railSide === \"right\") {\n // Rail is on the right, so reduce maxX to prevent rail from going off-screen\n maxX = window.innerWidth - modalWidth - railExtraSpace;\n } else {\n // Rail is on the left, so increase minX to prevent rail from going off-screen\n minX = railExtraSpace;\n }\n } else {\n // Rail is positioned above the modal (viewport <= 400px)\n // Account for rail height + offset at the top\n minY = railSize + railOffset;\n }\n\n const constrainedX = Math.max(minX, Math.min(maxX, newX));\n const constrainedY = Math.max(minY, Math.min(maxY, newY));\n\n // Convert to offset from center for our transform\n const centerX = window.innerWidth / 2 - modalWidth / 2;\n const centerY = window.innerHeight / 2 - modalHeight / 2;\n\n setPosition({\n x: constrainedX - centerX,\n y: constrainedY - centerY,\n });\n };\n\n const handleMouseUp = () => {\n setIsDragging(false);\n document.removeEventListener(\"mousemove\", handleMouseMove);\n document.removeEventListener(\"mouseup\", handleMouseUp);\n };\n\n document.addEventListener(\"mousemove\", handleMouseMove);\n document.addEventListener(\"mouseup\", handleMouseUp);\n },\n [draggable, railSide, railExtraSpace]\n );\n\n const dragContextValue = React.useMemo<DragContextValue>(\n () => ({\n position,\n isDragging,\n onHeaderMouseDown: handleHeaderMouseDown,\n contentRef,\n draggable: draggable ?? false,\n }),\n [position, isDragging, handleHeaderMouseDown, draggable]\n );\n\n // Prevent modal from closing on outside interaction when draggable\n const handleInteractOutside = React.useCallback(\n (e: Event) => {\n if (draggable) {\n e.preventDefault();\n }\n },\n [draggable]\n );\n\n return (\n <DragContext.Provider value={draggable ? dragContextValue : null}>\n <StyledContent\n ref={contentRef}\n width={computedWidth}\n bg={bg}\n zIndex={computedZIndex}\n aria-label={label}\n draggable={draggable}\n isDragging={isDragging}\n railSize={railSize}\n railOffset={railOffset}\n railSide={railSide}\n onInteractOutside={handleInteractOutside}\n style={\n draggable\n ? {\n transform: `translate(calc(-50% + ${position.x}px), calc(-50% + ${position.y}px))`,\n transition: isDragging ? \"none\" : undefined,\n }\n : undefined\n }\n {...dataAttributes}\n {...rest}\n >\n {children}\n </StyledContent>\n </DragContext.Provider>\n );\n};\n\n/**\n * The modal you want - with Radix UI Dialog\n *\n * Features:\n * - Built with Radix UI Dialog for superior accessibility\n * - Same API as the original Modal component\n * - Automatic focus management and keyboard navigation\n * - Portal rendering for proper z-index layering\n * - Customizable styling through system props\n * - Optional draggable functionality using react-dnd\n */\nconst Modal = (props: TypeModalV2Props) => {\n const {\n children,\n modalTrigger,\n draggable = false,\n open,\n defaultOpen,\n onOpenChange,\n \"aria-label\": label,\n title,\n subtitle,\n description,\n size,\n priority,\n data = {},\n bg = DEFAULT_MODAL_BG,\n showOverlay = true,\n actions,\n railProps,\n ...rest\n } = props;\n\n const handleOpenChange = React.useCallback(\n (newOpen: boolean) => {\n onOpenChange?.(newOpen);\n },\n [onOpenChange]\n );\n\n // Compute actual width\n const computedWidth = React.useMemo(() => {\n if (size) {\n // Handle preset sizes\n if (typeof size === \"string\" && size in MODAL_SIZE_PRESETS) {\n return MODAL_SIZE_PRESETS[size as keyof typeof MODAL_SIZE_PRESETS];\n }\n // Handle custom size values\n return size;\n }\n // Fall back to default width\n return DEFAULT_MODAL_WIDTH;\n }, [size]);\n\n // Compute actual z-index\n const computedZIndex = React.useMemo(() => {\n if (priority) {\n return MODAL_PRIORITY_Z_INDEX[priority];\n }\n return DEFAULT_MODAL_Z_INDEX;\n }, [priority]);\n\n // Create data attributes object\n const dataAttributes = React.useMemo(() => {\n const attrs: Record<string, string> = {};\n Object.entries(data).forEach(([key, value]) => {\n attrs[`data-${key}`] = String(value);\n });\n attrs[\"data-qa-modal\"] = \"\";\n // Only add open attribute if in controlled mode\n if (open !== undefined) {\n attrs[\"data-qa-modal-open\"] = String(open);\n }\n return attrs;\n }, [data, open]);\n\n // Determine if we should auto-render the header from provided props\n const shouldRenderHeader = Boolean(title || subtitle);\n\n // Build Dialog.Root props conditionally\n const dialogRootProps = React.useMemo(() => {\n const props: any = {};\n\n // If controlled (open prop provided), use it\n if (open !== undefined) {\n props.open = open;\n }\n // If uncontrolled with explicit defaultOpen, use it\n else if (defaultOpen !== undefined) {\n props.defaultOpen = defaultOpen;\n }\n // If completely uncontrolled (neither open nor defaultOpen provided), default to closed\n else {\n props.defaultOpen = false;\n }\n\n // Always add onOpenChange if provided\n if (onOpenChange) {\n props.onOpenChange = handleOpenChange;\n }\n\n // When draggable, prevent modal from closing on outside interaction\n // This allows users to interact with background content\n if (draggable) {\n props.modal = false;\n }\n\n return props;\n }, [open, defaultOpen, handleOpenChange, onOpenChange, draggable]);\n\n // Handle trigger - use modalTrigger prop if provided, otherwise look for ModalTrigger children (backward compatibility)\n const triggers: React.ReactNode[] = [];\n const content: React.ReactNode[] = [];\n\n if (modalTrigger) {\n // New prop-based approach: wrap the provided element with Dialog.Trigger\n triggers.push(\n <Dialog.Trigger key=\"modal-trigger\" asChild>\n {modalTrigger}\n </Dialog.Trigger>\n );\n // All children are content\n content.push(children);\n } else {\n // Legacy approach: separate ModalTrigger children from content children\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child) && child.type === ModalTrigger) {\n triggers.push(child);\n } else {\n content.push(child);\n }\n });\n }\n\n return (\n <Dialog.Root {...dialogRootProps}>\n {/* Render triggers as direct children of Dialog.Root */}\n {triggers}\n\n <Dialog.Portal>\n {showOverlay && (\n <StyledOverlay zIndex={computedZIndex} allowInteraction={draggable} />\n )}\n <DraggableModalContent\n computedWidth={computedWidth}\n bg={bg}\n computedZIndex={computedZIndex}\n label={label}\n dataAttributes={dataAttributes}\n draggable={draggable}\n rest={rest}\n railProps={railProps}\n >\n {/* Floating actions rail - always show a close by default */}\n <ModalRail {...railProps}>\n <ModalAction\n actionType=\"close\"\n aria-label=\"Close\"\n iconName=\"x-outline\"\n />\n {actions?.map((action, idx) => (\n <ModalAction key={idx} {...action} />\n ))}\n </ModalRail>\n {/* Auto-render header when title or subtitle is provided */}\n {shouldRenderHeader && (\n <ModalHeader title={title} subtitle={subtitle} />\n )}\n\n {/* Auto-render description when provided */}\n {description && <ModalDescription>{description}</ModalDescription>}\n\n {/* Main content (everything except triggers) */}\n {content}\n </DraggableModalContent>\n </Dialog.Portal>\n </Dialog.Root>\n );\n};\n\nexport default Modal;\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { width, zIndex } from \"styled-system\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport Box, { type TypeContainerProps } from \"@sproutsocial/seeds-react-box\";\nimport {\n BODY_PADDING,\n DEFAULT_OVERLAY_Z_INDEX_OFFSET,\n} from \"../shared/constants\";\n\ninterface StyledOverlayProps extends TypeContainerProps {\n zIndex?: number;\n allowInteraction?: boolean;\n}\n\nexport const StyledOverlay = styled(Dialog.Overlay)<StyledOverlayProps>`\n position: fixed;\n top: 0px;\n left: 0px;\n right: 0px;\n bottom: 0px;\n background-color: ${(props) => props.theme.colors.overlay.background.base};\n opacity: 0;\n will-change: opacity;\n transition: opacity ${(props) => props.theme.duration.medium}\n ${(props) => props.theme.easing.ease_inout};\n z-index: ${(props) =>\n props.zIndex ? props.zIndex + DEFAULT_OVERLAY_Z_INDEX_OFFSET : 999};\n\n /* Allow clicking through overlay when modal is draggable */\n ${(props) =>\n props.allowInteraction &&\n `\n pointer-events: none;\n `}\n\n ${zIndex}\n\n &[data-state=\"open\"] {\n opacity: 1;\n }\n &[data-state=\"closed\"] {\n opacity: 0;\n }\n`;\n\ninterface StyledContentProps extends TypeContainerProps {\n zIndex?: number;\n isDragging?: boolean;\n draggable?: boolean;\n railSize?: number;\n railOffset?: number;\n railSide?: \"right\" | \"left\";\n}\n\nexport const StyledContent = styled(Dialog.Content)<StyledContentProps>`\n position: fixed;\n ${(props) =>\n props.draggable\n ? `\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n `\n : `\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n `}\n display: flex;\n flex-direction: column;\n border-radius: ${(props) => props.theme.radii[600]};\n box-shadow: ${(props) => props.theme.shadows.medium};\n filter: blur(0);\n color: ${(props) => props.theme.colors.text.body};\n outline: none;\n max-width: ${(props) => {\n // Calculate extra space needed for the rail when it's on the side (viewport > 400px)\n const railSize = props.railSize ?? 44;\n const railOffset = props.railOffset ?? 12;\n const railExtraSpace = railSize + railOffset;\n\n // Account for rail space when positioned on the side\n // At viewport <= 400px, rail is above modal, so no horizontal space needed\n return `calc(100vw - ${BODY_PADDING} - ${railExtraSpace}px)`;\n }};\n max-height: calc(100vh - ${BODY_PADDING});\n z-index: ${(props) => props.zIndex || 1000};\n\n /* When viewport is <= 400px, rail is above modal, so restore full width */\n @media (max-width: 400px) {\n max-width: calc(100vw - ${BODY_PADDING});\n }\n\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n height: calc(100vh - ${BODY_PADDING});\n }\n\n ${width}\n ${COMMON}\n\n /* Enhanced Radix Dialog animations */\n opacity: 0;\n ${(props) =>\n !props.draggable\n ? `\n transform: translate(-50%, -50%) scale(0.95);\n transition: opacity ${props.theme.duration.medium} ${props.theme.easing.ease_inout},\n transform ${props.theme.duration.medium} ${props.theme.easing.ease_inout};\n `\n : `\n transition: opacity ${props.theme.duration.medium} ${props.theme.easing.ease_inout};\n `}\n\n &[data-state=\"open\"] {\n opacity: 1;\n ${(props) =>\n !props.draggable ? `transform: translate(-50%, -50%) scale(1);` : ``}\n }\n &[data-state=\"closed\"] {\n opacity: 0;\n ${(props) =>\n !props.draggable ? `transform: translate(-50%, -50%) scale(0.95);` : ``}\n }\n`;\n\nexport const Content = styled(Box)`\n font-family: ${(props) => props.theme.fontFamily};\n min-height: 80px;\n overflow-y: auto;\n flex: 1 1 auto;\n padding: 0 ${(props) => props.theme.space[300]}\n ${(props) => props.theme.space[300]} ${(props) => props.theme.space[300]};\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n flex-basis: 100%;\n }\n`;\n\ninterface HeaderProps {\n draggable?: boolean;\n isDragging?: boolean;\n}\n\nexport const Header = styled(Box)<HeaderProps>`\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[300]};\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex: 0 0 auto;\n\n /* Draggable cursor styling */\n ${(props) =>\n props.draggable &&\n `\n cursor: ${props.isDragging ? \"grabbing\" : \"grab\"};\n user-select: none;\n `}\n`;\n\nexport const Footer = styled(Box)`\n flex: 0 0 auto;\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[300]};\n border-bottom-right-radius: ${(props) => props.theme.radii[500]};\n border-bottom-left-radius: ${(props) => props.theme.radii[500]};\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: ${(props) => props.theme.space[100]};\n`;\n\nStyledOverlay.displayName = \"ModalOverlay\";\nStyledContent.displayName = \"ModalContent\";\nContent.displayName = \"ModalContent\";\nHeader.displayName = \"ModalHeader\";\nFooter.displayName = \"ModalFooter\";\n","// Shared constants for both Modal versions\n\n// Default z-index values\nexport const DEFAULT_MODAL_Z_INDEX = 6;\nexport const DEFAULT_OVERLAY_Z_INDEX_OFFSET = -1;\n\n// Default styling values\nexport const DEFAULT_MODAL_WIDTH = \"600px\";\nexport const DEFAULT_MODAL_BG = \"container.background.base\";\nexport const DEFAULT_CLOSE_BUTTON_LABEL = \"Close dialog\";\n\n// Max space allowed between the modal and the edge of the browser\nexport const BODY_PADDING = \"64px\";\n\n// Size presets for simplified API\nexport const MODAL_SIZE_PRESETS = {\n small: \"400px\",\n medium: \"600px\",\n large: \"800px\",\n full: \"90vw\",\n} as const;\n\n// Priority level z-index mappings\nexport const MODAL_PRIORITY_Z_INDEX = {\n low: 100,\n medium: 1000,\n high: 2000,\n} as const;\n","import * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { Header } from \"../ModalV2Styles\";\nimport { ModalCloseButton } from \"./ModalCloseButton\";\nimport type { TypeModalV2HeaderProps } from \"../ModalV2Types\";\nimport { useDragContext } from \"../ModalV2\";\n\nexport const ModalHeader = (props: TypeModalV2HeaderProps) => {\n const {\n title,\n subtitle,\n children,\n titleProps = {},\n subtitleProps = {},\n showInlineClose,\n ...rest\n } = props;\n\n const dragContext = useDragContext();\n const isDraggable = dragContext?.draggable ?? false;\n\n return (\n <Header\n {...rest}\n onMouseDown={isDraggable ? dragContext?.onHeaderMouseDown : undefined}\n draggable={isDraggable}\n isDragging={dragContext?.isDragging}\n >\n {children ? (\n children\n ) : (\n <React.Fragment>\n <Box>\n {title && (\n <Dialog.Title asChild {...titleProps}>\n <Text.Headline>{title}</Text.Headline>\n </Dialog.Title>\n )}\n {subtitle && (\n <Dialog.Description asChild {...subtitleProps}>\n <Text as=\"div\" fontSize={200}>\n {subtitle}\n </Text>\n </Dialog.Description>\n )}\n </Box>\n {showInlineClose && (\n <Box display=\"flex\" alignItems=\"center\" justifyContent=\"flex-end\">\n <ModalCloseButton position=\"relative\" offset={0} />\n </Box>\n )}\n </React.Fragment>\n )}\n </Header>\n );\n};\n\nModalHeader.displayName = \"ModalHeader\";\n","import * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport styled from \"styled-components\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport type { TypeModalV2CloseButtonProps } from \"../ModalV2Types\";\n\nconst CloseButtonWrapper = styled.button<{\n size?: number;\n position?: \"absolute\" | \"relative\";\n side?: \"right\" | \"left\";\n offset?: number;\n}>`\n width: ${(p) => p.size || 44}px;\n height: ${(p) => p.size || 44}px;\n display: inline-grid;\n place-items: center;\n border-radius: 8px;\n border: none;\n background: rgba(22, 32, 32, 0.56);\n color: #ffffff;\n cursor: pointer;\n outline: none;\n transition: all 0.2s ease;\n\n ${(p) =>\n p.position === \"absolute\" &&\n `\n position: absolute;\n top: 0px;\n ${p.side || \"right\"}: ${p.offset || -48}px;\n z-index: 1;\n `}\n\n &:hover {\n background: rgba(22, 32, 32, 0.7);\n transform: translateY(-1px);\n }\n\n &:active {\n transform: translateY(0);\n }\n\n &:focus-visible {\n box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #205bc3;\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n`;\n\nexport const ModalCloseButton = (props: TypeModalV2CloseButtonProps) => {\n const {\n children,\n onClick,\n asChild,\n closeButtonLabel = \"Close modal\",\n size = 44,\n position = \"absolute\",\n side = \"right\",\n offset = -48,\n ...rest\n } = props;\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n // Dialog.Close automatically handles closing\n };\n\n if (asChild) {\n return (\n <Dialog.Close asChild>\n {React.cloneElement(children as React.ReactElement, {\n onClick: handleClick,\n ...rest,\n })}\n </Dialog.Close>\n );\n }\n\n return (\n <Dialog.Close asChild>\n <CloseButtonWrapper\n onClick={handleClick}\n size={size}\n position={position}\n side={side}\n offset={offset}\n aria-label={closeButtonLabel}\n title={closeButtonLabel}\n {...rest}\n >\n {children || <Icon name=\"x-outline\" size=\"small\" />}\n </CloseButtonWrapper>\n </Dialog.Close>\n );\n};\n\nModalCloseButton.displayName = \"ModalCloseButton\";\n","import * as React from \"react\";\nimport { Footer } from \"../ModalV2Styles\";\nimport { DEFAULT_MODAL_BG } from \"../../shared/constants\";\nimport type { TypeModalV2FooterProps } from \"../ModalV2Types\";\n\nexport const ModalFooter = (props: TypeModalV2FooterProps) => {\n const { bg = DEFAULT_MODAL_BG, children, ...rest } = props;\n return (\n <Footer\n bg={bg}\n borderTop={500}\n borderColor=\"container.border.base\"\n {...rest}\n >\n {children}\n </Footer>\n );\n};\n\nModalFooter.displayName = \"ModalFooter\";\n","import * as React from \"react\";\nimport { Content } from \"../ModalV2Styles\";\nimport type { TypeModalV2ContentProps } from \"../ModalV2Types\";\n\nexport const ModalContent = React.forwardRef<\n HTMLDivElement,\n TypeModalV2ContentProps\n>(({ children, ...rest }, ref) => {\n return (\n <Content data-qa-modal ref={ref} {...rest}>\n {children}\n </Content>\n );\n});\n\nModalContent.displayName = \"ModalContent\";\n","import * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport type { TypeModalV2DescriptionProps } from \"../ModalV2Types\";\n\nexport const ModalDescription = React.forwardRef<\n HTMLDivElement,\n TypeModalV2DescriptionProps\n>(({ children, descriptionProps = {}, ...rest }, ref) => {\n return (\n <Dialog.Description asChild {...descriptionProps}>\n <Box ref={ref} {...rest}>\n {children}\n </Box>\n </Dialog.Description>\n );\n});\n\nModalDescription.displayName = \"ModalDescription\";\n","import * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport Button from \"@sproutsocial/seeds-react-button\";\nimport type { TypeModalV2TriggerProps } from \"../ModalV2Types\";\n\n/**\n * A trigger button that opens the modal when clicked.\n * Must be used inside a Modal component's Dialog.Root context.\n * Uses Seeds Button by default but supports asChild for custom elements.\n */\nexport const ModalTrigger = (props: TypeModalV2TriggerProps) => {\n const { children, onClick, asChild, ...rest } = props;\n\n const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e);\n // Dialog.Trigger automatically handles modal opening\n };\n\n if (asChild) {\n return (\n <Dialog.Trigger asChild>\n {React.cloneElement(children as React.ReactElement, {\n onClick: handleClick,\n ...rest,\n })}\n </Dialog.Trigger>\n );\n }\n\n return (\n <Dialog.Trigger asChild>\n <Button onClick={handleClick} {...rest}>\n {children}\n </Button>\n </Dialog.Trigger>\n );\n};\n\nModalTrigger.displayName = \"ModalTrigger\";\n","import * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\n\nexport interface ModalCloseProps {\n children: React.ReactNode;\n onClick?: (e: React.MouseEvent) => void;\n asChild?: boolean;\n}\n\n/**\n * A component that closes the modal when clicked.\n * Uses asChild pattern like Radix primitives.\n */\nexport const ModalClose = (props: ModalCloseProps) => {\n const { children, onClick, asChild = false, ...rest } = props;\n\n const handleClick = (e: React.MouseEvent) => {\n onClick?.(e);\n // Dialog.Close automatically handles closing\n };\n\n return (\n <Dialog.Close asChild={asChild} onClick={handleClick} {...rest}>\n {children}\n </Dialog.Close>\n );\n};\n\nModalClose.displayName = \"ModalClose\";\n","// components/ModalRail.tsx\nimport * as React from \"react\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport styled from \"styled-components\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport type { TypeModalRailProps, TypeModalActionProps } from \"../ModalV2Types\";\n\n// --- styled wrappers ---\nconst Rail = styled.div<{\n side: \"right\" | \"left\";\n offset: number;\n gap: number;\n size: number;\n}>`\n position: absolute;\n top: ${(p) => p.offset}px;\n ${(p) =>\n p.side === \"right\"\n ? `right: calc(-1 * (${p.size}px + ${p.offset}px));`\n : `left: calc(-1 * (${p.size}px + ${p.offset}px));`}\n display: flex;\n flex-direction: column;\n gap: ${(p) => p.gap}px;\n z-index: 1;\n\n @media (max-width: 400px) {\n /* Move rail above the modal on the right side */\n top: auto;\n bottom: calc(100% + ${(p) => p.offset}px);\n right: ${(p) => p.offset}px;\n left: auto;\n /* Change to horizontal layout with reversed order */\n flex-direction: row-reverse;\n }\n`;\n\nconst RailBtn = styled.button<{ size: number }>`\n width: ${(p) => p.size}px;\n height: ${(p) => p.size}px;\n display: inline-grid;\n place-items: center;\n border-radius: 8px;\n border: none;\n background: rgba(22, 32, 32, 0.56);\n color: #ffffff;\n cursor: pointer;\n outline: none;\n transition: all 0.2s ease;\n\n &:hover {\n background: rgba(22, 32, 32, 0.7);\n transform: translateY(-1px);\n }\n\n &:active {\n transform: translateY(0);\n }\n\n &:focus-visible {\n box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #205bc3;\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n`;\n\n// --- components ---\nexport const ModalRail: React.FC<TypeModalRailProps> = ({\n side = \"right\",\n offset = 12,\n gap = 12,\n size = 44,\n children,\n}) => {\n return (\n <Rail\n data-slot=\"modal-rail\"\n side={side}\n offset={offset}\n gap={gap}\n size={size}\n aria-label=\"Modal quick actions\"\n >\n {React.Children.map(children, (child) =>\n React.isValidElement(child)\n ? React.cloneElement(child as any, { size })\n : child\n )}\n </Rail>\n );\n};\n\nexport const ModalAction: React.FC<\n TypeModalActionProps & { size?: number }\n> = ({\n \"aria-label\": ariaLabel,\n iconName,\n disabled,\n size = 44,\n actionType,\n onClick,\n ...rest\n}) => {\n const Btn = (\n <RailBtn\n size={size}\n aria-label={ariaLabel}\n title={ariaLabel}\n disabled={disabled}\n {...rest}\n >\n {iconName ? <Icon name={iconName} size=\"small\" /> : ariaLabel}\n </RailBtn>\n );\n\n return actionType === \"close\" ? (\n <Dialog.Close asChild>{Btn}</Dialog.Close>\n ) : (\n React.cloneElement(Btn, { onClick })\n );\n};\n"],"mappings":";AAAA,YAAYA,aAAW;AACvB,YAAYC,aAAY;;;ACDxB,OAAkB;AAClB,OAAO,YAAY;AACnB,SAAS,OAAO,cAAc;AAC9B,YAAY,YAAY;AACxB,SAAS,cAAc;AACvB,OAAO,SAAsC;;;ACFtC,IAAM,wBAAwB;AAC9B,IAAM,iCAAiC;AAGvC,IAAM,sBAAsB;AAC5B,IAAM,mBAAmB;AAIzB,IAAM,eAAe;AAGrB,IAAM,qBAAqB;AAAA,EAChC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AACR;AAGO,IAAM,yBAAyB;AAAA,EACpC,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AACR;;;ADXO,IAAM,gBAAgB,OAAc,cAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAM5B,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ,WAAW,IAAI;AAAA;AAAA;AAAA,wBAGnD,CAAC,UAAU,MAAM,MAAM,SAAS,MAAM;AAAA,MACxD,CAAC,UAAU,MAAM,MAAM,OAAO,UAAU;AAAA,aACjC,CAAC,UACV,MAAM,SAAS,MAAM,SAAS,iCAAiC,GAAG;AAAA;AAAA;AAAA,IAGlE,CAAC,UACD,MAAM,oBACN;AAAA;AAAA,GAED;AAAA;AAAA,IAEC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBH,IAAM,gBAAgB,OAAc,cAAO;AAAA;AAAA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EAAa,GAAG,iBAEd;AAAA;AAAA,IAED,gBAAAA,MAAQ,gBAAP,EACE;AAAA,qBACC,gBAAAD,KAAC,iBAAc,QAAQ,gBAAgB,kBAAkB,WAAW;AAAA,MAEtE,gBAAAC;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UAGA;AAAA,4BAAAA,MAAC,aAAW,GAAG,WACb;AAAA,8BAAAD;AAAA,gBAAC;AAAA;AAAA,kBACC,YAAW;AAAA,kBACX,cAAW;AAAA,kBACX,UAAS;AAAA;AAAA,cACX;AAAA,cACC,SAAS,IAAI,CAAC,QAAQ,QACrB,gBAAAA,KAAC,eAAuB,GAAG,UAAT,GAAiB,CACpC;AAAA,eACH;AAAA,YAEC,sBACC,gBAAAA,KAAC,eAAY,OAAc,UAAoB;AAAA,YAIhD,eAAe,gBAAAA,KAAC,oBAAkB,uBAAY;AAAA,YAG9C;AAAA;AAAA;AAAA,MACH;AAAA,OACF;AAAA,KACF;AAEJ;AAEA,IAAO,kBAAQ;","names":["React","Dialog","Content","React","Dialog","Box","React","Dialog","styled","jsx","Box","jsx","React","jsx","Content","React","Dialog","Box","jsx","React","Dialog","jsx","Dialog","jsx","React","Dialog","styled","Icon","jsx","jsx","jsxs","e","props"]}
|
package/src/v2/ModalV2.tsx
DELETED
|
@@ -1,388 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import * as Dialog from "@radix-ui/react-dialog";
|
|
3
|
-
import { StyledOverlay, StyledContent } from "./ModalV2Styles";
|
|
4
|
-
import {
|
|
5
|
-
ModalHeader,
|
|
6
|
-
ModalDescription,
|
|
7
|
-
ModalTrigger,
|
|
8
|
-
ModalRail,
|
|
9
|
-
ModalAction,
|
|
10
|
-
} from "./components";
|
|
11
|
-
import {
|
|
12
|
-
DEFAULT_MODAL_WIDTH,
|
|
13
|
-
DEFAULT_MODAL_BG,
|
|
14
|
-
DEFAULT_MODAL_Z_INDEX,
|
|
15
|
-
MODAL_SIZE_PRESETS,
|
|
16
|
-
MODAL_PRIORITY_Z_INDEX,
|
|
17
|
-
} from "../shared/constants";
|
|
18
|
-
import type { TypeModalV2Props } from "./ModalV2Types";
|
|
19
|
-
|
|
20
|
-
interface DraggableModalContentProps {
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
computedWidth: any;
|
|
23
|
-
bg: any;
|
|
24
|
-
computedZIndex: number;
|
|
25
|
-
label?: string;
|
|
26
|
-
dataAttributes: Record<string, string>;
|
|
27
|
-
draggable?: boolean;
|
|
28
|
-
rest: any;
|
|
29
|
-
railProps?: Partial<TypeModalV2Props["railProps"]>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Context to share drag state between modal content and header
|
|
33
|
-
interface DragContextValue {
|
|
34
|
-
position: { x: number; y: number };
|
|
35
|
-
isDragging: boolean;
|
|
36
|
-
onHeaderMouseDown: (e: React.MouseEvent) => void;
|
|
37
|
-
contentRef: React.RefObject<HTMLDivElement>;
|
|
38
|
-
draggable: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const DragContext = React.createContext<DragContextValue | null>(null);
|
|
42
|
-
|
|
43
|
-
export const useDragContext = () => {
|
|
44
|
-
const context = React.useContext(DragContext);
|
|
45
|
-
return context;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const DraggableModalContent: React.FC<DraggableModalContentProps> = ({
|
|
49
|
-
children,
|
|
50
|
-
computedWidth,
|
|
51
|
-
bg,
|
|
52
|
-
computedZIndex,
|
|
53
|
-
label,
|
|
54
|
-
dataAttributes,
|
|
55
|
-
draggable,
|
|
56
|
-
rest,
|
|
57
|
-
railProps,
|
|
58
|
-
}) => {
|
|
59
|
-
const [position, setPosition] = React.useState({ x: 0, y: 0 });
|
|
60
|
-
const [isDragging, setIsDragging] = React.useState(false);
|
|
61
|
-
const contentRef = React.useRef<HTMLDivElement>(null);
|
|
62
|
-
|
|
63
|
-
// Calculate rail dimensions for boundary constraints
|
|
64
|
-
const railSize = railProps?.size ?? 44;
|
|
65
|
-
const railOffset = railProps?.offset ?? 12;
|
|
66
|
-
const railSide = railProps?.side ?? "right";
|
|
67
|
-
|
|
68
|
-
// Total extra space needed on the side with the rail
|
|
69
|
-
// (only when viewport is wider than 400px breakpoint)
|
|
70
|
-
const railExtraSpace = railSize + railOffset;
|
|
71
|
-
|
|
72
|
-
const handleHeaderMouseDown = React.useCallback(
|
|
73
|
-
(e: React.MouseEvent) => {
|
|
74
|
-
if (!draggable) return;
|
|
75
|
-
|
|
76
|
-
// Only allow dragging from header (not interactive elements)
|
|
77
|
-
const target = e.target as HTMLElement;
|
|
78
|
-
if (
|
|
79
|
-
target.tagName === "BUTTON" ||
|
|
80
|
-
target.tagName === "INPUT" ||
|
|
81
|
-
target.closest("button")
|
|
82
|
-
) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
e.preventDefault();
|
|
87
|
-
setIsDragging(true);
|
|
88
|
-
|
|
89
|
-
const rect = contentRef.current?.getBoundingClientRect();
|
|
90
|
-
if (!rect) return;
|
|
91
|
-
|
|
92
|
-
// Calculate offset from mouse to current modal position
|
|
93
|
-
const offsetX = e.clientX - rect.left;
|
|
94
|
-
const offsetY = e.clientY - rect.top;
|
|
95
|
-
|
|
96
|
-
const handleMouseMove = (e: MouseEvent) => {
|
|
97
|
-
e.preventDefault();
|
|
98
|
-
|
|
99
|
-
// Calculate new position based on mouse position minus offset
|
|
100
|
-
const newX = e.clientX - offsetX;
|
|
101
|
-
const newY = e.clientY - offsetY;
|
|
102
|
-
|
|
103
|
-
// Determine if rail is on the side (viewport > 400px) or above (viewport <= 400px)
|
|
104
|
-
const isRailOnSide = window.innerWidth > 400;
|
|
105
|
-
|
|
106
|
-
// Constrain to viewport bounds (keeping modal AND rail fully visible)
|
|
107
|
-
const modalWidth = rect.width;
|
|
108
|
-
const modalHeight = rect.height;
|
|
109
|
-
|
|
110
|
-
// Adjust boundaries to account for rail position
|
|
111
|
-
let maxX = window.innerWidth - modalWidth;
|
|
112
|
-
let minX = 0;
|
|
113
|
-
let maxY = window.innerHeight - modalHeight;
|
|
114
|
-
let minY = 0;
|
|
115
|
-
|
|
116
|
-
if (isRailOnSide) {
|
|
117
|
-
// Rail is positioned on the side of the modal
|
|
118
|
-
if (railSide === "right") {
|
|
119
|
-
// Rail is on the right, so reduce maxX to prevent rail from going off-screen
|
|
120
|
-
maxX = window.innerWidth - modalWidth - railExtraSpace;
|
|
121
|
-
} else {
|
|
122
|
-
// Rail is on the left, so increase minX to prevent rail from going off-screen
|
|
123
|
-
minX = railExtraSpace;
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
// Rail is positioned above the modal (viewport <= 400px)
|
|
127
|
-
// Account for rail height + offset at the top
|
|
128
|
-
minY = railSize + railOffset;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const constrainedX = Math.max(minX, Math.min(maxX, newX));
|
|
132
|
-
const constrainedY = Math.max(minY, Math.min(maxY, newY));
|
|
133
|
-
|
|
134
|
-
// Convert to offset from center for our transform
|
|
135
|
-
const centerX = window.innerWidth / 2 - modalWidth / 2;
|
|
136
|
-
const centerY = window.innerHeight / 2 - modalHeight / 2;
|
|
137
|
-
|
|
138
|
-
setPosition({
|
|
139
|
-
x: constrainedX - centerX,
|
|
140
|
-
y: constrainedY - centerY,
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const handleMouseUp = () => {
|
|
145
|
-
setIsDragging(false);
|
|
146
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
147
|
-
document.removeEventListener("mouseup", handleMouseUp);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
151
|
-
document.addEventListener("mouseup", handleMouseUp);
|
|
152
|
-
},
|
|
153
|
-
[draggable, railSide, railExtraSpace]
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
const dragContextValue = React.useMemo<DragContextValue>(
|
|
157
|
-
() => ({
|
|
158
|
-
position,
|
|
159
|
-
isDragging,
|
|
160
|
-
onHeaderMouseDown: handleHeaderMouseDown,
|
|
161
|
-
contentRef,
|
|
162
|
-
draggable: draggable ?? false,
|
|
163
|
-
}),
|
|
164
|
-
[position, isDragging, handleHeaderMouseDown, draggable]
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
// Prevent modal from closing on outside interaction when draggable
|
|
168
|
-
const handleInteractOutside = React.useCallback(
|
|
169
|
-
(e: Event) => {
|
|
170
|
-
if (draggable) {
|
|
171
|
-
e.preventDefault();
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
[draggable]
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<DragContext.Provider value={draggable ? dragContextValue : null}>
|
|
179
|
-
<StyledContent
|
|
180
|
-
ref={contentRef}
|
|
181
|
-
width={computedWidth}
|
|
182
|
-
bg={bg}
|
|
183
|
-
zIndex={computedZIndex}
|
|
184
|
-
aria-label={label}
|
|
185
|
-
draggable={draggable}
|
|
186
|
-
isDragging={isDragging}
|
|
187
|
-
railSize={railSize}
|
|
188
|
-
railOffset={railOffset}
|
|
189
|
-
railSide={railSide}
|
|
190
|
-
onInteractOutside={handleInteractOutside}
|
|
191
|
-
style={
|
|
192
|
-
draggable
|
|
193
|
-
? {
|
|
194
|
-
transform: `translate(calc(-50% + ${position.x}px), calc(-50% + ${position.y}px))`,
|
|
195
|
-
transition: isDragging ? "none" : undefined,
|
|
196
|
-
}
|
|
197
|
-
: undefined
|
|
198
|
-
}
|
|
199
|
-
{...dataAttributes}
|
|
200
|
-
{...rest}
|
|
201
|
-
>
|
|
202
|
-
{children}
|
|
203
|
-
</StyledContent>
|
|
204
|
-
</DragContext.Provider>
|
|
205
|
-
);
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* The modal you want - with Radix UI Dialog
|
|
210
|
-
*
|
|
211
|
-
* Features:
|
|
212
|
-
* - Built with Radix UI Dialog for superior accessibility
|
|
213
|
-
* - Same API as the original Modal component
|
|
214
|
-
* - Automatic focus management and keyboard navigation
|
|
215
|
-
* - Portal rendering for proper z-index layering
|
|
216
|
-
* - Customizable styling through system props
|
|
217
|
-
* - Optional draggable functionality using react-dnd
|
|
218
|
-
*/
|
|
219
|
-
const Modal = (props: TypeModalV2Props) => {
|
|
220
|
-
const {
|
|
221
|
-
children,
|
|
222
|
-
modalTrigger,
|
|
223
|
-
draggable = false,
|
|
224
|
-
open,
|
|
225
|
-
defaultOpen,
|
|
226
|
-
onOpenChange,
|
|
227
|
-
"aria-label": label,
|
|
228
|
-
title,
|
|
229
|
-
subtitle,
|
|
230
|
-
description,
|
|
231
|
-
size,
|
|
232
|
-
priority,
|
|
233
|
-
data = {},
|
|
234
|
-
bg = DEFAULT_MODAL_BG,
|
|
235
|
-
showOverlay = true,
|
|
236
|
-
actions,
|
|
237
|
-
railProps,
|
|
238
|
-
...rest
|
|
239
|
-
} = props;
|
|
240
|
-
|
|
241
|
-
const handleOpenChange = React.useCallback(
|
|
242
|
-
(newOpen: boolean) => {
|
|
243
|
-
onOpenChange?.(newOpen);
|
|
244
|
-
},
|
|
245
|
-
[onOpenChange]
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
// Compute actual width
|
|
249
|
-
const computedWidth = React.useMemo(() => {
|
|
250
|
-
if (size) {
|
|
251
|
-
// Handle preset sizes
|
|
252
|
-
if (typeof size === "string" && size in MODAL_SIZE_PRESETS) {
|
|
253
|
-
return MODAL_SIZE_PRESETS[size as keyof typeof MODAL_SIZE_PRESETS];
|
|
254
|
-
}
|
|
255
|
-
// Handle custom size values
|
|
256
|
-
return size;
|
|
257
|
-
}
|
|
258
|
-
// Fall back to default width
|
|
259
|
-
return DEFAULT_MODAL_WIDTH;
|
|
260
|
-
}, [size]);
|
|
261
|
-
|
|
262
|
-
// Compute actual z-index
|
|
263
|
-
const computedZIndex = React.useMemo(() => {
|
|
264
|
-
if (priority) {
|
|
265
|
-
return MODAL_PRIORITY_Z_INDEX[priority];
|
|
266
|
-
}
|
|
267
|
-
return DEFAULT_MODAL_Z_INDEX;
|
|
268
|
-
}, [priority]);
|
|
269
|
-
|
|
270
|
-
// Create data attributes object
|
|
271
|
-
const dataAttributes = React.useMemo(() => {
|
|
272
|
-
const attrs: Record<string, string> = {};
|
|
273
|
-
Object.entries(data).forEach(([key, value]) => {
|
|
274
|
-
attrs[`data-${key}`] = String(value);
|
|
275
|
-
});
|
|
276
|
-
attrs["data-qa-modal"] = "";
|
|
277
|
-
// Only add open attribute if in controlled mode
|
|
278
|
-
if (open !== undefined) {
|
|
279
|
-
attrs["data-qa-modal-open"] = String(open);
|
|
280
|
-
}
|
|
281
|
-
return attrs;
|
|
282
|
-
}, [data, open]);
|
|
283
|
-
|
|
284
|
-
// Determine if we should auto-render the header from provided props
|
|
285
|
-
const shouldRenderHeader = Boolean(title || subtitle);
|
|
286
|
-
|
|
287
|
-
// Build Dialog.Root props conditionally
|
|
288
|
-
const dialogRootProps = React.useMemo(() => {
|
|
289
|
-
const props: any = {};
|
|
290
|
-
|
|
291
|
-
// If controlled (open prop provided), use it
|
|
292
|
-
if (open !== undefined) {
|
|
293
|
-
props.open = open;
|
|
294
|
-
}
|
|
295
|
-
// If uncontrolled with explicit defaultOpen, use it
|
|
296
|
-
else if (defaultOpen !== undefined) {
|
|
297
|
-
props.defaultOpen = defaultOpen;
|
|
298
|
-
}
|
|
299
|
-
// If completely uncontrolled (neither open nor defaultOpen provided), default to closed
|
|
300
|
-
else {
|
|
301
|
-
props.defaultOpen = false;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Always add onOpenChange if provided
|
|
305
|
-
if (onOpenChange) {
|
|
306
|
-
props.onOpenChange = handleOpenChange;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// When draggable, prevent modal from closing on outside interaction
|
|
310
|
-
// This allows users to interact with background content
|
|
311
|
-
if (draggable) {
|
|
312
|
-
props.modal = false;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return props;
|
|
316
|
-
}, [open, defaultOpen, handleOpenChange, onOpenChange, draggable]);
|
|
317
|
-
|
|
318
|
-
// Handle trigger - use modalTrigger prop if provided, otherwise look for ModalTrigger children (backward compatibility)
|
|
319
|
-
const triggers: React.ReactNode[] = [];
|
|
320
|
-
const content: React.ReactNode[] = [];
|
|
321
|
-
|
|
322
|
-
if (modalTrigger) {
|
|
323
|
-
// New prop-based approach: wrap the provided element with Dialog.Trigger
|
|
324
|
-
triggers.push(
|
|
325
|
-
<Dialog.Trigger key="modal-trigger" asChild>
|
|
326
|
-
{modalTrigger}
|
|
327
|
-
</Dialog.Trigger>
|
|
328
|
-
);
|
|
329
|
-
// All children are content
|
|
330
|
-
content.push(children);
|
|
331
|
-
} else {
|
|
332
|
-
// Legacy approach: separate ModalTrigger children from content children
|
|
333
|
-
React.Children.forEach(children, (child) => {
|
|
334
|
-
if (React.isValidElement(child) && child.type === ModalTrigger) {
|
|
335
|
-
triggers.push(child);
|
|
336
|
-
} else {
|
|
337
|
-
content.push(child);
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
return (
|
|
343
|
-
<Dialog.Root {...dialogRootProps}>
|
|
344
|
-
{/* Render triggers as direct children of Dialog.Root */}
|
|
345
|
-
{triggers}
|
|
346
|
-
|
|
347
|
-
<Dialog.Portal>
|
|
348
|
-
{showOverlay && (
|
|
349
|
-
<StyledOverlay zIndex={computedZIndex} allowInteraction={draggable} />
|
|
350
|
-
)}
|
|
351
|
-
<DraggableModalContent
|
|
352
|
-
computedWidth={computedWidth}
|
|
353
|
-
bg={bg}
|
|
354
|
-
computedZIndex={computedZIndex}
|
|
355
|
-
label={label}
|
|
356
|
-
dataAttributes={dataAttributes}
|
|
357
|
-
draggable={draggable}
|
|
358
|
-
rest={rest}
|
|
359
|
-
railProps={railProps}
|
|
360
|
-
>
|
|
361
|
-
{/* Floating actions rail - always show a close by default */}
|
|
362
|
-
<ModalRail {...railProps}>
|
|
363
|
-
<ModalAction
|
|
364
|
-
actionType="close"
|
|
365
|
-
aria-label="Close"
|
|
366
|
-
iconName="x-outline"
|
|
367
|
-
/>
|
|
368
|
-
{actions?.map((action, idx) => (
|
|
369
|
-
<ModalAction key={idx} {...action} />
|
|
370
|
-
))}
|
|
371
|
-
</ModalRail>
|
|
372
|
-
{/* Auto-render header when title or subtitle is provided */}
|
|
373
|
-
{shouldRenderHeader && (
|
|
374
|
-
<ModalHeader title={title} subtitle={subtitle} />
|
|
375
|
-
)}
|
|
376
|
-
|
|
377
|
-
{/* Auto-render description when provided */}
|
|
378
|
-
{description && <ModalDescription>{description}</ModalDescription>}
|
|
379
|
-
|
|
380
|
-
{/* Main content (everything except triggers) */}
|
|
381
|
-
{content}
|
|
382
|
-
</DraggableModalContent>
|
|
383
|
-
</Dialog.Portal>
|
|
384
|
-
</Dialog.Root>
|
|
385
|
-
);
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
export default Modal;
|
package/src/v2/ModalV2Styles.tsx
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
import { width, zIndex } from "styled-system";
|
|
4
|
-
import * as Dialog from "@radix-ui/react-dialog";
|
|
5
|
-
import { COMMON } from "@sproutsocial/seeds-react-system-props";
|
|
6
|
-
import Box, { type TypeContainerProps } from "@sproutsocial/seeds-react-box";
|
|
7
|
-
import {
|
|
8
|
-
BODY_PADDING,
|
|
9
|
-
DEFAULT_OVERLAY_Z_INDEX_OFFSET,
|
|
10
|
-
} from "../shared/constants";
|
|
11
|
-
|
|
12
|
-
interface StyledOverlayProps extends TypeContainerProps {
|
|
13
|
-
zIndex?: number;
|
|
14
|
-
allowInteraction?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const StyledOverlay = styled(Dialog.Overlay)<StyledOverlayProps>`
|
|
18
|
-
position: fixed;
|
|
19
|
-
top: 0px;
|
|
20
|
-
left: 0px;
|
|
21
|
-
right: 0px;
|
|
22
|
-
bottom: 0px;
|
|
23
|
-
background-color: ${(props) => props.theme.colors.overlay.background.base};
|
|
24
|
-
opacity: 0;
|
|
25
|
-
will-change: opacity;
|
|
26
|
-
transition: opacity ${(props) => props.theme.duration.medium}
|
|
27
|
-
${(props) => props.theme.easing.ease_inout};
|
|
28
|
-
z-index: ${(props) =>
|
|
29
|
-
props.zIndex ? props.zIndex + DEFAULT_OVERLAY_Z_INDEX_OFFSET : 999};
|
|
30
|
-
|
|
31
|
-
/* Allow clicking through overlay when modal is draggable */
|
|
32
|
-
${(props) =>
|
|
33
|
-
props.allowInteraction &&
|
|
34
|
-
`
|
|
35
|
-
pointer-events: none;
|
|
36
|
-
`}
|
|
37
|
-
|
|
38
|
-
${zIndex}
|
|
39
|
-
|
|
40
|
-
&[data-state="open"] {
|
|
41
|
-
opacity: 1;
|
|
42
|
-
}
|
|
43
|
-
&[data-state="closed"] {
|
|
44
|
-
opacity: 0;
|
|
45
|
-
}
|
|
46
|
-
`;
|
|
47
|
-
|
|
48
|
-
interface StyledContentProps extends TypeContainerProps {
|
|
49
|
-
zIndex?: number;
|
|
50
|
-
isDragging?: boolean;
|
|
51
|
-
draggable?: boolean;
|
|
52
|
-
railSize?: number;
|
|
53
|
-
railOffset?: number;
|
|
54
|
-
railSide?: "right" | "left";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const StyledContent = styled(Dialog.Content)<StyledContentProps>`
|
|
58
|
-
position: fixed;
|
|
59
|
-
${(props) =>
|
|
60
|
-
props.draggable
|
|
61
|
-
? `
|
|
62
|
-
top: 50%;
|
|
63
|
-
left: 50%;
|
|
64
|
-
transform: translate(-50%, -50%);
|
|
65
|
-
`
|
|
66
|
-
: `
|
|
67
|
-
top: 50%;
|
|
68
|
-
left: 50%;
|
|
69
|
-
transform: translate(-50%, -50%);
|
|
70
|
-
`}
|
|
71
|
-
display: flex;
|
|
72
|
-
flex-direction: column;
|
|
73
|
-
border-radius: ${(props) => props.theme.radii[600]};
|
|
74
|
-
box-shadow: ${(props) => props.theme.shadows.medium};
|
|
75
|
-
filter: blur(0);
|
|
76
|
-
color: ${(props) => props.theme.colors.text.body};
|
|
77
|
-
outline: none;
|
|
78
|
-
max-width: ${(props) => {
|
|
79
|
-
// Calculate extra space needed for the rail when it's on the side (viewport > 400px)
|
|
80
|
-
const railSize = props.railSize ?? 44;
|
|
81
|
-
const railOffset = props.railOffset ?? 12;
|
|
82
|
-
const railExtraSpace = railSize + railOffset;
|
|
83
|
-
|
|
84
|
-
// Account for rail space when positioned on the side
|
|
85
|
-
// At viewport <= 400px, rail is above modal, so no horizontal space needed
|
|
86
|
-
return `calc(100vw - ${BODY_PADDING} - ${railExtraSpace}px)`;
|
|
87
|
-
}};
|
|
88
|
-
max-height: calc(100vh - ${BODY_PADDING});
|
|
89
|
-
z-index: ${(props) => props.zIndex || 1000};
|
|
90
|
-
|
|
91
|
-
/* When viewport is <= 400px, rail is above modal, so restore full width */
|
|
92
|
-
@media (max-width: 400px) {
|
|
93
|
-
max-width: calc(100vw - ${BODY_PADDING});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
|
97
|
-
height: calc(100vh - ${BODY_PADDING});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
${width}
|
|
101
|
-
${COMMON}
|
|
102
|
-
|
|
103
|
-
/* Enhanced Radix Dialog animations */
|
|
104
|
-
opacity: 0;
|
|
105
|
-
${(props) =>
|
|
106
|
-
!props.draggable
|
|
107
|
-
? `
|
|
108
|
-
transform: translate(-50%, -50%) scale(0.95);
|
|
109
|
-
transition: opacity ${props.theme.duration.medium} ${props.theme.easing.ease_inout},
|
|
110
|
-
transform ${props.theme.duration.medium} ${props.theme.easing.ease_inout};
|
|
111
|
-
`
|
|
112
|
-
: `
|
|
113
|
-
transition: opacity ${props.theme.duration.medium} ${props.theme.easing.ease_inout};
|
|
114
|
-
`}
|
|
115
|
-
|
|
116
|
-
&[data-state="open"] {
|
|
117
|
-
opacity: 1;
|
|
118
|
-
${(props) =>
|
|
119
|
-
!props.draggable ? `transform: translate(-50%, -50%) scale(1);` : ``}
|
|
120
|
-
}
|
|
121
|
-
&[data-state="closed"] {
|
|
122
|
-
opacity: 0;
|
|
123
|
-
${(props) =>
|
|
124
|
-
!props.draggable ? `transform: translate(-50%, -50%) scale(0.95);` : ``}
|
|
125
|
-
}
|
|
126
|
-
`;
|
|
127
|
-
|
|
128
|
-
export const Content = styled(Box)`
|
|
129
|
-
font-family: ${(props) => props.theme.fontFamily};
|
|
130
|
-
min-height: 80px;
|
|
131
|
-
overflow-y: auto;
|
|
132
|
-
flex: 1 1 auto;
|
|
133
|
-
padding: 0 ${(props) => props.theme.space[300]}
|
|
134
|
-
${(props) => props.theme.space[300]} ${(props) => props.theme.space[300]};
|
|
135
|
-
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
|
136
|
-
flex-basis: 100%;
|
|
137
|
-
}
|
|
138
|
-
`;
|
|
139
|
-
|
|
140
|
-
interface HeaderProps {
|
|
141
|
-
draggable?: boolean;
|
|
142
|
-
isDragging?: boolean;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export const Header = styled(Box)<HeaderProps>`
|
|
146
|
-
font-family: ${(props) => props.theme.fontFamily};
|
|
147
|
-
padding: ${(props) => props.theme.space[400]}
|
|
148
|
-
${(props) => props.theme.space[300]};
|
|
149
|
-
display: flex;
|
|
150
|
-
align-items: center;
|
|
151
|
-
justify-content: space-between;
|
|
152
|
-
flex: 0 0 auto;
|
|
153
|
-
|
|
154
|
-
/* Draggable cursor styling */
|
|
155
|
-
${(props) =>
|
|
156
|
-
props.draggable &&
|
|
157
|
-
`
|
|
158
|
-
cursor: ${props.isDragging ? "grabbing" : "grab"};
|
|
159
|
-
user-select: none;
|
|
160
|
-
`}
|
|
161
|
-
`;
|
|
162
|
-
|
|
163
|
-
export const Footer = styled(Box)`
|
|
164
|
-
flex: 0 0 auto;
|
|
165
|
-
font-family: ${(props) => props.theme.fontFamily};
|
|
166
|
-
padding: ${(props) => props.theme.space[400]}
|
|
167
|
-
${(props) => props.theme.space[300]};
|
|
168
|
-
border-bottom-right-radius: ${(props) => props.theme.radii[500]};
|
|
169
|
-
border-bottom-left-radius: ${(props) => props.theme.radii[500]};
|
|
170
|
-
display: flex;
|
|
171
|
-
align-items: center;
|
|
172
|
-
justify-content: flex-end;
|
|
173
|
-
gap: ${(props) => props.theme.space[100]};
|
|
174
|
-
`;
|
|
175
|
-
|
|
176
|
-
StyledOverlay.displayName = "ModalOverlay";
|
|
177
|
-
StyledContent.displayName = "ModalContent";
|
|
178
|
-
Content.displayName = "ModalContent";
|
|
179
|
-
Header.displayName = "ModalHeader";
|
|
180
|
-
Footer.displayName = "ModalFooter";
|