Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release #1475

Merged
merged 15 commits into from
Dec 6, 2024
Merged

release #1475

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 19.0.3(2024-12-05)

### Contributing Fix

- Fix ([#1455](https://github.com/JsDaddy/ngx-mask/pull/1455))

### Fix

- Fix ([#1472](https://github.com/JsDaddy/ngx-mask/pull/1472))
- Fix ([#1415](https://github.com/JsDaddy/ngx-mask/pull/1415))

# 19.0.2(2024-12-03)

### Fix
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ const maskConfigFunction: () => Partial<NgxMaskConfig> = () => {

Then, just define masks in inputs.

## Actively supported versions

ngx-mask follows the official Angular support policy, supporting the Active and LTS (Long-Term Support) versions of Angular. As of the latest release, Angular v17 and newer are supported.

Projects using Angular versions outside the supported range (e.g., older than v17) should use the last compatible version of ngx-mask. However, these versions will no longer receive updates, bug fixes, or new features.

For detailed information about Angular's versioning and support schedule, visit the official [Angular releases page](https://angular.dev/reference/releases#actively-supported-versions).

## Usage

Text [documentation](https://github.com/JsDaddy/ngx-mask/blob/develop/USAGE.md)
Expand Down
16 changes: 13 additions & 3 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,20 @@ Input value: 789HelloWorld
Masked value: (Hel-loW)
```

### Custom pattern for this
### Custom Pattern Definition for Input Masks

You can define custom pattern and specify symbol to be rendered in input field.
Patterns may conflict with such letters as h, d, m, s, because we use these characters for dates.
You can define a custom pattern and specify a unique symbol to be rendered in the input field.

Important Notes:

Reserved Characters: Certain characters (h, d, m, s) are reserved for date patterns and should not be used in custom patterns to avoid conflicts.

```html
Special Symbol *: The * character is reserved for patterns like 0*, which means any length of digits
can appear before the asterisk. Avoid using this symbol in custom patterns.

<input type="text" mask="A*" />
```

```typescript
pattern = {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mask",
"version": "19.0.2",
"version": "19.0.3",
"description": "Awesome ngx mask",
"license": "MIT",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-mask-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-mask",
"version": "19.0.2",
"version": "19.0.3",
"description": "awesome ngx mask",
"keywords": [
"ng2-mask",
Expand Down
20 changes: 9 additions & 11 deletions projects/ngx-mask-lib/src/lib/ngx-mask-applier.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export class NgxMaskApplierService {
? processedPosition + 1
: processedPosition;
cursor += 1;
this._shiftStep(maskExpression, cursor, inputArray.length);
this._shiftStep(cursor);
i--;
if (this.leadZeroDateTime) {
result += '0';
Expand Down Expand Up @@ -527,7 +527,7 @@ export class NgxMaskApplierService {
? processedPosition + 1
: processedPosition;
cursor += 1;
this._shiftStep(maskExpression, cursor, inputArray.length);
this._shiftStep(cursor);
i--;
if (this.leadZeroDateTime) {
result += '0';
Expand Down Expand Up @@ -576,7 +576,7 @@ export class NgxMaskApplierService {
? processedPosition + 1
: processedPosition;
cursor += 1;
this._shiftStep(maskExpression, cursor, inputArray.length);
this._shiftStep(cursor);
i--;

if (this.leadZeroDateTime) {
Expand Down Expand Up @@ -649,7 +649,7 @@ export class NgxMaskApplierService {
? processedPosition + 1
: processedPosition;
cursor += 1;
this._shiftStep(maskExpression, cursor, inputArray.length);
this._shiftStep(cursor);
i--;
if (this.leadZeroDateTime) {
result += '0';
Expand All @@ -672,13 +672,13 @@ export class NgxMaskApplierService {
) {
result += maskExpression[cursor];
cursor++;
this._shiftStep(maskExpression, cursor, inputArray.length);
this._shiftStep(cursor);
i--;
} else if (
maskExpression[cursor] === MaskExpression.NUMBER_NINE &&
this.showMaskTyped
) {
this._shiftStep(maskExpression, cursor, inputArray.length);
this._shiftStep(cursor);
} else if (
this.patterns[maskExpression[cursor] ?? MaskExpression.EMPTY_STRING] &&
this.patterns[maskExpression[cursor] ?? MaskExpression.EMPTY_STRING]?.optional
Expand Down Expand Up @@ -738,6 +738,7 @@ export class NgxMaskApplierService {
}
}
if (
result[processedPosition - 1] &&
result.length + 1 === maskExpression.length &&
this.specialCharacters.indexOf(
maskExpression[maskExpression.length - 1] ?? MaskExpression.EMPTY_STRING
Expand Down Expand Up @@ -982,11 +983,8 @@ export class NgxMaskApplierService {
return char;
}

private _shiftStep(maskExpression: string, cursor: number, inputLength: number) {
const shiftStep: number = /[*?]/g.test(maskExpression.slice(0, cursor))
? inputLength
: cursor;
this._shift.add(shiftStep + this.prefix.length || 0);
private _shiftStep(cursor: number) {
this._shift.add(cursor + this.prefix.length || 0);
}

protected _compareOrIncludes<T>(value: T, comparedValue: T | T[], excludedValue: T): boolean {
Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-mask-lib/src/lib/ngx-mask.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type NgxMaskConfig = {
shownMaskExpression: string;
specialCharacters: string[] | readonly string[];
dropSpecialCharacters: boolean | string[] | readonly string[];
hiddenInput: boolean | null;
hiddenInput: boolean;
validation: boolean;
separatorLimit: string;
apm: boolean;
Expand Down Expand Up @@ -52,7 +52,7 @@ export const initialConfig: NgxMaskConfig = {
showMaskTyped: false,
placeHolderCharacter: '_',
dropSpecialCharacters: true,
hiddenInput: null,
hiddenInput: false,
shownMaskExpression: '',
separatorLimit: '',
allowNegativeNumbers: false,
Expand Down
6 changes: 5 additions & 1 deletion projects/ngx-mask-lib/src/lib/ngx-mask.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ export class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valida
}
if (hiddenInput) {
this._maskService.hiddenInput = hiddenInput.currentValue;
if (hiddenInput.previousValue === true && hiddenInput.currentValue === false) {
this._inputValue.set(this._maskService.actualValue);
}
}
if (showMaskTyped) {
this._maskService.showMaskTyped = showMaskTyped.currentValue;
Expand Down Expand Up @@ -1115,11 +1118,12 @@ export class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valida
this._maskService.maskExpression = maskValue;
}
} else {
const cleanMask = this._maskService.removeMask(mask);
const check: boolean = this._maskService
.removeMask(this._inputValue())
?.split(MaskExpression.EMPTY_STRING)
.every((character, index) => {
const indexMask = mask.charAt(index);
const indexMask = cleanMask.charAt(index);
return this._maskService._checkSymbolMask(character, indexMask);
});

Expand Down
Loading
Loading