@internetarchive/donation-form 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/demo/braintree-endpoint-manager.js.map +1 -1
- package/dist/demo/submit-form-with.js.map +1 -1
- package/dist/src/braintree-manager/braintree-manager.js.map +1 -1
- package/dist/src/braintree-manager/payment-clients.d.ts +0 -2
- package/dist/src/braintree-manager/payment-clients.js +0 -1
- package/dist/src/braintree-manager/payment-clients.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource-interface.d.ts +0 -1
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource.d.ts +0 -1
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource.js +2 -2
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-datasource.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay-session-manager.d.ts +0 -1
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay.js +0 -1
- package/dist/src/braintree-manager/payment-providers/apple-pay/apple-pay.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.js +2 -2
- package/dist/src/braintree-manager/payment-providers/credit-card/credit-card.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/google-pay-interface.d.ts +0 -1
- package/dist/src/braintree-manager/payment-providers/google-pay.d.ts +0 -1
- package/dist/src/braintree-manager/payment-providers/paypal/paypal-button-datasource.js +3 -3
- package/dist/src/braintree-manager/payment-providers/paypal/paypal-button-datasource.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/paypal/paypal.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers/venmo.js +1 -1
- package/dist/src/braintree-manager/payment-providers/venmo.js.map +1 -1
- package/dist/src/braintree-manager/payment-providers.js.map +1 -1
- package/dist/src/donation-form-controller.js +0 -1
- package/dist/src/donation-form-controller.js.map +1 -1
- package/dist/src/donation-form.js +18 -15
- package/dist/src/donation-form.js.map +1 -1
- package/dist/src/form-elements/badged-input.js.map +1 -1
- package/dist/src/form-elements/contact-form/contact-form.js.map +1 -1
- package/dist/src/form-elements/header/donation-form-header.js.map +1 -1
- package/dist/src/form-elements/header/donation-summary.js.map +1 -1
- package/dist/src/form-elements/payment-selector.js +1 -1
- package/dist/src/form-elements/payment-selector.js.map +1 -1
- package/dist/src/form-elements/total-amount.js.map +1 -1
- package/dist/src/modals/confirm-donation-modal-content.js +0 -2
- package/dist/src/modals/confirm-donation-modal-content.js.map +1 -1
- package/dist/src/modals/error-modal-content.js.map +1 -1
- package/dist/src/modals/upsell-modal-content.js.map +1 -1
- package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js +0 -1
- package/dist/src/payment-flow-handlers/donation-flow-modal-manager.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/applepay-flow-handler.js +1 -1
- package/dist/src/payment-flow-handlers/handlers/applepay-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/creditcard-flow-handler.js +1 -1
- package/dist/src/payment-flow-handlers/handlers/creditcard-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/googlepay-flow-handler.js +1 -1
- package/dist/src/payment-flow-handlers/handlers/googlepay-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/paypal-flow-handler.js +6 -14
- package/dist/src/payment-flow-handlers/handlers/paypal-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/venmo-flow-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/handlers/venmo-restoration-state-handler.js +1 -1
- package/dist/src/payment-flow-handlers/handlers/venmo-restoration-state-handler.js.map +1 -1
- package/dist/src/payment-flow-handlers/payment-flow-handlers.js +1 -1
- package/dist/src/payment-flow-handlers/payment-flow-handlers.js.map +1 -1
- package/dist/src/recaptcha-manager/recaptcha-manager.d.ts +0 -1
- package/dist/src/recaptcha-manager/recaptcha-manager.js.map +1 -1
- package/dist/test/mocks/flow-handlers/individual-handlers/mock-creditcard-flow-handler.js +0 -1
- package/dist/test/mocks/flow-handlers/individual-handlers/mock-creditcard-flow-handler.js.map +1 -1
- package/dist/test/mocks/flow-handlers/mock-payment-flow-handlers.js +1 -1
- package/dist/test/mocks/flow-handlers/mock-payment-flow-handlers.js.map +1 -1
- package/dist/test/mocks/mock-braintree-manager.js.map +1 -1
- package/dist/test/mocks/mock-lazy-loader.js.map +1 -1
- package/dist/test/mocks/mock-modal-manager.js +0 -1
- package/dist/test/mocks/mock-modal-manager.js.map +1 -1
- package/dist/test/mocks/mock-payment-clients.d.ts +0 -2
- package/dist/test/mocks/mock-payment-clients.js +0 -1
- package/dist/test/mocks/mock-payment-clients.js.map +1 -1
- package/dist/test/mocks/mock-recaptcha-manager.d.ts +0 -1
- package/dist/test/mocks/payment-clients/mock-applepay-client.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-applepay-payment.d.ts +0 -1
- package/dist/test/mocks/payment-clients/mock-applepay-paymentauthorizedevent.d.ts +0 -1
- package/dist/test/mocks/payment-clients/mock-applepay-session.d.ts +0 -1
- package/dist/test/mocks/payment-clients/mock-applepay-session.js +0 -2
- package/dist/test/mocks/payment-clients/mock-applepay-session.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-applepay-sessionmanager.d.ts +0 -1
- package/dist/test/mocks/payment-clients/mock-applepay-validatemerchantevent.d.ts +0 -1
- package/dist/test/mocks/payment-clients/mock-data-collector.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-googlepay-client.d.ts +0 -1
- package/dist/test/mocks/payment-clients/mock-googlepay-library.d.ts +0 -1
- package/dist/test/mocks/payment-clients/mock-grecaptcha.d.ts +0 -1
- package/dist/test/mocks/payment-clients/mock-grecaptcha.js +0 -1
- package/dist/test/mocks/payment-clients/mock-grecaptcha.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-hostedfields-client.js.map +1 -1
- package/dist/test/mocks/payment-clients/mock-hostedfieldtokenizepayload.d.ts +1 -1
- package/dist/test/mocks/payment-providers/individual-providers/mock-googlepay-handler.d.ts +0 -1
- package/dist/test/mocks/payment-providers/individual-providers/mock-paypal-button-datasource.js +2 -2
- package/dist/test/mocks/payment-providers/individual-providers/mock-paypal-button-datasource.js.map +1 -1
- package/dist/test/tests/braintree-manager.test.js +12 -13
- package/dist/test/tests/braintree-manager.test.js.map +1 -1
- package/dist/test/tests/donation-form-controller.test.js +21 -21
- package/dist/test/tests/donation-form.test.js +7 -7
- package/dist/test/tests/flow-handlers/donation-flow-modal-manager.test.js +8 -8
- package/dist/test/tests/form-elements/donation-summary.test.js +2 -2
- package/dist/test/tests/form-elements/payment-selector.test.js +8 -8
- package/dist/test/tests/modals/upsell-modal-content.test.js +21 -21
- package/dist/test/tests/models/donation-payment-info.test.js +7 -7
- package/dist/test/tests/models/donation-payment-info.test.js.map +1 -1
- package/dist/test/tests/payment-providers/applepay-sessiondatasource.test.js.map +1 -1
- package/dist/test/tests/payment-providers/creditcard.test.js.map +1 -1
- package/dist/test/tests/recaptcha-manager.test.js.map +1 -1
- package/package.json +40 -40
- package/src/braintree-manager/payment-clients.ts +0 -1
- package/src/braintree-manager/payment-providers/apple-pay/apple-pay.ts +0 -1
- package/src/donation-form-controller.ts +0 -1
- package/src/donation-form.ts +9 -6
- package/src/modals/confirm-donation-modal-content.ts +0 -2
- package/src/payment-flow-handlers/donation-flow-modal-manager.ts +0 -1
- package/src/payment-flow-handlers/handlers/paypal-flow-handler.ts +2 -4
- package/src/payment-flow-handlers/payment-flow-handlers.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"donation-form-controller.js","sourceRoot":"","sources":["../../src/donation-form-controller.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ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;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAoD;AAEnD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAA0C;AAGrE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAC6C;AAEhD;IAAvB,KAAK,CAAC,eAAe,CAAC;4DAAqC;AAE5B;IAA/B,KAAK,CAAC,uBAAuB,CAAC;oEAA+C;AAErD;IAAxB,KAAK,CAAC,gBAAgB,CAAC;iEAA4C;AAEpC;IAA/B,KAAK,CAAC,uBAAuB,CAAC;4EAAuD;AAEnD;IAAlC,KAAK,CAAC,0BAA0B,CAAC;qEAAgD;AAE3D;IAAtB,KAAK,CAAC,cAAc,CAAC;2DAAmC;AA5D9C,sBAAsB;IADlC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,sBAAsB,CA+iBlC;SA/iBY,sBAAsB","sourcesContent":["/* eslint-disable @typescript-eslint/ban-types */\nimport { LitElement, html, PropertyValues, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport currency from 'currency.js';\nimport {\n LazyLoaderService,\n LazyLoaderServiceInterface,\n} from '@internetarchive/lazy-loader-service';\nimport { ModalManagerInterface } from '@internetarchive/modal-manager';\n\nimport { DonationForm } from './donation-form';\nimport { PaymentClients, PaymentClientsInterface } from './braintree-manager/payment-clients';\nimport { BraintreeManager } from './braintree-manager/braintree-manager';\nimport {\n BraintreeEndpointManagerInterface,\n BraintreeManagerInterface,\n HostingEnvironment,\n} from './braintree-manager/braintree-interfaces';\nimport {\n PaymentFlowHandlers,\n PaymentFlowHandlersInterface,\n} from './payment-flow-handlers/payment-flow-handlers';\n\nimport { RecaptchaManager, RecaptchaManagerInterface } from './recaptcha-manager/recaptcha-manager';\nimport { HostedFieldConfiguration } from './braintree-manager/payment-providers/credit-card/hosted-field-configuration';\nimport {\n HostedFieldContainerInterface,\n HostedFieldContainer,\n} from './braintree-manager/payment-providers/credit-card/hosted-field-container';\n\nimport './form-elements/badged-input';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/contact-form/contact-form';\n\nimport creditCardImg from '@internetarchive/icon-credit-card/index.js';\nimport calendarImg from '@internetarchive/icon-calendar/index.js';\nimport lockImg from '@internetarchive/icon-lock/index.js';\nimport { DonationControllerEventLoggerInterface } from './@types/analytics-handler';\nimport { AnalyticsManagerInterface, AnalyticsEvent } from '@internetarchive/analytics-manager';\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport {\n DonationPaymentInfo,\n PaymentProvider,\n DonationType,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from '@internetarchive/donation-form-data-models';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\n\n/**\n * The DonationFormController orchestrates several of the interactions between\n * the various pieces of the donation form like modals, braintree, paypal, and recaptcha\n *\n * @export\n * @class RadioPlayerController\n * @extends {LitElement}\n */\n@customElement('donation-form-controller')\nexport class DonationFormController extends LitElement {\n @property({ type: String }) environment?: HostingEnvironment;\n\n @property({ type: String }) braintreeAuthToken?: string;\n\n @property({ type: String }) recaptchaSiteKey?: string;\n\n @property({ type: String }) venmoProfileId?: string;\n\n @property({ type: String }) googlePayMerchantId?: string;\n\n @property({ type: String }) analyticsCategory = 'DonationForm';\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: Object }) donationInfo: DonationPaymentInfo = defaultSelectedDonationInfo;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String }) referrer?: string;\n\n @property({ type: String }) loggedInUser?: string;\n\n @property({ type: String }) origin?: string;\n\n @property({ type: String }) donorEmail: string = '';\n\n @property({ type: Object }) endpointManager?: BraintreeEndpointManagerInterface;\n\n @property({ type: Object }) analyticsHandler?: AnalyticsManagerInterface;\n\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n @property({ type: Object }) recaptchaElement?: HTMLElement;\n\n @property({ type: Object }) braintreeManager?: BraintreeManagerInterface;\n\n @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;\n\n @property({ type: Object }) paymentFlowHandlers?: PaymentFlowHandlersInterface;\n\n @property({ type: Object }) paymentClients?: PaymentClientsInterface;\n\n @property({ type: Object })\n lazyLoaderService: LazyLoaderServiceInterface = new LazyLoaderService();\n\n @query('donation-form') private donationForm!: DonationForm;\n\n @query('#braintree-creditcard') private braintreeNumberInput!: HTMLDivElement;\n\n @query('#braintree-cvv') private braintreeCVVInput!: HTMLDivElement;\n\n @query('#braintree-expiration') private braintreeExpirationDateInput!: HTMLDivElement;\n\n @query('#braintree-error-message') private braintreeErrorMessage!: HTMLDivElement;\n\n @query('contact-form') private contactForm?: ContactForm;\n\n /** @inheritdoc */\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('referrer') && this.referrer) {\n this.braintreeManager?.setReferrer(this.referrer);\n this.logDonationFlowEvent('referrer', this.referrer);\n }\n\n if (changedProperties.has('loggedInUser') && this.loggedInUser) {\n this.braintreeManager?.setLoggedInUser(this.loggedInUser);\n }\n\n if (changedProperties.has('origin') && this.origin) {\n this.braintreeManager?.setOrigin(this.origin);\n this.logDonationFlowEvent('origin', this.origin);\n }\n\n if (\n changedProperties.has('paymentClients') ||\n changedProperties.has('braintreeAuthToken') ||\n changedProperties.has('endpointManager') ||\n changedProperties.has('environment')\n ) {\n this.setupBraintreeManager();\n this.setupRecaptchaManager();\n }\n\n if (changedProperties.has('recaptchaSiteKey')) {\n this.setupRecaptchaManager();\n }\n\n if (\n changedProperties.has('braintreeManager') ||\n changedProperties.has('recaptchaManager') ||\n changedProperties.has('modalManager') ||\n changedProperties.has('recaptchaElement')\n ) {\n this.setupPaymentFlowHandlers();\n }\n\n if (\n (changedProperties.has('environment') || changedProperties.has('lazyLoaderService')) &&\n this.environment\n ) {\n this.paymentClients = new PaymentClients(this.lazyLoaderService, this.environment);\n }\n }\n\n async showConfirmationStepDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: Function;\n confirmDonationCB: Function;\n }): Promise<void> {\n this.donationForm.showConfirmationModalDev(options);\n }\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.donationForm.showUpsellModalDev(options);\n }\n\n private setupBraintreeManager(): void {\n if (\n this.braintreeManager === undefined &&\n this.braintreeAuthToken &&\n this.endpointManager &&\n this.paymentClients &&\n this.environment\n ) {\n this.braintreeManager = new BraintreeManager({\n paymentClients: this.paymentClients,\n endpointManager: this.endpointManager,\n authorizationToken: this.braintreeAuthToken,\n venmoProfileId: this.venmoProfileId,\n googlePayMerchantId: this.googlePayMerchantId,\n hostedFieldConfig: this.hostedFieldConfig,\n hostingEnvironment: this.environment,\n referrer: this.referrer,\n loggedInUser: this.loggedInUser,\n origin: this.origin,\n });\n\n this.braintreeManager.on('paymentProvidersHostedFieldsRetry', (retryNumber: number) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsRetry', {\n detail: { retryNumber },\n });\n this.dispatchEvent(event);\n });\n\n this.braintreeManager.on('paymentProvidersHostedFieldsFailed', (error: unknown) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsFailed', {\n detail: { error },\n });\n this.dispatchEvent(event);\n });\n }\n }\n\n private recaptchaManagerSetup = false;\n\n private async setupRecaptchaManager(): Promise<void> {\n if (!this.recaptchaSiteKey || !this.paymentClients || this.recaptchaManagerSetup) {\n return;\n }\n this.recaptchaManagerSetup = true;\n const grecaptchaLibrary = await this.paymentClients.recaptchaLibrary.get();\n this.recaptchaManager = new RecaptchaManager({\n grecaptchaLibrary: grecaptchaLibrary,\n siteKey: this.recaptchaSiteKey,\n });\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.configureFromQueryParams();\n this.trackViewedEvent();\n }\n\n private configureFromQueryParams(): void {\n const urlParams = new URLSearchParams(window.location.search);\n\n let amountOptions = this.amountOptions;\n const amountOptionsParam = urlParams.get('dollarAmounts');\n if (amountOptionsParam) {\n const stripBrackets = amountOptionsParam.slice(1, -1);\n const splitValues = stripBrackets.split(',');\n const numberArray = splitValues\n .map(value => parseFloat(value))\n .filter(value => !isNaN(value));\n amountOptions = numberArray;\n }\n\n let coverFees = this.donationInfo.coverFees;\n const coverFeesParam = urlParams.get('coverFees');\n if (coverFeesParam) {\n coverFees = coverFeesParam === 'true';\n }\n\n let frequency = this.donationInfo.donationType;\n const frequencyParam = urlParams.get('contrib_type');\n if (frequencyParam === 'monthly') {\n frequency = DonationType.Monthly;\n }\n\n let amount = this.donationInfo.amount;\n const amountParam = urlParams.get('amt');\n if (amountParam) {\n const parsedAmount = currency(amountParam).value;\n if (parsedAmount > 0) {\n amount = parsedAmount;\n }\n }\n\n const amountLayoutParam = urlParams.get('amountLayout');\n if (amountLayoutParam) {\n const amountLayout = amountLayoutParam as EditDonationAmountSelectionLayout;\n if (Object.values(EditDonationAmountSelectionLayout).includes(amountLayout)) {\n this.amountSelectionLayout = amountLayout;\n }\n }\n\n const frequencyModeParam = urlParams.get('frequencyMode');\n if (frequencyModeParam) {\n const frequencyMode = frequencyModeParam as EditDonationFrequencySelectionMode;\n if (Object.values(EditDonationFrequencySelectionMode).includes(frequencyMode)) {\n this.frequencySelectionMode = frequencyMode;\n }\n }\n\n const donationInfo = new DonationPaymentInfo({\n donationType: frequency,\n amount: amount,\n coverFees: coverFees,\n });\n\n this.amountOptions = amountOptions;\n this.donationInfo = donationInfo;\n }\n\n private setupPaymentFlowHandlers(): void {\n // only set up once\n if (this.paymentFlowHandlers) {\n return;\n }\n\n // verify we have all of the dependencies\n if (\n !this.braintreeManager ||\n !this.recaptchaManager ||\n !this.modalManager ||\n !this.recaptchaElement\n ) {\n return;\n }\n\n this.paymentFlowHandlers = new PaymentFlowHandlers({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n recaptchaManager: this.recaptchaManager,\n resources: {\n analytics: {\n logEvent: this.logEvent.bind(this),\n logDonationFlowEvent: this.logDonationFlowEvent.bind(this),\n } as DonationControllerEventLoggerInterface,\n },\n });\n\n this.donationForm.braintreeManager = this.braintreeManager;\n this.donationForm.paymentFlowHandlers = this.paymentFlowHandlers;\n\n this.braintreeManager.startup();\n this.paymentFlowHandlers?.startup();\n this.recaptchaManager.setup(this.recaptchaElement, 1, 'light', 'image');\n }\n\n private get hostedFieldConfig(): HostedFieldConfiguration {\n const hostedFieldStyle: Record<string, Record<string, string>> = {\n input: {\n 'font-size': '16px',\n 'font-family': '\"Helvetica Neue\", Helvetica, Arial, sans-serif',\n 'font-weight': '700',\n color: '#333',\n },\n ':focus': {\n color: '#333',\n },\n '.valid': {},\n '.invalid': {\n color: '#b00b00',\n },\n };\n\n const hostedFieldFieldOptions: braintree.HostedFieldFieldOptions = {\n number: {\n selector: '#braintree-creditcard',\n placeholder: 'Card number',\n },\n cvv: {\n selector: '#braintree-cvv',\n placeholder: 'CVC',\n },\n expirationDate: {\n selector: '#braintree-expiration',\n placeholder: 'MM / YY',\n },\n };\n\n const hostedFieldContainer: HostedFieldContainerInterface = new HostedFieldContainer({\n number: this.braintreeNumberInput,\n cvv: this.braintreeCVVInput,\n expirationDate: this.braintreeExpirationDateInput,\n errorContainer: this.braintreeErrorMessage,\n });\n\n const config: HostedFieldConfiguration = new HostedFieldConfiguration({\n hostedFieldStyle,\n hostedFieldFieldOptions,\n hostedFieldContainer,\n });\n\n return config;\n }\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"donation-form-controller-container\">\n <donation-form\n .environment=${this.environment}\n .braintreeManager=${this.braintreeManager}\n .contactForm=${this.contactForm}\n .amountOptions=${this.amountOptions}\n .donationInfo=${this.donationInfo}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @paymentProviderSelected=${this.paymentProviderSelected}\n @paymentFlowStarted=${this.paymentFlowStarted}\n @paymentFlowConfirmed=${this.paymentFlowConfirmed}\n @paymentFlowCancelled=${this.paymentFlowCancelled}\n @paymentFlowError=${this.paymentFlowError}\n >\n <!--\n Why are these slots here?\n\n Due to the way Braintree, PayPal, and Recaptcha work, they cannot exist\n in the shadowDOM so must exist in the clearDOM and get passed\n in through a <slot>.\n\n Braintree / PayPal are working on a solution to this. See:\n - https://github.com/braintree/braintree-web-drop-in/issues/614#issuecomment-616796104\n - https://github.com/braintree/braintree-web-drop-in/issues/296#issuecomment-616749307\n - https://github.com/paypal/paypal-checkout-components/issues/353#issuecomment-595956216\n -->\n <div slot=\"braintree-hosted-fields\">\n <div id=\"braintree-error-message\"></div>\n <div class=\"braintree-row\">\n <badged-input .icon=${creditCardImg} ?required=${true} class=\"creditcard\">\n <div class=\"braintree-input\" id=\"braintree-creditcard\"></div>\n </badged-input>\n </div>\n <div class=\"braintree-row\">\n <badged-input .icon=${calendarImg} ?required=${true} class=\"expiration\">\n <div class=\"braintree-input\" id=\"braintree-expiration\"></div>\n </badged-input>\n <badged-input .icon=${lockImg} ?required=${true} class=\"cvv\">\n <div class=\"braintree-input\" id=\"braintree-cvv\"></div>\n </badged-input>\n </div>\n </div>\n\n <!--\n Form autocompletion does not work in the shadowDOM so\n we slot the contact form in from the lightDOM and pass\n in a reference to it in the <donation-form> tag above\n -->\n <div slot=\"contact-form\">\n <contact-form .donorEmail=${this.donorEmail}></contact-form>\n </div>\n\n <div slot=\"paypal-button\">\n <div id=\"paypal-button\"></div>\n </div>\n\n <slot name=\"recaptcha\" slot=\"recaptcha\"> </slot>\n </donation-form>\n </div>\n\n ${this.getStyles}\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 // We have to do this to accomodate the PayPal buttons and HostedFields,\n // which do not work in the shadow DOM\n return this;\n }\n\n private donationInfoChanged(): void {\n this.logEvent('DonationInfoChanged');\n }\n\n private trackViewedEvent(): void {\n this.logEvent('Viewed');\n }\n\n private paymentProviderSelected(e: CustomEvent): void {\n const paymentProvider = e.detail.paymentProvider as PaymentProvider;\n const previousPaymentProvider = e.detail.previousPaymentProvider;\n const providerNoSpaces = this.removeSpaces(paymentProvider ?? 'unset');\n let eventName = `ProviderFirstSelected-${providerNoSpaces}`;\n let previousProviderInfo;\n if (previousPaymentProvider !== undefined) {\n eventName = `ProviderChangedTo-${providerNoSpaces}`;\n previousProviderInfo = `ProviderChangedFrom-${this.removeSpaces(previousPaymentProvider)}`;\n }\n\n this.logEvent(eventName, previousProviderInfo);\n }\n\n private paymentFlowConfirmed(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowConfirmed', providerNoSpaces);\n }\n\n private paymentFlowStarted(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowStarted', providerNoSpaces);\n }\n\n private paymentFlowCancelled(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowCancelled', providerNoSpaces);\n }\n\n private paymentFlowError(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n const error = e.detail.error;\n const detail = `${providerNoSpaces}-${error}`;\n this.logEvent('PaymentFlowError', detail);\n }\n\n private removeSpaces(original: string): string {\n return original.replace(/\\s+/g, '');\n }\n\n /**\n * Log an event\n *\n * @param {string} action Name of event\n * @param {string} label Event label, optional\n */\n private logEvent(action: string, label?: string): void {\n const analyticEvent = { action, label, category: this.analyticsCategory } as AnalyticsEvent;\n this.analyticsHandler?.sendEvent(analyticEvent);\n }\n\n /**\n * Logs `DonationFlow` Event category into no sample bucket\n *\n * @param {string} action Name of event\n * @param {string} label Event label, optional\n */\n private logDonationFlowEvent(action: string, label?: string): void {\n const analyticEvent = { action, label, category: 'DonationFlow' } as AnalyticsEvent;\n this.analyticsHandler?.sendEventNoSampling(analyticEvent);\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, 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 IADonationFormController\n */\n private get getStyles(): TemplateResult {\n return html`\n <style>\n .donation-form-controller-container {\n color: var(--donateFormTextColor, #333);\n background-color: var(--donateFormBgColor, transparent);\n\n --formSectionContentBackgroundColor: var(--donateFormBgColor, transparent);\n\n --editFormBadgeBgColor: var(--donateFormBadgeBgColor, #333);\n --formSectionBadgeBackgroundColor: var(--donateFormBadgeBgColor, #333);\n\n --editFormBadgeFontColor: var(--donateFormBadgeTextColor, #fff);\n --formSectionBadgeFontColor: var(--donateFormBadgeTextColor, #fff);\n\n --paymentButtonFontColor: var(--donateFormPaymentOptionTextColor);\n --paymentButtonColor: var(--donateFormPaymentOptionBgColor);\n\n --paymentButtonSelectedColor: var(--donateFormSelectedOptionBgColor);\n --paymentButtonSelectedFontColor: var(--donateFormSelectedOptionTextColor);\n }\n .donation-form-controller-container donation-form:focus {\n outline: none;\n }\n\n .donation-form-controller-container #paypal-button {\n opacity: 0.001;\n width: 5rem;\n height: 3rem;\n overflow: hidden;\n }\n\n .donation-form-controller-container .braintree-row {\n display: flex;\n margin-top: -1px;\n }\n\n .donation-form-controller-container badged-input {\n width: 100%;\n }\n\n .donation-form-controller-container badged-input.cvv {\n margin-left: -1px;\n }\n\n .donation-form-controller-container .braintree-input {\n width: 100%;\n height: 100%;\n }\n\n .donation-form-controller-container #braintree-error-message {\n color: red;\n font-size: 1.4rem;\n margin-bottom: 0.6rem;\n }\n\n .donation-form-controller-container div[slot='braintree-hosted-fields'] {\n background-color: white;\n }\n </style>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"donation-form-controller.js","sourceRoot":"","sources":["../../src/donation-form-controller.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EACL,iBAAiB,GAElB,MAAM,sCAAsC,CAAC;AAI9C,OAAO,EAAE,cAAc,EAA2B,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAMzE,OAAO,EACL,mBAAmB,GAEpB,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAA6B,MAAM,uCAAuC,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,8EAA8E,CAAC;AACxH,OAAO,EAEL,oBAAoB,GACrB,MAAM,0EAA0E,CAAC;AAElF,OAAO,8BAA8B,CAAC;AAEtC,OAAO,2CAA2C,CAAC;AAEnD,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,WAAW,MAAM,yCAAyC,CAAC;AAClE,OAAO,OAAO,MAAM,qCAAqC,CAAC;AAG1D,OAAO,EACL,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EACL,mBAAmB,EAEnB,YAAY,EACZ,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,4CAA4C,CAAC;AAGpD;;;;;;;GAOG;AAEI,IAA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BAAsB,CA+iBlC","sourcesContent":["import { LitElement, html, PropertyValues, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport currency from 'currency.js';\nimport {\n LazyLoaderService,\n LazyLoaderServiceInterface,\n} from '@internetarchive/lazy-loader-service';\nimport { ModalManagerInterface } from '@internetarchive/modal-manager';\n\nimport { DonationForm } from './donation-form';\nimport { PaymentClients, PaymentClientsInterface } from './braintree-manager/payment-clients';\nimport { BraintreeManager } from './braintree-manager/braintree-manager';\nimport {\n BraintreeEndpointManagerInterface,\n BraintreeManagerInterface,\n HostingEnvironment,\n} from './braintree-manager/braintree-interfaces';\nimport {\n PaymentFlowHandlers,\n PaymentFlowHandlersInterface,\n} from './payment-flow-handlers/payment-flow-handlers';\n\nimport { RecaptchaManager, RecaptchaManagerInterface } from './recaptcha-manager/recaptcha-manager';\nimport { HostedFieldConfiguration } from './braintree-manager/payment-providers/credit-card/hosted-field-configuration';\nimport {\n HostedFieldContainerInterface,\n HostedFieldContainer,\n} from './braintree-manager/payment-providers/credit-card/hosted-field-container';\n\nimport './form-elements/badged-input';\nimport { ContactForm } from './form-elements/contact-form/contact-form';\nimport './form-elements/contact-form/contact-form';\n\nimport creditCardImg from '@internetarchive/icon-credit-card/index.js';\nimport calendarImg from '@internetarchive/icon-calendar/index.js';\nimport lockImg from '@internetarchive/icon-lock/index.js';\nimport { DonationControllerEventLoggerInterface } from './@types/analytics-handler';\nimport { AnalyticsManagerInterface, AnalyticsEvent } from '@internetarchive/analytics-manager';\nimport {\n EditDonationAmountSelectionLayout,\n EditDonationFrequencySelectionMode,\n} from '@internetarchive/donation-form-edit-donation';\n\nimport {\n DonationPaymentInfo,\n PaymentProvider,\n DonationType,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from '@internetarchive/donation-form-data-models';\nimport { UpsellModalCTAMode } from './modals/upsell-modal-content';\n\n/**\n * The DonationFormController orchestrates several of the interactions between\n * the various pieces of the donation form like modals, braintree, paypal, and recaptcha\n *\n * @export\n * @class RadioPlayerController\n * @extends {LitElement}\n */\n@customElement('donation-form-controller')\nexport class DonationFormController extends LitElement {\n @property({ type: String }) environment?: HostingEnvironment;\n\n @property({ type: String }) braintreeAuthToken?: string;\n\n @property({ type: String }) recaptchaSiteKey?: string;\n\n @property({ type: String }) venmoProfileId?: string;\n\n @property({ type: String }) googlePayMerchantId?: string;\n\n @property({ type: String }) analyticsCategory = 'DonationForm';\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: Object }) donationInfo: DonationPaymentInfo = defaultSelectedDonationInfo;\n\n @property({ type: String }) amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String }) frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String }) referrer?: string;\n\n @property({ type: String }) loggedInUser?: string;\n\n @property({ type: String }) origin?: string;\n\n @property({ type: String }) donorEmail: string = '';\n\n @property({ type: Object }) endpointManager?: BraintreeEndpointManagerInterface;\n\n @property({ type: Object }) analyticsHandler?: AnalyticsManagerInterface;\n\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n @property({ type: Object }) recaptchaElement?: HTMLElement;\n\n @property({ type: Object }) braintreeManager?: BraintreeManagerInterface;\n\n @property({ type: Object }) recaptchaManager?: RecaptchaManagerInterface;\n\n @property({ type: Object }) paymentFlowHandlers?: PaymentFlowHandlersInterface;\n\n @property({ type: Object }) paymentClients?: PaymentClientsInterface;\n\n @property({ type: Object })\n lazyLoaderService: LazyLoaderServiceInterface = new LazyLoaderService();\n\n @query('donation-form') private donationForm!: DonationForm;\n\n @query('#braintree-creditcard') private braintreeNumberInput!: HTMLDivElement;\n\n @query('#braintree-cvv') private braintreeCVVInput!: HTMLDivElement;\n\n @query('#braintree-expiration') private braintreeExpirationDateInput!: HTMLDivElement;\n\n @query('#braintree-error-message') private braintreeErrorMessage!: HTMLDivElement;\n\n @query('contact-form') private contactForm?: ContactForm;\n\n /** @inheritdoc */\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('referrer') && this.referrer) {\n this.braintreeManager?.setReferrer(this.referrer);\n this.logDonationFlowEvent('referrer', this.referrer);\n }\n\n if (changedProperties.has('loggedInUser') && this.loggedInUser) {\n this.braintreeManager?.setLoggedInUser(this.loggedInUser);\n }\n\n if (changedProperties.has('origin') && this.origin) {\n this.braintreeManager?.setOrigin(this.origin);\n this.logDonationFlowEvent('origin', this.origin);\n }\n\n if (\n changedProperties.has('paymentClients') ||\n changedProperties.has('braintreeAuthToken') ||\n changedProperties.has('endpointManager') ||\n changedProperties.has('environment')\n ) {\n this.setupBraintreeManager();\n this.setupRecaptchaManager();\n }\n\n if (changedProperties.has('recaptchaSiteKey')) {\n this.setupRecaptchaManager();\n }\n\n if (\n changedProperties.has('braintreeManager') ||\n changedProperties.has('recaptchaManager') ||\n changedProperties.has('modalManager') ||\n changedProperties.has('recaptchaElement')\n ) {\n this.setupPaymentFlowHandlers();\n }\n\n if (\n (changedProperties.has('environment') || changedProperties.has('lazyLoaderService')) &&\n this.environment\n ) {\n this.paymentClients = new PaymentClients(this.lazyLoaderService, this.environment);\n }\n }\n\n async showConfirmationStepDev(options: {\n donationType: DonationType;\n amount: number;\n currencyType: string;\n cancelDonationCB: Function;\n confirmDonationCB: Function;\n }): Promise<void> {\n this.donationForm.showConfirmationModalDev(options);\n }\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.donationForm.showUpsellModalDev(options);\n }\n\n private setupBraintreeManager(): void {\n if (\n this.braintreeManager === undefined &&\n this.braintreeAuthToken &&\n this.endpointManager &&\n this.paymentClients &&\n this.environment\n ) {\n this.braintreeManager = new BraintreeManager({\n paymentClients: this.paymentClients,\n endpointManager: this.endpointManager,\n authorizationToken: this.braintreeAuthToken,\n venmoProfileId: this.venmoProfileId,\n googlePayMerchantId: this.googlePayMerchantId,\n hostedFieldConfig: this.hostedFieldConfig,\n hostingEnvironment: this.environment,\n referrer: this.referrer,\n loggedInUser: this.loggedInUser,\n origin: this.origin,\n });\n\n this.braintreeManager.on('paymentProvidersHostedFieldsRetry', (retryNumber: number) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsRetry', {\n detail: { retryNumber },\n });\n this.dispatchEvent(event);\n });\n\n this.braintreeManager.on('paymentProvidersHostedFieldsFailed', (error: unknown) => {\n const event = new CustomEvent('paymentProvidersHostedFieldsFailed', {\n detail: { error },\n });\n this.dispatchEvent(event);\n });\n }\n }\n\n private recaptchaManagerSetup = false;\n\n private async setupRecaptchaManager(): Promise<void> {\n if (!this.recaptchaSiteKey || !this.paymentClients || this.recaptchaManagerSetup) {\n return;\n }\n this.recaptchaManagerSetup = true;\n const grecaptchaLibrary = await this.paymentClients.recaptchaLibrary.get();\n this.recaptchaManager = new RecaptchaManager({\n grecaptchaLibrary: grecaptchaLibrary,\n siteKey: this.recaptchaSiteKey,\n });\n }\n\n /** @inheritdoc */\n firstUpdated(): void {\n this.configureFromQueryParams();\n this.trackViewedEvent();\n }\n\n private configureFromQueryParams(): void {\n const urlParams = new URLSearchParams(window.location.search);\n\n let amountOptions = this.amountOptions;\n const amountOptionsParam = urlParams.get('dollarAmounts');\n if (amountOptionsParam) {\n const stripBrackets = amountOptionsParam.slice(1, -1);\n const splitValues = stripBrackets.split(',');\n const numberArray = splitValues\n .map(value => parseFloat(value))\n .filter(value => !isNaN(value));\n amountOptions = numberArray;\n }\n\n let coverFees = this.donationInfo.coverFees;\n const coverFeesParam = urlParams.get('coverFees');\n if (coverFeesParam) {\n coverFees = coverFeesParam === 'true';\n }\n\n let frequency = this.donationInfo.donationType;\n const frequencyParam = urlParams.get('contrib_type');\n if (frequencyParam === 'monthly') {\n frequency = DonationType.Monthly;\n }\n\n let amount = this.donationInfo.amount;\n const amountParam = urlParams.get('amt');\n if (amountParam) {\n const parsedAmount = currency(amountParam).value;\n if (parsedAmount > 0) {\n amount = parsedAmount;\n }\n }\n\n const amountLayoutParam = urlParams.get('amountLayout');\n if (amountLayoutParam) {\n const amountLayout = amountLayoutParam as EditDonationAmountSelectionLayout;\n if (Object.values(EditDonationAmountSelectionLayout).includes(amountLayout)) {\n this.amountSelectionLayout = amountLayout;\n }\n }\n\n const frequencyModeParam = urlParams.get('frequencyMode');\n if (frequencyModeParam) {\n const frequencyMode = frequencyModeParam as EditDonationFrequencySelectionMode;\n if (Object.values(EditDonationFrequencySelectionMode).includes(frequencyMode)) {\n this.frequencySelectionMode = frequencyMode;\n }\n }\n\n const donationInfo = new DonationPaymentInfo({\n donationType: frequency,\n amount: amount,\n coverFees: coverFees,\n });\n\n this.amountOptions = amountOptions;\n this.donationInfo = donationInfo;\n }\n\n private setupPaymentFlowHandlers(): void {\n // only set up once\n if (this.paymentFlowHandlers) {\n return;\n }\n\n // verify we have all of the dependencies\n if (\n !this.braintreeManager ||\n !this.recaptchaManager ||\n !this.modalManager ||\n !this.recaptchaElement\n ) {\n return;\n }\n\n this.paymentFlowHandlers = new PaymentFlowHandlers({\n braintreeManager: this.braintreeManager,\n modalManager: this.modalManager,\n recaptchaManager: this.recaptchaManager,\n resources: {\n analytics: {\n logEvent: this.logEvent.bind(this),\n logDonationFlowEvent: this.logDonationFlowEvent.bind(this),\n } as DonationControllerEventLoggerInterface,\n },\n });\n\n this.donationForm.braintreeManager = this.braintreeManager;\n this.donationForm.paymentFlowHandlers = this.paymentFlowHandlers;\n\n this.braintreeManager.startup();\n this.paymentFlowHandlers?.startup();\n this.recaptchaManager.setup(this.recaptchaElement, 1, 'light', 'image');\n }\n\n private get hostedFieldConfig(): HostedFieldConfiguration {\n const hostedFieldStyle: Record<string, Record<string, string>> = {\n input: {\n 'font-size': '16px',\n 'font-family': '\"Helvetica Neue\", Helvetica, Arial, sans-serif',\n 'font-weight': '700',\n color: '#333',\n },\n ':focus': {\n color: '#333',\n },\n '.valid': {},\n '.invalid': {\n color: '#b00b00',\n },\n };\n\n const hostedFieldFieldOptions: braintree.HostedFieldFieldOptions = {\n number: {\n selector: '#braintree-creditcard',\n placeholder: 'Card number',\n },\n cvv: {\n selector: '#braintree-cvv',\n placeholder: 'CVC',\n },\n expirationDate: {\n selector: '#braintree-expiration',\n placeholder: 'MM / YY',\n },\n };\n\n const hostedFieldContainer: HostedFieldContainerInterface = new HostedFieldContainer({\n number: this.braintreeNumberInput,\n cvv: this.braintreeCVVInput,\n expirationDate: this.braintreeExpirationDateInput,\n errorContainer: this.braintreeErrorMessage,\n });\n\n const config: HostedFieldConfiguration = new HostedFieldConfiguration({\n hostedFieldStyle,\n hostedFieldFieldOptions,\n hostedFieldContainer,\n });\n\n return config;\n }\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"donation-form-controller-container\">\n <donation-form\n .environment=${this.environment}\n .braintreeManager=${this.braintreeManager}\n .contactForm=${this.contactForm}\n .amountOptions=${this.amountOptions}\n .donationInfo=${this.donationInfo}\n .amountSelectionLayout=${this.amountSelectionLayout}\n .frequencySelectionMode=${this.frequencySelectionMode}\n @donationInfoChanged=${this.donationInfoChanged}\n @paymentProviderSelected=${this.paymentProviderSelected}\n @paymentFlowStarted=${this.paymentFlowStarted}\n @paymentFlowConfirmed=${this.paymentFlowConfirmed}\n @paymentFlowCancelled=${this.paymentFlowCancelled}\n @paymentFlowError=${this.paymentFlowError}\n >\n <!--\n Why are these slots here?\n\n Due to the way Braintree, PayPal, and Recaptcha work, they cannot exist\n in the shadowDOM so must exist in the clearDOM and get passed\n in through a <slot>.\n\n Braintree / PayPal are working on a solution to this. See:\n - https://github.com/braintree/braintree-web-drop-in/issues/614#issuecomment-616796104\n - https://github.com/braintree/braintree-web-drop-in/issues/296#issuecomment-616749307\n - https://github.com/paypal/paypal-checkout-components/issues/353#issuecomment-595956216\n -->\n <div slot=\"braintree-hosted-fields\">\n <div id=\"braintree-error-message\"></div>\n <div class=\"braintree-row\">\n <badged-input .icon=${creditCardImg} ?required=${true} class=\"creditcard\">\n <div class=\"braintree-input\" id=\"braintree-creditcard\"></div>\n </badged-input>\n </div>\n <div class=\"braintree-row\">\n <badged-input .icon=${calendarImg} ?required=${true} class=\"expiration\">\n <div class=\"braintree-input\" id=\"braintree-expiration\"></div>\n </badged-input>\n <badged-input .icon=${lockImg} ?required=${true} class=\"cvv\">\n <div class=\"braintree-input\" id=\"braintree-cvv\"></div>\n </badged-input>\n </div>\n </div>\n\n <!--\n Form autocompletion does not work in the shadowDOM so\n we slot the contact form in from the lightDOM and pass\n in a reference to it in the <donation-form> tag above\n -->\n <div slot=\"contact-form\">\n <contact-form .donorEmail=${this.donorEmail}></contact-form>\n </div>\n\n <div slot=\"paypal-button\">\n <div id=\"paypal-button\"></div>\n </div>\n\n <slot name=\"recaptcha\" slot=\"recaptcha\"> </slot>\n </donation-form>\n </div>\n\n ${this.getStyles}\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 // We have to do this to accomodate the PayPal buttons and HostedFields,\n // which do not work in the shadow DOM\n return this;\n }\n\n private donationInfoChanged(): void {\n this.logEvent('DonationInfoChanged');\n }\n\n private trackViewedEvent(): void {\n this.logEvent('Viewed');\n }\n\n private paymentProviderSelected(e: CustomEvent): void {\n const paymentProvider = e.detail.paymentProvider as PaymentProvider;\n const previousPaymentProvider = e.detail.previousPaymentProvider;\n const providerNoSpaces = this.removeSpaces(paymentProvider ?? 'unset');\n let eventName = `ProviderFirstSelected-${providerNoSpaces}`;\n let previousProviderInfo;\n if (previousPaymentProvider !== undefined) {\n eventName = `ProviderChangedTo-${providerNoSpaces}`;\n previousProviderInfo = `ProviderChangedFrom-${this.removeSpaces(previousPaymentProvider)}`;\n }\n\n this.logEvent(eventName, previousProviderInfo);\n }\n\n private paymentFlowConfirmed(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowConfirmed', providerNoSpaces);\n }\n\n private paymentFlowStarted(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowStarted', providerNoSpaces);\n }\n\n private paymentFlowCancelled(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n this.logEvent('PaymentFlowCancelled', providerNoSpaces);\n }\n\n private paymentFlowError(e: CustomEvent): void {\n const selectedProvider = e.detail.paymentProvider as PaymentProvider;\n const providerNoSpaces = this.removeSpaces(selectedProvider);\n const error = e.detail.error;\n const detail = `${providerNoSpaces}-${error}`;\n this.logEvent('PaymentFlowError', detail);\n }\n\n private removeSpaces(original: string): string {\n return original.replace(/\\s+/g, '');\n }\n\n /**\n * Log an event\n *\n * @param {string} action Name of event\n * @param {string} label Event label, optional\n */\n private logEvent(action: string, label?: string): void {\n const analyticEvent = { action, label, category: this.analyticsCategory } as AnalyticsEvent;\n this.analyticsHandler?.sendEvent(analyticEvent);\n }\n\n /**\n * Logs `DonationFlow` Event category into no sample bucket\n *\n * @param {string} action Name of event\n * @param {string} label Event label, optional\n */\n private logDonationFlowEvent(action: string, label?: string): void {\n const analyticEvent = { action, label, category: 'DonationFlow' } as AnalyticsEvent;\n this.analyticsHandler?.sendEventNoSampling(analyticEvent);\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, 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 IADonationFormController\n */\n private get getStyles(): TemplateResult {\n return html`\n <style>\n .donation-form-controller-container {\n color: var(--donateFormTextColor, #333);\n background-color: var(--donateFormBgColor, transparent);\n\n --formSectionContentBackgroundColor: var(--donateFormBgColor, transparent);\n\n --editFormBadgeBgColor: var(--donateFormBadgeBgColor, #333);\n --formSectionBadgeBackgroundColor: var(--donateFormBadgeBgColor, #333);\n\n --editFormBadgeFontColor: var(--donateFormBadgeTextColor, #fff);\n --formSectionBadgeFontColor: var(--donateFormBadgeTextColor, #fff);\n\n --paymentButtonFontColor: var(--donateFormPaymentOptionTextColor);\n --paymentButtonColor: var(--donateFormPaymentOptionBgColor);\n\n --paymentButtonSelectedColor: var(--donateFormSelectedOptionBgColor);\n --paymentButtonSelectedFontColor: var(--donateFormSelectedOptionTextColor);\n }\n .donation-form-controller-container donation-form:focus {\n outline: none;\n }\n\n .donation-form-controller-container #paypal-button {\n opacity: 0.001;\n width: 5rem;\n height: 3rem;\n overflow: hidden;\n }\n\n .donation-form-controller-container .braintree-row {\n display: flex;\n margin-top: -1px;\n }\n\n .donation-form-controller-container badged-input {\n width: 100%;\n }\n\n .donation-form-controller-container badged-input.cvv {\n margin-left: -1px;\n }\n\n .donation-form-controller-container .braintree-input {\n width: 100%;\n height: 100%;\n }\n\n .donation-form-controller-container #braintree-error-message {\n color: red;\n font-size: 1.4rem;\n margin-bottom: 0.6rem;\n }\n\n .donation-form-controller-container div[slot='braintree-hosted-fields'] {\n background-color: white;\n }\n </style>\n `;\n }\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __awaiter, __decorate } from "tslib";
|
|
2
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
3
2
|
import { LitElement, html, css } from 'lit';
|
|
4
3
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
4
|
import lockImg from '@internetarchive/icon-lock/index.js';
|
|
@@ -79,8 +78,8 @@ let DonationForm = class DonationForm extends LitElement {
|
|
|
79
78
|
`;
|
|
80
79
|
}
|
|
81
80
|
showConfirmationModalDev(options) {
|
|
82
|
-
var _a;
|
|
83
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
var _a;
|
|
84
83
|
(_a = this.paymentFlowHandlers) === null || _a === void 0 ? void 0 : _a.showConfirmationStepModal(options);
|
|
85
84
|
});
|
|
86
85
|
}
|
|
@@ -101,8 +100,8 @@ let DonationForm = class DonationForm extends LitElement {
|
|
|
101
100
|
* @memberof DonationForm
|
|
102
101
|
*/
|
|
103
102
|
showUpsellModalDev(options) {
|
|
104
|
-
var _a, _b;
|
|
105
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
var _a, _b;
|
|
106
105
|
(_a = this.paymentFlowHandlers) === null || _a === void 0 ? void 0 : _a.showUpsellModal(options);
|
|
107
106
|
if (options.ctaMode === UpsellModalCTAMode.PayPalUpsellSlot) {
|
|
108
107
|
const handler = yield ((_b = this.braintreeManager) === null || _b === void 0 ? void 0 : _b.paymentProviders.paypalHandler.get());
|
|
@@ -199,8 +198,9 @@ let DonationForm = class DonationForm extends LitElement {
|
|
|
199
198
|
return;
|
|
200
199
|
}
|
|
201
200
|
const originalEvent = e.detail.originalEvent;
|
|
202
|
-
this.donationInfo
|
|
203
|
-
(
|
|
201
|
+
if (this.donationInfo) {
|
|
202
|
+
(_b = (_a = this.paymentFlowHandlers) === null || _a === void 0 ? void 0 : _a.applePayHandler) === null || _b === void 0 ? void 0 : _b.paymentInitiated(this.donationInfo, originalEvent);
|
|
203
|
+
}
|
|
204
204
|
this.emitPaymentFlowStartedEvent();
|
|
205
205
|
}
|
|
206
206
|
googlePaySelected() {
|
|
@@ -212,8 +212,9 @@ let DonationForm = class DonationForm extends LitElement {
|
|
|
212
212
|
this.showInvalidDonationInfoAlert();
|
|
213
213
|
}
|
|
214
214
|
else {
|
|
215
|
-
this.donationInfo
|
|
216
|
-
(
|
|
215
|
+
if (this.donationInfo) {
|
|
216
|
+
(_b = (_a = this.paymentFlowHandlers) === null || _a === void 0 ? void 0 : _a.googlePayHandler) === null || _b === void 0 ? void 0 : _b.paymentInitiated(this.donationInfo);
|
|
217
|
+
}
|
|
217
218
|
this.emitPaymentFlowStartedEvent();
|
|
218
219
|
}
|
|
219
220
|
}
|
|
@@ -247,8 +248,8 @@ let DonationForm = class DonationForm extends LitElement {
|
|
|
247
248
|
this.showInvalidDonationInfoAlert();
|
|
248
249
|
}
|
|
249
250
|
focusContactForm() {
|
|
250
|
-
var _a;
|
|
251
251
|
return __awaiter(this, void 0, void 0, function* () {
|
|
252
|
+
var _a;
|
|
252
253
|
yield this.updateComplete;
|
|
253
254
|
if (this.contactFormSection) {
|
|
254
255
|
(_a = this.contactForm) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -277,8 +278,8 @@ let DonationForm = class DonationForm extends LitElement {
|
|
|
277
278
|
});
|
|
278
279
|
}
|
|
279
280
|
handleCreditCardDonationFlow(contactInfo, donationInfo) {
|
|
280
|
-
var _a, _b, _c;
|
|
281
281
|
return __awaiter(this, void 0, void 0, function* () {
|
|
282
|
+
var _a, _b, _c;
|
|
282
283
|
const creditCardFlowHandler = (_a = this.paymentFlowHandlers) === null || _a === void 0 ? void 0 : _a.creditCardHandler;
|
|
283
284
|
const creditCardHandler = yield ((_b = this.braintreeManager) === null || _b === void 0 ? void 0 : _b.paymentProviders.creditCardHandler.get());
|
|
284
285
|
creditCardHandler === null || creditCardHandler === void 0 ? void 0 : creditCardHandler.hideErrorMessage();
|
|
@@ -292,8 +293,8 @@ let DonationForm = class DonationForm extends LitElement {
|
|
|
292
293
|
});
|
|
293
294
|
}
|
|
294
295
|
handleVenmoDonationFlow(contactInfo, donationInfo) {
|
|
295
|
-
var _a, _b, _c;
|
|
296
296
|
return __awaiter(this, void 0, void 0, function* () {
|
|
297
|
+
var _a, _b, _c;
|
|
297
298
|
const valid = (_a = this.contactForm) === null || _a === void 0 ? void 0 : _a.reportValidity();
|
|
298
299
|
if (!valid) {
|
|
299
300
|
return;
|
|
@@ -341,14 +342,15 @@ let DonationForm = class DonationForm extends LitElement {
|
|
|
341
342
|
alert('Please enter a valid donation amount.');
|
|
342
343
|
}
|
|
343
344
|
renderPayPalButtonIfNeeded() {
|
|
344
|
-
var _a, _b;
|
|
345
345
|
return __awaiter(this, void 0, void 0, function* () {
|
|
346
|
+
var _a, _b;
|
|
346
347
|
if (!this.paypalButtonNeedsRender) {
|
|
347
348
|
return;
|
|
348
349
|
}
|
|
349
350
|
this.paypalButtonNeedsRender = false;
|
|
350
|
-
this.donationInfo
|
|
351
|
-
|
|
351
|
+
if (this.donationInfo) {
|
|
352
|
+
yield ((_b = (_a = this.paymentFlowHandlers) === null || _a === void 0 ? void 0 : _a.paypalHandler) === null || _b === void 0 ? void 0 : _b.renderPayPalButton(this.donationInfo));
|
|
353
|
+
}
|
|
352
354
|
this.paymentSelector.showPaypalButton();
|
|
353
355
|
});
|
|
354
356
|
}
|
|
@@ -386,8 +388,9 @@ let DonationForm = class DonationForm extends LitElement {
|
|
|
386
388
|
this.flowHandlersConfigured = true;
|
|
387
389
|
this.bindFlowListenerEvents();
|
|
388
390
|
this.renderPayPalButtonIfNeeded();
|
|
389
|
-
this.donationInfo
|
|
390
|
-
(
|
|
391
|
+
if (this.donationInfo) {
|
|
392
|
+
(_b = (_a = this.paymentFlowHandlers) === null || _a === void 0 ? void 0 : _a.paypalHandler) === null || _b === void 0 ? void 0 : _b.updateDonationInfo(this.donationInfo);
|
|
393
|
+
}
|
|
391
394
|
}
|
|
392
395
|
bindFlowListenerEvents() {
|
|
393
396
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
@@ -1 +1 @@
|
|
|
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;AAC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AAE,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,CAghBxB;SAhhBY,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 @resetPaymentMethod=${async () => {\n this.selectedPaymentProvider = undefined;\n this.contactFormVisible = false;\n this.requestUpdate();\n }}\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 const headline =\n this.selectedPaymentProvider === PaymentProvider.Venmo\n ? 'Help us stay in touch'\n : 'Enter payment information';\n\n return html`\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart + 1}\n headline=${headline}\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"]}
|
|
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,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,eAA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ropertyValues } 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 @resetPaymentMethod=${async () => {\n this.selectedPaymentProvider = undefined;\n this.contactFormVisible = false;\n this.requestUpdate();\n }}\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 const headline =\n this.selectedPaymentProvider === PaymentProvider.Venmo\n ? 'Help us stay in touch'\n : 'Enter payment information';\n\n return html`\n <donation-form-section\n .sectionBadge=${this.paymentSelectorNumberingStart + 1}\n headline=${headline}\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 if (this.donationInfo) {\n this.paymentFlowHandlers?.applePayHandler?.paymentInitiated(this.donationInfo, originalEvent);\n }\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 if (this.donationInfo) {\n this.paymentFlowHandlers?.googlePayHandler?.paymentInitiated(this.donationInfo);\n }\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 if (this.donationInfo) {\n await this.paymentFlowHandlers?.paypalHandler?.renderPayPalButton(this.donationInfo);\n }\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 if (this.donationInfo) {\n this.paymentFlowHandlers?.paypalHandler?.updateDonationInfo(this.donationInfo);\n }\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badged-input.js","sourceRoot":"","sources":["../../../src/form-elements/badged-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA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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;AAlG8B;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,CAmGvB","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
|
-
{"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,EAAkC,MAAM,KAAK,CAAC;AAC5E,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;QAEvB,eAAU,GAAG,EAAE,CAAC;IAyX9C,CAAC;IAvXC,OAAO,CAAC,OAAuB;;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YAC7B,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,MAAA,IAAI,CAAC,UAAU,mCAAI,EAAE,CAAC;SAC/C;IACH,CAAC;IAED,cAAc;QACZ,MAAM,iBAAiB,GAA2C;YAChE,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC;YACxC,CAAC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CAAiC,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;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAiB;AAnCjC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA4ZvB;SA5ZY,WAAW","sourcesContent":["import { LitElement, html, css, TemplateResult, PropertyValues } 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 @property({ type: String }) donorEmail = '';\n\n updated(changed: PropertyValues): void {\n if (changed.has('donorEmail')) {\n this.emailField.value = this.donorEmail ?? '';\n }\n }\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: calc(100%);\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 }\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,EAAkC,MAAM,KAAK,CAA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CAAwB;AAGV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAwB;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAiB;AAnCjC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA4ZvB","sourcesContent":["import { LitElement, html, css, TemplateResult, PropertyValues } 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 @property({ type: String }) donorEmail = '';\n\n updated(changed: PropertyValues): void {\n if (changed.has('donorEmail')) {\n this.emailField.value = this.donorEmail ?? '';\n }\n }\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: calc(100%);\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 }\n </style>\n `;\n }\n}\n"]}
|