Skip to content

Commit

Permalink
work for #4842
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Feb 7, 2024
1 parent 19cd675 commit 9bdce6d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/mask/mask_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class MaskManagerType {
return new InputMaskBase(maskOption);
}
public getAllTypes(): Array<string> {
var result = new Array<string>();
var result = ["none"];
for (var key in this.creatorHash) {
result.push(key);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mask/mask_number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class InputMaskNumber extends InputMaskBase {
}

public getNumberMaskedValue(src: string | number, matchWholeMask: boolean = false): string {
const input = src.toString();
const input = (src === undefined || src === null) ? "" : src.toString();
const parsedNumber = this.parseNumber(input);
const displayText = this.displayNumber(parsedNumber, true, matchWholeMask);
return displayText;
Expand Down
13 changes: 7 additions & 6 deletions src/mask/mask_pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function getFirstMatch(str: string, strIndex: number, literal: IMaskLiteral): nu
return strIndex;
}

export function getMaskedValueByPattern(str: string, pattern: string | Array<IMaskLiteral>, matchWholeMask:boolean): string {
export function getMaskedValueByPattern(src: string, pattern: string | Array<IMaskLiteral>, matchWholeMask:boolean): string {
const input = (src === undefined || src === null) ? "" : src;
let result = "";
let strIndex = 0;
const literals: Array<IMaskLiteral> = (typeof pattern === "string") ? getLiterals(pattern) : pattern;
Expand All @@ -48,11 +49,11 @@ export function getMaskedValueByPattern(str: string, pattern: string | Array<IMa
for(let maskIndex = 0; maskIndex < literals.length; maskIndex++) {
switch(literals[maskIndex].type) {
case "regex" :
if(strIndex < str.length) {
strIndex = getFirstMatch(str, strIndex, literals[maskIndex]);
if(strIndex < input.length) {
strIndex = getFirstMatch(input, strIndex, literals[maskIndex]);
}
if(strIndex < str.length) {
result += str[strIndex];
if(strIndex < input.length) {
result += input[strIndex];
} else if(matchWholeMask) {
result += settings.placeholderChar;
} else {
Expand All @@ -65,7 +66,7 @@ export function getMaskedValueByPattern(str: string, pattern: string | Array<IMa
case "const":
case "fixed":
result += literals[maskIndex].value;
if(literals[maskIndex].value === str[strIndex]) {
if(literals[maskIndex].value === input[strIndex]) {
strIndex++;
}
break;
Expand Down
7 changes: 6 additions & 1 deletion src/mask/mask_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ Serializer.addClass(
},
{ name: "dataToSave",
choices: ["masked", "unmasked"],
defaultValue: "unmasked"
defaultValue: "unmasked",
dependsOn: "type",
visibleIf: function(obj: any) {
if (!obj) return false;
return obj.type !== "none";
},
},
{ name: "allowNegative:boolean",
dependsOn: "type",
Expand Down

0 comments on commit 9bdce6d

Please sign in to comment.