@wordpress/fields 0.5.1-next.cd6172eb0.0 → 0.6.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 (265) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +32 -36
  3. package/build/actions/delete-post.js +5 -0
  4. package/build/actions/delete-post.js.map +1 -1
  5. package/build/actions/duplicate-pattern.js +4 -0
  6. package/build/actions/duplicate-pattern.js.map +1 -1
  7. package/build/actions/duplicate-post.js +8 -3
  8. package/build/actions/duplicate-post.js.map +1 -1
  9. package/build/actions/duplicate-template-part.js +3 -0
  10. package/build/actions/duplicate-template-part.js.map +1 -1
  11. package/build/actions/export-pattern.js +5 -0
  12. package/build/actions/export-pattern.js.map +1 -1
  13. package/build/actions/index.js +0 -21
  14. package/build/actions/index.js.map +1 -1
  15. package/build/actions/permanently-delete-post.js +5 -0
  16. package/build/actions/permanently-delete-post.js.map +1 -1
  17. package/build/actions/rename-post.js +4 -0
  18. package/build/actions/rename-post.js.map +1 -1
  19. package/build/actions/reorder-page.js +4 -0
  20. package/build/actions/reorder-page.js.map +1 -1
  21. package/build/actions/reset-post.js +4 -0
  22. package/build/actions/reset-post.js.map +1 -1
  23. package/build/actions/restore-post.js +5 -0
  24. package/build/actions/restore-post.js.map +1 -1
  25. package/build/actions/trash-post.js +5 -0
  26. package/build/actions/trash-post.js.map +1 -1
  27. package/build/actions/view-post-revisions.js +4 -0
  28. package/build/actions/view-post-revisions.js.map +1 -1
  29. package/build/actions/view-post.js +4 -0
  30. package/build/actions/view-post.js.map +1 -1
  31. package/build/components/create-template-part-modal/index.js +32 -41
  32. package/build/components/create-template-part-modal/index.js.map +1 -1
  33. package/build/components/create-template-part-modal/utils.js +1 -0
  34. package/build/components/create-template-part-modal/utils.js.map +1 -1
  35. package/build/fields/featured-image/index.js +4 -0
  36. package/build/fields/featured-image/index.js.map +1 -1
  37. package/build/fields/index.js +21 -0
  38. package/build/fields/index.js.map +1 -1
  39. package/build/fields/order/index.js +4 -0
  40. package/build/fields/order/index.js.map +1 -1
  41. package/build/fields/page-title/index.js +36 -0
  42. package/build/fields/page-title/index.js.map +1 -0
  43. package/build/fields/page-title/view.js +45 -0
  44. package/build/fields/page-title/view.js.map +1 -0
  45. package/build/fields/parent/index.js +1 -1
  46. package/build/fields/parent/index.js.map +1 -1
  47. package/build/fields/parent/parent-edit.js +1 -0
  48. package/build/fields/parent/parent-edit.js.map +1 -1
  49. package/build/fields/password/index.js +1 -1
  50. package/build/fields/password/index.js.map +1 -1
  51. package/build/fields/pattern-title/index.js +36 -0
  52. package/build/fields/pattern-title/index.js.map +1 -0
  53. package/build/fields/pattern-title/view.js +45 -0
  54. package/build/fields/pattern-title/view.js.map +1 -0
  55. package/build/fields/slug/index.js +4 -0
  56. package/build/fields/slug/index.js.map +1 -1
  57. package/build/fields/status/status-view.js +1 -0
  58. package/build/fields/status/status-view.js.map +1 -1
  59. package/build/fields/template/index.js +4 -3
  60. package/build/fields/template/index.js.map +1 -1
  61. package/build/fields/template/template-edit.js +1 -0
  62. package/build/fields/template/template-edit.js.map +1 -1
  63. package/build/fields/template-title/index.js +36 -0
  64. package/build/fields/template-title/index.js.map +1 -0
  65. package/build/fields/title/index.js +10 -3
  66. package/build/fields/title/index.js.map +1 -1
  67. package/build/fields/title/view.js +48 -0
  68. package/build/fields/title/view.js.map +1 -0
  69. package/build/index.native.js +0 -26
  70. package/build/index.native.js.map +1 -1
  71. package/build/mutation/index.js +1 -0
  72. package/build/mutation/index.js.map +1 -1
  73. package/build-module/actions/delete-post.js +5 -0
  74. package/build-module/actions/delete-post.js.map +1 -1
  75. package/build-module/actions/duplicate-pattern.js +4 -0
  76. package/build-module/actions/duplicate-pattern.js.map +1 -1
  77. package/build-module/actions/duplicate-post.js +8 -3
  78. package/build-module/actions/duplicate-post.js.map +1 -1
  79. package/build-module/actions/duplicate-template-part.js +3 -0
  80. package/build-module/actions/duplicate-template-part.js.map +1 -1
  81. package/build-module/actions/export-pattern.js +5 -0
  82. package/build-module/actions/export-pattern.js.map +1 -1
  83. package/build-module/actions/index.js +0 -3
  84. package/build-module/actions/index.js.map +1 -1
  85. package/build-module/actions/permanently-delete-post.js +5 -0
  86. package/build-module/actions/permanently-delete-post.js.map +1 -1
  87. package/build-module/actions/rename-post.js +4 -0
  88. package/build-module/actions/rename-post.js.map +1 -1
  89. package/build-module/actions/reorder-page.js +4 -0
  90. package/build-module/actions/reorder-page.js.map +1 -1
  91. package/build-module/actions/reset-post.js +4 -0
  92. package/build-module/actions/reset-post.js.map +1 -1
  93. package/build-module/actions/restore-post.js +5 -0
  94. package/build-module/actions/restore-post.js.map +1 -1
  95. package/build-module/actions/trash-post.js +5 -0
  96. package/build-module/actions/trash-post.js.map +1 -1
  97. package/build-module/actions/view-post-revisions.js +4 -0
  98. package/build-module/actions/view-post-revisions.js.map +1 -1
  99. package/build-module/actions/view-post.js +4 -0
  100. package/build-module/actions/view-post.js.map +1 -1
  101. package/build-module/components/create-template-part-modal/index.js +32 -41
  102. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  103. package/build-module/components/create-template-part-modal/utils.js +1 -0
  104. package/build-module/components/create-template-part-modal/utils.js.map +1 -1
  105. package/build-module/fields/featured-image/index.js +4 -0
  106. package/build-module/fields/featured-image/index.js.map +1 -1
  107. package/build-module/fields/index.js +3 -0
  108. package/build-module/fields/index.js.map +1 -1
  109. package/build-module/fields/order/index.js +4 -0
  110. package/build-module/fields/order/index.js.map +1 -1
  111. package/build-module/fields/page-title/index.js +30 -0
  112. package/build-module/fields/page-title/index.js.map +1 -0
  113. package/build-module/fields/page-title/view.js +39 -0
  114. package/build-module/fields/page-title/view.js.map +1 -0
  115. package/build-module/fields/parent/index.js +1 -1
  116. package/build-module/fields/parent/index.js.map +1 -1
  117. package/build-module/fields/parent/parent-edit.js +1 -0
  118. package/build-module/fields/parent/parent-edit.js.map +1 -1
  119. package/build-module/fields/password/index.js +1 -1
  120. package/build-module/fields/password/index.js.map +1 -1
  121. package/build-module/fields/pattern-title/index.js +30 -0
  122. package/build-module/fields/pattern-title/index.js.map +1 -0
  123. package/build-module/fields/pattern-title/view.js +36 -0
  124. package/build-module/fields/pattern-title/view.js.map +1 -0
  125. package/build-module/fields/slug/index.js +4 -0
  126. package/build-module/fields/slug/index.js.map +1 -1
  127. package/build-module/fields/status/status-view.js +1 -0
  128. package/build-module/fields/status/status-view.js.map +1 -1
  129. package/build-module/fields/template/index.js +4 -3
  130. package/build-module/fields/template/index.js.map +1 -1
  131. package/build-module/fields/template/template-edit.js +1 -0
  132. package/build-module/fields/template/template-edit.js.map +1 -1
  133. package/build-module/fields/template-title/index.js +30 -0
  134. package/build-module/fields/template-title/index.js.map +1 -0
  135. package/build-module/fields/title/index.js +9 -2
  136. package/build-module/fields/title/index.js.map +1 -1
  137. package/build-module/fields/title/view.js +39 -0
  138. package/build-module/fields/title/view.js.map +1 -0
  139. package/build-module/index.native.js +1 -2
  140. package/build-module/index.native.js.map +1 -1
  141. package/build-module/mutation/index.js +1 -0
  142. package/build-module/mutation/index.js.map +1 -1
  143. package/build-style/style-rtl.css +24 -0
  144. package/build-style/style.css +24 -0
  145. package/build-types/actions/delete-post.d.ts +3 -0
  146. package/build-types/actions/delete-post.d.ts.map +1 -1
  147. package/build-types/actions/duplicate-pattern.d.ts +3 -0
  148. package/build-types/actions/duplicate-pattern.d.ts.map +1 -1
  149. package/build-types/actions/duplicate-post.d.ts +3 -0
  150. package/build-types/actions/duplicate-post.d.ts.map +1 -1
  151. package/build-types/actions/duplicate-template-part.d.ts +3 -0
  152. package/build-types/actions/duplicate-template-part.d.ts.map +1 -1
  153. package/build-types/actions/export-pattern.d.ts +3 -0
  154. package/build-types/actions/export-pattern.d.ts.map +1 -1
  155. package/build-types/actions/index.d.ts +0 -3
  156. package/build-types/actions/index.d.ts.map +1 -1
  157. package/build-types/actions/permanently-delete-post.d.ts +3 -0
  158. package/build-types/actions/permanently-delete-post.d.ts.map +1 -1
  159. package/build-types/actions/rename-post.d.ts +3 -0
  160. package/build-types/actions/rename-post.d.ts.map +1 -1
  161. package/build-types/actions/reorder-page.d.ts +3 -0
  162. package/build-types/actions/reorder-page.d.ts.map +1 -1
  163. package/build-types/actions/reset-post.d.ts +3 -0
  164. package/build-types/actions/reset-post.d.ts.map +1 -1
  165. package/build-types/actions/restore-post.d.ts +3 -0
  166. package/build-types/actions/restore-post.d.ts.map +1 -1
  167. package/build-types/actions/trash-post.d.ts +3 -0
  168. package/build-types/actions/trash-post.d.ts.map +1 -1
  169. package/build-types/actions/view-post-revisions.d.ts +3 -0
  170. package/build-types/actions/view-post-revisions.d.ts.map +1 -1
  171. package/build-types/actions/view-post.d.ts +3 -0
  172. package/build-types/actions/view-post.d.ts.map +1 -1
  173. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
  174. package/build-types/fields/featured-image/index.d.ts +3 -0
  175. package/build-types/fields/featured-image/index.d.ts.map +1 -1
  176. package/build-types/fields/index.d.ts +3 -0
  177. package/build-types/fields/index.d.ts.map +1 -1
  178. package/build-types/fields/order/index.d.ts +3 -0
  179. package/build-types/fields/order/index.d.ts.map +1 -1
  180. package/build-types/fields/page-title/index.d.ts +14 -0
  181. package/build-types/fields/page-title/index.d.ts.map +1 -0
  182. package/build-types/fields/page-title/view.d.ts +8 -0
  183. package/build-types/fields/page-title/view.d.ts.map +1 -0
  184. package/build-types/fields/parent/index.d.ts +1 -1
  185. package/build-types/fields/password/index.d.ts +1 -1
  186. package/build-types/fields/pattern-title/index.d.ts +14 -0
  187. package/build-types/fields/pattern-title/index.d.ts.map +1 -0
  188. package/build-types/fields/pattern-title/view.d.ts +9 -0
  189. package/build-types/fields/pattern-title/view.d.ts.map +1 -0
  190. package/build-types/fields/slug/index.d.ts +3 -0
  191. package/build-types/fields/slug/index.d.ts.map +1 -1
  192. package/build-types/fields/template/index.d.ts +3 -0
  193. package/build-types/fields/template/index.d.ts.map +1 -1
  194. package/build-types/fields/template-title/index.d.ts +14 -0
  195. package/build-types/fields/template-title/index.d.ts.map +1 -0
  196. package/build-types/fields/title/index.d.ts +7 -2
  197. package/build-types/fields/title/index.d.ts.map +1 -1
  198. package/build-types/fields/title/view.d.ts +14 -0
  199. package/build-types/fields/title/view.d.ts.map +1 -0
  200. package/build-types/index.native.d.ts +0 -2
  201. package/build-types/index.native.d.ts.map +1 -1
  202. package/package.json +24 -24
  203. package/src/actions/delete-post.tsx +3 -0
  204. package/src/actions/duplicate-pattern.tsx +3 -0
  205. package/src/actions/duplicate-post.tsx +6 -3
  206. package/src/actions/duplicate-template-part.tsx +3 -1
  207. package/src/actions/export-pattern.tsx +3 -0
  208. package/src/actions/index.ts +0 -3
  209. package/src/actions/permanently-delete-post.tsx +3 -0
  210. package/src/actions/rename-post.tsx +3 -0
  211. package/src/actions/reorder-page.tsx +3 -0
  212. package/src/actions/reset-post.tsx +3 -0
  213. package/src/actions/restore-post.tsx +3 -0
  214. package/src/actions/trash-post.tsx +3 -0
  215. package/src/actions/view-post-revisions.tsx +3 -0
  216. package/src/actions/view-post.tsx +3 -0
  217. package/src/components/create-template-part-modal/index.tsx +25 -26
  218. package/src/fields/featured-image/index.ts +3 -0
  219. package/src/fields/index.ts +3 -0
  220. package/src/fields/order/index.ts +3 -0
  221. package/src/fields/page-title/index.ts +28 -0
  222. package/src/fields/page-title/style.scss +10 -0
  223. package/src/fields/page-title/view.tsx +38 -0
  224. package/src/fields/parent/index.ts +1 -1
  225. package/src/fields/password/index.tsx +1 -1
  226. package/src/fields/pattern-title/index.ts +28 -0
  227. package/src/fields/pattern-title/style.scss +3 -0
  228. package/src/fields/pattern-title/view.tsx +32 -0
  229. package/src/fields/slug/index.ts +3 -0
  230. package/src/fields/template/index.ts +3 -1
  231. package/src/fields/template-title/index.ts +28 -0
  232. package/src/fields/title/index.ts +9 -3
  233. package/src/fields/title/style.scss +8 -0
  234. package/src/fields/title/view.tsx +43 -0
  235. package/src/index.native.ts +0 -2
  236. package/src/style.scss +3 -0
  237. package/tsconfig.tsbuildinfo +1 -1
  238. package/build/actions/duplicate-post.native.js +0 -9
  239. package/build/actions/duplicate-post.native.js.map +0 -1
  240. package/build/actions/export-pattern.native.js +0 -9
  241. package/build/actions/export-pattern.native.js.map +0 -1
  242. package/build/actions/reorder-page.native.js +0 -9
  243. package/build/actions/reorder-page.native.js.map +0 -1
  244. package/build/fields/title/title-view.js +0 -61
  245. package/build/fields/title/title-view.js.map +0 -1
  246. package/build-module/actions/duplicate-post.native.js +0 -3
  247. package/build-module/actions/duplicate-post.native.js.map +0 -1
  248. package/build-module/actions/export-pattern.native.js +0 -3
  249. package/build-module/actions/export-pattern.native.js.map +0 -1
  250. package/build-module/actions/reorder-page.native.js +0 -3
  251. package/build-module/actions/reorder-page.native.js.map +0 -1
  252. package/build-module/fields/title/title-view.js +0 -55
  253. package/build-module/fields/title/title-view.js.map +0 -1
  254. package/build-types/actions/duplicate-post.native.d.ts +0 -3
  255. package/build-types/actions/duplicate-post.native.d.ts.map +0 -1
  256. package/build-types/actions/export-pattern.native.d.ts +0 -3
  257. package/build-types/actions/export-pattern.native.d.ts.map +0 -1
  258. package/build-types/actions/reorder-page.native.d.ts +0 -3
  259. package/build-types/actions/reorder-page.native.d.ts.map +0 -1
  260. package/build-types/fields/title/title-view.d.ts +0 -9
  261. package/build-types/fields/title/title-view.d.ts.map +0 -1
  262. package/src/actions/duplicate-post.native.tsx +0 -3
  263. package/src/actions/export-pattern.native.tsx +0 -3
  264. package/src/actions/reorder-page.native.tsx +0 -3
  265. package/src/fields/title/title-view.tsx +0 -61
