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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) 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/post-comments-form/edit.js +10 -2
  76. package/build/post-comments-form/edit.js.map +1 -1
  77. package/build/post-comments-form/form.js +5 -3
  78. package/build/post-comments-form/form.js.map +1 -1
  79. package/build/post-content/edit.js +8 -7
  80. package/build/post-content/edit.js.map +1 -1
  81. package/build/post-content/index.js +3 -0
  82. package/build/post-content/index.js.map +1 -1
  83. package/build/post-featured-image/overlay.js +2 -1
  84. package/build/post-featured-image/overlay.js.map +1 -1
  85. package/build/preformatted/edit.js +4 -1
  86. package/build/preformatted/edit.js.map +1 -1
  87. package/build/preformatted/index.js +1 -1
  88. package/build/preformatted/index.js.map +1 -1
  89. package/build/pullquote/deprecated.js +6 -7
  90. package/build/pullquote/deprecated.js.map +1 -1
  91. package/build/query/edit/enhanced-pagination-modal.js +56 -0
  92. package/build/query/edit/enhanced-pagination-modal.js.map +1 -0
  93. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +42 -0
  94. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
  95. package/build/query/edit/inspector-controls/index.js +8 -25
  96. package/build/query/edit/inspector-controls/index.js.map +1 -1
  97. package/build/query/edit/query-content.js +8 -2
  98. package/build/query/edit/query-content.js.map +1 -1
  99. package/build/query/utils.js +19 -0
  100. package/build/query/utils.js.map +1 -1
  101. package/build/query/view.js +4 -5
  102. package/build/query/view.js.map +1 -1
  103. package/build/search/index.js +1 -0
  104. package/build/search/index.js.map +1 -1
  105. package/build/search/view.js +81 -150
  106. package/build/search/view.js.map +1 -1
  107. package/build/social-link/edit.native.js +3 -1
  108. package/build/social-link/edit.native.js.map +1 -1
  109. package/build/table/edit.js +7 -7
  110. package/build/table/edit.js.map +1 -1
  111. package/build/table-of-contents/edit.js +2 -130
  112. package/build/table-of-contents/edit.js.map +1 -1
  113. package/build/table-of-contents/hooks.js +145 -0
  114. package/build/table-of-contents/hooks.js.map +1 -0
  115. package/build/table-of-contents/index.js +2 -1
  116. package/build/table-of-contents/index.js.map +1 -1
  117. package/build/verse/edit.js +4 -1
  118. package/build/verse/edit.js.map +1 -1
  119. package/build/verse/index.js +1 -1
  120. package/build/verse/index.js.map +1 -1
  121. package/build-module/block/edit.js +54 -3
  122. package/build-module/block/edit.js.map +1 -1
  123. package/build-module/button/edit.js +7 -4
  124. package/build-module/button/edit.js.map +1 -1
  125. package/build-module/button/index.js +11 -2
  126. package/build-module/button/index.js.map +1 -1
  127. package/build-module/button/save.js +10 -4
  128. package/build-module/button/save.js.map +1 -1
  129. package/build-module/buttons/edit.js +12 -3
  130. package/build-module/buttons/edit.js.map +1 -1
  131. package/build-module/code/edit.js +8 -2
  132. package/build-module/code/edit.js.map +1 -1
  133. package/build-module/code/index.js +7 -1
  134. package/build-module/code/index.js.map +1 -1
  135. package/build-module/column/index.js +1 -0
  136. package/build-module/column/index.js.map +1 -1
  137. package/build-module/columns/index.js +2 -0
  138. package/build-module/columns/index.js.map +1 -1
  139. package/build-module/file/edit.native.js +1 -1
  140. package/build-module/file/edit.native.js.map +1 -1
  141. package/build-module/file/index.js +2 -1
  142. package/build-module/file/index.js.map +1 -1
  143. package/build-module/file/utils/index.js +0 -13
  144. package/build-module/file/utils/index.js.map +1 -1
  145. package/build-module/file/view.js +14 -2
  146. package/build-module/file/view.js.map +1 -1
  147. package/build-module/footnotes/edit.js +12 -2
  148. package/build-module/footnotes/edit.js.map +1 -1
  149. package/build-module/gallery/edit.js +1 -1
  150. package/build-module/gallery/edit.js.map +1 -1
  151. package/build-module/group/edit.js +0 -1
  152. package/build-module/group/edit.js.map +1 -1
  153. package/build-module/group/index.js +4 -0
  154. package/build-module/group/index.js.map +1 -1
  155. package/build-module/heading/edit.js +0 -1
  156. package/build-module/heading/edit.js.map +1 -1
  157. package/build-module/heading/index.js +2 -0
  158. package/build-module/heading/index.js.map +1 -1
  159. package/build-module/heading/transforms.js +3 -6
  160. package/build-module/heading/transforms.js.map +1 -1
  161. package/build-module/image/deprecated.js +191 -7
  162. package/build-module/image/deprecated.js.map +1 -1
  163. package/build-module/image/edit.js +27 -12
  164. package/build-module/image/edit.js.map +1 -1
  165. package/build-module/image/image.js +77 -42
  166. package/build-module/image/image.js.map +1 -1
  167. package/build-module/image/index.js +7 -4
  168. package/build-module/image/index.js.map +1 -1
  169. package/build-module/image/{view-interactivity.js → view.js} +1 -1
  170. package/build-module/image/view.js.map +1 -0
  171. package/build-module/list/deprecated.js +95 -3
  172. package/build-module/list/deprecated.js.map +1 -1
  173. package/build-module/list/edit.js +10 -10
  174. package/build-module/list/edit.js.map +1 -1
  175. package/build-module/list/ordered-list-settings.js +10 -10
  176. package/build-module/list/ordered-list-settings.js.map +1 -1
  177. package/build-module/list/save.js +4 -2
  178. package/build-module/list/save.js.map +1 -1
  179. package/build-module/list/utils.js +20 -2
  180. package/build-module/list/utils.js.map +1 -1
  181. package/build-module/navigation/constants.js +1 -1
  182. package/build-module/navigation/constants.js.map +1 -1
  183. package/build-module/navigation/index.js +4 -2
  184. package/build-module/navigation/index.js.map +1 -1
  185. package/build-module/navigation/view.js +168 -83
  186. package/build-module/navigation/view.js.map +1 -1
  187. package/build-module/navigation-link/edit.js +3 -9
  188. package/build-module/navigation-link/edit.js.map +1 -1
  189. package/build-module/navigation-link/transforms.js +24 -0
  190. package/build-module/navigation-link/transforms.js.map +1 -1
  191. package/build-module/page-list/edit.js +2 -1
  192. package/build-module/page-list/edit.js.map +1 -1
  193. package/build-module/post-comments-form/edit.js +10 -2
  194. package/build-module/post-comments-form/edit.js.map +1 -1
  195. package/build-module/post-comments-form/form.js +5 -3
  196. package/build-module/post-comments-form/form.js.map +1 -1
  197. package/build-module/post-content/edit.js +8 -7
  198. package/build-module/post-content/edit.js.map +1 -1
  199. package/build-module/post-content/index.js +3 -0
  200. package/build-module/post-content/index.js.map +1 -1
  201. package/build-module/post-featured-image/overlay.js +2 -1
  202. package/build-module/post-featured-image/overlay.js.map +1 -1
  203. package/build-module/preformatted/edit.js +4 -1
  204. package/build-module/preformatted/edit.js.map +1 -1
  205. package/build-module/preformatted/index.js +1 -1
  206. package/build-module/preformatted/index.js.map +1 -1
  207. package/build-module/pullquote/deprecated.js +6 -7
  208. package/build-module/pullquote/deprecated.js.map +1 -1
  209. package/build-module/query/edit/enhanced-pagination-modal.js +50 -0
  210. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -0
  211. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +35 -0
  212. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
  213. package/build-module/query/edit/inspector-controls/index.js +9 -26
  214. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  215. package/build-module/query/edit/query-content.js +8 -2
  216. package/build-module/query/edit/query-content.js.map +1 -1
  217. package/build-module/query/utils.js +17 -0
  218. package/build-module/query/utils.js.map +1 -1
  219. package/build-module/query/view.js +4 -5
  220. package/build-module/query/view.js.map +1 -1
  221. package/build-module/search/index.js +1 -0
  222. package/build-module/search/index.js.map +1 -1
  223. package/build-module/search/view.js +81 -151
  224. package/build-module/search/view.js.map +1 -1
  225. package/build-module/social-link/edit.native.js +3 -1
  226. package/build-module/social-link/edit.native.js.map +1 -1
  227. package/build-module/table/edit.js +7 -7
  228. package/build-module/table/edit.js.map +1 -1
  229. package/build-module/table-of-contents/edit.js +3 -131
  230. package/build-module/table-of-contents/edit.js.map +1 -1
  231. package/build-module/table-of-contents/hooks.js +137 -0
  232. package/build-module/table-of-contents/hooks.js.map +1 -0
  233. package/build-module/table-of-contents/index.js +2 -1
  234. package/build-module/table-of-contents/index.js.map +1 -1
  235. package/build-module/verse/edit.js +4 -1
  236. package/build-module/verse/edit.js.map +1 -1
  237. package/build-module/verse/index.js +1 -1
  238. package/build-module/verse/index.js.map +1 -1
  239. package/build-style/cover/style-rtl.css +9 -0
  240. package/build-style/cover/style.css +9 -0
  241. package/build-style/editor-rtl.css +15 -9
  242. package/build-style/editor.css +15 -9
  243. package/build-style/file/style-rtl.css +5 -0
  244. package/build-style/file/style.css +5 -0
  245. package/build-style/heading/style-rtl.css +13 -0
  246. package/build-style/heading/style.css +13 -0
  247. package/build-style/navigation-link/editor-rtl.css +0 -9
  248. package/build-style/navigation-link/editor.css +0 -9
  249. package/build-style/paragraph/editor-rtl.css +5 -0
  250. package/build-style/paragraph/editor.css +5 -0
  251. package/build-style/paragraph/style-rtl.css +5 -0
  252. package/build-style/paragraph/style.css +5 -0
  253. package/build-style/post-navigation-link/style-rtl.css +3 -0
  254. package/build-style/post-navigation-link/style.css +3 -0
  255. package/build-style/query/editor-rtl.css +10 -0
  256. package/build-style/query/editor.css +10 -0
  257. package/build-style/query/style-rtl.css +1 -1
  258. package/build-style/query/style.css +1 -1
  259. package/build-style/reset-rtl.css +27 -27
  260. package/build-style/reset.css +27 -27
  261. package/build-style/style-rtl.css +35 -0
  262. package/build-style/style.css +35 -0
  263. package/package.json +32 -33
  264. package/src/audio/test/__snapshots__/edit.native.js.snap +78 -106
  265. package/src/avatar/index.php +2 -2
  266. package/src/block/edit.js +58 -2
  267. package/src/block/test/edit.native.js +2 -3
  268. package/src/button/block.json +11 -2
  269. package/src/button/edit.js +27 -11
  270. package/src/button/save.js +10 -4
  271. package/src/buttons/edit.js +13 -3
  272. package/src/buttons/test/edit.native.js +28 -24
  273. package/src/calendar/index.php +2 -2
  274. package/src/code/block.json +2 -1
  275. package/src/code/edit.js +13 -1
  276. package/src/code/index.js +5 -0
  277. package/src/column/block.json +1 -0
  278. package/src/columns/block.json +2 -0
  279. package/src/comment-template/index.php +1 -1
  280. package/src/comments-pagination-next/index.php +1 -1
  281. package/src/comments-pagination-previous/index.php +1 -1
  282. package/src/cover/style.scss +12 -1
  283. package/src/cover/test/edit.js +7 -7
  284. package/src/cover/test/edit.native.js +18 -27
  285. package/src/embed/test/index.native.js +30 -45
  286. package/src/file/block.json +2 -1
  287. package/src/file/edit.native.js +1 -1
  288. package/src/file/index.php +19 -21
  289. package/src/file/style.scss +6 -1
  290. package/src/file/test/__snapshots__/edit.native.js.snap +162 -218
  291. package/src/file/utils/index.js +0 -15
  292. package/src/file/view.js +14 -5
  293. package/src/footnotes/edit.js +13 -1
  294. package/src/gallery/edit.js +1 -1
  295. package/src/gallery/index.php +1 -1
  296. package/src/group/block.json +4 -0
  297. package/src/group/edit.js +0 -1
  298. package/src/heading/block.json +2 -0
  299. package/src/heading/edit.js +0 -1
  300. package/src/heading/style.scss +4 -0
  301. package/src/heading/transforms.js +1 -6
  302. package/src/image/block.json +7 -4
  303. package/src/image/deprecated.js +210 -7
  304. package/src/image/edit.js +43 -29
  305. package/src/image/image.js +86 -43
  306. package/src/image/index.php +251 -28
  307. package/src/latest-posts/index.php +1 -1
  308. package/src/list/deprecated.js +84 -3
  309. package/src/list/edit.js +6 -3
  310. package/src/list/ordered-list-settings.js +20 -5
  311. package/src/list/save.js +10 -1
  312. package/src/list/test/edit.native.js +2 -4
  313. package/src/list/utils.js +22 -1
  314. package/src/navigation/block.json +4 -2
  315. package/src/navigation/constants.js +1 -0
  316. package/src/navigation/index.php +85 -123
  317. package/src/navigation/view.js +192 -96
  318. package/src/navigation-link/edit.js +21 -36
  319. package/src/navigation-link/editor.scss +0 -8
  320. package/src/navigation-link/transforms.js +22 -0
  321. package/src/page-list/edit.js +2 -1
  322. package/src/paragraph/editor.scss +5 -0
  323. package/src/paragraph/style.scss +5 -0
  324. package/src/pattern/index.php +2 -2
  325. package/src/post-comments-form/edit.js +10 -0
  326. package/src/post-comments-form/form.js +7 -1
  327. package/src/post-content/block.json +3 -0
  328. package/src/post-content/edit.js +14 -6
  329. package/src/post-excerpt/index.php +2 -2
  330. package/src/post-featured-image/index.php +2 -2
  331. package/src/post-featured-image/overlay.js +1 -0
  332. package/src/post-navigation-link/index.php +0 -5
  333. package/src/post-navigation-link/style.scss +4 -0
  334. package/src/post-template/index.php +1 -1
  335. package/src/post-terms/index.php +5 -2
  336. package/src/preformatted/edit.js +5 -0
  337. package/src/preformatted/index.js +1 -1
  338. package/src/pullquote/deprecated.js +8 -13
  339. package/src/query/edit/enhanced-pagination-modal.js +65 -0
  340. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +49 -0
  341. package/src/query/edit/inspector-controls/index.js +9 -45
  342. package/src/query/edit/query-content.js +8 -0
  343. package/src/query/editor.scss +10 -0
  344. package/src/query/index.php +29 -16
  345. package/src/query/style.scss +2 -2
  346. package/src/query/utils.js +22 -0
  347. package/src/query/view.js +5 -5
  348. package/src/query-pagination-next/index.php +1 -1
  349. package/src/query-pagination-previous/index.php +1 -1
  350. package/src/reset.scss +1 -1
  351. package/src/search/block.json +1 -0
  352. package/src/search/index.php +45 -4
  353. package/src/search/test/__snapshots__/edit.native.js.snap +265 -363
  354. package/src/search/view.js +70 -169
  355. package/src/social-link/edit.native.js +1 -1
  356. package/src/social-link/editor.native.scss +4 -0
  357. package/src/table/edit.js +21 -19
  358. package/src/table-of-contents/block.json +2 -1
  359. package/src/table-of-contents/edit.js +5 -162
  360. package/src/table-of-contents/hooks.js +156 -0
  361. package/src/verse/edit.js +5 -0
  362. package/src/verse/index.js +1 -1
  363. package/src/verse/test/edit.native.js +2 -3
  364. package/build/file/view-interactivity.js +0 -22
  365. package/build/file/view-interactivity.js.map +0 -1
  366. package/build/image/view-interactivity.js.map +0 -1
  367. package/build/navigation/view-interactivity.js +0 -172
  368. package/build/navigation/view-interactivity.js.map +0 -1
  369. package/build/navigation/view-modal.js +0 -115
  370. package/build/navigation/view-modal.js.map +0 -1
  371. package/build-module/file/view-interactivity.js +0 -18
  372. package/build-module/file/view-interactivity.js.map +0 -1
  373. package/build-module/image/view-interactivity.js.map +0 -1
  374. package/build-module/navigation/view-interactivity.js +0 -169
  375. package/build-module/navigation/view-interactivity.js.map +0 -1
  376. package/build-module/navigation/view-modal.js +0 -112
  377. package/build-module/navigation/view-modal.js.map +0 -1
  378. package/src/file/view-interactivity.js +0 -18
  379. package/src/navigation/view-interactivity.js +0 -196
  380. package/src/navigation/view-modal.js +0 -127
  381. /package/src/image/{view-interactivity.js → view.js} +0 -0
