@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.
- package/.eslintrc.js +3 -0
- package/.hooks/pre-push +8 -0
- package/.nvmrc +1 -0
- package/.prettierignore +4 -0
- package/.prettierrc.js +5 -0
- package/.stylelintrc.js +3 -0
- package/AGENTS.md +275 -0
- package/CHANGELOG.md +3971 -0
- package/CLAUDE.md +1 -0
- package/README.md +43 -0
- package/babel.config.js +6 -0
- package/bin/install-wp-tests.sh +155 -0
- package/bin/update-translations.sh +13 -0
- package/block-list.json +12 -0
- package/composer.json +46 -0
- package/composer.lock +3632 -0
- package/dist/author-list/view-rtl.css +1 -0
- package/dist/author-list/view.asset.php +1 -0
- package/dist/author-list/view.css +1 -0
- package/dist/author-list/view.js +0 -0
- package/dist/author-profile/view-rtl.css +1 -0
- package/dist/author-profile/view.asset.php +1 -0
- package/dist/author-profile/view.css +1 -0
- package/dist/author-profile/view.js +0 -0
- package/dist/block_styles-rtl.css +2 -0
- package/dist/block_styles.asset.php +1 -0
- package/dist/block_styles.css +2 -0
- package/dist/block_styles.js +0 -0
- package/dist/blocks/author-list/block.json +89 -0
- package/dist/blocks/author-profile/block.json +80 -0
- package/dist/blocks/carousel/block.json +125 -0
- package/dist/blocks/checkout-button/block.json +117 -0
- package/dist/blocks/donate/block.json +103 -0
- package/dist/blocks/homepage-articles/block.json +260 -0
- package/dist/blocks/iframe/block.json +36 -0
- package/dist/carousel/view-rtl.css +2 -0
- package/dist/carousel/view.asset.php +1 -0
- package/dist/carousel/view.css +2 -0
- package/dist/carousel/view.js +3 -0
- package/dist/checkout-button/view-rtl.css +1 -0
- package/dist/checkout-button/view.asset.php +1 -0
- package/dist/checkout-button/view.css +1 -0
- package/dist/checkout-button/view.js +0 -0
- package/dist/donate/view-rtl.css +1 -0
- package/dist/donate/view.asset.php +1 -0
- package/dist/donate/view.css +1 -0
- package/dist/donate/view.js +1 -0
- package/dist/editor-rtl.css +66 -0
- package/dist/editor.asset.php +1 -0
- package/dist/editor.css +66 -0
- package/dist/editor.js +57 -0
- package/dist/frequencyBased-rtl.css +1 -0
- package/dist/frequencyBased.asset.php +1 -0
- package/dist/frequencyBased.css +1 -0
- package/dist/frequencyBased.js +1 -0
- package/dist/homepage-articles/view-rtl.css +1 -0
- package/dist/homepage-articles/view.asset.php +1 -0
- package/dist/homepage-articles/view.css +1 -0
- package/dist/homepage-articles/view.js +1 -0
- package/dist/iframe/view-rtl.css +1 -0
- package/dist/iframe/view.asset.php +1 -0
- package/dist/iframe/view.css +1 -0
- package/dist/iframe/view.js +1 -0
- package/dist/modal-rtl.css +1 -0
- package/dist/modal.asset.php +1 -0
- package/dist/modal.css +1 -0
- package/dist/modal.js +1 -0
- package/dist/modalCheckout-rtl.css +1 -0
- package/dist/modalCheckout.asset.php +1 -0
- package/dist/modalCheckout.css +1 -0
- package/dist/modalCheckout.js +1 -0
- package/dist/placeholder_blocks.asset.php +1 -0
- package/dist/placeholder_blocks.js +4 -0
- package/dist/tiersBased-rtl.css +1 -0
- package/dist/tiersBased.asset.php +1 -0
- package/dist/tiersBased.css +1 -0
- package/dist/tiersBased.js +1 -0
- package/includes/class-modal-checkout.php +2324 -0
- package/includes/class-newspack-blocks-api.php +347 -0
- package/includes/class-newspack-blocks-caching.php +291 -0
- package/includes/class-newspack-blocks-patterns.php +167 -0
- package/includes/class-newspack-blocks.php +1581 -0
- package/includes/modal-checkout/class-change-payment-gateway.php +86 -0
- package/includes/modal-checkout/class-checkout-data.php +406 -0
- package/includes/plugins/class-the-events-calendar.php +84 -0
- package/includes/tracking/class-data-events.php +83 -0
- package/languages/newspack-blocks-de_DE-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
- package/languages/newspack-blocks-de_DE-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
- package/languages/newspack-blocks-de_DE-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
- package/languages/newspack-blocks-de_DE-10754bc02d28d4301c103f26dbf519ce.json +1 -0
- package/languages/newspack-blocks-de_DE-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
- package/languages/newspack-blocks-de_DE-34e5c64f90b1444f3fc735376442eada.json +1 -0
- package/languages/newspack-blocks-de_DE-351fd022e077061b5796bf7042446bfc.json +1 -0
- package/languages/newspack-blocks-de_DE-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
- package/languages/newspack-blocks-de_DE-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
- package/languages/newspack-blocks-de_DE-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
- package/languages/newspack-blocks-de_DE-4f16e21047908d19937bc10ced63acd1.json +1 -0
- package/languages/newspack-blocks-de_DE-4fdea541976076f02d56139fb35e5b42.json +1 -0
- package/languages/newspack-blocks-de_DE-501b38ac90d35730a620fb0d483702fa.json +1 -0
- package/languages/newspack-blocks-de_DE-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
- package/languages/newspack-blocks-de_DE-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
- package/languages/newspack-blocks-de_DE-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
- package/languages/newspack-blocks-de_DE-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
- package/languages/newspack-blocks-de_DE-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
- package/languages/newspack-blocks-de_DE-727631509ad8eec8e2cbe740c6dad199.json +1 -0
- package/languages/newspack-blocks-de_DE-73c6d3bde805172d1993f75397e9832d.json +1 -0
- package/languages/newspack-blocks-de_DE-78456b164809d080adecb4d2b3895802.json +1 -0
- package/languages/newspack-blocks-de_DE-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
- package/languages/newspack-blocks-de_DE-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
- package/languages/newspack-blocks-de_DE-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
- package/languages/newspack-blocks-de_DE-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
- package/languages/newspack-blocks-de_DE-969286d51bb0afe10983b9aec317b5ee.json +1 -0
- package/languages/newspack-blocks-de_DE-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
- package/languages/newspack-blocks-de_DE-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
- package/languages/newspack-blocks-de_DE-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
- package/languages/newspack-blocks-de_DE-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
- package/languages/newspack-blocks-de_DE-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
- package/languages/newspack-blocks-de_DE-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
- package/languages/newspack-blocks-de_DE-bb66d96d450663284550bed5a3e9113e.json +1 -0
- package/languages/newspack-blocks-de_DE-c810378e74f20906b8193ea76adb6bc0.json +1 -0
- package/languages/newspack-blocks-de_DE-d3a1c55a07efd1a65e227bf120840752.json +1 -0
- package/languages/newspack-blocks-de_DE-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
- package/languages/newspack-blocks-de_DE-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
- package/languages/newspack-blocks-de_DE-dd56360b115d1b39c48033c1e0749a11.json +1 -0
- package/languages/newspack-blocks-de_DE-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
- package/languages/newspack-blocks-de_DE-e58126c278611ed6c17684ba8e7459b4.json +1 -0
- package/languages/newspack-blocks-de_DE-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
- package/languages/newspack-blocks-de_DE-eccbc51a43c04f59165364eda71e0be7.json +1 -0
- package/languages/newspack-blocks-de_DE-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
- package/languages/newspack-blocks-de_DE-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
- package/languages/newspack-blocks-de_DE-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
- package/languages/newspack-blocks-de_DE-f5f8db76788e4079ddfa743333708b88.json +1 -0
- package/languages/newspack-blocks-de_DE-f8b1589c450689398f90b179f47e74ee.json +1 -0
- package/languages/newspack-blocks-de_DE-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
- package/languages/newspack-blocks-de_DE-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
- package/languages/newspack-blocks-de_DE-fcc93143c1f2b74671f595454b971f44.json +1 -0
- package/languages/newspack-blocks-de_DE.mo +0 -0
- package/languages/newspack-blocks-de_DE.po +2088 -0
- package/languages/newspack-blocks-es_ES-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
- package/languages/newspack-blocks-es_ES-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
- package/languages/newspack-blocks-es_ES-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
- package/languages/newspack-blocks-es_ES-10754bc02d28d4301c103f26dbf519ce.json +1 -0
- package/languages/newspack-blocks-es_ES-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
- package/languages/newspack-blocks-es_ES-34e5c64f90b1444f3fc735376442eada.json +1 -0
- package/languages/newspack-blocks-es_ES-351fd022e077061b5796bf7042446bfc.json +1 -0
- package/languages/newspack-blocks-es_ES-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
- package/languages/newspack-blocks-es_ES-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
- package/languages/newspack-blocks-es_ES-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
- package/languages/newspack-blocks-es_ES-4f16e21047908d19937bc10ced63acd1.json +1 -0
- package/languages/newspack-blocks-es_ES-4fdea541976076f02d56139fb35e5b42.json +1 -0
- package/languages/newspack-blocks-es_ES-501b38ac90d35730a620fb0d483702fa.json +1 -0
- package/languages/newspack-blocks-es_ES-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
- package/languages/newspack-blocks-es_ES-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
- package/languages/newspack-blocks-es_ES-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
- package/languages/newspack-blocks-es_ES-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
- package/languages/newspack-blocks-es_ES-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
- package/languages/newspack-blocks-es_ES-727631509ad8eec8e2cbe740c6dad199.json +1 -0
- package/languages/newspack-blocks-es_ES-73c6d3bde805172d1993f75397e9832d.json +1 -0
- package/languages/newspack-blocks-es_ES-78456b164809d080adecb4d2b3895802.json +1 -0
- package/languages/newspack-blocks-es_ES-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
- package/languages/newspack-blocks-es_ES-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
- package/languages/newspack-blocks-es_ES-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
- package/languages/newspack-blocks-es_ES-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
- package/languages/newspack-blocks-es_ES-969286d51bb0afe10983b9aec317b5ee.json +1 -0
- package/languages/newspack-blocks-es_ES-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
- package/languages/newspack-blocks-es_ES-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
- package/languages/newspack-blocks-es_ES-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
- package/languages/newspack-blocks-es_ES-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
- package/languages/newspack-blocks-es_ES-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
- package/languages/newspack-blocks-es_ES-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
- package/languages/newspack-blocks-es_ES-bb66d96d450663284550bed5a3e9113e.json +1 -0
- package/languages/newspack-blocks-es_ES-c810378e74f20906b8193ea76adb6bc0.json +1 -0
- package/languages/newspack-blocks-es_ES-d3a1c55a07efd1a65e227bf120840752.json +1 -0
- package/languages/newspack-blocks-es_ES-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
- package/languages/newspack-blocks-es_ES-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
- package/languages/newspack-blocks-es_ES-dd56360b115d1b39c48033c1e0749a11.json +1 -0
- package/languages/newspack-blocks-es_ES-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
- package/languages/newspack-blocks-es_ES-e58126c278611ed6c17684ba8e7459b4.json +1 -0
- package/languages/newspack-blocks-es_ES-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
- package/languages/newspack-blocks-es_ES-eccbc51a43c04f59165364eda71e0be7.json +1 -0
- package/languages/newspack-blocks-es_ES-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
- package/languages/newspack-blocks-es_ES-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
- package/languages/newspack-blocks-es_ES-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
- package/languages/newspack-blocks-es_ES-f5f8db76788e4079ddfa743333708b88.json +1 -0
- package/languages/newspack-blocks-es_ES-f8b1589c450689398f90b179f47e74ee.json +1 -0
- package/languages/newspack-blocks-es_ES-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
- package/languages/newspack-blocks-es_ES-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
- package/languages/newspack-blocks-es_ES-fcc93143c1f2b74671f595454b971f44.json +1 -0
- package/languages/newspack-blocks-es_ES.mo +0 -0
- package/languages/newspack-blocks-es_ES.po +2080 -0
- package/languages/newspack-blocks-fr_BE-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
- package/languages/newspack-blocks-fr_BE-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
- package/languages/newspack-blocks-fr_BE-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
- package/languages/newspack-blocks-fr_BE-10754bc02d28d4301c103f26dbf519ce.json +1 -0
- package/languages/newspack-blocks-fr_BE-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
- package/languages/newspack-blocks-fr_BE-34e5c64f90b1444f3fc735376442eada.json +1 -0
- package/languages/newspack-blocks-fr_BE-351fd022e077061b5796bf7042446bfc.json +1 -0
- package/languages/newspack-blocks-fr_BE-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
- package/languages/newspack-blocks-fr_BE-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
- package/languages/newspack-blocks-fr_BE-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
- package/languages/newspack-blocks-fr_BE-4f16e21047908d19937bc10ced63acd1.json +1 -0
- package/languages/newspack-blocks-fr_BE-4fdea541976076f02d56139fb35e5b42.json +1 -0
- package/languages/newspack-blocks-fr_BE-501b38ac90d35730a620fb0d483702fa.json +1 -0
- package/languages/newspack-blocks-fr_BE-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
- package/languages/newspack-blocks-fr_BE-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
- package/languages/newspack-blocks-fr_BE-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
- package/languages/newspack-blocks-fr_BE-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
- package/languages/newspack-blocks-fr_BE-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
- package/languages/newspack-blocks-fr_BE-727631509ad8eec8e2cbe740c6dad199.json +1 -0
- package/languages/newspack-blocks-fr_BE-73c6d3bde805172d1993f75397e9832d.json +1 -0
- package/languages/newspack-blocks-fr_BE-78456b164809d080adecb4d2b3895802.json +1 -0
- package/languages/newspack-blocks-fr_BE-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
- package/languages/newspack-blocks-fr_BE-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
- package/languages/newspack-blocks-fr_BE-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
- package/languages/newspack-blocks-fr_BE-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
- package/languages/newspack-blocks-fr_BE-969286d51bb0afe10983b9aec317b5ee.json +1 -0
- package/languages/newspack-blocks-fr_BE-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
- package/languages/newspack-blocks-fr_BE-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
- package/languages/newspack-blocks-fr_BE-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
- package/languages/newspack-blocks-fr_BE-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
- package/languages/newspack-blocks-fr_BE-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
- package/languages/newspack-blocks-fr_BE-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
- package/languages/newspack-blocks-fr_BE-bb66d96d450663284550bed5a3e9113e.json +1 -0
- package/languages/newspack-blocks-fr_BE-c810378e74f20906b8193ea76adb6bc0.json +1 -0
- package/languages/newspack-blocks-fr_BE-d3a1c55a07efd1a65e227bf120840752.json +1 -0
- package/languages/newspack-blocks-fr_BE-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
- package/languages/newspack-blocks-fr_BE-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
- package/languages/newspack-blocks-fr_BE-dd56360b115d1b39c48033c1e0749a11.json +1 -0
- package/languages/newspack-blocks-fr_BE-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
- package/languages/newspack-blocks-fr_BE-e58126c278611ed6c17684ba8e7459b4.json +1 -0
- package/languages/newspack-blocks-fr_BE-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
- package/languages/newspack-blocks-fr_BE-eccbc51a43c04f59165364eda71e0be7.json +1 -0
- package/languages/newspack-blocks-fr_BE-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
- package/languages/newspack-blocks-fr_BE-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
- package/languages/newspack-blocks-fr_BE-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
- package/languages/newspack-blocks-fr_BE-f5f8db76788e4079ddfa743333708b88.json +1 -0
- package/languages/newspack-blocks-fr_BE-f8b1589c450689398f90b179f47e74ee.json +1 -0
- package/languages/newspack-blocks-fr_BE-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
- package/languages/newspack-blocks-fr_BE-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
- package/languages/newspack-blocks-fr_BE-fcc93143c1f2b74671f595454b971f44.json +1 -0
- package/languages/newspack-blocks-fr_BE.mo +0 -0
- package/languages/newspack-blocks-fr_BE.po +2079 -0
- package/languages/newspack-blocks-nb_NO-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
- package/languages/newspack-blocks-nb_NO-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
- package/languages/newspack-blocks-nb_NO-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
- package/languages/newspack-blocks-nb_NO-10754bc02d28d4301c103f26dbf519ce.json +1 -0
- package/languages/newspack-blocks-nb_NO-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
- package/languages/newspack-blocks-nb_NO-34e5c64f90b1444f3fc735376442eada.json +1 -0
- package/languages/newspack-blocks-nb_NO-351fd022e077061b5796bf7042446bfc.json +1 -0
- package/languages/newspack-blocks-nb_NO-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
- package/languages/newspack-blocks-nb_NO-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
- package/languages/newspack-blocks-nb_NO-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
- package/languages/newspack-blocks-nb_NO-4f16e21047908d19937bc10ced63acd1.json +1 -0
- package/languages/newspack-blocks-nb_NO-4fdea541976076f02d56139fb35e5b42.json +1 -0
- package/languages/newspack-blocks-nb_NO-501b38ac90d35730a620fb0d483702fa.json +1 -0
- package/languages/newspack-blocks-nb_NO-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
- package/languages/newspack-blocks-nb_NO-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
- package/languages/newspack-blocks-nb_NO-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
- package/languages/newspack-blocks-nb_NO-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
- package/languages/newspack-blocks-nb_NO-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
- package/languages/newspack-blocks-nb_NO-73c6d3bde805172d1993f75397e9832d.json +1 -0
- package/languages/newspack-blocks-nb_NO-78456b164809d080adecb4d2b3895802.json +1 -0
- package/languages/newspack-blocks-nb_NO-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
- package/languages/newspack-blocks-nb_NO-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
- package/languages/newspack-blocks-nb_NO-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
- package/languages/newspack-blocks-nb_NO-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
- package/languages/newspack-blocks-nb_NO-969286d51bb0afe10983b9aec317b5ee.json +1 -0
- package/languages/newspack-blocks-nb_NO-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
- package/languages/newspack-blocks-nb_NO-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
- package/languages/newspack-blocks-nb_NO-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
- package/languages/newspack-blocks-nb_NO-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
- package/languages/newspack-blocks-nb_NO-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
- package/languages/newspack-blocks-nb_NO-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
- package/languages/newspack-blocks-nb_NO-bb66d96d450663284550bed5a3e9113e.json +1 -0
- package/languages/newspack-blocks-nb_NO-c810378e74f20906b8193ea76adb6bc0.json +1 -0
- package/languages/newspack-blocks-nb_NO-d3a1c55a07efd1a65e227bf120840752.json +1 -0
- package/languages/newspack-blocks-nb_NO-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
- package/languages/newspack-blocks-nb_NO-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
- package/languages/newspack-blocks-nb_NO-dd56360b115d1b39c48033c1e0749a11.json +1 -0
- package/languages/newspack-blocks-nb_NO-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
- package/languages/newspack-blocks-nb_NO-e58126c278611ed6c17684ba8e7459b4.json +1 -0
- package/languages/newspack-blocks-nb_NO-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
- package/languages/newspack-blocks-nb_NO-eccbc51a43c04f59165364eda71e0be7.json +1 -0
- package/languages/newspack-blocks-nb_NO-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
- package/languages/newspack-blocks-nb_NO-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
- package/languages/newspack-blocks-nb_NO-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
- package/languages/newspack-blocks-nb_NO-f5f8db76788e4079ddfa743333708b88.json +1 -0
- package/languages/newspack-blocks-nb_NO-f8b1589c450689398f90b179f47e74ee.json +1 -0
- package/languages/newspack-blocks-nb_NO-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
- package/languages/newspack-blocks-nb_NO-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
- package/languages/newspack-blocks-nb_NO-fcc93143c1f2b74671f595454b971f44.json +1 -0
- package/languages/newspack-blocks-nb_NO.mo +0 -0
- package/languages/newspack-blocks-nb_NO.po +2078 -0
- package/languages/newspack-blocks-pt_PT-01a5b44b8bc8d20f62541de420aa61ab.json +1 -0
- package/languages/newspack-blocks-pt_PT-0662222bf15e7a1a7b74db2dabb48d6c.json +1 -0
- package/languages/newspack-blocks-pt_PT-0c8dad524e2a57cee4f8efb6e35387c1.json +1 -0
- package/languages/newspack-blocks-pt_PT-10754bc02d28d4301c103f26dbf519ce.json +1 -0
- package/languages/newspack-blocks-pt_PT-2d52b39fdbc5d6c94b3514803f3720b8.json +1 -0
- package/languages/newspack-blocks-pt_PT-34e5c64f90b1444f3fc735376442eada.json +1 -0
- package/languages/newspack-blocks-pt_PT-351fd022e077061b5796bf7042446bfc.json +1 -0
- package/languages/newspack-blocks-pt_PT-37552bb09e2a9fceec1970e3c6d46557.json +1 -0
- package/languages/newspack-blocks-pt_PT-4b2ccb4e4dc8b3491228b2feb54872f2.json +1 -0
- package/languages/newspack-blocks-pt_PT-4cecf783e091d36284a3e0cdafcd0fd5.json +1 -0
- package/languages/newspack-blocks-pt_PT-4f16e21047908d19937bc10ced63acd1.json +1 -0
- package/languages/newspack-blocks-pt_PT-4fdea541976076f02d56139fb35e5b42.json +1 -0
- package/languages/newspack-blocks-pt_PT-501b38ac90d35730a620fb0d483702fa.json +1 -0
- package/languages/newspack-blocks-pt_PT-53e2a1d5945b8d2b1c35e81ae1e532f3.json +1 -0
- package/languages/newspack-blocks-pt_PT-5d4055f484eeb00e3ea0f9d8aace0897.json +1 -0
- package/languages/newspack-blocks-pt_PT-5f70538e0223bc8a05b922cba67da6fb.json +1 -0
- package/languages/newspack-blocks-pt_PT-6c2e53bab28419c30e1eaee70ba599cf.json +1 -0
- package/languages/newspack-blocks-pt_PT-6ed95fb4873e6e2b81351177a44995f6.json +1 -0
- package/languages/newspack-blocks-pt_PT-727631509ad8eec8e2cbe740c6dad199.json +1 -0
- package/languages/newspack-blocks-pt_PT-73c6d3bde805172d1993f75397e9832d.json +1 -0
- package/languages/newspack-blocks-pt_PT-78456b164809d080adecb4d2b3895802.json +1 -0
- package/languages/newspack-blocks-pt_PT-7b1aa64ce2d962decc04666ab86c53de.json +1 -0
- package/languages/newspack-blocks-pt_PT-7c29764d5ef91723f5ce454f66431b9e.json +1 -0
- package/languages/newspack-blocks-pt_PT-912a2876091ef0dca9b26f3cfc01fc9c.json +1 -0
- package/languages/newspack-blocks-pt_PT-91a7ac8017d6e2159be1c5a3c1e372e4.json +1 -0
- package/languages/newspack-blocks-pt_PT-969286d51bb0afe10983b9aec317b5ee.json +1 -0
- package/languages/newspack-blocks-pt_PT-9ef9b2c60c897ad79f92951e6e9949a1.json +1 -0
- package/languages/newspack-blocks-pt_PT-a822c3d210c89af3cb7da28eaaef929c.json +1 -0
- package/languages/newspack-blocks-pt_PT-aa9f9057c77a46b31d7e325a4322f2da.json +1 -0
- package/languages/newspack-blocks-pt_PT-b6d3cfc30bb16d88d7bc5384bc775543.json +1 -0
- package/languages/newspack-blocks-pt_PT-b712270cd4eb3cae7899b50b57bdd576.json +1 -0
- package/languages/newspack-blocks-pt_PT-babcc0ca24e7f0145b1c8f647049f085.json +1 -0
- package/languages/newspack-blocks-pt_PT-bb66d96d450663284550bed5a3e9113e.json +1 -0
- package/languages/newspack-blocks-pt_PT-c810378e74f20906b8193ea76adb6bc0.json +1 -0
- package/languages/newspack-blocks-pt_PT-d3a1c55a07efd1a65e227bf120840752.json +1 -0
- package/languages/newspack-blocks-pt_PT-d5f23a52ecbfd492ebf819c14206a9e2.json +1 -0
- package/languages/newspack-blocks-pt_PT-d684e5c5ac51934ba20811c2f588e1d5.json +1 -0
- package/languages/newspack-blocks-pt_PT-dd56360b115d1b39c48033c1e0749a11.json +1 -0
- package/languages/newspack-blocks-pt_PT-e0e4434aee4db01e71268ce3edf1dd97.json +1 -0
- package/languages/newspack-blocks-pt_PT-e58126c278611ed6c17684ba8e7459b4.json +1 -0
- package/languages/newspack-blocks-pt_PT-ea3e2a660753c7bfa13b5bbd8a46bdd0.json +1 -0
- package/languages/newspack-blocks-pt_PT-eccbc51a43c04f59165364eda71e0be7.json +1 -0
- package/languages/newspack-blocks-pt_PT-eeb28f99adedd5fad3081d2756d6f4a4.json +1 -0
- package/languages/newspack-blocks-pt_PT-f03802d9ac1ae8f3b85caee4347b93a7.json +1 -0
- package/languages/newspack-blocks-pt_PT-f32a4d8bd8f1f1e03b6523dfaa4c9f73.json +1 -0
- package/languages/newspack-blocks-pt_PT-f5f8db76788e4079ddfa743333708b88.json +1 -0
- package/languages/newspack-blocks-pt_PT-f8b1589c450689398f90b179f47e74ee.json +1 -0
- package/languages/newspack-blocks-pt_PT-f9d0b05d4d6ddd3273f1f3fb2eb2ca50.json +1 -0
- package/languages/newspack-blocks-pt_PT-fbe7f8c598cf05d4603ba49fec909ded.json +1 -0
- package/languages/newspack-blocks-pt_PT-fcc93143c1f2b74671f595454b971f44.json +1 -0
- package/languages/newspack-blocks-pt_PT.mo +0 -0
- package/languages/newspack-blocks-pt_PT.po +2078 -0
- package/languages/newspack-blocks.pot +2370 -0
- package/newspack-blocks.php +96 -0
- package/package.json +64 -0
- package/phpcs.xml +38 -0
- package/release.config.js +1 -0
- package/src/assets/placeholder-1024x536.jpg +0 -0
- package/src/assets/placeholder-600x800.jpg +0 -0
- package/src/assets/placeholder-800x600.jpg +0 -0
- package/src/assets/placeholder-800x800.jpg +0 -0
- package/src/assets/placeholder-donations-cover.jpg +0 -0
- package/src/assets/placeholder-donations-image.jpg +0 -0
- package/src/assets/placeholder-subscribe-cover.jpg +0 -0
- package/src/assets/placeholder-subscribe-image.jpg +0 -0
- package/src/block-patterns/donations-1.php +13 -0
- package/src/block-patterns/donations-2.php +13 -0
- package/src/block-patterns/donations-3.php +13 -0
- package/src/block-patterns/donations-4.php +13 -0
- package/src/block-patterns/donations-5.php +13 -0
- package/src/block-patterns/homepage-posts-1.php +13 -0
- package/src/block-patterns/homepage-posts-10.php +13 -0
- package/src/block-patterns/homepage-posts-11.php +13 -0
- package/src/block-patterns/homepage-posts-12.php +13 -0
- package/src/block-patterns/homepage-posts-13.php +13 -0
- package/src/block-patterns/homepage-posts-14.php +13 -0
- package/src/block-patterns/homepage-posts-15.php +13 -0
- package/src/block-patterns/homepage-posts-16.php +13 -0
- package/src/block-patterns/homepage-posts-17.php +13 -0
- package/src/block-patterns/homepage-posts-18.php +13 -0
- package/src/block-patterns/homepage-posts-19.php +13 -0
- package/src/block-patterns/homepage-posts-2.php +13 -0
- package/src/block-patterns/homepage-posts-20.php +13 -0
- package/src/block-patterns/homepage-posts-21.php +13 -0
- package/src/block-patterns/homepage-posts-22.php +13 -0
- package/src/block-patterns/homepage-posts-23.php +13 -0
- package/src/block-patterns/homepage-posts-24.php +13 -0
- package/src/block-patterns/homepage-posts-25.php +13 -0
- package/src/block-patterns/homepage-posts-26.php +13 -0
- package/src/block-patterns/homepage-posts-27.php +13 -0
- package/src/block-patterns/homepage-posts-28.php +13 -0
- package/src/block-patterns/homepage-posts-29.php +13 -0
- package/src/block-patterns/homepage-posts-3.php +13 -0
- package/src/block-patterns/homepage-posts-30.php +13 -0
- package/src/block-patterns/homepage-posts-31.php +13 -0
- package/src/block-patterns/homepage-posts-4.php +13 -0
- package/src/block-patterns/homepage-posts-5.php +13 -0
- package/src/block-patterns/homepage-posts-6.php +13 -0
- package/src/block-patterns/homepage-posts-7.php +13 -0
- package/src/block-patterns/homepage-posts-8.php +13 -0
- package/src/block-patterns/homepage-posts-9.php +13 -0
- package/src/block-patterns/subscribe-1.php +13 -0
- package/src/block-patterns/subscribe-2.php +13 -0
- package/src/block-patterns/subscribe-3.php +13 -0
- package/src/block-patterns/subscribe-4.php +13 -0
- package/src/block-patterns/subscribe-5.php +13 -0
- package/src/block-patterns/subscribe-6.php +13 -0
- package/src/block-patterns/subscribe-7.php +13 -0
- package/src/block-styles/core/columns/editor.scss +90 -0
- package/src/block-styles/core/columns/index.js +20 -0
- package/src/block-styles/core/columns/view.scss +131 -0
- package/src/block-styles/core/group/editor.scss +24 -0
- package/src/block-styles/core/group/index.js +25 -0
- package/src/block-styles/core/group/view.scss +13 -0
- package/src/block-styles/view.js +5 -0
- package/src/blocks/author-list/block.json +84 -0
- package/src/blocks/author-list/class-wp-rest-newspack-author-list-controller.php +381 -0
- package/src/blocks/author-list/edit.js +456 -0
- package/src/blocks/author-list/editor.js +7 -0
- package/src/blocks/author-list/editor.scss +1 -0
- package/src/blocks/author-list/index.js +60 -0
- package/src/blocks/author-list/view.js +5 -0
- package/src/blocks/author-list/view.php +180 -0
- package/src/blocks/author-list/view.scss +46 -0
- package/src/blocks/author-profile/README.md +105 -0
- package/src/blocks/author-profile/block.json +77 -0
- package/src/blocks/author-profile/class-wp-rest-newspack-authors-controller.php +618 -0
- package/src/blocks/author-profile/context.js +26 -0
- package/src/blocks/author-profile/edit.js +1031 -0
- package/src/blocks/author-profile/editor.js +7 -0
- package/src/blocks/author-profile/editor.scss +61 -0
- package/src/blocks/author-profile/index.js +66 -0
- package/src/blocks/author-profile/single-author.js +106 -0
- package/src/blocks/author-profile/templates.js +263 -0
- package/src/blocks/author-profile/variations.js +86 -0
- package/src/blocks/author-profile/view.js +5 -0
- package/src/blocks/author-profile/view.php +501 -0
- package/src/blocks/author-profile/view.scss +159 -0
- package/src/blocks/carousel/block.json +121 -0
- package/src/blocks/carousel/create-swiper.js +230 -0
- package/src/blocks/carousel/edit.js +469 -0
- package/src/blocks/carousel/editor.js +7 -0
- package/src/blocks/carousel/editor.scss +54 -0
- package/src/blocks/carousel/index.js +55 -0
- package/src/blocks/carousel/view.js +49 -0
- package/src/blocks/carousel/view.php +417 -0
- package/src/blocks/carousel/view.scss +397 -0
- package/src/blocks/checkout-button/block.json +117 -0
- package/src/blocks/checkout-button/deprecated.js +81 -0
- package/src/blocks/checkout-button/edit.js +385 -0
- package/src/blocks/checkout-button/edit.scss +67 -0
- package/src/blocks/checkout-button/editor.js +19 -0
- package/src/blocks/checkout-button/index.js +32 -0
- package/src/blocks/checkout-button/view.js +4 -0
- package/src/blocks/checkout-button/view.php +178 -0
- package/src/blocks/checkout-button/view.scss +39 -0
- package/src/blocks/donate/block.json +103 -0
- package/src/blocks/donate/consts.ts +25 -0
- package/src/blocks/donate/edit/FrequencyBasedLayout.tsx +255 -0
- package/src/blocks/donate/edit/TierBasedLayout.tsx +133 -0
- package/src/blocks/donate/edit/components/AmountValueInput.tsx +62 -0
- package/src/blocks/donate/edit/components/index.tsx +1 -0
- package/src/blocks/donate/edit/index.tsx +445 -0
- package/src/blocks/donate/editor.js +7 -0
- package/src/blocks/donate/frequency-based/index.ts +135 -0
- package/src/blocks/donate/frequency-based/style.scss +245 -0
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-base.php +225 -0
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-frequency-based.php +341 -0
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-tiers-based.php +184 -0
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer.php +117 -0
- package/src/blocks/donate/index.js +72 -0
- package/src/blocks/donate/styles/editor.scss +230 -0
- package/src/blocks/donate/styles/style-variations.scss +792 -0
- package/src/blocks/donate/styles/view.scss +45 -0
- package/src/blocks/donate/tiers-based/index.ts +36 -0
- package/src/blocks/donate/tiers-based/slider.ts +64 -0
- package/src/blocks/donate/tiers-based/style.scss +185 -0
- package/src/blocks/donate/tiers-based/types.ts +3 -0
- package/src/blocks/donate/tiers-based/utils.test.js +38 -0
- package/src/blocks/donate/tiers-based/utils.ts +21 -0
- package/src/blocks/donate/tiers-based/view.ts +132 -0
- package/src/blocks/donate/types.ts +96 -0
- package/src/blocks/donate/utils.ts +108 -0
- package/src/blocks/donate/view.php +29 -0
- package/src/blocks/donate/view.ts +44 -0
- package/src/blocks/homepage-articles/block.json +260 -0
- package/src/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php +231 -0
- package/src/blocks/homepage-articles/edit.tsx +730 -0
- package/src/blocks/homepage-articles/editor.js +16 -0
- package/src/blocks/homepage-articles/editor.scss +226 -0
- package/src/blocks/homepage-articles/index.js +102 -0
- package/src/blocks/homepage-articles/store.js +193 -0
- package/src/blocks/homepage-articles/templates/article.php +290 -0
- package/src/blocks/homepage-articles/templates/articles-list.php +21 -0
- package/src/blocks/homepage-articles/templates/articles-loop.php +35 -0
- package/src/blocks/homepage-articles/utils.ts +270 -0
- package/src/blocks/homepage-articles/view.js +242 -0
- package/src/blocks/homepage-articles/view.php +561 -0
- package/src/blocks/homepage-articles/view.scss +784 -0
- package/src/blocks/iframe/block.json +36 -0
- package/src/blocks/iframe/class-wp-rest-newspack-iframe-controller.php +586 -0
- package/src/blocks/iframe/edit.js +232 -0
- package/src/blocks/iframe/editor.js +7 -0
- package/src/blocks/iframe/editor.scss +84 -0
- package/src/blocks/iframe/iframe-placeholder.js +166 -0
- package/src/blocks/iframe/index.js +54 -0
- package/src/blocks/iframe/view.js +49 -0
- package/src/blocks/iframe/view.php +116 -0
- package/src/blocks/iframe/view.scss +9 -0
- package/src/blocks/shared/author.js +47 -0
- package/src/blocks/video-playlist/edit.js +222 -0
- package/src/blocks/video-playlist/editor.js +7 -0
- package/src/blocks/video-playlist/editor.scss +23 -0
- package/src/blocks/video-playlist/index.js +54 -0
- package/src/blocks/video-playlist/view.php +188 -0
- package/src/components/autocomplete-tokenfield.js +189 -0
- package/src/components/autocomplete-tokenfield.scss +27 -0
- package/src/components/editor-panels.js +90 -0
- package/src/components/query-controls.js +450 -0
- package/src/components/redirect-after-success.tsx +50 -0
- package/src/modal-checkout/accessibility.js +73 -0
- package/src/modal-checkout/analytics/ga4/README.md +45 -0
- package/src/modal-checkout/analytics/ga4/checkout-attempt.js +18 -0
- package/src/modal-checkout/analytics/ga4/checkout-success.js +17 -0
- package/src/modal-checkout/analytics/ga4/dismissed.js +17 -0
- package/src/modal-checkout/analytics/ga4/loaded.js +17 -0
- package/src/modal-checkout/analytics/ga4/opened.js +37 -0
- package/src/modal-checkout/analytics/ga4/pagination.js +59 -0
- package/src/modal-checkout/analytics/ga4/utils/index.js +64 -0
- package/src/modal-checkout/analytics/index.js +6 -0
- package/src/modal-checkout/checkout.scss +1064 -0
- package/src/modal-checkout/index.js +929 -0
- package/src/modal-checkout/modal.js +983 -0
- package/src/modal-checkout/modal.scss +265 -0
- package/src/modal-checkout/templates/empty-html-add-recipient.php +15 -0
- package/src/modal-checkout/templates/empty-order-details.php +16 -0
- package/src/modal-checkout/templates/form-change-payment-method.php +99 -0
- package/src/modal-checkout/templates/form-checkout.php +74 -0
- package/src/modal-checkout/templates/form-coupon.php +22 -0
- package/src/modal-checkout/templates/form-gift-subscription.php +34 -0
- package/src/modal-checkout/templates/payment-method.php +29 -0
- package/src/modal-checkout/templates/thankyou.php +94 -0
- package/src/modal-checkout/utils.js +309 -0
- package/src/setup/block-styles.js +2 -0
- package/src/setup/category.js +18 -0
- package/src/setup/editor.js +7 -0
- package/src/setup/editor.scss +56 -0
- package/src/setup/newspack-logo.js +26 -0
- package/src/setup/placeholder-blocks.js +84 -0
- package/src/setup/unregister-blocks.js +14 -0
- package/src/shared/authors.php +63 -0
- package/src/shared/js/newspack-icon.js +31 -0
- package/src/shared/js/utils.js +50 -0
- package/src/shared/sass/_mixins.scss +42 -0
- package/src/shared/sass/_placeholder.scss +5 -0
- package/src/shared/sass/_preview.scss +12 -0
- package/src/shared/sass/_variables.scss +24 -0
- package/src/templates/author-profile-card.php +145 -0
- package/src/types/@wordpress/block-editor.d.ts +1 -0
- package/src/types/@wordpress/components.d.ts +1 -0
- package/src/types/index.d.ts +170 -0
- package/src/types/newspack-components.d.ts +7 -0
- package/tsconfig.json +7 -0
- package/vendor/autoload.php +22 -0
- package/vendor/composer/ClassLoader.php +579 -0
- package/vendor/composer/InstalledVersions.php +396 -0
- package/vendor/composer/LICENSE +21 -0
- package/vendor/composer/autoload_classmap.php +10 -0
- package/vendor/composer/autoload_namespaces.php +9 -0
- package/vendor/composer/autoload_psr4.php +9 -0
- package/vendor/composer/autoload_real.php +36 -0
- package/vendor/composer/autoload_static.php +20 -0
- package/vendor/composer/installed.json +5 -0
- package/vendor/composer/installed.php +23 -0
- package/webpack.config.js +82 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { hooks } from 'newspack-components';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
11
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
12
|
+
import { useState, useEffect, Fragment } from '@wordpress/element';
|
|
13
|
+
import {
|
|
14
|
+
CheckboxControl,
|
|
15
|
+
PanelBody,
|
|
16
|
+
ExternalLink,
|
|
17
|
+
Placeholder,
|
|
18
|
+
Spinner,
|
|
19
|
+
SelectControl,
|
|
20
|
+
ToggleControl,
|
|
21
|
+
Toolbar,
|
|
22
|
+
TextControl,
|
|
23
|
+
Button,
|
|
24
|
+
Notice,
|
|
25
|
+
} from '@wordpress/components';
|
|
26
|
+
import { BlockControls, ColorPaletteControl, InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
|
27
|
+
import { isEmpty, pick } from 'lodash';
|
|
28
|
+
import { Icon, formatListBullets, grid } from '@wordpress/icons';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Internal dependencies
|
|
32
|
+
*/
|
|
33
|
+
import { getMigratedAmount } from '../utils';
|
|
34
|
+
import type { DonationSettings, DonationFrequencySlug, DonationAmountsArray, EditState, EditProps } from '../types';
|
|
35
|
+
import TierBasedLayout from './TierBasedLayout';
|
|
36
|
+
import FrequencyBasedLayout from './FrequencyBasedLayout';
|
|
37
|
+
import { AmountValueInput } from './components';
|
|
38
|
+
import { FREQUENCIES, FREQUENCY_SLUGS, LAYOUT_OPTIONS, DISABLED_IN_TIERS_BASED_LAYOUT_TIER_INDEX } from '../consts';
|
|
39
|
+
import RedirectAfterSuccess from '../../../components/redirect-after-success';
|
|
40
|
+
|
|
41
|
+
const TIER_LABELS = [ __( 'Low-tier', 'newspack-blocks' ), __( 'Mid-tier', 'newspack-blocks' ), __( 'High-tier', 'newspack-blocks' ) ];
|
|
42
|
+
|
|
43
|
+
const Edit = ( { attributes, setAttributes }: EditProps ) => {
|
|
44
|
+
const [ isLoading, setIsLoading ] = useState( true );
|
|
45
|
+
const [ error, setError ] = useState( '' );
|
|
46
|
+
|
|
47
|
+
const [ settings, setSettings ] = hooks.useObjectState< EditState >( {
|
|
48
|
+
amounts: {},
|
|
49
|
+
currencySymbol: '$',
|
|
50
|
+
tiered: false,
|
|
51
|
+
disabledFrequencies: {},
|
|
52
|
+
minimumDonation: 5,
|
|
53
|
+
platform: '',
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
interface AudienceDonations {
|
|
57
|
+
donation_data: DonationSettings;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
useEffect( () => {
|
|
61
|
+
apiFetch< AudienceDonations >( {
|
|
62
|
+
path: '/newspack/v1/wizard/newspack-audience-donations',
|
|
63
|
+
} )
|
|
64
|
+
.then( ( { donation_data: donationSettings }: AudienceDonations ) => {
|
|
65
|
+
setSettings( {
|
|
66
|
+
amounts: donationSettings.amounts,
|
|
67
|
+
currencySymbol: donationSettings.currencySymbol,
|
|
68
|
+
tiered: donationSettings.tiered,
|
|
69
|
+
disabledFrequencies: donationSettings.disabledFrequencies,
|
|
70
|
+
minimumDonation: donationSettings.minimumDonation,
|
|
71
|
+
platform: donationSettings.platform,
|
|
72
|
+
} );
|
|
73
|
+
|
|
74
|
+
if ( isEmpty( attributes.disabledFrequencies ) ) {
|
|
75
|
+
setAttributes( { disabledFrequencies: donationSettings.disabledFrequencies } );
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if ( isEmpty( attributes.minimumDonation ) ) {
|
|
79
|
+
setAttributes( { minimumDonation: donationSettings.minimumDonation } );
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Migrate old attributes.
|
|
83
|
+
if ( isEmpty( attributes.amounts ) && attributes.suggestedAmounts && attributes.suggestedAmounts.length ) {
|
|
84
|
+
const untieredAmount = attributes.suggestedAmountUntiered || donationSettings.amounts.month[ 3 ];
|
|
85
|
+
setAttributes( {
|
|
86
|
+
suggestedAmounts: undefined,
|
|
87
|
+
suggestedAmountUntiered: undefined,
|
|
88
|
+
amounts: {
|
|
89
|
+
once: getMigratedAmount( 'once', attributes.suggestedAmounts, untieredAmount ),
|
|
90
|
+
month: getMigratedAmount( 'month', attributes.suggestedAmounts, untieredAmount ),
|
|
91
|
+
year: getMigratedAmount( 'year', attributes.suggestedAmounts, untieredAmount ),
|
|
92
|
+
},
|
|
93
|
+
} );
|
|
94
|
+
} else {
|
|
95
|
+
setAttributes( { amounts: { ...donationSettings.amounts, ...attributes.amounts } } );
|
|
96
|
+
}
|
|
97
|
+
} )
|
|
98
|
+
.catch( setError )
|
|
99
|
+
.finally( () => setIsLoading( false ) );
|
|
100
|
+
}, [] );
|
|
101
|
+
|
|
102
|
+
const blockProps = useBlockProps();
|
|
103
|
+
if ( error.length ) {
|
|
104
|
+
return (
|
|
105
|
+
<div { ...blockProps }>
|
|
106
|
+
<Placeholder icon="warning" label={ __( 'Error', 'newspack-blocks' ) } instructions={ error }>
|
|
107
|
+
<ExternalLink href="/wp-admin/admin.php?page=newspack-audience#/payment">
|
|
108
|
+
{ __( 'Go to checkout & payment settings to troubleshoot.', 'newspack-blocks' ) }
|
|
109
|
+
</ExternalLink>
|
|
110
|
+
</Placeholder>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if ( settings.platform === 'other' ) {
|
|
116
|
+
return (
|
|
117
|
+
<div { ...blockProps }>
|
|
118
|
+
<Placeholder
|
|
119
|
+
icon="warning"
|
|
120
|
+
label={ __( 'The Donate block will not be rendered.', 'newspack-blocks' ) }
|
|
121
|
+
instructions={ __( 'The Reader Revenue platform is set to "other".', 'newspack-blocks' ) }
|
|
122
|
+
>
|
|
123
|
+
<ExternalLink href="/wp-admin/admin.php?page=newspack-audience#/payment">
|
|
124
|
+
{ __( 'Go to checkout & payment settings to update the platform.', 'newspack-blocks' ) }
|
|
125
|
+
</ExternalLink>
|
|
126
|
+
</Placeholder>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if ( isLoading ) {
|
|
132
|
+
return (
|
|
133
|
+
<div { ...blockProps }>
|
|
134
|
+
<Placeholder icon={ <Spinner /> } className="component-placeholder__align-center" />
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const canUseNameYourPrice = window?.newspack_blocks_data?.can_use_name_your_price;
|
|
140
|
+
const isManual = attributes.manual && canUseNameYourPrice;
|
|
141
|
+
const isTiered = isManual ? attributes.tiered : settings.tiered;
|
|
142
|
+
const isTierBasedLayoutEnabled = isTiered && attributes.layoutOption === 'tiers';
|
|
143
|
+
const tierLayoutStyle = attributes.tierStyle;
|
|
144
|
+
const hasRecaptcha = window?.newspack_blocks_data?.has_recaptcha;
|
|
145
|
+
const supportsRecaptcha = window?.newspack_blocks_data?.supports_recaptcha;
|
|
146
|
+
const recaptchaURL = window?.newspack_blocks_data?.recaptcha_url || '';
|
|
147
|
+
|
|
148
|
+
const amounts = isManual ? attributes.amounts : settings.amounts;
|
|
149
|
+
|
|
150
|
+
const availableFrequencies = FREQUENCY_SLUGS.filter( slug =>
|
|
151
|
+
isManual ? ! attributes.disabledFrequencies[ slug ] : ! settings.disabledFrequencies[ slug ]
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
let className = attributes?.className || '';
|
|
155
|
+
// Editor bug – initially, the default style is selected, but the class not applied.
|
|
156
|
+
if ( className.indexOf( 'is-style' ) === -1 ) {
|
|
157
|
+
className += ' is-style-default';
|
|
158
|
+
}
|
|
159
|
+
if ( ! canUseNameYourPrice ) {
|
|
160
|
+
className += ' wpbnbd--nyp-disabled';
|
|
161
|
+
}
|
|
162
|
+
const getWrapperClassNames = ( classes: string[] = [] ) =>
|
|
163
|
+
classNames(
|
|
164
|
+
classes,
|
|
165
|
+
className,
|
|
166
|
+
'wpbnbd',
|
|
167
|
+
`wpbnbd--${ isTierBasedLayoutEnabled ? 'tiers-based' : 'frequency-based' }`,
|
|
168
|
+
`wpbnbd--platform-${ settings.platform }`,
|
|
169
|
+
`wpbnbd-frequencies--${ availableFrequencies.length }`,
|
|
170
|
+
isTierBasedLayoutEnabled && `wpbnbd--tier-style-${ tierLayoutStyle }`
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const tiersLayoutControls = [
|
|
174
|
+
{
|
|
175
|
+
icon: <Icon icon={ grid } />,
|
|
176
|
+
title: __( 'Grid View', 'newspack-blocks' ),
|
|
177
|
+
onClick: () => setAttributes( { tierStyle: 'grid' } ),
|
|
178
|
+
isActive: attributes.tierStyle === 'grid',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
icon: <Icon icon={ formatListBullets } />,
|
|
182
|
+
title: __( 'List View', 'newspack-blocks' ),
|
|
183
|
+
onClick: () => setAttributes( { tierStyle: 'list' } ),
|
|
184
|
+
isActive: attributes.tierStyle === 'list',
|
|
185
|
+
},
|
|
186
|
+
];
|
|
187
|
+
|
|
188
|
+
const minimumDonation = isManual ? attributes.minimumDonation : settings.minimumDonation;
|
|
189
|
+
const displayedAmounts = { ...amounts };
|
|
190
|
+
Object.keys( amounts ).forEach( frequency => {
|
|
191
|
+
const amountsWithMinimum = amounts[ frequency ].map( amount => Math.max( amount, minimumDonation ) ) as DonationAmountsArray;
|
|
192
|
+
displayedAmounts[ frequency ] = amountsWithMinimum;
|
|
193
|
+
} );
|
|
194
|
+
|
|
195
|
+
const componentProps = {
|
|
196
|
+
attributes,
|
|
197
|
+
amounts,
|
|
198
|
+
availableFrequencies,
|
|
199
|
+
settings,
|
|
200
|
+
setAttributes,
|
|
201
|
+
setSettings,
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const renderMinAmountWarning = () => (
|
|
205
|
+
<p className="components-frequency-donations__error">
|
|
206
|
+
{ sprintf(
|
|
207
|
+
// translators: %1$s: currency symbol, %2$d: minimum donation amount.
|
|
208
|
+
__( 'Warning: suggested donations should be at least the minimum donation amount (%1$s%2$d).', 'newspack-blocks' ),
|
|
209
|
+
settings.currencySymbol,
|
|
210
|
+
minimumDonation
|
|
211
|
+
) }
|
|
212
|
+
</p>
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<Fragment>
|
|
217
|
+
<InspectorControls>
|
|
218
|
+
<PanelBody title={ __( 'Layout', 'newspack-blocks' ) }>
|
|
219
|
+
{ canUseNameYourPrice && (
|
|
220
|
+
<div className="newspack-blocks-donate__layout-selector">
|
|
221
|
+
{ LAYOUT_OPTIONS.map( ( { label, key } ) => {
|
|
222
|
+
const isSelected = key === 'tiers' ? isTierBasedLayoutEnabled : ! isTierBasedLayoutEnabled;
|
|
223
|
+
return (
|
|
224
|
+
<Button
|
|
225
|
+
key={ key }
|
|
226
|
+
variant={ isSelected ? 'primary' : 'secondary' }
|
|
227
|
+
isPressed={ isSelected }
|
|
228
|
+
onClick={ () => setAttributes( { layoutOption: key } ) }
|
|
229
|
+
aria-current={ isSelected }
|
|
230
|
+
disabled={ key === 'tiers' && ! isTiered }
|
|
231
|
+
>
|
|
232
|
+
{ label }
|
|
233
|
+
</Button>
|
|
234
|
+
);
|
|
235
|
+
} ) }
|
|
236
|
+
</div>
|
|
237
|
+
) }
|
|
238
|
+
{ canUseNameYourPrice && ! isTiered && (
|
|
239
|
+
<Notice isDismissible={ false } className="newspack-blocks-donate__notice">
|
|
240
|
+
{ __( 'Tiers layout is disabled if the block is set to render untiered.', 'newspack-blocks' ) }
|
|
241
|
+
</Notice>
|
|
242
|
+
) }
|
|
243
|
+
<SelectControl
|
|
244
|
+
label={ __( 'Default Tab', 'newspack-blocks' ) }
|
|
245
|
+
value={ attributes.defaultFrequency }
|
|
246
|
+
options={ availableFrequencies.map( key => ( {
|
|
247
|
+
label: FREQUENCIES[ key ],
|
|
248
|
+
value: key,
|
|
249
|
+
} ) ) }
|
|
250
|
+
onChange={ ( defaultFrequency: DonationFrequencySlug ) => setAttributes( { defaultFrequency } ) }
|
|
251
|
+
/>
|
|
252
|
+
</PanelBody>
|
|
253
|
+
{ canUseNameYourPrice && (
|
|
254
|
+
<PanelBody title={ __( 'Suggested Donations', 'newspack-blocks' ) }>
|
|
255
|
+
<ToggleControl
|
|
256
|
+
checked={ Boolean( isManual ) }
|
|
257
|
+
onChange={ () => setAttributes( { manual: ! attributes.manual } ) }
|
|
258
|
+
label={ __( 'Configure manually', 'newspack-blocks' ) }
|
|
259
|
+
/>
|
|
260
|
+
{ isManual ? (
|
|
261
|
+
<>
|
|
262
|
+
<ToggleControl
|
|
263
|
+
checked={ Boolean( isTiered ) }
|
|
264
|
+
onChange={ () => setAttributes( { tiered: ! attributes.tiered } ) }
|
|
265
|
+
label={ __( 'Tiered', 'newspack-blocks' ) }
|
|
266
|
+
/>
|
|
267
|
+
{ isTiered ? (
|
|
268
|
+
<>
|
|
269
|
+
<div className="components-frequency-donations">
|
|
270
|
+
{ FREQUENCY_SLUGS.map( ( frequency: DonationFrequencySlug ) => {
|
|
271
|
+
const isFrequencyDisabled = attributes.disabledFrequencies[ frequency ];
|
|
272
|
+
const disabledDisplayedFrequencyCount = Object.values(
|
|
273
|
+
pick( attributes.disabledFrequencies, FREQUENCY_SLUGS )
|
|
274
|
+
).filter( Boolean ).length;
|
|
275
|
+
const isOnlyOneFrequencyActive = FREQUENCY_SLUGS.length - disabledDisplayedFrequencyCount === 1;
|
|
276
|
+
return (
|
|
277
|
+
<Fragment key={ frequency }>
|
|
278
|
+
<CheckboxControl
|
|
279
|
+
label={ FREQUENCIES[ frequency ] }
|
|
280
|
+
checked={ ! isFrequencyDisabled }
|
|
281
|
+
disabled={ ! isFrequencyDisabled && isOnlyOneFrequencyActive }
|
|
282
|
+
onChange={ () => {
|
|
283
|
+
setAttributes( {
|
|
284
|
+
disabledFrequencies: {
|
|
285
|
+
...attributes.disabledFrequencies,
|
|
286
|
+
[ frequency ]: ! isFrequencyDisabled,
|
|
287
|
+
},
|
|
288
|
+
} );
|
|
289
|
+
} }
|
|
290
|
+
/>
|
|
291
|
+
{ ! isFrequencyDisabled && (
|
|
292
|
+
<div className="wp-block-newspack-blocks-donate__panel-inputs">
|
|
293
|
+
{ amounts[ frequency ].reduce(
|
|
294
|
+
( acc: boolean, suggestedAmount: number ) =>
|
|
295
|
+
! suggestedAmount || suggestedAmount < minimumDonation ? true : acc,
|
|
296
|
+
false
|
|
297
|
+
) && renderMinAmountWarning() }
|
|
298
|
+
|
|
299
|
+
{ amounts[ frequency ].map( ( suggestedAmount, tierIndex ) => {
|
|
300
|
+
// The "Other" tier is no longer customizable and should always render empty for tiered layout.
|
|
301
|
+
if ( tierIndex === 3 ) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
return (
|
|
305
|
+
<AmountValueInput
|
|
306
|
+
ignoreMinimumAmount
|
|
307
|
+
{ ...componentProps }
|
|
308
|
+
key={ `amount-${ frequency }-${ tierIndex }` }
|
|
309
|
+
frequencySlug={ frequency }
|
|
310
|
+
tierIndex={ tierIndex }
|
|
311
|
+
label={ TIER_LABELS[ tierIndex ] }
|
|
312
|
+
id={ `${ frequency }-${ tierIndex }-amount` }
|
|
313
|
+
disabled={
|
|
314
|
+
isTierBasedLayoutEnabled &&
|
|
315
|
+
tierIndex === DISABLED_IN_TIERS_BASED_LAYOUT_TIER_INDEX
|
|
316
|
+
}
|
|
317
|
+
/>
|
|
318
|
+
);
|
|
319
|
+
} ) }
|
|
320
|
+
</div>
|
|
321
|
+
) }
|
|
322
|
+
</Fragment>
|
|
323
|
+
);
|
|
324
|
+
} ) }
|
|
325
|
+
</div>
|
|
326
|
+
</>
|
|
327
|
+
) : (
|
|
328
|
+
<div className="components-frequency-donations">
|
|
329
|
+
<div className="wp-block-newspack-blocks-donate__panel-inputs">
|
|
330
|
+
{ FREQUENCY_SLUGS.reduce(
|
|
331
|
+
( acc: boolean, frequencySlug: DonationFrequencySlug ) =>
|
|
332
|
+
! amounts[ frequencySlug ][ 3 ] || amounts[ frequencySlug ][ 3 ] < attributes.minimumDonation
|
|
333
|
+
? true
|
|
334
|
+
: acc,
|
|
335
|
+
false
|
|
336
|
+
) && renderMinAmountWarning() }
|
|
337
|
+
|
|
338
|
+
{ FREQUENCY_SLUGS.map( ( frequencySlug: DonationFrequencySlug ) => (
|
|
339
|
+
<AmountValueInput
|
|
340
|
+
ignoreMinimumAmount
|
|
341
|
+
{ ...componentProps }
|
|
342
|
+
key={ frequencySlug }
|
|
343
|
+
frequencySlug={ frequencySlug }
|
|
344
|
+
tierIndex={ 3 }
|
|
345
|
+
label={ FREQUENCIES[ frequencySlug ] }
|
|
346
|
+
id={ `${ frequencySlug }-${ 3 }-amount` }
|
|
347
|
+
/>
|
|
348
|
+
) ) }
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
) }
|
|
352
|
+
<TextControl
|
|
353
|
+
className="components-frequency-donations__minimum-donation"
|
|
354
|
+
type="number"
|
|
355
|
+
label={ __( 'Minimum donation', 'newspack-blocks' ) }
|
|
356
|
+
min={ 1 }
|
|
357
|
+
onChange={ ( value: number ) => setAttributes( { minimumDonation: value } ) }
|
|
358
|
+
value={ attributes.minimumDonation }
|
|
359
|
+
/>
|
|
360
|
+
</>
|
|
361
|
+
) : (
|
|
362
|
+
<p>
|
|
363
|
+
{ __(
|
|
364
|
+
'The Donate Block allows you to collect donations from readers. The fields are automatically defined based on your donation settings.',
|
|
365
|
+
'newspack-blocks'
|
|
366
|
+
) }
|
|
367
|
+
<br />
|
|
368
|
+
<br />
|
|
369
|
+
<ExternalLink href="/wp-admin/admin.php?page=newspack-audience-donations">
|
|
370
|
+
{ __( 'Edit donation settings', 'newspack-blocks' ) }
|
|
371
|
+
</ExternalLink>
|
|
372
|
+
</p>
|
|
373
|
+
) }
|
|
374
|
+
</PanelBody>
|
|
375
|
+
) }
|
|
376
|
+
<PanelBody title={ __( 'Styling', 'newspack-blocks' ) } initialOpen={ false }>
|
|
377
|
+
<ColorPaletteControl
|
|
378
|
+
value={ attributes.buttonColor }
|
|
379
|
+
onChange={ ( buttonColor: string ) => setAttributes( { buttonColor } ) }
|
|
380
|
+
label={ __( 'Button Color', 'newspack-blocks' ) }
|
|
381
|
+
/>
|
|
382
|
+
</PanelBody>
|
|
383
|
+
{ settings.platform === 'nrh' && (
|
|
384
|
+
<PanelBody title={ __( 'News Revenue Hub Settings', 'newspack-blocks' ) } initialOpen={ false }>
|
|
385
|
+
<TextControl
|
|
386
|
+
label={ __( 'Campaign ID', 'newspack-blocks' ) }
|
|
387
|
+
value={ attributes.campaign || '' }
|
|
388
|
+
onChange={ ( value: string ) =>
|
|
389
|
+
setAttributes( {
|
|
390
|
+
campaign: value,
|
|
391
|
+
} )
|
|
392
|
+
}
|
|
393
|
+
/>
|
|
394
|
+
</PanelBody>
|
|
395
|
+
) }
|
|
396
|
+
{ supportsRecaptcha && (
|
|
397
|
+
<PanelBody title={ __( 'Spam protection', 'newspack' ) }>
|
|
398
|
+
<p>
|
|
399
|
+
{ sprintf(
|
|
400
|
+
// translators: %s is either 'enabled' or 'disabled'.
|
|
401
|
+
__( 'reCAPTCHA is currently %s.', 'newspack' ),
|
|
402
|
+
hasRecaptcha ? __( 'enabled', 'newspack' ) : __( 'disabled', 'newspack' )
|
|
403
|
+
) }
|
|
404
|
+
</p>
|
|
405
|
+
{ ! hasRecaptcha && (
|
|
406
|
+
<p>
|
|
407
|
+
{ __(
|
|
408
|
+
"It's highly recommended that you enable reCAPTCHA protection to prevent spambots from using this form!",
|
|
409
|
+
'newspack'
|
|
410
|
+
) }
|
|
411
|
+
</p>
|
|
412
|
+
) }
|
|
413
|
+
<p>
|
|
414
|
+
<a href={ recaptchaURL }>{ __( 'Configure your reCAPTCHA settings.', 'newspack' ) }</a>
|
|
415
|
+
</p>
|
|
416
|
+
</PanelBody>
|
|
417
|
+
) }
|
|
418
|
+
<PanelBody title={ __( 'After purchase', 'newspack-blocks' ) }>
|
|
419
|
+
<RedirectAfterSuccess setAttributes={ setAttributes } attributes={ attributes } />
|
|
420
|
+
</PanelBody>
|
|
421
|
+
</InspectorControls>
|
|
422
|
+
{ isTierBasedLayoutEnabled && (
|
|
423
|
+
<BlockControls>
|
|
424
|
+
<Toolbar controls={ tiersLayoutControls } />
|
|
425
|
+
</BlockControls>
|
|
426
|
+
) }
|
|
427
|
+
{ isTierBasedLayoutEnabled ? (
|
|
428
|
+
<div { ...blockProps } className={ classNames( blockProps.className, getWrapperClassNames() ) }>
|
|
429
|
+
<TierBasedLayout { ...componentProps } amounts={ displayedAmounts } />
|
|
430
|
+
</div>
|
|
431
|
+
) : (
|
|
432
|
+
<div { ...blockProps } className={ classNames( blockProps.className, getWrapperClassNames( [ isTiered ? 'tiered' : 'untiered' ] ) ) }>
|
|
433
|
+
<FrequencyBasedLayout
|
|
434
|
+
isTiered={ isTiered }
|
|
435
|
+
canUseNameYourPrice={ canUseNameYourPrice }
|
|
436
|
+
amounts={ displayedAmounts }
|
|
437
|
+
{ ...componentProps }
|
|
438
|
+
/>
|
|
439
|
+
</div>
|
|
440
|
+
) }
|
|
441
|
+
</Fragment>
|
|
442
|
+
);
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
export default Edit;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import './style.scss';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Specify a function to execute when the DOM is fully loaded.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/WordPress/gutenberg/blob/trunk/packages/dom-ready/
|
|
10
|
+
*
|
|
11
|
+
* @param {Function} callback A function to execute after the DOM is ready.
|
|
12
|
+
* @return {void}
|
|
13
|
+
*/
|
|
14
|
+
function domReady( callback: () => void ): void {
|
|
15
|
+
if ( typeof document === 'undefined' ) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (
|
|
19
|
+
document.readyState === 'complete' || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly.
|
|
20
|
+
document.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.
|
|
21
|
+
) {
|
|
22
|
+
return void callback();
|
|
23
|
+
}
|
|
24
|
+
// DOMContentLoaded has not fired yet, delay callback until then.
|
|
25
|
+
document.addEventListener( 'DOMContentLoaded', callback );
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const handleOtherValue = ( container: HTMLElement ) => {
|
|
29
|
+
const frequencies = container.querySelectorAll( '.tiers' );
|
|
30
|
+
if ( ! frequencies?.length ) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const frequencyInputs = container.querySelectorAll( 'input[name="donation_frequency"]' );
|
|
34
|
+
const submitButton = container.querySelector( 'button[type="submit"]' );
|
|
35
|
+
frequencies.forEach( frequency => {
|
|
36
|
+
const tiers = frequency.querySelectorAll( 'input[type="radio"]' );
|
|
37
|
+
const input = < HTMLInputElement >frequency.querySelector( '.money-input input' );
|
|
38
|
+
if ( ! tiers?.length || ! input ) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const originalValue = input.getAttribute( 'value' );
|
|
42
|
+
const reset = () => {
|
|
43
|
+
input.value = originalValue || '';
|
|
44
|
+
};
|
|
45
|
+
const toggleSubmit = () => {
|
|
46
|
+
const checkedTier = < HTMLInputElement >frequency.querySelector( 'input[type="radio"]:checked' );
|
|
47
|
+
if ( ! checkedTier ) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if ( checkedTier.value === 'other' && ! input.value ) {
|
|
51
|
+
submitButton?.setAttribute( 'disabled', 'disabled' );
|
|
52
|
+
} else {
|
|
53
|
+
submitButton?.removeAttribute( 'disabled' );
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
input.addEventListener( 'keyup', toggleSubmit );
|
|
57
|
+
toggleSubmit();
|
|
58
|
+
tiers.forEach( tierInput => {
|
|
59
|
+
tierInput.addEventListener( 'change', reset );
|
|
60
|
+
tierInput.addEventListener( 'change', toggleSubmit );
|
|
61
|
+
} );
|
|
62
|
+
frequencyInputs.forEach( frequencyInput => {
|
|
63
|
+
frequencyInput.addEventListener( 'change', reset );
|
|
64
|
+
frequencyInput.addEventListener( 'change', toggleSubmit );
|
|
65
|
+
} );
|
|
66
|
+
} );
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const addAccessibleTabs = ( container: HTMLElement ) => {
|
|
70
|
+
// Get the block's tabs, panels, and radio buttons associated with donation frequency.
|
|
71
|
+
const tabList = container.querySelectorAll( 'div[role="tablist"] [role="tab"]' ) as NodeListOf< HTMLElement >;
|
|
72
|
+
const panels = container.querySelectorAll( 'div[role="tabpanel"]' ) as NodeListOf< HTMLElement >;
|
|
73
|
+
const radioButtons = container.querySelectorAll( 'input[type="radio"][name="donation_frequency"]' ) as NodeListOf< HTMLInputElement >;
|
|
74
|
+
// Figure out which radio button is currently selected.
|
|
75
|
+
const checkedRadioId = Array.from( radioButtons ).find( ( radio: HTMLInputElement ) => radio.checked )?.id || null;
|
|
76
|
+
|
|
77
|
+
// Set the tab associated to the radio button to selected.
|
|
78
|
+
if ( checkedRadioId ) {
|
|
79
|
+
const selectedTabId = `tab-${ checkedRadioId }`;
|
|
80
|
+
document.getElementById( selectedTabId )?.setAttribute( 'aria-selected', 'true' );
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Add a click event listener to each tab.
|
|
84
|
+
tabList.forEach( ( tab: HTMLElement ) => {
|
|
85
|
+
tab.addEventListener( 'click', function () {
|
|
86
|
+
selectTab( tab, tabList, radioButtons, panels );
|
|
87
|
+
} );
|
|
88
|
+
} );
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const selectTab = (
|
|
92
|
+
tab: HTMLElement,
|
|
93
|
+
tabList: NodeListOf< HTMLElement >,
|
|
94
|
+
radioButtons: NodeListOf< HTMLInputElement >,
|
|
95
|
+
panels: NodeListOf< HTMLElement >
|
|
96
|
+
) => {
|
|
97
|
+
// Loop through tabs and set them as selected or not selected:
|
|
98
|
+
tabList.forEach( ( thisTab: HTMLElement ) => {
|
|
99
|
+
if ( tab === thisTab ) {
|
|
100
|
+
thisTab.setAttribute( 'aria-selected', 'true' );
|
|
101
|
+
thisTab.classList.add( 'wpbnbd__button--active' );
|
|
102
|
+
} else {
|
|
103
|
+
thisTab.setAttribute( 'aria-selected', 'false' );
|
|
104
|
+
thisTab.classList.remove( 'wpbnbd__button--active' );
|
|
105
|
+
}
|
|
106
|
+
} );
|
|
107
|
+
|
|
108
|
+
// Update the underlying radio button.
|
|
109
|
+
const tabId = tab.id || '';
|
|
110
|
+
const frequencyId = tabId.replace( 'tab-', '' );
|
|
111
|
+
radioButtons.forEach( ( radio: HTMLInputElement ) => {
|
|
112
|
+
radio.checked = frequencyId === radio.id;
|
|
113
|
+
} );
|
|
114
|
+
|
|
115
|
+
// Loop through the panels and set tabindex 0 on the selected panel; remove it from others.
|
|
116
|
+
panels.forEach( ( panel: HTMLElement ) => {
|
|
117
|
+
if ( tab.getAttribute( 'aria-controls' ) === panel.id ) {
|
|
118
|
+
panel.setAttribute( 'tabindex', '0' );
|
|
119
|
+
} else {
|
|
120
|
+
panel.removeAttribute( 'tabindex' );
|
|
121
|
+
}
|
|
122
|
+
} );
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const processFrequencyBasedElements = ( parentEl = document ) => {
|
|
126
|
+
const elements = parentEl.querySelectorAll( '.wpbnbd--frequency-based' ) as NodeListOf< HTMLElement >;
|
|
127
|
+
elements.forEach( container => {
|
|
128
|
+
handleOtherValue( container );
|
|
129
|
+
addAccessibleTabs( container );
|
|
130
|
+
} );
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
if ( typeof window !== 'undefined' ) {
|
|
134
|
+
domReady( () => processFrequencyBasedElements() );
|
|
135
|
+
}
|