@digital-realty/ix-phone-input 2.2.7 → 2.2.9
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/IxPhoneInput.d.ts +2 -1
- package/dist/IxPhoneInput.js +20 -5
- package/dist/IxPhoneInput.js.map +1 -1
- package/esmDist/ix-phone-input.js +45 -31
- package/package.json +3 -3
package/dist/IxPhoneInput.d.ts
CHANGED
|
@@ -163,8 +163,9 @@ export declare class IxPhoneInput extends LitElement {
|
|
|
163
163
|
private handleFocusin;
|
|
164
164
|
private handleFocusout;
|
|
165
165
|
private getInput;
|
|
166
|
+
connectedCallback(): void;
|
|
166
167
|
protected firstUpdated(): void;
|
|
167
|
-
attributeChangedCallback(attribute: string,
|
|
168
|
+
attributeChangedCallback(attribute: string, oldValue: string | null, newValue: string | null): void;
|
|
168
169
|
protected updated(changedProperties: PropertyValues): void;
|
|
169
170
|
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
170
171
|
private handleInput;
|
package/dist/IxPhoneInput.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
+
/* eslint-disable lit/no-value-attribute */
|
|
2
3
|
import '@digital-realty/ix-field/ix-field.js';
|
|
3
4
|
import { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';
|
|
4
5
|
import { styles as outlinedForcedColorsStyles, styles as outlinedStyles, } from '@material/web/textfield/internal/outlined-styles.css.js';
|
|
@@ -231,6 +232,7 @@ export class IxPhoneInput extends LitElement {
|
|
|
231
232
|
var _a;
|
|
232
233
|
this.dirty = false;
|
|
233
234
|
this.value = (_a = this.getAttribute('value')) !== null && _a !== void 0 ? _a : '';
|
|
235
|
+
this.input.value = this.value;
|
|
234
236
|
this.nativeError = false;
|
|
235
237
|
this.nativeErrorText = '';
|
|
236
238
|
}
|
|
@@ -288,30 +290,40 @@ export class IxPhoneInput extends LitElement {
|
|
|
288
290
|
}
|
|
289
291
|
return this.input;
|
|
290
292
|
}
|
|
293
|
+
connectedCallback() {
|
|
294
|
+
super.connectedCallback();
|
|
295
|
+
if (!window.intlTelInputUtils) {
|
|
296
|
+
window.intlTelInputGlobals.loadUtils(CONFIG.UTILS_SCRIPT);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
291
299
|
firstUpdated() {
|
|
292
300
|
this.input.addEventListener('countrychange', () => {
|
|
293
301
|
this.formatValue();
|
|
302
|
+
this.dispatchEvent(new CustomEvent('country-change', {
|
|
303
|
+
bubbles: true,
|
|
304
|
+
composed: true,
|
|
305
|
+
}));
|
|
294
306
|
});
|
|
295
307
|
this.iti = intlTelInput(this.input, {
|
|
296
308
|
initialCountry: this.region !== '' ? this.region : 'auto',
|
|
297
|
-
|
|
309
|
+
formatOnDisplay: true,
|
|
310
|
+
nationalMode: false,
|
|
298
311
|
hiddenInput: 'full',
|
|
299
312
|
autoPlaceholder: 'off',
|
|
300
313
|
geoIpLookup: this.geoFn,
|
|
301
|
-
utilsScript: CONFIG.UTILS_SCRIPT,
|
|
302
314
|
});
|
|
303
315
|
this.iti.promise.then(() => {
|
|
304
316
|
// format on inititalisation
|
|
305
317
|
this.formatValue();
|
|
306
318
|
});
|
|
307
319
|
}
|
|
308
|
-
attributeChangedCallback(attribute,
|
|
320
|
+
attributeChangedCallback(attribute, oldValue, newValue) {
|
|
309
321
|
if (attribute === 'value' && this.dirty) {
|
|
310
322
|
// After user input, changing the value attribute no longer updates the
|
|
311
323
|
// text field's value (until reset). This matches native <input> behavior.
|
|
312
324
|
return;
|
|
313
325
|
}
|
|
314
|
-
super.attributeChangedCallback(attribute,
|
|
326
|
+
super.attributeChangedCallback(attribute, oldValue, newValue);
|
|
315
327
|
}
|
|
316
328
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
317
329
|
updated(changedProperties) {
|
|
@@ -347,6 +359,9 @@ export class IxPhoneInput extends LitElement {
|
|
|
347
359
|
(_a = this.iti) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
348
360
|
}
|
|
349
361
|
render() {
|
|
362
|
+
if (this.iti && this.value) {
|
|
363
|
+
this.iti.setNumber(this.value);
|
|
364
|
+
}
|
|
350
365
|
const classes = {
|
|
351
366
|
disabled: this.disabled,
|
|
352
367
|
error: !this.disabled && this.hasError,
|
|
@@ -371,12 +386,12 @@ export class IxPhoneInput extends LitElement {
|
|
|
371
386
|
<input
|
|
372
387
|
name="${this.name}"
|
|
373
388
|
type="${this.type}"
|
|
389
|
+
value="${this.value}"
|
|
374
390
|
?disabled=${this.disabled}
|
|
375
391
|
?required=${this.required}
|
|
376
392
|
aria-invalid=${this.hasError}
|
|
377
393
|
aria-label=${ariaLabel}
|
|
378
394
|
aria-describedby="description"
|
|
379
|
-
.value="${this.value}"
|
|
380
395
|
@input="${this.handleInput}"
|
|
381
396
|
@keypress="${this.handleKeyPress}"
|
|
382
397
|
/>
|
package/dist/IxPhoneInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxPhoneInput.js","sourceRoot":"","sources":["../src/IxPhoneInput.ts"],"names":[],"mappings":";AAAA,OAAO,sCAAsC,CAAC;AAE9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EACL,MAAM,IAAI,0BAA0B,EACpC,MAAM,IAAI,cAAc,GACzB,MAAM,yDAAyD,CAAC;AACjE,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,uDAAuD,CAAC;AAC/F,OAAO,YAAwB,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,OAAO,EAAE,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,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,k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AE,IAAI;CACrB,AAHgC,CAG/B;AAEF,mBAAmB;AACH,2BAAc,GAAG,IAAI,AAAP,CAAQ;AArB7B;IADR,KAAK,CAAC,OAAO,CAAC;2CACmB;AAEA;IAAjC,KAAK,CAAC,QAAQ,CAAC;2CAAuC;AAyBtC;IADhB,QAAQ,EAAE;0CACmB;AAEc;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB;AAQjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAe;AAUnB;IAAtC,QAAQ,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;+CAAgB;AAMV;IAA3C,QAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;oDAAqB;AAEpB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB;AAM5C;IAAhB,KAAK,EAAE;2CAAuB;AAEd;IAAhB,KAAK,EAAE;6CAAyB;AAKhB;IAAhB,KAAK,EAAE;iDAA6B;AAMpB;IAAhB,KAAK,EAAE;qDAA8B;AAiN1B;IAAX,QAAQ,EAAE;2CAAY;AAEK;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAa;AAG5B;IAAX,QAAQ,EAAE;2CAAkE","sourcesContent":["import '@digital-realty/ix-field/ix-field.js';\nimport { Field } from '@material/web/field/internal/field.js';\nimport { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';\nimport {\n styles as outlinedForcedColorsStyles,\n styles as outlinedStyles,\n} from '@material/web/textfield/internal/outlined-styles.css.js';\nimport { styles as sharedStyles } from '@material/web/textfield/internal/shared-styles.css.js';\nimport intlTelInput, { Plugin } from 'intl-tel-input';\nimport { LitElement, PropertyValues, html, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { CONFIG } from './config.js';\nimport { IxPhoneInputStyles } from './ix-phone-input-styles.js';\n\nexport class IxPhoneInput extends LitElement {\n static {\n requestUpdateOnAriaChange(IxPhoneInput);\n }\n\n @query('input')\n readonly input!: HTMLInputElement;\n\n @query('.field') private readonly field?: Field | null;\n\n static get styles() {\n return [\n sharedStyles,\n outlinedStyles,\n outlinedForcedColorsStyles,\n CONFIG.FLAG_SPRITES,\n IxPhoneInputStyles,\n ];\n }\n\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\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 @property()\n private readonly type = 'tel';\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 /**\n * The error message that replaces supporting text when `error` is true. If\n * `errorText` is an empty string, then the supporting text will continue to\n * show.\n *\n * This error message overrides the error message displayed by\n * `reportValidity()`.\n */\n @property({ attribute: 'error-text' }) errorText = '';\n\n /**\n * Conveys additional information below the text field, such as how it should\n * be used.\n */\n @property({ attribute: 'supporting-text' }) supportingText = '';\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n /**\n * Returns true when the text field has been interacted with. Native\n * validation errors only display in response to user interactions.\n */\n @state() private dirty = false;\n\n @state() private focused = false;\n\n /**\n * Whether or not a native error has been reported via `reportValidity()`.\n */\n @state() private nativeError = false;\n\n /**\n * The validation message displayed from a native error via\n * `reportValidity()`.\n */\n @state() private nativeErrorText = '';\n\n private get hasError() {\n return this.error || this.nativeError;\n }\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 this.syncValidity();\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 this.syncValidity();\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 this.syncValidity();\n return this.internals.willValidate;\n }\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 /**\n * Gets or sets the direction in which selection occurred.\n */\n get selectionDirection() {\n return this.getInput().selectionDirection;\n }\n\n set selectionDirection(value: 'forward' | 'backward' | 'none' | null) {\n this.getInput().selectionDirection = value;\n }\n\n /**\n * Gets or sets the end position or offset of a text selection.\n */\n get selectionEnd() {\n return this.getInput().selectionEnd;\n }\n\n set selectionEnd(value: number | null) {\n this.getInput().selectionEnd = value;\n }\n\n /**\n * Gets or sets the starting position or offset of a text selection.\n */\n get selectionStart() {\n return this.getInput().selectionStart;\n }\n\n set selectionStart(value: number | null) {\n this.getInput().selectionStart = value;\n }\n\n /**\n * Checks the text field's native validation and returns whether or not the\n * element is valid.\n *\n * If invalid, this method will dispatch the `invalid` event.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity\n *\n * @return true if the text field is valid, or false if not.\n */\n checkValidity() {\n this.syncValidity();\n return this.internals.checkValidity();\n }\n\n /**\n * Checks the text field's native validation and returns whether or not the\n * element is valid.\n *\n * If invalid, this method will dispatch the `invalid` event.\n *\n * This method will display or clear an error text message equal to the text\n * field's `validationMessage`, unless the invalid event is canceled.\n *\n * Use `setCustomValidity()` to customize the `validationMessage`.\n *\n * This method can also be used to re-announce error messages to screen\n * readers.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity\n *\n * @return true if the text field is valid, or false if not.\n */\n reportValidity() {\n let invalidEvent: Event | undefined;\n this.addEventListener(\n 'invalid',\n event => {\n invalidEvent = event;\n },\n { once: true }\n );\n\n const valid = this.checkValidity();\n if (invalidEvent?.defaultPrevented) {\n return valid;\n }\n\n const prevMessage = this.getErrorText();\n this.nativeError = !valid;\n this.nativeErrorText = this.validationMessage;\n\n if (prevMessage === this.getErrorText()) {\n this.field?.reannounceError();\n }\n\n return valid;\n }\n\n /**\n * Selects all the text in the text field.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select\n */\n select() {\n this.input.select();\n }\n\n /**\n * Sets a custom validation error message for the text field. Use this for\n * custom error message.\n *\n * When the error is not an empty string, the text field is considered invalid\n * and `validity.customError` will be true.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity\n *\n * @param error The error message to display.\n */\n setCustomValidity(error: string) {\n this.hasCustomValidityError = !!error;\n this.internals.setValidity({ customError: !!error }, error, this.input);\n }\n\n /**\n * Reset the text field to its default value.\n */\n reset() {\n this.dirty = false;\n this.value = this.getAttribute('value') ?? '';\n this.nativeError = false;\n this.nativeErrorText = '';\n }\n\n private hasCustomValidityError = false;\n\n private syncValidity() {\n // Sync the internal <input>'s validity and the host's ElementInternals\n // validity. We do this to re-use native `<input>` validation messages.\n const input = this.getInput();\n if (this.hasCustomValidityError) {\n input.setCustomValidity(this.internals.validationMessage);\n } else {\n input.setCustomValidity('');\n }\n\n this.internals.setValidity(\n input.validity,\n input.validationMessage,\n this.getInput()\n );\n }\n\n @property() label = '';\n\n @property({ type: String }) value = '';\n\n @property({ type: String }) region = '';\n\n // get geo lookup fn from props, use default fn from config or use empty callback\n @property() geoFn = CONFIG?.GEO_FN || ((callback: Function) => callback(''));\n\n iti: Plugin | undefined = undefined;\n\n private formatValue() {\n if (window.intlTelInputUtils?.numberFormat) {\n this.value =\n this.iti?.getNumber(window.intlTelInputUtils.numberFormat.E164) || '';\n }\n }\n\n private handleKeyPress(e: KeyboardEvent) {\n if (/^[A-Z]$/i.test(e.key)) {\n e.preventDefault();\n return false;\n }\n this.formatValue();\n return true;\n }\n\n private getErrorText() {\n return this.error ? this.errorText : this.nativeErrorText;\n }\n\n private handleFocusin() {\n this.focused = true;\n }\n\n private handleFocusout() {\n this.focused = false;\n }\n\n private getInput() {\n if (!this.input) {\n // If the input is not yet defined, synchronously render.\n // e.g.\n // const textField = document.createElement('md-outlined-text-field');\n // document.body.appendChild(textField);\n // textField.focus(); // synchronously render\n this.connectedCallback();\n this.scheduleUpdate();\n }\n\n if (this.isUpdatePending) {\n // If there are pending updates, synchronously perform them. This ensures\n // that constraint validation properties (like `required`) are synced\n // before interacting with input APIs that depend on them.\n this.scheduleUpdate();\n }\n\n return this.input!;\n }\n\n protected override firstUpdated() {\n this.input.addEventListener('countrychange', () => {\n this.formatValue();\n });\n this.iti = intlTelInput(this.input, {\n initialCountry: this.region !== '' ? this.region : 'auto',\n nationalMode: true,\n hiddenInput: 'full',\n autoPlaceholder: 'off',\n geoIpLookup: this.geoFn,\n utilsScript: CONFIG.UTILS_SCRIPT,\n });\n this.iti.promise.then(() => {\n // format on inititalisation\n this.formatValue();\n });\n }\n\n override attributeChangedCallback(\n attribute: string,\n newValue: string | null,\n oldValue: string | null\n ) {\n if (attribute === 'value' && this.dirty) {\n // After user input, changing the value attribute no longer updates the\n // text field's value (until reset). This matches native <input> behavior.\n return;\n }\n\n super.attributeChangedCallback(attribute, newValue, oldValue);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected override updated(changedProperties: PropertyValues) {\n // Keep changedProperties arg so that subclasses may call it\n\n // If a property such as `type` changes and causes the internal <input>\n // value to change without dispatching an event, re-sync it.\n const { value } = this.input;\n if (this.value !== value) {\n // Note this is typically inefficient in updated() since it schedules\n // another update. However, it is needed for the <input> to fully render\n // before checking its value.\n this.value = value;\n }\n\n this.internals.setFormValue(value);\n // Sync validity when properties change, since validation properties may\n // have changed.\n this.syncValidity();\n }\n\n protected willUpdate(changedProperties: PropertyValues<this>) {\n if (changedProperties.has('region')) {\n this.iti?.setCountry(this.region);\n }\n }\n\n private handleInput(event: InputEvent) {\n this.dirty = true;\n this.value = (event.target as HTMLInputElement).value;\n // Sync validity so that clients can check validity on input.\n this.syncValidity();\n }\n\n override disconnectedCallback() {\n this.iti?.destroy();\n }\n\n protected override render() {\n const classes = {\n disabled: this.disabled,\n error: !this.disabled && this.hasError,\n };\n\n const ariaLabel = this.ariaLabel || this.label || nothing;\n\n return html`\n <span class=\"text-field ${classMap(classes)}\">\n <ix-field\n class=\"field\"\n count=${this.value.length}\n ?disabled=${this.disabled}\n ?error=${this.hasError}\n error-text=${this.getErrorText()}\n ?focused=${this.focused}\n label=${this.label}\n ?populated=${!!this.value}\n ?required=${this.required}\n supporting-text=${this.supportingText}\n @focusin=${this.handleFocusin}\n @focusout=${this.handleFocusout}\n >\n <input\n name=\"${this.name}\"\n type=\"${this.type}\"\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-invalid=${this.hasError}\n aria-label=${ariaLabel}\n aria-describedby=\"description\"\n .value=\"${this.value}\"\n @input=\"${this.handleInput}\"\n @keypress=\"${this.handleKeyPress}\"\n />\n <div id=\"description\" slot=\"aria-describedby\"></div>\n </ix-field>\n </span>\n `;\n }\n\n /** @private */\n formResetCallback() {\n this.reset();\n }\n\n /** @private */\n formStateRestoreCallback(newState: string) {\n this.value = newState;\n }\n\n override focus() {\n // Required for the case that the user slots a focusable element into the\n // leading icon slot such as an iconbutton due to how delegatesFocus works.\n this.getInput().focus();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IxPhoneInput.js","sourceRoot":"","sources":["../src/IxPhoneInput.ts"],"names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CACmB;AAEA;IAAjC,KAAK,CAAC,QAAQ,CAAC;2CAAuC;AAyBtC;IADhB,QAAQ,EAAE;0CACmB;AAEc;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB;AAQjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAe;AAUnB;IAAtC,QAAQ,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;+CAAgB;AAMV;IAA3C,QAAQ,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;oDAAqB;AAEpB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB;AAM5C;IAAhB,KAAK,EAAE;2CAAuB;AAEd;IAAhB,KAAK,EAAE;6CAAyB;AAKhB;IAAhB,KAAK,EAAE;iDAA6B;AAMpB;IAAhB,KAAK,EAAE;qDAA8B;AAkN1B;IAAX,QAAQ,EAAE;2CAAY;AAEK;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAY;AAEX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAa;AAG5B;IAAX,QAAQ,EAAE;2CAAkE","sourcesContent":["/* eslint-disable lit/no-value-attribute */\nimport '@digital-realty/ix-field/ix-field.js';\nimport { Field } from '@material/web/field/internal/field.js';\nimport { requestUpdateOnAriaChange } from '@material/web/internal/aria/delegate.js';\nimport {\n styles as outlinedForcedColorsStyles,\n styles as outlinedStyles,\n} from '@material/web/textfield/internal/outlined-styles.css.js';\nimport { styles as sharedStyles } from '@material/web/textfield/internal/shared-styles.css.js';\nimport intlTelInput, { Plugin } from 'intl-tel-input';\nimport { LitElement, PropertyValues, html, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { CONFIG } from './config.js';\nimport { IxPhoneInputStyles } from './ix-phone-input-styles.js';\n\nexport class IxPhoneInput extends LitElement {\n static {\n requestUpdateOnAriaChange(IxPhoneInput);\n }\n\n @query('input')\n readonly input!: HTMLInputElement;\n\n @query('.field') private readonly field?: Field | null;\n\n static get styles() {\n return [\n sharedStyles,\n outlinedStyles,\n outlinedForcedColorsStyles,\n CONFIG.FLAG_SPRITES,\n IxPhoneInputStyles,\n ];\n }\n\n /** @nocollapse */\n static override shadowRootOptions: ShadowRootInit = {\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 @property()\n private readonly type = 'tel';\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 /**\n * The error message that replaces supporting text when `error` is true. If\n * `errorText` is an empty string, then the supporting text will continue to\n * show.\n *\n * This error message overrides the error message displayed by\n * `reportValidity()`.\n */\n @property({ attribute: 'error-text' }) errorText = '';\n\n /**\n * Conveys additional information below the text field, such as how it should\n * be used.\n */\n @property({ attribute: 'supporting-text' }) supportingText = '';\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n /**\n * Returns true when the text field has been interacted with. Native\n * validation errors only display in response to user interactions.\n */\n @state() private dirty = false;\n\n @state() private focused = false;\n\n /**\n * Whether or not a native error has been reported via `reportValidity()`.\n */\n @state() private nativeError = false;\n\n /**\n * The validation message displayed from a native error via\n * `reportValidity()`.\n */\n @state() private nativeErrorText = '';\n\n private get hasError() {\n return this.error || this.nativeError;\n }\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 this.syncValidity();\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 this.syncValidity();\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 this.syncValidity();\n return this.internals.willValidate;\n }\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 /**\n * Gets or sets the direction in which selection occurred.\n */\n get selectionDirection() {\n return this.getInput().selectionDirection;\n }\n\n set selectionDirection(value: 'forward' | 'backward' | 'none' | null) {\n this.getInput().selectionDirection = value;\n }\n\n /**\n * Gets or sets the end position or offset of a text selection.\n */\n get selectionEnd() {\n return this.getInput().selectionEnd;\n }\n\n set selectionEnd(value: number | null) {\n this.getInput().selectionEnd = value;\n }\n\n /**\n * Gets or sets the starting position or offset of a text selection.\n */\n get selectionStart() {\n return this.getInput().selectionStart;\n }\n\n set selectionStart(value: number | null) {\n this.getInput().selectionStart = value;\n }\n\n /**\n * Checks the text field's native validation and returns whether or not the\n * element is valid.\n *\n * If invalid, this method will dispatch the `invalid` event.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity\n *\n * @return true if the text field is valid, or false if not.\n */\n checkValidity() {\n this.syncValidity();\n return this.internals.checkValidity();\n }\n\n /**\n * Checks the text field's native validation and returns whether or not the\n * element is valid.\n *\n * If invalid, this method will dispatch the `invalid` event.\n *\n * This method will display or clear an error text message equal to the text\n * field's `validationMessage`, unless the invalid event is canceled.\n *\n * Use `setCustomValidity()` to customize the `validationMessage`.\n *\n * This method can also be used to re-announce error messages to screen\n * readers.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity\n *\n * @return true if the text field is valid, or false if not.\n */\n reportValidity() {\n let invalidEvent: Event | undefined;\n this.addEventListener(\n 'invalid',\n event => {\n invalidEvent = event;\n },\n { once: true }\n );\n\n const valid = this.checkValidity();\n if (invalidEvent?.defaultPrevented) {\n return valid;\n }\n\n const prevMessage = this.getErrorText();\n this.nativeError = !valid;\n this.nativeErrorText = this.validationMessage;\n\n if (prevMessage === this.getErrorText()) {\n this.field?.reannounceError();\n }\n\n return valid;\n }\n\n /**\n * Selects all the text in the text field.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select\n */\n select() {\n this.input.select();\n }\n\n /**\n * Sets a custom validation error message for the text field. Use this for\n * custom error message.\n *\n * When the error is not an empty string, the text field is considered invalid\n * and `validity.customError` will be true.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity\n *\n * @param error The error message to display.\n */\n setCustomValidity(error: string) {\n this.hasCustomValidityError = !!error;\n this.internals.setValidity({ customError: !!error }, error, this.input);\n }\n\n /**\n * Reset the text field to its default value.\n */\n reset() {\n this.dirty = false;\n this.value = this.getAttribute('value') ?? '';\n this.input.value = this.value;\n this.nativeError = false;\n this.nativeErrorText = '';\n }\n\n private hasCustomValidityError = false;\n\n private syncValidity() {\n // Sync the internal <input>'s validity and the host's ElementInternals\n // validity. We do this to re-use native `<input>` validation messages.\n const input = this.getInput();\n if (this.hasCustomValidityError) {\n input.setCustomValidity(this.internals.validationMessage);\n } else {\n input.setCustomValidity('');\n }\n\n this.internals.setValidity(\n input.validity,\n input.validationMessage,\n this.getInput()\n );\n }\n\n @property() label = '';\n\n @property({ type: String }) value = '';\n\n @property({ type: String }) region = '';\n\n // get geo lookup fn from props, use default fn from config or use empty callback\n @property() geoFn = CONFIG?.GEO_FN || ((callback: Function) => callback(''));\n\n iti: Plugin | undefined = undefined;\n\n private formatValue() {\n if (window.intlTelInputUtils?.numberFormat) {\n this.value =\n this.iti?.getNumber(window.intlTelInputUtils.numberFormat.E164) || '';\n }\n }\n\n private handleKeyPress(e: KeyboardEvent) {\n if (/^[A-Z]$/i.test(e.key)) {\n e.preventDefault();\n return false;\n }\n this.formatValue();\n return true;\n }\n\n private getErrorText() {\n return this.error ? this.errorText : this.nativeErrorText;\n }\n\n private handleFocusin() {\n this.focused = true;\n }\n\n private handleFocusout() {\n this.focused = false;\n }\n\n private getInput() {\n if (!this.input) {\n // If the input is not yet defined, synchronously render.\n // e.g.\n // const textField = document.createElement('md-outlined-text-field');\n // document.body.appendChild(textField);\n // textField.focus(); // synchronously render\n this.connectedCallback();\n this.scheduleUpdate();\n }\n\n if (this.isUpdatePending) {\n // If there are pending updates, synchronously perform them. This ensures\n // that constraint validation properties (like `required`) are synced\n // before interacting with input APIs that depend on them.\n this.scheduleUpdate();\n }\n\n return this.input!;\n }\n\n override connectedCallback() {\n super.connectedCallback();\n if (!window.intlTelInputUtils) {\n window.intlTelInputGlobals.loadUtils(CONFIG.UTILS_SCRIPT);\n }\n }\n\n protected override firstUpdated() {\n this.input.addEventListener('countrychange', () => {\n this.formatValue();\n this.dispatchEvent(\n new CustomEvent('country-change', {\n bubbles: true,\n composed: true,\n })\n );\n });\n this.iti = intlTelInput(this.input, {\n initialCountry: this.region !== '' ? this.region : 'auto',\n formatOnDisplay: true,\n nationalMode: false,\n hiddenInput: 'full',\n autoPlaceholder: 'off',\n geoIpLookup: this.geoFn,\n });\n this.iti.promise.then(() => {\n // format on inititalisation\n this.formatValue();\n });\n }\n\n override attributeChangedCallback(\n attribute: string,\n oldValue: string | null,\n newValue: string | null\n ) {\n if (attribute === 'value' && this.dirty) {\n // After user input, changing the value attribute no longer updates the\n // text field's value (until reset). This matches native <input> behavior.\n return;\n }\n\n super.attributeChangedCallback(attribute, oldValue, newValue);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n protected override updated(changedProperties: PropertyValues) {\n // Keep changedProperties arg so that subclasses may call it\n\n // If a property such as `type` changes and causes the internal <input>\n // value to change without dispatching an event, re-sync it.\n const { value } = this.input;\n if (this.value !== value) {\n // Note this is typically inefficient in updated() since it schedules\n // another update. However, it is needed for the <input> to fully render\n // before checking its value.\n this.value = value;\n }\n\n this.internals.setFormValue(value);\n // Sync validity when properties change, since validation properties may\n // have changed.\n this.syncValidity();\n }\n\n protected willUpdate(changedProperties: PropertyValues<this>) {\n if (changedProperties.has('region')) {\n this.iti?.setCountry(this.region);\n }\n }\n\n private handleInput(event: InputEvent) {\n this.dirty = true;\n this.value = (event.target as HTMLInputElement).value;\n // Sync validity so that clients can check validity on input.\n this.syncValidity();\n }\n\n override disconnectedCallback() {\n this.iti?.destroy();\n }\n\n protected override render() {\n if (this.iti && this.value) {\n this.iti.setNumber(this.value);\n }\n\n const classes = {\n disabled: this.disabled,\n error: !this.disabled && this.hasError,\n };\n\n const ariaLabel = this.ariaLabel || this.label || nothing;\n\n return html`\n <span class=\"text-field ${classMap(classes)}\">\n <ix-field\n class=\"field\"\n count=${this.value.length}\n ?disabled=${this.disabled}\n ?error=${this.hasError}\n error-text=${this.getErrorText()}\n ?focused=${this.focused}\n label=${this.label}\n ?populated=${!!this.value}\n ?required=${this.required}\n supporting-text=${this.supportingText}\n @focusin=${this.handleFocusin}\n @focusout=${this.handleFocusout}\n >\n <input\n name=\"${this.name}\"\n type=\"${this.type}\"\n value=\"${this.value}\"\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-invalid=${this.hasError}\n aria-label=${ariaLabel}\n aria-describedby=\"description\"\n @input=\"${this.handleInput}\"\n @keypress=\"${this.handleKeyPress}\"\n />\n <div id=\"description\" slot=\"aria-describedby\"></div>\n </ix-field>\n </span>\n `;\n }\n\n /** @private */\n formResetCallback() {\n this.reset();\n }\n\n /** @private */\n formStateRestoreCallback(newState: string) {\n this.value = newState;\n }\n\n override focus() {\n // Required for the case that the user slots a focusable element into the\n // leading icon slot such as an iconbutton due to how delegatesFocus works.\n this.getInput().focus();\n }\n}\n"]}
|
|
@@ -89,7 +89,7 @@ var intlTelInput$1 = {exports: {}};
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
92
|
-
_defineProperties(Constructor.prototype, protoProps);
|
|
92
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
93
93
|
Object.defineProperty(Constructor, "prototype", {
|
|
94
94
|
writable: false
|
|
95
95
|
});
|
|
@@ -3053,7 +3053,7 @@ class IxPhoneInput extends LitElement {
|
|
|
3053
3053
|
this.value = '';
|
|
3054
3054
|
this.region = '';
|
|
3055
3055
|
// get geo lookup fn from props, use default fn from config or use empty callback
|
|
3056
|
-
this.geoFn = (CONFIG === null || CONFIG ===
|
|
3056
|
+
this.geoFn = (CONFIG === null || CONFIG === void 0 ? void 0 : CONFIG.GEO_FN) || ((callback) => callback(''));
|
|
3057
3057
|
this.iti = undefined;
|
|
3058
3058
|
}
|
|
3059
3059
|
static get styles() {
|
|
@@ -3114,7 +3114,7 @@ class IxPhoneInput extends LitElement {
|
|
|
3114
3114
|
*/
|
|
3115
3115
|
get name() {
|
|
3116
3116
|
var _a;
|
|
3117
|
-
return (_a = this.getAttribute('name')) !== null && _a !==
|
|
3117
|
+
return (_a = this.getAttribute('name')) !== null && _a !== void 0 ? _a : '';
|
|
3118
3118
|
}
|
|
3119
3119
|
set name(name) {
|
|
3120
3120
|
this.setAttribute('name', name);
|
|
@@ -3185,14 +3185,14 @@ class IxPhoneInput extends LitElement {
|
|
|
3185
3185
|
invalidEvent = event;
|
|
3186
3186
|
}, { once: true });
|
|
3187
3187
|
const valid = this.checkValidity();
|
|
3188
|
-
if (invalidEvent === null || invalidEvent ===
|
|
3188
|
+
if (invalidEvent === null || invalidEvent === void 0 ? void 0 : invalidEvent.defaultPrevented) {
|
|
3189
3189
|
return valid;
|
|
3190
3190
|
}
|
|
3191
3191
|
const prevMessage = this.getErrorText();
|
|
3192
3192
|
this.nativeError = !valid;
|
|
3193
3193
|
this.nativeErrorText = this.validationMessage;
|
|
3194
3194
|
if (prevMessage === this.getErrorText()) {
|
|
3195
|
-
(_a = this.field) === null || _a ===
|
|
3195
|
+
(_a = this.field) === null || _a === void 0 ? void 0 : _a.reannounceError();
|
|
3196
3196
|
}
|
|
3197
3197
|
return valid;
|
|
3198
3198
|
}
|
|
@@ -3225,7 +3225,8 @@ class IxPhoneInput extends LitElement {
|
|
|
3225
3225
|
reset() {
|
|
3226
3226
|
var _a;
|
|
3227
3227
|
this.dirty = false;
|
|
3228
|
-
this.value = (_a = this.getAttribute('value')) !== null && _a !==
|
|
3228
|
+
this.value = (_a = this.getAttribute('value')) !== null && _a !== void 0 ? _a : '';
|
|
3229
|
+
this.input.value = this.value;
|
|
3229
3230
|
this.nativeError = false;
|
|
3230
3231
|
this.nativeErrorText = '';
|
|
3231
3232
|
}
|
|
@@ -3243,9 +3244,9 @@ class IxPhoneInput extends LitElement {
|
|
|
3243
3244
|
}
|
|
3244
3245
|
formatValue() {
|
|
3245
3246
|
var _a, _b;
|
|
3246
|
-
if ((_a = window.intlTelInputUtils) === null || _a ===
|
|
3247
|
+
if ((_a = window.intlTelInputUtils) === null || _a === void 0 ? void 0 : _a.numberFormat) {
|
|
3247
3248
|
this.value =
|
|
3248
|
-
((_b = this.iti) === null || _b ===
|
|
3249
|
+
((_b = this.iti) === null || _b === void 0 ? void 0 : _b.getNumber(window.intlTelInputUtils.numberFormat.E164)) || '';
|
|
3249
3250
|
}
|
|
3250
3251
|
}
|
|
3251
3252
|
handleKeyPress(e) {
|
|
@@ -3283,30 +3284,40 @@ class IxPhoneInput extends LitElement {
|
|
|
3283
3284
|
}
|
|
3284
3285
|
return this.input;
|
|
3285
3286
|
}
|
|
3287
|
+
connectedCallback() {
|
|
3288
|
+
super.connectedCallback();
|
|
3289
|
+
if (!window.intlTelInputUtils) {
|
|
3290
|
+
window.intlTelInputGlobals.loadUtils(CONFIG.UTILS_SCRIPT);
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3286
3293
|
firstUpdated() {
|
|
3287
3294
|
this.input.addEventListener('countrychange', () => {
|
|
3288
3295
|
this.formatValue();
|
|
3296
|
+
this.dispatchEvent(new CustomEvent('country-change', {
|
|
3297
|
+
bubbles: true,
|
|
3298
|
+
composed: true,
|
|
3299
|
+
}));
|
|
3289
3300
|
});
|
|
3290
3301
|
this.iti = index(this.input, {
|
|
3291
3302
|
initialCountry: this.region !== '' ? this.region : 'auto',
|
|
3292
|
-
|
|
3303
|
+
formatOnDisplay: true,
|
|
3304
|
+
nationalMode: false,
|
|
3293
3305
|
hiddenInput: 'full',
|
|
3294
3306
|
autoPlaceholder: 'off',
|
|
3295
3307
|
geoIpLookup: this.geoFn,
|
|
3296
|
-
utilsScript: CONFIG.UTILS_SCRIPT,
|
|
3297
3308
|
});
|
|
3298
3309
|
this.iti.promise.then(() => {
|
|
3299
3310
|
// format on inititalisation
|
|
3300
3311
|
this.formatValue();
|
|
3301
3312
|
});
|
|
3302
3313
|
}
|
|
3303
|
-
attributeChangedCallback(attribute,
|
|
3314
|
+
attributeChangedCallback(attribute, oldValue, newValue) {
|
|
3304
3315
|
if (attribute === 'value' && this.dirty) {
|
|
3305
3316
|
// After user input, changing the value attribute no longer updates the
|
|
3306
3317
|
// text field's value (until reset). This matches native <input> behavior.
|
|
3307
3318
|
return;
|
|
3308
3319
|
}
|
|
3309
|
-
super.attributeChangedCallback(attribute,
|
|
3320
|
+
super.attributeChangedCallback(attribute, oldValue, newValue);
|
|
3310
3321
|
}
|
|
3311
3322
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3312
3323
|
updated(changedProperties) {
|
|
@@ -3328,7 +3339,7 @@ class IxPhoneInput extends LitElement {
|
|
|
3328
3339
|
willUpdate(changedProperties) {
|
|
3329
3340
|
var _a;
|
|
3330
3341
|
if (changedProperties.has('region')) {
|
|
3331
|
-
(_a = this.iti) === null || _a ===
|
|
3342
|
+
(_a = this.iti) === null || _a === void 0 ? void 0 : _a.setCountry(this.region);
|
|
3332
3343
|
}
|
|
3333
3344
|
}
|
|
3334
3345
|
handleInput(event) {
|
|
@@ -3339,9 +3350,12 @@ class IxPhoneInput extends LitElement {
|
|
|
3339
3350
|
}
|
|
3340
3351
|
disconnectedCallback() {
|
|
3341
3352
|
var _a;
|
|
3342
|
-
(_a = this.iti) === null || _a ===
|
|
3353
|
+
(_a = this.iti) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
3343
3354
|
}
|
|
3344
3355
|
render() {
|
|
3356
|
+
if (this.iti && this.value) {
|
|
3357
|
+
this.iti.setNumber(this.value);
|
|
3358
|
+
}
|
|
3345
3359
|
const classes = {
|
|
3346
3360
|
disabled: this.disabled,
|
|
3347
3361
|
error: !this.disabled && this.hasError,
|
|
@@ -3366,12 +3380,12 @@ class IxPhoneInput extends LitElement {
|
|
|
3366
3380
|
<input
|
|
3367
3381
|
name="${this.name}"
|
|
3368
3382
|
type="${this.type}"
|
|
3383
|
+
value="${this.value}"
|
|
3369
3384
|
?disabled=${this.disabled}
|
|
3370
3385
|
?required=${this.required}
|
|
3371
3386
|
aria-invalid=${this.hasError}
|
|
3372
3387
|
aria-label=${ariaLabel}
|
|
3373
3388
|
aria-describedby="description"
|
|
3374
|
-
.value="${this.value}"
|
|
3375
3389
|
@input="${this.handleInput}"
|
|
3376
3390
|
@keypress="${this.handleKeyPress}"
|
|
3377
3391
|
/>
|
|
@@ -3406,51 +3420,51 @@ IxPhoneInput.shadowRootOptions = {
|
|
|
3406
3420
|
IxPhoneInput.formAssociated = true;
|
|
3407
3421
|
__decorate([
|
|
3408
3422
|
query('input')
|
|
3409
|
-
], IxPhoneInput.prototype, "input",
|
|
3423
|
+
], IxPhoneInput.prototype, "input", void 0);
|
|
3410
3424
|
__decorate([
|
|
3411
3425
|
query('.field')
|
|
3412
|
-
], IxPhoneInput.prototype, "field",
|
|
3426
|
+
], IxPhoneInput.prototype, "field", void 0);
|
|
3413
3427
|
__decorate([
|
|
3414
3428
|
property()
|
|
3415
|
-
], IxPhoneInput.prototype, "type",
|
|
3429
|
+
], IxPhoneInput.prototype, "type", void 0);
|
|
3416
3430
|
__decorate([
|
|
3417
3431
|
property({ type: Boolean, reflect: true })
|
|
3418
|
-
], IxPhoneInput.prototype, "disabled",
|
|
3432
|
+
], IxPhoneInput.prototype, "disabled", void 0);
|
|
3419
3433
|
__decorate([
|
|
3420
3434
|
property({ type: Boolean, reflect: true })
|
|
3421
|
-
], IxPhoneInput.prototype, "error",
|
|
3435
|
+
], IxPhoneInput.prototype, "error", void 0);
|
|
3422
3436
|
__decorate([
|
|
3423
3437
|
property({ attribute: 'error-text' })
|
|
3424
|
-
], IxPhoneInput.prototype, "errorText",
|
|
3438
|
+
], IxPhoneInput.prototype, "errorText", void 0);
|
|
3425
3439
|
__decorate([
|
|
3426
3440
|
property({ attribute: 'supporting-text' })
|
|
3427
|
-
], IxPhoneInput.prototype, "supportingText",
|
|
3441
|
+
], IxPhoneInput.prototype, "supportingText", void 0);
|
|
3428
3442
|
__decorate([
|
|
3429
3443
|
property({ type: Boolean, reflect: true })
|
|
3430
|
-
], IxPhoneInput.prototype, "required",
|
|
3444
|
+
], IxPhoneInput.prototype, "required", void 0);
|
|
3431
3445
|
__decorate([
|
|
3432
3446
|
state()
|
|
3433
|
-
], IxPhoneInput.prototype, "dirty",
|
|
3447
|
+
], IxPhoneInput.prototype, "dirty", void 0);
|
|
3434
3448
|
__decorate([
|
|
3435
3449
|
state()
|
|
3436
|
-
], IxPhoneInput.prototype, "focused",
|
|
3450
|
+
], IxPhoneInput.prototype, "focused", void 0);
|
|
3437
3451
|
__decorate([
|
|
3438
3452
|
state()
|
|
3439
|
-
], IxPhoneInput.prototype, "nativeError",
|
|
3453
|
+
], IxPhoneInput.prototype, "nativeError", void 0);
|
|
3440
3454
|
__decorate([
|
|
3441
3455
|
state()
|
|
3442
|
-
], IxPhoneInput.prototype, "nativeErrorText",
|
|
3456
|
+
], IxPhoneInput.prototype, "nativeErrorText", void 0);
|
|
3443
3457
|
__decorate([
|
|
3444
3458
|
property()
|
|
3445
|
-
], IxPhoneInput.prototype, "label",
|
|
3459
|
+
], IxPhoneInput.prototype, "label", void 0);
|
|
3446
3460
|
__decorate([
|
|
3447
3461
|
property({ type: String })
|
|
3448
|
-
], IxPhoneInput.prototype, "value",
|
|
3462
|
+
], IxPhoneInput.prototype, "value", void 0);
|
|
3449
3463
|
__decorate([
|
|
3450
3464
|
property({ type: String })
|
|
3451
|
-
], IxPhoneInput.prototype, "region",
|
|
3465
|
+
], IxPhoneInput.prototype, "region", void 0);
|
|
3452
3466
|
__decorate([
|
|
3453
3467
|
property()
|
|
3454
|
-
], IxPhoneInput.prototype, "geoFn",
|
|
3468
|
+
], IxPhoneInput.prototype, "geoFn", void 0);
|
|
3455
3469
|
|
|
3456
3470
|
customElements.define('ix-phone-input', IxPhoneInput);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ix-phone-input following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Digital Realty",
|
|
6
|
-
"version": "2.2.
|
|
6
|
+
"version": "2.2.9",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@digital-realty/ix-field": "^1.1.6",
|
|
34
34
|
"@lit/react": "^1.0.2",
|
|
35
35
|
"@material/web": "1.2.0",
|
|
36
|
-
"intl-tel-input": "^18.
|
|
36
|
+
"intl-tel-input": "^18.5.3",
|
|
37
37
|
"lit": "^3.2.1",
|
|
38
38
|
"react": "^18.2.0"
|
|
39
39
|
},
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"README.md",
|
|
120
120
|
"LICENSE"
|
|
121
121
|
],
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "88d71dc777dfb338bb137b04f0ec54489600ee26"
|
|
123
123
|
}
|