@wordpress/block-library 8.13.0 → 8.14.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 (366) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/index.js +5 -1
  3. package/build/archives/index.js.map +1 -1
  4. package/build/audio/index.js +5 -1
  5. package/build/audio/index.js.map +1 -1
  6. package/build/avatar/index.js +1 -1
  7. package/build/block/edit.js +1 -1
  8. package/build/block/edit.js.map +1 -1
  9. package/build/block/edit.native.js +6 -9
  10. package/build/block/edit.native.js.map +1 -1
  11. package/build/buttons/edit.js +5 -1
  12. package/build/buttons/edit.js.map +1 -1
  13. package/build/categories/index.js +5 -1
  14. package/build/categories/index.js.map +1 -1
  15. package/build/code/index.js +5 -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/comments/index.js +1 -0
  20. package/build/comments/index.js.map +1 -1
  21. package/build/cover/edit/inspector-controls.js +2 -1
  22. package/build/cover/edit/inspector-controls.js.map +1 -1
  23. package/build/cover/index.js +1 -0
  24. package/build/cover/index.js.map +1 -1
  25. package/build/details/index.js +5 -1
  26. package/build/details/index.js.map +1 -1
  27. package/build/embed/util.js +9 -8
  28. package/build/embed/util.js.map +1 -1
  29. package/build/file/index.js +2 -1
  30. package/build/file/index.js.map +1 -1
  31. package/build/file/view.js +15 -1
  32. package/build/file/view.js.map +1 -1
  33. package/build/gallery/index.js +3 -1
  34. package/build/gallery/index.js.map +1 -1
  35. package/build/group/index.js +1 -0
  36. package/build/group/index.js.map +1 -1
  37. package/build/heading/index.js +5 -1
  38. package/build/heading/index.js.map +1 -1
  39. package/build/heading/transforms.js +5 -1
  40. package/build/heading/transforms.js.map +1 -1
  41. package/build/image/deprecated.js +453 -175
  42. package/build/image/deprecated.js.map +1 -1
  43. package/build/image/edit.js +0 -4
  44. package/build/image/edit.js.map +1 -1
  45. package/build/image/image.js +96 -43
  46. package/build/image/image.js.map +1 -1
  47. package/build/image/index.js +6 -0
  48. package/build/image/index.js.map +1 -1
  49. package/build/image/save.js +8 -1
  50. package/build/image/save.js.map +1 -1
  51. package/build/image/utils.js +18 -0
  52. package/build/image/utils.js.map +1 -1
  53. package/build/image/{interactivity.js → view-interactivity.js} +86 -44
  54. package/build/image/view-interactivity.js.map +1 -0
  55. package/build/index.js +12 -3
  56. package/build/index.js.map +1 -1
  57. package/build/list/index.js +5 -1
  58. package/build/list/index.js.map +1 -1
  59. package/build/list-item/utils.js +6 -1
  60. package/build/list-item/utils.js.map +1 -1
  61. package/build/media-text/index.js +1 -0
  62. package/build/media-text/index.js.map +1 -1
  63. package/build/missing/edit.js +22 -8
  64. package/build/missing/edit.js.map +1 -1
  65. package/build/navigation/edit/index.js +1 -1
  66. package/build/navigation/edit/index.js.map +1 -1
  67. package/build/navigation/edit/menu-inspector-controls.js +0 -1
  68. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  69. package/build/navigation/index.js +3 -2
  70. package/build/navigation/index.js.map +1 -1
  71. package/build/navigation/view.js +174 -50
  72. package/build/navigation/view.js.map +1 -1
  73. package/build/navigation-link/edit.js +0 -11
  74. package/build/navigation-link/edit.js.map +1 -1
  75. package/build/navigation-link/link-ui.js +12 -2
  76. package/build/navigation-link/link-ui.js.map +1 -1
  77. package/build/page-list/convert-to-links-modal.js +3 -3
  78. package/build/page-list/convert-to-links-modal.js.map +1 -1
  79. package/build/page-list/edit.js +34 -39
  80. package/build/page-list/edit.js.map +1 -1
  81. package/build/page-list/use-convert-to-navigation-links.js +2 -15
  82. package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
  83. package/build/paragraph/index.js +1 -0
  84. package/build/paragraph/index.js.map +1 -1
  85. package/build/paragraph/transforms.js +1 -0
  86. package/build/paragraph/transforms.js.map +1 -1
  87. package/build/post-comments-form/index.js +1 -0
  88. package/build/post-comments-form/index.js.map +1 -1
  89. package/build/post-navigation-link/index.js +1 -0
  90. package/build/post-navigation-link/index.js.map +1 -1
  91. package/build/post-time-to-read/index.js +5 -1
  92. package/build/post-time-to-read/index.js.map +1 -1
  93. package/build/query-pagination-numbers/index.js +1 -1
  94. package/build/quote/index.js +1 -0
  95. package/build/quote/index.js.map +1 -1
  96. package/build/site-logo/index.js +5 -1
  97. package/build/site-logo/index.js.map +1 -1
  98. package/build/site-tagline/icon.js +1 -1
  99. package/build/site-tagline/icon.js.map +1 -1
  100. package/build/site-tagline/index.js +5 -1
  101. package/build/site-tagline/index.js.map +1 -1
  102. package/build/site-title/index.js +5 -1
  103. package/build/site-title/index.js.map +1 -1
  104. package/build/social-links/index.js +3 -1
  105. package/build/social-links/index.js.map +1 -1
  106. package/build/table/index.js +5 -1
  107. package/build/table/index.js.map +1 -1
  108. package/build/term-description/index.js +1 -0
  109. package/build/term-description/index.js.map +1 -1
  110. package/build/verse/index.js +5 -1
  111. package/build/verse/index.js.map +1 -1
  112. package/build/video/deprecated.js +5 -1
  113. package/build/video/deprecated.js.map +1 -1
  114. package/build/video/index.js +5 -1
  115. package/build/video/index.js.map +1 -1
  116. package/build-module/archives/index.js +5 -1
  117. package/build-module/archives/index.js.map +1 -1
  118. package/build-module/audio/index.js +5 -1
  119. package/build-module/audio/index.js.map +1 -1
  120. package/build-module/avatar/index.js +1 -1
  121. package/build-module/block/edit.js +1 -1
  122. package/build-module/block/edit.js.map +1 -1
  123. package/build-module/block/edit.native.js +7 -9
  124. package/build-module/block/edit.native.js.map +1 -1
  125. package/build-module/buttons/edit.js +5 -1
  126. package/build-module/buttons/edit.js.map +1 -1
  127. package/build-module/categories/index.js +5 -1
  128. package/build-module/categories/index.js.map +1 -1
  129. package/build-module/code/index.js +5 -1
  130. package/build-module/code/index.js.map +1 -1
  131. package/build-module/column/index.js +1 -0
  132. package/build-module/column/index.js.map +1 -1
  133. package/build-module/comments/index.js +1 -0
  134. package/build-module/comments/index.js.map +1 -1
  135. package/build-module/cover/edit/inspector-controls.js +2 -1
  136. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  137. package/build-module/cover/index.js +1 -0
  138. package/build-module/cover/index.js.map +1 -1
  139. package/build-module/details/index.js +5 -1
  140. package/build-module/details/index.js.map +1 -1
  141. package/build-module/embed/util.js +6 -6
  142. package/build-module/embed/util.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/view.js +15 -2
  146. package/build-module/file/view.js.map +1 -1
  147. package/build-module/gallery/index.js +3 -1
  148. package/build-module/gallery/index.js.map +1 -1
  149. package/build-module/group/index.js +1 -0
  150. package/build-module/group/index.js.map +1 -1
  151. package/build-module/heading/index.js +5 -1
  152. package/build-module/heading/index.js.map +1 -1
  153. package/build-module/heading/transforms.js +5 -1
  154. package/build-module/heading/transforms.js.map +1 -1
  155. package/build-module/image/deprecated.js +454 -176
  156. package/build-module/image/deprecated.js.map +1 -1
  157. package/build-module/image/edit.js +0 -4
  158. package/build-module/image/edit.js.map +1 -1
  159. package/build-module/image/image.js +96 -46
  160. package/build-module/image/image.js.map +1 -1
  161. package/build-module/image/index.js +6 -0
  162. package/build-module/image/index.js.map +1 -1
  163. package/build-module/image/save.js +8 -1
  164. package/build-module/image/save.js.map +1 -1
  165. package/build-module/image/utils.js +16 -0
  166. package/build-module/image/utils.js.map +1 -1
  167. package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
  168. package/build-module/image/view-interactivity.js.map +1 -0
  169. package/build-module/index.js +12 -3
  170. package/build-module/index.js.map +1 -1
  171. package/build-module/list/index.js +5 -1
  172. package/build-module/list/index.js.map +1 -1
  173. package/build-module/list-item/utils.js +6 -1
  174. package/build-module/list-item/utils.js.map +1 -1
  175. package/build-module/media-text/index.js +1 -0
  176. package/build-module/media-text/index.js.map +1 -1
  177. package/build-module/missing/edit.js +22 -8
  178. package/build-module/missing/edit.js.map +1 -1
  179. package/build-module/navigation/edit/index.js +1 -1
  180. package/build-module/navigation/edit/index.js.map +1 -1
  181. package/build-module/navigation/edit/menu-inspector-controls.js +0 -1
  182. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  183. package/build-module/navigation/index.js +3 -2
  184. package/build-module/navigation/index.js.map +1 -1
  185. package/build-module/navigation/view.js +173 -50
  186. package/build-module/navigation/view.js.map +1 -1
  187. package/build-module/navigation-link/edit.js +1 -12
  188. package/build-module/navigation-link/edit.js.map +1 -1
  189. package/build-module/navigation-link/link-ui.js +13 -3
  190. package/build-module/navigation-link/link-ui.js.map +1 -1
  191. package/build-module/page-list/convert-to-links-modal.js +3 -3
  192. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  193. package/build-module/page-list/edit.js +34 -39
  194. package/build-module/page-list/edit.js.map +1 -1
  195. package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
  196. package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
  197. package/build-module/paragraph/index.js +1 -0
  198. package/build-module/paragraph/index.js.map +1 -1
  199. package/build-module/paragraph/transforms.js +1 -0
  200. package/build-module/paragraph/transforms.js.map +1 -1
  201. package/build-module/post-comments-form/index.js +1 -0
  202. package/build-module/post-comments-form/index.js.map +1 -1
  203. package/build-module/post-navigation-link/index.js +1 -0
  204. package/build-module/post-navigation-link/index.js.map +1 -1
  205. package/build-module/post-time-to-read/index.js +5 -1
  206. package/build-module/post-time-to-read/index.js.map +1 -1
  207. package/build-module/query-pagination-numbers/index.js +1 -1
  208. package/build-module/quote/index.js +1 -0
  209. package/build-module/quote/index.js.map +1 -1
  210. package/build-module/site-logo/index.js +5 -1
  211. package/build-module/site-logo/index.js.map +1 -1
  212. package/build-module/site-tagline/icon.js +1 -1
  213. package/build-module/site-tagline/icon.js.map +1 -1
  214. package/build-module/site-tagline/index.js +5 -1
  215. package/build-module/site-tagline/index.js.map +1 -1
  216. package/build-module/site-title/index.js +5 -1
  217. package/build-module/site-title/index.js.map +1 -1
  218. package/build-module/social-links/index.js +3 -1
  219. package/build-module/social-links/index.js.map +1 -1
  220. package/build-module/table/index.js +5 -1
  221. package/build-module/table/index.js.map +1 -1
  222. package/build-module/term-description/index.js +1 -0
  223. package/build-module/term-description/index.js.map +1 -1
  224. package/build-module/verse/index.js +5 -1
  225. package/build-module/verse/index.js.map +1 -1
  226. package/build-module/video/deprecated.js +5 -1
  227. package/build-module/video/deprecated.js.map +1 -1
  228. package/build-module/video/index.js +5 -1
  229. package/build-module/video/index.js.map +1 -1
  230. package/build-style/footnotes/style-rtl.css +2 -2
  231. package/build-style/footnotes/style.css +2 -2
  232. package/build-style/image/style-rtl.css +16 -2
  233. package/build-style/image/style.css +16 -2
  234. package/build-style/style-rtl.css +18 -4
  235. package/build-style/style.css +18 -4
  236. package/package.json +33 -38
  237. package/src/archives/block.json +5 -1
  238. package/src/audio/block.json +5 -1
  239. package/src/avatar/block.json +1 -1
  240. package/src/block/edit.js +2 -2
  241. package/src/block/edit.native.js +8 -12
  242. package/src/block/test/edit.native.js +4 -4
  243. package/src/buttons/edit.js +2 -2
  244. package/src/categories/block.json +5 -1
  245. package/src/code/block.json +5 -1
  246. package/src/column/block.json +1 -0
  247. package/src/comments/block.json +1 -0
  248. package/src/cover/block.json +1 -0
  249. package/src/cover/edit/inspector-controls.js +1 -0
  250. package/src/details/block.json +5 -1
  251. package/src/embed/util.js +4 -6
  252. package/src/file/block.json +2 -1
  253. package/src/file/index.php +0 -17
  254. package/src/file/view.js +14 -5
  255. package/src/footnotes/index.php +11 -9
  256. package/src/footnotes/style.scss +2 -2
  257. package/src/gallery/block.json +3 -1
  258. package/src/group/block.json +1 -0
  259. package/src/heading/block.json +5 -1
  260. package/src/heading/test/index.native.js +18 -0
  261. package/src/image/block.json +6 -0
  262. package/src/image/deprecated.js +597 -320
  263. package/src/image/edit.js +0 -4
  264. package/src/image/image.js +131 -62
  265. package/src/image/save.js +9 -1
  266. package/src/image/style.scss +15 -2
  267. package/src/image/utils.js +16 -0
  268. package/src/image/{interactivity.js → view-interactivity.js} +99 -50
  269. package/src/index.js +18 -1
  270. package/src/latest-posts/index.php +1 -1
  271. package/src/list/block.json +5 -1
  272. package/src/media-text/block.json +1 -0
  273. package/src/missing/edit.js +31 -11
  274. package/src/navigation/block.json +3 -2
  275. package/src/navigation/edit/index.js +1 -2
  276. package/src/navigation/edit/menu-inspector-controls.js +0 -1
  277. package/src/navigation/index.php +39 -30
  278. package/src/navigation/view.js +189 -67
  279. package/src/navigation-link/edit.js +1 -15
  280. package/src/navigation-link/link-ui.js +14 -2
  281. package/src/navigation-submenu/index.php +2 -12
  282. package/src/page-list/convert-to-links-modal.js +3 -3
  283. package/src/page-list/edit.js +65 -62
  284. package/src/page-list/use-convert-to-navigation-links.js +3 -20
  285. package/src/paragraph/block.json +1 -0
  286. package/src/post-comments-form/block.json +1 -0
  287. package/src/post-navigation-link/block.json +1 -0
  288. package/src/post-time-to-read/block.json +5 -1
  289. package/src/query-pagination-numbers/block.json +1 -1
  290. package/src/quote/block.json +1 -0
  291. package/src/site-logo/block.json +5 -1
  292. package/src/site-tagline/block.json +5 -1
  293. package/src/site-tagline/icon.js +1 -1
  294. package/src/site-title/block.json +5 -1
  295. package/src/social-links/block.json +3 -1
  296. package/src/table/block.json +5 -1
  297. package/src/term-description/block.json +1 -0
  298. package/src/verse/block.json +5 -1
  299. package/src/video/block.json +5 -1
  300. package/build/file/interactivity.js +0 -19
  301. package/build/file/interactivity.js.map +0 -1
  302. package/build/heading/heading-level-icon.js +0 -61
  303. package/build/heading/heading-level-icon.js.map +0 -1
  304. package/build/image/interactivity.js.map +0 -1
  305. package/build/navigation/interactivity.js +0 -167
  306. package/build/navigation/interactivity.js.map +0 -1
  307. package/build/navigation/view-modal.js +0 -64
  308. package/build/navigation/view-modal.js.map +0 -1
  309. package/build/utils/interactivity/constants.js +0 -9
  310. package/build/utils/interactivity/constants.js.map +0 -1
  311. package/build/utils/interactivity/directives.js +0 -222
  312. package/build/utils/interactivity/directives.js.map +0 -1
  313. package/build/utils/interactivity/hooks.js +0 -159
  314. package/build/utils/interactivity/hooks.js.map +0 -1
  315. package/build/utils/interactivity/hydration.js +0 -34
  316. package/build/utils/interactivity/hydration.js.map +0 -1
  317. package/build/utils/interactivity/index.js +0 -32
  318. package/build/utils/interactivity/index.js.map +0 -1
  319. package/build/utils/interactivity/portals.js +0 -108
  320. package/build/utils/interactivity/portals.js.map +0 -1
  321. package/build/utils/interactivity/store.js +0 -66
  322. package/build/utils/interactivity/store.js.map +0 -1
  323. package/build/utils/interactivity/utils.js +0 -87
  324. package/build/utils/interactivity/utils.js.map +0 -1
  325. package/build/utils/interactivity/vdom.js +0 -119
  326. package/build/utils/interactivity/vdom.js.map +0 -1
  327. package/build-module/file/interactivity.js +0 -15
  328. package/build-module/file/interactivity.js.map +0 -1
  329. package/build-module/heading/heading-level-icon.js +0 -53
  330. package/build-module/heading/heading-level-icon.js.map +0 -1
  331. package/build-module/image/interactivity.js.map +0 -1
  332. package/build-module/navigation/interactivity.js +0 -164
  333. package/build-module/navigation/interactivity.js.map +0 -1
  334. package/build-module/navigation/view-modal.js +0 -58
  335. package/build-module/navigation/view-modal.js.map +0 -1
  336. package/build-module/utils/interactivity/constants.js +0 -2
  337. package/build-module/utils/interactivity/constants.js.map +0 -1
  338. package/build-module/utils/interactivity/directives.js +0 -209
  339. package/build-module/utils/interactivity/directives.js.map +0 -1
  340. package/build-module/utils/interactivity/hooks.js +0 -145
  341. package/build-module/utils/interactivity/hooks.js.map +0 -1
  342. package/build-module/utils/interactivity/hydration.js +0 -21
  343. package/build-module/utils/interactivity/hydration.js.map +0 -1
  344. package/build-module/utils/interactivity/index.js +0 -15
  345. package/build-module/utils/interactivity/index.js.map +0 -1
  346. package/build-module/utils/interactivity/portals.js +0 -100
  347. package/build-module/utils/interactivity/portals.js.map +0 -1
  348. package/build-module/utils/interactivity/store.js +0 -55
  349. package/build-module/utils/interactivity/store.js.map +0 -1
  350. package/build-module/utils/interactivity/utils.js +0 -75
  351. package/build-module/utils/interactivity/utils.js.map +0 -1
  352. package/build-module/utils/interactivity/vdom.js +0 -107
  353. package/build-module/utils/interactivity/vdom.js.map +0 -1
  354. package/src/file/interactivity.js +0 -15
  355. package/src/heading/heading-level-icon.js +0 -48
  356. package/src/navigation/interactivity.js +0 -169
  357. package/src/navigation/view-modal.js +0 -78
  358. package/src/utils/interactivity/constants.js +0 -1
  359. package/src/utils/interactivity/directives.js +0 -200
  360. package/src/utils/interactivity/hooks.js +0 -145
  361. package/src/utils/interactivity/hydration.js +0 -22
  362. package/src/utils/interactivity/index.js +0 -15
  363. package/src/utils/interactivity/portals.js +0 -98
  364. package/src/utils/interactivity/store.js +0 -45
  365. package/src/utils/interactivity/utils.js +0 -66
  366. package/src/utils/interactivity/vdom.js +0 -111