@@ -1,169 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store as wpStore } from '@wordpress/interactivity';
5
- const focusableSelectors = ['a[href]', 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', 'select:not([disabled]):not([aria-hidden])', 'textarea:not([disabled]):not([aria-hidden])', 'button:not([disabled]):not([aria-hidden])', '[contenteditable]', '[tabindex]:not([tabindex^="-"])'];
6
- const openMenu = (store, menuOpenedOn) => {
7
- const {
8
- context,
9
- ref,
10
- selectors
11
- } = store;
12
- selectors.core.navigation.menuOpenedBy(store)[menuOpenedOn] = true;
13
- context.core.navigation.previousFocus = ref;
14
- if (context.core.navigation.type === 'overlay') {
15
- // Add a `has-modal-open` class to the <html> root.
16
- document.documentElement.classList.add('has-modal-open');
17
- }
18
- };
19
- const closeMenu = (store, menuClosedOn) => {
20
- const {
21
- context,
22
- selectors
23
- } = store;
24
- selectors.core.navigation.menuOpenedBy(store)[menuClosedOn] = false;
25
- // Check if the menu is still open or not.
26
- if (!selectors.core.navigation.isMenuOpen(store)) {
27
- if (context.core.navigation.modal?.contains(window.document.activeElement)) {
28
- context.core.navigation.previousFocus.focus();
29
- }
30
- context.core.navigation.modal = null;
31
- context.core.navigation.previousFocus = null;
32
- if (context.core.navigation.type === 'overlay') {
33
- document.documentElement.classList.remove('has-modal-open');
34
- }
35
- }
36
- };
37
- wpStore({
38
- effects: {
39
- core: {
40
- navigation: {
41
- initMenu: store => {
42
- const {
43
- context,
44
- selectors,
45
- ref
46
- } = store;
47
- if (selectors.core.navigation.isMenuOpen(store)) {
48
- const focusableElements = ref.querySelectorAll(focusableSelectors);
49
- context.core.navigation.modal = ref;
50
- context.core.navigation.firstFocusableElement = focusableElements[0];
51
- context.core.navigation.lastFocusableElement = focusableElements[focusableElements.length - 1];
52
- }
53
- },
54
- focusFirstElement: store => {
55
- const {
56
- selectors,
57
- ref
58
- } = store;
59
- if (selectors.core.navigation.isMenuOpen(store)) {
60
- ref.querySelector('.wp-block-navigation-item > *:first-child').focus();
61
- }
62
- }
63
- }
64
- }
65
- },
66
- selectors: {
67
- core: {
68
- navigation: {
69
- roleAttribute: store => {
70
- const {
71
- context,
72
- selectors
73
- } = store;
74
- return context.core.navigation.type === 'overlay' && selectors.core.navigation.isMenuOpen(store) ? 'dialog' : '';
75
- },
76
- isMenuOpen: ({
77
- context
78
- }) =>
79
- // The menu is opened if either `click`, `hover` or `focus` is true.
80
- Object.values(context.core.navigation[context.core.navigation.type === 'overlay' ? 'overlayOpenedBy' : 'submenuOpenedBy']).filter(Boolean).length > 0,
81
- menuOpenedBy: ({
82
- context
83
- }) => context.core.navigation[context.core.navigation.type === 'overlay' ? 'overlayOpenedBy' : 'submenuOpenedBy']
84
- }
85
- }
86
- },
87
- actions: {
88
- core: {
89
- navigation: {
90
- openMenuOnHover(store) {
91
- const {
92
- navigation
93
- } = store.context.core;
94
- if (navigation.type === 'submenu' &&
95
- // Only open on hover if the overlay is closed.
96
- Object.values(navigation.overlayOpenedBy || {}).filter(Boolean).length === 0) openMenu(store, 'hover');
97
- },
98
- closeMenuOnHover(store) {
99
- closeMenu(store, 'hover');
100
- },
101
- openMenuOnClick(store) {
102
- openMenu(store, 'click');
103
- },
104
- closeMenuOnClick(store) {
105
- closeMenu(store, 'click');
106
- closeMenu(store, 'focus');
107
- },
108
- openMenuOnFocus(store) {
109
- openMenu(store, 'focus');
110
- },
111
- toggleMenuOnClick: store => {
112
- const {
113
- selectors
114
- } = store;
115
- const menuOpenedBy = selectors.core.navigation.menuOpenedBy(store);
116
- if (menuOpenedBy.click || menuOpenedBy.focus) {
117
- closeMenu(store, 'click');
118
- closeMenu(store, 'focus');
119
- } else {
120
- openMenu(store, 'click');
121
- }
122
- },
123
- handleMenuKeydown: store => {
124
- const {
125
- context,
126
- selectors,
127
- event
128
- } = store;
129
- if (selectors.core.navigation.menuOpenedBy(store).click) {
130
- // If Escape close the menu.
131
- if (event?.key === 'Escape') {
132
- closeMenu(store, 'click');
133
- closeMenu(store, 'focus');
134
- return;
135
- }
136
-
137
- // Trap focus if it is an overlay (main menu).
138
- if (context.core.navigation.type === 'overlay' && event.key === 'Tab') {
139
- // If shift + tab it change the direction.
140
- if (event.shiftKey && window.document.activeElement === context.core.navigation.firstFocusableElement) {
141
- event.preventDefault();
142
- context.core.navigation.lastFocusableElement.focus();
143
- } else if (!event.shiftKey && window.document.activeElement === context.core.navigation.lastFocusableElement) {
144
- event.preventDefault();
145
- context.core.navigation.firstFocusableElement.focus();
146
- }
147
- }
148
- }
149
- },
150
- handleMenuFocusout: store => {
151
- const {
152
- context,
153
- event
154
- } = store;
155
- // If focus is outside modal, and in the document, close menu
156
- // event.target === The element losing focus
157
- // event.relatedTarget === The element receiving focus (if any)
158
- // When focusout is outsite the document,
159
- // `window.document.activeElement` doesn't change.
160
- if (!context.core.navigation.modal?.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
161
- closeMenu(store, 'click');
162
- closeMenu(store, 'focus');
163
- }
164
- }
165
- }
166
- }
167
- }
168
- });
169
- //# sourceMappingURL=view-interactivity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["store","wpStore","focusableSelectors","openMenu","menuOpenedOn","context","ref","selectors","core","navigation","menuOpenedBy","previousFocus","type","document","documentElement","classList","add","closeMenu","menuClosedOn","isMenuOpen","modal","contains","window","activeElement","focus","remove","effects","initMenu","focusableElements","querySelectorAll","firstFocusableElement","lastFocusableElement","length","focusFirstElement","querySelector","roleAttribute","Object","values","filter","Boolean","actions","openMenuOnHover","overlayOpenedBy","closeMenuOnHover","openMenuOnClick","closeMenuOnClick","openMenuOnFocus","toggleMenuOnClick","click","handleMenuKeydown","event","key","shiftKey","preventDefault","handleMenuFocusout","relatedTarget","target"],"sources":["@wordpress/block-library/src/navigation/view-interactivity.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as wpStore } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\nconst openMenu = ( store, menuOpenedOn ) => {\n\tconst { context, ref, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuOpenedOn ] = true;\n\tcontext.core.navigation.previousFocus = ref;\n\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t// Add a `has-modal-open` class to the <html> root.\n\t\tdocument.documentElement.classList.add( 'has-modal-open' );\n\t}\n};\n\nconst closeMenu = ( store, menuClosedOn ) => {\n\tconst { context, selectors } = store;\n\tselectors.core.navigation.menuOpenedBy( store )[ menuClosedOn ] = false;\n\t// Check if the menu is still open or not.\n\tif ( ! selectors.core.navigation.isMenuOpen( store ) ) {\n\t\tif (\n\t\t\tcontext.core.navigation.modal?.contains(\n\t\t\t\twindow.document.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcontext.core.navigation.previousFocus.focus();\n\t\t}\n\t\tcontext.core.navigation.modal = null;\n\t\tcontext.core.navigation.previousFocus = null;\n\t\tif ( context.core.navigation.type === 'overlay' ) {\n\t\t\tdocument.documentElement.classList.remove( 'has-modal-open' );\n\t\t}\n\t}\n};\n\nwpStore( {\n\teffects: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\tinitMenu: ( store ) => {\n\t\t\t\t\tconst { context, selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tconst focusableElements =\n\t\t\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\t\t\tcontext.core.navigation.modal = ref;\n\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ 0 ];\n\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tfocusFirstElement: ( store ) => {\n\t\t\t\t\tconst { selectors, ref } = store;\n\t\t\t\t\tif ( selectors.core.navigation.isMenuOpen( store ) ) {\n\t\t\t\t\t\tref.querySelector(\n\t\t\t\t\t\t\t'.wp-block-navigation-item > *:first-child'\n\t\t\t\t\t\t).focus();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tselectors: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\troleAttribute: ( store ) => {\n\t\t\t\t\tconst { context, selectors } = store;\n\t\t\t\t\treturn context.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\tselectors.core.navigation.isMenuOpen( store )\n\t\t\t\t\t\t? 'dialog'\n\t\t\t\t\t\t: '';\n\t\t\t\t},\n\t\t\t\tisMenuOpen: ( { context } ) =>\n\t\t\t\t\t// The menu is opened if either `click`, `hover` or `focus` is true.\n\t\t\t\t\tObject.values(\n\t\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t\t]\n\t\t\t\t\t).filter( Boolean ).length > 0,\n\t\t\t\tmenuOpenedBy: ( { context } ) =>\n\t\t\t\t\tcontext.core.navigation[\n\t\t\t\t\t\tcontext.core.navigation.type === 'overlay'\n\t\t\t\t\t\t\t? 'overlayOpenedBy'\n\t\t\t\t\t\t\t: 'submenuOpenedBy'\n\t\t\t\t\t],\n\t\t\t},\n\t\t},\n\t},\n\tactions: {\n\t\tcore: {\n\t\t\tnavigation: {\n\t\t\t\topenMenuOnHover( store ) {\n\t\t\t\t\tconst { navigation } = store.context.core;\n\t\t\t\t\tif (\n\t\t\t\t\t\tnavigation.type === 'submenu' &&\n\t\t\t\t\t\t// Only open on hover if the overlay is closed.\n\t\t\t\t\t\tObject.values(\n\t\t\t\t\t\t\tnavigation.overlayOpenedBy || {}\n\t\t\t\t\t\t).filter( Boolean ).length === 0\n\t\t\t\t\t)\n\t\t\t\t\t\topenMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnHover( store ) {\n\t\t\t\t\tcloseMenu( store, 'hover' );\n\t\t\t\t},\n\t\t\t\topenMenuOnClick( store ) {\n\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t},\n\t\t\t\tcloseMenuOnClick( store ) {\n\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\topenMenuOnFocus( store ) {\n\t\t\t\t\topenMenu( store, 'focus' );\n\t\t\t\t},\n\t\t\t\ttoggleMenuOnClick: ( store ) => {\n\t\t\t\t\tconst { selectors } = store;\n\t\t\t\t\tconst menuOpenedBy =\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store );\n\t\t\t\t\tif ( menuOpenedBy.click || menuOpenedBy.focus ) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\topenMenu( store, 'click' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuKeydown: ( store ) => {\n\t\t\t\t\tconst { context, selectors, event } = store;\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectors.core.navigation.menuOpenedBy( store ).click\n\t\t\t\t\t) {\n\t\t\t\t\t\t// If Escape close the menu.\n\t\t\t\t\t\tif ( event?.key === 'Escape' ) {\n\t\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Trap focus if it is an overlay (main menu).\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tcontext.core.navigation.type === 'overlay' &&\n\t\t\t\t\t\t\tevent.key === 'Tab'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// If shift + tab it change the direction.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation\n\t\t\t\t\t\t\t\t\t\t.firstFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement.focus();\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\t\t\tcontext.core.navigation.lastFocusableElement\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tcontext.core.navigation.firstFocusableElement.focus();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thandleMenuFocusout: ( store ) => {\n\t\t\t\t\tconst { context, event } = store;\n\t\t\t\t\t// If focus is outside modal, 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 outsite 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! context.core.navigation.modal?.contains(\n\t\t\t\t\t\t\tevent.relatedTarget\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\tevent.target !== window.document.activeElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tcloseMenu( store, 'click' );\n\t\t\t\t\t\tcloseMenu( store, 'focus' );\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,OAAO,QAAQ,0BAA0B;AAE3D,MAAMC,kBAAkB,GAAG,CAC1B,SAAS,EACT,+DAA+D,EAC/D,2CAA2C,EAC3C,6CAA6C,EAC7C,2CAA2C,EAC3C,mBAAmB,EACnB,iCAAiC,CACjC;AAED,MAAMC,QAAQ,GAAGA,CAAEH,KAAK,EAAEI,YAAY,KAAM;EAC3C,MAAM;IAAEC,OAAO;IAAEC,GAAG;IAAEC;EAAU,CAAC,GAAGP,KAAK;EACzCO,SAAS,CAACC,IAAI,CAACC,UAAU,CAACC,YAAY,CAAEV,KAAM,CAAC,CAAEI,YAAY,CAAE,GAAG,IAAI;EACtEC,OAAO,CAACG,IAAI,CAACC,UAAU,CAACE,aAAa,GAAGL,GAAG;EAC3C,IAAKD,OAAO,CAACG,IAAI,CAACC,UAAU,CAACG,IAAI,KAAK,SAAS,EAAG;IACjD;IACAC,QAAQ,CAACC,eAAe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6C;UAAM,CAAC,GAAGlD,KAAK;UAChC;UACA;UACA;UACA;UACA;UACA,IACC,CAAEK,OAAO,CAACG,IAAI,CAACC,UAAU,CAACW,KAAK,EAAEC,QAAQ,CACxC6B,KAAK,CAACK,aACP,CAAC,IACDL,KAAK,CAACM,MAAM,KAAKlC,MAAM,CAACT,QAAQ,CAACU,aAAa,EAC7C;YACDN,SAAS,CAAEjB,KAAK,EAAE,OAAQ,CAAC;YAC3BiB,SAAS,CAAEjB,KAAK,EAAE,OAAQ,CAAC;UAC5B;QACD;MACD;IACD;EACD;AACD,CAAE,CAAC"}
@@ -1,112 +0,0 @@
1
- /*eslint-env browser*/
2
- /**
3
- * External dependencies
4
- */
5
- import MicroModal from 'micromodal';
6
-
7
- // Responsive navigation toggle.
8
-
9
- /**
10
- * Toggles responsive navigation.
11
- *
12
- * @param {HTMLDivElement} modal
13
- * @param {boolean} isHidden
14
- */
15
- function navigationToggleModal(modal, isHidden) {
16
- const dialogContainer = modal.querySelector(`.wp-block-navigation__responsive-dialog`);
17
- modal.classList.toggle('has-modal-open', !isHidden);
18
- dialogContainer.toggleAttribute('aria-modal', !isHidden);
19
- if (isHidden) {
20
- dialogContainer.removeAttribute('role');
21
- dialogContainer.removeAttribute('aria-modal');
22
- } else {
23
- dialogContainer.setAttribute('role', 'dialog');
24
- dialogContainer.setAttribute('aria-modal', 'true');
25
- }
26
-
27
- // Add a class to indicate the modal is open.
28
- document.documentElement.classList.toggle('has-modal-open');
29
- }
30
-
31
- /**
32
- * Checks whether the provided link is an anchor on the current page.
33
- *
34
- * @param {HTMLAnchorElement} node
35
- * @return {boolean} Is anchor.
36
- */
37
- function isLinkToAnchorOnCurrentPage(node) {
38
- return node.hash && node.protocol === window.location.protocol && node.host === window.location.host && node.pathname === window.location.pathname && node.search === window.location.search;
39
- }
40
-
41
- /**
42
- * Handles effects after opening the modal.
43
- *
44
- * @param {HTMLDivElement} modal
45
- */
46
- function onShow(modal) {
47
- navigationToggleModal(modal, false);
48
- modal.addEventListener('click', handleAnchorLinkClicksInsideModal, {
49
- passive: true
50
- });
51
- }
52
-
53
- /**
54
- * Handles effects after closing the modal.
55
- *
56
- * @param {HTMLDivElement} modal
57
- */
58
- function onClose(modal) {
59
- navigationToggleModal(modal, true);
60
- modal.removeEventListener('click', handleAnchorLinkClicksInsideModal, {
61
- passive: true
62
- });
63
- }
64
-
65
- /**
66
- * Handle clicks to anchor links in modal using event delegation by closing modal automatically
67
- *
68
- * @param {UIEvent} event
69
- */
70
- function handleAnchorLinkClicksInsideModal(event) {
71
- const link = event.target.closest('.wp-block-navigation-item__content');
72
- if (!(link instanceof HTMLAnchorElement)) {
73
- return;
74
- }
75
-
76
- // Ignore non-anchor links and anchor links which open on a new tab.
77
- if (!isLinkToAnchorOnCurrentPage(link) || link.attributes?.target === '_blank') {
78
- return;
79
- }
80
-
81
- // Find the specific parent modal for this link
82
- // since .close() won't work without an ID if there are
83
- // multiple navigation menus in a post/page.
84
- const modal = link.closest('.wp-block-navigation__responsive-container');
85
- const modalId = modal?.getAttribute('id');
86
- if (!modalId) {
87
- return;
88
- }
89
-
90
- // check if modal exists and is open before trying to close it
91
- // otherwise Micromodal will toggle the `has-modal-open` class
92
- // on the html tag which prevents scrolling
93
- if (modalId && modal.classList.contains('has-modal-open')) {
94
- MicroModal.close(modalId);
95
- }
96
- }
97
-
98
- // MicroModal.init() does not support event delegation for the open trigger, so here MicroModal.show() is called manually.
99
- document.addEventListener('click', event => {
100
- /** @type {HTMLElement} */
101
- const target = event.target;
102
- if (target.dataset.micromodalTrigger) {
103
- MicroModal.show(target.dataset.micromodalTrigger, {
104
- onShow,
105
- onClose,
106
- openClass: 'is-menu-open'
107
- });
108
- }
109
- }, {
110
- passive: true
111
- });
112
- //# sourceMappingURL=view-modal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["MicroModal","navigationToggleModal","modal","isHidden","dialogContainer","querySelector","classList","toggle","toggleAttribute","removeAttribute","setAttribute","document","documentElement","isLinkToAnchorOnCurrentPage","node","hash","protocol","window","location","host","pathname","search","onShow","addEventListener","handleAnchorLinkClicksInsideModal","passive","onClose","removeEventListener","event","link","target","closest","HTMLAnchorElement","attributes","modalId","getAttribute","contains","close","dataset","micromodalTrigger","show","openClass"],"sources":["@wordpress/block-library/src/navigation/view-modal.js"],"sourcesContent":["/*eslint-env browser*/\n/**\n * External dependencies\n */\nimport MicroModal from 'micromodal';\n\n// Responsive navigation toggle.\n\n/**\n * Toggles responsive navigation.\n *\n * @param {HTMLDivElement} modal\n * @param {boolean} isHidden\n */\nfunction navigationToggleModal( modal, isHidden ) {\n\tconst dialogContainer = modal.querySelector(\n\t\t`.wp-block-navigation__responsive-dialog`\n\t);\n\n\tmodal.classList.toggle( 'has-modal-open', ! isHidden );\n\tdialogContainer.toggleAttribute( 'aria-modal', ! isHidden );\n\n\tif ( isHidden ) {\n\t\tdialogContainer.removeAttribute( 'role' );\n\t\tdialogContainer.removeAttribute( 'aria-modal' );\n\t} else {\n\t\tdialogContainer.setAttribute( 'role', 'dialog' );\n\t\tdialogContainer.setAttribute( 'aria-modal', 'true' );\n\t}\n\n\t// Add a class to indicate the modal is open.\n\tdocument.documentElement.classList.toggle( 'has-modal-open' );\n}\n\n/**\n * Checks whether the provided link is an anchor on the current page.\n *\n * @param {HTMLAnchorElement} node\n * @return {boolean} Is anchor.\n */\nfunction isLinkToAnchorOnCurrentPage( node ) {\n\treturn (\n\t\tnode.hash &&\n\t\tnode.protocol === window.location.protocol &&\n\t\tnode.host === window.location.host &&\n\t\tnode.pathname === window.location.pathname &&\n\t\tnode.search === window.location.search\n\t);\n}\n\n/**\n * Handles effects after opening the modal.\n *\n * @param {HTMLDivElement} modal\n */\nfunction onShow( modal ) {\n\tnavigationToggleModal( modal, false );\n\tmodal.addEventListener( 'click', handleAnchorLinkClicksInsideModal, {\n\t\tpassive: true,\n\t} );\n}\n\n/**\n * Handles effects after closing the modal.\n *\n * @param {HTMLDivElement} modal\n */\nfunction onClose( modal ) {\n\tnavigationToggleModal( modal, true );\n\tmodal.removeEventListener( 'click', handleAnchorLinkClicksInsideModal, {\n\t\tpassive: true,\n\t} );\n}\n\n/**\n * Handle clicks to anchor links in modal using event delegation by closing modal automatically\n *\n * @param {UIEvent} event\n */\nfunction handleAnchorLinkClicksInsideModal( event ) {\n\tconst link = event.target.closest( '.wp-block-navigation-item__content' );\n\tif ( ! ( link instanceof HTMLAnchorElement ) ) {\n\t\treturn;\n\t}\n\n\t// Ignore non-anchor links and anchor links which open on a new tab.\n\tif (\n\t\t! isLinkToAnchorOnCurrentPage( link ) ||\n\t\tlink.attributes?.target === '_blank'\n\t) {\n\t\treturn;\n\t}\n\n\t// Find the specific parent modal for this link\n\t// since .close() won't work without an ID if there are\n\t// multiple navigation menus in a post/page.\n\tconst modal = link.closest( '.wp-block-navigation__responsive-container' );\n\tconst modalId = modal?.getAttribute( 'id' );\n\tif ( ! modalId ) {\n\t\treturn;\n\t}\n\n\t// check if modal exists and is open before trying to close it\n\t// otherwise Micromodal will toggle the `has-modal-open` class\n\t// on the html tag which prevents scrolling\n\tif ( modalId && modal.classList.contains( 'has-modal-open' ) ) {\n\t\tMicroModal.close( modalId );\n\t}\n}\n\n// MicroModal.init() does not support event delegation for the open trigger, so here MicroModal.show() is called manually.\ndocument.addEventListener(\n\t'click',\n\t( event ) => {\n\t\t/** @type {HTMLElement} */\n\t\tconst target = event.target;\n\n\t\tif ( target.dataset.micromodalTrigger ) {\n\t\t\tMicroModal.show( target.dataset.micromodalTrigger, {\n\t\t\t\tonShow,\n\t\t\t\tonClose,\n\t\t\t\topenClass: 'is-menu-open',\n\t\t\t} );\n\t\t}\n\t},\n\t{ passive: true }\n);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,qBAAqBA,CAAEC,KAAK,EAAEC,QAAQ,EAAG;EACjD,MAAMC,eAAe,GAAGF,KAAK,CAACG,aAA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AAEH,iCAAiC,EAAE;IACtEC,OAAO,EAAE;EACV,CAAE,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASD,iCAAiCA,CAAEI,KAAK,EAAG;EACnD,MAAMC,IAAI,GAAGD,KAAK,CAACE,MAAM,CAACC,OAAO,CAAE,oCAAqC,CAAC;EACzE,IAAK,EAAIF,IAAI,YAAYG,iBAAiB,CAAE,EAAG;IAC9C;EACD;;EAEA;EACA,IACC,CAAEnB,2BAA2B,CAAEgB,IAAK,CAAC,IACrCA,IAAI,CAACI,UAAU,EAAEH,MAAM,KAAK,QAAQ,EACnC;IACD;EACD;;EAEA;EACA;EACA;EACA,MAAM5B,KAAK,GAAG2B,IAAI,CAACE,OAAO,CAAE,4CAA6C,CAAC;EAC1E,MAAMG,OAAO,GAAGhC,KAAK,EAAEiC,YAAY,CAAE,IAAK,CAAC;EAC3C,IAAK,CAAED,OAAO,EAAG;IAChB;EACD;;EAEA;EACA;EACA;EACA,IAAKA,OAAO,IAAIhC,KAAK,CAACI,SAAS,CAAC8B,QAAQ,CAAE,gBAAiB,CAAC,EAAG;IAC9DpC,UAAU,CAACqC,KAAK,CAAEH,OAAQ,CAAC;EAC5B;AACD;;AAEA;AACAvB,QAAQ,CAACY,gBAAgB,CACxB,OAAO,EACLK,KAAK,IAAM;EACZ;EACA,MAAME,MAAM,GAAGF,KAAK,CAACE,MAAM;EAE3B,IAAKA,MAAM,CAACQ,OAAO,CAACC,iBAAiB,EAAG;IACvCvC,UAAU,CAACwC,IAAI,CAAEV,MAAM,CAACQ,OAAO,CAACC,iBAAiB,EAAE;MAClDjB,MAAM;MACNI,OAAO;MACPe,SAAS,EAAE;IACZ,CAAE,CAAC;EACJ;AACD,CAAC,EACD;EAAEhB,OAAO,EAAE;AAAK,CACjB,CAAC"}
@@ -1,18 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store } from '@wordpress/interactivity';
5
- /**
6
- * Internal dependencies
7
- */
8
- import { browserSupportsPdfs as hasPdfPreview } from './utils';
9
-
10
- store( {
11
- selectors: {
12
- core: {
13
- file: {
14
- hasPdfPreview,
15
- },
16
- },
17
- },
18
- } );
@@ -1,196 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store as wpStore } from '@wordpress/interactivity';
5
-
6
- const focusableSelectors = [
7
- 'a[href]',
8
- 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',
9
- 'select:not([disabled]):not([aria-hidden])',
10
- 'textarea:not([disabled]):not([aria-hidden])',
11
- 'button:not([disabled]):not([aria-hidden])',
12
- '[contenteditable]',
13
- '[tabindex]:not([tabindex^="-"])',
14
- ];
15
-
16
- const openMenu = ( store, menuOpenedOn ) => {
17
- const { context, ref, selectors } = store;
18
- selectors.core.navigation.menuOpenedBy( store )[ menuOpenedOn ] = true;
19
- context.core.navigation.previousFocus = ref;
20
- if ( context.core.navigation.type === 'overlay' ) {
21
- // Add a `has-modal-open` class to the <html> root.
22
- document.documentElement.classList.add( 'has-modal-open' );
23
- }
24
- };
25
-
26
- const closeMenu = ( store, menuClosedOn ) => {
27
- const { context, selectors } = store;
28
- selectors.core.navigation.menuOpenedBy( store )[ menuClosedOn ] = false;
29
- // Check if the menu is still open or not.
30
- if ( ! selectors.core.navigation.isMenuOpen( store ) ) {
31
- if (
32
- context.core.navigation.modal?.contains(
33
- window.document.activeElement
34
- )
35
- ) {
36
- context.core.navigation.previousFocus.focus();
37
- }
38
- context.core.navigation.modal = null;
39
- context.core.navigation.previousFocus = null;
40
- if ( context.core.navigation.type === 'overlay' ) {
41
- document.documentElement.classList.remove( 'has-modal-open' );
42
- }
43
- }
44
- };
45
-
46
- wpStore( {
47
- effects: {
48
- core: {
49
- navigation: {
50
- initMenu: ( store ) => {
51
- const { context, selectors, ref } = store;
52
- if ( selectors.core.navigation.isMenuOpen( store ) ) {
53
- const focusableElements =
54
- ref.querySelectorAll( focusableSelectors );
55
- context.core.navigation.modal = ref;
56
- context.core.navigation.firstFocusableElement =
57
- focusableElements[ 0 ];
58
- context.core.navigation.lastFocusableElement =
59
- focusableElements[ focusableElements.length - 1 ];
60
- }
61
- },
62
- focusFirstElement: ( store ) => {
63
- const { selectors, ref } = store;
64
- if ( selectors.core.navigation.isMenuOpen( store ) ) {
65
- ref.querySelector(
66
- '.wp-block-navigation-item > *:first-child'
67
- ).focus();
68
- }
69
- },
70
- },
71
- },
72
- },
73
- selectors: {
74
- core: {
75
- navigation: {
76
- roleAttribute: ( store ) => {
77
- const { context, selectors } = store;
78
- return context.core.navigation.type === 'overlay' &&
79
- selectors.core.navigation.isMenuOpen( store )
80
- ? 'dialog'
81
- : '';
82
- },
83
- isMenuOpen: ( { context } ) =>
84
- // The menu is opened if either `click`, `hover` or `focus` is true.
85
- Object.values(
86
- context.core.navigation[
87
- context.core.navigation.type === 'overlay'
88
- ? 'overlayOpenedBy'
89
- : 'submenuOpenedBy'
90
- ]
91
- ).filter( Boolean ).length > 0,
92
- menuOpenedBy: ( { context } ) =>
93
- context.core.navigation[
94
- context.core.navigation.type === 'overlay'
95
- ? 'overlayOpenedBy'
96
- : 'submenuOpenedBy'
97
- ],
98
- },
99
- },
100
- },
101
- actions: {
102
- core: {
103
- navigation: {
104
- openMenuOnHover( store ) {
105
- const { navigation } = store.context.core;
106
- if (
107
- navigation.type === 'submenu' &&
108
- // Only open on hover if the overlay is closed.
109
- Object.values(
110
- navigation.overlayOpenedBy || {}
111
- ).filter( Boolean ).length === 0
112
- )
113
- openMenu( store, 'hover' );
114
- },
115
- closeMenuOnHover( store ) {
116
- closeMenu( store, 'hover' );
117
- },
118
- openMenuOnClick( store ) {
119
- openMenu( store, 'click' );
120
- },
121
- closeMenuOnClick( store ) {
122
- closeMenu( store, 'click' );
123
- closeMenu( store, 'focus' );
124
- },
125
- openMenuOnFocus( store ) {
126
- openMenu( store, 'focus' );
127
- },
128
- toggleMenuOnClick: ( store ) => {
129
- const { selectors } = store;
130
- const menuOpenedBy =
131
- selectors.core.navigation.menuOpenedBy( store );
132
- if ( menuOpenedBy.click || menuOpenedBy.focus ) {
133
- closeMenu( store, 'click' );
134
- closeMenu( store, 'focus' );
135
- } else {
136
- openMenu( store, 'click' );
137
- }
138
- },
139
- handleMenuKeydown: ( store ) => {
140
- const { context, selectors, event } = store;
141
- if (
142
- selectors.core.navigation.menuOpenedBy( store ).click
143
- ) {
144
- // If Escape close the menu.
145
- if ( event?.key === 'Escape' ) {
146
- closeMenu( store, 'click' );
147
- closeMenu( store, 'focus' );
148
- return;
149
- }
150
-
151
- // Trap focus if it is an overlay (main menu).
152
- if (
153
- context.core.navigation.type === 'overlay' &&
154
- event.key === 'Tab'
155
- ) {
156
- // If shift + tab it change the direction.
157
- if (
158
- event.shiftKey &&
159
- window.document.activeElement ===
160
- context.core.navigation
161
- .firstFocusableElement
162
- ) {
163
- event.preventDefault();
164
- context.core.navigation.lastFocusableElement.focus();
165
- } else if (
166
- ! event.shiftKey &&
167
- window.document.activeElement ===
168
- context.core.navigation.lastFocusableElement
169
- ) {
170
- event.preventDefault();
171
- context.core.navigation.firstFocusableElement.focus();
172
- }
173
- }
174
- }
175
- },
176
- handleMenuFocusout: ( store ) => {
177
- const { context, event } = store;
178
- // If focus is outside modal, and in the document, close menu
179
- // event.target === The element losing focus
180
- // event.relatedTarget === The element receiving focus (if any)
181
- // When focusout is outsite the document,
182
- // `window.document.activeElement` doesn't change.
183
- if (
184
- ! context.core.navigation.modal?.contains(
185
- event.relatedTarget
186
- ) &&
187
- event.target !== window.document.activeElement
188
- ) {
189
- closeMenu( store, 'click' );
190
- closeMenu( store, 'focus' );
191
- }
192
- },
193
- },
194
- },
195
- },
196
- } );
@@ -1,127 +0,0 @@
1
- /*eslint-env browser*/
2
- /**
3
- * External dependencies
4
- */
5
- import MicroModal from 'micromodal';
6
-
7
- // Responsive navigation toggle.
8
-
9
- /**
10
- * Toggles responsive navigation.
11
- *
12
- * @param {HTMLDivElement} modal
13
- * @param {boolean} isHidden
14
- */
15
- function navigationToggleModal( modal, isHidden ) {
16
- const dialogContainer = modal.querySelector(
17
- `.wp-block-navigation__responsive-dialog`
18
- );
19
-
20
- modal.classList.toggle( 'has-modal-open', ! isHidden );
21
- dialogContainer.toggleAttribute( 'aria-modal', ! isHidden );
22
-
23
- if ( isHidden ) {
24
- dialogContainer.removeAttribute( 'role' );
25
- dialogContainer.removeAttribute( 'aria-modal' );
26
- } else {
27
- dialogContainer.setAttribute( 'role', 'dialog' );
28
- dialogContainer.setAttribute( 'aria-modal', 'true' );
29
- }
30
-
31
- // Add a class to indicate the modal is open.
32
- document.documentElement.classList.toggle( 'has-modal-open' );
33
- }
34
-
35
- /**
36
- * Checks whether the provided link is an anchor on the current page.
37
- *
38
- * @param {HTMLAnchorElement} node
39
- * @return {boolean} Is anchor.
40
- */
41
- function isLinkToAnchorOnCurrentPage( node ) {
42
- return (
43
- node.hash &&
44
- node.protocol === window.location.protocol &&
45
- node.host === window.location.host &&
46
- node.pathname === window.location.pathname &&
47
- node.search === window.location.search
48
- );
49
- }
50
-
51
- /**
52
- * Handles effects after opening the modal.
53
- *
54
- * @param {HTMLDivElement} modal
55
- */
56
- function onShow( modal ) {
57
- navigationToggleModal( modal, false );
58
- modal.addEventListener( 'click', handleAnchorLinkClicksInsideModal, {
59
- passive: true,
60
- } );
61
- }
62
-
63
- /**
64
- * Handles effects after closing the modal.
65
- *
66
- * @param {HTMLDivElement} modal
67
- */
68
- function onClose( modal ) {
69
- navigationToggleModal( modal, true );
70
- modal.removeEventListener( 'click', handleAnchorLinkClicksInsideModal, {
71
- passive: true,
72
- } );
73
- }
74
-
75
- /**
76
- * Handle clicks to anchor links in modal using event delegation by closing modal automatically
77
- *
78
- * @param {UIEvent} event
79
- */
80
- function handleAnchorLinkClicksInsideModal( event ) {
81
- const link = event.target.closest( '.wp-block-navigation-item__content' );
82
- if ( ! ( link instanceof HTMLAnchorElement ) ) {
83
- return;
84
- }
85
-
86
- // Ignore non-anchor links and anchor links which open on a new tab.
87
- if (
88
- ! isLinkToAnchorOnCurrentPage( link ) ||
89
- link.attributes?.target === '_blank'
90
- ) {
91
- return;
92
- }
93
-
94
- // Find the specific parent modal for this link
95
- // since .close() won't work without an ID if there are
96
- // multiple navigation menus in a post/page.
97
- const modal = link.closest( '.wp-block-navigation__responsive-container' );
98
- const modalId = modal?.getAttribute( 'id' );
99
- if ( ! modalId ) {
100
- return;
101
- }
102
-
103
- // check if modal exists and is open before trying to close it
104
- // otherwise Micromodal will toggle the `has-modal-open` class
105
- // on the html tag which prevents scrolling
106
- if ( modalId && modal.classList.contains( 'has-modal-open' ) ) {
107
- MicroModal.close( modalId );
108
- }
109
- }
110
-
111
- // MicroModal.init() does not support event delegation for the open trigger, so here MicroModal.show() is called manually.
112
- document.addEventListener(
113
- 'click',
114
- ( event ) => {
115
- /** @type {HTMLElement} */
116
- const target = event.target;
117
-
118
- if ( target.dataset.micromodalTrigger ) {
119
- MicroModal.show( target.dataset.micromodalTrigger, {
120
- onShow,
121
- onClose,
122
- openClass: 'is-menu-open',
123
- } );
124
- }
125
- },
126
- { passive: true }
127
- );
File without changes