@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
|
@@ -7,7 +7,8 @@ function isString(str) {
|
|
|
7
7
|
|
|
8
8
|
/** Checks if value is object */
|
|
9
9
|
function isObject(obj) {
|
|
10
|
-
|
|
10
|
+
var _obj$constructor;
|
|
11
|
+
return typeof obj === 'object' && obj != null && (obj == null || (_obj$constructor = obj.constructor) == null ? void 0 : _obj$constructor.name) === 'Object';
|
|
11
12
|
}
|
|
12
13
|
function pick(obj, keys) {
|
|
13
14
|
if (Array.isArray(keys)) return pick(obj, (_, k) => keys.includes(k));
|
|
@@ -95,10 +96,11 @@ class ActionDetails {
|
|
|
95
96
|
while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {
|
|
96
97
|
--this.oldSelection.start;
|
|
97
98
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
if (this.insertedCount) {
|
|
100
|
+
// double check right part
|
|
101
|
+
while (this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end)) {
|
|
102
|
+
if (this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end) ++this.oldSelection.end;else ++this.cursorPos;
|
|
103
|
+
}
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
106
|
|
|
@@ -264,7 +266,7 @@ function createMask(opts) {
|
|
|
264
266
|
if (IMask.Masked && opts instanceof IMask.Masked) return opts;
|
|
265
267
|
const nOpts = normalizeOpts(opts);
|
|
266
268
|
const MaskedClass = maskedClass(nOpts.mask);
|
|
267
|
-
if (!MaskedClass) throw new Error(
|
|
269
|
+
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.");
|
|
268
270
|
if (nOpts.mask === MaskedClass) delete nOpts.mask;
|
|
269
271
|
if (nOpts._mask) {
|
|
270
272
|
nOpts.mask = nOpts._mask;
|
|
@@ -336,7 +338,8 @@ class HTMLMaskElement extends MaskElement {
|
|
|
336
338
|
this._onCompositionEnd = this._onCompositionEnd.bind(this);
|
|
337
339
|
}
|
|
338
340
|
get rootElement() {
|
|
339
|
-
|
|
341
|
+
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
|
|
342
|
+
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;
|
|
340
343
|
}
|
|
341
344
|
|
|
342
345
|
/** Is element in focus */
|
|
@@ -481,9 +484,10 @@ class HTMLContenteditableMaskElement extends HTMLMaskElement {
|
|
|
481
484
|
IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
|
|
482
485
|
|
|
483
486
|
class InputHistory {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
+
constructor() {
|
|
488
|
+
this.states = [];
|
|
489
|
+
this.currentIndex = 0;
|
|
490
|
+
}
|
|
487
491
|
get currentState() {
|
|
488
492
|
return this.states[this.currentIndex];
|
|
489
493
|
}
|
|
@@ -512,6 +516,7 @@ class InputHistory {
|
|
|
512
516
|
this.currentIndex = 0;
|
|
513
517
|
}
|
|
514
518
|
}
|
|
519
|
+
InputHistory.MAX_LENGTH = 100;
|
|
515
520
|
|
|
516
521
|
/** Listens to element events and controls changes between element and {@link Masked} */
|
|
517
522
|
class InputMask {
|
|
@@ -542,11 +547,11 @@ class InputMask {
|
|
|
542
547
|
this._bindEvents();
|
|
543
548
|
|
|
544
549
|
// refresh
|
|
545
|
-
this.updateValue();
|
|
546
550
|
this._onChange();
|
|
547
551
|
}
|
|
548
552
|
maskEquals(mask) {
|
|
549
|
-
|
|
553
|
+
var _this$masked;
|
|
554
|
+
return mask == null || ((_this$masked = this.masked) == null ? void 0 : _this$masked.maskEquals(mask));
|
|
550
555
|
}
|
|
551
556
|
|
|
552
557
|
/** Masked */
|
|
@@ -672,6 +677,8 @@ class InputMask {
|
|
|
672
677
|
updateValue() {
|
|
673
678
|
this.masked.value = this.el.value;
|
|
674
679
|
this._value = this.masked.value;
|
|
680
|
+
this._unmaskedValue = this.masked.unmaskedValue;
|
|
681
|
+
this._rawInputValue = this.masked.rawInputValue;
|
|
675
682
|
}
|
|
676
683
|
|
|
677
684
|
/** Syncronizes view from model value, fires change events */
|
|
@@ -804,9 +811,7 @@ class InputMask {
|
|
|
804
811
|
|
|
805
812
|
/** Handles view change event and commits model value */
|
|
806
813
|
_onChange() {
|
|
807
|
-
if (this.displayValue !== this.el.value)
|
|
808
|
-
this.updateValue();
|
|
809
|
-
}
|
|
814
|
+
if (this.displayValue !== this.el.value) this.updateValue();
|
|
810
815
|
this.masked.doCommit();
|
|
811
816
|
this.updateControl();
|
|
812
817
|
this._saveSelection();
|
|
@@ -855,12 +860,12 @@ IMask.InputMask = InputMask;
|
|
|
855
860
|
class ChangeDetails {
|
|
856
861
|
/** Inserted symbols */
|
|
857
862
|
|
|
858
|
-
/** Can skip chars */
|
|
859
|
-
|
|
860
863
|
/** Additional offset if any changes occurred before tail */
|
|
861
864
|
|
|
862
865
|
/** Raw inserted is used by dynamic mask */
|
|
863
866
|
|
|
867
|
+
/** Can skip chars */
|
|
868
|
+
|
|
864
869
|
static normalize(prep) {
|
|
865
870
|
return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
|
|
866
871
|
}
|
|
@@ -868,17 +873,17 @@ class ChangeDetails {
|
|
|
868
873
|
Object.assign(this, {
|
|
869
874
|
inserted: '',
|
|
870
875
|
rawInserted: '',
|
|
871
|
-
|
|
872
|
-
|
|
876
|
+
tailShift: 0,
|
|
877
|
+
skip: false
|
|
873
878
|
}, details);
|
|
874
879
|
}
|
|
875
880
|
|
|
876
881
|
/** Aggregate changes */
|
|
877
882
|
aggregate(details) {
|
|
878
|
-
this.rawInserted += details.rawInserted;
|
|
879
|
-
this.skip = this.skip || details.skip;
|
|
880
883
|
this.inserted += details.inserted;
|
|
884
|
+
this.rawInserted += details.rawInserted;
|
|
881
885
|
this.tailShift += details.tailShift;
|
|
886
|
+
this.skip = this.skip || details.skip;
|
|
882
887
|
return this;
|
|
883
888
|
}
|
|
884
889
|
|
|
@@ -886,6 +891,12 @@ class ChangeDetails {
|
|
|
886
891
|
get offset() {
|
|
887
892
|
return this.tailShift + this.inserted.length;
|
|
888
893
|
}
|
|
894
|
+
get consumed() {
|
|
895
|
+
return Boolean(this.rawInserted) || this.skip;
|
|
896
|
+
}
|
|
897
|
+
equals(details) {
|
|
898
|
+
return this.inserted === details.inserted && this.tailShift === details.tailShift && this.rawInserted === details.rawInserted && this.skip === details.skip;
|
|
899
|
+
}
|
|
889
900
|
}
|
|
890
901
|
IMask.ChangeDetails = ChangeDetails;
|
|
891
902
|
|
|
@@ -951,11 +962,6 @@ class ContinuousTailDetails {
|
|
|
951
962
|
|
|
952
963
|
/** Provides common masking stuff */
|
|
953
964
|
class Masked {
|
|
954
|
-
static DEFAULTS = {
|
|
955
|
-
skipInvalid: true
|
|
956
|
-
};
|
|
957
|
-
static EMPTY_VALUES = [undefined, null, ''];
|
|
958
|
-
|
|
959
965
|
/** */
|
|
960
966
|
|
|
961
967
|
/** */
|
|
@@ -980,6 +986,8 @@ class Masked {
|
|
|
980
986
|
|
|
981
987
|
/** */
|
|
982
988
|
|
|
989
|
+
/** */
|
|
990
|
+
|
|
983
991
|
constructor(opts) {
|
|
984
992
|
this._value = '';
|
|
985
993
|
this._update({
|
|
@@ -1133,7 +1141,28 @@ class Masked {
|
|
|
1133
1141
|
const consistentState = this.state;
|
|
1134
1142
|
let details;
|
|
1135
1143
|
[ch, details] = this.doPrepareChar(ch, flags);
|
|
1136
|
-
if (ch)
|
|
1144
|
+
if (ch) {
|
|
1145
|
+
details = details.aggregate(this._appendCharRaw(ch, flags));
|
|
1146
|
+
|
|
1147
|
+
// TODO handle `skip`?
|
|
1148
|
+
|
|
1149
|
+
// try `autofix` lookahead
|
|
1150
|
+
if (!details.rawInserted && this.autofix === 'pad') {
|
|
1151
|
+
const noFixState = this.state;
|
|
1152
|
+
this.state = consistentState;
|
|
1153
|
+
let fixDetails = this.pad(flags);
|
|
1154
|
+
const chDetails = this._appendCharRaw(ch, flags);
|
|
1155
|
+
fixDetails = fixDetails.aggregate(chDetails);
|
|
1156
|
+
|
|
1157
|
+
// if fix was applied or
|
|
1158
|
+
// if details are equal use skip restoring state optimization
|
|
1159
|
+
if (chDetails.rawInserted || fixDetails.equals(details)) {
|
|
1160
|
+
details = fixDetails;
|
|
1161
|
+
} else {
|
|
1162
|
+
this.state = noFixState;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1137
1166
|
if (details.inserted) {
|
|
1138
1167
|
let consistentTail;
|
|
1139
1168
|
let appended = this.doValidate(flags) !== false;
|
|
@@ -1188,7 +1217,7 @@ class Masked {
|
|
|
1188
1217
|
append(str, flags, tail) {
|
|
1189
1218
|
if (!isString(str)) throw new Error('value should be string');
|
|
1190
1219
|
const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
|
|
1191
|
-
if (flags
|
|
1220
|
+
if (flags != null && flags.tail) flags._beforeTailState = this.state;
|
|
1192
1221
|
let details;
|
|
1193
1222
|
[str, details] = this.doPrepare(str, flags);
|
|
1194
1223
|
for (let ci = 0; ci < str.length; ++ci) {
|
|
@@ -1196,7 +1225,7 @@ class Masked {
|
|
|
1196
1225
|
if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
|
|
1197
1226
|
details.aggregate(d);
|
|
1198
1227
|
}
|
|
1199
|
-
if ((this.eager === true || this.eager === 'append') && flags
|
|
1228
|
+
if ((this.eager === true || this.eager === 'append') && flags != null && flags.input && str) {
|
|
1200
1229
|
details.aggregate(this._appendEager());
|
|
1201
1230
|
}
|
|
1202
1231
|
|
|
@@ -1275,6 +1304,9 @@ class Masked {
|
|
|
1275
1304
|
if (this.commit) this.commit(this.value, this);
|
|
1276
1305
|
}
|
|
1277
1306
|
splice(start, deleteCount, inserted, removeDirection, flags) {
|
|
1307
|
+
if (inserted === void 0) {
|
|
1308
|
+
inserted = '';
|
|
1309
|
+
}
|
|
1278
1310
|
if (removeDirection === void 0) {
|
|
1279
1311
|
removeDirection = DIRECTION.NONE;
|
|
1280
1312
|
}
|
|
@@ -1328,7 +1360,14 @@ class Masked {
|
|
|
1328
1360
|
const tval = this.typedValue;
|
|
1329
1361
|
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);
|
|
1330
1362
|
}
|
|
1363
|
+
pad(flags) {
|
|
1364
|
+
return new ChangeDetails();
|
|
1365
|
+
}
|
|
1331
1366
|
}
|
|
1367
|
+
Masked.DEFAULTS = {
|
|
1368
|
+
skipInvalid: true
|
|
1369
|
+
};
|
|
1370
|
+
Masked.EMPTY_VALUES = [undefined, null, ''];
|
|
1332
1371
|
IMask.Masked = Masked;
|
|
1333
1372
|
|
|
1334
1373
|
class ChunksTailDetails {
|
|
@@ -1390,7 +1429,7 @@ class ChunksTailDetails {
|
|
|
1390
1429
|
return tail.appendTo(masked);
|
|
1391
1430
|
}
|
|
1392
1431
|
const details = new ChangeDetails();
|
|
1393
|
-
for (let ci = 0; ci < this.chunks.length
|
|
1432
|
+
for (let ci = 0; ci < this.chunks.length; ++ci) {
|
|
1394
1433
|
const chunk = this.chunks[ci];
|
|
1395
1434
|
const lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);
|
|
1396
1435
|
const stop = chunk.stop;
|
|
@@ -1401,16 +1440,13 @@ class ChunksTailDetails {
|
|
|
1401
1440
|
if (chunk instanceof ChunksTailDetails ||
|
|
1402
1441
|
// for continuous block also check if stop is exist
|
|
1403
1442
|
masked._stops.indexOf(stop) >= 0) {
|
|
1404
|
-
|
|
1405
|
-
details.aggregate(phDetails);
|
|
1443
|
+
details.aggregate(masked._appendPlaceholder(stop));
|
|
1406
1444
|
}
|
|
1407
1445
|
chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
|
|
1408
1446
|
}
|
|
1409
1447
|
if (chunkBlock) {
|
|
1410
1448
|
const tailDetails = chunkBlock.appendTail(chunk);
|
|
1411
|
-
tailDetails.skip = false; // always ignore skip, it will be set on last
|
|
1412
1449
|
details.aggregate(tailDetails);
|
|
1413
|
-
masked._value += tailDetails.inserted;
|
|
1414
1450
|
|
|
1415
1451
|
// get not inserted chars
|
|
1416
1452
|
const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
|
|
@@ -1545,7 +1581,8 @@ class PatternCursor {
|
|
|
1545
1581
|
}
|
|
1546
1582
|
_pushLeft(fn) {
|
|
1547
1583
|
this.pushState();
|
|
1548
|
-
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = this.block
|
|
1584
|
+
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) == null ? void 0 : _this$block.displayValue.length) || 0) {
|
|
1585
|
+
var _this$block;
|
|
1549
1586
|
if (fn()) return this.ok = true;
|
|
1550
1587
|
}
|
|
1551
1588
|
return this.ok = false;
|
|
@@ -1706,13 +1743,15 @@ class PatternFixedDefinition {
|
|
|
1706
1743
|
if (flags === void 0) {
|
|
1707
1744
|
flags = {};
|
|
1708
1745
|
}
|
|
1709
|
-
|
|
1710
|
-
if (this.isFilled) return details;
|
|
1746
|
+
if (this.isFilled) return new ChangeDetails();
|
|
1711
1747
|
const appendEager = this.eager === true || this.eager === 'append';
|
|
1712
1748
|
const appended = this.char === ch;
|
|
1713
1749
|
const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
|
|
1714
|
-
|
|
1715
|
-
|
|
1750
|
+
const details = new ChangeDetails({
|
|
1751
|
+
inserted: this.char,
|
|
1752
|
+
rawInserted: isResolved ? this.char : ''
|
|
1753
|
+
});
|
|
1754
|
+
this._value = this.char;
|
|
1716
1755
|
this._isRawInput = isResolved && (flags.raw || flags.input);
|
|
1717
1756
|
return details;
|
|
1718
1757
|
}
|
|
@@ -1752,16 +1791,12 @@ class PatternFixedDefinition {
|
|
|
1752
1791
|
this._value = state._value;
|
|
1753
1792
|
this._isRawInput = Boolean(state._rawInputValue);
|
|
1754
1793
|
}
|
|
1794
|
+
pad(flags) {
|
|
1795
|
+
return this._appendPlaceholder();
|
|
1796
|
+
}
|
|
1755
1797
|
}
|
|
1756
1798
|
|
|
1757
1799
|
class PatternInputDefinition {
|
|
1758
|
-
static DEFAULT_DEFINITIONS = {
|
|
1759
|
-
'0': /\d/,
|
|
1760
|
-
'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]/,
|
|
1761
|
-
// http://stackoverflow.com/a/22075070
|
|
1762
|
-
'*': /./
|
|
1763
|
-
};
|
|
1764
|
-
|
|
1765
1800
|
/** */
|
|
1766
1801
|
|
|
1767
1802
|
/** */
|
|
@@ -1837,9 +1872,9 @@ class PatternInputDefinition {
|
|
|
1837
1872
|
if (this.isFilled) return new ChangeDetails();
|
|
1838
1873
|
const state = this.masked.state;
|
|
1839
1874
|
// simulate input
|
|
1840
|
-
|
|
1875
|
+
let details = this.masked._appendChar(ch, this.currentMaskFlags(flags));
|
|
1841
1876
|
if (details.inserted && this.doValidate(flags) === false) {
|
|
1842
|
-
details
|
|
1877
|
+
details = new ChangeDetails();
|
|
1843
1878
|
this.masked.state = state;
|
|
1844
1879
|
}
|
|
1845
1880
|
if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
|
|
@@ -1854,11 +1889,11 @@ class PatternInputDefinition {
|
|
|
1854
1889
|
return this.masked.append(str, this.currentMaskFlags(flags), tail);
|
|
1855
1890
|
}
|
|
1856
1891
|
_appendPlaceholder() {
|
|
1857
|
-
|
|
1858
|
-
if (this.isFilled || this.isOptional) return details;
|
|
1892
|
+
if (this.isFilled || this.isOptional) return new ChangeDetails();
|
|
1859
1893
|
this.isFilled = true;
|
|
1860
|
-
|
|
1861
|
-
|
|
1894
|
+
return new ChangeDetails({
|
|
1895
|
+
inserted: this.placeholderChar
|
|
1896
|
+
});
|
|
1862
1897
|
}
|
|
1863
1898
|
_appendEager() {
|
|
1864
1899
|
return new ChangeDetails();
|
|
@@ -1925,12 +1960,22 @@ class PatternInputDefinition {
|
|
|
1925
1960
|
this.isFilled = state.isFilled;
|
|
1926
1961
|
}
|
|
1927
1962
|
currentMaskFlags(flags) {
|
|
1963
|
+
var _flags$_beforeTailSta;
|
|
1928
1964
|
return {
|
|
1929
1965
|
...flags,
|
|
1930
|
-
_beforeTailState: flags
|
|
1966
|
+
_beforeTailState: (flags == null || (_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.masked) || (flags == null ? void 0 : flags._beforeTailState)
|
|
1931
1967
|
};
|
|
1932
1968
|
}
|
|
1969
|
+
pad(flags) {
|
|
1970
|
+
return new ChangeDetails();
|
|
1971
|
+
}
|
|
1933
1972
|
}
|
|
1973
|
+
PatternInputDefinition.DEFAULT_DEFINITIONS = {
|
|
1974
|
+
'0': /\d/,
|
|
1975
|
+
'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]/,
|
|
1976
|
+
// http://stackoverflow.com/a/22075070
|
|
1977
|
+
'*': /./
|
|
1978
|
+
};
|
|
1934
1979
|
|
|
1935
1980
|
/** Masking by RegExp */
|
|
1936
1981
|
class MaskedRegExp extends Masked {
|
|
@@ -1942,6 +1987,8 @@ class MaskedRegExp extends Masked {
|
|
|
1942
1987
|
|
|
1943
1988
|
/** */
|
|
1944
1989
|
|
|
1990
|
+
/** */
|
|
1991
|
+
|
|
1945
1992
|
updateOptions(opts) {
|
|
1946
1993
|
super.updateOptions(opts);
|
|
1947
1994
|
}
|
|
@@ -1955,15 +2002,6 @@ IMask.MaskedRegExp = MaskedRegExp;
|
|
|
1955
2002
|
|
|
1956
2003
|
/** Pattern mask */
|
|
1957
2004
|
class MaskedPattern extends Masked {
|
|
1958
|
-
static DEFAULTS = {
|
|
1959
|
-
lazy: true,
|
|
1960
|
-
placeholderChar: '_'
|
|
1961
|
-
};
|
|
1962
|
-
static STOP_CHAR = '`';
|
|
1963
|
-
static ESCAPE_CHAR = '\\';
|
|
1964
|
-
static InputDefinition = PatternInputDefinition;
|
|
1965
|
-
static FixedDefinition = PatternFixedDefinition;
|
|
1966
|
-
|
|
1967
2005
|
/** */
|
|
1968
2006
|
|
|
1969
2007
|
/** */
|
|
@@ -1980,11 +2018,13 @@ class MaskedPattern extends Masked {
|
|
|
1980
2018
|
|
|
1981
2019
|
/** */
|
|
1982
2020
|
|
|
2021
|
+
/** */
|
|
2022
|
+
|
|
1983
2023
|
constructor(opts) {
|
|
1984
2024
|
super({
|
|
1985
2025
|
...MaskedPattern.DEFAULTS,
|
|
1986
2026
|
...opts,
|
|
1987
|
-
definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts
|
|
2027
|
+
definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts == null ? void 0 : opts.definitions)
|
|
1988
2028
|
});
|
|
1989
2029
|
}
|
|
1990
2030
|
updateOptions(opts) {
|
|
@@ -2025,6 +2065,7 @@ class MaskedPattern extends Masked {
|
|
|
2025
2065
|
placeholderChar: this.placeholderChar,
|
|
2026
2066
|
displayChar: this.displayChar,
|
|
2027
2067
|
overwrite: this.overwrite,
|
|
2068
|
+
autofix: this.autofix,
|
|
2028
2069
|
...bOpts,
|
|
2029
2070
|
repeat,
|
|
2030
2071
|
parent: this
|
|
@@ -2158,8 +2199,9 @@ class MaskedPattern extends Masked {
|
|
|
2158
2199
|
return super.appendTail(tail).aggregate(this._appendPlaceholder());
|
|
2159
2200
|
}
|
|
2160
2201
|
_appendEager() {
|
|
2202
|
+
var _this$_mapPosToBlock;
|
|
2161
2203
|
const details = new ChangeDetails();
|
|
2162
|
-
let startBlockIndex = this._mapPosToBlock(this.displayValue.length)
|
|
2204
|
+
let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index;
|
|
2163
2205
|
if (startBlockIndex == null) return details;
|
|
2164
2206
|
|
|
2165
2207
|
// TODO test if it works for nested pattern masks
|
|
@@ -2179,12 +2221,13 @@ class MaskedPattern extends Masked {
|
|
|
2179
2221
|
const details = new ChangeDetails();
|
|
2180
2222
|
if (!blockIter) return details;
|
|
2181
2223
|
for (let bi = blockIter.index, block; block = this._blocks[bi]; ++bi) {
|
|
2224
|
+
var _flags$_beforeTailSta;
|
|
2182
2225
|
const blockDetails = block._appendChar(ch, {
|
|
2183
2226
|
...flags,
|
|
2184
|
-
_beforeTailState: flags._beforeTailState
|
|
2227
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
2185
2228
|
});
|
|
2186
2229
|
details.aggregate(blockDetails);
|
|
2187
|
-
if (blockDetails.
|
|
2230
|
+
if (blockDetails.consumed) break; // go next char
|
|
2188
2231
|
}
|
|
2189
2232
|
return details;
|
|
2190
2233
|
}
|
|
@@ -2242,9 +2285,8 @@ class MaskedPattern extends Masked {
|
|
|
2242
2285
|
const endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
|
|
2243
2286
|
this._blocks.slice(startBlockIndex, endBlockIndex).forEach(b => {
|
|
2244
2287
|
if (!b.lazy || toBlockIndex != null) {
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
details.aggregate(bDetails);
|
|
2288
|
+
var _blocks2;
|
|
2289
|
+
details.aggregate(b._appendPlaceholder((_blocks2 = b._blocks) == null ? void 0 : _blocks2.length));
|
|
2248
2290
|
}
|
|
2249
2291
|
});
|
|
2250
2292
|
return details;
|
|
@@ -2392,7 +2434,21 @@ class MaskedPattern extends Masked {
|
|
|
2392
2434
|
if (!indices) return [];
|
|
2393
2435
|
return indices.map(gi => this._blocks[gi]);
|
|
2394
2436
|
}
|
|
2437
|
+
pad(flags) {
|
|
2438
|
+
const details = new ChangeDetails();
|
|
2439
|
+
this._forEachBlocksInRange(0, this.displayValue.length, b => details.aggregate(b.pad(flags)));
|
|
2440
|
+
return details;
|
|
2441
|
+
}
|
|
2395
2442
|
}
|
|
2443
|
+
MaskedPattern.DEFAULTS = {
|
|
2444
|
+
...Masked.DEFAULTS,
|
|
2445
|
+
lazy: true,
|
|
2446
|
+
placeholderChar: '_'
|
|
2447
|
+
};
|
|
2448
|
+
MaskedPattern.STOP_CHAR = '`';
|
|
2449
|
+
MaskedPattern.ESCAPE_CHAR = '\\';
|
|
2450
|
+
MaskedPattern.InputDefinition = PatternInputDefinition;
|
|
2451
|
+
MaskedPattern.FixedDefinition = PatternFixedDefinition;
|
|
2396
2452
|
IMask.MaskedPattern = MaskedPattern;
|
|
2397
2453
|
|
|
2398
2454
|
/** Pattern which accepts ranges */
|
|
@@ -2406,8 +2462,6 @@ class MaskedRange extends MaskedPattern {
|
|
|
2406
2462
|
|
|
2407
2463
|
/** Max bound */
|
|
2408
2464
|
|
|
2409
|
-
/** */
|
|
2410
|
-
|
|
2411
2465
|
get _matchFrom() {
|
|
2412
2466
|
return this.maxLength - String(this.from).length;
|
|
2413
2467
|
}
|
|
@@ -2457,23 +2511,25 @@ class MaskedRange extends MaskedPattern {
|
|
|
2457
2511
|
}
|
|
2458
2512
|
let details;
|
|
2459
2513
|
[ch, details] = super.doPrepareChar(ch.replace(/\D/g, ''), flags);
|
|
2460
|
-
if (!
|
|
2461
|
-
|
|
2462
|
-
|
|
2514
|
+
if (!ch) details.skip = !this.isComplete;
|
|
2515
|
+
return [ch, details];
|
|
2516
|
+
}
|
|
2517
|
+
_appendCharRaw(ch, flags) {
|
|
2518
|
+
if (flags === void 0) {
|
|
2519
|
+
flags = {};
|
|
2463
2520
|
}
|
|
2521
|
+
if (!this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(ch, flags);
|
|
2464
2522
|
const fromStr = String(this.from).padStart(this.maxLength, '0');
|
|
2465
2523
|
const toStr = String(this.to).padStart(this.maxLength, '0');
|
|
2466
|
-
const
|
|
2467
|
-
if (
|
|
2468
|
-
const [minstr, maxstr] = this.boundaries(nextVal);
|
|
2469
|
-
if (Number(maxstr) < this.from) return [fromStr[nextVal.length - 1], details];
|
|
2524
|
+
const [minstr, maxstr] = this.boundaries(this.value + ch);
|
|
2525
|
+
if (Number(maxstr) < this.from) return super._appendCharRaw(fromStr[this.value.length], flags);
|
|
2470
2526
|
if (Number(minstr) > this.to) {
|
|
2471
|
-
if (this.autofix === 'pad' &&
|
|
2472
|
-
return [
|
|
2527
|
+
if (!flags.tail && this.autofix === 'pad' && this.value.length + 1 < this.maxLength) {
|
|
2528
|
+
return super._appendCharRaw(fromStr[this.value.length], flags).aggregate(this._appendCharRaw(ch, flags));
|
|
2473
2529
|
}
|
|
2474
|
-
return
|
|
2530
|
+
return super._appendCharRaw(toStr[this.value.length], flags);
|
|
2475
2531
|
}
|
|
2476
|
-
return
|
|
2532
|
+
return super._appendCharRaw(ch, flags);
|
|
2477
2533
|
}
|
|
2478
2534
|
doValidate(flags) {
|
|
2479
2535
|
const str = this.value;
|
|
@@ -2482,45 +2538,27 @@ class MaskedRange extends MaskedPattern {
|
|
|
2482
2538
|
const [minstr, maxstr] = this.boundaries(str);
|
|
2483
2539
|
return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(flags);
|
|
2484
2540
|
}
|
|
2541
|
+
pad(flags) {
|
|
2542
|
+
const details = new ChangeDetails();
|
|
2543
|
+
if (this.value.length === this.maxLength) return details;
|
|
2544
|
+
const value = this.value;
|
|
2545
|
+
const padLength = this.maxLength - this.value.length;
|
|
2546
|
+
if (padLength) {
|
|
2547
|
+
this.reset();
|
|
2548
|
+
for (let i = 0; i < padLength; ++i) {
|
|
2549
|
+
details.aggregate(super._appendCharRaw('0', flags));
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
// append tail
|
|
2553
|
+
value.split('').forEach(ch => this._appendCharRaw(ch));
|
|
2554
|
+
}
|
|
2555
|
+
return details;
|
|
2556
|
+
}
|
|
2485
2557
|
}
|
|
2486
2558
|
IMask.MaskedRange = MaskedRange;
|
|
2487
2559
|
|
|
2488
2560
|
/** Date mask */
|
|
2489
2561
|
class MaskedDate extends MaskedPattern {
|
|
2490
|
-
static GET_DEFAULT_BLOCKS = () => ({
|
|
2491
|
-
d: {
|
|
2492
|
-
mask: MaskedRange,
|
|
2493
|
-
from: 1,
|
|
2494
|
-
to: 31,
|
|
2495
|
-
maxLength: 2
|
|
2496
|
-
},
|
|
2497
|
-
m: {
|
|
2498
|
-
mask: MaskedRange,
|
|
2499
|
-
from: 1,
|
|
2500
|
-
to: 12,
|
|
2501
|
-
maxLength: 2
|
|
2502
|
-
},
|
|
2503
|
-
Y: {
|
|
2504
|
-
mask: MaskedRange,
|
|
2505
|
-
from: 1900,
|
|
2506
|
-
to: 9999
|
|
2507
|
-
}
|
|
2508
|
-
});
|
|
2509
|
-
static DEFAULTS = {
|
|
2510
|
-
mask: Date,
|
|
2511
|
-
pattern: 'd{.}`m{.}`Y',
|
|
2512
|
-
format: (date, masked) => {
|
|
2513
|
-
if (!date) return '';
|
|
2514
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
2515
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
2516
|
-
const year = date.getFullYear();
|
|
2517
|
-
return [day, month, year].join('.');
|
|
2518
|
-
},
|
|
2519
|
-
parse: (str, masked) => {
|
|
2520
|
-
const [day, month, year] = str.split('.').map(Number);
|
|
2521
|
-
return new Date(year, month - 1, day);
|
|
2522
|
-
}
|
|
2523
|
-
};
|
|
2524
2562
|
static extractPatternOptions(opts) {
|
|
2525
2563
|
const {
|
|
2526
2564
|
mask,
|
|
@@ -2539,8 +2577,6 @@ class MaskedDate extends MaskedPattern {
|
|
|
2539
2577
|
|
|
2540
2578
|
/** End date */
|
|
2541
2579
|
|
|
2542
|
-
/** */
|
|
2543
|
-
|
|
2544
2580
|
/** Format typed value to string */
|
|
2545
2581
|
|
|
2546
2582
|
/** Parse string to get typed value */
|
|
@@ -2577,12 +2613,6 @@ class MaskedDate extends MaskedPattern {
|
|
|
2577
2613
|
}
|
|
2578
2614
|
}
|
|
2579
2615
|
Object.assign(patternBlocks, this.blocks, blocks);
|
|
2580
|
-
|
|
2581
|
-
// add autofix
|
|
2582
|
-
Object.keys(patternBlocks).forEach(bk => {
|
|
2583
|
-
const b = patternBlocks[bk];
|
|
2584
|
-
if (!('autofix' in b) && 'autofix' in opts) b.autofix = opts.autofix;
|
|
2585
|
-
});
|
|
2586
2616
|
super._update({
|
|
2587
2617
|
...patternOpts,
|
|
2588
2618
|
mask: isString(mask) ? mask : pattern,
|
|
@@ -2619,20 +2649,45 @@ class MaskedDate extends MaskedPattern {
|
|
|
2619
2649
|
return super.optionsIsChanged(MaskedDate.extractPatternOptions(opts));
|
|
2620
2650
|
}
|
|
2621
2651
|
}
|
|
2652
|
+
MaskedDate.GET_DEFAULT_BLOCKS = () => ({
|
|
2653
|
+
d: {
|
|
2654
|
+
mask: MaskedRange,
|
|
2655
|
+
from: 1,
|
|
2656
|
+
to: 31,
|
|
2657
|
+
maxLength: 2
|
|
2658
|
+
},
|
|
2659
|
+
m: {
|
|
2660
|
+
mask: MaskedRange,
|
|
2661
|
+
from: 1,
|
|
2662
|
+
to: 12,
|
|
2663
|
+
maxLength: 2
|
|
2664
|
+
},
|
|
2665
|
+
Y: {
|
|
2666
|
+
mask: MaskedRange,
|
|
2667
|
+
from: 1900,
|
|
2668
|
+
to: 9999
|
|
2669
|
+
}
|
|
2670
|
+
});
|
|
2671
|
+
MaskedDate.DEFAULTS = {
|
|
2672
|
+
...MaskedPattern.DEFAULTS,
|
|
2673
|
+
mask: Date,
|
|
2674
|
+
pattern: 'd{.}`m{.}`Y',
|
|
2675
|
+
format: (date, masked) => {
|
|
2676
|
+
if (!date) return '';
|
|
2677
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
2678
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
2679
|
+
const year = date.getFullYear();
|
|
2680
|
+
return [day, month, year].join('.');
|
|
2681
|
+
},
|
|
2682
|
+
parse: (str, masked) => {
|
|
2683
|
+
const [day, month, year] = str.split('.').map(Number);
|
|
2684
|
+
return new Date(year, month - 1, day);
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2622
2687
|
IMask.MaskedDate = MaskedDate;
|
|
2623
2688
|
|
|
2624
2689
|
/** Dynamic mask for choosing appropriate mask in run-time */
|
|
2625
2690
|
class MaskedDynamic extends Masked {
|
|
2626
|
-
static DEFAULTS;
|
|
2627
|
-
|
|
2628
|
-
/** Currently chosen mask */
|
|
2629
|
-
|
|
2630
|
-
/** Currently chosen mask */
|
|
2631
|
-
|
|
2632
|
-
/** Compliled {@link Masked} options */
|
|
2633
|
-
|
|
2634
|
-
/** Chooses {@link Masked} depending on input value */
|
|
2635
|
-
|
|
2636
2691
|
constructor(opts) {
|
|
2637
2692
|
super({
|
|
2638
2693
|
...MaskedDynamic.DEFAULTS,
|
|
@@ -2692,7 +2747,7 @@ class MaskedDynamic extends Masked {
|
|
|
2692
2747
|
const tailValue = inputValue.slice(insertValue.length);
|
|
2693
2748
|
const prevMask = this.currentMask;
|
|
2694
2749
|
const details = new ChangeDetails();
|
|
2695
|
-
const prevMaskState = prevMask
|
|
2750
|
+
const prevMaskState = prevMask == null ? void 0 : prevMask.state;
|
|
2696
2751
|
|
|
2697
2752
|
// clone flags to prevent overwriting `_beforeTailState`
|
|
2698
2753
|
this.currentMask = this.doDispatch(appended, {
|
|
@@ -2705,10 +2760,10 @@ class MaskedDynamic extends Masked {
|
|
|
2705
2760
|
// if mask changed reapply input
|
|
2706
2761
|
this.currentMask.reset();
|
|
2707
2762
|
if (insertValue) {
|
|
2708
|
-
|
|
2763
|
+
this.currentMask.append(insertValue, {
|
|
2709
2764
|
raw: true
|
|
2710
2765
|
});
|
|
2711
|
-
details.tailShift =
|
|
2766
|
+
details.tailShift = this.currentMask.value.length - prevValueBeforeTail.length;
|
|
2712
2767
|
}
|
|
2713
2768
|
if (tailValue) {
|
|
2714
2769
|
details.tailShift += this.currentMask.append(tailValue, {
|
|
@@ -2744,9 +2799,10 @@ class MaskedDynamic extends Masked {
|
|
|
2744
2799
|
return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
|
|
2745
2800
|
}
|
|
2746
2801
|
currentMaskFlags(flags) {
|
|
2802
|
+
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
|
|
2747
2803
|
return {
|
|
2748
2804
|
...flags,
|
|
2749
|
-
_beforeTailState: flags._beforeTailState
|
|
2805
|
+
_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
|
|
2750
2806
|
};
|
|
2751
2807
|
}
|
|
2752
2808
|
doDispatch(appended, flags, tail) {
|
|
@@ -2786,7 +2842,8 @@ class MaskedDynamic extends Masked {
|
|
|
2786
2842
|
return [s, details];
|
|
2787
2843
|
}
|
|
2788
2844
|
reset() {
|
|
2789
|
-
|
|
2845
|
+
var _this$currentMask;
|
|
2846
|
+
(_this$currentMask = this.currentMask) == null || _this$currentMask.reset();
|
|
2790
2847
|
this.compiledMasks.forEach(m => m.reset());
|
|
2791
2848
|
}
|
|
2792
2849
|
get value() {
|
|
@@ -2832,10 +2889,12 @@ class MaskedDynamic extends Masked {
|
|
|
2832
2889
|
return this.currentMask ? this.currentMask.displayValue : '';
|
|
2833
2890
|
}
|
|
2834
2891
|
get isComplete() {
|
|
2835
|
-
|
|
2892
|
+
var _this$currentMask2;
|
|
2893
|
+
return Boolean((_this$currentMask2 = this.currentMask) == null ? void 0 : _this$currentMask2.isComplete);
|
|
2836
2894
|
}
|
|
2837
2895
|
get isFilled() {
|
|
2838
|
-
|
|
2896
|
+
var _this$currentMask3;
|
|
2897
|
+
return Boolean((_this$currentMask3 = this.currentMask) == null ? void 0 : _this$currentMask3.isFilled);
|
|
2839
2898
|
}
|
|
2840
2899
|
remove(fromPos, toPos) {
|
|
2841
2900
|
const details = new ChangeDetails();
|
|
@@ -2847,12 +2906,13 @@ class MaskedDynamic extends Masked {
|
|
|
2847
2906
|
return details;
|
|
2848
2907
|
}
|
|
2849
2908
|
get state() {
|
|
2909
|
+
var _this$currentMask4;
|
|
2850
2910
|
return {
|
|
2851
2911
|
...super.state,
|
|
2852
2912
|
_rawInputValue: this.rawInputValue,
|
|
2853
2913
|
compiledMasks: this.compiledMasks.map(m => m.state),
|
|
2854
2914
|
currentMaskRef: this.currentMask,
|
|
2855
|
-
currentMask: this.currentMask
|
|
2915
|
+
currentMask: (_this$currentMask4 = this.currentMask) == null ? void 0 : _this$currentMask4.state
|
|
2856
2916
|
};
|
|
2857
2917
|
}
|
|
2858
2918
|
set state(state) {
|
|
@@ -2900,6 +2960,12 @@ class MaskedDynamic extends Masked {
|
|
|
2900
2960
|
set skipInvalid(skipInvalid) {
|
|
2901
2961
|
this._skipInvalid = skipInvalid;
|
|
2902
2962
|
}
|
|
2963
|
+
get autofix() {
|
|
2964
|
+
return this.currentMask ? this.currentMask.autofix : this._autofix;
|
|
2965
|
+
}
|
|
2966
|
+
set autofix(autofix) {
|
|
2967
|
+
this._autofix = autofix;
|
|
2968
|
+
}
|
|
2903
2969
|
maskEquals(mask) {
|
|
2904
2970
|
return Array.isArray(mask) ? this.compiledMasks.every((m, mi) => {
|
|
2905
2971
|
if (!mask[mi]) return;
|
|
@@ -2911,10 +2977,16 @@ class MaskedDynamic extends Masked {
|
|
|
2911
2977
|
}) : super.maskEquals(mask);
|
|
2912
2978
|
}
|
|
2913
2979
|
typedValueEquals(value) {
|
|
2914
|
-
|
|
2980
|
+
var _this$currentMask5;
|
|
2981
|
+
return Boolean((_this$currentMask5 = this.currentMask) == null ? void 0 : _this$currentMask5.typedValueEquals(value));
|
|
2915
2982
|
}
|
|
2916
2983
|
}
|
|
2984
|
+
/** Currently chosen mask */
|
|
2985
|
+
/** Currently chosen mask */
|
|
2986
|
+
/** Compliled {@link Masked} options */
|
|
2987
|
+
/** Chooses {@link Masked} depending on input value */
|
|
2917
2988
|
MaskedDynamic.DEFAULTS = {
|
|
2989
|
+
...Masked.DEFAULTS,
|
|
2918
2990
|
dispatch: (appended, masked, flags, tail) => {
|
|
2919
2991
|
if (!masked.compiledMasks.length) return;
|
|
2920
2992
|
const inputValue = masked.rawInputValue;
|
|
@@ -2950,30 +3022,88 @@ IMask.MaskedDynamic = MaskedDynamic;
|
|
|
2950
3022
|
/** Pattern which validates enum values */
|
|
2951
3023
|
class MaskedEnum extends MaskedPattern {
|
|
2952
3024
|
constructor(opts) {
|
|
2953
|
-
super(
|
|
3025
|
+
super({
|
|
3026
|
+
...MaskedEnum.DEFAULTS,
|
|
3027
|
+
...opts
|
|
3028
|
+
}); // mask will be created in _update
|
|
2954
3029
|
}
|
|
2955
3030
|
updateOptions(opts) {
|
|
2956
3031
|
super.updateOptions(opts);
|
|
2957
3032
|
}
|
|
2958
3033
|
_update(opts) {
|
|
2959
3034
|
const {
|
|
2960
|
-
enum:
|
|
3035
|
+
enum: enum_,
|
|
2961
3036
|
...eopts
|
|
2962
3037
|
} = opts;
|
|
2963
|
-
if (
|
|
2964
|
-
const lengths =
|
|
3038
|
+
if (enum_) {
|
|
3039
|
+
const lengths = enum_.map(e => e.length);
|
|
2965
3040
|
const requiredLength = Math.min(...lengths);
|
|
2966
3041
|
const optionalLength = Math.max(...lengths) - requiredLength;
|
|
2967
3042
|
eopts.mask = '*'.repeat(requiredLength);
|
|
2968
3043
|
if (optionalLength) eopts.mask += '[' + '*'.repeat(optionalLength) + ']';
|
|
2969
|
-
this.enum =
|
|
3044
|
+
this.enum = enum_;
|
|
2970
3045
|
}
|
|
2971
3046
|
super._update(eopts);
|
|
2972
3047
|
}
|
|
2973
|
-
|
|
2974
|
-
|
|
3048
|
+
_appendCharRaw(ch, flags) {
|
|
3049
|
+
if (flags === void 0) {
|
|
3050
|
+
flags = {};
|
|
3051
|
+
}
|
|
3052
|
+
const matchFrom = Math.min(this.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
3053
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.unmaskedValue + ch, matchFrom));
|
|
3054
|
+
if (matches.length) {
|
|
3055
|
+
if (matches.length === 1) {
|
|
3056
|
+
this._forEachBlocksInRange(0, this.value.length, (b, bi) => {
|
|
3057
|
+
const mch = matches[0][bi];
|
|
3058
|
+
if (bi >= this.value.length || mch === b.value) return;
|
|
3059
|
+
b.reset();
|
|
3060
|
+
b._appendChar(mch, flags);
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
3063
|
+
const d = super._appendCharRaw(matches[0][this.value.length], flags);
|
|
3064
|
+
if (matches.length === 1) {
|
|
3065
|
+
matches[0].slice(this.unmaskedValue.length).split('').forEach(mch => d.aggregate(super._appendCharRaw(mch)));
|
|
3066
|
+
}
|
|
3067
|
+
return d;
|
|
3068
|
+
}
|
|
3069
|
+
return new ChangeDetails({
|
|
3070
|
+
skip: !this.isComplete
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
extractTail(fromPos, toPos) {
|
|
3074
|
+
if (fromPos === void 0) {
|
|
3075
|
+
fromPos = 0;
|
|
3076
|
+
}
|
|
3077
|
+
// just drop tail
|
|
3078
|
+
return new ContinuousTailDetails('', fromPos);
|
|
3079
|
+
}
|
|
3080
|
+
remove(fromPos, toPos) {
|
|
3081
|
+
if (fromPos === void 0) {
|
|
3082
|
+
fromPos = 0;
|
|
3083
|
+
}
|
|
3084
|
+
if (toPos === void 0) {
|
|
3085
|
+
toPos = this.displayValue.length;
|
|
3086
|
+
}
|
|
3087
|
+
if (fromPos === toPos) return new ChangeDetails();
|
|
3088
|
+
const matchFrom = Math.min(super.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
3089
|
+
let pos;
|
|
3090
|
+
for (pos = fromPos; pos >= 0; --pos) {
|
|
3091
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.value.slice(matchFrom, pos), matchFrom));
|
|
3092
|
+
if (matches.length > 1) break;
|
|
3093
|
+
}
|
|
3094
|
+
const details = super.remove(pos, toPos);
|
|
3095
|
+
details.tailShift += pos - fromPos;
|
|
3096
|
+
return details;
|
|
3097
|
+
}
|
|
3098
|
+
get isComplete() {
|
|
3099
|
+
return this.enum.indexOf(this.value) >= 0;
|
|
2975
3100
|
}
|
|
2976
3101
|
}
|
|
3102
|
+
/** Match enum value */
|
|
3103
|
+
MaskedEnum.DEFAULTS = {
|
|
3104
|
+
...MaskedPattern.DEFAULTS,
|
|
3105
|
+
matchValue: (estr, istr, matchFrom) => estr.indexOf(istr, matchFrom) === matchFrom
|
|
3106
|
+
};
|
|
2977
3107
|
IMask.MaskedEnum = MaskedEnum;
|
|
2978
3108
|
|
|
2979
3109
|
/** Masking by custom Function */
|
|
@@ -2986,6 +3116,8 @@ class MaskedFunction extends Masked {
|
|
|
2986
3116
|
|
|
2987
3117
|
/** */
|
|
2988
3118
|
|
|
3119
|
+
/** */
|
|
3120
|
+
|
|
2989
3121
|
updateOptions(opts) {
|
|
2990
3122
|
super.updateOptions(opts);
|
|
2991
3123
|
}
|
|
@@ -2998,27 +3130,9 @@ class MaskedFunction extends Masked {
|
|
|
2998
3130
|
}
|
|
2999
3131
|
IMask.MaskedFunction = MaskedFunction;
|
|
3000
3132
|
|
|
3133
|
+
var _MaskedNumber;
|
|
3001
3134
|
/** Number mask */
|
|
3002
3135
|
class MaskedNumber extends Masked {
|
|
3003
|
-
static UNMASKED_RADIX = '.';
|
|
3004
|
-
static EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
|
|
3005
|
-
static DEFAULTS = {
|
|
3006
|
-
mask: Number,
|
|
3007
|
-
radix: ',',
|
|
3008
|
-
thousandsSeparator: '',
|
|
3009
|
-
mapToRadix: [MaskedNumber.UNMASKED_RADIX],
|
|
3010
|
-
min: Number.MIN_SAFE_INTEGER,
|
|
3011
|
-
max: Number.MAX_SAFE_INTEGER,
|
|
3012
|
-
scale: 2,
|
|
3013
|
-
normalizeZeros: true,
|
|
3014
|
-
padFractionalZeros: false,
|
|
3015
|
-
parse: Number,
|
|
3016
|
-
format: n => n.toLocaleString('en-US', {
|
|
3017
|
-
useGrouping: false,
|
|
3018
|
-
maximumFractionDigits: 20
|
|
3019
|
-
})
|
|
3020
|
-
};
|
|
3021
|
-
|
|
3022
3136
|
/** Single char */
|
|
3023
3137
|
|
|
3024
3138
|
/** Single char */
|
|
@@ -3041,6 +3155,8 @@ class MaskedNumber extends Masked {
|
|
|
3041
3155
|
|
|
3042
3156
|
/** */
|
|
3043
3157
|
|
|
3158
|
+
/** */
|
|
3159
|
+
|
|
3044
3160
|
/** Format typed value to string */
|
|
3045
3161
|
|
|
3046
3162
|
/** Parse string to get typed value */
|
|
@@ -3061,9 +3177,9 @@ class MaskedNumber extends Masked {
|
|
|
3061
3177
|
_updateRegExps() {
|
|
3062
3178
|
const start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
|
|
3063
3179
|
const mid = '\\d*';
|
|
3064
|
-
const end = (this.scale ?
|
|
3180
|
+
const end = (this.scale ? "(" + escapeRegExp(this.radix) + "\\d{0," + this.scale + "})?" : '') + '$';
|
|
3065
3181
|
this._numberRegExp = new RegExp(start + mid + end);
|
|
3066
|
-
this._mapToRadixRegExp = new RegExp(
|
|
3182
|
+
this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(escapeRegExp).join('') + "]", 'g');
|
|
3067
3183
|
this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
|
|
3068
3184
|
}
|
|
3069
3185
|
_removeThousandsSeparators(value) {
|
|
@@ -3126,16 +3242,43 @@ class MaskedNumber extends Masked {
|
|
|
3126
3242
|
if (flags === void 0) {
|
|
3127
3243
|
flags = {};
|
|
3128
3244
|
}
|
|
3129
|
-
if (!this.thousandsSeparator) return super._appendCharRaw(ch, flags);
|
|
3130
3245
|
const prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
3131
3246
|
const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
|
|
3132
3247
|
this._value = this._removeThousandsSeparators(this.value);
|
|
3133
|
-
const
|
|
3248
|
+
const oldValue = this._value;
|
|
3249
|
+
this._value += ch;
|
|
3250
|
+
const num = this.number;
|
|
3251
|
+
let accepted = !isNaN(num);
|
|
3252
|
+
let skip = false;
|
|
3253
|
+
if (accepted) {
|
|
3254
|
+
let fixedNum;
|
|
3255
|
+
if (this.min != null && this.min < 0 && this.number < this.min) fixedNum = this.min;
|
|
3256
|
+
if (this.max != null && this.max > 0 && this.number > this.max) fixedNum = this.max;
|
|
3257
|
+
if (fixedNum != null) {
|
|
3258
|
+
if (this.autofix) {
|
|
3259
|
+
this._value = this.format(fixedNum, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
|
|
3260
|
+
skip || (skip = oldValue === this._value && !flags.tail); // if not changed on tail it's still ok to proceed
|
|
3261
|
+
} else {
|
|
3262
|
+
accepted = false;
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
accepted && (accepted = Boolean(this._value.match(this._numberRegExp)));
|
|
3266
|
+
}
|
|
3267
|
+
let appendDetails;
|
|
3268
|
+
if (!accepted) {
|
|
3269
|
+
this._value = oldValue;
|
|
3270
|
+
appendDetails = new ChangeDetails();
|
|
3271
|
+
} else {
|
|
3272
|
+
appendDetails = new ChangeDetails({
|
|
3273
|
+
inserted: this._value.slice(oldValue.length),
|
|
3274
|
+
rawInserted: skip ? '' : ch,
|
|
3275
|
+
skip
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3134
3278
|
this._value = this._insertThousandsSeparators(this._value);
|
|
3135
3279
|
const beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
3136
3280
|
const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
|
|
3137
3281
|
appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
|
|
3138
|
-
appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
|
|
3139
3282
|
return appendDetails;
|
|
3140
3283
|
}
|
|
3141
3284
|
_findSeparatorAround(pos) {
|
|
@@ -3197,20 +3340,6 @@ class MaskedNumber extends Masked {
|
|
|
3197
3340
|
}
|
|
3198
3341
|
return cursorPos;
|
|
3199
3342
|
}
|
|
3200
|
-
doValidate(flags) {
|
|
3201
|
-
// validate as string
|
|
3202
|
-
let valid = Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));
|
|
3203
|
-
if (valid) {
|
|
3204
|
-
// validate as number
|
|
3205
|
-
const number = this.number;
|
|
3206
|
-
valid = valid && !isNaN(number) && (
|
|
3207
|
-
// check min bound for negative values
|
|
3208
|
-
this.min == null || this.min >= 0 || this.min <= this.number) && (
|
|
3209
|
-
// check max bound for positive values
|
|
3210
|
-
this.max == null || this.max <= 0 || this.number <= this.max);
|
|
3211
|
-
}
|
|
3212
|
-
return valid && super.doValidate(flags);
|
|
3213
|
-
}
|
|
3214
3343
|
doCommit() {
|
|
3215
3344
|
if (this.value) {
|
|
3216
3345
|
const number = this.number;
|
|
@@ -3286,6 +3415,26 @@ class MaskedNumber extends Masked {
|
|
|
3286
3415
|
return (super.typedValueEquals(value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
|
|
3287
3416
|
}
|
|
3288
3417
|
}
|
|
3418
|
+
_MaskedNumber = MaskedNumber;
|
|
3419
|
+
MaskedNumber.UNMASKED_RADIX = '.';
|
|
3420
|
+
MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
|
|
3421
|
+
MaskedNumber.DEFAULTS = {
|
|
3422
|
+
...Masked.DEFAULTS,
|
|
3423
|
+
mask: Number,
|
|
3424
|
+
radix: ',',
|
|
3425
|
+
thousandsSeparator: '',
|
|
3426
|
+
mapToRadix: [_MaskedNumber.UNMASKED_RADIX],
|
|
3427
|
+
min: Number.MIN_SAFE_INTEGER,
|
|
3428
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
3429
|
+
scale: 2,
|
|
3430
|
+
normalizeZeros: true,
|
|
3431
|
+
padFractionalZeros: false,
|
|
3432
|
+
parse: Number,
|
|
3433
|
+
format: n => n.toLocaleString('en-US', {
|
|
3434
|
+
useGrouping: false,
|
|
3435
|
+
maximumFractionDigits: 20
|
|
3436
|
+
})
|
|
3437
|
+
};
|
|
3289
3438
|
IMask.MaskedNumber = MaskedNumber;
|
|
3290
3439
|
|
|
3291
3440
|
/** Mask pipe source and destination types */
|
|
@@ -3320,10 +3469,12 @@ IMask.pipe = pipe;
|
|
|
3320
3469
|
/** Pattern mask */
|
|
3321
3470
|
class RepeatBlock extends MaskedPattern {
|
|
3322
3471
|
get repeatFrom() {
|
|
3323
|
-
|
|
3472
|
+
var _ref;
|
|
3473
|
+
return (_ref = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === Infinity ? 0 : this.repeat) != null ? _ref : 0;
|
|
3324
3474
|
}
|
|
3325
3475
|
get repeatTo() {
|
|
3326
|
-
|
|
3476
|
+
var _ref2;
|
|
3477
|
+
return (_ref2 = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? _ref2 : Infinity;
|
|
3327
3478
|
}
|
|
3328
3479
|
constructor(opts) {
|
|
3329
3480
|
super(opts);
|
|
@@ -3332,16 +3483,17 @@ class RepeatBlock extends MaskedPattern {
|
|
|
3332
3483
|
super.updateOptions(opts);
|
|
3333
3484
|
}
|
|
3334
3485
|
_update(opts) {
|
|
3486
|
+
var _ref3, _ref4, _this$_blocks;
|
|
3335
3487
|
const {
|
|
3336
3488
|
repeat,
|
|
3337
3489
|
...blockOpts
|
|
3338
3490
|
} = normalizeOpts(opts); // TODO type
|
|
3339
3491
|
this._blockOpts = Object.assign({}, this._blockOpts, blockOpts);
|
|
3340
3492
|
const block = createMask(this._blockOpts);
|
|
3341
|
-
this.repeat = repeat
|
|
3493
|
+
this.repeat = (_ref3 = (_ref4 = repeat != null ? repeat : block.repeat) != null ? _ref4 : this.repeat) != null ? _ref3 : Infinity; // TODO type
|
|
3342
3494
|
|
|
3343
3495
|
super._update({
|
|
3344
|
-
mask: 'm'.repeat(Math.max(this.repeatTo === Infinity && this._blocks
|
|
3496
|
+
mask: 'm'.repeat(Math.max(this.repeatTo === Infinity && ((_this$_blocks = this._blocks) == null ? void 0 : _this$_blocks.length) || 0, this.repeatFrom)),
|
|
3345
3497
|
blocks: {
|
|
3346
3498
|
m: block
|
|
3347
3499
|
},
|
|
@@ -3366,13 +3518,14 @@ class RepeatBlock extends MaskedPattern {
|
|
|
3366
3518
|
flags = {};
|
|
3367
3519
|
}
|
|
3368
3520
|
const details = new ChangeDetails();
|
|
3369
|
-
for (let bi = this._mapPosToBlock(this.displayValue.length)
|
|
3521
|
+
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;
|
|
3370
3522
|
// try to get a block or
|
|
3371
3523
|
// try to allocate a new block if not allocated already
|
|
3372
|
-
block = this._blocks[bi]
|
|
3524
|
+
block = (_this$_blocks$bi = this._blocks[bi]) != null ? _this$_blocks$bi : allocated = !allocated && this._allocateBlock(bi); ++bi) {
|
|
3525
|
+
var _this$_mapPosToBlock$, _this$_mapPosToBlock, _this$_blocks$bi, _flags$_beforeTailSta;
|
|
3373
3526
|
const blockDetails = block._appendChar(ch, {
|
|
3374
3527
|
...flags,
|
|
3375
|
-
_beforeTailState: flags._beforeTailState
|
|
3528
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
3376
3529
|
});
|
|
3377
3530
|
if (blockDetails.skip && allocated) {
|
|
3378
3531
|
// remove the last allocated block and break
|
|
@@ -3381,17 +3534,18 @@ class RepeatBlock extends MaskedPattern {
|
|
|
3381
3534
|
break;
|
|
3382
3535
|
}
|
|
3383
3536
|
details.aggregate(blockDetails);
|
|
3384
|
-
if (blockDetails.
|
|
3537
|
+
if (blockDetails.consumed) break; // go next char
|
|
3385
3538
|
}
|
|
3386
3539
|
return details;
|
|
3387
3540
|
}
|
|
3388
3541
|
_trimEmptyTail(fromPos, toPos) {
|
|
3542
|
+
var _this$_mapPosToBlock2, _this$_mapPosToBlock3;
|
|
3389
3543
|
if (fromPos === void 0) {
|
|
3390
3544
|
fromPos = 0;
|
|
3391
3545
|
}
|
|
3392
|
-
const firstBlockIndex = Math.max(this._mapPosToBlock(fromPos)
|
|
3546
|
+
const firstBlockIndex = Math.max(((_this$_mapPosToBlock2 = this._mapPosToBlock(fromPos)) == null ? void 0 : _this$_mapPosToBlock2.index) || 0, this.repeatFrom, 0);
|
|
3393
3547
|
let lastBlockIndex;
|
|
3394
|
-
if (toPos != null) lastBlockIndex = this._mapPosToBlock(toPos)
|
|
3548
|
+
if (toPos != null) lastBlockIndex = (_this$_mapPosToBlock3 = this._mapPosToBlock(toPos)) == null ? void 0 : _this$_mapPosToBlock3.index;
|
|
3395
3549
|
if (lastBlockIndex == null) lastBlockIndex = this._blocks.length - 1;
|
|
3396
3550
|
let removeCount = 0;
|
|
3397
3551
|
for (let blockIndex = lastBlockIndex; firstBlockIndex <= blockIndex; --blockIndex, ++removeCount) {
|