@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
@@ -6,12 +6,19 @@ import { createElement, Fragment } from "@wordpress/element";
6
6
  import { FormTokenField } from '@wordpress/components';
7
7
  import { useSelect } from '@wordpress/data';
8
8
  import { store as coreStore } from '@wordpress/core-data';
9
+ import { useState, useEffect } from '@wordpress/element';
10
+ import { useDebounce } from '@wordpress/compose';
9
11
  /**
10
12
  * Internal dependencies
11
13
  */
12
14
 
13
15
  import { useTaxonomies } from '../../utils';
14
- import { MAX_FETCHED_TERMS } from '../../constants'; // Helper function to get the term id based on user input in terms `FormTokenField`.
16
+ const EMPTY_ARRAY = [];
17
+ const BASE_QUERY = {
18
+ order: 'asc',
19
+ _fields: 'id,name',
20
+ context: 'view'
21
+ }; // Helper function to get the term id based on user input in terms `FormTokenField`.
15
22
 
16
23
  const getTermIdByTermValue = (terms, termValue) => {
17
24
  var _terms$find, _terms$find2;
@@ -37,18 +44,6 @@ const getTermIdByTermValue = (terms, termValue) => {
37
44
  return (_terms$find2 = terms.find(term => term.name.toLocaleLowerCase() === termValueLower)) === null || _terms$find2 === void 0 ? void 0 : _terms$find2.id;
38
45
  };
39
46
 
40
- const useTaxonomyTerms = slug => {
41
- return useSelect(select => {
42
- const terms = select(coreStore).getEntityRecords('taxonomy', slug, {
43
- context: 'view',
44
- per_page: MAX_FETCHED_TERMS
45
- });
46
- return {
47
- terms
48
- };
49
- }, [slug]);
50
- };
51
-
52
47
  export function TaxonomyControls(_ref) {
53
48
  let {
54
49
  onChange,
@@ -65,7 +60,7 @@ export function TaxonomyControls(_ref) {
65
60
  }
66
61
 
67
62
  return createElement(Fragment, null, taxonomies.map(taxonomy => {
68
- const value = (taxQuery === null || taxQuery === void 0 ? void 0 : taxQuery[taxonomy.slug]) || [];
63
+ const termIds = (taxQuery === null || taxQuery === void 0 ? void 0 : taxQuery[taxonomy.slug]) || [];
69
64
 
70
65
  const handleChange = newTermIds => onChange({
71
66
  taxQuery: { ...taxQuery,
@@ -76,53 +71,122 @@ export function TaxonomyControls(_ref) {
76
71
  return createElement(TaxonomyItem, {
77
72
  key: taxonomy.slug,
78
73
  taxonomy: taxonomy,
79
- value: value,
74
+ termIds: termIds,
80
75
  onChange: handleChange
81
76
  });
82
77
  }));
83
78
  }
79
+ /**
80
+ * Renders a `FormTokenField` for a given taxonomy.
81
+ *
82
+ * @param {Object} props The props for the component.
83
+ * @param {Object} props.taxonomy The taxonomy object.
84
+ * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.
85
+ * @param {Function} props.onChange Callback `onChange` function.
86
+ * @return {JSX.Element} The rendered component.
87
+ */
84
88
 
85
89
  function TaxonomyItem(_ref2) {
86
90
  let {
87
91
  taxonomy,
88
- value,
92
+ termIds,
89
93
  onChange
90
94
  } = _ref2;
95
+ const [search, setSearch] = useState('');
96
+ const [value, setValue] = useState(EMPTY_ARRAY);
97
+ const [suggestions, setSuggestions] = useState(EMPTY_ARRAY);
98
+ const debouncedSearch = useDebounce(setSearch, 250);
91
99
  const {
92
- terms
93
- } = useTaxonomyTerms(taxonomy.slug);
100
+ searchResults,
101
+ searchHasResolved
102
+ } = useSelect(select => {
103
+ if (!search) {
104
+ return {
105
+ searchResults: EMPTY_ARRAY,
106
+ searchHasResolved: true
107
+ };
108
+ }
94
109
 
95
- if (!(terms !== null && terms !== void 0 && terms.length)) {
96
- return null;
97
- }
110
+ const {
111
+ getEntityRecords,
112
+ hasFinishedResolution
113
+ } = select(coreStore);
114
+ const selectorArgs = ['taxonomy', taxonomy.slug, { ...BASE_QUERY,
115
+ search,
116
+ orderby: 'name',
117
+ exclude: termIds,
118
+ per_page: 20
119
+ }];
120
+ return {
121
+ searchResults: getEntityRecords(...selectorArgs),
122
+ searchHasResolved: hasFinishedResolution('getEntityRecords', selectorArgs)
123
+ };
124
+ }, [search, termIds]); // `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.
125
+ // They are used to extract the terms' names to populate the `FormTokenField` properly
126
+ // and to sanitize the provided `termIds`, by setting only the ones that exist.
127
+
128
+ const existingTerms = useSelect(select => {
129
+ if (!(termIds !== null && termIds !== void 0 && termIds.length)) return EMPTY_ARRAY;
130
+ const {
131
+ getEntityRecords
132
+ } = select(coreStore);
133
+ return getEntityRecords('taxonomy', taxonomy.slug, { ...BASE_QUERY,
134
+ include: termIds,
135
+ per_page: termIds.length
136
+ });
137
+ }, [termIds]); // Update the `value` state only after the selectors are resolved
138
+ // to avoid emptying the input when we're changing terms.
139
+
140
+ useEffect(() => {
141
+ if (!(termIds !== null && termIds !== void 0 && termIds.length)) {
142
+ setValue(EMPTY_ARRAY);
143
+ }
144
+
145
+ if (!(existingTerms !== null && existingTerms !== void 0 && existingTerms.length)) return; // Returns only the existing entity ids. This prevents the component
146
+ // from crashing in the editor, when non existing ids are provided.
147
+
148
+ const sanitizedValue = termIds.reduce((accumulator, id) => {
149
+ const entity = existingTerms.find(term => term.id === id);
150
+
151
+ if (entity) {
152
+ accumulator.push({
153
+ id,
154
+ value: entity.name
155
+ });
156
+ }
157
+
158
+ return accumulator;
159
+ }, []);
160
+ setValue(sanitizedValue);
161
+ }, [termIds, existingTerms]); // Update suggestions only when the query has resolved.
162
+
163
+ useEffect(() => {
164
+ if (!searchHasResolved) return;
165
+ setSuggestions(searchResults.map(result => result.name));
166
+ }, [searchResults, searchHasResolved]);
98
167
 
99
168
  const onTermsChange = newTermValues => {
100
- const termIds = new Set();
169
+ const newTermIds = new Set();
101
170
 
102
171
  for (const termValue of newTermValues) {
103
- const termId = getTermIdByTermValue(terms, termValue);
172
+ const termId = getTermIdByTermValue(searchResults, termValue);
104
173
 
105
174
  if (termId) {
106
- termIds.add(termId);
175
+ newTermIds.add(termId);
107
176
  }
108
177
  }
109
178
 
110
- onChange(Array.from(termIds));
111
- }; // Selects only the existing term ids in proper format to be
112
- // used in `FormTokenField`. This prevents the component from
113
- // crashing in the editor, when non existing term ids were provided.
179
+ setSuggestions(EMPTY_ARRAY);
180
+ onChange(Array.from(newTermIds));
181
+ };
114
182
 
115
-
116
- const taxQueryValue = value.map(termId => terms.find(t => t.id === termId)).filter(Boolean).map(term => ({
117
- id: term.id,
118
- value: term.name
119
- }));
120
183
  return createElement("div", {
121
184
  className: "block-library-query-inspector__taxonomy-control"
122
185
  }, createElement(FormTokenField, {
123
186
  label: taxonomy.name,
124
- value: taxQueryValue,
125
- suggestions: terms.map(t => t.name),
187
+ value: value,
188
+ onInputChange: debouncedSearch,
189
+ suggestions: suggestions,
126
190
  onChange: onTermsChange,
127
191
  __experimentalShowHowTo: false
128
192
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["FormTokenField","useSelect","store","coreStore","useTaxonomies","MAX_FETCHED_TERMS","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","useTaxonomyTerms","slug","select","getEntityRecords","context","per_page","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","map","taxonomy","value","handleChange","newTermIds","TaxonomyItem","onTermsChange","newTermValues","termIds","Set","add","Array","from","taxQueryValue","t","filter","Boolean"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AACA,SAASC,SAAT,QA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QAAAA,OAAO,CAACE,GAAR,CAAa9B,MAAb;AACA;AACD;;AAEDc,IAAAA,QAAQ,CAAEiB,KAAK,CAACC,IAAN,CAAYJ,OAAZ,CAAF,CAAR;AACA,GAVD,CANsD,CAkBtD;AACA;AACA;;;AACA,QAAMK,aAAa,GAAGX,KAAK,CACzBF,GADoB,CACbpB,MAAF,IAAcF,KAAK,CAACI,IAAN,CAAcgC,CAAF,IAASA,CAAC,CAACjC,EAAF,KAASD,MAA9B,CADC,EAEpBmC,MAFoB,CAEZC,OAFY,EAGpBhB,GAHoB,CAGbjB,IAAF,KAAc;AAAEF,IAAAA,EAAE,EAAEE,IAAI,CAACF,EAAX;AAAeqB,IAAAA,KAAK,EAAEnB,IAAI,CAACC;AAA3B,GAAd,CAHe,CAAtB;AAKA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,cAAD;AACC,IAAA,KAAK,EAAGiB,QAAQ,CAACjB,IADlB;AAEC,IAAA,KAAK,EAAG6B,aAFT;AAGC,IAAA,WAAW,EAAGnC,KAAK,CAACsB,GAAN,CAAac,CAAF,IAASA,CAAC,CAAC9B,IAAtB,CAHf;AAIC,IAAA,QAAQ,EAAGsB,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":["FormTokenField","useSelect","store","coreStore","useState","useEffect","useDebounce","useTaxonomies","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","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,uBAA/B;AACA,SAASC,SAAT,QAA0B,i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;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,cAAD;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,EAAGoB,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"]}
@@ -15,7 +15,7 @@ import { __ } from '@wordpress/i18n';
15
15
 
16
16
  import QueryToolbar from './query-toolbar';
17
17
  import QueryInspectorControls from './inspector-controls';
18
- import { DEFAULTS_POSTS_PER_PAGE } from '../constants';
18
+ const DEFAULTS_POSTS_PER_PAGE = 3;
19
19
  const TEMPLATE = [['core/post-template']];
20
20
  export default function QueryContent(_ref) {
21
21
  let {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"names":["useSelect","useDispatch","useInstanceId","useEffect","BlockControls","InspectorControls","useBlockProps","useSetting","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","QueryToolbar","QueryInspectorControls","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","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":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K,EAAE;AAA7B,KAHS,EAIT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAJS,CAFX;AAQC,IAAA,KAAK,EAAG5B,OART;AASC,IAAA,QAAQ,EAAK4B,KAAF,IACVpC,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAE6B;AAAX,KAAF;AAVf,IADD,CAhBD,EA+BC,cAAC,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';\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":["useSelect","useDispatch","useInstanceId","useEffect","BlockControls","InspectorControls","useBlockProps","useSetting","store","blockEditorStore","useInnerBlocksProps","SelectControl","__","QueryToolbar","QueryInspectorControls","DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","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":";;AAAA;AACA;AACA;AACA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S,EAIT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAJS,CAFX;AAQC,IAAA,KAAK,EAAG5B,OART;AASC,IAAA,QAAQ,EAAK4B,KAAF,IACVpC,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAE6B;AAAX,KAAF;AAVf,IADD,CAhBD,EA+BC,cAAC,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"]}
@@ -9,6 +9,11 @@ import { useState } from '@wordpress/element';
9
9
  import { useBlockProps, store as blockEditorStore, __experimentalBlockVariationPicker, __experimentalGetMatchingVariation as getMatchingVariation } from '@wordpress/block-editor';
10
10
  import { Button, Placeholder } from '@wordpress/components';
11
11
  import { __ } from '@wordpress/i18n';
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ import { useScopedBlockVariations } from '../utils';
12
17
  export default function QueryPlaceholder(_ref) {
13
18
  var _matchingVariation$ic, _blockType$icon;
14
19
 
@@ -48,7 +53,6 @@ export default function QueryPlaceholder(_ref) {
48
53
  if (isStartingBlank) {
49
54
  return createElement(QueryVariationPicker, {
50
55
  clientId: clientId,
51
- name: name,
52
56
  attributes: attributes,
53
57
  setAttributes: setAttributes,
54
58
  icon: icon,
@@ -74,27 +78,12 @@ export default function QueryPlaceholder(_ref) {
74
78
  function QueryVariationPicker(_ref2) {
75
79
  let {
76
80
  clientId,
77
- name,
78
81
  attributes,
79
82
  setAttributes,
80
83
  icon,
81
84
  label
82
85
  } = _ref2;
83
- const {
84
- defaultVariation,
85
- scopeVariations
86
- } = useSelect(select => {
87
- const {
88
- getBlockVariations,
89
- getBlockType,
90
- getDefaultBlockVariation
91
- } = select(blocksStore);
92
- return {
93
- blockType: getBlockType(name),
94
- defaultVariation: getDefaultBlockVariation(name, 'block'),
95
- scopeVariations: getBlockVariations(name, 'block')
96
- };
97
- }, [name]);
86
+ const scopeVariations = useScopedBlockVariations(attributes);
98
87
  const {
99
88
  replaceInnerBlocks
100
89
  } = useDispatch(blockEditorStore);
@@ -103,19 +92,18 @@ function QueryVariationPicker(_ref2) {
103
92
  icon: icon,
104
93
  label: label,
105
94
  variations: scopeVariations,
106
- onSelect: function () {
107
- let nextVariation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultVariation;
108
-
109
- if (nextVariation.attributes) {
110
- setAttributes({ ...nextVariation.attributes,
111
- query: { ...nextVariation.attributes.query,
112
- postType: attributes.query.postType || nextVariation.attributes.query.postType
113
- }
95
+ onSelect: variation => {
96
+ if (variation.attributes) {
97
+ setAttributes({ ...variation.attributes,
98
+ query: { ...variation.attributes.query,
99
+ postType: attributes.query.postType || variation.attributes.query.postType
100
+ },
101
+ namespace: attributes.namespace
114
102
  });
115
103
  }
116
104
 
117
- if (nextVariation.innerBlocks) {
118
- replaceInnerBlocks(clientId, createBlocksFromInnerBlocksTemplate(nextVariation.innerBlocks), false);
105
+ if (variation.innerBlocks) {
106
+ replaceInnerBlocks(clientId, createBlocksFromInnerBlocksTemplate(variation.innerBlocks), false);
119
107
  }
120
108
  }
121
109
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"names":["useSelect","useDispatch","createBlocksFromInnerBlocksTemplate","store","blocksStore","useState","useBlockProps","blockEditorStore","__experimentalBlockVariationPicker","__experimentalGetMatchingVariation","getMatchingVariation","Button","Placeholder","__","QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","setAttributes","isStartingBlank","setIsStartingBlank","blockProps","blockType","allVariations","hasPatterns","select","getBlockVariations","getBlockType","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","rootClientId","length","matchingVariation","icon","src","label","title","QueryVariationPicker","defaultVariation","scopeVariations","getDefaultBlockVariation","replaceInnerBlocks","nextVariation","query","postType","innerBlocks"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,mCADD,EAECC,KAAK,IAAIC,WAFV,QAGO,mBAHP;AAIA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SACCC,aADD,EAECH,KAAK,IAAII,gBAFV,EAGCC,kCAHD,EAICC,kCAAkC,IAAIC,oBAJvC,QAKO,yBALP;AAMA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,uBAApC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,eAAe,SAASC,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,IAA0ChB,QAAQ,CAAE,KAAF,CAAxD;AACA,QAAMiB,UAAU,GAAGhB,aAAa,EAAhC;AAEA,QAAM;AAAEiB,IAAAA,SAAF;AAAaC,IAAAA,aAAb;AAA4BC,IAAAA;AAA5B,MAA4CzB,SAAS,CACxD0B,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,kBAAF;AAAsBC,MAAAA;AAAtB,QAAuCF,MAAM,CAAEtB,WAAF,CAAnD;AACA,UAAM;AACLyB,MAAAA,oBADK;AAELC,MAAAA;AAFK,QAGFJ,MAAM,CAAEnB,gB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AIC,IAAA,QAAQ,EAAG,YAAwC;AAAA,UAAtCG,aAAsC,uEAAtBJ,gBAAsB;;AAClD,UAAKI,aAAa,CAAC5B,UAAnB,EAAgC;AAC/BI,QAAAA,aAAa,CAAE,EACd,GAAGwB,aAAa,CAAC5B,UADH;AAEd6B,UAAAA,KAAK,EAAE,EACN,GAAGD,aAAa,CAAC5B,UAAd,CAAyB6B,KADtB;AAENC,YAAAA,QAAQ,EACP9B,UAAU,CAAC6B,KAAX,CAAiBC,QAAjB,IACAF,aAAa,CAAC5B,UAAd,CAAyB6B,KAAzB,CAA+BC;AAJ1B;AAFO,SAAF,CAAb;AASA;;AACD,UAAKF,aAAa,CAACG,WAAnB,EAAiC;AAChCJ,QAAAA,kBAAkB,CACjB1B,QADiB,EAEjBd,mCAAmC,CAClCyC,aAAa,CAACG,WADoB,CAFlB,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":["useSelect","useDispatch","createBlocksFromInnerBlocksTemplate","store","blocksStore","useState","useBlockProps","blockEditorStore","__experimentalBlockVariationPicker","__experimentalGetMatchingVariation","getMatchingVariation","Button","Placeholder","__","useScopedBlockVariations","QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","setAttributes","isStartingBlank","setIsStartingBlank","blockProps","blockType","allVariations","hasPatterns","select","getBlockVariations","getBlockType","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","rootClientId","length","matchingVariation","icon","src","label","title","QueryVariationPicker","scopeVariations","replaceInnerBlocks","variation","query","postType","namespace","innerBlocks"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,mCADD,EAECC,KAAK,IAAIC,WAFV,QAGO,mBAHP;AAIA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SACCC,aADD,EAECH,KAAK,IAAII,gBAFV,EAGCC,kCAHD,EAICC,kCAAkC,IAAIC,oBAJvC,QAKO,yBALP;AAMA,SAASC,MAAT,EAAiBC,WAAjB,QAAoC,uBAApC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,UAAzC;AAEA,eAAe,SAASC,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,IAA0CjB,QAAQ,CAAE,KAAF,CAAxD;AACA,QAAMkB,UAAU,GAAGjB,aAAa,EAAhC;AAEA,QAAM;AAAEkB,IAAAA,SAAF;AAAaC,IAAAA,aAAb;AAA4BC,IAAAA;AAA5B,MAA4C1B,SAAS,CACxD2B,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,kBA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,KAArB,CAA2BC;AAJtB,WAFO;AAQdC,UAAAA,SAAS,EAAE7B,UAAU,CAAC6B;AARR,SAAF,CAAb;AAUA;;AACD,UAAKH,SAAS,CAACI,WAAf,EAA6B;AAC5BL,QAAAA,kBAAkB,CACjBxB,QADiB,EAEjBf,mCAAmC,CAClCwC,SAAS,CAACI,WADwB,CAFlB,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"]}
@@ -60,14 +60,6 @@ const metadata = {
60
60
  supports: {
61
61
  align: ["wide", "full"],
62
62
  html: false,
63
- color: {
64
- gradients: true,
65
- link: true,
66
- __experimentalDefaultControls: {
67
- background: true,
68
- text: true
69
- }
70
- },
71
63
  __experimentalLayout: true
72
64
  },
73
65
  editorStyle: "wp-block-query-editor"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/index.js"],"names":["loop","icon","addFilter","initBlock","edit","save","variations","deprecated","queryInspectorControls","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,IAAIC,IAAjB,QAA6B,kBAA7B;AACA,SAASC,SAAT,QAA0B,kBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,sBAAP,MAAmC,SAAnC;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBV,EAAAA,IADuB;AAEvBG,EAAAA,IAFuB;AAGvBC,EAAAA,IAHuB;AAIvBC,EAAAA,UAJuB;AAKvBC,EAAAA;AALuB,CAAjB;AAQP,OAAO,MAAMK,IAAI,GAAG,MAAM;AACzBV,EAAAA,SAAS,CAAE,kBAAF,EAAsB,YAAtB,EAAoCM,sBAApC,CAAT;AAEA,SAAOL,SAAS,CAAE;AAAEM,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAF,CAAhB;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":["loop","icon","addFilter","initBlock","edit","save","variations","deprecated","queryInspectorControls","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,IAAIC,IAAjB,QAA6B,kBAA7B;AACA,SAASC,SAAT,QAA0B,kBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,sBAAP,MAAmC,SAAnC;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBV,EAAAA,IADuB;AAEvBG,EAAAA,IAFuB;AAGvBC,EAAAA,IAHuB;AAIvBC,EAAAA,UAJuB;AAKvBC,EAAAA;AALuB,CAAjB;AAQP,OAAO,MAAMK,IAAI,GAAG,MAAM;AACzBV,EAAAA,SAAS,CAAE,kBAAF,EAAsB,YAAtB,EAAoCM,sBAApC,CAAT;AAEA,SAAOL,SAAS,CAAE;AAAEM,IAAAA,IAAF;AAAQC,IAAAA,QAAR;AAAkBC,IAAAA;AAAlB,GAAF,CAAhB;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"]}
@@ -70,18 +70,12 @@ const {
70
70
  supports: {
71
71
  align: ["wide", "full"],
72
72
  html: false,
73
- color: {
74
- gradients: true,
75
- link: true,
76
- __experimentalDefaultControls: {
77
- background: true,
78
- text: true
79
- }
80
- },
81
73
  __experimentalLayout: true
82
74
  },
83
75
  editorStyle: "wp-block-query-editor"
84
76
  };
77
+ /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
78
+
85
79
  /**
86
80
  * @typedef IHasNameAndId
87
81
  * @property {string|number} id The entity's id.
@@ -335,4 +329,71 @@ export function useBlockNameForPatterns(clientId, attributes) {
335
329
  }, [clientId, activeVariationName]);
336
330
  return activeVariationPatterns !== null && activeVariationPatterns !== void 0 && activeVariationPatterns.length ? blockName : queryLoopName;
337
331
  }
332
+ /**
333
+ * Helper hook that determines if there is an active variation of the block
334
+ * and if there are available specific scoped `block` variations connected with
335
+ * this variation.
336
+ *
337
+ * If there are, these variations are going to be the only ones suggested
338
+ * to the user in setup flow when clicking to `start blank`, without including
339
+ * the default ones for Query Loop.
340
+ *
341
+ * If there are no such scoped `block` variations, the default ones for Query
342
+ * Loop are going to be suggested.
343
+ *
344
+ * The way we determine such variations is with the convention that they have the `namespace`
345
+ * attribute defined as an array. This array should contain the names(`name` property) of any
346
+ * variations they want to be connected to.
347
+ * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,
348
+ * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.
349
+ * If the user selects this variation, the `namespace` attribute will be overridden by the
350
+ * main `inserter` variation.
351
+ *
352
+ * @param {Object} attributes The block's attributes.
353
+ * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.
354
+ */
355
+
356
+ export function useScopedBlockVariations(attributes) {
357
+ const {
358
+ activeVariationName,
359
+ blockVariations
360
+ } = useSelect(select => {
361
+ var _getActiveBlockVariat;
362
+
363
+ const {
364
+ getActiveBlockVariation,
365
+ getBlockVariations
366
+ } = select(blocksStore);
367
+ return {
368
+ activeVariationName: (_getActiveBlockVariat = getActiveBlockVariation(queryLoopName, attributes)) === null || _getActiveBlockVariat === void 0 ? void 0 : _getActiveBlockVariat.name,
369
+ blockVariations: getBlockVariations(queryLoopName, 'block')
370
+ };
371
+ }, [attributes]);
372
+ const variations = useMemo(() => {
373
+ // Filter out the variations that have defined a `namespace` attribute,
374
+ // which means they are 'connected' to specific variations of the block.
375
+ const isNotConnected = variation => {
376
+ var _variation$attributes;
377
+
378
+ return !((_variation$attributes = variation.attributes) !== null && _variation$attributes !== void 0 && _variation$attributes.namespace);
379
+ };
380
+
381
+ if (!activeVariationName) {
382
+ return blockVariations.filter(isNotConnected);
383
+ }
384
+
385
+ const connectedVariations = blockVariations.filter(variation => {
386
+ var _variation$attributes2, _variation$attributes3;
387
+
388
+ 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);
389
+ });
390
+
391
+ if (!!connectedVariations.length) {
392
+ return connectedVariations;
393
+ }
394
+
395
+ return blockVariations.filter(isNotConnected);
396
+ }, [activeVariationName, blockVariations]);
397
+ return variations;
398
+ }
338
399
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["get","useSelect","useMemo","store","coreStore","blockEditorStore","decodeEntities","cloneBlock","blocksStore","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","getActiveBlockVariation","queryLoopName","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","forEach","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","activeVariationPatterns","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","rootClientId"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,UAAT,EAAqBJ,KAAK,IAAIK,WAA9B,QAAiD,mBAAjD;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,eAAe,GAAKC,QAAF,IAAgB;AAC9C,QAAMC,OAAO,GAAGD,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEE,MAAV,CACf,CAAEC,WAAF,EAAeC,MAAf,KAA2B;AAC1B,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,SAAX;AAAsBC,MAAAA;AAAtB,QAAgCJ,WAAtC;AACAE,IAAAA,OAAO,CAAED,MAAM,CAACI,EAAT,CAAP,GAAuBJ,MAAvB;AACAE,IAAAA,SAAS,CAAEF,MAAM,CAACK,IAAT,CAAT,GAA2BL,MAA3B;AACAG,IAAAA,KAAK,CAACG,IAAN,CAAYN,MAAM,CAACK,IAAnB;AACA,WAAON,WAAP;AACA,GAPc,EAQf;AAAEE,IAAAA,OAAO,EAAE,EAAX;AAAeC,IAAAA,SAAS,EAAE,EAA1B;AAA8BC,IAAAA,KAAK,EAAE;AAArC,GARe,CAAhB;AAUA,SAAO;AACNP,IAAAA,QADM;AAEN,OA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CAAEzC,MAAzB,GAAkCwC,SAAlC,GAA8CrB,aAArD;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as queryLoopName } from './block.json';\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.name,\n\n\t\t[ attributes ]\n\t);\n\tconst blockName = `${ queryLoopName }/${ activeVariationName }`;\n\tconst activeVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn;\n\t\t\t}\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\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ clientId, activeVariationName ]\n\t);\n\treturn activeVariationPatterns?.length ? blockName : queryLoopName;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["get","useSelect","useMemo","store","coreStore","blockEditorStore","decodeEntities","cloneBlock","blocksStore","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","getActiveBlockVariation","queryLoopName","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","clientId","innerBlocks","forEach","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","activeVariationPatterns","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","rootClientId","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAnC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,UAAT,EAAqBJ,KAAK,IAAIK,WAA9B,QAAiD,mBAAjD;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,eAAe,GAA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CAZyD,CAA1D;AAcA,QAAM+B,UAAU,GAAGlF,OAAO,CAAE,MAAM;AACjC;AACA;AACA,UAAMmF,cAAc,GAAKC,SAAF;AAAA;;AAAA,aACtB,2BAAEA,SAAS,CAACjC,UAAZ,kDAAE,sBAAsBkC,SAAxB,CADsB;AAAA,KAAvB;;AAEA,QAAK,CAAEZ,mBAAP,EAA6B;AAC5B,aAAOO,eAAe,CAACnD,MAAhB,CAAwBsD,cAAxB,CAAP;AACA;;AACD,UAAMG,mBAAmB,GAAGN,eAAe,CAACnD,MAAhB,CAA0BuD,SAAF;AAAA;;AAAA,uCACnDA,SAAS,CAACjC,UADyC,qFACnD,uBAAsBkC,SAD6B,2DACnD,uBAAiCrD,QAAjC,CAA2CyC,mBAA3C,CADmD;AAAA,KAAxB,CAA5B;;AAGA,QAAK,CAAC,CAAEa,mBAAmB,CAACpD,MAA5B,EAAqC;AACpC,aAAOoD,mBAAP;AACA;;AACD,WAAON,eAAe,CAACnD,MAAhB,CAAwBsD,cAAxB,CAAP;AACA,GAfyB,EAevB,CAAEV,mBAAF,EAAuBO,eAAvB,CAfuB,CAA1B;AAgBA,SAAOE,UAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock, store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { name as queryLoopName } from './block.json';\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Hook that returns whether a specific post type is hierarchical.\n *\n * @param {string} postType The post type to check.\n * @return {boolean} Whether a specific post type is hierarchical.\n */\nexport function useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\n/**\n * Hook that returns the query properties' names defined by the active\n * block variation, to determine which block's filters to show.\n *\n * @param {Object} attributes Block attributes.\n * @return {string[]} An array of the query attributes.\n */\nexport function useAllowedControls( attributes ) {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.allowedControls,\n\n\t\t[ attributes ]\n\t);\n}\nexport function isControlAllowed( allowedControls, key ) {\n\t// Every controls is allowed if the list is not defined.\n\tif ( ! allowedControls ) {\n\t\treturn true;\n\t}\n\treturn allowedControls.includes( key );\n}\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific patterns for this variation.\n * If there are, these patterns are going to be the only ones suggested to\n * the user in setup and replace flow, without including the default ones\n * for Query Loop.\n *\n * If there are no such patterns, the default ones for Query Loop are going\n * to be suggested.\n *\n * @param {string} clientId The block's client ID.\n * @param {Object} attributes The block's attributes.\n * @return {string} The block name to be used in the patterns suggestions.\n */\nexport function useBlockNameForPatterns( clientId, attributes ) {\n\tconst activeVariationName = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blocksStore ).getActiveBlockVariation(\n\t\t\t\tqueryLoopName,\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `${ queryLoopName }/${ activeVariationName }`;\n\tconst activeVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn;\n\t\t\t}\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\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ clientId, activeVariationName ]\n\t);\n\treturn activeVariationPatterns?.length ? blockName : queryLoopName;\n}\n\n/**\n * Helper hook that determines if there is an active variation of the block\n * and if there are available specific scoped `block` variations connected with\n * this variation.\n *\n * If there are, these variations are going to be the only ones suggested\n * to the user in setup flow when clicking to `start blank`, without including\n * the default ones for Query Loop.\n *\n * If there are no such scoped `block` variations, the default ones for Query\n * Loop are going to be suggested.\n *\n * The way we determine such variations is with the convention that they have the `namespace`\n * attribute defined as an array. This array should contain the names(`name` property) of any\n * variations they want to be connected to.\n * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,\n * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.\n * If the user selects this variation, the `namespace` attribute will be overridden by the\n * main `inserter` variation.\n *\n * @param {Object} attributes The block's attributes.\n * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.\n */\nexport function useScopedBlockVariations( attributes ) {\n\tconst { activeVariationName, blockVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\t\t\treturn {\n\t\t\t\tactiveVariationName: getActiveBlockVariation(\n\t\t\t\t\tqueryLoopName,\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( queryLoopName, 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ attributes ]\n\t);\n\tconst variations = useMemo( () => {\n\t\t// Filter out the variations that have defined a `namespace` attribute,\n\t\t// which means they are 'connected' to specific variations of the block.\n\t\tconst isNotConnected = ( variation ) =>\n\t\t\t! variation.attributes?.namespace;\n\t\tif ( ! activeVariationName ) {\n\t\t\treturn blockVariations.filter( isNotConnected );\n\t\t}\n\t\tconst connectedVariations = blockVariations.filter( ( variation ) =>\n\t\t\tvariation.attributes?.namespace?.includes( activeVariationName )\n\t\t);\n\t\tif ( !! connectedVariations.length ) {\n\t\t\treturn connectedVariations;\n\t\t}\n\t\treturn blockVariations.filter( isNotConnected );\n\t}, [ activeVariationName, blockVariations ] );\n\treturn variations;\n}\n"]}