@xto/form 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.mjs +2907 -0
- package/es/style.css +1 -0
- package/lib/index.cjs +1 -0
- package/lib/style.css +1 -0
- package/package.json +39 -0
package/es/index.mjs
ADDED
|
@@ -0,0 +1,2907 @@
|
|
|
1
|
+
import { defineComponent as Q, ref as A, useSlots as Le, computed as h, openBlock as c, createElementBlock as d, normalizeClass as u, unref as s, renderSlot as le, createElementVNode as f, toDisplayString as E, createCommentVNode as K, withDirectives as de, vModelDynamic as Ee, watch as ie, normalizeStyle as ae, vModelText as $e, inject as ke, withModifiers as ue, createTextVNode as ve, provide as xe, onMounted as ge, onUnmounted as be, Fragment as j, renderList as _, createBlock as pe, Teleport as Me, createVNode as ye, Transition as Te, withCtx as Re, vShow as Be, nextTick as we } from "vue";
|
|
2
|
+
import { useNamespace as J, useZIndex as Fe } from "@xto/core";
|
|
3
|
+
const Ye = ["type", "placeholder", "disabled", "readonly", "maxlength", "minlength"], tl = /* @__PURE__ */ Q({
|
|
4
|
+
name: "XInput",
|
|
5
|
+
__name: "index",
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: { default: "" },
|
|
8
|
+
type: { default: "text" },
|
|
9
|
+
placeholder: { default: "" },
|
|
10
|
+
size: { default: "default" },
|
|
11
|
+
disabled: { type: Boolean, default: !1 },
|
|
12
|
+
readonly: { type: Boolean, default: !1 },
|
|
13
|
+
maxlength: {},
|
|
14
|
+
minlength: {},
|
|
15
|
+
showWordLimit: { type: Boolean, default: !1 },
|
|
16
|
+
clearable: { type: Boolean, default: !1 },
|
|
17
|
+
showPassword: { type: Boolean, default: !1 },
|
|
18
|
+
prefixIcon: {},
|
|
19
|
+
suffixIcon: {}
|
|
20
|
+
},
|
|
21
|
+
emits: ["update:modelValue", "input", "change", "focus", "blur", "clear"],
|
|
22
|
+
setup(n, { expose: p, emit: e }) {
|
|
23
|
+
const t = n, l = e, a = J("input"), y = A(), v = A(!1), V = A(!1), x = Le(), F = h(
|
|
24
|
+
() => t.type === "password" && t.showPassword && !t.disabled
|
|
25
|
+
), C = h(() => F.value ? V.value ? "text" : "password" : t.type), w = h({
|
|
26
|
+
get: () => t.modelValue,
|
|
27
|
+
set: (z) => l("update:modelValue", z)
|
|
28
|
+
}), b = h(() => String(w.value).length), S = h(() => [
|
|
29
|
+
a.b(),
|
|
30
|
+
t.size !== "default" ? a.m(t.size) : "",
|
|
31
|
+
a.is("disabled", t.disabled),
|
|
32
|
+
a.is("focus", v.value),
|
|
33
|
+
a.is("has-prefix", t.prefixIcon || x.prefix),
|
|
34
|
+
a.is("has-suffix", t.suffixIcon || x.suffix || t.clearable || F.value || t.showWordLimit)
|
|
35
|
+
]), r = (z) => {
|
|
36
|
+
const U = z.target.value;
|
|
37
|
+
l("update:modelValue", U), l("input", U);
|
|
38
|
+
}, k = (z) => {
|
|
39
|
+
const U = z.target.value;
|
|
40
|
+
l("change", U);
|
|
41
|
+
}, M = (z) => {
|
|
42
|
+
v.value = !0, l("focus", z);
|
|
43
|
+
}, B = (z) => {
|
|
44
|
+
v.value = !1, l("blur", z);
|
|
45
|
+
}, I = () => {
|
|
46
|
+
l("update:modelValue", ""), l("clear");
|
|
47
|
+
}, T = () => {
|
|
48
|
+
V.value = !V.value;
|
|
49
|
+
};
|
|
50
|
+
return p({
|
|
51
|
+
focus: () => {
|
|
52
|
+
var z;
|
|
53
|
+
(z = y.value) == null || z.focus();
|
|
54
|
+
},
|
|
55
|
+
blur: () => {
|
|
56
|
+
var z;
|
|
57
|
+
(z = y.value) == null || z.blur();
|
|
58
|
+
},
|
|
59
|
+
inputRef: y
|
|
60
|
+
}), (z, U) => (c(), d("div", {
|
|
61
|
+
class: u(S.value)
|
|
62
|
+
}, [
|
|
63
|
+
z.$slots.prefix || n.prefixIcon ? (c(), d("span", {
|
|
64
|
+
key: 0,
|
|
65
|
+
class: u(s(a).e("prefix"))
|
|
66
|
+
}, [
|
|
67
|
+
le(z.$slots, "prefix", {}, () => [
|
|
68
|
+
f("span", {
|
|
69
|
+
class: u(s(a).e("icon"))
|
|
70
|
+
}, E(n.prefixIcon), 3)
|
|
71
|
+
])
|
|
72
|
+
], 2)) : K("", !0),
|
|
73
|
+
de(f("input", {
|
|
74
|
+
ref_key: "inputRef",
|
|
75
|
+
ref: y,
|
|
76
|
+
"onUpdate:modelValue": U[0] || (U[0] = (q) => w.value = q),
|
|
77
|
+
type: C.value,
|
|
78
|
+
placeholder: n.placeholder,
|
|
79
|
+
disabled: n.disabled,
|
|
80
|
+
readonly: n.readonly,
|
|
81
|
+
maxlength: n.maxlength,
|
|
82
|
+
minlength: n.minlength,
|
|
83
|
+
class: u(s(a).e("inner")),
|
|
84
|
+
onInput: r,
|
|
85
|
+
onChange: k,
|
|
86
|
+
onFocus: M,
|
|
87
|
+
onBlur: B
|
|
88
|
+
}, null, 42, Ye), [
|
|
89
|
+
[Ee, w.value]
|
|
90
|
+
]),
|
|
91
|
+
z.$slots.suffix || n.suffixIcon || n.clearable || F.value || n.showWordLimit ? (c(), d("span", {
|
|
92
|
+
key: 1,
|
|
93
|
+
class: u(s(a).e("suffix"))
|
|
94
|
+
}, [
|
|
95
|
+
le(z.$slots, "suffix", {}, () => [
|
|
96
|
+
n.clearable && w.value && !n.disabled ? (c(), d("span", {
|
|
97
|
+
key: 0,
|
|
98
|
+
class: u([s(a).e("icon"), s(a).e("clear")]),
|
|
99
|
+
onClick: I
|
|
100
|
+
}, " โ ", 2)) : K("", !0),
|
|
101
|
+
F.value ? (c(), d("span", {
|
|
102
|
+
key: 1,
|
|
103
|
+
class: u([s(a).e("icon"), s(a).e("password")]),
|
|
104
|
+
onClick: T
|
|
105
|
+
}, E(V.value ? "๐" : "๐๏ธ"), 3)) : K("", !0),
|
|
106
|
+
n.showWordLimit && n.maxlength ? (c(), d("span", {
|
|
107
|
+
key: 2,
|
|
108
|
+
class: u(s(a).e("count"))
|
|
109
|
+
}, E(b.value) + "/" + E(n.maxlength), 3)) : K("", !0)
|
|
110
|
+
])
|
|
111
|
+
], 2)) : K("", !0)
|
|
112
|
+
], 2));
|
|
113
|
+
}
|
|
114
|
+
}), ze = ["disabled"], He = ["value", "placeholder", "disabled"], Oe = ["disabled"], ll = /* @__PURE__ */ Q({
|
|
115
|
+
name: "XInputNumber",
|
|
116
|
+
__name: "index",
|
|
117
|
+
props: {
|
|
118
|
+
modelValue: { default: void 0 },
|
|
119
|
+
min: { default: -1 / 0 },
|
|
120
|
+
max: { default: 1 / 0 },
|
|
121
|
+
step: { default: 1 },
|
|
122
|
+
stepStrictly: { type: Boolean, default: !1 },
|
|
123
|
+
precision: { default: void 0 },
|
|
124
|
+
size: { default: "default" },
|
|
125
|
+
disabled: { type: Boolean, default: !1 },
|
|
126
|
+
controls: { type: Boolean, default: !0 },
|
|
127
|
+
controlsPosition: { default: "" },
|
|
128
|
+
placeholder: { default: "" },
|
|
129
|
+
valueOnClear: { default: null }
|
|
130
|
+
},
|
|
131
|
+
emits: ["update:modelValue", "change", "focus", "blur"],
|
|
132
|
+
setup(n, { expose: p, emit: e }) {
|
|
133
|
+
const t = n, l = e, a = J("input-number"), y = A(), v = A(!1), V = A(null), x = A(t.modelValue), F = h(() => {
|
|
134
|
+
if (t.precision !== void 0)
|
|
135
|
+
return t.precision;
|
|
136
|
+
const o = C(t.step), i = t.modelValue !== void 0 ? C(t.modelValue) : 0;
|
|
137
|
+
return Math.max(o, i);
|
|
138
|
+
});
|
|
139
|
+
function C(o) {
|
|
140
|
+
const i = o.toString(), m = i.indexOf(".");
|
|
141
|
+
return m === -1 ? 0 : i.length - m - 1;
|
|
142
|
+
}
|
|
143
|
+
function w(o, i = F.value) {
|
|
144
|
+
if (i === 0) return Math.round(o);
|
|
145
|
+
let m = o.toFixed(i);
|
|
146
|
+
return Number(m);
|
|
147
|
+
}
|
|
148
|
+
function b(o) {
|
|
149
|
+
return o > t.max ? t.max : o < t.min ? t.min : o;
|
|
150
|
+
}
|
|
151
|
+
const S = h(() => t.modelValue), r = h(() => V.value !== null ? V.value : S.value === void 0 ? "" : w(S.value)), k = h(() => t.disabled ? !0 : S.value === void 0 ? t.min !== -1 / 0 : S.value <= t.min), M = h(() => t.disabled ? !0 : S.value === void 0 ? t.max !== 1 / 0 : S.value >= t.max), B = h(() => [
|
|
152
|
+
a.b(),
|
|
153
|
+
t.size !== "default" ? a.m(t.size) : "",
|
|
154
|
+
a.is("disabled", t.disabled),
|
|
155
|
+
a.is("focus", v.value),
|
|
156
|
+
t.controlsPosition ? a.m(t.controlsPosition) : ""
|
|
157
|
+
]);
|
|
158
|
+
function I() {
|
|
159
|
+
if (t.disabled || M.value) return;
|
|
160
|
+
const o = S.value ?? (t.min === -1 / 0 ? 0 : t.min), i = w(o + t.step), m = b(i);
|
|
161
|
+
R(m);
|
|
162
|
+
}
|
|
163
|
+
function T() {
|
|
164
|
+
if (t.disabled || k.value) return;
|
|
165
|
+
const o = S.value ?? (t.min === -1 / 0 ? 0 : t.min), i = w(o - t.step), m = b(i);
|
|
166
|
+
R(m);
|
|
167
|
+
}
|
|
168
|
+
function R(o) {
|
|
169
|
+
const i = x.value;
|
|
170
|
+
if (o === void 0)
|
|
171
|
+
l("update:modelValue", void 0), l("change", void 0, i);
|
|
172
|
+
else {
|
|
173
|
+
const m = w(o), O = b(m);
|
|
174
|
+
if (t.stepStrictly) {
|
|
175
|
+
const ee = Math.round((O - t.min) / t.step), P = w(t.min + ee * t.step);
|
|
176
|
+
l("update:modelValue", P), l("change", P, i);
|
|
177
|
+
} else
|
|
178
|
+
l("update:modelValue", O), l("change", O, i);
|
|
179
|
+
}
|
|
180
|
+
x.value = t.modelValue, V.value = null;
|
|
181
|
+
}
|
|
182
|
+
function H(o) {
|
|
183
|
+
if (o === "" || o === "-")
|
|
184
|
+
return;
|
|
185
|
+
let i = o.replace(/[^\d.-]/g, "");
|
|
186
|
+
const m = i.split(".");
|
|
187
|
+
m.length > 2 && (i = m[0] + "." + m.slice(1).join("")), i.indexOf("-") > 0 && (i = i.replace(/-/g, "")), i.lastIndexOf("-") > 0 && (i = "-" + i.replace(/-/g, ""));
|
|
188
|
+
const O = Number(i);
|
|
189
|
+
if (!isNaN(O))
|
|
190
|
+
return O;
|
|
191
|
+
}
|
|
192
|
+
function z(o) {
|
|
193
|
+
const i = o.target.value;
|
|
194
|
+
V.value = i;
|
|
195
|
+
}
|
|
196
|
+
function U(o) {
|
|
197
|
+
if (v.value = !1, V.value !== null) {
|
|
198
|
+
const i = H(V.value);
|
|
199
|
+
i === void 0 ? t.valueOnClear !== null ? R(t.valueOnClear) : V.value = null : R(i);
|
|
200
|
+
}
|
|
201
|
+
l("blur", o);
|
|
202
|
+
}
|
|
203
|
+
function q(o) {
|
|
204
|
+
v.value = !0, x.value = t.modelValue, l("focus", o);
|
|
205
|
+
}
|
|
206
|
+
function Z(o) {
|
|
207
|
+
var i;
|
|
208
|
+
if (!t.disabled)
|
|
209
|
+
switch (o.key) {
|
|
210
|
+
case "ArrowUp":
|
|
211
|
+
o.preventDefault(), I();
|
|
212
|
+
break;
|
|
213
|
+
case "ArrowDown":
|
|
214
|
+
o.preventDefault(), T();
|
|
215
|
+
break;
|
|
216
|
+
case "Enter":
|
|
217
|
+
(i = y.value) == null || i.blur();
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function D() {
|
|
222
|
+
V.value = null, t.valueOnClear !== null && t.valueOnClear !== void 0 ? R(t.valueOnClear) : (l("update:modelValue", void 0), l("change", void 0, x.value), x.value = void 0);
|
|
223
|
+
}
|
|
224
|
+
function $() {
|
|
225
|
+
var o;
|
|
226
|
+
(o = y.value) == null || o.focus();
|
|
227
|
+
}
|
|
228
|
+
function g() {
|
|
229
|
+
var o;
|
|
230
|
+
(o = y.value) == null || o.blur();
|
|
231
|
+
}
|
|
232
|
+
return ie(() => t.modelValue, (o) => {
|
|
233
|
+
x.value = o, V.value = null;
|
|
234
|
+
}, { immediate: !0 }), p({
|
|
235
|
+
focus: $,
|
|
236
|
+
blur: g,
|
|
237
|
+
clear: D,
|
|
238
|
+
increase: I,
|
|
239
|
+
decrease: T
|
|
240
|
+
}), (o, i) => (c(), d("div", {
|
|
241
|
+
class: u(B.value)
|
|
242
|
+
}, [
|
|
243
|
+
n.controls ? (c(), d("button", {
|
|
244
|
+
key: 0,
|
|
245
|
+
type: "button",
|
|
246
|
+
class: u([s(a).e("decrease"), s(a).is("disabled", k.value)]),
|
|
247
|
+
disabled: k.value,
|
|
248
|
+
onClick: T
|
|
249
|
+
}, " โ ", 10, ze)) : K("", !0),
|
|
250
|
+
f("div", {
|
|
251
|
+
class: u(s(a).e("wrapper"))
|
|
252
|
+
}, [
|
|
253
|
+
f("input", {
|
|
254
|
+
ref_key: "inputRef",
|
|
255
|
+
ref: y,
|
|
256
|
+
value: r.value,
|
|
257
|
+
placeholder: n.placeholder,
|
|
258
|
+
disabled: n.disabled,
|
|
259
|
+
class: u(s(a).e("inner")),
|
|
260
|
+
type: "text",
|
|
261
|
+
autocomplete: "off",
|
|
262
|
+
onInput: z,
|
|
263
|
+
onFocus: q,
|
|
264
|
+
onBlur: U,
|
|
265
|
+
onKeydown: Z
|
|
266
|
+
}, null, 42, He)
|
|
267
|
+
], 2),
|
|
268
|
+
n.controls ? (c(), d("button", {
|
|
269
|
+
key: 1,
|
|
270
|
+
type: "button",
|
|
271
|
+
class: u([s(a).e("increase"), s(a).is("disabled", M.value)]),
|
|
272
|
+
disabled: M.value,
|
|
273
|
+
onClick: I
|
|
274
|
+
}, " + ", 10, Oe)) : K("", !0)
|
|
275
|
+
], 2));
|
|
276
|
+
}
|
|
277
|
+
}), Ne = ["placeholder", "disabled", "readonly", "maxlength", "minlength", "rows"], al = /* @__PURE__ */ Q({
|
|
278
|
+
name: "XTextarea",
|
|
279
|
+
__name: "index",
|
|
280
|
+
props: {
|
|
281
|
+
modelValue: { default: "" },
|
|
282
|
+
placeholder: { default: "" },
|
|
283
|
+
disabled: { type: Boolean, default: !1 },
|
|
284
|
+
readonly: { type: Boolean, default: !1 },
|
|
285
|
+
maxlength: {},
|
|
286
|
+
minlength: {},
|
|
287
|
+
rows: { default: 2 },
|
|
288
|
+
autosize: { type: [Boolean, Object], default: !1 },
|
|
289
|
+
showWordLimit: { type: Boolean, default: !1 },
|
|
290
|
+
resize: { default: "vertical" }
|
|
291
|
+
},
|
|
292
|
+
emits: ["update:modelValue", "input", "change", "focus", "blur"],
|
|
293
|
+
setup(n, { expose: p, emit: e }) {
|
|
294
|
+
const t = n, l = e, a = J("textarea"), y = A(), v = A(!1), V = h({
|
|
295
|
+
get: () => t.modelValue,
|
|
296
|
+
set: (B) => l("update:modelValue", B)
|
|
297
|
+
}), x = h(() => String(V.value).length), F = h(() => {
|
|
298
|
+
const B = {};
|
|
299
|
+
if (t.resize && (B.resize = t.resize), t.autosize && (B.minHeight = "auto", typeof t.autosize == "object")) {
|
|
300
|
+
const I = t.autosize.minRows || 1, T = t.autosize.maxRows;
|
|
301
|
+
B.minHeight = `${I * 22 + 12}px`, T && (B.maxHeight = `${T * 22 + 12}px`);
|
|
302
|
+
}
|
|
303
|
+
return B;
|
|
304
|
+
}), C = h(() => [
|
|
305
|
+
a.b(),
|
|
306
|
+
a.is("disabled", t.disabled),
|
|
307
|
+
a.is("focus", v.value),
|
|
308
|
+
a.is("exceed", t.maxlength && x.value > t.maxlength)
|
|
309
|
+
]), w = (B) => {
|
|
310
|
+
const I = B.target.value;
|
|
311
|
+
l("update:modelValue", I), l("input", I), t.autosize && y.value && (y.value.style.height = "auto", y.value.style.height = `${y.value.scrollHeight}px`);
|
|
312
|
+
}, b = (B) => {
|
|
313
|
+
const I = B.target.value;
|
|
314
|
+
l("change", I);
|
|
315
|
+
}, S = (B) => {
|
|
316
|
+
v.value = !0, l("focus", B);
|
|
317
|
+
}, r = (B) => {
|
|
318
|
+
v.value = !1, l("blur", B);
|
|
319
|
+
};
|
|
320
|
+
return p({
|
|
321
|
+
focus: () => {
|
|
322
|
+
var B;
|
|
323
|
+
(B = y.value) == null || B.focus();
|
|
324
|
+
},
|
|
325
|
+
blur: () => {
|
|
326
|
+
var B;
|
|
327
|
+
(B = y.value) == null || B.blur();
|
|
328
|
+
},
|
|
329
|
+
textareaRef: y
|
|
330
|
+
}), (B, I) => (c(), d("div", {
|
|
331
|
+
class: u(C.value),
|
|
332
|
+
style: ae(n.disabled ? void 0 : { cursor: "text" })
|
|
333
|
+
}, [
|
|
334
|
+
de(f("textarea", {
|
|
335
|
+
ref_key: "textareaRef",
|
|
336
|
+
ref: y,
|
|
337
|
+
"onUpdate:modelValue": I[0] || (I[0] = (T) => V.value = T),
|
|
338
|
+
placeholder: n.placeholder,
|
|
339
|
+
disabled: n.disabled,
|
|
340
|
+
readonly: n.readonly,
|
|
341
|
+
maxlength: n.maxlength,
|
|
342
|
+
minlength: n.minlength,
|
|
343
|
+
rows: n.rows,
|
|
344
|
+
style: ae(F.value),
|
|
345
|
+
class: u(s(a).e("inner")),
|
|
346
|
+
onInput: w,
|
|
347
|
+
onChange: b,
|
|
348
|
+
onFocus: S,
|
|
349
|
+
onBlur: r
|
|
350
|
+
}, null, 46, Ne), [
|
|
351
|
+
[$e, V.value]
|
|
352
|
+
]),
|
|
353
|
+
n.showWordLimit && n.maxlength ? (c(), d("span", {
|
|
354
|
+
key: 0,
|
|
355
|
+
class: u(s(a).e("count"))
|
|
356
|
+
}, E(x.value) + "/" + E(n.maxlength), 3)) : K("", !0)
|
|
357
|
+
], 6));
|
|
358
|
+
}
|
|
359
|
+
}), nl = /* @__PURE__ */ Q({
|
|
360
|
+
name: "XSwitch",
|
|
361
|
+
__name: "index",
|
|
362
|
+
props: {
|
|
363
|
+
modelValue: { type: [Boolean, Number, String], default: !1 },
|
|
364
|
+
disabled: { type: Boolean, default: !1 },
|
|
365
|
+
width: { default: 40 },
|
|
366
|
+
activeColor: { default: "#409eff" },
|
|
367
|
+
inactiveColor: { default: "#dcdfe6" },
|
|
368
|
+
activeValue: { type: [Boolean, Number, String], default: !0 },
|
|
369
|
+
inactiveValue: { type: [Boolean, Number, String], default: !1 }
|
|
370
|
+
},
|
|
371
|
+
emits: ["update:modelValue", "change"],
|
|
372
|
+
setup(n, { emit: p }) {
|
|
373
|
+
const e = n, t = p, l = J("switch"), a = h(() => e.modelValue === e.activeValue), y = h(() => [
|
|
374
|
+
l.b(),
|
|
375
|
+
l.is("disabled", e.disabled),
|
|
376
|
+
l.is("checked", a.value)
|
|
377
|
+
]), v = h(() => ({
|
|
378
|
+
width: typeof e.width == "number" ? `${e.width}px` : e.width,
|
|
379
|
+
height: "20px",
|
|
380
|
+
backgroundColor: a.value ? e.activeColor : e.inactiveColor
|
|
381
|
+
})), V = () => {
|
|
382
|
+
if (e.disabled) return;
|
|
383
|
+
const x = a.value ? e.inactiveValue : e.activeValue;
|
|
384
|
+
t("update:modelValue", x), t("change", x);
|
|
385
|
+
};
|
|
386
|
+
return (x, F) => (c(), d("span", {
|
|
387
|
+
class: u(y.value),
|
|
388
|
+
onClick: V
|
|
389
|
+
}, [
|
|
390
|
+
f("span", {
|
|
391
|
+
class: u(s(l).e("core")),
|
|
392
|
+
style: ae(v.value)
|
|
393
|
+
}, null, 6),
|
|
394
|
+
x.$slots.default ? (c(), d("span", {
|
|
395
|
+
key: 0,
|
|
396
|
+
class: u(s(l).e("text"))
|
|
397
|
+
}, [
|
|
398
|
+
le(x.$slots, "default")
|
|
399
|
+
], 2)) : K("", !0)
|
|
400
|
+
], 2));
|
|
401
|
+
}
|
|
402
|
+
}), Ke = ["checked", "disabled", "name", "value"], sl = /* @__PURE__ */ Q({
|
|
403
|
+
name: "XRadio",
|
|
404
|
+
__name: "index",
|
|
405
|
+
props: {
|
|
406
|
+
modelValue: { type: [String, Number, Boolean] },
|
|
407
|
+
value: { type: [String, Number, Boolean] },
|
|
408
|
+
label: {},
|
|
409
|
+
disabled: { type: Boolean },
|
|
410
|
+
name: {}
|
|
411
|
+
},
|
|
412
|
+
emits: ["update:modelValue", "change"],
|
|
413
|
+
setup(n, { emit: p }) {
|
|
414
|
+
const e = n, t = p, l = J("radio"), a = ke("radioGroup", null), y = h(() => !!a), v = h(() => y.value ? a.modelValue.value : e.modelValue), V = h(() => e.value ?? e.label), x = h(() => v.value === V.value), F = h(() => e.disabled || y.value && a.disabled), C = h(() => e.name || (y.value ? a.name : void 0)), w = h(() => [
|
|
415
|
+
l.b(),
|
|
416
|
+
l.is("checked", x.value),
|
|
417
|
+
l.is("disabled", F.value)
|
|
418
|
+
]), b = () => {
|
|
419
|
+
F.value || (y.value ? a.changeValue(V.value) : (t("update:modelValue", V.value), t("change", V.value)));
|
|
420
|
+
};
|
|
421
|
+
return (S, r) => (c(), d("label", {
|
|
422
|
+
class: u(w.value),
|
|
423
|
+
onClick: ue(b, ["prevent"])
|
|
424
|
+
}, [
|
|
425
|
+
f("span", {
|
|
426
|
+
class: u(s(l).e("input"))
|
|
427
|
+
}, [
|
|
428
|
+
f("input", {
|
|
429
|
+
type: "radio",
|
|
430
|
+
checked: x.value,
|
|
431
|
+
disabled: F.value,
|
|
432
|
+
name: C.value,
|
|
433
|
+
value: V.value
|
|
434
|
+
}, null, 8, Ke)
|
|
435
|
+
], 2),
|
|
436
|
+
S.$slots.default || n.label ? (c(), d("span", {
|
|
437
|
+
key: 0,
|
|
438
|
+
class: u(s(l).e("label"))
|
|
439
|
+
}, [
|
|
440
|
+
le(S.$slots, "default", {}, () => [
|
|
441
|
+
ve(E(n.label), 1)
|
|
442
|
+
])
|
|
443
|
+
], 2)) : K("", !0)
|
|
444
|
+
], 2));
|
|
445
|
+
}
|
|
446
|
+
}), ul = /* @__PURE__ */ Q({
|
|
447
|
+
name: "XRadioGroup",
|
|
448
|
+
__name: "group",
|
|
449
|
+
props: {
|
|
450
|
+
modelValue: { type: [String, Number, Boolean], default: "" },
|
|
451
|
+
disabled: { type: Boolean, default: !1 },
|
|
452
|
+
name: {}
|
|
453
|
+
},
|
|
454
|
+
emits: ["update:modelValue", "change"],
|
|
455
|
+
setup(n, { emit: p }) {
|
|
456
|
+
const e = n, t = p, l = J("radio-group"), a = (y) => {
|
|
457
|
+
t("update:modelValue", y), t("change", y);
|
|
458
|
+
};
|
|
459
|
+
return xe("radioGroup", {
|
|
460
|
+
modelValue: h(() => e.modelValue),
|
|
461
|
+
name: e.name || `radio-group-${Date.now()}`,
|
|
462
|
+
disabled: e.disabled,
|
|
463
|
+
changeValue: a
|
|
464
|
+
}), (y, v) => (c(), d("div", {
|
|
465
|
+
class: u(s(l).b()),
|
|
466
|
+
role: "radiogroup"
|
|
467
|
+
}, [
|
|
468
|
+
le(y.$slots, "default")
|
|
469
|
+
], 2));
|
|
470
|
+
}
|
|
471
|
+
}), Xe = ["checked", "disabled", "value"], ol = /* @__PURE__ */ Q({
|
|
472
|
+
name: "XRadioButton",
|
|
473
|
+
__name: "button",
|
|
474
|
+
props: {
|
|
475
|
+
value: { type: [String, Number, Boolean] },
|
|
476
|
+
label: {},
|
|
477
|
+
disabled: { type: Boolean },
|
|
478
|
+
name: {}
|
|
479
|
+
},
|
|
480
|
+
emits: ["update:modelValue", "change"],
|
|
481
|
+
setup(n, { emit: p }) {
|
|
482
|
+
const e = n, t = J("radio-button"), l = ke("radioGroup", null), a = h(() => !!l), y = h(() => a.value ? l.modelValue.value : null), v = h(() => e.value ?? e.label), V = h(() => y.value === v.value), x = h(() => e.disabled || a.value && l.disabled), F = h(() => [
|
|
483
|
+
t.b(),
|
|
484
|
+
t.is("active", V.value),
|
|
485
|
+
t.is("disabled", x.value)
|
|
486
|
+
]), C = () => {
|
|
487
|
+
x.value || a.value && l.changeValue(v.value);
|
|
488
|
+
};
|
|
489
|
+
return (w, b) => (c(), d("label", {
|
|
490
|
+
class: u(F.value),
|
|
491
|
+
onClick: ue(C, ["prevent"])
|
|
492
|
+
}, [
|
|
493
|
+
f("input", {
|
|
494
|
+
type: "radio",
|
|
495
|
+
checked: V.value,
|
|
496
|
+
disabled: x.value,
|
|
497
|
+
value: v.value,
|
|
498
|
+
class: u(s(t).e("input"))
|
|
499
|
+
}, null, 10, Xe),
|
|
500
|
+
f("span", {
|
|
501
|
+
class: u(s(t).e("inner"))
|
|
502
|
+
}, [
|
|
503
|
+
le(w.$slots, "default", {}, () => [
|
|
504
|
+
ve(E(n.label), 1)
|
|
505
|
+
])
|
|
506
|
+
], 2)
|
|
507
|
+
], 2));
|
|
508
|
+
}
|
|
509
|
+
}), Ue = ["checked", "disabled", "name", "value"], rl = /* @__PURE__ */ Q({
|
|
510
|
+
name: "XCheckbox",
|
|
511
|
+
__name: "index",
|
|
512
|
+
props: {
|
|
513
|
+
modelValue: { type: [Boolean, String, Number, Array] },
|
|
514
|
+
value: { type: [String, Number, Boolean] },
|
|
515
|
+
label: {},
|
|
516
|
+
disabled: { type: Boolean },
|
|
517
|
+
name: {},
|
|
518
|
+
indeterminate: { type: Boolean }
|
|
519
|
+
},
|
|
520
|
+
emits: ["update:modelValue", "change"],
|
|
521
|
+
setup(n, { emit: p }) {
|
|
522
|
+
const e = n, t = p, l = J("checkbox"), a = ke("checkboxGroup", null), y = h(() => !!a), v = h(() => e.value ?? e.label), V = h(() => y.value ? a.modelValue.value.includes(v.value) : Array.isArray(e.modelValue) ? e.modelValue.includes(v.value) : !!e.modelValue), x = h(() => {
|
|
523
|
+
if (e.disabled) return !0;
|
|
524
|
+
if (y.value) {
|
|
525
|
+
const w = a.disabled, b = a.min > 0 && a.modelValue.value.length <= a.min, S = a.max > 0 && a.modelValue.value.length >= a.max;
|
|
526
|
+
return V.value && b || !V.value && S ? !0 : w;
|
|
527
|
+
}
|
|
528
|
+
return !1;
|
|
529
|
+
}), F = h(() => [
|
|
530
|
+
l.b(),
|
|
531
|
+
l.is("checked", V.value),
|
|
532
|
+
l.is("disabled", x.value),
|
|
533
|
+
l.is("indeterminate", e.indeterminate && !V.value)
|
|
534
|
+
]), C = () => {
|
|
535
|
+
if (!x.value)
|
|
536
|
+
if (y.value)
|
|
537
|
+
a.changeValue(v.value);
|
|
538
|
+
else {
|
|
539
|
+
let w;
|
|
540
|
+
if (Array.isArray(e.modelValue)) {
|
|
541
|
+
const b = e.modelValue.indexOf(v.value);
|
|
542
|
+
b > -1 ? w = [...e.modelValue.slice(0, b), ...e.modelValue.slice(b + 1)] : w = [...e.modelValue, v.value];
|
|
543
|
+
} else
|
|
544
|
+
w = !e.modelValue;
|
|
545
|
+
t("update:modelValue", w), t("change", w);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
return (w, b) => (c(), d("label", {
|
|
549
|
+
class: u(F.value),
|
|
550
|
+
onClick: ue(C, ["prevent"])
|
|
551
|
+
}, [
|
|
552
|
+
f("span", {
|
|
553
|
+
class: u(s(l).e("input"))
|
|
554
|
+
}, [
|
|
555
|
+
f("input", {
|
|
556
|
+
type: "checkbox",
|
|
557
|
+
checked: V.value,
|
|
558
|
+
disabled: x.value,
|
|
559
|
+
name: n.name,
|
|
560
|
+
value: v.value
|
|
561
|
+
}, null, 8, Ue)
|
|
562
|
+
], 2),
|
|
563
|
+
w.$slots.default || n.label !== void 0 ? (c(), d("span", {
|
|
564
|
+
key: 0,
|
|
565
|
+
class: u(s(l).e("label"))
|
|
566
|
+
}, [
|
|
567
|
+
le(w.$slots, "default", {}, () => [
|
|
568
|
+
ve(E(n.label), 1)
|
|
569
|
+
])
|
|
570
|
+
], 2)) : K("", !0)
|
|
571
|
+
], 2));
|
|
572
|
+
}
|
|
573
|
+
}), il = /* @__PURE__ */ Q({
|
|
574
|
+
name: "XCheckboxGroup",
|
|
575
|
+
__name: "group",
|
|
576
|
+
props: {
|
|
577
|
+
modelValue: { default: () => [] },
|
|
578
|
+
disabled: { type: Boolean, default: !1 },
|
|
579
|
+
min: { default: 0 },
|
|
580
|
+
max: { default: 0 }
|
|
581
|
+
},
|
|
582
|
+
emits: ["update:modelValue", "change"],
|
|
583
|
+
setup(n, { emit: p }) {
|
|
584
|
+
const e = n, t = p, l = J("checkbox-group"), a = (y) => {
|
|
585
|
+
const v = [...e.modelValue], V = v.indexOf(y);
|
|
586
|
+
V > -1 ? v.splice(V, 1) : v.push(y), t("update:modelValue", v), t("change", v);
|
|
587
|
+
};
|
|
588
|
+
return xe("checkboxGroup", {
|
|
589
|
+
modelValue: h(() => e.modelValue),
|
|
590
|
+
disabled: e.disabled,
|
|
591
|
+
min: e.min,
|
|
592
|
+
max: e.max,
|
|
593
|
+
changeValue: a
|
|
594
|
+
}), (y, v) => (c(), d("div", {
|
|
595
|
+
class: u(s(l).b()),
|
|
596
|
+
role: "group"
|
|
597
|
+
}, [
|
|
598
|
+
le(y.$slots, "default")
|
|
599
|
+
], 2));
|
|
600
|
+
}
|
|
601
|
+
}), cl = /* @__PURE__ */ Q({
|
|
602
|
+
name: "XForm",
|
|
603
|
+
__name: "index",
|
|
604
|
+
props: {
|
|
605
|
+
model: { default: () => ({}) },
|
|
606
|
+
rules: { default: () => ({}) },
|
|
607
|
+
labelWidth: { default: "100px" },
|
|
608
|
+
labelPosition: { default: "right" },
|
|
609
|
+
inline: { type: Boolean, default: !1 },
|
|
610
|
+
disabled: { type: Boolean, default: !1 },
|
|
611
|
+
size: { default: "default" }
|
|
612
|
+
},
|
|
613
|
+
emits: ["validate"],
|
|
614
|
+
setup(n, { expose: p, emit: e }) {
|
|
615
|
+
const t = n, l = e, a = J("form"), y = A([]), v = h(() => [
|
|
616
|
+
a.b(),
|
|
617
|
+
a.m(`label-${t.labelPosition}`),
|
|
618
|
+
a.is("inline", t.inline)
|
|
619
|
+
]), V = h(() => ({ width: typeof t.labelWidth == "number" ? `${t.labelWidth}px` : t.labelWidth })), x = (r) => {
|
|
620
|
+
y.value.push(r);
|
|
621
|
+
}, F = (r) => {
|
|
622
|
+
const k = y.value.indexOf(r);
|
|
623
|
+
k > -1 && y.value.splice(k, 1);
|
|
624
|
+
}, C = async () => {
|
|
625
|
+
let r = !0;
|
|
626
|
+
for (const k of y.value)
|
|
627
|
+
await k.validate() || (r = !1);
|
|
628
|
+
return r;
|
|
629
|
+
}, w = async (r) => {
|
|
630
|
+
const k = Array.isArray(r) ? r : [r];
|
|
631
|
+
let M = !0;
|
|
632
|
+
for (const B of y.value)
|
|
633
|
+
k.includes(B.prop) && (await B.validate() || (M = !1));
|
|
634
|
+
return M;
|
|
635
|
+
}, b = () => {
|
|
636
|
+
y.value.forEach((r) => {
|
|
637
|
+
r.resetField();
|
|
638
|
+
});
|
|
639
|
+
}, S = (r) => {
|
|
640
|
+
if (r) {
|
|
641
|
+
const k = Array.isArray(r) ? r : [r];
|
|
642
|
+
y.value.forEach((M) => {
|
|
643
|
+
k.includes(M.prop) && M.clearValidate();
|
|
644
|
+
});
|
|
645
|
+
} else
|
|
646
|
+
y.value.forEach((k) => {
|
|
647
|
+
k.clearValidate();
|
|
648
|
+
});
|
|
649
|
+
};
|
|
650
|
+
return xe("form", {
|
|
651
|
+
model: t.model,
|
|
652
|
+
rules: t.rules,
|
|
653
|
+
labelWidth: t.labelWidth,
|
|
654
|
+
labelPosition: t.labelPosition,
|
|
655
|
+
disabled: t.disabled,
|
|
656
|
+
size: t.size,
|
|
657
|
+
labelStyle: V,
|
|
658
|
+
addField: x,
|
|
659
|
+
removeField: F,
|
|
660
|
+
emit: l
|
|
661
|
+
}), p({
|
|
662
|
+
validate: C,
|
|
663
|
+
validateField: w,
|
|
664
|
+
resetFields: b,
|
|
665
|
+
clearValidate: S
|
|
666
|
+
}), (r, k) => (c(), d("form", {
|
|
667
|
+
class: u(v.value),
|
|
668
|
+
onSubmit: k[0] || (k[0] = ue(() => {
|
|
669
|
+
}, ["prevent"]))
|
|
670
|
+
}, [
|
|
671
|
+
le(r.$slots, "default")
|
|
672
|
+
], 34));
|
|
673
|
+
}
|
|
674
|
+
}), dl = /* @__PURE__ */ Q({
|
|
675
|
+
name: "XFormItem",
|
|
676
|
+
__name: "item",
|
|
677
|
+
props: {
|
|
678
|
+
prop: {},
|
|
679
|
+
label: {},
|
|
680
|
+
labelWidth: {},
|
|
681
|
+
required: { type: Boolean },
|
|
682
|
+
rules: {},
|
|
683
|
+
showMessage: { type: Boolean }
|
|
684
|
+
},
|
|
685
|
+
setup(n, { expose: p }) {
|
|
686
|
+
const e = n, t = J("form-item"), l = ke("form", null), a = A(""), y = A(""), v = h(() => e.required ? !0 : V().some((M) => M.required)), V = () => {
|
|
687
|
+
const k = [];
|
|
688
|
+
return e.rules && k.push(...e.rules), l && e.prop && l.rules[e.prop] && k.push(...l.rules[e.prop]), k;
|
|
689
|
+
}, x = () => {
|
|
690
|
+
if (!(!l || !e.prop))
|
|
691
|
+
return l.model[e.prop];
|
|
692
|
+
}, F = (k) => {
|
|
693
|
+
!l || !e.prop || (l.model[e.prop] = k);
|
|
694
|
+
}, C = async (k) => {
|
|
695
|
+
const M = V();
|
|
696
|
+
if (M.length === 0)
|
|
697
|
+
return a.value = "valid", !0;
|
|
698
|
+
const B = x();
|
|
699
|
+
let I = !0, T = "";
|
|
700
|
+
for (const R of M)
|
|
701
|
+
if (!(k && R.trigger && R.trigger !== k)) {
|
|
702
|
+
if (R.required && (B == null || B === "" || Array.isArray(B) && B.length === 0)) {
|
|
703
|
+
I = !1, T = R.message || "่ฏฅๅญๆฎตไธบๅฟ
ๅกซ้กน";
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
if (R.min !== void 0 || R.max !== void 0) {
|
|
707
|
+
const H = typeof B == "string" ? B.length : 0;
|
|
708
|
+
if (R.min !== void 0 && H < R.min) {
|
|
709
|
+
I = !1, T = R.message || `้ฟๅบฆไธ่ฝๅฐไบ ${R.min} ไธชๅญ็ฌฆ`;
|
|
710
|
+
break;
|
|
711
|
+
}
|
|
712
|
+
if (R.max !== void 0 && H > R.max) {
|
|
713
|
+
I = !1, T = R.message || `้ฟๅบฆไธ่ฝๅคงไบ ${R.max} ไธชๅญ็ฌฆ`;
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (R.pattern && B && !R.pattern.test(B)) {
|
|
718
|
+
I = !1, T = R.message || "ๆ ผๅผไธๆญฃ็กฎ";
|
|
719
|
+
break;
|
|
720
|
+
}
|
|
721
|
+
if (R.validator)
|
|
722
|
+
try {
|
|
723
|
+
await new Promise((H, z) => {
|
|
724
|
+
R.validator(R, B, (U) => {
|
|
725
|
+
U ? z(U) : H();
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
} catch (H) {
|
|
729
|
+
I = !1, T = H.message || R.message || "้ช่ฏๅคฑ่ดฅ";
|
|
730
|
+
break;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
return a.value = I ? "valid" : "invalid", y.value = T, l && e.prop && l.emit("validate", e.prop, I, T), I;
|
|
734
|
+
}, w = () => {
|
|
735
|
+
F(void 0), b();
|
|
736
|
+
}, b = () => {
|
|
737
|
+
a.value = "", y.value = "";
|
|
738
|
+
}, S = h(() => [
|
|
739
|
+
t.b(),
|
|
740
|
+
t.is("required", v.value),
|
|
741
|
+
t.is("error", a.value === "invalid"),
|
|
742
|
+
t.is("success", a.value === "valid")
|
|
743
|
+
]), r = h(() => {
|
|
744
|
+
const k = e.labelWidth ?? (l == null ? void 0 : l.labelWidth) ?? "100px";
|
|
745
|
+
return { width: typeof k == "number" ? `${k}px` : k };
|
|
746
|
+
});
|
|
747
|
+
return ie(() => x(), () => {
|
|
748
|
+
a.value === "invalid" && C("change");
|
|
749
|
+
}), ge(() => {
|
|
750
|
+
l && e.prop && l.addField({
|
|
751
|
+
prop: e.prop,
|
|
752
|
+
validate: C,
|
|
753
|
+
resetField: w,
|
|
754
|
+
clearValidate: b
|
|
755
|
+
});
|
|
756
|
+
}), be(() => {
|
|
757
|
+
l && e.prop && l.removeField({
|
|
758
|
+
prop: e.prop,
|
|
759
|
+
validate: C,
|
|
760
|
+
resetField: w,
|
|
761
|
+
clearValidate: b
|
|
762
|
+
});
|
|
763
|
+
}), p({
|
|
764
|
+
validate: C,
|
|
765
|
+
resetField: w,
|
|
766
|
+
clearValidate: b
|
|
767
|
+
}), (k, M) => (c(), d("div", {
|
|
768
|
+
class: u(S.value)
|
|
769
|
+
}, [
|
|
770
|
+
n.label ? (c(), d("label", {
|
|
771
|
+
key: 0,
|
|
772
|
+
class: u(s(t).e("label")),
|
|
773
|
+
style: ae(r.value)
|
|
774
|
+
}, E(n.label), 7)) : K("", !0),
|
|
775
|
+
f("div", {
|
|
776
|
+
class: u(s(t).e("content"))
|
|
777
|
+
}, [
|
|
778
|
+
le(k.$slots, "default"),
|
|
779
|
+
n.showMessage !== !1 && a.value === "invalid" ? (c(), d("div", {
|
|
780
|
+
key: 0,
|
|
781
|
+
class: u(s(t).e("error"))
|
|
782
|
+
}, E(y.value), 3)) : K("", !0)
|
|
783
|
+
], 2)
|
|
784
|
+
], 2));
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
function We(n, p) {
|
|
788
|
+
return new Date(n, p + 1, 0).getDate();
|
|
789
|
+
}
|
|
790
|
+
function Ge(n, p) {
|
|
791
|
+
return new Date(n, p, 1).getDay();
|
|
792
|
+
}
|
|
793
|
+
function ce(n, p) {
|
|
794
|
+
return !n || !p ? !1 : n.getFullYear() === p.getFullYear() && n.getMonth() === p.getMonth() && n.getDate() === p.getDate();
|
|
795
|
+
}
|
|
796
|
+
function qe(n, p) {
|
|
797
|
+
return !n || !p ? !1 : n.getFullYear() === p.getFullYear() && n.getMonth() === p.getMonth();
|
|
798
|
+
}
|
|
799
|
+
function Ie(n, p, e) {
|
|
800
|
+
if (!p || !e) return !1;
|
|
801
|
+
const t = n.getTime();
|
|
802
|
+
return t >= p.getTime() && t <= e.getTime();
|
|
803
|
+
}
|
|
804
|
+
function je(n, p, e = 0) {
|
|
805
|
+
const t = [], l = We(n, p), a = Ge(n, p);
|
|
806
|
+
let y = new Date(n, p, 1);
|
|
807
|
+
const v = (a - e + 7) % 7;
|
|
808
|
+
y.setDate(1 - v);
|
|
809
|
+
let V = [], x = new Date(y);
|
|
810
|
+
for (; (x.getMonth() <= p || x.getMonth() === p && x.getDate() <= l) && (V.push(new Date(x)), !(V.length === 7 && (t.push(V), V = [], x.getMonth() > p) || (x.setDate(x.getDate() + 1), t.length > 7))); )
|
|
811
|
+
;
|
|
812
|
+
return V.length > 0 && t.push(V), t;
|
|
813
|
+
}
|
|
814
|
+
function re(n, p = "YYYY-MM-DD") {
|
|
815
|
+
if (!n) return "";
|
|
816
|
+
const e = n.getFullYear(), t = n.getMonth() + 1, l = n.getDate(), a = n.getHours(), y = n.getMinutes(), v = n.getSeconds();
|
|
817
|
+
return p.replace(/YYYY/g, String(e)).replace(/YY/g, String(e).slice(-2)).replace(/MM/g, String(t).padStart(2, "0")).replace(/M/g, String(t)).replace(/DD/g, String(l).padStart(2, "0")).replace(/D/g, String(l)).replace(/HH/g, String(a).padStart(2, "0")).replace(/H/g, String(a)).replace(/mm/g, String(y).padStart(2, "0")).replace(/m/g, String(y)).replace(/ss/g, String(v).padStart(2, "0")).replace(/s/g, String(v));
|
|
818
|
+
}
|
|
819
|
+
function he(n) {
|
|
820
|
+
if (!n) return null;
|
|
821
|
+
if (n instanceof Date)
|
|
822
|
+
return isNaN(n.getTime()) ? null : n;
|
|
823
|
+
if (typeof n == "number")
|
|
824
|
+
return new Date(n);
|
|
825
|
+
const p = new Date(n);
|
|
826
|
+
if (isNaN(p.getTime())) {
|
|
827
|
+
const e = n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})/);
|
|
828
|
+
return e ? new Date(parseInt(e[1]), parseInt(e[2]) - 1, parseInt(e[3])) : null;
|
|
829
|
+
}
|
|
830
|
+
return p;
|
|
831
|
+
}
|
|
832
|
+
function Ze(n) {
|
|
833
|
+
const p = new Date(n);
|
|
834
|
+
return p.setMonth(p.getMonth() - 1), p;
|
|
835
|
+
}
|
|
836
|
+
function Qe(n) {
|
|
837
|
+
const p = new Date(n);
|
|
838
|
+
return p.setMonth(p.getMonth() + 1), p;
|
|
839
|
+
}
|
|
840
|
+
function Je(n) {
|
|
841
|
+
const p = new Date(n);
|
|
842
|
+
return p.setFullYear(p.getFullYear() - 1), p;
|
|
843
|
+
}
|
|
844
|
+
function _e(n) {
|
|
845
|
+
const p = new Date(n);
|
|
846
|
+
return p.setFullYear(p.getFullYear() + 1), p;
|
|
847
|
+
}
|
|
848
|
+
function Pe(n) {
|
|
849
|
+
const p = Math.floor(n / 10) * 10;
|
|
850
|
+
return [p, p + 9];
|
|
851
|
+
}
|
|
852
|
+
function Ce(n) {
|
|
853
|
+
const p = new Date(n);
|
|
854
|
+
return p.setHours(0, 0, 0, 0), p;
|
|
855
|
+
}
|
|
856
|
+
function et(n, p, e, t) {
|
|
857
|
+
if (p && p(n))
|
|
858
|
+
return !0;
|
|
859
|
+
const l = Ce(n).getTime();
|
|
860
|
+
return !!(e && l < Ce(e).getTime() || t && l > Ce(t).getTime());
|
|
861
|
+
}
|
|
862
|
+
const tt = [
|
|
863
|
+
"ไธๆ",
|
|
864
|
+
"ไบๆ",
|
|
865
|
+
"ไธๆ",
|
|
866
|
+
"ๅๆ",
|
|
867
|
+
"ไบๆ",
|
|
868
|
+
"ๅ
ญๆ",
|
|
869
|
+
"ไธๆ",
|
|
870
|
+
"ๅ
ซๆ",
|
|
871
|
+
"ไนๆ",
|
|
872
|
+
"ๅๆ",
|
|
873
|
+
"ๅไธๆ",
|
|
874
|
+
"ๅไบๆ"
|
|
875
|
+
], lt = ["ๆฅ", "ไธ", "ไบ", "ไธ", "ๅ", "ไบ", "ๅ
ญ"], at = ["onClick", "onMouseenter"], nt = /* @__PURE__ */ Q({
|
|
876
|
+
name: "XDateTable",
|
|
877
|
+
__name: "DateTable",
|
|
878
|
+
props: {
|
|
879
|
+
modelValue: { default: null },
|
|
880
|
+
viewedMonth: { default: () => /* @__PURE__ */ new Date() },
|
|
881
|
+
minDate: { default: null },
|
|
882
|
+
maxDate: { default: null },
|
|
883
|
+
disabledDate: {},
|
|
884
|
+
rangeState: { default: () => ({
|
|
885
|
+
selecting: !1,
|
|
886
|
+
startDate: null,
|
|
887
|
+
endDate: null
|
|
888
|
+
}) },
|
|
889
|
+
selectionMode: { default: "single" }
|
|
890
|
+
},
|
|
891
|
+
emits: ["pick", "range-select", "range-move", "update:viewedMonth"],
|
|
892
|
+
setup(n, { emit: p }) {
|
|
893
|
+
const e = n, t = p, l = J("date-table"), a = A(null), y = h(() => e.viewedMonth.getFullYear()), v = h(() => e.viewedMonth.getMonth()), V = h(() => je(y.value, v.value, 0)), x = (T) => e.modelValue ? ce(T, e.modelValue) : !1, F = (T) => ce(T, /* @__PURE__ */ new Date()), C = (T) => qe(T, e.viewedMonth), w = (T) => {
|
|
894
|
+
if (e.selectionMode !== "range") return !1;
|
|
895
|
+
const { startDate: R, endDate: H, selecting: z } = e.rangeState || {};
|
|
896
|
+
if (z && R) {
|
|
897
|
+
const U = a.value;
|
|
898
|
+
if (U) {
|
|
899
|
+
const q = R < U ? R : U, Z = R < U ? U : R;
|
|
900
|
+
return Ie(T, q, Z);
|
|
901
|
+
}
|
|
902
|
+
return ce(T, R);
|
|
903
|
+
}
|
|
904
|
+
return R && H ? Ie(T, R, H) : !1;
|
|
905
|
+
}, b = (T) => {
|
|
906
|
+
if (e.selectionMode !== "range") return !1;
|
|
907
|
+
const { startDate: R, selecting: H } = e.rangeState || {};
|
|
908
|
+
return H && R && a.value ? ce(T, R < a.value ? R : a.value) : R ? ce(T, R) : !1;
|
|
909
|
+
}, S = (T) => {
|
|
910
|
+
if (e.selectionMode !== "range") return !1;
|
|
911
|
+
const { endDate: R, selecting: H } = e.rangeState || {};
|
|
912
|
+
if (H && a.value) {
|
|
913
|
+
const { startDate: z } = e.rangeState || {};
|
|
914
|
+
return ce(T, z < a.value ? a.value : z);
|
|
915
|
+
}
|
|
916
|
+
return R ? ce(T, R) : !1;
|
|
917
|
+
}, r = (T) => et(T, e.disabledDate, e.minDate, e.maxDate), k = (T) => [
|
|
918
|
+
l.e("cell"),
|
|
919
|
+
l.is("selected", x(T)),
|
|
920
|
+
l.is("today", F(T)),
|
|
921
|
+
l.is("disabled", r(T)),
|
|
922
|
+
l.is("in-range", w(T)),
|
|
923
|
+
l.is("range-start", b(T)),
|
|
924
|
+
l.is("range-end", S(T)),
|
|
925
|
+
l.is("prev-month", !C(T) && T.getMonth() < v.value),
|
|
926
|
+
l.is("next-month", !C(T) && T.getMonth() > v.value)
|
|
927
|
+
], M = (T) => {
|
|
928
|
+
r(T) || (e.selectionMode === "range" ? t("range-select", T) : t("pick", T));
|
|
929
|
+
}, B = (T) => {
|
|
930
|
+
a.value = T;
|
|
931
|
+
}, I = () => {
|
|
932
|
+
a.value = null;
|
|
933
|
+
};
|
|
934
|
+
return (T, R) => (c(), d("table", {
|
|
935
|
+
class: u(s(l).b()),
|
|
936
|
+
cellspacing: "0",
|
|
937
|
+
cellpadding: "0"
|
|
938
|
+
}, [
|
|
939
|
+
f("thead", null, [
|
|
940
|
+
f("tr", null, [
|
|
941
|
+
(c(!0), d(j, null, _(s(lt), (H) => (c(), d("th", {
|
|
942
|
+
key: H,
|
|
943
|
+
class: u(s(l).e("header-cell"))
|
|
944
|
+
}, E(H), 3))), 128))
|
|
945
|
+
])
|
|
946
|
+
]),
|
|
947
|
+
f("tbody", null, [
|
|
948
|
+
(c(!0), d(j, null, _(V.value, (H, z) => (c(), d("tr", { key: z }, [
|
|
949
|
+
(c(!0), d(j, null, _(H, (U, q) => (c(), d("td", {
|
|
950
|
+
key: q,
|
|
951
|
+
class: u(k(U)),
|
|
952
|
+
onClick: (Z) => M(U),
|
|
953
|
+
onMouseenter: (Z) => B(U),
|
|
954
|
+
onMouseleave: I
|
|
955
|
+
}, [
|
|
956
|
+
f("span", {
|
|
957
|
+
class: u(s(l).e("cell-text"))
|
|
958
|
+
}, E(U.getDate()), 3)
|
|
959
|
+
], 42, at))), 128))
|
|
960
|
+
]))), 128))
|
|
961
|
+
])
|
|
962
|
+
], 2));
|
|
963
|
+
}
|
|
964
|
+
}), st = ["onClick"], ut = /* @__PURE__ */ Q({
|
|
965
|
+
name: "XMonthTable",
|
|
966
|
+
__name: "MonthTable",
|
|
967
|
+
props: {
|
|
968
|
+
modelValue: { default: null },
|
|
969
|
+
viewedYear: { default: () => (/* @__PURE__ */ new Date()).getFullYear() },
|
|
970
|
+
disabledDate: {}
|
|
971
|
+
},
|
|
972
|
+
emits: ["pick"],
|
|
973
|
+
setup(n, { emit: p }) {
|
|
974
|
+
const e = n, t = p, l = J("month-table");
|
|
975
|
+
h(() => e.modelValue ? e.modelValue.getMonth() : -1);
|
|
976
|
+
const a = (C) => e.modelValue ? e.modelValue.getFullYear() === e.viewedYear && e.modelValue.getMonth() === C : !1, y = (C) => {
|
|
977
|
+
const w = /* @__PURE__ */ new Date();
|
|
978
|
+
return w.getFullYear() === e.viewedYear && w.getMonth() === C;
|
|
979
|
+
}, v = (C) => {
|
|
980
|
+
if (!e.disabledDate) return !1;
|
|
981
|
+
const w = new Date(e.viewedYear, C, 1), b = new Date(e.viewedYear, C + 1, 0);
|
|
982
|
+
return e.disabledDate(w) && e.disabledDate(b);
|
|
983
|
+
}, V = (C) => [
|
|
984
|
+
l.e("cell"),
|
|
985
|
+
l.is("selected", a(C)),
|
|
986
|
+
l.is("current", y(C)),
|
|
987
|
+
l.is("disabled", v(C))
|
|
988
|
+
], x = (C) => {
|
|
989
|
+
v(C) || t("pick", C);
|
|
990
|
+
}, F = h(() => {
|
|
991
|
+
const C = [];
|
|
992
|
+
for (let w = 0; w < 12; w += 3)
|
|
993
|
+
C.push([w, w + 1, w + 2]);
|
|
994
|
+
return C;
|
|
995
|
+
});
|
|
996
|
+
return (C, w) => (c(), d("table", {
|
|
997
|
+
class: u(s(l).b()),
|
|
998
|
+
cellspacing: "0",
|
|
999
|
+
cellpadding: "0"
|
|
1000
|
+
}, [
|
|
1001
|
+
f("tbody", null, [
|
|
1002
|
+
(c(!0), d(j, null, _(F.value, (b, S) => (c(), d("tr", { key: S }, [
|
|
1003
|
+
(c(!0), d(j, null, _(b, (r) => (c(), d("td", {
|
|
1004
|
+
key: r,
|
|
1005
|
+
class: u(V(r)),
|
|
1006
|
+
onClick: (k) => x(r)
|
|
1007
|
+
}, [
|
|
1008
|
+
f("span", {
|
|
1009
|
+
class: u(s(l).e("cell-text"))
|
|
1010
|
+
}, E(s(tt)[r]), 3)
|
|
1011
|
+
], 10, st))), 128))
|
|
1012
|
+
]))), 128))
|
|
1013
|
+
])
|
|
1014
|
+
], 2));
|
|
1015
|
+
}
|
|
1016
|
+
}), ot = ["onClick"], rt = /* @__PURE__ */ Q({
|
|
1017
|
+
name: "XYearTable",
|
|
1018
|
+
__name: "YearTable",
|
|
1019
|
+
props: {
|
|
1020
|
+
modelValue: { default: null },
|
|
1021
|
+
viewedYear: { default: () => (/* @__PURE__ */ new Date()).getFullYear() },
|
|
1022
|
+
disabledDate: {}
|
|
1023
|
+
},
|
|
1024
|
+
emits: ["pick"],
|
|
1025
|
+
setup(n, { emit: p }) {
|
|
1026
|
+
const e = n, t = p, l = J("year-table"), a = h(() => (/* @__PURE__ */ new Date()).getFullYear()), y = h(() => Pe(e.viewedYear)), v = h(() => {
|
|
1027
|
+
const [r] = y.value, k = [];
|
|
1028
|
+
k.push(r - 1);
|
|
1029
|
+
for (let M = 0; M < 10; M++)
|
|
1030
|
+
k.push(r + M);
|
|
1031
|
+
return k.push(r + 10), k;
|
|
1032
|
+
}), V = h(() => {
|
|
1033
|
+
const r = [];
|
|
1034
|
+
for (let k = 0; k < v.value.length; k += 3)
|
|
1035
|
+
r.push(v.value.slice(k, k + 3));
|
|
1036
|
+
return r;
|
|
1037
|
+
}), x = (r) => e.modelValue ? e.modelValue.getFullYear() === r : !1, F = (r) => r === a.value, C = (r) => {
|
|
1038
|
+
const [k, M] = y.value;
|
|
1039
|
+
return r >= k && r <= M;
|
|
1040
|
+
}, w = (r) => {
|
|
1041
|
+
if (!e.disabledDate) return !1;
|
|
1042
|
+
const k = new Date(r, 0, 1), M = new Date(r, 11, 31);
|
|
1043
|
+
return e.disabledDate(k) && e.disabledDate(M);
|
|
1044
|
+
}, b = (r) => [
|
|
1045
|
+
l.e("cell"),
|
|
1046
|
+
l.is("selected", x(r)),
|
|
1047
|
+
l.is("current", F(r)),
|
|
1048
|
+
l.is("disabled", w(r)),
|
|
1049
|
+
l.is("in-decade", C(r))
|
|
1050
|
+
], S = (r) => {
|
|
1051
|
+
w(r) || t("pick", r);
|
|
1052
|
+
};
|
|
1053
|
+
return (r, k) => (c(), d("table", {
|
|
1054
|
+
class: u(s(l).b()),
|
|
1055
|
+
cellspacing: "0",
|
|
1056
|
+
cellpadding: "0"
|
|
1057
|
+
}, [
|
|
1058
|
+
f("tbody", null, [
|
|
1059
|
+
(c(!0), d(j, null, _(V.value, (M, B) => (c(), d("tr", { key: B }, [
|
|
1060
|
+
(c(!0), d(j, null, _(M, (I) => (c(), d("td", {
|
|
1061
|
+
key: I,
|
|
1062
|
+
class: u(b(I)),
|
|
1063
|
+
onClick: (T) => S(I)
|
|
1064
|
+
}, [
|
|
1065
|
+
f("span", {
|
|
1066
|
+
class: u(s(l).e("cell-text"))
|
|
1067
|
+
}, E(I), 3)
|
|
1068
|
+
], 10, ot))), 128))
|
|
1069
|
+
]))), 128))
|
|
1070
|
+
])
|
|
1071
|
+
], 2));
|
|
1072
|
+
}
|
|
1073
|
+
}), it = ["placeholder", "disabled", "value"], ct = ["placeholder", "disabled", "value"], dt = ["placeholder", "disabled", "value"], vl = /* @__PURE__ */ Q({
|
|
1074
|
+
name: "XDatePicker",
|
|
1075
|
+
__name: "index",
|
|
1076
|
+
props: {
|
|
1077
|
+
modelValue: { default: null },
|
|
1078
|
+
type: { default: "date" },
|
|
1079
|
+
placeholder: { default: "่ฏท้ๆฉๆฅๆ" },
|
|
1080
|
+
startPlaceholder: { default: "ๅผๅงๆฅๆ" },
|
|
1081
|
+
endPlaceholder: { default: "็ปๆๆฅๆ" },
|
|
1082
|
+
disabled: { type: Boolean, default: !1 },
|
|
1083
|
+
readonly: { type: Boolean, default: !1 },
|
|
1084
|
+
clearable: { type: Boolean, default: !1 },
|
|
1085
|
+
size: { default: "default" },
|
|
1086
|
+
format: { default: "YYYY-MM-DD" },
|
|
1087
|
+
valueFormat: { default: "" },
|
|
1088
|
+
disabledDate: {},
|
|
1089
|
+
minDate: {},
|
|
1090
|
+
maxDate: {}
|
|
1091
|
+
},
|
|
1092
|
+
emits: ["update:modelValue", "change", "focus", "blur", "clear"],
|
|
1093
|
+
setup(n, { expose: p, emit: e }) {
|
|
1094
|
+
const t = n, l = e, a = J("date-picker"), y = A(!1), v = A(2e3), V = A(), x = A(), F = A(), C = A({
|
|
1095
|
+
top: "0px",
|
|
1096
|
+
left: "0px"
|
|
1097
|
+
}), w = () => Fe().next(), b = A("date"), S = A(/* @__PURE__ */ new Date()), r = A({
|
|
1098
|
+
selecting: !1,
|
|
1099
|
+
startDate: null,
|
|
1100
|
+
endDate: null
|
|
1101
|
+
}), k = h(() => {
|
|
1102
|
+
if (!t.modelValue) return null;
|
|
1103
|
+
if (t.type === "daterange") {
|
|
1104
|
+
const [N, G] = t.modelValue;
|
|
1105
|
+
return [he(N), he(G)];
|
|
1106
|
+
}
|
|
1107
|
+
return he(t.modelValue);
|
|
1108
|
+
}), M = h(() => !k.value || Array.isArray(k.value) ? "" : re(k.value, t.format)), B = h(() => {
|
|
1109
|
+
if (!Array.isArray(k.value)) return "";
|
|
1110
|
+
const [N] = k.value;
|
|
1111
|
+
return N ? re(N, t.format) : "";
|
|
1112
|
+
}), I = h(() => {
|
|
1113
|
+
if (!Array.isArray(k.value)) return "";
|
|
1114
|
+
const [, N] = k.value;
|
|
1115
|
+
return N ? re(N, t.format) : "";
|
|
1116
|
+
}), T = h(() => Array.isArray(k.value) ? null : k.value), R = h(() => S.value.getFullYear()), H = h(() => S.value.getMonth()), z = h(() => Pe(R.value)), U = h(() => b.value === "year" ? `${z.value[0]} ๅนด - ${z.value[1]} ๅนด` : b.value === "month" ? `${R.value} ๅนด` : `${R.value} ๅนด ${H.value + 1} ๆ`), q = h(() => [
|
|
1117
|
+
a.b(),
|
|
1118
|
+
a.m(t.size),
|
|
1119
|
+
a.is("disabled", t.disabled),
|
|
1120
|
+
a.is("range", t.type === "daterange")
|
|
1121
|
+
]), Z = h(() => [
|
|
1122
|
+
a.e("input"),
|
|
1123
|
+
a.is("focus", y.value),
|
|
1124
|
+
a.is("has-value", !!M.value || !!(B.value || I.value))
|
|
1125
|
+
]), D = () => {
|
|
1126
|
+
t.disabled || t.readonly || (y.value ? g() : $());
|
|
1127
|
+
}, $ = () => {
|
|
1128
|
+
y.value = !0, v.value = w(), we(() => {
|
|
1129
|
+
if (V.value && x.value) {
|
|
1130
|
+
const N = V.value.getBoundingClientRect(), G = x.value.getBoundingClientRect();
|
|
1131
|
+
let se = N.bottom + 8, Ve = N.left;
|
|
1132
|
+
Ve + G.width > window.innerWidth && (Ve = window.innerWidth - G.width - 8), se + G.height > window.innerHeight && (se = N.top - G.height - 8), C.value = {
|
|
1133
|
+
top: `${se}px`,
|
|
1134
|
+
left: `${Ve}px`
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
}), l("focus", {});
|
|
1138
|
+
}, g = () => {
|
|
1139
|
+
y.value = !1, b.value = "date", l("blur", {});
|
|
1140
|
+
}, o = (N) => {
|
|
1141
|
+
if (t.type === "date") {
|
|
1142
|
+
const G = t.valueFormat ? re(N, t.valueFormat) : N;
|
|
1143
|
+
l("update:modelValue", G), l("change", G), g();
|
|
1144
|
+
}
|
|
1145
|
+
}, i = (N) => {
|
|
1146
|
+
if (!r.value.selecting)
|
|
1147
|
+
r.value.selecting = !0, r.value.startDate = N, r.value.endDate = null;
|
|
1148
|
+
else {
|
|
1149
|
+
r.value.selecting = !1, r.value.startDate && N < r.value.startDate ? [r.value.startDate, r.value.endDate] = [N, r.value.startDate] : r.value.endDate = N;
|
|
1150
|
+
const G = t.valueFormat ? re(r.value.startDate, t.valueFormat) : r.value.startDate, se = t.valueFormat ? re(r.value.endDate, t.valueFormat) : r.value.endDate;
|
|
1151
|
+
l("update:modelValue", [G, se]), l("change", [G, se]), g();
|
|
1152
|
+
}
|
|
1153
|
+
}, m = (N) => {
|
|
1154
|
+
if (S.value = new Date(R.value, N, 1), t.type === "month") {
|
|
1155
|
+
const G = new Date(R.value, N, 1), se = t.valueFormat ? re(G, t.valueFormat) : G;
|
|
1156
|
+
l("update:modelValue", se), l("change", se), g();
|
|
1157
|
+
} else
|
|
1158
|
+
b.value = "date";
|
|
1159
|
+
}, O = (N) => {
|
|
1160
|
+
if (S.value = new Date(N, H.value, 1), t.type === "year") {
|
|
1161
|
+
const G = new Date(N, 0, 1), se = t.valueFormat ? re(G, t.valueFormat) : G;
|
|
1162
|
+
l("update:modelValue", se), l("change", se), g();
|
|
1163
|
+
} else
|
|
1164
|
+
b.value = "month";
|
|
1165
|
+
}, ee = () => {
|
|
1166
|
+
S.value = Ze(S.value);
|
|
1167
|
+
}, P = () => {
|
|
1168
|
+
S.value = Qe(S.value);
|
|
1169
|
+
}, te = () => {
|
|
1170
|
+
b.value === "year" ? S.value = new Date(R.value - 10, H.value, 1) : S.value = Je(S.value);
|
|
1171
|
+
}, Y = () => {
|
|
1172
|
+
b.value === "year" ? S.value = new Date(R.value + 10, H.value, 1) : S.value = _e(S.value);
|
|
1173
|
+
}, L = () => {
|
|
1174
|
+
b.value = "month";
|
|
1175
|
+
}, X = () => {
|
|
1176
|
+
b.value = "year";
|
|
1177
|
+
}, W = () => {
|
|
1178
|
+
l("update:modelValue", null), l("change", null), l("clear"), r.value = {
|
|
1179
|
+
selecting: !1,
|
|
1180
|
+
startDate: null,
|
|
1181
|
+
endDate: null
|
|
1182
|
+
};
|
|
1183
|
+
}, ne = (N) => {
|
|
1184
|
+
if (!V.value) return;
|
|
1185
|
+
const G = N.target;
|
|
1186
|
+
V.value.contains(G) || x.value && x.value.contains(G) || g();
|
|
1187
|
+
};
|
|
1188
|
+
ie(
|
|
1189
|
+
() => t.modelValue,
|
|
1190
|
+
(N) => {
|
|
1191
|
+
if (N)
|
|
1192
|
+
if (Array.isArray(k.value)) {
|
|
1193
|
+
const [G] = k.value;
|
|
1194
|
+
G && (S.value = new Date(G));
|
|
1195
|
+
} else k.value && (S.value = new Date(k.value));
|
|
1196
|
+
},
|
|
1197
|
+
{ immediate: !0 }
|
|
1198
|
+
), ie(y, (N) => {
|
|
1199
|
+
N && (b.value = "date", t.type === "daterange" && (r.value = {
|
|
1200
|
+
selecting: !1,
|
|
1201
|
+
startDate: Array.isArray(k.value) ? k.value[0] : null,
|
|
1202
|
+
endDate: Array.isArray(k.value) ? k.value[1] : null
|
|
1203
|
+
}));
|
|
1204
|
+
});
|
|
1205
|
+
const oe = (N) => {
|
|
1206
|
+
N.key === "Escape" && g();
|
|
1207
|
+
};
|
|
1208
|
+
return ge(() => {
|
|
1209
|
+
document.addEventListener("click", ne), document.addEventListener("keydown", oe);
|
|
1210
|
+
}), be(() => {
|
|
1211
|
+
document.removeEventListener("click", ne), document.removeEventListener("keydown", oe);
|
|
1212
|
+
}), p({
|
|
1213
|
+
focus: () => {
|
|
1214
|
+
var N;
|
|
1215
|
+
return (N = F.value) == null ? void 0 : N.focus();
|
|
1216
|
+
},
|
|
1217
|
+
blur: () => {
|
|
1218
|
+
var N;
|
|
1219
|
+
return (N = F.value) == null ? void 0 : N.blur();
|
|
1220
|
+
}
|
|
1221
|
+
}), (N, G) => (c(), d("div", {
|
|
1222
|
+
ref_key: "pickerRef",
|
|
1223
|
+
ref: V,
|
|
1224
|
+
class: u(q.value)
|
|
1225
|
+
}, [
|
|
1226
|
+
n.type !== "daterange" ? (c(), d("div", {
|
|
1227
|
+
key: 0,
|
|
1228
|
+
class: u(Z.value),
|
|
1229
|
+
onClick: D
|
|
1230
|
+
}, [
|
|
1231
|
+
f("input", {
|
|
1232
|
+
ref_key: "inputRef",
|
|
1233
|
+
ref: F,
|
|
1234
|
+
type: "text",
|
|
1235
|
+
placeholder: n.placeholder,
|
|
1236
|
+
disabled: n.disabled,
|
|
1237
|
+
readonly: !0,
|
|
1238
|
+
value: M.value,
|
|
1239
|
+
class: u(s(a).e("input-inner"))
|
|
1240
|
+
}, null, 10, it),
|
|
1241
|
+
f("span", {
|
|
1242
|
+
class: u(s(a).e("suffix"))
|
|
1243
|
+
}, [
|
|
1244
|
+
n.clearable && M.value && !n.disabled ? (c(), d("span", {
|
|
1245
|
+
key: 0,
|
|
1246
|
+
class: u(s(a).e("clear")),
|
|
1247
|
+
onClick: ue(W, ["stop"])
|
|
1248
|
+
}, " โ ", 2)) : (c(), d("span", {
|
|
1249
|
+
key: 1,
|
|
1250
|
+
class: u(s(a).e("icon"))
|
|
1251
|
+
}, "๐
", 2))
|
|
1252
|
+
], 2)
|
|
1253
|
+
], 2)) : (c(), d("div", {
|
|
1254
|
+
key: 1,
|
|
1255
|
+
class: u(Z.value),
|
|
1256
|
+
onClick: D
|
|
1257
|
+
}, [
|
|
1258
|
+
f("input", {
|
|
1259
|
+
type: "text",
|
|
1260
|
+
placeholder: n.startPlaceholder,
|
|
1261
|
+
disabled: n.disabled,
|
|
1262
|
+
readonly: !0,
|
|
1263
|
+
value: B.value,
|
|
1264
|
+
class: u(s(a).e("input-inner"))
|
|
1265
|
+
}, null, 10, ct),
|
|
1266
|
+
f("span", {
|
|
1267
|
+
class: u(s(a).e("separator"))
|
|
1268
|
+
}, "่ณ", 2),
|
|
1269
|
+
f("input", {
|
|
1270
|
+
type: "text",
|
|
1271
|
+
placeholder: n.endPlaceholder,
|
|
1272
|
+
disabled: n.disabled,
|
|
1273
|
+
readonly: !0,
|
|
1274
|
+
value: I.value,
|
|
1275
|
+
class: u(s(a).e("input-inner"))
|
|
1276
|
+
}, null, 10, dt),
|
|
1277
|
+
f("span", {
|
|
1278
|
+
class: u(s(a).e("suffix"))
|
|
1279
|
+
}, [
|
|
1280
|
+
n.clearable && (B.value || I.value) && !n.disabled ? (c(), d("span", {
|
|
1281
|
+
key: 0,
|
|
1282
|
+
class: u(s(a).e("clear")),
|
|
1283
|
+
onClick: ue(W, ["stop"])
|
|
1284
|
+
}, " โ ", 2)) : (c(), d("span", {
|
|
1285
|
+
key: 1,
|
|
1286
|
+
class: u(s(a).e("icon"))
|
|
1287
|
+
}, "๐
", 2))
|
|
1288
|
+
], 2)
|
|
1289
|
+
], 2)),
|
|
1290
|
+
(c(), pe(Me, { to: "body" }, [
|
|
1291
|
+
ye(Te, { name: "fade" }, {
|
|
1292
|
+
default: Re(() => [
|
|
1293
|
+
de(f("div", {
|
|
1294
|
+
ref_key: "popperRef",
|
|
1295
|
+
ref: x,
|
|
1296
|
+
class: u(s(a).e("popper")),
|
|
1297
|
+
style: ae({ zIndex: v.value, ...C.value })
|
|
1298
|
+
}, [
|
|
1299
|
+
f("div", {
|
|
1300
|
+
class: u(s(a).e("header"))
|
|
1301
|
+
}, [
|
|
1302
|
+
f("button", {
|
|
1303
|
+
type: "button",
|
|
1304
|
+
class: u(s(a).e("prev-btn")),
|
|
1305
|
+
onClick: G[0] || (G[0] = (se) => b.value === "date" ? ee() : te())
|
|
1306
|
+
}, " โน ", 2),
|
|
1307
|
+
f("div", {
|
|
1308
|
+
class: u(s(a).e("header-title"))
|
|
1309
|
+
}, [
|
|
1310
|
+
b.value === "year" ? (c(), d("span", {
|
|
1311
|
+
key: 0,
|
|
1312
|
+
onClick: G[1] || (G[1] = (se) => b.value = "month")
|
|
1313
|
+
}, E(U.value), 1)) : (c(), d(j, { key: 1 }, [
|
|
1314
|
+
f("span", { onClick: X }, E(R.value) + " ๅนด", 1),
|
|
1315
|
+
b.value === "date" ? (c(), d("span", {
|
|
1316
|
+
key: 0,
|
|
1317
|
+
onClick: L
|
|
1318
|
+
}, E(H.value + 1) + " ๆ", 1)) : K("", !0)
|
|
1319
|
+
], 64))
|
|
1320
|
+
], 2),
|
|
1321
|
+
f("button", {
|
|
1322
|
+
type: "button",
|
|
1323
|
+
class: u(s(a).e("next-btn")),
|
|
1324
|
+
onClick: G[2] || (G[2] = (se) => b.value === "date" ? P() : Y())
|
|
1325
|
+
}, " โบ ", 2)
|
|
1326
|
+
], 2),
|
|
1327
|
+
f("div", {
|
|
1328
|
+
class: u(s(a).e("content"))
|
|
1329
|
+
}, [
|
|
1330
|
+
b.value === "date" ? (c(), pe(nt, {
|
|
1331
|
+
key: 0,
|
|
1332
|
+
"model-value": T.value,
|
|
1333
|
+
"viewed-month": S.value,
|
|
1334
|
+
"disabled-date": n.disabledDate,
|
|
1335
|
+
"min-date": n.minDate ? s(he)(n.minDate) : null,
|
|
1336
|
+
"max-date": n.maxDate ? s(he)(n.maxDate) : null,
|
|
1337
|
+
"selection-mode": n.type === "daterange" ? "range" : "single",
|
|
1338
|
+
"range-state": r.value,
|
|
1339
|
+
onPick: o,
|
|
1340
|
+
onRangeSelect: i
|
|
1341
|
+
}, null, 8, ["model-value", "viewed-month", "disabled-date", "min-date", "max-date", "selection-mode", "range-state"])) : b.value === "month" ? (c(), pe(ut, {
|
|
1342
|
+
key: 1,
|
|
1343
|
+
"model-value": T.value,
|
|
1344
|
+
"viewed-year": R.value,
|
|
1345
|
+
"disabled-date": n.disabledDate,
|
|
1346
|
+
onPick: m
|
|
1347
|
+
}, null, 8, ["model-value", "viewed-year", "disabled-date"])) : b.value === "year" ? (c(), pe(rt, {
|
|
1348
|
+
key: 2,
|
|
1349
|
+
"model-value": T.value,
|
|
1350
|
+
"viewed-year": R.value,
|
|
1351
|
+
"disabled-date": n.disabledDate,
|
|
1352
|
+
onPick: O
|
|
1353
|
+
}, null, 8, ["model-value", "viewed-year", "disabled-date"])) : K("", !0)
|
|
1354
|
+
], 2)
|
|
1355
|
+
], 6), [
|
|
1356
|
+
[Be, y.value]
|
|
1357
|
+
])
|
|
1358
|
+
]),
|
|
1359
|
+
_: 1
|
|
1360
|
+
})
|
|
1361
|
+
]))
|
|
1362
|
+
], 2));
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
function fe(n, p = "HH:mm:ss") {
|
|
1366
|
+
if (!n) return "";
|
|
1367
|
+
const e = n.getHours(), t = n.getMinutes(), l = n.getSeconds();
|
|
1368
|
+
return p.replace(/HH/g, String(e).padStart(2, "0")).replace(/H/g, String(e)).replace(/mm/g, String(t).padStart(2, "0")).replace(/m/g, String(t)).replace(/ss/g, String(l).padStart(2, "0")).replace(/s/g, String(l));
|
|
1369
|
+
}
|
|
1370
|
+
function De(n) {
|
|
1371
|
+
if (!n) return null;
|
|
1372
|
+
if (n instanceof Date)
|
|
1373
|
+
return isNaN(n.getTime()) ? null : n;
|
|
1374
|
+
if (typeof n == "number") {
|
|
1375
|
+
const t = /* @__PURE__ */ new Date();
|
|
1376
|
+
return t.setTime(n), t;
|
|
1377
|
+
}
|
|
1378
|
+
const p = n.match(/^(\d{1,2}):(\d{1,2})(?::(\d{1,2}))?/);
|
|
1379
|
+
if (p) {
|
|
1380
|
+
const t = /* @__PURE__ */ new Date();
|
|
1381
|
+
return t.setHours(parseInt(p[1]), parseInt(p[2]), p[3] ? parseInt(p[3]) : 0, 0), t;
|
|
1382
|
+
}
|
|
1383
|
+
const e = new Date(n);
|
|
1384
|
+
return isNaN(e.getTime()) ? null : e;
|
|
1385
|
+
}
|
|
1386
|
+
function me(n) {
|
|
1387
|
+
return String(n).padStart(2, "0");
|
|
1388
|
+
}
|
|
1389
|
+
const vt = ["onClick"], ft = ["onClick"], mt = ["onClick"], pt = /* @__PURE__ */ Q({
|
|
1390
|
+
name: "XTimePanel",
|
|
1391
|
+
__name: "TimePanel",
|
|
1392
|
+
props: {
|
|
1393
|
+
modelValue: { default: null },
|
|
1394
|
+
format: { default: "HH:mm:ss" },
|
|
1395
|
+
disabledHours: {},
|
|
1396
|
+
disabledMinutes: {},
|
|
1397
|
+
disabledSeconds: {},
|
|
1398
|
+
hourStep: { default: 1 },
|
|
1399
|
+
minuteStep: { default: 1 },
|
|
1400
|
+
secondStep: { default: 1 }
|
|
1401
|
+
},
|
|
1402
|
+
emits: ["confirm", "cancel"],
|
|
1403
|
+
setup(n, { emit: p }) {
|
|
1404
|
+
const e = n, t = p, l = J("time-panel"), a = A(0), y = A(0), v = A(0), V = A(), x = A(), F = A(), C = h(() => e.format.includes("ss") || e.format.includes("s")), w = h(() => {
|
|
1405
|
+
const P = [], te = Math.max(1, e.hourStep);
|
|
1406
|
+
for (let Y = 0; Y < 24; Y += te)
|
|
1407
|
+
P.push(Y);
|
|
1408
|
+
return P;
|
|
1409
|
+
}), b = h(() => {
|
|
1410
|
+
const P = [], te = Math.max(1, e.minuteStep);
|
|
1411
|
+
for (let Y = 0; Y < 60; Y += te)
|
|
1412
|
+
P.push(Y);
|
|
1413
|
+
return P;
|
|
1414
|
+
}), S = h(() => {
|
|
1415
|
+
const P = [], te = Math.max(1, e.secondStep);
|
|
1416
|
+
for (let Y = 0; Y < 60; Y += te)
|
|
1417
|
+
P.push(Y);
|
|
1418
|
+
return P;
|
|
1419
|
+
}), r = h(() => e.disabledHours ? new Set(e.disabledHours()) : /* @__PURE__ */ new Set()), k = h(() => e.disabledMinutes ? new Set(e.disabledMinutes(a.value)) : /* @__PURE__ */ new Set()), M = h(() => e.disabledSeconds ? new Set(e.disabledSeconds(a.value, y.value)) : /* @__PURE__ */ new Set()), B = h(() => `${me(a.value)}:${me(y.value)}${C.value ? ":" + me(v.value) : ""}`), I = (P) => r.value.has(P), T = (P) => k.value.has(P), R = (P) => M.value.has(P), H = (P) => {
|
|
1420
|
+
I(P) || (a.value = P, $(V.value, q(P)));
|
|
1421
|
+
}, z = (P) => {
|
|
1422
|
+
T(P) || (y.value = P, $(x.value, Z(P)));
|
|
1423
|
+
}, U = (P) => {
|
|
1424
|
+
R(P) || (v.value = P, $(F.value, D(P)));
|
|
1425
|
+
}, q = (P) => w.value.indexOf(P), Z = (P) => b.value.indexOf(P), D = (P) => S.value.indexOf(P), $ = (P, te) => {
|
|
1426
|
+
if (!P) return;
|
|
1427
|
+
const Y = 32, X = te * Y + 84 - 200 / 2 + Y / 2;
|
|
1428
|
+
P.scrollTop = Math.max(0, X);
|
|
1429
|
+
}, g = () => {
|
|
1430
|
+
if (!V.value) return;
|
|
1431
|
+
const P = V.value.scrollTop, te = Math.round((P - 84 + 100) / 32), Y = w.value[Math.max(0, Math.min(te, w.value.length - 1))];
|
|
1432
|
+
Y !== void 0 && !I(Y) && (a.value = Y);
|
|
1433
|
+
}, o = () => {
|
|
1434
|
+
if (!x.value) return;
|
|
1435
|
+
const P = x.value.scrollTop, te = Math.round((P - 84 + 100) / 32), Y = b.value[Math.max(0, Math.min(te, b.value.length - 1))];
|
|
1436
|
+
Y !== void 0 && !T(Y) && (y.value = Y);
|
|
1437
|
+
}, i = () => {
|
|
1438
|
+
if (!F.value) return;
|
|
1439
|
+
const P = F.value.scrollTop, te = Math.round((P - 84 + 100) / 32), Y = S.value[Math.max(0, Math.min(te, S.value.length - 1))];
|
|
1440
|
+
Y !== void 0 && !R(Y) && (v.value = Y);
|
|
1441
|
+
}, m = () => {
|
|
1442
|
+
const P = e.modelValue ? new Date(e.modelValue) : /* @__PURE__ */ new Date();
|
|
1443
|
+
P.setHours(a.value, y.value, v.value, 0), t("confirm", P);
|
|
1444
|
+
}, O = () => {
|
|
1445
|
+
t("cancel");
|
|
1446
|
+
}, ee = () => {
|
|
1447
|
+
if (e.modelValue)
|
|
1448
|
+
a.value = e.modelValue.getHours(), y.value = e.modelValue.getMinutes(), v.value = e.modelValue.getSeconds();
|
|
1449
|
+
else {
|
|
1450
|
+
const P = /* @__PURE__ */ new Date();
|
|
1451
|
+
a.value = P.getHours(), y.value = P.getMinutes(), v.value = P.getSeconds();
|
|
1452
|
+
}
|
|
1453
|
+
we(() => {
|
|
1454
|
+
$(V.value, q(a.value)), $(x.value, Z(y.value)), C.value && $(F.value, D(v.value));
|
|
1455
|
+
});
|
|
1456
|
+
};
|
|
1457
|
+
return ie(
|
|
1458
|
+
() => e.modelValue,
|
|
1459
|
+
() => {
|
|
1460
|
+
ee();
|
|
1461
|
+
},
|
|
1462
|
+
{ immediate: !0 }
|
|
1463
|
+
), ge(() => {
|
|
1464
|
+
ee();
|
|
1465
|
+
}), (P, te) => (c(), d("div", {
|
|
1466
|
+
class: u(s(l).b())
|
|
1467
|
+
}, [
|
|
1468
|
+
f("div", {
|
|
1469
|
+
class: u(s(l).e("content"))
|
|
1470
|
+
}, [
|
|
1471
|
+
f("div", {
|
|
1472
|
+
class: u(s(l).e("indicator"))
|
|
1473
|
+
}, null, 2),
|
|
1474
|
+
f("div", {
|
|
1475
|
+
ref_key: "hourListRef",
|
|
1476
|
+
ref: V,
|
|
1477
|
+
class: u(s(l).e("list")),
|
|
1478
|
+
onScroll: g
|
|
1479
|
+
}, [
|
|
1480
|
+
f("div", {
|
|
1481
|
+
class: u(s(l).e("padding"))
|
|
1482
|
+
}, null, 2),
|
|
1483
|
+
(c(!0), d(j, null, _(w.value, (Y) => (c(), d("div", {
|
|
1484
|
+
key: Y,
|
|
1485
|
+
class: u([s(l).e("item"), s(l).is("selected", a.value === Y), s(l).is("disabled", I(Y))]),
|
|
1486
|
+
onClick: (L) => H(Y)
|
|
1487
|
+
}, E(s(me)(Y)), 11, vt))), 128)),
|
|
1488
|
+
f("div", {
|
|
1489
|
+
class: u(s(l).e("padding"))
|
|
1490
|
+
}, null, 2)
|
|
1491
|
+
], 34),
|
|
1492
|
+
f("div", {
|
|
1493
|
+
ref_key: "minuteListRef",
|
|
1494
|
+
ref: x,
|
|
1495
|
+
class: u(s(l).e("list")),
|
|
1496
|
+
onScroll: o
|
|
1497
|
+
}, [
|
|
1498
|
+
f("div", {
|
|
1499
|
+
class: u(s(l).e("padding"))
|
|
1500
|
+
}, null, 2),
|
|
1501
|
+
(c(!0), d(j, null, _(b.value, (Y) => (c(), d("div", {
|
|
1502
|
+
key: Y,
|
|
1503
|
+
class: u([s(l).e("item"), s(l).is("selected", y.value === Y), s(l).is("disabled", T(Y))]),
|
|
1504
|
+
onClick: (L) => z(Y)
|
|
1505
|
+
}, E(s(me)(Y)), 11, ft))), 128)),
|
|
1506
|
+
f("div", {
|
|
1507
|
+
class: u(s(l).e("padding"))
|
|
1508
|
+
}, null, 2)
|
|
1509
|
+
], 34),
|
|
1510
|
+
C.value ? (c(), d("div", {
|
|
1511
|
+
key: 0,
|
|
1512
|
+
ref_key: "secondListRef",
|
|
1513
|
+
ref: F,
|
|
1514
|
+
class: u(s(l).e("list")),
|
|
1515
|
+
onScroll: i
|
|
1516
|
+
}, [
|
|
1517
|
+
f("div", {
|
|
1518
|
+
class: u(s(l).e("padding"))
|
|
1519
|
+
}, null, 2),
|
|
1520
|
+
(c(!0), d(j, null, _(S.value, (Y) => (c(), d("div", {
|
|
1521
|
+
key: Y,
|
|
1522
|
+
class: u([s(l).e("item"), s(l).is("selected", v.value === Y), s(l).is("disabled", R(Y))]),
|
|
1523
|
+
onClick: (L) => U(Y)
|
|
1524
|
+
}, E(s(me)(Y)), 11, mt))), 128)),
|
|
1525
|
+
f("div", {
|
|
1526
|
+
class: u(s(l).e("padding"))
|
|
1527
|
+
}, null, 2)
|
|
1528
|
+
], 34)) : K("", !0)
|
|
1529
|
+
], 2),
|
|
1530
|
+
f("div", {
|
|
1531
|
+
class: u(s(l).e("footer"))
|
|
1532
|
+
}, [
|
|
1533
|
+
f("span", {
|
|
1534
|
+
class: u(s(l).e("current-time"))
|
|
1535
|
+
}, E(B.value), 3),
|
|
1536
|
+
f("div", {
|
|
1537
|
+
class: u(s(l).e("actions"))
|
|
1538
|
+
}, [
|
|
1539
|
+
f("button", {
|
|
1540
|
+
class: u(s(l).e("btn-cancel")),
|
|
1541
|
+
onClick: O
|
|
1542
|
+
}, "ๅๆถ", 2),
|
|
1543
|
+
f("button", {
|
|
1544
|
+
class: u(s(l).e("btn-confirm")),
|
|
1545
|
+
onClick: m
|
|
1546
|
+
}, "็กฎๅฎ", 2)
|
|
1547
|
+
], 2)
|
|
1548
|
+
], 2)
|
|
1549
|
+
], 2));
|
|
1550
|
+
}
|
|
1551
|
+
}), ht = ["placeholder", "disabled", "value"], gt = ["placeholder", "disabled", "value"], bt = ["placeholder", "disabled", "value"], fl = /* @__PURE__ */ Q({
|
|
1552
|
+
name: "XTimePicker",
|
|
1553
|
+
__name: "index",
|
|
1554
|
+
props: {
|
|
1555
|
+
modelValue: { default: null },
|
|
1556
|
+
type: { default: "time" },
|
|
1557
|
+
placeholder: { default: "่ฏท้ๆฉๆถ้ด" },
|
|
1558
|
+
startPlaceholder: { default: "ๅผๅงๆถ้ด" },
|
|
1559
|
+
endPlaceholder: { default: "็ปๆๆถ้ด" },
|
|
1560
|
+
disabled: { type: Boolean, default: !1 },
|
|
1561
|
+
readonly: { type: Boolean, default: !1 },
|
|
1562
|
+
clearable: { type: Boolean, default: !1 },
|
|
1563
|
+
size: { default: "default" },
|
|
1564
|
+
format: { default: "HH:mm:ss" },
|
|
1565
|
+
valueFormat: { default: "" },
|
|
1566
|
+
disabledHours: {},
|
|
1567
|
+
disabledMinutes: {},
|
|
1568
|
+
disabledSeconds: {},
|
|
1569
|
+
hourStep: { default: 1 },
|
|
1570
|
+
minuteStep: { default: 1 },
|
|
1571
|
+
secondStep: { default: 1 }
|
|
1572
|
+
},
|
|
1573
|
+
emits: ["update:modelValue", "change", "focus", "blur", "clear"],
|
|
1574
|
+
setup(n, { expose: p, emit: e }) {
|
|
1575
|
+
const t = n, l = e, a = J("time-picker"), y = () => Fe().next(), v = A(!1), V = A(2e3), x = A(), F = A(), C = A(), w = A({
|
|
1576
|
+
top: "0px",
|
|
1577
|
+
left: "0px"
|
|
1578
|
+
}), b = A({
|
|
1579
|
+
startTime: null,
|
|
1580
|
+
endTime: null
|
|
1581
|
+
}), S = A("start"), r = h(() => {
|
|
1582
|
+
if (!t.modelValue) return null;
|
|
1583
|
+
if (t.type === "timerange") {
|
|
1584
|
+
const [i, m] = t.modelValue;
|
|
1585
|
+
return [De(i), De(m)];
|
|
1586
|
+
}
|
|
1587
|
+
return De(t.modelValue);
|
|
1588
|
+
}), k = h(() => !r.value || Array.isArray(r.value) ? "" : fe(r.value, t.format)), M = h(() => {
|
|
1589
|
+
if (!Array.isArray(r.value)) return "";
|
|
1590
|
+
const [i] = r.value;
|
|
1591
|
+
return i ? fe(i, t.format) : "";
|
|
1592
|
+
}), B = h(() => {
|
|
1593
|
+
if (!Array.isArray(r.value)) return "";
|
|
1594
|
+
const [, i] = r.value;
|
|
1595
|
+
return i ? fe(i, t.format) : "";
|
|
1596
|
+
}), I = h(() => t.type === "timerange" ? S.value === "start" ? b.value.startTime : b.value.endTime || b.value.startTime : r.value), T = h(() => [
|
|
1597
|
+
a.b(),
|
|
1598
|
+
a.m(t.size),
|
|
1599
|
+
a.is("disabled", t.disabled),
|
|
1600
|
+
a.is("range", t.type === "timerange")
|
|
1601
|
+
]), R = h(() => [
|
|
1602
|
+
a.e("input"),
|
|
1603
|
+
a.is("focus", v.value)
|
|
1604
|
+
]), H = () => {
|
|
1605
|
+
t.disabled || t.readonly || (v.value ? q() : U());
|
|
1606
|
+
}, z = (i) => {
|
|
1607
|
+
t.disabled || t.readonly || (S.value = i, v.value || U());
|
|
1608
|
+
}, U = () => {
|
|
1609
|
+
v.value = !0, V.value = y(), we(() => {
|
|
1610
|
+
if (x.value && F.value) {
|
|
1611
|
+
const i = x.value.getBoundingClientRect(), m = F.value.getBoundingClientRect();
|
|
1612
|
+
let O = i.bottom + 8, ee = i.left;
|
|
1613
|
+
ee + m.width > window.innerWidth && (ee = window.innerWidth - m.width - 8), O + m.height > window.innerHeight && (O = i.top - m.height - 8), w.value = {
|
|
1614
|
+
top: `${O}px`,
|
|
1615
|
+
left: `${ee}px`
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
}), l("focus", {});
|
|
1619
|
+
}, q = () => {
|
|
1620
|
+
v.value = !1, l("blur", {});
|
|
1621
|
+
}, Z = (i) => {
|
|
1622
|
+
if (t.type === "timerange")
|
|
1623
|
+
if (S.value === "start")
|
|
1624
|
+
b.value.startTime = i, S.value = "end", b.value.endTime && b.value.endTime < i && (b.value.endTime = null);
|
|
1625
|
+
else {
|
|
1626
|
+
b.value.startTime && i < b.value.startTime ? (b.value.endTime = b.value.startTime, b.value.startTime = i) : b.value.endTime = i;
|
|
1627
|
+
const m = t.valueFormat ? fe(b.value.startTime, t.valueFormat) : b.value.startTime, O = t.valueFormat ? fe(b.value.endTime, t.valueFormat) : b.value.endTime;
|
|
1628
|
+
l("update:modelValue", [m, O]), l("change", [m, O]), q();
|
|
1629
|
+
}
|
|
1630
|
+
else {
|
|
1631
|
+
const m = t.valueFormat ? fe(i, t.valueFormat) : i;
|
|
1632
|
+
l("update:modelValue", m), l("change", m), q();
|
|
1633
|
+
}
|
|
1634
|
+
}, D = () => {
|
|
1635
|
+
q();
|
|
1636
|
+
}, $ = () => {
|
|
1637
|
+
l("update:modelValue", null), l("change", null), l("clear"), b.value = {
|
|
1638
|
+
startTime: null,
|
|
1639
|
+
endTime: null
|
|
1640
|
+
};
|
|
1641
|
+
}, g = (i) => {
|
|
1642
|
+
if (!x.value) return;
|
|
1643
|
+
const m = i.target;
|
|
1644
|
+
x.value.contains(m) || F.value && F.value.contains(m) || q();
|
|
1645
|
+
};
|
|
1646
|
+
ie(
|
|
1647
|
+
() => t.modelValue,
|
|
1648
|
+
(i) => {
|
|
1649
|
+
if (i && t.type === "timerange") {
|
|
1650
|
+
const [m, O] = r.value;
|
|
1651
|
+
b.value = {
|
|
1652
|
+
startTime: m,
|
|
1653
|
+
endTime: O
|
|
1654
|
+
};
|
|
1655
|
+
}
|
|
1656
|
+
},
|
|
1657
|
+
{ immediate: !0 }
|
|
1658
|
+
), ie(v, (i) => {
|
|
1659
|
+
i && t.type === "timerange" && (b.value = {
|
|
1660
|
+
startTime: Array.isArray(r.value) ? r.value[0] : null,
|
|
1661
|
+
endTime: Array.isArray(r.value) ? r.value[1] : null
|
|
1662
|
+
}, S.value = "start");
|
|
1663
|
+
});
|
|
1664
|
+
const o = (i) => {
|
|
1665
|
+
i.key === "Escape" && q();
|
|
1666
|
+
};
|
|
1667
|
+
return ge(() => {
|
|
1668
|
+
document.addEventListener("click", g), document.addEventListener("keydown", o);
|
|
1669
|
+
}), be(() => {
|
|
1670
|
+
document.removeEventListener("click", g), document.removeEventListener("keydown", o);
|
|
1671
|
+
}), p({
|
|
1672
|
+
focus: () => {
|
|
1673
|
+
var i;
|
|
1674
|
+
return (i = C.value) == null ? void 0 : i.focus();
|
|
1675
|
+
},
|
|
1676
|
+
blur: () => {
|
|
1677
|
+
var i;
|
|
1678
|
+
return (i = C.value) == null ? void 0 : i.blur();
|
|
1679
|
+
}
|
|
1680
|
+
}), (i, m) => (c(), d("div", {
|
|
1681
|
+
ref_key: "pickerRef",
|
|
1682
|
+
ref: x,
|
|
1683
|
+
class: u(T.value)
|
|
1684
|
+
}, [
|
|
1685
|
+
n.type !== "timerange" ? (c(), d("div", {
|
|
1686
|
+
key: 0,
|
|
1687
|
+
class: u(R.value),
|
|
1688
|
+
onClick: H
|
|
1689
|
+
}, [
|
|
1690
|
+
f("input", {
|
|
1691
|
+
ref_key: "inputRef",
|
|
1692
|
+
ref: C,
|
|
1693
|
+
type: "text",
|
|
1694
|
+
placeholder: n.placeholder,
|
|
1695
|
+
disabled: n.disabled,
|
|
1696
|
+
readonly: !0,
|
|
1697
|
+
value: k.value,
|
|
1698
|
+
class: u(s(a).e("input-inner"))
|
|
1699
|
+
}, null, 10, ht),
|
|
1700
|
+
f("span", {
|
|
1701
|
+
class: u(s(a).e("suffix"))
|
|
1702
|
+
}, [
|
|
1703
|
+
n.clearable && k.value && !n.disabled ? (c(), d("span", {
|
|
1704
|
+
key: 0,
|
|
1705
|
+
class: u(s(a).e("clear")),
|
|
1706
|
+
onClick: ue($, ["stop"])
|
|
1707
|
+
}, " โ ", 2)) : (c(), d("span", {
|
|
1708
|
+
key: 1,
|
|
1709
|
+
class: u(s(a).e("icon"))
|
|
1710
|
+
}, "๐", 2))
|
|
1711
|
+
], 2)
|
|
1712
|
+
], 2)) : (c(), d("div", {
|
|
1713
|
+
key: 1,
|
|
1714
|
+
class: u(R.value),
|
|
1715
|
+
onClick: H
|
|
1716
|
+
}, [
|
|
1717
|
+
f("input", {
|
|
1718
|
+
type: "text",
|
|
1719
|
+
placeholder: n.startPlaceholder,
|
|
1720
|
+
disabled: n.disabled,
|
|
1721
|
+
readonly: !0,
|
|
1722
|
+
value: M.value,
|
|
1723
|
+
class: u([s(a).e("input-inner"), s(a).is("active", S.value === "start")]),
|
|
1724
|
+
onClick: m[0] || (m[0] = ue((O) => z("start"), ["stop"]))
|
|
1725
|
+
}, null, 10, gt),
|
|
1726
|
+
f("span", {
|
|
1727
|
+
class: u(s(a).e("separator"))
|
|
1728
|
+
}, "่ณ", 2),
|
|
1729
|
+
f("input", {
|
|
1730
|
+
type: "text",
|
|
1731
|
+
placeholder: n.endPlaceholder,
|
|
1732
|
+
disabled: n.disabled,
|
|
1733
|
+
readonly: !0,
|
|
1734
|
+
value: B.value,
|
|
1735
|
+
class: u([s(a).e("input-inner"), s(a).is("active", S.value === "end")]),
|
|
1736
|
+
onClick: m[1] || (m[1] = ue((O) => z("end"), ["stop"]))
|
|
1737
|
+
}, null, 10, bt),
|
|
1738
|
+
f("span", {
|
|
1739
|
+
class: u(s(a).e("suffix"))
|
|
1740
|
+
}, [
|
|
1741
|
+
n.clearable && (M.value || B.value) && !n.disabled ? (c(), d("span", {
|
|
1742
|
+
key: 0,
|
|
1743
|
+
class: u(s(a).e("clear")),
|
|
1744
|
+
onClick: ue($, ["stop"])
|
|
1745
|
+
}, " โ ", 2)) : (c(), d("span", {
|
|
1746
|
+
key: 1,
|
|
1747
|
+
class: u(s(a).e("icon"))
|
|
1748
|
+
}, "๐", 2))
|
|
1749
|
+
], 2)
|
|
1750
|
+
], 2)),
|
|
1751
|
+
(c(), pe(Me, { to: "body" }, [
|
|
1752
|
+
ye(Te, { name: "fade" }, {
|
|
1753
|
+
default: Re(() => [
|
|
1754
|
+
de(f("div", {
|
|
1755
|
+
ref_key: "popperRef",
|
|
1756
|
+
ref: F,
|
|
1757
|
+
class: u(s(a).e("popper")),
|
|
1758
|
+
style: ae({ zIndex: V.value, ...w.value })
|
|
1759
|
+
}, [
|
|
1760
|
+
n.type === "timerange" ? (c(), d("div", {
|
|
1761
|
+
key: 0,
|
|
1762
|
+
class: u(s(a).e("popper-header"))
|
|
1763
|
+
}, E(S.value === "start" ? "่ฏท้ๆฉๅผๅงๆถ้ด" : "่ฏท้ๆฉ็ปๆๆถ้ด"), 3)) : K("", !0),
|
|
1764
|
+
ye(pt, {
|
|
1765
|
+
"model-value": I.value,
|
|
1766
|
+
format: n.format,
|
|
1767
|
+
"disabled-hours": n.disabledHours,
|
|
1768
|
+
"disabled-minutes": n.disabledMinutes,
|
|
1769
|
+
"disabled-seconds": n.disabledSeconds,
|
|
1770
|
+
"hour-step": n.hourStep,
|
|
1771
|
+
"minute-step": n.minuteStep,
|
|
1772
|
+
"second-step": n.secondStep,
|
|
1773
|
+
onConfirm: Z,
|
|
1774
|
+
onCancel: D
|
|
1775
|
+
}, null, 8, ["model-value", "format", "disabled-hours", "disabled-minutes", "disabled-seconds", "hour-step", "minute-step", "second-step"])
|
|
1776
|
+
], 6), [
|
|
1777
|
+
[Be, v.value]
|
|
1778
|
+
])
|
|
1779
|
+
]),
|
|
1780
|
+
_: 1
|
|
1781
|
+
})
|
|
1782
|
+
]))
|
|
1783
|
+
], 2));
|
|
1784
|
+
}
|
|
1785
|
+
});
|
|
1786
|
+
function yt(n, p, e) {
|
|
1787
|
+
return e ? e(p, n) : n.toLowerCase().includes(p.toLowerCase());
|
|
1788
|
+
}
|
|
1789
|
+
function Ae(n, p, e = "value", t = "children") {
|
|
1790
|
+
for (const l of n) {
|
|
1791
|
+
if (l[e] === p)
|
|
1792
|
+
return l;
|
|
1793
|
+
if (l[t] && l[t].length > 0) {
|
|
1794
|
+
const a = Ae(l[t], p, e, t);
|
|
1795
|
+
if (a) return a;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
return null;
|
|
1799
|
+
}
|
|
1800
|
+
function Se(n, p, e = "value", t = "children") {
|
|
1801
|
+
const l = [];
|
|
1802
|
+
function a(y) {
|
|
1803
|
+
for (const v of y) {
|
|
1804
|
+
if (v[e] === p)
|
|
1805
|
+
return l.push(v), !0;
|
|
1806
|
+
if (v[t] && v[t].length > 0) {
|
|
1807
|
+
if (l.push(v), a(v[t]))
|
|
1808
|
+
return !0;
|
|
1809
|
+
l.pop();
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
return !1;
|
|
1813
|
+
}
|
|
1814
|
+
return a(n), l;
|
|
1815
|
+
}
|
|
1816
|
+
function kt(n, p = "children") {
|
|
1817
|
+
const e = [];
|
|
1818
|
+
function t(l, a = 0, y = null) {
|
|
1819
|
+
for (const v of l)
|
|
1820
|
+
e.push({ ...v, level: a, parent: y }), v[p] && v[p].length > 0 && t(v[p], a + 1, v);
|
|
1821
|
+
}
|
|
1822
|
+
return t(n), e;
|
|
1823
|
+
}
|
|
1824
|
+
const xt = ["onClick"], wt = ["placeholder", "disabled", "readonly", "value"], Vt = ["onClick"], Ct = ["onClick"], ml = /* @__PURE__ */ Q({
|
|
1825
|
+
name: "XSelect",
|
|
1826
|
+
__name: "index",
|
|
1827
|
+
props: {
|
|
1828
|
+
modelValue: { default: "" },
|
|
1829
|
+
options: { default: () => [] },
|
|
1830
|
+
type: { default: "single" },
|
|
1831
|
+
placeholder: { default: "่ฏท้ๆฉ" },
|
|
1832
|
+
disabled: { type: Boolean, default: !1 },
|
|
1833
|
+
clearable: { type: Boolean, default: !1 },
|
|
1834
|
+
filterable: { type: Boolean, default: !1 },
|
|
1835
|
+
filterMethod: {},
|
|
1836
|
+
size: { default: "default" },
|
|
1837
|
+
multipleLimit: { default: 0 },
|
|
1838
|
+
collapseTags: { type: Boolean, default: !0 },
|
|
1839
|
+
maxCollapseTags: { default: 1 },
|
|
1840
|
+
separator: { default: " / " },
|
|
1841
|
+
valueKey: { default: "value" },
|
|
1842
|
+
labelKey: { default: "label" },
|
|
1843
|
+
childrenKey: { default: "children" },
|
|
1844
|
+
noDataText: { default: "ๆๆ ๆฐๆฎ" },
|
|
1845
|
+
noMatchText: { default: "ๆ ๅน้
ๆฐๆฎ" }
|
|
1846
|
+
},
|
|
1847
|
+
emits: ["update:modelValue", "change", "clear", "focus", "blur", "visible-change", "remove-tag"],
|
|
1848
|
+
setup(n, { emit: p }) {
|
|
1849
|
+
const e = n, t = p, l = J("select"), a = () => Fe().next(), y = A(), v = A(), V = A(), x = A(!1), F = A(2e3), C = A(""), w = A(-1), b = A({ top: "0px", left: "0px" }), S = h(() => e.type === "multiple"), r = h(() => e.type === "cascader"), k = A([]), M = h(() => S.value ? Array.isArray(e.modelValue) ? e.modelValue : [] : r.value ? Array.isArray(e.modelValue) ? e.modelValue : e.modelValue ? [e.modelValue] : [] : e.modelValue !== "" && e.modelValue !== null && e.modelValue !== void 0 ? [e.modelValue] : []), B = h(() => r.value ? kt(e.options, e.childrenKey) : e.options.map((L) => ({ ...L, level: 0 }))), I = h(() => !e.filterable || !C.value ? B.value : B.value.filter((L) => {
|
|
1850
|
+
const X = L[e.labelKey] || "";
|
|
1851
|
+
return yt(X, C.value, e.filterMethod);
|
|
1852
|
+
})), T = h(() => {
|
|
1853
|
+
const L = [];
|
|
1854
|
+
for (const X of M.value) {
|
|
1855
|
+
const W = Ae(e.options, X, e.valueKey, e.childrenKey);
|
|
1856
|
+
W && L.push(W);
|
|
1857
|
+
}
|
|
1858
|
+
return L;
|
|
1859
|
+
}), R = h(() => {
|
|
1860
|
+
if (S.value)
|
|
1861
|
+
return "";
|
|
1862
|
+
if (r.value)
|
|
1863
|
+
return Se(e.options, M.value[M.value.length - 1], e.valueKey, e.childrenKey).map((W) => W[e.labelKey]).join(e.separator);
|
|
1864
|
+
const L = T.value[0];
|
|
1865
|
+
return L ? L[e.labelKey] : "";
|
|
1866
|
+
}), H = h(() => S.value ? T.value : []), z = h(() => e.collapseTags ? H.value.slice(0, e.maxCollapseTags) : H.value), U = h(() => e.collapseTags ? Math.max(0, H.value.length - e.maxCollapseTags) : 0), q = h(() => [
|
|
1867
|
+
l.b(),
|
|
1868
|
+
l.m(e.size),
|
|
1869
|
+
l.is("disabled", e.disabled),
|
|
1870
|
+
l.is("multiple", S.value),
|
|
1871
|
+
l.is("cascader", r.value),
|
|
1872
|
+
l.is("filterable", e.filterable),
|
|
1873
|
+
l.is("focus", x.value)
|
|
1874
|
+
]), Z = () => {
|
|
1875
|
+
if (!y.value || !V.value || !x.value) return;
|
|
1876
|
+
const L = y.value.getBoundingClientRect(), X = V.value.getBoundingClientRect();
|
|
1877
|
+
let W = L.bottom + 4, ne = L.left;
|
|
1878
|
+
ne + X.width > window.innerWidth && (ne = window.innerWidth - X.width - 8), W + X.height > window.innerHeight && (W = L.top - X.height - 4), b.value = {
|
|
1879
|
+
top: `${W}px`,
|
|
1880
|
+
left: `${ne}px`
|
|
1881
|
+
};
|
|
1882
|
+
}, D = () => {
|
|
1883
|
+
e.disabled || (x.value = !0, F.value = a(), C.value = "", we(() => {
|
|
1884
|
+
Z();
|
|
1885
|
+
}), t("visible-change", !0), t("focus", {}));
|
|
1886
|
+
}, $ = () => {
|
|
1887
|
+
x.value = !1, C.value = "", k.value = [], t("visible-change", !1), t("blur", {});
|
|
1888
|
+
}, g = (L) => {
|
|
1889
|
+
if (!L.disabled)
|
|
1890
|
+
if (S.value) {
|
|
1891
|
+
const X = [...M.value], W = L[e.valueKey], ne = X.indexOf(W);
|
|
1892
|
+
if (ne > -1)
|
|
1893
|
+
X.splice(ne, 1), t("remove-tag", W);
|
|
1894
|
+
else {
|
|
1895
|
+
if (e.multipleLimit > 0 && X.length >= e.multipleLimit)
|
|
1896
|
+
return;
|
|
1897
|
+
X.push(W);
|
|
1898
|
+
}
|
|
1899
|
+
t("update:modelValue", X), t("change", X);
|
|
1900
|
+
} else if (r.value)
|
|
1901
|
+
if (L.children && L.children.length > 0) {
|
|
1902
|
+
const X = Se(e.options, L[e.valueKey], e.valueKey, e.childrenKey);
|
|
1903
|
+
k.value = X;
|
|
1904
|
+
} else {
|
|
1905
|
+
const W = Se(e.options, L[e.valueKey], e.valueKey, e.childrenKey).map((ne) => ne[e.valueKey]);
|
|
1906
|
+
t("update:modelValue", W), t("change", W), $();
|
|
1907
|
+
}
|
|
1908
|
+
else
|
|
1909
|
+
t("update:modelValue", L[e.valueKey]), t("change", L[e.valueKey]), $();
|
|
1910
|
+
}, o = (L) => {
|
|
1911
|
+
const X = M.value.filter((W) => W !== L[e.valueKey]);
|
|
1912
|
+
t("update:modelValue", X), t("change", X), t("remove-tag", L[e.valueKey]);
|
|
1913
|
+
}, i = () => {
|
|
1914
|
+
const L = S.value ? [] : "";
|
|
1915
|
+
t("update:modelValue", L), t("change", L), t("clear");
|
|
1916
|
+
}, m = (L) => {
|
|
1917
|
+
C.value = L.target.value;
|
|
1918
|
+
}, O = (L) => {
|
|
1919
|
+
if (!y.value) return;
|
|
1920
|
+
const X = L.target;
|
|
1921
|
+
y.value.contains(X) || V.value && V.value.contains(X) || $();
|
|
1922
|
+
}, ee = (L) => {
|
|
1923
|
+
if (L.key === "Escape")
|
|
1924
|
+
$();
|
|
1925
|
+
else if (L.key === "Enter" && x.value) {
|
|
1926
|
+
const X = I.value[w.value];
|
|
1927
|
+
X && g(X);
|
|
1928
|
+
} else L.key === "ArrowDown" && x.value ? (L.preventDefault(), w.value = Math.min(w.value + 1, I.value.length - 1)) : L.key === "ArrowUp" && x.value && (L.preventDefault(), w.value = Math.max(w.value - 1, 0));
|
|
1929
|
+
}, P = (L) => M.value.includes(L[e.valueKey]), te = (L, X) => [
|
|
1930
|
+
l.e("option"),
|
|
1931
|
+
l.is("selected", P(L)),
|
|
1932
|
+
l.is("disabled", L.disabled === !0),
|
|
1933
|
+
l.is("hover", w.value === X),
|
|
1934
|
+
l.is("group", !!(L.children && L.children.length > 0))
|
|
1935
|
+
], Y = h(() => {
|
|
1936
|
+
if (!r.value) return [];
|
|
1937
|
+
const L = [e.options];
|
|
1938
|
+
for (const X of k.value)
|
|
1939
|
+
X.children && X.children.length > 0 && L.push(X.children);
|
|
1940
|
+
return L;
|
|
1941
|
+
});
|
|
1942
|
+
return ge(() => {
|
|
1943
|
+
document.addEventListener("click", O), document.addEventListener("keydown", ee);
|
|
1944
|
+
}), be(() => {
|
|
1945
|
+
document.removeEventListener("click", O), document.removeEventListener("keydown", ee), document.removeEventListener("scroll", Z, !0);
|
|
1946
|
+
}), ie(x, (L) => {
|
|
1947
|
+
L ? document.addEventListener("scroll", Z, !0) : document.removeEventListener("scroll", Z, !0);
|
|
1948
|
+
}), xe("select", {
|
|
1949
|
+
selectedValues: M,
|
|
1950
|
+
handleSelect: g,
|
|
1951
|
+
isSelected: P
|
|
1952
|
+
}), (L, X) => (c(), d("div", {
|
|
1953
|
+
ref_key: "selectRef",
|
|
1954
|
+
ref: y,
|
|
1955
|
+
class: u(q.value)
|
|
1956
|
+
}, [
|
|
1957
|
+
f("div", {
|
|
1958
|
+
class: u(s(l).e("wrapper")),
|
|
1959
|
+
onClick: X[0] || (X[0] = (W) => x.value ? $() : D())
|
|
1960
|
+
}, [
|
|
1961
|
+
S.value && H.value.length > 0 ? (c(), d("div", {
|
|
1962
|
+
key: 0,
|
|
1963
|
+
class: u(s(l).e("tags"))
|
|
1964
|
+
}, [
|
|
1965
|
+
(c(!0), d(j, null, _(z.value, (W) => (c(), d("span", {
|
|
1966
|
+
key: W[n.valueKey],
|
|
1967
|
+
class: u(s(l).e("tag"))
|
|
1968
|
+
}, [
|
|
1969
|
+
f("span", {
|
|
1970
|
+
class: u(s(l).e("tag-text"))
|
|
1971
|
+
}, E(W[n.labelKey]), 3),
|
|
1972
|
+
f("span", {
|
|
1973
|
+
class: u(s(l).e("tag-close")),
|
|
1974
|
+
onClick: ue((ne) => o(W), ["stop"])
|
|
1975
|
+
}, "ร", 10, xt)
|
|
1976
|
+
], 2))), 128)),
|
|
1977
|
+
U.value > 0 ? (c(), d("span", {
|
|
1978
|
+
key: 0,
|
|
1979
|
+
class: u(s(l).e("tag-count"))
|
|
1980
|
+
}, " +" + E(U.value), 3)) : K("", !0)
|
|
1981
|
+
], 2)) : K("", !0),
|
|
1982
|
+
f("input", {
|
|
1983
|
+
ref_key: "inputRef",
|
|
1984
|
+
ref: v,
|
|
1985
|
+
class: u(s(l).e("input")),
|
|
1986
|
+
placeholder: S.value && H.value.length > 0 ? "" : n.placeholder,
|
|
1987
|
+
disabled: n.disabled,
|
|
1988
|
+
readonly: !n.filterable || !x.value,
|
|
1989
|
+
value: n.filterable && x.value ? C.value : R.value,
|
|
1990
|
+
onInput: m
|
|
1991
|
+
}, null, 42, wt),
|
|
1992
|
+
f("span", {
|
|
1993
|
+
class: u(s(l).e("suffix"))
|
|
1994
|
+
}, [
|
|
1995
|
+
n.clearable && M.value.length > 0 && !n.disabled ? (c(), d("span", {
|
|
1996
|
+
key: 0,
|
|
1997
|
+
class: u(s(l).e("clear")),
|
|
1998
|
+
onClick: ue(i, ["stop"])
|
|
1999
|
+
}, "ร", 2)) : (c(), d("span", {
|
|
2000
|
+
key: 1,
|
|
2001
|
+
class: u([s(l).e("arrow"), s(l).is("reverse", x.value)])
|
|
2002
|
+
}, "โผ", 2))
|
|
2003
|
+
], 2)
|
|
2004
|
+
], 2),
|
|
2005
|
+
(c(), pe(Me, { to: "body" }, [
|
|
2006
|
+
ye(Te, { name: "fade" }, {
|
|
2007
|
+
default: Re(() => [
|
|
2008
|
+
de(f("div", {
|
|
2009
|
+
ref_key: "popperRef",
|
|
2010
|
+
ref: V,
|
|
2011
|
+
class: u([s(l).e("popper"), s(l).is("cascader", r.value)]),
|
|
2012
|
+
style: ae({ zIndex: F.value, ...b.value })
|
|
2013
|
+
}, [
|
|
2014
|
+
r.value ? (c(), d("div", {
|
|
2015
|
+
key: 0,
|
|
2016
|
+
class: u(s(l).e("cascader-panels"))
|
|
2017
|
+
}, [
|
|
2018
|
+
(c(!0), d(j, null, _(Y.value, (W, ne) => (c(), d("div", {
|
|
2019
|
+
key: ne,
|
|
2020
|
+
class: u(s(l).e("cascader-panel"))
|
|
2021
|
+
}, [
|
|
2022
|
+
(c(!0), d(j, null, _(W, (oe, N) => (c(), d("div", {
|
|
2023
|
+
key: oe[n.valueKey],
|
|
2024
|
+
class: u(te(oe, N)),
|
|
2025
|
+
onClick: (G) => g(oe)
|
|
2026
|
+
}, [
|
|
2027
|
+
f("span", {
|
|
2028
|
+
class: u(s(l).e("option-label"))
|
|
2029
|
+
}, E(oe[n.labelKey]), 3),
|
|
2030
|
+
oe.children && oe.children.length > 0 ? (c(), d("span", {
|
|
2031
|
+
key: 0,
|
|
2032
|
+
class: u(s(l).e("option-arrow"))
|
|
2033
|
+
}, "โบ", 2)) : K("", !0)
|
|
2034
|
+
], 10, Vt))), 128))
|
|
2035
|
+
], 2))), 128))
|
|
2036
|
+
], 2)) : (c(), d(j, { key: 1 }, [
|
|
2037
|
+
I.value.length === 0 ? (c(), d("div", {
|
|
2038
|
+
key: 0,
|
|
2039
|
+
class: u(s(l).e("empty"))
|
|
2040
|
+
}, E(C.value ? n.noMatchText : n.noDataText), 3)) : (c(), d("div", {
|
|
2041
|
+
key: 1,
|
|
2042
|
+
class: u(s(l).e("options"))
|
|
2043
|
+
}, [
|
|
2044
|
+
(c(!0), d(j, null, _(I.value, (W, ne) => (c(), d("div", {
|
|
2045
|
+
key: W[n.valueKey],
|
|
2046
|
+
class: u(te(W, ne)),
|
|
2047
|
+
onClick: (oe) => g(W)
|
|
2048
|
+
}, [
|
|
2049
|
+
f("span", {
|
|
2050
|
+
class: u(s(l).e("option-label"))
|
|
2051
|
+
}, E(W[n.labelKey]), 3),
|
|
2052
|
+
P(W) ? (c(), d("span", {
|
|
2053
|
+
key: 0,
|
|
2054
|
+
class: u(s(l).e("option-check"))
|
|
2055
|
+
}, "โ", 2)) : K("", !0)
|
|
2056
|
+
], 10, Ct))), 128))
|
|
2057
|
+
], 2))
|
|
2058
|
+
], 64))
|
|
2059
|
+
], 6), [
|
|
2060
|
+
[Be, x.value]
|
|
2061
|
+
])
|
|
2062
|
+
]),
|
|
2063
|
+
_: 1
|
|
2064
|
+
})
|
|
2065
|
+
]))
|
|
2066
|
+
], 2));
|
|
2067
|
+
}
|
|
2068
|
+
}), Dt = ["checked", "indeterminate"], St = ["placeholder"], $t = ["onClick"], Mt = ["checked", "disabled", "onChange"], Tt = ["disabled"], Rt = ["disabled"], Bt = ["checked", "indeterminate"], Ft = ["placeholder"], It = ["onClick"], Lt = ["checked", "disabled", "onChange"], pl = /* @__PURE__ */ Q({
|
|
2069
|
+
name: "XTransfer",
|
|
2070
|
+
__name: "index",
|
|
2071
|
+
props: {
|
|
2072
|
+
modelValue: { default: () => [] },
|
|
2073
|
+
data: { default: () => [] },
|
|
2074
|
+
titles: { default: () => ["ๅ่กจ1", "ๅ่กจ2"] },
|
|
2075
|
+
buttonTexts: { default: () => ["", ""] },
|
|
2076
|
+
filterable: { type: Boolean, default: !1 },
|
|
2077
|
+
filterPlaceholder: { default: "่ฏท่พๅ
ฅๆ็ดขๅ
ๅฎน" },
|
|
2078
|
+
filterMethod: {},
|
|
2079
|
+
targetOrder: { default: "original" },
|
|
2080
|
+
props: {},
|
|
2081
|
+
leftDefaultChecked: { default: () => [] },
|
|
2082
|
+
rightDefaultChecked: { default: () => [] }
|
|
2083
|
+
},
|
|
2084
|
+
emits: ["update:modelValue", "change", "left-check-change", "right-check-change"],
|
|
2085
|
+
setup(n, { expose: p, emit: e }) {
|
|
2086
|
+
const t = n, l = e, a = J("transfer"), y = h(() => {
|
|
2087
|
+
var o;
|
|
2088
|
+
return ((o = t.props) == null ? void 0 : o.key) || "key";
|
|
2089
|
+
}), v = h(() => {
|
|
2090
|
+
var o;
|
|
2091
|
+
return ((o = t.props) == null ? void 0 : o.label) || "label";
|
|
2092
|
+
}), V = h(() => {
|
|
2093
|
+
var o;
|
|
2094
|
+
return ((o = t.props) == null ? void 0 : o.disabled) || "disabled";
|
|
2095
|
+
}), x = A(""), F = A(""), C = A([]), w = A([]), b = (o) => o[y.value], S = (o) => o[v.value], r = (o) => o[V.value] || !1, k = h(() => t.data.filter((o) => {
|
|
2096
|
+
const i = b(o);
|
|
2097
|
+
return t.modelValue.includes(i) ? !1 : t.filterable && x.value ? t.filterMethod ? t.filterMethod(x.value, o) : S(o).toLowerCase().includes(x.value.toLowerCase()) : !0;
|
|
2098
|
+
})), M = h(() => {
|
|
2099
|
+
const o = t.modelValue;
|
|
2100
|
+
let i = t.data.filter((m) => {
|
|
2101
|
+
const O = b(m);
|
|
2102
|
+
return o.includes(O);
|
|
2103
|
+
});
|
|
2104
|
+
return t.filterable && F.value && (i = i.filter((m) => t.filterMethod ? t.filterMethod(F.value, m) : S(m).toLowerCase().includes(F.value.toLowerCase()))), t.targetOrder === "push" ? i.sort((m, O) => o.indexOf(b(m)) - o.indexOf(b(O))) : t.targetOrder === "unshift" ? i.sort((m, O) => o.indexOf(b(O)) - o.indexOf(b(m))) : i;
|
|
2105
|
+
}), B = h(() => k.value.filter((o) => C.value.includes(b(o))).every((o) => r(o))), I = h(() => M.value.filter((o) => w.value.includes(b(o))).every((o) => r(o))), T = h(() => C.value.length === 0 || B.value), R = h(() => w.value.length === 0 || I.value), H = () => {
|
|
2106
|
+
const o = C.value.filter((m) => {
|
|
2107
|
+
const O = t.data.find((ee) => b(ee) === m);
|
|
2108
|
+
return O && !r(O);
|
|
2109
|
+
});
|
|
2110
|
+
let i;
|
|
2111
|
+
t.targetOrder === "unshift" ? i = [...o, ...t.modelValue] : i = [...t.modelValue, ...o], l("update:modelValue", i), l("change", i, "right", o), C.value = [];
|
|
2112
|
+
}, z = () => {
|
|
2113
|
+
const o = w.value.filter((m) => {
|
|
2114
|
+
const O = t.data.find((ee) => b(ee) === m);
|
|
2115
|
+
return O && !r(O);
|
|
2116
|
+
}), i = t.modelValue.filter((m) => !o.includes(m));
|
|
2117
|
+
l("update:modelValue", i), l("change", i, "left", o), w.value = [];
|
|
2118
|
+
}, U = (o) => {
|
|
2119
|
+
const i = C.value.indexOf(o);
|
|
2120
|
+
i > -1 ? C.value.splice(i, 1) : C.value.push(o), l("left-check-change", [...C.value]);
|
|
2121
|
+
}, q = (o) => {
|
|
2122
|
+
const i = w.value.indexOf(o);
|
|
2123
|
+
i > -1 ? w.value.splice(i, 1) : w.value.push(o), l("right-check-change", [...w.value]);
|
|
2124
|
+
}, Z = () => {
|
|
2125
|
+
C.value.length === k.value.filter((o) => !r(o)).length ? C.value = [] : C.value = k.value.filter((o) => !r(o)).map((o) => b(o)), l("left-check-change", [...C.value]);
|
|
2126
|
+
}, D = () => {
|
|
2127
|
+
w.value.length === M.value.filter((o) => !r(o)).length ? w.value = [] : w.value = M.value.filter((o) => !r(o)).map((o) => b(o)), l("right-check-change", [...w.value]);
|
|
2128
|
+
}, $ = (o) => {
|
|
2129
|
+
o === "left" ? x.value = "" : F.value = "";
|
|
2130
|
+
}, g = h(() => [a.b()]);
|
|
2131
|
+
return p({
|
|
2132
|
+
clearQuery: $
|
|
2133
|
+
}), (o, i) => (c(), d("div", {
|
|
2134
|
+
class: u(g.value)
|
|
2135
|
+
}, [
|
|
2136
|
+
f("div", {
|
|
2137
|
+
class: u(s(a).e("panel"))
|
|
2138
|
+
}, [
|
|
2139
|
+
f("div", {
|
|
2140
|
+
class: u(s(a).e("header"))
|
|
2141
|
+
}, [
|
|
2142
|
+
f("label", {
|
|
2143
|
+
class: u(s(a).e("checkbox"))
|
|
2144
|
+
}, [
|
|
2145
|
+
f("input", {
|
|
2146
|
+
type: "checkbox",
|
|
2147
|
+
checked: C.value.length > 0 && C.value.length === k.value.filter((m) => !r(m)).length,
|
|
2148
|
+
indeterminate: C.value.length > 0 && C.value.length < k.value.filter((m) => !r(m)).length,
|
|
2149
|
+
onChange: Z
|
|
2150
|
+
}, null, 40, Dt),
|
|
2151
|
+
f("span", null, E(n.titles[0]), 1)
|
|
2152
|
+
], 2),
|
|
2153
|
+
f("span", {
|
|
2154
|
+
class: u(s(a).e("count"))
|
|
2155
|
+
}, E(C.value.length) + " / " + E(k.value.length), 3)
|
|
2156
|
+
], 2),
|
|
2157
|
+
n.filterable ? (c(), d("div", {
|
|
2158
|
+
key: 0,
|
|
2159
|
+
class: u(s(a).e("filter"))
|
|
2160
|
+
}, [
|
|
2161
|
+
de(f("input", {
|
|
2162
|
+
"onUpdate:modelValue": i[0] || (i[0] = (m) => x.value = m),
|
|
2163
|
+
placeholder: n.filterPlaceholder,
|
|
2164
|
+
class: u(s(a).e("filter-input"))
|
|
2165
|
+
}, null, 10, St), [
|
|
2166
|
+
[$e, x.value]
|
|
2167
|
+
]),
|
|
2168
|
+
x.value ? (c(), d("span", {
|
|
2169
|
+
key: 0,
|
|
2170
|
+
class: u(s(a).e("filter-clear")),
|
|
2171
|
+
onClick: i[1] || (i[1] = (m) => $("left"))
|
|
2172
|
+
}, "ร", 2)) : K("", !0)
|
|
2173
|
+
], 2)) : K("", !0),
|
|
2174
|
+
f("div", {
|
|
2175
|
+
class: u(s(a).e("body"))
|
|
2176
|
+
}, [
|
|
2177
|
+
(c(!0), d(j, null, _(k.value, (m) => (c(), d("div", {
|
|
2178
|
+
key: b(m),
|
|
2179
|
+
class: u([
|
|
2180
|
+
s(a).e("item"),
|
|
2181
|
+
s(a).is("disabled", r(m)),
|
|
2182
|
+
s(a).is("checked", C.value.includes(b(m)))
|
|
2183
|
+
]),
|
|
2184
|
+
onClick: (O) => !r(m) && U(b(m))
|
|
2185
|
+
}, [
|
|
2186
|
+
f("label", {
|
|
2187
|
+
class: u(s(a).e("checkbox"))
|
|
2188
|
+
}, [
|
|
2189
|
+
f("input", {
|
|
2190
|
+
type: "checkbox",
|
|
2191
|
+
checked: C.value.includes(b(m)),
|
|
2192
|
+
disabled: r(m),
|
|
2193
|
+
onClick: i[2] || (i[2] = ue(() => {
|
|
2194
|
+
}, ["stop"])),
|
|
2195
|
+
onChange: (O) => U(b(m))
|
|
2196
|
+
}, null, 40, Mt),
|
|
2197
|
+
f("span", null, E(S(m)), 1)
|
|
2198
|
+
], 2)
|
|
2199
|
+
], 10, $t))), 128)),
|
|
2200
|
+
k.value.length === 0 ? (c(), d("div", {
|
|
2201
|
+
key: 0,
|
|
2202
|
+
class: u(s(a).e("empty"))
|
|
2203
|
+
}, [
|
|
2204
|
+
le(o.$slots, "left-empty", {}, () => [
|
|
2205
|
+
i[6] || (i[6] = ve("ๆๆ ๆฐๆฎ", -1))
|
|
2206
|
+
])
|
|
2207
|
+
], 2)) : K("", !0)
|
|
2208
|
+
], 2)
|
|
2209
|
+
], 2),
|
|
2210
|
+
f("div", {
|
|
2211
|
+
class: u(s(a).e("buttons"))
|
|
2212
|
+
}, [
|
|
2213
|
+
f("button", {
|
|
2214
|
+
class: u([s(a).e("button"), s(a).is("disabled", T.value)]),
|
|
2215
|
+
disabled: T.value,
|
|
2216
|
+
onClick: H
|
|
2217
|
+
}, E(n.buttonTexts[0] || ">"), 11, Tt),
|
|
2218
|
+
f("button", {
|
|
2219
|
+
class: u([s(a).e("button"), s(a).is("disabled", R.value)]),
|
|
2220
|
+
disabled: R.value,
|
|
2221
|
+
onClick: z
|
|
2222
|
+
}, E(n.buttonTexts[1] || "<"), 11, Rt)
|
|
2223
|
+
], 2),
|
|
2224
|
+
f("div", {
|
|
2225
|
+
class: u(s(a).e("panel"))
|
|
2226
|
+
}, [
|
|
2227
|
+
f("div", {
|
|
2228
|
+
class: u(s(a).e("header"))
|
|
2229
|
+
}, [
|
|
2230
|
+
f("label", {
|
|
2231
|
+
class: u(s(a).e("checkbox"))
|
|
2232
|
+
}, [
|
|
2233
|
+
f("input", {
|
|
2234
|
+
type: "checkbox",
|
|
2235
|
+
checked: w.value.length > 0 && w.value.length === M.value.filter((m) => !r(m)).length,
|
|
2236
|
+
indeterminate: w.value.length > 0 && w.value.length < M.value.filter((m) => !r(m)).length,
|
|
2237
|
+
onChange: D
|
|
2238
|
+
}, null, 40, Bt),
|
|
2239
|
+
f("span", null, E(n.titles[1]), 1)
|
|
2240
|
+
], 2),
|
|
2241
|
+
f("span", {
|
|
2242
|
+
class: u(s(a).e("count"))
|
|
2243
|
+
}, E(w.value.length) + " / " + E(M.value.length), 3)
|
|
2244
|
+
], 2),
|
|
2245
|
+
n.filterable ? (c(), d("div", {
|
|
2246
|
+
key: 0,
|
|
2247
|
+
class: u(s(a).e("filter"))
|
|
2248
|
+
}, [
|
|
2249
|
+
de(f("input", {
|
|
2250
|
+
"onUpdate:modelValue": i[3] || (i[3] = (m) => F.value = m),
|
|
2251
|
+
placeholder: n.filterPlaceholder,
|
|
2252
|
+
class: u(s(a).e("filter-input"))
|
|
2253
|
+
}, null, 10, Ft), [
|
|
2254
|
+
[$e, F.value]
|
|
2255
|
+
]),
|
|
2256
|
+
F.value ? (c(), d("span", {
|
|
2257
|
+
key: 0,
|
|
2258
|
+
class: u(s(a).e("filter-clear")),
|
|
2259
|
+
onClick: i[4] || (i[4] = (m) => $("right"))
|
|
2260
|
+
}, "ร", 2)) : K("", !0)
|
|
2261
|
+
], 2)) : K("", !0),
|
|
2262
|
+
f("div", {
|
|
2263
|
+
class: u(s(a).e("body"))
|
|
2264
|
+
}, [
|
|
2265
|
+
(c(!0), d(j, null, _(M.value, (m) => (c(), d("div", {
|
|
2266
|
+
key: b(m),
|
|
2267
|
+
class: u([
|
|
2268
|
+
s(a).e("item"),
|
|
2269
|
+
s(a).is("disabled", r(m)),
|
|
2270
|
+
s(a).is("checked", w.value.includes(b(m)))
|
|
2271
|
+
]),
|
|
2272
|
+
onClick: (O) => !r(m) && q(b(m))
|
|
2273
|
+
}, [
|
|
2274
|
+
f("label", {
|
|
2275
|
+
class: u(s(a).e("checkbox"))
|
|
2276
|
+
}, [
|
|
2277
|
+
f("input", {
|
|
2278
|
+
type: "checkbox",
|
|
2279
|
+
checked: w.value.includes(b(m)),
|
|
2280
|
+
disabled: r(m),
|
|
2281
|
+
onClick: i[5] || (i[5] = ue(() => {
|
|
2282
|
+
}, ["stop"])),
|
|
2283
|
+
onChange: (O) => q(b(m))
|
|
2284
|
+
}, null, 40, Lt),
|
|
2285
|
+
f("span", null, E(S(m)), 1)
|
|
2286
|
+
], 2)
|
|
2287
|
+
], 10, It))), 128)),
|
|
2288
|
+
M.value.length === 0 ? (c(), d("div", {
|
|
2289
|
+
key: 0,
|
|
2290
|
+
class: u(s(a).e("empty"))
|
|
2291
|
+
}, [
|
|
2292
|
+
le(o.$slots, "right-empty", {}, () => [
|
|
2293
|
+
i[7] || (i[7] = ve("ๆๆ ๆฐๆฎ", -1))
|
|
2294
|
+
])
|
|
2295
|
+
], 2)) : K("", !0)
|
|
2296
|
+
], 2)
|
|
2297
|
+
], 2)
|
|
2298
|
+
], 2));
|
|
2299
|
+
}
|
|
2300
|
+
}), Pt = { key: 0 }, At = { key: 1 }, hl = /* @__PURE__ */ Q({
|
|
2301
|
+
name: "XSlider",
|
|
2302
|
+
__name: "index",
|
|
2303
|
+
props: {
|
|
2304
|
+
modelValue: { default: 0 },
|
|
2305
|
+
min: { default: 0 },
|
|
2306
|
+
max: { default: 100 },
|
|
2307
|
+
step: { default: 1 },
|
|
2308
|
+
disabled: { type: Boolean, default: !1 },
|
|
2309
|
+
showTooltip: { type: Boolean, default: !0 },
|
|
2310
|
+
formatTooltip: {},
|
|
2311
|
+
showStops: { type: Boolean, default: !1 },
|
|
2312
|
+
vertical: { type: Boolean, default: !1 },
|
|
2313
|
+
height: { default: "200px" },
|
|
2314
|
+
marks: {}
|
|
2315
|
+
},
|
|
2316
|
+
emits: ["update:modelValue", "change", "input"],
|
|
2317
|
+
setup(n, { emit: p }) {
|
|
2318
|
+
const e = n, t = p, l = J("slider"), a = A(), y = A(), v = A(!1), V = A(!1), x = h(() => {
|
|
2319
|
+
const $ = e.max - e.min;
|
|
2320
|
+
return (e.modelValue - e.min) / $ * 100;
|
|
2321
|
+
}), F = h(() => e.formatTooltip ? e.formatTooltip(e.modelValue) : e.modelValue), C = h(() => {
|
|
2322
|
+
if (!e.showStops || e.min >= e.max) return [];
|
|
2323
|
+
const $ = [], g = (e.max - e.min) / e.step;
|
|
2324
|
+
for (let o = 0; o <= g; o++) {
|
|
2325
|
+
const i = e.min + o * e.step;
|
|
2326
|
+
i > e.min && i < e.max && $.push((i - e.min) / (e.max - e.min) * 100);
|
|
2327
|
+
}
|
|
2328
|
+
return $;
|
|
2329
|
+
}), w = h(() => e.marks ? Object.keys(e.marks).map(($) => {
|
|
2330
|
+
const g = Number($), o = e.marks[g], i = (g - e.min) / (e.max - e.min) * 100;
|
|
2331
|
+
let m, O = {};
|
|
2332
|
+
return typeof o == "string" ? m = o : (m = o.label || String(g), O = o.style || {}), { value: g, pos: i, label: m, style: O };
|
|
2333
|
+
}) : []), b = () => a.value ? e.vertical ? a.value.offsetHeight : a.value.offsetWidth : 0, S = ($, g) => {
|
|
2334
|
+
if (!a.value) return e.modelValue;
|
|
2335
|
+
const o = a.value.getBoundingClientRect(), i = b();
|
|
2336
|
+
let m;
|
|
2337
|
+
e.vertical ? m = (o.bottom - g) / i * 100 : m = ($ - o.left) / i * 100, m = Math.max(0, Math.min(100, m));
|
|
2338
|
+
const O = e.min + m / 100 * (e.max - e.min), ee = Math.round(O / e.step) * e.step;
|
|
2339
|
+
return Math.max(e.min, Math.min(e.max, ee));
|
|
2340
|
+
}, r = ($) => {
|
|
2341
|
+
if (e.disabled) return;
|
|
2342
|
+
const g = Math.max(e.min, Math.min(e.max, $));
|
|
2343
|
+
g !== e.modelValue && (t("update:modelValue", g), t("input", g));
|
|
2344
|
+
}, k = ($) => {
|
|
2345
|
+
if (e.disabled) return;
|
|
2346
|
+
$.preventDefault(), V.value = !0, v.value = !0;
|
|
2347
|
+
const g = S($.clientX, $.clientY);
|
|
2348
|
+
r(g), document.addEventListener("mousemove", M), document.addEventListener("mouseup", B);
|
|
2349
|
+
}, M = ($) => {
|
|
2350
|
+
if (!V.value) return;
|
|
2351
|
+
const g = S($.clientX, $.clientY);
|
|
2352
|
+
r(g);
|
|
2353
|
+
}, B = () => {
|
|
2354
|
+
V.value = !1, t("change", e.modelValue), document.removeEventListener("mousemove", M), document.removeEventListener("mouseup", B);
|
|
2355
|
+
}, I = ($) => {
|
|
2356
|
+
if (e.disabled) return;
|
|
2357
|
+
$.preventDefault(), V.value = !0, v.value = !0;
|
|
2358
|
+
const g = $.touches[0], o = S(g.clientX, g.clientY);
|
|
2359
|
+
r(o);
|
|
2360
|
+
}, T = ($) => {
|
|
2361
|
+
if (!V.value) return;
|
|
2362
|
+
const g = $.touches[0], o = S(g.clientX, g.clientY);
|
|
2363
|
+
r(o);
|
|
2364
|
+
}, R = () => {
|
|
2365
|
+
V.value = !1, t("change", e.modelValue);
|
|
2366
|
+
}, H = () => {
|
|
2367
|
+
e.showTooltip && (v.value = !0);
|
|
2368
|
+
}, z = () => {
|
|
2369
|
+
V.value || (v.value = !1);
|
|
2370
|
+
};
|
|
2371
|
+
be(() => {
|
|
2372
|
+
document.removeEventListener("mousemove", M), document.removeEventListener("mouseup", B);
|
|
2373
|
+
});
|
|
2374
|
+
const U = h(() => [
|
|
2375
|
+
l.b(),
|
|
2376
|
+
l.is("disabled", e.disabled),
|
|
2377
|
+
l.is("vertical", e.vertical)
|
|
2378
|
+
]), q = h(() => e.vertical && e.height ? { height: typeof e.height == "number" ? `${e.height}px` : e.height } : {}), Z = h(() => e.vertical ? { height: `${x.value}%` } : { width: `${x.value}%` }), D = h(() => e.vertical ? { bottom: `${x.value}%` } : { left: `${x.value}%` });
|
|
2379
|
+
return ($, g) => (c(), d("div", {
|
|
2380
|
+
class: u(U.value),
|
|
2381
|
+
style: ae(q.value)
|
|
2382
|
+
}, [
|
|
2383
|
+
f("div", {
|
|
2384
|
+
ref_key: "sliderRef",
|
|
2385
|
+
ref: a,
|
|
2386
|
+
class: u(s(l).e("runway")),
|
|
2387
|
+
onMousedown: k,
|
|
2388
|
+
onTouchstart: I
|
|
2389
|
+
}, [
|
|
2390
|
+
f("div", {
|
|
2391
|
+
class: u(s(l).e("bar")),
|
|
2392
|
+
style: ae(Z.value)
|
|
2393
|
+
}, null, 6),
|
|
2394
|
+
n.showStops ? (c(), d("div", Pt, [
|
|
2395
|
+
(c(!0), d(j, null, _(C.value, (o, i) => (c(), d("div", {
|
|
2396
|
+
key: i,
|
|
2397
|
+
class: u(s(l).e("stop")),
|
|
2398
|
+
style: ae(n.vertical ? { bottom: `${o}%` } : { left: `${o}%` })
|
|
2399
|
+
}, null, 6))), 128))
|
|
2400
|
+
])) : K("", !0),
|
|
2401
|
+
w.value.length > 0 ? (c(), d("div", At, [
|
|
2402
|
+
(c(!0), d(j, null, _(w.value, (o) => (c(), d("div", {
|
|
2403
|
+
key: o.value,
|
|
2404
|
+
class: u(s(l).e("mark")),
|
|
2405
|
+
style: ae(n.vertical ? { bottom: `${o.pos}%` } : { left: `${o.pos}%`, ...o.style })
|
|
2406
|
+
}, [
|
|
2407
|
+
f("span", {
|
|
2408
|
+
class: u(s(l).e("mark-text"))
|
|
2409
|
+
}, E(o.label), 3)
|
|
2410
|
+
], 6))), 128))
|
|
2411
|
+
])) : K("", !0),
|
|
2412
|
+
f("div", {
|
|
2413
|
+
ref_key: "buttonRef",
|
|
2414
|
+
ref: y,
|
|
2415
|
+
class: u(s(l).e("button-wrapper")),
|
|
2416
|
+
style: ae(D.value),
|
|
2417
|
+
onMouseenter: H,
|
|
2418
|
+
onMouseleave: z,
|
|
2419
|
+
onTouchmove: T,
|
|
2420
|
+
onTouchend: R
|
|
2421
|
+
}, [
|
|
2422
|
+
n.showTooltip && v.value ? (c(), d("div", {
|
|
2423
|
+
key: 0,
|
|
2424
|
+
class: u(s(l).e("tooltip"))
|
|
2425
|
+
}, E(F.value), 3)) : K("", !0),
|
|
2426
|
+
f("div", {
|
|
2427
|
+
class: u(s(l).e("button"))
|
|
2428
|
+
}, null, 2)
|
|
2429
|
+
], 38)
|
|
2430
|
+
], 34)
|
|
2431
|
+
], 6));
|
|
2432
|
+
}
|
|
2433
|
+
}), Et = ["src"], Yt = {
|
|
2434
|
+
key: 0,
|
|
2435
|
+
class: "status-uploading"
|
|
2436
|
+
}, zt = { class: "progress-circle" }, Ht = { class: "progress-text" }, Ot = {
|
|
2437
|
+
key: 1,
|
|
2438
|
+
class: "status-error"
|
|
2439
|
+
}, Nt = {
|
|
2440
|
+
key: 2,
|
|
2441
|
+
class: "status-success"
|
|
2442
|
+
}, Kt = {
|
|
2443
|
+
key: 0,
|
|
2444
|
+
class: "action-preview"
|
|
2445
|
+
}, Xt = ["onClick"], Ut = ["disabled"], Wt = { class: "progress-text" }, Gt = ["onClick"], qt = ["src"], jt = {
|
|
2446
|
+
key: 0,
|
|
2447
|
+
class: "action-success"
|
|
2448
|
+
}, Zt = ["onClick"], Qt = ["multiple", "accept", "disabled"], gl = /* @__PURE__ */ Q({
|
|
2449
|
+
name: "XUpload",
|
|
2450
|
+
__name: "index",
|
|
2451
|
+
props: {
|
|
2452
|
+
action: { default: "#" },
|
|
2453
|
+
headers: {},
|
|
2454
|
+
data: {},
|
|
2455
|
+
multiple: { type: Boolean, default: !1 },
|
|
2456
|
+
accept: {},
|
|
2457
|
+
limit: {},
|
|
2458
|
+
disabled: { type: Boolean, default: !1 },
|
|
2459
|
+
drag: { type: Boolean, default: !1 },
|
|
2460
|
+
listType: { default: "text" },
|
|
2461
|
+
autoUpload: { type: Boolean, default: !0 },
|
|
2462
|
+
fileList: { default: () => [] },
|
|
2463
|
+
showFileList: { type: Boolean, default: !0 },
|
|
2464
|
+
withCredentials: { type: Boolean, default: !1 },
|
|
2465
|
+
name: { default: "file" },
|
|
2466
|
+
httpRequest: {},
|
|
2467
|
+
beforeUpload: {},
|
|
2468
|
+
beforeRemove: {},
|
|
2469
|
+
onSuccess: {},
|
|
2470
|
+
onError: {},
|
|
2471
|
+
onProgress: {},
|
|
2472
|
+
onChange: {},
|
|
2473
|
+
onRemove: {},
|
|
2474
|
+
onExceed: {}
|
|
2475
|
+
},
|
|
2476
|
+
emits: ["update:fileList", "success", "error", "progress", "change", "remove", "exceed"],
|
|
2477
|
+
setup(n, { expose: p, emit: e }) {
|
|
2478
|
+
const t = n, l = e, a = J("upload");
|
|
2479
|
+
Le();
|
|
2480
|
+
const y = A(), v = A([...t.fileList]), V = A(!1);
|
|
2481
|
+
let x = 1;
|
|
2482
|
+
const F = () => Date.now() + x++, C = (D) => {
|
|
2483
|
+
var o;
|
|
2484
|
+
const $ = (o = D.name.split(".").pop()) == null ? void 0 : o.toLowerCase(), g = {
|
|
2485
|
+
pdf: "๐",
|
|
2486
|
+
doc: "๐",
|
|
2487
|
+
docx: "๐",
|
|
2488
|
+
xls: "๐",
|
|
2489
|
+
xlsx: "๐",
|
|
2490
|
+
ppt: "๐ฝ๏ธ",
|
|
2491
|
+
pptx: "๐ฝ๏ธ",
|
|
2492
|
+
zip: "๐ฆ",
|
|
2493
|
+
rar: "๐ฆ",
|
|
2494
|
+
mp3: "๐ต",
|
|
2495
|
+
mp4: "๐ฌ",
|
|
2496
|
+
default: "๐"
|
|
2497
|
+
};
|
|
2498
|
+
return g[$ || ""] || g.default;
|
|
2499
|
+
}, w = h(() => t.limit ? v.value.length < t.limit : !0), b = h(() => [
|
|
2500
|
+
a.b(),
|
|
2501
|
+
a.is("disabled", t.disabled),
|
|
2502
|
+
a.is("drag", t.drag),
|
|
2503
|
+
a.m(t.listType)
|
|
2504
|
+
]), S = (D) => {
|
|
2505
|
+
const $ = D.target.files;
|
|
2506
|
+
!$ || $.length === 0 || (r(Array.from($)), y.value && (y.value.value = ""));
|
|
2507
|
+
}, r = async (D) => {
|
|
2508
|
+
var $, g;
|
|
2509
|
+
if (t.limit && v.value.length + D.length > t.limit) {
|
|
2510
|
+
l("exceed", D, v.value), ($ = t.onExceed) == null || $.call(t, D, v.value);
|
|
2511
|
+
return;
|
|
2512
|
+
}
|
|
2513
|
+
for (const o of D) {
|
|
2514
|
+
if (t.beforeUpload && await t.beforeUpload(o, D) === !1)
|
|
2515
|
+
continue;
|
|
2516
|
+
const i = {
|
|
2517
|
+
name: o.name,
|
|
2518
|
+
size: o.size,
|
|
2519
|
+
status: "ready",
|
|
2520
|
+
percentage: 0,
|
|
2521
|
+
uid: F(),
|
|
2522
|
+
raw: o
|
|
2523
|
+
};
|
|
2524
|
+
o.type.startsWith("image/") && (i.thumbUrl = await k(o), i.url = i.thumbUrl), v.value.push(i), l("update:fileList", v.value), l("change", i, v.value), (g = t.onChange) == null || g.call(t, i, v.value), t.autoUpload && M(i);
|
|
2525
|
+
}
|
|
2526
|
+
}, k = (D) => new Promise(($) => {
|
|
2527
|
+
const g = new FileReader();
|
|
2528
|
+
g.onload = (o) => {
|
|
2529
|
+
var i;
|
|
2530
|
+
$((i = o.target) == null ? void 0 : i.result);
|
|
2531
|
+
}, g.readAsDataURL(D);
|
|
2532
|
+
}), M = (D) => {
|
|
2533
|
+
if (!D.raw) return;
|
|
2534
|
+
D.status = "uploading", (t.httpRequest || B)({
|
|
2535
|
+
action: t.action,
|
|
2536
|
+
headers: t.headers,
|
|
2537
|
+
data: t.data,
|
|
2538
|
+
file: D.raw,
|
|
2539
|
+
name: t.name,
|
|
2540
|
+
withCredentials: t.withCredentials,
|
|
2541
|
+
onProgress: (g) => {
|
|
2542
|
+
var o;
|
|
2543
|
+
D.percentage = g.percent, l("progress", g, D, v.value), (o = t.onProgress) == null || o.call(t, g, D, v.value);
|
|
2544
|
+
},
|
|
2545
|
+
onSuccess: (g) => {
|
|
2546
|
+
var o;
|
|
2547
|
+
D.status = "success", D.response = g, l("success", g, D, v.value), (o = t.onSuccess) == null || o.call(t, g, D, v.value);
|
|
2548
|
+
},
|
|
2549
|
+
onError: (g) => {
|
|
2550
|
+
var o;
|
|
2551
|
+
D.status = "error", l("error", g, D, v.value), (o = t.onError) == null || o.call(t, g, D, v.value);
|
|
2552
|
+
}
|
|
2553
|
+
});
|
|
2554
|
+
}, B = (D) => new Promise(($, g) => {
|
|
2555
|
+
const o = new XMLHttpRequest();
|
|
2556
|
+
o.upload.addEventListener("progress", (m) => {
|
|
2557
|
+
m.lengthComputable && D.onProgress({ percent: m.loaded / m.total * 100 });
|
|
2558
|
+
}), o.addEventListener("load", () => {
|
|
2559
|
+
if (o.status < 200 || o.status >= 300) {
|
|
2560
|
+
D.onError(new Error("Upload failed")), g(new Error("Upload failed"));
|
|
2561
|
+
return;
|
|
2562
|
+
}
|
|
2563
|
+
try {
|
|
2564
|
+
const m = JSON.parse(o.responseText);
|
|
2565
|
+
D.onSuccess(m), $(m);
|
|
2566
|
+
} catch {
|
|
2567
|
+
D.onSuccess(o.responseText), $(o.responseText);
|
|
2568
|
+
}
|
|
2569
|
+
}), o.addEventListener("error", () => {
|
|
2570
|
+
D.onError(new Error("Upload error")), g(new Error("Upload error"));
|
|
2571
|
+
});
|
|
2572
|
+
const i = new FormData();
|
|
2573
|
+
i.append(D.name, D.file), D.data && Object.keys(D.data).forEach((m) => {
|
|
2574
|
+
i.append(m, D.data[m]);
|
|
2575
|
+
}), o.open("POST", D.action, !0), D.withCredentials && (o.withCredentials = !0), D.headers && Object.keys(D.headers).forEach((m) => {
|
|
2576
|
+
o.setRequestHeader(m, D.headers[m]);
|
|
2577
|
+
}), o.send(i);
|
|
2578
|
+
}), I = async (D) => {
|
|
2579
|
+
var g;
|
|
2580
|
+
if (t.beforeRemove && await t.beforeRemove(D, v.value) === !1)
|
|
2581
|
+
return;
|
|
2582
|
+
const $ = v.value.findIndex((o) => o.uid === D.uid);
|
|
2583
|
+
$ > -1 && (v.value.splice($, 1), l("update:fileList", v.value), l("remove", D, v.value), (g = t.onRemove) == null || g.call(t, D, v.value));
|
|
2584
|
+
}, T = () => {
|
|
2585
|
+
v.value.filter((D) => D.status === "ready" && D.raw).forEach((D) => M(D));
|
|
2586
|
+
}, R = () => {
|
|
2587
|
+
v.value = [], l("update:fileList", v.value);
|
|
2588
|
+
}, H = () => {
|
|
2589
|
+
var D;
|
|
2590
|
+
t.disabled || (D = y.value) == null || D.click();
|
|
2591
|
+
}, z = (D) => {
|
|
2592
|
+
D.preventDefault(), !t.disabled && t.drag && (V.value = !0);
|
|
2593
|
+
}, U = () => {
|
|
2594
|
+
V.value = !1;
|
|
2595
|
+
}, q = (D) => {
|
|
2596
|
+
var g;
|
|
2597
|
+
if (D.preventDefault(), V.value = !1, t.disabled) return;
|
|
2598
|
+
const $ = (g = D.dataTransfer) == null ? void 0 : g.files;
|
|
2599
|
+
$ && $.length > 0 && r(Array.from($));
|
|
2600
|
+
}, Z = (D) => {
|
|
2601
|
+
if (!D) return "0 B";
|
|
2602
|
+
const $ = ["B", "KB", "MB", "GB"];
|
|
2603
|
+
let g = 0, o = D;
|
|
2604
|
+
for (; o >= 1024 && g < $.length - 1; )
|
|
2605
|
+
o /= 1024, g++;
|
|
2606
|
+
return `${o.toFixed(2)} ${$[g]}`;
|
|
2607
|
+
};
|
|
2608
|
+
return p({
|
|
2609
|
+
submit: T,
|
|
2610
|
+
clearFiles: R,
|
|
2611
|
+
uploadFiles: v
|
|
2612
|
+
}), (D, $) => (c(), d("div", {
|
|
2613
|
+
class: u(b.value)
|
|
2614
|
+
}, [
|
|
2615
|
+
n.drag ? (c(), d("div", {
|
|
2616
|
+
key: 0,
|
|
2617
|
+
class: u([s(a).e("drag"), s(a).is("dragover", V.value)]),
|
|
2618
|
+
onClick: H,
|
|
2619
|
+
onDragover: z,
|
|
2620
|
+
onDragleave: U,
|
|
2621
|
+
onDrop: q
|
|
2622
|
+
}, [
|
|
2623
|
+
le(D.$slots, "drag", {}, () => [
|
|
2624
|
+
f("span", {
|
|
2625
|
+
class: u(s(a).e("drag-icon"))
|
|
2626
|
+
}, "๐", 2),
|
|
2627
|
+
f("div", {
|
|
2628
|
+
class: u(s(a).e("drag-text"))
|
|
2629
|
+
}, [...$[0] || ($[0] = [
|
|
2630
|
+
ve(" ๅฐๆไปถๆๅฐๆญคๅค๏ผๆ", -1),
|
|
2631
|
+
f("em", null, "็นๅปไธไผ ", -1)
|
|
2632
|
+
])], 2)
|
|
2633
|
+
])
|
|
2634
|
+
], 34)) : n.listType === "picture-card" ? (c(), d("ul", {
|
|
2635
|
+
key: 1,
|
|
2636
|
+
class: u([s(a).e("files"), s(a).e("upload-list")])
|
|
2637
|
+
}, [
|
|
2638
|
+
(c(!0), d(j, null, _(v.value, (g) => (c(), d("li", {
|
|
2639
|
+
key: g.uid,
|
|
2640
|
+
class: u([s(a).e("file"), s(a).is(`status-${g.status}`)])
|
|
2641
|
+
}, [
|
|
2642
|
+
g.thumbUrl && g.status !== "uploading" ? (c(), d("img", {
|
|
2643
|
+
key: 0,
|
|
2644
|
+
src: g.thumbUrl,
|
|
2645
|
+
class: u(s(a).e("file-image"))
|
|
2646
|
+
}, null, 10, Et)) : (c(), d("div", {
|
|
2647
|
+
key: 1,
|
|
2648
|
+
class: u(s(a).e("file-status"))
|
|
2649
|
+
}, [
|
|
2650
|
+
g.status === "uploading" ? (c(), d("span", Yt, [
|
|
2651
|
+
f("span", zt, [
|
|
2652
|
+
f("span", Ht, E(Math.round(g.percentage || 0)) + "%", 1)
|
|
2653
|
+
])
|
|
2654
|
+
])) : g.status === "error" ? (c(), d("span", Ot, "โ")) : g.status === "success" ? (c(), d("span", Nt, "โ")) : K("", !0)
|
|
2655
|
+
], 2)),
|
|
2656
|
+
f("span", {
|
|
2657
|
+
class: u(s(a).e("file-actions"))
|
|
2658
|
+
}, [
|
|
2659
|
+
g.url ? (c(), d("span", Kt, "๐๏ธ")) : K("", !0),
|
|
2660
|
+
f("span", {
|
|
2661
|
+
class: "action-remove",
|
|
2662
|
+
onClick: (o) => I(g)
|
|
2663
|
+
}, "๐๏ธ", 8, Xt)
|
|
2664
|
+
], 2)
|
|
2665
|
+
], 2))), 128)),
|
|
2666
|
+
w.value ? (c(), d("li", {
|
|
2667
|
+
key: 0,
|
|
2668
|
+
class: u(s(a).e("upload-card")),
|
|
2669
|
+
onClick: H
|
|
2670
|
+
}, [
|
|
2671
|
+
le(D.$slots, "trigger", {}, () => [
|
|
2672
|
+
$[1] || ($[1] = f("span", { class: "upload-icon" }, "+", -1))
|
|
2673
|
+
])
|
|
2674
|
+
], 2)) : K("", !0)
|
|
2675
|
+
], 2)) : (c(), d(j, { key: 2 }, [
|
|
2676
|
+
f("div", {
|
|
2677
|
+
class: u(s(a).e("trigger-wrapper")),
|
|
2678
|
+
onClick: H
|
|
2679
|
+
}, [
|
|
2680
|
+
le(D.$slots, "trigger", {}, () => [
|
|
2681
|
+
w.value ? (c(), d("button", {
|
|
2682
|
+
key: 0,
|
|
2683
|
+
type: "button",
|
|
2684
|
+
class: u(s(a).e("trigger")),
|
|
2685
|
+
disabled: n.disabled
|
|
2686
|
+
}, [
|
|
2687
|
+
le(D.$slots, "default", {}, () => [
|
|
2688
|
+
$[2] || ($[2] = ve("็นๅปไธไผ ", -1))
|
|
2689
|
+
])
|
|
2690
|
+
], 10, Ut)) : K("", !0)
|
|
2691
|
+
])
|
|
2692
|
+
], 2),
|
|
2693
|
+
n.showFileList && v.value.length > 0 ? (c(), d("ul", {
|
|
2694
|
+
key: 0,
|
|
2695
|
+
class: u(s(a).e("files"))
|
|
2696
|
+
}, [
|
|
2697
|
+
(c(!0), d(j, null, _(v.value, (g) => (c(), d("li", {
|
|
2698
|
+
key: g.uid,
|
|
2699
|
+
class: u([s(a).e("file"), s(a).is(`status-${g.status}`)])
|
|
2700
|
+
}, [
|
|
2701
|
+
n.listType === "text" ? (c(), d(j, { key: 0 }, [
|
|
2702
|
+
f("span", {
|
|
2703
|
+
class: u(s(a).e("file-icon"))
|
|
2704
|
+
}, E(C(g)), 3),
|
|
2705
|
+
f("span", {
|
|
2706
|
+
class: u(s(a).e("file-name"))
|
|
2707
|
+
}, E(g.name), 3),
|
|
2708
|
+
f("span", {
|
|
2709
|
+
class: u(s(a).e("file-size"))
|
|
2710
|
+
}, E(Z(g.size)), 3),
|
|
2711
|
+
g.status === "uploading" ? (c(), d("span", {
|
|
2712
|
+
key: 0,
|
|
2713
|
+
class: u(s(a).e("file-progress"))
|
|
2714
|
+
}, [
|
|
2715
|
+
f("span", {
|
|
2716
|
+
class: "progress-bar",
|
|
2717
|
+
style: ae({ width: g.percentage + "%" })
|
|
2718
|
+
}, null, 4),
|
|
2719
|
+
f("span", Wt, E(Math.round(g.percentage || 0)) + "%", 1)
|
|
2720
|
+
], 2)) : K("", !0),
|
|
2721
|
+
g.status === "success" ? (c(), d("span", {
|
|
2722
|
+
key: 1,
|
|
2723
|
+
class: u(s(a).e("file-success"))
|
|
2724
|
+
}, "โ", 2)) : K("", !0),
|
|
2725
|
+
g.status === "error" ? (c(), d("span", {
|
|
2726
|
+
key: 2,
|
|
2727
|
+
class: u(s(a).e("file-error"))
|
|
2728
|
+
}, "โ", 2)) : K("", !0),
|
|
2729
|
+
f("span", {
|
|
2730
|
+
class: u(s(a).e("file-actions"))
|
|
2731
|
+
}, [
|
|
2732
|
+
f("span", {
|
|
2733
|
+
class: "action-remove",
|
|
2734
|
+
onClick: (o) => I(g)
|
|
2735
|
+
}, "โ", 8, Gt)
|
|
2736
|
+
], 2)
|
|
2737
|
+
], 64)) : n.listType === "picture" ? (c(), d(j, { key: 1 }, [
|
|
2738
|
+
g.thumbUrl ? (c(), d("img", {
|
|
2739
|
+
key: 0,
|
|
2740
|
+
src: g.thumbUrl,
|
|
2741
|
+
class: u(s(a).e("file-thumb"))
|
|
2742
|
+
}, null, 10, qt)) : (c(), d("span", {
|
|
2743
|
+
key: 1,
|
|
2744
|
+
class: u(s(a).e("file-icon"))
|
|
2745
|
+
}, E(C(g)), 3)),
|
|
2746
|
+
f("div", {
|
|
2747
|
+
class: u(s(a).e("file-info"))
|
|
2748
|
+
}, [
|
|
2749
|
+
f("span", {
|
|
2750
|
+
class: u(s(a).e("file-name"))
|
|
2751
|
+
}, E(g.name), 3),
|
|
2752
|
+
g.status === "uploading" ? (c(), d("span", {
|
|
2753
|
+
key: 0,
|
|
2754
|
+
class: u(s(a).e("file-progress"))
|
|
2755
|
+
}, [
|
|
2756
|
+
f("span", {
|
|
2757
|
+
class: "progress-bar",
|
|
2758
|
+
style: ae({ width: g.percentage + "%" })
|
|
2759
|
+
}, null, 4)
|
|
2760
|
+
], 2)) : K("", !0)
|
|
2761
|
+
], 2),
|
|
2762
|
+
f("span", {
|
|
2763
|
+
class: u(s(a).e("file-actions"))
|
|
2764
|
+
}, [
|
|
2765
|
+
g.status === "success" ? (c(), d("span", jt, "โ")) : K("", !0),
|
|
2766
|
+
f("span", {
|
|
2767
|
+
class: "action-remove",
|
|
2768
|
+
onClick: (o) => I(g)
|
|
2769
|
+
}, "โ", 8, Zt)
|
|
2770
|
+
], 2)
|
|
2771
|
+
], 64)) : K("", !0)
|
|
2772
|
+
], 2))), 128))
|
|
2773
|
+
], 2)) : K("", !0)
|
|
2774
|
+
], 64)),
|
|
2775
|
+
f("input", {
|
|
2776
|
+
ref_key: "inputRef",
|
|
2777
|
+
ref: y,
|
|
2778
|
+
type: "file",
|
|
2779
|
+
class: u(s(a).e("input")),
|
|
2780
|
+
multiple: n.multiple,
|
|
2781
|
+
accept: n.accept,
|
|
2782
|
+
disabled: n.disabled,
|
|
2783
|
+
onChange: S
|
|
2784
|
+
}, null, 42, Qt),
|
|
2785
|
+
D.$slots.tip ? (c(), d("div", {
|
|
2786
|
+
key: 3,
|
|
2787
|
+
class: u(s(a).e("tip"))
|
|
2788
|
+
}, [
|
|
2789
|
+
le(D.$slots, "tip")
|
|
2790
|
+
], 2)) : K("", !0)
|
|
2791
|
+
], 2));
|
|
2792
|
+
}
|
|
2793
|
+
}), Jt = ["onMousemove", "onClick"], bl = /* @__PURE__ */ Q({
|
|
2794
|
+
name: "XRate",
|
|
2795
|
+
__name: "index",
|
|
2796
|
+
props: {
|
|
2797
|
+
modelValue: { default: 0 },
|
|
2798
|
+
max: { default: 5 },
|
|
2799
|
+
disabled: { type: Boolean, default: !1 },
|
|
2800
|
+
readonly: { type: Boolean, default: !1 },
|
|
2801
|
+
allowHalf: { type: Boolean, default: !1 },
|
|
2802
|
+
lowThreshold: { default: 2 },
|
|
2803
|
+
highThreshold: { default: 4 },
|
|
2804
|
+
colors: { default: () => ["#F7BA2A", "#F7BA2A", "#F7BA2A"] },
|
|
2805
|
+
voidColor: { default: "#C6D1DE" },
|
|
2806
|
+
disabledVoidColor: { default: "#EFF2F7" },
|
|
2807
|
+
icon: { default: "โ
" },
|
|
2808
|
+
voidIcon: { default: "โ
" },
|
|
2809
|
+
disabledVoidIcon: { default: "โ
" },
|
|
2810
|
+
showText: { type: Boolean, default: !1 },
|
|
2811
|
+
showScore: { type: Boolean, default: !1 },
|
|
2812
|
+
textColor: { default: "#1F2D3D" },
|
|
2813
|
+
texts: { default: () => ["ๆๅทฎ", "ๅคฑๆ", "ไธ่ฌ", "ๆปกๆ", "ๆๅ"] },
|
|
2814
|
+
scoreTemplate: { default: "{value}" },
|
|
2815
|
+
size: { default: "default" }
|
|
2816
|
+
},
|
|
2817
|
+
emits: ["update:modelValue", "change"],
|
|
2818
|
+
setup(n, { emit: p }) {
|
|
2819
|
+
const e = n, t = p, l = J("rate"), a = A(-1), y = h(() => a.value > -1 ? a.value : e.modelValue), v = h(() => [
|
|
2820
|
+
l.b(),
|
|
2821
|
+
l.m(e.size),
|
|
2822
|
+
l.is("disabled", e.disabled),
|
|
2823
|
+
l.is("readonly", e.readonly)
|
|
2824
|
+
]), V = (r) => e.disabled ? e.disabledVoidColor : r <= e.lowThreshold ? e.colors[0] : r <= e.highThreshold ? e.colors[1] || e.colors[0] : e.colors[2] || e.colors[1] || e.colors[0], x = (r) => {
|
|
2825
|
+
const k = y.value;
|
|
2826
|
+
return k >= r ? 100 : e.allowHalf && k >= r - 0.5 ? 50 : 0;
|
|
2827
|
+
}, F = (r) => x(r) > 0 ? V(y.value) : e.disabled ? e.disabledVoidColor : e.voidColor, C = h(() => {
|
|
2828
|
+
if (e.showScore)
|
|
2829
|
+
return e.scoreTemplate.replace("{value}", String(e.modelValue));
|
|
2830
|
+
if (e.showText) {
|
|
2831
|
+
const r = Math.min(Math.ceil(e.modelValue || 0), e.max) - 1;
|
|
2832
|
+
return e.texts[Math.max(0, r)] || "";
|
|
2833
|
+
}
|
|
2834
|
+
return "";
|
|
2835
|
+
}), w = (r, k) => {
|
|
2836
|
+
if (!(e.disabled || e.readonly))
|
|
2837
|
+
if (e.allowHalf) {
|
|
2838
|
+
const B = k.currentTarget.getBoundingClientRect(), I = k.clientX - B.left < B.width / 2;
|
|
2839
|
+
a.value = I ? r - 0.5 : r;
|
|
2840
|
+
} else
|
|
2841
|
+
a.value = r;
|
|
2842
|
+
}, b = () => {
|
|
2843
|
+
e.disabled || e.readonly || (a.value = -1);
|
|
2844
|
+
}, S = (r, k) => {
|
|
2845
|
+
if (e.disabled || e.readonly) return;
|
|
2846
|
+
let M;
|
|
2847
|
+
if (e.allowHalf) {
|
|
2848
|
+
const I = k.currentTarget.getBoundingClientRect();
|
|
2849
|
+
M = k.clientX - I.left < I.width / 2 ? r - 0.5 : r;
|
|
2850
|
+
} else
|
|
2851
|
+
M = r;
|
|
2852
|
+
t("update:modelValue", M), t("change", M);
|
|
2853
|
+
};
|
|
2854
|
+
return (r, k) => (c(), d("div", {
|
|
2855
|
+
class: u(v.value),
|
|
2856
|
+
onMouseleave: b
|
|
2857
|
+
}, [
|
|
2858
|
+
f("div", {
|
|
2859
|
+
class: u(s(l).e("items"))
|
|
2860
|
+
}, [
|
|
2861
|
+
(c(!0), d(j, null, _(n.max, (M) => (c(), d("span", {
|
|
2862
|
+
key: M,
|
|
2863
|
+
class: u(s(l).e("item")),
|
|
2864
|
+
onMousemove: (B) => w(M, B),
|
|
2865
|
+
onClick: (B) => S(M, B)
|
|
2866
|
+
}, [
|
|
2867
|
+
f("span", {
|
|
2868
|
+
class: u(s(l).e("void")),
|
|
2869
|
+
style: ae({ color: n.disabled ? n.disabledVoidColor : n.voidColor })
|
|
2870
|
+
}, E(n.disabled ? n.disabledVoidIcon : n.voidIcon), 7),
|
|
2871
|
+
f("span", {
|
|
2872
|
+
class: u([s(l).e("fill"), x(M) > 0 ? "is-active" : ""]),
|
|
2873
|
+
style: ae({
|
|
2874
|
+
color: F(M),
|
|
2875
|
+
clipPath: `inset(0 ${100 - x(M)}% 0 0)`
|
|
2876
|
+
})
|
|
2877
|
+
}, E(n.icon), 7)
|
|
2878
|
+
], 42, Jt))), 128))
|
|
2879
|
+
], 2),
|
|
2880
|
+
n.showText || n.showScore ? (c(), d("div", {
|
|
2881
|
+
key: 0,
|
|
2882
|
+
class: u(s(l).e("text")),
|
|
2883
|
+
style: ae({ color: n.textColor })
|
|
2884
|
+
}, E(C.value), 7)) : K("", !0)
|
|
2885
|
+
], 34));
|
|
2886
|
+
}
|
|
2887
|
+
});
|
|
2888
|
+
export {
|
|
2889
|
+
rl as Checkbox,
|
|
2890
|
+
il as CheckboxGroup,
|
|
2891
|
+
vl as DatePicker,
|
|
2892
|
+
cl as Form,
|
|
2893
|
+
dl as FormItem,
|
|
2894
|
+
tl as Input,
|
|
2895
|
+
ll as InputNumber,
|
|
2896
|
+
sl as Radio,
|
|
2897
|
+
ol as RadioButton,
|
|
2898
|
+
ul as RadioGroup,
|
|
2899
|
+
bl as Rate,
|
|
2900
|
+
ml as Select,
|
|
2901
|
+
hl as Slider,
|
|
2902
|
+
nl as Switch,
|
|
2903
|
+
al as Textarea,
|
|
2904
|
+
fl as TimePicker,
|
|
2905
|
+
pl as Transfer,
|
|
2906
|
+
gl as Upload
|
|
2907
|
+
};
|