@wordpress/block-library 7.19.0 → 8.1.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 (862) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/audio/edit.native.js +1 -3
  3. package/build/audio/edit.native.js.map +1 -1
  4. package/build/audio/index.js +2 -1
  5. package/build/audio/index.js.map +1 -1
  6. package/build/avatar/edit.js +1 -0
  7. package/build/avatar/edit.js.map +1 -1
  8. package/build/avatar/user-control.js +1 -0
  9. package/build/avatar/user-control.js.map +1 -1
  10. package/build/block/edit.js +14 -2
  11. package/build/block/edit.js.map +1 -1
  12. package/build/block/edit.native.js +14 -6
  13. package/build/block/edit.native.js.map +1 -1
  14. package/build/block/index.js +1 -2
  15. package/build/block/index.js.map +1 -1
  16. package/build/button/edit.native.js.map +1 -1
  17. package/build/categories/edit.js +1 -1
  18. package/build/categories/edit.js.map +1 -1
  19. package/build/code/transforms.js +1 -1
  20. package/build/code/transforms.js.map +1 -1
  21. package/build/columns/edit.js +1 -0
  22. package/build/columns/edit.js.map +1 -1
  23. package/build/columns/edit.native.js +13 -30
  24. package/build/columns/edit.native.js.map +1 -1
  25. package/build/comment-author-avatar/edit.js +1 -0
  26. package/build/comment-author-avatar/edit.js.map +1 -1
  27. package/build/cover/edit/inspector-controls.js +3 -1
  28. package/build/cover/edit/inspector-controls.js.map +1 -1
  29. package/build/cover/edit.native.js +24 -16
  30. package/build/cover/edit.native.js.map +1 -1
  31. package/build/embed/embed-controls.native.js +1 -0
  32. package/build/embed/embed-controls.native.js.map +1 -1
  33. package/build/embed/embed-preview.native.js +1 -3
  34. package/build/embed/embed-preview.native.js.map +1 -1
  35. package/build/file/inspector.js +1 -0
  36. package/build/file/inspector.js.map +1 -1
  37. package/build/freeform/edit.js +21 -6
  38. package/build/freeform/edit.js.map +1 -1
  39. package/build/freeform/modal.js +97 -0
  40. package/build/freeform/modal.js.map +1 -0
  41. package/build/gallery/edit.js +38 -15
  42. package/build/gallery/edit.js.map +1 -1
  43. package/build/gallery/gallery.js +2 -16
  44. package/build/gallery/gallery.js.map +1 -1
  45. package/build/gallery/gallery.native.js +1 -3
  46. package/build/gallery/gallery.native.js.map +1 -1
  47. package/build/gallery/shared.js +4 -10
  48. package/build/gallery/shared.js.map +1 -1
  49. package/build/gallery/transforms.js +1 -7
  50. package/build/gallery/transforms.js.map +1 -1
  51. package/build/gallery/use-get-media.js +1 -1
  52. package/build/gallery/use-get-media.js.map +1 -1
  53. package/build/gallery/use-get-media.native.js +3 -1
  54. package/build/gallery/use-get-media.native.js.map +1 -1
  55. package/build/gallery/v1/edit.js +22 -15
  56. package/build/gallery/v1/edit.js.map +1 -1
  57. package/build/gallery/v1/gallery.native.js +1 -3
  58. package/build/gallery/v1/gallery.native.js.map +1 -1
  59. package/build/gallery/v1/shared.js +4 -1
  60. package/build/gallery/v1/shared.js.map +1 -1
  61. package/build/group/edit.js +1 -2
  62. package/build/group/edit.js.map +1 -1
  63. package/build/group/index.js +3 -1
  64. package/build/group/index.js.map +1 -1
  65. package/build/group/placeholder.js +5 -26
  66. package/build/group/placeholder.js.map +1 -1
  67. package/build/heading/deprecated.js +152 -69
  68. package/build/heading/deprecated.js.map +1 -1
  69. package/build/heading/index.js +1 -2
  70. package/build/heading/index.js.map +1 -1
  71. package/build/heading/transforms.js +1 -2
  72. package/build/heading/transforms.js.map +1 -1
  73. package/build/html/index.js +1 -1
  74. package/build/image/edit.js +8 -5
  75. package/build/image/edit.js.map +1 -1
  76. package/build/image/edit.native.js +3 -2
  77. package/build/image/edit.native.js.map +1 -1
  78. package/build/image/image.js +13 -8
  79. package/build/image/image.js.map +1 -1
  80. package/build/index.js +3 -1
  81. package/build/index.js.map +1 -1
  82. package/build/latest-comments/edit.js +1 -0
  83. package/build/latest-comments/edit.js.map +1 -1
  84. package/build/latest-posts/edit.js +2 -0
  85. package/build/latest-posts/edit.js.map +1 -1
  86. package/build/list/transforms.js +1 -9
  87. package/build/list/transforms.js.map +1 -1
  88. package/build/list/utils.js +5 -2
  89. package/build/list/utils.js.map +1 -1
  90. package/build/list-item/index.js +4 -1
  91. package/build/list-item/index.js.map +1 -1
  92. package/build/list-item/transforms.js +22 -0
  93. package/build/list-item/transforms.js.map +1 -0
  94. package/build/list-item/utils.js +77 -1
  95. package/build/list-item/utils.js.map +1 -1
  96. package/build/media-text/edit.js +5 -2
  97. package/build/media-text/edit.js.map +1 -1
  98. package/build/missing/edit.native.js +2 -2
  99. package/build/missing/edit.native.js.map +1 -1
  100. package/build/navigation/edit/are-blocks-dirty.js +52 -0
  101. package/build/navigation/edit/are-blocks-dirty.js.map +1 -0
  102. package/build/navigation/edit/index.js +95 -117
  103. package/build/navigation/edit/index.js.map +1 -1
  104. package/build/navigation/edit/menu-inspector-controls.js +94 -0
  105. package/build/navigation/edit/menu-inspector-controls.js.map +1 -0
  106. package/build/navigation/edit/navigation-menu-selector.js +2 -4
  107. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  108. package/build/navigation/edit/unsaved-inner-blocks.js +11 -7
  109. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  110. package/build/navigation/edit/utils.js +81 -0
  111. package/build/navigation/edit/utils.js.map +1 -1
  112. package/build/navigation/view-modal.js +6 -2
  113. package/build/navigation/view-modal.js.map +1 -1
  114. package/build/navigation-link/edit.js +46 -356
  115. package/build/navigation-link/edit.js.map +1 -1
  116. package/build/navigation-link/link-ui.js +222 -0
  117. package/build/navigation-link/link-ui.js.map +1 -0
  118. package/build/navigation-link/transforms.js +12 -0
  119. package/build/navigation-link/transforms.js.map +1 -1
  120. package/build/navigation-link/update-attributes.js +108 -0
  121. package/build/navigation-link/update-attributes.js.map +1 -0
  122. package/build/navigation-submenu/edit.js +49 -245
  123. package/build/navigation-submenu/edit.js.map +1 -1
  124. package/build/page-list/constants.js +15 -0
  125. package/build/page-list/constants.js.map +1 -0
  126. package/build/page-list/convert-to-links-modal.js +22 -86
  127. package/build/page-list/convert-to-links-modal.js.map +1 -1
  128. package/build/page-list/convert-to-navigation-links.js +76 -0
  129. package/build/page-list/convert-to-navigation-links.js.map +1 -0
  130. package/build/page-list/edit.js +143 -78
  131. package/build/page-list/edit.js.map +1 -1
  132. package/build/page-list/index.js +35 -3
  133. package/build/page-list/index.js.map +1 -1
  134. package/build/page-list-item/edit.js +91 -0
  135. package/build/page-list-item/edit.js.map +1 -0
  136. package/build/page-list-item/index.js +85 -0
  137. package/build/page-list-item/index.js.map +1 -0
  138. package/build/page-list-item/init.js +16 -0
  139. package/build/page-list-item/init.js.map +1 -0
  140. package/build/paragraph/index.js +1 -7
  141. package/build/paragraph/index.js.map +1 -1
  142. package/build/post-author/edit.js +3 -2
  143. package/build/post-author/edit.js.map +1 -1
  144. package/build/post-featured-image/overlay.js +1 -1
  145. package/build/post-featured-image/overlay.js.map +1 -1
  146. package/build/post-template/index.js +8 -0
  147. package/build/post-template/index.js.map +1 -1
  148. package/build/preformatted/transforms.js +3 -1
  149. package/build/preformatted/transforms.js.map +1 -1
  150. package/build/query/deprecated.js +192 -21
  151. package/build/query/deprecated.js.map +1 -1
  152. package/build/query/edit/index.js +2 -1
  153. package/build/query/edit/index.js.map +1 -1
  154. package/build/query/edit/inspector-controls/index.js +11 -5
  155. package/build/query/edit/inspector-controls/index.js.map +1 -1
  156. package/build/query/edit/inspector-controls/taxonomy-controls.js +101 -37
  157. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  158. package/build/query/edit/query-content.js +2 -3
  159. package/build/query/edit/query-content.js.map +1 -1
  160. package/build/query/edit/query-placeholder.js +16 -27
  161. package/build/query/edit/query-placeholder.js.map +1 -1
  162. package/build/query/index.js +0 -8
  163. package/build/query/index.js.map +1 -1
  164. package/build/query/utils.js +73 -9
  165. package/build/query/utils.js.map +1 -1
  166. package/build/rss/edit.js +3 -0
  167. package/build/rss/edit.js.map +1 -1
  168. package/build/search/edit.js +2 -2
  169. package/build/search/edit.js.map +1 -1
  170. package/build/search/edit.native.js +22 -22
  171. package/build/search/edit.native.js.map +1 -1
  172. package/build/search/index.js +9 -1
  173. package/build/search/index.js.map +1 -1
  174. package/build/site-logo/edit.js +17 -9
  175. package/build/site-logo/edit.js.map +1 -1
  176. package/build/site-logo/index.js +1 -0
  177. package/build/site-logo/index.js.map +1 -1
  178. package/build/site-title/index.js +1 -0
  179. package/build/site-title/index.js.map +1 -1
  180. package/build/social-link/edit.js.map +1 -1
  181. package/build/social-link/social-list.js +4 -12
  182. package/build/social-link/social-list.js.map +1 -1
  183. package/build/social-links/edit.js +0 -1
  184. package/build/social-links/edit.js.map +1 -1
  185. package/build/table/edit.js +3 -1
  186. package/build/table/edit.js.map +1 -1
  187. package/build/table/index.js +17 -1
  188. package/build/table/index.js.map +1 -1
  189. package/build/table/save.js +4 -2
  190. package/build/table/save.js.map +1 -1
  191. package/build/table/state.js +24 -12
  192. package/build/table/state.js.map +1 -1
  193. package/build/table/transforms.js +3 -2
  194. package/build/table/transforms.js.map +1 -1
  195. package/build/table-of-contents/edit.js +3 -3
  196. package/build/table-of-contents/edit.js.map +1 -1
  197. package/build/tag-cloud/edit.js +2 -1
  198. package/build/tag-cloud/edit.js.map +1 -1
  199. package/build/template-part/edit/advanced-controls.js +11 -1
  200. package/build/template-part/edit/advanced-controls.js.map +1 -1
  201. package/build/template-part/edit/import-controls.js +160 -0
  202. package/build/template-part/edit/import-controls.js.map +1 -0
  203. package/build/template-part/edit/index.js +2 -1
  204. package/build/template-part/edit/index.js.map +1 -1
  205. package/build/template-part/edit/selection-modal.js +5 -2
  206. package/build/template-part/edit/selection-modal.js.map +1 -1
  207. package/build/template-part/edit/utils/hooks.js +2 -6
  208. package/build/template-part/edit/utils/hooks.js.map +1 -1
  209. package/build/template-part/edit/utils/transformers.js +48 -0
  210. package/build/template-part/edit/utils/transformers.js.map +1 -0
  211. package/build/text-columns/edit.js +1 -0
  212. package/build/text-columns/edit.js.map +1 -1
  213. package/build/utils/transformation-categories.native.js +1 -1
  214. package/build/utils/transformation-categories.native.js.map +1 -1
  215. package/build/video/edit.js +1 -1
  216. package/build/video/edit.js.map +1 -1
  217. package/build/video/edit.native.js +1 -3
  218. package/build/video/edit.native.js.map +1 -1
  219. package/build-module/audio/edit.native.js +1 -2
  220. package/build-module/audio/edit.native.js.map +1 -1
  221. package/build-module/audio/index.js +2 -1
  222. package/build-module/audio/index.js.map +1 -1
  223. package/build-module/avatar/edit.js +1 -0
  224. package/build-module/avatar/edit.js.map +1 -1
  225. package/build-module/avatar/user-control.js +1 -0
  226. package/build-module/avatar/user-control.js.map +1 -1
  227. package/build-module/block/edit.js +14 -2
  228. package/build-module/block/edit.js.map +1 -1
  229. package/build-module/block/edit.native.js +14 -6
  230. package/build-module/block/edit.native.js.map +1 -1
  231. package/build-module/block/index.js +1 -2
  232. package/build-module/block/index.js.map +1 -1
  233. package/build-module/button/edit.native.js +2 -1
  234. package/build-module/button/edit.native.js.map +1 -1
  235. package/build-module/categories/edit.js +1 -1
  236. package/build-module/categories/edit.js.map +1 -1
  237. package/build-module/code/transforms.js +1 -1
  238. package/build-module/code/transforms.js.map +1 -1
  239. package/build-module/columns/edit.js +1 -0
  240. package/build-module/columns/edit.js.map +1 -1
  241. package/build-module/columns/edit.native.js +13 -29
  242. package/build-module/columns/edit.native.js.map +1 -1
  243. package/build-module/comment-author-avatar/edit.js +1 -0
  244. package/build-module/comment-author-avatar/edit.js.map +1 -1
  245. package/build-module/cover/edit/inspector-controls.js +5 -3
  246. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  247. package/build-module/cover/edit.native.js +22 -14
  248. package/build-module/cover/edit.native.js.map +1 -1
  249. package/build-module/embed/embed-controls.native.js +2 -1
  250. package/build-module/embed/embed-controls.native.js.map +1 -1
  251. package/build-module/embed/embed-preview.native.js +1 -2
  252. package/build-module/embed/embed-preview.native.js.map +1 -1
  253. package/build-module/file/inspector.js +1 -0
  254. package/build-module/file/inspector.js.map +1 -1
  255. package/build-module/freeform/edit.js +22 -8
  256. package/build-module/freeform/edit.js.map +1 -1
  257. package/build-module/freeform/modal.js +90 -0
  258. package/build-module/freeform/modal.js.map +1 -0
  259. package/build-module/gallery/edit.js +39 -15
  260. package/build-module/gallery/edit.js.map +1 -1
  261. package/build-module/gallery/gallery.js +3 -16
  262. package/build-module/gallery/gallery.js.map +1 -1
  263. package/build-module/gallery/gallery.native.js +1 -2
  264. package/build-module/gallery/gallery.native.js.map +1 -1
  265. package/build-module/gallery/shared.js +5 -11
  266. package/build-module/gallery/shared.js.map +1 -1
  267. package/build-module/gallery/transforms.js +1 -6
  268. package/build-module/gallery/transforms.js.map +1 -1
  269. package/build-module/gallery/use-get-media.js +1 -1
  270. package/build-module/gallery/use-get-media.js.map +1 -1
  271. package/build-module/gallery/use-get-media.native.js +3 -1
  272. package/build-module/gallery/use-get-media.native.js.map +1 -1
  273. package/build-module/gallery/v1/edit.js +23 -16
  274. package/build-module/gallery/v1/edit.js.map +1 -1
  275. package/build-module/gallery/v1/gallery.native.js +1 -2
  276. package/build-module/gallery/v1/gallery.native.js.map +1 -1
  277. package/build-module/gallery/v1/shared.js +5 -2
  278. package/build-module/gallery/v1/shared.js.map +1 -1
  279. package/build-module/group/edit.js +1 -3
  280. package/build-module/group/edit.js.map +1 -1
  281. package/build-module/group/index.js +3 -1
  282. package/build-module/group/index.js.map +1 -1
  283. package/build-module/group/placeholder.js +5 -26
  284. package/build-module/group/placeholder.js.map +1 -1
  285. package/build-module/heading/deprecated.js +152 -69
  286. package/build-module/heading/deprecated.js.map +1 -1
  287. package/build-module/heading/index.js +1 -2
  288. package/build-module/heading/index.js.map +1 -1
  289. package/build-module/heading/transforms.js +1 -2
  290. package/build-module/heading/transforms.js.map +1 -1
  291. package/build-module/html/index.js +1 -1
  292. package/build-module/image/edit.js +9 -6
  293. package/build-module/image/edit.js.map +1 -1
  294. package/build-module/image/edit.native.js +2 -1
  295. package/build-module/image/edit.native.js.map +1 -1
  296. package/build-module/image/image.js +14 -9
  297. package/build-module/image/image.js.map +1 -1
  298. package/build-module/index.js +2 -1
  299. package/build-module/index.js.map +1 -1
  300. package/build-module/latest-comments/edit.js +1 -0
  301. package/build-module/latest-comments/edit.js.map +1 -1
  302. package/build-module/latest-posts/edit.js +2 -0
  303. package/build-module/latest-posts/edit.js.map +1 -1
  304. package/build-module/list/transforms.js +1 -9
  305. package/build-module/list/transforms.js.map +1 -1
  306. package/build-module/list/utils.js +5 -2
  307. package/build-module/list/utils.js.map +1 -1
  308. package/build-module/list-item/index.js +3 -1
  309. package/build-module/list-item/index.js.map +1 -1
  310. package/build-module/list-item/transforms.js +13 -0
  311. package/build-module/list-item/transforms.js.map +1 -0
  312. package/build-module/list-item/utils.js +78 -1
  313. package/build-module/list-item/utils.js.map +1 -1
  314. package/build-module/media-text/edit.js +6 -3
  315. package/build-module/media-text/edit.js.map +1 -1
  316. package/build-module/missing/edit.native.js +2 -2
  317. package/build-module/missing/edit.native.js.map +1 -1
  318. package/build-module/navigation/edit/are-blocks-dirty.js +44 -0
  319. package/build-module/navigation/edit/are-blocks-dirty.js.map +1 -0
  320. package/build-module/navigation/edit/index.js +95 -118
  321. package/build-module/navigation/edit/index.js.map +1 -1
  322. package/build-module/navigation/edit/menu-inspector-controls.js +80 -0
  323. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -0
  324. package/build-module/navigation/edit/navigation-menu-selector.js +2 -4
  325. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  326. package/build-module/navigation/edit/unsaved-inner-blocks.js +9 -6
  327. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  328. package/build-module/navigation/edit/utils.js +75 -0
  329. package/build-module/navigation/edit/utils.js.map +1 -1
  330. package/build-module/navigation/view-modal.js +6 -2
  331. package/build-module/navigation/view-modal.js.map +1 -1
  332. package/build-module/navigation-link/edit.js +49 -357
  333. package/build-module/navigation-link/edit.js.map +1 -1
  334. package/build-module/navigation-link/link-ui.js +206 -0
  335. package/build-module/navigation-link/link-ui.js.map +1 -0
  336. package/build-module/navigation-link/transforms.js +12 -0
  337. package/build-module/navigation-link/transforms.js.map +1 -1
  338. package/build-module/navigation-link/update-attributes.js +97 -0
  339. package/build-module/navigation-link/update-attributes.js.map +1 -0
  340. package/build-module/navigation-submenu/edit.js +52 -246
  341. package/build-module/navigation-submenu/edit.js.map +1 -1
  342. package/build-module/page-list/constants.js +6 -0
  343. package/build-module/page-list/constants.js.map +1 -0
  344. package/build-module/page-list/convert-to-links-modal.js +20 -81
  345. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  346. package/build-module/page-list/convert-to-navigation-links.js +66 -0
  347. package/build-module/page-list/convert-to-navigation-links.js.map +1 -0
  348. package/build-module/page-list/edit.js +146 -82
  349. package/build-module/page-list/edit.js.map +1 -1
  350. package/build-module/page-list/index.js +36 -4
  351. package/build-module/page-list/index.js.map +1 -1
  352. package/build-module/page-list-item/edit.js +77 -0
  353. package/build-module/page-list-item/edit.js.map +1 -0
  354. package/build-module/page-list-item/index.js +68 -0
  355. package/build-module/page-list-item/index.js.map +1 -0
  356. package/build-module/page-list-item/init.js +6 -0
  357. package/build-module/page-list-item/init.js.map +1 -0
  358. package/build-module/paragraph/index.js +1 -7
  359. package/build-module/paragraph/index.js.map +1 -1
  360. package/build-module/post-author/edit.js +3 -2
  361. package/build-module/post-author/edit.js.map +1 -1
  362. package/build-module/post-featured-image/overlay.js +1 -1
  363. package/build-module/post-featured-image/overlay.js.map +1 -1
  364. package/build-module/post-template/index.js +8 -0
  365. package/build-module/post-template/index.js.map +1 -1
  366. package/build-module/preformatted/transforms.js +3 -1
  367. package/build-module/preformatted/transforms.js.map +1 -1
  368. package/build-module/query/deprecated.js +185 -21
  369. package/build-module/query/deprecated.js.map +1 -1
  370. package/build-module/query/edit/index.js +2 -1
  371. package/build-module/query/edit/index.js.map +1 -1
  372. package/build-module/query/edit/inspector-controls/index.js +11 -5
  373. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  374. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +99 -35
  375. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  376. package/build-module/query/edit/query-content.js +1 -1
  377. package/build-module/query/edit/query-content.js.map +1 -1
  378. package/build-module/query/edit/query-placeholder.js +15 -27
  379. package/build-module/query/edit/query-placeholder.js.map +1 -1
  380. package/build-module/query/index.js +0 -8
  381. package/build-module/query/index.js.map +1 -1
  382. package/build-module/query/utils.js +69 -8
  383. package/build-module/query/utils.js.map +1 -1
  384. package/build-module/rss/edit.js +3 -0
  385. package/build-module/rss/edit.js.map +1 -1
  386. package/build-module/search/edit.js +2 -2
  387. package/build-module/search/edit.js.map +1 -1
  388. package/build-module/search/edit.native.js +20 -20
  389. package/build-module/search/edit.native.js.map +1 -1
  390. package/build-module/search/index.js +8 -1
  391. package/build-module/search/index.js.map +1 -1
  392. package/build-module/site-logo/edit.js +17 -8
  393. package/build-module/site-logo/edit.js.map +1 -1
  394. package/build-module/site-logo/index.js +1 -0
  395. package/build-module/site-logo/index.js.map +1 -1
  396. package/build-module/site-title/index.js +1 -0
  397. package/build-module/site-title/index.js.map +1 -1
  398. package/build-module/social-link/edit.js +2 -2
  399. package/build-module/social-link/edit.js.map +1 -1
  400. package/build-module/social-link/social-list.js +2 -11
  401. package/build-module/social-link/social-list.js.map +1 -1
  402. package/build-module/social-links/edit.js +0 -1
  403. package/build-module/social-links/edit.js.map +1 -1
  404. package/build-module/table/edit.js +3 -1
  405. package/build-module/table/edit.js.map +1 -1
  406. package/build-module/table/index.js +17 -1
  407. package/build-module/table/index.js.map +1 -1
  408. package/build-module/table/save.js +4 -2
  409. package/build-module/table/save.js.map +1 -1
  410. package/build-module/table/state.js +25 -13
  411. package/build-module/table/state.js.map +1 -1
  412. package/build-module/table/transforms.js +3 -2
  413. package/build-module/table/transforms.js.map +1 -1
  414. package/build-module/table-of-contents/edit.js +3 -3
  415. package/build-module/table-of-contents/edit.js.map +1 -1
  416. package/build-module/tag-cloud/edit.js +3 -2
  417. package/build-module/tag-cloud/edit.js.map +1 -1
  418. package/build-module/template-part/edit/advanced-controls.js +10 -1
  419. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  420. package/build-module/template-part/edit/import-controls.js +146 -0
  421. package/build-module/template-part/edit/import-controls.js.map +1 -0
  422. package/build-module/template-part/edit/index.js +2 -1
  423. package/build-module/template-part/edit/index.js.map +1 -1
  424. package/build-module/template-part/edit/selection-modal.js +6 -3
  425. package/build-module/template-part/edit/selection-modal.js.map +1 -1
  426. package/build-module/template-part/edit/utils/hooks.js +3 -7
  427. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  428. package/build-module/template-part/edit/utils/transformers.js +40 -0
  429. package/build-module/template-part/edit/utils/transformers.js.map +1 -0
  430. package/build-module/text-columns/edit.js +1 -0
  431. package/build-module/text-columns/edit.js.map +1 -1
  432. package/build-module/utils/transformation-categories.native.js +1 -1
  433. package/build-module/utils/transformation-categories.native.js.map +1 -1
  434. package/build-module/video/edit.js +1 -1
  435. package/build-module/video/edit.js.map +1 -1
  436. package/build-module/video/edit.native.js +1 -2
  437. package/build-module/video/edit.native.js.map +1 -1
  438. package/build-style/archives/editor-rtl.css +15 -3
  439. package/build-style/archives/editor.css +15 -3
  440. package/build-style/archives/style-rtl.css +15 -3
  441. package/build-style/archives/style.css +15 -3
  442. package/build-style/audio/editor-rtl.css +15 -3
  443. package/build-style/audio/editor.css +15 -3
  444. package/build-style/audio/style-rtl.css +15 -3
  445. package/build-style/audio/style.css +15 -3
  446. package/build-style/audio/theme-rtl.css +15 -3
  447. package/build-style/audio/theme.css +15 -3
  448. package/build-style/avatar/editor-rtl.css +15 -3
  449. package/build-style/avatar/editor.css +15 -3
  450. package/build-style/avatar/style-rtl.css +15 -3
  451. package/build-style/avatar/style.css +15 -3
  452. package/build-style/block/editor-rtl.css +25 -3
  453. package/build-style/block/editor.css +25 -3
  454. package/build-style/button/editor-rtl.css +15 -3
  455. package/build-style/button/editor.css +15 -3
  456. package/build-style/button/style-rtl.css +15 -3
  457. package/build-style/button/style.css +15 -3
  458. package/build-style/buttons/editor-rtl.css +15 -3
  459. package/build-style/buttons/editor.css +15 -3
  460. package/build-style/buttons/style-rtl.css +15 -3
  461. package/build-style/buttons/style.css +15 -3
  462. package/build-style/calendar/style-rtl.css +15 -3
  463. package/build-style/calendar/style.css +15 -3
  464. package/build-style/categories/editor-rtl.css +15 -3
  465. package/build-style/categories/editor.css +15 -3
  466. package/build-style/categories/style-rtl.css +15 -3
  467. package/build-style/categories/style.css +15 -3
  468. package/build-style/classic-rtl.css +15 -3
  469. package/build-style/classic.css +15 -3
  470. package/build-style/code/editor-rtl.css +15 -3
  471. package/build-style/code/editor.css +15 -3
  472. package/build-style/code/style-rtl.css +15 -3
  473. package/build-style/code/style.css +15 -3
  474. package/build-style/code/theme-rtl.css +15 -3
  475. package/build-style/code/theme.css +15 -3
  476. package/build-style/columns/editor-rtl.css +15 -3
  477. package/build-style/columns/editor.css +15 -3
  478. package/build-style/columns/style-rtl.css +15 -3
  479. package/build-style/columns/style.css +15 -3
  480. package/build-style/comment-author-avatar/editor-rtl.css +15 -3
  481. package/build-style/comment-author-avatar/editor.css +15 -3
  482. package/build-style/comment-content/style-rtl.css +15 -3
  483. package/build-style/comment-content/style.css +15 -3
  484. package/build-style/comment-template/style-rtl.css +15 -3
  485. package/build-style/comment-template/style.css +15 -3
  486. package/build-style/comments/editor-rtl.css +15 -3
  487. package/build-style/comments/editor.css +15 -3
  488. package/build-style/comments/style-rtl.css +15 -3
  489. package/build-style/comments/style.css +15 -3
  490. package/build-style/comments-pagination/editor-rtl.css +15 -3
  491. package/build-style/comments-pagination/editor.css +15 -3
  492. package/build-style/comments-pagination/style-rtl.css +15 -3
  493. package/build-style/comments-pagination/style.css +15 -3
  494. package/build-style/comments-pagination-numbers/editor-rtl.css +15 -3
  495. package/build-style/comments-pagination-numbers/editor.css +15 -3
  496. package/build-style/comments-title/editor-rtl.css +15 -3
  497. package/build-style/comments-title/editor.css +15 -3
  498. package/build-style/common-rtl.css +20 -4
  499. package/build-style/common.css +20 -4
  500. package/build-style/cover/editor-rtl.css +15 -3
  501. package/build-style/cover/editor.css +15 -3
  502. package/build-style/cover/style-rtl.css +17 -4
  503. package/build-style/cover/style.css +17 -4
  504. package/build-style/editor-elements-rtl.css +15 -3
  505. package/build-style/editor-elements.css +15 -3
  506. package/build-style/editor-rtl.css +46 -29
  507. package/build-style/editor.css +46 -29
  508. package/build-style/elements-rtl.css +15 -3
  509. package/build-style/elements.css +15 -3
  510. package/build-style/embed/editor-rtl.css +15 -3
  511. package/build-style/embed/editor.css +15 -3
  512. package/build-style/embed/style-rtl.css +15 -3
  513. package/build-style/embed/style.css +15 -3
  514. package/build-style/embed/theme-rtl.css +15 -3
  515. package/build-style/embed/theme.css +15 -3
  516. package/build-style/file/editor-rtl.css +15 -3
  517. package/build-style/file/editor.css +15 -3
  518. package/build-style/file/style-rtl.css +15 -3
  519. package/build-style/file/style.css +15 -3
  520. package/build-style/freeform/editor-rtl.css +15 -3
  521. package/build-style/freeform/editor.css +15 -3
  522. package/build-style/gallery/editor-rtl.css +16 -4
  523. package/build-style/gallery/editor.css +16 -4
  524. package/build-style/gallery/style-rtl.css +19 -5
  525. package/build-style/gallery/style.css +19 -5
  526. package/build-style/gallery/theme-rtl.css +15 -3
  527. package/build-style/gallery/theme.css +15 -3
  528. package/build-style/group/editor-rtl.css +15 -3
  529. package/build-style/group/editor.css +15 -3
  530. package/build-style/group/style-rtl.css +15 -3
  531. package/build-style/group/style.css +15 -3
  532. package/build-style/group/theme-rtl.css +15 -3
  533. package/build-style/group/theme.css +15 -3
  534. package/build-style/heading/style-rtl.css +15 -3
  535. package/build-style/heading/style.css +15 -3
  536. package/build-style/html/editor-rtl.css +15 -3
  537. package/build-style/html/editor.css +15 -3
  538. package/build-style/image/editor-rtl.css +15 -12
  539. package/build-style/image/editor.css +15 -12
  540. package/build-style/image/style-rtl.css +15 -3
  541. package/build-style/image/style.css +15 -3
  542. package/build-style/image/theme-rtl.css +15 -3
  543. package/build-style/image/theme.css +15 -3
  544. package/build-style/latest-comments/style-rtl.css +15 -3
  545. package/build-style/latest-comments/style.css +15 -3
  546. package/build-style/latest-posts/editor-rtl.css +15 -3
  547. package/build-style/latest-posts/editor.css +15 -3
  548. package/build-style/latest-posts/style-rtl.css +15 -3
  549. package/build-style/latest-posts/style.css +15 -3
  550. package/build-style/list/style-rtl.css +15 -3
  551. package/build-style/list/style.css +15 -3
  552. package/build-style/media-text/editor-rtl.css +15 -3
  553. package/build-style/media-text/editor.css +15 -3
  554. package/build-style/media-text/style-rtl.css +15 -3
  555. package/build-style/media-text/style.css +15 -3
  556. package/build-style/more/editor-rtl.css +15 -3
  557. package/build-style/more/editor.css +15 -3
  558. package/build-style/navigation/editor-rtl.css +15 -9
  559. package/build-style/navigation/editor.css +15 -9
  560. package/build-style/navigation/style-rtl.css +15 -4
  561. package/build-style/navigation/style.css +15 -4
  562. package/build-style/navigation-link/editor-rtl.css +15 -3
  563. package/build-style/navigation-link/editor.css +15 -3
  564. package/build-style/navigation-link/style-rtl.css +15 -3
  565. package/build-style/navigation-link/style.css +15 -3
  566. package/build-style/navigation-submenu/editor-rtl.css +15 -3
  567. package/build-style/navigation-submenu/editor.css +15 -3
  568. package/build-style/nextpage/editor-rtl.css +15 -3
  569. package/build-style/nextpage/editor.css +15 -3
  570. package/build-style/page-list/editor-rtl.css +19 -3
  571. package/build-style/page-list/editor.css +19 -3
  572. package/build-style/page-list/style-rtl.css +15 -3
  573. package/build-style/page-list/style.css +15 -3
  574. package/build-style/paragraph/editor-rtl.css +15 -3
  575. package/build-style/paragraph/editor.css +15 -3
  576. package/build-style/paragraph/style-rtl.css +15 -3
  577. package/build-style/paragraph/style.css +15 -3
  578. package/build-style/post-author/style-rtl.css +15 -3
  579. package/build-style/post-author/style.css +15 -3
  580. package/build-style/post-comments-form/editor-rtl.css +15 -3
  581. package/build-style/post-comments-form/editor.css +15 -3
  582. package/build-style/post-comments-form/style-rtl.css +15 -3
  583. package/build-style/post-comments-form/style.css +15 -3
  584. package/build-style/post-date/style-rtl.css +15 -3
  585. package/build-style/post-date/style.css +15 -3
  586. package/build-style/post-excerpt/editor-rtl.css +15 -3
  587. package/build-style/post-excerpt/editor.css +15 -3
  588. package/build-style/post-excerpt/style-rtl.css +15 -3
  589. package/build-style/post-excerpt/style.css +15 -3
  590. package/build-style/post-featured-image/editor-rtl.css +15 -3
  591. package/build-style/post-featured-image/editor.css +15 -3
  592. package/build-style/post-featured-image/style-rtl.css +15 -3
  593. package/build-style/post-featured-image/style.css +15 -3
  594. package/build-style/post-navigation-link/style-rtl.css +15 -3
  595. package/build-style/post-navigation-link/style.css +15 -3
  596. package/build-style/post-template/editor-rtl.css +15 -3
  597. package/build-style/post-template/editor.css +15 -3
  598. package/build-style/post-template/style-rtl.css +15 -3
  599. package/build-style/post-template/style.css +15 -3
  600. package/build-style/post-terms/style-rtl.css +15 -3
  601. package/build-style/post-terms/style.css +15 -3
  602. package/build-style/post-title/style-rtl.css +15 -3
  603. package/build-style/post-title/style.css +15 -3
  604. package/build-style/preformatted/style-rtl.css +15 -3
  605. package/build-style/preformatted/style.css +15 -3
  606. package/build-style/pullquote/editor-rtl.css +15 -3
  607. package/build-style/pullquote/editor.css +15 -3
  608. package/build-style/pullquote/style-rtl.css +15 -3
  609. package/build-style/pullquote/style.css +15 -3
  610. package/build-style/pullquote/theme-rtl.css +15 -3
  611. package/build-style/pullquote/theme.css +15 -3
  612. package/build-style/query/editor-rtl.css +15 -3
  613. package/build-style/query/editor.css +15 -3
  614. package/build-style/query-pagination/editor-rtl.css +15 -3
  615. package/build-style/query-pagination/editor.css +15 -3
  616. package/build-style/query-pagination/style-rtl.css +15 -3
  617. package/build-style/query-pagination/style.css +15 -3
  618. package/build-style/query-pagination-numbers/editor-rtl.css +15 -3
  619. package/build-style/query-pagination-numbers/editor.css +15 -3
  620. package/build-style/query-title/style-rtl.css +15 -3
  621. package/build-style/query-title/style.css +15 -3
  622. package/build-style/quote/style-rtl.css +15 -3
  623. package/build-style/quote/style.css +15 -3
  624. package/build-style/quote/theme-rtl.css +15 -3
  625. package/build-style/quote/theme.css +15 -3
  626. package/build-style/read-more/style-rtl.css +15 -3
  627. package/build-style/read-more/style.css +15 -3
  628. package/build-style/reset-rtl.css +15 -3
  629. package/build-style/reset.css +15 -3
  630. package/build-style/rss/editor-rtl.css +15 -3
  631. package/build-style/rss/editor.css +15 -3
  632. package/build-style/rss/style-rtl.css +15 -3
  633. package/build-style/rss/style.css +15 -3
  634. package/build-style/search/editor-rtl.css +15 -3
  635. package/build-style/search/editor.css +15 -3
  636. package/build-style/search/style-rtl.css +15 -3
  637. package/build-style/search/style.css +15 -3
  638. package/build-style/search/theme-rtl.css +15 -3
  639. package/build-style/search/theme.css +15 -3
  640. package/build-style/separator/editor-rtl.css +15 -3
  641. package/build-style/separator/editor.css +15 -3
  642. package/build-style/separator/style-rtl.css +15 -3
  643. package/build-style/separator/style.css +15 -3
  644. package/build-style/separator/theme-rtl.css +15 -3
  645. package/build-style/separator/theme.css +15 -3
  646. package/build-style/shortcode/editor-rtl.css +16 -4
  647. package/build-style/shortcode/editor.css +16 -4
  648. package/build-style/site-logo/editor-rtl.css +15 -3
  649. package/build-style/site-logo/editor.css +15 -3
  650. package/build-style/site-logo/style-rtl.css +15 -3
  651. package/build-style/site-logo/style.css +15 -3
  652. package/build-style/site-tagline/editor-rtl.css +15 -3
  653. package/build-style/site-tagline/editor.css +15 -3
  654. package/build-style/site-title/editor-rtl.css +15 -3
  655. package/build-style/site-title/editor.css +15 -3
  656. package/build-style/site-title/style-rtl.css +15 -3
  657. package/build-style/site-title/style.css +15 -3
  658. package/build-style/social-link/editor-rtl.css +15 -3
  659. package/build-style/social-link/editor.css +15 -3
  660. package/build-style/social-links/editor-rtl.css +15 -3
  661. package/build-style/social-links/editor.css +15 -3
  662. package/build-style/social-links/style-rtl.css +15 -3
  663. package/build-style/social-links/style.css +15 -3
  664. package/build-style/spacer/editor-rtl.css +15 -3
  665. package/build-style/spacer/editor.css +15 -3
  666. package/build-style/spacer/style-rtl.css +15 -3
  667. package/build-style/spacer/style.css +15 -3
  668. package/build-style/style-rtl.css +36 -10
  669. package/build-style/style.css +36 -10
  670. package/build-style/table/editor-rtl.css +15 -11
  671. package/build-style/table/editor.css +15 -11
  672. package/build-style/table/style-rtl.css +21 -3
  673. package/build-style/table/style.css +21 -3
  674. package/build-style/table/theme-rtl.css +15 -9
  675. package/build-style/table/theme.css +15 -9
  676. package/build-style/tag-cloud/style-rtl.css +15 -3
  677. package/build-style/tag-cloud/style.css +15 -3
  678. package/build-style/template-part/editor-rtl.css +30 -4
  679. package/build-style/template-part/editor.css +30 -4
  680. package/build-style/template-part/theme-rtl.css +15 -3
  681. package/build-style/template-part/theme.css +15 -3
  682. package/build-style/text-columns/editor-rtl.css +15 -3
  683. package/build-style/text-columns/editor.css +15 -3
  684. package/build-style/text-columns/style-rtl.css +15 -3
  685. package/build-style/text-columns/style.css +15 -3
  686. package/build-style/theme-rtl.css +15 -9
  687. package/build-style/theme.css +15 -9
  688. package/build-style/verse/style-rtl.css +19 -4
  689. package/build-style/verse/style.css +19 -4
  690. package/build-style/video/editor-rtl.css +15 -3
  691. package/build-style/video/editor.css +15 -3
  692. package/build-style/video/style-rtl.css +17 -4
  693. package/build-style/video/style.css +17 -4
  694. package/build-style/video/theme-rtl.css +15 -3
  695. package/build-style/video/theme.css +15 -3
  696. package/package.json +32 -30
  697. package/src/audio/edit.native.js +1 -2
  698. package/src/audio/index.js +1 -0
  699. package/src/avatar/edit.js +1 -0
  700. package/src/avatar/user-control.js +1 -0
  701. package/src/block/block.json +1 -2
  702. package/src/block/edit.js +14 -3
  703. package/src/block/edit.native.js +24 -12
  704. package/src/block/editor.scss +17 -0
  705. package/src/block/index.php +1 -2
  706. package/src/block/test/edit.native.js +28 -32
  707. package/src/button/edit.native.js +1 -0
  708. package/src/buttons/test/edit.native.js +40 -51
  709. package/src/categories/edit.js +1 -1
  710. package/src/code/transforms.js +3 -1
  711. package/src/columns/edit.js +1 -0
  712. package/src/columns/edit.native.js +18 -26
  713. package/src/comment-author-avatar/edit.js +1 -0
  714. package/src/comments/index.php +0 -1
  715. package/src/cover/edit/inspector-controls.js +6 -4
  716. package/src/cover/edit.native.js +32 -19
  717. package/src/cover/test/edit.native.js +73 -126
  718. package/src/embed/embed-controls.native.js +1 -0
  719. package/src/embed/embed-preview.native.js +1 -2
  720. package/src/embed/test/index.native.js +237 -231
  721. package/src/file/inspector.js +1 -0
  722. package/src/file/test/__snapshots__/edit.native.js.snap +2 -6
  723. package/src/freeform/edit.js +48 -29
  724. package/src/freeform/modal.js +111 -0
  725. package/src/gallery/edit.js +32 -7
  726. package/src/gallery/gallery.js +3 -13
  727. package/src/gallery/gallery.native.js +1 -2
  728. package/src/gallery/shared.js +7 -11
  729. package/src/gallery/transforms.js +1 -6
  730. package/src/gallery/use-get-media.js +1 -1
  731. package/src/gallery/use-get-media.native.js +2 -1
  732. package/src/gallery/v1/edit.js +8 -7
  733. package/src/gallery/v1/gallery.native.js +1 -2
  734. package/src/gallery/v1/shared.js +7 -2
  735. package/src/group/block.json +3 -1
  736. package/src/group/edit.js +2 -6
  737. package/src/group/placeholder.js +6 -25
  738. package/src/group/test/__snapshots__/edit.native.js.snap +1 -1
  739. package/src/heading/block.json +1 -2
  740. package/src/heading/deprecated.js +209 -136
  741. package/src/heading/index.php +52 -0
  742. package/src/heading/test/__snapshots__/index.native.js.snap +7 -0
  743. package/src/heading/test/index.native.js +44 -0
  744. package/src/home-link/index.php +1 -1
  745. package/src/html/block.json +1 -1
  746. package/src/image/edit.js +7 -2
  747. package/src/image/edit.native.js +2 -1
  748. package/src/image/editor.scss +0 -11
  749. package/src/image/image.js +14 -8
  750. package/src/image/test/edit.native.js +14 -10
  751. package/src/index.js +2 -0
  752. package/src/latest-comments/edit.js +1 -0
  753. package/src/latest-posts/edit.js +2 -0
  754. package/src/latest-posts/test/__snapshots__/edit.native.js.snap +3 -0
  755. package/src/latest-posts/test/edit.native.js +49 -0
  756. package/src/list/test/edit.native.js +53 -45
  757. package/src/list/transforms.js +0 -11
  758. package/src/list/utils.js +6 -2
  759. package/src/list-item/index.js +2 -0
  760. package/src/list-item/transforms.js +17 -0
  761. package/src/list-item/utils.js +10 -1
  762. package/src/media-text/edit.js +6 -3
  763. package/src/missing/edit.native.js +13 -6
  764. package/src/missing/test/edit-integration.native.js +10 -12
  765. package/src/more/test/__snapshots__/edit.native.js.snap +7 -0
  766. package/src/more/test/edit.native.js +41 -0
  767. package/src/navigation/edit/are-blocks-dirty.js +51 -0
  768. package/src/navigation/edit/index.js +229 -298
  769. package/src/navigation/edit/menu-inspector-controls.js +119 -0
  770. package/src/navigation/edit/navigation-menu-selector.js +6 -7
  771. package/src/navigation/edit/test/are-blocks-dirty.js +121 -0
  772. package/src/navigation/edit/unsaved-inner-blocks.js +12 -7
  773. package/src/navigation/edit/utils.js +82 -0
  774. package/src/navigation/editor.scss +0 -7
  775. package/src/navigation/index.php +89 -10
  776. package/src/navigation/style.scss +0 -1
  777. package/src/navigation/view-modal.js +11 -1
  778. package/src/navigation-link/edit.js +62 -386
  779. package/src/navigation-link/index.php +64 -0
  780. package/src/navigation-link/link-ui.js +213 -0
  781. package/src/navigation-link/test/edit.js +23 -82
  782. package/src/navigation-link/transforms.js +14 -0
  783. package/src/navigation-link/update-attributes.js +99 -0
  784. package/src/navigation-submenu/edit.js +85 -276
  785. package/src/navigation-submenu/index.php +72 -0
  786. package/src/page-list/block.json +24 -2
  787. package/src/page-list/constants.js +8 -0
  788. package/src/page-list/convert-to-links-modal.js +19 -76
  789. package/src/page-list/convert-to-navigation-links.js +60 -0
  790. package/src/page-list/edit.js +187 -118
  791. package/src/page-list/editor.scss +4 -0
  792. package/src/page-list/index.js +8 -2
  793. package/src/page-list/index.php +18 -10
  794. package/src/page-list/test/convert-to-links-modal.js +28 -34
  795. package/src/page-list-item/block.json +51 -0
  796. package/src/page-list-item/edit.js +102 -0
  797. package/src/page-list-item/index.js +24 -0
  798. package/src/page-list-item/init.js +6 -0
  799. package/src/paragraph/index.js +0 -6
  800. package/src/post-author/edit.js +3 -2
  801. package/src/post-content/index.php +1 -2
  802. package/src/post-featured-image/index.php +7 -2
  803. package/src/post-featured-image/overlay.js +1 -1
  804. package/src/post-template/block.json +8 -0
  805. package/src/preformatted/transforms.js +4 -1
  806. package/src/query/block.json +0 -8
  807. package/src/query/deprecated.js +257 -86
  808. package/src/query/edit/index.js +1 -0
  809. package/src/query/edit/inspector-controls/index.js +50 -38
  810. package/src/query/edit/inspector-controls/taxonomy-controls.js +102 -38
  811. package/src/query/edit/query-content.js +2 -1
  812. package/src/query/edit/query-placeholder.js +14 -25
  813. package/src/query/utils.js +59 -1
  814. package/src/rss/edit.js +3 -0
  815. package/src/search/edit.js +2 -2
  816. package/src/search/edit.native.js +31 -27
  817. package/src/search/index.js +5 -1
  818. package/src/separator/test/__snapshots__/edit.native.js.snap +7 -0
  819. package/src/separator/test/edit.native.js +41 -0
  820. package/src/shortcode/test/edit.native.js +15 -18
  821. package/src/site-logo/edit.js +13 -5
  822. package/src/site-logo/index.js +1 -0
  823. package/src/site-title/index.js +1 -0
  824. package/src/social-link/edit.js +3 -3
  825. package/src/social-link/social-list.js +2 -7
  826. package/src/social-link/test/index.native.js +10 -16
  827. package/src/social-links/edit.js +0 -1
  828. package/src/social-links/test/edit.native.js +4 -3
  829. package/src/spacer/test/index.native.js +39 -36
  830. package/src/table/block.json +15 -0
  831. package/src/table/edit.js +2 -1
  832. package/src/table/editor.scss +0 -4
  833. package/src/table/index.js +1 -0
  834. package/src/table/save.js +5 -1
  835. package/src/table/state.js +22 -7
  836. package/src/table/style.scss +8 -0
  837. package/src/table/theme.scss +0 -8
  838. package/src/table/transforms.js +2 -1
  839. package/src/table-of-contents/edit.js +3 -3
  840. package/src/tag-cloud/edit.js +3 -2
  841. package/src/template-part/edit/advanced-controls.js +12 -0
  842. package/src/template-part/edit/import-controls.js +180 -0
  843. package/src/template-part/edit/index.js +1 -0
  844. package/src/template-part/edit/selection-modal.js +4 -3
  845. package/src/template-part/edit/utils/hooks.js +7 -3
  846. package/src/template-part/edit/utils/transformers.js +37 -0
  847. package/src/template-part/editor.scss +20 -2
  848. package/src/template-part/index.php +1 -2
  849. package/src/text-columns/edit.js +1 -0
  850. package/src/utils/transformation-categories.native.js +1 -0
  851. package/src/verse/style.scss +4 -1
  852. package/src/verse/test/__snapshots__/edit.native.js.snap +13 -0
  853. package/src/verse/test/edit.native.js +40 -33
  854. package/src/video/edit.js +1 -1
  855. package/src/video/edit.native.js +1 -2
  856. package/test/babel-plugin.js +35 -35
  857. package/tsconfig.tsbuildinfo +1 -1
  858. package/build/query/constants.js +0 -16
  859. package/build/query/constants.js.map +0 -1
  860. package/build-module/query/constants.js +0 -7
  861. package/build-module/query/constants.js.map +0 -1
  862. package/src/query/constants.js +0 -7
