1- import ExclamationIcon from "@heroicons/react/outline/ExclamationIcon " ;
1+ import { Actions , CloseButton } from "../../../shared-admin/components/danger-modal " ;
22import { __ } from "@wordpress/i18n" ;
3- import { Button , Modal , useSvgAria } from "@yoast/ui-library" ;
4- import { noop } from "lodash" ;
3+ import { Button } from "@yoast/ui-library" ;
54import PropTypes from "prop-types" ;
65
7- /**
8- * Wraps the error copy below the title, applying the muted modal-description tone.
9- * The message `Paragraph`s add their own top margin, so the first paragraph sits
10- * just under the title.
11- *
12- * @param {JSX.node } children The copy (message `Body`).
13- * @returns {JSX.Element } The element.
14- */
15- export const ModalDescription = ( { children } ) => (
16- < div className = "yst-mt-1 yst-text-sm yst-text-slate-500" >
17- { children }
18- </ div >
19- ) ;
20- ModalDescription . propTypes = { children : PropTypes . node . isRequired } ;
21-
22- /**
23- * The button row shown at the bottom of an error modal.
24- *
25- * @param {JSX.node } children The buttons.
26- * @returns {JSX.Element } The element.
27- */
28- export const Actions = ( { children } ) => (
29- < div className = "yst-mt-6 yst-flex yst-flex-row yst-justify-end yst-gap-3" >
30- { children }
31- </ div >
32- ) ;
33- Actions . propTypes = { children : PropTypes . node . isRequired } ;
34-
35- /**
36- * A "Close" button that dismisses the modal.
37- *
38- * @param {function } onClose Dismisses the modal.
39- * @returns {JSX.Element } The element.
40- */
41- export const CloseButton = ( { onClose } ) => (
42- < Button variant = "secondary" onClick = { onClose } >
43- { __ ( "Close" , "wordpress-seo" ) }
44- </ Button >
45- ) ;
46- CloseButton . propTypes = { onClose : PropTypes . func . isRequired } ;
47-
486/**
497 * The action row for retryable errors: always a Close button, plus a Try again
508 * when `showActions` is set (a retryable context such as a timeout or a failed
@@ -71,47 +29,4 @@ RetryableActions.propTypes = {
7129 onClose : PropTypes . func . isRequired ,
7230} ;
7331
74- /**
75- * The "Danger modal" shell every AI error shares: a centered modal panel with the
76- * rose-circle outline exclamation icon, the resolved title, and a dismiss control.
77- *
78- * @param {boolean } isOpen Whether the modal is open.
79- * @param {string } title The modal title.
80- * @param {function } [onClose=noop] Dismisses the modal.
81- * @param {JSX.node } children The modal body (copy + actions).
82- * @returns {JSX.Element } The element.
83- */
84- export const DangerModal = ( { isOpen, title, onClose = noop , children } ) => {
85- const svgAriaProps = useSvgAria ( ) ;
86-
87- return (
88- < Modal isOpen = { isOpen } onClose = { onClose } >
89- < Modal . Panel className = "yst-max-w-lg" closeButtonScreenReaderText = { __ ( "Dismiss" , "wordpress-seo" ) } >
90- { /*
91- * An unconditional row (icon | title + body), not the `sm:`-gated
92- * stack-then-row other danger modals use. This modal is portaled inside
93- * the block editor, where the viewport `sm` breakpoint does not match
94- * reliably; gating the layout on it leaves the modal stuck stacked and
95- * centered. Mirrors `ReplaceContentModal`, which renders in the same context.
96- */ }
97- < div className = "yst-flex yst-items-start yst-gap-4" >
98- < div className = "yst-flex-shrink-0 yst-flex yst-items-center yst-justify-center yst-h-10 yst-w-10 yst-rounded-full yst-bg-red-100" >
99- < ExclamationIcon className = "yst-h-6 yst-w-6 yst-text-red-600" { ...svgAriaProps } />
100- </ div >
101- < div className = "yst-text-start yst-flex-1 yst-min-w-0" >
102- < Modal . Title className = "yst-text-lg yst-leading-6 yst-font-medium yst-text-slate-900" >
103- { title }
104- </ Modal . Title >
105- { children }
106- </ div >
107- </ div >
108- </ Modal . Panel >
109- </ Modal >
110- ) ;
111- } ;
112- DangerModal . propTypes = {
113- isOpen : PropTypes . bool . isRequired ,
114- title : PropTypes . string . isRequired ,
115- onClose : PropTypes . func ,
116- children : PropTypes . node . isRequired ,
117- } ;
32+ export { DangerModal , CloseButton , Actions , ModalDescription } from "../../../shared-admin/components/danger-modal" ;
0 commit comments