Skip to content

Commit

Permalink
feat(ref: #188): fix 1410
Browse files Browse the repository at this point in the history
  • Loading branch information
andriikamaldinov1 committed Oct 30, 2024
1 parent 2e45d01 commit 6b84685
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 95 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# 18.0.1(2024-10-29)

### Enhancement

- add tailwind
- change interface to type, remove prefix "I"
- update dependencies
- add ESLint strict rules

### Fix

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

# 17.1.8(2024-07-16)

### Fix

- Fix ([#1344](https://github.com/JsDaddy/ngx-mask/issues/1344))
- Fix ([#1356](https://github.com/JsDaddy/ngx-mask/issues/1356))




# 17.1.8(2024-07-16)

### Fix
Expand Down
4 changes: 0 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,8 @@ module.exports = tseslint.config(
'lines-between-class-members': 'off',
'no-return-assign': 'off',
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],

//THINK ABOUT THIS
// 'no-param-reassign': 'off',
'no-param-reassign': 'error',
'no-undefined': 'error',

'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-assertions': [
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.0",
"version": "18.0.1",
"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.0",
"version": "18.0.1",
"description": "awesome ngx mask",
"keywords": [
"ng2-mask",
Expand Down
8 changes: 6 additions & 2 deletions projects/ngx-mask-lib/src/lib/ngx-mask-applier.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export class NgxMaskApplierService {
) {
processedValue = this._stripToDecimal(processedValue);
}

const precision: number = this.getPrecision(maskExpression);
const decimalMarker = Array.isArray(this.decimalMarker)
? MaskExpression.DOT
Expand Down Expand Up @@ -369,7 +370,8 @@ export class NgxMaskApplierService {
const shiftStep: number = result.length - processedValue.length;

if (
result[processedPosition - 1] === this.thousandSeparator &&
(result[processedPosition - 1] === this.thousandSeparator ||
result[processedPosition - this.prefix.length]) &&
this.prefix &&
backspaced
) {
Expand Down Expand Up @@ -555,14 +557,16 @@ export class NgxMaskApplierService {
this.specialCharacters.includes(inputValueCursorPlusTwo)) ||
this.specialCharacters.includes(inputValueCursor)
: Number(inputValueSliceCursorPlusTwo) > daysCount ||
this.specialCharacters.includes(inputValueCursorPlusOne))
(this.specialCharacters.includes(inputValueCursorPlusOne) &&
!backspaced))
) {
processedPosition = !this.leadZeroDateTime
? processedPosition + 1
: processedPosition;
cursor += 1;
this._shiftStep(maskExpression, cursor, inputArray.length);
i--;

if (this.leadZeroDateTime) {
result += '0';
}
Expand Down
207 changes: 120 additions & 87 deletions projects/ngx-mask-lib/src/test/delete.cy-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,93 +289,93 @@ describe('Directive: Mask (Delete)', () => {
.should('have.value', '+32 __ ___ __ __');
});

// it('should backspace with separator and prefix', () => {
// cy.mount(CypressTestMaskComponent, {
// componentProperties: {
// mask: 'separator.2',
// thousandSeparator: ',',
// prefix: '$ ',
// },
// imports: [CypressTestMaskModule],
// });
//
// cy.get('#masked')
// .type('1234567890')
// .should('have.value', '$ 1,234,567,890')
// .type('{leftArrow}'.repeat(3))
// .type('{backspace}')
// .should('have.prop', 'selectionStart', 10);
// });
//
// it('should backspace with separator and prefix', () => {
// cy.mount(CypressTestMaskComponent, {
// componentProperties: {
// mask: 'separator.2',
// thousandSeparator: '.',
// prefix: '$ ',
// },
// imports: [CypressTestMaskModule],
// });
//
// cy.get('#masked')
// .type('1234567890')
// .should('have.value', '$ 1.234.567.890')
// .type('{leftArrow}'.repeat(3))
// .type('{backspace}')
// .should('have.prop', 'selectionStart', 10);
// });
//
// it('should backspace with showMaskTyped and leadZeroDateTime', () => {
// cy.mount(CypressTestMaskComponent, {
// componentProperties: {
// mask: 'M0-d0-0000',
// leadZeroDateTime: true,
// showMaskTyped: true,
// },
// imports: [CypressTestMaskModule],
// });
//
// cy.get('#masked')
// .type('12310000')
// .should('have.value', '12-31-0000')
// .type('{backspace}'.repeat(8))
// .should('have.value', '__-__-____');
// });
//
// it('should backspace with showMaskTyped and leadZeroDateTime', () => {
// cy.mount(CypressTestMaskComponent, {
// componentProperties: {
// mask: 'M0/d0/0000',
// leadZeroDateTime: true,
// showMaskTyped: true,
// },
// imports: [CypressTestMaskModule],
// });
//
// cy.get('#masked')
// .type('12310000')
// .should('have.value', '12/31/0000')
// .type('{backspace}'.repeat(8))
// .should('have.value', '__/__/____');
// });
//
// it('should backspace with showMaskTyped and leadZeroDateTime', () => {
// cy.mount(CypressTestMaskComponent, {
// componentProperties: {
// mask: 'M0:d0:0000',
// leadZeroDateTime: true,
// showMaskTyped: true,
// },
// imports: [CypressTestMaskModule],
// });
//
// cy.get('#masked')
// .type('12310000')
// .should('have.value', '12:31:0000')
// .type('{backspace}'.repeat(8))
// .should('have.value', '__:__:____');
// });
//
it('should backspace with separator and prefix', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: ',',
prefix: '$ ',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('1234567890')
.should('have.value', '$ 1,234,567,890')
.type('{leftArrow}'.repeat(3))
.type('{backspace}')
.should('have.prop', 'selectionStart', 11);
});

it('should backspace with separator and prefix', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'separator.2',
thousandSeparator: '.',
prefix: '$ ',
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('1234567890')
.should('have.value', '$ 1.234.567.890')
.type('{leftArrow}'.repeat(3))
.type('{backspace}')
.should('have.prop', 'selectionStart', 11);
});

it('should backspace with showMaskTyped and leadZeroDateTime', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'M0-d0-0000',
leadZeroDateTime: true,
showMaskTyped: true,
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('12310000')
.should('have.value', '12-31-0000')
.type('{backspace}'.repeat(10))
.should('have.value', '__-__-____');
});

it('should backspace with showMaskTyped and leadZeroDateTime', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'M0/d0/0000',
leadZeroDateTime: true,
showMaskTyped: true,
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('12310000')
.should('have.value', '12/31/0000')
.type('{backspace}'.repeat(10))
.should('have.value', '__/__/____');
});

it('should backspace with showMaskTyped and leadZeroDateTime', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'M0:d0:0000',
leadZeroDateTime: true,
showMaskTyped: true,
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('12310000')
.should('have.value', '12:31:0000')
.type('{backspace}'.repeat(10))
.should('have.value', '__:__:____');
});

it('should correct work after backspace separator.6 decimalMarker . thousandSeparator ,', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
Expand Down Expand Up @@ -602,4 +602,37 @@ describe('Directive: Mask (Delete)', () => {
.type('{backspace}')
.should('have.value', '4');
});

it('should backspace with mask Hh:m0', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'Hh:m0',
showMaskTyped: true,
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('1234')
.should('have.value', '12:34')
.type('{backspace}'.repeat(4))
.should('have.value', '__:__');
});

it('should backspace with mask Hh:m0 and leadZeroDateTime', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: 'Hh:m0',
showMaskTyped: true,
leadZeroDateTime: true,
},
imports: [CypressTestMaskModule],
});

cy.get('#masked')
.type('344')
.should('have.value', '03:44')
.type('{backspace}'.repeat(5))
.should('have.value', '__:__');
});
});

0 comments on commit 6b84685

Please sign in to comment.