@automattic/newspack-blocks 1.0.0-hotfix-cap-count-user-posts-dedup.1

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 (568) hide show
  1. package/.eslintrc.js +3 -0
  2. package/.hooks/pre-push +8 -0
  3. package/.nvmrc +1 -0
  4. package/.prettierignore +4 -0
  5. package/.prettierrc.js +5 -0
  6. package/.stylelintrc.js +3 -0
  7. package/AGENTS.md +275 -0
  8. package/CHANGELOG.md +3971 -0
  9. package/CLAUDE.md +1 -0
  10. package/README.md +43 -0
  11. package/babel.config.js +6 -0
  12. package/bin/install-wp-tests.sh +155 -0
  13. package/bin/update-translations.sh +13 -0
  14. package/block-list.json +12 -0
  15. package/composer.json +46 -0
  16. package/composer.lock +3632 -0
  17. package/dist/author-list/view-rtl.css +1 -0
  18. package/dist/author-list/view.asset.php +1 -0
  19. package/dist/author-list/view.css +1 -0
  20. package/dist/author-list/view.js +0 -0
  21. package/dist/author-profile/view-rtl.css +1 -0
  22. package/dist/author-profile/view.asset.php +1 -0
  23. package/dist/author-profile/view.css +1 -0
  24. package/dist/author-profile/view.js +0 -0
  25. package/dist/block_styles-rtl.css +2 -0
  26. package/dist/block_styles.asset.php +1 -0
  27. package/dist/block_styles.css +2 -0
  28. package/dist/block_styles.js +0 -0
  29. package/dist/blocks/author-list/block.json +89 -0
  30. package/dist/blocks/author-profile/block.json +80 -0
  31. package/dist/blocks/carousel/block.json +125 -0
  32. package/dist/blocks/checkout-button/block.json +117 -0
  33. package/dist/blocks/donate/block.json +103 -0
  34. package/dist/blocks/homepage-articles/block.json +260 -0
  35. package/dist/blocks/iframe/block.json +36 -0
  36. package/dist/carousel/view-rtl.css +2 -0
  37. package/dist/carousel/view.asset.php +1 -0
  38. package/dist/carousel/view.css +2 -0
  39. package/dist/carousel/view.js +3 -0
  40. package/dist/checkout-button/view-rtl.css +1 -0
  41. package/dist/checkout-button/view.asset.php +1 -0
  42. package/dist/checkout-button/view.css +1 -0
  43. package/dist/checkout-button/view.js +0 -0
  44. package/dist/donate/view-rtl.css +1 -0
  45. package/dist/donate/view.asset.php +1 -0
  46. package/dist/donate/view.css +1 -0
  47. package/dist/donate/view.js +1 -0
  48. package/dist/editor-rtl.css +66 -0
  49. package/dist/editor.asset.php +1 -0
  50. package/dist/editor.css +66 -0
  51. package/dist/editor.js +57 -0
  52. package/dist/frequencyBased-rtl.css +1 -0
  53. package/dist/frequencyBased.asset.php +1 -0
  54. package/dist/frequencyBased.css +1 -0
  55. package/dist/frequencyBased.js +1 -0
  56. package/dist/homepage-articles/view-rtl.css +1 -0
  57. package/dist/homepage-articles/view.asset.php +1 -0
  58. package/dist/homepage-articles/view.css +1 -0
  59. package/dist/homepage-articles/view.js +1 -0
  60. package/dist/iframe/view-rtl.css +1 -0
  61. package/dist/iframe/view.asset.php +1 -0
  62. package/dist/iframe/view.css +1 -0
  63. package/dist/iframe/view.js +1 -0
  64. package/dist/modal-rtl.css +1 -0
  65. package/dist/modal.asset.php +1 -0
  66. package/dist/modal.css +1 -0
  67. package/dist/modal.js +1 -0
  68. package/dist/modalCheckout-rtl.css +1 -0
  69. package/dist/modalCheckout.asset.php +1 -0
  70. package/dist/modalCheckout.css +1 -0
  71. package/dist/modalCheckout.js +1 -0
  72. package/dist/placeholder_blocks.asset.php +1 -0
  73. package/dist/placeholder_blocks.js +4 -0
  74. package/dist/tiersBased-rtl.css +1 -0
  75. package/dist/tiersBased.asset.php +1 -0
  76. package/dist/tiersBased.css +1 -0
  77. package/dist/tiersBased.js +1 -0
  78. package/includes/class-modal-checkout.php +2324 -0
  79. package/includes/class-newspack-blocks-api.php +347 -0
  80. package/includes/class-newspack-blocks-caching.php +291 -0
  81. package/includes/class-newspack-blocks-patterns.php +167 -0
  82. package/includes/class-newspack-blocks.php +1581 -0
  83. package/includes/modal-checkout/class-change-payment-gateway.php +86 -0
  84. package/includes/modal-checkout/class-checkout-data.php +406 -0
  85. package/includes/plugins/class-the-events-calendar.php +84 -0
  86. package/includes/tracking/class-data-events.php +83 -0
  87. package/languages/newspack-blocks-de_DE-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
  88. package/languages/newspack-blocks-de_DE-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
  89. package/languages/newspack-blocks-de_DE-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
  90. package/languages/newspack-blocks-de_DE-10754bc02d28d4301c103f26dbf519ce.json +1 -0
  91. package/languages/newspack-blocks-de_DE-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
  92. package/languages/newspack-blocks-de_DE-34e5c64f90b1444f3fc735376442eada.json +1 -0
  93. package/languages/newspack-blocks-de_DE-351fd022e077061b5796bf7042446bfc.json +1 -0
  94. package/languages/newspack-blocks-de_DE-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
  95. package/languages/newspack-blocks-de_DE-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
  96. package/languages/newspack-blocks-de_DE-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
  97. package/languages/newspack-blocks-de_DE-4f16e21047908d19937bc10ced63acd1.json +1 -0
  98. package/languages/newspack-blocks-de_DE-4fdea541976076f02d56139fb35e5b42.json +1 -0
  99. package/languages/newspack-blocks-de_DE-501b38ac90d35730a620fb0d483702fa.json +1 -0
  100. package/languages/newspack-blocks-de_DE-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
  101. package/languages/newspack-blocks-de_DE-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
  102. package/languages/newspack-blocks-de_DE-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
  103. package/languages/newspack-blocks-de_DE-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
  104. package/languages/newspack-blocks-de_DE-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
  105. package/languages/newspack-blocks-de_DE-727631509ad8eec8e2cbe740c6dad199.json +1 -0
  106. package/languages/newspack-blocks-de_DE-73c6d3bde805172d1993f75397e9832d.json +1 -0
  107. package/languages/newspack-blocks-de_DE-78456b164809d080adecb4d2b3895802.json +1 -0
  108. package/languages/newspack-blocks-de_DE-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
  109. package/languages/newspack-blocks-de_DE-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
  110. package/languages/newspack-blocks-de_DE-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
  111. package/languages/newspack-blocks-de_DE-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
  112. package/languages/newspack-blocks-de_DE-969286d51bb0afe10983b9aec317b5ee.json +1 -0
  113. package/languages/newspack-blocks-de_DE-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
  114. package/languages/newspack-blocks-de_DE-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
  115. package/languages/newspack-blocks-de_DE-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
  116. package/languages/newspack-blocks-de_DE-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
  117. package/languages/newspack-blocks-de_DE-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
  118. package/languages/newspack-blocks-de_DE-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
  119. package/languages/newspack-blocks-de_DE-bb66d96d450663284550bed5a3e9113e.json +1 -0
  120. package/languages/newspack-blocks-de_DE-c810378e74f20906b8193ea76adb6bc0.json +1 -0
  121. package/languages/newspack-blocks-de_DE-d3a1c55a07efd1a65e227bf120840752.json +1 -0
  122. package/languages/newspack-blocks-de_DE-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
  123. package/languages/newspack-blocks-de_DE-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
  124. package/languages/newspack-blocks-de_DE-dd56360b115d1b39c48033c1e0749a11.json +1 -0
  125. package/languages/newspack-blocks-de_DE-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
  126. package/languages/newspack-blocks-de_DE-e58126c278611ed6c17684ba8e7459b4.json +1 -0
  127. package/languages/newspack-blocks-de_DE-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
  128. package/languages/newspack-blocks-de_DE-eccbc51a43c04f59165364eda71e0be7.json +1 -0
  129. package/languages/newspack-blocks-de_DE-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
  130. package/languages/newspack-blocks-de_DE-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
  131. package/languages/newspack-blocks-de_DE-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
  132. package/languages/newspack-blocks-de_DE-f5f8db76788e4079ddfa743333708b88.json +1 -0
  133. package/languages/newspack-blocks-de_DE-f8b1589c450689398f90b179f47e74ee.json +1 -0
  134. package/languages/newspack-blocks-de_DE-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
  135. package/languages/newspack-blocks-de_DE-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
  136. package/languages/newspack-blocks-de_DE-fcc93143c1f2b74671f595454b971f44.json +1 -0
  137. package/languages/newspack-blocks-de_DE.mo +0 -0
  138. package/languages/newspack-blocks-de_DE.po +2088 -0
  139. package/languages/newspack-blocks-es_ES-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
  140. package/languages/newspack-blocks-es_ES-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
  141. package/languages/newspack-blocks-es_ES-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
  142. package/languages/newspack-blocks-es_ES-10754bc02d28d4301c103f26dbf519ce.json +1 -0
  143. package/languages/newspack-blocks-es_ES-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
  144. package/languages/newspack-blocks-es_ES-34e5c64f90b1444f3fc735376442eada.json +1 -0
  145. package/languages/newspack-blocks-es_ES-351fd022e077061b5796bf7042446bfc.json +1 -0
  146. package/languages/newspack-blocks-es_ES-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
  147. package/languages/newspack-blocks-es_ES-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
  148. package/languages/newspack-blocks-es_ES-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
  149. package/languages/newspack-blocks-es_ES-4f16e21047908d19937bc10ced63acd1.json +1 -0
  150. package/languages/newspack-blocks-es_ES-4fdea541976076f02d56139fb35e5b42.json +1 -0
  151. package/languages/newspack-blocks-es_ES-501b38ac90d35730a620fb0d483702fa.json +1 -0
  152. package/languages/newspack-blocks-es_ES-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
  153. package/languages/newspack-blocks-es_ES-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
  154. package/languages/newspack-blocks-es_ES-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
  155. package/languages/newspack-blocks-es_ES-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
  156. package/languages/newspack-blocks-es_ES-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
  157. package/languages/newspack-blocks-es_ES-727631509ad8eec8e2cbe740c6dad199.json +1 -0
  158. package/languages/newspack-blocks-es_ES-73c6d3bde805172d1993f75397e9832d.json +1 -0
  159. package/languages/newspack-blocks-es_ES-78456b164809d080adecb4d2b3895802.json +1 -0
  160. package/languages/newspack-blocks-es_ES-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
  161. package/languages/newspack-blocks-es_ES-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
  162. package/languages/newspack-blocks-es_ES-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
  163. package/languages/newspack-blocks-es_ES-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
  164. package/languages/newspack-blocks-es_ES-969286d51bb0afe10983b9aec317b5ee.json +1 -0
  165. package/languages/newspack-blocks-es_ES-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
  166. package/languages/newspack-blocks-es_ES-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
  167. package/languages/newspack-blocks-es_ES-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
  168. package/languages/newspack-blocks-es_ES-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
  169. package/languages/newspack-blocks-es_ES-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
  170. package/languages/newspack-blocks-es_ES-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
  171. package/languages/newspack-blocks-es_ES-bb66d96d450663284550bed5a3e9113e.json +1 -0
  172. package/languages/newspack-blocks-es_ES-c810378e74f20906b8193ea76adb6bc0.json +1 -0
  173. package/languages/newspack-blocks-es_ES-d3a1c55a07efd1a65e227bf120840752.json +1 -0
  174. package/languages/newspack-blocks-es_ES-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
  175. package/languages/newspack-blocks-es_ES-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
  176. package/languages/newspack-blocks-es_ES-dd56360b115d1b39c48033c1e0749a11.json +1 -0
  177. package/languages/newspack-blocks-es_ES-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
  178. package/languages/newspack-blocks-es_ES-e58126c278611ed6c17684ba8e7459b4.json +1 -0
  179. package/languages/newspack-blocks-es_ES-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
  180. package/languages/newspack-blocks-es_ES-eccbc51a43c04f59165364eda71e0be7.json +1 -0
  181. package/languages/newspack-blocks-es_ES-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
  182. package/languages/newspack-blocks-es_ES-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
  183. package/languages/newspack-blocks-es_ES-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
  184. package/languages/newspack-blocks-es_ES-f5f8db76788e4079ddfa743333708b88.json +1 -0
  185. package/languages/newspack-blocks-es_ES-f8b1589c450689398f90b179f47e74ee.json +1 -0
  186. package/languages/newspack-blocks-es_ES-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
  187. package/languages/newspack-blocks-es_ES-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
  188. package/languages/newspack-blocks-es_ES-fcc93143c1f2b74671f595454b971f44.json +1 -0
  189. package/languages/newspack-blocks-es_ES.mo +0 -0
  190. package/languages/newspack-blocks-es_ES.po +2080 -0
  191. package/languages/newspack-blocks-fr_BE-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
  192. package/languages/newspack-blocks-fr_BE-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
  193. package/languages/newspack-blocks-fr_BE-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
  194. package/languages/newspack-blocks-fr_BE-10754bc02d28d4301c103f26dbf519ce.json +1 -0
  195. package/languages/newspack-blocks-fr_BE-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
  196. package/languages/newspack-blocks-fr_BE-34e5c64f90b1444f3fc735376442eada.json +1 -0
  197. package/languages/newspack-blocks-fr_BE-351fd022e077061b5796bf7042446bfc.json +1 -0
  198. package/languages/newspack-blocks-fr_BE-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
  199. package/languages/newspack-blocks-fr_BE-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
  200. package/languages/newspack-blocks-fr_BE-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
  201. package/languages/newspack-blocks-fr_BE-4f16e21047908d19937bc10ced63acd1.json +1 -0
  202. package/languages/newspack-blocks-fr_BE-4fdea541976076f02d56139fb35e5b42.json +1 -0
  203. package/languages/newspack-blocks-fr_BE-501b38ac90d35730a620fb0d483702fa.json +1 -0
  204. package/languages/newspack-blocks-fr_BE-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
  205. package/languages/newspack-blocks-fr_BE-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
  206. package/languages/newspack-blocks-fr_BE-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
  207. package/languages/newspack-blocks-fr_BE-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
  208. package/languages/newspack-blocks-fr_BE-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
  209. package/languages/newspack-blocks-fr_BE-727631509ad8eec8e2cbe740c6dad199.json +1 -0
  210. package/languages/newspack-blocks-fr_BE-73c6d3bde805172d1993f75397e9832d.json +1 -0
  211. package/languages/newspack-blocks-fr_BE-78456b164809d080adecb4d2b3895802.json +1 -0
  212. package/languages/newspack-blocks-fr_BE-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
  213. package/languages/newspack-blocks-fr_BE-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
  214. package/languages/newspack-blocks-fr_BE-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
  215. package/languages/newspack-blocks-fr_BE-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
  216. package/languages/newspack-blocks-fr_BE-969286d51bb0afe10983b9aec317b5ee.json +1 -0
  217. package/languages/newspack-blocks-fr_BE-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
  218. package/languages/newspack-blocks-fr_BE-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
  219. package/languages/newspack-blocks-fr_BE-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
  220. package/languages/newspack-blocks-fr_BE-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
  221. package/languages/newspack-blocks-fr_BE-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
  222. package/languages/newspack-blocks-fr_BE-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
  223. package/languages/newspack-blocks-fr_BE-bb66d96d450663284550bed5a3e9113e.json +1 -0
  224. package/languages/newspack-blocks-fr_BE-c810378e74f20906b8193ea76adb6bc0.json +1 -0
  225. package/languages/newspack-blocks-fr_BE-d3a1c55a07efd1a65e227bf120840752.json +1 -0
  226. package/languages/newspack-blocks-fr_BE-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
  227. package/languages/newspack-blocks-fr_BE-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
  228. package/languages/newspack-blocks-fr_BE-dd56360b115d1b39c48033c1e0749a11.json +1 -0
  229. package/languages/newspack-blocks-fr_BE-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
  230. package/languages/newspack-blocks-fr_BE-e58126c278611ed6c17684ba8e7459b4.json +1 -0
  231. package/languages/newspack-blocks-fr_BE-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
  232. package/languages/newspack-blocks-fr_BE-eccbc51a43c04f59165364eda71e0be7.json +1 -0
  233. package/languages/newspack-blocks-fr_BE-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
  234. package/languages/newspack-blocks-fr_BE-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
  235. package/languages/newspack-blocks-fr_BE-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
  236. package/languages/newspack-blocks-fr_BE-f5f8db76788e4079ddfa743333708b88.json +1 -0
  237. package/languages/newspack-blocks-fr_BE-f8b1589c450689398f90b179f47e74ee.json +1 -0
  238. package/languages/newspack-blocks-fr_BE-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
  239. package/languages/newspack-blocks-fr_BE-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
  240. package/languages/newspack-blocks-fr_BE-fcc93143c1f2b74671f595454b971f44.json +1 -0
  241. package/languages/newspack-blocks-fr_BE.mo +0 -0
  242. package/languages/newspack-blocks-fr_BE.po +2079 -0
  243. package/languages/newspack-blocks-nb_NO-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
  244. package/languages/newspack-blocks-nb_NO-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
  245. package/languages/newspack-blocks-nb_NO-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
  246. package/languages/newspack-blocks-nb_NO-10754bc02d28d4301c103f26dbf519ce.json +1 -0
  247. package/languages/newspack-blocks-nb_NO-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
  248. package/languages/newspack-blocks-nb_NO-34e5c64f90b1444f3fc735376442eada.json +1 -0
  249. package/languages/newspack-blocks-nb_NO-351fd022e077061b5796bf7042446bfc.json +1 -0
  250. package/languages/newspack-blocks-nb_NO-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
  251. package/languages/newspack-blocks-nb_NO-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
  252. package/languages/newspack-blocks-nb_NO-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
  253. package/languages/newspack-blocks-nb_NO-4f16e21047908d19937bc10ced63acd1.json +1 -0
  254. package/languages/newspack-blocks-nb_NO-4fdea541976076f02d56139fb35e5b42.json +1 -0
  255. package/languages/newspack-blocks-nb_NO-501b38ac90d35730a620fb0d483702fa.json +1 -0
  256. package/languages/newspack-blocks-nb_NO-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
  257. package/languages/newspack-blocks-nb_NO-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
  258. package/languages/newspack-blocks-nb_NO-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
  259. package/languages/newspack-blocks-nb_NO-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
  260. package/languages/newspack-blocks-nb_NO-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
  261. package/languages/newspack-blocks-nb_NO-73c6d3bde805172d1993f75397e9832d.json +1 -0
  262. package/languages/newspack-blocks-nb_NO-78456b164809d080adecb4d2b3895802.json +1 -0
  263. package/languages/newspack-blocks-nb_NO-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
  264. package/languages/newspack-blocks-nb_NO-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
  265. package/languages/newspack-blocks-nb_NO-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
  266. package/languages/newspack-blocks-nb_NO-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
  267. package/languages/newspack-blocks-nb_NO-969286d51bb0afe10983b9aec317b5ee.json +1 -0
  268. package/languages/newspack-blocks-nb_NO-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
  269. package/languages/newspack-blocks-nb_NO-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
  270. package/languages/newspack-blocks-nb_NO-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
  271. package/languages/newspack-blocks-nb_NO-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
  272. package/languages/newspack-blocks-nb_NO-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
  273. package/languages/newspack-blocks-nb_NO-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
  274. package/languages/newspack-blocks-nb_NO-bb66d96d450663284550bed5a3e9113e.json +1 -0
  275. package/languages/newspack-blocks-nb_NO-c810378e74f20906b8193ea76adb6bc0.json +1 -0
  276. package/languages/newspack-blocks-nb_NO-d3a1c55a07efd1a65e227bf120840752.json +1 -0
  277. package/languages/newspack-blocks-nb_NO-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
  278. package/languages/newspack-blocks-nb_NO-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
  279. package/languages/newspack-blocks-nb_NO-dd56360b115d1b39c48033c1e0749a11.json +1 -0
  280. package/languages/newspack-blocks-nb_NO-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
  281. package/languages/newspack-blocks-nb_NO-e58126c278611ed6c17684ba8e7459b4.json +1 -0
  282. package/languages/newspack-blocks-nb_NO-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
  283. package/languages/newspack-blocks-nb_NO-eccbc51a43c04f59165364eda71e0be7.json +1 -0
  284. package/languages/newspack-blocks-nb_NO-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
  285. package/languages/newspack-blocks-nb_NO-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
  286. package/languages/newspack-blocks-nb_NO-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
  287. package/languages/newspack-blocks-nb_NO-f5f8db76788e4079ddfa743333708b88.json +1 -0
  288. package/languages/newspack-blocks-nb_NO-f8b1589c450689398f90b179f47e74ee.json +1 -0
  289. package/languages/newspack-blocks-nb_NO-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
  290. package/languages/newspack-blocks-nb_NO-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
  291. package/languages/newspack-blocks-nb_NO-fcc93143c1f2b74671f595454b971f44.json +1 -0
  292. package/languages/newspack-blocks-nb_NO.mo +0 -0
  293. package/languages/newspack-blocks-nb_NO.po +2078 -0
  294. package/languages/newspack-blocks-pt_PT-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
  295. package/languages/newspack-blocks-pt_PT-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
  296. package/languages/newspack-blocks-pt_PT-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
  297. package/languages/newspack-blocks-pt_PT-10754bc02d28d4301c103f26dbf519ce.json +1 -0
  298. package/languages/newspack-blocks-pt_PT-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
  299. package/languages/newspack-blocks-pt_PT-34e5c64f90b1444f3fc735376442eada.json +1 -0
  300. package/languages/newspack-blocks-pt_PT-351fd022e077061b5796bf7042446bfc.json +1 -0
  301. package/languages/newspack-blocks-pt_PT-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
  302. package/languages/newspack-blocks-pt_PT-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
  303. package/languages/newspack-blocks-pt_PT-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
  304. package/languages/newspack-blocks-pt_PT-4f16e21047908d19937bc10ced63acd1.json +1 -0
  305. package/languages/newspack-blocks-pt_PT-4fdea541976076f02d56139fb35e5b42.json +1 -0
  306. package/languages/newspack-blocks-pt_PT-501b38ac90d35730a620fb0d483702fa.json +1 -0
  307. package/languages/newspack-blocks-pt_PT-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
  308. package/languages/newspack-blocks-pt_PT-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
  309. package/languages/newspack-blocks-pt_PT-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
  310. package/languages/newspack-blocks-pt_PT-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
  311. package/languages/newspack-blocks-pt_PT-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
  312. package/languages/newspack-blocks-pt_PT-727631509ad8eec8e2cbe740c6dad199.json +1 -0
  313. package/languages/newspack-blocks-pt_PT-73c6d3bde805172d1993f75397e9832d.json +1 -0
  314. package/languages/newspack-blocks-pt_PT-78456b164809d080adecb4d2b3895802.json +1 -0
  315. package/languages/newspack-blocks-pt_PT-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
  316. package/languages/newspack-blocks-pt_PT-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
  317. package/languages/newspack-blocks-pt_PT-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
  318. package/languages/newspack-blocks-pt_PT-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
  319. package/languages/newspack-blocks-pt_PT-969286d51bb0afe10983b9aec317b5ee.json +1 -0
  320. package/languages/newspack-blocks-pt_PT-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
  321. package/languages/newspack-blocks-pt_PT-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
  322. package/languages/newspack-blocks-pt_PT-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
  323. package/languages/newspack-blocks-pt_PT-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
  324. package/languages/newspack-blocks-pt_PT-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
  325. package/languages/newspack-blocks-pt_PT-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
  326. package/languages/newspack-blocks-pt_PT-bb66d96d450663284550bed5a3e9113e.json +1 -0
  327. package/languages/newspack-blocks-pt_PT-c810378e74f20906b8193ea76adb6bc0.json +1 -0
  328. package/languages/newspack-blocks-pt_PT-d3a1c55a07efd1a65e227bf120840752.json +1 -0
  329. package/languages/newspack-blocks-pt_PT-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
  330. package/languages/newspack-blocks-pt_PT-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
  331. package/languages/newspack-blocks-pt_PT-dd56360b115d1b39c48033c1e0749a11.json +1 -0
  332. package/languages/newspack-blocks-pt_PT-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
  333. package/languages/newspack-blocks-pt_PT-e58126c278611ed6c17684ba8e7459b4.json +1 -0
  334. package/languages/newspack-blocks-pt_PT-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
  335. package/languages/newspack-blocks-pt_PT-eccbc51a43c04f59165364eda71e0be7.json +1 -0
  336. package/languages/newspack-blocks-pt_PT-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
  337. package/languages/newspack-blocks-pt_PT-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
  338. package/languages/newspack-blocks-pt_PT-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
  339. package/languages/newspack-blocks-pt_PT-f5f8db76788e4079ddfa743333708b88.json +1 -0
  340. package/languages/newspack-blocks-pt_PT-f8b1589c450689398f90b179f47e74ee.json +1 -0
  341. package/languages/newspack-blocks-pt_PT-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
  342. package/languages/newspack-blocks-pt_PT-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
  343. package/languages/newspack-blocks-pt_PT-fcc93143c1f2b74671f595454b971f44.json +1 -0
  344. package/languages/newspack-blocks-pt_PT.mo +0 -0
  345. package/languages/newspack-blocks-pt_PT.po +2078 -0
  346. package/languages/newspack-blocks.pot +2370 -0
  347. package/newspack-blocks.php +96 -0
  348. package/package.json +64 -0
  349. package/phpcs.xml +38 -0
  350. package/release.config.js +1 -0
  351. package/src/assets/placeholder-1024x536.jpg +0 -0
  352. package/src/assets/placeholder-600x800.jpg +0 -0
  353. package/src/assets/placeholder-800x600.jpg +0 -0
  354. package/src/assets/placeholder-800x800.jpg +0 -0
  355. package/src/assets/placeholder-donations-cover.jpg +0 -0
  356. package/src/assets/placeholder-donations-image.jpg +0 -0
  357. package/src/assets/placeholder-subscribe-cover.jpg +0 -0
  358. package/src/assets/placeholder-subscribe-image.jpg +0 -0
  359. package/src/block-patterns/donations-1.php +13 -0
  360. package/src/block-patterns/donations-2.php +13 -0
  361. package/src/block-patterns/donations-3.php +13 -0
  362. package/src/block-patterns/donations-4.php +13 -0
  363. package/src/block-patterns/donations-5.php +13 -0
  364. package/src/block-patterns/homepage-posts-1.php +13 -0
  365. package/src/block-patterns/homepage-posts-10.php +13 -0
  366. package/src/block-patterns/homepage-posts-11.php +13 -0
  367. package/src/block-patterns/homepage-posts-12.php +13 -0
  368. package/src/block-patterns/homepage-posts-13.php +13 -0
  369. package/src/block-patterns/homepage-posts-14.php +13 -0
  370. package/src/block-patterns/homepage-posts-15.php +13 -0
  371. package/src/block-patterns/homepage-posts-16.php +13 -0
  372. package/src/block-patterns/homepage-posts-17.php +13 -0
  373. package/src/block-patterns/homepage-posts-18.php +13 -0
  374. package/src/block-patterns/homepage-posts-19.php +13 -0
  375. package/src/block-patterns/homepage-posts-2.php +13 -0
  376. package/src/block-patterns/homepage-posts-20.php +13 -0
  377. package/src/block-patterns/homepage-posts-21.php +13 -0
  378. package/src/block-patterns/homepage-posts-22.php +13 -0
  379. package/src/block-patterns/homepage-posts-23.php +13 -0
  380. package/src/block-patterns/homepage-posts-24.php +13 -0
  381. package/src/block-patterns/homepage-posts-25.php +13 -0
  382. package/src/block-patterns/homepage-posts-26.php +13 -0
  383. package/src/block-patterns/homepage-posts-27.php +13 -0
  384. package/src/block-patterns/homepage-posts-28.php +13 -0
  385. package/src/block-patterns/homepage-posts-29.php +13 -0
  386. package/src/block-patterns/homepage-posts-3.php +13 -0
  387. package/src/block-patterns/homepage-posts-30.php +13 -0
  388. package/src/block-patterns/homepage-posts-31.php +13 -0
  389. package/src/block-patterns/homepage-posts-4.php +13 -0
  390. package/src/block-patterns/homepage-posts-5.php +13 -0
  391. package/src/block-patterns/homepage-posts-6.php +13 -0
  392. package/src/block-patterns/homepage-posts-7.php +13 -0
  393. package/src/block-patterns/homepage-posts-8.php +13 -0
  394. package/src/block-patterns/homepage-posts-9.php +13 -0
  395. package/src/block-patterns/subscribe-1.php +13 -0
  396. package/src/block-patterns/subscribe-2.php +13 -0
  397. package/src/block-patterns/subscribe-3.php +13 -0
  398. package/src/block-patterns/subscribe-4.php +13 -0
  399. package/src/block-patterns/subscribe-5.php +13 -0
  400. package/src/block-patterns/subscribe-6.php +13 -0
  401. package/src/block-patterns/subscribe-7.php +13 -0
  402. package/src/block-styles/core/columns/editor.scss +90 -0
  403. package/src/block-styles/core/columns/index.js +20 -0
  404. package/src/block-styles/core/columns/view.scss +131 -0
  405. package/src/block-styles/core/group/editor.scss +24 -0
  406. package/src/block-styles/core/group/index.js +25 -0
  407. package/src/block-styles/core/group/view.scss +13 -0
  408. package/src/block-styles/view.js +5 -0
  409. package/src/blocks/author-list/block.json +84 -0
  410. package/src/blocks/author-list/class-wp-rest-newspack-author-list-controller.php +381 -0
  411. package/src/blocks/author-list/edit.js +456 -0
  412. package/src/blocks/author-list/editor.js +7 -0
  413. package/src/blocks/author-list/editor.scss +1 -0
  414. package/src/blocks/author-list/index.js +60 -0
  415. package/src/blocks/author-list/view.js +5 -0
  416. package/src/blocks/author-list/view.php +180 -0
  417. package/src/blocks/author-list/view.scss +46 -0
  418. package/src/blocks/author-profile/README.md +105 -0
  419. package/src/blocks/author-profile/block.json +77 -0
  420. package/src/blocks/author-profile/class-wp-rest-newspack-authors-controller.php +618 -0
  421. package/src/blocks/author-profile/context.js +26 -0
  422. package/src/blocks/author-profile/edit.js +1031 -0
  423. package/src/blocks/author-profile/editor.js +7 -0
  424. package/src/blocks/author-profile/editor.scss +61 -0
  425. package/src/blocks/author-profile/index.js +66 -0
  426. package/src/blocks/author-profile/single-author.js +106 -0
  427. package/src/blocks/author-profile/templates.js +263 -0
  428. package/src/blocks/author-profile/variations.js +86 -0
  429. package/src/blocks/author-profile/view.js +5 -0
  430. package/src/blocks/author-profile/view.php +501 -0
  431. package/src/blocks/author-profile/view.scss +159 -0
  432. package/src/blocks/carousel/block.json +121 -0
  433. package/src/blocks/carousel/create-swiper.js +230 -0
  434. package/src/blocks/carousel/edit.js +469 -0
  435. package/src/blocks/carousel/editor.js +7 -0
  436. package/src/blocks/carousel/editor.scss +54 -0
  437. package/src/blocks/carousel/index.js +55 -0
  438. package/src/blocks/carousel/view.js +49 -0
  439. package/src/blocks/carousel/view.php +417 -0
  440. package/src/blocks/carousel/view.scss +397 -0
  441. package/src/blocks/checkout-button/block.json +117 -0
  442. package/src/blocks/checkout-button/deprecated.js +81 -0
  443. package/src/blocks/checkout-button/edit.js +385 -0
  444. package/src/blocks/checkout-button/edit.scss +67 -0
  445. package/src/blocks/checkout-button/editor.js +19 -0
  446. package/src/blocks/checkout-button/index.js +32 -0
  447. package/src/blocks/checkout-button/view.js +4 -0
  448. package/src/blocks/checkout-button/view.php +178 -0
  449. package/src/blocks/checkout-button/view.scss +39 -0
  450. package/src/blocks/donate/block.json +103 -0
  451. package/src/blocks/donate/consts.ts +25 -0
  452. package/src/blocks/donate/edit/FrequencyBasedLayout.tsx +255 -0
  453. package/src/blocks/donate/edit/TierBasedLayout.tsx +133 -0
  454. package/src/blocks/donate/edit/components/AmountValueInput.tsx +62 -0
  455. package/src/blocks/donate/edit/components/index.tsx +1 -0
  456. package/src/blocks/donate/edit/index.tsx +445 -0
  457. package/src/blocks/donate/editor.js +7 -0
  458. package/src/blocks/donate/frequency-based/index.ts +135 -0
  459. package/src/blocks/donate/frequency-based/style.scss +245 -0
  460. package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-base.php +225 -0
  461. package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-frequency-based.php +341 -0
  462. package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-tiers-based.php +184 -0
  463. package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer.php +117 -0
  464. package/src/blocks/donate/index.js +72 -0
  465. package/src/blocks/donate/styles/editor.scss +230 -0
  466. package/src/blocks/donate/styles/style-variations.scss +792 -0
  467. package/src/blocks/donate/styles/view.scss +45 -0
  468. package/src/blocks/donate/tiers-based/index.ts +36 -0
  469. package/src/blocks/donate/tiers-based/slider.ts +64 -0
  470. package/src/blocks/donate/tiers-based/style.scss +185 -0
  471. package/src/blocks/donate/tiers-based/types.ts +3 -0
  472. package/src/blocks/donate/tiers-based/utils.test.js +38 -0
  473. package/src/blocks/donate/tiers-based/utils.ts +21 -0
  474. package/src/blocks/donate/tiers-based/view.ts +132 -0
  475. package/src/blocks/donate/types.ts +96 -0
  476. package/src/blocks/donate/utils.ts +108 -0
  477. package/src/blocks/donate/view.php +29 -0
  478. package/src/blocks/donate/view.ts +44 -0
  479. package/src/blocks/homepage-articles/block.json +260 -0
  480. package/src/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php +231 -0
  481. package/src/blocks/homepage-articles/edit.tsx +730 -0
  482. package/src/blocks/homepage-articles/editor.js +16 -0
  483. package/src/blocks/homepage-articles/editor.scss +226 -0
  484. package/src/blocks/homepage-articles/index.js +102 -0
  485. package/src/blocks/homepage-articles/store.js +193 -0
  486. package/src/blocks/homepage-articles/templates/article.php +290 -0
  487. package/src/blocks/homepage-articles/templates/articles-list.php +21 -0
  488. package/src/blocks/homepage-articles/templates/articles-loop.php +35 -0
  489. package/src/blocks/homepage-articles/utils.ts +270 -0
  490. package/src/blocks/homepage-articles/view.js +242 -0
  491. package/src/blocks/homepage-articles/view.php +561 -0
  492. package/src/blocks/homepage-articles/view.scss +784 -0
  493. package/src/blocks/iframe/block.json +36 -0
  494. package/src/blocks/iframe/class-wp-rest-newspack-iframe-controller.php +586 -0
  495. package/src/blocks/iframe/edit.js +232 -0
  496. package/src/blocks/iframe/editor.js +7 -0
  497. package/src/blocks/iframe/editor.scss +84 -0
  498. package/src/blocks/iframe/iframe-placeholder.js +166 -0
  499. package/src/blocks/iframe/index.js +54 -0
  500. package/src/blocks/iframe/view.js +49 -0
  501. package/src/blocks/iframe/view.php +116 -0
  502. package/src/blocks/iframe/view.scss +9 -0
  503. package/src/blocks/shared/author.js +47 -0
  504. package/src/blocks/video-playlist/edit.js +222 -0
  505. package/src/blocks/video-playlist/editor.js +7 -0
  506. package/src/blocks/video-playlist/editor.scss +23 -0
  507. package/src/blocks/video-playlist/index.js +54 -0
  508. package/src/blocks/video-playlist/view.php +188 -0
  509. package/src/components/autocomplete-tokenfield.js +189 -0
  510. package/src/components/autocomplete-tokenfield.scss +27 -0
  511. package/src/components/editor-panels.js +90 -0
  512. package/src/components/query-controls.js +450 -0
  513. package/src/components/redirect-after-success.tsx +50 -0
  514. package/src/modal-checkout/accessibility.js +73 -0
  515. package/src/modal-checkout/analytics/ga4/README.md +45 -0
  516. package/src/modal-checkout/analytics/ga4/checkout-attempt.js +18 -0
  517. package/src/modal-checkout/analytics/ga4/checkout-success.js +17 -0
  518. package/src/modal-checkout/analytics/ga4/dismissed.js +17 -0
  519. package/src/modal-checkout/analytics/ga4/loaded.js +17 -0
  520. package/src/modal-checkout/analytics/ga4/opened.js +37 -0
  521. package/src/modal-checkout/analytics/ga4/pagination.js +59 -0
  522. package/src/modal-checkout/analytics/ga4/utils/index.js +64 -0
  523. package/src/modal-checkout/analytics/index.js +6 -0
  524. package/src/modal-checkout/checkout.scss +1064 -0
  525. package/src/modal-checkout/index.js +929 -0
  526. package/src/modal-checkout/modal.js +983 -0
  527. package/src/modal-checkout/modal.scss +265 -0
  528. package/src/modal-checkout/templates/empty-html-add-recipient.php +15 -0
  529. package/src/modal-checkout/templates/empty-order-details.php +16 -0
  530. package/src/modal-checkout/templates/form-change-payment-method.php +99 -0
  531. package/src/modal-checkout/templates/form-checkout.php +74 -0
  532. package/src/modal-checkout/templates/form-coupon.php +22 -0
  533. package/src/modal-checkout/templates/form-gift-subscription.php +34 -0
  534. package/src/modal-checkout/templates/payment-method.php +29 -0
  535. package/src/modal-checkout/templates/thankyou.php +94 -0
  536. package/src/modal-checkout/utils.js +309 -0
  537. package/src/setup/block-styles.js +2 -0
  538. package/src/setup/category.js +18 -0
  539. package/src/setup/editor.js +7 -0
  540. package/src/setup/editor.scss +56 -0
  541. package/src/setup/newspack-logo.js +26 -0
  542. package/src/setup/placeholder-blocks.js +84 -0
  543. package/src/setup/unregister-blocks.js +14 -0
  544. package/src/shared/authors.php +63 -0
  545. package/src/shared/js/newspack-icon.js +31 -0
  546. package/src/shared/js/utils.js +50 -0
  547. package/src/shared/sass/_mixins.scss +42 -0
  548. package/src/shared/sass/_placeholder.scss +5 -0
  549. package/src/shared/sass/_preview.scss +12 -0
  550. package/src/shared/sass/_variables.scss +24 -0
  551. package/src/templates/author-profile-card.php +145 -0
  552. package/src/types/@wordpress/block-editor.d.ts +1 -0
  553. package/src/types/@wordpress/components.d.ts +1 -0
  554. package/src/types/index.d.ts +170 -0
  555. package/src/types/newspack-components.d.ts +7 -0
  556. package/tsconfig.json +7 -0
  557. package/vendor/autoload.php +22 -0
  558. package/vendor/composer/ClassLoader.php +579 -0
  559. package/vendor/composer/InstalledVersions.php +396 -0
  560. package/vendor/composer/LICENSE +21 -0
  561. package/vendor/composer/autoload_classmap.php +10 -0
  562. package/vendor/composer/autoload_namespaces.php +9 -0
  563. package/vendor/composer/autoload_psr4.php +9 -0
  564. package/vendor/composer/autoload_real.php +36 -0
  565. package/vendor/composer/autoload_static.php +20 -0
  566. package/vendor/composer/installed.json +5 -0
  567. package/vendor/composer/installed.php +23 -0
  568. package/webpack.config.js +82 -0
