@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
@@ -20,13 +20,45 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // packages/fields/src/fields/template/hooks.ts
21
21
  var hooks_exports = {};
22
22
  __export(hooks_exports, {
23
- useDefaultTemplateLabel: () => useDefaultTemplateLabel
23
+ useDefaultTemplateLabel: () => useDefaultTemplateLabel,
24
+ useTemplateFieldMode: () => useTemplateFieldMode
24
25
  });
25
26
  module.exports = __toCommonJS(hooks_exports);
26
27
  var import_data = require("@wordpress/data");
27
28
  var import_core_data = require("@wordpress/core-data");
28
29
  var import_utils = require("../../actions/utils.cjs");
29
30
  var import_lock_unlock = require("../../lock-unlock.cjs");
31
+ function useTemplateFieldMode(record) {
32
+ const postType = record.type;
33
+ const availableTemplates = record?.available_templates ?? {};
34
+ const hasAvailableTemplates = Object.keys(availableTemplates).length > 0;
35
+ return (0, import_data.useSelect)(
36
+ (select) => {
37
+ const isBlockTheme = !!select(import_core_data.store).getCurrentTheme()?.is_block_theme;
38
+ const postTypeObj = select(import_core_data.store).getPostType(postType);
39
+ if (!postTypeObj?.viewable) {
40
+ return null;
41
+ }
42
+ const canCreateTemplates = isBlockTheme && (select(import_core_data.store).canUser("create", {
43
+ kind: "postType",
44
+ name: "wp_template"
45
+ }) ?? false);
46
+ const isVisible = hasAvailableTemplates || canCreateTemplates;
47
+ const canViewTemplates = isVisible ? !!select(import_core_data.store).canUser("read", {
48
+ kind: "postType",
49
+ name: "wp_template"
50
+ }) : false;
51
+ if ((!isBlockTheme || !canViewTemplates) && isVisible) {
52
+ return "classic";
53
+ }
54
+ if (isBlockTheme && canViewTemplates) {
55
+ return "block-theme";
56
+ }
57
+ return null;
58
+ },
59
+ [postType, hasAvailableTemplates]
60
+ );
61
+ }
30
62
  function getTemplateSlugToCheck(postType, slug) {
31
63
  if (slug) {
32
64
  return postType === "page" ? `${postType}-${slug}` : `single-${postType}-${slug}`;
@@ -91,6 +123,7 @@ function useDefaultTemplateLabel(postType, postId, slug) {
91
123
  }
92
124
  // Annotate the CommonJS export names for ESM import in node:
93
125
  0 && (module.exports = {
94
- useDefaultTemplateLabel
126
+ useDefaultTemplateLabel,
127
+ useTemplateFieldMode
95
128
  });
96
129
  //# sourceMappingURL=hooks.cjs.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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,uBAAmC;AAMnC,mBAA6B;AAC7B,yBAAuB;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,aAAO;AAAA,IACN,CAAE,WAAY;AACb,UAAK,CAAE,YAAY,CAAE,QAAS;AAC7B,eAAO;AAAA,MACR;AAEA,YAAM,YAAY,OAAQ,MAAO;AAGjC,YAAM,eAAW,2BAAQ,OAAQ,iBAAAA,KAAU,CAAE,EAAE,YAAY;AAC3D,UACC,aAAa,UACb,UAAU,aAAa,UACvB,UAAU,WAAW,WACpB;AACD,cAAM,YAAY;AAAA,UACjB,iBAAAA;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,qBAAO,2BAAc,SAAU;AAAA,QAChC;AAAA,MAID;AAGA,YAAM,kBAAc,2BAAQ,OAAQ,iBAAAA,KAAU,CAAE,EAAE,eAAe;AACjE,UAAK,aAAa,UAAU,gBAAgB,WAAY;AACvD,cAAMC,cAAa,OAAQ,iBAAAD,KAAU,EAAE,qBAAsB;AAAA,UAC5D,MAAM;AAAA,QACP,CAAE;AACF,YAAK,CAAEC,aAAa;AACnB,iBAAO;AAAA,QACR;AAEA,cAAMC,YAAW;AAAA,UAChB,iBAAAF;AAAA,QACD,EAAE;AAAA,UACD;AAAA,UACA;AAAA,UACAC;AAAA,QACD;AACA,eAAOC,gBAAW,2BAAcA,SAAS,IAAI;AAAA,MAC9C;AAGA,YAAM,cAAc,uBAAwB,UAAU,IAAK;AAC3D,YAAM,aAAa,OAAQ,iBAAAF,KAAU,EAAE,qBAAsB;AAAA,QAC5D,MAAM;AAAA,MACP,CAAE;AACF,UAAK,CAAE,YAAa;AACnB,eAAO;AAAA,MACR;AAEA,YAAM,WAAW,OAAQ,iBAAAA,KAAU,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,aAAO,eAAW,2BAAc,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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,uBAAmC;AAMnC,mBAA6B;AAC7B,yBAAuB;AAShB,SAAS,qBACf,QACmC;AACnC,QAAM,WAAW,OAAO;AACxB,QAAM,qBAAyB,QAC5B,uBAAuB,CAAC;AAC3B,QAAM,wBAAwB,OAAO,KAAM,kBAAmB,EAAE,SAAS;AACzE,aAAO;AAAA,IACN,CAAE,WAAY;AACb,YAAM,eACL,CAAC,CAAE,OAAQ,iBAAAA,KAAU,EAAE,gBAAgB,GAAG;AAC3C,YAAM,cAAc,OAAQ,iBAAAA,KAAU,EAAE,YAAa,QAAS;AAC9D,UAAK,CAAE,aAAa,UAAW;AAC9B,eAAO;AAAA,MACR;AACA,YAAM,qBACL,iBACE,OAAQ,iBAAAA,KAAU,EAAE,QAAS,UAAU;AAAA,QACxC,MAAM;AAAA,QACN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MC,cAAa,OAAQ,iBAAAD,KAAU,EAAE,qBAAsB;AAAA,UAC5D,MAAM;AAAA,QACP,CAAE;AACF,YAAK,CAAEC,aAAa;AACnB,iBAAO;AAAA,QACR;AAEA,cAAMC,YAAW;AAAA,UAChB,iBAAAF;AAAA,QACD,EAAE;AAAA,UACD;AAAA,UACA;AAAA,UACAC;AAAA,QACD;AACA,eAAOC,gBAAW,2BAAcA,SAAS,IAAI;AAAA,MAC9C;AAGA,YAAM,cAAc,uBAAwB,UAAU,IAAK;AAC3D,YAAM,aAAa,OAAQ,iBAAAF,KAAU,EAAE,qBAAsB;AAAA,QAC5D,MAAM;AAAA,MACP,CAAE;AACF,UAAK,CAAE,YAAa;AACnB,eAAO;AAAA,MACR;AAEA,YAAM,WAAW,OAAQ,iBAAAA,KAAU,EAAE;AAAA,QACpC;AAAA,QACA;AAAA,QACA;AAAA,MACD;AACA,aAAO,eAAW,2BAAc,QAAS,IAAI;AAAA,IAC9C;AAAA,IACA,CAAE,UAAU,QAAQ,IAAK;AAAA,EAC1B;AACD;",
6
6
  "names": ["coreStore", "templateId", "template"]
7
7
  }
@@ -33,12 +33,52 @@ var import_hooks = require("./hooks.cjs");
33
33
  var import_lock_unlock = require("../../lock-unlock.cjs");
34
34
  var import_jsx_runtime = require("react/jsx-runtime");
35
35
  var EMPTY_ARRAY = [];
36
- var TemplateEdit = ({
36
+ function ClassicTemplateEdit({
37
37
  data,
38
38
  field,
39
39
  onChange
40
- }) => {
41
- const { id } = field;
40
+ }) {
41
+ const postId = typeof data.id === "number" ? data.id : parseInt(data.id, 10);
42
+ const value = field.getValue({ item: data });
43
+ const options = (0, import_element.useMemo)(
44
+ () => Object.entries(
45
+ data?.available_templates ?? {}
46
+ ).map(([templateSlug, title]) => ({
47
+ label: title,
48
+ value: templateSlug
49
+ })),
50
+ [data]
51
+ );
52
+ const canSwitchTemplate = (0, import_data.useSelect)(
53
+ (select) => {
54
+ const { getHomePage, getPostsPageId } = (0, import_lock_unlock.unlock)(
55
+ select(import_core_data.store)
56
+ );
57
+ const singlePostId = String(postId);
58
+ const isPostsPage = getPostsPageId() === singlePostId;
59
+ const isFrontPage = data.type === "page" && getHomePage()?.postId === singlePostId;
60
+ return !isPostsPage && !isFrontPage;
61
+ },
62
+ [postId, data.type]
63
+ );
64
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
+ import_components.SelectControl,
66
+ {
67
+ __next40pxDefaultSize: true,
68
+ label: (0, import_i18n.__)("Template"),
69
+ hideLabelFromVision: true,
70
+ value,
71
+ options,
72
+ onChange,
73
+ disabled: !canSwitchTemplate
74
+ }
75
+ );
76
+ }
77
+ function BlockThemeTemplateEdit({
78
+ data,
79
+ field,
80
+ onChange
81
+ }) {
42
82
  const postType = data.type;
43
83
  const postId = typeof data.id === "number" ? data.id : parseInt(data.id, 10);
44
84
  const slug = data.slug;
@@ -56,8 +96,8 @@ var TemplateEdit = ({
56
96
  select(import_core_data.store)
57
97
  );
58
98
  const singlePostId = String(postId);
59
- const isPostsPage = singlePostId !== void 0 && getPostsPageId() === singlePostId;
60
- const isFrontPage = singlePostId !== void 0 && postType === "page" && getHomePage()?.postId === singlePostId;
99
+ const isPostsPage = getPostsPageId() === singlePostId;
100
+ const isFrontPage = postType === "page" && getHomePage()?.postId === singlePostId;
61
101
  return {
62
102
  templates: allTemplates,
63
103
  canSwitchTemplate: !isPostsPage && !isFrontPage
@@ -71,12 +111,6 @@ var TemplateEdit = ({
71
111
  slug
72
112
  );
73
113
  const value = field.getValue({ item: data });
74
- const onChangeControl = (0, import_element.useCallback)(
75
- (newValue) => onChange({
76
- [id]: newValue
77
- }),
78
- [id, onChange]
79
- );
80
114
  const options = (0, import_element.useMemo)(() => {
81
115
  const templateOptions = templates.map((template) => ({
82
116
  label: (0, import_utils.getItemTitle)(template),
@@ -95,10 +129,28 @@ var TemplateEdit = ({
95
129
  hideLabelFromVision: true,
96
130
  value,
97
131
  options,
98
- onChange: onChangeControl,
132
+ onChange,
99
133
  disabled: !canSwitchTemplate
100
134
  }
101
135
  );
136
+ }
137
+ var TemplateEdit = ({
138
+ data,
139
+ field,
140
+ onChange
141
+ }) => {
142
+ const onChangeControl = (0, import_element.useCallback)(
143
+ (newValue) => onChange({
144
+ [field.id]: newValue
145
+ }),
146
+ [field.id, onChange]
147
+ );
148
+ const mode = (0, import_hooks.useTemplateFieldMode)(data);
149
+ if (!mode || !["block-theme", "classic"].includes(mode)) {
150
+ return null;
151
+ }
152
+ const Edit = mode === "classic" ? ClassicTemplateEdit : BlockThemeTemplateEdit;
153
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Edit, { data, field, onChange: onChangeControl });
102
154
  };
103
155
  // Annotate the CommonJS export names for ESM import in node:
104
156
  0 && (module.exports = {
@@ -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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA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AS,MAAM;AAC9B,UAAM,kBAAkB,UAAU,IAAK,CAAE,cAAgB;AAAA,MACxD,WAAO,2BAAc,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;AAEvC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,WAAQ,gBAAI,UAAW;AAAA,MACvB,qBAAmB;AAAA,MACnB;AAAA,MACA;AAAA,MACA,UAAW;AAAA,MACX,UAAW,CAAE;AAAA;AAAA,EACd;AAEF;",
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, 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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAqC;AAErC,uBAAmC;AAEnC,wBAA8B;AAC9B,kBAA0B;AAC1B,kBAAmB;AAKnB,mBAA6B;AAE7B,mBAA8D;AAC9D,yBAAuB;AA6CrB;AApCF,IAAM,c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AAO,mCAAsB,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,4CAAC,QAAK,MAAc,OAAgB,UAAW,iBAAkB;AACzE;",
6
6
  "names": ["coreStore"]
7
7
  }
@@ -25,13 +25,23 @@ __export(template_view_exports, {
25
25
  module.exports = __toCommonJS(template_view_exports);
26
26
  var import_data = require("@wordpress/data");
27
27
  var import_core_data = require("@wordpress/core-data");
28
+ var import_i18n = require("@wordpress/i18n");
28
29
  var import_utils = require("../../actions/utils.cjs");
29
30
  var import_hooks = require("./hooks.cjs");
30
31
  var import_jsx_runtime = require("react/jsx-runtime");
31
- var TemplateView = ({
32
+ function ClassicTemplateView({
32
33
  item,
33
34
  field
34
- }) => {
35
+ }) {
36
+ const templateSlug = field.getValue({ item });
37
+ const availableTemplates = item?.available_templates ?? {};
38
+ const classicLabel = templateSlug && availableTemplates[templateSlug] ? availableTemplates[templateSlug] : (0, import_i18n.__)("Default template");
39
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: classicLabel });
40
+ }
41
+ function BlockThemeTemplateView({
42
+ item,
43
+ field
44
+ }) {
35
45
  const postType = item.type;
36
46
  const slug = item.slug;
37
47
  const postId = item.id;
@@ -60,6 +70,17 @@ var TemplateView = ({
60
70
  [postType, templateSlug]
61
71
  );
62
72
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: templateLabel ?? defaultTemplateLabel });
73
+ }
74
+ var TemplateView = ({
75
+ item,
76
+ field
77
+ }) => {
78
+ const mode = (0, import_hooks.useTemplateFieldMode)(item);
79
+ if (!mode || !["block-theme", "classic"].includes(mode)) {
80
+ return null;
81
+ }
82
+ const View = mode === "classic" ? ClassicTemplateView : BlockThemeTemplateView;
83
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(View, { item, field });
63
84
  };
64
85
  // Annotate the CommonJS export names for ESM import in node:
65
86
  0 && (module.exports = {
@@ -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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAE1B,uBAAmC;AAMnC,mBAA6B;AAE7B,mBAAwC;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,2BAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,oBAAgB;AAAA,IACrB,CAAE,WAAY;AACb,UAAK,CAAE,cAAe;AACrB;AAAA,MACD;AAEA,YAAM,eAAe;AAAA,QACpB,iBAAAA;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,YAAQ,2BAAc,KAAM,IAAI;AAAA,IACxC;AAAA,IACA,CAAE,UAAU,YAAa;AAAA,EAC1B;AAEA,SAAO,2EAAI,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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAE1B,uBAAmC;AAEnC,kBAAmB;AAKnB,mBAA6B;AAE7B,mBAA8D;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,QACjC,gBAAI,kBAAmB;AAE3B,SAAO,2EAAI,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,2BAAuB;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,oBAAgB;AAAA,IACrB,CAAE,WAAY;AACb,UAAK,CAAE,cAAe;AACrB;AAAA,MACD;AAEA,YAAM,eAAe;AAAA,QACpB,iBAAAA;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,YAAQ,2BAAc,KAAM,IAAI;AAAA,IACxC;AAAA,IACA,CAAE,UAAU,YAAa;AAAA,EAC1B;AAEA,SAAO,2EAAI,2BAAiB,sBAAsB;AACnD;AAEO,IAAM,eAAe,CAAE;AAAA,EAC7B;AAAA,EACA;AACD,MAA6C;AAC5C,QAAM,WAAO,mCAAsB,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,4CAAC,QAAK,MAAc,OAAgB;AAC5C;",
6
6
  "names": ["coreStore"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/types.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\ntype PostStatus =\n\t| 'publish'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface CommonPost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\tcontent: string | { raw: string; rendered: string };\n\ttype: string;\n\tid: string | number;\n\tblocks?: Object[];\n\t_links?: Links;\n}\n\ninterface Links {\n\t'predecessor-version'?: { href: string; id: number }[];\n\t'version-history'?: { href: string; count: number }[];\n\t[ key: string ]: { href: string }[] | undefined;\n}\n\ninterface Author {\n\tid: number;\n\tname: string;\n\tavatar_urls: Record< string, string >;\n}\n\ninterface EmbeddedAuthor {\n\tauthor: Author[];\n}\n\n/**\n * BasePost interface used for all post types.\n */\nexport interface BasePost extends CommonPost {\n\tcomment_status?: 'open' | 'closed';\n\texcerpt?: string | { raw: string; rendered: string };\n\tmeta?: Record< string, any >;\n\tparent?: number;\n\tpassword?: string;\n\ttemplate?: string;\n\tformat?: string;\n\tfeatured_media?: number;\n\tmenu_order?: number;\n\tping_status?: 'open' | 'closed';\n\tlink?: string;\n\tslug?: string;\n\tpermalink_template?: string;\n\tdate?: string;\n\tmodified?: string;\n\tauthor?: number;\n}\n\nexport interface BasePostWithEmbeddedAuthor extends BasePost {\n\t_embedded: EmbeddedAuthor;\n}\n\ninterface FeaturedMedia {\n\ttitle: {\n\t\trendered: string;\n\t};\n\tsource_url: string;\n\tmedia_details: {\n\t\tsizes: Record< string, { width: number; source_url: string } >;\n\t};\n}\n\ninterface EmbeddedFeaturedMedia {\n\t'wp:featuredmedia': FeaturedMedia[];\n}\n\nexport interface BasePostWithEmbeddedFeaturedMedia extends BasePost {\n\t_embedded: EmbeddedFeaturedMedia;\n}\n\nexport interface Template extends CommonPost {\n\ttype: 'wp_template';\n\tis_custom: boolean;\n\tsource: string;\n\torigin: string;\n\tplugin?: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface TemplatePart extends CommonPost {\n\ttype: 'wp_template_part';\n\tsource: string;\n\torigin: string;\n\thas_theme_file: boolean;\n\tid: string;\n\tarea: string;\n\tplugin?: string;\n}\n\nexport interface Pattern extends CommonPost {\n\tslug: string;\n\ttitle: { raw: string };\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = Template | TemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\ninterface EditorSupport {\n\tnotes?: boolean;\n}\n\nexport interface PostType {\n\tslug: string;\n\tviewable: boolean;\n\tsupports?: {\n\t\t'page-attributes'?: boolean;\n\t\ttitle?: boolean;\n\t\trevisions?: boolean;\n\t\tauthor?: string;\n\t\tthumbnail?: string;\n\t\tcomments?: string;\n\t\teditor?: boolean | [ EditorSupport ];\n\t\ttrackbacks?: boolean;\n\t};\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n\nexport interface MediaEditProps< Item >\n\textends Pick<\n\t\tDataFormControlProps< Item >,\n\t\t'data' | 'field' | 'onChange' | 'hideLabelFromVision' | 'validity'\n\t> {\n\t/**\n\t * Array of allowed media types (e.g., ['image', 'video']).\n\t *\n\t * @default ['image']\n\t */\n\tallowedTypes?: string[];\n\t/**\n\t * Whether to allow multiple media selections.\n\t *\n\t * @default false\n\t */\n\tmultiple?: boolean;\n\t/**\n\t * Whether to render in an expanded form.\n\t *\n\t * @default false\n\t */\n\tisExpanded?: boolean;\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\ntype PostStatus =\n\t| 'publish'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface CommonPost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\tcontent: string | { raw: string; rendered: string };\n\ttype: string;\n\tid: string | number;\n\tblocks?: Object[];\n\t_links?: Links;\n}\n\ninterface Links {\n\t'predecessor-version'?: { href: string; id: number }[];\n\t'version-history'?: { href: string; count: number }[];\n\t[ key: string ]: { href: string }[] | undefined;\n}\n\ninterface Author {\n\tid: number;\n\tname: string;\n\tavatar_urls: Record< string, string >;\n}\n\ninterface EmbeddedAuthor {\n\tauthor: Author[];\n}\n\n/**\n * BasePost interface used for all post types.\n */\nexport interface BasePost extends CommonPost {\n\tcomment_status?: 'open' | 'closed';\n\texcerpt?: string | { raw: string; rendered: string };\n\tmeta?: Record< string, any >;\n\tparent?: number;\n\tpassword?: string;\n\ttemplate?: string;\n\tformat?: string;\n\tfeatured_media?: number;\n\tmenu_order?: number;\n\tping_status?: 'open' | 'closed';\n\tlink?: string;\n\tslug?: string;\n\tpermalink_template?: string;\n\tdate?: string;\n\tmodified?: string;\n\tauthor?: number;\n}\n\nexport interface BasePostWithEmbeddedAuthor extends BasePost {\n\t_embedded: EmbeddedAuthor;\n}\n\ninterface FeaturedMedia {\n\ttitle: {\n\t\trendered: string;\n\t};\n\tsource_url: string;\n\tmedia_details: {\n\t\tsizes: Record< string, { width: number; source_url: string } >;\n\t};\n}\n\ninterface EmbeddedFeaturedMedia {\n\t'wp:featuredmedia': FeaturedMedia[];\n}\n\nexport interface BasePostWithEmbeddedFeaturedMedia extends BasePost {\n\t_embedded: EmbeddedFeaturedMedia;\n}\n\nexport interface Template extends CommonPost {\n\ttype: 'wp_template';\n\tis_custom: boolean;\n\tsource: string;\n\torigin: string;\n\tplugin?: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface TemplatePart extends CommonPost {\n\ttype: 'wp_template_part';\n\tsource: string;\n\torigin: string;\n\thas_theme_file: boolean;\n\tid: string;\n\tarea: string;\n\tplugin?: string;\n}\n\nexport interface Pattern extends CommonPost {\n\tslug: string;\n\ttitle: { raw: string };\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = Template | TemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\ninterface EditorSupport {\n\tnotes?: boolean;\n}\n\nexport interface PostType {\n\tslug: string;\n\tviewable: boolean;\n\tsupports?: {\n\t\t'page-attributes'?: boolean;\n\t\ttitle?: boolean;\n\t\trevisions?: boolean;\n\t\tauthor?: string;\n\t\tthumbnail?: string;\n\t\tcomments?: string;\n\t\teditor?: boolean | [ EditorSupport ];\n\t\ttrackbacks?: boolean;\n\t\t'post-formats'?: boolean;\n\t};\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n\nexport interface MediaEditProps< Item >\n\textends Pick<\n\t\tDataFormControlProps< Item >,\n\t\t'data' | 'field' | 'onChange' | 'hideLabelFromVision' | 'validity'\n\t> {\n\t/**\n\t * Array of allowed media types (e.g., ['image', 'video']).\n\t *\n\t * @default ['image']\n\t */\n\tallowedTypes?: string[];\n\t/**\n\t * Whether to allow multiple media selections.\n\t *\n\t * @default false\n\t */\n\tmultiple?: boolean;\n\t/**\n\t * Whether to render in an expanded form.\n\t *\n\t * @default false\n\t */\n\tisExpanded?: boolean;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -11,7 +11,7 @@ function AuthorView({ item }) {
11
11
  const authorId = item?.author;
12
12
  const embeddedAuthorId = item?._embedded?.author?.[0]?.id;
13
13
  const shouldFetch = Boolean(
14
- authorId && embeddedAuthorId && authorId !== embeddedAuthorId
14
+ authorId && (!embeddedAuthorId || authorId !== embeddedAuthorId)
15
15
  );
16
16
  const author = useSelect(
17
17
  (select) => {
@@ -30,7 +30,7 @@ function AuthorView({ item }) {
30
30
  !!imageUrl && /* @__PURE__ */ jsx(
31
31
  "div",
32
32
  {
33
- className: clsx("page-templates-author-field__avatar", {
33
+ className: clsx("fields-controls__author-avatar", {
34
34
  "is-loaded": isImageLoaded
35
35
  }),
36
36
  children: /* @__PURE__ */ jsx(
@@ -43,8 +43,8 @@ function AuthorView({ item }) {
43
43
  )
44
44
  }
45
45
  ),
46
- !imageUrl && /* @__PURE__ */ jsx("div", { className: "page-templates-author-field__icon", children: /* @__PURE__ */ jsx(Icon, { icon: authorIcon }) }),
47
- /* @__PURE__ */ jsx("span", { className: "page-templates-author-field__name", children: text })
46
+ !imageUrl && /* @__PURE__ */ jsx("div", { className: "fields-controls__author-icon", children: /* @__PURE__ */ jsx(Icon, { icon: authorIcon }) }),
47
+ /* @__PURE__ */ jsx("span", { className: "fields-controls__author-name", children: text })
48
48
  ] });
49
49
  }
50
50
  var author_view_default = AuthorView;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/author/author-view.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { commentAuthorAvatar as authorIcon } from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePostWithEmbeddedAuthor } from '../../types';\n\nfunction AuthorView( { item }: { item: BasePostWithEmbeddedAuthor } ) {\n\t// When editing, item.author may differ from _embedded.author (which preserves\n\t// the saved record). Fetch the updated author only when they differ, so the\n\t// view reflects edits while lists preserve original data.\n\tconst authorId = item?.author;\n\tconst embeddedAuthorId = item?._embedded?.author?.[ 0 ]?.id;\n\tconst shouldFetch = Boolean(\n\t\tauthorId && embeddedAuthorId && authorId !== embeddedAuthorId\n\t);\n\tconst author = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! shouldFetch ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\t// This doesn't make extra REST requests because the records are\n\t\t\t// already in the store from the field's getElements function.\n\t\t\treturn authorId\n\t\t\t\t? getEntityRecord( 'root', 'user', authorId )\n\t\t\t\t: null;\n\t\t},\n\t\t[ authorId, shouldFetch ]\n\t);\n\t// Use fetched author if available, otherwise use _embedded.\n\tconst text = author?.name || item?._embedded?.author?.[ 0 ]?.name;\n\tconst imageUrl =\n\t\tauthor?.avatar_urls?.[ 48 ] ||\n\t\titem?._embedded?.author?.[ 0 ]?.avatar_urls?.[ 48 ];\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'page-templates-author-field__avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"page-templates-author-field__icon\">\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"page-templates-author-field__name\">{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default AuthorView;\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,uBAAuB,kBAAkB;AAClD,SAAS,wBAAwB,QAAQ,YAAY;AACrD,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AAqCjC,SAOG,KAPH;AA9BF,SAAS,WAAY,EAAE,KAAK,GAA0C;AAIrE,QAAM,WAAW,MAAM;AACvB,QAAM,mBAAmB,MAAM,WAAW,SAAU,CAAE,GAAG;AACzD,QAAM,cAAc;AAAA,IACnB,YAAY,oBAAoB,aAAa;AAAA,EAC9C;AACA,QAAM,SAAS;AAAA,IACd,CAAE,WAAY;AACb,UAAK,CAAE,aAAc;AACpB,eAAO;AAAA,MACR;AACA,YAAM,EAAE,gBAAgB,IAAI,OAAQ,SAAU;AAG9C,aAAO,WACJ,gBAAiB,QAAQ,QAAQ,QAAS,IAC1C;AAAA,IACJ;AAAA,IACA,CAAE,UAAU,WAAY;AAAA,EACzB;AAEA,QAAM,OAAO,QAAQ,QAAQ,MAAM,WAAW,SAAU,CAAE,GAAG;AAC7D,QAAM,WACL,QAAQ,cAAe,EAAG,KAC1B,MAAM,WAAW,SAAU,CAAE,GAAG,cAAe,EAAG;AACnD,QAAM,CAAE,eAAe,gBAAiB,IAAI,SAAU,KAAM;AAC5D,SACC,qBAAC,UAAO,WAAU,QAAO,SAAU,GAChC;AAAA,KAAC,CAAE,YACJ;AAAA,MAAC;AAAA;AAAA,QACA,WAAY,KAAM,uCAAuC;AAAA,UACxD,aAAa;AAAA,QACd,CAAE;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACA,QAAS,MAAM,iBAAkB,IAAK;AAAA,YACtC,KAAM,GAAI,eAAgB;AAAA,YAC1B,KAAM;AAAA;AAAA,QACP;AAAA;AAAA,IACD;AAAA,IAEC,CAAE,YACH,oBAAC,SAAI,WAAU,qCACd,8BAAC,QAAK,MAAO,YAAa,GAC3B;AAAA,IAED,oBAAC,UAAK,WAAU,qCAAsC,gBAAM;AAAA,KAC7D;AAEF;AAEA,IAAO,sBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { commentAuthorAvatar as authorIcon } from '@wordpress/icons';\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePostWithEmbeddedAuthor } from '../../types';\n\nfunction AuthorView( { item }: { item: BasePostWithEmbeddedAuthor } ) {\n\t// Fetch the author record from the store when _embedded data is unavailable\n\t// (e.g. in the post editor inspector) or when the author has been changed\n\t// during editing (item.author differs from _embedded.author).\n\tconst authorId = item?.author;\n\tconst embeddedAuthorId = item?._embedded?.author?.[ 0 ]?.id;\n\tconst shouldFetch = Boolean(\n\t\tauthorId && ( ! embeddedAuthorId || authorId !== embeddedAuthorId )\n\t);\n\tconst author = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! shouldFetch ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\t// This doesn't make extra REST requests because the records are\n\t\t\t// already in the store from the field's getElements function.\n\t\t\treturn authorId\n\t\t\t\t? getEntityRecord( 'root', 'user', authorId )\n\t\t\t\t: null;\n\t\t},\n\t\t[ authorId, shouldFetch ]\n\t);\n\t// Use fetched author if available, otherwise use _embedded.\n\tconst text = author?.name || item?._embedded?.author?.[ 0 ]?.name;\n\tconst imageUrl =\n\t\tauthor?.avatar_urls?.[ 48 ] ||\n\t\titem?._embedded?.author?.[ 0 ]?.avatar_urls?.[ 48 ];\n\tconst [ isImageLoaded, setIsImageLoaded ] = useState( false );\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ !! imageUrl && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'fields-controls__author-avatar', {\n\t\t\t\t\t\t'is-loaded': isImageLoaded,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t<img\n\t\t\t\t\t\tonLoad={ () => setIsImageLoaded( true ) }\n\t\t\t\t\t\talt={ __( 'Author avatar' ) }\n\t\t\t\t\t\tsrc={ imageUrl }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! imageUrl && (\n\t\t\t\t<div className=\"fields-controls__author-icon\">\n\t\t\t\t\t<Icon icon={ authorIcon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span className=\"fields-controls__author-name\">{ text }</span>\n\t\t</H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O,YAAa,GAC3B;AAAA,IAED,oBAAC,UAAK,WAAU,gCAAiC,gBAAM;AAAA,KACxD;AAEF;AAEA,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,18 @@
1
+ // packages/fields/src/fields/date/scheduled/index.tsx
2
+ import { __ } from "@wordpress/i18n";
3
+ var scheduledDateField = {
4
+ id: "scheduled_date",
5
+ type: "datetime",
6
+ label: __("Scheduled Date"),
7
+ getValue: ({ item }) => item.date,
8
+ setValue: ({ value }) => ({ date: value }),
9
+ isVisible: (item) => item.status === "future",
10
+ enableHiding: false,
11
+ enableSorting: false,
12
+ filterBy: false
13
+ };
14
+ var scheduled_default = scheduledDateField;
15
+ export {
16
+ scheduled_default as default
17
+ };
18
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/fields/date/scheduled/index.tsx"],
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';\n\nconst scheduledDateField: Field< BasePost > = {\n\tid: 'scheduled_date',\n\ttype: 'datetime',\n\tlabel: __( 'Scheduled Date' ),\n\tgetValue: ( { item } ) => item.date,\n\tsetValue: ( { value } ) => ( { date: value } ),\n\tisVisible: ( item ) => item.status === 'future',\n\tenableHiding: false,\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * ScheduledDate Field.\n */\nexport default scheduledDateField;\n"],
5
+ "mappings": ";AAIA,SAAS,UAAU;AAOnB,IAAM,qBAAwC;AAAA,EAC7C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,gBAAiB;AAAA,EAC5B,UAAU,CAAE,EAAE,KAAK,MAAO,KAAK;AAAA,EAC/B,UAAU,CAAE,EAAE,MAAM,OAAS,EAAE,MAAM,MAAM;AAAA,EAC3C,WAAW,CAAE,SAAU,KAAK,WAAW;AAAA,EACvC,cAAc;AAAA,EACd,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,oBAAQ;",
6
+ "names": []
7
+ }
@@ -7,6 +7,7 @@ var featuredImageField = {
7
7
  id: "featured_media",
8
8
  type: "media",
9
9
  label: __("Featured Image"),
10
+ placeholder: __("Set featured image"),
10
11
  Edit: (props) => /* @__PURE__ */ jsx(MediaEdit, { ...props, isExpanded: true }),
11
12
  render: FeaturedImageView,
12
13
  setValue: ({ value }) => ({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/featured-image/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport MediaEdit from '../../components/media-edit';\nimport type { BasePostWithEmbeddedFeaturedMedia } from '../../types';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePostWithEmbeddedFeaturedMedia > = {\n\tid: 'featured_media',\n\ttype: 'media',\n\tlabel: __( 'Featured Image' ),\n\tEdit: ( props ) => <MediaEdit { ...props } isExpanded />,\n\trender: FeaturedImageView,\n\tsetValue: ( { value } ) => ( {\n\t\tfeatured_media: value ?? 0,\n\t} ),\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * Featured Image field for BasePostWithEmbeddedFeaturedMedia.\n */\nexport default featuredImageField;\n"],
5
- "mappings": ";AAIA,SAAS,UAAU;AAKnB,OAAO,eAAe;AAEtB,SAAS,yBAAyB;AAMd;AAJpB,IAAM,qBAAiE;AAAA,EACtE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,gBAAiB;AAAA,EAC5B,MAAM,CAAE,UAAW,oBAAC,aAAY,GAAG,OAAQ,YAAU,MAAC;AAAA,EACtD,QAAQ;AAAA,EACR,UAAU,CAAE,EAAE,MAAM,OAAS;AAAA,IAC5B,gBAAgB,SAAS;AAAA,EAC1B;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,yBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport MediaEdit from '../../components/media-edit';\nimport type { BasePostWithEmbeddedFeaturedMedia } from '../../types';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePostWithEmbeddedFeaturedMedia > = {\n\tid: 'featured_media',\n\ttype: 'media',\n\tlabel: __( 'Featured Image' ),\n\tplaceholder: __( 'Set featured image' ),\n\tEdit: ( props ) => <MediaEdit { ...props } isExpanded />,\n\trender: FeaturedImageView,\n\tsetValue: ( { value } ) => ( {\n\t\tfeatured_media: value ?? 0,\n\t} ),\n\tenableSorting: false,\n\tfilterBy: false,\n};\n\n/**\n * Featured Image field for BasePostWithEmbeddedFeaturedMedia.\n */\nexport default featuredImageField;\n"],
5
+ "mappings": ";AAIA,SAAS,UAAU;AAKnB,OAAO,eAAe;AAEtB,SAAS,yBAAyB;AAOd;AALpB,IAAM,qBAAiE;AAAA,EACtE,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,gBAAiB;AAAA,EAC5B,aAAa,GAAI,oBAAqB;AAAA,EACtC,MAAM,CAAE,UAAW,oBAAC,aAAY,GAAG,OAAQ,YAAU,MAAC;AAAA,EACtD,QAAQ;AAAA,EACR,UAAU,CAAE,EAAE,MAAM,OAAS;AAAA,IAC5B,gBAAgB,SAAS;AAAA,EAC1B;AAAA,EACA,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,yBAAQ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,48 @@
1
+ // packages/fields/src/fields/format/index.ts
2
+ import { __ } from "@wordpress/i18n";
3
+ import { resolveSelect } from "@wordpress/data";
4
+ import { store as coreStore } from "@wordpress/core-data";
5
+ var POST_FORMATS = [
6
+ { id: "aside", caption: __("Aside") },
7
+ { id: "audio", caption: __("Audio") },
8
+ { id: "chat", caption: __("Chat") },
9
+ { id: "gallery", caption: __("Gallery") },
10
+ { id: "image", caption: __("Image") },
11
+ { id: "link", caption: __("Link") },
12
+ { id: "quote", caption: __("Quote") },
13
+ { id: "standard", caption: __("Standard") },
14
+ { id: "status", caption: __("Status") },
15
+ { id: "video", caption: __("Video") }
16
+ ].sort((a, b) => {
17
+ const normalizedA = a.caption.toUpperCase();
18
+ const normalizedB = b.caption.toUpperCase();
19
+ if (normalizedA < normalizedB) {
20
+ return -1;
21
+ }
22
+ if (normalizedA > normalizedB) {
23
+ return 1;
24
+ }
25
+ return 0;
26
+ });
27
+ var formatField = {
28
+ id: "format",
29
+ label: __("Format"),
30
+ type: "text",
31
+ Edit: "radio",
32
+ enableSorting: false,
33
+ enableHiding: false,
34
+ filterBy: false,
35
+ getElements: async () => {
36
+ const themeSupports = await resolveSelect(coreStore).getThemeSupports();
37
+ return POST_FORMATS.filter(
38
+ (f) => themeSupports?.formats?.includes(
39
+ f.id
40
+ )
41
+ ).map((f) => ({ value: f.id, label: f.caption }));
42
+ }
43
+ };
44
+ var format_default = formatField;
45
+ export {
46
+ format_default as default
47
+ };
48
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/fields/format/index.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\nimport { resolveSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\n// All WP post formats, sorted alphabetically by translated name.\nconst POST_FORMATS = [\n\t{ id: 'aside', caption: __( 'Aside' ) },\n\t{ id: 'audio', caption: __( 'Audio' ) },\n\t{ id: 'chat', caption: __( 'Chat' ) },\n\t{ id: 'gallery', caption: __( 'Gallery' ) },\n\t{ id: 'image', caption: __( 'Image' ) },\n\t{ id: 'link', caption: __( 'Link' ) },\n\t{ id: 'quote', caption: __( 'Quote' ) },\n\t{ id: 'standard', caption: __( 'Standard' ) },\n\t{ id: 'status', caption: __( 'Status' ) },\n\t{ id: 'video', caption: __( 'Video' ) },\n].sort( ( a, b ) => {\n\tconst normalizedA = a.caption.toUpperCase();\n\tconst normalizedB = b.caption.toUpperCase();\n\n\tif ( normalizedA < normalizedB ) {\n\t\treturn -1;\n\t}\n\tif ( normalizedA > normalizedB ) {\n\t\treturn 1;\n\t}\n\treturn 0;\n} );\n\nconst formatField: Field< BasePost > = {\n\tid: 'format',\n\tlabel: __( 'Format' ),\n\ttype: 'text',\n\tEdit: 'radio',\n\tenableSorting: false,\n\tenableHiding: false,\n\tfilterBy: false,\n\tgetElements: async () => {\n\t\tconst themeSupports =\n\t\t\tawait resolveSelect( coreStore ).getThemeSupports();\n\t\treturn POST_FORMATS.filter(\n\t\t\t( f ) =>\n\t\t\t\t( themeSupports?.formats as string[] | undefined )?.includes(\n\t\t\t\t\tf.id\n\t\t\t\t)\n\t\t).map( ( f ) => ( { value: f.id, label: f.caption } ) );\n\t},\n};\n\n/**\n * Format field for BasePost.\n */\nexport default formatField;\n"],
5
+ "mappings": ";AAIA,SAAS,UAAU;AACnB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,iBAAiB;AAQnC,IAAM,eAAe;AAAA,EACpB,EAAE,IAAI,SAAS,SAAS,GAAI,OAAQ,EAAE;AAAA,EACtC,EAAE,IAAI,SAAS,SAAS,GAAI,OAAQ,EAAE;AAAA,EACtC,EAAE,IAAI,QAAQ,SAAS,GAAI,MAAO,EAAE;AAAA,EACpC,EAAE,IAAI,WAAW,SAAS,GAAI,SAAU,EAAE;AAAA,EAC1C,EAAE,IAAI,SAAS,SAAS,GAAI,OAAQ,EAAE;AAAA,EACtC,EAAE,IAAI,QAAQ,SAAS,GAAI,MAAO,EAAE;AAAA,EACpC,EAAE,IAAI,SAAS,SAAS,GAAI,OAAQ,EAAE;AAAA,EACtC,EAAE,IAAI,YAAY,SAAS,GAAI,UAAW,EAAE;AAAA,EAC5C,EAAE,IAAI,UAAU,SAAS,GAAI,QAAS,EAAE;AAAA,EACxC,EAAE,IAAI,SAAS,SAAS,GAAI,OAAQ,EAAE;AACvC,EAAE,KAAM,CAAE,GAAG,MAAO;AACnB,QAAM,cAAc,EAAE,QAAQ,YAAY;AAC1C,QAAM,cAAc,EAAE,QAAQ,YAAY;AAE1C,MAAK,cAAc,aAAc;AAChC,WAAO;AAAA,EACR;AACA,MAAK,cAAc,aAAc;AAChC,WAAO;AAAA,EACR;AACA,SAAO;AACR,CAAE;AAEF,IAAM,cAAiC;AAAA,EACtC,IAAI;AAAA,EACJ,OAAO,GAAI,QAAS;AAAA,EACpB,MAAM;AAAA,EACN,MAAM;AAAA,EACN,eAAe;AAAA,EACf,cAAc;AAAA,EACd,UAAU;AAAA,EACV,aAAa,YAAY;AACxB,UAAM,gBACL,MAAM,cAAe,SAAU,EAAE,iBAAiB;AACnD,WAAO,aAAa;AAAA,MACnB,CAAE,MACC,eAAe,SAAmC;AAAA,QACnD,EAAE;AAAA,MACH;AAAA,IACF,EAAE,IAAK,CAAE,OAAS,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,QAAQ,EAAI;AAAA,EACvD;AACD;AAKA,IAAO,iBAAQ;",
6
+ "names": []
7
+ }
@@ -14,21 +14,27 @@ import { default as default13 } from "./comment-status/index.mjs";
14
14
  import { default as default14 } from "./ping-status/index.mjs";
15
15
  import { default as default15 } from "./discussion/index.mjs";
16
16
  import { default as default16 } from "./date/index.mjs";
17
- import { default as default17 } from "./author/index.mjs";
18
- import { default as default18 } from "./notes/index.mjs";
17
+ import { default as default17 } from "./date/scheduled/index.mjs";
18
+ import { default as default18 } from "./author/index.mjs";
19
+ import { default as default19 } from "./notes/index.mjs";
20
+ import { default as default20 } from "./format/index.mjs";
21
+ import { default as default21 } from "./post-content-info/index.mjs";
19
22
  export {
20
- default17 as authorField,
23
+ default18 as authorField,
21
24
  default13 as commentStatusField,
22
25
  default16 as dateField,
23
26
  default15 as discussionField,
24
27
  default8 as featuredImageField,
25
- default18 as notesField,
28
+ default20 as formatField,
29
+ default19 as notesField,
26
30
  default7 as orderField,
27
31
  default4 as pageTitleField,
28
32
  default10 as parentField,
29
33
  default11 as passwordField,
30
34
  default6 as patternTitleField,
31
35
  default14 as pingStatusField,
36
+ default21 as postContentInfoField,
37
+ default17 as scheduledDateField,
32
38
  default2 as slugField,
33
39
  default12 as statusField,
34
40
  default9 as templateField,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/fields/index.ts"],
4
- "sourcesContent": ["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as pageTitleField } from './page-title';\nexport { default as templateTitleField } from './template-title';\nexport { default as patternTitleField } from './pattern-title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as templateField } from './template';\nexport { default as parentField } from './parent';\nexport { default as passwordField } from './password';\nexport { default as statusField } from './status';\nexport { default as commentStatusField } from './comment-status';\nexport { default as pingStatusField } from './ping-status';\nexport { default as discussionField } from './discussion';\nexport { default as dateField } from './date';\nexport { default as authorField } from './author';\nexport { default as notesField } from './notes';\n"],
5
- "mappings": ";AAAA,SAAoB,WAAXA,gBAA4B;AACrC,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAoC;AAC7C,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAA4B;AACrC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA6B;",
4
+ "sourcesContent": ["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as pageTitleField } from './page-title';\nexport { default as templateTitleField } from './template-title';\nexport { default as patternTitleField } from './pattern-title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as templateField } from './template';\nexport { default as parentField } from './parent';\nexport { default as passwordField } from './password';\nexport { default as statusField } from './status';\nexport { default as commentStatusField } from './comment-status';\nexport { default as pingStatusField } from './ping-status';\nexport { default as discussionField } from './discussion';\nexport { default as dateField } from './date';\nexport { default as scheduledDateField } from './date/scheduled';\nexport { default as authorField } from './author';\nexport { default as notesField } from './notes';\nexport { default as formatField } from './format';\nexport { default as postContentInfoField } from './post-content-info';\n"],
5
+ "mappings": ";AAAA,SAAoB,WAAXA,gBAA4B;AACrC,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAoC;AAC7C,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAA4B;AACrC,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA6B;AACtC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAuC;",
6
6
  "names": ["default"]
7
7
  }
@@ -64,7 +64,7 @@ function PageAttributesParent({
64
64
  data,
65
65
  onChangeControl
66
66
  }) {
67
- const [fieldValue, setFieldValue] = useState(null);
67
+ const [fieldValue, setFieldValue] = useState("");
68
68
  const pageId = data.parent;
69
69
  const postId = data.id;
70
70
  const postTypeSlug = data.type;
@@ -85,7 +85,7 @@ function PageAttributesParent({
85
85
  orderby: "menu_order",
86
86
  order: "asc",
87
87
  _fields: "id,title,parent",
88
- ...fieldValue !== null && {
88
+ ...!!fieldValue && {
89
89
  // Perform a search by relevance when the field is changed.
90
90
  search: fieldValue,
91
91
  orderby: "relevance"
@@ -114,14 +114,8 @@ function PageAttributesParent({
114
114
  ...getOptionsFromTree(treeNode.children || [], level + 1)
115
115
  ]);
116
116
  const sortedNodes = mappedNodes.sort(([a], [b]) => {
117
- const priorityA = getItemPriority(
118
- a.rawName,
119
- fieldValue ?? ""
120
- );
121
- const priorityB = getItemPriority(
122
- b.rawName,
123
- fieldValue ?? ""
124
- );
117
+ const priorityA = getItemPriority(a.rawName, fieldValue);
118
+ const priorityB = getItemPriority(b.rawName, fieldValue);
125
119
  return priorityA >= priorityB ? 1 : -1;
126
120
  });
127
121
  return sortedNodes.flat();