@wordpress/block-library 8.18.1-next.5a1d1283.0 → 8.19.1

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 (386) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -1
  3. package/build/block/edit.js +53 -2
  4. package/build/block/edit.js.map +1 -1
  5. package/build/button/edit.js +7 -4
  6. package/build/button/edit.js.map +1 -1
  7. package/build/button/index.js +11 -2
  8. package/build/button/index.js.map +1 -1
  9. package/build/button/save.js +10 -4
  10. package/build/button/save.js.map +1 -1
  11. package/build/buttons/edit.js +12 -3
  12. package/build/buttons/edit.js.map +1 -1
  13. package/build/code/edit.js +8 -2
  14. package/build/code/edit.js.map +1 -1
  15. package/build/code/index.js +7 -1
  16. package/build/code/index.js.map +1 -1
  17. package/build/column/index.js +1 -0
  18. package/build/column/index.js.map +1 -1
  19. package/build/columns/index.js +2 -0
  20. package/build/columns/index.js.map +1 -1
  21. package/build/file/edit.native.js +1 -1
  22. package/build/file/edit.native.js.map +1 -1
  23. package/build/file/index.js +2 -1
  24. package/build/file/index.js.map +1 -1
  25. package/build/file/utils/index.js +1 -15
  26. package/build/file/utils/index.js.map +1 -1
  27. package/build/file/view.js +14 -1
  28. package/build/file/view.js.map +1 -1
  29. package/build/footnotes/edit.js +12 -2
  30. package/build/footnotes/edit.js.map +1 -1
  31. package/build/gallery/edit.js +1 -1
  32. package/build/gallery/edit.js.map +1 -1
  33. package/build/group/edit.js +0 -1
  34. package/build/group/edit.js.map +1 -1
  35. package/build/group/index.js +4 -0
  36. package/build/group/index.js.map +1 -1
  37. package/build/heading/edit.js +0 -1
  38. package/build/heading/edit.js.map +1 -1
  39. package/build/heading/index.js +2 -0
  40. package/build/heading/index.js.map +1 -1
  41. package/build/heading/transforms.js +3 -6
  42. package/build/heading/transforms.js.map +1 -1
  43. package/build/image/deprecated.js +191 -7
  44. package/build/image/deprecated.js.map +1 -1
  45. package/build/image/edit.js +27 -12
  46. package/build/image/edit.js.map +1 -1
  47. package/build/image/image.js +75 -40
  48. package/build/image/image.js.map +1 -1
  49. package/build/image/index.js +7 -4
  50. package/build/image/index.js.map +1 -1
  51. package/build/image/{view-interactivity.js → view.js} +1 -1
  52. package/build/image/view.js.map +1 -0
  53. package/build/list/deprecated.js +93 -1
  54. package/build/list/deprecated.js.map +1 -1
  55. package/build/list/edit.js +10 -10
  56. package/build/list/edit.js.map +1 -1
  57. package/build/list/ordered-list-settings.js +10 -10
  58. package/build/list/ordered-list-settings.js.map +1 -1
  59. package/build/list/save.js +4 -2
  60. package/build/list/save.js.map +1 -1
  61. package/build/list/utils.js +21 -2
  62. package/build/list/utils.js.map +1 -1
  63. package/build/navigation/constants.js +1 -1
  64. package/build/navigation/constants.js.map +1 -1
  65. package/build/navigation/index.js +4 -2
  66. package/build/navigation/index.js.map +1 -1
  67. package/build/navigation/view.js +168 -82
  68. package/build/navigation/view.js.map +1 -1
  69. package/build/navigation-link/edit.js +3 -9
  70. package/build/navigation-link/edit.js.map +1 -1
  71. package/build/navigation-link/transforms.js +24 -0
  72. package/build/navigation-link/transforms.js.map +1 -1
  73. package/build/page-list/edit.js +2 -1
  74. package/build/page-list/edit.js.map +1 -1
  75. package/build/pattern/edit.js +2 -0
  76. package/build/pattern/edit.js.map +1 -1
  77. package/build/post-comments-form/edit.js +10 -2
  78. package/build/post-comments-form/edit.js.map +1 -1
  79. package/build/post-comments-form/form.js +5 -3
  80. package/build/post-comments-form/form.js.map +1 -1
  81. package/build/post-content/edit.js +8 -7
  82. package/build/post-content/edit.js.map +1 -1
  83. package/build/post-content/index.js +3 -0
  84. package/build/post-content/index.js.map +1 -1
  85. package/build/post-featured-image/overlay.js +2 -1
  86. package/build/post-featured-image/overlay.js.map +1 -1
  87. package/build/preformatted/edit.js +4 -1
  88. package/build/preformatted/edit.js.map +1 -1
  89. package/build/preformatted/index.js +1 -1
  90. package/build/preformatted/index.js.map +1 -1
  91. package/build/pullquote/deprecated.js +6 -7
  92. package/build/pullquote/deprecated.js.map +1 -1
  93. package/build/query/edit/enhanced-pagination-modal.js +56 -0
  94. package/build/query/edit/enhanced-pagination-modal.js.map +1 -0
  95. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +42 -0
  96. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
  97. package/build/query/edit/inspector-controls/index.js +8 -25
  98. package/build/query/edit/inspector-controls/index.js.map +1 -1
  99. package/build/query/edit/query-content.js +8 -2
  100. package/build/query/edit/query-content.js.map +1 -1
  101. package/build/query/utils.js +19 -0
  102. package/build/query/utils.js.map +1 -1
  103. package/build/query/view.js +21 -6
  104. package/build/query/view.js.map +1 -1
  105. package/build/search/index.js +1 -0
  106. package/build/search/index.js.map +1 -1
  107. package/build/search/view.js +81 -150
  108. package/build/search/view.js.map +1 -1
  109. package/build/social-link/edit.native.js +3 -1
  110. package/build/social-link/edit.native.js.map +1 -1
  111. package/build/table/edit.js +7 -7
  112. package/build/table/edit.js.map +1 -1
  113. package/build/table-of-contents/edit.js +2 -130
  114. package/build/table-of-contents/edit.js.map +1 -1
  115. package/build/table-of-contents/hooks.js +145 -0
  116. package/build/table-of-contents/hooks.js.map +1 -0
  117. package/build/table-of-contents/index.js +2 -1
  118. package/build/table-of-contents/index.js.map +1 -1
  119. package/build/verse/edit.js +4 -1
  120. package/build/verse/edit.js.map +1 -1
  121. package/build/verse/index.js +1 -1
  122. package/build/verse/index.js.map +1 -1
  123. package/build-module/block/edit.js +54 -3
  124. package/build-module/block/edit.js.map +1 -1
  125. package/build-module/button/edit.js +7 -4
  126. package/build-module/button/edit.js.map +1 -1
  127. package/build-module/button/index.js +11 -2
  128. package/build-module/button/index.js.map +1 -1
  129. package/build-module/button/save.js +10 -4
  130. package/build-module/button/save.js.map +1 -1
  131. package/build-module/buttons/edit.js +12 -3
  132. package/build-module/buttons/edit.js.map +1 -1
  133. package/build-module/code/edit.js +8 -2
  134. package/build-module/code/edit.js.map +1 -1
  135. package/build-module/code/index.js +7 -1
  136. package/build-module/code/index.js.map +1 -1
  137. package/build-module/column/index.js +1 -0
  138. package/build-module/column/index.js.map +1 -1
  139. package/build-module/columns/index.js +2 -0
  140. package/build-module/columns/index.js.map +1 -1
  141. package/build-module/file/edit.native.js +1 -1
  142. package/build-module/file/edit.native.js.map +1 -1
  143. package/build-module/file/index.js +2 -1
  144. package/build-module/file/index.js.map +1 -1
  145. package/build-module/file/utils/index.js +0 -13
  146. package/build-module/file/utils/index.js.map +1 -1
  147. package/build-module/file/view.js +14 -2
  148. package/build-module/file/view.js.map +1 -1
  149. package/build-module/footnotes/edit.js +12 -2
  150. package/build-module/footnotes/edit.js.map +1 -1
  151. package/build-module/gallery/edit.js +1 -1
  152. package/build-module/gallery/edit.js.map +1 -1
  153. package/build-module/group/edit.js +0 -1
  154. package/build-module/group/edit.js.map +1 -1
  155. package/build-module/group/index.js +4 -0
  156. package/build-module/group/index.js.map +1 -1
  157. package/build-module/heading/edit.js +0 -1
  158. package/build-module/heading/edit.js.map +1 -1
  159. package/build-module/heading/index.js +2 -0
  160. package/build-module/heading/index.js.map +1 -1
  161. package/build-module/heading/transforms.js +3 -6
  162. package/build-module/heading/transforms.js.map +1 -1
  163. package/build-module/image/deprecated.js +191 -7
  164. package/build-module/image/deprecated.js.map +1 -1
  165. package/build-module/image/edit.js +27 -12
  166. package/build-module/image/edit.js.map +1 -1
  167. package/build-module/image/image.js +77 -42
  168. package/build-module/image/image.js.map +1 -1
  169. package/build-module/image/index.js +7 -4
  170. package/build-module/image/index.js.map +1 -1
  171. package/build-module/image/{view-interactivity.js → view.js} +1 -1
  172. package/build-module/image/view.js.map +1 -0
  173. package/build-module/list/deprecated.js +95 -3
  174. package/build-module/list/deprecated.js.map +1 -1
  175. package/build-module/list/edit.js +10 -10
  176. package/build-module/list/edit.js.map +1 -1
  177. package/build-module/list/ordered-list-settings.js +10 -10
  178. package/build-module/list/ordered-list-settings.js.map +1 -1
  179. package/build-module/list/save.js +4 -2
  180. package/build-module/list/save.js.map +1 -1
  181. package/build-module/list/utils.js +20 -2
  182. package/build-module/list/utils.js.map +1 -1
  183. package/build-module/navigation/constants.js +1 -1
  184. package/build-module/navigation/constants.js.map +1 -1
  185. package/build-module/navigation/index.js +4 -2
  186. package/build-module/navigation/index.js.map +1 -1
  187. package/build-module/navigation/view.js +168 -83
  188. package/build-module/navigation/view.js.map +1 -1
  189. package/build-module/navigation-link/edit.js +3 -9
  190. package/build-module/navigation-link/edit.js.map +1 -1
  191. package/build-module/navigation-link/transforms.js +24 -0
  192. package/build-module/navigation-link/transforms.js.map +1 -1
  193. package/build-module/page-list/edit.js +2 -1
  194. package/build-module/page-list/edit.js.map +1 -1
  195. package/build-module/pattern/edit.js +2 -0
  196. package/build-module/pattern/edit.js.map +1 -1
  197. package/build-module/post-comments-form/edit.js +10 -2
  198. package/build-module/post-comments-form/edit.js.map +1 -1
  199. package/build-module/post-comments-form/form.js +5 -3
  200. package/build-module/post-comments-form/form.js.map +1 -1
  201. package/build-module/post-content/edit.js +8 -7
  202. package/build-module/post-content/edit.js.map +1 -1
  203. package/build-module/post-content/index.js +3 -0
  204. package/build-module/post-content/index.js.map +1 -1
  205. package/build-module/post-featured-image/overlay.js +2 -1
  206. package/build-module/post-featured-image/overlay.js.map +1 -1
  207. package/build-module/preformatted/edit.js +4 -1
  208. package/build-module/preformatted/edit.js.map +1 -1
  209. package/build-module/preformatted/index.js +1 -1
  210. package/build-module/preformatted/index.js.map +1 -1
  211. package/build-module/pullquote/deprecated.js +6 -7
  212. package/build-module/pullquote/deprecated.js.map +1 -1
  213. package/build-module/query/edit/enhanced-pagination-modal.js +50 -0
  214. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -0
  215. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +35 -0
  216. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
  217. package/build-module/query/edit/inspector-controls/index.js +9 -26
  218. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  219. package/build-module/query/edit/query-content.js +8 -2
  220. package/build-module/query/edit/query-content.js.map +1 -1
  221. package/build-module/query/utils.js +17 -0
  222. package/build-module/query/utils.js.map +1 -1
  223. package/build-module/query/view.js +21 -6
  224. package/build-module/query/view.js.map +1 -1
  225. package/build-module/search/index.js +1 -0
  226. package/build-module/search/index.js.map +1 -1
  227. package/build-module/search/view.js +81 -151
  228. package/build-module/search/view.js.map +1 -1
  229. package/build-module/social-link/edit.native.js +3 -1
  230. package/build-module/social-link/edit.native.js.map +1 -1
  231. package/build-module/table/edit.js +7 -7
  232. package/build-module/table/edit.js.map +1 -1
  233. package/build-module/table-of-contents/edit.js +3 -131
  234. package/build-module/table-of-contents/edit.js.map +1 -1
  235. package/build-module/table-of-contents/hooks.js +137 -0
  236. package/build-module/table-of-contents/hooks.js.map +1 -0
  237. package/build-module/table-of-contents/index.js +2 -1
  238. package/build-module/table-of-contents/index.js.map +1 -1
  239. package/build-module/verse/edit.js +4 -1
  240. package/build-module/verse/edit.js.map +1 -1
  241. package/build-module/verse/index.js +1 -1
  242. package/build-module/verse/index.js.map +1 -1
  243. package/build-style/cover/style-rtl.css +9 -0
  244. package/build-style/cover/style.css +9 -0
  245. package/build-style/editor-rtl.css +15 -9
  246. package/build-style/editor.css +15 -9
  247. package/build-style/file/style-rtl.css +5 -0
  248. package/build-style/file/style.css +5 -0
  249. package/build-style/heading/style-rtl.css +13 -0
  250. package/build-style/heading/style.css +13 -0
  251. package/build-style/navigation-link/editor-rtl.css +0 -9
  252. package/build-style/navigation-link/editor.css +0 -9
  253. package/build-style/paragraph/editor-rtl.css +5 -0
  254. package/build-style/paragraph/editor.css +5 -0
  255. package/build-style/paragraph/style-rtl.css +5 -0
  256. package/build-style/paragraph/style.css +5 -0
  257. package/build-style/post-navigation-link/style-rtl.css +3 -0
  258. package/build-style/post-navigation-link/style.css +3 -0
  259. package/build-style/query/editor-rtl.css +10 -0
  260. package/build-style/query/editor.css +10 -0
  261. package/build-style/query/style-rtl.css +1 -1
  262. package/build-style/query/style.css +1 -1
  263. package/build-style/reset-rtl.css +27 -27
  264. package/build-style/reset.css +27 -27
  265. package/build-style/style-rtl.css +35 -0
  266. package/build-style/style.css +35 -0
  267. package/package.json +33 -34
  268. package/src/audio/test/__snapshots__/edit.native.js.snap +78 -106
  269. package/src/avatar/index.php +2 -2
  270. package/src/block/edit.js +58 -2
  271. package/src/block/test/edit.native.js +2 -3
  272. package/src/button/block.json +11 -2
  273. package/src/button/edit.js +27 -11
  274. package/src/button/save.js +10 -4
  275. package/src/buttons/edit.js +13 -3
  276. package/src/buttons/test/edit.native.js +28 -24
  277. package/src/calendar/index.php +2 -2
  278. package/src/code/block.json +2 -1
  279. package/src/code/edit.js +13 -1
  280. package/src/code/index.js +5 -0
  281. package/src/column/block.json +1 -0
  282. package/src/columns/block.json +2 -0
  283. package/src/comment-template/index.php +1 -1
  284. package/src/comments-pagination-next/index.php +1 -1
  285. package/src/comments-pagination-previous/index.php +1 -1
  286. package/src/cover/style.scss +12 -1
  287. package/src/cover/test/edit.js +10 -10
  288. package/src/cover/test/edit.native.js +18 -27
  289. package/src/embed/test/index.native.js +30 -45
  290. package/src/file/block.json +2 -1
  291. package/src/file/edit.native.js +1 -1
  292. package/src/file/index.php +21 -21
  293. package/src/file/style.scss +6 -1
  294. package/src/file/test/__snapshots__/edit.native.js.snap +162 -218
  295. package/src/file/utils/index.js +0 -15
  296. package/src/file/view.js +14 -5
  297. package/src/footnotes/edit.js +13 -1
  298. package/src/gallery/edit.js +1 -1
  299. package/src/gallery/index.php +1 -1
  300. package/src/group/block.json +4 -0
  301. package/src/group/edit.js +0 -1
  302. package/src/heading/block.json +2 -0
  303. package/src/heading/edit.js +0 -1
  304. package/src/heading/style.scss +4 -0
  305. package/src/heading/transforms.js +1 -6
  306. package/src/image/block.json +7 -4
  307. package/src/image/deprecated.js +210 -7
  308. package/src/image/edit.js +43 -29
  309. package/src/image/image.js +86 -43
  310. package/src/image/index.php +253 -28
  311. package/src/latest-posts/index.php +1 -1
  312. package/src/list/deprecated.js +84 -3
  313. package/src/list/edit.js +6 -3
  314. package/src/list/ordered-list-settings.js +20 -5
  315. package/src/list/save.js +10 -1
  316. package/src/list/test/edit.native.js +2 -4
  317. package/src/list/utils.js +22 -1
  318. package/src/navigation/block.json +4 -2
  319. package/src/navigation/constants.js +1 -0
  320. package/src/navigation/index.php +87 -123
  321. package/src/navigation/view.js +192 -96
  322. package/src/navigation-link/edit.js +21 -36
  323. package/src/navigation-link/editor.scss +0 -8
  324. package/src/navigation-link/transforms.js +22 -0
  325. package/src/page-list/edit.js +2 -1
  326. package/src/paragraph/editor.scss +5 -0
  327. package/src/paragraph/style.scss +5 -0
  328. package/src/pattern/edit.js +1 -0
  329. package/src/pattern/index.php +5 -5
  330. package/src/post-comments-form/edit.js +10 -0
  331. package/src/post-comments-form/form.js +7 -1
  332. package/src/post-content/block.json +3 -0
  333. package/src/post-content/edit.js +14 -6
  334. package/src/post-excerpt/index.php +2 -2
  335. package/src/post-featured-image/index.php +2 -2
  336. package/src/post-featured-image/overlay.js +1 -0
  337. package/src/post-navigation-link/index.php +0 -5
  338. package/src/post-navigation-link/style.scss +4 -0
  339. package/src/post-template/index.php +1 -1
  340. package/src/post-terms/index.php +5 -2
  341. package/src/preformatted/edit.js +5 -0
  342. package/src/preformatted/index.js +1 -1
  343. package/src/pullquote/deprecated.js +8 -13
  344. package/src/query/edit/enhanced-pagination-modal.js +65 -0
  345. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +49 -0
  346. package/src/query/edit/inspector-controls/index.js +9 -45
  347. package/src/query/edit/query-content.js +8 -0
  348. package/src/query/editor.scss +10 -0
  349. package/src/query/index.php +31 -16
  350. package/src/query/style.scss +2 -2
  351. package/src/query/utils.js +22 -0
  352. package/src/query/view.js +19 -10
  353. package/src/query-pagination-next/index.php +2 -1
  354. package/src/query-pagination-previous/index.php +2 -1
  355. package/src/reset.scss +1 -1
  356. package/src/search/block.json +1 -0
  357. package/src/search/index.php +47 -4
  358. package/src/search/test/__snapshots__/edit.native.js.snap +265 -363
  359. package/src/search/view.js +70 -169
  360. package/src/social-link/edit.native.js +1 -1
  361. package/src/social-link/editor.native.scss +4 -0
  362. package/src/table/edit.js +21 -19
  363. package/src/table-of-contents/block.json +2 -1
  364. package/src/table-of-contents/edit.js +5 -162
  365. package/src/table-of-contents/hooks.js +156 -0
  366. package/src/verse/edit.js +5 -0
  367. package/src/verse/index.js +1 -1
  368. package/src/verse/test/edit.native.js +2 -3
  369. package/build/file/view-interactivity.js +0 -22
  370. package/build/file/view-interactivity.js.map +0 -1
  371. package/build/image/view-interactivity.js.map +0 -1
  372. package/build/navigation/view-interactivity.js +0 -172
  373. package/build/navigation/view-interactivity.js.map +0 -1
  374. package/build/navigation/view-modal.js +0 -115
  375. package/build/navigation/view-modal.js.map +0 -1
  376. package/build-module/file/view-interactivity.js +0 -18
  377. package/build-module/file/view-interactivity.js.map +0 -1
  378. package/build-module/image/view-interactivity.js.map +0 -1
  379. package/build-module/navigation/view-interactivity.js +0 -169
  380. package/build-module/navigation/view-interactivity.js.map +0 -1
  381. package/build-module/navigation/view-modal.js +0 -112
  382. package/build-module/navigation/view-modal.js.map +0 -1
  383. package/src/file/view-interactivity.js +0 -18
  384. package/src/navigation/view-interactivity.js +0 -196
  385. package/src/navigation/view-modal.js +0 -127
  386. /package/src/image/{view-interactivity.js → view.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_element","_coreData","_blockEditor","_htmlEntities","_blocks","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","exports","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","decodeEntities","usePostTypes","postTypes","useSelect","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","useMemo","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","cloneBlock","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","blockEditorStore","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\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/** @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 return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\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( getValueFromObjectPath( 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\t'core/query',\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\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\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\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', '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\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AARA;AACA;AACA;;AAQA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAC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GAAG,IAAAlD,gBAAO,EAAE,MAAM;IACjC;IACA;IACA,MAAMmD,cAAc,GAAKC,SAAS,IACjC,CAAEA,SAAS,CAACnC,UAAU,EAAEoC,SAAS;IAClC,IAAK,CAAEd,mBAAmB,EAAG;MAC5B,OAAOS,eAAe,CAACrD,MAAM,CAAEwD,cAAe,CAAC;IAChD;IACA,MAAMG,mBAAmB,GAAGN,eAAe,CAACrD,MAAM,CAAIyD,SAAS,IAC9DA,SAAS,CAACnC,UAAU,EAAEoC,SAAS,EAAEvD,QAAQ,CAAEyC,mBAAoB,CAChE,CAAC;IACD,IAAK,CAAC,CAAEe,mBAAmB,CAACrD,MAAM,EAAG;MACpC,OAAOqD,mBAAmB;IAC3B;IACA,OAAON,eAAe,CAACrD,MAAM,CAAEwD,cAAe,CAAC;EAChD,CAAC,EAAE,CAAEZ,mBAAmB,EAAES,eAAe,CAAG,CAAC;EAC7C,OAAOE,UAAU;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMK,WAAW,GAAGA,CAAErB,QAAQ,EAAE9D,IAAI,KAAM;EAChD,OAAO,IAAAgB,eAAS,EACbC,MAAM,IAAM;IACb,MAAM;MAAEqD,oBAAoB;MAAEC;IAAwB,CAAC,GACtDtD,MAAM,CAAEuD,kBAAiB,CAAC;IAC3B,MAAMC,YAAY,GAAGH,oBAAoB,CAAER,QAAS,CAAC;IACrD,OAAOS,uBAAuB,CAAEvE,IAAI,EAAEyE,YAAa,CAAC;EACrD,CAAC,EACD,CAAEzE,IAAI,EAAE8D,QAAQ,CACjB,CAAC;AACF,CAAC;AAAC5D,OAAA,CAAAiF,WAAA,GAAAA,WAAA"}
1
+ {"version":3,"names":["_data","require","_element","_coreData","_blockEditor","_htmlEntities","_blocks","getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","exports","getValueFromObjectPath","object","path","normalizedPath","split","value","forEach","fieldName","mapToIHasNameAndId","map","decodeEntities","usePostTypes","postTypes","useSelect","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","useMemo","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","useIsPostTypeHierarchical","getPostType","hierarchical","useAllowedControls","attributes","blocksStore","getActiveBlockVariation","allowedControls","isControlAllowed","key","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","cloneBlock","queryClientIds","blocksQueue","shift","clientId","innerBlocks","innerBlock","newBlocks","useBlockNameForPatterns","activeVariationName","blockName","hasActiveVariationPatterns","getBlockRootClientId","getPatternsByBlockTypes","blockEditorStore","rootClientId","activePatterns","useScopedBlockVariations","blockVariations","getBlockVariations","variations","isNotConnected","variation","namespace","connectedVariations","usePatterns","useContainsThirdPartyBlocks","getClientIdsOfDescendants","getBlockName","some","descendantClientId","startsWith"],"sources":["@wordpress/block-library/src/query/utils.js"],"sourcesContent":["/**\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/** @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 return a value from a certain path of the object.\n * Path is specified as a string of properties, separated by dots,\n * for example: \"parent.child\".\n *\n * @param {Object} object Input object.\n * @param {string} path Path to the object property.\n * @return {*} Value of the object property at the specified path.\n */\nexport const getValueFromObjectPath = ( object, path ) => {\n\tconst normalizedPath = path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value;\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( getValueFromObjectPath( 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\t'core/query',\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\t'core/query',\n\t\t\t\tattributes\n\t\t\t)?.name,\n\t\t[ attributes ]\n\t);\n\tconst blockName = `core/query/${ activeVariationName }`;\n\tconst hasActiveVariationPatterns = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! activeVariationName ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst activePatterns = getPatternsByBlockTypes(\n\t\t\t\tblockName,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t\treturn activePatterns.length > 0;\n\t\t},\n\t\t[ clientId, activeVariationName, blockName ]\n\t);\n\treturn hasActiveVariationPatterns ? blockName : 'core/query';\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\t'core/query',\n\t\t\t\t\tattributes\n\t\t\t\t)?.name,\n\t\t\t\tblockVariations: getBlockVariations( 'core/query', '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\n/**\n * Hook that returns the block patterns for a specific block type.\n *\n * @param {string} clientId The block's client ID.\n * @param {string} name The block type name.\n * @return {Object[]} An array of valid block patterns.\n */\nexport const usePatterns = ( clientId, name ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getPatternsByBlockTypes } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn getPatternsByBlockTypes( name, rootClientId );\n\t\t},\n\t\t[ name, clientId ]\n\t);\n};\n\n/**\n * Hook that returns whether the Query Loop with the given `clientId` contains\n * any third-party block.\n *\n * @param {string} clientId The block's client ID.\n * @return {boolean} True if it contains third-party blocks.\n */\nexport const useContainsThirdPartyBlocks = ( clientId ) => {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst { getClientIdsOfDescendants, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn getClientIdsOfDescendants( clientId ).some(\n\t\t\t\t( descendantClientId ) =>\n\t\t\t\t\t! getBlockName( descendantClientId ).startsWith( 'core/' )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AARA;AACA;AACA;;AAQA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,eAAe,GAAKC,QAAQ,IAAM;EAC9C,MAAMC,OAAO,GAAGD,QAAQ,EAAEE,MAAM,CAC/B,CAAEC,WAAW,EAAEC,MAAM,KAAM;IAC1B,MAAM;MAAEC,OAAO;MAAEC,SAAS;MAAEC;IAAM,CAAC,GAAGJ,WAAW;IACjDE,OAAO,CAAED,MAAM,CAACI,EAAE,CAAE,GAAGJ,MAAM;IAC7BE,SAAS,CAAEF,MAAM,CAACK,IAAI,CAAE,GAAGL,MAAM;IACjCG,KAAK,CAACG,IAAI,CAAEN,MAAM,CAACK,IAAK,CAAC;IACzB,OAAON,WAAW;EACnB,CAAC,EACD;IAAEE,OAAO,EAAE,CAAC,CAAC;IAAEC,SAAS,EAAE,CAAC,CAAC;IAAEC,KAAK,EAAE;EAAG,CACzC,CAAC;EACD,OAAO;IACNP,QAAQ;IACR,GAAGC;EACJ,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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ACO,MAAMK,WAAW,GAAGA,CAAErB,QAAQ,EAAE9D,IAAI,KAAM;EAChD,OAAO,IAAAgB,eAAS,EACbC,MAAM,IAAM;IACb,MAAM;MAAEqD,oBAAoB;MAAEC;IAAwB,CAAC,GACtDtD,MAAM,CAAEuD,kBAAiB,CAAC;IAC3B,MAAMC,YAAY,GAAGH,oBAAoB,CAAER,QAAS,CAAC;IACrD,OAAOS,uBAAuB,CAAEvE,IAAI,EAAEyE,YAAa,CAAC;EACrD,CAAC,EACD,CAAEzE,IAAI,EAAE8D,QAAQ,CACjB,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANA5D,OAAA,CAAAiF,WAAA,GAAAA,WAAA;AAOO,MAAMC,2BAA2B,GAAKtB,QAAQ,IAAM;EAC1D,OAAO,IAAA9C,eAAS,EACbC,MAAM,IAAM;IACb,MAAM;MAAEoE,yBAAyB;MAAEC;IAAa,CAAC,GAChDrE,MAAM,CAAEuD,kBAAiB,CAAC;IAE3B,OAAOa,yBAAyB,CAAEvB,QAAS,CAAC,CAACyB,IAAI,CAC9CC,kBAAkB,IACnB,CAAEF,YAAY,CAAEE,kBAAmB,CAAC,CAACC,UAAU,CAAE,OAAQ,CAC3D,CAAC;EACF,CAAC,EACD,CAAE3B,QAAQ,CACX,CAAC;AACF,CAAC;AAAC5D,OAAA,CAAAkF,2BAAA,GAAAA,2BAAA"}
@@ -34,8 +34,7 @@ const isValidEvent = event => event.button === 0 &&
34
34
  navigate: async ({
35
35
  event,
36
36
  ref,
37
- context,
38
- state
37
+ context
39
38
  }) => {
40
39
  if (isValidLink(ref) && isValidEvent(event)) {
41
40
  event.preventDefault();
@@ -43,9 +42,9 @@ const isValidEvent = event => event.button === 0 &&
43
42
 
44
43
  // Don't announce the navigation immediately, wait 300 ms.
45
44
  const timeout = setTimeout(() => {
46
- context.core.query.message = state.core.query.loadingText;
45
+ context.core.query.message = context.core.query.loadingText;
47
46
  context.core.query.animation = 'start';
48
- }, 300);
47
+ }, 400);
49
48
  await (0, _interactivity.navigate)(ref.href);
50
49
 
51
50
  // Dismiss loading message if it hasn't been added yet.
@@ -54,11 +53,13 @@ const isValidEvent = event => event.button === 0 &&
54
53
  // Announce that the page has been loaded. If the message is the
55
54
  // same, we use a no-break space similar to the @wordpress/a11y
56
55
  // package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
57
- context.core.query.message = state.core.query.loadedText + (context.core.query.message === state.core.query.loadedText ? '\u00A0' : '');
56
+ context.core.query.message = context.core.query.loadedText + (context.core.query.message === context.core.query.loadedText ? '\u00A0' : '');
58
57
  context.core.query.animation = 'finish';
58
+ context.core.query.url = ref.href;
59
59
 
60
60
  // Focus the first anchor of the Query block.
61
- document.querySelector(`[data-wp-navigation-id=${id}] a[href]`)?.focus();
61
+ const firstAnchor = `[data-wp-navigation-id=${id}] .wp-block-post-template a[href]`;
62
+ document.querySelector(firstAnchor)?.focus();
62
63
  }
63
64
  },
64
65
  prefetch: async ({
@@ -70,6 +71,20 @@ const isValidEvent = event => event.button === 0 &&
70
71
  }
71
72
  }
72
73
  }
