@wordpress/block-library 8.13.0 → 8.15.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 (549) hide show
  1. package/CHANGELOG.md +4 -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/edit.js +1 -0
  7. package/build/avatar/edit.js.map +1 -1
  8. package/build/avatar/index.js +1 -1
  9. package/build/block/edit.js +1 -1
  10. package/build/block/edit.js.map +1 -1
  11. package/build/block/edit.native.js +6 -9
  12. package/build/block/edit.native.js.map +1 -1
  13. package/build/block/index.js +2 -1
  14. package/build/block/index.js.map +1 -1
  15. package/build/buttons/edit.js +7 -3
  16. package/build/buttons/edit.js.map +1 -1
  17. package/build/categories/index.js +5 -1
  18. package/build/categories/index.js.map +1 -1
  19. package/build/code/index.js +5 -1
  20. package/build/code/index.js.map +1 -1
  21. package/build/column/edit.native.js +1 -4
  22. package/build/column/edit.native.js.map +1 -1
  23. package/build/column/index.js +1 -0
  24. package/build/column/index.js.map +1 -1
  25. package/build/columns/edit.js +1 -0
  26. package/build/columns/edit.js.map +1 -1
  27. package/build/comment-author-avatar/edit.js +1 -0
  28. package/build/comment-author-avatar/edit.js.map +1 -1
  29. package/build/comments/index.js +1 -0
  30. package/build/comments/index.js.map +1 -1
  31. package/build/cover/deprecated.js +4 -2
  32. package/build/cover/deprecated.js.map +1 -1
  33. package/build/cover/edit/inspector-controls.js +2 -1
  34. package/build/cover/edit/inspector-controls.js.map +1 -1
  35. package/build/cover/index.js +1 -0
  36. package/build/cover/index.js.map +1 -1
  37. package/build/details/index.js +5 -1
  38. package/build/details/index.js.map +1 -1
  39. package/build/embed/embed-placeholder.native.js +37 -13
  40. package/build/embed/embed-placeholder.native.js.map +1 -1
  41. package/build/embed/util.js +9 -8
  42. package/build/embed/util.js.map +1 -1
  43. package/build/file/inspector.js +1 -0
  44. package/build/file/inspector.js.map +1 -1
  45. package/build/file/{interactivity.js → view-interactivity.js} +6 -2
  46. package/build/file/view-interactivity.js.map +1 -0
  47. package/build/footnotes/edit.js +20 -1
  48. package/build/footnotes/edit.js.map +1 -1
  49. package/build/footnotes/format.js +19 -16
  50. package/build/footnotes/format.js.map +1 -1
  51. package/build/footnotes/index.js +0 -1
  52. package/build/footnotes/index.js.map +1 -1
  53. package/build/gallery/edit.js +1 -1
  54. package/build/gallery/edit.js.map +1 -1
  55. package/build/gallery/index.js +3 -1
  56. package/build/gallery/index.js.map +1 -1
  57. package/build/group/index.js +1 -0
  58. package/build/group/index.js.map +1 -1
  59. package/build/heading/index.js +5 -1
  60. package/build/heading/index.js.map +1 -1
  61. package/build/heading/transforms.js +5 -1
  62. package/build/heading/transforms.js.map +1 -1
  63. package/build/image/deprecated.js +453 -175
  64. package/build/image/deprecated.js.map +1 -1
  65. package/build/image/edit.js +0 -4
  66. package/build/image/edit.js.map +1 -1
  67. package/build/image/image.js +96 -43
  68. package/build/image/image.js.map +1 -1
  69. package/build/image/index.js +6 -0
  70. package/build/image/index.js.map +1 -1
  71. package/build/image/save.js +8 -1
  72. package/build/image/save.js.map +1 -1
  73. package/build/image/utils.js +18 -0
  74. package/build/image/utils.js.map +1 -1
  75. package/build/image/{interactivity.js → view-interactivity.js} +86 -44
  76. package/build/image/view-interactivity.js.map +1 -0
  77. package/build/index.js +12 -3
  78. package/build/index.js.map +1 -1
  79. package/build/latest-comments/edit.js +1 -0
  80. package/build/latest-comments/edit.js.map +1 -1
  81. package/build/latest-posts/edit.js +2 -0
  82. package/build/latest-posts/edit.js.map +1 -1
  83. package/build/list/edit.js +4 -4
  84. package/build/list/edit.js.map +1 -1
  85. package/build/list/index.js +5 -1
  86. package/build/list/index.js.map +1 -1
  87. package/build/list-item/utils.js +6 -1
  88. package/build/list-item/utils.js.map +1 -1
  89. package/build/media-text/index.js +1 -0
  90. package/build/media-text/index.js.map +1 -1
  91. package/build/media-text/media-container.native.js +2 -1
  92. package/build/media-text/media-container.native.js.map +1 -1
  93. package/build/missing/edit.js +22 -8
  94. package/build/missing/edit.js.map +1 -1
  95. package/build/missing/edit.native.js +7 -5
  96. package/build/missing/edit.native.js.map +1 -1
  97. package/build/navigation/constants.js +10 -4
  98. package/build/navigation/constants.js.map +1 -1
  99. package/build/navigation/edit/index.js +17 -3
  100. package/build/navigation/edit/index.js.map +1 -1
  101. package/build/navigation/edit/inner-blocks.js +2 -2
  102. package/build/navigation/edit/inner-blocks.js.map +1 -1
  103. package/build/navigation/edit/menu-inspector-controls.js +0 -1
  104. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  105. package/build/navigation/edit/unsaved-inner-blocks.js +2 -2
  106. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  107. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -15
  108. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  109. package/build/navigation/use-navigation-menu.js +33 -45
  110. package/build/navigation/use-navigation-menu.js.map +1 -1
  111. package/build/navigation/view-interactivity.js +185 -0
  112. package/build/navigation/view-interactivity.js.map +1 -0
  113. package/build/navigation-link/edit.js +12 -18
  114. package/build/navigation-link/edit.js.map +1 -1
  115. package/build/navigation-link/link-ui.js +12 -2
  116. package/build/navigation-link/link-ui.js.map +1 -1
  117. package/build/navigation-submenu/edit.js +2 -2
  118. package/build/navigation-submenu/edit.js.map +1 -1
  119. package/build/page-list/convert-to-links-modal.js +3 -3
  120. package/build/page-list/convert-to-links-modal.js.map +1 -1
  121. package/build/page-list/edit.js +34 -39
  122. package/build/page-list/edit.js.map +1 -1
  123. package/build/page-list/use-convert-to-navigation-links.js +2 -15
  124. package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
  125. package/build/paragraph/index.js +1 -0
  126. package/build/paragraph/index.js.map +1 -1
  127. package/build/paragraph/transforms.js +1 -0
  128. package/build/paragraph/transforms.js.map +1 -1
  129. package/build/post-comments-form/index.js +1 -0
  130. package/build/post-comments-form/index.js.map +1 -1
  131. package/build/post-navigation-link/index.js +1 -0
  132. package/build/post-navigation-link/index.js.map +1 -1
  133. package/build/post-time-to-read/index.js +5 -1
  134. package/build/post-time-to-read/index.js.map +1 -1
  135. package/build/query-pagination/edit.js +1 -1
  136. package/build/query-pagination/edit.js.map +1 -1
  137. package/build/query-pagination-numbers/index.js +1 -1
  138. package/build/query-title/edit.js +43 -1
  139. package/build/query-title/edit.js.map +1 -1
  140. package/build/quote/index.js +1 -0
  141. package/build/quote/index.js.map +1 -1
  142. package/build/quote/transforms.js +8 -0
  143. package/build/quote/transforms.js.map +1 -1
  144. package/build/rss/edit.js +3 -0
  145. package/build/rss/edit.js.map +1 -1
  146. package/build/search/edit.js +4 -3
  147. package/build/search/edit.js.map +1 -1
  148. package/build/search/index.js +1 -0
  149. package/build/search/index.js.map +1 -1
  150. package/build/site-logo/edit.js +1 -0
  151. package/build/site-logo/edit.js.map +1 -1
  152. package/build/site-logo/index.js +5 -1
  153. package/build/site-logo/index.js.map +1 -1
  154. package/build/site-tagline/icon.js +1 -1
  155. package/build/site-tagline/icon.js.map +1 -1
  156. package/build/site-tagline/index.js +5 -1
  157. package/build/site-tagline/index.js.map +1 -1
  158. package/build/site-title/index.js +5 -1
  159. package/build/site-title/index.js.map +1 -1
  160. package/build/social-links/index.js +3 -1
  161. package/build/social-links/index.js.map +1 -1
  162. package/build/table/index.js +5 -1
  163. package/build/table/index.js.map +1 -1
  164. package/build/tag-cloud/edit.js +1 -0
  165. package/build/tag-cloud/edit.js.map +1 -1
  166. package/build/template-part/edit/index.js +1 -1
  167. package/build/template-part/edit/index.js.map +1 -1
  168. package/build/term-description/index.js +1 -0
  169. package/build/term-description/index.js.map +1 -1
  170. package/build/text-columns/edit.js +1 -0
  171. package/build/text-columns/edit.js.map +1 -1
  172. package/build/verse/index.js +5 -1
  173. package/build/verse/index.js.map +1 -1
  174. package/build/video/deprecated.js +5 -1
  175. package/build/video/deprecated.js.map +1 -1
  176. package/build/video/index.js +5 -1
  177. package/build/video/index.js.map +1 -1
  178. package/build-module/archives/index.js +5 -1
  179. package/build-module/archives/index.js.map +1 -1
  180. package/build-module/audio/index.js +5 -1
  181. package/build-module/audio/index.js.map +1 -1
  182. package/build-module/avatar/edit.js +1 -0
  183. package/build-module/avatar/edit.js.map +1 -1
  184. package/build-module/avatar/index.js +1 -1
  185. package/build-module/block/edit.js +1 -1
  186. package/build-module/block/edit.js.map +1 -1
  187. package/build-module/block/edit.native.js +7 -9
  188. package/build-module/block/edit.native.js.map +1 -1
  189. package/build-module/block/index.js +2 -1
  190. package/build-module/block/index.js.map +1 -1
  191. package/build-module/buttons/edit.js +7 -3
  192. package/build-module/buttons/edit.js.map +1 -1
  193. package/build-module/categories/index.js +5 -1
  194. package/build-module/categories/index.js.map +1 -1
  195. package/build-module/code/index.js +5 -1
  196. package/build-module/code/index.js.map +1 -1
  197. package/build-module/column/edit.native.js +1 -4
  198. package/build-module/column/edit.native.js.map +1 -1
  199. package/build-module/column/index.js +1 -0
  200. package/build-module/column/index.js.map +1 -1
  201. package/build-module/columns/edit.js +1 -0
  202. package/build-module/columns/edit.js.map +1 -1
  203. package/build-module/comment-author-avatar/edit.js +1 -0
  204. package/build-module/comment-author-avatar/edit.js.map +1 -1
  205. package/build-module/comments/index.js +1 -0
  206. package/build-module/comments/index.js.map +1 -1
  207. package/build-module/cover/deprecated.js +4 -2
  208. package/build-module/cover/deprecated.js.map +1 -1
  209. package/build-module/cover/edit/inspector-controls.js +2 -1
  210. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  211. package/build-module/cover/index.js +1 -0
  212. package/build-module/cover/index.js.map +1 -1
  213. package/build-module/details/index.js +5 -1
  214. package/build-module/details/index.js.map +1 -1
  215. package/build-module/embed/embed-placeholder.native.js +37 -14
  216. package/build-module/embed/embed-placeholder.native.js.map +1 -1
  217. package/build-module/embed/util.js +6 -6
  218. package/build-module/embed/util.js.map +1 -1
  219. package/build-module/file/inspector.js +1 -0
  220. package/build-module/file/inspector.js.map +1 -1
  221. package/build-module/file/{interactivity.js → view-interactivity.js} +6 -2
  222. package/build-module/file/view-interactivity.js.map +1 -0
  223. package/build-module/footnotes/edit.js +18 -2
  224. package/build-module/footnotes/edit.js.map +1 -1
  225. package/build-module/footnotes/format.js +19 -16
  226. package/build-module/footnotes/format.js.map +1 -1
  227. package/build-module/footnotes/index.js +0 -1
  228. package/build-module/footnotes/index.js.map +1 -1
  229. package/build-module/gallery/edit.js +1 -1
  230. package/build-module/gallery/edit.js.map +1 -1
  231. package/build-module/gallery/index.js +3 -1
  232. package/build-module/gallery/index.js.map +1 -1
  233. package/build-module/group/index.js +1 -0
  234. package/build-module/group/index.js.map +1 -1
  235. package/build-module/heading/index.js +5 -1
  236. package/build-module/heading/index.js.map +1 -1
  237. package/build-module/heading/transforms.js +5 -1
  238. package/build-module/heading/transforms.js.map +1 -1
  239. package/build-module/image/deprecated.js +454 -176
  240. package/build-module/image/deprecated.js.map +1 -1
  241. package/build-module/image/edit.js +0 -4
  242. package/build-module/image/edit.js.map +1 -1
  243. package/build-module/image/image.js +96 -46
  244. package/build-module/image/image.js.map +1 -1
  245. package/build-module/image/index.js +6 -0
  246. package/build-module/image/index.js.map +1 -1
  247. package/build-module/image/save.js +8 -1
  248. package/build-module/image/save.js.map +1 -1
  249. package/build-module/image/utils.js +16 -0
  250. package/build-module/image/utils.js.map +1 -1
  251. package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
  252. package/build-module/image/view-interactivity.js.map +1 -0
  253. package/build-module/index.js +12 -3
  254. package/build-module/index.js.map +1 -1
  255. package/build-module/latest-comments/edit.js +1 -0
  256. package/build-module/latest-comments/edit.js.map +1 -1
  257. package/build-module/latest-posts/edit.js +2 -0
  258. package/build-module/latest-posts/edit.js.map +1 -1
  259. package/build-module/list/edit.js +4 -4
  260. package/build-module/list/edit.js.map +1 -1
  261. package/build-module/list/index.js +5 -1
  262. package/build-module/list/index.js.map +1 -1
  263. package/build-module/list-item/utils.js +6 -1
  264. package/build-module/list-item/utils.js.map +1 -1
  265. package/build-module/media-text/index.js +1 -0
  266. package/build-module/media-text/index.js.map +1 -1
  267. package/build-module/media-text/media-container.native.js +2 -1
  268. package/build-module/media-text/media-container.native.js.map +1 -1
  269. package/build-module/missing/edit.js +22 -8
  270. package/build-module/missing/edit.js.map +1 -1
  271. package/build-module/missing/edit.native.js +8 -6
  272. package/build-module/missing/edit.native.js.map +1 -1
  273. package/build-module/navigation/constants.js +8 -3
  274. package/build-module/navigation/constants.js.map +1 -1
  275. package/build-module/navigation/edit/index.js +18 -4
  276. package/build-module/navigation/edit/index.js.map +1 -1
  277. package/build-module/navigation/edit/inner-blocks.js +2 -2
  278. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  279. package/build-module/navigation/edit/menu-inspector-controls.js +0 -1
  280. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  281. package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -2
  282. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  283. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -14
  284. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  285. package/build-module/navigation/use-navigation-menu.js +35 -47
  286. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  287. package/build-module/navigation/view-interactivity.js +182 -0
  288. package/build-module/navigation/view-interactivity.js.map +1 -0
  289. package/build-module/navigation-link/edit.js +13 -19
  290. package/build-module/navigation-link/edit.js.map +1 -1
  291. package/build-module/navigation-link/link-ui.js +13 -3
  292. package/build-module/navigation-link/link-ui.js.map +1 -1
  293. package/build-module/navigation-submenu/edit.js +2 -2
  294. package/build-module/navigation-submenu/edit.js.map +1 -1
  295. package/build-module/page-list/convert-to-links-modal.js +3 -3
  296. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  297. package/build-module/page-list/edit.js +34 -39
  298. package/build-module/page-list/edit.js.map +1 -1
  299. package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
  300. package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
  301. package/build-module/paragraph/index.js +1 -0
  302. package/build-module/paragraph/index.js.map +1 -1
  303. package/build-module/paragraph/transforms.js +1 -0
  304. package/build-module/paragraph/transforms.js.map +1 -1
  305. package/build-module/post-comments-form/index.js +1 -0
  306. package/build-module/post-comments-form/index.js.map +1 -1
  307. package/build-module/post-navigation-link/index.js +1 -0
  308. package/build-module/post-navigation-link/index.js.map +1 -1
  309. package/build-module/post-time-to-read/index.js +5 -1
  310. package/build-module/post-time-to-read/index.js.map +1 -1
  311. package/build-module/query-pagination/edit.js +1 -1
  312. package/build-module/query-pagination/edit.js.map +1 -1
  313. package/build-module/query-pagination-numbers/index.js +1 -1
  314. package/build-module/query-title/edit.js +44 -3
  315. package/build-module/query-title/edit.js.map +1 -1
  316. package/build-module/quote/index.js +1 -0
  317. package/build-module/quote/index.js.map +1 -1
  318. package/build-module/quote/transforms.js +8 -0
  319. package/build-module/quote/transforms.js.map +1 -1
  320. package/build-module/rss/edit.js +3 -0
  321. package/build-module/rss/edit.js.map +1 -1
  322. package/build-module/search/edit.js +4 -3
  323. package/build-module/search/edit.js.map +1 -1
  324. package/build-module/search/index.js +1 -0
  325. package/build-module/search/index.js.map +1 -1
  326. package/build-module/site-logo/edit.js +1 -0
  327. package/build-module/site-logo/edit.js.map +1 -1
  328. package/build-module/site-logo/index.js +5 -1
  329. package/build-module/site-logo/index.js.map +1 -1
  330. package/build-module/site-tagline/icon.js +1 -1
  331. package/build-module/site-tagline/icon.js.map +1 -1
  332. package/build-module/site-tagline/index.js +5 -1
  333. package/build-module/site-tagline/index.js.map +1 -1
  334. package/build-module/site-title/index.js +5 -1
  335. package/build-module/site-title/index.js.map +1 -1
  336. package/build-module/social-links/index.js +3 -1
  337. package/build-module/social-links/index.js.map +1 -1
  338. package/build-module/table/index.js +5 -1
  339. package/build-module/table/index.js.map +1 -1
  340. package/build-module/tag-cloud/edit.js +1 -0
  341. package/build-module/tag-cloud/edit.js.map +1 -1
  342. package/build-module/template-part/edit/index.js +1 -1
  343. package/build-module/template-part/edit/index.js.map +1 -1
  344. package/build-module/term-description/index.js +1 -0
  345. package/build-module/term-description/index.js.map +1 -1
  346. package/build-module/text-columns/edit.js +1 -0
  347. package/build-module/text-columns/edit.js.map +1 -1
  348. package/build-module/verse/index.js +5 -1
  349. package/build-module/verse/index.js.map +1 -1
  350. package/build-module/video/deprecated.js +5 -1
  351. package/build-module/video/deprecated.js.map +1 -1
  352. package/build-module/video/index.js +5 -1
  353. package/build-module/video/index.js.map +1 -1
  354. package/build-style/details/style-rtl.css +4 -2
  355. package/build-style/details/style.css +4 -2
  356. package/build-style/footnotes/style-rtl.css +4 -3
  357. package/build-style/footnotes/style.css +4 -3
  358. package/build-style/image/style-rtl.css +16 -2
  359. package/build-style/image/style.css +16 -2
  360. package/build-style/navigation/style-rtl.css +14 -2
  361. package/build-style/navigation/style.css +14 -2
  362. package/build-style/query-pagination/style-rtl.css +4 -2
  363. package/build-style/query-pagination/style.css +4 -2
  364. package/build-style/style-rtl.css +42 -11
  365. package/build-style/style.css +42 -11
  366. package/package.json +33 -37
  367. package/src/archives/block.json +5 -1
  368. package/src/audio/block.json +5 -1
  369. package/src/audio/test/__snapshots__/edit.native.js.snap +58 -33
  370. package/src/avatar/block.json +1 -1
  371. package/src/avatar/edit.js +1 -0
  372. package/src/block/block.json +2 -1
  373. package/src/block/edit.js +2 -2
  374. package/src/block/edit.native.js +8 -12
  375. package/src/block/editor.native.scss +2 -2
  376. package/src/block/test/edit.native.js +4 -4
  377. package/src/buttons/edit.js +4 -4
  378. package/src/categories/block.json +5 -1
  379. package/src/code/block.json +5 -1
  380. package/src/column/block.json +1 -0
  381. package/src/column/edit.native.js +4 -10
  382. package/src/column/editor.native.scss +0 -4
  383. package/src/columns/edit.js +1 -0
  384. package/src/comment-author-avatar/edit.js +1 -0
  385. package/src/comment-template/index.php +5 -2
  386. package/src/comments/block.json +1 -0
  387. package/src/cover/block.json +1 -0
  388. package/src/cover/deprecated.js +2 -0
  389. package/src/cover/edit/inspector-controls.js +1 -0
  390. package/src/details/block.json +5 -1
  391. package/src/embed/embed-placeholder.native.js +80 -47
  392. package/src/embed/styles.native.scss +54 -18
  393. package/src/embed/test/index.native.js +5 -5
  394. package/src/embed/util.js +4 -6
  395. package/src/file/index.php +4 -3
  396. package/src/file/inspector.js +1 -0
  397. package/src/file/test/__snapshots__/edit.native.js.snap +58 -33
  398. package/src/file/{interactivity.js → view-interactivity.js} +4 -1
  399. package/src/footnotes/block.json +0 -1
  400. package/src/footnotes/edit.js +21 -2
  401. package/src/footnotes/format.js +22 -20
  402. package/src/footnotes/index.php +11 -9
  403. package/src/footnotes/style.scss +6 -3
  404. package/src/gallery/block.json +3 -1
  405. package/src/gallery/edit.js +1 -1
  406. package/src/gallery/test/index.native.js +17 -16
  407. package/src/group/block.json +1 -0
  408. package/src/heading/block.json +5 -1
  409. package/src/heading/test/index.native.js +18 -0
  410. package/src/home-link/index.php +15 -2
  411. package/src/image/block.json +6 -0
  412. package/src/image/deprecated.js +597 -320
  413. package/src/image/edit.js +0 -4
  414. package/src/image/image.js +131 -62
  415. package/src/image/index.php +47 -8
  416. package/src/image/save.js +9 -1
  417. package/src/image/style.scss +15 -2
  418. package/src/image/test/edit.native.js +1 -1
  419. package/src/image/utils.js +16 -0
  420. package/src/image/{interactivity.js → view-interactivity.js} +99 -50
  421. package/src/index.js +18 -1
  422. package/src/latest-comments/edit.js +1 -0
  423. package/src/latest-posts/edit.js +2 -0
  424. package/src/latest-posts/index.php +1 -1
  425. package/src/list/block.json +5 -1
  426. package/src/list/edit.js +6 -4
  427. package/src/list/test/edit.native.js +129 -33
  428. package/src/media-text/block.json +1 -0
  429. package/src/media-text/media-container.native.js +1 -0
  430. package/src/missing/edit.js +31 -11
  431. package/src/missing/edit.native.js +12 -10
  432. package/src/missing/style.native.scss +19 -12
  433. package/src/missing/test/__snapshots__/edit.native.js.snap +21 -13
  434. package/src/navigation/constants.js +12 -6
  435. package/src/navigation/edit/index.js +30 -3
  436. package/src/navigation/edit/inner-blocks.js +2 -2
  437. package/src/navigation/edit/menu-inspector-controls.js +0 -1
  438. package/src/navigation/edit/unsaved-inner-blocks.js +2 -2
  439. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +17 -21
  440. package/src/navigation/index.php +43 -16
  441. package/src/navigation/style.scss +27 -8
  442. package/src/navigation/use-navigation-menu.js +39 -63
  443. package/src/navigation/view-interactivity.js +196 -0
  444. package/src/navigation-link/edit.js +61 -61
  445. package/src/navigation-link/link-ui.js +14 -2
  446. package/src/navigation-submenu/edit.js +2 -2
  447. package/src/navigation-submenu/index.php +2 -12
  448. package/src/page-list/convert-to-links-modal.js +3 -3
  449. package/src/page-list/edit.js +65 -62
  450. package/src/page-list/use-convert-to-navigation-links.js +3 -20
  451. package/src/paragraph/block.json +1 -0
  452. package/src/paragraph/test/__snapshots__/edit.native.js.snap +1 -0
  453. package/src/paragraph/test/edit.native.js +26 -0
  454. package/src/post-comments-form/block.json +1 -0
  455. package/src/post-navigation-link/block.json +1 -0
  456. package/src/post-template/index.php +4 -2
  457. package/src/post-time-to-read/block.json +5 -1
  458. package/src/post-title/index.php +6 -3
  459. package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -0
  460. package/src/query-pagination/edit.js +17 -14
  461. package/src/query-pagination-numbers/block.json +1 -1
  462. package/src/query-title/edit.js +48 -6
  463. package/src/quote/block.json +1 -0
  464. package/src/quote/test/__snapshots__/transforms.native.js.snap +10 -0
  465. package/src/quote/test/transforms.native.js +5 -1
  466. package/src/quote/transforms.js +13 -0
  467. package/src/rss/edit.js +3 -0
  468. package/src/search/block.json +1 -0
  469. package/src/search/edit.js +4 -3
  470. package/src/search/index.php +22 -4
  471. package/src/search/test/__snapshots__/edit.native.js.snap +7 -0
  472. package/src/site-logo/block.json +5 -1
  473. package/src/site-logo/edit.js +1 -0
  474. package/src/site-tagline/block.json +5 -1
  475. package/src/site-tagline/icon.js +1 -1
  476. package/src/site-title/block.json +5 -1
  477. package/src/social-links/block.json +3 -1
  478. package/src/table/block.json +5 -1
  479. package/src/tag-cloud/edit.js +1 -0
  480. package/src/template-part/edit/index.js +1 -1
  481. package/src/template-part/index.php +9 -15
  482. package/src/term-description/block.json +1 -0
  483. package/src/text-columns/edit.js +1 -0
  484. package/src/verse/block.json +5 -1
  485. package/src/video/block.json +5 -1
  486. package/build/file/interactivity.js.map +0 -1
  487. package/build/gallery/shared-icon.native.js +0 -38
  488. package/build/gallery/shared-icon.native.js.map +0 -1
  489. package/build/heading/heading-level-icon.js +0 -61
  490. package/build/heading/heading-level-icon.js.map +0 -1
  491. package/build/image/interactivity.js.map +0 -1
  492. package/build/navigation/interactivity.js +0 -167
  493. package/build/navigation/interactivity.js.map +0 -1
  494. package/build/utils/interactivity/constants.js +0 -9
  495. package/build/utils/interactivity/constants.js.map +0 -1
  496. package/build/utils/interactivity/directives.js +0 -222
  497. package/build/utils/interactivity/directives.js.map +0 -1
  498. package/build/utils/interactivity/hooks.js +0 -159
  499. package/build/utils/interactivity/hooks.js.map +0 -1
  500. package/build/utils/interactivity/hydration.js +0 -34
  501. package/build/utils/interactivity/hydration.js.map +0 -1
  502. package/build/utils/interactivity/index.js +0 -32
  503. package/build/utils/interactivity/index.js.map +0 -1
  504. package/build/utils/interactivity/portals.js +0 -108
  505. package/build/utils/interactivity/portals.js.map +0 -1
  506. package/build/utils/interactivity/store.js +0 -66
  507. package/build/utils/interactivity/store.js.map +0 -1
  508. package/build/utils/interactivity/utils.js +0 -87
  509. package/build/utils/interactivity/utils.js.map +0 -1
  510. package/build/utils/interactivity/vdom.js +0 -119
  511. package/build/utils/interactivity/vdom.js.map +0 -1
  512. package/build-module/file/interactivity.js.map +0 -1
  513. package/build-module/gallery/shared-icon.native.js +0 -24
  514. package/build-module/gallery/shared-icon.native.js.map +0 -1
  515. package/build-module/heading/heading-level-icon.js +0 -53
  516. package/build-module/heading/heading-level-icon.js.map +0 -1
  517. package/build-module/image/interactivity.js.map +0 -1
  518. package/build-module/navigation/interactivity.js +0 -164
  519. package/build-module/navigation/interactivity.js.map +0 -1
  520. package/build-module/utils/interactivity/constants.js +0 -2
  521. package/build-module/utils/interactivity/constants.js.map +0 -1
  522. package/build-module/utils/interactivity/directives.js +0 -209
  523. package/build-module/utils/interactivity/directives.js.map +0 -1
  524. package/build-module/utils/interactivity/hooks.js +0 -145
  525. package/build-module/utils/interactivity/hooks.js.map +0 -1
  526. package/build-module/utils/interactivity/hydration.js +0 -21
  527. package/build-module/utils/interactivity/hydration.js.map +0 -1
  528. package/build-module/utils/interactivity/index.js +0 -15
  529. package/build-module/utils/interactivity/index.js.map +0 -1
  530. package/build-module/utils/interactivity/portals.js +0 -100
  531. package/build-module/utils/interactivity/portals.js.map +0 -1
  532. package/build-module/utils/interactivity/store.js +0 -55
  533. package/build-module/utils/interactivity/store.js.map +0 -1
  534. package/build-module/utils/interactivity/utils.js +0 -75
  535. package/build-module/utils/interactivity/utils.js.map +0 -1
  536. package/build-module/utils/interactivity/vdom.js +0 -107
  537. package/build-module/utils/interactivity/vdom.js.map +0 -1
  538. package/src/gallery/shared-icon.native.js +0 -23
  539. package/src/heading/heading-level-icon.js +0 -48
  540. package/src/navigation/interactivity.js +0 -169
  541. package/src/utils/interactivity/constants.js +0 -1
  542. package/src/utils/interactivity/directives.js +0 -200
  543. package/src/utils/interactivity/hooks.js +0 -145
  544. package/src/utils/interactivity/hydration.js +0 -22
  545. package/src/utils/interactivity/index.js +0 -15
  546. package/src/utils/interactivity/portals.js +0 -98
  547. package/src/utils/interactivity/store.js +0 -45
  548. package/src/utils/interactivity/utils.js +0 -66
  549. package/src/utils/interactivity/vdom.js +0 -111
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/constants.js"],"names":["directivePrefix"],"mappings":"AAAA,OAAO,MAAMA,eAAe,GAAG,IAAxB","sourcesContent":["export const directivePrefix = 'wp';\n"]}
@@ -1,209 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * External dependencies
5
- */
6
- import { useContext, useMemo, useEffect } from 'preact/hooks';
7
- import { deepSignal, peek } from 'deepsignal';
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- import { createPortal } from './portals.js';
13
- /**
14
- * Internal dependencies
15
- */
16
-
17
- import { useSignalEffect } from './utils';
18
- import { directive } from './hooks';
19
-
20
- const isObject = item => item && typeof item === 'object' && !Array.isArray(item);
21
-
22
- const mergeDeepSignals = (target, source) => {
23
- for (const k in source) {
24
- if (typeof peek(target, k) === 'undefined') {
25
- target[`$${k}`] = source[`$${k}`];
26
- } else if (isObject(peek(target, k)) && isObject(peek(source, k))) {
27
- mergeDeepSignals(target[`$${k}`].peek(), source[`$${k}`].peek());
28
- }
29
- }
30
- };
31
-
32
- export default (() => {
33
- // data-wp-context
34
- directive('context', ({
35
- directives: {
36
- context: {
37
- default: context
38
- }
39
- },
40
- props: {
41
- children
42
- },
43
- context: inherited
44
- }) => {
45
- const {
46
- Provider
47
- } = 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
- return createElement(Provider, {
55
- value: value
56
- }, children);
57
- }, {
58
- priority: 5
59
- }); // data-wp-body
60
-
61
- directive('body', ({
62
- props: {
63
- children
64
- },
65
- context: inherited
66
- }) => {
67
- const {
68
- Provider
69
- } = inherited;
70
- const inheritedValue = useContext(inherited);
71
- return createPortal(createElement(Provider, {
72
- value: inheritedValue
73
- }, children), document.body);
74
- }); // data-wp-effect--[name]
75
-
76
- directive('effect', ({
77
- directives: {
78
- effect
79
- },
80
- context,
81
- evaluate
82
- }) => {
83
- const contextValue = useContext(context);
84
- Object.values(effect).forEach(path => {
85
- useSignalEffect(() => {
86
- return evaluate(path, {
87
- context: contextValue
88
- });
89
- });
90
- });
91
- }); // data-wp-init--[name]
92
-
93
- directive('init', ({
94
- directives: {
95
- init
96
- },
97
- context,
98
- evaluate
99
- }) => {
100
- const contextValue = useContext(context);
101
- Object.values(init).forEach(path => {
102
- useEffect(() => {
103
- return evaluate(path, {
104
- context: contextValue
105
- });
106
- }, []);
107
- });
108
- }); // data-wp-on--[event]
109
-
110
- directive('on', ({
111
- directives: {
112
- on
113
- },
114
- element,
115
- evaluate,
116
- context
117
- }) => {
118
- const contextValue = useContext(context);
119
- Object.entries(on).forEach(([name, path]) => {
120
- element.props[`on${name}`] = event => {
121
- evaluate(path, {
122
- event,
123
- context: contextValue
124
- });
125
- };
126
- });
127
- }); // data-wp-class--[classname]
128
-
129
- directive('class', ({
130
- directives: {
131
- class: className
132
- },
133
- element,
134
- evaluate,
135
- context
136
- }) => {
137
- const contextValue = useContext(context);
138
- Object.keys(className).filter(n => n !== 'default').forEach(name => {
139
- const result = evaluate(className[name], {
140
- className: name,
141
- context: contextValue
142
- });
143
- const currentClass = element.props.class || '';
144
- const classFinder = new RegExp(`(^|\\s)${name}(\\s|$)`, 'g');
145
- if (!result) element.props.class = currentClass.replace(classFinder, ' ').trim();else if (!classFinder.test(currentClass)) element.props.class = currentClass ? `${currentClass} ${name}` : name;
146
- useEffect(() => {
147
- // This seems necessary because Preact doesn't change the class
148
- // names on the hydration, so we have to do it manually. It doesn't
149
- // need deps because it only needs to do it the first time.
150
- if (!result) {
151
- element.ref.current.classList.remove(name);
152
- } else {
153
- element.ref.current.classList.add(name);
154
- }
155
- }, []);
156
- });
157
- }); // data-wp-bind--[attribute]
158
-
159
- directive('bind', ({
160
- directives: {
161
- bind
162
- },
163
- element,
164
- context,
165
- evaluate
166
- }) => {
167
- const contextValue = useContext(context);
168
- Object.entries(bind).filter(n => n !== 'default').forEach(([attribute, path]) => {
169
- const result = evaluate(path, {
170
- context: contextValue
171
- });
172
- element.props[attribute] = result; // This seems necessary because Preact doesn't change the attributes
173
- // on the hydration, so we have to do it manually. It doesn't need
174
- // deps because it only needs to do it the first time.
175
-
176
- useEffect(() => {
177
- // aria- and data- attributes have no boolean representation.
178
- // A `false` value is different from the attribute not being
179
- // present, so we can't remove it.
180
- // We follow Preact's logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136
181
- if (result === false && attribute[4] !== '-') {
182
- element.ref.current.removeAttribute(attribute);
183
- } else {
184
- element.ref.current.setAttribute(attribute, result === true && attribute[4] !== '-' ? '' : result);
185
- }
186
- }, []);
187
- });
188
- }); // data-wp-ignore
189
-
190
- directive('ignore', ({
191
- element: {
192
- type: Type,
193
- props: {
194
- innerHTML,
195
- ...rest
196
- }
197
- }
198
- }) => {
199
- // Preserve the initial inner HTML.
200
- const cached = useMemo(() => innerHTML, []);
201
- return createElement(Type, {
202
- dangerouslySetInnerHTML: {
203
- __html: cached
204
- },
205
- ...rest
206
- });
207
- });
208
- });
209
- //# sourceMappingURL=directives.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/directives.js"],"names":["useContext","useMemo","useEffect","deepSignal","peek","createPortal","useSignalEffect","directive","isObject","item","Array","isArray","mergeDeepSignals","target","source","k","directives","context","default","props","children","inherited","Provider","inheritedValue","value","localValue","priority","document","body","effect","evaluate","contextValue","Object","values","forEach","path","init","on","element","entries","name","event","class","className","keys","filter","n","result","currentClass","classFinder","RegExp","replace","trim","test","ref","current","classList","remove","add","bind","attribute","removeAttribute","setAttribute","type","Type","innerHTML","rest","cached","__html"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,OAArB,EAA8BC,SAA9B,QAA+C,cAA/C;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,YAAjC;AACA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,cAA7B;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,SAAhC;AACA,SAASC,SAAT,QAA0B,SAA1B;;AAEA,MAAMC,QAAQ,GAAK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AR,EAAmB,EAAnB,CAAtB;AACA,WACC,cAAC,IAAD;AACC,MAAA,uBAAuB,EAAG;AAAEG,QAAAA,MAAM,EAAED;AAAV,OAD3B;AAAA,SAEMD;AAFN,MADD;AAMA,GAhBO,CAAT;AAkBA,CApKD","sourcesContent":["/**\n * External dependencies\n */\nimport { useContext, useMemo, useEffect } from 'preact/hooks';\nimport { deepSignal, peek } from 'deepsignal';\n/**\n * Internal dependencies\n */\nimport { createPortal } from './portals.js';\n\n/**\n * Internal dependencies\n */\nimport { useSignalEffect } from './utils';\nimport { directive } from './hooks';\n\nconst isObject = ( item ) =>\n\titem && typeof item === 'object' && ! Array.isArray( item );\n\nconst mergeDeepSignals = ( target, source ) => {\n\tfor ( const k in source ) {\n\t\tif ( typeof peek( target, k ) === 'undefined' ) {\n\t\t\ttarget[ `$${ k }` ] = source[ `$${ k }` ];\n\t\t} else if (\n\t\t\tisObject( peek( target, k ) ) &&\n\t\t\tisObject( peek( source, k ) )\n\t\t) {\n\t\t\tmergeDeepSignals(\n\t\t\t\ttarget[ `$${ k }` ].peek(),\n\t\t\t\tsource[ `$${ k }` ].peek()\n\t\t\t);\n\t\t}\n\t}\n};\n\nexport default () => {\n\t// data-wp-context\n\tdirective(\n\t\t'context',\n\t\t( {\n\t\t\tdirectives: {\n\t\t\t\tcontext: { default: context },\n\t\t\t},\n\t\t\tprops: { children },\n\t\t\tcontext: inherited,\n\t\t} ) => {\n\t\t\tconst { Provider } = inherited;\n\t\t\tconst inheritedValue = useContext( inherited );\n\t\t\tconst value = useMemo( () => {\n\t\t\t\tconst localValue = deepSignal( context );\n\t\t\t\tmergeDeepSignals( localValue, inheritedValue );\n\t\t\t\treturn localValue;\n\t\t\t}, [ context, inheritedValue ] );\n\n\t\t\treturn <Provider value={ value }>{ children }</Provider>;\n\t\t},\n\t\t{ priority: 5 }\n\t);\n\n\t// data-wp-body\n\tdirective( 'body', ( { props: { children }, context: inherited } ) => {\n\t\tconst { Provider } = inherited;\n\t\tconst inheritedValue = useContext( inherited );\n\t\treturn createPortal(\n\t\t\t<Provider value={ inheritedValue }>{ children }</Provider>,\n\t\t\tdocument.body\n\t\t);\n\t} );\n\n\t// data-wp-effect--[name]\n\tdirective( 'effect', ( { directives: { effect }, context, evaluate } ) => {\n\t\tconst contextValue = useContext( context );\n\t\tObject.values( effect ).forEach( ( path ) => {\n\t\t\tuseSignalEffect( () => {\n\t\t\t\treturn evaluate( path, { context: contextValue } );\n\t\t\t} );\n\t\t} );\n\t} );\n\n\t// data-wp-init--[name]\n\tdirective( 'init', ( { directives: { init }, context, evaluate } ) => {\n\t\tconst contextValue = useContext( context );\n\t\tObject.values( init ).forEach( ( path ) => {\n\t\t\tuseEffect( () => {\n\t\t\t\treturn evaluate( path, { context: contextValue } );\n\t\t\t}, [] );\n\t\t} );\n\t} );\n\n\t// data-wp-on--[event]\n\tdirective( 'on', ( { directives: { on }, element, evaluate, context } ) => {\n\t\tconst contextValue = useContext( context );\n\t\tObject.entries( on ).forEach( ( [ name, path ] ) => {\n\t\t\telement.props[ `on${ name }` ] = ( event ) => {\n\t\t\t\tevaluate( path, { event, context: contextValue } );\n\t\t\t};\n\t\t} );\n\t} );\n\n\t// data-wp-class--[classname]\n\tdirective(\n\t\t'class',\n\t\t( {\n\t\t\tdirectives: { class: className },\n\t\t\telement,\n\t\t\tevaluate,\n\t\t\tcontext,\n\t\t} ) => {\n\t\t\tconst contextValue = useContext( context );\n\t\t\tObject.keys( className )\n\t\t\t\t.filter( ( n ) => n !== 'default' )\n\t\t\t\t.forEach( ( name ) => {\n\t\t\t\t\tconst result = evaluate( className[ name ], {\n\t\t\t\t\t\tclassName: name,\n\t\t\t\t\t\tcontext: contextValue,\n\t\t\t\t\t} );\n\t\t\t\t\tconst currentClass = element.props.class || '';\n\t\t\t\t\tconst classFinder = new RegExp(\n\t\t\t\t\t\t`(^|\\\\s)${ name }(\\\\s|$)`,\n\t\t\t\t\t\t'g'\n\t\t\t\t\t);\n\t\t\t\t\tif ( ! result )\n\t\t\t\t\t\telement.props.class = currentClass\n\t\t\t\t\t\t\t.replace( classFinder, ' ' )\n\t\t\t\t\t\t\t.trim();\n\t\t\t\t\telse if ( ! classFinder.test( currentClass ) )\n\t\t\t\t\t\telement.props.class = currentClass\n\t\t\t\t\t\t\t? `${ currentClass } ${ name }`\n\t\t\t\t\t\t\t: name;\n\n\t\t\t\t\tuseEffect( () => {\n\t\t\t\t\t\t// This seems necessary because Preact doesn't change the class\n\t\t\t\t\t\t// names on the hydration, so we have to do it manually. It doesn't\n\t\t\t\t\t\t// need deps because it only needs to do it the first time.\n\t\t\t\t\t\tif ( ! result ) {\n\t\t\t\t\t\t\telement.ref.current.classList.remove( name );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\telement.ref.current.classList.add( name );\n\t\t\t\t\t\t}\n\t\t\t\t\t}, [] );\n\t\t\t\t} );\n\t\t}\n\t);\n\n\t// data-wp-bind--[attribute]\n\tdirective(\n\t\t'bind',\n\t\t( { directives: { bind }, element, context, evaluate } ) => {\n\t\t\tconst contextValue = useContext( context );\n\t\t\tObject.entries( bind )\n\t\t\t\t.filter( ( n ) => n !== 'default' )\n\t\t\t\t.forEach( ( [ attribute, path ] ) => {\n\t\t\t\t\tconst result = evaluate( path, {\n\t\t\t\t\t\tcontext: contextValue,\n\t\t\t\t\t} );\n\t\t\t\t\telement.props[ attribute ] = result;\n\n\t\t\t\t\t// This seems necessary because Preact doesn't change the attributes\n\t\t\t\t\t// on the hydration, so we have to do it manually. It doesn't need\n\t\t\t\t\t// deps because it only needs to do it the first time.\n\t\t\t\t\tuseEffect( () => {\n\t\t\t\t\t\t// aria- and data- attributes have no boolean representation.\n\t\t\t\t\t\t// A `false` value is different from the attribute not being\n\t\t\t\t\t\t// present, so we can't remove it.\n\t\t\t\t\t\t// We follow Preact's logic: https://github.com/preactjs/preact/blob/ea49f7a0f9d1ff2c98c0bdd66aa0cbc583055246/src/diff/props.js#L131C24-L136\n\t\t\t\t\t\tif ( result === false && attribute[ 4 ] !== '-' ) {\n\t\t\t\t\t\t\telement.ref.current.removeAttribute( attribute );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\telement.ref.current.setAttribute(\n\t\t\t\t\t\t\t\tattribute,\n\t\t\t\t\t\t\t\tresult === true && attribute[ 4 ] !== '-'\n\t\t\t\t\t\t\t\t\t? ''\n\t\t\t\t\t\t\t\t\t: result\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, [] );\n\t\t\t\t} );\n\t\t}\n\t);\n\n\t// data-wp-ignore\n\tdirective(\n\t\t'ignore',\n\t\t( {\n\t\t\telement: {\n\t\t\t\ttype: Type,\n\t\t\t\tprops: { innerHTML, ...rest },\n\t\t\t},\n\t\t} ) => {\n\t\t\t// Preserve the initial inner HTML.\n\t\t\tconst cached = useMemo( () => innerHTML, [] );\n\t\t\treturn (\n\t\t\t\t<Type\n\t\t\t\t\tdangerouslySetInnerHTML={ { __html: cached } }\n\t\t\t\t\t{ ...rest }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t);\n};\n"]}
@@ -1,145 +0,0 @@
1
- import { createElement } from "@wordpress/element";
2
-
3
- /**
4
- * External dependencies
5
- */
6
- import { h, options, createContext, cloneElement } from 'preact';
7
- import { useRef, useMemo } from 'preact/hooks';
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- import { rawStore as store } from './store'; // Main context.
13
-
14
- const context = createContext({}); // WordPress Directives.
15
-
16
- const directiveMap = {};
17
- const directivePriorities = {};
18
- export const directive = (name, cb, {
19
- priority = 10
20
- } = {}) => {
21
- directiveMap[name] = cb;
22
- directivePriorities[name] = priority;
23
- }; // Resolve the path to some property of the store object.
24
-
25
- const resolve = (path, ctx) => {
26
- let current = { ...store,
27
- context: ctx
28
- };
29
- path.split('.').forEach(p => current = current[p]);
30
- return current;
31
- }; // Generate the evaluate function.
32
-
33
-
34
- const getEvaluate = ({
35
- ref
36
- } = {}) => (path, extraArgs = {}) => {
37
- // If path starts with !, remove it and save a flag.
38
- const hasNegationOperator = path[0] === '!' && !!(path = path.slice(1));
39
- const value = resolve(path, extraArgs.context);
40
- const returnValue = typeof value === 'function' ? value({
41
- ref: ref.current,
42
- ...store,
43
- ...extraArgs
44
- }) : value;
45
- return hasNegationOperator ? !returnValue : returnValue;
46
- }; // Separate directives by priority. The resulting array contains objects
47
- // of directives grouped by same priority, and sorted in ascending order.
48
-
49
-
50
- const usePriorityLevels = directives => useMemo(() => {
51
- const byPriority = Object.entries(directives).reduce((acc, [name, values]) => {
52
- const priority = directivePriorities[name];
53
- if (!acc[priority]) acc[priority] = {};
54
- acc[priority][name] = values;
55
- return acc;
56
- }, {});
57
- return Object.entries(byPriority).sort(([p1], [p2]) => p1 - p2).map(([, obj]) => obj);
58
- }, [directives]); // Directive wrapper.
59
-
60
-
61
- const Directive = ({
62
- type,
63
- directives,
64
- props: originalProps
65
- }) => {
66
- const ref = useRef(null);
67
- const element = h(type, { ...originalProps,
68
- ref
69
- });
70
- const evaluate = useMemo(() => getEvaluate({
71
- ref
72
- }), []); // Add wrappers recursively for each priority level.
73
-
74
- const byPriorityLevel = usePriorityLevels(directives);
75
- return createElement(RecursivePriorityLevel, {
76
- directives: byPriorityLevel,
77
- element: element,
78
- evaluate: evaluate,
79
- originalProps: originalProps
80
- });
81
- }; // Priority level wrapper.
82
-
83
-
84
- const RecursivePriorityLevel = ({
85
- directives: [directives, ...rest],
86
- element,
87
- evaluate,
88
- originalProps
89
- }) => {
90
- // This element needs to be a fresh copy so we are not modifying an already
91
- // rendered element with Preact's internal properties initialized. This
92
- // prevents an error with changes in `element.props.children` not being
93
- // reflected in `element.__k`.
94
- element = cloneElement(element); // Recursively render the wrapper for the next priority level.
95
- //
96
- // Note that, even though we're instantiating a vnode with a
97
- // `RecursivePriorityLevel` here, its render function will not be executed
98
- // just yet. Actually, it will be delayed until the current render function
99
- // has finished. That ensures directives in the current priorty level have
100
- // run (and thus modified the passed `element`) before the next level.
101
-
102
- const children = rest.length > 0 ? createElement(RecursivePriorityLevel, {
103
- directives: rest,
104
- element: element,
105
- evaluate: evaluate,
106
- originalProps: originalProps
107
- }) : element;
108
- const props = { ...originalProps,
109
- children
110
- };
111
- const directiveArgs = {
112
- directives,
113
- props,
114
- element,
115
- context,
116
- evaluate
117
- };
118
-
119
- for (const d in directives) {
120
- const wrapper = directiveMap[d]?.(directiveArgs);
121
- if (wrapper !== undefined) props.children = wrapper;
122
- }
123
-
124
- return props.children;
125
- }; // Preact Options Hook called each time a vnode is created.
126
-
127
-
128
- const old = options.vnode;
129
-
130
- options.vnode = vnode => {
131
- if (vnode.props.__directives) {
132
- const props = vnode.props;
133
- const directives = props.__directives;
134
- delete props.__directives;
135
- vnode.props = {
136
- type: vnode.type,
137
- directives,
138
- props
139
- };
140
- vnode.type = Directive;
141
- }
142
-
143
- if (old) old(vnode);
144
- };
145
- //# sourceMappingURL=hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hooks.js"],"names":["h","options","createContext","cloneElement","useRef","useMemo","rawStore","store","context","directiveMap","directivePriorities","directive","name","cb","priority","resolve","path","ctx","current","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","vnode","__directives"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,CAAT,EAAYC,OAAZ,EAAqBC,aAArB,EAAoCC,YAApC,QAAwD,QAAxD;AACA,SAASC,MAAT,EAAiBC,OAAjB,QAAgC,cAAhC;AACA;AACA;AACA;;AACA,SAASC,QAAQ,IAAIC,KAArB,QAAkC,SAAlC,C,CAEA;;AACA,MAAMC,OAAO,GAAGN,aAAa,CAAE,EAAF,CAA7B,C,CAEA;;AACA,MAAMO,YAAY,GAAG,EAArB;AACA,MAAMC,mBA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,CAACd,KAAN,CAAYe,YAAjB,EAAgC;AAC/B,UAAMf,KAAK,GAAGc,KAAK,CAACd,KAApB;AACA,UAAMd,UAAU,GAAGc,KAAK,CAACe,YAAzB;AACA,WAAOf,KAAK,CAACe,YAAb;AACAD,IAAAA,KAAK,CAACd,KAAN,GAAc;AACbD,MAAAA,IAAI,EAAEe,KAAK,CAACf,IADC;AAEbb,MAAAA,UAFa;AAGbc,MAAAA;AAHa,KAAd;AAKAc,IAAAA,KAAK,CAACf,IAAN,GAAaD,SAAb;AACA;;AAED,MAAKe,GAAL,EAAWA,GAAG,CAAEC,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"]}
@@ -1,21 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { hydrate } from 'preact';
5
- /**
6
- * Internal dependencies
7
- */
8
-
9
- import { toVdom, hydratedIslands } from './vdom';
10
- import { createRootFragment } from './utils';
11
- import { directivePrefix } from './constants';
12
- export const init = async () => {
13
- document.querySelectorAll(`[data-${directivePrefix}-interactive]`).forEach(node => {
14
- if (!hydratedIslands.has(node)) {
15
- const fragment = createRootFragment(node.parentNode, node);
16
- const vdom = toVdom(node);
17
- hydrate(vdom, fragment);
18
- }
19
- });
20
- };
21
- //# sourceMappingURL=hydration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hydration.js"],"names":["hydrate","toVdom","hydratedIslands","createRootFragment","directivePrefix","init","document","querySelectorAll","forEach","node","has","fragment","parentNode","vdom"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AACA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,eAAjB,QAAwC,QAAxC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,eAAT,QAAgC,aAAhC;AAEA,OAAO,MAAMC,IAAI,GAAG,YAAY;AAC/BC,EAAAA,QAAQ,CACNC,gBADF,CACqB,SAASH,eAAiB,eAD/C,EAEEI,OAFF,CAEaC,IAAF,IAAY;AACrB,QAAK,CAAEP,eAAe,CAACQ,GAAhB,CAAqBD,IAArB,CAAP,EAAqC;AACpC,YAAME,QAAQ,GAAGR,kBAAkB,CAAEM,IAAI,CAACG,UAAP,EAAmBH,IAAnB,CAAnC;AACA,YAAMI,IAAI,GAAGZ,MAAM,CAAEQ,IAAF,CAAnB;AACAT,MAAAA,OAAO,CAAEa,IAAF,EAAQF,QAAR,CAAP;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( `[data-${ directivePrefix }-interactive]` )\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"]}
@@ -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
- * Initialize the Interactivity API.
9
- */
10
-
11
- registerDirectives();
12
- document.addEventListener('DOMContentLoaded', async () => {
13
- await init();
14
- });
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/index.js"],"names":["registerDirectives","init","store","document","addEventListener"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,kBAAP,MAA+B,cAA/B;AACA,SAASC,IAAT,QAAqB,aAArB;AACA,SAASC,KAAT,QAAsB,SAAtB;AAEA;AACA;AACA;;AACAF,kBAAkB;AAElBG,QAAQ,CAACC,gBAAT,CAA2B,kBAA3B,EAA+C,YAAY;AAC1D,QAAMH,IAAI,EAAV;AACA,CAFD","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} );\n"]}
@@ -1,100 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { createElement, render } from 'preact';
5
- /**
6
- * @param {import('../../src/index').RenderableProps<{ context: any }>} props
7
- */
8
-
9
- function ContextProvider(props) {
10
- this.getChildContext = () => props.context;
11
-
12
- return props.children;
13
- }
14
- /**
15
- * Portal component
16
- *
17
- * @this {import('./internal').Component}
18
- * @param {object | null | undefined} props
19
- *
20
- * TODO: use createRoot() instead of fake root
21
- */
22
-
23
-
24
- function Portal(props) {
25
- const _this = this;
26
-
27
- const container = props._container;
28
-
29
- _this.componentWillUnmount = function () {
30
- render(null, _this._temp);
31
- _this._temp = null;
32
- _this._container = null;
33
- }; // When we change container we should clear our old container and
34
- // indicate a new mount.
35
-
36
-
37
- if (_this._container && _this._container !== container) {
38
- _this.componentWillUnmount();
39
- } // When props.vnode is undefined/false/null we are dealing with some kind of
40
- // conditional vnode. This should not trigger a render.
41
-
42
-
43
- if (props._vnode) {
44
- if (!_this._temp) {
45
- _this._container = container; // Create a fake DOM parent node that manages a subset of `container`'s children:
46
-
47
- _this._temp = {
48
- nodeType: 1,
49
- parentNode: container,
50
- childNodes: [],
51
-
52
- appendChild(child) {
53
- this.childNodes.push(child);
54
-
55
- _this._container.appendChild(child);
56
- },
57
-
58
- insertBefore(child) {
59
- this.childNodes.push(child);
60
-
61
- _this._container.appendChild(child);
62
- },
63
-
64
- removeChild(child) {
65
- this.childNodes.splice( // eslint-disable-next-line no-bitwise
66
- this.childNodes.indexOf(child) >>> 1, 1);
67
-
68
- _this._container.removeChild(child);
69
- }
70
-
71
- };
72
- } // Render our wrapping element into temp.
73
-
74
-
75
- render(createElement(ContextProvider, {
76
- context: _this.context
77
- }, props._vnode), _this._temp);
78
- } // When we come from a conditional render, on a mounted
79
- // portal we should clear the DOM.
80
- else if (_this._temp) {
81
- _this.componentWillUnmount();
82
- }
83
- }
84
- /**
85
- * Create a `Portal` to continue rendering the vnode tree at a different DOM node
86
- *
87
- * @param {import('./internal').VNode} vnode The vnode to render
88
- * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
89
- */
90
-
91
-
92
- export function createPortal(vnode, container) {
93
- const el = createElement(Portal, {
94
- _vnode: vnode,
95
- _container: container
96
- });
97
- el.containerInfo = container;
98
- return el;
99
- }
100
- //# sourceMappingURL=portals.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/portals.js"],"names":["createElement","render","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":"AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,MAAxB,QAAsC,QAAtC;AAEA;AACA;AACA;;AACA,SAASC,eAAT,CAA0BC,KAA1B,EAAkC;AACjC,OAAKC,eAAL,GAAuB,MAAMD,KAAK,CAACE,OAAnC;;AACA,SAAOF,KAAK,CAACG,QAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,MAAT,CAAiBJ,KAAjB,EAAyB;AACxB,QAAMK,KAAK,GAAG,IAAd;;AACA,QAAMC,SAAS,GAAGN,KAAK,CAACO,UAAxB;;AAEAF,EAAAA,KAAK,CAACG,oBAAN,GAA6B,YAAY;AACxCV,IAAAA,MAAM,CAAE,IAAF,EAAQO,KAAK,CAACI,KAAd,CAAN;AACAJ,IAAAA,KAAK,CAACI,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,CAACU,MAHM,CADR,EAMLL,KAAK,CAACI,KAND,CAAN;AAQA,GArCD,CAsCA;AACA;AAvCA,OAwCK,IAAKJ,KAAK,CAACI,KAAX,EAAmB;AACvBJ,IAAAA,KAAK,CAACG,oBAAN;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASa,YAAT,CAAuBC,KAAvB,EAA8BhB,SAA9B,EAA0C;AAChD,QAAMiB,EAAE,GAAG1B,aAAa,CAAEO,MAAF,EAAU;AACjCM,IAAAA,MAAM,EAAEY,KADyB;AAEjCf,IAAAA,UAAU,EAAED;AAFqB,GAAV,CAAxB;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"]}
@@ -1,55 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { deepSignal } from 'deepsignal';
5
-
6
- const isObject = item => item && typeof item === 'object' && !Array.isArray(item);
7
-
8
- const deepMerge = (target, source) => {
9
- if (isObject(target) && isObject(source)) {
10
- for (const key in source) {
11
- if (isObject(source[key])) {
12
- if (!target[key]) Object.assign(target, {
13
- [key]: {}
14
- });
15
- deepMerge(target[key], source[key]);
16
- } else {
17
- Object.assign(target, {
18
- [key]: source[key]
19
- });
20
- }
21
- }
22
- }
23
- };
24
-
25
- const getSerializedState = () => {
26
- // TODO: change the store tag ID for a better one.
27
- const storeTag = document.querySelector(`script[type="application/json"]#store`);
28
- if (!storeTag) return {};
29
-
30
- try {
31
- const {
32
- state
33
- } = JSON.parse(storeTag.textContent);
34
- if (isObject(state)) return state;
35
- throw Error('Parsed state is not an object');
36
- } catch (e) {
37
- // eslint-disable-next-line no-console
38
- console.log(e);
39
- }
40
-
41
- return {};
42
- };
43
-
44
- const rawState = getSerializedState();
45
- export const rawStore = {
46
- state: deepSignal(rawState)
47
- };
48
- export const store = ({
49
- state,
50
- ...block
51
- }) => {
52
- deepMerge(rawStore, block);
53
- deepMerge(rawState, state);
54
- };
55
- //# sourceMappingURL=store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/store.js"],"names":["deepSignal","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":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,YAA3B;;AAEA,MAAMC,QAAQ,GAAKC,IAAF,IAChBA,IAAI,IAAI,OAAOA,IAAP,KAAgB,QAAxB,IAAoC,CAAEC,KAAK,CAACC,OAAN,CAAeF,IAAf,CADvC;;AAGA,MAAMG,SAAS,GAAG,CAAEC,MAAF,EAAUC,MAAV,KAAsB;AACvC,MAAKN,QAAQ,CAAEK,MAAF,CAAR,IAAsBL,QAAQ,CAAEM,MAAF,CAAnC,EAAgD;AAC/C,SAAM,MAAMC,GAAZ,IAAmBD,MAAnB,EAA4B;AAC3B,UAAKN,QAAQ,CAAEM,MAAM,CAAEC,GAAF,CAAR,CAAb,EAAiC;AAChC,YAAK,CAAEF,MAAM,CAAEE,GAAF,CAAb,EAAuBC,MAAM,CAACC,MAAP,CAAeJ,MAAf,EAAuB;AAAE,WAAEE,GAAF,GAAS;AAAX,SAAvB;AACvBH,QAAAA,SAAS,CAAEC,MAAM,CAAEE,GAAF,CAAR,EAAiBD,MAAM,CAAEC,GAAF,CAAvB,CAAT;AACA,OAHD,MAGO;AACNC,QAAAA,MAAM,CAACC,MAAP,CAAeJ,MAAf,EAAuB;AAAE,WAAEE,GAAF,GAASD,MAAM,CAAEC,GAAF;AAAjB,SAAvB;AACA;AACD;AACD;AACD,CAXD;;AAaA,MAAMG,kBAAkB,GAAG,MAAM;AAChC;AACA,QAAMC,QAAQ,GAAGC,QAAQ,CAACC,aAAT,CACf,uCADe,CAAjB;AAGA,MAAK,CAAEF,QAAP,EAAkB,OAAO,EAAP;;AAClB,MAAI;AACH,UAAM;AAAEG,MAAAA;AAAF,QAAYC,IAAI,CAACC,KAAL,CAAYL,QAAQ,CAACM,WAArB,CAAlB;AACA,QAAKjB,QAAQ,CAAEc,KAAF,CAAb,EAAyB,OAAOA,KAAP;AACzB,UAAMI,KAAK,CAAE,+BAAF,CAAX;AACA,GAJD,CAIE,OAAQC,CAAR,EAAY;AACb;AACAC,IAAAA,OAAO,CAACC,GAAR,CAAaF,CAAb;AACA;;AACD,SAAO,EAAP;AACA,CAfD;;AAiBA,MAAMG,QAAQ,GAAGZ,kBAAkB,EAAnC;AACA,OAAO,MAAMa,QAAQ,GAAG;AAAET,EAAAA,KAAK,EAAEf,UAAU,CAAEuB,QAAF;AAAnB,CAAjB;AAEP,OAAO,MAAME,KAAK,GAAG,CAAE;AAAEV,EAAAA,KAAF;AAAS,KAAGW;AAAZ,CAAF,KAA2B;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"]}