@internetarchive/elements 1.9.1 → 1.9.2
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/README.md +17 -0
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.d.ts.map +1 -1
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js +7 -7
- package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js.map +1 -1
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.d.ts.map +1 -1
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js +6 -6
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.js.map +1 -1
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.d.ts.map +1 -1
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js +5 -4
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-summary.js.map +1 -1
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.d.ts.map +1 -1
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js +5 -4
- package/dist/src/elements/ia-donation-form/form-elements/ia-donation-total-amount.js.map +1 -1
- package/dist/src/elements/ia-donation-form/localized-format.d.ts +20 -0
- package/dist/src/elements/ia-donation-form/localized-format.d.ts.map +1 -0
- package/dist/src/elements/ia-donation-form/localized-format.js +73 -0
- package/dist/src/elements/ia-donation-form/localized-format.js.map +1 -0
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.d.ts.map +1 -1
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js +6 -2
- package/dist/src/elements/ia-donation-form/modals/ia-donation-confirm-modal.js.map +1 -1
- package/dist/src/elements/ia-donation-thermometer/ia-donation-thermometer.d.ts +12 -1
- package/dist/src/elements/ia-donation-thermometer/ia-donation-thermometer.d.ts.map +1 -1
- package/dist/src/elements/ia-donation-thermometer/ia-donation-thermometer.js +21 -9
- package/dist/src/elements/ia-donation-thermometer/ia-donation-thermometer.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -342,6 +342,23 @@ export const templates = { ...elements, ...app };
|
|
|
342
342
|
|
|
343
343
|
The XLIFF in `xliff/` is where translations are edited. It isn't published.
|
|
344
344
|
|
|
345
|
+
#### Drafting and reviewing translations
|
|
346
|
+
|
|
347
|
+
`pnpm run i18n:status` lists each locale's missing translations and the drafts still waiting on a native speaker. CI runs it on every PR and only warns.
|
|
348
|
+
|
|
349
|
+
To fill the gaps:
|
|
350
|
+
|
|
351
|
+
```zsh
|
|
352
|
+
pnpm run i18n:draft --locale es --export pending.es.json # extract, then write {id: text} for the missing strings
|
|
353
|
+
pnpm run i18n:draft --locale es --from translations.es.json # write translations of the same shape
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
`{0}` tokens are placeholders and have to stay in the translation. A unit that loses one is skipped and reported. Written translations are drafts, saved as `<target state="needs-review-translation">`.
|
|
357
|
+
|
|
358
|
+
A native speaker reviews each draft, fixes the `<target>` if needed, and sets `state="final"` (or deletes the attribute). Don't ship a language to everyone before its drafts have been reviewed.
|
|
359
|
+
|
|
360
|
+
To add a language, add its code to `targetLocales` in `lit-localize.json`, run `pnpm run strings:extract` to create `xliff/<locale>.xlf`, draft it as above, then run `pnpm run strings:build`.
|
|
361
|
+
|
|
345
362
|
## Icons
|
|
346
363
|
|
|
347
364
|
SVG sources live in `icons/<kebab-name>.svg`. To add one, drop the file in that folder and run `pnpm run icons` (`build`, `dev`, `typecheck` and `test` run it for you). The root `<svg>` needs a `viewBox`. The build fails on a name that isn't kebab-case, a duplicate, or a missing `viewBox`. It writes `src/icons/` (gitignored), one `.ts` and one `.svg` per icon.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-contact-form.d.ts","sourceRoot":"","sources":["../../../../../../src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAMb,OAAO,EACL,WAAW,EACX,YAAY,EACZ,gBAAgB,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"ia-donation-contact-form.d.ts","sourceRoot":"","sources":["../../../../../../src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAMb,OAAO,EACL,WAAW,EACX,YAAY,EACZ,gBAAgB,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AAMrC;;;;;;;GAOG;AACH,qBAEa,qBAAsB,SAAQ,UAAU;IAEnD,gBAAgB,EAAG,qBAAqB,CAAC;IACF,UAAU,EAAG,gBAAgB,CAAC;IAGrE,oBAAoB,EAAG,qBAAqB,CAAC;IACD,cAAc,EAAG,gBAAgB,CAAC;IAG9E,mBAAmB,EAAG,qBAAqB,CAAC;IACD,aAAa,EAAG,gBAAgB,CAAC;IAG5E,iBAAiB,EAAG,qBAAqB,CAAC;IAE1C,eAAe,EAAG,gBAAgB,CAAC;IAGnC,wBAAwB,EAAG,qBAAqB,CAAC;IAEjD,kBAAkB,EAAG,gBAAgB,CAAC;IAGtC,mBAAmB,EAAG,qBAAqB,CAAC;IACF,aAAa,EAAG,gBAAgB,CAAC;IAG3E,iBAAiB,EAAG,qBAAqB,CAAC;IACF,WAAW,EAAG,gBAAgB,CAAC;IAGvE,sBAAsB,EAAG,iBAAiB,CAAC;IAEI,YAAY,EAAG,cAAc,CAAC;IAC9D,IAAI,EAAG,eAAe,CAAC;IAEtC,yEAAyE;IAC7C,eAAe,SAAQ;IAEnD,uDAAuD;IAC3B,UAAU,SAAM;IAE5C,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAMtC,mFAAmF;IACnF,cAAc,IAAI,OAAO;IAKzB,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,YAAY;IAUpB,KAAK,IAAI,IAAI;IAIb,6CAA6C;IAC7C,OAAO,CAAC,iBAAiB,CAAiB;IAC1C,OAAO,KAAK,2BAA2B,GAEtC;IAED,uFAAuF;IACvF,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,KAAK,8BAA8B,GAEzC;IAED,qCAAqC;IACrC,OAAO,CAAC,gBAAgB,CAAyB;IACjD,OAAO,KAAK,0BAA0B,GAErC;IAED,MAAM,IAAI,cAAc;IAgGxB,OAAO,KAAK,2BAA2B,GAEtC;IAED,OAAO,KAAK,uBAAuB,GAkClC;IAED,0DAA0D;IAC1D,gBAAgB,IAAI,IAAI;IAIxB,kEAAkE;IAClE,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,aAAa;IA6CrB,IAAI,gBAAgB,IAAI,gBAAgB,CAKvC;IAED,IAAI,WAAW,IAAI,WAAW,CAQ7B;IAED,IAAI,WAAW,IAAI,YAAY,CAM9B;IAED;;;;OAIG;IACH,OAAO,KAAK,SAAS,GA6IpB;CACF"}
|
package/dist/src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.js
CHANGED
|
@@ -3,11 +3,13 @@ import { css, html, LitElement, nothing, } from 'lit';
|
|
|
3
3
|
import { property, query } from 'lit/decorators.js';
|
|
4
4
|
import { customElement } from '../../../../utils/custom-element.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
|
-
import { msg } from '@lit/localize';
|
|
6
|
+
import { localized, msg } from '@lit/localize';
|
|
7
7
|
import { BillingInfo, CustomerInfo, DonorContactInfo, } from '../../models/donor-contact-info.js';
|
|
8
8
|
import { SpacerOption, } from '../ia-donation-badged-input.js';
|
|
9
9
|
import '../ia-donation-badged-input.js';
|
|
10
10
|
import { countries } from './countries.js';
|
|
11
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
12
|
+
import { localizedCountries } from '../../localized-format.js';
|
|
11
13
|
/**
|
|
12
14
|
* The donor's name, email and billing address.
|
|
13
15
|
*
|
|
@@ -199,14 +201,11 @@ let IADonationContactForm = class IADonationContactForm extends LitElement {
|
|
|
199
201
|
this.selectedCountry = newValue;
|
|
200
202
|
}}
|
|
201
203
|
>
|
|
202
|
-
${
|
|
203
|
-
const name = countries[key];
|
|
204
|
-
return html `
|
|
204
|
+
${repeat(localizedCountries(), ([key]) => key, ([key, name]) => html `
|
|
205
205
|
<option value=${key} ?selected=${key === this.selectedCountry}>
|
|
206
206
|
${name}
|
|
207
207
|
</option>
|
|
208
|
-
|
|
209
|
-
})}
|
|
208
|
+
`)}
|
|
210
209
|
</select>
|
|
211
210
|
</ia-donation-badged-input>
|
|
212
211
|
</div>
|
|
@@ -483,7 +482,8 @@ __decorate([
|
|
|
483
482
|
property({ type: String })
|
|
484
483
|
], IADonationContactForm.prototype, "donorEmail", void 0);
|
|
485
484
|
IADonationContactForm = __decorate([
|
|
486
|
-
customElement('ia-donation-contact-form')
|
|
485
|
+
customElement('ia-donation-contact-form'),
|
|
486
|
+
localized()
|
|
487
487
|
], IADonationContactForm);
|
|
488
488
|
export { IADonationContactForm };
|
|
489
489
|
//# sourceMappingURL=ia-donation-contact-form.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-contact-form.js","sourceRoot":"","sources":["../../../../../../src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,C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B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsFjC,CAAC;IACJ,CAAC;CACF,CAAA;AA5dC;IADC,KAAK,CAAC,sDAAsD,CAAC;+DACrB;AACF;IAAtC,KAAK,CAAC,8BAA8B,CAAC;yDAA+B;AAGrE;IADC,KAAK,CAAC,2DAA2D,CAAC;mEACtB;AACD;IAA3C,KAAK,CAAC,mCAAmC,CAAC;6DAAmC;AAG9E;IADC,KAAK,CAAC,0DAA0D,CAAC;kEACtB;AACD;IAA1C,KAAK,CAAC,kCAAkC,CAAC;4DAAkC;AAG5E;IADC,KAAK,CAAC,4DAA4D,CAAC;gEAC1B;AAE1C;IADC,KAAK,CAAC,oCAAoC,CAAC;8DACT;AAGnC;IADC,KAAK,CAAC,+DAA+D,CAAC;uEACtB;AAEjD;IADC,KAAK,CAAC,uCAAuC,CAAC;iEACT;AAGtC;IADC,KAAK,CAAC,yDAAyD,CAAC;kEACrB;AACF;IAAzC,KAAK,CAAC,iCAAiC,CAAC;4DAAkC;AAG3E;IADC,KAAK,CAAC,uDAAuD,CAAC;gEACrB;AACF;IAAvC,KAAK,CAAC,+BAA+B,CAAC;0DAAgC;AAGvE;IADC,KAAK,CAAC,0CAA0C,CAAC;qEACP;AAEI;IAA9C,KAAK,CAAC,sCAAsC,CAAC;2DAA+B;AAC9D;IAAd,KAAK,CAAC,MAAM,CAAC;mDAAwB;AAGV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAwB;AAGvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAiB;AAzCjC,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CA8djC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { msg } from '@lit/localize';\n\nimport {\n BillingInfo,\n CustomerInfo,\n DonorContactInfo,\n} from '../../models/donor-contact-info';\nimport {\n SpacerOption,\n type IADonationBadgedInput,\n} from '../ia-donation-badged-input';\nimport '../ia-donation-badged-input';\nimport type { AutoCompleteFieldOptions } from './autocomplete-field-options';\nimport { countries } from './countries';\n\n/**\n * The donor's name, email and billing address.\n *\n * This renders into the light DOM, not a shadow root: browser autofill\n * doesn't reach into shadow DOM, and autofill matters a lot on a donation\n * form. So its styles are a `<style>` block with every selector prefixed by\n * the tag name, and its field ids are unique across the page.\n */\n@customElement('ia-donation-contact-form')\nexport class IADonationContactForm extends LitElement {\n @query('ia-donation-badged-input.donation-contact-form-email')\n emailBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-email') emailField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-first-name')\n firstNameBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-first-name') firstNameField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-last-name')\n lastNameBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-last-name') lastNameField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-postal-code')\n postalBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-postal-code')\n postalCodeField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-street-address')\n streetAddressBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-street-address')\n streetAddressField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-locality')\n localityBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-locality') localityField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-region')\n regionBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-region') regionField!: HTMLInputElement;\n\n @query('#donation-contact-form-countryCodeAlpha2')\n countryCodeAlpha2Field!: HTMLSelectElement;\n\n @query('#donation-contact-form-error-message') errorMessage!: HTMLDivElement;\n @query('form') form!: HTMLFormElement;\n\n /** A key of `countries`. US addresses require a state and a zip code. */\n @property({ type: String }) selectedCountry = 'US';\n\n /** Pre-fills the email field, for a logged-in donor */\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 /** Validates every field, marks the bad ones, and shows the browser's messages. */\n reportValidity(): boolean {\n this.validateFormFields();\n return this.validateForm();\n }\n\n private validateFormFields(): void {\n const fields: {\n badgedInput: IADonationBadgedInput;\n inputField: HTMLInputElement;\n }[] = [\n { badgedInput: this.emailBadgedInput, inputField: this.emailField },\n {\n badgedInput: this.firstNameBadgedInput,\n inputField: this.firstNameField,\n },\n { badgedInput: this.lastNameBadgedInput, inputField: this.lastNameField },\n {\n badgedInput: this.streetAddressBadgedInput,\n inputField: this.streetAddressField,\n },\n { badgedInput: this.localityBadgedInput, inputField: this.localityField },\n { badgedInput: this.regionBadgedInput, inputField: this.regionField },\n { badgedInput: this.postalBadgedInput, inputField: this.postalCodeField },\n ];\n fields.forEach(({ badgedInput, inputField }) => {\n badgedInput.error = !inputField.checkValidity();\n });\n }\n\n private validateForm(): boolean {\n const isValid = this.form.reportValidity();\n\n this.errorMessage.textContent = isValid\n ? ''\n : msg('Please enter any missing or invalid contact information below');\n\n return isValid;\n }\n\n focus(): void {\n this.emailField.focus();\n }\n\n /** At least two non-whitespace characters */\n private minTwoCharPattern = '.*\\\\S{2,}.*';\n private get minTwoCharValidationMessage(): string {\n return msg('Enter at least two characters');\n }\n\n /** At least two non-whitespace characters with at least two characters between them */\n private streetAddressPattern = '.*?\\\\S.{2,}\\\\S.*?';\n private get streetAddressValidationMessage(): string {\n return msg('Enter at least four characters');\n }\n\n /** 12345, 12345-6789 or 123456789 */\n private usZipCodePattern = '^\\\\d{5}(-?\\\\d{4})?$';\n private get usZipCodeValidationMessage(): string {\n return msg('Enter a valid 5 or 9 digit zip/postal code');\n }\n\n render(): TemplateResult {\n return html`\n <div id=\"donation-contact-form-error-message\"></div>\n <form>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-email',\n label: msg('Email'),\n required: true,\n fieldType: 'email',\n name: 'email',\n autocomplete: 'email',\n minlength: 5,\n maxlength: 255,\n })}\n </div>\n\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-first-name',\n label: msg('First name'),\n name: 'fname',\n required: true,\n validationPattern: this.minTwoCharPattern,\n validationMessage: this.minTwoCharValidationMessage,\n maxlength: 255,\n autocomplete: 'given-name',\n })}\n ${this.generateInput({\n id: 'donation-contact-form-last-name',\n label: msg('Last name'),\n name: 'lname',\n autocomplete: 'family-name',\n required: true,\n validationPattern: this.minTwoCharPattern,\n validationMessage: this.minTwoCharValidationMessage,\n maxlength: 255,\n })}\n </div>\n\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-street-address',\n label: msg('Address'),\n required: true,\n autocomplete: 'address-line1',\n name: 'street-address',\n validationPattern: this.streetAddressPattern,\n validationMessage: this.streetAddressValidationMessage,\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-locality',\n label: msg('City'),\n autocomplete: 'address-level2',\n required: true,\n name: 'locality',\n validationPattern: this.minTwoCharPattern,\n validationMessage: this.minTwoCharValidationMessage,\n })}\n </div>\n <div class=\"row\">${this.countrySelectorTemplate}</div>\n <div class=\"row region-postal-row\">\n ${this.generateInput({\n id: 'donation-contact-form-region',\n label: msg('State / Province'),\n autocomplete: 'address-level1',\n required: this.regionAndPostalCodeRequired,\n name: 'region',\n validationPattern: this.regionAndPostalCodeRequired\n ? this.minTwoCharPattern\n : undefined,\n validationMessage: this.regionAndPostalCodeRequired\n ? this.minTwoCharValidationMessage\n : undefined,\n })}\n ${this.generateInput({\n id: 'donation-contact-form-postal-code',\n label: msg('Zip / Postal Code'),\n autocomplete: 'postal-code',\n required: this.regionAndPostalCodeRequired,\n name: 'postal',\n validationPattern: this.regionAndPostalCodeRequired\n ? this.usZipCodePattern\n : undefined,\n validationMessage: this.regionAndPostalCodeRequired\n ? this.usZipCodeValidationMessage\n : undefined,\n })}\n </div>\n </form>\n ${this.getStyles}\n `;\n }\n\n private get regionAndPostalCodeRequired(): boolean {\n return this.selectedCountry === 'US';\n }\n\n private get countrySelectorTemplate(): TemplateResult {\n return html`\n <div class=\"field\">\n <label\n for=\"donation-contact-form-countryCodeAlpha2\"\n class=\"field-label\"\n >\n ${msg('Country')}<span class=\"required-asterisk\"> *</span>\n </label>\n <ia-donation-badged-input\n .iconSpaceOption=${SpacerOption.CompressSpace}\n >\n <select\n id=\"donation-contact-form-countryCodeAlpha2\"\n name=\"country\"\n autocomplete=\"country\"\n @change=${(e: Event) => {\n const newValue = (e.target as HTMLSelectElement).value;\n if (countries[newValue]) this.selectedCountry = newValue;\n }}\n >\n ${Object.keys(countries).map((key) => {\n const name = countries[key];\n return html`\n <option value=${key} ?selected=${key === this.selectedCountry}>\n ${name}\n </option>\n `;\n })}\n </select>\n </ia-donation-badged-input>\n </div>\n `;\n }\n\n /** Light DOM, so browser autofill can reach the fields */\n createRenderRoot(): this {\n return this;\n }\n\n /** Clears the error state once the donor starts fixing a field */\n private inputChanged(e: Event): void {\n this.errorMessage.textContent = '';\n const input = e.target as HTMLInputElement;\n const badgedInput = this.querySelector<IADonationBadgedInput>(\n `ia-donation-badged-input.${input.id}`,\n );\n if (badgedInput) badgedInput.error = false;\n }\n\n private generateInput(options: {\n id: string;\n label: string;\n required?: boolean;\n fieldType?: 'text' | 'email';\n autocomplete?: AutoCompleteFieldOptions;\n minlength?: number;\n maxlength?: number;\n name: string;\n validationPattern?: string;\n validationMessage?: string;\n }): TemplateResult {\n const required = options.required ?? true;\n const fieldType = options.fieldType ?? 'text';\n\n return html`\n <div class=\"field ${options.id}\">\n <label for=${options.id} class=\"field-label\">\n ${options.label}${required\n ? html`<span class=\"required-asterisk\"> *</span>`\n : nothing}\n </label>\n <ia-donation-badged-input\n class=${options.id}\n .iconSpaceOption=${SpacerOption.CompressSpace}\n .requiredIndicatorSpaceOption=${SpacerOption.CompressSpace}\n >\n <input\n type=${fieldType}\n id=${options.id}\n class=\"donation-contact-form-input\"\n name=${options.name}\n maxlength=${ifDefined(options.maxlength)}\n minlength=${ifDefined(options.minlength)}\n autocomplete=${options.autocomplete ?? 'on'}\n pattern=${ifDefined(options.validationPattern)}\n title=${ifDefined(options.validationMessage)}\n @input=${this.inputChanged}\n ?required=${required}\n />\n </ia-donation-badged-input>\n </div>\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 return new BillingInfo({\n streetAddress: this.streetAddressField.value,\n locality: this.localityField.value,\n region: this.regionField.value,\n postalCode: this.postalCodeField.value,\n countryCodeAlpha2: this.countryCodeAlpha2Field.value,\n });\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 * The element renders into the light DOM, so instead of a `styles` block\n * it writes its own `<style>` tag, with every selector prefixed by the tag\n * name so nothing leaks onto the rest of the page.\n */\n private get getStyles(): TemplateResult {\n const noIconSpacerWidth = css`var(--ia-donation-badged-input-no-icon-spacer-width, calc(var(--donation-contact-base-font-size--) * 3))`;\n\n return html`\n <style>\n ia-donation-contact-form {\n --donation-contact-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-contact-row-gap--: var(\n --ia-donation-field-row-gap,\n calc(var(--donation-contact-base-font-size--) * 0.5)\n );\n --donation-contact-field-font-family--: var(\n --ia-theme-base-font-family,\n 'Helvetica Neue',\n Helvetica,\n Arial,\n sans-serif\n );\n --donation-contact-field-font-size--: var(\n --ia-donation-contact-field-font-size,\n calc(var(--donation-contact-base-font-size--) * 1.4)\n );\n --donation-contact-field-font-color--: var(\n --ia-donation-form-input-font-color,\n #2c2c2c\n );\n --donation-contact-label-font-family--: var(\n --ia-donation-field-label-font-family,\n var(--donation-contact-field-font-family--)\n );\n --donation-contact-label-font-size--: var(\n --ia-donation-field-label-font-size,\n calc(var(--donation-contact-base-font-size--) * 1.4)\n );\n --donation-contact-label-color--: var(\n --ia-donation-field-label-color,\n #2c2c2c\n );\n --donation-contact-label-margin-bottom--: var(\n --ia-donation-field-label-margin-bottom,\n calc(var(--donation-contact-base-font-size--) * 0.5)\n );\n --donation-contact-required-color--: var(\n --ia-donation-badged-input-required-color,\n var(--ia-theme-color-danger, #e51c23)\n );\n --donation-contact-error-color--: var(\n --ia-theme-color-danger,\n #e51c23\n );\n --donation-contact-no-icon-field-width--: calc(\n 100% - ${noIconSpacerWidth}\n );\n }\n\n /*\n A grid, so a label that wraps to two lines in one column doesn't push\n that column's input out of line with its siblings. All labels share\n row line 1 and all inputs share row line 2, each sized to the tallest\n content on its line.\n */\n ia-donation-contact-form .row {\n display: grid;\n grid-auto-flow: column;\n grid-auto-columns: 1fr;\n grid-template-rows: auto auto;\n column-gap: var(--donation-contact-row-gap--);\n }\n\n /*\n State / Province gives up room to Zip / Postal Code so the\n \"Zip / Postal Code *\" label stays on one line.\n */\n ia-donation-contact-form .row.region-postal-row {\n grid-template-columns:\n calc(60% - var(--donation-contact-base-font-size--) * 3)\n calc(40% + var(--donation-contact-base-font-size--) * 3);\n }\n\n ia-donation-contact-form .row + .row {\n margin-top: var(--donation-contact-row-gap--);\n }\n\n ia-donation-contact-form .field {\n display: contents;\n }\n\n ia-donation-contact-form .field-label {\n display: block;\n font-family: var(--donation-contact-label-font-family--);\n font-size: var(--donation-contact-label-font-size--);\n font-weight: bold;\n color: var(--donation-contact-label-color--);\n margin-bottom: var(--donation-contact-label-margin-bottom--);\n }\n\n ia-donation-contact-form .required-asterisk {\n color: var(--donation-contact-required-color--);\n }\n\n ia-donation-contact-form\n ia-donation-badged-input.donation-contact-form-region,\n ia-donation-contact-form\n ia-donation-badged-input.donation-contact-form-postal-code {\n width: 100%;\n }\n\n ia-donation-contact-form #donation-contact-form-error-message {\n color: var(--donation-contact-error-color--);\n font-size: calc(var(--donation-contact-base-font-size--) * 1.4);\n margin-bottom: calc(var(--donation-contact-base-font-size--) * 0.6);\n }\n\n ia-donation-contact-form .donation-contact-form-input {\n width: var(--donation-contact-no-icon-field-width--);\n border: 0;\n outline: 0;\n background: transparent;\n font-weight: bold;\n color: var(--donation-contact-field-font-color--);\n font-size: var(--donation-contact-field-font-size--);\n padding: 0;\n font-family: var(--donation-contact-field-font-family--);\n }\n\n ia-donation-contact-form #donation-contact-form-countryCodeAlpha2 {\n width: var(--donation-contact-no-icon-field-width--);\n height: 100%;\n box-sizing: border-box;\n font-weight: bold;\n font-size: var(--donation-contact-field-font-size--);\n color: var(--donation-contact-field-font-color--);\n font-family: var(--donation-contact-field-font-family--);\n border: 0;\n background: #fff;\n }\n </style>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ia-donation-contact-form.js","sourceRoot":"","sources":["../../../../../../src/elements/ia-donation-form/form-elements/contact-form/ia-donation-contact-form.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EACL,WAAW,EACX,YAAY,EACZ,gBAAgB,GACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,YAAY,GAEb,MAAM,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AAErC,OAA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E;IADC,KAAK,CAAC,2DAA2D,CAAC;mEACtB;AACD;IAA3C,KAAK,CAAC,mCAAmC,CAAC;6DAAmC;AAG9E;IADC,KAAK,CAAC,0DAA0D,CAAC;kEACtB;AACD;IAA1C,KAAK,CAAC,kCAAkC,CAAC;4DAAkC;AAG5E;IADC,KAAK,CAAC,4DAA4D,CAAC;gEAC1B;AAE1C;IADC,KAAK,CAAC,oCAAoC,CAAC;8DACT;AAGnC;IADC,KAAK,CAAC,+DAA+D,CAAC;uEACtB;AAEjD;IADC,KAAK,CAAC,uCAAuC,CAAC;iEACT;AAGtC;IADC,KAAK,CAAC,yDAAyD,CAAC;kEACrB;AACF;IAAzC,KAAK,CAAC,iCAAiC,CAAC;4DAAkC;AAG3E;IADC,KAAK,CAAC,uDAAuD,CAAC;gEACrB;AACF;IAAvC,KAAK,CAAC,+BAA+B,CAAC;0DAAgC;AAGvE;IADC,KAAK,CAAC,0CAA0C,CAAC;qEACP;AAEI;IAA9C,KAAK,CAAC,sCAAsC,CAAC;2DAA+B;AAC9D;IAAd,KAAK,CAAC,MAAM,CAAC;mDAAwB;AAGV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAwB;AAGvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAiB;AAzCjC,qBAAqB;IAFjC,aAAa,CAAC,0BAA0B,CAAC;IACzC,SAAS,EAAE;GACC,qBAAqB,CA+djC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { localized, msg } from '@lit/localize';\n\nimport {\n BillingInfo,\n CustomerInfo,\n DonorContactInfo,\n} from '../../models/donor-contact-info';\nimport {\n SpacerOption,\n type IADonationBadgedInput,\n} from '../ia-donation-badged-input';\nimport '../ia-donation-badged-input';\nimport type { AutoCompleteFieldOptions } from './autocomplete-field-options';\nimport { countries } from './countries';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { localizedCountries } from '../../localized-format';\n\n/**\n * The donor's name, email and billing address.\n *\n * This renders into the light DOM, not a shadow root: browser autofill\n * doesn't reach into shadow DOM, and autofill matters a lot on a donation\n * form. So its styles are a `<style>` block with every selector prefixed by\n * the tag name, and its field ids are unique across the page.\n */\n@customElement('ia-donation-contact-form')\n@localized()\nexport class IADonationContactForm extends LitElement {\n @query('ia-donation-badged-input.donation-contact-form-email')\n emailBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-email') emailField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-first-name')\n firstNameBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-first-name') firstNameField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-last-name')\n lastNameBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-last-name') lastNameField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-postal-code')\n postalBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-postal-code')\n postalCodeField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-street-address')\n streetAddressBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-street-address')\n streetAddressField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-locality')\n localityBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-locality') localityField!: HTMLInputElement;\n\n @query('ia-donation-badged-input.donation-contact-form-region')\n regionBadgedInput!: IADonationBadgedInput;\n @query('#donation-contact-form-region') regionField!: HTMLInputElement;\n\n @query('#donation-contact-form-countryCodeAlpha2')\n countryCodeAlpha2Field!: HTMLSelectElement;\n\n @query('#donation-contact-form-error-message') errorMessage!: HTMLDivElement;\n @query('form') form!: HTMLFormElement;\n\n /** A key of `countries`. US addresses require a state and a zip code. */\n @property({ type: String }) selectedCountry = 'US';\n\n /** Pre-fills the email field, for a logged-in donor */\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 /** Validates every field, marks the bad ones, and shows the browser's messages. */\n reportValidity(): boolean {\n this.validateFormFields();\n return this.validateForm();\n }\n\n private validateFormFields(): void {\n const fields: {\n badgedInput: IADonationBadgedInput;\n inputField: HTMLInputElement;\n }[] = [\n { badgedInput: this.emailBadgedInput, inputField: this.emailField },\n {\n badgedInput: this.firstNameBadgedInput,\n inputField: this.firstNameField,\n },\n { badgedInput: this.lastNameBadgedInput, inputField: this.lastNameField },\n {\n badgedInput: this.streetAddressBadgedInput,\n inputField: this.streetAddressField,\n },\n { badgedInput: this.localityBadgedInput, inputField: this.localityField },\n { badgedInput: this.regionBadgedInput, inputField: this.regionField },\n { badgedInput: this.postalBadgedInput, inputField: this.postalCodeField },\n ];\n fields.forEach(({ badgedInput, inputField }) => {\n badgedInput.error = !inputField.checkValidity();\n });\n }\n\n private validateForm(): boolean {\n const isValid = this.form.reportValidity();\n\n this.errorMessage.textContent = isValid\n ? ''\n : msg('Please enter any missing or invalid contact information below');\n\n return isValid;\n }\n\n focus(): void {\n this.emailField.focus();\n }\n\n /** At least two non-whitespace characters */\n private minTwoCharPattern = '.*\\\\S{2,}.*';\n private get minTwoCharValidationMessage(): string {\n return msg('Enter at least two characters');\n }\n\n /** At least two non-whitespace characters with at least two characters between them */\n private streetAddressPattern = '.*?\\\\S.{2,}\\\\S.*?';\n private get streetAddressValidationMessage(): string {\n return msg('Enter at least four characters');\n }\n\n /** 12345, 12345-6789 or 123456789 */\n private usZipCodePattern = '^\\\\d{5}(-?\\\\d{4})?$';\n private get usZipCodeValidationMessage(): string {\n return msg('Enter a valid 5 or 9 digit zip/postal code');\n }\n\n render(): TemplateResult {\n return html`\n <div id=\"donation-contact-form-error-message\"></div>\n <form>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-email',\n label: msg('Email'),\n required: true,\n fieldType: 'email',\n name: 'email',\n autocomplete: 'email',\n minlength: 5,\n maxlength: 255,\n })}\n </div>\n\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-first-name',\n label: msg('First name'),\n name: 'fname',\n required: true,\n validationPattern: this.minTwoCharPattern,\n validationMessage: this.minTwoCharValidationMessage,\n maxlength: 255,\n autocomplete: 'given-name',\n })}\n ${this.generateInput({\n id: 'donation-contact-form-last-name',\n label: msg('Last name'),\n name: 'lname',\n autocomplete: 'family-name',\n required: true,\n validationPattern: this.minTwoCharPattern,\n validationMessage: this.minTwoCharValidationMessage,\n maxlength: 255,\n })}\n </div>\n\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-street-address',\n label: msg('Address'),\n required: true,\n autocomplete: 'address-line1',\n name: 'street-address',\n validationPattern: this.streetAddressPattern,\n validationMessage: this.streetAddressValidationMessage,\n })}\n </div>\n <div class=\"row\">\n ${this.generateInput({\n id: 'donation-contact-form-locality',\n label: msg('City'),\n autocomplete: 'address-level2',\n required: true,\n name: 'locality',\n validationPattern: this.minTwoCharPattern,\n validationMessage: this.minTwoCharValidationMessage,\n })}\n </div>\n <div class=\"row\">${this.countrySelectorTemplate}</div>\n <div class=\"row region-postal-row\">\n ${this.generateInput({\n id: 'donation-contact-form-region',\n label: msg('State / Province'),\n autocomplete: 'address-level1',\n required: this.regionAndPostalCodeRequired,\n name: 'region',\n validationPattern: this.regionAndPostalCodeRequired\n ? this.minTwoCharPattern\n : undefined,\n validationMessage: this.regionAndPostalCodeRequired\n ? this.minTwoCharValidationMessage\n : undefined,\n })}\n ${this.generateInput({\n id: 'donation-contact-form-postal-code',\n label: msg('Zip / Postal Code'),\n autocomplete: 'postal-code',\n required: this.regionAndPostalCodeRequired,\n name: 'postal',\n validationPattern: this.regionAndPostalCodeRequired\n ? this.usZipCodePattern\n : undefined,\n validationMessage: this.regionAndPostalCodeRequired\n ? this.usZipCodeValidationMessage\n : undefined,\n })}\n </div>\n </form>\n ${this.getStyles}\n `;\n }\n\n private get regionAndPostalCodeRequired(): boolean {\n return this.selectedCountry === 'US';\n }\n\n private get countrySelectorTemplate(): TemplateResult {\n return html`\n <div class=\"field\">\n <label\n for=\"donation-contact-form-countryCodeAlpha2\"\n class=\"field-label\"\n >\n ${msg('Country')}<span class=\"required-asterisk\"> *</span>\n </label>\n <ia-donation-badged-input\n .iconSpaceOption=${SpacerOption.CompressSpace}\n >\n <select\n id=\"donation-contact-form-countryCodeAlpha2\"\n name=\"country\"\n autocomplete=\"country\"\n @change=${(e: Event) => {\n const newValue = (e.target as HTMLSelectElement).value;\n if (countries[newValue]) this.selectedCountry = newValue;\n }}\n >\n ${repeat(\n localizedCountries(),\n ([key]) => key,\n ([key, name]) => html`\n <option value=${key} ?selected=${key === this.selectedCountry}>\n ${name}\n </option>\n `,\n )}\n </select>\n </ia-donation-badged-input>\n </div>\n `;\n }\n\n /** Light DOM, so browser autofill can reach the fields */\n createRenderRoot(): this {\n return this;\n }\n\n /** Clears the error state once the donor starts fixing a field */\n private inputChanged(e: Event): void {\n this.errorMessage.textContent = '';\n const input = e.target as HTMLInputElement;\n const badgedInput = this.querySelector<IADonationBadgedInput>(\n `ia-donation-badged-input.${input.id}`,\n );\n if (badgedInput) badgedInput.error = false;\n }\n\n private generateInput(options: {\n id: string;\n label: string;\n required?: boolean;\n fieldType?: 'text' | 'email';\n autocomplete?: AutoCompleteFieldOptions;\n minlength?: number;\n maxlength?: number;\n name: string;\n validationPattern?: string;\n validationMessage?: string;\n }): TemplateResult {\n const required = options.required ?? true;\n const fieldType = options.fieldType ?? 'text';\n\n return html`\n <div class=\"field ${options.id}\">\n <label for=${options.id} class=\"field-label\">\n ${options.label}${required\n ? html`<span class=\"required-asterisk\"> *</span>`\n : nothing}\n </label>\n <ia-donation-badged-input\n class=${options.id}\n .iconSpaceOption=${SpacerOption.CompressSpace}\n .requiredIndicatorSpaceOption=${SpacerOption.CompressSpace}\n >\n <input\n type=${fieldType}\n id=${options.id}\n class=\"donation-contact-form-input\"\n name=${options.name}\n maxlength=${ifDefined(options.maxlength)}\n minlength=${ifDefined(options.minlength)}\n autocomplete=${options.autocomplete ?? 'on'}\n pattern=${ifDefined(options.validationPattern)}\n title=${ifDefined(options.validationMessage)}\n @input=${this.inputChanged}\n ?required=${required}\n />\n </ia-donation-badged-input>\n </div>\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 return new BillingInfo({\n streetAddress: this.streetAddressField.value,\n locality: this.localityField.value,\n region: this.regionField.value,\n postalCode: this.postalCodeField.value,\n countryCodeAlpha2: this.countryCodeAlpha2Field.value,\n });\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 * The element renders into the light DOM, so instead of a `styles` block\n * it writes its own `<style>` tag, with every selector prefixed by the tag\n * name so nothing leaks onto the rest of the page.\n */\n private get getStyles(): TemplateResult {\n const noIconSpacerWidth = css`var(--ia-donation-badged-input-no-icon-spacer-width, calc(var(--donation-contact-base-font-size--) * 3))`;\n\n return html`\n <style>\n ia-donation-contact-form {\n --donation-contact-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-contact-row-gap--: var(\n --ia-donation-field-row-gap,\n calc(var(--donation-contact-base-font-size--) * 0.5)\n );\n --donation-contact-field-font-family--: var(\n --ia-theme-base-font-family,\n 'Helvetica Neue',\n Helvetica,\n Arial,\n sans-serif\n );\n --donation-contact-field-font-size--: var(\n --ia-donation-contact-field-font-size,\n calc(var(--donation-contact-base-font-size--) * 1.4)\n );\n --donation-contact-field-font-color--: var(\n --ia-donation-form-input-font-color,\n #2c2c2c\n );\n --donation-contact-label-font-family--: var(\n --ia-donation-field-label-font-family,\n var(--donation-contact-field-font-family--)\n );\n --donation-contact-label-font-size--: var(\n --ia-donation-field-label-font-size,\n calc(var(--donation-contact-base-font-size--) * 1.4)\n );\n --donation-contact-label-color--: var(\n --ia-donation-field-label-color,\n #2c2c2c\n );\n --donation-contact-label-margin-bottom--: var(\n --ia-donation-field-label-margin-bottom,\n calc(var(--donation-contact-base-font-size--) * 0.5)\n );\n --donation-contact-required-color--: var(\n --ia-donation-badged-input-required-color,\n var(--ia-theme-color-danger, #e51c23)\n );\n --donation-contact-error-color--: var(\n --ia-theme-color-danger,\n #e51c23\n );\n --donation-contact-no-icon-field-width--: calc(\n 100% - ${noIconSpacerWidth}\n );\n }\n\n /*\n A grid, so a label that wraps to two lines in one column doesn't push\n that column's input out of line with its siblings. All labels share\n row line 1 and all inputs share row line 2, each sized to the tallest\n content on its line.\n */\n ia-donation-contact-form .row {\n display: grid;\n grid-auto-flow: column;\n grid-auto-columns: 1fr;\n grid-template-rows: auto auto;\n column-gap: var(--donation-contact-row-gap--);\n }\n\n /*\n State / Province gives up room to Zip / Postal Code so the\n \"Zip / Postal Code *\" label stays on one line.\n */\n ia-donation-contact-form .row.region-postal-row {\n grid-template-columns:\n calc(60% - var(--donation-contact-base-font-size--) * 3)\n calc(40% + var(--donation-contact-base-font-size--) * 3);\n }\n\n ia-donation-contact-form .row + .row {\n margin-top: var(--donation-contact-row-gap--);\n }\n\n ia-donation-contact-form .field {\n display: contents;\n }\n\n ia-donation-contact-form .field-label {\n display: block;\n font-family: var(--donation-contact-label-font-family--);\n font-size: var(--donation-contact-label-font-size--);\n font-weight: bold;\n color: var(--donation-contact-label-color--);\n margin-bottom: var(--donation-contact-label-margin-bottom--);\n }\n\n ia-donation-contact-form .required-asterisk {\n color: var(--donation-contact-required-color--);\n }\n\n ia-donation-contact-form\n ia-donation-badged-input.donation-contact-form-region,\n ia-donation-contact-form\n ia-donation-badged-input.donation-contact-form-postal-code {\n width: 100%;\n }\n\n ia-donation-contact-form #donation-contact-form-error-message {\n color: var(--donation-contact-error-color--);\n font-size: calc(var(--donation-contact-base-font-size--) * 1.4);\n margin-bottom: calc(var(--donation-contact-base-font-size--) * 0.6);\n }\n\n ia-donation-contact-form .donation-contact-form-input {\n width: var(--donation-contact-no-icon-field-width--);\n border: 0;\n outline: 0;\n background: transparent;\n font-weight: bold;\n color: var(--donation-contact-field-font-color--);\n font-size: var(--donation-contact-field-font-size--);\n padding: 0;\n font-family: var(--donation-contact-field-font-family--);\n }\n\n ia-donation-contact-form #donation-contact-form-countryCodeAlpha2 {\n width: var(--donation-contact-no-icon-field-width--);\n height: 100%;\n box-sizing: border-box;\n font-weight: bold;\n font-size: var(--donation-contact-field-font-size--);\n color: var(--donation-contact-field-font-color--);\n font-family: var(--donation-contact-field-font-family--);\n border: 0;\n background: #fff;\n }\n </style>\n `;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-edit-donation.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"ia-donation-edit-donation.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AASb,OAAO,EACL,mBAAmB,EAGpB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,uBAAuB,CAAC;AAE/B,6DAA6D;AAC7D,eAAO,MAAM,0BAA0B;;;CAG7B,CAAC;AAEX,MAAM,MAAM,0BAA0B,GACpC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC;AAE/E,2CAA2C;AAC3C,eAAO,MAAM,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B,OAAO,CAAC,iBAAiB,EAAE,cAAc,GAAG,IAAI;IA8BhD,OAAO,KAAK,wBAAwB,GAYnC;IAED,OAAO,KAAK,yBAAyB,GAapC;IAED,OAAO,KAAK,yBAAyB,GAapC;IAED,+EAA+E;IAC/E,OAAO,KAAK,4BAA4B,GAKvC;IAED,OAAO,KAAK,qBAAqB,GAOhC;IAED;;;OAGG;IACH,OAAO,CAAC,8BAA8B;IAsDtC;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAmClC,OAAO,KAAK,aAAa,GAIxB;IAED;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAK7B,OAAO,KAAK,iBAAiB,GAoB5B;IAED,OAAO,KAAK,qBAAqB,GAkBhC;IAED,OAAO,CAAC,cAAc;IAqCtB,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,KAAK,wBAAwB,GAGnC;IAED,OAAO,KAAK,oBAAoB,GA6B/B;IAED,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,mBAAmB;IAM3B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,wBAAwB;IA0BhC,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,sBAAsB;IAQ9B,OAAO,CAAC,yBAAyB;IAOjC,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,kBAAkB;IAmB1B,MAAM,KAAK,MAAM,IAAI,cAAc,CAsNlC;CACF"}
|
|
@@ -2,8 +2,9 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html, LitElement, nothing, } from 'lit';
|
|
3
3
|
import { property, query, state } from 'lit/decorators.js';
|
|
4
4
|
import { customElement } from '../../../utils/custom-element.js';
|
|
5
|
-
import { msg, str } from '@lit/localize';
|
|
5
|
+
import { localized, msg, str } from '@lit/localize';
|
|
6
6
|
import currency from 'currency.js';
|
|
7
|
+
import { formatUsd } from '../localized-format.js';
|
|
7
8
|
import themeStyles from '../../../themes/theme-styles.js';
|
|
8
9
|
import { CurrencyValidator } from '../currency-validator.js';
|
|
9
10
|
import { DonationPaymentInfo, defaultDonationAmounts, defaultSelectedDonationInfo, } from '../models/donation-payment-info.js';
|
|
@@ -267,9 +268,7 @@ let IADonationEditDonation = class IADonationEditDonation extends LitElement {
|
|
|
267
268
|
}
|
|
268
269
|
}
|
|
269
270
|
get coverFeesText() {
|
|
270
|
-
const feeAmountString =
|
|
271
|
-
symbol: '$',
|
|
272
|
-
}).format();
|
|
271
|
+
const feeAmountString = formatUsd(this.donationInfo.fee);
|
|
273
272
|
return msg(str `I'll generously add ${feeAmountString} to cover fees.`);
|
|
274
273
|
}
|
|
275
274
|
/**
|
|
@@ -278,7 +277,7 @@ let IADonationEditDonation = class IADonationEditDonation extends LitElement {
|
|
|
278
277
|
*/
|
|
279
278
|
formatShortenedAmount(dollars) {
|
|
280
279
|
const precision = dollars % 1 === 0 ? 0 : 2;
|
|
281
|
-
return
|
|
280
|
+
return formatUsd(dollars, precision);
|
|
282
281
|
}
|
|
283
282
|
get frequencyTemplate() {
|
|
284
283
|
return html `
|
|
@@ -768,7 +767,8 @@ __decorate([
|
|
|
768
767
|
query('#custom-amount-input')
|
|
769
768
|
], IADonationEditDonation.prototype, "customAmountInput", void 0);
|
|
770
769
|
IADonationEditDonation = __decorate([
|
|
771
|
-
customElement('ia-donation-edit-donation')
|
|
770
|
+
customElement('ia-donation-edit-donation'),
|
|
771
|
+
localized()
|
|
772
772
|
], IADonationEditDonation);
|
|
773
773
|
export { IADonationEditDonation };
|
|
774
774
|
//# sourceMappingURL=ia-donation-edit-donation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-edit-donation.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.ts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AM,EAAE,CAAC;4DACqC;AAGhE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAEc;AAMb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEAAgC;AAEhC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;6DAAkD;AAG5E;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEAEmB;AAG9C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sEAEE;AAED;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gEAEnB;AAEoB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qEAEnB;AAGoB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sEAEnB;AAEN;IAAhB,KAAK,EAAE;qDAAgC;AAEvB;IAAhB,KAAK,EAAE;oEAAsC;AAEN;IAAvC,KAAK,CAAC,uBAAuB,CAAC;kEAA+C;AAEvC;IAAtC,KAAK,CAAC,sBAAsB,CAAC;iEAA8C;AA3CjE,sBAAsB;IADlC,aAAa,CAAC,2BAA2B,CAAC;GAC9B,sBAAsB,CA+wBlC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type CSSResultGroup,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { msg, str } from '@lit/localize';\nimport currency from 'currency.js';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport { CurrencyValidator } from '../currency-validator';\nimport {\n DonationPaymentInfo,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from '../models/donation-payment-info';\nimport { DonationType } from '../models/donation-type';\nimport { DonationSectionBadgeMode } from './ia-donation-section';\nimport './ia-donation-section';\n\n/** Whether the numbered step badges show on the sections. */\nexport const EditDonationStepNumberMode = {\n HideNumbers: 'hidenumbers',\n ShowNumbers: 'shownumbers',\n} as const;\n\nexport type EditDonationStepNumberMode =\n (typeof EditDonationStepNumberMode)[keyof typeof EditDonationStepNumberMode];\n\n/** The radio button groups in the form. */\nexport const EditDonationSelectionGroup = {\n DonationType: 'donationType',\n Amount: 'amount',\n} as const;\n\nexport type EditDonationSelectionGroup =\n (typeof EditDonationSelectionGroup)[keyof typeof EditDonationSelectionGroup];\n\n/** The outcome of validating an amount. Sent in the `editDonationError` event. */\nexport const EditDonationInfoStatus = {\n ValidDonationAmount: 'valid_donation_amount',\n InvalidDonationAmount: 'invalid_donation_amount',\n DonationTooHigh: 'donation_too_high',\n DonationTooLow: 'donation_too_low',\n} as const;\n\nexport type EditDonationInfoStatus =\n (typeof EditDonationInfoStatus)[keyof typeof EditDonationInfoStatus];\n\n/** How the one-time / monthly choice is presented. */\nexport const EditDonationFrequencySelectionMode = {\n Button: 'button',\n Checkbox: 'checkbox',\n Hide: 'hide',\n} as const;\n\nexport type EditDonationFrequencySelectionMode =\n (typeof EditDonationFrequencySelectionMode)[keyof typeof EditDonationFrequencySelectionMode];\n\n/** Whether the amount buttons wrap onto several lines or stay on one. */\nexport const EditDonationAmountSelectionLayout = {\n SingleLine: 'single-line',\n MultiLine: 'multi-line',\n} as const;\n\nexport type EditDonationAmountSelectionLayout =\n (typeof EditDonationAmountSelectionLayout)[keyof typeof EditDonationAmountSelectionLayout];\n\n/**\n * The part of the donation form where the donor picks a frequency, an amount\n * (preset or custom) and whether to cover the processing fee. Fires\n * `donationInfoChanged` with the new `DonationPaymentInfo` on every change\n * and `editDonationError` when a custom amount is out of range.\n *\n * The petabox donation banner uses this on its own, without the rest of the\n * form.\n */\n@customElement('ia-donation-edit-donation')\nexport class IADonationEditDonation extends LitElement {\n @property({ type: Object })\n donationInfo: DonationPaymentInfo = defaultSelectedDonationInfo;\n\n @property({ type: String })\n stepNumberMode: EditDonationStepNumberMode =\n EditDonationStepNumberMode.ShowNumbers;\n\n /**\n * A convenience for setting the selected amount from plain HTML. When\n * present it wins over `donationInfo`.\n */\n @property({ type: Number }) defaultSelectedAmount?: number;\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: String })\n amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String, reflect: true })\n frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String, reflect: true }) customAmountMode:\n | 'display'\n | 'hide' = 'display';\n\n @property({ type: String, reflect: true }) coverFeesCheckboxMode:\n | 'display'\n | 'hide' = 'display';\n\n /** `slot` renders the `edit-donation-amount-title` slot in place of the default headline. */\n @property({ type: String, reflect: true }) amountTitleDisplayMode:\n | 'default'\n | 'slot' = 'default';\n\n @state() private error?: TemplateResult;\n\n @state() private customAmountSelected = false;\n\n @query('#custom-amount-button') private customAmountButton!: HTMLInputElement;\n\n @query('#custom-amount-input') private customAmountInput!: HTMLInputElement;\n\n private currencyValidator: CurrencyValidator = new CurrencyValidator();\n\n render(): TemplateResult {\n const amountTitle =\n this.amountTitleDisplayMode === 'default'\n ? msg('Choose an amount (USD)')\n : '';\n return html`\n ${this.frequencySelectionMode ===\n EditDonationFrequencySelectionMode.Button\n ? this.frequencyButtonsTemplate\n : nothing}\n\n <ia-donation-section\n sectionBadge=\"${this.amountSelectionSectionNumber}\"\n headline=${amountTitle}\n badgeMode=${this.formSectionNumberMode}\n >\n ${this.amountTitleDisplayMode === 'slot'\n ? html`<slot name=\"edit-donation-amount-title\"></slot>`\n : nothing}\n <ul class=\"amount-selector\">\n ${this.presetAmountsTemplate}\n ${this.customAmountMode === 'display'\n ? html`<li class=\"custom-amount\">${this.customAmountTemplate}</li>`\n : nothing}\n </ul>\n\n <div class=\"errors\" id=\"amount-errors\" aria-live=\"polite\">\n ${this.error}\n </div>\n\n ${this.coverFeesCheckboxMode === 'display'\n ? html`<div class=\"checkbox-options\">\n ${this.coverFeesCheckboxTemplate}\n ${this.frequencySelectionMode ===\n EditDonationFrequencySelectionMode.Checkbox\n ? this.frequencyCheckboxTemplate\n : nothing}\n </div>`\n : nothing}\n </ia-donation-section>\n `;\n }\n\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('customAmountSelected')) {\n if (this.customAmountButton) {\n this.customAmountButton.checked = this.customAmountSelected;\n }\n }\n if (changedProperties.has('amountOptions')) {\n this.customAmountSelected = false;\n this.updateSelectedDonationInfo();\n this.setupAmountColumnsLayoutConfig();\n }\n if (changedProperties.has('amountSelectionLayout')) {\n this.setupAmountColumnsLayoutConfig();\n }\n if (changedProperties.has('donationInfo')) {\n this.updateSelectedDonationInfo();\n }\n if (\n changedProperties.has('defaultSelectedAmount') &&\n this.defaultSelectedAmount !== undefined\n ) {\n this.customAmountSelected = false;\n this.donationInfo = new DonationPaymentInfo({\n donationType: this.donationInfo.donationType,\n amount: this.defaultSelectedAmount,\n coverFees: this.donationInfo.coverFees,\n });\n }\n }\n\n private get frequencyButtonsTemplate(): TemplateResult {\n return html`\n <ia-donation-section\n sectionBadge=\"1\"\n headline=${msg('Choose a frequency')}\n badgeMode=${this.formSectionNumberMode}\n >\n <ul class=\"frequency-selector\">\n ${this.frequencyTemplate}\n </ul>\n </ia-donation-section>\n `;\n }\n\n private get frequencyCheckboxTemplate(): TemplateResult {\n return html`\n <div class=\"checkbox-option-container\">\n <input\n type=\"checkbox\"\n id=\"make-this-monthly\"\n @input=${this.monthlyCheckboxChecked}\n .checked=${this.donationInfo.donationType === DonationType.Monthly}\n tabindex=\"0\"\n />\n <label for=\"make-this-monthly\">${msg('Make this monthly')}</label>\n </div>\n `;\n }\n\n private get coverFeesCheckboxTemplate(): TemplateResult {\n return html`\n <div class=\"checkbox-option-container\">\n <input\n type=\"checkbox\"\n id=\"cover-fees\"\n @input=${this.coverFeesChecked}\n .checked=${this.donationInfo.coverFees}\n tabindex=\"0\"\n />\n <label for=\"cover-fees\">${this.coverFeesText}</label>\n </div>\n `;\n }\n\n /** The amount step is 2 when the frequency buttons come first, otherwise 1. */\n private get amountSelectionSectionNumber(): number {\n return this.frequencySelectionMode ===\n EditDonationFrequencySelectionMode.Button\n ? 2\n : 1;\n }\n\n private get formSectionNumberMode(): DonationSectionBadgeMode {\n switch (this.stepNumberMode) {\n case EditDonationStepNumberMode.ShowNumbers:\n return DonationSectionBadgeMode.ShowBadge;\n case EditDonationStepNumberMode.HideNumbers:\n return DonationSectionBadgeMode.HideBadge;\n }\n }\n\n /**\n * Picks the amount grid's column count, and how many columns the custom\n * amount field spans, from how many preset amounts there are.\n */\n private setupAmountColumnsLayoutConfig(): void {\n const minimalView =\n this.customAmountMode === 'hide' &&\n this.coverFeesCheckboxMode === 'hide' &&\n this.frequencySelectionMode === EditDonationFrequencySelectionMode.Hide;\n const amountCount = this.amountOptions.length;\n let columnCount = 5;\n let customAmountSpan = 3;\n switch (amountCount) {\n case 7:\n columnCount = 5;\n customAmountSpan = 3;\n break;\n case 6:\n columnCount = 4;\n customAmountSpan = 2;\n break;\n case 5:\n columnCount = 4;\n customAmountSpan = 3;\n break;\n case 4:\n if (minimalView) {\n columnCount = 4;\n customAmountSpan = 0;\n break;\n }\n columnCount = 3;\n customAmountSpan = 2;\n break;\n case 3:\n columnCount = 2;\n customAmountSpan = 1;\n break;\n }\n\n if (\n this.amountSelectionLayout ===\n EditDonationAmountSelectionLayout.SingleLine\n ) {\n columnCount = amountCount + 3;\n customAmountSpan = 3;\n }\n\n this.style.setProperty(\n '--ia-donation-edit-amount-column-count',\n `${columnCount}`,\n );\n this.style.setProperty(\n '--ia-donation-edit-custom-amount-col-span',\n `${customAmountSpan}`,\n );\n }\n\n /**\n * Syncs the radios and the custom field with `donationInfo`. A preset\n * amount checks its radio and clears the custom field; anything else\n * selects the custom field and formats the amount into it.\n */\n private updateSelectedDonationInfo(): void {\n // Keep the custom amount selected while the donor is typing in it, even\n // if the value matches a preset, so the selection doesn't jump to the\n // preset radio mid-keystroke.\n // With the custom field hidden both sides would be null, so guard on it\n // existing first.\n const typingInCustomAmount =\n !!this.customAmountInput &&\n this.shadowRoot?.activeElement === this.customAmountInput;\n if (\n !this.isCustomAmount &&\n !(this.customAmountSelected && typingInCustomAmount)\n ) {\n const radioButton = this.shadowRoot?.querySelector<HTMLInputElement>(\n `input[type=\"radio\"][name=\"${EditDonationSelectionGroup.Amount}\"][value=\"${this.donationInfo.amount}\"]`,\n );\n if (radioButton) radioButton.checked = true;\n this.customAmountSelected = false;\n this.error = undefined;\n if (this.customAmountInput) {\n this.customAmountInput.value = '';\n }\n } else {\n this.customAmountSelected = true;\n // Leave the field alone while it has focus, the donor may be typing\n if (!typingInCustomAmount && this.customAmountInput) {\n this.customAmountInput.value = this.customAmountDisplayValue;\n const donationInfoStatus = this.getDonationInfoStatus(\n this.donationInfo.amount,\n );\n this.handleDonationInfoStatus(donationInfoStatus);\n }\n }\n }\n\n private get coverFeesText(): string {\n const feeAmountString = currency(this.donationInfo.fee, {\n symbol: '$',\n }).format();\n\n return msg(str`I'll generously add ${feeAmountString} to cover fees.`);\n }\n\n /**\n * Formats a dollar amount without cents when it's a whole number and with\n * them when it isn't: `$5` and `$5.50`.\n */\n private formatShortenedAmount(dollars: number): string {\n const precision = dollars % 1 === 0 ? 0 : 2;\n return currency(dollars, { symbol: '$', precision }).format();\n }\n\n private get frequencyTemplate(): TemplateResult {\n return html`\n <li>\n ${this.getRadioButton({\n group: EditDonationSelectionGroup.DonationType,\n value: DonationType.OneTime,\n displayText: msg('One time'),\n checked: this.donationInfo.donationType === DonationType.OneTime,\n })}\n </li>\n\n <li>\n ${this.getRadioButton({\n group: EditDonationSelectionGroup.DonationType,\n value: DonationType.Monthly,\n displayText: msg('Monthly'),\n checked: this.donationInfo.donationType === DonationType.Monthly,\n })}\n </li>\n `;\n }\n\n private get presetAmountsTemplate(): TemplateResult {\n return html`\n ${this.amountOptions.map((amount) => {\n const checked =\n !this.customAmountSelected && amount === this.donationInfo.amount;\n\n return html`\n <li>\n ${this.getRadioButton({\n group: EditDonationSelectionGroup.Amount,\n value: `${amount}`,\n displayText: this.formatShortenedAmount(amount),\n checked,\n })}\n </li>\n `;\n })}\n `;\n }\n\n private getRadioButton(options: {\n group: EditDonationSelectionGroup;\n value: string;\n displayText: string;\n checked: boolean;\n }): TemplateResult {\n const radioId = `${options.group}-${options.value}-option`;\n return html`\n <div class=\"selection-button\">\n <input\n type=\"radio\"\n name=${options.group}\n value=${options.value}\n id=${radioId}\n tabindex=\"0\"\n .checked=${options.checked}\n @change=${this.radioSelected}\n @click=${(e: Event): void => {\n // `change` doesn't fire when the checked radio is clicked again,\n // so re-selecting the current amount is caught here. It matters\n // after a custom amount, which unchecks the presets visually.\n const isAmountSelection =\n options.group === EditDonationSelectionGroup.Amount;\n if (isAmountSelection) {\n const isSameValue =\n parseFloat(options.value) === this.donationInfo.amount;\n if (isSameValue) {\n this.radioSelected(e);\n }\n }\n }}\n />\n <label for=${radioId}>${options.displayText}</label>\n </div>\n `;\n }\n\n private get isCustomAmount(): boolean {\n return !this.amountOptions.includes(this.donationInfo.amount);\n }\n\n private get customAmountDisplayValue(): string {\n if (!this.isCustomAmount) return '';\n return currency(this.donationInfo.amount, { symbol: '' }).format();\n }\n\n private get customAmountTemplate(): TemplateResult {\n return html`\n <div class=\"selection-button\">\n <input\n type=\"radio\"\n name=${EditDonationSelectionGroup.Amount}\n value=\"custom\"\n id=\"custom-amount-button\"\n tabindex=\"0\"\n @change=${this.customRadioSelected}\n />\n\n <label for=\"custom-amount-button\">\n <span class=\"custom-amount-text\">${msg('Custom: $')}</span\n ><input\n type=\"text\"\n id=\"custom-amount-input\"\n tabindex=\"-1\"\n aria-label=${msg('Custom amount in dollars')}\n aria-describedby=\"amount-errors\"\n value=${this.customAmountDisplayValue}\n @input=${this.customAmountChanged}\n @keydown=${this.currencyValidator.keydown}\n @focus=${this.customAmountFocused}\n @blur=${this.customAmountBlurred}\n />\n </label>\n </div>\n `;\n }\n\n private customRadioSelected(): void {\n this.customAmountInput.focus();\n }\n\n private customAmountFocused(e: Event): void {\n const target = e.target as HTMLInputElement;\n this.customAmountSelected = true;\n this.handleCustomAmountInput(target.value);\n }\n\n /**\n * Once focus leaves the custom field the mid-keystroke protection is over,\n * so the UI re-syncs with `donationInfo`: a typed amount equal to a preset\n * moves to that preset, anything else gets re-formatted in place.\n */\n private customAmountBlurred(): void {\n this.updateSelectedDonationInfo();\n }\n\n private coverFeesChecked(e: Event): void {\n const target = e.target as HTMLInputElement;\n this.updateDonationInfo({ coverFees: target.checked });\n }\n\n private customAmountChanged(e: Event): void {\n const target = e.target as HTMLInputElement;\n this.customAmountSelected = true;\n this.handleCustomAmountInput(target.value);\n }\n\n private handleCustomAmountInput(value: string): void {\n const amount = parseFloat(value);\n if (isNaN(amount)) {\n this.dispatchEditDonationError(\n EditDonationInfoStatus.InvalidDonationAmount,\n );\n } else {\n this.amountChanged(amount);\n }\n }\n\n private handleDonationInfoStatus(status: EditDonationInfoStatus): void {\n switch (status) {\n case EditDonationInfoStatus.ValidDonationAmount:\n this.error = undefined;\n break;\n case EditDonationInfoStatus.DonationTooHigh:\n this.error = msg(html`\n To make a donation of $10,000 or more, please contact our philanthropy\n department at\n <a href=\"mailto:donations@archive.org\">donations@archive.org</a>\n `);\n this.dispatchEditDonationError(status);\n break;\n case EditDonationInfoStatus.DonationTooLow:\n if (this.customAmountInput.value.length > 0) {\n this.error = html`${msg('Please select an amount (minimum $1)')}`;\n }\n this.dispatchEditDonationError(status);\n break;\n case EditDonationInfoStatus.InvalidDonationAmount:\n this.error = html`${msg('Please enter a valid donation amount')}`;\n this.dispatchEditDonationError(status);\n break;\n }\n }\n\n private amountChanged(amount: number): void {\n const donationInfoStatus = this.getDonationInfoStatus(amount);\n this.handleDonationInfoStatus(donationInfoStatus);\n\n // Only a valid amount makes it into the donation info\n if (donationInfoStatus === EditDonationInfoStatus.ValidDonationAmount) {\n this.updateDonationInfo({ amount });\n }\n }\n\n private getDonationInfoStatus(amount: number): EditDonationInfoStatus {\n if (isNaN(amount)) {\n return EditDonationInfoStatus.InvalidDonationAmount;\n }\n\n if (amount >= 10000) {\n return EditDonationInfoStatus.DonationTooHigh;\n }\n\n if (amount < 1) {\n return EditDonationInfoStatus.DonationTooLow;\n }\n\n return EditDonationInfoStatus.ValidDonationAmount;\n }\n\n private radioSelected(e: Event): void {\n const radioButton = e.target as HTMLInputElement;\n const group = radioButton.name as EditDonationSelectionGroup;\n const { value } = radioButton;\n\n switch (group) {\n case EditDonationSelectionGroup.Amount:\n this.presetAmountChanged(parseFloat(value));\n break;\n case EditDonationSelectionGroup.DonationType:\n this.updateDonationInfo({ donationType: value as DonationType });\n break;\n default:\n break;\n }\n }\n\n private monthlyCheckboxChecked(e: Event): void {\n const isChecked = (e.target as HTMLInputElement).checked;\n const donationType = isChecked\n ? DonationType.Monthly\n : DonationType.OneTime;\n this.updateDonationInfo({ donationType });\n }\n\n private dispatchEditDonationError(error: EditDonationInfoStatus): void {\n const event = new CustomEvent('editDonationError', {\n detail: { error },\n });\n this.dispatchEvent(event);\n }\n\n private presetAmountChanged(amount: number): void {\n this.error = undefined;\n this.customAmountSelected = false;\n if (this.customAmountInput) {\n this.customAmountInput.value = '';\n }\n this.updateDonationInfo({ amount });\n }\n\n private updateDonationInfo(options: {\n donationType?: DonationType;\n amount?: number;\n coverFees?: boolean;\n }): void {\n const newDonationInfo = new DonationPaymentInfo({\n donationType: options.donationType ?? this.donationInfo.donationType,\n amount: options.amount ?? this.donationInfo.amount,\n coverFees: options.coverFees ?? this.donationInfo.coverFees,\n });\n\n this.donationInfo = newDonationInfo;\n\n const event = new CustomEvent('donationInfoChanged', {\n detail: { donationInfo: newDonationInfo },\n });\n this.dispatchEvent(event);\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n /*\n * The donation form was built for a 10px root font size. Sizing off\n * this base keeps the element self-contained, so it looks the same\n * whatever the page's root size is. Override it to rescale\n * everything, sections included.\n */\n --donation-edit-base-font-size--: var(\n --ia-donation-edit-base-font-size,\n 10px\n );\n\n --donation-edit-button-border-color--: var(\n --ia-donation-edit-button-border-color,\n var(--mid-gray)\n );\n --donation-edit-button-grid-gap--: var(\n --ia-donation-edit-button-grid-gap,\n var(--donation-edit-base-font-size--)\n );\n --donation-edit-button-font-size--: var(\n --ia-donation-edit-button-font-size,\n calc(var(--donation-edit-base-font-size--) * 1.6)\n );\n --donation-edit-button-font-color--: var(\n --ia-donation-edit-button-font-color,\n #000\n );\n --donation-edit-button-selected-font-color--: var(\n --ia-donation-edit-button-selected-font-color,\n #000\n );\n --donation-edit-button-selected-color--: var(\n --ia-donation-edit-button-selected-color,\n #f9bf3b\n );\n --donation-edit-button-focused-outline-color--: var(\n --ia-donation-edit-button-focused-outline-color,\n #7fb3f9\n );\n --donation-edit-button-color--: var(\n --ia-donation-edit-button-color,\n var(--true-white)\n );\n --donation-edit-cover-fees-font-size--: var(\n --ia-donation-edit-cover-fees-font-size,\n calc(var(--donation-edit-base-font-size--) * 1.2)\n );\n --donation-edit-cover-fees-font-weight--: var(\n --ia-donation-edit-cover-fees-font-weight,\n bold\n );\n --donation-edit-custom-amount-width--: var(\n --ia-donation-edit-custom-amount-width,\n calc(var(--donation-edit-base-font-size--) * 4)\n );\n --donation-edit-input-font-color--: var(\n --ia-donation-edit-input-font-color,\n var(--mid-gray)\n );\n --donation-edit-input-border--: var(\n --ia-donation-edit-input-border,\n 1px solid #d9d9d9\n );\n /* These two are set on the host by the element itself, from the number of amounts */\n --donation-edit-amount-column-count--: var(\n --ia-donation-edit-amount-column-count,\n 5\n );\n --donation-edit-custom-amount-col-span--: var(\n --ia-donation-edit-custom-amount-col-span,\n 3\n );\n --donation-edit-error-color--: var(--color-danger);\n\n /* Passed through to the sections */\n --ia-donation-section-base-font-size: var(\n --donation-edit-base-font-size--\n );\n --ia-donation-section-background-color: var(\n --ia-donation-edit-background-color,\n transparent\n );\n --ia-donation-section-badge-background-color: var(\n --ia-donation-edit-badge-background-color,\n var(--mid-gray)\n );\n --ia-donation-section-badge-font-color: var(\n --ia-donation-edit-badge-font-color,\n var(--true-white)\n );\n }\n\n .errors {\n color: var(--donation-edit-error-color--);\n font-size: calc(var(--donation-edit-base-font-size--) * 1.4);\n margin-top: var(--padding-sm);\n }\n\n ul {\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n grid-gap: var(--donation-edit-button-grid-gap--);\n }\n\n li {\n margin: 0;\n padding: 0;\n display: inline-block;\n }\n\n .frequency-selector {\n grid-template-columns: repeat(2, 1fr);\n }\n\n .amount-selector {\n grid-template-columns: repeat(\n var(--donation-edit-amount-column-count--),\n 1fr\n );\n }\n\n .custom-amount {\n grid-column: span var(--donation-edit-custom-amount-col-span--);\n }\n\n .selection-button {\n height: calc(var(--donation-edit-base-font-size--) * 3);\n }\n\n .selection-button label {\n padding: 0 calc(var(--donation-edit-base-font-size--) * 0.3);\n display: flex;\n cursor: pointer;\n text-align: center;\n font-size: var(--donation-edit-button-font-size--);\n font-weight: bold;\n border: 1px solid var(--donation-edit-button-border-color--);\n border-radius: 5px;\n height: 100%;\n justify-content: center;\n align-items: center;\n }\n\n label[for='custom-amount-button'] {\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .custom-amount-text {\n white-space: nowrap;\n margin-right: var(--padding-sm);\n }\n\n input[type='radio'] {\n opacity: 0;\n width: 0;\n height: 0;\n position: absolute;\n }\n\n input[type='radio'] + label {\n color: var(--donation-edit-button-font-color--);\n background-color: var(--donation-edit-button-color--);\n }\n\n input[type='radio']:checked + label {\n color: var(--donation-edit-button-selected-font-color--);\n background-color: var(--donation-edit-button-selected-color--);\n }\n\n input[type='radio']:focus + label {\n outline: 2px solid var(--donation-edit-button-focused-outline-color--);\n }\n\n .checkbox-options {\n margin-top: var(--donation-edit-base-font-size--);\n }\n\n .checkbox-option-container {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .checkbox-option-container input {\n width: calc(var(--donation-edit-base-font-size--) * 2);\n }\n\n .checkbox-option-container label {\n font-size: var(--donation-edit-cover-fees-font-size--);\n font-weight: var(--donation-edit-cover-fees-font-weight--);\n flex: 1;\n }\n\n #custom-amount-input {\n width: var(--donation-edit-custom-amount-width--);\n font-size: var(--donation-edit-button-font-size--);\n font-weight: bold;\n color: var(--donation-edit-input-font-color--);\n padding: calc(var(--donation-edit-base-font-size--) * 0.1);\n border: var(--donation-edit-input-border--);\n appearance: none;\n }\n `,\n ];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ia-donation-edit-donation.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-edit-donation.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,GAIR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,uBAAuB,CAAC;AAE/B,6DAA6D;AAC7D,MAAM,CAA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CAAC,uBAAuB,CAAC;kEAA+C;AAEvC;IAAtC,KAAK,CAAC,sBAAsB,CAAC;iEAA8C;AA3CjE,sBAAsB;IAFlC,aAAa,CAAC,2BAA2B,CAAC;IAC1C,SAAS,EAAE;GACC,sBAAsB,CA6wBlC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type CSSResultGroup,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { localized, msg, str } from '@lit/localize';\nimport currency from 'currency.js';\nimport { formatUsd } from '../localized-format';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport { CurrencyValidator } from '../currency-validator';\nimport {\n DonationPaymentInfo,\n defaultDonationAmounts,\n defaultSelectedDonationInfo,\n} from '../models/donation-payment-info';\nimport { DonationType } from '../models/donation-type';\nimport { DonationSectionBadgeMode } from './ia-donation-section';\nimport './ia-donation-section';\n\n/** Whether the numbered step badges show on the sections. */\nexport const EditDonationStepNumberMode = {\n HideNumbers: 'hidenumbers',\n ShowNumbers: 'shownumbers',\n} as const;\n\nexport type EditDonationStepNumberMode =\n (typeof EditDonationStepNumberMode)[keyof typeof EditDonationStepNumberMode];\n\n/** The radio button groups in the form. */\nexport const EditDonationSelectionGroup = {\n DonationType: 'donationType',\n Amount: 'amount',\n} as const;\n\nexport type EditDonationSelectionGroup =\n (typeof EditDonationSelectionGroup)[keyof typeof EditDonationSelectionGroup];\n\n/** The outcome of validating an amount. Sent in the `editDonationError` event. */\nexport const EditDonationInfoStatus = {\n ValidDonationAmount: 'valid_donation_amount',\n InvalidDonationAmount: 'invalid_donation_amount',\n DonationTooHigh: 'donation_too_high',\n DonationTooLow: 'donation_too_low',\n} as const;\n\nexport type EditDonationInfoStatus =\n (typeof EditDonationInfoStatus)[keyof typeof EditDonationInfoStatus];\n\n/** How the one-time / monthly choice is presented. */\nexport const EditDonationFrequencySelectionMode = {\n Button: 'button',\n Checkbox: 'checkbox',\n Hide: 'hide',\n} as const;\n\nexport type EditDonationFrequencySelectionMode =\n (typeof EditDonationFrequencySelectionMode)[keyof typeof EditDonationFrequencySelectionMode];\n\n/** Whether the amount buttons wrap onto several lines or stay on one. */\nexport const EditDonationAmountSelectionLayout = {\n SingleLine: 'single-line',\n MultiLine: 'multi-line',\n} as const;\n\nexport type EditDonationAmountSelectionLayout =\n (typeof EditDonationAmountSelectionLayout)[keyof typeof EditDonationAmountSelectionLayout];\n\n/**\n * The part of the donation form where the donor picks a frequency, an amount\n * (preset or custom) and whether to cover the processing fee. Fires\n * `donationInfoChanged` with the new `DonationPaymentInfo` on every change\n * and `editDonationError` when a custom amount is out of range.\n *\n * The petabox donation banner uses this on its own, without the rest of the\n * form.\n */\n@customElement('ia-donation-edit-donation')\n@localized()\nexport class IADonationEditDonation extends LitElement {\n @property({ type: Object })\n donationInfo: DonationPaymentInfo = defaultSelectedDonationInfo;\n\n @property({ type: String })\n stepNumberMode: EditDonationStepNumberMode =\n EditDonationStepNumberMode.ShowNumbers;\n\n /**\n * A convenience for setting the selected amount from plain HTML. When\n * present it wins over `donationInfo`.\n */\n @property({ type: Number }) defaultSelectedAmount?: number;\n\n @property({ type: Array }) amountOptions: number[] = defaultDonationAmounts;\n\n @property({ type: String })\n amountSelectionLayout: EditDonationAmountSelectionLayout =\n EditDonationAmountSelectionLayout.MultiLine;\n\n @property({ type: String, reflect: true })\n frequencySelectionMode: EditDonationFrequencySelectionMode =\n EditDonationFrequencySelectionMode.Button;\n\n @property({ type: String, reflect: true }) customAmountMode:\n | 'display'\n | 'hide' = 'display';\n\n @property({ type: String, reflect: true }) coverFeesCheckboxMode:\n | 'display'\n | 'hide' = 'display';\n\n /** `slot` renders the `edit-donation-amount-title` slot in place of the default headline. */\n @property({ type: String, reflect: true }) amountTitleDisplayMode:\n | 'default'\n | 'slot' = 'default';\n\n @state() private error?: TemplateResult;\n\n @state() private customAmountSelected = false;\n\n @query('#custom-amount-button') private customAmountButton!: HTMLInputElement;\n\n @query('#custom-amount-input') private customAmountInput!: HTMLInputElement;\n\n private currencyValidator: CurrencyValidator = new CurrencyValidator();\n\n render(): TemplateResult {\n const amountTitle =\n this.amountTitleDisplayMode === 'default'\n ? msg('Choose an amount (USD)')\n : '';\n return html`\n ${this.frequencySelectionMode ===\n EditDonationFrequencySelectionMode.Button\n ? this.frequencyButtonsTemplate\n : nothing}\n\n <ia-donation-section\n sectionBadge=\"${this.amountSelectionSectionNumber}\"\n headline=${amountTitle}\n badgeMode=${this.formSectionNumberMode}\n >\n ${this.amountTitleDisplayMode === 'slot'\n ? html`<slot name=\"edit-donation-amount-title\"></slot>`\n : nothing}\n <ul class=\"amount-selector\">\n ${this.presetAmountsTemplate}\n ${this.customAmountMode === 'display'\n ? html`<li class=\"custom-amount\">${this.customAmountTemplate}</li>`\n : nothing}\n </ul>\n\n <div class=\"errors\" id=\"amount-errors\" aria-live=\"polite\">\n ${this.error}\n </div>\n\n ${this.coverFeesCheckboxMode === 'display'\n ? html`<div class=\"checkbox-options\">\n ${this.coverFeesCheckboxTemplate}\n ${this.frequencySelectionMode ===\n EditDonationFrequencySelectionMode.Checkbox\n ? this.frequencyCheckboxTemplate\n : nothing}\n </div>`\n : nothing}\n </ia-donation-section>\n `;\n }\n\n updated(changedProperties: PropertyValues): void {\n if (changedProperties.has('customAmountSelected')) {\n if (this.customAmountButton) {\n this.customAmountButton.checked = this.customAmountSelected;\n }\n }\n if (changedProperties.has('amountOptions')) {\n this.customAmountSelected = false;\n this.updateSelectedDonationInfo();\n this.setupAmountColumnsLayoutConfig();\n }\n if (changedProperties.has('amountSelectionLayout')) {\n this.setupAmountColumnsLayoutConfig();\n }\n if (changedProperties.has('donationInfo')) {\n this.updateSelectedDonationInfo();\n }\n if (\n changedProperties.has('defaultSelectedAmount') &&\n this.defaultSelectedAmount !== undefined\n ) {\n this.customAmountSelected = false;\n this.donationInfo = new DonationPaymentInfo({\n donationType: this.donationInfo.donationType,\n amount: this.defaultSelectedAmount,\n coverFees: this.donationInfo.coverFees,\n });\n }\n }\n\n private get frequencyButtonsTemplate(): TemplateResult {\n return html`\n <ia-donation-section\n sectionBadge=\"1\"\n headline=${msg('Choose a frequency')}\n badgeMode=${this.formSectionNumberMode}\n >\n <ul class=\"frequency-selector\">\n ${this.frequencyTemplate}\n </ul>\n </ia-donation-section>\n `;\n }\n\n private get frequencyCheckboxTemplate(): TemplateResult {\n return html`\n <div class=\"checkbox-option-container\">\n <input\n type=\"checkbox\"\n id=\"make-this-monthly\"\n @input=${this.monthlyCheckboxChecked}\n .checked=${this.donationInfo.donationType === DonationType.Monthly}\n tabindex=\"0\"\n />\n <label for=\"make-this-monthly\">${msg('Make this monthly')}</label>\n </div>\n `;\n }\n\n private get coverFeesCheckboxTemplate(): TemplateResult {\n return html`\n <div class=\"checkbox-option-container\">\n <input\n type=\"checkbox\"\n id=\"cover-fees\"\n @input=${this.coverFeesChecked}\n .checked=${this.donationInfo.coverFees}\n tabindex=\"0\"\n />\n <label for=\"cover-fees\">${this.coverFeesText}</label>\n </div>\n `;\n }\n\n /** The amount step is 2 when the frequency buttons come first, otherwise 1. */\n private get amountSelectionSectionNumber(): number {\n return this.frequencySelectionMode ===\n EditDonationFrequencySelectionMode.Button\n ? 2\n : 1;\n }\n\n private get formSectionNumberMode(): DonationSectionBadgeMode {\n switch (this.stepNumberMode) {\n case EditDonationStepNumberMode.ShowNumbers:\n return DonationSectionBadgeMode.ShowBadge;\n case EditDonationStepNumberMode.HideNumbers:\n return DonationSectionBadgeMode.HideBadge;\n }\n }\n\n /**\n * Picks the amount grid's column count, and how many columns the custom\n * amount field spans, from how many preset amounts there are.\n */\n private setupAmountColumnsLayoutConfig(): void {\n const minimalView =\n this.customAmountMode === 'hide' &&\n this.coverFeesCheckboxMode === 'hide' &&\n this.frequencySelectionMode === EditDonationFrequencySelectionMode.Hide;\n const amountCount = this.amountOptions.length;\n let columnCount = 5;\n let customAmountSpan = 3;\n switch (amountCount) {\n case 7:\n columnCount = 5;\n customAmountSpan = 3;\n break;\n case 6:\n columnCount = 4;\n customAmountSpan = 2;\n break;\n case 5:\n columnCount = 4;\n customAmountSpan = 3;\n break;\n case 4:\n if (minimalView) {\n columnCount = 4;\n customAmountSpan = 0;\n break;\n }\n columnCount = 3;\n customAmountSpan = 2;\n break;\n case 3:\n columnCount = 2;\n customAmountSpan = 1;\n break;\n }\n\n if (\n this.amountSelectionLayout ===\n EditDonationAmountSelectionLayout.SingleLine\n ) {\n columnCount = amountCount + 3;\n customAmountSpan = 3;\n }\n\n this.style.setProperty(\n '--ia-donation-edit-amount-column-count',\n `${columnCount}`,\n );\n this.style.setProperty(\n '--ia-donation-edit-custom-amount-col-span',\n `${customAmountSpan}`,\n );\n }\n\n /**\n * Syncs the radios and the custom field with `donationInfo`. A preset\n * amount checks its radio and clears the custom field; anything else\n * selects the custom field and formats the amount into it.\n */\n private updateSelectedDonationInfo(): void {\n // Keep the custom amount selected while the donor is typing in it, even\n // if the value matches a preset, so the selection doesn't jump to the\n // preset radio mid-keystroke.\n // With the custom field hidden both sides would be null, so guard on it\n // existing first.\n const typingInCustomAmount =\n !!this.customAmountInput &&\n this.shadowRoot?.activeElement === this.customAmountInput;\n if (\n !this.isCustomAmount &&\n !(this.customAmountSelected && typingInCustomAmount)\n ) {\n const radioButton = this.shadowRoot?.querySelector<HTMLInputElement>(\n `input[type=\"radio\"][name=\"${EditDonationSelectionGroup.Amount}\"][value=\"${this.donationInfo.amount}\"]`,\n );\n if (radioButton) radioButton.checked = true;\n this.customAmountSelected = false;\n this.error = undefined;\n if (this.customAmountInput) {\n this.customAmountInput.value = '';\n }\n } else {\n this.customAmountSelected = true;\n // Leave the field alone while it has focus, the donor may be typing\n if (!typingInCustomAmount && this.customAmountInput) {\n this.customAmountInput.value = this.customAmountDisplayValue;\n const donationInfoStatus = this.getDonationInfoStatus(\n this.donationInfo.amount,\n );\n this.handleDonationInfoStatus(donationInfoStatus);\n }\n }\n }\n\n private get coverFeesText(): string {\n const feeAmountString = formatUsd(this.donationInfo.fee);\n\n return msg(str`I'll generously add ${feeAmountString} to cover fees.`);\n }\n\n /**\n * Formats a dollar amount without cents when it's a whole number and with\n * them when it isn't: `$5` and `$5.50`.\n */\n private formatShortenedAmount(dollars: number): string {\n const precision = dollars % 1 === 0 ? 0 : 2;\n return formatUsd(dollars, precision);\n }\n\n private get frequencyTemplate(): TemplateResult {\n return html`\n <li>\n ${this.getRadioButton({\n group: EditDonationSelectionGroup.DonationType,\n value: DonationType.OneTime,\n displayText: msg('One time'),\n checked: this.donationInfo.donationType === DonationType.OneTime,\n })}\n </li>\n\n <li>\n ${this.getRadioButton({\n group: EditDonationSelectionGroup.DonationType,\n value: DonationType.Monthly,\n displayText: msg('Monthly'),\n checked: this.donationInfo.donationType === DonationType.Monthly,\n })}\n </li>\n `;\n }\n\n private get presetAmountsTemplate(): TemplateResult {\n return html`\n ${this.amountOptions.map((amount) => {\n const checked =\n !this.customAmountSelected && amount === this.donationInfo.amount;\n\n return html`\n <li>\n ${this.getRadioButton({\n group: EditDonationSelectionGroup.Amount,\n value: `${amount}`,\n displayText: this.formatShortenedAmount(amount),\n checked,\n })}\n </li>\n `;\n })}\n `;\n }\n\n private getRadioButton(options: {\n group: EditDonationSelectionGroup;\n value: string;\n displayText: string;\n checked: boolean;\n }): TemplateResult {\n const radioId = `${options.group}-${options.value}-option`;\n return html`\n <div class=\"selection-button\">\n <input\n type=\"radio\"\n name=${options.group}\n value=${options.value}\n id=${radioId}\n tabindex=\"0\"\n .checked=${options.checked}\n @change=${this.radioSelected}\n @click=${(e: Event): void => {\n // `change` doesn't fire when the checked radio is clicked again,\n // so re-selecting the current amount is caught here. It matters\n // after a custom amount, which unchecks the presets visually.\n const isAmountSelection =\n options.group === EditDonationSelectionGroup.Amount;\n if (isAmountSelection) {\n const isSameValue =\n parseFloat(options.value) === this.donationInfo.amount;\n if (isSameValue) {\n this.radioSelected(e);\n }\n }\n }}\n />\n <label for=${radioId}>${options.displayText}</label>\n </div>\n `;\n }\n\n private get isCustomAmount(): boolean {\n return !this.amountOptions.includes(this.donationInfo.amount);\n }\n\n private get customAmountDisplayValue(): string {\n if (!this.isCustomAmount) return '';\n return currency(this.donationInfo.amount, { symbol: '' }).format();\n }\n\n private get customAmountTemplate(): TemplateResult {\n return html`\n <div class=\"selection-button\">\n <input\n type=\"radio\"\n name=${EditDonationSelectionGroup.Amount}\n value=\"custom\"\n id=\"custom-amount-button\"\n tabindex=\"0\"\n @change=${this.customRadioSelected}\n />\n\n <label for=\"custom-amount-button\">\n <span class=\"custom-amount-text\">${msg('Custom: $')}</span\n ><input\n type=\"text\"\n id=\"custom-amount-input\"\n tabindex=\"-1\"\n aria-label=${msg('Custom amount in dollars')}\n aria-describedby=\"amount-errors\"\n value=${this.customAmountDisplayValue}\n @input=${this.customAmountChanged}\n @keydown=${this.currencyValidator.keydown}\n @focus=${this.customAmountFocused}\n @blur=${this.customAmountBlurred}\n />\n </label>\n </div>\n `;\n }\n\n private customRadioSelected(): void {\n this.customAmountInput.focus();\n }\n\n private customAmountFocused(e: Event): void {\n const target = e.target as HTMLInputElement;\n this.customAmountSelected = true;\n this.handleCustomAmountInput(target.value);\n }\n\n /**\n * Once focus leaves the custom field the mid-keystroke protection is over,\n * so the UI re-syncs with `donationInfo`: a typed amount equal to a preset\n * moves to that preset, anything else gets re-formatted in place.\n */\n private customAmountBlurred(): void {\n this.updateSelectedDonationInfo();\n }\n\n private coverFeesChecked(e: Event): void {\n const target = e.target as HTMLInputElement;\n this.updateDonationInfo({ coverFees: target.checked });\n }\n\n private customAmountChanged(e: Event): void {\n const target = e.target as HTMLInputElement;\n this.customAmountSelected = true;\n this.handleCustomAmountInput(target.value);\n }\n\n private handleCustomAmountInput(value: string): void {\n const amount = parseFloat(value);\n if (isNaN(amount)) {\n this.dispatchEditDonationError(\n EditDonationInfoStatus.InvalidDonationAmount,\n );\n } else {\n this.amountChanged(amount);\n }\n }\n\n private handleDonationInfoStatus(status: EditDonationInfoStatus): void {\n switch (status) {\n case EditDonationInfoStatus.ValidDonationAmount:\n this.error = undefined;\n break;\n case EditDonationInfoStatus.DonationTooHigh:\n this.error = msg(html`\n To make a donation of $10,000 or more, please contact our philanthropy\n department at\n <a href=\"mailto:donations@archive.org\">donations@archive.org</a>\n `);\n this.dispatchEditDonationError(status);\n break;\n case EditDonationInfoStatus.DonationTooLow:\n if (this.customAmountInput.value.length > 0) {\n this.error = html`${msg('Please select an amount (minimum $1)')}`;\n }\n this.dispatchEditDonationError(status);\n break;\n case EditDonationInfoStatus.InvalidDonationAmount:\n this.error = html`${msg('Please enter a valid donation amount')}`;\n this.dispatchEditDonationError(status);\n break;\n }\n }\n\n private amountChanged(amount: number): void {\n const donationInfoStatus = this.getDonationInfoStatus(amount);\n this.handleDonationInfoStatus(donationInfoStatus);\n\n // Only a valid amount makes it into the donation info\n if (donationInfoStatus === EditDonationInfoStatus.ValidDonationAmount) {\n this.updateDonationInfo({ amount });\n }\n }\n\n private getDonationInfoStatus(amount: number): EditDonationInfoStatus {\n if (isNaN(amount)) {\n return EditDonationInfoStatus.InvalidDonationAmount;\n }\n\n if (amount >= 10000) {\n return EditDonationInfoStatus.DonationTooHigh;\n }\n\n if (amount < 1) {\n return EditDonationInfoStatus.DonationTooLow;\n }\n\n return EditDonationInfoStatus.ValidDonationAmount;\n }\n\n private radioSelected(e: Event): void {\n const radioButton = e.target as HTMLInputElement;\n const group = radioButton.name as EditDonationSelectionGroup;\n const { value } = radioButton;\n\n switch (group) {\n case EditDonationSelectionGroup.Amount:\n this.presetAmountChanged(parseFloat(value));\n break;\n case EditDonationSelectionGroup.DonationType:\n this.updateDonationInfo({ donationType: value as DonationType });\n break;\n default:\n break;\n }\n }\n\n private monthlyCheckboxChecked(e: Event): void {\n const isChecked = (e.target as HTMLInputElement).checked;\n const donationType = isChecked\n ? DonationType.Monthly\n : DonationType.OneTime;\n this.updateDonationInfo({ donationType });\n }\n\n private dispatchEditDonationError(error: EditDonationInfoStatus): void {\n const event = new CustomEvent('editDonationError', {\n detail: { error },\n });\n this.dispatchEvent(event);\n }\n\n private presetAmountChanged(amount: number): void {\n this.error = undefined;\n this.customAmountSelected = false;\n if (this.customAmountInput) {\n this.customAmountInput.value = '';\n }\n this.updateDonationInfo({ amount });\n }\n\n private updateDonationInfo(options: {\n donationType?: DonationType;\n amount?: number;\n coverFees?: boolean;\n }): void {\n const newDonationInfo = new DonationPaymentInfo({\n donationType: options.donationType ?? this.donationInfo.donationType,\n amount: options.amount ?? this.donationInfo.amount,\n coverFees: options.coverFees ?? this.donationInfo.coverFees,\n });\n\n this.donationInfo = newDonationInfo;\n\n const event = new CustomEvent('donationInfoChanged', {\n detail: { donationInfo: newDonationInfo },\n });\n this.dispatchEvent(event);\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n /*\n * The donation form was built for a 10px root font size. Sizing off\n * this base keeps the element self-contained, so it looks the same\n * whatever the page's root size is. Override it to rescale\n * everything, sections included.\n */\n --donation-edit-base-font-size--: var(\n --ia-donation-edit-base-font-size,\n 10px\n );\n\n --donation-edit-button-border-color--: var(\n --ia-donation-edit-button-border-color,\n var(--mid-gray)\n );\n --donation-edit-button-grid-gap--: var(\n --ia-donation-edit-button-grid-gap,\n var(--donation-edit-base-font-size--)\n );\n --donation-edit-button-font-size--: var(\n --ia-donation-edit-button-font-size,\n calc(var(--donation-edit-base-font-size--) * 1.6)\n );\n --donation-edit-button-font-color--: var(\n --ia-donation-edit-button-font-color,\n #000\n );\n --donation-edit-button-selected-font-color--: var(\n --ia-donation-edit-button-selected-font-color,\n #000\n );\n --donation-edit-button-selected-color--: var(\n --ia-donation-edit-button-selected-color,\n #f9bf3b\n );\n --donation-edit-button-focused-outline-color--: var(\n --ia-donation-edit-button-focused-outline-color,\n #7fb3f9\n );\n --donation-edit-button-color--: var(\n --ia-donation-edit-button-color,\n var(--true-white)\n );\n --donation-edit-cover-fees-font-size--: var(\n --ia-donation-edit-cover-fees-font-size,\n calc(var(--donation-edit-base-font-size--) * 1.2)\n );\n --donation-edit-cover-fees-font-weight--: var(\n --ia-donation-edit-cover-fees-font-weight,\n bold\n );\n --donation-edit-custom-amount-width--: var(\n --ia-donation-edit-custom-amount-width,\n calc(var(--donation-edit-base-font-size--) * 4)\n );\n --donation-edit-input-font-color--: var(\n --ia-donation-edit-input-font-color,\n var(--mid-gray)\n );\n --donation-edit-input-border--: var(\n --ia-donation-edit-input-border,\n 1px solid #d9d9d9\n );\n /* These two are set on the host by the element itself, from the number of amounts */\n --donation-edit-amount-column-count--: var(\n --ia-donation-edit-amount-column-count,\n 5\n );\n --donation-edit-custom-amount-col-span--: var(\n --ia-donation-edit-custom-amount-col-span,\n 3\n );\n --donation-edit-error-color--: var(--color-danger);\n\n /* Passed through to the sections */\n --ia-donation-section-base-font-size: var(\n --donation-edit-base-font-size--\n );\n --ia-donation-section-background-color: var(\n --ia-donation-edit-background-color,\n transparent\n );\n --ia-donation-section-badge-background-color: var(\n --ia-donation-edit-badge-background-color,\n var(--mid-gray)\n );\n --ia-donation-section-badge-font-color: var(\n --ia-donation-edit-badge-font-color,\n var(--true-white)\n );\n }\n\n .errors {\n color: var(--donation-edit-error-color--);\n font-size: calc(var(--donation-edit-base-font-size--) * 1.4);\n margin-top: var(--padding-sm);\n }\n\n ul {\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n grid-gap: var(--donation-edit-button-grid-gap--);\n }\n\n li {\n margin: 0;\n padding: 0;\n display: inline-block;\n }\n\n .frequency-selector {\n grid-template-columns: repeat(2, 1fr);\n }\n\n .amount-selector {\n grid-template-columns: repeat(\n var(--donation-edit-amount-column-count--),\n 1fr\n );\n }\n\n .custom-amount {\n grid-column: span var(--donation-edit-custom-amount-col-span--);\n }\n\n .selection-button {\n height: calc(var(--donation-edit-base-font-size--) * 3);\n }\n\n .selection-button label {\n padding: 0 calc(var(--donation-edit-base-font-size--) * 0.3);\n display: flex;\n cursor: pointer;\n text-align: center;\n font-size: var(--donation-edit-button-font-size--);\n font-weight: bold;\n border: 1px solid var(--donation-edit-button-border-color--);\n border-radius: 5px;\n height: 100%;\n justify-content: center;\n align-items: center;\n }\n\n label[for='custom-amount-button'] {\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .custom-amount-text {\n white-space: nowrap;\n margin-right: var(--padding-sm);\n }\n\n input[type='radio'] {\n opacity: 0;\n width: 0;\n height: 0;\n position: absolute;\n }\n\n input[type='radio'] + label {\n color: var(--donation-edit-button-font-color--);\n background-color: var(--donation-edit-button-color--);\n }\n\n input[type='radio']:checked + label {\n color: var(--donation-edit-button-selected-font-color--);\n background-color: var(--donation-edit-button-selected-color--);\n }\n\n input[type='radio']:focus + label {\n outline: 2px solid var(--donation-edit-button-focused-outline-color--);\n }\n\n .checkbox-options {\n margin-top: var(--donation-edit-base-font-size--);\n }\n\n .checkbox-option-container {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .checkbox-option-container input {\n width: calc(var(--donation-edit-base-font-size--) * 2);\n }\n\n .checkbox-option-container label {\n font-size: var(--donation-edit-cover-fees-font-size--);\n font-weight: var(--donation-edit-cover-fees-font-weight--);\n flex: 1;\n }\n\n #custom-amount-input {\n width: var(--donation-edit-custom-amount-width--);\n font-size: var(--donation-edit-button-font-size--);\n font-weight: bold;\n color: var(--donation-edit-input-font-color--);\n padding: calc(var(--donation-edit-base-font-size--) * 0.1);\n border: var(--donation-edit-input-border--);\n appearance: none;\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-summary.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAOb,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,uFAAuF;AACvF,
|
|
1
|
+
{"version":3,"file":"ia-donation-summary.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAOb,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,uFAAuF;AACvF,qBAEa,iBAAkB,SAAQ,UAAU;IACnB,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAE/D,MAAM,IAAI,cAAc;IAOxB,IAAI,YAAY,IAAI,MAAM,CAazB;IAED,OAAO,CAAC,WAAW;IAInB,MAAM,KAAK,MAAM,IAAI,cAAc,CAkBlC;CACF"}
|
|
@@ -2,8 +2,8 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html, LitElement, } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { customElement } from '../../../utils/custom-element.js';
|
|
5
|
-
import { msg, str } from '@lit/localize';
|
|
6
|
-
import
|
|
5
|
+
import { localized, msg, str } from '@lit/localize';
|
|
6
|
+
import { formatUsd } from '../localized-format.js';
|
|
7
7
|
import themeStyles from '../../../themes/theme-styles.js';
|
|
8
8
|
import { DonationType } from '../models/donation-type.js';
|
|
9
9
|
/** The collapsed view of the chosen donation, with a button to go back and edit it. */
|
|
@@ -21,7 +21,7 @@ let IADonationSummary = class IADonationSummary extends LitElement {
|
|
|
21
21
|
const amount = this.donationInfo.amount;
|
|
22
22
|
// Whole dollars don't need the cents
|
|
23
23
|
const precision = amount === Math.round(amount) ? 0 : 2;
|
|
24
|
-
const displayAmount =
|
|
24
|
+
const displayAmount = formatUsd(amount, precision);
|
|
25
25
|
return this.donationInfo.donationType === DonationType.Monthly
|
|
26
26
|
? msg(str `${displayAmount} Monthly Donation`)
|
|
27
27
|
: msg(str `${displayAmount} Donation`);
|
|
@@ -53,7 +53,8 @@ __decorate([
|
|
|
53
53
|
property({ type: Object })
|
|
54
54
|
], IADonationSummary.prototype, "donationInfo", void 0);
|
|
55
55
|
IADonationSummary = __decorate([
|
|
56
|
-
customElement('ia-donation-summary')
|
|
56
|
+
customElement('ia-donation-summary'),
|
|
57
|
+
localized()
|
|
57
58
|
], IADonationSummary);
|
|
58
59
|
export { IADonationSummary };
|
|
59
60
|
//# sourceMappingURL=ia-donation-summary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-summary.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-summary.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ia-donation-summary.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-summary.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,uFAAuF;AAGhF,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAG/C,MAAM;QACJ,OAAO,IAAI,CAAA;YACH,IAAI,CAAC,YAAY;uBACN,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC,kBAAkB,CAAC;KAC7D,CAAC;IACJ,CAAC;IAED,IAAI,YAAY;QACd,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QACxC,qCAAqC;QACrC,MAAM,SAAS,GAAG,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO;YAC5D,CAAC,CAAC,GAAG,CAAC,GAAG,CAAA,GAAG,aAAa,mBAAmB,CAAC;YAC7C,CAAC,CAAC,GAAG,CAAC,GAAG,CAAA,GAAG,aAAa,WAAW,CAAC,CAAC;IAC1C,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;OAaF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA/C6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAoC;AADpD,iBAAiB;IAF7B,aAAa,CAAC,qBAAqB,CAAC;IACpC,SAAS,EAAE;GACC,iBAAiB,CAgD7B","sourcesContent":["import {\n css,\n html,\n LitElement,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { localized, msg, str } from '@lit/localize';\nimport { formatUsd } from '../localized-format';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport type { DonationPaymentInfo } from '../models/donation-payment-info';\nimport { DonationType } from '../models/donation-type';\n\n/** The collapsed view of the chosen donation, with a button to go back and edit it. */\n@customElement('ia-donation-summary')\n@localized()\nexport class IADonationSummary extends LitElement {\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n render(): TemplateResult {\n return html`\n <h1>${this.displayTitle}</h1>\n <button @click=${this.editClicked}>${msg('Edit this amount')}</button>\n `;\n }\n\n get displayTitle(): string {\n if (!this.donationInfo) {\n return '';\n }\n\n const amount = this.donationInfo.amount;\n // Whole dollars don't need the cents\n const precision = amount === Math.round(amount) ? 0 : 2;\n const displayAmount = formatUsd(amount, precision);\n\n return this.donationInfo.donationType === DonationType.Monthly\n ? msg(str`${displayAmount} Monthly Donation`)\n : msg(str`${displayAmount} Donation`);\n }\n\n private editClicked(): void {\n this.dispatchEvent(new Event('editClicked'));\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n display: flex;\n justify-content: center;\n align-content: center;\n }\n\n button {\n border: 0;\n background: none;\n color: var(--link-color);\n cursor: pointer;\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-total-amount.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-total-amount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAOb,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,qFAAqF;AACrF,
|
|
1
|
+
{"version":3,"file":"ia-donation-total-amount.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-total-amount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAOb,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,qFAAqF;AACrF,qBAEa,qBAAsB,SAAQ,UAAU;IACvB,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAE/D,MAAM,IAAI,cAAc;IAOxB,OAAO,KAAK,SAAS,GAMpB;IAED,MAAM,KAAK,MAAM,IAAI,cAAc,CAyClC;CACF"}
|
|
@@ -2,8 +2,8 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html, LitElement, } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { customElement } from '../../../utils/custom-element.js';
|
|
5
|
-
import { msg, str } from '@lit/localize';
|
|
6
|
-
import
|
|
5
|
+
import { localized, msg, str } from '@lit/localize';
|
|
6
|
+
import { formatUsd } from '../localized-format.js';
|
|
7
7
|
import themeStyles from '../../../themes/theme-styles.js';
|
|
8
8
|
import { DonationType } from '../models/donation-type.js';
|
|
9
9
|
/** The "Total: $X" line under the amount picker, with "/month" for monthly gifts. */
|
|
@@ -17,7 +17,7 @@ let IADonationTotalAmount = class IADonationTotalAmount extends LitElement {
|
|
|
17
17
|
get totalLine() {
|
|
18
18
|
if (!this.donationInfo)
|
|
19
19
|
return '';
|
|
20
|
-
const amount =
|
|
20
|
+
const amount = formatUsd(this.donationInfo.total);
|
|
21
21
|
return this.donationInfo.donationType === DonationType.Monthly
|
|
22
22
|
? msg(str `Total: ${amount}/month`)
|
|
23
23
|
: msg(str `Total: ${amount}`);
|
|
@@ -69,7 +69,8 @@ __decorate([
|
|
|
69
69
|
property({ type: Object })
|
|
70
70
|
], IADonationTotalAmount.prototype, "donationInfo", void 0);
|
|
71
71
|
IADonationTotalAmount = __decorate([
|
|
72
|
-
customElement('ia-donation-total-amount')
|
|
72
|
+
customElement('ia-donation-total-amount'),
|
|
73
|
+
localized()
|
|
73
74
|
], IADonationTotalAmount);
|
|
74
75
|
export { IADonationTotalAmount };
|
|
75
76
|
//# sourceMappingURL=ia-donation-total-amount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-total-amount.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-total-amount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ia-donation-total-amount.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/form-elements/ia-donation-total-amount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qFAAqF;AAG9E,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAGnD,MAAM;QACJ,OAAO,IAAI,CAAA;;gCAEiB,IAAI,CAAC,SAAS;KACzC,CAAC;IACJ,CAAC;IAED,IAAY,SAAS;QACnB,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,OAAO,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO;YAC5D,CAAC,CAAC,GAAG,CAAC,GAAG,CAAA,UAAU,MAAM,QAAQ,CAAC;YAClC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAA,UAAU,MAAM,EAAE,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA3D6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAoC;AADpD,qBAAqB;IAFjC,aAAa,CAAC,0BAA0B,CAAC;IACzC,SAAS,EAAE;GACC,qBAAqB,CA4DjC","sourcesContent":["import {\n css,\n html,\n LitElement,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { localized, msg, str } from '@lit/localize';\nimport { formatUsd } from '../localized-format';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport type { DonationPaymentInfo } from '../models/donation-payment-info';\nimport { DonationType } from '../models/donation-type';\n\n/** The \"Total: $X\" line under the amount picker, with \"/month\" for monthly gifts. */\n@customElement('ia-donation-total-amount')\n@localized()\nexport class IADonationTotalAmount extends LitElement {\n @property({ type: Object }) donationInfo?: DonationPaymentInfo;\n\n render(): TemplateResult {\n return html`\n <div class=\"top-line\"></div>\n <div class=\"total-line\">${this.totalLine}</div>\n `;\n }\n\n private get totalLine(): string {\n if (!this.donationInfo) return '';\n const amount = formatUsd(this.donationInfo.total);\n return this.donationInfo.donationType === DonationType.Monthly\n ? msg(str`Total: ${amount}/month`)\n : msg(str`Total: ${amount}`);\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-total-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-total-line-color--: var(\n --ia-donation-total-amount-line-color,\n var(--mid-gray)\n );\n --donation-total-line-thickness--: var(\n --ia-donation-total-amount-line-thickness,\n 2px\n );\n --donation-total-vertical-spacing--: var(\n --ia-donation-total-amount-vertical-spacing,\n var(--padding-sm)\n );\n --donation-total-font-size--: var(\n --ia-donation-total-amount-font-size,\n calc(var(--donation-total-base-font-size--) * 2.6)\n );\n }\n\n .top-line {\n width: 100%;\n height: var(--donation-total-line-thickness--);\n background-color: var(--donation-total-line-color--);\n }\n\n .total-line {\n font-size: var(--donation-total-font-size--);\n font-weight: bold;\n text-align: center;\n margin-top: var(--donation-total-vertical-spacing--);\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The language the app last finished loading, falling back to the page's
|
|
3
|
+
* `lang`. `@lit/localize` only hands `getLocale` to whoever configures it, and
|
|
4
|
+
* this package never does, so the locale is read from its status event.
|
|
5
|
+
*/
|
|
6
|
+
export declare function currentLocale(): string;
|
|
7
|
+
/**
|
|
8
|
+
* Formats a US dollar amount for the current language. English keeps the
|
|
9
|
+
* `$10.00` form. Other languages get `Intl.NumberFormat`'s USD form, like
|
|
10
|
+
* `10,00 US$` in Spanish.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatUsd(amount: number, precision?: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* The country choices as `[code, name]` pairs. English keeps the list in its
|
|
15
|
+
* own order and spelling. Other languages get each name from
|
|
16
|
+
* `Intl.DisplayNames`, sorted in that language, and a country the browser
|
|
17
|
+
* can't name keeps its English name.
|
|
18
|
+
*/
|
|
19
|
+
export declare function localizedCountries(): [string, string][];
|
|
20
|
+
//# sourceMappingURL=localized-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localized-format.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/localized-format.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAMD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,MAAM,CAe/D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAgBvD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import currency from 'currency.js';
|
|
2
|
+
import { countries } from './form-elements/contact-form/countries.js';
|
|
3
|
+
let readyLocale;
|
|
4
|
+
if (typeof window !== 'undefined') {
|
|
5
|
+
window.addEventListener('lit-localize-status', (event) => {
|
|
6
|
+
const detail = event.detail;
|
|
7
|
+
if (detail.status === 'ready')
|
|
8
|
+
readyLocale = detail.readyLocale;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The language the app last finished loading, falling back to the page's
|
|
13
|
+
* `lang`. `@lit/localize` only hands `getLocale` to whoever configures it, and
|
|
14
|
+
* this package never does, so the locale is read from its status event.
|
|
15
|
+
*/
|
|
16
|
+
export function currentLocale() {
|
|
17
|
+
if (readyLocale)
|
|
18
|
+
return readyLocale;
|
|
19
|
+
if (typeof document === 'undefined')
|
|
20
|
+
return 'en';
|
|
21
|
+
return document.documentElement.lang || 'en';
|
|
22
|
+
}
|
|
23
|
+
function isEnglish(locale) {
|
|
24
|
+
return locale === 'en' || locale.startsWith('en-');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Formats a US dollar amount for the current language. English keeps the
|
|
28
|
+
* `$10.00` form. Other languages get `Intl.NumberFormat`'s USD form, like
|
|
29
|
+
* `10,00 US$` in Spanish.
|
|
30
|
+
*/
|
|
31
|
+
export function formatUsd(amount, precision = 2) {
|
|
32
|
+
const locale = currentLocale();
|
|
33
|
+
if (isEnglish(locale)) {
|
|
34
|
+
return currency(amount, { symbol: '$', precision }).format();
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return new Intl.NumberFormat(locale, {
|
|
38
|
+
style: 'currency',
|
|
39
|
+
currency: 'USD',
|
|
40
|
+
minimumFractionDigits: precision,
|
|
41
|
+
maximumFractionDigits: precision,
|
|
42
|
+
}).format(amount);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return currency(amount, { symbol: '$', precision }).format();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The country choices as `[code, name]` pairs. English keeps the list in its
|
|
50
|
+
* own order and spelling. Other languages get each name from
|
|
51
|
+
* `Intl.DisplayNames`, sorted in that language, and a country the browser
|
|
52
|
+
* can't name keeps its English name.
|
|
53
|
+
*/
|
|
54
|
+
export function localizedCountries() {
|
|
55
|
+
const locale = currentLocale();
|
|
56
|
+
const entries = Object.entries(countries);
|
|
57
|
+
if (isEnglish(locale))
|
|
58
|
+
return entries;
|
|
59
|
+
try {
|
|
60
|
+
const displayNames = new Intl.DisplayNames([locale], { type: 'region' });
|
|
61
|
+
const collator = new Intl.Collator(locale);
|
|
62
|
+
return entries
|
|
63
|
+
.map(([code, englishName]) => {
|
|
64
|
+
const name = displayNames.of(code);
|
|
65
|
+
return [code, name && name !== code ? name : englishName.trim()];
|
|
66
|
+
})
|
|
67
|
+
.sort((a, b) => collator.compare(a[1], b[1]));
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return entries;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=localized-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localized-format.js","sourceRoot":"","sources":["../../../../src/elements/ia-donation-form/localized-format.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAInE,IAAI,WAA+B,CAAC;AAEpC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,MAAM,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,CAAC,K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IAChC,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI,SAAS,CAAC,MAAM,CAAC;QAAE,OAAO,OAAO,CAAC;IACtC,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,OAAO;aACX,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,WAAW,CAAC,EAAoB,EAAE;YAC7C,MAAM,IAAI,GAAG,YAAY,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;YACnC,OAAO,CAAC,IAAI,EAAE,IAAI,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QACnE,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["import currency from 'currency.js';\n\nimport { countries } from './form-elements/contact-form/countries';\n\ntype LocaleStatusDetail = { status: string; readyLocale?: string };\n\nlet readyLocale: string | undefined;\n\nif (typeof window !== 'undefined') {\n window.addEventListener('lit-localize-status', (event) => {\n const detail = (event as CustomEvent<LocaleStatusDetail>).detail;\n if (detail.status === 'ready') readyLocale = detail.readyLocale;\n });\n}\n\n/**\n * The language the app last finished loading, falling back to the page's\n * `lang`. `@lit/localize` only hands `getLocale` to whoever configures it, and\n * this package never does, so the locale is read from its status event.\n */\nexport function currentLocale(): string {\n if (readyLocale) return readyLocale;\n if (typeof document === 'undefined') return 'en';\n return document.documentElement.lang || 'en';\n}\n\nfunction isEnglish(locale: string): boolean {\n return locale === 'en' || locale.startsWith('en-');\n}\n\n/**\n * Formats a US dollar amount for the current language. English keeps the\n * `$10.00` form. Other languages get `Intl.NumberFormat`'s USD form, like\n * `10,00 US$` in Spanish.\n */\nexport function formatUsd(amount: number, precision = 2): string {\n const locale = currentLocale();\n if (isEnglish(locale)) {\n return currency(amount, { symbol: '$', precision }).format();\n }\n try {\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: 'USD',\n minimumFractionDigits: precision,\n maximumFractionDigits: precision,\n }).format(amount);\n } catch {\n return currency(amount, { symbol: '$', precision }).format();\n }\n}\n\n/**\n * The country choices as `[code, name]` pairs. English keeps the list in its\n * own order and spelling. Other languages get each name from\n * `Intl.DisplayNames`, sorted in that language, and a country the browser\n * can't name keeps its English name.\n */\nexport function localizedCountries(): [string, string][] {\n const locale = currentLocale();\n const entries = Object.entries(countries);\n if (isEnglish(locale)) return entries;\n try {\n const displayNames = new Intl.DisplayNames([locale], { type: 'region' });\n const collator = new Intl.Collator(locale);\n return entries\n .map(([code, englishName]): [string, string] => {\n const name = displayNames.of(code);\n return [code, name && name !== code ? name : englishName.trim()];\n })\n .sort((a, b) => collator.compare(a[1], b[1]));\n } catch {\n return entries;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-confirm-modal.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-confirm-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"ia-donation-confirm-modal.d.ts","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-confirm-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAQb,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;;GAGG;AACH,qBAEa,sBAAuB,SAAQ,UAAU;IACxB,MAAM,SAAK;IAEvC,iFAAiF;IACrD,YAAY,SAAS;IAErB,YAAY,EAAE,YAAY,CAAwB;IAE9C,eAAe,EAAE,MAAM,IAAI,CAAY;IAEvC,cAAc,EAAE,MAAM,IAAI,CAAY;IAEtE,OAAO,KAAK,eAAe,GAG1B;IAED,IAAI,gBAAgB,IAAI,cAAc,CAQrC;IAED,IAAI,iBAAiB,IAAI,cAAc,CAQtC;IAED,IAAI,UAAU,IAAI,MAAM,CAIvB;IAED,MAAM,IAAI,cAAc;IAiBxB,MAAM,KAAK,MAAM,IAAI,cAAc,CAsDlC;IAED;;;;OAIG;IACH,IAAI,cAAc,IAAI,MAAM,CAiD3B;CACF"}
|
|
@@ -2,7 +2,8 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html, LitElement, } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { customElement } from '../../../utils/custom-element.js';
|
|
5
|
-
import { msg } from '@lit/localize';
|
|
5
|
+
import { localized, msg } from '@lit/localize';
|
|
6
|
+
import { formatUsd } from '../localized-format.js';
|
|
6
7
|
import currency from 'currency.js';
|
|
7
8
|
import themeStyles from '../../../themes/theme-styles.js';
|
|
8
9
|
import { DonationType } from '../models/donation-type.js';
|
|
@@ -21,6 +22,8 @@ let IADonationConfirmModal = class IADonationConfirmModal extends LitElement {
|
|
|
21
22
|
this.cancelDonation = () => { };
|
|
22
23
|
}
|
|
23
24
|
get formattedAmount() {
|
|
25
|
+
if (this.currencyType === 'USD')
|
|
26
|
+
return formatUsd(this.amount);
|
|
24
27
|
return currency(this.amount, { symbol: this.currencySymbol }).format();
|
|
25
28
|
}
|
|
26
29
|
get confirmationText() {
|
|
@@ -189,7 +192,8 @@ __decorate([
|
|
|
189
192
|
property({ attribute: false })
|
|
190
193
|
], IADonationConfirmModal.prototype, "cancelDonation", void 0);
|
|
191
194
|
IADonationConfirmModal = __decorate([
|
|
192
|
-
customElement('ia-donation-confirm-modal')
|
|
195
|
+
customElement('ia-donation-confirm-modal'),
|
|
196
|
+
localized()
|
|
193
197
|
], IADonationConfirmModal);
|
|
194
198
|
export { IADonationConfirmModal };
|
|
195
199
|
//# sourceMappingURL=ia-donation-confirm-modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-confirm-modal.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-confirm-modal.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ia-donation-confirm-modal.js","sourceRoot":"","sources":["../../../../../src/elements/ia-donation-form/modals/ia-donation-confirm-modal.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB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BACR,OAAO,GAAG,CAAC;YACb,KAAK,KAAK;gBACR,OAAO,KAAK,CAAC;YACf;gBACE,OAAO,GAAG,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAA;AA1K6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAY;AAGX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAsB;AAErB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAmD;AAE9C;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+DAAwC;AAEvC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8DAAuC;AAV3D,sBAAsB;IAFlC,aAAa,CAAC,2BAA2B,CAAC;IAC1C,SAAS,EAAE;GACC,sBAAsB,CA2KlC","sourcesContent":["import {\n css,\n html,\n LitElement,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { localized, msg } from '@lit/localize';\nimport { formatUsd } from '../localized-format';\nimport currency from 'currency.js';\n\nimport themeStyles from '@src/themes/theme-styles';\nimport { DonationType } from '../models/donation-type';\n\n/**\n * The confirmation step shown before a PayPal donation goes through: what the\n * donor is about to give, with Complete and Cancel buttons.\n */\n@customElement('ia-donation-confirm-modal')\n@localized()\nexport class IADonationConfirmModal extends LitElement {\n @property({ type: Number }) amount = 5;\n\n /** An ISO currency code, e.g. `USD`. Drives the symbol shown with the amount. */\n @property({ type: String }) currencyType = 'USD';\n\n @property({ type: String }) donationType: DonationType = DonationType.OneTime;\n\n @property({ attribute: false }) confirmDonation: () => void = () => {};\n\n @property({ attribute: false }) cancelDonation: () => void = () => {};\n\n private get formattedAmount(): string {\n if (this.currencyType === 'USD') return formatUsd(this.amount);\n return currency(this.amount, { symbol: this.currencySymbol }).format();\n }\n\n get confirmationText(): TemplateResult {\n return msg(html`\n <p>\n You are about to make a <b>${this.donationType}</b> donation of\n <b>${this.formattedAmount} ${this.currencyType}</b> to the Internet\n Archive.\n </p>\n `);\n }\n\n get confirmUpsellText(): TemplateResult {\n return msg(html`\n <p>\n You are about to begin making <b>monthly</b> donations of\n <b>${this.formattedAmount} ${this.currencyType}</b> to the Internet\n Archive. (Your first recurring contribution will be next month.)\n </p>\n `);\n }\n\n get confirmCTA(): string {\n return this.donationType === DonationType.Upsell\n ? msg('Start monthly donation')\n : msg('Complete donation');\n }\n\n render(): TemplateResult {\n return html`\n ${this.donationType === DonationType.Upsell\n ? this.confirmUpsellText\n : this.confirmationText}\n\n <div class=\"cta-group\">\n <button id=\"confirm\" @click=${() => this.confirmDonation()}>\n ${this.confirmCTA}\n </button>\n <button id=\"cancel\" @click=${() => this.cancelDonation()}>\n ${msg('Cancel')}\n </button>\n </div>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-confirm-base-font-size--: var(\n --ia-donation-form-base-font-size,\n 10px\n );\n --donation-confirm-cta-color--: var(\n --ia-donation-upsell-cta-button-color,\n var(--navy-blue)\n );\n --donation-confirm-cta-disabled-color--: var(\n --ia-donation-upsell-cta-button-disabled-color,\n rgba(109, 148, 201, 0.5)\n );\n\n display: block;\n }\n\n button {\n outline: none;\n cursor: pointer;\n }\n\n button#confirm {\n font-size: calc(var(--donation-confirm-base-font-size--) * 2);\n display: block;\n width: 100%;\n margin-top: var(--padding-sm);\n padding: var(--donation-confirm-base-font-size--)\n calc(var(--donation-confirm-base-font-size--) * 2);\n background-color: var(--donation-confirm-cta-color--);\n color: var(--true-white);\n border-radius: 5px;\n border: 0;\n font-weight: bold;\n line-height: normal;\n }\n\n button#cancel {\n margin-top: var(--donation-confirm-base-font-size--);\n border: 0;\n text-decoration: underline;\n background-color: transparent;\n }\n\n button:disabled {\n background-color: var(--donation-confirm-cta-disabled-color--);\n cursor: not-allowed;\n }\n `,\n ];\n }\n\n /**\n * The symbol for a PayPal-supported currency code. Dollars for anything\n * unlisted, which covers USD and NZD.\n * https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/\n */\n get currencySymbol(): string {\n switch (this.currencyType) {\n case 'AUD':\n return 'AU$';\n case 'BRL':\n return 'R$';\n case 'CAD':\n return 'CA$';\n case 'CHF':\n return 'Fr';\n case 'CNY':\n return '¥';\n case 'CZK':\n return 'Kč';\n case 'DKK':\n return 'Kr';\n case 'EUR':\n return '€';\n case 'GBP':\n return '£';\n case 'HKD':\n return 'HK$';\n case 'HUF':\n return 'Ft';\n case 'ILS':\n return '₪';\n case 'JPY':\n return '¥';\n case 'MXN':\n return 'MX$';\n case 'MYR':\n return 'RM';\n case 'NOK':\n return 'kr';\n case 'PLN':\n return 'zł';\n case 'RUB':\n return '₽';\n case 'SEK':\n return 'kr';\n case 'SGD':\n return 'S$';\n case 'THB':\n return '฿';\n case 'TWD':\n return 'NT$';\n default:\n return '$';\n }\n }\n}\n"]}
|
|
@@ -11,9 +11,20 @@ export type CurrentAmountMode = 'on' | 'off';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare class IADonationThermometer extends LitElement {
|
|
13
13
|
goalMessageMode: GoalMessageMode;
|
|
14
|
+
/**
|
|
15
|
+
* The message shown when the goal is near. Empty shows the built-in message
|
|
16
|
+
* in the current language.
|
|
17
|
+
*/
|
|
14
18
|
goalNearMessage: string;
|
|
19
|
+
/**
|
|
20
|
+
* The message shown when the goal is reached. Empty shows the built-in
|
|
21
|
+
* message in the current language.
|
|
22
|
+
*/
|
|
15
23
|
goalReachedMessage: string;
|
|
16
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The accessible name of the progress bar, for screen readers. Empty uses
|
|
26
|
+
* the built-in name in the current language.
|
|
27
|
+
*/
|
|
17
28
|
label: string;
|
|
18
29
|
goalAmount: number;
|
|
19
30
|
currentAmountMode: CurrentAmountMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-thermometer.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-donation-thermometer/ia-donation-thermometer.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAOb,iFAAiF;AACjF,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE3D,wDAAwD;AACxD,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,KAAK,CAAC;AAE7C;;;;;GAKG;AACH,
|
|
1
|
+
{"version":3,"file":"ia-donation-thermometer.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-donation-thermometer/ia-donation-thermometer.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAOb,iFAAiF;AACjF,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE3D,wDAAwD;AACxD,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,KAAK,CAAC;AAE7C;;;;;GAKG;AACH,qBAEa,qBAAsB,SAAQ,UAAU;IACvB,eAAe,EAAE,eAAe,CAAY;IAExE;;;OAGG;IACyB,eAAe,SAAM;IAEjD;;;OAGG;IACyB,kBAAkB,SAAM;IAEpD;;;OAGG;IACyB,KAAK,SAAM;IAEX,UAAU,SAAa;IAEvB,iBAAiB,EAAE,iBAAiB,CAAQ;IAE5C,aAAa,SAAK;IAEjB,OAAO,CAAC,gBAAgB,CAAC,CAAiB;IAE3C,OAAO,CAAC,eAAe,CAAC,CAAiB;IAE5D,OAAO,CAAC,qBAAqB,CAAK;IAElC,OAAO,CAAC,oBAAoB,CAAK;IAE1C;;;OAGG;IACH,OAAO,CAAC,cAAc,CAAC,CAAiB;IAExC;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB,CAAwB;IAEnD,OAAO,CAAC,oBAAoB,CAAwB;IAEpD,MAAM,IAAI,cAAc;IA2BxB,OAAO,KAAK,wBAAwB,GAMnC;IAED;;;;;OAKG;IACH,OAAO,KAAK,wBAAwB,GAKnC;IAED,iBAAiB,IAAI,IAAI;IAUzB,oBAAoB,IAAI,IAAI;IAQ5B,OAAO,IAAI,IAAI;IAIf,kFAAkF;IAClF,OAAO,CAAC,YAAY;IAgBpB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,YAAY;IAYpB,OAAO,KAAK,WAAW,GAItB;IAED,OAAO,KAAK,yBAAyB,GAEpC;IAED,OAAO,KAAK,sBAAsB,GAEjC;IAED;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAYpB,OAAO,KAAK,kBAAkB,GAS7B;IAED;;;;;OAKG;IACH,OAAO,KAAK,WAAW,GAItB;IAED;;;;OAIG;IACH,OAAO,KAAK,aAAa,GAGxB;IAED;;;OAGG;IACH,OAAO,KAAK,eAAe,GAK1B;IAED,MAAM,KAAK,MAAM,IAAI,cAAc,CAmIlC;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,yBAAyB,EAAE,qBAAqB,CAAC;KAClD;CACF"}
|
|
@@ -2,7 +2,7 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html, LitElement, nothing, } from 'lit';
|
|
3
3
|
import { property, query, state } from 'lit/decorators.js';
|
|
4
4
|
import { customElement } from '../../utils/custom-element.js';
|
|
5
|
-
import { msg, str } from '@lit/localize';
|
|
5
|
+
import { localized, msg, str } from '@lit/localize';
|
|
6
6
|
import themeStyles from '../../themes/theme-styles.js';
|
|
7
7
|
/**
|
|
8
8
|
* A horizontal progress bar for a fundraising goal, as shown in the
|
|
@@ -14,10 +14,21 @@ let IADonationThermometer = class IADonationThermometer extends LitElement {
|
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
16
|
this.goalMessageMode = 'amount';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The message shown when the goal is near. Empty shows the built-in message
|
|
19
|
+
* in the current language.
|
|
20
|
+
*/
|
|
21
|
+
this.goalNearMessage = '';
|
|
22
|
+
/**
|
|
23
|
+
* The message shown when the goal is reached. Empty shows the built-in
|
|
24
|
+
* message in the current language.
|
|
25
|
+
*/
|
|
26
|
+
this.goalReachedMessage = '';
|
|
27
|
+
/**
|
|
28
|
+
* The accessible name of the progress bar, for screen readers. Empty uses
|
|
29
|
+
* the built-in name in the current language.
|
|
30
|
+
*/
|
|
31
|
+
this.label = '';
|
|
21
32
|
this.goalAmount = 7_500_000;
|
|
22
33
|
this.currentAmountMode = 'on';
|
|
23
34
|
this.currentAmount = 0;
|
|
@@ -40,7 +51,7 @@ let IADonationThermometer = class IADonationThermometer extends LitElement {
|
|
|
40
51
|
class="thermometer-background ${this.thermometerValuePosition}"
|
|
41
52
|
style="--fill-end--: ${this.percentComplete}%"
|
|
42
53
|
role="progressbar"
|
|
43
|
-
aria-label="${this.label}"
|
|
54
|
+
aria-label="${this.label || msg('Donation progress')}"
|
|
44
55
|
aria-valuemin="0"
|
|
45
56
|
aria-valuemax="${this.progressMax}"
|
|
46
57
|
aria-valuenow="${this.progressValue}"
|
|
@@ -128,8 +139,8 @@ let IADonationThermometer = class IADonationThermometer extends LitElement {
|
|
|
128
139
|
}
|
|
129
140
|
get goalMessage() {
|
|
130
141
|
return this.currentAmount >= this.goalAmount
|
|
131
|
-
? this.goalReachedMessage
|
|
132
|
-
: this.goalNearMessage;
|
|
142
|
+
? this.goalReachedMessage || msg('We’ve reached our goal!')
|
|
143
|
+
: this.goalNearMessage || msg('We’ve almost reached our goal!');
|
|
133
144
|
}
|
|
134
145
|
get currentAmountDisplayValue() {
|
|
135
146
|
return this.formatNumber(this.currentAmount);
|
|
@@ -363,7 +374,8 @@ __decorate([
|
|
|
363
374
|
state()
|
|
364
375
|
], IADonationThermometer.prototype, "thermometerFillWidth", void 0);
|
|
365
376
|
IADonationThermometer = __decorate([
|
|
366
|
-
customElement('ia-donation-thermometer')
|
|
377
|
+
customElement('ia-donation-thermometer'),
|
|
378
|
+
localized()
|
|
367
379
|
], IADonationThermometer);
|
|
368
380
|
export { IADonationThermometer };
|
|
369
381
|
//# sourceMappingURL=ia-donation-thermometer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-donation-thermometer.js","sourceRoot":"","sources":["../../../../src/elements/ia-donation-thermometer/ia-donation-thermometer.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAQnD;;;;;GAKG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAA9C;;QACuB,oBAAe,GAAoB,QAAQ,CAAC;QAE5C,oBAAe,GAAG,GAAG,CAC/C,gCAAgC,CACjC,CAAC;QAE0B,uBAAkB,GAAG,GAAG,CAClD,yBAAyB,CAC1B,CAAC;QAEF,mEAAmE;QACvC,UAAK,GAAG,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAEjC,eAAU,GAAG,SAAS,CAAC;QAEvB,sBAAiB,GAAsB,IAAI,CAAC;QAE5C,kBAAa,GAAG,CAAC,CAAC;QAM7B,0BAAqB,GAAG,CAAC,CAAC;QAE1B,yBAAoB,GAAG,CAAC,CAAC;QAQ1C;;;;;WAKG;QACK,wBAAmB,GAAmB,IAAI,CAAC;QAE3C,yBAAoB,GAAmB,IAAI,CAAC;IAmUtD,CAAC;IAjUC,MAAM;Q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AA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAEzB;AAE0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAEzB;AAG0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAkC;AAEjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAwB;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAA6C;AAE5C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAmB;AAET;IAApC,KAAK,CAAC,oBAAoB,CAAC;+DAA2C;AAEnC;IAAnC,KAAK,CAAC,mBAAmB,CAAC;8DAA0C;AAEpD;IAAhB,KAAK,EAAE;oEAAmC;AAE1B;IAAhB,KAAK,EAAE;mEAAkC;AA1B/B,qBAAqB;IADjC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,qBAAqB,CA6WjC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { msg, str } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\n\n/** What the text beside the bar says: the goal amount, a message, or nothing. */\nexport type GoalMessageMode = 'off' | 'amount' | 'message';\n\n/** Whether the current amount is printed on the bar. */\nexport type CurrentAmountMode = 'on' | 'off';\n\n/**\n * A horizontal progress bar for a fundraising goal, as shown in the\n * archive.org donation banner. The fill grows with `currentAmount`, the amount\n * raised is printed on the fill when it fits and beside it when it doesn't,\n * and the goal (or a goal message) sits to the right of the bar.\n */\n@customElement('ia-donation-thermometer')\nexport class IADonationThermometer extends LitElement {\n @property({ type: String }) goalMessageMode: GoalMessageMode = 'amount';\n\n @property({ type: String }) goalNearMessage = msg(\n 'We’ve almost reached our goal!',\n );\n\n @property({ type: String }) goalReachedMessage = msg(\n 'We’ve reached our goal!',\n );\n\n /** The accessible name of the progress bar, for screen readers. */\n @property({ type: String }) label = msg('Donation progress');\n\n @property({ type: Number }) goalAmount = 7_500_000;\n\n @property({ type: String }) currentAmountMode: CurrentAmountMode = 'on';\n\n @property({ type: Number }) currentAmount = 0;\n\n @query('.thermometer-value') private thermometerValue?: HTMLDivElement;\n\n @query('.thermometer-fill') private thermometerFill?: HTMLDivElement;\n\n @state() private thermometerValueWidth = 0;\n\n @state() private thermometerFillWidth = 0;\n\n /**\n * Watches the fill and the value label so the label can move to whichever\n * side of the fill has room for it.\n */\n private resizeObserver?: ResizeObserver;\n\n /**\n * The observed nodes are tracked so each is observed exactly once. Calling\n * `observe` on an already-observed target re-reports its size, which costs a\n * notification on every render. Lit also discards the value label when\n * `currentAmountMode` turns it off, so a replacement has to be picked up.\n */\n private observedFillElement: Element | null = null;\n\n private observedValueElement: Element | null = null;\n\n render(): TemplateResult {\n return html`\n <div class=\"thermometer-message-container\">\n <div class=\"thermometer-container\">\n <div\n class=\"thermometer-background ${this.thermometerValuePosition}\"\n style=\"--fill-end--: ${this.percentComplete}%\"\n role=\"progressbar\"\n aria-label=\"${this.label}\"\n aria-valuemin=\"0\"\n aria-valuemax=\"${this.progressMax}\"\n aria-valuenow=\"${this.progressValue}\"\n aria-valuetext=\"${this.currentAmountDisplayValue}\"\n >\n <div class=\"thermometer-clip\">\n <div class=\"thermometer-fill\"></div>\n </div>\n ${this.thermometerValueTemplate}\n </div>\n </div>\n ${this.goalMessageMode !== 'off'\n ? html`<div class=\"donate-goal\">${this.currentGoalMessage}</div>`\n : nothing}\n </div>\n `;\n }\n\n private get thermometerValueTemplate(): TemplateResult | typeof nothing {\n return this.currentAmountMode === 'off'\n ? nothing\n : html`\n <div class=\"thermometer-value\">${this.currentAmountDisplayValue}</div>\n `;\n }\n\n /**\n * Which side of the fill's end the value label sits on, as a class name for\n * the CSS that places it. The label sits over the fill when the fill is\n * wider than the label plus a little breathing room, and just past the\n * fill's right edge otherwise.\n */\n private get thermometerValuePosition(): 'value-left' | 'value-right' {\n const buffer = 10;\n return this.thermometerValueWidth + buffer < this.thermometerFillWidth\n ? 'value-left'\n : 'value-right';\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.resizeObserver = new ResizeObserver((entries) =>\n this.handleResize(entries),\n );\n // On a re-connect the fill already exists; on first connect it doesn't\n // until the first render, and `updated` picks it up then.\n this.observeParts();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n this.resizeObserver = undefined;\n this.observedFillElement = null;\n this.observedValueElement = null;\n }\n\n updated(): void {\n this.observeParts();\n }\n\n /** Observes the fill and the value label, picking up either if it is replaced. */\n private observeParts(): void {\n const observer = this.resizeObserver;\n if (!observer) return;\n\n this.observedFillElement = this.observeInPlaceOf(\n observer,\n this.observedFillElement,\n this.thermometerFill ?? null,\n );\n this.observedValueElement = this.observeInPlaceOf(\n observer,\n this.observedValueElement,\n this.thermometerValue ?? null,\n );\n }\n\n /**\n * Swaps `observed` for `current` on the observer and returns whichever is\n * now being watched. A target that hasn't changed is left alone.\n */\n private observeInPlaceOf(\n observer: ResizeObserver,\n observed: Element | null,\n current: Element | null,\n ): Element | null {\n if (current === observed) return observed;\n if (observed) observer.unobserve(observed);\n if (current) observer.observe(current);\n return current;\n }\n\n private handleResize(entries: ResizeObserverEntry[]): void {\n for (const entry of entries) {\n const width =\n entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;\n if (entry.target === this.observedFillElement) {\n this.thermometerFillWidth = width;\n } else if (entry.target === this.observedValueElement) {\n this.thermometerValueWidth = width;\n }\n }\n }\n\n private get goalMessage(): string {\n return this.currentAmount >= this.goalAmount\n ? this.goalReachedMessage\n : this.goalNearMessage;\n }\n\n private get currentAmountDisplayValue(): string {\n return this.formatNumber(this.currentAmount);\n }\n\n private get goalAmountDisplayValue(): string {\n return this.formatNumber(this.goalAmount);\n }\n\n /**\n * Formats a dollar amount in millions, e.g. `$0.5MM` or `$35MM`. Amounts\n * under ten million keep one decimal place, larger ones round to a whole\n * number.\n */\n private formatNumber(number: number): string {\n if (!Number.isFinite(number) || number === 0) return '$0';\n const suffix = 'MM';\n const divisor = 1_000_000;\n const result = number / divisor;\n const roundToOne = result < 10;\n const rounded = roundToOne\n ? Math.round((result + Number.EPSILON) * 10) / 10\n : Math.round(result);\n return `$${rounded}${suffix}`;\n }\n\n private get currentGoalMessage(): string {\n switch (this.goalMessageMode) {\n case 'amount':\n return msg(str`${this.goalAmountDisplayValue} goal`);\n case 'message':\n return this.goalMessage;\n case 'off':\n return '';\n }\n }\n\n /**\n * The goal the bar measures against. A goal that isn't a positive, finite\n * number leaves the bar empty, since there is no range to report progress\n * against. Named clear of `ariaValueMax`, which `HTMLElement` declares as a\n * public string.\n */\n private get progressMax(): number {\n return Number.isFinite(this.goalAmount) && this.goalAmount > 0\n ? this.goalAmount\n : 0;\n }\n\n /**\n * The progress reported to screen readers, clamped into the\n * `aria-valuemin`/`aria-valuemax` range the spec requires.\n * `aria-valuetext` carries the amount as it is displayed.\n */\n private get progressValue(): number {\n if (!Number.isFinite(this.currentAmount)) return 0;\n return Math.min(Math.max(this.currentAmount, 0), this.progressMax);\n }\n\n /**\n * How much of the bar is filled, as a percentage, clamped to `0`-`100`. An\n * amount or goal that can't produce a usable percentage empties the bar.\n */\n private get percentComplete(): number {\n const goal = this.progressMax;\n if (goal === 0 || !Number.isFinite(this.currentAmount)) return 0;\n const percent = (this.currentAmount / goal) * 100;\n return Math.min(Math.max(percent, 0), 100);\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-thermometer-height--: var(\n --ia-donation-thermometer-height,\n 20px\n );\n --donation-thermometer-fill-color--: var(\n --ia-donation-thermometer-fill-color,\n #23765d\n );\n --donation-thermometer-track-color--: var(\n --ia-donation-thermometer-track-color,\n #b8f5e2\n );\n --donation-thermometer-border--: var(\n --ia-donation-thermometer-border,\n 1px solid var(--donation-thermometer-fill-color--)\n );\n /* Large enough to round any height into a pill */\n --donation-thermometer-border-radius--: var(\n --ia-donation-thermometer-border-radius,\n 9999px\n );\n --donation-thermometer-value-on-fill-color--: var(\n --ia-donation-thermometer-value-on-fill-color,\n var(--true-white)\n );\n --donation-thermometer-value-on-track-color--: var(\n --ia-donation-thermometer-value-on-track-color,\n var(--donation-thermometer-fill-color--)\n );\n --donation-thermometer-goal-color--: var(--primary-text-color);\n --donation-thermometer-goal-padding--: var(\n --ia-donation-thermometer-goal-padding,\n 0 10px\n );\n\n display: block;\n height: var(--donation-thermometer-height--);\n }\n\n .thermometer-message-container {\n height: 100%;\n display: flex;\n align-items: center;\n }\n\n .thermometer-container {\n height: 100%;\n flex: 1;\n }\n\n .thermometer-background {\n box-sizing: border-box;\n position: relative;\n background-color: var(--donation-thermometer-track-color--);\n height: 100%;\n border-radius: var(--donation-thermometer-border-radius--);\n border: var(--donation-thermometer-border--);\n }\n\n /*\n * Clips the square-ended fill to the rounded track. It covers only the\n * fill, so the label is never cut off by it.\n */\n .thermometer-clip {\n position: absolute;\n inset: 0;\n overflow: hidden;\n border-radius: var(--donation-thermometer-border-radius--);\n }\n\n .thermometer-fill {\n background-color: var(--donation-thermometer-fill-color--);\n height: 100%;\n /*\n * The fallback matters: without it a missing --fill-end-- makes the\n * declaration invalid, width resolves to auto, and the bar paints as\n * a fully funded fundraiser.\n */\n width: var(--fill-end--, 0%);\n }\n\n /*\n * The label is placed by offset from the end of the fill, so it is one\n * node in one position in the DOM whichever side it shows on, and it\n * never counts towards the width of the fill it is measured against.\n */\n .thermometer-value {\n position: absolute;\n top: 0;\n bottom: 0;\n left: var(--fill-end--, 0%);\n /*\n * Without this, the left offset caps the shrink-to-fit width of a\n * translated label and it collapses to its padding.\n */\n width: max-content;\n display: flex;\n align-items: center;\n font-weight: bold;\n white-space: nowrap;\n }\n\n /*\n * Both paddings total 1.5rem, so changing sides leaves the label the\n * same width and cannot feed back into the side it is placed on.\n */\n .value-left .thermometer-value {\n transform: translateX(-100%);\n color: var(--donation-thermometer-value-on-fill-color--);\n padding: 0 0.5rem 0 1rem;\n }\n\n .value-right .thermometer-value {\n color: var(--donation-thermometer-value-on-track-color--);\n padding: 0 1rem 0 0.5rem;\n }\n\n .donate-goal {\n text-align: left;\n padding: var(--donation-thermometer-goal-padding--);\n text-transform: uppercase;\n font-weight: bold;\n color: var(--donation-thermometer-goal-color--);\n }\n `,\n ];\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ia-donation-thermometer': IADonationThermometer;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ia-donation-thermometer.js","sourceRoot":"","sources":["../../../../src/elements/ia-donation-thermometer/ia-donation-thermometer.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EACV,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAQnD;;;;;GAKG;AAGI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,UAAU;IAA9C;;QACuB,oBAAe,GAAoB,QAAQ,CAAC;QAExE;;;WAGG;QACyB,oBAAe,GAAG,EAAE,CAAC;QAEjD;;;WAGG;QACyB,uBAAkB,GAAG,EAAE,CAAC;QAEpD;;;WAGG;QACyB,UAAK,GAAG,EAAE,CAAC;QAEX,eAAU,GAAG,SAAS,CAAC;QAEvB,sBAAiB,GAAsB,IAAI,CAAC;QAE5C,kBAAa,GAAG,CAAC,CAAC;QAM7B,0BAAqB,GAAG,CAAC,CAAC;QAE1B,yBAAoB,GAAG,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8HF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAnX6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAA6C;AAM5C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAsB;AAMrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAAyB;AAMxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAwB;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAA6C;AAE5C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAmB;AAET;IAApC,KAAK,CAAC,oBAAoB,CAAC;+DAA2C;AAEnC;IAAnC,KAAK,CAAC,mBAAmB,CAAC;8DAA0C;AAEpD;IAAhB,KAAK,EAAE;oEAAmC;AAE1B;IAAhB,KAAK,EAAE;mEAAkC;AAjC/B,qBAAqB;IAFjC,aAAa,CAAC,yBAAyB,CAAC;IACxC,SAAS,EAAE;GACC,qBAAqB,CAoXjC","sourcesContent":["import {\n css,\n html,\n LitElement,\n nothing,\n type CSSResultGroup,\n type TemplateResult,\n} from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { customElement } from '@src/utils/custom-element';\nimport { localized, msg, str } from '@lit/localize';\n\nimport themeStyles from '@src/themes/theme-styles';\n\n/** What the text beside the bar says: the goal amount, a message, or nothing. */\nexport type GoalMessageMode = 'off' | 'amount' | 'message';\n\n/** Whether the current amount is printed on the bar. */\nexport type CurrentAmountMode = 'on' | 'off';\n\n/**\n * A horizontal progress bar for a fundraising goal, as shown in the\n * archive.org donation banner. The fill grows with `currentAmount`, the amount\n * raised is printed on the fill when it fits and beside it when it doesn't,\n * and the goal (or a goal message) sits to the right of the bar.\n */\n@customElement('ia-donation-thermometer')\n@localized()\nexport class IADonationThermometer extends LitElement {\n @property({ type: String }) goalMessageMode: GoalMessageMode = 'amount';\n\n /**\n * The message shown when the goal is near. Empty shows the built-in message\n * in the current language.\n */\n @property({ type: String }) goalNearMessage = '';\n\n /**\n * The message shown when the goal is reached. Empty shows the built-in\n * message in the current language.\n */\n @property({ type: String }) goalReachedMessage = '';\n\n /**\n * The accessible name of the progress bar, for screen readers. Empty uses\n * the built-in name in the current language.\n */\n @property({ type: String }) label = '';\n\n @property({ type: Number }) goalAmount = 7_500_000;\n\n @property({ type: String }) currentAmountMode: CurrentAmountMode = 'on';\n\n @property({ type: Number }) currentAmount = 0;\n\n @query('.thermometer-value') private thermometerValue?: HTMLDivElement;\n\n @query('.thermometer-fill') private thermometerFill?: HTMLDivElement;\n\n @state() private thermometerValueWidth = 0;\n\n @state() private thermometerFillWidth = 0;\n\n /**\n * Watches the fill and the value label so the label can move to whichever\n * side of the fill has room for it.\n */\n private resizeObserver?: ResizeObserver;\n\n /**\n * The observed nodes are tracked so each is observed exactly once. Calling\n * `observe` on an already-observed target re-reports its size, which costs a\n * notification on every render. Lit also discards the value label when\n * `currentAmountMode` turns it off, so a replacement has to be picked up.\n */\n private observedFillElement: Element | null = null;\n\n private observedValueElement: Element | null = null;\n\n render(): TemplateResult {\n return html`\n <div class=\"thermometer-message-container\">\n <div class=\"thermometer-container\">\n <div\n class=\"thermometer-background ${this.thermometerValuePosition}\"\n style=\"--fill-end--: ${this.percentComplete}%\"\n role=\"progressbar\"\n aria-label=\"${this.label || msg('Donation progress')}\"\n aria-valuemin=\"0\"\n aria-valuemax=\"${this.progressMax}\"\n aria-valuenow=\"${this.progressValue}\"\n aria-valuetext=\"${this.currentAmountDisplayValue}\"\n >\n <div class=\"thermometer-clip\">\n <div class=\"thermometer-fill\"></div>\n </div>\n ${this.thermometerValueTemplate}\n </div>\n </div>\n ${this.goalMessageMode !== 'off'\n ? html`<div class=\"donate-goal\">${this.currentGoalMessage}</div>`\n : nothing}\n </div>\n `;\n }\n\n private get thermometerValueTemplate(): TemplateResult | typeof nothing {\n return this.currentAmountMode === 'off'\n ? nothing\n : html`\n <div class=\"thermometer-value\">${this.currentAmountDisplayValue}</div>\n `;\n }\n\n /**\n * Which side of the fill's end the value label sits on, as a class name for\n * the CSS that places it. The label sits over the fill when the fill is\n * wider than the label plus a little breathing room, and just past the\n * fill's right edge otherwise.\n */\n private get thermometerValuePosition(): 'value-left' | 'value-right' {\n const buffer = 10;\n return this.thermometerValueWidth + buffer < this.thermometerFillWidth\n ? 'value-left'\n : 'value-right';\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.resizeObserver = new ResizeObserver((entries) =>\n this.handleResize(entries),\n );\n // On a re-connect the fill already exists; on first connect it doesn't\n // until the first render, and `updated` picks it up then.\n this.observeParts();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n this.resizeObserver?.disconnect();\n this.resizeObserver = undefined;\n this.observedFillElement = null;\n this.observedValueElement = null;\n }\n\n updated(): void {\n this.observeParts();\n }\n\n /** Observes the fill and the value label, picking up either if it is replaced. */\n private observeParts(): void {\n const observer = this.resizeObserver;\n if (!observer) return;\n\n this.observedFillElement = this.observeInPlaceOf(\n observer,\n this.observedFillElement,\n this.thermometerFill ?? null,\n );\n this.observedValueElement = this.observeInPlaceOf(\n observer,\n this.observedValueElement,\n this.thermometerValue ?? null,\n );\n }\n\n /**\n * Swaps `observed` for `current` on the observer and returns whichever is\n * now being watched. A target that hasn't changed is left alone.\n */\n private observeInPlaceOf(\n observer: ResizeObserver,\n observed: Element | null,\n current: Element | null,\n ): Element | null {\n if (current === observed) return observed;\n if (observed) observer.unobserve(observed);\n if (current) observer.observe(current);\n return current;\n }\n\n private handleResize(entries: ResizeObserverEntry[]): void {\n for (const entry of entries) {\n const width =\n entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;\n if (entry.target === this.observedFillElement) {\n this.thermometerFillWidth = width;\n } else if (entry.target === this.observedValueElement) {\n this.thermometerValueWidth = width;\n }\n }\n }\n\n private get goalMessage(): string {\n return this.currentAmount >= this.goalAmount\n ? this.goalReachedMessage || msg('We’ve reached our goal!')\n : this.goalNearMessage || msg('We’ve almost reached our goal!');\n }\n\n private get currentAmountDisplayValue(): string {\n return this.formatNumber(this.currentAmount);\n }\n\n private get goalAmountDisplayValue(): string {\n return this.formatNumber(this.goalAmount);\n }\n\n /**\n * Formats a dollar amount in millions, e.g. `$0.5MM` or `$35MM`. Amounts\n * under ten million keep one decimal place, larger ones round to a whole\n * number.\n */\n private formatNumber(number: number): string {\n if (!Number.isFinite(number) || number === 0) return '$0';\n const suffix = 'MM';\n const divisor = 1_000_000;\n const result = number / divisor;\n const roundToOne = result < 10;\n const rounded = roundToOne\n ? Math.round((result + Number.EPSILON) * 10) / 10\n : Math.round(result);\n return `$${rounded}${suffix}`;\n }\n\n private get currentGoalMessage(): string {\n switch (this.goalMessageMode) {\n case 'amount':\n return msg(str`${this.goalAmountDisplayValue} goal`);\n case 'message':\n return this.goalMessage;\n case 'off':\n return '';\n }\n }\n\n /**\n * The goal the bar measures against. A goal that isn't a positive, finite\n * number leaves the bar empty, since there is no range to report progress\n * against. Named clear of `ariaValueMax`, which `HTMLElement` declares as a\n * public string.\n */\n private get progressMax(): number {\n return Number.isFinite(this.goalAmount) && this.goalAmount > 0\n ? this.goalAmount\n : 0;\n }\n\n /**\n * The progress reported to screen readers, clamped into the\n * `aria-valuemin`/`aria-valuemax` range the spec requires.\n * `aria-valuetext` carries the amount as it is displayed.\n */\n private get progressValue(): number {\n if (!Number.isFinite(this.currentAmount)) return 0;\n return Math.min(Math.max(this.currentAmount, 0), this.progressMax);\n }\n\n /**\n * How much of the bar is filled, as a percentage, clamped to `0`-`100`. An\n * amount or goal that can't produce a usable percentage empties the bar.\n */\n private get percentComplete(): number {\n const goal = this.progressMax;\n if (goal === 0 || !Number.isFinite(this.currentAmount)) return 0;\n const percent = (this.currentAmount / goal) * 100;\n return Math.min(Math.max(percent, 0), 100);\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --donation-thermometer-height--: var(\n --ia-donation-thermometer-height,\n 20px\n );\n --donation-thermometer-fill-color--: var(\n --ia-donation-thermometer-fill-color,\n #23765d\n );\n --donation-thermometer-track-color--: var(\n --ia-donation-thermometer-track-color,\n #b8f5e2\n );\n --donation-thermometer-border--: var(\n --ia-donation-thermometer-border,\n 1px solid var(--donation-thermometer-fill-color--)\n );\n /* Large enough to round any height into a pill */\n --donation-thermometer-border-radius--: var(\n --ia-donation-thermometer-border-radius,\n 9999px\n );\n --donation-thermometer-value-on-fill-color--: var(\n --ia-donation-thermometer-value-on-fill-color,\n var(--true-white)\n );\n --donation-thermometer-value-on-track-color--: var(\n --ia-donation-thermometer-value-on-track-color,\n var(--donation-thermometer-fill-color--)\n );\n --donation-thermometer-goal-color--: var(--primary-text-color);\n --donation-thermometer-goal-padding--: var(\n --ia-donation-thermometer-goal-padding,\n 0 10px\n );\n\n display: block;\n height: var(--donation-thermometer-height--);\n }\n\n .thermometer-message-container {\n height: 100%;\n display: flex;\n align-items: center;\n }\n\n .thermometer-container {\n height: 100%;\n flex: 1;\n }\n\n .thermometer-background {\n box-sizing: border-box;\n position: relative;\n background-color: var(--donation-thermometer-track-color--);\n height: 100%;\n border-radius: var(--donation-thermometer-border-radius--);\n border: var(--donation-thermometer-border--);\n }\n\n /*\n * Clips the square-ended fill to the rounded track. It covers only the\n * fill, so the label is never cut off by it.\n */\n .thermometer-clip {\n position: absolute;\n inset: 0;\n overflow: hidden;\n border-radius: var(--donation-thermometer-border-radius--);\n }\n\n .thermometer-fill {\n background-color: var(--donation-thermometer-fill-color--);\n height: 100%;\n /*\n * The fallback matters: without it a missing --fill-end-- makes the\n * declaration invalid, width resolves to auto, and the bar paints as\n * a fully funded fundraiser.\n */\n width: var(--fill-end--, 0%);\n }\n\n /*\n * The label is placed by offset from the end of the fill, so it is one\n * node in one position in the DOM whichever side it shows on, and it\n * never counts towards the width of the fill it is measured against.\n */\n .thermometer-value {\n position: absolute;\n top: 0;\n bottom: 0;\n left: var(--fill-end--, 0%);\n /*\n * Without this, the left offset caps the shrink-to-fit width of a\n * translated label and it collapses to its padding.\n */\n width: max-content;\n display: flex;\n align-items: center;\n font-weight: bold;\n white-space: nowrap;\n }\n\n /*\n * Both paddings total 1.5rem, so changing sides leaves the label the\n * same width and cannot feed back into the side it is placed on.\n */\n .value-left .thermometer-value {\n transform: translateX(-100%);\n color: var(--donation-thermometer-value-on-fill-color--);\n padding: 0 0.5rem 0 1rem;\n }\n\n .value-right .thermometer-value {\n color: var(--donation-thermometer-value-on-track-color--);\n padding: 0 1rem 0 0.5rem;\n }\n\n .donate-goal {\n text-align: left;\n padding: var(--donation-thermometer-goal-padding--);\n text-transform: uppercase;\n font-weight: bold;\n color: var(--donation-thermometer-goal-color--);\n }\n `,\n ];\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ia-donation-thermometer': IADonationThermometer;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/elements",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"description": "A web component library from the Internet Archive.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
"ghpages:build": "wireit",
|
|
34
34
|
"strings:extract": "wireit",
|
|
35
35
|
"strings:build": "wireit",
|
|
36
|
-
"strings:translate": "node scripts/translate-xliff.mts"
|
|
36
|
+
"strings:translate": "node scripts/translate-xliff.mts",
|
|
37
|
+
"i18n:draft": "pnpm run strings:extract && pnpm run strings:translate",
|
|
38
|
+
"i18n:status": "node scripts/i18n-status.mts"
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
39
41
|
"@internetarchive/analytics-manager": "^0.1.5",
|