{"version":3,"file":"hooks.mjs","names":[],"sources":["../../src/base-control/hooks.ts"],"sourcesContent":["import { useInstanceId } from '@wordpress/compose';\nimport type { BaseControlProps } from './types';\n\n/**\n * Generate props for the `BaseControl` and the inner control itself.\n *\n * Namely, it takes care of generating a unique `id`, properly associating it with the `label` and `help` elements.\n *\n * @param props\n */\nexport function useBaseControlProps(\n\tprops: Omit< BaseControlProps, 'children' >\n) {\n\tconst { help, id: preferredId, ...restProps } = props;\n\n\tconst uniqueId = useInstanceId(\n\t\tuseBaseControlProps,\n\t\t'wp-components-base-control',\n\t\tpreferredId\n\t);\n\n\treturn {\n\t\tbaseControlProps: {\n\t\t\tid: uniqueId,\n\t\t\thelp,\n\t\t\t...restProps,\n\t\t},\n\t\tcontrolProps: {\n\t\t\tid: uniqueId,\n\t\t\t...( !! help ? { 'aria-describedby': `${ uniqueId }__help` } : {} ),\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,oBACf,OACC;CACD,MAAM,EAAE,MAAM,IAAI,aAAa,GAAG,cAAc;CAEhD,MAAM,WAAW,cAChB,qBACA,8BACA,WACD;CAEA,OAAO;EACN,kBAAkB;GACjB,IAAI;GACJ;GACA,GAAG;EACJ;EACA,cAAc;GACb,IAAI;GACJ,GAAK,CAAC,CAAE,OAAO,EAAE,oBAAoB,GAAI,SAAU,QAAQ,IAAI,CAAC;EACjE;CACD;AACD"}