@wordpress/fields 0.25.5 → 0.26.1-next.2f1c7c01b.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 (223) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/actions/delete-post.js +5 -3
  3. package/build/actions/delete-post.js.map +1 -1
  4. package/build/actions/duplicate-pattern.js +5 -3
  5. package/build/actions/duplicate-pattern.js.map +1 -1
  6. package/build/actions/duplicate-post.js +4 -2
  7. package/build/actions/duplicate-post.js.map +1 -1
  8. package/build/actions/duplicate-template-part.js +4 -2
  9. package/build/actions/duplicate-template-part.js.map +1 -1
  10. package/build/actions/export-pattern.js +3 -1
  11. package/build/actions/export-pattern.js.map +1 -1
  12. package/build/actions/index.js +2 -0
  13. package/build/actions/index.js.map +1 -1
  14. package/build/actions/permanently-delete-post.js +4 -2
  15. package/build/actions/permanently-delete-post.js.map +1 -1
  16. package/build/actions/rename-post.js +5 -3
  17. package/build/actions/rename-post.js.map +1 -1
  18. package/build/actions/reorder-page.js +4 -2
  19. package/build/actions/reorder-page.js.map +1 -1
  20. package/build/actions/reset-post.js +6 -4
  21. package/build/actions/reset-post.js.map +1 -1
  22. package/build/actions/restore-post.js +3 -1
  23. package/build/actions/restore-post.js.map +1 -1
  24. package/build/actions/trash-post.js +4 -2
  25. package/build/actions/trash-post.js.map +1 -1
  26. package/build/actions/utils.js +2 -0
  27. package/build/actions/utils.js.map +1 -1
  28. package/build/actions/view-post-revisions.js +3 -1
  29. package/build/actions/view-post-revisions.js.map +1 -1
  30. package/build/actions/view-post.js +3 -1
  31. package/build/actions/view-post.js.map +1 -1
  32. package/build/components/create-template-part-modal/index.js +4 -2
  33. package/build/components/create-template-part-modal/index.js.map +1 -1
  34. package/build/components/create-template-part-modal/utils.js +5 -3
  35. package/build/components/create-template-part-modal/utils.js.map +1 -1
  36. package/build/fields/author/author-view.js +3 -1
  37. package/build/fields/author/author-view.js.map +1 -1
  38. package/build/fields/author/index.js +3 -1
  39. package/build/fields/author/index.js.map +1 -1
  40. package/build/fields/comment-status/index.js +3 -1
  41. package/build/fields/comment-status/index.js.map +1 -1
  42. package/build/fields/date/date-view.js +5 -3
  43. package/build/fields/date/date-view.js.map +1 -1
  44. package/build/fields/date/index.js +3 -1
  45. package/build/fields/date/index.js.map +1 -1
  46. package/build/fields/discussion/index.js +3 -1
  47. package/build/fields/discussion/index.js.map +1 -1
  48. package/build/fields/featured-image/featured-image-edit.js +92 -61
  49. package/build/fields/featured-image/featured-image-edit.js.map +3 -3
  50. package/build/fields/featured-image/featured-image-view.js +3 -1
  51. package/build/fields/featured-image/featured-image-view.js.map +1 -1
  52. package/build/fields/featured-image/index.js +3 -1
  53. package/build/fields/featured-image/index.js.map +1 -1
  54. package/build/fields/index.js +2 -0
  55. package/build/fields/index.js.map +1 -1
  56. package/build/fields/order/index.js +3 -1
  57. package/build/fields/order/index.js.map +1 -1
  58. package/build/fields/page-title/index.js +3 -1
  59. package/build/fields/page-title/index.js.map +1 -1
  60. package/build/fields/page-title/view.js +4 -2
  61. package/build/fields/page-title/view.js.map +1 -1
  62. package/build/fields/parent/index.js +3 -1
  63. package/build/fields/parent/index.js.map +1 -1
  64. package/build/fields/parent/parent-edit.js +5 -3
  65. package/build/fields/parent/parent-edit.js.map +1 -1
  66. package/build/fields/parent/parent-view.js +4 -2
  67. package/build/fields/parent/parent-view.js.map +1 -1
  68. package/build/fields/parent/utils.js +2 -0
  69. package/build/fields/parent/utils.js.map +1 -1
  70. package/build/fields/password/edit.js +3 -1
  71. package/build/fields/password/edit.js.map +1 -1
  72. package/build/fields/password/index.js +3 -1
  73. package/build/fields/password/index.js.map +1 -1
  74. package/build/fields/pattern-title/index.js +3 -1
  75. package/build/fields/pattern-title/index.js.map +1 -1
  76. package/build/fields/pattern-title/view.js +4 -2
  77. package/build/fields/pattern-title/view.js.map +1 -1
  78. package/build/fields/ping-status/index.js +4 -2
  79. package/build/fields/ping-status/index.js.map +1 -1
  80. package/build/fields/slug/index.js +3 -1
  81. package/build/fields/slug/index.js.map +1 -1
  82. package/build/fields/slug/slug-edit.js +4 -2
  83. package/build/fields/slug/slug-edit.js.map +1 -1
  84. package/build/fields/slug/slug-view.js +3 -1
  85. package/build/fields/slug/slug-view.js.map +1 -1
  86. package/build/fields/slug/utils.js +3 -1
  87. package/build/fields/slug/utils.js.map +1 -1
  88. package/build/fields/status/index.js +4 -2
  89. package/build/fields/status/index.js.map +1 -1
  90. package/build/fields/status/status-elements.js +3 -1
  91. package/build/fields/status/status-elements.js.map +1 -1
  92. package/build/fields/status/status-view.js +3 -1
  93. package/build/fields/status/status-view.js.map +1 -1
  94. package/build/fields/template/index.js +3 -1
  95. package/build/fields/template/index.js.map +1 -1
  96. package/build/fields/template/template-edit.js +5 -3
  97. package/build/fields/template/template-edit.js.map +1 -1
  98. package/build/fields/template-title/index.js +3 -1
  99. package/build/fields/template-title/index.js.map +1 -1
  100. package/build/fields/title/index.js +3 -1
  101. package/build/fields/title/index.js.map +1 -1
  102. package/build/fields/title/view.js +3 -1
  103. package/build/fields/title/view.js.map +1 -1
  104. package/build/index.js +2 -0
  105. package/build/index.js.map +1 -1
  106. package/build/lock-unlock.js +3 -1
  107. package/build/lock-unlock.js.map +1 -1
  108. package/build/mutation/index.js +4 -2
  109. package/build/mutation/index.js.map +1 -1
  110. package/build/types.js +2 -0
  111. package/build/types.js.map +1 -1
  112. package/build-module/actions/delete-post.js +4 -3
  113. package/build-module/actions/delete-post.js.map +1 -1
  114. package/build-module/actions/duplicate-pattern.js +4 -3
  115. package/build-module/actions/duplicate-pattern.js.map +1 -1
  116. package/build-module/actions/duplicate-post.js +3 -2
  117. package/build-module/actions/duplicate-post.js.map +1 -1
  118. package/build-module/actions/duplicate-template-part.js +3 -2
  119. package/build-module/actions/duplicate-template-part.js.map +1 -1
  120. package/build-module/actions/export-pattern.js +2 -1
  121. package/build-module/actions/export-pattern.js.map +1 -1
  122. package/build-module/actions/index.js +1 -0
  123. package/build-module/actions/index.js.map +1 -1
  124. package/build-module/actions/permanently-delete-post.js +3 -2
  125. package/build-module/actions/permanently-delete-post.js.map +1 -1
  126. package/build-module/actions/rename-post.js +4 -3
  127. package/build-module/actions/rename-post.js.map +1 -1
  128. package/build-module/actions/reorder-page.js +3 -2
  129. package/build-module/actions/reorder-page.js.map +1 -1
  130. package/build-module/actions/reset-post.js +5 -4
  131. package/build-module/actions/reset-post.js.map +1 -1
  132. package/build-module/actions/restore-post.js +2 -1
  133. package/build-module/actions/restore-post.js.map +1 -1
  134. package/build-module/actions/trash-post.js +3 -2
  135. package/build-module/actions/trash-post.js.map +1 -1
  136. package/build-module/actions/utils.js +1 -0
  137. package/build-module/actions/utils.js.map +1 -1
  138. package/build-module/actions/view-post-revisions.js +2 -1
  139. package/build-module/actions/view-post-revisions.js.map +1 -1
  140. package/build-module/actions/view-post.js +2 -1
  141. package/build-module/actions/view-post.js.map +1 -1
  142. package/build-module/components/create-template-part-modal/index.js +3 -2
  143. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  144. package/build-module/components/create-template-part-modal/utils.js +4 -3
  145. package/build-module/components/create-template-part-modal/utils.js.map +1 -1
  146. package/build-module/fields/author/author-view.js +2 -1
  147. package/build-module/fields/author/author-view.js.map +1 -1
  148. package/build-module/fields/author/index.js +2 -1
  149. package/build-module/fields/author/index.js.map +1 -1
  150. package/build-module/fields/comment-status/index.js +2 -1
  151. package/build-module/fields/comment-status/index.js.map +1 -1
  152. package/build-module/fields/date/date-view.js +4 -3
  153. package/build-module/fields/date/date-view.js.map +1 -1
  154. package/build-module/fields/date/index.js +2 -1
  155. package/build-module/fields/date/index.js.map +1 -1
  156. package/build-module/fields/discussion/index.js +2 -1
  157. package/build-module/fields/discussion/index.js.map +1 -1
  158. package/build-module/fields/featured-image/featured-image-edit.js +96 -63
  159. package/build-module/fields/featured-image/featured-image-edit.js.map +2 -2
  160. package/build-module/fields/featured-image/featured-image-view.js +2 -1
  161. package/build-module/fields/featured-image/featured-image-view.js.map +1 -1
  162. package/build-module/fields/featured-image/index.js +2 -1
  163. package/build-module/fields/featured-image/index.js.map +1 -1
  164. package/build-module/fields/index.js +1 -0
  165. package/build-module/fields/index.js.map +1 -1
  166. package/build-module/fields/order/index.js +2 -1
  167. package/build-module/fields/order/index.js.map +1 -1
  168. package/build-module/fields/page-title/index.js +2 -1
  169. package/build-module/fields/page-title/index.js.map +1 -1
  170. package/build-module/fields/page-title/view.js +3 -2
  171. package/build-module/fields/page-title/view.js.map +1 -1
  172. package/build-module/fields/parent/index.js +2 -1
  173. package/build-module/fields/parent/index.js.map +1 -1
  174. package/build-module/fields/parent/parent-edit.js +4 -3
  175. package/build-module/fields/parent/parent-edit.js.map +1 -1
  176. package/build-module/fields/parent/parent-view.js +3 -2
  177. package/build-module/fields/parent/parent-view.js.map +1 -1
  178. package/build-module/fields/parent/utils.js +1 -0
  179. package/build-module/fields/parent/utils.js.map +1 -1
  180. package/build-module/fields/password/edit.js +2 -1
  181. package/build-module/fields/password/edit.js.map +1 -1
  182. package/build-module/fields/password/index.js +2 -1
  183. package/build-module/fields/password/index.js.map +1 -1
  184. package/build-module/fields/pattern-title/index.js +2 -1
  185. package/build-module/fields/pattern-title/index.js.map +1 -1
  186. package/build-module/fields/pattern-title/view.js +3 -2
  187. package/build-module/fields/pattern-title/view.js.map +1 -1
  188. package/build-module/fields/ping-status/index.js +3 -2
  189. package/build-module/fields/ping-status/index.js.map +1 -1
  190. package/build-module/fields/slug/index.js +2 -1
  191. package/build-module/fields/slug/index.js.map +1 -1
  192. package/build-module/fields/slug/slug-edit.js +3 -2
  193. package/build-module/fields/slug/slug-edit.js.map +1 -1
  194. package/build-module/fields/slug/slug-view.js +2 -1
  195. package/build-module/fields/slug/slug-view.js.map +1 -1
  196. package/build-module/fields/slug/utils.js +2 -1
  197. package/build-module/fields/slug/utils.js.map +1 -1
  198. package/build-module/fields/status/index.js +3 -2
  199. package/build-module/fields/status/index.js.map +1 -1
  200. package/build-module/fields/status/status-elements.js +2 -1
  201. package/build-module/fields/status/status-elements.js.map +1 -1
  202. package/build-module/fields/status/status-view.js +2 -1
  203. package/build-module/fields/status/status-view.js.map +1 -1
  204. package/build-module/fields/template/index.js +2 -1
  205. package/build-module/fields/template/index.js.map +1 -1
  206. package/build-module/fields/template/template-edit.js +4 -3
  207. package/build-module/fields/template/template-edit.js.map +1 -1
  208. package/build-module/fields/template-title/index.js +2 -1
  209. package/build-module/fields/template-title/index.js.map +1 -1
  210. package/build-module/fields/title/index.js +2 -1
  211. package/build-module/fields/title/index.js.map +1 -1
  212. package/build-module/fields/title/view.js +2 -1
  213. package/build-module/fields/title/view.js.map +1 -1
  214. package/build-module/index.js +1 -0
  215. package/build-module/index.js.map +1 -1
  216. package/build-module/lock-unlock.js +2 -1
  217. package/build-module/lock-unlock.js.map +1 -1
  218. package/build-module/mutation/index.js +3 -2
  219. package/build-module/mutation/index.js.map +1 -1
  220. package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -1
  221. package/package.json +26 -26
  222. package/src/fields/featured-image/featured-image-edit.tsx +113 -66
  223. package/tsconfig.tsbuildinfo +1 -1
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/status/index.tsx"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport StatusView from './status-view';\nimport STATUSES from './status-elements';\n\nconst OPERATOR_IS_ANY = 'isAny';\n\nconst statusField: Field< BasePost > = {\n\tlabel: __( 'Status' ),\n\tid: 'status',\n\ttype: 'text',\n\telements: STATUSES,\n\trender: StatusView,\n\tEdit: 'radio',\n\tenableSorting: false,\n\tfilterBy: {\n\t\toperators: [ OPERATOR_IS_ANY ],\n\t},\n};\n\n/**\n * Status field for BasePost.\n */\nexport default statusField;\n"],
5
- "mappings": "AAIA,SAAS,UAAU;AAMnB,OAAO,gBAAgB;AACvB,OAAO,cAAc;AAErB,MAAM,kBAAkB;AAExB,MAAM,cAAiC;AAAA,EACtC,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,eAAe;AAAA,EACf,UAAU;AAAA,IACT,WAAW,CAAE,eAAgB;AAAA,EAC9B;AACD;AAKA,IAAO,iBAAQ;",
5
+ "mappings": ";AAIA,SAAS,UAAU;AAMnB,OAAO,gBAAgB;AACvB,OAAO,cAAc;AAErB,IAAM,kBAAkB;AAExB,IAAM,cAAiC;AAAA,EACtC,OAAO,GAAI,QAAS;AAAA,EACpB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,eAAe;AAAA,EACf,UAAU;AAAA,IACT,WAAW,CAAE,eAAgB;AAAA,EAC9B;AACD;AAKA,IAAO,iBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ // packages/fields/src/fields/status/status-elements.tsx
1
2
  import {
2
3
  trash,
3
4
  drafts,
@@ -7,7 +8,7 @@ import {
7
8
  notAllowed
8
9
  } from "@wordpress/icons";
9
10
  import { __ } from "@wordpress/i18n";
10
- const STATUSES = [
11
+ var STATUSES = [
11
12
  {
12
13
  value: "draft",
13
14
  label: __("Draft"),
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/status/status-elements.tsx"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\ttrash,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n// See https://github.com/WordPress/gutenberg/issues/55886\n// We do not support custom statutes at the moment.\nconst STATUSES = [\n\t{\n\t\tvalue: 'draft',\n\t\tlabel: __( 'Draft' ),\n\t\ticon: drafts,\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tvalue: 'future',\n\t\tlabel: __( 'Scheduled' ),\n\t\ticon: scheduled,\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tvalue: 'pending',\n\t\tlabel: __( 'Pending Review' ),\n\t\ticon: pending,\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tvalue: 'private',\n\t\tlabel: __( 'Private' ),\n\t\ticon: notAllowed,\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tvalue: 'publish',\n\t\tlabel: __( 'Published' ),\n\t\ticon: published,\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n\t{ value: 'trash', label: __( 'Trash' ), icon: trash },\n];\n\nexport default STATUSES;\n"],
5
- "mappings": "AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AAInB,MAAM,WAAW;AAAA,EAChB;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,OAAQ;AAAA,IACnB,MAAM;AAAA,IACN,aAAa,GAAI,uBAAwB;AAAA,EAC1C;AAAA,EACA;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,WAAY;AAAA,IACvB,MAAM;AAAA,IACN,aAAa,GAAI,yCAA0C;AAAA,EAC5D;AAAA,EACA;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,gBAAiB;AAAA,IAC5B,MAAM;AAAA,IACN,aAAa,GAAI,uCAAwC;AAAA,EAC1D;AAAA,EACA;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,SAAU;AAAA,IACrB,MAAM;AAAA,IACN,aAAa,GAAI,0CAA2C;AAAA,EAC7D;AAAA,EACA;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,WAAY;AAAA,IACvB,MAAM;AAAA,IACN,aAAa,GAAI,sBAAuB;AAAA,EACzC;AAAA,EACA,EAAE,OAAO,SAAS,OAAO,GAAI,OAAQ,GAAG,MAAM,MAAM;AACrD;AAEA,IAAO,0BAAQ;",
5
+ "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AAInB,IAAM,WAAW;AAAA,EAChB;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,OAAQ;AAAA,IACnB,MAAM;AAAA,IACN,aAAa,GAAI,uBAAwB;AAAA,EAC1C;AAAA,EACA;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,WAAY;AAAA,IACvB,MAAM;AAAA,IACN,aAAa,GAAI,yCAA0C;AAAA,EAC5D;AAAA,EACA;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,gBAAiB;AAAA,IAC5B,MAAM;AAAA,IACN,aAAa,GAAI,uCAAwC;AAAA,EAC1D;AAAA,EACA;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,SAAU;AAAA,IACrB,MAAM;AAAA,IACN,aAAa,GAAI,0CAA2C;AAAA,EAC7D;AAAA,EACA;AAAA,IACC,OAAO;AAAA,IACP,OAAO,GAAI,WAAY;AAAA,IACvB,MAAM;AAAA,IACN,aAAa,GAAI,sBAAuB;AAAA,EACzC;AAAA,EACA,EAAE,OAAO,SAAS,OAAO,GAAI,OAAQ,GAAG,MAAM,MAAM;AACrD;AAEA,IAAO,0BAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,7 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ // packages/fields/src/fields/status/status-view.tsx
2
2
  import { __experimentalHStack as HStack, Icon } from "@wordpress/components";
3
3
  import STATUSES from "./status-elements";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
4
5
  function StatusView({ item }) {
5
6
  const status = STATUSES.find(({ value }) => value === item.status);
6
7
  const label = status?.label || item.status;
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/status/status-view.tsx"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport STATUSES from './status-elements';\n\nfunction StatusView( { item }: { item: BasePost } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default StatusView;\n"],
5
- "mappings": "AAgBE,SAGG,KAHH;AAbF,SAAS,wBAAwB,QAAQ,YAAY;AAMrD,OAAO,cAAc;AAErB,SAAS,WAAY,EAAE,KAAK,GAAwB;AACnD,QAAM,SAAS,SAAS,KAAM,CAAE,EAAE,MAAM,MAAO,UAAU,KAAK,MAAO;AACrE,QAAM,QAAQ,QAAQ,SAAS,KAAK;AACpC,QAAM,OAAO,QAAQ;AACrB,SACC,qBAAC,UAAO,WAAU,QAAO,SAAU,GAChC;AAAA,YACD,oBAAC,SAAI,WAAU,oCACd,8BAAC,QAAK,MAAc,GACrB;AAAA,IAED,oBAAC,UAAO,iBAAO;AAAA,KAChB;AAEF;AAEA,IAAO,sBAAQ;",
5
+ "mappings": ";AAGA,SAAS,wBAAwB,QAAQ,YAAY;AAMrD,OAAO,cAAc;AAOnB,SAGG,KAHH;AALF,SAAS,WAAY,EAAE,KAAK,GAAwB;AACnD,QAAM,SAAS,SAAS,KAAM,CAAE,EAAE,MAAM,MAAO,UAAU,KAAK,MAAO;AACrE,QAAM,QAAQ,QAAQ,SAAS,KAAK;AACpC,QAAM,OAAO,QAAQ;AACrB,SACC,qBAAC,UAAO,WAAU,QAAO,SAAU,GAChC;AAAA,YACD,oBAAC,SAAI,WAAU,oCACd,8BAAC,QAAK,MAAc,GACrB;AAAA,IAED,oBAAC,UAAO,iBAAO;AAAA,KAChB;AAEF;AAEA,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,7 @@
1
+ // packages/fields/src/fields/template/index.ts
1
2
  import { __ } from "@wordpress/i18n";
2
3
  import { TemplateEdit } from "./template-edit";
3
- const templateField = {
4
+ var templateField = {
4
5
  id: "template",
5
6
  type: "text",
6
7
  label: __("Template"),
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/template/index.ts"],
4
4
  "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\tfilterBy: false,\n};\n\n/**\n * Template field for BasePost.\n */\nexport default templateField;\n"],
5
- "mappings": "AAQA,SAAS,UAAU;AAEnB,SAAS,oBAAoB;AAE7B,MAAM,gBAAmC;AAAA,EACxC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,UAAW;AAAA,EACtB,MAAM;AAAA,EACN,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,mBAAQ;",
5
+ "mappings": ";AAQA,SAAS,UAAU;AAEnB,SAAS,oBAAoB;AAE7B,IAAM,gBAAmC;AAAA,EACxC,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,GAAI,UAAW;AAAA,EACtB,MAAM;AAAA,EACN,eAAe;AAAA,EACf,UAAU;AACX;AAKA,IAAO,mBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ // packages/fields/src/fields/template/template-edit.tsx
2
2
  import { useCallback, useMemo, useState } from "@wordpress/element";
3
3
  import { parse } from "@wordpress/blocks";
4
4
  import { store as coreStore } from "@wordpress/core-data";
@@ -16,8 +16,9 @@ import { decodeEntities } from "@wordpress/html-entities";
16
16
  import { __ } from "@wordpress/i18n";
17
17
  import { getItemTitle } from "../../actions/utils";
18
18
  import { unlock } from "../../lock-unlock";
19
- const EMPTY_ARRAY = [];
20
- const TemplateEdit = ({
19
+ import { jsx, jsxs } from "react/jsx-runtime";
20
+ var EMPTY_ARRAY = [];
21
+ var TemplateEdit = ({
21
22
  data,
22
23
  field,
23
24
  onChange
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/template/template-edit.tsx"],
4
4
  "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\nconst EMPTY_ARRAY: [] = [];\n\nexport const TemplateEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\tconst postType = data.type;\n\tconst postId =\n\t\ttypeof data.id === 'number' ? data.id : parseInt( data.id, 10 );\n\tconst slug = data.slug;\n\n\tconst { canSwitchTemplate, 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) ?? EMPTY_ARRAY;\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\tcanSwitchTemplate: allowSwitchingTemplate,\n\t\t\t};\n\t\t},\n\t\t[ postId, postType ]\n\t);\n\n\tconst templatesAsPatterns = useMemo( () => {\n\t\tif ( ! canSwitchTemplate ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn templates\n\t\t\t.filter(\n\t\t\t\t( template ) =>\n\t\t\t\t\ttemplate.is_custom &&\n\t\t\t\t\ttemplate.slug !== data.template &&\n\t\t\t\t\t// Skip empty templates.\n\t\t\t\t\t!! template.content.raw\n\t\t\t)\n\t\t\t.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}, [ canSwitchTemplate, data.template, templates ] );\n\n\tconst shownTemplates = useAsyncList( templatesAsPatterns );\n\n\tconst value = field.getValue( { item: data } );\n\tconst foundTemplate = templates.find(\n\t\t( template ) => template.slug === value\n\t);\n\n\tconst currentTemplate = useSelect(\n\t\t( select ) => {\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[ foundTemplate, postType, slug ]\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{ __( 'Change 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 );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AA,YACA,uBAAqB;AAAA,YACrB,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,SAAU;AAAA,YAER,4BACC,aAAc,eAAgB,IAC9B;AAAA;AAAA,QACJ;AAAA,QAED,eAAgB,CAAE,EAAE,SAAS,MAC5B,qBAAC,aACA;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,SAAU,MAAM;AACf,6BAAc,IAAK;AACnB,yBAAS;AAAA,cACV;AAAA,cAEE,aAAI,iBAAkB;AAAA;AAAA,UACzB;AAAA;AAAA,UAGC,UAAU,MACT;AAAA,YAAC;AAAA;AAAA,cACA,SAAU,MAAM;AACf,gCAAiB,EAAG;AACpB,yBAAS;AAAA,cACV;AAAA,cAEE,aAAI,sBAAuB;AAAA;AAAA,UAC9B;AAAA,WAGH;AAAA;AAAA,IAEF;AAAA,IACE,aACD;AAAA,MAAC;AAAA;AAAA,QACA,OAAQ,GAAI,mBAAoB;AAAA,QAChC,gBAAiB,MAAM,aAAc,KAAM;AAAA,QAC3C,kBAAiB;AAAA,QACjB,cAAY;AAAA,QAEZ,8BAAC,SAAI,WAAU,qCACd;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ,GAAI,WAAY;AAAA,YACxB,eAAgB;AAAA,YAChB,eAAgB;AAAA,YAChB,gBAAiB,CAChB,aACI;AACJ,8BAAiB,SAAS,IAAK;AAC/B,2BAAc,KAAM;AAAA,YACrB;AAAA;AAAA,QACD,GACD;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
+ // packages/fields/src/fields/template-title/index.ts
1
2
  import { __ } from "@wordpress/i18n";
2
3
  import { getItemTitle } from "../../actions/utils";
3
4
  import TitleView from "../title/view";
4
- const templateTitleField = {
5
+ var templateTitleField = {
5
6
  type: "text",
6
7
  label: __("Template"),
7
8
  placeholder: __("No title"),
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/template-title/index.ts"],
4
4
  "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\tfilterBy: false,\n};\n\n/**\n * Title for the template entity.\n */\nexport default templateTitleField;\n"],
5
- "mappings": "AAIA,SAAS,UAAU;AAMnB,SAAS,oBAAoB;AAC7B,OAAO,eAAe;AAEtB,MAAM,qBAAwC;AAAA,EAC7C,MAAM;AAAA,EACN,OAAO,GAAI,UAAW;AAAA,EACtB,aAAa,GAAI,UAAW;AAAA,EAC5B,IAAI;AAAA,EACJ,UAAU,CAAE,EAAE,KAAK,MAAO,aAAc,IAAK;AAAA,EAC7C,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,UAAU;AACX;AAKA,IAAO,yBAAQ;",
5
+ "mappings": ";AAIA,SAAS,UAAU;AAMnB,SAAS,oBAAoB;AAC7B,OAAO,eAAe;AAEtB,IAAM,qBAAwC;AAAA,EAC7C,MAAM;AAAA,EACN,OAAO,GAAI,UAAW;AAAA,EACtB,aAAa,GAAI,UAAW;AAAA,EAC5B,IAAI;AAAA,EACJ,UAAU,CAAE,EAAE,KAAK,MAAO,aAAc,IAAK;AAAA,EAC7C,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,UAAU;AACX;AAKA,IAAO,yBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
+ // packages/fields/src/fields/title/index.ts
1
2
  import { __ } from "@wordpress/i18n";
2
3
  import { getItemTitle } from "../../actions/utils";
3
4
  import TitleView from "./view";
4
- const titleField = {
5
+ var titleField = {
5
6
  type: "text",
6
7
  id: "title",
7
8
  label: __("Title"),
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/title/index.ts"],
4
4
  "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: true,\n\tenableGlobalSearch: true,\n\tfilterBy: false,\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"],
5
- "mappings": "AAIA,SAAS,UAAU;AAMnB,SAAS,oBAAoB;AAC7B,OAAO,eAAe;AAEtB,MAAM,aAAkC;AAAA,EACvC,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO,GAAI,OAAQ;AAAA,EACnB,aAAa,GAAI,UAAW;AAAA,EAC5B,UAAU,CAAE,EAAE,KAAK,MAAO,aAAc,IAAK;AAAA,EAC7C,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,UAAU;AACX;AAOA,IAAO,gBAAQ;",
5
+ "mappings": ";AAIA,SAAS,UAAU;AAMnB,SAAS,oBAAoB;AAC7B,OAAO,eAAe;AAEtB,IAAM,aAAkC;AAAA,EACvC,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO,GAAI,OAAQ;AAAA,EACnB,aAAa,GAAI,UAAW;AAAA,EAC5B,UAAU,CAAE,EAAE,KAAK,MAAO,aAAc,IAAK;AAAA,EAC7C,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,UAAU;AACX;AAOA,IAAO,gBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,9 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ // packages/fields/src/fields/title/view.tsx
2
2
  import clsx from "clsx";
3
3
  import { __experimentalHStack as HStack } from "@wordpress/components";
4
4
  import { __ } from "@wordpress/i18n";
5
5
  import { getItemTitle } from "../../actions/utils";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
6
7
  function BaseTitleView({
7
8
  item,
8
9
  className,
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/fields/title/view.tsx"],
4
4
  "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { CommonPost } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\n\nexport function BaseTitleView( {\n\titem,\n\tclassName,\n\tchildren,\n}: {\n\titem: CommonPost;\n\tclassName?: string;\n\tchildren?: ReactNode;\n} ) {\n\tconst renderedTitle = getItemTitle( item );\n\treturn (\n\t\t<HStack\n\t\t\tclassName={ clsx( 'fields-field__title', className ) }\n\t\t\talignment=\"center\"\n\t\t\tjustify=\"flex-start\"\n\t\t>\n\t\t\t<span>{ renderedTitle || __( '(no title)' ) }</span>\n\t\t\t{ children }\n\t\t</HStack>\n\t);\n}\n\nexport default function TitleView( { item }: { item: CommonPost } ) {\n\treturn <BaseTitleView item={ item } />;\n}\n"],
5
- "mappings": "AA6BE,SAKC,KALD;AA1BF,OAAO,UAAU;AAMjB,SAAS,wBAAwB,cAAc;AAC/C,SAAS,UAAU;AAMnB,SAAS,oBAAoB;AAEtB,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GAII;AACH,QAAM,gBAAgB,aAAc,IAAK;AACzC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAY,KAAM,uBAAuB,SAAU;AAAA,MACnD,WAAU;AAAA,MACV,SAAQ;AAAA,MAER;AAAA,4BAAC,UAAO,2BAAiB,GAAI,YAAa,GAAG;AAAA,QAC3C;AAAA;AAAA;AAAA,EACH;AAEF;AAEe,SAAR,UAA4B,EAAE,KAAK,GAA0B;AACnE,SAAO,oBAAC,iBAAc,MAAc;AACrC;",
5
+ "mappings": ";AAGA,OAAO,UAAU;AAMjB,SAAS,wBAAwB,cAAc;AAC/C,SAAS,UAAU;AAMnB,SAAS,oBAAoB;AAa3B,SAKC,KALD;AAXK,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACD,GAII;AACH,QAAM,gBAAgB,aAAc,IAAK;AACzC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAY,KAAM,uBAAuB,SAAU;AAAA,MACnD,WAAU;AAAA,MACV,SAAQ;AAAA,MAER;AAAA,4BAAC,UAAO,2BAAiB,GAAI,YAAa,GAAG;AAAA,QAC3C;AAAA;AAAA;AAAA,EACH;AAEF;AAEe,SAAR,UAA4B,EAAE,KAAK,GAA0B;AACnE,SAAO,oBAAC,iBAAc,MAAc;AACrC;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ // packages/fields/src/index.ts
1
2
  export * from "./fields";
2
3
  export * from "./actions";
3
4
  import { default as default2 } from "./components/create-template-part-modal";
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
4
  "sourcesContent": ["export * from './fields';\nexport * from './actions';\nexport { default as CreateTemplatePartModal } from './components/create-template-part-modal';\nexport type { BasePostWithEmbeddedAuthor, BasePost, PostType } from './types';\n"],
5
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,SAAoB,WAAXA,gBAA0C;",
5
+ "mappings": ";AAAA,cAAc;AACd,cAAc;AACd,SAAoB,WAAXA,gBAA0C;",
6
6
  "names": ["default"]
7
7
  }
@@ -1,5 +1,6 @@
1
+ // packages/fields/src/lock-unlock.ts
1
2
  import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
2
- const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
3
+ var { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
3
4
  "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
4
5
  "@wordpress/fields"
5
6
  );
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/lock-unlock.ts"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/fields'\n\t);\n"],
5
- "mappings": "AAGA,SAAS,wDAAwD;AAC1D,MAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
5
+ "mappings": ";AAGA,SAAS,wDAAwD;AAC1D,IAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ // packages/fields/src/mutation/index.ts
1
2
  import { store as noticesStore } from "@wordpress/notices";
2
3
  import { store as coreStore } from "@wordpress/core-data";
3
4
  import { dispatch } from "@wordpress/data";
@@ -21,7 +22,7 @@ function getErrorMessagesFromPromises(allSettledResults) {
21
22
  }
22
23
  return errorMessages;
23
24
  }
24
- const deletePostWithNotices = async (posts, notice, callbacks) => {
25
+ var deletePostWithNotices = async (posts, notice, callbacks) => {
25
26
  const { createSuccessNotice, createErrorNotice } = dispatch(noticesStore);
26
27
  const { deleteEntityRecord } = dispatch(coreStore);
27
28
  const allSettledResults = await Promise.allSettled(
@@ -62,7 +63,7 @@ const deletePostWithNotices = async (posts, notice, callbacks) => {
62
63
  callbacks.onActionError?.();
63
64
  }
64
65
  };
65
- const editPostWithNotices = async (postsWithUpdates, notice, callbacks) => {
66
+ var editPostWithNotices = async (postsWithUpdates, notice, callbacks) => {
66
67
  const { createSuccessNotice, createErrorNotice } = dispatch(noticesStore);
67
68
  const { editEntityRecord, saveEditedEntityRecord } = dispatch(coreStore);
68
69
  await Promise.allSettled(
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/mutation/index.ts"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport type { CoreDataError, Post } from '../types';\n\nfunction getErrorMessagesFromPromises< T >(\n\tallSettledResults: PromiseSettledResult< T >[]\n) {\n\tconst errorMessages = new Set< string >();\n\t// If there was at lease one failure.\n\tif ( allSettledResults.length === 1 ) {\n\t\tconst typedError = allSettledResults[ 0 ] as {\n\t\t\treason?: CoreDataError;\n\t\t};\n\t\tif ( typedError.reason?.message ) {\n\t\t\terrorMessages.add( typedError.reason.message );\n\t\t}\n\t} else {\n\t\tconst failedPromises = allSettledResults.filter(\n\t\t\t( { status } ) => status === 'rejected'\n\t\t);\n\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\tconst typedError = failedPromise as {\n\t\t\t\treason?: CoreDataError;\n\t\t\t};\n\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t}\n\t\t}\n\t}\n\treturn errorMessages;\n}\n\nexport type NoticeSettings< T extends Post > = {\n\tsuccess: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( posts: T ) => string;\n\t\t\tgetBatchMessage: ( posts: T[] ) => string;\n\t\t};\n\t};\n\terror: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( errors: Set< string > ) => string;\n\t\t\tgetBatchMessage: ( errors: Set< string > ) => string;\n\t\t};\n\t};\n};\n\nexport const deletePostWithNotices = async < T extends Post >(\n\tposts: T[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { deleteEntityRecord } = dispatch( coreStore );\n\tconst allSettledResults = await Promise.allSettled(\n\t\tposts.map( ( post ) => {\n\t\t\treturn deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.type,\n\t\t\t\tpost.id,\n\t\t\t\t{ force: true },\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage( posts[ 0 ] );\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage( posts );\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.( posts );\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n\nexport const editPostWithNotices = async < T extends Post >(\n\tpostsWithUpdates: {\n\t\toriginalPost: T;\n\t\tchanges: Partial< T >;\n\t}[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } = dispatch( coreStore );\n\tawait Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\t...post.changes,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\tconst allSettledResults = await Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage(\n\t\t\t\tpostsWithUpdates[ 0 ].originalPost\n\t\t\t);\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage(\n\t\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t\t);\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.(\n\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t);\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n"],
5
- "mappings": "AAGA,SAAS,SAAS,oBAAoB;AACtC,SAAS,SAAS,iBAAiB;AACnC,SAAS,gBAAgB;AAOzB,SAAS,6BACR,mBACC;AACD,QAAM,gBAAgB,oBAAI,IAAc;AAExC,MAAK,kBAAkB,WAAW,GAAI;AACrC,UAAM,aAAa,kBAAmB,CAAE;AAGxC,QAAK,WAAW,QAAQ,SAAU;AACjC,oBAAc,IAAK,WAAW,OAAO,OAAQ;AAAA,IAC9C;AAAA,EACD,OAAO;AACN,UAAM,iBAAiB,kBAAkB;AAAA,MACxC,CAAE,EAAE,OAAO,MAAO,WAAW;AAAA,IAC9B;AACA,eAAY,iBAAiB,gBAAiB;AAC7C,YAAM,aAAa;AAGnB,UAAK,WAAW,QAAQ,SAAU;AACjC,sBAAc,IAAK,WAAW,OAAO,OAAQ;AAAA,MAC9C;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;AAqBO,MAAM,wBAAwB,OACpC,OACA,QACA,cAII;AACJ,QAAM,EAAE,qBAAqB,kBAAkB,IAAI,SAAU,YAAa;AAC1E,QAAM,EAAE,mBAAmB,IAAI,SAAU,SAAU;AACnD,QAAM,oBAAoB,MAAM,QAAQ;AAAA,IACvC,MAAM,IAAK,CAAE,SAAU;AACtB,aAAO;AAAA,QACN;AAAA,QACA,KAAK;AAAA,QACL,KAAK;AAAA,QACL,EAAE,OAAO,KAAK;AAAA,QACd,EAAE,cAAc,KAAK;AAAA,MACtB;AAAA,IACD,CAAE;AAAA,EACH;AAEA,MAAK,kBAAkB,MAAO,CAAE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D,OAAO;AACN,UAAM,gBAAgB,6BAA8B,iBAAkB;AACtE,QAAI,eAAe;AACnB,QAAK,kBAAkB,WAAW,GAAI;AACrC,qBAAe,OAAO,MAAM,SAAS,WAAY,aAAc;AAAA,IAChE,OAAO;AACN,qBACC,OAAO,MAAM,SAAS,gBAAiB,aAAc;AAAA,IACvD;AAEA,sBAAmB,cAAc;AAAA,MAChC,MAAM,OAAO,MAAM,QAAQ;AAAA,MAC3B,IAAI,OAAO,MAAM;AAAA,IAClB,CAAE;AACF,cAAU,gBAAgB;AAAA,EAC3B;AACD;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"featured-image-edit.d.ts","sourceRoot":"","sources":["../../../src/fields/featured-image/featured-image-edit.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGjE;;GAEG;AACH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAErE,eAAO,MAAM,iBAAiB,+BAI3B,oBAAoB,CAAE,iCAAiC,CAAE,gCAoG3D,CAAC"}
1
+ {"version":3,"file":"featured-image-edit.d.ts","sourceRoot":"","sources":["../../../src/fields/featured-image/featured-image-edit.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAGjE;;GAEG;AACH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAyCrE,eAAO,MAAM,iBAAiB,+BAI3B,oBAAoB,CAAE,iCAAiC,CAAE,gCA0G3D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/fields",
3
- "version": "0.25.5",
3
+ "version": "0.26.1-next.2f1c7c01b.0",
4
4
  "description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -39,30 +39,30 @@
39
39
  "src/**/*.scss"
40
40
  ],
41
41
  "dependencies": {
42
- "@wordpress/api-fetch": "^7.33.1",
43
- "@wordpress/base-styles": "^6.9.1",
44
- "@wordpress/blob": "^4.33.1",
45
- "@wordpress/block-editor": "^15.6.3",
46
- "@wordpress/blocks": "^15.6.1",
47
- "@wordpress/components": "^30.6.1",
48
- "@wordpress/compose": "^7.33.1",
49
- "@wordpress/core-data": "^7.33.3",
50
- "@wordpress/data": "^10.33.1",
51
- "@wordpress/dataviews": "^10.1.2",
52
- "@wordpress/date": "^5.33.1",
53
- "@wordpress/element": "^6.33.1",
54
- "@wordpress/hooks": "^4.33.1",
55
- "@wordpress/html-entities": "^4.33.1",
56
- "@wordpress/i18n": "^6.6.1",
57
- "@wordpress/icons": "^11.0.1",
58
- "@wordpress/media-utils": "^5.33.1",
59
- "@wordpress/notices": "^5.33.1",
60
- "@wordpress/patterns": "^2.33.3",
61
- "@wordpress/primitives": "^4.33.1",
62
- "@wordpress/private-apis": "^1.33.1",
63
- "@wordpress/router": "^1.33.1",
64
- "@wordpress/url": "^4.33.1",
65
- "@wordpress/warning": "^3.33.1",
42
+ "@wordpress/api-fetch": "^7.34.1-next.2f1c7c01b.0",
43
+ "@wordpress/base-styles": "^6.10.1-next.2f1c7c01b.0",
44
+ "@wordpress/blob": "^4.34.1-next.2f1c7c01b.0",
45
+ "@wordpress/block-editor": "^15.7.1-next.2f1c7c01b.0",
46
+ "@wordpress/blocks": "^15.7.1-next.2f1c7c01b.0",
47
+ "@wordpress/components": "^30.7.2-next.2f1c7c01b.0",
48
+ "@wordpress/compose": "^7.34.1-next.2f1c7c01b.0",
49
+ "@wordpress/core-data": "^7.34.1-next.2f1c7c01b.0",
50
+ "@wordpress/data": "^10.34.1-next.2f1c7c01b.0",
51
+ "@wordpress/dataviews": "^10.3.1-next.2f1c7c01b.0",
52
+ "@wordpress/date": "^5.34.1-next.2f1c7c01b.0",
53
+ "@wordpress/element": "^6.34.1-next.2f1c7c01b.0",
54
+ "@wordpress/hooks": "^4.34.1-next.2f1c7c01b.0",
55
+ "@wordpress/html-entities": "^4.34.1-next.2f1c7c01b.0",
56
+ "@wordpress/i18n": "^6.7.1-next.2f1c7c01b.0",
57
+ "@wordpress/icons": "^11.1.1-next.2f1c7c01b.0",
58
+ "@wordpress/media-utils": "^5.34.1-next.2f1c7c01b.0",
59
+ "@wordpress/notices": "^5.34.1-next.2f1c7c01b.0",
60
+ "@wordpress/patterns": "^2.34.1-next.2f1c7c01b.0",
61
+ "@wordpress/primitives": "^4.34.1-next.2f1c7c01b.0",
62
+ "@wordpress/private-apis": "^1.34.1-next.2f1c7c01b.0",
63
+ "@wordpress/router": "^1.34.1-next.2f1c7c01b.0",
64
+ "@wordpress/url": "^4.34.1-next.2f1c7c01b.0",
65
+ "@wordpress/warning": "^3.34.1-next.2f1c7c01b.0",
66
66
  "change-case": "4.1.2",
67
67
  "client-zip": "^2.4.5",
68
68
  "clsx": "2.1.1",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "b54bd3285e50e409580bdfa2c47bc81f0000a0c9"
77
+ "gitHead": "c6ddcdf455bc02567a2c9e03de6862a2061b85e8"
78
78
  }
@@ -3,9 +3,11 @@
3
3
  */
4
4
  import { Button, __experimentalGrid as Grid } from '@wordpress/components';
5
5
  import { useSelect } from '@wordpress/data';
6
- import { useCallback, useRef } from '@wordpress/element';
7
- // @ts-ignore
8
- import { MediaUpload } from '@wordpress/media-utils';
6
+ import { useCallback, useRef, useState } from '@wordpress/element';
7
+ import {
8
+ privateApis as mediaUtilsPrivateApis,
9
+ MediaUpload,
10
+ } from '@wordpress/media-utils';
9
11
  import { lineSolid } from '@wordpress/icons';
10
12
  import { store as coreStore } from '@wordpress/core-data';
11
13
  import type { DataFormControlProps } from '@wordpress/dataviews';
@@ -15,6 +17,45 @@ import { __ } from '@wordpress/i18n';
15
17
  * Internal dependencies
16
18
  */
17
19
  import type { BasePostWithEmbeddedFeaturedMedia } from '../../types';
20
+ import { unlock } from '../../lock-unlock';
21
+
22
+ const { MediaUploadModal } = unlock( mediaUtilsPrivateApis );
23
+
24
+ /**
25
+ * Conditional Media component that uses MediaUploadModal when experiment is enabled,
26
+ * otherwise falls back to media-utils MediaUpload.
27
+ *
28
+ * @param {Object} root0 Component props.
29
+ * @param {Function} root0.render Render prop function that receives { open } object.
30
+ * @param {Object} root0.props Other props passed to the media upload component.
31
+ * @return {JSX.Element} The component.
32
+ */
33
+ function ConditionalMediaUpload( { render, ...props }: any ) {
34
+ const [ isModalOpen, setIsModalOpen ] = useState( false );
35
+
36
+ if ( ( window as any ).__experimentalDataViewsMediaModal ) {
37
+ return (
38
+ <>
39
+ { render && render( { open: () => setIsModalOpen( true ) } ) }
40
+ <MediaUploadModal
41
+ { ...props }
42
+ isOpen={ isModalOpen }
43
+ onClose={ () => {
44
+ setIsModalOpen( false );
45
+ props.onClose?.();
46
+ } }
47
+ onSelect={ ( media: any ) => {
48
+ setIsModalOpen( false );
49
+ props.onSelect?.( media );
50
+ } }
51
+ />
52
+ </>
53
+ );
54
+ }
55
+
56
+ // Fallback to media-utils MediaUpload when experiment is disabled
57
+ return <MediaUpload { ...props } render={ render } />;
58
+ }
18
59
 
19
60
  export const FeaturedImageEdit = ( {
20
61
  data,
@@ -48,74 +89,80 @@ export const FeaturedImageEdit = ( {
48
89
  return (
49
90
  <fieldset className="fields-controls__featured-image">
50
91
  <div className="fields-controls__featured-image-container">
51
- <MediaUpload
52
- onSelect={ ( selectedMedia: { id: number } ) => {
92
+ <ConditionalMediaUpload
93
+ onSelect={ ( selectedMedia: any ) => {
53
94
  onChangeControl( selectedMedia.id );
54
95
  } }
55
96
  allowedTypes={ [ 'image' ] }
56
- render={ ( { open }: { open: () => void } ) => {
57
- return (
58
- <div
59
- ref={ ref }
60
- role="button"
61
- tabIndex={ -1 }
62
- onClick={ () => {
97
+ value={ value }
98
+ title={ __( 'Select Featured Image' ) }
99
+ render={ ( { open }: any ) => (
100
+ <div
101
+ ref={ ref }
102
+ role="button"
103
+ tabIndex={ -1 }
104
+ onClick={ open }
105
+ onKeyDown={ ( event ) => {
106
+ if (
107
+ event.key === 'Enter' ||
108
+ event.key === ' '
109
+ ) {
110
+ event.preventDefault();
63
111
  open();
64
- } }
65
- onKeyDown={ open }
112
+ }
113
+ } }
114
+ >
115
+ <Grid
116
+ rowGap={ 0 }
117
+ columnGap={ 8 }
118
+ templateColumns="24px 1fr 24px"
66
119
  >
67
- <Grid
68
- rowGap={ 0 }
69
- columnGap={ 8 }
70
- templateColumns="24px 1fr 24px"
71
- >
72
- { url && (
73
- <>
74
- <img
75
- className="fields-controls__featured-image-image"
76
- alt=""
77
- width={ 24 }
78
- height={ 24 }
79
- src={ url }
80
- />
81
- <span className="fields-controls__featured-image-title">
82
- { title }
83
- </span>
84
- </>
85
- ) }
86
- { ! url && (
87
- <>
88
- <span
89
- className="fields-controls__featured-image-placeholder"
90
- style={ {
91
- width: '24px',
92
- height: '24px',
93
- } }
94
- />
95
- <span className="fields-controls__featured-image-title">
96
- { __( 'Choose an image…' ) }
97
- </span>
98
- </>
99
- ) }
100
- { url && (
101
- <>
102
- <Button
103
- size="small"
104
- className="fields-controls__featured-image-remove-button"
105
- icon={ lineSolid }
106
- onClick={ (
107
- event: React.MouseEvent< HTMLButtonElement >
108
- ) => {
109
- event.stopPropagation();
110
- onChangeControl( 0 );
111
- } }
112
- />
113
- </>
114
- ) }
115
- </Grid>
116
- </div>
117
- );
118
- } }
120
+ { url && (
121
+ <>
122
+ <img
123
+ className="fields-controls__featured-image-image"
124
+ alt=""
125
+ width={ 24 }
126
+ height={ 24 }
127
+ src={ url }
128
+ />
129
+ <span className="fields-controls__featured-image-title">
130
+ { title }
131
+ </span>
132
+ </>
133
+ ) }
134
+ { ! url && (
135
+ <>
136
+ <span
137
+ className="fields-controls__featured-image-placeholder"
138
+ style={ {
139
+ width: '24px',
140
+ height: '24px',
141
+ } }
142
+ />
143
+ <span className="fields-controls__featured-image-title">
144
+ { __( 'Choose an image…' ) }
145
+ </span>
146
+ </>
147
+ ) }
148
+ { url && (
149
+ <>
150
+ <Button
151
+ size="small"
152
+ className="fields-controls__featured-image-remove-button"
153
+ icon={ lineSolid }
154
+ onClick={ (
155
+ event: React.MouseEvent< HTMLButtonElement >
156
+ ) => {
157
+ event.stopPropagation();
158
+ onChangeControl( 0 );
159
+ } }
160
+ />
161
+ </>
162
+ ) }
163
+ </Grid>
164
+ </div>
165
+ ) }
119
166
  />
120
167
  </div>
121
168
  </fieldset>