@wordpress/block-library 8.8.0 → 8.10.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 (437) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/comment-author-name/edit.js +1 -1
  3. package/build/comment-author-name/edit.js.map +1 -1
  4. package/build/comment-edit-link/edit.js +1 -1
  5. package/build/comment-edit-link/edit.js.map +1 -1
  6. package/build/cover/edit/inspector-controls.js +1 -1
  7. package/build/cover/edit/inspector-controls.js.map +1 -1
  8. package/build/cover/index.js +1 -1
  9. package/build/cover/transforms.js +10 -7
  10. package/build/cover/transforms.js.map +1 -1
  11. package/build/cover/variations.js +1 -1
  12. package/build/cover/variations.js.map +1 -1
  13. package/build/details/edit.js +19 -5
  14. package/build/details/edit.js.map +1 -1
  15. package/build/details/index.js +14 -10
  16. package/build/details/index.js.map +1 -1
  17. package/build/details/save.js +4 -1
  18. package/build/details/save.js.map +1 -1
  19. package/build/embed/variations.js +2 -2
  20. package/build/embed/variations.js.map +1 -1
  21. package/build/file/view.js +1 -1
  22. package/build/file/view.js.map +1 -1
  23. package/build/gallery/edit.js +2 -8
  24. package/build/gallery/edit.js.map +1 -1
  25. package/build/group/edit.js +3 -1
  26. package/build/group/edit.js.map +1 -1
  27. package/build/group/index.js +3 -0
  28. package/build/group/index.js.map +1 -1
  29. package/build/image/edit.js +16 -13
  30. package/build/image/edit.js.map +1 -1
  31. package/build/image/index.js +1 -1
  32. package/build/index.js +0 -6
  33. package/build/index.js.map +1 -1
  34. package/build/index.native.js +10 -6
  35. package/build/index.native.js.map +1 -1
  36. package/build/list-item/utils.js +5 -1
  37. package/build/list-item/utils.js.map +1 -1
  38. package/build/loginout/index.js +11 -1
  39. package/build/loginout/index.js.map +1 -1
  40. package/build/media-text/edit.js +4 -2
  41. package/build/media-text/edit.js.map +1 -1
  42. package/build/media-text/index.js +3 -0
  43. package/build/media-text/index.js.map +1 -1
  44. package/build/navigation/constants.js +13 -0
  45. package/build/navigation/constants.js.map +1 -0
  46. package/build/navigation/edit/index.js +26 -68
  47. package/build/navigation/edit/index.js.map +1 -1
  48. package/build/navigation/edit/inner-blocks.js +4 -7
  49. package/build/navigation/edit/inner-blocks.js.map +1 -1
  50. package/build/navigation/edit/unsaved-inner-blocks.js +4 -6
  51. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  52. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
  53. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  54. package/build/navigation/interactivity.js +139 -0
  55. package/build/navigation/interactivity.js.map +1 -0
  56. package/build/navigation-link/edit.js +1 -1
  57. package/build/navigation-link/edit.js.map +1 -1
  58. package/build/navigation-submenu/edit.js +1 -1
  59. package/build/navigation-submenu/edit.js.map +1 -1
  60. package/build/paragraph/index.js +5 -1
  61. package/build/paragraph/index.js.map +1 -1
  62. package/build/paragraph/transforms.js +5 -1
  63. package/build/paragraph/transforms.js.map +1 -1
  64. package/build/post-author-name/edit.js +1 -1
  65. package/build/post-author-name/edit.js.map +1 -1
  66. package/build/post-date/edit.js +4 -2
  67. package/build/post-date/edit.js.map +1 -1
  68. package/build/post-excerpt/edit.js +2 -2
  69. package/build/post-excerpt/edit.js.map +1 -1
  70. package/build/post-featured-image/edit.js +6 -4
  71. package/build/post-featured-image/edit.js.map +1 -1
  72. package/build/post-featured-image/overlay.js +5 -0
  73. package/build/post-featured-image/overlay.js.map +1 -1
  74. package/build/post-title/edit.js +14 -4
  75. package/build/post-title/edit.js.map +1 -1
  76. package/build/preformatted/edit.native.js +3 -2
  77. package/build/preformatted/edit.native.js.map +1 -1
  78. package/build/query/deprecated.js +8 -6
  79. package/build/query/deprecated.js.map +1 -1
  80. package/build/query/edit/inspector-controls/create-new-post-link.js +41 -0
  81. package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  82. package/build/query/edit/inspector-controls/index.js +14 -6
  83. package/build/query/edit/inspector-controls/index.js.map +1 -1
  84. package/build/query/edit/pattern-selection-modal.js +2 -1
  85. package/build/query/edit/pattern-selection-modal.js.map +1 -1
  86. package/build/query/index.js +5 -12
  87. package/build/query/index.js.map +1 -1
  88. package/build/quote/transforms.js +16 -27
  89. package/build/quote/transforms.js.map +1 -1
  90. package/build/read-more/edit.js +1 -1
  91. package/build/read-more/edit.js.map +1 -1
  92. package/build/search/edit.js +9 -1
  93. package/build/search/edit.js.map +1 -1
  94. package/build/site-logo/edit.js +114 -16
  95. package/build/site-logo/edit.js.map +1 -1
  96. package/build/site-logo/index.js +1 -1
  97. package/build/site-title/edit/index.js +1 -1
  98. package/build/site-title/edit/index.js.map +1 -1
  99. package/build/social-link/icons/chain.js +1 -1
  100. package/build/social-link/icons/chain.js.map +1 -1
  101. package/build/social-link/icons/mail.js +1 -1
  102. package/build/social-link/icons/mail.js.map +1 -1
  103. package/build/social-links/edit.js +2 -2
  104. package/build/social-links/edit.js.map +1 -1
  105. package/build/spacer/edit.js +117 -11
  106. package/build/spacer/edit.js.map +1 -1
  107. package/build/template-part/edit/index.js +2 -1
  108. package/build/template-part/edit/index.js.map +1 -1
  109. package/build/template-part/edit/utils/hooks.js +2 -2
  110. package/build/template-part/edit/utils/hooks.js.map +1 -1
  111. package/build/utils/interactivity/constants.js +9 -0
  112. package/build/utils/interactivity/constants.js.map +1 -0
  113. package/build/utils/interactivity/directives.js +208 -0
  114. package/build/utils/interactivity/directives.js.map +1 -0
  115. package/build/utils/interactivity/hooks.js +112 -0
  116. package/build/utils/interactivity/hooks.js.map +1 -0
  117. package/build/utils/interactivity/hydration.js +34 -0
  118. package/build/utils/interactivity/hydration.js.map +1 -0
  119. package/build/utils/interactivity/index.js +34 -0
  120. package/build/utils/interactivity/index.js.map +1 -0
  121. package/build/utils/interactivity/store.js +67 -0
  122. package/build/utils/interactivity/store.js.map +1 -0
  123. package/build/utils/interactivity/utils.js +87 -0
  124. package/build/utils/interactivity/utils.js.map +1 -0
  125. package/build/utils/interactivity/vdom.js +109 -0
  126. package/build/utils/interactivity/vdom.js.map +1 -0
  127. package/build/utils/migrate-font-family.js +12 -5
  128. package/build/utils/migrate-font-family.js.map +1 -1
  129. package/build/video/edit.native.js +4 -3
  130. package/build/video/edit.native.js.map +1 -1
  131. package/build-module/comment-author-name/edit.js +1 -1
  132. package/build-module/comment-author-name/edit.js.map +1 -1
  133. package/build-module/comment-edit-link/edit.js +1 -1
  134. package/build-module/comment-edit-link/edit.js.map +1 -1
  135. package/build-module/cover/edit/inspector-controls.js +1 -1
  136. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  137. package/build-module/cover/index.js +1 -1
  138. package/build-module/cover/transforms.js +5 -1
  139. package/build-module/cover/transforms.js.map +1 -1
  140. package/build-module/cover/variations.js +1 -1
  141. package/build-module/cover/variations.js.map +1 -1
  142. package/build-module/details/edit.js +20 -6
  143. package/build-module/details/edit.js.map +1 -1
  144. package/build-module/details/index.js +14 -10
  145. package/build-module/details/index.js.map +1 -1
  146. package/build-module/details/save.js +5 -2
  147. package/build-module/details/save.js.map +1 -1
  148. package/build-module/embed/variations.js +2 -2
  149. package/build-module/embed/variations.js.map +1 -1
  150. package/build-module/file/view.js +1 -1
  151. package/build-module/file/view.js.map +1 -1
  152. package/build-module/gallery/edit.js +2 -8
  153. package/build-module/gallery/edit.js.map +1 -1
  154. package/build-module/group/edit.js +3 -1
  155. package/build-module/group/edit.js.map +1 -1
  156. package/build-module/group/index.js +3 -0
  157. package/build-module/group/index.js.map +1 -1
  158. package/build-module/image/edit.js +16 -13
  159. package/build-module/image/edit.js.map +1 -1
  160. package/build-module/image/index.js +1 -1
  161. package/build-module/index.js +0 -4
  162. package/build-module/index.js.map +1 -1
  163. package/build-module/index.native.js +10 -6
  164. package/build-module/index.native.js.map +1 -1
  165. package/build-module/list-item/utils.js +5 -1
  166. package/build-module/list-item/utils.js.map +1 -1
  167. package/build-module/loginout/index.js +11 -1
  168. package/build-module/loginout/index.js.map +1 -1
  169. package/build-module/media-text/edit.js +4 -2
  170. package/build-module/media-text/edit.js.map +1 -1
  171. package/build-module/media-text/index.js +3 -0
  172. package/build-module/media-text/index.js.map +1 -1
  173. package/build-module/navigation/constants.js +5 -0
  174. package/build-module/navigation/constants.js.map +1 -0
  175. package/build-module/navigation/edit/index.js +28 -69
  176. package/build-module/navigation/edit/index.js.map +1 -1
  177. package/build-module/navigation/edit/inner-blocks.js +1 -4
  178. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  179. package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -4
  180. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  181. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
  182. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  183. package/build-module/navigation/interactivity.js +136 -0
  184. package/build-module/navigation/interactivity.js.map +1 -0
  185. package/build-module/navigation-link/edit.js +1 -1
  186. package/build-module/navigation-link/edit.js.map +1 -1
  187. package/build-module/navigation-submenu/edit.js +1 -1
  188. package/build-module/navigation-submenu/edit.js.map +1 -1
  189. package/build-module/paragraph/index.js +5 -1
  190. package/build-module/paragraph/index.js.map +1 -1
  191. package/build-module/paragraph/transforms.js +5 -1
  192. package/build-module/paragraph/transforms.js.map +1 -1
  193. package/build-module/post-author-name/edit.js +1 -1
  194. package/build-module/post-author-name/edit.js.map +1 -1
  195. package/build-module/post-date/edit.js +4 -2
  196. package/build-module/post-date/edit.js.map +1 -1
  197. package/build-module/post-excerpt/edit.js +2 -2
  198. package/build-module/post-excerpt/edit.js.map +1 -1
  199. package/build-module/post-featured-image/edit.js +6 -4
  200. package/build-module/post-featured-image/edit.js.map +1 -1
  201. package/build-module/post-featured-image/overlay.js +5 -0
  202. package/build-module/post-featured-image/overlay.js.map +1 -1
  203. package/build-module/post-title/edit.js +13 -4
  204. package/build-module/post-title/edit.js.map +1 -1
  205. package/build-module/preformatted/edit.native.js +3 -2
  206. package/build-module/preformatted/edit.native.js.map +1 -1
  207. package/build-module/query/deprecated.js +5 -2
  208. package/build-module/query/deprecated.js.map +1 -1
  209. package/build-module/query/edit/inspector-controls/create-new-post-link.js +33 -0
  210. package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
  211. package/build-module/query/edit/inspector-controls/index.js +12 -7
  212. package/build-module/query/edit/inspector-controls/index.js.map +1 -1
  213. package/build-module/query/edit/pattern-selection-modal.js +2 -1
  214. package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
  215. package/build-module/query/index.js +5 -10
  216. package/build-module/query/index.js.map +1 -1
  217. package/build-module/quote/transforms.js +16 -27
  218. package/build-module/quote/transforms.js.map +1 -1
  219. package/build-module/read-more/edit.js +1 -1
  220. package/build-module/read-more/edit.js.map +1 -1
  221. package/build-module/search/edit.js +9 -1
  222. package/build-module/search/edit.js.map +1 -1
  223. package/build-module/site-logo/edit.js +115 -18
  224. package/build-module/site-logo/edit.js.map +1 -1
  225. package/build-module/site-logo/index.js +1 -1
  226. package/build-module/site-title/edit/index.js +1 -1
  227. package/build-module/site-title/edit/index.js.map +1 -1
  228. package/build-module/social-link/icons/chain.js +1 -1
  229. package/build-module/social-link/icons/chain.js.map +1 -1
  230. package/build-module/social-link/icons/mail.js +1 -1
  231. package/build-module/social-link/icons/mail.js.map +1 -1
  232. package/build-module/social-links/edit.js +2 -2
  233. package/build-module/social-links/edit.js.map +1 -1
  234. package/build-module/spacer/edit.js +118 -12
  235. package/build-module/spacer/edit.js.map +1 -1
  236. package/build-module/template-part/edit/index.js +2 -1
  237. package/build-module/template-part/edit/index.js.map +1 -1
  238. package/build-module/template-part/edit/utils/hooks.js +2 -2
  239. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  240. package/build-module/utils/interactivity/constants.js +2 -0
  241. package/build-module/utils/interactivity/constants.js.map +1 -0
  242. package/build-module/utils/interactivity/directives.js +193 -0
  243. package/build-module/utils/interactivity/directives.js.map +1 -0
  244. package/build-module/utils/interactivity/hooks.js +98 -0
  245. package/build-module/utils/interactivity/hooks.js.map +1 -0
  246. package/build-module/utils/interactivity/hydration.js +21 -0
  247. package/build-module/utils/interactivity/hydration.js.map +1 -0
  248. package/build-module/utils/interactivity/index.js +17 -0
  249. package/build-module/utils/interactivity/index.js.map +1 -0
  250. package/build-module/utils/interactivity/store.js +56 -0
  251. package/build-module/utils/interactivity/store.js.map +1 -0
  252. package/build-module/utils/interactivity/utils.js +75 -0
  253. package/build-module/utils/interactivity/utils.js.map +1 -0
  254. package/build-module/utils/interactivity/vdom.js +97 -0
  255. package/build-module/utils/interactivity/vdom.js.map +1 -0
  256. package/build-module/utils/migrate-font-family.js +9 -1
  257. package/build-module/utils/migrate-font-family.js.map +1 -1
  258. package/build-module/video/edit.native.js +4 -3
  259. package/build-module/video/edit.native.js.map +1 -1
  260. package/build-style/cover/editor-rtl.css +3 -3
  261. package/build-style/cover/editor.css +3 -3
  262. package/build-style/cover/style-rtl.css +2 -1
  263. package/build-style/cover/style.css +2 -1
  264. package/build-style/{details-summary → details}/editor-rtl.css +1 -1
  265. package/build-style/{details-summary → details}/editor.css +1 -1
  266. package/build-style/details/style-rtl.css +14 -0
  267. package/build-style/details/style.css +14 -0
  268. package/build-style/editor-rtl.css +74 -39
  269. package/build-style/editor.css +74 -39
  270. package/build-style/gallery/editor-rtl.css +0 -4
  271. package/build-style/gallery/editor.css +0 -4
  272. package/build-style/html/editor-rtl.css +2 -2
  273. package/build-style/html/editor.css +2 -2
  274. package/build-style/image/editor-rtl.css +1 -1
  275. package/build-style/image/editor.css +1 -1
  276. package/build-style/query/editor-rtl.css +8 -12
  277. package/build-style/query/editor.css +8 -12
  278. package/build-style/search/editor-rtl.css +1 -0
  279. package/build-style/search/editor.css +1 -0
  280. package/build-style/search/style-rtl.css +2 -0
  281. package/build-style/search/style.css +2 -0
  282. package/build-style/shortcode/editor-rtl.css +3 -4
  283. package/build-style/shortcode/editor.css +3 -4
  284. package/build-style/site-logo/editor-rtl.css +47 -0
  285. package/build-style/site-logo/editor.css +47 -0
  286. package/build-style/style-rtl.css +15 -2
  287. package/build-style/style.css +15 -2
  288. package/build-style/template-part/editor-rtl.css +8 -12
  289. package/build-style/template-part/editor.css +8 -12
  290. package/package.json +36 -32
  291. package/src/buttons/test/__snapshots__/edit.native.js.snap +18 -0
  292. package/src/buttons/test/edit.native.js +123 -2
  293. package/src/comment-author-name/edit.js +1 -1
  294. package/src/comment-edit-link/edit.js +1 -1
  295. package/src/comment-template/index.php +8 -7
  296. package/src/cover/block.json +1 -1
  297. package/src/cover/edit/inspector-controls.js +56 -54
  298. package/src/cover/editor.scss +1 -1
  299. package/src/cover/style.scss +4 -0
  300. package/src/cover/test/edit.js +56 -2
  301. package/src/cover/transforms.js +4 -1
  302. package/src/cover/variations.js +1 -3
  303. package/src/details/block.json +8 -6
  304. package/src/details/edit.js +27 -5
  305. package/src/details/editor.scss +3 -0
  306. package/src/details/index.js +10 -5
  307. package/src/details/save.js +5 -1
  308. package/src/details/style.scss +16 -0
  309. package/src/editor.scss +1 -1
  310. package/src/embed/variations.js +2 -2
  311. package/src/file/view.js +4 -1
  312. package/src/gallery/edit.js +5 -8
  313. package/src/gallery/editor.scss +0 -6
  314. package/src/gallery/test/index.native.js +52 -7
  315. package/src/group/block.json +3 -0
  316. package/src/group/edit.js +8 -2
  317. package/src/heading/test/__snapshots__/index.native.js.snap +12 -0
  318. package/src/heading/test/index.native.js +71 -0
  319. package/src/html/editor.scss +2 -21
  320. package/src/image/block.json +1 -1
  321. package/src/image/edit.js +21 -17
  322. package/src/image/editor.scss +1 -1
  323. package/src/image/test/edit.native.js +38 -16
  324. package/src/index.js +0 -4
  325. package/src/index.native.js +10 -5
  326. package/src/list/test/edit.native.js +7 -7
  327. package/src/loginout/block.json +11 -1
  328. package/src/media-text/block.json +3 -0
  329. package/src/media-text/edit.js +2 -1
  330. package/src/navigation/constants.js +16 -0
  331. package/src/navigation/edit/index.js +77 -163
  332. package/src/navigation/edit/inner-blocks.js +1 -16
  333. package/src/navigation/edit/unsaved-inner-blocks.js +1 -16
  334. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +1 -1
  335. package/src/navigation/index.php +210 -197
  336. package/src/navigation/interactivity.js +144 -0
  337. package/src/navigation-link/edit.js +1 -1
  338. package/src/navigation-submenu/edit.js +1 -1
  339. package/src/paragraph/block.json +5 -1
  340. package/src/paragraph/test/edit.native.js +288 -28
  341. package/src/post-author-name/edit.js +1 -1
  342. package/src/post-date/edit.js +4 -0
  343. package/src/post-date/index.php +17 -8
  344. package/src/post-excerpt/edit.js +1 -1
  345. package/src/post-featured-image/edit.js +5 -4
  346. package/src/post-featured-image/overlay.js +4 -0
  347. package/src/post-terms/index.php +2 -2
  348. package/src/post-title/edit.js +8 -1
  349. package/src/preformatted/edit.native.js +1 -3
  350. package/src/preformatted/test/edit.native.js +6 -9
  351. package/src/pullquote/test/edit.native.js +7 -12
  352. package/src/query/deprecated.js +4 -1
  353. package/src/query/edit/inspector-controls/create-new-post-link.js +26 -0
  354. package/src/query/edit/inspector-controls/index.js +13 -6
  355. package/src/query/edit/pattern-selection-modal.js +1 -0
  356. package/src/query/editor.scss +8 -11
  357. package/src/query/index.js +1 -7
  358. package/src/quote/test/edit.native.js +6 -10
  359. package/src/quote/transforms.js +0 -6
  360. package/src/read-more/edit.js +1 -1
  361. package/src/search/edit.js +9 -4
  362. package/src/search/editor.scss +1 -0
  363. package/src/search/style.scss +3 -0
  364. package/src/shortcode/editor.scss +1 -21
  365. package/src/site-logo/block.json +1 -1
  366. package/src/site-logo/edit.js +123 -9
  367. package/src/site-logo/editor.scss +58 -0
  368. package/src/site-title/edit/index.js +1 -1
  369. package/src/social-link/icons/chain.js +1 -1
  370. package/src/social-link/icons/mail.js +1 -1
  371. package/src/social-link/index.php +2 -2
  372. package/src/social-links/edit.js +33 -31
  373. package/src/spacer/edit.js +157 -18
  374. package/src/style.scss +0 -1
  375. package/src/template-part/edit/index.js +1 -0
  376. package/src/template-part/edit/utils/hooks.js +2 -2
  377. package/src/template-part/editor.scss +9 -11
  378. package/src/template-part/index.php +20 -5
  379. package/src/utils/interactivity/constants.js +1 -0
  380. package/src/utils/interactivity/directives.js +179 -0
  381. package/src/utils/interactivity/hooks.js +76 -0
  382. package/src/utils/interactivity/hydration.js +22 -0
  383. package/src/utils/interactivity/index.js +17 -0
  384. package/src/utils/interactivity/store.js +45 -0
  385. package/src/utils/interactivity/utils.js +66 -0
  386. package/src/utils/interactivity/vdom.js +94 -0
  387. package/src/utils/migrate-font-family.js +8 -1
  388. package/src/verse/test/edit.native.js +4 -9
  389. package/src/video/edit.native.js +2 -2
  390. package/tsconfig.json +2 -0
  391. package/tsconfig.tsbuildinfo +1 -1
  392. package/build/details-content/edit.js +0 -34
  393. package/build/details-content/edit.js.map +0 -1
  394. package/build/details-content/index.js +0 -94
  395. package/build/details-content/index.js.map +0 -1
  396. package/build/details-content/save.js +0 -20
  397. package/build/details-content/save.js.map +0 -1
  398. package/build/details-summary/edit.js +0 -42
  399. package/build/details-summary/edit.js.map +0 -1
  400. package/build/details-summary/index.js +0 -97
  401. package/build/details-summary/index.js.map +0 -1
  402. package/build/details-summary/save.js +0 -24
  403. package/build/details-summary/save.js.map +0 -1
  404. package/build/query/hooks.js +0 -72
  405. package/build/query/hooks.js.map +0 -1
  406. package/build/utils/clean-empty-object.js +0 -37
  407. package/build/utils/clean-empty-object.js.map +0 -1
  408. package/build-module/details-content/edit.js +0 -23
  409. package/build-module/details-content/edit.js.map +0 -1
  410. package/build-module/details-content/index.js +0 -76
  411. package/build-module/details-content/index.js.map +0 -1
  412. package/build-module/details-content/save.js +0 -11
  413. package/build-module/details-content/save.js.map +0 -1
  414. package/build-module/details-summary/edit.js +0 -30
  415. package/build-module/details-summary/edit.js.map +0 -1
  416. package/build-module/details-summary/index.js +0 -79
  417. package/build-module/details-summary/index.js.map +0 -1
  418. package/build-module/details-summary/save.js +0 -16
  419. package/build-module/details-summary/save.js.map +0 -1
  420. package/build-module/query/hooks.js +0 -59
  421. package/build-module/query/hooks.js.map +0 -1
  422. package/build-module/utils/clean-empty-object.js +0 -28
  423. package/build-module/utils/clean-empty-object.js.map +0 -1
  424. package/build-style/details-summary/style-rtl.css +0 -91
  425. package/build-style/details-summary/style.css +0 -91
  426. package/src/details-content/block.json +0 -50
  427. package/src/details-content/edit.js +0 -29
  428. package/src/details-content/index.js +0 -23
  429. package/src/details-content/save.js +0 -12
  430. package/src/details-summary/block.json +0 -53
  431. package/src/details-summary/edit.js +0 -27
  432. package/src/details-summary/editor.scss +0 -3
  433. package/src/details-summary/index.js +0 -23
  434. package/src/details-summary/save.js +0 -13
  435. package/src/details-summary/style.scss +0 -3
  436. package/src/query/hooks.js +0 -53
  437. package/src/utils/clean-empty-object.js +0 -28
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _hooks = require("preact/hooks");
15
+
16
+ var _deepsignal = require("deepsignal");
17
+
18
+ var _utils = require("./utils");
19
+
20
+ var _hooks2 = require("./hooks");
21
+
22
+ /**
23
+ * External dependencies
24
+ */
25
+
26
+ /**
27
+ * Internal dependencies
28
+ */
29
+ const isObject = item => item && typeof item === 'object' && !Array.isArray(item);
30
+
31
+ const mergeDeepSignals = (target, source) => {
32
+ for (const k in source) {
33
+ if (typeof (0, _deepsignal.peek)(target, k) === 'undefined') {
34
+ target[`$${k}`] = source[`$${k}`];
35
+ } else if (isObject((0, _deepsignal.peek)(target, k)) && isObject((0, _deepsignal.peek)(source, k))) {
36
+ mergeDeepSignals(target[`$${k}`].peek(), source[`$${k}`].peek());
37
+ }
38
+ }
39
+ };
40
+
41
+ var _default = () => {
42
+ // data-wp-context
43
+ (0, _hooks2.directive)('context', _ref => {
44
+ let {
45
+ directives: {
46
+ context: {
47
+ default: context
48
+ }
49
+ },
50
+ props: {
51
+ children
52
+ },
53
+ context: inherited
54
+ } = _ref;
55
+ const {
56
+ Provider
57
+ } = inherited;
58
+ const inheritedValue = (0, _hooks.useContext)(inherited);
59
+ const value = (0, _hooks.useMemo)(() => {
60
+ const localValue = (0, _deepsignal.deepSignal)(context);
61
+ mergeDeepSignals(localValue, inheritedValue);
62
+ return localValue;
63
+ }, [context, inheritedValue]);
64
+ return (0, _element.createElement)(Provider, {
65
+ value: value
66
+ }, children);
67
+ }); // data-wp-effect.[name]
68
+
69
+ (0, _hooks2.directive)('effect', _ref2 => {
70
+ let {
71
+ directives: {
72
+ effect
73
+ },
74
+ context,
75
+ evaluate
76
+ } = _ref2;
77
+ const contextValue = (0, _hooks.useContext)(context);
78
+ Object.values(effect).forEach(path => {
79
+ (0, _utils.useSignalEffect)(() => {
80
+ return evaluate(path, {
81
+ context: contextValue
82
+ });
83
+ });
84
+ });
85
+ }); // data-wp-init.[name]
86
+
87
+ (0, _hooks2.directive)('init', _ref3 => {
88
+ let {
89
+ directives: {
90
+ init
91
+ },
92
+ context,
93
+ evaluate
94
+ } = _ref3;
95
+ const contextValue = (0, _hooks.useContext)(context);
96
+ Object.values(init).forEach(path => {
97
+ (0, _hooks.useEffect)(() => {
98
+ return evaluate(path, {
99
+ context: contextValue
100
+ });
101
+ }, []);
102
+ });
103
+ }); // data-wp-on.[event]
104
+
105
+ (0, _hooks2.directive)('on', _ref4 => {
106
+ let {
107
+ directives: {
108
+ on
109
+ },
110
+ element,
111
+ evaluate,
112
+ context
113
+ } = _ref4;
114
+ const contextValue = (0, _hooks.useContext)(context);
115
+ Object.entries(on).forEach(_ref5 => {
116
+ let [name, path] = _ref5;
117
+
118
+ element.props[`on${name}`] = event => {
119
+ evaluate(path, {
120
+ event,
121
+ context: contextValue
122
+ });
123
+ };
124
+ });
125
+ }); // data-wp-class.[classname]
126
+
127
+ (0, _hooks2.directive)('class', _ref6 => {
128
+ let {
129
+ directives: {
130
+ class: className
131
+ },
132
+ element,
133
+ evaluate,
134
+ context
135
+ } = _ref6;
136
+ const contextValue = (0, _hooks.useContext)(context);
137
+ Object.keys(className).filter(n => n !== 'default').forEach(name => {
138
+ const result = evaluate(className[name], {
139
+ className: name,
140
+ context: contextValue
141
+ });
142
+ const currentClass = element.props.class || '';
143
+ const classFinder = new RegExp(`(^|\\s)${name}(\\s|$)`, 'g');
144
+ if (!result) element.props.class = currentClass.replace(classFinder, ' ').trim();else if (!classFinder.test(currentClass)) element.props.class = currentClass ? `${currentClass} ${name}` : name;
145
+ (0, _hooks.useEffect)(() => {
146
+ // This seems necessary because Preact doesn't change the class
147
+ // names on the hydration, so we have to do it manually. It doesn't
148
+ // need deps because it only needs to do it the first time.
149
+ if (!result) {
150
+ element.ref.current.classList.remove(name);
151
+ } else {
152
+ element.ref.current.classList.add(name);
153
+ }
154
+ }, []);
155
+ });
156
+ }); // data-wp-bind.[attribute]
157
+
158
+ (0, _hooks2.directive)('bind', _ref7 => {
159
+ let {
160
+ directives: {
161
+ bind
162
+ },
163
+ element,
164
+ context,
165
+ evaluate
166
+ } = _ref7;
167
+ const contextValue = (0, _hooks.useContext)(context);
168
+ Object.entries(bind).filter(n => n !== 'default').forEach(_ref8 => {
169
+ let [attribute, path] = _ref8;
170
+ const result = evaluate(path, {
171
+ context: contextValue
172
+ });
173
+ element.props[attribute] = result;
174
+ (0, _hooks.useEffect)(() => {
175
+ // This seems necessary because Preact doesn't change the attributes
176
+ // on the hydration, so we have to do it manually. It doesn't need
177
+ // deps because it only needs to do it the first time.
178
+ if (result === false) {
179
+ element.ref.current.removeAttribute(attribute);
180
+ } else {
181
+ element.ref.current.setAttribute(attribute, result === true ? '' : result);
182
+ }
183
+ }, []);
184
+ });
185
+ }); // data-wp-ignore
186
+
187
+ (0, _hooks2.directive)('ignore', _ref9 => {
188
+ let {
189
+ element: {
190
+ type: Type,
191
+ props: {
192
+ innerHTML,
193
+ ...rest
194
+ }
195
+ }
196
+ } = _ref9;
197
+ // Preserve the initial inner HTML.
198
+ const cached = (0, _hooks.useMemo)(() => innerHTML, []);
199
+ return (0, _element.createElement)(Type, (0, _extends2.default)({
200
+ dangerouslySetInnerHTML: {
201
+ __html: cached
202
+ }
203
+ }, rest));
204
+ });
205
+ };
206
+
207
+ exports.default = _default;
208
+ //# sourceMappingURL=directives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/directives.js"],"names":["isObject","item","Array","isArray","mergeDeepSignals","target","source","k","peek","directives","context","default","props","children","inherited","Provider","inheritedValue","value","localValue","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":";;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIA,MAAMA,QAAQ,GAAKC,IAAF,IAChBA,IAAI,IAAI,OAAOA,IAAP,KAAgB,QAAxB,IAAoC,CAAEC,KAAK,CAACC,OAAN,CAAeF,IAAf,CADvC;;AAGA,MAAMG,gBAAgB,GAAG,CAAEC,MAAF,EAAUC,MAAV,KAAsB;AAC9C,OAAM,MAAMC,CAAZ,IAAiBD,MAAjB,EAA0B;AACzB,QAAK,OAAO,sBAAMD,MAAN,EAAcE,CAAd,CAAP,KAA6B,WAAlC,EAAgD;AAC/CF,MAAAA,MAAM,CAAG,IAAIE,CAAG,EAAV,CAAN,GAAsBD,MAAM,CAAG,IAAIC,CAAG,EAAV,CAA5B;AACA,KAFD,MAEO,IACNP,QAAQ,CAAE,sBAAMK,MAAN,EAAcE,CAAd,CAAF,CAAR,IACAP,QAAQ,CAAE,sBAAMM,MAAN,EAAcC,CAAd,CAAF,CAFF,EAGL;AACDH,MAAAA,gBAAgB,CACfC,MAAM,CAAG,IAAIE,CAAG,EAAV,CAAN,CAA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act/hooks';\nimport { deepSignal, peek } from 'deepsignal';\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);\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\tuseEffect( () => {\n\t\t\t\t\t\t// This seems necessary because Preact doesn't change the attributes\n\t\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\t// deps because it only needs to do it the first time.\n\t\t\t\t\t\tif ( result === false ) {\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 ? '' : 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"]}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.directive = void 0;
7
+
8
+ var _preact = require("preact");
9
+
10
+ var _hooks = require("preact/hooks");
11
+
12
+ var _store = require("./store");
13
+
14
+ /**
15
+ * External dependencies
16
+ */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ // Main context.
22
+ const context = (0, _preact.createContext)({}); // WordPress Directives.
23
+
24
+ const directiveMap = {};
25
+
26
+ const directive = (name, cb) => {
27
+ directiveMap[name] = cb;
28
+ }; // Resolve the path to some property of the store object.
29
+
30
+
31
+ exports.directive = directive;
32
+
33
+ const resolve = (path, ctx) => {
34
+ // If path starts with !, remove it and save a flag.
35
+ const hasNegationOperator = path[0] === '!' && !!(path = path.slice(1));
36
+ let current = { ..._store.rawStore,
37
+ context: ctx
38
+ };
39
+ path.split('.').forEach(p => current = current[p]);
40
+ return hasNegationOperator ? !current : current;
41
+ }; // Generate the evaluate function.
42
+
43
+
44
+ const getEvaluate = function () {
45
+ let {
46
+ ref
47
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
48
+ return function (path) {
49
+ let extraArgs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
50
+ const value = resolve(path, extraArgs.context);
51
+ return typeof value === 'function' ? value({
52
+ ref: ref.current,
53
+ ..._store.rawStore,
54
+ ...extraArgs
55
+ }) : value;
56
+ };
57
+ }; // Directive wrapper.
58
+
59
+
60
+ const Directive = _ref => {
61
+ let {
62
+ type,
63
+ directives,
64
+ props: originalProps
65
+ } = _ref;
66
+ const ref = (0, _hooks.useRef)(null);
67
+ const element = (0, _preact.h)(type, { ...originalProps,
68
+ ref
69
+ });
70
+ const props = { ...originalProps,
71
+ children: element
72
+ };
73
+ const evaluate = (0, _hooks.useMemo)(() => getEvaluate({
74
+ ref
75
+ }), []);
76
+ const directiveArgs = {
77
+ directives,
78
+ props,
79
+ element,
80
+ context,
81
+ evaluate
82
+ };
83
+
84
+ for (const d in directives) {
85
+ var _directiveMap$d;
86
+
87
+ const wrapper = (_directiveMap$d = directiveMap[d]) === null || _directiveMap$d === void 0 ? void 0 : _directiveMap$d.call(directiveMap, directiveArgs);
88
+ if (wrapper !== undefined) props.children = wrapper;
89
+ }
90
+
91
+ return props.children;
92
+ }; // Preact Options Hook called each time a vnode is created.
93
+
94
+
95
+ const old = _preact.options.vnode;
96
+
97
+ _preact.options.vnode = vnode => {
98
+ if (vnode.props.__directives) {
99
+ const props = vnode.props;
100
+ const directives = props.__directives;
101
+ delete props.__directives;
102
+ vnode.props = {
103
+ type: vnode.type,
104
+ directives,
105
+ props
106
+ };
107
+ vnode.type = Directive;
108
+ }
109
+
110
+ if (old) old(vnode);
111
+ };
112
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hooks.js"],"names":["context","directiveMap","directive","name","cb","resolve","path","ctx","hasNegationOperator","slice","current","store","split","forEach","p","getEvaluate","ref","extraArgs","value","Directive","type","directives","props","originalProps","element","children","evaluate","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;;AACO,MAAMC,SAAS,GAAG,CAAEC,IAAF,EAAQC,EAAR,KAAgB;AACxCH,EAAAA,YAAY,CAAEE,IAAF,CAAZ,GAAuBC,EAAvB;AACA,CAFM,C,CAIP;;;;;AACA,MAAMC,OAAO,GAAG,CAAEC,IAAF,EAAQC,GAAR,KAAiB;AAChC;AACA,QAAMC,mBAAmB,GACxBF,IAAI,CAAE,CAAF,CAAJ,KAAc,GAAd,IAAqB,CAAC,EAAIA,IAAI,GAAGA,IAAI,CAACG,KAAL,CAAY,CAAZ,CAAX,CADvB;AAEA,MAAIC,OAAO,GAAG,EAAE,GAAGC,eAAL;AAAYX,IAAAA,OAAO,EAAEO;AAArB,GAAd;AACA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M,MAAME,CAAZ,IAAiBP,UAAjB,EAA8B;AAAA;;AAC7B,UAAMQ,OAAO,sBAAG5B,YAAY,CAAE2B,CAAF,CAAf,oDAAG,qBAAA3B,YAAY,EAAS0B,aAAT,CAA5B;AACA,QAAKE,OAAO,KAAKC,SAAjB,EAA6BR,KAAK,CAACG,QAAN,GAAiBI,OAAjB;AAC7B;;AAED,SAAOP,KAAK,CAACG,QAAb;AACA,CAbD,C,CAeA;;;AACA,MAAMM,GAAG,GAAGC,gBAAQC,KAApB;;AACAD,gBAAQC,KAAR,GAAkBA,KAAF,IAAa;AAC5B,MAAKA,KAAK,CAACX,KAAN,CAAYY,YAAjB,EAAgC;AAC/B,UAAMZ,KAAK,GAAGW,KAAK,CAACX,KAApB;AACA,UAAMD,UAAU,GAAGC,KAAK,CAACY,YAAzB;AACA,WAAOZ,KAAK,CAACY,YAAb;AACAD,IAAAA,KAAK,CAACX,KAAN,GAAc;AACbF,MAAAA,IAAI,EAAEa,KAAK,CAACb,IADC;AAEbC,MAAAA,UAFa;AAGbC,MAAAA;AAHa,KAAd;AAKAW,IAAAA,KAAK,CAACb,IAAN,GAAaD,SAAb;AACA;;AAED,MAAKY,GAAL,EAAWA,GAAG,CAAEE,KAAF,CAAH;AACX,CAdD","sourcesContent":["/**\n * External dependencies\n */\nimport { h, options, createContext } 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 = {};\nexport const directive = ( name, cb ) => {\n\tdirectiveMap[ name ] = cb;\n};\n\n// Resolve the path to some property of the store object.\nconst resolve = ( path, ctx ) => {\n\t// If path starts with !, remove it and save a flag.\n\tconst hasNegationOperator =\n\t\tpath[ 0 ] === '!' && !! ( path = path.slice( 1 ) );\n\tlet current = { ...store, context: ctx };\n\tpath.split( '.' ).forEach( ( p ) => ( current = current[ p ] ) );\n\treturn hasNegationOperator ? ! current : current;\n};\n\n// Generate the evaluate function.\nconst getEvaluate =\n\t( { ref } = {} ) =>\n\t( path, extraArgs = {} ) => {\n\t\tconst value = resolve( path, extraArgs.context );\n\t\treturn typeof value === 'function'\n\t\t\t? value( {\n\t\t\t\t\tref: ref.current,\n\t\t\t\t\t...store,\n\t\t\t\t\t...extraArgs,\n\t\t\t } )\n\t\t\t: value;\n\t};\n\n// Directive wrapper.\nconst Directive = ( { type, directives, props: originalProps } ) => {\n\tconst ref = useRef( null );\n\tconst element = h( type, { ...originalProps, ref } );\n\tconst props = { ...originalProps, children: element };\n\tconst evaluate = useMemo( () => getEvaluate( { ref } ), [] );\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,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,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,MA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ourcesContent":["/**\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","par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W,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"]}