Fix input issue with phone numbers
This commit is contained in:
parent
19a9c5e63e
commit
1e5483e941
2 changed files with 5 additions and 6 deletions
|
@ -7,7 +7,7 @@ export class TextField extends InputElement<string> {
|
|||
public readonly enterPressed = new UIEventSource<string>(undefined);
|
||||
private readonly value: UIEventSource<string>;
|
||||
private _element: HTMLElement;
|
||||
private readonly _isValid: (s: string, country?: () => string) => boolean;
|
||||
private readonly _isValid: (s: string) => boolean;
|
||||
private _rawValue: UIEventSource<string>
|
||||
|
||||
constructor(options?: {
|
||||
|
@ -18,7 +18,7 @@ export class TextField extends InputElement<string> {
|
|||
label?: BaseUIElement,
|
||||
textAreaRows?: number,
|
||||
inputStyle?: string,
|
||||
isValid?: ((s: string, country?: () => string) => boolean)
|
||||
isValid?: (s: string) => boolean
|
||||
}) {
|
||||
super();
|
||||
const self = this;
|
||||
|
@ -140,7 +140,7 @@ export class TextField extends InputElement<string> {
|
|||
if (t === undefined || t === null) {
|
||||
return false
|
||||
}
|
||||
return this._isValid(t, undefined);
|
||||
return this._isValid(t);
|
||||
}
|
||||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
|
|
|
@ -25,7 +25,6 @@ import Title from "../Base/Title";
|
|||
import InputElementMap from "./InputElementMap";
|
||||
import Translations from "../i18n/Translations";
|
||||
import {Translation} from "../i18n/Translation";
|
||||
import {NOTFOUND} from "dns";
|
||||
|
||||
export class TextFieldDef {
|
||||
|
||||
|
@ -97,7 +96,7 @@ export class TextFieldDef {
|
|||
return self.isValid(stripped, options.country)
|
||||
}
|
||||
} else {
|
||||
options["isValid"] = self.isValid;
|
||||
options["isValid"] = str => self.isValid(str, options.country);
|
||||
}
|
||||
|
||||
|
||||
|
@ -752,7 +751,7 @@ class PhoneTextField extends TextFieldDef {
|
|||
if (str.startsWith("tel:")) {
|
||||
str = str.substring("tel:".length)
|
||||
}
|
||||
return parsePhoneNumberFromString(str, (country())?.toUpperCase() as any).formatInternational();
|
||||
return parsePhoneNumberFromString(str, (country())?.toUpperCase() as any)?.formatInternational();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue