diff --git a/packages/editor/README.md b/packages/editor/README.md index 0a1da1e0723ed1..634b16a29971e7 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -1296,15 +1296,42 @@ _Returns_ ### PostTaxonomies -Undocumented declaration. +Renders the taxonomies associated with a post. + +_Parameters_ + +- _props_ `Object`: The component props. +- _props.taxonomyWrapper_ `Function`: The wrapper function for each taxonomy component. + +_Returns_ + +- `Array`: An array of JSX elements representing the visible taxonomies. ### PostTaxonomiesCheck -Undocumented declaration. +Renders the children components only if the current post type has taxonomies. + +_Parameters_ + +- _props_ `Object`: The component props. +- _props.children_ `Element`: The children components to render. + +_Returns_ + +- `Component|null`: The rendered children components or null if the current post type has no taxonomies. ### PostTaxonomiesFlatTermSelector -Undocumented declaration. +Renders a flat term selector component. + +_Parameters_ + +- _props_ `Object`: The component props. +- _props.slug_ `string`: The slug of the taxonomy. + +_Returns_ + +- `JSX.Element`: The rendered flat term selector component. ### PostTaxonomiesHierarchicalTermSelector @@ -1321,7 +1348,17 @@ _Returns_ ### PostTaxonomiesPanel -Undocumented declaration. +Renders a panel for a specific taxonomy. + +_Parameters_ + +- _props_ `Object`: The component props. +- _props.taxonomy_ `Object`: The taxonomy object. +- _props.children_ `Element`: The child components. + +_Returns_ + +- `Component`: The rendered taxonomy panel. ### PostTemplatePanel diff --git a/packages/editor/src/components/post-taxonomies/check.js b/packages/editor/src/components/post-taxonomies/check.js index c5621d724cd83b..401b1adad7cad4 100644 --- a/packages/editor/src/components/post-taxonomies/check.js +++ b/packages/editor/src/components/post-taxonomies/check.js @@ -9,6 +9,14 @@ import { store as coreStore } from '@wordpress/core-data'; */ import { store as editorStore } from '../../store'; +/** + * Renders the children components only if the current post type has taxonomies. + * + * @param {Object} props The component props. + * @param {Element} props.children The children components to render. + * + * @return {Component|null} The rendered children components or null if the current post type has no taxonomies. + */ export default function PostTaxonomiesCheck( { children } ) { const hasTaxonomies = useSelect( ( select ) => { const postType = select( editorStore ).getCurrentPostType(); diff --git a/packages/editor/src/components/post-taxonomies/flat-term-selector.js b/packages/editor/src/components/post-taxonomies/flat-term-selector.js index a558cc05f555d3..85331fc242a10f 100644 --- a/packages/editor/src/components/post-taxonomies/flat-term-selector.js +++ b/packages/editor/src/components/post-taxonomies/flat-term-selector.js @@ -52,6 +52,14 @@ const termNamesToIds = ( names, terms ) => { .filter( ( id ) => id !== undefined ); }; +/** + * Renders a flat term selector component. + * + * @param {Object} props The component props. + * @param {string} props.slug The slug of the taxonomy. + * + * @return {JSX.Element} The rendered flat term selector component. + */ export function FlatTermSelector( { slug } ) { const [ values, setValues ] = useState( [] ); const [ search, setSearch ] = useState( '' ); diff --git a/packages/editor/src/components/post-taxonomies/index.js b/packages/editor/src/components/post-taxonomies/index.js index 30468e04091837..d96027a918c182 100644 --- a/packages/editor/src/components/post-taxonomies/index.js +++ b/packages/editor/src/components/post-taxonomies/index.js @@ -43,4 +43,12 @@ export function PostTaxonomies( { taxonomyWrapper = identity } ) { } ); } +/** + * Renders the taxonomies associated with a post. + * + * @param {Object} props The component props. + * @param {Function} props.taxonomyWrapper The wrapper function for each taxonomy component. + * + * @return {Array} An array of JSX elements representing the visible taxonomies. + */ export default PostTaxonomies; diff --git a/packages/editor/src/components/post-taxonomies/panel.js b/packages/editor/src/components/post-taxonomies/panel.js index a2c2d175246403..760626f984db36 100644 --- a/packages/editor/src/components/post-taxonomies/panel.js +++ b/packages/editor/src/components/post-taxonomies/panel.js @@ -63,4 +63,13 @@ function PostTaxonomies() { ); } +/** + * Renders a panel for a specific taxonomy. + * + * @param {Object} props The component props. + * @param {Object} props.taxonomy The taxonomy object. + * @param {Element} props.children The child components. + * + * @return {Component} The rendered taxonomy panel. + */ export default PostTaxonomies;