74
+ },
75
+ effects: {
76
+ core: {
77
+ query: {
78
+ prefetch: async ({
79
+ ref,
80
+ context
81
+ }) => {
82
+ if (context.core.query.url && isValidLink(ref)) {
83
+ await (0, _interactivity.prefetch)(ref.href);
84
+ }
85
+ }
86
+ }
87
+ }
73
88
  }
74
89
  });
75
90
  //# sourceMappingURL=view.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_interactivity","require","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","store","selectors","core","query","startAnimation","context","animation","finishAnimation","actions","navigate","state","preventDefault","id","closest","dataset","wpNavigationId","timeout","setTimeout","message","loadingText","clearTimeout","loadedText","document","querySelector","focus","prefetch"],"sources":["@wordpress/block-library/src/query/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, navigate, prefetch } from '@wordpress/interactivity';\n\nconst isValidLink = ( ref ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin;\n\nconst isValidEvent = ( event ) =>\n\tevent.button === 0 && // left clicks only\n\t! event.metaKey && // open in new tab (mac)\n\t! event.ctrlKey && // open in new tab (windows)\n\t! event.altKey && // download\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tstartAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'start',\n\t\t\t\tfinishAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'finish',\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tnavigate: async ( { event, ref, context, state } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\tconst id = ref.closest( '[data-wp-navigation-id]' )\n\t\t\t\t\t\t\t.dataset.wpNavigationId;\n\n\t\t\t\t\t\t// Don't announce the navigation immediately, wait 300 ms.\n\t\t\t\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\t\tstate.core.query.loadingText;\n\t\t\t\t\t\t\tcontext.core.query.animation = 'start';\n\t\t\t\t\t\t}, 300 );\n\n\t\t\t\t\t\tawait navigate( ref.href );\n\n\t\t\t\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\t\t\t\tclearTimeout( timeout );\n\n\t\t\t\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\tstate.core.query.loadedText +\n\t\t\t\t\t\t\t( context.core.query.message ===\n\t\t\t\t\t\t\tstate.core.query.loadedText\n\t\t\t\t\t\t\t\t? '\\u00A0'\n\t\t\t\t\t\t\t\t: '' );\n\n\t\t\t\t\t\tcontext.core.query.animation = 'finish';\n\n\t\t\t\t\t\t// Focus the first anchor of the Query block.\n\t\t\t\t\t\tdocument\n\t\t\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t\t\t`[data-wp-navigation-id=${ id }] a[href]`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t?.focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tprefetch: async ( { ref } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,WAAW,GAAKC,GAAG,IACxBA,GAAG,IACHA,GAAG,YAAYC,MAAM,CAACC,iBAAiB,IACvCF,GAAG,CAACG,IAAI,KACN,CAAEH,GAAG,CAACI,MAAM,IAAIJ,GAAG,CAACI,MAAM,KAAK,OAAO,CAAE,IAC1CJ,GAAG,CAACK,MAAM,KAAKJ,MAAM,CAACK,QAAQ,CAACD,MAAM;AAEtC,MAAME,YAAY,GAAKC,KAAK,IAC3BA,KAAK,CAACC,MAAM,KAAK,CAAC;AAAI;AACtB,CAAED,KAAK,CAACE,OAAO;AAAI;AACnB,CAAEF,KAAK,CAACG,OAAO;AAAI;AACnB,CAAEH,KAAK,CAACI,MAAM;AAAI;AAClB,CAAEJ,KAAK,CAACK,QAAQ,IAChB,CAAEL,KAAK,CAACM,gBAAgB;AAEzB,IAAAC,oBAAK,EAAE;EACNC,SAAS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CAAE;YAERhB,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,GAAG,QAAQ;;YAEvC;YACAgB,QAAQ,CACNC,aAAa,CACZ,0BAA0BX,EAAI,WAChC,CAAC,EACCY,KAAK,CAAC,CAAC;UACX;QACD,CAAC;QACDC,QAAQ,EAAE,MAAAA,CAAQ;UAAExC;QAAI,CAAC,KAAM;UAC9B,IAAKD,WAAW,CAAEC,GAAI,CAAC,EAAG;YACzB,MAAM,IAAAwC,uBAAQ,EAAExC,GAAG,CAACG,IAAK,CAAC;UAC3B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
