@wordpress/fields 0.29.1-next.ba3aee3a2.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.30.0 (2026-01-16)
6
+
5
7
  ## 0.28.0 (2025-11-26)
6
8
 
7
9
  ## 0.27.0 (2025-11-12)
@@ -68,7 +68,7 @@ var getTemplatePartIcon = (areaOrIconName) => {
68
68
  return import_icons.footer;
69
69
  } else if ("sidebar" === areaOrIconName) {
70
70
  return import_icons.sidebar;
71
- } else if ("navigation-overlay" === areaOrIconName) {
71
+ } else if ("overlay" === areaOrIconName) {
72
72
  return import_icons.tableColumnAfter;
73
73
  }
74
74
  if ("menu" === areaOrIconName) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/create-template-part-modal/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport type { TemplatePartArea } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tcheck,\n\tfooter as footerIcon,\n\theader as headerIcon,\n\tsidebar as sidebarIcon,\n\ttableColumnAfter as overlayIcon,\n\tsymbolFilled as symbolFilledIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n// @ts-expect-error serialize is not typed\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetCleanTemplatePartSlug,\n\tgetUniqueTemplatePartTitle,\n\tuseExistingTemplateParts,\n} from './utils';\n\nfunction getAreaRadioId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-${ value }-${ instanceId }`;\n}\nfunction getAreaRadioDescriptionId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-description-${ value }-${ instanceId }`;\n}\n\ntype CreateTemplatePartModalContentsProps = {\n\tdefaultArea?: string;\n\tblocks: any[];\n\tconfirmLabel?: string;\n\tcloseModal: () => void;\n\tonCreate: ( templatePart: any ) => void;\n\tonError?: () => void;\n\tdefaultTitle?: string;\n};\n\n/**\n * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.\n * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.\n * @param props The component props.\n * @param props.modalTitle\n */\nexport default function CreateTemplatePartModal( {\n\tmodalTitle,\n\t...restProps\n}: {\n\tmodalTitle?: string;\n} & CreateTemplatePartModalContentsProps ) {\n\tconst defaultModalTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getPostType( 'wp_template_part' )?.labels\n\t\t\t\t?.add_new_item,\n\t\t[]\n\t);\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle || defaultModalTitle }\n\t\t\tonRequestClose={ restProps.closeModal }\n\t\t\toverlayClassName=\"fields-create-template-part-modal\"\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<CreateTemplatePartModalContents { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\n/**\n * Helper function to retrieve the corresponding icon by area name or icon name.\n *\n * @param {string} areaOrIconName The area name (e.g., 'header', 'navigation-overlay') or icon name (e.g., 'menu').\n *\n * @return {Object} The corresponding icon.\n */\nconst getTemplatePartIcon = ( areaOrIconName: string ) => {\n\t// Handle area names first\n\tif ( 'header' === areaOrIconName ) {\n\t\treturn headerIcon;\n\t} else if ( 'footer' === areaOrIconName ) {\n\t\treturn footerIcon;\n\t} else if ( 'sidebar' === areaOrIconName ) {\n\t\treturn sidebarIcon;\n\t} else if ( 'navigation-overlay' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\t// Handle icon names for backwards compatibility\n\tif ( 'menu' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\treturn symbolFilledIcon;\n};\n\n/**\n * A React component that renders the content of a model for creating a template part.\n * This component should not live in this package; it should be moved to a dedicated package responsible for managing template.\n *\n * @param {Object} props - The component props.\n * @param {string} [props.defaultArea=uncategorized] - The default area for the template part.\n * @param {Array} [props.blocks=[]] - The blocks to be included in the template part.\n * @param {string} [props.confirmLabel='Add'] - The label for the confirm button.\n * @param {Function} props.closeModal - Function to close the modal.\n * @param {Function} props.onCreate - Function to call when the template part is successfully created.\n * @param {Function} [props.onError] - Function to call when there is an error creating the template part.\n * @param {string} [props.defaultTitle=''] - The default title for the template part.\n */\nexport function CreateTemplatePartModalContents( {\n\tdefaultArea = 'uncategorized',\n\tblocks = [],\n\tconfirmLabel = __( 'Add' ),\n\tcloseModal,\n\tonCreate,\n\tonError,\n\tdefaultTitle = '',\n}: CreateTemplatePartModalContentsProps ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tconst [ title, setTitle ] = useState( defaultTitle );\n\tconst [ area, setArea ] = useState( defaultArea );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst defaultTemplatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_part_areas,\n\t\t[]\n\t);\n\n\tasync function createTemplatePart() {\n\t\tif ( ! title || isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSubmitting( true );\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error &&\n\t\t\t\t'code' in error &&\n\t\t\t\terror.message &&\n\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tonError?.();\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait createTemplatePart();\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"4\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<fieldset className=\"fields-create-template-part-modal__area-fieldset\">\n\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t{ __( 'Area' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<div className=\"fields-create-template-part-modal__area-radio-group\">\n\t\t\t\t\t\t{ ( defaultTemplatePartAreas ?? [] ).map(\n\t\t\t\t\t\t\t( item: TemplatePartArea ) => {\n\t\t\t\t\t\t\t\tconst icon = getTemplatePartIcon( item.icon );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tkey={ item.area }\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-wrapper\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tname={ `fields-create-template-part-modal__area-${ instanceId }` }\n\t\t\t\t\t\t\t\t\t\t\tvalue={ item.area }\n\t\t\t\t\t\t\t\t\t\t\tchecked={ area === item.area }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tsetArea( item.area );\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\taria-describedby={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-icon\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\t\thtmlFor={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-label\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-checkmark\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-description\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ item.description }\n\t\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</fieldset>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t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A,oBACA;AAAA,sBAAC;AAAA;AAAA,wBACA,MAAO;AAAA,wBACP,WAAU;AAAA;AAAA,oBACX;AAAA,oBACA;AAAA,sBAAC;AAAA;AAAA,wBACA,WAAU;AAAA,wBACV,IAAK;AAAA,0BACJ,KAAK;AAAA,0BACL;AAAA,wBACD;AAAA,wBAEE,eAAK;AAAA;AAAA,oBACR;AAAA;AAAA;AAAA,gBA7CM,KAAK;AAAA,cA8CZ;AAAA,YAEF;AAAA,UACD,GACD;AAAA,WACD;AAAA,QACA,6CAAC,kBAAAC,sBAAA,EAAO,SAAQ,SACf;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU,MAAM;AACf,2BAAW;AAAA,cACZ;AAAA,cAEE,8BAAI,QAAS;AAAA;AAAA,UAChB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,iBAAgB,CAAE,SAAS;AAAA,cAC3B,QAAS;AAAA,cAEP;AAAA;AAAA,UACH;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport type { TemplatePartArea } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tcheck,\n\tfooter as footerIcon,\n\theader as headerIcon,\n\tsidebar as sidebarIcon,\n\ttableColumnAfter as overlayIcon,\n\tsymbolFilled as symbolFilledIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n// @ts-expect-error serialize is not typed\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetCleanTemplatePartSlug,\n\tgetUniqueTemplatePartTitle,\n\tuseExistingTemplateParts,\n} from './utils';\n\nfunction getAreaRadioId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-${ value }-${ instanceId }`;\n}\nfunction getAreaRadioDescriptionId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-description-${ value }-${ instanceId }`;\n}\n\ntype CreateTemplatePartModalContentsProps = {\n\tdefaultArea?: string;\n\tblocks: any[];\n\tconfirmLabel?: string;\n\tcloseModal: () => void;\n\tonCreate: ( templatePart: any ) => void;\n\tonError?: () => void;\n\tdefaultTitle?: string;\n};\n\n/**\n * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.\n * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.\n * @param props The component props.\n * @param props.modalTitle\n */\nexport default function CreateTemplatePartModal( {\n\tmodalTitle,\n\t...restProps\n}: {\n\tmodalTitle?: string;\n} & CreateTemplatePartModalContentsProps ) {\n\tconst defaultModalTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getPostType( 'wp_template_part' )?.labels\n\t\t\t\t?.add_new_item,\n\t\t[]\n\t);\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle || defaultModalTitle }\n\t\t\tonRequestClose={ restProps.closeModal }\n\t\t\toverlayClassName=\"fields-create-template-part-modal\"\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<CreateTemplatePartModalContents { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\n/**\n * Helper function to retrieve the corresponding icon by area name or icon name.\n *\n * @param {string} areaOrIconName The area name (e.g., 'header', 'navigation-overlay') or icon name (e.g., 'menu').\n *\n * @return {Object} The corresponding icon.\n */\nconst getTemplatePartIcon = ( areaOrIconName: string ) => {\n\t// Handle area names first\n\tif ( 'header' === areaOrIconName ) {\n\t\treturn headerIcon;\n\t} else if ( 'footer' === areaOrIconName ) {\n\t\treturn footerIcon;\n\t} else if ( 'sidebar' === areaOrIconName ) {\n\t\treturn sidebarIcon;\n\t} else if ( 'overlay' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\t// Handle icon names for backwards compatibility\n\tif ( 'menu' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\treturn symbolFilledIcon;\n};\n\n/**\n * A React component that renders the content of a model for creating a template part.\n * This component should not live in this package; it should be moved to a dedicated package responsible for managing template.\n *\n * @param {Object} props - The component props.\n * @param {string} [props.defaultArea=uncategorized] - The default area for the template part.\n * @param {Array} [props.blocks=[]] - The blocks to be included in the template part.\n * @param {string} [props.confirmLabel='Add'] - The label for the confirm button.\n * @param {Function} props.closeModal - Function to close the modal.\n * @param {Function} props.onCreate - Function to call when the template part is successfully created.\n * @param {Function} [props.onError] - Function to call when there is an error creating the template part.\n * @param {string} [props.defaultTitle=''] - The default title for the template part.\n */\nexport function CreateTemplatePartModalContents( {\n\tdefaultArea = 'uncategorized',\n\tblocks = [],\n\tconfirmLabel = __( 'Add' ),\n\tcloseModal,\n\tonCreate,\n\tonError,\n\tdefaultTitle = '',\n}: CreateTemplatePartModalContentsProps ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tconst [ title, setTitle ] = useState( defaultTitle );\n\tconst [ area, setArea ] = useState( defaultArea );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst defaultTemplatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_part_areas,\n\t\t[]\n\t);\n\n\tasync function createTemplatePart() {\n\t\tif ( ! title || isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSubmitting( true );\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error &&\n\t\t\t\t'code' in error &&\n\t\t\t\terror.message &&\n\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tonError?.();\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait createTemplatePart();\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"4\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<fieldset className=\"fields-create-template-part-modal__area-fieldset\">\n\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t{ __( 'Area' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<div className=\"fields-create-template-part-modal__area-radio-group\">\n\t\t\t\t\t\t{ ( defaultTemplatePartAreas ?? [] ).map(\n\t\t\t\t\t\t\t( item: TemplatePartArea ) => {\n\t\t\t\t\t\t\t\tconst icon = getTemplatePartIcon( item.icon );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tkey={ item.area }\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-wrapper\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tname={ `fields-create-template-part-modal__area-${ instanceId }` }\n\t\t\t\t\t\t\t\t\t\t\tvalue={ item.area }\n\t\t\t\t\t\t\t\t\t\t\tchecked={ area === item.area }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tsetArea( item.area );\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\taria-describedby={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-icon\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\t\thtmlFor={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-label\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-checkmark\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-description\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ item.description }\n\t\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</fieldset>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title || isSubmitting }\n\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ confirmLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAQO;AACP,qBAA8B;AAE9B,uBAAmC;AACnC,kBAAuC;AACvC,qBAAyB;AACzB,kBAAmB;AACnB,mBAOO;AACP,qBAAsC;AAEtC,oBAA0B;AAK1B,mBAIO;AA6CJ;AA3CH,SAAS,eAAgB,OAAe,YAAqB;AAC5D,SAAO,kDAAmD,KAAM,IAAK,UAAW;AACjF;AACA,SAAS,0BAA2B,OAAe,YAAqB;AACvE,SAAO,8DAA+D,KAAM,IAAK,UAAW;AAC7F;AAkBe,SAAR,wBAA0C;AAAA,EAChD;AAAA,EACA,GAAG;AACJ,GAE2C;AAC1C,QAAM,wBAAoB;AAAA,IACzB,CAAE,WACD,OAAQ,iBAAAA,KAAU,EAAE,YAAa,kBAAmB,GAAG,QACpD;AAAA,IACJ,CAAC;AAAA,EACF;AACA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ,cAAc;AAAA,MACtB,gBAAiB,UAAU;AAAA,MAC3B,kBAAiB;AAAA,MACjB,cAAa;AAAA,MACb,MAAK;AAAA,MAEL,sDAAC,mCAAkC,GAAG,WAAY;AAAA;AAAA,EACnD;AAEF;AASA,IAAM,sBAAsB,CAAE,mBAA4B;AAEzD,MAAK,aAAa,gBAAiB;AAClC,WAAO,aAAAC;AAAA,EACR,WAAY,aAAa,gBAAiB;AACzC,WAAO,aAAAC;AAAA,EACR,WAAY,cAAc,gBAAiB;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wBACA,SAAU;AAAA,0BACT,KAAK;AAAA,0BACL;AAAA,wBACD;AAAA,wBACA,WAAU;AAAA,wBAER,eAAK;AAAA;AAAA,oBACR;AAAA,oBACA;AAAA,sBAAC;AAAA;AAAA,wBACA,MAAO;AAAA,wBACP,WAAU;AAAA;AAAA,oBACX;AAAA,oBACA;AAAA,sBAAC;AAAA;AAAA,wBACA,WAAU;AAAA,wBACV,IAAK;AAAA,0BACJ,KAAK;AAAA,0BACL;AAAA,wBACD;AAAA,wBAEE,eAAK;AAAA;AAAA,oBACR;AAAA;AAAA;AAAA,gBA7CM,KAAK;AAAA,cA8CZ;AAAA,YAEF;AAAA,UACD,GACD;AAAA,WACD;AAAA,QACA,6CAAC,kBAAAC,sBAAA,EAAO,SAAQ,SACf;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU,MAAM;AACf,2BAAW;AAAA,cACZ;AAAA,cAEE,8BAAI,QAAS;AAAA;AAAA,UAChB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,iBAAgB,CAAE,SAAS;AAAA,cAC3B,QAAS;AAAA,cAEP;AAAA;AAAA,UACH;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": ["coreStore", "headerIcon", "footerIcon", "sidebarIcon", "overlayIcon", "symbolFilledIcon", "noticesStore", "VStack", "HStack"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/author/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePostWithEmbeddedAuthor } from '../../types';\nimport AuthorView from './author-view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Field< BasePostWithEmbeddedAuthor > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\tsetValue: ( { value } ) => ( { author: Number( value ) } ),\n\trender: AuthorView,\n\tsort: ( a, b, direction ) => {\n\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\treturn direction === 'asc'\n\t\t\t? nameA.localeCompare( nameB )\n\t\t\t: nameB.localeCompare( nameA );\n\t},\n\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n};\n\n/**\n * Author field for BasePost.\n */\nexport default authorField;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AACnB,kBAA8B;AAC9B,uBAAuC;AAMvC,yBAAuB;AAOvB,IAAM,cAAmD;AAAA,EACxD,WAAO,gBAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,UAAM,2BAAe,iBAAAA,KAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,MACX;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,UAAU,CAAE,EAAE,MAAM,OAAS,EAAE,QAAQ,OAAQ,KAAM,EAAE;AAAA,EACvD,QAAQ,mBAAAC;AAAA,EACR,MAAM,CAAE,GAAG,GAAG,cAAe;AAC5B,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAClD,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAElD,WAAO,cAAc,QAClB,MAAM,cAAe,KAAM,IAC3B,MAAM,cAAe,KAAM;AAAA,EAC/B;AAAA,EAEA,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AACD;AAKA,IAAO,iBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePostWithEmbeddedAuthor } from '../../types';\nimport AuthorView from './author-view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Field< BasePostWithEmbeddedAuthor > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\tsetValue: ( { value } ) => ( { author: Number( value ) } ),\n\trender: AuthorView,\n\tsort: ( a, b, direction ) => {\n\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\treturn direction === 'asc'\n\t\t\t? nameA.localeCompare( nameB )\n\t\t\t: nameB.localeCompare( nameA );\n\t},\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n};\n\n/**\n * Author field for BasePost.\n */\nexport default authorField;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAmB;AACnB,kBAA8B;AAC9B,uBAAuC;AAMvC,yBAAuB;AAOvB,IAAM,cAAmD;AAAA,EACxD,WAAO,gBAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,UAAM,2BAAe,iBAAAA,KAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,MACX;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,UAAU,CAAE,EAAE,MAAM,OAAS,EAAE,QAAQ,OAAQ,KAAM,EAAE;AAAA,EACvD,QAAQ,mBAAAC;AAAA,EACR,MAAM,CAAE,GAAG,GAAG,cAAe;AAC5B,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAClD,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAElD,WAAO,cAAc,QAClB,MAAM,cAAe,KAAM,IAC3B,MAAM,cAAe,KAAM;AAAA,EAC/B;AAAA,EACA,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AACD;AAKA,IAAO,iBAAQ;",
