@wordpress/block-library 8.0.0 → 8.2.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 (558) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +1 -1
  3. package/build/archives/edit.js +1 -0
  4. package/build/archives/edit.js.map +1 -1
  5. package/build/audio/edit.js +2 -0
  6. package/build/audio/edit.js.map +1 -1
  7. package/build/categories/edit.js +1 -1
  8. package/build/categories/edit.js.map +1 -1
  9. package/build/comments/edit/comments-inspector-controls.js +9 -3
  10. package/build/comments/edit/comments-inspector-controls.js.map +1 -1
  11. package/build/cover/edit/inspector-controls.js +1 -1
  12. package/build/cover/edit/inspector-controls.js.map +1 -1
  13. package/build/embed/embed-preview.js +1 -0
  14. package/build/embed/embed-preview.js.map +1 -1
  15. package/build/file/inspector.js +1 -0
  16. package/build/file/inspector.js.map +1 -1
  17. package/build/freeform/edit.js +21 -6
  18. package/build/freeform/edit.js.map +1 -1
  19. package/build/freeform/modal.js +97 -0
  20. package/build/freeform/modal.js.map +1 -0
  21. package/build/gallery/edit.js +15 -2
  22. package/build/gallery/edit.js.map +1 -1
  23. package/build/gallery/gallery.js +3 -16
  24. package/build/gallery/gallery.js.map +1 -1
  25. package/build/gallery/v1/edit.js +2 -0
  26. package/build/gallery/v1/edit.js.map +1 -1
  27. package/build/group/edit.js +1 -0
  28. package/build/group/edit.js.map +1 -1
  29. package/build/group/index.js +3 -0
  30. package/build/group/index.js.map +1 -1
  31. package/build/image/image.js +7 -10
  32. package/build/image/image.js.map +1 -1
  33. package/build/latest-posts/edit.js +11 -8
  34. package/build/latest-posts/edit.js.map +1 -1
  35. package/build/media-text/edit.js +1 -0
  36. package/build/media-text/edit.js.map +1 -1
  37. package/build/missing/edit.native.js +2 -2
  38. package/build/missing/edit.native.js.map +1 -1
  39. package/build/navigation/edit/index.js +9 -7
  40. package/build/navigation/edit/index.js.map +1 -1
  41. package/build/navigation/edit/menu-inspector-controls.js +81 -22
  42. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  43. package/build/navigation/edit/navigation-menu-selector.js +15 -10
  44. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  45. package/build/navigation/edit/utils.js +81 -0
  46. package/build/navigation/edit/utils.js.map +1 -1
  47. package/build/navigation/leaf-more-menu.js +95 -0
  48. package/build/navigation/leaf-more-menu.js.map +1 -0
  49. package/build/navigation-link/edit.js +10 -61
  50. package/build/navigation-link/edit.js.map +1 -1
  51. package/build/navigation-link/update-attributes.js +3 -3
  52. package/build/navigation-link/update-attributes.js.map +1 -1
  53. package/build/navigation-submenu/edit.js +7 -72
  54. package/build/navigation-submenu/edit.js.map +1 -1
  55. package/build/page-list/edit.js +16 -15
  56. package/build/page-list/edit.js.map +1 -1
  57. package/build/page-list/index.js +29 -2
  58. package/build/page-list/index.js.map +1 -1
  59. package/build/page-list-item/edit.js +9 -5
  60. package/build/page-list-item/edit.js.map +1 -1
  61. package/build/page-list-item/index.js +2 -1
  62. package/build/page-list-item/index.js.map +1 -1
  63. package/build/post-author/edit.js +2 -0
  64. package/build/post-author/edit.js.map +1 -1
  65. package/build/post-featured-image/dimension-controls.js +1 -0
  66. package/build/post-featured-image/dimension-controls.js.map +1 -1
  67. package/build/post-featured-image/overlay.js +0 -1
  68. package/build/post-featured-image/overlay.js.map +1 -1
  69. package/build/query/edit/index.js +2 -1
  70. package/build/query/edit/index.js.map +1 -1
  71. package/build/query/edit/inspector-controls/index.js +11 -5
  72. package/build/query/edit/inspector-controls/index.js.map +1 -1
  73. package/build/query/edit/inspector-controls/order-control.js +1 -0
  74. package/build/query/edit/inspector-controls/order-control.js.map +1 -1
  75. package/build/query/edit/inspector-controls/sticky-control.js +1 -0
  76. package/build/query/edit/inspector-controls/sticky-control.js.map +1 -1
  77. package/build/query/edit/inspector-controls/taxonomy-controls.js +101 -37
  78. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  79. package/build/query/edit/query-content.js +10 -4
  80. package/build/query/edit/query-content.js.map +1 -1
  81. package/build/query/edit/query-placeholder.js +17 -12
  82. package/build/query/edit/query-placeholder.js.map +1 -1
  83. package/build/query/utils.js +73 -1
  84. package/build/query/utils.js.map +1 -1
  85. package/build/search/edit.js +2 -2
  86. package/build/search/edit.js.map +1 -1
  87. package/build/social-link/edit.js +2 -1
  88. package/build/social-link/edit.js.map +1 -1
  89. package/build/social-links/edit.js +0 -1
  90. package/build/social-links/edit.js.map +1 -1
  91. package/build/table/edit.js +1 -0
  92. package/build/table/edit.js.map +1 -1
  93. package/build/table-of-contents/edit.js +1 -1
  94. package/build/table-of-contents/edit.js.map +1 -1
  95. package/build/tag-cloud/edit.js +1 -0
  96. package/build/tag-cloud/edit.js.map +1 -1
  97. package/build/template-part/edit/advanced-controls.js +23 -2
  98. package/build/template-part/edit/advanced-controls.js.map +1 -1
  99. package/build/template-part/edit/import-controls.js +160 -0
  100. package/build/template-part/edit/import-controls.js.map +1 -0
  101. package/build/template-part/edit/index.js +2 -1
  102. package/build/template-part/edit/index.js.map +1 -1
  103. package/build/template-part/edit/utils/transformers.js +48 -0
  104. package/build/template-part/edit/utils/transformers.js.map +1 -0
  105. package/build/video/edit-common-settings.js +6 -5
  106. package/build/video/edit-common-settings.js.map +1 -1
  107. package/build/video/edit.js +1 -0
  108. package/build/video/edit.js.map +1 -1
  109. package/build/video/tracks-editor.js +1 -0
  110. package/build/video/tracks-editor.js.map +1 -1
  111. package/build-module/archives/edit.js +1 -0
  112. package/build-module/archives/edit.js.map +1 -1
  113. package/build-module/audio/edit.js +2 -0
  114. package/build-module/audio/edit.js.map +1 -1
  115. package/build-module/categories/edit.js +1 -1
  116. package/build-module/categories/edit.js.map +1 -1
  117. package/build-module/comments/edit/comments-inspector-controls.js +9 -3
  118. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
  119. package/build-module/cover/edit/inspector-controls.js +3 -3
  120. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  121. package/build-module/embed/embed-preview.js +1 -0
  122. package/build-module/embed/embed-preview.js.map +1 -1
  123. package/build-module/file/inspector.js +1 -0
  124. package/build-module/file/inspector.js.map +1 -1
  125. package/build-module/freeform/edit.js +22 -8
  126. package/build-module/freeform/edit.js.map +1 -1
  127. package/build-module/freeform/modal.js +90 -0
  128. package/build-module/freeform/modal.js.map +1 -0
  129. package/build-module/gallery/edit.js +16 -3
  130. package/build-module/gallery/edit.js.map +1 -1
  131. package/build-module/gallery/gallery.js +4 -16
  132. package/build-module/gallery/gallery.js.map +1 -1
  133. package/build-module/gallery/v1/edit.js +2 -0
  134. package/build-module/gallery/v1/edit.js.map +1 -1
  135. package/build-module/group/edit.js +1 -0
  136. package/build-module/group/edit.js.map +1 -1
  137. package/build-module/group/index.js +3 -0
  138. package/build-module/group/index.js.map +1 -1
  139. package/build-module/image/image.js +7 -10
  140. package/build-module/image/image.js.map +1 -1
  141. package/build-module/latest-posts/edit.js +12 -9
  142. package/build-module/latest-posts/edit.js.map +1 -1
  143. package/build-module/media-text/edit.js +1 -0
  144. package/build-module/media-text/edit.js.map +1 -1
  145. package/build-module/missing/edit.native.js +2 -2
  146. package/build-module/missing/edit.native.js.map +1 -1
  147. package/build-module/navigation/edit/index.js +9 -7
  148. package/build-module/navigation/edit/index.js.map +1 -1
  149. package/build-module/navigation/edit/menu-inspector-controls.js +80 -25
  150. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  151. package/build-module/navigation/edit/navigation-menu-selector.js +16 -11
  152. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  153. package/build-module/navigation/edit/utils.js +75 -0
  154. package/build-module/navigation/edit/utils.js.map +1 -1
  155. package/build-module/navigation/leaf-more-menu.js +76 -0
  156. package/build-module/navigation/leaf-more-menu.js.map +1 -0
  157. package/build-module/navigation-link/edit.js +10 -62
  158. package/build-module/navigation-link/edit.js.map +1 -1
  159. package/build-module/navigation-link/update-attributes.js +3 -3
  160. package/build-module/navigation-link/update-attributes.js.map +1 -1
  161. package/build-module/navigation-submenu/edit.js +6 -72
  162. package/build-module/navigation-submenu/edit.js.map +1 -1
  163. package/build-module/page-list/edit.js +17 -15
  164. package/build-module/page-list/edit.js.map +1 -1
  165. package/build-module/page-list/index.js +30 -3
  166. package/build-module/page-list/index.js.map +1 -1
  167. package/build-module/page-list-item/edit.js +9 -6
  168. package/build-module/page-list-item/edit.js.map +1 -1
  169. package/build-module/page-list-item/index.js +2 -1
  170. package/build-module/page-list-item/index.js.map +1 -1
  171. package/build-module/post-author/edit.js +2 -0
  172. package/build-module/post-author/edit.js.map +1 -1
  173. package/build-module/post-featured-image/dimension-controls.js +1 -0
  174. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  175. package/build-module/post-featured-image/overlay.js +0 -1
  176. package/build-module/post-featured-image/overlay.js.map +1 -1
  177. package/build-module/query/edit/index.js +2 -1
  178. package/build-module/query/edit/index.js.map +1 -1
  179. package/build-module/query/edit/inspector-controls/index.js +11 -5
  180. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  181. package/build-module/query/edit/inspector-controls/order-control.js +1 -0
  182. package/build-module/query/edit/inspector-controls/order-control.js.map +1 -1
  183. package/build-module/query/edit/inspector-controls/sticky-control.js +1 -0
  184. package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -1
  185. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +99 -35
  186. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
  187. package/build-module/query/edit/query-content.js +9 -2
  188. package/build-module/query/edit/query-content.js.map +1 -1
  189. package/build-module/query/edit/query-placeholder.js +16 -12
  190. package/build-module/query/edit/query-placeholder.js.map +1 -1
  191. package/build-module/query/utils.js +69 -0
  192. package/build-module/query/utils.js.map +1 -1
  193. package/build-module/search/edit.js +2 -2
  194. package/build-module/search/edit.js.map +1 -1
  195. package/build-module/social-link/edit.js +4 -3
  196. package/build-module/social-link/edit.js.map +1 -1
  197. package/build-module/social-links/edit.js +0 -1
  198. package/build-module/social-links/edit.js.map +1 -1
  199. package/build-module/table/edit.js +1 -0
  200. package/build-module/table/edit.js.map +1 -1
  201. package/build-module/table-of-contents/edit.js +1 -1
  202. package/build-module/table-of-contents/edit.js.map +1 -1
  203. package/build-module/tag-cloud/edit.js +1 -0
  204. package/build-module/tag-cloud/edit.js.map +1 -1
  205. package/build-module/template-part/edit/advanced-controls.js +22 -2
  206. package/build-module/template-part/edit/advanced-controls.js.map +1 -1
  207. package/build-module/template-part/edit/import-controls.js +146 -0
  208. package/build-module/template-part/edit/import-controls.js.map +1 -0
  209. package/build-module/template-part/edit/index.js +2 -1
  210. package/build-module/template-part/edit/index.js.map +1 -1
  211. package/build-module/template-part/edit/utils/transformers.js +40 -0
  212. package/build-module/template-part/edit/utils/transformers.js.map +1 -0
  213. package/build-module/video/edit-common-settings.js +6 -5
  214. package/build-module/video/edit-common-settings.js.map +1 -1
  215. package/build-module/video/edit.js +1 -0
  216. package/build-module/video/edit.js.map +1 -1
  217. package/build-module/video/tracks-editor.js +1 -0
  218. package/build-module/video/tracks-editor.js.map +1 -1
  219. package/build-style/archives/editor-rtl.css +3 -3
  220. package/build-style/archives/editor.css +3 -3
  221. package/build-style/archives/style-rtl.css +3 -3
  222. package/build-style/archives/style.css +3 -3
  223. package/build-style/audio/editor-rtl.css +3 -3
  224. package/build-style/audio/editor.css +3 -3
  225. package/build-style/audio/style-rtl.css +3 -3
  226. package/build-style/audio/style.css +3 -3
  227. package/build-style/audio/theme-rtl.css +3 -3
  228. package/build-style/audio/theme.css +3 -3
  229. package/build-style/avatar/editor-rtl.css +3 -3
  230. package/build-style/avatar/editor.css +3 -3
  231. package/build-style/avatar/style-rtl.css +3 -3
  232. package/build-style/avatar/style.css +3 -3
  233. package/build-style/block/editor-rtl.css +3 -3
  234. package/build-style/block/editor.css +3 -3
  235. package/build-style/button/editor-rtl.css +3 -3
  236. package/build-style/button/editor.css +3 -3
  237. package/build-style/button/style-rtl.css +3 -3
  238. package/build-style/button/style.css +3 -3
  239. package/build-style/buttons/editor-rtl.css +3 -3
  240. package/build-style/buttons/editor.css +3 -3
  241. package/build-style/buttons/style-rtl.css +3 -3
  242. package/build-style/buttons/style.css +3 -3
  243. package/build-style/calendar/style-rtl.css +3 -3
  244. package/build-style/calendar/style.css +3 -3
  245. package/build-style/categories/editor-rtl.css +3 -3
  246. package/build-style/categories/editor.css +3 -3
  247. package/build-style/categories/style-rtl.css +3 -3
  248. package/build-style/categories/style.css +3 -3
  249. package/build-style/classic-rtl.css +3 -3
  250. package/build-style/classic.css +3 -3
  251. package/build-style/code/editor-rtl.css +3 -3
  252. package/build-style/code/editor.css +3 -3
  253. package/build-style/code/style-rtl.css +3 -3
  254. package/build-style/code/style.css +3 -3
  255. package/build-style/code/theme-rtl.css +3 -3
  256. package/build-style/code/theme.css +3 -3
  257. package/build-style/columns/editor-rtl.css +3 -3
  258. package/build-style/columns/editor.css +3 -3
  259. package/build-style/columns/style-rtl.css +3 -3
  260. package/build-style/columns/style.css +3 -3
  261. package/build-style/comment-author-avatar/editor-rtl.css +3 -3
  262. package/build-style/comment-author-avatar/editor.css +3 -3
  263. package/build-style/comment-content/style-rtl.css +3 -3
  264. package/build-style/comment-content/style.css +3 -3
  265. package/build-style/comment-template/style-rtl.css +3 -3
  266. package/build-style/comment-template/style.css +3 -3
  267. package/build-style/comments/editor-rtl.css +3 -3
  268. package/build-style/comments/editor.css +3 -3
  269. package/build-style/comments/style-rtl.css +3 -3
  270. package/build-style/comments/style.css +3 -3
  271. package/build-style/comments-pagination/editor-rtl.css +3 -3
  272. package/build-style/comments-pagination/editor.css +3 -3
  273. package/build-style/comments-pagination/style-rtl.css +3 -3
  274. package/build-style/comments-pagination/style.css +3 -3
  275. package/build-style/comments-pagination-numbers/editor-rtl.css +3 -3
  276. package/build-style/comments-pagination-numbers/editor.css +3 -3
  277. package/build-style/comments-title/editor-rtl.css +3 -3
  278. package/build-style/comments-title/editor.css +3 -3
  279. package/build-style/common-rtl.css +3 -3
  280. package/build-style/common.css +3 -3
  281. package/build-style/cover/editor-rtl.css +3 -3
  282. package/build-style/cover/editor.css +3 -3
  283. package/build-style/cover/style-rtl.css +3 -3
  284. package/build-style/cover/style.css +3 -3
  285. package/build-style/editor-elements-rtl.css +3 -3
  286. package/build-style/editor-elements.css +3 -3
  287. package/build-style/editor-rtl.css +7 -9
  288. package/build-style/editor.css +7 -9
  289. package/build-style/elements-rtl.css +3 -3
  290. package/build-style/elements.css +3 -3
  291. package/build-style/embed/editor-rtl.css +3 -3
  292. package/build-style/embed/editor.css +3 -3
  293. package/build-style/embed/style-rtl.css +3 -3
  294. package/build-style/embed/style.css +3 -3
  295. package/build-style/embed/theme-rtl.css +3 -3
  296. package/build-style/embed/theme.css +3 -3
  297. package/build-style/file/editor-rtl.css +3 -3
  298. package/build-style/file/editor.css +3 -3
  299. package/build-style/file/style-rtl.css +3 -3
  300. package/build-style/file/style.css +3 -3
  301. package/build-style/freeform/editor-rtl.css +3 -3
  302. package/build-style/freeform/editor.css +3 -3
  303. package/build-style/gallery/editor-rtl.css +3 -3
  304. package/build-style/gallery/editor.css +3 -3
  305. package/build-style/gallery/style-rtl.css +3 -3
  306. package/build-style/gallery/style.css +3 -3
  307. package/build-style/gallery/theme-rtl.css +3 -3
  308. package/build-style/gallery/theme.css +3 -3
  309. package/build-style/group/editor-rtl.css +3 -3
  310. package/build-style/group/editor.css +3 -3
  311. package/build-style/group/style-rtl.css +3 -3
  312. package/build-style/group/style.css +3 -3
  313. package/build-style/group/theme-rtl.css +3 -3
  314. package/build-style/group/theme.css +3 -3
  315. package/build-style/heading/style-rtl.css +3 -3
  316. package/build-style/heading/style.css +3 -3
  317. package/build-style/html/editor-rtl.css +3 -3
  318. package/build-style/html/editor.css +3 -3
  319. package/build-style/image/editor-rtl.css +3 -3
  320. package/build-style/image/editor.css +3 -3
  321. package/build-style/image/style-rtl.css +3 -3
  322. package/build-style/image/style.css +3 -3
  323. package/build-style/image/theme-rtl.css +3 -3
  324. package/build-style/image/theme.css +3 -3
  325. package/build-style/latest-comments/style-rtl.css +3 -3
  326. package/build-style/latest-comments/style.css +3 -3
  327. package/build-style/latest-posts/editor-rtl.css +3 -3
  328. package/build-style/latest-posts/editor.css +3 -3
  329. package/build-style/latest-posts/style-rtl.css +3 -3
  330. package/build-style/latest-posts/style.css +3 -3
  331. package/build-style/list/style-rtl.css +3 -3
  332. package/build-style/list/style.css +3 -3
  333. package/build-style/media-text/editor-rtl.css +3 -3
  334. package/build-style/media-text/editor.css +3 -3
  335. package/build-style/media-text/style-rtl.css +3 -3
  336. package/build-style/media-text/style.css +3 -3
  337. package/build-style/more/editor-rtl.css +3 -3
  338. package/build-style/more/editor.css +3 -3
  339. package/build-style/navigation/editor-rtl.css +3 -9
  340. package/build-style/navigation/editor.css +3 -9
  341. package/build-style/navigation/style-rtl.css +3 -4
  342. package/build-style/navigation/style.css +3 -4
  343. package/build-style/navigation-link/editor-rtl.css +3 -3
  344. package/build-style/navigation-link/editor.css +3 -3
  345. package/build-style/navigation-link/style-rtl.css +3 -3
  346. package/build-style/navigation-link/style.css +3 -3
  347. package/build-style/navigation-submenu/editor-rtl.css +3 -3
  348. package/build-style/navigation-submenu/editor.css +3 -3
  349. package/build-style/nextpage/editor-rtl.css +3 -3
  350. package/build-style/nextpage/editor.css +3 -3
  351. package/build-style/page-list/editor-rtl.css +7 -3
  352. package/build-style/page-list/editor.css +7 -3
  353. package/build-style/page-list/style-rtl.css +3 -3
  354. package/build-style/page-list/style.css +3 -3
  355. package/build-style/paragraph/editor-rtl.css +3 -3
  356. package/build-style/paragraph/editor.css +3 -3
  357. package/build-style/paragraph/style-rtl.css +3 -3
  358. package/build-style/paragraph/style.css +3 -3
  359. package/build-style/post-author/style-rtl.css +3 -3
  360. package/build-style/post-author/style.css +3 -3
  361. package/build-style/post-comments-form/editor-rtl.css +3 -3
  362. package/build-style/post-comments-form/editor.css +3 -3
  363. package/build-style/post-comments-form/style-rtl.css +3 -3
  364. package/build-style/post-comments-form/style.css +3 -3
  365. package/build-style/post-date/style-rtl.css +3 -3
  366. package/build-style/post-date/style.css +3 -3
  367. package/build-style/post-excerpt/editor-rtl.css +3 -3
  368. package/build-style/post-excerpt/editor.css +3 -3
  369. package/build-style/post-excerpt/style-rtl.css +3 -3
  370. package/build-style/post-excerpt/style.css +3 -3
  371. package/build-style/post-featured-image/editor-rtl.css +3 -3
  372. package/build-style/post-featured-image/editor.css +3 -3
  373. package/build-style/post-featured-image/style-rtl.css +3 -3
  374. package/build-style/post-featured-image/style.css +3 -3
  375. package/build-style/post-navigation-link/style-rtl.css +3 -3
  376. package/build-style/post-navigation-link/style.css +3 -3
  377. package/build-style/post-template/editor-rtl.css +3 -3
  378. package/build-style/post-template/editor.css +3 -3
  379. package/build-style/post-template/style-rtl.css +3 -3
  380. package/build-style/post-template/style.css +3 -3
  381. package/build-style/post-terms/style-rtl.css +3 -3
  382. package/build-style/post-terms/style.css +3 -3
  383. package/build-style/post-title/style-rtl.css +3 -3
  384. package/build-style/post-title/style.css +3 -3
  385. package/build-style/preformatted/style-rtl.css +3 -3
  386. package/build-style/preformatted/style.css +3 -3
  387. package/build-style/pullquote/editor-rtl.css +3 -3
  388. package/build-style/pullquote/editor.css +3 -3
  389. package/build-style/pullquote/style-rtl.css +3 -3
  390. package/build-style/pullquote/style.css +3 -3
  391. package/build-style/pullquote/theme-rtl.css +3 -3
  392. package/build-style/pullquote/theme.css +3 -3
  393. package/build-style/query/editor-rtl.css +3 -3
  394. package/build-style/query/editor.css +3 -3
  395. package/build-style/query-pagination/editor-rtl.css +3 -3
  396. package/build-style/query-pagination/editor.css +3 -3
  397. package/build-style/query-pagination/style-rtl.css +3 -3
  398. package/build-style/query-pagination/style.css +3 -3
  399. package/build-style/query-pagination-numbers/editor-rtl.css +3 -3
  400. package/build-style/query-pagination-numbers/editor.css +3 -3
  401. package/build-style/query-title/style-rtl.css +3 -3
  402. package/build-style/query-title/style.css +3 -3
  403. package/build-style/quote/style-rtl.css +3 -3
  404. package/build-style/quote/style.css +3 -3
  405. package/build-style/quote/theme-rtl.css +3 -3
  406. package/build-style/quote/theme.css +3 -3
  407. package/build-style/read-more/style-rtl.css +3 -3
  408. package/build-style/read-more/style.css +3 -3
  409. package/build-style/reset-rtl.css +3 -3
  410. package/build-style/reset.css +3 -3
  411. package/build-style/rss/editor-rtl.css +3 -3
  412. package/build-style/rss/editor.css +3 -3
  413. package/build-style/rss/style-rtl.css +3 -3
  414. package/build-style/rss/style.css +3 -3
  415. package/build-style/search/editor-rtl.css +3 -3
  416. package/build-style/search/editor.css +3 -3
  417. package/build-style/search/style-rtl.css +3 -3
  418. package/build-style/search/style.css +3 -3
  419. package/build-style/search/theme-rtl.css +3 -3
  420. package/build-style/search/theme.css +3 -3
  421. package/build-style/separator/editor-rtl.css +3 -3
  422. package/build-style/separator/editor.css +3 -3
  423. package/build-style/separator/style-rtl.css +3 -3
  424. package/build-style/separator/style.css +3 -3
  425. package/build-style/separator/theme-rtl.css +3 -3
  426. package/build-style/separator/theme.css +3 -3
  427. package/build-style/shortcode/editor-rtl.css +3 -3
  428. package/build-style/shortcode/editor.css +3 -3
  429. package/build-style/site-logo/editor-rtl.css +3 -3
  430. package/build-style/site-logo/editor.css +3 -3
  431. package/build-style/site-logo/style-rtl.css +3 -3
  432. package/build-style/site-logo/style.css +3 -3
  433. package/build-style/site-tagline/editor-rtl.css +3 -3
  434. package/build-style/site-tagline/editor.css +3 -3
  435. package/build-style/site-title/editor-rtl.css +3 -3
  436. package/build-style/site-title/editor.css +3 -3
  437. package/build-style/site-title/style-rtl.css +3 -3
  438. package/build-style/site-title/style.css +3 -3
  439. package/build-style/social-link/editor-rtl.css +3 -3
  440. package/build-style/social-link/editor.css +3 -3
  441. package/build-style/social-links/editor-rtl.css +3 -3
  442. package/build-style/social-links/editor.css +3 -3
  443. package/build-style/social-links/style-rtl.css +3 -3
  444. package/build-style/social-links/style.css +3 -3
  445. package/build-style/spacer/editor-rtl.css +3 -3
  446. package/build-style/spacer/editor.css +3 -3
  447. package/build-style/spacer/style-rtl.css +3 -3
  448. package/build-style/spacer/style.css +3 -3
  449. package/build-style/style-rtl.css +13 -5
  450. package/build-style/style.css +13 -5
  451. package/build-style/table/editor-rtl.css +3 -3
  452. package/build-style/table/editor.css +3 -3
  453. package/build-style/table/style-rtl.css +9 -3
  454. package/build-style/table/style.css +9 -3
  455. package/build-style/table/theme-rtl.css +3 -9
  456. package/build-style/table/theme.css +3 -9
  457. package/build-style/tag-cloud/style-rtl.css +3 -3
  458. package/build-style/tag-cloud/style.css +3 -3
  459. package/build-style/template-part/editor-rtl.css +3 -3
  460. package/build-style/template-part/editor.css +3 -3
  461. package/build-style/template-part/theme-rtl.css +3 -3
  462. package/build-style/template-part/theme.css +3 -3
  463. package/build-style/text-columns/editor-rtl.css +3 -3
  464. package/build-style/text-columns/editor.css +3 -3
  465. package/build-style/text-columns/style-rtl.css +3 -3
  466. package/build-style/text-columns/style.css +3 -3
  467. package/build-style/theme-rtl.css +3 -9
  468. package/build-style/theme.css +3 -9
  469. package/build-style/verse/style-rtl.css +7 -4
  470. package/build-style/verse/style.css +7 -4
  471. package/build-style/video/editor-rtl.css +3 -3
  472. package/build-style/video/editor.css +3 -3
  473. package/build-style/video/style-rtl.css +3 -3
  474. package/build-style/video/style.css +3 -3
  475. package/build-style/video/theme-rtl.css +3 -3
  476. package/build-style/video/theme.css +3 -3
  477. package/package.json +29 -29
  478. package/src/archives/edit.js +1 -0
  479. package/src/audio/edit.js +2 -0
  480. package/src/categories/edit.js +1 -1
  481. package/src/comments/edit/comments-inspector-controls.js +12 -2
  482. package/src/comments/index.php +0 -1
  483. package/src/cover/edit/inspector-controls.js +4 -4
  484. package/src/embed/embed-preview.js +1 -0
  485. package/src/file/inspector.js +1 -0
  486. package/src/freeform/edit.js +48 -29
  487. package/src/freeform/modal.js +111 -0
  488. package/src/gallery/edit.js +19 -2
  489. package/src/gallery/gallery.js +4 -13
  490. package/src/gallery/v1/edit.js +2 -0
  491. package/src/group/block.json +3 -0
  492. package/src/group/edit.js +1 -0
  493. package/src/image/image.js +27 -36
  494. package/src/latest-posts/edit.js +6 -7
  495. package/src/latest-posts/test/__snapshots__/edit.native.js.snap +3 -0
  496. package/src/latest-posts/test/edit.native.js +49 -0
  497. package/src/media-text/edit.js +1 -0
  498. package/src/missing/edit.native.js +13 -6
  499. package/src/more/test/__snapshots__/edit.native.js.snap +7 -0
  500. package/src/more/test/edit.native.js +41 -0
  501. package/src/navigation/edit/index.js +6 -4
  502. package/src/navigation/edit/menu-inspector-controls.js +115 -44
  503. package/src/navigation/edit/navigation-menu-selector.js +24 -11
  504. package/src/navigation/edit/utils.js +82 -0
  505. package/src/navigation/editor.scss +0 -7
  506. package/src/navigation/index.php +32 -0
  507. package/src/navigation/leaf-more-menu.js +93 -0
  508. package/src/navigation/style.scss +0 -1
  509. package/src/navigation-link/edit.js +23 -65
  510. package/src/navigation-link/index.php +62 -3
  511. package/src/navigation-link/update-attributes.js +1 -1
  512. package/src/navigation-submenu/edit.js +29 -100
  513. package/src/navigation-submenu/index.php +34 -2
  514. package/src/page-list/block.json +18 -1
  515. package/src/page-list/edit.js +30 -22
  516. package/src/page-list/editor.scss +4 -0
  517. package/src/page-list/index.js +8 -2
  518. package/src/page-list/index.php +14 -10
  519. package/src/page-list-item/block.json +2 -1
  520. package/src/page-list-item/edit.js +17 -9
  521. package/src/post-author/edit.js +2 -0
  522. package/src/post-featured-image/dimension-controls.js +1 -0
  523. package/src/post-featured-image/overlay.js +0 -1
  524. package/src/query/edit/index.js +1 -0
  525. package/src/query/edit/inspector-controls/index.js +50 -38
  526. package/src/query/edit/inspector-controls/order-control.js +1 -0
  527. package/src/query/edit/inspector-controls/sticky-control.js +1 -0
  528. package/src/query/edit/inspector-controls/taxonomy-controls.js +102 -38
  529. package/src/query/edit/query-content.js +15 -1
  530. package/src/query/edit/query-placeholder.js +15 -14
  531. package/src/query/utils.js +59 -1
  532. package/src/rss/index.php +1 -1
  533. package/src/search/edit.js +2 -2
  534. package/src/separator/test/__snapshots__/edit.native.js.snap +7 -0
  535. package/src/separator/test/edit.native.js +41 -0
  536. package/src/social-link/edit.js +5 -4
  537. package/src/social-links/edit.js +0 -1
  538. package/src/table/edit.js +1 -0
  539. package/src/table/style.scss +8 -0
  540. package/src/table/theme.scss +0 -8
  541. package/src/table-of-contents/edit.js +1 -1
  542. package/src/tag-cloud/edit.js +1 -0
  543. package/src/template-part/edit/advanced-controls.js +36 -0
  544. package/src/template-part/edit/import-controls.js +180 -0
  545. package/src/template-part/edit/index.js +1 -0
  546. package/src/template-part/edit/utils/transformers.js +37 -0
  547. package/src/verse/style.scss +4 -1
  548. package/src/verse/test/__snapshots__/edit.native.js.snap +13 -0
  549. package/src/verse/test/edit.native.js +40 -33
  550. package/src/video/edit-common-settings.js +6 -5
  551. package/src/video/edit.js +1 -0
  552. package/src/video/tracks-editor.js +1 -0
  553. package/tsconfig.tsbuildinfo +1 -1
  554. package/build/query/constants.js +0 -16
  555. package/build/query/constants.js.map +0 -1
  556. package/build-module/query/constants.js +0 -7
  557. package/build-module/query/constants.js.map +0 -1
  558. package/src/query/constants.js +0 -7
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","useTaxonomyTerms","slug","select","coreStore","getEntityRecords","context","per_page","MAX_FETCHED_TERMS","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","map","taxonomy","value","handleChange","newTermIds","TaxonomyItem","onTermsChange","newTermValues","termIds","Set","add","Array","from","taxQueryValue","t","filter","Boolean"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA;AACA,MAAMA,oBAAoB,GAAG,CAAEC,KAAF,EAASC,SAAT,KAAwB;AAAA;;AACpD;AACA,QAAMC,MAAM,GACX,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,S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oB,CAEZC,OAFY,EAGpBhB,GAHoB,CAGbnB,IAAF,KAAc;AAAEF,IAAAA,EAAE,EAAEE,IAAI,CAACF,EAAX;AAAeuB,IAAAA,KAAK,EAAErB,IAAI,CAACC;AAA3B,GAAd,CAHe,CAAtB;AAKA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAGmB,QAAQ,CAACnB,IADlB;AAEC,IAAA,KAAK,EAAG+B,aAFT;AAGC,IAAA,WAAW,EAAGrC,KAAK,CAACwB,GAAN,CAAac,CAAF,IAASA,CAAC,CAAChC,IAAtB,CAHf;AAIC,IAAA,QAAQ,EAAGwB,aAJZ;AAKC,IAAA,uBAAuB,EAAG;AAL3B,IADD,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\nimport { MAX_FETCHED_TERMS } from '../../constants';\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nconst useTaxonomyTerms = ( slug ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst terms = select( coreStore ).getEntityRecords(\n\t\t\t\t'taxonomy',\n\t\t\t\tslug,\n\t\t\t\t{ context: 'view', per_page: MAX_FETCHED_TERMS }\n\t\t\t);\n\t\t\treturn { terms };\n\t\t},\n\t\t[ slug ]\n\t);\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst value = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\nfunction TaxonomyItem( { taxonomy, value, onChange } ) {\n\tconst { terms } = useTaxonomyTerms( taxonomy.slug );\n\tif ( ! terms?.length ) {\n\t\treturn null;\n\t}\n\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst termIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( terms, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\ttermIds.add( termId );\n\t\t\t}\n\t\t}\n\n\t\tonChange( Array.from( termIds ) );\n\t};\n\n\t// Selects only the existing term ids in proper format to be\n\t// used in `FormTokenField`. This prevents the component from\n\t// crashing in the editor, when non existing term ids were provided.\n\tconst taxQueryValue = value\n\t\t.map( ( termId ) => terms.find( ( t ) => t.id === termId ) )\n\t\t.filter( Boolean )\n\t\t.map( ( term ) => ( { id: term.id, value: term.name } ) );\n\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ taxQueryValue }\n\t\t\t\tsuggestions={ terms.map( ( t ) => t.name ) }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["EMPTY_ARRAY","BASE_QUERY","order","_fields","context","getTermIdByTermValue","terms","termValue","termId","id","find","term","name","termValueLower","toLocaleLowerCase","TaxonomyControls","onChange","query","postType","taxQuery","taxonomies","length","map","taxonomy","termIds","slug","handleChange","newTermIds","TaxonomyItem","search","setSearch","value","setValue","suggestions","setSuggestions","debouncedSearch","searchResults","searchHasResolved","select","getEntityRecords","hasFinishedResolution","coreStore","selectorArgs","orderby","exclude","per_page","existingTerms","include","sanitizedValue","reduce","accumulator","entity","push","result","onTermsChange","newTermValues","Set","add","Array","from"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,MAAMA,WAAW,GAAG,EAApB;AACA,MAAMC,UAAU,GAAG;AAClBC,EAAAA,KAAK,EAAE,KADW;AAElBC,EAAAA,OAAO,EAAE,SAFS;AAGlBC,EAAAA,OAAO,EAAE;AAHS,CAAnB,C,CAMA;;AACA,MAAMC,oBAAoB,GAAG,CAAEC,KAAF,EAASC,SAAT,KAAwB;AAAA;;AACpD;AACA,QAAMC,MAAM,GACX,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEE,EAAX,qBAAiBH,KAAK,CAACI,IAA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Ac,CAAEE,aAAa,CAACd,GAAd,CAAqB+B,MAAF,IAAcA,MAAM,CAACzC,IAAxC,CAAF,CAAd;AACA,GAHD,EAGG,CAAEwB,aAAF,EAAiBC,iBAAjB,CAHH;;AAIA,QAAMiB,aAAa,GAAKC,aAAF,IAAqB;AAC1C,UAAM5B,UAAU,GAAG,IAAI6B,GAAJ,EAAnB;;AACA,SAAM,MAAMjD,SAAZ,IAAyBgD,aAAzB,EAAyC;AACxC,YAAM/C,MAAM,GAAGH,oBAAoB,CAAE+B,aAAF,EAAiB7B,SAAjB,CAAnC;;AACA,UAAKC,MAAL,EAAc;AACbmB,QAAAA,UAAU,CAAC8B,GAAX,CAAgBjD,MAAhB;AACA;AACD;;AACD0B,IAAAA,cAAc,CAAElC,WAAF,CAAd;AACAgB,IAAAA,QAAQ,CAAE0C,KAAK,CAACC,IAAN,CAAYhC,UAAZ,CAAF,CAAR;AACA,GAVD;;AAWA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,0BAAD;AACC,IAAA,KAAK,EAAGJ,QAAQ,CAACX,IADlB;AAEC,IAAA,KAAK,EAAGmB,KAFT;AAGC,IAAA,aAAa,EAAGI,eAHjB;AAIC,IAAA,WAAW,EAAGF,WAJf;AAKC,IAAA,QAAQ,EAAGqB,aALZ;AAMC,IAAA,uBAAuB,EAAG;AAN3B,IADD,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useTaxonomies } from '../../utils';\n\nconst EMPTY_ARRAY = [];\nconst BASE_QUERY = {\n\torder: 'asc',\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( terms, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId =\n\t\ttermValue?.id || terms.find( ( term ) => term.name === termValue )?.id;\n\tif ( termId ) {\n\t\treturn termId;\n\t}\n\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\treturn terms.find(\n\t\t( term ) => term.name.toLocaleLowerCase() === termValueLower\n\t)?.id;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst { postType, taxQuery } = query;\n\n\tconst taxonomies = useTaxonomies( postType );\n\tif ( ! taxonomies || taxonomies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ taxonomies.map( ( taxonomy ) => {\n\t\t\t\tconst termIds = taxQuery?.[ taxonomy.slug ] || [];\n\t\t\t\tconst handleChange = ( newTermIds ) =>\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\ttaxQuery: {\n\t\t\t\t\t\t\t...taxQuery,\n\t\t\t\t\t\t\t[ taxonomy.slug ]: newTermIds,\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\n\t\t\t\treturn (\n\t\t\t\t\t<TaxonomyItem\n\t\t\t\t\t\tkey={ taxonomy.slug }\n\t\t\t\t\t\ttaxonomy={ taxonomy }\n\t\t\t\t\t\ttermIds={ termIds }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n\n/**\n * Renders a `FormTokenField` for a given taxonomy.\n *\n * @param {Object} props The props for the component.\n * @param {Object} props.taxonomy The taxonomy object.\n * @param {number[]} props.termIds An array with the block's term ids for the given taxonomy.\n * @param {Function} props.onChange Callback `onChange` function.\n * @return {JSX.Element} The rendered component.\n */\nfunction TaxonomyItem( { taxonomy, termIds, onChange } ) {\n\tconst [ search, setSearch ] = useState( '' );\n\tconst [ value, setValue ] = useState( EMPTY_ARRAY );\n\tconst [ suggestions, setSuggestions ] = useState( EMPTY_ARRAY );\n\tconst debouncedSearch = useDebounce( setSearch, 250 );\n\tconst { searchResults, searchHasResolved } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! search ) {\n\t\t\t\treturn { searchResults: EMPTY_ARRAY, searchHasResolved: true };\n\t\t\t}\n\t\t\tconst { getEntityRecords, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst selectorArgs = [\n\t\t\t\t'taxonomy',\n\t\t\t\ttaxonomy.slug,\n\t\t\t\t{\n\t\t\t\t\t...BASE_QUERY,\n\t\t\t\t\tsearch,\n\t\t\t\t\torderby: 'name',\n\t\t\t\t\texclude: termIds,\n\t\t\t\t\tper_page: 20,\n\t\t\t\t},\n\t\t\t];\n\t\t\treturn {\n\t\t\t\tsearchResults: getEntityRecords( ...selectorArgs ),\n\t\t\t\tsearchHasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tselectorArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ search, termIds ]\n\t);\n\t// `existingTerms` are the ones fetched from the API and their type is `{ id: number; name: string }`.\n\t// They are used to extract the terms' names to populate the `FormTokenField` properly\n\t// and to sanitize the provided `termIds`, by setting only the ones that exist.\n\tconst existingTerms = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! termIds?.length ) return EMPTY_ARRAY;\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\treturn getEntityRecords( 'taxonomy', taxonomy.slug, {\n\t\t\t\t...BASE_QUERY,\n\t\t\t\tinclude: termIds,\n\t\t\t\tper_page: termIds.length,\n\t\t\t} );\n\t\t},\n\t\t[ termIds ]\n\t);\n\t// Update the `value` state only after the selectors are resolved\n\t// to avoid emptying the input when we're changing terms.\n\tuseEffect( () => {\n\t\tif ( ! termIds?.length ) {\n\t\t\tsetValue( EMPTY_ARRAY );\n\t\t}\n\t\tif ( ! existingTerms?.length ) return;\n\t\t// Returns only the existing entity ids. This prevents the component\n\t\t// from crashing in the editor, when non existing ids are provided.\n\t\tconst sanitizedValue = termIds.reduce( ( accumulator, id ) => {\n\t\t\tconst entity = existingTerms.find( ( term ) => term.id === id );\n\t\t\tif ( entity ) {\n\t\t\t\taccumulator.push( {\n\t\t\t\t\tid,\n\t\t\t\t\tvalue: entity.name,\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, [] );\n\t\tsetValue( sanitizedValue );\n\t}, [ termIds, existingTerms ] );\n\t// Update suggestions only when the query has resolved.\n\tuseEffect( () => {\n\t\tif ( ! searchHasResolved ) return;\n\t\tsetSuggestions( searchResults.map( ( result ) => result.name ) );\n\t}, [ searchResults, searchHasResolved ] );\n\tconst onTermsChange = ( newTermValues ) => {\n\t\tconst newTermIds = new Set();\n\t\tfor ( const termValue of newTermValues ) {\n\t\t\tconst termId = getTermIdByTermValue( searchResults, termValue );\n\t\t\tif ( termId ) {\n\t\t\t\tnewTermIds.add( termId );\n\t\t\t}\n\t\t}\n\t\tsetSuggestions( EMPTY_ARRAY );\n\t\tonChange( Array.from( newTermIds ) );\n\t};\n\treturn (\n\t\t<div className=\"block-library-query-inspector__taxonomy-control\">\n\t\t\t<FormTokenField\n\t\t\t\tlabel={ taxonomy.name }\n\t\t\t\tvalue={ value }\n\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\tsuggestions={ suggestions }\n\t\t\t\tonChange={ onTermsChange }\n\t\t\t\t__experimentalShowHowTo={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -23,8 +23,6 @@ var _queryToolbar = _interopRequireDefault(require("./query-toolbar"));
23
23
 