1
+ {"version":3,"names":["_interactivity","require","isValidLink","ref","window","HTMLAnchorElement","href","target","origin","location","isValidEvent","event","button","metaKey","ctrlKey","altKey","shiftKey","defaultPrevented","store","selectors","core","query","startAnimation","context","animation","finishAnimation","actions","navigate","preventDefault","id","closest","dataset","wpNavigationId","timeout","setTimeout","message","loadingText","clearTimeout","loadedText","url","firstAnchor","document","querySelector","focus","prefetch","effects"],"sources":["@wordpress/block-library/src/query/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, navigate, prefetch } from '@wordpress/interactivity';\n\nconst isValidLink = ( ref ) =>\n\tref &&\n\tref instanceof window.HTMLAnchorElement &&\n\tref.href &&\n\t( ! ref.target || ref.target === '_self' ) &&\n\tref.origin === window.location.origin;\n\nconst isValidEvent = ( event ) =>\n\tevent.button === 0 && // left clicks only\n\t! event.metaKey && // open in new tab (mac)\n\t! event.ctrlKey && // open in new tab (windows)\n\t! event.altKey && // download\n\t! event.shiftKey &&\n\t! event.defaultPrevented;\n\nstore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tstartAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'start',\n\t\t\t\tfinishAnimation: ( { context } ) =>\n\t\t\t\t\tcontext.core.query.animation === 'finish',\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tnavigate: async ( { event, ref, context } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) && isValidEvent( event ) ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\tconst id = ref.closest( '[data-wp-navigation-id]' )\n\t\t\t\t\t\t\t.dataset.wpNavigationId;\n\n\t\t\t\t\t\t// Don't announce the navigation immediately, wait 300 ms.\n\t\t\t\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\t\tcontext.core.query.loadingText;\n\t\t\t\t\t\t\tcontext.core.query.animation = 'start';\n\t\t\t\t\t\t}, 400 );\n\n\t\t\t\t\t\tawait navigate( ref.href );\n\n\t\t\t\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\t\t\t\tclearTimeout( timeout );\n\n\t\t\t\t\t\t// Announce that the page has been loaded. If the message is the\n\t\t\t\t\t\t// same, we use a no-break space similar to the @wordpress/a11y\n\t\t\t\t\t\t// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26\n\t\t\t\t\t\tcontext.core.query.message =\n\t\t\t\t\t\t\tcontext.core.query.loadedText +\n\t\t\t\t\t\t\t( context.core.query.message ===\n\t\t\t\t\t\t\tcontext.core.query.loadedText\n\t\t\t\t\t\t\t\t? '\\u00A0'\n\t\t\t\t\t\t\t\t: '' );\n\n\t\t\t\t\t\tcontext.core.query.animation = 'finish';\n\t\t\t\t\t\tcontext.core.query.url = ref.href;\n\n\t\t\t\t\t\t// Focus the first anchor of the Query block.\n\t\t\t\t\t\tconst firstAnchor = `[data-wp-navigation-id=${ id }] .wp-block-post-template a[href]`;\n\t\t\t\t\t\tdocument.querySelector( firstAnchor )?.focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tprefetch: async ( { ref } ) => {\n\t\t\t\t\tif ( isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\teffects: {\n\t\tcore: {\n\t\t\tquery: {\n\t\t\t\tprefetch: async ( { ref, context } ) => {\n\t\t\t\t\tif ( context.core.query.url && isValidLink( ref ) ) {\n\t\t\t\t\t\tawait prefetch( ref.href );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,WAAW,GAAKC,GAAG,IACxBA,GAAG,IACHA,GAAG,YAAYC,MAAM,CAACC,iBAAiB,IACvCF,GAAG,CAACG,IAAI,KACN,CAAEH,GAAG,CAACI,MAAM,IAAIJ,GAAG,CAACI,MAAM,KAAK,OAAO,CAAE,IAC1CJ,GAAG,CAACK,MAAM,KAAKJ,MAAM,CAACK,QAAQ,CAACD,MAAM;AAEtC,MAAME,YAAY,GAAKC,KAAK,IAC3BA,KAAK,CAACC,MAAM,KAAK,CAAC;AAAI;AACtB,CAAED,KAAK,CAACE,OAAO;AAAI;AACnB,CAAEF,KAAK,CAACG,OAAO;AAAI;AACnB,CAAEH,KAAK,CAACI,MAAM;AAAI;AAClB,CAAEJ,KAAK,CAACK,QAAQ,IAChB,CAAEL,KAAK,CAACM,gBAAgB;AAEzB,IAAAC,oBAAK,EAAE;EACNC,SAAS,EAAE;IACVC,IAAI,EAAE;MACLC,KAAK,EAAE;QACNC,cAAc,EAAEA,CAAE;UAAEC;QAAQ,CAAC,KAC5BA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,KAAK,OAAO;QACzCC,eAAe,EAAEA,CAAE;UAAEF;QAAQ,CAAC,KAC7BA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACG,SAAS,KAAK;MACnC;IACD;EACD,CAAC;EACDE,OAAO,EAAE;IACRN,IAAI,EAAE;MACLC,KAAK,EAAE;QACNM,QAAQ,EAAE,MA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AAKD,WAAW,CAAEC,GAAI,CAAC,EAAG;YACzB,MAAM,IAAAyC,uBAAQ,EAAEzC,GAAG,CAACG,IAAK,CAAC;UAC3B;QACD;MACD;IACD;EACD,CAAC;EACDuC,OAAO,EAAE;IACRzB,IAAI,EAAE;MACLC,KAAK,EAAE;QACNuB,QAAQ,EAAE,MAAAA,CAAQ;UAAEzC,GAAG;UAAEoB;QAAQ,CAAC,KAAM;UACvC,IAAKA,OAAO,CAACH,IAAI,CAACC,KAAK,CAACkB,GAAG,IAAIrC,WAAW,CAAEC,GAAI,CAAC,EAAG;YACnD,MAAM,IAAAyC,uBAAQ,EAAEzC,GAAG,CAACG,IAAK,CAAC;UAC3B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
@@ -80,6 +80,7 @@ const metadata = {
80
80
  text: true
81
81
  }
82
82
  },
83
+ interactivity: true,
83
84
  typography: {
84
85
  __experimentalSkipSerialization: true,
85
86
  __experimentalSelector: ".wp-block-search__label, .wp-block-search__input, .wp-block-search__button",
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_edit","_variations","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","label","type","__experimentalRole","showLabel","placeholder","width","widthUnit","buttonText","buttonPosition","buttonUseIcon","query","buttonBehavior","isSearchFieldHidden","supports","align","color","gradients","__experimentalSkipSerialization","__experimentalDefaultControls","background","text","typography","__experimentalSelector","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalBorder","radius","html","viewScript","editorStyle","style","exports","settings","icon","example","__","viewportWidth","variations","edit","init","initBlock"],"sources":["@wordpress/block-library/src/search/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { search as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: { buttonText: __( 'Search' ), label: __( 'Search' ) },\n\t\tviewportWidth: 400,\n\t},\n\tvariations,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAF,sBAAA,CAAAH,OAAA;AAZA;AACA;AACA;AAIA;AACA;AACA;AAFA,MAAAM,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,kBAAA;IAAA;IAAAC,SAAA;MAAAF,IAAA;MAAA;IAAA;IAAAG,WAAA;MAAAH,IAAA;MAAA;MAAAC,kBAAA;IAAA;IAAAG,KAAA;MAAAJ,IAAA;IAAA;IAAAK,SAAA;MAAAL,IAAA;IAAA;IAAAM,UAAA;MAAAN,IAAA;MAAAC,kBAAA;IAAA;IAAAM,cAAA;MAAAP,IAAA;MAAA;IAAA;IAAAQ,aAAA;MAAAR,IAAA;MAAA;IAAA;IAAAS,KAAA;MAAAT,IAAA;MAAA;IAAA;IAAAU,cAAA;MAAAV,IAAA;MAAA;IAAA;IAAAW,mBAAA;MAAAX,IAAA;MAAA;IAAA;EAAA;EAAAY,QAAA;IAAAC,KAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,+BAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,UAAA;MAAAJ,+BAAA;MAAAK,sBAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAZ,6BAAA;QAAAK,QAAA;MAAA;IAAA;IAAAQ,oBAAA;MAAAhB,KAAA;MAAAiB,MAAA;MAAA3B,KAAA;MAAAY,+BAAA;MAAAC,6BAAA;QAAAH,KAAA;QAAAiB,MAAA;QAAA3B,KAAA;MAAA;IAAA;IAAA4B,IAAA;EAAA;EAAAC,UAAA;EAAAC,WAAA;EAAAC,KAAA;AAAA;AAAAC,OAAA,CAAA/C,QAAA,GAAAA,QAAA;AAQA,MAAM;EAAEG;AAAK,CAAC,GAAGH,QAAQ;AAAC+C,OAAA,CAAA5C,IAAA,GAAAA,IAAA;AAInB,MAAM6C,QAAQ,GAAG;EACvBC,IAAI,EAAJA,aAAI;EACJC,OAAO,EAAE;IACRzC,UAAU,EAAE;MAAEQ,UAAU,EAAE,IAAAkC,QAAE,EAAE,QAAS,CAAC;MAAEzC,KAAK,EAAE,IAAAyC,QAAE,EAAE,QAAS;IAAE,CAAC;IACjEC,aAAa,EAAE;EAChB,CAAC;EACDC,UAAU,EAAVA,mBAAU;EACVC,IAAI,EAAJA;AACD,CAAC;AAACP,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAEK,MAAMO,IAAI,GAAGA,CAAA,KAAM,IAAAC,kBAAS,EAAE;EAAErD,IAAI;EAAEH,QAAQ;EAAEgD;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAQ,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"names":["_i18n","require","_icons","_initBlock","_interopRequireDefault","_edit","_variations","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","label","type","__experimentalRole","showLabel","placeholder","width","widthUnit","buttonText","buttonPosition","buttonUseIcon","query","buttonBehavior","isSearchFieldHidden","supports","align","color","gradients","__experimentalSkipSerialization","__experimentalDefaultControls","background","text","interactivity","typography","__experimentalSelector","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalBorder","radius","html","viewScript","editorStyle","style","exports","settings","icon","example","__","viewportWidth","variations","edit","init","initBlock"],"sources":["@wordpress/block-library/src/search/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { search as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: { buttonText: __( 'Search' ), label: __( 'Search' ) },\n\t\tviewportWidth: 400,\n\t},\n\tvariations,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAF,sBAAA,CAAAH,OAAA;AAZA;AACA;AACA;AAIA;AACA;AACA;AAFA,MAAAM,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,kBAAA;IAAA;IAAAC,SAAA;MAAAF,IAAA;MAAA;IAAA;IAAAG,WAAA;MAAAH,IAAA;MAAA;MAAAC,kBAAA;IAAA;IAAAG,KAAA;MAAAJ,IAAA;IAAA;IAAAK,SAAA;MAAAL,IAAA;IAAA;IAAAM,UAAA;MAAAN,IAAA;MAAAC,kBAAA;IAAA;IAAAM,cAAA;MAAAP,IAAA;MAAA;IAAA;IAAAQ,a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;EAAEiD;AAAS,CAAE,CAAC;AAACD,OAAA,CAAAQ,IAAA,GAAAA,IAAA"}
@@ -1,158 +1,89 @@
1
1
  "use strict";
2
2
 
3
- /*eslint-env browser*/
4
-
5
- /** @type {?HTMLFormElement} */
6
- let expandedSearchBlock = null;
7
- const hiddenClass = 'wp-block-search__searchfield-hidden';
8
-
9
- /**
10
- * Toggles aria-label with data-toggled-aria-label.
11
- *
12
- * @param {HTMLElement} element
13
- */
14
- function toggleAriaLabel(element) {
15
- if (!('toggledAriaLabel' in element.dataset)) {
16
- throw new Error('Element lacks toggledAriaLabel in dataset.');
17
- }
18
- const ariaLabel = element.dataset.toggledAriaLabel;
19
- element.dataset.toggledAriaLabel = element.ariaLabel;
20
- element.ariaLabel = ariaLabel;
21
- }
22
-
23
- /**
24
- * Gets search input.
25
- *
26
- * @param {HTMLFormElement} block Search block.
27
- * @return {HTMLInputElement} Search input.
28
- */
29
- function getSearchInput(block) {
30
- return block.querySelector('.wp-block-search__input');
31
- }
32
-
33
- /**
34
- * Gets search button.
35
- *
36
- * @param {HTMLFormElement} block Search block.
37
- * @return {HTMLButtonElement} Search button.
38
- */
39
- function getSearchButton(block) {
40
- return block.querySelector('.wp-block-search__button');
41
- }
42
-
43
- /**
44
- * Handles keydown event to collapse an expanded Search block (when pressing Escape key).
45
- *
46
- * @param {KeyboardEvent} event
47
- */
48
- function handleKeydownEvent(event) {
49
- if (!expandedSearchBlock) {
50
- // In case the event listener wasn't removed in time.
51
- return;
52
- }
53
- if (event.key === 'Escape') {
54
- const block = expandedSearchBlock; // This is nullified by collapseExpandedSearchBlock().
55
- collapseExpandedSearchBlock();
56
- getSearchButton(block).focus();
57
- }
58
- }
59
-
60
- /**
61
- * Handles keyup event to collapse an expanded Search block (e.g. when tabbing out of expanded Search block).
62
- *
63
- * @param {KeyboardEvent} event
64
- */
65
- function handleKeyupEvent(event) {
66
- if (!expandedSearchBlock) {
67
- // In case the event listener wasn't removed in time.
68
- return;
69
- }
70
- if (event.target.closest('.wp-block-search') !== expandedSearchBlock) {
71
- collapseExpandedSearchBlock();
72
- }
73
- }
74
-
75
- /**
76
- * Expands search block.
77
- *
78
- * Inverse of what is done in collapseExpandedSearchBlock().
79
- *
80
- * @param {HTMLFormElement} block Search block.
81
- */
82
- function expandSearchBlock(block) {
83
- // Make sure only one is open at a time.
84
- if (expandedSearchBlock) {
85
- collapseExpandedSearchBlock();
86
- }
87
- const searchField = getSearchInput(block);
88
- const searchButton = getSearchButton(block);
89
- searchButton.type = 'submit';
90
- searchField.ariaHidden = 'false';
91
- searchField.tabIndex = 0;
92
- searchButton.ariaExpanded = 'true';
93
- searchButton.removeAttribute('aria-controls'); // Note: Seemingly not reflected with searchButton.ariaControls.
94
- toggleAriaLabel(searchButton);
95
- block.classList.remove(hiddenClass);
96
- searchField.focus(); // Note that Chrome seems to do this automatically.
97
-
98
- // The following two must be inverse of what is done in collapseExpandedSearchBlock().
99
- document.addEventListener('keydown', handleKeydownEvent, {
100
- passive: true
101
- });
102
- document.addEventListener('keyup', handleKeyupEvent, {
103
- passive: true
104
- });
105
- expandedSearchBlock = block;
106
- }
107
-
3
+ var _interactivity = require("@wordpress/interactivity");
108
4
  /**
109
- * Collapses the expanded search block.
110
- *
111
- * Inverse of what is done in expandSearchBlock().
5
+ * WordPress dependencies
112
6
  */
113
- function collapseExpandedSearchBlock() {
114
- if (!expandedSearchBlock) {
115
- throw new Error('Expected expandedSearchBlock to be defined.');
116
- }
117
- const block = expandedSearchBlock;
118
- const searchField = getSearchInput(block);
119
- const searchButton = getSearchButton(block);
120
- searchButton.type = 'button';
121
- searchField.ariaHidden = 'true';
122
- searchField.tabIndex = -1;
123
- searchButton.ariaExpanded = 'false';
124
- searchButton.setAttribute('aria-controls', searchField.id); // Note: Seemingly not reflected with searchButton.ariaControls.
125
- toggleAriaLabel(searchButton);
126
- block.classList.add(hiddenClass);
127
-
128
- // The following two must be inverse of what is done in expandSearchBlock().
129
- document.removeEventListener('keydown', handleKeydownEvent, {
130
- passive: true
131
- });
132
- document.removeEventListener('keyup', handleKeyupEvent, {
133
- passive: true
134
- });
135
- expandedSearchBlock = null;
136
- }
137
-
138
- // Listen for click events anywhere on the document so this script can be loaded asynchronously in the head.
139
- document.addEventListener('click', event => {
140
- // Get the ancestor expandable Search block of the clicked element.
141
- const block = event.target.closest('.wp-block-search__button-behavior-expand');
142
-
143
- /*
144
- * If there is already an expanded search block and either the current click was not for a Search block or it was
145
- * for another block, then collapse the currently-expanded block.
146
- */
147
- if (expandedSearchBlock && block !== expandedSearchBlock) {
148
- collapseExpandedSearchBlock();
149
- }
150
7
 
151
- // If the click was on or inside a collapsed Search block, expand it.
152
- if (block instanceof HTMLFormElement && block.classList.contains(hiddenClass)) {
153
- expandSearchBlock(block);
8
+ (0, _interactivity.store)({
9
+ selectors: {
10
+ core: {
11
+ search: {
12
+ ariaLabel: ({
13
+ context
14
+ }) => {
15
+ const {
16
+ ariaLabelCollapsed,
17
+ ariaLabelExpanded
18
+ } = context.core.search;
19
+ return context.core.search.isSearchInputVisible ? ariaLabelExpanded : ariaLabelCollapsed;
20
+ },
21
+ ariaControls: ({
22
+ context
23
+ }) => {
24
+ return context.core.search.isSearchInputVisible ? null : context.core.search.inputId;
25
+ },
26
+ type: ({
27
+ context
28
+ }) => {
29
+ return context.core.search.isSearchInputVisible ? 'submit' : 'button';
30
+ },
31
+ tabindex: ({
32
+ context
33
+ }) => {
34
+ return context.core.search.isSearchInputVisible ? '0' : '-1';
35
+ }
36
+ }
37
+ }
38
+ },
39
+ actions: {
40
+ core: {
41
+ search: {
42
+ openSearchInput: ({
43
+ context,
44
+ event,
45
+ ref
46
+ }) => {
47
+ if (!context.core.search.isSearchInputVisible) {
48
+ event.preventDefault();
49
+ context.core.search.isSearchInputVisible = true;
50
+ ref.parentElement.querySelector('input').focus();
51
+ }
52
+ },
53
+ closeSearchInput: ({
54
+ context
55
+ }) => {
56
+ context.core.search.isSearchInputVisible = false;
57
+ },
58
+ handleSearchKeydown: store => {
59
+ const {
60
+ actions,
61
+ event,
62
+ ref
63
+ } = store;
64
+ // If Escape close the menu.
65
+ if (event?.key === 'Escape') {
66
+ actions.core.search.closeSearchInput(store);
67
+ ref.querySelector('button').focus();
68
+ }
69
+ },
70
+ handleSearchFocusout: store => {
71
+ const {
72
+ actions,
73
+ event,
74
+ ref
75
+ } = store;
76
+ // If focus is outside search form, and in the document, close menu
77
+ // event.target === The element losing focus
78
+ // event.relatedTarget === The element receiving focus (if any)
79
+ // When focusout is outside the document,
80
+ // `window.document.activeElement` doesn't change.
81
+ if (!ref.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
82
+ actions.core.search.closeSearchInput(store);
83
+ }
84
+ }
85
+ }
86
+ }
154
87
  }
155
- }, {
156
- passive: true
157
88
  });
158
89
  //# sourceMappingURL=view.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["expandedSearchBlock","hiddenClass","toggleAriaLabel","element","dataset","Error","ariaLabel","toggledAriaLabel","getSearchInput","block","querySelector","getSearchButton","handleKeydownEvent","event","key","collapseExpandedSearchBlock","focus","handleKeyupEvent","target","closest","expandSearchBlock","searchField","searchButton","type","ariaHidden","tabIndex","ariaExpanded","removeAttribute","classList","remove","document","addEventListener","passive","setAttribute","id","add","removeEventListener","HTMLFormElement","contains"],"sources":["@wordpress/block-library/src/search/view.js"],"sourcesContent":["/*eslint-env browser*/\n\n/** @type {?HTMLFormElement} */\nlet expandedSearchBlock = null;\n\nconst hiddenClass = 'wp-block-search__searchfield-hidden';\n\n/**\n * Toggles aria-label with data-toggled-aria-label.\n *\n * @param {HTMLElement} element\n */\nfunction toggleAriaLabel( element ) {\n\tif ( ! ( 'toggledAriaLabel' in element.dataset ) ) {\n\t\tthrow new Error( 'Element lacks toggledAriaLabel in dataset.' );\n\t}\n\n\tconst ariaLabel = element.dataset.toggledAriaLabel;\n\telement.dataset.toggledAriaLabel = element.ariaLabel;\n\telement.ariaLabel = ariaLabel;\n}\n\n/**\n * Gets search input.\n *\n * @param {HTMLFormElement} block Search block.\n * @return {HTMLInputElement} Search input.\n */\nfunction getSearchInput( block ) {\n\treturn block.querySelector( '.wp-block-search__input' );\n}\n\n/**\n * Gets search button.\n *\n * @param {HTMLFormElement} block Search block.\n * @return {HTMLButtonElement} Search button.\n */\nfunction getSearchButton( block ) {\n\treturn block.querySelector( '.wp-block-search__button' );\n}\n\n/**\n * Handles keydown event to collapse an expanded Search block (when pressing Escape key).\n *\n * @param {KeyboardEvent} event\n */\nfunction handleKeydownEvent( event ) {\n\tif ( ! expandedSearchBlock ) {\n\t\t// In case the event listener wasn't removed in time.\n\t\treturn;\n\t}\n\n\tif ( event.key === 'Escape' ) {\n\t\tconst block = expandedSearchBlock; // This is nullified by collapseExpandedSearchBlock().\n\t\tcollapseExpandedSearchBlock();\n\t\tgetSearchButton( block ).focus();\n\t}\n}\n\n/**\n * Handles keyup event to collapse an expanded Search block (e.g. when tabbing out of expanded Search block).\n *\n * @param {KeyboardEvent} event\n */\nfunction handleKeyupEvent( event ) {\n\tif ( ! expandedSearchBlock ) {\n\t\t// In case the event listener wasn't removed in time.\n\t\treturn;\n\t}\n\n\tif ( event.target.closest( '.wp-block-search' ) !== expandedSearchBlock ) {\n\t\tcollapseExpandedSearchBlock();\n\t}\n}\n\n/**\n * Expands search block.\n *\n * Inverse of what is done in collapseExpandedSearchBlock().\n *\n * @param {HTMLFormElement} block Search block.\n */\nfunction expandSearchBlock( block ) {\n\t// Make sure only one is open at a time.\n\tif ( expandedSearchBlock ) {\n\t\tcollapseExpandedSearchBlock();\n\t}\n\n\tconst searchField = getSearchInput( block );\n\tconst searchButton = getSearchButton( block );\n\n\tsearchButton.type = 'submit';\n\tsearchField.ariaHidden = 'false';\n\tsearchField.tabIndex = 0;\n\tsearchButton.ariaExpanded = 'true';\n\tsearchButton.removeAttribute( 'aria-controls' ); // Note: Seemingly not reflected with searchButton.ariaControls.\n\ttoggleAriaLabel( searchButton );\n\tblock.classList.remove( hiddenClass );\n\n\tsearchField.focus(); // Note that Chrome seems to do this automatically.\n\n\t// The following two must be inverse of what is done in collapseExpandedSearchBlock().\n\tdocument.addEventListener( 'keydown', handleKeydownEvent, {\n\t\tpassive: true,\n\t} );\n\tdocument.addEventListener( 'keyup', handleKeyupEvent, {\n\t\tpassive: true,\n\t} );\n\n\texpandedSearchBlock = block;\n}\n\n/**\n * Collapses the expanded search block.\n *\n * Inverse of what is done in expandSearchBlock().\n */\nfunction collapseExpandedSearchBlock() {\n\tif ( ! expandedSearchBlock ) {\n\t\tthrow new Error( 'Expected expandedSearchBlock to be defined.' );\n\t}\n\tconst block = expandedSearchBlock;\n\tconst searchField = getSearchInput( block );\n\tconst searchButton = getSearchButton( block );\n\n\tsearchButton.type = 'button';\n\tsearchField.ariaHidden = 'true';\n\tsearchField.tabIndex = -1;\n\tsearchButton.ariaExpanded = 'false';\n\tsearchButton.setAttribute( 'aria-controls', searchField.id ); // Note: Seemingly not reflected with searchButton.ariaControls.\n\ttoggleAriaLabel( searchButton );\n\tblock.classList.add( hiddenClass );\n\n\t// The following two must be inverse of what is done in expandSearchBlock().\n\tdocument.removeEventListener( 'keydown', handleKeydownEvent, {\n\t\tpassive: true,\n\t} );\n\tdocument.removeEventListener( 'keyup', handleKeyupEvent, {\n\t\tpassive: true,\n\t} );\n\n\texpandedSearchBlock = null;\n}\n\n// Listen for click events anywhere on the document so this script can be loaded asynchronously in the head.\ndocument.addEventListener(\n\t'click',\n\t( event ) => {\n\t\t// Get the ancestor expandable Search block of the clicked element.\n\t\tconst block = event.target.closest(\n\t\t\t'.wp-block-search__button-behavior-expand'\n\t\t);\n\n\t\t/*\n\t\t * If there is already an expanded search block and either the current click was not for a Search block or it was\n\t\t * for another block, then collapse the currently-expanded block.\n\t\t */\n\t\tif ( expandedSearchBlock && block !== expandedSearchBlock ) {\n\t\t\tcollapseExpandedSearchBlock();\n\t\t}\n\n\t\t// If the click was on or inside a collapsed Search block, expand it.\n\t\tif (\n\t\t\tblock instanceof HTMLFormElement &&\n\t\t\tblock.classList.contains( hiddenClass )\n\t\t) {\n\t\t\texpandSearchBlock( block );\n\t\t}\n\t},\n\t{ passive: true }\n);\n"],"mappings":";;AAAA;;AAEA;AACA,IAAIA,mBAAmB,GAAG,IAAI;AAE9B,MAAMC,WAAW,GAAG,qCAAqC;;AAEzD;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAEC,OAAO,EAAG;EACnC,IAAK,EAAI,kBAAkB,IAAIA,OAAO,CAACC,OAAO,CAAE,EAAG;IAClD,MAAM,IAAIC,KAAK,CAAE,4CAA6C,CAAC;EAChE;EAEA,MAAMC,SAAS,GAAGH,OAAO,CAACC,OAAO,CAACG,gBAAgB;EAClDJ,OAAO,CAACC,OAAO,CAACG,gBAAgB,GAAGJ,OAAO,CAACG,SAAS;EACpDH,OAAO,CAACG,SAAS,GAAGA,SAAS;AAC9B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,cAAcA,CAAEC,KAAK,EAAG;EAChC,OAAOA,KAAK,CAACC,aAAa,CAAE,yBAA0B,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAEF,KAAK,EAAG;EACjC,OAAOA,KAAK,CAACC,aAAa,CAAE,0BAA2B,CAAC;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASE,kBAAkBA,CAAEC,KAAK,EAAG;EACpC,IAAK,CAAEb,mBAAmB,EAAG;IAC5B;IACA;EACD;EAEA,IAAKa,KAAK,CAACC,GAAG,KAAK,QAAQ,EAAG;IAC7B,MAAML,KAAK,GAAGT,mBAAmB,CAAC,CAAC;IACnCe,2BAA2B,CAAC,CAAC;IAC7BJ,eAAe,CAAEF,KAAM,CAAC,CAACO,KAAK,CAAC,CAAC;EACjC;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAAEJ,KAAK,EAAG;EAClC,IAAK,CAAEb,mBAAmB,EAAG;IAC5B;IACA;EACD;EAEA,IAAKa,KAAK,CAACK,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AAC;EAE7Ca,YAAY,CAACC,IAAI,GAAG,QAAQ;EAC5BF,WAAW,CAACG,UAAU,GAAG,MAAM;EAC/BH,WAAW,CAACI,QAAQ,GAAG,CAAC,CAAC;EACzBH,YAAY,CAACI,YAAY,GAAG,OAAO;EACnCJ,YAAY,CAACW,YAAY,CAAE,eAAe,EAAEZ,WAAW,CAACa,EAAG,CAAC,CAAC,CAAC;EAC9DhC,eAAe,CAAEoB,YAAa,CAAC;EAC/Bb,KAAK,CAACmB,SAAS,CAACO,GAAG,CAAElC,WAAY,CAAC;;EAElC;EACA6B,QAAQ,CAACM,mBAAmB,CAAE,SAAS,EAAExB,kBAAkB,EAAE;IAC5DoB,OAAO,EAAE;EACV,CAAE,CAAC;EACHF,QAAQ,CAACM,mBAAmB,CAAE,OAAO,EAAEnB,gBAAgB,EAAE;IACxDe,OAAO,EAAE;EACV,CAAE,CAAC;EAEHhC,mBAAmB,GAAG,IAAI;AAC3B;;AAEA;AACA8B,QAAQ,CAACC,gBAAgB,CACxB,OAAO,EACLlB,KAAK,IAAM;EACZ;EACA,MAAMJ,KAAK,GAAGI,KAAK,CAACK,MAAM,CAACC,OAAO,CACjC,0CACD,CAAC;;EAED;AACF;AACA;AACA;EACE,IAAKnB,mBAAmB,IAAIS,KAAK,KAAKT,mBAAmB,EAAG;IAC3De,2BAA2B,CAAC,CAAC;EAC9B;;EAEA;EACA,IACCN,KAAK,YAAY4B,eAAe,IAChC5B,KAAK,CAACmB,SAAS,CAACU,QAAQ,CAAErC,WAAY,CAAC,EACtC;IACDmB,iBAAiB,CAAEX,KAAM,CAAC;EAC3B;AACD,CAAC,EACD;EAAEuB,OAAO,EAAE;AAAK,CACjB,CAAC"}
1
+ {"version":3,"names":["_interactivity","require","wpStore","selectors","core","search","ariaLabel","context","ariaLabelCollapsed","ariaLabelExpanded","isSearchInputVisible","ariaControls","inputId","type","tabindex","actions","openSearchInput","event","ref","preventDefault","parentElement","querySelector","focus","closeSearchInput","handleSearchKeydown","store","key","handleSearchFocusout","contains","relatedTarget","target","window","document","activeElement"],"sources":["@wordpress/block-library/src/search/view.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as wpStore } from '@wordpress/interactivity';\n\nwpStore( {\n\tselectors: {\n\t\tcore: {\n\t\t\tsearch: {\n\t\t\t\tariaLabel: ( { context } ) => {\n\t\t\t\t\tconst { ariaLabelCollapsed, ariaLabelExpanded } =\n\t\t\t\t\t\tcontext.core.search;\n\t\t\t\t\treturn context.core.search.isSearchInputVisible\n\t\t\t\t\t\t? ariaLabelExpanded\n\t\t\t\t\t\t: ariaLabelCollapsed;\n\t\t\t\t},\n\t\t\t\tariaControls: ( { context } ) => {\n\t\t\t\t\treturn context.core.search.isSearchInputVisible\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: context.core.search.inputId;\n\t\t\t\t},\n\t\t\t\ttype: ( { context } ) => {\n\t\t\t\t\treturn context.core.search.isSearchInputVisible\n\t\t\t\t\t\t? 'submit'\n\t\t\t\t\t\t: 'button';\n\t\t\t\t},\n\t\t\t\ttabindex: ( { context } ) => {\n\t\t\t\t\treturn context.core.search.isSearchInputVisible\n\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t: '-1';\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tsearch: {\n\t\t\t\topenSearchInput: ( { context, event, ref } ) => {\n\t\t\t\t\tif ( ! context.core.search.isSearchInputVisible ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tcontext.core.search.isSearchInputVisible = true;\n\t\t\t\t\t\tref.parentElement.querySelector( 'input' ).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcloseSearchInput: ( { context } ) => {\n\t\t\t\t\tcontext.core.search.isSearchInputVisible = false;\n\t\t\t\t},\n\t\t\t\thandleSearchKeydown: ( store ) => {\n\t\t\t\t\tconst { actions, event, ref } = store;\n\t\t\t\t\t// If Escape close the menu.\n\t\t\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\t\t\tactions.core.search.closeSearchInput( store );\n\t\t\t\t\t\tref.querySelector( 'button' ).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleSearchFocusout: ( store ) => {\n\t\t\t\t\tconst { actions, event, ref } = store;\n\t\t\t\t\t// If focus is outside search form, and in the document, close menu\n\t\t\t\t\t// event.target === The element losing focus\n\t\t\t\t\t// event.relatedTarget === The element receiving focus (if any)\n\t\t\t\t\t// When focusout is outside the document,\n\t\t\t\t\t// `window.document.activeElement` doesn't change.\n\t\t\t\t\tif (\n\t\t\t\t\t\t! ref.contains( event.relatedTarget ) &&\n\t\t\t\t\t\tevent.target !== window.document.activeElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tactions.core.search.closeSearchInput( store );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":";;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,IAAAC,oBAAO,EAAE;EACRC,SAAS,EAAE;IACVC,IAAI,EAAE;MACLC,MAAM,EAAE;QACPC,SAAS,EAAEA,CAAE;UAAEC;QAAQ,CAAC,KAAM;UAC7B,MAAM;YAAEC,kBAAkB;YAAEC;UAAkB,CAAC,GAC9CF,OAAO,CAACH,IAAI,CAACC,MAAM;UACpB,OAAOE,OAAO,CAACH,IAAI,CAACC,MAAM,CAACK,oBAAoB,GAC5CD,iBAAiB,GACjBD,kBAAkB;QACtB,CAAC;QACDG,YAAY,EAAEA,CAAE;UAAEJ;QAAQ,CAAC,KAAM;UAChC,OAAOA,OAAO,CAACH,IAAI,CAACC,MAAM,CAACK,oBAAoB,GAC5C,IAAI,GACJH,OAAO,CAACH,IAAI,CAACC,MAAM,CAACO,OAAO;QAC/B,CAAC;QACDC,IAAI,EAAEA,CAAE;UAAEN;QAAQ,CAAC,KAAM;UACxB,OAAOA,OAAO,CAACH,IAAI,CAACC,MAAM,CAACK,oB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KAAK,CAACY,aAAc,CAAC,IACrCZ,KAAK,CAACa,MAAM,KAAKC,MAAM,CAACC,QAAQ,CAACC,aAAa,EAC7C;YACDlB,OAAO,CAACX,IAAI,CAACC,MAAM,CAACkB,gBAAgB,CAAEE,KAAM,CAAC;UAC9C;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
@@ -130,7 +130,9 @@ const SocialLinkEdit = ({
130
130
  (0, _i18n.__)('%s has URL set'), socialLinkName) : (0, _i18n.sprintf)(
131
131
  // translators: %s: social link name e.g: "Instagram".
132
132
  (0, _i18n.__)('%s has no URL set'), socialLinkName);
133
- return (0, _element.createElement)(_reactNative.View, null, isSelected && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockControls, null, (0, _element.createElement)(_components.ToolbarGroup, null, (0, _element.createElement)(_components.ToolbarButton, {
133
+ return (0, _element.createElement)(_reactNative.View, {
134
+ style: _editor.default.container
135
+ }, isSelected && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockControls, null, (0, _element.createElement)(_components.ToolbarGroup, null, (0, _element.createElement)(_components.ToolbarButton, {
134
136
  title: (0, _i18n.sprintf)(
135
137
  // translators: %s: social link name e.g: "Instagram".
136
138
  (0, _i18n.__)('Add link to %s'), socialLinkName),
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_reactNative","_blockEditor","_components","_compose","_i18n","_icons","_data","_socialList","_editor","_interopRequireDefault","DEFAULT_ACTIVE_ICON_STYLES","backgroundColor","color","DEFAULT_INACTIVE_ICON_STYLES","ANIMATION_DELAY","ANIMATION_DURATION","linkSettingsOptions","url","label","__","placeholder","autoFocus","linkLabel","footer","SocialLinkEdit","attributes","setAttributes","isSelected","onFocus","name","service","isLinkSheetVisible","setIsLinkSheetVisible","useState","hasUrl","setHasUrl","activeIcon","styles","inactiveIcon","usePreferredColorSchemeStyle","inactiveIconDark","animatedValue","useRef","Animated","Value","current","IconComponent","getIconBySite","socialLinkName","getNameBySite","useEffect","setValue","animateColors","interpolationColors","interpolate","inputRange","outputRange","stroke","sequence","delay","timing","toValue","duration","easing","Easing","circle","useNativeDriver","start","onCloseSettingsSheet","useCallback","onOpenSettingsSheet","onEmptyURL","onIconPress","accessibilityHint","sprintf","createElement","View","Fragment","BlockControls","ToolbarGroup","ToolbarButton","title","icon","link","onClick","isActive","LinkSettingsNavigation","isVisible","rel","onClose","options","withBottomSheet","TouchableWithoutFeedback","onPress","accessibilityRole","accessibilityLabel","style","iconContainer","Icon","animated","_default","compose","withSelect","select","clientId","getBlock","blockEditorStore","block","substring","exports","default"],"sources":["@wordpress/block-library/src/social-link/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Animated, Easing, TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect, useState, useRef, useCallback } from '@wordpress/element';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n} from '@wordpress/components';\nimport { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { link, Icon } from '@wordpress/icons';\nimport { withSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { getIconBySite, getNameBySite } from './social-list';\nimport styles from './editor.scss';\n\nconst DEFAULT_ACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#f0f0f0',\n\tcolor: '#444',\n};\nconst DEFAULT_INACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#0000003f',\n\tcolor: '#fff',\n};\nconst ANIMATION_DELAY = 300;\nconst ANIMATION_DURATION = 400;\n\nconst linkSettingsOptions = {\n\turl: {\n\t\tlabel: __( 'URL' ),\n\t\tplaceholder: __( 'Add URL' ),\n\t\tautoFocus: true,\n\t},\n\tlinkLabel: {\n\t\tlabel: __( 'Link label' ),\n\t\tplaceholder: __( 'None' ),\n\t},\n\tfooter: {\n\t\tlabel: __( 'Briefly describe the link to help screen reader user' ),\n\t},\n};\n\nconst SocialLinkEdit = ( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tonFocus,\n\tname,\n} ) => {\n\tconst { url, service = name } = attributes;\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ hasUrl, setHasUrl ] = useState( !! url );\n\tconst activeIcon =\n\t\tstyles[ `wp-social-link-${ service }` ] ||\n\t\tstyles[ `wp-social-link` ] ||\n\t\tDEFAULT_ACTIVE_ICON_STYLES;\n\tconst inactiveIcon =\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.inactiveIcon,\n\t\t\tstyles.inactiveIconDark\n\t\t) || DEFAULT_INACTIVE_ICON_STYLES;\n\n\tconst animatedValue = useRef( new Animated.Value( 0 ) ).current;\n\n\tconst IconComponent = getIconBySite( service )();\n\tconst socialLinkName = getNameBySite( service );\n\n\t// When new social icon is added link sheet is opened automatically.\n\tuseEffect( () => {\n\t\tif ( isSelected && ! url ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! url ) {\n\t\t\tsetHasUrl( false );\n\t\t\tanimatedValue.setValue( 0 );\n\t\t} else if ( url ) {\n\t\t\tanimateColors();\n\t\t}\n\t}, [ url ] );\n\n\tconst interpolationColors = {\n\t\tbackgroundColor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [\n\t\t\t\tinactiveIcon.backgroundColor,\n\t\t\t\tactiveIcon.backgroundColor,\n\t\t\t],\n\t\t} ),\n\t\tcolor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [ inactiveIcon.color, activeIcon.color ],\n\t\t} ),\n\t\tstroke: '',\n\t};\n\n\tconst { backgroundColor, color, stroke } = hasUrl\n\t\t? activeIcon\n\t\t: interpolationColors;\n\n\tfunction animateColors() {\n\t\tAnimated.sequence( [\n\t\t\tAnimated.delay( ANIMATION_DELAY ),\n\t\t\tAnimated.timing( animatedValue, {\n\t\t\t\ttoValue: 1,\n\t\t\t\tduration: ANIMATION_DURATION,\n\t\t\t\teasing: Easing.circle,\n\t\t\t\tuseNativeDriver: false,\n\t\t\t} ),\n\t\t] ).start( () => setHasUrl( true ) );\n\t}\n\n\tconst onCloseSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( false );\n\t}, [] );\n\n\tconst onOpenSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( true );\n\t}, [] );\n\n\tconst onEmptyURL = useCallback( () => {\n\t\tanimatedValue.setValue( 0 );\n\t\tsetHasUrl( false );\n\t}, [ animatedValue ] );\n\n\tfunction onIconPress() {\n\t\tif ( isSelected ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t}\n\n\tconst accessibilityHint = url\n\t\t? sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has URL set' ),\n\t\t\t\tsocialLinkName\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has no URL set' ),\n\t\t\t\tsocialLinkName\n\t\t );\n\n\treturn (\n\t\t<View>\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t\t\t\t\t__( 'Add link to %s' ),\n\t\t\t\t\t\t\t\t\tsocialLinkName\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onOpenSettingsSheet }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<LinkSettingsNavigation\n\t\t\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\t\t\turl={ attributes.url }\n\t\t\t\t\t\tlabel={ attributes.label }\n\t\t\t\t\t\trel={ attributes.rel }\n\t\t\t\t\t\tonEmptyURL={ onEmptyURL }\n\t\t\t\t\t\tonClose={ onCloseSettingsSheet }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\toptions={ linkSettingsOptions }\n\t\t\t\t\t\twithBottomSheet\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tonPress={ onIconPress }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t__( '%s social icon' ),\n\t\t\t\t\tsocialLinkName\n\t\t\t\t) }\n\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t>\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={ [ styles.iconContainer, { backgroundColor } ] }\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tanimated\n\t\t\t\t\t\ticon={ IconComponent }\n\t\t\t\t\t\tstyle={ { stroke, color } }\n\t\t\t\t\t/>\n\t\t\t\t</Animated.View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t</View>\n\t);\n};\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\n\t\tconst block = getBlock( clientId );\n\t\tconst name = block?.name.substring( 17 );\n\n\t\treturn {\n\t\t\tname,\n\t\t};\n\t} ),\n] )( SocialLinkEdit );\n"],"mappings":";;;;;;;AAYA,IAAAA,QAAA,GAAAC,OAAA;AATA,IAAAC,YAAA,GAAAD,OAAA;AAKA,IAAAE,YAAA,GAAAF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AArB,aAAO;IAC3B;IACA,IAAAvD,QAAE,EAAE,gBAAiB,CAAC,EACtB6B,cACD,CAAG;IACHyB,iBAAiB,EAAGA;EAAmB,GAEvC,IAAA3E,QAAA,CAAA6E,aAAA,EAAC3E,YAAA,CAAA2C,QAAQ,CAACiC,IAAI;IACboB,KAAK,EAAG,CAAE3D,eAAM,CAAC4D,aAAa,EAAE;MAAEtF;IAAgB,CAAC;EAAI,GAEvD,IAAAb,QAAA,CAAA6E,aAAA,EAACtE,MAAA,CAAA6F,IAAI;IACJC,QAAQ;IACRjB,IAAI,EAAGpC,aAAe;IACtBkD,KAAK,EAAG;MAAEvC,MAAM;MAAE7C;IAAM;EAAG,CAC3B,CACa,CACU,CACrB,CAAC;AAET,CAAC;AAAC,IAAAwF,QAAA,GAEa,IAAAC,gBAAO,EAAE,CACvB,IAAAC,gBAAU,EAAE,CAAEC,MAAM,EAAE;EAAEC;AAAS,CAAC,KAAM;EACvC,MAAM;IAAEC;EAAS,CAAC,GAAGF,MAAM,CAAEG,kBAAiB,CAAC;EAE/C,MAAMC,KAAK,GAAGF,QAAQ,CAAED,QAAS,CAAC;EAClC,MAAM3E,IAAI,GAAG8E,KAAK,EAAE9E,IAAI,CAAC+E,SAAS,CAAE,EAAG,CAAC;EAExC,OAAO;IACN/E;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAEL,cAAe,CAAC;AAAAqF,OAAA,CAAAC,OAAA,GAAAV,QAAA"}
1
+ {"version":3,"names":["_element","require","_reactNative","_blockEditor","_components","_compose","_i18n","_icons","_data","_socialList","_editor","_interopRequireDefault","DEFAULT_ACTIVE_ICON_STYLES","backgroundColor","color","DEFAULT_INACTIVE_ICON_STYLES","ANIMATION_DELAY","ANIMATION_DURATION","linkSettingsOptions","url","label","__","placeholder","autoFocus","linkLabel","footer","SocialLinkEdit","attributes","setAttributes","isSelected","onFocus","name","service","isLinkSheetVisible","setIsLinkSheetVisible","useState","hasUrl","setHasUrl","activeIcon","styles","inactiveIcon","usePreferredColorSchemeStyle","inactiveIconDark","animatedValue","useRef","Animated","Value","current","IconComponent","getIconBySite","socialLinkName","getNameBySite","useEffect","setValue","animateColors","interpolationColors","interpolate","inputRange","outputRange","stroke","sequence","delay","timing","toValue","duration","easing","Easing","circle","useNativeDriver","start","onCloseSettingsSheet","useCallback","onOpenSettingsSheet","onEmptyURL","onIconPress","accessibilityHint","sprintf","createElement","View","style","container","Fragment","BlockControls","ToolbarGroup","ToolbarButton","title","icon","link","onClick","isActive","LinkSettingsNavigation","isVisible","rel","onClose","options","withBottomSheet","TouchableWithoutFeedback","onPress","accessibilityRole","accessibilityLabel","iconContainer","Icon","animated","_default","compose","withSelect","select","clientId","getBlock","blockEditorStore","block","substring","exports","default"],"sources":["@wordpress/block-library/src/social-link/edit.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Animated, Easing, TouchableWithoutFeedback } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect, useState, useRef, useCallback } from '@wordpress/element';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tLinkSettingsNavigation,\n} from '@wordpress/components';\nimport { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { link, Icon } from '@wordpress/icons';\nimport { withSelect } from '@wordpress/data';\n/**\n * Internal dependencies\n */\nimport { getIconBySite, getNameBySite } from './social-list';\nimport styles from './editor.scss';\n\nconst DEFAULT_ACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#f0f0f0',\n\tcolor: '#444',\n};\nconst DEFAULT_INACTIVE_ICON_STYLES = {\n\tbackgroundColor: '#0000003f',\n\tcolor: '#fff',\n};\nconst ANIMATION_DELAY = 300;\nconst ANIMATION_DURATION = 400;\n\nconst linkSettingsOptions = {\n\turl: {\n\t\tlabel: __( 'URL' ),\n\t\tplaceholder: __( 'Add URL' ),\n\t\tautoFocus: true,\n\t},\n\tlinkLabel: {\n\t\tlabel: __( 'Link label' ),\n\t\tplaceholder: __( 'None' ),\n\t},\n\tfooter: {\n\t\tlabel: __( 'Briefly describe the link to help screen reader user' ),\n\t},\n};\n\nconst SocialLinkEdit = ( {\n\tattributes,\n\tsetAttributes,\n\tisSelected,\n\tonFocus,\n\tname,\n} ) => {\n\tconst { url, service = name } = attributes;\n\tconst [ isLinkSheetVisible, setIsLinkSheetVisible ] = useState( false );\n\tconst [ hasUrl, setHasUrl ] = useState( !! url );\n\tconst activeIcon =\n\t\tstyles[ `wp-social-link-${ service }` ] ||\n\t\tstyles[ `wp-social-link` ] ||\n\t\tDEFAULT_ACTIVE_ICON_STYLES;\n\tconst inactiveIcon =\n\t\tusePreferredColorSchemeStyle(\n\t\t\tstyles.inactiveIcon,\n\t\t\tstyles.inactiveIconDark\n\t\t) || DEFAULT_INACTIVE_ICON_STYLES;\n\n\tconst animatedValue = useRef( new Animated.Value( 0 ) ).current;\n\n\tconst IconComponent = getIconBySite( service )();\n\tconst socialLinkName = getNameBySite( service );\n\n\t// When new social icon is added link sheet is opened automatically.\n\tuseEffect( () => {\n\t\tif ( isSelected && ! url ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( ! url ) {\n\t\t\tsetHasUrl( false );\n\t\t\tanimatedValue.setValue( 0 );\n\t\t} else if ( url ) {\n\t\t\tanimateColors();\n\t\t}\n\t}, [ url ] );\n\n\tconst interpolationColors = {\n\t\tbackgroundColor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [\n\t\t\t\tinactiveIcon.backgroundColor,\n\t\t\t\tactiveIcon.backgroundColor,\n\t\t\t],\n\t\t} ),\n\t\tcolor: animatedValue.interpolate( {\n\t\t\tinputRange: [ 0, 1 ],\n\t\t\toutputRange: [ inactiveIcon.color, activeIcon.color ],\n\t\t} ),\n\t\tstroke: '',\n\t};\n\n\tconst { backgroundColor, color, stroke } = hasUrl\n\t\t? activeIcon\n\t\t: interpolationColors;\n\n\tfunction animateColors() {\n\t\tAnimated.sequence( [\n\t\t\tAnimated.delay( ANIMATION_DELAY ),\n\t\t\tAnimated.timing( animatedValue, {\n\t\t\t\ttoValue: 1,\n\t\t\t\tduration: ANIMATION_DURATION,\n\t\t\t\teasing: Easing.circle,\n\t\t\t\tuseNativeDriver: false,\n\t\t\t} ),\n\t\t] ).start( () => setHasUrl( true ) );\n\t}\n\n\tconst onCloseSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( false );\n\t}, [] );\n\n\tconst onOpenSettingsSheet = useCallback( () => {\n\t\tsetIsLinkSheetVisible( true );\n\t}, [] );\n\n\tconst onEmptyURL = useCallback( () => {\n\t\tanimatedValue.setValue( 0 );\n\t\tsetHasUrl( false );\n\t}, [ animatedValue ] );\n\n\tfunction onIconPress() {\n\t\tif ( isSelected ) {\n\t\t\tsetIsLinkSheetVisible( true );\n\t\t} else {\n\t\t\tonFocus();\n\t\t}\n\t}\n\n\tconst accessibilityHint = url\n\t\t? sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has URL set' ),\n\t\t\t\tsocialLinkName\n\t\t )\n\t\t: sprintf(\n\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t__( '%s has no URL set' ),\n\t\t\t\tsocialLinkName\n\t\t );\n\n\treturn (\n\t\t<View style={ styles.container }>\n\t\t\t{ isSelected && (\n\t\t\t\t<>\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t\t\t\t\t__( 'Add link to %s' ),\n\t\t\t\t\t\t\t\t\tsocialLinkName\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ticon={ link }\n\t\t\t\t\t\t\t\tonClick={ onOpenSettingsSheet }\n\t\t\t\t\t\t\t\tisActive={ url }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t\t<LinkSettingsNavigation\n\t\t\t\t\t\tisVisible={ isLinkSheetVisible }\n\t\t\t\t\t\turl={ attributes.url }\n\t\t\t\t\t\tlabel={ attributes.label }\n\t\t\t\t\t\trel={ attributes.rel }\n\t\t\t\t\t\tonEmptyURL={ onEmptyURL }\n\t\t\t\t\t\tonClose={ onCloseSettingsSheet }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\toptions={ linkSettingsOptions }\n\t\t\t\t\t\twithBottomSheet\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t<TouchableWithoutFeedback\n\t\t\t\tonPress={ onIconPress }\n\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t// translators: %s: social link name e.g: \"Instagram\".\n\t\t\t\t\t__( '%s social icon' ),\n\t\t\t\t\tsocialLinkName\n\t\t\t\t) }\n\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t>\n\t\t\t\t<Animated.View\n\t\t\t\t\tstyle={ [ styles.iconContainer, { backgroundColor } ] }\n\t\t\t\t>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tanimated\n\t\t\t\t\t\ticon={ IconComponent }\n\t\t\t\t\t\tstyle={ { stroke, color } }\n\t\t\t\t\t/>\n\t\t\t\t</Animated.View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t</View>\n\t);\n};\n\nexport default compose( [\n\twithSelect( ( select, { clientId } ) => {\n\t\tconst { getBlock } = select( blockEditorStore );\n\n\t\tconst block = getBlock( clientId );\n\t\tconst name = block?.name.substring( 17 );\n\n\t\treturn {\n\t\t\tname,\n\t\t};\n\t} ),\n] )( SocialLinkEdit );\n"],"m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