{"version":3,"file":"edit.mjs","names":["useColorProps"],"sources":["../../src/separator/edit.jsx"],"sourcesContent":["import clsx from 'clsx';\nimport {\n\tgetColorClassName,\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalUseColorProps as useColorProps,\n} from '@wordpress/block-editor';\nimport { HorizontalRule } from '@wordpress/components';\nimport { SelectControl } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport useDeprecatedOpacity from './use-deprecated-opacity';\n\nconst HTML_ELEMENT_ITEMS = [\n\t{ label: __( 'Default (<hr>)' ), value: 'hr' },\n\t{ label: '<div>', value: 'div' },\n];\n\nconst HtmlElementControl = ( { tagName = 'hr', setAttributes } ) => {\n\tconst selectedItem =\n\t\tHTML_ELEMENT_ITEMS.find( ( item ) => item.value === tagName ) ??\n\t\tHTML_ELEMENT_ITEMS[ 0 ];\n\n\treturn (\n\t\t<SelectControl\n\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\tvalue={ selectedItem }\n\t\t\tonValueChange={ ( item ) =>\n\t\t\t\tsetAttributes( { tagName: item?.value ?? 'hr' } )\n\t\t\t}\n\t\t\titems={ HTML_ELEMENT_ITEMS }\n\t\t\tdescription={\n\t\t\t\ttagName === 'hr'\n\t\t\t\t\t? __(\n\t\t\t\t\t\t\t'Only select <hr> if the separator conveys important information and should be announced by screen readers.'\n\t\t\t\t\t\t)\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'The <div> element should only be used if the block is a design element with no semantic meaning.'\n\t\t\t\t\t\t)\n\t\t\t}\n\t\t/>\n\t);\n};\n\nexport default function SeparatorEdit( { attributes, setAttributes } ) {\n\tconst { backgroundColor, opacity, style, tagName } = attributes;\n\tconst colorProps = useColorProps( attributes );\n\tconst currentColor = colorProps?.style?.backgroundColor;\n\tconst hasCustomColor = !! style?.color?.background;\n\n\tuseDeprecatedOpacity( opacity, currentColor, setAttributes );\n\n\t// The dots styles uses text for the dots, to change those dots color is\n\t// using color, not backgroundColor.\n\tconst colorClass = getColorClassName( 'color', backgroundColor );\n\n\tconst className = clsx(\n\t\t{\n\t\t\t'has-text-color': backgroundColor || currentColor,\n\t\t\t[ colorClass ]: colorClass,\n\t\t\t'has-css-opacity': opacity === 'css',\n\t\t\t'has-alpha-channel-opacity': opacity === 'alpha-channel',\n\t\t},\n\t\tcolorProps.className\n\t);\n\n\tconst styles = {\n\t\tcolor: currentColor,\n\t\tbackgroundColor: currentColor,\n\t};\n\tconst Wrapper = tagName === 'hr' ? HorizontalRule : tagName;\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t<HtmlElementControl\n\t\t\t\t\ttagName={ tagName }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<Wrapper\n\t\t\t\t{ ...useBlockProps( {\n\t\t\t\t\tclassName,\n\t\t\t\t\tstyle: hasCustomColor ? styles : undefined,\n\t\t\t\t} ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":";;;;;;;;AAYA,MAAM,qBAAqB,CAC1B;CAAE,OAAO,GAAI,gBAAiB;CAAG,OAAO;AAAK,GAC7C;CAAE,OAAO;CAAS,OAAO;AAAM,CAChC;AAEA,MAAM,sBAAuB,EAAE,UAAU,MAAM,oBAAqB;CACnE,MAAM,eACL,mBAAmB,MAAQ,SAAU,KAAK,UAAU,OAAQ,KAC5D,mBAAoB;CAErB,OACC,oBAAC,eAAD;EACC,OAAQ,GAAI,cAAe;EAC3B,OAAQ;EACR,gBAAkB,SACjB,cAAe,EAAE,SAAS,MAAM,SAAS,KAAK,CAAE;EAEjD,OAAQ;EACR,aACC,YAAY,OACT,GACA,4GACD,IACC,GACA,kGACD;CAEH,CAAA;AAEH;AAEA,SAAwB,cAAe,EAAE,YAAY,iBAAkB;CACtE,MAAM,EAAE,iBAAiB,SAAS,OAAO,YAAY;CACrD,MAAM,aAAaA,4BAAe,UAAW;CAC7C,MAAM,eAAe,YAAY,OAAO;CACxC,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