@wordpress/fields 0.5.1-next.cd6172eb0.0 → 0.7.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 (267) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +32 -36
  4. package/build/actions/delete-post.js +5 -0
  5. package/build/actions/delete-post.js.map +1 -1
  6. package/build/actions/duplicate-pattern.js +4 -0
  7. package/build/actions/duplicate-pattern.js.map +1 -1
  8. package/build/actions/duplicate-post.js +8 -3
  9. package/build/actions/duplicate-post.js.map +1 -1
  10. package/build/actions/duplicate-template-part.js +3 -0
  11. package/build/actions/duplicate-template-part.js.map +1 -1
  12. package/build/actions/export-pattern.js +5 -0
  13. package/build/actions/export-pattern.js.map +1 -1
  14. package/build/actions/index.js +0 -21
  15. package/build/actions/index.js.map +1 -1
  16. package/build/actions/permanently-delete-post.js +109 -65
  17. package/build/actions/permanently-delete-post.js.map +1 -1
  18. package/build/actions/rename-post.js +4 -0
  19. package/build/actions/rename-post.js.map +1 -1
  20. package/build/actions/reorder-page.js +4 -0
  21. package/build/actions/reorder-page.js.map +1 -1
  22. package/build/actions/reset-post.js +4 -0
  23. package/build/actions/reset-post.js.map +1 -1
  24. package/build/actions/restore-post.js +5 -0
  25. package/build/actions/restore-post.js.map +1 -1
  26. package/build/actions/trash-post.js +5 -0
  27. package/build/actions/trash-post.js.map +1 -1
  28. package/build/actions/view-post-revisions.js +4 -0
  29. package/build/actions/view-post-revisions.js.map +1 -1
  30. package/build/actions/view-post.js +4 -0
  31. package/build/actions/view-post.js.map +1 -1
  32. package/build/components/create-template-part-modal/index.js +48 -52
  33. package/build/components/create-template-part-modal/index.js.map +1 -1
  34. package/build/components/create-template-part-modal/utils.js +1 -0
  35. package/build/components/create-template-part-modal/utils.js.map +1 -1
  36. package/build/fields/featured-image/index.js +4 -0
  37. package/build/fields/featured-image/index.js.map +1 -1
  38. package/build/fields/index.js +21 -0
  39. package/build/fields/index.js.map +1 -1
  40. package/build/fields/order/index.js +4 -0
  41. package/build/fields/order/index.js.map +1 -1
  42. package/build/fields/page-title/index.js +36 -0
  43. package/build/fields/page-title/index.js.map +1 -0
  44. package/build/fields/page-title/view.js +49 -0
  45. package/build/fields/page-title/view.js.map +1 -0
  46. package/build/fields/parent/index.js +1 -1
  47. package/build/fields/parent/index.js.map +1 -1
  48. package/build/fields/parent/parent-edit.js +1 -0
  49. package/build/fields/parent/parent-edit.js.map +1 -1
  50. package/build/fields/password/index.js +1 -1
  51. package/build/fields/password/index.js.map +1 -1
  52. package/build/fields/pattern-title/index.js +36 -0
  53. package/build/fields/pattern-title/index.js.map +1 -0
  54. package/build/fields/pattern-title/view.js +45 -0
  55. package/build/fields/pattern-title/view.js.map +1 -0
  56. package/build/fields/slug/index.js +4 -0
  57. package/build/fields/slug/index.js.map +1 -1
  58. package/build/fields/status/status-view.js +1 -0
  59. package/build/fields/status/status-view.js.map +1 -1
  60. package/build/fields/template/index.js +4 -3
  61. package/build/fields/template/index.js.map +1 -1
  62. package/build/fields/template/template-edit.js +1 -0
  63. package/build/fields/template/template-edit.js.map +1 -1
  64. package/build/fields/template-title/index.js +36 -0
  65. package/build/fields/template-title/index.js.map +1 -0
  66. package/build/fields/title/index.js +10 -3
  67. package/build/fields/title/index.js.map +1 -1
  68. package/build/fields/title/view.js +48 -0
  69. package/build/fields/title/view.js.map +1 -0
  70. package/build/index.native.js +0 -26
  71. package/build/index.native.js.map +1 -1
  72. package/build/mutation/index.js +1 -0
  73. package/build/mutation/index.js.map +1 -1
  74. package/build-module/actions/delete-post.js +5 -0
  75. package/build-module/actions/delete-post.js.map +1 -1
  76. package/build-module/actions/duplicate-pattern.js +4 -0
  77. package/build-module/actions/duplicate-pattern.js.map +1 -1
  78. package/build-module/actions/duplicate-post.js +8 -3
  79. package/build-module/actions/duplicate-post.js.map +1 -1
  80. package/build-module/actions/duplicate-template-part.js +3 -0
  81. package/build-module/actions/duplicate-template-part.js.map +1 -1
  82. package/build-module/actions/export-pattern.js +5 -0
  83. package/build-module/actions/export-pattern.js.map +1 -1
  84. package/build-module/actions/index.js +0 -3
  85. package/build-module/actions/index.js.map +1 -1
  86. package/build-module/actions/permanently-delete-post.js +110 -66
  87. package/build-module/actions/permanently-delete-post.js.map +1 -1
  88. package/build-module/actions/rename-post.js +4 -0
  89. package/build-module/actions/rename-post.js.map +1 -1
  90. package/build-module/actions/reorder-page.js +4 -0
  91. package/build-module/actions/reorder-page.js.map +1 -1
  92. package/build-module/actions/reset-post.js +4 -0
  93. package/build-module/actions/reset-post.js.map +1 -1
  94. package/build-module/actions/restore-post.js +5 -0
  95. package/build-module/actions/restore-post.js.map +1 -1
  96. package/build-module/actions/trash-post.js +5 -0
  97. package/build-module/actions/trash-post.js.map +1 -1
  98. package/build-module/actions/view-post-revisions.js +4 -0
  99. package/build-module/actions/view-post-revisions.js.map +1 -1
  100. package/build-module/actions/view-post.js +4 -0
  101. package/build-module/actions/view-post.js.map +1 -1
  102. package/build-module/components/create-template-part-modal/index.js +49 -53
  103. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  104. package/build-module/components/create-template-part-modal/utils.js +1 -0
  105. package/build-module/components/create-template-part-modal/utils.js.map +1 -1
  106. package/build-module/fields/featured-image/index.js +4 -0
  107. package/build-module/fields/featured-image/index.js.map +1 -1
  108. package/build-module/fields/index.js +3 -0
  109. package/build-module/fields/index.js.map +1 -1
  110. package/build-module/fields/order/index.js +4 -0
  111. package/build-module/fields/order/index.js.map +1 -1
  112. package/build-module/fields/page-title/index.js +30 -0
  113. package/build-module/fields/page-title/index.js.map +1 -0
  114. package/build-module/fields/page-title/view.js +43 -0
  115. package/build-module/fields/page-title/view.js.map +1 -0
  116. package/build-module/fields/parent/index.js +1 -1
  117. package/build-module/fields/parent/index.js.map +1 -1
  118. package/build-module/fields/parent/parent-edit.js +1 -0
  119. package/build-module/fields/parent/parent-edit.js.map +1 -1
  120. package/build-module/fields/password/index.js +1 -1
  121. package/build-module/fields/password/index.js.map +1 -1
  122. package/build-module/fields/pattern-title/index.js +30 -0
  123. package/build-module/fields/pattern-title/index.js.map +1 -0
  124. package/build-module/fields/pattern-title/view.js +36 -0
  125. package/build-module/fields/pattern-title/view.js.map +1 -0
  126. package/build-module/fields/slug/index.js +4 -0
  127. package/build-module/fields/slug/index.js.map +1 -1
  128. package/build-module/fields/status/status-view.js +1 -0
  129. package/build-module/fields/status/status-view.js.map +1 -1
  130. package/build-module/fields/template/index.js +4 -3
  131. package/build-module/fields/template/index.js.map +1 -1
  132. package/build-module/fields/template/template-edit.js +1 -0
  133. package/build-module/fields/template/template-edit.js.map +1 -1
  134. package/build-module/fields/template-title/index.js +30 -0
  135. package/build-module/fields/template-title/index.js.map +1 -0
  136. package/build-module/fields/title/index.js +9 -2
  137. package/build-module/fields/title/index.js.map +1 -1
  138. package/build-module/fields/title/view.js +39 -0
  139. package/build-module/fields/title/view.js.map +1 -0
  140. package/build-module/index.native.js +1 -2
  141. package/build-module/index.native.js.map +1 -1
  142. package/build-module/mutation/index.js +1 -0
  143. package/build-module/mutation/index.js.map +1 -1
  144. package/build-style/style-rtl.css +62 -32
  145. package/build-style/style.css +62 -32
  146. package/build-types/actions/delete-post.d.ts +3 -0
  147. package/build-types/actions/delete-post.d.ts.map +1 -1
  148. package/build-types/actions/duplicate-pattern.d.ts +3 -0
  149. package/build-types/actions/duplicate-pattern.d.ts.map +1 -1
  150. package/build-types/actions/duplicate-post.d.ts +3 -0
  151. package/build-types/actions/duplicate-post.d.ts.map +1 -1
  152. package/build-types/actions/duplicate-template-part.d.ts +3 -0
  153. package/build-types/actions/duplicate-template-part.d.ts.map +1 -1
  154. package/build-types/actions/export-pattern.d.ts +3 -0
  155. package/build-types/actions/export-pattern.d.ts.map +1 -1
  156. package/build-types/actions/index.d.ts +0 -3
  157. package/build-types/actions/index.d.ts.map +1 -1
  158. package/build-types/actions/permanently-delete-post.d.ts +3 -0
  159. package/build-types/actions/permanently-delete-post.d.ts.map +1 -1
  160. package/build-types/actions/rename-post.d.ts +3 -0
  161. package/build-types/actions/rename-post.d.ts.map +1 -1
  162. package/build-types/actions/reorder-page.d.ts +3 -0
  163. package/build-types/actions/reorder-page.d.ts.map +1 -1
  164. package/build-types/actions/reset-post.d.ts +3 -0
  165. package/build-types/actions/reset-post.d.ts.map +1 -1
  166. package/build-types/actions/restore-post.d.ts +3 -0
  167. package/build-types/actions/restore-post.d.ts.map +1 -1
  168. package/build-types/actions/trash-post.d.ts +3 -0
  169. package/build-types/actions/trash-post.d.ts.map +1 -1
  170. package/build-types/actions/view-post-revisions.d.ts +3 -0
  171. package/build-types/actions/view-post-revisions.d.ts.map +1 -1
  172. package/build-types/actions/view-post.d.ts +3 -0
  173. package/build-types/actions/view-post.d.ts.map +1 -1
  174. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
  175. package/build-types/fields/featured-image/index.d.ts +3 -0
  176. package/build-types/fields/featured-image/index.d.ts.map +1 -1
  177. package/build-types/fields/index.d.ts +3 -0
  178. package/build-types/fields/index.d.ts.map +1 -1
  179. package/build-types/fields/order/index.d.ts +3 -0
  180. package/build-types/fields/order/index.d.ts.map +1 -1
  181. package/build-types/fields/page-title/index.d.ts +14 -0
  182. package/build-types/fields/page-title/index.d.ts.map +1 -0
  183. package/build-types/fields/page-title/view.d.ts +8 -0
  184. package/build-types/fields/page-title/view.d.ts.map +1 -0
  185. package/build-types/fields/parent/index.d.ts +1 -1
  186. package/build-types/fields/password/index.d.ts +1 -1
  187. package/build-types/fields/pattern-title/index.d.ts +14 -0
  188. package/build-types/fields/pattern-title/index.d.ts.map +1 -0
  189. package/build-types/fields/pattern-title/view.d.ts +9 -0
  190. package/build-types/fields/pattern-title/view.d.ts.map +1 -0
  191. package/build-types/fields/slug/index.d.ts +3 -0
  192. package/build-types/fields/slug/index.d.ts.map +1 -1
  193. package/build-types/fields/template/index.d.ts +3 -0
  194. package/build-types/fields/template/index.d.ts.map +1 -1
  195. package/build-types/fields/template-title/index.d.ts +14 -0
  196. package/build-types/fields/template-title/index.d.ts.map +1 -0
  197. package/build-types/fields/title/index.d.ts +7 -2
  198. package/build-types/fields/title/index.d.ts.map +1 -1
  199. package/build-types/fields/title/view.d.ts +14 -0
  200. package/build-types/fields/title/view.d.ts.map +1 -0
  201. package/build-types/index.native.d.ts +0 -2
  202. package/build-types/index.native.d.ts.map +1 -1
  203. package/package.json +25 -25
  204. package/src/actions/delete-post.tsx +3 -0
  205. package/src/actions/duplicate-pattern.tsx +3 -0
  206. package/src/actions/duplicate-post.tsx +6 -3
  207. package/src/actions/duplicate-template-part.tsx +3 -1
  208. package/src/actions/export-pattern.tsx +3 -0
  209. package/src/actions/index.ts +0 -3
  210. package/src/actions/permanently-delete-post.tsx +160 -86
  211. package/src/actions/rename-post.tsx +3 -0
  212. package/src/actions/reorder-page.tsx +3 -0
  213. package/src/actions/reset-post.tsx +3 -0
  214. package/src/actions/restore-post.tsx +3 -0
  215. package/src/actions/trash-post.tsx +3 -0
  216. package/src/actions/view-post-revisions.tsx +3 -0
  217. package/src/actions/view-post.tsx +3 -0
  218. package/src/components/create-template-part-modal/index.tsx +81 -66
  219. package/src/components/create-template-part-modal/style.scss +79 -54
  220. package/src/fields/featured-image/index.ts +3 -0
  221. package/src/fields/index.ts +3 -0
  222. package/src/fields/order/index.ts +3 -0
  223. package/src/fields/page-title/index.ts +28 -0
  224. package/src/fields/page-title/view.tsx +41 -0
  225. package/src/fields/parent/index.ts +1 -1
  226. package/src/fields/password/index.tsx +1 -1
  227. package/src/fields/pattern-title/index.ts +28 -0
  228. package/src/fields/pattern-title/style.scss +3 -0
  229. package/src/fields/pattern-title/view.tsx +32 -0
  230. package/src/fields/slug/index.ts +3 -0
  231. package/src/fields/template/index.ts +3 -1
  232. package/src/fields/template-title/index.ts +28 -0
  233. package/src/fields/title/index.ts +9 -3
  234. package/src/fields/title/style.scss +8 -0
  235. package/src/fields/title/view.tsx +43 -0
  236. package/src/index.native.ts +0 -2
  237. package/src/style.scss +2 -0
  238. package/tsconfig.json +1 -4
  239. package/tsconfig.tsbuildinfo +1 -1
  240. package/build/actions/duplicate-post.native.js +0 -9
  241. package/build/actions/duplicate-post.native.js.map +0 -1
  242. package/build/actions/export-pattern.native.js +0 -9
  243. package/build/actions/export-pattern.native.js.map +0 -1
  244. package/build/actions/reorder-page.native.js +0 -9
  245. package/build/actions/reorder-page.native.js.map +0 -1
  246. package/build/fields/title/title-view.js +0 -61
  247. package/build/fields/title/title-view.js.map +0 -1
  248. package/build-module/actions/duplicate-post.native.js +0 -3
  249. package/build-module/actions/duplicate-post.native.js.map +0 -1
  250. package/build-module/actions/export-pattern.native.js +0 -3
  251. package/build-module/actions/export-pattern.native.js.map +0 -1
  252. package/build-module/actions/reorder-page.native.js +0 -3
  253. package/build-module/actions/reorder-page.native.js.map +0 -1
  254. package/build-module/fields/title/title-view.js +0 -55
  255. package/build-module/fields/title/title-view.js.map +0 -1
  256. package/build-types/actions/duplicate-post.native.d.ts +0 -3
  257. package/build-types/actions/duplicate-post.native.d.ts.map +0 -1
  258. package/build-types/actions/export-pattern.native.d.ts +0 -3
  259. package/build-types/actions/export-pattern.native.d.ts.map +0 -1
  260. package/build-types/actions/reorder-page.native.d.ts +0 -3
  261. package/build-types/actions/reorder-page.native.d.ts.map +0 -1
  262. package/build-types/fields/title/title-view.d.ts +0 -9
  263. package/build-types/fields/title/title-view.d.ts.map +0 -1
  264. package/src/actions/duplicate-post.native.tsx +0 -3
  265. package/src/actions/export-pattern.native.tsx +0 -3
  266. package/src/actions/reorder-page.native.tsx +0 -3
  267. package/src/fields/title/title-view.tsx +0 -61
