mhz-ui 1.0.15 → 1.0.16
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/UiInput/UiInput.d.ts +0 -6
- package/dist/UiInput/UiInput.js +40 -225
- package/package.json +1 -2
|
@@ -21,9 +21,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
21
21
|
isCenter: {
|
|
22
22
|
type: import("vue").PropType<boolean>;
|
|
23
23
|
};
|
|
24
|
-
isPhone: {
|
|
25
|
-
type: import("vue").PropType<boolean>;
|
|
26
|
-
};
|
|
27
24
|
isCopy: {
|
|
28
25
|
type: import("vue").PropType<boolean>;
|
|
29
26
|
};
|
|
@@ -49,9 +46,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
49
46
|
isCenter: {
|
|
50
47
|
type: import("vue").PropType<boolean>;
|
|
51
48
|
};
|
|
52
|
-
isPhone: {
|
|
53
|
-
type: import("vue").PropType<boolean>;
|
|
54
|
-
};
|
|
55
49
|
isCopy: {
|
|
56
50
|
type: import("vue").PropType<boolean>;
|
|
57
51
|
};
|
package/dist/UiInput/UiInput.js
CHANGED
|
@@ -1,199 +1,18 @@
|
|
|
1
1
|
import "./UiInput.css";
|
|
2
|
-
import { openBlock as
|
|
3
|
-
import { _ as
|
|
4
|
-
|
|
5
|
-
var H = Object.defineProperty, K = (n, t, e) => t in n ? H(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, g = (n, t, e) => (K(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
6
|
-
const R = {
|
|
7
|
-
"#": { pattern: /[0-9]/ },
|
|
8
|
-
"@": { pattern: /[a-zA-Z]/ },
|
|
9
|
-
"*": { pattern: /[a-zA-Z0-9]/ }
|
|
10
|
-
};
|
|
11
|
-
class V {
|
|
12
|
-
constructor(t = {}) {
|
|
13
|
-
g(this, "opts", {}), g(this, "memo", /* @__PURE__ */ new Map());
|
|
14
|
-
const e = { ...t };
|
|
15
|
-
if (e.tokens != null) {
|
|
16
|
-
e.tokens = e.tokensReplace ? { ...e.tokens } : { ...R, ...e.tokens };
|
|
17
|
-
for (const s of Object.values(e.tokens))
|
|
18
|
-
typeof s.pattern == "string" && (s.pattern = new RegExp(s.pattern));
|
|
19
|
-
} else
|
|
20
|
-
e.tokens = R;
|
|
21
|
-
Array.isArray(e.mask) && (e.mask.length > 1 ? e.mask = [...e.mask].sort((s, a) => s.length - a.length) : e.mask = e.mask[0] ?? ""), e.mask === "" && (e.mask = null), this.opts = e;
|
|
22
|
-
}
|
|
23
|
-
masked(t) {
|
|
24
|
-
return this.process(t, this.findMask(t));
|
|
25
|
-
}
|
|
26
|
-
unmasked(t) {
|
|
27
|
-
return this.process(t, this.findMask(t), !1);
|
|
28
|
-
}
|
|
29
|
-
isEager() {
|
|
30
|
-
return this.opts.eager === !0;
|
|
31
|
-
}
|
|
32
|
-
isReversed() {
|
|
33
|
-
return this.opts.reversed === !0;
|
|
34
|
-
}
|
|
35
|
-
completed(t) {
|
|
36
|
-
const e = this.findMask(t);
|
|
37
|
-
if (this.opts.mask == null || e == null)
|
|
38
|
-
return !1;
|
|
39
|
-
const s = this.process(t, e).length;
|
|
40
|
-
return typeof this.opts.mask == "string" ? s >= this.opts.mask.length : typeof this.opts.mask == "function" ? s >= e.length : this.opts.mask.filter((a) => s >= a.length).length === this.opts.mask.length;
|
|
41
|
-
}
|
|
42
|
-
findMask(t) {
|
|
43
|
-
const e = this.opts.mask;
|
|
44
|
-
if (e == null)
|
|
45
|
-
return null;
|
|
46
|
-
if (typeof e == "string")
|
|
47
|
-
return e;
|
|
48
|
-
if (typeof e == "function")
|
|
49
|
-
return e(t);
|
|
50
|
-
const s = this.process(t, e.slice(-1).pop() ?? "", !1);
|
|
51
|
-
return e.find((a) => this.process(t, a, !1).length >= s.length) ?? "";
|
|
52
|
-
}
|
|
53
|
-
escapeMask(t) {
|
|
54
|
-
const e = [], s = [];
|
|
55
|
-
return t.split("").forEach((a, o) => {
|
|
56
|
-
a === "!" && t[o - 1] !== "!" ? s.push(o - s.length) : e.push(a);
|
|
57
|
-
}), { mask: e.join(""), escaped: s };
|
|
58
|
-
}
|
|
59
|
-
process(t, e, s = !0) {
|
|
60
|
-
var a;
|
|
61
|
-
if (e == null)
|
|
62
|
-
return t;
|
|
63
|
-
const o = `value=${t},mask=${e},masked=${s ? 1 : 0}`;
|
|
64
|
-
if (this.memo.has(o))
|
|
65
|
-
return this.memo.get(o);
|
|
66
|
-
const { mask: i, escaped: l } = this.escapeMask(e), u = [], m = this.opts.tokens != null ? this.opts.tokens : {}, p = this.isReversed() ? -1 : 1, h = this.isReversed() ? "unshift" : "push", v = this.isReversed() ? 0 : i.length - 1, T = this.isReversed() ? () => r > -1 && d > -1 : () => r < i.length && d < t.length, S = (k) => !this.isReversed() && k <= v || this.isReversed() && k >= v;
|
|
67
|
-
let E, f = -1, r = this.isReversed() ? i.length - 1 : 0, d = this.isReversed() ? t.length - 1 : 0;
|
|
68
|
-
for (; T(); ) {
|
|
69
|
-
const k = i.charAt(r), c = m[k], y = c?.transform != null ? c.transform(t.charAt(d)) : t.charAt(d);
|
|
70
|
-
if (!l.includes(r) && c != null) {
|
|
71
|
-
if (y.match(c.pattern) != null)
|
|
72
|
-
u[h](y), c.repeated ? (f === -1 ? f = r : r === v && r !== f && (r = f - p), v === f && (r -= p)) : c.multiple && (r -= p), r += p;
|
|
73
|
-
else if (c.multiple) {
|
|
74
|
-
const $ = ((a = u[d - p]) == null ? void 0 : a.match(c.pattern)) != null, C = i.charAt(r + p);
|
|
75
|
-
$ && C !== "" && m[C] == null ? (r += p, d -= p) : u[h]("");
|
|
76
|
-
} else
|
|
77
|
-
y === E ? E = void 0 : c.optional && (r += p, d -= p);
|
|
78
|
-
d += p;
|
|
79
|
-
} else
|
|
80
|
-
s && !this.isEager() && u[h](k), y === k && !this.isEager() ? d += p : E = k, this.isEager() || (r += p);
|
|
81
|
-
if (this.isEager())
|
|
82
|
-
for (; S(r) && (m[i.charAt(r)] == null || l.includes(r)); )
|
|
83
|
-
s ? u[h](i.charAt(r)) : i.charAt(r) === t.charAt(d) && (d += p), r += p;
|
|
84
|
-
}
|
|
85
|
-
return this.memo.set(o, u.join("")), this.memo.get(o);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const P = (n) => JSON.parse(n.replaceAll("'", '"')), O = (n, t = {}) => {
|
|
89
|
-
const e = { ...t };
|
|
90
|
-
return n.dataset.maska != null && n.dataset.maska !== "" && (e.mask = G(n.dataset.maska)), n.dataset.maskaEager != null && (e.eager = M(n.dataset.maskaEager)), n.dataset.maskaReversed != null && (e.reversed = M(n.dataset.maskaReversed)), n.dataset.maskaTokensReplace != null && (e.tokensReplace = M(n.dataset.maskaTokensReplace)), n.dataset.maskaTokens != null && (e.tokens = Q(n.dataset.maskaTokens)), e;
|
|
91
|
-
}, M = (n) => n !== "" ? !!JSON.parse(n) : !0, G = (n) => n.startsWith("[") && n.endsWith("]") ? P(n) : n, Q = (n) => {
|
|
92
|
-
if (n.startsWith("{") && n.endsWith("}"))
|
|
93
|
-
return P(n);
|
|
94
|
-
const t = {};
|
|
95
|
-
return n.split("|").forEach((e) => {
|
|
96
|
-
const s = e.split(":");
|
|
97
|
-
t[s[0]] = {
|
|
98
|
-
pattern: new RegExp(s[1]),
|
|
99
|
-
optional: s[2] === "optional",
|
|
100
|
-
multiple: s[2] === "multiple",
|
|
101
|
-
repeated: s[2] === "repeated"
|
|
102
|
-
};
|
|
103
|
-
}), t;
|
|
104
|
-
};
|
|
105
|
-
class X {
|
|
106
|
-
constructor(t, e = {}) {
|
|
107
|
-
g(this, "items", /* @__PURE__ */ new Map()), g(this, "beforeinputEvent", (s) => {
|
|
108
|
-
const a = s.target, o = this.items.get(a);
|
|
109
|
-
o.isEager() && "inputType" in s && s.inputType.startsWith("delete") && o.unmasked(a.value).length <= 1 && this.setMaskedValue(a, "");
|
|
110
|
-
}), g(this, "inputEvent", (s) => {
|
|
111
|
-
if (s instanceof CustomEvent && s.type === "input" && s.detail != null && typeof s.detail == "object" && "masked" in s.detail)
|
|
112
|
-
return;
|
|
113
|
-
const a = s.target, o = this.items.get(a), i = a.value, l = a.selectionStart, u = a.selectionEnd;
|
|
114
|
-
let m = i;
|
|
115
|
-
if (o.isEager()) {
|
|
116
|
-
const p = o.masked(i), h = o.unmasked(i);
|
|
117
|
-
h === "" && "data" in s && s.data != null ? m = s.data : h !== o.unmasked(p) && (m = h);
|
|
118
|
-
}
|
|
119
|
-
if (this.setMaskedValue(a, m), "inputType" in s && (s.inputType.startsWith("delete") || l != null && l < i.length))
|
|
120
|
-
try {
|
|
121
|
-
a.setSelectionRange(l, u);
|
|
122
|
-
} catch {
|
|
123
|
-
}
|
|
124
|
-
}), this.options = e, typeof t == "string" ? this.init(
|
|
125
|
-
Array.from(document.querySelectorAll(t)),
|
|
126
|
-
this.getMaskOpts(e)
|
|
127
|
-
) : this.init(
|
|
128
|
-
"length" in t ? Array.from(t) : [t],
|
|
129
|
-
this.getMaskOpts(e)
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
destroy() {
|
|
133
|
-
for (const t of this.items.keys())
|
|
134
|
-
t.removeEventListener("input", this.inputEvent), t.removeEventListener("beforeinput", this.beforeinputEvent);
|
|
135
|
-
this.items.clear();
|
|
136
|
-
}
|
|
137
|
-
needUpdateOptions(t, e) {
|
|
138
|
-
const s = this.items.get(t), a = new V(O(t, this.getMaskOpts(e)));
|
|
139
|
-
return JSON.stringify(s.opts) !== JSON.stringify(a.opts);
|
|
140
|
-
}
|
|
141
|
-
needUpdateValue(t) {
|
|
142
|
-
const e = t.dataset.maskaValue;
|
|
143
|
-
return e == null && t.value !== "" || e != null && e !== t.value;
|
|
144
|
-
}
|
|
145
|
-
getMaskOpts(t) {
|
|
146
|
-
const { onMaska: e, preProcess: s, postProcess: a, ...o } = t;
|
|
147
|
-
return o;
|
|
148
|
-
}
|
|
149
|
-
init(t, e) {
|
|
150
|
-
for (const s of t) {
|
|
151
|
-
const a = new V(O(s, e));
|
|
152
|
-
this.items.set(s, a), s.value !== "" && this.setMaskedValue(s, s.value), s.addEventListener("input", this.inputEvent), s.addEventListener("beforeinput", this.beforeinputEvent);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
setMaskedValue(t, e) {
|
|
156
|
-
const s = this.items.get(t);
|
|
157
|
-
this.options.preProcess != null && (e = this.options.preProcess(e));
|
|
158
|
-
const a = s.masked(e), o = s.unmasked(s.isEager() ? a : e), i = s.completed(e), l = { masked: a, unmasked: o, completed: i };
|
|
159
|
-
e = a, this.options.postProcess != null && (e = this.options.postProcess(e)), t.value = e, t.dataset.maskaValue = e, this.options.onMaska != null && (Array.isArray(this.options.onMaska) ? this.options.onMaska.forEach((u) => u(l)) : this.options.onMaska(l)), t.dispatchEvent(new CustomEvent("maska", { detail: l })), t.dispatchEvent(new CustomEvent("input", { detail: l }));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const w = /* @__PURE__ */ new WeakMap(), Y = (n) => {
|
|
163
|
-
setTimeout(() => {
|
|
164
|
-
var t;
|
|
165
|
-
((t = w.get(n)) == null ? void 0 : t.needUpdateValue(n)) === !0 && n.dispatchEvent(new CustomEvent("input"));
|
|
166
|
-
});
|
|
167
|
-
}, ee = (n, t) => {
|
|
168
|
-
const e = n instanceof HTMLInputElement ? n : n.querySelector("input"), s = { ...t.arg };
|
|
169
|
-
if (e == null || e?.type === "file")
|
|
170
|
-
return;
|
|
171
|
-
Y(e);
|
|
172
|
-
const a = w.get(e);
|
|
173
|
-
if (a != null) {
|
|
174
|
-
if (!a.needUpdateOptions(e, s))
|
|
175
|
-
return;
|
|
176
|
-
a.destroy();
|
|
177
|
-
}
|
|
178
|
-
if (t.value != null) {
|
|
179
|
-
const o = t.value, i = (l) => {
|
|
180
|
-
o.masked = l.masked, o.unmasked = l.unmasked, o.completed = l.completed;
|
|
181
|
-
};
|
|
182
|
-
s.onMaska = s.onMaska == null ? i : Array.isArray(s.onMaska) ? [...s.onMaska, i] : [s.onMaska, i];
|
|
183
|
-
}
|
|
184
|
-
w.set(e, new X(e, s));
|
|
185
|
-
}, te = {
|
|
2
|
+
import { openBlock as l, createElementBlock as c, createStaticVNode as r, defineComponent as m, ref as f, onMounted as h, nextTick as y, withKeys as _, normalizeClass as s, createElementVNode as C, mergeProps as g, createBlock as v, resolveDynamicComponent as k, unref as B, createCommentVNode as b } from "vue";
|
|
3
|
+
import { _ as I } from "../_plugin-vue_export-helper-dad06003.js";
|
|
4
|
+
const w = {
|
|
186
5
|
xmlns: "http://www.w3.org/2000/svg",
|
|
187
6
|
width: "16",
|
|
188
7
|
height: "16",
|
|
189
8
|
fill: "none"
|
|
190
|
-
},
|
|
191
|
-
|
|
9
|
+
}, V = /* @__PURE__ */ r('<g fill="currentColor" fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path d="M11.5 11.5v-1c.25.005 2.485-.016 2.734-.031.433-.057.678-.302.735-.735.02-2.666.02-5.333 0-8-.057-.432-.302-.677-.735-.734-2.666-.02-5.333-.02-8 0-.432.057-.677.302-.734.734-.016.25-.005 1.516 0 1.766h-1a69.046 69.046 0 0 1 0-2.078C4.682.656 5.156.182 5.922 0c2.875-.02 5.75-.02 8.625 0 .765.182 1.24.656 1.422 1.422.02 2.875.02 5.75 0 8.625-.182.765-.656 1.24-1.422 1.422-.354.015-2.693.036-3.047.031Z"></path><path d="M2.5 3.5h1c2.2-.005 4.8-.016 7 0 .923.197 1.285.578 1.5 1.5.016 2.217-.029 5.131-.034 7.348v1.044c.145.963-.17 1.73-.943 2.298-.24.153-.5.25-.78.294-2.84.021-5.68.021-8.52 0-.923-.197-1.492-.757-1.707-1.68A665.626 665.626 0 0 1 0 5c.215-.922.577-1.303 1.5-1.5.292-.016.707-.005 1 0Zm-.5 1c2.601-.005 5.399-.016 8 0 .623.06.94.375 1 1 .022 2.608-.07 5.805-.091 8.413-.06.625-.401.968-1.024 1.027-2.602.022-5.203.022-7.804 0-.623-.06-.965-.402-1.024-1.027C1.035 11.305.978 8.108 1 5.5c0-.697.383-.93 1-1Z"></path></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"></path></clipPath></defs>', 2), $ = [
|
|
10
|
+
V
|
|
192
11
|
];
|
|
193
|
-
function
|
|
194
|
-
return
|
|
12
|
+
function x(d, n) {
|
|
13
|
+
return l(), c("svg", w, $);
|
|
195
14
|
}
|
|
196
|
-
const
|
|
15
|
+
const M = { render: x }, N = ["data-mode", "tabindex"], D = ["value", "disabled", "data-mode", "data-center", "data-append-icon", "tabindex"], F = /* @__PURE__ */ m({
|
|
197
16
|
__name: "UiInput",
|
|
198
17
|
props: {
|
|
199
18
|
modelValue: { type: [String, Number, Boolean, null], default: "" },
|
|
@@ -202,58 +21,54 @@ const ie = { render: ae }, oe = ["data-mode", "tabindex"], le = ["value", "disab
|
|
|
202
21
|
appendIcon: { type: [Function, Object], default: void 0 },
|
|
203
22
|
isFocus: { type: Boolean },
|
|
204
23
|
isCenter: { type: Boolean },
|
|
205
|
-
isPhone: { type: Boolean },
|
|
206
24
|
isCopy: { type: Boolean }
|
|
207
25
|
},
|
|
208
26
|
emits: ["update:modelValue", "toggle"],
|
|
209
|
-
setup(
|
|
210
|
-
const e =
|
|
211
|
-
function
|
|
212
|
-
|
|
27
|
+
setup(d, { emit: n }) {
|
|
28
|
+
const e = d;
|
|
29
|
+
function p(t) {
|
|
30
|
+
n("update:modelValue", t.value);
|
|
213
31
|
}
|
|
214
|
-
const
|
|
215
|
-
function
|
|
32
|
+
const i = f();
|
|
33
|
+
function u() {
|
|
216
34
|
e.isCopy && e.modelValue && navigator.clipboard.writeText(e.modelValue.toString());
|
|
217
35
|
}
|
|
218
|
-
return
|
|
219
|
-
e.isFocus && (await
|
|
220
|
-
}), (
|
|
221
|
-
onClick:
|
|
222
|
-
onKeydown:
|
|
223
|
-
class:
|
|
36
|
+
return h(async () => {
|
|
37
|
+
e.isFocus && (await y(), i.value?.focus());
|
|
38
|
+
}), (t, o) => (l(), c("div", {
|
|
39
|
+
onClick: o[1] || (o[1] = (a) => n("toggle")),
|
|
40
|
+
onKeydown: o[2] || (o[2] = _((a) => n("toggle"), ["space"])),
|
|
41
|
+
class: s(t.$style.inputBlock),
|
|
224
42
|
"data-mode": e.mode,
|
|
225
43
|
tabindex: e.mode === "default" ? "-1" : "0"
|
|
226
44
|
}, [
|
|
227
|
-
|
|
45
|
+
C("input", g({
|
|
228
46
|
value: e.modelValue,
|
|
229
|
-
onInput:
|
|
47
|
+
onInput: o[0] || (o[0] = (a) => p(a.target)),
|
|
230
48
|
disabled: e.isDisabled,
|
|
231
|
-
class:
|
|
49
|
+
class: t.$style.input,
|
|
232
50
|
ref_key: "input",
|
|
233
|
-
ref:
|
|
234
|
-
},
|
|
235
|
-
"data-maska": e.isPhone ? "+7 (###) ###-##-##" : null,
|
|
51
|
+
ref: i
|
|
52
|
+
}, t.$attrs, {
|
|
236
53
|
"data-mode": e.mode,
|
|
237
54
|
"data-center": e.isCenter,
|
|
238
55
|
"data-append-icon": !!e.appendIcon || e.isCopy,
|
|
239
56
|
tabindex: e.mode === "default" ? "0" : "-1"
|
|
240
|
-
}), null, 16,
|
|
241
|
-
|
|
242
|
-
]),
|
|
243
|
-
e.appendIcon || e.isCopy ? (b(), z(D(e.isCopy ? A(ie) : e.appendIcon), {
|
|
57
|
+
}), null, 16, D),
|
|
58
|
+
e.appendIcon || e.isCopy ? (l(), v(k(e.isCopy ? B(M) : e.appendIcon), {
|
|
244
59
|
key: 0,
|
|
245
|
-
onClick:
|
|
246
|
-
class:
|
|
247
|
-
}, null, 8, ["class"])) :
|
|
248
|
-
], 42,
|
|
249
|
-
}
|
|
250
|
-
}),
|
|
251
|
-
inputBlock:
|
|
252
|
-
input:
|
|
253
|
-
icon:
|
|
254
|
-
},
|
|
255
|
-
$style:
|
|
256
|
-
},
|
|
60
|
+
onClick: u,
|
|
61
|
+
class: s(t.$style.icon)
|
|
62
|
+
}, null, 8, ["class"])) : b("", !0)
|
|
63
|
+
], 42, N));
|
|
64
|
+
}
|
|
65
|
+
}), P = "_inputBlock_18lh2_1", S = "_input_18lh2_1", Z = "_icon_18lh2_47", z = {
|
|
66
|
+
inputBlock: P,
|
|
67
|
+
input: S,
|
|
68
|
+
icon: Z
|
|
69
|
+
}, E = {
|
|
70
|
+
$style: z
|
|
71
|
+
}, U = /* @__PURE__ */ I(F, [["__cssModules", E]]);
|
|
257
72
|
export {
|
|
258
|
-
|
|
73
|
+
U as default
|
|
259
74
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mhz-ui",
|
|
3
3
|
"description": "mhz-ui",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.16",
|
|
5
5
|
"author": "Alexandr Dergunov <dergunovs@mail.ru> (https://github.com/dergunovs)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"@vueform/slider": "2.1.7",
|
|
30
30
|
"@vueuse/core": "10.4.1",
|
|
31
31
|
"@vueuse/integrations": "10.4.1",
|
|
32
|
-
"maska": "2.1.10",
|
|
33
32
|
"perfect-debounce": "1.0.0",
|
|
34
33
|
"vue": "3.3.4",
|
|
35
34
|
"vue-router": "4.2.4"
|