6
6
  "names": ["coreDataStore", "AuthorView"]
7
7
  }
@@ -62,7 +62,7 @@ var getTemplatePartIcon = (areaOrIconName) => {
62
62
  return footerIcon;
63
63
  } else if ("sidebar" === areaOrIconName) {
64
64
  return sidebarIcon;
65
- } else if ("navigation-overlay" === areaOrIconName) {
65
+ } else if ("overlay" === areaOrIconName) {
66
66
  return overlayIcon;
67
67
  }
68
68
  if ("menu" === areaOrIconName) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/create-template-part-modal/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport type { TemplatePartArea } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tcheck,\n\tfooter as footerIcon,\n\theader as headerIcon,\n\tsidebar as sidebarIcon,\n\ttableColumnAfter as overlayIcon,\n\tsymbolFilled as symbolFilledIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n// @ts-expect-error serialize is not typed\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetCleanTemplatePartSlug,\n\tgetUniqueTemplatePartTitle,\n\tuseExistingTemplateParts,\n} from './utils';\n\nfunction getAreaRadioId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-${ value }-${ instanceId }`;\n}\nfunction getAreaRadioDescriptionId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-description-${ value }-${ instanceId }`;\n}\n\ntype CreateTemplatePartModalContentsProps = {\n\tdefaultArea?: string;\n\tblocks: any[];\n\tconfirmLabel?: string;\n\tcloseModal: () => void;\n\tonCreate: ( templatePart: any ) => void;\n\tonError?: () => void;\n\tdefaultTitle?: string;\n};\n\n/**\n * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.\n * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.\n * @param props The component props.\n * @param props.modalTitle\n */\nexport default function CreateTemplatePartModal( {\n\tmodalTitle,\n\t...restProps\n}: {\n\tmodalTitle?: string;\n} & CreateTemplatePartModalContentsProps ) {\n\tconst defaultModalTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getPostType( 'wp_template_part' )?.labels\n\t\t\t\t?.add_new_item,\n\t\t[]\n\t);\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle || defaultModalTitle }\n\t\t\tonRequestClose={ restProps.closeModal }\n\t\t\toverlayClassName=\"fields-create-template-part-modal\"\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<CreateTemplatePartModalContents { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\n/**\n * Helper function to retrieve the corresponding icon by area name or icon name.\n *\n * @param {string} areaOrIconName The area name (e.g., 'header', 'navigation-overlay') or icon name (e.g., 'menu').\n *\n * @return {Object} The corresponding icon.\n */\nconst getTemplatePartIcon = ( areaOrIconName: string ) => {\n\t// Handle area names first\n\tif ( 'header' === areaOrIconName ) {\n\t\treturn headerIcon;\n\t} else if ( 'footer' === areaOrIconName ) {\n\t\treturn footerIcon;\n\t} else if ( 'sidebar' === areaOrIconName ) {\n\t\treturn sidebarIcon;\n\t} else if ( 'navigation-overlay' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\t// Handle icon names for backwards compatibility\n\tif ( 'menu' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\treturn symbolFilledIcon;\n};\n\n/**\n * A React component that renders the content of a model for creating a template part.\n * This component should not live in this package; it should be moved to a dedicated package responsible for managing template.\n *\n * @param {Object} props - The component props.\n * @param {string} [props.defaultArea=uncategorized] - The default area for the template part.\n * @param {Array} [props.blocks=[]] - The blocks to be included in the template part.\n * @param {string} [props.confirmLabel='Add'] - The label for the confirm button.\n * @param {Function} props.closeModal - Function to close the modal.\n * @param {Function} props.onCreate - Function to call when the template part is successfully created.\n * @param {Function} [props.onError] - Function to call when there is an error creating the template part.\n * @param {string} [props.defaultTitle=''] - The default title for the template part.\n */\nexport function CreateTemplatePartModalContents( {\n\tdefaultArea = 'uncategorized',\n\tblocks = [],\n\tconfirmLabel = __( 'Add' ),\n\tcloseModal,\n\tonCreate,\n\tonError,\n\tdefaultTitle = '',\n}: CreateTemplatePartModalContentsProps ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tconst [ title, setTitle ] = useState( defaultTitle );\n\tconst [ area, setArea ] = useState( defaultArea );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst defaultTemplatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_part_areas,\n\t\t[]\n\t);\n\n\tasync function createTemplatePart() {\n\t\tif ( ! title || isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSubmitting( true );\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error &&\n\t\t\t\t'code' in error &&\n\t\t\t\terror.message &&\n\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tonError?.();\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait createTemplatePart();\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"4\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<fieldset className=\"fields-create-template-part-modal__area-fieldset\">\n\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t{ __( 'Area' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<div className=\"fields-create-template-part-modal__area-radio-group\">\n\t\t\t\t\t\t{ ( defaultTemplatePartAreas ?? [] ).map(\n\t\t\t\t\t\t\t( item: TemplatePartArea ) => {\n\t\t\t\t\t\t\t\tconst icon = getTemplatePartIcon( item.icon );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tkey={ item.area }\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-wrapper\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tname={ `fields-create-template-part-modal__area-${ instanceId }` }\n\t\t\t\t\t\t\t\t\t\t\tvalue={ item.area }\n\t\t\t\t\t\t\t\t\t\t\tchecked={ area === item.area }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tsetArea( item.area );\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\taria-describedby={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-icon\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\t\thtmlFor={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-label\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-checkmark\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-description\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ item.description }\n\t\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</fieldset>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title || isSubmitting }\n\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ confirmLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,OAClB;AACP,SAAS,qBAAqB;AAE9B,SAAS,SAAS,iBAAiB;AACnC,SAAS,aAAa,iBAAiB;AACvC,SAAS,gBAAgB;AACzB,SAAS,UAAU;AACnB;AAAA,EACC;AAAA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ACD;AAAA,WACD;AAAA,QACA,qBAAC,UAAO,SAAQ,SACf;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU,MAAM;AACf,2BAAW;AAAA,cACZ;AAAA,cAEE,aAAI,QAAS;AAAA;AAAA,UAChB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,iBAAgB,CAAE,SAAS;AAAA,cAC3B,QAAS;AAAA,cAEP;AAAA;AAAA,UACH;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport type { TemplatePartArea } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tcheck,\n\tfooter as footerIcon,\n\theader as headerIcon,\n\tsidebar as sidebarIcon,\n\ttableColumnAfter as overlayIcon,\n\tsymbolFilled as symbolFilledIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n// @ts-expect-error serialize is not typed\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetCleanTemplatePartSlug,\n\tgetUniqueTemplatePartTitle,\n\tuseExistingTemplateParts,\n} from './utils';\n\nfunction getAreaRadioId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-${ value }-${ instanceId }`;\n}\nfunction getAreaRadioDescriptionId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-description-${ value }-${ instanceId }`;\n}\n\ntype CreateTemplatePartModalContentsProps = {\n\tdefaultArea?: string;\n\tblocks: any[];\n\tconfirmLabel?: string;\n\tcloseModal: () => void;\n\tonCreate: ( templatePart: any ) => void;\n\tonError?: () => void;\n\tdefaultTitle?: string;\n};\n\n/**\n * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.\n * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.\n * @param props The component props.\n * @param props.modalTitle\n */\nexport default function CreateTemplatePartModal( {\n\tmodalTitle,\n\t...restProps\n}: {\n\tmodalTitle?: string;\n} & CreateTemplatePartModalContentsProps ) {\n\tconst defaultModalTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getPostType( 'wp_template_part' )?.labels\n\t\t\t\t?.add_new_item,\n\t\t[]\n\t);\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle || defaultModalTitle }\n\t\t\tonRequestClose={ restProps.closeModal }\n\t\t\toverlayClassName=\"fields-create-template-part-modal\"\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<CreateTemplatePartModalContents { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\n/**\n * Helper function to retrieve the corresponding icon by area name or icon name.\n *\n * @param {string} areaOrIconName The area name (e.g., 'header', 'navigation-overlay') or icon name (e.g., 'menu').\n *\n * @return {Object} The corresponding icon.\n */\nconst getTemplatePartIcon = ( areaOrIconName: string ) => {\n\t// Handle area names first\n\tif ( 'header' === areaOrIconName ) {\n\t\treturn headerIcon;\n\t} else if ( 'footer' === areaOrIconName ) {\n\t\treturn footerIcon;\n\t} else if ( 'sidebar' === areaOrIconName ) {\n\t\treturn sidebarIcon;\n\t} else if ( 'overlay' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\t// Handle icon names for backwards compatibility\n\tif ( 'menu' === areaOrIconName ) {\n\t\t// TODO: Replace with a proper overlay icon when available.\n\t\t// Using tableColumnAfter as a placeholder.\n\t\treturn overlayIcon;\n\t}\n\treturn symbolFilledIcon;\n};\n\n/**\n * A React component that renders the content of a model for creating a template part.\n * This component should not live in this package; it should be moved to a dedicated package responsible for managing template.\n *\n * @param {Object} props - The component props.\n * @param {string} [props.defaultArea=uncategorized] - The default area for the template part.\n * @param {Array} [props.blocks=[]] - The blocks to be included in the template part.\n * @param {string} [props.confirmLabel='Add'] - The label for the confirm button.\n * @param {Function} props.closeModal - Function to close the modal.\n * @param {Function} props.onCreate - Function to call when the template part is successfully created.\n * @param {Function} [props.onError] - Function to call when there is an error creating the template part.\n * @param {string} [props.defaultTitle=''] - The default title for the template part.\n */\nexport function CreateTemplatePartModalContents( {\n\tdefaultArea = 'uncategorized',\n\tblocks = [],\n\tconfirmLabel = __( 'Add' ),\n\tcloseModal,\n\tonCreate,\n\tonError,\n\tdefaultTitle = '',\n}: CreateTemplatePartModalContentsProps ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tconst [ title, setTitle ] = useState( defaultTitle );\n\tconst [ area, setArea ] = useState( defaultArea );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst defaultTemplatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getCurrentTheme()?.default_template_part_areas,\n\t\t[]\n\t);\n\n\tasync function createTemplatePart() {\n\t\tif ( ! title || isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSubmitting( true );\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error &&\n\t\t\t\t'code' in error &&\n\t\t\t\terror.message &&\n\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tonError?.();\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait createTemplatePart();\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"4\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<fieldset className=\"fields-create-template-part-modal__area-fieldset\">\n\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t{ __( 'Area' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<div className=\"fields-create-template-part-modal__area-radio-group\">\n\t\t\t\t\t\t{ ( defaultTemplatePartAreas ?? [] ).map(\n\t\t\t\t\t\t\t( item: TemplatePartArea ) => {\n\t\t\t\t\t\t\t\tconst icon = getTemplatePartIcon( item.icon );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tkey={ item.area }\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-wrapper\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tname={ `fields-create-template-part-modal__area-${ instanceId }` }\n\t\t\t\t\t\t\t\t\t\t\tvalue={ item.area }\n\t\t\t\t\t\t\t\t\t\t\tchecked={ area === item.area }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\t\tsetArea( item.area );\n\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\taria-describedby={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-icon\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\t\thtmlFor={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-label\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-checkmark\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-description\"\n\t\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ item.description }\n\t\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t</fieldset>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title || isSubmitting }\n\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ confirmLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n"],