@@ -45,5 +45,9 @@ const viewPostRevisions = {
45
45
  }
46
46
  }
47
47
  };
48
+
49
+ /**
50
+ * View post revisions action for Post.
51
+ */
48
52
  var _default = exports.default = viewPostRevisions;
49
53
  //# sourceMappingURL=view-post-revisions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_url","require","_i18n","viewPostRevisions","id","context","label","items","_items$0$_links$versi","revisionsCount","_links","count","sprintf","__","isEligible","post","_post$_links$predeces","_post$_links$version","status","lastRevisionId","callback","posts","onActionPerformed","href","addQueryArgs","revision","document","location","_default","exports","default"],"sources":["@wordpress/fields/src/actions/view-post-revisions.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Post } from '../types';\n\nconst viewPostRevisions: Action< Post > = {\n\tid: 'view-post-revisions',\n\tcontext: 'list',\n\tlabel( items ) {\n\t\tconst revisionsCount =\n\t\t\titems[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn sprintf(\n\t\t\t/* translators: %s: number of revisions. */\n\t\t\t__( 'View revisions (%s)' ),\n\t\t\trevisionsCount\n\t\t);\n\t},\n\tisEligible( post ) {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn !! lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( posts, { onActionPerformed } ) {\n\t\tconst post = posts[ 0 ];\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\nexport default viewPostRevisions;\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAME,iBAAiC,GAAG;EACzCC,EAAE,EAAE,qBAAqB;EACzBC,O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ED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa3B,iBAAiB","ignoreList":[]}
