@wordpress/block-library 8.9.0 → 8.11.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 (502) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/block/edit.native.js +17 -10
  3. package/build/block/edit.native.js.map +1 -1
  4. package/build/code/index.js +1 -0
  5. package/build/code/index.js.map +1 -1
  6. package/build/column/index.js +1 -1
  7. package/build/columns/transforms.js +1 -5
  8. package/build/columns/transforms.js.map +1 -1
  9. package/build/comment-author-name/edit.js +1 -1
  10. package/build/comment-author-name/edit.js.map +1 -1
  11. package/build/comment-edit-link/edit.js +1 -1
  12. package/build/comment-edit-link/edit.js.map +1 -1
  13. package/build/cover/edit/inspector-controls.js +1 -1
  14. package/build/cover/edit/inspector-controls.js.map +1 -1
  15. package/build/cover/edit/resizable-cover-popover.js +3 -3
  16. package/build/cover/edit/resizable-cover-popover.js.map +1 -1
  17. package/build/cover/index.js +1 -1
  18. package/build/cover/variations.js +1 -1
  19. package/build/cover/variations.js.map +1 -1
  20. package/build/details/edit.js +19 -5
  21. package/build/details/edit.js.map +1 -1
  22. package/build/details/index.js +14 -10
  23. package/build/details/index.js.map +1 -1
  24. package/build/details/save.js +4 -1
  25. package/build/details/save.js.map +1 -1
  26. package/build/embed/variations.js +2 -2
  27. package/build/embed/variations.js.map +1 -1
  28. package/build/file/interactivity.js +19 -0
  29. package/build/file/interactivity.js.map +1 -0
  30. package/build/file/{utils.js → utils/index.js} +1 -1
  31. package/build/file/utils/index.js.map +1 -0
  32. package/build/file/view.js +1 -1
  33. package/build/file/view.js.map +1 -1
  34. package/build/freeform/modal.js +20 -17
  35. package/build/freeform/modal.js.map +1 -1
  36. package/build/gallery/edit.js +2 -8
  37. package/build/gallery/edit.js.map +1 -1
  38. package/build/gallery/v1/edit.js +1 -7
  39. package/build/gallery/v1/edit.js.map +1 -1
  40. package/build/gallery/v1/gallery-image.native.js +1 -3
  41. package/build/gallery/v1/gallery-image.native.js.map +1 -1
  42. package/build/group/transforms.js +0 -5
  43. package/build/group/transforms.js.map +1 -1
  44. package/build/image/deprecated.js +2 -4
  45. package/build/image/deprecated.js.map +1 -1
  46. package/build/image/edit.js +13 -11
  47. package/build/image/edit.js.map +1 -1
  48. package/build/image/image.js +7 -12
  49. package/build/image/image.js.map +1 -1
  50. package/build/image/index.js +3 -0
  51. package/build/image/index.js.map +1 -1
  52. package/build/image/interactivity.js +102 -0
  53. package/build/image/interactivity.js.map +1 -0
  54. package/build/image/save.js +2 -4
  55. package/build/image/save.js.map +1 -1
  56. package/build/image/utils.js +10 -18
  57. package/build/image/utils.js.map +1 -1
  58. package/build/index.js +0 -6
  59. package/build/index.js.map +1 -1
  60. package/build/index.native.js +1 -1
  61. package/build/index.native.js.map +1 -1
  62. package/build/latest-posts/edit.native.js +1 -3
  63. package/build/latest-posts/edit.native.js.map +1 -1
  64. package/build/list/edit.js +1 -1
  65. package/build/list/edit.js.map +1 -1
  66. package/build/list-item/edit.native.js +1 -1
  67. package/build/list-item/edit.native.js.map +1 -1
  68. package/build/list-item/transforms.js +4 -1
  69. package/build/list-item/transforms.js.map +1 -1
  70. package/build/list-item/utils.js +5 -1
  71. package/build/list-item/utils.js.map +1 -1
  72. package/build/loginout/index.js +11 -1
  73. package/build/loginout/index.js.map +1 -1
  74. package/build/media-text/deprecated.js +4 -6
  75. package/build/media-text/deprecated.js.map +1 -1
  76. package/build/media-text/edit.js +13 -11
  77. package/build/media-text/edit.js.map +1 -1
  78. package/build/media-text/media-container.js +3 -3
  79. package/build/media-text/media-container.js.map +1 -1
  80. package/build/media-text/save.js +1 -3
  81. package/build/media-text/save.js.map +1 -1
  82. package/build/navigation/constants.js +15 -0
  83. package/build/navigation/constants.js.map +1 -0
  84. package/build/navigation/edit/index.js +16 -26
  85. package/build/navigation/edit/index.js.map +1 -1
  86. package/build/navigation/edit/inner-blocks.js +5 -7
  87. package/build/navigation/edit/inner-blocks.js.map +1 -1
  88. package/build/navigation/edit/leaf-more-menu.js +148 -0
  89. package/build/navigation/edit/leaf-more-menu.js.map +1 -0
  90. package/build/navigation/edit/menu-inspector-controls.js +53 -8
  91. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  92. package/build/navigation/edit/navigation-menu-delete-control.js +6 -6
  93. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  94. package/build/navigation/edit/unsaved-inner-blocks.js +12 -25
  95. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  96. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
  97. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  98. package/build/navigation/interactivity.js +157 -0
  99. package/build/navigation/interactivity.js.map +1 -0
  100. package/build/navigation-link/edit.js +7 -5
  101. package/build/navigation-link/edit.js.map +1 -1
  102. package/build/navigation-link/update-attributes.js +5 -5
  103. package/build/navigation-link/update-attributes.js.map +1 -1
  104. package/build/navigation-submenu/edit.js +7 -5
  105. package/build/navigation-submenu/edit.js.map +1 -1
  106. package/build/paragraph/index.js +5 -1
  107. package/build/paragraph/index.js.map +1 -1
  108. package/build/paragraph/transforms.js +5 -1
  109. package/build/paragraph/transforms.js.map +1 -1
  110. package/build/pattern/edit.js +42 -8
  111. package/build/pattern/edit.js.map +1 -1
  112. package/build/pattern/index.js +12 -5
  113. package/build/pattern/index.js.map +1 -1
  114. package/build/pattern/v1/edit.js +57 -0
  115. package/build/pattern/v1/edit.js.map +1 -0
  116. package/build/post-author-name/edit.js +1 -1
  117. package/build/post-author-name/edit.js.map +1 -1
  118. package/build/post-featured-image/edit.js +1 -2
  119. package/build/post-featured-image/edit.js.map +1 -1
  120. package/build/post-featured-image/overlay.js +5 -0
  121. package/build/post-featured-image/overlay.js.map +1 -1
  122. package/build/post-title/edit.js +24 -7
  123. package/build/post-title/edit.js.map +1 -1
  124. package/build/preformatted/edit.native.js +3 -2
  125. package/build/preformatted/edit.native.js.map +1 -1
  126. package/build/quote/transforms.js +23 -37
  127. package/build/quote/transforms.js.map +1 -1
  128. package/build/read-more/edit.js +1 -1
  129. package/build/read-more/edit.js.map +1 -1
  130. package/build/search/edit.js +9 -1
  131. package/build/search/edit.js.map +1 -1
  132. package/build/site-title/edit/index.js +1 -1
  133. package/build/site-title/edit/index.js.map +1 -1
  134. package/build/social-link/edit.js +21 -4
  135. package/build/social-link/edit.js.map +1 -1
  136. package/build/social-links/edit.js +2 -2
  137. package/build/social-links/edit.js.map +1 -1
  138. package/build/template-part/edit/index.js +1 -7
  139. package/build/template-part/edit/index.js.map +1 -1
  140. package/build/template-part/edit/utils/hooks.js +2 -2
  141. package/build/template-part/edit/utils/hooks.js.map +1 -1
  142. package/build/utils/interactivity/constants.js +9 -0
  143. package/build/utils/interactivity/constants.js.map +1 -0
  144. package/build/utils/interactivity/directives.js +236 -0
  145. package/build/utils/interactivity/directives.js.map +1 -0
  146. package/build/utils/interactivity/hooks.js +176 -0
  147. package/build/utils/interactivity/hooks.js.map +1 -0
  148. package/build/utils/interactivity/hydration.js +34 -0
  149. package/build/utils/interactivity/hydration.js.map +1 -0
  150. package/build/utils/interactivity/index.js +34 -0
  151. package/build/utils/interactivity/index.js.map +1 -0
  152. package/build/utils/interactivity/portals.js +108 -0
  153. package/build/utils/interactivity/portals.js.map +1 -0
  154. package/build/utils/interactivity/store.js +67 -0
  155. package/build/utils/interactivity/store.js.map +1 -0
  156. package/build/utils/interactivity/utils.js +87 -0
  157. package/build/utils/interactivity/utils.js.map +1 -0
  158. package/build/utils/interactivity/vdom.js +109 -0
  159. package/build/utils/interactivity/vdom.js.map +1 -0
  160. package/build-module/block/edit.native.js +7 -1
  161. package/build-module/block/edit.native.js.map +1 -1
  162. package/build-module/code/index.js +1 -0
  163. package/build-module/code/index.js.map +1 -1
  164. package/build-module/column/index.js +1 -1
  165. package/build-module/columns/transforms.js +1 -5
  166. package/build-module/columns/transforms.js.map +1 -1
  167. package/build-module/comment-author-name/edit.js +1 -1
  168. package/build-module/comment-author-name/edit.js.map +1 -1
  169. package/build-module/comment-edit-link/edit.js +1 -1
  170. package/build-module/comment-edit-link/edit.js.map +1 -1
  171. package/build-module/cover/edit/inspector-controls.js +1 -1
  172. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  173. package/build-module/cover/edit/resizable-cover-popover.js +3 -3
  174. package/build-module/cover/edit/resizable-cover-popover.js.map +1 -1
  175. package/build-module/cover/index.js +1 -1
  176. package/build-module/cover/variations.js +1 -1
  177. package/build-module/cover/variations.js.map +1 -1
  178. package/build-module/details/edit.js +20 -6
  179. package/build-module/details/edit.js.map +1 -1
  180. package/build-module/details/index.js +14 -10
  181. package/build-module/details/index.js.map +1 -1
  182. package/build-module/details/save.js +5 -2
  183. package/build-module/details/save.js.map +1 -1
  184. package/build-module/embed/variations.js +2 -2
  185. package/build-module/embed/variations.js.map +1 -1
  186. package/build-module/file/interactivity.js +15 -0
  187. package/build-module/file/interactivity.js.map +1 -0
  188. package/build-module/file/{utils.js → utils/index.js} +1 -1
  189. package/build-module/file/utils/index.js.map +1 -0
  190. package/build-module/file/view.js +1 -1
  191. package/build-module/file/view.js.map +1 -1
  192. package/build-module/freeform/modal.js +19 -18
  193. package/build-module/freeform/modal.js.map +1 -1
  194. package/build-module/gallery/edit.js +2 -8
  195. package/build-module/gallery/edit.js.map +1 -1
  196. package/build-module/gallery/v1/edit.js +1 -6
  197. package/build-module/gallery/v1/edit.js.map +1 -1
  198. package/build-module/gallery/v1/gallery-image.native.js +1 -2
  199. package/build-module/gallery/v1/gallery-image.native.js.map +1 -1
  200. package/build-module/group/transforms.js +0 -5
  201. package/build-module/group/transforms.js.map +1 -1
  202. package/build-module/image/deprecated.js +2 -3
  203. package/build-module/image/deprecated.js.map +1 -1
  204. package/build-module/image/edit.js +12 -11
  205. package/build-module/image/edit.js.map +1 -1
  206. package/build-module/image/image.js +7 -11
  207. package/build-module/image/image.js.map +1 -1
  208. package/build-module/image/index.js +3 -0
  209. package/build-module/image/index.js.map +1 -1
  210. package/build-module/image/interactivity.js +99 -0
  211. package/build-module/image/interactivity.js.map +1 -0
  212. package/build-module/image/save.js +2 -3
  213. package/build-module/image/save.js.map +1 -1
  214. package/build-module/image/utils.js +10 -17
  215. package/build-module/image/utils.js.map +1 -1
  216. package/build-module/index.js +0 -4
  217. package/build-module/index.js.map +1 -1
  218. package/build-module/index.native.js +1 -1
  219. package/build-module/index.native.js.map +1 -1
  220. package/build-module/latest-posts/edit.native.js +1 -2
  221. package/build-module/latest-posts/edit.native.js.map +1 -1
  222. package/build-module/list/edit.js +1 -1
  223. package/build-module/list/edit.js.map +1 -1
  224. package/build-module/list-item/edit.native.js +1 -1
  225. package/build-module/list-item/edit.native.js.map +1 -1
  226. package/build-module/list-item/transforms.js +5 -2
  227. package/build-module/list-item/transforms.js.map +1 -1
  228. package/build-module/list-item/utils.js +5 -1
  229. package/build-module/list-item/utils.js.map +1 -1
  230. package/build-module/loginout/index.js +11 -1
  231. package/build-module/loginout/index.js.map +1 -1
  232. package/build-module/media-text/deprecated.js +4 -5
  233. package/build-module/media-text/deprecated.js.map +1 -1
  234. package/build-module/media-text/edit.js +13 -12
  235. package/build-module/media-text/edit.js.map +1 -1
  236. package/build-module/media-text/media-container.js +3 -3
  237. package/build-module/media-text/media-container.js.map +1 -1
  238. package/build-module/media-text/save.js +1 -2
  239. package/build-module/media-text/save.js.map +1 -1
  240. package/build-module/navigation/constants.js +6 -0
  241. package/build-module/navigation/constants.js.map +1 -0
  242. package/build-module/navigation/edit/index.js +18 -27
  243. package/build-module/navigation/edit/index.js.map +1 -1
  244. package/build-module/navigation/edit/inner-blocks.js +2 -4
  245. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  246. package/build-module/navigation/edit/leaf-more-menu.js +132 -0
  247. package/build-module/navigation/edit/leaf-more-menu.js.map +1 -0
  248. package/build-module/navigation/edit/menu-inspector-controls.js +52 -9
  249. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  250. package/build-module/navigation/edit/navigation-menu-delete-control.js +7 -7
  251. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  252. package/build-module/navigation/edit/unsaved-inner-blocks.js +9 -20
  253. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  254. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
  255. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  256. package/build-module/navigation/interactivity.js +154 -0
  257. package/build-module/navigation/interactivity.js.map +1 -0
  258. package/build-module/navigation-link/edit.js +7 -5
  259. package/build-module/navigation-link/edit.js.map +1 -1
  260. package/build-module/navigation-link/update-attributes.js +4 -4
  261. package/build-module/navigation-link/update-attributes.js.map +1 -1
  262. package/build-module/navigation-submenu/edit.js +7 -5
  263. package/build-module/navigation-submenu/edit.js.map +1 -1
  264. package/build-module/paragraph/index.js +5 -1
  265. package/build-module/paragraph/index.js.map +1 -1
  266. package/build-module/paragraph/transforms.js +5 -1
  267. package/build-module/paragraph/transforms.js.map +1 -1
  268. package/build-module/pattern/edit.js +42 -9
  269. package/build-module/pattern/edit.js.map +1 -1
  270. package/build-module/pattern/index.js +12 -3
  271. package/build-module/pattern/index.js.map +1 -1
  272. package/build-module/pattern/v1/edit.js +48 -0
  273. package/build-module/pattern/v1/edit.js.map +1 -0
  274. package/build-module/post-author-name/edit.js +1 -1
  275. package/build-module/post-author-name/edit.js.map +1 -1
  276. package/build-module/post-featured-image/edit.js +1 -2
  277. package/build-module/post-featured-image/edit.js.map +1 -1
  278. package/build-module/post-featured-image/overlay.js +5 -0
  279. package/build-module/post-featured-image/overlay.js.map +1 -1
  280. package/build-module/post-title/edit.js +23 -7
  281. package/build-module/post-title/edit.js.map +1 -1
  282. package/build-module/preformatted/edit.native.js +3 -2
  283. package/build-module/preformatted/edit.native.js.map +1 -1
  284. package/build-module/quote/transforms.js +23 -37
  285. package/build-module/quote/transforms.js.map +1 -1
  286. package/build-module/read-more/edit.js +1 -1
  287. package/build-module/read-more/edit.js.map +1 -1
  288. package/build-module/search/edit.js +9 -1
  289. package/build-module/search/edit.js.map +1 -1
  290. package/build-module/site-title/edit/index.js +1 -1
  291. package/build-module/site-title/edit/index.js.map +1 -1
  292. package/build-module/social-link/edit.js +20 -5
  293. package/build-module/social-link/edit.js.map +1 -1
  294. package/build-module/social-links/edit.js +2 -2
  295. package/build-module/social-links/edit.js.map +1 -1
  296. package/build-module/template-part/edit/index.js +1 -6
  297. package/build-module/template-part/edit/index.js.map +1 -1
  298. package/build-module/template-part/edit/utils/hooks.js +1 -1
  299. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  300. package/build-module/utils/interactivity/constants.js +2 -0
  301. package/build-module/utils/interactivity/constants.js.map +1 -0
  302. package/build-module/utils/interactivity/directives.js +220 -0
  303. package/build-module/utils/interactivity/directives.js.map +1 -0
  304. package/build-module/utils/interactivity/hooks.js +162 -0
  305. package/build-module/utils/interactivity/hooks.js.map +1 -0
  306. package/build-module/utils/interactivity/hydration.js +21 -0
  307. package/build-module/utils/interactivity/hydration.js.map +1 -0
  308. package/build-module/utils/interactivity/index.js +17 -0
  309. package/build-module/utils/interactivity/index.js.map +1 -0
  310. package/build-module/utils/interactivity/portals.js +100 -0
  311. package/build-module/utils/interactivity/portals.js.map +1 -0
  312. package/build-module/utils/interactivity/store.js +56 -0
  313. package/build-module/utils/interactivity/store.js.map +1 -0
  314. package/build-module/utils/interactivity/utils.js +75 -0
  315. package/build-module/utils/interactivity/utils.js.map +1 -0
  316. package/build-module/utils/interactivity/vdom.js +97 -0
  317. package/build-module/utils/interactivity/vdom.js.map +1 -0
  318. package/build-style/common-rtl.css +1 -1
  319. package/build-style/common.css +1 -1
  320. package/build-style/cover/style-rtl.css +3 -2
  321. package/build-style/cover/style.css +3 -2
  322. package/build-style/{details-summary → details}/editor-rtl.css +1 -1
  323. package/build-style/{details-summary → details}/editor.css +1 -1
  324. package/build-style/details/style-rtl.css +14 -0
  325. package/build-style/details/style.css +14 -0
  326. package/build-style/editor-rtl.css +71 -5
  327. package/build-style/editor.css +71 -5
  328. package/build-style/file/editor-rtl.css +3 -0
  329. package/build-style/file/editor.css +3 -0
  330. package/build-style/freeform/editor-rtl.css +29 -0
  331. package/build-style/freeform/editor.css +29 -0
  332. package/build-style/gallery/editor-rtl.css +0 -4
  333. package/build-style/gallery/editor.css +0 -4
  334. package/build-style/gallery/style-rtl.css +2 -4
  335. package/build-style/gallery/style.css +2 -4
  336. package/build-style/image/style-rtl.css +98 -0
  337. package/build-style/image/style.css +98 -0
  338. package/build-style/navigation/editor-rtl.css +36 -0
  339. package/build-style/navigation/editor.css +36 -0
  340. package/build-style/post-comments-form/style-rtl.css +1 -1
  341. package/build-style/post-comments-form/style.css +1 -1
  342. package/build-style/search/editor-rtl.css +1 -0
  343. package/build-style/search/editor.css +1 -0
  344. package/build-style/site-logo/editor-rtl.css +1 -0
  345. package/build-style/site-logo/editor.css +1 -0
  346. package/build-style/style-rtl.css +116 -10
  347. package/build-style/style.css +116 -10
  348. package/build-style/video/style-rtl.css +1 -2
  349. package/build-style/video/style.css +1 -2
  350. package/package.json +37 -33
  351. package/src/block/edit.native.js +18 -4
  352. package/src/buttons/test/edit.native.js +0 -9
  353. package/src/code/block.json +1 -0
  354. package/src/column/block.json +1 -1
  355. package/src/columns/test/__snapshots__/transforms.native.js.snap +1 -1
  356. package/src/columns/test/transforms.native.js +3 -5
  357. package/src/columns/transforms.js +2 -8
  358. package/src/comment-author-name/edit.js +1 -1
  359. package/src/comment-edit-link/edit.js +1 -1
  360. package/src/comment-template/index.php +8 -7
  361. package/src/comments/index.php +1 -6
  362. package/src/cover/block.json +1 -1
  363. package/src/cover/edit/inspector-controls.js +56 -54
  364. package/src/cover/edit/resizable-cover-popover.js +2 -1
  365. package/src/cover/style.scss +5 -0
  366. package/src/cover/test/edit.js +56 -2
  367. package/src/cover/variations.js +1 -3
  368. package/src/details/block.json +8 -6
  369. package/src/details/edit.js +27 -5
  370. package/src/details/editor.scss +3 -0
  371. package/src/details/index.js +10 -5
  372. package/src/details/save.js +5 -1
  373. package/src/details/style.scss +16 -0
  374. package/src/editor.scss +1 -1
  375. package/src/embed/variations.js +2 -2
  376. package/src/file/editor.scss +4 -0
  377. package/src/file/interactivity.js +15 -0
  378. package/src/file/view.js +4 -1
  379. package/src/freeform/editor.scss +45 -0
  380. package/src/freeform/modal.js +22 -19
  381. package/src/gallery/edit.js +5 -8
  382. package/src/gallery/editor.scss +0 -6
  383. package/src/gallery/test/index.native.js +48 -3
  384. package/src/gallery/v1/edit.js +1 -6
  385. package/src/gallery/v1/gallery-image.native.js +1 -2
  386. package/src/group/test/__snapshots__/transforms.native.js.snap +1 -1
  387. package/src/group/test/transforms.native.js +3 -5
  388. package/src/group/transforms.js +0 -7
  389. package/src/image/block.json +3 -0
  390. package/src/image/deprecated.js +2 -3
  391. package/src/image/edit.js +18 -18
  392. package/src/image/image.js +8 -11
  393. package/src/image/index.php +75 -2
  394. package/src/image/interactivity.js +113 -0
  395. package/src/image/save.js +4 -3
  396. package/src/image/style.scss +113 -0
  397. package/src/image/test/edit.native.js +38 -16
  398. package/src/image/utils.js +11 -18
  399. package/src/index.js +0 -4
  400. package/src/index.native.js +1 -0
  401. package/src/latest-posts/edit.native.js +1 -4
  402. package/src/list/edit.js +1 -1
  403. package/src/list/test/edit.native.js +80 -1
  404. package/src/list-item/edit.native.js +1 -1
  405. package/src/list-item/transforms.js +4 -2
  406. package/src/loginout/block.json +11 -1
  407. package/src/media-text/deprecated.js +4 -5
  408. package/src/media-text/edit.js +12 -10
  409. package/src/media-text/media-container.js +3 -3
  410. package/src/media-text/save.js +1 -2
  411. package/src/navigation/constants.js +21 -0
  412. package/src/navigation/edit/index.js +71 -83
  413. package/src/navigation/edit/inner-blocks.js +6 -16
  414. package/src/navigation/edit/leaf-more-menu.js +170 -0
  415. package/src/navigation/edit/menu-inspector-controls.js +78 -10
  416. package/src/navigation/edit/navigation-menu-delete-control.js +29 -29
  417. package/src/navigation/edit/unsaved-inner-blocks.js +12 -40
  418. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
  419. package/src/navigation/editor.scss +10 -0
  420. package/src/navigation/index.php +213 -204
  421. package/src/navigation/interactivity.js +151 -0
  422. package/src/navigation-link/edit.js +9 -3
  423. package/src/navigation-link/update-attributes.js +2 -2
  424. package/src/navigation-submenu/edit.js +9 -3
  425. package/src/paragraph/block.json +5 -1
  426. package/src/pattern/block.json +4 -0
  427. package/src/pattern/edit.js +53 -16
  428. package/src/pattern/index.js +5 -4
  429. package/src/pattern/index.php +14 -1
  430. package/src/pattern/v1/edit.js +57 -0
  431. package/src/post-author-name/edit.js +1 -1
  432. package/src/post-comments-form/style.scss +3 -1
  433. package/src/post-featured-image/edit.js +1 -1
  434. package/src/post-featured-image/index.php +1 -1
  435. package/src/post-featured-image/overlay.js +4 -0
  436. package/src/post-terms/index.php +2 -2
  437. package/src/post-title/edit.js +57 -44
  438. package/src/preformatted/edit.native.js +1 -3
  439. package/src/quote/test/__snapshots__/transforms.native.js.snap +1 -1
  440. package/src/quote/test/transforms.native.js +3 -5
  441. package/src/quote/transforms.js +9 -19
  442. package/src/read-more/edit.js +1 -1
  443. package/src/search/edit.js +9 -4
  444. package/src/search/editor.scss +1 -0
  445. package/src/site-logo/editor.scss +2 -1
  446. package/src/site-title/edit/index.js +1 -1
  447. package/src/social-link/edit.js +51 -26
  448. package/src/social-links/edit.js +33 -31
  449. package/src/style.scss +0 -1
  450. package/src/template-part/edit/index.js +4 -6
  451. package/src/template-part/edit/utils/hooks.js +1 -1
  452. package/src/template-part/index.php +22 -7
  453. package/src/utils/interactivity/constants.js +1 -0
  454. package/src/utils/interactivity/directives.js +200 -0
  455. package/src/utils/interactivity/hooks.js +145 -0
  456. package/src/utils/interactivity/hydration.js +22 -0
  457. package/src/utils/interactivity/index.js +17 -0
  458. package/src/utils/interactivity/portals.js +98 -0
  459. package/src/utils/interactivity/store.js +45 -0
  460. package/src/utils/interactivity/utils.js +66 -0
  461. package/src/utils/interactivity/vdom.js +94 -0
  462. package/tsconfig.json +1 -0
  463. package/tsconfig.tsbuildinfo +1 -1
  464. package/build/details-content/edit.js +0 -34
  465. package/build/details-content/edit.js.map +0 -1
  466. package/build/details-content/index.js +0 -94
  467. package/build/details-content/index.js.map +0 -1
  468. package/build/details-content/save.js +0 -20
  469. package/build/details-content/save.js.map +0 -1
  470. package/build/details-summary/edit.js +0 -42
  471. package/build/details-summary/edit.js.map +0 -1
  472. package/build/details-summary/index.js +0 -97
  473. package/build/details-summary/index.js.map +0 -1
  474. package/build/details-summary/save.js +0 -24
  475. package/build/details-summary/save.js.map +0 -1
  476. package/build/file/utils.js.map +0 -1
  477. package/build-module/details-content/edit.js +0 -23
  478. package/build-module/details-content/edit.js.map +0 -1
  479. package/build-module/details-content/index.js +0 -76
  480. package/build-module/details-content/index.js.map +0 -1
  481. package/build-module/details-content/save.js +0 -11
  482. package/build-module/details-content/save.js.map +0 -1
  483. package/build-module/details-summary/edit.js +0 -30
  484. package/build-module/details-summary/edit.js.map +0 -1
  485. package/build-module/details-summary/index.js +0 -79
  486. package/build-module/details-summary/index.js.map +0 -1
  487. package/build-module/details-summary/save.js +0 -16
  488. package/build-module/details-summary/save.js.map +0 -1
  489. package/build-module/file/utils.js.map +0 -1
  490. package/build-style/details-summary/style-rtl.css +0 -91
  491. package/build-style/details-summary/style.css +0 -91
  492. package/src/details-content/block.json +0 -50
  493. package/src/details-content/edit.js +0 -29
  494. package/src/details-content/index.js +0 -23
  495. package/src/details-content/save.js +0 -12
  496. package/src/details-summary/block.json +0 -53
  497. package/src/details-summary/edit.js +0 -27
  498. package/src/details-summary/editor.scss +0 -3
  499. package/src/details-summary/index.js +0 -23
  500. package/src/details-summary/save.js +0 -13
  501. package/src/details-summary/style.scss +0 -3
  502. /package/src/file/{utils.js → utils/index.js} +0 -0
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.directive = void 0;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _preact = require("preact");
11
+
12
+ var _hooks = require("preact/hooks");
13
+
14
+ var _store = require("./store");
15
+
16
+ /**
17
+ * External dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+ // Main context.
24
+ const context = (0, _preact.createContext)({}); // WordPress Directives.
25
+
26
+ const directiveMap = {};
27
+ const directivePriorities = {};
28
+
29
+ const directive = function (name, cb) {
30
+ let {
31
+ priority = 10
32
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
33
+ directiveMap[name] = cb;
34
+ directivePriorities[name] = priority;
35
+ }; // Resolve the path to some property of the store object.
36
+
37
+
38
+ exports.directive = directive;
39
+
40
+ const resolve = (path, ctx) => {
41
+ let current = { ..._store.rawStore,
42
+ context: ctx
43
+ };
44
+ path.split('.').forEach(p => current = current[p]);
45
+ return current;
46
+ }; // Generate the evaluate function.
47
+
48
+
49
+ const getEvaluate = function () {
50
+ let {
51
+ ref
52
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
53
+ return function (path) {
54
+ let extraArgs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
55
+ // If path starts with !, remove it and save a flag.
56
+ const hasNegationOperator = path[0] === '!' && !!(path = path.slice(1));
57
+ const value = resolve(path, extraArgs.context);
58
+ const returnValue = typeof value === 'function' ? value({
59
+ ref: ref.current,
60
+ ..._store.rawStore,
61
+ ...extraArgs
62
+ }) : value;
63
+ return hasNegationOperator ? !returnValue : returnValue;
64
+ };
65
+ }; // Separate directives by priority. The resulting array contains objects
66
+ // of directives grouped by same priority, and sorted in ascending order.
67
+
68
+
69
+ const usePriorityLevels = directives => (0, _hooks.useMemo)(() => {
70
+ const byPriority = Object.entries(directives).reduce((acc, _ref) => {
71
+ let [name, values] = _ref;
72
+ const priority = directivePriorities[name];
73
+ if (!acc[priority]) acc[priority] = {};
74
+ acc[priority][name] = values;
75
+ return acc;
76
+ }, {});
77
+ return Object.entries(byPriority).sort((_ref2, _ref3) => {
78
+ let [p1] = _ref2;
79
+ let [p2] = _ref3;
80
+ return p1 - p2;
81
+ }).map(_ref4 => {
82
+ let [, obj] = _ref4;
83
+ return obj;
84
+ });
85
+ }, [directives]); // Directive wrapper.
86
+
87
+
88
+ const Directive = _ref5 => {
89
+ let {
90
+ type,
91
+ directives,
92
+ props: originalProps
93
+ } = _ref5;
94
+ const ref = (0, _hooks.useRef)(null);
95
+ const element = (0, _preact.h)(type, { ...originalProps,
96
+ ref
97
+ });
98
+ const evaluate = (0, _hooks.useMemo)(() => getEvaluate({
99
+ ref
100
+ }), []); // Add wrappers recursively for each priority level.
101
+
102
+ const byPriorityLevel = usePriorityLevels(directives);
103
+ return (0, _element.createElement)(RecursivePriorityLevel, {
104
+ directives: byPriorityLevel,
105
+ element: element,
106
+ evaluate: evaluate,
107
+ originalProps: originalProps
108
+ });
109
+ }; // Priority level wrapper.
110
+
111
+
112
+ const RecursivePriorityLevel = _ref6 => {
113
+ let {
114
+ directives: [directives, ...rest],
115
+ element,
116
+ evaluate,
117
+ originalProps
118
+ } = _ref6;
119
+ // This element needs to be a fresh copy so we are not modifying an already
120
+ // rendered element with Preact's internal properties initialized. This
121
+ // prevents an error with changes in `element.props.children` not being
122
+ // reflected in `element.__k`.
123
+ element = (0, _preact.cloneElement)(element); // Recursively render the wrapper for the next priority level.
124
+ //
125
+ // Note that, even though we're instantiating a vnode with a
126
+ // `RecursivePriorityLevel` here, its render function will not be executed
127
+ // just yet. Actually, it will be delayed until the current render function
128
+ // has finished. That ensures directives in the current priorty level have
129
+ // run (and thus modified the passed `element`) before the next level.
130
+
131
+ const children = rest.length > 0 ? (0, _element.createElement)(RecursivePriorityLevel, {
132
+ directives: rest,
133
+ element: element,
134
+ evaluate: evaluate,
135
+ originalProps: originalProps
136
+ }) : element;
137
+ const props = { ...originalProps,
138
+ children
139
+ };
140
+ const directiveArgs = {
141
+ directives,
142
+ props,
143
+ element,
144
+ context,
145
+ evaluate
146
+ };
147
+
148
+ for (const d in directives) {
149
+ var _directiveMap$d;
150
+
151
+ const wrapper = (_directiveMap$d = directiveMap[d]) === null || _directiveMap$d === void 0 ? void 0 : _directiveMap$d.call(directiveMap, directiveArgs);
152
+ if (wrapper !== undefined) props.children = wrapper;
153
+ }
154
+
155
+ return props.children;
156
+ }; // Preact Options Hook called each time a vnode is created.
157
+
158
+
159
+ const old = _preact.options.vnode;
160
+
161
+ _preact.options.vnode = vnode => {
162
+ if (vnode.props.__directives) {
163
+ const props = vnode.props;
164
+ const directives = props.__directives;
165
+ delete props.__directives;
166
+ vnode.props = {
167
+ type: vnode.type,
168
+ directives,
169
+ props
170
+ };
171
+ vnode.type = Directive;
172
+ }
173
+
174
+ if (old) old(vnode);
175
+ };
176
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hooks.js"],"names":["context","directiveMap","directivePriorities","directive","name","cb","priority","resolve","path","ctx","current","store","split","forEach","p","getEvaluate","ref","extraArgs","hasNegationOperator","slice","value","returnValue","usePriorityLevels","directives","byPriority","Object","entries","reduce","acc","values","sort","p1","p2","map","obj","Directive","type","props","originalProps","element","evaluate","byPriorityLevel","RecursivePriorityLevel","rest","children","length","directiveArgs","d","wrapper","undefined","old","options","vnode","__directives"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA;AACA,MAAMA,OAAO,GAAG,2BAAe,EAAf,CAAhB,C,CAEA;;AACA,MAAMC,YAAY,GAAG,EAArB;AACA,MAAMC,mBAAmB,GAAG,EAA5B;;AACO,MAAMC,SAAS,GAAG,UAAEC,IAAF,EAAQC,EAAR,EAAwC;AAAA,MAA5B;AAAEC,IAAAA,QAAQ,GAAG;AAAb,GAA4B,uEAAR,EAAQ;AAChEL,EAAAA,YAAY,CAAEG,IAAF,CAAZ,GAAuBC,EAAvB;AACAH,EAAAA,mBAAmB,CAAEE,IAAF,CAAnB,GAA8B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AK,CAACgB,YAAb;AACAD,IAAAA,KAAK,CAACf,KAAN,GAAc;AACbD,MAAAA,IAAI,EAAEgB,KAAK,CAAChB,IADC;AAEbb,MAAAA,UAFa;AAGbc,MAAAA;AAHa,KAAd;AAKAe,IAAAA,KAAK,CAAChB,IAAN,GAAaD,SAAb;AACA;;AAED,MAAKe,GAAL,EAAWA,GAAG,CAAEE,KAAF,CAAH;AACX,CAdD","sourcesContent":["/**\n * External dependencies\n */\nimport { h, options, createContext, cloneElement } from 'preact';\nimport { useRef, useMemo } from 'preact/hooks';\n/**\n * Internal dependencies\n */\nimport { rawStore as store } from './store';\n\n// Main context.\nconst context = createContext( {} );\n\n// WordPress Directives.\nconst directiveMap = {};\nconst directivePriorities = {};\nexport const directive = ( name, cb, { priority = 10 } = {} ) => {\n\tdirectiveMap[ name ] = cb;\n\tdirectivePriorities[ name ] = priority;\n};\n\n// Resolve the path to some property of the store object.\nconst resolve = ( path, ctx ) => {\n\tlet current = { ...store, context: ctx };\n\tpath.split( '.' ).forEach( ( p ) => ( current = current[ p ] ) );\n\treturn current;\n};\n\n// Generate the evaluate function.\nconst getEvaluate =\n\t( { ref } = {} ) =>\n\t( path, extraArgs = {} ) => {\n\t\t// If path starts with !, remove it and save a flag.\n\t\tconst hasNegationOperator =\n\t\t\tpath[ 0 ] === '!' && !! ( path = path.slice( 1 ) );\n\t\tconst value = resolve( path, extraArgs.context );\n\t\tconst returnValue =\n\t\t\ttypeof value === 'function'\n\t\t\t\t? value( {\n\t\t\t\t\t\tref: ref.current,\n\t\t\t\t\t\t...store,\n\t\t\t\t\t\t...extraArgs,\n\t\t\t\t } )\n\t\t\t\t: value;\n\t\treturn hasNegationOperator ? ! returnValue : returnValue;\n\t};\n\n// Separate directives by priority. The resulting array contains objects\n// of directives grouped by same priority, and sorted in ascending order.\nconst usePriorityLevels = ( directives ) =>\n\tuseMemo( () => {\n\t\tconst byPriority = Object.entries( directives ).reduce(\n\t\t\t( acc, [ name, values ] ) => {\n\t\t\t\tconst priority = directivePriorities[ name ];\n\t\t\t\tif ( ! acc[ priority ] ) acc[ priority ] = {};\n\t\t\t\tacc[ priority ][ name ] = values;\n\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\treturn Object.entries( byPriority )\n\t\t\t.sort( ( [ p1 ], [ p2 ] ) => p1 - p2 )\n\t\t\t.map( ( [ , obj ] ) => obj );\n\t}, [ directives ] );\n\n// Directive wrapper.\nconst Directive = ( { type, directives, props: originalProps } ) => {\n\tconst ref = useRef( null );\n\tconst element = h( type, { ...originalProps, ref } );\n\tconst evaluate = useMemo( () => getEvaluate( { ref } ), [] );\n\n\t// Add wrappers recursively for each priority level.\n\tconst byPriorityLevel = usePriorityLevels( directives );\n\treturn (\n\t\t<RecursivePriorityLevel\n\t\t\tdirectives={ byPriorityLevel }\n\t\t\telement={ element }\n\t\t\tevaluate={ evaluate }\n\t\t\toriginalProps={ originalProps }\n\t\t/>\n\t);\n};\n\n// Priority level wrapper.\nconst RecursivePriorityLevel = ( {\n\tdirectives: [ directives, ...rest ],\n\telement,\n\tevaluate,\n\toriginalProps,\n} ) => {\n\t// This element needs to be a fresh copy so we are not modifying an already\n\t// rendered element with Preact's internal properties initialized. This\n\t// prevents an error with changes in `element.props.children` not being\n\t// reflected in `element.__k`.\n\telement = cloneElement( element );\n\n\t// Recursively render the wrapper for the next priority level.\n\t//\n\t// Note that, even though we're instantiating a vnode with a\n\t// `RecursivePriorityLevel` here, its render function will not be executed\n\t// just yet. Actually, it will be delayed until the current render function\n\t// has finished. That ensures directives in the current priorty level have\n\t// run (and thus modified the passed `element`) before the next level.\n\tconst children =\n\t\trest.length > 0 ? (\n\t\t\t<RecursivePriorityLevel\n\t\t\t\tdirectives={ rest }\n\t\t\t\telement={ element }\n\t\t\t\tevaluate={ evaluate }\n\t\t\t\toriginalProps={ originalProps }\n\t\t\t/>\n\t\t) : (\n\t\t\telement\n\t\t);\n\n\tconst props = { ...originalProps, children };\n\tconst directiveArgs = { directives, props, element, context, evaluate };\n\n\tfor ( const d in directives ) {\n\t\tconst wrapper = directiveMap[ d ]?.( directiveArgs );\n\t\tif ( wrapper !== undefined ) props.children = wrapper;\n\t}\n\n\treturn props.children;\n};\n\n// Preact Options Hook called each time a vnode is created.\nconst old = options.vnode;\noptions.vnode = ( vnode ) => {\n\tif ( vnode.props.__directives ) {\n\t\tconst props = vnode.props;\n\t\tconst directives = props.__directives;\n\t\tdelete props.__directives;\n\t\tvnode.props = {\n\t\t\ttype: vnode.type,\n\t\t\tdirectives,\n\t\t\tprops,\n\t\t};\n\t\tvnode.type = Directive;\n\t}\n\n\tif ( old ) old( vnode );\n};\n"]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.init = void 0;
7
+
8
+ var _preact = require("preact");
9
+
10
+ var _vdom = require("./vdom");
11
+
12
+ var _utils = require("./utils");
13
+
14
+ var _constants = require("./constants");
15
+
16
+ /**
17
+ * External dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+ const init = async () => {
24
+ document.querySelectorAll(`[${_constants.directivePrefix}island]`).forEach(node => {
25
+ if (!_vdom.hydratedIslands.has(node)) {
26
+ const fragment = (0, _utils.createRootFragment)(node.parentNode, node);
27
+ const vdom = (0, _vdom.toVdom)(node);
28
+ (0, _preact.hydrate)(vdom, fragment);
29
+ }
30
+ });
31
+ };
32
+
33
+ exports.init = init;
34
+ //# sourceMappingURL=hydration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hydration.js"],"names":["init","document","querySelectorAll","directivePrefix","forEach","node","hydratedIslands","has","fragment","parentNode","vdom"],"mappings":";;;;;;;AAGA;;AAIA;;AACA;;AACA;;AATA;AACA;AACA;;AAEA;AACA;AACA;AAKO,MAAMA,IAAI,GAAG,YAAY;AAC/BC,EAAAA,QAAQ,CACNC,gBADF,CACqB,IAAIC,0BAAiB,SAD1C,EAEEC,OAFF,CAEaC,IAAF,IAAY;AACrB,QAAK,CAAEC,sBAAgBC,GAAhB,CAAqBF,IAArB,CAAP,EAAqC;AACpC,YAAMG,QAAQ,GAAG,+BAAoBH,IAAI,CAACI,UAAzB,EAAqCJ,IAArC,CAAjB;AACA,YAAMK,IAAI,GAAG,kBAAQL,IAAR,CAAb;AACA,2BAASK,IAAT,EAAeF,QAAf;AACA;AACD,GARF;AASA,CAVM","sourcesContent":["/**\n * External dependencies\n */\nimport { hydrate } from 'preact';\n/**\n * Internal dependencies\n */\nimport { toVdom, hydratedIslands } from './vdom';\nimport { createRootFragment } from './utils';\nimport { directivePrefix } from './constants';\n\nexport const init = async () => {\n\tdocument\n\t\t.querySelectorAll( `[${ directivePrefix }island]` )\n\t\t.forEach( ( node ) => {\n\t\t\tif ( ! hydratedIslands.has( node ) ) {\n\t\t\t\tconst fragment = createRootFragment( node.parentNode, node );\n\t\t\t\tconst vdom = toVdom( node );\n\t\t\t\thydrate( vdom, fragment );\n\t\t\t}\n\t\t} );\n};\n"]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "store", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _store.store;
12
+ }
13
+ });
14
+
15
+ var _directives = _interopRequireDefault(require("./directives"));
16
+
17
+ var _hydration = require("./hydration");
18
+
19
+ var _store = require("./store");
20
+
21
+ /**
22
+ * Internal dependencies
23
+ */
24
+
25
+ /**
26
+ * Initialize the Interactivity API.
27
+ */
28
+ (0, _directives.default)();
29
+ document.addEventListener('DOMContentLoaded', async () => {
30
+ await (0, _hydration.init)(); // eslint-disable-next-line no-console
31
+
32
+ console.log('Interactivity API started');
33
+ });
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/index.js"],"names":["document","addEventListener","console","log"],"mappings":";;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AAEAA,QAAQ,CAACC,gBAAT,CAA2B,kBAA3B,EAA+C,YAAY;AAC1D,QAAM,sBAAN,CAD0D,CAE1D;;AACAC,EAAAA,OAAO,CAACC,GAAR,CAAa,2BAAb;AACA,CAJD","sourcesContent":["/**\n * Internal dependencies\n */\nimport registerDirectives from './directives';\nimport { init } from './hydration';\nexport { store } from './store';\n\n/**\n * Initialize the Interactivity API.\n */\nregisterDirectives();\n\ndocument.addEventListener( 'DOMContentLoaded', async () => {\n\tawait init();\n\t// eslint-disable-next-line no-console\n\tconsole.log( 'Interactivity API started' );\n} );\n"]}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createPortal = createPortal;
7
+
8
+ var _preact = require("preact");
9
+
10
+ /**
11
+ * External dependencies
12
+ */
13
+
14
+ /**
15
+ * @param {import('../../src/index').RenderableProps<{ context: any }>} props
16
+ */
17
+ function ContextProvider(props) {
18
+ this.getChildContext = () => props.context;
19
+
20
+ return props.children;
21
+ }
22
+ /**
23
+ * Portal component
24
+ *
25
+ * @this {import('./internal').Component}
26
+ * @param {object | null | undefined} props
27
+ *
28
+ * TODO: use createRoot() instead of fake root
29
+ */
30
+
31
+
32
+ function Portal(props) {
33
+ const _this = this;
34
+
35
+ const container = props._container;
36
+
37
+ _this.componentWillUnmount = function () {
38
+ (0, _preact.render)(null, _this._temp);
39
+ _this._temp = null;
40
+ _this._container = null;
41
+ }; // When we change container we should clear our old container and
42
+ // indicate a new mount.
43
+
44
+
45
+ if (_this._container && _this._container !== container) {
46
+ _this.componentWillUnmount();
47
+ } // When props.vnode is undefined/false/null we are dealing with some kind of
48
+ // conditional vnode. This should not trigger a render.
49
+
50
+
51
+ if (props._vnode) {
52
+ if (!_this._temp) {
53
+ _this._container = container; // Create a fake DOM parent node that manages a subset of `container`'s children:
54
+
55
+ _this._temp = {
56
+ nodeType: 1,
57
+ parentNode: container,
58
+ childNodes: [],
59
+
60
+ appendChild(child) {
61
+ this.childNodes.push(child);
62
+
63
+ _this._container.appendChild(child);
64
+ },
65
+
66
+ insertBefore(child) {
67
+ this.childNodes.push(child);
68
+
69
+ _this._container.appendChild(child);
70
+ },
71
+
72
+ removeChild(child) {
73
+ this.childNodes.splice( // eslint-disable-next-line no-bitwise
74
+ this.childNodes.indexOf(child) >>> 1, 1);
75
+
76
+ _this._container.removeChild(child);
77
+ }
78
+
79
+ };
80
+ } // Render our wrapping element into temp.
81
+
82
+
83
+ (0, _preact.render)((0, _preact.createElement)(ContextProvider, {
84
+ context: _this.context
85
+ }, props._vnode), _this._temp);
86
+ } // When we come from a conditional render, on a mounted
87
+ // portal we should clear the DOM.
88
+ else if (_this._temp) {
89
+ _this.componentWillUnmount();
90
+ }
91
+ }
92
+ /**
93
+ * Create a `Portal` to continue rendering the vnode tree at a different DOM node
94
+ *
95
+ * @param {import('./internal').VNode} vnode The vnode to render
96
+ * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
97
+ */
98
+
99
+
100
+ function createPortal(vnode, container) {
101
+ const el = (0, _preact.createElement)(Portal, {
102
+ _vnode: vnode,
103
+ _container: container
104
+ });
105
+ el.containerInfo = container;
106
+ return el;
107
+ }
108
+ //# sourceMappingURL=portals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/portals.js"],"names":["ContextProvider","props","getChildContext","context","children","Portal","_this","container","_container","componentWillUnmount","_temp","_vnode","nodeType","parentNode","childNodes","appendChild","child","push","insertBefore","removeChild","splice","indexOf","createPortal","vnode","el","containerInfo"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,eAAT,CAA0BC,KAA1B,EAAkC;AACjC,OAAKC,eAAL,GAAuB,MA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pB,eAAKF,UAAL,CAAgBM,MAAhB,EACC;AACA,eAAKN,UAAL,CAAgBO,OAAhB,CAAyBL,KAAzB,MAAqC,CAFtC,EAGC,CAHD;;AAKAV,UAAAA,KAAK,CAACE,UAAN,CAAiBW,WAAjB,CAA8BH,KAA9B;AACA;;AAnBY,OAAd;AAqBA,KA1BkB,CA4BnB;;;AACA,wBACC,2BACChB,eADD,EAEC;AAAEG,MAAAA,OAAO,EAAEG,KAAK,CAACH;AAAjB,KAFD,EAGCF,KAAK,CAACU,MAHP,CADD,EAMCL,KAAK,CAACI,KANP;AAQA,GArCD,CAsCA;AACA;AAvCA,OAwCK,IAAKJ,KAAK,CAACI,KAAX,EAAmB;AACvBJ,IAAAA,KAAK,CAACG,oBAAN;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASa,YAAT,CAAuBC,KAAvB,EAA8BhB,SAA9B,EAA0C;AAChD,QAAMiB,EAAE,GAAG,2BAAenB,MAAf,EAAuB;AACjCM,IAAAA,MAAM,EAAEY,KADyB;AAEjCf,IAAAA,UAAU,EAAED;AAFqB,GAAvB,CAAX;AAIAiB,EAAAA,EAAE,CAACC,aAAH,GAAmBlB,SAAnB;AACA,SAAOiB,EAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { createElement, render } from 'preact';\n\n/**\n * @param {import('../../src/index').RenderableProps<{ context: any }>} props\n */\nfunction ContextProvider( props ) {\n\tthis.getChildContext = () => props.context;\n\treturn props.children;\n}\n\n/**\n * Portal component\n *\n * @this {import('./internal').Component}\n * @param {object | null | undefined} props\n *\n * TODO: use createRoot() instead of fake root\n */\nfunction Portal( props ) {\n\tconst _this = this;\n\tconst container = props._container;\n\n\t_this.componentWillUnmount = function () {\n\t\trender( null, _this._temp );\n\t\t_this._temp = null;\n\t\t_this._container = null;\n\t};\n\n\t// When we change container we should clear our old container and\n\t// indicate a new mount.\n\tif ( _this._container && _this._container !== container ) {\n\t\t_this.componentWillUnmount();\n\t}\n\n\t// When props.vnode is undefined/false/null we are dealing with some kind of\n\t// conditional vnode. This should not trigger a render.\n\tif ( props._vnode ) {\n\t\tif ( ! _this._temp ) {\n\t\t\t_this._container = container;\n\n\t\t\t// Create a fake DOM parent node that manages a subset of `container`'s children:\n\t\t\t_this._temp = {\n\t\t\t\tnodeType: 1,\n\t\t\t\tparentNode: container,\n\t\t\t\tchildNodes: [],\n\t\t\t\tappendChild( child ) {\n\t\t\t\t\tthis.childNodes.push( child );\n\t\t\t\t\t_this._container.appendChild( child );\n\t\t\t\t},\n\t\t\t\tinsertBefore( child ) {\n\t\t\t\t\tthis.childNodes.push( child );\n\t\t\t\t\t_this._container.appendChild( child );\n\t\t\t\t},\n\t\t\t\tremoveChild( child ) {\n\t\t\t\t\tthis.childNodes.splice(\n\t\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\t\tthis.childNodes.indexOf( child ) >>> 1,\n\t\t\t\t\t\t1\n\t\t\t\t\t);\n\t\t\t\t\t_this._container.removeChild( child );\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t// Render our wrapping element into temp.\n\t\trender(\n\t\t\tcreateElement(\n\t\t\t\tContextProvider,\n\t\t\t\t{ context: _this.context },\n\t\t\t\tprops._vnode\n\t\t\t),\n\t\t\t_this._temp\n\t\t);\n\t}\n\t// When we come from a conditional render, on a mounted\n\t// portal we should clear the DOM.\n\telse if ( _this._temp ) {\n\t\t_this.componentWillUnmount();\n\t}\n}\n\n/**\n * Create a `Portal` to continue rendering the vnode tree at a different DOM node\n *\n * @param {import('./internal').VNode} vnode The vnode to render\n * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.\n */\nexport function createPortal( vnode, container ) {\n\tconst el = createElement( Portal, {\n\t\t_vnode: vnode,\n\t\t_container: container,\n\t} );\n\tel.containerInfo = container;\n\treturn el;\n}\n"]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.store = exports.rawStore = void 0;
7
+
8
+ var _deepsignal = require("deepsignal");
9
+
10
+ /**
11
+ * External dependencies
12
+ */
13
+ const isObject = item => item && typeof item === 'object' && !Array.isArray(item);
14
+
15
+ const deepMerge = (target, source) => {
16
+ if (isObject(target) && isObject(source)) {
17
+ for (const key in source) {
18
+ if (isObject(source[key])) {
19
+ if (!target[key]) Object.assign(target, {
20
+ [key]: {}
21
+ });
22
+ deepMerge(target[key], source[key]);
23
+ } else {
24
+ Object.assign(target, {
25
+ [key]: source[key]
26
+ });
27
+ }
28
+ }
29
+ }
30
+ };
31
+
32
+ const getSerializedState = () => {
33
+ // TODO: change the store tag ID for a better one.
34
+ const storeTag = document.querySelector(`script[type="application/json"]#store`);
35
+ if (!storeTag) return {};
36
+
37
+ try {
38
+ const {
39
+ state
40
+ } = JSON.parse(storeTag.textContent);
41
+ if (isObject(state)) return state;
42
+ throw Error('Parsed state is not an object');
43
+ } catch (e) {
44
+ // eslint-disable-next-line no-console
45
+ console.log(e);
46
+ }
47
+
48
+ return {};
49
+ };
50
+
51
+ const rawState = getSerializedState();
52
+ const rawStore = {
53
+ state: (0, _deepsignal.deepSignal)(rawState)
54
+ };
55
+ exports.rawStore = rawStore;
56
+
57
+ const store = _ref => {
58
+ let {
59
+ state,
60
+ ...block
61
+ } = _ref;
62
+ deepMerge(rawStore, block);
63
+ deepMerge(rawState, state);
64
+ };
65
+
66
+ exports.store = store;
67
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/store.js"],"names":["isObject","item","Array","isArray","deepMerge","target","source","key","Object","assign","getSerializedState","storeTag","document","querySelector","state","JSON","parse","textContent","Error","e","console","log","rawState","rawStore","store","block"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAKC,IAAF,IAChBA,IAAI,IAAI,OAAOA,IAAP,KAAgB,QAAxB,IAAoC,CAAEC,KAAK,CAACC,OAAN,C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Q,QAAZ;AAAT,CAAjB;;;AAEA,MAAME,KAAK,GAAG,QAA2B;AAAA,MAAzB;AAAEV,IAAAA,KAAF;AAAS,OAAGW;AAAZ,GAAyB;AAC/CrB,EAAAA,SAAS,CAAEmB,QAAF,EAAYE,KAAZ,CAAT;AACArB,EAAAA,SAAS,CAAEkB,QAAF,EAAYR,KAAZ,CAAT;AACA,CAHM","sourcesContent":["/**\n * External dependencies\n */\nimport { deepSignal } from 'deepsignal';\n\nconst isObject = ( item ) =>\n\titem && typeof item === 'object' && ! Array.isArray( item );\n\nconst deepMerge = ( target, source ) => {\n\tif ( isObject( target ) && isObject( source ) ) {\n\t\tfor ( const key in source ) {\n\t\t\tif ( isObject( source[ key ] ) ) {\n\t\t\t\tif ( ! target[ key ] ) Object.assign( target, { [ key ]: {} } );\n\t\t\t\tdeepMerge( target[ key ], source[ key ] );\n\t\t\t} else {\n\t\t\t\tObject.assign( target, { [ key ]: source[ key ] } );\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst getSerializedState = () => {\n\t// TODO: change the store tag ID for a better one.\n\tconst storeTag = document.querySelector(\n\t\t`script[type=\"application/json\"]#store`\n\t);\n\tif ( ! storeTag ) return {};\n\ttry {\n\t\tconst { state } = JSON.parse( storeTag.textContent );\n\t\tif ( isObject( state ) ) return state;\n\t\tthrow Error( 'Parsed state is not an object' );\n\t} catch ( e ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log( e );\n\t}\n\treturn {};\n};\n\nconst rawState = getSerializedState();\nexport const rawStore = { state: deepSignal( rawState ) };\n\nexport const store = ( { state, ...block } ) => {\n\tdeepMerge( rawStore, block );\n\tdeepMerge( rawState, state );\n};\n"]}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createRootFragment = void 0;
7
+ exports.useSignalEffect = useSignalEffect;
8
+
9
+ var _hooks = require("preact/hooks");
10
+
11
+ var _signals = require("@preact/signals");
12
+
13
+ /**
14
+ * External dependencies
15
+ */
16
+ function afterNextFrame(callback) {
17
+ const done = () => {
18
+ window.cancelAnimationFrame(raf);
19
+ setTimeout(callback);
20
+ };
21
+
22
+ const raf = window.requestAnimationFrame(done);
23
+ } // Using the mangled properties:
24
+ // this.c: this._callback
25
+ // this.x: this._compute
26
+ // https://github.com/preactjs/signals/blob/main/mangle.json
27
+
28
+
29
+ function createFlusher(compute, notify) {
30
+ let flush;
31
+ const dispose = (0, _signals.effect)(function () {
32
+ flush = this.c.bind(this);
33
+ this.x = compute;
34
+ this.c = notify;
35
+ return compute();
36
+ });
37
+ return {
38
+ flush,
39
+ dispose
40
+ };
41
+ } // Version of `useSignalEffect` with a `useEffect`-like execution. This hook
42
+ // implementation comes from this PR:
43
+ // https://github.com/preactjs/signals/pull/290.
44
+ //
45
+ // We need to include it here in this repo until the mentioned PR is merged.
46
+
47
+
48
+ function useSignalEffect(cb) {
49
+ const callback = (0, _hooks.useRef)(cb);
50
+ callback.current = cb;
51
+ (0, _hooks.useEffect)(() => {
52
+ const execute = () => callback.current();
53
+
54
+ const notify = () => afterNextFrame(eff.flush);
55
+
56
+ const eff = createFlusher(execute, notify);
57
+ return eff.dispose;
58
+ }, []);
59
+ } // For wrapperless hydration.
60
+ // See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c
61
+
62
+
63
+ const createRootFragment = (parent, replaceNode) => {
64
+ replaceNode = [].concat(replaceNode);
65
+ const s = replaceNode[replaceNode.length - 1].nextSibling;
66
+
67
+ function insert(c, r) {
68
+ parent.insertBefore(c, r || s);
69
+ }
70
+
71
+ return parent.__k = {
72
+ nodeType: 1,
73
+ parentNode: parent,
74
+ firstChild: replaceNode[0],
75
+ childNodes: replaceNode,
76
+ insertBefore: insert,
77
+ appendChild: insert,
78
+
79
+ removeChild(c) {
80
+ parent.removeChild(c);
81
+ }
82
+
83
+ };
84
+ };
85
+
86
+ exports.createRootFragment = createRootFragment;
87
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/utils.js"],"names":["afterNextFrame","callback","done","window","cancelAnimationFrame","raf","setTimeout","requestAnimationFrame","createFlusher","compute","notify","flush","dispose","c","bind","x","useSignalEffect","cb","current","execute","eff","createRootFragment","parent","replaceNode","concat","s","length","nextSibling","insert","r","insertBefore","__k","nodeType","parentNode","firstChild","childNodes","appendChild","removeChild"],"mappings":";;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,cAAT,CAAyBC,QAAzB,EAAoC;AACnC,QAAMC,IAAI,GAAG,MAAM;AAClBC,IAAAA,MAAM,CAACC,oBAAP,CAA6BC,GAA7B;AACAC,IAAAA,UAAU,CAAEL,QAAF,CAAV;AACA,GAHD;;AAIA,QAAMI,GAAG,GAAGF,MAAM,CAACI,qBAAP,CAA8BL,IAA9B,CAAZ;AACA,C,CAED;AACA;AACA;AACA;;;AACA,SAASM,aAAT,CAAwBC,OAAxB,EAAiCC,MAAjC,EAA0C;AACzC,MAAIC,KAAJ;AACA,QAAMC,OAAO,GAAG,qBAAQ,YAAY;AACnCD,IAAAA,KAAK,GAAG,KAAKE,CAAL,CAAOC,IAAP,CAAa,IAAb,CAAR;AACA,SAAKC,CAAL,GAASN,OAAT;AACA,SAAKI,CAAL,GAASH,MAAT;AACA,WAAOD,OAAO,EAAd;AACA,GALe,CAAhB;AAMA,SAAO;AAAEE,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAP;AACA,C,CAED;AACA;AACA;AACA;AACA;;;AACO,SAASI,eAAT,CAA0BC,EAA1B,EAA+B;AACrC,QAAMhB,QAAQ,GAAG,mBAAQgB,EAAR,CAAjB;AACAhB,EAAAA,QAAQ,CAACiB,OAAT,GAAmBD,EAAnB;AAEA,wBAAW,MAAM;AAChB,UAAME,OAAO,GAAG,MAAMlB,QAAQ,CAACiB,OAAT,EAAtB;;AACA,UAAMR,MAAM,GAAG,MAAMV,cAAc,CAAEoB,GAAG,CAACT,KAAN,CAAnC;;AACA,UAAMS,GAAG,GAAGZ,aAAa,CAAEW,OAAF,EAAWT,MAAX,CAAzB;AACA,WAAOU,GAAG,CAACR,OAAX;AACA,GALD,EAKG,EALH;AAMA,C,CAED;AACA;;;AACO,MAAMS,kBAAkB,GAAG,CAAEC,MAAF,EAAUC,WAAV,KAA2B;AAC5DA,EAAAA,WAAW,GAAG,GAAGC,MAAH,CAAWD,WAAX,CAAd;AACA,QAAME,CAAC,GAAGF,WAAW,CAAEA,WAAW,CAACG,MAAZ,GAAqB,CAAvB,CAAX,CAAsCC,WAAhD;;AACA,WAASC,MAAT,CAAiBf,CAAjB,EAAoBgB,CAApB,EAAwB;AACvBP,IAAAA,MAAM,CAACQ,YAAP,CAAqBjB,CAArB,EAAwBgB,CAAC,IAAIJ,CAA7B;AACA;;AACD,SAASH,MAAM,CAACS,GAAP,GAAa;AACrBC,IAAAA,QAAQ,EAAE,CADW;AAErBC,IAAAA,UAAU,EAAEX,MAFS;AAGrBY,IAAAA,UAAU,EAAEX,WAAW,CAAE,CAAF,CAHF;AAIrBY,IAAAA,UAAU,EAAEZ,WAJS;AAKrBO,IAAAA,YAAY,EAAEF,MALO;AAMrBQ,IAAAA,WAAW,EAAER,MANQ;;AAOrBS,IAAAA,WAAW,CAAExB,CAAF,EAAM;AAChBS,MAAAA,MAAM,CAACe,WAAP,CAAoBxB,CAApB;AACA;;AAToB,GAAtB;AAWA,CAjBM","sourcesContent":["/**\n * External dependencies\n */\nimport { useRef, useEffect } from 'preact/hooks';\nimport { effect } from '@preact/signals';\n\nfunction afterNextFrame( callback ) {\n\tconst done = () => {\n\t\twindow.cancelAnimationFrame( raf );\n\t\tsetTimeout( callback );\n\t};\n\tconst raf = window.requestAnimationFrame( done );\n}\n\n// Using the mangled properties:\n// this.c: this._callback\n// this.x: this._compute\n// https://github.com/preactjs/signals/blob/main/mangle.json\nfunction createFlusher( compute, notify ) {\n\tlet flush;\n\tconst dispose = effect( function () {\n\t\tflush = this.c.bind( this );\n\t\tthis.x = compute;\n\t\tthis.c = notify;\n\t\treturn compute();\n\t} );\n\treturn { flush, dispose };\n}\n\n// Version of `useSignalEffect` with a `useEffect`-like execution. This hook\n// implementation comes from this PR:\n// https://github.com/preactjs/signals/pull/290.\n//\n// We need to include it here in this repo until the mentioned PR is merged.\nexport function useSignalEffect( cb ) {\n\tconst callback = useRef( cb );\n\tcallback.current = cb;\n\n\tuseEffect( () => {\n\t\tconst execute = () => callback.current();\n\t\tconst notify = () => afterNextFrame( eff.flush );\n\t\tconst eff = createFlusher( execute, notify );\n\t\treturn eff.dispose;\n\t}, [] );\n}\n\n// For wrapperless hydration.\n// See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c\nexport const createRootFragment = ( parent, replaceNode ) => {\n\treplaceNode = [].concat( replaceNode );\n\tconst s = replaceNode[ replaceNode.length - 1 ].nextSibling;\n\tfunction insert( c, r ) {\n\t\tparent.insertBefore( c, r || s );\n\t}\n\treturn ( parent.__k = {\n\t\tnodeType: 1,\n\t\tparentNode: parent,\n\t\tfirstChild: replaceNode[ 0 ],\n\t\tchildNodes: replaceNode,\n\t\tinsertBefore: insert,\n\t\tappendChild: insert,\n\t\tremoveChild( c ) {\n\t\t\tparent.removeChild( c );\n\t\t},\n\t} );\n};\n"]}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hydratedIslands = void 0;
7
+ exports.toVdom = toVdom;
8
+
9
+ var _preact = require("preact");
10
+
11
+ var _constants = require("./constants");
12
+
13
+ /**
14
+ * External dependencies
15
+ */
16
+
17
+ /**
18
+ * Internal dependencies
19
+ */
20
+ const ignoreAttr = `${_constants.directivePrefix}ignore`;
21
+ const islandAttr = `${_constants.directivePrefix}island`;
22
+ const directiveParser = new RegExp(`${_constants.directivePrefix}([^.]+)\.?(.*)$`);
23
+ const hydratedIslands = new WeakSet(); // Recursive function that transforms a DOM tree into vDOM.
24
+
25
+ exports.hydratedIslands = hydratedIslands;
26
+
27
+ function toVdom(root) {
28
+ const treeWalker = document.createTreeWalker(root, 205 // ELEMENT + TEXT + COMMENT + CDATA_SECTION + PROCESSING_INSTRUCTION
29
+ );
30
+
31
+ function walk(node) {
32
+ const {
33
+ attributes,
34
+ nodeType
35
+ } = node;
36
+ if (nodeType === 3) return [node.data];
37
+
38
+ if (nodeType === 4) {
39
+ const next = treeWalker.nextSibling();
40
+ node.replaceWith(new window.Text(node.nodeValue));
41
+ return [node.nodeValue, next];
42
+ }
43
+
44
+ if (nodeType === 8 || nodeType === 7) {
45
+ const next = treeWalker.nextSibling();
46
+ node.remove();
47
+ return [null, next];
48
+ }
49
+
50
+ const props = {};
51
+ const children = [];
52
+ const directives = {};
53
+ let hasDirectives = false;
54
+ let ignore = false;
55
+ let island = false;
56
+
57
+ for (let i = 0; i < attributes.length; i++) {
58
+ const n = attributes[i].name;
59
+
60
+ if (n[_constants.directivePrefix.length] && n.slice(0, _constants.directivePrefix.length) === _constants.directivePrefix) {
61
+ if (n === ignoreAttr) {
62
+ ignore = true;
63
+ } else if (n === islandAttr) {
64
+ island = true;
65
+ } else {
66
+ hasDirectives = true;
67
+ let val = attributes[i].value;
68
+
69
+ try {
70
+ val = JSON.parse(val);
71
+ } catch (e) {}
72
+
73
+ const [, prefix, suffix] = directiveParser.exec(n);
74
+ directives[prefix] = directives[prefix] || {};
75
+ directives[prefix][suffix || 'default'] = val;
76
+ }
77
+ } else if (n === 'ref') {
78
+ continue;
79
+ }
80
+
81
+ props[n] = attributes[i].value;
82
+ }
83
+
84
+ if (ignore && !island) return [(0, _preact.h)(node.localName, { ...props,
85
+ innerHTML: node.innerHTML,
86
+ __directives: {
87
+ ignore: true
88
+ }
89
+ })];
90
+ if (island) hydratedIslands.add(node);
91
+ if (hasDirectives) props.__directives = directives;
92
+ let child = treeWalker.firstChild();
93
+
94
+ if (child) {
95
+ while (child) {
96
+ const [vnode, nextChild] = walk(child);
97
+ if (vnode) children.push(vnode);
98
+ child = nextChild || treeWalker.nextSibling();
99
+ }
100
+
101
+ treeWalker.parentNode();
102
+ }
103
+
104
+ return [(0, _preact.h)(node.localName, props, children)];
105
+ }
106
+
107
+ return walk(treeWalker.currentNode);
108
+ }
109
+ //# sourceMappingURL=vdom.js.map