@@ -13,9 +13,9 @@ var _data = require("@wordpress/data");
13
13
 
14
14
  var _coreData = require("@wordpress/core-data");
15
15
 
16
- var _utils = require("../../utils");
16
+ var _compose = require("@wordpress/compose");
17
17
 
18
- var _constants = require("../../constants");
18
+ var _utils = require("../../utils");
19
19
 
20
20
  /**
21
21
  * WordPress dependencies
@@ -24,7 +24,13 @@ var _constants = require("../../constants");
24
24
  /**
25
25
  * Internal dependencies
26
26
  */
27
- // Helper function to get the term id based on user input in terms `FormTokenField`.
27
+ const EMPTY_ARRAY = [];
28
+ const BASE_QUERY = {
29
+ order: 'asc',
30
+ _fields: 'id,name',
31
+ context: 'view'
32
+ }; // Helper function to get the term id based on user input in terms `FormTokenField`.
33
+
28
34
  const getTermIdByTermValue = (terms, termValue) => {
29
35
  var _terms$find, _terms$find2;
30
36
 
@@ -49,18 +55,6 @@ const getTermIdByTermValue = (terms, termValue) => {
49
55
  return (_terms$find2 = terms.find(term => term.name.toLocaleLowerCase() === termValueLower)) === null || _terms$find2 === void 0 ? void 0 : _terms$find2.id;
50
56
  };
51
57
 
52
- const useTaxonomyTerms = slug => {
53
- return (0, _data.useSelect)(select => {
54
- const terms = select(_coreData.store).getEntityRecords('taxonomy', slug, {
55
- context: 'view',
56
- per_page: _constants.MAX_FETCHED_TERMS
57
- });
58
- return {
59
- terms
60
- };
61
- }, [slug]);
62
- };
63
-
64
58
  function TaxonomyControls(_ref) {
65
59
  let {
66
60
  onChange,
@@ -77,7 +71,7 @@ function TaxonomyControls(_ref) {
77
71
  }
78
72
 
79
73
  return (0, _element.createElement)(_element.Fragment, null, taxonomies.map(taxonomy => {
80
- const value = (taxQuery === null || taxQuery === void 0 ? void 0 : taxQuery[taxonomy.slug]) || [];
74
+ const termIds = (taxQuery === null || taxQuery === void 0 ? void 0 : taxQuery[taxonomy.slug]) || [];
81
75
 
82
76
  const handleChange = newTermIds => onChange({
83
77
  taxQuery: { ...taxQuery,
@@ -88,53 +82,123 @@ function TaxonomyControls(_ref) {
88
82
  return (0, _element.createElement)(TaxonomyItem, {
89
83
  key: taxonomy.slug,
90
84
  taxonomy: taxonomy,
91
- value: value,
85
+ termIds: termIds,
92
86
  onChange: handleChange
93
87
  });
94
88
  }));
95
89
  }
90
+ /**
91
+ * Renders a `FormTokenField` for a given taxonomy.
92
+ *
93
+ * @param {Object} props The props for the component.
94
+ * @param {Object} props.taxonomy The taxonomy object.
95
+ * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.
96
+ * @param {Function} props.onChange Callback `onChange` function.
97
+ * @return {JSX.Element} The rendered component.
98
+ */
99
+
96
100
 
97
101
  function TaxonomyItem(_ref2) {
98
102
  let {
99
103
  taxonomy,
100
- value,
104
+ termIds,
101
105
  onChange
102
106
  } = _ref2;
107
+ const [search, setSearch] = (0, _element.useState)('');
108
+ const [value, setValue] = (0, _element.useState)(EMPTY_ARRAY);
109
+ const [suggestions, setSuggestions] = (0, _element.useState)(EMPTY_ARRAY);
110
+ const debouncedSearch = (0, _compose.useDebounce)(setSearch, 250);
103
111
  const {
104
- terms
105
- } = useTaxonomyTerms(taxonomy.slug);
112
+ searchResults,
113
+ searchHasResolved
114
+ } = (0, _data.useSelect)(select => {
115
+ if (!search) {
116
+ return {
117
+ searchResults: EMPTY_ARRAY,
118
+ searchHasResolved: true
119
+ };
120
+ }
106
121
 
107
- if (!(terms !== null && terms !== void 0 && terms.length)) {
108
- return null;
109
- }
122
+ const {
123
+ getEntityRecords,
124
+ hasFinishedResolution
125
+ } = select(_coreData.store);
126
+ const selectorArgs = ['taxonomy', taxonomy.slug, { ...BASE_QUERY,
127
+ search,
128
+ orderby: 'name',
129
+ exclude: termIds,
130
+ per_page: 20
131
+ }];
132
+ return {
133
+ searchResults: getEntityRecords(...selectorArgs),
134
+ searchHasResolved: hasFinishedResolution('getEntityRecords', selectorArgs)
135
+ };
136
+ }, [search, termIds]); // `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.
137
+ // They are used to extract the terms' names to populate the `FormTokenField` properly
138
+ // and to sanitize the provided `termIds`, by setting only the ones that exist.
139
+
140
+ const existingTerms = (0, _data.useSelect)(select => {
141
+ if (!(termIds !== null && termIds !== void 0 && termIds.length)) return EMPTY_ARRAY;
142
+ const {
143
+ getEntityRecords
144
+ } = select(_coreData.store);
145
+ return getEntityRecords('taxonomy', taxonomy.slug, { ...BASE_QUERY,
146
+ include: termIds,
147
+ per_page: termIds.length
148
+ });
149
+ }, [termIds]); // Update the `value` state only after the selectors are resolved
150
+ // to avoid emptying the input when we're changing terms.
151
+
152
+ (0, _element.useEffect)(() => {
153
+ if (!(termIds !== null && termIds !== void 0 && termIds.length)) {
154
+ setValue(EMPTY_ARRAY);
155
+ }
156
+
157
+ if (!(existingTerms !== null && existingTerms !== void 0 && existingTerms.length)) return; // Returns only the existing entity ids. This prevents the component
158
+ // from crashing in the editor, when non existing ids are provided.
159
+
160
+ const sanitizedValue = termIds.reduce((accumulator, id) => {
161
+ const entity = existingTerms.find(term => term.id === id);
162
+
163
+ if (entity) {
164
+ accumulator.push({
165
+ id,
166
+ value: entity.name
167
+ });
168
+ }
169
+
170
+ return accumulator;
171
+ }, []);
172
+ setValue(sanitizedValue);
173
+ }, [termIds, existingTerms]); // Update suggestions only when the query has resolved.
174
+
175
+ (0, _element.useEffect)(() => {
176
+ if (!searchHasResolved) return;
177
+ setSuggestions(searchResults.map(result => result.name));
178
+ }, [searchResults, searchHasResolved]);
110
179
 
111
180
  const onTermsChange = newTermValues => {
112
- const termIds = new Set();
181
+ const newTermIds = new Set();
113
182
 
114
183
  for (const termValue of newTermValues) {
115
- const termId = getTermIdByTermValue(terms, termValue);
184
+ const termId = getTermIdByTermValue(searchResults, termValue);
116
185
 
117
186
  if (termId) {
118
- termIds.add(termId);
187
+ newTermIds.add(termId);
119
188
  }
120
189
  }
121
190
 
122
- onChange(Array.from(termIds));
123
- }; // Selects only the existing term ids in proper format to be
124
- // used in `FormTokenField`. This prevents the component from
125
- // crashing in the editor, when non existing term ids were provided.
126
-
191
+ setSuggestions(EMPTY_ARRAY);
192
+ onChange(Array.from(newTermIds));
193
+ };
127
194
 
128
- const taxQueryValue = value.map(termId => terms.find(t => t.id === termId)).filter(Boolean).map(term => ({
129
- id: term.id,
130
- value: term.name
131
- }));
132
195
  return (0, _element.createElement)("div", {
133
196
  className: "block-library-query-inspector__taxonomy-control"
134
197
  }, (0, _element.createElement)(_components.FormTokenField, {
135
198
  label: taxonomy.name,
136
- value: taxQueryValue,
137
- suggestions: terms.map(t => t.name),
199
+ value: value,
200
+ onInputChange: debouncedSearch,
201
+ suggestions: suggestions,
138
202
  onChange: onTermsChange,
139
203
  __experimentalShowHowTo: false
140
204
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","useTaxonomyTerms","slug","select","coreStore","getEntityRecords","context","per_page","MAX_FETCHED_TERMS","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","map","taxonomy","value","handleChange","newTermIds","TaxonomyItem","onTermsChange","newTermValues","termIds","Set","add","Array","from","taxQueryVal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,CAAEiB,KAAK,CAACC,IAAN,CAAYJ,OAAZ,CAAF,CAAR;AACA,GAVD,CANsD,CAkBtD;AACA;AACA;;;AACA,QAAMK,aAAa,GAAGX,KAAK,CACzBF,GADoB,CACbtB,MAAF,IAAcF,KAAK,CAACI,IAAN,CAAckC,CAAF,IAASA,CAAC,CAACnC,EAAF,KAASD,MAA9B,CADC,EAEpBqC,MAFoB,CAEZC,OAFY,EAGpBhB,GAHoB,CAGbnB,IAAF,KAAc;AAAEF,IAAAA,EAAE,EAAEE,IAAI,CAACF,EAAX;AAAeuB,IAAAA,KAAK,EAAErB,IAAI,CAACC;AAA3B,GAAd,CAHe,CAAtB;AAKA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAGmB,QAAQ,CAACnB,IADlB;AAEC,IAAA,KAAK,EAAG+B,aAFT;AAGC,IAAA,WAAW,EAAGrC,KAAK,CAACwB,GAAN,CAAac,CAAF,IAASA,CAAC,CAAChC,IAAtB,CAHf;AAIC,IAAA,QAAQ,EAAGwB,aAJZ;AAKC,IAAA,uBAAuB,EAAG;AAL3B,IADD,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\nimport { MAX_FETCHED_TERMS } from '../../constants';\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nconst useTaxonomyTerms = ( slug ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst terms = select( coreStore ).getEntityRecords(\n\t\t\t\t'taxonomy',\n\t\t\t\tslug,\n\t\t\t\t{ context: 'view', per_page: MAX_FETCHED_TERMS }\n\t\t\t);\n\t\t\treturn { terms };\n\t\t},\n\t\t[ slug ]\n\t);\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst value = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\nfunction TaxonomyItem( { taxonomy, value, onChange } ) {\n\tconst { terms } = useTaxonomyTerms( taxonomy.slug );\n\tif ( ! terms?.length ) {\n\t\treturn null;\n\t}\n\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst termIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( terms, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\ttermIds.add( termId );\n\t\t\t}\n\t\t}\n\n\t\tonChange( Array.from( termIds ) );\n\t};\n\n\t// Selects only the existing term ids in proper format to be\n\t// used in `FormTokenField`. This prevents the component from\n\t// crashing in the editor, when non existing term ids were provided.\n\tconst taxQueryValue = value\n\t\t.map( ( termId ) => terms.find( ( t ) => t.id === termId ) )\n\t\t.filter( Boolean )\n\t\t.map( ( term ) => ( { id: term.id, value: term.name } ) );\n\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ taxQueryValue }\n\t\t\t\tsuggestions={ terms.map( ( t ) => t.name ) }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","coreStore","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,MAAMA,WAAW,GAAG,EAApB;AACA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE,KADW;AAElBC,EAAAA,OAAO,EA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AAlB;AAIA;;AACD,aAAOsC,WAAP;AACA,KATsB,EASpB,EAToB,CAAvB;AAUAlB,IAAAA,QAAQ,CAAEgB,cAAF,CAAR;AACA,GAlBD,EAkBG,CAAExB,OAAF,EAAWsB,aAAX,CAlBH,EAlDwD,CAqExD;;AACA,0BAAW,MAAM;AAChB,QAAK,CAAET,iBAAP,EAA2B;AAC3BH,IAAAA,cAAc,CAAEE,aAAa,CAACd,GAAd,CAAqB+B,MAAF,IAAcA,MAAM,CAACzC,IAAxC,CAAF,CAAd;AACA,GAHD,EAGG,CAAEwB,aAAF,EAAiBC,iBAAjB,CAHH;;AAIA,QAAMiB,aAAa,GAAKC,aAAF,IAAqB;AAC1C,UAAM5B,UAAU,GAAG,IAAI6B,GAAJ,EAAnB;;AACA,SAAM,MAAMjD,SAAZ,IAAyBgD,aAAzB,EAAyC;AACxC,YAAM/C,MAAM,GAAGH,oBAAoB,CAAE+B,aAAF,EAAiB7B,SAAjB,CAAnC;;AACA,UAAKC,MAAL,EAAc;AACbmB,QAAAA,UAAU,CAAC8B,GAAX,CAAgBjD,MAAhB;AACA;AACD;;AACD0B,IAAAA,cAAc,CAAElC,WAAF,CAAd;AACAgB,IAAAA,QAAQ,CAAE0C,KAAK,CAACC,IAAN,CAAYhC,UAAZ,CAAF,CAAR;AACA,GAVD;;AAWA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAGJ,QAAQ,CAACX,IADlB;AAEC,IAAA,KAAK,EAAGmB,KAFT;AAGC,IAAA,aAAa,EAAGI,eAHjB;AAIC,IAAA,WAAW,EAAGF,WAJf;AAKC,IAAA,QAAQ,EAAGqB,aALZ;AAMC,IAAA,uBAAuB,EAAG;AAN3B,IADD,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) return EMPTY_ARRAY;\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) return;\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -23,8 +23,6 @@ var _queryToolbar = _interopRequireDefault(require("./query-toolbar"));
23
23
 
24
24
  var _inspectorControls = _interopRequireDefault(require("./inspector-controls"));
25
25
 
26
- var _constants = require("../constants");
27
-
28
26
  /**
29
27
  * WordPress dependencies
30
28
  */
@@ -32,6 +30,7 @@ var _constants = require("../constants");
32
30
  /**
33
31
  * Internal dependencies
34
32
  */
33
+ const DEFAULTS_POSTS_PER_PAGE = 3;
35
34
  const TEMPLATE = [['core/post-template']];
36
35
 
37
36
  function QueryContent(_ref) {
@@ -84,7 +83,7 @@ function QueryContent(_ref) {
84
83
  getSettings
85
84
  } = select(_blockEditor.store);
86
85
  return {
87
- postsPerPage: +getSettings().postsPerPage || _constants.DEFAULTS_POSTS_PER_PAGE
86
+ postsPerPage: +getSettings().postsPerPage || DEFAULTS_POSTS_PER_PAGE
88
87
  };
89
88
  }, []); // There are some effects running where some initialization logic is
90
89
  // happening and setting some values to some attributes (ex. queryId).
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"names":["TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","instanceId","themeSupportsLayout","select","getSettings","supportsLayout","defaultLayout","usedLayout","type","blockProps","innerBlocksProps","template","__experimentalLayout","undefined","postsPerPage","DEFAULTS_POSTS_PER_PAGE","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","label","value"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAQA;;AACA;;AAKA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAeA;AACA;AACA;AAKA,MAAMA,QAAQ,GAAG,CAAE,CAAE,oBAAF,CA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,EAAGG;AAHpB,IADD,EAMC,4BAAC,0BAAD,QACC,4BAAC,qBAAD;AACC,IAAA,IAAI,EAAGjC,IADR;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,UAAU,EAAGJ,UAHd;AAIC,IAAA,QAAQ,EAAGiC,WAJZ;AAKC,IAAA,gBAAgB,EAAGG,mBALpB;AAMC,IAAA,yBAAyB,EAAGlC;AAN7B,IADD,CAND,EAgBC,4BAAC,8BAAD;AAAmB,IAAA,mBAAmB,EAAC;AAAvC,KACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,cAAJ,CADT;AAEC,IAAA,OAAO,EAAG,CACT;AAAEoC,MAAAA,KAAK,EAAE,cAAI,iBAAJ,CAAT;AAAkCC,MAAAA,KAAK,EAAE;AAAzC,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,QAAT;AAAmBC,MAAAA,KAAK,EAAE;AAA1B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAHS,EAIT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAJS,CAFX;AAQC,IAAA,KAAK,EAAG9B,OART;AASC,IAAA,QAAQ,EAAK8B,KAAF,IACVtC,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAE+B;AAAX,KAAF;AAVf,IADD,CAhBD,EA+BC,4BAAC,OAAD,EAAcjB,gBAAd,CA/BD,CADD;AAmCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\nimport { DEFAULTS_POSTS_PER_PAGE } from '../constants';\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tlayout = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn { themeSupportsLayout: getSettings()?.supportsLayout };\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\t+getSettings().postsPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\tif ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\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: '<main>', value: 'main' },\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\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"names":["DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","instanceId","themeSupportsLayout","select","getSettings","supportsLayout","defaultLayout","usedLayout","type","blockProps","innerBlocksProps","template","__experimentalLayout","undefined","postsPerPage","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","label","value"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAQA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAeA;AACA;AACA;AAIA,MAAMA,uBAAuB,GAAG,CAAhC;AAEA,MAAMC,QAAQ,GAAG,CAAE,CAAE,oBAAF,CAAF,CAAjB;;AACe,SAASC,YAAT,OAMX;AAAA,MANkC;AACrCC,IAAAA,UADqC;AAErCC,IAAAA,aAFqC;AAGrCC,IAAAA,yBAHqC;AAIrCC,IAAAA,IAJqC;AAKrCC,IAAAA;AALqC,GAMlC;AACH,QAAM;AACLC,IAAAA,OADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,OAAO,EAAEC,OAAO,GAAG,KAJd;AAKLC,IAAAA,MAAM,GAAG;AALJ,MAMFV,UANJ;AAOA,QAAM;AAAEW,IAAAA;AAAF,MACL,uBAAaC,kBAAb,CADD;AAEA,QAAMC,UAAU,GAAG,4BAAed,YAAf,CAAnB;AACA,QAAM;AAAEe,IAAAA;AAAF,MAA0B,qBAAaC,MAAF,IAAc;AAAA;;AACxD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MA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AAT;AAAmBC,MAAAA,KAAK,EAAE;AAA1B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAHS,EAIT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAJS,CAFX;AAQC,IAAA,KAAK,EAAG7B,OART;AASC,IAAA,QAAQ,EAAK6B,KAAF,IACVrC,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAE8B;AAAX,KAAF;AAVf,IADD,CAhBD,EA+BC,4BAAC,OAAD,EAAchB,gBAAd,CA/BD,CADD;AAmCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\n\nconst DEFAULTS_POSTS_PER_PAGE = 3;\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tlayout = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn { themeSupportsLayout: getSettings()?.supportsLayout };\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\t+getSettings().postsPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\tif ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\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: '<main>', value: 'main' },\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\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
@@ -17,9 +17,15 @@ var _components = require("@wordpress/components");
17
17
 
18
18
  var _i18n = require("@wordpress/i18n");
19
19
 
20
+ var _utils = require("../utils");
21
+
20
22
  /**
21
23
  * WordPress dependencies
22
24
  */
25
+
26
+ /**
27
+ * Internal dependencies
28
+ */
23
29
  function QueryPlaceholder(_ref) {
24
30
  var _matchingVariation$ic, _blockType$icon;
25
31
 
@@ -59,7 +65,6 @@ function QueryPlaceholder(_ref) {
59
65
  if (isStartingBlank) {
60
66
  return (0, _element.createElement)(QueryVariationPicker, {
61
67
  clientId: clientId,
62
- name: name,
63
68
  attributes: attributes,
64
69
  setAttributes: setAttributes,
65
70
  icon: icon,
@@ -85,27 +90,12 @@ function QueryPlaceholder(_ref) {
85
90
  function QueryVariationPicker(_ref2) {
86
91
  let {
87
92
  clientId,
88
- name,
89
93
  attributes,
90
94
  setAttributes,
91
95
  icon,
92
96
  label
93
97
  } = _ref2;
94
- const {
95
- defaultVariation,
96
- scopeVariations
97
- } = (0, _data.useSelect)(select => {
98
- const {
99
- getBlockVariations,
100
- getBlockType,
101
- getDefaultBlockVariation
102
- } = select(_blocks.store);
103
- return {
104
- blockType: getBlockType(name),
105
- defaultVariation: getDefaultBlockVariation(name, 'block'),
106
- scopeVariations: getBlockVariations(name, 'block')
107
- };
108
- }, [name]);
98
+ const scopeVariations = (0, _utils.useScopedBlockVariations)(attributes);
109
99
  const {
110
100
  replaceInnerBlocks
111
101
  } = (0, _data.useDispatch)(_blockEditor.store);
@@ -114,19 +104,18 @@ function QueryVariationPicker(_ref2) {
114
104
  icon: icon,
115
105
  label: label,
116
106
  variations: scopeVariations,
117
- onSelect: function () {
118
- let nextVariation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultVariation;
119
-
120
- if (nextVariation.attributes) {
121
- setAttributes({ ...nextVariation.attributes,
122
- query: { ...nextVariation.attributes.query,
123
- postType: attributes.query.postType || nextVariation.attributes.query.postType
124
- }
107
+ onSelect: variation => {
108
+ if (variation.attributes) {
109
+ setAttributes({ ...variation.attributes,
110
+ query: { ...variation.attributes.query,
111
+ postType: attributes.query.postType || variation.attributes.query.postType
112
+ },
113
+ namespace: attributes.namespace
125
114
  });
126
115
  }
127
116
 
128
- if (nextVariation.innerBlocks) {
129
- replaceInnerBlocks(clientId, (0, _blocks.createBlocksFromInnerBlocksTemplate)(nextVariation.innerBlocks), false);
117
+ if (variation.innerBlocks) {
118
+ replaceInnerBlocks(clientId, (0, _blocks.createBlocksFromInnerBlocksTemplate)(variation.innerBlocks), false);
130
119
  }
131
120
  }
132
121
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"names":["QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","setAttributes","isStartingBlank","setIsStartingBlank","blockProps","blockType","allVariations","hasPatterns","select","getBlockVariations","getBlockType","blocksStore","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId","length","matchingVariation","icon","src","label","title","QueryVariationPicker","defaultVariation","scopeVariations","getDefaultBlockVariation","replaceInnerBlocks","nextVariation","query","postType","innerBlocks"],"mappings":";;;;;;;AAQA;;AALA;;AACA;;AAKA;;AAMA;;AACA;;AAhBA;AACA;AACA;AAgBe,SAASA,gBAAT,OAMX;AAAA;;AAAA,MANsC;AACzCC,IAAAA,UADyC;AAEzCC,IAAAA,QAFyC;AAGzCC,IAAAA,IAHyC;AAIzCC,IAAAA,yBAJyC;AAKzCC,IAAAA;AALyC,GAMtC;AACH,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,KAAV,CAAhD;AACA,QAAMC,UAAU,GAAG,iCAAnB;AAEA,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,aAAb;AAA4BC,IAAAA;AAA5B,MAA4C,qBAC/CC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,kBAAF;AAAsBC,MAAAA;AAAtB,QAAuCF,MAAM,CAAEG,aAAF,CAAnD;AACA,UAAM;AACLC,MAAAA,oBADK;AAELC,MAAAA;AAFK,QAGFL,MAAM,CAAEM,kBAAF,CAHV;AAIA,UAAMC,YAAY,GAAGH,oBAAoB,CAAEd,QAAF,CAAzC;AAEA,WAAO;AACNO,MAAAA,SAAS,EAAEK,YAAY,CAAEX,IAAF,CADjB;AAENO,MAAAA,aAAa,EAAEG,kBAAkB,CAAEV,IAAF,CAF3B;AAGNQ,MAAAA,WAAW,EAAE,CAAC,CAAEM,qCAAqC,CACpDd,IADoD,EAEpDgB,YAFoD,CAArC,CAGdC;AANI,KAAP;AAQA,GAjBgD,EAkBjD,CAAEj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B+B,KAAzB,CAA+BC;AAJ1B;AAFO,SAAF,CAAb;AASA;;AACD,UAAKF,aAAa,CAACG,WAAnB,EAAiC;AAChCJ,QAAAA,kBAAkB,CACjB5B,QADiB,EAEjB,iDACC6B,aAAa,CAACG,WADf,CAFiB,EAKjB,KALiB,CAAlB;AAOA;AACD;AAzBF,IADD,CADD;AA+BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useState } from '@wordpress/element';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalBlockVariationPicker,\n\t__experimentalGetMatchingVariation as getMatchingVariation,\n} from '@wordpress/block-editor';\nimport { Button, Placeholder } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function QueryPlaceholder( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\n\tconst { blockType, allVariations, hasPatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tallVariations: getBlockVariations( name ),\n\t\t\t\thasPatterns: !! __experimentalGetPatternsByBlockTypes(\n\t\t\t\t\tname,\n\t\t\t\t\trootClientId\n\t\t\t\t).length,\n\t\t\t};\n\t\t},\n\t\t[ name, clientId ]\n\t);\n\n\tconst matchingVariation = getMatchingVariation( attributes, allVariations );\n\tconst icon =\n\t\tmatchingVariation?.icon?.src ||\n\t\tmatchingVariation?.icon ||\n\t\tblockType?.icon?.src;\n\tconst label = matchingVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryVariationPicker\n\t\t\t\tclientId={ clientId }\n\t\t\t\tname={ name }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nfunction QueryVariationPicker( {\n\tclientId,\n\tname,\n\tattributes,\n\tsetAttributes,\n\ticon,\n\tlabel,\n} ) {\n\tconst { defaultVariation, scopeVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetDefaultBlockVariation,\n\t\t\t} = select( blocksStore );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tdefaultVariation: getDefaultBlockVariation( name, 'block' ),\n\t\t\t\tscopeVariations: getBlockVariations( name, 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tvariations={ scopeVariations }\n\t\t\t\tonSelect={ ( nextVariation = defaultVariation ) => {\n\t\t\t\t\tif ( nextVariation.attributes ) {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t...nextVariation.attributes,\n\t\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\t\t...nextVariation.attributes.query,\n\t\t\t\t\t\t\t\tpostType:\n\t\t\t\t\t\t\t\t\tattributes.query.postType ||\n\t\t\t\t\t\t\t\t\tnextVariation.attributes.query.postType,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tif ( nextVariation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tnextVariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"names":["QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","setAttributes","isStartingBlank","setIsStartingBlank","blockProps","blockType","allVariations","hasPatterns","select","getBlockVariations","getBlockType","blocksStore","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId","length","matchingVariation","icon","src","label","title","QueryVariationPicker","scopeVariations","replaceInnerBlocks","variation","query","postType","namespace","innerBlocks"],"mappings":";;;;;;;AAQA;;AALA;;AACA;;AAKA;;AAMA;;AACA;;AAKA;;AArBA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AGc,IADR;AAEC,IAAA,KAAK,EAAGE,KAFT;AAGC,IAAA,UAAU,EAAGG,eAHd;AAIC,IAAA,QAAQ,EAAKE,SAAF,IAAiB;AAC3B,UAAKA,SAAS,CAAC5B,UAAf,EAA4B;AAC3BI,QAAAA,aAAa,CAAE,EACd,GAAGwB,SAAS,CAAC5B,UADC;AAEd6B,UAAAA,KAAK,EAAE,EACN,GAAGD,SAAS,CAAC5B,UAAV,CAAqB6B,KADlB;AAENC,YAAAA,QAAQ,EACP9B,UAAU,CAAC6B,KAAX,CAAiBC,QAAjB,IACAF,SAAS,CAAC5B,UAAV,CAAqB6B,KAArB,CAA2BC;AAJtB,WAFO;AAQdC,UAAAA,SAAS,EAAE/B,UAAU,CAAC+B;AARR,SAAF,CAAb;AAUA;;AACD,UAAKH,SAAS,CAACI,WAAf,EAA6B;AAC5BL,QAAAA,kBAAkB,CACjB1B,QADiB,EAEjB,iDACC2B,SAAS,CAACI,WADX,CAFiB,EAKjB,KALiB,CAAlB;AAOA;AACD;AA1BF,IADD,CADD;AAgCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useState } from '@wordpress/element';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalBlockVariationPicker,\n\t__experimentalGetMatchingVariation as getMatchingVariation,\n} from '@wordpress/block-editor';\nimport { Button, Placeholder } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useScopedBlockVariations } from '../utils';\n\nexport default function QueryPlaceholder( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\n\tconst { blockType, allVariations, hasPatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tallVariations: getBlockVariations( name ),\n\t\t\t\thasPatterns: !! __experimentalGetPatternsByBlockTypes(\n\t\t\t\t\tname,\n\t\t\t\t\trootClientId\n\t\t\t\t).length,\n\t\t\t};\n\t\t},\n\t\t[ name, clientId ]\n\t);\n\n\tconst matchingVariation = getMatchingVariation( attributes, allVariations );\n\tconst icon =\n\t\tmatchingVariation?.icon?.src ||\n\t\tmatchingVariation?.icon ||\n\t\tblockType?.icon?.src;\n\tconst label = matchingVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryVariationPicker\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nfunction QueryVariationPicker( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\ticon,\n\tlabel,\n} ) {\n\tconst scopeVariations = useScopedBlockVariations( attributes );\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tvariations={ scopeVariations }\n\t\t\t\tonSelect={ ( variation ) => {\n\t\t\t\t\tif ( variation.attributes ) {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t...variation.attributes,\n\t\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\t\t...variation.attributes.query,\n\t\t\t\t\t\t\t\tpostType:\n\t\t\t\t\t\t\t\t\tattributes.query.postType ||\n\t\t\t\t\t\t\t\t\tvariation.attributes.query.postType,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tnamespace: attributes.namespace,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tif ( variation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tvariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -82,14 +82,6 @@ const metadata = {
82
82
  supports: {
83
83
  align: ["wide", "full"],
84
84
  html: false,
85
- color: {
86
- gradients: true,
87
- link: true,
88
- __experimentalDefaultControls: {
89
- background: true,
90
- text: true
91
- }
92
- },
93
85
  __experimentalLayout: true
94
86
  },
95
87
  editorStyle: "wp-block-query-editor"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/index.js"],"names":["name","metadata","settings","icon","edit","save","variations","deprecated","init","queryInspectorControls"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,WADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,IAAI,EAAJA,aAHuB;AAIvBC,EAAAA,UAAU,EAAVA,mBAJuB;AAKvBC,EAAAA,UAAU,EAAVA;AALuB,CAAjB;;;AAQA,MAAMC,IAAI,GAAG,MAAM;AACzB,wBAAW,kBAAX,EAA+B,YAA/B,EAA6CC,eAA7C;AAEA,SAAO,wBAAW;AAAET,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAX,CAAP;AACA,CAJM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { loop as icon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport variations from './variations';\nimport deprecated from './deprecated';\nimport queryInspectorControls from './hooks';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tvariations,\n\tdeprecated,\n};\n\nexport const init = () => {\n\taddFilter( 'editor.BlockEdit', 'core/query', queryInspectorControls );\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/index.js"],"names":["name","metadata","settings","icon","edit","save","variations","deprecated","init","queryInspectorControls"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAfA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,WADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,IAAI,EAAJA,aAHuB;AAIvBC,EAAAA,UAAU,EAAVA,mBAJuB;AAKvBC,EAAAA,UAAU,EAAVA;AALuB,CAAjB;;;AAQA,MAAMC,IAAI,GAAG,MAAM;AACzB,wBAAW,kBAAX,EAA+B,YAA/B,EAA6CC,eAA7C;AAEA,SAAO,wBAAW;AAAET,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAX,CAAP;AACA,CAJM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { loop as icon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport variations from './variations';\nimport deprecated from './deprecated';\nimport queryInspectorControls from './hooks';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tvariations,\n\tdeprecated,\n};\n\nexport const init = () => {\n\taddFilter( 'editor.BlockEdit', 'core/query', queryInspectorControls );\n\n\treturn initBlock( { name, metadata, settings } );\n};\n"]}
@@ -9,7 +9,9 @@ exports.mapToIHasNameAndId = void 0;
9
9
  exports.useAllowedControls = useAllowedControls;
10
10
  exports.useBlockNameForPatterns = useBlockNameForPatterns;
11
11
  exports.useIsPostTypeHierarchical = useIsPostTypeHierarchical;
12
- exports.useTaxonomies = exports.usePostTypes = void 0;
12
+ exports.usePostTypes = void 0;
13
+ exports.useScopedBlockVariations = useScopedBlockVariations;
14
+ exports.useTaxonomies = void 0;
13
15
 
14
16
  var _lodash = require("lodash");
15
17
 
@@ -90,18 +92,12 @@ const {
90
92
  supports: {
91
93
  align: ["wide", "full"],
92
94
  html: false,
93
- color: {
94
- gradients: true,
95
- link: true,
96
- __experimentalDefaultControls: {
97
- background: true,
98
- text: true
99
- }
100
- },
101
95
  __experimentalLayout: true
102
96
  },
103
97
  editorStyle: "wp-block-query-editor"
104
98
  };
99
+ /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
100
+
105
101
  /**
106
102
  * @typedef IHasNameAndId
107
103
  * @property {string|number} id The entity's id.
@@ -373,4 +369,72 @@ function useBlockNameForPatterns(clientId, attributes) {
373
369
  }, [clientId, activeVariationName]);
374
370
  return activeVariationPatterns !== null && activeVariationPatterns !== void 0 && activeVariationPatterns.length ? blockName : queryLoopName;
375
371
  }
372
+ /**
373
+ * Helper hook that determines if there is an active variation of the block
374
+ * and if there are available specific scoped `block` variations connected with
375
+ * this variation.
376
+ *
377
+ * If there are, these variations are going to be the only ones suggested
378
+ * to the user in setup flow when clicking to `start blank`, without including
379
+ * the default ones for Query Loop.
380
+ *
381
+ * If there are no such scoped `block` variations, the default ones for Query
382
+ * Loop are going to be suggested.
383
+ *
384
+ * The way we determine such variations is with the convention that they have the `namespace`
385
+ * attribute defined as an array. This array should contain the names(`name` property) of any
386
+ * variations they want to be connected to.
387
+ * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,
388
+ * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.
389
+ * If the user selects this variation, the `namespace` attribute will be overridden by the
390
+ * main `inserter` variation.
391
+ *
392
+ * @param {Object} attributes The block's attributes.
393
+ * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.
394
+ */
395
+
396
+
397
+ function useScopedBlockVariations(attributes) {
398
+ const {
399
+ activeVariationName,
400
+ blockVariations
401
+ } = (0, _data.useSelect)(select => {
402
+ var _getActiveBlockVariat;
403
+
404
+ const {
405
+ getActiveBlockVariation,
406
+ getBlockVariations
407
+ } = select(_blocks.store);
408
+ return {
409
+ activeVariationName: (_getActiveBlockVariat = getActiveBlockVariation(queryLoopName, attributes)) === null || _getActiveBlockVariat === void 0 ? void 0 : _getActiveBlockVariat.name,
410
+ blockVariations: getBlockVariations(queryLoopName, 'block')
411
+ };
412
+ }, [attributes]);
413
+ const variations = (0, _element.useMemo)(() => {
414
+ // Filter out the variations that have defined a `namespace` attribute,
415
+ // which means they are 'connected' to specific variations of the block.
416
+ const isNotConnected = variation => {
417
+ var _variation$attributes;
418
+
419
+ return !((_variation$attributes = variation.attributes) !== null && _variation$attributes !== void 0 && _variation$attributes.namespace);
420
+ };
421
+
422
+ if (!activeVariationName) {
423
+ return blockVariations.filter(isNotConnected);
424
+ }
425
+
426
+ const connectedVariations = blockVariations.filter(variation => {
427
+ var _variation$attributes2, _variation$attributes3;
428
+
429
+ return (_variation$attributes2 = variation.attributes) === null || _variation$attributes2 === void 0 ? void 0 : (_variation$attributes3 = _variation$attributes2.namespace) === null || _variation$attributes3 === void 0 ? void 0 : _variation$attributes3.includes(activeVariationName);
430
+ });
431
+
432
+ if (!!connectedVariations.length) {
433
+ return connectedVariations;
434
+ }
435
+
436
+ return blockVariations.filter(isNotConnected);
437
+ }, [activeVariationName, blockVariations]);
438
+ return variations;
439
+ }
376
440
  //# sourceMappingURL=utils.js.map