@tabler/core 1.0.0-beta6 → 1.0.0-beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/demo.css +10 -11
- package/dist/css/demo.min.css +3 -3
- package/dist/css/demo.rtl.css +10 -11
- package/dist/css/demo.rtl.min.css +3 -3
- package/dist/css/tabler-flags.css +2 -2
- package/dist/css/tabler-flags.min.css +2 -2
- package/dist/css/tabler-flags.rtl.css +2 -2
- package/dist/css/tabler-flags.rtl.min.css +2 -2
- package/dist/css/tabler-payments.css +2 -2
- package/dist/css/tabler-payments.min.css +2 -2
- package/dist/css/tabler-payments.rtl.css +2 -2
- package/dist/css/tabler-payments.rtl.min.css +2 -2
- package/dist/css/tabler-vendors.css +12 -5
- package/dist/css/tabler-vendors.min.css +3 -3
- package/dist/css/tabler-vendors.rtl.css +12 -5
- package/dist/css/tabler-vendors.rtl.min.css +3 -3
- package/dist/css/tabler.css +480 -287
- package/dist/css/tabler.min.css +4 -4
- package/dist/css/tabler.rtl.css +480 -287
- package/dist/css/tabler.rtl.min.css +14 -0
- package/dist/fonts/inter-v7-latin-ext_latin-300.woff +0 -0
- package/dist/fonts/inter-v7-latin-ext_latin-300.woff2 +0 -0
- package/dist/fonts/inter-v7-latin-ext_latin-500.woff +0 -0
- package/dist/fonts/inter-v7-latin-ext_latin-500.woff2 +0 -0
- package/dist/fonts/inter-v7-latin-ext_latin-600.woff +0 -0
- package/dist/fonts/inter-v7-latin-ext_latin-600.woff2 +0 -0
- package/dist/fonts/inter-v7-latin-ext_latin-700.woff +0 -0
- package/dist/fonts/inter-v7-latin-ext_latin-700.woff2 +0 -0
- package/dist/fonts/inter-v7-latin-ext_latin-regular.woff +0 -0
- package/dist/fonts/inter-v7-latin-ext_latin-regular.woff2 +0 -0
- package/dist/js/demo.js +5 -5
- package/dist/js/demo.min.js +3 -3
- package/dist/js/tabler.esm.js +476 -233
- package/dist/js/tabler.esm.min.js +3 -3
- package/dist/js/tabler.js +476 -233
- package/dist/js/tabler.min.js +3 -3
- package/dist/libs/jsvectormap/dist/js/jsvectormap.min.js +1 -1
- package/dist/libs/jsvectormap/dist/maps/world.js +1 -1
- package/dist/libs/nouislider/dist/nouislider.min.js +1 -1
- package/package.json +16 -15
- package/src/js/demo.js +4 -5
- package/src/scss/_variables.scss +16 -15
- package/src/scss/demo/_highlight.scss +0 -1
- package/src/scss/demo.scss +2 -2
- package/src/scss/fonts/_webfonts.scss +51 -6
- package/src/scss/layout/_dark.scss +10 -1
- package/src/scss/layout/_navbar.scss +3 -1
- package/src/scss/mixins/_functions.scss +2 -2
- package/src/scss/ui/_avatars.scss +1 -5
- package/src/scss/ui/_badges.scss +7 -1
- package/src/scss/ui/_buttons.scss +46 -0
- package/src/scss/ui/_cards.scss +152 -60
- package/src/scss/ui/_dropdowns.scss +1 -0
- package/src/scss/ui/_forms.scss +2 -2
- package/src/scss/ui/_grid.scss +14 -0
- package/src/scss/ui/_markdown.scss +1 -0
- package/src/scss/ui/_nav.scss +0 -4
- package/src/scss/ui/_type.scss +1 -1
- package/src/scss/vendor/_jsvectormap.scss +7 -6
package/dist/js/tabler.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Tabler v1.0.0-
|
|
3
|
-
* @version 1.0.0-
|
|
2
|
+
* Tabler v1.0.0-beta8 (https://tabler.io)
|
|
3
|
+
* @version 1.0.0-beta8
|
|
4
4
|
* @link https://tabler.io
|
|
5
5
|
* Copyright 2018-2022 The Tabler Authors
|
|
6
6
|
* Copyright 2018-2022 codecalm.net Paweł Kuna
|
|
@@ -17,16 +17,11 @@ if (elements.length) {
|
|
|
17
17
|
|
|
18
18
|
function _typeof(obj) {
|
|
19
19
|
"@babel/helpers - typeof";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
_typeof = function (obj) {
|
|
26
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return _typeof(obj);
|
|
20
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
21
|
+
return typeof obj;
|
|
22
|
+
} : function (obj) {
|
|
23
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
24
|
+
}, _typeof(obj);
|
|
30
25
|
}
|
|
31
26
|
function _classCallCheck(instance, Constructor) {
|
|
32
27
|
if (!(instance instanceof Constructor)) {
|
|
@@ -45,6 +40,9 @@ function _defineProperties(target, props) {
|
|
|
45
40
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
46
41
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
47
42
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
43
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
44
|
+
writable: false
|
|
45
|
+
});
|
|
48
46
|
return Constructor;
|
|
49
47
|
}
|
|
50
48
|
function _defineProperty(obj, key, value) {
|
|
@@ -71,6 +69,9 @@ function _inherits(subClass, superClass) {
|
|
|
71
69
|
configurable: true
|
|
72
70
|
}
|
|
73
71
|
});
|
|
72
|
+
Object.defineProperty(subClass, "prototype", {
|
|
73
|
+
writable: false
|
|
74
|
+
});
|
|
74
75
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
75
76
|
}
|
|
76
77
|
function _getPrototypeOf(o) {
|
|
@@ -159,7 +160,7 @@ function _superPropBase(object, property) {
|
|
|
159
160
|
}
|
|
160
161
|
return object;
|
|
161
162
|
}
|
|
162
|
-
function _get(
|
|
163
|
+
function _get() {
|
|
163
164
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
164
165
|
_get = Reflect.get;
|
|
165
166
|
} else {
|
|
@@ -168,12 +169,12 @@ function _get(target, property, receiver) {
|
|
|
168
169
|
if (!base) return;
|
|
169
170
|
var desc = Object.getOwnPropertyDescriptor(base, property);
|
|
170
171
|
if (desc.get) {
|
|
171
|
-
return desc.get.call(receiver);
|
|
172
|
+
return desc.get.call(arguments.length < 3 ? target : receiver);
|
|
172
173
|
}
|
|
173
174
|
return desc.value;
|
|
174
175
|
};
|
|
175
176
|
}
|
|
176
|
-
return _get(
|
|
177
|
+
return _get.apply(this, arguments);
|
|
177
178
|
}
|
|
178
179
|
function set(target, property, value, receiver) {
|
|
179
180
|
if (typeof Reflect !== "undefined" && Reflect.set) {
|
|
@@ -260,6 +261,34 @@ function _nonIterableRest() {
|
|
|
260
261
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
261
262
|
}
|
|
262
263
|
|
|
264
|
+
var ChangeDetails = function () {
|
|
265
|
+
function ChangeDetails(details) {
|
|
266
|
+
_classCallCheck(this, ChangeDetails);
|
|
267
|
+
Object.assign(this, {
|
|
268
|
+
inserted: '',
|
|
269
|
+
rawInserted: '',
|
|
270
|
+
skip: false,
|
|
271
|
+
tailShift: 0
|
|
272
|
+
}, details);
|
|
273
|
+
}
|
|
274
|
+
_createClass(ChangeDetails, [{
|
|
275
|
+
key: "aggregate",
|
|
276
|
+
value: function aggregate(details) {
|
|
277
|
+
this.rawInserted += details.rawInserted;
|
|
278
|
+
this.skip = this.skip || details.skip;
|
|
279
|
+
this.inserted += details.inserted;
|
|
280
|
+
this.tailShift += details.tailShift;
|
|
281
|
+
return this;
|
|
282
|
+
}
|
|
283
|
+
}, {
|
|
284
|
+
key: "offset",
|
|
285
|
+
get: function get() {
|
|
286
|
+
return this.tailShift + this.inserted.length;
|
|
287
|
+
}
|
|
288
|
+
}]);
|
|
289
|
+
return ChangeDetails;
|
|
290
|
+
}();
|
|
291
|
+
|
|
263
292
|
function isString(str) {
|
|
264
293
|
return typeof str === 'string' || str instanceof String;
|
|
265
294
|
}
|
|
@@ -283,6 +312,9 @@ function forceDirection(direction) {
|
|
|
283
312
|
function escapeRegExp(str) {
|
|
284
313
|
return str.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
|
|
285
314
|
}
|
|
315
|
+
function normalizePrepare(prep) {
|
|
316
|
+
return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
|
|
317
|
+
}
|
|
286
318
|
function objectIncludes(b, a) {
|
|
287
319
|
if (a === b) return true;
|
|
288
320
|
var arrA = Array.isArray(a),
|
|
@@ -370,40 +402,13 @@ var ActionDetails = function () {
|
|
|
370
402
|
key: "removeDirection",
|
|
371
403
|
get: function get() {
|
|
372
404
|
if (!this.removedCount || this.insertedCount) return DIRECTION.NONE;
|
|
373
|
-
return this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos
|
|
405
|
+
return (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) &&
|
|
406
|
+
this.oldSelection.end === this.oldSelection.start ? DIRECTION.RIGHT : DIRECTION.LEFT;
|
|
374
407
|
}
|
|
375
408
|
}]);
|
|
376
409
|
return ActionDetails;
|
|
377
410
|
}();
|
|
378
411
|
|
|
379
|
-
var ChangeDetails = function () {
|
|
380
|
-
function ChangeDetails(details) {
|
|
381
|
-
_classCallCheck(this, ChangeDetails);
|
|
382
|
-
Object.assign(this, {
|
|
383
|
-
inserted: '',
|
|
384
|
-
rawInserted: '',
|
|
385
|
-
skip: false,
|
|
386
|
-
tailShift: 0
|
|
387
|
-
}, details);
|
|
388
|
-
}
|
|
389
|
-
_createClass(ChangeDetails, [{
|
|
390
|
-
key: "aggregate",
|
|
391
|
-
value: function aggregate(details) {
|
|
392
|
-
this.rawInserted += details.rawInserted;
|
|
393
|
-
this.skip = this.skip || details.skip;
|
|
394
|
-
this.inserted += details.inserted;
|
|
395
|
-
this.tailShift += details.tailShift;
|
|
396
|
-
return this;
|
|
397
|
-
}
|
|
398
|
-
}, {
|
|
399
|
-
key: "offset",
|
|
400
|
-
get: function get() {
|
|
401
|
-
return this.tailShift + this.inserted.length;
|
|
402
|
-
}
|
|
403
|
-
}]);
|
|
404
|
-
return ChangeDetails;
|
|
405
|
-
}();
|
|
406
|
-
|
|
407
412
|
var ContinuousTailDetails = function () {
|
|
408
413
|
function ContinuousTailDetails() {
|
|
409
414
|
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
@@ -444,13 +449,21 @@ var ContinuousTailDetails = function () {
|
|
|
444
449
|
Object.assign(this, state);
|
|
445
450
|
}
|
|
446
451
|
}, {
|
|
447
|
-
key: "
|
|
448
|
-
value: function
|
|
449
|
-
if (this.
|
|
452
|
+
key: "unshift",
|
|
453
|
+
value: function unshift(beforePos) {
|
|
454
|
+
if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
|
|
450
455
|
var shiftChar = this.value[0];
|
|
451
456
|
this.value = this.value.slice(1);
|
|
452
457
|
return shiftChar;
|
|
453
458
|
}
|
|
459
|
+
}, {
|
|
460
|
+
key: "shift",
|
|
461
|
+
value: function shift() {
|
|
462
|
+
if (!this.value.length) return '';
|
|
463
|
+
var shiftChar = this.value[this.value.length - 1];
|
|
464
|
+
this.value = this.value.slice(0, -1);
|
|
465
|
+
return shiftChar;
|
|
466
|
+
}
|
|
454
467
|
}]);
|
|
455
468
|
return ContinuousTailDetails;
|
|
456
469
|
}();
|
|
@@ -548,6 +561,11 @@ var Masked = function () {
|
|
|
548
561
|
get: function get() {
|
|
549
562
|
return true;
|
|
550
563
|
}
|
|
564
|
+
}, {
|
|
565
|
+
key: "isFilled",
|
|
566
|
+
get: function get() {
|
|
567
|
+
return this.isComplete;
|
|
568
|
+
}
|
|
551
569
|
}, {
|
|
552
570
|
key: "nearestInputPos",
|
|
553
571
|
value: function nearestInputPos(cursorPos, direction) {
|
|
@@ -589,18 +607,30 @@ var Masked = function () {
|
|
|
589
607
|
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
590
608
|
var checkTail = arguments.length > 2 ? arguments[2] : undefined;
|
|
591
609
|
var consistentState = this.state;
|
|
592
|
-
var details
|
|
610
|
+
var details;
|
|
611
|
+
var _normalizePrepare = normalizePrepare(this.doPrepare(ch, flags));
|
|
612
|
+
var _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2);
|
|
613
|
+
ch = _normalizePrepare2[0];
|
|
614
|
+
details = _normalizePrepare2[1];
|
|
615
|
+
details = details.aggregate(this._appendCharRaw(ch, flags));
|
|
593
616
|
if (details.inserted) {
|
|
594
617
|
var consistentTail;
|
|
595
618
|
var appended = this.doValidate(flags) !== false;
|
|
596
619
|
if (appended && checkTail != null) {
|
|
597
620
|
var beforeTailState = this.state;
|
|
598
|
-
if (this.overwrite) {
|
|
621
|
+
if (this.overwrite === true) {
|
|
599
622
|
consistentTail = checkTail.state;
|
|
600
|
-
checkTail.
|
|
623
|
+
checkTail.unshift(this.value.length);
|
|
601
624
|
}
|
|
602
625
|
var tailDetails = this.appendTail(checkTail);
|
|
603
626
|
appended = tailDetails.rawInserted === checkTail.toString();
|
|
627
|
+
if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
|
|
628
|
+
this.state = beforeTailState;
|
|
629
|
+
consistentTail = checkTail.state;
|
|
630
|
+
checkTail.shift();
|
|
631
|
+
tailDetails = this.appendTail(checkTail);
|
|
632
|
+
appended = tailDetails.rawInserted === checkTail.toString();
|
|
633
|
+
}
|
|
604
634
|
if (appended && tailDetails.inserted) this.state = beforeTailState;
|
|
605
635
|
}
|
|
606
636
|
if (!appended) {
|
|
@@ -616,6 +646,11 @@ var Masked = function () {
|
|
|
616
646
|
value: function _appendPlaceholder() {
|
|
617
647
|
return new ChangeDetails();
|
|
618
648
|
}
|
|
649
|
+
}, {
|
|
650
|
+
key: "_appendEager",
|
|
651
|
+
value: function _appendEager() {
|
|
652
|
+
return new ChangeDetails();
|
|
653
|
+
}
|
|
619
654
|
}, {
|
|
620
655
|
key: "append",
|
|
621
656
|
value: function append(str, flags, tail) {
|
|
@@ -629,6 +664,9 @@ var Masked = function () {
|
|
|
629
664
|
if (checkTail != null) {
|
|
630
665
|
details.tailShift += this.appendTail(checkTail).tailShift;
|
|
631
666
|
}
|
|
667
|
+
if (this.eager && flags !== null && flags !== void 0 && flags.input && str) {
|
|
668
|
+
details.aggregate(this._appendEager());
|
|
669
|
+
}
|
|
632
670
|
return details;
|
|
633
671
|
}
|
|
634
672
|
}, {
|
|
@@ -696,13 +734,37 @@ var Masked = function () {
|
|
|
696
734
|
value: function splice(start, deleteCount, inserted, removeDirection) {
|
|
697
735
|
var tailPos = start + deleteCount;
|
|
698
736
|
var tail = this.extractTail(tailPos);
|
|
699
|
-
var
|
|
700
|
-
|
|
737
|
+
var oldRawValue;
|
|
738
|
+
if (this.eager) {
|
|
739
|
+
removeDirection = forceDirection(removeDirection);
|
|
740
|
+
oldRawValue = this.extractInput(0, tailPos, {
|
|
741
|
+
raw: true
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
var startChangePos = this.nearestInputPos(start, deleteCount > 1 && start !== 0 && !this.eager ? DIRECTION.NONE : removeDirection);
|
|
745
|
+
var details = new ChangeDetails({
|
|
701
746
|
tailShift: startChangePos - start
|
|
702
|
-
}).aggregate(this.remove(startChangePos))
|
|
747
|
+
}).aggregate(this.remove(startChangePos));
|
|
748
|
+
if (this.eager && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
|
|
749
|
+
if (removeDirection === DIRECTION.FORCE_LEFT) {
|
|
750
|
+
var valLength;
|
|
751
|
+
while (oldRawValue === this.rawInputValue && (valLength = this.value.length)) {
|
|
752
|
+
details.aggregate(new ChangeDetails({
|
|
753
|
+
tailShift: -1
|
|
754
|
+
})).aggregate(this.remove(valLength - 1));
|
|
755
|
+
}
|
|
756
|
+
} else if (removeDirection === DIRECTION.FORCE_RIGHT) {
|
|
757
|
+
tail.unshift();
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return details.aggregate(this.append(inserted, {
|
|
703
761
|
input: true
|
|
704
762
|
}, tail));
|
|
705
|
-
|
|
763
|
+
}
|
|
764
|
+
}, {
|
|
765
|
+
key: "maskEquals",
|
|
766
|
+
value: function maskEquals(mask) {
|
|
767
|
+
return this.mask === mask;
|
|
706
768
|
}
|
|
707
769
|
}]);
|
|
708
770
|
return Masked;
|
|
@@ -727,8 +789,8 @@ function maskedClass(mask) {
|
|
|
727
789
|
if (mask instanceof Number || typeof mask === 'number' || mask === Number) return IMask.MaskedNumber;
|
|
728
790
|
if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
|
|
729
791
|
if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
|
|
730
|
-
if (mask instanceof Function) return IMask.MaskedFunction;
|
|
731
792
|
if (mask instanceof IMask.Masked) return mask.constructor;
|
|
793
|
+
if (mask instanceof Function) return IMask.MaskedFunction;
|
|
732
794
|
console.warn('Mask not found for mask', mask);
|
|
733
795
|
return IMask.Masked;
|
|
734
796
|
}
|
|
@@ -762,7 +824,7 @@ var PatternInputDefinition = function () {
|
|
|
762
824
|
_createClass(PatternInputDefinition, [{
|
|
763
825
|
key: "reset",
|
|
764
826
|
value: function reset() {
|
|
765
|
-
this.
|
|
827
|
+
this.isFilled = false;
|
|
766
828
|
this.masked.reset();
|
|
767
829
|
}
|
|
768
830
|
}, {
|
|
@@ -771,7 +833,7 @@ var PatternInputDefinition = function () {
|
|
|
771
833
|
var fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
772
834
|
var toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
773
835
|
if (fromPos === 0 && toPos >= 1) {
|
|
774
|
-
this.
|
|
836
|
+
this.isFilled = false;
|
|
775
837
|
return this.masked.remove(fromPos, toPos);
|
|
776
838
|
}
|
|
777
839
|
return new ChangeDetails();
|
|
@@ -779,7 +841,7 @@ var PatternInputDefinition = function () {
|
|
|
779
841
|
}, {
|
|
780
842
|
key: "value",
|
|
781
843
|
get: function get() {
|
|
782
|
-
return this.masked.value || (this.
|
|
844
|
+
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
|
|
783
845
|
}
|
|
784
846
|
}, {
|
|
785
847
|
key: "unmaskedValue",
|
|
@@ -793,11 +855,11 @@ var PatternInputDefinition = function () {
|
|
|
793
855
|
}
|
|
794
856
|
}, {
|
|
795
857
|
key: "_appendChar",
|
|
796
|
-
value: function _appendChar(
|
|
858
|
+
value: function _appendChar(ch) {
|
|
797
859
|
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
798
|
-
if (this.
|
|
860
|
+
if (this.isFilled) return new ChangeDetails();
|
|
799
861
|
var state = this.masked.state;
|
|
800
|
-
var details = this.masked._appendChar(
|
|
862
|
+
var details = this.masked._appendChar(ch, flags);
|
|
801
863
|
if (details.inserted && this.doValidate(flags) === false) {
|
|
802
864
|
details.inserted = details.rawInserted = '';
|
|
803
865
|
this.masked.state = state;
|
|
@@ -806,7 +868,7 @@ var PatternInputDefinition = function () {
|
|
|
806
868
|
details.inserted = this.placeholderChar;
|
|
807
869
|
}
|
|
808
870
|
details.skip = !details.inserted && !this.isOptional;
|
|
809
|
-
this.
|
|
871
|
+
this.isFilled = Boolean(details.inserted);
|
|
810
872
|
return details;
|
|
811
873
|
}
|
|
812
874
|
}, {
|
|
@@ -819,11 +881,16 @@ var PatternInputDefinition = function () {
|
|
|
819
881
|
key: "_appendPlaceholder",
|
|
820
882
|
value: function _appendPlaceholder() {
|
|
821
883
|
var details = new ChangeDetails();
|
|
822
|
-
if (this.
|
|
823
|
-
this.
|
|
884
|
+
if (this.isFilled || this.isOptional) return details;
|
|
885
|
+
this.isFilled = true;
|
|
824
886
|
details.inserted = this.placeholderChar;
|
|
825
887
|
return details;
|
|
826
888
|
}
|
|
889
|
+
}, {
|
|
890
|
+
key: "_appendEager",
|
|
891
|
+
value: function _appendEager() {
|
|
892
|
+
return new ChangeDetails();
|
|
893
|
+
}
|
|
827
894
|
}, {
|
|
828
895
|
key: "extractTail",
|
|
829
896
|
value: function extractTail() {
|
|
@@ -879,12 +946,12 @@ var PatternInputDefinition = function () {
|
|
|
879
946
|
get: function get() {
|
|
880
947
|
return {
|
|
881
948
|
masked: this.masked.state,
|
|
882
|
-
|
|
949
|
+
isFilled: this.isFilled
|
|
883
950
|
};
|
|
884
951
|
},
|
|
885
952
|
set: function set(state) {
|
|
886
953
|
this.masked.state = state.masked;
|
|
887
|
-
this.
|
|
954
|
+
this.isFilled = state.isFilled;
|
|
888
955
|
}
|
|
889
956
|
}]);
|
|
890
957
|
return PatternInputDefinition;
|
|
@@ -895,6 +962,7 @@ var PatternFixedDefinition = function () {
|
|
|
895
962
|
_classCallCheck(this, PatternFixedDefinition);
|
|
896
963
|
Object.assign(this, opts);
|
|
897
964
|
this._value = '';
|
|
965
|
+
this.isFixed = true;
|
|
898
966
|
}
|
|
899
967
|
_createClass(PatternFixedDefinition, [{
|
|
900
968
|
key: "value",
|
|
@@ -951,19 +1019,29 @@ var PatternFixedDefinition = function () {
|
|
|
951
1019
|
get: function get() {
|
|
952
1020
|
return true;
|
|
953
1021
|
}
|
|
1022
|
+
}, {
|
|
1023
|
+
key: "isFilled",
|
|
1024
|
+
get: function get() {
|
|
1025
|
+
return Boolean(this._value);
|
|
1026
|
+
}
|
|
954
1027
|
}, {
|
|
955
1028
|
key: "_appendChar",
|
|
956
|
-
value: function _appendChar(
|
|
1029
|
+
value: function _appendChar(ch) {
|
|
957
1030
|
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
958
1031
|
var details = new ChangeDetails();
|
|
959
1032
|
if (this._value) return details;
|
|
960
|
-
var appended = this.char ===
|
|
961
|
-
var isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && !flags.tail;
|
|
1033
|
+
var appended = this.char === ch;
|
|
1034
|
+
var isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && !this.eager && !flags.tail;
|
|
962
1035
|
if (isResolved) details.rawInserted = this.char;
|
|
963
1036
|
this._value = details.inserted = this.char;
|
|
964
1037
|
this._isRawInput = isResolved && (flags.raw || flags.input);
|
|
965
1038
|
return details;
|
|
966
1039
|
}
|
|
1040
|
+
}, {
|
|
1041
|
+
key: "_appendEager",
|
|
1042
|
+
value: function _appendEager() {
|
|
1043
|
+
return this._appendChar(this.char);
|
|
1044
|
+
}
|
|
967
1045
|
}, {
|
|
968
1046
|
key: "_appendPlaceholder",
|
|
969
1047
|
value: function _appendPlaceholder() {
|
|
@@ -987,7 +1065,7 @@ var PatternFixedDefinition = function () {
|
|
|
987
1065
|
}, {
|
|
988
1066
|
key: "append",
|
|
989
1067
|
value: function append(str, flags, tail) {
|
|
990
|
-
var details = this._appendChar(str, flags);
|
|
1068
|
+
var details = this._appendChar(str[0], flags);
|
|
991
1069
|
if (tail != null) {
|
|
992
1070
|
details.tailShift += this.appendTail(tail).tailShift;
|
|
993
1071
|
}
|
|
@@ -1031,7 +1109,8 @@ var ChunksTailDetails = function () {
|
|
|
1031
1109
|
if (!String(tailChunk)) return;
|
|
1032
1110
|
if (isString(tailChunk)) tailChunk = new ContinuousTailDetails(String(tailChunk));
|
|
1033
1111
|
var lastChunk = this.chunks[this.chunks.length - 1];
|
|
1034
|
-
var extendLast = lastChunk && (
|
|
1112
|
+
var extendLast = lastChunk && (
|
|
1113
|
+
lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
|
|
1035
1114
|
tailChunk.from === lastChunk.from + lastChunk.toString().length;
|
|
1036
1115
|
if (tailChunk instanceof ContinuousTailDetails) {
|
|
1037
1116
|
if (extendLast) {
|
|
@@ -1067,7 +1146,8 @@ var ChunksTailDetails = function () {
|
|
|
1067
1146
|
var lastBlockIter = masked._mapPosToBlock(masked.value.length);
|
|
1068
1147
|
var stop = chunk.stop;
|
|
1069
1148
|
var chunkBlock = void 0;
|
|
1070
|
-
if (stop != null && (
|
|
1149
|
+
if (stop != null && (
|
|
1150
|
+
!lastBlockIter || lastBlockIter.index <= stop)) {
|
|
1071
1151
|
if (chunk instanceof ChunksTailDetails ||
|
|
1072
1152
|
masked._stops.indexOf(stop) >= 0) {
|
|
1073
1153
|
details.aggregate(masked._appendPlaceholder(stop));
|
|
@@ -1114,14 +1194,14 @@ var ChunksTailDetails = function () {
|
|
|
1114
1194
|
});
|
|
1115
1195
|
}
|
|
1116
1196
|
}, {
|
|
1117
|
-
key: "
|
|
1118
|
-
value: function
|
|
1119
|
-
if (this.
|
|
1120
|
-
var chunkShiftPos =
|
|
1197
|
+
key: "unshift",
|
|
1198
|
+
value: function unshift(beforePos) {
|
|
1199
|
+
if (!this.chunks.length || beforePos != null && this.from >= beforePos) return '';
|
|
1200
|
+
var chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
|
|
1121
1201
|
var ci = 0;
|
|
1122
1202
|
while (ci < this.chunks.length) {
|
|
1123
1203
|
var chunk = this.chunks[ci];
|
|
1124
|
-
var shiftChar = chunk.
|
|
1204
|
+
var shiftChar = chunk.unshift(chunkShiftPos);
|
|
1125
1205
|
if (chunk.toString()) {
|
|
1126
1206
|
if (!shiftChar) break;
|
|
1127
1207
|
++ci;
|
|
@@ -1132,10 +1212,178 @@ var ChunksTailDetails = function () {
|
|
|
1132
1212
|
}
|
|
1133
1213
|
return '';
|
|
1134
1214
|
}
|
|
1215
|
+
}, {
|
|
1216
|
+
key: "shift",
|
|
1217
|
+
value: function shift() {
|
|
1218
|
+
if (!this.chunks.length) return '';
|
|
1219
|
+
var ci = this.chunks.length - 1;
|
|
1220
|
+
while (0 <= ci) {
|
|
1221
|
+
var chunk = this.chunks[ci];
|
|
1222
|
+
var shiftChar = chunk.shift();
|
|
1223
|
+
if (chunk.toString()) {
|
|
1224
|
+
if (!shiftChar) break;
|
|
1225
|
+
--ci;
|
|
1226
|
+
} else {
|
|
1227
|
+
this.chunks.splice(ci, 1);
|
|
1228
|
+
}
|
|
1229
|
+
if (shiftChar) return shiftChar;
|
|
1230
|
+
}
|
|
1231
|
+
return '';
|
|
1232
|
+
}
|
|
1135
1233
|
}]);
|
|
1136
1234
|
return ChunksTailDetails;
|
|
1137
1235
|
}();
|
|
1138
1236
|
|
|
1237
|
+
var PatternCursor = function () {
|
|
1238
|
+
function PatternCursor(masked, pos) {
|
|
1239
|
+
_classCallCheck(this, PatternCursor);
|
|
1240
|
+
this.masked = masked;
|
|
1241
|
+
this._log = [];
|
|
1242
|
+
var _ref = masked._mapPosToBlock(pos) || (pos < 0 ?
|
|
1243
|
+
{
|
|
1244
|
+
index: 0,
|
|
1245
|
+
offset: 0
|
|
1246
|
+
} :
|
|
1247
|
+
{
|
|
1248
|
+
index: this.masked._blocks.length,
|
|
1249
|
+
offset: 0
|
|
1250
|
+
}),
|
|
1251
|
+
offset = _ref.offset,
|
|
1252
|
+
index = _ref.index;
|
|
1253
|
+
this.offset = offset;
|
|
1254
|
+
this.index = index;
|
|
1255
|
+
this.ok = false;
|
|
1256
|
+
}
|
|
1257
|
+
_createClass(PatternCursor, [{
|
|
1258
|
+
key: "block",
|
|
1259
|
+
get: function get() {
|
|
1260
|
+
return this.masked._blocks[this.index];
|
|
1261
|
+
}
|
|
1262
|
+
}, {
|
|
1263
|
+
key: "pos",
|
|
1264
|
+
get: function get() {
|
|
1265
|
+
return this.masked._blockStartPos(this.index) + this.offset;
|
|
1266
|
+
}
|
|
1267
|
+
}, {
|
|
1268
|
+
key: "state",
|
|
1269
|
+
get: function get() {
|
|
1270
|
+
return {
|
|
1271
|
+
index: this.index,
|
|
1272
|
+
offset: this.offset,
|
|
1273
|
+
ok: this.ok
|
|
1274
|
+
};
|
|
1275
|
+
},
|
|
1276
|
+
set: function set(s) {
|
|
1277
|
+
Object.assign(this, s);
|
|
1278
|
+
}
|
|
1279
|
+
}, {
|
|
1280
|
+
key: "pushState",
|
|
1281
|
+
value: function pushState() {
|
|
1282
|
+
this._log.push(this.state);
|
|
1283
|
+
}
|
|
1284
|
+
}, {
|
|
1285
|
+
key: "popState",
|
|
1286
|
+
value: function popState() {
|
|
1287
|
+
var s = this._log.pop();
|
|
1288
|
+
this.state = s;
|
|
1289
|
+
return s;
|
|
1290
|
+
}
|
|
1291
|
+
}, {
|
|
1292
|
+
key: "bindBlock",
|
|
1293
|
+
value: function bindBlock() {
|
|
1294
|
+
if (this.block) return;
|
|
1295
|
+
if (this.index < 0) {
|
|
1296
|
+
this.index = 0;
|
|
1297
|
+
this.offset = 0;
|
|
1298
|
+
}
|
|
1299
|
+
if (this.index >= this.masked._blocks.length) {
|
|
1300
|
+
this.index = this.masked._blocks.length - 1;
|
|
1301
|
+
this.offset = this.block.value.length;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}, {
|
|
1305
|
+
key: "_pushLeft",
|
|
1306
|
+
value: function _pushLeft(fn) {
|
|
1307
|
+
this.pushState();
|
|
1308
|
+
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) === null || _this$block === void 0 ? void 0 : _this$block.value.length) || 0) {
|
|
1309
|
+
var _this$block;
|
|
1310
|
+
if (fn()) return this.ok = true;
|
|
1311
|
+
}
|
|
1312
|
+
return this.ok = false;
|
|
1313
|
+
}
|
|
1314
|
+
}, {
|
|
1315
|
+
key: "_pushRight",
|
|
1316
|
+
value: function _pushRight(fn) {
|
|
1317
|
+
this.pushState();
|
|
1318
|
+
for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {
|
|
1319
|
+
if (fn()) return this.ok = true;
|
|
1320
|
+
}
|
|
1321
|
+
return this.ok = false;
|
|
1322
|
+
}
|
|
1323
|
+
}, {
|
|
1324
|
+
key: "pushLeftBeforeFilled",
|
|
1325
|
+
value: function pushLeftBeforeFilled() {
|
|
1326
|
+
var _this = this;
|
|
1327
|
+
return this._pushLeft(function () {
|
|
1328
|
+
if (_this.block.isFixed || !_this.block.value) return;
|
|
1329
|
+
_this.offset = _this.block.nearestInputPos(_this.offset, DIRECTION.FORCE_LEFT);
|
|
1330
|
+
if (_this.offset !== 0) return true;
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
}, {
|
|
1334
|
+
key: "pushLeftBeforeInput",
|
|
1335
|
+
value: function pushLeftBeforeInput() {
|
|
1336
|
+
var _this2 = this;
|
|
1337
|
+
return this._pushLeft(function () {
|
|
1338
|
+
if (_this2.block.isFixed) return;
|
|
1339
|
+
_this2.offset = _this2.block.nearestInputPos(_this2.offset, DIRECTION.LEFT);
|
|
1340
|
+
return true;
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
}, {
|
|
1344
|
+
key: "pushLeftBeforeRequired",
|
|
1345
|
+
value: function pushLeftBeforeRequired() {
|
|
1346
|
+
var _this3 = this;
|
|
1347
|
+
return this._pushLeft(function () {
|
|
1348
|
+
if (_this3.block.isFixed || _this3.block.isOptional && !_this3.block.value) return;
|
|
1349
|
+
_this3.offset = _this3.block.nearestInputPos(_this3.offset, DIRECTION.LEFT);
|
|
1350
|
+
return true;
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
}, {
|
|
1354
|
+
key: "pushRightBeforeFilled",
|
|
1355
|
+
value: function pushRightBeforeFilled() {
|
|
1356
|
+
var _this4 = this;
|
|
1357
|
+
return this._pushRight(function () {
|
|
1358
|
+
if (_this4.block.isFixed || !_this4.block.value) return;
|
|
1359
|
+
_this4.offset = _this4.block.nearestInputPos(_this4.offset, DIRECTION.FORCE_RIGHT);
|
|
1360
|
+
if (_this4.offset !== _this4.block.value.length) return true;
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
}, {
|
|
1364
|
+
key: "pushRightBeforeInput",
|
|
1365
|
+
value: function pushRightBeforeInput() {
|
|
1366
|
+
var _this5 = this;
|
|
1367
|
+
return this._pushRight(function () {
|
|
1368
|
+
if (_this5.block.isFixed) return;
|
|
1369
|
+
_this5.offset = _this5.block.nearestInputPos(_this5.offset, DIRECTION.NONE);
|
|
1370
|
+
return true;
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
}, {
|
|
1374
|
+
key: "pushRightBeforeRequired",
|
|
1375
|
+
value: function pushRightBeforeRequired() {
|
|
1376
|
+
var _this6 = this;
|
|
1377
|
+
return this._pushRight(function () {
|
|
1378
|
+
if (_this6.block.isFixed || _this6.block.isOptional && !_this6.block.value) return;
|
|
1379
|
+
_this6.offset = _this6.block.nearestInputPos(_this6.offset, DIRECTION.NONE);
|
|
1380
|
+
return true;
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
}]);
|
|
1384
|
+
return PatternCursor;
|
|
1385
|
+
}();
|
|
1386
|
+
|
|
1139
1387
|
var MaskedRegExp = function (_Masked) {
|
|
1140
1388
|
_inherits(MaskedRegExp, _Masked);
|
|
1141
1389
|
var _super = _createSuper(MaskedRegExp);
|
|
@@ -1202,6 +1450,7 @@ var MaskedPattern = function (_Masked) {
|
|
|
1202
1450
|
var maskedBlock = createMask(Object.assign({
|
|
1203
1451
|
parent: _this,
|
|
1204
1452
|
lazy: _this.lazy,
|
|
1453
|
+
eager: _this.eager,
|
|
1205
1454
|
placeholderChar: _this.placeholderChar,
|
|
1206
1455
|
overwrite: _this.overwrite
|
|
1207
1456
|
}, _this.blocks[bName]));
|
|
@@ -1217,7 +1466,7 @@ var MaskedPattern = function (_Masked) {
|
|
|
1217
1466
|
if (_ret === "continue") continue;
|
|
1218
1467
|
}
|
|
1219
1468
|
var char = pattern[i];
|
|
1220
|
-
var
|
|
1469
|
+
var isInput = (char in defs);
|
|
1221
1470
|
if (char === MaskedPattern.STOP_CHAR) {
|
|
1222
1471
|
this._stops.push(this._blocks.length);
|
|
1223
1472
|
continue;
|
|
@@ -1234,16 +1483,18 @@ var MaskedPattern = function (_Masked) {
|
|
|
1234
1483
|
++i;
|
|
1235
1484
|
char = pattern[i];
|
|
1236
1485
|
if (!char) break;
|
|
1237
|
-
|
|
1486
|
+
isInput = false;
|
|
1238
1487
|
}
|
|
1239
|
-
var def =
|
|
1488
|
+
var def = isInput ? new PatternInputDefinition({
|
|
1240
1489
|
parent: this,
|
|
1241
1490
|
lazy: this.lazy,
|
|
1491
|
+
eager: this.eager,
|
|
1242
1492
|
placeholderChar: this.placeholderChar,
|
|
1243
1493
|
mask: defs[char],
|
|
1244
1494
|
isOptional: optionalBlock
|
|
1245
1495
|
}) : new PatternFixedDefinition({
|
|
1246
1496
|
char: char,
|
|
1497
|
+
eager: this.eager,
|
|
1247
1498
|
isUnmasking: unmaskingBlock
|
|
1248
1499
|
});
|
|
1249
1500
|
this._blocks.push(def);
|
|
@@ -1281,6 +1532,27 @@ var MaskedPattern = function (_Masked) {
|
|
|
1281
1532
|
return b.isComplete;
|
|
1282
1533
|
});
|
|
1283
1534
|
}
|
|
1535
|
+
}, {
|
|
1536
|
+
key: "isFilled",
|
|
1537
|
+
get: function get() {
|
|
1538
|
+
return this._blocks.every(function (b) {
|
|
1539
|
+
return b.isFilled;
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
}, {
|
|
1543
|
+
key: "isFixed",
|
|
1544
|
+
get: function get() {
|
|
1545
|
+
return this._blocks.every(function (b) {
|
|
1546
|
+
return b.isFixed;
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
}, {
|
|
1550
|
+
key: "isOptional",
|
|
1551
|
+
get: function get() {
|
|
1552
|
+
return this._blocks.every(function (b) {
|
|
1553
|
+
return b.isOptional;
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1284
1556
|
}, {
|
|
1285
1557
|
key: "doCommit",
|
|
1286
1558
|
value: function doCommit() {
|
|
@@ -1314,6 +1586,21 @@ var MaskedPattern = function (_Masked) {
|
|
|
1314
1586
|
value: function appendTail(tail) {
|
|
1315
1587
|
return _get(_getPrototypeOf(MaskedPattern.prototype), "appendTail", this).call(this, tail).aggregate(this._appendPlaceholder());
|
|
1316
1588
|
}
|
|
1589
|
+
}, {
|
|
1590
|
+
key: "_appendEager",
|
|
1591
|
+
value: function _appendEager() {
|
|
1592
|
+
var _this$_mapPosToBlock;
|
|
1593
|
+
var details = new ChangeDetails();
|
|
1594
|
+
var startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.value.length)) === null || _this$_mapPosToBlock === void 0 ? void 0 : _this$_mapPosToBlock.index;
|
|
1595
|
+
if (startBlockIndex == null) return details;
|
|
1596
|
+
if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
|
|
1597
|
+
for (var bi = startBlockIndex; bi < this._blocks.length; ++bi) {
|
|
1598
|
+
var d = this._blocks[bi]._appendEager();
|
|
1599
|
+
if (!d.inserted) break;
|
|
1600
|
+
details.aggregate(d);
|
|
1601
|
+
}
|
|
1602
|
+
return details;
|
|
1603
|
+
}
|
|
1317
1604
|
}, {
|
|
1318
1605
|
key: "_appendCharRaw",
|
|
1319
1606
|
value: function _appendCharRaw(ch) {
|
|
@@ -1322,9 +1609,12 @@ var MaskedPattern = function (_Masked) {
|
|
|
1322
1609
|
var details = new ChangeDetails();
|
|
1323
1610
|
if (!blockIter) return details;
|
|
1324
1611
|
for (var bi = blockIter.index;; ++bi) {
|
|
1612
|
+
var _flags$_beforeTailSta;
|
|
1325
1613
|
var _block = this._blocks[bi];
|
|
1326
1614
|
if (!_block) break;
|
|
1327
|
-
var blockDetails = _block._appendChar(ch, flags
|
|
1615
|
+
var blockDetails = _block._appendChar(ch, Object.assign({}, flags, {
|
|
1616
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : _flags$_beforeTailSta._blocks[bi]
|
|
1617
|
+
}));
|
|
1328
1618
|
var skip = blockDetails.skip;
|
|
1329
1619
|
details.aggregate(blockDetails);
|
|
1330
1620
|
if (skip || blockDetails.rawInserted) break;
|
|
@@ -1449,136 +1739,49 @@ var MaskedPattern = function (_Masked) {
|
|
|
1449
1739
|
key: "nearestInputPos",
|
|
1450
1740
|
value: function nearestInputPos(cursorPos) {
|
|
1451
1741
|
var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
offset: 0
|
|
1455
|
-
};
|
|
1456
|
-
var beginBlockOffset = beginBlockData.offset,
|
|
1457
|
-
beginBlockIndex = beginBlockData.index;
|
|
1458
|
-
var beginBlock = this._blocks[beginBlockIndex];
|
|
1459
|
-
if (!beginBlock) return cursorPos;
|
|
1460
|
-
var beginBlockCursorPos = beginBlockOffset;
|
|
1461
|
-
if (beginBlockCursorPos !== 0 && beginBlockCursorPos < beginBlock.value.length) {
|
|
1462
|
-
beginBlockCursorPos = beginBlock.nearestInputPos(beginBlockOffset, forceDirection(direction));
|
|
1463
|
-
}
|
|
1464
|
-
var cursorAtRight = beginBlockCursorPos === beginBlock.value.length;
|
|
1465
|
-
var cursorAtLeft = beginBlockCursorPos === 0;
|
|
1466
|
-
if (!cursorAtLeft && !cursorAtRight) return this._blockStartPos(beginBlockIndex) + beginBlockCursorPos;
|
|
1467
|
-
var searchBlockIndex = cursorAtRight ? beginBlockIndex + 1 : beginBlockIndex;
|
|
1742
|
+
if (!this._blocks.length) return 0;
|
|
1743
|
+
var cursor = new PatternCursor(this, cursorPos);
|
|
1468
1744
|
if (direction === DIRECTION.NONE) {
|
|
1469
|
-
if (
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
if (!blockAtLeft.value.length || blockInputPos !== blockAtLeft.value.length) {
|
|
1474
|
-
return this._blockStartPos(searchBlockIndex);
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
var firstInputAtRight = searchBlockIndex;
|
|
1478
|
-
for (var bi = firstInputAtRight; bi < this._blocks.length; ++bi) {
|
|
1479
|
-
var blockAtRight = this._blocks[bi];
|
|
1480
|
-
var _blockInputPos = blockAtRight.nearestInputPos(0, DIRECTION.NONE);
|
|
1481
|
-
if (!blockAtRight.value.length || _blockInputPos !== blockAtRight.value.length) {
|
|
1482
|
-
return this._blockStartPos(bi) + _blockInputPos;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
for (var _bi = searchBlockIndex - 1; _bi >= 0; --_bi) {
|
|
1486
|
-
var _block3 = this._blocks[_bi];
|
|
1487
|
-
var _blockInputPos2 = _block3.nearestInputPos(0, DIRECTION.NONE);
|
|
1488
|
-
if (!_block3.value.length || _blockInputPos2 !== _block3.value.length) {
|
|
1489
|
-
return this._blockStartPos(_bi) + _block3.value.length;
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
return cursorPos;
|
|
1745
|
+
if (cursor.pushRightBeforeInput()) return cursor.pos;
|
|
1746
|
+
cursor.popState();
|
|
1747
|
+
if (cursor.pushLeftBeforeInput()) return cursor.pos;
|
|
1748
|
+
return this.value.length;
|
|
1493
1749
|
}
|
|
1494
1750
|
if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
|
|
1495
|
-
var firstFilledBlockIndexAtRight;
|
|
1496
|
-
for (var _bi2 = searchBlockIndex; _bi2 < this._blocks.length; ++_bi2) {
|
|
1497
|
-
if (this._blocks[_bi2].value) {
|
|
1498
|
-
firstFilledBlockIndexAtRight = _bi2;
|
|
1499
|
-
break;
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
if (firstFilledBlockIndexAtRight != null) {
|
|
1503
|
-
var filledBlock = this._blocks[firstFilledBlockIndexAtRight];
|
|
1504
|
-
var _blockInputPos3 = filledBlock.nearestInputPos(0, DIRECTION.RIGHT);
|
|
1505
|
-
if (_blockInputPos3 === 0 && filledBlock.unmaskedValue.length) {
|
|
1506
|
-
return this._blockStartPos(firstFilledBlockIndexAtRight) + _blockInputPos3;
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
var firstFilledInputBlockIndex = -1;
|
|
1510
|
-
var firstEmptyInputBlockIndex;
|
|
1511
|
-
for (var _bi3 = searchBlockIndex - 1; _bi3 >= 0; --_bi3) {
|
|
1512
|
-
var _block4 = this._blocks[_bi3];
|
|
1513
|
-
var _blockInputPos4 = _block4.nearestInputPos(_block4.value.length, DIRECTION.FORCE_LEFT);
|
|
1514
|
-
if (!_block4.value || _blockInputPos4 !== 0) firstEmptyInputBlockIndex = _bi3;
|
|
1515
|
-
if (_blockInputPos4 !== 0) {
|
|
1516
|
-
if (_blockInputPos4 !== _block4.value.length) {
|
|
1517
|
-
return this._blockStartPos(_bi3) + _blockInputPos4;
|
|
1518
|
-
} else {
|
|
1519
|
-
firstFilledInputBlockIndex = _bi3;
|
|
1520
|
-
break;
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
1751
|
if (direction === DIRECTION.LEFT) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
var blockAlignedPos = this._blockStartPos(_bi4) + _blockInputPos5;
|
|
1529
|
-
if (blockAlignedPos > cursorPos) break;
|
|
1530
|
-
if (_blockInputPos5 !== _block5.value.length) return blockAlignedPos;
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
if (firstFilledInputBlockIndex >= 0) {
|
|
1534
|
-
return this._blockStartPos(firstFilledInputBlockIndex) + this._blocks[firstFilledInputBlockIndex].value.length;
|
|
1535
|
-
}
|
|
1536
|
-
if (direction === DIRECTION.FORCE_LEFT || this.lazy && !this.extractInput() && !isInput(this._blocks[searchBlockIndex])) {
|
|
1537
|
-
return 0;
|
|
1538
|
-
}
|
|
1539
|
-
if (firstEmptyInputBlockIndex != null) {
|
|
1540
|
-
return this._blockStartPos(firstEmptyInputBlockIndex);
|
|
1752
|
+
cursor.pushRightBeforeFilled();
|
|
1753
|
+
if (cursor.ok && cursor.pos === cursorPos) return cursorPos;
|
|
1754
|
+
cursor.popState();
|
|
1541
1755
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1756
|
+
cursor.pushLeftBeforeInput();
|
|
1757
|
+
cursor.pushLeftBeforeRequired();
|
|
1758
|
+
cursor.pushLeftBeforeFilled();
|
|
1759
|
+
if (direction === DIRECTION.LEFT) {
|
|
1760
|
+
cursor.pushRightBeforeInput();
|
|
1761
|
+
cursor.pushRightBeforeRequired();
|
|
1762
|
+
if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
|
|
1763
|
+
cursor.popState();
|
|
1764
|
+
if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
|
|
1765
|
+
cursor.popState();
|
|
1548
1766
|
}
|
|
1767
|
+
if (cursor.ok) return cursor.pos;
|
|
1768
|
+
if (direction === DIRECTION.FORCE_LEFT) return 0;
|
|
1769
|
+
cursor.popState();
|
|
1770
|
+
if (cursor.ok) return cursor.pos;
|
|
1771
|
+
cursor.popState();
|
|
1772
|
+
if (cursor.ok) return cursor.pos;
|
|
1549
1773
|
return 0;
|
|
1550
1774
|
}
|
|
1551
1775
|
if (direction === DIRECTION.RIGHT || direction === DIRECTION.FORCE_RIGHT) {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
if (firstInputBlockAlignedIndex != null && firstInputBlockAlignedPos != null) {
|
|
1564
|
-
for (var _bi7 = firstInputBlockAlignedIndex; _bi7 < this._blocks.length; ++_bi7) {
|
|
1565
|
-
var _block8 = this._blocks[_bi7];
|
|
1566
|
-
var _blockInputPos8 = _block8.nearestInputPos(0, DIRECTION.FORCE_RIGHT);
|
|
1567
|
-
if (_blockInputPos8 !== _block8.value.length) {
|
|
1568
|
-
return this._blockStartPos(_bi7) + _blockInputPos8;
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
return direction === DIRECTION.FORCE_RIGHT ? this.value.length : firstInputBlockAlignedPos;
|
|
1572
|
-
}
|
|
1573
|
-
for (var _bi8 = Math.min(searchBlockIndex, this._blocks.length - 1); _bi8 >= 0; --_bi8) {
|
|
1574
|
-
var _block9 = this._blocks[_bi8];
|
|
1575
|
-
var _blockInputPos9 = _block9.nearestInputPos(_block9.value.length, DIRECTION.LEFT);
|
|
1576
|
-
if (_blockInputPos9 !== 0) {
|
|
1577
|
-
var alignedPos = this._blockStartPos(_bi8) + _blockInputPos9;
|
|
1578
|
-
if (alignedPos >= cursorPos) return alignedPos;
|
|
1579
|
-
break;
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1776
|
+
cursor.pushRightBeforeInput();
|
|
1777
|
+
cursor.pushRightBeforeRequired();
|
|
1778
|
+
if (cursor.pushRightBeforeFilled()) return cursor.pos;
|
|
1779
|
+
if (direction === DIRECTION.FORCE_RIGHT) return this.value.length;
|
|
1780
|
+
cursor.popState();
|
|
1781
|
+
if (cursor.ok) return cursor.pos;
|
|
1782
|
+
cursor.popState();
|
|
1783
|
+
if (cursor.ok) return cursor.pos;
|
|
1784
|
+
return this.nearestInputPos(cursorPos, DIRECTION.LEFT);
|
|
1582
1785
|
}
|
|
1583
1786
|
return cursorPos;
|
|
1584
1787
|
}
|
|
@@ -1608,11 +1811,6 @@ MaskedPattern.STOP_CHAR = '`';
|
|
|
1608
1811
|
MaskedPattern.ESCAPE_CHAR = '\\';
|
|
1609
1812
|
MaskedPattern.InputDefinition = PatternInputDefinition;
|
|
1610
1813
|
MaskedPattern.FixedDefinition = PatternFixedDefinition;
|
|
1611
|
-
function isInput(block) {
|
|
1612
|
-
if (!block) return false;
|
|
1613
|
-
var value = block.value;
|
|
1614
|
-
return !value || block.nearestInputPos(0, DIRECTION.NONE) !== value.length;
|
|
1615
|
-
}
|
|
1616
1814
|
IMask.MaskedPattern = MaskedPattern;
|
|
1617
1815
|
|
|
1618
1816
|
var MaskedRange = function (_MaskedPattern) {
|
|
@@ -1633,7 +1831,8 @@ var MaskedRange = function (_MaskedPattern) {
|
|
|
1633
1831
|
value: function _update(opts) {
|
|
1634
1832
|
opts = Object.assign({
|
|
1635
1833
|
to: this.to || 0,
|
|
1636
|
-
from: this.from || 0
|
|
1834
|
+
from: this.from || 0,
|
|
1835
|
+
maxLength: this.maxLength || 0
|
|
1637
1836
|
}, opts);
|
|
1638
1837
|
var maxLength = String(opts.to).length;
|
|
1639
1838
|
if (opts.maxLength != null) maxLength = Math.max(maxLength, opts.maxLength);
|
|
@@ -1671,23 +1870,30 @@ var MaskedRange = function (_MaskedPattern) {
|
|
|
1671
1870
|
}
|
|
1672
1871
|
}, {
|
|
1673
1872
|
key: "doPrepare",
|
|
1674
|
-
value: function doPrepare(
|
|
1873
|
+
value: function doPrepare(ch) {
|
|
1675
1874
|
var flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1676
|
-
|
|
1677
|
-
|
|
1875
|
+
var details;
|
|
1876
|
+
var _normalizePrepare = normalizePrepare(_get(_getPrototypeOf(MaskedRange.prototype), "doPrepare", this).call(this, ch.replace(/\D/g, ''), flags));
|
|
1877
|
+
var _normalizePrepare2 = _slicedToArray(_normalizePrepare, 2);
|
|
1878
|
+
ch = _normalizePrepare2[0];
|
|
1879
|
+
details = _normalizePrepare2[1];
|
|
1880
|
+
if (!this.autofix || !ch) return ch;
|
|
1678
1881
|
var fromStr = String(this.from).padStart(this.maxLength, '0');
|
|
1679
1882
|
var toStr = String(this.to).padStart(this.maxLength, '0');
|
|
1680
|
-
var
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
if (
|
|
1883
|
+
var nextVal = this.value + ch;
|
|
1884
|
+
if (nextVal.length > this.maxLength) return '';
|
|
1885
|
+
var _this$boundaries = this.boundaries(nextVal),
|
|
1886
|
+
_this$boundaries2 = _slicedToArray(_this$boundaries, 2),
|
|
1887
|
+
minstr = _this$boundaries2[0],
|
|
1888
|
+
maxstr = _this$boundaries2[1];
|
|
1889
|
+
if (Number(maxstr) < this.from) return fromStr[nextVal.length - 1];
|
|
1890
|
+
if (Number(minstr) > this.to) {
|
|
1891
|
+
if (this.autofix === 'pad' && nextVal.length < this.maxLength) {
|
|
1892
|
+
return ['', details.aggregate(this.append(fromStr[nextVal.length - 1] + ch, flags))];
|
|
1893
|
+
}
|
|
1894
|
+
return toStr[nextVal.length - 1];
|
|
1689
1895
|
}
|
|
1690
|
-
return
|
|
1896
|
+
return ch;
|
|
1691
1897
|
}
|
|
1692
1898
|
}, {
|
|
1693
1899
|
key: "doValidate",
|
|
@@ -1734,10 +1940,10 @@ var MaskedDate = function (_MaskedPattern) {
|
|
|
1734
1940
|
opts.blocks.d.to = opts.max.getDate();
|
|
1735
1941
|
}
|
|
1736
1942
|
}
|
|
1737
|
-
Object.assign(opts.blocks, blocks);
|
|
1943
|
+
Object.assign(opts.blocks, this.blocks, blocks);
|
|
1738
1944
|
Object.keys(opts.blocks).forEach(function (bk) {
|
|
1739
1945
|
var b = opts.blocks[bk];
|
|
1740
|
-
if (!('autofix' in b)) b.autofix = opts.autofix;
|
|
1946
|
+
if (!('autofix' in b) && 'autofix' in opts) b.autofix = opts.autofix;
|
|
1741
1947
|
});
|
|
1742
1948
|
_get(_getPrototypeOf(MaskedDate.prototype), "_update", this).call(this, opts);
|
|
1743
1949
|
}
|
|
@@ -1772,12 +1978,18 @@ var MaskedDate = function (_MaskedPattern) {
|
|
|
1772
1978
|
set: function set(value) {
|
|
1773
1979
|
_set(_getPrototypeOf(MaskedDate.prototype), "typedValue", value, this, true);
|
|
1774
1980
|
}
|
|
1981
|
+
}, {
|
|
1982
|
+
key: "maskEquals",
|
|
1983
|
+
value: function maskEquals(mask) {
|
|
1984
|
+
return mask === Date || _get(_getPrototypeOf(MaskedDate.prototype), "maskEquals", this).call(this, mask);
|
|
1985
|
+
}
|
|
1775
1986
|
}]);
|
|
1776
1987
|
return MaskedDate;
|
|
1777
1988
|
}(MaskedPattern);
|
|
1778
1989
|
MaskedDate.DEFAULTS = {
|
|
1779
1990
|
pattern: 'd{.}`m{.}`Y',
|
|
1780
1991
|
format: function format(date) {
|
|
1992
|
+
if (!date) return '';
|
|
1781
1993
|
var day = String(date.getDate()).padStart(2, '0');
|
|
1782
1994
|
var month = String(date.getMonth() + 1).padStart(2, '0');
|
|
1783
1995
|
var year = date.getFullYear();
|
|
@@ -1879,7 +2091,8 @@ var HTMLMaskElement = function (_MaskElement) {
|
|
|
1879
2091
|
_createClass(HTMLMaskElement, [{
|
|
1880
2092
|
key: "rootElement",
|
|
1881
2093
|
get: function get() {
|
|
1882
|
-
|
|
2094
|
+
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
|
|
2095
|
+
return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) === null || _this$input$getRootNo2 === void 0 ? void 0 : _this$input$getRootNo2.call(_this$input)) !== null && _this$input$getRootNo !== void 0 ? _this$input$getRootNo : document;
|
|
1883
2096
|
}
|
|
1884
2097
|
}, {
|
|
1885
2098
|
key: "isActive",
|
|
@@ -1963,14 +2176,24 @@ var HTMLContenteditableMaskElement = function (_HTMLMaskElement) {
|
|
|
1963
2176
|
function get() {
|
|
1964
2177
|
var root = this.rootElement;
|
|
1965
2178
|
var selection = root.getSelection && root.getSelection();
|
|
1966
|
-
|
|
2179
|
+
var anchorOffset = selection && selection.anchorOffset;
|
|
2180
|
+
var focusOffset = selection && selection.focusOffset;
|
|
2181
|
+
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
|
|
2182
|
+
return anchorOffset;
|
|
2183
|
+
}
|
|
2184
|
+
return focusOffset;
|
|
1967
2185
|
}
|
|
1968
2186
|
}, {
|
|
1969
2187
|
key: "_unsafeSelectionEnd",
|
|
1970
2188
|
get: function get() {
|
|
1971
2189
|
var root = this.rootElement;
|
|
1972
2190
|
var selection = root.getSelection && root.getSelection();
|
|
1973
|
-
|
|
2191
|
+
var anchorOffset = selection && selection.anchorOffset;
|
|
2192
|
+
var focusOffset = selection && selection.focusOffset;
|
|
2193
|
+
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
|
|
2194
|
+
return anchorOffset;
|
|
2195
|
+
}
|
|
2196
|
+
return focusOffset;
|
|
1974
2197
|
}
|
|
1975
2198
|
}, {
|
|
1976
2199
|
key: "_unsafeSelect",
|
|
@@ -2042,7 +2265,8 @@ var InputMask = function () {
|
|
|
2042
2265
|
}, {
|
|
2043
2266
|
key: "maskEquals",
|
|
2044
2267
|
value: function maskEquals(mask) {
|
|
2045
|
-
|
|
2268
|
+
var _this$masked;
|
|
2269
|
+
return mask == null || ((_this$masked = this.masked) === null || _this$masked === void 0 ? void 0 : _this$masked.maskEquals(mask));
|
|
2046
2270
|
}
|
|
2047
2271
|
}, {
|
|
2048
2272
|
key: "value",
|
|
@@ -2120,7 +2344,8 @@ var InputMask = function () {
|
|
|
2120
2344
|
}
|
|
2121
2345
|
}, {
|
|
2122
2346
|
key: "_saveSelection",
|
|
2123
|
-
value: function
|
|
2347
|
+
value: function
|
|
2348
|
+
_saveSelection() {
|
|
2124
2349
|
if (this.value !== this.el.value) {
|
|
2125
2350
|
console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.');
|
|
2126
2351
|
}
|
|
@@ -2193,7 +2418,7 @@ var InputMask = function () {
|
|
|
2193
2418
|
}, {
|
|
2194
2419
|
key: "alignCursor",
|
|
2195
2420
|
value: function alignCursor() {
|
|
2196
|
-
this.cursorPos = this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT);
|
|
2421
|
+
this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
|
|
2197
2422
|
}
|
|
2198
2423
|
}, {
|
|
2199
2424
|
key: "alignCursorFriendly",
|
|
@@ -2233,6 +2458,7 @@ var InputMask = function () {
|
|
|
2233
2458
|
var offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection).offset;
|
|
2234
2459
|
var removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
|
|
2235
2460
|
var cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
|
|
2461
|
+
if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
|
|
2236
2462
|
this.updateControl();
|
|
2237
2463
|
this.updateCursor(cursorPos);
|
|
2238
2464
|
delete this._inputEvent;
|
|
@@ -2345,12 +2571,19 @@ var MaskedNumber = function (_Masked) {
|
|
|
2345
2571
|
}
|
|
2346
2572
|
}, {
|
|
2347
2573
|
key: "doPrepare",
|
|
2348
|
-
value: function doPrepare(
|
|
2574
|
+
value: function doPrepare(ch) {
|
|
2349
2575
|
var _get2;
|
|
2576
|
+
ch = ch.replace(this._mapToRadixRegExp, this.radix);
|
|
2577
|
+
var noSepCh = this._removeThousandsSeparators(ch);
|
|
2350
2578
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2351
2579
|
args[_key - 1] = arguments[_key];
|
|
2352
2580
|
}
|
|
2353
|
-
|
|
2581
|
+
var _normalizePrepare = normalizePrepare((_get2 = _get(_getPrototypeOf(MaskedNumber.prototype), "doPrepare", this)).call.apply(_get2, [this, noSepCh].concat(args))),
|
|
2582
|
+
_normalizePrepare2 = _slicedToArray(_normalizePrepare, 2),
|
|
2583
|
+
prepCh = _normalizePrepare2[0],
|
|
2584
|
+
details = _normalizePrepare2[1];
|
|
2585
|
+
if (ch && !noSepCh) details.skip = true;
|
|
2586
|
+
return [prepCh, details];
|
|
2354
2587
|
}
|
|
2355
2588
|
}, {
|
|
2356
2589
|
key: "_separatorsCount",
|
|
@@ -2472,7 +2705,9 @@ var MaskedNumber = function (_Masked) {
|
|
|
2472
2705
|
var valid = regexp.test(this._removeThousandsSeparators(this.value));
|
|
2473
2706
|
if (valid) {
|
|
2474
2707
|
var number = this.number;
|
|
2475
|
-
valid = valid && !isNaN(number) && (
|
|
2708
|
+
valid = valid && !isNaN(number) && (
|
|
2709
|
+
this.min == null || this.min >= 0 || this.min <= this.number) && (
|
|
2710
|
+
this.max == null || this.max <= 0 || this.number <= this.max);
|
|
2476
2711
|
}
|
|
2477
2712
|
return valid && _get(_getPrototypeOf(MaskedNumber.prototype), "doValidate", this).call(this, flags);
|
|
2478
2713
|
}
|
|
@@ -2487,7 +2722,7 @@ var MaskedNumber = function (_Masked) {
|
|
|
2487
2722
|
if (validnum !== number) this.unmaskedValue = String(validnum);
|
|
2488
2723
|
var formatted = this.value;
|
|
2489
2724
|
if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
|
|
2490
|
-
if (this.padFractionalZeros) formatted = this._padFractionalZeros(formatted);
|
|
2725
|
+
if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
|
|
2491
2726
|
this._value = formatted;
|
|
2492
2727
|
}
|
|
2493
2728
|
_get(_getPrototypeOf(MaskedNumber.prototype), "doCommit", this).call(this);
|
|
@@ -2785,6 +3020,14 @@ var MaskedDynamic = function (_Masked) {
|
|
|
2785
3020
|
set: function set(overwrite) {
|
|
2786
3021
|
console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings');
|
|
2787
3022
|
}
|
|
3023
|
+
}, {
|
|
3024
|
+
key: "maskEquals",
|
|
3025
|
+
value: function maskEquals(mask) {
|
|
3026
|
+
return Array.isArray(mask) && this.compiledMasks.every(function (m, mi) {
|
|
3027
|
+
var _mask$mi;
|
|
3028
|
+
return m.maskEquals((_mask$mi = mask[mi]) === null || _mask$mi === void 0 ? void 0 : _mask$mi.mask);
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
2788
3031
|
}]);
|
|
2789
3032
|
return MaskedDynamic;
|
|
2790
3033
|
}(Masked);
|