24
24
  var _inspectorControls = _interopRequireDefault(require("./inspector-controls"));
25
25
 
26
- var _constants = require("../constants");
27
-
28
26
  /**
29
27
  * WordPress dependencies
30
28
  */
@@ -32,6 +30,7 @@ var _constants = require("../constants");
32
30
  /**
33
31
  * Internal dependencies
34
32
  */
33
+ const DEFAULTS_POSTS_PER_PAGE = 3;
35
34
  const TEMPLATE = [['core/post-template']];
36
35
 
37
36
  function QueryContent(_ref) {
@@ -84,7 +83,7 @@ function QueryContent(_ref) {
84
83
  getSettings
85
84
  } = select(_blockEditor.store);
86
85
  return {
87
- postsPerPage: +getSettings().postsPerPage || _constants.DEFAULTS_POSTS_PER_PAGE
86
+ postsPerPage: +getSettings().postsPerPage || DEFAULTS_POSTS_PER_PAGE
88
87
  };
89
88
  }, []); // There are some effects running where some initialization logic is
90
89
  // happening and setting some values to some attributes (ex. queryId).
@@ -132,6 +131,11 @@ function QueryContent(_ref) {
132
131
  }
133
132
  });
134
133
 
134
+ const htmlElementMessages = {
135
+ main: (0, _i18n.__)('The <main> element should be used for the primary content of your document only. '),
136
+ section: (0, _i18n.__)("The <section> element should represent a standalone portion of the document that can't be better represented by another element."),
137
+ aside: (0, _i18n.__)("The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.")
138
+ };
135
139
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_inspectorControls.default, {
136
140
  attributes: attributes,
137
141
  setQuery: updateQuery,
@@ -146,6 +150,7 @@ function QueryContent(_ref) {
146
150
  })), (0, _element.createElement)(_blockEditor.InspectorControls, {
147
151
  __experimentalGroup: "advanced"
148
152
  }, (0, _element.createElement)(_components.SelectControl, {
153
+ __nextHasNoMarginBottom: true,
149
154
  label: (0, _i18n.__)('HTML element'),
150
155
  options: [{
151
156
  label: (0, _i18n.__)('Default (<div>)'),
@@ -163,7 +168,8 @@ function QueryContent(_ref) {
163
168
  value: TagName,
164
169
  onChange: value => setAttributes({
165
170
  tagName: value
166
- })
171
+ }),
172
+ help: htmlElementMessages[TagName]
167
173
  })), (0, _element.createElement)(TagName, innerBlocksProps));
