@wordpress/components
Version:
UI components for WordPress.
1 lines • 1.22 kB
Source Map (JSON)
{"version":3,"file":"category-select.mjs","names":[],"sources":["../../src/query-controls/category-select.tsx"],"sourcesContent":["import { useMemo } from '@wordpress/element';\nimport { buildTermsTree } from './terms';\nimport TreeSelect from '../tree-select';\nimport type { CategorySelectProps } from './types';\n\nexport default function CategorySelect( {\n\tlabel,\n\tnoOptionLabel,\n\tcategoriesList,\n\tselectedCategoryId,\n\tonChange: onChangeProp,\n\t...props\n}: CategorySelectProps ) {\n\tconst termsTree = useMemo( () => {\n\t\treturn buildTermsTree( categoriesList );\n\t}, [ categoriesList ] );\n\n\treturn (\n\t\t<TreeSelect\n\t\t\t{ ...{\n\t\t\t\tlabel,\n\t\t\t\tnoOptionLabel,\n\t\t\t\tonChange: onChangeProp,\n\t\t\t} }\n\t\t\ttree={ termsTree }\n\t\t\tselectedId={\n\t\t\t\tselectedCategoryId !== undefined\n\t\t\t\t\t? String( selectedCategoryId )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;AAKA,SAAwB,eAAgB,EACvC,OACA,eACA,gBACA,oBACA,UAAU,cACV,GAAG,SACqB;CACxB,MAAM,YAAY,cAAe;EAChC,OAAO,eAAgB,cAAe;CACvC,GAAG,CAAE,cAAe,CAAE;CAEtB,OACC,oBAAC,YAAD;EAEE;EACA;EACA,UAAU;EAEX,MAAO;EACP,YACC,uBAAuB,KAAA,IACpB,OAAQ,kBAAmB,IAC3B,KAAA;EAEJ,GAAK;CACL,CAAA;AAEH"}