@wordpress/block-library
Version:
Block library for the WordPress editor.
1 lines • 3.58 kB
Source Map (JSON)
{"version":3,"file":"dialog-wrapper.cjs","names":["Button","isRTL","chevronRightSmall","chevronLeftSmall","__","useInstanceId","useFocusOnMount","VisuallyHidden"],"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,iBAAA,GAAA,kBAAA,IAAA,CAACA,sBAAAA,QAAD;EACa;EACZ,OAAA,GAAOC,gBAAAA,MAAAA,CAAM,IAAIC,iBAAAA,oBAAoBC,iBAAAA;EACrC,UAAY,MAAO;GAClB,EAAE,eAAe;GACjB,OAAO;EACR;EACA,MAAK;EAEHC,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,MAAO;CACN,CAAA;AAEV;;;;;;;;;;;AAYA,SAAS,cAAe,EAAE,WAAW,OAAO,aAAa,QAAQ,YAAa;CAC7E,MAAM,iBAAA,GAAgBC,mBAAAA,cAAAA,CACrB,eACA,sBACD;CACA,MAAM,uBAAA,GAAsBA,mBAAAA,cAAAA,CAC3B,eACA,4BACD;CACA,MAAM,mBAAA,GAAkBC,mBAAAA,gBAAAA,CAAiB,cAAe;CACxD,MAAM,sBAAsB,GAAI,UAAW;CAE3C,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EACa;EACZ,MAAK;EACL,mBAAkB;EAClB,oBAAmB;EACnB,KAAM;EALP,UAAA;GAOC,iBAAA,GAAA,kBAAA,KAAA,CAACC,cAAAA,gBAAD,EAAA,UAAA,CACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;IAAI,IAAK;IAAkB,UAAA;GAAW,CAAA,GACtC,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IAAG,IAAK;IAAwB,UAAA;GAAgB,CAAA,CACjC,EAAA,CAAA;GAEhB,iBAAA,GAAA,kBAAA,IAAA,CAAC,YAAD;IAAY,WAAY;IAA+B;GAAU,CAAA;GAE/D;EACE;;AAEP"}