168
174
  }
169
175
  //# sourceMappingURL=query-content.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"names":["TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","instanceId","themeSupportsLayout","select","getSettings","supportsLayout","defaultLayout","usedLayout","type","blockProps","innerBlocksProps","template","__experimentalLayout","undefined","postsPerPage","DEFAULTS_POSTS_PER_PAGE","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","label","value"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAQA;;AACA;;AAKA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAeA;AACA;AACA;AAKA,MAAMA,QAAQ,GAAG,CAAE,CAAE,oBAAF,CAAF,CAAjB;;AACe,SAASC,YAAT,OAMX;AAAA,MANkC;AACrCC,IAAAA,UADqC;AAErCC,IAAAA,aAFqC;AAGrCC,IAAAA,yBAHqC;AAIrCC,IAAAA,IAJqC;AAKrCC,IAAAA;AALqC,GAMlC;AACH,QAAM;AACLC,IAAAA,OADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,OAAO,EAAEC,OAAO,GAAG,KAJd;AAKLC,IAAAA,MAAM,GAAG;AALJ,MAMFV,UANJ;AAOA,QAAM;AAAEW,IAAAA;AAAF,MACL,uBAAaC,kBAAb,CADD;AAEA,QAAMC,UAAU,GAAG,4BAAed,YAAf,CAAnB;AACA,QAAM;AAAEe,IAAAA;AAAF,MAA0B,qBAAaC,MAAF,IAAc;AAAA;;AACxD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEH,kBAAF,CAA9B;AACA,WAAO;AAAEE,MAAAA,mBAAmB,kBAAEE,WAAW,EAAb,iDAAE,aAAeC;AAAtC,KAAP;AACA,GAH+B,EAG7B,EAH6B,CAAhC;AAIA,QAAMC,aAAa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T;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAJS,CAFX;AAQC,IAAA,KAAK,EAAG9B,OART;AASC,IAAA,QAAQ,EAAK8B,KAAF,IACVtC,aAAa,CAAE;AAAEO,MAAAA,OAAO,EAAE+B;AAAX,KAAF;AAVf,IADD,CAhBD,EA+BC,4BAAC,OAAD,EAAcjB,gBAAd,CA/BD,CADD;AAmCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\nimport { DEFAULTS_POSTS_PER_PAGE } from '../constants';\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport default function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tlayout = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn { themeSupportsLayout: getSettings()?.supportsLayout };\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\t+getSettings().postsPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\tif ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-content.js"],"names":["DEFAULTS_POSTS_PER_PAGE","TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","instanceId","themeSupportsLayout","select","getSettings","supportsLayout","defaultLayout","usedLayout","type","blockProps","innerBlocksProps","template","__experimentalLayout","undefined","postsPerPage","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","htmlElementMessages","main","section","aside","label","value"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAQA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAeA;AACA;AACA;AAIA,MAAMA,uBAAuB,GAAG,CAAhC;AAEA,MAAMC,QAAQ,GAAG,CA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Press 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\tconst htmlElementMessages = {\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\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\t__nextHasNoMarginBottom\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\thelp={ htmlElementMessages[ TagName ] }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n"]}
