Skip to content

Commit

Permalink
fix/issues (#1443)
Browse files Browse the repository at this point in the history
* v15.1.2 (#1127)

* Fix/readme (#1057)

* feat(no-ref): change readme

* feat(no-ref): fix budge

Co-authored-by: Igor Nepipenko <[email protected]>

* build(deps): bump json5 from 1.0.1 to 1.0.2 (#1061)

Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](json5/json5@v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump ua-parser-js from 0.7.32 to 0.7.33 (#1065)

Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 0.7.32 to 0.7.33.
- [Release notes](https://github.com/faisalman/ua-parser-js/releases)
- [Changelog](https://github.com/faisalman/ua-parser-js/blob/master/changelog.md)
- [Commits](faisalman/ua-parser-js@0.7.32...0.7.33)

---
updated-dependencies:
- dependency-name: ua-parser-js
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: typo in separator.ts (#1064)

* build(deps): bump http-cache-semantics from 4.1.0 to 4.1.1 (#1067)

Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/kornelski/http-cache-semantics/releases)
- [Commits](kornelski/http-cache-semantics@v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: http-cache-semantics
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(1069): input seleciontStart goes to wrong position after dynamic mask changes while typing (#1070)

* fix(1069): input seleciontStart goes to wrong position after dynamic mask changes while typing

* fix(1069): patch version, update changelog and lint files

* fix(#1077): pipe no should work as directive (#1082)

* fix(#1077): pipe no should work as directive

* fix(#1077): reinstall deps

---------

Co-authored-by: Igor Nepipenko <[email protected]>

* Feature/v15.1.0 (#1084)

* Fix/readme (#1057) (#1058)

* feat(no-ref): change readme

* feat(no-ref): fix budge

Co-authored-by: Igor Nepipenko <[email protected]>

Co-authored-by: Igor Nepipenko <[email protected]>

* v15.0.3 (#1075)

* Fix/readme (#1057)

* feat(no-ref): change readme

* feat(no-ref): fix budge

Co-authored-by: Igor Nepipenko <[email protected]>

* build(deps): bump json5 from 1.0.1 to 1.0.2 (#1061)

Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](json5/json5@v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump ua-parser-js from 0.7.32 to 0.7.33 (#1065)

Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 0.7.32 to 0.7.33.
- [Release notes](https://github.com/faisalman/ua-parser-js/releases)
- [Changelog](https://github.com/faisalman/ua-parser-js/blob/master/changelog.md)
- [Commits](faisalman/ua-parser-js@0.7.32...0.7.33)

---
updated-dependencies:
- dependency-name: ua-parser-js
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: typo in separator.ts (#1064)

* build(deps): bump http-cache-semantics from 4.1.0 to 4.1.1 (#1067)

Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1.
- [Release notes](https://github.com/kornelski/http-cache-semantics/releases)
- [Commits](kornelski/http-cache-semantics@v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: http-cache-semantics
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(1069): input seleciontStart goes to wrong position after dynamic mask changes while typing (#1070)

* fix(1069): input seleciontStart goes to wrong position after dynamic mask changes while typing

* fix(1069): patch version, update changelog and lint files

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Igor Nepipenko <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: PradeepRaj <[email protected]>
Co-authored-by: Mikael Augusto Boff <[email protected]>

* feat(no-ref): reverse merge fron master v1

* feat(no-ref): reverse merge reformat changelog

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Igor Nepipenko <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: PradeepRaj <[email protected]>
Co-authored-by: Mikael Augusto Boff <[email protected]>

* feat(no-ref): before reverse merge v15.0.1

* feat(no-ref): reverse merge v15.1.0 v1

* feature/demo_redesign: Delete mat-accordion, do it custom, add new styles

* fix(no-ref): up deps and check lint

* fix(no-ref): up deps and check lint

* fix(no-ref): sync package lock v1

* fix(no-ref): tests should work

* fix(no-ref): try to change code scan

* fix(no-ref): try to change code scan v1

* fix(no-ref): try to change code scan v2

* fix(no-ref): remove codescan

* fix(no-ref): try to change code scan v3

* feat(no-ref): Did new layout for header,sub-header,app-component, delete material from layout

* feat(no-ref): fix layout and styles

* feat(no-ref): fix layout and styles

* feat(no-ref): fix layout and styles

* feat(no-ref): fix layout and styles

* feat(no-ref): fix few styles, and start do adaptive layout

* feat(no-ref): Add responsive layout for header, sub-header,app-component

* feat(no-ref): Add responsive layout for header, sub-header,app-component

* feat(no-ref): check lint

* feat(no-ref): check lint

* feat(no-ref): check lint

* feat(no-ref): check lint

* feat(no-ref): check lint

* feat(no-ref): check lint

* feat(no-ref): check lint

* feat(no-ref): did responsive layout, prepair for submodules

* feat(no-ref): fix styles where was important and few fix with OnInit

* feat(no-ref): fix styles where was important and few fix with OnInit

* feat(no-ref): fix logic in accordion

* feat(no-ref): fix logic in accordion

* feat(no-ref): fix logic in accordion

* feat(no-ref): fix app component

* feat(no-ref): add reusable card-content

* feat(no-ref): add variable to scss color

* feat(no-ref): add required filds for component

* feat(no-ref): add required filds for component

* feat(no-ref): add required filds for component

* feat(no-ref): fix few styles

* feat(no-ref): add animation from open accrodion block

* feat(no-ref): remove quit-logo button

* feat(no-ref): add animation for accordion block

* Feature/track by (#1100)

* feat(no-ref): remove quit-logo button

* feat(no-ref): add animation for accordion block

* feat(no-ref): add trackBy for ngFor

* feat(no-ref): change prefix and add submodule to project

* feat(no-ref): change few files

* feat(no-ref): change import

* feat(no-ref): add ci parametr

* feat(no-ref): change name file

* feat(no-ref): remove angular-material

* feat(no-ref): add command for gh-pages (#1102)

* feat(no-ref): fixes after QA

* feat(no-ref): fixes after QA

* feat(no-ref): fixes after QA

* feat(no-ref): fixes after QA

* feat(no-ref): fixes after QA

* feat(no-ref): fixes after QA

* feat(no-ref): fixes after QA

* feat(no-ref): fixes after QA

* feat(no-ref): fixes after QA

* feat(no-ref): fixes after QA

* feat(no-ref): fixes img view

* feat(no-ref): fixes img view

* feat(no-ref): fixes img view

* feat(no-ref): fixes img view

* feat(no-ref): fixes img view

* fix(no-ref): fix imports and add new img

* fix(no-ref): fix import

* fix(no-ref): fix import

* fix(no-ref): fix import

* fix(no-ref): fix scroll and new item in accordion

* fix(no-ref): fix scroll and new item in accordion

* fix(no-ref): fix scroll and new item in accordion

* fix(no-ref): remove class

* fix(no-ref): add scroll img

* fix(no-ref): add use strick comparison

* fix(no-ref): change title

* fix(no-ref): change title

* fix(no-ref): fix scroll cards

* fix(no-ref): fix scroll navigation

* fix(no-ref): change naming

* fix(no-ref): fix scroll and add anchor scroll

* fix(no-ref): fix scroll and add anchor scroll

* fix(no-ref): fix scroll and add anchor scroll

* fix(no-ref): fix naming

* fix(no-ref): fix naming and add unsubscriber

* fix(no-ref): fix naming and add unsubscriber

* fix(no-ref): fix naming and add unsubscriber

* fix(no-ref): add click outside accordion

* fix(no-ref): fix after qa

* fix(no-ref): add meta description

* fix(no-ref): add meta description

* fix(no-ref): add meta description

* fix(no-ref): close non public api (#1118)

Co-authored-by: Igor Nepipenko <[email protected]>

* fix(no-ref): uncommit package lock

* fix(no-ref): sync package and lock file

* fix(no-ref): sync package and lock file v1

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* feat(no-ref): redisign

* fix(1009): decimalMarker not locale default (#1052)

* fix(1009): decimalMarker not locale default

note: manually tested with added showcase
"Decimal separator with existing value"

of course, if someone finds a way to mock/set the locale
in the tests, I'll gladly add a unit test for that :)

to test: set browser locale to German for instance
(so that decimal marker defaults to ',')

before fix: 1234.56 shows as 1234.5
after fix: 1234.56 shows as 1234.56

* test(1009): test non EN locale

e.g. FR locale uses comma (,) as decimal marker

* fix(#1101): right flow for drop special character (#1126)

* fix(#1101): right flow for drop special character

* fix(#1101): right flow for drop special character v1

* fix(#1101): right flow for drop special character v2

---------

Co-authored-by: Igor Nepipenko <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Igor Nepipenko <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: PradeepRaj <[email protected]>
Co-authored-by: Mikael Augusto Boff <[email protected]>
Co-authored-by: andriikamaldinov <[email protected]>
Co-authored-by: Andrii Kamaldinov <[email protected]>
Co-authored-by: Pierre-Arnaud Galiana <[email protected]>

* fix(#1103): fix 1103

* fix(#1103): fix 1103

* fix(#1078): fix 1078

* fix(#1078): fix 1078

* Feat/ng16 (#1144) (#1145)

* fix(no-ref): before update

* fix(no-ref): ng 16

* fix(no-ref): remove non need in this moment deps

---------

Co-authored-by: Igor Nepipenko <[email protected]>

* fix(#1071): fix 1071

* fix(#1200): fix 1200

* fix(#658): fix 658

* fix(#658): fix 658

* feat(no-ref): up deps (#1363)

* feat(ref: no-ref): add setup hooks, remove karma (#1340)

* feat(ref: no-ref): add setup hooks, remove carma

* feat(ref: no-ref): remove environment

* feat(ref: no-ref): fix warnings in console

* feat(ref: no-ref): remove cypress from lib folder

* feat(ref: no-ref): add text to readme

* build(deps-dev): bump undici from 5.28.3 to 5.28.4 (#1343)

Bumps [undici](https://github.com/nodejs/undici) from 5.28.3 to 5.28.4.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](nodejs/undici@v5.28.3...v5.28.4)

---
updated-dependencies:
- dependency-name: undici
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump tar and npm (#1346)

Bumps [tar](https://github.com/isaacs/node-tar) and [npm](https://github.com/npm/cli). These dependencies needed to be updated together.

Updates `tar` from 6.1.14 to 6.2.1
- [Release notes](https://github.com/isaacs/node-tar/releases)
- [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md)
- [Commits](isaacs/node-tar@v6.1.14...v6.2.1)

Updates `npm` from 10.5.0 to 10.5.2
- [Release notes](https://github.com/npm/cli/releases)
- [Changelog](https://github.com/npm/cli/blob/latest/CHANGELOG.md)
- [Commits](npm/cli@v10.5.0...v10.5.2)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
- dependency-name: npm
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump undici and @angular-devkit/build-angular (#1351)

Bumps [undici](https://github.com/nodejs/undici) to 6.11.1 and updates ancestor dependency [@angular-devkit/build-angular](https://github.com/angular/angular-cli). These dependencies need to be updated together.


Updates `undici` from 6.7.1 to 6.11.1
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](nodejs/undici@v6.7.1...v6.11.1)

Updates `@angular-devkit/build-angular` from 17.3.0 to 17.3.4
- [Release notes](https://github.com/angular/angular-cli/releases)
- [Changelog](https://github.com/angular/angular-cli/blob/main/CHANGELOG.md)
- [Commits](angular/angular-cli@17.3.0...17.3.4)

---
updated-dependencies:
- dependency-name: undici
  dependency-type: indirect
- dependency-name: "@angular-devkit/build-angular"
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(no-ref): update deps (#1353)

* feat(no-ref): update deps

* feat(no-ref): update deps v1

* fix(1358): add trailing zero when mask="separator.1" and leadZero="true" (#1359)

Currently, no trailing zero is added when mask="separator.1" and leadZero="true" and input loses focus. This change adds the trailing zero in that case.

* feat(no-ref): up deps (#1362)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Andrii Kamaldinov <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nathaniel Buck <[email protected]>

* fix(ref: no-ref): fix issues 

* fix(ref: no-ref): fix issues

* fix(ref: no-ref): fix bugs

* fix(ref: no-ref): fix bugs

* feat(ref: no-ref): fix issue 

* feat(ref: no-ref): fix issue

* feat(ref: no-ref): fix issue

* feat(ref: no-ref): fix issue

* fix(ref: no-ref): fix issue

* fix(ref: no-ref): fix issue

* fix(ref: no-ref): fix issue

* fix(ref: no-ref): fix issue

* fix(ref: no-ref): fix issue

* fix(ref: no-ref): fix issue

* feat(ref: no-ref): up-deps

* feat(ref: no-ref): up-deps

* feat(ref: no-ref): up-deps

* fix(ref:no-ref): add cache folder to ignore

* fix(ref:no-ref): add cache folder to ignore v1

* feat(ref: no-ref): add more timeout to cypress

---------

Co-authored-by: NepipenkoIgor <[email protected]>

* fix(ref: no-ref): release

* fix(ref: no-ref): fix issues

* fix(ref: no-ref): fix issues

* fix(ref: no-ref): fix issues

* fix(ref: no-ref): fix issues

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Igor Nepipenko <[email protected]>
Co-authored-by: Igor Nepipenko <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: PradeepRaj <[email protected]>
Co-authored-by: Mikael Augusto Boff <[email protected]>
Co-authored-by: Pierre-Arnaud Galiana <[email protected]>
Co-authored-by: Nathaniel Buck <[email protected]>
  • Loading branch information
8 people authored Nov 1, 2024
1 parent 408dbd9 commit 8b72978
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 18 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 18.0.2(2024-11-01)

### Fix

- Fix ([#1427](https://github.com/JsDaddy/ngx-mask/issues/1427))
- Fix ([#1405](https://github.com/JsDaddy/ngx-mask/issues/1405))
- Fix ([#1426](https://github.com/JsDaddy/ngx-mask/issues/1426))
- Fix ([#1406](https://github.com/JsDaddy/ngx-mask/issues/1406))
- Fix ([#1420](https://github.com/JsDaddy/ngx-mask/issues/1420))
- Fix ([#1416](https://github.com/JsDaddy/ngx-mask/issues/1416))

# 18.0.1(2024-10-29)

### Breaking Changes
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": "18.0.1",
"version": "18.0.2",
"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": "18.0.1",
"version": "18.0.2",
"description": "awesome ngx mask",
"keywords": [
"ng2-mask",
Expand Down
16 changes: 12 additions & 4 deletions projects/ngx-mask-lib/src/lib/ngx-mask-applier.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ export class NgxMaskApplierService {

const precision: number = this.getPrecision(maskExpression);
const decimalMarker = Array.isArray(this.decimalMarker)
? MaskExpression.DOT
? this.thousandSeparator === MaskExpression.DOT
? MaskExpression.COMMA
: MaskExpression.DOT
: this.decimalMarker;

if (precision === 0) {
Expand Down Expand Up @@ -371,6 +373,8 @@ export class NgxMaskApplierService {
const commaShift: number =
result.indexOf(MaskExpression.COMMA) - processedValue.indexOf(MaskExpression.COMMA);
const shiftStep: number = result.length - processedValue.length;
const backspacedDecimalMarkerWithSeparatorLimit =
backspaced && result.length < inputValue.length && this.separatorLimit;

if (
(result[processedPosition - 1] === this.thousandSeparator ||
Expand All @@ -379,15 +383,18 @@ export class NgxMaskApplierService {
backspaced
) {
processedPosition = processedPosition - 1;
} else if (shiftStep > 0 && result[processedPosition] !== this.thousandSeparator) {
} else if (
(shiftStep > 0 && result[processedPosition] !== this.thousandSeparator) ||
backspacedDecimalMarkerWithSeparatorLimit
) {
backspaceShift = true;
let _shift = 0;
do {
this._shift.add(processedPosition + _shift);
_shift++;
} while (_shift < shiftStep);
} else if (
result[processedPosition - 1] === this.decimalMarker ||
result[processedPosition - 1] === this.thousandSeparator ||
shiftStep === -4 ||
shiftStep === -3 ||
result[processedPosition] === this.thousandSeparator
Expand Down Expand Up @@ -821,6 +828,7 @@ export class NgxMaskApplierService {
) => {
let x: string[] = [];
let decimalChar = '';

if (Array.isArray(decimalChars)) {
const regExp = new RegExp(
decimalChars.map((v) => ('[\\^$.|?*+()'.indexOf(v) >= 0 ? `\\${v}` : v)).join('|')
Expand Down Expand Up @@ -870,7 +878,7 @@ export class NgxMaskApplierService {
return !isNaN(value) && value >= 0 && value <= 100;
};

private getPrecision = (maskExpression: string): number => {
public getPrecision = (maskExpression: string): number => {
const x: string[] = maskExpression.split(MaskExpression.DOT);
if (x.length > 1) {
return Number(x[x.length - 1]);
Expand Down
39 changes: 28 additions & 11 deletions projects/ngx-mask-lib/src/lib/ngx-mask.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,25 +687,35 @@ export class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valida
public onBlur(e: CustomKeyboardEvent): void {
if (this._maskValue) {
const el: HTMLInputElement = e.target as HTMLInputElement;
if (this.leadZero && el.value.length > 0 && typeof this.decimalMarker === 'string') {
if (
this._maskService.leadZero &&
el.value.length > 0 &&
typeof this._maskService.decimalMarker === 'string'
) {
const maskExpression = this._maskService.maskExpression;
const precision = Number(
this._maskService.maskExpression.slice(
maskExpression.length - 1,
maskExpression.length
)
);

if (precision > 0) {
el.value = this.suffix ? el.value.split(this.suffix).join('') : el.value;
const decimalPart = el.value.split(this.decimalMarker)[1] as string;
el.value = el.value.includes(this.decimalMarker)
el.value = this._maskService.suffix
? el.value.split(this._maskService.suffix).join('')
: el.value;
const decimalPart = el.value.split(
this._maskService.decimalMarker
)[1] as string;

el.value = el.value.includes(this._maskService.decimalMarker)
? el.value +
MaskExpression.NUMBER_ZERO.repeat(precision - decimalPart.length) +
this.suffix
this._maskService.suffix
: el.value +
this.decimalMarker +
this._maskService.decimalMarker +
MaskExpression.NUMBER_ZERO.repeat(precision) +
this.suffix;
this._maskService.suffix;
this._maskService.actualValue = el.value;
}
}
Expand Down Expand Up @@ -771,7 +781,14 @@ export class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valida
((el.selectionStart as number) || (el.selectionEnd as number)) <=
this._maskService.prefix.length
) {
el.selectionStart = this._maskService.prefix.length;
const specialCharactersAtTheStart =
this._maskService.maskExpression.match(
new RegExp(
`^[${this._maskService.specialCharacters.map((c) => `\\${c}`).join('')}]+`
)
)?.[0].length || 0;

el.selectionStart = this._maskService.prefix.length + specialCharactersAtTheStart;
return;
}
/** select only inserted text */
Expand Down Expand Up @@ -903,7 +920,6 @@ export class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valida
if (value !== null) {
value = this.inputTransformFn ? this.inputTransformFn(value) : value;
}

if (
typeof value === 'string' ||
typeof value === 'number' ||
Expand Down Expand Up @@ -943,10 +959,11 @@ export class NgxMaskDirective implements ControlValueAccessor, OnChanges, Valida
inputValue as string
);
}

if (
this.decimalMarker === MaskExpression.COMMA ||
this._maskService.decimalMarker === MaskExpression.COMMA ||
(Array.isArray(this._maskService.decimalMarker) &&
this.thousandSeparator === MaskExpression.DOT)
this._maskService.thousandSeparator === MaskExpression.DOT)
) {
inputValue = inputValue
.toString()
Expand Down
3 changes: 2 additions & 1 deletion projects/ngx-mask-lib/src/lib/ngx-mask.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,9 @@ export class NgxMaskService extends NgxMaskApplierService {
}

public _checkPrecision(separatorExpression: string, separatorValue: string): number | string {
const separatorPrecision = separatorExpression.slice(10, 11);
const separatorPrecision = this.getPrecision(separatorExpression);
let value = separatorValue;

if (
separatorExpression.indexOf('2') > 0 ||
(this.leadZero && Number(separatorPrecision) > 0)
Expand Down
91 changes: 91 additions & 0 deletions projects/ngx-mask-lib/src/test/cursor.cy-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,95 @@ describe('Test Date Hh:m0', () => {
cy.get('#masked').type('111').should('have.value', '(11) 1');
cy.get('#masked').type('{backspace}').should('have.prop', 'selectionStart', 4);
});

it('when decimalMarker doenst set should have right position cursor thousandSeparator = .', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: '.',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('12345678,00')

.should('have.value', '12.345.678,00')
.type('{leftArrow}'.repeat(3))
.type('{backspace}'.repeat(3))
.should('have.value', '12.345,00');
});

it('when decimalMarker doenst set should have right position cursor thousandSeparator = ,', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: ',',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('12345678.00')

.should('have.value', '12,345,678.00')
.type('{leftArrow}'.repeat(3))
.type('{backspace}'.repeat(3))
.should('have.value', '12,345.00');
});

it('should place cursor after backspace with separatorLimit = 10 in correct position', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
separatorLimit: '10',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('12.10')
.should('have.value', '12.10')
.type('{leftArrow}'.repeat(2))
.type('{backspace}')
.should('have.value', '12')
.should('have.prop', 'selectionStart', 2);
});

it('should place cursor after backspace with separatorLimit = 100 in correct position', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
separatorLimit: '100',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('123.10')
.should('have.value', '123.10')
.type('{leftArrow}'.repeat(2))
.type('{backspace}')
.should('have.value', '123')
.should('have.prop', 'selectionStart', 3);
});

it('should place cursor after backspace with separatorLimit = 1000 in correct position', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: ',',
separatorLimit: '1000',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('1234.10')
.should('have.value', '1,234.10')
.type('{leftArrow}'.repeat(2))
.type('{backspace}')
.should('have.value', '1,234')
.should('have.prop', 'selectionStart', 5);
});
});
34 changes: 34 additions & 0 deletions projects/ngx-mask-lib/src/test/default-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,38 @@ describe('Default config', () => {
expect(fixture.nativeElement.querySelector('input').value).toBe('1.234,56');
});
});

it('default config overriden - decimalMarker and thousandSeparator and leadZero', () => {
const fixture = createComponentWithDefaultConfig({
thousandSeparator: '.',
decimalMarker: ',',
leadZero: true,
separatorLimit: '100',
});
const component = fixture.componentInstance;
component.mask = 'separator.2';

component.form = new FormControl(123);
fixture.detectChanges();
fixture.whenRenderingDone().then(() => {
expect(fixture.nativeElement.querySelector('input').value).toBe('123,00');
});
});

it('default config overriden - decimalMarker and thousandSeparator and leadZero and suffix', () => {
const fixture = createComponentWithDefaultConfig({
suffix: ' €',
thousandSeparator: ' ',
decimalMarker: ',',
leadZero: true,
});
const component = fixture.componentInstance;
component.mask = 'separator.2';

component.form = new FormControl(15000.33);
fixture.detectChanges();
fixture.whenRenderingDone().then(() => {
expect(fixture.nativeElement.querySelector('input').value).toBe('15 000,33 €');
});
});
});
40 changes: 40 additions & 0 deletions projects/ngx-mask-lib/src/test/separator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1795,4 +1795,44 @@ describe('Separator: Mask', () => {
expect(inputElement.value).toBe('1 234 567.89');
expect(inputElement.selectionStart).toBe(1);
});

it('should show correct value with separator.9', fakeAsync(() => {
component.mask = 'separator.9';
component.decimalMarker = '.';
component.leadZero = true;
component.separatorLimit = '10';
fixture.detectChanges();

const debugElement: DebugElement = fixture.debugElement.query(By.css('input'));
const inputTarget: HTMLInputElement = debugElement.nativeElement as HTMLInputElement;
spyOnProperty(document, 'activeElement').and.returnValue(inputTarget);

equal('1', '1', fixture);
equal('12', '12', fixture);

component.form.setValue(10.1);
tick();
fixture.detectChanges();
expect(inputTarget.value).toBe('10.100000000');
}));

it('should show correct value with separator.10', fakeAsync(() => {
component.mask = 'separator.10';
component.decimalMarker = '.';
component.leadZero = true;
component.separatorLimit = '10';
fixture.detectChanges();

const debugElement: DebugElement = fixture.debugElement.query(By.css('input'));
const inputTarget: HTMLInputElement = debugElement.nativeElement as HTMLInputElement;
spyOnProperty(document, 'activeElement').and.returnValue(inputTarget);

equal('1', '1', fixture);
equal('12', '12', fixture);

component.form.setValue(10.1);
tick();
fixture.detectChanges();
expect(inputTarget.value).toBe('10.1000000000');
}));
});
Loading

0 comments on commit 8b72978

Please sign in to comment.