@digital-realty/ix-email-list 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/IxEmailList.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export interface EmailListItem {
|
|
|
10
10
|
isDuplicate?: boolean;
|
|
11
11
|
isDisconnected?: boolean;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
declare const ixEmailListBaseClass: import("@material/web/labs/behaviors/mixin.js").MixinReturn<import("@material/web/labs/behaviors/mixin.js").MixinReturn<typeof LitElement, import("@material/web/labs/behaviors/element-internals.js").WithElementInternals>, object>;
|
|
14
|
+
export declare class IxEmailList extends ixEmailListBaseClass {
|
|
14
15
|
static get styles(): import("lit").CSSResult[];
|
|
15
16
|
/** @nocollapse */
|
|
16
17
|
static shadowRootOptions: {
|
|
@@ -106,3 +107,4 @@ export declare class IxEmailList extends LitElement {
|
|
|
106
107
|
private addError;
|
|
107
108
|
render(): import("lit-html").TemplateResult<1>;
|
|
108
109
|
}
|
|
110
|
+
export {};
|
package/dist/IxEmailList.js
CHANGED
|
@@ -3,13 +3,15 @@ import '@digital-realty/ix-chip/ix-chip-set.js';
|
|
|
3
3
|
import '@digital-realty/ix-chip/ix-chip.js';
|
|
4
4
|
import '@digital-realty/ix-field/ix-field.js';
|
|
5
5
|
import '@digital-realty/ix-icon-button/ix-icon-button.js';
|
|
6
|
-
import {
|
|
6
|
+
import { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';
|
|
7
|
+
import { mixinElementInternals } from '@material/web/labs/behaviors/element-internals.js';
|
|
7
8
|
import { html, LitElement, nothing } from 'lit';
|
|
8
9
|
import { property, query, state } from 'lit/decorators.js';
|
|
9
10
|
import { classMap } from 'lit/directives/class-map.js';
|
|
10
11
|
import { IxEmailListStyles } from './ix-email-list-styles.js';
|
|
11
12
|
import { isValidEmail } from './utils/email-validation.js';
|
|
12
|
-
|
|
13
|
+
const ixEmailListBaseClass = mixinDelegatesAria(mixinElementInternals(LitElement));
|
|
14
|
+
export class IxEmailList extends ixEmailListBaseClass {
|
|
13
15
|
constructor() {
|
|
14
16
|
super(...arguments);
|
|
15
17
|
this.internals = this /* needed for closure */
|
|
@@ -306,9 +308,6 @@ export class IxEmailList extends LitElement {
|
|
|
306
308
|
`;
|
|
307
309
|
}
|
|
308
310
|
}
|
|
309
|
-
(() => {
|
|
310
|
-
requestUpdateOnAriaChange(IxEmailList);
|
|
311
|
-
})();
|
|
312
311
|
/** @nocollapse */
|
|
313
312
|
IxEmailList.shadowRootOptions = {
|
|
314
313
|
...LitElement.shadowRootOptions,
|
package/dist/IxEmailList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxEmailList.js","sourceRoot":"","sources":["../src/IxEmailList.ts"],"names":[],"mappings":";AAAA,OAAO,wCAAwC,CAAC;AAChD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,kDAAkD,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAU3D,MAAM,OAAO,WAAY,SAAQ,UAAU;IAA3C;;QAkBmB,cAAS,GAAI,IAAoB,CAAC,wBAAwB;aACxE,eAAe,EAAE,CAAC;QAIrB,kDAAkD;QACtC,WAAM,GAA6C,GAAG,EAAE,CAClE,SAAS,CAAC;QAEgB,UAAK,GAAG,EAAE,CAAC;QAEX,UAAK,GAAG,EAAE,CA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E,IAAI,EAAE,CAAC;0CAAe;AAEd;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAkB;AAG/B;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;8CAA2B;AAEZ;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAAyB;AAEzB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sDAAwB;AAEvB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAc;AAE5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAyB;AA6B3C;IAAR,KAAK,EAAE;4CAAyB;AAExB;IAAR,KAAK,EAAE;+CAAyB;AAExB;IAAR,KAAK,EAAE;8CAAiC","sourcesContent":["import '@digital-realty/ix-chip/ix-chip-set.js';\nimport '@digital-realty/ix-chip/ix-chip.js';\nimport '@digital-realty/ix-field/ix-field.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';\nimport { html, LitElement, nothing, PropertyValues } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { IxEmailListStyles } from './ix-email-list-styles.js';\nimport { isValidEmail } from './utils/email-validation.js';\n\nexport interface EmailListItem {\n address: string;\n isValid: boolean;\n name?: string;\n isDuplicate?: boolean;\n isDisconnected?: boolean;\n}\n\nexport class IxEmailList extends LitElement {\n static {\n requestUpdateOnAriaChange(IxEmailList);\n }\n\n static get styles() {\n return [IxEmailListStyles];\n }\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** @nocollapse */\n static readonly formAssociated = true;\n\n private readonly internals = (this as HTMLElement) /* needed for closure */\n .attachInternals();\n\n @query('#email-input') emailInput!: HTMLInputElement;\n\n // eslint-disable-next-line class-methods-use-this\n @property() lookup: (address?: string) => string | undefined = () =>\n undefined;\n\n @property({ type: String }) label = '';\n\n @property({ type: String }) value = '';\n\n @property({ type: String, attribute: 'error-text' }) errorText =\n 'Invalid email in list.';\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * Gets or sets whether or not the text field is in a visually invalid state.\n *\n * This error state overrides the error state controlled by\n * `reportValidity()`.\n */\n @property({ type: Boolean, reflect: true }) error = false;\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n // eslint-disable-next-line class-methods-use-this\n @property({ type: Function }) onChanged: any = () => {};\n\n @property({ type: Boolean, reflect: true }) checkDuplicates = false;\n\n @property({ type: Number, reflect: true }) maximumEmailCount = -1;\n\n @property({ type: Number, reflect: true }) tabIndex = 0;\n\n @property({ type: Number }) maximumEmailLength = -1;\n\n private errorMessage: string = '';\n\n /**\n * The associated form element with which this element's value will submit.\n */\n get form() {\n return this.internals.form;\n }\n\n /**\n * The labels this element is associated with.\n */\n get labels() {\n return this.internals.labels;\n }\n\n /**\n * The HTML name to use in form submission.\n */\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n @state() private focused = false;\n\n @state() private inputValue = '';\n\n @state() addresses: EmailListItem[] = [];\n\n /**\n * Returns the text field's validation error message.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation\n */\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n /**\n * Returns a `ValidityState` object that represents the validity states of the\n * text field.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ValidityState\n */\n get validity() {\n return this.internals.validity;\n }\n\n /**\n * Returns whether an element will successfully validate based on forms\n * validation rules and constraints.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate\n */\n get willValidate() {\n return this.internals.willValidate;\n }\n\n checkValidity() {\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n return this.internals.reportValidity();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.reset(true);\n }\n\n private chipRemove = async (id: number) => {\n const addresses = this.addresses.filter((_item, i: number) => i !== id);\n this.addresses = [];\n await 0;\n this.addresses = addresses;\n this.isValidList();\n this.value = this.addresses.map(item => item.address).join(',');\n this.onChanged(this.addresses);\n if (!this.addresses.length) {\n this.handleFocusout();\n }\n };\n\n handleFocusin = () => {\n this.focused = true;\n };\n\n handleFocusout = () => {\n if (this.inputValue) {\n this.resolveInput();\n }\n this.focused = false;\n };\n\n keydown = (e: KeyboardEvent) => {\n // input completion keys\n const completionKeys = [' ', ',', 'Tab', 'Enter', ';'];\n if (completionKeys.includes(e.key) && this.inputValue.length) {\n e.preventDefault();\n this.resolveInput();\n }\n };\n\n resolveInput = () => {\n const address = this.inputValue.toLowerCase();\n const isValid = isValidEmail(address);\n\n const name = this.lookup(address);\n this.addresses = [...this.addresses, { address, isValid, name }];\n this.inputValue = '';\n this.value = this.addresses.map(item => item.address).join(',');\n this.isValidList();\n this.onChanged(this.addresses);\n };\n\n input = (e: InputEvent) => {\n const { value } = e.target as HTMLInputElement;\n this.inputValue = value;\n };\n\n validate() {\n if (this.required && this.addresses.length === 0) {\n this.addError(this.errorText);\n } else {\n this.isValidList();\n }\n }\n\n clear = (isDisconnected: boolean) => {\n this.addresses = [];\n this.inputValue = '';\n this.value = '';\n this.error = false;\n if (!isDisconnected) {\n this.onChanged(this.addresses);\n }\n this.handleFocusout();\n };\n\n /** @private */\n formResetCallback() {\n this.reset(false);\n }\n\n /**\n * Reset the text field to its default value.\n */\n reset(isDisconnected: boolean) {\n this.clear(isDisconnected);\n this.value = this.getAttribute('value') ?? '';\n }\n\n isValidList = () => {\n this.errorMessage = '';\n this.error = false;\n\n if (this.addresses.some((item: EmailListItem) => !item.isValid))\n this.addError(this.errorText);\n\n if (this.checkDuplicates) this.checkForDuplicates();\n\n if (this.maximumEmailCount > 0) this.validateEmailCount();\n if (this.maximumEmailLength > 0) this.validateEmailLength();\n\n this.internals.setValidity(\n {\n badInput: this.error,\n },\n this.error ? this.errorMessage : '',\n this.emailInput\n );\n };\n\n validateEmailCount() {\n if (this.addresses.length > this.maximumEmailCount)\n this.addError(\n `Maximum of ${this.maximumEmailCount} emails are allowed. `\n );\n }\n\n validateEmailLength() {\n if (\n this.addresses.some(\n (item: EmailListItem) => item.address.length > this.maximumEmailLength\n )\n )\n this.addError(\n `Email address exceeds the maximum length of ${this.maximumEmailLength} characters.`\n );\n }\n\n checkForDuplicates() {\n let hasDuplicates = false;\n\n const groupByAddress = this.addresses.reduce((addressMap, email, index) => {\n const { address } = email;\n\n if (!addressMap[address]) {\n addressMap[address] = [];\n }\n addressMap[address].push(index);\n return addressMap;\n }, {} as Record<string, number[]>);\n\n Object.values(groupByAddress).forEach((addressIds: number[]) => {\n if (addressIds.length > 1) {\n hasDuplicates = true;\n addressIds.forEach(index => {\n this.addresses[index].isDuplicate = true;\n });\n } else {\n this.addresses[addressIds[0]].isDuplicate = false;\n }\n });\n\n if (hasDuplicates) {\n this.addError('Duplicate emails detected.');\n }\n }\n\n static labelText = (item: EmailListItem) => {\n const address = item.isValid ? item.address : `${item.address}!`;\n return item.name ? item.name : address;\n };\n\n protected override updated(changedProperties: PropertyValues) {\n if (changedProperties.has('disabled')) {\n this.tabIndex = this.disabled ? -1 : 0;\n }\n if (changedProperties.has('value')) {\n this.internals.setFormValue(this.value);\n if (this.value.trim() !== '') {\n this.addresses = this.value.split(',').map((item: string) => {\n const address = item.toLowerCase().trim();\n return {\n address,\n isValid: isValidEmail(address),\n };\n });\n } else {\n this.addresses = [];\n }\n this.isValidList();\n }\n }\n\n override focus() {\n this.emailInput.focus();\n }\n\n private addError(errorText: string) {\n this.error = true;\n this.errorMessage += errorText;\n }\n\n render() {\n const classes = {\n disabled: this.disabled,\n error: !this.disabled && this.error,\n };\n\n return html`\n <ix-field\n class=\"${classMap(classes)}\"\n ?focused=${this.focused}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?checkDuplicates=${this.checkDuplicates}\n ?maximumEmailCount=${this.maximumEmailCount}\n label=${this.label}\n ?error=${this.error}\n error-text=${this.errorMessage}\n @focusin=${this.handleFocusin}\n @focusout=${this.handleFocusout}\n ?populated=${this.addresses.length || this.inputValue.length}\n >\n <div class=\"field-content\">\n ${this.addresses.length\n ? html`<ix-chip-set>\n ${this.addresses.map(\n (item, id: number) => html`<span\n ><ix-chip\n @remove=${() => this.chipRemove(id)}\n label=${IxEmailList.labelText(item)}\n class=${!item.isValid || item.isDuplicate ? 'error' : ''}\n appearance=\"input\"\n removable\n remove-only\n ></ix-chip\n ></span>`\n )}\n </ix-chip-set>`\n : nothing}\n <input\n id=\"email-input\"\n @keydown=${this.keydown}\n @input=${this.input}\n .value=${this.inputValue}\n type=\"text\"\n />\n </div>\n <slot name=\"end\" slot=\"end\">\n ${this.addresses.length\n ? html`<ix-icon-button\n class=\"clear-icon\"\n @click=${() => this.clear(false)}\n icon=\"close\"\n aria-label=\"clear\"\n ></ix-icon-button>`\n : nothing}\n </slot>\n </ix-field>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IxEmailList.js","sourceRoot":"","sources":["../src/IxEmailList.ts"],"names":[],"mappings":";AAAA,OAAO,wCAAwC,CAAC;AAChD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,kDAAkD,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA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;2CACC;AAEgB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAY;AAEc;IAApD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;8CACzB;AAEiB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAkB;AAQjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEd;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAkB;AAG/B;IAA7B,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;8CAA2B;AAEZ;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAAyB;AAEzB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sDAAwB;AAEvB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAc;AAE5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAyB;AA6B3C;IAAR,KAAK,EAAE;4CAAyB;AAExB;IAAR,KAAK,EAAE;+CAAyB;AAExB;IAAR,KAAK,EAAE;8CAAiC","sourcesContent":["import '@digital-realty/ix-chip/ix-chip-set.js';\nimport '@digital-realty/ix-chip/ix-chip.js';\nimport '@digital-realty/ix-field/ix-field.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport { mixinDelegatesAria } from '@material/web/internal/aria/delegate.js';\nimport { mixinElementInternals } from '@material/web/labs/behaviors/element-internals.js';\nimport { html, LitElement, nothing, PropertyValues } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { IxEmailListStyles } from './ix-email-list-styles.js';\nimport { isValidEmail } from './utils/email-validation.js';\n\nexport interface EmailListItem {\n address: string;\n isValid: boolean;\n name?: string;\n isDuplicate?: boolean;\n isDisconnected?: boolean;\n}\n\nconst ixEmailListBaseClass = mixinDelegatesAria(\n mixinElementInternals(LitElement)\n);\n\nexport class IxEmailList extends ixEmailListBaseClass {\n static get styles() {\n return [IxEmailListStyles];\n }\n\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /** @nocollapse */\n static readonly formAssociated = true;\n\n private readonly internals = (this as HTMLElement) /* needed for closure */\n .attachInternals();\n\n @query('#email-input') emailInput!: HTMLInputElement;\n\n // eslint-disable-next-line class-methods-use-this\n @property() lookup: (address?: string) => string | undefined = () =>\n undefined;\n\n @property({ type: String }) label = '';\n\n @property({ type: String }) value = '';\n\n @property({ type: String, attribute: 'error-text' }) errorText =\n 'Invalid email in list.';\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * Gets or sets whether or not the text field is in a visually invalid state.\n *\n * This error state overrides the error state controlled by\n * `reportValidity()`.\n */\n @property({ type: Boolean, reflect: true }) error = false;\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n // eslint-disable-next-line class-methods-use-this\n @property({ type: Function }) onChanged: any = () => {};\n\n @property({ type: Boolean, reflect: true }) checkDuplicates = false;\n\n @property({ type: Number, reflect: true }) maximumEmailCount = -1;\n\n @property({ type: Number, reflect: true }) tabIndex = 0;\n\n @property({ type: Number }) maximumEmailLength = -1;\n\n private errorMessage: string = '';\n\n /**\n * The associated form element with which this element's value will submit.\n */\n get form() {\n return this.internals.form;\n }\n\n /**\n * The labels this element is associated with.\n */\n get labels() {\n return this.internals.labels;\n }\n\n /**\n * The HTML name to use in form submission.\n */\n get name() {\n return this.getAttribute('name') ?? '';\n }\n\n set name(name: string) {\n this.setAttribute('name', name);\n }\n\n @state() private focused = false;\n\n @state() private inputValue = '';\n\n @state() addresses: EmailListItem[] = [];\n\n /**\n * Returns the text field's validation error message.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation\n */\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n /**\n * Returns a `ValidityState` object that represents the validity states of the\n * text field.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ValidityState\n */\n get validity() {\n return this.internals.validity;\n }\n\n /**\n * Returns whether an element will successfully validate based on forms\n * validation rules and constraints.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate\n */\n get willValidate() {\n return this.internals.willValidate;\n }\n\n checkValidity() {\n return this.internals.checkValidity();\n }\n\n reportValidity() {\n return this.internals.reportValidity();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.reset(true);\n }\n\n private chipRemove = async (id: number) => {\n const addresses = this.addresses.filter((_item, i: number) => i !== id);\n this.addresses = [];\n await 0;\n this.addresses = addresses;\n this.isValidList();\n this.value = this.addresses.map(item => item.address).join(',');\n this.onChanged(this.addresses);\n if (!this.addresses.length) {\n this.handleFocusout();\n }\n };\n\n handleFocusin = () => {\n this.focused = true;\n };\n\n handleFocusout = () => {\n if (this.inputValue) {\n this.resolveInput();\n }\n this.focused = false;\n };\n\n keydown = (e: KeyboardEvent) => {\n // input completion keys\n const completionKeys = [' ', ',', 'Tab', 'Enter', ';'];\n if (completionKeys.includes(e.key) && this.inputValue.length) {\n e.preventDefault();\n this.resolveInput();\n }\n };\n\n resolveInput = () => {\n const address = this.inputValue.toLowerCase();\n const isValid = isValidEmail(address);\n\n const name = this.lookup(address);\n this.addresses = [...this.addresses, { address, isValid, name }];\n this.inputValue = '';\n this.value = this.addresses.map(item => item.address).join(',');\n this.isValidList();\n this.onChanged(this.addresses);\n };\n\n input = (e: InputEvent) => {\n const { value } = e.target as HTMLInputElement;\n this.inputValue = value;\n };\n\n validate() {\n if (this.required && this.addresses.length === 0) {\n this.addError(this.errorText);\n } else {\n this.isValidList();\n }\n }\n\n clear = (isDisconnected: boolean) => {\n this.addresses = [];\n this.inputValue = '';\n this.value = '';\n this.error = false;\n if (!isDisconnected) {\n this.onChanged(this.addresses);\n }\n this.handleFocusout();\n };\n\n /** @private */\n formResetCallback() {\n this.reset(false);\n }\n\n /**\n * Reset the text field to its default value.\n */\n reset(isDisconnected: boolean) {\n this.clear(isDisconnected);\n this.value = this.getAttribute('value') ?? '';\n }\n\n isValidList = () => {\n this.errorMessage = '';\n this.error = false;\n\n if (this.addresses.some((item: EmailListItem) => !item.isValid))\n this.addError(this.errorText);\n\n if (this.checkDuplicates) this.checkForDuplicates();\n\n if (this.maximumEmailCount > 0) this.validateEmailCount();\n if (this.maximumEmailLength > 0) this.validateEmailLength();\n\n this.internals.setValidity(\n {\n badInput: this.error,\n },\n this.error ? this.errorMessage : '',\n this.emailInput\n );\n };\n\n validateEmailCount() {\n if (this.addresses.length > this.maximumEmailCount)\n this.addError(\n `Maximum of ${this.maximumEmailCount} emails are allowed. `\n );\n }\n\n validateEmailLength() {\n if (\n this.addresses.some(\n (item: EmailListItem) => item.address.length > this.maximumEmailLength\n )\n )\n this.addError(\n `Email address exceeds the maximum length of ${this.maximumEmailLength} characters.`\n );\n }\n\n checkForDuplicates() {\n let hasDuplicates = false;\n\n const groupByAddress = this.addresses.reduce((addressMap, email, index) => {\n const { address } = email;\n\n if (!addressMap[address]) {\n addressMap[address] = [];\n }\n addressMap[address].push(index);\n return addressMap;\n }, {} as Record<string, number[]>);\n\n Object.values(groupByAddress).forEach((addressIds: number[]) => {\n if (addressIds.length > 1) {\n hasDuplicates = true;\n addressIds.forEach(index => {\n this.addresses[index].isDuplicate = true;\n });\n } else {\n this.addresses[addressIds[0]].isDuplicate = false;\n }\n });\n\n if (hasDuplicates) {\n this.addError('Duplicate emails detected.');\n }\n }\n\n static labelText = (item: EmailListItem) => {\n const address = item.isValid ? item.address : `${item.address}!`;\n return item.name ? item.name : address;\n };\n\n protected override updated(changedProperties: PropertyValues) {\n if (changedProperties.has('disabled')) {\n this.tabIndex = this.disabled ? -1 : 0;\n }\n if (changedProperties.has('value')) {\n this.internals.setFormValue(this.value);\n if (this.value.trim() !== '') {\n this.addresses = this.value.split(',').map((item: string) => {\n const address = item.toLowerCase().trim();\n return {\n address,\n isValid: isValidEmail(address),\n };\n });\n } else {\n this.addresses = [];\n }\n this.isValidList();\n }\n }\n\n override focus() {\n this.emailInput.focus();\n }\n\n private addError(errorText: string) {\n this.error = true;\n this.errorMessage += errorText;\n }\n\n render() {\n const classes = {\n disabled: this.disabled,\n error: !this.disabled && this.error,\n };\n\n return html`\n <ix-field\n class=\"${classMap(classes)}\"\n ?focused=${this.focused}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?checkDuplicates=${this.checkDuplicates}\n ?maximumEmailCount=${this.maximumEmailCount}\n label=${this.label}\n ?error=${this.error}\n error-text=${this.errorMessage}\n @focusin=${this.handleFocusin}\n @focusout=${this.handleFocusout}\n ?populated=${this.addresses.length || this.inputValue.length}\n >\n <div class=\"field-content\">\n ${this.addresses.length\n ? html`<ix-chip-set>\n ${this.addresses.map(\n (item, id: number) => html`<span\n ><ix-chip\n @remove=${() => this.chipRemove(id)}\n label=${IxEmailList.labelText(item)}\n class=${!item.isValid || item.isDuplicate ? 'error' : ''}\n appearance=\"input\"\n removable\n remove-only\n ></ix-chip\n ></span>`\n )}\n </ix-chip-set>`\n : nothing}\n <input\n id=\"email-input\"\n @keydown=${this.keydown}\n @input=${this.input}\n .value=${this.inputValue}\n type=\"text\"\n />\n </div>\n <slot name=\"end\" slot=\"end\">\n ${this.addresses.length\n ? html`<ix-icon-button\n class=\"clear-icon\"\n @click=${() => this.clear(false)}\n icon=\"close\"\n aria-label=\"clear\"\n ></ix-icon-button>`\n : nothing}\n </slot>\n </ix-field>\n `;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import"@digital-realty/ix-chip/ix-chip-set.js";import"@digital-realty/ix-chip/ix-chip.js";import"@digital-realty/ix-field/ix-field.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import{
|
|
1
|
+
import{__decorate}from"tslib";import"@digital-realty/ix-chip/ix-chip-set.js";import"@digital-realty/ix-chip/ix-chip.js";import"@digital-realty/ix-field/ix-field.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import{mixinDelegatesAria}from"@material/web/internal/aria/delegate.js";import{mixinElementInternals}from"@material/web/labs/behaviors/element-internals.js";import{css,LitElement,nothing,html}from"lit";import{query,property,state}from"lit/decorators.js";import{classMap}from"lit/directives/class-map.js";let IxEmailListStyles=css`:host{display:block}:host([disabled]){pointer-events:none}ix-field{display:block}ix-field label{display:none}ix-chip.error{--ix-chip-container-color:var(--md-sys-color-error);--md-input-chip-outline-color:var(--md-sys-color-error)}.field-content{display:flex;flex-wrap:wrap;min-height:var(--ix-custom-field-min-height,24px)}input{border:none;background:0 0;outline:0;min-width:30%;line-height:var(--_content-line-height);flex-grow:1}ix-chip-set{min-height:var(--_content-line-height);display:flex;padding-right:.5rem}ix-icon-button{--md-icon-button-icon-color:var(--md-sys-text-color-secondary);--md-icon-button-hover-icon-color:var(--md-sys-text-color-secondary);--md-icon-button-hover-state-layer-color:var(
|
|
2
2
|
--md-sys-text-color-secondary
|
|
3
3
|
);--md-icon-button-pressed-icon-color:var(--md-sys-text-color-secondary);--md-icon-button-pressed-state-layer-color:var(
|
|
4
4
|
--md-sys-text-color-secondary
|
|
5
|
-
)}.clear-icon{margin-right:.5rem}`,isValidEmail=
|
|
5
|
+
)}.clear-icon{margin-right:.5rem}`,isValidEmail=e=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e),ixEmailListBaseClass=mixinDelegatesAria(mixinElementInternals(LitElement));class IxEmailList extends ixEmailListBaseClass{constructor(){super(...arguments),this.internals=this.attachInternals(),this.lookup=()=>{},this.label="",this.value="",this.errorText="Invalid email in list.",this.disabled=!1,this.error=!1,this.required=!1,this.onChanged=()=>{},this.checkDuplicates=!1,this.maximumEmailCount=-1,this.tabIndex=0,this.maximumEmailLength=-1,this.errorMessage="",this.focused=!1,this.inputValue="",this.addresses=[],this.chipRemove=async i=>{var e=this.addresses.filter((e,t)=>t!==i);this.addresses=[],await 0,this.addresses=e,this.isValidList(),this.value=this.addresses.map(e=>e.address).join(","),this.onChanged(this.addresses),this.addresses.length||this.handleFocusout()},this.handleFocusin=()=>{this.focused=!0},this.handleFocusout=()=>{this.inputValue&&this.resolveInput(),this.focused=!1},this.keydown=e=>{[" ",",","Tab","Enter",";"].includes(e.key)&&this.inputValue.length&&(e.preventDefault(),this.resolveInput())},this.resolveInput=()=>{var e=this.inputValue.toLowerCase(),t=isValidEmail(e),i=this.lookup(e);this.addresses=[...this.addresses,{address:e,isValid:t,name:i}],this.inputValue="",this.value=this.addresses.map(e=>e.address).join(","),this.isValidList(),this.onChanged(this.addresses)},this.input=e=>{e=e.target.value;this.inputValue=e},this.clear=e=>{this.addresses=[],this.inputValue="",this.value="",this.error=!1,e||this.onChanged(this.addresses),this.handleFocusout()},this.isValidList=()=>{this.errorMessage="",this.error=!1,this.addresses.some(e=>!e.isValid)&&this.addError(this.errorText),this.checkDuplicates&&this.checkForDuplicates(),0<this.maximumEmailCount&&this.validateEmailCount(),0<this.maximumEmailLength&&this.validateEmailLength(),this.internals.setValidity({badInput:this.error},this.error?this.errorMessage:"",this.emailInput)}}static get styles(){return[IxEmailListStyles]}get form(){return this.internals.form}get labels(){return this.internals.labels}get name(){var e;return null!=(e=this.getAttribute("name"))?e:""}set name(e){this.setAttribute("name",e)}get validationMessage(){return this.internals.validationMessage}get validity(){return this.internals.validity}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}disconnectedCallback(){super.disconnectedCallback(),this.reset(!0)}validate(){this.required&&0===this.addresses.length?this.addError(this.errorText):this.isValidList()}formResetCallback(){this.reset(!1)}reset(e){this.clear(e),this.value=null!=(e=this.getAttribute("value"))?e:""}validateEmailCount(){this.addresses.length>this.maximumEmailCount&&this.addError(`Maximum of ${this.maximumEmailCount} emails are allowed. `)}validateEmailLength(){this.addresses.some(e=>e.address.length>this.maximumEmailLength)&&this.addError(`Email address exceeds the maximum length of ${this.maximumEmailLength} characters.`)}checkForDuplicates(){let t=!1;var e=this.addresses.reduce((e,t,i)=>{t=t.address;return e[t]||(e[t]=[]),e[t].push(i),e},{});Object.values(e).forEach(e=>{1<e.length?(t=!0,e.forEach(e=>{this.addresses[e].isDuplicate=!0})):this.addresses[e[0]].isDuplicate=!1}),t&&this.addError("Duplicate emails detected.")}updated(e){e.has("disabled")&&(this.tabIndex=this.disabled?-1:0),e.has("value")&&(this.internals.setFormValue(this.value),""!==this.value.trim()?this.addresses=this.value.split(",").map(e=>{e=e.toLowerCase().trim();return{address:e,isValid:isValidEmail(e)}}):this.addresses=[],this.isValidList())}focus(){this.emailInput.focus()}addError(e){this.error=!0,this.errorMessage+=e}render(){var e={disabled:this.disabled,error:!this.disabled&&this.error};return html`<ix-field class="${classMap(e)}" ?focused="${this.focused}" ?disabled="${this.disabled}" ?required="${this.required}" ?checkDuplicates="${this.checkDuplicates}" ?maximumEmailCount="${this.maximumEmailCount}" label="${this.label}" ?error="${this.error}" error-text="${this.errorMessage}" @focusin="${this.handleFocusin}" @focusout="${this.handleFocusout}" ?populated="${this.addresses.length||this.inputValue.length}"><div class="field-content">${this.addresses.length?html`<ix-chip-set>${this.addresses.map((e,t)=>html`<span><ix-chip @remove="${()=>this.chipRemove(t)}" label="${IxEmailList.labelText(e)}" class="${!e.isValid||e.isDuplicate?"error":""}" appearance="input" removable remove-only></ix-chip></span>`)}</ix-chip-set>`:nothing} <input id="email-input" @keydown="${this.keydown}" @input="${this.input}" .value="${this.inputValue}" type="text"></div><slot name="end" slot="end">${this.addresses.length?html`<ix-icon-button class="clear-icon" @click="${()=>this.clear(!1)}" icon="close" aria-label="clear"></ix-icon-button>`:nothing}</slot></ix-field>`}}IxEmailList.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0},IxEmailList.formAssociated=!0,IxEmailList.labelText=e=>{var t=e.isValid?e.address:e.address+"!";return e.name||t},__decorate([query("#email-input")],IxEmailList.prototype,"emailInput",void 0),__decorate([property()],IxEmailList.prototype,"lookup",void 0),__decorate([property({type:String})],IxEmailList.prototype,"label",void 0),__decorate([property({type:String})],IxEmailList.prototype,"value",void 0),__decorate([property({type:String,attribute:"error-text"})],IxEmailList.prototype,"errorText",void 0),__decorate([property({type:Boolean,reflect:!0})],IxEmailList.prototype,"disabled",void 0),__decorate([property({type:Boolean,reflect:!0})],IxEmailList.prototype,"error",void 0),__decorate([property({type:Boolean,reflect:!0})],IxEmailList.prototype,"required",void 0),__decorate([property({type:Function})],IxEmailList.prototype,"onChanged",void 0),__decorate([property({type:Boolean,reflect:!0})],IxEmailList.prototype,"checkDuplicates",void 0),__decorate([property({type:Number,reflect:!0})],IxEmailList.prototype,"maximumEmailCount",void 0),__decorate([property({type:Number,reflect:!0})],IxEmailList.prototype,"tabIndex",void 0),__decorate([property({type:Number})],IxEmailList.prototype,"maximumEmailLength",void 0),__decorate([state()],IxEmailList.prototype,"focused",void 0),__decorate([state()],IxEmailList.prototype,"inputValue",void 0),__decorate([state()],IxEmailList.prototype,"addresses",void 0),window.customElements.define("ix-email-list",IxEmailList);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ix-email-list following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Digital Realty",
|
|
6
|
-
"version": "1.3.
|
|
6
|
+
"version": "1.3.4",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@digital-realty/ix-chip": "^1.2.
|
|
30
|
-
"@digital-realty/ix-field": "^1.2.
|
|
31
|
-
"@digital-realty/ix-icon-button": "^1.2.
|
|
32
|
-
"@material/web": "
|
|
29
|
+
"@digital-realty/ix-chip": "^1.2.4",
|
|
30
|
+
"@digital-realty/ix-field": "^1.2.3",
|
|
31
|
+
"@digital-realty/ix-icon-button": "^1.2.3",
|
|
32
|
+
"@material/web": "2.4.0",
|
|
33
33
|
"@web/test-runner-commands": "^0.9.0",
|
|
34
34
|
"lit": "^3.2.1"
|
|
35
35
|
},
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"README.md",
|
|
103
103
|
"LICENSE"
|
|
104
104
|
],
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "36d89e383e58b8b6bab4c26e956298524e9a69a8"
|
|
106
106
|
}
|