@wordpress/fields 0.5.0 → 0.5.1-next.a9f418477.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 (299) hide show
  1. package/README.md +52 -27
  2. package/build/actions/delete-post.js +4 -0
  3. package/build/actions/delete-post.js.map +1 -1
  4. package/build/actions/duplicate-pattern.js +4 -0
  5. package/build/actions/duplicate-pattern.js.map +1 -1
  6. package/build/actions/duplicate-post.js +7 -3
  7. package/build/actions/duplicate-post.js.map +1 -1
  8. package/build/actions/duplicate-template-part.js +71 -0
  9. package/build/actions/duplicate-template-part.js.map +1 -0
  10. package/build/actions/export-pattern.js +4 -0
  11. package/build/actions/export-pattern.js.map +1 -1
  12. package/build/actions/index.js +3 -17
  13. package/build/actions/index.js.map +1 -1
  14. package/build/actions/permanently-delete-post.js +4 -1
  15. package/build/actions/permanently-delete-post.js.map +1 -1
  16. package/build/actions/rename-post.js +6 -2
  17. package/build/actions/rename-post.js.map +1 -1
  18. package/build/actions/reorder-page.js +4 -0
  19. package/build/actions/reorder-page.js.map +1 -1
  20. package/build/actions/reset-post.js +7 -3
  21. package/build/actions/reset-post.js.map +1 -1
  22. package/build/actions/restore-post.js +4 -1
  23. package/build/actions/restore-post.js.map +1 -1
  24. package/build/actions/trash-post.js +4 -1
  25. package/build/actions/trash-post.js.map +1 -1
  26. package/build/actions/utils.js +4 -12
  27. package/build/actions/utils.js.map +1 -1
  28. package/build/actions/view-post-revisions.js +4 -0
  29. package/build/actions/view-post-revisions.js.map +1 -1
  30. package/build/actions/view-post.js +4 -0
  31. package/build/actions/view-post.js.map +1 -1
  32. package/build/components/create-template-part-modal/index.js +213 -0
  33. package/build/components/create-template-part-modal/index.js.map +1 -0
  34. package/build/components/create-template-part-modal/utils.js +64 -0
  35. package/build/components/create-template-part-modal/utils.js.map +1 -0
  36. package/build/fields/featured-image/index.js +4 -0
  37. package/build/fields/featured-image/index.js.map +1 -1
  38. package/build/fields/index.js +28 -0
  39. package/build/fields/index.js.map +1 -1
  40. package/build/fields/order/index.js +4 -0
  41. package/build/fields/order/index.js.map +1 -1
  42. package/build/fields/page-title/index.js +36 -0
  43. package/build/fields/page-title/index.js.map +1 -0
  44. package/build/fields/page-title/view.js +45 -0
  45. package/build/fields/page-title/view.js.map +1 -0
  46. package/build/fields/parent/index.js +1 -1
  47. package/build/fields/parent/index.js.map +1 -1
  48. package/build/fields/password/index.js +1 -1
  49. package/build/fields/password/index.js.map +1 -1
  50. package/build/fields/pattern-title/index.js +36 -0
  51. package/build/fields/pattern-title/index.js.map +1 -0
  52. package/build/fields/pattern-title/view.js +45 -0
  53. package/build/fields/pattern-title/view.js.map +1 -0
  54. package/build/fields/slug/index.js +4 -0
  55. package/build/fields/slug/index.js.map +1 -1
  56. package/build/fields/slug/slug-view.js +1 -1
  57. package/build/fields/slug/slug-view.js.map +1 -1
  58. package/build/fields/slug/utils.js +3 -0
  59. package/build/fields/slug/utils.js.map +1 -1
  60. package/build/fields/template/index.js +29 -0
  61. package/build/fields/template/index.js.map +1 -0
  62. package/build/fields/template/template-edit.js +154 -0
  63. package/build/fields/template/template-edit.js.map +1 -0
  64. package/build/fields/template-title/index.js +36 -0
  65. package/build/fields/template-title/index.js.map +1 -0
  66. package/build/fields/title/index.js +10 -3
  67. package/build/fields/title/index.js.map +1 -1
  68. package/build/fields/title/view.js +48 -0
  69. package/build/fields/title/view.js.map +1 -0
  70. package/build/index.js +13 -0
  71. package/build/index.js.map +1 -1
  72. package/build/index.native.js +0 -26
  73. package/build/index.native.js.map +1 -1
  74. package/build/mutation/index.js +0 -1
  75. package/build/mutation/index.js.map +1 -1
  76. package/build/types.js.map +1 -1
  77. package/build-module/actions/delete-post.js +4 -0
  78. package/build-module/actions/delete-post.js.map +1 -1
  79. package/build-module/actions/duplicate-pattern.js +4 -0
  80. package/build-module/actions/duplicate-pattern.js.map +1 -1
  81. package/build-module/actions/duplicate-post.js +7 -3
  82. package/build-module/actions/duplicate-post.js.map +1 -1
  83. package/build-module/actions/duplicate-template-part.js +66 -0
  84. package/build-module/actions/duplicate-template-part.js.map +1 -0
  85. package/build-module/actions/export-pattern.js +4 -0
  86. package/build-module/actions/export-pattern.js.map +1 -1
  87. package/build-module/actions/index.js +1 -3
  88. package/build-module/actions/index.js.map +1 -1
  89. package/build-module/actions/permanently-delete-post.js +4 -1
  90. package/build-module/actions/permanently-delete-post.js.map +1 -1
  91. package/build-module/actions/rename-post.js +7 -3
  92. package/build-module/actions/rename-post.js.map +1 -1
  93. package/build-module/actions/reorder-page.js +4 -0
  94. package/build-module/actions/reorder-page.js.map +1 -1
  95. package/build-module/actions/reset-post.js +8 -4
  96. package/build-module/actions/reset-post.js.map +1 -1
  97. package/build-module/actions/restore-post.js +4 -1
  98. package/build-module/actions/restore-post.js.map +1 -1
  99. package/build-module/actions/trash-post.js +4 -1
  100. package/build-module/actions/trash-post.js.map +1 -1
  101. package/build-module/actions/utils.js +4 -11
  102. package/build-module/actions/utils.js.map +1 -1
  103. package/build-module/actions/view-post-revisions.js +4 -0
  104. package/build-module/actions/view-post-revisions.js.map +1 -1
  105. package/build-module/actions/view-post.js +4 -0
  106. package/build-module/actions/view-post.js.map +1 -1
  107. package/build-module/components/create-template-part-modal/index.js +204 -0
  108. package/build-module/components/create-template-part-modal/index.js.map +1 -0
  109. package/build-module/components/create-template-part-modal/utils.js +55 -0
  110. package/build-module/components/create-template-part-modal/utils.js.map +1 -0
  111. package/build-module/fields/featured-image/index.js +4 -0
  112. package/build-module/fields/featured-image/index.js.map +1 -1
  113. package/build-module/fields/index.js +4 -0
  114. package/build-module/fields/index.js.map +1 -1
  115. package/build-module/fields/order/index.js +4 -0
  116. package/build-module/fields/order/index.js.map +1 -1
  117. package/build-module/fields/page-title/index.js +30 -0
  118. package/build-module/fields/page-title/index.js.map +1 -0
  119. package/build-module/fields/page-title/view.js +39 -0
  120. package/build-module/fields/page-title/view.js.map +1 -0
  121. package/build-module/fields/parent/index.js +1 -1
  122. package/build-module/fields/parent/index.js.map +1 -1
  123. package/build-module/fields/password/index.js +1 -1
  124. package/build-module/fields/password/index.js.map +1 -1
  125. package/build-module/fields/pattern-title/index.js +30 -0
  126. package/build-module/fields/pattern-title/index.js.map +1 -0
  127. package/build-module/fields/pattern-title/view.js +36 -0
  128. package/build-module/fields/pattern-title/view.js.map +1 -0
  129. package/build-module/fields/slug/index.js +4 -0
  130. package/build-module/fields/slug/index.js.map +1 -1
  131. package/build-module/fields/slug/slug-view.js +1 -1
  132. package/build-module/fields/slug/slug-view.js.map +1 -1
  133. package/build-module/fields/slug/utils.js +3 -0
  134. package/build-module/fields/slug/utils.js.map +1 -1
  135. package/build-module/fields/template/index.js +22 -0
  136. package/build-module/fields/template/index.js.map +1 -0
  137. package/build-module/fields/template/template-edit.js +144 -0
  138. package/build-module/fields/template/template-edit.js.map +1 -0
  139. package/build-module/fields/template-title/index.js +30 -0
  140. package/build-module/fields/template-title/index.js.map +1 -0
  141. package/build-module/fields/title/index.js +9 -2
  142. package/build-module/fields/title/index.js.map +1 -1
  143. package/build-module/fields/title/view.js +39 -0
  144. package/build-module/fields/title/view.js.map +1 -0
  145. package/build-module/index.js +1 -0
  146. package/build-module/index.js.map +1 -1
  147. package/build-module/index.native.js +1 -2
  148. package/build-module/index.native.js.map +1 -1
  149. package/build-module/mutation/index.js +0 -1
  150. package/build-module/mutation/index.js.map +1 -1
  151. package/build-module/types.js.map +1 -1
  152. package/build-style/style-rtl.css +98 -0
  153. package/build-style/style.css +98 -0
  154. package/build-types/actions/delete-post.d.ts +3 -0
  155. package/build-types/actions/delete-post.d.ts.map +1 -1
  156. package/build-types/actions/duplicate-pattern.d.ts +3 -0
  157. package/build-types/actions/duplicate-pattern.d.ts.map +1 -1
  158. package/build-types/actions/duplicate-post.d.ts +3 -0
  159. package/build-types/actions/duplicate-post.d.ts.map +1 -1
  160. package/build-types/actions/duplicate-template-part.d.ts +14 -0
  161. package/build-types/actions/duplicate-template-part.d.ts.map +1 -0
  162. package/build-types/actions/export-pattern.d.ts +3 -0
  163. package/build-types/actions/export-pattern.d.ts.map +1 -1
  164. package/build-types/actions/index.d.ts +1 -3
  165. package/build-types/actions/index.d.ts.map +1 -1
  166. package/build-types/actions/permanently-delete-post.d.ts +3 -0
  167. package/build-types/actions/permanently-delete-post.d.ts.map +1 -1
  168. package/build-types/actions/rename-post.d.ts +3 -0
  169. package/build-types/actions/rename-post.d.ts.map +1 -1
  170. package/build-types/actions/reorder-page.d.ts +3 -0
  171. package/build-types/actions/reorder-page.d.ts.map +1 -1
  172. package/build-types/actions/reset-post.d.ts +3 -0
  173. package/build-types/actions/reset-post.d.ts.map +1 -1
  174. package/build-types/actions/restore-post.d.ts +3 -0
  175. package/build-types/actions/restore-post.d.ts.map +1 -1
  176. package/build-types/actions/trash-post.d.ts +3 -0
  177. package/build-types/actions/trash-post.d.ts.map +1 -1
  178. package/build-types/actions/utils.d.ts +7 -8
  179. package/build-types/actions/utils.d.ts.map +1 -1
  180. package/build-types/actions/view-post-revisions.d.ts +3 -0
  181. package/build-types/actions/view-post-revisions.d.ts.map +1 -1
  182. package/build-types/actions/view-post.d.ts +3 -0
  183. package/build-types/actions/view-post.d.ts.map +1 -1
  184. package/build-types/components/create-template-part-modal/index.d.ts +34 -0
  185. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -0
  186. package/build-types/components/create-template-part-modal/utils.d.ts +4 -0
  187. package/build-types/components/create-template-part-modal/utils.d.ts.map +1 -0
  188. package/build-types/fields/featured-image/index.d.ts +3 -0
  189. package/build-types/fields/featured-image/index.d.ts.map +1 -1
  190. package/build-types/fields/index.d.ts +4 -0
  191. package/build-types/fields/index.d.ts.map +1 -1
  192. package/build-types/fields/order/index.d.ts +3 -0
  193. package/build-types/fields/order/index.d.ts.map +1 -1
  194. package/build-types/fields/page-title/index.d.ts +14 -0
  195. package/build-types/fields/page-title/index.d.ts.map +1 -0
  196. package/build-types/fields/page-title/view.d.ts +8 -0
  197. package/build-types/fields/page-title/view.d.ts.map +1 -0
  198. package/build-types/fields/parent/index.d.ts +1 -1
  199. package/build-types/fields/password/index.d.ts +1 -1
  200. package/build-types/fields/pattern-title/index.d.ts +14 -0
  201. package/build-types/fields/pattern-title/index.d.ts.map +1 -0
  202. package/build-types/fields/pattern-title/view.d.ts +9 -0
  203. package/build-types/fields/pattern-title/view.d.ts.map +1 -0
  204. package/build-types/fields/slug/index.d.ts +3 -0
  205. package/build-types/fields/slug/index.d.ts.map +1 -1
  206. package/build-types/fields/slug/utils.d.ts.map +1 -1
  207. package/build-types/fields/template/index.d.ts +11 -0
  208. package/build-types/fields/template/index.d.ts.map +1 -0
  209. package/build-types/fields/template/template-edit.d.ts +4 -0
  210. package/build-types/fields/template/template-edit.d.ts.map +1 -0
  211. package/build-types/fields/template-title/index.d.ts +14 -0
  212. package/build-types/fields/template-title/index.d.ts.map +1 -0
  213. package/build-types/fields/title/index.d.ts +7 -2
  214. package/build-types/fields/title/index.d.ts.map +1 -1
  215. package/build-types/fields/title/view.d.ts +14 -0
  216. package/build-types/fields/title/view.d.ts.map +1 -0
  217. package/build-types/index.d.ts +2 -1
  218. package/build-types/index.d.ts.map +1 -1
  219. package/build-types/index.native.d.ts +0 -2
  220. package/build-types/index.native.d.ts.map +1 -1
  221. package/build-types/lock-unlock.d.ts +1 -1
  222. package/build-types/lock-unlock.d.ts.map +1 -1
  223. package/build-types/types.d.ts +3 -0
  224. package/build-types/types.d.ts.map +1 -1
  225. package/package.json +24 -23
  226. package/src/actions/delete-post.tsx +3 -0
  227. package/src/actions/duplicate-pattern.tsx +3 -0
  228. package/src/actions/duplicate-post.tsx +6 -3
  229. package/src/actions/duplicate-template-part.tsx +74 -0
  230. package/src/actions/export-pattern.tsx +3 -0
  231. package/src/actions/index.ts +1 -3
  232. package/src/actions/permanently-delete-post.tsx +3 -0
  233. package/src/actions/rename-post.tsx +6 -6
  234. package/src/actions/reorder-page.tsx +3 -0
  235. package/src/actions/reset-post.tsx +7 -9
  236. package/src/actions/restore-post.tsx +3 -0
  237. package/src/actions/trash-post.tsx +3 -0
  238. package/src/actions/utils.ts +7 -15
  239. package/src/actions/view-post-revisions.tsx +3 -0
  240. package/src/actions/view-post.tsx +3 -0
  241. package/src/components/create-template-part-modal/index.tsx +274 -0
  242. package/src/components/create-template-part-modal/style.scss +63 -0
  243. package/src/components/create-template-part-modal/test/utils.js +60 -0
  244. package/src/components/create-template-part-modal/utils.js +68 -0
  245. package/src/fields/featured-image/index.ts +3 -0
  246. package/src/fields/index.ts +4 -0
  247. package/src/fields/order/index.ts +3 -0
  248. package/src/fields/page-title/index.ts +28 -0
  249. package/src/fields/page-title/style.scss +10 -0
  250. package/src/fields/page-title/view.tsx +38 -0
  251. package/src/fields/parent/index.ts +1 -1
  252. package/src/fields/password/index.tsx +1 -1
  253. package/src/fields/pattern-title/index.ts +28 -0
  254. package/src/fields/pattern-title/style.scss +3 -0
  255. package/src/fields/pattern-title/view.tsx +32 -0
  256. package/src/fields/slug/index.ts +3 -0
  257. package/src/fields/slug/slug-view.tsx +1 -1
  258. package/src/fields/slug/utils.ts +4 -0
  259. package/src/fields/template/index.ts +24 -0
  260. package/src/fields/template/style.scss +23 -0
  261. package/src/fields/template/template-edit.tsx +210 -0
  262. package/src/fields/template-title/index.ts +28 -0
  263. package/src/fields/title/index.ts +9 -3
  264. package/src/fields/title/style.scss +8 -0
  265. package/src/fields/title/view.tsx +43 -0
  266. package/src/index.native.ts +0 -2
  267. package/src/index.ts +2 -1
  268. package/src/style.scss +5 -0
  269. package/src/types.ts +3 -0
  270. package/tsconfig.json +2 -0
  271. package/tsconfig.tsbuildinfo +1 -1
  272. package/build/actions/duplicate-post.native.js +0 -9
  273. package/build/actions/duplicate-post.native.js.map +0 -1
  274. package/build/actions/export-pattern.native.js +0 -9
  275. package/build/actions/export-pattern.native.js.map +0 -1
  276. package/build/actions/reorder-page.native.js +0 -9
  277. package/build/actions/reorder-page.native.js.map +0 -1
  278. package/build/fields/title/title-view.js +0 -61
  279. package/build/fields/title/title-view.js.map +0 -1
  280. package/build-module/actions/duplicate-post.native.js +0 -3
  281. package/build-module/actions/duplicate-post.native.js.map +0 -1
  282. package/build-module/actions/export-pattern.native.js +0 -3
  283. package/build-module/actions/export-pattern.native.js.map +0 -1
  284. package/build-module/actions/reorder-page.native.js +0 -3
  285. package/build-module/actions/reorder-page.native.js.map +0 -1
  286. package/build-module/fields/title/title-view.js +0 -55
  287. package/build-module/fields/title/title-view.js.map +0 -1
  288. package/build-types/actions/duplicate-post.native.d.ts +0 -3
  289. package/build-types/actions/duplicate-post.native.d.ts.map +0 -1
  290. package/build-types/actions/export-pattern.native.d.ts +0 -3
  291. package/build-types/actions/export-pattern.native.d.ts.map +0 -1
  292. package/build-types/actions/reorder-page.native.d.ts +0 -3
  293. package/build-types/actions/reorder-page.native.d.ts.map +0 -1
  294. package/build-types/fields/title/title-view.d.ts +0 -9
  295. package/build-types/fields/title/title-view.d.ts.map +0 -1
  296. package/src/actions/duplicate-post.native.tsx +0 -3
  297. package/src/actions/export-pattern.native.tsx +0 -3
  298. package/src/actions/reorder-page.native.tsx +0 -3
  299. package/src/fields/title/title-view.tsx +0 -62
