@mcistudio/unoui-vue 1.1.0 → 1.2.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.
Files changed (65) hide show
  1. package/dist/button/index.js +1 -1
  2. package/dist/checkbox/index.js +1 -1
  3. package/dist/chunks/{ImageEditor-CahA7Ut7.js → ImageEditor-DRoD50TJ.js} +2 -2
  4. package/dist/chunks/{ImageEditor-CahA7Ut7.js.map → ImageEditor-DRoD50TJ.js.map} +1 -1
  5. package/dist/chunks/{Table-DhXmuKQd.js → Table-QvmJFoxl.js} +3 -3
  6. package/dist/chunks/{Table-DhXmuKQd.js.map → Table-QvmJFoxl.js.map} +1 -1
  7. package/dist/chunks/{button-pDObrN_X.js → button-BBFPr3FH.js} +34 -33
  8. package/dist/chunks/{button-pDObrN_X.js.map → button-BBFPr3FH.js.map} +1 -1
  9. package/dist/chunks/{checkbox-9_0oR4kg.js → checkbox-wJpQHCeN.js} +2 -2
  10. package/dist/chunks/{checkbox-9_0oR4kg.js.map → checkbox-wJpQHCeN.js.map} +1 -1
  11. package/dist/chunks/{colorpicker-CcizUCQv.js → colorpicker-B-kSQ2Gh.js} +154 -158
  12. package/dist/chunks/colorpicker-B-kSQ2Gh.js.map +1 -0
  13. package/dist/chunks/control-BIl2ynWn.js +10 -0
  14. package/dist/chunks/control-BIl2ynWn.js.map +1 -0
  15. package/dist/chunks/datepicker-XNgIvgTe.js +1411 -0
  16. package/dist/chunks/datepicker-XNgIvgTe.js.map +1 -0
  17. package/dist/chunks/{dropdown-0l967g7D.js → dropdown-B4XuqfaI.js} +4 -4
  18. package/dist/chunks/dropdown-B4XuqfaI.js.map +1 -0
  19. package/dist/chunks/{form-Qeqkd-HH.js → form-CVJ4YMWA.js} +7 -7
  20. package/dist/chunks/{form-Qeqkd-HH.js.map → form-CVJ4YMWA.js.map} +1 -1
  21. package/dist/chunks/input-hIYHtcTj.js +1272 -0
  22. package/dist/chunks/input-hIYHtcTj.js.map +1 -0
  23. package/dist/chunks/{pagination-Bc583AQX.js → pagination-xntyuczw.js} +38 -56
  24. package/dist/chunks/pagination-xntyuczw.js.map +1 -0
  25. package/dist/chunks/{popconfirm-D6lUfSxG.js → popconfirm-DWmeebIf.js} +2 -2
  26. package/dist/chunks/{popconfirm-D6lUfSxG.js.map → popconfirm-DWmeebIf.js.map} +1 -1
  27. package/dist/chunks/{radio-DnYm59xH.js → radio-DGt8o-UL.js} +12 -12
  28. package/dist/chunks/{radio-DnYm59xH.js.map → radio-DGt8o-UL.js.map} +1 -1
  29. package/dist/chunks/select-eZ9h_f58.js +462 -0
  30. package/dist/chunks/select-eZ9h_f58.js.map +1 -0
  31. package/dist/chunks/{switch-BULGbODP.js → switch-C6a6ga2G.js} +2 -2
  32. package/dist/chunks/{switch-BULGbODP.js.map → switch-C6a6ga2G.js.map} +1 -1
  33. package/dist/chunks/{timepicker-DsGIdcf8.js → timepicker-BU9TRvFI.js} +326 -329
  34. package/dist/chunks/{timepicker-DsGIdcf8.js.map → timepicker-BU9TRvFI.js.map} +1 -1
  35. package/dist/colorpicker/index.d.ts +4 -0
  36. package/dist/colorpicker/index.js +2 -2
  37. package/dist/control.d.ts +6 -0
  38. package/dist/datepicker/index.js +1 -1
  39. package/dist/dropdown/index.js +1 -1
  40. package/dist/form/index.js +1 -1
  41. package/dist/imageeditor/index.js +1 -1
  42. package/dist/index.js +31 -31
  43. package/dist/input/index.d.ts +4 -0
  44. package/dist/input/index.js +2 -2
  45. package/dist/modal/Modal.vue.d.ts +1 -1
  46. package/dist/pagination/index.js +1 -1
  47. package/dist/popconfirm/index.js +1 -1
  48. package/dist/radio/index.js +1 -1
  49. package/dist/select/index.js +1 -1
  50. package/dist/style.css +1 -1
  51. package/dist/switch/index.js +1 -1
  52. package/dist/table/index.js +1 -1
  53. package/dist/timepicker/index.js +1 -1
  54. package/dist/uno.js +1 -0
  55. package/dist/uno.js.map +1 -1
  56. package/package.json +1 -1
  57. package/dist/chunks/colorpicker-CcizUCQv.js.map +0 -1
  58. package/dist/chunks/datepicker-Cy808x7X.js +0 -1414
  59. package/dist/chunks/datepicker-Cy808x7X.js.map +0 -1
  60. package/dist/chunks/dropdown-0l967g7D.js.map +0 -1
  61. package/dist/chunks/input-BDOXVCrK.js +0 -1281
  62. package/dist/chunks/input-BDOXVCrK.js.map +0 -1
  63. package/dist/chunks/pagination-Bc583AQX.js.map +0 -1
  64. package/dist/chunks/select-ChTfQM5u.js +0 -417
  65. package/dist/chunks/select-ChTfQM5u.js.map +0 -1
