@wordpress/fields 0.33.0 → 0.33.1-next.v.202603161435.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.
Files changed (89) hide show
  1. package/README.md +12 -0
  2. package/build/fields/author/author-view.cjs +4 -4
  3. package/build/fields/author/author-view.cjs.map +2 -2
  4. package/build/fields/date/scheduled/index.cjs +39 -0
  5. package/build/fields/date/scheduled/index.cjs.map +7 -0
  6. package/build/fields/featured-image/index.cjs +1 -0
  7. package/build/fields/featured-image/index.cjs.map +2 -2
  8. package/build/fields/format/index.cjs +69 -0
  9. package/build/fields/format/index.cjs.map +7 -0
  10. package/build/fields/index.cjs +9 -0
  11. package/build/fields/index.cjs.map +2 -2
  12. package/build/fields/parent/parent-edit.cjs +4 -10
  13. package/build/fields/parent/parent-edit.cjs.map +2 -2
  14. package/build/fields/post-content-info/index.cjs +49 -0
  15. package/build/fields/post-content-info/index.cjs.map +7 -0
  16. package/build/fields/post-content-info/post-content-info-view.cjs +76 -0
  17. package/build/fields/post-content-info/post-content-info-view.cjs.map +7 -0
  18. package/build/fields/status/status-view.cjs +1 -1
  19. package/build/fields/status/status-view.cjs.map +2 -2
  20. package/build/fields/template/hooks.cjs +35 -2
  21. package/build/fields/template/hooks.cjs.map +2 -2
  22. package/build/fields/template/template-edit.cjs +64 -12
  23. package/build/fields/template/template-edit.cjs.map +2 -2
  24. package/build/fields/template/template-view.cjs +23 -2
  25. package/build/fields/template/template-view.cjs.map +2 -2
  26. package/build/types.cjs.map +1 -1
  27. package/build-module/fields/author/author-view.mjs +4 -4
  28. package/build-module/fields/author/author-view.mjs.map +2 -2
  29. package/build-module/fields/date/scheduled/index.mjs +18 -0
  30. package/build-module/fields/date/scheduled/index.mjs.map +7 -0
  31. package/build-module/fields/featured-image/index.mjs +1 -0
  32. package/build-module/fields/featured-image/index.mjs.map +2 -2
  33. package/build-module/fields/format/index.mjs +48 -0
  34. package/build-module/fields/format/index.mjs.map +7 -0
  35. package/build-module/fields/index.mjs +10 -4
  36. package/build-module/fields/index.mjs.map +2 -2
  37. package/build-module/fields/parent/parent-edit.mjs +4 -10
  38. package/build-module/fields/parent/parent-edit.mjs.map +2 -2
  39. package/build-module/fields/post-content-info/index.mjs +18 -0
  40. package/build-module/fields/post-content-info/index.mjs.map +7 -0
  41. package/build-module/fields/post-content-info/post-content-info-view.mjs +58 -0
  42. package/build-module/fields/post-content-info/post-content-info-view.mjs.map +7 -0
  43. package/build-module/fields/status/status-view.mjs +1 -1
  44. package/build-module/fields/status/status-view.mjs.map +2 -2
  45. package/build-module/fields/template/hooks.mjs +33 -1
  46. package/build-module/fields/template/hooks.mjs.map +2 -2
  47. package/build-module/fields/template/template-edit.mjs +65 -13
  48. package/build-module/fields/template/template-edit.mjs.map +2 -2
  49. package/build-module/fields/template/template-view.mjs +24 -3
  50. package/build-module/fields/template/template-view.mjs.map +2 -2
  51. package/build-style/style-rtl.css +50 -0
  52. package/build-style/style.css +50 -0
  53. package/build-types/fields/date/scheduled/index.d.ts +14 -0
  54. package/build-types/fields/date/scheduled/index.d.ts.map +1 -0
  55. package/build-types/fields/featured-image/index.d.ts.map +1 -1
  56. package/build-types/fields/format/index.d.ts +14 -0
  57. package/build-types/fields/format/index.d.ts.map +1 -0
  58. package/build-types/fields/index.d.ts +3 -0
  59. package/build-types/fields/index.d.ts.map +1 -1
  60. package/build-types/fields/parent/parent-edit.d.ts.map +1 -1
  61. package/build-types/fields/post-content-info/index.d.ts +14 -0
  62. package/build-types/fields/post-content-info/index.d.ts.map +1 -0
  63. package/build-types/fields/post-content-info/post-content-info-view.d.ts +8 -0
  64. package/build-types/fields/post-content-info/post-content-info-view.d.ts.map +1 -0
  65. package/build-types/fields/template/hooks.d.ts +8 -0
  66. package/build-types/fields/template/hooks.d.ts.map +1 -1
  67. package/build-types/fields/template/template-edit.d.ts +1 -1
  68. package/build-types/fields/template/template-edit.d.ts.map +1 -1
  69. package/build-types/fields/template/template-view.d.ts +1 -1
  70. package/build-types/fields/template/template-view.d.ts.map +1 -1
  71. package/build-types/types.d.ts +1 -0
  72. package/build-types/types.d.ts.map +1 -1
  73. package/package.json +26 -26
  74. package/src/fields/author/author-view.tsx +7 -7
  75. package/src/fields/author/style.scss +46 -0
  76. package/src/fields/date/scheduled/index.tsx +27 -0
  77. package/src/fields/featured-image/index.tsx +1 -0
  78. package/src/fields/format/index.ts +62 -0
  79. package/src/fields/index.ts +3 -0
  80. package/src/fields/parent/parent-edit.tsx +4 -10
  81. package/src/fields/post-content-info/index.ts +27 -0
  82. package/src/fields/post-content-info/post-content-info-view.tsx +88 -0
  83. package/src/fields/status/status-view.tsx +1 -1
  84. package/src/fields/status/style.scss +10 -0
  85. package/src/fields/template/hooks.ts +48 -0
  86. package/src/fields/template/template-edit.tsx +80 -23
  87. package/src/fields/template/template-view.tsx +33 -3
  88. package/src/style.scss +2 -0
  89. package/src/types.ts +1 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/parent/parent-edit.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { ComboboxControl, ExternalLink } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateInterpolateElement,\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n// @ts-ignore\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { debounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\n\ntype TreeBase = {\n\tid: number;\n\tname: string;\n\t[ key: string ]: any;\n};\n\ntype TreeWithParent = TreeBase & {\n\tparent: number;\n};\n\ntype TreeWithoutParent = TreeBase & {\n\tparent: null;\n};\n\ntype Tree = TreeWithParent | TreeWithoutParent;\n\nfunction buildTermsTree( flatTerms: Tree[] ) {\n\tconst flatTermsWithParentAndChildren = flatTerms.map( ( term ) => {\n\t\treturn {\n\t\t\tchildren: [],\n\t\t\t...term,\n\t\t};\n\t} );\n\n\t// All terms should have a `parent` because we're about to index them by it.\n\tif (\n\t\tflatTermsWithParentAndChildren.some(\n\t\t\t( { parent } ) => parent === null || parent === undefined\n\t\t)\n\t) {\n\t\treturn flatTermsWithParentAndChildren as TreeWithParent[];\n\t}\n\n\tconst termsByParent = (\n\t\tflatTermsWithParentAndChildren as TreeWithParent[]\n\t ).reduce(\n\t\t( acc, term ) => {\n\t\t\tconst { parent } = term;\n\t\t\tif ( ! acc[ parent ] ) {\n\t\t\t\tacc[ parent ] = [];\n\t\t\t}\n\t\t\tacc[ parent ].push( term );\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record< string, Array< TreeWithParent > >\n\t);\n\n\tconst fillWithChildren = (\n\t\tterms: Array< TreeWithParent >\n\t): Array< TreeWithParent > => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n\nexport const getItemPriority = ( name: string, searchValue: string ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent( {\n\tdata,\n\tonChangeControl,\n}: {\n\tdata: BasePost;\n\tonChangeControl: ( newValue: number ) => void;\n} ) {\n\tconst [ fieldValue, setFieldValue ] = useState< null | string >( null );\n\n\tconst pageId = data.parent;\n\tconst postId = data.id;\n\tconst postTypeSlug = data.type;\n\n\tconst { parentPostTitle, pageItems, isHierarchical } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEntityRecords, getPostType } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postTypeInfo = getPostType( postTypeSlug );\n\n\t\t\tconst postIsHierarchical =\n\t\t\t\tpostTypeInfo?.hierarchical && postTypeInfo.viewable;\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord< BasePost >(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\tpageId\n\t\t\t\t )\n\t\t\t\t: null;\n\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t...( fieldValue !== null && {\n\t\t\t\t\t// Perform a search by relevance when the field is changed.\n\t\t\t\t\tsearch: fieldValue,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t} ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostTitle: parentPost\n\t\t\t\t\t? getTitleWithFallbackName( parentPost )\n\t\t\t\t\t: '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords< BasePost >(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue, pageId, postId, postTypeSlug ]\n\t);\n\n\t/**\n\t * This logic has been copied from https://github.com/WordPress/gutenberg/blob/0249771b519d5646171fb9fae422006c8ab773f2/packages/editor/src/components/page-attributes/parent.js#L106.\n\t */\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = (\n\t\t\ttree: Array< Tree >,\n\t\t\tlevel = 0\n\t\t): Array< {\n\t\t\tvalue: number;\n\t\t\tlabel: string;\n\t\t\trawName: string;\n\t\t} > => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'\u2014 '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority(\n\t\t\t\t\ta.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\tconst priorityB = getItemPriority(\n\t\t\t\t\tb.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id as number,\n\t\t\tparent: item.parent ?? null,\n\t\t\tname: getTitleWithFallbackName( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find( ( item ) => item.value === pageId );\n\t\tif ( pageId && parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: pageId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t\trawName: '',\n\t\t\t} );\n\t\t}\n\t\treturn opts.map( ( option ) => ( {\n\t\t\t...option,\n\t\t\tvalue: option.value.toString(),\n\t\t} ) );\n\t}, [ pageItems, fieldValue, parentPostTitle, pageId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue: string ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId: string | null | undefined ) => {\n\t\tif ( selectedPostId ) {\n\t\t\treturn onChangeControl( parseInt( selectedPostId, 10 ) ?? 0 );\n\t\t}\n\n\t\tonChangeControl( 0 );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ pageId?.toString() }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce(\n\t\t\t\t( value: unknown ) => handleKeydown( value as string ),\n\t\t\t\t300\n\t\t\t) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n\nexport const ParentEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst homeUrl = useSelect( ( select ) => {\n\t\treturn select( coreStore ).getEntityRecord< {\n\t\t\thome: string;\n\t\t} >( 'root', '__unstableBase' )?.home as string;\n\t}, [] );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue?: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__parent\">\n\t\t\t<div>\n\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %1$s The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %1$s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t<p>\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tchildren={ undefined }\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) }\n\t\t\t\t</p>\n\t\t\t\t<PageAttributesParent\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tonChangeControl={ onChangeControl }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n"],