@@ -1,48 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { Path, SVG } from '@wordpress/components';
5
-
6
- /** @typedef {import('@wordpress/element').WPComponent} WPComponent */
7
-
8
- /**
9
- * HeadingLevelIcon props.
10
- *
11
- * @typedef WPHeadingLevelIconProps
12
- *
13
- * @property {number} level The heading level to show an icon for.
14
- * @property {?boolean} isPressed Whether or not the icon should appear pressed; default: false.
15
- */
16
-
17
- /**
18
- * Heading level icon.
19
- *
20
- * @param {WPHeadingLevelIconProps} props Component props.
21
- *
22
- * @return {?WPComponent} The icon.
23
- */
24
- export default function HeadingLevelIcon( { level, isPressed = false } ) {
25
- const levelToPath = {
26
- 1: 'M9 5h2v10H9v-4H5v4H3V5h2v4h4V5zm6.6 0c-.6.9-1.5 1.7-2.6 2v1h2v7h2V5h-1.4z',
27
- 2: 'M7 5h2v10H7v-4H3v4H1V5h2v4h4V5zm8 8c.5-.4.6-.6 1.1-1.1.4-.4.8-.8 1.2-1.3.3-.4.6-.8.9-1.3.2-.4.3-.8.3-1.3 0-.4-.1-.9-.3-1.3-.2-.4-.4-.7-.8-1-.3-.3-.7-.5-1.2-.6-.5-.2-1-.2-1.5-.2-.4 0-.7 0-1.1.1-.3.1-.7.2-1 .3-.3.1-.6.3-.9.5-.3.2-.6.4-.8.7l1.2 1.2c.3-.3.6-.5 1-.7.4-.2.7-.3 1.2-.3s.9.1 1.3.4c.3.3.5.7.5 1.1 0 .4-.1.8-.4 1.1-.3.5-.6.9-1 1.2-.4.4-1 .9-1.6 1.4-.6.5-1.4 1.1-2.2 1.6V15h8v-2H15z',
28
- 3: 'M12.1 12.2c.4.3.8.5 1.2.7.4.2.9.3 1.4.3.5 0 1-.1 1.4-.3.3-.1.5-.5.5-.8 0-.2 0-.4-.1-.6-.1-.2-.3-.3-.5-.4-.3-.1-.7-.2-1-.3-.5-.1-1-.1-1.5-.1V9.1c.7.1 1.5-.1 2.2-.4.4-.2.6-.5.6-.9 0-.3-.1-.6-.4-.8-.3-.2-.7-.3-1.1-.3-.4 0-.8.1-1.1.3-.4.2-.7.4-1.1.6l-1.2-1.4c.5-.4 1.1-.7 1.6-.9.5-.2 1.2-.3 1.8-.3.5 0 1 .1 1.6.2.4.1.8.3 1.2.5.3.2.6.5.8.8.2.3.3.7.3 1.1 0 .5-.2.9-.5 1.3-.4.4-.9.7-1.5.9v.1c.6.1 1.2.4 1.6.8.4.4.7.9.7 1.5 0 .4-.1.8-.3 1.2-.2.4-.5.7-.9.9-.4.3-.9.4-1.3.5-.5.1-1 .2-1.6.2-.8 0-1.6-.1-2.3-.4-.6-.2-1.1-.6-1.6-1l1.1-1.4zM7 9H3V5H1v10h2v-4h4v4h2V5H7v4z',
29
- 4: 'M9 15H7v-4H3v4H1V5h2v4h4V5h2v10zm10-2h-1v2h-2v-2h-5v-2l4-6h3v6h1v2zm-3-2V7l-2.8 4H16z',
30
- 5: 'M12.1 12.2c.4.3.7.5 1.1.7.4.2.9.3 1.3.3.5 0 1-.1 1.4-.4.4-.3.6-.7.6-1.1 0-.4-.2-.9-.6-1.1-.4-.3-.9-.4-1.4-.4H14c-.1 0-.3 0-.4.1l-.4.1-.5.2-1-.6.3-5h6.4v1.9h-4.3L14 8.8c.2-.1.5-.1.7-.2.2 0 .5-.1.7-.1.5 0 .9.1 1.4.2.4.1.8.3 1.1.6.3.2.6.6.8.9.2.4.3.9.3 1.4 0 .5-.1 1-.3 1.4-.2.4-.5.8-.9 1.1-.4.3-.8.5-1.3.7-.5.2-1 .3-1.5.3-.8 0-1.6-.1-2.3-.4-.6-.2-1.1-.6-1.6-1-.1-.1 1-1.5 1-1.5zM9 15H7v-4H3v4H1V5h2v4h4V5h2v10z',
31
- 6: 'M9 15H7v-4H3v4H1V5h2v4h4V5h2v10zm8.6-7.5c-.2-.2-.5-.4-.8-.5-.6-.2-1.3-.2-1.9 0-.3.1-.6.3-.8.5l-.6.9c-.2.5-.2.9-.2 1.4.4-.3.8-.6 1.2-.8.4-.2.8-.3 1.3-.3.4 0 .8 0 1.2.2.4.1.7.3 1 .6.3.3.5.6.7.9.2.4.3.8.3 1.3s-.1.9-.3 1.4c-.2.4-.5.7-.8 1-.4.3-.8.5-1.2.6-1 .3-2 .3-3 0-.5-.2-1-.5-1.4-.9-.4-.4-.8-.9-1-1.5-.2-.6-.3-1.3-.3-2.1s.1-1.6.4-2.3c.2-.6.6-1.2 1-1.6.4-.4.9-.7 1.4-.9.6-.3 1.1-.4 1.7-.4.7 0 1.4.1 2 .3.5.2 1 .5 1.4.8 0 .1-1.3 1.4-1.3 1.4zm-2.4 5.8c.2 0 .4 0 .6-.1.2 0 .4-.1.5-.2.1-.1.3-.3.4-.5.1-.2.1-.5.1-.7 0-.4-.1-.8-.4-1.1-.3-.2-.7-.3-1.1-.3-.3 0-.7.1-1 .2-.4.2-.7.4-1 .7 0 .3.1.7.3 1 .1.2.3.4.4.6.2.1.3.3.5.3.2.1.5.2.7.1z',
32
- };
33
- if ( ! levelToPath.hasOwnProperty( level ) ) {
34
- return null;
35
- }
36
-
37
- return (
38
- <SVG
39
- width="24"
40
- height="24"
41
- viewBox="0 0 20 20"
42
- xmlns="http://www.w3.org/2000/svg"
43
- isPressed={ isPressed }
44
- >
45
- <Path d={ levelToPath[ level ] } />
46
- </SVG>
47
- );
48
- }
@@ -1,169 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { store } from '../utils/interactivity';
5
-
6
- const focusableSelectors = [
7
- 'a[href]',
8
- 'area[href]',
9
- 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',
10
- 'select:not([disabled]):not([aria-hidden])',
11
- 'textarea:not([disabled]):not([aria-hidden])',
12
- 'button:not([disabled]):not([aria-hidden])',
13
- 'iframe',
14
- 'object',
15
- 'embed',
16
- '[contenteditable]',
17
- '[tabindex]:not([tabindex^="-"])',
18
- ];
19
-
20
- const openMenu = ( { context, ref }, menuOpenedOn ) => {
21
- context.core.navigation.isMenuOpen[ menuOpenedOn ] = true;
22
- context.core.navigation.previousFocus = ref;
23
- if ( context.core.navigation.overlay ) {
24
- // Add a `has-modal-open` class to the <html> root.
25
- document.documentElement.classList.add( 'has-modal-open' );
26
- }
27
- };
28
-
29
- const closeMenu = ( { context, selectors }, menuClosedOn ) => {
30
- context.core.navigation.isMenuOpen[ menuClosedOn ] = false;
31
- // Check if the menu is still open or not.
32
- if ( ! selectors.core.navigation.isMenuOpen( { context } ) ) {
33
- if (
34
- context.core.navigation.modal.contains(
35
- window.document.activeElement
36
- )
37
- ) {
38
- context.core.navigation.previousFocus.focus();
39
- }
40
- context.core.navigation.modal = null;
41
- context.core.navigation.previousFocus = null;
42
- if ( context.core.navigation.overlay ) {
43
- document.documentElement.classList.remove( 'has-modal-open' );
44
- }
45
- }
46
- };
47
-
48
- store( {
49
- effects: {
50
- core: {
51
- navigation: {
52
- initMenu: ( { context, selectors, ref } ) => {
53
- if ( selectors.core.navigation.isMenuOpen( { context } ) ) {
54
- const focusableElements =
55
- ref.querySelectorAll( focusableSelectors );
56
- context.core.navigation.modal = ref;
57
- context.core.navigation.firstFocusableElement =
58
- focusableElements[ 0 ];
59
- context.core.navigation.lastFocusableElement =
60
- focusableElements[ focusableElements.length - 1 ];
61
- }
62
- },
63
- focusFirstElement: ( { context, selectors, ref } ) => {
64
- if ( selectors.core.navigation.isMenuOpen( { context } ) ) {
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: ( { context, selectors } ) =>
77
- context.core.navigation.overlay &&
78
- selectors.core.navigation.isMenuOpen( { context } )
79
- ? 'dialog'
80
- : '',
81
- isMenuOpen: ( { context } ) =>
82
- // The menu is opened if either `click` or `hover` is true.
83
- Object.values( context.core.navigation.isMenuOpen ).filter(
84
- Boolean
85
- ).length > 0,
86
- },
87
- },
88
- },
89
- actions: {
90
- core: {
91
- navigation: {
92
- openMenuOnHover( args ) {
93
- openMenu( args, 'hover' );
94
- },
95
- closeMenuOnHover( args ) {
96
- closeMenu( args, 'hover' );
97
- },
98
- openMenuOnClick( args ) {
99
- openMenu( args, 'click' );
100
- },
101
- closeMenuOnClick( args ) {
102
- closeMenu( args, 'click' );
103
- },
104
- toggleMenuOnClick: ( args ) => {
105
- const { context } = args;
106
- if ( context.core.navigation.isMenuOpen.click ) {
107
- closeMenu( args, 'click' );
108
- } else {
109
- openMenu( args, 'click' );
110
- }
111
- },
112
- handleMenuKeydown: ( args ) => {
113
- const { context, event } = args;
114
- if ( context.core.navigation.isMenuOpen.click ) {
115
- // If Escape close the menu
116
- if (
117
- event?.key === 'Escape' ||
118
- event?.keyCode === 27
119
- ) {
120
- closeMenu( args, 'click' );
121
- return;
122
- }
123
-
124
- // Trap focus if it is an overlay (main menu)
125
- if (
126
- context.core.navigation.overlay &&
127
- ( event.key === 'Tab' || event.keyCode === 9 )
128
- ) {
129
- // If shift + tab it change the direction
130
- if (
131
- event.shiftKey &&
132
- window.document.activeElement ===
133
- context.core.navigation
134
- .firstFocusableElement
135
- ) {
136
- event.preventDefault();
137
- context.core.navigation.lastFocusableElement.focus();
138
- } else if (
139
- ! event.shiftKey &&
140
- window.document.activeElement ===
141
- context.core.navigation.lastFocusableElement
142
- ) {
143
- event.preventDefault();
144
- context.core.navigation.firstFocusableElement.focus();
145
- }
146
- }
147
- }
148
- },
149
- handleMenuFocusout: ( args ) => {
150
- const { context, event } = args;
151
- // If focus is outside modal, and in the document, close menu
152
- // event.target === The element losing focus
153
- // event.relatedTarget === The element receiving focus (if any)
154
- // When focusout is outsite the document,
155
- // `window.document.activeElement` doesn't change
156
- if (
157
- context.core.navigation.isMenuOpen.click &&
158
- ! context.core.navigation.modal.contains(
159
- event.relatedTarget
160
- ) &&
161
- event.target !== window.document.activeElement
162
- ) {
163
- closeMenu( args, 'click' );
164
- }
165
- },
166
- },
167
- },
168
- },
169
- } );
@@ -1,78 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import MicroModal from 'micromodal';
5
-
6
- // Responsive navigation toggle.
7
- function navigationToggleModal( modal ) {
8
- const dialogContainer = modal.querySelector(
9
- `.wp-block-navigation__responsive-dialog`
10
- );
11
-
12
- const isHidden = 'true' === modal.getAttribute( 'aria-hidden' );
13
-
14
- modal.classList.toggle( 'has-modal-open', ! isHidden );
15
- dialogContainer.toggleAttribute( 'aria-modal', ! isHidden );
16
-
17
- if ( isHidden ) {
18
- dialogContainer.removeAttribute( 'role' );
19
- dialogContainer.removeAttribute( 'aria-modal' );
20
- } else {
21
- dialogContainer.setAttribute( 'role', 'dialog' );
22
- dialogContainer.setAttribute( 'aria-modal', 'true' );
23
- }
24
-
25
- // Add a class to indicate the modal is open.
26
- const htmlElement = document.documentElement;
27
- htmlElement.classList.toggle( 'has-modal-open' );
28
- }
29
-
30
- function isLinkToAnchorOnCurrentPage( node ) {
31
- return (
32
- node.hash &&
33
- node.protocol === window.location.protocol &&
34
- node.host === window.location.host &&
35
- node.pathname === window.location.pathname &&
36
- node.search === window.location.search
37
- );
38
- }
39
-
40
- window.addEventListener( 'load', () => {
41
- MicroModal.init( {
42
- onShow: navigationToggleModal,
43
- onClose: navigationToggleModal,
44
- openClass: 'is-menu-open',
45
- } );
46
-
47
- // Close modal automatically on clicking anchor links inside modal.
48
- const navigationLinks = document.querySelectorAll(
49
- '.wp-block-navigation-item__content'
50
- );
51
-
52
- navigationLinks.forEach( function ( link ) {
53
- // Ignore non-anchor links and anchor links which open on a new tab.
54
- if (
55
- ! isLinkToAnchorOnCurrentPage( link ) ||
56
- link.attributes?.target === '_blank'
57
- ) {
58
- return;
59
- }
60
-
61
- // Find the specific parent modal for this link
62
- // since .close() won't work without an ID if there are
63
- // multiple navigation menus in a post/page.
64
- const modal = link.closest(
65
- '.wp-block-navigation__responsive-container'
66
- );
67
- const modalId = modal?.getAttribute( 'id' );
68
-
69
- link.addEventListener( 'click', () => {
70
- // check if modal exists and is open before trying to close it
71
- // otherwise Micromodal will toggle the `has-modal-open` class
72
- // on the html tag which prevents scrolling
73
- if ( modalId && modal.classList.contains( 'has-modal-open' ) ) {
74
- MicroModal.close( modalId );
75
- }
76
- } );
77
- } );
78
- } );
@@ -1 +0,0 @@
1
- export const directivePrefix = 'wp';
@@ -1,200 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { useContext, useMemo, useEffect } from 'preact/hooks';
5
- import { deepSignal, peek } from 'deepsignal';
6
- /**
7
- * Internal dependencies
8
- */
9
- import { createPortal } from './portals.js';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { useSignalEffect } from './utils';
15
- import { directive } from './hooks';
16
-
17
- const isObject = ( item ) =>
18
- item && typeof item === 'object' && ! Array.isArray( item );
19
-
20
- const mergeDeepSignals = ( target, source ) => {
21
- for ( const k in source ) {
22
- if ( typeof peek( target, k ) === 'undefined' ) {
23
- target[ `$${ k }` ] = source[ `$${ k }` ];
24
- } else if (
25
- isObject( peek( target, k ) ) &&
26
- isObject( peek( source, k ) )
27
- ) {
28
- mergeDeepSignals(
29
- target[ `$${ k }` ].peek(),
30
- source[ `$${ k }` ].peek()
31
- );
32
- }
33
- }
34
- };
35
-
36
- export default () => {
37
- // data-wp-context
38
- directive(
39
- 'context',
40
- ( {
41
- directives: {
42
- context: { default: context },
43
- },
44
- props: { children },
45
- context: inherited,
46
- } ) => {
47
- const { Provider } = inherited;
48
- const inheritedValue = useContext( inherited );
49
- const value = useMemo( () => {
50
- const localValue = deepSignal( context );
51
- mergeDeepSignals( localValue, inheritedValue );
52
- return localValue;
53
- }, [ context, inheritedValue ] );
54
-
55
- return <Provider value={ value }>{ children }</Provider>;
56
- },
57
- { priority: 5 }
58
- );
59
-
60
- // data-wp-body
61
- directive( 'body', ( { props: { children }, context: inherited } ) => {
62
- const { Provider } = inherited;
63
- const inheritedValue = useContext( inherited );
64
- return createPortal(
65
- <Provider value={ inheritedValue }>{ children }</Provider>,
66
- document.body
67
- );
68
- } );
69
-
70
- // data-wp-effect--[name]
71
- directive( 'effect', ( { directives: { effect }, context, evaluate } ) => {
72
- const contextValue = useContext( context );
73
- Object.values( effect ).forEach( ( path ) => {
74
- useSignalEffect( () => {
75
- return evaluate( path, { context: contextValue } );
76
- } );
77
- } );
78
- } );
79
-
80
- // data-wp-init--[name]
81
- directive( 'init', ( { directives: { init }, context, evaluate } ) => {
82
- const contextValue = useContext( context );
83
- Object.values( init ).forEach( ( path ) => {
84
- useEffect( () => {
85
- return evaluate( path, { context: contextValue } );
86
- }, [] );
87
- } );
88
- } );
89
-
90
- // data-wp-on--[event]
91
- directive( 'on', ( { directives: { on }, element, evaluate, context } ) => {
92
- const contextValue = useContext( context );
93
- Object.entries( on ).forEach( ( [ name, path ] ) => {
94
- element.props[ `on${ name }` ] = ( event ) => {
95
- evaluate( path, { event, context: contextValue } );
96
- };
97
- } );
98
- } );
99
-
100
- // data-wp-class--[classname]
101
- directive(
102
- 'class',
103
- ( {
104
- directives: { class: className },
105
- element,
106
- evaluate,
107
- context,
108
- } ) => {
109
- const contextValue = useContext( context );
110
- Object.keys( className )
111
- .filter( ( n ) => n !== 'default' )
112
- .forEach( ( name ) => {
113
- const result = evaluate( className[ name ], {
114
- className: name,
115
- context: contextValue,
116
- } );
117
- const currentClass = element.props.class || '';
118
- const classFinder = new RegExp(
119
- `(^|\\s)${ name }(\\s|$)`,
120
- 'g'
121
- );
122
- if ( ! result )
123
- element.props.class = currentClass
124
- .replace( classFinder, ' ' )
125
- .trim();
126
- else if ( ! classFinder.test( currentClass ) )
127
- element.props.class = currentClass
128
- ? `${ currentClass } ${ name }`
129
- : name;
130
-
131
- useEffect( () => {
132
- // This seems necessary because Preact doesn't change the class
133
- // names on the hydration, so we have to do it manually. It doesn't
134
- // need deps because it only needs to do it the first time.
135
- if ( ! result ) {
136
- element.ref.current.classList.remove( name );
137
- } else {
138
- element.ref.current.classList.add( name );
139
- }
140
- }, [] );
141
- } );
142
- }
143
- );
144
-
145
- // data-wp-bind--[attribute]
146
- directive(
147
- 'bind',
148
- ( { directives: { bind }, element, context, evaluate } ) => {
149
- const contextValue = useContext( context );
150
- Object.entries( bind )
151
- .filter( ( n ) => n !== 'default' )
152
- .forEach( ( [ attribute, path ] ) => {
153
- const result = evaluate( path, {
154
- context: contextValue,
155
- } );
156
- element.props[ attribute ] = result;
157
-
158
- // This seems necessary because Preact doesn't change the attributes
159
- // on the hydration, so we have to do it manually. It doesn't need
160
- // deps because it only needs to do it the first time.
161
- useEffect( () => {
162
- // aria- and data- attributes have no boolean representation.
163
- // A `false` value is different from the attribute not being
164
- // present, so we can't remove it.
165
- // We follow Preact's logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136
166
- if ( result === false && attribute[ 4 ] !== '-' ) {
167
- element.ref.current.removeAttribute( attribute );
168
- } else {
169
- element.ref.current.setAttribute(
170
- attribute,
171
- result === true && attribute[ 4 ] !== '-'
172
- ? ''
173
- : result
174
- );
175
- }
176
- }, [] );
177
- } );
178
- }
179
- );
180
-
181
- // data-wp-ignore
182
- directive(
183
- 'ignore',
184
- ( {
185
- element: {
186
- type: Type,
187
- props: { innerHTML, ...rest },
188
- },
189
- } ) => {
190
- // Preserve the initial inner HTML.
191
- const cached = useMemo( () => innerHTML, [] );
192
- return (
193
- <Type
194
- dangerouslySetInnerHTML={ { __html: cached } }
195
- { ...rest }
196
- />
197
- );
198
- }
199
- );
200
- };
@@ -1,145 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { h, options, createContext, cloneElement } from 'preact';
5
- import { useRef, useMemo } from 'preact/hooks';
6
- /**
7
- * Internal dependencies
8
- */
9
- import { rawStore as store } from './store';
10
-
11
- // Main context.
12
- const context = createContext( {} );
13
-
14
- // WordPress Directives.
15
- const directiveMap = {};
16
- const directivePriorities = {};
17
- export const directive = ( name, cb, { priority = 10 } = {} ) => {
18
- directiveMap[ name ] = cb;
19
- directivePriorities[ name ] = priority;
20
- };
21
-
22
- // Resolve the path to some property of the store object.
23
- const resolve = ( path, ctx ) => {
24
- let current = { ...store, context: ctx };
25
- path.split( '.' ).forEach( ( p ) => ( current = current[ p ] ) );
26
- return current;
27
- };
28
-
29
- // Generate the evaluate function.
30
- const getEvaluate =
31
- ( { ref } = {} ) =>
32
- ( path, extraArgs = {} ) => {
33
- // If path starts with !, remove it and save a flag.
34
- const hasNegationOperator =
35
- path[ 0 ] === '!' && !! ( path = path.slice( 1 ) );
36
- const value = resolve( path, extraArgs.context );
37
- const returnValue =
38
- typeof value === 'function'
39
- ? value( {
40
- ref: ref.current,
41
- ...store,
42
- ...extraArgs,
43
- } )
44
- : value;
45
- return hasNegationOperator ? ! returnValue : returnValue;
46
- };
47
-
48
- // Separate directives by priority. The resulting array contains objects
49
- // of directives grouped by same priority, and sorted in ascending order.
50
- const usePriorityLevels = ( directives ) =>
51
- useMemo( () => {
52
- const byPriority = Object.entries( directives ).reduce(
53
- ( acc, [ name, values ] ) => {
54
- const priority = directivePriorities[ name ];
55
- if ( ! acc[ priority ] ) acc[ priority ] = {};
56
- acc[ priority ][ name ] = values;
57
-
58
- return acc;
59
- },
60
- {}
61
- );
62
-
63
- return Object.entries( byPriority )
64
- .sort( ( [ p1 ], [ p2 ] ) => p1 - p2 )
65
- .map( ( [ , obj ] ) => obj );
66
- }, [ directives ] );
67
-
68
- // Directive wrapper.
69
- const Directive = ( { type, directives, props: originalProps } ) => {
70
- const ref = useRef( null );
71
- const element = h( type, { ...originalProps, ref } );
72
- const evaluate = useMemo( () => getEvaluate( { ref } ), [] );
73
-
74
- // Add wrappers recursively for each priority level.
75
- const byPriorityLevel = usePriorityLevels( directives );
76
- return (
77
- <RecursivePriorityLevel
78
- directives={ byPriorityLevel }
79
- element={ element }
80
- evaluate={ evaluate }
81
- originalProps={ originalProps }
82
- />
83
- );
84
- };
85
-
86
- // Priority level wrapper.
87
- const RecursivePriorityLevel = ( {
88
- directives: [ directives, ...rest ],
89
- element,
90
- evaluate,
91
- originalProps,
92
- } ) => {
93
- // This element needs to be a fresh copy so we are not modifying an already
94
- // rendered element with Preact's internal properties initialized. This
95
- // prevents an error with changes in `element.props.children` not being
96
- // reflected in `element.__k`.
97
- element = cloneElement( element );
98
-
99
- // Recursively render the wrapper for the next priority level.
100
- //
101
- // Note that, even though we're instantiating a vnode with a
102
- // `RecursivePriorityLevel` here, its render function will not be executed
103
- // just yet. Actually, it will be delayed until the current render function
104
- // has finished. That ensures directives in the current priorty level have
105
- // run (and thus modified the passed `element`) before the next level.
106
- const children =
107
- rest.length > 0 ? (
108
- <RecursivePriorityLevel
109
- directives={ rest }
110
- element={ element }
111
- evaluate={ evaluate }
112
- originalProps={ originalProps }
113
- />
114
- ) : (
115
- element
116
- );
117
-
118
- const props = { ...originalProps, children };
119
- const directiveArgs = { directives, props, element, context, evaluate };
120
-
121
- for ( const d in directives ) {
122
- const wrapper = directiveMap[ d ]?.( directiveArgs );
123
- if ( wrapper !== undefined ) props.children = wrapper;
124
- }
125
-
126
- return props.children;
127
- };
128
-
129
- // Preact Options Hook called each time a vnode is created.
130
- const old = options.vnode;
131
- options.vnode = ( vnode ) => {
132
- if ( vnode.props.__directives ) {
133
- const props = vnode.props;
134
- const directives = props.__directives;
135
- delete props.__directives;
136
- vnode.props = {
137
- type: vnode.type,
138
- directives,
139
- props,
140
- };
141
- vnode.type = Directive;
142
- }
143
-
144
- if ( old ) old( vnode );
145
- };
@@ -1,22 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { hydrate } from 'preact';
5
- /**
6
- * Internal dependencies
7
- */
8
- import { toVdom, hydratedIslands } from './vdom';
9
- import { createRootFragment } from './utils';
10
- import { directivePrefix } from './constants';
11
-
12
- export const init = async () => {
13
- document
14
- .querySelectorAll( `[data-${ directivePrefix }-interactive]` )
15
- .forEach( ( node ) => {
16
- if ( ! hydratedIslands.has( node ) ) {
17
- const fragment = createRootFragment( node.parentNode, node );
18
- const vdom = toVdom( node );
19
- hydrate( vdom, fragment );
20
- }
21
- } );
22
- };
@@ -1,15 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import registerDirectives from './directives';
5
- import { init } from './hydration';
6
- export { store } from './store';
7
-
8
- /**
9
- * Initialize the Interactivity API.
10
- */
11
- registerDirectives();
12
-
13
- document.addEventListener( 'DOMContentLoaded', async () => {
14
- await init();
15
- } );