@grayscale-dev/dragon 0.1.8 → 0.1.9
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/README.md +35 -5
- package/dist/components/dui-input.d.ts +11 -4
- package/dist/index.js +417 -381
- package/dist/manifest.json +59 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { css as Q, LitElement as tt, html as z } from "lit";
|
|
2
2
|
import { property as C, query as et, customElement as st } from "lit/decorators.js";
|
|
3
|
-
import { ifDefined as
|
|
4
|
-
function b(
|
|
5
|
-
return typeof
|
|
3
|
+
import { ifDefined as j } from "lit/directives/if-defined.js";
|
|
4
|
+
function b(n) {
|
|
5
|
+
return typeof n == "string" || n instanceof String;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function H(n) {
|
|
8
8
|
var t;
|
|
9
|
-
return typeof
|
|
9
|
+
return typeof n == "object" && n != null && (n == null || (t = n.constructor) == null ? void 0 : t.name) === "Object";
|
|
10
10
|
}
|
|
11
|
-
function G(
|
|
12
|
-
return Array.isArray(t) ? G(
|
|
13
|
-
let [i,
|
|
14
|
-
return t(
|
|
11
|
+
function G(n, t) {
|
|
12
|
+
return Array.isArray(t) ? G(n, (e, s) => t.includes(s)) : Object.entries(n).reduce((e, s) => {
|
|
13
|
+
let [i, a] = s;
|
|
14
|
+
return t(a, i) && (e[i] = a), e;
|
|
15
15
|
}, {});
|
|
16
16
|
}
|
|
17
17
|
const h = {
|
|
@@ -21,45 +21,45 @@ const h = {
|
|
|
21
21
|
RIGHT: "RIGHT",
|
|
22
22
|
FORCE_RIGHT: "FORCE_RIGHT"
|
|
23
23
|
};
|
|
24
|
-
function it(
|
|
25
|
-
switch (
|
|
24
|
+
function it(n) {
|
|
25
|
+
switch (n) {
|
|
26
26
|
case h.LEFT:
|
|
27
27
|
return h.FORCE_LEFT;
|
|
28
28
|
case h.RIGHT:
|
|
29
29
|
return h.FORCE_RIGHT;
|
|
30
30
|
default:
|
|
31
|
-
return
|
|
31
|
+
return n;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function L(
|
|
35
|
-
return
|
|
34
|
+
function L(n) {
|
|
35
|
+
return n.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1");
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
if (t ===
|
|
39
|
-
const e = Array.isArray(t), s = Array.isArray(
|
|
37
|
+
function I(n, t) {
|
|
38
|
+
if (t === n) return !0;
|
|
39
|
+
const e = Array.isArray(t), s = Array.isArray(n);
|
|
40
40
|
let i;
|
|
41
41
|
if (e && s) {
|
|
42
|
-
if (t.length !=
|
|
43
|
-
for (i = 0; i < t.length; i++) if (!
|
|
42
|
+
if (t.length != n.length) return !1;
|
|
43
|
+
for (i = 0; i < t.length; i++) if (!I(t[i], n[i])) return !1;
|
|
44
44
|
return !0;
|
|
45
45
|
}
|
|
46
46
|
if (e != s) return !1;
|
|
47
|
-
if (t &&
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
if (
|
|
51
|
-
const u = t instanceof RegExp, l =
|
|
52
|
-
if (u && l) return t.toString() ==
|
|
47
|
+
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
48
|
+
const a = t instanceof Date, r = n instanceof Date;
|
|
49
|
+
if (a && r) return t.getTime() == n.getTime();
|
|
50
|
+
if (a != r) return !1;
|
|
51
|
+
const u = t instanceof RegExp, l = n instanceof RegExp;
|
|
52
|
+
if (u && l) return t.toString() == n.toString();
|
|
53
53
|
if (u != l) return !1;
|
|
54
54
|
const o = Object.keys(t);
|
|
55
|
-
for (i = 0; i < o.length; i++) if (!Object.prototype.hasOwnProperty.call(
|
|
56
|
-
for (i = 0; i < o.length; i++) if (!
|
|
55
|
+
for (i = 0; i < o.length; i++) if (!Object.prototype.hasOwnProperty.call(n, o[i])) return !1;
|
|
56
|
+
for (i = 0; i < o.length; i++) if (!I(n[o[i]], t[o[i]])) return !1;
|
|
57
57
|
return !0;
|
|
58
|
-
} else if (t &&
|
|
59
|
-
return t.toString() ===
|
|
58
|
+
} else if (t && n && typeof t == "function" && typeof n == "function")
|
|
59
|
+
return t.toString() === n.toString();
|
|
60
60
|
return !1;
|
|
61
61
|
}
|
|
62
|
-
class
|
|
62
|
+
class at {
|
|
63
63
|
/** Current input value */
|
|
64
64
|
/** Current cursor position */
|
|
65
65
|
/** Old input value */
|
|
@@ -106,44 +106,44 @@ class nt {
|
|
|
106
106
|
this.oldSelection.end === this.oldSelection.start ? h.RIGHT : h.LEFT;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
function p(
|
|
110
|
-
return new p.InputMask(
|
|
109
|
+
function p(n, t) {
|
|
110
|
+
return new p.InputMask(n, t);
|
|
111
111
|
}
|
|
112
|
-
function K(
|
|
113
|
-
if (
|
|
114
|
-
return
|
|
112
|
+
function K(n) {
|
|
113
|
+
if (n == null) throw new Error("mask property should be defined");
|
|
114
|
+
return n instanceof RegExp ? p.MaskedRegExp : b(n) ? p.MaskedPattern : n === Date ? p.MaskedDate : n === Number ? p.MaskedNumber : Array.isArray(n) || n === Array ? p.MaskedDynamic : p.Masked && n.prototype instanceof p.Masked ? n : p.Masked && n instanceof p.Masked ? n.constructor : n instanceof Function ? p.MaskedFunction : (console.warn("Mask not found for mask", n), p.Masked);
|
|
115
115
|
}
|
|
116
|
-
function S(
|
|
117
|
-
if (!
|
|
116
|
+
function S(n) {
|
|
117
|
+
if (!n) throw new Error("Options in not defined");
|
|
118
118
|
if (p.Masked) {
|
|
119
|
-
if (
|
|
120
|
-
mask:
|
|
119
|
+
if (n.prototype instanceof p.Masked) return {
|
|
120
|
+
mask: n
|
|
121
121
|
};
|
|
122
122
|
const {
|
|
123
123
|
mask: t = void 0,
|
|
124
124
|
...e
|
|
125
|
-
} =
|
|
126
|
-
mask:
|
|
127
|
-
} :
|
|
125
|
+
} = n instanceof p.Masked ? {
|
|
126
|
+
mask: n
|
|
127
|
+
} : H(n) && n.mask instanceof p.Masked ? n : {};
|
|
128
128
|
if (t) {
|
|
129
129
|
const s = t.mask;
|
|
130
130
|
return {
|
|
131
|
-
...G(t, (i,
|
|
131
|
+
...G(t, (i, a) => !a.startsWith("_")),
|
|
132
132
|
mask: t.constructor,
|
|
133
133
|
_mask: s,
|
|
134
134
|
...e
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
return
|
|
139
|
-
...
|
|
138
|
+
return H(n) ? {
|
|
139
|
+
...n
|
|
140
140
|
} : {
|
|
141
|
-
mask:
|
|
141
|
+
mask: n
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
function x(
|
|
145
|
-
if (p.Masked &&
|
|
146
|
-
const t = S(
|
|
144
|
+
function x(n) {
|
|
145
|
+
if (p.Masked && n instanceof p.Masked) return n;
|
|
146
|
+
const t = S(n), e = K(t.mask);
|
|
147
147
|
if (!e) throw new Error("Masked class is not found for provided mask " + t.mask + ", appropriate module needs to be imported manually before creating mask.");
|
|
148
148
|
return t.mask === e && delete t.mask, t._mask && (t.mask = t._mask, delete t._mask), new e(t);
|
|
149
149
|
}
|
|
@@ -187,8 +187,8 @@ class U {
|
|
|
187
187
|
/** */
|
|
188
188
|
}
|
|
189
189
|
p.MaskElement = U;
|
|
190
|
-
const
|
|
191
|
-
class
|
|
190
|
+
const $ = 90, nt = 89;
|
|
191
|
+
class w extends U {
|
|
192
192
|
/** HTMLElement to use mask on */
|
|
193
193
|
constructor(t) {
|
|
194
194
|
super(), this.input = t, this._onKeydown = this._onKeydown.bind(this), this._onInput = this._onInput.bind(this), this._onBeforeinput = this._onBeforeinput.bind(this), this._onCompositionEnd = this._onCompositionEnd.bind(this);
|
|
@@ -206,9 +206,9 @@ class D extends U {
|
|
|
206
206
|
this.input.addEventListener("keydown", this._onKeydown), this.input.addEventListener("input", this._onInput), this.input.addEventListener("beforeinput", this._onBeforeinput), this.input.addEventListener("compositionend", this._onCompositionEnd), this.input.addEventListener("drop", t.drop), this.input.addEventListener("click", t.click), this.input.addEventListener("focus", t.focus), this.input.addEventListener("blur", t.commit), this._handlers = t;
|
|
207
207
|
}
|
|
208
208
|
_onKeydown(t) {
|
|
209
|
-
if (this._handlers.redo && (t.keyCode ===
|
|
209
|
+
if (this._handlers.redo && (t.keyCode === $ && t.shiftKey && (t.metaKey || t.ctrlKey) || t.keyCode === nt && t.ctrlKey))
|
|
210
210
|
return t.preventDefault(), this._handlers.redo(t);
|
|
211
|
-
if (this._handlers.undo && t.keyCode ===
|
|
211
|
+
if (this._handlers.undo && t.keyCode === $ && (t.metaKey || t.ctrlKey))
|
|
212
212
|
return t.preventDefault(), this._handlers.undo(t);
|
|
213
213
|
t.isComposing || this._handlers.selectionChange(t);
|
|
214
214
|
}
|
|
@@ -229,8 +229,8 @@ class D extends U {
|
|
|
229
229
|
this.input.removeEventListener("keydown", this._onKeydown), this.input.removeEventListener("input", this._onInput), this.input.removeEventListener("beforeinput", this._onBeforeinput), this.input.removeEventListener("compositionend", this._onCompositionEnd), this.input.removeEventListener("drop", this._handlers.drop), this.input.removeEventListener("click", this._handlers.click), this.input.removeEventListener("focus", this._handlers.focus), this.input.removeEventListener("blur", this._handlers.commit), this._handlers = {};
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
|
-
p.HTMLMaskElement =
|
|
233
|
-
class rt extends
|
|
232
|
+
p.HTMLMaskElement = w;
|
|
233
|
+
class rt extends w {
|
|
234
234
|
/** InputElement to use mask on */
|
|
235
235
|
constructor(t) {
|
|
236
236
|
super(t), this.input = t;
|
|
@@ -254,8 +254,8 @@ class rt extends D {
|
|
|
254
254
|
this.input.value = t;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
p.HTMLMaskElement =
|
|
258
|
-
class Y extends
|
|
257
|
+
p.HTMLMaskElement = w;
|
|
258
|
+
class Y extends w {
|
|
259
259
|
/** Returns HTMLElement selection start */
|
|
260
260
|
get _unsafeSelectionStart() {
|
|
261
261
|
const t = this.rootElement, e = t.getSelection && t.getSelection(), s = e && e.anchorOffset, i = e && e.focusOffset;
|
|
@@ -271,8 +271,8 @@ class Y extends D {
|
|
|
271
271
|
if (!this.rootElement.createRange) return;
|
|
272
272
|
const s = this.rootElement.createRange();
|
|
273
273
|
s.setStart(this.input.firstChild || this.input, t), s.setEnd(this.input.lastChild || this.input, e);
|
|
274
|
-
const i = this.rootElement,
|
|
275
|
-
|
|
274
|
+
const i = this.rootElement, a = i.getSelection && i.getSelection();
|
|
275
|
+
a && (a.removeAllRanges(), a.addRange(s));
|
|
276
276
|
}
|
|
277
277
|
/** HTMLElement value */
|
|
278
278
|
get value() {
|
|
@@ -283,7 +283,7 @@ class Y extends D {
|
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
p.HTMLContenteditableMaskElement = Y;
|
|
286
|
-
class
|
|
286
|
+
class T {
|
|
287
287
|
constructor() {
|
|
288
288
|
this.states = [], this.currentIndex = 0;
|
|
289
289
|
}
|
|
@@ -294,7 +294,7 @@ class M {
|
|
|
294
294
|
return this.states.length === 0;
|
|
295
295
|
}
|
|
296
296
|
push(t) {
|
|
297
|
-
this.currentIndex < this.states.length - 1 && (this.states.length = this.currentIndex + 1), this.states.push(t), this.states.length >
|
|
297
|
+
this.currentIndex < this.states.length - 1 && (this.states.length = this.currentIndex + 1), this.states.push(t), this.states.length > T.MAX_LENGTH && this.states.shift(), this.currentIndex = this.states.length - 1;
|
|
298
298
|
}
|
|
299
299
|
go(t) {
|
|
300
300
|
return this.currentIndex = Math.min(Math.max(this.currentIndex + t, 0), this.states.length - 1), this.currentState;
|
|
@@ -309,14 +309,14 @@ class M {
|
|
|
309
309
|
this.states.length = 0, this.currentIndex = 0;
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
|
|
312
|
+
T.MAX_LENGTH = 100;
|
|
313
313
|
class ut {
|
|
314
314
|
/**
|
|
315
315
|
View element
|
|
316
316
|
*/
|
|
317
317
|
/** Internal {@link Masked} model */
|
|
318
318
|
constructor(t, e) {
|
|
319
|
-
this.el = t instanceof U ? t : t.isContentEditable && t.tagName !== "INPUT" && t.tagName !== "TEXTAREA" ? new Y(t) : new rt(t), this.masked = x(e), this._listeners = {}, this._value = "", this._unmaskedValue = "", this._rawInputValue = "", this.history = new
|
|
319
|
+
this.el = t instanceof U ? t : t.isContentEditable && t.tagName !== "INPUT" && t.tagName !== "TEXTAREA" ? new Y(t) : new rt(t), this.masked = x(e), this._listeners = {}, this._value = "", this._unmaskedValue = "", this._rawInputValue = "", this.history = new T(), this._saveSelection = this._saveSelection.bind(this), this._onInput = this._onInput.bind(this), this._onChange = this._onChange.bind(this), this._onDrop = this._onDrop.bind(this), this._onFocus = this._onFocus.bind(this), this._onClick = this._onClick.bind(this), this._onUndo = this._onUndo.bind(this), this._onRedo = this._onRedo.bind(this), this.alignCursor = this.alignCursor.bind(this), this.alignCursorFriendly = this.alignCursorFriendly.bind(this), this._bindEvents(), this.updateValue(), this._onChange();
|
|
320
320
|
}
|
|
321
321
|
maskEquals(t) {
|
|
322
322
|
var e;
|
|
@@ -417,8 +417,8 @@ class ut {
|
|
|
417
417
|
}
|
|
418
418
|
/** Syncronizes view from model value, fires change events */
|
|
419
419
|
updateControl(t) {
|
|
420
|
-
const e = this.masked.unmaskedValue, s = this.masked.value, i = this.masked.rawInputValue,
|
|
421
|
-
this._unmaskedValue = e, this._value = s, this._rawInputValue = i, this.el.value !==
|
|
420
|
+
const e = this.masked.unmaskedValue, s = this.masked.value, i = this.masked.rawInputValue, a = this.displayValue, r = this.unmaskedValue !== e || this.value !== s || this._rawInputValue !== i;
|
|
421
|
+
this._unmaskedValue = e, this._value = s, this._rawInputValue = i, this.el.value !== a && (this.el.value = a), t === "auto" ? this.alignCursor() : t != null && (this.cursorPos = t), r && this._fireChangeEvents(), !this._historyChanging && (r || this.history.isEmpty) && this.history.push({
|
|
422
422
|
unmaskedValue: e,
|
|
423
423
|
selection: {
|
|
424
424
|
start: this.selectionStart,
|
|
@@ -431,8 +431,8 @@ class ut {
|
|
|
431
431
|
const {
|
|
432
432
|
mask: e,
|
|
433
433
|
...s
|
|
434
|
-
} = t, i = !this.maskEquals(e),
|
|
435
|
-
i && (this.mask = e),
|
|
434
|
+
} = t, i = !this.maskEquals(e), a = this.masked.optionsIsChanged(s);
|
|
435
|
+
i && (this.mask = e), a && this.masked.updateOptions(s), (i || a) && this.updateControl();
|
|
436
436
|
}
|
|
437
437
|
/** Updates cursor */
|
|
438
438
|
updateCursor(t) {
|
|
@@ -475,7 +475,7 @@ class ut {
|
|
|
475
475
|
/** Handles view input event */
|
|
476
476
|
_onInput(t) {
|
|
477
477
|
this._inputEvent = t, this._abortUpdateCursor();
|
|
478
|
-
const e = new
|
|
478
|
+
const e = new at({
|
|
479
479
|
// new state
|
|
480
480
|
value: this.el.value,
|
|
481
481
|
cursorPos: this.cursorPos,
|
|
@@ -485,9 +485,9 @@ class ut {
|
|
|
485
485
|
}), s = this.masked.rawInputValue, i = this.masked.splice(e.startChangePos, e.removed.length, e.inserted, e.removeDirection, {
|
|
486
486
|
input: !0,
|
|
487
487
|
raw: !0
|
|
488
|
-
}).offset,
|
|
489
|
-
let
|
|
490
|
-
|
|
488
|
+
}).offset, a = s === this.masked.rawInputValue ? e.removeDirection : h.NONE;
|
|
489
|
+
let r = this.masked.nearestInputPos(e.startChangePos + i, a);
|
|
490
|
+
a !== h.NONE && (r = this.masked.nearestInputPos(r, h.NONE)), this.updateControl(r), delete this._inputEvent;
|
|
491
491
|
}
|
|
492
492
|
/** Handles view change event and commits model value */
|
|
493
493
|
_onChange() {
|
|
@@ -591,7 +591,7 @@ class F {
|
|
|
591
591
|
return this.value = this.value.slice(0, -1), t;
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
|
-
class
|
|
594
|
+
class m {
|
|
595
595
|
/** */
|
|
596
596
|
/** */
|
|
597
597
|
/** Transforms value before mask processing */
|
|
@@ -607,7 +607,7 @@ class g {
|
|
|
607
607
|
/** */
|
|
608
608
|
constructor(t) {
|
|
609
609
|
this._value = "", this._update({
|
|
610
|
-
...
|
|
610
|
+
...m.DEFAULTS,
|
|
611
611
|
...t
|
|
612
612
|
}), this._initialized = !0;
|
|
613
613
|
}
|
|
@@ -709,35 +709,35 @@ class g {
|
|
|
709
709
|
_appendChar(t, e, s) {
|
|
710
710
|
e === void 0 && (e = {});
|
|
711
711
|
const i = this.state;
|
|
712
|
-
let
|
|
713
|
-
if ([t,
|
|
714
|
-
const
|
|
712
|
+
let a;
|
|
713
|
+
if ([t, a] = this.doPrepareChar(t, e), t && (a = a.aggregate(this._appendCharRaw(t, e)), !a.rawInserted && this.autofix === "pad")) {
|
|
714
|
+
const r = this.state;
|
|
715
715
|
this.state = i;
|
|
716
716
|
let u = this.pad(e);
|
|
717
717
|
const l = this._appendCharRaw(t, e);
|
|
718
|
-
u = u.aggregate(l), l.rawInserted || u.equals(
|
|
718
|
+
u = u.aggregate(l), l.rawInserted || u.equals(a) ? a = u : this.state = r;
|
|
719
719
|
}
|
|
720
|
-
if (
|
|
721
|
-
let
|
|
720
|
+
if (a.inserted) {
|
|
721
|
+
let r, u = this.doValidate(e) !== !1;
|
|
722
722
|
if (u && s != null) {
|
|
723
723
|
const l = this.state;
|
|
724
724
|
if (this.overwrite === !0) {
|
|
725
|
-
|
|
726
|
-
for (let c = 0; c <
|
|
727
|
-
s.unshift(this.displayValue.length -
|
|
725
|
+
r = s.state;
|
|
726
|
+
for (let c = 0; c < a.rawInserted.length; ++c)
|
|
727
|
+
s.unshift(this.displayValue.length - a.tailShift);
|
|
728
728
|
}
|
|
729
729
|
let o = this.appendTail(s);
|
|
730
730
|
if (u = o.rawInserted.length === s.toString().length, !(u && o.inserted) && this.overwrite === "shift") {
|
|
731
|
-
this.state = l,
|
|
732
|
-
for (let c = 0; c <
|
|
731
|
+
this.state = l, r = s.state;
|
|
732
|
+
for (let c = 0; c < a.rawInserted.length; ++c)
|
|
733
733
|
s.shift();
|
|
734
734
|
o = this.appendTail(s), u = o.rawInserted.length === s.toString().length;
|
|
735
735
|
}
|
|
736
736
|
u && o.inserted && (this.state = l);
|
|
737
737
|
}
|
|
738
|
-
u || (
|
|
738
|
+
u || (a = new d(), this.state = i, s && r && (s.state = r));
|
|
739
739
|
}
|
|
740
|
-
return
|
|
740
|
+
return a;
|
|
741
741
|
}
|
|
742
742
|
/** Appends optional placeholder at the end */
|
|
743
743
|
_appendPlaceholder() {
|
|
@@ -752,14 +752,14 @@ class g {
|
|
|
752
752
|
if (!b(t)) throw new Error("value should be string");
|
|
753
753
|
const i = b(s) ? new F(String(s)) : s;
|
|
754
754
|
e != null && e.tail && (e._beforeTailState = this.state);
|
|
755
|
-
let
|
|
756
|
-
[t,
|
|
757
|
-
for (let
|
|
758
|
-
const u = this._appendChar(t[
|
|
759
|
-
if (!u.rawInserted && !this.doSkipInvalid(t[
|
|
760
|
-
|
|
755
|
+
let a;
|
|
756
|
+
[t, a] = this.doPrepare(t, e);
|
|
757
|
+
for (let r = 0; r < t.length; ++r) {
|
|
758
|
+
const u = this._appendChar(t[r], e, i);
|
|
759
|
+
if (!u.rawInserted && !this.doSkipInvalid(t[r], e, i)) break;
|
|
760
|
+
a.aggregate(u);
|
|
761
761
|
}
|
|
762
|
-
return (this.eager === !0 || this.eager === "append") && e != null && e.input && t &&
|
|
762
|
+
return (this.eager === !0 || this.eager === "append") && e != null && e.input && t && a.aggregate(this._appendEager()), i != null && (a.tailShift += this.appendTail(i).tailShift), a;
|
|
763
763
|
}
|
|
764
764
|
remove(t, e) {
|
|
765
765
|
return t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), this._value = this.displayValue.slice(0, t) + this.displayValue.slice(e), new d();
|
|
@@ -796,47 +796,47 @@ class g {
|
|
|
796
796
|
doCommit() {
|
|
797
797
|
this.commit && this.commit(this.value, this);
|
|
798
798
|
}
|
|
799
|
-
splice(t, e, s, i,
|
|
800
|
-
s === void 0 && (s = ""), i === void 0 && (i = h.NONE),
|
|
799
|
+
splice(t, e, s, i, a) {
|
|
800
|
+
s === void 0 && (s = ""), i === void 0 && (i = h.NONE), a === void 0 && (a = {
|
|
801
801
|
input: !0
|
|
802
802
|
});
|
|
803
|
-
const
|
|
803
|
+
const r = t + e, u = this.extractTail(r), l = this.eager === !0 || this.eager === "remove";
|
|
804
804
|
let o;
|
|
805
|
-
l && (i = it(i), o = this.extractInput(0,
|
|
805
|
+
l && (i = it(i), o = this.extractInput(0, r, {
|
|
806
806
|
raw: !0
|
|
807
807
|
}));
|
|
808
808
|
let c = t;
|
|
809
|
-
const
|
|
810
|
-
if (i !== h.NONE && (c = this.nearestInputPos(t, e > 1 && t !== 0 && !l ? h.NONE : i),
|
|
809
|
+
const g = new d();
|
|
810
|
+
if (i !== h.NONE && (c = this.nearestInputPos(t, e > 1 && t !== 0 && !l ? h.NONE : i), g.tailShift = c - t), g.aggregate(this.remove(c)), l && i !== h.NONE && o === this.rawInputValue)
|
|
811
811
|
if (i === h.FORCE_LEFT) {
|
|
812
|
-
let
|
|
813
|
-
for (; o === this.rawInputValue && (
|
|
814
|
-
|
|
812
|
+
let v;
|
|
813
|
+
for (; o === this.rawInputValue && (v = this.displayValue.length); )
|
|
814
|
+
g.aggregate(new d({
|
|
815
815
|
tailShift: -1
|
|
816
|
-
})).aggregate(this.remove(
|
|
816
|
+
})).aggregate(this.remove(v - 1));
|
|
817
817
|
} else i === h.FORCE_RIGHT && u.unshift();
|
|
818
|
-
return
|
|
818
|
+
return g.aggregate(this.append(s, a, u));
|
|
819
819
|
}
|
|
820
820
|
maskEquals(t) {
|
|
821
821
|
return this.mask === t;
|
|
822
822
|
}
|
|
823
823
|
optionsIsChanged(t) {
|
|
824
|
-
return !
|
|
824
|
+
return !I(this, t);
|
|
825
825
|
}
|
|
826
826
|
typedValueEquals(t) {
|
|
827
827
|
const e = this.typedValue;
|
|
828
|
-
return t === e ||
|
|
828
|
+
return t === e || m.EMPTY_VALUES.includes(t) && m.EMPTY_VALUES.includes(e) || (this.format ? this.format(t, this) === this.format(this.typedValue, this) : !1);
|
|
829
829
|
}
|
|
830
830
|
pad(t) {
|
|
831
831
|
return new d();
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
|
-
|
|
834
|
+
m.DEFAULTS = {
|
|
835
835
|
skipInvalid: !0
|
|
836
836
|
};
|
|
837
|
-
|
|
838
|
-
p.Masked =
|
|
839
|
-
class
|
|
837
|
+
m.EMPTY_VALUES = [void 0, null, ""];
|
|
838
|
+
p.Masked = m;
|
|
839
|
+
class y {
|
|
840
840
|
/** */
|
|
841
841
|
constructor(t, e) {
|
|
842
842
|
t === void 0 && (t = []), e === void 0 && (e = 0), this.chunks = t, this.from = e;
|
|
@@ -852,7 +852,7 @@ class B {
|
|
|
852
852
|
t.from === e.from + e.toString().length;
|
|
853
853
|
if (t instanceof F)
|
|
854
854
|
s ? e.extend(t.toString()) : this.chunks.push(t);
|
|
855
|
-
else if (t instanceof
|
|
855
|
+
else if (t instanceof y) {
|
|
856
856
|
if (t.stop == null) {
|
|
857
857
|
let i;
|
|
858
858
|
for (; t.chunks.length && t.chunks[0].stop == null; )
|
|
@@ -866,11 +866,11 @@ class B {
|
|
|
866
866
|
return new F(this.toString()).appendTo(t);
|
|
867
867
|
const e = new d();
|
|
868
868
|
for (let s = 0; s < this.chunks.length; ++s) {
|
|
869
|
-
const i = this.chunks[s],
|
|
869
|
+
const i = this.chunks[s], a = t._mapPosToBlock(t.displayValue.length), r = i.stop;
|
|
870
870
|
let u;
|
|
871
|
-
if (
|
|
872
|
-
(!
|
|
873
|
-
t._stops.indexOf(
|
|
871
|
+
if (r != null && // if block not found or stop is behind lastBlock
|
|
872
|
+
(!a || a.index <= r) && ((i instanceof y || // for continuous block also check if stop is exist
|
|
873
|
+
t._stops.indexOf(r) >= 0) && e.aggregate(t._appendPlaceholder(r)), u = i instanceof y && t._blocks[r]), u) {
|
|
874
874
|
const l = u.appendTail(i);
|
|
875
875
|
e.aggregate(l);
|
|
876
876
|
const o = i.toString().slice(l.rawInserted.length);
|
|
@@ -898,8 +898,8 @@ class B {
|
|
|
898
898
|
...s
|
|
899
899
|
} = t;
|
|
900
900
|
Object.assign(this, s), this.chunks = e.map((i) => {
|
|
901
|
-
const
|
|
902
|
-
return
|
|
901
|
+
const a = "chunks" in i ? new y() : new F();
|
|
902
|
+
return a.state = i, a;
|
|
903
903
|
});
|
|
904
904
|
}
|
|
905
905
|
unshift(t) {
|
|
@@ -907,13 +907,13 @@ class B {
|
|
|
907
907
|
const e = t != null ? t - this.from : t;
|
|
908
908
|
let s = 0;
|
|
909
909
|
for (; s < this.chunks.length; ) {
|
|
910
|
-
const i = this.chunks[s],
|
|
910
|
+
const i = this.chunks[s], a = i.unshift(e);
|
|
911
911
|
if (i.toString()) {
|
|
912
|
-
if (!
|
|
912
|
+
if (!a) break;
|
|
913
913
|
++s;
|
|
914
914
|
} else
|
|
915
915
|
this.chunks.splice(s, 1);
|
|
916
|
-
if (
|
|
916
|
+
if (a) return a;
|
|
917
917
|
}
|
|
918
918
|
return "";
|
|
919
919
|
}
|
|
@@ -1084,11 +1084,11 @@ class Z {
|
|
|
1084
1084
|
}
|
|
1085
1085
|
_appendChar(t, e) {
|
|
1086
1086
|
if (e === void 0 && (e = {}), this.isFilled) return new d();
|
|
1087
|
-
const s = this.eager === !0 || this.eager === "append",
|
|
1087
|
+
const s = this.eager === !0 || this.eager === "append", a = this.char === t && (this.isUnmasking || e.input || e.raw) && (!e.raw || !s) && !e.tail, r = new d({
|
|
1088
1088
|
inserted: this.char,
|
|
1089
|
-
rawInserted:
|
|
1089
|
+
rawInserted: a ? this.char : ""
|
|
1090
1090
|
});
|
|
1091
|
-
return this._value = this.char, this._isRawInput =
|
|
1091
|
+
return this._value = this.char, this._isRawInput = a && (e.raw || e.input), r;
|
|
1092
1092
|
}
|
|
1093
1093
|
_appendEager() {
|
|
1094
1094
|
return this._appendChar(this.char, {
|
|
@@ -1124,7 +1124,7 @@ class Z {
|
|
|
1124
1124
|
return this._appendPlaceholder();
|
|
1125
1125
|
}
|
|
1126
1126
|
}
|
|
1127
|
-
class
|
|
1127
|
+
class D {
|
|
1128
1128
|
/** */
|
|
1129
1129
|
/** */
|
|
1130
1130
|
/** */
|
|
@@ -1138,8 +1138,8 @@ class w {
|
|
|
1138
1138
|
parent: e,
|
|
1139
1139
|
isOptional: s,
|
|
1140
1140
|
placeholderChar: i,
|
|
1141
|
-
displayChar:
|
|
1142
|
-
lazy:
|
|
1141
|
+
displayChar: a,
|
|
1142
|
+
lazy: r,
|
|
1143
1143
|
eager: u,
|
|
1144
1144
|
...l
|
|
1145
1145
|
} = t;
|
|
@@ -1147,8 +1147,8 @@ class w {
|
|
|
1147
1147
|
parent: e,
|
|
1148
1148
|
isOptional: s,
|
|
1149
1149
|
placeholderChar: i,
|
|
1150
|
-
displayChar:
|
|
1151
|
-
lazy:
|
|
1150
|
+
displayChar: a,
|
|
1151
|
+
lazy: r,
|
|
1152
1152
|
eager: u
|
|
1153
1153
|
});
|
|
1154
1154
|
}
|
|
@@ -1201,17 +1201,17 @@ class w {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
nearestInputPos(t, e) {
|
|
1203
1203
|
e === void 0 && (e = h.NONE);
|
|
1204
|
-
const s = 0, i = this.value.length,
|
|
1204
|
+
const s = 0, i = this.value.length, a = Math.min(Math.max(t, s), i);
|
|
1205
1205
|
switch (e) {
|
|
1206
1206
|
case h.LEFT:
|
|
1207
1207
|
case h.FORCE_LEFT:
|
|
1208
|
-
return this.isComplete ?
|
|
1208
|
+
return this.isComplete ? a : s;
|
|
1209
1209
|
case h.RIGHT:
|
|
1210
1210
|
case h.FORCE_RIGHT:
|
|
1211
|
-
return this.isComplete ?
|
|
1211
|
+
return this.isComplete ? a : i;
|
|
1212
1212
|
case h.NONE:
|
|
1213
1213
|
default:
|
|
1214
|
-
return
|
|
1214
|
+
return a;
|
|
1215
1215
|
}
|
|
1216
1216
|
}
|
|
1217
1217
|
totalInputPositions(t, e) {
|
|
@@ -1245,13 +1245,13 @@ class w {
|
|
|
1245
1245
|
return new d();
|
|
1246
1246
|
}
|
|
1247
1247
|
}
|
|
1248
|
-
|
|
1248
|
+
D.DEFAULT_DEFINITIONS = {
|
|
1249
1249
|
0: /\d/,
|
|
1250
1250
|
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]/,
|
|
1251
1251
|
// http://stackoverflow.com/a/22075070
|
|
1252
1252
|
"*": /./
|
|
1253
1253
|
};
|
|
1254
|
-
class ht extends
|
|
1254
|
+
class ht extends m {
|
|
1255
1255
|
/** */
|
|
1256
1256
|
/** Enable characters overwriting */
|
|
1257
1257
|
/** */
|
|
@@ -1266,7 +1266,7 @@ class ht extends g {
|
|
|
1266
1266
|
}
|
|
1267
1267
|
}
|
|
1268
1268
|
p.MaskedRegExp = ht;
|
|
1269
|
-
class k extends
|
|
1269
|
+
class k extends m {
|
|
1270
1270
|
/** */
|
|
1271
1271
|
/** */
|
|
1272
1272
|
/** Single char for empty input */
|
|
@@ -1280,7 +1280,7 @@ class k extends g {
|
|
|
1280
1280
|
super({
|
|
1281
1281
|
...k.DEFAULTS,
|
|
1282
1282
|
...t,
|
|
1283
|
-
definitions: Object.assign({},
|
|
1283
|
+
definitions: Object.assign({}, D.DEFAULT_DEFINITIONS, t?.definitions)
|
|
1284
1284
|
});
|
|
1285
1285
|
}
|
|
1286
1286
|
updateOptions(t) {
|
|
@@ -1295,17 +1295,17 @@ class k extends g {
|
|
|
1295
1295
|
const e = this.mask;
|
|
1296
1296
|
if (!e || !t) return;
|
|
1297
1297
|
let s = !1, i = !1;
|
|
1298
|
-
for (let
|
|
1298
|
+
for (let a = 0; a < e.length; ++a) {
|
|
1299
1299
|
if (this.blocks) {
|
|
1300
|
-
const o = e.slice(
|
|
1301
|
-
c.sort((
|
|
1302
|
-
const
|
|
1303
|
-
if (
|
|
1300
|
+
const o = e.slice(a), c = Object.keys(this.blocks).filter((v) => o.indexOf(v) === 0);
|
|
1301
|
+
c.sort((v, B) => B.length - v.length);
|
|
1302
|
+
const g = c[0];
|
|
1303
|
+
if (g) {
|
|
1304
1304
|
const {
|
|
1305
|
-
expose:
|
|
1306
|
-
repeat:
|
|
1305
|
+
expose: v,
|
|
1306
|
+
repeat: B,
|
|
1307
1307
|
...J
|
|
1308
|
-
} = S(this.blocks[
|
|
1308
|
+
} = S(this.blocks[g]), P = {
|
|
1309
1309
|
lazy: this.lazy,
|
|
1310
1310
|
eager: this.eager,
|
|
1311
1311
|
placeholderChar: this.placeholderChar,
|
|
@@ -1313,43 +1313,43 @@ class k extends g {
|
|
|
1313
1313
|
overwrite: this.overwrite,
|
|
1314
1314
|
autofix: this.autofix,
|
|
1315
1315
|
...J,
|
|
1316
|
-
repeat:
|
|
1316
|
+
repeat: B,
|
|
1317
1317
|
parent: this
|
|
1318
|
-
}, O =
|
|
1318
|
+
}, O = B != null ? new p.RepeatBlock(
|
|
1319
1319
|
P
|
|
1320
1320
|
/* TODO */
|
|
1321
1321
|
) : x(P);
|
|
1322
|
-
O && (this._blocks.push(O),
|
|
1322
|
+
O && (this._blocks.push(O), v && (this.exposeBlock = O), this._maskedBlocks[g] || (this._maskedBlocks[g] = []), this._maskedBlocks[g].push(this._blocks.length - 1)), a += g.length - 1;
|
|
1323
1323
|
continue;
|
|
1324
1324
|
}
|
|
1325
1325
|
}
|
|
1326
|
-
let
|
|
1327
|
-
if (
|
|
1326
|
+
let r = e[a], u = r in t;
|
|
1327
|
+
if (r === k.STOP_CHAR) {
|
|
1328
1328
|
this._stops.push(this._blocks.length);
|
|
1329
1329
|
continue;
|
|
1330
1330
|
}
|
|
1331
|
-
if (
|
|
1331
|
+
if (r === "{" || r === "}") {
|
|
1332
1332
|
s = !s;
|
|
1333
1333
|
continue;
|
|
1334
1334
|
}
|
|
1335
|
-
if (
|
|
1335
|
+
if (r === "[" || r === "]") {
|
|
1336
1336
|
i = !i;
|
|
1337
1337
|
continue;
|
|
1338
1338
|
}
|
|
1339
|
-
if (
|
|
1340
|
-
if (++
|
|
1339
|
+
if (r === k.ESCAPE_CHAR) {
|
|
1340
|
+
if (++a, r = e[a], !r) break;
|
|
1341
1341
|
u = !1;
|
|
1342
1342
|
}
|
|
1343
|
-
const l = u ? new
|
|
1343
|
+
const l = u ? new D({
|
|
1344
1344
|
isOptional: i,
|
|
1345
1345
|
lazy: this.lazy,
|
|
1346
1346
|
eager: this.eager,
|
|
1347
1347
|
placeholderChar: this.placeholderChar,
|
|
1348
1348
|
displayChar: this.displayChar,
|
|
1349
|
-
...S(t[
|
|
1349
|
+
...S(t[r]),
|
|
1350
1350
|
parent: this
|
|
1351
1351
|
}) : new Z({
|
|
1352
|
-
char:
|
|
1352
|
+
char: r,
|
|
1353
1353
|
eager: this.eager,
|
|
1354
1354
|
isUnmasking: s
|
|
1355
1355
|
});
|
|
@@ -1371,7 +1371,7 @@ class k extends g {
|
|
|
1371
1371
|
_blocks: e,
|
|
1372
1372
|
...s
|
|
1373
1373
|
} = t;
|
|
1374
|
-
this._blocks.forEach((i,
|
|
1374
|
+
this._blocks.forEach((i, a) => i.state = e[a]), super.state = s;
|
|
1375
1375
|
}
|
|
1376
1376
|
reset() {
|
|
1377
1377
|
super.reset(), this._blocks.forEach((t) => t.reset());
|
|
@@ -1434,9 +1434,9 @@ class k extends g {
|
|
|
1434
1434
|
if (s == null) return e;
|
|
1435
1435
|
this._blocks[s].isFilled && ++s;
|
|
1436
1436
|
for (let i = s; i < this._blocks.length; ++i) {
|
|
1437
|
-
const
|
|
1438
|
-
if (!
|
|
1439
|
-
e.aggregate(
|
|
1437
|
+
const a = this._blocks[i]._appendEager();
|
|
1438
|
+
if (!a.inserted) break;
|
|
1439
|
+
e.aggregate(a);
|
|
1440
1440
|
}
|
|
1441
1441
|
return e;
|
|
1442
1442
|
}
|
|
@@ -1444,11 +1444,11 @@ class k extends g {
|
|
|
1444
1444
|
e === void 0 && (e = {});
|
|
1445
1445
|
const s = this._mapPosToBlock(this.displayValue.length), i = new d();
|
|
1446
1446
|
if (!s) return i;
|
|
1447
|
-
for (let
|
|
1448
|
-
var
|
|
1447
|
+
for (let r = s.index, u; u = this._blocks[r]; ++r) {
|
|
1448
|
+
var a;
|
|
1449
1449
|
const l = u._appendChar(t, {
|
|
1450
1450
|
...e,
|
|
1451
|
-
_beforeTailState: (
|
|
1451
|
+
_beforeTailState: (a = e._beforeTailState) == null || (a = a._blocks) == null ? void 0 : a[r]
|
|
1452
1452
|
});
|
|
1453
1453
|
if (i.aggregate(l), l.consumed) break;
|
|
1454
1454
|
}
|
|
@@ -1456,17 +1456,17 @@ class k extends g {
|
|
|
1456
1456
|
}
|
|
1457
1457
|
extractTail(t, e) {
|
|
1458
1458
|
t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
|
|
1459
|
-
const s = new
|
|
1460
|
-
return t === e || this._forEachBlocksInRange(t, e, (i,
|
|
1461
|
-
const l = i.extractTail(
|
|
1462
|
-
l.stop = this._findStopBefore(
|
|
1459
|
+
const s = new y();
|
|
1460
|
+
return t === e || this._forEachBlocksInRange(t, e, (i, a, r, u) => {
|
|
1461
|
+
const l = i.extractTail(r, u);
|
|
1462
|
+
l.stop = this._findStopBefore(a), l.from = this._blockStartPos(a), l instanceof y && (l.blockIndex = a), s.extend(l);
|
|
1463
1463
|
}), s;
|
|
1464
1464
|
}
|
|
1465
1465
|
extractInput(t, e, s) {
|
|
1466
1466
|
if (t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), s === void 0 && (s = {}), t === e) return "";
|
|
1467
1467
|
let i = "";
|
|
1468
|
-
return this._forEachBlocksInRange(t, e, (
|
|
1469
|
-
i +=
|
|
1468
|
+
return this._forEachBlocksInRange(t, e, (a, r, u, l) => {
|
|
1469
|
+
i += a.extractInput(u, l, s);
|
|
1470
1470
|
}), i;
|
|
1471
1471
|
}
|
|
1472
1472
|
_findStopBefore(t) {
|
|
@@ -1484,11 +1484,11 @@ class k extends g {
|
|
|
1484
1484
|
if (this.lazy && t == null) return e;
|
|
1485
1485
|
const s = this._mapPosToBlock(this.displayValue.length);
|
|
1486
1486
|
if (!s) return e;
|
|
1487
|
-
const i = s.index,
|
|
1488
|
-
return this._blocks.slice(i,
|
|
1489
|
-
if (!
|
|
1487
|
+
const i = s.index, a = t ?? this._blocks.length;
|
|
1488
|
+
return this._blocks.slice(i, a).forEach((r) => {
|
|
1489
|
+
if (!r.lazy || t != null) {
|
|
1490
1490
|
var u;
|
|
1491
|
-
e.aggregate(
|
|
1491
|
+
e.aggregate(r._appendPlaceholder((u = r._blocks) == null ? void 0 : u.length));
|
|
1492
1492
|
}
|
|
1493
1493
|
}), e;
|
|
1494
1494
|
}
|
|
@@ -1496,11 +1496,11 @@ class k extends g {
|
|
|
1496
1496
|
_mapPosToBlock(t) {
|
|
1497
1497
|
let e = "";
|
|
1498
1498
|
for (let s = 0; s < this._blocks.length; ++s) {
|
|
1499
|
-
const i = this._blocks[s],
|
|
1499
|
+
const i = this._blocks[s], a = e.length;
|
|
1500
1500
|
if (e += i.displayValue, t <= e.length)
|
|
1501
1501
|
return {
|
|
1502
1502
|
index: s,
|
|
1503
|
-
offset: t -
|
|
1503
|
+
offset: t - a
|
|
1504
1504
|
};
|
|
1505
1505
|
}
|
|
1506
1506
|
}
|
|
@@ -1511,19 +1511,19 @@ class k extends g {
|
|
|
1511
1511
|
e === void 0 && (e = this.displayValue.length);
|
|
1512
1512
|
const i = this._mapPosToBlock(t);
|
|
1513
1513
|
if (i) {
|
|
1514
|
-
const
|
|
1515
|
-
if (s(this._blocks[i.index], i.index, u, l),
|
|
1516
|
-
for (let o = i.index + 1; o <
|
|
1514
|
+
const a = this._mapPosToBlock(e), r = a && i.index === a.index, u = i.offset, l = a && r ? a.offset : this._blocks[i.index].displayValue.length;
|
|
1515
|
+
if (s(this._blocks[i.index], i.index, u, l), a && !r) {
|
|
1516
|
+
for (let o = i.index + 1; o < a.index; ++o)
|
|
1517
1517
|
s(this._blocks[o], o, 0, this._blocks[o].displayValue.length);
|
|
1518
|
-
s(this._blocks[
|
|
1518
|
+
s(this._blocks[a.index], a.index, 0, a.offset);
|
|
1519
1519
|
}
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
1522
1522
|
remove(t, e) {
|
|
1523
1523
|
t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
|
|
1524
1524
|
const s = super.remove(t, e);
|
|
1525
|
-
return this._forEachBlocksInRange(t, e, (i,
|
|
1526
|
-
s.aggregate(i.remove(
|
|
1525
|
+
return this._forEachBlocksInRange(t, e, (i, a, r, u) => {
|
|
1526
|
+
s.aggregate(i.remove(r, u));
|
|
1527
1527
|
}), s;
|
|
1528
1528
|
}
|
|
1529
1529
|
nearestInputPos(t, e) {
|
|
@@ -1547,8 +1547,8 @@ class k extends g {
|
|
|
1547
1547
|
totalInputPositions(t, e) {
|
|
1548
1548
|
t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length);
|
|
1549
1549
|
let s = 0;
|
|
1550
|
-
return this._forEachBlocksInRange(t, e, (i,
|
|
1551
|
-
s += i.totalInputPositions(
|
|
1550
|
+
return this._forEachBlocksInRange(t, e, (i, a, r, u) => {
|
|
1551
|
+
s += i.totalInputPositions(r, u);
|
|
1552
1552
|
}), s;
|
|
1553
1553
|
}
|
|
1554
1554
|
/** Get block by name */
|
|
@@ -1566,16 +1566,16 @@ class k extends g {
|
|
|
1566
1566
|
}
|
|
1567
1567
|
}
|
|
1568
1568
|
k.DEFAULTS = {
|
|
1569
|
-
...
|
|
1569
|
+
...m.DEFAULTS,
|
|
1570
1570
|
lazy: !0,
|
|
1571
1571
|
placeholderChar: "_"
|
|
1572
1572
|
};
|
|
1573
1573
|
k.STOP_CHAR = "`";
|
|
1574
1574
|
k.ESCAPE_CHAR = "\\";
|
|
1575
|
-
k.InputDefinition =
|
|
1575
|
+
k.InputDefinition = D;
|
|
1576
1576
|
k.FixedDefinition = Z;
|
|
1577
1577
|
p.MaskedPattern = k;
|
|
1578
|
-
class
|
|
1578
|
+
class V extends k {
|
|
1579
1579
|
/**
|
|
1580
1580
|
Optionally sets max length of pattern.
|
|
1581
1581
|
Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
|
|
@@ -1596,22 +1596,22 @@ class I extends k {
|
|
|
1596
1596
|
to: e = this.to || 0,
|
|
1597
1597
|
from: s = this.from || 0,
|
|
1598
1598
|
maxLength: i = this.maxLength || 0,
|
|
1599
|
-
autofix:
|
|
1600
|
-
...
|
|
1599
|
+
autofix: a = this.autofix,
|
|
1600
|
+
...r
|
|
1601
1601
|
} = t;
|
|
1602
|
-
this.to = e, this.from = s, this.maxLength = Math.max(String(e).length, i), this.autofix =
|
|
1602
|
+
this.to = e, this.from = s, this.maxLength = Math.max(String(e).length, i), this.autofix = a;
|
|
1603
1603
|
const u = String(this.from).padStart(this.maxLength, "0"), l = String(this.to).padStart(this.maxLength, "0");
|
|
1604
1604
|
let o = 0;
|
|
1605
1605
|
for (; o < l.length && l[o] === u[o]; ) ++o;
|
|
1606
|
-
|
|
1606
|
+
r.mask = l.slice(0, o).replace(/0/g, "\\0") + "0".repeat(this.maxLength - o), super._update(r);
|
|
1607
1607
|
}
|
|
1608
1608
|
get isComplete() {
|
|
1609
1609
|
return super.isComplete && !!this.value;
|
|
1610
1610
|
}
|
|
1611
1611
|
boundaries(t) {
|
|
1612
1612
|
let e = "", s = "";
|
|
1613
|
-
const [, i,
|
|
1614
|
-
return
|
|
1613
|
+
const [, i, a] = t.match(/^(\D*)(\d*)(\D*)/) || [];
|
|
1614
|
+
return a && (e = "0".repeat(i.length) + a, s = "9".repeat(i.length) + a), e = e.padEnd(this.maxLength, "0"), s = s.padEnd(this.maxLength, "9"), [e, s];
|
|
1615
1615
|
}
|
|
1616
1616
|
doPrepareChar(t, e) {
|
|
1617
1617
|
e === void 0 && (e = {});
|
|
@@ -1620,14 +1620,14 @@ class I extends k {
|
|
|
1620
1620
|
}
|
|
1621
1621
|
_appendCharRaw(t, e) {
|
|
1622
1622
|
if (e === void 0 && (e = {}), !this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(t, e);
|
|
1623
|
-
const s = String(this.from).padStart(this.maxLength, "0"), i = String(this.to).padStart(this.maxLength, "0"), [
|
|
1624
|
-
return Number(
|
|
1623
|
+
const s = String(this.from).padStart(this.maxLength, "0"), i = String(this.to).padStart(this.maxLength, "0"), [a, r] = this.boundaries(this.value + t);
|
|
1624
|
+
return Number(r) < this.from ? super._appendCharRaw(s[this.value.length], e) : Number(a) > this.to ? !e.tail && this.autofix === "pad" && this.value.length + 1 < this.maxLength ? super._appendCharRaw(s[this.value.length], e).aggregate(this._appendCharRaw(t, e)) : super._appendCharRaw(i[this.value.length], e) : super._appendCharRaw(t, e);
|
|
1625
1625
|
}
|
|
1626
1626
|
doValidate(t) {
|
|
1627
1627
|
const e = this.value;
|
|
1628
1628
|
if (e.search(/[^0]/) === -1 && e.length <= this._matchFrom) return !0;
|
|
1629
|
-
const [i,
|
|
1630
|
-
return this.from <= Number(
|
|
1629
|
+
const [i, a] = this.boundaries(e);
|
|
1630
|
+
return this.from <= Number(a) && Number(i) <= this.to && super.doValidate(t);
|
|
1631
1631
|
}
|
|
1632
1632
|
pad(t) {
|
|
1633
1633
|
const e = new d();
|
|
@@ -1635,14 +1635,14 @@ class I extends k {
|
|
|
1635
1635
|
const s = this.value, i = this.maxLength - this.value.length;
|
|
1636
1636
|
if (i) {
|
|
1637
1637
|
this.reset();
|
|
1638
|
-
for (let
|
|
1638
|
+
for (let a = 0; a < i; ++a)
|
|
1639
1639
|
e.aggregate(super._appendCharRaw("0", t));
|
|
1640
|
-
s.split("").forEach((
|
|
1640
|
+
s.split("").forEach((a) => this._appendCharRaw(a));
|
|
1641
1641
|
}
|
|
1642
1642
|
return e;
|
|
1643
1643
|
}
|
|
1644
1644
|
}
|
|
1645
|
-
p.MaskedRange =
|
|
1645
|
+
p.MaskedRange = V;
|
|
1646
1646
|
const ot = "d{.}`m{.}`Y";
|
|
1647
1647
|
class A extends k {
|
|
1648
1648
|
static extractPatternOptions(t) {
|
|
@@ -1675,15 +1675,15 @@ class A extends k {
|
|
|
1675
1675
|
mask: e,
|
|
1676
1676
|
pattern: s,
|
|
1677
1677
|
blocks: i,
|
|
1678
|
-
...
|
|
1678
|
+
...a
|
|
1679
1679
|
} = {
|
|
1680
1680
|
...A.DEFAULTS,
|
|
1681
1681
|
...t
|
|
1682
|
-
},
|
|
1683
|
-
t.min && (
|
|
1684
|
-
...
|
|
1682
|
+
}, r = Object.assign({}, A.GET_DEFAULT_BLOCKS());
|
|
1683
|
+
t.min && (r.Y.from = t.min.getFullYear()), t.max && (r.Y.to = t.max.getFullYear()), t.min && t.max && r.Y.from === r.Y.to && (r.m.from = t.min.getMonth() + 1, r.m.to = t.max.getMonth() + 1, r.m.from === r.m.to && (r.d.from = t.min.getDate(), r.d.to = t.max.getDate())), Object.assign(r, this.blocks, i), super._update({
|
|
1684
|
+
...a,
|
|
1685
1685
|
mask: b(e) ? e : s,
|
|
1686
|
-
blocks:
|
|
1686
|
+
blocks: r
|
|
1687
1687
|
});
|
|
1688
1688
|
}
|
|
1689
1689
|
doValidate(t) {
|
|
@@ -1716,19 +1716,19 @@ class A extends k {
|
|
|
1716
1716
|
}
|
|
1717
1717
|
A.GET_DEFAULT_BLOCKS = () => ({
|
|
1718
1718
|
d: {
|
|
1719
|
-
mask:
|
|
1719
|
+
mask: V,
|
|
1720
1720
|
from: 1,
|
|
1721
1721
|
to: 31,
|
|
1722
1722
|
maxLength: 2
|
|
1723
1723
|
},
|
|
1724
1724
|
m: {
|
|
1725
|
-
mask:
|
|
1725
|
+
mask: V,
|
|
1726
1726
|
from: 1,
|
|
1727
1727
|
to: 12,
|
|
1728
1728
|
maxLength: 2
|
|
1729
1729
|
},
|
|
1730
1730
|
Y: {
|
|
1731
|
-
mask:
|
|
1731
|
+
mask: V,
|
|
1732
1732
|
from: 1900,
|
|
1733
1733
|
to: 9999
|
|
1734
1734
|
}
|
|
@@ -1737,21 +1737,21 @@ A.DEFAULTS = {
|
|
|
1737
1737
|
...k.DEFAULTS,
|
|
1738
1738
|
mask: Date,
|
|
1739
1739
|
pattern: ot,
|
|
1740
|
-
format: (
|
|
1741
|
-
if (!
|
|
1742
|
-
const e = String(
|
|
1740
|
+
format: (n, t) => {
|
|
1741
|
+
if (!n) return "";
|
|
1742
|
+
const e = String(n.getDate()).padStart(2, "0"), s = String(n.getMonth() + 1).padStart(2, "0"), i = n.getFullYear();
|
|
1743
1743
|
return [e, s, i].join(".");
|
|
1744
1744
|
},
|
|
1745
|
-
parse: (
|
|
1746
|
-
const [e, s, i] =
|
|
1745
|
+
parse: (n, t) => {
|
|
1746
|
+
const [e, s, i] = n.split(".").map(Number);
|
|
1747
1747
|
return new Date(i, s - 1, e);
|
|
1748
1748
|
}
|
|
1749
1749
|
};
|
|
1750
1750
|
p.MaskedDate = A;
|
|
1751
|
-
class
|
|
1751
|
+
class M extends m {
|
|
1752
1752
|
constructor(t) {
|
|
1753
1753
|
super({
|
|
1754
|
-
...
|
|
1754
|
+
...M.DEFAULTS,
|
|
1755
1755
|
...t
|
|
1756
1756
|
}), this.currentMask = void 0;
|
|
1757
1757
|
}
|
|
@@ -1763,13 +1763,13 @@ class T extends g {
|
|
|
1763
1763
|
const {
|
|
1764
1764
|
expose: s,
|
|
1765
1765
|
...i
|
|
1766
|
-
} = S(e),
|
|
1766
|
+
} = S(e), a = x({
|
|
1767
1767
|
overwrite: this._overwrite,
|
|
1768
1768
|
eager: this._eager,
|
|
1769
1769
|
skipInvalid: this._skipInvalid,
|
|
1770
1770
|
...i
|
|
1771
1771
|
});
|
|
1772
|
-
return s && (this.exposeMask =
|
|
1772
|
+
return s && (this.exposeMask = a), a;
|
|
1773
1773
|
}) : []);
|
|
1774
1774
|
}
|
|
1775
1775
|
_appendCharRaw(t, e) {
|
|
@@ -1779,10 +1779,10 @@ class T extends g {
|
|
|
1779
1779
|
}
|
|
1780
1780
|
_applyDispatch(t, e, s) {
|
|
1781
1781
|
t === void 0 && (t = ""), e === void 0 && (e = {}), s === void 0 && (s = "");
|
|
1782
|
-
const i = e.tail && e._beforeTailState != null ? e._beforeTailState._value : this.value,
|
|
1782
|
+
const i = e.tail && e._beforeTailState != null ? e._beforeTailState._value : this.value, a = this.rawInputValue, r = e.tail && e._beforeTailState != null ? e._beforeTailState._rawInputValue : a, u = a.slice(r.length), l = this.currentMask, o = new d(), c = l?.state;
|
|
1783
1783
|
return this.currentMask = this.doDispatch(t, {
|
|
1784
1784
|
...e
|
|
1785
|
-
}, s), this.currentMask && (this.currentMask !== l ? (this.currentMask.reset(),
|
|
1785
|
+
}, s), this.currentMask && (this.currentMask !== l ? (this.currentMask.reset(), r && (this.currentMask.append(r, {
|
|
1786
1786
|
raw: !0
|
|
1787
1787
|
}), o.tailShift = this.currentMask.value.length - i.length), u && (o.tailShift += this.currentMask.append(u, {
|
|
1788
1788
|
raw: !0,
|
|
@@ -1818,8 +1818,8 @@ class T extends g {
|
|
|
1818
1818
|
e === void 0 && (e = {});
|
|
1819
1819
|
let [s, i] = super.doPrepare(t, e);
|
|
1820
1820
|
if (this.currentMask) {
|
|
1821
|
-
let
|
|
1822
|
-
[s,
|
|
1821
|
+
let a;
|
|
1822
|
+
[s, a] = super.doPrepare(s, this.currentMaskFlags(e)), i = i.aggregate(a);
|
|
1823
1823
|
}
|
|
1824
1824
|
return [s, i];
|
|
1825
1825
|
}
|
|
@@ -1827,8 +1827,8 @@ class T extends g {
|
|
|
1827
1827
|
e === void 0 && (e = {});
|
|
1828
1828
|
let [s, i] = super.doPrepareChar(t, e);
|
|
1829
1829
|
if (this.currentMask) {
|
|
1830
|
-
let
|
|
1831
|
-
[s,
|
|
1830
|
+
let a;
|
|
1831
|
+
[s, a] = super.doPrepareChar(s, this.currentMaskFlags(e)), i = i.aggregate(a);
|
|
1832
1832
|
}
|
|
1833
1833
|
return [s, i];
|
|
1834
1834
|
}
|
|
@@ -1889,9 +1889,9 @@ class T extends g {
|
|
|
1889
1889
|
compiledMasks: e,
|
|
1890
1890
|
currentMaskRef: s,
|
|
1891
1891
|
currentMask: i,
|
|
1892
|
-
...
|
|
1892
|
+
...a
|
|
1893
1893
|
} = t;
|
|
1894
|
-
e && this.compiledMasks.forEach((
|
|
1894
|
+
e && this.compiledMasks.forEach((r, u) => r.state = e[u]), s != null && (this.currentMask = s, this.currentMask.state = i), super.state = a;
|
|
1895
1895
|
}
|
|
1896
1896
|
extractInput(t, e, s) {
|
|
1897
1897
|
return this.currentMask ? this.currentMask.extractInput(t, e, s) : "";
|
|
@@ -1934,9 +1934,9 @@ class T extends g {
|
|
|
1934
1934
|
if (!t[s]) return;
|
|
1935
1935
|
const {
|
|
1936
1936
|
mask: i,
|
|
1937
|
-
...
|
|
1937
|
+
...a
|
|
1938
1938
|
} = t[s];
|
|
1939
|
-
return
|
|
1939
|
+
return I(e, a) && e.maskEquals(i);
|
|
1940
1940
|
}) : super.maskEquals(t);
|
|
1941
1941
|
}
|
|
1942
1942
|
typedValueEquals(t) {
|
|
@@ -1944,24 +1944,24 @@ class T extends g {
|
|
|
1944
1944
|
return !!((e = this.currentMask) != null && e.typedValueEquals(t));
|
|
1945
1945
|
}
|
|
1946
1946
|
}
|
|
1947
|
-
|
|
1948
|
-
...
|
|
1949
|
-
dispatch: (
|
|
1947
|
+
M.DEFAULTS = {
|
|
1948
|
+
...m.DEFAULTS,
|
|
1949
|
+
dispatch: (n, t, e, s) => {
|
|
1950
1950
|
if (!t.compiledMasks.length) return;
|
|
1951
|
-
const i = t.rawInputValue,
|
|
1952
|
-
const l = t.currentMask ===
|
|
1953
|
-
return
|
|
1951
|
+
const i = t.rawInputValue, a = t.compiledMasks.map((r, u) => {
|
|
1952
|
+
const l = t.currentMask === r, o = l ? r.displayValue.length : r.nearestInputPos(r.displayValue.length, h.FORCE_LEFT);
|
|
1953
|
+
return r.rawInputValue !== i ? (r.reset(), r.append(i, {
|
|
1954
1954
|
raw: !0
|
|
1955
|
-
})) : l ||
|
|
1955
|
+
})) : l || r.remove(o), r.append(n, t.currentMaskFlags(e)), r.appendTail(s), {
|
|
1956
1956
|
index: u,
|
|
1957
|
-
weight:
|
|
1958
|
-
totalInputPositions:
|
|
1957
|
+
weight: r.rawInputValue.length,
|
|
1958
|
+
totalInputPositions: r.totalInputPositions(0, Math.max(o, r.nearestInputPos(r.displayValue.length, h.FORCE_LEFT)))
|
|
1959
1959
|
};
|
|
1960
1960
|
});
|
|
1961
|
-
return
|
|
1961
|
+
return a.sort((r, u) => u.weight - r.weight || u.totalInputPositions - r.totalInputPositions), t.compiledMasks[a[0].index];
|
|
1962
1962
|
}
|
|
1963
1963
|
};
|
|
1964
|
-
p.MaskedDynamic =
|
|
1964
|
+
p.MaskedDynamic = M;
|
|
1965
1965
|
class R extends k {
|
|
1966
1966
|
constructor(t) {
|
|
1967
1967
|
super({
|
|
@@ -1978,21 +1978,21 @@ class R extends k {
|
|
|
1978
1978
|
...s
|
|
1979
1979
|
} = t;
|
|
1980
1980
|
if (e) {
|
|
1981
|
-
const i = e.map((u) => u.length),
|
|
1982
|
-
s.mask = "*".repeat(
|
|
1981
|
+
const i = e.map((u) => u.length), a = Math.min(...i), r = Math.max(...i) - a;
|
|
1982
|
+
s.mask = "*".repeat(a), r && (s.mask += "[" + "*".repeat(r) + "]"), this.enum = e;
|
|
1983
1983
|
}
|
|
1984
1984
|
super._update(s);
|
|
1985
1985
|
}
|
|
1986
1986
|
_appendCharRaw(t, e) {
|
|
1987
1987
|
e === void 0 && (e = {});
|
|
1988
|
-
const s = Math.min(this.nearestInputPos(0, h.FORCE_RIGHT), this.value.length), i = this.enum.filter((
|
|
1988
|
+
const s = Math.min(this.nearestInputPos(0, h.FORCE_RIGHT), this.value.length), i = this.enum.filter((a) => this.matchValue(a, this.unmaskedValue + t, s));
|
|
1989
1989
|
if (i.length) {
|
|
1990
|
-
i.length === 1 && this._forEachBlocksInRange(0, this.value.length, (
|
|
1990
|
+
i.length === 1 && this._forEachBlocksInRange(0, this.value.length, (r, u) => {
|
|
1991
1991
|
const l = i[0][u];
|
|
1992
|
-
u >= this.value.length || l ===
|
|
1992
|
+
u >= this.value.length || l === r.value || (r.reset(), r._appendChar(l, e));
|
|
1993
1993
|
});
|
|
1994
|
-
const
|
|
1995
|
-
return i.length === 1 && i[0].slice(this.unmaskedValue.length).split("").forEach((
|
|
1994
|
+
const a = super._appendCharRaw(i[0][this.value.length], e);
|
|
1995
|
+
return i.length === 1 && i[0].slice(this.unmaskedValue.length).split("").forEach((r) => a.aggregate(super._appendCharRaw(r))), a;
|
|
1996
1996
|
}
|
|
1997
1997
|
return new d({
|
|
1998
1998
|
skip: !this.isComplete
|
|
@@ -2007,8 +2007,8 @@ class R extends k {
|
|
|
2007
2007
|
let i;
|
|
2008
2008
|
for (i = t; i >= 0 && !(this.enum.filter((u) => this.matchValue(u, this.value.slice(s, i), s)).length > 1); --i)
|
|
2009
2009
|
;
|
|
2010
|
-
const
|
|
2011
|
-
return
|
|
2010
|
+
const a = super.remove(i, e);
|
|
2011
|
+
return a.tailShift += i - t, a;
|
|
2012
2012
|
}
|
|
2013
2013
|
get isComplete() {
|
|
2014
2014
|
return this.enum.indexOf(this.value) >= 0;
|
|
@@ -2016,10 +2016,10 @@ class R extends k {
|
|
|
2016
2016
|
}
|
|
2017
2017
|
R.DEFAULTS = {
|
|
2018
2018
|
...k.DEFAULTS,
|
|
2019
|
-
matchValue: (
|
|
2019
|
+
matchValue: (n, t, e) => n.indexOf(t, e) === e
|
|
2020
2020
|
};
|
|
2021
2021
|
p.MaskedEnum = R;
|
|
2022
|
-
class pt extends
|
|
2022
|
+
class pt extends m {
|
|
2023
2023
|
/** */
|
|
2024
2024
|
/** Enable characters overwriting */
|
|
2025
2025
|
/** */
|
|
@@ -2036,8 +2036,8 @@ class pt extends g {
|
|
|
2036
2036
|
}
|
|
2037
2037
|
}
|
|
2038
2038
|
p.MaskedFunction = pt;
|
|
2039
|
-
var
|
|
2040
|
-
class
|
|
2039
|
+
var X;
|
|
2040
|
+
class E extends m {
|
|
2041
2041
|
/** Single char */
|
|
2042
2042
|
/** Single char */
|
|
2043
2043
|
/** Array of single chars */
|
|
@@ -2054,7 +2054,7 @@ class v extends g {
|
|
|
2054
2054
|
/** Parse string to get typed value */
|
|
2055
2055
|
constructor(t) {
|
|
2056
2056
|
super({
|
|
2057
|
-
...
|
|
2057
|
+
...E.DEFAULTS,
|
|
2058
2058
|
...t
|
|
2059
2059
|
});
|
|
2060
2060
|
}
|
|
@@ -2105,22 +2105,22 @@ class v extends g {
|
|
|
2105
2105
|
e === void 0 && (e = {});
|
|
2106
2106
|
const s = e.tail && e._beforeTailState ? e._beforeTailState._value : this._value, i = this._separatorsCountFromSlice(s);
|
|
2107
2107
|
this._value = this._removeThousandsSeparators(this.value);
|
|
2108
|
-
const
|
|
2108
|
+
const a = this._value;
|
|
2109
2109
|
this._value += t;
|
|
2110
|
-
const
|
|
2111
|
-
let u = !isNaN(
|
|
2110
|
+
const r = this.number;
|
|
2111
|
+
let u = !isNaN(r), l = !1;
|
|
2112
2112
|
if (u) {
|
|
2113
|
-
let
|
|
2114
|
-
this.min != null && this.min < 0 && this.number < this.min && (
|
|
2113
|
+
let v;
|
|
2114
|
+
this.min != null && this.min < 0 && this.number < this.min && (v = this.min), this.max != null && this.max > 0 && this.number > this.max && (v = this.max), v != null && (this.autofix ? (this._value = this.format(v, this).replace(E.UNMASKED_RADIX, this.radix), l || (l = a === this._value && !e.tail)) : u = !1), u && (u = !!this._value.match(this._numberRegExp));
|
|
2115
2115
|
}
|
|
2116
2116
|
let o;
|
|
2117
2117
|
u ? o = new d({
|
|
2118
|
-
inserted: this._value.slice(
|
|
2118
|
+
inserted: this._value.slice(a.length),
|
|
2119
2119
|
rawInserted: l ? "" : t,
|
|
2120
2120
|
skip: l
|
|
2121
|
-
}) : (this._value =
|
|
2122
|
-
const c = e.tail && e._beforeTailState ? e._beforeTailState._value : this._value,
|
|
2123
|
-
return o.tailShift += (
|
|
2121
|
+
}) : (this._value = a, o = new d()), this._value = this._insertThousandsSeparators(this._value);
|
|
2122
|
+
const c = e.tail && e._beforeTailState ? e._beforeTailState._value : this._value, g = this._separatorsCountFromSlice(c);
|
|
2123
|
+
return o.tailShift += (g - i) * this.thousandsSeparator.length, o;
|
|
2124
2124
|
}
|
|
2125
2125
|
_findSeparatorAround(t) {
|
|
2126
2126
|
if (this.thousandsSeparator) {
|
|
@@ -2137,11 +2137,11 @@ class v extends g {
|
|
|
2137
2137
|
}
|
|
2138
2138
|
remove(t, e) {
|
|
2139
2139
|
t === void 0 && (t = 0), e === void 0 && (e = this.displayValue.length), [t, e] = this._adjustRangeWithSeparators(t, e);
|
|
2140
|
-
const s = this.value.slice(0, t), i = this.value.slice(e),
|
|
2140
|
+
const s = this.value.slice(0, t), i = this.value.slice(e), a = this._separatorsCount(s.length);
|
|
2141
2141
|
this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(s + i));
|
|
2142
|
-
const
|
|
2142
|
+
const r = this._separatorsCountFromSlice(s);
|
|
2143
2143
|
return new d({
|
|
2144
|
-
tailShift: (
|
|
2144
|
+
tailShift: (r - a) * this.thousandsSeparator.length
|
|
2145
2145
|
});
|
|
2146
2146
|
}
|
|
2147
2147
|
nearestInputPos(t, e) {
|
|
@@ -2179,7 +2179,7 @@ class v extends g {
|
|
|
2179
2179
|
}
|
|
2180
2180
|
_normalizeZeros(t) {
|
|
2181
2181
|
const e = this._removeThousandsSeparators(t).split(this.radix);
|
|
2182
|
-
return e[0] = e[0].replace(/^(\D*)(0*)(\d*)/, (s, i,
|
|
2182
|
+
return e[0] = e[0].replace(/^(\D*)(0*)(\d*)/, (s, i, a, r) => i + r), t.length && !/\d$/.test(e[0]) && (e[0] = e[0] + "0"), e.length > 1 && (e[1] = e[1].replace(/0*$/, ""), e[1].length || (e.length = 1)), this._insertThousandsSeparators(e.join(this.radix));
|
|
2183
2183
|
}
|
|
2184
2184
|
_padFractionalZeros(t) {
|
|
2185
2185
|
if (!t) return t;
|
|
@@ -2188,11 +2188,11 @@ class v extends g {
|
|
|
2188
2188
|
}
|
|
2189
2189
|
doSkipInvalid(t, e, s) {
|
|
2190
2190
|
e === void 0 && (e = {});
|
|
2191
|
-
const i = this.scale === 0 && t !== this.thousandsSeparator && (t === this.radix || t ===
|
|
2191
|
+
const i = this.scale === 0 && t !== this.thousandsSeparator && (t === this.radix || t === E.UNMASKED_RADIX || this.mapToRadix.includes(t));
|
|
2192
2192
|
return super.doSkipInvalid(t, e, s) && !i;
|
|
2193
2193
|
}
|
|
2194
2194
|
get unmaskedValue() {
|
|
2195
|
-
return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,
|
|
2195
|
+
return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, E.UNMASKED_RADIX);
|
|
2196
2196
|
}
|
|
2197
2197
|
set unmaskedValue(t) {
|
|
2198
2198
|
super.unmaskedValue = t;
|
|
@@ -2201,7 +2201,7 @@ class v extends g {
|
|
|
2201
2201
|
return this.parse(this.unmaskedValue, this);
|
|
2202
2202
|
}
|
|
2203
2203
|
set typedValue(t) {
|
|
2204
|
-
this.rawInputValue = this.format(t, this).replace(
|
|
2204
|
+
this.rawInputValue = this.format(t, this).replace(E.UNMASKED_RADIX, this.radix);
|
|
2205
2205
|
}
|
|
2206
2206
|
/** Parsed Number */
|
|
2207
2207
|
get number() {
|
|
@@ -2217,45 +2217,45 @@ class v extends g {
|
|
|
2217
2217
|
return this.min != null && this.min > 0 || this.max != null && this.max > 0;
|
|
2218
2218
|
}
|
|
2219
2219
|
typedValueEquals(t) {
|
|
2220
|
-
return (super.typedValueEquals(t) ||
|
|
2220
|
+
return (super.typedValueEquals(t) || E.EMPTY_VALUES.includes(t) && E.EMPTY_VALUES.includes(this.typedValue)) && !(t === 0 && this.value === "");
|
|
2221
2221
|
}
|
|
2222
2222
|
}
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
...
|
|
2223
|
+
X = E;
|
|
2224
|
+
E.UNMASKED_RADIX = ".";
|
|
2225
|
+
E.EMPTY_VALUES = [...m.EMPTY_VALUES, 0];
|
|
2226
|
+
E.DEFAULTS = {
|
|
2227
|
+
...m.DEFAULTS,
|
|
2228
2228
|
mask: Number,
|
|
2229
2229
|
radix: ",",
|
|
2230
2230
|
thousandsSeparator: "",
|
|
2231
|
-
mapToRadix: [
|
|
2231
|
+
mapToRadix: [X.UNMASKED_RADIX],
|
|
2232
2232
|
min: Number.MIN_SAFE_INTEGER,
|
|
2233
2233
|
max: Number.MAX_SAFE_INTEGER,
|
|
2234
2234
|
scale: 2,
|
|
2235
2235
|
normalizeZeros: !0,
|
|
2236
2236
|
padFractionalZeros: !1,
|
|
2237
2237
|
parse: Number,
|
|
2238
|
-
format: (
|
|
2238
|
+
format: (n) => n.toLocaleString("en-US", {
|
|
2239
2239
|
useGrouping: !1,
|
|
2240
2240
|
maximumFractionDigits: 20
|
|
2241
2241
|
})
|
|
2242
2242
|
};
|
|
2243
|
-
p.MaskedNumber =
|
|
2243
|
+
p.MaskedNumber = E;
|
|
2244
2244
|
const N = {
|
|
2245
2245
|
MASKED: "value",
|
|
2246
2246
|
UNMASKED: "unmaskedValue",
|
|
2247
2247
|
TYPED: "typedValue"
|
|
2248
2248
|
};
|
|
2249
|
-
function
|
|
2249
|
+
function W(n, t, e) {
|
|
2250
2250
|
t === void 0 && (t = N.MASKED), e === void 0 && (e = N.MASKED);
|
|
2251
|
-
const s = x(
|
|
2252
|
-
return (i) => s.runIsolated((
|
|
2251
|
+
const s = x(n);
|
|
2252
|
+
return (i) => s.runIsolated((a) => (a[t] = i, a[e]));
|
|
2253
2253
|
}
|
|
2254
|
-
function dt(
|
|
2255
|
-
return
|
|
2254
|
+
function dt(n, t, e, s) {
|
|
2255
|
+
return W(t, e, s)(n);
|
|
2256
2256
|
}
|
|
2257
2257
|
p.PIPE_TYPE = N;
|
|
2258
|
-
p.createPipe =
|
|
2258
|
+
p.createPipe = W;
|
|
2259
2259
|
p.pipe = dt;
|
|
2260
2260
|
class ct extends k {
|
|
2261
2261
|
get repeatFrom() {
|
|
@@ -2275,12 +2275,12 @@ class ct extends k {
|
|
|
2275
2275
|
_update(t) {
|
|
2276
2276
|
var e, s, i;
|
|
2277
2277
|
const {
|
|
2278
|
-
repeat:
|
|
2279
|
-
...
|
|
2278
|
+
repeat: a,
|
|
2279
|
+
...r
|
|
2280
2280
|
} = S(t);
|
|
2281
|
-
this._blockOpts = Object.assign({}, this._blockOpts,
|
|
2281
|
+
this._blockOpts = Object.assign({}, this._blockOpts, r);
|
|
2282
2282
|
const u = x(this._blockOpts);
|
|
2283
|
-
this.repeat = (e = (s =
|
|
2283
|
+
this.repeat = (e = (s = a ?? u.repeat) != null ? s : this.repeat) != null ? e : 1 / 0, super._update({
|
|
2284
2284
|
mask: "m".repeat(Math.max(this.repeatTo === 1 / 0 && ((i = this._blocks) == null ? void 0 : i.length) || 0, this.repeatFrom)),
|
|
2285
2285
|
blocks: {
|
|
2286
2286
|
m: u
|
|
@@ -2302,35 +2302,35 @@ class ct extends k {
|
|
|
2302
2302
|
e === void 0 && (e = {});
|
|
2303
2303
|
const s = new d();
|
|
2304
2304
|
for (
|
|
2305
|
-
let l = (i = (
|
|
2305
|
+
let l = (i = (a = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : a.index) != null ? i : Math.max(this._blocks.length - 1, 0), o, c;
|
|
2306
2306
|
// try to get a block or
|
|
2307
2307
|
// try to allocate a new block if not allocated already
|
|
2308
|
-
o = (
|
|
2308
|
+
o = (r = this._blocks[l]) != null ? r : c = !c && this._allocateBlock(l);
|
|
2309
2309
|
++l
|
|
2310
2310
|
) {
|
|
2311
|
-
var i,
|
|
2312
|
-
const
|
|
2311
|
+
var i, a, r, u;
|
|
2312
|
+
const g = o._appendChar(t, {
|
|
2313
2313
|
...e,
|
|
2314
2314
|
_beforeTailState: (u = e._beforeTailState) == null || (u = u._blocks) == null ? void 0 : u[l]
|
|
2315
2315
|
});
|
|
2316
|
-
if (
|
|
2316
|
+
if (g.skip && c) {
|
|
2317
2317
|
this._blocks.pop(), this.mask = this.mask.slice(1);
|
|
2318
2318
|
break;
|
|
2319
2319
|
}
|
|
2320
|
-
if (s.aggregate(
|
|
2320
|
+
if (s.aggregate(g), g.consumed) break;
|
|
2321
2321
|
}
|
|
2322
2322
|
return s;
|
|
2323
2323
|
}
|
|
2324
2324
|
_trimEmptyTail(t, e) {
|
|
2325
2325
|
var s, i;
|
|
2326
2326
|
t === void 0 && (t = 0);
|
|
2327
|
-
const
|
|
2328
|
-
let
|
|
2329
|
-
e != null && (
|
|
2327
|
+
const a = Math.max(((s = this._mapPosToBlock(t)) == null ? void 0 : s.index) || 0, this.repeatFrom, 0);
|
|
2328
|
+
let r;
|
|
2329
|
+
e != null && (r = (i = this._mapPosToBlock(e)) == null ? void 0 : i.index), r == null && (r = this._blocks.length - 1);
|
|
2330
2330
|
let u = 0;
|
|
2331
|
-
for (let l =
|
|
2331
|
+
for (let l = r; a <= l && !this._blocks[l].unmaskedValue; --l, ++u)
|
|
2332
2332
|
;
|
|
2333
|
-
u && (this._blocks.splice(
|
|
2333
|
+
u && (this._blocks.splice(r - u + 1, u), this.mask = this.mask.slice(u));
|
|
2334
2334
|
}
|
|
2335
2335
|
reset() {
|
|
2336
2336
|
super.reset(), this._trimEmptyTail();
|
|
@@ -2355,13 +2355,13 @@ try {
|
|
|
2355
2355
|
globalThis.IMask = p;
|
|
2356
2356
|
} catch {
|
|
2357
2357
|
}
|
|
2358
|
-
var ft = Object.defineProperty, gt = Object.getOwnPropertyDescriptor,
|
|
2359
|
-
for (var i = s > 1 ? void 0 : s ? gt(t, e) : t,
|
|
2360
|
-
(
|
|
2358
|
+
var ft = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, _ = (n, t, e, s) => {
|
|
2359
|
+
for (var i = s > 1 ? void 0 : s ? gt(t, e) : t, a = n.length - 1, r; a >= 0; a--)
|
|
2360
|
+
(r = n[a]) && (i = (s ? r(t, e, i) : r(i)) || i);
|
|
2361
2361
|
return s && i && ft(t, e, i), i;
|
|
2362
2362
|
};
|
|
2363
|
-
function
|
|
2364
|
-
const t =
|
|
2363
|
+
function q(n) {
|
|
2364
|
+
const t = n.trim();
|
|
2365
2365
|
if (!t) return null;
|
|
2366
2366
|
try {
|
|
2367
2367
|
if (t.startsWith("/")) {
|
|
@@ -2376,46 +2376,87 @@ function $(r) {
|
|
|
2376
2376
|
return null;
|
|
2377
2377
|
}
|
|
2378
2378
|
}
|
|
2379
|
-
let
|
|
2379
|
+
let f = class extends tt {
|
|
2380
2380
|
constructor() {
|
|
2381
|
-
super(), this.value = "", this.placeholder = "", this.name = "", this.disabled = !1, this.required = !1, this.type = "text", this.label = "", this.labelPosition = "above", this.regex = "", this.
|
|
2381
|
+
super(), this.value = "", this.placeholder = "", this.prefix = "", this.suffix = "", this.template = "", this.name = "", this.disabled = !1, this.required = !1, this.type = "text", this.label = "", this.labelPosition = "above", this.regex = "", this.compiledRegex = null, "attachInternals" in this && (this.internals = this.attachInternals());
|
|
2382
2382
|
}
|
|
2383
2383
|
connectedCallback() {
|
|
2384
|
-
super.connectedCallback(), this.compiledRegex =
|
|
2384
|
+
super.connectedCallback(), this.compiledRegex = q(this.regex), this.defaultValue === void 0 && (this.defaultValue = this.getAttribute("value") ?? ""), this.syncFormValue();
|
|
2385
2385
|
}
|
|
2386
|
-
willUpdate(
|
|
2387
|
-
|
|
2386
|
+
willUpdate(n) {
|
|
2387
|
+
n.has("regex") && (this.compiledRegex = q(this.regex));
|
|
2388
2388
|
}
|
|
2389
|
-
updated(
|
|
2390
|
-
if (
|
|
2391
|
-
const t = this.
|
|
2389
|
+
updated(n) {
|
|
2390
|
+
if (n.has("value") || n.has("regex") || n.has("prefix") || n.has("suffix") || n.has("template")) {
|
|
2391
|
+
const t = this.normalizeFromValue(this.value);
|
|
2392
2392
|
if (t !== this.value) {
|
|
2393
2393
|
this.value = t;
|
|
2394
2394
|
return;
|
|
2395
2395
|
}
|
|
2396
|
-
|
|
2396
|
+
const e = this.formatDisplayValue(t);
|
|
2397
|
+
this.inputEl && this.inputEl.value !== e && (this.inputEl.value = e);
|
|
2397
2398
|
}
|
|
2398
|
-
(
|
|
2399
|
+
(n.has("value") || n.has("disabled")) && this.syncFormValue();
|
|
2399
2400
|
}
|
|
2400
|
-
focus(
|
|
2401
|
-
this.inputEl?.focus(
|
|
2401
|
+
focus(n) {
|
|
2402
|
+
this.inputEl?.focus(n);
|
|
2402
2403
|
}
|
|
2403
2404
|
blur() {
|
|
2404
2405
|
this.inputEl?.blur();
|
|
2405
2406
|
}
|
|
2406
2407
|
formResetCallback() {
|
|
2407
|
-
this.value = this.defaultValue ?? "";
|
|
2408
|
+
this.value = this.normalizeFromValue(this.defaultValue ?? "");
|
|
2408
2409
|
}
|
|
2409
|
-
formStateRestoreCallback(
|
|
2410
|
-
typeof
|
|
2410
|
+
formStateRestoreCallback(n) {
|
|
2411
|
+
typeof n == "string" && (this.value = this.normalizeFromValue(n));
|
|
2411
2412
|
}
|
|
2412
|
-
formDisabledCallback(
|
|
2413
|
-
this.disabled =
|
|
2413
|
+
formDisabledCallback(n) {
|
|
2414
|
+
this.disabled = n;
|
|
2414
2415
|
}
|
|
2415
|
-
normalizeWithRegex(
|
|
2416
|
-
if (!this.compiledRegex) return
|
|
2416
|
+
normalizeWithRegex(n) {
|
|
2417
|
+
if (!this.compiledRegex) return n;
|
|
2417
2418
|
const t = p.createMask({ mask: this.compiledRegex });
|
|
2418
|
-
return t.resolve(
|
|
2419
|
+
return t.resolve(n), t.value;
|
|
2420
|
+
}
|
|
2421
|
+
stripAffixes(n) {
|
|
2422
|
+
let t = n;
|
|
2423
|
+
return this.prefix && (t = t.split(this.prefix).join("")), this.suffix && (t = t.split(this.suffix).join("")), t;
|
|
2424
|
+
}
|
|
2425
|
+
getTemplateCapacity() {
|
|
2426
|
+
return [...this.template].filter((n) => n === "x").length;
|
|
2427
|
+
}
|
|
2428
|
+
capToTemplate(n) {
|
|
2429
|
+
const t = this.getTemplateCapacity();
|
|
2430
|
+
return t === 0 ? n : n.slice(0, t);
|
|
2431
|
+
}
|
|
2432
|
+
extractTemplateValue(n) {
|
|
2433
|
+
if (!this.template) return n;
|
|
2434
|
+
const t = new Set([...this.template].filter((r) => r !== "x")), e = [...this.template].filter((r) => r === "x"), s = [...n].filter((r) => !t.has(r)), i = e.length, a = [];
|
|
2435
|
+
for (let r = 0; r < Math.min(s.length, i); r += 1)
|
|
2436
|
+
s[r] !== e[r] && a.push(s[r]);
|
|
2437
|
+
return s.length > i && a.push(...s.slice(i)), a.join("");
|
|
2438
|
+
}
|
|
2439
|
+
normalizeFromValue(n) {
|
|
2440
|
+
const t = this.normalizeWithRegex(this.stripAffixes(n));
|
|
2441
|
+
return this.capToTemplate(t);
|
|
2442
|
+
}
|
|
2443
|
+
normalizeFromUserInput(n) {
|
|
2444
|
+
const t = this.stripAffixes(n), e = this.extractTemplateValue(t), s = this.normalizeWithRegex(e);
|
|
2445
|
+
return this.capToTemplate(s);
|
|
2446
|
+
}
|
|
2447
|
+
applyTemplate(n) {
|
|
2448
|
+
if (!this.template) return n;
|
|
2449
|
+
const t = [...this.capToTemplate(n)];
|
|
2450
|
+
let e = 0;
|
|
2451
|
+
return [...this.template].map((s) => {
|
|
2452
|
+
if (s !== "x") return s;
|
|
2453
|
+
const i = t[e];
|
|
2454
|
+
return e += 1, i ?? "x";
|
|
2455
|
+
}).join("");
|
|
2456
|
+
}
|
|
2457
|
+
formatDisplayValue(n) {
|
|
2458
|
+
const t = this.applyTemplate(n);
|
|
2459
|
+
return `${this.prefix}${t}${this.suffix}`;
|
|
2419
2460
|
}
|
|
2420
2461
|
syncFormValue() {
|
|
2421
2462
|
if (this.internals) {
|
|
@@ -2426,48 +2467,37 @@ let m = class extends tt {
|
|
|
2426
2467
|
this.internals.setFormValue(this.value);
|
|
2427
2468
|
}
|
|
2428
2469
|
}
|
|
2429
|
-
handleInput(
|
|
2430
|
-
|
|
2431
|
-
const t =
|
|
2432
|
-
t.value !==
|
|
2470
|
+
handleInput(n) {
|
|
2471
|
+
n.stopPropagation();
|
|
2472
|
+
const t = n.target, e = this.normalizeFromUserInput(t.value), s = this.formatDisplayValue(e);
|
|
2473
|
+
t.value !== s && (t.value = s), this.value = e, this.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 }));
|
|
2433
2474
|
}
|
|
2434
|
-
handleChange(
|
|
2435
|
-
|
|
2436
|
-
const t =
|
|
2437
|
-
t.value !==
|
|
2475
|
+
handleChange(n) {
|
|
2476
|
+
n.stopPropagation();
|
|
2477
|
+
const t = n.target, e = this.normalizeFromUserInput(t.value), s = this.formatDisplayValue(e);
|
|
2478
|
+
t.value !== s && (t.value = s), this.value = e, this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 }));
|
|
2438
2479
|
}
|
|
2439
|
-
handleKeydown(
|
|
2440
|
-
if (
|
|
2441
|
-
const t =
|
|
2442
|
-
t.value !==
|
|
2443
|
-
}
|
|
2444
|
-
handleFocus() {
|
|
2445
|
-
this.isFocused = !0, this.requestUpdate();
|
|
2446
|
-
}
|
|
2447
|
-
handleBlur() {
|
|
2448
|
-
this.isFocused = !1, this.requestUpdate();
|
|
2480
|
+
handleKeydown(n) {
|
|
2481
|
+
if (n.key !== "Enter") return;
|
|
2482
|
+
const t = n.target, e = this.normalizeFromUserInput(t.value), s = this.formatDisplayValue(e);
|
|
2483
|
+
t.value !== s && (t.value = s), this.value = e, this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 }));
|
|
2449
2484
|
}
|
|
2450
2485
|
render() {
|
|
2451
|
-
const
|
|
2452
|
-
let i;
|
|
2453
|
-
t ? i = s && this.isFocused ? s : void 0 : s ? i = s : i = this.placeholder || void 0;
|
|
2454
|
-
const n = this.label || i || this.placeholder || s || void 0;
|
|
2486
|
+
const n = this.label.length > 0, t = n && this.labelPosition === "floating", e = this.value.length > 0, s = t ? void 0 : this.placeholder || void 0, i = this.label || s || void 0;
|
|
2455
2487
|
return z`
|
|
2456
2488
|
<div class="field ${t ? "floating" : ""}" data-has-value=${e}>
|
|
2457
|
-
${
|
|
2489
|
+
${n ? z`<label for="input">${this.label}</label>` : null}
|
|
2458
2490
|
<input
|
|
2459
2491
|
id="input"
|
|
2460
2492
|
part="input"
|
|
2461
|
-
.value=${this.value}
|
|
2493
|
+
.value=${this.formatDisplayValue(this.value)}
|
|
2462
2494
|
.type=${this.type}
|
|
2463
2495
|
.name=${this.name}
|
|
2464
2496
|
?disabled=${this.disabled}
|
|
2465
2497
|
?required=${this.required}
|
|
2466
|
-
.placeholder=${
|
|
2467
|
-
autocomplete=${
|
|
2468
|
-
aria-label=${
|
|
2469
|
-
@focus=${this.handleFocus}
|
|
2470
|
-
@blur=${this.handleBlur}
|
|
2498
|
+
.placeholder=${s ?? ""}
|
|
2499
|
+
autocomplete=${j(this.autocomplete)}
|
|
2500
|
+
aria-label=${j(i)}
|
|
2471
2501
|
@input=${this.handleInput}
|
|
2472
2502
|
@change=${this.handleChange}
|
|
2473
2503
|
@keydown=${this.handleKeydown}
|
|
@@ -2476,8 +2506,8 @@ let m = class extends tt {
|
|
|
2476
2506
|
`;
|
|
2477
2507
|
}
|
|
2478
2508
|
};
|
|
2479
|
-
|
|
2480
|
-
|
|
2509
|
+
f.formAssociated = !0;
|
|
2510
|
+
f.styles = Q`
|
|
2481
2511
|
:host {
|
|
2482
2512
|
display: inline-block;
|
|
2483
2513
|
width: 100%;
|
|
@@ -2551,45 +2581,51 @@ m.styles = Q`
|
|
|
2551
2581
|
padding-left: var(--ui-input-floating-padding-left, 12px);
|
|
2552
2582
|
}
|
|
2553
2583
|
`;
|
|
2554
|
-
|
|
2584
|
+
_([
|
|
2585
|
+
C({ type: String })
|
|
2586
|
+
], f.prototype, "value", 2);
|
|
2587
|
+
_([
|
|
2588
|
+
C({ type: String })
|
|
2589
|
+
], f.prototype, "placeholder", 2);
|
|
2590
|
+
_([
|
|
2591
|
+
C({ type: String })
|
|
2592
|
+
], f.prototype, "prefix", 2);
|
|
2593
|
+
_([
|
|
2555
2594
|
C({ type: String })
|
|
2556
|
-
],
|
|
2557
|
-
|
|
2595
|
+
], f.prototype, "suffix", 2);
|
|
2596
|
+
_([
|
|
2558
2597
|
C({ type: String })
|
|
2559
|
-
],
|
|
2560
|
-
|
|
2598
|
+
], f.prototype, "template", 2);
|
|
2599
|
+
_([
|
|
2561
2600
|
C({ type: String, reflect: !0 })
|
|
2562
|
-
],
|
|
2563
|
-
|
|
2601
|
+
], f.prototype, "name", 2);
|
|
2602
|
+
_([
|
|
2564
2603
|
C({ type: Boolean, reflect: !0 })
|
|
2565
|
-
],
|
|
2566
|
-
|
|
2604
|
+
], f.prototype, "disabled", 2);
|
|
2605
|
+
_([
|
|
2567
2606
|
C({ type: Boolean, reflect: !0 })
|
|
2568
|
-
],
|
|
2569
|
-
|
|
2607
|
+
], f.prototype, "required", 2);
|
|
2608
|
+
_([
|
|
2570
2609
|
C({ type: String, reflect: !0 })
|
|
2571
|
-
],
|
|
2572
|
-
|
|
2610
|
+
], f.prototype, "type", 2);
|
|
2611
|
+
_([
|
|
2573
2612
|
C({ type: String, reflect: !0 })
|
|
2574
|
-
],
|
|
2575
|
-
|
|
2613
|
+
], f.prototype, "autocomplete", 2);
|
|
2614
|
+
_([
|
|
2576
2615
|
C({ type: String })
|
|
2577
|
-
],
|
|
2578
|
-
|
|
2616
|
+
], f.prototype, "label", 2);
|
|
2617
|
+
_([
|
|
2579
2618
|
C({ type: String, attribute: "label-position" })
|
|
2580
|
-
],
|
|
2581
|
-
|
|
2619
|
+
], f.prototype, "labelPosition", 2);
|
|
2620
|
+
_([
|
|
2582
2621
|
C({ type: String, reflect: !0 })
|
|
2583
|
-
],
|
|
2584
|
-
|
|
2585
|
-
C({ type: String, attribute: "regex-placeholder" })
|
|
2586
|
-
], m.prototype, "regexPlaceholder", 2);
|
|
2587
|
-
E([
|
|
2622
|
+
], f.prototype, "regex", 2);
|
|
2623
|
+
_([
|
|
2588
2624
|
et("input")
|
|
2589
|
-
],
|
|
2590
|
-
|
|
2625
|
+
], f.prototype, "inputEl", 2);
|
|
2626
|
+
f = _([
|
|
2591
2627
|
st("dui-input")
|
|
2592
|
-
],
|
|
2628
|
+
], f);
|
|
2593
2629
|
export {
|
|
2594
|
-
|
|
2630
|
+
f as DuiInput
|
|
2595
2631
|
};
|