@internetarchive/elements 1.9.1 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +17 -0
  2. package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.d.ts.map +1 -1
  3. package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js +7 -7
  4. package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js.map +1 -1
  5. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.d.ts.map +1 -1
  6. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js +12 -8
  7. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js.map +1 -1
  8. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.d.ts.map +1 -1
  9. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js +5 -4
  10. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js.map +1 -1
  11. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.d.ts.map +1 -1
  12. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js +5 -4
  13. package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js.map +1 -1
  14. package/dist/src/elements/ia-donation-form/ia-donation-form-controller.d.ts.map +1 -1
  15. package/dist/src/elements/ia-donation-form/ia-donation-form-controller.js +3 -2
  16. package/dist/src/elements/ia-donation-form/ia-donation-form-controller.js.map +1 -1
  17. package/dist/src/elements/ia-donation-form/localized-format.d.ts +20 -0
  18. package/dist/src/elements/ia-donation-form/localized-format.d.ts.map +1 -0
  19. package/dist/src/elements/ia-donation-form/localized-format.js +73 -0
  20. package/dist/src/elements/ia-donation-form/localized-format.js.map +1 -0
  21. package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.d.ts.map +1 -1
  22. package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js +6 -2
  23. package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js.map +1 -1
  24. package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.d.ts.map +1 -1
  25. package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.js +2 -1
  26. package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.js.map +1 -1
  27. package/dist/src/elements/ia-donation-form/parse-amount.d.ts +12 -0
  28. package/dist/src/elements/ia-donation-form/parse-amount.d.ts.map +1 -0
  29. package/dist/src/elements/ia-donation-form/parse-amount.js +39 -0
  30. package/dist/src/elements/ia-donation-form/parse-amount.js.map +1 -0
  31. package/dist/src/elements/ia-donation-thermometer/ia-donation-thermometer.d.ts +12 -1
  32. package/dist/src/elements/ia-donation-thermometer/ia-donation-thermometer.d.ts.map +1 -1
  33. package/dist/src/elements/ia-donation-thermometer/ia-donation-thermometer.js +21 -9
  34. package/dist/src/elements/ia-donation-thermometer/ia-donation-thermometer.js.map +1 -1
  35. package/package.json +4 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ia-donation-total-amount.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-total-amount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qFAAqF;AAE9E,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAGnD,MAAM;QACJ,OAAO,IAAI,CAAA;;gCAEiB,IAAI,CAAC,SAAS;KACzC,CAAC;IACJ,CAAC;IAED,IAAY,SAAS;QACnB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,OAAO,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAC3E,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO;YAC5D,CAAC,CAAC,GAAG,CAAC,GAAG,CAAA,UAAU,MAAM,QAAQ,CAAC;YAClC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAA,UAAU,MAAM,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA3D6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAoC;AADpD,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CA4DjC","sourcesContent":["import {\n css,\n html,\n LitElement,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { msg, str } from '@lit/localize';\nimport currency from 'currency.js';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport type { DonationPaymentInfo } from '../models/donation-payment-info';\nimport { DonationType } from '../models/donation-type';\n\n/** The \"Total: $X\" line under the amount picker, with \"/month\" for monthly gifts. */\n@customElement('ia-donation-total-amount')\nexport class IADonationTotalAmount extends LitElement {\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n render(): TemplateResult {\n return html`\n <div class=\"top-line\"></div>\n <div class=\"total-line\">${this.totalLine}</div>\n `;\n }\n\n private get totalLine(): string {\n if (!this.donationInfo) return '';\n const amount = currency(this.donationInfo.total, { symbol: '$' }).format();\n return this.donationInfo.donationType === DonationType.Monthly\n ? msg(str`Total: ${amount}/month`)\n : msg(str`Total: ${amount}`);\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-total-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-total-line-color--: var(\n --ia-donation-total-amount-line-color,\n var(--mid-gray)\n );\n --donation-total-line-thickness--: var(\n --ia-donation-total-amount-line-thickness,\n 2px\n );\n --donation-total-vertical-spacing--: var(\n --ia-donation-total-amount-vertical-spacing,\n var(--padding-sm)\n );\n --donation-total-font-size--: var(\n --ia-donation-total-amount-font-size,\n calc(var(--donation-total-base-font-size--) * 2.6)\n );\n }\n\n .top-line {\n width: 100%;\n height: var(--donation-total-line-thickness--);\n background-color: var(--donation-total-line-color--);\n }\n\n .total-line {\n font-size: var(--donation-total-font-size--);\n font-weight: bold;\n text-align: center;\n margin-top: var(--donation-total-vertical-spacing--);\n }\n `,\n ];\n }\n}\n"]}
1
+ {"version":3,"file":"ia-donation-total-amount.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-total-amount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qFAAqF;AAG9E,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAGnD,MAAM;QACJ,OAAO,IAAI,CAAA;;gCAEiB,IAAI,CAAC,SAAS;KACzC,CAAC;IACJ,CAAC;IAED,IAAY,SAAS;QACnB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,OAAO,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO;YAC5D,CAAC,CAAC,GAAG,CAAC,GAAG,CAAA,UAAU,MAAM,QAAQ,CAAC;YAClC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAA,UAAU,MAAM,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA3D6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAoC;AADpD,qBAAqB;IAFjC,aAAa,CAAC,0BAA0B,CAAC;IACzC,SAAS,EAAE;GACC,qBAAqB,CA4DjC","sourcesContent":["import {\n css,\n html,\n LitElement,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { localized, msg, str } from '@lit/localize';\nimport { formatUsd } from '../localized-format';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport type { DonationPaymentInfo } from '../models/donation-payment-info';\nimport { DonationType } from '../models/donation-type';\n\n/** The \"Total: $X\" line under the amount picker, with \"/month\" for monthly gifts. */\n@customElement('ia-donation-total-amount')\n@localized()\nexport class IADonationTotalAmount extends LitElement {\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n render(): TemplateResult {\n return html`\n <div class=\"top-line\"></div>\n <div class=\"total-line\">${this.totalLine}</div>\n `;\n }\n\n private get totalLine(): string {\n if (!this.donationInfo) return '';\n const amount = formatUsd(this.donationInfo.total);\n return this.donationInfo.donationType === DonationType.Monthly\n ? msg(str`Total: ${amount}/month`)\n : msg(str`Total: ${amount}`);\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-total-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-total-line-color--: var(\n --ia-donation-total-amount-line-color,\n var(--mid-gray)\n );\n --donation-total-line-thickness--: var(\n --ia-donation-total-amount-line-thickness,\n 2px\n );\n --donation-total-vertical-spacing--: var(\n --ia-donation-total-amount-vertical-spacing,\n var(--padding-sm)\n );\n --donation-total-font-size--: var(\n --ia-donation-total-amount-font-size,\n calc(var(--donation-total-base-font-size--) * 2.6)\n );\n }\n\n .top-line {\n width: 100%;\n height: var(--donation-total-line-thickness--);\n background-color: var(--donation-total-line-color--);\n }\n\n .total-line {\n font-size: var(--donation-total-font-size--);\n font-weight: bold;\n text-align: center;\n margin-top: var(--donation-total-vertical-spacing--);\n }\n `,\n ];\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ia-donation-form-controller.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/ia-donation-form-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAIb,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAEV,yBAAyB,EAC1B,MAAM,oCAAoC,CAAC;AAG5C,OAAO,KAAK,EACV,iCAAiC,EACjC,yBAAyB,EAC1B,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCA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OAAO,KAAK,iBAAiB,GA2C5B;IAED,MAAM,IAAI,cAAc;IA+CxB,gFAAgF;IAChF,gBAAgB,IAAI,IAAI;IAIxB,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,uBAAuB;IAoB/B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,YAAY;IAIpB,8CAA8C;IAC9C,OAAO,CAAC,QAAQ;IAShB,wDAAwD;IACxD,OAAO,CAAC,oBAAoB;IAS5B;;;;;;;OAOG;IACH,OAAO,KAAK,SAAS,GAyEpB;CACF"}
1
+ {"version":3,"file":"ia-donation-form-controller.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/ia-donation-form-controller.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAIb,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAEV,yBAAyB,EAC1B,MAAM,oCAAoC,CAAC;AAG5C,OAAO,KAAK,EACV,iCAAiC,EACjC,yBAAyB,EAC1B,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,iCAAiC,EACjC,kCAAkC,EACnC,MAAM,2CAA2C,CAAC;AAGnD,OAAO,EACL,mBAAmB,EAGpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM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B;IAKxB,OAAO,CAAC,YAAY;IAIpB,8CAA8C;IAC9C,OAAO,CAAC,QAAQ;IAShB,wDAAwD;IACxD,OAAO,CAAC,oBAAoB;IAS5B;;;;;;;OAOG;IACH,OAAO,KAAK,SAAS,GAyEpB;CACF"}
@@ -2,7 +2,7 @@ import { __decorate } from "tslib";
2
2
  import { html, LitElement, } from 'lit';
3
3
  import { property, query } from 'lit/decorators.js';
4
4
  import { customElement } from '../../utils/custom-element.js';
5
- import currency from 'currency.js';
5
+ import { parseAmount } from './parse-amount.js';
6
6
  import { LazyLoaderService, } from '@internetarchive/lazy-loader-service';
7
7
  import { BraintreeManager } from './braintree/braintree-manager.js';
8
8
  import { PaymentClients, } from './braintree/payment-clients.js';
@@ -160,7 +160,8 @@ let IADonationFormController = class IADonationFormController extends LitElement
160
160
  let amount = this.donationInfo.amount;
161
161
  const amountParam = urlParams.get('amt');
162
162
  if (amountParam) {
163
- const parsedAmount = currency(amountParam).value;
163
+ // Links like ?amt=$10 or ?amt=10 USD have always worked
164
+ const parsedAmount = parseAmount(amountParam.replace(/usd|\$/gi, '').trim());
164
165
  if (parsedAmount > 0) {
165
166
  amount = parsedAmount;
166
167
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ia-donation-form-controller.js","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/ia-donation-form-controller.ts"],"names":[],"mappings":";AACA,OAAO,EACL,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EACL,iBAAiB,GAElB,MAAM,sCAAsC,CAAC;AAO9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAMjE,OAAO,EACL,cAAc,GAEf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE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,CAAC;kEAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAsC;AAGrC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEAAgC;AAE/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEAA8C;AAGzE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEACwB;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAA0C;AAMrE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAC6C;AAErC;IAAlC,KAAK,CAAC,kBAAkB,CAAC;8DAAuC;AAGzD;IADP,KAAK,CAAC,gCAAgC,CAAC;yEACqB;AAGrD;IADP,KAAK,CAAC,0BAA0B,CAAC;6DACU;AAjEjC,wBAAwB;IADpC,aAAa,CAAC,6BAA6B,CAAC;GAChC,wBAAwB,CA+jBpC","sourcesContent":["import type * as braintree from 'braintree-web';\nimport {\n html,\n LitElement,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport currency from 'currency.js';\nimport {\n LazyLoaderService,\n type LazyLoaderServiceInterface,\n} from '@internetarchive/lazy-loader-service';\nimport type { ModalManagerInterface } from '@src/elements/modal-manager/models';\nimport type {\n AnalyticsEvent,\n AnalyticsManagerInterface,\n} from '@internetarchive/analytics-manager';\n\nimport { BraintreeManager } from './braintree/braintree-manager';\nimport type {\n BraintreeEndpointManagerInterface,\n BraintreeManagerInterface,\n} from './braintree/braintree-manager-interface';\nimport type { HostingEnvironment } from './braintree/hosting-environment';\nimport {\n PaymentClients,\n type PaymentClientsInterface,\n} from './braintree/payment-clients';\nimport { HostedFieldConfiguration } from './braintree/payment-providers/credit-card/hosted-field-configuration';\nimport {\n PaymentFlowHandlers,\n type PaymentFlowHandlersInterface,\n} from './flow-handlers/payment-flow-handlers';\nimport type { IADonationContactForm } from './form-elements/contact-form/ia-donation-contact-form';\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from './form-elements/ia-donation-edit-donation';\nimport type { IADonationCreditCardFields } from './form-elements/ia-donation-credit-card-fields';\nimport type { IADonationForm } from './ia-donation-form';\nimport {\n DonationPaymentInfo,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from './models/donation-payment-info';\nimport { DonationType } from './models/donation-type';\nimport type { PaymentProvider } from './models/payment-provider';\nimport type { UpsellModalCTAMode } from './modals/ia-donation-upsell-modal-content';\nimport {\n RecaptchaManager,\n type RecaptchaManagerInterface,\n} from './recaptcha-manager';\nimport './form-elements/contact-form/ia-donation-contact-form';\nimport './form-elements/ia-donation-credit-card-fields';\nimport './ia-donation-form';\n\n/**\n * Wires the donation form to everything around it: Braintree and the payment\n * libraries, the modal manager, recaptcha, and analytics. Give it the\n * environment, tokens and an endpoint manager and it builds the rest.\n *\n * It renders into the light DOM, because Braintree's hosted fields, the\n * PayPal button and recaptcha all refuse to work inside a shadow root. Those\n * are rendered here and slotted into `<ia-donation-form>`.\n */\n@customElement('ia-donation-form-controller')\nexport class IADonationFormController extends LitElement {\n @property({ type: String }) environment?: HostingEnvironment;\n\n @property({ type: String }) braintreeAuthToken?: string;\n\n @property({ type: String }) recaptchaSiteKey?: string;\n\n @property({ type: String }) venmoProfileId?: string;\n\n @property({ type: String }) googlePayMerchantId?: string;\n\n @property({ type: String }) analyticsCategory = 'DonationForm';\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: Object }) donationInfo: DonationPaymentInfo =\n defaultSelectedDonationInfo;\n\n @property({ type: String })\n amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String })\n frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String }) referrer?: string;\n\n @property({ type: String }) loggedInUser?: string;\n\n @property({ type: String }) origin?: string;\n\n @property({ type: String }) donorEmail: string = '';\n\n @property({ type: Object })\n endpointManager?: BraintreeEndpointManagerInterface;\n\n @property({ type: Object }) analyticsHandler?: AnalyticsManagerInterface;\n\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n /** The element recaptcha renders its (invisible) widget into. Must be in the light DOM. */\n @property({ type: Object }) recaptchaElement?: HTMLElement;\n\n @property({ type: Object }) braintreeManager?: BraintreeManagerInterface;\n\n @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;\n\n @property({ type: Object })\n paymentFlowHandlers?: PaymentFlowHandlersInterface;\n\n @property({ type: Object }) paymentClients?: PaymentClientsInterface;\n\n /** The clients this element built itself, so it knows when it may rebuild them */\n private defaultPaymentClients?: PaymentClientsInterface;\n\n @property({ type: Object })\n lazyLoaderService: LazyLoaderServiceInterface = new LazyLoaderService();\n\n @query('ia-donation-form') private donationForm!: IADonationForm;\n\n @query('ia-donation-credit-card-fields')\n private creditCardFieldsElement!: IADonationCreditCardFields;\n\n @query('ia-donation-contact-form')\n private contactForm?: IADonationContactForm;\n\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('referrer') && this.referrer) {\n this.braintreeManager?.setReferrer(this.referrer);\n this.logDonationFlowEvent('referrer', this.referrer);\n }\n\n if (changedProperties.has('loggedInUser') && this.loggedInUser) {\n this.braintreeManager?.setLoggedInUser(this.loggedInUser);\n }\n\n if (changedProperties.has('origin') && this.origin) {\n this.braintreeManager?.setOrigin(this.origin);\n this.logDonationFlowEvent('origin', this.origin);\n }\n\n if (\n changedProperties.has('paymentClients') ||\n changedProperties.has('braintreeAuthToken') ||\n changedProperties.has('endpointManager') ||\n changedProperties.has('environment')\n ) {\n this.setupBraintreeManager();\n this.setupRecaptchaManager();\n }\n\n if (changedProperties.has('recaptchaSiteKey')) {\n this.setupRecaptchaManager();\n }\n\n if (\n changedProperties.has('braintreeManager') ||\n changedProperties.has('recaptchaManager') ||\n changedProperties.has('modalManager') ||\n changedProperties.has('recaptchaElement')\n ) {\n this.setupPaymentFlowHandlers();\n }\n\n // Build the default clients for the environment, unless the consumer\n // supplied their own\n if (\n (changedProperties.has('environment') ||\n changedProperties.has('lazyLoaderService')) &&\n this.environment &&\n (this.paymentClients === undefined ||\n this.paymentClients === this.defaultPaymentClients)\n ) {\n this.defaultPaymentClients = new PaymentClients(\n this.lazyLoaderService,\n this.environment,\n );\n this.paymentClients = this.defaultPaymentClients;\n }\n }\n\n /** Developer convenience: show the confirmation step without a payment. */\n async showConfirmationStepDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: () => void;\n confirmDonationCB: () => void;\n }): Promise<void> {\n this.donationForm.showConfirmationModalDev(options);\n }\n\n /** Developer convenience: show the upsell modal without a payment. */\n async showUpsellModalDev(options: {\n oneTimeAmount: number;\n ctaMode?: UpsellModalCTAMode;\n yesSelected?: (amount: number) => void;\n noSelected?: () => void;\n amountChanged?: (amount: number) => void;\n userClosedModalCallback?: () => void;\n }): Promise<void> {\n this.donationForm.showUpsellModalDev(options);\n }\n\n private setupBraintreeManager(): void {\n if (\n this.braintreeManager === undefined &&\n this.braintreeAuthToken &&\n this.endpointManager &&\n this.paymentClients &&\n this.environment\n ) {\n this.braintreeManager = new BraintreeManager({\n paymentClients: this.paymentClients,\n endpointManager: this.endpointManager,\n authorizationToken: this.braintreeAuthToken,\n venmoProfileId: this.venmoProfileId,\n googlePayMerchantId: this.googlePayMerchantId,\n hostedFieldConfig: this.hostedFieldConfig,\n hostingEnvironment: this.environment,\n referrer: this.referrer,\n loggedInUser: this.loggedInUser,\n origin: this.origin,\n });\n\n this.braintreeManager.on(\n 'paymentProvidersHostedFieldsRetry',\n (retryNumber: number) => {\n this.dispatchEvent(\n new CustomEvent('paymentProvidersHostedFieldsRetry', {\n detail: { retryNumber },\n }),\n );\n },\n );\n\n this.braintreeManager.on(\n 'paymentProvidersHostedFieldsFailed',\n (error: unknown) => {\n this.dispatchEvent(\n new CustomEvent('paymentProvidersHostedFieldsFailed', {\n detail: { error },\n }),\n );\n },\n );\n }\n }\n\n private recaptchaManagerSetup = false;\n\n private async setupRecaptchaManager(): Promise<void> {\n if (\n !this.recaptchaSiteKey ||\n !this.paymentClients ||\n this.recaptchaManagerSetup\n ) {\n return;\n }\n this.recaptchaManagerSetup = true;\n const grecaptchaLibrary = await this.paymentClients.recaptchaLibrary.get();\n this.recaptchaManager = new RecaptchaManager({\n grecaptchaLibrary,\n siteKey: this.recaptchaSiteKey,\n });\n }\n\n firstUpdated(): void {\n this.configureFromQueryParams();\n this.trackViewedEvent();\n }\n\n /**\n * The donate page links carry the starting configuration in the query\n * string: `amt`, `contrib_type`, `coverFees`, `dollarAmounts`,\n * `amountLayout` and `frequencyMode`.\n */\n private configureFromQueryParams(): void {\n const urlParams = new URLSearchParams(window.location.search);\n\n let amountOptions = this.amountOptions;\n const amountOptionsParam = urlParams.get('dollarAmounts');\n if (amountOptionsParam) {\n // e.g. `[5,10,25]`\n const stripBrackets = amountOptionsParam.slice(1, -1);\n amountOptions = stripBrackets\n .split(',')\n .map((value) => parseFloat(value))\n .filter((value) => !isNaN(value));\n }\n\n let coverFees = this.donationInfo.coverFees;\n const coverFeesParam = urlParams.get('coverFees');\n if (coverFeesParam) {\n coverFees = coverFeesParam === 'true';\n }\n\n let frequency = this.donationInfo.donationType;\n const frequencyParam = urlParams.get('contrib_type');\n if (frequencyParam === 'monthly') {\n frequency = DonationType.Monthly;\n }\n\n let amount = this.donationInfo.amount;\n const amountParam = urlParams.get('amt');\n if (amountParam) {\n const parsedAmount = currency(amountParam).value;\n if (parsedAmount > 0) {\n amount = parsedAmount;\n }\n }\n\n const amountLayoutParam = urlParams.get('amountLayout');\n if (amountLayoutParam) {\n const amountLayout =\n amountLayoutParam as EditDonationAmountSelectionLayout;\n if (\n Object.values(EditDonationAmountSelectionLayout).includes(amountLayout)\n ) {\n this.amountSelectionLayout = amountLayout;\n }\n }\n\n const frequencyModeParam = urlParams.get('frequencyMode');\n if (frequencyModeParam) {\n const frequencyMode =\n frequencyModeParam as EditDonationFrequencySelectionMode;\n if (\n Object.values(EditDonationFrequencySelectionMode).includes(\n frequencyMode,\n )\n ) {\n this.frequencySelectionMode = frequencyMode;\n }\n }\n\n this.amountOptions = amountOptions;\n this.donationInfo = new DonationPaymentInfo({\n donationType: frequency,\n amount,\n coverFees,\n });\n }\n\n private setupPaymentFlowHandlers(): void {\n if (this.paymentFlowHandlers) {\n return;\n }\n\n if (\n !this.braintreeManager ||\n !this.recaptchaManager ||\n !this.modalManager ||\n !this.recaptchaElement\n ) {\n return;\n }\n\n this.paymentFlowHandlers = new PaymentFlowHandlers({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n recaptchaManager: this.recaptchaManager,\n analytics: {\n logEvent: this.logEvent.bind(this),\n logDonationFlowEvent: this.logDonationFlowEvent.bind(this),\n },\n });\n\n this.donationForm.braintreeManager = this.braintreeManager;\n this.donationForm.paymentFlowHandlers = this.paymentFlowHandlers;\n\n this.braintreeManager.startup();\n this.paymentFlowHandlers.startup();\n this.recaptchaManager.setup(this.recaptchaElement, 1, 'light', 'image');\n }\n\n private get hostedFieldConfig(): HostedFieldConfiguration {\n const hostedFieldStyle: Record<string, Record<string, string>> = {\n input: {\n 'font-size': '16px',\n 'font-family': '\"Helvetica Neue\", Helvetica, Arial, sans-serif',\n 'font-weight': '700',\n color: '#333',\n },\n ':focus': {\n color: '#333',\n },\n // The text color stays the same when valid or invalid. The badged\n // input's red border and the error message already show the error\n // state, and red text on top of them is confusing.\n '.valid': {\n color: '#333',\n },\n '.invalid': {\n color: '#333',\n },\n };\n\n // No placeholders. The visible labels above each field are the only text.\n const hostedFieldFieldOptions: braintree.HostedFieldFieldOptions = {\n number: {\n selector: '#braintree-creditcard',\n },\n cvv: {\n selector: '#braintree-cvv',\n },\n expirationDate: {\n selector: '#braintree-expiration',\n },\n };\n\n const hostedFieldContainer =\n this.creditCardFieldsElement.hostedFieldContainer;\n\n return new HostedFieldConfiguration({\n hostedFieldStyle,\n hostedFieldFieldOptions,\n hostedFieldContainer,\n });\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"ia-donation-form-controller-container\">\n <ia-donation-form\n .braintreeManager=${this.braintreeManager}\n .contactForm=${this.contactForm}\n .amountOptions=${this.amountOptions}\n .donationInfo=${this.donationInfo}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @paymentProviderSelected=${this.paymentProviderSelected}\n @paymentFlowStarted=${this.paymentFlowStarted}\n @paymentFlowConfirmed=${this.paymentFlowConfirmed}\n @paymentFlowCancelled=${this.paymentFlowCancelled}\n @paymentFlowError=${this.paymentFlowError}\n >\n <!--\n Braintree's hosted fields, the PayPal button and recaptcha can't\n live in a shadow root, so they render here in the light DOM and\n are slotted into the form. See\n https://github.com/braintree/braintree-web-drop-in/issues/614\n and https://github.com/paypal/paypal-checkout-components/issues/353\n -->\n <div slot=\"braintree-hosted-fields\">\n <ia-donation-credit-card-fields></ia-donation-credit-card-fields>\n </div>\n\n <!-- Autofill doesn't reach into shadow DOM, so the contact form is light DOM too -->\n <div slot=\"contact-form\">\n <ia-donation-contact-form\n .donorEmail=${this.donorEmail}\n ></ia-donation-contact-form>\n </div>\n\n <div slot=\"paypal-button\">\n <div id=\"paypal-button\"></div>\n </div>\n\n <slot name=\"recaptcha\" slot=\"recaptcha\"></slot>\n </ia-donation-form>\n </div>\n\n ${this.getStyles}\n `;\n }\n\n /** Light DOM, for the payment libraries that can't render into a shadow root */\n createRenderRoot(): this {\n return this;\n }\n\n private donationInfoChanged(e: CustomEvent): void {\n this.logEvent('DonationInfoChanged');\n this.donationInfo = e.detail.donationInfo;\n }\n\n private trackViewedEvent(): void {\n this.logEvent('Viewed');\n }\n\n private paymentProviderSelected(e: CustomEvent): void {\n const paymentProvider = e.detail.paymentProvider as\n | PaymentProvider\n | undefined;\n const previousPaymentProvider = e.detail.previousPaymentProvider as\n | PaymentProvider\n | undefined;\n const providerNoSpaces = this.removeSpaces(paymentProvider ?? 'unset');\n let eventName = `ProviderFirstSelected-${providerNoSpaces}`;\n let previousProviderInfo: string | undefined;\n if (previousPaymentProvider !== undefined) {\n eventName = `ProviderChangedTo-${providerNoSpaces}`;\n previousProviderInfo = `ProviderChangedFrom-${this.removeSpaces(\n previousPaymentProvider,\n )}`;\n }\n\n this.logEvent(eventName, previousProviderInfo);\n }\n\n private paymentFlowConfirmed(e: CustomEvent): void {\n this.logEvent(\n 'PaymentFlowConfirmed',\n this.removeSpaces(e.detail.paymentProvider),\n );\n }\n\n private paymentFlowStarted(e: CustomEvent): void {\n this.logEvent(\n 'PaymentFlowStarted',\n this.removeSpaces(e.detail.paymentProvider),\n );\n }\n\n private paymentFlowCancelled(e: CustomEvent): void {\n this.logEvent(\n 'PaymentFlowCancelled',\n this.removeSpaces(e.detail.paymentProvider),\n );\n }\n\n private paymentFlowError(e: CustomEvent): void {\n const providerNoSpaces = this.removeSpaces(e.detail.paymentProvider);\n this.logEvent('PaymentFlowError', `${providerNoSpaces}-${e.detail.error}`);\n }\n\n private removeSpaces(original: string): string {\n return original.replace(/\\s+/g, '');\n }\n\n /** A sampled event in this form's category */\n private logEvent(action: string, label?: string): void {\n const analyticEvent: AnalyticsEvent = {\n action,\n label,\n category: this.analyticsCategory,\n };\n this.analyticsHandler?.sendEvent(analyticEvent);\n }\n\n /** An unsampled event in the `DonationFlow` category */\n private logDonationFlowEvent(action: string, label?: string): void {\n const analyticEvent: AnalyticsEvent = {\n action,\n label,\n category: 'DonationFlow',\n };\n this.analyticsHandler?.sendEventNoSampling(analyticEvent);\n }\n\n /**\n * The element renders into the light DOM, so instead of a `styles` block\n * it writes its own `<style>` tag, scoped to its container class.\n *\n * The `--ia-donation-form-*` variables set here are the consumer-facing\n * theming for the whole form; they fan out to the sections, the amount\n * picker and the payment buttons.\n */\n private get getStyles(): TemplateResult {\n return html`\n <style>\n .ia-donation-form-controller-container {\n --donation-form-controller-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n color: var(--ia-donation-form-text-color, #333);\n background-color: var(\n --ia-donation-form-background-color,\n transparent\n );\n\n --ia-donation-section-background-color: var(\n --ia-donation-form-background-color,\n transparent\n );\n --ia-donation-edit-background-color: var(\n --ia-donation-form-background-color,\n transparent\n );\n\n --ia-donation-section-badge-background-color: var(\n --ia-donation-form-badge-background-color,\n #333\n );\n --ia-donation-edit-badge-background-color: var(\n --ia-donation-form-badge-background-color,\n #333\n );\n\n --ia-donation-section-badge-font-color: var(\n --ia-donation-form-badge-text-color,\n #fff\n );\n --ia-donation-edit-badge-font-color: var(\n --ia-donation-form-badge-text-color,\n #fff\n );\n\n --ia-donation-edit-button-font-color: var(\n --ia-donation-form-payment-option-text-color\n );\n --ia-donation-edit-button-color: var(\n --ia-donation-form-payment-option-background-color\n );\n --ia-donation-edit-button-selected-color: var(\n --ia-donation-form-selected-option-background-color\n );\n --ia-donation-edit-button-selected-font-color: var(\n --ia-donation-form-selected-option-text-color\n );\n }\n\n .ia-donation-form-controller-container ia-donation-form:focus {\n outline: none;\n }\n\n /* The real PayPal button, kept but nearly invisible under the local one */\n .ia-donation-form-controller-container #paypal-button {\n opacity: 0.001;\n width: calc(var(--donation-form-controller-base-font-size--) * 5);\n height: calc(var(--donation-form-controller-base-font-size--) * 3);\n overflow: hidden;\n }\n\n .ia-donation-form-controller-container\n div[slot='braintree-hosted-fields'] {\n background-color: white;\n }\n </style>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"ia-donation-form-controller.js","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/ia-donation-form-controller.ts"],"names":[],"mappings":";AACA,OAAO,EACL,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAA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Q,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAAmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAuB;AAEtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAiB;AAEhB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAyB;AAGpD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEACyB;AAExB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAsC;AAGrC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEAAgC;AAE/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEAA8C;AAGzE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEACwB;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAA0C;AAMrE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAC6C;AAErC;IAAlC,KAAK,CAAC,kBAAkB,CAAC;8DAAuC;AAGzD;IADP,KAAK,CAAC,gCAAgC,CAAC;yEACqB;AAGrD;IADP,KAAK,CAAC,0BAA0B,CAAC;6DACU;AAjEjC,wBAAwB;IADpC,aAAa,CAAC,6BAA6B,CAAC;GAChC,wBAAwB,CAkkBpC","sourcesContent":["import type * as braintree from 'braintree-web';\nimport {\n html,\n LitElement,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { parseAmount } from './parse-amount';\nimport {\n LazyLoaderService,\n type LazyLoaderServiceInterface,\n} from '@internetarchive/lazy-loader-service';\nimport type { ModalManagerInterface } from '@src/elements/modal-manager/models';\nimport type {\n AnalyticsEvent,\n AnalyticsManagerInterface,\n} from '@internetarchive/analytics-manager';\n\nimport { BraintreeManager } from './braintree/braintree-manager';\nimport type {\n BraintreeEndpointManagerInterface,\n BraintreeManagerInterface,\n} from './braintree/braintree-manager-interface';\nimport type { HostingEnvironment } from './braintree/hosting-environment';\nimport {\n PaymentClients,\n type PaymentClientsInterface,\n} from './braintree/payment-clients';\nimport { HostedFieldConfiguration } from './braintree/payment-providers/credit-card/hosted-field-configuration';\nimport {\n PaymentFlowHandlers,\n type PaymentFlowHandlersInterface,\n} from './flow-handlers/payment-flow-handlers';\nimport type { IADonationContactForm } from './form-elements/contact-form/ia-donation-contact-form';\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from './form-elements/ia-donation-edit-donation';\nimport type { IADonationCreditCardFields } from './form-elements/ia-donation-credit-card-fields';\nimport type { IADonationForm } from './ia-donation-form';\nimport {\n DonationPaymentInfo,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from './models/donation-payment-info';\nimport { DonationType } from './models/donation-type';\nimport type { PaymentProvider } from './models/payment-provider';\nimport type { UpsellModalCTAMode } from './modals/ia-donation-upsell-modal-content';\nimport {\n RecaptchaManager,\n type RecaptchaManagerInterface,\n} from './recaptcha-manager';\nimport './form-elements/contact-form/ia-donation-contact-form';\nimport './form-elements/ia-donation-credit-card-fields';\nimport './ia-donation-form';\n\n/**\n * Wires the donation form to everything around it: Braintree and the payment\n * libraries, the modal manager, recaptcha, and analytics. Give it the\n * environment, tokens and an endpoint manager and it builds the rest.\n *\n * It renders into the light DOM, because Braintree's hosted fields, the\n * PayPal button and recaptcha all refuse to work inside a shadow root. Those\n * are rendered here and slotted into `<ia-donation-form>`.\n */\n@customElement('ia-donation-form-controller')\nexport class IADonationFormController extends LitElement {\n @property({ type: String }) environment?: HostingEnvironment;\n\n @property({ type: String }) braintreeAuthToken?: string;\n\n @property({ type: String }) recaptchaSiteKey?: string;\n\n @property({ type: String }) venmoProfileId?: string;\n\n @property({ type: String }) googlePayMerchantId?: string;\n\n @property({ type: String }) analyticsCategory = 'DonationForm';\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: Object }) donationInfo: DonationPaymentInfo =\n defaultSelectedDonationInfo;\n\n @property({ type: String })\n amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String })\n frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String }) referrer?: string;\n\n @property({ type: String }) loggedInUser?: string;\n\n @property({ type: String }) origin?: string;\n\n @property({ type: String }) donorEmail: string = '';\n\n @property({ type: Object })\n endpointManager?: BraintreeEndpointManagerInterface;\n\n @property({ type: Object }) analyticsHandler?: AnalyticsManagerInterface;\n\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n /** The element recaptcha renders its (invisible) widget into. Must be in the light DOM. */\n @property({ type: Object }) recaptchaElement?: HTMLElement;\n\n @property({ type: Object }) braintreeManager?: BraintreeManagerInterface;\n\n @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;\n\n @property({ type: Object })\n paymentFlowHandlers?: PaymentFlowHandlersInterface;\n\n @property({ type: Object }) paymentClients?: PaymentClientsInterface;\n\n /** The clients this element built itself, so it knows when it may rebuild them */\n private defaultPaymentClients?: PaymentClientsInterface;\n\n @property({ type: Object })\n lazyLoaderService: LazyLoaderServiceInterface = new LazyLoaderService();\n\n @query('ia-donation-form') private donationForm!: IADonationForm;\n\n @query('ia-donation-credit-card-fields')\n private creditCardFieldsElement!: IADonationCreditCardFields;\n\n @query('ia-donation-contact-form')\n private contactForm?: IADonationContactForm;\n\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('referrer') && this.referrer) {\n this.braintreeManager?.setReferrer(this.referrer);\n this.logDonationFlowEvent('referrer', this.referrer);\n }\n\n if (changedProperties.has('loggedInUser') && this.loggedInUser) {\n this.braintreeManager?.setLoggedInUser(this.loggedInUser);\n }\n\n if (changedProperties.has('origin') && this.origin) {\n this.braintreeManager?.setOrigin(this.origin);\n this.logDonationFlowEvent('origin', this.origin);\n }\n\n if (\n changedProperties.has('paymentClients') ||\n changedProperties.has('braintreeAuthToken') ||\n changedProperties.has('endpointManager') ||\n changedProperties.has('environment')\n ) {\n this.setupBraintreeManager();\n this.setupRecaptchaManager();\n }\n\n if (changedProperties.has('recaptchaSiteKey')) {\n this.setupRecaptchaManager();\n }\n\n if (\n changedProperties.has('braintreeManager') ||\n changedProperties.has('recaptchaManager') ||\n changedProperties.has('modalManager') ||\n changedProperties.has('recaptchaElement')\n ) {\n this.setupPaymentFlowHandlers();\n }\n\n // Build the default clients for the environment, unless the consumer\n // supplied their own\n if (\n (changedProperties.has('environment') ||\n changedProperties.has('lazyLoaderService')) &&\n this.environment &&\n (this.paymentClients === undefined ||\n this.paymentClients === this.defaultPaymentClients)\n ) {\n this.defaultPaymentClients = new PaymentClients(\n this.lazyLoaderService,\n this.environment,\n );\n this.paymentClients = this.defaultPaymentClients;\n }\n }\n\n /** Developer convenience: show the confirmation step without a payment. */\n async showConfirmationStepDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: () => void;\n confirmDonationCB: () => void;\n }): Promise<void> {\n this.donationForm.showConfirmationModalDev(options);\n }\n\n /** Developer convenience: show the upsell modal without a payment. */\n async showUpsellModalDev(options: {\n oneTimeAmount: number;\n ctaMode?: UpsellModalCTAMode;\n yesSelected?: (amount: number) => void;\n noSelected?: () => void;\n amountChanged?: (amount: number) => void;\n userClosedModalCallback?: () => void;\n }): Promise<void> {\n this.donationForm.showUpsellModalDev(options);\n }\n\n private setupBraintreeManager(): void {\n if (\n this.braintreeManager === undefined &&\n this.braintreeAuthToken &&\n this.endpointManager &&\n this.paymentClients &&\n this.environment\n ) {\n this.braintreeManager = new BraintreeManager({\n paymentClients: this.paymentClients,\n endpointManager: this.endpointManager,\n authorizationToken: this.braintreeAuthToken,\n venmoProfileId: this.venmoProfileId,\n googlePayMerchantId: this.googlePayMerchantId,\n hostedFieldConfig: this.hostedFieldConfig,\n hostingEnvironment: this.environment,\n referrer: this.referrer,\n loggedInUser: this.loggedInUser,\n origin: this.origin,\n });\n\n this.braintreeManager.on(\n 'paymentProvidersHostedFieldsRetry',\n (retryNumber: number) => {\n this.dispatchEvent(\n new CustomEvent('paymentProvidersHostedFieldsRetry', {\n detail: { retryNumber },\n }),\n );\n },\n );\n\n this.braintreeManager.on(\n 'paymentProvidersHostedFieldsFailed',\n (error: unknown) => {\n this.dispatchEvent(\n new CustomEvent('paymentProvidersHostedFieldsFailed', {\n detail: { error },\n }),\n );\n },\n );\n }\n }\n\n private recaptchaManagerSetup = false;\n\n private async setupRecaptchaManager(): Promise<void> {\n if (\n !this.recaptchaSiteKey ||\n !this.paymentClients ||\n this.recaptchaManagerSetup\n ) {\n return;\n }\n this.recaptchaManagerSetup = true;\n const grecaptchaLibrary = await this.paymentClients.recaptchaLibrary.get();\n this.recaptchaManager = new RecaptchaManager({\n grecaptchaLibrary,\n siteKey: this.recaptchaSiteKey,\n });\n }\n\n firstUpdated(): void {\n this.configureFromQueryParams();\n this.trackViewedEvent();\n }\n\n /**\n * The donate page links carry the starting configuration in the query\n * string: `amt`, `contrib_type`, `coverFees`, `dollarAmounts`,\n * `amountLayout` and `frequencyMode`.\n */\n private configureFromQueryParams(): void {\n const urlParams = new URLSearchParams(window.location.search);\n\n let amountOptions = this.amountOptions;\n const amountOptionsParam = urlParams.get('dollarAmounts');\n if (amountOptionsParam) {\n // e.g. `[5,10,25]`\n const stripBrackets = amountOptionsParam.slice(1, -1);\n amountOptions = stripBrackets\n .split(',')\n .map((value) => parseFloat(value))\n .filter((value) => !isNaN(value));\n }\n\n let coverFees = this.donationInfo.coverFees;\n const coverFeesParam = urlParams.get('coverFees');\n if (coverFeesParam) {\n coverFees = coverFeesParam === 'true';\n }\n\n let frequency = this.donationInfo.donationType;\n const frequencyParam = urlParams.get('contrib_type');\n if (frequencyParam === 'monthly') {\n frequency = DonationType.Monthly;\n }\n\n let amount = this.donationInfo.amount;\n const amountParam = urlParams.get('amt');\n if (amountParam) {\n // Links like ?amt=$10 or ?amt=10 USD have always worked\n const parsedAmount = parseAmount(\n amountParam.replace(/usd|\\$/gi, '').trim(),\n );\n if (parsedAmount > 0) {\n amount = parsedAmount;\n }\n }\n\n const amountLayoutParam = urlParams.get('amountLayout');\n if (amountLayoutParam) {\n const amountLayout =\n amountLayoutParam as EditDonationAmountSelectionLayout;\n if (\n Object.values(EditDonationAmountSelectionLayout).includes(amountLayout)\n ) {\n this.amountSelectionLayout = amountLayout;\n }\n }\n\n const frequencyModeParam = urlParams.get('frequencyMode');\n if (frequencyModeParam) {\n const frequencyMode =\n frequencyModeParam as EditDonationFrequencySelectionMode;\n if (\n Object.values(EditDonationFrequencySelectionMode).includes(\n frequencyMode,\n )\n ) {\n this.frequencySelectionMode = frequencyMode;\n }\n }\n\n this.amountOptions = amountOptions;\n this.donationInfo = new DonationPaymentInfo({\n donationType: frequency,\n amount,\n coverFees,\n });\n }\n\n private setupPaymentFlowHandlers(): void {\n if (this.paymentFlowHandlers) {\n return;\n }\n\n if (\n !this.braintreeManager ||\n !this.recaptchaManager ||\n !this.modalManager ||\n !this.recaptchaElement\n ) {\n return;\n }\n\n this.paymentFlowHandlers = new PaymentFlowHandlers({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n recaptchaManager: this.recaptchaManager,\n analytics: {\n logEvent: this.logEvent.bind(this),\n logDonationFlowEvent: this.logDonationFlowEvent.bind(this),\n },\n });\n\n this.donationForm.braintreeManager = this.braintreeManager;\n this.donationForm.paymentFlowHandlers = this.paymentFlowHandlers;\n\n this.braintreeManager.startup();\n this.paymentFlowHandlers.startup();\n this.recaptchaManager.setup(this.recaptchaElement, 1, 'light', 'image');\n }\n\n private get hostedFieldConfig(): HostedFieldConfiguration {\n const hostedFieldStyle: Record<string, Record<string, string>> = {\n input: {\n 'font-size': '16px',\n 'font-family': '\"Helvetica Neue\", Helvetica, Arial, sans-serif',\n 'font-weight': '700',\n color: '#333',\n },\n ':focus': {\n color: '#333',\n },\n // The text color stays the same when valid or invalid. The badged\n // input's red border and the error message already show the error\n // state, and red text on top of them is confusing.\n '.valid': {\n color: '#333',\n },\n '.invalid': {\n color: '#333',\n },\n };\n\n // No placeholders. The visible labels above each field are the only text.\n const hostedFieldFieldOptions: braintree.HostedFieldFieldOptions = {\n number: {\n selector: '#braintree-creditcard',\n },\n cvv: {\n selector: '#braintree-cvv',\n },\n expirationDate: {\n selector: '#braintree-expiration',\n },\n };\n\n const hostedFieldContainer =\n this.creditCardFieldsElement.hostedFieldContainer;\n\n return new HostedFieldConfiguration({\n hostedFieldStyle,\n hostedFieldFieldOptions,\n hostedFieldContainer,\n });\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"ia-donation-form-controller-container\">\n <ia-donation-form\n .braintreeManager=${this.braintreeManager}\n .contactForm=${this.contactForm}\n .amountOptions=${this.amountOptions}\n .donationInfo=${this.donationInfo}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @paymentProviderSelected=${this.paymentProviderSelected}\n @paymentFlowStarted=${this.paymentFlowStarted}\n @paymentFlowConfirmed=${this.paymentFlowConfirmed}\n @paymentFlowCancelled=${this.paymentFlowCancelled}\n @paymentFlowError=${this.paymentFlowError}\n >\n <!--\n Braintree's hosted fields, the PayPal button and recaptcha can't\n live in a shadow root, so they render here in the light DOM and\n are slotted into the form. See\n https://github.com/braintree/braintree-web-drop-in/issues/614\n and https://github.com/paypal/paypal-checkout-components/issues/353\n -->\n <div slot=\"braintree-hosted-fields\">\n <ia-donation-credit-card-fields></ia-donation-credit-card-fields>\n </div>\n\n <!-- Autofill doesn't reach into shadow DOM, so the contact form is light DOM too -->\n <div slot=\"contact-form\">\n <ia-donation-contact-form\n .donorEmail=${this.donorEmail}\n ></ia-donation-contact-form>\n </div>\n\n <div slot=\"paypal-button\">\n <div id=\"paypal-button\"></div>\n </div>\n\n <slot name=\"recaptcha\" slot=\"recaptcha\"></slot>\n </ia-donation-form>\n </div>\n\n ${this.getStyles}\n `;\n }\n\n /** Light DOM, for the payment libraries that can't render into a shadow root */\n createRenderRoot(): this {\n return this;\n }\n\n private donationInfoChanged(e: CustomEvent): void {\n this.logEvent('DonationInfoChanged');\n this.donationInfo = e.detail.donationInfo;\n }\n\n private trackViewedEvent(): void {\n this.logEvent('Viewed');\n }\n\n private paymentProviderSelected(e: CustomEvent): void {\n const paymentProvider = e.detail.paymentProvider as\n | PaymentProvider\n | undefined;\n const previousPaymentProvider = e.detail.previousPaymentProvider as\n | PaymentProvider\n | undefined;\n const providerNoSpaces = this.removeSpaces(paymentProvider ?? 'unset');\n let eventName = `ProviderFirstSelected-${providerNoSpaces}`;\n let previousProviderInfo: string | undefined;\n if (previousPaymentProvider !== undefined) {\n eventName = `ProviderChangedTo-${providerNoSpaces}`;\n previousProviderInfo = `ProviderChangedFrom-${this.removeSpaces(\n previousPaymentProvider,\n )}`;\n }\n\n this.logEvent(eventName, previousProviderInfo);\n }\n\n private paymentFlowConfirmed(e: CustomEvent): void {\n this.logEvent(\n 'PaymentFlowConfirmed',\n this.removeSpaces(e.detail.paymentProvider),\n );\n }\n\n private paymentFlowStarted(e: CustomEvent): void {\n this.logEvent(\n 'PaymentFlowStarted',\n this.removeSpaces(e.detail.paymentProvider),\n );\n }\n\n private paymentFlowCancelled(e: CustomEvent): void {\n this.logEvent(\n 'PaymentFlowCancelled',\n this.removeSpaces(e.detail.paymentProvider),\n );\n }\n\n private paymentFlowError(e: CustomEvent): void {\n const providerNoSpaces = this.removeSpaces(e.detail.paymentProvider);\n this.logEvent('PaymentFlowError', `${providerNoSpaces}-${e.detail.error}`);\n }\n\n private removeSpaces(original: string): string {\n return original.replace(/\\s+/g, '');\n }\n\n /** A sampled event in this form's category */\n private logEvent(action: string, label?: string): void {\n const analyticEvent: AnalyticsEvent = {\n action,\n label,\n category: this.analyticsCategory,\n };\n this.analyticsHandler?.sendEvent(analyticEvent);\n }\n\n /** An unsampled event in the `DonationFlow` category */\n private logDonationFlowEvent(action: string, label?: string): void {\n const analyticEvent: AnalyticsEvent = {\n action,\n label,\n category: 'DonationFlow',\n };\n this.analyticsHandler?.sendEventNoSampling(analyticEvent);\n }\n\n /**\n * The element renders into the light DOM, so instead of a `styles` block\n * it writes its own `<style>` tag, scoped to its container class.\n *\n * The `--ia-donation-form-*` variables set here are the consumer-facing\n * theming for the whole form; they fan out to the sections, the amount\n * picker and the payment buttons.\n */\n private get getStyles(): TemplateResult {\n return html`\n <style>\n .ia-donation-form-controller-container {\n --donation-form-controller-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n color: var(--ia-donation-form-text-color, #333);\n background-color: var(\n --ia-donation-form-background-color,\n transparent\n );\n\n --ia-donation-section-background-color: var(\n --ia-donation-form-background-color,\n transparent\n );\n --ia-donation-edit-background-color: var(\n --ia-donation-form-background-color,\n transparent\n );\n\n --ia-donation-section-badge-background-color: var(\n --ia-donation-form-badge-background-color,\n #333\n );\n --ia-donation-edit-badge-background-color: var(\n --ia-donation-form-badge-background-color,\n #333\n );\n\n --ia-donation-section-badge-font-color: var(\n --ia-donation-form-badge-text-color,\n #fff\n );\n --ia-donation-edit-badge-font-color: var(\n --ia-donation-form-badge-text-color,\n #fff\n );\n\n --ia-donation-edit-button-font-color: var(\n --ia-donation-form-payment-option-text-color\n );\n --ia-donation-edit-button-color: var(\n --ia-donation-form-payment-option-background-color\n );\n --ia-donation-edit-button-selected-color: var(\n --ia-donation-form-selected-option-background-color\n );\n --ia-donation-edit-button-selected-font-color: var(\n --ia-donation-form-selected-option-text-color\n );\n }\n\n .ia-donation-form-controller-container ia-donation-form:focus {\n outline: none;\n }\n\n /* The real PayPal button, kept but nearly invisible under the local one */\n .ia-donation-form-controller-container #paypal-button {\n opacity: 0.001;\n width: calc(var(--donation-form-controller-base-font-size--) * 5);\n height: calc(var(--donation-form-controller-base-font-size--) * 3);\n overflow: hidden;\n }\n\n .ia-donation-form-controller-container\n div[slot='braintree-hosted-fields'] {\n background-color: white;\n }\n </style>\n `;\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The language the app last finished loading, falling back to the page's
3
+ * `lang`. `@lit/localize` only hands `getLocale` to whoever configures it, and
4
+ * this package never does, so the locale is read from its status event.
5
+ */
6
+ export declare function currentLocale(): string;
7
+ /**
8
+ * Formats a US dollar amount for the current language. English keeps the
9
+ * `$10.00` form. Other languages get `Intl.NumberFormat`'s USD form, like
10
+ * `10,00 US$` in Spanish.
11
+ */
12
+ export declare function formatUsd(amount: number, precision?: number): string;
13
+ /**
14
+ * The country choices as `[code, name]` pairs. English keeps the list in its
15
+ * own order and spelling. Other languages get each name from
16
+ * `Intl.DisplayNames`, sorted in that language, and a country the browser
17
+ * can't name keeps its English name.
18
+ */
19
+ export declare function localizedCountries(): [string, string][];
20
+ //# sourceMappingURL=localized-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localized-format.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/localized-format.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAMD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,MAAM,CAe/D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAgBvD"}
@@ -0,0 +1,73 @@
1
+ import currency from 'currency.js';
2
+ import { countries } from './form-elements/contact-form/countries.js';
3
+ let readyLocale;
4
+ if (typeof window !== 'undefined') {
5
+ window.addEventListener('lit-localize-status', (event) => {
6
+ const detail = event.detail;
7
+ if (detail.status === 'ready')
8
+ readyLocale = detail.readyLocale;
9
+ });
10
+ }
11
+ /**
12
+ * The language the app last finished loading, falling back to the page's
13
+ * `lang`. `@lit/localize` only hands `getLocale` to whoever configures it, and
14
+ * this package never does, so the locale is read from its status event.
15
+ */
16
+ export function currentLocale() {
17
+ if (readyLocale)
18
+ return readyLocale;
19
+ if (typeof document === 'undefined')
20
+ return 'en';
21
+ return document.documentElement.lang || 'en';
22
+ }
23
+ function isEnglish(locale) {
24
+ return locale === 'en' || locale.startsWith('en-');
25
+ }
26
+ /**
27
+ * Formats a US dollar amount for the current language. English keeps the
28
+ * `$10.00` form. Other languages get `Intl.NumberFormat`'s USD form, like
29
+ * `10,00 US$` in Spanish.
30
+ */
31
+ export function formatUsd(amount, precision = 2) {
32
+ const locale = currentLocale();
33
+ if (isEnglish(locale)) {
34
+ return currency(amount, { symbol: '$', precision }).format();
35
+ }
36
+ try {
37
+ return new Intl.NumberFormat(locale, {
38
+ style: 'currency',
39
+ currency: 'USD',
40
+ minimumFractionDigits: precision,
41
+ maximumFractionDigits: precision,
42
+ }).format(amount);
43
+ }
44
+ catch {
45
+ return currency(amount, { symbol: '$', precision }).format();
46
+ }
47
+ }
48
+ /**
49
+ * The country choices as `[code, name]` pairs. English keeps the list in its
50
+ * own order and spelling. Other languages get each name from
51
+ * `Intl.DisplayNames`, sorted in that language, and a country the browser
52
+ * can't name keeps its English name.
53
+ */
54
+ export function localizedCountries() {
55
+ const locale = currentLocale();
56
+ const entries = Object.entries(countries);
57
+ if (isEnglish(locale))
58
+ return entries;
59
+ try {
60
+ const displayNames = new Intl.DisplayNames([locale], { type: 'region' });
61
+ const collator = new Intl.Collator(locale);
62
+ return entries
63
+ .map(([code, englishName]) => {
64
+ const name = displayNames.of(code);
65
+ return [code, name && name !== code ? name : englishName.trim()];
66
+ })
67
+ .sort((a, b) => collator.compare(a[1], b[1]));
68
+ }
69
+ catch {
70
+ return entries;
71
+ }
72
+ }
73
+ //# sourceMappingURL=localized-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localized-format.js","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/localized-format.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAInE,IAAI,WAA+B,CAAC;AAEpC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,EAAE;QACvD,MAAM,MAAM,GAAI,KAAyC,CAAC,MAAM,CAAC;QACjE,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO;YAAE,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,WAAW;QAAE,OAAO,WAAW,CAAC;IACpC,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IACjD,OAAO,QAAQ,CAAC,eAAe,CAAC,IAAI,IAAI,IAAI,CAAC;AAC/C,CAAC;AAED,SAAS,SAAS,CAAC,MAAc;IAC/B,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,SAAS,GAAG,CAAC;IACrD,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/D,CAAC;IACD,IAAI,CAAC;QACH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,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["import currency from 'currency.js';\n\nimport { countries } from './form-elements/contact-form/countries';\n\ntype LocaleStatusDetail = { status: string; readyLocale?: string };\n\nlet readyLocale: string | undefined;\n\nif (typeof window !== 'undefined') {\n window.addEventListener('lit-localize-status', (event) => {\n const detail = (event as CustomEvent<LocaleStatusDetail>).detail;\n if (detail.status === 'ready') readyLocale = detail.readyLocale;\n });\n}\n\n/**\n * The language the app last finished loading, falling back to the page's\n * `lang`. `@lit/localize` only hands `getLocale` to whoever configures it, and\n * this package never does, so the locale is read from its status event.\n */\nexport function currentLocale(): string {\n if (readyLocale) return readyLocale;\n if (typeof document === 'undefined') return 'en';\n return document.documentElement.lang || 'en';\n}\n\nfunction isEnglish(locale: string): boolean {\n return locale === 'en' || locale.startsWith('en-');\n}\n\n/**\n * Formats a US dollar amount for the current language. English keeps the\n * `$10.00` form. Other languages get `Intl.NumberFormat`'s USD form, like\n * `10,00 US$` in Spanish.\n */\nexport function formatUsd(amount: number, precision = 2): string {\n const locale = currentLocale();\n if (isEnglish(locale)) {\n return currency(amount, { symbol: '$', precision }).format();\n }\n try {\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: 'USD',\n minimumFractionDigits: precision,\n maximumFractionDigits: precision,\n }).format(amount);\n } catch {\n return currency(amount, { symbol: '$', precision }).format();\n }\n}\n\n/**\n * The country choices as `[code, name]` pairs. English keeps the list in its\n * own order and spelling. Other languages get each name from\n * `Intl.DisplayNames`, sorted in that language, and a country the browser\n * can't name keeps its English name.\n */\nexport function localizedCountries(): [string, string][] {\n const locale = currentLocale();\n const entries = Object.entries(countries);\n if (isEnglish(locale)) return entries;\n try {\n const displayNames = new Intl.DisplayNames([locale], { type: 'region' });\n const collator = new Intl.Collator(locale);\n return entries\n .map(([code, englishName]): [string, string] => {\n const name = displayNames.of(code);\n return [code, name && name !== code ? name : englishName.trim()];\n })\n .sort((a, b) => collator.compare(a[1], b[1]));\n } catch {\n return entries;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ia-donation-confirm-modal.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-confirm-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAOb,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;;GAGG;AACH,qBACa,sBAAuB,SAAQ,UAAU;IACxB,MAAM,SAAK;IAEvC,iFAAiF;IACrD,YAAY,SAAS;IAErB,YAAY,EAAE,YAAY,CAAwB;IAE9C,eAAe,EAAE,MAAM,IAAI,CAAY;IAEvC,cAAc,EAAE,MAAM,IAAI,CAAY;IAEtE,OAAO,KAAK,eAAe,GAE1B;IAED,IAAI,gBAAgB,IAAI,cAAc,CAQrC;IAED,IAAI,iBAAiB,IAAI,cAAc,CAQtC;IAED,IAAI,UAAU,IAAI,MAAM,CAIvB;IAED,MAAM,IAAI,cAAc;IAiBxB,MAAM,KAAK,MAAM,IAAI,cAAc,CAsDlC;IAED;;;;OAIG;IACH,IAAI,cAAc,IAAI,MAAM,CAiD3B;CACF"}
1
+ {"version":3,"file":"ia-donation-confirm-modal.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-confirm-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAQb,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;;GAGG;AACH,qBAEa,sBAAuB,SAAQ,UAAU;IACxB,MAAM,SAAK;IAEvC,iFAAiF;IACrD,YAAY,SAAS;IAErB,YAAY,EAAE,YAAY,CAAwB;IAE9C,eAAe,EAAE,MAAM,IAAI,CAAY;IAEvC,cAAc,EAAE,MAAM,IAAI,CAAY;IAEtE,OAAO,KAAK,eAAe,GAG1B;IAED,IAAI,gBAAgB,IAAI,cAAc,CAQrC;IAED,IAAI,iBAAiB,IAAI,cAAc,CAQtC;IAED,IAAI,UAAU,IAAI,MAAM,CAIvB;IAED,MAAM,IAAI,cAAc;IAiBxB,MAAM,KAAK,MAAM,IAAI,cAAc,CAsDlC;IAED;;;;OAIG;IACH,IAAI,cAAc,IAAI,MAAM,CAiD3B;CACF"}
@@ -2,7 +2,8 @@ import { __decorate } from "tslib";
2
2
  import { css, html, LitElement, } from 'lit';
