@maskito/core
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -60,2 +60,3 @@ 'use strict'; | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
set(target, prop, val, receiver) { | ||
@@ -146,2 +147,3 @@ return Reflect.set(prop in adapter ? adapter : target, prop, val, receiver); | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function getLeadingFixedCharacters(mask, validatedValuePart, newCharacter, initialElementState) { | ||
@@ -217,3 +219,9 @@ let leadingFixedCharacters = ''; | ||
}, ''); | ||
return { value: validatedValue, selection: [newFrom, newTo] }; | ||
return { | ||
value: validatedValue, | ||
selection: [ | ||
Math.min(newFrom, validatedValue.length), | ||
Math.min(newTo, validatedValue.length), | ||
], | ||
}; | ||
} | ||
@@ -532,9 +540,2 @@ | ||
switch (event.inputType) { | ||
// historyUndo/historyRedo will not be triggered if value was modified programmatically | ||
case 'historyUndo': | ||
event.preventDefault(); | ||
return this.undo(); | ||
case 'historyRedo': | ||
event.preventDefault(); | ||
return this.redo(); | ||
case 'deleteByCut': | ||
@@ -548,22 +549,32 @@ case 'deleteContentBackward': | ||
}); | ||
case 'deleteWordForward': | ||
case 'deleteWordBackward': | ||
case 'deleteHardLineBackward': | ||
case 'deleteHardLineForward': | ||
case 'deleteSoftLineBackward': | ||
case 'deleteSoftLineForward': | ||
return this.handleDelete({ | ||
event, | ||
isForward, | ||
selection: getWordSelection(this.elementState, isForward), | ||
selection: getLineSelection(this.elementState, isForward), | ||
force: true, | ||
}); | ||
case 'deleteSoftLineBackward': | ||
case 'deleteSoftLineForward': | ||
case 'deleteHardLineBackward': | ||
case 'deleteHardLineForward': | ||
case 'deleteWordBackward': | ||
case 'deleteWordForward': | ||
return this.handleDelete({ | ||
event, | ||
isForward, | ||
selection: getLineSelection(this.elementState, isForward), | ||
selection: getWordSelection(this.elementState, isForward), | ||
force: true, | ||
}); | ||
case 'historyRedo': | ||
event.preventDefault(); | ||
return this.redo(); | ||
// historyUndo/historyRedo will not be triggered if value was modified programmatically | ||
case 'historyUndo': | ||
event.preventDefault(); | ||
return this.undo(); | ||
case 'insertCompositionText': | ||
return; // will be handled inside `compositionend` event | ||
case 'insertLineBreak': | ||
case 'insertParagraph': | ||
return this.handleEnter(event); | ||
case 'insertReplacementText': | ||
@@ -585,8 +596,5 @@ /** | ||
return; | ||
case 'insertLineBreak': | ||
case 'insertParagraph': | ||
return this.handleEnter(event); | ||
case 'insertFromDrop': | ||
case 'insertFromPaste': | ||
case 'insertText': | ||
case 'insertFromDrop': | ||
default: | ||
@@ -593,0 +601,0 @@ return this.handleInsert(event, (_c = (_a = event.data) !== null && _a !== void 0 ? _a : |
@@ -58,2 +58,3 @@ function getContentEditableSelection(element) { | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
set(target, prop, val, receiver) { | ||
@@ -144,2 +145,3 @@ return Reflect.set(prop in adapter ? adapter : target, prop, val, receiver); | ||
// eslint-disable-next-line @typescript-eslint/max-params | ||
function getLeadingFixedCharacters(mask, validatedValuePart, newCharacter, initialElementState) { | ||
@@ -215,3 +217,9 @@ let leadingFixedCharacters = ''; | ||
}, ''); | ||
return { value: validatedValue, selection: [newFrom, newTo] }; | ||
return { | ||
value: validatedValue, | ||
selection: [ | ||
Math.min(newFrom, validatedValue.length), | ||
Math.min(newTo, validatedValue.length), | ||
], | ||
}; | ||
} | ||
@@ -530,9 +538,2 @@ | ||
switch (event.inputType) { | ||
// historyUndo/historyRedo will not be triggered if value was modified programmatically | ||
case 'historyUndo': | ||
event.preventDefault(); | ||
return this.undo(); | ||
case 'historyRedo': | ||
event.preventDefault(); | ||
return this.redo(); | ||
case 'deleteByCut': | ||
@@ -546,22 +547,32 @@ case 'deleteContentBackward': | ||
}); | ||
case 'deleteWordForward': | ||
case 'deleteWordBackward': | ||
case 'deleteHardLineBackward': | ||
case 'deleteHardLineForward': | ||
case 'deleteSoftLineBackward': | ||
case 'deleteSoftLineForward': | ||
return this.handleDelete({ | ||
event, | ||
isForward, | ||
selection: getWordSelection(this.elementState, isForward), | ||
selection: getLineSelection(this.elementState, isForward), | ||
force: true, | ||
}); | ||
case 'deleteSoftLineBackward': | ||
case 'deleteSoftLineForward': | ||
case 'deleteHardLineBackward': | ||
case 'deleteHardLineForward': | ||
case 'deleteWordBackward': | ||
case 'deleteWordForward': | ||
return this.handleDelete({ | ||
event, | ||
isForward, | ||
selection: getLineSelection(this.elementState, isForward), | ||
selection: getWordSelection(this.elementState, isForward), | ||
force: true, | ||
}); | ||
case 'historyRedo': | ||
event.preventDefault(); | ||
return this.redo(); | ||
// historyUndo/historyRedo will not be triggered if value was modified programmatically | ||
case 'historyUndo': | ||
event.preventDefault(); | ||
return this.undo(); | ||
case 'insertCompositionText': | ||
return; // will be handled inside `compositionend` event | ||
case 'insertLineBreak': | ||
case 'insertParagraph': | ||
return this.handleEnter(event); | ||
case 'insertReplacementText': | ||
@@ -583,8 +594,5 @@ /** | ||
return; | ||
case 'insertLineBreak': | ||
case 'insertParagraph': | ||
return this.handleEnter(event); | ||
case 'insertFromDrop': | ||
case 'insertFromPaste': | ||
case 'insertText': | ||
case 'insertFromDrop': | ||
default: | ||
@@ -591,0 +599,0 @@ return this.handleInsert(event, (_c = (_a = event.data) !== null && _a !== void 0 ? _a : |
{ | ||
"name": "@maskito/core", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "The main zero-dependency and framework-agnostic Maskito's package to create an input mask", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
96836
1766