{"version":3,"file":"hook.mjs","names":[],"sources":["../../src/heading/hook.ts"],"sourcesContent":["import type { WordPressComponentProps } from '../context';\nimport { useContextSystem } from '../context';\nimport { useText } from '../text';\nimport { getHeadingFontSize } from '../utils/font-size';\nimport type { HeadingProps } from './types';\n\nexport function useHeading(\n\tprops: WordPressComponentProps< HeadingProps, 'h1' >\n) {\n\tconst {\n\t\tas: asProp,\n\t\tlevel = 2,\n\t\tcolor,\n\t\tisBlock = true,\n\t\tweight = 'var(--wpds-typography-font-weight-emphasis)',\n\t\t...otherProps\n\t} = useContextSystem( props, 'Heading' );\n\n\tconst as = ( asProp || `h${ level }` ) as keyof React.JSX.IntrinsicElements;\n\n\tconst a11yProps: {\n\t\trole?: string;\n\t\t'aria-level'?: number;\n\t} = {};\n\tif ( typeof as === 'string' && as[ 0 ] !== 'h' ) {\n\t\t// If not a semantic `h` element, add a11y props:\n\t\ta11yProps.role = 'heading';\n\t\ta11yProps[ 'aria-level' ] =\n\t\t\ttypeof level === 'string' ? parseInt( level ) : level;\n\t}\n\n\tconst textProps = useText( {\n\t\tcolor,\n\t\tisBlock,\n\t\tweight,\n\t\tsize: getHeadingFontSize( level ),\n\t\t...otherProps,\n\t} );\n\n\treturn { ...textProps, ...a11yProps, as };\n}\n"],"mappings":";;;;AAMA,SAAgB,WACf,OACC;CACD,MAAM,EACL,IAAI,QACJ,QAAQ,GACR,OACA,UAAU,MACV,SAAS,oDACT,GAAG,eACA,iBAAkB,OAAO,SAAU;CAEvC,MAAM,KAAO,UAAU,IAAK;CAE5B,MAAM,YAGF,CAAC;CACL,IAAK,OAAO,OAAO,YAAY,GAAI,OAAQ,KAAM;EAEhD,UAAU,OAAO;EACjB,UAAW,gBACV,OAAO,UAAU,WAAW,SAAU,KAAM,IAAI;CAClD;CAUA,OAAO;EAAE,GARS,QAAS;GAC1B;GACA;GACA;GACA,MAAM,mBAAoB,KAAM;GAChC,GAAG;EACJ,CAEoB;EAAG,GAAG;EAAW;CAAG;AACzC"}