@beamimpact/web-sdk 1.56.3 → 1.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/_share-dialog-dependencies-U9953n3E.esm.js +2 -0
- package/dist/chunks/{_share-dialog-dependencies-Bk60ibnw.esm.js.map → _share-dialog-dependencies-U9953n3E.esm.js.map} +1 -1
- package/dist/chunks/{order-page-CSEjG6ma.esm.d.ts → cart-ChovPXmM.esm.d.ts} +5 -28
- package/dist/chunks/css-card-grid-BUidQqf0.esm.js +21 -0
- package/dist/chunks/css-card-grid-BUidQqf0.esm.js.map +1 -0
- package/dist/chunks/handlebars-B_i-to-h.esm.js +23 -0
- package/dist/chunks/handlebars-B_i-to-h.esm.js.map +1 -0
- package/dist/chunks/index--PfL-_nX.esm.js +2 -0
- package/dist/chunks/index--PfL-_nX.esm.js.map +1 -0
- package/dist/chunks/index-B4xKTDaF.esm.js +2 -0
- package/dist/chunks/index-B4xKTDaF.esm.js.map +1 -0
- package/dist/chunks/{index-DDCtGN21.esm.d.ts → index-BG4XJXUa.esm.d.ts} +1 -5
- package/dist/chunks/index-BHglsF5j.esm.js +2 -0
- package/dist/chunks/index-BHglsF5j.esm.js.map +1 -0
- package/dist/chunks/{index-hghrT7Z_.esm.d.ts → index-BoIHE1tC.esm.d.ts} +3 -0
- package/dist/chunks/index-CTsxQr7R.esm.js +32 -0
- package/dist/chunks/index-CTsxQr7R.esm.js.map +1 -0
- package/dist/chunks/{index-UMeAzKTG.esm.js → index-CVmIOuEY.esm.js} +6 -6
- package/dist/chunks/{index-BEEmYYxP.esm.js.map → index-CVmIOuEY.esm.js.map} +1 -1
- package/dist/chunks/{index-BLlSL37B.esm.d.ts → index-CdinWvYu.esm.d.ts} +1 -1
- package/dist/chunks/index-DBKUxzAl.esm.js +32 -0
- package/dist/chunks/index-DBKUxzAl.esm.js.map +1 -0
- package/dist/chunks/{index-BEEmYYxP.esm.js → index-DTw-q6W4.esm.js} +6 -6
- package/dist/chunks/{index-UMeAzKTG.esm.js.map → index-DTw-q6W4.esm.js.map} +1 -1
- package/dist/chunks/index-DhHhFTBE.esm.js +31 -0
- package/dist/chunks/index-DhHhFTBE.esm.js.map +1 -0
- package/dist/chunks/{index-C_u1FXtO.esm.d.ts → index-IQOpw0qx.esm.d.ts} +1 -10
- package/dist/chunks/{index-DyUuvdr3.esm.d.ts → index-_0XeyyF9.esm.d.ts} +1 -1
- package/dist/chunks/index-cb5vYQx0.esm.js +2 -0
- package/dist/chunks/index-cb5vYQx0.esm.js.map +1 -0
- package/dist/chunks/{lit-JRlupCB5.esm.js → lit-BEag9MFp.esm.js} +2 -2
- package/dist/chunks/{lit-JRlupCB5.esm.js.map → lit-BEag9MFp.esm.js.map} +1 -1
- package/dist/chunks/{lodash-BSs6Il-c.esm.js → lodash-CrMU6wKg.esm.js} +2 -2
- package/dist/chunks/{lodash-BSs6Il-c.esm.js.map → lodash-CrMU6wKg.esm.js.map} +1 -1
- package/dist/chunks/{promo-pill-label-D_4zJ7uy.esm.js → promo-pill-label-BdTmmg_U.esm.js} +2 -2
- package/dist/chunks/{promo-pill-label-D_4zJ7uy.esm.js.map → promo-pill-label-BdTmmg_U.esm.js.map} +1 -1
- package/dist/chunks/{responsive-CIV4sFdH.esm.js → responsive-aN8P5PqD.esm.js} +2 -2
- package/dist/chunks/{responsive-CIV4sFdH.esm.js.map → responsive-aN8P5PqD.esm.js.map} +1 -1
- package/dist/chunks/{routes-OxC3Ah30.esm.d.ts → routes-D6Gtw6kZ.esm.d.ts} +1 -1
- package/dist/chunks/share-button-7sI6zg-x.esm.js +54 -0
- package/dist/chunks/share-button-7sI6zg-x.esm.js.map +1 -0
- package/dist/chunks/{share-button-Dzc7loia.esm.js → share-button-BaIbuJOl.esm.js} +3 -3
- package/dist/chunks/{share-button-DkTpGZk1.esm.js.map → share-button-BaIbuJOl.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-DWgFuC7U.esm.d.ts → update-cart-CcgzHTEm.esm.d.ts} +1 -2
- package/dist/chunks/utils-BjhsDvuU.esm.js +2 -0
- package/dist/chunks/utils-BjhsDvuU.esm.js.map +1 -0
- package/dist/chunks/{openapi-spec-B4z4_CMq.esm.d.ts → utils-D8HO_RIu.esm.d.ts} +597 -11
- package/dist/chunks/{vendor-ckSdd6aH.esm.js → vendor-DUOg5fL-.esm.js} +2 -2
- package/dist/chunks/{vendor-ckSdd6aH.esm.js.map → vendor-DUOg5fL-.esm.js.map} +1 -1
- package/dist/components/beam-partner-logos.d.ts +3 -1
- package/dist/components/beam-partner-logos.esm.js +1 -1
- package/dist/components/beam-partner-logos.js +1 -1
- package/dist/components/community-impact.d.ts +3 -2
- package/dist/components/community-impact.esm.js +6 -6
- package/dist/components/community-impact.esm.js.map +1 -1
- package/dist/components/community-impact.js +6 -6
- package/dist/components/community-impact.js.map +1 -1
- package/dist/components/cumulative-impact.d.ts +3 -2
- package/dist/components/cumulative-impact.esm.js +11 -11
- package/dist/components/cumulative-impact.esm.js.map +1 -1
- package/dist/components/cumulative-impact.js +11 -11
- package/dist/components/cumulative-impact.js.map +1 -1
- package/dist/components/impact-overview.d.ts +3 -2
- package/dist/components/impact-overview.esm.js +5 -5
- package/dist/components/impact-overview.esm.js.map +1 -1
- package/dist/components/impact-overview.js +5 -5
- package/dist/components/impact-overview.js.map +1 -1
- package/dist/components/index.d.ts +5 -5
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/post-purchase.d.ts +3 -4
- package/dist/components/post-purchase.esm.js +1 -31
- package/dist/components/post-purchase.esm.js.map +1 -1
- package/dist/components/post-purchase.js +1 -31
- package/dist/components/post-purchase.js.map +1 -1
- package/dist/components/product-details-page.d.ts +4 -2
- package/dist/components/product-details-page.esm.js +4 -4
- package/dist/components/product-details-page.esm.js.map +1 -1
- package/dist/components/product-details-page.js +4 -4
- package/dist/components/product-details-page.js.map +1 -1
- package/dist/components/redeem-transaction.d.ts +3 -4
- package/dist/components/redeem-transaction.esm.js +1 -1
- package/dist/components/redeem-transaction.js +1 -1
- package/dist/components/select-nonprofit.d.ts +3 -4
- package/dist/components/select-nonprofit.esm.js +6 -6
- package/dist/components/select-nonprofit.esm.js.map +1 -1
- package/dist/components/select-nonprofit.js +6 -6
- package/dist/components/select-nonprofit.js.map +1 -1
- package/dist/components/select-subscription-nonprofit.d.ts +3 -2
- package/dist/components/select-subscription-nonprofit.esm.js +5 -5
- package/dist/components/select-subscription-nonprofit.esm.js.map +1 -1
- package/dist/components/select-subscription-nonprofit.js +5 -5
- package/dist/components/select-subscription-nonprofit.js.map +1 -1
- package/dist/components/shopify.d.ts +9 -12
- package/dist/components/shopify.esm.js +1 -1
- package/dist/components/shopify.esm.js.map +1 -1
- package/dist/components/shopify.js +1 -1
- package/dist/components/shopify.js.map +1 -1
- package/dist/components/social-share.d.ts +3 -2
- package/dist/components/social-share.esm.js +2 -2
- package/dist/components/social-share.esm.js.map +1 -1
- package/dist/components/social-share.js +2 -2
- package/dist/components/social-share.js.map +1 -1
- package/dist/components/subscriber-select-nonprofit.d.ts +59 -0
- package/dist/components/subscriber-select-nonprofit.esm.js +137 -0
- package/dist/components/subscriber-select-nonprofit.esm.js.map +1 -0
- package/dist/components/subscriber-select-nonprofit.js +137 -0
- package/dist/components/subscriber-select-nonprofit.js.map +1 -0
- package/dist/components/subscription-impact.d.ts +3 -2
- package/dist/components/subscription-impact.esm.js +6 -6
- package/dist/components/subscription-impact.esm.js.map +1 -1
- package/dist/components/subscription-impact.js +6 -6
- package/dist/components/subscription-impact.js.map +1 -1
- package/dist/components/subscription-management.d.ts +4 -5
- package/dist/components/subscription-management.esm.js +4 -4
- package/dist/components/subscription-management.esm.js.map +1 -1
- package/dist/components/subscription-management.js +4 -4
- package/dist/components/subscription-management.js.map +1 -1
- package/dist/index.d.ts +39 -38
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/beam.d.ts +3 -1
- package/dist/integrations/beam.esm.js +1 -1
- package/dist/integrations/beam.esm.js.map +1 -1
- package/dist/integrations/beam.js +1 -1
- package/dist/integrations/beam.js.map +1 -1
- package/dist/integrations/cart.d.ts +4 -4
- package/dist/integrations/cart.esm.js +1 -1
- package/dist/integrations/cart.js +1 -1
- package/dist/integrations/logs.d.ts +4 -2
- package/dist/integrations/logs.esm.js +1 -1
- package/dist/integrations/logs.js +1 -1
- package/dist/integrations/promoManager.d.ts +3 -1
- package/dist/integrations/promoManager.esm.js +1 -1
- package/dist/integrations/promoManager.esm.js.map +1 -1
- package/dist/integrations/promoManager.js +1 -1
- package/dist/integrations/promoManager.js.map +1 -1
- package/dist/integrations/session.esm.js +1 -1
- package/dist/integrations/session.js +1 -1
- package/dist/integrations/shopify-order.d.ts +38 -0
- package/dist/integrations/shopify-order.esm.js +2 -0
- package/dist/integrations/shopify-order.esm.js.map +1 -0
- package/dist/integrations/shopify-order.js +2 -0
- package/dist/integrations/shopify-order.js.map +1 -0
- package/dist/integrations/shopify.d.ts +5 -12
- package/dist/integrations/shopify.esm.js +1 -1
- package/dist/integrations/shopify.js +1 -1
- package/dist/integrations/statsig.d.ts +3 -1
- package/dist/integrations/statsig.esm.js +2 -2
- package/dist/integrations/statsig.esm.js.map +1 -1
- package/dist/integrations/statsig.js +2 -2
- package/dist/integrations/statsig.js.map +1 -1
- package/dist/integrations/utils.d.ts +1 -14
- package/dist/integrations/utils.esm.js +1 -1
- package/dist/integrations/utils.js +1 -1
- package/dist/react/beam-partner-logos.d.ts +3 -1
- package/dist/react/beam-partner-logos.esm.js +1 -1
- package/dist/react/beam-partner-logos.js +1 -1
- package/dist/react/community-impact.d.ts +3 -2
- package/dist/react/community-impact.esm.js +1 -1
- package/dist/react/community-impact.esm.js.map +1 -1
- package/dist/react/community-impact.js +1 -1
- package/dist/react/community-impact.js.map +1 -1
- package/dist/react/cumulative-impact.d.ts +3 -2
- package/dist/react/cumulative-impact.esm.js +1 -1
- package/dist/react/cumulative-impact.esm.js.map +1 -1
- package/dist/react/cumulative-impact.js +1 -1
- package/dist/react/cumulative-impact.js.map +1 -1
- package/dist/react/impact-overview.d.ts +3 -2
- package/dist/react/impact-overview.esm.js +1 -1
- package/dist/react/impact-overview.esm.js.map +1 -1
- package/dist/react/impact-overview.js +1 -1
- package/dist/react/impact-overview.js.map +1 -1
- package/dist/react/index.d.ts +6 -7
- package/dist/react/index.esm.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/post-purchase.d.ts +3 -4
- package/dist/react/post-purchase.esm.js +1 -1
- package/dist/react/post-purchase.esm.js.map +1 -1
- package/dist/react/post-purchase.js +1 -1
- package/dist/react/post-purchase.js.map +1 -1
- package/dist/react/product-details-page.d.ts +4 -2
- package/dist/react/product-details-page.esm.js +1 -1
- package/dist/react/product-details-page.esm.js.map +1 -1
- package/dist/react/product-details-page.js +1 -1
- package/dist/react/product-details-page.js.map +1 -1
- package/dist/react/redeem-transaction.d.ts +3 -6
- package/dist/react/redeem-transaction.esm.js +1 -1
- package/dist/react/redeem-transaction.esm.js.map +1 -1
- package/dist/react/redeem-transaction.js +1 -1
- package/dist/react/redeem-transaction.js.map +1 -1
- package/dist/react/select-nonprofit.d.ts +3 -6
- package/dist/react/select-nonprofit.esm.js +1 -1
- package/dist/react/select-nonprofit.esm.js.map +1 -1
- package/dist/react/select-nonprofit.js +1 -1
- package/dist/react/select-nonprofit.js.map +1 -1
- package/dist/react/select-subscription-nonprofit.d.ts +3 -6
- package/dist/react/select-subscription-nonprofit.esm.js +1 -1
- package/dist/react/select-subscription-nonprofit.esm.js.map +1 -1
- package/dist/react/select-subscription-nonprofit.js +1 -1
- package/dist/react/select-subscription-nonprofit.js.map +1 -1
- package/dist/react/shopify.d.ts +2 -2
- package/dist/react/shopify.esm.js +1 -1
- package/dist/react/shopify.esm.js.map +1 -1
- package/dist/react/shopify.js +1 -1
- package/dist/react/shopify.js.map +1 -1
- package/dist/react/social-share.d.ts +3 -2
- package/dist/react/social-share.esm.js +1 -1
- package/dist/react/social-share.esm.js.map +1 -1
- package/dist/react/social-share.js +1 -1
- package/dist/react/social-share.js.map +1 -1
- package/dist/react/subscriber-select-nonprofit.d.ts +14 -0
- package/dist/react/subscriber-select-nonprofit.esm.js +2 -0
- package/dist/react/subscriber-select-nonprofit.esm.js.map +1 -0
- package/dist/react/subscriber-select-nonprofit.js +2 -0
- package/dist/react/subscriber-select-nonprofit.js.map +1 -0
- package/dist/react/subscription-impact.d.ts +3 -2
- package/dist/react/subscription-impact.esm.js +1 -1
- package/dist/react/subscription-impact.esm.js.map +1 -1
- package/dist/react/subscription-impact.js +1 -1
- package/dist/react/subscription-impact.js.map +1 -1
- package/dist/react/subscription-management.d.ts +4 -5
- package/dist/react/subscription-management.esm.js +1 -1
- package/dist/react/subscription-management.esm.js.map +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/dist/react/subscription-management.js.map +1 -1
- package/dist/utils/beam-errors.d.ts +3 -1
- package/dist/utils/beam-errors.esm.js +1 -1
- package/dist/utils/beam-errors.js +1 -1
- package/dist/utils/cart.d.ts +3 -18
- package/dist/utils/cart.esm.js +1 -1
- package/dist/utils/cart.esm.js.map +1 -1
- package/dist/utils/cart.js +1 -1
- package/dist/utils/cart.js.map +1 -1
- package/dist/utils/cookies.d.ts +3 -18
- package/dist/utils/cookies.esm.js +1 -1
- package/dist/utils/cookies.esm.js.map +1 -1
- package/dist/utils/cookies.js +1 -1
- package/dist/utils/cookies.js.map +1 -1
- package/dist/utils/debounce.esm.js +1 -1
- package/dist/utils/debounce.js +1 -1
- package/dist/utils/events.d.ts +3 -5
- package/dist/utils/events.esm.js +1 -1
- package/dist/utils/events.js +1 -1
- package/dist/utils/is-equal.esm.js +1 -1
- package/dist/utils/is-equal.js +1 -1
- package/dist/utils/local-storage.d.ts +3 -19
- package/dist/utils/local-storage.esm.js +1 -1
- package/dist/utils/local-storage.esm.js.map +1 -1
- package/dist/utils/local-storage.js +1 -1
- package/dist/utils/local-storage.js.map +1 -1
- package/dist/utils/logger.d.ts +3 -8
- package/dist/utils/logger.esm.js +1 -1
- package/dist/utils/logger.esm.js.map +1 -1
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/makeApiKeyHeader.d.ts +3 -5
- package/dist/utils/makeApiKeyHeader.esm.js +1 -1
- package/dist/utils/makeApiKeyHeader.esm.js.map +1 -1
- package/dist/utils/makeApiKeyHeader.js +1 -1
- package/dist/utils/makeApiKeyHeader.js.map +1 -1
- package/dist/utils/memoize-last.d.ts +3 -17
- package/dist/utils/memoize-last.esm.js +1 -1
- package/dist/utils/memoize-last.esm.js.map +1 -1
- package/dist/utils/memoize-last.js +1 -1
- package/dist/utils/memoize-last.js.map +1 -1
- package/dist/utils/network-listeners.d.ts +3 -3
- package/dist/utils/network-listeners.esm.js +1 -1
- package/dist/utils/network-listeners.esm.js.map +1 -1
- package/dist/utils/network-listeners.js +1 -1
- package/dist/utils/network-listeners.js.map +1 -1
- package/dist/utils/promoManager.d.ts +3 -111
- package/dist/utils/promoManager.esm.js +1 -1
- package/dist/utils/promoManager.esm.js.map +1 -1
- package/dist/utils/promoManager.js +1 -1
- package/dist/utils/promoManager.js.map +1 -1
- package/dist/utils/remote-session.d.ts +3 -9
- package/dist/utils/remote-session.esm.js +1 -1
- package/dist/utils/remote-session.esm.js.map +1 -1
- package/dist/utils/remote-session.js +1 -1
- package/dist/utils/remote-session.js.map +1 -1
- package/dist/utils/wait-for-element.d.ts +3 -5
- package/dist/utils/wait-for-element.esm.js +1 -1
- package/dist/utils/wait-for-element.esm.js.map +1 -1
- package/dist/utils/wait-for-element.js +1 -1
- package/dist/utils/wait-for-element.js.map +1 -1
- package/package.json +9 -6
- package/dist/chunks/_share-dialog-dependencies-Bk60ibnw.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-D6vA_2f6.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-D6vA_2f6.esm.js.map +0 -1
- package/dist/chunks/beam-errors-Ci0d3926.esm.js +0 -2
- package/dist/chunks/beam-errors-Ci0d3926.esm.js.map +0 -1
- package/dist/chunks/beam-errors-DUQ9pK2V.esm.d.ts +0 -46
- package/dist/chunks/cart-contents-CEoSx3y4.esm.d.ts +0 -18
- package/dist/chunks/cart-contents-DkoytiZh.esm.js +0 -2
- package/dist/chunks/cart-contents-DkoytiZh.esm.js.map +0 -1
- package/dist/chunks/css-card-grid-DixMt6ek.esm.js +0 -20
- package/dist/chunks/css-card-grid-DixMt6ek.esm.js.map +0 -1
- package/dist/chunks/enforce-config-DHnpgqSK.esm.js +0 -3
- package/dist/chunks/enforce-config-DHnpgqSK.esm.js.map +0 -1
- package/dist/chunks/enforce-config-DUbQnaLO.esm.js +0 -3
- package/dist/chunks/enforce-config-DUbQnaLO.esm.js.map +0 -1
- package/dist/chunks/events-COWOQoLW.esm.js +0 -2
- package/dist/chunks/events-COWOQoLW.esm.js.map +0 -1
- package/dist/chunks/events-Dwqfqbij.esm.d.ts +0 -214
- package/dist/chunks/index-8rOpG9kf.esm.js +0 -2
- package/dist/chunks/index-8rOpG9kf.esm.js.map +0 -1
- package/dist/chunks/index-B1GmdVT3.esm.js +0 -2
- package/dist/chunks/index-B1GmdVT3.esm.js.map +0 -1
- package/dist/chunks/index-B2dxbh1d.esm.js +0 -2
- package/dist/chunks/index-B2dxbh1d.esm.js.map +0 -1
- package/dist/chunks/index-BIEV1MH0.esm.js +0 -2
- package/dist/chunks/index-BIEV1MH0.esm.js.map +0 -1
- package/dist/chunks/index-BaWMWAyt.esm.js +0 -2
- package/dist/chunks/index-BaWMWAyt.esm.js.map +0 -1
- package/dist/chunks/index-BeX4QeUu.esm.js +0 -2
- package/dist/chunks/index-BeX4QeUu.esm.js.map +0 -1
- package/dist/chunks/index-C3hpHWh1.esm.js +0 -2
- package/dist/chunks/index-C3hpHWh1.esm.js.map +0 -1
- package/dist/chunks/index-C3v-y56g.esm.js +0 -2
- package/dist/chunks/index-C3v-y56g.esm.js.map +0 -1
- package/dist/chunks/index-CqqF1sQo.esm.js +0 -2
- package/dist/chunks/index-CqqF1sQo.esm.js.map +0 -1
- package/dist/chunks/index-Cs4Kp9X4.esm.js +0 -2
- package/dist/chunks/index-Cs4Kp9X4.esm.js.map +0 -1
- package/dist/chunks/index-D20ifskY.esm.d.ts +0 -21
- package/dist/chunks/index-D3hxLDQF.esm.js +0 -2
- package/dist/chunks/index-D3hxLDQF.esm.js.map +0 -1
- package/dist/chunks/index-D5TZB-zM.esm.js +0 -2
- package/dist/chunks/index-D5TZB-zM.esm.js.map +0 -1
- package/dist/chunks/index-D6qJfs7_.esm.js +0 -2
- package/dist/chunks/index-D6qJfs7_.esm.js.map +0 -1
- package/dist/chunks/index-DSJACB_p.esm.js +0 -2
- package/dist/chunks/index-DSJACB_p.esm.js.map +0 -1
- package/dist/chunks/index-DmjZnpod.esm.js +0 -2
- package/dist/chunks/index-DmjZnpod.esm.js.map +0 -1
- package/dist/chunks/index-EJRmgmQu.esm.d.ts +0 -74
- package/dist/chunks/index-mppXVWCH.esm.js +0 -2
- package/dist/chunks/index-mppXVWCH.esm.js.map +0 -1
- package/dist/chunks/index-n62IxH5D.esm.js +0 -2
- package/dist/chunks/index-n62IxH5D.esm.js.map +0 -1
- package/dist/chunks/index-nAPzvUWE.esm.js +0 -2
- package/dist/chunks/index-nAPzvUWE.esm.js.map +0 -1
- package/dist/chunks/index-xcGPhpiO.esm.d.ts +0 -44
- package/dist/chunks/is-all-html-elements-fcB7UUA1.esm.js +0 -2
- package/dist/chunks/is-all-html-elements-fcB7UUA1.esm.js.map +0 -1
- package/dist/chunks/loading-template-BFvXaTlD.esm.js +0 -2
- package/dist/chunks/loading-template-BFvXaTlD.esm.js.map +0 -1
- package/dist/chunks/localize-Dg7NgKIP.esm.js +0 -31
- package/dist/chunks/localize-Dg7NgKIP.esm.js.map +0 -1
- package/dist/chunks/localize-DkAbsh05.esm.js +0 -31
- package/dist/chunks/localize-DkAbsh05.esm.js.map +0 -1
- package/dist/chunks/order-page-B0WbVrvh.esm.js +0 -2
- package/dist/chunks/order-page-B0WbVrvh.esm.js.map +0 -1
- package/dist/chunks/order-page-CT3hnhzf.esm.js +0 -2
- package/dist/chunks/order-page-CT3hnhzf.esm.js.map +0 -1
- package/dist/chunks/progress-bar-B82FOT8n.esm.js +0 -54
- package/dist/chunks/progress-bar-B82FOT8n.esm.js.map +0 -1
- package/dist/chunks/promo-pill-label-DcsiJS_N.esm.js +0 -16
- package/dist/chunks/promo-pill-label-DcsiJS_N.esm.js.map +0 -1
- package/dist/chunks/promo-types-CmZzhkpN.esm.d.ts +0 -15
- package/dist/chunks/promo-types-DKAOFHJr.esm.js +0 -2
- package/dist/chunks/promo-types-DKAOFHJr.esm.js.map +0 -1
- package/dist/chunks/routes-BIMwJ8u9.esm.js +0 -2
- package/dist/chunks/routes-BIMwJ8u9.esm.js.map +0 -1
- package/dist/chunks/routes-DSu5s3K7.esm.js +0 -2
- package/dist/chunks/routes-DSu5s3K7.esm.js.map +0 -1
- package/dist/chunks/share-button-CLMw49f5.esm.js +0 -2
- package/dist/chunks/share-button-CLMw49f5.esm.js.map +0 -1
- package/dist/chunks/share-button-DXS3zbJz.esm.js +0 -2
- package/dist/chunks/share-button-DXS3zbJz.esm.js.map +0 -1
- package/dist/chunks/share-button-DkTpGZk1.esm.js +0 -172
- package/dist/chunks/share-button-Dzc7loia.esm.js.map +0 -1
- package/dist/chunks/types-D_PLq1pj.esm.d.ts +0 -28
- package/dist/chunks/types-DfRc36jU.esm.d.ts +0 -15
- package/dist/chunks/update-cart-ByUvNLyZ.esm.js +0 -2
- package/dist/chunks/update-cart-ByUvNLyZ.esm.js.map +0 -1
- package/dist/chunks/update-cart-yj_9VGHp.esm.js +0 -2
- package/dist/chunks/update-cart-yj_9VGHp.esm.js.map +0 -1
- package/dist/integrations/index.d.ts +0 -31
- package/dist/integrations/index.esm.js +0 -2
- package/dist/integrations/index.esm.js.map +0 -1
- package/dist/integrations/index.js +0 -2
- package/dist/integrations/index.js.map +0 -1
- package/dist/utils/index.d.ts +0 -16
- package/dist/utils/index.esm.js +0 -2
- package/dist/utils/index.esm.js.map +0 -1
- package/dist/utils/index.js +0 -2
- package/dist/utils/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"social-share.js","sources":["../../src/components/social-share/index.ts"],"sourcesContent":["import { css, html, LitElement } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport \"@shoelace-style/shoelace/dist/components/icon/icon.js\";\nimport \"../../shared/components/_share-dialog-dependencies\";\nimport \"../../shared/components/progress-bar\";\nimport \"../beam-partner-logos\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { getImpact } from \"../../api-sdk/v3/routes\";\nimport { _loading } from \"../../shared/fragments/loading-template\";\nimport { DEFAULT_BASE_URL, SUPPORTED_LANGUAGES, WIDGET_NAMES } from \"../../api-sdk/constants\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { TNumericId } from \"../../shared/types\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { strings } from \"../../shared/components/strings/share-button\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { urlToFile } from \"../../shared/files\";\nimport { postSocialShareAnalyticsEvent } from \"../../api-sdk/v2/users/events\";\n\ntype RequiredConfig = {\n apiKey: string;\n storeId: TNumericId;\n nonprofitId: TNumericId;\n};\n\nexport class BeamSocialShare extends LitElement {\n static tagName = \"beam-social-share\";\n\n @property({ type: String }) public apiKey?: RequiredConfig[\"apiKey\"];\n @property({ type: Number }) storeId?: RequiredConfig[\"storeId\"];\n @property({ type: Number }) nonprofitId?: RequiredConfig[\"nonprofitId\"];\n @property({ type: String }) public baseUrl = DEFAULT_BASE_URL;\n @property({ type: String }) public lang: LANGUAGES = \"en\";\n @property({ type: Boolean }) public debug = false;\n @property({ type: String }) transactionId?: string;\n\n @state() private brandName: string | null = null;\n @state() private shareImageUrl: string | null = null;\n @state() private dataUrl?: string;\n @state() private file?: File;\n @state() private isMobile = false;\n @state() private windowResized = false;\n\n get configLang() {\n return SUPPORTED_LANGUAGES[this.lang] || \"en\";\n }\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\"resize\", this.checkViewport);\n this.checkViewport();\n }\n\n disconnectedCallback() {\n window.removeEventListener(\"resize\", this.checkViewport);\n super.disconnectedCallback();\n }\n\n checkViewport = () => {\n this.windowResized = window.innerWidth <= 768;\n };\n\n private async fetchImpactData() {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"storeId\", \"nonprofitId\"], this)) {\n throw new MissingConfig();\n }\n try {\n const res = await getImpact({\n baseUrl: this.baseUrl,\n headers: { authorization: `Api-Key ${this.apiKey}` },\n queryParams: {\n storeId: this.storeId,\n personalImpactLimit: 0,\n nonprofitId: this.nonprofitId,\n widgetName: WIDGET_NAMES.community_impact,\n version: \"1.0.0\",\n lang: this.configLang,\n transactionId: this.transactionId ?? undefined,\n },\n });\n return res;\n } catch (error) {\n if (this.debug) {\n console.error(\"Failed to fetch impact data\", error);\n }\n throw error;\n }\n }\n\n // Updates component state with fetched impact data\n private async updateImpactData() {\n try {\n const data = await this.fetchImpactData();\n if (data) {\n this.brandName = data.chain.name;\n this.shareImageUrl = data.promoAssetUrl || data.personalImpactAssetUrl || data.community[0].share.imageUrl;\n\n if (this.shareImageUrl) {\n const file = await urlToFile(this.shareImageUrl);\n this.file = file;\n this.dataUrl = URL.createObjectURL(file);\n }\n }\n } catch (error) {\n if (this.debug) {\n console.error(\"Error updating impact data:\", error);\n }\n }\n }\n\n async firstUpdated() {\n await this.updateImpactData();\n this.isMobile =\n /Mobi|Android/i.test(navigator.userAgent) || \"ontouchstart\" in window || navigator.maxTouchPoints > 0;\n }\n\n private async openSystemShareSheet(imageUrl: string) {\n if (!imageUrl) return;\n\n try {\n const file = await urlToFile(imageUrl);\n if (navigator.share && this.brandName) {\n await navigator.share({\n files: [file],\n title: strings[this.lang].impactShareTitle(),\n text: strings[this.lang].impactShareText({ brandName: this.brandName }),\n });\n }\n } catch (error) {\n if (this.debug) {\n console.error(\"Failed to open share sheet\", error);\n }\n }\n }\n\n private async handleClickCopy() {\n if (this.file) {\n try {\n if (this.apiKey && this.transactionId) {\n void postSocialShareAnalyticsEvent({\n baseUrl: this.baseUrl,\n apiKey: this.apiKey || \"\",\n requestBody: {\n eventName: \"ExtensibilityCopyImageButtonClick\",\n nonprofitId: this.nonprofitId,\n storeId: this.storeId,\n timestamp: Date.now(),\n transactionId: Number(this.transactionId),\n },\n }).catch(() => null);\n } else {\n console.error(\"Missing data for social share analytics. Skipping send\");\n }\n await navigator.clipboard.write([new ClipboardItem({ \"image/png\": this.file })]);\n } catch (error) {\n if (this.debug) {\n console.error(\"Failed to copy image to clipboard:\", error);\n }\n }\n }\n }\n\n private handleClickDownload(event: Event) {\n if (this.apiKey && this.transactionId) {\n void postSocialShareAnalyticsEvent({\n baseUrl: this.baseUrl,\n apiKey: this.apiKey || \"\",\n requestBody: {\n eventName: \"ExtensibilityDownloadImageButtonClick\",\n nonprofitId: this.nonprofitId,\n storeId: this.storeId,\n timestamp: Date.now(),\n transactionId: Number(this.transactionId),\n },\n }).catch(() => null);\n } else {\n console.error(\"Missing data for social share analytics. Skipping send\");\n }\n const target = event.currentTarget as HTMLAnchorElement;\n if (this.isMobile && this.shareImageUrl) {\n event.preventDefault();\n this.openSystemShareSheet(this.shareImageUrl);\n } else if (this.dataUrl) {\n target.href = this.dataUrl;\n target.download = strings[this.lang].impactShareTitle();\n }\n }\n\n render() {\n if (!this.brandName || !this.shareImageUrl || !this.dataUrl) {\n return _loading();\n }\n\n return html`\n <div class=\"share-container ${this.windowResized || this.isMobile ? \"mobile\" : \"desktop\"}\">\n <h2 class=\"share-title\">${strings[this.lang].impactShareTitle()}</h2>\n <p class=\"share-text\">${strings[this.lang].impactShareText({ brandName: this.brandName })}</p>\n <img\n data-speedsize-ignore=\"true\"\n src=\"${this.shareImageUrl}\"\n alt=\"${strings[this.lang].impactShareTitle()}\"\n class=\"share-image\"\n />\n <div class=\"share-actions\">\n <button class=\"plain-button button share-action-button\" @click=\"${this.handleClickCopy}\">\n <sl-icon\n library=\"lucide\"\n name=\"copy\"\n label=\"${strings[this.lang].impactShareCopy()}\"\n class=\"share-action-icon\"\n ></sl-icon>\n <div class=\"share-action-text\">${strings[this.lang].impactShareCopy()}</div>\n </button>\n <a\n class=\"plain-button button share-action-button plain-link\"\n download=\"${strings[this.lang].impactShareTitle()}\"\n href=\"${this.dataUrl}\"\n @click=\"${this.handleClickDownload}\"\n >\n <sl-icon\n library=\"lucide\"\n name=\"download\"\n label=\"${strings[this.lang].impactShareDownload()}\"\n class=\"share-action-icon\"\n ></sl-icon>\n <div class=\"share-action-text\">${strings[this.lang].impactShareDownload()}</div>\n </a>\n </div>\n </div>\n `;\n }\n\n static styles = [\n cssReset,\n css`\n @font-face {\n font-family: \"Mabry-Bold\";\n src: url(\"../../../assets/fonts/mabry-bold.otf\") format(\"opentype\");\n font-weight: bold;\n font-style: normal;\n }\n @font-face {\n font-family: \"Mabry-Medium\";\n src: url(\"../../../assets/fonts/mabry-medium.otf\") format(\"opentype\");\n font-weight: bold;\n font-style: normal;\n }\n :host {\n align-items: center;\n justify-content: center;\n display: flex;\n box-sizing: border-box;\n width: 100%;\n }\n\n .share-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n max-width: 700px;\n text-align: center;\n }\n\n .share-container.mobile {\n padding: 1rem;\n max-width: 100%;\n }\n\n .share-title {\n font-family: \"Mabry-Bold\", sans-serif;\n font-size: 2.5rem;\n font-weight: bold;\n word-break: break-word;\n margin: 10px 0;\n }\n\n .share-title.mobile {\n font-size: 1.5rem;\n }\n\n .share-text {\n font-family: \"Mabry-Medium\", sans-serif;\n font-size: 1.25rem;\n line-height: 1.4;\n word-break: break-word;\n margin: 10px 0;\n max-width: 500px;\n }\n\n .share-text.mobile {\n font-size: 1rem;\n }\n\n .share-image {\n border-radius: 8px;\n width: 100%;\n max-width: 300px;\n height: auto;\n display: block;\n margin: 20px auto;\n }\n\n .share-actions {\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 10px;\n align-items: center;\n margin: 20px 0;\n }\n\n .share-actions.mobile {\n flex-direction: column;\n }\n\n .share-action-button {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 10px 20px;\n border: 1px solid #ccc;\n border-radius: 4px;\n background-color: #fff;\n text-decoration: none;\n color: #333;\n cursor: pointer;\n transition:\n background-color 0.3s,\n border-color 0.3s;\n }\n\n .share-action-button:hover {\n background-color: #f0f0f0;\n border-color: #bbb;\n }\n\n .share-action-icon {\n font-size: 1.25rem;\n margin-right: 8px;\n }\n\n .share-action-text {\n font-family: \"Mabry-Medium\", sans-serif;\n font-size: 1rem;\n line-height: 1.4;\n margin-top: 5px;\n }\n\n @media (max-width: 600px) {\n .share-title {\n font-size: 1.5rem;\n }\n\n .share-text {\n font-size: 1rem;\n }\n\n .share-image {\n max-width: 240px;\n }\n\n .share-actions {\n flex-direction: row;\n width: 50%;\n margin: 10px 0;\n }\n\n .share-action-button {\n width: 100%;\n margin: 5px 0;\n }\n }\n `,\n ];\n}\n\ndefineCustomElement(BeamSocialShare);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-social-share\": BeamSocialShare;\n }\n}\n"],"names":["m","i","o","t","e","r","d","BeamSocialShare","LitElement","DEFAULT_BASE_URL","SUPPORTED_LANGUAGES","enforceConfig","getImpact","WIDGET_NAMES","error","data","file","urlToFile","imageUrl","strings","postSocialShareAnalyticsEvent","event","target","_loading","html","cssReset","css","__decorateClass","property","state","defineCustomElement"],"mappings":"gwBAAA,IAAAA,EAAA,OAAA,eAAAC,EAAA,CAAA,EAAAC,EAAAC,EAAAC,IAAA,CAAA,QAAAC,EAAA,OAAA,EAAA,EAAA,OAAA,EAAAC,EAAA,GAAA,EAAA,KAAAA,EAAA,EAAA,CAAA,KAAAD,EAAAC,EAAAJ,EAAAC,EAAAE,CAAA,GAAAA,GAAA,OAAAA,GAAAL,EAAAE,EAAAC,EAAA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,EALfrB,EAKiB,UAAA,aAAA,EACOoB,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EANfrB,EAMwB,qBACAoB,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAPfrB,EAOwB,UAAA,MAAA,EACCoB,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EARhBrB,EAQyB,UAAA,OAAA,EACRoB,EAAA,CAA3BC,EAAS,CAAE,KAAM,MAAO,CAAC,GATfrB,EASiB,UAAA,eAAA,EAEXoB,EAAA,CAAhBE,EAAAA,CAAM,EAXItB,EAWM,UAAA,WAAA,EACAoB,EAAA,CAAhBE,EAAAA,CAAM,EAZItB,EAYM,2BACAoB,EAAA,CAAhBE,EAAAA,CAAM,EAbItB,EAaM,UAAA,SAAA,EACAoB,EAAA,CAAhBE,EAAAA,CAAM,EAdItB,EAcM,UAAA,MAAA,EACAoB,EAAA,CAAhBE,EAAAA,CAAM,EAfItB,EAeM,UAAA,UAAA,EACAoB,EAAA,CAAhBE,GAAM,EAhBItB,EAgBM,UAAA,eAAA,EAgVnBuB,EAAoBvB,CAAe"}
|
|
1
|
+
{"version":3,"file":"social-share.js","sources":["../../src/components/social-share/index.ts"],"sourcesContent":["import { css, html, LitElement } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\nimport \"@shoelace-style/shoelace/dist/components/icon/icon.js\";\nimport \"../../shared/components/_share-dialog-dependencies\";\nimport \"../../shared/components/progress-bar\";\nimport \"../beam-partner-logos\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { getImpact } from \"../../api-sdk/v3/routes\";\nimport { _loading } from \"../../shared/fragments/loading-template\";\nimport { DEFAULT_BASE_URL, SUPPORTED_LANGUAGES, WIDGET_NAMES } from \"../../api-sdk/constants\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { TNumericId } from \"../../shared/types\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { strings } from \"../../shared/components/strings/share-button\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { urlToFile } from \"../../shared/files\";\nimport { postSocialShareAnalyticsEvent } from \"../../api-sdk/v2/users/events\";\n\ntype RequiredConfig = {\n apiKey: string;\n storeId: TNumericId;\n nonprofitId: TNumericId;\n};\n\nexport class BeamSocialShare extends LitElement {\n static tagName = \"beam-social-share\";\n\n @property({ type: String }) public apiKey?: RequiredConfig[\"apiKey\"];\n @property({ type: Number }) storeId?: RequiredConfig[\"storeId\"];\n @property({ type: Number }) nonprofitId?: RequiredConfig[\"nonprofitId\"];\n @property({ type: String }) public baseUrl = DEFAULT_BASE_URL;\n @property({ type: String }) public lang: LANGUAGES = \"en\";\n @property({ type: Boolean }) public debug = false;\n @property({ type: String }) transactionId?: string;\n\n @state() private brandName: string | null = null;\n @state() private shareImageUrl: string | null = null;\n @state() private dataUrl?: string;\n @state() private file?: File;\n @state() private isMobile = false;\n @state() private windowResized = false;\n\n get configLang() {\n return SUPPORTED_LANGUAGES[this.lang] || \"en\";\n }\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener(\"resize\", this.checkViewport);\n this.checkViewport();\n }\n\n disconnectedCallback() {\n window.removeEventListener(\"resize\", this.checkViewport);\n super.disconnectedCallback();\n }\n\n checkViewport = () => {\n this.windowResized = window.innerWidth <= 768;\n };\n\n private async fetchImpactData() {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"storeId\", \"nonprofitId\"], this)) {\n throw new MissingConfig();\n }\n try {\n const res = await getImpact({\n baseUrl: this.baseUrl,\n headers: { authorization: `Api-Key ${this.apiKey}` },\n queryParams: {\n storeId: this.storeId,\n personalImpactLimit: 0,\n nonprofitId: this.nonprofitId,\n widgetName: WIDGET_NAMES.community_impact,\n version: \"1.0.0\",\n lang: this.configLang,\n transactionId: this.transactionId ?? undefined,\n },\n });\n return res;\n } catch (error) {\n if (this.debug) {\n console.error(\"Failed to fetch impact data\", error);\n }\n throw error;\n }\n }\n\n // Updates component state with fetched impact data\n private async updateImpactData() {\n try {\n const data = await this.fetchImpactData();\n if (data) {\n this.brandName = data.chain.name;\n this.shareImageUrl = data.promoAssetUrl || data.personalImpactAssetUrl || data.community[0].share.imageUrl;\n\n if (this.shareImageUrl) {\n const file = await urlToFile(this.shareImageUrl);\n this.file = file;\n this.dataUrl = URL.createObjectURL(file);\n }\n }\n } catch (error) {\n if (this.debug) {\n console.error(\"Error updating impact data:\", error);\n }\n }\n }\n\n async firstUpdated() {\n await this.updateImpactData();\n this.isMobile =\n /Mobi|Android/i.test(navigator.userAgent) || \"ontouchstart\" in window || navigator.maxTouchPoints > 0;\n }\n\n private async openSystemShareSheet(imageUrl: string) {\n if (!imageUrl) return;\n\n try {\n const file = await urlToFile(imageUrl);\n if (navigator.share && this.brandName) {\n await navigator.share({\n files: [file],\n title: strings[this.lang].impactShareTitle(),\n text: strings[this.lang].impactShareText({ brandName: this.brandName }),\n });\n }\n } catch (error) {\n if (this.debug) {\n console.error(\"Failed to open share sheet\", error);\n }\n }\n }\n\n private async handleClickCopy() {\n if (this.file) {\n try {\n if (this.apiKey && this.transactionId) {\n void postSocialShareAnalyticsEvent({\n baseUrl: this.baseUrl,\n apiKey: this.apiKey || \"\",\n requestBody: {\n eventName: \"ExtensibilityCopyImageButtonClick\",\n nonprofitId: this.nonprofitId,\n storeId: this.storeId,\n timestamp: Date.now(),\n transactionId: Number(this.transactionId),\n },\n }).catch(() => null);\n } else {\n console.error(\"Missing data for social share analytics. Skipping send\");\n }\n await navigator.clipboard.write([new ClipboardItem({ \"image/png\": this.file })]);\n } catch (error) {\n if (this.debug) {\n console.error(\"Failed to copy image to clipboard:\", error);\n }\n }\n }\n }\n\n private handleClickDownload(event: Event) {\n if (this.apiKey && this.transactionId) {\n void postSocialShareAnalyticsEvent({\n baseUrl: this.baseUrl,\n apiKey: this.apiKey || \"\",\n requestBody: {\n eventName: \"ExtensibilityDownloadImageButtonClick\",\n nonprofitId: this.nonprofitId,\n storeId: this.storeId,\n timestamp: Date.now(),\n transactionId: Number(this.transactionId),\n },\n }).catch(() => null);\n } else {\n console.error(\"Missing data for social share analytics. Skipping send\");\n }\n const target = event.currentTarget as HTMLAnchorElement;\n if (this.isMobile && this.shareImageUrl) {\n event.preventDefault();\n this.openSystemShareSheet(this.shareImageUrl);\n } else if (this.dataUrl) {\n target.href = this.dataUrl;\n target.download = strings[this.lang].impactShareTitle();\n }\n }\n\n render() {\n if (!this.brandName || !this.shareImageUrl || !this.dataUrl) {\n return _loading();\n }\n\n return html`\n <div class=\"share-container ${this.windowResized || this.isMobile ? \"mobile\" : \"desktop\"}\">\n <h2 class=\"share-title\">${strings[this.lang].impactShareTitle()}</h2>\n <p class=\"share-text\">${strings[this.lang].impactShareText({ brandName: this.brandName })}</p>\n <img\n data-speedsize-ignore=\"true\"\n src=\"${this.shareImageUrl}\"\n alt=\"${strings[this.lang].impactShareTitle()}\"\n class=\"share-image\"\n />\n <div class=\"share-actions\">\n <button class=\"plain-button button share-action-button\" @click=\"${this.handleClickCopy}\">\n <sl-icon\n library=\"lucide\"\n name=\"copy\"\n label=\"${strings[this.lang].impactShareCopy()}\"\n class=\"share-action-icon\"\n ></sl-icon>\n <div class=\"share-action-text\">${strings[this.lang].impactShareCopy()}</div>\n </button>\n <a\n class=\"plain-button button share-action-button plain-link\"\n download=\"${strings[this.lang].impactShareTitle()}\"\n href=\"${this.dataUrl}\"\n @click=\"${this.handleClickDownload}\"\n >\n <sl-icon\n library=\"lucide\"\n name=\"download\"\n label=\"${strings[this.lang].impactShareDownload()}\"\n class=\"share-action-icon\"\n ></sl-icon>\n <div class=\"share-action-text\">${strings[this.lang].impactShareDownload()}</div>\n </a>\n </div>\n </div>\n `;\n }\n\n static styles = [\n cssReset,\n css`\n @font-face {\n font-family: \"Mabry-Bold\";\n src: url(\"../../../assets/fonts/mabry-bold.otf\") format(\"opentype\");\n font-weight: bold;\n font-style: normal;\n }\n @font-face {\n font-family: \"Mabry-Medium\";\n src: url(\"../../../assets/fonts/mabry-medium.otf\") format(\"opentype\");\n font-weight: bold;\n font-style: normal;\n }\n :host {\n align-items: center;\n justify-content: center;\n display: flex;\n box-sizing: border-box;\n width: 100%;\n }\n\n .share-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n max-width: 700px;\n text-align: center;\n }\n\n .share-container.mobile {\n padding: 1rem;\n max-width: 100%;\n }\n\n .share-title {\n font-family: \"Mabry-Bold\", sans-serif;\n font-size: 2.5rem;\n font-weight: bold;\n word-break: break-word;\n margin: 10px 0;\n }\n\n .share-title.mobile {\n font-size: 1.5rem;\n }\n\n .share-text {\n font-family: \"Mabry-Medium\", sans-serif;\n font-size: 1.25rem;\n line-height: 1.4;\n word-break: break-word;\n margin: 10px 0;\n max-width: 500px;\n }\n\n .share-text.mobile {\n font-size: 1rem;\n }\n\n .share-image {\n border-radius: 8px;\n width: 100%;\n max-width: 300px;\n height: auto;\n display: block;\n margin: 20px auto;\n }\n\n .share-actions {\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 10px;\n align-items: center;\n margin: 20px 0;\n }\n\n .share-actions.mobile {\n flex-direction: column;\n }\n\n .share-action-button {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 10px 20px;\n border: 1px solid #ccc;\n border-radius: 4px;\n background-color: #fff;\n text-decoration: none;\n color: #333;\n cursor: pointer;\n transition:\n background-color 0.3s,\n border-color 0.3s;\n }\n\n .share-action-button:hover {\n background-color: #f0f0f0;\n border-color: #bbb;\n }\n\n .share-action-icon {\n font-size: 1.25rem;\n margin-right: 8px;\n }\n\n .share-action-text {\n font-family: \"Mabry-Medium\", sans-serif;\n font-size: 1rem;\n line-height: 1.4;\n margin-top: 5px;\n }\n\n @media (max-width: 600px) {\n .share-title {\n font-size: 1.5rem;\n }\n\n .share-text {\n font-size: 1rem;\n }\n\n .share-image {\n max-width: 240px;\n }\n\n .share-actions {\n flex-direction: row;\n width: 50%;\n margin: 10px 0;\n }\n\n .share-action-button {\n width: 100%;\n margin: 5px 0;\n }\n }\n `,\n ];\n}\n\ndefineCustomElement(BeamSocialShare);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-social-share\": BeamSocialShare;\n }\n}\n"],"names":["m","i","o","t","e","r","d","BeamSocialShare","LitElement","DEFAULT_BASE_URL","SUPPORTED_LANGUAGES","enforceConfig","getImpact","WIDGET_NAMES","error","data","file","urlToFile","imageUrl","strings","postSocialShareAnalyticsEvent","event","target","_loading","html","cssReset","css","__decorateClass","property","state","defineCustomElement"],"mappings":"8fAAA,IAAAA,EAAA,OAAA,eAAAC,EAAA,CAAA,EAAAC,EAAAC,EAAAC,IAAA,CAAA,QAAAC,EAAA,OAAA,EAAA,EAAA,OAAA,EAAAC,EAAA,GAAA,EAAA,KAAAA,EAAA,EAAA,CAAA,KAAAD,EAAAC,EAAAJ,EAAAC,EAAAE,CAAA,GAAAA,GAAA,OAAAA,GAAAL,EAAAE,EAAAC,EAAAE,CAAA,EAAAA,CAAA,EAyBO,MAAME,UAAwBC,CAAW,CAAzC,aAAA,CAAA,MAAA,GAAA,SAAA,EAMuB,KAAO,QAAUC,EACjB,KAAO,KAAkB,KACxB,KAAO,MAAQ,GAGnC,KAAQ,UAA2B,KACnC,KAAQ,cAA+B,KAGvC,KAAQ,SAAW,GACnB,KAAQ,cAAgB,GAiBjC,KAAA,cAAgB,IAAM,CACpB,KAAK,cAAgB,OAAO,YAAc,GAC5C,CAAA,CAjBA,IAAI,YAAa,CACf,OAAOC,EAAoB,KAAK,IAAI,GAAK,IAC3C,CAEA,mBAAoB,CAClB,MAAM,kBAAA,EACN,OAAO,iBAAiB,SAAU,KAAK,aAAa,EACpD,KAAK,cAAA,CACP,CAEA,sBAAuB,CACrB,OAAO,oBAAoB,SAAU,KAAK,aAAa,EACvD,MAAM,qBAAA,CACR,CAMA,MAAc,iBAAkB,CACzBC,EAA8B,CAAC,SAAU,UAAW,aAAa,EAAG,IAAI,EAG7E,GAAI,CAc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EAeM,UAAA,UAAA,EACAoB,EAAA,CAAhBE,GAAM,EAhBItB,EAgBM,UAAA,eAAA,EAgVnBuB,EAAoBvB,CAAe"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as lit_html from 'lit-html';
|
|
2
|
+
import * as lit from 'lit';
|
|
3
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
4
|
+
import { b as TNumericId, L as LANGUAGES } from '../chunks/utils-D8HO_RIu.esm.js';
|
|
5
|
+
import 'lodash-es/debounce';
|
|
6
|
+
import 'lodash-es/isEqual';
|
|
7
|
+
|
|
8
|
+
interface RequiredDataPropsWithEmail {
|
|
9
|
+
email: string;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
subscriptionId: string;
|
|
12
|
+
}
|
|
13
|
+
interface RequiredDataPropsWithPartnerUserId {
|
|
14
|
+
partnerUserId: string;
|
|
15
|
+
apiKey: string;
|
|
16
|
+
subscriptionId: string;
|
|
17
|
+
}
|
|
18
|
+
declare class BeamSubscriberSelectNonprofit extends LitElement {
|
|
19
|
+
static tagName: string;
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
apiKey: string;
|
|
22
|
+
subscriptionId: string;
|
|
23
|
+
storeId?: number;
|
|
24
|
+
email?: RequiredDataPropsWithEmail["email"];
|
|
25
|
+
partnerUserId?: RequiredDataPropsWithPartnerUserId["partnerUserId"];
|
|
26
|
+
postalCode?: string;
|
|
27
|
+
countryCode?: string;
|
|
28
|
+
selectedNonprofitId?: TNumericId;
|
|
29
|
+
preselectNonprofitAtIndex?: number;
|
|
30
|
+
lang: LANGUAGES;
|
|
31
|
+
debug: boolean;
|
|
32
|
+
draftConfig: boolean;
|
|
33
|
+
templateData: Record<string, any>;
|
|
34
|
+
private chain;
|
|
35
|
+
private subscriptionLookup;
|
|
36
|
+
get configLang(): LANGUAGES;
|
|
37
|
+
private getChainNonprofits;
|
|
38
|
+
private fetchSubscription;
|
|
39
|
+
private updateNonprofitForSubscription;
|
|
40
|
+
private nonprofitListDataController;
|
|
41
|
+
private subscriptionDataController;
|
|
42
|
+
private selectionDataController;
|
|
43
|
+
private getNonprofitById;
|
|
44
|
+
connectedCallback(): Promise<void>;
|
|
45
|
+
firstUpdated(): Promise<void>;
|
|
46
|
+
updated(changedProperties: PropertyValues): Promise<void>;
|
|
47
|
+
disconnectedCallback(): void;
|
|
48
|
+
private makeHandleSelect;
|
|
49
|
+
get cssVariables(): any;
|
|
50
|
+
static styles: lit.CSSResult[];
|
|
51
|
+
protected render(): "" | lit_html.TemplateResult<1>;
|
|
52
|
+
}
|
|
53
|
+
declare global {
|
|
54
|
+
interface HTMLElementTagNameMap {
|
|
55
|
+
"beam-subscriber-select-nonprofit": BeamSubscriberSelectNonprofit;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { BeamSubscriberSelectNonprofit };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import{h as A,i as E,n as b,r as T,a as L,b as N,k as H,j as U}from"../chunks/lit-BEag9MFp.esm.js";import{e as P,u as h,D as B,j as z,W as D,k as _,l as W,m as K,A as C,S as O,f as g,h as R,_ as j,d as k}from"../chunks/index-DhHhFTBE.esm.js";import{c as F,d as q,e as w}from"../chunks/css-card-grid-BUidQqf0.esm.js";import{t as v,B as G}from"../chunks/utils-BjhsDvuU.esm.js";import{a as V}from"../chunks/share-button-7sI6zg-x.esm.js";import{c as J}from"../chunks/responsive-aN8P5PqD.esm.js";import{h as o,g as $}from"../chunks/handlebars-B_i-to-h.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";const M={long:"dddd, MMMM D, YYYY",short:"MMM D, YYYY",numeric:"MM/DD/YYYY",iso:"YYYY-MM-DD",time:"h:mm A",time24:"HH:mm",datetime:"MMMM D, YYYY h:mm A",month:"MMMM YYYY",monthShort:"MMM YYYY",dayMonth:"MMMM D"},x=(t,e)=>{const r=M[e??"long"]??e??M.long;return $(t).format(r)};o.registerHelper("currentDate",t=>x(new Date,typeof t=="string"?t:void 0)),o.registerHelper("nextMonth",t=>{const e=$().add(1,"month").toDate();return x(e,typeof t=="string"?t:void 0)}),o.registerHelper("dateOffset",(t,e,r)=>{const s=typeof e=="string"?e:void 0,i=(typeof e=="string"?r:e)?.hash?.from,n=i?new Date(i):new Date,p=$(n).add(t,"day").toDate();return s==="relative"?t===-1?"yesterday":t===0?"today":t===1?"tomorrow":t<0?`${Math.abs(t)} days ago`:`${t} days from now`:x(p,s)}),o.registerHelper("formatDate",(t,e)=>{const r=t instanceof Date?t:new Date(t);return isNaN(r.getTime())?"":x(r,typeof e=="string"?e:void 0)}),o.registerHelper("color",(t,e)=>{const r=o.escapeExpression(e),s=o.escapeExpression(t);return new o.SafeString(`<span style="color:${s}">${r}</span>`)}),o.registerHelper("br",()=>new o.SafeString("<br>")),o.registerHelper("bold",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<strong>${e}</strong>`)}),o.registerHelper("italic",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<em>${e}</em>`)}),o.registerHelper("underline",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-decoration:underline">${e}</span>`)}),o.registerHelper("strikethrough",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<s>${e}</s>`)}),o.registerHelper("uppercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:uppercase">${e}</span>`)}),o.registerHelper("lowercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:lowercase">${e}</span>`)}),o.registerHelper("capitalize",t=>{const e=String(t??""),r=e.charAt(0).toUpperCase()+e.slice(1);return new o.SafeString(o.escapeExpression(r))}),o.registerHelper("style",(t,e)=>{const{bold:r,italic:s,underline:i,strikethrough:n,uppercase:p,lowercase:a,color:m,fontSize:f,fontFamily:y}=e.hash;let d=o.escapeExpression(t);r&&(d=`<strong>${d}</strong>`),s&&(d=`<em>${d}</em>`),n&&(d=`<s>${d}</s>`);const u=[];return i&&u.push("text-decoration:underline"),p&&u.push("text-transform:uppercase"),a&&u.push("text-transform:lowercase"),m&&u.push(`color:${o.escapeExpression(m)}`),f&&u.push(`font-size:${o.escapeExpression(f)}`),y&&u.push(`font-family:${o.escapeExpression(y)}`),u.length&&(d=`<span style="${u.join(";")}">${d}</span>`),new o.SafeString(d)});const Q="en",Y=(t,e={},r="")=>{const s=e.lang||Q,i=t||r,n=P(s,i)??i;return o.compile(n)(e)},S=(t,e={},r="")=>A(Y(t,e,r)),I={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},es:{beamAttribution:()=>"Desarrollado por Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},it:{beamAttribution:()=>"Offerto da Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},pl:{beamAttribution:()=>"Wspierane przez Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`}};var X=Object.defineProperty,c=(t,e,r,s)=>{for(var i=void 0,n=t.length-1,p;n>=0;n--)(p=t[n])&&(i=p(e,r,i)||i);return i&&X(e,r,i),i};class l extends L{constructor(){super(...arguments),this.baseUrl=B,this.lang="en",this.debug=!1,this.draftConfig=!1,this.templateData={},this.chain={},this.subscriptionLookup=Promise.resolve(),this.getChainNonprofits=async()=>{w(["apiKey","subscriptionId"],this);const e=await z({baseUrl:this.baseUrl,headers:v(this.apiKey),requestBody:{storeId:this.storeId,widgetName:D.subscriber_select_nonprofit,postalCode:this.postalCode,countryCode:this.countryCode,version:"1.0.0",lang:this.configLang,options:{config:{draftConfig:this.draftConfig}}}});if(e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),await this.subscriptionLookup,this.selectedNonprofitId!=null&&!e.nonprofits.map(r=>r.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=void 0),this.selectedNonprofitId==null&&this.preselectNonprofitAtIndex!=null){const r=e.nonprofits[this.preselectNonprofitAtIndex-1];r&&(this.selectedNonprofitId=r.nonprofit.id,await this.selectionDataController.exec({selectedNonprofitId:r.nonprofit.id}))}return this.chain={...e?.chain},e},this.fetchSubscription=async()=>{w(["apiKey","subscriptionId"],this);const e=await _({baseUrl:this.baseUrl,headers:v(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return e.nonprofit?.id&&this.selectedNonprofitId===void 0&&(this.selectedNonprofitId=e.nonprofit.id),e},this.updateNonprofitForSubscription=async({selectedNonprofitId:e})=>{w(["apiKey","subscriptionId"],this);const r=await W({baseUrl:this.baseUrl,headers:v(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e,selectionMethod:K.subscriber_select_nonprofit_widget}});await this.updateComplete;const s=this.getNonprofitById(e);return this.dispatchEvent(new G({selectedNonprofitId:e,nonprofitName:s?.nonprofit?.name??null,source:D.subscriber_select_nonprofit,timestamp:new Date})),r},this.nonprofitListDataController=new C(this,this.getChainNonprofits),this.subscriptionDataController=new C(this,this.fetchSubscription),this.selectionDataController=new C(this,this.updateNonprofitForSubscription),this.makeHandleSelect=(e,r,s)=>async i=>{const n=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let p=null;switch(i.key){case"ArrowUp":case"ArrowLeft":p=r===0?s[s.length-1]:s[r-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":p=r===s.length-1?s[0]:s[r+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(p){n!=null&&(this.selectedNonprofitId=p.nonprofit.id);const a=this.renderRoot.querySelector(`[data-value="${p.nonprofit.id}"]`);a!==null&&(a.tabIndex=0,a.focus());return}}!(i.currentTarget instanceof HTMLElement)||n===e||(this.selectedNonprofitId=e,await this.selectionDataController.exec({selectedNonprofitId:e}))}}get configLang(){return O[this.lang]||"en"}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(r=>r.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),this.nonprofitListDataController.loading=!0}async firstUpdated(){!this.apiKey||!this.email&&!this.partnerUserId||(this.subscriptionLookup=this.subscriptionDataController.exec(),await this.subscriptionLookup)}async updated(e){const r=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const s of r)if(e.has(s)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...V,"--beam-SubscriberSelectNonprofit-title-textAlign":"inherit","--beam-SubscriberSelectNonprofit-description-textAlign":"inherit","--beam-SubscriberSelectNonprofit-maxWidth":"800px","--beam-SubscriberSelectNonprofit-options-marginTop":"0px","--beam-SubscriberSelectNonprofit-options-iconHeight":"20px","--beam-SubscriberSelectNonprofit-options-padding":"6px 4px","--beam-SubscriberSelectNonprofit-options-borderRadius":"4px","--beam-SubscriberSelectNonprofit-options-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-borderWidth":"1px","--beam-SubscriberSelectNonprofit-options--selected-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-backgroundColor":"transparent","--beam-SubscriberSelectNonprofit-options-gap":"8px","--beam-SubscriberSelectNonprofit-options-margin":"14px 0 0 0","--beam-SubscriberSelectNonprofit-width":"100%","--beam-SubscriberSelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SubscriberSelectNonprofit-details-marginTop":"6px","--beam-SubscriberSelectNonprofit-details-borderRadius":"4px","--beam-SubscriberSelectNonprofit-details-borderWidth":"1px","--beam-SubscriberSelectNonprofit-details-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-details-backgroundColor":"inherit","--beam-SubscriberSelectNonprofit-details-padding":"10px",...g("--beam-SubscriberSelectNonprofit-title",{fontSize:"1em",fontWeight:"bold"}),...g("--beam-SubscriberSelectNonprofit-description",{marginTop:"1em",fontSize:".85em"}),"--beam-SubscriberSelectNonprofit-title-block-margin-right":"8px",...g("--beam-SubscriberSelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold",textTransform:"uppercase"}),...g("--beam-SubscriberSelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...g("--beam-SubscriberSelectNonprofit-details-impactDescription",{fontSize:".85em",marginTop:"10px",lineHeight:"normal"}),"--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop":"10px",...g("--beam-SubscriberSelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"})},r=this.nonprofitListDataController?.data?.config?.web?.theme||{},s={...e,...r};return Object.assign(Object.create({toCSS(){return R(this)}}),s)}render(){if(!this.apiKey||!this.email&&!this.partnerUserId)return N``;const{selectedNonprofitId:e}=this,{data:r,loading:s}=this.nonprofitListDataController;if(s&&!r)return j();if(this.nonprofitListDataController.error)return this.debug?k({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return k({error:this.selectionDataController.error});const i=r?.nonprofits||[],n=i.find(a=>a.nonprofit.id===e)||null,p={custom:{...this.templateData},chain:{...this.chain},selectedNonprofit:{...n?.nonprofit},lang:this.configLang};return N`
|
|
2
|
+
<style>
|
|
3
|
+
:host {
|
|
4
|
+
${this.cssVariables.toCSS()}
|
|
5
|
+
}
|
|
6
|
+
</style>
|
|
7
|
+
<div part="heading">
|
|
8
|
+
<h3 class="title-block" part="title" id="beam-SubscriberSelectNonprofit-title">
|
|
9
|
+
${S(r?.config?.web?.title||"",p,I[this.configLang].ctaTitle())}
|
|
10
|
+
</h3>
|
|
11
|
+
<p class="description" part="description">
|
|
12
|
+
${S(r?.config?.web?.description||"",p,I[this.configLang].ctaMessage())}
|
|
13
|
+
</p>
|
|
14
|
+
</div>
|
|
15
|
+
<div
|
|
16
|
+
class="options"
|
|
17
|
+
part="options"
|
|
18
|
+
role="radiogroup"
|
|
19
|
+
aria-labelledby="beam-SubscriberSelectNonprofit-title"
|
|
20
|
+
style="display: flex; gap: var(--beam-SubscriberSelectNonprofit-options-gap); margin: var(--beam-SubscriberSelectNonprofit-options-margin, 12px 0 0 0);"
|
|
21
|
+
>
|
|
22
|
+
${H(i,a=>a.nonprofit.id,({nonprofit:a},m)=>{const f=e===a.id,y=f||n==null&&m===0,d={...p,nonprofit:a};return N`
|
|
23
|
+
<div
|
|
24
|
+
class="option"
|
|
25
|
+
part="option"
|
|
26
|
+
role="radio"
|
|
27
|
+
tabindex="${y?0:-1}"
|
|
28
|
+
data-value=${a.id}
|
|
29
|
+
aria-checked=${f}
|
|
30
|
+
@click=${this.makeHandleSelect(a.id,m,i)}
|
|
31
|
+
@keydown=${this.makeHandleSelect(a.id,m,i)}
|
|
32
|
+
aria-label="${Y(a.cause||"",d)}"
|
|
33
|
+
style="${U({cursor:"pointer",flex:"1",textAlign:"center",lineHeight:"1",marginTop:"var(--beam-SubscriberSelectNonprofit-options-marginTop, 0px)",padding:"var(--beam-SubscriberSelectNonprofit-options-padding, 6px 4px)",borderStyle:"solid",position:"relative",borderRadius:"var(--beam-SubscriberSelectNonprofit-options-borderRadius, 4px)",borderColor:f?a.causeColor||"var(--beam-SubscriberSelectNonprofit-options--selected-borderColor, currentColor)":"var(--beam-SubscriberSelectNonprofit-options-borderColor, currentColor)",borderWidth:"var(--beam-SubscriberSelectNonprofit-options-borderWidth, 1px)",backgroundColor:f?a.causeColor||"var(--beam-SubscriberSelectNonprofit-options--selected-backgroundColor, currentColor)":"var(--beam-SubscriberSelectNonprofit-options-backgroundColor, transparent)"})}"
|
|
34
|
+
>
|
|
35
|
+
<img
|
|
36
|
+
src="${f?a.causeIconSelectedUrl:a.causeIconUrl}"
|
|
37
|
+
alt=""
|
|
38
|
+
role="presentation"
|
|
39
|
+
data-speedsize-ignore="true"
|
|
40
|
+
style="
|
|
41
|
+
height: var(--beam-SubscriberSelectNonprofit-options-iconHeight, 24px);
|
|
42
|
+
user-select: none;
|
|
43
|
+
vertical-align: -webkit-baseline-middle;
|
|
44
|
+
"
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
`})}
|
|
48
|
+
</div>
|
|
49
|
+
${n!=null?N`
|
|
50
|
+
<div
|
|
51
|
+
class="details"
|
|
52
|
+
part="details"
|
|
53
|
+
style="
|
|
54
|
+
border: var(--beam-SubscriberSelectNonprofit-details-borderWidth) solid var(--beam-SubscriberSelectNonprofit-details-borderColor);
|
|
55
|
+
border-radius: var(--beam-SubscriberSelectNonprofit-details-borderRadius);
|
|
56
|
+
background-color: var(--beam-SubscriberSelectNonprofit-details-backgroundColor);
|
|
57
|
+
padding: var(--beam-SubscriberSelectNonprofit-details-padding);
|
|
58
|
+
margin-top: var(--beam-SubscriberSelectNonprofit-details-marginTop);
|
|
59
|
+
"
|
|
60
|
+
aria-label="Funding information for selected nonprofit ${n.nonprofit?.name}. Powered by Beam"
|
|
61
|
+
>
|
|
62
|
+
<div style="display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap-reverse">
|
|
63
|
+
<span
|
|
64
|
+
class="details-cause"
|
|
65
|
+
style="flex: 0 1; white-space: nowrap; ${h("--beam-SubscriberSelectNonprofit-details-cause")}"
|
|
66
|
+
>
|
|
67
|
+
${S(n.nonprofit.cause||"",p)}
|
|
68
|
+
</span>
|
|
69
|
+
<div aria-hidden="true">
|
|
70
|
+
<span
|
|
71
|
+
class="details-beamAttribution"
|
|
72
|
+
aria-hidden="true"
|
|
73
|
+
style="flex: 0 1; white-space: nowrap; ${h("--beam-SubscriberSelectNonprofit-details-beamAttribution")}"
|
|
74
|
+
>
|
|
75
|
+
${I[this.configLang].beamAttribution()}
|
|
76
|
+
</span>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
<p class="details-impactDescription">
|
|
80
|
+
${S(n.impact.description||"",p)}
|
|
81
|
+
</p>
|
|
82
|
+
<div
|
|
83
|
+
style="display: flex; margin-top: var(--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop); align-items: center;"
|
|
84
|
+
>
|
|
85
|
+
<beam-progress-bar
|
|
86
|
+
value="${n.impact.goalProgressPercentage}"
|
|
87
|
+
style="flex: 1 0;"
|
|
88
|
+
></beam-progress-bar>
|
|
89
|
+
<span
|
|
90
|
+
class="details-fundingProgressLabel"
|
|
91
|
+
style="${h("--beam-SubscriberSelectNonprofit-details-fundingProgressLabel")} white-space: nowrap; text-align: right; flex: 0 1; margin-left: 15px;"
|
|
92
|
+
>
|
|
93
|
+
${S(n.impact.goalProgressText,p)}
|
|
94
|
+
</span>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
`:""}
|
|
98
|
+
`}}l.tagName="beam-subscriber-select-nonprofit",l.styles=[F,J,E`
|
|
99
|
+
:host {
|
|
100
|
+
display: block;
|
|
101
|
+
width: var(--beam-SubscriberSelectNonprofit-width, 100%);
|
|
102
|
+
max-width: var(--beam-SubscriberSelectNonprofit-maxWidth, 800px);
|
|
103
|
+
font-family: var(--beam-fontFamily);
|
|
104
|
+
font-style: var(--beam-fontStyle);
|
|
105
|
+
font-size: var(--beam-fontSize);
|
|
106
|
+
background-color: var(--beam-backgroundColor);
|
|
107
|
+
color: var(--beam-textColor);
|
|
108
|
+
word-break: normal;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.details-impactDescription {
|
|
112
|
+
${h("--beam-SubscriberSelectNonprofit-details-impactDescription")}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.details-impactDescription .nonprofitName {
|
|
116
|
+
font-weight: var(--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight);
|
|
117
|
+
font-style: var(--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle, inherit);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.title-block {
|
|
121
|
+
margin-right: var(--beam-SubscriberSelectNonprofit-title-block-margin-right);
|
|
122
|
+
${h("--beam-SubscriberSelectNonprofit-title")}
|
|
123
|
+
text-align: var(--beam-SubscriberSelectNonprofit-title-textAlign);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.description {
|
|
127
|
+
${h("--beam-SubscriberSelectNonprofit-description")}
|
|
128
|
+
text-align: var(--beam-SubscriberSelectNonprofit-description-textAlign);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.option {
|
|
132
|
+
display: flex;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
align-items: center;
|
|
135
|
+
}
|
|
136
|
+
`],c([b({type:String})],l.prototype,"baseUrl"),c([b({type:String})],l.prototype,"apiKey"),c([b({type:String})],l.prototype,"subscriptionId"),c([b({type:Number,reflect:!0})],l.prototype,"storeId"),c([b({type:String})],l.prototype,"email"),c([b({type:String})],l.prototype,"partnerUserId"),c([b({type:String})],l.prototype,"postalCode"),c([b({type:String})],l.prototype,"countryCode"),c([b({type:Number,reflect:!0})],l.prototype,"selectedNonprofitId"),c([b({type:Number})],l.prototype,"preselectNonprofitAtIndex"),c([b({type:String})],l.prototype,"lang"),c([b({type:Boolean})],l.prototype,"debug"),c([b({type:Boolean})],l.prototype,"draftConfig"),c([b({type:Object})],l.prototype,"templateData"),c([T()],l.prototype,"chain"),q(l);export{l as BeamSubscriberSelectNonprofit};
|
|
137
|
+
//# sourceMappingURL=subscriber-select-nonprofit.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriber-select-nonprofit.esm.js","sources":["../../src/shared/handlebars-helpers.ts","../../src/shared/fragments/user-strings.ts","../../src/components/subscriber-select-nonprofit/strings.ts","../../src/components/subscriber-select-nonprofit/index.ts"],"sourcesContent":["import * as Handlebars from \"handlebars\";\nimport dayjs from \"dayjs\";\n\n// ── Date helpers ────────────────────────────────────────────────────────────\n\n// Named presets so callers don't need to remember dayjs tokens\nconst PRESETS: Record<string, string> = {\n long: \"dddd, MMMM D, YYYY\", // Sunday, June 15, 2026\n short: \"MMM D, YYYY\", // Jun 15, 2026\n numeric: \"MM/DD/YYYY\", // 06/15/2026\n iso: \"YYYY-MM-DD\", // 2026-06-15\n time: \"h:mm A\", // 3:45 PM\n time24: \"HH:mm\", // 15:45\n datetime: \"MMMM D, YYYY h:mm A\", // June 15, 2026 3:45 PM\n month: \"MMMM YYYY\", // June 2026\n monthShort: \"MMM YYYY\", // Jun 2026\n dayMonth: \"MMMM D\", // June 15\n};\n\nconst formatDate = (date: Date, fmt?: string): string => {\n const resolved = PRESETS[fmt ?? \"long\"] ?? fmt ?? PRESETS.long;\n return dayjs(date).format(resolved);\n};\n\n/**\n * Accepts named presets or any dayjs format string.\n *\n * Presets: long · short · numeric · iso · time · time24 · datetime · month · monthShort · dayMonth\n * Tokens: any dayjs format string, e.g. \"Do [of] MMMM\" → \"15th of June\"\n *\n * {{currentDate}} → \"Sunday, June 15, 2026\"\n * {{currentDate \"short\"}} → \"Jun 15, 2026\"\n * {{currentDate \"iso\"}} → \"2026-06-15\"\n * {{currentDate \"time\"}} → \"3:45 PM\"\n * {{currentDate \"Do [of] MMMM\"}} → \"15th of June\"\n */\nHandlebars.registerHelper(\"currentDate\", (format?: string) => {\n return formatDate(new Date(), typeof format === \"string\" ? format : undefined);\n});\n\n/**\n * {{nextMonth}} → \"Wednesday, July 15, 2026\"\n * {{nextMonth \"short\"}} → \"Jul 15, 2026\"\n * {{nextMonth \"iso\"}} → \"2026-07-15\"\n * {{nextMonth \"month\"}} → \"July 2026\"\n *\n * Advances by one calendar month, clamping to the last day of the target month\n * (e.g. Jan 31 → Feb 28).\n */\nHandlebars.registerHelper(\"nextMonth\", (format?: string) => {\n // dayjs clamps month-end naturally (e.g. Jan 31 → Feb 28)\n const target = dayjs().add(1, \"month\").toDate();\n return formatDate(target, typeof format === \"string\" ? format : undefined);\n});\n\n/**\n * {{dateOffset -1}} → \"Saturday, June 14, 2026\"\n * {{dateOffset 1}} → \"Monday, June 16, 2026\"\n * {{dateOffset -1 \"relative\"}} → \"yesterday\"\n * {{dateOffset 0 \"relative\"}} → \"today\"\n * {{dateOffset 1 \"relative\"}} → \"tomorrow\"\n * {{dateOffset -7 \"relative\"}} → \"7 days ago\"\n * {{dateOffset 7 \"relative\"}} → \"7 days from now\"\n * {{dateOffset 7 \"short\"}} → \"Jun 22, 2026\"\n * {{dateOffset 7 \"Do [of] MMMM\"}} → \"22nd of June\"\n * {{dateOffset -30 \"iso\"}} → \"2026-05-16\"\n * {{dateOffset 7 from=orderDate}} → \"Sunday, June 22, 2026\" (7 days after orderDate)\n * {{dateOffset 7 \"short\" from=orderDate}} → \"Jun 22, 2026\" (7 days after orderDate)\n *\n * `from` accepts a Date object, ISO string, or timestamp number.\n */\nHandlebars.registerHelper(\n \"dateOffset\",\n (days: number, format?: string | Handlebars.HelperOptions, options?: Handlebars.HelperOptions) => {\n const fmt = typeof format === \"string\" ? format : undefined;\n const opts = typeof format === \"string\" ? options : (format as Handlebars.HelperOptions);\n const fromVal = opts?.hash?.from;\n const baseDate = fromVal ? new Date(fromVal as string | number) : new Date();\n const d = dayjs(baseDate).add(days, \"day\").toDate();\n\n if (fmt === \"relative\") {\n if (days === -1) return \"yesterday\";\n if (days === 0) return \"today\";\n if (days === 1) return \"tomorrow\";\n return days < 0 ? `${Math.abs(days)} days ago` : `${days} days from now`;\n }\n\n return formatDate(d, fmt);\n },\n);\n\n/**\n * Format a date value from context using any preset or date-fns format string.\n * Accepts a Date object, ISO string, or timestamp number.\n *\n * {{formatDate orderDate \"short\"}} → \"Jun 15, 2026\"\n * {{formatDate orderDate \"iso\"}} → \"2026-06-15\"\n * {{formatDate orderDate \"Do [of] MMMM\"}} → \"15th of June\"\n * {{formatDate orderDate}} → \"Sunday, June 15, 2026\"\n */\nHandlebars.registerHelper(\"formatDate\", (value: unknown, format?: string) => {\n const date = value instanceof Date ? value : new Date(value as string | number);\n if (isNaN(date.getTime())) return \"\";\n return formatDate(date, typeof format === \"string\" ? format : undefined);\n});\n\n// ── Color helper ─────────────────────────────────────────────────────────────\n\n/**\n * {{color \"red\" \"Sale ends today!\"}}\n * {{color \"#ff6600\" someVar}}\n *\n * Accepts any valid CSS color value (named color, hex, rgb(), hsl(), etc.).\n */\nHandlebars.registerHelper(\"color\", (colorValue: string, text: unknown) => {\n const escaped = Handlebars.escapeExpression(text as any);\n const safeColor = Handlebars.escapeExpression(colorValue);\n return new Handlebars.SafeString(`<span style=\"color:${safeColor}\">${escaped}</span>`);\n});\n\n// ── Layout helpers ───────────────────────────────────────────────────────────\n\n/** {{br}} → inserts a line break */\nHandlebars.registerHelper(\"br\", () => new Handlebars.SafeString(\"<br>\"));\n\n// ── Font-style helpers ────────────────────────────────────────────────────────\n\n/** {{bold \"Important!\"}} */\nHandlebars.registerHelper(\"bold\", (text: unknown) => {\n const escaped = Handlebars.escapeExpression(text as any);\n return new Handlebars.SafeString(`<strong>${escaped}</strong>`);\n});\n\n/** {{italic \"Note:\"}} */\nHandlebars.registerHelper(\"italic\", (text: unknown) => {\n const escaped = Handlebars.escapeExpression(text as any);\n return new Handlebars.SafeString(`<em>${escaped}</em>`);\n});\n\n/** {{underline \"Click here\"}} */\nHandlebars.registerHelper(\"underline\", (text: unknown) => {\n const escaped = Handlebars.escapeExpression(text as any);\n return new Handlebars.SafeString(`<span style=\"text-decoration:underline\">${escaped}</span>`);\n});\n\n/** {{strikethrough \"Was $99\"}} */\nHandlebars.registerHelper(\"strikethrough\", (text: unknown) => {\n const escaped = Handlebars.escapeExpression(text as any);\n return new Handlebars.SafeString(`<s>${escaped}</s>`);\n});\n\n/** {{uppercase \"hello\"}} → renders as \"HELLO\" via CSS so the source text is preserved */\nHandlebars.registerHelper(\"uppercase\", (text: unknown) => {\n const escaped = Handlebars.escapeExpression(text as any);\n return new Handlebars.SafeString(`<span style=\"text-transform:uppercase\">${escaped}</span>`);\n});\n\n/** {{lowercase \"HELLO\"}} */\nHandlebars.registerHelper(\"lowercase\", (text: unknown) => {\n const escaped = Handlebars.escapeExpression(text as any);\n return new Handlebars.SafeString(`<span style=\"text-transform:lowercase\">${escaped}</span>`);\n});\n\n/**\n * {{capitalize \"hello world\"}} → \"Hello world\" (first letter only — use uppercase for ALL CAPS)\n * Note: CSS text-transform:capitalize uppercases every word; this helper only touches the first character.\n */\nHandlebars.registerHelper(\"capitalize\", (text: unknown) => {\n const str = String(text ?? \"\");\n const capitalized = str.charAt(0).toUpperCase() + str.slice(1);\n return new Handlebars.SafeString(Handlebars.escapeExpression(capitalized));\n});\n\n/**\n * Combine multiple styles at once.\n *\n * {{style text bold=true italic=true color=\"#333\" underline=true strikethrough=false fontSize=\"16px\" fontFamily=\"Georgia, serif\"}}\n */\nHandlebars.registerHelper(\n \"style\",\n (\n text: unknown,\n options: Handlebars.HelperOptions & {\n hash: {\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strikethrough?: boolean;\n uppercase?: boolean;\n lowercase?: boolean;\n color?: string;\n fontSize?: string;\n fontFamily?: string;\n };\n },\n ) => {\n const { bold, italic, underline, strikethrough, uppercase, lowercase, color, fontSize, fontFamily } = options.hash;\n\n let content = Handlebars.escapeExpression(text as any);\n\n if (bold) content = `<strong>${content}</strong>`;\n if (italic) content = `<em>${content}</em>`;\n if (strikethrough) content = `<s>${content}</s>`;\n\n const cssProps: string[] = [];\n if (underline) cssProps.push(\"text-decoration:underline\");\n if (uppercase) cssProps.push(\"text-transform:uppercase\");\n if (lowercase) cssProps.push(\"text-transform:lowercase\");\n if (color) cssProps.push(`color:${Handlebars.escapeExpression(color)}`);\n if (fontSize) cssProps.push(`font-size:${Handlebars.escapeExpression(fontSize)}`);\n if (fontFamily) cssProps.push(`font-family:${Handlebars.escapeExpression(fontFamily)}`);\n\n if (cssProps.length) {\n content = `<span style=\"${cssProps.join(\";\")}\">${content}</span>`;\n }\n\n return new Handlebars.SafeString(content);\n },\n);\n\nexport { Handlebars };\n","import { unsafeHTML } from \"lit/directives/unsafe-html.js\";\nimport { Handlebars } from \"../handlebars-helpers\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { localizeUserString } from \"../localize\";\n\nconst DEFAULT_LANGUAGE_CODE = \"en\";\n\n/**\n * Compile a string through Handlebars and return the raw HTML string.\n * If `context.lang` is set, the string is first passed through localizeUserString\n * so JSON-encoded multilingual strings ({\"en\":\"...\",\"fr\":\"...\"}) are resolved\n * before Handlebars processes them — no call to localizeUserString needed at call sites.\n */\nconst compileUserString = (str: string, context: Record<string, unknown> = {}, fallback = \"\"): string => {\n const lang = (context.lang || DEFAULT_LANGUAGE_CODE) as LANGUAGES;\n const source = str || fallback;\n const localized = localizeUserString(lang, source) ?? source;\n return Handlebars.compile(localized)(context);\n};\n\n/**\n * Compile a string through Handlebars and return a Lit TemplateResult safe for rendering HTML.\n * Equivalent to unsafeHTML(compileUserString(str, context, fallback)).\n */\nconst renderUserString = (str: string, context: Record<string, unknown> = {}, fallback = \"\") =>\n unsafeHTML(compileUserString(str, context, fallback));\n\nexport { compileUserString, renderUserString };\n","export const strings = {\n en: {\n beamAttribution: () => `Powered by Beam`,\n ctaTitle: () => `Choose Your Impact`,\n ctaMessage: ({ donationPercentage = \"1%\" } = {}) =>\n `Choose a nonprofit and ${donationPercentage} will be donated there for you,at no extra cost, with every order of your subscription.`,\n },\n fr: {\n beamAttribution: () => `Optimisé par Beam`,\n ctaTitle: () => `Choose Your Impact`,\n ctaMessage: ({ donationPercentage = \"1%\" } = {}) =>\n `Choose a nonprofit and ${donationPercentage} will be donated there for you,at no extra cost, with every order of your subscription.`,\n },\n de: {\n beamAttribution: () => `Unterstützt von Beam`,\n ctaTitle: () => `Choose Your Impact`,\n ctaMessage: ({ donationPercentage = \"1%\" } = {}) =>\n `Choose a nonprofit and ${donationPercentage} will be donated there for you,at no extra cost, with every order of your subscription.`,\n },\n es: {\n beamAttribution: () => `Desarrollado por Beam`,\n ctaTitle: () => `Choose Your Impact`,\n ctaMessage: ({ donationPercentage = \"1%\" } = {}) =>\n `Choose a nonprofit and ${donationPercentage} will be donated there for you,at no extra cost, with every order of your subscription.`,\n },\n it: {\n beamAttribution: () => `Offerto da Beam`,\n ctaTitle: () => `Choose Your Impact`,\n ctaMessage: ({ donationPercentage = \"1%\" } = {}) =>\n `Choose a nonprofit and ${donationPercentage} will be donated there for you,at no extra cost, with every order of your subscription.`,\n },\n pl: {\n beamAttribution: () => `Wspierane przez Beam`,\n ctaTitle: () => `Choose Your Impact`,\n ctaMessage: ({ donationPercentage = \"1%\" } = {}) =>\n `Choose a nonprofit and ${donationPercentage} will be donated there for you,at no extra cost, with every order of your subscription.`,\n },\n ja: {\n beamAttribution: () => `Powered by Beam`,\n ctaTitle: () => `Choose Your Impact`,\n ctaMessage: ({ donationPercentage = \"1%\" } = {}) =>\n `Choose a nonprofit and ${donationPercentage} will be donated there for you,at no extra cost, with every order of your subscription.`,\n },\n};\n","import { css, html, LitElement, PropertyValues } from \"lit\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { property } from \"lit/decorators/property.js\";\nimport { styleMap } from \"lit/directives/style-map.js\";\nimport { state } from \"lit/decorators/state.js\";\nimport { AsyncController } from \"../../shared/controllers/async-controller\";\nimport { DEFAULT_BASE_URL, SELECTION_METHODS, SUPPORTED_LANGUAGES, WIDGET_NAMES } from \"../../api-sdk/constants\";\nimport { defineCustomElement } from \"../../shared/defineCustomElement\";\nimport { _loading } from \"../../shared/fragments/loading-template\";\nimport { _errorMessage } from \"../../shared/fragments/error-message-template\";\nimport { defineCustomText, useCustomText } from \"../../shared/fragments/custom-text\";\nimport { cssReset } from \"../../shared/css-reset\";\nimport { _cssVariableMap } from \"../../shared/fragments/css-variable-map\";\nimport { enforceConfig } from \"../../shared/enforce-config\";\nimport { MissingConfig } from \"../../utils/beam-errors\";\nimport { TNumericId } from \"../../shared/types\";\nimport {\n postChainEligibleNonprofitsForCart,\n postFindOrCreateSubscription,\n updateSubscription,\n} from \"../../api-sdk/v3/routes\";\nimport { LANGUAGES } from \"../../api-sdk/types\";\nimport { BeamNonprofitSelectEvent } from \"../../utils/events\";\nimport { progressBarConfigDefaults } from \"../../shared/components/progress-bar\";\nimport { cssResponsiveUtils } from \"../../shared/responsive\";\nimport { makeApiKeyHeader } from \"../../utils/makeApiKeyHeader\";\nimport { compileUserString, renderUserString } from \"../../shared/fragments/user-strings\";\nimport { strings } from \"./strings\";\n\ninterface RequiredDataPropsWithEmail {\n email: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ninterface RequiredDataPropsWithPartnerUserId {\n partnerUserId: string;\n apiKey: string;\n subscriptionId: string;\n}\n\ninterface RequiredConfig {\n apiKey: string;\n subscriptionId: string;\n}\n\nexport class BeamSubscriberSelectNonprofit extends LitElement {\n static tagName = \"beam-subscriber-select-nonprofit\";\n\n @property({ type: String }) public baseUrl: string = DEFAULT_BASE_URL;\n @property({ type: String }) public apiKey!: string;\n @property({ type: String }) public subscriptionId!: string;\n @property({ type: Number, reflect: true }) public storeId?: number;\n @property({ type: String }) public email?: RequiredDataPropsWithEmail[\"email\"];\n @property({ type: String }) public partnerUserId?: RequiredDataPropsWithPartnerUserId[\"partnerUserId\"];\n @property({ type: String }) public postalCode?: string;\n @property({ type: String }) public countryCode?: string;\n @property({ type: Number, reflect: true }) public selectedNonprofitId?: TNumericId;\n @property({ type: Number }) public preselectNonprofitAtIndex?: number;\n @property({ type: String }) public lang: LANGUAGES = \"en\";\n @property({ type: Boolean }) public debug = false;\n @property({ type: Boolean }) public draftConfig = false;\n @property({ type: Object }) public templateData: Record<string, any> = {};\n @state() private chain: Record<string, any> = {};\n\n // Resolves once the subscription find/create lookup (if any) has settled, so nonprofit\n // list handling can tell whether the subscriber already has a saved selection\n private subscriptionLookup: Promise<unknown> = Promise.resolve();\n\n get configLang() {\n return SUPPORTED_LANGUAGES[this.lang] || \"en\";\n }\n\n private getChainNonprofits = async () => {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"subscriptionId\"], this)) {\n throw new MissingConfig();\n }\n\n const res = await postChainEligibleNonprofitsForCart({\n baseUrl: this.baseUrl,\n headers: makeApiKeyHeader(this.apiKey),\n requestBody: {\n storeId: this.storeId,\n widgetName: WIDGET_NAMES.subscriber_select_nonprofit,\n postalCode: this.postalCode,\n countryCode: this.countryCode,\n version: \"1.0.0\",\n lang: this.configLang,\n options: {\n config: {\n draftConfig: this.draftConfig,\n },\n },\n },\n });\n\n if (res.store?.id && res.store.id !== this.storeId) {\n this.storeId = res.store.id;\n }\n\n // Wait for the subscription to be found/created (if applicable) so we know whether\n // it already has a saved nonprofit selection before we clear or preselect one\n await this.subscriptionLookup;\n\n // Clear selection if the saved nonprofit is no longer in the eligible list\n if (\n this.selectedNonprofitId != null &&\n !res.nonprofits.map((np) => np.nonprofit.id).includes(this.selectedNonprofitId)\n ) {\n this.selectedNonprofitId = undefined;\n }\n\n // Auto-select the nonprofit at the given 1-based position if there is no existing selection\n if (this.selectedNonprofitId == null && this.preselectNonprofitAtIndex != null) {\n const preselectedNonprofit = res.nonprofits[this.preselectNonprofitAtIndex - 1];\n if (preselectedNonprofit) {\n this.selectedNonprofitId = preselectedNonprofit.nonprofit.id;\n await this.selectionDataController.exec({ selectedNonprofitId: preselectedNonprofit.nonprofit.id });\n }\n }\n\n this.chain = { ...res?.chain };\n\n return res;\n };\n\n private fetchSubscription = async () => {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"subscriptionId\"], this)) {\n throw new MissingConfig();\n }\n\n const result = await postFindOrCreateSubscription({\n baseUrl: this.baseUrl,\n headers: makeApiKeyHeader(this.apiKey),\n requestBody: {\n remoteSubscriptionId: this.subscriptionId,\n email: this.email,\n partnerUserId: this.partnerUserId,\n },\n });\n\n // Pre-populate selection from the subscription record if not already set\n if (result.nonprofit?.id && this.selectedNonprofitId === undefined) {\n this.selectedNonprofitId = result.nonprofit.id;\n }\n\n return result;\n };\n\n private updateNonprofitForSubscription = async ({ selectedNonprofitId }: { selectedNonprofitId: TNumericId }) => {\n if (!enforceConfig<RequiredConfig>([\"apiKey\", \"subscriptionId\"], this)) {\n throw new MissingConfig();\n }\n\n const result = await updateSubscription({\n baseUrl: this.baseUrl,\n headers: makeApiKeyHeader(this.apiKey),\n requestBody: {\n remoteSubscriptionId: this.subscriptionId,\n nonprofitId: selectedNonprofitId,\n selectionMethod: SELECTION_METHODS.subscriber_select_nonprofit_widget,\n },\n });\n\n await this.updateComplete;\n\n const selectedNonprofit = this.getNonprofitById(selectedNonprofitId);\n\n this.dispatchEvent(\n new BeamNonprofitSelectEvent({\n selectedNonprofitId,\n nonprofitName: selectedNonprofit?.nonprofit?.name ?? null,\n source: WIDGET_NAMES.subscriber_select_nonprofit,\n timestamp: new Date(),\n }),\n );\n\n return result;\n };\n\n private nonprofitListDataController = new AsyncController<typeof this.getChainNonprofits>(\n this,\n this.getChainNonprofits,\n );\n\n private subscriptionDataController = new AsyncController<typeof this.fetchSubscription>(this, this.fetchSubscription);\n\n private selectionDataController = new AsyncController<typeof this.updateNonprofitForSubscription>(\n this,\n this.updateNonprofitForSubscription,\n );\n\n private getNonprofitById(id: number | null) {\n if (!id) return null;\n return this.nonprofitListDataController?.data?.nonprofits.find((np) => np.nonprofit.id === id);\n }\n\n async connectedCallback() {\n super.connectedCallback();\n this.nonprofitListDataController.loading = true;\n }\n\n async firstUpdated() {\n if (!this.apiKey || (!this.email && !this.partnerUserId)) return;\n this.subscriptionLookup = this.subscriptionDataController.exec();\n await this.subscriptionLookup;\n }\n\n async updated(changedProperties: PropertyValues) {\n const requireNewDataProps = [\"baseUrl\", \"storeId\", \"apiKey\", \"countryCode\", \"postalCode\", \"lang\"];\n for (const prop of requireNewDataProps) {\n if (changedProperties.has(prop)) {\n await this.nonprofitListDataController.exec();\n break;\n }\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n }\n\n private makeHandleSelect =\n (id: number, index: number, nonprofits: { nonprofit: { id: number } }[]) => async (evt: Event) => {\n const currentId = this.selectedNonprofitId;\n if (evt instanceof KeyboardEvent) {\n let nextFocus = null;\n switch (evt.key) {\n case \"ArrowUp\":\n case \"ArrowLeft\":\n nextFocus = index === 0 ? nonprofits[nonprofits.length - 1] : nonprofits[index - 1];\n evt.preventDefault();\n break;\n case \"ArrowRight\":\n case \"ArrowDown\":\n nextFocus = index === nonprofits.length - 1 ? nonprofits[0] : nonprofits[index + 1];\n evt.preventDefault();\n break;\n case \"Enter\":\n case \" \":\n evt.preventDefault();\n break;\n default:\n return;\n }\n if (nextFocus) {\n if (currentId != null) {\n this.selectedNonprofitId = nextFocus.nonprofit.id;\n }\n const focusTarget = this.renderRoot.querySelector(`[data-value=\"${nextFocus.nonprofit.id}\"]`) as HTMLElement;\n if (focusTarget !== null) {\n focusTarget.tabIndex = 0;\n focusTarget.focus();\n }\n return;\n }\n }\n const targetEl = evt.currentTarget;\n if (!(targetEl instanceof HTMLElement) || currentId === id) return;\n this.selectedNonprofitId = id;\n await this.selectionDataController.exec({ selectedNonprofitId: id });\n };\n\n public get cssVariables() {\n const defaults = {\n \"--beam-fontFamily\": \"inherit\",\n \"--beam-fontStyle\": \"inherit\",\n \"--beam-fontSize\": \"inherit\",\n \"--beam-textColor\": \"inherit\",\n \"--beam-backgroundColor\": \"inherit\",\n ...progressBarConfigDefaults,\n \"--beam-SubscriberSelectNonprofit-title-textAlign\": \"inherit\",\n \"--beam-SubscriberSelectNonprofit-description-textAlign\": \"inherit\",\n \"--beam-SubscriberSelectNonprofit-maxWidth\": \"800px\",\n \"--beam-SubscriberSelectNonprofit-options-marginTop\": \"0px\",\n \"--beam-SubscriberSelectNonprofit-options-iconHeight\": \"20px\",\n \"--beam-SubscriberSelectNonprofit-options-padding\": \"6px 4px\",\n \"--beam-SubscriberSelectNonprofit-options-borderRadius\": \"4px\",\n \"--beam-SubscriberSelectNonprofit-options-borderColor\": \"currentColor\",\n \"--beam-SubscriberSelectNonprofit-options-borderWidth\": \"1px\",\n \"--beam-SubscriberSelectNonprofit-options--selected-borderColor\": \"currentColor\",\n \"--beam-SubscriberSelectNonprofit-options-backgroundColor\": \"transparent\",\n \"--beam-SubscriberSelectNonprofit-options-gap\": \"8px\",\n \"--beam-SubscriberSelectNonprofit-options-margin\": \"14px 0 0 0\",\n \"--beam-SubscriberSelectNonprofit-width\": \"100%\",\n \"--beam-SubscriberSelectNonprofit-options--selected-backgroundColor\": \"currentColor\",\n \"--beam-SubscriberSelectNonprofit-details-marginTop\": \"6px\",\n \"--beam-SubscriberSelectNonprofit-details-borderRadius\": \"4px\",\n \"--beam-SubscriberSelectNonprofit-details-borderWidth\": \"1px\",\n \"--beam-SubscriberSelectNonprofit-details-borderColor\": \"currentColor\",\n \"--beam-SubscriberSelectNonprofit-details-backgroundColor\": \"inherit\",\n \"--beam-SubscriberSelectNonprofit-details-padding\": \"10px\",\n ...defineCustomText(\"--beam-SubscriberSelectNonprofit-title\", {\n fontSize: \"1em\",\n fontWeight: \"bold\",\n }),\n ...defineCustomText(\"--beam-SubscriberSelectNonprofit-description\", {\n marginTop: \"1em\",\n fontSize: \".85em\",\n }),\n \"--beam-SubscriberSelectNonprofit-title-block-margin-right\": \"8px\",\n ...defineCustomText(\"--beam-SubscriberSelectNonprofit-details-cause\", {\n fontSize: \"0.85em\",\n fontWeight: \"bold\",\n textTransform: \"uppercase\",\n }),\n ...defineCustomText(\"--beam-SubscriberSelectNonprofit-details-beamAttribution\", {\n fontSize: \"0.85em\",\n }),\n ...defineCustomText(\"--beam-SubscriberSelectNonprofit-details-impactDescription\", {\n fontSize: \".85em\",\n marginTop: \"10px\",\n lineHeight: \"normal\",\n }),\n \"--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight\": \"bold\",\n \"--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle\": \"inherit\",\n \"--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop\": \"10px\",\n ...defineCustomText(\"--beam-SubscriberSelectNonprofit-details-fundingProgressLabel\", {\n fontSize: \"0.85em\",\n }),\n };\n\n const remoteConfig = this.nonprofitListDataController?.data?.config?.web?.theme || {};\n\n const config = { ...defaults, ...remoteConfig };\n\n const serializable = Object.create({\n toCSS() {\n return _cssVariableMap(this as Record<string, string>);\n },\n });\n\n return Object.assign(serializable, config);\n }\n\n static styles = [\n cssReset,\n cssResponsiveUtils,\n css`\n :host {\n display: block;\n width: var(--beam-SubscriberSelectNonprofit-width, 100%);\n max-width: var(--beam-SubscriberSelectNonprofit-maxWidth, 800px);\n font-family: var(--beam-fontFamily);\n font-style: var(--beam-fontStyle);\n font-size: var(--beam-fontSize);\n background-color: var(--beam-backgroundColor);\n color: var(--beam-textColor);\n word-break: normal;\n }\n\n .details-impactDescription {\n ${useCustomText(\"--beam-SubscriberSelectNonprofit-details-impactDescription\")}\n }\n\n .details-impactDescription .nonprofitName {\n font-weight: var(--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight);\n font-style: var(--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle, inherit);\n }\n\n .title-block {\n margin-right: var(--beam-SubscriberSelectNonprofit-title-block-margin-right);\n ${useCustomText(\"--beam-SubscriberSelectNonprofit-title\")}\n text-align: var(--beam-SubscriberSelectNonprofit-title-textAlign);\n }\n\n .description {\n ${useCustomText(\"--beam-SubscriberSelectNonprofit-description\")}\n text-align: var(--beam-SubscriberSelectNonprofit-description-textAlign);\n }\n\n .option {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n `,\n ];\n\n protected render() {\n if (!this.apiKey || (!this.email && !this.partnerUserId)) {\n return html``;\n }\n\n const { selectedNonprofitId } = this;\n const { data, loading } = this.nonprofitListDataController;\n\n if (loading && !data) {\n return _loading();\n }\n if (this.nonprofitListDataController.error) {\n if (this.debug) {\n return _errorMessage({ error: this.nonprofitListDataController.error });\n }\n return \"\";\n }\n if (this.selectionDataController.error && this.debug) {\n return _errorMessage({ error: this.selectionDataController.error });\n }\n\n const nonprofits = data?.nonprofits || [];\n const selectedNonprofit = nonprofits.find((np) => np.nonprofit.id === selectedNonprofitId) || null;\n\n const templateContext: Record<string, any> = {\n custom: { ...this.templateData },\n chain: { ...this.chain },\n selectedNonprofit: { ...selectedNonprofit?.nonprofit },\n lang: this.configLang,\n };\n\n return html`\n <style>\n :host {\n ${this.cssVariables.toCSS()}\n }\n </style>\n <div part=\"heading\">\n <h3 class=\"title-block\" part=\"title\" id=\"beam-SubscriberSelectNonprofit-title\">\n ${renderUserString(data?.config?.web?.title || \"\", templateContext, strings[this.configLang].ctaTitle())}\n </h3>\n <p class=\"description\" part=\"description\">\n ${renderUserString(\n data?.config?.web?.description || \"\",\n templateContext,\n strings[this.configLang].ctaMessage(),\n )}\n </p>\n </div>\n <div\n class=\"options\"\n part=\"options\"\n role=\"radiogroup\"\n aria-labelledby=\"beam-SubscriberSelectNonprofit-title\"\n style=\"display: flex; gap: var(--beam-SubscriberSelectNonprofit-options-gap); margin: var(--beam-SubscriberSelectNonprofit-options-margin, 12px 0 0 0);\"\n >\n ${repeat(\n nonprofits,\n (i) => i.nonprofit.id,\n ({ nonprofit }, index) => {\n const isSelected = selectedNonprofitId === nonprofit.id;\n const isFocusable = isSelected || (selectedNonprofit == null && index === 0);\n const optionTemplateContext: Record<string, any> = {\n ...templateContext,\n nonprofit,\n };\n\n return html`\n <div\n class=\"option\"\n part=\"option\"\n role=\"radio\"\n tabindex=\"${isFocusable ? 0 : -1}\"\n data-value=${nonprofit.id}\n aria-checked=${isSelected}\n @click=${this.makeHandleSelect(nonprofit.id, index, nonprofits)}\n @keydown=${this.makeHandleSelect(nonprofit.id, index, nonprofits)}\n aria-label=\"${compileUserString(nonprofit.cause || \"\", optionTemplateContext)}\"\n style=\"${styleMap({\n cursor: \"pointer\",\n flex: \"1\",\n textAlign: \"center\",\n lineHeight: \"1\",\n marginTop: \"var(--beam-SubscriberSelectNonprofit-options-marginTop, 0px)\",\n padding: \"var(--beam-SubscriberSelectNonprofit-options-padding, 6px 4px)\",\n borderStyle: \"solid\",\n position: \"relative\",\n borderRadius: \"var(--beam-SubscriberSelectNonprofit-options-borderRadius, 4px)\",\n borderColor: isSelected\n ? nonprofit.causeColor ||\n \"var(--beam-SubscriberSelectNonprofit-options--selected-borderColor, currentColor)\"\n : \"var(--beam-SubscriberSelectNonprofit-options-borderColor, currentColor)\",\n borderWidth: \"var(--beam-SubscriberSelectNonprofit-options-borderWidth, 1px)\",\n backgroundColor: isSelected\n ? nonprofit.causeColor ||\n \"var(--beam-SubscriberSelectNonprofit-options--selected-backgroundColor, currentColor)\"\n : \"var(--beam-SubscriberSelectNonprofit-options-backgroundColor, transparent)\",\n })}\"\n >\n <img\n src=\"${isSelected ? nonprofit.causeIconSelectedUrl : nonprofit.causeIconUrl}\"\n alt=\"\"\n role=\"presentation\"\n data-speedsize-ignore=\"true\"\n style=\"\n height: var(--beam-SubscriberSelectNonprofit-options-iconHeight, 24px);\n user-select: none;\n vertical-align: -webkit-baseline-middle;\n \"\n />\n </div>\n `;\n },\n )}\n </div>\n ${selectedNonprofit != null\n ? html`\n <div\n class=\"details\"\n part=\"details\"\n style=\"\n border: var(--beam-SubscriberSelectNonprofit-details-borderWidth) solid var(--beam-SubscriberSelectNonprofit-details-borderColor);\n border-radius: var(--beam-SubscriberSelectNonprofit-details-borderRadius);\n background-color: var(--beam-SubscriberSelectNonprofit-details-backgroundColor);\n padding: var(--beam-SubscriberSelectNonprofit-details-padding);\n margin-top: var(--beam-SubscriberSelectNonprofit-details-marginTop);\n \"\n aria-label=\"Funding information for selected nonprofit ${selectedNonprofit.nonprofit\n ?.name}. Powered by Beam\"\n >\n <div style=\"display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap-reverse\">\n <span\n class=\"details-cause\"\n style=\"flex: 0 1; white-space: nowrap; ${useCustomText(\n \"--beam-SubscriberSelectNonprofit-details-cause\",\n )}\"\n >\n ${renderUserString(selectedNonprofit.nonprofit.cause || \"\", templateContext)}\n </span>\n <div aria-hidden=\"true\">\n <span\n class=\"details-beamAttribution\"\n aria-hidden=\"true\"\n style=\"flex: 0 1; white-space: nowrap; ${useCustomText(\n \"--beam-SubscriberSelectNonprofit-details-beamAttribution\",\n )}\"\n >\n ${strings[this.configLang].beamAttribution()}\n </span>\n </div>\n </div>\n <p class=\"details-impactDescription\">\n ${renderUserString(selectedNonprofit.impact.description || \"\", templateContext)}\n </p>\n <div\n style=\"display: flex; margin-top: var(--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop); align-items: center;\"\n >\n <beam-progress-bar\n value=\"${selectedNonprofit.impact.goalProgressPercentage}\"\n style=\"flex: 1 0;\"\n ></beam-progress-bar>\n <span\n class=\"details-fundingProgressLabel\"\n style=\"${useCustomText(\n \"--beam-SubscriberSelectNonprofit-details-fundingProgressLabel\",\n )} white-space: nowrap; text-align: right; flex: 0 1; margin-left: 15px;\"\n >\n ${renderUserString(selectedNonprofit.impact.goalProgressText, templateContext)}\n </span>\n </div>\n </div>\n `\n : \"\"}\n `;\n }\n}\n\ndefineCustomElement(BeamSubscriberSelectNonprofit);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-subscriber-select-nonprofit\": BeamSubscriberSelectNonprofit;\n }\n}\n"],"names":["PRESETS","formatDate","date","fmt","resolved","dayjs","Handlebars","format","target","days","options","fromVal","baseDate","d","value","colorValue","text","escaped","safeColor","str","capitalized","bold","italic","underline","strikethrough","uppercase","lowercase","color","fontSize","fontFamily","content","cssProps","DEFAULT_LANGUAGE_CODE","compileUserString","context","fallback","lang","source","localized","localizeUserString","renderUserString","unsafeHTML","strings","donationPercentage","BeamSubscriberSelectNonprofit","LitElement","DEFAULT_BASE_URL","enforceConfig","res","postChainEligibleNonprofitsForCart","makeApiKeyHeader","WIDGET_NAMES","np","preselectedNonprofit","result","postFindOrCreateSubscription","selectedNonprofitId","updateSubscription","SELECTION_METHODS","selectedNonprofit","BeamNonprofitSelectEvent","AsyncController","id","index","nonprofits","evt","currentId","nextFocus","focusTarget","SUPPORTED_LANGUAGES","changedProperties","requireNewDataProps","prop","defaults","progressBarConfigDefaults","defineCustomText","remoteConfig","config","_cssVariableMap","html","data","loading","_loading","_errorMessage","templateContext","repeat","i","nonprofit","isSelected","isFocusable","optionTemplateContext","styleMap","useCustomText","cssReset","cssResponsiveUtils","css","__decorateClass","property","state","defineCustomElement"],"mappings":"olBAMA,MAAMA,EAAkC,CACtC,KAAM,qBACN,MAAO,cACP,QAAS,aACT,IAAK,aACL,KAAM,SACN,OAAQ,QACR,SAAU,sBACV,MAAO,YACP,WAAY,WACZ,SAAU,QACZ,EAEMC,EAAa,CAACC,EAAYC,IAAyB,CACvD,MAAMC,EAAWJ,EAAQG,GAAO,MAAM,GAAKA,GAAOH,EAAQ,KAC1D,OAAOK,EAAMH,CAAI,EAAE,OAAOE,CAAQ,CACpC,EAcAE,iBAA0B,cAAgBC,GACjCN,EAAW,IAAI,KAAQ,OAAOM,GAAW,SAAWA,EAAS,MAAS,CAC9E,EAWDD,EAAAA,eAA0B,YAAcC,GAAoB,CAE1D,MAAMC,EAASH,EAAAA,EAAQ,IAAI,EAAG,OAAO,EAAE,OAAA,EACvC,OAAOJ,EAAWO,EAAQ,OAAOD,GAAW,SAAWA,EAAS,MAAS,CAC3E,CAAC,EAkBDD,EAAAA,eACE,aACA,CAACG,EAAcF,EAA4CG,IAAuC,CAChG,MAAM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CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EATfrD,EASwB,UAAA,YAAA,EACAoD,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAVfrD,EAUwB,yBACeoD,EAAA,CAAjDC,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAX9BrD,EAWuC,UAAA,qBAAA,EACfoD,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,GAZfrD,EAYwB,UAAA,2BAAA,EACAoD,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,GAbfrD,EAawB,UAAA,MAAA,EACCoD,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAdhBrD,EAcyB,UAAA,OAAA,EACAoD,EAAA,CAAnCC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAAA,EAfhBrD,EAeyB,UAAA,aAAA,EACDoD,EAAA,CAAlCC,EAAS,CAAE,KAAM,MAAO,CAAC,CAAA,EAhBfrD,EAgBwB,UAAA,cAAA,EAClBoD,EAAA,CAAhBE,EAAAA,CAAM,EAjBItD,EAiBM,UAAA,OAAA,EA6enBuD,EAAoBvD,CAA6B"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import{h as A,i as E,n as b,r as T,a as L,b as N,k as H,j as U}from"../chunks/lit-BEag9MFp.esm.js";import{e as P,u as h,D as B,j as z,W as D,k as _,l as W,m as K,A as C,S as O,f as g,h as R,_ as j,d as k}from"../chunks/index-DhHhFTBE.esm.js";import{c as F,d as q,e as w}from"../chunks/css-card-grid-BUidQqf0.esm.js";import{t as v,B as G}from"../chunks/utils-BjhsDvuU.esm.js";import{a as V}from"../chunks/share-button-7sI6zg-x.esm.js";import{c as J}from"../chunks/responsive-aN8P5PqD.esm.js";import{h as o,g as $}from"../chunks/handlebars-B_i-to-h.esm.js";import"../chunks/lodash-CrMU6wKg.esm.js";const M={long:"dddd, MMMM D, YYYY",short:"MMM D, YYYY",numeric:"MM/DD/YYYY",iso:"YYYY-MM-DD",time:"h:mm A",time24:"HH:mm",datetime:"MMMM D, YYYY h:mm A",month:"MMMM YYYY",monthShort:"MMM YYYY",dayMonth:"MMMM D"},x=(t,e)=>{const r=M[e??"long"]??e??M.long;return $(t).format(r)};o.registerHelper("currentDate",t=>x(new Date,typeof t=="string"?t:void 0)),o.registerHelper("nextMonth",t=>{const e=$().add(1,"month").toDate();return x(e,typeof t=="string"?t:void 0)}),o.registerHelper("dateOffset",(t,e,r)=>{const s=typeof e=="string"?e:void 0,i=(typeof e=="string"?r:e)?.hash?.from,n=i?new Date(i):new Date,p=$(n).add(t,"day").toDate();return s==="relative"?t===-1?"yesterday":t===0?"today":t===1?"tomorrow":t<0?`${Math.abs(t)} days ago`:`${t} days from now`:x(p,s)}),o.registerHelper("formatDate",(t,e)=>{const r=t instanceof Date?t:new Date(t);return isNaN(r.getTime())?"":x(r,typeof e=="string"?e:void 0)}),o.registerHelper("color",(t,e)=>{const r=o.escapeExpression(e),s=o.escapeExpression(t);return new o.SafeString(`<span style="color:${s}">${r}</span>`)}),o.registerHelper("br",()=>new o.SafeString("<br>")),o.registerHelper("bold",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<strong>${e}</strong>`)}),o.registerHelper("italic",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<em>${e}</em>`)}),o.registerHelper("underline",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-decoration:underline">${e}</span>`)}),o.registerHelper("strikethrough",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<s>${e}</s>`)}),o.registerHelper("uppercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:uppercase">${e}</span>`)}),o.registerHelper("lowercase",t=>{const e=o.escapeExpression(t);return new o.SafeString(`<span style="text-transform:lowercase">${e}</span>`)}),o.registerHelper("capitalize",t=>{const e=String(t??""),r=e.charAt(0).toUpperCase()+e.slice(1);return new o.SafeString(o.escapeExpression(r))}),o.registerHelper("style",(t,e)=>{const{bold:r,italic:s,underline:i,strikethrough:n,uppercase:p,lowercase:a,color:m,fontSize:f,fontFamily:y}=e.hash;let d=o.escapeExpression(t);r&&(d=`<strong>${d}</strong>`),s&&(d=`<em>${d}</em>`),n&&(d=`<s>${d}</s>`);const u=[];return i&&u.push("text-decoration:underline"),p&&u.push("text-transform:uppercase"),a&&u.push("text-transform:lowercase"),m&&u.push(`color:${o.escapeExpression(m)}`),f&&u.push(`font-size:${o.escapeExpression(f)}`),y&&u.push(`font-family:${o.escapeExpression(y)}`),u.length&&(d=`<span style="${u.join(";")}">${d}</span>`),new o.SafeString(d)});const Q="en",Y=(t,e={},r="")=>{const s=e.lang||Q,i=t||r,n=P(s,i)??i;return o.compile(n)(e)},S=(t,e={},r="")=>A(Y(t,e,r)),I={en:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},fr:{beamAttribution:()=>"Optimis\xE9 par Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},de:{beamAttribution:()=>"Unterst\xFCtzt von Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},es:{beamAttribution:()=>"Desarrollado por Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},it:{beamAttribution:()=>"Offerto da Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},pl:{beamAttribution:()=>"Wspierane przez Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`},ja:{beamAttribution:()=>"Powered by Beam",ctaTitle:()=>"Choose Your Impact",ctaMessage:({donationPercentage:t="1%"}={})=>`Choose a nonprofit and ${t} will be donated there for you,at no extra cost, with every order of your subscription.`}};var X=Object.defineProperty,c=(t,e,r,s)=>{for(var i=void 0,n=t.length-1,p;n>=0;n--)(p=t[n])&&(i=p(e,r,i)||i);return i&&X(e,r,i),i};class l extends L{constructor(){super(...arguments),this.baseUrl=B,this.lang="en",this.debug=!1,this.draftConfig=!1,this.templateData={},this.chain={},this.subscriptionLookup=Promise.resolve(),this.getChainNonprofits=async()=>{w(["apiKey","subscriptionId"],this);const e=await z({baseUrl:this.baseUrl,headers:v(this.apiKey),requestBody:{storeId:this.storeId,widgetName:D.subscriber_select_nonprofit,postalCode:this.postalCode,countryCode:this.countryCode,version:"1.0.0",lang:this.configLang,options:{config:{draftConfig:this.draftConfig}}}});if(e.store?.id&&e.store.id!==this.storeId&&(this.storeId=e.store.id),await this.subscriptionLookup,this.selectedNonprofitId!=null&&!e.nonprofits.map(r=>r.nonprofit.id).includes(this.selectedNonprofitId)&&(this.selectedNonprofitId=void 0),this.selectedNonprofitId==null&&this.preselectNonprofitAtIndex!=null){const r=e.nonprofits[this.preselectNonprofitAtIndex-1];r&&(this.selectedNonprofitId=r.nonprofit.id,await this.selectionDataController.exec({selectedNonprofitId:r.nonprofit.id}))}return this.chain={...e?.chain},e},this.fetchSubscription=async()=>{w(["apiKey","subscriptionId"],this);const e=await _({baseUrl:this.baseUrl,headers:v(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,email:this.email,partnerUserId:this.partnerUserId}});return e.nonprofit?.id&&this.selectedNonprofitId===void 0&&(this.selectedNonprofitId=e.nonprofit.id),e},this.updateNonprofitForSubscription=async({selectedNonprofitId:e})=>{w(["apiKey","subscriptionId"],this);const r=await W({baseUrl:this.baseUrl,headers:v(this.apiKey),requestBody:{remoteSubscriptionId:this.subscriptionId,nonprofitId:e,selectionMethod:K.subscriber_select_nonprofit_widget}});await this.updateComplete;const s=this.getNonprofitById(e);return this.dispatchEvent(new G({selectedNonprofitId:e,nonprofitName:s?.nonprofit?.name??null,source:D.subscriber_select_nonprofit,timestamp:new Date})),r},this.nonprofitListDataController=new C(this,this.getChainNonprofits),this.subscriptionDataController=new C(this,this.fetchSubscription),this.selectionDataController=new C(this,this.updateNonprofitForSubscription),this.makeHandleSelect=(e,r,s)=>async i=>{const n=this.selectedNonprofitId;if(i instanceof KeyboardEvent){let p=null;switch(i.key){case"ArrowUp":case"ArrowLeft":p=r===0?s[s.length-1]:s[r-1],i.preventDefault();break;case"ArrowRight":case"ArrowDown":p=r===s.length-1?s[0]:s[r+1],i.preventDefault();break;case"Enter":case" ":i.preventDefault();break;default:return}if(p){n!=null&&(this.selectedNonprofitId=p.nonprofit.id);const a=this.renderRoot.querySelector(`[data-value="${p.nonprofit.id}"]`);a!==null&&(a.tabIndex=0,a.focus());return}}!(i.currentTarget instanceof HTMLElement)||n===e||(this.selectedNonprofitId=e,await this.selectionDataController.exec({selectedNonprofitId:e}))}}get configLang(){return O[this.lang]||"en"}getNonprofitById(e){return e?this.nonprofitListDataController?.data?.nonprofits.find(r=>r.nonprofit.id===e):null}async connectedCallback(){super.connectedCallback(),this.nonprofitListDataController.loading=!0}async firstUpdated(){!this.apiKey||!this.email&&!this.partnerUserId||(this.subscriptionLookup=this.subscriptionDataController.exec(),await this.subscriptionLookup)}async updated(e){const r=["baseUrl","storeId","apiKey","countryCode","postalCode","lang"];for(const s of r)if(e.has(s)){await this.nonprofitListDataController.exec();break}}disconnectedCallback(){super.disconnectedCallback()}get cssVariables(){const e={"--beam-fontFamily":"inherit","--beam-fontStyle":"inherit","--beam-fontSize":"inherit","--beam-textColor":"inherit","--beam-backgroundColor":"inherit",...V,"--beam-SubscriberSelectNonprofit-title-textAlign":"inherit","--beam-SubscriberSelectNonprofit-description-textAlign":"inherit","--beam-SubscriberSelectNonprofit-maxWidth":"800px","--beam-SubscriberSelectNonprofit-options-marginTop":"0px","--beam-SubscriberSelectNonprofit-options-iconHeight":"20px","--beam-SubscriberSelectNonprofit-options-padding":"6px 4px","--beam-SubscriberSelectNonprofit-options-borderRadius":"4px","--beam-SubscriberSelectNonprofit-options-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-borderWidth":"1px","--beam-SubscriberSelectNonprofit-options--selected-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-options-backgroundColor":"transparent","--beam-SubscriberSelectNonprofit-options-gap":"8px","--beam-SubscriberSelectNonprofit-options-margin":"14px 0 0 0","--beam-SubscriberSelectNonprofit-width":"100%","--beam-SubscriberSelectNonprofit-options--selected-backgroundColor":"currentColor","--beam-SubscriberSelectNonprofit-details-marginTop":"6px","--beam-SubscriberSelectNonprofit-details-borderRadius":"4px","--beam-SubscriberSelectNonprofit-details-borderWidth":"1px","--beam-SubscriberSelectNonprofit-details-borderColor":"currentColor","--beam-SubscriberSelectNonprofit-details-backgroundColor":"inherit","--beam-SubscriberSelectNonprofit-details-padding":"10px",...g("--beam-SubscriberSelectNonprofit-title",{fontSize:"1em",fontWeight:"bold"}),...g("--beam-SubscriberSelectNonprofit-description",{marginTop:"1em",fontSize:".85em"}),"--beam-SubscriberSelectNonprofit-title-block-margin-right":"8px",...g("--beam-SubscriberSelectNonprofit-details-cause",{fontSize:"0.85em",fontWeight:"bold",textTransform:"uppercase"}),...g("--beam-SubscriberSelectNonprofit-details-beamAttribution",{fontSize:"0.85em"}),...g("--beam-SubscriberSelectNonprofit-details-impactDescription",{fontSize:".85em",marginTop:"10px",lineHeight:"normal"}),"--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight":"bold","--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle":"inherit","--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop":"10px",...g("--beam-SubscriberSelectNonprofit-details-fundingProgressLabel",{fontSize:"0.85em"})},r=this.nonprofitListDataController?.data?.config?.web?.theme||{},s={...e,...r};return Object.assign(Object.create({toCSS(){return R(this)}}),s)}render(){if(!this.apiKey||!this.email&&!this.partnerUserId)return N``;const{selectedNonprofitId:e}=this,{data:r,loading:s}=this.nonprofitListDataController;if(s&&!r)return j();if(this.nonprofitListDataController.error)return this.debug?k({error:this.nonprofitListDataController.error}):"";if(this.selectionDataController.error&&this.debug)return k({error:this.selectionDataController.error});const i=r?.nonprofits||[],n=i.find(a=>a.nonprofit.id===e)||null,p={custom:{...this.templateData},chain:{...this.chain},selectedNonprofit:{...n?.nonprofit},lang:this.configLang};return N`
|
|
2
|
+
<style>
|
|
3
|
+
:host {
|
|
4
|
+
${this.cssVariables.toCSS()}
|
|
5
|
+
}
|
|
6
|
+
</style>
|
|
7
|
+
<div part="heading">
|
|
8
|
+
<h3 class="title-block" part="title" id="beam-SubscriberSelectNonprofit-title">
|
|
9
|
+
${S(r?.config?.web?.title||"",p,I[this.configLang].ctaTitle())}
|
|
10
|
+
</h3>
|
|
11
|
+
<p class="description" part="description">
|
|
12
|
+
${S(r?.config?.web?.description||"",p,I[this.configLang].ctaMessage())}
|
|
13
|
+
</p>
|
|
14
|
+
</div>
|
|
15
|
+
<div
|
|
16
|
+
class="options"
|
|
17
|
+
part="options"
|
|
18
|
+
role="radiogroup"
|
|
19
|
+
aria-labelledby="beam-SubscriberSelectNonprofit-title"
|
|
20
|
+
style="display: flex; gap: var(--beam-SubscriberSelectNonprofit-options-gap); margin: var(--beam-SubscriberSelectNonprofit-options-margin, 12px 0 0 0);"
|
|
21
|
+
>
|
|
22
|
+
${H(i,a=>a.nonprofit.id,({nonprofit:a},m)=>{const f=e===a.id,y=f||n==null&&m===0,d={...p,nonprofit:a};return N`
|
|
23
|
+
<div
|
|
24
|
+
class="option"
|
|
25
|
+
part="option"
|
|
26
|
+
role="radio"
|
|
27
|
+
tabindex="${y?0:-1}"
|
|
28
|
+
data-value=${a.id}
|
|
29
|
+
aria-checked=${f}
|
|
30
|
+
@click=${this.makeHandleSelect(a.id,m,i)}
|
|
31
|
+
@keydown=${this.makeHandleSelect(a.id,m,i)}
|
|
32
|
+
aria-label="${Y(a.cause||"",d)}"
|
|
33
|
+
style="${U({cursor:"pointer",flex:"1",textAlign:"center",lineHeight:"1",marginTop:"var(--beam-SubscriberSelectNonprofit-options-marginTop, 0px)",padding:"var(--beam-SubscriberSelectNonprofit-options-padding, 6px 4px)",borderStyle:"solid",position:"relative",borderRadius:"var(--beam-SubscriberSelectNonprofit-options-borderRadius, 4px)",borderColor:f?a.causeColor||"var(--beam-SubscriberSelectNonprofit-options--selected-borderColor, currentColor)":"var(--beam-SubscriberSelectNonprofit-options-borderColor, currentColor)",borderWidth:"var(--beam-SubscriberSelectNonprofit-options-borderWidth, 1px)",backgroundColor:f?a.causeColor||"var(--beam-SubscriberSelectNonprofit-options--selected-backgroundColor, currentColor)":"var(--beam-SubscriberSelectNonprofit-options-backgroundColor, transparent)"})}"
|
|
34
|
+
>
|
|
35
|
+
<img
|
|
36
|
+
src="${f?a.causeIconSelectedUrl:a.causeIconUrl}"
|
|
37
|
+
alt=""
|
|
38
|
+
role="presentation"
|
|
39
|
+
data-speedsize-ignore="true"
|
|
40
|
+
style="
|
|
41
|
+
height: var(--beam-SubscriberSelectNonprofit-options-iconHeight, 24px);
|
|
42
|
+
user-select: none;
|
|
43
|
+
vertical-align: -webkit-baseline-middle;
|
|
44
|
+
"
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
`})}
|
|
48
|
+
</div>
|
|
49
|
+
${n!=null?N`
|
|
50
|
+
<div
|
|
51
|
+
class="details"
|
|
52
|
+
part="details"
|
|
53
|
+
style="
|
|
54
|
+
border: var(--beam-SubscriberSelectNonprofit-details-borderWidth) solid var(--beam-SubscriberSelectNonprofit-details-borderColor);
|
|
55
|
+
border-radius: var(--beam-SubscriberSelectNonprofit-details-borderRadius);
|
|
56
|
+
background-color: var(--beam-SubscriberSelectNonprofit-details-backgroundColor);
|
|
57
|
+
padding: var(--beam-SubscriberSelectNonprofit-details-padding);
|
|
58
|
+
margin-top: var(--beam-SubscriberSelectNonprofit-details-marginTop);
|
|
59
|
+
"
|
|
60
|
+
aria-label="Funding information for selected nonprofit ${n.nonprofit?.name}. Powered by Beam"
|
|
61
|
+
>
|
|
62
|
+
<div style="display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap-reverse">
|
|
63
|
+
<span
|
|
64
|
+
class="details-cause"
|
|
65
|
+
style="flex: 0 1; white-space: nowrap; ${h("--beam-SubscriberSelectNonprofit-details-cause")}"
|
|
66
|
+
>
|
|
67
|
+
${S(n.nonprofit.cause||"",p)}
|
|
68
|
+
</span>
|
|
69
|
+
<div aria-hidden="true">
|
|
70
|
+
<span
|
|
71
|
+
class="details-beamAttribution"
|
|
72
|
+
aria-hidden="true"
|
|
73
|
+
style="flex: 0 1; white-space: nowrap; ${h("--beam-SubscriberSelectNonprofit-details-beamAttribution")}"
|
|
74
|
+
>
|
|
75
|
+
${I[this.configLang].beamAttribution()}
|
|
76
|
+
</span>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
<p class="details-impactDescription">
|
|
80
|
+
${S(n.impact.description||"",p)}
|
|
81
|
+
</p>
|
|
82
|
+
<div
|
|
83
|
+
style="display: flex; margin-top: var(--beam-SubscriberSelectNonprofit-details-fundingProgress-marginTop); align-items: center;"
|
|
84
|
+
>
|
|
85
|
+
<beam-progress-bar
|
|
86
|
+
value="${n.impact.goalProgressPercentage}"
|
|
87
|
+
style="flex: 1 0;"
|
|
88
|
+
></beam-progress-bar>
|
|
89
|
+
<span
|
|
90
|
+
class="details-fundingProgressLabel"
|
|
91
|
+
style="${h("--beam-SubscriberSelectNonprofit-details-fundingProgressLabel")} white-space: nowrap; text-align: right; flex: 0 1; margin-left: 15px;"
|
|
92
|
+
>
|
|
93
|
+
${S(n.impact.goalProgressText,p)}
|
|
94
|
+
</span>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
`:""}
|
|
98
|
+
`}}l.tagName="beam-subscriber-select-nonprofit",l.styles=[F,J,E`
|
|
99
|
+
:host {
|
|
100
|
+
display: block;
|
|
101
|
+
width: var(--beam-SubscriberSelectNonprofit-width, 100%);
|
|
102
|
+
max-width: var(--beam-SubscriberSelectNonprofit-maxWidth, 800px);
|
|
103
|
+
font-family: var(--beam-fontFamily);
|
|
104
|
+
font-style: var(--beam-fontStyle);
|
|
105
|
+
font-size: var(--beam-fontSize);
|
|
106
|
+
background-color: var(--beam-backgroundColor);
|
|
107
|
+
color: var(--beam-textColor);
|
|
108
|
+
word-break: normal;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.details-impactDescription {
|
|
112
|
+
${h("--beam-SubscriberSelectNonprofit-details-impactDescription")}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.details-impactDescription .nonprofitName {
|
|
116
|
+
font-weight: var(--beam-SubscriberSelectNonprofit-details-nonprofitName-fontWeight);
|
|
117
|
+
font-style: var(--beam-SubscriberSelectNonprofit-details-nonprofitName-fontStyle, inherit);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.title-block {
|
|
121
|
+
margin-right: var(--beam-SubscriberSelectNonprofit-title-block-margin-right);
|
|
122
|
+
${h("--beam-SubscriberSelectNonprofit-title")}
|
|
123
|
+
text-align: var(--beam-SubscriberSelectNonprofit-title-textAlign);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.description {
|
|
127
|
+
${h("--beam-SubscriberSelectNonprofit-description")}
|
|
128
|
+
text-align: var(--beam-SubscriberSelectNonprofit-description-textAlign);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.option {
|
|
132
|
+
display: flex;
|
|
133
|
+
justify-content: center;
|
|
134
|
+
align-items: center;
|
|
135
|
+
}
|
|
136
|
+
`],c([b({type:String})],l.prototype,"baseUrl"),c([b({type:String})],l.prototype,"apiKey"),c([b({type:String})],l.prototype,"subscriptionId"),c([b({type:Number,reflect:!0})],l.prototype,"storeId"),c([b({type:String})],l.prototype,"email"),c([b({type:String})],l.prototype,"partnerUserId"),c([b({type:String})],l.prototype,"postalCode"),c([b({type:String})],l.prototype,"countryCode"),c([b({type:Number,reflect:!0})],l.prototype,"selectedNonprofitId"),c([b({type:Number})],l.prototype,"preselectNonprofitAtIndex"),c([b({type:String})],l.prototype,"lang"),c([b({type:Boolean})],l.prototype,"debug"),c([b({type:Boolean})],l.prototype,"draftConfig"),c([b({type:Object})],l.prototype,"templateData"),c([T()],l.prototype,"chain"),q(l);export{l as BeamSubscriberSelectNonprofit};
|
|
137
|
+
//# sourceMappingURL=subscriber-select-nonprofit.js.map
|