1
+ {"version":3,"names":["_url","require","_i18n","viewPostRevisions","id","context","label","items","_items$0$_links$versi","revisionsCount","_links","count","sprintf","__","isEligible","post","_post$_links$predeces","_post$_links$version","status","lastRevisionId","callback","posts","onActionPerformed","href","addQueryArgs","revision","document","location","_default","exports","default"],"sources":["@wordpress/fields/src/actions/view-post-revisions.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Post } from '../types';\n\nconst viewPostRevisions: Action< Post > = {\n\tid: 'view-post-revisions',\n\tcontext: 'list',\n\tlabel( items ) {\n\t\tconst revisionsCount =\n\t\t\titems[ 0 ]._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn sprintf(\n\t\t\t/* translators: %s: number of revisions. */\n\t\t\t__( 'View revisions (%s)' ),\n\t\t\trevisionsCount\n\t\t);\n\t},\n\tisEligible( post ) {\n\t\tif ( post.status === 'trash' ) {\n\t\t\treturn false;\n\t\t}\n\t\tconst lastRevisionId =\n\t\t\tpost?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\t\tconst revisionsCount =\n\t\t\tpost?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\t\treturn !! lastRevisionId && revisionsCount > 1;\n\t},\n\tcallback( posts, { onActionPerformed } ) {\n\t\tconst post = posts[ 0 ];\n\t\tconst href = addQueryArgs( 'revision.php', {\n\t\t\trevision: post?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id,\n\t\t} );\n\t\tdocument.location.href = href;\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\n/**\n * View post revisions action for Post.\n */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,EAAEV,IAAI,EAAEL,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEN;IAC3D,CAAE,CAAC;IACHsB,QAAQ,CAACC,QAAQ,CAACJ,IAAI,GAAGA,IAAI;IAC7B,IAAKD,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;;AAED;AACA;AACA;AAFA,IAAAO,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGe3B,iBAAiB","ignoreList":[]}
@@ -32,5 +32,9 @@ const viewPost = {
32
32
  }
33
33
  }
34
34
  };
35
+
36
+ /**
37
+ * View post action for BasePost.
38
+ */
35
39
  var _default = exports.default = viewPost;
36
40
  //# sourceMappingURL=view-post.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_icons","require","_i18n","viewPost","id","label","_x","isPrimary","icon","external","isEligible","post","status","callback","posts","onActionPerformed","window","open","link","_default","exports","default"],"sources":["@wordpress/fields/src/actions/view-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external } from '@wordpress/icons';\nimport { _x } from '@wordpress/i18n';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../types';\n\nconst viewPost: Action< BasePost > = {\n\tid: 'view-post',\n\tlabel: _x( 'View', 'verb' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( posts, { onActionPerformed } ) {\n\t\tconst post = posts[ 0 ];\n\t\twindow.open( post?.link, '_blank' );\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\nexport default viewPost;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAME,QAA4B,GAAG;EACpCC,EAAE,EAAE,WAAW;EACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAM,EAAE,MAAO,CAAC;EAC3BC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEC,eAAQ;EACdC,UAAUA,CAAEC,IAAI,EAAG;IAClB,OAAOA,IAAI,CAACC,MAAM,KAAK,OAAO;EAC/B,CAAC;EACDC,QAAQA,CAAEC,KAAK,EAAE;IAAEC;EAAkB,CAAC,EAAG;IACxC,MAAMJ,IAAI,GAAGG,KAAK,CAAE,CAAC,CAAE;IACvBE,MAAM,CAACC,IAAI,CAAEN,IAAI,EAAEO,IAAI,EAAE,QAAS,CAAC;IACnC,IAAKH,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEalB,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["_icons","require","_i18n","viewPost","id","label","_x","isPrimary","icon","external","isEligible","post","status","callback","posts","onActionPerformed","window","open","link","_default","exports","default"],"sources":["@wordpress/fields/src/actions/view-post.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { external } from '@wordpress/icons';\nimport { _x } from '@wordpress/i18n';\nimport type { Action } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../types';\n\nconst viewPost: Action< BasePost > = {\n\tid: 'view-post',\n\tlabel: _x( 'View', 'verb' ),\n\tisPrimary: true,\n\ticon: external,\n\tisEligible( post ) {\n\t\treturn post.status !== 'trash';\n\t},\n\tcallback( posts, { onActionPerformed } ) {\n\t\tconst post = posts[ 0 ];\n\t\twindow.open( post?.link, '_blank' );\n\t\tif ( onActionPerformed ) {\n\t\t\tonActionPerformed( posts );\n\t\t}\n\t},\n};\n\n/**\n * View post action for BasePost.\n */\nexport default viewPost;\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAKA;AACA;AACA;;AAGA,MAAME,QAA4B,GAAG;EACpCC,EAAE,EAAE,WAAW;EACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,MAAM,EAAE,MAAO,CAAC;EAC3BC,SAAS,EAAE,IAAI;EACfC,IAAI,EAAEC,eAAQ;EACdC,UAAUA,CAAEC,IAAI,EAAG;IAClB,OAAOA,IAAI,CAACC,MAAM,KAAK,OAAO;EAC/B,CAAC;EACDC,QAAQA,CAAEC,KAAK,EAAE;IAAEC;EAAkB,CAAC,EAAG;IACxC,MAAMJ,IAAI,GAAGG,KAAK,CAAE,CAAC,CAAE;IACvBE,MAAM,CAACC,IAAI,CAAEN,IAAI,EAAEO,IAAI,EAAE,QAAS,CAAC;IACnC,IAAKH,iBAAiB,EAAG;MACxBA,iBAAiB,CAAED,KAAM,CAAC;IAC3B;EACD;AACD,CAAC;;AAED;AACA;AACA;AAFA,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGelB,QAAQ","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -20,12 +21,18 @@ var _jsxRuntime = require("react/jsx-runtime");
20
21
  * WordPress dependencies
21
22
  */
22
23
 
23
- // @ts-ignore
24
+ // @ts-expect-error serialize is not typed
24
25
 
25
26
  /**
26
27
  * Internal dependencies
27
28
  */
28
29
 
