Browse Source

The inputmask is autocompleted to the min value when deleting the radix point
#2773

Robin Herbots 1 year ago
parent
commit
8a211a89a8

+ 1 - 1
Changelog.md

@@ -7,7 +7,7 @@
 ### Updates
 
 ### Fixed
-
+- The inputmask is autocompleted to the min value when deleting the radix point #2773
 
 ## [5.0.9 - 31/05/2024]
 

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.10-beta.0",
+  "version": "5.0.10-beta.1",
   "main": [
 	  "./index.js",
     "./css/inputmask.css"

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "5.0.10-beta.0",
+  "version": "5.0.10-beta.1",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 6 - 6
dist/colormask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2024 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.10-beta.0
+ * Version: 5.0.10-beta.1
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else {
@@ -1893,15 +1893,15 @@
                                 rewritePosition: t
                             };
                         },
-                        postValidation: function(e, t, n, i, a, r, o) {
+                        postValidation: function(e, t, n, i, a, r, o, l, c) {
                             if (!1 === i) return i;
                             if (o) return !0;
                             if (null !== a.min || null !== a.max) {
-                                var l = a.onUnMask(e.slice().reverse().join(""), void 0, s.extend({}, a, {
+                                var f = a.onUnMask(e.slice().reverse().join(""), void 0, s.extend({}, a, {
                                     unmaskAsNumber: !0
                                 }));
-                                if (null !== a.min && l < a.min && (l.toString().length > a.min.toString().length || l < 0)) return !1;
-                                if (null !== a.max && l > a.max) return !!a.SetMaxOnOverflow && {
+                                if (null !== a.min && f < a.min && !0 !== c && (f.toString().length > a.min.toString().length || e[0] === a.radixPoint || f < 0)) return !1;
+                                if (null !== a.max && f > a.max) return !!a.SetMaxOnOverflow && {
                                     refreshFromBuffer: !0,
                                     buffer: u(a.max.toString().replace(".", a.radixPoint).split(""), a.digits, a).reverse()
                                 };
@@ -3754,7 +3754,7 @@
                         });
                     }
                     if ("function" == typeof k.postValidation && !0 !== i && !0 !== p) {
-                        var A = k.postValidation.call(g, r.getBuffer.call(g, !0), void 0 !== e.begin ? g.isRTL ? e.end : e.begin : e, t, S, k, b, n, m);
+                        var A = k.postValidation.call(g, r.getBuffer.call(g, !0), void 0 !== e.begin ? g.isRTL ? e.end : e.begin : e, t, S, k, b, n, m, a);
                         void 0 !== A && (S = !0 === A ? S : A);
                     }
                     S && void 0 === S.pos && (S.pos = x), !1 === S || !0 === p ? (r.resetMaskSet.call(g, !0), 

File diff suppressed because it is too large
+ 2 - 2
dist/colormask.min.js


+ 6 - 6
dist/inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2024 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.10-beta.0
+ * Version: 5.0.10-beta.1
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else {
@@ -1778,15 +1778,15 @@
                                 rewritePosition: t
                             };
                         },
-                        postValidation: function(e, t, n, i, a, r, o) {
+                        postValidation: function(e, t, n, i, a, r, o, l, c) {
                             if (!1 === i) return i;
                             if (o) return !0;
                             if (null !== a.min || null !== a.max) {
-                                var l = a.onUnMask(e.slice().reverse().join(""), void 0, s.extend({}, a, {
+                                var f = a.onUnMask(e.slice().reverse().join(""), void 0, s.extend({}, a, {
                                     unmaskAsNumber: !0
                                 }));
-                                if (null !== a.min && l < a.min && (l.toString().length > a.min.toString().length || l < 0)) return !1;
-                                if (null !== a.max && l > a.max) return !!a.SetMaxOnOverflow && {
+                                if (null !== a.min && f < a.min && !0 !== c && (f.toString().length > a.min.toString().length || e[0] === a.radixPoint || f < 0)) return !1;
+                                if (null !== a.max && f > a.max) return !!a.SetMaxOnOverflow && {
                                     refreshFromBuffer: !0,
                                     buffer: u(a.max.toString().replace(".", a.radixPoint).split(""), a.digits, a).reverse()
                                 };
@@ -3639,7 +3639,7 @@
                         });
                     }
                     if ("function" == typeof k.postValidation && !0 !== i && !0 !== p) {
-                        var A = k.postValidation.call(g, r.getBuffer.call(g, !0), void 0 !== e.begin ? g.isRTL ? e.end : e.begin : e, t, S, k, b, n, m);
+                        var A = k.postValidation.call(g, r.getBuffer.call(g, !0), void 0 !== e.begin ? g.isRTL ? e.end : e.begin : e, t, S, k, b, n, m, a);
                         void 0 !== A && (S = !0 === A ? S : A);
                     }
                     S && void 0 === S.pos && (S.pos = x), !1 === S || !0 === p ? (r.resetMaskSet.call(g, !0), 

File diff suppressed because it is too large
+ 2 - 2
dist/inputmask.min.js


+ 6 - 6
dist/jquery.inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2024 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.10-beta.0
+ * Version: 5.0.10-beta.1
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(require("jquery")); else if ("function" == typeof define && define.amd) define([ "jquery" ], t); else {
@@ -1607,15 +1607,15 @@
                                 rewritePosition: t
                             };
                         },
-                        postValidation: function(e, t, n, i, a, r, o) {
+                        postValidation: function(e, t, n, i, a, r, o, s, c) {
                             if (!1 === i) return i;
                             if (o) return !0;
                             if (null !== a.min || null !== a.max) {
-                                var s = a.onUnMask(e.slice().reverse().join(""), void 0, l.extend({}, a, {
+                                var f = a.onUnMask(e.slice().reverse().join(""), void 0, l.extend({}, a, {
                                     unmaskAsNumber: !0
                                 }));
-                                if (null !== a.min && s < a.min && (s.toString().length > a.min.toString().length || s < 0)) return !1;
-                                if (null !== a.max && s > a.max) return !!a.SetMaxOnOverflow && {
+                                if (null !== a.min && f < a.min && !0 !== c && (f.toString().length > a.min.toString().length || e[0] === a.radixPoint || f < 0)) return !1;
+                                if (null !== a.max && f > a.max) return !!a.SetMaxOnOverflow && {
                                     refreshFromBuffer: !0,
                                     buffer: u(a.max.toString().replace(".", a.radixPoint).split(""), a.digits, a).reverse()
                                 };
@@ -3536,7 +3536,7 @@
                         });
                     }
                     if ("function" == typeof k.postValidation && !0 !== i && !0 !== p) {
-                        var A = k.postValidation.call(g, r.getBuffer.call(g, !0), void 0 !== e.begin ? g.isRTL ? e.end : e.begin : e, t, S, k, b, n, v);
+                        var A = k.postValidation.call(g, r.getBuffer.call(g, !0), void 0 !== e.begin ? g.isRTL ? e.end : e.begin : e, t, S, k, b, n, v, a);
                         void 0 !== A && (S = !0 === A ? S : A);
                     }
                     S && void 0 === S.pos && (S.pos = x), !1 === S || !0 === p ? (r.resetMaskSet.call(g, !0), 

File diff suppressed because it is too large
+ 2 - 2
dist/jquery.inputmask.min.js


+ 1 - 1
inputmask-pages/src/assets/Changelog.md

@@ -7,7 +7,7 @@
 ### Updates
 
 ### Fixed
-
+- The inputmask is autocompleted to the min value when deleting the radix point #2773
 
 ## [5.0.9 - 31/05/2024]
 

+ 1 - 1
inputmask-pages/src/assets/Documentation.md

@@ -1093,7 +1093,7 @@ $(selector).inputmask({
 
 ### postValidation
 
-Hook to postValidate the result from isValid.  Usefull for validating the entry as a whole.  Args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval<br>Return => true|false|command object
+Hook to postValidate the result from isValid.  Usefull for validating the entry as a whole.  Args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval, fromAlternate<br>Return => true|false|command object
 
 ### preValidation
 

+ 1 - 1
lib/defaults.js

@@ -47,7 +47,7 @@ export default {
   supportsInputType: ["text", "tel", "url", "password", "search"], // list with the supported input types
   isComplete: null, // override for isComplete - args => buffer, opts - return true || false
   preValidation: null, // hook to preValidate the input.  Usefull for validating regardless the definition.	args => buffer, pos, char, isSelection, opts, maskset, caretPos, strict => return true/false/command object
-  postValidation: null, // hook to postValidate the result from isValid.	Usefull for validating the entry as a whole.	args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval => return true/false/json
+  postValidation: null, // hook to postValidate the result from isValid.	Usefull for validating the entry as a whole.	args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval, fromAlternate => return true/false/json
   staticDefinitionSymbol: undefined, // specify a definitionSymbol for static content, used to make matches for alternators
   jitMasking: false, // just in time masking ~ only mask while typing, can n (number), true or false
   nullable: true, // return nothing instead of the buffertemplate when the user hasn't entered anything.

+ 8 - 4
lib/extensions/inputmask.numeric.extensions.js

@@ -232,7 +232,7 @@ function genMask(opts) {
   return mask;
 }
 
-function hanndleRadixDance(pos, c, radixPos, maskset, opts) {
+function handleRadixDance(pos, c, radixPos, maskset, opts) {
   if (opts._radixDance && opts.numericInput && c !== opts.negationSymbol.back) {
     if (
       pos <= radixPos &&
@@ -382,7 +382,7 @@ Inputmask.extendAliases({
       if (opts.__financeInput !== false && c === opts.radixPoint) return false;
       const radixPos = buffer.indexOf(opts.radixPoint),
         initPos = pos;
-      pos = hanndleRadixDance(pos, c, radixPos, maskset, opts);
+      pos = handleRadixDance(pos, c, radixPos, maskset, opts);
       if (c === "-" || c === opts.negationSymbol.front) {
         if (opts.allowMinus !== true) return false;
         let isNegative = false,
@@ -480,7 +480,9 @@ Inputmask.extendAliases({
       currentResult,
       opts,
       maskset,
-      strict
+      strict,
+      fromCheckval,
+      fromAlternate
     ) {
       if (currentResult === false) return currentResult;
       if (strict) return true;
@@ -495,7 +497,9 @@ Inputmask.extendAliases({
         if (
           opts.min !== null &&
           unmasked < opts.min &&
-          (unmasked.toString().length > opts.min.toString().length ||
+          fromAlternate !== true &&
+          (unmasked.toString().length > opts.min.toString().length || // > instead of >= because we want to allow to type a bigger number
+            buffer[0] === opts.radixPoint || // disallow radixpoint when value is smaller than min
             unmasked < 0)
         ) {
           return false;

+ 2 - 1
lib/validation.js

@@ -724,7 +724,8 @@ function isValid(
       opts,
       maskset,
       strict,
-      fromCheckval
+      fromCheckval,
+      fromAlternate
     );
     if (postResult !== undefined) {
       result = postResult === true ? result : postResult;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.10-beta.0",
+  "version": "5.0.10-beta.1",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "dist/inputmask.js",
   "exports": {