@internetarchive/elements 1.1.7-webdev-9378.0 → 1.1.7-webdev-9054.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/elements/ia-donation-form/analytics.d.ts +12 -0
- package/dist/src/elements/ia-donation-form/analytics.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/analytics.js +2 -0
- package/dist/src/elements/ia-donation-form/analytics.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.d.ts +79 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager.d.ts +73 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager.js +126 -0
- package/dist/src/elements/ia-donation-form/braintree/braintree-manager.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/hosting-environment.d.ts +10 -0
- package/dist/src/elements/ia-donation-form/braintree/hosting-environment.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/hosting-environment.js +9 -0
- package/dist/src/elements/ia-donation-form/braintree/hosting-environment.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-clients.d.ts +47 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-clients.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-clients.js +104 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-clients.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.d.ts +11 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.d.ts +20 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.d.ts +21 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.js +83 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-datasource.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.d.ts +11 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.js +13 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay-session-manager.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.d.ts +27 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.js +67 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/apple-pay/apple-pay.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.d.ts +19 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.d.ts +42 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.js +99 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/credit-card.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.d.ts +14 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.js +9 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-configuration.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.d.ts +40 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.js +58 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/credit-card/hosted-field-container.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.d.ts +8 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.d.ts +19 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.js +45 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/google-pay/google-pay.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.d.ts +57 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.js +44 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-button-datasource.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.d.ts +14 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.d.ts +27 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.js +44 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/paypal/paypal.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.d.ts +8 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.d.ts +44 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.js +65 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo-restoration-state-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.d.ts +25 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.js +42 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers/venmo/venmo.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.d.ts +18 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.js +2 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers-interface.js.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers.d.ts +42 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers.js +99 -0
- package/dist/src/elements/ia-donation-form/braintree/payment-providers.js.map +1 -0
- package/dist/src/elements/ia-donation-form/donation-form-error.d.ts +5 -0
- package/dist/src/elements/ia-donation-form/donation-form-error.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/donation-form-error.js +8 -0
- package/dist/src/elements/ia-donation-form/donation-form-error.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.d.ts +118 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.js +194 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/donation-flow-modal-manager.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.d.ts +24 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.js +70 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/apple-pay-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.d.ts +44 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.js +116 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/credit-card-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.d.ts +24 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.js +74 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/google-pay-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.d.ts +47 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.js +204 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/paypal-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.d.ts +30 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.js +77 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/handlers/venmo-flow-handler.js.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.d.ts +80 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.js +72 -0
- package/dist/src/elements/ia-donation-form/flow-handlers/payment-flow-handlers.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.d.ts +2 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.js +2 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/autocomplete-field-options.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.d.ts +3 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.js +254 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/countries.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.d.ts +68 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js +483 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.d.ts +26 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.js +163 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-badged-input.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.d.ts +39 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.js +212 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-credit-card-fields.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.d.ts +118 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js +774 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.d.ts +31 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.js +93 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-header.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.d.ts +33 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.js +380 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-payment-selector.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.d.ts +11 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js +59 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.d.ts +10 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js +75 -0
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js.map +1 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form-controller.d.ts +111 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form-controller.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form-controller.js +522 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form-controller.js.map +1 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form.d.ts +95 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form.js +522 -0
- package/dist/src/elements/ia-donation-form/ia-donation-form.js.map +1 -0
- package/dist/src/elements/ia-donation-form/icons/apple-pay.svg +22 -0
- package/dist/src/elements/ia-donation-form/icons/calendar.svg +12 -0
- package/dist/src/elements/ia-donation-form/icons/credit-card.svg +7 -0
- package/dist/src/elements/ia-donation-form/icons/google-pay.svg +38 -0
- package/dist/src/elements/ia-donation-form/icons/lock.svg +6 -0
- package/dist/src/elements/ia-donation-form/icons/paypal.svg +39 -0
- package/dist/src/elements/ia-donation-form/icons/venmo.svg +9 -0
- package/dist/src/elements/ia-donation-form/icons.d.ts +9 -0
- package/dist/src/elements/ia-donation-form/icons.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/icons.js +27 -0
- package/dist/src/elements/ia-donation-form/icons.js.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.d.ts +27 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js +195 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.d.ts +7 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.js +63 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-error-modal-content.js.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.d.ts +28 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.js +313 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-upsell-modal-content.js.map +1 -0
- package/dist/src/elements/ia-donation-form/recaptcha-manager.d.ts +36 -0
- package/dist/src/elements/ia-donation-form/recaptcha-manager.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/recaptcha-manager.js +76 -0
- package/dist/src/elements/ia-donation-form/recaptcha-manager.js.map +1 -0
- package/dist/src/elements/ia-image-viewer/image-viewer-gestures.d.ts.map +1 -1
- package/dist/src/elements/ia-image-viewer/image-viewer-gestures.js +2 -4
- package/dist/src/elements/ia-image-viewer/image-viewer-gestures.js.map +1 -1
- package/package.json +12 -1
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html, LitElement, nothing, } from 'lit';
|
|
3
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
4
|
+
import { customElement } from '../../../util/custom-element.js';
|
|
5
|
+
import { msg, str } from '@lit/localize';
|
|
6
|
+
import currency from 'currency.js';
|
|
7
|
+
import themeStyles from '../../../themes/theme-styles.js';
|
|
8
|
+
import { CurrencyValidator } from '../currency-validator.js';
|
|
9
|
+
import { DonationPaymentInfo, defaultDonationAmounts, defaultSelectedDonationInfo, } from '../models/donation-payment-info.js';
|
|
10
|
+
import { DonationType } from '../models/donation-type.js';
|
|
11
|
+
import { DonationSectionBadgeMode } from './ia-donation-section.js';
|
|
12
|
+
import './ia-donation-section.js';
|
|
13
|
+
/** Whether the numbered step badges show on the sections. */
|
|
14
|
+
export const EditDonationStepNumberMode = {
|
|
15
|
+
HideNumbers: 'hidenumbers',
|
|
16
|
+
ShowNumbers: 'shownumbers',
|
|
17
|
+
};
|
|
18
|
+
/** The radio button groups in the form. */
|
|
19
|
+
export const EditDonationSelectionGroup = {
|
|
20
|
+
DonationType: 'donationType',
|
|
21
|
+
Amount: 'amount',
|
|
22
|
+
};
|
|
23
|
+
/** The outcome of validating an amount. Sent in the `editDonationError` event. */
|
|
24
|
+
export const EditDonationInfoStatus = {
|
|
25
|
+
ValidDonationAmount: 'valid_donation_amount',
|
|
26
|
+
InvalidDonationAmount: 'invalid_donation_amount',
|
|
27
|
+
DonationTooHigh: 'donation_too_high',
|
|
28
|
+
DonationTooLow: 'donation_too_low',
|
|
29
|
+
};
|
|
30
|
+
/** How the one-time / monthly choice is presented. */
|
|
31
|
+
export const EditDonationFrequencySelectionMode = {
|
|
32
|
+
Button: 'button',
|
|
33
|
+
Checkbox: 'checkbox',
|
|
34
|
+
Hide: 'hide',
|
|
35
|
+
};
|
|
36
|
+
/** Whether the amount buttons wrap onto several lines or stay on one. */
|
|
37
|
+
export const EditDonationAmountSelectionLayout = {
|
|
38
|
+
SingleLine: 'single-line',
|
|
39
|
+
MultiLine: 'multi-line',
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The part of the donation form where the donor picks a frequency, an amount
|
|
43
|
+
* (preset or custom) and whether to cover the processing fee. Fires
|
|
44
|
+
* `donationInfoChanged` with the new `DonationPaymentInfo` on every change
|
|
45
|
+
* and `editDonationError` when a custom amount is out of range.
|
|
46
|
+
*
|
|
47
|
+
* The petabox donation banner uses this on its own, without the rest of the
|
|
48
|
+
* form.
|
|
49
|
+
*/
|
|
50
|
+
let IADonationEditDonation = class IADonationEditDonation extends LitElement {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
53
|
+
this.donationInfo = defaultSelectedDonationInfo;
|
|
54
|
+
this.stepNumberMode = EditDonationStepNumberMode.ShowNumbers;
|
|
55
|
+
this.amountOptions = defaultDonationAmounts;
|
|
56
|
+
this.amountSelectionLayout = EditDonationAmountSelectionLayout.MultiLine;
|
|
57
|
+
this.frequencySelectionMode = EditDonationFrequencySelectionMode.Button;
|
|
58
|
+
this.customAmountMode = 'display';
|
|
59
|
+
this.coverFeesCheckboxMode = 'display';
|
|
60
|
+
/** `slot` renders the `edit-donation-amount-title` slot in place of the default headline. */
|
|
61
|
+
this.amountTitleDisplayMode = 'default';
|
|
62
|
+
this.customAmountSelected = false;
|
|
63
|
+
this.currencyValidator = new CurrencyValidator();
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
const amountTitle = this.amountTitleDisplayMode === 'default'
|
|
67
|
+
? msg('Choose an amount (USD)')
|
|
68
|
+
: '';
|
|
69
|
+
return html `
|
|
70
|
+
${this.frequencySelectionMode ===
|
|
71
|
+
EditDonationFrequencySelectionMode.Button
|
|
72
|
+
? this.frequencyButtonsTemplate
|
|
73
|
+
: nothing}
|
|
74
|
+
|
|
75
|
+
<ia-donation-section
|
|
76
|
+
sectionBadge="${this.amountSelectionSectionNumber}"
|
|
77
|
+
headline=${amountTitle}
|
|
78
|
+
badgeMode=${this.formSectionNumberMode}
|
|
79
|
+
>
|
|
80
|
+
${this.amountTitleDisplayMode === 'slot'
|
|
81
|
+
? html `<slot name="edit-donation-amount-title"></slot>`
|
|
82
|
+
: nothing}
|
|
83
|
+
<ul class="amount-selector">
|
|
84
|
+
${this.presetAmountsTemplate}
|
|
85
|
+
${this.customAmountMode === 'display'
|
|
86
|
+
? html `<li class="custom-amount">${this.customAmountTemplate}</li>`
|
|
87
|
+
: nothing}
|
|
88
|
+
</ul>
|
|
89
|
+
|
|
90
|
+
<div class="errors" id="amount-errors" aria-live="polite">
|
|
91
|
+
${this.error}
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
${this.coverFeesCheckboxMode === 'display'
|
|
95
|
+
? html `<div class="checkbox-options">
|
|
96
|
+
${this.coverFeesCheckboxTemplate}
|
|
97
|
+
${this.frequencySelectionMode ===
|
|
98
|
+
EditDonationFrequencySelectionMode.Checkbox
|
|
99
|
+
? this.frequencyCheckboxTemplate
|
|
100
|
+
: nothing}
|
|
101
|
+
</div>`
|
|
102
|
+
: nothing}
|
|
103
|
+
</ia-donation-section>
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
updated(changedProperties) {
|
|
107
|
+
if (changedProperties.has('customAmountSelected')) {
|
|
108
|
+
if (this.customAmountButton) {
|
|
109
|
+
this.customAmountButton.checked = this.customAmountSelected;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (changedProperties.has('amountOptions')) {
|
|
113
|
+
this.customAmountSelected = false;
|
|
114
|
+
this.updateSelectedDonationInfo();
|
|
115
|
+
this.setupAmountColumnsLayoutConfig();
|
|
116
|
+
}
|
|
117
|
+
if (changedProperties.has('amountSelectionLayout')) {
|
|
118
|
+
this.setupAmountColumnsLayoutConfig();
|
|
119
|
+
}
|
|
120
|
+
if (changedProperties.has('donationInfo')) {
|
|
121
|
+
this.updateSelectedDonationInfo();
|
|
122
|
+
}
|
|
123
|
+
if (changedProperties.has('defaultSelectedAmount') &&
|
|
124
|
+
this.defaultSelectedAmount !== undefined) {
|
|
125
|
+
this.customAmountSelected = false;
|
|
126
|
+
this.donationInfo = new DonationPaymentInfo({
|
|
127
|
+
donationType: this.donationInfo.donationType,
|
|
128
|
+
amount: this.defaultSelectedAmount,
|
|
129
|
+
coverFees: this.donationInfo.coverFees,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
get frequencyButtonsTemplate() {
|
|
134
|
+
return html `
|
|
135
|
+
<ia-donation-section
|
|
136
|
+
sectionBadge="1"
|
|
137
|
+
headline=${msg('Choose a frequency')}
|
|
138
|
+
badgeMode=${this.formSectionNumberMode}
|
|
139
|
+
>
|
|
140
|
+
<ul class="frequency-selector">
|
|
141
|
+
${this.frequencyTemplate}
|
|
142
|
+
</ul>
|
|
143
|
+
</ia-donation-section>
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
get frequencyCheckboxTemplate() {
|
|
147
|
+
return html `
|
|
148
|
+
<div class="checkbox-option-container">
|
|
149
|
+
<input
|
|
150
|
+
type="checkbox"
|
|
151
|
+
id="make-this-monthly"
|
|
152
|
+
@input=${this.monthlyCheckboxChecked}
|
|
153
|
+
.checked=${this.donationInfo.donationType === DonationType.Monthly}
|
|
154
|
+
tabindex="0"
|
|
155
|
+
/>
|
|
156
|
+
<label for="make-this-monthly">${msg('Make this monthly')}</label>
|
|
157
|
+
</div>
|
|
158
|
+
`;
|
|
159
|
+
}
|
|
160
|
+
get coverFeesCheckboxTemplate() {
|
|
161
|
+
return html `
|
|
162
|
+
<div class="checkbox-option-container">
|
|
163
|
+
<input
|
|
164
|
+
type="checkbox"
|
|
165
|
+
id="cover-fees"
|
|
166
|
+
@input=${this.coverFeesChecked}
|
|
167
|
+
.checked=${this.donationInfo.coverFees}
|
|
168
|
+
tabindex="0"
|
|
169
|
+
/>
|
|
170
|
+
<label for="cover-fees">${this.coverFeesText}</label>
|
|
171
|
+
</div>
|
|
172
|
+
`;
|
|
173
|
+
}
|
|
174
|
+
/** The amount step is 2 when the frequency buttons come first, otherwise 1. */
|
|
175
|
+
get amountSelectionSectionNumber() {
|
|
176
|
+
return this.frequencySelectionMode ===
|
|
177
|
+
EditDonationFrequencySelectionMode.Button
|
|
178
|
+
? 2
|
|
179
|
+
: 1;
|
|
180
|
+
}
|
|
181
|
+
get formSectionNumberMode() {
|
|
182
|
+
switch (this.stepNumberMode) {
|
|
183
|
+
case EditDonationStepNumberMode.ShowNumbers:
|
|
184
|
+
return DonationSectionBadgeMode.ShowBadge;
|
|
185
|
+
case EditDonationStepNumberMode.HideNumbers:
|
|
186
|
+
return DonationSectionBadgeMode.HideBadge;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Picks the amount grid's column count, and how many columns the custom
|
|
191
|
+
* amount field spans, from how many preset amounts there are.
|
|
192
|
+
*/
|
|
193
|
+
setupAmountColumnsLayoutConfig() {
|
|
194
|
+
const minimalView = this.customAmountMode === 'hide' &&
|
|
195
|
+
this.coverFeesCheckboxMode === 'hide' &&
|
|
196
|
+
this.frequencySelectionMode === EditDonationFrequencySelectionMode.Hide;
|
|
197
|
+
const amountCount = this.amountOptions.length;
|
|
198
|
+
let columnCount = 5;
|
|
199
|
+
let customAmountSpan = 3;
|
|
200
|
+
switch (amountCount) {
|
|
201
|
+
case 7:
|
|
202
|
+
columnCount = 5;
|
|
203
|
+
customAmountSpan = 3;
|
|
204
|
+
break;
|
|
205
|
+
case 6:
|
|
206
|
+
columnCount = 4;
|
|
207
|
+
customAmountSpan = 2;
|
|
208
|
+
break;
|
|
209
|
+
case 5:
|
|
210
|
+
columnCount = 4;
|
|
211
|
+
customAmountSpan = 3;
|
|
212
|
+
break;
|
|
213
|
+
case 4:
|
|
214
|
+
if (minimalView) {
|
|
215
|
+
columnCount = 4;
|
|
216
|
+
customAmountSpan = 0;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
columnCount = 3;
|
|
220
|
+
customAmountSpan = 2;
|
|
221
|
+
break;
|
|
222
|
+
case 3:
|
|
223
|
+
columnCount = 2;
|
|
224
|
+
customAmountSpan = 1;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
if (this.amountSelectionLayout ===
|
|
228
|
+
EditDonationAmountSelectionLayout.SingleLine) {
|
|
229
|
+
columnCount = amountCount + 3;
|
|
230
|
+
customAmountSpan = 3;
|
|
231
|
+
}
|
|
232
|
+
this.style.setProperty('--ia-donation-edit-amount-column-count', `${columnCount}`);
|
|
233
|
+
this.style.setProperty('--ia-donation-edit-custom-amount-col-span', `${customAmountSpan}`);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Syncs the radios and the custom field with `donationInfo`. A preset
|
|
237
|
+
* amount checks its radio and clears the custom field; anything else
|
|
238
|
+
* selects the custom field and formats the amount into it.
|
|
239
|
+
*/
|
|
240
|
+
updateSelectedDonationInfo() {
|
|
241
|
+
// Keep the custom amount selected while the donor is typing in it, even
|
|
242
|
+
// if the value matches a preset, so the selection doesn't jump to the
|
|
243
|
+
// preset radio mid-keystroke.
|
|
244
|
+
// With the custom field hidden both sides would be null, so guard on it
|
|
245
|
+
// existing first.
|
|
246
|
+
const typingInCustomAmount = !!this.customAmountInput &&
|
|
247
|
+
this.shadowRoot?.activeElement === this.customAmountInput;
|
|
248
|
+
if (!this.isCustomAmount &&
|
|
249
|
+
!(this.customAmountSelected && typingInCustomAmount)) {
|
|
250
|
+
const radioButton = this.shadowRoot?.querySelector(`input[type="radio"][name="${EditDonationSelectionGroup.Amount}"][value="${this.donationInfo.amount}"]`);
|
|
251
|
+
if (radioButton)
|
|
252
|
+
radioButton.checked = true;
|
|
253
|
+
this.customAmountSelected = false;
|
|
254
|
+
this.error = undefined;
|
|
255
|
+
if (this.customAmountInput) {
|
|
256
|
+
this.customAmountInput.value = '';
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
this.customAmountSelected = true;
|
|
261
|
+
// Leave the field alone while it has focus, the donor may be typing
|
|
262
|
+
if (!typingInCustomAmount && this.customAmountInput) {
|
|
263
|
+
this.customAmountInput.value = this.customAmountDisplayValue;
|
|
264
|
+
const donationInfoStatus = this.getDonationInfoStatus(this.donationInfo.amount);
|
|
265
|
+
this.handleDonationInfoStatus(donationInfoStatus);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
get coverFeesText() {
|
|
270
|
+
const feeAmountString = currency(this.donationInfo.fee, {
|
|
271
|
+
symbol: '$',
|
|
272
|
+
}).format();
|
|
273
|
+
return msg(str `I'll generously add ${feeAmountString} to cover fees.`);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Formats a dollar amount without cents when it's a whole number and with
|
|
277
|
+
* them when it isn't: `$5` and `$5.50`.
|
|
278
|
+
*/
|
|
279
|
+
formatShortenedAmount(dollars) {
|
|
280
|
+
const precision = dollars % 1 === 0 ? 0 : 2;
|
|
281
|
+
return currency(dollars, { symbol: '$', precision }).format();
|
|
282
|
+
}
|
|
283
|
+
get frequencyTemplate() {
|
|
284
|
+
return html `
|
|
285
|
+
<li>
|
|
286
|
+
${this.getRadioButton({
|
|
287
|
+
group: EditDonationSelectionGroup.DonationType,
|
|
288
|
+
value: DonationType.OneTime,
|
|
289
|
+
displayText: msg('One time'),
|
|
290
|
+
checked: this.donationInfo.donationType === DonationType.OneTime,
|
|
291
|
+
})}
|
|
292
|
+
</li>
|
|
293
|
+
|
|
294
|
+
<li>
|
|
295
|
+
${this.getRadioButton({
|
|
296
|
+
group: EditDonationSelectionGroup.DonationType,
|
|
297
|
+
value: DonationType.Monthly,
|
|
298
|
+
displayText: msg('Monthly'),
|
|
299
|
+
checked: this.donationInfo.donationType === DonationType.Monthly,
|
|
300
|
+
})}
|
|
301
|
+
</li>
|
|
302
|
+
`;
|
|
303
|
+
}
|
|
304
|
+
get presetAmountsTemplate() {
|
|
305
|
+
return html `
|
|
306
|
+
${this.amountOptions.map((amount) => {
|
|
307
|
+
const checked = !this.customAmountSelected && amount === this.donationInfo.amount;
|
|
308
|
+
return html `
|
|
309
|
+
<li>
|
|
310
|
+
${this.getRadioButton({
|
|
311
|
+
group: EditDonationSelectionGroup.Amount,
|
|
312
|
+
value: `${amount}`,
|
|
313
|
+
displayText: this.formatShortenedAmount(amount),
|
|
314
|
+
checked,
|
|
315
|
+
})}
|
|
316
|
+
</li>
|
|
317
|
+
`;
|
|
318
|
+
})}
|
|
319
|
+
`;
|
|
320
|
+
}
|
|
321
|
+
getRadioButton(options) {
|
|
322
|
+
const radioId = `${options.group}-${options.value}-option`;
|
|
323
|
+
return html `
|
|
324
|
+
<div class="selection-button">
|
|
325
|
+
<input
|
|
326
|
+
type="radio"
|
|
327
|
+
name=${options.group}
|
|
328
|
+
value=${options.value}
|
|
329
|
+
id=${radioId}
|
|
330
|
+
tabindex="0"
|
|
331
|
+
.checked=${options.checked}
|
|
332
|
+
@change=${this.radioSelected}
|
|
333
|
+
@click=${(e) => {
|
|
334
|
+
// `change` doesn't fire when the checked radio is clicked again,
|
|
335
|
+
// so re-selecting the current amount is caught here. It matters
|
|
336
|
+
// after a custom amount, which unchecks the presets visually.
|
|
337
|
+
const isAmountSelection = options.group === EditDonationSelectionGroup.Amount;
|
|
338
|
+
if (isAmountSelection) {
|
|
339
|
+
const isSameValue = parseFloat(options.value) === this.donationInfo.amount;
|
|
340
|
+
if (isSameValue) {
|
|
341
|
+
this.radioSelected(e);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}}
|
|
345
|
+
/>
|
|
346
|
+
<label for=${radioId}>${options.displayText}</label>
|
|
347
|
+
</div>
|
|
348
|
+
`;
|
|
349
|
+
}
|
|
350
|
+
get isCustomAmount() {
|
|
351
|
+
return !this.amountOptions.includes(this.donationInfo.amount);
|
|
352
|
+
}
|
|
353
|
+
get customAmountDisplayValue() {
|
|
354
|
+
if (!this.isCustomAmount)
|
|
355
|
+
return '';
|
|
356
|
+
return currency(this.donationInfo.amount, { symbol: '' }).format();
|
|
357
|
+
}
|
|
358
|
+
get customAmountTemplate() {
|
|
359
|
+
return html `
|
|
360
|
+
<div class="selection-button">
|
|
361
|
+
<input
|
|
362
|
+
type="radio"
|
|
363
|
+
name=${EditDonationSelectionGroup.Amount}
|
|
364
|
+
value="custom"
|
|
365
|
+
id="custom-amount-button"
|
|
366
|
+
tabindex="0"
|
|
367
|
+
@change=${this.customRadioSelected}
|
|
368
|
+
/>
|
|
369
|
+
|
|
370
|
+
<label for="custom-amount-button">
|
|
371
|
+
<span class="custom-amount-text">${msg('Custom: $')}</span
|
|
372
|
+
><input
|
|
373
|
+
type="text"
|
|
374
|
+
id="custom-amount-input"
|
|
375
|
+
tabindex="-1"
|
|
376
|
+
aria-label=${msg('Custom amount in dollars')}
|
|
377
|
+
aria-describedby="amount-errors"
|
|
378
|
+
value=${this.customAmountDisplayValue}
|
|
379
|
+
@input=${this.customAmountChanged}
|
|
380
|
+
@keydown=${this.currencyValidator.keydown}
|
|
381
|
+
@focus=${this.customAmountFocused}
|
|
382
|
+
@blur=${this.customAmountBlurred}
|
|
383
|
+
/>
|
|
384
|
+
</label>
|
|
385
|
+
</div>
|
|
386
|
+
`;
|
|
387
|
+
}
|
|
388
|
+
customRadioSelected() {
|
|
389
|
+
this.customAmountInput.focus();
|
|
390
|
+
}
|
|
391
|
+
customAmountFocused(e) {
|
|
392
|
+
const target = e.target;
|
|
393
|
+
this.customAmountSelected = true;
|
|
394
|
+
this.handleCustomAmountInput(target.value);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Once focus leaves the custom field the mid-keystroke protection is over,
|
|
398
|
+
* so the UI re-syncs with `donationInfo`: a typed amount equal to a preset
|
|
399
|
+
* moves to that preset, anything else gets re-formatted in place.
|
|
400
|
+
*/
|
|
401
|
+
customAmountBlurred() {
|
|
402
|
+
this.updateSelectedDonationInfo();
|
|
403
|
+
}
|
|
404
|
+
coverFeesChecked(e) {
|
|
405
|
+
const target = e.target;
|
|
406
|
+
this.updateDonationInfo({ coverFees: target.checked });
|
|
407
|
+
}
|
|
408
|
+
customAmountChanged(e) {
|
|
409
|
+
const target = e.target;
|
|
410
|
+
this.customAmountSelected = true;
|
|
411
|
+
this.handleCustomAmountInput(target.value);
|
|
412
|
+
}
|
|
413
|
+
handleCustomAmountInput(value) {
|
|
414
|
+
const amount = parseFloat(value);
|
|
415
|
+
if (isNaN(amount)) {
|
|
416
|
+
this.dispatchEditDonationError(EditDonationInfoStatus.InvalidDonationAmount);
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
this.amountChanged(amount);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
handleDonationInfoStatus(status) {
|
|
423
|
+
switch (status) {
|
|
424
|
+
case EditDonationInfoStatus.ValidDonationAmount:
|
|
425
|
+
this.error = undefined;
|
|
426
|
+
break;
|
|
427
|
+
case EditDonationInfoStatus.DonationTooHigh:
|
|
428
|
+
this.error = msg(html `
|
|
429
|
+
To make a donation of $10,000 or more, please contact our philanthropy
|
|
430
|
+
department at
|
|
431
|
+
<a href="mailto:donations@archive.org">donations@archive.org</a>
|
|
432
|
+
`);
|
|
433
|
+
this.dispatchEditDonationError(status);
|
|
434
|
+
break;
|
|
435
|
+
case EditDonationInfoStatus.DonationTooLow:
|
|
436
|
+
if (this.customAmountInput.value.length > 0) {
|
|
437
|
+
this.error = html `${msg('Please select an amount (minimum $1)')}`;
|
|
438
|
+
}
|
|
439
|
+
this.dispatchEditDonationError(status);
|
|
440
|
+
break;
|
|
441
|
+
case EditDonationInfoStatus.InvalidDonationAmount:
|
|
442
|
+
this.error = html `${msg('Please enter a valid donation amount')}`;
|
|
443
|
+
this.dispatchEditDonationError(status);
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
amountChanged(amount) {
|
|
448
|
+
const donationInfoStatus = this.getDonationInfoStatus(amount);
|
|
449
|
+
this.handleDonationInfoStatus(donationInfoStatus);
|
|
450
|
+
// Only a valid amount makes it into the donation info
|
|
451
|
+
if (donationInfoStatus === EditDonationInfoStatus.ValidDonationAmount) {
|
|
452
|
+
this.updateDonationInfo({ amount });
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
getDonationInfoStatus(amount) {
|
|
456
|
+
if (isNaN(amount)) {
|
|
457
|
+
return EditDonationInfoStatus.InvalidDonationAmount;
|
|
458
|
+
}
|
|
459
|
+
if (amount >= 10000) {
|
|
460
|
+
return EditDonationInfoStatus.DonationTooHigh;
|
|
461
|
+
}
|
|
462
|
+
if (amount < 1) {
|
|
463
|
+
return EditDonationInfoStatus.DonationTooLow;
|
|
464
|
+
}
|
|
465
|
+
return EditDonationInfoStatus.ValidDonationAmount;
|
|
466
|
+
}
|
|
467
|
+
radioSelected(e) {
|
|
468
|
+
const radioButton = e.target;
|
|
469
|
+
const group = radioButton.name;
|
|
470
|
+
const { value } = radioButton;
|
|
471
|
+
switch (group) {
|
|
472
|
+
case EditDonationSelectionGroup.Amount:
|
|
473
|
+
this.presetAmountChanged(parseFloat(value));
|
|
474
|
+
break;
|
|
475
|
+
case EditDonationSelectionGroup.DonationType:
|
|
476
|
+
this.updateDonationInfo({ donationType: value });
|
|
477
|
+
break;
|
|
478
|
+
default:
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
monthlyCheckboxChecked(e) {
|
|
483
|
+
const isChecked = e.target.checked;
|
|
484
|
+
const donationType = isChecked
|
|
485
|
+
? DonationType.Monthly
|
|
486
|
+
: DonationType.OneTime;
|
|
487
|
+
this.updateDonationInfo({ donationType });
|
|
488
|
+
}
|
|
489
|
+
dispatchEditDonationError(error) {
|
|
490
|
+
const event = new CustomEvent('editDonationError', {
|
|
491
|
+
detail: { error },
|
|
492
|
+
});
|
|
493
|
+
this.dispatchEvent(event);
|
|
494
|
+
}
|
|
495
|
+
presetAmountChanged(amount) {
|
|
496
|
+
this.error = undefined;
|
|
497
|
+
this.customAmountSelected = false;
|
|
498
|
+
if (this.customAmountInput) {
|
|
499
|
+
this.customAmountInput.value = '';
|
|
500
|
+
}
|
|
501
|
+
this.updateDonationInfo({ amount });
|
|
502
|
+
}
|
|
503
|
+
updateDonationInfo(options) {
|
|
504
|
+
const newDonationInfo = new DonationPaymentInfo({
|
|
505
|
+
donationType: options.donationType ?? this.donationInfo.donationType,
|
|
506
|
+
amount: options.amount ?? this.donationInfo.amount,
|
|
507
|
+
coverFees: options.coverFees ?? this.donationInfo.coverFees,
|
|
508
|
+
});
|
|
509
|
+
this.donationInfo = newDonationInfo;
|
|
510
|
+
const event = new CustomEvent('donationInfoChanged', {
|
|
511
|
+
detail: { donationInfo: newDonationInfo },
|
|
512
|
+
});
|
|
513
|
+
this.dispatchEvent(event);
|
|
514
|
+
}
|
|
515
|
+
static get styles() {
|
|
516
|
+
return [
|
|
517
|
+
themeStyles,
|
|
518
|
+
css `
|
|
519
|
+
:host {
|
|
520
|
+
/*
|
|
521
|
+
* The donation form was built for a 10px root font size. Sizing off
|
|
522
|
+
* this base keeps the element self-contained, so it looks the same
|
|
523
|
+
* whatever the page's root size is. Override it to rescale
|
|
524
|
+
* everything, sections included.
|
|
525
|
+
*/
|
|
526
|
+
--donation-edit-base-font-size--: var(
|
|
527
|
+
--ia-donation-edit-base-font-size,
|
|
528
|
+
10px
|
|
529
|
+
);
|
|
530
|
+
|
|
531
|
+
--donation-edit-button-border-color--: var(
|
|
532
|
+
--ia-donation-edit-button-border-color,
|
|
533
|
+
var(--mid-gray)
|
|
534
|
+
);
|
|
535
|
+
--donation-edit-button-grid-gap--: var(
|
|
536
|
+
--ia-donation-edit-button-grid-gap,
|
|
537
|
+
var(--donation-edit-base-font-size--)
|
|
538
|
+
);
|
|
539
|
+
--donation-edit-button-font-size--: var(
|
|
540
|
+
--ia-donation-edit-button-font-size,
|
|
541
|
+
calc(var(--donation-edit-base-font-size--) * 1.6)
|
|
542
|
+
);
|
|
543
|
+
--donation-edit-button-font-color--: var(
|
|
544
|
+
--ia-donation-edit-button-font-color,
|
|
545
|
+
#000
|
|
546
|
+
);
|
|
547
|
+
--donation-edit-button-selected-font-color--: var(
|
|
548
|
+
--ia-donation-edit-button-selected-font-color,
|
|
549
|
+
#000
|
|
550
|
+
);
|
|
551
|
+
--donation-edit-button-selected-color--: var(
|
|
552
|
+
--ia-donation-edit-button-selected-color,
|
|
553
|
+
#f9bf3b
|
|
554
|
+
);
|
|
555
|
+
--donation-edit-button-focused-outline-color--: var(
|
|
556
|
+
--ia-donation-edit-button-focused-outline-color,
|
|
557
|
+
#7fb3f9
|
|
558
|
+
);
|
|
559
|
+
--donation-edit-button-color--: var(
|
|
560
|
+
--ia-donation-edit-button-color,
|
|
561
|
+
var(--true-white)
|
|
562
|
+
);
|
|
563
|
+
--donation-edit-cover-fees-font-size--: var(
|
|
564
|
+
--ia-donation-edit-cover-fees-font-size,
|
|
565
|
+
calc(var(--donation-edit-base-font-size--) * 1.2)
|
|
566
|
+
);
|
|
567
|
+
--donation-edit-cover-fees-font-weight--: var(
|
|
568
|
+
--ia-donation-edit-cover-fees-font-weight,
|
|
569
|
+
bold
|
|
570
|
+
);
|
|
571
|
+
--donation-edit-custom-amount-width--: var(
|
|
572
|
+
--ia-donation-edit-custom-amount-width,
|
|
573
|
+
calc(var(--donation-edit-base-font-size--) * 4)
|
|
574
|
+
);
|
|
575
|
+
--donation-edit-input-font-color--: var(
|
|
576
|
+
--ia-donation-edit-input-font-color,
|
|
577
|
+
var(--mid-gray)
|
|
578
|
+
);
|
|
579
|
+
--donation-edit-input-border--: var(
|
|
580
|
+
--ia-donation-edit-input-border,
|
|
581
|
+
1px solid #d9d9d9
|
|
582
|
+
);
|
|
583
|
+
/* These two are set on the host by the element itself, from the number of amounts */
|
|
584
|
+
--donation-edit-amount-column-count--: var(
|
|
585
|
+
--ia-donation-edit-amount-column-count,
|
|
586
|
+
5
|
|
587
|
+
);
|
|
588
|
+
--donation-edit-custom-amount-col-span--: var(
|
|
589
|
+
--ia-donation-edit-custom-amount-col-span,
|
|
590
|
+
3
|
|
591
|
+
);
|
|
592
|
+
--donation-edit-error-color--: var(--color-danger);
|
|
593
|
+
|
|
594
|
+
/* Passed through to the sections */
|
|
595
|
+
--ia-donation-section-base-font-size: var(
|
|
596
|
+
--donation-edit-base-font-size--
|
|
597
|
+
);
|
|
598
|
+
--ia-donation-section-background-color: var(
|
|
599
|
+
--ia-donation-edit-background-color,
|
|
600
|
+
transparent
|
|
601
|
+
);
|
|
602
|
+
--ia-donation-section-badge-background-color: var(
|
|
603
|
+
--ia-donation-edit-badge-background-color,
|
|
604
|
+
var(--mid-gray)
|
|
605
|
+
);
|
|
606
|
+
--ia-donation-section-badge-font-color: var(
|
|
607
|
+
--ia-donation-edit-badge-font-color,
|
|
608
|
+
var(--true-white)
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.errors {
|
|
613
|
+
color: var(--donation-edit-error-color--);
|
|
614
|
+
font-size: calc(var(--donation-edit-base-font-size--) * 1.4);
|
|
615
|
+
margin-top: var(--padding-sm);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
ul {
|
|
619
|
+
list-style: none;
|
|
620
|
+
margin: 0;
|
|
621
|
+
padding: 0;
|
|
622
|
+
display: grid;
|
|
623
|
+
grid-gap: var(--donation-edit-button-grid-gap--);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
li {
|
|
627
|
+
margin: 0;
|
|
628
|
+
padding: 0;
|
|
629
|
+
display: inline-block;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
.frequency-selector {
|
|
633
|
+
grid-template-columns: repeat(2, 1fr);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
.amount-selector {
|
|
637
|
+
grid-template-columns: repeat(
|
|
638
|
+
var(--donation-edit-amount-column-count--),
|
|
639
|
+
1fr
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
.custom-amount {
|
|
644
|
+
grid-column: span var(--donation-edit-custom-amount-col-span--);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.selection-button {
|
|
648
|
+
height: calc(var(--donation-edit-base-font-size--) * 3);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
.selection-button label {
|
|
652
|
+
padding: 0 calc(var(--donation-edit-base-font-size--) * 0.3);
|
|
653
|
+
display: flex;
|
|
654
|
+
cursor: pointer;
|
|
655
|
+
text-align: center;
|
|
656
|
+
font-size: var(--donation-edit-button-font-size--);
|
|
657
|
+
font-weight: bold;
|
|
658
|
+
border: 1px solid var(--donation-edit-button-border-color--);
|
|
659
|
+
border-radius: 5px;
|
|
660
|
+
height: 100%;
|
|
661
|
+
justify-content: center;
|
|
662
|
+
align-items: center;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
label[for='custom-amount-button'] {
|
|
666
|
+
padding: 0;
|
|
667
|
+
display: flex;
|
|
668
|
+
align-items: center;
|
|
669
|
+
justify-content: center;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
.custom-amount-text {
|
|
673
|
+
white-space: nowrap;
|
|
674
|
+
margin-right: var(--padding-sm);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
input[type='radio'] {
|
|
678
|
+
opacity: 0;
|
|
679
|
+
width: 0;
|
|
680
|
+
height: 0;
|
|
681
|
+
position: absolute;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
input[type='radio'] + label {
|
|
685
|
+
color: var(--donation-edit-button-font-color--);
|
|
686
|
+
background-color: var(--donation-edit-button-color--);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
input[type='radio']:checked + label {
|
|
690
|
+
color: var(--donation-edit-button-selected-font-color--);
|
|
691
|
+
background-color: var(--donation-edit-button-selected-color--);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
input[type='radio']:focus + label {
|
|
695
|
+
outline: 2px solid var(--donation-edit-button-focused-outline-color--);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
.checkbox-options {
|
|
699
|
+
margin-top: var(--donation-edit-base-font-size--);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.checkbox-option-container {
|
|
703
|
+
display: flex;
|
|
704
|
+
align-items: center;
|
|
705
|
+
justify-content: center;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.checkbox-option-container input {
|
|
709
|
+
width: calc(var(--donation-edit-base-font-size--) * 2);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
.checkbox-option-container label {
|
|
713
|
+
font-size: var(--donation-edit-cover-fees-font-size--);
|
|
714
|
+
font-weight: var(--donation-edit-cover-fees-font-weight--);
|
|
715
|
+
flex: 1;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
#custom-amount-input {
|
|
719
|
+
width: var(--donation-edit-custom-amount-width--);
|
|
720
|
+
font-size: var(--donation-edit-button-font-size--);
|
|
721
|
+
font-weight: bold;
|
|
722
|
+
color: var(--donation-edit-input-font-color--);
|
|
723
|
+
padding: calc(var(--donation-edit-base-font-size--) * 0.1);
|
|
724
|
+
border: var(--donation-edit-input-border--);
|
|
725
|
+
appearance: none;
|
|
726
|
+
}
|
|
727
|
+
`,
|
|
728
|
+
];
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
__decorate([
|
|
732
|
+
property({ type: Object })
|
|
733
|
+
], IADonationEditDonation.prototype, "donationInfo", void 0);
|
|
734
|
+
__decorate([
|
|
735
|
+
property({ type: String })
|
|
736
|
+
], IADonationEditDonation.prototype, "stepNumberMode", void 0);
|
|
737
|
+
__decorate([
|
|
738
|
+
property({ type: Number })
|
|
739
|
+
], IADonationEditDonation.prototype, "defaultSelectedAmount", void 0);
|
|
740
|
+
__decorate([
|
|
741
|
+
property({ type: Array })
|
|
742
|
+
], IADonationEditDonation.prototype, "amountOptions", void 0);
|
|
743
|
+
__decorate([
|
|
744
|
+
property({ type: String })
|
|
745
|
+
], IADonationEditDonation.prototype, "amountSelectionLayout", void 0);
|
|
746
|
+
__decorate([
|
|
747
|
+
property({ type: String, reflect: true })
|
|
748
|
+
], IADonationEditDonation.prototype, "frequencySelectionMode", void 0);
|
|
749
|
+
__decorate([
|
|
750
|
+
property({ type: String, reflect: true })
|
|
751
|
+
], IADonationEditDonation.prototype, "customAmountMode", void 0);
|
|
752
|
+
__decorate([
|
|
753
|
+
property({ type: String, reflect: true })
|
|
754
|
+
], IADonationEditDonation.prototype, "coverFeesCheckboxMode", void 0);
|
|
755
|
+
__decorate([
|
|
756
|
+
property({ type: String, reflect: true })
|
|
757
|
+
], IADonationEditDonation.prototype, "amountTitleDisplayMode", void 0);
|
|
758
|
+
__decorate([
|
|
759
|
+
state()
|
|
760
|
+
], IADonationEditDonation.prototype, "error", void 0);
|
|
761
|
+
__decorate([
|
|
762
|
+
state()
|
|
763
|
+
], IADonationEditDonation.prototype, "customAmountSelected", void 0);
|
|
764
|
+
__decorate([
|
|
765
|
+
query('#custom-amount-button')
|
|
766
|
+
], IADonationEditDonation.prototype, "customAmountButton", void 0);
|
|
767
|
+
__decorate([
|
|
768
|
+
query('#custom-amount-input')
|
|
769
|
+
], IADonationEditDonation.prototype, "customAmountInput", void 0);
|
|
770
|
+
IADonationEditDonation = __decorate([
|
|
771
|
+
customElement('ia-donation-edit-donation')
|
|
772
|
+
], IADonationEditDonation);
|
|
773
|
+
export { IADonationEditDonation };
|
|
774
|
+
//# sourceMappingURL=ia-donation-edit-donation.js.map
|