@beamimpact/web-sdk 1.37.1 → 1.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/_share-dialog-dependencies-0yVtRIRR.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-0yVtRIRR.esm.js.map +1 -0
- package/dist/chunks/_share-dialog-dependencies-HWissVga.esm.js +2 -0
- package/dist/chunks/_share-dialog-dependencies-HWissVga.esm.js.map +1 -0
- package/dist/chunks/{cart-contents-IOhdr24g.esm.d.ts → cart-contents-dKdDg09p.esm.d.ts} +1 -1
- package/dist/chunks/{css-card-grid-3b56QBzq.esm.js → css-card-grid-inRnKSWs.esm.js} +2 -2
- package/dist/chunks/{css-card-grid-3b56QBzq.esm.js.map → css-card-grid-inRnKSWs.esm.js.map} +1 -1
- package/dist/chunks/{enforce-config-qna7hEL6.esm.js → enforce-config-7R9KCF_i.esm.js} +2 -2
- package/dist/chunks/{enforce-config-qna7hEL6.esm.js.map → enforce-config-7R9KCF_i.esm.js.map} +1 -1
- package/dist/chunks/{enforce-config-fo8kIfoY.esm.js → enforce-config-iFdf1QkH.esm.js} +2 -2
- package/dist/chunks/{enforce-config-fo8kIfoY.esm.js.map → enforce-config-iFdf1QkH.esm.js.map} +1 -1
- package/dist/chunks/events-Y8fYvSqM.esm.js.map +1 -1
- package/dist/chunks/{events-j-SJ9Cot.esm.d.ts → events-zF9NDtBD.esm.d.ts} +2 -1
- package/dist/chunks/{index-9YcaEQju.esm.js → index-6iInzwnG.esm.js} +2 -2
- package/dist/chunks/{index-9YcaEQju.esm.js.map → index-6iInzwnG.esm.js.map} +1 -1
- package/dist/chunks/{index-3F_Wjm5v.esm.d.ts → index-EjqeU7Mu.esm.d.ts} +1 -1
- package/dist/chunks/index-FsVWk2WD.esm.js +2 -0
- package/dist/chunks/index-FsVWk2WD.esm.js.map +1 -0
- package/dist/chunks/index-IKTofhFw.esm.js +2 -0
- package/dist/chunks/index-IKTofhFw.esm.js.map +1 -0
- package/dist/chunks/index-IWF7IfQk.esm.js +2 -0
- package/dist/chunks/index-IWF7IfQk.esm.js.map +1 -0
- package/dist/chunks/index-MG0WE1Fz.esm.js +2 -0
- package/dist/chunks/index-MG0WE1Fz.esm.js.map +1 -0
- package/dist/chunks/index-NU6RpwSa.esm.js +2 -0
- package/dist/chunks/index-NU6RpwSa.esm.js.map +1 -0
- package/dist/chunks/index-QrlkSlnv.esm.js +2 -0
- package/dist/chunks/index-QrlkSlnv.esm.js.map +1 -0
- package/dist/chunks/{index-s8uQH63W.esm.d.ts → index-Tnwxn22c.esm.d.ts} +4 -4
- package/dist/chunks/{index-vpkWmZo_.esm.js → index-UCh8HjVN.esm.js} +2 -2
- package/dist/chunks/{index-vpkWmZo_.esm.js.map → index-UCh8HjVN.esm.js.map} +1 -1
- package/dist/chunks/{index-Gz7Q9nUW.esm.js → index-_WQFoMIz.esm.js} +2 -2
- package/dist/chunks/{index-Gz7Q9nUW.esm.js.map → index-_WQFoMIz.esm.js.map} +1 -1
- package/dist/chunks/{index-yXqJ9Znv.esm.d.ts → index-cRyQ6D5G.esm.d.ts} +1 -1
- package/dist/chunks/{index-mWnpDGl1.esm.d.ts → index-dDBsHD_s.esm.d.ts} +1 -1
- package/dist/chunks/{index-slrOT8Gd.esm.d.ts → index-iYxrQMxt.esm.d.ts} +1 -1
- package/dist/chunks/{index-Z1UUeVXR.esm.js → index-l7Ao8g5B.esm.js} +2 -2
- package/dist/chunks/{index-Z1UUeVXR.esm.js.map → index-l7Ao8g5B.esm.js.map} +1 -1
- package/dist/chunks/{index-WX8Yyx2u.esm.d.ts → index-tqTROh5B.esm.d.ts} +1 -1
- package/dist/chunks/{lit-yVXn5Cbs.esm.js → lit-HCWbxxT7.esm.js} +4 -4
- package/dist/chunks/{lit-yVXn5Cbs.esm.js.map → lit-HCWbxxT7.esm.js.map} +1 -1
- package/dist/chunks/{localize-pzAAkBvG.esm.js → localize-ZHtlNltZ.esm.js} +2 -2
- package/dist/chunks/{localize-pzAAkBvG.esm.js.map → localize-ZHtlNltZ.esm.js.map} +1 -1
- package/dist/chunks/{localize-GCkVUD8S.esm.js → localize-jRg7W6Ul.esm.js} +2 -2
- package/dist/chunks/{localize-GCkVUD8S.esm.js.map → localize-jRg7W6Ul.esm.js.map} +1 -1
- package/dist/chunks/{openapi-spec-b529HHW3.esm.d.ts → openapi-spec-fxMWpEwU.esm.d.ts} +259 -14
- package/dist/chunks/order-page-5VQO1Sil.esm.js +2 -0
- package/dist/chunks/order-page-5VQO1Sil.esm.js.map +1 -0
- package/dist/chunks/{order-page-jkuLE25f.esm.d.ts → order-page-AezeN9KY.esm.d.ts} +2 -2
- package/dist/chunks/order-page-E7Kyu1JP.esm.js +2 -0
- package/dist/chunks/order-page-E7Kyu1JP.esm.js.map +1 -0
- package/dist/chunks/{progress-bar-7gWYaGlq.esm.js → progress-bar-9vfd2JYm.esm.js} +2 -2
- package/dist/chunks/{progress-bar-7gWYaGlq.esm.js.map → progress-bar-9vfd2JYm.esm.js.map} +1 -1
- package/dist/chunks/promo-pill-label-3bA1z-la.esm.d.ts +19 -0
- package/dist/chunks/promo-pill-label-vCWNyiaj.esm.js +13 -0
- package/dist/chunks/promo-pill-label-vCWNyiaj.esm.js.map +1 -0
- package/dist/chunks/{responsive-LYEag6TI.esm.js → responsive-Bzkkpj11.esm.js} +2 -2
- package/dist/chunks/{responsive-LYEag6TI.esm.js.map → responsive-Bzkkpj11.esm.js.map} +1 -1
- package/dist/chunks/{routes-LFjgVNGB.esm.js → routes-UBDDazXd.esm.js} +2 -2
- package/dist/chunks/{routes-LFjgVNGB.esm.js.map → routes-UBDDazXd.esm.js.map} +1 -1
- package/dist/chunks/{routes-ad0I3Ayc.esm.js → routes-t5eRHMRc.esm.js} +2 -2
- package/dist/chunks/{routes-ad0I3Ayc.esm.js.map → routes-t5eRHMRc.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-EKZbvT8c.esm.d.ts → update-cart-43LEXveI.esm.d.ts} +1 -1
- package/dist/chunks/{update-cart-A2hs4tF8.esm.js → update-cart-6fMyZd34.esm.js} +2 -2
- package/dist/chunks/{update-cart-A2hs4tF8.esm.js.map → update-cart-6fMyZd34.esm.js.map} +1 -1
- package/dist/chunks/{update-cart-vcujKNky.esm.js → update-cart-WfOplzik.esm.js} +2 -2
- package/dist/chunks/{update-cart-vcujKNky.esm.js.map → update-cart-WfOplzik.esm.js.map} +1 -1
- package/dist/chunks/{vendor-eeJfrOkP.esm.js → vendor-h5FNKy-G.esm.js} +124 -25
- package/dist/chunks/vendor-h5FNKy-G.esm.js.map +1 -0
- package/dist/components/beam-partner-logos.esm.js +1 -1
- package/dist/components/beam-partner-logos.js +1 -1
- package/dist/components/community-impact.esm.js +1 -1
- package/dist/components/community-impact.js +1 -1
- package/dist/components/cumulative-impact.esm.js +1 -1
- package/dist/components/cumulative-impact.js +1 -1
- package/dist/components/impact-overview.d.ts +12 -0
- package/dist/components/impact-overview.esm.js +2 -2
- package/dist/components/impact-overview.esm.js.map +1 -1
- package/dist/components/impact-overview.js +2 -2
- package/dist/components/impact-overview.js.map +1 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.esm.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/post-purchase.d.ts +3 -2
- package/dist/components/post-purchase.esm.js +2 -1
- package/dist/components/post-purchase.esm.js.map +1 -1
- package/dist/components/post-purchase.js +2 -1
- package/dist/components/post-purchase.js.map +1 -1
- package/dist/components/redeem-transaction.d.ts +4 -2
- package/dist/components/redeem-transaction.esm.js +60 -38
- package/dist/components/redeem-transaction.esm.js.map +1 -1
- package/dist/components/redeem-transaction.js +60 -38
- package/dist/components/redeem-transaction.js.map +1 -1
- package/dist/components/select-nonprofit.d.ts +13 -2
- package/dist/components/select-nonprofit.esm.js +73 -30
- package/dist/components/select-nonprofit.esm.js.map +1 -1
- package/dist/components/select-nonprofit.js +73 -30
- package/dist/components/select-nonprofit.js.map +1 -1
- package/dist/components/shopify.d.ts +6 -5
- 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/subscription-management.d.ts +13 -2
- package/dist/components/subscription-management.esm.js +1 -1
- package/dist/components/subscription-management.js +1 -1
- package/dist/index.d.ts +12 -11
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/integrations/beam.esm.js +1 -1
- package/dist/integrations/beam.js +1 -1
- package/dist/integrations/cart.d.ts +3 -3
- package/dist/integrations/cart.esm.js +1 -1
- package/dist/integrations/cart.js +1 -1
- package/dist/integrations/index.d.ts +10 -9
- package/dist/integrations/index.esm.js +1 -1
- package/dist/integrations/index.js +1 -1
- package/dist/integrations/logs.d.ts +2 -2
- package/dist/integrations/logs.esm.js +1 -1
- package/dist/integrations/logs.js +1 -1
- package/dist/integrations/session.esm.js +1 -1
- package/dist/integrations/session.js +1 -1
- package/dist/integrations/shopify.d.ts +5 -4
- package/dist/integrations/shopify.esm.js +1 -1
- package/dist/integrations/shopify.js +1 -1
- package/dist/integrations/statsig.esm.js +1 -1
- package/dist/integrations/statsig.js +1 -1
- package/dist/integrations/utils.d.ts +3 -3
- package/dist/react/beam-partner-logos.esm.js +1 -1
- package/dist/react/beam-partner-logos.js +1 -1
- package/dist/react/community-impact.esm.js +1 -1
- package/dist/react/community-impact.js +1 -1
- package/dist/react/cumulative-impact.esm.js +1 -1
- package/dist/react/cumulative-impact.js +1 -1
- package/dist/react/impact-overview.esm.js +1 -1
- package/dist/react/impact-overview.js +1 -1
- package/dist/react/index.d.ts +4 -3
- package/dist/react/index.esm.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/post-purchase.d.ts +3 -2
- 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/redeem-transaction.d.ts +4 -3
- 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 +4 -3
- 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/subscription-management.d.ts +2 -2
- package/dist/react/subscription-management.esm.js +1 -1
- package/dist/react/subscription-management.js +1 -1
- package/dist/utils/events.d.ts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/package.json +1 -1
- package/dist/chunks/_share-dialog-dependencies-FheD3_vQ.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-FheD3_vQ.esm.js.map +0 -1
- package/dist/chunks/_share-dialog-dependencies-l35ECwOP.esm.js +0 -2
- package/dist/chunks/_share-dialog-dependencies-l35ECwOP.esm.js.map +0 -1
- package/dist/chunks/index-B2oj1JKu.esm.js +0 -2
- package/dist/chunks/index-B2oj1JKu.esm.js.map +0 -1
- package/dist/chunks/index-E_HMWZ2A.esm.js +0 -2
- package/dist/chunks/index-E_HMWZ2A.esm.js.map +0 -1
- package/dist/chunks/index-JsXH5Lnc.esm.js +0 -2
- package/dist/chunks/index-JsXH5Lnc.esm.js.map +0 -1
- package/dist/chunks/index-RDKeoKqc.esm.js +0 -2
- package/dist/chunks/index-RDKeoKqc.esm.js.map +0 -1
- package/dist/chunks/index-VGoZaoVm.esm.js +0 -2
- package/dist/chunks/index-VGoZaoVm.esm.js.map +0 -1
- package/dist/chunks/index-xYLcuL6Z.esm.js +0 -2
- package/dist/chunks/index-xYLcuL6Z.esm.js.map +0 -1
- package/dist/chunks/order-page-9B0nZVh1.esm.js +0 -2
- package/dist/chunks/order-page-9B0nZVh1.esm.js.map +0 -1
- package/dist/chunks/order-page-yM2h67MI.esm.js +0 -2
- package/dist/chunks/order-page-yM2h67MI.esm.js.map +0 -1
- package/dist/chunks/vendor-eeJfrOkP.esm.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localize-
|
|
1
|
+
{"version":3,"file":"localize-jRg7W6Ul.esm.js","sources":["../../src/shared/fragments/loading-template.ts","../../src/shared/fragments/custom-text.ts","../../src/shared/localize.ts"],"sourcesContent":["import { html } from \"lit\";\n\nconst strings = {\n loading: \"\", // Default is no loading content\n};\n\nexport const _loading = () => {\n return html`<p class=\"beam-loading\">${strings.loading}</p>`;\n};\n","import { CSSResult, unsafeCSS } from \"lit\";\n\n/**\n * Create an object that can be passed to cssVariableMap\n * to define CSS variables in a style tag. The default properties\n * are the ones exposed for customization in the remote config interface.\n * @example\n * const variables = {\n * ...customizableTextJs(\"widget-header\",\n * \"widget-border-color\": \"red\"\n * };\n *\n * html`<style>:host { ${_cssVariableMap(variables)} }</style>`;\n * @returns {{[p: string]: string}}\n */\nexport const defineCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n [`${prefix}-fontFamily`]: fontFamily,\n [`${prefix}-fontStyle`]: fontStyle,\n [`${prefix}-fontSize`]: fontSize,\n [`${prefix}-fontWeight`]: fontWeight,\n [`${prefix}-textTransform`]: textTransform,\n [`${prefix}-marginTop`]: marginTop,\n [`${prefix}-lineHeight`]: lineHeight,\n [`${prefix}-color`]: color,\n };\n};\n\n/**\n * Returns a string that defines css properties based on variables,\n * which can be used in a css`` template. The default properties are the\n * ones exposed for customization in the remote config interface.\n * @example\n * css`.widget-header { ${customizableTextCss(\"widget-header\")} border: none; }`\n * @returns {CSSResult}\n */\nexport const useCustomText = (\n namespace = \"\",\n {\n fontFamily = \"inherit\",\n fontStyle = \"inherit\",\n fontSize = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n color = \"inherit\",\n } = {}\n): CSSResult => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return unsafeCSS(`\\\n font-family: var(${prefix}-fontFamily, ${fontFamily});\n font-style: var(${prefix}-fontStyle, ${fontStyle});\n font-size: var(${prefix}-fontSize, ${fontSize});\n font-weight: var(${prefix}-fontWeight, ${fontWeight});\n text-transform: var(${prefix}-textTransform, ${textTransform});\n margin-top: var(${prefix}-marginTop, ${marginTop});\n line-height: var(${prefix}-lineHeight, ${lineHeight});\n color: var(${prefix}-color, ${color});\n `);\n};\n\n/**\n * Same as useCustomText except returns an object that can be passed to styleMap\n */\nexport const useCustomTextMap = (\n namespace = \"\",\n {\n fontSize = \"inherit\",\n fontStyle = \"inherit\",\n fontWeight = \"inherit\",\n textTransform = \"none\",\n marginTop = \"0\",\n lineHeight = \"inherit\",\n } = {}\n): Record<string, string> => {\n const prefix = namespace.startsWith(\"--beam-\") ? namespace : `--beam-${namespace}`;\n return {\n fontSize: `var(${prefix}-fontSize, ${fontSize})`,\n fontStyle: `var(${prefix}-fontStyle, ${fontStyle})`,\n fontWeight: `var(${prefix}-fontWeight, ${fontWeight})`,\n textTransform: `var(${prefix}-textTransform, ${textTransform})`,\n marginTop: `var(${prefix}-marginTop, ${marginTop})`,\n lineHeight: `var(${prefix}-lineHeight, ${lineHeight})`,\n };\n};\n","import { LANGUAGES } from \"../api-sdk/types\";\nimport { logger } from \"../utils/logger\";\nimport { BeamError } from \"../utils/beam-errors\";\n\n/**\n * User-provided strings may include embedded translations in JSON form\n * This function extracts the string for the provided language\n * If it fails to parse, or the string is not json-like, it returns the whole string\n * TODO: consider returning unsafeHtml() or adding an option for it\n */\nconst localizeUserString = (lang: LANGUAGES, str: string): string => {\n const isJson = str.startsWith(\"{\");\n if (isJson) {\n try {\n const json = JSON.parse(str);\n return json[lang] ?? json[\"en\"] ?? str;\n } catch (err) {\n logger.error(new BeamError(\"Failed to extract JSON translation from string\"), str);\n return str;\n }\n }\n return str;\n};\n\nexport { localizeUserString };\n"],"names":["strings","_loading","html","defineCustomText","namespace","fontFamily","fontStyle","fontSize","fontWeight","textTransform","marginTop","lineHeight","color","prefix","useCustomText","unsafeCSS","localizeUserString","lang","str","json","logger","BeamError"],"mappings":"mJAEA,MAAMA,EAAU,CACd,QAAS,EACX,EAEaC,EAAW,IACfC,4BAA+BF,EAAQ,OAAO,OCQ1CG,EAAmB,CAC9BC,EAAY,GACZ,CACE,WAAAC,EAAa,UACb,UAAAC,EAAY,UACZ,SAAAC,EAAW,UACX,WAAAC,EAAa,UACb,cAAAC,EAAgB,OAChB,UAAAC,EAAY,IACZ,WAAAC,EAAa,UACb,MAAAC,EAAQ,SACV,EAAI,CAAA,IACuB,CAC3B,MAAMC,EAAST,EAAU,WAAW,SAAS,EAAIA,EAAY,UAAUA,CAAS,GAChF,MAAO,CACL,CAAC,GAAGS,CAAM,aAAa,EAAGR,EAC1B,CAAC,GAAGQ,CAAM,YAAY,EAAGP,EACzB,CAAC,GAAGO,CAAM,WAAW,EAAGN,EACxB,CAAC,GAAGM,CAAM,aAAa,EAAGL,EAC1B,CAAC,GAAGK,CAAM,gBAAgB,EAAGJ,EAC7B,CAAC,GAAGI,CAAM,YAAY,EAAGH,EACzB,CAAC,GAAGG,CAAM,aAAa,EAAGF,EAC1B,CAAC,GAAGE,CAAM,QAAQ,EAAGD,CACvB,CACF,EAUaE,EAAgB,CAC3BV,EAAY,GACZ,CACE,WAAAC,EAAa,UACb,UAAAC,EAAY,UACZ,SAAAC,EAAW,UACX,WAAAC,EAAa,UACb,cAAAC,EAAgB,OAChB,UAAAC,EAAY,IACZ,WAAAC,EAAa,UACb,MAAAC,EAAQ,SACV,EAAI,CACU,IAAA,CACd,MAAMC,EAAST,EAAU,WAAW,SAAS,EAAIA,EAAY,UAAUA,CAAS,GAChF,OAAOW,EAAU,4BACQF,CAAM,gBAAgBR,CAAU;AAAA,0BACjCQ,CAAM,eAAeP,CAAS;AAAA,yBAC/BO,CAAM,cAAcN,CAAQ;AAAA,2BAC1BM,CAAM,gBAAgBL,CAAU;AAAA,8BAC7BK,CAAM,mBAAmBJ,CAAa;AAAA,0BAC1CI,CAAM,eAAeH,CAAS;AAAA,2BAC7BG,CAAM,gBAAgBF,CAAU;AAAA,qBACtCE,CAAM,WAAWD,CAAK;AAAA,KACtC,CACL,EC/DMI,EAAqB,CAACC,EAAiBC,IAAwB,CAEnE,GADeA,EAAI,WAAW,GAAG,EAE/B,GAAI,CACF,MAAMC,EAAO,KAAK,MAAMD,CAAG,EAC3B,OAAOC,EAAKF,CAAI,GAAKE,EAAK,IAASD,CACrC,MAAc,CACZ,OAAAE,EAAO,MAAM,IAAIC,EAAU,gDAAgD,EAAGH,CAAG,EAC1EA,CACT,CAEF,OAAOA,CACT"}
|
|
@@ -55,11 +55,18 @@ interface paths {
|
|
|
55
55
|
* @example Choose your impact
|
|
56
56
|
*/
|
|
57
57
|
title: string;
|
|
58
|
+
/** @description Subtitle/description for the widget */
|
|
59
|
+
description: string;
|
|
58
60
|
/**
|
|
59
|
-
* @description
|
|
61
|
+
* @description The prefix promo description for the widget for web
|
|
62
|
+
* @example At no extra cost,
|
|
63
|
+
*/
|
|
64
|
+
promoDescriptionPrefix?: string;
|
|
65
|
+
/**
|
|
66
|
+
* @description The promo description for the widget for web
|
|
60
67
|
* @example Select a nonprofit and 1% of your purchase will be donated, at no extra cost
|
|
61
68
|
*/
|
|
62
|
-
|
|
69
|
+
promoDescription?: string;
|
|
63
70
|
/** @description Remote config theme data as requested by the given widgetName & version query params */
|
|
64
71
|
theme?: {
|
|
65
72
|
[key: string]: unknown;
|
|
@@ -76,6 +83,18 @@ interface paths {
|
|
|
76
83
|
nonprofitUnselectedHeader?: string;
|
|
77
84
|
/** @description Disables counter animation for cumulative-impact widget */
|
|
78
85
|
disableAnimation?: boolean;
|
|
86
|
+
/** @description promo copy is sent in this object to be used in conditionally rendered UI components */
|
|
87
|
+
promo?: {
|
|
88
|
+
/** @example Donations are 2x for Black History Month */
|
|
89
|
+
"promo-text-long": string;
|
|
90
|
+
/** @example Donations are 2x */
|
|
91
|
+
"promo-text-short": string;
|
|
92
|
+
/**
|
|
93
|
+
* @description replaces cause copy
|
|
94
|
+
* @example 2x boosting donations
|
|
95
|
+
*/
|
|
96
|
+
"promo-cause-alt-text": string;
|
|
97
|
+
};
|
|
79
98
|
};
|
|
80
99
|
mobileWeb?: {
|
|
81
100
|
/**
|
|
@@ -203,6 +222,14 @@ interface paths {
|
|
|
203
222
|
*/
|
|
204
223
|
goalProgressPercentage: number;
|
|
205
224
|
};
|
|
225
|
+
promo?: {
|
|
226
|
+
isActive: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* @description When a promo is active, the total amount donated is multiplied by this value. ex:\ (subtotal * donationAmount) * multiplier -> ($100 * 1%) * 2 = $2.00 donated
|
|
229
|
+
* @example 2
|
|
230
|
+
*/
|
|
231
|
+
multiplier: number | null;
|
|
232
|
+
} | null;
|
|
206
233
|
}[];
|
|
207
234
|
/** @description a site-specific identifier */
|
|
208
235
|
store: {
|
|
@@ -287,11 +314,18 @@ interface paths {
|
|
|
287
314
|
* @example Choose your impact
|
|
288
315
|
*/
|
|
289
316
|
title: string;
|
|
317
|
+
/** @description Subtitle/description for the widget */
|
|
318
|
+
description: string;
|
|
290
319
|
/**
|
|
291
|
-
* @description
|
|
320
|
+
* @description The prefix promo description for the widget for web
|
|
321
|
+
* @example At no extra cost,
|
|
322
|
+
*/
|
|
323
|
+
promoDescriptionPrefix?: string;
|
|
324
|
+
/**
|
|
325
|
+
* @description The promo description for the widget for web
|
|
292
326
|
* @example Select a nonprofit and 1% of your purchase will be donated, at no extra cost
|
|
293
327
|
*/
|
|
294
|
-
|
|
328
|
+
promoDescription?: string;
|
|
295
329
|
/** @description Remote config theme data as requested by the given widgetName & version query params */
|
|
296
330
|
theme?: {
|
|
297
331
|
[key: string]: unknown;
|
|
@@ -308,6 +342,18 @@ interface paths {
|
|
|
308
342
|
nonprofitUnselectedHeader?: string;
|
|
309
343
|
/** @description Disables counter animation for cumulative-impact widget */
|
|
310
344
|
disableAnimation?: boolean;
|
|
345
|
+
/** @description promo copy is sent in this object to be used in conditionally rendered UI components */
|
|
346
|
+
promo?: {
|
|
347
|
+
/** @example Donations are 2x for Black History Month */
|
|
348
|
+
"promo-text-long": string;
|
|
349
|
+
/** @example Donations are 2x */
|
|
350
|
+
"promo-text-short": string;
|
|
351
|
+
/**
|
|
352
|
+
* @description replaces cause copy
|
|
353
|
+
* @example 2x boosting donations
|
|
354
|
+
*/
|
|
355
|
+
"promo-cause-alt-text": string;
|
|
356
|
+
};
|
|
311
357
|
};
|
|
312
358
|
mobileWeb?: {
|
|
313
359
|
/**
|
|
@@ -477,11 +523,18 @@ interface paths {
|
|
|
477
523
|
* @example Choose your impact
|
|
478
524
|
*/
|
|
479
525
|
title: string;
|
|
526
|
+
/** @description Subtitle/description for the widget */
|
|
527
|
+
description: string;
|
|
480
528
|
/**
|
|
481
|
-
* @description
|
|
529
|
+
* @description The prefix promo description for the widget for web
|
|
530
|
+
* @example At no extra cost,
|
|
531
|
+
*/
|
|
532
|
+
promoDescriptionPrefix?: string;
|
|
533
|
+
/**
|
|
534
|
+
* @description The promo description for the widget for web
|
|
482
535
|
* @example Select a nonprofit and 1% of your purchase will be donated, at no extra cost
|
|
483
536
|
*/
|
|
484
|
-
|
|
537
|
+
promoDescription?: string;
|
|
485
538
|
/** @description Remote config theme data as requested by the given widgetName & version query params */
|
|
486
539
|
theme?: {
|
|
487
540
|
[key: string]: unknown;
|
|
@@ -498,6 +551,18 @@ interface paths {
|
|
|
498
551
|
nonprofitUnselectedHeader?: string;
|
|
499
552
|
/** @description Disables counter animation for cumulative-impact widget */
|
|
500
553
|
disableAnimation?: boolean;
|
|
554
|
+
/** @description promo copy is sent in this object to be used in conditionally rendered UI components */
|
|
555
|
+
promo?: {
|
|
556
|
+
/** @example Donations are 2x for Black History Month */
|
|
557
|
+
"promo-text-long": string;
|
|
558
|
+
/** @example Donations are 2x */
|
|
559
|
+
"promo-text-short": string;
|
|
560
|
+
/**
|
|
561
|
+
* @description replaces cause copy
|
|
562
|
+
* @example 2x boosting donations
|
|
563
|
+
*/
|
|
564
|
+
"promo-cause-alt-text": string;
|
|
565
|
+
};
|
|
501
566
|
};
|
|
502
567
|
mobileWeb?: {
|
|
503
568
|
/**
|
|
@@ -625,6 +690,14 @@ interface paths {
|
|
|
625
690
|
*/
|
|
626
691
|
goalProgressPercentage: number;
|
|
627
692
|
};
|
|
693
|
+
promo?: {
|
|
694
|
+
isActive: boolean;
|
|
695
|
+
/**
|
|
696
|
+
* @description When a promo is active, the total amount donated is multiplied by this value. ex:\ (subtotal * donationAmount) * multiplier -> ($100 * 1%) * 2 = $2.00 donated
|
|
697
|
+
* @example 2
|
|
698
|
+
*/
|
|
699
|
+
multiplier: number | null;
|
|
700
|
+
} | null;
|
|
628
701
|
}[];
|
|
629
702
|
/** @description a site-specific identifier */
|
|
630
703
|
store: {
|
|
@@ -756,6 +829,7 @@ interface paths {
|
|
|
756
829
|
query: {
|
|
757
830
|
/** @deprecated No longer needed, chainId inferred from API Key */
|
|
758
831
|
chainId?: number;
|
|
832
|
+
storeId?: number;
|
|
759
833
|
beamUserId?: string;
|
|
760
834
|
/** Nonprofit ID */
|
|
761
835
|
nonprofitId?: number;
|
|
@@ -800,11 +874,18 @@ interface paths {
|
|
|
800
874
|
* @example Choose your impact
|
|
801
875
|
*/
|
|
802
876
|
title: string;
|
|
877
|
+
/** @description Subtitle/description for the widget */
|
|
878
|
+
description: string;
|
|
803
879
|
/**
|
|
804
|
-
* @description
|
|
880
|
+
* @description The prefix promo description for the widget for web
|
|
881
|
+
* @example At no extra cost,
|
|
882
|
+
*/
|
|
883
|
+
promoDescriptionPrefix?: string;
|
|
884
|
+
/**
|
|
885
|
+
* @description The promo description for the widget for web
|
|
805
886
|
* @example Select a nonprofit and 1% of your purchase will be donated, at no extra cost
|
|
806
887
|
*/
|
|
807
|
-
|
|
888
|
+
promoDescription?: string;
|
|
808
889
|
/** @description Remote config theme data as requested by the given widgetName & version query params */
|
|
809
890
|
theme?: {
|
|
810
891
|
[key: string]: unknown;
|
|
@@ -821,6 +902,18 @@ interface paths {
|
|
|
821
902
|
nonprofitUnselectedHeader?: string;
|
|
822
903
|
/** @description Disables counter animation for cumulative-impact widget */
|
|
823
904
|
disableAnimation?: boolean;
|
|
905
|
+
/** @description promo copy is sent in this object to be used in conditionally rendered UI components */
|
|
906
|
+
promo?: {
|
|
907
|
+
/** @example Donations are 2x for Black History Month */
|
|
908
|
+
"promo-text-long": string;
|
|
909
|
+
/** @example Donations are 2x */
|
|
910
|
+
"promo-text-short": string;
|
|
911
|
+
/**
|
|
912
|
+
* @description replaces cause copy
|
|
913
|
+
* @example 2x boosting donations
|
|
914
|
+
*/
|
|
915
|
+
"promo-cause-alt-text": string;
|
|
916
|
+
};
|
|
824
917
|
};
|
|
825
918
|
mobileWeb?: {
|
|
826
919
|
/**
|
|
@@ -1034,6 +1127,14 @@ interface paths {
|
|
|
1034
1127
|
*/
|
|
1035
1128
|
filters?: string[];
|
|
1036
1129
|
}[];
|
|
1130
|
+
promo: {
|
|
1131
|
+
isActive: boolean;
|
|
1132
|
+
/**
|
|
1133
|
+
* @description When a promo is active, the total amount donated is multiplied by this value. ex:\ (subtotal * donationAmount) * multiplier -> ($100 * 1%) * 2 = $2.00 donated
|
|
1134
|
+
* @example 2
|
|
1135
|
+
*/
|
|
1136
|
+
multiplier: number | null;
|
|
1137
|
+
} | null;
|
|
1037
1138
|
};
|
|
1038
1139
|
};
|
|
1039
1140
|
};
|
|
@@ -1942,11 +2043,18 @@ interface paths {
|
|
|
1942
2043
|
* @example Choose your impact
|
|
1943
2044
|
*/
|
|
1944
2045
|
title: string;
|
|
2046
|
+
/** @description Subtitle/description for the widget */
|
|
2047
|
+
description: string;
|
|
1945
2048
|
/**
|
|
1946
|
-
* @description
|
|
2049
|
+
* @description The prefix promo description for the widget for web
|
|
2050
|
+
* @example At no extra cost,
|
|
2051
|
+
*/
|
|
2052
|
+
promoDescriptionPrefix?: string;
|
|
2053
|
+
/**
|
|
2054
|
+
* @description The promo description for the widget for web
|
|
1947
2055
|
* @example Select a nonprofit and 1% of your purchase will be donated, at no extra cost
|
|
1948
2056
|
*/
|
|
1949
|
-
|
|
2057
|
+
promoDescription?: string;
|
|
1950
2058
|
/** @description Remote config theme data as requested by the given widgetName & version query params */
|
|
1951
2059
|
theme?: {
|
|
1952
2060
|
[key: string]: unknown;
|
|
@@ -1963,6 +2071,18 @@ interface paths {
|
|
|
1963
2071
|
nonprofitUnselectedHeader?: string;
|
|
1964
2072
|
/** @description Disables counter animation for cumulative-impact widget */
|
|
1965
2073
|
disableAnimation?: boolean;
|
|
2074
|
+
/** @description promo copy is sent in this object to be used in conditionally rendered UI components */
|
|
2075
|
+
promo?: {
|
|
2076
|
+
/** @example Donations are 2x for Black History Month */
|
|
2077
|
+
"promo-text-long": string;
|
|
2078
|
+
/** @example Donations are 2x */
|
|
2079
|
+
"promo-text-short": string;
|
|
2080
|
+
/**
|
|
2081
|
+
* @description replaces cause copy
|
|
2082
|
+
* @example 2x boosting donations
|
|
2083
|
+
*/
|
|
2084
|
+
"promo-cause-alt-text": string;
|
|
2085
|
+
};
|
|
1966
2086
|
};
|
|
1967
2087
|
mobileWeb?: {
|
|
1968
2088
|
/**
|
|
@@ -2647,11 +2767,18 @@ interface paths {
|
|
|
2647
2767
|
* @example Choose your impact
|
|
2648
2768
|
*/
|
|
2649
2769
|
title: string;
|
|
2770
|
+
/** @description Subtitle/description for the widget */
|
|
2771
|
+
description: string;
|
|
2650
2772
|
/**
|
|
2651
|
-
* @description
|
|
2773
|
+
* @description The prefix promo description for the widget for web
|
|
2774
|
+
* @example At no extra cost,
|
|
2775
|
+
*/
|
|
2776
|
+
promoDescriptionPrefix?: string;
|
|
2777
|
+
/**
|
|
2778
|
+
* @description The promo description for the widget for web
|
|
2652
2779
|
* @example Select a nonprofit and 1% of your purchase will be donated, at no extra cost
|
|
2653
2780
|
*/
|
|
2654
|
-
|
|
2781
|
+
promoDescription?: string;
|
|
2655
2782
|
/** @description Remote config theme data as requested by the given widgetName & version query params */
|
|
2656
2783
|
theme?: {
|
|
2657
2784
|
[key: string]: unknown;
|
|
@@ -2668,6 +2795,18 @@ interface paths {
|
|
|
2668
2795
|
nonprofitUnselectedHeader?: string;
|
|
2669
2796
|
/** @description Disables counter animation for cumulative-impact widget */
|
|
2670
2797
|
disableAnimation?: boolean;
|
|
2798
|
+
/** @description promo copy is sent in this object to be used in conditionally rendered UI components */
|
|
2799
|
+
promo?: {
|
|
2800
|
+
/** @example Donations are 2x for Black History Month */
|
|
2801
|
+
"promo-text-long": string;
|
|
2802
|
+
/** @example Donations are 2x */
|
|
2803
|
+
"promo-text-short": string;
|
|
2804
|
+
/**
|
|
2805
|
+
* @description replaces cause copy
|
|
2806
|
+
* @example 2x boosting donations
|
|
2807
|
+
*/
|
|
2808
|
+
"promo-cause-alt-text": string;
|
|
2809
|
+
};
|
|
2671
2810
|
};
|
|
2672
2811
|
mobileWeb?: {
|
|
2673
2812
|
/**
|
|
@@ -2726,11 +2865,18 @@ interface paths {
|
|
|
2726
2865
|
* @example Choose your impact
|
|
2727
2866
|
*/
|
|
2728
2867
|
title: string;
|
|
2868
|
+
/** @description Subtitle/description for the widget */
|
|
2869
|
+
description: string;
|
|
2729
2870
|
/**
|
|
2730
|
-
* @description
|
|
2871
|
+
* @description The prefix promo description for the widget for web
|
|
2872
|
+
* @example At no extra cost,
|
|
2873
|
+
*/
|
|
2874
|
+
promoDescriptionPrefix?: string;
|
|
2875
|
+
/**
|
|
2876
|
+
* @description The promo description for the widget for web
|
|
2731
2877
|
* @example Select a nonprofit and 1% of your purchase will be donated, at no extra cost
|
|
2732
2878
|
*/
|
|
2733
|
-
|
|
2879
|
+
promoDescription?: string;
|
|
2734
2880
|
/** @description Remote config theme data as requested by the given widgetName & version query params */
|
|
2735
2881
|
theme?: {
|
|
2736
2882
|
[key: string]: unknown;
|
|
@@ -2747,6 +2893,18 @@ interface paths {
|
|
|
2747
2893
|
nonprofitUnselectedHeader?: string;
|
|
2748
2894
|
/** @description Disables counter animation for cumulative-impact widget */
|
|
2749
2895
|
disableAnimation?: boolean;
|
|
2896
|
+
/** @description promo copy is sent in this object to be used in conditionally rendered UI components */
|
|
2897
|
+
promo?: {
|
|
2898
|
+
/** @example Donations are 2x for Black History Month */
|
|
2899
|
+
"promo-text-long": string;
|
|
2900
|
+
/** @example Donations are 2x */
|
|
2901
|
+
"promo-text-short": string;
|
|
2902
|
+
/**
|
|
2903
|
+
* @description replaces cause copy
|
|
2904
|
+
* @example 2x boosting donations
|
|
2905
|
+
*/
|
|
2906
|
+
"promo-cause-alt-text": string;
|
|
2907
|
+
};
|
|
2750
2908
|
};
|
|
2751
2909
|
mobileWeb?: {
|
|
2752
2910
|
/**
|
|
@@ -5502,6 +5660,93 @@ interface paths {
|
|
|
5502
5660
|
};
|
|
5503
5661
|
};
|
|
5504
5662
|
};
|
|
5663
|
+
"/chainWidgetVersion": {
|
|
5664
|
+
post: {
|
|
5665
|
+
responses: {
|
|
5666
|
+
/** Chain widget version created */
|
|
5667
|
+
200: unknown;
|
|
5668
|
+
/** Standard error */
|
|
5669
|
+
default: {
|
|
5670
|
+
content: {
|
|
5671
|
+
"application/json": {
|
|
5672
|
+
/** @description Beam code for the error, meant to be used programmatically */
|
|
5673
|
+
code: string;
|
|
5674
|
+
/** @description A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization */
|
|
5675
|
+
title: string;
|
|
5676
|
+
/** @description A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized */
|
|
5677
|
+
detail: string;
|
|
5678
|
+
/** @description a JSON Pointer to the associated entity in the request document */
|
|
5679
|
+
field?: string;
|
|
5680
|
+
/** @description A meta object containing non-standard meta-information about the error */
|
|
5681
|
+
metadata?: {
|
|
5682
|
+
[key: string]: unknown;
|
|
5683
|
+
};
|
|
5684
|
+
/** @description Whether the API or user can resend the request */
|
|
5685
|
+
retryable?: boolean;
|
|
5686
|
+
} & {
|
|
5687
|
+
source: unknown;
|
|
5688
|
+
meta: unknown;
|
|
5689
|
+
};
|
|
5690
|
+
};
|
|
5691
|
+
};
|
|
5692
|
+
};
|
|
5693
|
+
requestBody: {
|
|
5694
|
+
content: {
|
|
5695
|
+
"application/json": {
|
|
5696
|
+
/**
|
|
5697
|
+
* @description A production release version of the Beam web widgets
|
|
5698
|
+
* @example v1.0.0
|
|
5699
|
+
*/
|
|
5700
|
+
widgetVersion: string;
|
|
5701
|
+
chainId: number;
|
|
5702
|
+
};
|
|
5703
|
+
};
|
|
5704
|
+
};
|
|
5705
|
+
};
|
|
5706
|
+
};
|
|
5707
|
+
"/widgetVersion": {
|
|
5708
|
+
post: {
|
|
5709
|
+
responses: {
|
|
5710
|
+
/** Widget version created */
|
|
5711
|
+
200: unknown;
|
|
5712
|
+
/** Standard error */
|
|
5713
|
+
default: {
|
|
5714
|
+
content: {
|
|
5715
|
+
"application/json": {
|
|
5716
|
+
/** @description Beam code for the error, meant to be used programmatically */
|
|
5717
|
+
code: string;
|
|
5718
|
+
/** @description A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization */
|
|
5719
|
+
title: string;
|
|
5720
|
+
/** @description A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized */
|
|
5721
|
+
detail: string;
|
|
5722
|
+
/** @description a JSON Pointer to the associated entity in the request document */
|
|
5723
|
+
field?: string;
|
|
5724
|
+
/** @description A meta object containing non-standard meta-information about the error */
|
|
5725
|
+
metadata?: {
|
|
5726
|
+
[key: string]: unknown;
|
|
5727
|
+
};
|
|
5728
|
+
/** @description Whether the API or user can resend the request */
|
|
5729
|
+
retryable?: boolean;
|
|
5730
|
+
} & {
|
|
5731
|
+
source: unknown;
|
|
5732
|
+
meta: unknown;
|
|
5733
|
+
};
|
|
5734
|
+
};
|
|
5735
|
+
};
|
|
5736
|
+
};
|
|
5737
|
+
requestBody: {
|
|
5738
|
+
content: {
|
|
5739
|
+
"application/json": {
|
|
5740
|
+
/**
|
|
5741
|
+
* @description A production release version of the Beam web widgets
|
|
5742
|
+
* @example v1.0.0
|
|
5743
|
+
*/
|
|
5744
|
+
widgetVersion: string;
|
|
5745
|
+
};
|
|
5746
|
+
};
|
|
5747
|
+
};
|
|
5748
|
+
};
|
|
5749
|
+
};
|
|
5505
5750
|
}
|
|
5506
5751
|
|
|
5507
5752
|
export type { paths as p };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as T}from"./lodash-P8OIs-at.esm.js";import{d as U,f as A,c as O,g as R}from"./events-Y8fYvSqM.esm.js";import{logger as j}from"../utils/logger.js";import{initNetworkListeners as k}from"../utils/network-listeners.js";import{createScopedLocalStorage as E}from"../utils/local-storage.js";import{getCookieValue as u}from"../utils/cookies.js";import{memoizeLast as J}from"../utils/memoize-last.js";import{B as b}from"./cart-contents-h60geKWa.esm.js";import{x as I}from"./update-cart-WfOplzik.esm.js";import"../components/post-purchase.js";import{D as x}from"./routes-t5eRHMRc.esm.js";import{waitForElement as K}from"../utils/wait-for-element.js";import{B as P}from"./beam-errors-P-Lu07Ce.esm.js";const N=window.Shopify?.routes?.root||"/";let S=!1;const v="cart";async function D(a){if(S)return!1;const p=await h(a);await I(a,p.cart),k(),window.addEventListener(U.eventName,async i=>{const r=i,t=/cart\/(add|change|update|clear)/,e=r.detail.type==="xhr"?r.detail.xhr.responseURL:r.detail.response.url,d=new URL(e);if(!t.test(d.pathname))return;const n=await h(a);if(!n.changed)return;const m={schema:n.cart.schema,content:{items:n.cart.content.items}};window.dispatchEvent(new A(m)),await I(a,n.cart)});let c,s;return window.addEventListener(O.eventName,async i=>{const r=i,{selectedNonprofitId:t,selectionId:e}=r.detail,d=await u(v),n=await u(b),{chainId:m,storeId:l}=a;c===t&&s===e||(await y({selectedNonprofitId:t,selectionId:e,beamCartId:n,cartId:d,chainId:m,storeId:l}),s=e,c=t)}),window.addEventListener(R.eventName,async i=>{const r=i,{newNonprofitId:t,selectionId:e}=r.detail,d=await u(v),n=await u(b),{chainId:m,storeId:l}=a;c===t&&s===e||(await y({selectedNonprofitId:t,beamCartId:n,selectionId:e,cartId:d,chainId:m,storeId:l}),s=e,c=t)}),S=!0,!0}async function h(a){const{token:p,total_price:c,item_count:s,currency:i,items:r}=await window.fetch(N+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(n=>n.json()),t={cartId:p,subtotal:c/100,itemCount:s,currencyCode:i,schema:{source:"generic"},content:{items:r.map(({sku:n,final_line_price:m,product_id:l})=>{const f=n||String(l),w=m/100;return{remoteProductIdentifier:f,localAmount:w}})}};let e=!1;const d=E(a).getItemJson("cart");return T(t,d)||(e=!0),{changed:e,cart:t}}const q=I,y=J(async function({selectedNonprofitId:a,selectionId:p,beamCartId:c,cartId:s,chainId:i,storeId:r}){const t={beam:JSON.stringify({nonprofit_id:a,selection_id:p,beam_cart_id:c,shopify_cart_id:s,chain_id:i,store_id:r})};try{await window.fetch(N+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:t})})}catch(e){j.error(e)}});async function F({parentSelector:a=".step__sections",apiKey:p,baseUrl:c=x,storeId:s,postalCode:i,countryCode:r,orderId:t,email:e,cartTotal:d,cart:n,discountCodes:m,currencyCode:l="USD",domain:f,lang:w="en",debug:B=!1}){const g=document.querySelector(a)||await K(a);if(!g)throw new P(`Timed out waiting for selector '${a}'. Could not render Beam post-purchase widget.`);const C=await u("cart");if(C){const _=E({apiKey:p}),L=_.getItemJson("cart")||{};_.setItemJson("cart",{...L,cartId:C})}const o=document.createElement("beam-post-purchase");o.apiKey=p,o.baseUrl=c,o.storeId=s,o.postalCode=i,o.countryCode=r,o.orderId=String(t),o.email=e,o.cartTotal=d,o.cart=n,o.discountCodes=m,o.currencyCode=l,o.domain=f,o.lang=w,o.debug=B,g.appendChild(o)}export{D as P,q as R,y as f,h as p,F as s};
|
|
2
|
+
//# sourceMappingURL=order-page-5VQO1Sil.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-page-5VQO1Sil.esm.js","sources":["../../src/integrations/shopify/cart-page.ts","../../src/integrations/shopify/order-page.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport isEqual from \"lodash-es/isEqual\";\nimport { logger, memoizeLast } from \"../../utils\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { initNetworkListeners } from \"../../utils/network-listeners\";\nimport {\n BeamCartChangeEvent,\n BeamNetworkCallEvent,\n BeamNonprofitSelectEvent,\n BeamNonprofitSelectionRemovedEvent,\n} from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { BEAM_CART_COOKIE_NAME, TCart, TCartApi, TCartItems } from \"../../shared/cart-contents\";\nimport { BeamCartAPIConfig, updateCart } from \"../cart\";\n\ntype BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {\n storeId: number; // will be added to cart custom_attributes, and used in cart API call\n chainId?: number; // will be added to cart custom_attributes\n};\n\nconst SHOPIFY_BASE_URL = window.Shopify?.routes?.root || \"/\"; // see window.d.ts\n\nlet isBeamCartIntegrationRegistered = false; // Skip registering event listeners if already set up\n\nconst SHOPIFY_CART_COOKIE_NAME = \"cart\";\n\n/**\n * @main registerCartIntegration - set up event listeners to integrate Beam with Shopify cart\n * @return {boolean} returns true if NEW listeners were created, false if setup was already done\n */\nasync function registerCartIntegration(config: BeamShopifyCartIntegrationConfig) {\n if (isBeamCartIntegrationRegistered) {\n return false; // Do nothing if listeners are already attached\n }\n\n // Handle full-page load, ie, first-time page load and reloads from form submit events\n // This creates a GET to /cart.js\n const currentCart = await getCurrentCart(config);\n await updateCart(config, currentCart.cart);\n\n // Set up event listeners for AJAX events\n initNetworkListeners();\n\n window.addEventListener(BeamNetworkCallEvent.eventName, async (_event: Event) => {\n const event = _event as BeamNetworkCallEvent;\n const cartChangePaths = /cart\\/(add|change|update|clear)/;\n // note: response urls below follow redirects\n const requestUrlStr = event.detail.type === \"xhr\" ? event.detail.xhr.responseURL : event.detail.response.url;\n const url = new URL(requestUrlStr);\n if (!cartChangePaths.test(url.pathname)) {\n return;\n }\n const currentCart = await getCurrentCart(config);\n if (!currentCart.changed) {\n return;\n }\n const eventDetail: TCartApi = {\n schema: currentCart.cart.schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: currentCart.cart.content.items as any,\n },\n };\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n // Send cart to Beam to update timestamp, which is used for cart abandonment / ROI calc\n await updateCart(config, currentCart.cart);\n });\n\n // Listen to Beam's own events to integrate Beam data into Shopify order\n let lastNonprofitId: number | null | undefined;\n let lastSelectionId: string | null | undefined;\n window.addEventListener(BeamNonprofitSelectEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectEvent;\n const { selectedNonprofitId, selectionId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME); // Shopify cart ID cookie\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME); // Beam cart ID cookie\n const { chainId, storeId } = config;\n // Skip update if nothing changed (can happen if widget is re-initialized and\n // emits event after cache restoration, i.e., on cart re-render).\n if (lastNonprofitId === selectedNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = selectedNonprofitId;\n });\n\n /**\n * Upon removal of the selected nonprofit from the widget and local storage,\n * an event is emitted and that event is then used to update the cart attributes accordingly\n * This event listener updates the cart attributes based on the emitted event\n */\n window.addEventListener(BeamNonprofitSelectionRemovedEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectionRemovedEvent;\n const { newNonprofitId, selectionId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME);\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME);\n const { chainId, storeId } = config;\n if (lastNonprofitId === newNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId: newNonprofitId,\n beamCartId,\n selectionId,\n cartId,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = newNonprofitId;\n });\n\n isBeamCartIntegrationRegistered = true;\n\n return true;\n}\n\n/* ***************************************** HELPER FUNCTIONS *****************************************\n These may be used individually to integrate with carts if the registerCartIntegration\n script doesn't work for some reason.\n ****************************************************************************************************/\n\n/**\n * Detects change in cart since last page load,\n * by calling GET /cart.js, and returns cart values.\n * Used for:\n * - Form-based carts where the page refreshes to modify cart instead of using AJAX calls\n * - Hydrogen/GraphQL based carts (needs to be integrated manually)\n */\nasync function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promise<{\n changed: boolean;\n cart: {\n cartId: string;\n subtotal: number;\n itemCount: number;\n currencyCode: string;\n } & TCart;\n}> {\n const {\n token, // equal to \"cart\" cookie\n total_price, // this is the pretax value, after discounts, and multiplied by 100 (integer from decimal)\n item_count,\n currency,\n items,\n } = await window\n .fetch(SHOPIFY_BASE_URL + \"cart.js\", {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n })\n .then((res) => res.json());\n\n const cart = {\n cartId: token,\n subtotal: total_price / 100,\n itemCount: item_count,\n currencyCode: currency,\n schema: { source: \"generic\" } as const,\n content: {\n // pull out minimal fields from full line items\n items: (items as TCartItems).map(({ sku, final_line_price, product_id }) => {\n const remoteProductIdentifier = sku || String(product_id);\n const localAmount = final_line_price / 100;\n return { remoteProductIdentifier, localAmount };\n }),\n },\n };\n\n let changed = false;\n\n const localStorage = createScopedLocalStorage(config);\n\n const cachedCart = localStorage.getItemJson(\"cart\");\n\n if (!isEqual(cart, cachedCart)) {\n changed = true;\n }\n\n return { changed, cart };\n}\n\n/**\n * trackCart - Backwards-compatible alias for updateCart\n */\nconst trackCart = updateCart;\n\n/**\n * Sends Beam data to Shopify to integrate with order as custom attributes.\n * Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.\n */\nconst addBeamAttributesToCart = memoizeLast(async function addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n}) {\n const beamCartAttrs = {\n beam: JSON.stringify({\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n }),\n };\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n logger.error(err); // don't throw, allow later calls to continue\n }\n});\n\nexport { trackCart, getCurrentCart, addBeamAttributesToCart, registerCartIntegration };\n","import \"../../components/post-purchase\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES, TUrl } from \"../../api-sdk/types\";\nimport { waitForElement } from \"../../utils/wait-for-element\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { TCart } from \"../../shared/cart-contents\";\n\n// Shopify admin page: admin/settings/checkout\n\nexport type TBeamOrderPageParams = Parameters<typeof postTransaction>[0][\"requestBody\"] & {\n // Either storeId or postalCode + countryCode must be provided\n storeId?: number;\n postalCode?: string;\n countryCode?: string;\n orderId: string;\n email: string;\n cartTotal: number;\n cart: TCart;\n discountCodes: string[];\n currencyCode: string;\n parentSelector: string; // CSS Selector for parent of widget to be inserted into DOM\n apiKey: string;\n baseUrl: TUrl;\n domain?: string; // Base domain for setting cookies\n lang: LANGUAGES;\n debug: boolean;\n};\n\nexport async function showBeamOrderPageWidgets({\n parentSelector = \".step__sections\",\n apiKey,\n baseUrl = DEFAULT_BASE_URL,\n storeId,\n postalCode,\n countryCode,\n orderId,\n email,\n cartTotal,\n cart,\n discountCodes,\n currencyCode = \"USD\",\n domain,\n lang = \"en\",\n debug = false,\n}: TBeamOrderPageParams) {\n const parentElement = document.querySelector(parentSelector) || (await waitForElement(parentSelector));\n if (!parentElement) {\n throw new BeamError(\n `Timed out waiting for selector '${parentSelector}'. Could not render Beam post-purchase widget.`\n );\n }\n\n // If checkout and order page are on different subdomains, we can't access localStorage\n // We can make postTransaction work by copying the cart cookie to the expected localStorage key on the current domain\n const cartId = await getCookieValue(\"cart\"); // Shopify-only cart identifier\n if (cartId) {\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n const existingValue = beamLocalStorage.getItemJson(\"cart\") || {};\n beamLocalStorage.setItemJson(\"cart\", { ...existingValue, cartId });\n }\n\n // Note: assign properties one by one instead of bulk Object.assign to type check assignments\n const widget = document.createElement(\"beam-post-purchase\");\n widget.apiKey = apiKey;\n widget.baseUrl = baseUrl;\n widget.storeId = storeId;\n widget.postalCode = postalCode;\n widget.countryCode = countryCode;\n widget.orderId = String(orderId);\n widget.email = email;\n widget.cartTotal = cartTotal;\n widget.cart = cart;\n widget.discountCodes = discountCodes;\n widget.currencyCode = currencyCode;\n widget.domain = domain;\n widget.lang = lang;\n widget.debug = debug;\n\n // Insert widget into DOM\n parentElement.appendChild(widget);\n}\n"],"names":["SHOPIFY_BASE_URL","isBeamCartIntegrationRegistered","SHOPIFY_CART_COOKIE_NAME","registerCartIntegration","config","currentCart","getCurrentCart","updateCart","initNetworkListeners","BeamNetworkCallEvent","_event","event","cartChangePaths","requestUrlStr","url","eventDetail","BeamCartChangeEvent","lastNonprofitId","lastSelectionId","BeamNonprofitSelectEvent","selectedNonprofitId","selectionId","cartId","getCookieValue","beamCartId","BEAM_CART_COOKIE_NAME","chainId","storeId","addBeamAttributesToCart","BeamNonprofitSelectionRemovedEvent","newNonprofitId","token","total_price","item_count","currency","items","res","cart","sku","final_line_price","product_id","remoteProductIdentifier","localAmount","changed","cachedCart","createScopedLocalStorage","isEqual","trackCart","memoizeLast","beamCartAttrs","err","logger","showBeamOrderPageWidgets","parentSelector","apiKey","baseUrl","DEFAULT_BASE_URL","postalCode","countryCode","orderId","email","cartTotal","discountCodes","currencyCode","domain","lang","debug","parentElement","waitForElement","BeamError","beamLocalStorage","existingValue","widget"],"mappings":"2rBAoBA,MAAMA,EAAmB,OAAO,SAAS,QAAQ,MAAQ,IAEzD,IAAIC,EAAkC,GAEtC,MAAMC,EAA2B,OAMjC,eAAeC,EAAwBC,EAA0C,CAC/E,GAAIH,EACF,MAAO,GAKT,MAAMI,EAAc,MAAMC,EAAeF,CAAM,EAC/C,MAAMG,EAAWH,EAAQC,EAAY,IAAI,EAGzCG,EAAqB,EAErB,OAAO,iBAAiBC,EAAqB,UAAW,MAAOC,GAAkB,CAC/E,MAAMC,EAAQD,EACRE,EAAkB,kCAElBC,EAAgBF,EAAM,OAAO,OAAS,MAAQA,EAAM,OAAO,IAAI,YAAcA,EAAM,OAAO,SAAS,IACnGG,EAAM,IAAI,IAAID,CAAa,EACjC,GAAI,CAACD,EAAgB,KAAKE,EAAI,QAAQ,EACpC,OAEF,MAAMT,EAAc,MAAMC,EAAeF,CAAM,EAC/C,GAAI,CAACC,EAAY,QACf,OAEF,MAAMU,EAAwB,CAC5B,OAAQV,EAAY,KAAK,OACzB,QAAS,CACP,MAAOA,EAAY,KAAK,QAAQ,KAClC,CACF,EACA,OAAO,cAAc,IAAIW,EAAoBD,CAAW,CAAC,EAEzD,MAAMR,EAAWH,EAAQC,EAAY,IAAI,CAC3C,CAAC,EAGD,IAAIY,EACAC,EACJ,OAAO,OAAA,iBAAiBC,EAAyB,UAAW,MAAOT,GAAW,CAC5E,MAAMC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AAS,MAAMC,EAAe,MAAM,EAC1C,GAAID,EAAQ,CACV,MAAMgD,EAAmBzB,EAAyB,CAAE,OAAAS,CAAO,CAAC,EACtDiB,EAAgBD,EAAiB,YAAY,MAAM,GAAK,CAAC,EAC/DA,EAAiB,YAAY,OAAQ,CAAE,GAAGC,EAAe,OAAAjD,CAAO,CAAC,CACnE,CAGA,MAAMkD,EAAS,SAAS,cAAc,oBAAoB,EAC1DA,EAAO,OAASlB,EAChBkB,EAAO,QAAUjB,EACjBiB,EAAO,QAAU7C,EACjB6C,EAAO,WAAaf,EACpBe,EAAO,YAAcd,EACrBc,EAAO,QAAU,OAAOb,CAAO,EAC/Ba,EAAO,MAAQZ,EACfY,EAAO,UAAYX,EACnBW,EAAO,KAAOnC,EACdmC,EAAO,cAAgBV,EACvBU,EAAO,aAAeT,EACtBS,EAAO,OAASR,EAChBQ,EAAO,KAAOP,EACdO,EAAO,MAAQN,EAGfC,EAAc,YAAYK,CAAM,CAClC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as lodash from 'lodash';
|
|
2
|
-
import { B as BeamCartAPIConfig, a as BeamCartValues } from './update-cart-
|
|
3
|
-
import { T as TCart } from './cart-contents-
|
|
2
|
+
import { B as BeamCartAPIConfig, a as BeamCartValues } from './update-cart-43LEXveI.esm.js';
|
|
3
|
+
import { T as TCart } from './cart-contents-dKdDg09p.esm.js';
|
|
4
4
|
import '../components/post-purchase.js';
|
|
5
5
|
import { T as TUrl, L as LANGUAGES } from './types-aju0qrRe.esm.js';
|
|
6
6
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as T}from"./lodash-P8OIs-at.esm.js";import{d as U,f as A,c as O,g as R}from"./events-Y8fYvSqM.esm.js";import{logger as j}from"../utils/logger.esm.js";import{initNetworkListeners as k}from"../utils/network-listeners.esm.js";import{createScopedLocalStorage as E}from"../utils/local-storage.esm.js";import{getCookieValue as u}from"../utils/cookies.esm.js";import{memoizeLast as J}from"../utils/memoize-last.esm.js";import{B as b}from"./cart-contents-h60geKWa.esm.js";import{x as I}from"./update-cart-6fMyZd34.esm.js";import"../components/post-purchase.esm.js";import{D as x}from"./routes-UBDDazXd.esm.js";import{waitForElement as K}from"../utils/wait-for-element.esm.js";import{B as P}from"./beam-errors-P-Lu07Ce.esm.js";const N=window.Shopify?.routes?.root||"/";let S=!1;const v="cart";async function D(a){if(S)return!1;const p=await h(a);await I(a,p.cart),k(),window.addEventListener(U.eventName,async i=>{const r=i,t=/cart\/(add|change|update|clear)/,e=r.detail.type==="xhr"?r.detail.xhr.responseURL:r.detail.response.url,d=new URL(e);if(!t.test(d.pathname))return;const n=await h(a);if(!n.changed)return;const m={schema:n.cart.schema,content:{items:n.cart.content.items}};window.dispatchEvent(new A(m)),await I(a,n.cart)});let c,s;return window.addEventListener(O.eventName,async i=>{const r=i,{selectedNonprofitId:t,selectionId:e}=r.detail,d=await u(v),n=await u(b),{chainId:m,storeId:l}=a;c===t&&s===e||(await y({selectedNonprofitId:t,selectionId:e,beamCartId:n,cartId:d,chainId:m,storeId:l}),s=e,c=t)}),window.addEventListener(R.eventName,async i=>{const r=i,{newNonprofitId:t,selectionId:e}=r.detail,d=await u(v),n=await u(b),{chainId:m,storeId:l}=a;c===t&&s===e||(await y({selectedNonprofitId:t,beamCartId:n,selectionId:e,cartId:d,chainId:m,storeId:l}),s=e,c=t)}),S=!0,!0}async function h(a){const{token:p,total_price:c,item_count:s,currency:i,items:r}=await window.fetch(N+"cart.js",{method:"GET",headers:{"Content-Type":"application/json"}}).then(n=>n.json()),t={cartId:p,subtotal:c/100,itemCount:s,currencyCode:i,schema:{source:"generic"},content:{items:r.map(({sku:n,final_line_price:m,product_id:l})=>{const f=n||String(l),w=m/100;return{remoteProductIdentifier:f,localAmount:w}})}};let e=!1;const d=E(a).getItemJson("cart");return T(t,d)||(e=!0),{changed:e,cart:t}}const q=I,y=J(async function({selectedNonprofitId:a,selectionId:p,beamCartId:c,cartId:s,chainId:i,storeId:r}){const t={beam:JSON.stringify({nonprofit_id:a,selection_id:p,beam_cart_id:c,shopify_cart_id:s,chain_id:i,store_id:r})};try{await window.fetch(N+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:t})})}catch(e){j.error(e)}});async function F({parentSelector:a=".step__sections",apiKey:p,baseUrl:c=x,storeId:s,postalCode:i,countryCode:r,orderId:t,email:e,cartTotal:d,cart:n,discountCodes:m,currencyCode:l="USD",domain:f,lang:w="en",debug:B=!1}){const g=document.querySelector(a)||await K(a);if(!g)throw new P(`Timed out waiting for selector '${a}'. Could not render Beam post-purchase widget.`);const C=await u("cart");if(C){const _=E({apiKey:p}),L=_.getItemJson("cart")||{};_.setItemJson("cart",{...L,cartId:C})}const o=document.createElement("beam-post-purchase");o.apiKey=p,o.baseUrl=c,o.storeId=s,o.postalCode=i,o.countryCode=r,o.orderId=String(t),o.email=e,o.cartTotal=d,o.cart=n,o.discountCodes=m,o.currencyCode=l,o.domain=f,o.lang=w,o.debug=B,g.appendChild(o)}export{D as P,q as R,y as f,h as p,F as s};
|
|
2
|
+
//# sourceMappingURL=order-page-E7Kyu1JP.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-page-E7Kyu1JP.esm.js","sources":["../../src/integrations/shopify/cart-page.ts","../../src/integrations/shopify/order-page.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport isEqual from \"lodash-es/isEqual\";\nimport { logger, memoizeLast } from \"../../utils\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { initNetworkListeners } from \"../../utils/network-listeners\";\nimport {\n BeamCartChangeEvent,\n BeamNetworkCallEvent,\n BeamNonprofitSelectEvent,\n BeamNonprofitSelectionRemovedEvent,\n} from \"../../utils/events\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { BEAM_CART_COOKIE_NAME, TCart, TCartApi, TCartItems } from \"../../shared/cart-contents\";\nimport { BeamCartAPIConfig, updateCart } from \"../cart\";\n\ntype BeamShopifyCartIntegrationConfig = BeamCartAPIConfig & {\n storeId: number; // will be added to cart custom_attributes, and used in cart API call\n chainId?: number; // will be added to cart custom_attributes\n};\n\nconst SHOPIFY_BASE_URL = window.Shopify?.routes?.root || \"/\"; // see window.d.ts\n\nlet isBeamCartIntegrationRegistered = false; // Skip registering event listeners if already set up\n\nconst SHOPIFY_CART_COOKIE_NAME = \"cart\";\n\n/**\n * @main registerCartIntegration - set up event listeners to integrate Beam with Shopify cart\n * @return {boolean} returns true if NEW listeners were created, false if setup was already done\n */\nasync function registerCartIntegration(config: BeamShopifyCartIntegrationConfig) {\n if (isBeamCartIntegrationRegistered) {\n return false; // Do nothing if listeners are already attached\n }\n\n // Handle full-page load, ie, first-time page load and reloads from form submit events\n // This creates a GET to /cart.js\n const currentCart = await getCurrentCart(config);\n await updateCart(config, currentCart.cart);\n\n // Set up event listeners for AJAX events\n initNetworkListeners();\n\n window.addEventListener(BeamNetworkCallEvent.eventName, async (_event: Event) => {\n const event = _event as BeamNetworkCallEvent;\n const cartChangePaths = /cart\\/(add|change|update|clear)/;\n // note: response urls below follow redirects\n const requestUrlStr = event.detail.type === \"xhr\" ? event.detail.xhr.responseURL : event.detail.response.url;\n const url = new URL(requestUrlStr);\n if (!cartChangePaths.test(url.pathname)) {\n return;\n }\n const currentCart = await getCurrentCart(config);\n if (!currentCart.changed) {\n return;\n }\n const eventDetail: TCartApi = {\n schema: currentCart.cart.schema as any, // TS union type can't figure out what variant applies here\n content: {\n items: currentCart.cart.content.items as any,\n },\n };\n window.dispatchEvent(new BeamCartChangeEvent(eventDetail));\n // Send cart to Beam to update timestamp, which is used for cart abandonment / ROI calc\n await updateCart(config, currentCart.cart);\n });\n\n // Listen to Beam's own events to integrate Beam data into Shopify order\n let lastNonprofitId: number | null | undefined;\n let lastSelectionId: string | null | undefined;\n window.addEventListener(BeamNonprofitSelectEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectEvent;\n const { selectedNonprofitId, selectionId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME); // Shopify cart ID cookie\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME); // Beam cart ID cookie\n const { chainId, storeId } = config;\n // Skip update if nothing changed (can happen if widget is re-initialized and\n // emits event after cache restoration, i.e., on cart re-render).\n if (lastNonprofitId === selectedNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = selectedNonprofitId;\n });\n\n /**\n * Upon removal of the selected nonprofit from the widget and local storage,\n * an event is emitted and that event is then used to update the cart attributes accordingly\n * This event listener updates the cart attributes based on the emitted event\n */\n window.addEventListener(BeamNonprofitSelectionRemovedEvent.eventName, async (_event) => {\n const event = _event as BeamNonprofitSelectionRemovedEvent;\n const { newNonprofitId, selectionId } = event.detail;\n const cartId = await getCookieValue(SHOPIFY_CART_COOKIE_NAME);\n const beamCartId = await getCookieValue(BEAM_CART_COOKIE_NAME);\n const { chainId, storeId } = config;\n if (lastNonprofitId === newNonprofitId && lastSelectionId === selectionId) {\n return;\n }\n await addBeamAttributesToCart({\n selectedNonprofitId: newNonprofitId,\n beamCartId,\n selectionId,\n cartId,\n chainId,\n storeId,\n });\n lastSelectionId = selectionId;\n lastNonprofitId = newNonprofitId;\n });\n\n isBeamCartIntegrationRegistered = true;\n\n return true;\n}\n\n/* ***************************************** HELPER FUNCTIONS *****************************************\n These may be used individually to integrate with carts if the registerCartIntegration\n script doesn't work for some reason.\n ****************************************************************************************************/\n\n/**\n * Detects change in cart since last page load,\n * by calling GET /cart.js, and returns cart values.\n * Used for:\n * - Form-based carts where the page refreshes to modify cart instead of using AJAX calls\n * - Hydrogen/GraphQL based carts (needs to be integrated manually)\n */\nasync function getCurrentCart(config: BeamShopifyCartIntegrationConfig): Promise<{\n changed: boolean;\n cart: {\n cartId: string;\n subtotal: number;\n itemCount: number;\n currencyCode: string;\n } & TCart;\n}> {\n const {\n token, // equal to \"cart\" cookie\n total_price, // this is the pretax value, after discounts, and multiplied by 100 (integer from decimal)\n item_count,\n currency,\n items,\n } = await window\n .fetch(SHOPIFY_BASE_URL + \"cart.js\", {\n method: \"GET\",\n headers: { \"Content-Type\": \"application/json\" },\n })\n .then((res) => res.json());\n\n const cart = {\n cartId: token,\n subtotal: total_price / 100,\n itemCount: item_count,\n currencyCode: currency,\n schema: { source: \"generic\" } as const,\n content: {\n // pull out minimal fields from full line items\n items: (items as TCartItems).map(({ sku, final_line_price, product_id }) => {\n const remoteProductIdentifier = sku || String(product_id);\n const localAmount = final_line_price / 100;\n return { remoteProductIdentifier, localAmount };\n }),\n },\n };\n\n let changed = false;\n\n const localStorage = createScopedLocalStorage(config);\n\n const cachedCart = localStorage.getItemJson(\"cart\");\n\n if (!isEqual(cart, cachedCart)) {\n changed = true;\n }\n\n return { changed, cart };\n}\n\n/**\n * trackCart - Backwards-compatible alias for updateCart\n */\nconst trackCart = updateCart;\n\n/**\n * Sends Beam data to Shopify to integrate with order as custom attributes.\n * Memoized so that calls with the same data as the previous don't create additional API calls to Shopify.\n */\nconst addBeamAttributesToCart = memoizeLast(async function addBeamAttributesToCart({\n selectedNonprofitId,\n selectionId,\n beamCartId,\n cartId,\n chainId,\n storeId,\n}: {\n selectedNonprofitId?: number | null;\n selectionId?: string;\n beamCartId?: string;\n cartId?: string;\n chainId?: number;\n storeId?: number;\n}) {\n const beamCartAttrs = {\n beam: JSON.stringify({\n nonprofit_id: selectedNonprofitId,\n selection_id: selectionId,\n beam_cart_id: beamCartId,\n shopify_cart_id: cartId,\n chain_id: chainId,\n store_id: storeId,\n }),\n };\n\n try {\n await window.fetch(SHOPIFY_BASE_URL + \"cart/update.js\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ attributes: beamCartAttrs }),\n });\n } catch (err) {\n logger.error(err); // don't throw, allow later calls to continue\n }\n});\n\nexport { trackCart, getCurrentCart, addBeamAttributesToCart, registerCartIntegration };\n","import \"../../components/post-purchase\";\nimport { postTransaction } from \"../../api-sdk/v3/routes\";\nimport { DEFAULT_BASE_URL } from \"../../api-sdk/constants\";\nimport { LANGUAGES, TUrl } from \"../../api-sdk/types\";\nimport { waitForElement } from \"../../utils/wait-for-element\";\nimport { BeamError } from \"../../utils/beam-errors\";\nimport { getCookieValue } from \"../../utils/cookies\";\nimport { createScopedLocalStorage } from \"../../utils/local-storage\";\nimport { TCart } from \"../../shared/cart-contents\";\n\n// Shopify admin page: admin/settings/checkout\n\nexport type TBeamOrderPageParams = Parameters<typeof postTransaction>[0][\"requestBody\"] & {\n // Either storeId or postalCode + countryCode must be provided\n storeId?: number;\n postalCode?: string;\n countryCode?: string;\n orderId: string;\n email: string;\n cartTotal: number;\n cart: TCart;\n discountCodes: string[];\n currencyCode: string;\n parentSelector: string; // CSS Selector for parent of widget to be inserted into DOM\n apiKey: string;\n baseUrl: TUrl;\n domain?: string; // Base domain for setting cookies\n lang: LANGUAGES;\n debug: boolean;\n};\n\nexport async function showBeamOrderPageWidgets({\n parentSelector = \".step__sections\",\n apiKey,\n baseUrl = DEFAULT_BASE_URL,\n storeId,\n postalCode,\n countryCode,\n orderId,\n email,\n cartTotal,\n cart,\n discountCodes,\n currencyCode = \"USD\",\n domain,\n lang = \"en\",\n debug = false,\n}: TBeamOrderPageParams) {\n const parentElement = document.querySelector(parentSelector) || (await waitForElement(parentSelector));\n if (!parentElement) {\n throw new BeamError(\n `Timed out waiting for selector '${parentSelector}'. Could not render Beam post-purchase widget.`\n );\n }\n\n // If checkout and order page are on different subdomains, we can't access localStorage\n // We can make postTransaction work by copying the cart cookie to the expected localStorage key on the current domain\n const cartId = await getCookieValue(\"cart\"); // Shopify-only cart identifier\n if (cartId) {\n const beamLocalStorage = createScopedLocalStorage({ apiKey });\n const existingValue = beamLocalStorage.getItemJson(\"cart\") || {};\n beamLocalStorage.setItemJson(\"cart\", { ...existingValue, cartId });\n }\n\n // Note: assign properties one by one instead of bulk Object.assign to type check assignments\n const widget = document.createElement(\"beam-post-purchase\");\n widget.apiKey = apiKey;\n widget.baseUrl = baseUrl;\n widget.storeId = storeId;\n widget.postalCode = postalCode;\n widget.countryCode = countryCode;\n widget.orderId = String(orderId);\n widget.email = email;\n widget.cartTotal = cartTotal;\n widget.cart = cart;\n widget.discountCodes = discountCodes;\n widget.currencyCode = currencyCode;\n widget.domain = domain;\n widget.lang = lang;\n widget.debug = debug;\n\n // Insert widget into DOM\n parentElement.appendChild(widget);\n}\n"],"names":["SHOPIFY_BASE_URL","isBeamCartIntegrationRegistered","SHOPIFY_CART_COOKIE_NAME","registerCartIntegration","config","currentCart","getCurrentCart","updateCart","initNetworkListeners","BeamNetworkCallEvent","_event","event","cartChangePaths","requestUrlStr","url","eventDetail","BeamCartChangeEvent","lastNonprofitId","lastSelectionId","BeamNonprofitSelectEvent","selectedNonprofitId","selectionId","cartId","getCookieValue","beamCartId","BEAM_CART_COOKIE_NAME","chainId","storeId","addBeamAttributesToCart","BeamNonprofitSelectionRemovedEvent","newNonprofitId","token","total_price","item_count","currency","items","res","cart","sku","final_line_price","product_id","remoteProductIdentifier","localAmount","changed","cachedCart","createScopedLocalStorage","isEqual","trackCart","memoizeLast","beamCartAttrs","err","logger","showBeamOrderPageWidgets","parentSelector","apiKey","baseUrl","DEFAULT_BASE_URL","postalCode","countryCode","orderId","email","cartTotal","discountCodes","currencyCode","domain","lang","debug","parentElement","waitForElement","BeamError","beamLocalStorage","existingValue","widget"],"mappings":"utBAoBA,MAAMA,EAAmB,OAAO,SAAS,QAAQ,MAAQ,IAEzD,IAAIC,EAAkC,GAEtC,MAAMC,EAA2B,OAMjC,eAAeC,EAAwBC,EAA0C,CAC/E,GAAIH,EACF,MAAO,GAKT,MAAMI,EAAc,MAAMC,EAAeF,CAAM,EAC/C,MAAMG,EAAWH,EAAQC,EAAY,IAAI,EAGzCG,EAAqB,EAErB,OAAO,iBAAiBC,EAAqB,UA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as b,h as l,y as d}from"./lit-
|
|
1
|
+
import{f as m,g as b,h as l,y as d}from"./lit-HCWbxxT7.esm.js";var c=Object.defineProperty,u=Object.getOwnPropertyDescriptor,g=(s,a,t,e)=>{for(var r=e>1?void 0:e?u(a,t):a,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=(e?n(a,t,r):n(r))||r);return e&&r&&c(a,t,r),r};class o extends l{constructor(){super(...arguments),this.value=0,this.animateProgress=!0}render(){return d`<div class="progress-bar-container">
|
|
2
2
|
<style>
|
|
3
3
|
:host {
|
|
4
4
|
--beam-ProgressBar-value: ${this.value};
|
|
@@ -50,4 +50,4 @@ import{f as m,g as b,h as l,y as d}from"./lit-yVXn5Cbs.esm.js";var c=Object.defi
|
|
|
50
50
|
animation-timing-function: linear;
|
|
51
51
|
}
|
|
52
52
|
`,g([b({type:Number})],o.prototype,"value",2),g([b({type:Boolean})],o.prototype,"animateProgress",2),customElements.get("beam-progress-bar")||customElements.define("beam-progress-bar",o);const p={"--beam-ProgressBar-border-radius":"0px","--beam-ProgressBar-height":"10px","--beam-ProgressBar-color-background":"transparent","--beam-ProgressBar-border-width":"1px","--beam-ProgressBar-color-border":"currentColor","--beam-ProgressBar-color-bar":"currentColor","--beam-ProgressBar-animation-duration-base":"0s","--beam-ProgressBar-animation-duration-variable":"0s"};export{p};
|
|
53
|
-
//# sourceMappingURL=progress-bar-
|
|
53
|
+
//# sourceMappingURL=progress-bar-9vfd2JYm.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress-bar-
|
|
1
|
+
{"version":3,"file":"progress-bar-9vfd2JYm.esm.js","sources":["../../src/shared/components/progress-bar.ts"],"sourcesContent":["import { css, html, LitElement } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\n\nexport class BeamProgressBar extends LitElement {\n @property({ type: Number }) value = 0;\n @property({ type: Boolean }) animateProgress = true;\n\n render() {\n return html`<div class=\"progress-bar-container\">\n <style>\n :host {\n --beam-ProgressBar-value: ${this.value};\n }\n </style>\n <div class=\"progress-bar\"></div>\n </div>`;\n }\n\n static styles = css`\n :host {\n display: inline-block;\n min-width: 20px;\n }\n\n .progress-bar-container {\n border-radius: var(--beam-ProgressBar-border-radius, 10px);\n height: var(--beam-ProgressBar-height, 10px);\n padding: 0;\n width: 100%;\n background: var(--beam-ProgressBar-color-background, lightgray);\n position: relative;\n border: var(--beam-ProgressBar-border-width, 1px) solid var(--beam-ProgressBar-color-border, currentColor);\n overflow: hidden;\n }\n\n @keyframes animate-bar {\n 0% {\n width: 0;\n }\n\n 100% {\n width: calc(var(--beam-ProgressBar-value) * 1%);\n }\n }\n\n .progress-bar {\n width: calc(var(--beam-ProgressBar-value, 0) * 1%);\n height: 100%;\n position: absolute;\n background: var(--beam-ProgressBar-color-bar, linear-gradient(to right, currentColor, currentColor));\n left: 0;\n bottom: 0;\n top: 0;\n background-clip: padding-box;\n animation-duration: calc(\n var(--beam-ProgressBar-animation-duration-base, 0s) + var(--beam-ProgressBar-animation-duration-variable, 0s) *\n var(--beam-ProgressBar-value) / 100\n );\n animation-iteration-count: 1;\n animation-name: animate-bar;\n animation-timing-function: linear;\n }\n `;\n}\n\ncustomElements.get(\"beam-progress-bar\") || customElements.define(\"beam-progress-bar\", BeamProgressBar);\n\nexport const progressBarConfigDefaults = {\n \"--beam-ProgressBar-border-radius\": \"0px\",\n \"--beam-ProgressBar-height\": \"10px\",\n \"--beam-ProgressBar-color-background\": \"transparent\",\n \"--beam-ProgressBar-border-width\": \"1px\",\n \"--beam-ProgressBar-color-border\": \"currentColor\",\n \"--beam-ProgressBar-color-bar\": \"currentColor\",\n \"--beam-ProgressBar-animation-duration-base\": \"0s\",\n \"--beam-ProgressBar-animation-duration-variable\": \"0s\",\n} as const;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"beam-progress-bar\": BeamProgressBar;\n }\n}\n"],"names":["BeamProgressBar","LitElement","html","css","__decorateClass","property","progressBarConfigDefaults"],"mappings":"qQAGaA,UAAwBC,CAAW,CAAzC,aACuB,CAAA,MAAA,GAAA,SAAA,EAAA,KAAA,MAAQ,EACP,KAAkB,gBAAA,EAAA,CAE/C,QAAS,CACP,OAAOC;AAAAA;AAAAA;AAAAA,sCAG2B,KAAK,KAAK;AAAA;AAAA;AAAA;AAAA,WAK9C,CA+CF,CA5DaF,EAeJ,OAASG;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,IAdYC,EAAA,CAA3BC,EAAS,CAAE,KAAM,MAAO,CAAC,GADfL,EACiB,UAAA,QAAA,CAAA,EACCI,EAAA,CAA5BC,EAAS,CAAE,KAAM,OAAQ,CAAC,CAFhB,EAAAL,EAEkB,UA4D/B,kBAAA,CAAA,EAAA,eAAe,IAAI,mBAAmB,GAAK,eAAe,OAAO,oBAAqBA,CAAe,QAExFM,EAA4B,CACvC,mCAAoC,MACpC,4BAA6B,OAC7B,sCAAuC,cACvC,kCAAmC,MACnC,kCAAmC,eACnC,+BAAgC,eAChC,6CAA8C,KAC9C,iDAAkD,IACpD"}
|