5
- "mappings": ";AAGA,OAAO,mBAAmB;AAK1B,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,SAAS,iBAAiB;AAEnC,SAAS,gBAAgB;AACzB,S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,OAAQ,GAAI,QAAS;AAAA,MACrB,MAAO,GAAI,uBAAwB;AAAA,MACnC,OAAQ,QAAQ,SAAS;AAAA,MACzB,SAAU;AAAA,MACV,qBAAsB;AAAA,QACrB,CAAE,UAAoB,cAAe,KAAgB;AAAA,QACrD;AAAA,MACD;AAAA,MACA,UAAW;AAAA,MACX,qBAAmB;AAAA;AAAA,EACpB;AAEF;AAEO,IAAM,aAAa,CAAE;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AACD,MAAyC;AACxC,QAAM,EAAE,GAAG,IAAI;AAEf,QAAM,UAAU,UAAW,CAAE,WAAY;AACxC,WAAO,OAAQ,SAAU,EAAE,gBAEtB,QAAQ,gBAAiB,GAAG;AAAA,EAClC,GAAG,CAAC,CAAE;AAEN,QAAM,kBAAkB;AAAA,IACvB,CAAE,aACD,SAAU;AAAA,MACT,CAAE,EAAG,GAAG;AAAA,IACT,CAAE;AAAA,IACH,CAAE,IAAI,QAAS;AAAA,EAChB;AAEA,SACC,oBAAC,cAAS,WAAU,2BACnB,+BAAC,SACE;AAAA;AAAA,MACD;AAAA;AAAA,QAEC;AAAA,UACC;AAAA,QACD;AAAA,QACA,oBAAqB,OAAQ,EAAE;AAAA,UAC9B;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,MACA;AAAA,QACC,KAAK,oBAAC,SAAI;AAAA,MACX;AAAA,IACD;AAAA,IACA,oBAAC,OACE;AAAA,MACD;AAAA,QACC;AAAA,MACD;AAAA,MACA;AAAA,QACC,GACC;AAAA,UAAC;AAAA;AAAA,YACA,MAAO;AAAA,cACN;AAAA,YACD;AAAA,YACA,UAAW;AAAA;AAAA,QACZ;AAAA,MAEF;AAAA,IACD,GACD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { ComboboxControl, ExternalLink } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateInterpolateElement,\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n// @ts-ignore\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { debounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\n\ntype TreeBase = {\n\tid: number;\n\tname: string;\n\t[ key: string ]: any;\n};\n\ntype TreeWithParent = TreeBase & {\n\tparent: number;\n};\n\ntype TreeWithoutParent = TreeBase & {\n\tparent: null;\n};\n\ntype Tree = TreeWithParent | TreeWithoutParent;\n\nfunction buildTermsTree( flatTerms: Tree[] ) {\n\tconst flatTermsWithParentAndChildren = flatTerms.map( ( term ) => {\n\t\treturn {\n\t\t\tchildren: [],\n\t\t\t...term,\n\t\t};\n\t} );\n\n\t// All terms should have a `parent` because we're about to index them by it.\n\tif (\n\t\tflatTermsWithParentAndChildren.some(\n\t\t\t( { parent } ) => parent === null || parent === undefined\n\t\t)\n\t) {\n\t\treturn flatTermsWithParentAndChildren as TreeWithParent[];\n\t}\n\n\tconst termsByParent = (\n\t\tflatTermsWithParentAndChildren as TreeWithParent[]\n\t ).reduce(\n\t\t( acc, term ) => {\n\t\t\tconst { parent } = term;\n\t\t\tif ( ! acc[ parent ] ) {\n\t\t\t\tacc[ parent ] = [];\n\t\t\t}\n\t\t\tacc[ parent ].push( term );\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record< string, Array< TreeWithParent > >\n\t);\n\n\tconst fillWithChildren = (\n\t\tterms: Array< TreeWithParent >\n\t): Array< TreeWithParent > => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n\nexport const getItemPriority = ( name: string, searchValue: string ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent( {\n\tdata,\n\tonChangeControl,\n}: {\n\tdata: BasePost;\n\tonChangeControl: ( newValue: number ) => void;\n} ) {\n\tconst [ fieldValue, setFieldValue ] = useState< string >( '' );\n\n\tconst pageId = data.parent;\n\tconst postId = data.id;\n\tconst postTypeSlug = data.type;\n\n\tconst { parentPostTitle, pageItems, isHierarchical } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEntityRecords, getPostType } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postTypeInfo = getPostType( postTypeSlug );\n\n\t\t\tconst postIsHierarchical =\n\t\t\t\tpostTypeInfo?.hierarchical && postTypeInfo.viewable;\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord< BasePost >(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\tpageId\n\t\t\t\t )\n\t\t\t\t: null;\n\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t...( !! fieldValue && {\n\t\t\t\t\t// Perform a search by relevance when the field is changed.\n\t\t\t\t\tsearch: fieldValue,\n\t\t\t\t\torderby: 'relevance',\n\t\t\t\t} ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostTitle: parentPost\n\t\t\t\t\t? getTitleWithFallbackName( parentPost )\n\t\t\t\t\t: '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords< BasePost >(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue, pageId, postId, postTypeSlug ]\n\t);\n\n\t/**\n\t * This logic has been copied from https://github.com/WordPress/gutenberg/blob/0249771b519d5646171fb9fae422006c8ab773f2/packages/editor/src/components/page-attributes/parent.js#L106.\n\t */\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = (\n\t\t\ttree: Array< Tree >,\n\t\t\tlevel = 0\n\t\t): Array< {\n\t\t\tvalue: number;\n\t\t\tlabel: string;\n\t\t\trawName: string;\n\t\t} > => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'\u2014 '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority( a.rawName, fieldValue );\n\t\t\t\tconst priorityB = getItemPriority( b.rawName, fieldValue );\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id as number,\n\t\t\tparent: item.parent ?? null,\n\t\t\tname: getTitleWithFallbackName( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find( ( item ) => item.value === pageId );\n\t\tif ( pageId && parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: pageId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t\trawName: '',\n\t\t\t} );\n\t\t}\n\t\treturn opts.map( ( option ) => ( {\n\t\t\t...option,\n\t\t\tvalue: option.value.toString(),\n\t\t} ) );\n\t}, [ pageItems, fieldValue, parentPostTitle, pageId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue: string ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId: string | null | undefined ) => {\n\t\tif ( selectedPostId ) {\n\t\t\treturn onChangeControl( parseInt( selectedPostId, 10 ) ?? 0 );\n\t\t}\n\n\t\tonChangeControl( 0 );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ pageId?.toString() }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce(\n\t\t\t\t( value: unknown ) => handleKeydown( value as string ),\n\t\t\t\t300\n\t\t\t) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n\nexport const ParentEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst homeUrl = useSelect( ( select ) => {\n\t\treturn select( coreStore ).getEntityRecord< {\n\t\t\thome: string;\n\t\t} >( 'root', '__unstableBase' )?.home as string;\n\t}, [] );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue?: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__parent\">\n\t\t\t<div>\n\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %1$s The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %1$s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t<p>\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tchildren={ undefined }\n\t\t\t\t\t\t\t\t/>\n\t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IACA,oBAAC,OACE;AAAA,MACD;AAAA,QACC;AAAA,MACD;AAAA,MACA;AAAA,QACC,GACC;AAAA,UAAC;AAAA;AAAA,YACA,MAAO;AAAA,cACN;AAAA,YACD;AAAA,YACA,UAAW;AAAA;AAAA,QACZ;AAAA,MAEF;AAAA,IACD,GACD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KACD,GACD;AAEF;",
6
6
  "names": ["tree"]
7
7
  }
