@justifi/webcomponents 4.12.1 → 4.13.0-rc.0
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/cjs/{Business-c928bf29.js → Business-98686045.js} +27 -4
- package/dist/cjs/additional-questions-details_5.cjs.entry.js +4 -4
- package/dist/cjs/{business-additional-questions-schema-3813615c.js → business-additional-questions-schema-f8086f7a.js} +19 -9
- package/dist/cjs/business-form-options-fd1c0032.js +128 -0
- package/dist/cjs/{business-form-types-4b138bf2.js → business-form-types-29b2bad9.js} +0 -26
- package/dist/cjs/form-control-date_3.cjs.entry.js +2 -2
- package/dist/cjs/form-control-datepart_2.cjs.entry.js +1 -1
- package/dist/cjs/form-control-monetary.cjs.entry.js +7 -12
- package/dist/cjs/form-input-masks-0879c139.js +27 -0
- package/dist/cjs/{index-fc5339a5.js → index-d8e99b54.js} +352 -198
- package/dist/cjs/justifi-additional-questions-form-step_5.cjs.entry.js +10 -9
- package/dist/cjs/justifi-additional-questions_4.cjs.entry.js +7 -7
- package/dist/cjs/justifi-billing-form_4.cjs.entry.js +4 -4
- package/dist/cjs/justifi-business-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-business-form.cjs.entry.js +6 -5
- package/dist/cjs/justifi-business-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-business-owners.cjs.entry.js +1 -1
- package/dist/cjs/justifi-checkout-core.cjs.entry.js +9 -4
- package/dist/cjs/justifi-checkout.cjs.entry.js +26 -4
- package/dist/cjs/justifi-new-payment-method_4.cjs.entry.js +1 -1
- package/dist/cjs/justifi-owner-form.cjs.entry.js +6 -5
- package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +1 -3
- package/dist/cjs/justifi-refund-form.cjs.entry.js +2 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{payload-parsers-58d3798e.js → payload-parsers-fe27be37.js} +65 -6
- package/dist/cjs/{state-options-4fbcb48a.js → state-options-4145f9b4.js} +0 -4
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/api/Business.js +26 -3
- package/dist/collection/components/business-details/additional-questions-details/additional-questions-details.js +2 -2
- package/dist/collection/components/business-details/generic-info-details/generic-info-details.js +2 -2
- package/dist/collection/components/business-forms/business-form/additional-questions/additional-questions.js +4 -2
- package/dist/collection/components/business-forms/business-form/business-core-info/business-core-info.js +2 -2
- package/dist/collection/components/business-forms/payment-provisioning/additional-questions/business-additional-questions-form-step.js +4 -2
- package/dist/collection/components/business-forms/payment-provisioning/business-core-info/business-core-info-form-step.js +3 -2
- package/dist/collection/components/business-forms/schemas/business-additional-questions-schema.js +16 -9
- package/dist/collection/components/business-forms/schemas/business-core-info-schema.js +5 -1
- package/dist/collection/components/business-forms/schemas/schema-helpers.js +3 -0
- package/dist/collection/components/business-forms/schemas/schema-validations.js +53 -6
- package/dist/collection/components/business-forms/utils/business-form-options.js +119 -0
- package/dist/collection/components/business-forms/utils/business-form-types.js +0 -23
- package/dist/collection/components/checkout/checkout-actions.js +28 -5
- package/dist/collection/components/checkout/checkout-core.js +30 -6
- package/dist/collection/components/checkout/payment-method-options.js +2 -18
- package/dist/collection/components/checkout/test/checkout-actions.spec.js +126 -0
- package/dist/collection/components/checkout/test/checkout-core.spec.js +127 -0
- package/dist/collection/components/checkout/test/checkout.spec.js +0 -153
- package/dist/collection/components/form/form-control-monetary.css +1812 -0
- package/dist/collection/components/form/form-control-monetary.js +24 -11
- package/dist/collection/components/form/test/form-control-monetary.spec.js +5 -3
- package/dist/collection/components/payment-method-form/payment-method-form.js +1 -1
- package/dist/collection/components/refund-form/refund-form.js +2 -1
- package/dist/collection/utils/form-input-masks.js +15 -0
- package/dist/collection/utils/state-options.js +0 -4
- package/dist/docs.json +93 -30
- package/dist/esm/{Business-6cb1b9c8.js → Business-6e0efa26.js} +28 -5
- package/dist/esm/additional-questions-details_5.entry.js +4 -4
- package/dist/esm/business-additional-questions-schema-8e742129.js +54 -0
- package/dist/esm/business-form-options-75c0a7ec.js +122 -0
- package/dist/esm/{business-form-types-5ba52d61.js → business-form-types-0d76133c.js} +1 -25
- package/dist/esm/form-control-date_3.entry.js +2 -2
- package/dist/esm/form-control-datepart_2.entry.js +1 -1
- package/dist/esm/form-control-monetary.entry.js +7 -12
- package/dist/esm/form-input-masks-0e18300f.js +22 -0
- package/dist/esm/{index-5eb05747.js → index-dc1350b1.js} +352 -198
- package/dist/esm/justifi-additional-questions-form-step_5.entry.js +10 -9
- package/dist/esm/justifi-additional-questions_4.entry.js +7 -7
- package/dist/esm/justifi-billing-form_4.entry.js +4 -4
- package/dist/esm/justifi-business-details.entry.js +2 -2
- package/dist/esm/justifi-business-form.entry.js +6 -5
- package/dist/esm/justifi-business-list.entry.js +2 -2
- package/dist/esm/justifi-business-owners.entry.js +1 -1
- package/dist/esm/justifi-checkout-core.entry.js +9 -4
- package/dist/esm/justifi-checkout.entry.js +27 -5
- package/dist/esm/justifi-new-payment-method_4.entry.js +1 -1
- package/dist/esm/justifi-owner-form.entry.js +6 -5
- package/dist/esm/justifi-payment-provisioning.entry.js +1 -3
- package/dist/esm/justifi-refund-form.entry.js +2 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{payload-parsers-3e817fe9.js → payload-parsers-73c12fa2.js} +57 -7
- package/dist/esm/{state-options-a356fb11.js → state-options-c0b757ad.js} +0 -4
- package/dist/esm/webcomponents.js +1 -1
- package/dist/module/Business.js +27 -4
- package/dist/module/additional-questions-details2.js +2 -2
- package/dist/module/additional-questions.js +18 -4
- package/dist/module/business-additional-questions-form-step.js +18 -4
- package/dist/module/business-additional-questions-schema.js +16 -9
- package/dist/module/business-address-schema.js +1 -1
- package/dist/module/business-core-info-form-step.js +10 -3
- package/dist/module/business-core-info-schema.js +5 -1
- package/dist/module/business-core-info.js +9 -3
- package/dist/module/business-form-options.js +122 -0
- package/dist/module/business-form-types.js +153 -24
- package/dist/module/business-identity-schema.js +1 -1
- package/dist/module/business-representative-form-step.js +1 -1
- package/dist/module/checkout-core.js +9 -5
- package/dist/module/form-control-monetary2.js +8 -12
- package/dist/module/form-input-masks.js +16 -1
- package/dist/module/generic-info-details2.js +2 -2
- package/dist/module/index2.js +352 -198
- package/dist/module/justifi-business-details.js +1 -1
- package/dist/module/justifi-business-form.js +3 -3
- package/dist/module/justifi-business-list.js +1 -1
- package/dist/module/justifi-checkout.js +27 -5
- package/dist/module/justifi-payment-provisioning.js +1 -1
- package/dist/module/justifi-refund-form.js +2 -1
- package/dist/module/legal-address-form-step.js +2 -2
- package/dist/module/owner-form.js +2 -2
- package/dist/module/payload-parsers.js +1 -104
- package/dist/module/payment-method-form.js +3 -3
- package/dist/module/payment-method-options.js +2 -2
- package/dist/module/state-options.js +0 -4
- package/dist/types/api/Business.d.ts +34 -5
- package/dist/types/api/services/checkout.service.d.ts +3 -3
- package/dist/types/components/business-forms/schemas/business-additional-questions-schema.d.ts +10 -4
- package/dist/types/components/business-forms/schemas/business-core-info-schema.d.ts +4 -0
- package/dist/types/components/business-forms/schemas/business-form-schema.d.ts +14 -4
- package/dist/types/components/business-forms/schemas/schema-helpers.d.ts +3 -0
- package/dist/types/components/business-forms/schemas/schema-validations.d.ts +9 -0
- package/dist/types/components/business-forms/utils/business-form-options.d.ts +21 -0
- package/dist/types/components/business-forms/utils/business-form-types.d.ts +0 -5
- package/dist/types/components/checkout/checkout-core.d.ts +3 -2
- package/dist/types/components/checkout/payment-method-options.d.ts +1 -1
- package/dist/types/components/form/form-control-monetary.d.ts +1 -0
- package/dist/types/components.d.ts +4 -2
- package/dist/types/utils/form-input-masks.d.ts +15 -0
- package/dist/webcomponents/{p-31e70d65.entry.js → p-19885f77.entry.js} +1 -1
- package/dist/webcomponents/p-2c4c5f0d.entry.js +1 -0
- package/dist/webcomponents/p-30b6ea06.entry.js +1 -0
- package/dist/webcomponents/p-31e8f29c.entry.js +1 -0
- package/dist/webcomponents/p-31fe7232.entry.js +1 -0
- package/dist/webcomponents/p-3496e37f.js +1 -0
- package/dist/webcomponents/{p-2fbe8823.entry.js → p-35e59bb5.entry.js} +1 -1
- package/dist/webcomponents/p-3917edbf.entry.js +1 -0
- package/dist/webcomponents/p-3934a3a8.entry.js +1 -0
- package/dist/webcomponents/p-3ffe6784.js +1 -0
- package/dist/webcomponents/p-49c349e7.js +1 -0
- package/dist/webcomponents/p-4d335a3d.entry.js +1 -0
- package/dist/webcomponents/p-4ff52695.entry.js +1 -0
- package/dist/webcomponents/p-525db3e8.js +1 -0
- package/dist/webcomponents/p-57fbd98d.js +1 -0
- package/dist/webcomponents/p-5a789239.entry.js +1 -0
- package/dist/webcomponents/{p-5f5e730c.entry.js → p-834cba99.entry.js} +1 -1
- package/dist/webcomponents/p-87d646c0.js +1 -0
- package/dist/webcomponents/{p-2bee72bd.entry.js → p-8da13f40.entry.js} +1 -1
- package/dist/webcomponents/p-935d6f55.js +1 -0
- package/dist/webcomponents/{p-71b8e2da.entry.js → p-ba454cd7.entry.js} +1 -1
- package/dist/webcomponents/p-ed6ca114.js +1 -0
- package/dist/webcomponents/p-ee68566f.entry.js +1 -0
- package/dist/webcomponents/{p-b9f04fb0.entry.js → p-f152d6b8.entry.js} +1 -1
- package/dist/webcomponents/p-f3cf3513.entry.js +1 -0
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/form-input-masks-efd44b8e.js +0 -11
- package/dist/esm/business-additional-questions-schema-228d86e0.js +0 -44
- package/dist/esm/form-input-masks-84875967.js +0 -7
- package/dist/webcomponents/p-01913426.js +0 -1
- package/dist/webcomponents/p-07080c01.entry.js +0 -1
- package/dist/webcomponents/p-0d371ff5.entry.js +0 -1
- package/dist/webcomponents/p-2319abaf.entry.js +0 -1
- package/dist/webcomponents/p-26fe62d6.entry.js +0 -1
- package/dist/webcomponents/p-31ccb5f0.entry.js +0 -1
- package/dist/webcomponents/p-4c705f56.js +0 -1
- package/dist/webcomponents/p-6078a370.js +0 -1
- package/dist/webcomponents/p-737473d8.js +0 -1
- package/dist/webcomponents/p-787d8f52.js +0 -1
- package/dist/webcomponents/p-889a83d2.js +0 -1
- package/dist/webcomponents/p-927150b4.entry.js +0 -1
- package/dist/webcomponents/p-93579716.js +0 -1
- package/dist/webcomponents/p-9b0e5c25.entry.js +0 -1
- package/dist/webcomponents/p-9e3f9e05.entry.js +0 -1
- package/dist/webcomponents/p-c1b92cec.entry.js +0 -1
- package/dist/webcomponents/p-c865cda8.entry.js +0 -1
- package/dist/webcomponents/p-edab5f2b.entry.js +0 -1
package/dist/module/index2.js
CHANGED
|
@@ -5,7 +5,8 @@ function isString(str) {
|
|
|
5
5
|
|
|
6
6
|
/** Checks if value is object */
|
|
7
7
|
function isObject(obj) {
|
|
8
|
-
|
|
8
|
+
var _obj$constructor;
|
|
9
|
+
return typeof obj === 'object' && obj != null && (obj == null || (_obj$constructor = obj.constructor) == null ? void 0 : _obj$constructor.name) === 'Object';
|
|
9
10
|
}
|
|
10
11
|
function pick(obj, keys) {
|
|
11
12
|
if (Array.isArray(keys)) return pick(obj, (_, k) => keys.includes(k));
|
|
@@ -93,10 +94,11 @@ class ActionDetails {
|
|
|
93
94
|
while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {
|
|
94
95
|
--this.oldSelection.start;
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
if (this.insertedCount) {
|
|
98
|
+
// double check right part
|
|
99
|
+
while (this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end)) {
|
|
100
|
+
if (this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end) ++this.oldSelection.end;else ++this.cursorPos;
|
|
101
|
+
}
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
|
|
@@ -262,7 +264,7 @@ function createMask(opts) {
|
|
|
262
264
|
if (IMask.Masked && opts instanceof IMask.Masked) return opts;
|
|
263
265
|
const nOpts = normalizeOpts(opts);
|
|
264
266
|
const MaskedClass = maskedClass(nOpts.mask);
|
|
265
|
-
if (!MaskedClass) throw new Error(
|
|
267
|
+
if (!MaskedClass) throw new Error("Masked class is not found for provided mask " + nOpts.mask + ", appropriate module needs to be imported manually before creating mask.");
|
|
266
268
|
if (nOpts.mask === MaskedClass) delete nOpts.mask;
|
|
267
269
|
if (nOpts._mask) {
|
|
268
270
|
nOpts.mask = nOpts._mask;
|
|
@@ -334,7 +336,8 @@ class HTMLMaskElement extends MaskElement {
|
|
|
334
336
|
this._onCompositionEnd = this._onCompositionEnd.bind(this);
|
|
335
337
|
}
|
|
336
338
|
get rootElement() {
|
|
337
|
-
|
|
339
|
+
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
|
|
340
|
+
return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) == null ? void 0 : _this$input$getRootNo2.call(_this$input)) != null ? _this$input$getRootNo : document;
|
|
338
341
|
}
|
|
339
342
|
|
|
340
343
|
/** Is element in focus */
|
|
@@ -479,9 +482,10 @@ class HTMLContenteditableMaskElement extends HTMLMaskElement {
|
|
|
479
482
|
IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
|
|
480
483
|
|
|
481
484
|
class InputHistory {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
+
constructor() {
|
|
486
|
+
this.states = [];
|
|
487
|
+
this.currentIndex = 0;
|
|
488
|
+
}
|
|
485
489
|
get currentState() {
|
|
486
490
|
return this.states[this.currentIndex];
|
|
487
491
|
}
|
|
@@ -510,6 +514,7 @@ class InputHistory {
|
|
|
510
514
|
this.currentIndex = 0;
|
|
511
515
|
}
|
|
512
516
|
}
|
|
517
|
+
InputHistory.MAX_LENGTH = 100;
|
|
513
518
|
|
|
514
519
|
/** Listens to element events and controls changes between element and {@link Masked} */
|
|
515
520
|
class InputMask {
|
|
@@ -540,11 +545,11 @@ class InputMask {
|
|
|
540
545
|
this._bindEvents();
|
|
541
546
|
|
|
542
547
|
// refresh
|
|
543
|
-
this.updateValue();
|
|
544
548
|
this._onChange();
|
|
545
549
|
}
|
|
546
550
|
maskEquals(mask) {
|
|
547
|
-
|
|
551
|
+
var _this$masked;
|
|
552
|
+
return mask == null || ((_this$masked = this.masked) == null ? void 0 : _this$masked.maskEquals(mask));
|
|
548
553
|
}
|
|
549
554
|
|
|
550
555
|
/** Masked */
|
|
@@ -670,6 +675,8 @@ class InputMask {
|
|
|
670
675
|
updateValue() {
|
|
671
676
|
this.masked.value = this.el.value;
|
|
672
677
|
this._value = this.masked.value;
|
|
678
|
+
this._unmaskedValue = this.masked.unmaskedValue;
|
|
679
|
+
this._rawInputValue = this.masked.rawInputValue;
|
|
673
680
|
}
|
|
674
681
|
|
|
675
682
|
/** Syncronizes view from model value, fires change events */
|
|
@@ -802,9 +809,7 @@ class InputMask {
|
|
|
802
809
|
|
|
803
810
|
/** Handles view change event and commits model value */
|
|
804
811
|
_onChange() {
|
|
805
|
-
if (this.displayValue !== this.el.value)
|
|
806
|
-
this.updateValue();
|
|
807
|
-
}
|
|
812
|
+
if (this.displayValue !== this.el.value) this.updateValue();
|
|
808
813
|
this.masked.doCommit();
|
|
809
814
|
this.updateControl();
|
|
810
815
|
this._saveSelection();
|
|
@@ -853,12 +858,12 @@ IMask.InputMask = InputMask;
|
|
|
853
858
|
class ChangeDetails {
|
|
854
859
|
/** Inserted symbols */
|
|
855
860
|
|
|
856
|
-
/** Can skip chars */
|
|
857
|
-
|
|
858
861
|
/** Additional offset if any changes occurred before tail */
|
|
859
862
|
|
|
860
863
|
/** Raw inserted is used by dynamic mask */
|
|
861
864
|
|
|
865
|
+
/** Can skip chars */
|
|
866
|
+
|
|
862
867
|
static normalize(prep) {
|
|
863
868
|
return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
|
|
864
869
|
}
|
|
@@ -866,17 +871,17 @@ class ChangeDetails {
|
|
|
866
871
|
Object.assign(this, {
|
|
867
872
|
inserted: '',
|
|
868
873
|
rawInserted: '',
|
|
869
|
-
|
|
870
|
-
|
|
874
|
+
tailShift: 0,
|
|
875
|
+
skip: false
|
|
871
876
|
}, details);
|
|
872
877
|
}
|
|
873
878
|
|
|
874
879
|
/** Aggregate changes */
|
|
875
880
|
aggregate(details) {
|
|
876
|
-
this.rawInserted += details.rawInserted;
|
|
877
|
-
this.skip = this.skip || details.skip;
|
|
878
881
|
this.inserted += details.inserted;
|
|
882
|
+
this.rawInserted += details.rawInserted;
|
|
879
883
|
this.tailShift += details.tailShift;
|
|
884
|
+
this.skip = this.skip || details.skip;
|
|
880
885
|
return this;
|
|
881
886
|
}
|
|
882
887
|
|
|
@@ -884,6 +889,12 @@ class ChangeDetails {
|
|
|
884
889
|
get offset() {
|
|
885
890
|
return this.tailShift + this.inserted.length;
|
|
886
891
|
}
|
|
892
|
+
get consumed() {
|
|
893
|
+
return Boolean(this.rawInserted) || this.skip;
|
|
894
|
+
}
|
|
895
|
+
equals(details) {
|
|
896
|
+
return this.inserted === details.inserted && this.tailShift === details.tailShift && this.rawInserted === details.rawInserted && this.skip === details.skip;
|
|
897
|
+
}
|
|
887
898
|
}
|
|
888
899
|
IMask.ChangeDetails = ChangeDetails;
|
|
889
900
|
|
|
@@ -949,11 +960,6 @@ class ContinuousTailDetails {
|
|
|
949
960
|
|
|
950
961
|
/** Provides common masking stuff */
|
|
951
962
|
class Masked {
|
|
952
|
-
static DEFAULTS = {
|
|
953
|
-
skipInvalid: true
|
|
954
|
-
};
|
|
955
|
-
static EMPTY_VALUES = [undefined, null, ''];
|
|
956
|
-
|
|
957
963
|
/** */
|
|
958
964
|
|
|
959
965
|
/** */
|
|
@@ -978,6 +984,8 @@ class Masked {
|
|
|
978
984
|
|
|
979
985
|
/** */
|
|
980
986
|
|
|
987
|
+
/** */
|
|
988
|
+
|
|
981
989
|
constructor(opts) {
|
|
982
990
|
this._value = '';
|
|
983
991
|
this._update({
|
|
@@ -1131,7 +1139,28 @@ class Masked {
|
|
|
1131
1139
|
const consistentState = this.state;
|
|
1132
1140
|
let details;
|
|
1133
1141
|
[ch, details] = this.doPrepareChar(ch, flags);
|
|
1134
|
-
if (ch)
|
|
1142
|
+
if (ch) {
|
|
1143
|
+
details = details.aggregate(this._appendCharRaw(ch, flags));
|
|
1144
|
+
|
|
1145
|
+
// TODO handle `skip`?
|
|
1146
|
+
|
|
1147
|
+
// try `autofix` lookahead
|
|
1148
|
+
if (!details.rawInserted && this.autofix === 'pad') {
|
|
1149
|
+
const noFixState = this.state;
|
|
1150
|
+
this.state = consistentState;
|
|
1151
|
+
let fixDetails = this.pad(flags);
|
|
1152
|
+
const chDetails = this._appendCharRaw(ch, flags);
|
|
1153
|
+
fixDetails = fixDetails.aggregate(chDetails);
|
|
1154
|
+
|
|
1155
|
+
// if fix was applied or
|
|
1156
|
+
// if details are equal use skip restoring state optimization
|
|
1157
|
+
if (chDetails.rawInserted || fixDetails.equals(details)) {
|
|
1158
|
+
details = fixDetails;
|
|
1159
|
+
} else {
|
|
1160
|
+
this.state = noFixState;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1135
1164
|
if (details.inserted) {
|
|
1136
1165
|
let consistentTail;
|
|
1137
1166
|
let appended = this.doValidate(flags) !== false;
|
|
@@ -1186,7 +1215,7 @@ class Masked {
|
|
|
1186
1215
|
append(str, flags, tail) {
|
|
1187
1216
|
if (!isString(str)) throw new Error('value should be string');
|
|
1188
1217
|
const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
|
|
1189
|
-
if (flags
|
|
1218
|
+
if (flags != null && flags.tail) flags._beforeTailState = this.state;
|
|
1190
1219
|
let details;
|
|
1191
1220
|
[str, details] = this.doPrepare(str, flags);
|
|
1192
1221
|
for (let ci = 0; ci < str.length; ++ci) {
|
|
@@ -1194,7 +1223,7 @@ class Masked {
|
|
|
1194
1223
|
if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
|
|
1195
1224
|
details.aggregate(d);
|
|
1196
1225
|
}
|
|
1197
|
-
if ((this.eager === true || this.eager === 'append') && flags
|
|
1226
|
+
if ((this.eager === true || this.eager === 'append') && flags != null && flags.input && str) {
|
|
1198
1227
|
details.aggregate(this._appendEager());
|
|
1199
1228
|
}
|
|
1200
1229
|
|
|
@@ -1273,6 +1302,9 @@ class Masked {
|
|
|
1273
1302
|
if (this.commit) this.commit(this.value, this);
|
|
1274
1303
|
}
|
|
1275
1304
|
splice(start, deleteCount, inserted, removeDirection, flags) {
|
|
1305
|
+
if (inserted === void 0) {
|
|
1306
|
+
inserted = '';
|
|
1307
|
+
}
|
|
1276
1308
|
if (removeDirection === void 0) {
|
|
1277
1309
|
removeDirection = DIRECTION.NONE;
|
|
1278
1310
|
}
|
|
@@ -1326,7 +1358,14 @@ class Masked {
|
|
|
1326
1358
|
const tval = this.typedValue;
|
|
1327
1359
|
return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || (this.format ? this.format(value, this) === this.format(this.typedValue, this) : false);
|
|
1328
1360
|
}
|
|
1361
|
+
pad(flags) {
|
|
1362
|
+
return new ChangeDetails();
|
|
1363
|
+
}
|
|
1329
1364
|
}
|
|
1365
|
+
Masked.DEFAULTS = {
|
|
1366
|
+
skipInvalid: true
|
|
1367
|
+
};
|
|
1368
|
+
Masked.EMPTY_VALUES = [undefined, null, ''];
|
|
1330
1369
|
IMask.Masked = Masked;
|
|
1331
1370
|
|
|
1332
1371
|
class ChunksTailDetails {
|
|
@@ -1388,7 +1427,7 @@ class ChunksTailDetails {
|
|
|
1388
1427
|
return tail.appendTo(masked);
|
|
1389
1428
|
}
|
|
1390
1429
|
const details = new ChangeDetails();
|
|
1391
|
-
for (let ci = 0; ci < this.chunks.length
|
|
1430
|
+
for (let ci = 0; ci < this.chunks.length; ++ci) {
|
|
1392
1431
|
const chunk = this.chunks[ci];
|
|
1393
1432
|
const lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);
|
|
1394
1433
|
const stop = chunk.stop;
|
|
@@ -1399,16 +1438,13 @@ class ChunksTailDetails {
|
|
|
1399
1438
|
if (chunk instanceof ChunksTailDetails ||
|
|
1400
1439
|
// for continuous block also check if stop is exist
|
|
1401
1440
|
masked._stops.indexOf(stop) >= 0) {
|
|
1402
|
-
|
|
1403
|
-
details.aggregate(phDetails);
|
|
1441
|
+
details.aggregate(masked._appendPlaceholder(stop));
|
|
1404
1442
|
}
|
|
1405
1443
|
chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
|
|
1406
1444
|
}
|
|
1407
1445
|
if (chunkBlock) {
|
|
1408
1446
|
const tailDetails = chunkBlock.appendTail(chunk);
|
|
1409
|
-
tailDetails.skip = false; // always ignore skip, it will be set on last
|
|
1410
1447
|
details.aggregate(tailDetails);
|
|
1411
|
-
masked._value += tailDetails.inserted;
|
|
1412
1448
|
|
|
1413
1449
|
// get not inserted chars
|
|
1414
1450
|
const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
|
|
@@ -1543,7 +1579,8 @@ class PatternCursor {
|
|
|
1543
1579
|
}
|
|
1544
1580
|
_pushLeft(fn) {
|
|
1545
1581
|
this.pushState();
|
|
1546
|
-
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = this.block
|
|
1582
|
+
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) == null ? void 0 : _this$block.displayValue.length) || 0) {
|
|
1583
|
+
var _this$block;
|
|
1547
1584
|
if (fn()) return this.ok = true;
|
|
1548
1585
|
}
|
|
1549
1586
|
return this.ok = false;
|
|
@@ -1704,13 +1741,15 @@ class PatternFixedDefinition {
|
|
|
1704
1741
|
if (flags === void 0) {
|
|
1705
1742
|
flags = {};
|
|
1706
1743
|
}
|
|
1707
|
-
|
|
1708
|
-
if (this.isFilled) return details;
|
|
1744
|
+
if (this.isFilled) return new ChangeDetails();
|
|
1709
1745
|
const appendEager = this.eager === true || this.eager === 'append';
|
|
1710
1746
|
const appended = this.char === ch;
|
|
1711
1747
|
const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
|
|
1712
|
-
|
|
1713
|
-
|
|
1748
|
+
const details = new ChangeDetails({
|
|
1749
|
+
inserted: this.char,
|
|
1750
|
+
rawInserted: isResolved ? this.char : ''
|
|
1751
|
+
});
|
|
1752
|
+
this._value = this.char;
|
|
1714
1753
|
this._isRawInput = isResolved && (flags.raw || flags.input);
|
|
1715
1754
|
return details;
|
|
1716
1755
|
}
|
|
@@ -1750,16 +1789,12 @@ class PatternFixedDefinition {
|
|
|
1750
1789
|
this._value = state._value;
|
|
1751
1790
|
this._isRawInput = Boolean(state._rawInputValue);
|
|
1752
1791
|
}
|
|
1792
|
+
pad(flags) {
|
|
1793
|
+
return this._appendPlaceholder();
|
|
1794
|
+
}
|
|
1753
1795
|
}
|
|
1754
1796
|
|
|
1755
1797
|
class PatternInputDefinition {
|
|
1756
|
-
static DEFAULT_DEFINITIONS = {
|
|
1757
|
-
'0': /\d/,
|
|
1758
|
-
'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
|
|
1759
|
-
// http://stackoverflow.com/a/22075070
|
|
1760
|
-
'*': /./
|
|
1761
|
-
};
|
|
1762
|
-
|
|
1763
1798
|
/** */
|
|
1764
1799
|
|
|
1765
1800
|
/** */
|
|
@@ -1835,9 +1870,9 @@ class PatternInputDefinition {
|
|
|
1835
1870
|
if (this.isFilled) return new ChangeDetails();
|
|
1836
1871
|
const state = this.masked.state;
|
|
1837
1872
|
// simulate input
|
|
1838
|
-
|
|
1873
|
+
let details = this.masked._appendChar(ch, this.currentMaskFlags(flags));
|
|
1839
1874
|
if (details.inserted && this.doValidate(flags) === false) {
|
|
1840
|
-
details
|
|
1875
|
+
details = new ChangeDetails();
|
|
1841
1876
|
this.masked.state = state;
|
|
1842
1877
|
}
|
|
1843
1878
|
if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
|
|
@@ -1852,11 +1887,11 @@ class PatternInputDefinition {
|
|
|
1852
1887
|
return this.masked.append(str, this.currentMaskFlags(flags), tail);
|
|
1853
1888
|
}
|
|
1854
1889
|
_appendPlaceholder() {
|
|
1855
|
-
|
|
1856
|
-
if (this.isFilled || this.isOptional) return details;
|
|
1890
|
+
if (this.isFilled || this.isOptional) return new ChangeDetails();
|
|
1857
1891
|
this.isFilled = true;
|
|
1858
|
-
|
|
1859
|
-
|
|
1892
|
+
return new ChangeDetails({
|
|
1893
|
+
inserted: this.placeholderChar
|
|
1894
|
+
});
|
|
1860
1895
|
}
|
|
1861
1896
|
_appendEager() {
|
|
1862
1897
|
return new ChangeDetails();
|
|
@@ -1923,12 +1958,22 @@ class PatternInputDefinition {
|
|
|
1923
1958
|
this.isFilled = state.isFilled;
|
|
1924
1959
|
}
|
|
1925
1960
|
currentMaskFlags(flags) {
|
|
1961
|
+
var _flags$_beforeTailSta;
|
|
1926
1962
|
return {
|
|
1927
1963
|
...flags,
|
|
1928
|
-
_beforeTailState: flags
|
|
1964
|
+
_beforeTailState: (flags == null || (_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.masked) || (flags == null ? void 0 : flags._beforeTailState)
|
|
1929
1965
|
};
|
|
1930
1966
|
}
|
|
1967
|
+
pad(flags) {
|
|
1968
|
+
return new ChangeDetails();
|
|
1969
|
+
}
|
|
1931
1970
|
}
|
|
1971
|
+
PatternInputDefinition.DEFAULT_DEFINITIONS = {
|
|
1972
|
+
'0': /\d/,
|
|
1973
|
+
'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
|
|
1974
|
+
// http://stackoverflow.com/a/22075070
|
|
1975
|
+
'*': /./
|
|
1976
|
+
};
|
|
1932
1977
|
|
|
1933
1978
|
/** Masking by RegExp */
|
|
1934
1979
|
class MaskedRegExp extends Masked {
|
|
@@ -1940,6 +1985,8 @@ class MaskedRegExp extends Masked {
|
|
|
1940
1985
|
|
|
1941
1986
|
/** */
|
|
1942
1987
|
|
|
1988
|
+
/** */
|
|
1989
|
+
|
|
1943
1990
|
updateOptions(opts) {
|
|
1944
1991
|
super.updateOptions(opts);
|
|
1945
1992
|
}
|
|
@@ -1953,15 +2000,6 @@ IMask.MaskedRegExp = MaskedRegExp;
|
|
|
1953
2000
|
|
|
1954
2001
|
/** Pattern mask */
|
|
1955
2002
|
class MaskedPattern extends Masked {
|
|
1956
|
-
static DEFAULTS = {
|
|
1957
|
-
lazy: true,
|
|
1958
|
-
placeholderChar: '_'
|
|
1959
|
-
};
|
|
1960
|
-
static STOP_CHAR = '`';
|
|
1961
|
-
static ESCAPE_CHAR = '\\';
|
|
1962
|
-
static InputDefinition = PatternInputDefinition;
|
|
1963
|
-
static FixedDefinition = PatternFixedDefinition;
|
|
1964
|
-
|
|
1965
2003
|
/** */
|
|
1966
2004
|
|
|
1967
2005
|
/** */
|
|
@@ -1978,11 +2016,13 @@ class MaskedPattern extends Masked {
|
|
|
1978
2016
|
|
|
1979
2017
|
/** */
|
|
1980
2018
|
|
|
2019
|
+
/** */
|
|
2020
|
+
|
|
1981
2021
|
constructor(opts) {
|
|
1982
2022
|
super({
|
|
1983
2023
|
...MaskedPattern.DEFAULTS,
|
|
1984
2024
|
...opts,
|
|
1985
|
-
definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts
|
|
2025
|
+
definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts == null ? void 0 : opts.definitions)
|
|
1986
2026
|
});
|
|
1987
2027
|
}
|
|
1988
2028
|
updateOptions(opts) {
|
|
@@ -2023,6 +2063,7 @@ class MaskedPattern extends Masked {
|
|
|
2023
2063
|
placeholderChar: this.placeholderChar,
|
|
2024
2064
|
displayChar: this.displayChar,
|
|
2025
2065
|
overwrite: this.overwrite,
|
|
2066
|
+
autofix: this.autofix,
|
|
2026
2067
|
...bOpts,
|
|
2027
2068
|
repeat,
|
|
2028
2069
|
parent: this
|
|
@@ -2156,8 +2197,9 @@ class MaskedPattern extends Masked {
|
|
|
2156
2197
|
return super.appendTail(tail).aggregate(this._appendPlaceholder());
|
|
2157
2198
|
}
|
|
2158
2199
|
_appendEager() {
|
|
2200
|
+
var _this$_mapPosToBlock;
|
|
2159
2201
|
const details = new ChangeDetails();
|
|
2160
|
-
let startBlockIndex = this._mapPosToBlock(this.displayValue.length)
|
|
2202
|
+
let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index;
|
|
2161
2203
|
if (startBlockIndex == null) return details;
|
|
2162
2204
|
|
|
2163
2205
|
// TODO test if it works for nested pattern masks
|
|
@@ -2177,12 +2219,13 @@ class MaskedPattern extends Masked {
|
|
|
2177
2219
|
const details = new ChangeDetails();
|
|
2178
2220
|
if (!blockIter) return details;
|
|
2179
2221
|
for (let bi = blockIter.index, block; block = this._blocks[bi]; ++bi) {
|
|
2222
|
+
var _flags$_beforeTailSta;
|
|
2180
2223
|
const blockDetails = block._appendChar(ch, {
|
|
2181
2224
|
...flags,
|
|
2182
|
-
_beforeTailState: flags._beforeTailState
|
|
2225
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
2183
2226
|
});
|
|
2184
2227
|
details.aggregate(blockDetails);
|
|
2185
|
-
if (blockDetails.
|
|
2228
|
+
if (blockDetails.consumed) break; // go next char
|
|
2186
2229
|
}
|
|
2187
2230
|
return details;
|
|
2188
2231
|
}
|
|
@@ -2240,9 +2283,8 @@ class MaskedPattern extends Masked {
|
|
|
2240
2283
|
const endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
|
|
2241
2284
|
this._blocks.slice(startBlockIndex, endBlockIndex).forEach(b => {
|
|
2242
2285
|
if (!b.lazy || toBlockIndex != null) {
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
details.aggregate(bDetails);
|
|
2286
|
+
var _blocks2;
|
|
2287
|
+
details.aggregate(b._appendPlaceholder((_blocks2 = b._blocks) == null ? void 0 : _blocks2.length));
|
|
2246
2288
|
}
|
|
2247
2289
|
});
|
|
2248
2290
|
return details;
|
|
@@ -2390,7 +2432,21 @@ class MaskedPattern extends Masked {
|
|
|
2390
2432
|
if (!indices) return [];
|
|
2391
2433
|
return indices.map(gi => this._blocks[gi]);
|
|
2392
2434
|
}
|
|
2435
|
+
pad(flags) {
|
|
2436
|
+
const details = new ChangeDetails();
|
|
2437
|
+
this._forEachBlocksInRange(0, this.displayValue.length, b => details.aggregate(b.pad(flags)));
|
|
2438
|
+
return details;
|
|
2439
|
+
}
|
|
2393
2440
|
}
|
|
2441
|
+
MaskedPattern.DEFAULTS = {
|
|
2442
|
+
...Masked.DEFAULTS,
|
|
2443
|
+
lazy: true,
|
|
2444
|
+
placeholderChar: '_'
|
|
2445
|
+
};
|
|
2446
|
+
MaskedPattern.STOP_CHAR = '`';
|
|
2447
|
+
MaskedPattern.ESCAPE_CHAR = '\\';
|
|
2448
|
+
MaskedPattern.InputDefinition = PatternInputDefinition;
|
|
2449
|
+
MaskedPattern.FixedDefinition = PatternFixedDefinition;
|
|
2394
2450
|
IMask.MaskedPattern = MaskedPattern;
|
|
2395
2451
|
|
|
2396
2452
|
/** Pattern which accepts ranges */
|
|
@@ -2404,8 +2460,6 @@ class MaskedRange extends MaskedPattern {
|
|
|
2404
2460
|
|
|
2405
2461
|
/** Max bound */
|
|
2406
2462
|
|
|
2407
|
-
/** */
|
|
2408
|
-
|
|
2409
2463
|
get _matchFrom() {
|
|
2410
2464
|
return this.maxLength - String(this.from).length;
|
|
2411
2465
|
}
|
|
@@ -2455,23 +2509,25 @@ class MaskedRange extends MaskedPattern {
|
|
|
2455
2509
|
}
|
|
2456
2510
|
let details;
|
|
2457
2511
|
[ch, details] = super.doPrepareChar(ch.replace(/\D/g, ''), flags);
|
|
2458
|
-
if (!
|
|
2459
|
-
|
|
2460
|
-
|
|
2512
|
+
if (!ch) details.skip = !this.isComplete;
|
|
2513
|
+
return [ch, details];
|
|
2514
|
+
}
|
|
2515
|
+
_appendCharRaw(ch, flags) {
|
|
2516
|
+
if (flags === void 0) {
|
|
2517
|
+
flags = {};
|
|
2461
2518
|
}
|
|
2519
|
+
if (!this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(ch, flags);
|
|
2462
2520
|
const fromStr = String(this.from).padStart(this.maxLength, '0');
|
|
2463
2521
|
const toStr = String(this.to).padStart(this.maxLength, '0');
|
|
2464
|
-
const
|
|
2465
|
-
if (
|
|
2466
|
-
const [minstr, maxstr] = this.boundaries(nextVal);
|
|
2467
|
-
if (Number(maxstr) < this.from) return [fromStr[nextVal.length - 1], details];
|
|
2522
|
+
const [minstr, maxstr] = this.boundaries(this.value + ch);
|
|
2523
|
+
if (Number(maxstr) < this.from) return super._appendCharRaw(fromStr[this.value.length], flags);
|
|
2468
2524
|
if (Number(minstr) > this.to) {
|
|
2469
|
-
if (this.autofix === 'pad' &&
|
|
2470
|
-
return [
|
|
2525
|
+
if (!flags.tail && this.autofix === 'pad' && this.value.length + 1 < this.maxLength) {
|
|
2526
|
+
return super._appendCharRaw(fromStr[this.value.length], flags).aggregate(this._appendCharRaw(ch, flags));
|
|
2471
2527
|
}
|
|
2472
|
-
return
|
|
2528
|
+
return super._appendCharRaw(toStr[this.value.length], flags);
|
|
2473
2529
|
}
|
|
2474
|
-
return
|
|
2530
|
+
return super._appendCharRaw(ch, flags);
|
|
2475
2531
|
}
|
|
2476
2532
|
doValidate(flags) {
|
|
2477
2533
|
const str = this.value;
|
|
@@ -2480,45 +2536,27 @@ class MaskedRange extends MaskedPattern {
|
|
|
2480
2536
|
const [minstr, maxstr] = this.boundaries(str);
|
|
2481
2537
|
return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(flags);
|
|
2482
2538
|
}
|
|
2539
|
+
pad(flags) {
|
|
2540
|
+
const details = new ChangeDetails();
|
|
2541
|
+
if (this.value.length === this.maxLength) return details;
|
|
2542
|
+
const value = this.value;
|
|
2543
|
+
const padLength = this.maxLength - this.value.length;
|
|
2544
|
+
if (padLength) {
|
|
2545
|
+
this.reset();
|
|
2546
|
+
for (let i = 0; i < padLength; ++i) {
|
|
2547
|
+
details.aggregate(super._appendCharRaw('0', flags));
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
// append tail
|
|
2551
|
+
value.split('').forEach(ch => this._appendCharRaw(ch));
|
|
2552
|
+
}
|
|
2553
|
+
return details;
|
|
2554
|
+
}
|
|
2483
2555
|
}
|
|
2484
2556
|
IMask.MaskedRange = MaskedRange;
|
|
2485
2557
|
|
|
2486
2558
|
/** Date mask */
|
|
2487
2559
|
class MaskedDate extends MaskedPattern {
|
|
2488
|
-
static GET_DEFAULT_BLOCKS = () => ({
|
|
2489
|
-
d: {
|
|
2490
|
-
mask: MaskedRange,
|
|
2491
|
-
from: 1,
|
|
2492
|
-
to: 31,
|
|
2493
|
-
maxLength: 2
|
|
2494
|
-
},
|
|
2495
|
-
m: {
|
|
2496
|
-
mask: MaskedRange,
|
|
2497
|
-
from: 1,
|
|
2498
|
-
to: 12,
|
|
2499
|
-
maxLength: 2
|
|
2500
|
-
},
|
|
2501
|
-
Y: {
|
|
2502
|
-
mask: MaskedRange,
|
|
2503
|
-
from: 1900,
|
|
2504
|
-
to: 9999
|
|
2505
|
-
}
|
|
2506
|
-
});
|
|
2507
|
-
static DEFAULTS = {
|
|
2508
|
-
mask: Date,
|
|
2509
|
-
pattern: 'd{.}`m{.}`Y',
|
|
2510
|
-
format: (date, masked) => {
|
|
2511
|
-
if (!date) return '';
|
|
2512
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
2513
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
2514
|
-
const year = date.getFullYear();
|
|
2515
|
-
return [day, month, year].join('.');
|
|
2516
|
-
},
|
|
2517
|
-
parse: (str, masked) => {
|
|
2518
|
-
const [day, month, year] = str.split('.').map(Number);
|
|
2519
|
-
return new Date(year, month - 1, day);
|
|
2520
|
-
}
|
|
2521
|
-
};
|
|
2522
2560
|
static extractPatternOptions(opts) {
|
|
2523
2561
|
const {
|
|
2524
2562
|
mask,
|
|
@@ -2537,8 +2575,6 @@ class MaskedDate extends MaskedPattern {
|
|
|
2537
2575
|
|
|
2538
2576
|
/** End date */
|
|
2539
2577
|
|
|
2540
|
-
/** */
|
|
2541
|
-
|
|
2542
2578
|
/** Format typed value to string */
|
|
2543
2579
|
|
|
2544
2580
|
/** Parse string to get typed value */
|
|
@@ -2575,12 +2611,6 @@ class MaskedDate extends MaskedPattern {
|
|
|
2575
2611
|
}
|
|
2576
2612
|
}
|
|
2577
2613
|
Object.assign(patternBlocks, this.blocks, blocks);
|
|
2578
|
-
|
|
2579
|
-
// add autofix
|
|
2580
|
-
Object.keys(patternBlocks).forEach(bk => {
|
|
2581
|
-
const b = patternBlocks[bk];
|
|
2582
|
-
if (!('autofix' in b) && 'autofix' in opts) b.autofix = opts.autofix;
|
|
2583
|
-
});
|
|
2584
2614
|
super._update({
|
|
2585
2615
|
...patternOpts,
|
|
2586
2616
|
mask: isString(mask) ? mask : pattern,
|
|
@@ -2617,20 +2647,45 @@ class MaskedDate extends MaskedPattern {
|
|
|
2617
2647
|
return super.optionsIsChanged(MaskedDate.extractPatternOptions(opts));
|
|
2618
2648
|
}
|
|
2619
2649
|
}
|
|
2650
|
+
MaskedDate.GET_DEFAULT_BLOCKS = () => ({
|
|
2651
|
+
d: {
|
|
2652
|
+
mask: MaskedRange,
|
|
2653
|
+
from: 1,
|
|
2654
|
+
to: 31,
|
|
2655
|
+
maxLength: 2
|
|
2656
|
+
},
|
|
2657
|
+
m: {
|
|
2658
|
+
mask: MaskedRange,
|
|
2659
|
+
from: 1,
|
|
2660
|
+
to: 12,
|
|
2661
|
+
maxLength: 2
|
|
2662
|
+
},
|
|
2663
|
+
Y: {
|
|
2664
|
+
mask: MaskedRange,
|
|
2665
|
+
from: 1900,
|
|
2666
|
+
to: 9999
|
|
2667
|
+
}
|
|
2668
|
+
});
|
|
2669
|
+
MaskedDate.DEFAULTS = {
|
|
2670
|
+
...MaskedPattern.DEFAULTS,
|
|
2671
|
+
mask: Date,
|
|
2672
|
+
pattern: 'd{.}`m{.}`Y',
|
|
2673
|
+
format: (date, masked) => {
|
|
2674
|
+
if (!date) return '';
|
|
2675
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
2676
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
2677
|
+
const year = date.getFullYear();
|
|
2678
|
+
return [day, month, year].join('.');
|
|
2679
|
+
},
|
|
2680
|
+
parse: (str, masked) => {
|
|
2681
|
+
const [day, month, year] = str.split('.').map(Number);
|
|
2682
|
+
return new Date(year, month - 1, day);
|
|
2683
|
+
}
|
|
2684
|
+
};
|
|
2620
2685
|
IMask.MaskedDate = MaskedDate;
|
|
2621
2686
|
|
|
2622
2687
|
/** Dynamic mask for choosing appropriate mask in run-time */
|
|
2623
2688
|
class MaskedDynamic extends Masked {
|
|
2624
|
-
static DEFAULTS;
|
|
2625
|
-
|
|
2626
|
-
/** Currently chosen mask */
|
|
2627
|
-
|
|
2628
|
-
/** Currently chosen mask */
|
|
2629
|
-
|
|
2630
|
-
/** Compliled {@link Masked} options */
|
|
2631
|
-
|
|
2632
|
-
/** Chooses {@link Masked} depending on input value */
|
|
2633
|
-
|
|
2634
2689
|
constructor(opts) {
|
|
2635
2690
|
super({
|
|
2636
2691
|
...MaskedDynamic.DEFAULTS,
|
|
@@ -2690,7 +2745,7 @@ class MaskedDynamic extends Masked {
|
|
|
2690
2745
|
const tailValue = inputValue.slice(insertValue.length);
|
|
2691
2746
|
const prevMask = this.currentMask;
|
|
2692
2747
|
const details = new ChangeDetails();
|
|
2693
|
-
const prevMaskState = prevMask
|
|
2748
|
+
const prevMaskState = prevMask == null ? void 0 : prevMask.state;
|
|
2694
2749
|
|
|
2695
2750
|
// clone flags to prevent overwriting `_beforeTailState`
|
|
2696
2751
|
this.currentMask = this.doDispatch(appended, {
|
|
@@ -2703,10 +2758,10 @@ class MaskedDynamic extends Masked {
|
|
|
2703
2758
|
// if mask changed reapply input
|
|
2704
2759
|
this.currentMask.reset();
|
|
2705
2760
|
if (insertValue) {
|
|
2706
|
-
|
|
2761
|
+
this.currentMask.append(insertValue, {
|
|
2707
2762
|
raw: true
|
|
2708
2763
|
});
|
|
2709
|
-
details.tailShift =
|
|
2764
|
+
details.tailShift = this.currentMask.value.length - prevValueBeforeTail.length;
|
|
2710
2765
|
}
|
|
2711
2766
|
if (tailValue) {
|
|
2712
2767
|
details.tailShift += this.currentMask.append(tailValue, {
|
|
@@ -2742,9 +2797,10 @@ class MaskedDynamic extends Masked {
|
|
|
2742
2797
|
return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
|
|
2743
2798
|
}
|
|
2744
2799
|
currentMaskFlags(flags) {
|
|
2800
|
+
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
|
|
2745
2801
|
return {
|
|
2746
2802
|
...flags,
|
|
2747
|
-
_beforeTailState: flags._beforeTailState
|
|
2803
|
+
_beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
|
|
2748
2804
|
};
|
|
2749
2805
|
}
|
|
2750
2806
|
doDispatch(appended, flags, tail) {
|
|
@@ -2784,7 +2840,8 @@ class MaskedDynamic extends Masked {
|
|
|
2784
2840
|
return [s, details];
|
|
2785
2841
|
}
|
|
2786
2842
|
reset() {
|
|
2787
|
-
|
|
2843
|
+
var _this$currentMask;
|
|
2844
|
+
(_this$currentMask = this.currentMask) == null || _this$currentMask.reset();
|
|
2788
2845
|
this.compiledMasks.forEach(m => m.reset());
|
|
2789
2846
|
}
|
|
2790
2847
|
get value() {
|
|
@@ -2830,10 +2887,12 @@ class MaskedDynamic extends Masked {
|
|
|
2830
2887
|
return this.currentMask ? this.currentMask.displayValue : '';
|
|
2831
2888
|
}
|
|
2832
2889
|
get isComplete() {
|
|
2833
|
-
|
|
2890
|
+
var _this$currentMask2;
|
|
2891
|
+
return Boolean((_this$currentMask2 = this.currentMask) == null ? void 0 : _this$currentMask2.isComplete);
|
|
2834
2892
|
}
|
|
2835
2893
|
get isFilled() {
|
|
2836
|
-
|
|
2894
|
+
var _this$currentMask3;
|
|
2895
|
+
return Boolean((_this$currentMask3 = this.currentMask) == null ? void 0 : _this$currentMask3.isFilled);
|
|
2837
2896
|
}
|
|
2838
2897
|
remove(fromPos, toPos) {
|
|
2839
2898
|
const details = new ChangeDetails();
|
|
@@ -2845,12 +2904,13 @@ class MaskedDynamic extends Masked {
|
|
|
2845
2904
|
return details;
|
|
2846
2905
|
}
|
|
2847
2906
|
get state() {
|
|
2907
|
+
var _this$currentMask4;
|
|
2848
2908
|
return {
|
|
2849
2909
|
...super.state,
|
|
2850
2910
|
_rawInputValue: this.rawInputValue,
|
|
2851
2911
|
compiledMasks: this.compiledMasks.map(m => m.state),
|
|
2852
2912
|
currentMaskRef: this.currentMask,
|
|
2853
|
-
currentMask: this.currentMask
|
|
2913
|
+
currentMask: (_this$currentMask4 = this.currentMask) == null ? void 0 : _this$currentMask4.state
|
|
2854
2914
|
};
|
|
2855
2915
|
}
|
|
2856
2916
|
set state(state) {
|
|
@@ -2898,6 +2958,12 @@ class MaskedDynamic extends Masked {
|
|
|
2898
2958
|
set skipInvalid(skipInvalid) {
|
|
2899
2959
|
this._skipInvalid = skipInvalid;
|
|
2900
2960
|
}
|
|
2961
|
+
get autofix() {
|
|
2962
|
+
return this.currentMask ? this.currentMask.autofix : this._autofix;
|
|
2963
|
+
}
|
|
2964
|
+
set autofix(autofix) {
|
|
2965
|
+
this._autofix = autofix;
|
|
2966
|
+
}
|
|
2901
2967
|
maskEquals(mask) {
|
|
2902
2968
|
return Array.isArray(mask) ? this.compiledMasks.every((m, mi) => {
|
|
2903
2969
|
if (!mask[mi]) return;
|
|
@@ -2909,10 +2975,16 @@ class MaskedDynamic extends Masked {
|
|
|
2909
2975
|
}) : super.maskEquals(mask);
|
|
2910
2976
|
}
|
|
2911
2977
|
typedValueEquals(value) {
|
|
2912
|
-
|
|
2978
|
+
var _this$currentMask5;
|
|
2979
|
+
return Boolean((_this$currentMask5 = this.currentMask) == null ? void 0 : _this$currentMask5.typedValueEquals(value));
|
|
2913
2980
|
}
|
|
2914
2981
|
}
|
|
2982
|
+
/** Currently chosen mask */
|
|
2983
|
+
/** Currently chosen mask */
|
|
2984
|
+
/** Compliled {@link Masked} options */
|
|
2985
|
+
/** Chooses {@link Masked} depending on input value */
|
|
2915
2986
|
MaskedDynamic.DEFAULTS = {
|
|
2987
|
+
...Masked.DEFAULTS,
|
|
2916
2988
|
dispatch: (appended, masked, flags, tail) => {
|
|
2917
2989
|
if (!masked.compiledMasks.length) return;
|
|
2918
2990
|
const inputValue = masked.rawInputValue;
|
|
@@ -2948,30 +3020,88 @@ IMask.MaskedDynamic = MaskedDynamic;
|
|
|
2948
3020
|
/** Pattern which validates enum values */
|
|
2949
3021
|
class MaskedEnum extends MaskedPattern {
|
|
2950
3022
|
constructor(opts) {
|
|
2951
|
-
super(
|
|
3023
|
+
super({
|
|
3024
|
+
...MaskedEnum.DEFAULTS,
|
|
3025
|
+
...opts
|
|
3026
|
+
}); // mask will be created in _update
|
|
2952
3027
|
}
|
|
2953
3028
|
updateOptions(opts) {
|
|
2954
3029
|
super.updateOptions(opts);
|
|
2955
3030
|
}
|
|
2956
3031
|
_update(opts) {
|
|
2957
3032
|
const {
|
|
2958
|
-
enum:
|
|
3033
|
+
enum: enum_,
|
|
2959
3034
|
...eopts
|
|
2960
3035
|
} = opts;
|
|
2961
|
-
if (
|
|
2962
|
-
const lengths =
|
|
3036
|
+
if (enum_) {
|
|
3037
|
+
const lengths = enum_.map(e => e.length);
|
|
2963
3038
|
const requiredLength = Math.min(...lengths);
|
|
2964
3039
|
const optionalLength = Math.max(...lengths) - requiredLength;
|
|
2965
3040
|
eopts.mask = '*'.repeat(requiredLength);
|
|
2966
3041
|
if (optionalLength) eopts.mask += '[' + '*'.repeat(optionalLength) + ']';
|
|
2967
|
-
this.enum =
|
|
3042
|
+
this.enum = enum_;
|
|
2968
3043
|
}
|
|
2969
3044
|
super._update(eopts);
|
|
2970
3045
|
}
|
|
2971
|
-
|
|
2972
|
-
|
|
3046
|
+
_appendCharRaw(ch, flags) {
|
|
3047
|
+
if (flags === void 0) {
|
|
3048
|
+
flags = {};
|
|
3049
|
+
}
|
|
3050
|
+
const matchFrom = Math.min(this.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
3051
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.unmaskedValue + ch, matchFrom));
|
|
3052
|
+
if (matches.length) {
|
|
3053
|
+
if (matches.length === 1) {
|
|
3054
|
+
this._forEachBlocksInRange(0, this.value.length, (b, bi) => {
|
|
3055
|
+
const mch = matches[0][bi];
|
|
3056
|
+
if (bi >= this.value.length || mch === b.value) return;
|
|
3057
|
+
b.reset();
|
|
3058
|
+
b._appendChar(mch, flags);
|
|
3059
|
+
});
|
|
3060
|
+
}
|
|
3061
|
+
const d = super._appendCharRaw(matches[0][this.value.length], flags);
|
|
3062
|
+
if (matches.length === 1) {
|
|
3063
|
+
matches[0].slice(this.unmaskedValue.length).split('').forEach(mch => d.aggregate(super._appendCharRaw(mch)));
|
|
3064
|
+
}
|
|
3065
|
+
return d;
|
|
3066
|
+
}
|
|
3067
|
+
return new ChangeDetails({
|
|
3068
|
+
skip: !this.isComplete
|
|
3069
|
+
});
|
|
3070
|
+
}
|
|
3071
|
+
extractTail(fromPos, toPos) {
|
|
3072
|
+
if (fromPos === void 0) {
|
|
3073
|
+
fromPos = 0;
|
|
3074
|
+
}
|
|
3075
|
+
// just drop tail
|
|
3076
|
+
return new ContinuousTailDetails('', fromPos);
|
|
3077
|
+
}
|
|
3078
|
+
remove(fromPos, toPos) {
|
|
3079
|
+
if (fromPos === void 0) {
|
|
3080
|
+
fromPos = 0;
|
|
3081
|
+
}
|
|
3082
|
+
if (toPos === void 0) {
|
|
3083
|
+
toPos = this.displayValue.length;
|
|
3084
|
+
}
|
|
3085
|
+
if (fromPos === toPos) return new ChangeDetails();
|
|
3086
|
+
const matchFrom = Math.min(super.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
3087
|
+
let pos;
|
|
3088
|
+
for (pos = fromPos; pos >= 0; --pos) {
|
|
3089
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.value.slice(matchFrom, pos), matchFrom));
|
|
3090
|
+
if (matches.length > 1) break;
|
|
3091
|
+
}
|
|
3092
|
+
const details = super.remove(pos, toPos);
|
|
3093
|
+
details.tailShift += pos - fromPos;
|
|
3094
|
+
return details;
|
|
3095
|
+
}
|
|
3096
|
+
get isComplete() {
|
|
3097
|
+
return this.enum.indexOf(this.value) >= 0;
|
|
2973
3098
|
}
|
|
2974
3099
|
}
|
|
3100
|
+
/** Match enum value */
|
|
3101
|
+
MaskedEnum.DEFAULTS = {
|
|
3102
|
+
...MaskedPattern.DEFAULTS,
|
|
3103
|
+
matchValue: (estr, istr, matchFrom) => estr.indexOf(istr, matchFrom) === matchFrom
|
|
3104
|
+
};
|
|
2975
3105
|
IMask.MaskedEnum = MaskedEnum;
|
|
2976
3106
|
|
|
2977
3107
|
/** Masking by custom Function */
|
|
@@ -2984,6 +3114,8 @@ class MaskedFunction extends Masked {
|
|
|
2984
3114
|
|
|
2985
3115
|
/** */
|
|
2986
3116
|
|
|
3117
|
+
/** */
|
|
3118
|
+
|
|
2987
3119
|
updateOptions(opts) {
|
|
2988
3120
|
super.updateOptions(opts);
|
|
2989
3121
|
}
|
|
@@ -2996,27 +3128,9 @@ class MaskedFunction extends Masked {
|
|
|
2996
3128
|
}
|
|
2997
3129
|
IMask.MaskedFunction = MaskedFunction;
|
|
2998
3130
|
|
|
3131
|
+
var _MaskedNumber;
|
|
2999
3132
|
/** Number mask */
|
|
3000
3133
|
class MaskedNumber extends Masked {
|
|
3001
|
-
static UNMASKED_RADIX = '.';
|
|
3002
|
-
static EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
|
|
3003
|
-
static DEFAULTS = {
|
|
3004
|
-
mask: Number,
|
|
3005
|
-
radix: ',',
|
|
3006
|
-
thousandsSeparator: '',
|
|
3007
|
-
mapToRadix: [MaskedNumber.UNMASKED_RADIX],
|
|
3008
|
-
min: Number.MIN_SAFE_INTEGER,
|
|
3009
|
-
max: Number.MAX_SAFE_INTEGER,
|
|
3010
|
-
scale: 2,
|
|
3011
|
-
normalizeZeros: true,
|
|
3012
|
-
padFractionalZeros: false,
|
|
3013
|
-
parse: Number,
|
|
3014
|
-
format: n => n.toLocaleString('en-US', {
|
|
3015
|
-
useGrouping: false,
|
|
3016
|
-
maximumFractionDigits: 20
|
|
3017
|
-
})
|
|
3018
|
-
};
|
|
3019
|
-
|
|
3020
3134
|
/** Single char */
|
|
3021
3135
|
|
|
3022
3136
|
/** Single char */
|
|
@@ -3039,6 +3153,8 @@ class MaskedNumber extends Masked {
|
|
|
3039
3153
|
|
|
3040
3154
|
/** */
|
|
3041
3155
|
|
|
3156
|
+
/** */
|
|
3157
|
+
|
|
3042
3158
|
/** Format typed value to string */
|
|
3043
3159
|
|
|
3044
3160
|
/** Parse string to get typed value */
|
|
@@ -3059,9 +3175,9 @@ class MaskedNumber extends Masked {
|
|
|
3059
3175
|
_updateRegExps() {
|
|
3060
3176
|
const start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
|
|
3061
3177
|
const mid = '\\d*';
|
|
3062
|
-
const end = (this.scale ?
|
|
3178
|
+
const end = (this.scale ? "(" + escapeRegExp(this.radix) + "\\d{0," + this.scale + "})?" : '') + '$';
|
|
3063
3179
|
this._numberRegExp = new RegExp(start + mid + end);
|
|
3064
|
-
this._mapToRadixRegExp = new RegExp(
|
|
3180
|
+
this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(escapeRegExp).join('') + "]", 'g');
|
|
3065
3181
|
this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
|
|
3066
3182
|
}
|
|
3067
3183
|
_removeThousandsSeparators(value) {
|
|
@@ -3124,16 +3240,43 @@ class MaskedNumber extends Masked {
|
|
|
3124
3240
|
if (flags === void 0) {
|
|
3125
3241
|
flags = {};
|
|
3126
3242
|
}
|
|
3127
|
-
if (!this.thousandsSeparator) return super._appendCharRaw(ch, flags);
|
|
3128
3243
|
const prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
3129
3244
|
const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
|
|
3130
3245
|
this._value = this._removeThousandsSeparators(this.value);
|
|
3131
|
-
const
|
|
3246
|
+
const oldValue = this._value;
|
|
3247
|
+
this._value += ch;
|
|
3248
|
+
const num = this.number;
|
|
3249
|
+
let accepted = !isNaN(num);
|
|
3250
|
+
let skip = false;
|
|
3251
|
+
if (accepted) {
|
|
3252
|
+
let fixedNum;
|
|
3253
|
+
if (this.min != null && this.min < 0 && this.number < this.min) fixedNum = this.min;
|
|
3254
|
+
if (this.max != null && this.max > 0 && this.number > this.max) fixedNum = this.max;
|
|
3255
|
+
if (fixedNum != null) {
|
|
3256
|
+
if (this.autofix) {
|
|
3257
|
+
this._value = this.format(fixedNum, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
|
|
3258
|
+
skip || (skip = oldValue === this._value && !flags.tail); // if not changed on tail it's still ok to proceed
|
|
3259
|
+
} else {
|
|
3260
|
+
accepted = false;
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
accepted && (accepted = Boolean(this._value.match(this._numberRegExp)));
|
|
3264
|
+
}
|
|
3265
|
+
let appendDetails;
|
|
3266
|
+
if (!accepted) {
|
|
3267
|
+
this._value = oldValue;
|
|
3268
|
+
appendDetails = new ChangeDetails();
|
|
3269
|
+
} else {
|
|
3270
|
+
appendDetails = new ChangeDetails({
|
|
3271
|
+
inserted: this._value.slice(oldValue.length),
|
|
3272
|
+
rawInserted: skip ? '' : ch,
|
|
3273
|
+
skip
|
|
3274
|
+
});
|
|
3275
|
+
}
|
|
3132
3276
|
this._value = this._insertThousandsSeparators(this._value);
|
|
3133
3277
|
const beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
3134
3278
|
const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
|
|
3135
3279
|
appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
|
|
3136
|
-
appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
|
|
3137
3280
|
return appendDetails;
|
|
3138
3281
|
}
|
|
3139
3282
|
_findSeparatorAround(pos) {
|
|
@@ -3195,20 +3338,6 @@ class MaskedNumber extends Masked {
|
|
|
3195
3338
|
}
|
|
3196
3339
|
return cursorPos;
|
|
3197
3340
|
}
|
|
3198
|
-
doValidate(flags) {
|
|
3199
|
-
// validate as string
|
|
3200
|
-
let valid = Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));
|
|
3201
|
-
if (valid) {
|
|
3202
|
-
// validate as number
|
|
3203
|
-
const number = this.number;
|
|
3204
|
-
valid = valid && !isNaN(number) && (
|
|
3205
|
-
// check min bound for negative values
|
|
3206
|
-
this.min == null || this.min >= 0 || this.min <= this.number) && (
|
|
3207
|
-
// check max bound for positive values
|
|
3208
|
-
this.max == null || this.max <= 0 || this.number <= this.max);
|
|
3209
|
-
}
|
|
3210
|
-
return valid && super.doValidate(flags);
|
|
3211
|
-
}
|
|
3212
3341
|
doCommit() {
|
|
3213
3342
|
if (this.value) {
|
|
3214
3343
|
const number = this.number;
|
|
@@ -3284,6 +3413,26 @@ class MaskedNumber extends Masked {
|
|
|
3284
3413
|
return (super.typedValueEquals(value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
|
|
3285
3414
|
}
|
|
3286
3415
|
}
|
|
3416
|
+
_MaskedNumber = MaskedNumber;
|
|
3417
|
+
MaskedNumber.UNMASKED_RADIX = '.';
|
|
3418
|
+
MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
|
|
3419
|
+
MaskedNumber.DEFAULTS = {
|
|
3420
|
+
...Masked.DEFAULTS,
|
|
3421
|
+
mask: Number,
|
|
3422
|
+
radix: ',',
|
|
3423
|
+
thousandsSeparator: '',
|
|
3424
|
+
mapToRadix: [_MaskedNumber.UNMASKED_RADIX],
|
|
3425
|
+
min: Number.MIN_SAFE_INTEGER,
|
|
3426
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
3427
|
+
scale: 2,
|
|
3428
|
+
normalizeZeros: true,
|
|
3429
|
+
padFractionalZeros: false,
|
|
3430
|
+
parse: Number,
|
|
3431
|
+
format: n => n.toLocaleString('en-US', {
|
|
3432
|
+
useGrouping: false,
|
|
3433
|
+
maximumFractionDigits: 20
|
|
3434
|
+
})
|
|
3435
|
+
};
|
|
3287
3436
|
IMask.MaskedNumber = MaskedNumber;
|
|
3288
3437
|
|
|
3289
3438
|
/** Mask pipe source and destination types */
|
|
@@ -3318,10 +3467,12 @@ IMask.pipe = pipe;
|
|
|
3318
3467
|
/** Pattern mask */
|
|
3319
3468
|
class RepeatBlock extends MaskedPattern {
|
|
3320
3469
|
get repeatFrom() {
|
|
3321
|
-
|
|
3470
|
+
var _ref;
|
|
3471
|
+
return (_ref = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === Infinity ? 0 : this.repeat) != null ? _ref : 0;
|
|
3322
3472
|
}
|
|
3323
3473
|
get repeatTo() {
|
|
3324
|
-
|
|
3474
|
+
var _ref2;
|
|
3475
|
+
return (_ref2 = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? _ref2 : Infinity;
|
|
3325
3476
|
}
|
|
3326
3477
|
constructor(opts) {
|
|
3327
3478
|
super(opts);
|
|
@@ -3330,16 +3481,17 @@ class RepeatBlock extends MaskedPattern {
|
|
|
3330
3481
|
super.updateOptions(opts);
|
|
3331
3482
|
}
|
|
3332
3483
|
_update(opts) {
|
|
3484
|
+
var _ref3, _ref4, _this$_blocks;
|
|
3333
3485
|
const {
|
|
3334
3486
|
repeat,
|
|
3335
3487
|
...blockOpts
|
|
3336
3488
|
} = normalizeOpts(opts); // TODO type
|
|
3337
3489
|
this._blockOpts = Object.assign({}, this._blockOpts, blockOpts);
|
|
3338
3490
|
const block = createMask(this._blockOpts);
|
|
3339
|
-
this.repeat = repeat
|
|
3491
|
+
this.repeat = (_ref3 = (_ref4 = repeat != null ? repeat : block.repeat) != null ? _ref4 : this.repeat) != null ? _ref3 : Infinity; // TODO type
|
|
3340
3492
|
|
|
3341
3493
|
super._update({
|
|
3342
|
-
mask: 'm'.repeat(Math.max(this.repeatTo === Infinity && this._blocks
|
|
3494
|
+
mask: 'm'.repeat(Math.max(this.repeatTo === Infinity && ((_this$_blocks = this._blocks) == null ? void 0 : _this$_blocks.length) || 0, this.repeatFrom)),
|
|
3343
3495
|
blocks: {
|
|
3344
3496
|
m: block
|
|
3345
3497
|
},
|
|
@@ -3364,13 +3516,14 @@ class RepeatBlock extends MaskedPattern {
|
|
|
3364
3516
|
flags = {};
|
|
3365
3517
|
}
|
|
3366
3518
|
const details = new ChangeDetails();
|
|
3367
|
-
for (let bi = this._mapPosToBlock(this.displayValue.length)
|
|
3519
|
+
for (let bi = (_this$_mapPosToBlock$ = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index) != null ? _this$_mapPosToBlock$ : Math.max(this._blocks.length - 1, 0), block, allocated;
|
|
3368
3520
|
// try to get a block or
|
|
3369
3521
|
// try to allocate a new block if not allocated already
|
|
3370
|
-
block = this._blocks[bi]
|
|
3522
|
+
block = (_this$_blocks$bi = this._blocks[bi]) != null ? _this$_blocks$bi : allocated = !allocated && this._allocateBlock(bi); ++bi) {
|
|
3523
|
+
var _this$_mapPosToBlock$, _this$_mapPosToBlock, _this$_blocks$bi, _flags$_beforeTailSta;
|
|
3371
3524
|
const blockDetails = block._appendChar(ch, {
|
|
3372
3525
|
...flags,
|
|
3373
|
-
_beforeTailState: flags._beforeTailState
|
|
3526
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
3374
3527
|
});
|
|
3375
3528
|
if (blockDetails.skip && allocated) {
|
|
3376
3529
|
// remove the last allocated block and break
|
|
@@ -3379,17 +3532,18 @@ class RepeatBlock extends MaskedPattern {
|
|
|
3379
3532
|
break;
|
|
3380
3533
|
}
|
|
3381
3534
|
details.aggregate(blockDetails);
|
|
3382
|
-
if (blockDetails.
|
|
3535
|
+
if (blockDetails.consumed) break; // go next char
|
|
3383
3536
|
}
|
|
3384
3537
|
return details;
|
|
3385
3538
|
}
|
|
3386
3539
|
_trimEmptyTail(fromPos, toPos) {
|
|
3540
|
+
var _this$_mapPosToBlock2, _this$_mapPosToBlock3;
|
|
3387
3541
|
if (fromPos === void 0) {
|
|
3388
3542
|
fromPos = 0;
|
|
3389
3543
|
}
|
|
3390
|
-
const firstBlockIndex = Math.max(this._mapPosToBlock(fromPos)
|
|
3544
|
+
const firstBlockIndex = Math.max(((_this$_mapPosToBlock2 = this._mapPosToBlock(fromPos)) == null ? void 0 : _this$_mapPosToBlock2.index) || 0, this.repeatFrom, 0);
|
|
3391
3545
|
let lastBlockIndex;
|
|
3392
|
-
if (toPos != null) lastBlockIndex = this._mapPosToBlock(toPos)
|
|
3546
|
+
if (toPos != null) lastBlockIndex = (_this$_mapPosToBlock3 = this._mapPosToBlock(toPos)) == null ? void 0 : _this$_mapPosToBlock3.index;
|
|
3393
3547
|
if (lastBlockIndex == null) lastBlockIndex = this._blocks.length - 1;
|
|
3394
3548
|
let removeCount = 0;
|
|
3395
3549
|
for (let blockIndex = lastBlockIndex; firstBlockIndex <= blockIndex; --blockIndex, ++removeCount) {
|