5
+ "mappings": ";AAGA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;AAAA;AAAA,oBACX;AAAA,oBACA;AAAA,sBAAC;AAAA;AAAA,wBACA,WAAU;AAAA,wBACV,IAAK;AAAA,0BACJ,KAAK;AAAA,0BACL;AAAA,wBACD;AAAA,wBAEE,eAAK;AAAA;AAAA,oBACR;AAAA;AAAA;AAAA,gBA7CM,KAAK;AAAA,cA8CZ;AAAA,YAEF;AAAA,UACD,GACD;AAAA,WACD;AAAA,QACA,qBAAC,UAAO,SAAQ,SACf;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,SAAU,MAAM;AACf,2BAAW;AAAA,cACZ;AAAA,cAEE,aAAI,QAAS;AAAA;AAAA,UAChB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,iBAAgB,CAAE,SAAS;AAAA,cAC3B,QAAS;AAAA,cAEP;AAAA;AAAA,UACH;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/author/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePostWithEmbeddedAuthor } from '../../types';\nimport AuthorView from './author-view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Field< BasePostWithEmbeddedAuthor > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\tsetValue: ( { value } ) => ( { author: Number( value ) } ),\n\trender: AuthorView,\n\tsort: ( a, b, direction ) => {\n\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\treturn direction === 'asc'\n\t\t\t? nameA.localeCompare( nameB )\n\t\t\t: nameB.localeCompare( nameA );\n\t},\n\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n};\n\n/**\n * Author field for BasePost.\n */\nexport default authorField;\n"],
5
- "mappings": ";AAIA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AAMvC,OAAO,gBAAgB;AAOvB,IAAM,cAAmD;AAAA,EACxD,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,MAAM,cAAe,aAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,MACX;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,UAAU,CAAE,EAAE,MAAM,OAAS,EAAE,QAAQ,OAAQ,KAAM,EAAE;AAAA,EACvD,QAAQ;AAAA,EACR,MAAM,CAAE,GAAG,GAAG,cAAe;AAC5B,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAClD,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAElD,WAAO,cAAc,QAClB,MAAM,cAAe,KAAM,IAC3B,MAAM,cAAe,KAAM;AAAA,EAC/B;AAAA,EAEA,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AACD;AAKA,IAAO,iBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePostWithEmbeddedAuthor } from '../../types';\nimport AuthorView from './author-view';\n\ninterface Author {\n\tid: number;\n\tname: string;\n}\n\nconst authorField: Field< BasePostWithEmbeddedAuthor > = {\n\tlabel: __( 'Author' ),\n\tid: 'author',\n\ttype: 'integer',\n\tgetElements: async () => {\n\t\tconst authors: Author[] =\n\t\t\t( await resolveSelect( coreDataStore ).getEntityRecords(\n\t\t\t\t'root',\n\t\t\t\t'user',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t) ) ?? [];\n\t\treturn authors.map( ( { id, name } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: name,\n\t\t} ) );\n\t},\n\tsetValue: ( { value } ) => ( { author: Number( value ) } ),\n\trender: AuthorView,\n\tsort: ( a, b, direction ) => {\n\t\tconst nameA = a._embedded?.author?.[ 0 ]?.name || '';\n\t\tconst nameB = b._embedded?.author?.[ 0 ]?.name || '';\n\n\t\treturn direction === 'asc'\n\t\t\t? nameA.localeCompare( nameB )\n\t\t\t: nameB.localeCompare( nameA );\n\t},\n\tfilterBy: {\n\t\toperators: [ 'isAny', 'isNone' ],\n\t},\n};\n\n/**\n * Author field for BasePost.\n */\nexport default authorField;\n"],
5
+ "mappings": ";AAIA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AAMvC,OAAO,gBAAgB;AAOvB,IAAM,cAAmD;AAAA,EACxD,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aAAa,YAAY;AACxB,UAAM,UACH,MAAM,cAAe,aAAc,EAAE;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,MACX;AAAA,IACD,KAAO,CAAC;AACT,WAAO,QAAQ,IAAK,CAAE,EAAE,IAAI,KAAK,OAAS;AAAA,MACzC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,EACL;AAAA,EACA,UAAU,CAAE,EAAE,MAAM,OAAS,EAAE,QAAQ,OAAQ,KAAM,EAAE;AAAA,EACvD,QAAQ;AAAA,EACR,MAAM,CAAE,GAAG,GAAG,cAAe;AAC5B,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAClD,UAAM,QAAQ,EAAE,WAAW,SAAU,CAAE,GAAG,QAAQ;AAElD,WAAO,cAAc,QAClB,MAAM,cAAe,KAAM,IAC3B,MAAM,cAAe,KAAM;AAAA,EAC/B;AAAA,EACA,UAAU;AAAA,IACT,WAAW,CAAE,SAAS,QAAS;AAAA,EAChC;AACD;AAKA,IAAO,iBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/author/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAKlD;;GAEG;AACH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAQ9D,QAAA,MAAM,WAAW,EAAE,KAAK,CAAE,0BAA0B,CAgCnD,CAAC;AAEF;;GAEG;AACH,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/author/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAKlD;;GAEG;AACH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAQ9D,QAAA,MAAM,WAAW,EAAE,KAAK,CAAE,0BAA0B,CA+BnD,CAAC;AAEF;;GAEG;AACH,eAAe,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/fields",
3
- "version": "0.29.1-next.ba3aee3a2.0",
3
+ "version": "0.30.0",
4
4
  "description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -47,30 +47,30 @@