@@ -17,9 +17,15 @@ var _components = require("@wordpress/components");
17
17
 
18
18
  var _i18n = require("@wordpress/i18n");
19
19
 
20
+ var _utils = require("../utils");
21
+
20
22
  /**
21
23
  * WordPress dependencies
22
24
  */
25
+
26
+ /**
27
+ * Internal dependencies
28
+ */
23
29
  function QueryPlaceholder(_ref) {
24
30
  var _matchingVariation$ic, _blockType$icon;
25
31
 
@@ -59,7 +65,6 @@ function QueryPlaceholder(_ref) {
59
65
  if (isStartingBlank) {
60
66
  return (0, _element.createElement)(QueryVariationPicker, {
61
67
  clientId: clientId,
62
- name: name,
63
68
  attributes: attributes,
64
69
  setAttributes: setAttributes,
65
70
  icon: icon,
@@ -85,13 +90,12 @@ function QueryPlaceholder(_ref) {
85
90
  function QueryVariationPicker(_ref2) {
86
91
  let {
87
92
  clientId,
88
- name,
89
93
  attributes,
90
94
  setAttributes,
91
95
  icon,
92
96
  label
93
97
  } = _ref2;
94
- const variations = (0, _data.useSelect)(select => select(_blocks.store).getBlockVariations(name, 'block'), [name]);
98
+ const scopeVariations = (0, _utils.useScopedBlockVariations)(attributes);
95
99
  const {
96
100
  replaceInnerBlocks
97
101
  } = (0, _data.useDispatch)(_blockEditor.store);
@@ -99,18 +103,19 @@ function QueryVariationPicker(_ref2) {
99
103
  return (0, _element.createElement)("div", blockProps, (0, _element.createElement)(_blockEditor.__experimentalBlockVariationPicker, {
100
104
  icon: icon,
101
105
  label: label,
102
- variations: variations,
103
- onSelect: nextVariation => {
104
- if (nextVariation.attributes) {
105
- setAttributes({ ...nextVariation.attributes,
106
- query: { ...nextVariation.attributes.query,
107
- postType: attributes.query.postType || nextVariation.attributes.query.postType
108
- }
106
+ variations: scopeVariations,
107
+ onSelect: variation => {
108
+ if (variation.attributes) {
109
+ setAttributes({ ...variation.attributes,
110
+ query: { ...variation.attributes.query,
111
+ postType: attributes.query.postType || variation.attributes.query.postType
112
+ },
113
+ namespace: attributes.namespace
109
114
  });
110
115
  }
111
116
 
112
- if (nextVariation.innerBlocks) {
113
- replaceInnerBlocks(clientId, (0, _blocks.createBlocksFromInnerBlocksTemplate)(nextVariation.innerBlocks), false);
117
+ if (variation.innerBlocks) {
118
+ replaceInnerBlocks(clientId, (0, _blocks.createBlocksFromInnerBlocksTemplate)(variation.innerBlocks), false);
114
119
  }
115
120
  }
116
121
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"names":["QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","setAttributes","isStartingBlank","setIsStartingBlank","blockProps","blockType","allVariations","hasPatterns","select","getBlockVariations","getBlockType","blocksStore","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId","length","matchingVariation","icon","src","label","title","QueryVariationPicker","variations","replaceInnerBlocks","nextVariation","query","postType","innerBlocks"],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,OAAhD,CADI,EAElB,CAAEA,IAAF,CAFkB,CAAnB;AAIA,QAAM;AAAEyB,IAAAA;AAAF,MAAyB,uBAAaV,kBAAb,CAA/B;AACA,QAAMV,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,4BAAC,+CAAD;AACC,IAAA,IAAI,EAAGc,IADR;AAEC,IAAA,KAAK,EAAGE,KAFT;AAGC,IAAA,UAAU,EAAGG,UAHd;AAIC,IAAA,QAAQ,EAAKE,aAAF,IAAqB;AAC/B,UAAKA,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,EAEjB,iDACC2B,aAAa,CAACG,WADf,CAFiB,EAKjB,KALiB,CAAlB;AAOA;AACD;AAzBF,IADD,CADD;AA+BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useState } from '@wordpress/element';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalBlockVariationPicker,\n\t__experimentalGetMatchingVariation as getMatchingVariation,\n} from '@wordpress/block-editor';\nimport { Button, Placeholder } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function QueryPlaceholder( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\n\tconst { blockType, allVariations, hasPatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tallVariations: getBlockVariations( name ),\n\t\t\t\thasPatterns: !! __experimentalGetPatternsByBlockTypes(\n\t\t\t\t\tname,\n\t\t\t\t\trootClientId\n\t\t\t\t).length,\n\t\t\t};\n\t\t},\n\t\t[ name, clientId ]\n\t);\n\n\tconst matchingVariation = getMatchingVariation( attributes, allVariations );\n\tconst icon =\n\t\tmatchingVariation?.icon?.src ||\n\t\tmatchingVariation?.icon ||\n\t\tblockType?.icon?.src;\n\tconst label = matchingVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryVariationPicker\n\t\t\t\tclientId={ clientId }\n\t\t\t\tname={ name }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nfunction QueryVariationPicker( {\n\tclientId,\n\tname,\n\tattributes,\n\tsetAttributes,\n\ticon,\n\tlabel,\n} ) {\n\tconst variations = useSelect(\n\t\t( select ) => select( blocksStore ).getBlockVariations( name, 'block' ),\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={ variations }\n\t\t\t\tonSelect={ ( nextVariation ) => {\n\t\t\t\t\tif ( nextVariation.attributes ) {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t...nextVariation.attributes,\n\t\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\t\t...nextVariation.attributes.query,\n\t\t\t\t\t\t\t\tpostType:\n\t\t\t\t\t\t\t\t\tattributes.query.postType ||\n\t\t\t\t\t\t\t\t\tnextVariation.attributes.query.postType,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tif ( nextVariation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tnextVariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"names":["QueryPlaceholder","attributes","clientId","name","openPatternSelectionModal","setAttributes","isStartingBlank","setIsStartingBlank","blockProps","blockType","allVariations","hasPatterns","select","getBlockVariations","getBlockType","blocksStore","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId","length","matchingVariation","icon","src","label","title","QueryVariationPicker","scopeVariations","replaceInnerBlocks","variation","query","postType","namespace","innerBlocks"],"mappings":";;;;;;;AAQA;;AALA;;AACA;;AAKA;;AAMA;;AACA;;AAKA;;AArBA;AACA;AACA;;AAgBA;AACA;AACA;AAGe,SAASA,gBAAT,OAMX;AAAA;;AAAA,MANsC;AACzCC,IAAAA,UADyC;AAEzCC,IAAAA,QAFyC;AAGzCC,IAAAA,IAHyC;AAIzCC,IAAAA,yBAJyC;AAKzCC,IAAAA;AALyC,GAMtC;AACH,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,KAAV,CAAhD;AACA,QAAMC,UAAU,GAAG,iCAAnB;AAEA,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,aAAb;AAA4BC,IAAAA;AAA5B,MAA4C,qBAC/CC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,kBAAF;AAAsBC,MAAAA;AAAtB,QAAuCF,MAAM,CAAEG,aAAF,CAAnD;AACA,UAAM;AACLC,MAAAA,oBADK;AAELC,MAAAA;AAFK,QAGFL,MAAM,CAAEM,kBAAF,CAHV;AAIA,UAAMC,YAAY,GAAGH,oBAAoB,CAAEd,QAAF,CAAzC;AAEA,WAAO;AACNO,MAAAA,SAAS,EAAEK,YAAY,CAAEX,IAAF,CADjB;AAENO,MAAAA,aAAa,EAAEG,kBAAkB,CAAEV,IAAF,CAF3B;AAGNQ,MAAAA,WAAW,EAAE,CAAC,CAAEM,qCAAqC,CACpDd,IADoD,EAEpDgB,YAFoD,CAArC,CAGdC;AANI,KAAP;AAQA,GAjBgD,EAkBjD,CAAEjB,IAAF,EAAQD,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AN2B;AAC9BxB,IAAAA,QAD8B;AAE9BD,IAAAA,UAF8B;AAG9BI,IAAAA,aAH8B;AAI9BiB,IAAAA,IAJ8B;AAK9BE,IAAAA;AAL8B,GAM3B;AACH,QAAMG,eAAe,GAAG,qCAA0B1B,UAA1B,CAAxB;AACA,QAAM;AAAE2B,IAAAA;AAAF,MAAyB,uBAAaV,kBAAb,CAA/B;AACA,QAAMV,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,4BAAC,+CAAD;AACC,IAAA,IAAI,EAAGc,IADR;AAEC,IAAA,KAAK,EAAGE,KAFT;AAGC,IAAA,UAAU,EAAGG,eAHd;AAIC,IAAA,QAAQ,EAAKE,SAAF,IAAiB;AAC3B,UAAKA,SAAS,CAAC5B,UAAf,EAA4B;AAC3BI,QAAAA,aAAa,CAAE,EACd,GAAGwB,SAAS,CAAC5B,UADC;AAEd6B,UAAAA,KAAK,EAAE,EACN,GAAGD,SAAS,CAAC5B,UAAV,CAAqB6B,KADlB;AAENC,YAAAA,QAAQ,EACP9B,UAAU,CAAC6B,KAAX,CAAiBC,QAAjB,IACAF,SAAS,CAAC5B,UAAV,CAAqB6B,KAArB,CAA2BC;AAJtB,WAFO;AAQdC,UAAAA,SAAS,EAAE/B,UAAU,CAAC+B;AARR,SAAF,CAAb;AAUA;;AACD,UAAKH,SAAS,CAACI,WAAf,EAA6B;AAC5BL,QAAAA,kBAAkB,CACjB1B,QADiB,EAEjB,iDACC2B,SAAS,CAACI,WADX,CAFiB,EAKjB,KALiB,CAAlB;AAOA;AACD;AA1BF,IADD,CADD;AAgCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useState } from '@wordpress/element';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalBlockVariationPicker,\n\t__experimentalGetMatchingVariation as getMatchingVariation,\n} from '@wordpress/block-editor';\nimport { Button, Placeholder } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useScopedBlockVariations } from '../utils';\n\nexport default function QueryPlaceholder( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\n\tconst { blockType, allVariations, hasPatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tallVariations: getBlockVariations( name ),\n\t\t\t\thasPatterns: !! __experimentalGetPatternsByBlockTypes(\n\t\t\t\t\tname,\n\t\t\t\t\trootClientId\n\t\t\t\t).length,\n\t\t\t};\n\t\t},\n\t\t[ name, clientId ]\n\t);\n\n\tconst matchingVariation = getMatchingVariation( attributes, allVariations );\n\tconst icon =\n\t\tmatchingVariation?.icon?.src ||\n\t\tmatchingVariation?.icon ||\n\t\tblockType?.icon?.src;\n\tconst label = matchingVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryVariationPicker\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nfunction QueryVariationPicker( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\ticon,\n\tlabel,\n} ) {\n\tconst scopeVariations = useScopedBlockVariations( attributes );\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tvariations={ scopeVariations }\n\t\t\t\tonSelect={ ( variation ) => {\n\t\t\t\t\tif ( variation.attributes ) {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t...variation.attributes,\n\t\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\t\t...variation.attributes.query,\n\t\t\t\t\t\t\t\tpostType:\n\t\t\t\t\t\t\t\t\tattributes.query.postType ||\n\t\t\t\t\t\t\t\t\tvariation.attributes.query.postType,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tnamespace: attributes.namespace,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tif ( variation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tvariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -9,7 +9,9 @@ exports.mapToIHasNameAndId = void 0;
9
9
  exports.useAllowedControls = useAllowedControls;
10
10
  exports.useBlockNameForPatterns = useBlockNameForPatterns;
11
11
  exports.useIsPostTypeHierarchical = useIsPostTypeHierarchical;
12
- exports.useTaxonomies = exports.usePostTypes = void 0;
12
+ exports.usePostTypes = void 0;
13
+ exports.useScopedBlockVariations = useScopedBlockVariations;
14
+ exports.useTaxonomies = void 0;
13
15
 
14
16
  var _lodash = require("lodash");
15
17
 
@@ -94,6 +96,8 @@ const {
94
96
  },
95
97
  editorStyle: "wp-block-query-editor"
96
98
  };
99
+ /** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
100
+
97
101
  /**
98
102
  * @typedef IHasNameAndId
99
103
  * @property {string|number} id The entity's id.
@@ -365,4 +369,72 @@ function useBlockNameForPatterns(clientId, attributes) {
365
369
  }, [clientId, activeVariationName]);
366
370
  return activeVariationPatterns !== null && activeVariationPatterns !== void 0 && activeVariationPatterns.length ? blockName : queryLoopName;
367
371
  }
372
+ /**
373
+ * Helper hook that determines if there is an active variation of the block
374
+ * and if there are available specific scoped `block` variations connected with
375
+ * this variation.
376
+ *
377
+ * If there are, these variations are going to be the only ones suggested
378
+ * to the user in setup flow when clicking to `start blank`, without including
379
+ * the default ones for Query Loop.
380
+ *
381
+ * If there are no such scoped `block` variations, the default ones for Query
382
+ * Loop are going to be suggested.
383
+ *
384
+ * The way we determine such variations is with the convention that they have the `namespace`
385
+ * attribute defined as an array. This array should contain the names(`name` property) of any
386
+ * variations they want to be connected to.
387
+ * For example, if we have a `Query Loop` scoped `inserter` variation with the name `products`,
388
+ * we can connect a scoped `block` variation by setting its `namespace` attribute to `['products']`.
389
+ * If the user selects this variation, the `namespace` attribute will be overridden by the
390
+ * main `inserter` variation.
391
+ *
392
+ * @param {Object} attributes The block's attributes.
393
+ * @return {WPBlockVariation[]} The block variations to be suggested in setup flow, when clicking to `start blank`.
394
+ */
395
+
396
+
397
+ function useScopedBlockVariations(attributes) {
398
+ const {
399
+ activeVariationName,
400
+ blockVariations
401
+ } = (0, _data.useSelect)(select => {
402
+ var _getActiveBlockVariat;
403
+
404
+ const {
405
+ getActiveBlockVariation,
406
+ getBlockVariations
407
+ } = select(_blocks.store);
408
+ return {
409
+ activeVariationName: (_getActiveBlockVariat = getActiveBlockVariation(queryLoopName, attributes)) === null || _getActiveBlockVariat === void 0 ? void 0 : _getActiveBlockVariat.name,
410
+ blockVariations: getBlockVariations(queryLoopName, 'block')
411
+ };
412
+ }, [attributes]);
413
+ const variations = (0, _element.useMemo)(() => {
414
+ // Filter out the variations that have defined a `namespace` attribute,
415
+ // which means they are 'connected' to specific variations of the block.
416
+ const isNotConnected = variation => {
417
+ var _variation$attributes;
418
+
419
+ return !((_variation$attributes = variation.attributes) !== null && _variation$attributes !== void 0 && _variation$attributes.namespace);
420
+ };
421
+
422
+ if (!activeVariationName) {
423
+ return blockVariations.filter(isNotConnected);
424
+ }
425
+
426
+ const connectedVariations = blockVariations.filter(variation => {
427
+ var _variation$attributes2, _variation$attributes3;
428
+
429
+ return (_variation$attributes2 = variation.attributes) === null || _variation$attributes2 === void 0 ? void 0 : (_variation$attributes3 = _variation$attributes2.namespace) === null || _variation$attributes3 === void 0 ? void 0 : _variation$attributes3.includes(activeVariationName);
430
+ });
431
+
432
+ if (!!connectedVariations.length) {
433
+ return connectedVariations;
434
+ }
435
+
436
+ return blockVariations.filter(isNotConnected);
437
+ }, [activeVariationName, blockVariations]);
438
+ return variations;
439
+ }
368
440
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","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","blocksStore","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","blockEditorStore","rootClientId"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;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;;AACO,MAAMA,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,G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BAAuB,SAAvB,IAAAA,uBAAuB,WAAvB,IAAAA,uBAAuB,CAAE1C,MAAzB,GAAkCyC,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":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","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","blocksStore","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","blockEditorStore","rootClientId","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;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;;AACO,MAAMA,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,QA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rD,MAAhB,CAA0ByD,SAAF;AAAA;;AAAA,uCACnDA,SAAS,CAACnC,UADyC,qFACnD,uBAAsBoC,SAD6B,2DACnD,uBAAiCvD,QAAjC,CAA2C0C,mBAA3C,CADmD;AAAA,KAAxB,CAA5B;;AAGA,QAAK,CAAC,CAAEc,mBAAmB,CAACtD,MAA5B,EAAqC;AACpC,aAAOsD,mBAAP;AACA;;AACD,WAAON,eAAe,CAACrD,MAAhB,CAAwBwD,cAAxB,CAAP;AACA,GAfkB,EAehB,CAAEX,mBAAF,EAAuBQ,eAAvB,CAfgB,CAAnB;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"]}
@@ -100,8 +100,8 @@ function SearchEdit(_ref) {
100
100
  }
101
101
 
102
102
  const colorProps = (0, _blockEditor.__experimentalUseColorProps)(attributes);
103
- const fluidTypographyEnabled = (0, _blockEditor.useSetting)('typography.fluid');
104
- const typographyProps = (0, _blockEditor.getTypographyClassesAndStyles)(attributes, fluidTypographyEnabled);
103
+ const fluidTypographySettings = (0, _blockEditor.useSetting)('typography.fluid');
104
+ const typographyProps = (0, _blockEditor.getTypographyClassesAndStyles)(attributes, fluidTypographySettings);
105
105
  const unitControlInstanceId = (0, _compose.useInstanceId)(_components.__experimentalUnitControl);
106
106
  const unitControlInputId = `wp-block-search__width-${unitControlInstanceId}`;
107
107
  const isButtonPositionInside = 'button-inside' === buttonPosition;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/search/edit.js"],"names":["DEFAULT_INNER_PADDING","SearchEdit","className","attributes","setAttributes","toggleSelection","isSelected","clientId","label","showLabel","placeholder","width","widthUnit","align","buttonText","buttonPosition","buttonUseIcon","style","insertedInNavigationBlock","select","getBlockParentsByBlockName","wasBlockJustInserted","blockEditorStore","length","__unstableMarkNextChangeAsNotPersistent","borderRadius","border","radius","borderProps","colorProps","fluidTypographyEnabled","typographyProps","unitControlInstanceId","UnitControl","unitControlInputId","isButtonPositionInside","isButtonPositionOutside","hasNoButton","hasOnlyButton","units","availableUnits","defaultValues","PC_WIDTH_DEFAULT","px","PX_WIDTH_DEFAULT","getBlockClassNames","undefined","buttonPositionControls","role","title","isActive","icon","buttonOutside","onClick","buttonInside","noButton","getButtonPositionIcon","buttonOnly","getResizableSides","right","left","renderTextField","textFieldClasses","textFieldStyles","textDecoration","event","target","value","renderButton","buttonClasses","buttonStyles","search","html","controls","toggleLabel","buttonWithIcon","MIN_WIDTH","MIN_WIDTH_UNIT","newWidth","filteredWidth","parseInt","newUnit","map","widthValue","padBorderRadius","getWrapperStyles","styles","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","isNonZeroBorderRadius","topLeft","topRight","bottomLeft","bottomRight","Number","isInteger","blockProps","labelClassnames","direction","elt","offsetWidth","delta"],"mappings":";;;;;;;;;AAqBA;;AAlBA;;AAKA;;AAYA;;AAEA;;AAYA;;AACA;;AACA;;AACA;;AAKA;;AAQA;;AAlDA;AACA;AACA;;AAGA;AACA;AACA;;AAgCA;AACA;AACA;AAgBA;AACA;AACA,MAAMA,qBAAqB,GAAG,KAA9B;;AAEe,SAASC,UAAT,OAOX;AAAA;;AAAA,MAPgC;AACnCC,IAAAA,SADmC;AAEnCC,IAAAA,UAFmC;AAGnCC,IAAAA,aAHmC;AAInCC,IAAAA,eAJmC;AAKnCC,IAAAA,UALmC;AAMnCC,IAAAA;AANmC,GAOhC;AACH,QAAM;AACLC,IAAAA,KADK;AAELC,IAAAA,SAFK;AAGLC,IAAAA,WAHK;AAILC,IAAAA,KAJK;AAKLC,IAAAA,SALK;AAMLC,IAAAA,KANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,cARK;AASLC,IAAAA,aATK;AAULC,IAAAA;AAVK,MAWFd,UAXJ;AAaA,QAAMe,yBAAyB,GAAG,qBAC/BC,MAAF,IAAc;AAAA;;AACb,UAAM;AAAEC,MAAAA,0BAAF;AAA8BC,MAAAA;AAA9B,QACLF,MAAM,CAAEG,kBAAF,CADP;AAEA,WACC,CAAC,2BAAEF,0BAA0B,CAAEb,QA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Ed1F,QAAAA,SAAS,EAAE;AAFG,OAAF,CAAb;AAIAP,MAAAA,eAAe,CAAE,KAAF,CAAf;AACA,KAjBF;AAkBC,IAAA,YAAY,EAAG,CAAE4D,KAAF,EAASmC,SAAT,EAAoBC,GAApB,EAAyBE,KAAzB,KAAoC;AAClDnG,MAAAA,aAAa,CAAE;AACdO,QAAAA,KAAK,EAAEqE,QAAQ,CAAErE,KAAK,GAAG4F,KAAK,CAAC5F,KAAhB,EAAuB,EAAvB;AADD,OAAF,CAAb;AAGAN,MAAAA,eAAe,CAAE,IAAF,CAAf;AACA,KAvBF;AAwBC,IAAA,UAAU,EAAGC;AAxBd,KA0BG,CAAE6B,sBAAsB,IAAIC,uBAA5B,KACD,qDACGyB,eAAe,EADlB,EAEGO,YAAY,EAFf,CA3BF,EAiCG9B,aAAa,IAAI8B,YAAY,EAjChC,EAkCG/B,WAAW,IAAIwB,eAAe,EAlCjC,CAfD,CADD;AAsDA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\tgetTypographyClassesAndStyles as useTypographyProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n\tuseSetting,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tToolbarDropdownMenu,\n\tToolbarGroup,\n\tButton,\n\tButtonGroup,\n\tToolbarButton,\n\tResizableBox,\n\tPanelBody,\n\tBaseControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { Icon, search } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport {\n\tbuttonOnly,\n\tbuttonOutside,\n\tbuttonInside,\n\tnoButton,\n\tbuttonWithIcon,\n\ttoggleLabel,\n} from './icons';\nimport {\n\tPC_WIDTH_DEFAULT,\n\tPX_WIDTH_DEFAULT,\n\tMIN_WIDTH,\n\tMIN_WIDTH_UNIT,\n} from './utils.js';\n\n// Used to calculate border radius adjustment to avoid \"fat\" corners when\n// button is placed inside wrapper.\nconst DEFAULT_INNER_PADDING = '4px';\n\nexport default function SearchEdit( {\n\tclassName,\n\tattributes,\n\tsetAttributes,\n\ttoggleSelection,\n\tisSelected,\n\tclientId,\n} ) {\n\tconst {\n\t\tlabel,\n\t\tshowLabel,\n\t\tplaceholder,\n\t\twidth,\n\t\twidthUnit,\n\t\talign,\n\t\tbuttonText,\n\t\tbuttonPosition,\n\t\tbuttonUseIcon,\n\t\tstyle,\n\t} = attributes;\n\n\tconst insertedInNavigationBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParentsByBlockName, wasBlockJustInserted } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\t!! getBlockParentsByBlockName( clientId, 'core/navigation' )\n\t\t\t\t\t?.length && wasBlockJustInserted( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tuseEffect( () => {\n\t\tif ( ! insertedInNavigationBlock ) return;\n\t\t// This side-effect should not create an undo level.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( {\n\t\t\tshowLabel: false,\n\t\t\tbuttonUseIcon: true,\n\t\t\tbuttonPosition: 'button-inside',\n\t\t} );\n\t}, [ insertedInNavigationBlock ] );\n\tconst borderRadius = style?.border?.radius;\n\tconst borderProps = useBorderProps( attributes );\n\n\t// Check for old deprecated numerical border radius. Done as a separate\n\t// check so that a borderRadius style won't overwrite the longhand\n\t// per-corner styles.\n\tif ( typeof borderRadius === 'number' ) {\n\t\tborderProps.style.borderRadius = `${ borderRadius }px`;\n\t}\n\n\tconst colorProps = useColorProps( attributes );\n\tconst fluidTypographyEnabled = useSetting( 'typography.fluid' );\n\tconst typographyProps = useTypographyProps(\n\t\tattributes,\n\t\tfluidTypographyEnabled\n\t);\n\tconst unitControlInstanceId = useInstanceId( UnitControl );\n\tconst unitControlInputId = `wp-block-search__width-${ unitControlInstanceId }`;\n\tconst isButtonPositionInside = 'button-inside' === buttonPosition;\n\tconst isButtonPositionOutside = 'button-outside' === buttonPosition;\n\tconst hasNoButton = 'no-button' === buttonPosition;\n\tconst hasOnlyButton = 'button-only' === buttonPosition;\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: [ '%', 'px' ],\n\t\tdefaultValues: { '%': PC_WIDTH_DEFAULT, px: PX_WIDTH_DEFAULT },\n\t} );\n\n\tconst getBlockClassNames = () => {\n\t\treturn classnames(\n\t\t\tclassName,\n\t\t\tisButtonPositionInside\n\t\t\t\t? 'wp-block-search__button-inside'\n\t\t\t\t: undefined,\n\t\t\tisButtonPositionOutside\n\t\t\t\t? 'wp-block-search__button-outside'\n\t\t\t\t: undefined,\n\t\t\thasNoButton ? 'wp-block-search__no-button' : undefined,\n\t\t\thasOnlyButton ? 'wp-block-search__button-only' : undefined,\n\t\t\t! buttonUseIcon && ! hasNoButton\n\t\t\t\t? 'wp-block-search__text-button'\n\t\t\t\t: undefined,\n\t\t\tbuttonUseIcon && ! hasNoButton\n\t\t\t\t? 'wp-block-search__icon-button'\n\t\t\t\t: undefined\n\t\t);\n\t};\n\n\tconst buttonPositionControls = [\n\t\t{\n\t\t\trole: 'menuitemradio',\n\t\t\ttitle: __( 'Button outside' ),\n\t\t\tisActive: buttonPosition === 'button-outside',\n\t\t\ticon: buttonOutside,\n\t\t\tonClick: () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tbuttonPosition: 'button-outside',\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\trole: 'menuitemradio',\n\t\t\ttitle: __( 'Button inside' ),\n\t\t\tisActive: buttonPosition === 'button-inside',\n\t\t\ticon: buttonInside,\n\t\t\tonClick: () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tbuttonPosition: 'button-inside',\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\trole: 'menuitemradio',\n\t\t\ttitle: __( 'No button' ),\n\t\t\tisActive: buttonPosition === 'no-button',\n\t\t\ticon: noButton,\n\t\t\tonClick: () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tbuttonPosition: 'no-button',\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t];\n\n\tconst getButtonPositionIcon = () => {\n\t\tswitch ( buttonPosition ) {\n\t\t\tcase 'button-inside':\n\t\t\t\treturn buttonInside;\n\t\t\tcase 'button-outside':\n\t\t\t\treturn buttonOutside;\n\t\t\tcase 'no-button':\n\t\t\t\treturn noButton;\n\t\t\tcase 'button-only':\n\t\t\t\treturn buttonOnly;\n\t\t}\n\t};\n\n\tconst getResizableSides = () => {\n\t\tif ( hasOnlyButton ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tright: align !== 'right',\n\t\t\tleft: align === 'right',\n\t\t};\n\t};\n\n\tconst renderTextField = () => {\n\t\t// If the input is inside the wrapper, the wrapper gets the border color styles/classes, not the input control.\n\t\tconst textFieldClasses = classnames(\n\t\t\t'wp-block-search__input',\n\t\t\tisButtonPositionInside ? undefined : borderProps.className,\n\t\t\ttypographyProps.className\n\t\t);\n\t\tconst textFieldStyles = {\n\t\t\t...( isButtonPositionInside\n\t\t\t\t? { borderRadius }\n\t\t\t\t: borderProps.style ),\n\t\t\t...typographyProps.style,\n\t\t\ttextDecoration: undefined,\n\t\t};\n\n\t\treturn (\n\t\t\t<input\n\t\t\t\ttype=\"search\"\n\t\t\t\tclassName={ textFieldClasses }\n\t\t\t\tstyle={ textFieldStyles }\n\t\t\t\taria-label={ __( 'Optional placeholder text' ) }\n\t\t\t\t// We hide the placeholder field's placeholder when there is a value. This\n\t\t\t\t// stops screen readers from reading the placeholder field's placeholder\n\t\t\t\t// which is confusing.\n\t\t\t\tplaceholder={\n\t\t\t\t\tplaceholder ? undefined : __( 'Optional placeholder…' )\n\t\t\t\t}\n\t\t\t\tvalue={ placeholder }\n\t\t\t\tonChange={ ( event ) =>\n\t\t\t\t\tsetAttributes( { placeholder: event.target.value } )\n\t\t\t\t}\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst renderButton = () => {\n\t\t// If the button is inside the wrapper, the wrapper gets the border color styles/classes, not the button.\n\t\tconst buttonClasses = classnames(\n\t\t\t'wp-block-search__button',\n\t\t\tcolorProps.className,\n\t\t\ttypographyProps.className,\n\t\t\tisButtonPositionInside ? undefined : borderProps.className,\n\t\t\tbuttonUseIcon ? 'has-icon' : undefined,\n\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t);\n\t\tconst buttonStyles = {\n\t\t\t...colorProps.style,\n\t\t\t...typographyProps.style,\n\t\t\t...( isButtonPositionInside\n\t\t\t\t? { borderRadius }\n\t\t\t\t: borderProps.style ),\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ buttonUseIcon && (\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclassName={ buttonClasses }\n\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\tbuttonText\n\t\t\t\t\t\t\t\t? stripHTML( buttonText )\n\t\t\t\t\t\t\t\t: __( 'Search' )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ search } />\n\t\t\t\t\t</button>\n\t\t\t\t) }\n\n\t\t\t\t{ ! buttonUseIcon && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tclassName={ buttonClasses }\n\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add button text…' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tvalue={ buttonText }\n\t\t\t\t\t\tonChange={ ( html ) =>\n\t\t\t\t\t\t\tsetAttributes( { buttonText: html } )\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);\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Toggle search label' ) }\n\t\t\t\t\t\ticon={ toggleLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowLabel: ! showLabel,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tclassName={ showLabel ? 'is-pressed' : undefined }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\t\ticon={ getButtonPositionIcon() }\n\t\t\t\t\t\tlabel={ __( 'Change button position' ) }\n\t\t\t\t\t\tcontrols={ buttonPositionControls }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! hasNoButton && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\ttitle={ __( 'Use button with icon' ) }\n\t\t\t\t\t\t\ticon={ buttonWithIcon }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tbuttonUseIcon: ! buttonUseIcon,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\tbuttonUseIcon ? 'is-pressed' : undefined\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</ToolbarGroup>\n\t\t\t</BlockControls>\n\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Display Settings' ) }>\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tid={ unitControlInputId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tid={ unitControlInputId }\n\t\t\t\t\t\t\tmin={ `${ MIN_WIDTH }${ MIN_WIDTH_UNIT }` }\n\t\t\t\t\t\t\tonChange={ ( newWidth ) => {\n\t\t\t\t\t\t\t\tconst filteredWidth =\n\t\t\t\t\t\t\t\t\twidthUnit === '%' &&\n\t\t\t\t\t\t\t\t\tparseInt( newWidth, 10 ) > 100\n\t\t\t\t\t\t\t\t\t\t? 100\n\t\t\t\t\t\t\t\t\t\t: newWidth;\n\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\twidth: parseInt( filteredWidth, 10 ),\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonUnitChange={ ( newUnit ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t'%' === newUnit\n\t\t\t\t\t\t\t\t\t\t\t? PC_WIDTH_DEFAULT\n\t\t\t\t\t\t\t\t\t\t\t: PX_WIDTH_DEFAULT,\n\t\t\t\t\t\t\t\t\twidthUnit: newUnit,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t__unstableInputWidth={ '80px' }\n\t\t\t\t\t\t\tvalue={ `${ width }${ widthUnit }` }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<ButtonGroup\n\t\t\t\t\t\t\tclassName=\"wp-block-search__components-button-group\"\n\t\t\t\t\t\t\taria-label={ __( 'Percentage Width' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ [ 25, 50, 75, 100 ].map( ( widthValue ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t`${ widthValue }%` ===\n\t\t\t\t\t\t\t\t\t\t\t`${ width }${ widthUnit }`\n\t\t\t\t\t\t\t\t\t\t\t\t? 'primary'\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\twidth: widthValue,\n\t\t\t\t\t\t\t\t\t\t\t\twidthUnit: '%',\n\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ widthValue }%\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</ButtonGroup>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst padBorderRadius = ( radius ) =>\n\t\tradius ? `calc(${ radius } + ${ DEFAULT_INNER_PADDING })` : undefined;\n\n\tconst getWrapperStyles = () => {\n\t\tconst styles = isButtonPositionInside\n\t\t\t? borderProps.style\n\t\t\t: {\n\t\t\t\t\tborderRadius: borderProps.style?.borderRadius,\n\t\t\t\t\tborderTopLeftRadius: borderProps.style?.borderTopLeftRadius,\n\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\tborderProps.style?.borderTopRightRadius,\n\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\tborderProps.style?.borderBottomLeftRadius,\n\t\t\t\t\tborderBottomRightRadius:\n\t\t\t\t\t\tborderProps.style?.borderBottomRightRadius,\n\t\t\t };\n\n\t\tconst isNonZeroBorderRadius =\n\t\t\tborderRadius !== undefined && parseInt( borderRadius, 10 ) !== 0;\n\n\t\tif ( isButtonPositionInside && isNonZeroBorderRadius ) {\n\t\t\t// We have button inside wrapper and a border radius value to apply.\n\t\t\t// Add default padding so we don't get \"fat\" corners.\n\t\t\t//\n\t\t\t// CSS calc() is used here to support non-pixel units. The inline\n\t\t\t// style using calc() will only apply if both values have units.\n\n\t\t\tif ( typeof borderRadius === 'object' ) {\n\t\t\t\t// Individual corner border radii present.\n\t\t\t\tconst { topLeft, topRight, bottomLeft, bottomRight } =\n\t\t\t\t\tborderRadius;\n\n\t\t\t\treturn {\n\t\t\t\t\t...styles,\n\t\t\t\t\tborderTopLeftRadius: padBorderRadius( topLeft ),\n\t\t\t\t\tborderTopRightRadius: padBorderRadius( topRight ),\n\t\t\t\t\tborderBottomLeftRadius: padBorderRadius( bottomLeft ),\n\t\t\t\t\tborderBottomRightRadius: padBorderRadius( bottomRight ),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// The inline style using calc() will only apply if both values\n\t\t\t// supplied to calc() have units. Deprecated block's may have\n\t\t\t// unitless integer.\n\t\t\tconst radius = Number.isInteger( borderRadius )\n\t\t\t\t? `${ borderRadius }px`\n\t\t\t\t: borderRadius;\n\n\t\t\tstyles.borderRadius = `calc(${ radius } + ${ DEFAULT_INNER_PADDING })`;\n\t\t}\n\n\t\treturn styles;\n\t};\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: getBlockClassNames(),\n\t\tstyle: {\n\t\t\t...typographyProps.style,\n\t\t\t// Input opts out of text decoration.\n\t\t\ttextDecoration: undefined,\n\t\t},\n\t} );\n\n\tconst labelClassnames = classnames(\n\t\t'wp-block-search__label',\n\t\ttypographyProps.className\n\t);\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ controls }\n\n\t\t\t{ showLabel && (\n\t\t\t\t<RichText\n\t\t\t\t\tclassName={ labelClassnames }\n\t\t\t\t\taria-label={ __( 'Label text' ) }\n\t\t\t\t\tplaceholder={ __( 'Add label…' ) }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tvalue={ label }\n\t\t\t\t\tonChange={ ( html ) => setAttributes( { label: html } ) }\n\t\t\t\t\tstyle={ typographyProps.style }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<ResizableBox\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: `${ width }${ widthUnit }`,\n\t\t\t\t} }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'wp-block-search__inside-wrapper',\n\t\t\t\t\tisButtonPositionInside ? borderProps.className : undefined\n\t\t\t\t) }\n\t\t\t\tstyle={ getWrapperStyles() }\n\t\t\t\tminWidth={ MIN_WIDTH }\n\t\t\t\tenable={ getResizableSides() }\n\t\t\t\tonResizeStart={ ( event, direction, elt ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( elt.offsetWidth, 10 ),\n\t\t\t\t\t\twidthUnit: 'px',\n\t\t\t\t\t} );\n\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t} }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( width + delta.width, 10 ),\n\t\t\t\t\t} );\n\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t>\n\t\t\t\t{ ( isButtonPositionInside || isButtonPositionOutside ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ renderTextField() }\n\t\t\t\t\t\t{ renderButton() }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t{ hasOnlyButton && renderButton() }\n\t\t\t\t{ hasNoButton && renderTextField() }\n\t\t\t</ResizableBox>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/search/edit.js"],"names":["DEFAULT_INNER_PADDING","SearchEdit","className","attributes","setAttributes","toggleSelection","isSelected","clientId","label","showLabel","placeholder","width","widthUnit","align","buttonText","buttonPosition","buttonUseIcon","style","insertedInNavigationBlock","select","getBlockParentsByBlockName","wasBlockJustInserted","blockEditorStore","length","__unstableMarkNextChangeAsNotPersistent","borderRadius","border","radius","borderProps","colorProps","fluidTypographySettings","typographyProps","unitControlInstanceId","UnitControl","unitControlInputId","isButtonPositionInside","isButtonPositionOutside","hasNoButton","hasOnlyButton","units","availableUnits","defaultValues","PC_WIDTH_DEFAULT","px","PX_WIDTH_DEFAULT","getBlockClassNames","undefined","buttonPositionControls","role","title","isActive","icon","buttonOutside","onClick","buttonInside","noButton","getButtonPositionIcon","buttonOnly","getResizableSides","right","left","renderTextField","textFieldClasses","textFieldStyles","textDecoration","event","target","value","renderButton","buttonClasses","buttonStyles","search","html","controls","toggleLabel","buttonWithIcon","MIN_WIDTH","MIN_WIDTH_UNIT","newWidth","filteredWidth","parseInt","newUnit","map","widthValue","padBorderRadius","getWrapperStyles","styles","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","isNonZeroBorderRadius","topLeft","topRight","bottomLeft","bottomRight","Number","isInteger","blockProps","labelClassnames","direction","elt","offsetWidth","delta"],"mappings":";;;;;;;;;AAqBA;;AAlBA;;AAKA;;AAYA;;AAEA;;AAYA;;AACA;;AACA;;AACA;;AAKA;;AAQA;;AAlDA;AACA;AACA;;AAGA;AACA;AACA;;AAgCA;AACA;AACA;AAgBA;AACA;AACA,MAAMA,qBAAqB,GAAG,KAA9B;;AAEe,SAASC,UAAT,OAOX;AAAA;;AAAA,MAPgC;AACnCC,IAAAA,SADmC;AAEnCC,IAAAA,UAFmC;AAGnCC,IAAAA,aAHmC;AAInCC,IAAAA,eAJmC;AAKnCC,IAAAA,UALmC;AAMnCC,IAAAA;AANmC,GAOhC;AACH,QAAM;AACLC,IAAAA,KADK;AAELC,IAAAA,SAFK;AAGLC,I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AGP,WAAW,CAAC1B,SAAf,GAA2B4C,SAFtC,CAJb;AAQC,IAAA,KAAK,EAAGuC,gBAAgB,EARzB;AASC,IAAA,QAAQ,EAAGT,gBATZ;AAUC,IAAA,MAAM,EAAGlB,iBAAiB,EAV3B;AAWC,IAAA,aAAa,EAAG,CAAEO,KAAF,EAASmC,SAAT,EAAoBC,GAApB,KAA6B;AAC5CjG,MAAAA,aAAa,CAAE;AACdO,QAAAA,KAAK,EAAEqE,QAAQ,CAAEqB,GAAG,CAACC,WAAN,EAAmB,EAAnB,CADD;AAEd1F,QAAAA,SAAS,EAAE;AAFG,OAAF,CAAb;AAIAP,MAAAA,eAAe,CAAE,KAAF,CAAf;AACA,KAjBF;AAkBC,IAAA,YAAY,EAAG,CAAE4D,KAAF,EAASmC,SAAT,EAAoBC,GAApB,EAAyBE,KAAzB,KAAoC;AAClDnG,MAAAA,aAAa,CAAE;AACdO,QAAAA,KAAK,EAAEqE,QAAQ,CAAErE,KAAK,GAAG4F,KAAK,CAAC5F,KAAhB,EAAuB,EAAvB;AADD,OAAF,CAAb;AAGAN,MAAAA,eAAe,CAAE,IAAF,CAAf;AACA,KAvBF;AAwBC,IAAA,UAAU,EAAGC;AAxBd,KA0BG,CAAE6B,sBAAsB,IAAIC,uBAA5B,KACD,qDACGyB,eAAe,EADlB,EAEGO,YAAY,EAFf,CA3BF,EAiCG9B,aAAa,IAAI8B,YAAY,EAjChC,EAkCG/B,WAAW,IAAIwB,eAAe,EAlCjC,CAfD,CADD;AAsDA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalUseColorProps as useColorProps,\n\tgetTypographyClassesAndStyles as useTypographyProps,\n\tstore as blockEditorStore,\n\t__experimentalGetElementClassName,\n\tuseSetting,\n} from '@wordpress/block-editor';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport {\n\tToolbarDropdownMenu,\n\tToolbarGroup,\n\tButton,\n\tButtonGroup,\n\tToolbarButton,\n\tResizableBox,\n\tPanelBody,\n\tBaseControl,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { Icon, search } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport {\n\tbuttonOnly,\n\tbuttonOutside,\n\tbuttonInside,\n\tnoButton,\n\tbuttonWithIcon,\n\ttoggleLabel,\n} from './icons';\nimport {\n\tPC_WIDTH_DEFAULT,\n\tPX_WIDTH_DEFAULT,\n\tMIN_WIDTH,\n\tMIN_WIDTH_UNIT,\n} from './utils.js';\n\n// Used to calculate border radius adjustment to avoid \"fat\" corners when\n// button is placed inside wrapper.\nconst DEFAULT_INNER_PADDING = '4px';\n\nexport default function SearchEdit( {\n\tclassName,\n\tattributes,\n\tsetAttributes,\n\ttoggleSelection,\n\tisSelected,\n\tclientId,\n} ) {\n\tconst {\n\t\tlabel,\n\t\tshowLabel,\n\t\tplaceholder,\n\t\twidth,\n\t\twidthUnit,\n\t\talign,\n\t\tbuttonText,\n\t\tbuttonPosition,\n\t\tbuttonUseIcon,\n\t\tstyle,\n\t} = attributes;\n\n\tconst insertedInNavigationBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParentsByBlockName, wasBlockJustInserted } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\t!! getBlockParentsByBlockName( clientId, 'core/navigation' )\n\t\t\t\t\t?.length && wasBlockJustInserted( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tuseEffect( () => {\n\t\tif ( ! insertedInNavigationBlock ) return;\n\t\t// This side-effect should not create an undo level.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( {\n\t\t\tshowLabel: false,\n\t\t\tbuttonUseIcon: true,\n\t\t\tbuttonPosition: 'button-inside',\n\t\t} );\n\t}, [ insertedInNavigationBlock ] );\n\tconst borderRadius = style?.border?.radius;\n\tconst borderProps = useBorderProps( attributes );\n\n\t// Check for old deprecated numerical border radius. Done as a separate\n\t// check so that a borderRadius style won't overwrite the longhand\n\t// per-corner styles.\n\tif ( typeof borderRadius === 'number' ) {\n\t\tborderProps.style.borderRadius = `${ borderRadius }px`;\n\t}\n\n\tconst colorProps = useColorProps( attributes );\n\tconst fluidTypographySettings = useSetting( 'typography.fluid' );\n\tconst typographyProps = useTypographyProps(\n\t\tattributes,\n\t\tfluidTypographySettings\n\t);\n\tconst unitControlInstanceId = useInstanceId( UnitControl );\n\tconst unitControlInputId = `wp-block-search__width-${ unitControlInstanceId }`;\n\tconst isButtonPositionInside = 'button-inside' === buttonPosition;\n\tconst isButtonPositionOutside = 'button-outside' === buttonPosition;\n\tconst hasNoButton = 'no-button' === buttonPosition;\n\tconst hasOnlyButton = 'button-only' === buttonPosition;\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: [ '%', 'px' ],\n\t\tdefaultValues: { '%': PC_WIDTH_DEFAULT, px: PX_WIDTH_DEFAULT },\n\t} );\n\n\tconst getBlockClassNames = () => {\n\t\treturn classnames(\n\t\t\tclassName,\n\t\t\tisButtonPositionInside\n\t\t\t\t? 'wp-block-search__button-inside'\n\t\t\t\t: undefined,\n\t\t\tisButtonPositionOutside\n\t\t\t\t? 'wp-block-search__button-outside'\n\t\t\t\t: undefined,\n\t\t\thasNoButton ? 'wp-block-search__no-button' : undefined,\n\t\t\thasOnlyButton ? 'wp-block-search__button-only' : undefined,\n\t\t\t! buttonUseIcon && ! hasNoButton\n\t\t\t\t? 'wp-block-search__text-button'\n\t\t\t\t: undefined,\n\t\t\tbuttonUseIcon && ! hasNoButton\n\t\t\t\t? 'wp-block-search__icon-button'\n\t\t\t\t: undefined\n\t\t);\n\t};\n\n\tconst buttonPositionControls = [\n\t\t{\n\t\t\trole: 'menuitemradio',\n\t\t\ttitle: __( 'Button outside' ),\n\t\t\tisActive: buttonPosition === 'button-outside',\n\t\t\ticon: buttonOutside,\n\t\t\tonClick: () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tbuttonPosition: 'button-outside',\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\trole: 'menuitemradio',\n\t\t\ttitle: __( 'Button inside' ),\n\t\t\tisActive: buttonPosition === 'button-inside',\n\t\t\ticon: buttonInside,\n\t\t\tonClick: () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tbuttonPosition: 'button-inside',\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\trole: 'menuitemradio',\n\t\t\ttitle: __( 'No button' ),\n\t\t\tisActive: buttonPosition === 'no-button',\n\t\t\ticon: noButton,\n\t\t\tonClick: () => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tbuttonPosition: 'no-button',\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t];\n\n\tconst getButtonPositionIcon = () => {\n\t\tswitch ( buttonPosition ) {\n\t\t\tcase 'button-inside':\n\t\t\t\treturn buttonInside;\n\t\t\tcase 'button-outside':\n\t\t\t\treturn buttonOutside;\n\t\t\tcase 'no-button':\n\t\t\t\treturn noButton;\n\t\t\tcase 'button-only':\n\t\t\t\treturn buttonOnly;\n\t\t}\n\t};\n\n\tconst getResizableSides = () => {\n\t\tif ( hasOnlyButton ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tright: align !== 'right',\n\t\t\tleft: align === 'right',\n\t\t};\n\t};\n\n\tconst renderTextField = () => {\n\t\t// If the input is inside the wrapper, the wrapper gets the border color styles/classes, not the input control.\n\t\tconst textFieldClasses = classnames(\n\t\t\t'wp-block-search__input',\n\t\t\tisButtonPositionInside ? undefined : borderProps.className,\n\t\t\ttypographyProps.className\n\t\t);\n\t\tconst textFieldStyles = {\n\t\t\t...( isButtonPositionInside\n\t\t\t\t? { borderRadius }\n\t\t\t\t: borderProps.style ),\n\t\t\t...typographyProps.style,\n\t\t\ttextDecoration: undefined,\n\t\t};\n\n\t\treturn (\n\t\t\t<input\n\t\t\t\ttype=\"search\"\n\t\t\t\tclassName={ textFieldClasses }\n\t\t\t\tstyle={ textFieldStyles }\n\t\t\t\taria-label={ __( 'Optional placeholder text' ) }\n\t\t\t\t// We hide the placeholder field's placeholder when there is a value. This\n\t\t\t\t// stops screen readers from reading the placeholder field's placeholder\n\t\t\t\t// which is confusing.\n\t\t\t\tplaceholder={\n\t\t\t\t\tplaceholder ? undefined : __( 'Optional placeholder…' )\n\t\t\t\t}\n\t\t\t\tvalue={ placeholder }\n\t\t\t\tonChange={ ( event ) =>\n\t\t\t\t\tsetAttributes( { placeholder: event.target.value } )\n\t\t\t\t}\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst renderButton = () => {\n\t\t// If the button is inside the wrapper, the wrapper gets the border color styles/classes, not the button.\n\t\tconst buttonClasses = classnames(\n\t\t\t'wp-block-search__button',\n\t\t\tcolorProps.className,\n\t\t\ttypographyProps.className,\n\t\t\tisButtonPositionInside ? undefined : borderProps.className,\n\t\t\tbuttonUseIcon ? 'has-icon' : undefined,\n\t\t\t__experimentalGetElementClassName( 'button' )\n\t\t);\n\t\tconst buttonStyles = {\n\t\t\t...colorProps.style,\n\t\t\t...typographyProps.style,\n\t\t\t...( isButtonPositionInside\n\t\t\t\t? { borderRadius }\n\t\t\t\t: borderProps.style ),\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ buttonUseIcon && (\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tclassName={ buttonClasses }\n\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\tbuttonText\n\t\t\t\t\t\t\t\t? stripHTML( buttonText )\n\t\t\t\t\t\t\t\t: __( 'Search' )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ search } />\n\t\t\t\t\t</button>\n\t\t\t\t) }\n\n\t\t\t\t{ ! buttonUseIcon && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\tclassName={ buttonClasses }\n\t\t\t\t\t\tstyle={ buttonStyles }\n\t\t\t\t\t\taria-label={ __( 'Button text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add button text…' ) }\n\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\tvalue={ buttonText }\n\t\t\t\t\t\tonChange={ ( html ) =>\n\t\t\t\t\t\t\tsetAttributes( { buttonText: html } )\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);\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\ttitle={ __( 'Toggle search label' ) }\n\t\t\t\t\t\ticon={ toggleLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tshowLabel: ! showLabel,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tclassName={ showLabel ? 'is-pressed' : undefined }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToolbarDropdownMenu\n\t\t\t\t\t\ticon={ getButtonPositionIcon() }\n\t\t\t\t\t\tlabel={ __( 'Change button position' ) }\n\t\t\t\t\t\tcontrols={ buttonPositionControls }\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! hasNoButton && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\ttitle={ __( 'Use button with icon' ) }\n\t\t\t\t\t\t\ticon={ buttonWithIcon }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tbuttonUseIcon: ! buttonUseIcon,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\tbuttonUseIcon ? 'is-pressed' : undefined\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</ToolbarGroup>\n\t\t\t</BlockControls>\n\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Display Settings' ) }>\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tid={ unitControlInputId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tid={ unitControlInputId }\n\t\t\t\t\t\t\tmin={ `${ MIN_WIDTH }${ MIN_WIDTH_UNIT }` }\n\t\t\t\t\t\t\tonChange={ ( newWidth ) => {\n\t\t\t\t\t\t\t\tconst filteredWidth =\n\t\t\t\t\t\t\t\t\twidthUnit === '%' &&\n\t\t\t\t\t\t\t\t\tparseInt( newWidth, 10 ) > 100\n\t\t\t\t\t\t\t\t\t\t? 100\n\t\t\t\t\t\t\t\t\t\t: newWidth;\n\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\twidth: parseInt( filteredWidth, 10 ),\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonUnitChange={ ( newUnit ) => {\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\twidth:\n\t\t\t\t\t\t\t\t\t\t'%' === newUnit\n\t\t\t\t\t\t\t\t\t\t\t? PC_WIDTH_DEFAULT\n\t\t\t\t\t\t\t\t\t\t\t: PX_WIDTH_DEFAULT,\n\t\t\t\t\t\t\t\t\twidthUnit: newUnit,\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t__unstableInputWidth={ '80px' }\n\t\t\t\t\t\t\tvalue={ `${ width }${ widthUnit }` }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<ButtonGroup\n\t\t\t\t\t\t\tclassName=\"wp-block-search__components-button-group\"\n\t\t\t\t\t\t\taria-label={ __( 'Percentage Width' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ [ 25, 50, 75, 100 ].map( ( widthValue ) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tkey={ widthValue }\n\t\t\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\t`${ widthValue }%` ===\n\t\t\t\t\t\t\t\t\t\t\t`${ width }${ widthUnit }`\n\t\t\t\t\t\t\t\t\t\t\t\t? 'primary'\n\t\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\twidth: widthValue,\n\t\t\t\t\t\t\t\t\t\t\t\twidthUnit: '%',\n\t\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ widthValue }%\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</ButtonGroup>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\n\tconst padBorderRadius = ( radius ) =>\n\t\tradius ? `calc(${ radius } + ${ DEFAULT_INNER_PADDING })` : undefined;\n\n\tconst getWrapperStyles = () => {\n\t\tconst styles = isButtonPositionInside\n\t\t\t? borderProps.style\n\t\t\t: {\n\t\t\t\t\tborderRadius: borderProps.style?.borderRadius,\n\t\t\t\t\tborderTopLeftRadius: borderProps.style?.borderTopLeftRadius,\n\t\t\t\t\tborderTopRightRadius:\n\t\t\t\t\t\tborderProps.style?.borderTopRightRadius,\n\t\t\t\t\tborderBottomLeftRadius:\n\t\t\t\t\t\tborderProps.style?.borderBottomLeftRadius,\n\t\t\t\t\tborderBottomRightRadius:\n\t\t\t\t\t\tborderProps.style?.borderBottomRightRadius,\n\t\t\t };\n\n\t\tconst isNonZeroBorderRadius =\n\t\t\tborderRadius !== undefined && parseInt( borderRadius, 10 ) !== 0;\n\n\t\tif ( isButtonPositionInside && isNonZeroBorderRadius ) {\n\t\t\t// We have button inside wrapper and a border radius value to apply.\n\t\t\t// Add default padding so we don't get \"fat\" corners.\n\t\t\t//\n\t\t\t// CSS calc() is used here to support non-pixel units. The inline\n\t\t\t// style using calc() will only apply if both values have units.\n\n\t\t\tif ( typeof borderRadius === 'object' ) {\n\t\t\t\t// Individual corner border radii present.\n\t\t\t\tconst { topLeft, topRight, bottomLeft, bottomRight } =\n\t\t\t\t\tborderRadius;\n\n\t\t\t\treturn {\n\t\t\t\t\t...styles,\n\t\t\t\t\tborderTopLeftRadius: padBorderRadius( topLeft ),\n\t\t\t\t\tborderTopRightRadius: padBorderRadius( topRight ),\n\t\t\t\t\tborderBottomLeftRadius: padBorderRadius( bottomLeft ),\n\t\t\t\t\tborderBottomRightRadius: padBorderRadius( bottomRight ),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// The inline style using calc() will only apply if both values\n\t\t\t// supplied to calc() have units. Deprecated block's may have\n\t\t\t// unitless integer.\n\t\t\tconst radius = Number.isInteger( borderRadius )\n\t\t\t\t? `${ borderRadius }px`\n\t\t\t\t: borderRadius;\n\n\t\t\tstyles.borderRadius = `calc(${ radius } + ${ DEFAULT_INNER_PADDING })`;\n\t\t}\n\n\t\treturn styles;\n\t};\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: getBlockClassNames(),\n\t\tstyle: {\n\t\t\t...typographyProps.style,\n\t\t\t// Input opts out of text decoration.\n\t\t\ttextDecoration: undefined,\n\t\t},\n\t} );\n\n\tconst labelClassnames = classnames(\n\t\t'wp-block-search__label',\n\t\ttypographyProps.className\n\t);\n\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t{ controls }\n\n\t\t\t{ showLabel && (\n\t\t\t\t<RichText\n\t\t\t\t\tclassName={ labelClassnames }\n\t\t\t\t\taria-label={ __( 'Label text' ) }\n\t\t\t\t\tplaceholder={ __( 'Add label…' ) }\n\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\tvalue={ label }\n\t\t\t\t\tonChange={ ( html ) => setAttributes( { label: html } ) }\n\t\t\t\t\tstyle={ typographyProps.style }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<ResizableBox\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: `${ width }${ widthUnit }`,\n\t\t\t\t} }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'wp-block-search__inside-wrapper',\n\t\t\t\t\tisButtonPositionInside ? borderProps.className : undefined\n\t\t\t\t) }\n\t\t\t\tstyle={ getWrapperStyles() }\n\t\t\t\tminWidth={ MIN_WIDTH }\n\t\t\t\tenable={ getResizableSides() }\n\t\t\t\tonResizeStart={ ( event, direction, elt ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( elt.offsetWidth, 10 ),\n\t\t\t\t\t\twidthUnit: 'px',\n\t\t\t\t\t} );\n\t\t\t\t\ttoggleSelection( false );\n\t\t\t\t} }\n\t\t\t\tonResizeStop={ ( event, direction, elt, delta ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\twidth: parseInt( width + delta.width, 10 ),\n\t\t\t\t\t} );\n\t\t\t\t\ttoggleSelection( true );\n\t\t\t\t} }\n\t\t\t\tshowHandle={ isSelected }\n\t\t\t>\n\t\t\t\t{ ( isButtonPositionInside || isButtonPositionOutside ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ renderTextField() }\n\t\t\t\t\t\t{ renderButton() }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\n\t\t\t\t{ hasOnlyButton && renderButton() }\n\t\t\t\t{ hasNoButton && renderTextField() }\n\t\t\t</ResizableBox>\n\t\t</div>\n\t);\n}\n"]}
@@ -51,6 +51,7 @@ const SocialLinkURLPopover = _ref => {
51
51
  }, (0, _element.createElement)("div", {
52
52
  className: "block-editor-url-input"
53
53
  }, (0, _element.createElement)(_blockEditor.URLInput, {
54
+ __nextHasNoMarginBottom: true,
54
55
  value: url,
55
56
  onChange: nextURL => setAttributes({
56
57
  url: nextURL
@@ -107,7 +108,7 @@ const SocialLinkEdit = _ref2 => {
107
108
  }, (0, _element.createElement)(_components.PanelRow, null, (0, _element.createElement)(_components.TextControl, {
108
109
  label: (0, _i18n.__)('Link label'),
109
110
  help: (0, _i18n.__)('Briefly describe the link to help screen reader users.'),
110
- value: label,
111
+ value: label || '',
111
112
  onChange: value => setAttributes({
112
113
  label: value
113
114
  })