@wordpress/block-library 7.0.1 → 7.1.0-next.e230fbab09.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 (608) hide show
  1. package/README.md +16 -0
  2. package/build/audio/edit.js +4 -4
  3. package/build/audio/edit.js.map +1 -1
  4. package/build/audio/edit.native.js +4 -4
  5. package/build/audio/edit.native.js.map +1 -1
  6. package/build/audio/transforms.js +1 -1
  7. package/build/audio/transforms.js.map +1 -1
  8. package/build/block/edit.js +3 -9
  9. package/build/block/edit.js.map +1 -1
  10. package/build/button/edit.js +3 -2
  11. package/build/button/edit.js.map +1 -1
  12. package/build/button/edit.native.js +4 -4
  13. package/build/button/edit.native.js.map +1 -1
  14. package/build/buttons/transforms.js +8 -8
  15. package/build/buttons/transforms.js.map +1 -1
  16. package/build/categories/edit.js +15 -26
  17. package/build/categories/edit.js.map +1 -1
  18. package/build/code/index.js +0 -1
  19. package/build/code/index.js.map +1 -1
  20. package/build/columns/columnCalculations.native.js +1 -1
  21. package/build/columns/columnCalculations.native.js.map +1 -1
  22. package/build/columns/edit.js +1 -1
  23. package/build/columns/edit.js.map +1 -1
  24. package/build/columns/edit.native.js +3 -3
  25. package/build/columns/edit.native.js.map +1 -1
  26. package/build/columns/index.js +12 -0
  27. package/build/columns/index.js.map +1 -1
  28. package/build/comment-author-avatar/edit.js +17 -4
  29. package/build/comment-author-avatar/edit.js.map +1 -1
  30. package/build/comment-template/edit.js +94 -36
  31. package/build/comment-template/edit.js.map +1 -1
  32. package/build/comment-template/hooks.js +175 -0
  33. package/build/comment-template/hooks.js.map +1 -0
  34. package/build/comment-template/index.js +1 -1
  35. package/build/comment-template/util.js.map +1 -1
  36. package/build/comments-pagination-next/index.js +1 -1
  37. package/build/comments-pagination-numbers/index.js +1 -1
  38. package/build/comments-query-loop/edit/comments-inspector-controls.js +20 -9
  39. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  40. package/build/comments-query-loop/edit.js +1 -19
  41. package/build/comments-query-loop/edit.js.map +1 -1
  42. package/build/comments-query-loop/index.js +5 -0
  43. package/build/comments-query-loop/index.js.map +1 -1
  44. package/build/cover/controls.native.js +5 -5
  45. package/build/cover/controls.native.js.map +1 -1
  46. package/build/cover/deprecated.js +188 -17
  47. package/build/cover/deprecated.js.map +1 -1
  48. package/build/cover/edit.js +29 -33
  49. package/build/cover/edit.js.map +1 -1
  50. package/build/cover/edit.native.js +15 -13
  51. package/build/cover/edit.native.js.map +1 -1
  52. package/build/cover/overlay-color-settings.native.js +7 -6
  53. package/build/cover/overlay-color-settings.native.js.map +1 -1
  54. package/build/cover/save.js +1 -1
  55. package/build/cover/save.js.map +1 -1
  56. package/build/cover/shared.js +2 -2
  57. package/build/cover/shared.js.map +1 -1
  58. package/build/cover/transforms.js +4 -2
  59. package/build/cover/transforms.js.map +1 -1
  60. package/build/embed/edit.js +1 -1
  61. package/build/embed/edit.js.map +1 -1
  62. package/build/embed/edit.native.js +1 -1
  63. package/build/embed/edit.native.js.map +1 -1
  64. package/build/embed/util.js +2 -2
  65. package/build/embed/util.js.map +1 -1
  66. package/build/embed/variations.js +1 -1
  67. package/build/embed/variations.js.map +1 -1
  68. package/build/file/edit.js +20 -17
  69. package/build/file/edit.js.map +1 -1
  70. package/build/file/edit.native.js +1 -1
  71. package/build/file/edit.native.js.map +1 -1
  72. package/build/file/save.js +7 -3
  73. package/build/file/save.js.map +1 -1
  74. package/build/freeform/edit.js +2 -2
  75. package/build/freeform/edit.js.map +1 -1
  76. package/build/gallery/edit.js +1 -1
  77. package/build/gallery/edit.js.map +1 -1
  78. package/build/gallery/gallery.native.js +1 -1
  79. package/build/gallery/gallery.native.js.map +1 -1
  80. package/build/gallery/v1/edit.js +3 -3
  81. package/build/gallery/v1/edit.js.map +1 -1
  82. package/build/gallery/v1/gallery-image.native.js +3 -3
  83. package/build/gallery/v1/gallery-image.native.js.map +1 -1
  84. package/build/gallery/v1/gallery.native.js +2 -2
  85. package/build/gallery/v1/gallery.native.js.map +1 -1
  86. package/build/group/index.js +4 -37
  87. package/build/group/index.js.map +1 -1
  88. package/build/group/transforms.js +45 -0
  89. package/build/group/transforms.js.map +1 -0
  90. package/build/heading/edit.js +14 -2
  91. package/build/heading/edit.js.map +1 -1
  92. package/build/home-link/edit.js +1 -1
  93. package/build/home-link/edit.js.map +1 -1
  94. package/build/image/deprecated.js +89 -5
  95. package/build/image/deprecated.js.map +1 -1
  96. package/build/image/edit.js +7 -6
  97. package/build/image/edit.js.map +1 -1
  98. package/build/image/edit.native.js +25 -10
  99. package/build/image/edit.native.js.map +1 -1
  100. package/build/image/save.js +0 -7
  101. package/build/image/save.js.map +1 -1
  102. package/build/image/transforms.js +1 -1
  103. package/build/image/transforms.js.map +1 -1
  104. package/build/index.js +3 -4
  105. package/build/index.js.map +1 -1
  106. package/build/index.native.js +2 -2
  107. package/build/index.native.js.map +1 -1
  108. package/build/latest-posts/edit.js +1 -0
  109. package/build/latest-posts/edit.js.map +1 -1
  110. package/build/media-text/edit.js +21 -2
  111. package/build/media-text/edit.js.map +1 -1
  112. package/build/media-text/edit.native.js +2 -2
  113. package/build/media-text/edit.native.js.map +1 -1
  114. package/build/media-text/media-container.native.js +1 -1
  115. package/build/media-text/media-container.native.js.map +1 -1
  116. package/build/missing/edit.native.js +1 -1
  117. package/build/missing/edit.native.js.map +1 -1
  118. package/build/more/transforms.js +2 -2
  119. package/build/more/transforms.js.map +1 -1
  120. package/build/navigation/edit/index.js +144 -68
  121. package/build/navigation/edit/index.js.map +1 -1
  122. package/build/navigation/edit/inner-blocks.js +8 -3
  123. package/build/navigation/edit/inner-blocks.js.map +1 -1
  124. package/build/navigation/edit/navigation-menu-selector.js +82 -52
  125. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  126. package/build/navigation/edit/placeholder/index.js +32 -61
  127. package/build/navigation/edit/placeholder/index.js.map +1 -1
  128. package/build/navigation/edit/placeholder/placeholder-preview.js +3 -12
  129. package/build/navigation/edit/placeholder/placeholder-preview.js.map +1 -1
  130. package/build/navigation/edit/unsaved-inner-blocks.js +3 -1
  131. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  132. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +120 -0
  133. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -0
  134. package/build/navigation/edit/use-create-navigation-menu.js +53 -4
  135. package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
  136. package/build/navigation/edit/use-navigation-notice.js +3 -3
  137. package/build/navigation/edit/use-navigation-notice.js.map +1 -1
  138. package/build/navigation/menu-items-to-blocks.js +1 -1
  139. package/build/navigation/menu-items-to-blocks.js.map +1 -1
  140. package/build/navigation/use-navigation-entities.js +25 -49
  141. package/build/navigation/use-navigation-entities.js.map +1 -1
  142. package/build/navigation/use-navigation-menu.js +8 -6
  143. package/build/navigation/use-navigation-menu.js.map +1 -1
  144. package/build/navigation-link/fallback-variations.js +1 -1
  145. package/build/navigation-link/fallback-variations.js.map +1 -1
  146. package/build/navigation-link/hooks.js +2 -2
  147. package/build/navigation-link/hooks.js.map +1 -1
  148. package/build/navigation-submenu/edit.js +43 -11
  149. package/build/navigation-submenu/edit.js.map +1 -1
  150. package/build/page-list/convert-to-links-modal.js +13 -23
  151. package/build/page-list/convert-to-links-modal.js.map +1 -1
  152. package/build/page-list/edit.js +19 -39
  153. package/build/page-list/edit.js.map +1 -1
  154. package/build/post-author-name/edit.js +2 -1
  155. package/build/post-author-name/edit.js.map +1 -1
  156. package/build/post-comments-form/edit.js +3 -1
  157. package/build/post-comments-form/edit.js.map +1 -1
  158. package/build/post-excerpt/edit.js +7 -4
  159. package/build/post-excerpt/edit.js.map +1 -1
  160. package/build/post-terms/edit.js +3 -1
  161. package/build/post-terms/edit.js.map +1 -1
  162. package/build/query-title/edit.js +0 -1
  163. package/build/query-title/edit.js.map +1 -1
  164. package/build/search/edit.js +4 -1
  165. package/build/search/edit.js.map +1 -1
  166. package/build/search/edit.native.js +1 -1
  167. package/build/search/edit.native.js.map +1 -1
  168. package/build/separator/save.js +4 -4
  169. package/build/separator/save.js.map +1 -1
  170. package/build/separator/separator-settings.native.js +1 -1
  171. package/build/separator/separator-settings.native.js.map +1 -1
  172. package/build/site-logo/edit.js +1 -1
  173. package/build/site-logo/edit.js.map +1 -1
  174. package/build/social-link/edit.native.js +11 -3
  175. package/build/social-link/edit.native.js.map +1 -1
  176. package/build/social-links/deprecated.js +1 -62
  177. package/build/social-links/deprecated.js.map +1 -1
  178. package/build/spacer/controls.js +5 -5
  179. package/build/spacer/controls.js.map +1 -1
  180. package/build/spacer/controls.native.js +5 -5
  181. package/build/spacer/controls.native.js.map +1 -1
  182. package/build/table/edit.js +2 -2
  183. package/build/table/edit.js.map +1 -1
  184. package/build/template-part/edit/index.js +36 -64
  185. package/build/template-part/edit/index.js.map +1 -1
  186. package/build/template-part/edit/placeholder.js +64 -0
  187. package/build/template-part/edit/placeholder.js.map +1 -0
  188. package/build/template-part/edit/selection-modal.js +103 -0
  189. package/build/template-part/edit/selection-modal.js.map +1 -0
  190. package/build/template-part/edit/title-modal.js +54 -0
  191. package/build/template-part/edit/title-modal.js.map +1 -0
  192. package/build/template-part/edit/utils/hooks.js +156 -0
  193. package/build/template-part/edit/utils/hooks.js.map +1 -0
  194. package/build/template-part/index.js +3 -1
  195. package/build/template-part/index.js.map +1 -1
  196. package/build/video/edit.js +4 -4
  197. package/build/video/edit.js.map +1 -1
  198. package/build/video/edit.native.js +3 -3
  199. package/build/video/edit.native.js.map +1 -1
  200. package/build-module/audio/edit.js +4 -4
  201. package/build-module/audio/edit.js.map +1 -1
  202. package/build-module/audio/edit.native.js +4 -4
  203. package/build-module/audio/edit.native.js.map +1 -1
  204. package/build-module/audio/transforms.js +1 -1
  205. package/build-module/audio/transforms.js.map +1 -1
  206. package/build-module/block/edit.js +5 -11
  207. package/build-module/block/edit.js.map +1 -1
  208. package/build-module/button/edit.js +3 -2
  209. package/build-module/button/edit.js.map +1 -1
  210. package/build-module/button/edit.native.js +6 -6
  211. package/build-module/button/edit.native.js.map +1 -1
  212. package/build-module/buttons/transforms.js +8 -8
  213. package/build-module/buttons/transforms.js.map +1 -1
  214. package/build-module/categories/edit.js +15 -25
  215. package/build-module/categories/edit.js.map +1 -1
  216. package/build-module/code/index.js +0 -1
  217. package/build-module/code/index.js.map +1 -1
  218. package/build-module/columns/columnCalculations.native.js +1 -1
  219. package/build-module/columns/columnCalculations.native.js.map +1 -1
  220. package/build-module/columns/edit.js +1 -1
  221. package/build-module/columns/edit.js.map +1 -1
  222. package/build-module/columns/edit.native.js +3 -3
  223. package/build-module/columns/edit.native.js.map +1 -1
  224. package/build-module/columns/index.js +12 -0
  225. package/build-module/columns/index.js.map +1 -1
  226. package/build-module/comment-author-avatar/edit.js +18 -6
  227. package/build-module/comment-author-avatar/edit.js.map +1 -1
  228. package/build-module/comment-template/edit.js +95 -37
  229. package/build-module/comment-template/edit.js.map +1 -1
  230. package/build-module/comment-template/hooks.js +156 -0
  231. package/build-module/comment-template/hooks.js.map +1 -0
  232. package/build-module/comment-template/index.js +1 -1
  233. package/build-module/comment-template/util.js.map +1 -1
  234. package/build-module/comments-pagination-next/index.js +1 -1
  235. package/build-module/comments-pagination-numbers/index.js +1 -1
  236. package/build-module/comments-query-loop/edit/comments-inspector-controls.js +20 -9
  237. package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  238. package/build-module/comments-query-loop/edit.js +2 -19
  239. package/build-module/comments-query-loop/edit.js.map +1 -1
  240. package/build-module/comments-query-loop/index.js +5 -0
  241. package/build-module/comments-query-loop/index.js.map +1 -1
  242. package/build-module/cover/controls.native.js +5 -5
  243. package/build-module/cover/controls.native.js.map +1 -1
  244. package/build-module/cover/deprecated.js +190 -17
  245. package/build-module/cover/deprecated.js.map +1 -1
  246. package/build-module/cover/edit.js +31 -35
  247. package/build-module/cover/edit.js.map +1 -1
  248. package/build-module/cover/edit.native.js +18 -16
  249. package/build-module/cover/edit.native.js.map +1 -1
  250. package/build-module/cover/overlay-color-settings.native.js +7 -7
  251. package/build-module/cover/overlay-color-settings.native.js.map +1 -1
  252. package/build-module/cover/save.js +1 -1
  253. package/build-module/cover/save.js.map +1 -1
  254. package/build-module/cover/shared.js +2 -2
  255. package/build-module/cover/shared.js.map +1 -1
  256. package/build-module/cover/transforms.js +4 -2
  257. package/build-module/cover/transforms.js.map +1 -1
  258. package/build-module/embed/edit.js +1 -1
  259. package/build-module/embed/edit.js.map +1 -1
  260. package/build-module/embed/edit.native.js +1 -1
  261. package/build-module/embed/edit.native.js.map +1 -1
  262. package/build-module/embed/util.js +2 -2
  263. package/build-module/embed/util.js.map +1 -1
  264. package/build-module/embed/variations.js +1 -1
  265. package/build-module/embed/variations.js.map +1 -1
  266. package/build-module/file/edit.js +21 -18
  267. package/build-module/file/edit.js.map +1 -1
  268. package/build-module/file/edit.native.js +1 -1
  269. package/build-module/file/edit.native.js.map +1 -1
  270. package/build-module/file/save.js +7 -3
  271. package/build-module/file/save.js.map +1 -1
  272. package/build-module/freeform/edit.js +2 -2
  273. package/build-module/freeform/edit.js.map +1 -1
  274. package/build-module/gallery/edit.js +1 -1
  275. package/build-module/gallery/edit.js.map +1 -1
  276. package/build-module/gallery/gallery.native.js +1 -1
  277. package/build-module/gallery/gallery.native.js.map +1 -1
  278. package/build-module/gallery/v1/edit.js +3 -3
  279. package/build-module/gallery/v1/edit.js.map +1 -1
  280. package/build-module/gallery/v1/gallery-image.native.js +3 -3
  281. package/build-module/gallery/v1/gallery-image.native.js.map +1 -1
  282. package/build-module/gallery/v1/gallery.native.js +2 -2
  283. package/build-module/gallery/v1/gallery.native.js.map +1 -1
  284. package/build-module/group/index.js +3 -36
  285. package/build-module/group/index.js.map +1 -1
  286. package/build-module/group/transforms.js +36 -0
  287. package/build-module/group/transforms.js.map +1 -0
  288. package/build-module/heading/edit.js +15 -3
  289. package/build-module/heading/edit.js.map +1 -1
  290. package/build-module/home-link/edit.js +1 -1
  291. package/build-module/home-link/edit.js.map +1 -1
  292. package/build-module/image/deprecated.js +90 -7
  293. package/build-module/image/deprecated.js.map +1 -1
  294. package/build-module/image/edit.js +7 -6
  295. package/build-module/image/edit.js.map +1 -1
  296. package/build-module/image/edit.native.js +25 -10
  297. package/build-module/image/edit.native.js.map +1 -1
  298. package/build-module/image/save.js +0 -7
  299. package/build-module/image/save.js.map +1 -1
  300. package/build-module/image/transforms.js +1 -1
  301. package/build-module/image/transforms.js.map +1 -1
  302. package/build-module/index.js +4 -5
  303. package/build-module/index.js.map +1 -1
  304. package/build-module/index.native.js +2 -2
  305. package/build-module/index.native.js.map +1 -1
  306. package/build-module/latest-posts/edit.js +1 -0
  307. package/build-module/latest-posts/edit.js.map +1 -1
  308. package/build-module/media-text/edit.js +20 -2
  309. package/build-module/media-text/edit.js.map +1 -1
  310. package/build-module/media-text/edit.native.js +2 -2
  311. package/build-module/media-text/edit.native.js.map +1 -1
  312. package/build-module/media-text/media-container.native.js +1 -1
  313. package/build-module/media-text/media-container.native.js.map +1 -1
  314. package/build-module/missing/edit.native.js +1 -1
  315. package/build-module/missing/edit.native.js.map +1 -1
  316. package/build-module/more/transforms.js +2 -2
  317. package/build-module/more/transforms.js.map +1 -1
  318. package/build-module/navigation/edit/index.js +138 -68
  319. package/build-module/navigation/edit/index.js.map +1 -1
  320. package/build-module/navigation/edit/inner-blocks.js +8 -3
  321. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  322. package/build-module/navigation/edit/navigation-menu-selector.js +82 -48
  323. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  324. package/build-module/navigation/edit/placeholder/index.js +33 -59
  325. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  326. package/build-module/navigation/edit/placeholder/placeholder-preview.js +3 -9
  327. package/build-module/navigation/edit/placeholder/placeholder-preview.js.map +1 -1
  328. package/build-module/navigation/edit/unsaved-inner-blocks.js +3 -1
  329. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  330. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +100 -0
  331. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -0
  332. package/build-module/navigation/edit/use-create-navigation-menu.js +48 -5
  333. package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
  334. package/build-module/navigation/edit/use-navigation-notice.js +3 -3
  335. package/build-module/navigation/edit/use-navigation-notice.js.map +1 -1
  336. package/build-module/navigation/menu-items-to-blocks.js +1 -1
  337. package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
  338. package/build-module/navigation/use-navigation-entities.js +26 -50
  339. package/build-module/navigation/use-navigation-entities.js.map +1 -1
  340. package/build-module/navigation/use-navigation-menu.js +8 -6
  341. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  342. package/build-module/navigation-link/fallback-variations.js +1 -1
  343. package/build-module/navigation-link/fallback-variations.js.map +1 -1
  344. package/build-module/navigation-link/hooks.js +2 -2
  345. package/build-module/navigation-link/hooks.js.map +1 -1
  346. package/build-module/navigation-submenu/edit.js +43 -12
  347. package/build-module/navigation-submenu/edit.js.map +1 -1
  348. package/build-module/page-list/convert-to-links-modal.js +15 -25
  349. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  350. package/build-module/page-list/edit.js +21 -41
  351. package/build-module/page-list/edit.js.map +1 -1
  352. package/build-module/post-author-name/edit.js +2 -1
  353. package/build-module/post-author-name/edit.js.map +1 -1
  354. package/build-module/post-comments-form/edit.js +4 -2
  355. package/build-module/post-comments-form/edit.js.map +1 -1
  356. package/build-module/post-excerpt/edit.js +9 -6
  357. package/build-module/post-excerpt/edit.js.map +1 -1
  358. package/build-module/post-terms/edit.js +2 -1
  359. package/build-module/post-terms/edit.js.map +1 -1
  360. package/build-module/query-title/edit.js +0 -1
  361. package/build-module/query-title/edit.js.map +1 -1
  362. package/build-module/search/edit.js +3 -1
  363. package/build-module/search/edit.js.map +1 -1
  364. package/build-module/search/edit.native.js +1 -1
  365. package/build-module/search/edit.native.js.map +1 -1
  366. package/build-module/separator/save.js +4 -4
  367. package/build-module/separator/save.js.map +1 -1
  368. package/build-module/separator/separator-settings.native.js +1 -1
  369. package/build-module/separator/separator-settings.native.js.map +1 -1
  370. package/build-module/site-logo/edit.js +1 -1
  371. package/build-module/site-logo/edit.js.map +1 -1
  372. package/build-module/social-link/edit.native.js +11 -3
  373. package/build-module/social-link/edit.native.js.map +1 -1
  374. package/build-module/social-links/deprecated.js +1 -62
  375. package/build-module/social-links/deprecated.js.map +1 -1
  376. package/build-module/spacer/controls.js +5 -5
  377. package/build-module/spacer/controls.js.map +1 -1
  378. package/build-module/spacer/controls.native.js +5 -5
  379. package/build-module/spacer/controls.native.js.map +1 -1
  380. package/build-module/table/edit.js +2 -2
  381. package/build-module/table/edit.js.map +1 -1
  382. package/build-module/template-part/edit/index.js +37 -65
  383. package/build-module/template-part/edit/index.js.map +1 -1
  384. package/build-module/template-part/edit/placeholder.js +52 -0
  385. package/build-module/template-part/edit/placeholder.js.map +1 -0
  386. package/build-module/template-part/edit/selection-modal.js +89 -0
  387. package/build-module/template-part/edit/selection-modal.js.map +1 -0
  388. package/build-module/template-part/edit/title-modal.js +46 -0
  389. package/build-module/template-part/edit/title-modal.js.map +1 -0
  390. package/build-module/template-part/edit/utils/hooks.js +135 -0
  391. package/build-module/template-part/edit/utils/hooks.js.map +1 -0
  392. package/build-module/template-part/index.js +2 -1
  393. package/build-module/template-part/index.js.map +1 -1
  394. package/build-module/video/edit.js +4 -4
  395. package/build-module/video/edit.js.map +1 -1
  396. package/build-module/video/edit.native.js +3 -3
  397. package/build-module/video/edit.native.js.map +1 -1
  398. package/build-style/button/editor-rtl.css +0 -3
  399. package/build-style/button/editor.css +0 -3
  400. package/build-style/code/style-rtl.css +2 -1
  401. package/build-style/code/style.css +2 -1
  402. package/build-style/code/theme-rtl.css +0 -3
  403. package/build-style/code/theme.css +0 -3
  404. package/build-style/comment-author-avatar/editor-rtl.css +83 -0
  405. package/build-style/comment-author-avatar/editor.css +83 -0
  406. package/build-style/common-rtl.css +1 -1
  407. package/build-style/common.css +1 -1
  408. package/build-style/cover/style-rtl.css +5 -5
  409. package/build-style/cover/style.css +5 -5
  410. package/build-style/editor-rtl.css +43 -84
  411. package/build-style/editor.css +43 -84
  412. package/build-style/image/editor-rtl.css +0 -16
  413. package/build-style/image/editor.css +0 -16
  414. package/build-style/image/style-rtl.css +4 -1
  415. package/build-style/image/style.css +4 -1
  416. package/build-style/navigation/editor-rtl.css +16 -0
  417. package/build-style/navigation/editor.css +16 -0
  418. package/build-style/navigation/style-rtl.css +14 -3
  419. package/build-style/navigation/style.css +14 -3
  420. package/build-style/page-list/editor-rtl.css +0 -9
  421. package/build-style/page-list/editor.css +0 -9
  422. package/build-style/style-rtl.css +32 -13
  423. package/build-style/style.css +32 -13
  424. package/build-style/tag-cloud/style-rtl.css +6 -2
  425. package/build-style/tag-cloud/style.css +6 -2
  426. package/build-style/template-part/editor-rtl.css +19 -56
  427. package/build-style/template-part/editor.css +19 -56
  428. package/build-style/theme-rtl.css +0 -3
  429. package/build-style/theme.css +0 -3
  430. package/package.json +32 -28
  431. package/src/archives/index.php +1 -1
  432. package/src/audio/edit.js +4 -4
  433. package/src/audio/edit.native.js +4 -4
  434. package/src/audio/transforms.js +1 -1
  435. package/src/block/edit.js +7 -22
  436. package/src/block/test/edit.native.js +9 -9
  437. package/src/button/edit.js +2 -1
  438. package/src/button/edit.native.js +5 -5
  439. package/src/button/editor.scss +0 -5
  440. package/src/buttons/test/edit.native.js +3 -3
  441. package/src/buttons/transforms.js +8 -8
  442. package/src/categories/edit.js +12 -22
  443. package/src/code/block.json +0 -1
  444. package/src/code/style.scss +4 -2
  445. package/src/code/theme.scss +0 -3
  446. package/src/columns/block.json +12 -0
  447. package/src/columns/columnCalculations.native.js +1 -1
  448. package/src/columns/edit.js +1 -1
  449. package/src/columns/edit.native.js +3 -3
  450. package/src/comment-author-avatar/edit.js +13 -8
  451. package/src/comment-author-avatar/editor.scss +7 -0
  452. package/src/comment-template/block.json +7 -1
  453. package/src/comment-template/edit.js +102 -40
  454. package/src/comment-template/hooks.js +151 -0
  455. package/src/comment-template/index.php +8 -0
  456. package/src/comment-template/util.js +1 -0
  457. package/src/comments-pagination-next/block.json +8 -1
  458. package/src/comments-pagination-next/index.php +6 -8
  459. package/src/comments-pagination-numbers/block.json +7 -1
  460. package/src/comments-pagination-numbers/index.php +3 -10
  461. package/src/comments-query-loop/block.json +5 -0
  462. package/src/comments-query-loop/edit/comments-inspector-controls.js +22 -4
  463. package/src/comments-query-loop/edit.js +1 -16
  464. package/src/common.scss +1 -1
  465. package/src/cover/controls.native.js +1 -1
  466. package/src/cover/deprecated.js +214 -1
  467. package/src/cover/edit.js +21 -36
  468. package/src/cover/edit.native.js +23 -15
  469. package/src/cover/overlay-color-settings.native.js +6 -7
  470. package/src/cover/save.js +4 -3
  471. package/src/cover/shared.js +2 -2
  472. package/src/cover/style.scss +5 -3
  473. package/src/cover/test/edit.native.js +39 -39
  474. package/src/cover/transforms.js +2 -0
  475. package/src/editor.scss +1 -0
  476. package/src/embed/edit.js +1 -1
  477. package/src/embed/edit.native.js +1 -1
  478. package/src/embed/test/index.native.js +105 -105
  479. package/src/embed/util.js +2 -2
  480. package/src/embed/variations.js +1 -1
  481. package/src/file/edit.js +19 -17
  482. package/src/file/edit.native.js +1 -1
  483. package/src/file/save.js +9 -3
  484. package/src/file/style.native.scss +1 -0
  485. package/src/freeform/edit.js +2 -2
  486. package/src/gallery/edit.js +1 -1
  487. package/src/gallery/gallery.native.js +1 -1
  488. package/src/gallery/index.php +1 -8
  489. package/src/gallery/test/__snapshots__/index.native.js.snap +164 -0
  490. package/src/gallery/test/helpers.native.js +293 -0
  491. package/src/gallery/test/index.native.js +583 -65
  492. package/src/gallery/v1/edit.js +3 -4
  493. package/src/gallery/v1/gallery-image.native.js +3 -3
  494. package/src/gallery/v1/gallery.native.js +2 -2
  495. package/src/group/block.json +1 -0
  496. package/src/group/index.js +2 -54
  497. package/src/group/transforms.js +52 -0
  498. package/src/heading/edit.js +18 -5
  499. package/src/home-link/edit.js +1 -1
  500. package/src/home-link/index.php +1 -19
  501. package/src/image/deprecated.js +105 -1
  502. package/src/image/edit.js +7 -6
  503. package/src/image/edit.native.js +25 -8
  504. package/src/image/editor.scss +0 -18
  505. package/src/image/save.js +0 -8
  506. package/src/image/style.scss +5 -1
  507. package/src/image/test/edit.native.js +1 -11
  508. package/src/image/transforms.js +1 -1
  509. package/src/index.js +2 -3
  510. package/src/index.native.js +2 -2
  511. package/src/latest-posts/edit.js +1 -0
  512. package/src/latest-posts/index.php +1 -1
  513. package/src/media-text/edit.js +20 -2
  514. package/src/media-text/edit.native.js +2 -2
  515. package/src/media-text/media-container.native.js +1 -1
  516. package/src/media-text/style.native.scss +1 -0
  517. package/src/missing/edit.native.js +1 -1
  518. package/src/missing/test/edit-integration.native.js +4 -4
  519. package/src/missing/test/edit.native.js +2 -2
  520. package/src/more/transforms.js +2 -2
  521. package/src/navigation/edit/index.js +212 -88
  522. package/src/navigation/edit/inner-blocks.js +11 -4
  523. package/src/navigation/edit/navigation-menu-selector.js +121 -58
  524. package/src/navigation/edit/placeholder/index.js +64 -111
  525. package/src/navigation/edit/placeholder/placeholder-preview.js +3 -10
  526. package/src/navigation/edit/unsaved-inner-blocks.js +3 -1
  527. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +137 -0
  528. package/src/navigation/edit/use-create-navigation-menu.js +59 -8
  529. package/src/navigation/edit/use-navigation-notice.js +3 -3
  530. package/src/navigation/editor.scss +23 -1
  531. package/src/navigation/index.php +4 -4
  532. package/src/navigation/menu-items-to-blocks.js +1 -1
  533. package/src/navigation/style.scss +22 -3
  534. package/src/navigation/test/menu-items-to-blocks.js +1 -1
  535. package/src/navigation/use-navigation-entities.js +26 -60
  536. package/src/navigation/use-navigation-menu.js +11 -6
  537. package/src/navigation-link/fallback-variations.js +1 -1
  538. package/src/navigation-link/hooks.js +2 -2
  539. package/src/navigation-link/index.php +3 -22
  540. package/src/navigation-link/test/edit.js +5 -5
  541. package/src/navigation-submenu/edit.js +52 -14
  542. package/src/navigation-submenu/index.php +3 -21
  543. package/src/page-list/convert-to-links-modal.js +17 -31
  544. package/src/page-list/edit.js +35 -48
  545. package/src/page-list/editor.scss +0 -10
  546. package/src/page-list/index.php +4 -4
  547. package/src/post-author-name/edit.js +1 -0
  548. package/src/post-author-name/index.php +1 -1
  549. package/src/post-comments-form/edit.js +7 -3
  550. package/src/post-excerpt/edit.js +9 -12
  551. package/src/post-navigation-link/index.php +3 -3
  552. package/src/post-terms/edit.js +2 -1
  553. package/src/query-title/edit.js +0 -1
  554. package/src/search/edit.js +6 -0
  555. package/src/search/edit.native.js +1 -1
  556. package/src/search/index.php +8 -4
  557. package/src/search/test/edit.native.js +0 -1
  558. package/src/separator/save.js +4 -4
  559. package/src/separator/separator-settings.native.js +1 -1
  560. package/src/site-logo/edit.js +1 -1
  561. package/src/site-logo/index.php +1 -1
  562. package/src/social-link/edit.native.js +17 -8
  563. package/src/social-link/test/index.native.js +138 -0
  564. package/src/social-links/deprecated.js +0 -59
  565. package/src/spacer/controls.js +1 -1
  566. package/src/spacer/controls.native.js +1 -1
  567. package/src/table/edit.js +2 -2
  568. package/src/tag-cloud/style.scss +12 -7
  569. package/src/template-part/edit/index.js +61 -71
  570. package/src/template-part/edit/placeholder.js +78 -0
  571. package/src/template-part/edit/selection-modal.js +115 -0
  572. package/src/template-part/edit/title-modal.js +59 -0
  573. package/src/template-part/edit/utils/hooks.js +158 -0
  574. package/src/template-part/editor.scss +16 -74
  575. package/src/template-part/index.js +4 -1
  576. package/src/video/edit.js +4 -4
  577. package/src/video/edit.native.js +3 -3
  578. package/src/video/style.native.scss +1 -0
  579. package/build/navigation/edit/existing-menus-options.js +0 -62
  580. package/build/navigation/edit/existing-menus-options.js.map +0 -1
  581. package/build/navigation/use-convert-classic-menu.js +0 -59
  582. package/build/navigation/use-convert-classic-menu.js.map +0 -1
  583. package/build/template-part/edit/placeholder/index.js +0 -141
  584. package/build/template-part/edit/placeholder/index.js.map +0 -1
  585. package/build/template-part/edit/placeholder/patterns-setup.js +0 -100
  586. package/build/template-part/edit/placeholder/patterns-setup.js.map +0 -1
  587. package/build/template-part/edit/selection/index.js +0 -45
  588. package/build/template-part/edit/selection/index.js.map +0 -1
  589. package/build/template-part/edit/selection/template-part-previews.js +0 -317
  590. package/build/template-part/edit/selection/template-part-previews.js.map +0 -1
  591. package/build-module/navigation/edit/existing-menus-options.js +0 -53
  592. package/build-module/navigation/edit/existing-menus-options.js.map +0 -1
  593. package/build-module/navigation/use-convert-classic-menu.js +0 -47
  594. package/build-module/navigation/use-convert-classic-menu.js.map +0 -1
  595. package/build-module/template-part/edit/placeholder/index.js +0 -124
  596. package/build-module/template-part/edit/placeholder/index.js.map +0 -1
  597. package/build-module/template-part/edit/placeholder/patterns-setup.js +0 -91
  598. package/build-module/template-part/edit/placeholder/patterns-setup.js.map +0 -1
  599. package/build-module/template-part/edit/selection/index.js +0 -35
  600. package/build-module/template-part/edit/selection/index.js.map +0 -1
  601. package/build-module/template-part/edit/selection/template-part-previews.js +0 -298
  602. package/build-module/template-part/edit/selection/template-part-previews.js.map +0 -1
  603. package/src/navigation/edit/existing-menus-options.js +0 -70
  604. package/src/navigation/use-convert-classic-menu.js +0 -58
  605. package/src/template-part/edit/placeholder/index.js +0 -172
  606. package/src/template-part/edit/placeholder/patterns-setup.js +0 -124
  607. package/src/template-part/edit/selection/index.js +0 -37
  608. package/src/template-part/edit/selection/template-part-previews.js +0 -372