@@ -0,0 +1,55 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { paramCase as kebabCase } from 'change-case';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useSelect } from '@wordpress/data';
10
+ import { store as coreStore } from '@wordpress/core-data';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ export const useExistingTemplateParts = () => {
17
+ var _useSelect;
18
+ return (_useSelect = useSelect(select => select(coreStore).getEntityRecords('postType', 'wp_template_part', {
19
+ per_page: -1
20
+ }), [])) !== null && _useSelect !== void 0 ? _useSelect : [];
21
+ };
22
+
23
+ /**
24
+ * Return a unique template part title based on
25
+ * the given title and existing template parts.
26
+ *
27
+ * @param {string} title The original template part title.
28
+ * @param {Object} templateParts The array of template part entities.
29
+ * @return {string} A unique template part title.
30
+ */
31
+ export const getUniqueTemplatePartTitle = (title, templateParts) => {
32
+ const lowercaseTitle = title.toLowerCase();
33
+ const existingTitles = templateParts.map(templatePart => templatePart.title.rendered.toLowerCase());
34
+ if (!existingTitles.includes(lowercaseTitle)) {
35
+ return title;
36
+ }
37
+ let suffix = 2;
38
+ while (existingTitles.includes(`${lowercaseTitle} ${suffix}`)) {
39
+ suffix++;
40
+ }
41
+ return `${title} ${suffix}`;
42
+ };
43
+
44
+ /**
45
+ * Get a valid slug for a template part.
46
+ * Currently template parts only allow latin chars.
47
+ * The fallback slug will receive suffix by default.
48
+ *
49
+ * @param {string} title The template part title.
50
+ * @return {string} A valid template part slug.
51
+ */
52
+ export const getCleanTemplatePartSlug = title => {
53
+ return kebabCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
54
+ };
55
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +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":[]}
@@ -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,7 +1,11 @@
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';
8
+ export { default as templateField } from './template';
5
9
  export { default as parentField } from './parent';
