@wordpress/block-library 8.12.6 → 8.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) 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/block/edit.native.js +2 -2
  7. package/build/block/edit.native.js.map +1 -1
  8. package/build/categories/index.js +5 -1
  9. package/build/categories/index.js.map +1 -1
  10. package/build/code/index.js +5 -1
  11. package/build/code/index.js.map +1 -1
  12. package/build/column/index.js +1 -0
  13. package/build/column/index.js.map +1 -1
  14. package/build/comments/index.js +1 -0
  15. package/build/comments/index.js.map +1 -1
  16. package/build/cover/edit/inspector-controls.js +2 -1
  17. package/build/cover/edit/inspector-controls.js.map +1 -1
  18. package/build/cover/index.js +1 -0
  19. package/build/cover/index.js.map +1 -1
  20. package/build/details/index.js +5 -1
  21. package/build/details/index.js.map +1 -1
  22. package/build/embed/util.js +9 -8
  23. package/build/embed/util.js.map +1 -1
  24. package/build/file/index.js +2 -1
  25. package/build/file/index.js.map +1 -1
  26. package/build/file/view.js +15 -1
  27. package/build/file/view.js.map +1 -1
  28. package/build/gallery/index.js +3 -1
  29. package/build/gallery/index.js.map +1 -1
  30. package/build/group/index.js +1 -0
  31. package/build/group/index.js.map +1 -1
  32. package/build/heading/index.js +5 -1
  33. package/build/heading/index.js.map +1 -1
  34. package/build/heading/transforms.js +5 -1
  35. package/build/heading/transforms.js.map +1 -1
  36. package/build/image/deprecated.js +453 -175
  37. package/build/image/deprecated.js.map +1 -1
  38. package/build/image/image.js +1 -1
  39. package/build/image/image.js.map +1 -1
  40. package/build/image/save.js +3 -1
  41. package/build/image/save.js.map +1 -1
  42. package/build/image/{interactivity.js → view-interactivity.js} +86 -44
  43. package/build/image/view-interactivity.js.map +1 -0
  44. package/build/index.js +12 -3
  45. package/build/index.js.map +1 -1
  46. package/build/list/index.js +5 -1
  47. package/build/list/index.js.map +1 -1
  48. package/build/list-item/utils.js +6 -1
  49. package/build/list-item/utils.js.map +1 -1
  50. package/build/media-text/index.js +1 -0
  51. package/build/media-text/index.js.map +1 -1
  52. package/build/missing/edit.js +22 -8
  53. package/build/missing/edit.js.map +1 -1
  54. package/build/navigation/index.js +3 -2
  55. package/build/navigation/index.js.map +1 -1
  56. package/build/navigation/view.js +174 -50
  57. package/build/navigation/view.js.map +1 -1
  58. package/build/page-list/convert-to-links-modal.js +3 -3
  59. package/build/page-list/convert-to-links-modal.js.map +1 -1
  60. package/build/page-list/edit.js +34 -39
  61. package/build/page-list/edit.js.map +1 -1
  62. package/build/page-list/use-convert-to-navigation-links.js +2 -15
  63. package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
  64. package/build/paragraph/index.js +1 -0
  65. package/build/paragraph/index.js.map +1 -1
  66. package/build/paragraph/transforms.js +1 -0
  67. package/build/paragraph/transforms.js.map +1 -1
  68. package/build/post-comments-form/index.js +1 -0
  69. package/build/post-comments-form/index.js.map +1 -1
  70. package/build/post-navigation-link/index.js +1 -0
  71. package/build/post-navigation-link/index.js.map +1 -1
  72. package/build/post-time-to-read/index.js +5 -1
  73. package/build/post-time-to-read/index.js.map +1 -1
  74. package/build/quote/index.js +1 -0
  75. package/build/quote/index.js.map +1 -1
  76. package/build/site-logo/index.js +5 -1
  77. package/build/site-logo/index.js.map +1 -1
  78. package/build/site-tagline/index.js +5 -1
  79. package/build/site-tagline/index.js.map +1 -1
  80. package/build/site-title/index.js +5 -1
  81. package/build/site-title/index.js.map +1 -1
  82. package/build/social-links/index.js +3 -1
  83. package/build/social-links/index.js.map +1 -1
  84. package/build/table/index.js +5 -1
  85. package/build/table/index.js.map +1 -1
  86. package/build/term-description/index.js +1 -0
  87. package/build/term-description/index.js.map +1 -1
  88. package/build/verse/index.js +5 -1
  89. package/build/verse/index.js.map +1 -1
  90. package/build/video/deprecated.js +5 -1
  91. package/build/video/deprecated.js.map +1 -1
  92. package/build/video/index.js +5 -1
  93. package/build/video/index.js.map +1 -1
  94. package/build-module/archives/index.js +5 -1
  95. package/build-module/archives/index.js.map +1 -1
  96. package/build-module/audio/index.js +5 -1
  97. package/build-module/audio/index.js.map +1 -1
  98. package/build-module/block/edit.native.js +2 -2
  99. package/build-module/block/edit.native.js.map +1 -1
  100. package/build-module/categories/index.js +5 -1
  101. package/build-module/categories/index.js.map +1 -1
  102. package/build-module/code/index.js +5 -1
  103. package/build-module/code/index.js.map +1 -1
  104. package/build-module/column/index.js +1 -0
  105. package/build-module/column/index.js.map +1 -1
  106. package/build-module/comments/index.js +1 -0
  107. package/build-module/comments/index.js.map +1 -1
  108. package/build-module/cover/edit/inspector-controls.js +2 -1
  109. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  110. package/build-module/cover/index.js +1 -0
  111. package/build-module/cover/index.js.map +1 -1
  112. package/build-module/details/index.js +5 -1
  113. package/build-module/details/index.js.map +1 -1
  114. package/build-module/embed/util.js +6 -6
  115. package/build-module/embed/util.js.map +1 -1
  116. package/build-module/file/index.js +2 -1
  117. package/build-module/file/index.js.map +1 -1
  118. package/build-module/file/view.js +15 -2
  119. package/build-module/file/view.js.map +1 -1
  120. package/build-module/gallery/index.js +3 -1
  121. package/build-module/gallery/index.js.map +1 -1
  122. package/build-module/group/index.js +1 -0
  123. package/build-module/group/index.js.map +1 -1
  124. package/build-module/heading/index.js +5 -1
  125. package/build-module/heading/index.js.map +1 -1
  126. package/build-module/heading/transforms.js +5 -1
  127. package/build-module/heading/transforms.js.map +1 -1
  128. package/build-module/image/deprecated.js +454 -176
  129. package/build-module/image/deprecated.js.map +1 -1
  130. package/build-module/image/image.js +1 -1
  131. package/build-module/image/image.js.map +1 -1
  132. package/build-module/image/save.js +3 -1
  133. package/build-module/image/save.js.map +1 -1
  134. package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
  135. package/build-module/image/view-interactivity.js.map +1 -0
  136. package/build-module/index.js +12 -3
  137. package/build-module/index.js.map +1 -1
  138. package/build-module/list/index.js +5 -1
  139. package/build-module/list/index.js.map +1 -1
  140. package/build-module/list-item/utils.js +6 -1
  141. package/build-module/list-item/utils.js.map +1 -1
  142. package/build-module/media-text/index.js +1 -0
  143. package/build-module/media-text/index.js.map +1 -1
  144. package/build-module/missing/edit.js +22 -8
  145. package/build-module/missing/edit.js.map +1 -1
  146. package/build-module/navigation/index.js +3 -2
  147. package/build-module/navigation/index.js.map +1 -1
  148. package/build-module/navigation/view.js +173 -50
  149. package/build-module/navigation/view.js.map +1 -1
  150. package/build-module/page-list/convert-to-links-modal.js +3 -3
  151. package/build-module/page-list/convert-to-links-modal.js.map +1 -1
  152. package/build-module/page-list/edit.js +34 -39
  153. package/build-module/page-list/edit.js.map +1 -1
  154. package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
  155. package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
  156. package/build-module/paragraph/index.js +1 -0
  157. package/build-module/paragraph/index.js.map +1 -1
  158. package/build-module/paragraph/transforms.js +1 -0
  159. package/build-module/paragraph/transforms.js.map +1 -1
  160. package/build-module/post-comments-form/index.js +1 -0
  161. package/build-module/post-comments-form/index.js.map +1 -1
  162. package/build-module/post-navigation-link/index.js +1 -0
  163. package/build-module/post-navigation-link/index.js.map +1 -1
  164. package/build-module/post-time-to-read/index.js +5 -1
  165. package/build-module/post-time-to-read/index.js.map +1 -1
  166. package/build-module/quote/index.js +1 -0
  167. package/build-module/quote/index.js.map +1 -1
  168. package/build-module/site-logo/index.js +5 -1
  169. package/build-module/site-logo/index.js.map +1 -1
  170. package/build-module/site-tagline/index.js +5 -1
  171. package/build-module/site-tagline/index.js.map +1 -1
  172. package/build-module/site-title/index.js +5 -1
  173. package/build-module/site-title/index.js.map +1 -1
  174. package/build-module/social-links/index.js +3 -1
  175. package/build-module/social-links/index.js.map +1 -1
  176. package/build-module/table/index.js +5 -1
  177. package/build-module/table/index.js.map +1 -1
  178. package/build-module/term-description/index.js +1 -0
  179. package/build-module/term-description/index.js.map +1 -1
  180. package/build-module/verse/index.js +5 -1
  181. package/build-module/verse/index.js.map +1 -1
  182. package/build-module/video/deprecated.js +5 -1
  183. package/build-module/video/deprecated.js.map +1 -1
  184. package/build-module/video/index.js +5 -1
  185. package/build-module/video/index.js.map +1 -1
  186. package/build-style/image/style-rtl.css +16 -2
  187. package/build-style/image/style.css +16 -2
  188. package/build-style/style-rtl.css +16 -2
  189. package/build-style/style.css +16 -2
  190. package/package.json +33 -38
  191. package/src/archives/block.json +5 -1
  192. package/src/audio/block.json +5 -1
  193. package/src/block/edit.native.js +2 -2
  194. package/src/block/test/edit.native.js +4 -4
  195. package/src/categories/block.json +5 -1
  196. package/src/code/block.json +5 -1
  197. package/src/column/block.json +1 -0
  198. package/src/comments/block.json +1 -0
  199. package/src/cover/block.json +1 -0
  200. package/src/cover/edit/inspector-controls.js +1 -0
  201. package/src/details/block.json +5 -1
  202. package/src/embed/util.js +4 -6
  203. package/src/file/block.json +2 -1
  204. package/src/file/index.php +0 -17
  205. package/src/file/view.js +14 -5
  206. package/src/gallery/block.json +3 -1
  207. package/src/group/block.json +1 -0
  208. package/src/heading/block.json +5 -1
  209. package/src/heading/test/index.native.js +18 -0
  210. package/src/image/deprecated.js +597 -320
  211. package/src/image/image.js +2 -1
  212. package/src/image/save.js +2 -0
  213. package/src/image/style.scss +15 -2
  214. package/src/image/{interactivity.js → view-interactivity.js} +99 -50
  215. package/src/index.js +18 -1
  216. package/src/list/block.json +5 -1
  217. package/src/media-text/block.json +1 -0
  218. package/src/missing/edit.js +31 -11
  219. package/src/navigation/block.json +3 -2
  220. package/src/navigation/index.php +15 -20
  221. package/src/navigation/view.js +189 -67
  222. package/src/navigation-submenu/index.php +0 -10
  223. package/src/page-list/convert-to-links-modal.js +3 -3
  224. package/src/page-list/edit.js +65 -62
  225. package/src/page-list/use-convert-to-navigation-links.js +3 -20
  226. package/src/paragraph/block.json +1 -0
  227. package/src/post-comments-form/block.json +1 -0
  228. package/src/post-navigation-link/block.json +1 -0
  229. package/src/post-time-to-read/block.json +5 -1
  230. package/src/quote/block.json +1 -0
  231. package/src/site-logo/block.json +5 -1
  232. package/src/site-tagline/block.json +5 -1
  233. package/src/site-title/block.json +5 -1
  234. package/src/social-links/block.json +3 -1
  235. package/src/table/block.json +5 -1
  236. package/src/term-description/block.json +1 -0
  237. package/src/verse/block.json +5 -1
  238. package/src/video/block.json +5 -1
  239. package/build/file/interactivity.js +0 -19
  240. package/build/file/interactivity.js.map +0 -1
  241. package/build/heading/heading-level-icon.js +0 -61
  242. package/build/heading/heading-level-icon.js.map +0 -1
  243. package/build/image/interactivity.js.map +0 -1
  244. package/build/navigation/interactivity.js +0 -167
  245. package/build/navigation/interactivity.js.map +0 -1
  246. package/build/navigation/view-modal.js +0 -64
  247. package/build/navigation/view-modal.js.map +0 -1
  248. package/build/utils/interactivity/constants.js +0 -9
  249. package/build/utils/interactivity/constants.js.map +0 -1
  250. package/build/utils/interactivity/directives.js +0 -222
  251. package/build/utils/interactivity/directives.js.map +0 -1
  252. package/build/utils/interactivity/hooks.js +0 -159
  253. package/build/utils/interactivity/hooks.js.map +0 -1
  254. package/build/utils/interactivity/hydration.js +0 -34
  255. package/build/utils/interactivity/hydration.js.map +0 -1
  256. package/build/utils/interactivity/index.js +0 -32
  257. package/build/utils/interactivity/index.js.map +0 -1
  258. package/build/utils/interactivity/portals.js +0 -108
  259. package/build/utils/interactivity/portals.js.map +0 -1
  260. package/build/utils/interactivity/store.js +0 -66
  261. package/build/utils/interactivity/store.js.map +0 -1
  262. package/build/utils/interactivity/utils.js +0 -87
  263. package/build/utils/interactivity/utils.js.map +0 -1
  264. package/build/utils/interactivity/vdom.js +0 -119
  265. package/build/utils/interactivity/vdom.js.map +0 -1
  266. package/build-module/file/interactivity.js +0 -15
  267. package/build-module/file/interactivity.js.map +0 -1
  268. package/build-module/heading/heading-level-icon.js +0 -53
  269. package/build-module/heading/heading-level-icon.js.map +0 -1
  270. package/build-module/image/interactivity.js.map +0 -1
  271. package/build-module/navigation/interactivity.js +0 -164
  272. package/build-module/navigation/interactivity.js.map +0 -1
  273. package/build-module/navigation/view-modal.js +0 -58
  274. package/build-module/navigation/view-modal.js.map +0 -1
  275. package/build-module/utils/interactivity/constants.js +0 -2
  276. package/build-module/utils/interactivity/constants.js.map +0 -1
  277. package/build-module/utils/interactivity/directives.js +0 -209
  278. package/build-module/utils/interactivity/directives.js.map +0 -1
  279. package/build-module/utils/interactivity/hooks.js +0 -145
  280. package/build-module/utils/interactivity/hooks.js.map +0 -1
  281. package/build-module/utils/interactivity/hydration.js +0 -21
  282. package/build-module/utils/interactivity/hydration.js.map +0 -1
  283. package/build-module/utils/interactivity/index.js +0 -15
  284. package/build-module/utils/interactivity/index.js.map +0 -1
  285. package/build-module/utils/interactivity/portals.js +0 -100
  286. package/build-module/utils/interactivity/portals.js.map +0 -1
  287. package/build-module/utils/interactivity/store.js +0 -55
  288. package/build-module/utils/interactivity/store.js.map +0 -1
  289. package/build-module/utils/interactivity/utils.js +0 -75
  290. package/build-module/utils/interactivity/utils.js.map +0 -1
  291. package/build-module/utils/interactivity/vdom.js +0 -107
  292. package/build-module/utils/interactivity/vdom.js.map +0 -1
  293. package/src/file/interactivity.js +0 -15
  294. package/src/heading/heading-level-icon.js +0 -48
  295. package/src/navigation/interactivity.js +0 -169
  296. package/src/navigation/view-modal.js +0 -78
  297. package/src/utils/interactivity/constants.js +0 -1
  298. package/src/utils/interactivity/directives.js +0 -200
  299. package/src/utils/interactivity/hooks.js +0 -145
  300. package/src/utils/interactivity/hydration.js +0 -22
  301. package/src/utils/interactivity/index.js +0 -15
  302. package/src/utils/interactivity/portals.js +0 -98
  303. package/src/utils/interactivity/store.js +0 -45
  304. package/src/utils/interactivity/utils.js +0 -66
  305. package/src/utils/interactivity/vdom.js +0 -111