47
47
  "src/**/*.scss"
48
48
  ],
49
49
  "dependencies": {
50
- "@wordpress/api-fetch": "^7.37.1-next.ba3aee3a2.0",
51
- "@wordpress/base-styles": "^6.13.2-next.ba3aee3a2.0",
52
- "@wordpress/blob": "^4.37.1-next.ba3aee3a2.0",
53
- "@wordpress/block-editor": "^15.10.1-next.ba3aee3a2.0",
54
- "@wordpress/blocks": "^15.10.1-next.ba3aee3a2.0",
55
- "@wordpress/components": "^32.0.1-next.ba3aee3a2.0",
56
- "@wordpress/compose": "^7.37.1-next.ba3aee3a2.0",
57
- "@wordpress/core-data": "^7.37.1-next.ba3aee3a2.0",
58
- "@wordpress/data": "^10.37.1-next.ba3aee3a2.0",
59
- "@wordpress/dataviews": "^11.2.1-next.ba3aee3a2.0",
60
- "@wordpress/date": "^5.37.2-next.ba3aee3a2.0",
61
- "@wordpress/element": "^6.37.1-next.ba3aee3a2.0",
62
- "@wordpress/hooks": "^4.37.1-next.ba3aee3a2.0",
63
- "@wordpress/html-entities": "^4.37.1-next.ba3aee3a2.0",
64
- "@wordpress/i18n": "^6.10.1-next.ba3aee3a2.0",
65
- "@wordpress/icons": "^11.4.1-next.ba3aee3a2.0",
66
- "@wordpress/media-utils": "^5.37.1-next.ba3aee3a2.0",
67
- "@wordpress/notices": "^5.37.1-next.ba3aee3a2.0",
68
- "@wordpress/patterns": "^2.37.1-next.ba3aee3a2.0",
69
- "@wordpress/primitives": "^4.37.1-next.ba3aee3a2.0",
70
- "@wordpress/private-apis": "^1.37.1-next.ba3aee3a2.0",
71
- "@wordpress/router": "^1.37.1-next.ba3aee3a2.0",
72
- "@wordpress/url": "^4.37.1-next.ba3aee3a2.0",
73
- "@wordpress/warning": "^3.37.1-next.ba3aee3a2.0",
50
+ "@wordpress/api-fetch": "^7.38.0",
51
+ "@wordpress/base-styles": "^6.14.0",
52
+ "@wordpress/blob": "^4.38.0",
53
+ "@wordpress/block-editor": "^15.11.0",
54
+ "@wordpress/blocks": "^15.11.0",
55
+ "@wordpress/components": "^32.0.0",
56
+ "@wordpress/compose": "^7.38.0",
57
+ "@wordpress/core-data": "^7.38.0",
58
+ "@wordpress/data": "^10.38.0",
59
+ "@wordpress/dataviews": "^11.2.0",
60
+ "@wordpress/date": "^5.38.0",
61
+ "@wordpress/element": "^6.38.0",
62
+ "@wordpress/hooks": "^4.38.0",
63
+ "@wordpress/html-entities": "^4.38.0",
64
+ "@wordpress/i18n": "^6.11.0",
65
+ "@wordpress/icons": "^11.5.0",
66
+ "@wordpress/media-utils": "^5.38.0",
67
+ "@wordpress/notices": "^5.38.0",
68
+ "@wordpress/patterns": "^2.38.0",
69
+ "@wordpress/primitives": "^4.38.0",
70
+ "@wordpress/private-apis": "^1.38.0",
71
+ "@wordpress/router": "^1.38.0",
72
+ "@wordpress/url": "^4.38.0",
73
+ "@wordpress/warning": "^3.38.0",
74
74
  "change-case": "4.1.2",
75
75
  "client-zip": "^2.4.5",
76
76
  "clsx": "2.1.1",
@@ -82,5 +82,5 @@
82
82
  "publishConfig": {
83
83
  "access": "public"
84
84
  },
85
- "gitHead": "67d2e486fcd40c753591cf911ca0659132f519ca"
85
+ "gitHead": "50c4c0f51e4797c217946ce42adfaa5eb026f33f"
86
86
  }
@@ -100,7 +100,7 @@ const getTemplatePartIcon = ( areaOrIconName: string ) => {
100
100
  return footerIcon;
101
101
  } else if ( 'sidebar' === areaOrIconName ) {
102
102
  return sidebarIcon;
103
- } else if ( 'navigation-overlay' === areaOrIconName ) {
103
+ } else if ( 'overlay' === areaOrIconName ) {
104
104
  // TODO: Replace with a proper overlay icon when available.
105
105
  // Using tableColumnAfter as a placeholder.
106
106
  return overlayIcon;
@@ -45,7 +45,6 @@ const authorField: Field< BasePostWithEmbeddedAuthor > = {
45
45
  ? nameA.localeCompare( nameB )
46
46
  : nameB.localeCompare( nameA );
47
47
  },
48
-
49
48
  filterBy: {
50
49
  operators: [ 'isAny', 'isNone' ],
51
50
  },