6
10
  export { default as passwordField } from './password';
7
11
  export { default as statusField } from './status';
@@ -1 +1 @@
1
- {"version":3,"names":["default","slugField","titleField","orderField","featuredImageField","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 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,WAAW,QAAQ,UAAU;AACjD,SAASL,OAAO,IAAIM,aAAa,QAAQ,YAAY;AACrD,SAASN,OAAO,IAAIO,WAAW,QAAQ,UAAU;AACjD,SAASP,OAAO,IAAIQ,kBAAkB,QAAQ,kBAAkB;AAChE,SAASR,OAAO,IAAIS,SAAS,QAAQ,QAAQ;AAC7C,SAAST,OAAO,IAAIU,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":[]}
@@ -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":[]}
@@ -11,7 +11,7 @@ import { getSlug } from './utils';
11
11
  const SlugView = ({
12
12
  item
13
13
  }) => {
14
- const slug = typeof item === 'object' ? getSlug(item) : '';
14
+ const slug = getSlug(item);
15
15
  const originalSlugRef = useRef(slug);
16
16
  useEffect(() => {
17
17
  if (slug && originalSlugRef.current === undefined) {
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","getSlug","SlugView","item","slug","originalSlugRef","current","undefined","slugToDisplay"],"sources":["@wordpress/fields/src/fields/slug/slug-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getSlug } from './utils';\n\nconst SlugView = ( { item }: { item: BasePost } ) => {\n\tconst slug = typeof item === 'object' ? getSlug( item ) : '';\n\tconst originalSlugRef = useRef( slug );\n\n\tuseEffect( () => {\n\t\tif ( slug && originalSlugRef.current === undefined ) {\n\t\t\toriginalSlugRef.current = slug;\n\t\t}\n\t}, [ slug ] );\n\n\tconst slugToDisplay = slug || originalSlugRef.current;\n\n\treturn `${ slugToDisplay }`;\n};\n\nexport default SlugView;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAEtD;AACA;AACA;;AAEA,SAASC,OAAO,QAAQ,SAAS;AAEjC,MAAMC,QAAQ,GAAGA,CAAE;EAAEC;AAAyB,CAAC,KAAM;EACpD,MAAMC,IAAI,GAAG,OAAOD,IAAI,KAAK,QAAQ,GAAGF,OAAO,CAAEE,IAAK,CAAC,GAAG,EAAE;EAC5D,MAAME,eAAe,GAAGL,MAAM,CAAEI,IAAK,CAAC;EAEtCL,SAAS,CAAE,MAAM;IAChB,IAAKK,IAAI,IAAIC,eAAe,CAACC,OAAO,KAAKC,SAAS,EAAG;MACpDF,eAAe,CAACC,OAAO,GAAGF,IAAI;IAC/B;EACD,CAAC,EAAE,CAAEA,IAAI,CAAG,CAAC;EAEb,MAAMI,aAAa,GAAGJ,IAAI,IAAIC,eAAe,CAACC,OAAO;EAErD,OAAO,GAAIE,aAAa,EAAG;AAC5B,CAAC;AAED,eAAeN,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["useEffect","useRef","getSlug","SlugView","item","slug","originalSlugRef","current","undefined","slugToDisplay"],"sources":["@wordpress/fields/src/fields/slug/slug-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getSlug } from './utils';\n\nconst SlugView = ( { item }: { item: BasePost } ) => {\n\tconst slug = getSlug( item );\n\tconst originalSlugRef = useRef( slug );\n\n\tuseEffect( () => {\n\t\tif ( slug && originalSlugRef.current === undefined ) {\n\t\t\toriginalSlugRef.current = slug;\n\t\t}\n\t}, [ slug ] );\n\n\tconst slugToDisplay = slug || originalSlugRef.current;\n\n\treturn `${ slugToDisplay }`;\n};\n\nexport default SlugView;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAEtD;AACA;AACA;;AAEA,SAASC,OAAO,QAAQ,SAAS;AAEjC,MAAMC,QAAQ,GAAGA,CAAE;EAAEC;AAAyB,CAAC,KAAM;EACpD,MAAMC,IAAI,GAAGH,OAAO,CAAEE,IAAK,CAAC;EAC5B,MAAME,eAAe,GAAGL,MAAM,CAAEI,IAAK,CAAC;EAEtCL,SAAS,CAAE,MAAM;IAChB,IAAKK,IAAI,IAAIC,eAAe,CAACC,OAAO,KAAKC,SAAS,EAAG;MACpDF,eAAe,CAACC,OAAO,GAAGF,IAAI;IAC/B;EACD,CAAC,EAAE,CAAEA,IAAI,CAAG,CAAC;EAEb,MAAMI,aAAa,GAAGJ,IAAI,IAAIC,eAAe,CAACC,OAAO;EAErD,OAAO,GAAIE,aAAa,EAAG;AAC5B,CAAC;AAED,eAAeN,QAAQ","ignoreList":[]}
@@ -8,6 +8,9 @@ import { cleanForSlug } from '@wordpress/url';
8
8
 
9
9
  import { getItemTitle } from '../../actions/utils';
10
10
  export const getSlug = item => {
11
+ if (typeof item !== 'object') {
12
+ return '';
13
+ }
11
14
  return item.slug || cleanForSlug(getItemTitle(item)) || item.id.toString();
12
15
  };
13
16
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["cleanForSlug","getItemTitle","getSlug","item","slug","id","toString"],"sources":["@wordpress/fields/src/fields/slug/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cleanForSlug } from '@wordpress/url';\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\n\nexport const getSlug = ( item: BasePost ): string => {\n\treturn (\n\t\titem.slug || cleanForSlug( getItemTitle( item ) ) || item.id.toString()\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,qBAAqB;AAElD,OAAO,MAAMC,OAAO,GAAKC,IAAc,IAAc;EACpD,OACCA,IAAI,CAACC,IAAI,IAAIJ,YAAY,CAAEC,YAAY,CAAEE,IAAK,CAAE,CAAC,IAAIA,IAAI,CAACE,EAAE,CAACC,QAAQ,CAAC,CAAC;AAEzE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["cleanForSlug","getItemTitle","getSlug","item","slug","id","toString"],"sources":["@wordpress/fields/src/fields/slug/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cleanForSlug } from '@wordpress/url';\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\n\nexport const getSlug = ( item: BasePost ): string => {\n\tif ( typeof item !== 'object' ) {\n\t\treturn '';\n\t}\n\n\treturn (\n\t\titem.slug || cleanForSlug( getItemTitle( item ) ) || item.id.toString()\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,qBAAqB;AAElD,OAAO,MAAMC,OAAO,GAAKC,IAAc,IAAc;EACpD,IAAK,OAAOA,IAAI,KAAK,QAAQ,EAAG;IAC/B,OAAO,EAAE;EACV;EAEA,OACCA,IAAI,CAACC,IAAI,IAAIJ,YAAY,CAAEC,YAAY,CAAEE,IAAK,CAAE,CAAC,IAAIA,IAAI,CAACE,EAAE,CAACC,QAAQ,CAAC,CAAC;AAEzE,CAAC","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import { __ } from '@wordpress/i18n';
9
+ import { TemplateEdit } from './template-edit';
10
+ const templateField = {
11
+ id: 'template',
12
+ type: 'text',
13
+ label: __('Template'),
14
+ Edit: TemplateEdit,
15
+ enableSorting: false
16
+ };
17
+
18
+ /**
19
+ * Template field for BasePost.
20
+ */
21
+ export default templateField;
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useCallback, useMemo, useState } from '@wordpress/element';
5
+ // @ts-ignore
6
+ import { parse } from '@wordpress/blocks';
7
+ import { store as coreStore } from '@wordpress/core-data';
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ // @ts-expect-error block-editor is not typed correctly.
12
+ import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
13
+ import { Button, Dropdown, MenuGroup, MenuItem, Modal } from '@wordpress/components';
14
+ import { useAsyncList } from '@wordpress/compose';
15
+ import { useSelect } from '@wordpress/data';
16
+ import { decodeEntities } from '@wordpress/html-entities';
17
+ import { __ } from '@wordpress/i18n';
18
+ import { getItemTitle } from '../../actions/utils';
19
+ import { unlock } from '../../lock-unlock';
20
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
21
+ export const TemplateEdit = ({
22
+ data,
23
+ field,
24
+ onChange
25
+ }) => {
26
+ const {
27
+ id
28
+ } = field;
29
+ const postType = data.type;
30
+ const postId = typeof data.id === 'number' ? data.id : parseInt(data.id, 10);
31
+ const slug = data.slug;
32
+ const {
33
+ availableTemplates,
34
+ templates
35
+ } = useSelect(select => {
36
+ var _select$getEntityReco;
37
+ const allTemplates = (_select$getEntityReco = select(coreStore).getEntityRecords('postType', 'wp_template', {
38
+ per_page: -1,
39
+ post_type: postType
40
+ })) !== null && _select$getEntityReco !== void 0 ? _select$getEntityReco : [];
41
+ const {
42
+ getHomePage,
43
+ getPostsPageId
44
+ } = unlock(select(coreStore));
45
+ const isPostsPage = getPostsPageId() === +postId;
46
+ const isFrontPage = postType === 'page' && getHomePage()?.postId === +postId;
47
+ const allowSwitchingTemplate = !isPostsPage && !isFrontPage;
48
+ return {
49
+ templates: allTemplates,
50
+ availableTemplates: allowSwitchingTemplate ? allTemplates.filter(template => template.is_custom && template.slug !== data.template && !!template.content.raw // Skip empty templates.
51
+ ) : []
52
+ };
53
+ }, [data.template, postId, postType]);
54
+ const templatesAsPatterns = useMemo(() => availableTemplates.map(template => ({
55
+ name: template.slug,
56
+ blocks: parse(template.content.raw),
57
+ title: decodeEntities(template.title.rendered),
58
+ id: template.id
59
+ })), [availableTemplates]);
60
+ const shownTemplates = useAsyncList(templatesAsPatterns);
61
+ const value = field.getValue({
62
+ item: data
63
+ });
64
+ const currentTemplate = useSelect(select => {
65
+ const foundTemplate = templates?.find(template => template.slug === value);
66
+ if (foundTemplate) {
67
+ return foundTemplate;
68
+ }
69
+ let slugToCheck;
70
+ // In `draft` status we might not have a slug available, so we use the `single`
71
+ // post type templates slug(ex page, single-post, single-product etc..).
72
+ // Pages do not need the `single` prefix in the slug to be prioritized
73
+ // through template hierarchy.
74
+ if (slug) {
75
+ slugToCheck = postType === 'page' ? `${postType}-${slug}` : `single-${postType}-${slug}`;
76
+ } else {
77
+ slugToCheck = postType === 'page' ? 'page' : `single-${postType}`;
78
+ }
79
+ if (postType) {
80
+ const templateId = select(coreStore).getDefaultTemplateId({
81
+ slug: slugToCheck
82
+ });
83
+ return select(coreStore).getEntityRecord('postType', 'wp_template', templateId);
84
+ }
85
+ }, [postType, slug, templates, value]);
86
+ const [showModal, setShowModal] = useState(false);
87
+ const onChangeControl = useCallback(newValue => onChange({
88
+ [id]: newValue
89
+ }), [id, onChange]);
90
+ return /*#__PURE__*/_jsxs("fieldset", {
91
+ className: "fields-controls__template",
92
+ children: [/*#__PURE__*/_jsx(Dropdown, {
93
+ popoverProps: {
94
+ placement: 'bottom-start'
95
+ },
96
+ renderToggle: ({
97
+ onToggle
98
+ }) => /*#__PURE__*/_jsx(Button, {
99
+ __next40pxDefaultSize: true,
100
+ variant: "tertiary",
101
+ size: "compact",
102
+ onClick: onToggle,
103
+ children: currentTemplate ? getItemTitle(currentTemplate) : ''
104
+ }),
105
+ renderContent: ({
106
+ onToggle
107
+ }) => /*#__PURE__*/_jsxs(MenuGroup, {
108
+ children: [/*#__PURE__*/_jsx(MenuItem, {
109
+ onClick: () => {
110
+ setShowModal(true);
111
+ onToggle();
112
+ },
113
+ children: __('Swap template')
114
+ }),
115
+ // The default template in a post is indicated by an empty string
116
+ value !== '' && /*#__PURE__*/_jsx(MenuItem, {
117
+ onClick: () => {
118
+ onChangeControl('');
119
+ onToggle();
120
+ },
121
+ children: __('Use default template')
122
+ })]
123
+ })
124
+ }), showModal && /*#__PURE__*/_jsx(Modal, {
125
+ title: __('Choose a template'),
126
+ onRequestClose: () => setShowModal(false),
127
+ overlayClassName: "fields-controls__template-modal",
128
+ isFullScreen: true,
129
+ children: /*#__PURE__*/_jsx("div", {
130
+ className: "fields-controls__template-content",
131
+ children: /*#__PURE__*/_jsx(BlockPatternsList, {
132
+ label: __('Templates'),
133
+ blockPatterns: templatesAsPatterns,
134
+ shownPatterns: shownTemplates,
135
+ onClickPattern: template => {
136
+ onChangeControl(template.name);
137
+ setShowModal(false);
138
+ }
139
+ })
140
+ })
141
+ })]
142
+ });
143
+ };
144
+ //# sourceMappingURL=template-edit.js.map
@@ -0,0 +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>\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,CAACG,EAAE,KAAK,QAAQ,GAAGH,IAAI,CAACG,EAAE,GAAGI,QAAQ,CAAEP,IAAI,CAACG,EAAE,EAAE,EAAG,CAAC;EAChE,MAAMK,IAAI,GAAGR,IAAI,CAACQ,IAAI;EAEtB,MAAM;IAAEC,kBAAkB;IAAEC;EAAU,CAAC,GAAGpB,SAAS,CAChDqB,MAAM,IAAM;IAAA,IAAAC,qBAAA;IACb,MAAMC,YAAY,IAAAD,qBAAA,GACjBD,MAAM,CAAE9B,SAAU,CAAC,CAACiC,gBAAgB,CACnC,UAAU,EACV,aAAa,EACb;MACCC,QAAQ,EAAE,CAAC,CAAC;MACZC,SAAS,EAAEZ;IACZ,CACD,CAAC,cAAAQ,qBAAA,cAAAA,qBAAA,GAAI,EAAE;IAER,MAAM;MAAEK,WAAW;MAAEC;IAAe,CAAC,GAAGxB,MAAM,CAC7CiB,MAAM,CAAE9B,SAAU,CACnB,CAAC;IAED,MAAMsC,WAAW,GAAGD,cAAc,CAAC,CAAC,KAAK,CAACZ,MAAM;IAChD,MAAMc,WAAW,GAChBhB,QAAQ,KAAK,MAAM,IAAIa,WAAW,CAAC,CAAC,EAAEX,MAAM,KAAK,CAACA,MAAM;IAEzD,MAAMe,sBAAsB,GAAG,CAAEF,WAAW,IAAI,CAAEC,WAAW;IAE7D,OAAO;MACNV,SAAS,EAAEG,YAAY;MACvBJ,kBAAkB,EAAEY,sBAAsB,GACvCR,YAAY,CAACS,MAAM,CACjBC,QAAQ,IACTA,QAAQ,CAACC,SAAS,IAClBD,QAAQ,CAACf,IAAI,KAAKR,IAAI,CAACuB,QAAQ,IAC/B,CAAC,CAAEA,QAAQ,CAACE,OAAO,CAACC,GAAG,CAAC;MACzB,CAAC,GACD;IACJ,CAAC;EACF,CAAC,EACD,CAAE1B,IAAI,CAACuB,QAAQ,EAAEjB,MAAM,EAAEF,QAAQ,CAClC,CAAC;EAED,MAAMuB,mBAAmB,GAAGlD,OAAO,CAClC,MACCgC,kBAAkB,CAACmB,GAAG,CAAIL,QAAQ,KAAQ;IACzCM,IAAI,EAAEN,QAAQ,CAACf,IAAI;IACnBsB,MAAM,EAAEnD,KAAK,CAAE4C,QAAQ,CAACE,OAAO,CAACC,GAAI,CAAC;IACrCK,KAAK,EAAExC,cAAc,CAAEgC,QAAQ,CAACQ,KAAK,CAACC,QAAS,CAAC;IAChD7B,EAAE,EAAEoB,QAAQ,CAACpB;EACd,CAAC,CAAG,CAAC,EACN,CAAEM,kBAAkB,CACrB,CAAC;EAED,MAAMwB,cAAc,GAAG5C,YAAY,CAAEsC,mBAAoB,CAAC;EAE1D,MAAMO,KAAK,GAAGjC,KAAK,CAACkC,QAAQ,CAAE;IAAEC,IAAI,EAAEpC;EAAK,CAAE,CAAC;EAE9C,MAAMqC,eAAe,GAAG/C,SAAS,CAC9BqB,MAAM,IAAM;IACb,MAAM2B,aAAa,GAAG5B,SAAS,EAAE6B,IAAI,CAClChB,QAAQ,IAAMA,QAAQ,CAACf,IAAI,KAAK0B,KACnC,CAAC;IAED,IAAKI,aAAa,EAAG;MACpB,OAAOA,aAAa;IACrB;IAEA,IAAIE,WAAW;IACf;IACA;IACA;IACA;IACA,IAAKhC,IAAI,EAAG;MACXgC,WAAW,GACVpC,QAAQ,KAAK,MAAM,GAChB,GAAIA,QAAQ,IAAMI,IAAI,EAAG,GACzB,UAAWJ,QAAQ,IAAMI,IAAI,EAAG;IACrC,CAAC,MAAM;MACNgC,WAAW,GACVpC,QAAQ,KAAK,MAAM,GAAG,MAAM,GAAG,UAAWA,QAAQ,EAAG;IACvD;IAEA,IAAKA,QAAQ,EAAG;MACf,MAAMqC,UAAU,GAAG9B,MAAM,CAAE9B,SAAU,CAAC,CAAC6D,oBAAoB,CAAE;QAC5DlC,IAAI,EAAEgC;MACP,CAAE,CAAC;MAEH,OAAO7B,MAAM,CAAE9B,SAAU,CAAC,CAAC8D,eAAe,CACzC,UAAU,EACV,aAAa,EACbF,UACD,CAAC;IACF;EACD,CAAC,EACD,CAAErC,QAAQ,EAAEI,IAAI,EAAEE,SAAS,EAAEwB,KAAK,CACnC,CAAC;EAED,MAAM,CAAEU,SAAS,EAAEC,YAAY,CAAE,GAAGnE,QAAQ,CAAE,KAAM,CAAC;EAErD,MAAMoE,eAAe,GAAGtE,WAAW,CAChCuE,QAAgB,IACjB7C,QAAQ,CAAE;IACT,CAAEC,EAAE,GAAI4C;EACT,CAAE,CAAC,EACJ,CAAE5C,EAAE,EAAED,QAAQ,CACf,CAAC;EAED,oBACCJ,KAAA;IAAUkD,SAAS,EAAC,2BAA2B;IAAAC,QAAA,gBAC9CrD,IAAA,CAACX,QAAQ;MACRiE,YAAY,EAAG;QAAEC,SAAS,EAAE;MAAe,CAAG;MAC9CC,YAAY,EAAGA,CAAE;QAAEC;MAAS,CAAC,kBAC5BzD,IAAA,CAACZ,MAAM;QACNsE,qBAAqB;QACrBC,OAAO,EAAC,UAAU;QAClBC,IAAI,EAAC,SAAS;QACdC,OAAO,EAAGJ,QAAU;QAAAJ,QAAA,EAElBZ,eAAe,GACd5C,YAAY,CAAE4C,eAAgB,CAAC,GAC/B;MAAE,CACE,CACN;MACHqB,aAAa,EAAGA,CAAE;QAAEL;MAAS,CAAC,kBAC7BvD,KAAA,CAACZ,SAAS;QAAA+D,QAAA,gBACTrD,IAAA,CAACT,QAAQ;UACRsE,OAAO,EAAGA,CAAA,KAAM;YACfZ,YAAY,CAAE,IAAK,CAAC;YACpBQ,QAAQ,CAAC,CAAC;UACX,CAAG;UAAAJ,QAAA,EAEDzD,EAAE,CAAE,eAAgB;QAAC,CACd,CAAC;QAEV;QACA0C,KAAK,KAAK,EAAE,iBACXtC,IAAA,CAACT,QAAQ;UACRsE,OAAO,EAAGA,CAAA,KAAM;YACfX,eAAe,CAAE,EAAG,CAAC;YACrBO,QAAQ,CAAC,CAAC;UACX,CAAG;UAAAJ,QAAA,EAEDzD,EAAE,CAAE,sBAAuB;QAAC,CACrB,CACV;MAAA,CAEQ;IACT,CACH,CAAC,EACAoD,SAAS,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