@@ -0,0 +1,1272 @@
1
+ import { t as e } from "./control-BIl2ynWn.js";
2
+ import { r as t } from "./button-BBFPr3FH.js";
3
+ import { t as n } from "./_plugin-vue_export-helper-B3ysoDQm.js";
4
+ import { getUiAttrStyle as r } from "../attrs.js";
5
+ import { getUnoUILanguageOption as i, normalizeUnoUILanguages as a, useUnoUIConfig as o } from "../config.js";
6
+ import { t as s } from "./dropdown-B4XuqfaI.js";
7
+ import { t as c } from "./modal-D6l1iIvE.js";
8
+ import { n as l } from "./tag-BYmNsrZC.js";
9
+ import { cva as u } from "class-variance-authority";
10
+ import { Fragment as d, computed as f, createBlock as p, createCommentVNode as m, createElementBlock as h, createElementVNode as g, createSlots as _, createTextVNode as v, createVNode as y, defineComponent as b, mergeProps as ee, nextTick as x, normalizeClass as S, normalizeStyle as C, onUnmounted as w, openBlock as T, ref as E, renderList as D, renderSlot as O, toDisplayString as k, unref as A, useAttrs as te, useSlots as j, useTemplateRef as M, watch as ne, withCtx as N, withModifiers as P } from "vue";
11
+ import { clsx as F } from "clsx";
12
+ import { useI18n as I } from "vue-i18n";
13
+ //#region src/input/Input.vue?vue&type=script&setup=true&lang.ts
14
+ var L = {
15
+ key: 2,
16
+ class: "text-xs"
17
+ }, R = [
18
+ "name",
19
+ "value",
20
+ "rows",
21
+ "maxlength",
22
+ "placeholder",
23
+ "disabled",
24
+ "readonly",
25
+ "autocomplete"
26
+ ], re = {
27
+ key: 2,
28
+ class: "relative min-w-0 flex-auto self-stretch"
29
+ }, z = [
30
+ "name",
31
+ "type",
32
+ "value",
33
+ "step",
34
+ "min",
35
+ "max",
36
+ "maxlength",
37
+ "placeholder",
38
+ "disabled",
39
+ "readonly",
40
+ "autocomplete"
41
+ ], B = {
42
+ key: 3,
43
+ class: "flex shrink-0 items-center gap-1 pr-2 text-tertiary"
44
+ }, V = {
45
+ key: 1,
46
+ class: "text-xs"
47
+ }, H = {
48
+ key: 2,
49
+ class: "whitespace-nowrap text-[10px] text-tertiary/70"
50
+ }, U = ["aria-label", "disabled"], ie = {
51
+ key: 0,
52
+ class: "mt-1 text-right text-[10px] text-tertiary/70"
53
+ }, W = /*#__PURE__*/ n(/* @__PURE__ */ b({
54
+ inheritAttrs: !1,
55
+ __name: "Input",
56
+ props: {
57
+ modelValue: { default: "" },
58
+ type: { default: "text" },
59
+ size: { default: "md" },
60
+ disabled: {
61
+ type: Boolean,
62
+ default: !1
63
+ },
64
+ placeholder: { default: "" },
65
+ prefixIcon: { default: "" },
66
+ suffixIcon: { default: "" },
67
+ prefix: { default: "" },
68
+ suffix: { default: "" },
69
+ password: {
70
+ type: Boolean,
71
+ default: !1
72
+ },
73
+ showPassword: {
74
+ type: Boolean,
75
+ default: !1
76
+ },
77
+ clearable: {
78
+ type: Boolean,
79
+ default: !1
80
+ },
81
+ clearIcon: { default: "i-lucide:x" },
82
+ rows: { default: void 0 },
83
+ multiline: {
84
+ type: Boolean,
85
+ default: !1
86
+ },
87
+ maxlength: { default: void 0 },
88
+ showWordLimit: {
89
+ type: Boolean,
90
+ default: !1
91
+ },
92
+ formatter: {
93
+ type: Function,
94
+ default: void 0
95
+ },
96
+ parser: {
97
+ type: Function,
98
+ default: void 0
99
+ },
100
+ precision: { default: void 0 },
101
+ step: { default: 1 },
102
+ min: { default: void 0 },
103
+ max: { default: void 0 },
104
+ draggable: {
105
+ type: Boolean,
106
+ default: !1
107
+ },
108
+ dragIcon: { default: "i-lucide:grip-horizontal" },
109
+ dragStep: { default: void 0 },
110
+ name: { default: void 0 },
111
+ autocomplete: { default: void 0 },
112
+ readonly: {
113
+ type: Boolean,
114
+ default: !1
115
+ },
116
+ modelModifiers: {}
117
+ },
118
+ emits: [
119
+ "update:modelValue",
120
+ "input",
121
+ "change",
122
+ "clear",
123
+ "focus",
124
+ "blur",
125
+ "keydown",
126
+ "drag-start",
127
+ "drag-end"
128
+ ],
129
+ setup(e, { expose: t, emit: n }) {
130
+ let r = e, i = n, a = te(), o = j(), s = M("controlRef"), c = E(!1), l = E(!1), u = E(!1), p = E(null), _ = !!o.prepend, v = !!o.append, y = () => r.multiline || r.rows !== void 0, b = () => !y() && r.type === "number", D = () => r.password || r.showPassword || r.type === "password", N = () => r.showWordLimit && r.maxlength !== void 0, I = () => N() && !y(), W = () => r.clearable && !r.disabled && !r.readonly && G.value.length > 0, ae = () => !!o.prefix || !!r.prefix || !!r.prefixIcon || b() && r.draggable, oe = () => !!o.suffix || !!r.suffix || !!r.suffixIcon || D() || W() || I(), G = f(() => r.modelValue === void 0 || r.modelValue === null ? "" : String(r.modelValue)), K = f(() => r.formatter ? r.formatter(G.value) : G.value), q = f(() => b() && p.value !== null ? p.value : K.value), se = f(() => G.value.length), ce = f(() => {
131
+ if (!y()) return D() ? l.value ? "text" : "password" : r.type;
132
+ }), le = () => F(a.class), ue = () => a.style, de = () => {
133
+ let { class: e, style: t, ...n } = a;
134
+ return n;
135
+ }, fe = f(() => F(le(), _e({
136
+ size: r.size,
137
+ focused: c.value,
138
+ disabled: r.disabled,
139
+ multiline: y()
140
+ }), _ && "-ml-px rounded-l-none", v && "-mr-px rounded-r-none")), pe = () => F(Z({
141
+ size: r.size,
142
+ multiline: y(),
143
+ number: b()
144
+ }), !y() && "absolute inset-0 w-full"), J = (e) => {
145
+ if (e === void 0 || e === "") return;
146
+ let t = Number(e);
147
+ return Number.isFinite(t) ? t : void 0;
148
+ }, me = () => J(r.min), he = () => J(r.max), Y = () => J(r.step) ?? 1, ge = () => r.dragStep ?? Y(), ye = (e) => {
149
+ let t = String(e), n = t.match(/e-(\d+)$/i);
150
+ return n ? Number(n[1]) : t.includes(".") && t.split(".")[1]?.length || 0;
151
+ }, be = (e) => {
152
+ let t = e, n = me(), r = he();
153
+ return n !== void 0 && (t = Math.max(n, t)), r !== void 0 && (t = Math.min(r, t)), t;
154
+ }, xe = (e) => {
155
+ let t = r.precision ?? ye(Y());
156
+ return Number(be(e).toFixed(t));
157
+ }, Se = () => b() && (r.modelModifiers?.number || typeof r.modelValue == "number"), Ce = (e) => {
158
+ let t = xe(e);
159
+ return Se() ? t : r.precision === void 0 ? String(t) : t.toFixed(r.precision);
160
+ }, $ = (e) => {
161
+ let t = r.modelModifiers?.trim ? e.trim() : e, n = r.parser ? r.parser(t) : t;
162
+ if (!b()) return n;
163
+ if (n === "") return "";
164
+ let i = Number(n);
165
+ return Number.isFinite(i) ? Ce(i) : n;
166
+ }, we = async () => {
167
+ await x();
168
+ let e = s.value;
169
+ e && e.value !== K.value && (e.value = K.value);
170
+ };
171
+ ne(K, () => {
172
+ c.value && p.value !== null || u.value || we();
173
+ });
174
+ let Te = (e, t) => {
175
+ i("update:modelValue", e), i("input", e, t);
176
+ }, Ee = (e) => {
177
+ !b() || r.disabled || r.readonly || !e.data?.includes("。") || (e.preventDefault(), document.execCommand("insertText", !1, e.data.replaceAll("。", ".")));
178
+ }, De = (e) => {
179
+ if (r.disabled) return;
180
+ let t = e.target;
181
+ if (b() && t.tagName === "INPUT" && (p.value = t.value), u.value) {
182
+ i("input", $(t.value), e);
183
+ return;
184
+ }
185
+ Te($(t.value), e);
186
+ }, Oe = (e) => {
187
+ r.disabled || i("change", $(e.target.value), e);
188
+ }, ke = (e) => {
189
+ c.value = !0, i("focus", e);
190
+ }, Ae = (e) => {
191
+ c.value = !1, p.value = null, i("blur", e), we();
192
+ }, je = () => {
193
+ u.value = !0;
194
+ }, Me = (e) => {
195
+ u.value = !1;
196
+ let t = e.target;
197
+ b() && t.tagName === "INPUT" && (p.value = t.value), Te($(t.value), e);
198
+ }, Ne = () => {
199
+ r.disabled || r.readonly || (p.value = null, i("update:modelValue", ""), i("input", "", new Event("input")), i("clear"), we(), s.value?.focus());
200
+ }, Pe = () => s.value?.focus(), Fe = () => s.value?.blur(), Ie = () => s.value?.select(), Le = null, Re = () => {
201
+ window.removeEventListener("pointermove", Ve), window.removeEventListener("pointerup", He), window.removeEventListener("pointercancel", He);
202
+ }, ze = () => {
203
+ let e = J(r.modelValue);
204
+ return e === void 0 ? J($(s.value?.value || "")) ?? 0 : e;
205
+ }, Be = (e, t) => {
206
+ let n = xe(e), r = Ce(n);
207
+ p.value = null, Le && (Le.lastValue = n), i("update:modelValue", r), i("input", r, t);
208
+ };
209
+ function Ve(e) {
210
+ let t = Le;
211
+ if (!t || e.pointerId !== t.pointerId) return;
212
+ e.preventDefault();
213
+ let n = e.clientX - t.startX;
214
+ Be(t.startValue + n * ge(), e);
215
+ }
216
+ function He(e) {
217
+ let t = Le;
218
+ if (!t || e.pointerId !== t.pointerId) return;
219
+ e.preventDefault(), Re(), Le = null;
220
+ let n = t.lastValue;
221
+ i("change", Ce(n), e), i("drag-end", n, e);
222
+ }
223
+ let Ue = (e) => {
224
+ if (!b() || !r.draggable || r.disabled || r.readonly || e.button !== 0) return;
225
+ e.preventDefault(), Re();
226
+ let t = ze();
227
+ Le = {
228
+ pointerId: e.pointerId,
229
+ startX: e.clientX,
230
+ startValue: t,
231
+ lastValue: t
232
+ }, e.currentTarget?.setPointerCapture?.(e.pointerId), i("drag-start", t, e), window.addEventListener("pointermove", Ve), window.addEventListener("pointerup", He), window.addEventListener("pointercancel", He);
233
+ };
234
+ return w(() => {
235
+ Re();
236
+ }), t({
237
+ blur: Fe,
238
+ clear: Ne,
239
+ focus: Pe,
240
+ select: Ie
241
+ }), (t, n) => (T(), h(d, null, [g("div", { class: S(A(ve)({
242
+ size: e.size,
243
+ multiline: y()
244
+ })) }, [
245
+ _ ? (T(), h("div", {
246
+ key: 0,
247
+ class: S(A(Q)({
248
+ position: "prepend",
249
+ size: e.size,
250
+ disabled: e.disabled
251
+ }))
252
+ }, [O(t.$slots, "prepend", {}, void 0, !0)], 2)) : m("", !0),
253
+ g("div", {
254
+ class: S(fe.value),
255
+ style: C(ue()),
256
+ "data-ui-input": "true"
257
+ }, [
258
+ ae() ? (T(), h("span", {
259
+ key: 0,
260
+ class: S(["flex shrink-0 items-center gap-1 pl-2 text-tertiary", { "cursor-ew-resize select-none": b() && e.draggable && !e.disabled && !e.readonly }]),
261
+ onPointerdown: Ue
262
+ }, [
263
+ b() && e.draggable ? (T(), h("span", {
264
+ key: 0,
265
+ class: S([e.dragIcon, "size-4"])
266
+ }, null, 2)) : m("", !0),
267
+ e.prefixIcon ? (T(), h("span", {
268
+ key: 1,
269
+ class: S([e.prefixIcon, "size-4"])
270
+ }, null, 2)) : m("", !0),
271
+ e.prefix ? (T(), h("span", L, k(e.prefix), 1)) : m("", !0),
272
+ O(t.$slots, "prefix", {}, void 0, !0)
273
+ ], 34)) : m("", !0),
274
+ y() ? (T(), h("textarea", ee({
275
+ key: 1,
276
+ ref_key: "controlRef",
277
+ ref: s
278
+ }, de(), {
279
+ "data-ui-input-control": "true",
280
+ name: e.name,
281
+ value: K.value,
282
+ rows: e.rows,
283
+ maxlength: e.maxlength,
284
+ placeholder: e.placeholder,
285
+ disabled: e.disabled,
286
+ readonly: e.readonly,
287
+ autocomplete: e.autocomplete,
288
+ class: pe(),
289
+ onInput: De,
290
+ onChange: Oe,
291
+ onFocus: ke,
292
+ onBlur: Ae,
293
+ onKeydown: n[0] ||= (e) => i("keydown", e),
294
+ onCompositionstart: je,
295
+ onCompositionend: Me
296
+ }), null, 16, R)) : (T(), h("span", re, [g("span", {
297
+ "aria-hidden": "true",
298
+ class: S(A(X)({ size: e.size }))
299
+ }, "x", 2), g("input", ee({
300
+ ref_key: "controlRef",
301
+ ref: s
302
+ }, de(), {
303
+ "data-ui-input-control": "true",
304
+ name: e.name,
305
+ type: ce.value,
306
+ value: q.value,
307
+ step: b() ? e.step : void 0,
308
+ min: b() ? e.min : void 0,
309
+ max: b() ? e.max : void 0,
310
+ maxlength: e.maxlength,
311
+ placeholder: e.placeholder,
312
+ disabled: e.disabled,
313
+ readonly: e.readonly,
314
+ autocomplete: e.autocomplete,
315
+ class: pe(),
316
+ onBeforeinput: Ee,
317
+ onInput: De,
318
+ onChange: Oe,
319
+ onFocus: ke,
320
+ onBlur: Ae,
321
+ onKeydown: n[1] ||= (e) => i("keydown", e),
322
+ onCompositionstart: je,
323
+ onCompositionend: Me
324
+ }), null, 16, z)])),
325
+ oe() ? (T(), h("span", B, [
326
+ O(t.$slots, "suffix", {}, void 0, !0),
327
+ e.suffixIcon ? (T(), h("span", {
328
+ key: 0,
329
+ class: S([e.suffixIcon, "size-4"])
330
+ }, null, 2)) : m("", !0),
331
+ e.suffix ? (T(), h("span", V, k(e.suffix), 1)) : m("", !0),
332
+ I() ? (T(), h("span", H, k(se.value) + " / " + k(e.maxlength), 1)) : m("", !0),
333
+ W() ? (T(), h("button", {
334
+ key: 3,
335
+ type: "button",
336
+ "aria-label": "清空",
337
+ class: "flex size-4 items-center justify-center rounded-full bg-tertiary/90 text-tertiary/60 opacity-0 transition-all duration-150 hover:bg-tertiary hover:text-tertiary group-hover/ui-input:opacity-100 group-focus-within/ui-input:opacity-100",
338
+ onClick: P(Ne, ["stop"])
339
+ }, [g("span", { class: S([e.clearIcon, "size-3"]) }, null, 2)])) : m("", !0),
340
+ D() ? (T(), h("button", {
341
+ key: 4,
342
+ type: "button",
343
+ "aria-label": l.value ? "隐藏密码" : "显示密码",
344
+ class: "flex size-5 items-center justify-center rounded text-tertiary transition-colors hover:bg-secondary/30 hover:text-primary disabled:cursor-not-allowed disabled:opacity-50",
345
+ disabled: e.disabled,
346
+ onClick: n[2] ||= P((e) => l.value = !l.value, ["stop"])
347
+ }, [g("span", { class: S([l.value ? "i-lucide:eye-off" : "i-lucide:eye", "size-3.5"]) }, null, 2)], 8, U)) : m("", !0)
348
+ ])) : m("", !0)
349
+ ], 6),
350
+ v ? (T(), h("div", {
351
+ key: 1,
352
+ class: S(A(Q)({
353
+ position: "append",
354
+ size: e.size,
355
+ disabled: e.disabled
356
+ }))
357
+ }, [O(t.$slots, "append", {}, void 0, !0)], 2)) : m("", !0)
358
+ ], 2), N() && y() ? (T(), h("div", ie, k(se.value) + " / " + k(e.maxlength), 1)) : m("", !0)], 64));
359
+ }
360
+ }), [["__scopeId", "data-v-6cd11edd"]]), ae = { class: "min-w-0 flex-1 truncate" }, oe = {
361
+ key: 0,
362
+ class: "border-t border-medium px-3 py-3 text-center text-sm text-tertiary"
363
+ }, G = /* @__PURE__ */ b({
364
+ inheritAttrs: !1,
365
+ __name: "Autocomplete",
366
+ props: {
367
+ modelValue: { default: "" },
368
+ dataSource: {},
369
+ valueKey: { default: "value" },
370
+ triggerOnFocus: {
371
+ type: Boolean,
372
+ default: !0
373
+ },
374
+ debounce: { default: 300 },
375
+ size: { default: "md" },
376
+ disabled: {
377
+ type: Boolean,
378
+ default: !1
379
+ },
380
+ readonly: {
381
+ type: Boolean,
382
+ default: !1
383
+ },
384
+ placeholder: { default: "" },
385
+ prefixIcon: { default: "" },
386
+ suffixIcon: { default: "" },
387
+ prefix: { default: "" },
388
+ suffix: { default: "" },
389
+ clearable: {
390
+ type: Boolean,
391
+ default: !1
392
+ },
393
+ clearIcon: { default: "i-lucide:x" },
394
+ name: { default: void 0 },
395
+ autocomplete: { default: void 0 },
396
+ teleportedWidth: { default: void 0 },
397
+ maxHeight: { default: "280px" },
398
+ hideLoading: {
399
+ type: Boolean,
400
+ default: !1
401
+ },
402
+ selectWhenUnmatched: {
403
+ type: Boolean,
404
+ default: !1
405
+ },
406
+ noDataText: { default: "暂无数据" },
407
+ loadingText: { default: "加载中" }
408
+ },
409
+ emits: [
410
+ "update:modelValue",
411
+ "input",
412
+ "change",
413
+ "clear",
414
+ "select",
415
+ "focus",
416
+ "blur",
417
+ "keydown"
418
+ ],
419
+ setup(e, { expose: t, emit: n }) {
420
+ let r = e, i = n, a = te(), o = E(!1), c = E(!1), l = E(r.modelValue), u = E([]), d = E(null), v = E(null), b = E(null), C = E("0px"), D = 0, j = 0, M = !1, F = 0, I = f(() => r.modelValue === void 0 || r.modelValue === null ? "" : String(r.modelValue)), L = f(() => r.teleportedWidth || C.value || "180px"), R = f(() => c.value && !r.hideLoading ? r.loadingText : r.noDataText);
421
+ ne(() => r.modelValue, (e) => {
422
+ l.value = e ?? "";
423
+ });
424
+ let re = async () => {
425
+ await x();
426
+ let e = d.value?.getBoundingClientRect().width;
427
+ e && (C.value = `${Math.round(e)}px`);
428
+ }, z = (e) => String(e[r.valueKey] ?? ""), B = (e) => {
429
+ if (r.disabled || r.readonly) {
430
+ o.value = !1;
431
+ return;
432
+ }
433
+ o.value = e, e && re();
434
+ }, V = (e) => {
435
+ if (r.disabled || r.readonly) return;
436
+ let t = ++j, n = (e) => {
437
+ t === j && (u.value = e, c.value = !1, B(!0));
438
+ };
439
+ if (Array.isArray(r.dataSource)) {
440
+ let t = e.trim().toLowerCase();
441
+ n(t ? r.dataSource.filter((e) => z(e).toLowerCase().includes(t)) : r.dataSource);
442
+ return;
443
+ }
444
+ c.value = !0, B(!0), r.dataSource(e, n);
445
+ }, H = (e, t = !1) => {
446
+ if (!(r.disabled || r.readonly)) {
447
+ if (D && window.clearTimeout(D), D = 0, t) {
448
+ V(e);
449
+ return;
450
+ }
451
+ D = window.setTimeout(() => {
452
+ D = 0, V(e);
453
+ }, Math.max(0, r.debounce));
454
+ }
455
+ }, U = () => {
456
+ D && window.clearTimeout(D), D = 0, j += 1, c.value = !1, o.value = !1;
457
+ }, ie = (e, t) => {
458
+ l.value = e, i("update:modelValue", e), i("input", e, t), H(String(e));
459
+ }, G = (e, t) => {
460
+ i("change", e, t);
461
+ }, K = (e) => {
462
+ if (M || Date.now() < F) {
463
+ M = !1, i("focus", e);
464
+ return;
465
+ }
466
+ r.triggerOnFocus && H(I.value), i("focus", e);
467
+ }, q = () => {
468
+ l.value = "", U(), H("", !0), i("clear");
469
+ }, se = (e) => {
470
+ if (r.disabled || r.readonly || e.disabled) return;
471
+ let t = z(e);
472
+ l.value = t, i("update:modelValue", t), i("input", t, new Event("input")), i("change", t, new Event("change")), i("select", e), U(), M = !0, F = Date.now() + 120, v.value?.focus();
473
+ }, ce = (e) => {
474
+ if (i("keydown", e), !r.disabled) {
475
+ if (o.value && [
476
+ "ArrowDown",
477
+ "ArrowUp",
478
+ "PageDown",
479
+ "PageUp"
480
+ ].includes(e.key)) {
481
+ b.value?.handleKeyDown(e);
482
+ return;
483
+ }
484
+ if (!(o.value && e.key === "Enter" && (b.value?.handleKeyDown(e), e.defaultPrevented))) {
485
+ if (e.key === "Escape") {
486
+ U();
487
+ return;
488
+ }
489
+ e.key === "Enter" && r.selectWhenUnmatched && I.value && (e.preventDefault(), i("select", { value: I.value }), U());
490
+ }
491
+ }
492
+ };
493
+ return w(U), t({
494
+ blur: () => v.value?.blur(),
495
+ clear: () => v.value?.clear(),
496
+ focus: () => v.value?.focus(),
497
+ select: () => v.value?.select()
498
+ }), (t, n) => (T(), p(A(s), {
499
+ ref_key: "dropdownRef",
500
+ ref: b,
501
+ open: o.value,
502
+ "onUpdate:open": n[2] ||= (e) => o.value = e,
503
+ items: u.value,
504
+ "value-key": "value",
505
+ width: L.value,
506
+ "max-height": e.maxHeight,
507
+ "focus-on-open": !1,
508
+ "content-class": "ui-autocomplete-dropdown",
509
+ class: "w-full",
510
+ onSelect: n[3] ||= (e) => se(e)
511
+ }, {
512
+ trigger: N(() => [g("div", {
513
+ ref_key: "triggerRef",
514
+ ref: d,
515
+ class: "w-full",
516
+ onClick: n[1] ||= P(() => {}, ["stop"])
517
+ }, [y(W, ee({
518
+ ref_key: "inputRef",
519
+ ref: v
520
+ }, A(a), {
521
+ "model-value": l.value,
522
+ size: e.size,
523
+ disabled: e.disabled,
524
+ readonly: e.readonly,
525
+ placeholder: e.placeholder,
526
+ "prefix-icon": e.prefixIcon,
527
+ "suffix-icon": e.suffixIcon,
528
+ prefix: e.prefix,
529
+ suffix: e.suffix,
530
+ clearable: e.clearable,
531
+ "clear-icon": e.clearIcon,
532
+ name: e.name,
533
+ autocomplete: e.autocomplete,
534
+ onInput: ie,
535
+ onChange: G,
536
+ onClear: q,
537
+ onFocus: K,
538
+ onBlur: n[0] ||= (e) => i("blur", e),
539
+ onKeydown: ce
540
+ }), _({ _: 2 }, [
541
+ t.$slots.prepend ? {
542
+ name: "prepend",
543
+ fn: N(() => [O(t.$slots, "prepend")]),
544
+ key: "0"
545
+ } : void 0,
546
+ t.$slots.append ? {
547
+ name: "append",
548
+ fn: N(() => [O(t.$slots, "append")]),
549
+ key: "1"
550
+ } : void 0,
551
+ t.$slots.prefix ? {
552
+ name: "prefix",
553
+ fn: N(() => [O(t.$slots, "prefix")]),
554
+ key: "2"
555
+ } : void 0,
556
+ t.$slots.suffix ? {
557
+ name: "suffix",
558
+ fn: N(() => [O(t.$slots, "suffix")]),
559
+ key: "3"
560
+ } : void 0
561
+ ]), 1040, [
562
+ "model-value",
563
+ "size",
564
+ "disabled",
565
+ "readonly",
566
+ "placeholder",
567
+ "prefix-icon",
568
+ "suffix-icon",
569
+ "prefix",
570
+ "suffix",
571
+ "clearable",
572
+ "clear-icon",
573
+ "name",
574
+ "autocomplete"
575
+ ])], 512)]),
576
+ item: N(({ item: e }) => [O(t.$slots, "suggestion", { item: e }, () => [g("div", { class: S(["flex min-h-9 cursor-pointer items-center gap-2 px-3 py-2 text-sm text-primary transition-colors hover:bg-secondary", { "pointer-events-none text-tertiary opacity-50": e.disabled }]) }, [g("span", ae, k(z(e)), 1)], 2)])]),
577
+ footer: N(() => [c.value && !e.hideLoading || u.value.length === 0 ? (T(), h("div", oe, k(R.value), 1)) : m("", !0)]),
578
+ _: 3
579
+ }, 8, [
580
+ "open",
581
+ "items",
582
+ "width",
583
+ "max-height"
584
+ ]));
585
+ }
586
+ }), K = {
587
+ key: 1,
588
+ class: "text-xs"
589
+ }, q = [
590
+ "disabled",
591
+ "title",
592
+ "aria-label"
593
+ ], se = { class: "space-y-3 p-4" }, ce = { class: "flex min-h-7 items-center justify-between gap-3" }, le = { class: "min-w-0 flex-1" }, ue = { class: "flex flex-col gap-3" }, de = ["for"], fe = {
594
+ key: 1,
595
+ class: "w-18"
596
+ }, pe = { class: "flex w-full items-center justify-center gap-3" }, J = /* @__PURE__ */ b({
597
+ inheritAttrs: !1,
598
+ __name: "InputI18n",
599
+ props: {
600
+ modelValue: { default: () => ({}) },
601
+ languages: { default: void 0 },
602
+ size: { default: "md" },
603
+ disabled: {
604
+ type: Boolean,
605
+ default: !1
606
+ },
607
+ readonly: {
608
+ type: Boolean,
609
+ default: !1
610
+ },
611
+ placeholder: { default: "" },
612
+ name: { default: void 0 },
613
+ clearable: {
614
+ type: Boolean,
615
+ default: !1
616
+ },
617
+ prefixIcon: { default: "" },
618
+ suffixIcon: { default: "" },
619
+ prefix: { default: "" },
620
+ suffix: { default: "" },
621
+ autocomplete: { default: "new-password" },
622
+ modalZIndex: { default: 2e3 }
623
+ },
624
+ emits: [
625
+ "update:modelValue",
626
+ "input",
627
+ "change",
628
+ "clear",
629
+ "focus",
630
+ "blur"
631
+ ],
632
+ setup(e, { emit: n }) {
633
+ let s = e, l = n, u = te(), { t: b } = I(), x = o(), C = E(!1), w = E({}), j = E([]), M = E(null), F = E(null), L = E(!1), R = f(() => x.languages), re = f(() => {
634
+ let e = x.locale;
635
+ return typeof e == "function" ? e() : e;
636
+ }), z = f(() => s.languages ? a(s.languages) : R.value.map((e) => e.key)), B = f(() => {
637
+ let e = String(re.value || "");
638
+ return s.languages ? z.value.includes(e) ? e : z.value[0] : e;
639
+ }), V = f(() => s.modelValue?.[B.value] || ""), H = f(() => s.disabled || u.disabled === "" || u.disabled === !0 || u.disabled === "true"), U = f(() => s.clearable && !H.value && !s.readonly && V.value.length > 0), ie = () => u.class, ae = () => {
640
+ let { class: e, style: t, disabled: n, readonly: r, ...i } = u;
641
+ return i;
642
+ }, oe = f(() => M.value ? M.value.tone === "success" ? "border-teal-500/20 bg-teal-50/60 text-teal-700 dark:border-teal-500/25 dark:bg-teal-950/20 dark:text-teal-300" : M.value.tone === "warning" ? "border-orange-400/25 bg-orange-50/60 text-orange-700 dark:border-orange-400/30 dark:bg-orange-950/20 dark:text-orange-300" : M.value.tone === "error" ? "border-rose-500/20 bg-rose-50/60 text-rose-700 dark:border-rose-500/30 dark:bg-rose-950/20 dark:text-rose-300" : "border-brand/20 bg-brand/5 text-brand dark:border-brand/30 dark:bg-brand/10 dark:text-brand-300" : ""), G = (e, t = z.value) => {
643
+ let n = {};
644
+ return t.forEach((t) => {
645
+ n[t] = e?.[t] || "";
646
+ }), Object.entries(e || {}).forEach(([e, t]) => {
647
+ e in n || (n[e] = t || "");
648
+ }), n;
649
+ }, J = (e) => i(e, R.value).label, me = () => {
650
+ let e = z.value;
651
+ j.value = [B.value, ...e.filter((e) => e !== B.value)], w.value = G(w.value);
652
+ }, he = (e, t) => {
653
+ l("update:modelValue", e), l("input", e, t);
654
+ }, Y = (e, t) => {
655
+ he(e, t), l("change", e, t);
656
+ }, ge = (e, t) => {
657
+ he({
658
+ ...G(s.modelValue),
659
+ [B.value]: String(e)
660
+ }, t);
661
+ }, _e = (e, t) => {
662
+ Y({
663
+ ...G(s.modelValue),
664
+ [B.value]: String(e)
665
+ }, t);
666
+ }, X = () => {
667
+ Y({
668
+ ...G(s.modelValue),
669
+ [B.value]: ""
670
+ }), l("clear");
671
+ }, Z = (e, t) => {
672
+ M.value = {
673
+ tone: e,
674
+ text: t
675
+ };
676
+ }, ve = () => {
677
+ H.value || (w.value = G(s.modelValue), M.value = null, C.value = !0);
678
+ }, Q = () => {
679
+ Y(w.value), C.value = !1;
680
+ }, ye = () => {
681
+ C.value = !1;
682
+ }, be = (e) => {
683
+ if (e) {
684
+ C.value = !0;
685
+ return;
686
+ }
687
+ ye();
688
+ }, xe = (e) => {
689
+ if (e instanceof Error) return e.message;
690
+ if (e && typeof e == "object") {
691
+ let t = e;
692
+ if (typeof t.data?.message == "string") return t.data.message;
693
+ if (typeof t.message == "string") return t.message;
694
+ }
695
+ return b("comp.mpInputI18n.unknownError");
696
+ }, Se = {
697
+ "zh-CN": "zh",
698
+ "zh-HK": "cht",
699
+ "zh-TW": "cht",
700
+ en: "en",
701
+ "en-US": "en",
702
+ "en-GB": "en",
703
+ ja: "jp",
704
+ ko: "kor",
705
+ ar: "ara",
706
+ fr: "fra",
707
+ de: "de",
708
+ es: "spa",
709
+ pt: "pt",
710
+ "pt-BR": "pt",
711
+ ru: "ru",
712
+ it: "it",
713
+ th: "th",
714
+ vi: "vie",
715
+ hi: "hi",
716
+ tr: "tr",
717
+ nl: "nl",
718
+ pl: "pl",
719
+ sv: "swe",
720
+ da: "dan",
721
+ fi: "fin",
722
+ cs: "cs",
723
+ hu: "hu",
724
+ ro: "rom",
725
+ el: "el"
726
+ }, Ce = (e) => i(e, R.value).baidu || Se[e] || e.split("-")[0], $ = async (e) => {
727
+ let t = w.value[B.value];
728
+ if (!t) return Z("warning", b("comp.mpInputI18n.sourceRequired")), null;
729
+ if (!x.translate) throw Error(b("comp.mpInputI18n.translateFailed"));
730
+ let n = await x.translate({
731
+ q: t,
732
+ from: Ce(B.value) || "auto",
733
+ to: Ce(e) || e
734
+ });
735
+ if (typeof n == "string") return n;
736
+ if (!n) throw Error(b("comp.mpInputI18n.translateFailed"));
737
+ if (n.text) return n.text;
738
+ if (n.trans_result?.[0]) return n.trans_result[0].dst;
739
+ throw Error(b("comp.mpInputI18n.translateFailed"));
740
+ }, we = async (e, t = !1) => {
741
+ if (F.value || L.value) return !1;
742
+ F.value = e;
743
+ try {
744
+ let n = await $(e);
745
+ return n ? (w.value[e] = n, t || Z("success", b("comp.mpInputI18n.translateSuccess", { lang: J(e) })), !0) : !1;
746
+ } catch (e) {
747
+ return Z("error", b("comp.mpInputI18n.translateFailedWithReason", { reason: xe(e) })), !1;
748
+ } finally {
749
+ F.value = null;
750
+ }
751
+ }, Te = async () => {
752
+ if (F.value || L.value) return;
753
+ if (!w.value[B.value]) {
754
+ Z("warning", b("comp.mpInputI18n.sourceRequired"));
755
+ return;
756
+ }
757
+ let e = j.value.filter((e) => e !== B.value);
758
+ L.value = !0, Z("info", b("comp.mpInputI18n.translatingAll"));
759
+ try {
760
+ for (let t of e) {
761
+ let e = await $(t);
762
+ e && (w.value[t] = e);
763
+ }
764
+ Z("success", b("comp.mpInputI18n.translateAllSuccess"));
765
+ } catch (e) {
766
+ Z("error", b("comp.mpInputI18n.translateFailedWithReason", { reason: xe(e) }));
767
+ } finally {
768
+ L.value = !1, F.value = null;
769
+ }
770
+ };
771
+ return ne([B, z], me, { immediate: !0 }), ne(() => s.modelValue, (e) => {
772
+ C.value || (w.value = G(e));
773
+ }, {
774
+ deep: !0,
775
+ immediate: !0
776
+ }), (n, i) => (T(), h(d, null, [y(W, ee(ae(), {
777
+ "data-ui-input-i18n": "true",
778
+ "model-value": V.value,
779
+ class: ie(),
780
+ style: A(r)(A(u)),
781
+ size: e.size,
782
+ disabled: H.value,
783
+ readonly: e.readonly,
784
+ placeholder: e.placeholder,
785
+ name: e.name,
786
+ clearable: !1,
787
+ "prefix-icon": e.prefixIcon,
788
+ prefix: e.prefix,
789
+ autocomplete: e.autocomplete,
790
+ dir: A(x).rtlLanguages.includes(B.value) ? "rtl" : "ltr",
791
+ onInput: ge,
792
+ onChange: _e,
793
+ onClear: X,
794
+ onFocus: i[1] ||= (e) => l("focus", e),
795
+ onBlur: i[2] ||= (e) => l("blur", e)
796
+ }), _({
797
+ suffix: N(() => [
798
+ O(n.$slots, "suffix"),
799
+ e.suffixIcon ? (T(), h("span", {
800
+ key: 0,
801
+ class: S([e.suffixIcon, "size-4"])
802
+ }, null, 2)) : m("", !0),
803
+ e.suffix ? (T(), h("span", K, k(e.suffix), 1)) : m("", !0),
804
+ U.value ? (T(), h("button", {
805
+ key: 2,
806
+ type: "button",
807
+ "aria-label": "清空",
808
+ class: "flex size-4 items-center justify-center rounded-full bg-tertiary/90 text-tertiary/60 opacity-0 transition-all duration-150 hover:bg-tertiary hover:text-tertiary group-hover/ui-input:opacity-100 group-focus-within/ui-input:opacity-100",
809
+ onClick: P(X, ["stop"])
810
+ }, [...i[3] ||= [g("span", { class: "i-lucide:x size-3" }, null, -1)]])) : m("", !0),
811
+ j.value.length > 1 ? (T(), h("button", {
812
+ key: 3,
813
+ type: "button",
814
+ class: "flex size-5 items-center justify-center rounded text-tertiary transition-colors hover:bg-secondary/30 hover:text-primary disabled:cursor-not-allowed disabled:opacity-50",
815
+ disabled: H.value,
816
+ title: A(b)("comp.mpInputI18n.editorTitle"),
817
+ "aria-label": A(b)("comp.mpInputI18n.editorTitle"),
818
+ onMousedown: i[0] ||= P(() => {}, ["prevent"]),
819
+ onClick: P(ve, ["stop"])
820
+ }, [...i[4] ||= [g("span", { class: "i-lucide:globe size-3.5" }, null, -1)]], 40, q)) : m("", !0)
821
+ ]),
822
+ _: 2
823
+ }, [
824
+ n.$slots.prepend ? {
825
+ name: "prepend",
826
+ fn: N(() => [O(n.$slots, "prepend")]),
827
+ key: "0"
828
+ } : void 0,
829
+ n.$slots.prefix ? {
830
+ name: "prefix",
831
+ fn: N(() => [O(n.$slots, "prefix")]),
832
+ key: "1"
833
+ } : void 0,
834
+ n.$slots.append ? {
835
+ name: "append",
836
+ fn: N(() => [O(n.$slots, "append")]),
837
+ key: "2"
838
+ } : void 0
839
+ ]), 1040, [
840
+ "model-value",
841
+ "class",
842
+ "style",
843
+ "size",
844
+ "disabled",
845
+ "readonly",
846
+ "placeholder",
847
+ "name",
848
+ "prefix-icon",
849
+ "prefix",
850
+ "autocomplete",
851
+ "dir"
852
+ ]), y(A(c), {
853
+ visible: C.value,
854
+ title: A(b)("comp.mpInputI18n.editorTitle"),
855
+ width: 560,
856
+ "z-index": e.modalZIndex,
857
+ "onUpdate:visible": be
858
+ }, {
859
+ icon: N(() => [...i[5] ||= [g("span", { class: "i-lucide:globe text-brand" }, null, -1)]]),
860
+ footer: N(() => [g("div", pe, [y(A(t), {
861
+ color: "gray",
862
+ variant: "mono",
863
+ size: "lg",
864
+ class: "min-w-24",
865
+ onClick: ye
866
+ }, {
867
+ default: N(() => [v(k(A(b)("common.cancel")), 1)]),
868
+ _: 1
869
+ }), y(A(t), {
870
+ size: "lg",
871
+ class: "min-w-24",
872
+ onClick: Q
873
+ }, {
874
+ default: N(() => [v(k(A(b)("common.save")), 1)]),
875
+ _: 1
876
+ })])]),
877
+ default: N(() => [g("div", se, [g("div", ce, [g("div", le, [M.value ? (T(), h("div", {
878
+ key: 0,
879
+ class: S(["truncate rounded border px-2.5 py-1.5 text-xs font-medium", oe.value])
880
+ }, k(M.value.text), 3)) : m("", !0)]), y(A(t), {
881
+ size: "sm",
882
+ variant: "outline",
883
+ loading: L.value,
884
+ disabled: !!F.value || L.value,
885
+ onClick: Te
886
+ }, {
887
+ default: N(() => [v(k(A(b)("comp.mpInputI18n.translateAll")), 1)]),
888
+ _: 1
889
+ }, 8, ["loading", "disabled"])]), g("div", ue, [(T(!0), h(d, null, D(j.value, (e) => (T(), h("div", {
890
+ key: e,
891
+ class: "grid grid-cols-1 items-center gap-2 sm:grid-cols-[96px_minmax(0,1fr)_72px]"
892
+ }, [
893
+ g("label", {
894
+ class: S(["truncate text-left text-xs font-bold text-tertiary sm:text-right", `font-${e}`]),
895
+ for: `ui-input-i18n-editor-${e}`
896
+ }, [v(k(J(e)), 1), i[6] ||= g("span", { "aria-hidden": "true" }, ":", -1)], 10, de),
897
+ y(W, {
898
+ id: `ui-input-i18n-editor-${e}`,
899
+ modelValue: w.value[e],
900
+ "onUpdate:modelValue": (t) => w.value[e] = t,
901
+ size: "sm",
902
+ class: S(`font-${e}`),
903
+ dir: A(x).rtlLanguages.includes(e) ? "rtl" : "ltr",
904
+ autocomplete: "new-password"
905
+ }, null, 8, [
906
+ "id",
907
+ "modelValue",
908
+ "onUpdate:modelValue",
909
+ "class",
910
+ "dir"
911
+ ]),
912
+ e === B.value ? (T(), h("span", fe)) : (T(), p(A(t), {
913
+ key: 0,
914
+ size: "sm",
915
+ variant: "outline",
916
+ disabled: !!F.value || L.value,
917
+ loading: F.value === e,
918
+ onClick: () => we(e)
919
+ }, {
920
+ default: N(() => [v(k(A(b)("comp.mpInputI18n.translate")), 1)]),
921
+ _: 1
922
+ }, 8, [
923
+ "disabled",
924
+ "loading",
925
+ "onClick"
926
+ ]))
927
+ ]))), 128))])])]),
928
+ _: 1
929
+ }, 8, [
930
+ "visible",
931
+ "title",
932
+ "z-index"
933
+ ])], 64));
934
+ }
935
+ }), me = {
936
+ key: 0,
937
+ class: "flex shrink-0 self-center items-center gap-1 text-tertiary"
938
+ }, he = [
939
+ "name",
940
+ "value",
941
+ "maxlength",
942
+ "placeholder",
943
+ "disabled",
944
+ "readonly",
945
+ "autocomplete"
946
+ ], Y = {
947
+ key: 1,
948
+ class: "ml-auto flex shrink-0 self-center items-center gap-1 text-tertiary"
949
+ }, ge = /* @__PURE__ */ b({
950
+ inheritAttrs: !1,
951
+ __name: "InputTag",
952
+ props: {
953
+ modelValue: { default: () => [] },
954
+ size: { default: "md" },
955
+ disabled: {
956
+ type: Boolean,
957
+ default: !1
958
+ },
959
+ readonly: {
960
+ type: Boolean,
961
+ default: !1
962
+ },
963
+ placeholder: { default: "" },
964
+ inputPlaceholder: { default: "" },
965
+ clearable: {
966
+ type: Boolean,
967
+ default: !1
968
+ },
969
+ clearIcon: { default: "i-lucide:x" },
970
+ closeIcon: { default: "i-lucide:x" },
971
+ trigger: { default: "Enter" },
972
+ delimiters: { default: () => [","] },
973
+ max: { default: void 0 },
974
+ maxlength: { default: void 0 },
975
+ validateTag: {
976
+ type: Function,
977
+ default: void 0
978
+ },
979
+ allowDuplicates: {
980
+ type: Boolean,
981
+ default: !1
982
+ },
983
+ tagColor: { default: "brand" },
984
+ tagVariant: { default: "light" },
985
+ tagRadius: { default: "md" },
986
+ name: { default: void 0 },
987
+ autocomplete: { default: void 0 }
988
+ },
989
+ emits: [
990
+ "update:modelValue",
991
+ "input",
992
+ "change",
993
+ "add-tag",
994
+ "remove-tag",
995
+ "clear",
996
+ "focus",
997
+ "blur",
998
+ "keydown"
999
+ ],
1000
+ setup(e, { expose: t, emit: n }) {
1001
+ let r = e, i = n, a = te(), o = j(), s = M("inputRef"), c = E(""), u = E(!1), _ = E(!1), y = !!o.prepend, b = !!o.append, w = () => !!o.prefix, ne = () => !!o.suffix, I = () => r.disabled || r.readonly, L = f(() => r.modelValue.filter((e) => e != null)), R = () => r.max === void 0 || L.value.length < r.max, re = () => r.clearable && !I() && L.value.length > 0, z = f(() => r.size === "lg" ? "md" : "sm"), B = f(() => L.value.length === 0 ? r.placeholder : r.inputPlaceholder), V = f(() => {
1002
+ let e = Array.isArray(r.trigger) ? r.trigger : [r.trigger];
1003
+ return new Set(e);
1004
+ }), H = f(() => r.delimiters.filter(Boolean)), U = () => F(a.class), ie = () => a.style, W = f(() => ie()), ae = () => {
1005
+ let { class: e, style: t, ...n } = a;
1006
+ return n;
1007
+ }, oe = f(() => F(U(), _e({
1008
+ size: r.size,
1009
+ focused: u.value,
1010
+ disabled: r.disabled,
1011
+ multiline: !0
1012
+ }), "flex-wrap items-center! content-start overflow-visible! gap-1 px-2 py-1", r.size === "sm" && "px-1.5", r.size === "lg" && "px-2.5", re() && "pr-7!", y && "-ml-px rounded-l-none", b && "-mr-px rounded-r-none")), G = f(() => F(Z({
1013
+ size: r.size,
1014
+ multiline: !1,
1015
+ number: !1
1016
+ }), "min-w-20 flex-[1_0_5rem]! self-center px-1! py-0!", r.size === "sm" ? "h-5! text-sm/5" : r.size === "lg" ? "h-7!" : "h-6!")), K = f(() => F("absolute right-2 top-1/2 flex size-4 -translate-y-1/2 items-center justify-center rounded-full bg-tertiary/90 text-tertiary/60 opacity-0 transition-all duration-150 hover:bg-tertiary hover:text-tertiary group-hover/ui-input:opacity-100 group-focus-within/ui-input:opacity-100")), q = () => s.value?.focus(), se = () => s.value?.blur(), ce = (e) => {
1017
+ i("update:modelValue", e), i("input", e);
1018
+ }, le = (e) => {
1019
+ ce(e), i("change", e);
1020
+ }, ue = (e) => e.trim(), de = (e, t) => !(!e || !r.allowDuplicates && t.includes(e) || r.validateTag && !r.validateTag(e)), fe = (e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), pe = (e) => H.value.length === 0 ? [e] : e.split(new RegExp(H.value.map(fe).join("|"))), J = (e) => {
1021
+ if (I() || !R()) return !1;
1022
+ let t = [...L.value], n = !1;
1023
+ for (let a of pe(e)) {
1024
+ if (r.max !== void 0 && t.length >= r.max) break;
1025
+ let e = ue(a);
1026
+ if (de(e, t) && (t.push(e), n = !0, i("add-tag", e), r.max !== void 0 && t.length >= r.max)) break;
1027
+ }
1028
+ return n && (c.value = "", le(t)), n;
1029
+ }, ge = (e) => {
1030
+ if (I()) return;
1031
+ let t = [...L.value], [n] = t.splice(e, 1);
1032
+ le(t), n !== void 0 && i("remove-tag", n, e), x(q);
1033
+ }, X = () => {
1034
+ I() || L.value.length === 0 || (c.value = "", le([]), i("clear"), x(q));
1035
+ }, ye = (e) => {
1036
+ e.target !== s.value && (e.target?.closest("button") || (e.preventDefault(), q()));
1037
+ }, be = (e) => {
1038
+ I() || (c.value = e.target.value, !_.value && H.value.some((e) => c.value.includes(e)) && J(c.value));
1039
+ }, xe = (e) => {
1040
+ if (I()) return;
1041
+ let t = e.clipboardData?.getData("text");
1042
+ !t || !H.value.some((e) => t.includes(e)) || (e.preventDefault(), J(t));
1043
+ }, Se = (e) => {
1044
+ u.value = !0, i("focus", e);
1045
+ }, Ce = (e) => {
1046
+ u.value = !1, c.value && J(c.value), i("blur", e);
1047
+ }, $ = () => {
1048
+ _.value = !0;
1049
+ }, we = (e) => {
1050
+ _.value = !1, c.value = e.target.value;
1051
+ }, Te = (e) => {
1052
+ if (i("keydown", e), !(I() || _.value)) {
1053
+ if (V.value.has(e.key) || e.key === " " && V.value.has("Space")) {
1054
+ e.key === "Tab" && c.value.trim() && e.preventDefault();
1055
+ let t = J(c.value);
1056
+ (t || c.value.trim()) && e.preventDefault(), t && e.key === "Tab" && x(q);
1057
+ return;
1058
+ }
1059
+ e.key === "Backspace" && c.value === "" && L.value.length > 0 && (e.preventDefault(), ge(L.value.length - 1));
1060
+ }
1061
+ };
1062
+ return t({
1063
+ blur: se,
1064
+ clear: X,
1065
+ focus: q
1066
+ }), (t, n) => (T(), h("div", { class: S(A(ve)({
1067
+ size: e.size,
1068
+ multiline: !0
1069
+ })) }, [
1070
+ y ? (T(), h("div", {
1071
+ key: 0,
1072
+ class: S(A(Q)({
1073
+ position: "prepend",
1074
+ size: e.size,
1075
+ disabled: e.disabled
1076
+ }))
1077
+ }, [O(t.$slots, "prepend")], 2)) : m("", !0),
1078
+ g("div", {
1079
+ class: S(oe.value),
1080
+ style: C(W.value),
1081
+ "data-ui-input-tag": "true",
1082
+ onPointerdown: ye
1083
+ }, [
1084
+ w() ? (T(), h("span", me, [O(t.$slots, "prefix")])) : m("", !0),
1085
+ (T(!0), h(d, null, D(L.value, (n, r) => (T(), p(A(l), {
1086
+ key: `${n}-${r}`,
1087
+ color: e.tagColor,
1088
+ variant: e.tagVariant,
1089
+ size: z.value,
1090
+ radius: e.tagRadius,
1091
+ closable: !e.disabled && !e.readonly,
1092
+ "close-icon": e.closeIcon,
1093
+ class: "max-w-full self-center",
1094
+ onClose: (e) => ge(r)
1095
+ }, {
1096
+ default: N(() => [O(t.$slots, "tag", {
1097
+ tag: n,
1098
+ index: r
1099
+ }, () => [v(k(n), 1)])]),
1100
+ _: 2
1101
+ }, 1032, [
1102
+ "color",
1103
+ "variant",
1104
+ "size",
1105
+ "radius",
1106
+ "closable",
1107
+ "close-icon",
1108
+ "onClose"
1109
+ ]))), 128)),
1110
+ g("input", ee({
1111
+ ref_key: "inputRef",
1112
+ ref: s
1113
+ }, ae(), {
1114
+ "data-ui-input-tag-control": "true",
1115
+ name: e.name,
1116
+ value: c.value,
1117
+ maxlength: e.maxlength,
1118
+ placeholder: B.value,
1119
+ disabled: e.disabled || !R(),
1120
+ readonly: e.readonly,
1121
+ autocomplete: e.autocomplete,
1122
+ class: G.value,
1123
+ onInput: be,
1124
+ onPaste: xe,
1125
+ onFocus: Se,
1126
+ onBlur: Ce,
1127
+ onKeydown: Te,
1128
+ onCompositionstart: $,
1129
+ onCompositionend: we
1130
+ }), null, 16, he),
1131
+ ne() ? (T(), h("span", Y, [O(t.$slots, "suffix")])) : m("", !0),
1132
+ re() ? (T(), h("button", {
1133
+ key: 2,
1134
+ type: "button",
1135
+ "aria-label": "清空",
1136
+ class: S(K.value),
1137
+ onClick: P(X, ["stop"])
1138
+ }, [g("span", { class: S([e.clearIcon, "size-3"]) }, null, 2)], 2)) : m("", !0)
1139
+ ], 38),
1140
+ b ? (T(), h("div", {
1141
+ key: 1,
1142
+ class: S(A(Q)({
1143
+ position: "append",
1144
+ size: e.size,
1145
+ disabled: e.disabled
1146
+ }))
1147
+ }, [O(t.$slots, "append")], 2)) : m("", !0)
1148
+ ], 2));
1149
+ }
1150
+ }), _e = u("group/ui-input relative flex w-full min-w-0 items-stretch overflow-hidden border bg-primary text-primary transition-colors duration-150", {
1151
+ variants: {
1152
+ size: {
1153
+ sm: "rounded-md text-sm/5",
1154
+ md: "rounded-md text-base/4",
1155
+ lg: "rounded-md text-lg/5"
1156
+ },
1157
+ focused: {
1158
+ true: "border-brand ring-2 ring-brand/15",
1159
+ false: "border-control hover:border-brand/40"
1160
+ },
1161
+ disabled: {
1162
+ true: "cursor-not-allowed bg-tertiary/20 text-tertiary opacity-70 hover:border-control",
1163
+ false: ""
1164
+ },
1165
+ multiline: {
1166
+ true: "h-auto",
1167
+ false: ""
1168
+ }
1169
+ },
1170
+ defaultVariants: {
1171
+ size: "md",
1172
+ focused: !1,
1173
+ disabled: !1,
1174
+ multiline: !1
1175
+ }
1176
+ }), X = u("invisible block w-[20ch] overflow-hidden", {
1177
+ variants: { size: e },
1178
+ defaultVariants: { size: "md" }
1179
+ }), Z = u("min-w-0 flex-1 border-0 bg-transparent text-inherit outline-none placeholder:text-tertiary/60 disabled:cursor-not-allowed disabled:opacity-100", {
1180
+ variants: {
1181
+ size: {
1182
+ sm: "text-sm/5",
1183
+ md: "text-base/4",
1184
+ lg: "text-lg/5"
1185
+ },
1186
+ multiline: {
1187
+ true: "min-h-20 resize-y",
1188
+ false: "h-full py-0"
1189
+ },
1190
+ number: {
1191
+ true: "font-mono [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
1192
+ false: ""
1193
+ }
1194
+ },
1195
+ defaultVariants: {
1196
+ size: "md",
1197
+ multiline: !1,
1198
+ number: !1
1199
+ },
1200
+ compoundVariants: [
1201
+ {
1202
+ size: "sm",
1203
+ multiline: !1,
1204
+ class: "px-2"
1205
+ },
1206
+ {
1207
+ size: "md",
1208
+ multiline: !1,
1209
+ class: "px-3"
1210
+ },
1211
+ {
1212
+ size: "lg",
1213
+ multiline: !1,
1214
+ class: "px-4"
1215
+ },
1216
+ {
1217
+ size: "sm",
1218
+ multiline: !0,
1219
+ class: "px-2 py-1"
1220
+ },
1221
+ {
1222
+ size: "md",
1223
+ multiline: !0,
1224
+ class: "px-3 py-2"
1225
+ },
1226
+ {
1227
+ size: "lg",
1228
+ multiline: !0,
1229
+ class: "px-4 py-2"
1230
+ }
1231
+ ]
1232
+ }), ve = u("inline-flex w-full min-w-0 self-start items-stretch align-middle", {
1233
+ variants: {
1234
+ size: {
1235
+ sm: "",
1236
+ md: "",
1237
+ lg: ""
1238
+ },
1239
+ multiline: {
1240
+ true: "h-auto",
1241
+ false: ""
1242
+ }
1243
+ },
1244
+ defaultVariants: {
1245
+ size: "md",
1246
+ multiline: !1
1247
+ }
1248
+ }), Q = u("flex shrink-0 items-center border border-control bg-tertiary/50 px-3 text-tertiary", {
1249
+ variants: {
1250
+ position: {
1251
+ prepend: "rounded-l-md border-r-0",
1252
+ append: "rounded-r-md border-l-0"
1253
+ },
1254
+ size: {
1255
+ sm: "text-xs",
1256
+ md: "text-sm",
1257
+ lg: "text-base"
1258
+ },
1259
+ disabled: {
1260
+ true: "cursor-not-allowed opacity-70",
1261
+ false: ""
1262
+ }
1263
+ },
1264
+ defaultVariants: {
1265
+ size: "md",
1266
+ disabled: !1
1267
+ }
1268
+ });
1269
+ //#endregion
1270
+ export { _e as a, G as c, X as i, W as l, Z as n, ge as o, ve as r, J as s, Q as t };
1271
+
1272
+ //# sourceMappingURL=input-hIYHtcTj.js.map