tsviewer 1.0.26 → 1.0.28

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.
@@ -0,0 +1,265 @@
1
+ import { defineComponent as Z, ref as oe, reactive as ce, computed as h, watch as de, onMounted as me, onUpdated as pe, createElementBlock as M, openBlock as b, withModifiers as z, normalizeClass as K, unref as r, withDirectives as q, createCommentVNode as J, createVNode as O, withKeys as E, renderSlot as _, withCtx as S, createBlock as P, createSlots as fe } from "vue";
2
+ import { u as be, c as ve, d as Ne, e as Ve, f as he, g as ye } from "./el-input-DNjlHApm.mjs";
3
+ import { i as p, a as y, b as Ie, U as N, I as F, C as ee, _ as ge, u as we, c as Ee, d as A, e as L, E as Q, f as _e, m as Se, g as Pe, p as Ae, t as Fe, h as Ce, w as ke } from "./base-CIy5gWpu.mjs";
4
+ import { v as X } from "./index-ClxLs_jS.mjs";
5
+ const xe = Ie({
6
+ id: {
7
+ type: String,
8
+ default: void 0
9
+ },
10
+ step: {
11
+ type: Number,
12
+ default: 1
13
+ },
14
+ stepStrictly: Boolean,
15
+ max: {
16
+ type: Number,
17
+ default: Number.POSITIVE_INFINITY
18
+ },
19
+ min: {
20
+ type: Number,
21
+ default: Number.NEGATIVE_INFINITY
22
+ },
23
+ modelValue: {
24
+ type: [Number, null]
25
+ },
26
+ readonly: Boolean,
27
+ disabled: Boolean,
28
+ size: ve,
29
+ controls: {
30
+ type: Boolean,
31
+ default: !0
32
+ },
33
+ controlsPosition: {
34
+ type: String,
35
+ default: "",
36
+ values: ["", "right"]
37
+ },
38
+ valueOnClear: {
39
+ type: [String, Number, null],
40
+ validator: (l) => l === null || p(l) || ["min", "max"].includes(l),
41
+ default: null
42
+ },
43
+ name: String,
44
+ placeholder: String,
45
+ precision: {
46
+ type: Number,
47
+ validator: (l) => l >= 0 && l === Number.parseInt(`${l}`, 10)
48
+ },
49
+ validateEvent: {
50
+ type: Boolean,
51
+ default: !0
52
+ },
53
+ ...be(["ariaLabel"])
54
+ }), Be = {
55
+ [ee]: (l, C) => C !== l,
56
+ blur: (l) => l instanceof FocusEvent,
57
+ focus: (l) => l instanceof FocusEvent,
58
+ [F]: (l) => p(l) || y(l),
59
+ [N]: (l) => p(l) || y(l)
60
+ }, De = Z({
61
+ name: "ElInputNumber"
62
+ }), Te = /* @__PURE__ */ Z({
63
+ ...De,
64
+ props: xe,
65
+ emits: Be,
66
+ setup(l, { expose: C, emit: c }) {
67
+ const a = l, { t: U } = we(), m = Ee("input-number"), f = oe(), u = ce({
68
+ currentValue: a.modelValue,
69
+ userInput: null
70
+ }), { formItem: v } = Ne(), G = h(() => p(a.modelValue) && a.modelValue <= a.min), R = h(() => p(a.modelValue) && a.modelValue >= a.max), ne = h(() => {
71
+ const e = Y(a.step);
72
+ return A(a.precision) ? Math.max(Y(a.modelValue), e) : (e > a.precision && L("InputNumber", "precision should not be less than the decimal places of step"), a.precision);
73
+ }), k = h(() => a.controls && a.controlsPosition === "right"), W = Ve(), V = he(), x = h(() => {
74
+ if (u.userInput !== null)
75
+ return u.userInput;
76
+ let e = u.currentValue;
77
+ if (y(e))
78
+ return "";
79
+ if (p(e)) {
80
+ if (Number.isNaN(e))
81
+ return "";
82
+ A(a.precision) || (e = e.toFixed(a.precision));
83
+ }
84
+ return e;
85
+ }), B = (e, n) => {
86
+ if (A(n) && (n = ne.value), n === 0)
87
+ return Math.round(e);
88
+ let t = String(e);
89
+ const s = t.indexOf(".");
90
+ if (s === -1 || !t.replace(".", "").split("")[s + n])
91
+ return e;
92
+ const g = t.length;
93
+ return t.charAt(g - 1) === "5" && (t = `${t.slice(0, Math.max(0, g - 1))}6`), Number.parseFloat(Number(t).toFixed(n));
94
+ }, Y = (e) => {
95
+ if (y(e))
96
+ return 0;
97
+ const n = e.toString(), t = n.indexOf(".");
98
+ let s = 0;
99
+ return t !== -1 && (s = n.length - t - 1), s;
100
+ }, H = (e, n = 1) => p(e) ? B(e + a.step * n) : u.currentValue, D = () => {
101
+ if (a.readonly || V.value || R.value)
102
+ return;
103
+ const e = Number(x.value) || 0, n = H(e);
104
+ I(n), c(F, u.currentValue), $();
105
+ }, T = () => {
106
+ if (a.readonly || V.value || G.value)
107
+ return;
108
+ const e = Number(x.value) || 0, n = H(e, -1);
109
+ I(n), c(F, u.currentValue), $();
110
+ }, j = (e, n) => {
111
+ const { max: t, min: s, step: i, precision: d, stepStrictly: g, valueOnClear: w } = a;
112
+ t < s && Fe("InputNumber", "min should not be greater than max.");
113
+ let o = Number(e);
114
+ if (y(e) || Number.isNaN(o))
115
+ return null;
116
+ if (e === "") {
117
+ if (w === null)
118
+ return null;
119
+ o = Ce(w) ? { min: s, max: t }[w] : w;
120
+ }
121
+ return g && (o = B(Math.round(o / i) * i, d), o !== e && n && c(N, o)), A(d) || (o = B(o, d)), (o > t || o < s) && (o = o > t ? t : s, n && c(N, o)), o;
122
+ }, I = (e, n = !0) => {
123
+ var t;
124
+ const s = u.currentValue, i = j(e);
125
+ if (!n) {
126
+ c(N, i);
127
+ return;
128
+ }
129
+ s === i && e || (u.userInput = null, c(N, i), s !== i && c(ee, i, s), a.validateEvent && ((t = v == null ? void 0 : v.validate) == null || t.call(v, "change").catch((d) => L(d))), u.currentValue = i);
130
+ }, te = (e) => {
131
+ u.userInput = e;
132
+ const n = e === "" ? null : Number(e);
133
+ c(F, n), I(n, !1);
134
+ }, re = (e) => {
135
+ const n = e !== "" ? Number(e) : "";
136
+ (p(n) && !Number.isNaN(n) || e === "") && I(n), $(), u.userInput = null;
137
+ }, ae = () => {
138
+ var e, n;
139
+ (n = (e = f.value) == null ? void 0 : e.focus) == null || n.call(e);
140
+ }, le = () => {
141
+ var e, n;
142
+ (n = (e = f.value) == null ? void 0 : e.blur) == null || n.call(e);
143
+ }, ue = (e) => {
144
+ c("focus", e);
145
+ }, se = (e) => {
146
+ var n, t;
147
+ u.userInput = null, u.currentValue === null && ((n = f.value) != null && n.input) && (f.value.input.value = ""), c("blur", e), a.validateEvent && ((t = v == null ? void 0 : v.validate) == null || t.call(v, "blur").catch((s) => L(s)));
148
+ }, $ = () => {
149
+ u.currentValue !== a.modelValue && (u.currentValue = a.modelValue);
150
+ }, ie = (e) => {
151
+ document.activeElement === e.target && e.preventDefault();
152
+ };
153
+ return de(() => a.modelValue, (e, n) => {
154
+ const t = j(e, !0);
155
+ u.userInput === null && t !== n && (u.currentValue = t);
156
+ }, { immediate: !0 }), me(() => {
157
+ var e;
158
+ const { min: n, max: t, modelValue: s } = a, i = (e = f.value) == null ? void 0 : e.input;
159
+ if (i.setAttribute("role", "spinbutton"), Number.isFinite(t) ? i.setAttribute("aria-valuemax", String(t)) : i.removeAttribute("aria-valuemax"), Number.isFinite(n) ? i.setAttribute("aria-valuemin", String(n)) : i.removeAttribute("aria-valuemin"), i.setAttribute("aria-valuenow", u.currentValue || u.currentValue === 0 ? String(u.currentValue) : ""), i.setAttribute("aria-disabled", String(V.value)), !p(s) && s != null) {
160
+ let d = Number(s);
161
+ Number.isNaN(d) && (d = null), c(N, d);
162
+ }
163
+ i.addEventListener("wheel", ie, { passive: !1 });
164
+ }), pe(() => {
165
+ var e, n;
166
+ const t = (e = f.value) == null ? void 0 : e.input;
167
+ t == null || t.setAttribute("aria-valuenow", `${(n = u.currentValue) != null ? n : ""}`);
168
+ }), C({
169
+ focus: ae,
170
+ blur: le
171
+ }), (e, n) => (b(), M("div", {
172
+ class: K([
173
+ r(m).b(),
174
+ r(m).m(r(W)),
175
+ r(m).is("disabled", r(V)),
176
+ r(m).is("without-controls", !e.controls),
177
+ r(m).is("controls-right", r(k))
178
+ ]),
179
+ onDragstart: z(() => {
180
+ }, ["prevent"])
181
+ }, [
182
+ e.controls ? q((b(), M("span", {
183
+ key: 0,
184
+ role: "button",
185
+ "aria-label": r(U)("el.inputNumber.decrease"),
186
+ class: K([r(m).e("decrease"), r(m).is("disabled", r(G))]),
187
+ onKeydown: E(T, ["enter"])
188
+ }, [
189
+ _(e.$slots, "decrease-icon", {}, () => [
190
+ O(r(Q), null, {
191
+ default: S(() => [
192
+ r(k) ? (b(), P(r(_e), { key: 0 })) : (b(), P(r(Se), { key: 1 }))
193
+ ]),
194
+ _: 1
195
+ })
196
+ ])
197
+ ], 42, ["aria-label", "onKeydown"])), [
198
+ [r(X), T]
199
+ ]) : J("v-if", !0),
200
+ e.controls ? q((b(), M("span", {
201
+ key: 1,
202
+ role: "button",
203
+ "aria-label": r(U)("el.inputNumber.increase"),
204
+ class: K([r(m).e("increase"), r(m).is("disabled", r(R))]),
205
+ onKeydown: E(D, ["enter"])
206
+ }, [
207
+ _(e.$slots, "increase-icon", {}, () => [
208
+ O(r(Q), null, {
209
+ default: S(() => [
210
+ r(k) ? (b(), P(r(Pe), { key: 0 })) : (b(), P(r(Ae), { key: 1 }))
211
+ ]),
212
+ _: 1
213
+ })
214
+ ])
215
+ ], 42, ["aria-label", "onKeydown"])), [
216
+ [r(X), D]
217
+ ]) : J("v-if", !0),
218
+ O(r(ye), {
219
+ id: e.id,
220
+ ref_key: "input",
221
+ ref: f,
222
+ type: "number",
223
+ step: e.step,
224
+ "model-value": r(x),
225
+ placeholder: e.placeholder,
226
+ readonly: e.readonly,
227
+ disabled: r(V),
228
+ size: r(W),
229
+ max: e.max,
230
+ min: e.min,
231
+ name: e.name,
232
+ "aria-label": e.ariaLabel,
233
+ "validate-event": !1,
234
+ onKeydown: [
235
+ E(z(D, ["prevent"]), ["up"]),
236
+ E(z(T, ["prevent"]), ["down"])
237
+ ],
238
+ onBlur: se,
239
+ onFocus: ue,
240
+ onInput: te,
241
+ onChange: re
242
+ }, fe({
243
+ _: 2
244
+ }, [
245
+ e.$slots.prefix ? {
246
+ name: "prefix",
247
+ fn: S(() => [
248
+ _(e.$slots, "prefix")
249
+ ])
250
+ } : void 0,
251
+ e.$slots.suffix ? {
252
+ name: "suffix",
253
+ fn: S(() => [
254
+ _(e.$slots, "suffix")
255
+ ])
256
+ } : void 0
257
+ ]), 1032, ["id", "step", "model-value", "placeholder", "readonly", "disabled", "size", "max", "min", "name", "aria-label", "onKeydown"])
258
+ ], 42, ["onDragstart"]));
259
+ }
260
+ });
261
+ var $e = /* @__PURE__ */ ge(Te, [["__file", "input-number.vue"]]);
262
+ const Le = ke($e);
263
+ export {
264
+ Le as E
265
+ };