3
3
  import { property } from 'lit/decorators.js';
4
4
  import { customElement } from '../../../utils/custom-element.js';
5
- import { msg } from '@lit/localize';
5
+ import { localized, msg } from '@lit/localize';
6
+ import { formatUsd } from '../localized-format.js';
6
7
  import currency from 'currency.js';
7
8
  import themeStyles from '../../../themes/theme-styles.js';
8
9
  import { DonationType } from '../models/donation-type.js';
@@ -21,6 +22,8 @@ let IADonationConfirmModal = class IADonationConfirmModal extends LitElement {
21
22
  this.cancelDonation = () => { };
22
23
  }
23
24
  get formattedAmount() {
25
+ if (this.currencyType === 'USD')
26
+ return formatUsd(this.amount);
24
27
  return currency(this.amount, { symbol: this.currencySymbol }).format();
25
28
  }
26
29
  get confirmationText() {
@@ -189,7 +192,8 @@ __decorate([
189
192
  property({ attribute: false })
190
193
  ], IADonationConfirmModal.prototype, "cancelDonation", void 0);
191
194
  IADonationConfirmModal = __decorate([
192
- customElement('ia-donation-confirm-modal')
195
+ customElement('ia-donation-confirm-modal'),
196
+ localized()
193
197
  ], IADonationConfirmModal);
194
198
  export { IADonationConfirmModal };
195
199
  //# sourceMappingURL=ia-donation-confirm-modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ia-donation-confirm-modal.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-confirm-modal.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,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BACR,OAAO,IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,GAAG,CAAC;YACb,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,GAAG,CAAC;YACb,KAAK,KAAK;gBACR,OAAO,KAAK,CAAC;YACf;gBACE,OAAO,GAAG,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAA;AAzK6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAY;AAGX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAsB;AAErB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAmD;AAE9C;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+DAAwC;AAEvC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8DAAuC;AAV3D,sBAAsB;IADlC,aAAa,CAAC,2BAA2B,CAAC;GAC9B,sBAAsB,CA0KlC","sourcesContent":["import {\n css,\n html,\n LitElement,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { msg } from '@lit/localize';\nimport currency from 'currency.js';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport { DonationType } from '../models/donation-type';\n\n/**\n * The confirmation step shown before a PayPal donation goes through: what the\n * donor is about to give, with Complete and Cancel buttons.\n */\n@customElement('ia-donation-confirm-modal')\nexport class IADonationConfirmModal extends LitElement {\n @property({ type: Number }) amount = 5;\n\n /** An ISO currency code, e.g. `USD`. Drives the symbol shown with the amount. */\n @property({ type: String }) currencyType = 'USD';\n\n @property({ type: String }) donationType: DonationType = DonationType.OneTime;\n\n @property({ attribute: false }) confirmDonation: () => void = () => {};\n\n @property({ attribute: false }) cancelDonation: () => void = () => {};\n\n private get formattedAmount(): string {\n return currency(this.amount, { symbol: this.currencySymbol }).format();\n }\n\n get confirmationText(): TemplateResult {\n return msg(html`\n <p>\n You are about to make a <b>${this.donationType}</b> donation of\n <b>${this.formattedAmount} ${this.currencyType}</b> to the Internet\n Archive.\n </p>\n `);\n }\n\n get confirmUpsellText(): TemplateResult {\n return msg(html`\n <p>\n You are about to begin making <b>monthly</b> donations of\n <b>${this.formattedAmount} ${this.currencyType}</b> to the Internet\n Archive. (Your first recurring contribution will be next month.)\n </p>\n `);\n }\n\n get confirmCTA(): string {\n return this.donationType === DonationType.Upsell\n ? msg('Start monthly donation')\n : msg('Complete donation');\n }\n\n render(): TemplateResult {\n return html`\n ${this.donationType === DonationType.Upsell\n ? this.confirmUpsellText\n : this.confirmationText}\n\n <div class=\"cta-group\">\n <button id=\"confirm\" @click=${() => this.confirmDonation()}>\n ${this.confirmCTA}\n </button>\n <button id=\"cancel\" @click=${() => this.cancelDonation()}>\n ${msg('Cancel')}\n </button>\n </div>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-confirm-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-confirm-cta-color--: var(\n --ia-donation-upsell-cta-button-color,\n var(--navy-blue)\n );\n --donation-confirm-cta-disabled-color--: var(\n --ia-donation-upsell-cta-button-disabled-color,\n rgba(109, 148, 201, 0.5)\n );\n\n display: block;\n }\n\n button {\n outline: none;\n cursor: pointer;\n }\n\n button#confirm {\n font-size: calc(var(--donation-confirm-base-font-size--) * 2);\n display: block;\n width: 100%;\n margin-top: var(--padding-sm);\n padding: var(--donation-confirm-base-font-size--)\n calc(var(--donation-confirm-base-font-size--) * 2);\n background-color: var(--donation-confirm-cta-color--);\n color: var(--true-white);\n border-radius: 5px;\n border: 0;\n font-weight: bold;\n line-height: normal;\n }\n\n button#cancel {\n margin-top: var(--donation-confirm-base-font-size--);\n border: 0;\n text-decoration: underline;\n background-color: transparent;\n }\n\n button:disabled {\n background-color: var(--donation-confirm-cta-disabled-color--);\n cursor: not-allowed;\n }\n `,\n ];\n }\n\n /**\n * The symbol for a PayPal-supported currency code. Dollars for anything\n * unlisted, which covers USD and NZD.\n * https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/\n */\n get currencySymbol(): string {\n switch (this.currencyType) {\n case 'AUD':\n return 'AU$';\n case 'BRL':\n return 'R$';\n case 'CAD':\n return 'CA$';\n case 'CHF':\n return 'Fr';\n case 'CNY':\n return '¥';\n case 'CZK':\n return 'Kč';\n case 'DKK':\n return 'Kr';\n case 'EUR':\n return '€';\n case 'GBP':\n return '£';\n case 'HKD':\n return 'HK$';\n case 'HUF':\n return 'Ft';\n case 'ILS':\n return '₪';\n case 'JPY':\n return '¥';\n case 'MXN':\n return 'MX$';\n case 'MYR':\n return 'RM';\n case 'NOK':\n return 'kr';\n case 'PLN':\n return 'zł';\n case 'RUB':\n return '₽';\n case 'SEK':\n return 'kr';\n case 'SGD':\n return 'S$';\n case 'THB':\n return '฿';\n case 'TWD':\n return 'NT$';\n default:\n return '$';\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ia-donation-confirm-modal.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-confirm-modal.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,E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IAAI,CAAC;YACd,KAAK,KAAK;gBACR,OAAO,GAAG,CAAC;YACb,KAAK,KAAK;gBACR,OAAO,KAAK,CAAC;YACf;gBACE,OAAO,GAAG,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAA;AA1K6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAY;AAGX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAsB;AAErB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAmD;AAE9C;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+DAAwC;AAEvC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8DAAuC;AAV3D,sBAAsB;IAFlC,aAAa,CAAC,2BAA2B,CAAC;IAC1C,SAAS,EAAE;GACC,sBAAsB,CA2KlC","sourcesContent":["import {\n css,\n html,\n LitElement,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { localized, msg } from '@lit/localize';\nimport { formatUsd } from '../localized-format';\nimport currency from 'currency.js';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport { DonationType } from '../models/donation-type';\n\n/**\n * The confirmation step shown before a PayPal donation goes through: what the\n * donor is about to give, with Complete and Cancel buttons.\n */\n@customElement('ia-donation-confirm-modal')\n@localized()\nexport class IADonationConfirmModal extends LitElement {\n @property({ type: Number }) amount = 5;\n\n /** An ISO currency code, e.g. `USD`. Drives the symbol shown with the amount. */\n @property({ type: String }) currencyType = 'USD';\n\n @property({ type: String }) donationType: DonationType = DonationType.OneTime;\n\n @property({ attribute: false }) confirmDonation: () => void = () => {};\n\n @property({ attribute: false }) cancelDonation: () => void = () => {};\n\n private get formattedAmount(): string {\n if (this.currencyType === 'USD') return formatUsd(this.amount);\n return currency(this.amount, { symbol: this.currencySymbol }).format();\n }\n\n get confirmationText(): TemplateResult {\n return msg(html`\n <p>\n You are about to make a <b>${this.donationType}</b> donation of\n <b>${this.formattedAmount} ${this.currencyType}</b> to the Internet\n Archive.\n </p>\n `);\n }\n\n get confirmUpsellText(): TemplateResult {\n return msg(html`\n <p>\n You are about to begin making <b>monthly</b> donations of\n <b>${this.formattedAmount} ${this.currencyType}</b> to the Internet\n Archive. (Your first recurring contribution will be next month.)\n </p>\n `);\n }\n\n get confirmCTA(): string {\n return this.donationType === DonationType.Upsell\n ? msg('Start monthly donation')\n : msg('Complete donation');\n }\n\n render(): TemplateResult {\n return html`\n ${this.donationType === DonationType.Upsell\n ? this.confirmUpsellText\n : this.confirmationText}\n\n <div class=\"cta-group\">\n <button id=\"confirm\" @click=${() => this.confirmDonation()}>\n ${this.confirmCTA}\n </button>\n <button id=\"cancel\" @click=${() => this.cancelDonation()}>\n ${msg('Cancel')}\n </button>\n </div>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-confirm-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-confirm-cta-color--: var(\n --ia-donation-upsell-cta-button-color,\n var(--navy-blue)\n );\n --donation-confirm-cta-disabled-color--: var(\n --ia-donation-upsell-cta-button-disabled-color,\n rgba(109, 148, 201, 0.5)\n );\n\n display: block;\n }\n\n button {\n outline: none;\n cursor: pointer;\n }\n\n button#confirm {\n font-size: calc(var(--donation-confirm-base-font-size--) * 2);\n display: block;\n width: 100%;\n margin-top: var(--padding-sm);\n padding: var(--donation-confirm-base-font-size--)\n calc(var(--donation-confirm-base-font-size--) * 2);\n background-color: var(--donation-confirm-cta-color--);\n color: var(--true-white);\n border-radius: 5px;\n border: 0;\n font-weight: bold;\n line-height: normal;\n }\n\n button#cancel {\n margin-top: var(--donation-confirm-base-font-size--);\n border: 0;\n text-decoration: underline;\n background-color: transparent;\n }\n\n button:disabled {\n background-color: var(--donation-confirm-cta-disabled-color--);\n cursor: not-allowed;\n }\n `,\n ];\n }\n\n /**\n * The symbol for a PayPal-supported currency code. Dollars for anything\n * unlisted, which covers USD and NZD.\n * https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/\n */\n get currencySymbol(): string {\n switch (this.currencyType) {\n case 'AUD':\n return 'AU$';\n case 'BRL':\n return 'R$';\n case 'CAD':\n return 'CA$';\n case 'CHF':\n return 'Fr';\n case 'CNY':\n return '¥';\n case 'CZK':\n return 'Kč';\n case 'DKK':\n return 'Kr';\n case 'EUR':\n return '€';\n case 'GBP':\n return '£';\n case 'HKD':\n return 'HK$';\n case 'HUF':\n return 'Ft';\n case 'ILS':\n return '₪';\n case 'JPY':\n return '¥';\n case 'MXN':\n return 'MX$';\n case 'MYR':\n return 'RM';\n case 'NOK':\n return 'kr';\n case 'PLN':\n return 'zł';\n case 'RUB':\n return '₽';\n case 'SEK':\n return 'kr';\n case 'SGD':\n return 'S$';\n case 'THB':\n return '฿';\n case 'TWD':\n return 'NT$';\n default:\n return '$';\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ia-donation-upsell-modal-content.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAQb,oGAAoG;AACpG,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE/D;;;;GAIG;AACH,qBACa,4BAA6B,SAAQ,UAAU;IAC9B,aAAa,EAAE,kBAAkB,CAC9B;IAEH,MAAM,SAAK;IAEX,KAAK,CAAC,EAAE,cAAc,CAAC;IAE3B,WAAW,EAAG,gBAAgB,CAAC;IAEvD,OAAO,CAAC,iBAAiB,CAA8C;IAEvE,MAAM,IAAI,cAAc;IAgCxB,OAAO,KAAK,SAAS,GA6BpB;IAED,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,aAAa;IA2BrB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,gBAAgB;IAIxB,MAAM,KAAK,MAAM,IAAI,cAAc,CAiKlC;CACF"}
1
+ {"version":3,"file":"ia-donation-upsell-modal-content.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AASb,oGAAoG;AACpG,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE/D;;;;GAIG;AACH,qBACa,4BAA6B,SAAQ,UAAU;IAC9B,aAAa,EAAE,kBAAkB,CAC9B;IAEH,MAAM,SAAK;IAEX,KAAK,CAAC,EAAE,cAAc,CAAC;IAE3B,WAAW,EAAG,gBAAgB,CAAC;IAEvD,OAAO,CAAC,iBAAiB,CAA8C;IAEvE,MAAM,IAAI,cAAc;IAgCxB,OAAO,KAAK,SAAS,GA6BpB;IAED,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,aAAa;IA2BrB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,gBAAgB;IAIxB,MAAM,KAAK,MAAM,IAAI,cAAc,CAiKlC;CACF"}
@@ -5,6 +5,7 @@ import { customElement } from '../../../utils/custom-element.js';
5
5
  import { msg } from '@lit/localize';
6
6
  import themeStyles from '../../../themes/theme-styles.js';
7
7
  import { CurrencyValidator } from '../currency-validator.js';
8
+ import { parseAmount } from '../parse-amount.js';
8
9
  /** How the "yes" side of the upsell is offered: our own button, or a slot for the PayPal button. */
9
10
  export const UpsellModalCTAMode = {
10
11
  YesButton: 'YesButton',
@@ -92,7 +93,7 @@ let IADonationUpsellModalContent = class IADonationUpsellModalContent extends Li
92
93
  this.handleCustomAmountInput(amount);
93
94
  }
94
95
  handleCustomAmountInput(value) {
95
- const amount = parseFloat(value);
96
+ const amount = parseAmount(value);
96
97
  if (isNaN(amount)) {
97
98
  this.error = html `${msg('Please enter a valid amount.')}`;
98
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ia-donation-upsell-modal-content.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,oGAAoG;AACpG,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS,EAAE,WAAW;IACtB,gBAAgB,EAAE,kBAAkB;CAC5B,CAAC;AAKX;;;;GAIG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,UAAU;IAArD;;QACuB,kBAAa,GACvC,kBAAkB,CAAC,SAAS,CAAC;QAEH,WAAM,GAAG,CAAC,CAAC;QAM/B,sBAAiB,GAAsB,IAAI,iBAAiB,EAAE,CAAC;IA2RzE,CAAC;IAzRC,MAAM;QACJ,OAAO,IAAI,CAAA;YACH,GAAG,CAAC,yBAAyB,CAAC;uBACnB,IAAI,CAAC,gBAAgB;UAClC,GAAG,CAAC,UAAU,CAAC;;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C,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4JF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AApS6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEACI;AAEH;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAwB;AAE3B;IAAvB,KAAK,CAAC,eAAe,CAAC;iEAAgC;AAR5C,4BAA4B;IADxC,aAAa,CAAC,kCAAkC,CAAC;GACrC,4BAA4B,CAqSxC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { msg } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport { CurrencyValidator } from '../currency-validator';\n\n/** How the \"yes\" side of the upsell is offered: our own button, or a slot for the PayPal button. */\nexport const UpsellModalCTAMode = {\n YesButton: 'YesButton',\n PayPalUpsellSlot: 'PayPalUpsellSlot',\n} as const;\n\nexport type UpsellModalCTAMode =\n (typeof UpsellModalCTAMode)[keyof typeof UpsellModalCTAMode];\n\n/**\n * The content of the upsell modal shown after a one-time donation: a thank\n * you, a monthly amount field, and a yes button (or the PayPal button, when\n * the donation came through PayPal).\n */\n@customElement('ia-donation-upsell-modal-content')\nexport class IADonationUpsellModalContent extends LitElement {\n @property({ type: String }) yesButtonMode: UpsellModalCTAMode =\n UpsellModalCTAMode.YesButton;\n\n @property({ type: Number }) amount = 5;\n\n @property({ type: Object }) error?: TemplateResult;\n\n @query('#amount-input') amountInput!: HTMLInputElement;\n\n private currencyValidator: CurrencyValidator = new CurrencyValidator();\n\n render(): TemplateResult {\n return html`\n <h3>${msg('Thank you for donating!')}</h3>\n <button @click=${this.noThanksSelected} class=\"cta-button\" id=\"no-button\">\n ${msg('Continue')}\n </button>\n <p class=\"or_separator\"><span>${msg('or')}</span></p>\n <h3>${msg('Join our Monthly Giving Circle')}</h3>\n <p class=\"appeal\">\n ${msg('Monthly support helps us reliably plan for the future.')}\n </p>\n <div class=\"monthly-amount\">\n <h1>${msg('Enter your monthly amount')}</h1>\n <div class=\"amount-input\">\n <span class=\"dollar-symbol\">$</span>\n <input\n id=\"amount-input\"\n type=\"text\"\n tabindex=\"0\"\n aria-label=${msg('Monthly amount in dollars')}\n value=${this.amount}\n @input=${this.amountChanged}\n @keydown=${this.currencyValidator.keydown}\n />\n </div>\n <div class=\"error ${this.error ? '' : 'hidden'}\">${this.error}</div>\n </div>\n\n ${this.yesButton}\n `;\n }\n\n private get yesButton(): TemplateResult | typeof nothing {\n switch (this.yesButtonMode) {\n case UpsellModalCTAMode.YesButton:\n return html`\n <button\n class=\"cta-button\"\n tabindex=\"0\"\n id=\"yes-button\"\n @click=${this.yesSelected}\n .disabled=${this.error !== undefined}\n >\n ${msg(\"YES, I'll donate monthly\")}\n </button>\n `;\n case UpsellModalCTAMode.PayPalUpsellSlot:\n return html`\n <div class=\"paypal-upsell-slot-container\">\n <div\n class=\"paypal-upsell-slot-blocker ${this.error ? '' : 'hidden'}\"\n ></div>\n <button class=\"cta-button\" id=\"paypal-cover-button\">\n ${msg(\"YES, I'll donate monthly\")}\n </button>\n <slot class=\"paypal-upsell-slot\"></slot>\n </div>\n `;\n default:\n return nothing;\n }\n }\n\n private amountChanged(e: Event): void {\n const target = e.target as HTMLInputElement;\n const amount = target.value;\n if (amount.length === 0) {\n return;\n }\n this.handleCustomAmountInput(amount);\n }\n\n private handleCustomAmountInput(value: string): void {\n const amount = parseFloat(value);\n if (isNaN(amount)) {\n this.error = html`${msg('Please enter a valid amount.')}`;\n } else {\n this.processAmount(amount);\n }\n }\n\n private processAmount(amount: number): void {\n if (amount >= 10000) {\n this.error = msg(html`\n To make a donation of $10,000 or more, please contact our philanthropy\n department at\n <a href=\"mailto:donations@archive.org\">donations@archive.org</a>\n `);\n return;\n }\n\n if (amount < 1) {\n if (this.amountInput && this.amountInput.value.length > 0) {\n this.error = html`${msg('The minimum donation amount is $1.')}`;\n }\n return;\n }\n\n this.error = undefined;\n\n this.amount = amount;\n\n const event = new CustomEvent('amountChanged', {\n detail: { amount: this.amount },\n });\n this.dispatchEvent(event);\n }\n\n private yesSelected(): void {\n const event = new CustomEvent('yesSelected', {\n detail: { amount: this.amount },\n });\n this.dispatchEvent(event);\n }\n\n private noThanksSelected(): void {\n this.dispatchEvent(new Event('noThanksSelected'));\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-upsell-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-upsell-cta-color--: var(\n --ia-donation-upsell-cta-button-color,\n var(--navy-blue)\n );\n --donation-upsell-cta-disabled-color--: var(\n --ia-donation-upsell-cta-button-disabled-color,\n rgba(109, 148, 201, 0.5)\n );\n /* Shifts the amount field left a little so the dollar sign and field read as centred */\n --donation-upsell-amount-input-offset--: var(\n --ia-donation-upsell-amount-input-offset,\n calc(var(--donation-upsell-base-font-size--) * -1)\n );\n --donation-upsell-error-color--: var(--color-danger);\n }\n\n .monthly-amount {\n background-color: var(--true-white);\n padding: var(--padding-sm) 0.625rem;\n border-radius: 5px;\n text-align: center;\n margin-bottom: var(--padding-sm);\n margin-top: 0;\n }\n\n .monthly-amount h1 {\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.8);\n font-weight: bold;\n text-align: center;\n line-height: 1.2em;\n margin: 0;\n padding: var(--padding-sm) 0 0 0;\n }\n\n .hidden {\n display: none;\n }\n\n h3 {\n text-align: center;\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.8);\n margin: 0 var(--donation-upsell-base-font-size--) var(--padding-sm)\n var(--donation-upsell-base-font-size--);\n }\n\n .appeal {\n text-align: center;\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.6);\n margin: var(--padding-sm) var(--donation-upsell-base-font-size--);\n }\n\n .amount-input {\n transform: translate(var(--donation-upsell-amount-input-offset--), 0);\n }\n\n .amount-input .dollar-symbol {\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.8);\n font-weight: bold;\n }\n\n .amount-input input {\n width: 100px;\n text-align: center;\n border: none;\n border-bottom: 1px solid gray;\n font-weight: bold;\n font-size: calc(var(--donation-upsell-base-font-size--) * 3.4);\n }\n\n .cta-button {\n font-size: calc(var(--donation-upsell-base-font-size--) * 2);\n display: block;\n width: 100%;\n margin-top: var(--padding-sm);\n padding: var(--donation-upsell-base-font-size--)\n calc(var(--donation-upsell-base-font-size--) * 2);\n background-color: var(--donation-upsell-cta-color--);\n color: var(--true-white);\n border-radius: 5px;\n border: 0;\n font-weight: bold;\n line-height: normal;\n outline: none;\n cursor: pointer;\n }\n\n .cta-button:disabled {\n background-color: var(--donation-upsell-cta-disabled-color--);\n cursor: not-allowed;\n }\n\n .paypal-upsell-slot {\n text-align: center;\n }\n\n .paypal-upsell-slot-blocker {\n position: absolute;\n width: 100%;\n height: calc(var(--donation-upsell-base-font-size--) * 4.5);\n bottom: 0;\n z-index: 250;\n cursor: not-allowed;\n background-color: rgba(255, 255, 255, 0.5);\n }\n\n .paypal-upsell-slot-blocker.hidden {\n display: none;\n }\n\n #paypal-cover-button {\n position: absolute;\n width: 100%;\n bottom: 0;\n }\n\n .paypal-upsell-slot-container {\n position: relative;\n }\n\n .error {\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.4);\n margin: var(--padding-sm) 0;\n color: var(--donation-upsell-error-color--);\n }\n\n .or_separator {\n position: relative;\n margin: 0 calc(var(--donation-upsell-base-font-size--) * 2);\n font-size: calc(var(--donation-upsell-base-font-size--) * 2.6);\n font-weight: bold;\n text-transform: uppercase;\n text-align: center;\n }\n\n .or_separator:before {\n position: absolute;\n top: calc(50% - 1px);\n right: 0;\n left: 0;\n height: 2px;\n content: '';\n background: var(--mid-gray);\n }\n\n .or_separator span {\n display: inline-block;\n position: relative;\n padding: 0 var(--donation-upsell-base-font-size--);\n background: #f5f5f7;\n }\n `,\n ];\n }\n}\n"]}
1
+ {"version":3,"file":"ia-donation-upsell-modal-content.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,oGAAoG;AACpG,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS,EAAE,WAAW;IACtB,gBAAgB,EAAE,kBAAkB;CAC5B,CAAC;AAKX;;;;GAIG;AAEI,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,UAAU;IAArD;;QACuB,kBAAa,GACvC,kBAAkB,CAAC,SAAS,CAAC;QAEH,WAAM,GAAG,CAAC,CAAC;QAM/B,sBAAiB,GAAsB,IAAI,iBAAiB,EAAE,CAAC;IA2RzE,CAAC;IAzRC,MAAM;QACJ,OAAO,IAAI,CAAA;YACH,GAAG,CAAC,yBAAyB,CAAC;uBACnB,IAAI,C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C,aAAa,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4JF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AApS6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEACI;AAEH;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAwB;AAE3B;IAAvB,KAAK,CAAC,eAAe,CAAC;iEAAgC;AAR5C,4BAA4B;IADxC,aAAa,CAAC,kCAAkC,CAAC;GACrC,4BAA4B,CAqSxC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { msg } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport { CurrencyValidator } from '../currency-validator';\nimport { parseAmount } from '../parse-amount';\n\n/** How the \"yes\" side of the upsell is offered: our own button, or a slot for the PayPal button. */\nexport const UpsellModalCTAMode = {\n YesButton: 'YesButton',\n PayPalUpsellSlot: 'PayPalUpsellSlot',\n} as const;\n\nexport type UpsellModalCTAMode =\n (typeof UpsellModalCTAMode)[keyof typeof UpsellModalCTAMode];\n\n/**\n * The content of the upsell modal shown after a one-time donation: a thank\n * you, a monthly amount field, and a yes button (or the PayPal button, when\n * the donation came through PayPal).\n */\n@customElement('ia-donation-upsell-modal-content')\nexport class IADonationUpsellModalContent extends LitElement {\n @property({ type: String }) yesButtonMode: UpsellModalCTAMode =\n UpsellModalCTAMode.YesButton;\n\n @property({ type: Number }) amount = 5;\n\n @property({ type: Object }) error?: TemplateResult;\n\n @query('#amount-input') amountInput!: HTMLInputElement;\n\n private currencyValidator: CurrencyValidator = new CurrencyValidator();\n\n render(): TemplateResult {\n return html`\n <h3>${msg('Thank you for donating!')}</h3>\n <button @click=${this.noThanksSelected} class=\"cta-button\" id=\"no-button\">\n ${msg('Continue')}\n </button>\n <p class=\"or_separator\"><span>${msg('or')}</span></p>\n <h3>${msg('Join our Monthly Giving Circle')}</h3>\n <p class=\"appeal\">\n ${msg('Monthly support helps us reliably plan for the future.')}\n </p>\n <div class=\"monthly-amount\">\n <h1>${msg('Enter your monthly amount')}</h1>\n <div class=\"amount-input\">\n <span class=\"dollar-symbol\">$</span>\n <input\n id=\"amount-input\"\n type=\"text\"\n tabindex=\"0\"\n aria-label=${msg('Monthly amount in dollars')}\n value=${this.amount}\n @input=${this.amountChanged}\n @keydown=${this.currencyValidator.keydown}\n />\n </div>\n <div class=\"error ${this.error ? '' : 'hidden'}\">${this.error}</div>\n </div>\n\n ${this.yesButton}\n `;\n }\n\n private get yesButton(): TemplateResult | typeof nothing {\n switch (this.yesButtonMode) {\n case UpsellModalCTAMode.YesButton:\n return html`\n <button\n class=\"cta-button\"\n tabindex=\"0\"\n id=\"yes-button\"\n @click=${this.yesSelected}\n .disabled=${this.error !== undefined}\n >\n ${msg(\"YES, I'll donate monthly\")}\n </button>\n `;\n case UpsellModalCTAMode.PayPalUpsellSlot:\n return html`\n <div class=\"paypal-upsell-slot-container\">\n <div\n class=\"paypal-upsell-slot-blocker ${this.error ? '' : 'hidden'}\"\n ></div>\n <button class=\"cta-button\" id=\"paypal-cover-button\">\n ${msg(\"YES, I'll donate monthly\")}\n </button>\n <slot class=\"paypal-upsell-slot\"></slot>\n </div>\n `;\n default:\n return nothing;\n }\n }\n\n private amountChanged(e: Event): void {\n const target = e.target as HTMLInputElement;\n const amount = target.value;\n if (amount.length === 0) {\n return;\n }\n this.handleCustomAmountInput(amount);\n }\n\n private handleCustomAmountInput(value: string): void {\n const amount = parseAmount(value);\n if (isNaN(amount)) {\n this.error = html`${msg('Please enter a valid amount.')}`;\n } else {\n this.processAmount(amount);\n }\n }\n\n private processAmount(amount: number): void {\n if (amount >= 10000) {\n this.error = msg(html`\n To make a donation of $10,000 or more, please contact our philanthropy\n department at\n <a href=\"mailto:donations@archive.org\">donations@archive.org</a>\n `);\n return;\n }\n\n if (amount < 1) {\n if (this.amountInput && this.amountInput.value.length > 0) {\n this.error = html`${msg('The minimum donation amount is $1.')}`;\n }\n return;\n }\n\n this.error = undefined;\n\n this.amount = amount;\n\n const event = new CustomEvent('amountChanged', {\n detail: { amount: this.amount },\n });\n this.dispatchEvent(event);\n }\n\n private yesSelected(): void {\n const event = new CustomEvent('yesSelected', {\n detail: { amount: this.amount },\n });\n this.dispatchEvent(event);\n }\n\n private noThanksSelected(): void {\n this.dispatchEvent(new Event('noThanksSelected'));\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-upsell-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-upsell-cta-color--: var(\n --ia-donation-upsell-cta-button-color,\n var(--navy-blue)\n );\n --donation-upsell-cta-disabled-color--: var(\n --ia-donation-upsell-cta-button-disabled-color,\n rgba(109, 148, 201, 0.5)\n );\n /* Shifts the amount field left a little so the dollar sign and field read as centred */\n --donation-upsell-amount-input-offset--: var(\n --ia-donation-upsell-amount-input-offset,\n calc(var(--donation-upsell-base-font-size--) * -1)\n );\n --donation-upsell-error-color--: var(--color-danger);\n }\n\n .monthly-amount {\n background-color: var(--true-white);\n padding: var(--padding-sm) 0.625rem;\n border-radius: 5px;\n text-align: center;\n margin-bottom: var(--padding-sm);\n margin-top: 0;\n }\n\n .monthly-amount h1 {\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.8);\n font-weight: bold;\n text-align: center;\n line-height: 1.2em;\n margin: 0;\n padding: var(--padding-sm) 0 0 0;\n }\n\n .hidden {\n display: none;\n }\n\n h3 {\n text-align: center;\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.8);\n margin: 0 var(--donation-upsell-base-font-size--) var(--padding-sm)\n var(--donation-upsell-base-font-size--);\n }\n\n .appeal {\n text-align: center;\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.6);\n margin: var(--padding-sm) var(--donation-upsell-base-font-size--);\n }\n\n .amount-input {\n transform: translate(var(--donation-upsell-amount-input-offset--), 0);\n }\n\n .amount-input .dollar-symbol {\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.8);\n font-weight: bold;\n }\n\n .amount-input input {\n width: 100px;\n text-align: center;\n border: none;\n border-bottom: 1px solid gray;\n font-weight: bold;\n font-size: calc(var(--donation-upsell-base-font-size--) * 3.4);\n }\n\n .cta-button {\n font-size: calc(var(--donation-upsell-base-font-size--) * 2);\n display: block;\n width: 100%;\n margin-top: var(--padding-sm);\n padding: var(--donation-upsell-base-font-size--)\n calc(var(--donation-upsell-base-font-size--) * 2);\n background-color: var(--donation-upsell-cta-color--);\n color: var(--true-white);\n border-radius: 5px;\n border: 0;\n font-weight: bold;\n line-height: normal;\n outline: none;\n cursor: pointer;\n }\n\n .cta-button:disabled {\n background-color: var(--donation-upsell-cta-disabled-color--);\n cursor: not-allowed;\n }\n\n .paypal-upsell-slot {\n text-align: center;\n }\n\n .paypal-upsell-slot-blocker {\n position: absolute;\n width: 100%;\n height: calc(var(--donation-upsell-base-font-size--) * 4.5);\n bottom: 0;\n z-index: 250;\n cursor: not-allowed;\n background-color: rgba(255, 255, 255, 0.5);\n }\n\n .paypal-upsell-slot-blocker.hidden {\n display: none;\n }\n\n #paypal-cover-button {\n position: absolute;\n width: 100%;\n bottom: 0;\n }\n\n .paypal-upsell-slot-container {\n position: relative;\n }\n\n .error {\n font-size: calc(var(--donation-upsell-base-font-size--) * 1.4);\n margin: var(--padding-sm) 0;\n color: var(--donation-upsell-error-color--);\n }\n\n .or_separator {\n position: relative;\n margin: 0 calc(var(--donation-upsell-base-font-size--) * 2);\n font-size: calc(var(--donation-upsell-base-font-size--) * 2.6);\n font-weight: bold;\n text-transform: uppercase;\n text-align: center;\n }\n\n .or_separator:before {\n position: absolute;\n top: calc(50% - 1px);\n right: 0;\n left: 0;\n height: 2px;\n content: '';\n background: var(--mid-gray);\n }\n\n .or_separator span {\n display: inline-block;\n position: relative;\n padding: 0 var(--donation-upsell-base-font-size--);\n background: #f5f5f7;\n }\n `,\n ];\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Reads a typed, pasted or linked amount as a number, whatever the language.
3
+ * A separator (comma or dot) followed by one or two digits at the end is the
4
+ * decimal point, and a comma followed by exactly three digits is a thousands
5
+ * separator: `10,50` and `10.50` are 10.50, `1,000` is 1000, and `1.000,50`
6
+ * and `1,000.50` are 1000.50. A dot followed by exactly three digits, as in
7
+ * `1.000`, can't be told apart from a decimal, so it isn't an amount. A trailing separator, as in `10,`,
8
+ * is a decimal point still being typed. Returns `NaN` for anything else, so a
9
+ * value that can't be read is reported instead of guessed at.
10
+ */
11
+ export declare function parseAmount(value: string): number;
12
+ //# sourceMappingURL=parse-amount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-amount.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/parse-amount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA6BjD"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Reads a typed, pasted or linked amount as a number, whatever the language.
3
+ * A separator (comma or dot) followed by one or two digits at the end is the
4
+ * decimal point, and a comma followed by exactly three digits is a thousands
5
+ * separator: `10,50` and `10.50` are 10.50, `1,000` is 1000, and `1.000,50`
6
+ * and `1,000.50` are 1000.50. A dot followed by exactly three digits, as in
7
+ * `1.000`, can't be told apart from a decimal, so it isn't an amount. A trailing separator, as in `10,`,
8
+ * is a decimal point still being typed. Returns `NaN` for anything else, so a
9
+ * value that can't be read is reported instead of guessed at.
10
+ */
11
+ export function parseAmount(value) {
12
+ const text = value.trim();
13
+ if (!/^[0-9]+([.,][0-9]*)*$/.test(text))
14
+ return NaN;
15
+ const lastSeparator = Math.max(text.lastIndexOf(','), text.lastIndexOf('.'));
16
+ if (lastSeparator === -1)
17
+ return parseFloat(text);
18
+ const separator = text[lastSeparator];
19
+ const other = separator === ',' ? '.' : ',';
20
+ const digitsAfter = text.length - lastSeparator - 1;
21
+ const grouped = (whole, groupSeparator) => new RegExp(`^[0-9]{1,3}(\\${groupSeparator}[0-9]{3})*$`).test(whole);
22
+ if (digitsAfter <= 2) {
23
+ const whole = text.slice(0, lastSeparator);
24
+ const wholeOk = whole.includes(other)
25
+ ? grouped(whole, other)
26
+ : /^[0-9]+$/.test(whole);
27
+ if (!wholeOk)
28
+ return NaN;
29
+ const fraction = text.slice(lastSeparator + 1);
30
+ return parseFloat(`${whole.split(other).join('')}.${fraction || '0'}`);
31
+ }
32
+ // A dot before three digits could be a decimal or a thousands separator,
33
+ // so only a comma reads as a thousands separator.
34
+ if (digitsAfter === 3 && separator === ',' && grouped(text, separator)) {
35
+ return parseFloat(text.split(separator).join(''));
36
+ }
37
+ return NaN;
38
+ }
39
+ //# sourceMappingURL=parse-amount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-amount.js","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/parse-amount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC;IAEpD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CA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AAC,EAAE,CAAC;QACvE,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Reads a typed, pasted or linked amount as a number, whatever the language.\n * A separator (comma or dot) followed by one or two digits at the end is the\n * decimal point, and a comma followed by exactly three digits is a thousands\n * separator: `10,50` and `10.50` are 10.50, `1,000` is 1000, and `1.000,50`\n * and `1,000.50` are 1000.50. A dot followed by exactly three digits, as in\n * `1.000`, can't be told apart from a decimal, so it isn't an amount. A trailing separator, as in `10,`,\n * is a decimal point still being typed. Returns `NaN` for anything else, so a\n * value that can't be read is reported instead of guessed at.\n */\nexport function parseAmount(value: string): number {\n const text = value.trim();\n if (!/^[0-9]+([.,][0-9]*)*$/.test(text)) return NaN;\n\n const lastSeparator = Math.max(text.lastIndexOf(','), text.lastIndexOf('.'));\n if (lastSeparator === -1) return parseFloat(text);\n\n const separator = text[lastSeparator];\n const other = separator === ',' ? '.' : ',';\n const digitsAfter = text.length - lastSeparator - 1;\n const grouped = (whole: string, groupSeparator: string): boolean =>\n new RegExp(`^[0-9]{1,3}(\\\\${groupSeparator}[0-9]{3})*$`).test(whole);\n\n if (digitsAfter <= 2) {\n const whole = text.slice(0, lastSeparator);\n const wholeOk = whole.includes(other)\n ? grouped(whole, other)\n : /^[0-9]+$/.test(whole);\n if (!wholeOk) return NaN;\n const fraction = text.slice(lastSeparator + 1);\n return parseFloat(`${whole.split(other).join('')}.${fraction || '0'}`);\n }\n\n // A dot before three digits could be a decimal or a thousands separator,\n // so only a comma reads as a thousands separator.\n if (digitsAfter === 3 && separator === ',' && grouped(text, separator)) {\n return parseFloat(text.split(separator).join(''));\n }\n return NaN;\n}\n"]}
@@ -11,9 +11,20 @@ export type CurrentAmountMode = 'on' | 'off';
11
11
  */
12
12
  export declare class IADonationThermometer extends LitElement {
13
13
  goalMessageMode: GoalMessageMode;
14
+ /**
15
+ * The message shown when the goal is near. Empty shows the built-in message
16
+ * in the current language.
17
+ */
14
18
  goalNearMessage: string;
19
+ /**
20
+ * The message shown when the goal is reached. Empty shows the built-in
21
+ * message in the current language.
22
+ */
15
23
  goalReachedMessage: string;
16
- /** The accessible name of the progress bar, for screen readers. */
24
+ /**
25
+ * The accessible name of the progress bar, for screen readers. Empty uses
26
+ * the built-in name in the current language.
27
+ */
17
28
  label: string;
18
29
  goalAmount: number;
19
30
  currentAmountMode: CurrentAmountMode;