{"version":3,"file":"dialog-wrapper.mjs","names":[],"sources":["../../../src/navigation-link/link-ui/dialog-wrapper.jsx"],"sourcesContent":["import { Button } from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { useInstanceId, useFocusOnMount } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\n\n/**\n * Shared BackButton component for consistent navigation across LinkUI sub-components.\n *\n * @param {Object}   props           Component props.\n * @param {string}   props.className CSS class name for the button.\n * @param {Function} props.onBack    Callback when user wants to go back.\n */\nfunction BackButton( { className, onBack } ) {\n\treturn (\n\t\t<Button\n\t\t\tclassName={ className }\n\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\tonClick={ ( e ) => {\n\t\t\t\te.preventDefault();\n\t\t\t\tonBack();\n\t\t\t} }\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t{ __( 'Back' ) }\n\t\t</Button>\n\t);\n}\n\n/**\n * Shared DialogWrapper component for consistent dialog structure across LinkUI sub-components.\n *\n * @param {Object}   props             Component props.\n * @param {string}   props.className   CSS class name for the dialog container.\n * @param {string}   props.title       Dialog title for accessibility.\n * @param {string}   props.description Dialog description for accessibility.\n * @param {Function} props.onBack      Callback when user wants to go back.\n * @param {Object}   props.children    Child components to render inside the dialog.\n */\nfunction DialogWrapper( { className, title, description, onBack, children } ) {\n\tconst dialogTitleId = useInstanceId(\n\t\tDialogWrapper,\n\t\t'link-ui-dialog-title'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tDialogWrapper,\n\t\t'link-ui-dialog-description'\n\t);\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst backButtonClassName = `${ className }__back`;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ className }\n\t\t\trole=\"dialog\"\n\t\t\taria-labelledby={ dialogTitleId }\n\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\tref={ focusOnMountRef }\n\t\t>\n\t\t\t<VisuallyHidden>\n\t\t\t\t<h2 id={ dialogTitleId }>{ title }</h2>\n\t\t\t\t<p id={ dialogDescriptionId }>{ description }</p>\n\t\t\t</VisuallyHidden>\n\n\t\t\t<BackButton className={ backButtonClassName } onBack={ onBack } />\n\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default DialogWrapper;\n"],"mappings":";;;;;;;;;;;;;;AAaA,SAAS,WAAY,EAAE,WAAW,UAAW;CAC5C,OACC,oBAAC,QAAD;EACa;EACZ,MAAO,MAAM,IAAI,oBAAoB;EACrC,UAAY,MAAO;GAClB,EAAE,eAAe;GACjB,OAAO;EACR;EACA,MAAK;EAEH,UAAA,GAAI,MAAO;CACN,CAAA;AAEV;;;;;;;;;;;AAYA,SAAS,cAAe,EAAE,WAAW,OAAO,aAAa,QAAQ,YAAa;CAC7E,MAAM,gBAAgB,cACrB,eACA,sBACD;CACA,MAAM,sBAAsB,cAC3B,eACA,4BACD;CACA,MAAM,kBAAkB,gBAAiB,cAAe;CACxD,MAAM,sBAAsB,GAAI,UAAW;CAE3C,OACC,qBAAC,OAAD;EACa;EACZ,MAAK;EACL,mBAAkB;EAClB,oBAAmB;EACnB,KAAM;EALP,UAAA;GAOC,qBAAC,gBAAD,EAAA,UAAA,CACC,oBAAC,MAAD;IAAI,IAAK;IAAkB,UAAA;GAAW,CAAA,GACtC,oBAAC,KAAD;IAAG,IAAK;IAAwB,UAAA;GAAgB,CAAA,CACjC,EAAA,CAAA;GAEhB,oBAAC,YAAD;IAAY,WAAY;IAA+B;GAAU,CAAA;GAE/D;EACE;;AAEP"}