@@ -1 +1 @@
1
- {"version":3,"names":["paramCase","kebabCase","useSelect","store","coreStore","useExistingTemplateParts","_useSelect","select","getEntityRecords","per_page","getUniqueTemplatePartTitle","title","templateParts","lowercaseTitle","toLowerCase","existingTitles","map","templatePart","rendered","includes","suffix","getCleanTemplatePartSlug","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":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;;AAEA,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAAA,IAAAC,UAAA;EAC7C,QAAAA,UAAA,GACCJ,SAAS,CACNK,MAAM,IACPA,MAAM,CAAEH,SAAU,CAAC,CAACI,gBAAgB,CACnC,UAAU,EACV,kBAAkB,EAClB;IACCC,QAAQ,EAAE,CAAC;EACZ,CACD,CAAC,EACF,EACD,CAAC,cAAAH,UAAA,cAAAA,UAAA,GAAI,EAAE;AAET,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,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;AACA,OAAO,MAAMC,wBAAwB,GAAKV,KAAK,IAAM;EACpD,OAAOV,SAAS,CAAEU,KAAM,CAAC,CAACW,OAAO,CAAE,UAAU,EAAE,EAAG,CAAC,IAAI,gBAAgB;AACxE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["paramCase","kebabCase","useSelect","store","coreStore","useExistingTemplateParts","_useSelect","select","getEntityRecords","per_page","getUniqueTemplatePartTitle","title","templateParts","lowercaseTitle","toLowerCase","existingTitles","map","templatePart","rendered","includes","suffix","getCleanTemplatePartSlug","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":";AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;;AAEA,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAAA,IAAAC,UAAA;EAC7C,QAAAA,UAAA,GACCJ,SAAS,CACNK,MAAM,IACPA,MAAM,CAAEH,SAAU,CAAC,CAACI,gBAAgB,CACnC,UAAU,EACV,kBAAkB,EAClB;IACCC,QAAQ,EAAE,CAAC;EACZ,CACD,CAAC,EACF,EACD,CAAC,cAAAH,UAAA,cAAAA,UAAA,GAAI,EAAE;AAET,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,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;AACA,OAAO,MAAMC,wBAAwB,GAAKV,KAAK,IAAM;EACpD,OAAOV,SAAS,CAAEU,KAAM,CAAC,CAACW,OAAO,CAAE,UAAU,EAAE,EAAG,CAAC,IAAI,gBAAgB;AACxE,CAAC","ignoreList":[]}
@@ -18,5 +18,9 @@ const featuredImageField = {
18
18
  render: FeaturedImageView,
19
19
  enableSorting: false
20
20
  };
21
+
22
+ /**
23
+ * Featured Image field for BasePost.
24
+ */
21
25
  export default featuredImageField;
22
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__","FeaturedImageEdit","FeaturedImageView","featuredImageField","id","type","label","Edit","render","enableSorting"],"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":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD,MAAMC,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,gBAAiB,CAAC;EAC7BO,IAAI,EAAEN,iBAAiB;EACvBO,MAAM,EAAEN,iBAAiB;EACzBO,aAAa,EAAE;AAChB,CAAC;AAED,eAAeN,kBAAkB","ignoreList":[]}
1
+ {"version":3,"names":["__","FeaturedImageEdit","FeaturedImageView","featuredImageField","id","type","label","Edit","render","enableSorting"],"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":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD,MAAMC,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,gBAAiB,CAAC;EAC7BO,IAAI,EAAEN,iBAAiB;EACvBO,MAAM,EAAEN,iBAAiB;EACzBO,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA,eAAeN,kBAAkB","ignoreList":[]}
@@ -1,5 +1,8 @@
1
1
  export { default as slugField } from './slug';
2
2
  export { default as titleField } from './title';
3
+ export { default as pageTitleField } from './page-title';
4
+ export { default as templateTitleField } from './template-title';
5
+ export { default as patternTitleField } from './pattern-title';
3
6
  export { default as orderField } from './order';
4
7
  export { default as featuredImageField } from './featured-image';
5
8
  export { default as templateField } from './template';
@@ -1 +1 @@
1
- {"version":3,"names":["default","slugField","titleField","orderField","featuredImageField","templateField","parentField","passwordField","statusField","commentStatusField","dateField","authorField"],"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,SAASA,OAAO,IAAIC,SAAS,QAAQ,QAAQ;AAC7C,SAASD,OAAO,IAAIE,UAAU,QAAQ,SAAS;AAC/C,SAASF,OAAO,IAAIG,UAAU,QAAQ,SAAS;AAC/C,SAASH,OAAO,IAAII,kBAAkB,QAAQ,kBAAkB;AAChE,SAASJ,OAAO,IAAIK,aAAa,QAAQ,YAAY;AACrD,SAASL,OAAO,IAAIM,WAAW,QAAQ,UAAU;AACjD,SAASN,OAAO,IAAIO,aAAa,QAAQ,YAAY;AACrD,SAASP,OAAO,IAAIQ,WAAW,QAAQ,UAAU;AACjD,SAASR,OAAO,IAAIS,kBAAkB,QAAQ,kBAAkB;AAChE,SAAST,OAAO,IAAIU,SAAS,QAAQ,QAAQ;AAC7C,SAASV,OAAO,IAAIW,WAAW,QAAQ,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["default","slugField","titleField","pageTitleField","templateTitleField","patternTitleField","orderField","featuredImageField","templateField","parentField","passwordField","statusField","commentStatusField","dateField","authorField"],"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,SAASA,OAAO,IAAIC,SAAS,QAAQ,QAAQ;AAC7C,SAASD,OAAO,IAAIE,UAAU,QAAQ,SAAS;AAC/C,SAASF,OAAO,IAAIG,cAAc,QAAQ,cAAc;AACxD,SAASH,OAAO,IAAII,kBAAkB,QAAQ,kBAAkB;AAChE,SAASJ,OAAO,IAAIK,iBAAiB,QAAQ,iBAAiB;AAC9D,SAASL,OAAO,IAAIM,UAAU,QAAQ,SAAS;AAC/C,SAASN,OAAO,IAAIO,kBAAkB,QAAQ,kBAAkB;AAChE,SAASP,OAAO,IAAIQ,aAAa,QAAQ,YAAY;AACrD,SAASR,OAAO,IAAIS,WAAW,QAAQ,UAAU;AACjD,SAAST,OAAO,IAAIU,aAAa,QAAQ,YAAY;AACrD,SAASV,OAAO,IAAIW,WAAW,QAAQ,UAAU;AACjD,SAASX,OAAO,IAAIY,kBAAkB,QAAQ,kBAAkB;AAChE,SAASZ,OAAO,IAAIa,SAAS,QAAQ,QAAQ;AAC7C,SAASb,OAAO,IAAIc,WAAW,QAAQ,UAAU","ignoreList":[]}
@@ -14,5 +14,9 @@ const orderField = {
14
14
  label: __('Order'),
15
15
  description: __('Determines the order of pages.')
16
16
  };
17
+
18
+ /**
19
+ * Order field for BasePost.
20
+ */
17
21
  export default orderField;
18
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__","orderField","id","type","label","description"],"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":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAEJ,EAAE,CAAE,OAAQ,CAAC;EACpBK,WAAW,EAAEL,EAAE,CAAE,gCAAiC;AACnD,CAAC;AAED,eAAeC,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["__","orderField","id","type","label","description"],"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":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAEJ,EAAE,CAAE,OAAQ,CAAC;EACpBK,WAAW,EAAEL,EAAE,CAAE,gCAAiC;AACnD,CAAC;;AAED;AACA;AACA;AACA,eAAeC,UAAU","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ import { getItemTitle } from '../../actions/utils';
12
+ import PageTitleView from './view';
13
+ const pageTitleField = {
14
+ type: 'text',
15
+ id: 'title',
16
+ label: __('Title'),
17
+ placeholder: __('No title'),
18
+ getValue: ({
19
+ item
20
+ }) => getItemTitle(item),
21
+ render: PageTitleView,
22
+ enableHiding: false,
23
+ enableGlobalSearch: true
24
+ };
25
+
26
+ /**
27
+ * Title for the page entity.
28
+ */
29
+ export default pageTitleField;
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","getItemTitle","PageTitleView","pageTitleField","type","id","label","placeholder","getValue","item","render","enableHiding","enableGlobalSearch"],"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":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,qBAAqB;AAClD,OAAOC,aAAa,MAAM,QAAQ;AAElC,MAAMC,cAAiC,GAAG;EACzCC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,OAAO;EACXC,KAAK,EAAEN,EAAE,CAAE,OAAQ,CAAC;EACpBO,WAAW,EAAEP,EAAE,CAAE,UAAW,CAAC;EAC7BQ,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMR,YAAY,CAAEQ,IAAK,CAAC;EAC9CC,MAAM,EAAER,aAAa;EACrBS,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE;AACrB,CAAC;;AAED;AACA;AACA;AACA,eAAeT,cAAc","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { store as coreStore } from '@wordpress/core-data';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+
12
+ import { BaseTitleView } from '../title/view';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ export default function PageTitleView({
15
+ item
16
+ }) {
17
+ const {
18
+ frontPageId,
19
+ postsPageId
20
+ } = useSelect(select => {
21
+ const {
22
+ getEntityRecord
23
+ } = select(coreStore);
24
+ const siteSettings = getEntityRecord('root', 'site');
25
+ return {
26
+ frontPageId: siteSettings?.page_on_front,
27
+ postsPageId: siteSettings?.page_for_posts
28
+ };
29
+ }, []);
30
+ return /*#__PURE__*/_jsx(BaseTitleView, {
31
+ item: item,
32
+ className: "fields-field__page-title",
33
+ children: [frontPageId, postsPageId].includes(item.id) && /*#__PURE__*/_jsx("span", {
34
+ className: "fields-field__page-title__badge",
35
+ children: item.id === frontPageId ? __('Homepage') : __('Posts Page')
36
+ })
37
+ });
38
+ }
39
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","useSelect","store","coreStore","BaseTitleView","jsx","_jsx","PageTitleView","item","frontPageId","postsPageId","select","getEntityRecord","siteSettings","page_on_front","page_for_posts","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';\n\n/**\n * Internal dependencies\n */\nimport type { CommonPost } from '../../types';\nimport { BaseTitleView } from '../title/view';\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<span className=\"fields-field__page-title__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</span>\n\t\t\t) }\n\t\t</BaseTitleView>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAGzD;AACA;AACA;;AAEA,SAASC,aAAa,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9C,eAAe,SAASC,aAAaA,CAAE;EAAEC;AAA2B,CAAC,EAAG;EACvE,MAAM;IAAEC,WAAW;IAAEC;EAAY,CAAC,GAAGT,SAAS,CAAIU,MAAM,IAAM;IAC7D,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAER,SAAU,CAAC;IAC/C,MAAMU,YAAY,GAAGD,eAAe,CACnC,MAAM,EACN,MACD,CAAwB;IACxB,OAAO;MACNH,WAAW,EAAEI,YAAY,EAAEC,aAAa;MACxCJ,WAAW,EAAEG,YAAY,EAAEE;IAC5B,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,oBACCT,IAAA,CAACF,aAAa;IAACI,IAAI,EAAGA,IAAM;IAACQ,SAAS,EAAC,0BAA0B;IAAAC,QAAA,EAC9D,CAAER,WAAW,EAAEC,WAAW,CAAE,CAACQ,QAAQ,CAAEV,IAAI,CAACW,EAAa,CAAC,iBAC3Db,IAAA;MAAMU,SAAS,EAAC,iCAAiC;MAAAC,QAAA,EAC9CT,IAAI,CAACW,EAAE,KAAKV,WAAW,GACtBT,EAAE,CAAE,UAAW,CAAC,GAChBA,EAAE,CAAE,YAAa;IAAC,CAChB;EACN,CACa,CAAC;AAElB","ignoreList":[]}
@@ -20,7 +20,7 @@ const parentField = {
20
20
  };
21
21
 
22
22
  /**
23
- * This field is used to display the post parent.
23
+ * Parent field for BasePost.
24
24
  */
25
25
  export default parentField;
26
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__","ParentEdit","ParentView","parentField","id","type","label","Edit","render","enableSorting"],"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":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,UAAU,QAAQ,eAAe;AAE1C,MAAMC,WAA8B,GAAG;EACtCC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,QAAS,CAAC;EACrBO,IAAI,EAAEN,UAAU;EAChBO,MAAM,EAAEN,UAAU;EAClBO,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA,eAAeN,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["__","ParentEdit","ParentView","parentField","id","type","label","Edit","render","enableSorting"],"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":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,UAAU,QAAQ,eAAe;AAE1C,MAAMC,WAA8B,GAAG;EACtCC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,QAAS,CAAC;EACrBO,IAAI,EAAEN,UAAU;EAChBO,MAAM,EAAEN,UAAU;EAClBO,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA,eAAeN,WAAW","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  /**
2
3
  * External dependencies
3
4
  */
@@ -1 +1 @@
1
- {"version":3,"names":["removeAccents","ComboboxControl","ExternalLink","useSelect","createInterpolateElement","useCallback","useMemo","useState","store","coreStore","debounce","decodeEntities","__","sprintf","filterURLForDisplay","getTitleWithFallbackName","jsx","_jsx","jsxs","_jsxs","buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","some","parent","undefined","termsByParent","reduce","acc","push","fillWithChildren","terms","id","length","getItemPriority","name","searchValue","normalizedName","toLowerCase","normalizedSearch","startsWith","Infinity","PageAttributesParent","data","onChangeControl","fieldValue","setFieldValue","pageId","postId","postTypeSlug","type","parentPostTitle","pageItems","isHierarchical","select","getEntityRecord","getEntityRecords","getPostType","postTypeInfo","postIsHierarchical","hierarchical","viewable","parentPost","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentOptions","getOptionsFromTree","tree","level","mappedNodes","treeNode","value","label","repeat","rawName","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","_item$parent","opts","optsHasParent","find","unshift","option","toString","handleKeydown","inputValue","handleChange","selectedPostId","_parseInt","parseInt","__nextHasNoMarginBottom","__next40pxDefaultSize","help","options","onFilterValueChange","onChange","hideLabelFromVision","ParentEdit","field","homeUrl","home","newValue","className","replace","wbr","href"],"sources":["@wordpress/fields/src/fields/parent/parent-edit.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { ComboboxControl, ExternalLink } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateInterpolateElement,\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n// @ts-ignore\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { debounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\n\ntype TreeBase = {\n\tid: number;\n\tname: string;\n\t[ key: string ]: any;\n};\n\ntype TreeWithParent = TreeBase & {\n\tparent: number;\n};\n\ntype TreeWithoutParent = TreeBase & {\n\tparent: null;\n};\n\ntype Tree = TreeWithParent | TreeWithoutParent;\n\nfunction buildTermsTree( flatTerms: Tree[] ) {\n\tconst flatTermsWithParentAndChildren = flatTerms.map( ( term ) => {\n\t\treturn {\n\t\t\tchildren: [],\n\t\t\t...term,\n\t\t};\n\t} );\n\n\t// All terms should have a `parent` because we're about to index them by it.\n\tif (\n\t\tflatTermsWithParentAndChildren.some(\n\t\t\t( { parent } ) => parent === null || parent === undefined\n\t\t)\n\t) {\n\t\treturn flatTermsWithParentAndChildren as TreeWithParent[];\n\t}\n\n\tconst termsByParent = (\n\t\tflatTermsWithParentAndChildren as TreeWithParent[]\n\t ).reduce(\n\t\t( acc, term ) => {\n\t\t\tconst { parent } = term;\n\t\t\tif ( ! acc[ parent ] ) {\n\t\t\t\tacc[ parent ] = [];\n\t\t\t}\n\t\t\tacc[ parent ].push( term );\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record< string, Array< TreeWithParent > >\n\t);\n\n\tconst fillWithChildren = (\n\t\tterms: Array< TreeWithParent >\n\t): Array< TreeWithParent > => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n\nexport const getItemPriority = ( name: string, searchValue: string ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent( {\n\tdata,\n\tonChangeControl,\n}: {\n\tdata: BasePost;\n\tonChangeControl: ( newValue: number ) => void;\n} ) {\n\tconst [ fieldValue, setFieldValue ] = useState< null | string >( null );\n\n\tconst pageId = data.parent;\n\tconst postId = data.id;\n\tconst postTypeSlug = data.type;\n\n\tconst { parentPostTitle, pageItems, isHierarchical } = useSelect(\n\t\t( select ) => {\n\t\t\t// @ts-expect-error getPostType is not typed\n\t\t\tconst { getEntityRecord, getEntityRecords, getPostType } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postTypeInfo = getPostType( postTypeSlug );\n\n\t\t\tconst postIsHierarchical =\n\t\t\t\tpostTypeInfo?.hierarchical && postTypeInfo.viewable;\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord< BasePost >(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\tpageId\n\t\t\t\t )\n\t\t\t\t: null;\n\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t...( fieldValue !== null && {\n\t\t\t\t\tsearch: fieldValue,\n\t\t\t\t} ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostTitle: parentPost\n\t\t\t\t\t? getTitleWithFallbackName( parentPost )\n\t\t\t\t\t: '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords< BasePost >(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue, pageId, postId, postTypeSlug ]\n\t);\n\n\t/**\n\t * This logic has been copied from https://github.com/WordPress/gutenberg/blob/0249771b519d5646171fb9fae422006c8ab773f2/packages/editor/src/components/page-attributes/parent.js#L106.\n\t */\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = (\n\t\t\ttree: Array< Tree >,\n\t\t\tlevel = 0\n\t\t): Array< {\n\t\t\tvalue: number;\n\t\t\tlabel: string;\n\t\t\trawName: string;\n\t\t} > => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority(\n\t\t\t\t\ta.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\tconst priorityB = getItemPriority(\n\t\t\t\t\tb.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id as number,\n\t\t\tparent: item.parent ?? null,\n\t\t\tname: getTitleWithFallbackName( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find( ( item ) => item.value === pageId );\n\t\tif ( pageId && parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: pageId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t\trawName: '',\n\t\t\t} );\n\t\t}\n\t\treturn opts.map( ( option ) => ( {\n\t\t\t...option,\n\t\t\tvalue: option.value.toString(),\n\t\t} ) );\n\t}, [ pageItems, fieldValue, parentPostTitle, pageId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue: string ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId: string | null | undefined ) => {\n\t\tif ( selectedPostId ) {\n\t\t\treturn onChangeControl( parseInt( selectedPostId, 10 ) ?? 0 );\n\t\t}\n\n\t\tonChangeControl( 0 );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ pageId?.toString() }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce(\n\t\t\t\t( value: unknown ) => handleKeydown( value as string ),\n\t\t\t\t300\n\t\t\t) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n\nexport const ParentEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.\n\t\treturn select( coreStore ).getEntityRecord< {\n\t\t\thome: string;\n\t\t} >( 'root', '__unstableBase' )?.home as string;\n\t}, [] );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue?: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__parent\">\n\t\t\t<div>\n\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %1$s The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %1$s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t<p>\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tchildren={ undef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ArE,IAAA,CAACf,YAAY;YACZsH,IAAI,EAAG5G,EAAE,CACR,yFACD,CAAG;YACHa,QAAQ,EAAGG;UAAW,CACtB;QAEH,CACD;MAAC,CACC,CAAC,eACJX,IAAA,CAAC4B,oBAAoB;QACpBC,IAAI,EAAGA,IAAM;QACbC,eAAe,EAAGA;MAAiB,CACnC,CAAC;IAAA,CACE;EAAC,CACG,CAAC;AAEb,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["removeAccents","ComboboxControl","ExternalLink","useSelect","createInterpolateElement","useCallback","useMemo","useState","store","coreStore","debounce","decodeEntities","__","sprintf","filterURLForDisplay","getTitleWithFallbackName","jsx","_jsx","jsxs","_jsxs","buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","some","parent","undefined","termsByParent","reduce","acc","push","fillWithChildren","terms","id","length","getItemPriority","name","searchValue","normalizedName","toLowerCase","normalizedSearch","startsWith","Infinity","PageAttributesParent","data","onChangeControl","fieldValue","setFieldValue","pageId","postId","postTypeSlug","type","parentPostTitle","pageItems","isHierarchical","select","getEntityRecord","getEntityRecords","getPostType","postTypeInfo","postIsHierarchical","hierarchical","viewable","parentPost","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentOptions","getOptionsFromTree","tree","level","mappedNodes","treeNode","value","label","repeat","rawName","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","_item$parent","opts","optsHasParent","find","unshift","option","toString","handleKeydown","inputValue","handleChange","selectedPostId","_parseInt","parseInt","__nextHasNoMarginBottom","__next40pxDefaultSize","help","options","onFilterValueChange","onChange","hideLabelFromVision","ParentEdit","field","homeUrl","home","newValue","className","replace","wbr","href"],"sources":["@wordpress/fields/src/fields/parent/parent-edit.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { ComboboxControl, ExternalLink } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateInterpolateElement,\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n// @ts-ignore\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { debounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\n\ntype TreeBase = {\n\tid: number;\n\tname: string;\n\t[ key: string ]: any;\n};\n\ntype TreeWithParent = TreeBase & {\n\tparent: number;\n};\n\ntype TreeWithoutParent = TreeBase & {\n\tparent: null;\n};\n\ntype Tree = TreeWithParent | TreeWithoutParent;\n\nfunction buildTermsTree( flatTerms: Tree[] ) {\n\tconst flatTermsWithParentAndChildren = flatTerms.map( ( term ) => {\n\t\treturn {\n\t\t\tchildren: [],\n\t\t\t...term,\n\t\t};\n\t} );\n\n\t// All terms should have a `parent` because we're about to index them by it.\n\tif (\n\t\tflatTermsWithParentAndChildren.some(\n\t\t\t( { parent } ) => parent === null || parent === undefined\n\t\t)\n\t) {\n\t\treturn flatTermsWithParentAndChildren as TreeWithParent[];\n\t}\n\n\tconst termsByParent = (\n\t\tflatTermsWithParentAndChildren as TreeWithParent[]\n\t ).reduce(\n\t\t( acc, term ) => {\n\t\t\tconst { parent } = term;\n\t\t\tif ( ! acc[ parent ] ) {\n\t\t\t\tacc[ parent ] = [];\n\t\t\t}\n\t\t\tacc[ parent ].push( term );\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record< string, Array< TreeWithParent > >\n\t);\n\n\tconst fillWithChildren = (\n\t\tterms: Array< TreeWithParent >\n\t): Array< TreeWithParent > => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n\nexport const getItemPriority = ( name: string, searchValue: string ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent( {\n\tdata,\n\tonChangeControl,\n}: {\n\tdata: BasePost;\n\tonChangeControl: ( newValue: number ) => void;\n} ) {\n\tconst [ fieldValue, setFieldValue ] = useState< null | string >( null );\n\n\tconst pageId = data.parent;\n\tconst postId = data.id;\n\tconst postTypeSlug = data.type;\n\n\tconst { parentPostTitle, pageItems, isHierarchical } = useSelect(\n\t\t( select ) => {\n\t\t\t// @ts-expect-error getPostType is not typed\n\t\t\tconst { getEntityRecord, getEntityRecords, getPostType } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postTypeInfo = getPostType( postTypeSlug );\n\n\t\t\tconst postIsHierarchical =\n\t\t\t\tpostTypeInfo?.hierarchical && postTypeInfo.viewable;\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord< BasePost >(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\tpageId\n\t\t\t\t )\n\t\t\t\t: null;\n\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t...( fieldValue !== null && {\n\t\t\t\t\tsearch: fieldValue,\n\t\t\t\t} ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostTitle: parentPost\n\t\t\t\t\t? getTitleWithFallbackName( parentPost )\n\t\t\t\t\t: '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords< BasePost >(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue, pageId, postId, postTypeSlug ]\n\t);\n\n\t/**\n\t * This logic has been copied from https://github.com/WordPress/gutenberg/blob/0249771b519d5646171fb9fae422006c8ab773f2/packages/editor/src/components/page-attributes/parent.js#L106.\n\t */\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = (\n\t\t\ttree: Array< Tree >,\n\t\t\tlevel = 0\n\t\t): Array< {\n\t\t\tvalue: number;\n\t\t\tlabel: string;\n\t\t\trawName: string;\n\t\t} > => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority(\n\t\t\t\t\ta.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\tconst priorityB = getItemPriority(\n\t\t\t\t\tb.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id as number,\n\t\t\tparent: item.parent ?? null,\n\t\t\tname: getTitleWithFallbackName( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find( ( item ) => item.value === pageId );\n\t\tif ( pageId && parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: pageId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t\trawName: '',\n\t\t\t} );\n\t\t}\n\t\treturn opts.map( ( option ) => ( {\n\t\t\t...option,\n\t\t\tvalue: option.value.toString(),\n\t\t} ) );\n\t}, [ pageItems, fieldValue, parentPostTitle, pageId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue: string ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId: string | null | undefined ) => {\n\t\tif ( selectedPostId ) {\n\t\t\treturn onChangeControl( parseInt( selectedPostId, 10 ) ?? 0 );\n\t\t}\n\n\t\tonChangeControl( 0 );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ pageId?.toString() }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce(\n\t\t\t\t( value: unknown ) => handleKeydown( value as string ),\n\t\t\t\t300\n\t\t\t) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n\nexport const ParentEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.\n\t\treturn select( coreStore ).getEntityRecord< {\n\t\t\thome: string;\n\t\t} >( 'root', '__unstableBase' )?.home as string;\n\t}, [] );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue?: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__parent\">\n\t\t\t<div>\n\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %1$s The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %1$s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t<p>\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tchildren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C,eACArE,IAAA,CAACf,YAAY;YACZsH,IAAI,EAAG5G,EAAE,CACR,yFACD,CAAG;YACHa,QAAQ,EAAGG;UAAW,CACtB;QAEH,CACD;MAAC,CACC,CAAC,eACJX,IAAA,CAAC4B,oBAAoB;QACpBC,IAAI,EAAGA,IAAM;QACbC,eAAe,EAAGA;MAAiB,CACnC,CAAC;IAAA,CACE;EAAC,CACG,CAAC;AAEb,CAAC","ignoreList":[]}
@@ -17,7 +17,7 @@ const passwordField = {
17
17
  };
18
18
 
19
19
  /**
20
- * This field is used to display the post password.
20
+ * Password field for BasePost.
21
21
  */
22
22
  export default passwordField;
23
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["PasswordEdit","passwordField","id","type","Edit","enableSorting","enableHiding","isVisible","item","status"],"sources":["@wordpress/fields/src/fields/password/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport PasswordEdit from './edit';\n\nconst passwordField: Field< BasePost > = {\n\tid: 'password',\n\ttype: 'text',\n\tEdit: PasswordEdit,\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => item.status !== 'private',\n};\n\n/**\n * This field is used to display the post password.\n */\nexport default passwordField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,OAAOA,YAAY,MAAM,QAAQ;AAEjC,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAEJ,YAAY;EAClBK,aAAa,EAAE,KAAK;EACpBC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAIC,IAAI,IAAMA,IAAI,CAACC,MAAM,KAAK;AACxC,CAAC;;AAED;AACA;AACA;AACA,eAAeR,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["PasswordEdit","passwordField","id","type","Edit","enableSorting","enableHiding","isVisible","item","status"],"sources":["@wordpress/fields/src/fields/password/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport PasswordEdit from './edit';\n\nconst passwordField: Field< BasePost > = {\n\tid: 'password',\n\ttype: 'text',\n\tEdit: PasswordEdit,\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => item.status !== 'private',\n};\n\n/**\n * Password field for BasePost.\n */\nexport default passwordField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,OAAOA,YAAY,MAAM,QAAQ;AAEjC,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAEJ,YAAY;EAClBK,aAAa,EAAE,KAAK;EACpBC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAIC,IAAI,IAAMA,IAAI,CAACC,MAAM,KAAK;AACxC,CAAC;;AAED;AACA;AACA;AACA,eAAeR,aAAa","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ import { getItemTitle } from '../../actions/utils';
12
+ import PatternTitleView from './view';
13
+ const patternTitleField = {
14
+ type: 'text',
15
+ id: 'title',
16
+ label: __('Title'),
17
+ placeholder: __('No title'),
18
+ getValue: ({
19
+ item
20
+ }) => getItemTitle(item),
21
+ render: PatternTitleView,
22
+ enableHiding: false,
23
+ enableGlobalSearch: true
24
+ };
25
+
26
+ /**
27
+ * Title for the pattern entity.
28
+ */
29
+ export default patternTitleField;
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","getItemTitle","PatternTitleView","patternTitleField","type","id","label","placeholder","getValue","item","render","enableHiding","enableGlobalSearch"],"sources":["@wordpress/fields/src/fields/pattern-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 { Pattern } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\nimport PatternTitleView from './view';\n\nconst patternTitleField: Field< Pattern > = {\n\ttype: 'text',\n\tid: 'title',\n\tlabel: __( 'Title' ),\n\tplaceholder: __( 'No title' ),\n\tgetValue: ( { item } ) => getItemTitle( item ),\n\trender: PatternTitleView,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\n/**\n * Title for the pattern entity.\n */\nexport default patternTitleField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,qBAAqB;AAClD,OAAOC,gBAAgB,MAAM,QAAQ;AAErC,MAAMC,iBAAmC,GAAG;EAC3CC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,OAAO;EACXC,KAAK,EAAEN,EAAE,CAAE,OAAQ,CAAC;EACpBO,WAAW,EAAEP,EAAE,CAAE,UAAW,CAAC;EAC7BQ,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMR,YAAY,CAAEQ,IAAK,CAAC;EAC9CC,MAAM,EAAER,gBAAgB;EACxBS,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE;AACrB,CAAC;;AAED;AACA;AACA;AACA,eAAeT,iBAAiB","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { Icon, lockSmall } from '@wordpress/icons';
6
+ import { Tooltip } from '@wordpress/components';
7
+ // @ts-ignore
8
+ import { privateApis as patternPrivateApis } from '@wordpress/patterns';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+
14
+ import { BaseTitleView } from '../title/view';
15
+ import { unlock } from '../../lock-unlock';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ export const {
18
+ PATTERN_TYPES
19
+ } = unlock(patternPrivateApis);
20
+ export default function PatternTitleView({
21
+ item
22
+ }) {
23
+ return /*#__PURE__*/_jsx(BaseTitleView, {
24
+ item: item,
25
+ className: "fields-field__pattern-title",
26
+ children: item.type === PATTERN_TYPES.theme && /*#__PURE__*/_jsx(Tooltip, {
27
+ placement: "top",
28
+ text: __('This pattern cannot be edited.'),
29
+ children: /*#__PURE__*/_jsx(Icon, {
30
+ icon: lockSmall,
31
+ size: 24
32
+ })
33
+ })
34
+ });
35
+ }
36
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","Icon","lockSmall","Tooltip","privateApis","patternPrivateApis","BaseTitleView","unlock","jsx","_jsx","PATTERN_TYPES","PatternTitleView","item","className","children","type","theme","placement","text","icon","size"],"sources":["@wordpress/fields/src/fields/pattern-title/view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, lockSmall } from '@wordpress/icons';\nimport { Tooltip } from '@wordpress/components';\n// @ts-ignore\nimport { privateApis as patternPrivateApis } from '@wordpress/patterns';\n\n/**\n * Internal dependencies\n */\nimport type { CommonPost } from '../../types';\nimport { BaseTitleView } from '../title/view';\nimport { unlock } from '../../lock-unlock';\n\nexport const { PATTERN_TYPES } = unlock( patternPrivateApis );\n\nexport default function PatternTitleView( { item }: { item: CommonPost } ) {\n\treturn (\n\t\t<BaseTitleView item={ item } className=\"fields-field__pattern-title\">\n\t\t\t{ item.type === PATTERN_TYPES.theme && (\n\t\t\t\t<Tooltip\n\t\t\t\t\tplacement=\"top\"\n\t\t\t\t\ttext={ __( 'This pattern cannot be edited.' ) }\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ lockSmall } size={ 24 } />\n\t\t\t\t</Tooltip>\n\t\t\t) }\n\t\t</BaseTitleView>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,SAAS,QAAQ,kBAAkB;AAClD,SAASC,OAAO,QAAQ,uBAAuB;AAC/C;AACA,SAASC,WAAW,IAAIC,kBAAkB,QAAQ,qBAAqB;;AAEvE;AACA;AACA;;AAEA,SAASC,aAAa,QAAQ,eAAe;AAC7C,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,OAAO,MAAM;EAAEC;AAAc,CAAC,GAAGH,MAAM,CAAEF,kBAAmB,CAAC;AAE7D,eAAe,SAASM,gBAAgBA,CAAE;EAAEC;AAA2B,CAAC,EAAG;EAC1E,oBACCH,IAAA,CAACH,aAAa;IAACM,IAAI,EAAGA,IAAM;IAACC,SAAS,EAAC,6BAA6B;IAAAC,QAAA,EACjEF,IAAI,CAACG,IAAI,KAAKL,aAAa,CAACM,KAAK,iBAClCP,IAAA,CAACN,OAAO;MACPc,SAAS,EAAC,KAAK;MACfC,IAAI,EAAGlB,EAAE,CAAE,gCAAiC,CAAG;MAAAc,QAAA,eAE/CL,IAAA,CAACR,IAAI;QAACkB,IAAI,EAAGjB,SAAW;QAACkB,IAAI,EAAG;MAAI,CAAE;IAAC,CAC/B;EACT,CACa,CAAC;AAElB","ignoreList":[]}
@@ -17,5 +17,9 @@ const slugField = {
17
17
  Edit: SlugEdit,
18
18
  render: SlugView
19
19
  };
20
+
21
+ /**
22
+ * Slug field for BasePost.
23
+ */
20
24
  export default slugField;
21
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__","SlugEdit","SlugView","slugField","id","type","label","Edit","render"],"sources":["@wordpress/fields/src/fields/slug/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 SlugEdit from './slug-edit';\nimport SlugView from './slug-view';\n\nconst slugField: Field< BasePost > = {\n\tid: 'slug',\n\ttype: 'text',\n\tlabel: __( 'Slug' ),\n\tEdit: SlugEdit,\n\trender: SlugView,\n};\n\nexport default slugField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,QAAQ,MAAM,aAAa;AAElC,MAAMC,SAA4B,GAAG;EACpCC,EAAE,EAAE,MAAM;EACVC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,MAAO,CAAC;EACnBO,IAAI,EAAEN,QAAQ;EACdO,MAAM,EAAEN;AACT,CAAC;AAED,eAAeC,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["__","SlugEdit","SlugView","slugField","id","type","label","Edit","render"],"sources":["@wordpress/fields/src/fields/slug/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 SlugEdit from './slug-edit';\nimport SlugView from './slug-view';\n\nconst slugField: Field< BasePost > = {\n\tid: 'slug',\n\ttype: 'text',\n\tlabel: __( 'Slug' ),\n\tEdit: SlugEdit,\n\trender: SlugView,\n};\n\n/**\n * Slug field for BasePost.\n */\nexport default slugField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,QAAQ,MAAM,aAAa;AAElC,MAAMC,SAA4B,GAAG;EACpCC,EAAE,EAAE,MAAM;EACVC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,MAAO,CAAC;EACnBO,IAAI,EAAEN,QAAQ;EACdO,MAAM,EAAEN;AACT,CAAC;;AAED;AACA;AACA;AACA,eAAeC,SAAS","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  /**
2
3
  * WordPress dependencies
3
4
  */
@@ -1 +1 @@
1
- {"version":3,"names":["__experimentalHStack","HStack","Icon","STATUSES","jsx","_jsx","jsxs","_jsxs","StatusView","item","status","find","value","label","icon","alignment","spacing","children","className"],"sources":["@wordpress/fields/src/fields/status/status-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport STATUSES from './status-elements';\n\nfunction StatusView( { item }: { item: BasePost } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default StatusView;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,oBAAoB,IAAIC,MAAM,EAAEC,IAAI,QAAQ,uBAAuB;;AAE5E;AACA;AACA;;AAEA,OAAOC,QAAQ,MAAM,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEzC,SAASC,UAAUA,CAAE;EAAEC;AAAyB,CAAC,EAAG;EACnD,MAAMC,MAAM,GAAGP,QAAQ,CAACQ,IAAI,CAAE,CAAE;IAAEC;EAAM,CAAC,KAAMA,KAAK,KAAKH,IAAI,CAACC,MAAO,CAAC;EACtE,MAAMG,KAAK,GAAGH,MAAM,EAAEG,KAAK,IAAIJ,IAAI,CAACC,MAAM;EAC1C,MAAMI,IAAI,GAAGJ,MAAM,EAAEI,IAAI;EACzB,oBACCP,KAAA,CAACN,MAAM;IAACc,SAAS,EAAC,MAAM;IAACC,OAAO,EAAG,CAAG;IAAAC,QAAA,GACnCH,IAAI,iBACLT,IAAA;MAAKa,SAAS,EAAC,kCAAkC;MAAAD,QAAA,eAChDZ,IAAA,CAACH,IAAI;QAACY,IAAI,EAAGA;MAAM,CAAE;IAAC,CAClB,CACL,eACDT,IAAA;MAAAY,QAAA,EAAQJ;IAAK,CAAQ,CAAC;EAAA,CACf,CAAC;AAEX;AAEA,eAAeL,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["__experimentalHStack","HStack","Icon","STATUSES","jsx","_jsx","jsxs","_jsxs","StatusView","item","status","find","value","label","icon","alignment","spacing","children","className"],"sources":["@wordpress/fields/src/fields/status/status-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport STATUSES from './status-elements';\n\nfunction StatusView( { item }: { item: BasePost } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default StatusView;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,oBAAoB,IAAIC,MAAM,EAAEC,IAAI,QAAQ,uBAAuB;;AAE5E;AACA;AACA;;AAEA,OAAOC,QAAQ,MAAM,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEzC,SAASC,UAAUA,CAAE;EAAEC;AAAyB,CAAC,EAAG;EACnD,MAAMC,MAAM,GAAGP,QAAQ,CAACQ,IAAI,CAAE,CAAE;IAAEC;EAAM,CAAC,KAAMA,KAAK,KAAKH,IAAI,CAACC,MAAO,CAAC;EACtE,MAAMG,KAAK,GAAGH,MAAM,EAAEG,KAAK,IAAIJ,IAAI,CAACC,MAAM;EAC1C,MAAMI,IAAI,GAAGJ,MAAM,EAAEI,IAAI;EACzB,oBACCP,KAAA,CAACN,MAAM;IAACc,SAAS,EAAC,MAAM;IAACC,OAAO,EAAG,CAAG;IAAAC,QAAA,GACnCH,IAAI,iBACLT,IAAA;MAAKa,SAAS,EAAC,kCAAkC;MAAAD,QAAA,eAChDZ,IAAA,CAACH,IAAI;QAACY,IAAI,EAAGA;MAAM,CAAE;IAAC,CAClB,CACL,eACDT,IAAA;MAAAY,QAAA,EAAQJ;IAAK,CAAQ,CAAC;EAAA,CACf,CAAC;AAEX;AAEA,eAAeL,UAAU","ignoreList":[]}
@@ -11,11 +11,12 @@ const templateField = {
11
11
  id: 'template',
12
12
  type: 'text',
13
13
  label: __('Template'),
14
- getValue: ({
15
- item
16
- }) => item.template,
17
14
  Edit: TemplateEdit,
18
15
  enableSorting: false
19
16
  };
17
+
18
+ /**
19
+ * Template field for BasePost.
20
+ */
20
21
  export default templateField;
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__","TemplateEdit","templateField","id","type","label","getValue","item","template","Edit","enableSorting"],"sources":["@wordpress/fields/src/fields/template/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport type { BasePost } from '../../types';\nimport { TemplateEdit } from './template-edit';\n\nconst templateField: Field< BasePost > = {\n\tid: 'template',\n\ttype: 'text',\n\tlabel: __( 'Template' ),\n\tgetValue: ( { item } ) => item.template,\n\tEdit: TemplateEdit,\n\tenableSorting: false,\n};\n\nexport default templateField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AAEpC,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEL,EAAE,CAAE,UAAW,CAAC;EACvBM,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMA,IAAI,CAACC,QAAQ;EACvCC,IAAI,EAAER,YAAY;EAClBS,aAAa,EAAE;AAChB,CAAC;AAED,eAAeR,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["__","TemplateEdit","templateField","id","type","label","Edit","enableSorting"],"sources":["@wordpress/fields/src/fields/template/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport type { BasePost } from '../../types';\nimport { TemplateEdit } from './template-edit';\n\nconst templateField: Field< BasePost > = {\n\tid: 'template',\n\ttype: 'text',\n\tlabel: __( 'Template' ),\n\tEdit: TemplateEdit,\n\tenableSorting: false,\n};\n\n/**\n * Template field for BasePost.\n */\nexport default templateField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AAEpC,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEL,EAAE,CAAE,UAAW,CAAC;EACvBM,IAAI,EAAEL,YAAY;EAClBM,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA,eAAeL,aAAa","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  /**
2
3
  * WordPress dependencies
3
4
  */
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useMemo","useState","parse","store","coreStore","__experimentalBlockPatternsList","BlockPatternsList","Button","Dropdown","MenuGroup","MenuItem","Modal","useAsyncList","useSelect","decodeEntities","__","getItemTitle","unlock","jsx","_jsx","jsxs","_jsxs","TemplateEdit","data","field","onChange","id","postType","type","postId","parseInt","slug","availableTemplates","templates","select","_select$getEntityReco","allTemplates","getEntityRecords","per_page","post_type","getHomePage","getPostsPageId","isPostsPage","isFrontPage","allowSwitchingTemplate","filter","template","is_custom","content","raw","templatesAsPatterns","map","name","blocks","title","rendered","shownTemplates","value","getValue","item","currentTemplate","foundTemplate","find","slugToCheck","templateId","getDefaultTemplateId","getEntityRecord","showModal","setShowModal","onChangeControl","newValue","className","children","popoverProps","placement","renderToggle","onToggle","__next40pxDefaultSize","variant","size","onClick","renderContent","onRequestClose","overlayClassName","isFullScreen","label","blockPatterns","shownPatterns","onClickPattern"],"sources":["@wordpress/fields/src/fields/template/template-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo, useState } from '@wordpress/element';\n// @ts-ignore\nimport { parse } from '@wordpress/blocks';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\n// @ts-expect-error block-editor is not typed correctly.\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tDropdown,\n\tMenuGroup,\n\tMenuItem,\n\tModal,\n} from '@wordpress/components';\nimport { useAsyncList } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { getItemTitle } from '../../actions/utils';\nimport type { BasePost } from '../../types';\nimport { unlock } from '../../lock-unlock';\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 { availableTemplates, templates } = 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) ?? [];\n\n\t\t\tconst { getHomePage, getPostsPageId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst isPostsPage = getPostsPageId() === +postId;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && getHomePage()?.postId === +postId;\n\n\t\t\tconst allowSwitchingTemplate = ! isPostsPage && ! isFrontPage;\n\n\t\t\treturn {\n\t\t\t\ttemplates: allTemplates,\n\t\t\t\tavailableTemplates: allowSwitchingTemplate\n\t\t\t\t\t? allTemplates.filter(\n\t\t\t\t\t\t\t( template ) =>\n\t\t\t\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\t\t\t\ttemplate.slug !== data.template &&\n\t\t\t\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t\t\t )\n\t\t\t\t\t: [],\n\t\t\t};\n\t\t},\n\t\t[ data.template, postId, postType ]\n\t);\n\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\n\tconst shownTemplates = useAsyncList( templatesAsPatterns );\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst currentTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst foundTemplate = templates?.find(\n\t\t\t\t( template ) => template.slug === value\n\t\t\t);\n\n\t\t\tif ( foundTemplate ) {\n\t\t\t\treturn foundTemplate;\n\t\t\t}\n\n\t\t\tlet slugToCheck;\n\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t// through template hierarchy.\n\t\t\tif ( slug ) {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page'\n\t\t\t\t\t\t? `${ postType }-${ slug }`\n\t\t\t\t\t\t: `single-${ postType }-${ slug }`;\n\t\t\t} else {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page' ? 'page' : `single-${ postType }`;\n\t\t\t}\n\n\t\t\tif ( postType ) {\n\t\t\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\n\t\t\t\treturn select( coreStore ).getEntityRecord(\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}\n\t\t},\n\t\t[ postType, slug, templates, value ]\n\t);\n\n\tconst [ showModal, setShowModal ] = useState( false );\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\treturn (\n\t\t<fieldset className=\"fields-controls__template\">\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\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\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ currentTemplate\n\t\t\t\t\t\t\t? getItemTitle( currentTemplate )\n\t\t\t\t\t\t\t: '' }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onToggle } ) => (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowModal( true );\n\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Swap template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// The default template in a post is indicated by an empty string\n\t\t\t\t\t\t\tvalue !== '' && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonChangeControl( '' );\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Use default template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"fields-controls__template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"fields-controls__template-content\">\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tlabel={ __( 'Templates' ) }\n\t\t\t\t\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\t\t\t\t\tshownPatterns={ shownTemplates }\n\t\t\t\t\t\t\tonClickPattern={ (\n\t\t\t\t\t\t\t\ttemplate: ( typeof templatesAsPatterns )[ 0 ]\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tonChangeControl( template.name );\n\t\t\t\t\t\t\t\tsetShowModal( false );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\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C,aAAa,EAAG/B,cAAgB;UAChCgC,cAAc,EACb1C,QAA6C,IACzC;YACJuB,eAAe,CAAEvB,QAAQ,CAACM,IAAK,CAAC;YAChCgB,YAAY,CAAE,KAAM,CAAC;UACtB;QAAG,CACH;MAAC,CACE;IAAC,CACA,CACP;EAAA,CACQ,CAAC;AAEb,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","useMemo","useState","parse","store","coreStore","__experimentalBlockPatternsList","BlockPatternsList","Button","Dropdown","MenuGroup","MenuItem","Modal","useAsyncList","useSelect","decodeEntities","__","getItemTitle","unlock","jsx","_jsx","jsxs","_jsxs","TemplateEdit","data","field","onChange","id","postType","type","postId","parseInt","slug","availableTemplates","templates","select","_select$getEntityReco","allTemplates","getEntityRecords","per_page","post_type","getHomePage","getPostsPageId","isPostsPage","isFrontPage","allowSwitchingTemplate","filter","template","is_custom","content","raw","templatesAsPatterns","map","name","blocks","title","rendered","shownTemplates","value","getValue","item","currentTemplate","foundTemplate","find","slugToCheck","templateId","getDefaultTemplateId","getEntityRecord","showModal","setShowModal","onChangeControl","newValue","className","children","popoverProps","placement","renderToggle","onToggle","__next40pxDefaultSize","variant","size","onClick","renderContent","onRequestClose","overlayClassName","isFullScreen","label","blockPatterns","shownPatterns","onClickPattern"],"sources":["@wordpress/fields/src/fields/template/template-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo, useState } from '@wordpress/element';\n// @ts-ignore\nimport { parse } from '@wordpress/blocks';\nimport type { WpTemplate } from '@wordpress/core-data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\n// @ts-expect-error block-editor is not typed correctly.\nimport { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';\nimport {\n\tButton,\n\tDropdown,\n\tMenuGroup,\n\tMenuItem,\n\tModal,\n} from '@wordpress/components';\nimport { useAsyncList } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { getItemTitle } from '../../actions/utils';\nimport type { BasePost } from '../../types';\nimport { unlock } from '../../lock-unlock';\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 { availableTemplates, templates } = 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) ?? [];\n\n\t\t\tconst { getHomePage, getPostsPageId } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\n\t\t\tconst isPostsPage = getPostsPageId() === +postId;\n\t\t\tconst isFrontPage =\n\t\t\t\tpostType === 'page' && getHomePage()?.postId === +postId;\n\n\t\t\tconst allowSwitchingTemplate = ! isPostsPage && ! isFrontPage;\n\n\t\t\treturn {\n\t\t\t\ttemplates: allTemplates,\n\t\t\t\tavailableTemplates: allowSwitchingTemplate\n\t\t\t\t\t? allTemplates.filter(\n\t\t\t\t\t\t\t( template ) =>\n\t\t\t\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\t\t\t\ttemplate.slug !== data.template &&\n\t\t\t\t\t\t\t\t!! template.content.raw // Skip empty templates.\n\t\t\t\t\t )\n\t\t\t\t\t: [],\n\t\t\t};\n\t\t},\n\t\t[ data.template, postId, postType ]\n\t);\n\n\tconst templatesAsPatterns = useMemo(\n\t\t() =>\n\t\t\tavailableTemplates.map( ( template ) => ( {\n\t\t\t\tname: template.slug,\n\t\t\t\tblocks: parse( template.content.raw ),\n\t\t\t\ttitle: decodeEntities( template.title.rendered ),\n\t\t\t\tid: template.id,\n\t\t\t} ) ),\n\t\t[ availableTemplates ]\n\t);\n\n\tconst shownTemplates = useAsyncList( templatesAsPatterns );\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst currentTemplate = useSelect(\n\t\t( select ) => {\n\t\t\tconst foundTemplate = templates?.find(\n\t\t\t\t( template ) => template.slug === value\n\t\t\t);\n\n\t\t\tif ( foundTemplate ) {\n\t\t\t\treturn foundTemplate;\n\t\t\t}\n\n\t\t\tlet slugToCheck;\n\t\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t\t// through template hierarchy.\n\t\t\tif ( slug ) {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page'\n\t\t\t\t\t\t? `${ postType }-${ slug }`\n\t\t\t\t\t\t: `single-${ postType }-${ slug }`;\n\t\t\t} else {\n\t\t\t\tslugToCheck =\n\t\t\t\t\tpostType === 'page' ? 'page' : `single-${ postType }`;\n\t\t\t}\n\n\t\t\tif ( postType ) {\n\t\t\t\tconst templateId = select( coreStore ).getDefaultTemplateId( {\n\t\t\t\t\tslug: slugToCheck,\n\t\t\t\t} );\n\n\t\t\t\treturn select( coreStore ).getEntityRecord(\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}\n\t\t},\n\t\t[ postType, slug, templates, value ]\n\t);\n\n\tconst [ showModal, setShowModal ] = useState( false );\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\treturn (\n\t\t<fieldset className=\"fields-controls__template\">\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ { placement: 'bottom-start' } }\n\t\t\t\trenderToggle={ ( { onToggle } ) => (\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\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ currentTemplate\n\t\t\t\t\t\t\t? getItemTitle( currentTemplate )\n\t\t\t\t\t\t\t: '' }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onToggle } ) => (\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetShowModal( true );\n\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Swap template' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// The default template in a post is indicated by an empty string\n\t\t\t\t\t\t\tvalue !== '' && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonChangeControl( '' );\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Use default template' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t{ showModal && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ __( 'Choose a template' ) }\n\t\t\t\t\tonRequestClose={ () => setShowModal( false ) }\n\t\t\t\t\toverlayClassName=\"fields-controls__template-modal\"\n\t\t\t\t\tisFullScreen\n\t\t\t\t>\n\t\t\t\t\t<div className=\"fields-controls__template-content\">\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tlabel={ __( 'Templates' ) }\n\t\t\t\t\t\t\tblockPatterns={ templatesAsPatterns }\n\t\t\t\t\t\t\tshownPatterns={ shownTemplates }\n\t\t\t\t\t\t\tonClickPattern={ (\n\t\t\t\t\t\t\t\ttemplate: ( typeof templatesAsPatterns )[ 0 ]\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tonChangeControl( template.name );\n\t\t\t\t\t\t\t\tsetShowModal( false );\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</Modal>\n\t\t\t) }\n\t\t</fieldset>\n\t);\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACnE;AACA,SAASC,KAAK,QAAQ,mBAAmB;AAEzC,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAGzD;AACA;AACA;AACA;AACA,SAASC,+BAA+B,IAAIC,iBAAiB,QAAQ,yBAAyB;AAC9F,SACCC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,KAAK,QACC,uBAAuB;AAC9B,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,qBAAqB;AAElD,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE3C,OAAO,MAAMC,YAAY,GAAGA,CAAE;EAC7BC,IAAI;EACJC,KAAK;EACLC;AACiC,CAAC,KAAM;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGF,KAAK;EACpB,MAAMG,QAAQ,GAAGJ,IAAI,CAACK,IAAI;EAC1B,MAAMC,MAAM,GACX,OAAON,IAAI,CA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iBACVhD,IAAA,CAACR,KAAK;MACL2C,KAAK,EAAGvC,EAAE,CAAE,mBAAoB,CAAG;MACnCmE,cAAc,EAAGA,CAAA,KAAMd,YAAY,CAAE,KAAM,CAAG;MAC9Ce,gBAAgB,EAAC,iCAAiC;MAClDC,YAAY;MAAAZ,QAAA,eAEZrD,IAAA;QAAKoD,SAAS,EAAC,mCAAmC;QAAAC,QAAA,eACjDrD,IAAA,CAACb,iBAAiB;UACjB+E,KAAK,EAAGtE,EAAE,CAAE,WAAY,CAAG;UAC3BuE,aAAa,EAAGpC,mBAAqB;UACrCqC,aAAa,EAAG/B,cAAgB;UAChCgC,cAAc,EACb1C,QAA6C,IACzC;YACJuB,eAAe,CAAEvB,QAAQ,CAACM,IAAK,CAAC;YAChCgB,YAAY,CAAE,KAAM,CAAC;UACtB;QAAG,CACH;MAAC,CACE;IAAC,CACA,CACP;EAAA,CACQ,CAAC;AAEb,CAAC","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ import { getItemTitle } from '../../actions/utils';
12
+ import TitleView from '../title/view';
13
+ const templateTitleField = {
14
+ type: 'text',
15
+ label: __('Template'),
16
+ placeholder: __('No title'),
17
+ id: 'title',
18
+ getValue: ({
19
+ item
20
+ }) => getItemTitle(item),
21
+ render: TitleView,
22
+ enableHiding: false,
23
+ enableGlobalSearch: true
24
+ };
25
+
26
+ /**
27
+ * Title for the template entity.
28
+ */
29
+ export default templateTitleField;
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","getItemTitle","TitleView","templateTitleField","type","label","placeholder","id","getValue","item","render","enableHiding","enableGlobalSearch"],"sources":["@wordpress/fields/src/fields/template-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 { Template } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\nimport TitleView from '../title/view';\n\nconst templateTitleField: Field< Template > = {\n\ttype: 'text',\n\tlabel: __( 'Template' ),\n\tplaceholder: __( 'No title' ),\n\tid: 'title',\n\tgetValue: ( { item } ) => getItemTitle( item ),\n\trender: TitleView,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\n/**\n * Title for the template entity.\n */\nexport default templateTitleField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,qBAAqB;AAClD,OAAOC,SAAS,MAAM,eAAe;AAErC,MAAMC,kBAAqC,GAAG;EAC7CC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEL,EAAE,CAAE,UAAW,CAAC;EACvBM,WAAW,EAAEN,EAAE,CAAE,UAAW,CAAC;EAC7BO,EAAE,EAAE,OAAO;EACXC,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMR,YAAY,CAAEQ,IAAK,CAAC;EAC9CC,MAAM,EAAER,SAAS;EACjBS,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE;AACrB,CAAC;;AAED;AACA;AACA;AACA,eAAeT,kBAAkB","ignoreList":[]}
@@ -9,7 +9,7 @@ import { __ } from '@wordpress/i18n';
9
9
  */
10
10
 
11
11
  import { getItemTitle } from '../../actions/utils';
12
- import TitleView from './title-view';
12
+ import TitleView from './view';
13
13
  const titleField = {
14
14
  type: 'text',
15
15
  id: 'title',
@@ -19,7 +19,14 @@ const titleField = {
19
19
  item
20
20
  }) => getItemTitle(item),
21
21
  render: TitleView,
22
- enableHiding: false
22
+ enableHiding: false,
23
+ enableGlobalSearch: true
23
24
  };
25
+
26
+ /**
27
+ * Title for the any entity with a `title` property.
28
+ * For patterns, pages or templates you should use the respective field
29
+ * because there are some differences in the rendering, labels, etc.
30
+ */
24
31
  export default titleField;
25
32
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__","getItemTitle","TitleView","titleField","type","id","label","placeholder","getValue","item","render","enableHiding"],"sources":["@wordpress/fields/src/fields/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 TitleView from './title-view';\n\nconst titleField: Field< BasePost > = {\n\ttype: 'text',\n\tid: 'title',\n\tlabel: __( 'Title' ),\n\tplaceholder: __( 'No title' ),\n\tgetValue: ( { item } ) => getItemTitle( item ),\n\trender: TitleView,\n\tenableHiding: false,\n};\n\nexport default titleField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,qBAAqB;AAClD,OAAOC,SAAS,MAAM,cAAc;AAEpC,MAAMC,UAA6B,GAAG;EACrCC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,OAAO;EACXC,KAAK,EAAEN,EAAE,CAAE,OAAQ,CAAC;EACpBO,WAAW,EAAEP,EAAE,CAAE,UAAW,CAAC;EAC7BQ,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMR,YAAY,CAAEQ,IAAK,CAAC;EAC9CC,MAAM,EAAER,SAAS;EACjBS,YAAY,EAAE;AACf,CAAC;AAED,eAAeR,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["__","getItemTitle","TitleView","titleField","type","id","label","placeholder","getValue","item","render","enableHiding","enableGlobalSearch"],"sources":["@wordpress/fields/src/fields/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 { CommonPost } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\nimport TitleView from './view';\n\nconst titleField: Field< CommonPost > = {\n\ttype: 'text',\n\tid: 'title',\n\tlabel: __( 'Title' ),\n\tplaceholder: __( 'No title' ),\n\tgetValue: ( { item } ) => getItemTitle( item ),\n\trender: TitleView,\n\tenableHiding: false,\n\tenableGlobalSearch: true,\n};\n\n/**\n * Title for the any entity with a `title` property.\n * For patterns, pages or templates you should use the respective field\n * because there are some differences in the rendering, labels, etc.\n */\nexport default titleField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,qBAAqB;AAClD,OAAOC,SAAS,MAAM,QAAQ;AAE9B,MAAMC,UAA+B,GAAG;EACvCC,IAAI,EAAE,MAAM;EACZC,EAAE,EAAE,OAAO;EACXC,KAAK,EAAEN,EAAE,CAAE,OAAQ,CAAC;EACpBO,WAAW,EAAEP,EAAE,CAAE,UAAW,CAAC;EAC7BQ,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMR,YAAY,CAAEQ,IAAK,CAAC;EAC9CC,MAAM,EAAER,SAAS;EACjBS,YAAY,EAAE,KAAK;EACnBC,kBAAkB,EAAE;AACrB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,eAAeT,UAAU","ignoreList":[]}