@@ -0,0 +1,929 @@
1
+ /* globals newspackBlocksModalCheckout, jQuery, wc_checkout_params */
2
+ /**
3
+ * Style dependencies
4
+ */
5
+ import './checkout.scss';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { manageCheckoutAttempt, manageCheckoutSuccess, manageLoaded, managePagination } from './analytics';
11
+ import { domReady, onCheckoutPlaceOrderProcessing } from './utils';
12
+
13
+ ( $ => {
14
+ domReady( () => {
15
+ if ( ! $ ) {
16
+ console.warn( 'jQuery is not available.' ); // eslint-disable-line no-console
17
+ return;
18
+ }
19
+
20
+ const container = document.querySelector( '#newspack_modal_checkout_container' );
21
+
22
+ const CLASS_PREFIX = newspackBlocksModalCheckout.newspack_class_prefix;
23
+ const readyEvent = new CustomEvent( 'checkout-ready' );
24
+ const completeEvent = new CustomEvent( 'checkout-complete' );
25
+ const cancelEvent = new CustomEvent( 'checkout-cancel' );
26
+ const placeOrderStartEvent = new CustomEvent( 'checkout-place-order-start' );
27
+ const placeOrderSuccessEvent = new CustomEvent( 'checkout-place-order-success' );
28
+ const placeOrderErrorEvent = new CustomEvent( 'checkout-place-order-error' );
29
+ const placeOrderCriticalErrorEvent = new CustomEvent( 'checkout-place-order-critical-error' );
30
+
31
+ function getEventHandlers( element, event ) {
32
+ const events = $._data( element, 'events' );
33
+ if ( ! events ) {
34
+ return [];
35
+ }
36
+ if ( ! event ) {
37
+ return events;
38
+ }
39
+ return events[ event ] || [];
40
+ }
41
+
42
+ function clearNotices() {
43
+ $( '.woocommerce-notices-wrapper' ).empty();
44
+ $(
45
+ `.woocommerce-NoticeGroup-checkout, .${ CLASS_PREFIX }__inline-error, .woocommerce-error, .woocommerce-message, .wc-block-components-notice-banner`
46
+ ).remove();
47
+ }
48
+
49
+ /**
50
+ * Set the checkout as ready so the modal can resolve the loading state.
51
+ */
52
+ function setReady( init_modal_opened = true ) {
53
+ container.checkoutReady = true;
54
+ container.dispatchEvent( readyEvent );
55
+ if ( init_modal_opened ) {
56
+ // Only fire this data event when the modal is being opened.
57
+ manageLoaded( container );
58
+ }
59
+ }
60
+
61
+ if ( newspackBlocksModalCheckout.is_checkout_complete ) {
62
+ manageCheckoutSuccess();
63
+
64
+ /**
65
+ * Set the checkout as complete so the modal can resolve post checkout flows.
66
+ */
67
+ if ( container ) {
68
+ container.checkoutComplete = true;
69
+ container.dispatchEvent( completeEvent );
70
+ }
71
+ } else {
72
+ function init() {
73
+ // If present, update the markup used for the WooPayments express checkout divider.
74
+ $(
75
+ '#wcpay-express-checkout-button-separator, #wc-stripe-payment-request-button-separator, #wc-stripe-express-checkout-button-separator'
76
+ ).after( '<div class="newspack-ui__word-divider">' + newspackBlocksModalCheckout.divider_text + '</div>' );
77
+
78
+ let originalFormHandlers = [];
79
+
80
+ const $form = $( 'form.checkout' );
81
+
82
+ const $checkout_cancel = $( '#checkout_cancel' );
83
+ if ( $checkout_cancel.length ) {
84
+ $checkout_cancel.on( 'click', function () {
85
+ container.dispatchEvent( cancelEvent );
86
+ } );
87
+ }
88
+
89
+ if ( ! $form.length ) {
90
+ console.warn( 'Checkout form is not available' ); // eslint-disable-line no-console
91
+ setReady();
92
+ return;
93
+ }
94
+
95
+ const $coupon = $( 'form.modal_checkout_coupon' );
96
+ const $nyp = $( 'form.modal_checkout_nyp' );
97
+ const $checkout_continue = $( '#checkout_continue' );
98
+ const $customer_details = $( '#customer_details' );
99
+ const $after_customer_details = $( '#after_customer_details' );
100
+ const $gift_options = $( '.newspack-wcsg--wrapper' );
101
+
102
+ /**
103
+ * Handle styling update for selected payment method.
104
+ */
105
+ function handlePaymentMethodSelect() {
106
+ const selected = $( 'input[name="payment_method"]:checked' ).val();
107
+ $( '.wc_payment_method' ).removeClass( 'selected' );
108
+ $( '.wc_payment_method.payment_method_' + selected ).addClass( 'selected' );
109
+ }
110
+ $( 'input[name="payment_method"]' ).change( handlePaymentMethodSelect );
111
+ $( document ).on( 'payment_method_selected', handlePaymentMethodSelect );
112
+ $( document ).on( 'updated_checkout', handlePaymentMethodSelect );
113
+ handlePaymentMethodSelect();
114
+
115
+ /**
116
+ * Bubble up checkout place order event.
117
+ */
118
+ let placedOrder = false;
119
+ $form.on( 'checkout_place_order', function () {
120
+ if ( placedOrder ) {
121
+ return;
122
+ }
123
+ placedOrder = true;
124
+ container.dispatchEvent( placeOrderStartEvent );
125
+ } );
126
+ onCheckoutPlaceOrderProcessing( container, function () {
127
+ if ( ! placedOrder ) {
128
+ return;
129
+ }
130
+ // If the form stops processing before the `checkout_place_order_success` event is fired, dispatch an error event.
131
+ if ( ! $form.is( '.processing' ) ) {
132
+ placedOrder = false;
133
+ container.dispatchEvent( placeOrderErrorEvent );
134
+ }
135
+ } );
136
+ $form.on( 'checkout_place_order_success', function () {
137
+ placedOrder = false;
138
+ container.dispatchEvent( placeOrderSuccessEvent );
139
+ } );
140
+
141
+ $( document.body ).on( 'checkout_error', function ( event, errors ) {
142
+ if ( ! placedOrder ) {
143
+ return;
144
+ }
145
+ placedOrder = false;
146
+ if ( errors && errors.indexOf( newspackBlocksModalCheckout.labels.critical_error ) >= 0 ) {
147
+ container.dispatchEvent( placeOrderCriticalErrorEvent );
148
+ return;
149
+ }
150
+ container.dispatchEvent( placeOrderErrorEvent );
151
+ } );
152
+ $form.on( 'update_checkout', function () {
153
+ if ( ! placedOrder ) {
154
+ return;
155
+ }
156
+ placedOrder = false;
157
+ container.dispatchEvent( placeOrderErrorEvent );
158
+ } );
159
+
160
+ /**
161
+ * Toggle "Payment info" title if there's no money transaction.
162
+ */
163
+ $( document ).on( 'updated_checkout', function () {
164
+ if ( $( '#payment .wc_payment_methods' ).length ) {
165
+ $( '#after_customer_details > h3' ).show();
166
+ } else {
167
+ $( '#after_customer_details > h3' ).hide();
168
+ }
169
+ } );
170
+
171
+ /**
172
+ * Handle order review table appearance.
173
+ */
174
+ $( document ).on( 'updated_checkout', function () {
175
+ const $wrapper = $( '.order-review-wrapper' );
176
+ if ( ! $wrapper.length ) {
177
+ return;
178
+ }
179
+
180
+ const $table = $wrapper.find( 'table' );
181
+
182
+ // Toggle visibility according to table content.
183
+ if ( $table.is( '.empty' ) ) {
184
+ $wrapper.addClass( 'hidden' );
185
+ } else {
186
+ // WooCommerce blocks the order review table while updating.
187
+ // We need to make sure the cloned table is always unblocked.
188
+ $table.unblock();
189
+ $wrapper.removeClass( 'hidden' );
190
+ }
191
+
192
+ const $details = $( '#after_customer_details' );
193
+ const expanded = $details.hasClass( 'transaction-details-expanded' );
194
+
195
+ // Move new order review table to the payment methods.
196
+ const $payment_methods = $( '.payment_methods' );
197
+ if ( $payment_methods.length ) {
198
+ const $el = $wrapper.clone();
199
+ // Make sure Transaction Details toggle's aria-expanded value is correct in cloned version.
200
+ if ( expanded ) {
201
+ $( '[id="order_review_heading"]', $el ).attr( 'aria-expanded', 'true' );
202
+ }
203
+ $( '.order-review-wrapper' ).remove();
204
+ $payment_methods.after( $el );
205
+ } else if ( ! expanded ) {
206
+ // If there's no payment method, make sure to expand the Transaction Details on load.
207
+ $wrapper.find( '#order_review_heading' ).trigger( 'click' );
208
+ }
209
+ } );
210
+
211
+ /**
212
+ * Toggle Transaction Details
213
+ */
214
+ $( document ).on( 'click', '#order_review_heading', function () {
215
+ // Toggle the aria-expanded attribute.
216
+ $( this ).attr( 'aria-expanded', function ( index, attr ) {
217
+ return attr === 'false' ? 'true' : 'false';
218
+ } );
219
+ // Toggle the CSS class to show/hide the Transaction Details.
220
+ $( '#after_customer_details' ).toggleClass( 'transaction-details-expanded' );
221
+ } );
222
+
223
+ /**
224
+ * Get updated cart total to update the "Place Order" button.
225
+ */
226
+ function getUpdatedCartTotal() {
227
+ let cartTotal;
228
+ $.ajax( {
229
+ url: newspackBlocksModalCheckout.ajax_url,
230
+ method: 'POST',
231
+ async: false,
232
+ data: {
233
+ action: 'get_cart_total',
234
+ },
235
+ success: response => {
236
+ cartTotal = response;
237
+ },
238
+ } );
239
+ if ( cartTotal ) {
240
+ return cartTotal;
241
+ }
242
+ }
243
+
244
+ /**
245
+ * Update Place Order button text.
246
+ */
247
+ $( document ).on( 'updated_checkout', function () {
248
+ // Update "Place Order" button to include current price.
249
+ let processOrderText = newspackBlocksModalCheckout.labels.complete_button;
250
+ if ( ! processOrderText ) {
251
+ return;
252
+ }
253
+ if ( $( '#place_order' ).has( $( 'span.cart-price' ) ) ) {
254
+ // Modify button text to include updated price.
255
+ const tree = $( '<div>' + processOrderText + '</div>' );
256
+ // Update the HTML in the .cart-price span with the new price, and return.
257
+ tree.find( '.cart-price' ).html( getUpdatedCartTotal, function () {
258
+ return this.childNodes;
259
+ } );
260
+ processOrderText = tree.html();
261
+ }
262
+ $( '#place_order' ).html( processOrderText );
263
+ $( '#place_order_clone' ).html( processOrderText );
264
+ } );
265
+
266
+ /**
267
+ * Handle gift options.
268
+ */
269
+ if ( $gift_options.length ) {
270
+ const $gift_toggle = $gift_options.find( '.newspack-wcsg--gift-toggle input' );
271
+ const $gift_email = $gift_options.find( '.newspack-wcsg--gift-email' );
272
+ $gift_toggle.on( 'change', function () {
273
+ if ( $gift_toggle.is( ':checked' ) ) {
274
+ $gift_email.addClass( 'visible' );
275
+ } else {
276
+ $gift_email.removeClass( 'visible' );
277
+ }
278
+ } );
279
+ }
280
+
281
+ /**
282
+ * Initialize the 2-step checkout form.
283
+ */
284
+ if ( $checkout_continue.length ) {
285
+ setEditingDetails( true );
286
+ if ( ! $gift_options.length ) {
287
+ // Perform initial validation so it can skip 1st step if possible.
288
+ validateForm( true, setReady );
289
+ } else {
290
+ setReady();
291
+ }
292
+ } else {
293
+ setReady();
294
+ }
295
+
296
+ /**
297
+ * Handle form errors while editing billing/shipping fields.
298
+ *
299
+ * @param {string} error_message
300
+ */
301
+ function handleFormError( error_message ) {
302
+ $form.find( '.input-text, select, input:checkbox' ).trigger( 'validate' ).trigger( 'blur' );
303
+
304
+ let $fieldToFocus = false;
305
+
306
+ const genericErrors = [];
307
+
308
+ /**
309
+ * If a field is found, append the error to it. Otherwise, add it to the
310
+ * generic errors array.
311
+ *
312
+ * @param {jQuery} $error
313
+ */
314
+ const handleErrorItem = $error => {
315
+ // Add errors to known fields.
316
+ const $field = $( '#' + $error.data( 'id' ) + '_field' );
317
+ if ( $field?.length ) {
318
+ if ( ! $fieldToFocus ) {
319
+ $fieldToFocus = $field;
320
+ }
321
+ const $existingError = $field.find( '.woocommerce-error' );
322
+ if ( $existingError.length ) {
323
+ $existingError.remove();
324
+ }
325
+ $field.addClass( 'woocommerce-invalid' ).removeClass( 'woocommerce-valid' );
326
+ $field.append( `<span class="${ CLASS_PREFIX }__inline-error">` + $error.text() + '</span>' );
327
+ $error.remove();
328
+ } else {
329
+ if ( ! $error.is( 'li' ) ) {
330
+ $error = $( '<li />' ).append( $error );
331
+ }
332
+ genericErrors.push( $error );
333
+ }
334
+ };
335
+
336
+ clearNotices();
337
+
338
+ if ( error_message.trimStart().indexOf( '<' ) !== 0 ) {
339
+ // If error_message is not an HTML string, wrap it in a <li />.
340
+ handleErrorItem( $( '<li />' ).append( error_message ) );
341
+ } else if ( ! error_message.includes( '<li' ) ) {
342
+ // If not a list, handle as a single error.
343
+ handleErrorItem( $( error_message ) );
344
+ } else {
345
+ // Handle multiple errors.
346
+ const $errors = $( error_message );
347
+ $errors.find( 'li' ).each( function () {
348
+ handleErrorItem( $( this ) );
349
+ } );
350
+ }
351
+
352
+ // Handle generic errors.
353
+ if ( genericErrors.length ) {
354
+ $fieldToFocus = false; // Don't focus a field if validation returned generic errors.
355
+ const $notices = $( '<div class="woocommerce-NoticeGroup woocommerce-NoticeGroup-checkout"/>' ).append(
356
+ $( '<ul class="woocommerce-error" role="alert" />' ).append( genericErrors )
357
+ );
358
+ $form.prepend( $notices );
359
+ $notices.get( 0 ).scrollIntoView( { behavior: 'smooth' } );
360
+ }
361
+
362
+ if ( $fieldToFocus?.length ) {
363
+ window.scroll( { top: $fieldToFocus.offset().top - 100, left: 0, behavior: 'smooth' } );
364
+ $fieldToFocus.find( 'input.input-text, select, input:checkbox' ).trigger( 'focus' );
365
+ }
366
+
367
+ unblockForm( $form );
368
+
369
+ $( document.body ).trigger( 'update_checkout' );
370
+ $( document.body ).trigger( 'checkout_error', [ error_message ] );
371
+ }
372
+
373
+ /**
374
+ * Handle coupon form submit.
375
+ *
376
+ * @param {Event} ev
377
+ */
378
+ function handleCouponSubmit( ev ) {
379
+ ev.preventDefault();
380
+ const blocked = blockForm( $coupon );
381
+ if ( ! blocked ) {
382
+ return false;
383
+ }
384
+ const data = {
385
+ security: wc_checkout_params.apply_coupon_nonce,
386
+ coupon_code: $coupon.find( 'input[name="coupon_code"]' ).val(),
387
+ };
388
+ // Ajax request.
389
+ $.ajax( {
390
+ type: 'POST',
391
+ url: wc_checkout_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'apply_coupon' ),
392
+ data,
393
+ dataType: 'html',
394
+ success: code => {
395
+ clearNotices();
396
+ $coupon.find( '.result' ).remove();
397
+ if ( code ) {
398
+ const isError = code.includes( 'error' );
399
+ $coupon.append(
400
+ `<p class="result ${ CLASS_PREFIX }__helper-text ${ isError ? CLASS_PREFIX + '__inline-error' : '' }">` +
401
+ $( code ).text() +
402
+ '</p>'
403
+ );
404
+ if ( isError ) {
405
+ $coupon.find( 'input[name="coupon_code"]' ).focus();
406
+ $coupon.find( 'h3, input[name="coupon_code"]' ).addClass( 'newspack-ui__field-error' );
407
+ } else {
408
+ $coupon.find( 'input[name="coupon_code"]' ).focus();
409
+ $coupon.find( 'h3, input[name="coupon_code"]' ).removeClass( 'newspack-ui__field-error' );
410
+ }
411
+ $( document.body ).trigger( 'applied_coupon_in_checkout', [ data.coupon_code ] );
412
+ $( document.body ).trigger( 'update_checkout', { update_shipping_method: false } );
413
+ }
414
+ },
415
+ complete: () => {
416
+ unblockForm( $coupon );
417
+ },
418
+ } );
419
+ }
420
+ if ( $coupon.length ) {
421
+ $coupon.on( 'submit', handleCouponSubmit );
422
+ $( document.body ).on( 'removed_coupon_in_checkout', () => {
423
+ clearNotices();
424
+ $coupon.find( '.result' ).remove();
425
+ $coupon.find( 'input[name="coupon_code"]' ).val( '' ).focus();
426
+ } );
427
+ }
428
+
429
+ /**
430
+ * Handle name your price submission.
431
+ *
432
+ * @param {Event} ev
433
+ */
434
+ function handleNYPFormSubmit( ev ) {
435
+ ev.preventDefault();
436
+ const blocked = blockForm( $nyp );
437
+ if ( ! blocked ) {
438
+ return false;
439
+ }
440
+ const input = $nyp.find( 'input[name="price"]' );
441
+ input.attr( 'disabled', true );
442
+ const data = {
443
+ _ajax_nonce: newspackBlocksModalCheckout.nyp_nonce,
444
+ action: 'process_name_your_price_request',
445
+ price: $nyp.find( 'input[name="price"]' ).val(),
446
+ product_id: $nyp.find( 'input[name="product_id"]' ).val(),
447
+ newspack_checkout_name_your_price: $nyp.find( 'input[name="newspack_checkout_name_your_price"]' ).val(),
448
+ };
449
+ $.ajax( {
450
+ type: 'POST',
451
+ url: newspackBlocksModalCheckout.ajax_url,
452
+ data,
453
+ success: ( { success, data: res } ) => {
454
+ clearNotices();
455
+ $nyp.find( '.result' ).remove();
456
+ $nyp.append(
457
+ `<p class="result ${ CLASS_PREFIX }__helper-text ${ ! success ? CLASS_PREFIX + '__inline-error' : '' }">` +
458
+ res.message +
459
+ '</p>'
460
+ );
461
+ if ( success ) {
462
+ $nyp.find( 'h3, input[name="price"]' ).removeClass( 'newspack-ui__field-error' );
463
+ } else {
464
+ $nyp.find( 'input[name="price"]' ).focus();
465
+ $nyp.find( 'h3, input[name="price"]' ).addClass( 'newspack-ui__field-error' );
466
+ }
467
+ $( document.body ).trigger( 'update_checkout', { update_shipping_method: false } );
468
+ },
469
+ complete: () => {
470
+ unblockForm( $nyp );
471
+ input.attr( 'disabled', false );
472
+ input.focus();
473
+ },
474
+ } );
475
+ }
476
+ if ( $nyp.length ) {
477
+ $nyp.on( 'submit', handleNYPFormSubmit );
478
+ }
479
+
480
+ /**
481
+ * Handle form 1st step submission.
482
+ *
483
+ * @param {Event} ev
484
+ */
485
+ function handleFormSubmit( ev ) {
486
+ ev.preventDefault();
487
+ ev.stopImmediatePropagation();
488
+ validateForm();
489
+ managePagination( 'continue' ); // TODOGA4: this is firing whether or not the form validates.
490
+ }
491
+
492
+ /**
493
+ * Set the checkout state as editing billing/shipping fields or not.
494
+ *
495
+ * @param {boolean} isEditingDetails
496
+ */
497
+ function setEditingDetails( isEditingDetails ) {
498
+ const newspack_grecaptcha = window.newspack_grecaptcha || {};
499
+ clearNotices();
500
+ // Clear checkout details.
501
+ $( '#checkout_details' ).remove();
502
+ if ( isEditingDetails ) {
503
+ $form.attr( 'data-skip-recaptcha', '1' );
504
+ $form.append( '<input name="is_validation_only" type="hidden" value="1" />' );
505
+ // Destroy reCAPTCHA inputs so we don't trigger validation between checkout steps.
506
+ if ( 'v3' === newspack_grecaptcha?.version ) {
507
+ newspack_grecaptcha.destroy( $form.get() );
508
+ }
509
+ if ( $coupon.length ) {
510
+ $coupon.hide();
511
+ }
512
+ if ( $nyp.length ) {
513
+ $nyp.hide();
514
+ }
515
+ $customer_details.show();
516
+ $after_customer_details.hide();
517
+ $customer_details.find( 'input' ).first().focus();
518
+ // Remove default form event handlers.
519
+ originalFormHandlers = getEventHandlers( $form[ 0 ], 'submit' ).slice( 0 );
520
+ originalFormHandlers.forEach( handler => {
521
+ $form.off( 'submit', handler.handler );
522
+ } );
523
+ $form.on( 'submit', handleFormSubmit );
524
+ } else {
525
+ $form.removeAttr( 'data-skip-recaptcha' );
526
+ const $validationOnlyField = $form.find( '[name="is_validation_only"]' );
527
+ if ( $validationOnlyField.length ) {
528
+ $validationOnlyField.remove();
529
+ }
530
+
531
+ // Initiate reCAPTCHA, if available.
532
+ if ( newspack_grecaptcha?.render ) {
533
+ $form.data( 'newspack-recaptcha', 'newspack_modal_checkout' );
534
+ const onSuccess = () => {
535
+ clearNotices();
536
+ $form.get( 0 ).scrollIntoView( { behavior: 'smooth' } );
537
+ };
538
+ const onError = error => handleFormError( error );
539
+ newspack_grecaptcha.render( $form.get(), onSuccess, onError );
540
+ // Refresh reCAPTCHAs on Woo checkout update and error.
541
+ $( document ).on( 'updated_checkout', () => newspack_grecaptcha.render( $form.get(), onSuccess, onError ) );
542
+ $( document.body ).on( 'checkout_error', () => newspack_grecaptcha.render( $form.get(), onSuccess, onError ) );
543
+ }
544
+ if ( $coupon.length ) {
545
+ $coupon.show();
546
+ }
547
+ if ( $nyp.length ) {
548
+ $nyp.show();
549
+ }
550
+ $customer_details.hide();
551
+ $after_customer_details.show();
552
+ renderCheckoutDetails();
553
+ // Store event handlers.
554
+ $form.off( 'submit', handleFormSubmit );
555
+ originalFormHandlers.forEach( handler => {
556
+ $form.on( 'submit', handler.handler );
557
+ } );
558
+
559
+ // Disable 'Place Order' button if Subscription Confirmation is required.
560
+ handleSubscriptionConfirmation();
561
+ }
562
+ $form.triggerHandler( 'editing_details', [ isEditingDetails ] );
563
+ // Scroll to top.
564
+ window.scroll( { top: 0, left: 0, behavior: 'smooth' } );
565
+ }
566
+
567
+ /**
568
+ * Render the checkout billing/shipping details summary HTML.
569
+ */
570
+ function renderCheckoutDetails() {
571
+ $( '#checkout_details' ).remove();
572
+ const data = {};
573
+ $form.serializeArray().forEach( item => {
574
+ data[ item.name ] = item.value;
575
+ } );
576
+
577
+ const classname = `${ newspackBlocksModalCheckout.newspack_class_prefix }__font--xs`;
578
+ const html = [];
579
+ html.push( '<div class="billing-details">' );
580
+ html.push( '<h3>' + newspackBlocksModalCheckout.labels.billing_details + '</h3>' );
581
+ if ( data.billing_first_name || data.billing_last_name ) {
582
+ html.push( `<p class="${ classname }">` + data.billing_first_name + ' ' + data.billing_last_name + '</p>' );
583
+ }
584
+ if ( data.billing_company ) {
585
+ html.push( `<p class="${ classname }">` + data.billing_company + '</p>' );
586
+ }
587
+ let billingAddress = '';
588
+ if ( data.billing_address_1 || data.billing_address_2 ) {
589
+ billingAddress = `<p class="${ classname }">`;
590
+ if ( data.billing_address_1 ) {
591
+ billingAddress += data.billing_address_1;
592
+ }
593
+ if ( data.billing_address_2 ) {
594
+ billingAddress += ' ' + data.billing_address_2;
595
+ }
596
+ billingAddress += '<br>';
597
+ if ( data.billing_city ) {
598
+ billingAddress += data.billing_city;
599
+ }
600
+ if ( data.billing_state ) {
601
+ billingAddress += ', ' + data.billing_state;
602
+ }
603
+ if ( data.billing_postcode ) {
604
+ billingAddress += ' ' + data.billing_postcode;
605
+ }
606
+ billingAddress += '<br>';
607
+ if ( data.billing_country ) {
608
+ billingAddress += data.billing_country;
609
+ }
610
+ }
611
+ html.push( billingAddress );
612
+ if ( data.billing_email ) {
613
+ html.push( `<p class="${ classname }">` + data.billing_email + '</p>' );
614
+ }
615
+ html.push( '</div>' ); // Close billing-details.
616
+
617
+ // Shipping details.
618
+ if ( data.hasOwnProperty( 'shipping_address_1' ) ) {
619
+ html.push( '<div class="shipping-details">' );
620
+ html.push( '<h3>' + newspackBlocksModalCheckout.labels.shipping_details + '</h3>' );
621
+ let shippingAddress = '';
622
+ if ( ! data.ship_to_different_address ) {
623
+ shippingAddress = billingAddress;
624
+ } else {
625
+ shippingAddress = `<p class="${ classname }">`;
626
+ if ( data.shipping_address_1 ) {
627
+ shippingAddress += data.shipping_address_1;
628
+ }
629
+ if ( data.shipping_address_2 ) {
630
+ shippingAddress += ' ' + data.shipping_address_2;
631
+ }
632
+ shippingAddress += '<br>';
633
+ if ( data.shipping_city ) {
634
+ shippingAddress += data.shipping_city;
635
+ }
636
+ if ( data.shipping_state ) {
637
+ shippingAddress += ', ' + data.shipping_state;
638
+ }
639
+ if ( data.shipping_postcode ) {
640
+ shippingAddress += ' ' + data.shipping_postcode;
641
+ }
642
+ shippingAddress += '<br>';
643
+ if ( data.shipping_country ) {
644
+ shippingAddress += data.shipping_country;
645
+ }
646
+ }
647
+ html.push( shippingAddress );
648
+ html.push( '</div>' ); // Close shipping-details.
649
+ }
650
+
651
+ // WCSG Gift details.
652
+ if ( data.hasOwnProperty( 'newspack_wcsg_is_gift' ) && data.hasOwnProperty( 'wcsg_gift_recipients_email' ) ) {
653
+ if ( !! data.newspack_wcsg_is_gift && !! data.wcsg_gift_recipients_email ) {
654
+ html.push( '<div class="gift-details">' );
655
+ html.push( '<h3>' + newspackBlocksModalCheckout.labels.gift_recipient + '</h3>' );
656
+ html.push( `<p class="${ classname }">` + data.wcsg_gift_recipients_email + '</p>' );
657
+ }
658
+ }
659
+
660
+ $( '.order-details-summary' ).after( '<div id="checkout_details">' + html.join( '' ) + '</div>' );
661
+ }
662
+
663
+ /**
664
+ * Validate the checkout form using Woo's "update_totals" ajax request.
665
+ *
666
+ * @param {boolean} silent Whether to show errors or not.
667
+ * @param {Function} cb Callback function.
668
+ */
669
+ function validateForm( silent = false, cb = () => {} ) {
670
+ const blocked = blockForm( $form );
671
+ if ( ! blocked ) {
672
+ console.warn( 'Unable to block the form' ); // eslint-disable-line no-console
673
+ cb();
674
+ return false;
675
+ }
676
+ clearNotices();
677
+
678
+ // Remove generic errors.
679
+ const $genericErrors = $form.find( '.woocommerce-NoticeGroup.woocommerce-NoticeGroup-checkout' );
680
+ if ( $genericErrors.length ) {
681
+ $genericErrors.remove();
682
+ }
683
+
684
+ const removeFromValidation = [ 'save_user_in_woopay' ];
685
+ // Serialize form and remove fields that shouldn't be included for validation.
686
+ const serializedForm = $form.serializeArray().filter( item => ! removeFromValidation.includes( item.name ) );
687
+ // Add 'update totals' parameter so it just performs validation.
688
+ serializedForm.push( { name: 'newspack_blocks_checkout_action', value: '1' } );
689
+ // Ajax request.
690
+ $.ajax( {
691
+ type: 'POST',
692
+ url: wc_checkout_params.checkout_url,
693
+ data: serializedForm,
694
+ dataType: 'html',
695
+ success: response => {
696
+ let result;
697
+ try {
698
+ result = JSON.parse( response );
699
+ } catch ( e ) {
700
+ result = {
701
+ messages: '<div class="woocommerce-error">' + wc_checkout_params.i18n_checkout_error + '</div>',
702
+ };
703
+ }
704
+
705
+ // Reload page
706
+ if ( ! silent && true === result.reload ) {
707
+ window.location.reload();
708
+ return;
709
+ }
710
+
711
+ unblockForm( $form );
712
+
713
+ // Result will always be 'failure' from the server. We'll check for
714
+ // 'messages' in the response to see if it was successful.
715
+ const success = ! result.messages;
716
+ if ( success ) {
717
+ setEditingDetails( false );
718
+ // If click #checkout_edit_billing event handler doesn't already exist add it to the form.
719
+ if ( ! $._data( $form[ 0 ], 'events' )?.click?.some( handler => handler.selector === '#checkout_edit_billing' ) ) {
720
+ $form.on( 'click', '#checkout_edit_billing', function ( ev ) {
721
+ ev.preventDefault();
722
+ setEditingDetails( true );
723
+ managePagination( 'back' );
724
+ } );
725
+ }
726
+ } else if ( ! silent ) {
727
+ if ( result.messages ) {
728
+ handleFormError( result.messages );
729
+ } else {
730
+ handleFormError(
731
+ `<div class="${ CLASS_PREFIX }__inline-error">` + wc_checkout_params.i18n_checkout_error + '</div>'
732
+ );
733
+ }
734
+ }
735
+ cb( result );
736
+ },
737
+ error: ( jqXHR, textStatus, errorThrown ) => {
738
+ let messages = '';
739
+ if ( ! silent ) {
740
+ messages = '<div class="woocommerce-error">' + ( errorThrown || wc_checkout_params.i18n_checkout_error ) + '</div>';
741
+ handleFormError( messages );
742
+ }
743
+ cb( { messages } );
744
+ },
745
+ } );
746
+ }
747
+
748
+ // Attach handler to "Place Order" button.
749
+ $form.on( 'click', '#place_order', function () {
750
+ manageCheckoutAttempt();
751
+ } );
752
+
753
+ /**
754
+ * Blocks provided form.
755
+ *
756
+ * @param {jQuery} form
757
+ *
758
+ * @return {boolean} Whether the form was blocked or not.
759
+ */
760
+ function blockForm( form ) {
761
+ if ( form.is( '.modal-processing' ) ) {
762
+ return false;
763
+ }
764
+ const buttons = form.find( 'button[type=submit]' );
765
+ buttons.each( ( i, el ) => {
766
+ $( el ).attr( 'disabled', true );
767
+ } );
768
+ form.addClass( 'modal-processing' );
769
+ return true;
770
+ }
771
+
772
+ /**
773
+ * Unblocks provided form.
774
+ *
775
+ * @param {jQuery} form
776
+ *
777
+ * @return {boolean} Whether the form was unblocked or not.
778
+ */
779
+ function unblockForm( form ) {
780
+ if ( ! form.is( '.modal-processing' ) ) {
781
+ return false;
782
+ }
783
+ const buttons = form.find( 'button[type=submit]' );
784
+ buttons.each( ( i, el ) => {
785
+ $( el ).attr( 'disabled', false );
786
+ } );
787
+ form.removeClass( 'modal-processing' );
788
+ return true;
789
+ }
790
+
791
+ /**
792
+ * Watch for Express Checkout errors added to the checkout container.
793
+ * Express Checkout (GPay/Apple Pay) uses the Store API which doesn't trigger
794
+ * the standard WooCommerce checkout_error event.
795
+ */
796
+ function observeExpressCheckoutErrors() {
797
+ if ( ! container ) {
798
+ return;
799
+ }
800
+
801
+ const ERROR_HANDLED_ATTR = 'data-newspack-error-handled';
802
+
803
+ const handleExpressCheckoutError = errorNode => {
804
+ if ( errorNode.hasAttribute( ERROR_HANDLED_ATTR ) ) {
805
+ return;
806
+ }
807
+ errorNode.setAttribute( ERROR_HANDLED_ATTR, 'true' );
808
+
809
+ $( errorNode ).addClass( `${ CLASS_PREFIX }__notice ${ CLASS_PREFIX }__notice--error` );
810
+ container.dispatchEvent( placeOrderErrorEvent );
811
+ errorNode.scrollIntoView( { behavior: 'smooth', block: 'center' } );
812
+ };
813
+
814
+ const isErrorNode = node => {
815
+ if ( node.classList?.contains( 'woocommerce-error' ) ) {
816
+ return true;
817
+ }
818
+ if ( node.classList?.contains( 'wc-block-components-notice-banner' ) && node.classList?.contains( 'is-error' ) ) {
819
+ return true;
820
+ }
821
+ return false;
822
+ };
823
+
824
+ const observer = new MutationObserver( mutations => {
825
+ for ( const mutation of mutations ) {
826
+ for ( const node of mutation.addedNodes ) {
827
+ if ( node.nodeType !== Node.ELEMENT_NODE ) {
828
+ continue;
829
+ }
830
+ if ( isErrorNode( node ) ) {
831
+ handleExpressCheckoutError( node );
832
+ return;
833
+ }
834
+ const nestedError = node.querySelector?.( '.woocommerce-error, .wc-block-components-notice-banner.is-error' );
835
+ if ( nestedError ) {
836
+ handleExpressCheckoutError( nestedError );
837
+ return;
838
+ }
839
+ }
840
+ }
841
+ } );
842
+
843
+ observer.observe( container, { childList: true, subtree: true } );
844
+ return observer;
845
+ }
846
+
847
+ const expressCheckoutErrorObserver = observeExpressCheckoutErrors();
848
+ if ( expressCheckoutErrorObserver ) {
849
+ const disconnect = () => expressCheckoutErrorObserver.disconnect();
850
+ container.addEventListener( 'checkout-complete', disconnect );
851
+ container.addEventListener( 'checkout-cancel', disconnect );
852
+ window.addEventListener( 'beforeunload', disconnect );
853
+ }
854
+ }
855
+ init();
856
+ }
857
+
858
+ /**
859
+ * Block form submission when Subscription Confirmation is required.
860
+ * This is enabled under Newspack > Audience > Configuration > Checkout & Payment, and only appears when there's a subscription product in the cart.
861
+ */
862
+ function handleSubscriptionConfirmation() {
863
+ const $subscription_confirmation = $( '#newspack_subscription_terms_confirmation, #newspack_subscription_confirmation' );
864
+ if ( $subscription_confirmation.length ) {
865
+ const $form = $( 'form.checkout' );
866
+ const $buttons = $form.find( 'button#place_order, button#place_order_clone' );
867
+
868
+ // Toggle button state based on checkbox.
869
+ function toggleButtonState() {
870
+ const isChecked = $subscription_confirmation.is( ':checked' );
871
+ $buttons.each( ( i, el ) => {
872
+ $( el ).attr( 'disabled', ! isChecked );
873
+ } );
874
+ }
875
+
876
+ // Initial state.
877
+ toggleButtonState();
878
+
879
+ // Watch for checkbox changes.
880
+ $subscription_confirmation.on( 'change', toggleButtonState );
881
+
882
+ // Prevent form submission if the Subscription Confirmation or Terms & Conditions checkbox is not checked.
883
+ $form.on( 'submit', function ( e ) {
884
+ if ( ! $subscription_confirmation.is( ':checked' ) ) {
885
+ e.preventDefault();
886
+ e.stopPropagation();
887
+ return false;
888
+ }
889
+ } );
890
+ }
891
+ }
892
+ // Listen to various WooCommerce events.
893
+ $( document.body ).on( 'updated_checkout payment_method_selected checkout_error', handleSubscriptionConfirmation );
894
+ // Also handle initial load.
895
+ $( document ).ready( handleSubscriptionConfirmation );
896
+
897
+ /**
898
+ * Handle modal checkout error events.
899
+ */
900
+ $( document.body ).on( 'checkout_error', function () {
901
+ // Apply newspack styling to default Woo checkout errors.
902
+ const $errors = $( '.woocommerce-NoticeGroup-checkout, .woocommerce-notices-wrapper:not(:empty)' );
903
+ if ( $errors.length ) {
904
+ $errors.each( ( _, error ) => $( error ).addClass( `${ CLASS_PREFIX }__notice ${ CLASS_PREFIX }__notice--error` ) );
905
+ }
906
+ // Handle "Back" button click.
907
+ const $checkout_error_back = $( '#checkout_error_back' );
908
+ if ( $checkout_error_back.length ) {
909
+ $checkout_error_back.on( 'click', ev => {
910
+ ev.preventDefault();
911
+ parent.newspackCloseModalCheckout();
912
+ } );
913
+ }
914
+ // Trigger ready state.
915
+ setReady( false );
916
+ } );
917
+
918
+ // Close modal when 'Esc' key is pressed and focus is inside of the iframe.
919
+ document.addEventListener( 'keydown', function ( ev ) {
920
+ if ( ev.key === 'Escape' ) {
921
+ parent.newspackCloseModalCheckout();
922
+ }
923
+ } );
924
+
925
+ if ( newspackBlocksModalCheckout.is_error ) {
926
+ $( document.body ).trigger( 'checkout_error' );
927
+ }
928
+ } );
929
+ } )( jQuery );