@wordpress/components
Version:
UI components for WordPress.
1 lines • 1.35 kB
Source Map (JSON)
{"version":3,"file":"category-select.cjs","names":["useMemo","buildTermsTree","TreeSelect"],"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,aAAA,GAAYA,mBAAAA,QAAAA,OAAe;EAChC,QAAA,GAAOC,WAAAA,eAAAA,CAAgB,cAAe;CACvC,GAAG,CAAE,cAAe,CAAE;CAEtB,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,SAAD;EAEE;EACA;EACA,UAAU;EAEX,MAAO;EACP,YACC,uBAAuB,KAAA,IACpB,OAAQ,kBAAmB,IAC3B,KAAA;EAEJ,GAAK;CACL,CAAA;AAEH"}