Browse Source

update radixFocus

Robin Herbots 1 year ago
parent
commit
b58b024f66

+ 3 - 1
Changelog.md

@@ -9,12 +9,14 @@
 - only apply character substitution on 'human' input - #2765
 - better handle unmatching alternations - #2277
 - datetime alias
-  - add support for mmm & mmmm #2751 (WIP)
+  - add support for mmm & mmmm #2751
+  - add custom placeholder support
 - Update IP extension to support greedy option. #2749
 - Properly handle insertMode false in alternation logic.
 - Enhance resolving of the ndxInitializer to determine the alternating tests.
 
 ### Fixed
+- Cursor moves to start when there is a 0 in the decimal, How to stop this behavior? #2784
 - Unexpected character removed #2765
 - d/mm/yyyy is converted to d/m//yyyd #2394
 - Invalid state after editing datetime #2708

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.9-beta.67",
+  "version": "5.0.9-beta.68",
   "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.9-beta.67",
+  "version": "5.0.9-beta.68",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 30 - 31
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.9-beta.67
+ * Version: 5.0.9-beta.68
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else {
@@ -3158,64 +3158,63 @@
                         }
                     }
                 }, t.determineLastRequiredPosition = function(e) {
-                    var t, n, i = this, a = i.maskset, l = i.dependencyLib, c = o.getMaskTemplate.call(i, !0, s.call(i), !0, !0), u = c.length, f = s.call(i), p = {}, d = a.validPositions[f], h = void 0 !== d ? d.locator.slice() : void 0;
-                    for (t = f + 1; t < c.length; t++) h = (n = o.getTestTemplate.call(i, t, h, t - 1)).locator.slice(), 
-                    p[t] = l.extend(!0, {}, n);
-                    var v = d && void 0 !== d.alternation ? d.locator[d.alternation] : void 0;
-                    for (t = u - 1; t > f && (((n = p[t]).match.optionality || n.match.optionalQuantifier && n.match.newBlockMarker || v && (v !== p[t].locator[d.alternation] && 1 != n.match.static || !0 === n.match.static && n.locator[d.alternation] && r.checkAlternationMatch.call(i, n.locator[d.alternation].toString().split(","), v.toString().split(",")) && "" !== o.getTests.call(i, t)[0].def)) && c[t] === o.getPlaceholder.call(i, t, n.match)); t--) u--;
+                    var t, n, i = this, a = i.maskset, l = i.dependencyLib, c = s.call(i), u = {}, f = a.validPositions[c], p = o.getMaskTemplate.call(i, !0, s.call(i), !0, !0), d = p.length, h = void 0 !== f ? f.locator.slice() : void 0;
+                    for (t = c + 1; t < p.length; t++) h = (n = o.getTestTemplate.call(i, t, h, t - 1)).locator.slice(), 
+                    u[t] = l.extend(!0, {}, n);
+                    var v = f && void 0 !== f.alternation ? f.locator[f.alternation] : void 0;
+                    for (t = d - 1; t > c && (((n = u[t]).match.optionality || n.match.optionalQuantifier && n.match.newBlockMarker || v && (v !== u[t].locator[f.alternation] && !0 !== n.match.static || !0 === n.match.static && n.locator[f.alternation] && r.checkAlternationMatch.call(i, n.locator[f.alternation].toString().split(","), v.toString().split(",")) && "" !== o.getTests.call(i, t)[0].def)) && p[t] === o.getPlaceholder.call(i, t, n.match)); t--) d--;
                     return e ? {
-                        l: u,
-                        def: p[u] ? p[u].match : void 0
-                    } : u;
+                        l: d,
+                        def: u[d] ? u[d].match : void 0
+                    } : d;
                 }, t.determineNewCaretPosition = function(e, t, n) {
-                    var i = this, a = i.maskset, r = i.opts;
-                    t && (i.isRTL ? e.end = e.begin : e.begin = e.end);
+                    var i, a, r, f = this, p = f.maskset, d = f.opts;
+                    t && (f.isRTL ? e.end = e.begin : e.begin = e.end);
                     if (e.begin === e.end) {
-                        switch (n = n || r.positionCaretOnClick) {
+                        switch (n = n || d.positionCaretOnClick) {
                           case "none":
                             break;
 
                           case "select":
                             e = {
                                 begin: 0,
-                                end: l.call(i).length
+                                end: l.call(f).length
                             };
                             break;
 
                           case "ignore":
-                            e.end = e.begin = u.call(i, s.call(i));
+                            e.end = e.begin = u.call(f, s.call(f));
                             break;
 
                           case "radixFocus":
-                            if (i.clicked > 1 && 0 == a.validPositions.length) break;
+                            if (f.clicked > 1 && 0 === p.validPositions.length) break;
                             if (function(e) {
-                                if ("" !== r.radixPoint && 0 !== r.digits) {
-                                    var t = a.validPositions;
-                                    if (void 0 === t[e] || t[e].input === o.getPlaceholder.call(i, e)) {
-                                        if (e < u.call(i, -1)) return !0;
-                                        var n = l.call(i).indexOf(r.radixPoint);
+                                if ("" !== d.radixPoint && 0 !== d.digits) {
+                                    var t = p.validPositions;
+                                    if (void 0 === t[e] || void 0 === t[e].input) {
+                                        if (e < u.call(f, -1)) return !0;
+                                        var n = l.call(f).indexOf(d.radixPoint);
                                         if (-1 !== n) {
-                                            for (var s = 0, c = t.length; s < c; s++) if (t[s] && n < s && t[s].input !== o.getPlaceholder.call(i, s)) return !1;
+                                            for (var i = 0, a = t.length; i < a; i++) if (t[i] && n < i && t[i].input !== o.getPlaceholder.call(f, i)) return !1;
                                             return !0;
                                         }
                                     }
                                 }
                                 return !1;
                             }(e.begin)) {
-                                var f = l.call(i).join("").indexOf(r.radixPoint);
-                                e.end = e.begin = r.numericInput ? u.call(i, f) : f;
+                                var h = l.call(f).join("").indexOf(d.radixPoint);
+                                e.end = e.begin = d.numericInput ? u.call(f, h) : h;
                                 break;
                             }
 
                           default:
-                            var p = e.begin, d = s.call(i, p, !0), h = u.call(i, -1 !== d || c.call(i, 0) ? d : -1);
-                            if (p <= h) e.end = e.begin = c.call(i, p, !1, !0) ? p : u.call(i, p); else {
-                                var v = a.validPositions[d], m = o.getTestTemplate.call(i, h, v ? v.match.locator : void 0, v), g = o.getPlaceholder.call(i, h, m.match);
-                                if ("" !== g && l.call(i)[h] !== g && !0 !== m.match.optionalQuantifier && !0 !== m.match.newBlockMarker || !c.call(i, h, r.keepStatic, !0) && m.match.def === g) {
-                                    var y = u.call(i, h);
-                                    (p >= y || p === h) && (h = y);
+                            if (i = e.begin, a = s.call(f, i, !0), i <= (r = u.call(f, -1 !== a || c.call(f, 0) ? a : -1))) e.end = e.begin = c.call(f, i, !1, !0) ? i : u.call(f, i); else {
+                                var v = p.validPositions[a], m = o.getTestTemplate.call(f, r, v ? v.match.locator : void 0, v), g = o.getPlaceholder.call(f, r, m.match);
+                                if ("" !== g && l.call(f)[r] !== g && !0 !== m.match.optionalQuantifier && !0 !== m.match.newBlockMarker || !c.call(f, r, d.keepStatic, !0) && m.match.def === g) {
+                                    var y = u.call(f, r);
+                                    (i >= y || i === r) && (r = y);
                                 }
-                                e.end = e.begin = h;
+                                e.end = e.begin = r;
                             }
                         }
                         return e;
@@ -3247,7 +3246,7 @@
                     void 0 === e && (e = -1);
                     for (var l = 0, s = o.length; l < s; l++) o[l] && (t || !0 !== o[l].generatedInput) && (l <= e && (a = l), 
                     l >= e && (r = l));
-                    return -1 === a || a == e ? r : -1 == r || e - a < r - e ? a : r;
+                    return -1 === a || a === e ? r : -1 === r || e - a < r - e ? a : r;
                 }
                 function c(e, t, n) {
                     var i = this, a = this.maskset, r = o.getTestTemplate.call(i, e).match;

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


+ 30 - 31
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.9-beta.67
+ * Version: 5.0.9-beta.68
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else {
@@ -3043,64 +3043,63 @@
                         }
                     }
                 }, t.determineLastRequiredPosition = function(e) {
-                    var t, n, i = this, a = i.maskset, l = i.dependencyLib, c = o.getMaskTemplate.call(i, !0, s.call(i), !0, !0), u = c.length, f = s.call(i), p = {}, d = a.validPositions[f], h = void 0 !== d ? d.locator.slice() : void 0;
-                    for (t = f + 1; t < c.length; t++) h = (n = o.getTestTemplate.call(i, t, h, t - 1)).locator.slice(), 
-                    p[t] = l.extend(!0, {}, n);
-                    var v = d && void 0 !== d.alternation ? d.locator[d.alternation] : void 0;
-                    for (t = u - 1; t > f && (((n = p[t]).match.optionality || n.match.optionalQuantifier && n.match.newBlockMarker || v && (v !== p[t].locator[d.alternation] && 1 != n.match.static || !0 === n.match.static && n.locator[d.alternation] && r.checkAlternationMatch.call(i, n.locator[d.alternation].toString().split(","), v.toString().split(",")) && "" !== o.getTests.call(i, t)[0].def)) && c[t] === o.getPlaceholder.call(i, t, n.match)); t--) u--;
+                    var t, n, i = this, a = i.maskset, l = i.dependencyLib, c = s.call(i), u = {}, f = a.validPositions[c], p = o.getMaskTemplate.call(i, !0, s.call(i), !0, !0), d = p.length, h = void 0 !== f ? f.locator.slice() : void 0;
+                    for (t = c + 1; t < p.length; t++) h = (n = o.getTestTemplate.call(i, t, h, t - 1)).locator.slice(), 
+                    u[t] = l.extend(!0, {}, n);
+                    var v = f && void 0 !== f.alternation ? f.locator[f.alternation] : void 0;
+                    for (t = d - 1; t > c && (((n = u[t]).match.optionality || n.match.optionalQuantifier && n.match.newBlockMarker || v && (v !== u[t].locator[f.alternation] && !0 !== n.match.static || !0 === n.match.static && n.locator[f.alternation] && r.checkAlternationMatch.call(i, n.locator[f.alternation].toString().split(","), v.toString().split(",")) && "" !== o.getTests.call(i, t)[0].def)) && p[t] === o.getPlaceholder.call(i, t, n.match)); t--) d--;
                     return e ? {
-                        l: u,
-                        def: p[u] ? p[u].match : void 0
-                    } : u;
+                        l: d,
+                        def: u[d] ? u[d].match : void 0
+                    } : d;
                 }, t.determineNewCaretPosition = function(e, t, n) {
-                    var i = this, a = i.maskset, r = i.opts;
-                    t && (i.isRTL ? e.end = e.begin : e.begin = e.end);
+                    var i, a, r, f = this, p = f.maskset, d = f.opts;
+                    t && (f.isRTL ? e.end = e.begin : e.begin = e.end);
                     if (e.begin === e.end) {
-                        switch (n = n || r.positionCaretOnClick) {
+                        switch (n = n || d.positionCaretOnClick) {
                           case "none":
                             break;
 
                           case "select":
                             e = {
                                 begin: 0,
-                                end: l.call(i).length
+                                end: l.call(f).length
                             };
                             break;
 
                           case "ignore":
-                            e.end = e.begin = u.call(i, s.call(i));
+                            e.end = e.begin = u.call(f, s.call(f));
                             break;
 
                           case "radixFocus":
-                            if (i.clicked > 1 && 0 == a.validPositions.length) break;
+                            if (f.clicked > 1 && 0 === p.validPositions.length) break;
                             if (function(e) {
-                                if ("" !== r.radixPoint && 0 !== r.digits) {
-                                    var t = a.validPositions;
-                                    if (void 0 === t[e] || t[e].input === o.getPlaceholder.call(i, e)) {
-                                        if (e < u.call(i, -1)) return !0;
-                                        var n = l.call(i).indexOf(r.radixPoint);
+                                if ("" !== d.radixPoint && 0 !== d.digits) {
+                                    var t = p.validPositions;
+                                    if (void 0 === t[e] || void 0 === t[e].input) {
+                                        if (e < u.call(f, -1)) return !0;
+                                        var n = l.call(f).indexOf(d.radixPoint);
                                         if (-1 !== n) {
-                                            for (var s = 0, c = t.length; s < c; s++) if (t[s] && n < s && t[s].input !== o.getPlaceholder.call(i, s)) return !1;
+                                            for (var i = 0, a = t.length; i < a; i++) if (t[i] && n < i && t[i].input !== o.getPlaceholder.call(f, i)) return !1;
                                             return !0;
                                         }
                                     }
                                 }
                                 return !1;
                             }(e.begin)) {
-                                var f = l.call(i).join("").indexOf(r.radixPoint);
-                                e.end = e.begin = r.numericInput ? u.call(i, f) : f;
+                                var h = l.call(f).join("").indexOf(d.radixPoint);
+                                e.end = e.begin = d.numericInput ? u.call(f, h) : h;
                                 break;
                             }
 
                           default:
-                            var p = e.begin, d = s.call(i, p, !0), h = u.call(i, -1 !== d || c.call(i, 0) ? d : -1);
-                            if (p <= h) e.end = e.begin = c.call(i, p, !1, !0) ? p : u.call(i, p); else {
-                                var v = a.validPositions[d], m = o.getTestTemplate.call(i, h, v ? v.match.locator : void 0, v), g = o.getPlaceholder.call(i, h, m.match);
-                                if ("" !== g && l.call(i)[h] !== g && !0 !== m.match.optionalQuantifier && !0 !== m.match.newBlockMarker || !c.call(i, h, r.keepStatic, !0) && m.match.def === g) {
-                                    var y = u.call(i, h);
-                                    (p >= y || p === h) && (h = y);
+                            if (i = e.begin, a = s.call(f, i, !0), i <= (r = u.call(f, -1 !== a || c.call(f, 0) ? a : -1))) e.end = e.begin = c.call(f, i, !1, !0) ? i : u.call(f, i); else {
+                                var v = p.validPositions[a], m = o.getTestTemplate.call(f, r, v ? v.match.locator : void 0, v), g = o.getPlaceholder.call(f, r, m.match);
+                                if ("" !== g && l.call(f)[r] !== g && !0 !== m.match.optionalQuantifier && !0 !== m.match.newBlockMarker || !c.call(f, r, d.keepStatic, !0) && m.match.def === g) {
+                                    var y = u.call(f, r);
+                                    (i >= y || i === r) && (r = y);
                                 }
-                                e.end = e.begin = h;
+                                e.end = e.begin = r;
                             }
                         }
                         return e;
@@ -3132,7 +3131,7 @@
                     void 0 === e && (e = -1);
                     for (var l = 0, s = o.length; l < s; l++) o[l] && (t || !0 !== o[l].generatedInput) && (l <= e && (a = l), 
                     l >= e && (r = l));
-                    return -1 === a || a == e ? r : -1 == r || e - a < r - e ? a : r;
+                    return -1 === a || a === e ? r : -1 === r || e - a < r - e ? a : r;
                 }
                 function c(e, t, n) {
                     var i = this, a = this.maskset, r = o.getTestTemplate.call(i, e).match;

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


+ 30 - 31
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.9-beta.67
+ * Version: 5.0.9-beta.68
  */
 !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 {
@@ -2940,64 +2940,63 @@
                         }
                     }
                 }, t.determineLastRequiredPosition = function(e) {
-                    var t, n, i = this, a = i.maskset, s = i.dependencyLib, c = o.getMaskTemplate.call(i, !0, l.call(i), !0, !0), u = c.length, f = l.call(i), p = {}, d = a.validPositions[f], h = void 0 !== d ? d.locator.slice() : void 0;
-                    for (t = f + 1; t < c.length; t++) h = (n = o.getTestTemplate.call(i, t, h, t - 1)).locator.slice(), 
-                    p[t] = s.extend(!0, {}, n);
-                    var m = d && void 0 !== d.alternation ? d.locator[d.alternation] : void 0;
-                    for (t = u - 1; t > f && (((n = p[t]).match.optionality || n.match.optionalQuantifier && n.match.newBlockMarker || m && (m !== p[t].locator[d.alternation] && 1 != n.match.static || !0 === n.match.static && n.locator[d.alternation] && r.checkAlternationMatch.call(i, n.locator[d.alternation].toString().split(","), m.toString().split(",")) && "" !== o.getTests.call(i, t)[0].def)) && c[t] === o.getPlaceholder.call(i, t, n.match)); t--) u--;
+                    var t, n, i = this, a = i.maskset, s = i.dependencyLib, c = l.call(i), u = {}, f = a.validPositions[c], p = o.getMaskTemplate.call(i, !0, l.call(i), !0, !0), d = p.length, h = void 0 !== f ? f.locator.slice() : void 0;
+                    for (t = c + 1; t < p.length; t++) h = (n = o.getTestTemplate.call(i, t, h, t - 1)).locator.slice(), 
+                    u[t] = s.extend(!0, {}, n);
+                    var m = f && void 0 !== f.alternation ? f.locator[f.alternation] : void 0;
+                    for (t = d - 1; t > c && (((n = u[t]).match.optionality || n.match.optionalQuantifier && n.match.newBlockMarker || m && (m !== u[t].locator[f.alternation] && !0 !== n.match.static || !0 === n.match.static && n.locator[f.alternation] && r.checkAlternationMatch.call(i, n.locator[f.alternation].toString().split(","), m.toString().split(",")) && "" !== o.getTests.call(i, t)[0].def)) && p[t] === o.getPlaceholder.call(i, t, n.match)); t--) d--;
                     return e ? {
-                        l: u,
-                        def: p[u] ? p[u].match : void 0
-                    } : u;
+                        l: d,
+                        def: u[d] ? u[d].match : void 0
+                    } : d;
                 }, t.determineNewCaretPosition = function(e, t, n) {
-                    var i = this, a = i.maskset, r = i.opts;
-                    t && (i.isRTL ? e.end = e.begin : e.begin = e.end);
+                    var i, a, r, f = this, p = f.maskset, d = f.opts;
+                    t && (f.isRTL ? e.end = e.begin : e.begin = e.end);
                     if (e.begin === e.end) {
-                        switch (n = n || r.positionCaretOnClick) {
+                        switch (n = n || d.positionCaretOnClick) {
                           case "none":
                             break;
 
                           case "select":
                             e = {
                                 begin: 0,
-                                end: s.call(i).length
+                                end: s.call(f).length
                             };
                             break;
 
                           case "ignore":
-                            e.end = e.begin = u.call(i, l.call(i));
+                            e.end = e.begin = u.call(f, l.call(f));
                             break;
 
                           case "radixFocus":
-                            if (i.clicked > 1 && 0 == a.validPositions.length) break;
+                            if (f.clicked > 1 && 0 === p.validPositions.length) break;
                             if (function(e) {
-                                if ("" !== r.radixPoint && 0 !== r.digits) {
-                                    var t = a.validPositions;
-                                    if (void 0 === t[e] || t[e].input === o.getPlaceholder.call(i, e)) {
-                                        if (e < u.call(i, -1)) return !0;
-                                        var n = s.call(i).indexOf(r.radixPoint);
+                                if ("" !== d.radixPoint && 0 !== d.digits) {
+                                    var t = p.validPositions;
+                                    if (void 0 === t[e] || void 0 === t[e].input) {
+                                        if (e < u.call(f, -1)) return !0;
+                                        var n = s.call(f).indexOf(d.radixPoint);
                                         if (-1 !== n) {
-                                            for (var l = 0, c = t.length; l < c; l++) if (t[l] && n < l && t[l].input !== o.getPlaceholder.call(i, l)) return !1;
+                                            for (var i = 0, a = t.length; i < a; i++) if (t[i] && n < i && t[i].input !== o.getPlaceholder.call(f, i)) return !1;
                                             return !0;
                                         }
                                     }
                                 }
                                 return !1;
                             }(e.begin)) {
-                                var f = s.call(i).join("").indexOf(r.radixPoint);
-                                e.end = e.begin = r.numericInput ? u.call(i, f) : f;
+                                var h = s.call(f).join("").indexOf(d.radixPoint);
+                                e.end = e.begin = d.numericInput ? u.call(f, h) : h;
                                 break;
                             }
 
                           default:
-                            var p = e.begin, d = l.call(i, p, !0), h = u.call(i, -1 !== d || c.call(i, 0) ? d : -1);
-                            if (p <= h) e.end = e.begin = c.call(i, p, !1, !0) ? p : u.call(i, p); else {
-                                var m = a.validPositions[d], v = o.getTestTemplate.call(i, h, m ? m.match.locator : void 0, m), g = o.getPlaceholder.call(i, h, v.match);
-                                if ("" !== g && s.call(i)[h] !== g && !0 !== v.match.optionalQuantifier && !0 !== v.match.newBlockMarker || !c.call(i, h, r.keepStatic, !0) && v.match.def === g) {
-                                    var y = u.call(i, h);
-                                    (p >= y || p === h) && (h = y);
+                            if (i = e.begin, a = l.call(f, i, !0), i <= (r = u.call(f, -1 !== a || c.call(f, 0) ? a : -1))) e.end = e.begin = c.call(f, i, !1, !0) ? i : u.call(f, i); else {
+                                var m = p.validPositions[a], v = o.getTestTemplate.call(f, r, m ? m.match.locator : void 0, m), g = o.getPlaceholder.call(f, r, v.match);
+                                if ("" !== g && s.call(f)[r] !== g && !0 !== v.match.optionalQuantifier && !0 !== v.match.newBlockMarker || !c.call(f, r, d.keepStatic, !0) && v.match.def === g) {
+                                    var y = u.call(f, r);
+                                    (i >= y || i === r) && (r = y);
                                 }
-                                e.end = e.begin = h;
+                                e.end = e.begin = r;
                             }
                         }
                         return e;
@@ -3029,7 +3028,7 @@
                     void 0 === e && (e = -1);
                     for (var s = 0, l = o.length; s < l; s++) o[s] && (t || !0 !== o[s].generatedInput) && (s <= e && (a = s), 
                     s >= e && (r = s));
-                    return -1 === a || a == e ? r : -1 == r || e - a < r - e ? a : r;
+                    return -1 === a || a === e ? r : -1 === r || e - a < r - e ? a : r;
                 }
                 function c(e, t, n) {
                     var i = this, a = this.maskset, r = o.getTestTemplate.call(i, e).match;

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


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

@@ -9,12 +9,14 @@
 - only apply character substitution on 'human' input - #2765
 - better handle unmatching alternations - #2277
 - datetime alias
-  - add support for mmm & mmmm #2751 (WIP)
+  - add support for mmm & mmmm #2751
+  - add custom placeholder support
 - Update IP extension to support greedy option. #2749
 - Properly handle insertMode false in alternation logic.
 - Enhance resolving of the ndxInitializer to determine the alternating tests.
 
 ### Fixed
+- Cursor moves to start when there is a 0 in the decimal, How to stop this behavior? #2784
 - Unexpected character removed #2765
 - d/mm/yyyy is converted to d/m//yyyd #2394
 - Invalid state after editing datetime #2708

+ 27 - 30
lib/positioning.js

@@ -141,20 +141,19 @@ function caret(input, begin, end, notranslate, isDelete) {
 // tobe put on prototype?
 function determineLastRequiredPosition(returnDefinition) {
   const inputmask = this,
-    { maskset, dependencyLib: $ } = inputmask;
-
-  let buffer = getMaskTemplate.call(
+    { maskset, dependencyLib: $ } = inputmask,
+    lvp = getLastValidPosition.call(inputmask),
+    positions = {},
+    lvTest = maskset.validPositions[lvp],
+    buffer = getMaskTemplate.call(
       inputmask,
       true,
       getLastValidPosition.call(inputmask),
       true,
       true
-    ),
-    bl = buffer.length,
+    );
+  let bl = buffer.length,
     pos,
-    lvp = getLastValidPosition.call(inputmask),
-    positions = {},
-    lvTest = maskset.validPositions[lvp],
     ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined,
     testPos;
   for (pos = lvp + 1; pos < buffer.length; pos++) {
@@ -174,7 +173,7 @@ function determineLastRequiredPosition(returnDefinition) {
         (testPos.match.optionalQuantifier && testPos.match.newBlockMarker) ||
         (lvTestAlt &&
           ((lvTestAlt !== positions[pos].locator[lvTest.alternation] &&
-            testPos.match.static != true) ||
+            testPos.match.static !== true) ||
             (testPos.match.static === true &&
               testPos.locator[lvTest.alternation] &&
               checkAlternationMatch.call(
@@ -206,14 +205,12 @@ function determineNewCaretPosition(
 ) {
   const inputmask = this,
     { maskset, opts } = inputmask;
+  let clickPosition, lvclickPosition, lastPosition;
 
   function doRadixFocus(clickPos) {
     if (opts.radixPoint !== "" && opts.digits !== 0) {
       const vps = maskset.validPositions;
-      if (
-        vps[clickPos] === undefined ||
-        vps[clickPos].input === getPlaceholder.call(inputmask, clickPos)
-      ) {
+      if (vps[clickPos] === undefined || vps[clickPos].input === undefined) {
         if (clickPos < seekNext.call(inputmask, -1)) return true;
         const radixPos = getBuffer.call(inputmask).indexOf(opts.radixPoint);
         if (radixPos !== -1) {
@@ -255,7 +252,7 @@ function determineNewCaretPosition(
         );
         break;
       case "radixFocus":
-        if (inputmask.clicked > 1 && maskset.validPositions.length == 0) break;
+        if (inputmask.clicked > 1 && maskset.validPositions.length === 0) break;
         if (doRadixFocus(selectedCaret.begin)) {
           const radixPos = getBuffer
             .call(inputmask)
@@ -268,18 +265,18 @@ function determineNewCaretPosition(
         } // fallback to lvp
       // eslint-disable-next-line no-fallthrough
       default: // lvp:
-        var clickPosition = selectedCaret.begin,
-          lvclickPosition = getLastValidPosition.call(
-            inputmask,
-            clickPosition,
-            true
-          ),
-          lastPosition = seekNext.call(
-            inputmask,
-            lvclickPosition === -1 && !isMask.call(inputmask, 0)
-              ? -1
-              : lvclickPosition
-          );
+        clickPosition = selectedCaret.begin;
+        lvclickPosition = getLastValidPosition.call(
+          inputmask,
+          clickPosition,
+          true
+        );
+        lastPosition = seekNext.call(
+          inputmask,
+          lvclickPosition === -1 && !isMask.call(inputmask, 0)
+            ? -1
+            : lvclickPosition
+        );
 
         if (clickPosition <= lastPosition) {
           selectedCaret.end = selectedCaret.begin = !isMask.call(
@@ -359,8 +356,8 @@ function getLastValidPosition(closestTo, strict, validPositions) {
   const maskset = this.maskset;
 
   let before = -1,
-    after = -1,
-    valids = validPositions || maskset.validPositions; // for use in valhook ~ context switch
+    after = -1;
+  const valids = validPositions || maskset.validPositions; // for use in valhook ~ context switch
   if (closestTo === undefined) closestTo = -1;
   for (let psNdx = 0, vpl = valids.length; psNdx < vpl; psNdx++) {
     if (valids[psNdx] && (strict || valids[psNdx].generatedInput !== true)) {
@@ -368,9 +365,9 @@ function getLastValidPosition(closestTo, strict, validPositions) {
       if (psNdx >= closestTo) after = psNdx;
     }
   }
-  return before === -1 || before == closestTo
+  return before === -1 || before === closestTo
     ? after
-    : after == -1
+    : after === -1
     ? before
     : closestTo - before < after - closestTo
     ? before

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.9-beta.67",
+  "version": "5.0.9-beta.68",
   "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": {