@@ -0,0 +1,156 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useState, useEffect, useMemo } from '@wordpress/element';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { store as blockEditorStore } from '@wordpress/block-editor';
7
+ import { addQueryArgs } from '@wordpress/url';
8
+ import apiFetch from '@wordpress/api-fetch';
9
+ /**
10
+ * Return an object with the query args needed to fetch the default page of
11
+ * comments.
12
+ *
13
+ * @param {Object} props Hook props.
14
+ * @param {number} props.postId ID of the post that contains the comments.
15
+ * @param {number} props.perPage The number of comments included per page.
16
+ * @param {string} props.defaultPage Page shown by default (newest/oldest).
17
+ * @param {boolean} props.inherit Overwrite props with values from WP
18
+ * discussion settings.
19
+ *
20
+ * @return {Object} Query args to retrieve the comments.
21
+ */
22
+
23
+ export const useCommentQueryArgs = _ref => {
24
+ let {
25
+ postId,
26
+ perPage,
27
+ defaultPage,
28
+ inherit
29
+ } = _ref;
30
+ // Initialize the query args that are not going to change.
31
+ const queryArgs = {
32
+ status: 'approve',
33
+ order: 'asc',
34
+ context: 'embed',
35
+ parent: 0,
36
+ _embed: 'children'
37
+ }; // Get the Discussion settings that may be needed to query the comments.
38
+
39
+ const {
40
+ commentsPerPage,
41
+ defaultCommentsPage
42
+ } = useSelect(select => {
43
+ const {
44
+ getSettings
45
+ } = select(blockEditorStore);
46
+ const {
47
+ __experimentalDiscussionSettings
48
+ } = getSettings();
49
+ return __experimentalDiscussionSettings;
50
+ }); // Overwrite the received attributes if `inherit` is true.
51
+
52
+ if (inherit) {
53
+ perPage = commentsPerPage;
54
+ defaultPage = defaultCommentsPage;
55
+ } // If a block props is not set, use the settings value to generate the
56
+ // appropriate query arg.
57
+
58
+
59
+ perPage = perPage || commentsPerPage;
60
+ defaultPage = defaultPage || defaultCommentsPage; // Get the number of the default page.
61
+
62
+ const page = useDefaultPageIndex({
63
+ defaultPage,
64
+ postId,
65
+ perPage,
66
+ queryArgs
67
+ }); // Merge, memoize and return all query arguments, unless the default page's
68
+ // number is not known yet.
69
+
70
+ return useMemo(() => {
71
+ return page ? { ...queryArgs,
72
+ post: postId,
73
+ per_page: perPage,
74
+ page
75
+ } : null;
76
+ }, [postId, perPage, page]);
77
+ };
78
+ /**
79
+ * Return the index of the default page, depending on whether `defaultPage` is
80
+ * `newest` or `oldest`. In the first case, the only way to know the page's
81
+ * index is by using the `X-WP-TotalPages` header, which forces to make an
82
+ * additional request.
83
+ *
84
+ * @param {Object} props Hook props.
85
+ * @param {string} props.defaultPage Page shown by default (newest/oldest).
86
+ * @param {number} props.postId ID of the post that contains the comments.
87
+ * @param {number} props.perPage The number of comments included per page.
88
+ * @param {Object} props.queryArgs Other query args.
89
+ *
90
+ * @return {number} Index of the default comments page.
91
+ */
92
+
93
+ const useDefaultPageIndex = _ref2 => {
94
+ let {
95
+ defaultPage,
96
+ postId,
97
+ perPage,
98
+ queryArgs
99
+ } = _ref2;
100
+ // Store the default page indices.
101
+ const [defaultPages, setDefaultPages] = useState({});
102
+ const key = `${postId}_${perPage}`;
103
+ const page = defaultPages[key] || 0;
104
+ useEffect(() => {
105
+ // Do nothing if the page is already known or not the newest page.
106
+ if (page || defaultPage !== 'newest') {
107
+ return;
108
+ } // We need to fetch comments to know the index. Use HEAD and limit
109
+ // fields just to ID, to make this call as light as possible.
110
+
111
+
112
+ apiFetch({
113
+ path: addQueryArgs('/wp/v2/comments', { ...queryArgs,
114
+ post: postId,
115
+ per_page: perPage,
116
+ _fields: 'id'
117
+ }),
118
+ method: 'HEAD',
119
+ parse: false
120
+ }).then(res => {
121
+ setDefaultPages({ ...defaultPages,
122
+ [key]: parseInt(res.headers.get('X-WP-TotalPages'))
123
+ });
124
+ });
125
+ }, [defaultPage, postId, perPage, setDefaultPages]); // The oldest one is always the first one.
126
+
127
+ return defaultPage === 'newest' ? page : 1;
128
+ };
129
+ /**
130
+ * Generate a tree structure of comment IDs from a list of comment entities. The
131
+ * children of each comment are obtained from `_embedded`.
132
+ *
133
+ * @typedef {{ commentId: number, children: CommentNode }} CommentNode
134
+ *
135
+ * @param {Object[]} topLevelComments List of comment entities.
136
+ * @return {{ commentTree: CommentNode[]}} Tree of comment IDs.
137
+ */
138
+
139
+
140
+ export const useCommentTree = topLevelComments => {
141
+ const commentTree = useMemo(() => topLevelComments === null || topLevelComments === void 0 ? void 0 : topLevelComments.map(_ref3 => {
142
+ let {
143
+ id,
144
+ _embedded
145
+ } = _ref3;
146
+ const [children] = (_embedded === null || _embedded === void 0 ? void 0 : _embedded.children) || [[]];
147
+ return {
148
+ commentId: id,
149
+ children: children.map(child => ({
150
+ commentId: child.id
151
+ }))
152
+ };
153
+ }), [topLevelComments]);
154
+ return commentTree;
155
+ };
156
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useState","useEffect","useMemo","useSelect","store","blockEditorStore","addQueryArgs","apiFetch","useCommentQueryArgs","postId","perPage","defaultPage","inherit","queryArgs","status","order","context","parent","_embed","commentsPerPage","defaultCommentsPage","select","getSettings","__experimentalDiscussionSettings","page","useDefaultPageIndex","post","per_page","defaultPages","setDefaultPages","key","path","_fields","method","parse","then","res","parseInt","headers","get","useCommentTree","topLevelComments","commentTree","map","id","_embedded","children","commentId","child"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,OAA9B,QAA6C,oBAA7C;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAG,QAK5B;AAAA,MAL8B;AACpCC,IAAAA,MADoC;AAEpCC,IAAAA,OAFoC;AAGpCC,IAAAA,WAHoC;AAIpCC,IAAAA;AAJoC,GAK9B;AACN;AACA,QAAMC,SAAS,GAAG;AACjBC,IAAAA,MAAM,EAAE,SADS;AAEjBC,IAAAA,KAAK,EAAE,KAFU;AAGjBC,IAAAA,OAAO,EAAE,OAHQ;AAIjBC,IAAAA,MAAM,EAAE,CAJS;AAKjBC,IAAAA,MAAM,EAAE;AALS,GAAlB,CAFM,CAUN;;AACA,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAA2CjB,SAAS,CAAIkB,MAAF,IAA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;AACNC,MAAAA,SAAS,EAAEH,EADL;AAENE,MAAAA,QAAQ,EAAEA,QAAQ,CAACH,GAAT,CAAgBK,KAAF,KAAe;AACtCD,QAAAA,SAAS,EAAEC,KAAK,CAACJ;AADqB,OAAf,CAAd;AAFJ,KAAP;AAMA,GARD,CAFyB,EAW1B,CAAEH,gBAAF,CAX0B,CAA3B;AAcA,SAAOC,WAAP;AACA,CAhBM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Return an object with the query args needed to fetch the default page of\n * comments.\n *\n * @param {Object} props Hook props.\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {boolean} props.inherit Overwrite props with values from WP\n * discussion settings.\n *\n * @return {Object} Query args to retrieve the comments.\n */\nexport const useCommentQueryArgs = ( {\n\tpostId,\n\tperPage,\n\tdefaultPage,\n\tinherit,\n} ) => {\n\t// Initialize the query args that are not going to change.\n\tconst queryArgs = {\n\t\tstatus: 'approve',\n\t\torder: 'asc',\n\t\tcontext: 'embed',\n\t\tparent: 0,\n\t\t_embed: 'children',\n\t};\n\n\t// Get the Discussion settings that may be needed to query the comments.\n\tconst { commentsPerPage, defaultCommentsPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\t// Overwrite the received attributes if `inherit` is true.\n\tif ( inherit ) {\n\t\tperPage = commentsPerPage;\n\t\tdefaultPage = defaultCommentsPage;\n\t}\n\n\t// If a block props is not set, use the settings value to generate the\n\t// appropriate query arg.\n\tperPage = perPage || commentsPerPage;\n\tdefaultPage = defaultPage || defaultCommentsPage;\n\n\t// Get the number of the default page.\n\tconst page = useDefaultPageIndex( {\n\t\tdefaultPage,\n\t\tpostId,\n\t\tperPage,\n\t\tqueryArgs,\n\t} );\n\n\t// Merge, memoize and return all query arguments, unless the default page's\n\t// number is not known yet.\n\treturn useMemo( () => {\n\t\treturn page\n\t\t\t? {\n\t\t\t\t\t...queryArgs,\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\tpage,\n\t\t\t }\n\t\t\t: null;\n\t}, [ postId, perPage, page ] );\n};\n\n/**\n * Return the index of the default page, depending on whether `defaultPage` is\n * `newest` or `oldest`. In the first case, the only way to know the page's\n * index is by using the `X-WP-TotalPages` header, which forces to make an\n * additional request.\n *\n * @param {Object} props Hook props.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {Object} props.queryArgs Other query args.\n *\n * @return {number} Index of the default comments page.\n */\nconst useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {\n\t// Store the default page indices.\n\tconst [ defaultPages, setDefaultPages ] = useState( {} );\n\tconst key = `${ postId }_${ perPage }`;\n\tconst page = defaultPages[ key ] || 0;\n\n\tuseEffect( () => {\n\t\t// Do nothing if the page is already known or not the newest page.\n\t\tif ( page || defaultPage !== 'newest' ) {\n\t\t\treturn;\n\t\t}\n\t\t// We need to fetch comments to know the index. Use HEAD and limit\n\t\t// fields just to ID, to make this call as light as possible.\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\t...queryArgs,\n\t\t\t\tpost: postId,\n\t\t\t\tper_page: perPage,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} ).then( ( res ) => {\n\t\t\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: parseInt( res.headers.get( 'X-WP-TotalPages' ) ),\n\t\t\t} );\n\t\t} );\n\t}, [ defaultPage, postId, perPage, setDefaultPages ] );\n\n\t// The oldest one is always the first one.\n\treturn defaultPage === 'newest' ? page : 1;\n};\n\n/**\n * Generate a tree structure of comment IDs from a list of comment entities. The\n * children of each comment are obtained from `_embedded`.\n *\n * @typedef {{ commentId: number, children: CommentNode }} CommentNode\n *\n * @param {Object[]} topLevelComments List of comment entities.\n * @return {{ commentTree: CommentNode[]}} Tree of comment IDs.\n */\nexport const useCommentTree = ( topLevelComments ) => {\n\tconst commentTree = useMemo(\n\t\t() =>\n\t\t\ttopLevelComments?.map( ( { id, _embedded } ) => {\n\t\t\t\tconst [ children ] = _embedded?.children || [ [] ];\n\t\t\t\treturn {\n\t\t\t\t\tcommentId: id,\n\t\t\t\t\tchildren: children.map( ( child ) => ( {\n\t\t\t\t\t\tcommentId: child.id,\n\t\t\t\t\t} ) ),\n\t\t\t\t};\n\t\t\t} ),\n\t\t[ topLevelComments ]\n\t);\n\n\treturn commentTree;\n};\n"]}
@@ -15,7 +15,7 @@ const metadata = {
15
15
  parent: ["core/comments-query-loop"],
16
16
  description: "Contains the block elements used to render a comment, like the title, date, author, avatar and more.",
17
17
  textdomain: "default",
18
- usesContext: ["comments/perPage", "postId", "comments/order"],
18
+ usesContext: ["comments/defaultPage", "comments/inherit", "comments/order", "comments/perPage", "postId"],
19
19
  supports: {
20
20
  reusable: false,
21
21
  html: false,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comment-template/util.js"],"names":["convertToTree","data","table","forEach","item","id","commentId","children","tree","parent","push"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAa,GAAKC,IAAF,IAAY;AACxC,QAAMC,KAAK,GAAG,EAAd;AACA,MAAK,CAAED,IAAP,EAAc,OAAO,EAAP,CAF0B,CAIxC;;AACAA,EAAAA,IAAI,CAACE,OAAL,CAAgBC,IAAF,IAAY;AACzBF,IAAAA,KAAK,CAAEE,IAAI,CAACC,EAAP,CAAL,GAAmB;AAAEC,MAAAA,SAAS,EAAEF,IAAI,CAACC,EAAlB;AAAsBE,MAAAA,QAAQ,EAAE;AAAhC,KAAnB;AACA,GAFD;AAIA,QAAMC,IAAI,GAAG,EAAb,CATwC,CAWxC;;AACAP,EAAAA,IAAI,CAACE,OAAL,CAAgBC,IAAF,IAAY;AACzB,QAAKA,IAAI,CAACK,MAAV,EAAmB;AAAA;;AAClB;AACA;AACA;AACA,4BAAAP,KAAK,CAAEE,IAAI,CAACK,MAAP,CAAL,0EAAsBF,QAAtB,CAA+BG,IAA/B,CAAqCR,KAAK,CAAEE,IAAI,CAACC,EAAP,CAA1C;AACA,KALD,MAKO;AACN;AACA;AACA;AACAG,MAAAA,IAAI,CAACE,IAAL,CAAWR,KAAK,CAAEE,IAAI,CAACC,EAAP,CAAhB;AACA;AACD,GAZD;AAaA,SAAOG,IAAP;AACA,CA1BM","sourcesContent":["/**\n *\n * This function converts a flat list of comment objects with a `parent` property\n * to a nested list of comment objects with a `children` property. The `children`\n * property is itself a list of comment objects.\n *\n * @example\n * ```\n * const comments = [\n * \t{ id: 1, parent: 0 },\n * \t{ id: 2, parent: 1 },\n * \t{ id: 3, parent: 2 },\n * \t{ id: 4, parent: 1 },\n * ];\n * expect( convertToTree( comments ) ).toEqual( [\n * \t{\n * \t\tcommentId: 1,\n * \t\tchildren: [\n * \t\t\t{ commentId: 2, children: [ { commentId: 3, children: [] } ] },\n * \t\t\t{ commentId: 4, children: [] },\n * \t\t],\n * \t},\n * ] );\n * ```\n * @typedef {{id: number, parent: number}} Comment\n * @param {Comment[]} data - List of comment objects.\n *\n * @return {Object[]} Nested list of comment objects with a `children` property.\n */\nexport const convertToTree = ( data ) => {\n\tconst table = {};\n\tif ( ! data ) return [];\n\n\t// First create a hash table of { [id]: { ...comment, children: [] }}\n\tdata.forEach( ( item ) => {\n\t\ttable[ item.id ] = { commentId: item.id, children: [] };\n\t} );\n\n\tconst tree = [];\n\n\t// Iterate over the original comments again\n\tdata.forEach( ( item ) => {\n\t\tif ( item.parent ) {\n\t\t\t// If the comment has a \"parent\", then find that parent in the table that\n\t\t\t// we have created above and push the current comment to the array of its\n\t\t\t// children.\n\t\t\ttable[ item.parent ]?.children.push( table[ item.id ] );\n\t\t} else {\n\t\t\t// Otherwise, if the comment has no parent (also works if parent is 0)\n\t\t\t// that means that it's a top-level comment so we can find it in the table\n\t\t\t// and push it to the final tree.\n\t\t\ttree.push( table[ item.id ] );\n\t\t}\n\t} );\n\treturn tree;\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comment-template/util.js"],"names":["convertToTree","data","table","forEach","item","id","commentId","children","tree","parent","push"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAa,GAAKC,IAAF,IAAY;AACxC,QAAMC,KAAK,GAAG,EAAd;AAEA,MAAK,CAAED,IAAP,EAAc,OAAO,EAAP,CAH0B,CAKxC;;AACAA,EAAAA,IAAI,CAACE,OAAL,CAAgBC,IAAF,IAAY;AACzBF,IAAAA,KAAK,CAAEE,IAAI,CAACC,EAAP,CAAL,GAAmB;AAAEC,MAAAA,SAAS,EAAEF,IAAI,CAACC,EAAlB;AAAsBE,MAAAA,QAAQ,EAAE;AAAhC,KAAnB;AACA,GAFD;AAIA,QAAMC,IAAI,GAAG,EAAb,CAVwC,CAYxC;;AACAP,EAAAA,IAAI,CAACE,OAAL,CAAgBC,IAAF,IAAY;AACzB,QAAKA,IAAI,CAACK,MAAV,EAAmB;AAAA;;AAClB;AACA;AACA;AACA,4BAAAP,KAAK,CAAEE,IAAI,CAACK,MAAP,CAAL,0EAAsBF,QAAtB,CAA+BG,IAA/B,CAAqCR,KAAK,CAAEE,IAAI,CAACC,EAAP,CAA1C;AACA,KALD,MAKO;AACN;AACA;AACA;AACAG,MAAAA,IAAI,CAACE,IAAL,CAAWR,KAAK,CAAEE,IAAI,CAACC,EAAP,CAAhB;AACA;AACD,GAZD;AAaA,SAAOG,IAAP;AACA,CA3BM","sourcesContent":["/**\n *\n * This function converts a flat list of comment objects with a `parent` property\n * to a nested list of comment objects with a `children` property. The `children`\n * property is itself a list of comment objects.\n *\n * @example\n * ```\n * const comments = [\n * \t{ id: 1, parent: 0 },\n * \t{ id: 2, parent: 1 },\n * \t{ id: 3, parent: 2 },\n * \t{ id: 4, parent: 1 },\n * ];\n * expect( convertToTree( comments ) ).toEqual( [\n * \t{\n * \t\tcommentId: 1,\n * \t\tchildren: [\n * \t\t\t{ commentId: 2, children: [ { commentId: 3, children: [] } ] },\n * \t\t\t{ commentId: 4, children: [] },\n * \t\t],\n * \t},\n * ] );\n * ```\n * @typedef {{id: number, parent: number}} Comment\n * @param {Comment[]} data - List of comment objects.\n *\n * @return {Object[]} Nested list of comment objects with a `children` property.\n */\nexport const convertToTree = ( data ) => {\n\tconst table = {};\n\n\tif ( ! data ) return [];\n\n\t// First create a hash table of { [id]: { ...comment, children: [] }}\n\tdata.forEach( ( item ) => {\n\t\ttable[ item.id ] = { commentId: item.id, children: [] };\n\t} );\n\n\tconst tree = [];\n\n\t// Iterate over the original comments again\n\tdata.forEach( ( item ) => {\n\t\tif ( item.parent ) {\n\t\t\t// If the comment has a \"parent\", then find that parent in the table that\n\t\t\t// we have created above and push the current comment to the array of its\n\t\t\t// children.\n\t\t\ttable[ item.parent ]?.children.push( table[ item.id ] );\n\t\t} else {\n\t\t\t// Otherwise, if the comment has no parent (also works if parent is 0)\n\t\t\t// that means that it's a top-level comment so we can find it in the table\n\t\t\t// and push it to the final tree.\n\t\t\ttree.push( table[ item.id ] );\n\t\t}\n\t} );\n\treturn tree;\n};\n"]}
@@ -20,7 +20,7 @@ const metadata = {
20
20
  type: "string"
21
21
  }
22
22
  },
23
- usesContext: ["postId", "comments/perPage", "comments/paginationArrow"],
23
+ usesContext: ["postId", "comments/perPage", "comments/order", "comments/inherit", "comments/defaultPage", "comments/paginationArrow"],
24
24
  supports: {
25
25
  reusable: false,
26
26
  html: false,
@@ -15,7 +15,7 @@ const metadata = {
15
15
  parent: ["core/comments-pagination"],
16
16
  description: "Displays a list of page numbers for comments pagination.",
17
17
  textdomain: "default",
18
- usesContext: ["comments/perPage", "postId", "comments/order"],
18
+ usesContext: ["postId", "comments/perPage", "comments/order", "comments/inherit", "comments/defaultPage"],
19
19
  supports: {
20
20
  reusable: false,
21
21
  html: false
@@ -13,19 +13,23 @@ const orderOptions = [{
13
13
  label: __('Oldest to newest'),
14
14
  value: 'asc'
15
15
  }];
16
+ const defaultPageOptions = [{
17
+ label: __('Newest'),
18
+ value: 'newest'
19
+ }, {
20
+ label: __('Oldest'),
21
+ value: 'oldest'
22
+ }];
16
23
  export default function CommentsInspectorControls(_ref) {
17
24
  let {
18
25
  attributes: {
19
26
  TagName,
20
27
  perPage,
21
28
  order,
22
- inherit
29
+ inherit,
30
+ defaultPage
23
31
  },
24
- setAttributes,
25
- defaultSettings: {
26
- defaultPerPage,
27
- defaultOrder
28
- }
32
+ setAttributes
29
33
  } = _ref;
30
34
  return createElement(InspectorControls, null, createElement(PanelBody, {
31
35
  title: __('Settings')
@@ -34,9 +38,7 @@ export default function CommentsInspectorControls(_ref) {
34
38
  checked: inherit,
35
39
  onChange: () => {
36
40
  setAttributes({
37
- inherit: !inherit,
38
- order: inherit ? defaultOrder : null,
39
- perPage: inherit ? defaultPerPage : null
41
+ inherit: !inherit
40
42
  });
41
43
  }
42
44
  }), !inherit && createElement(Fragment, null, createElement(SelectControl, {
@@ -48,6 +50,15 @@ export default function CommentsInspectorControls(_ref) {
48
50
  order: value
49
51
  });
50
52
  }
53
+ }), createElement(SelectControl, {
54
+ label: __('Default page'),
55
+ value: defaultPage,
56
+ options: defaultPageOptions,
57
+ onChange: value => {
58
+ setAttributes({
59
+ defaultPage: value
60
+ });
61
+ }
51
62
  }), createElement(NumberControl, {
52
63
  __unstableInputWidth: "60px",
53
64
  label: __('Items per Page'),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit/comments-inspector-controls.js"],"names":["PanelBody","SelectControl","ToggleControl","__experimentalNumberControl","NumberControl","__","InspectorControls","orderOptions","label","value","CommentsInspectorControls","attributes","TagName","perPage","order","inherit","setAttributes","defaultSettings","defaultPerPage","defaultOrder","num","parseInt","isNaN","tagName"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,SADD,EAECC,aAFD,EAGCC,aAHD,EAICC,2BAA2B,IAAIC,aAJhC,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAEA,MAAMC,YAAY,GAAG,CACpB;AACCC,EAAAA,KAAK,EAAEH,EAAE,CAAE,kBAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CADoB,EAKpB;AACCD,EAAAA,KAAK,EAAEH,EAAE,CAAE,kBAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CALoB,CAArB;AAWA,eAAe,SAASC,yBAAT,OAIX;AAAA,MAJ+C;AAClDC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,OAAX;AAAoBC,MAAAA,KAApB;AAA2BC,MAAAA;AAA3B,KADsC;AAElDC,IAAAA,aAFkD;AAGlDC,IAAAA,eAAe,EAAE;AAAEC,MAAAA,cAAF;AAAkBC,MAAAA;AAAlB;AAHiC,GAI/C;AACH,SACC,cAAC,iBAAD,QACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGd,EAAE,CAAE,UAAF;AAArB,KACC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGA,EAAE,CAAE,kCAAF,CADX;AAEC,IAAA,O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,EAAGR,EAAE,CAAE,cAAF,CADX;AAEC,IAAA,OAAO,EAAG,CACT;AAAEG,MAAAA,KAAK,EAAEH,EAAE,CAAE,iBAAF,CAAX;AAAkCI,MAAAA,KAAK,EAAE;AAAzC,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAHS,CAFX;AAOC,IAAA,KAAK,EAAGG,OAPT;AAQC,IAAA,QAAQ,EAAKH,KAAF,IACVO,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAEd;AAAX,KAAF;AATf,IADD,CA/CD,CADD;AAgEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\t__experimentalNumberControl as NumberControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\n\nconst orderOptions = [\n\t{\n\t\tlabel: __( 'Newest to oldest' ),\n\t\tvalue: 'desc',\n\t},\n\t{\n\t\tlabel: __( 'Oldest to newest' ),\n\t\tvalue: 'asc',\n\t},\n];\n\nexport default function CommentsInspectorControls( {\n\tattributes: { TagName, perPage, order, inherit },\n\tsetAttributes,\n\tdefaultSettings: { defaultPerPage, defaultOrder },\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Inherit from Discussion Settings' ) }\n\t\t\t\t\tchecked={ inherit }\n\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tinherit: ! inherit,\n\t\t\t\t\t\t\torder: inherit ? defaultOrder : null,\n\t\t\t\t\t\t\tperPage: inherit ? defaultPerPage : null,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ ! inherit && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Order by' ) }\n\t\t\t\t\t\t\tvalue={ order }\n\t\t\t\t\t\t\toptions={ orderOptions }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\torder: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<NumberControl\n\t\t\t\t\t\t\t__unstableInputWidth=\"60px\"\n\t\t\t\t\t\t\tlabel={ __( 'Items per Page' ) }\n\t\t\t\t\t\t\tlabelPosition=\"edge\"\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tmax={ 100 }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tconst num = parseInt( value, 10 );\n\t\t\t\t\t\t\t\tif ( isNaN( num ) || num < 1 || num > 100 ) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tperPage: num,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tstep=\"1\"\n\t\t\t\t\t\t\tvalue={ perPage }\n\t\t\t\t\t\t\tisDragEnabled={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</InspectorControls>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit/comments-inspector-controls.js"],"names":["PanelBody","SelectControl","ToggleControl","__experimentalNumberControl","NumberControl","__","InspectorControls","orderOptions","label","value","defaultPageOptions","CommentsInspectorControls","attributes","TagName","perPage","order","inherit","defaultPage","setAttributes","num","parseInt","isNaN","tagName"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,SADD,EAECC,aAFD,EAGCC,aAHD,EAICC,2BAA2B,IAAIC,aAJhC,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,QAAkC,yBAAlC;AAEA,MAAMC,YAAY,GAAG,CACpB;AACCC,EAAAA,KAAK,EAAEH,EAAE,CAAE,kBAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CADoB,EAKpB;AACCD,EAAAA,KAAK,EAAEH,EAAE,CAAE,kBAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CALoB,CAArB;AAWA,MAAMC,kBAAkB,GAAG,CAC1B;AACCF,EAAAA,KAAK,EAAEH,EAAE,CAAE,QAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CAD0B,EAK1B;AACCD,EAAAA,KAAK,EAAEH,EAAE,CAAE,QAAF,CADV;AAECI,EAAAA,KAAK,EAAE;AAFR,CAL0B,CAA3B;AAWA,eAAe,SAASE,yBAAT,OAGX;AAAA,MAH+C;AAClDC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,OAAX;AAAoBC,MAAAA,KAApB;AAA2BC,MAAAA,OAA3B;AAAoCC,MAAAA;AAApC,KADsC;AAElDC,IAAAA;AAFkD,GAG/C;AACH,SACC,cAAC,iBAAD,QACC,cAA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Aa,CAAE;AACdJ,QAAAA,OAAO,EAAEK;AADK,OAAF,CAAb;AAGA,KAdF;AAeC,IAAA,IAAI,EAAC,GAfN;AAgBC,IAAA,KAAK,EAAGL,OAhBT;AAiBC,IAAA,aAAa,EAAG;AAjBjB,IArBD,CAXF,CADD,EAuDC,cAAC,iBAAD;AAAmB,IAAA,mBAAmB,EAAC;AAAvC,KACC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGT,EAAE,CAAE,cAAF,CADX;AAEC,IAAA,OAAO,EAAG,CACT;AAAEG,MAAAA,KAAK,EAAEH,EAAE,CAAE,iBAAF,CAAX;AAAkCI,MAAAA,KAAK,EAAE;AAAzC,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAHS,CAFX;AAOC,IAAA,KAAK,EAAGI,OAPT;AAQC,IAAA,QAAQ,EAAKJ,KAAF,IACVS,aAAa,CAAE;AAAEI,MAAAA,OAAO,EAAEb;AAAX,KAAF;AATf,IADD,CAvDD,CADD;AAwEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\t__experimentalNumberControl as NumberControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\n\nconst orderOptions = [\n\t{\n\t\tlabel: __( 'Newest to oldest' ),\n\t\tvalue: 'desc',\n\t},\n\t{\n\t\tlabel: __( 'Oldest to newest' ),\n\t\tvalue: 'asc',\n\t},\n];\n\nconst defaultPageOptions = [\n\t{\n\t\tlabel: __( 'Newest' ),\n\t\tvalue: 'newest',\n\t},\n\t{\n\t\tlabel: __( 'Oldest' ),\n\t\tvalue: 'oldest',\n\t},\n];\n\nexport default function CommentsInspectorControls( {\n\tattributes: { TagName, perPage, order, inherit, defaultPage },\n\tsetAttributes,\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Inherit from Discussion Settings' ) }\n\t\t\t\t\tchecked={ inherit }\n\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tinherit: ! inherit,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ ! inherit && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Order by' ) }\n\t\t\t\t\t\t\tvalue={ order }\n\t\t\t\t\t\t\toptions={ orderOptions }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\torder: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Default page' ) }\n\t\t\t\t\t\t\tvalue={ defaultPage }\n\t\t\t\t\t\t\toptions={ defaultPageOptions }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tdefaultPage: value,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<NumberControl\n\t\t\t\t\t\t\t__unstableInputWidth=\"60px\"\n\t\t\t\t\t\t\tlabel={ __( 'Items per Page' ) }\n\t\t\t\t\t\t\tlabelPosition=\"edge\"\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tmax={ 100 }\n\t\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t\tconst num = parseInt( value, 10 );\n\t\t\t\t\t\t\t\tif ( isNaN( num ) || num < 1 || num > 100 ) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tperPage: num,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tstep=\"1\"\n\t\t\t\t\t\t\tvalue={ perPage }\n\t\t\t\t\t\t\tisDragEnabled={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t</InspectorControls>\n\t);\n}\n"]}
@@ -3,13 +3,12 @@ import { createElement, Fragment } from "@wordpress/element";
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { useBlockProps, useInnerBlocksProps, store as blockEditorStore } from '@wordpress/block-editor';
6
+ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
10
 
11
11
  import CommentsInspectorControls from './edit/comments-inspector-controls';
12
- import { useSelect } from '@wordpress/data';
13
12
  const TEMPLATE = [['core/comment-template'], ['core/comments-pagination']];
14
13
  export default function CommentsQueryLoopEdit(_ref) {
15
14
  let {
@@ -23,25 +22,9 @@ export default function CommentsQueryLoopEdit(_ref) {
23
22
  const innerBlocksProps = useInnerBlocksProps(blockProps, {
24
23
  template: TEMPLATE
25
24
  });
26
- const {
27
- commentOrder,
28
- commentsPerPage
29
- } = useSelect(select => {
30
- const {
31
- getSettings
32
- } = select(blockEditorStore);
33
- const {
34
- __experimentalDiscussionSettings
35
- } = getSettings();
36
- return __experimentalDiscussionSettings;
37
- });
38
25
  return createElement(Fragment, null, createElement(CommentsInspectorControls, {
39
26
  attributes: attributes,
40
- setAttributes: setAttributes,
41
- defaultSettings: {
42
- defaultOrder: commentOrder,
43
- defaultPerPage: commentsPerPage
44
- }
27
+ setAttributes: setAttributes
45
28
  }), createElement(TagName, innerBlocksProps));
46
29
  }
47
30
  //# sourceMappingURL=edit.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit.js"],"names":["useBlockProps","useInnerBlocksProps","store","blockEditorStore","CommentsInspectorControls","useSelect","TEMPLATE","CommentsQueryLoopEdit","attributes","setAttributes","tagName","TagName","blockProps","innerBlocksProps","template","commentOrder","commentsPerPage","select","getSettings","__experimentalDiscussionSettings","defaultOrder","defaultPerPage"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,aADD,EAECC,mBAFD,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAMA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,oCAAtC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA,MAAMC,QAAQ,GAAG,CAChB,CAAE,uBAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,CAAjB;AAKA,eAAe,SAASC,qBAAT,OAAgE;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AAC9E,QAAM;AAAEC,IAAAA,OAAO,EAAEC;AAAX,MAAuBH,UAA7B;AAEA,QAAMI,UAAU,GAAGZ,aAAa,EAAhC;AACA,QAAMa,gBAAgB,GAAGZ,mBAAmB,CAAEW,UAAF,EAAc;AACzDE,IAAAA,QAAQ,EAAER;AAD+C,GAAd,CAA5C;AAIA,QAAM;AAAES,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAoCX,SAAS,CAAIY,MAAF,IAAc;AAClE,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEd,gBAAF,CAA9B;AACA,UAAM;AAAEgB,MAAAA;AAAF,QAAuCD,WAAW,EAAxD;AACA,WAAOC,gCAAP;AACA,GAJkD,CAAnD;AAMA,SACC,8BACC,cAAC,yBAAD;AACC,IAAA,UAAU,EAAGX,UADd;AAEC,IAAA,aAAa,EAAGC,aAFjB;AAGC,IAAA,eAAe,EAAG;AACjBW,MAAAA,YAAY,EAAEL,YADG;AAEjBM,MAAAA,cAAc,EAAEL;AAFC;AAHnB,IADD,EASC,cAAC,OAAD,EAAcH,gBAAd,CATD,CADD;AAaA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentsInspectorControls from './edit/comments-inspector-controls';\nimport { useSelect } from '@wordpress/data';\n\nconst TEMPLATE = [\n\t[ 'core/comment-template' ],\n\t[ 'core/comments-pagination' ],\n];\n\nexport default function CommentsQueryLoopEdit( { attributes, setAttributes } ) {\n\tconst { tagName: TagName } = attributes;\n\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\tconst { commentOrder, commentsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<CommentsInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tdefaultSettings={ {\n\t\t\t\t\tdefaultOrder: commentOrder,\n\t\t\t\t\tdefaultPerPage: commentsPerPage,\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit.js"],"names":["useBlockProps","useInnerBlocksProps","CommentsInspectorControls","TEMPLATE","CommentsQueryLoopEdit","attributes","setAttributes","tagName","TagName","blockProps","innerBlocksProps","template"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,mBAAxB,QAAmD,yBAAnD;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,oCAAtC;AAEA,MAAMC,QAAQ,GAAG,CAChB,CAAE,uBAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,CAAjB;AAKA,eAAe,SAASC,qBAAT,OAAgE;AAAA,MAAhC;AAAEC,IAAAA,UAAF;AAAcC,IAAAA;AAAd,GAAgC;AAC9E,QAAM;AAAEC,IAAAA,OAAO,EAAEC;AAAX,MAAuBH,UAA7B;AAEA,QAAMI,UAAU,GAAGT,aAAa,EAAhC;AACA,QAAMU,gBAAgB,GAAGT,mBAAmB,CAAEQ,UAAF,EAAc;AACzDE,IAAAA,QAAQ,EAAER;AAD+C,GAAd,CAA5C;AAIA,SACC,8BACC,cAAC,yBAAD;AACC,IAAA,UAAU,EAAGE,UADd;AAEC,IAAA,aAAa,EAAGC;AAFjB,IADD,EAKC,cAAC,OAAD,EAAcI,gBAAd,CALD,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CommentsInspectorControls from './edit/comments-inspector-controls';\n\nconst TEMPLATE = [\n\t[ 'core/comment-template' ],\n\t[ 'core/comments-pagination' ],\n];\n\nexport default function CommentsQueryLoopEdit( { attributes, setAttributes } ) {\n\tconst { tagName: TagName } = attributes;\n\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<CommentsInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
@@ -30,11 +30,16 @@ const metadata = {
30
30
  tagName: {
31
31
  type: "string",
32
32
  "default": "div"
33
+ },
34
+ defaultPage: {
35
+ type: "string",
36
+ "default": "oldest"
33
37
  }
34
38
  },
35
39
  providesContext: {
36
40
  "comments/perPage": "perPage",
37
41
  "comments/order": "order",
42
+ "comments/defaultPage": "defaultPage",
38
43
  "comments/inherit": "inherit"
39
44
  },
40
45
  supports: {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/index.js"],"names":["postComments","icon","edit","save","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,IAAIC,IAAzB,QAAqC,kBAArC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBL,EAAAA,IADuB;AAEvBC,EAAAA,IAFuB;AAGvBC,EAAAA;AAHuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postComments as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/index.js"],"names":["postComments","icon","edit","save","name","metadata","settings"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,IAAIC,IAAzB,QAAqC,kBAArC;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBL,EAAAA,IADuB;AAEvBC,EAAAA,IAFuB;AAGvBC,EAAAA;AAHuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postComments as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n"]}
@@ -56,11 +56,11 @@ function Controls(_ref) {
56
56
  const units = useCustomUnits({
57
57
  availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem', 'vw', 'vh'],
58
58
  defaultValues: {
59
- px: '430',
60
- em: '20',
61
- rem: '20',
62
- vw: '20',
63
- vh: '50'
59
+ px: 430,
60
+ em: 20,
61
+ rem: 20,
62
+ vw: 20,
63
+ vh: 50
64
64
  }
65
65
  });
66
66
  const onOpacityChange = useCallback(value => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/cover/controls.native.js"],"names":["View","Video","Image","Icon","IMAGE_DEFAULT_FOCAL_POINT","PanelBody","RangeControl","UnitControl","TextControl","BottomSheet","ToggleControl","__experimentalUseCustomUnits","useCustomUnits","plus","useState","useCallback","useRef","usePreferredColorSchemeStyle","useSetting","MediaUpload","__","styles","OverlayColorSettings","FocalPointSettingsButton","ALLOWED_MEDIA_TYPES","COVER_MIN_HEIGHT","COVER_MAX_HEIGHT","COVER_DEFAULT_HEIGHT","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","Controls","attributes","didUploadFail","hasOnlyColorBackground","isUploadInProgress","onClearMedia","onSelectMedia","setAttributes","backgroundType","dimRatio","hasParallax","focalPoint","minHeight","minHeightUnit","url","CONTAINER_HEIGHT","onHeightChange","value","units","availableUnits","defaultValues","px","em","rem","vw","vh","onOpacityChange","onChangeUnit","nextUnit","Math","max","displayPlaceholder","setDisplayPlaceholder","setFocalPoint","toggleParallax","undefined","addMediaButtonStyle","addMediaButton","addMediaButtonDark","focalPointPosition","x","y","left","top","videoNaturalSize","setVideoNaturalSize","videoRef","mediaBackground","mediaBackgroundDark","imagePreviewStyles","imagePlaceholder","videoPreviewStyles","aspectRatio","width","height","opacity","video","focalPointHint","renderMediaSection","open","openMediaOptions","getMediaOptions","mediaPreview","mediaInner","destructiveButton","id","label","onPress","separated","image","event","naturalSize","current","seek","uri","clearMediaButton","overlayColor","customOverlayColor","gradient","customGradient","rangeCellContainer"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AACA,OAAOC,KAAP,MAAkB,oBAAlB;AAEA;AACA;AACA;;AACA,SACCC,KADD,EAECC,IAFD,EAGCC,yBAHD,EAICC,SAJD,EAKCC,YALD,EAMCC,WAND,EAOCC,WAPD,EAQCC,WARD,EASCC,aATD,EAUCC,4BAA4B,IAAIC,cAVjC,QAWO,uBAXP;AAYA,SAASC,IAAT,QAAqB,kBAArB;AACA,SAASC,QAAT,EAAmBC,WAAnB,EAAgCC,MAAhC,QAA8C,oBAA9C;AACA,SAASC,4BAAT,QAA6C,oBAA7C;AACA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,yBAAxC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,wBAAP,MAAqC,+BAArC;AACA,SACCC,mBADD,EAECC,gBAFD,EAGCC,gBAHD,EAICC,oBAJD,EAKCC,qBALD,EAMCC,qBAND,QAOO,UAPP;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CD,CADD;AAiDA;;AAED,eAAeb,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\nimport Video from 'react-native-video';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tImage,\n\tIcon,\n\tIMAGE_DEFAULT_FOCAL_POINT,\n\tPanelBody,\n\tRangeControl,\n\tUnitControl,\n\tTextControl,\n\tBottomSheet,\n\tToggleControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { plus } from '@wordpress/icons';\nimport { useState, useCallback, useRef } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { useSetting, MediaUpload } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport OverlayColorSettings from './overlay-color-settings';\nimport FocalPointSettingsButton from './focal-point-settings-button';\nimport {\n\tALLOWED_MEDIA_TYPES,\n\tCOVER_MIN_HEIGHT,\n\tCOVER_MAX_HEIGHT,\n\tCOVER_DEFAULT_HEIGHT,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n} from './shared';\n\nfunction Controls( {\n\tattributes,\n\tdidUploadFail,\n\thasOnlyColorBackground,\n\tisUploadInProgress,\n\tonClearMedia,\n\tonSelectMedia,\n\tsetAttributes,\n} ) {\n\tconst {\n\t\tbackgroundType,\n\t\tdimRatio,\n\t\thasParallax,\n\t\tfocalPoint,\n\t\tminHeight,\n\t\tminHeightUnit = 'px',\n\t\turl,\n\t} = attributes;\n\tconst CONTAINER_HEIGHT = minHeight || COVER_DEFAULT_HEIGHT;\n\tconst onHeightChange = useCallback(\n\t\t( value ) => {\n\t\t\tif ( minHeight || value !== COVER_DEFAULT_HEIGHT ) {\n\t\t\t\tsetAttributes( { minHeight: value } );\n\t\t\t}\n\t\t},\n\t\t[ minHeight ]\n\t);\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: '430', em: '20', rem: '20', vw: '20', vh: '50' },\n\t} );\n\n\tconst onOpacityChange = useCallback( ( value ) => {\n\t\tsetAttributes( { dimRatio: value } );\n\t}, [] );\n\n\tconst onChangeUnit = useCallback( ( nextUnit ) => {\n\t\tsetAttributes( {\n\t\t\tminHeightUnit: nextUnit,\n\t\t\tminHeight:\n\t\t\t\tnextUnit === 'px'\n\t\t\t\t\t? Math.max( CONTAINER_HEIGHT, COVER_MIN_HEIGHT )\n\t\t\t\t\t: CONTAINER_HEIGHT,\n\t\t} );\n\t}, [] );\n\n\tconst [ displayPlaceholder, setDisplayPlaceholder ] = useState( true );\n\n\tfunction setFocalPoint( value ) {\n\t\tsetAttributes( { focalPoint: value } );\n\t}\n\n\tconst toggleParallax = () => {\n\t\tsetAttributes( {\n\t\t\thasParallax: ! hasParallax,\n\t\t\t...( ! hasParallax\n\t\t\t\t? { focalPoint: undefined }\n\t\t\t\t: { focalPoint: IMAGE_DEFAULT_FOCAL_POINT } ),\n\t\t} );\n\t};\n\n\tconst addMediaButtonStyle = usePreferredColorSchemeStyle(\n\t\tstyles.addMediaButton,\n\t\tstyles.addMediaButtonDark\n\t);\n\n\tfunction focalPointPosition( { x, y } = IMAGE_DEFAULT_FOCAL_POINT ) {\n\t\treturn {\n\t\t\tleft: `${ ( hasParallax ? 0.5 : x ) * 100 }%`,\n\t\t\ttop: `${ ( hasParallax ? 0.5 : y ) * 100 }%`,\n\t\t};\n\t}\n\n\tconst [ videoNaturalSize, setVideoNaturalSize ] = useState( null );\n\tconst videoRef = useRef( null );\n\n\tconst mediaBackground = usePreferredColorSchemeStyle(\n\t\tstyles.mediaBackground,\n\t\tstyles.mediaBackgroundDark\n\t);\n\tconst imagePreviewStyles = [\n\t\tdisplayPlaceholder && styles.imagePlaceholder,\n\t];\n\tconst videoPreviewStyles = [\n\t\t{\n\t\t\taspectRatio:\n\t\t\t\tvideoNaturalSize &&\n\t\t\t\tvideoNaturalSize.width / videoNaturalSize.height,\n\t\t\t// Hide Video component since it has black background while loading the source\n\t\t\topacity: displayPlaceholder ? 0 : 1,\n\t\t},\n\t\tstyles.video,\n\t\tdisplayPlaceholder && styles.imagePlaceholder,\n\t];\n\n\tconst focalPointHint = ! hasParallax && ! displayPlaceholder && (\n\t\t<Icon\n\t\t\ticon={ plus }\n\t\t\tsize={ styles.focalPointHint?.width }\n\t\t\tstyle={ [\n\t\t\t\tstyles.focalPointHint,\n\t\t\t\tfocalPointPosition( focalPoint ),\n\t\t\t] }\n\t\t/>\n\t);\n\n\tconst renderMediaSection = ( {\n\t\topen: openMediaOptions,\n\t\tgetMediaOptions,\n\t} ) => (\n\t\t<>\n\t\t\t{ getMediaOptions() }\n\t\t\t{ url ? (\n\t\t\t\t<>\n\t\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\t\taccessible={ false }\n\t\t\t\t\t\tcellContainerStyle={ [\n\t\t\t\t\t\t\tstyles.mediaPreview,\n\t\t\t\t\t\t\tmediaBackground,\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonLongPress={ openMediaOptions }\n\t\t\t\t\t>\n\t\t\t\t\t\t<View style={ styles.mediaInner }>\n\t\t\t\t\t\t\t{ IMAGE_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\t\t\teditButton={ ! displayPlaceholder }\n\t\t\t\t\t\t\t\t\thighlightSelected={ false }\n\t\t\t\t\t\t\t\t\tisSelected={ ! displayPlaceholder }\n\t\t\t\t\t\t\t\t\tisUploadFailed={ didUploadFail }\n\t\t\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\t\t\tmediaPickerOptions={ [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tdestructiveButton: true,\n\t\t\t\t\t\t\t\t\t\t\tid: 'clearMedia',\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Clear Media' ),\n\t\t\t\t\t\t\t\t\t\t\tonPress: onClearMedia,\n\t\t\t\t\t\t\t\t\t\t\tseparated: true,\n\t\t\t\t\t\t\t\t\t\t\tvalue: 'clearMedia',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\t\tonImageDataLoad={ () => {\n\t\t\t\t\t\t\t\t\t\tsetDisplayPlaceholder( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tonSelectMediaUploadOption={ onSelectMedia }\n\t\t\t\t\t\t\t\t\topenMediaOptions={ openMediaOptions }\n\t\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\t\theight=\"100%\"\n\t\t\t\t\t\t\t\t\tstyle={ imagePreviewStyles }\n\t\t\t\t\t\t\t\t\twidth={ styles.image?.width }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ VIDEO_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t\t\t\t<Video\n\t\t\t\t\t\t\t\t\tmuted\n\t\t\t\t\t\t\t\t\tpaused\n\t\t\t\t\t\t\t\t\tdisableFocus\n\t\t\t\t\t\t\t\t\tonLoadStart={ () => {\n\t\t\t\t\t\t\t\t\t\tsetDisplayPlaceholder( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\t\theight,\n\t\t\t\t\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\t\t\t\t} = event.naturalSize;\n\t\t\t\t\t\t\t\t\t\tsetVideoNaturalSize( {\n\t\t\t\t\t\t\t\t\t\t\theight,\n\t\t\t\t\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tsetDisplayPlaceholder( false );\n\t\t\t\t\t\t\t\t\t\t// Avoid invisible, paused video on Android, presumably\n\t\t\t\t\t\t\t\t\t\t// related to https://git.io/Jt6Dr\n\t\t\t\t\t\t\t\t\t\tvideoRef?.current.seek( 0 );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tref={ videoRef }\n\t\t\t\t\t\t\t\t\tresizeMode={ 'cover' }\n\t\t\t\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t\t\t\t\tstyle={ videoPreviewStyles }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ displayPlaceholder ? null : focalPointHint }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</BottomSheet.Cell>\n\t\t\t\t\t<FocalPointSettingsButton\n\t\t\t\t\t\tdisabled={ hasParallax }\n\t\t\t\t\t\tfocalPoint={ focalPoint || IMAGE_DEFAULT_FOCAL_POINT }\n\t\t\t\t\t\tonFocalPointChange={ setFocalPoint }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t/>\n\t\t\t\t\t{ IMAGE_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Fixed background' ) }\n\t\t\t\t\t\t\tchecked={ hasParallax }\n\t\t\t\t\t\t\tonChange={ toggleParallax }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tleftAlign\n\t\t\t\t\t\tlabel={ __( 'Clear Media' ) }\n\t\t\t\t\t\tlabelStyle={ styles.clearMediaButton }\n\t\t\t\t\t\tonPress={ onClearMedia }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<TextControl\n\t\t\t\t\taccessibilityLabel={ __( 'Add image or video' ) }\n\t\t\t\t\tlabel={ __( 'Add image or video' ) }\n\t\t\t\t\tlabelStyle={ addMediaButtonStyle }\n\t\t\t\t\tleftAlign\n\t\t\t\t\tonPress={ openMediaOptions }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Media' ) }>\n\t\t\t\t<MediaUpload\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tisReplacingMedia={ ! hasOnlyColorBackground }\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\trender={ renderMediaSection }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\n\t\t\t<OverlayColorSettings\n\t\t\t\toverlayColor={ attributes.overlayColor }\n\t\t\t\tcustomOverlayColor={ attributes.customOverlayColor }\n\t\t\t\tgradient={ attributes.gradient }\n\t\t\t\tcustomGradient={ attributes.customGradient }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\n\t\t\t{ url ? (\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Opacity' ) }\n\t\t\t\t\t\tminimumValue={ 0 }\n\t\t\t\t\t\tmaximumValue={ 100 }\n\t\t\t\t\t\tvalue={ dimRatio }\n\t\t\t\t\t\tonChange={ onOpacityChange }\n\t\t\t\t\t\tstyle={ styles.rangeCellContainer }\n\t\t\t\t\t\tseparatorType={ 'topFullWidth' }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t) : null }\n\n\t\t\t<PanelBody title={ __( 'Dimensions' ) }>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Minimum height' ) }\n\t\t\t\t\tmin={ minHeightUnit === 'px' ? COVER_MIN_HEIGHT : 1 }\n\t\t\t\t\tmax={ COVER_MAX_HEIGHT }\n\t\t\t\t\tunit={ minHeightUnit }\n\t\t\t\t\tvalue={ CONTAINER_HEIGHT }\n\t\t\t\t\tonChange={ onHeightChange }\n\t\t\t\t\tonUnitChange={ onChangeUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tstyle={ styles.rangeCellContainer }\n\t\t\t\t\tkey={ minHeightUnit }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</>\n\t);\n}\n\nexport default Controls;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/cover/controls.native.js"],"names":["View","Video","Image","Icon","IMAGE_DEFAULT_FOCAL_POINT","PanelBody","RangeControl","UnitControl","TextControl","BottomSheet","ToggleControl","__experimentalUseCustomUnits","useCustomUnits","plus","useState","useCallback","useRef","usePreferredColorSchemeStyle","useSetting","MediaUpload","__","styles","OverlayColorSettings","FocalPointSettingsButton","ALLOWED_MEDIA_TYPES","COVER_MIN_HEIGHT","COVER_MAX_HEIGHT","COVER_DEFAULT_HEIGHT","IMAGE_BACKGROUND_TYPE","VIDEO_BACKGROUND_TYPE","Controls","attributes","didUploadFail","hasOnlyColorBackground","isUploadInProgress","onClearMedia","onSelectMedia","setAttributes","backgroundType","dimRatio","hasParallax","focalPoint","minHeight","minHeightUnit","url","CONTAINER_HEIGHT","onHeightChange","value","units","availableUnits","defaultValues","px","em","rem","vw","vh","onOpacityChange","onChangeUnit","nextUnit","Math","max","displayPlaceholder","setDisplayPlaceholder","setFocalPoint","toggleParallax","undefined","addMediaButtonStyle","addMediaButton","addMediaButtonDark","focalPointPosition","x","y","left","top","videoNaturalSize","setVideoNaturalSize","videoRef","mediaBackground","mediaBackgroundDark","imagePreviewStyles","imagePlaceholder","videoPreviewStyles","aspectRatio","width","height","opacity","video","focalPointHint","renderMediaSection","open","openMediaOptions","getMediaOptions","mediaPreview","mediaInner","destructiveButton","id","label","onPress","separated","image","event","naturalSize","current","seek","uri","clearMediaButton","overlayColor","customOverlayColor","gradient","customGradient","rangeCellContainer"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AACA,OAAOC,KAAP,MAAkB,oBAAlB;AAEA;AACA;AACA;;AACA,SACCC,KADD,EAECC,IAFD,EAGCC,yBAHD,EAICC,SAJD,EAKCC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AAPjB,IADD,CADI,GAYD,IA9BL,EAgCC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAG1F,EAAE,CAAE,YAAF;AAArB,KACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGA,EAAE,CAAE,gBAAF,CADX;AAEC,IAAA,GAAG,EAAGuB,aAAa,KAAK,IAAlB,GAAyBlB,gBAAzB,GAA4C,CAFnD;AAGC,IAAA,GAAG,EAAGC,gBAHP;AAIC,IAAA,IAAI,EAAGiB,aAJR;AAKC,IAAA,KAAK,EAAGE,gBALT;AAMC,IAAA,QAAQ,EAAGC,cANZ;AAOC,IAAA,YAAY,EAAGW,YAPhB;AAQC,IAAA,KAAK,EAAGT,KART;AASC,IAAA,KAAK,EAAG3B,MAAM,CAACyF,kBAThB;AAUC,IAAA,GAAG,EAAGnE;AAVP,IADD,CAhCD,CADD;AAiDA;;AAED,eAAeb,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\nimport Video from 'react-native-video';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tImage,\n\tIcon,\n\tIMAGE_DEFAULT_FOCAL_POINT,\n\tPanelBody,\n\tRangeControl,\n\tUnitControl,\n\tTextControl,\n\tBottomSheet,\n\tToggleControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { plus } from '@wordpress/icons';\nimport { useState, useCallback, useRef } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { useSetting, MediaUpload } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport OverlayColorSettings from './overlay-color-settings';\nimport FocalPointSettingsButton from './focal-point-settings-button';\nimport {\n\tALLOWED_MEDIA_TYPES,\n\tCOVER_MIN_HEIGHT,\n\tCOVER_MAX_HEIGHT,\n\tCOVER_DEFAULT_HEIGHT,\n\tIMAGE_BACKGROUND_TYPE,\n\tVIDEO_BACKGROUND_TYPE,\n} from './shared';\n\nfunction Controls( {\n\tattributes,\n\tdidUploadFail,\n\thasOnlyColorBackground,\n\tisUploadInProgress,\n\tonClearMedia,\n\tonSelectMedia,\n\tsetAttributes,\n} ) {\n\tconst {\n\t\tbackgroundType,\n\t\tdimRatio,\n\t\thasParallax,\n\t\tfocalPoint,\n\t\tminHeight,\n\t\tminHeightUnit = 'px',\n\t\turl,\n\t} = attributes;\n\tconst CONTAINER_HEIGHT = minHeight || COVER_DEFAULT_HEIGHT;\n\tconst onHeightChange = useCallback(\n\t\t( value ) => {\n\t\t\tif ( minHeight || value !== COVER_DEFAULT_HEIGHT ) {\n\t\t\t\tsetAttributes( { minHeight: value } );\n\t\t\t}\n\t\t},\n\t\t[ minHeight ]\n\t);\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: 430, em: 20, rem: 20, vw: 20, vh: 50 },\n\t} );\n\n\tconst onOpacityChange = useCallback( ( value ) => {\n\t\tsetAttributes( { dimRatio: value } );\n\t}, [] );\n\n\tconst onChangeUnit = useCallback( ( nextUnit ) => {\n\t\tsetAttributes( {\n\t\t\tminHeightUnit: nextUnit,\n\t\t\tminHeight:\n\t\t\t\tnextUnit === 'px'\n\t\t\t\t\t? Math.max( CONTAINER_HEIGHT, COVER_MIN_HEIGHT )\n\t\t\t\t\t: CONTAINER_HEIGHT,\n\t\t} );\n\t}, [] );\n\n\tconst [ displayPlaceholder, setDisplayPlaceholder ] = useState( true );\n\n\tfunction setFocalPoint( value ) {\n\t\tsetAttributes( { focalPoint: value } );\n\t}\n\n\tconst toggleParallax = () => {\n\t\tsetAttributes( {\n\t\t\thasParallax: ! hasParallax,\n\t\t\t...( ! hasParallax\n\t\t\t\t? { focalPoint: undefined }\n\t\t\t\t: { focalPoint: IMAGE_DEFAULT_FOCAL_POINT } ),\n\t\t} );\n\t};\n\n\tconst addMediaButtonStyle = usePreferredColorSchemeStyle(\n\t\tstyles.addMediaButton,\n\t\tstyles.addMediaButtonDark\n\t);\n\n\tfunction focalPointPosition( { x, y } = IMAGE_DEFAULT_FOCAL_POINT ) {\n\t\treturn {\n\t\t\tleft: `${ ( hasParallax ? 0.5 : x ) * 100 }%`,\n\t\t\ttop: `${ ( hasParallax ? 0.5 : y ) * 100 }%`,\n\t\t};\n\t}\n\n\tconst [ videoNaturalSize, setVideoNaturalSize ] = useState( null );\n\tconst videoRef = useRef( null );\n\n\tconst mediaBackground = usePreferredColorSchemeStyle(\n\t\tstyles.mediaBackground,\n\t\tstyles.mediaBackgroundDark\n\t);\n\tconst imagePreviewStyles = [\n\t\tdisplayPlaceholder && styles.imagePlaceholder,\n\t];\n\tconst videoPreviewStyles = [\n\t\t{\n\t\t\taspectRatio:\n\t\t\t\tvideoNaturalSize &&\n\t\t\t\tvideoNaturalSize.width / videoNaturalSize.height,\n\t\t\t// Hide Video component since it has black background while loading the source\n\t\t\topacity: displayPlaceholder ? 0 : 1,\n\t\t},\n\t\tstyles.video,\n\t\tdisplayPlaceholder && styles.imagePlaceholder,\n\t];\n\n\tconst focalPointHint = ! hasParallax && ! displayPlaceholder && (\n\t\t<Icon\n\t\t\ticon={ plus }\n\t\t\tsize={ styles.focalPointHint?.width }\n\t\t\tstyle={ [\n\t\t\t\tstyles.focalPointHint,\n\t\t\t\tfocalPointPosition( focalPoint ),\n\t\t\t] }\n\t\t/>\n\t);\n\n\tconst renderMediaSection = ( {\n\t\topen: openMediaOptions,\n\t\tgetMediaOptions,\n\t} ) => (\n\t\t<>\n\t\t\t{ getMediaOptions() }\n\t\t\t{ url ? (\n\t\t\t\t<>\n\t\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\t\taccessible={ false }\n\t\t\t\t\t\tcellContainerStyle={ [\n\t\t\t\t\t\t\tstyles.mediaPreview,\n\t\t\t\t\t\t\tmediaBackground,\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonLongPress={ openMediaOptions }\n\t\t\t\t\t>\n\t\t\t\t\t\t<View style={ styles.mediaInner }>\n\t\t\t\t\t\t\t{ IMAGE_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t\t\t\t<Image\n\t\t\t\t\t\t\t\t\teditButton={ ! displayPlaceholder }\n\t\t\t\t\t\t\t\t\thighlightSelected={ false }\n\t\t\t\t\t\t\t\t\tisSelected={ ! displayPlaceholder }\n\t\t\t\t\t\t\t\t\tisUploadFailed={ didUploadFail }\n\t\t\t\t\t\t\t\t\tisUploadInProgress={ isUploadInProgress }\n\t\t\t\t\t\t\t\t\tmediaPickerOptions={ [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tdestructiveButton: true,\n\t\t\t\t\t\t\t\t\t\t\tid: 'clearMedia',\n\t\t\t\t\t\t\t\t\t\t\tlabel: __( 'Clear Media' ),\n\t\t\t\t\t\t\t\t\t\t\tonPress: onClearMedia,\n\t\t\t\t\t\t\t\t\t\t\tseparated: true,\n\t\t\t\t\t\t\t\t\t\t\tvalue: 'clearMedia',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\t\tonImageDataLoad={ () => {\n\t\t\t\t\t\t\t\t\t\tsetDisplayPlaceholder( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tonSelectMediaUploadOption={ onSelectMedia }\n\t\t\t\t\t\t\t\t\topenMediaOptions={ openMediaOptions }\n\t\t\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\t\t\theight=\"100%\"\n\t\t\t\t\t\t\t\t\tstyle={ imagePreviewStyles }\n\t\t\t\t\t\t\t\t\twidth={ styles.image?.width }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ VIDEO_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t\t\t\t<Video\n\t\t\t\t\t\t\t\t\tmuted\n\t\t\t\t\t\t\t\t\tpaused\n\t\t\t\t\t\t\t\t\tdisableFocus\n\t\t\t\t\t\t\t\t\tonLoadStart={ () => {\n\t\t\t\t\t\t\t\t\t\tsetDisplayPlaceholder( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tonLoad={ ( event ) => {\n\t\t\t\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\t\t\t\theight,\n\t\t\t\t\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\t\t\t\t} = event.naturalSize;\n\t\t\t\t\t\t\t\t\t\tsetVideoNaturalSize( {\n\t\t\t\t\t\t\t\t\t\t\theight,\n\t\t\t\t\t\t\t\t\t\t\twidth,\n\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\tsetDisplayPlaceholder( false );\n\t\t\t\t\t\t\t\t\t\t// Avoid invisible, paused video on Android, presumably\n\t\t\t\t\t\t\t\t\t\t// related to https://git.io/Jt6Dr\n\t\t\t\t\t\t\t\t\t\tvideoRef?.current.seek( 0 );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tref={ videoRef }\n\t\t\t\t\t\t\t\t\tresizeMode={ 'cover' }\n\t\t\t\t\t\t\t\t\tsource={ { uri: url } }\n\t\t\t\t\t\t\t\t\tstyle={ videoPreviewStyles }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ displayPlaceholder ? null : focalPointHint }\n\t\t\t\t\t\t</View>\n\t\t\t\t\t</BottomSheet.Cell>\n\t\t\t\t\t<FocalPointSettingsButton\n\t\t\t\t\t\tdisabled={ hasParallax }\n\t\t\t\t\t\tfocalPoint={ focalPoint || IMAGE_DEFAULT_FOCAL_POINT }\n\t\t\t\t\t\tonFocalPointChange={ setFocalPoint }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t/>\n\t\t\t\t\t{ IMAGE_BACKGROUND_TYPE === backgroundType && (\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\tlabel={ __( 'Fixed background' ) }\n\t\t\t\t\t\t\tchecked={ hasParallax }\n\t\t\t\t\t\t\tonChange={ toggleParallax }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tleftAlign\n\t\t\t\t\t\tlabel={ __( 'Clear Media' ) }\n\t\t\t\t\t\tlabelStyle={ styles.clearMediaButton }\n\t\t\t\t\t\tonPress={ onClearMedia }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<TextControl\n\t\t\t\t\taccessibilityLabel={ __( 'Add image or video' ) }\n\t\t\t\t\tlabel={ __( 'Add image or video' ) }\n\t\t\t\t\tlabelStyle={ addMediaButtonStyle }\n\t\t\t\t\tleftAlign\n\t\t\t\t\tonPress={ openMediaOptions }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Media' ) }>\n\t\t\t\t<MediaUpload\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tisReplacingMedia={ ! hasOnlyColorBackground }\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\trender={ renderMediaSection }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\n\t\t\t<OverlayColorSettings\n\t\t\t\toverlayColor={ attributes.overlayColor }\n\t\t\t\tcustomOverlayColor={ attributes.customOverlayColor }\n\t\t\t\tgradient={ attributes.gradient }\n\t\t\t\tcustomGradient={ attributes.customGradient }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t/>\n\n\t\t\t{ url ? (\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Opacity' ) }\n\t\t\t\t\t\tminimumValue={ 0 }\n\t\t\t\t\t\tmaximumValue={ 100 }\n\t\t\t\t\t\tvalue={ dimRatio }\n\t\t\t\t\t\tonChange={ onOpacityChange }\n\t\t\t\t\t\tstyle={ styles.rangeCellContainer }\n\t\t\t\t\t\tseparatorType={ 'topFullWidth' }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t) : null }\n\n\t\t\t<PanelBody title={ __( 'Dimensions' ) }>\n\t\t\t\t<UnitControl\n\t\t\t\t\tlabel={ __( 'Minimum height' ) }\n\t\t\t\t\tmin={ minHeightUnit === 'px' ? COVER_MIN_HEIGHT : 1 }\n\t\t\t\t\tmax={ COVER_MAX_HEIGHT }\n\t\t\t\t\tunit={ minHeightUnit }\n\t\t\t\t\tvalue={ CONTAINER_HEIGHT }\n\t\t\t\t\tonChange={ onHeightChange }\n\t\t\t\t\tonUnitChange={ onChangeUnit }\n\t\t\t\t\tunits={ units }\n\t\t\t\t\tstyle={ styles.rangeCellContainer }\n\t\t\t\t\tkey={ minHeightUnit }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</>\n\t);\n}\n\nexport default Controls;\n"]}