@@ -1 +0,0 @@
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","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":";;;;;;;;;AAGA;;AACA;;AAIA;;AAKA;;AACA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;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,CAAoBC,IAApB,EADe,EAEfF,MAAM,CAAG,IAAIC,CAAG,EAAV,CAAN,CAAoBC,IAApB,EAFe,CAAhB;AAIA;AACD;AACD,CAdD;;eAgBe,MAAM;AACpB;AACA,yBACC,SADD,EAEC,CAAE;AACDC,IAAAA,UAAU,EAAE;AACXC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,OAAO,EAAED;AAAX;AADE,KADX;AAIDE,IAAAA,KAAK,EAAE;AAAEC,MAAA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f;AACA,WACC,4BAAC,IAAD;AACC,MAAA,uBAAuB,EAAG;AAAEG,QAAAA,MAAM,EAAED;AAAV,OAD3B;AAAA,SAEMD;AAFN,MADD;AAMA,GAhBF;AAkBA,C","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,159 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.directive = void 0;
7
-
8
- var _element = require("@wordpress/element");
9
-
10
- var _preact = require("preact");
11
-
12
- var _hooks = require("preact/hooks");
13
-
14
- var _store = require("./store");
15
-
16
- /**
17
- * External dependencies
18
- */
19
-
20
- /**
21
- * Internal dependencies
22
- */
23
- // Main context.
24
- const context = (0, _preact.createContext)({}); // WordPress Directives.
25
-
26
- const directiveMap = {};
27
- const directivePriorities = {};
28
-
29
- const directive = (name, cb, {
30
- priority = 10
31
- } = {}) => {
32
- directiveMap[name] = cb;
33
- directivePriorities[name] = priority;
34
- }; // Resolve the path to some property of the store object.
35
-
36
-
37
- exports.directive = directive;
38
-
39
- const resolve = (path, ctx) => {
40
- let current = { ..._store.rawStore,
41
- context: ctx
42
- };
43
- path.split('.').forEach(p => current = current[p]);
44
- return current;
45
- }; // Generate the evaluate function.
46
-
47
-
48
- const getEvaluate = ({
49
- ref
50
- } = {}) => (path, extraArgs = {}) => {
51
- // If path starts with !, remove it and save a flag.
52
- const hasNegationOperator = path[0] === '!' && !!(path = path.slice(1));
53
- const value = resolve(path, extraArgs.context);
54
- const returnValue = typeof value === 'function' ? value({
55
- ref: ref.current,
56
- ..._store.rawStore,
57
- ...extraArgs
58
- }) : value;
59
- return hasNegationOperator ? !returnValue : returnValue;
60
- }; // Separate directives by priority. The resulting array contains objects
61
- // of directives grouped by same priority, and sorted in ascending order.
62
-
63
-
64
- const usePriorityLevels = directives => (0, _hooks.useMemo)(() => {
65
- const byPriority = Object.entries(directives).reduce((acc, [name, values]) => {
66
- const priority = directivePriorities[name];
67
- if (!acc[priority]) acc[priority] = {};
68
- acc[priority][name] = values;
69
- return acc;
70
- }, {});
71
- return Object.entries(byPriority).sort(([p1], [p2]) => p1 - p2).map(([, obj]) => obj);
72
- }, [directives]); // Directive wrapper.
73
-
74
-
75
- const Directive = ({
76
- type,
77
- directives,
78
- props: originalProps
79
- }) => {
80
- const ref = (0, _hooks.useRef)(null);
81
- const element = (0, _preact.h)(type, { ...originalProps,
82
- ref
83
- });
84
- const evaluate = (0, _hooks.useMemo)(() => getEvaluate({
85
- ref
86
- }), []); // Add wrappers recursively for each priority level.
87
-
88
- const byPriorityLevel = usePriorityLevels(directives);
89
- return (0, _element.createElement)(RecursivePriorityLevel, {
90
- directives: byPriorityLevel,
91
- element: element,
92
- evaluate: evaluate,
93
- originalProps: originalProps
94
- });
95
- }; // Priority level wrapper.
96
-
97
-
98
- const RecursivePriorityLevel = ({
99
- directives: [directives, ...rest],
100
- element,
101
- evaluate,
102
- originalProps
103
- }) => {
104
- // This element needs to be a fresh copy so we are not modifying an already
105
- // rendered element with Preact's internal properties initialized. This
106
- // prevents an error with changes in `element.props.children` not being
107
- // reflected in `element.__k`.
108
- element = (0, _preact.cloneElement)(element); // Recursively render the wrapper for the next priority level.
109
- //
110
- // Note that, even though we're instantiating a vnode with a
111
- // `RecursivePriorityLevel` here, its render function will not be executed
112
- // just yet. Actually, it will be delayed until the current render function
113
- // has finished. That ensures directives in the current priorty level have
114
- // run (and thus modified the passed `element`) before the next level.
115
-
116
- const children = rest.length > 0 ? (0, _element.createElement)(RecursivePriorityLevel, {
117
- directives: rest,
118
- element: element,
119
- evaluate: evaluate,
120
- originalProps: originalProps
121
- }) : element;
122
- const props = { ...originalProps,
123
- children
124
- };
125
- const directiveArgs = {
126
- directives,
127
- props,
128
- element,
129
- context,
130
- evaluate
131
- };
132
-
133
- for (const d in directives) {
134
- const wrapper = directiveMap[d]?.(directiveArgs);
135
- if (wrapper !== undefined) props.children = wrapper;
136
- }
137
-
138
- return props.children;
139
- }; // Preact Options Hook called each time a vnode is created.
140
-
141
-
142
- const old = _preact.options.vnode;
143
-
144
- _preact.options.vnode = vnode => {
145
- if (vnode.props.__directives) {
146
- const props = vnode.props;
147
- const directives = props.__directives;
148
- delete props.__directives;
149
- vnode.props = {
150
- type: vnode.type,
151
- directives,
152
- props
153
- };
154
- vnode.type = Directive;
155
- }
156
-
157
- if (old) old(vnode);
158
- };
159
- //# sourceMappingURL=hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hooks.js"],"names":["context","directiveMap","directivePriorities","directive","name","cb","priority","resolve","path","ctx","current","store","split","forEach","p","getEvaluate","ref","extraArgs","hasNegationOperator","slice","value","returnValue","usePriorityLevels","directives","byPriority","Object","entries","reduce","acc","values","sort","p1","p2","map","obj","Directive","type","props","originalProps","element","evaluate","byPriorityLevel","RecursivePriorityLevel","rest","children","length","directiveArgs","d","wrapper","undefined","old","options","vnode","__directives"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA;AACA,MAAMA,OAAO,GAAG,2BAAe,EAAf,CAAhB,C,CAEA;;AACA,MAAMC,YAAY,GAAG,EAArB;AACA,MAAMC,mBAAmB,GAAG,EAA5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CAACf,KAApB;AACA,UAAMd,UAAU,GAAGc,KAAK,CAACgB,YAAzB;AACA,WAAOhB,KAAK,CAACgB,YAAb;AACAD,IAAAA,KAAK,CAACf,KAAN,GAAc;AACbD,MAAAA,IAAI,EAAEgB,KAAK,CAAChB,IADC;AAEbb,MAAAA,UAFa;AAGbc,MAAAA;AAHa,KAAd;AAKAe,IAAAA,KAAK,CAAChB,IAAN,GAAaD,SAAb;AACA;;AAED,MAAKe,GAAL,EAAWA,GAAG,CAAEE,KAAF,CAAH;AACX,CAdD","sourcesContent":["/**\n * External dependencies\n */\nimport { h, options, createContext, cloneElement } from 'preact';\nimport { useRef, useMemo } from 'preact/hooks';\n/**\n * Internal dependencies\n */\nimport { rawStore as store } from './store';\n\n// Main context.\nconst context = createContext( {} );\n\n// WordPress Directives.\nconst directiveMap = {};\nconst directivePriorities = {};\nexport const directive = ( name, cb, { priority = 10 } = {} ) => {\n\tdirectiveMap[ name ] = cb;\n\tdirectivePriorities[ name ] = priority;\n};\n\n// Resolve the path to some property of the store object.\nconst resolve = ( path, ctx ) => {\n\tlet current = { ...store, context: ctx };\n\tpath.split( '.' ).forEach( ( p ) => ( current = current[ p ] ) );\n\treturn current;\n};\n\n// Generate the evaluate function.\nconst getEvaluate =\n\t( { ref } = {} ) =>\n\t( path, extraArgs = {} ) => {\n\t\t// If path starts with !, remove it and save a flag.\n\t\tconst hasNegationOperator =\n\t\t\tpath[ 0 ] === '!' && !! ( path = path.slice( 1 ) );\n\t\tconst value = resolve( path, extraArgs.context );\n\t\tconst returnValue =\n\t\t\ttypeof value === 'function'\n\t\t\t\t? value( {\n\t\t\t\t\t\tref: ref.current,\n\t\t\t\t\t\t...store,\n\t\t\t\t\t\t...extraArgs,\n\t\t\t\t } )\n\t\t\t\t: value;\n\t\treturn hasNegationOperator ? ! returnValue : returnValue;\n\t};\n\n// Separate directives by priority. The resulting array contains objects\n// of directives grouped by same priority, and sorted in ascending order.\nconst usePriorityLevels = ( directives ) =>\n\tuseMemo( () => {\n\t\tconst byPriority = Object.entries( directives ).reduce(\n\t\t\t( acc, [ name, values ] ) => {\n\t\t\t\tconst priority = directivePriorities[ name ];\n\t\t\t\tif ( ! acc[ priority ] ) acc[ priority ] = {};\n\t\t\t\tacc[ priority ][ name ] = values;\n\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\treturn Object.entries( byPriority )\n\t\t\t.sort( ( [ p1 ], [ p2 ] ) => p1 - p2 )\n\t\t\t.map( ( [ , obj ] ) => obj );\n\t}, [ directives ] );\n\n// Directive wrapper.\nconst Directive = ( { type, directives, props: originalProps } ) => {\n\tconst ref = useRef( null );\n\tconst element = h( type, { ...originalProps, ref } );\n\tconst evaluate = useMemo( () => getEvaluate( { ref } ), [] );\n\n\t// Add wrappers recursively for each priority level.\n\tconst byPriorityLevel = usePriorityLevels( directives );\n\treturn (\n\t\t<RecursivePriorityLevel\n\t\t\tdirectives={ byPriorityLevel }\n\t\t\telement={ element }\n\t\t\tevaluate={ evaluate }\n\t\t\toriginalProps={ originalProps }\n\t\t/>\n\t);\n};\n\n// Priority level wrapper.\nconst RecursivePriorityLevel = ( {\n\tdirectives: [ directives, ...rest ],\n\telement,\n\tevaluate,\n\toriginalProps,\n} ) => {\n\t// This element needs to be a fresh copy so we are not modifying an already\n\t// rendered element with Preact's internal properties initialized. This\n\t// prevents an error with changes in `element.props.children` not being\n\t// reflected in `element.__k`.\n\telement = cloneElement( element );\n\n\t// Recursively render the wrapper for the next priority level.\n\t//\n\t// Note that, even though we're instantiating a vnode with a\n\t// `RecursivePriorityLevel` here, its render function will not be executed\n\t// just yet. Actually, it will be delayed until the current render function\n\t// has finished. That ensures directives in the current priorty level have\n\t// run (and thus modified the passed `element`) before the next level.\n\tconst children =\n\t\trest.length > 0 ? (\n\t\t\t<RecursivePriorityLevel\n\t\t\t\tdirectives={ rest }\n\t\t\t\telement={ element }\n\t\t\t\tevaluate={ evaluate }\n\t\t\t\toriginalProps={ originalProps }\n\t\t\t/>\n\t\t) : (\n\t\t\telement\n\t\t);\n\n\tconst props = { ...originalProps, children };\n\tconst directiveArgs = { directives, props, element, context, evaluate };\n\n\tfor ( const d in directives ) {\n\t\tconst wrapper = directiveMap[ d ]?.( directiveArgs );\n\t\tif ( wrapper !== undefined ) props.children = wrapper;\n\t}\n\n\treturn props.children;\n};\n\n// Preact Options Hook called each time a vnode is created.\nconst old = options.vnode;\noptions.vnode = ( vnode ) => {\n\tif ( vnode.props.__directives ) {\n\t\tconst props = vnode.props;\n\t\tconst directives = props.__directives;\n\t\tdelete props.__directives;\n\t\tvnode.props = {\n\t\t\ttype: vnode.type,\n\t\t\tdirectives,\n\t\t\tprops,\n\t\t};\n\t\tvnode.type = Directive;\n\t}\n\n\tif ( old ) old( vnode );\n};\n"]}
@@ -1,34 +0,0 @@
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(`[data-${_constants.directivePrefix}-interactive]`).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
@@ -1 +0,0 @@
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,SAASC,0BAAiB,eAD/C,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( `[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,32 +0,0 @@
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)();
31
- });
32
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/index.js"],"names":["document","addEventListener"],"mappings":";;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AAEAA,QAAQ,CAACC,gBAAT,CAA2B,kBAA3B,EAA+C,YAAY;AAC1D,QAAM,sBAAN;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,108 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createPortal = createPortal;
7
-
8
- var _preact = require("preact");
9
-
10
- /**
11
- * External dependencies
12
- */
13
-
14
- /**
15
- * @param {import('../../src/index').RenderableProps<{ context: any }>} props
16
- */
17
- function ContextProvider(props) {
18
- this.getChildContext = () => props.context;
19
-
20
- return props.children;
21
- }
22
- /**
23
- * Portal component
24
- *
25
- * @this {import('./internal').Component}
26
- * @param {object | null | undefined} props
27
- *
28
- * TODO: use createRoot() instead of fake root
29
- */
30
-
31
-
32
- function Portal(props) {
33
- const _this = this;
34
-
35
- const container = props._container;
36
-
37
- _this.componentWillUnmount = function () {
38
- (0, _preact.render)(null, _this._temp);
39
- _this._temp = null;
40
- _this._container = null;
41
- }; // When we change container we should clear our old container and
42
- // indicate a new mount.
43
-
44
-
45
- if (_this._container && _this._container !== container) {
46
- _this.componentWillUnmount();
47
- } // When props.vnode is undefined/false/null we are dealing with some kind of
48
- // conditional vnode. This should not trigger a render.
49
-
50
-
51
- if (props._vnode) {
52
- if (!_this._temp) {
53
- _this._container = container; // Create a fake DOM parent node that manages a subset of `container`'s children:
54
-
55
- _this._temp = {
56
- nodeType: 1,
57
- parentNode: container,
58
- childNodes: [],
59
-
60
- appendChild(child) {
61
- this.childNodes.push(child);
62
-
63
- _this._container.appendChild(child);
64
- },
65
-
66
- insertBefore(child) {
67
- this.childNodes.push(child);
68
-
69
- _this._container.appendChild(child);
70
- },
71
-
72
- removeChild(child) {
73
- this.childNodes.splice( // eslint-disable-next-line no-bitwise
74
- this.childNodes.indexOf(child) >>> 1, 1);
75
-
76
- _this._container.removeChild(child);
77
- }
78
-
79
- };
80
- } // Render our wrapping element into temp.
81
-
82
-
83
- (0, _preact.render)((0, _preact.createElement)(ContextProvider, {
84
- context: _this.context
85
- }, props._vnode), _this._temp);
86
- } // When we come from a conditional render, on a mounted
87
- // portal we should clear the DOM.
88
- else if (_this._temp) {
89
- _this.componentWillUnmount();
90
- }
91
- }
92
- /**
93
- * Create a `Portal` to continue rendering the vnode tree at a different DOM node
94
- *
95
- * @param {import('./internal').VNode} vnode The vnode to render
96
- * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
97
- */
98
-
99
-
100
- function createPortal(vnode, container) {
101
- const el = (0, _preact.createElement)(Portal, {
102
- _vnode: vnode,
103
- _container: container
104
- });
105
- el.containerInfo = container;
106
- return el;
107
- }
108
- //# sourceMappingURL=portals.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/portals.js"],"names":["ContextProvider","props","getChildContext","context","children","Portal","_this","container","_container","componentWillUnmount","_temp","_vnode","nodeType","parentNode","childNodes","appendChild","child","push","insertBefore","removeChild","splice","indexOf","createPortal","vnode","el","containerInfo"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,eAAT,CAA0BC,KAA1B,EAAkC;AACjC,OAAKC,eAAL,GAAuB,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,K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BACChB,eADD,EAEC;AAAEG,MAAAA,OAAO,EAAEG,KAAK,CAACH;AAAjB,KAFD,EAGCF,KAAK,CAACU,MAHP,CADD,EAMCL,KAAK,CAACI,KANP;AAQA,GArCD,CAsCA;AACA;AAvCA,OAwCK,IAAKJ,KAAK,CAACI,KAAX,EAAmB;AACvBJ,IAAAA,KAAK,CAACG,oBAAN;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASa,YAAT,CAAuBC,KAAvB,EAA8BhB,SAA9B,EAA0C;AAChD,QAAMiB,EAAE,GAAG,2BAAenB,MAAf,EAAuB;AACjCM,IAAAA,MAAM,EAAEY,KADyB;AAEjCf,IAAAA,UAAU,EAAED;AAFqB,GAAvB,CAAX;AAIAiB,EAAAA,EAAE,CAACC,aAAH,GAAmBlB,SAAnB;AACA,SAAOiB,EAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { createElement, render } from 'preact';\n\n/**\n * @param {import('../../src/index').RenderableProps<{ context: any }>} props\n */\nfunction ContextProvider( props ) {\n\tthis.getChildContext = () => props.context;\n\treturn props.children;\n}\n\n/**\n * Portal component\n *\n * @this {import('./internal').Component}\n * @param {object | null | undefined} props\n *\n * TODO: use createRoot() instead of fake root\n */\nfunction Portal( props ) {\n\tconst _this = this;\n\tconst container = props._container;\n\n\t_this.componentWillUnmount = function () {\n\t\trender( null, _this._temp );\n\t\t_this._temp = null;\n\t\t_this._container = null;\n\t};\n\n\t// When we change container we should clear our old container and\n\t// indicate a new mount.\n\tif ( _this._container && _this._container !== container ) {\n\t\t_this.componentWillUnmount();\n\t}\n\n\t// When props.vnode is undefined/false/null we are dealing with some kind of\n\t// conditional vnode. This should not trigger a render.\n\tif ( props._vnode ) {\n\t\tif ( ! _this._temp ) {\n\t\t\t_this._container = container;\n\n\t\t\t// Create a fake DOM parent node that manages a subset of `container`'s children:\n\t\t\t_this._temp = {\n\t\t\t\tnodeType: 1,\n\t\t\t\tparentNode: container,\n\t\t\t\tchildNodes: [],\n\t\t\t\tappendChild( child ) {\n\t\t\t\t\tthis.childNodes.push( child );\n\t\t\t\t\t_this._container.appendChild( child );\n\t\t\t\t},\n\t\t\t\tinsertBefore( child ) {\n\t\t\t\t\tthis.childNodes.push( child );\n\t\t\t\t\t_this._container.appendChild( child );\n\t\t\t\t},\n\t\t\t\tremoveChild( child ) {\n\t\t\t\t\tthis.childNodes.splice(\n\t\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\t\tthis.childNodes.indexOf( child ) >>> 1,\n\t\t\t\t\t\t1\n\t\t\t\t\t);\n\t\t\t\t\t_this._container.removeChild( child );\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t// Render our wrapping element into temp.\n\t\trender(\n\t\t\tcreateElement(\n\t\t\t\tContextProvider,\n\t\t\t\t{ context: _this.context },\n\t\t\t\tprops._vnode\n\t\t\t),\n\t\t\t_this._temp\n\t\t);\n\t}\n\t// When we come from a conditional render, on a mounted\n\t// portal we should clear the DOM.\n\telse if ( _this._temp ) {\n\t\t_this.componentWillUnmount();\n\t}\n}\n\n/**\n * Create a `Portal` to continue rendering the vnode tree at a different DOM node\n *\n * @param {import('./internal').VNode} vnode The vnode to render\n * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.\n */\nexport function createPortal( vnode, container ) {\n\tconst el = createElement( Portal, {\n\t\t_vnode: vnode,\n\t\t_container: container,\n\t} );\n\tel.containerInfo = container;\n\treturn el;\n}\n"]}
@@ -1,66 +0,0 @@
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 = ({
58
- state,
59
- ...block
60
- }) => {
61
- deepMerge(rawStore, block);
62
- deepMerge(rawState, state);
63
- };
64
-
65
- exports.store = store;
66
- //# sourceMappingURL=store.js.map
@@ -1 +0,0 @@
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,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;AACO,MAAMa,QAAQ,GAAG;AAAET,EAAAA,KAAK,EAAE,4BAAYQ,QAAZ;AAAT,CAAjB;;;AAEA,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"]}
@@ -1,87 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/utils.js"],"names":["afterNextFrame","callback","done","window","cancelAnimationFrame","raf","setTimeout","requestAnimationFrame","createFlusher","compute","notify","flush","dispose","c","bind","x","useSignalEffect","cb","current","execute","eff","createRootFragment","parent","replaceNode","concat","s","length","nextSibling","insert","r","insertBefore","__k","nodeType","parentNode","firstChild","childNodes","appendChild","removeChild"],"mappings":";;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,cAAT,CAAyBC,QAAzB,EAAoC;AACnC,QAAMC,IAAI,GAAG,MAAM;AAClBC,IAAAA,MAAM,C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AAoBgB,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"]}