@internetarchive/donation-form 0.5.20 → 0.5.21-a2

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 (135) hide show
  1. package/dist/demo/braintree-endpoint-manager.js +0 -1
  2. package/dist/demo/braintree-endpoint-manager.js.map +1 -1
  3. package/dist/demo/demo-analytics-handler.js.map +1 -1
  4. package/dist/demo/submit-form-with.js.map +1 -1
  5. package/dist/src/braintree-manager/braintree-manager.js +33 -35
  6. package/dist/src/braintree-manager/braintree-manager.js.map +1 -1
  7. package/dist/src/braintree-manager/payment-clients.js.map +1 -1
  8. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-interface.js +1 -0
  9. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource-delegate.js +1 -0
  10. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource-interface.js +1 -0
  11. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource.js.map +1 -1
  12. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay.js +15 -14
  13. package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay.js.map +1 -1
  14. package/dist/src/braintree-manager/payment-providers/credit-card/credit-card-interface.js +1 -0
  15. package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.js +3 -3
  16. package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.js.map +1 -1
  17. package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container.js +6 -6
  18. package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container.js.map +1 -1
  19. package/dist/src/braintree-manager/payment-providers/google-pay-interface.js +1 -0
  20. package/dist/src/braintree-manager/payment-providers/google-pay.js +15 -15
  21. package/dist/src/braintree-manager/payment-providers/google-pay.js.map +1 -1
  22. package/dist/src/braintree-manager/payment-providers/paypal/paypal-button-datasource.js.map +1 -1
  23. package/dist/src/braintree-manager/payment-providers/paypal/paypal-interface.js +1 -0
  24. package/dist/src/braintree-manager/payment-providers/paypal/paypal.js +1 -3
  25. package/dist/src/braintree-manager/payment-providers/paypal/paypal.js.map +1 -1
  26. package/dist/src/braintree-manager/payment-providers/venmo-interface.js +1 -0
  27. package/dist/src/braintree-manager/payment-providers/venmo.js +9 -8
  28. package/dist/src/braintree-manager/payment-providers/venmo.js.map +1 -1
  29. package/dist/src/braintree-manager/payment-providers-interface.d.ts +1 -1
  30. package/dist/src/braintree-manager/payment-providers-interface.js +1 -0
  31. package/dist/src/braintree-manager/payment-providers.js +3 -3
  32. package/dist/src/braintree-manager/payment-providers.js.map +1 -1
  33. package/dist/src/donation-form-controller.js +6 -5
  34. package/dist/src/donation-form-controller.js.map +1 -1
  35. package/dist/src/donation-form.js +10 -10
  36. package/dist/src/donation-form.js.map +1 -1
  37. package/dist/src/form-elements/badged-input.js +1 -5
  38. package/dist/src/form-elements/badged-input.js.map +1 -1
  39. package/dist/src/form-elements/contact-form/autocomplete-field-options.d.ts +1 -1
  40. package/dist/src/form-elements/contact-form/autocomplete-field-options.js +1 -0
  41. package/dist/src/form-elements/contact-form/contact-form.js +12 -10
  42. package/dist/src/form-elements/contact-form/contact-form.js.map +1 -1
  43. package/dist/src/form-elements/header/donation-form-header.js +1 -3
  44. package/dist/src/form-elements/header/donation-form-header.js.map +1 -1
  45. package/dist/src/form-elements/header/donation-summary.js.map +1 -1
  46. package/dist/src/form-elements/payment-selector.js +4 -4
  47. package/dist/src/form-elements/payment-selector.js.map +1 -1
  48. package/dist/src/form-elements/total-amount.js.map +1 -1
  49. package/dist/src/modals/confirm-donation-modal-content.js +13 -3
  50. package/dist/src/modals/confirm-donation-modal-content.js.map +1 -1
  51. package/dist/src/modals/error-modal-content.js.map +1 -1
  52. package/dist/src/modals/upsell-modal-content.js +5 -15
  53. package/dist/src/modals/upsell-modal-content.js.map +1 -1
  54. package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js +8 -19
  55. package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js.map +1 -1
  56. package/dist/src/payment-flow-handlers/handlers/applepay-flow-handler.js.map +1 -1
  57. package/dist/src/payment-flow-handlers/handlers/creditcard-flow-handler.js.map +1 -1
  58. package/dist/src/payment-flow-handlers/handlers/googlepay-flow-handler.js.map +1 -1
  59. package/dist/src/payment-flow-handlers/handlers/paypal-flow-handler.js +6 -6
  60. package/dist/src/payment-flow-handlers/handlers/paypal-flow-handler.js.map +1 -1
  61. package/dist/src/payment-flow-handlers/handlers/venmo-flow-handler.js +2 -1
  62. package/dist/src/payment-flow-handlers/handlers/venmo-flow-handler.js.map +1 -1
  63. package/dist/src/payment-flow-handlers/handlers/venmo-restoration-state-handler.js.map +1 -1
  64. package/dist/src/payment-flow-handlers/payment-flow-handlers.js +11 -11
  65. package/dist/src/payment-flow-handlers/payment-flow-handlers.js.map +1 -1
  66. package/dist/test/mocks/flow-handlers/individual-handlers/mock-creditcard-flow-handler.js.map +1 -1
  67. package/dist/test/mocks/flow-handlers/individual-handlers/mock-googlepay-flow-handler.js.map +1 -1
  68. package/dist/test/mocks/flow-handlers/mock-payment-flow-handlers.js.map +1 -1
  69. package/dist/test/mocks/mock-braintree-manager.js.map +1 -1
  70. package/dist/test/mocks/mock-modal-manager.js.map +1 -1
  71. package/dist/test/mocks/mock-payment-clients.js +68 -58
  72. package/dist/test/mocks/mock-payment-clients.js.map +1 -1
  73. package/dist/test/mocks/models/mock-custom-fields.js +0 -1
  74. package/dist/test/mocks/models/mock-custom-fields.js.map +1 -1
  75. package/dist/test/mocks/models/mock-success-response.js +0 -1
  76. package/dist/test/mocks/models/mock-success-response.js.map +1 -1
  77. package/dist/test/mocks/payment-clients/mock-applepay-client.js.map +1 -1
  78. package/dist/test/mocks/payment-clients/mock-applepay-paymentauthorizedevent.js.map +1 -1
  79. package/dist/test/mocks/payment-clients/mock-applepay-sessionmanager.js +3 -3
  80. package/dist/test/mocks/payment-clients/mock-applepay-sessionmanager.js.map +1 -1
  81. package/dist/test/mocks/payment-clients/mock-googlepay-library.js +4 -4
  82. package/dist/test/mocks/payment-clients/mock-googlepay-library.js.map +1 -1
  83. package/dist/test/mocks/payment-clients/mock-grecaptcha.js +8 -9
  84. package/dist/test/mocks/payment-clients/mock-grecaptcha.js.map +1 -1
  85. package/dist/test/mocks/payment-clients/mock-hostedfields-client.js +6 -6
  86. package/dist/test/mocks/payment-clients/mock-hostedfields-client.js.map +1 -1
  87. package/dist/test/mocks/payment-clients/mock-venmo-client.js +5 -5
  88. package/dist/test/mocks/payment-clients/mock-venmo-client.js.map +1 -1
  89. package/dist/test/mocks/payment-providers/individual-providers/mock-creditcard-handler.js +13 -13
  90. package/dist/test/mocks/payment-providers/individual-providers/mock-creditcard-handler.js.map +1 -1
  91. package/dist/test/mocks/payment-providers/individual-providers/mock-paypal-button-datasource.js.map +1 -1
  92. package/dist/test/mocks/payment-providers/mock-payment-providers.js +2 -1
  93. package/dist/test/mocks/payment-providers/mock-payment-providers.js.map +1 -1
  94. package/dist/test/tests/braintree-manager.test.js +0 -1
  95. package/dist/test/tests/braintree-manager.test.js.map +1 -1
  96. package/dist/test/tests/donation-form-controller.test.js +1 -3
  97. package/dist/test/tests/donation-form-controller.test.js.map +1 -1
  98. package/dist/test/tests/donation-form.test.js +4 -12
  99. package/dist/test/tests/donation-form.test.js.map +1 -1
  100. package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js +7 -8
  101. package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js.map +1 -1
  102. package/dist/test/tests/form-elements/donation-summary.test.js +2 -6
  103. package/dist/test/tests/form-elements/donation-summary.test.js.map +1 -1
  104. package/dist/test/tests/form-elements/payment-selector.test.js +5 -15
  105. package/dist/test/tests/form-elements/payment-selector.test.js.map +1 -1
  106. package/dist/test/tests/modals/error-modal-content.test.js.map +1 -1
  107. package/dist/test/tests/modals/upsell-modal-content.test.js.map +1 -1
  108. package/dist/test/tests/payment-clients.test.js.map +1 -1
  109. package/dist/test/tests/payment-providers/applepay.test.js +1 -1
  110. package/dist/test/tests/payment-providers/applepay.test.js.map +1 -1
  111. package/dist/test/tests/payment-providers/paypal-button-datasource.test.js.map +1 -1
  112. package/dist/test/tests/payment-providers/venmo.test.js +1 -1
  113. package/dist/test/tests/payment-providers/venmo.test.js.map +1 -1
  114. package/dist/test/tests/recaptcha-manager.test.js +4 -12
  115. package/dist/test/tests/recaptcha-manager.test.js.map +1 -1
  116. package/package.json +31 -25
  117. package/src/braintree-manager/braintree-manager.ts +0 -2
  118. package/src/braintree-manager/payment-clients.ts +1 -2
  119. package/src/braintree-manager/payment-providers/paypal/paypal-button-datasource.ts +1 -1
  120. package/src/braintree-manager/payment-providers/paypal/paypal.ts +3 -3
  121. package/src/donation-form-controller.ts +10 -9
  122. package/src/donation-form.ts +13 -16
  123. package/src/form-elements/badged-input.ts +1 -5
  124. package/src/form-elements/contact-form/contact-form.ts +25 -23
  125. package/src/form-elements/header/donation-form-header.ts +1 -3
  126. package/src/form-elements/payment-selector.ts +4 -4
  127. package/src/modals/confirm-donation-modal-content.ts +16 -6
  128. package/src/modals/upsell-modal-content.ts +5 -15
  129. package/src/payment-flow-handlers/donation-flow-modal-manager.ts +12 -22
  130. package/src/payment-flow-handlers/handlers/applepay-flow-handler.ts +2 -1
  131. package/src/payment-flow-handlers/handlers/creditcard-flow-handler.ts +2 -1
  132. package/src/payment-flow-handlers/handlers/googlepay-flow-handler.ts +4 -6
  133. package/src/payment-flow-handlers/handlers/paypal-flow-handler.ts +7 -6
  134. package/src/payment-flow-handlers/handlers/venmo-flow-handler.ts +2 -1
  135. package/src/payment-flow-handlers/payment-flow-handlers.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"donation-form.js","sourceRoot":"","sources":["../../src/donation-form.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6C,MAAM,KAAK,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO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oC;AAEnC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAkC;AAElC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAAmD;AAEhD;IAA7B,KAAK,CAAC,qBAAqB,CAAC;wDAA0C;AAExC;IAA9B,KAAK,CAAC,sBAAsB,CAAC;wDAAyC;AAE5C;IAA1B,KAAK,CAAC,kBAAkB,CAAC;qDAAmC;AA/BlD,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CA0gBxB;SA1gBY,YAAY","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport lockImg from '@internetarchive/icon-lock';\n\n// we have to import the registered component independently from the definition below\n// because inside each of these files, we're registering the custom element inside\n// these files and by simply importing the class name, you lose that behavior\n// See https://github.com/microsoft/TypeScript/issues/9191 for more discussion\nimport './form-elements/payment-selector';\nimport './form-elements/header/donation-form-header';\n\nimport { DonationFormHeader } from './form-elements/header/donation-form-header';\nimport { PaymentSelector } from './form-elements/payment-selector';\n\nimport { BraintreeManagerInterface } from './braintree-manager/braintree-interfaces';\n\nimport {\n DonationRequest,\n DonationPaymentInfo,\n PaymentProvider,\n DonorContactInfo,\n DonationType,\n defaultDonationAmounts,\n} from '@internetarchive/donation-form-data-models';\n\nimport { PaymentFlowHandlersInterface } from './payment-flow-handlers/payment-flow-handlers';\n\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport '@internetarchive/donation-form-section';\nimport {\n DonationFormSection,\n DonationFormSectionBadgeMode,\n} from '@internetarchive/donation-form-section';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/total-amount';\n\n@customElement('donation-form')\nexport class DonationForm extends LitElement {\n @property({ type: Object }) braintreeManager: BraintreeManagerInterface | undefined;\n\n @property({ type: Object }) paymentFlowHandlers: PaymentFlowHandlersInterface | undefined;\n\n @property({ type: Object }) donationRequest: DonationRequest | undefined;\n\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n @property({ type: Object }) contactForm?: ContactForm;\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: Boolean }) private creditCardVisible = false;\n\n @property({ type: Boolean }) private contactFormVisible = false;\n\n @property({ type: Boolean }) private donationInfoValid = true;\n\n @property({ type: String }) private selectedPaymentProvider?: PaymentProvider;\n\n @query('#contactFormSection') contactFormSection?: DonationFormSection;\n\n @query('donation-form-header') donationFormHeader!: DonationFormHeader;\n\n @query('payment-selector') paymentSelector!: PaymentSelector;\n\n private paypalButtonNeedsRender = true;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <donation-form-header\n .amountOptions=${this.amountOptions}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @editDonationError=${this.editDonationError}\n >\n </donation-form-header>\n\n <donation-form-section\n .badgeMode=${DonationFormSectionBadgeMode.HideBadgeLeaveSpacing}\n id=\"total-amount-section\"\n >\n <donation-form-total-amount .donationInfo=${this.donationInfo}>\n </donation-form-total-amount>\n </donation-form-section>\n\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart}\n headline=\"Choose a payment method\"\n >\n <payment-selector\n .paymentProviders=${this.braintreeManager?.paymentProviders}\n @firstUpdated=${this.paymentSelectorFirstUpdated}\n @creditCardSelected=${this.creditCardSelected}\n @venmoSelected=${this.venmoSelected}\n @applePaySelected=${this.applePaySelected}\n @googlePaySelected=${this.googlePaySelected}\n @paypalBlockerSelected=${this.paypalBlockerSelected}\n tabindex=\"0\"\n >\n <slot name=\"paypal-button\" slot=\"paypal-button\"></slot>\n </payment-selector>\n </donation-form-section>\n\n <div class=\"contact-form-section ${this.contactFormVisible ? '' : 'hidden'}\">\n ${this.contactFormSectionTemplate}\n </div>\n <slot name=\"recaptcha\"></slot>\n `;\n }\n\n async showConfirmationModalDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: Function;\n confirmDonationCB: Function;\n }): Promise<void> {\n this.paymentFlowHandlers?.showConfirmationStepModal(options);\n }\n\n /**\n * This is a developer convenience method that allows us to show the upsell modal without going\n * through the purchasing flow. If it's showing the PayPal button, it will trigger\n * the PayPal button render\n *\n * @param {{\n * oneTimeAmount: number;\n * ctaMode?: UpsellModalCTAMode;\n * yesSelected?: (amount: number) => void;\n * noSelected?: () => void;\n * amountChanged?: (amount: number) => void;\n * userClosedModalCallback?: () => void;\n * }} options\n * @returns {Promise<void>}\n * @memberof DonationForm\n */\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.paymentFlowHandlers?.showUpsellModal(options);\n\n if (options.ctaMode === UpsellModalCTAMode.PayPalUpsellSlot) {\n const handler = await this.braintreeManager?.paymentProviders.paypalHandler.get();\n const donationInfo = new DonationPaymentInfo({\n amount: options.oneTimeAmount,\n donationType: DonationType.OneTime,\n coverFees: false,\n });\n handler?.renderPayPalButton({\n selector: '#paypal-upsell-button',\n style: {\n color: 'blue' as paypal.ButtonColorOption,\n label: 'paypal' as paypal.ButtonLabelOption,\n shape: 'rect' as paypal.ButtonShapeOption,\n size: 'responsive' as paypal.ButtonSizeOption,\n tagline: false,\n },\n donationInfo: donationInfo,\n });\n }\n }\n\n get contactFormSectionTemplate(): TemplateResult {\n return html`\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart + 1}\n headline=\"Enter payment information\"\n id=\"contactFormSection\"\n >\n <slot name=\"contact-form\"></slot>\n <div class=\"credit-card-fields\" class=\"${this.creditCardVisible ? '' : 'hidden'}\">\n <slot name=\"braintree-hosted-fields\"></slot>\n </div>\n </donation-form-section>\n\n <donation-form-section .sectionBadge=${this.paymentSelectorNumberingStart + 2}>\n <slot name=\"recaptcha\"></slot>\n <button id=\"donate-button\" @click=${this.donateClicked}>\n Donate\n </button>\n\n <div class=\"secure-process-note\">\n ${lockImg} Your payment will be securely processed\n </div>\n </donation-form-section>\n `;\n }\n\n /**\n * Where to start the numbering of the payment selector\n *\n * - If we show the frequency selector in button mode, it becomes section 1, which makes\n * the amount selection section 2, and the payment selector section 3.\n * - If we show the frequency selector in checkbox mode, it is no longer section 1. The amount\n * selector becomes section 1 and the payment selector becomes section 2.\n *\n * Visually:\n *\n * Button Mode:\n * 1. Frequency selector\n * 2. Amount selector\n * 3. Payment selector\n * 4. Contact info\n * 5. Donate button\n *\n * Checkbox Mode:\n * 1. Amount selector (including the monthly checkbox)\n * 2. Payment selector <-- changes from 3 to 2\n * 3. Contact info <-- changes from 4 to 3\n * 4. Donate button <-- changes from 5 to 4\n *\n * @readonly\n * @private\n * @type {number}\n * @memberof DonationForm\n */\n private get paymentSelectorNumberingStart(): number {\n return this.frequencySelectionMode === EditDonationFrequencySelectionMode.Button ? 3 : 2;\n }\n\n private editDonationError(): void {\n this.donationInfoValid = false;\n }\n\n private paymentSelectorFirstUpdated(): void {\n if (this.paymentFlowHandlers?.paypalHandler) {\n this.renderPayPalButtonIfNeeded();\n }\n }\n\n private applePaySelected(e: CustomEvent): void {\n this.selectedPaymentProvider = PaymentProvider.ApplePay;\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n\n const originalEvent = e.detail.originalEvent;\n this.donationInfo &&\n this.paymentFlowHandlers?.applePayHandler?.paymentInitiated(this.donationInfo, originalEvent);\n this.emitPaymentFlowStartedEvent();\n }\n\n private googlePaySelected(): void {\n this.selectedPaymentProvider = PaymentProvider.GooglePay;\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n } else {\n this.donationInfo &&\n this.paymentFlowHandlers?.googlePayHandler?.paymentInitiated(this.donationInfo);\n this.emitPaymentFlowStartedEvent();\n }\n }\n\n private async creditCardSelected(): Promise<void> {\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n this.selectedPaymentProvider = PaymentProvider.CreditCard;\n this.contactFormVisible = true;\n this.creditCardVisible = true;\n this.focusContactForm();\n }\n\n private async venmoSelected(): Promise<void> {\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n this.selectedPaymentProvider = PaymentProvider.Venmo;\n this.contactFormVisible = true;\n this.creditCardVisible = false;\n this.focusContactForm();\n }\n\n private paypalBlockerSelected(): void {\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n this.showInvalidDonationInfoAlert();\n }\n\n private async focusContactForm(): Promise<void> {\n await this.updateComplete;\n if (this.contactFormSection) {\n this.contactForm?.focus();\n }\n }\n\n private async donateClicked(): Promise<void> {\n if (!this.contactForm) {\n alert('Please enter contact info.');\n return;\n }\n if (!this.donationInfoValid || !this.donationInfo) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n\n const contactInfo = this.contactForm.donorContactInfo;\n\n switch (this.selectedPaymentProvider) {\n case PaymentProvider.CreditCard:\n this.handleCreditCardDonationFlow(contactInfo, this.donationInfo);\n break;\n case PaymentProvider.Venmo:\n this.handleVenmoDonationFlow(contactInfo, this.donationInfo);\n break;\n }\n }\n\n private async handleCreditCardDonationFlow(\n contactInfo: DonorContactInfo,\n donationInfo: DonationPaymentInfo,\n ): Promise<void> {\n const creditCardFlowHandler = this.paymentFlowHandlers?.creditCardHandler;\n const creditCardHandler = await this.braintreeManager?.paymentProviders.creditCardHandler.get();\n creditCardHandler?.hideErrorMessage();\n const valid = this.contactForm?.reportValidity();\n const hostedFieldsResponse = await creditCardFlowHandler?.tokenizeFields();\n\n if (!valid || hostedFieldsResponse === undefined) {\n return;\n }\n\n this.emitPaymentFlowStartedEvent();\n creditCardFlowHandler?.paymentInitiated(hostedFieldsResponse, donationInfo, contactInfo);\n }\n\n private async handleVenmoDonationFlow(\n contactInfo: DonorContactInfo,\n donationInfo: DonationPaymentInfo,\n ): Promise<void> {\n const valid = this.contactForm?.reportValidity();\n if (!valid) {\n return;\n }\n this.paymentFlowHandlers?.venmoHandler?.paymentInitiated(contactInfo, donationInfo);\n }\n\n private emitPaymentFlowStartedEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowStarted', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowConfirmedEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowConfirmed', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowCancelledEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowCancelled', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowErrorEvent(error?: string): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowError', {\n detail: { paymentProvider: this.selectedPaymentProvider, error: error },\n });\n this.dispatchEvent(event);\n }\n\n private showInvalidDonationInfoAlert(): void {\n alert('Please enter a valid donation amount.');\n }\n\n private async renderPayPalButtonIfNeeded(): Promise<void> {\n if (!this.paypalButtonNeedsRender) {\n return;\n }\n this.paypalButtonNeedsRender = false;\n this.donationInfo &&\n (await this.paymentFlowHandlers?.paypalHandler?.renderPayPalButton(this.donationInfo));\n this.paymentSelector.showPaypalButton();\n }\n\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('donationInfo') && this.donationInfo) {\n // The PayPal button has a standalone datasource since we don't initiate the payment\n // through code so it has to have the donation info ready when the user taps the button.\n this.paymentFlowHandlers?.paypalHandler?.updateDonationInfo(this.donationInfo);\n this.donationFormHeader.donationInfo = this.donationInfo;\n }\n\n if (\n (changedProperties.has('paymentFlowHandlers') || changedProperties.has('donationInfo')) &&\n this.donationInfo &&\n this.paymentFlowHandlers\n ) {\n this.setupFlowHandlers();\n }\n\n if (changedProperties.has('donationInfoValid')) {\n this.paymentSelector.donationInfoValid = this.donationInfoValid;\n }\n\n if (changedProperties.has('selectedPaymentProvider')) {\n const event = new CustomEvent('paymentProviderSelected', {\n detail: {\n paymentProvider: this.selectedPaymentProvider,\n previousPaymentProvider: changedProperties.get('selectedPaymentProvider'),\n },\n });\n this.dispatchEvent(event);\n }\n }\n\n private flowHandlersConfigured = false;\n\n private setupFlowHandlers(): void {\n if (this.flowHandlersConfigured) {\n return;\n }\n this.flowHandlersConfigured = true;\n this.bindFlowListenerEvents();\n this.renderPayPalButtonIfNeeded();\n this.donationInfo &&\n this.paymentFlowHandlers?.paypalHandler?.updateDonationInfo(this.donationInfo);\n }\n\n private flowHandlerListenersBound = false;\n\n private bindFlowListenerEvents(): void {\n if (this.flowHandlerListenersBound) {\n return;\n }\n this.flowHandlerListenersBound = true;\n\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentStarted', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowStartedEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentConfirmed', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowConfirmedEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentCancelled', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowCancelledEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentError', (datasource, error) => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowErrorEvent(error);\n });\n\n this.paymentFlowHandlers?.googlePayHandler?.on('paymentCancelled', () => {\n this.selectedPaymentProvider = PaymentProvider.GooglePay;\n this.emitPaymentFlowCancelledEvent();\n });\n }\n\n private donationInfoChanged(e: CustomEvent): void {\n const donationInfo: DonationPaymentInfo = e.detail.donationInfo;\n this.donationInfo = new DonationPaymentInfo({\n amount: donationInfo.amount,\n donationType: donationInfo.donationType,\n coverFees: donationInfo.coverFees,\n });\n this.donationInfoValid = true;\n const event = new CustomEvent('donationInfoChanged', { detail: { donationInfo } });\n this.dispatchEvent(event);\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const donateButtonFontSize = css`var(--donateButtonFontSize, 2.6rem)`;\n const donateButtonHeight = css`var(--donateButtonHeight, 4rem)`;\n const donateButtonColor = css`var(--donateButtonColor, rgba(49, 164, 129, 1))`;\n const donateButtonTextColor = css`var(--donateButtonTextColor, #fff)`;\n const donateButtonHoverColor = css`var(--donateButtonHoverColor, rgba(39, 131, 103, 1))`;\n const totalAmountTopMargin = css`var(--donateTotalAmountTopMargin, 1.5rem)`;\n const totalAmountBottomMargin = css`var(--donateTotalAmountBottomMargin, 1.2rem)`;\n\n return css`\n h1 {\n margin: 0;\n padding: 0;\n }\n\n .hidden {\n display: none;\n }\n\n .secure-process-note {\n margin-top: 0.5em;\n font-size: 0.75em;\n text-align: center;\n }\n\n .secure-process-note svg {\n width: 1.2rem;\n height: 1.5rem;\n vertical-align: bottom;\n }\n\n #donate-button {\n width: 100%;\n appearance: none;\n -webkit-appearance: none;\n font-size: ${donateButtonFontSize};\n font-weight: bold;\n text-align: center;\n color: ${donateButtonTextColor};\n cursor: pointer;\n border: none;\n border-radius: 5px;\n background-color: ${donateButtonColor};\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n height: ${donateButtonHeight};\n }\n\n #donate-button:hover {\n background-color: ${donateButtonHoverColor};\n }\n\n #total-amount-section {\n display: block;\n margin-top: ${totalAmountTopMargin};\n margin-bottom: ${totalAmountBottomMargin};\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"donation-form.js","sourceRoot":"","sources":["../../src/donation-form.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6C,MAAM,KAAK,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,OAAO,MAAM,qCAAqC,CAAC;AAE1D,qFAAqF;AACrF,kFAAkF;AAClF,6EAA6E;AAC7E,8EAA8E;AAC9E,OAAO,kCAAkC,CAAC;AAC1C,OAAO,6CAA6C,CAAC;AAOrD,OAAO,EAEL,mBAAmB,EACnB,eAAe,EAEf,YAAY,EACZ,sBAAsB,GACvB,MAAM,4CAA4C,CAAC;AAIpD,OAAO,EACL,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,8CAA8C,CAAC;AAEtD,OAAO,wCAAwC,CAAC;AAChD,OAAO,EAEL,4BAA4B,GAC7B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,8BAA8B,CAAC;AAG/B,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAWsB,kBAAa,GAAa,sBAAsB,CAAC;QAEhD,0BAAqB,GAC/C,iCAAiC,CAAC,SAAS,CAAC;QAElB,2BAAsB,GAChD,kCAAkC,CAAC,MAAM,CAAC;QAEP,sBAAiB,GAAG,KAAK,CAAC;QAE1B,uBAAkB,GAAG,KAAK,CAAC;QAE3B,sBAAiB,GAAG,IAAI,CAAC;QAUtD,4BAAuB,GAAG,IAAI,CAAC;QAiX/B,2BAAsB,GAAG,KAAK,CAAC;QAa/B,8BAAyB,GAAG,KAAK,CAAC;IAuG5C,CAA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AQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA+D;AAE9D;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAoC;AAEnC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAA2B;AAE3B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;mDAAkD;AAEhD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DACmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DACiB;AAEf;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAmC;AAElC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDAAoC;AAEnC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAkC;AAElC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAAmD;AAEhD;IAA7B,KAAK,CAAC,qBAAqB,CAAC;wDAA0C;AAExC;IAA9B,KAAK,CAAC,sBAAsB,CAAC;wDAAyC;AAE5C;IAA1B,KAAK,CAAC,kBAAkB,CAAC;qDAAmC;AA/BlD,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAsgBxB;SAtgBY,YAAY","sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport { LitElement, html, css, CSSResult, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport lockImg from '@internetarchive/icon-lock/index.js';\n\n// we have to import the registered component independently from the definition below\n// because inside each of these files, we're registering the custom element inside\n// these files and by simply importing the class name, you lose that behavior\n// See https://github.com/microsoft/TypeScript/issues/9191 for more discussion\nimport './form-elements/payment-selector';\nimport './form-elements/header/donation-form-header';\n\nimport { DonationFormHeader } from './form-elements/header/donation-form-header';\nimport { PaymentSelector } from './form-elements/payment-selector';\n\nimport { BraintreeManagerInterface } from './braintree-manager/braintree-interfaces';\n\nimport {\n DonationRequest,\n DonationPaymentInfo,\n PaymentProvider,\n DonorContactInfo,\n DonationType,\n defaultDonationAmounts,\n} from '@internetarchive/donation-form-data-models';\n\nimport { PaymentFlowHandlersInterface } from './payment-flow-handlers/payment-flow-handlers';\n\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport '@internetarchive/donation-form-section';\nimport {\n DonationFormSection,\n DonationFormSectionBadgeMode,\n} from '@internetarchive/donation-form-section';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/total-amount';\n\n@customElement('donation-form')\nexport class DonationForm extends LitElement {\n @property({ type: Object }) braintreeManager: BraintreeManagerInterface | undefined;\n\n @property({ type: Object }) paymentFlowHandlers: PaymentFlowHandlersInterface | undefined;\n\n @property({ type: Object }) donationRequest: DonationRequest | undefined;\n\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n @property({ type: Object }) contactForm?: ContactForm;\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: Boolean }) private creditCardVisible = false;\n\n @property({ type: Boolean }) private contactFormVisible = false;\n\n @property({ type: Boolean }) private donationInfoValid = true;\n\n @property({ type: String }) private selectedPaymentProvider?: PaymentProvider;\n\n @query('#contactFormSection') contactFormSection?: DonationFormSection;\n\n @query('donation-form-header') donationFormHeader!: DonationFormHeader;\n\n @query('payment-selector') paymentSelector!: PaymentSelector;\n\n private paypalButtonNeedsRender = true;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <donation-form-header\n .amountOptions=${this.amountOptions}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @editDonationError=${this.editDonationError}\n >\n </donation-form-header>\n\n <donation-form-section\n .badgeMode=${DonationFormSectionBadgeMode.HideBadgeLeaveSpacing}\n id=\"total-amount-section\"\n >\n <donation-form-total-amount .donationInfo=${this.donationInfo}>\n </donation-form-total-amount>\n </donation-form-section>\n\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart}\n headline=\"Choose a payment method\"\n >\n <payment-selector\n .paymentProviders=${this.braintreeManager?.paymentProviders}\n @firstUpdated=${this.paymentSelectorFirstUpdated}\n @creditCardSelected=${this.creditCardSelected}\n @venmoSelected=${this.venmoSelected}\n @applePaySelected=${this.applePaySelected}\n @googlePaySelected=${this.googlePaySelected}\n @paypalBlockerSelected=${this.paypalBlockerSelected}\n tabindex=\"0\"\n >\n <slot name=\"paypal-button\" slot=\"paypal-button\"></slot>\n </payment-selector>\n </donation-form-section>\n\n <div class=\"contact-form-section ${this.contactFormVisible ? '' : 'hidden'}\">\n ${this.contactFormSectionTemplate}\n </div>\n <slot name=\"recaptcha\"></slot>\n `;\n }\n\n async showConfirmationModalDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: Function;\n confirmDonationCB: Function;\n }): Promise<void> {\n this.paymentFlowHandlers?.showConfirmationStepModal(options);\n }\n\n /**\n * This is a developer convenience method that allows us to show the upsell modal without going\n * through the purchasing flow. If it's showing the PayPal button, it will trigger\n * the PayPal button render\n *\n * @param {{\n * oneTimeAmount: number;\n * ctaMode?: UpsellModalCTAMode;\n * yesSelected?: (amount: number) => void;\n * noSelected?: () => void;\n * amountChanged?: (amount: number) => void;\n * userClosedModalCallback?: () => void;\n * }} options\n * @returns {Promise<void>}\n * @memberof DonationForm\n */\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.paymentFlowHandlers?.showUpsellModal(options);\n\n if (options.ctaMode === UpsellModalCTAMode.PayPalUpsellSlot) {\n const handler = await this.braintreeManager?.paymentProviders.paypalHandler.get();\n const donationInfo = new DonationPaymentInfo({\n amount: options.oneTimeAmount,\n donationType: DonationType.OneTime,\n coverFees: false,\n });\n handler?.renderPayPalButton({\n selector: '#paypal-upsell-button',\n style: {\n color: 'blue' as paypal.ButtonColorOption,\n label: 'paypal' as paypal.ButtonLabelOption,\n shape: 'rect' as paypal.ButtonShapeOption,\n size: 'responsive' as paypal.ButtonSizeOption,\n tagline: false,\n },\n donationInfo: donationInfo,\n });\n }\n }\n\n get contactFormSectionTemplate(): TemplateResult {\n return html`\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart + 1}\n headline=\"Enter payment information\"\n id=\"contactFormSection\"\n >\n <slot name=\"contact-form\"></slot>\n <div class=\"credit-card-fields\" class=\"${this.creditCardVisible ? '' : 'hidden'}\">\n <slot name=\"braintree-hosted-fields\"></slot>\n </div>\n </donation-form-section>\n\n <donation-form-section .sectionBadge=${this.paymentSelectorNumberingStart + 2}>\n <slot name=\"recaptcha\"></slot>\n <button id=\"donate-button\" @click=${this.donateClicked}>Donate</button>\n\n <div class=\"secure-process-note\">${lockImg} Your payment will be securely processed</div>\n </donation-form-section>\n `;\n }\n\n /**\n * Where to start the numbering of the payment selector\n *\n * - If we show the frequency selector in button mode, it becomes section 1, which makes\n * the amount selection section 2, and the payment selector section 3.\n * - If we show the frequency selector in checkbox mode, it is no longer section 1. The amount\n * selector becomes section 1 and the payment selector becomes section 2.\n *\n * Visually:\n *\n * Button Mode:\n * 1. Frequency selector\n * 2. Amount selector\n * 3. Payment selector\n * 4. Contact info\n * 5. Donate button\n *\n * Checkbox Mode:\n * 1. Amount selector (including the monthly checkbox)\n * 2. Payment selector <-- changes from 3 to 2\n * 3. Contact info <-- changes from 4 to 3\n * 4. Donate button <-- changes from 5 to 4\n *\n * @readonly\n * @private\n * @type {number}\n * @memberof DonationForm\n */\n private get paymentSelectorNumberingStart(): number {\n return this.frequencySelectionMode === EditDonationFrequencySelectionMode.Button ? 3 : 2;\n }\n\n private editDonationError(): void {\n this.donationInfoValid = false;\n }\n\n private paymentSelectorFirstUpdated(): void {\n if (this.paymentFlowHandlers?.paypalHandler) {\n this.renderPayPalButtonIfNeeded();\n }\n }\n\n private applePaySelected(e: CustomEvent): void {\n this.selectedPaymentProvider = PaymentProvider.ApplePay;\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n\n const originalEvent = e.detail.originalEvent;\n this.donationInfo &&\n this.paymentFlowHandlers?.applePayHandler?.paymentInitiated(this.donationInfo, originalEvent);\n this.emitPaymentFlowStartedEvent();\n }\n\n private googlePaySelected(): void {\n this.selectedPaymentProvider = PaymentProvider.GooglePay;\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n } else {\n this.donationInfo &&\n this.paymentFlowHandlers?.googlePayHandler?.paymentInitiated(this.donationInfo);\n this.emitPaymentFlowStartedEvent();\n }\n }\n\n private async creditCardSelected(): Promise<void> {\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n this.selectedPaymentProvider = PaymentProvider.CreditCard;\n this.contactFormVisible = true;\n this.creditCardVisible = true;\n this.focusContactForm();\n }\n\n private async venmoSelected(): Promise<void> {\n if (!this.donationInfoValid) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n this.selectedPaymentProvider = PaymentProvider.Venmo;\n this.contactFormVisible = true;\n this.creditCardVisible = false;\n this.focusContactForm();\n }\n\n private paypalBlockerSelected(): void {\n this.contactFormVisible = false;\n this.creditCardVisible = false;\n this.showInvalidDonationInfoAlert();\n }\n\n private async focusContactForm(): Promise<void> {\n await this.updateComplete;\n if (this.contactFormSection) {\n this.contactForm?.focus();\n }\n }\n\n private async donateClicked(): Promise<void> {\n if (!this.contactForm) {\n alert('Please enter contact info.');\n return;\n }\n if (!this.donationInfoValid || !this.donationInfo) {\n this.showInvalidDonationInfoAlert();\n return;\n }\n\n const contactInfo = this.contactForm.donorContactInfo;\n\n switch (this.selectedPaymentProvider) {\n case PaymentProvider.CreditCard:\n this.handleCreditCardDonationFlow(contactInfo, this.donationInfo);\n break;\n case PaymentProvider.Venmo:\n this.handleVenmoDonationFlow(contactInfo, this.donationInfo);\n break;\n }\n }\n\n private async handleCreditCardDonationFlow(\n contactInfo: DonorContactInfo,\n donationInfo: DonationPaymentInfo,\n ): Promise<void> {\n const creditCardFlowHandler = this.paymentFlowHandlers?.creditCardHandler;\n const creditCardHandler = await this.braintreeManager?.paymentProviders.creditCardHandler.get();\n creditCardHandler?.hideErrorMessage();\n const valid = this.contactForm?.reportValidity();\n const hostedFieldsResponse = await creditCardFlowHandler?.tokenizeFields();\n\n if (!valid || hostedFieldsResponse === undefined) {\n return;\n }\n\n this.emitPaymentFlowStartedEvent();\n creditCardFlowHandler?.paymentInitiated(hostedFieldsResponse, donationInfo, contactInfo);\n }\n\n private async handleVenmoDonationFlow(\n contactInfo: DonorContactInfo,\n donationInfo: DonationPaymentInfo,\n ): Promise<void> {\n const valid = this.contactForm?.reportValidity();\n if (!valid) {\n return;\n }\n this.paymentFlowHandlers?.venmoHandler?.paymentInitiated(contactInfo, donationInfo);\n }\n\n private emitPaymentFlowStartedEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowStarted', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowConfirmedEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowConfirmed', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowCancelledEvent(): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowCancelled', {\n detail: { paymentProvider: this.selectedPaymentProvider },\n });\n this.dispatchEvent(event);\n }\n\n private emitPaymentFlowErrorEvent(error?: string): void {\n if (!this.selectedPaymentProvider) {\n return;\n }\n const event = new CustomEvent('paymentFlowError', {\n detail: { paymentProvider: this.selectedPaymentProvider, error: error },\n });\n this.dispatchEvent(event);\n }\n\n private showInvalidDonationInfoAlert(): void {\n alert('Please enter a valid donation amount.');\n }\n\n private async renderPayPalButtonIfNeeded(): Promise<void> {\n if (!this.paypalButtonNeedsRender) {\n return;\n }\n this.paypalButtonNeedsRender = false;\n this.donationInfo &&\n (await this.paymentFlowHandlers?.paypalHandler?.renderPayPalButton(this.donationInfo));\n this.paymentSelector.showPaypalButton();\n }\n\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('donationInfo') && this.donationInfo) {\n // The PayPal button has a standalone datasource since we don't initiate the payment\n // through code so it has to have the donation info ready when the user taps the button.\n this.paymentFlowHandlers?.paypalHandler?.updateDonationInfo(this.donationInfo);\n this.donationFormHeader.donationInfo = this.donationInfo;\n }\n\n if (\n (changedProperties.has('paymentFlowHandlers') || changedProperties.has('donationInfo')) &&\n this.donationInfo &&\n this.paymentFlowHandlers\n ) {\n this.setupFlowHandlers();\n }\n\n if (changedProperties.has('donationInfoValid')) {\n this.paymentSelector.donationInfoValid = this.donationInfoValid;\n }\n\n if (changedProperties.has('selectedPaymentProvider')) {\n const event = new CustomEvent('paymentProviderSelected', {\n detail: {\n paymentProvider: this.selectedPaymentProvider,\n previousPaymentProvider: changedProperties.get('selectedPaymentProvider'),\n },\n });\n this.dispatchEvent(event);\n }\n }\n\n private flowHandlersConfigured = false;\n\n private setupFlowHandlers(): void {\n if (this.flowHandlersConfigured) {\n return;\n }\n this.flowHandlersConfigured = true;\n this.bindFlowListenerEvents();\n this.renderPayPalButtonIfNeeded();\n this.donationInfo &&\n this.paymentFlowHandlers?.paypalHandler?.updateDonationInfo(this.donationInfo);\n }\n\n private flowHandlerListenersBound = false;\n\n private bindFlowListenerEvents(): void {\n if (this.flowHandlerListenersBound) {\n return;\n }\n this.flowHandlerListenersBound = true;\n\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentStarted', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowStartedEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentConfirmed', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowConfirmedEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentCancelled', () => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowCancelledEvent();\n });\n this.paymentFlowHandlers?.paypalHandler?.on('payPalPaymentError', (datasource, error) => {\n this.selectedPaymentProvider = PaymentProvider.PayPal;\n this.emitPaymentFlowErrorEvent(error);\n });\n\n this.paymentFlowHandlers?.googlePayHandler?.on('paymentCancelled', () => {\n this.selectedPaymentProvider = PaymentProvider.GooglePay;\n this.emitPaymentFlowCancelledEvent();\n });\n }\n\n private donationInfoChanged(e: CustomEvent): void {\n const donationInfo: DonationPaymentInfo = e.detail.donationInfo;\n this.donationInfo = new DonationPaymentInfo({\n amount: donationInfo.amount,\n donationType: donationInfo.donationType,\n coverFees: donationInfo.coverFees,\n });\n this.donationInfoValid = true;\n const event = new CustomEvent('donationInfoChanged', { detail: { donationInfo } });\n this.dispatchEvent(event);\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const donateButtonFontSize = css`var(--donateButtonFontSize, 2.6rem)`;\n const donateButtonHeight = css`var(--donateButtonHeight, 4rem)`;\n const donateButtonColor = css`var(--donateButtonColor, rgba(49, 164, 129, 1))`;\n const donateButtonTextColor = css`var(--donateButtonTextColor, #fff)`;\n const donateButtonHoverColor = css`var(--donateButtonHoverColor, rgba(39, 131, 103, 1))`;\n const totalAmountTopMargin = css`var(--donateTotalAmountTopMargin, 1.5rem)`;\n const totalAmountBottomMargin = css`var(--donateTotalAmountBottomMargin, 1.2rem)`;\n\n return css`\n h1 {\n margin: 0;\n padding: 0;\n }\n\n .hidden {\n display: none;\n }\n\n .secure-process-note {\n margin-top: 0.5em;\n font-size: 0.75em;\n text-align: center;\n }\n\n .secure-process-note svg {\n width: 1.2rem;\n height: 1.5rem;\n vertical-align: bottom;\n }\n\n #donate-button {\n width: 100%;\n appearance: none;\n -webkit-appearance: none;\n font-size: ${donateButtonFontSize};\n font-weight: bold;\n text-align: center;\n color: ${donateButtonTextColor};\n cursor: pointer;\n border: none;\n border-radius: 5px;\n background-color: ${donateButtonColor};\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n height: ${donateButtonHeight};\n }\n\n #donate-button:hover {\n background-color: ${donateButtonHoverColor};\n }\n\n #total-amount-section {\n display: block;\n margin-top: ${totalAmountTopMargin};\n margin-bottom: ${totalAmountBottomMargin};\n }\n `;\n }\n}\n"]}
@@ -34,11 +34,7 @@ let BadgedInput = class BadgedInput extends LitElement {
34
34
  <div class="input-wrapper ${this.errorClass} ${this.iconSpaceOptionClass}">
35
35
  <div class="icon-container">${this.icon}</div>
36
36
  <div class="required-indicator ${this.requiredIndicatorSpaceOption}">
37
- ${this.required
38
- ? html `
39
- *
40
- `
41
- : nothing}
37
+ ${this.required ? html ` * ` : nothing}
42
38
  </div>
43
39
 
44
40
  <slot></slot>
@@ -1 +1 @@
1
- {"version":3,"file":"badged-input.js","sourceRoot":"","sources":["../../../src/form-elements/badged-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,OAAO,EAAE,MAAM,KAAK,CAAC;AAChF,OAAO,EAAE,a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GAAG,GAAG,CAAA,2CAA2C,CAAC;QACzE,MAAM,WAAW,GAAG,GAAG,CAAA,gCAAgC,CAAC;QACxD,MAAM,sBAAsB,GAAG,GAAG,CAAA,+CAA+C,CAAC;QAClF,MAAM,uBAAuB,GAAG,GAAG,CAAA,0DAA0D,CAAC;QAC9F,MAAM,yBAAyB,GAAG,GAAG,CAAA,mDAAmD,CAAC;QAEzF,OAAO,GAAG,CAAA;;kBAEI,SAAS;kBACT,WAAW;;;;;;4CAMe,aAAa;wBACjC,aAAa;;;;iBAIpB,iBAAiB;;;;iBAIjB,eAAe;;;;;;;;kBAQd,QAAQ;;;;iBAIT,sBAAsB;qBAClB,yBAAyB;kBAC5B,uBAAuB;;;;;;KAMpC,CAAC;IACJ,CAAC;CACF,CAAA;AAtG8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAe;AAEf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAuB;AAErB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAkB;AAQlB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAyD;AAUxD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAAsE;AAvBtF,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAuGvB;SAvGY,WAAW","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nexport enum SpacerOption {\n LeaveSpace = 'leave-space',\n CompressSpace = 'compress-space',\n}\n\n@customElement('badged-input')\nexport class BadgedInput extends LitElement {\n @property({ type: Boolean }) error = false;\n\n @property({ type: Object }) icon?: TemplateResult;\n\n @property({ type: Boolean }) required = false;\n\n /**\n * If the icon is hidden, should the space remain or be compressed\n *\n * @type {SpacerOption}\n * @memberof BadgedInput\n */\n @property({ type: String }) iconSpaceOption: SpacerOption = SpacerOption.LeaveSpace;\n\n /**\n * When the required indicator is hidden, should the spacing remain\n *\n * This is useful for aligning many fields where some may not be required\n *\n * @type {SpacerOption}\n * @memberof BadgedInput\n */\n @property({ type: String }) requiredIndicatorSpaceOption: SpacerOption = SpacerOption.LeaveSpace;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"input-wrapper ${this.errorClass} ${this.iconSpaceOptionClass}\">\n <div class=\"icon-container\">${this.icon}</div>\n <div class=\"required-indicator ${this.requiredIndicatorSpaceOption}\">\n ${this.required\n ? html`\n *\n `\n : nothing}\n </div>\n\n <slot></slot>\n </div>\n `;\n }\n\n private get errorClass(): string {\n return this.error ? 'error' : '';\n }\n\n private get iconSpaceOptionClass(): string {\n return this.iconSpaceOption === SpacerOption.CompressSpace ? 'compress-space' : '';\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const borderCss = css`var(--inputBorder, 1px solid #d9d9d9)`;\n const errorColorCss = css`var(--badgedInputBorderErrorColor, red)`;\n const iconSize = css`var(--badgedInputIconSize, 1.4rem)`;\n const iconSpacerWidth = css`var(--badgedInputIconSpacerWidth, 3rem)`;\n const noIconSpacerWidth = css`var(--badgedInputNoIconSpacerWidth, 1rem)`;\n const fieldHeight = css`var(--badgedInputHeight, 3rem)`;\n const requiredIndicatorColor = css`var(--badgedInputRequiredIndicatorColor, red)`;\n const requiredIndicatorMargin = css`var(--badgedInputRequiredIndicatorMargin, 0 0.25rem 0 0)`;\n const requiredIndicatorFontSize = css`var(--badgedInputRequiredIndicatorFontSize, 2rem)`;\n\n return css`\n .input-wrapper {\n border: ${borderCss};\n height: ${fieldHeight};\n display: flex;\n align-items: center;\n }\n\n .input-wrapper.error {\n box-shadow: inset 0px 0px 0px 1px ${errorColorCss};\n border-color: ${errorColorCss};\n }\n\n .input-wrapper.compress-space .icon-container {\n width: ${noIconSpacerWidth};\n }\n\n .icon-container {\n width: ${iconSpacerWidth};\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .icon-container svg {\n height: ${iconSize};\n }\n\n .required-indicator {\n color: ${requiredIndicatorColor};\n font-size: ${requiredIndicatorFontSize};\n margin: ${requiredIndicatorMargin};\n }\n\n .required-indicator.leave-space {\n width: 0.5em;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"badged-input.js","sourceRoot":"","sources":["../../../src/form-elements/badged-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,OAAO,EAAE,MAAM,KAAK,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,0CAA0B,CAAA;IAC1B,gDAAgC,CAAA;AAClC,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAGM,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QACwB,UAAK,GAAG,KAAK,CAAC;QAId,aAAQ,GAAG,KAAK,CAAC;QAE9C;;;;;WAKG;QACyB,oBAAe,GAAiB,YAAY,CAAC,UAAU,CAAC;QAEpF;;;;;;;WAOG;QACyB,iCAA4B,GAAiB,YAAY,CAAC,UAAU,CAAC;IA4EnG,CAAC;IA1EC,kBAAkB;IAClB,MAAM;QACJ,OAAO,IAAI,CAAA;kCACmB,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,oBAAoB;sCACxC,IAAI,CAAC,IAAI;yCACN,IAAI,CAAC,4BAA4B;YAC9D,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA,KAAK,CAAC,CAAC,CAAC,OAAO;;;;;KAK1C,CAAC;IACJ,CAAC;IAED,IAAY,UAAU;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACnC,CA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E,CAAC;iEAAsE;AAvBtF,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAmGvB;SAnGY,WAAW","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nexport enum SpacerOption {\n LeaveSpace = 'leave-space',\n CompressSpace = 'compress-space',\n}\n\n@customElement('badged-input')\nexport class BadgedInput extends LitElement {\n @property({ type: Boolean }) error = false;\n\n @property({ type: Object }) icon?: TemplateResult;\n\n @property({ type: Boolean }) required = false;\n\n /**\n * If the icon is hidden, should the space remain or be compressed\n *\n * @type {SpacerOption}\n * @memberof BadgedInput\n */\n @property({ type: String }) iconSpaceOption: SpacerOption = SpacerOption.LeaveSpace;\n\n /**\n * When the required indicator is hidden, should the spacing remain\n *\n * This is useful for aligning many fields where some may not be required\n *\n * @type {SpacerOption}\n * @memberof BadgedInput\n */\n @property({ type: String }) requiredIndicatorSpaceOption: SpacerOption = SpacerOption.LeaveSpace;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"input-wrapper ${this.errorClass} ${this.iconSpaceOptionClass}\">\n <div class=\"icon-container\">${this.icon}</div>\n <div class=\"required-indicator ${this.requiredIndicatorSpaceOption}\">\n ${this.required ? html` * ` : nothing}\n </div>\n\n <slot></slot>\n </div>\n `;\n }\n\n private get errorClass(): string {\n return this.error ? 'error' : '';\n }\n\n private get iconSpaceOptionClass(): string {\n return this.iconSpaceOption === SpacerOption.CompressSpace ? 'compress-space' : '';\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const borderCss = css`var(--inputBorder, 1px solid #d9d9d9)`;\n const errorColorCss = css`var(--badgedInputBorderErrorColor, red)`;\n const iconSize = css`var(--badgedInputIconSize, 1.4rem)`;\n const iconSpacerWidth = css`var(--badgedInputIconSpacerWidth, 3rem)`;\n const noIconSpacerWidth = css`var(--badgedInputNoIconSpacerWidth, 1rem)`;\n const fieldHeight = css`var(--badgedInputHeight, 3rem)`;\n const requiredIndicatorColor = css`var(--badgedInputRequiredIndicatorColor, red)`;\n const requiredIndicatorMargin = css`var(--badgedInputRequiredIndicatorMargin, 0 0.25rem 0 0)`;\n const requiredIndicatorFontSize = css`var(--badgedInputRequiredIndicatorFontSize, 2rem)`;\n\n return css`\n .input-wrapper {\n border: ${borderCss};\n height: ${fieldHeight};\n display: flex;\n align-items: center;\n }\n\n .input-wrapper.error {\n box-shadow: inset 0px 0px 0px 1px ${errorColorCss};\n border-color: ${errorColorCss};\n }\n\n .input-wrapper.compress-space .icon-container {\n width: ${noIconSpacerWidth};\n }\n\n .icon-container {\n width: ${iconSpacerWidth};\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n\n .icon-container svg {\n height: ${iconSize};\n }\n\n .required-indicator {\n color: ${requiredIndicatorColor};\n font-size: ${requiredIndicatorFontSize};\n margin: ${requiredIndicatorMargin};\n }\n\n .required-indicator.leave-space {\n width: 0.5em;\n }\n `;\n }\n}\n"]}
@@ -1 +1 @@
1
- export declare type AutoCompleteFieldOptions = 'on' | 'off' | 'additional-name' | 'address-level1' | 'address-level2' | 'address-level3' | 'address-level4' | 'address-line1' | 'address-line2' | 'address-line3' | 'bday' | 'bday-year' | 'bday-day' | 'bday-month' | 'billing' | 'cc-additional-name' | 'cc-csc' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-family-name' | 'cc-given-name' | 'cc-name' | 'cc-number' | 'cc-type' | 'country' | 'country-name' | 'current-password' | 'email' | 'family-name' | 'fax' | 'given-name' | 'home' | 'honorific-prefix' | 'honorific-suffix' | 'impp' | 'language' | 'mobile' | 'name' | 'new-password' | 'nickname' | 'organization' | 'organization-title' | 'pager' | 'photo' | 'postal-code' | 'sex' | 'shipping' | 'street-address' | 'tel-area-code' | 'tel' | 'tel-country-code' | 'tel-extension' | 'tel-local' | 'tel-local-prefix' | 'tel-local-suffix' | 'tel-national' | 'transaction-amount' | 'transaction-currency' | 'url' | 'username' | 'work';
1
+ export type AutoCompleteFieldOptions = 'on' | 'off' | 'additional-name' | 'address-level1' | 'address-level2' | 'address-level3' | 'address-level4' | 'address-line1' | 'address-line2' | 'address-line3' | 'bday' | 'bday-year' | 'bday-day' | 'bday-month' | 'billing' | 'cc-additional-name' | 'cc-csc' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-family-name' | 'cc-given-name' | 'cc-name' | 'cc-number' | 'cc-type' | 'country' | 'country-name' | 'current-password' | 'email' | 'family-name' | 'fax' | 'given-name' | 'home' | 'honorific-prefix' | 'honorific-suffix' | 'impp' | 'language' | 'mobile' | 'name' | 'new-password' | 'nickname' | 'organization' | 'organization-title' | 'pager' | 'photo' | 'postal-code' | 'sex' | 'shipping' | 'street-address' | 'tel-area-code' | 'tel' | 'tel-country-code' | 'tel-extension' | 'tel-local' | 'tel-local-prefix' | 'tel-local-suffix' | 'tel-national' | 'transaction-amount' | 'transaction-currency' | 'url' | 'username' | 'work';
@@ -1 +1,2 @@
1
+ export {};
1
2
  //# sourceMappingURL=autocomplete-field-options.js.map
@@ -5,9 +5,9 @@ import { ifDefined } from 'lit/directives/if-defined.js';
5
5
  import { BillingInfo, CustomerInfo, DonorContactInfo, } from '@internetarchive/donation-form-data-models';
6
6
  import { SpacerOption } from '../badged-input';
7
7
  import '../badged-input';
8
- import emailImg from '@internetarchive/icon-email';
9
- import localePinImg from '@internetarchive/icon-locale-pin';
10
- import userIcon from '@internetarchive/icon-user';
8
+ import emailImg from '@internetarchive/icon-email/index.js';
9
+ import localePinImg from '@internetarchive/icon-locale-pin/index.js';
10
+ import userIcon from '@internetarchive/icon-user/index.js';
11
11
  import { countries } from './countries';
12
12
  let ContactForm = class ContactForm extends LitElement {
13
13
  constructor() {
@@ -136,9 +136,7 @@ let ContactForm = class ContactForm extends LitElement {
136
136
  iconSpaceOption: SpacerOption.CompressSpace,
137
137
  })}
138
138
  </div>
139
- <div class="row">
140
- ${this.countrySelectorTemplate}
141
- </div>
139
+ <div class="row">${this.countrySelectorTemplate}</div>
142
140
  </fieldset>
143
141
  </form>
144
142
  ${this.getStyles}
@@ -147,11 +145,14 @@ let ContactForm = class ContactForm extends LitElement {
147
145
  get countrySelectorTemplate() {
148
146
  return html `
149
147
  <badged-input>
150
- <select id="donation-contact-form-countryCodeAlpha2"
151
- @change=${(e) => {
148
+ <select
149
+ id="donation-contact-form-countryCodeAlpha2"
150
+ @change=${(e) => {
152
151
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
153
152
  const currCountry = this.selectedCountry;
154
- this.selectedCountry = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) ? (_b = e.target) === null || _b === void 0 ? void 0 : _b.value : currCountry;
153
+ this.selectedCountry = ((_a = e.target) === null || _a === void 0 ? void 0 : _a.value)
154
+ ? (_b = e.target) === null || _b === void 0 ? void 0 : _b.value
155
+ : currCountry;
155
156
  // update required visual cue on region/state/province & postal code fields
156
157
  if (this.selectedCountry === 'US') {
157
158
  (_c = this.postalBadgedInput) === null || _c === void 0 ? void 0 : _c.setAttribute('required', '');
@@ -165,7 +166,8 @@ let ContactForm = class ContactForm extends LitElement {
165
166
  (_j = this.regionBadgedInput) === null || _j === void 0 ? void 0 : _j.removeAttribute('required');
166
167
  (_k = this.regionField) === null || _k === void 0 ? void 0 : _k.removeAttribute('required');
167
168
  }
168
- }}>
169
+ }}
170
+ >
169
171
  ${Object.keys(countries).map(key => {
170
172
  const name = countries[key];
171
173
  return html `
@@ -1 +1 @@
1
- {"version":3,"file":"contact-form.js","sourceRoot":"","sources":["../../../../src/form-elements/contact-form/contact-form.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EACL,WAAW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AC;mDAAmC;AAEvB;IAAtD,KAAK,CAAC,8CAA8C,CAAC;wDAAmC;AAC9C;IAA1C,KAAK,CAAC,kCAAkC,CAAC;kDAAkC;AAEnB;IAAxD,KAAK,CAAC,gDAAgD,CAAC;sDAAiC;AAC5C;IAA5C,KAAK,CAAC,oCAAoC,CAAC;oDAAoC;AAGhF;IADC,KAAK,CAAC,mDAAmD,CAAC;6DACpB;AACS;IAA/C,KAAK,CAAC,uCAAuC,CAAC;uDAAuC;AAGtF;IADC,KAAK,CAAC,qDAAqD,CAAC;+DACpB;AACS;IAAjD,KAAK,CAAC,yCAAyC,CAAC;yDAAyC;AAEpC;IAArD,KAAK,CAAC,6CAA6C,CAAC;wDAAmC;AAC9C;IAAzC,KAAK,CAAC,iCAAiC,CAAC;kDAAkC;AAEvB;IAAnD,KAAK,CAAC,2CAA2C,CAAC;sDAAiC;AAC5C;IAAvC,KAAK,CAAC,+BAA+B,CAAC;gDAAgC;AAEpB;IAAlD,KAAK,CAAC,0CAA0C,CAAC;2DAA4C;AAE/C;IAA9C,KAAK,CAAC,sCAAsC,CAAC;iDAA+B;AAC9D;IAAd,KAAK,CAAC,MAAM,CAAC;yCAAwB;AAGV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAwB;AAjCxC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAqZvB;SArZY,WAAW","sourcesContent":["import { LitElement, html, css, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport {\n BillingInfo,\n CustomerInfo,\n DonorContactInfo,\n} from '@internetarchive/donation-form-data-models';\nimport { AutoCompleteFieldOptions } from './autocomplete-field-options';\nimport { SpacerOption } from '../badged-input';\nimport { BadgedInput } from '../badged-input';\nimport '../badged-input';\n\nimport emailImg from '@internetarchive/icon-email';\nimport localePinImg from '@internetarchive/icon-locale-pin';\nimport userIcon from '@internetarchive/icon-user';\n\nimport { countries } from './countries';\n\n@customElement('contact-form')\nexport class ContactForm extends LitElement {\n @query('badged-input.donation-contact-form-email') emailBadgedInput!: BadgedInput;\n @query('#donation-contact-form-email') emailField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-first-name') firstNameBadgedInput!: BadgedInput;\n @query('#donation-contact-form-first-name') firstNameField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-last-name') lastNameBadgedInput!: BadgedInput;\n @query('#donation-contact-form-last-name') lastNameField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-postal-code') postalBadgedInput!: BadgedInput;\n @query('#donation-contact-form-postal-code') postalCodeField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-street-address')\n streetAddressBadgedInput!: BadgedInput;\n @query('#donation-contact-form-street-address') streetAddressField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-extended-address')\n extendedAddressBadgedInput!: BadgedInput;\n @query('#donation-contact-form-extended-address') extendedAddressField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-locality') localityBadgedInput!: BadgedInput;\n @query('#donation-contact-form-locality') localityField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-region') regionBadgedInput!: BadgedInput;\n @query('#donation-contact-form-region') regionField!: HTMLInputElement;\n\n @query('#donation-contact-form-countryCodeAlpha2') countryCodeAlpha2Field!: HTMLSelectElement;\n\n @query('#donation-contact-form-error-message') errorMessage!: HTMLDivElement;\n @query('form') form!: HTMLFormElement;\n\n /** @keyof countries */\n @property({ type: String }) selectedCountry = 'US';\n\n reportValidity(): boolean {\n const fieldBadgedInputs: Array<[HTMLInputElement, BadgedInput]> = [\n [this.emailField, this.emailBadgedInput],\n [this.firstNameField, this.firstNameBadgedInput],\n [this.lastNameField, this.lastNameBadgedInput],\n [this.regionField, this.regionBadgedInput],\n [this.localityField, this.localityBadgedInput],\n [this.streetAddressField, this.streetAddressBadgedInput],\n [this.postalCodeField, this.postalBadgedInput],\n ];\n\n let isValid = true;\n fieldBadgedInputs.forEach(([inputElement, badgedInput]) => {\n const fieldValid = inputElement.checkValidity();\n isValid = isValid && fieldValid;\n if (!fieldValid) {\n badgedInput.error = true;\n }\n });\n\n if (!isValid) {\n this.errorMessage.innerText = 'Please enter any missing contact information below';\n } else {\n this.errorMessage.innerText = '';\n }\n\n return isValid;\n }\n\n focus(): void {\n this.emailField.focus();\n }\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div id=\"donation-contact-form-error-message\"></div>\n <form>\n <fieldset>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-email',\n placeholder: 'Email',\n required: true,\n fieldType: 'email',\n name: 'email',\n autocomplete: 'email',\n maxlength: 255,\n icon: emailImg,\n })}\n </div>\n </fieldset>\n\n <fieldset>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-first-name',\n placeholder: 'First name',\n name: 'fname',\n required: true,\n maxlength: 255,\n autocomplete: 'given-name',\n icon: userIcon,\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-last-name',\n placeholder: 'Last name',\n name: 'lname',\n autocomplete: 'family-name',\n required: true,\n maxlength: 255,\n })}\n </div>\n </fieldset>\n <fieldset>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-street-address',\n placeholder: 'Address Line 1',\n required: true,\n autocomplete: 'address-line1',\n icon: localePinImg,\n name: 'street-address',\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-extended-address',\n placeholder: 'Address Line 2 (optional)',\n autocomplete: 'address-line2',\n required: false,\n name: 'extended-address',\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-locality',\n placeholder: 'City',\n autocomplete: 'address-level2',\n required: true,\n name: 'locality',\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-region',\n placeholder: 'State / Province',\n autocomplete: 'address-level1',\n required: true,\n name: 'region',\n })}\n ${this.generateInput({\n id: 'donation-contact-form-postal-code',\n placeholder: 'Zip / Postal',\n autocomplete: 'postal-code',\n required: true,\n name: 'postal',\n maxlength: 9,\n // must start with a character, then may contain spaces\n validationPattern: '[a-zA-Z\\\\-\\\\d]+[a-zA-Z\\\\-\\\\d\\\\s]*',\n iconSpaceOption: SpacerOption.CompressSpace,\n })}\n </div>\n <div class=\"row\">\n ${this.countrySelectorTemplate}\n </div>\n </fieldset>\n </form>\n ${this.getStyles}\n `;\n }\n\n private get countrySelectorTemplate(): TemplateResult {\n return html`\n <badged-input>\n <select id=\"donation-contact-form-countryCodeAlpha2\"\n @change=${(e: Event) => {\n const currCountry = this.selectedCountry;\n this.selectedCountry = (e.target as HTMLInputElement)?.value ? (e.target as HTMLInputElement)?.value as string : currCountry;\n // update required visual cue on region/state/province & postal code fields\n if (this.selectedCountry === 'US') {\n this.postalBadgedInput?.setAttribute('required', '');\n this.postalCodeField?.setAttribute('required', '');\n this.regionBadgedInput?.setAttribute('required', '');\n this.regionField?.setAttribute('required', '');\n } else {\n this.postalBadgedInput?.removeAttribute('required');\n this.postalCodeField?.removeAttribute('required');\n this.regionBadgedInput?.removeAttribute('required');\n this.regionField?.removeAttribute('required');\n }\n }}>\n ${Object.keys(countries).map(key => {\n const name = countries[key];\n return html`\n <option value=${key} ?selected=${key === this.selectedCountry}>${name}</option>\n `;\n })}\n </select>\n </badged-input>\n `;\n }\n\n /** @inheritdoc */\n createRenderRoot(): this {\n // Render template without shadow DOM. Note that shadow DOM features like\n // encapsulated CSS and slots are unavailable.\n // Form autofill does not work properly in the shadow DOM\n // so we need our form fields in the light DOM\n return this;\n }\n\n // reset the error state when the user focuses the input\n private inputFocused(e: KeyboardEvent): void {\n this.errorMessage.innerText = '';\n const input = e.target as HTMLInputElement;\n const inputIdentifier = input.id;\n const badgedInput = this.querySelector(`badged-input.${inputIdentifier}`) as BadgedInput;\n badgedInput.error = false;\n }\n\n private generateInput(options: {\n id: string;\n placeholder: string;\n required?: boolean;\n fieldType?: 'text' | 'email';\n autocomplete?: AutoCompleteFieldOptions;\n maxlength?: number;\n name: string;\n icon?: TemplateResult;\n iconSpaceOption?: SpacerOption;\n validationPattern?: string;\n }): TemplateResult {\n const required = options.required ?? true;\n const fieldType = options.fieldType ?? 'text';\n const iconOption = options.iconSpaceOption ?? SpacerOption.LeaveSpace;\n\n return html`\n <badged-input\n class=${options.id}\n .icon=${options.icon}\n .iconSpaceOption=${iconOption}\n ?required=${options.required}\n >\n <label for=${options.id}>${options.placeholder}</label>\n <input\n type=${fieldType}\n id=${options.id}\n class=\"donation-contact-form-input\"\n name=${options.name}\n aria-label=${options.placeholder}\n placeholder=${options.placeholder}\n maxlength=${ifDefined(options.maxlength)}\n autocomplete=${options.autocomplete ?? 'on'}\n pattern=${ifDefined(options.validationPattern)}\n @focus=${this.inputFocused}\n ?required=${required}\n />\n </badged-input>\n `;\n }\n\n get donorContactInfo(): DonorContactInfo {\n return new DonorContactInfo({\n billing: this.billingInfo,\n customer: this.contactInfo,\n });\n }\n\n get billingInfo(): BillingInfo {\n const billingInfo = new BillingInfo({\n streetAddress: this.streetAddressField.value,\n extendedAddress: this.extendedAddressField.value,\n locality: this.localityField.value,\n region: this.regionField.value,\n postalCode: this.postalCodeField.value,\n countryCodeAlpha2: this.countryCodeAlpha2Field.value,\n });\n return billingInfo;\n }\n\n get contactInfo(): CustomerInfo {\n return new CustomerInfo({\n email: this.emailField.value,\n firstName: this.firstNameField.value,\n lastName: this.lastNameField.value,\n });\n }\n\n /**\n * This is not the normal LitElement styles block.\n *\n * This element uses the clear DOM instead of the shadow DOM so it can't use\n * the shadowRoot's isolated styling. This is a bit of a workaround to keep all of\n * the styling local by writing out our own <style> tag and just be careful about\n * the selectors since they will leak outside of this component.\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof ContactForm\n */\n private get getStyles(): TemplateResult {\n const noIconSpacerWidth = css`var(--badgedInputNoIconSpacerWidth, 3rem)`;\n const iconSpacerWidth = css`var(--badgedInputIconSpacerWidth, 5rem)`;\n\n const fieldSetSpacing = css`var(--fieldSetSpacing, 1rem)`;\n const fieldFontFamily = css`var(--fontFamily, \"Helvetica Neue\", Helvetica, Arial, sans-serif)`;\n const fieldFontSize = css`var(--contactFieldFontSize, 1.6rem)`;\n const fieldFontColor = css`var(--inputFieldFontColor, #333)`;\n\n const iconFieldWidth = css`calc(100% - ${iconSpacerWidth})`;\n const noIconFieldWidth = css`calc(100% - ${noIconSpacerWidth})`;\n\n return html`\n <style>\n /*\n **NOTE**\n This element is in the lightDOM so be sure to prefix all styles\n with \"contact-form\" so styles don't leak.\n */\n contact-form fieldset {\n border: 0;\n padding: 0;\n margin: 0;\n margin-bottom: ${fieldSetSpacing};\n background-color: white;\n }\n\n /* These 1px and 0 margins in the next few selectors are to account for the\n double outlines caused by the fields being right next to each other */\n contact-form .row {\n display: flex;\n margin: -1px 0 0 0;\n }\n\n contact-form fieldset .row:first-child {\n margin-top: 0;\n }\n\n contact-form badged-input.donation-contact-form-region {\n width: 60%;\n }\n\n contact-form badged-input.donation-contact-form-postal-code {\n width: 40%;\n }\n\n contact-form #donation-contact-form-region {\n width: ${iconFieldWidth};\n }\n\n contact-form #donation-contact-form-postal-code {\n width: ${noIconFieldWidth};\n }\n\n contact-form #donation-contact-form-error-message {\n color: red;\n font-size: 1.4rem;\n margin-bottom: 0.6rem;\n }\n\n contact-form #donation-contact-form-last-name {\n width: ${noIconFieldWidth};\n }\n\n /* only show for screen readers */\n contact-form label {\n position: absolute;\n left: -10000px;\n top: auto;\n width: 1px;\n height: 1px;\n overflow: hidden;\n }\n\n contact-form .donation-contact-form-input {\n width: ${iconFieldWidth};\n border: 0;\n outline: 0;\n background: transparent;\n font-weight: bold;\n color: ${fieldFontColor};\n font-size: ${fieldFontSize};\n padding: 0;\n font-family: ${fieldFontFamily};\n }\n\n contact-form .donation-contact-form-input::placeholder {\n color: revert;\n }\n\n contact-form #donation-contact-form-countryCodeAlpha2 {\n width: ${iconFieldWidth};\n height: 100%;\n box-sizing: border-box;\n font-weight: bold;\n font-size: ${fieldFontSize};\n font-family: ${fieldFontFamily};\n border: 0;\n background: #fff;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n }\n </style>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"contact-form.js","sourceRoot":"","sources":["../../../../src/form-elements/contact-form/contact-form.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EACL,WAAW,EACX,YAAY,EACZ,gBAAgB,GACjB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,iBAAiB,CAAC;AAEzB,OAAO,QAAQ,MAAM,sCAAsC,CAAC;AAC5D,OAAO,YAAY,MAAM,2CAA2C,CAAC;AACrE,OAAO,QAAQ,MAAM,qCAAqC,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGjC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAgCL,uBAAuB;QACK,oBAAe,GAAG,IAAI,CAAC;IAsXrD,CAAC;IApXC,cAAc;QACZ,MAAM,iBAAiB,GAA2C;YAChE,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC;YACxC,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,oBAAoB,CAAC;YAChD,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,mBAAmB,CAAC;YAC9C,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC;YAC1C,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,mBAAmB,CAAC;Y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Ad,KAAK,CAAC,MAAM,CAAC;yCAAwB;AAGV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAwB;AAjCxC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAuZvB;SAvZY,WAAW","sourcesContent":["import { LitElement, html, css, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport {\n BillingInfo,\n CustomerInfo,\n DonorContactInfo,\n} from '@internetarchive/donation-form-data-models';\nimport { AutoCompleteFieldOptions } from './autocomplete-field-options';\nimport { SpacerOption } from '../badged-input';\nimport { BadgedInput } from '../badged-input';\nimport '../badged-input';\n\nimport emailImg from '@internetarchive/icon-email/index.js';\nimport localePinImg from '@internetarchive/icon-locale-pin/index.js';\nimport userIcon from '@internetarchive/icon-user/index.js';\n\nimport { countries } from './countries';\n\n@customElement('contact-form')\nexport class ContactForm extends LitElement {\n @query('badged-input.donation-contact-form-email') emailBadgedInput!: BadgedInput;\n @query('#donation-contact-form-email') emailField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-first-name') firstNameBadgedInput!: BadgedInput;\n @query('#donation-contact-form-first-name') firstNameField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-last-name') lastNameBadgedInput!: BadgedInput;\n @query('#donation-contact-form-last-name') lastNameField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-postal-code') postalBadgedInput!: BadgedInput;\n @query('#donation-contact-form-postal-code') postalCodeField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-street-address')\n streetAddressBadgedInput!: BadgedInput;\n @query('#donation-contact-form-street-address') streetAddressField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-extended-address')\n extendedAddressBadgedInput!: BadgedInput;\n @query('#donation-contact-form-extended-address') extendedAddressField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-locality') localityBadgedInput!: BadgedInput;\n @query('#donation-contact-form-locality') localityField!: HTMLInputElement;\n\n @query('badged-input.donation-contact-form-region') regionBadgedInput!: BadgedInput;\n @query('#donation-contact-form-region') regionField!: HTMLInputElement;\n\n @query('#donation-contact-form-countryCodeAlpha2') countryCodeAlpha2Field!: HTMLSelectElement;\n\n @query('#donation-contact-form-error-message') errorMessage!: HTMLDivElement;\n @query('form') form!: HTMLFormElement;\n\n /** @keyof countries */\n @property({ type: String }) selectedCountry = 'US';\n\n reportValidity(): boolean {\n const fieldBadgedInputs: Array<[HTMLInputElement, BadgedInput]> = [\n [this.emailField, this.emailBadgedInput],\n [this.firstNameField, this.firstNameBadgedInput],\n [this.lastNameField, this.lastNameBadgedInput],\n [this.regionField, this.regionBadgedInput],\n [this.localityField, this.localityBadgedInput],\n [this.streetAddressField, this.streetAddressBadgedInput],\n [this.postalCodeField, this.postalBadgedInput],\n ];\n\n let isValid = true;\n fieldBadgedInputs.forEach(([inputElement, badgedInput]) => {\n const fieldValid = inputElement.checkValidity();\n isValid = isValid && fieldValid;\n if (!fieldValid) {\n badgedInput.error = true;\n }\n });\n\n if (!isValid) {\n this.errorMessage.innerText = 'Please enter any missing contact information below';\n } else {\n this.errorMessage.innerText = '';\n }\n\n return isValid;\n }\n\n focus(): void {\n this.emailField.focus();\n }\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div id=\"donation-contact-form-error-message\"></div>\n <form>\n <fieldset>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-email',\n placeholder: 'Email',\n required: true,\n fieldType: 'email',\n name: 'email',\n autocomplete: 'email',\n maxlength: 255,\n icon: emailImg,\n })}\n </div>\n </fieldset>\n\n <fieldset>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-first-name',\n placeholder: 'First name',\n name: 'fname',\n required: true,\n maxlength: 255,\n autocomplete: 'given-name',\n icon: userIcon,\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-last-name',\n placeholder: 'Last name',\n name: 'lname',\n autocomplete: 'family-name',\n required: true,\n maxlength: 255,\n })}\n </div>\n </fieldset>\n <fieldset>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-street-address',\n placeholder: 'Address Line 1',\n required: true,\n autocomplete: 'address-line1',\n icon: localePinImg,\n name: 'street-address',\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-extended-address',\n placeholder: 'Address Line 2 (optional)',\n autocomplete: 'address-line2',\n required: false,\n name: 'extended-address',\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-locality',\n placeholder: 'City',\n autocomplete: 'address-level2',\n required: true,\n name: 'locality',\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-region',\n placeholder: 'State / Province',\n autocomplete: 'address-level1',\n required: true,\n name: 'region',\n })}\n ${this.generateInput({\n id: 'donation-contact-form-postal-code',\n placeholder: 'Zip / Postal',\n autocomplete: 'postal-code',\n required: true,\n name: 'postal',\n maxlength: 9,\n // must start with a character, then may contain spaces\n validationPattern: '[a-zA-Z\\\\-\\\\d]+[a-zA-Z\\\\-\\\\d\\\\s]*',\n iconSpaceOption: SpacerOption.CompressSpace,\n })}\n </div>\n <div class=\"row\">${this.countrySelectorTemplate}</div>\n </fieldset>\n </form>\n ${this.getStyles}\n `;\n }\n\n private get countrySelectorTemplate(): TemplateResult {\n return html`\n <badged-input>\n <select\n id=\"donation-contact-form-countryCodeAlpha2\"\n @change=${(e: Event) => {\n const currCountry = this.selectedCountry;\n this.selectedCountry = (e.target as HTMLInputElement)?.value\n ? ((e.target as HTMLInputElement)?.value as string)\n : currCountry;\n // update required visual cue on region/state/province & postal code fields\n if (this.selectedCountry === 'US') {\n this.postalBadgedInput?.setAttribute('required', '');\n this.postalCodeField?.setAttribute('required', '');\n this.regionBadgedInput?.setAttribute('required', '');\n this.regionField?.setAttribute('required', '');\n } else {\n this.postalBadgedInput?.removeAttribute('required');\n this.postalCodeField?.removeAttribute('required');\n this.regionBadgedInput?.removeAttribute('required');\n this.regionField?.removeAttribute('required');\n }\n }}\n >\n ${Object.keys(countries).map(key => {\n const name = countries[key];\n return html`\n <option value=${key} ?selected=${key === this.selectedCountry}>${name}</option>\n `;\n })}\n </select>\n </badged-input>\n `;\n }\n\n /** @inheritdoc */\n createRenderRoot(): this {\n // Render template without shadow DOM. Note that shadow DOM features like\n // encapsulated CSS and slots are unavailable.\n // Form autofill does not work properly in the shadow DOM\n // so we need our form fields in the light DOM\n return this;\n }\n\n // reset the error state when the user focuses the input\n private inputFocused(e: KeyboardEvent): void {\n this.errorMessage.innerText = '';\n const input = e.target as HTMLInputElement;\n const inputIdentifier = input.id;\n const badgedInput = this.querySelector(`badged-input.${inputIdentifier}`) as BadgedInput;\n badgedInput.error = false;\n }\n\n private generateInput(options: {\n id: string;\n placeholder: string;\n required?: boolean;\n fieldType?: 'text' | 'email';\n autocomplete?: AutoCompleteFieldOptions;\n maxlength?: number;\n name: string;\n icon?: TemplateResult;\n iconSpaceOption?: SpacerOption;\n validationPattern?: string;\n }): TemplateResult {\n const required = options.required ?? true;\n const fieldType = options.fieldType ?? 'text';\n const iconOption = options.iconSpaceOption ?? SpacerOption.LeaveSpace;\n\n return html`\n <badged-input\n class=${options.id}\n .icon=${options.icon}\n .iconSpaceOption=${iconOption}\n ?required=${options.required}\n >\n <label for=${options.id}>${options.placeholder}</label>\n <input\n type=${fieldType}\n id=${options.id}\n class=\"donation-contact-form-input\"\n name=${options.name}\n aria-label=${options.placeholder}\n placeholder=${options.placeholder}\n maxlength=${ifDefined(options.maxlength)}\n autocomplete=${options.autocomplete ?? 'on'}\n pattern=${ifDefined(options.validationPattern)}\n @focus=${this.inputFocused}\n ?required=${required}\n />\n </badged-input>\n `;\n }\n\n get donorContactInfo(): DonorContactInfo {\n return new DonorContactInfo({\n billing: this.billingInfo,\n customer: this.contactInfo,\n });\n }\n\n get billingInfo(): BillingInfo {\n const billingInfo = new BillingInfo({\n streetAddress: this.streetAddressField.value,\n extendedAddress: this.extendedAddressField.value,\n locality: this.localityField.value,\n region: this.regionField.value,\n postalCode: this.postalCodeField.value,\n countryCodeAlpha2: this.countryCodeAlpha2Field.value,\n });\n return billingInfo;\n }\n\n get contactInfo(): CustomerInfo {\n return new CustomerInfo({\n email: this.emailField.value,\n firstName: this.firstNameField.value,\n lastName: this.lastNameField.value,\n });\n }\n\n /**\n * This is not the normal LitElement styles block.\n *\n * This element uses the clear DOM instead of the shadow DOM so it can't use\n * the shadowRoot's isolated styling. This is a bit of a workaround to keep all of\n * the styling local by writing out our own <style> tag and just be careful about\n * the selectors since they will leak outside of this component.\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof ContactForm\n */\n private get getStyles(): TemplateResult {\n const noIconSpacerWidth = css`var(--badgedInputNoIconSpacerWidth, 3rem)`;\n const iconSpacerWidth = css`var(--badgedInputIconSpacerWidth, 5rem)`;\n\n const fieldSetSpacing = css`var(--fieldSetSpacing, 1rem)`;\n const fieldFontFamily = css`var(--fontFamily, \"Helvetica Neue\", Helvetica, Arial, sans-serif)`;\n const fieldFontSize = css`var(--contactFieldFontSize, 1.6rem)`;\n const fieldFontColor = css`var(--inputFieldFontColor, #333)`;\n\n const iconFieldWidth = css`calc(100% - ${iconSpacerWidth})`;\n const noIconFieldWidth = css`calc(100% - ${noIconSpacerWidth})`;\n\n return html`\n <style>\n /*\n **NOTE**\n This element is in the lightDOM so be sure to prefix all styles\n with \"contact-form\" so styles don't leak.\n */\n contact-form fieldset {\n border: 0;\n padding: 0;\n margin: 0;\n margin-bottom: ${fieldSetSpacing};\n background-color: white;\n }\n\n /* These 1px and 0 margins in the next few selectors are to account for the\n double outlines caused by the fields being right next to each other */\n contact-form .row {\n display: flex;\n margin: -1px 0 0 0;\n }\n\n contact-form fieldset .row:first-child {\n margin-top: 0;\n }\n\n contact-form badged-input.donation-contact-form-region {\n width: 60%;\n }\n\n contact-form badged-input.donation-contact-form-postal-code {\n width: 40%;\n }\n\n contact-form #donation-contact-form-region {\n width: ${iconFieldWidth};\n }\n\n contact-form #donation-contact-form-postal-code {\n width: ${noIconFieldWidth};\n }\n\n contact-form #donation-contact-form-error-message {\n color: red;\n font-size: 1.4rem;\n margin-bottom: 0.6rem;\n }\n\n contact-form #donation-contact-form-last-name {\n width: ${noIconFieldWidth};\n }\n\n /* only show for screen readers */\n contact-form label {\n position: absolute;\n left: -10000px;\n top: auto;\n width: 1px;\n height: 1px;\n overflow: hidden;\n }\n\n contact-form .donation-contact-form-input {\n width: ${iconFieldWidth};\n border: 0;\n outline: 0;\n background: transparent;\n font-weight: bold;\n color: ${fieldFontColor};\n font-size: ${fieldFontSize};\n padding: 0;\n font-family: ${fieldFontFamily};\n }\n\n contact-form .donation-contact-form-input::placeholder {\n color: revert;\n }\n\n contact-form #donation-contact-form-countryCodeAlpha2 {\n width: ${iconFieldWidth};\n height: 100%;\n box-sizing: border-box;\n font-weight: bold;\n font-size: ${fieldFontSize};\n font-family: ${fieldFontFamily};\n border: 0;\n background: #fff;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n }\n </style>\n `;\n }\n}\n"]}
@@ -19,9 +19,7 @@ let DonationFormHeader = class DonationFormHeader extends LitElement {
19
19
  }
20
20
  /** @inheritdoc */
21
21
  render() {
22
- return html `
23
- ${this.currentTemplate}
24
- `;
22
+ return html ` ${this.currentTemplate} `;
25
23
  }
26
24
  get currentTemplate() {
27
25
  switch (this.mode) {
@@ -1 +1 @@
1
- {"version":3,"file":"donation-form-header.js","sourceRoot":"","sources":["../../../../src/form-elements/header/donation-form-header.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EACL,sBAAsB,GAEvB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,8CAA8C,CAAC;AACtD,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from 'lit/decorators.js';\n\nimport {\n defaultDonationAmounts,\n DonationPaymentInfo,\n} from '@internetarchive/donation-form-data-models';\n\nimport '@internetarchive/donation-form-edit-donation';\nimport {\n DonationFormEditDonation,\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nexport enum DonationFormHeaderMode {\n Summary = 'summary',\n Edit = 'edit',\n}\n\n@customElement('donation-form-header')\nexport class DonationFormHeader extends LitElement {\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n @property({ type: String }) mode: DonationFormHeaderMode = DonationFormHeaderMode.Edit;\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @query('edit-donation') editDonation?: DonationFormEditDonation;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n ${this.currentTemplate}\n `;\n }\n\n private get currentTemplate(): TemplateResult {\n switch (this.mode) {\n case DonationFormHeaderMode.Summary:\n return this.donationSummaryTemplate;\n case DonationFormHeaderMode.Edit:\n return this.editDonationTemplate;\n }\n }\n\n private get editDonationTemplate(): TemplateResult {\n return html`\n <donation-form-edit-donation\n .donationInfo=${this.donationInfo}\n .amountOptions=${this.amountOptions}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @showSummaryClicked=${this.showSummaryClicked}\n @editDonationError=${this.editDonationError}\n >\n </donation-form-edit-donation>\n `;\n }\n\n private get donationSummaryTemplate(): TemplateResult {\n return html`\n <donation-summary .donationInfo=${this.donationInfo} @editClicked=${this.summaryEditClicked}>\n </donation-summary>\n `;\n }\n\n private donationInfoChanged(e: CustomEvent): void {\n this.donationInfo = e.detail.donationInfo as DonationPaymentInfo;\n const event = new CustomEvent('donationInfoChanged', {\n detail: { donationInfo: this.donationInfo },\n });\n this.dispatchEvent(event);\n }\n\n private editDonationError(e: CustomEvent): void {\n const event = new CustomEvent('editDonationError', { detail: e.detail });\n this.dispatchEvent(event);\n }\n\n private summaryEditClicked(): void {\n this.mode = DonationFormHeaderMode.Edit;\n }\n\n private showSummaryClicked(): void {\n this.mode = DonationFormHeaderMode.Summary;\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n return css``;\n }\n}\n"]}
1
+ {"version":3,"file":"donation-form-header.js","sourceRoot":"","sources":["../../../../src/form-elements/header/donation-form-header.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EACL,sBAAsB,GAEvB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,8CAA8C,CAAC;AACtD,OAAO,EAEL,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,8CAA8C,CAAC;AAEtD,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,6CAAmB,CAAA;IACnB,uCAAa,CAAA;AACf,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC;AAGM,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAA3C;;QAGuB,SAAI,GAA2B,sBAAsB,CAAC,IAAI,CAAC;QAE5D,kBAAa,GAAa,sBAAsB,CAAC;QAEhD,0BAAqB,GAC/C,iCAAiC,CAAC,SAAS,CAAC;QAElB,2BAAsB,GAChD,kCAAkC,CAAC,MAAM,CAAC;IAiE9C,CAAC;IA7DC,kBAAkB;IAClB,MAAM;QACJ,OAAO,IAAI,CAAA,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC;IACzC,CAAC;IAED,IAAY,eAAe;QACzB,QA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;IAED,kBAAkB;IAClB,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA,EAAE,CAAC;IACf,CAAC;CACF,CAAA;AA3E6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAoC;AAEnC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA4D;AAE5D;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yDAAkD;AAEhD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEACmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEACiB;AAEpB;IAAvB,KAAK,CAAC,eAAe,CAAC;wDAAyC;AAbrD,kBAAkB;IAD9B,aAAa,CAAC,sBAAsB,CAAC;GACzB,kBAAkB,CA4E9B;SA5EY,kBAAkB","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport {\n defaultDonationAmounts,\n DonationPaymentInfo,\n} from '@internetarchive/donation-form-data-models';\n\nimport '@internetarchive/donation-form-edit-donation';\nimport {\n DonationFormEditDonation,\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nexport enum DonationFormHeaderMode {\n Summary = 'summary',\n Edit = 'edit',\n}\n\n@customElement('donation-form-header')\nexport class DonationFormHeader extends LitElement {\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n @property({ type: String }) mode: DonationFormHeaderMode = DonationFormHeaderMode.Edit;\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @query('edit-donation') editDonation?: DonationFormEditDonation;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html` ${this.currentTemplate} `;\n }\n\n private get currentTemplate(): TemplateResult {\n switch (this.mode) {\n case DonationFormHeaderMode.Summary:\n return this.donationSummaryTemplate;\n case DonationFormHeaderMode.Edit:\n return this.editDonationTemplate;\n }\n }\n\n private get editDonationTemplate(): TemplateResult {\n return html`\n <donation-form-edit-donation\n .donationInfo=${this.donationInfo}\n .amountOptions=${this.amountOptions}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @showSummaryClicked=${this.showSummaryClicked}\n @editDonationError=${this.editDonationError}\n >\n </donation-form-edit-donation>\n `;\n }\n\n private get donationSummaryTemplate(): TemplateResult {\n return html`\n <donation-summary .donationInfo=${this.donationInfo} @editClicked=${this.summaryEditClicked}>\n </donation-summary>\n `;\n }\n\n private donationInfoChanged(e: CustomEvent): void {\n this.donationInfo = e.detail.donationInfo as DonationPaymentInfo;\n const event = new CustomEvent('donationInfoChanged', {\n detail: { donationInfo: this.donationInfo },\n });\n this.dispatchEvent(event);\n }\n\n private editDonationError(e: CustomEvent): void {\n const event = new CustomEvent('editDonationError', { detail: e.detail });\n this.dispatchEvent(event);\n }\n\n private summaryEditClicked(): void {\n this.mode = DonationFormHeaderMode.Edit;\n }\n\n private showSummaryClicked(): void {\n this.mode = DonationFormHeaderMode.Summary;\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n return css``;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"donation-summary.js","sourceRoot":"","sources":["../../../../src/form-elements/header/donation-summary.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,QAAQ,MAAM,a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SApDY,eAAe","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport currency from 'currency.js';\n\nimport { DonationType, DonationPaymentInfo } from '@internetarchive/donation-form-data-models';\n\n@customElement('donation-summary')\nexport class DonationSummary extends LitElement {\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <h1>${this.displayTitle}</h1>\n <button @click=${this.editClicked}>Edit this amount</button>\n `;\n }\n\n get displayTitle(): string {\n if (!this.donationInfo) {\n return '';\n }\n\n const monthlyString = this.donationInfo.donationType === DonationType.Monthly ? 'Monthly' : '';\n const amount = this.donationInfo.amount;\n let precision = 2;\n // whole number, don't use decimals\n if (amount === Math.round(amount)) {\n precision = 0;\n }\n\n const displayAmount = currency(this.donationInfo.amount, {\n symbol: '$',\n precision: precision,\n }).format();\n\n return `${displayAmount} ${monthlyString} Donation`;\n }\n\n private editClicked(): void {\n this.dispatchEvent(new Event('editClicked'));\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n return css`\n :host {\n display: flex;\n justify-content: center;\n align-content: center;\n }\n\n button {\n border: 0;\n background: none;\n color: blue;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"donation-summary.js","sourceRoot":"","sources":["../../../../src/form-elements/header/donation-summary.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAuB,MAAM,4CAA4C,CAAC;AAGxF,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAG7C,kBAAkB;IAClB,MAAM;QACJ,OAAO,IAAI,CAAA;YACH,IAAI,CAAC,YAAY;uBACN,IAAI,CAAC,WAAW;KAClC,CAAC;IACJ,CAAC;IAED,IAAI,YAAY;QACd,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,OAAO,EAAE,CAAC;SACX;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/F,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QACxC,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,mCAAmC;QACnC,IAAI,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;YACjC,SAAS,GAAG,CAAC,CAAC;SACf;QAED,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YACvD,MAAM,EAAE,GAAG;YACX,SAAS,EAAE,SAAS;SACrB,CAAC,CAAC,MAAM,EAAE,CAAC;QAEZ,OAAO,GAAG,aAAa,IAAI,aAAa,WAAW,CAAC;IACtD,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,kBAAkB;IAClB,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;KAYT,CAAC;IACJ,CAAC;CACF,CAAA;AAnD6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAoC;AADpD,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAoD3B;SApDY,eAAe","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport currency from 'currency.js';\n\nimport { DonationType, DonationPaymentInfo } from '@internetarchive/donation-form-data-models';\n\n@customElement('donation-summary')\nexport class DonationSummary extends LitElement {\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <h1>${this.displayTitle}</h1>\n <button @click=${this.editClicked}>Edit this amount</button>\n `;\n }\n\n get displayTitle(): string {\n if (!this.donationInfo) {\n return '';\n }\n\n const monthlyString = this.donationInfo.donationType === DonationType.Monthly ? 'Monthly' : '';\n const amount = this.donationInfo.amount;\n let precision = 2;\n // whole number, don't use decimals\n if (amount === Math.round(amount)) {\n precision = 0;\n }\n\n const displayAmount = currency(this.donationInfo.amount, {\n symbol: '$',\n precision: precision,\n }).format();\n\n return `${displayAmount} ${monthlyString} Donation`;\n }\n\n private editClicked(): void {\n this.dispatchEvent(new Event('editClicked'));\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n return css`\n :host {\n display: flex;\n justify-content: center;\n align-content: center;\n }\n\n button {\n border: 0;\n background: none;\n color: blue;\n }\n `;\n }\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import { __awaiter, __decorate } from "tslib";
2
2
  import { LitElement, html, css } from 'lit';
3
3
  import { customElement, property } from 'lit/decorators.js';
4
- import applePayButtonImage from '@internetarchive/icon-applepay';
5
- import googlePayButtonImage from '@internetarchive/icon-googlepay';
6
- import paypalButtonImage from '@internetarchive/icon-paypal';
7
- import venmoButtonImage from '@internetarchive/icon-venmo';
4
+ import applePayButtonImage from '@internetarchive/icon-applepay/index.js';
5
+ import googlePayButtonImage from '@internetarchive/icon-googlepay/index.js';
6
+ import paypalButtonImage from '@internetarchive/icon-paypal/index.js';
7
+ import venmoButtonImage from '@internetarchive/icon-venmo/index.js';
8
8
  var PaymentButtonMode;
9
9
  (function (PaymentButtonMode) {
10
10
  PaymentButtonMode["Loading"] = "loading";
@@ -1 +1 @@
1
- {"version":3,"file":"payment-selector.js","sourceRoot":"","sources":["../../../src/form-elements/payment-selector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6C,MAAM,KAAK,CAAC;AACvF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B;kBACpB,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgCnB,qBAAqB;;;;KAIrC,CAAC;IACJ,CAAC;CACF,CAAA;AAnR8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DAA0B;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAqE;AAEpE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAsE;AAErE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAkE;AAEjE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAmE;AAXnF,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAoR3B;SApRY,eAAe","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport applePayButtonImage from '@internetarchive/icon-applepay';\nimport googlePayButtonImage from '@internetarchive/icon-googlepay';\nimport paypalButtonImage from '@internetarchive/icon-paypal';\nimport venmoButtonImage from '@internetarchive/icon-venmo';\nimport { PaymentProvidersInterface } from '../braintree-manager/payment-providers-interface';\n\nenum PaymentButtonMode {\n Loading = 'loading',\n Available = 'available',\n Unavailable = 'unavailable',\n}\n\n@customElement('payment-selector')\nexport class PaymentSelector extends LitElement {\n @property({ type: Boolean }) donationInfoValid = true;\n\n @property({ type: Object }) paymentProviders?: PaymentProvidersInterface;\n\n @property({ type: String }) private applePayMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private googlePayMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private venmoMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private payPalMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div\n class=\"payment-container ${this.donationInfoValid\n ? 'donation-info-valid'\n : 'donation-info-invalid'}\n \"\n >\n <div class=\"payment-provider-container\">\n <button\n class=\"applepay provider-button ${this.applePayMode}\"\n @click=${this.applePaySelected}\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${applePayButtonImage}</div>\n </button>\n\n <button\n class=\"googlepay provider-button ${this.googlePayMode}\"\n @click=${this.googlePaySelected}\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${googlePayButtonImage}</div>\n </button>\n\n <button\n class=\"venmo provider-button ${this.venmoMode}\"\n @click=${this.venmoSelected}\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${venmoButtonImage}</div>\n </button>\n\n <div class=\"paypal-container provider-button ${this.payPalMode}\" tabindex=\"0\">\n <div class=\"payment-image\">\n <div class=\"paypal-local-button\" @click=${this.localPaypalButtonClicked}>\n ${paypalButtonImage}\n </div>\n <slot name=\"paypal-button\"></slot>\n </div>\n </div>\n </div>\n\n <div class=\"credit-card-container\">\n <button\n @click=${this.creditCardSelected}\n class=\"button-style credit-card-button\"\n tabindex=\"0\"\n >\n <div class=\"cc-title\">Credit Card</div>\n <div class=\"cc-background\"></div>\n </button>\n </div>\n </div>\n `;\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.dispatchEvent(new Event('firstUpdated'));\n }\n\n /** @inheritdoc */\n updated(changed: PropertyValues): void {\n if (changed.has('paymentProviders')) {\n this.setButtonVisibility();\n }\n }\n\n showPaypalButton(): void {\n this.payPalMode = PaymentButtonMode.Available;\n }\n\n private async setButtonVisibility(): Promise<void> {\n this.paymentProviders?.venmoHandler\n .get()\n .then(handler => {\n if (!handler) {\n this.venmoMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isBrowserSupported()\n .then(supported => {\n this.venmoMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading venmo', reason);\n this.venmoMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('venmo unavailable', reason);\n this.venmoMode = PaymentButtonMode.Unavailable;\n });\n\n this.paymentProviders?.applePayHandler\n .get()\n .then(handler => {\n if (!handler) {\n console.error('applePayHandler unavailable');\n this.applePayMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isAvailable()\n .then(supported => {\n this.applePayMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading applepay', reason);\n this.applePayMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('apple pay unavailable', reason);\n this.applePayMode = PaymentButtonMode.Unavailable;\n });\n\n this.paymentProviders?.googlePayHandler\n .get()\n .then(handler => {\n if (!handler) {\n console.error('google pay handler unavailable');\n this.googlePayMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isBrowserSupported()\n .then(supported => {\n this.googlePayMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading googlepay', reason);\n this.googlePayMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('google pay unavailable', reason);\n this.googlePayMode = PaymentButtonMode.Unavailable;\n });\n }\n\n private googlePaySelected(): void {\n this.dispatchEvent(new Event('googlePaySelected'));\n }\n\n private applePaySelected(e: Event): void {\n const event = new CustomEvent('applePaySelected', { detail: { originalEvent: e } });\n this.dispatchEvent(event);\n }\n\n private venmoSelected(): void {\n this.dispatchEvent(new Event('venmoSelected'));\n }\n\n private creditCardSelected(): void {\n this.dispatchEvent(new Event('creditCardSelected'));\n }\n\n private localPaypalButtonClicked(): void {\n this.dispatchEvent(new Event('paypalBlockerSelected'));\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const paymentButtonWidthCss = css`var(--paymentButtonWidth, 5rem)`;\n const paymentButtonHeightCss = css`var(--paymentButtonHeight, 3.2rem)`;\n const creditCardFontSizeCss = css`var(--creditCardFontSize, 1.8rem)`;\n\n return css`\n button {\n color: inherit;\n font-family: inherit;\n }\n\n .payment-container {\n width: 100%;\n }\n\n .payment-provider-container {\n display: grid;\n grid-template-columns: 1fr 1fr 1fr 1fr;\n grid-gap: 1rem;\n margin-bottom: 1rem;\n max-width: 23rem;\n }\n\n .provider-button {\n border: 0;\n padding: 0;\n background: none;\n cursor: pointer;\n width: ${paymentButtonWidthCss};\n height: ${paymentButtonHeightCss};\n }\n\n .provider-button.unavailable {\n display: none;\n }\n\n .provider-button.loading {\n border: 1px solid #ddd;\n border-radius: 2px;\n /* account for the borders that don't exist once the provider loads, otherwise the layout shifts */\n margin-bottom: -2px;\n }\n\n .provider-button.loading .payment-image {\n display: none;\n }\n\n .paypal-local-button {\n position: absolute;\n width: ${paymentButtonWidthCss};\n height: ${paymentButtonHeightCss};\n }\n\n .donation-info-valid .paypal-local-button {\n z-index: 0;\n }\n\n .donation-info-invalid .paypal-local-button {\n z-index: 250;\n }\n\n .credit-card-button {\n color: var(--ccButtonFontColor, #333);\n background-color: var(--ccButtonColor, white);\n border: 1px solid #333;\n border-radius: 4px;\n cursor: pointer;\n margin: 0;\n padding: 0.7rem 1rem;\n width: 100%;\n }\n\n .credit-card-button .cc-background {\n height: 2.4rem;\n width: 100%;\n background-repeat: no-repeat;\n background-image: url(https://archive.org/images/cc_logos.png);\n background-position: 50% 50%;\n background-size: contain;\n }\n\n .credit-card-button .cc-title {\n font-size: ${creditCardFontSizeCss};\n font-weight: 700;\n margin-bottom: 0.5rem;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"payment-selector.js","sourceRoot":"","sources":["../../../src/form-elements/payment-selector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6C,MAAM,KAAK,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MA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;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgCnB,qBAAqB;;;;KAIrC,CAAC;IACJ,CAAC;CACF,CAAA;AAnR8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DAA0B;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAqE;AAEpE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAsE;AAErE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAkE;AAEjE;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAmE;AAXnF,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAoR3B;SApRY,eAAe","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport applePayButtonImage from '@internetarchive/icon-applepay/index.js';\nimport googlePayButtonImage from '@internetarchive/icon-googlepay/index.js';\nimport paypalButtonImage from '@internetarchive/icon-paypal/index.js';\nimport venmoButtonImage from '@internetarchive/icon-venmo/index.js';\nimport { PaymentProvidersInterface } from '../braintree-manager/payment-providers-interface';\n\nenum PaymentButtonMode {\n Loading = 'loading',\n Available = 'available',\n Unavailable = 'unavailable',\n}\n\n@customElement('payment-selector')\nexport class PaymentSelector extends LitElement {\n @property({ type: Boolean }) donationInfoValid = true;\n\n @property({ type: Object }) paymentProviders?: PaymentProvidersInterface;\n\n @property({ type: String }) private applePayMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private googlePayMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private venmoMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n @property({ type: String }) private payPalMode: PaymentButtonMode = PaymentButtonMode.Loading;\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div\n class=\"payment-container ${this.donationInfoValid\n ? 'donation-info-valid'\n : 'donation-info-invalid'}\n \"\n >\n <div class=\"payment-provider-container\">\n <button\n class=\"applepay provider-button ${this.applePayMode}\"\n @click=${this.applePaySelected}\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${applePayButtonImage}</div>\n </button>\n\n <button\n class=\"googlepay provider-button ${this.googlePayMode}\"\n @click=${this.googlePaySelected}\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${googlePayButtonImage}</div>\n </button>\n\n <button\n class=\"venmo provider-button ${this.venmoMode}\"\n @click=${this.venmoSelected}\n tabindex=\"0\"\n >\n <div class=\"payment-image\">${venmoButtonImage}</div>\n </button>\n\n <div class=\"paypal-container provider-button ${this.payPalMode}\" tabindex=\"0\">\n <div class=\"payment-image\">\n <div class=\"paypal-local-button\" @click=${this.localPaypalButtonClicked}>\n ${paypalButtonImage}\n </div>\n <slot name=\"paypal-button\"></slot>\n </div>\n </div>\n </div>\n\n <div class=\"credit-card-container\">\n <button\n @click=${this.creditCardSelected}\n class=\"button-style credit-card-button\"\n tabindex=\"0\"\n >\n <div class=\"cc-title\">Credit Card</div>\n <div class=\"cc-background\"></div>\n </button>\n </div>\n </div>\n `;\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.dispatchEvent(new Event('firstUpdated'));\n }\n\n /** @inheritdoc */\n updated(changed: PropertyValues): void {\n if (changed.has('paymentProviders')) {\n this.setButtonVisibility();\n }\n }\n\n showPaypalButton(): void {\n this.payPalMode = PaymentButtonMode.Available;\n }\n\n private async setButtonVisibility(): Promise<void> {\n this.paymentProviders?.venmoHandler\n .get()\n .then(handler => {\n if (!handler) {\n this.venmoMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isBrowserSupported()\n .then(supported => {\n this.venmoMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading venmo', reason);\n this.venmoMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('venmo unavailable', reason);\n this.venmoMode = PaymentButtonMode.Unavailable;\n });\n\n this.paymentProviders?.applePayHandler\n .get()\n .then(handler => {\n if (!handler) {\n console.error('applePayHandler unavailable');\n this.applePayMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isAvailable()\n .then(supported => {\n this.applePayMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading applepay', reason);\n this.applePayMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('apple pay unavailable', reason);\n this.applePayMode = PaymentButtonMode.Unavailable;\n });\n\n this.paymentProviders?.googlePayHandler\n .get()\n .then(handler => {\n if (!handler) {\n console.error('google pay handler unavailable');\n this.googlePayMode = PaymentButtonMode.Unavailable;\n return;\n }\n\n handler\n .isBrowserSupported()\n .then(supported => {\n this.googlePayMode = supported\n ? PaymentButtonMode.Available\n : PaymentButtonMode.Unavailable;\n })\n .catch(reason => {\n console.error('error loading googlepay', reason);\n this.googlePayMode = PaymentButtonMode.Unavailable;\n });\n })\n .catch(reason => {\n console.error('google pay unavailable', reason);\n this.googlePayMode = PaymentButtonMode.Unavailable;\n });\n }\n\n private googlePaySelected(): void {\n this.dispatchEvent(new Event('googlePaySelected'));\n }\n\n private applePaySelected(e: Event): void {\n const event = new CustomEvent('applePaySelected', { detail: { originalEvent: e } });\n this.dispatchEvent(event);\n }\n\n private venmoSelected(): void {\n this.dispatchEvent(new Event('venmoSelected'));\n }\n\n private creditCardSelected(): void {\n this.dispatchEvent(new Event('creditCardSelected'));\n }\n\n private localPaypalButtonClicked(): void {\n this.dispatchEvent(new Event('paypalBlockerSelected'));\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const paymentButtonWidthCss = css`var(--paymentButtonWidth, 5rem)`;\n const paymentButtonHeightCss = css`var(--paymentButtonHeight, 3.2rem)`;\n const creditCardFontSizeCss = css`var(--creditCardFontSize, 1.8rem)`;\n\n return css`\n button {\n color: inherit;\n font-family: inherit;\n }\n\n .payment-container {\n width: 100%;\n }\n\n .payment-provider-container {\n display: grid;\n grid-template-columns: 1fr 1fr 1fr 1fr;\n grid-gap: 1rem;\n margin-bottom: 1rem;\n max-width: 23rem;\n }\n\n .provider-button {\n border: 0;\n padding: 0;\n background: none;\n cursor: pointer;\n width: ${paymentButtonWidthCss};\n height: ${paymentButtonHeightCss};\n }\n\n .provider-button.unavailable {\n display: none;\n }\n\n .provider-button.loading {\n border: 1px solid #ddd;\n border-radius: 2px;\n /* account for the borders that don't exist once the provider loads, otherwise the layout shifts */\n margin-bottom: -2px;\n }\n\n .provider-button.loading .payment-image {\n display: none;\n }\n\n .paypal-local-button {\n position: absolute;\n width: ${paymentButtonWidthCss};\n height: ${paymentButtonHeightCss};\n }\n\n .donation-info-valid .paypal-local-button {\n z-index: 0;\n }\n\n .donation-info-invalid .paypal-local-button {\n z-index: 250;\n }\n\n .credit-card-button {\n color: var(--ccButtonFontColor, #333);\n background-color: var(--ccButtonColor, white);\n border: 1px solid #333;\n border-radius: 4px;\n cursor: pointer;\n margin: 0;\n padding: 0.7rem 1rem;\n width: 100%;\n }\n\n .credit-card-button .cc-background {\n height: 2.4rem;\n width: 100%;\n background-repeat: no-repeat;\n background-image: url(https://archive.org/images/cc_logos.png);\n background-position: 50% 50%;\n background-size: contain;\n }\n\n .credit-card-button .cc-title {\n font-size: ${creditCardFontSizeCss};\n font-weight: 700;\n margin-bottom: 0.5rem;\n }\n `;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"total-amount.js","sourceRoot":"","sources":["../../../src/form-elements/total-amount.ts"],"names":[],"mappings":";AAAA,OAAO,EAAuB,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,GAAG,EAAa,IAAI,EAAE,UAAU,EAAkB,MAAM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Element, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport currency from 'currency.js';\n\n@customElement('donation-form-total-amount')\nexport class TotalAmount extends LitElement {\n @property({ type: Object })\n donationInfo?: DonationPaymentInfo;\n\n render(): TemplateResult {\n return html`\n <div class=\"top-line\"></div>\n <div class=\"total-line\">Total: ${this.totalAmount}</div>\n `;\n }\n\n private get totalAmount(): string | undefined {\n if (!this.donationInfo) return;\n const amount = currency(this.donationInfo.total, { symbol: '$' }).format();\n const monthly = this.donationInfo.donationType === DonationType.Monthly ? '/month' : '';\n return `${amount}${monthly}`;\n }\n\n static get styles(): CSSResult {\n const lineColor = css`var(--totalAmountLineColor, #333)`;\n const lineThickness = css`var(--totalAmountLineThickness, 2px)`;\n const totalAmountVerticalSpacing = css`var(--totalAmountVerticalSpacing, 0.5rem)`;\n const totalAmountFontSize = css`var(--totalAmountFontSize, 2.6rem)`;\n\n return css`\n .top-line {\n width: 100%;\n height: ${lineThickness};\n background-color: ${lineColor};\n }\n\n .total-line {\n font-size: ${totalAmountFontSize};\n font-weight: bold;\n text-align: center;\n margin-top: ${totalAmountVerticalSpacing};\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"total-amount.js","sourceRoot":"","sources":["../../../src/form-elements/total-amount.ts"],"names":[],"mappings":";AAAA,OAAO,EAAuB,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,GAAG,EAAa,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,QAAQ,MAAM,aAAa,CAAC;AAG5B,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAIzC,MAAM;QACJ,OAAO,IAAI,CAAA;;uCAEwB,IAAI,CAAC,WAAW;KAClD,CAAC;IACJ,CAAC;IAED,IAAY,WAAW;QACrB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,OAAO;QAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACxF,OAAO,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,KAAK,MAAM;QACf,MAAM,SAAS,GAAG,GAAG,CAAA,mCAAmC,CAAC;QACzD,MAAM,aAAa,GAAG,GAAG,CAAA,sCAAsC,CAAC;QAChE,MAAM,0BAA0B,GAAG,GAAG,CAAA,2CAA2C,CAAC;QAClF,MAAM,mBAAmB,GAAG,GAAG,CAAA,oCAAoC,CAAC;QAEpE,OAAO,GAAG,CAAA;;;kBAGI,aAAa;4BACH,SAAS;;;;qBAIhB,mBAAmB;;;sBAGlB,0BAA0B;;KAE3C,CAAC;IACJ,CAAC;CACF,CAAA;AArCC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACQ;AAFxB,WAAW;IADvB,aAAa,CAAC,4BAA4B,CAAC;GAC/B,WAAW,CAuCvB;SAvCY,WAAW","sourcesContent":["import { DonationPaymentInfo, DonationType } from '@internetarchive/donation-form-data-models';\nimport { css, CSSResult, html, LitElement, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport currency from 'currency.js';\n\n@customElement('donation-form-total-amount')\nexport class TotalAmount extends LitElement {\n @property({ type: Object })\n donationInfo?: DonationPaymentInfo;\n\n render(): TemplateResult {\n return html`\n <div class=\"top-line\"></div>\n <div class=\"total-line\">Total: ${this.totalAmount}</div>\n `;\n }\n\n private get totalAmount(): string | undefined {\n if (!this.donationInfo) return;\n const amount = currency(this.donationInfo.total, { symbol: '$' }).format();\n const monthly = this.donationInfo.donationType === DonationType.Monthly ? '/month' : '';\n return `${amount}${monthly}`;\n }\n\n static get styles(): CSSResult {\n const lineColor = css`var(--totalAmountLineColor, #333)`;\n const lineThickness = css`var(--totalAmountLineThickness, 2px)`;\n const totalAmountVerticalSpacing = css`var(--totalAmountVerticalSpacing, 0.5rem)`;\n const totalAmountFontSize = css`var(--totalAmountFontSize, 2.6rem)`;\n\n return css`\n .top-line {\n width: 100%;\n height: ${lineThickness};\n background-color: ${lineColor};\n }\n\n .total-line {\n font-size: ${totalAmountFontSize};\n font-weight: bold;\n text-align: center;\n margin-top: ${totalAmountVerticalSpacing};\n }\n `;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  /* eslint-disable @typescript-eslint/no-empty-function */
3
+ /* eslint-disable @typescript-eslint/ban-types */
3
4
  import { LitElement, html, css } from 'lit';
4
5
  import { customElement, property } from 'lit/decorators.js';
5
6
  import { DonationType } from '@internetarchive/donation-form-data-models';
@@ -26,12 +27,19 @@ let ConfirmDonationContent = class ConfirmDonationContent extends LitElement {
26
27
  get confirmationText() {
27
28
  const amount = currency(this.amount, { symbol: this.currencySymbol }).format();
28
29
  return html `
29
- <p>You are about to make a <b>${this.donationType}</b> donation of <b>${amount} ${this.currencyType}</b> to the Internet Archive.</p>
30
+ <p>
31
+ You are about to make a <b>${this.donationType}</b> donation of
32
+ <b>${amount} ${this.currencyType}</b> to the Internet Archive.
33
+ </p>
30
34
  `;
31
35
  }
32
36
  get confirmUpsellText() {
33
37
  const amount = currency(this.amount, { symbol: this.currencySymbol }).format();
34
- return html `<p>You are about to begin making <b>monthly</b> donations of <b>${amount} ${this.currencyType}</b> to the Internet Archive. (Your first recurring contribution will be next month.)</p>`;
38
+ return html `<p>
39
+ You are about to begin making <b>monthly</b> donations of
40
+ <b>${amount} ${this.currencyType}</b> to the Internet Archive. (Your first recurring
41
+ contribution will be next month.)
42
+ </p>`;
35
43
  }
36
44
  confirm() {
37
45
  this === null || this === void 0 ? void 0 : this.confirmDonation();
@@ -40,7 +48,9 @@ let ConfirmDonationContent = class ConfirmDonationContent extends LitElement {
40
48
  this === null || this === void 0 ? void 0 : this.cancelDonation();
41
49
  }
42
50
  get confirmCTA() {
43
- return this.donationType === DonationType.Upsell ? 'Start monthly donation' : 'Complete donation';
51
+ return this.donationType === DonationType.Upsell
52
+ ? 'Start monthly donation'
53
+ : 'Complete donation';
44
54
  }
45
55
  /** @inheritdoc */
46
56
  render() {