30
+ function getAreaRadioId(value, instanceId) {
31
+ return `fields-create-template-part-modal__area-option-${value}-${instanceId}`;
32
+ }
33
+ function getAreaRadioDescriptionId(value, instanceId) {
34
+ return `fields-create-template-part-modal__area-option-description-${value}-${instanceId}`;
35
+ }
29
36
  /**
30
37
  * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.
31
38
  * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.
@@ -37,7 +44,7 @@ function CreateTemplatePartModal({
37
44
  ...restProps
38
45
  }) {
39
46
  const defaultModalTitle = (0, _data.useSelect)(select =>
40
- // @ts-ignore
47
+ // @ts-expect-error getPostType is not typed with 'wp_template_part' as argument.
41
48
  select(_coreData.store).getPostType('wp_template_part')?.labels?.add_new_item, []);
42
49
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Modal, {
43
50
  title: modalTitle || defaultModalTitle,
@@ -94,17 +101,9 @@ function CreateTemplatePartModalContents({
94
101
  const [area, setArea] = (0, _element.useState)(defaultArea);
95
102
  const [isSubmitting, setIsSubmitting] = (0, _element.useState)(false);
96
103
  const instanceId = (0, _compose.useInstanceId)(CreateTemplatePartModal);
97
- const defaultTemplatePartAreas = (0, _data.useSelect)(select => {
98
- const areas =
99
- // @ts-expect-error getEntityRecord is not typed with unstableBase as argument.
100
- select(_coreData.store).getEntityRecord('root', '__unstableBase')?.default_template_part_areas || [];
101
- return areas.map(item => {
102
- return {
103
- ...item,
104
- icon: getTemplatePartIcon(item.icon)
105
- };
106
- });
107
- }, []);
104
+ const defaultTemplatePartAreas = (0, _data.useSelect)(select =>
105
+ // @ts-expect-error getEntityRecord is not typed with unstableBase as argument.
106
+ select(_coreData.store).getEntityRecord('root', '__unstableBase')?.default_template_part_areas, []);
108
107
  async function createTemplatePart() {
109
108
  if (!title || isSubmitting) {
110
109
  return;
@@ -148,47 +147,44 @@ function CreateTemplatePartModalContents({
148
147
  value: title,
149
148
  onChange: setTitle,
150
149
  required: true
151
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BaseControl, {
152
- __nextHasNoMarginBottom: true,
153
- label: (0, _i18n.__)('Area'),
154
- id: `fields-create-template-part-modal__area-selection-${instanceId}`,
155
- className: "fields-create-template-part-modal__area-base-control",
156
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalRadioGroup, {
157
- label: (0, _i18n.__)('Area'),
150
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("fieldset", {
151
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BaseControl.VisualLabel, {
152
+ as: "legend",
153
+ children: (0, _i18n.__)('Area')
154
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
158
155
  className: "fields-create-template-part-modal__area-radio-group",
159
- id: `fields-create-template-part-modal__area-selection-${instanceId}`,
160
- onChange: value => value && typeof value === 'string' ? setArea(value) : () => void 0,
161
- checked: area,
162
- children: defaultTemplatePartAreas.map(({
163
- icon,
164
- label,
165
- area: value,
166
- description
167
- }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalRadio, {
168
- __next40pxDefaultSize: true,
169
- value: value,
170
- className: "fields-create-template-part-modal__area-radio",
171
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Flex, {
172
- align: "start",
173
- justify: "start",
174
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexItem, {
175
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
176
- icon: icon
177
- })
178
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.FlexBlock, {
179
- className: "fields-create-template-part-modal__option-label",
180
- children: [label, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
181
- children: description
182
- })]
183
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexItem, {
184
- className: "fields-create-template-part-modal__checkbox",
185
- children: area === value && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
186
- icon: _icons.check
187
- })
156
+ children: (defaultTemplatePartAreas !== null && defaultTemplatePartAreas !== void 0 ? defaultTemplatePartAreas : []).map(item => {
157
+ const icon = getTemplatePartIcon(item.icon);
158
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
159
+ className: "fields-create-template-part-modal__area-radio-wrapper",
160
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
161
+ type: "radio",
162
+ id: getAreaRadioId(item.area, instanceId),
163
+ name: `fields-create-template-part-modal__area-${instanceId}`,
164
+ value: item.area,
165
+ checked: area === item.area,
166
+ onChange: () => {
167
+ setArea(item.area);
168
+ },
169
+ "aria-describedby": getAreaRadioDescriptionId(item.area, instanceId)
170
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
171
+ icon: icon,
172
+ className: "fields-create-template-part-modal__area-radio-icon"
173
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
174
+ htmlFor: getAreaRadioId(item.area, instanceId),
175
+ className: "fields-create-template-part-modal__area-radio-label",
176
+ children: item.label
177
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
178
+ icon: _icons.check,
179
+ className: "fields-create-template-part-modal__area-radio-checkmark"
180
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
181
+ className: "fields-create-template-part-modal__area-radio-description",
182
+ id: getAreaRadioDescriptionId(item.area, instanceId),
183
+ children: item.description
188
184
  })]
189
- })
190
- }, label))
191
- })
185
+ }, item.area);
186
+ })
187
+ })]
192
188
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalHStack, {
193
189
  justify: "right",
194
190
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_compose","_coreData","_data","_element","_i18n","_icons","_notices","_blocks","_utils","_jsxRuntime","CreateTemplatePartModal","modalTitle","restProps","defaultModalTitle","useSelect","select","coreStore","getPostType","labels","add_new_item","jsx","Modal","title","onRequestClose","closeModal","overlayClassName","focusOnMount","size","children","CreateTemplatePartModalContents","getTemplatePartIcon","iconName","headerIcon","footerIcon","sidebarIcon","symbolFilledIcon","defaultArea","blocks","confirmLabel","__","onCreate","onError","defaultTitle","createErrorNotice","useDispatch","noticesStore","saveEntityRecord","existingTemplateParts","useExistingTemplateParts","setTitle","useState","area","setArea","isSubmitting","setIsSubmitting","instanceId","useInstanceId","defaultTemplatePartAreas","areas","getEntityRecord","default_template_part_areas","map","item","icon","createTemplatePart","uniqueTitle","getUniqueTemplatePartTitle","cleanSlug","getCleanTemplatePartSlug","templatePart","slug","content","serialize","throwOnError","error","errorMessage","Error","message","code","type","onSubmit","event","preventDefault","jsxs","__experimentalVStack","spacing","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","required","BaseControl","id","className","__experimentalRadioGroup","checked","description","__experimentalRadio","Flex","align","justify","FlexItem","Icon","FlexBlock","check","__experimentalHStack","Button","variant","onClick","isBusy"],"sources":["@wordpress/fields/src/components/create-template-part-modal/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tFlex,\n\tFlexItem,\n\tFlexBlock,\n\tButton,\n\tModal,\n\t__experimentalRadioGroup as RadioGroup,\n\t__experimentalRadio as Radio,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tcheck,\n\tfooter as footerIcon,\n\theader as headerIcon,\n\tsidebar as sidebarIcon,\n\tsymbolFilled as symbolFilledIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n// @ts-ignore\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetCleanTemplatePartSlug,\n\tgetUniqueTemplatePartTitle,\n\tuseExistingTemplateParts,\n} from './utils';\n\ntype CreateTemplatePartModalContentsProps = {\n\tdefaultArea?: string;\n\tblocks: any[];\n\tconfirmLabel?: string;\n\tcloseModal: () => void;\n\tonCreate: ( templatePart: any ) => void;\n\tonError?: () => void;\n\tdefaultTitle?: string;\n};\n\n/**\n * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.\n * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.\n * @param {Object} props The component props.\n * @param props.modalTitle\n */\nexport default function CreateTemplatePartModal( {\n\tmodalTitle,\n\t...restProps\n}: {\n\tmodalTitle: string;\n} & CreateTemplatePartModalContentsProps ) {\n\tconst defaultModalTitle = useSelect(\n\t\t( select ) =>\n\t\t\t// @ts-ignore\n\t\t\tselect( coreStore ).getPostType( 'wp_template_part' )?.labels\n\t\t\t\t?.add_new_item,\n\t\t[]\n\t);\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle || defaultModalTitle }\n\t\t\tonRequestClose={ restProps.closeModal }\n\t\t\toverlayClassName=\"fields-create-template-part-modal\"\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t{ /* @ts-ignore */ }\n\t\t\t<CreateTemplatePartModalContents { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nconst getTemplatePartIcon = ( iconName: string ) => {\n\tif ( 'header' === iconName ) {\n\t\treturn headerIcon;\n\t} else if ( 'footer' === iconName ) {\n\t\treturn footerIcon;\n\t} else if ( 'sidebar' === iconName ) {\n\t\treturn sidebarIcon;\n\t}\n\treturn symbolFilledIcon;\n};\n\n/**\n * A React component that renders the content of a model for creating a template part.\n * This component should not live in this package; it should be moved to a dedicated package responsible for managing template.\n *\n * @param {Object} props - The component props.\n * @param {string} [props.defaultArea=uncategorized] - The default area for the template part.\n * @param {Array} [props.blocks=[]] - The blocks to be included in the template part.\n * @param {string} [props.confirmLabel='Add'] - The label for the confirm button.\n * @param {Function} props.closeModal - Function to close the modal.\n * @param {Function} props.onCreate - Function to call when the template part is successfully created.\n * @param {Function} [props.onError] - Function to call when there is an error creating the template part.\n * @param {string} [props.defaultTitle=''] - The default title for the template part.\n */\nexport function CreateTemplatePartModalContents( {\n\tdefaultArea = 'uncategorized',\n\tblocks = [],\n\tconfirmLabel = __( 'Add' ),\n\tcloseModal,\n\tonCreate,\n\tonError,\n\tdefaultTitle = '',\n}: CreateTemplatePartModalContentsProps ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tconst [ title, setTitle ] = useState( defaultTitle );\n\tconst [ area, setArea ] = useState( defaultArea );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst defaultTemplatePartAreas = useSelect( ( select ) => {\n\t\tconst areas =\n\t\t\t// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.\n\t\t\tselect( coreStore ).getEntityRecord< {\n\t\t\t\tdefault_template_part_areas: Array< {\n\t\t\t\t\tarea: string;\n\t\t\t\t\tlabel: string;\n\t\t\t\t\ticon: string;\n\t\t\t\t\tdescription: string;\n\t\t\t\t} >;\n\t\t\t} >( 'root', '__unstableBase' )?.default_template_part_areas || [];\n\n\t\treturn areas.map( ( item ) => {\n\t\t\treturn { ...item, icon: getTemplatePartIcon( item.icon ) };\n\t\t} );\n\t}, [] );\n\n\tasync function createTemplatePart() {\n\t\tif ( ! title || isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSubmitting( true );\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error &&\n\t\t\t\t'code' in error &&\n\t\t\t\terror.message &&\n\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tonError?.();\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait createTemplatePart();\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"4\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<BaseControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\tid={ `fields-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-base-control\"\n\t\t\t\t>\n\t\t\t\t\t<RadioGroup\n\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-group\"\n\t\t\t\t\t\tid={ `fields-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tvalue && typeof value === 'string'\n\t\t\t\t\t\t\t\t? setArea( value )\n\t\t\t\t\t\t\t\t: () => void 0\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ area }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ defaultTemplatePartAreas.map(\n\t\t\t\t\t\t\t( { icon, label, area: value, description } ) => (\n\t\t\t\t\t\t\t\t<Radio\n\t\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Flex align=\"start\" justify=\"start\">\n\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock className=\"fields-create-template-part-modal__option-label\">\n\t\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t\t\t<div>{ description }</div>\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\n\t\t\t\t\t\t\t\t\t\t<FlexItem className=\"fields-create-template-part-modal__checkbox\">\n\t\t\t\t\t\t\t\t\t\t\t{ area === value && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t\t</Radio>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</RadioGroup>\n\t\t\t\t</BaseControl>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title || isSubmitting }\n\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t>\n\t\t\t\t\t\t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BAAqB;UACrBsB,OAAO,EAAC,SAAS;UACjB9B,IAAI,EAAC,QAAQ;UACb,iBAAgB,CAAEzD,KAAK,IAAI+B,YAAc;UACzC0D,MAAM,EAAG1D,YAAc;UAAAzB,QAAA,EAErBU;QAAY,CACP,CAAC;MAAA,CACF,CAAC;IAAA,CACF;EAAC,CACJ,CAAC;AAET","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_compose","_coreData","_data","_element","_i18n","_icons","_notices","_blocks","_utils","_jsxRuntime","getAreaRadioId","value","instanceId","getAreaRadioDescriptionId","CreateTemplatePartModal","modalTitle","restProps","defaultModalTitle","useSelect","select","coreStore","getPostType","labels","add_new_item","jsx","Modal","title","onRequestClose","closeModal","overlayClassName","focusOnMount","size","children","CreateTemplatePartModalContents","getTemplatePartIcon","iconName","headerIcon","footerIcon","sidebarIcon","symbolFilledIcon","defaultArea","blocks","confirmLabel","__","onCreate","onError","defaultTitle","createErrorNotice","useDispatch","noticesStore","saveEntityRecord","existingTemplateParts","useExistingTemplateParts","setTitle","useState","area","setArea","isSubmitting","setIsSubmitting","useInstanceId","defaultTemplatePartAreas","getEntityRecord","default_template_part_areas","createTemplatePart","uniqueTitle","getUniqueTemplatePartTitle","cleanSlug","getCleanTemplatePartSlug","templatePart","slug","content","serialize","throwOnError","error","errorMessage","Error","message","code","type","onSubmit","event","preventDefault","jsxs","__experimentalVStack","spacing","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","label","onChange","required","BaseControl","VisualLabel","as","className","map","item","icon","id","name","checked","Icon","htmlFor","check","description","__experimentalHStack","justify","Button","variant","onClick","isBusy"],"sources":["@wordpress/fields/src/components/create-template-part-modal/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tcheck,\n\tfooter as footerIcon,\n\theader as headerIcon,\n\tsidebar as sidebarIcon,\n\tsymbolFilled as symbolFilledIcon,\n} from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n// @ts-expect-error serialize is not typed\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetCleanTemplatePartSlug,\n\tgetUniqueTemplatePartTitle,\n\tuseExistingTemplateParts,\n} from './utils';\n\nfunction getAreaRadioId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-${ value }-${ instanceId }`;\n}\nfunction getAreaRadioDescriptionId( value: string, instanceId: number ) {\n\treturn `fields-create-template-part-modal__area-option-description-${ value }-${ instanceId }`;\n}\n\ntype CreateTemplatePartModalContentsProps = {\n\tdefaultArea?: string;\n\tblocks: any[];\n\tconfirmLabel?: string;\n\tcloseModal: () => void;\n\tonCreate: ( templatePart: any ) => void;\n\tonError?: () => void;\n\tdefaultTitle?: string;\n};\n\ntype TemplatePartArea = {\n\tarea: string;\n\tlabel: string;\n\ticon: string;\n\tdescription: string;\n};\n\n/**\n * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.\n * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.\n * @param {Object} props The component props.\n * @param props.modalTitle\n */\nexport default function CreateTemplatePartModal( {\n\tmodalTitle,\n\t...restProps\n}: {\n\tmodalTitle: string;\n} & CreateTemplatePartModalContentsProps ) {\n\tconst defaultModalTitle = useSelect(\n\t\t( select ) =>\n\t\t\t// @ts-expect-error getPostType is not typed with 'wp_template_part' as argument.\n\t\t\tselect( coreStore ).getPostType( 'wp_template_part' )?.labels\n\t\t\t\t?.add_new_item,\n\t\t[]\n\t);\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle || defaultModalTitle }\n\t\t\tonRequestClose={ restProps.closeModal }\n\t\t\toverlayClassName=\"fields-create-template-part-modal\"\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<CreateTemplatePartModalContents { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nconst getTemplatePartIcon = ( iconName: string ) => {\n\tif ( 'header' === iconName ) {\n\t\treturn headerIcon;\n\t} else if ( 'footer' === iconName ) {\n\t\treturn footerIcon;\n\t} else if ( 'sidebar' === iconName ) {\n\t\treturn sidebarIcon;\n\t}\n\treturn symbolFilledIcon;\n};\n\n/**\n * A React component that renders the content of a model for creating a template part.\n * This component should not live in this package; it should be moved to a dedicated package responsible for managing template.\n *\n * @param {Object} props - The component props.\n * @param {string} [props.defaultArea=uncategorized] - The default area for the template part.\n * @param {Array} [props.blocks=[]] - The blocks to be included in the template part.\n * @param {string} [props.confirmLabel='Add'] - The label for the confirm button.\n * @param {Function} props.closeModal - Function to close the modal.\n * @param {Function} props.onCreate - Function to call when the template part is successfully created.\n * @param {Function} [props.onError] - Function to call when there is an error creating the template part.\n * @param {string} [props.defaultTitle=''] - The default title for the template part.\n */\nexport function CreateTemplatePartModalContents( {\n\tdefaultArea = 'uncategorized',\n\tblocks = [],\n\tconfirmLabel = __( 'Add' ),\n\tcloseModal,\n\tonCreate,\n\tonError,\n\tdefaultTitle = '',\n}: CreateTemplatePartModalContentsProps ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tconst [ title, setTitle ] = useState( defaultTitle );\n\tconst [ area, setArea ] = useState( defaultArea );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst defaultTemplatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\t// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.\n\t\t\tselect( coreStore ).getEntityRecord< {\n\t\t\t\tdefault_template_part_areas: Array< TemplatePartArea >;\n\t\t\t} >( 'root', '__unstableBase' )?.default_template_part_areas,\n\t\t[]\n\t);\n\n\tasync function createTemplatePart() {\n\t\tif ( ! title || isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSubmitting( true );\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror instanceof Error &&\n\t\t\t\t'code' in error &&\n\t\t\t\terror.message &&\n\t\t\t\terror.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tonError?.();\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait createTemplatePart();\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"4\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<fieldset>\n\t\t\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t\t\t{ __( 'Area' ) }\n\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t<div className=\"fields-create-template-part-modal__area-radio-group\">\n\t\t\t\t\t\t{ ( defaultTemplatePartAreas ?? [] ).map( ( item ) => {\n\t\t\t\t\t\t\tconst icon = getTemplatePartIcon( item.icon );\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tkey={ item.area }\n\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-wrapper\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\t\t\ttype=\"radio\"\n\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tname={ `fields-create-template-part-modal__area-${ instanceId }` }\n\t\t\t\t\t\t\t\t\t\tvalue={ item.area }\n\t\t\t\t\t\t\t\t\t\tchecked={ area === item.area }\n\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetArea( item.area );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\taria-describedby={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-icon\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<label\n\t\t\t\t\t\t\t\t\t\thtmlFor={ getAreaRadioId(\n\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-label\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-checkmark\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<p\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-create-template-part-modal__area-radio-description\"\n\t\t\t\t\t\t\t\t\t\tid={ getAreaRadioDescriptionId(\n\t\t\t\t\t\t\t\t\t\t\titem.area,\n\t\t\t\t\t\t\t\t\t\t\tinstanceId\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ item.description }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t</div>\n\t\t\t\t</fieldset>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title || isSubmitting }\n\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ confirmLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AASA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAOA,IAAAO,QAAA,GAAAP,OAAA;AAEA,IAAAQ,OAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AAIiB,IAAAU,WAAA,GAAAV,OAAA;AAnCjB;AACA;AACA;;AAuBA;;AAGA;AACA;AACA;;AAOA,SAASW,cAAcA,CAAEC,KAAa,EAAEC,UAAkB,EAAG;EAC5D,OAAO,kDAAmDD,KAAK,IAAMC,UAAU,EAAG;AACnF;AACA,SAASC,yBAAyBA,CAAEF,KAAa,EAAEC,UAAkB,EAAG;EACvE,OAAO,8DAA+DD,KAAK,IAAMC,UAAU,EAAG;AAC/F;AAmBA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,uBAAuBA,CAAE;EAChDC,UAAU;EACV,GAAGC;AAGmC,CAAC,EAAG;EAC1C,MAAMC,iBAAiB,GAAG,IAAAC,eAAS,EAChCC,MAAM;EACP;EACAA,MAAM,CAAEC,eAAU,CAAC,CAACC,WAAW,CAAE,kBAAmB,CAAC,EAAEC,MAAM,EAC1DC,YAAY,EAChB,EACD,CAAC;EACD,oBACC,IAAAd,WAAA,CAAAe,GAAA,EAAC1B,WAAA,CAAA2B,KAAK;IACLC,KAAK,EAAGX,UAAU,IAAIE,iBAAmB;IACzCU,cAAc,EAAGX,S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;UACb,CAAG;UAAAI,QAAA,EAED,IAAAW,QAAE,EAAE,QAAS;QAAC,CACT,CAAC,eACT,IAAAlC,WAAA,CAAAe,GAAA,EAAC1B,WAAA,CAAA6G,MAAM;UACNrB,qBAAqB;UACrBsB,OAAO,EAAC,SAAS;UACjB9B,IAAI,EAAC,QAAQ;UACb,iBAAgB,CAAEpD,KAAK,IAAI+B,YAAc;UACzCqD,MAAM,EAAGrD,YAAc;UAAAzB,QAAA,EAErBU;QAAY,CACP,CAAC;MAAA,CACF,CAAC;IAAA,CACF;EAAC,CACJ,CAAC;AAET","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  Object.defineProperty(exports, "__esModule", {
@@ -1 +1 @@
1
- {"version":3,"names":["_changeCase","require","_data","_coreData","useExistingTemplateParts","_useSelect","useSelect","select","coreStore","getEntityRecords","per_page","exports","getUniqueTemplatePartTitle","title","templateParts","lowercaseTitle","toLowerCase","existingTitles","map","templatePart","rendered","includes","suffix","getCleanTemplatePartSlug","kebabCase","replace"],"sources":["@wordpress/fields/src/components/create-template-part-modal/utils.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\n\nexport const useExistingTemplateParts = () => {\n\treturn (\n\t\tuseSelect(\n\t\t\t( select ) =>\n\t\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t{\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t[]\n\t\t) ?? []\n\t);\n};\n\n/**\n * Return a unique template part title based on\n * the given title and existing template parts.\n *\n * @param {string} title The original template part title.\n * @param {Object} templateParts The array of template part entities.\n * @return {string} A unique template part title.\n */\nexport const getUniqueTemplatePartTitle = ( title, templateParts ) => {\n\tconst lowercaseTitle = title.toLowerCase();\n\tconst existingTitles = templateParts.map( ( templatePart ) =>\n\t\ttemplatePart.title.rendered.toLowerCase()\n\t);\n\n\tif ( ! existingTitles.includes( lowercaseTitle ) ) {\n\t\treturn title;\n\t}\n\n\tlet suffix = 2;\n\twhile ( existingTitles.includes( `${ lowercaseTitle } ${ suffix }` ) ) {\n\t\tsuffix++;\n\t}\n\n\treturn `${ title } ${ suffix }`;\n};\n\n/**\n * Get a valid slug for a template part.\n * Currently template parts only allow latin chars.\n * The fallback slug will receive suffix by default.\n *\n * @param {string} title The template part title.\n * @return {string} A valid template part slug.\n */\nexport const getCleanTemplatePartSlug = ( title ) => {\n\treturn kebabCase( title ).replace( /[^\\w-]+/g, '' ) || 'wp-custom-part';\n};\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAEO,MAAMG,wBAAwB,GAAGA,CAAA,KAAM;EAAA,IAAAC,UAAA;EAC7C,QAAAA,UAAA,GACC,IAAAC,eAAS,EACNC,MAAM,IACPA,MAAM,CAAEC,eAAU,CAAC,CAACC,gBAAgB,CACnC,UAAU,EACV,kBAAkB,EAClB;IACCC,QAAQ,EAAE,CAAC;EACZ,CACD,CAAC,EACF,EACD,CAAC,cAAAL,UAAA,cAAAA,UAAA,GAAI,EAAE;AAET,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAM,OAAA,CAAAP,wBAAA,GAAAA,wBAAA;AAQO,MAAMQ,0BAA0B,GAAGA,CAAEC,KAAK,EAAEC,aAAa,KAAM;EACrE,MAAMC,cAAc,GAAGF,KAAK,CAACG,WAAW,CAAC,CAAC;EAC1C,MAAMC,cAAc,GAAGH,aAAa,CAACI,GAAG,CAAIC,YAAY,IACvDA,YAAY,CAACN,KAAK,CAACO,QAAQ,CAACJ,WAAW,CAAC,CACzC,CAAC;EAED,IAAK,CAAEC,cAAc,CAACI,QAAQ,CAAEN,cAAe,CAAC,EAAG;IAClD,OAAOF,KAAK;EACb;EAEA,IAAIS,MAAM,GAAG,CAAC;EACd,OAAQL,cAAc,CAACI,QAAQ,CAAE,GAAIN,cAAc,IAAMO,MAAM,EAAI,CAAC,EAAG;IACtEA,MAAM,EAAE;EACT;EAEA,OAAO,GAAIT,KAAK,IAAMS,MAAM,EAAG;AAChC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAX,OAAA,CAAAC,0BAAA,GAAAA,0BAAA;AAQO,MAAMW,wBAAwB,GAAKV,KAAK,IAAM;EACpD,OAAO,IAAAW,qBAAS,EAAEX,KAAM,CAAC,CAACY,OAAO,CAAE,UAAU,EAAE,EAAG,CAAC,IAAI,gBAAgB;AACxE,CAAC;AAACd,OAAA,CAAAY,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_changeCase","require","_data","_coreData","useExistingTemplateParts","_useSelect","useSelect","select","coreStore","getEntityRecords","per_page","exports","getUniqueTemplatePartTitle","title","templateParts","lowercaseTitle","toLowerCase","existingTitles","map","templatePart","rendered","includes","suffix","getCleanTemplatePartSlug","kebabCase","replace"],"sources":["@wordpress/fields/src/components/create-template-part-modal/utils.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\n\nexport const useExistingTemplateParts = () => {\n\treturn (\n\t\tuseSelect(\n\t\t\t( select ) =>\n\t\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template_part',\n\t\t\t\t\t{\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t[]\n\t\t) ?? []\n\t);\n};\n\n/**\n * Return a unique template part title based on\n * the given title and existing template parts.\n *\n * @param {string} title The original template part title.\n * @param {Object} templateParts The array of template part entities.\n * @return {string} A unique template part title.\n */\nexport const getUniqueTemplatePartTitle = ( title, templateParts ) => {\n\tconst lowercaseTitle = title.toLowerCase();\n\tconst existingTitles = templateParts.map( ( templatePart ) =>\n\t\ttemplatePart.title.rendered.toLowerCase()\n\t);\n\n\tif ( ! existingTitles.includes( lowercaseTitle ) ) {\n\t\treturn title;\n\t}\n\n\tlet suffix = 2;\n\twhile ( existingTitles.includes( `${ lowercaseTitle } ${ suffix }` ) ) {\n\t\tsuffix++;\n\t}\n\n\treturn `${ title } ${ suffix }`;\n};\n\n/**\n * Get a valid slug for a template part.\n * Currently template parts only allow latin chars.\n * The fallback slug will receive suffix by default.\n *\n * @param {string} title The template part title.\n * @return {string} A valid template part slug.\n */\nexport const getCleanTemplatePartSlug = ( title ) => {\n\treturn kebabCase( title ).replace( /[^\\w-]+/g, '' ) || 'wp-custom-part';\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAEO,MAAMG,wBAAwB,GAAGA,CAAA,KAAM;EAAA,IAAAC,UAAA;EAC7C,QAAAA,UAAA,GACC,IAAAC,eAAS,EACNC,MAAM,IACPA,MAAM,CAAEC,eAAU,CAAC,CAACC,gBAAgB,CACnC,UAAU,EACV,kBAAkB,EAClB;IACCC,QAAQ,EAAE,CAAC;EACZ,CACD,CAAC,EACF,EACD,CAAC,cAAAL,UAAA,cAAAA,UAAA,GAAI,EAAE;AAET,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAM,OAAA,CAAAP,wBAAA,GAAAA,wBAAA;AAQO,MAAMQ,0BAA0B,GAAGA,CAAEC,KAAK,EAAEC,aAAa,KAAM;EACrE,MAAMC,cAAc,GAAGF,KAAK,CAACG,WAAW,CAAC,CAAC;EAC1C,MAAMC,cAAc,GAAGH,aAAa,CAACI,GAAG,CAAIC,YAAY,IACvDA,YAAY,CAACN,KAAK,CAACO,QAAQ,CAACJ,WAAW,CAAC,CACzC,CAAC;EAED,IAAK,CAAEC,cAAc,CAACI,QAAQ,CAAEN,cAAe,CAAC,EAAG;IAClD,OAAOF,KAAK;EACb;EAEA,IAAIS,MAAM,GAAG,CAAC;EACd,OAAQL,cAAc,CAACI,QAAQ,CAAE,GAAIN,cAAc,IAAMO,MAAM,EAAI,CAAC,EAAG;IACtEA,MAAM,EAAE;EACT;EAEA,OAAO,GAAIT,KAAK,IAAMS,MAAM,EAAG;AAChC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAX,OAAA,CAAAC,0BAAA,GAAAA,0BAAA;AAQO,MAAMW,wBAAwB,GAAKV,KAAK,IAAM;EACpD,OAAO,IAAAW,qBAAS,EAAEX,KAAM,CAAC,CAACY,OAAO,CAAE,UAAU,EAAE,EAAG,CAAC,IAAI,gBAAgB;AACxE,CAAC;AAACd,OAAA,CAAAY,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -23,5 +23,9 @@ const featuredImageField = {
23
23
  render: _featuredImageView.FeaturedImageView,
24
24
  enableSorting: false
25
25
  };
26
+
27
+ /**
28
+ * Featured Image field for BasePost.
29
+ */
26
30
  var _default = exports.default = featuredImageField;
27
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_featuredImageEdit","_featuredImageView","featuredImageField","id","type","label","__","Edit","FeaturedImageEdit","render","FeaturedImageView","enableSorting","_default","exports","default"],"sources":["@wordpress/fields/src/fields/featured-image/index.ts"],"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 { FeaturedImageEdit } from './featured-image-edit';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePost > = {\n\tid: 'featured_media',\n\ttype: 'text',\n\tlabel: __( 'Featured Image' ),\n\tEdit: FeaturedImageEdit,\n\trender: FeaturedImageView,\n\tenableSorting: false,\n};\n\nexport default featuredImageField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMG,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,gBAAiB,CAAC;EAC7BC,IAAI,EAAEC,oCAAiB;EACvBC,MAAM,EAAEC,oCAAiB;EACzBC,aAAa,EAAE;AAChB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaZ,kBAAkB","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_featuredImageEdit","_featuredImageView","featuredImageField","id","type","label","__","Edit","FeaturedImageEdit","render","FeaturedImageView","enableSorting","_default","exports","default"],"sources":["@wordpress/fields/src/fields/featured-image/index.ts"],"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 { FeaturedImageEdit } from './featured-image-edit';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePost > = {\n\tid: 'featured_media',\n\ttype: 'text',\n\tlabel: __( 'Featured Image' ),\n\tEdit: FeaturedImageEdit,\n\trender: FeaturedImageView,\n\tenableSorting: false,\n};\n\n/**\n * Featured Image field for BasePost.\n */\nexport default featuredImageField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMG,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,gBAAiB,CAAC;EAC7BC,IAAI,EAAEC,oCAAiB;EACvBC,MAAM,EAAEC,oCAAiB;EACzBC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeZ,kBAAkB","ignoreList":[]}
@@ -34,6 +34,12 @@ Object.defineProperty(exports, "orderField", {
34
34
  return _order.default;
35
35
  }
36
36
  });
37
+ Object.defineProperty(exports, "pageTitleField", {
38
+ enumerable: true,
39
+ get: function () {
40
+ return _pageTitle.default;
41
+ }
42
+ });
37
43
  Object.defineProperty(exports, "parentField", {
38
44
  enumerable: true,
39
45
  get: function () {
@@ -46,6 +52,12 @@ Object.defineProperty(exports, "passwordField", {
46
52
  return _password.default;
47
53
  }
48
54
  });
55
+ Object.defineProperty(exports, "patternTitleField", {
56
+ enumerable: true,
57
+ get: function () {
58
+ return _patternTitle.default;
59
+ }
60
+ });
49
61
  Object.defineProperty(exports, "slugField", {
50
62
  enumerable: true,
51
63
  get: function () {
@@ -64,6 +76,12 @@ Object.defineProperty(exports, "templateField", {
64
76
  return _template.default;
65
77
  }
66
78
  });
79
+ Object.defineProperty(exports, "templateTitleField", {
80
+ enumerable: true,
81
+ get: function () {
82
+ return _templateTitle.default;
83
+ }
84
+ });
67
85
  Object.defineProperty(exports, "titleField", {
68
86
  enumerable: true,
69
87
  get: function () {
@@ -72,6 +90,9 @@ Object.defineProperty(exports, "titleField", {
72
90
  });
73
91
  var _slug = _interopRequireDefault(require("./slug"));
74
92
  var _title = _interopRequireDefault(require("./title"));
93
+ var _pageTitle = _interopRequireDefault(require("./page-title"));
94
+ var _templateTitle = _interopRequireDefault(require("./template-title"));
95
+ var _patternTitle = _interopRequireDefault(require("./pattern-title"));
75
96
  var _order = _interopRequireDefault(require("./order"));
76
97
  var _featuredImage = _interopRequireDefault(require("./featured-image"));
77
98
  var _template = _interopRequireDefault(require("./template"));
@@ -1 +1 @@
1
- {"version":3,"names":["_slug","_interopRequireDefault","require","_title","_order","_featuredImage","_template","_parent","_password","_status","_commentStatus","_date","_author"],"sources":["@wordpress/fields/src/fields/index.ts"],"sourcesContent":["export { default as slugField } from './slug';\nexport { default as titleField } from './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 dateField } from './date';\nexport { default as authorField } from './author';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,SAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,OAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,cAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,KAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,OAAA,GAAAX,sBAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_slug","_interopRequireDefault","require","_title","_pageTitle","_templateTitle","_patternTitle","_order","_featuredImage","_template","_parent","_password","_status","_commentStatus","_date","_author"],"sources":["@wordpress/fields/src/fields/index.ts"],"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 dateField } from './date';\nexport { default as authorField } from './author';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,aAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,cAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,OAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,SAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,OAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,cAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,KAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,OAAA,GAAAd,sBAAA,CAAAC,OAAA","ignoreList":[]}
@@ -19,5 +19,9 @@ const orderField = {
19
19
  label: (0, _i18n.__)('Order'),
20
20
  description: (0, _i18n.__)('Determines the order of pages.')
21
21
  };
22
+
23
+ /**
24
+ * Order field for BasePost.
25
+ */
22
26
  var _default = exports.default = orderField;
23
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","orderField","id","type","label","__","description","_default","exports","default"],"sources":["@wordpress/fields/src/fields/order/index.ts"],"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 orderField: Field< BasePost > = {\n\tid: 'menu_order',\n\ttype: 'integer',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n};\n\nexport default orderField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,WAAW,EAAE,IAAAD,QAAE,EAAE,gCAAiC;AACnD,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaR,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","orderField","id","type","label","__","description","_default","exports","default"],"sources":["@wordpress/fields/src/fields/order/index.ts"],"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 orderField: Field< BasePost > = {\n\tid: 'menu_order',\n\ttype: 'integer',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n};\n\n/**\n * Order field for BasePost.\n */\nexport default orderField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,WAAW,EAAE,IAAAD,QAAE,EAAE,gCAAiC;AACnD,CAAC;;AAED;AACA;AACA;AAFA,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeR,UAAU","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _i18n = require("@wordpress/i18n");
9
+ var _utils = require("../../actions/utils");
10
+ var _view = _interopRequireDefault(require("./view"));
11
+ /**
12
+ * WordPress dependencies
13
+ */
14
+
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+
19
+ const pageTitleField = {
20
+ type: 'text',
21
+ id: 'title',
22
+ label: (0, _i18n.__)('Title'),
23
+ placeholder: (0, _i18n.__)('No title'),
24
+ getValue: ({
25
+ item
26
+ }) => (0, _utils.getItemTitle)(item),
27
+ render: _view.default,
28
+ enableHiding: false,
29
+ enableGlobalSearch: true
30
+ };
31
+
32
+ /**
33
+ * Title for the page entity.
34
+ */
35
+ var _default = exports.default = pageTitleField;
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_i18n","require","_utils","_view","_interopRequireDefault","pageTitleField","type","id","label","__","placeholder","getValue","item","getItemTitle","render","PageTitleView","enableHiding","enableGlobalSearch","_default","exports","default"],"sources":["@wordpress/fields/src/fields/page-title/index.ts"],"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 { getItemTitle } from '../../actions/utils';\nimport PageTitleView from './view';\n\nconst pageTitleField: Field< BasePost > = {\n\ttype: 'text',\n\tid: 'title',\n\tlabel: __( 'Title' ),\n\tplaceholder: __( 'No title' ),\n\tgetValue: ( { item } ) => getItemTitle( item ),\n\trender: PageTitleView,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\n/**\n * Title for the page entity.\n */\nexport default pageTitleField;\n"],"mappings":";;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMI,cAAiC,GAAG;EACzCC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,OAAO;EACXC,KAAK,EAAE,IAAAC,QAAE,EAAE,OAAQ,CAAC;EACpBC,WAAW,EAAE,IAAAD,QAAE,EAAE,UAAW,CAAC;EAC7BE,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAM,IAAAC,mBAAY,EAAED,IAAK,CAAC;EAC9CE,MAAM,EAAEC,aAAa;EACrBC,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE;AACrB,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGef,cAAc","ignoreList":[]}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = PageTitleView;
7
+ var _i18n = require("@wordpress/i18n");
8
+ var _data = require("@wordpress/data");
9
+ var _coreData = require("@wordpress/core-data");
10
+ var _components = require("@wordpress/components");
11
+ var _view = require("../title/view");
12
+ var _lockUnlock = require("../../lock-unlock");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+
22
+ const {
23
+ Badge
24
+ } = (0, _lockUnlock.unlock)(_components.privateApis);
25
+ function PageTitleView({
26
+ item
27
+ }) {
28
+ const {
29
+ frontPageId,
30
+ postsPageId
31
+ } = (0, _data.useSelect)(select => {
32
+ const {
33
+ getEntityRecord
34
+ } = select(_coreData.store);
35
+ const siteSettings = getEntityRecord('root', 'site');
36
+ return {
37
+ frontPageId: siteSettings?.page_on_front,
38
+ postsPageId: siteSettings?.page_for_posts
39
+ };
40
+ }, []);
41
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_view.BaseTitleView, {
42
+ item: item,
43
+ className: "fields-field__page-title",
44
+ children: [frontPageId, postsPageId].includes(item.id) && /*#__PURE__*/(0, _jsxRuntime.jsx)(Badge, {
45
+ children: item.id === frontPageId ? (0, _i18n.__)('Homepage') : (0, _i18n.__)('Posts Page')
46
+ })
47
+ });
48
+ }
49
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_i18n","require","_data","_coreData","_components","_view","_lockUnlock","_jsxRuntime","Badge","unlock","componentsPrivateApis","PageTitleView","item","frontPageId","postsPageId","useSelect","select","getEntityRecord","coreStore","siteSettings","page_on_front","page_for_posts","jsx","BaseTitleView","className","children","includes","id","__"],"sources":["@wordpress/fields/src/fields/page-title/view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { Settings } from '@wordpress/core-data';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { CommonPost } from '../../types';\nimport { BaseTitleView } from '../title/view';\nimport { unlock } from '../../lock-unlock';\nconst { Badge } = unlock( componentsPrivateApis );\n\nexport default function PageTitleView( { item }: { item: CommonPost } ) {\n\tconst { frontPageId, postsPageId } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t) as Partial< Settings >;\n\t\treturn {\n\t\t\tfrontPageId: siteSettings?.page_on_front,\n\t\t\tpostsPageId: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<BaseTitleView item={ item } className=\"fields-field__page-title\">\n\t\t\t{ [ frontPageId, postsPageId ].includes( item.id as number ) && (\n\t\t\t\t<Badge>\n\t\t\t\t\t{ item.id === frontPageId\n\t\t\t\t\t\t? __( 'Homepage' )\n\t\t\t\t\t\t: __( 'Posts Page' ) }\n\t\t\t\t</Badge>\n\t\t\t) }\n\t\t</BaseTitleView>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAA2C,IAAAM,WAAA,GAAAN,OAAA;AAd3C;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAM;EAAEO;AAAM,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAElC,SAASC,aAAaA,CAAE;EAAEC;AAA2B,CAAC,EAAG;EACvE,MAAM;IAAEC,WAAW;IAAEC;EAAY,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC7D,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,eAAU,CAAC;IAC/C,MAAMC,YAAY,GAAGF,eAAe,CACnC,MAAM,EACN,MACD,CAAwB;IACxB,OAAO;MACNJ,WAAW,EAAEM,YAAY,EAAEC,aAAa;MACxCN,WAAW,EAAEK,YAAY,EAAEE;IAC5B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,oBACC,IAAAd,WAAA,CAAAe,GAAA,EAACjB,KAAA,CAAAkB,aAAa;IAACX,IAAI,EAAGA,IAAM;IAACY,SAAS,EAAC,0BAA0B;IAAAC,QAAA,EAC9D,CAAEZ,WAAW,EAAEC,WAAW,CAAE,CAACY,QAAQ,CAAEd,IAAI,CAACe,EAAa,CAAC,iBAC3D,IAAApB,WAAA,CAAAe,GAAA,EAACd,KAAK;MAAAiB,QAAA,EACHb,IAAI,CAACe,EAAE,KAAKd,WAAW,GACtB,IAAAe,QAAE,EAAE,UAAW,CAAC,GAChB,IAAAA,QAAE,EAAE,YAAa;IAAC,CACf;EACP,CACa,CAAC;AAElB","ignoreList":[]}
@@ -25,7 +25,7 @@ const parentField = {
25
25
  };
26
26
 
27
27
  /**
28
- * This field is used to display the post parent.
28
+ * Parent field for BasePost.
29
29
  */
30
30
  var _default = exports.default = parentField;
31
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_parentEdit","_parentView","parentField","id","type","label","__","Edit","ParentEdit","render","ParentView","enableSorting","_default","exports","default"],"sources":["@wordpress/fields/src/fields/parent/index.ts"],"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 { ParentEdit } from './parent-edit';\nimport { ParentView } from './parent-view';\n\nconst parentField: Field< BasePost > = {\n\tid: 'parent',\n\ttype: 'text',\n\tlabel: __( 'Parent' ),\n\tEdit: ParentEdit,\n\trender: ParentView,\n\tenableSorting: true,\n};\n\n/**\n * This field is used to display the post parent.\n */\nexport default parentField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMG,WAA8B,GAAG;EACtCC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,QAAS,CAAC;EACrBC,IAAI,EAAEC,sBAAU;EAChBC,MAAM,EAAEC,sBAAU;EAClBC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeZ,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_parentEdit","_parentView","parentField","id","type","label","__","Edit","ParentEdit","render","ParentView","enableSorting","_default","exports","default"],"sources":["@wordpress/fields/src/fields/parent/index.ts"],"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 { ParentEdit } from './parent-edit';\nimport { ParentView } from './parent-view';\n\nconst parentField: Field< BasePost > = {\n\tid: 'parent',\n\ttype: 'text',\n\tlabel: __( 'Parent' ),\n\tEdit: ParentEdit,\n\trender: ParentView,\n\tenableSorting: true,\n};\n\n/**\n * Parent field for BasePost.\n */\nexport default parentField;\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AAMA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKA,MAAMG,WAA8B,GAAG;EACtCC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,IAAAC,QAAE,EAAE,QAAS,CAAC;EACrBC,IAAI,EAAEC,sBAAU;EAChBC,MAAM,EAAEC,sBAAU;EAClBC,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AAFA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGeZ,WAAW","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  "use strict";
2
3
 
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");