@@ -0,0 +1,18 @@
1
+ // packages/fields/src/fields/post-content-info/index.ts
2
+ import { __ } from "@wordpress/i18n";
3
+ import PostContentInfoView from "./post-content-info-view.mjs";
4
+ var postContentInfoField = {
5
+ label: __("Post content information"),
6
+ id: "post-content-info",
7
+ type: "text",
8
+ readOnly: true,
9
+ render: PostContentInfoView,
10
+ enableSorting: false,
11
+ enableHiding: false,
12
+ filterBy: false
13
+ };
14
+ var post_content_info_default = postContentInfoField;
15
+ export {
16
+ post_content_info_default as default
17
+ };
18
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/post-content-info/index.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport PostContentInfoView from './post-content-info-view';\n\nconst postContentInfoField: Field< BasePost > = {\n\tlabel: __( 'Post content information' ),\n\tid: 'post-content-info',\n\ttype: 'text',\n\treadOnly: true,\n\trender: PostContentInfoView,\n\tenableSorting: false,\n\tenableHiding: false,\n\tfilterBy: false,\n};\n\n/**\n * Post content information field for BasePost.\n */\nexport default postContentInfoField;\n"],
5
+ "mappings": ";AAIA,SAAS,UAAU;AAMnB,OAAO,yBAAyB;AAEhC,IAAM,uBAA0C;AAAA,EAC/C,OAAO,GAAI,0BAA2B;AAAA,EACtC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,cAAc;AAAA,EACd,UAAU;AACX;AAKA,IAAO,4BAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,58 @@
1
+ // packages/fields/src/fields/post-content-info/post-content-info-view.tsx
2
+ import {
3
+ __experimentalText as Text,
4
+ __experimentalVStack as VStack
5
+ } from "@wordpress/components";
6
+ import { __, _x, _n, sprintf } from "@wordpress/i18n";
7
+ import { count as wordCount } from "@wordpress/wordcount";
8
+ import { humanTimeDiff } from "@wordpress/date";
9
+ import { useMemo } from "@wordpress/element";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ var AVERAGE_READING_RATE = 189;
12
+ function PostContentInfoView({ item }) {
13
+ const content = typeof item.content === "string" ? item.content : item.content?.raw || "";
14
+ const wordCountType = _x(
15
+ "words",
16
+ "Word count type. Do not translate!"
17
+ );
18
+ const wordsCounted = useMemo(
19
+ () => content ? wordCount(content, wordCountType) : 0,
20
+ [content, wordCountType]
21
+ );
22
+ const modified = item.modified;
23
+ if (!wordsCounted && !modified) {
24
+ return null;
25
+ }
26
+ let contentInfoText;
27
+ if (wordsCounted) {
28
+ const readingTime = Math.round(wordsCounted / AVERAGE_READING_RATE);
29
+ const wordsCountText = sprintf(
30
+ // translators: %s: the number of words in the post.
31
+ _n("%s word", "%s words", wordsCounted),
32
+ wordsCounted.toLocaleString()
33
+ );
34
+ const minutesText = readingTime <= 1 ? __("1 minute") : sprintf(
35
+ /* translators: %s: the number of minutes to read the post. */
36
+ _n("%s minute", "%s minutes", readingTime),
37
+ readingTime.toLocaleString()
38
+ );
39
+ contentInfoText = sprintf(
40
+ /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
41
+ __("%1$s, %2$s read time."),
42
+ wordsCountText,
43
+ minutesText
44
+ );
45
+ }
46
+ return /* @__PURE__ */ jsxs(VStack, { spacing: 1, children: [
47
+ contentInfoText && /* @__PURE__ */ jsx(Text, { variant: "muted", children: contentInfoText }),
48
+ modified && /* @__PURE__ */ jsx(Text, { variant: "muted", children: sprintf(
49
+ // translators: %s: Human-readable time difference, e.g. "2 days ago".
50
+ __("Last edited %s."),
51
+ humanTimeDiff(modified)
52
+ ) })
53
+ ] });
54
+ }
55
+ export {
56
+ PostContentInfoView as default
57
+ };
58
+ //# sourceMappingURL=post-content-info-view.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/post-content-info/post-content-info-view.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport type { Strategy } from '@wordpress/wordcount';\nimport { humanTimeDiff } from '@wordpress/date';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\n// Taken from packages/editor/src/components/time-to-read/index.js.\nconst AVERAGE_READING_RATE = 189;\n\nexport default function PostContentInfoView( { item }: { item: BasePost } ) {\n\tconst content =\n\t\ttypeof item.content === 'string'\n\t\t\t? item.content\n\t\t\t: item.content?.raw || '';\n\n\t/*\n\t * translators: If your word count is based on single characters (e.g. East Asian characters),\n\t * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.\n\t * Do not translate into your own language.\n\t */\n\tconst wordCountType = _x(\n\t\t'words',\n\t\t'Word count type. Do not translate!'\n\t) as Strategy;\n\tconst wordsCounted = useMemo(\n\t\t() => ( content ? wordCount( content, wordCountType ) : 0 ),\n\t\t[ content, wordCountType ]\n\t);\n\n\tconst modified = item.modified;\n\n\tif ( ! wordsCounted && ! modified ) {\n\t\treturn null;\n\t}\n\n\tlet contentInfoText: string | undefined;\n\tif ( wordsCounted ) {\n\t\tconst readingTime = Math.round( wordsCounted / AVERAGE_READING_RATE );\n\t\tconst wordsCountText = sprintf(\n\t\t\t// translators: %s: the number of words in the post.\n\t\t\t_n( '%s word', '%s words', wordsCounted ),\n\t\t\twordsCounted.toLocaleString()\n\t\t);\n\t\tconst minutesText =\n\t\t\treadingTime <= 1\n\t\t\t\t? __( '1 minute' )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t/* translators: %s: the number of minutes to read the post. */\n\t\t\t\t\t\t_n( '%s minute', '%s minutes', readingTime ),\n\t\t\t\t\t\treadingTime.toLocaleString()\n\t\t\t\t );\n\t\tcontentInfoText = sprintf(\n\t\t\t/* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */\n\t\t\t__( '%1$s, %2$s read time.' ),\n\t\t\twordsCountText,\n\t\t\tminutesText\n\t\t);\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 1 }>\n\t\t\t{ contentInfoText && (\n\t\t\t\t<Text variant=\"muted\">{ contentInfoText }</Text>\n\t\t\t) }\n\t\t\t{ modified && (\n\t\t\t\t<Text variant=\"muted\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: %s: Human-readable time difference, e.g. \"2 days ago\".\n\t\t\t\t\t\t__( 'Last edited %s.' ),\n\t\t\t\t\t\thumanTimeDiff( modified )\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],
5
+ "mappings": ";AAGA;AAAA,EACC,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,OAClB;AACP,SAAS,IAAI,IAAI,IAAI,eAAe;AACpC,SAAS,SAAS,iBAAiB;AAEnC,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AA6DtB,SAEE,KAFF;AArDF,IAAM,uBAAuB;AAEd,SAAR,oBAAsC,EAAE,KAAK,GAAwB;AAC3E,QAAM,UACL,OAAO,KAAK,YAAY,WACrB,KAAK,UACL,KAAK,SAAS,OAAO;AAOzB,QAAM,gBAAgB;AAAA,IACrB;AAAA,IACA;AAAA,EACD;AACA,QAAM,eAAe;AAAA,IACpB,MAAQ,UAAU,UAAW,SAAS,aAAc,IAAI;AAAA,IACxD,CAAE,SAAS,aAAc;AAAA,EAC1B;AAEA,QAAM,WAAW,KAAK;AAEtB,MAAK,CAAE,gBAAgB,CAAE,UAAW;AACnC,WAAO;AAAA,EACR;AAEA,MAAI;AACJ,MAAK,cAAe;AACnB,UAAM,cAAc,KAAK,MAAO,eAAe,oBAAqB;AACpE,UAAM,iBAAiB;AAAA;AAAA,MAEtB,GAAI,WAAW,YAAY,YAAa;AAAA,MACxC,aAAa,eAAe;AAAA,IAC7B;AACA,UAAM,cACL,eAAe,IACZ,GAAI,UAAW,IACf;AAAA;AAAA,MAEA,GAAI,aAAa,cAAc,WAAY;AAAA,MAC3C,YAAY,eAAe;AAAA,IAC3B;AACJ,sBAAkB;AAAA;AAAA,MAEjB,GAAI,uBAAwB;AAAA,MAC5B;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SACC,qBAAC,UAAO,SAAU,GACf;AAAA,uBACD,oBAAC,QAAK,SAAQ,SAAU,2BAAiB;AAAA,IAExC,YACD,oBAAC,QAAK,SAAQ,SACX;AAAA;AAAA,MAED,GAAI,iBAAkB;AAAA,MACtB,cAAe,QAAS;AAAA,IACzB,GACD;AAAA,KAEF;AAEF;",
6
+ "names": []
7
+ }
@@ -7,7 +7,7 @@ function StatusView({ item }) {
7
7
  const label = status?.label || item.status;
8
8
  const icon = status?.icon;
9
9
  return /* @__PURE__ */ jsxs(HStack, { alignment: "left", spacing: 0, children: [
10
- icon && /* @__PURE__ */ jsx("div", { className: "edit-site-post-list__status-icon", children: /* @__PURE__ */ jsx(Icon, { icon }) }),
10
+ icon && /* @__PURE__ */ jsx("div", { className: "fields-controls__status-icon", children: /* @__PURE__ */ jsx(Icon, { icon }) }),
11
11
  /* @__PURE__ */ jsx("span", { children: label })
12
12
  ] });
13
13
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/status/status-view.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport STATUSES from './status-elements';\n\nfunction StatusView( { item }: { item: BasePost } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default StatusView;\n"],
5
- "mappings": ";AAGA,SAAS,wBAAwB,QAAQ,YAAY;AAMrD,OAAO,cAAc;AAOnB,SAGG,KAHH;AALF,SAAS,WAAY,EAAE,KAAK,GAAwB;AACnD,QAAM,SAAS,SAAS,KAAM,CAAE,EAAE,MAAM,MAAO,UAAU,KAAK,MAAO;AACrE,QAAM,QAAQ,QAAQ,SAAS,KAAK;AACpC,QAAM,OAAO,QAAQ;AACrB,SACC,qBAAC,UAAO,WAAU,QAAO,SAAU,GAChC;AAAA,YACD,oBAAC,SAAI,WAAU,oCACd,8BAAC,QAAK,MAAc,GACrB;AAAA,IAED,oBAAC,UAAO,iBAAO;AAAA,KAChB;AAEF;AAEA,IAAO,sBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport STATUSES from './status-elements';\n\nfunction StatusView( { item }: { item: BasePost } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"fields-controls__status-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default StatusView;\n"],
5
+ "mappings": ";AAGA,SAAS,wBAAwB,QAAQ,YAAY;AAMrD,OAAO,cAAc;AAOnB,SAGG,KAHH;AALF,SAAS,WAAY,EAAE,KAAK,GAAwB;AACnD,QAAM,SAAS,SAAS,KAAM,CAAE,EAAE,MAAM,MAAO,UAAU,KAAK,MAAO;AACrE,QAAM,QAAQ,QAAQ,SAAS,KAAK;AACpC,QAAM,OAAO,QAAQ;AACrB,SACC,qBAAC,UAAO,WAAU,QAAO,SAAU,GAChC;AAAA,YACD,oBAAC,SAAI,WAAU,gCACd,8BAAC,QAAK,MAAc,GACrB;AAAA,IAED,oBAAC,UAAO,iBAAO;AAAA,KAChB;AAEF;AAEA,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -3,6 +3,37 @@ import { useSelect } from "@wordpress/data";
3
3
  import { store as coreStore } from "@wordpress/core-data";
4
4
  import { getItemTitle } from "../../actions/utils.mjs";
5
5
  import { unlock } from "../../lock-unlock.mjs";
6
+ function useTemplateFieldMode(record) {
7
+ const postType = record.type;
8
+ const availableTemplates = record?.available_templates ?? {};
9
+ const hasAvailableTemplates = Object.keys(availableTemplates).length > 0;
10
+ return useSelect(
11
+ (select) => {
12
+ const isBlockTheme = !!select(coreStore).getCurrentTheme()?.is_block_theme;
13
+ const postTypeObj = select(coreStore).getPostType(postType);
14
+ if (!postTypeObj?.viewable) {
15
+ return null;
16
+ }
17
+ const canCreateTemplates = isBlockTheme && (select(coreStore).canUser("create", {
18
+ kind: "postType",
19
+ name: "wp_template"
20
+ }) ?? false);
21
+ const isVisible = hasAvailableTemplates || canCreateTemplates;
22
+ const canViewTemplates = isVisible ? !!select(coreStore).canUser("read", {
23
+ kind: "postType",
24
+ name: "wp_template"
25
+ }) : false;
26
+ if ((!isBlockTheme || !canViewTemplates) && isVisible) {
27
+ return "classic";
28
+ }
29
+ if (isBlockTheme && canViewTemplates) {
30
+ return "block-theme";
31
+ }
32
+ return null;
33
+ },
34
+ [postType, hasAvailableTemplates]
35
+ );
36
+ }
6
37
  function getTemplateSlugToCheck(postType, slug) {
7
38
  if (slug) {
8
39
  return postType === "page" ? `${postType}-${slug}` : `single-${postType}-${slug}`;
@@ -66,6 +97,7 @@ function useDefaultTemplateLabel(postType, postId, slug) {
66
97
  );
67
98
  }
68
99
  export {
69
- useDefaultTemplateLabel
100
+ useDefaultTemplateLabel,
101
+ useTemplateFieldMode
70
102
  };
71
103
  //# sourceMappingURL=hooks.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/template/hooks.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { WpTemplate } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../actions/utils';\nimport { unlock } from '../../lock-unlock';\n\n/**\n * Compute the template slug to look up in the template hierarchy.\n *\n * In `draft` status we might not have a slug available, so we use the\n * `single` post type template slug (e.g. page, single-post,\n * single-product, etc.). Pages do not need the `single` prefix to be\n * prioritised through template hierarchy.\n *\n * @param postType The post type.\n * @param slug The post slug.\n */\nfunction getTemplateSlugToCheck(\n\tpostType: string,\n\tslug: string | undefined\n): string {\n\tif ( slug ) {\n\t\treturn postType === 'page'\n\t\t\t? `${ postType }-${ slug }`\n\t\t\t: `single-${ postType }-${ slug }`;\n\t}\n\treturn postType === 'page' ? 'page' : `single-${ postType }`;\n}\n\nconst NAME_NOT_FOUND = '';\n\n/**\n * Hook that resolves the human-readable label for the default template\n * that would apply to a post, given its type, ID and slug.\n *\n * @param postType The post type.\n * @param postId The post ID.\n * @param slug The post slug.\n */\nexport function useDefaultTemplateLabel(\n\tpostType: string | undefined,\n\tpostId: string | number | undefined,\n\tslug: string | undefined\n): string {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! postType || ! postId ) {\n\t\t\t\treturn NAME_NOT_FOUND;\n\t\t\t}\n\n\t\t\tconst postIdStr = String( postId );\n\n\t\t\t// Check if the current page is the front page.\n\t\t\tconst homePage = unlock( select( coreStore ) ).getHomePage();\n\t\t\tif (\n\t\t\t\tpostType === 'page' &&\n\t\t\t\thomePage?.postType === 'page' &&\n\t\t\t\thomePage?.postId === postIdStr\n\t\t\t) {\n\t\t\t\tconst templates = select(\n\t\t\t\t\tcoreStore\n\t\t\t\t).getEntityRecords< WpTemplate >( 'postType', 'wp_template', {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} );\n\t\t\t\tconst frontPage = templates?.find(\n\t\t\t\t\t( t ) => t.slug === 'front-page'\n\t\t\t\t);\n\t\t\t\tif ( frontPage ) {\n\t\t\t\t\treturn getItemTitle( frontPage );\n\t\t\t\t}\n\n\t\t\t\t// If no front page template is found, fall back to the page template.\n\t\t\t\t// See @getTemplateId private selector in core-data package.\n\t\t\t}\n\n\t\t\t// Check if the current page is the posts page.\n\t\t\tconst postsPageId = unlock( select( coreStore ) ).getPostsPageId();\n\t\t\tif ( postType === 'page' && postsPageId === postIdStr ) {\n\t\t\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\t\t\tslug: 'home',\n\t\t\t\t} );\n\t\t\t\tif ( ! templateId ) {\n\t\t\t\t\treturn NAME_NOT_FOUND;\n\t\t\t\t}\n\n\t\t\t\tconst template = select(\n\t\t\t\t\tcoreStore\n\t\t\t\t).getEntityRecord< WpTemplate >(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\ttemplateId\n\t\t\t\t);\n\t\t\t\treturn template ? getItemTitle( template ) : NAME_NOT_FOUND;\n\t\t\t}\n\n\t\t\t// Check any other case.\n\t\t\tconst slugToCheck = getTemplateSlugToCheck( postType, slug );\n\t\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\t\tslug: slugToCheck,\n\t\t\t} );\n\t\t\tif ( ! templateId ) {\n\t\t\t\treturn NAME_NOT_FOUND;\n\t\t\t}\n\n\t\t\tconst template = select( coreStore ).getEntityRecord< WpTemplate >(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\ttemplateId\n\t\t\t);\n\t\t\treturn template ? getItemTitle( template ) : NAME_NOT_FOUND;\n\t\t},\n\t\t[ postType, postId, slug ]\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AAMnC,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AAavB,SAAS,uBACR,UACA,MACS;AACT,MAAK,MAAO;AACX,WAAO,aAAa,SACjB,GAAI,QAAS,IAAK,IAAK,KACvB,UAAW,QAAS,IAAK,IAAK;AAAA,EAClC;AACA,SAAO,aAAa,SAAS,SAAS,UAAW,QAAS;AAC3D;AAEA,IAAM,iBAAiB;AAUhB,SAAS,wBACf,UACA,QACA,MACS;AACT,SAAO;AAAA,IACN,CAAE,WAAY;AACb,UAAK,CAAE,YAAY,CAAE,QAAS;AAC7B,eAAO;AAAA,MACR;AAEA,YAAM,YAAY,OAAQ,MAAO;AAGjC,YAAM,WAAW,OAAQ,OAAQ,SAAU,CAAE,EAAE,YAAY;AAC3D,UACC,aAAa,UACb,UAAU,aAAa,UACvB,UAAU,WAAW,WACpB;AACD,cAAM,YAAY;AAAA,UACjB;AAAA,QACD,EAAE,iBAAgC,YAAY,eAAe;AAAA,UAC5D,UAAU;AAAA,QACX,CAAE;AACF,cAAM,YAAY,WAAW;AAAA,UAC5B,CAAE,MAAO,EAAE,SAAS;AAAA,QACrB;AACA,YAAK,WAAY;AAChB,iBAAO,aAAc,SAAU;AAAA,QAChC;AAAA,MAID;AAGA,YAAM,cAAc,OAAQ,OAAQ,SAAU,CAAE,EAAE,eAAe;AACjE,UAAK,aAAa,UAAU,gBAAgB,WAAY;AACvD,cAAMA,cAAa,OAAQ,SAAU,EAAE,qBAAsB;AAAA,UAC5D,MAAM;AAAA,QACP,CAAE;AACF,YAAK,CAAEA,aAAa;AACnB,iBAAO;AAAA,QACR;AAEA,cAAMC,YAAW;AAAA,UAChB;AAAA,QACD,EAAE;AAAA,UACD;AAAA,UACA;AAAA,UACAD;AAAA,QACD;AACA,eAAOC,YAAW,aAAcA,SAAS,IAAI;AAAA,MAC9C;AAGA,YAAM,cAAc,uBAAwB,UAAU,IAAK;AAC3D,YAAM,aAAa,OAAQ,SAAU,EAAE,qBAAsB;AAAA,QAC5D,MAAM;AAAA,MACP,CAAE;AACF,UAAK,CAAE,YAAa;AACnB,eAAO;AAAA,MACR;AAEA,YAAM,WAAW,OAAQ,SAAU,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,aAAO,WAAW,aAAc,QAAS,IAAI;AAAA,IAC9C;AAAA,IACA,CAAE,UAAU,QAAQ,IAAK;AAAA,EAC1B;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { WpTemplate } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../actions/utils';\nimport { unlock } from '../../lock-unlock';\nimport type { BasePost } from '../../types';\n\n/**\n * Hook that determines the template field rendering mode for a post.\n *\n * @param record The post record.\n * @return 'block-theme' | 'classic' | null\n */\nexport function useTemplateFieldMode(\n\trecord: BasePost\n): 'block-theme' | 'classic' | null {\n\tconst postType = record.type;\n\tconst availableTemplates = ( ( record as Record< string, any > )\n\t\t?.available_templates ?? {} ) as Record< string, string >;\n\tconst hasAvailableTemplates = Object.keys( availableTemplates ).length > 0;\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst isBlockTheme =\n\t\t\t\t!! select( coreStore ).getCurrentTheme()?.is_block_theme;\n\t\t\tconst postTypeObj = select( coreStore ).getPostType( postType );\n\t\t\tif ( ! postTypeObj?.viewable ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst canCreateTemplates =\n\t\t\t\tisBlockTheme &&\n\t\t\t\t( select( coreStore ).canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} ) ??\n\t\t\t\t\tfalse );\n\t\t\tconst isVisible = hasAvailableTemplates || canCreateTemplates;\n\t\t\tconst canViewTemplates = isVisible\n\t\t\t\t? !! select( coreStore ).canUser( 'read', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_template',\n\t\t\t\t } )\n\t\t\t\t: false;\n\t\t\tif ( ( ! isBlockTheme || ! canViewTemplates ) && isVisible ) {\n\t\t\t\treturn 'classic';\n\t\t\t}\n\t\t\tif ( isBlockTheme && canViewTemplates ) {\n\t\t\t\treturn 'block-theme';\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t\t[ postType, hasAvailableTemplates ]\n\t);\n}\n\n/**\n * Compute the template slug to look up in the template hierarchy.\n *\n * In `draft` status we might not have a slug available, so we use the\n * `single` post type template slug (e.g. page, single-post,\n * single-product, etc.). Pages do not need the `single` prefix to be\n * prioritised through template hierarchy.\n *\n * @param postType The post type.\n * @param slug The post slug.\n */\nfunction getTemplateSlugToCheck(\n\tpostType: string,\n\tslug: string | undefined\n): string {\n\tif ( slug ) {\n\t\treturn postType === 'page'\n\t\t\t? `${ postType }-${ slug }`\n\t\t\t: `single-${ postType }-${ slug }`;\n\t}\n\treturn postType === 'page' ? 'page' : `single-${ postType }`;\n}\n\nconst NAME_NOT_FOUND = '';\n\n/**\n * Hook that resolves the human-readable label for the default template\n * that would apply to a post, given its type, ID and slug.\n *\n * @param postType The post type.\n * @param postId The post ID.\n * @param slug The post slug.\n */\nexport function useDefaultTemplateLabel(\n\tpostType: string | undefined,\n\tpostId: string | number | undefined,\n\tslug: string | undefined\n): string {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! postType || ! postId ) {\n\t\t\t\treturn NAME_NOT_FOUND;\n\t\t\t}\n\n\t\t\tconst postIdStr = String( postId );\n\n\t\t\t// Check if the current page is the front page.\n\t\t\tconst homePage = unlock( select( coreStore ) ).getHomePage();\n\t\t\tif (\n\t\t\t\tpostType === 'page' &&\n\t\t\t\thomePage?.postType === 'page' &&\n\t\t\t\thomePage?.postId === postIdStr\n\t\t\t) {\n\t\t\t\tconst templates = select(\n\t\t\t\t\tcoreStore\n\t\t\t\t).getEntityRecords< WpTemplate >( 'postType', 'wp_template', {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} );\n\t\t\t\tconst frontPage = templates?.find(\n\t\t\t\t\t( t ) => t.slug === 'front-page'\n\t\t\t\t);\n\t\t\t\tif ( frontPage ) {\n\t\t\t\t\treturn getItemTitle( frontPage );\n\t\t\t\t}\n\n\t\t\t\t// If no front page template is found, fall back to the page template.\n\t\t\t\t// See @getTemplateId private selector in core-data package.\n\t\t\t}\n\n\t\t\t// Check if the current page is the posts page.\n\t\t\tconst postsPageId = unlock( select( coreStore ) ).getPostsPageId();\n\t\t\tif ( postType === 'page' && postsPageId === postIdStr ) {\n\t\t\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\t\t\tslug: 'home',\n\t\t\t\t} );\n\t\t\t\tif ( ! templateId ) {\n\t\t\t\t\treturn NAME_NOT_FOUND;\n\t\t\t\t}\n\n\t\t\t\tconst template = select(\n\t\t\t\t\tcoreStore\n\t\t\t\t).getEntityRecord< WpTemplate >(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\ttemplateId\n\t\t\t\t);\n\t\t\t\treturn template ? getItemTitle( template ) : NAME_NOT_FOUND;\n\t\t\t}\n\n\t\t\t// Check any other case.\n\t\t\tconst slugToCheck = getTemplateSlugToCheck( postType, slug );\n\t\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\t\tslug: slugToCheck,\n\t\t\t} );\n\t\t\tif ( ! templateId ) {\n\t\t\t\treturn NAME_NOT_FOUND;\n\t\t\t}\n\n\t\t\tconst template = select( coreStore ).getEntityRecord< WpTemplate >(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\ttemplateId\n\t\t\t);\n\t\t\treturn template ? getItemTitle( template ) : NAME_NOT_FOUND;\n\t\t},\n\t\t[ postType, postId, slug ]\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AAMnC,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AAShB,SAAS,qBACf,QACmC;AACnC,QAAM,WAAW,OAAO;AACxB,QAAM,qBAAyB,QAC5B,uBAAuB,CAAC;AAC3B,QAAM,wBAAwB,OAAO,KAAM,kBAAmB,EAAE,SAAS;AACzE,SAAO;AAAA,IACN,CAAE,WAAY;AACb,YAAM,eACL,CAAC,CAAE,OAAQ,SAAU,EAAE,gBAAgB,GAAG;AAC3C,YAAM,cAAc,OAAQ,SAAU,EAAE,YAAa,QAAS;AAC9D,UAAK,CAAE,aAAa,UAAW;AAC9B,eAAO;AAAA,MACR;AACA,YAAM,qBACL,iBACE,OAAQ,SAAU,EAAE,QAAS,UAAU;AAAA,QACxC,MAAM;AAAA,QACN,MAAM;AAAA,MACP,CAAE,KACD;AACF,YAAM,YAAY,yBAAyB;AAC3C,YAAM,mBAAmB,YACtB,CAAC,CAAE,OAAQ,SAAU,EAAE,QAAS,QAAQ;AAAA,QACxC,MAAM;AAAA,QACN,MAAM;AAAA,MACN,CAAE,IACF;AACH,WAAO,CAAE,gBAAgB,CAAE,qBAAsB,WAAY;AAC5D,eAAO;AAAA,MACR;AACA,UAAK,gBAAgB,kBAAmB;AACvC,eAAO;AAAA,MACR;AACA,aAAO;AAAA,IACR;AAAA,IACA,CAAE,UAAU,qBAAsB;AAAA,EACnC;AACD;AAaA,SAAS,uBACR,UACA,MACS;AACT,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WAAW,OAAQ,SAAU,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,aAAO,WAAW,aAAc,QAAS,IAAI;AAAA,IAC9C;AAAA,IACA,CAAE,UAAU,QAAQ,IAAK;AAAA,EAC1B;AACD;",
6
6
  "names": ["templateId", "template"]
7
7
  }
@@ -5,16 +5,56 @@ import { SelectControl } from "@wordpress/components";
5
5
  import { useSelect } from "@wordpress/data";
6
6
  import { __ } from "@wordpress/i18n";
7
7
  import { getItemTitle } from "../../actions/utils.mjs";
8
- import { useDefaultTemplateLabel } from "./hooks.mjs";
8
+ import { useDefaultTemplateLabel, useTemplateFieldMode } from "./hooks.mjs";
9
9
  import { unlock } from "../../lock-unlock.mjs";
10
10
  import { jsx } from "react/jsx-runtime";
11
11
  var EMPTY_ARRAY = [];
12
- var TemplateEdit = ({
12
+ function ClassicTemplateEdit({
13
13
  data,
14
14
  field,
15
15
  onChange
16
- }) => {
17
- const { id } = field;
16
+ }) {
17
+ const postId = typeof data.id === "number" ? data.id : parseInt(data.id, 10);
18
+ const value = field.getValue({ item: data });
19
+ const options = useMemo(
20
+ () => Object.entries(
21
+ data?.available_templates ?? {}
22
+ ).map(([templateSlug, title]) => ({
23
+ label: title,
24
+ value: templateSlug
25
+ })),
26
+ [data]
27
+ );
28
+ const canSwitchTemplate = useSelect(
29
+ (select) => {
30
+ const { getHomePage, getPostsPageId } = unlock(
31
+ select(coreStore)
32
+ );
33
+ const singlePostId = String(postId);
34
+ const isPostsPage = getPostsPageId() === singlePostId;
35
+ const isFrontPage = data.type === "page" && getHomePage()?.postId === singlePostId;
36
+ return !isPostsPage && !isFrontPage;
37
+ },
38
+ [postId, data.type]
39
+ );
40
+ return /* @__PURE__ */ jsx(
41
+ SelectControl,
42
+ {
43
+ __next40pxDefaultSize: true,
44
+ label: __("Template"),
45
+ hideLabelFromVision: true,
46
+ value,
47
+ options,
48
+ onChange,
49
+ disabled: !canSwitchTemplate
50
+ }
51
+ );
52
+ }
53
+ function BlockThemeTemplateEdit({
54
+ data,
55
+ field,
56
+ onChange
57
+ }) {
18
58
  const postType = data.type;
19
59
  const postId = typeof data.id === "number" ? data.id : parseInt(data.id, 10);
20
60
  const slug = data.slug;
@@ -32,8 +72,8 @@ var TemplateEdit = ({
32
72
  select(coreStore)
33
73
  );
34
74
  const singlePostId = String(postId);
35
- const isPostsPage = singlePostId !== void 0 && getPostsPageId() === singlePostId;
36
- const isFrontPage = singlePostId !== void 0 && postType === "page" && getHomePage()?.postId === singlePostId;
75
+ const isPostsPage = getPostsPageId() === singlePostId;
76
+ const isFrontPage = postType === "page" && getHomePage()?.postId === singlePostId;
37
77
  return {
38
78
  templates: allTemplates,
39
79
  canSwitchTemplate: !isPostsPage && !isFrontPage
@@ -47,12 +87,6 @@ var TemplateEdit = ({
47
87
  slug
48
88
  );
49
89
  const value = field.getValue({ item: data });
50
- const onChangeControl = useCallback(
51
- (newValue) => onChange({
52
- [id]: newValue
53
- }),
54
- [id, onChange]
55
- );
56
90
  const options = useMemo(() => {
57
91
  const templateOptions = templates.map((template) => ({
58
92
  label: getItemTitle(template),
@@ -71,10 +105,28 @@ var TemplateEdit = ({
71
105
  hideLabelFromVision: true,
72
106
  value,
73
107
  options,
74
- onChange: onChangeControl,
108
+ onChange,
75
109
  disabled: !canSwitchTemplate
76
110
  }
77
111
  );
112
+ }
113
+ var TemplateEdit = ({
114
+ data,
115
+ field,
116
+ onChange
117
+ }) => {
118
+ const onChangeControl = useCallback(
119
+ (newValue) => onChange({
120
+ [field.id]: newValue
121
+ }),
122
+ [field.id, onChange]
123
+ );
124
+ const mode = useTemplateFieldMode(data);
125
+ if (!mode || !["block-theme", "classic"].includes(mode)) {
126
+ return null;
127
+ }
128
+ const Edit = mode === "classic" ? ClassicTemplateEdit : BlockThemeTemplateEdit;
129
+ return /* @__PURE__ */ jsx(Edit, { data, field, onChange: onChangeControl });
78
130
  };
79
131
  export {
80
132
  TemplateEdit
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/template/template-edit.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { SelectControl } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../actions/utils';\nimport type { BasePost } from '../../types';\nimport { useDefaultTemplateLabel } from './hooks';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_ARRAY: [] = [];\n\nexport const TemplateEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\tconst postType = data.type;\n\tconst postId =\n\t\ttypeof data.id === 'number' ? data.id : parseInt( data.id, 10 );\n\tconst slug = data.slug;\n\n\tconst { templates, canSwitchTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst allTemplates =\n\t\t\t\tselect( coreStore ).getEntityRecords< WpTemplate >(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\t{\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\tpost_type: postType,\n\t\t\t\t\t}\n\t\t\t\t) ?? EMPTY_ARRAY;\n\n\t\t\tconst { getHomePage, getPostsPageId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\t\t\tconst singlePostId = String( postId );\n\t\t\tconst isPostsPage =\n\t\t\t\tsinglePostId !== undefined && getPostsPageId() === singlePostId;\n\t\t\tconst isFrontPage =\n\t\t\t\tsinglePostId !== undefined &&\n\t\t\t\tpostType === 'page' &&\n\t\t\t\tgetHomePage()?.postId === singlePostId;\n\n\t\t\treturn {\n\t\t\t\ttemplates: allTemplates,\n\t\t\t\tcanSwitchTemplate: ! isPostsPage && ! isFrontPage,\n\t\t\t};\n\t\t},\n\t\t[ postId, postType ]\n\t);\n\n\tconst defaultTemplateLabel = useDefaultTemplateLabel(\n\t\tpostType,\n\t\tpostId,\n\t\tslug\n\t);\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\tconst options = useMemo( () => {\n\t\tconst templateOptions = templates.map( ( template ) => ( {\n\t\t\tlabel: getItemTitle( template ),\n\t\t\tvalue: template.slug,\n\t\t} ) );\n\t\treturn [\n\t\t\t{ label: defaultTemplateLabel, value: '' },\n\t\t\t...templateOptions,\n\t\t];\n\t}, [ templates, defaultTemplateLabel ] );\n\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Template' ) }\n\t\t\thideLabelFromVision\n\t\t\tvalue={ value }\n\t\t\toptions={ options }\n\t\t\tonChange={ onChangeControl }\n\t\t\tdisabled={ ! canSwitchTemplate }\n\t\t/>\n\t);\n};\n"],
5
- "mappings": ";AAGA,SAAS,aAAa,eAAe;AAErC,SAAS,SAAS,iBAAiB;AAEnC,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAKnB,SAAS,oBAAoB;AAE7B,SAAS,+BAA+B;AACxC,SAAS,cAAc;AA0ErB;AAxEF,IAAM,cAAkB,CAAC;AAElB,IAAM,eAAe,CAAE;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACD,MAAyC;AACxC,QAAM,EAAE,GAAG,IAAI;AACf,QAAM,WAAW,KAAK;AACtB,QAAM,SACL,OAAO,KAAK,OAAO,WAAW,KAAK,KAAK,SAAU,KAAK,IAAI,EAAG;AAC/D,QAAM,OAAO,KAAK;AAElB,QAAM,EAAE,WAAW,kBAAkB,IAAI;AAAA,IACxC,CAAE,WAAY;AACb,YAAM,eACL,OAAQ,SAAU,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element';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { SelectControl } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../actions/utils';\nimport type { BasePost } from '../../types';\nimport { useDefaultTemplateLabel, useTemplateFieldMode } from './hooks';\nimport { unlock } from '../../lock-unlock';\n\ntype TemplateEditComponentProps = Omit<\n\tDataFormControlProps< BasePost >,\n\t'onChange'\n> & {\n\tonChange: ( value: string ) => void;\n};\n\nconst EMPTY_ARRAY: [] = [];\n\nfunction ClassicTemplateEdit( {\n\tdata,\n\tfield,\n\tonChange,\n}: TemplateEditComponentProps ) {\n\tconst postId =\n\t\ttypeof data.id === 'number' ? data.id : parseInt( data.id, 10 );\n\tconst value = field.getValue( { item: data } );\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries(\n\t\t\t\t( ( data as Record< string, any > )?.available_templates ??\n\t\t\t\t\t{} ) as Record< string, string >\n\t\t\t).map( ( [ templateSlug, title ] ) => ( {\n\t\t\t\tlabel: title,\n\t\t\t\tvalue: templateSlug,\n\t\t\t} ) ),\n\t\t[ data ]\n\t);\n\tconst canSwitchTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getHomePage, getPostsPageId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\t\t\tconst singlePostId = String( postId );\n\t\t\tconst isPostsPage = getPostsPageId() === singlePostId;\n\t\t\tconst isFrontPage =\n\t\t\t\tdata.type === 'page' && getHomePage()?.postId === singlePostId;\n\n\t\t\treturn ! isPostsPage && ! isFrontPage;\n\t\t},\n\t\t[ postId, data.type ]\n\t);\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Template' ) }\n\t\t\thideLabelFromVision\n\t\t\tvalue={ value }\n\t\t\toptions={ options }\n\t\t\tonChange={ onChange }\n\t\t\tdisabled={ ! canSwitchTemplate }\n\t\t/>\n\t);\n}\n\nfunction BlockThemeTemplateEdit( {\n\tdata,\n\tfield,\n\tonChange,\n}: TemplateEditComponentProps ) {\n\tconst postType = data.type;\n\tconst postId =\n\t\ttypeof data.id === 'number' ? data.id : parseInt( data.id, 10 );\n\tconst slug = data.slug;\n\tconst { templates, canSwitchTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst allTemplates =\n\t\t\t\tselect( coreStore ).getEntityRecords< WpTemplate >(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\t{\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\tpost_type: postType,\n\t\t\t\t\t}\n\t\t\t\t) ?? EMPTY_ARRAY;\n\n\t\t\tconst { getHomePage, getPostsPageId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\t\t\tconst singlePostId = String( postId );\n\t\t\tconst isPostsPage = getPostsPageId() === singlePostId;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && getHomePage()?.postId === singlePostId;\n\n\t\t\treturn {\n\t\t\t\ttemplates: allTemplates,\n\t\t\t\tcanSwitchTemplate: ! isPostsPage && ! isFrontPage,\n\t\t\t};\n\t\t},\n\t\t[ postId, postType ]\n\t);\n\tconst defaultTemplateLabel = useDefaultTemplateLabel(\n\t\tpostType,\n\t\tpostId,\n\t\tslug\n\t);\n\tconst value = field.getValue( { item: data } );\n\tconst options = useMemo( () => {\n\t\tconst templateOptions = templates.map( ( template ) => ( {\n\t\t\tlabel: getItemTitle( template ),\n\t\t\tvalue: template.slug,\n\t\t} ) );\n\t\treturn [\n\t\t\t{ label: defaultTemplateLabel, value: '' },\n\t\t\t...templateOptions,\n\t\t];\n\t}, [ templates, defaultTemplateLabel ] );\n\treturn (\n\t\t<SelectControl\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Template' ) }\n\t\t\thideLabelFromVision\n\t\t\tvalue={ value }\n\t\t\toptions={ options }\n\t\t\tonChange={ onChange }\n\t\t\tdisabled={ ! canSwitchTemplate }\n\t\t/>\n\t);\n}\n\nexport const TemplateEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst onChangeControl = useCallback(\n\t\t( newValue: string ) =>\n\t\t\tonChange( {\n\t\t\t\t[ field.id ]: newValue,\n\t\t\t} ),\n\t\t[ field.id, onChange ]\n\t);\n\tconst mode = useTemplateFieldMode( data );\n\tif ( ! mode || ! [ 'block-theme', 'classic' ].includes( mode ) ) {\n\t\treturn null;\n\t}\n\tconst Edit =\n\t\tmode === 'classic' ? ClassicTemplateEdit : BlockThemeTemplateEdit;\n\treturn <Edit data={ data } field={ field } onChange={ onChangeControl } />;\n};\n"],
5
+ "mappings": ";AAGA,SAAS,aAAa,eAAe;AAErC,SAAS,SAAS,iBAAiB;AAEnC,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAKnB,SAAS,oBAAoB;AAE7B,SAAS,yBAAyB,4BAA4B;AAC9D,SAAS,cAAc;AA6CrB;AApCF,IAAM,cAAkB,CAAC;AAEzB,SAAS,oBAAqB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACD,GAAgC;AAC/B,QAAM,SACL,OAAO,KAAK,OAAO,WAAW,KAAK,KAAK,SAAU,KAAK,IAAI,EAAG;AAC/D,QAAM,QAAQ,MAAM,SAAU,EAAE,MAAM,KAAK,CAAE;AAC7C,QAAM,UAAU;AAAA,IACf,MACC,OAAO;AAAA,MACF,MAAiC,uBACpC,CAAC;AAAA,IACH,EAAE,IAAK,CAAE,CAAE,cAAc,KAAM,OAAS;AAAA,MACvC,OAAO;AAAA,MACP,OAAO;AAAA,IACR,EAAI;AAAA,IACL,CAAE,IAAK;AAAA,EACR;AACA,QAAM,oBAAoB;AAAA,IACzB,CAAE,WAAY;AACb,YAAM,EAAE,aAAa,eAAe,IAAI;A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CAAE;AAC7C,QAAM,UAAU,QAAS,MAAM;AAC9B,UAAM,kBAAkB,UAAU,IAAK,CAAE,cAAgB;AAAA,MACxD,OAAO,aAAc,QAAS;AAAA,MAC9B,OAAO,SAAS;AAAA,IACjB,EAAI;AACJ,WAAO;AAAA,MACN,EAAE,OAAO,sBAAsB,OAAO,GAAG;AAAA,MACzC,GAAG;AAAA,IACJ;AAAA,EACD,GAAG,CAAE,WAAW,oBAAqB,CAAE;AACvC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,OAAQ,GAAI,UAAW;AAAA,MACvB,qBAAmB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAW,CAAE;AAAA;AAAA,EACd;AAEF;AAEO,IAAM,eAAe,CAAE;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AACD,MAAyC;AACxC,QAAM,kBAAkB;AAAA,IACvB,CAAE,aACD,SAAU;AAAA,MACT,CAAE,MAAM,EAAG,GAAG;AAAA,IACf,CAAE;AAAA,IACH,CAAE,MAAM,IAAI,QAAS;AAAA,EACtB;AACA,QAAM,OAAO,qBAAsB,IAAK;AACxC,MAAK,CAAE,QAAQ,CAAE,CAAE,eAAe,SAAU,EAAE,SAAU,IAAK,GAAI;AAChE,WAAO;AAAA,EACR;AACA,QAAM,OACL,SAAS,YAAY,sBAAsB;AAC5C,SAAO,oBAAC,QAAK,MAAc,OAAgB,UAAW,iBAAkB;AACzE;",
6
6
  "names": []
7
7
  }
@@ -1,13 +1,23 @@
1
1
  // packages/fields/src/fields/template/template-view.tsx
2
2
  import { useSelect } from "@wordpress/data";
3
3
  import { store as coreStore } from "@wordpress/core-data";
4
+ import { __ } from "@wordpress/i18n";
4
5
  import { getItemTitle } from "../../actions/utils.mjs";
5
- import { useDefaultTemplateLabel } from "./hooks.mjs";
6
+ import { useDefaultTemplateLabel, useTemplateFieldMode } from "./hooks.mjs";
6
7
  import { Fragment, jsx } from "react/jsx-runtime";
7
- var TemplateView = ({
8
+ function ClassicTemplateView({
8
9
  item,
9
10
  field
10
- }) => {
11
+ }) {
12
+ const templateSlug = field.getValue({ item });
13
+ const availableTemplates = item?.available_templates ?? {};
14
+ const classicLabel = templateSlug && availableTemplates[templateSlug] ? availableTemplates[templateSlug] : __("Default template");
15
+ return /* @__PURE__ */ jsx(Fragment, { children: classicLabel });
16
+ }
17
+ function BlockThemeTemplateView({
18
+ item,
19
+ field
20
+ }) {
11
21
  const postType = item.type;
12
22
  const slug = item.slug;
13
23
  const postId = item.id;
@@ -36,6 +46,17 @@ var TemplateView = ({
36
46
  [postType, templateSlug]
37
47
  );
38
48
  return /* @__PURE__ */ jsx(Fragment, { children: templateLabel ?? defaultTemplateLabel });
49
+ }
50
+ var TemplateView = ({
51
+ item,
52
+ field
53
+ }) => {
54
+ const mode = useTemplateFieldMode(item);
55
+ if (!mode || !["block-theme", "classic"].includes(mode)) {
56
+ return null;
57
+ }
58
+ const View = mode === "classic" ? ClassicTemplateView : BlockThemeTemplateView;
59
+ return /* @__PURE__ */ jsx(View, { item, field });
39
60
  };
40
61
  export {
41
62
  TemplateView
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/template/template-view.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../actions/utils';\nimport type { BasePost } from '../../types';\nimport { useDefaultTemplateLabel } from './hooks';\n\nexport const TemplateView = ( {\n\titem,\n\tfield,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst postType = item.type;\n\tconst slug = item.slug;\n\tconst postId = item.id;\n\tconst templateSlug = field.getValue( { item } );\n\n\tconst defaultTemplateLabel = useDefaultTemplateLabel(\n\t\tpostType,\n\t\tpostId,\n\t\tslug\n\t);\n\n\tconst templateLabel = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! templateSlug ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst allTemplates = select(\n\t\t\t\tcoreStore\n\t\t\t).getEntityRecords< WpTemplate >( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} );\n\t\t\tconst match = allTemplates?.find(\n\t\t\t\t( t ) => t.slug === templateSlug\n\t\t\t);\n\t\t\treturn match ? getItemTitle( match ) : undefined;\n\t\t},\n\t\t[ postType, templateSlug ]\n\t);\n\n\treturn <>{ templateLabel ?? defaultTemplateLabel }</>;\n};\n"],
5
- "mappings": ";AAGA,SAAS,iBAAiB;AAE1B,SAAS,SAAS,iBAAiB;AAMnC,SAAS,oBAAoB;AAE7B,SAAS,+BAA+B;AAqChC;AAnCD,IAAM,eAAe,CAAE;AAAA,EAC7B;AAAA,EACA;AACD,MAA6C;AAC5C,QAAM,WAAW,KAAK;AACtB,QAAM,OAAO,KAAK;AAClB,QAAM,SAAS,KAAK;AACpB,QAAM,eAAe,MAAM,SAAU,EAAE,KAAK,CAAE;AAE9C,QAAM,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,gBAAgB;AAAA,IACrB,CAAE,WAAY;AACb,UAAK,CAAE,cAAe;AACrB;AAAA,MACD;AAEA,YAAM,eAAe;AAAA,QACpB;AAAA,MACD,EAAE,iBAAgC,YAAY,eAAe;AAAA,QAC5D,UAAU;AAAA,QACV,WAAW;AAAA,MACZ,CAAE;AACF,YAAM,QAAQ,cAAc;AAAA,QAC3B,CAAE,MAAO,EAAE,SAAS;AAAA,MACrB;AACA,aAAO,QAAQ,aAAc,KAAM,IAAI;AAAA,IACxC;AAAA,IACA,CAAE,UAAU,YAAa;AAAA,EAC1B;AAEA,SAAO,gCAAI,2BAAiB,sBAAsB;AACnD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getItemTitle } from '../../actions/utils';\nimport type { BasePost } from '../../types';\nimport { useDefaultTemplateLabel, useTemplateFieldMode } from './hooks';\n\nfunction ClassicTemplateView( {\n\titem,\n\tfield,\n}: DataViewRenderFieldProps< BasePost > ) {\n\tconst templateSlug = field.getValue( { item } );\n\tconst availableTemplates = ( ( item as Record< string, any > )\n\t\t?.available_templates ?? {} ) as Record< string, string >;\n\n\tconst classicLabel =\n\t\ttemplateSlug && availableTemplates[ templateSlug ]\n\t\t\t? availableTemplates[ templateSlug ]\n\t\t\t: __( 'Default template' );\n\n\treturn <>{ classicLabel }</>;\n}\n\nfunction BlockThemeTemplateView( {\n\titem,\n\tfield,\n}: DataViewRenderFieldProps< BasePost > ) {\n\tconst postType = item.type;\n\tconst slug = item.slug;\n\tconst postId = item.id;\n\tconst templateSlug = field.getValue( { item } );\n\n\tconst defaultTemplateLabel = useDefaultTemplateLabel(\n\t\tpostType,\n\t\tpostId,\n\t\tslug\n\t);\n\n\tconst templateLabel = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! templateSlug ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst allTemplates = select(\n\t\t\t\tcoreStore\n\t\t\t).getEntityRecords< WpTemplate >( 'postType', 'wp_template', {\n\t\t\t\tper_page: -1,\n\t\t\t\tpost_type: postType,\n\t\t\t} );\n\t\t\tconst match = allTemplates?.find(\n\t\t\t\t( t ) => t.slug === templateSlug\n\t\t\t);\n\t\t\treturn match ? getItemTitle( match ) : undefined;\n\t\t},\n\t\t[ postType, templateSlug ]\n\t);\n\n\treturn <>{ templateLabel ?? defaultTemplateLabel }</>;\n}\n\nexport const TemplateView = ( {\n\titem,\n\tfield,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst mode = useTemplateFieldMode( item );\n\tif ( ! mode || ! [ 'block-theme', 'classic' ].includes( mode ) ) {\n\t\treturn null;\n\t}\n\tconst View =\n\t\tmode === 'classic' ? ClassicTemplateView : BlockThemeTemplateView;\n\treturn <View item={ item } field={ field } />;\n};\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAE1B,SAAS,SAAS,iBAAiB;AAEnC,SAAS,UAAU;AAKnB,SAAS,oBAAoB;AAE7B,SAAS,yBAAyB,4BAA4B;AAetD;AAbR,SAAS,oBAAqB;AAAA,EAC7B;AAAA,EACA;AACD,GAA0C;AACzC,QAAM,eAAe,MAAM,SAAU,EAAE,KAAK,CAAE;AAC9C,QAAM,qBAAyB,MAC5B,uBAAuB,CAAC;AAE3B,QAAM,eACL,gBAAgB,mBAAoB,YAAa,IAC9C,mBAAoB,YAAa,IACjC,GAAI,kBAAmB;AAE3B,SAAO,gCAAI,wBAAc;AAC1B;AAEA,SAAS,uBAAwB;AAAA,EAChC;AAAA,EACA;AACD,GAA0C;AACzC,QAAM,WAAW,KAAK;AACtB,QAAM,OAAO,KAAK;AAClB,QAAM,SAAS,KAAK;AACpB,QAAM,eAAe,MAAM,SAAU,EAAE,KAAK,CAAE;AAE9C,QAAM,uBAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,gBAAgB;AAAA,IACrB,CAAE,WAAY;AACb,UAAK,CAAE,cAAe;AACrB;AAAA,MACD;AAEA,YAAM,eAAe;AAAA,QACpB;AAAA,MACD,EAAE,iBAAgC,YAAY,eAAe;AAAA,QAC5D,UAAU;AAAA,QACV,WAAW;AAAA,MACZ,CAAE;AACF,YAAM,QAAQ,cAAc;AAAA,QAC3B,CAAE,MAAO,EAAE,SAAS;AAAA,MACrB;AACA,aAAO,QAAQ,aAAc,KAAM,IAAI;AAAA,IACxC;AAAA,IACA,CAAE,UAAU,YAAa;AAAA,EAC1B;AAEA,SAAO,gCAAI,2BAAiB,sBAAsB;AACnD;AAEO,IAAM,eAAe,CAAE;AAAA,EAC7B;AAAA,EACA;AACD,MAA6C;AAC5C,QAAM,OAAO,qBAAsB,IAAK;AACxC,MAAK,CAAE,QAAQ,CAAE,CAAE,eAAe,SAAU,EAAE,SAAU,IAAK,GAAI;AAChE,WAAO;AAAA,EACR;AACA,QAAM,OACL,SAAS,YAAY,sBAAsB;AAC5C,SAAO,oBAAC,QAAK,MAAc,OAAgB;AAC5C;",
6
6
  "names": []
7
7
  }
@@ -404,6 +404,47 @@ fieldset.fields__media-edit .fields__media-edit-expanded:not(.is-empty) .fields_
404
404
  aspect-ratio: var(--fields-media-edit-expanded-multiple-aspect-ratio, 3/2);
405
405
  }
406
406
 
407
+ .fields-controls__author-avatar {
408
+ flex-shrink: 0;
409
+ overflow: hidden;
410
+ width: 24px;
411
+ height: 24px;
412
+ align-items: center;
413
+ justify-content: right;
414
+ display: flex;
415
+ }
416
+ .fields-controls__author-avatar img {
417
+ width: 16px;
418
+ height: 16px;
419
+ object-fit: cover;
420
+ opacity: 0;
421
+ border-radius: 100%;
422
+ }
423
+ @media not (prefers-reduced-motion) {
424
+ .fields-controls__author-avatar img {
425
+ transition: opacity 0.1s linear;
426
+ }
427
+ }
428
+ .fields-controls__author-avatar.is-loaded img {
429
+ opacity: 1;
430
+ }
431
+
432
+ .fields-controls__author-icon {
433
+ display: flex;
434
+ flex-shrink: 0;
435
+ width: 24px;
436
+ height: 24px;
437
+ }
438
+ .fields-controls__author-icon svg {
439
+ margin-right: -4px;
440
+ fill: currentColor;
441
+ }
442
+
443
+ .fields-controls__author-name {
444
+ text-overflow: ellipsis;
445
+ overflow: hidden;
446
+ }
447
+
407
448
  .fields-controls__slug {
408
449
  border: 0;
409
450
  padding: 0;
@@ -451,6 +492,15 @@ fieldset.fields__media-edit .fields__media-edit-expanded:not(.is-empty) .fields_
451
492
  margin: 0;
452
493
  }
453
494
 
495
+ .fields-controls__status-icon {
496
+ height: 24px;
497
+ width: 24px;
498
+ }
499
+ .fields-controls__status-icon svg {
500
+ fill: currentColor;
501
+ margin-right: -4px;
502
+ }
503
+
454
504
  .fields-field__title > span:first-child {
455
505
  text-overflow: ellipsis;
456
506
  overflow: hidden;
@@ -404,6 +404,47 @@ fieldset.fields__media-edit .fields__media-edit-expanded:not(.is-empty) .fields_
404
404
  aspect-ratio: var(--fields-media-edit-expanded-multiple-aspect-ratio, 3/2);
405
405
  }
406
406
 
407
+ .fields-controls__author-avatar {
408
+ flex-shrink: 0;
409
+ overflow: hidden;
410
+ width: 24px;
411
+ height: 24px;
412
+ align-items: center;
413
+ justify-content: left;
414
+ display: flex;
415
+ }
416
+ .fields-controls__author-avatar img {
417
+ width: 16px;
418
+ height: 16px;
419
+ object-fit: cover;
420
+ opacity: 0;
421
+ border-radius: 100%;
422
+ }
423
+ @media not (prefers-reduced-motion) {
424
+ .fields-controls__author-avatar img {
425
+ transition: opacity 0.1s linear;
426
+ }
427
+ }
428
+ .fields-controls__author-avatar.is-loaded img {
429
+ opacity: 1;
430
+ }
431
+
432
+ .fields-controls__author-icon {
433
+ display: flex;
434
+ flex-shrink: 0;
435
+ width: 24px;
436
+ height: 24px;
437
+ }
438
+ .fields-controls__author-icon svg {
439
+ margin-left: -4px;
440
+ fill: currentColor;
441
+ }
442
+
443
+ .fields-controls__author-name {
444
+ text-overflow: ellipsis;
445
+ overflow: hidden;
446
+ }
447
+
407
448
  .fields-controls__slug {
408
449
  border: 0;
409
450
  padding: 0;
@@ -451,6 +492,15 @@ fieldset.fields__media-edit .fields__media-edit-expanded:not(.is-empty) .fields_
451
492
  margin: 0;
452
493
  }
453
494
 
495
+ .fields-controls__status-icon {
496
+ height: 24px;
497
+ width: 24px;
498
+ }
499
+ .fields-controls__status-icon svg {
500
+ fill: currentColor;
501
+ margin-left: -4px;
502
+ }
503
+
454
504
  .fields-field__title > span:first-child {
455
505
  text-overflow: ellipsis;
456
506
  overflow: hidden;