@ug666/ui-vue 0.2.0 → 0.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aliases.d.ts +38 -21
- package/dist/aliases.d.ts.map +1 -1
- package/dist/blocks/feature-grid.vue.d.ts +9 -13
- package/dist/blocks/feature-grid.vue.d.ts.map +1 -1
- package/dist/blocks/index.cjs +1 -1
- package/dist/blocks/index.cjs.map +1 -1
- package/dist/blocks/index.js +155 -65
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/landing-hero.vue.d.ts +21 -19
- package/dist/blocks/landing-hero.vue.d.ts.map +1 -1
- package/dist/button-CVw3ryBz.cjs +2 -0
- package/dist/button-CVw3ryBz.cjs.map +1 -0
- package/dist/button-D_ikOxrp.js +292 -0
- package/dist/button-D_ikOxrp.js.map +1 -0
- package/dist/cn-CFAiuoYh.cjs +2 -0
- package/dist/cn-CFAiuoYh.cjs.map +1 -0
- package/dist/cn-Cl2u7rTh.js +10 -0
- package/dist/cn-Cl2u7rTh.js.map +1 -0
- package/dist/components/accordion.vue.d.ts +29 -6
- package/dist/components/accordion.vue.d.ts.map +1 -1
- package/dist/components/alert.vue.d.ts +9 -8
- package/dist/components/alert.vue.d.ts.map +1 -1
- package/dist/components/avatar-group.vue.d.ts +3 -2
- package/dist/components/avatar-group.vue.d.ts.map +1 -1
- package/dist/components/avatar.vue.d.ts +6 -5
- package/dist/components/avatar.vue.d.ts.map +1 -1
- package/dist/components/badge.vue.d.ts +9 -16
- package/dist/components/badge.vue.d.ts.map +1 -1
- package/dist/components/breadcrumb.vue.d.ts +20 -11
- package/dist/components/breadcrumb.vue.d.ts.map +1 -1
- package/dist/components/button-group.vue.d.ts +92 -0
- package/dist/components/button-group.vue.d.ts.map +1 -0
- package/dist/components/button.vue.d.ts +77 -39
- package/dist/components/button.vue.d.ts.map +1 -1
- package/dist/components/card.vue.d.ts +15 -11
- package/dist/components/card.vue.d.ts.map +1 -1
- package/dist/components/checkbox-group.vue.d.ts +43 -0
- package/dist/components/checkbox-group.vue.d.ts.map +1 -0
- package/dist/components/checkbox.vue.d.ts +23 -24
- package/dist/components/checkbox.vue.d.ts.map +1 -1
- package/dist/components/config-provider.vue.d.ts +77 -0
- package/dist/components/config-provider.vue.d.ts.map +1 -0
- package/dist/components/container.vue.d.ts +141 -0
- package/dist/components/container.vue.d.ts.map +1 -0
- package/dist/components/context/accordion-context.d.ts +7 -2
- package/dist/components/context/accordion-context.d.ts.map +1 -1
- package/dist/components/context/button-group.d.ts +40 -0
- package/dist/components/context/button-group.d.ts.map +1 -0
- package/dist/components/context/checkbox-context.d.ts +14 -0
- package/dist/components/context/checkbox-context.d.ts.map +1 -0
- package/dist/components/context/context-menu-context.d.ts +4 -0
- package/dist/components/context/context-menu-context.d.ts.map +1 -1
- package/dist/components/context/drawer-context.d.ts +4 -0
- package/dist/components/context/drawer-context.d.ts.map +1 -1
- package/dist/components/context/dropdown-context.d.ts +10 -0
- package/dist/components/context/dropdown-context.d.ts.map +1 -1
- package/dist/components/context/form-context.d.ts +31 -1
- package/dist/components/context/form-context.d.ts.map +1 -1
- package/dist/components/context/popover-context.d.ts +2 -0
- package/dist/components/context/popover-context.d.ts.map +1 -1
- package/dist/components/context/radio-context.d.ts +11 -3
- package/dist/components/context/radio-context.d.ts.map +1 -1
- package/dist/components/context/tabs-context.d.ts +2 -0
- package/dist/components/context/tabs-context.d.ts.map +1 -1
- package/dist/components/context/tooltip-context.d.ts +2 -0
- package/dist/components/context/tooltip-context.d.ts.map +1 -1
- package/dist/components/context-menu.vue.d.ts +6 -5
- package/dist/components/context-menu.vue.d.ts.map +1 -1
- package/dist/components/descriptions.vue.d.ts +12 -18
- package/dist/components/descriptions.vue.d.ts.map +1 -1
- package/dist/components/dialog.vue.d.ts +5 -3
- package/dist/components/dialog.vue.d.ts.map +1 -1
- package/dist/components/drawer.vue.d.ts +9 -8
- package/dist/components/drawer.vue.d.ts.map +1 -1
- package/dist/components/dropdown.vue.d.ts +11 -10
- package/dist/components/dropdown.vue.d.ts.map +1 -1
- package/dist/components/empty-state.vue.d.ts +16 -17
- package/dist/components/empty-state.vue.d.ts.map +1 -1
- package/dist/components/form.vue.d.ts +95 -17
- package/dist/components/form.vue.d.ts.map +1 -1
- package/dist/components/icon.vue.d.ts +28 -0
- package/dist/components/icon.vue.d.ts.map +1 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +21 -6
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -5
- package/dist/components/input.vue.d.ts +71 -29
- package/dist/components/input.vue.d.ts.map +1 -1
- package/dist/components/label.vue.d.ts +12 -19
- package/dist/components/label.vue.d.ts.map +1 -1
- package/dist/components/layout.d.ts +194 -0
- package/dist/components/layout.d.ts.map +1 -0
- package/dist/components/link.vue.d.ts +55 -0
- package/dist/components/link.vue.d.ts.map +1 -0
- package/dist/components/modal.vue.d.ts +15 -16
- package/dist/components/modal.vue.d.ts.map +1 -1
- package/dist/components/navigation-menu.vue.d.ts +30 -14
- package/dist/components/navigation-menu.vue.d.ts.map +1 -1
- package/dist/components/number-input.vue.d.ts +53 -25
- package/dist/components/number-input.vue.d.ts.map +1 -1
- package/dist/components/otp-input.vue.d.ts +12 -9
- package/dist/components/otp-input.vue.d.ts.map +1 -1
- package/dist/components/pagination.vue.d.ts +15 -13
- package/dist/components/pagination.vue.d.ts.map +1 -1
- package/dist/components/popover.vue.d.ts +9 -8
- package/dist/components/popover.vue.d.ts.map +1 -1
- package/dist/components/progress.vue.d.ts +3 -2
- package/dist/components/progress.vue.d.ts.map +1 -1
- package/dist/components/radio-group.vue.d.ts +23 -30
- package/dist/components/radio-group.vue.d.ts.map +1 -1
- package/dist/components/radio.vue.d.ts +28 -17
- package/dist/components/radio.vue.d.ts.map +1 -1
- package/dist/components/scrollbar.vue.d.ts +65 -0
- package/dist/components/scrollbar.vue.d.ts.map +1 -0
- package/dist/components/select.vue.d.ts +83 -35
- package/dist/components/select.vue.d.ts.map +1 -1
- package/dist/components/separator.vue.d.ts +19 -8
- package/dist/components/separator.vue.d.ts.map +1 -1
- package/dist/components/sheet.vue.d.ts +15 -16
- package/dist/components/sheet.vue.d.ts.map +1 -1
- package/dist/components/sidebar.vue.d.ts +13 -35
- package/dist/components/sidebar.vue.d.ts.map +1 -1
- package/dist/components/skeleton.vue.d.ts +3 -2
- package/dist/components/skeleton.vue.d.ts.map +1 -1
- package/dist/components/slider.vue.d.ts +56 -22
- package/dist/components/slider.vue.d.ts.map +1 -1
- package/dist/components/space.vue.d.ts +35 -0
- package/dist/components/space.vue.d.ts.map +1 -0
- package/dist/components/spinner.vue.d.ts +6 -5
- package/dist/components/spinner.vue.d.ts.map +1 -1
- package/dist/components/splitter.vue.d.ts +234 -0
- package/dist/components/splitter.vue.d.ts.map +1 -0
- package/dist/components/statistic.vue.d.ts +12 -15
- package/dist/components/statistic.vue.d.ts.map +1 -1
- package/dist/components/steps.vue.d.ts +8 -19
- package/dist/components/steps.vue.d.ts.map +1 -1
- package/dist/components/switch.vue.d.ts +50 -19
- package/dist/components/switch.vue.d.ts.map +1 -1
- package/dist/components/table.vue.d.ts +6 -5
- package/dist/components/table.vue.d.ts.map +1 -1
- package/dist/components/tabs.vue.d.ts +26 -9
- package/dist/components/tabs.vue.d.ts.map +1 -1
- package/dist/components/tag.vue.d.ts +11 -18
- package/dist/components/tag.vue.d.ts.map +1 -1
- package/dist/components/text.vue.d.ts +32 -0
- package/dist/components/text.vue.d.ts.map +1 -0
- package/dist/components/textarea.vue.d.ts +58 -26
- package/dist/components/textarea.vue.d.ts.map +1 -1
- package/dist/components/toast.vue.d.ts +3 -2
- package/dist/components/toast.vue.d.ts.map +1 -1
- package/dist/components/tooltip.vue.d.ts +7 -6
- package/dist/components/tooltip.vue.d.ts.map +1 -1
- package/dist/components/types/forms.d.ts +15 -0
- package/dist/components/types/forms.d.ts.map +1 -0
- package/dist/components/types/foundation.d.ts +5 -0
- package/dist/components/types/foundation.d.ts.map +1 -0
- package/dist/composables/index.cjs +1 -1
- package/dist/composables/index.d.ts +2 -1
- package/dist/composables/index.d.ts.map +1 -1
- package/dist/composables/index.js +2 -2
- package/dist/composables/use-copy-to-clipboard.d.ts.map +1 -1
- package/dist/composables/use-event-listener.d.ts.map +1 -1
- package/dist/composables/use-form.d.ts +38 -26
- package/dist/composables/use-form.d.ts.map +1 -1
- package/dist/composables/use-local-storage.d.ts.map +1 -1
- package/dist/composables-C-Go-D3m.js +386 -0
- package/dist/composables-C-Go-D3m.js.map +1 -0
- package/dist/composables-CiWPyBEE.cjs +2 -0
- package/dist/composables-CiWPyBEE.cjs.map +1 -0
- package/dist/global.d.ts +17 -0
- package/dist/global.d.ts.map +1 -1
- package/dist/icon-NbssmDYT.js +1561 -0
- package/dist/icon-NbssmDYT.js.map +1 -0
- package/dist/icon-jF_XZntG.cjs +2 -0
- package/dist/icon-jF_XZntG.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +26 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +134 -332
- package/dist/index.js.map +1 -1
- package/dist/internal/use-overlay-focus.d.ts +3 -0
- package/dist/internal/use-overlay-focus.d.ts.map +1 -0
- package/dist/internal/use-overlay-lifecycle.d.ts +3 -0
- package/dist/internal/use-overlay-lifecycle.d.ts.map +1 -0
- package/dist/labs/file-preview.vue.d.ts +42 -0
- package/dist/labs/file-preview.vue.d.ts.map +1 -0
- package/dist/labs/index.cjs +1 -1
- package/dist/labs/index.cjs.map +1 -1
- package/dist/labs/index.d.ts +7 -2
- package/dist/labs/index.d.ts.map +1 -1
- package/dist/labs/index.js +209 -5
- package/dist/labs/index.js.map +1 -1
- package/dist/labs/model-card.vue.d.ts +46 -0
- package/dist/labs/model-card.vue.d.ts.map +1 -0
- package/dist/patterns/admin-shell.vue.d.ts +18 -17
- package/dist/patterns/admin-shell.vue.d.ts.map +1 -1
- package/dist/patterns/confirm-dialog.vue.d.ts +13 -15
- package/dist/patterns/confirm-dialog.vue.d.ts.map +1 -1
- package/dist/patterns/copy-field.vue.d.ts +12 -15
- package/dist/patterns/copy-field.vue.d.ts.map +1 -1
- package/dist/patterns/index.cjs +1 -1
- package/dist/patterns/index.cjs.map +1 -1
- package/dist/patterns/index.js +178 -79
- package/dist/patterns/index.js.map +1 -1
- package/dist/patterns/page-header.vue.d.ts +25 -23
- package/dist/patterns/page-header.vue.d.ts.map +1 -1
- package/dist/primitives/index.cjs +1 -1
- package/dist/primitives/index.d.ts +13 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +3 -3
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.cjs.map +1 -1
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +13 -12
- package/dist/resolver.js.map +1 -1
- package/dist/sidebar-DI7FOJiw.cjs +2 -0
- package/dist/sidebar-DI7FOJiw.cjs.map +1 -0
- package/dist/sidebar-wW1OGS5T.js +442 -0
- package/dist/sidebar-wW1OGS5T.js.map +1 -0
- package/dist/statistic-1kiSjvCX.cjs +2 -0
- package/dist/statistic-1kiSjvCX.cjs.map +1 -0
- package/dist/statistic-DBlNBT-A.js +4748 -0
- package/dist/statistic-DBlNBT-A.js.map +1 -0
- package/dist/styles.css +2797 -956
- package/dist/theme.cjs +2 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.d.ts +172 -76
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +128 -0
- package/dist/theme.js.map +1 -0
- package/dist/themes/default.css +80 -0
- package/dist/themes/mecha.css +195 -0
- package/dist/themes/minimal.css +160 -0
- package/dist/{toast-state-BBoVvR0u.cjs → toast-state-DZPoRLPw.cjs} +2 -2
- package/dist/{toast-state-BBoVvR0u.cjs.map → toast-state-DZPoRLPw.cjs.map} +1 -1
- package/dist/{toast-state-Crugc-IE.js → toast-state-DyrVOjSJ.js} +1 -1
- package/dist/{toast-state-Crugc-IE.js.map → toast-state-DyrVOjSJ.js.map} +1 -1
- package/dist/tokens.css +1173 -18
- package/package.json +24 -12
- package/dist/aliases-CKe0wVQy.cjs +0 -2
- package/dist/aliases-CKe0wVQy.cjs.map +0 -1
- package/dist/aliases-u3xep8jx.js +0 -2732
- package/dist/aliases-u3xep8jx.js.map +0 -1
- package/dist/button-C10AiP5_.cjs +0 -2
- package/dist/button-C10AiP5_.cjs.map +0 -1
- package/dist/button-Sy9e0tiI.js +0 -1742
- package/dist/button-Sy9e0tiI.js.map +0 -1
- package/dist/component-layers.d.ts +0 -199
- package/dist/component-layers.d.ts.map +0 -1
- package/dist/composables-GXmQiqgg.cjs +0 -2
- package/dist/composables-GXmQiqgg.cjs.map +0 -1
- package/dist/composables-YMNfao5g.js +0 -251
- package/dist/composables-YMNfao5g.js.map +0 -1
- package/dist/separator-BnNQAp6A.js +0 -259
- package/dist/separator-BnNQAp6A.js.map +0 -1
- package/dist/separator-Bynwn-we.cjs +0 -2
- package/dist/separator-Bynwn-we.cjs.map +0 -1
- package/dist/sidebar-BnZB7vlK.js +0 -344
- package/dist/sidebar-BnZB7vlK.js.map +0 -1
- package/dist/sidebar-xKPzL0NQ.cjs +0 -2
- package/dist/sidebar-xKPzL0NQ.cjs.map +0 -1
|
@@ -0,0 +1,4748 @@
|
|
|
1
|
+
import { t as e } from "./cn-Cl2u7rTh.js";
|
|
2
|
+
import { a as t, i as n, o as r, s as i } from "./button-D_ikOxrp.js";
|
|
3
|
+
import { O as a } from "./icon-NbssmDYT.js";
|
|
4
|
+
import { i as o, r as s } from "./sidebar-wW1OGS5T.js";
|
|
5
|
+
import { getUGThemeDataAttributes as c, useUGTheme as l } from "./theme.js";
|
|
6
|
+
import { r as u, t as d } from "./toast-state-DyrVOjSJ.js";
|
|
7
|
+
import { Fragment as f, Teleport as p, cloneVNode as m, computed as h, createBlock as g, createCommentVNode as _, createElementBlock as v, createElementVNode as y, createTextVNode as b, createVNode as x, defineComponent as S, h as C, inject as w, mergeModels as T, mergeProps as E, nextTick as D, normalizeClass as O, normalizeStyle as k, onBeforeUnmount as A, onMounted as ee, openBlock as j, provide as M, reactive as N, ref as P, renderList as F, renderSlot as I, resolveDynamicComponent as L, toDisplayString as R, toRef as z, unref as B, useAttrs as te, useId as V, useModel as H, useSlots as U, vModelText as W, watch as G, withCtx as ne, withDirectives as re, withModifiers as K } from "vue";
|
|
8
|
+
import { AlertCircle as q, AlertTriangle as J, Check as ie, CheckCircle as Y, ChevronDown as ae, ChevronLeft as oe, ChevronRight as se, ChevronUp as ce, Info as le, LoaderCircle as ue, Minus as de, Plus as fe, Search as pe, TrendingDown as me, TrendingUp as X, User as he, X as ge } from "@lucide/vue";
|
|
9
|
+
import { countTextCharacters as Z, encodeSelectValue as Q, limitTextByCount as $, normalizeSelectKeys as _e } from "@ug666/ui-core";
|
|
10
|
+
import { trapTabKey as ve } from "@ug666/ui-web/overlay";
|
|
11
|
+
//#region src/components/dialog.vue?vue&type=script&setup=true&lang.ts
|
|
12
|
+
var ye = [
|
|
13
|
+
"aria-labelledby",
|
|
14
|
+
"aria-describedby",
|
|
15
|
+
"data-variant"
|
|
16
|
+
], be = {
|
|
17
|
+
class: "px-[var(--content-gap)] pb-[calc(var(--content-gap)*0.75)] pt-[var(--content-gap)]",
|
|
18
|
+
"data-ug-slot": "header"
|
|
19
|
+
}, xe = ["id"], Se = ["id"], Ce = {
|
|
20
|
+
class: "flex items-center justify-end gap-2 border-t border-border-subtle p-[var(--content-gap)]",
|
|
21
|
+
"data-ug-slot": "footer"
|
|
22
|
+
}, we = ["data-variant"], Te = "inline-flex h-[var(--control-height-sm)] items-center justify-center rounded-[var(--radius-control)] px-[var(--control-padding-x-md)] py-0 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2", Ee = /* @__PURE__ */ S({
|
|
23
|
+
name: "UDialog",
|
|
24
|
+
__name: "dialog",
|
|
25
|
+
props: /*@__PURE__*/ T({
|
|
26
|
+
title: {},
|
|
27
|
+
description: { default: void 0 },
|
|
28
|
+
variant: { default: "default" },
|
|
29
|
+
cancelText: { default: "取消" },
|
|
30
|
+
confirmText: { default: "确认" },
|
|
31
|
+
class: { default: void 0 }
|
|
32
|
+
}, {
|
|
33
|
+
open: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: !1
|
|
36
|
+
},
|
|
37
|
+
openModifiers: {}
|
|
38
|
+
}),
|
|
39
|
+
emits: /*@__PURE__*/ T(["confirm", "cancel"], ["update:open"]),
|
|
40
|
+
setup(t, { emit: n }) {
|
|
41
|
+
let r = t, i = n, a = H(t, "open"), s = V(), u = V(), d = P(null), f = P(null), m = null, b = {
|
|
42
|
+
default: "bg-primary text-primary-fg hover:bg-primary-hover focus-visible:ring-ring",
|
|
43
|
+
destructive: "bg-danger text-danger-fg hover:bg-danger-hover focus-visible:ring-danger"
|
|
44
|
+
}, x = h(() => e("fixed inset-0 z-[90] flex items-center justify-center p-[var(--content-gap)]", r.class)), S = l(), C = h(() => c(S.value));
|
|
45
|
+
o(a, A);
|
|
46
|
+
let w = h(() => e(Te, b[r.variant]));
|
|
47
|
+
function T() {
|
|
48
|
+
i("cancel"), a.value = !1;
|
|
49
|
+
}
|
|
50
|
+
function k() {
|
|
51
|
+
i("confirm"), a.value = !1;
|
|
52
|
+
}
|
|
53
|
+
function A(e) {
|
|
54
|
+
e.key === "Escape" && a.value && T();
|
|
55
|
+
}
|
|
56
|
+
function ee(e) {
|
|
57
|
+
ve(e, d.value);
|
|
58
|
+
}
|
|
59
|
+
return G(a, (e) => {
|
|
60
|
+
typeof document > "u" || (e ? (m = document.activeElement instanceof HTMLElement ? document.activeElement : null, D(() => f.value?.focus())) : (m?.focus(), m = null));
|
|
61
|
+
}, { immediate: !0 }), (n, r) => (j(), g(p, { to: "body" }, [a.value ? (j(), v("div", E({
|
|
62
|
+
key: 0,
|
|
63
|
+
ref_key: "dialogRef",
|
|
64
|
+
ref: d
|
|
65
|
+
}, C.value, {
|
|
66
|
+
class: x.value,
|
|
67
|
+
role: "alertdialog",
|
|
68
|
+
"aria-modal": "true",
|
|
69
|
+
"aria-labelledby": B(s),
|
|
70
|
+
"aria-describedby": t.description ? B(u) : void 0,
|
|
71
|
+
"data-ug": "dialog",
|
|
72
|
+
"data-state": "open",
|
|
73
|
+
"data-variant": t.variant,
|
|
74
|
+
"data-size": "md",
|
|
75
|
+
tabindex: "-1",
|
|
76
|
+
onKeydown: ee
|
|
77
|
+
}), [y("div", {
|
|
78
|
+
class: "absolute inset-0 bg-overlay",
|
|
79
|
+
"aria-hidden": "true",
|
|
80
|
+
"data-ug-slot": "overlay",
|
|
81
|
+
onClick: T
|
|
82
|
+
}), y("div", {
|
|
83
|
+
class: "relative z-10 w-full max-w-sm rounded-[var(--radius-overlay)] border border-border-base bg-surface-1 shadow-xl",
|
|
84
|
+
"data-ug-slot": "content",
|
|
85
|
+
onClick: r[0] || (r[0] = K(() => {}, ["stop"]))
|
|
86
|
+
}, [y("div", be, [y("h2", {
|
|
87
|
+
id: B(s),
|
|
88
|
+
class: "text-base font-bold text-text-primary",
|
|
89
|
+
"data-ug-slot": "title"
|
|
90
|
+
}, R(t.title), 9, xe), t.description ? (j(), v("p", {
|
|
91
|
+
key: 0,
|
|
92
|
+
id: B(u),
|
|
93
|
+
class: "mt-2 text-sm text-text-secondary",
|
|
94
|
+
"data-ug-slot": "description"
|
|
95
|
+
}, R(t.description), 9, Se)) : _("", !0)]), y("div", Ce, [y("button", {
|
|
96
|
+
type: "button",
|
|
97
|
+
class: O(B(e)(Te, "border border-border-strong bg-surface-1 text-text-secondary", "hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-ring/30")),
|
|
98
|
+
"data-ug-slot": "cancel",
|
|
99
|
+
"data-state": "default",
|
|
100
|
+
"data-variant": "outline",
|
|
101
|
+
"data-size": "sm",
|
|
102
|
+
onClick: T
|
|
103
|
+
}, R(t.cancelText), 3), y("button", {
|
|
104
|
+
ref_key: "confirmButtonRef",
|
|
105
|
+
ref: f,
|
|
106
|
+
type: "button",
|
|
107
|
+
class: O(w.value),
|
|
108
|
+
"data-ug-slot": "confirm",
|
|
109
|
+
"data-state": "default",
|
|
110
|
+
"data-variant": t.variant,
|
|
111
|
+
"data-size": "sm",
|
|
112
|
+
onClick: k
|
|
113
|
+
}, R(t.confirmText), 11, we)])])], 16, ye)) : _("", !0)]));
|
|
114
|
+
}
|
|
115
|
+
}), De = Symbol("ug-drawer-context");
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/components/drawer.vue?vue&type=script&setup=true&lang.ts
|
|
118
|
+
function Oe() {
|
|
119
|
+
let e = w(De);
|
|
120
|
+
if (!e) throw Error("Drawer 子组件必须在 <UDrawer> 内使用");
|
|
121
|
+
return e;
|
|
122
|
+
}
|
|
123
|
+
var ke = {
|
|
124
|
+
right: "inset-y-0 right-0 h-full w-80 max-w-full",
|
|
125
|
+
left: "inset-y-0 left-0 h-full w-80 max-w-full",
|
|
126
|
+
top: "inset-x-0 top-0 w-full max-h-[80vh]",
|
|
127
|
+
bottom: "inset-x-0 bottom-0 w-full max-h-[80vh]"
|
|
128
|
+
}, Ae = S({
|
|
129
|
+
name: "UDrawerContent",
|
|
130
|
+
props: { class: {
|
|
131
|
+
type: String,
|
|
132
|
+
default: void 0
|
|
133
|
+
} },
|
|
134
|
+
setup(t, { slots: n }) {
|
|
135
|
+
let r = Oe(), i = P(null), a = s(r.open, i), o = l(), u = h(() => c(o.value)), d = h(() => e("absolute flex flex-col bg-surface-1 shadow-xl transition-transform duration-300 ease-in-out", ke[r.side.value], t.class));
|
|
136
|
+
return () => r.open.value ? C(p, { to: "body" }, [C("div", {
|
|
137
|
+
ref: i,
|
|
138
|
+
...u.value,
|
|
139
|
+
class: "fixed inset-0 z-50",
|
|
140
|
+
role: "dialog",
|
|
141
|
+
"aria-modal": "true",
|
|
142
|
+
"aria-label": "抽屉",
|
|
143
|
+
"aria-labelledby": r.titleId,
|
|
144
|
+
"aria-describedby": r.descriptionId,
|
|
145
|
+
tabindex: -1,
|
|
146
|
+
onKeydown: a,
|
|
147
|
+
"data-ug": "drawer",
|
|
148
|
+
"data-state": "open",
|
|
149
|
+
"data-variant": "default",
|
|
150
|
+
"data-size": "md"
|
|
151
|
+
}, [C("div", {
|
|
152
|
+
class: "absolute inset-0 bg-overlay transition-opacity",
|
|
153
|
+
"aria-hidden": "true",
|
|
154
|
+
"data-ug-slot": "overlay",
|
|
155
|
+
onClick: () => r.setOpen(!1)
|
|
156
|
+
}), C("div", {
|
|
157
|
+
class: d.value,
|
|
158
|
+
"data-ug-slot": "content",
|
|
159
|
+
onClick: (e) => e.stopPropagation()
|
|
160
|
+
}, n.default?.())])]) : null;
|
|
161
|
+
}
|
|
162
|
+
}), je = S({
|
|
163
|
+
name: "UDrawerHeader",
|
|
164
|
+
props: { class: {
|
|
165
|
+
type: String,
|
|
166
|
+
default: void 0
|
|
167
|
+
} },
|
|
168
|
+
setup(t, { slots: n }) {
|
|
169
|
+
let r = h(() => e("flex flex-col gap-1.5 border-b border-border-base px-[var(--content-gap)] py-[calc(var(--content-gap)*0.75)]", t.class));
|
|
170
|
+
return () => C("div", {
|
|
171
|
+
class: r.value,
|
|
172
|
+
"data-ug-slot": "header"
|
|
173
|
+
}, n.default?.());
|
|
174
|
+
}
|
|
175
|
+
}), Me = S({
|
|
176
|
+
name: "UDrawerTitle",
|
|
177
|
+
props: { class: {
|
|
178
|
+
type: String,
|
|
179
|
+
default: void 0
|
|
180
|
+
} },
|
|
181
|
+
setup(t, { slots: n }) {
|
|
182
|
+
let r = Oe(), i = h(() => e("text-lg font-semibold text-text-primary", t.class));
|
|
183
|
+
return () => C("h2", {
|
|
184
|
+
id: r.titleId,
|
|
185
|
+
class: i.value,
|
|
186
|
+
"data-ug-slot": "title"
|
|
187
|
+
}, n.default?.());
|
|
188
|
+
}
|
|
189
|
+
}), Ne = S({
|
|
190
|
+
name: "UDrawerDescription",
|
|
191
|
+
props: { class: {
|
|
192
|
+
type: String,
|
|
193
|
+
default: void 0
|
|
194
|
+
} },
|
|
195
|
+
setup(t, { slots: n }) {
|
|
196
|
+
let r = Oe(), i = h(() => e("text-sm text-text-secondary", t.class));
|
|
197
|
+
return () => C("p", {
|
|
198
|
+
id: r.descriptionId,
|
|
199
|
+
class: i.value,
|
|
200
|
+
"data-ug-slot": "description"
|
|
201
|
+
}, n.default?.());
|
|
202
|
+
}
|
|
203
|
+
}), Pe = S({
|
|
204
|
+
name: "UDrawerFooter",
|
|
205
|
+
props: { class: {
|
|
206
|
+
type: String,
|
|
207
|
+
default: void 0
|
|
208
|
+
} },
|
|
209
|
+
setup(t, { slots: n }) {
|
|
210
|
+
let r = h(() => e("mt-auto flex items-center justify-end gap-2 border-t border-border-base px-[var(--content-gap)] py-[calc(var(--content-gap)*0.75)]", t.class));
|
|
211
|
+
return () => C("div", {
|
|
212
|
+
class: r.value,
|
|
213
|
+
"data-ug-slot": "footer"
|
|
214
|
+
}, n.default?.());
|
|
215
|
+
}
|
|
216
|
+
}), Fe = S({
|
|
217
|
+
name: "UDrawerClose",
|
|
218
|
+
props: { class: {
|
|
219
|
+
type: String,
|
|
220
|
+
default: void 0
|
|
221
|
+
} },
|
|
222
|
+
emits: { click: (e) => !0 },
|
|
223
|
+
setup(t, { emit: n, slots: r }) {
|
|
224
|
+
let i = Oe(), a = h(() => e("inline-flex items-center justify-center rounded-[var(--radius-control)] px-[var(--control-padding-x-md)] py-[calc(var(--content-gap)*0.5)] text-sm font-medium text-text-secondary transition-colors hover:bg-surface-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30", t.class));
|
|
225
|
+
function o(e) {
|
|
226
|
+
i.setOpen(!1), n("click", e);
|
|
227
|
+
}
|
|
228
|
+
return () => C("button", {
|
|
229
|
+
type: "button",
|
|
230
|
+
class: a.value,
|
|
231
|
+
"data-ug-slot": "close",
|
|
232
|
+
"data-state": "default",
|
|
233
|
+
"data-variant": "default",
|
|
234
|
+
"data-size": "md",
|
|
235
|
+
onClick: o
|
|
236
|
+
}, r.default?.() ?? [C(ge, { size: 18 })]);
|
|
237
|
+
}
|
|
238
|
+
}), Ie = /* @__PURE__ */ S({
|
|
239
|
+
name: "UDrawer",
|
|
240
|
+
__name: "drawer",
|
|
241
|
+
props: /*@__PURE__*/ T({
|
|
242
|
+
side: { default: "right" },
|
|
243
|
+
class: { default: void 0 }
|
|
244
|
+
}, {
|
|
245
|
+
open: {
|
|
246
|
+
type: Boolean,
|
|
247
|
+
default: !1
|
|
248
|
+
},
|
|
249
|
+
openModifiers: {}
|
|
250
|
+
}),
|
|
251
|
+
emits: /*@__PURE__*/ T(["openChange"], ["update:open"]),
|
|
252
|
+
setup(e, { emit: t }) {
|
|
253
|
+
let n = e, r = t, i = H(e, "open");
|
|
254
|
+
o(i, d);
|
|
255
|
+
let a = h(() => n.side), s = V(), c = `ug-drawer-title-${s}`, l = `ug-drawer-description-${s}`;
|
|
256
|
+
function u(e) {
|
|
257
|
+
i.value = e, r("openChange", e);
|
|
258
|
+
}
|
|
259
|
+
function d(e) {
|
|
260
|
+
e.key === "Escape" && i.value && u(!1);
|
|
261
|
+
}
|
|
262
|
+
return M(De, {
|
|
263
|
+
open: i,
|
|
264
|
+
side: a,
|
|
265
|
+
setOpen: u,
|
|
266
|
+
titleId: c,
|
|
267
|
+
descriptionId: l
|
|
268
|
+
}), (e, t) => I(e.$slots, "default");
|
|
269
|
+
}
|
|
270
|
+
}), Le = {
|
|
271
|
+
class: "w-full overflow-auto",
|
|
272
|
+
"data-ug": "table",
|
|
273
|
+
"data-state": "default",
|
|
274
|
+
"data-variant": "default",
|
|
275
|
+
"data-size": "md"
|
|
276
|
+
};
|
|
277
|
+
function Re(t, n, r, i) {
|
|
278
|
+
return S({
|
|
279
|
+
name: t,
|
|
280
|
+
props: { class: {
|
|
281
|
+
type: String,
|
|
282
|
+
default: void 0
|
|
283
|
+
} },
|
|
284
|
+
setup(t, { attrs: a, slots: o }) {
|
|
285
|
+
let s = h(() => e(i, t.class));
|
|
286
|
+
return () => C(n, {
|
|
287
|
+
...a,
|
|
288
|
+
class: s.value,
|
|
289
|
+
"data-ug-slot": r
|
|
290
|
+
}, o.default?.());
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
var ze = Re("UTableHeader", "thead", "header", "[&_tr]:border-b border-border-base"), Be = Re("UTableBody", "tbody", "body", "[&_tr:last-child]:border-0"), Ve = Re("UTableRow", "tr", "row", "border-b border-border-base transition-colors hover:bg-surface-2"), He = Re("UTableHead", "th", "head", "[height:var(--control-height-md)] px-[var(--control-padding-x-md)] text-left align-middle font-medium text-text-secondary [&:has([role=checkbox])]:pr-0"), Ue = Re("UTableCell", "td", "cell", "px-[var(--control-padding-x-md)] py-[calc(var(--control-height-md)*0.3)] align-middle text-text-primary [&:has([role=checkbox])]:pr-0"), We = /* @__PURE__ */ S({
|
|
295
|
+
name: "UTable",
|
|
296
|
+
inheritAttrs: !1,
|
|
297
|
+
__name: "table",
|
|
298
|
+
props: { class: { default: void 0 } },
|
|
299
|
+
setup(t) {
|
|
300
|
+
let n = t, r = h(() => e("w-full caption-bottom text-sm", n.class));
|
|
301
|
+
return (e, t) => (j(), v("div", Le, [y("table", E(e.$attrs, {
|
|
302
|
+
class: r.value,
|
|
303
|
+
"data-ug-slot": "table"
|
|
304
|
+
}), [I(e.$slots, "default")], 16)]));
|
|
305
|
+
}
|
|
306
|
+
}), Ge = ["data-variant"], Ke = { "data-ug-slot": "content" }, qe = {
|
|
307
|
+
class: "font-semibold",
|
|
308
|
+
"data-ug-slot": "title"
|
|
309
|
+
}, Je = { "data-ug-slot": "message" }, Ye = ["onClick"], Xe = /* @__PURE__ */ S({
|
|
310
|
+
name: "UToaster",
|
|
311
|
+
inheritAttrs: !1,
|
|
312
|
+
__name: "toast",
|
|
313
|
+
props: { class: { default: void 0 } },
|
|
314
|
+
setup(t) {
|
|
315
|
+
let n = t, r = {
|
|
316
|
+
success: "bg-success-soft border-success/30 text-success-soft-fg",
|
|
317
|
+
error: "bg-danger-soft border-danger/30 text-danger-soft-fg",
|
|
318
|
+
info: "bg-info-soft border-info/30 text-info-soft-fg"
|
|
319
|
+
}, i = {
|
|
320
|
+
success: "成功",
|
|
321
|
+
error: "错误",
|
|
322
|
+
info: "提示"
|
|
323
|
+
}, { items: a } = u(), o = h(() => e("fixed left-4 right-4 top-4 z-[9999] flex w-auto flex-col gap-2 sm:left-auto sm:w-80", n.class)), s = te(), m = l(), b = h(() => c(m.value)), S = h(() => ({
|
|
324
|
+
...s,
|
|
325
|
+
...b.value
|
|
326
|
+
}));
|
|
327
|
+
return (t, n) => (j(), g(p, { to: "body" }, [B(a).length ? (j(), v("div", E({ key: 0 }, S.value, {
|
|
328
|
+
class: o.value,
|
|
329
|
+
role: "region",
|
|
330
|
+
"aria-label": "通知",
|
|
331
|
+
"data-ug": "toast",
|
|
332
|
+
"data-state": "open",
|
|
333
|
+
"data-variant": "default",
|
|
334
|
+
"data-size": "md"
|
|
335
|
+
}), [(j(!0), v(f, null, F(B(a), (t) => (j(), v("div", {
|
|
336
|
+
key: t.id,
|
|
337
|
+
class: O(B(e)("flex items-start justify-between gap-2 rounded-[var(--radius-control)] border px-[var(--control-padding-x-md)] py-[calc(var(--content-gap)*0.75)] text-sm shadow-md", r[t.type])),
|
|
338
|
+
role: "alert",
|
|
339
|
+
"data-ug-slot": "item",
|
|
340
|
+
"data-state": "default",
|
|
341
|
+
"data-variant": t.type,
|
|
342
|
+
"data-size": "md"
|
|
343
|
+
}, [y("div", Ke, [y("span", qe, R(i[t.type]) + ":", 1), y("span", Je, R(t.message), 1)]), y("button", {
|
|
344
|
+
type: "button",
|
|
345
|
+
class: "mt-[calc(var(--content-gap)*0.125)] shrink-0 rounded-[var(--radius-control)] opacity-60 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
|
|
346
|
+
"aria-label": "关闭通知",
|
|
347
|
+
"data-ug-slot": "close",
|
|
348
|
+
"data-state": "default",
|
|
349
|
+
"data-variant": "default",
|
|
350
|
+
"data-size": "md",
|
|
351
|
+
onClick: (e) => B(d)(t.id)
|
|
352
|
+
}, [x(B(ge), {
|
|
353
|
+
size: 14,
|
|
354
|
+
"aria-hidden": "true",
|
|
355
|
+
focusable: "false"
|
|
356
|
+
})], 8, Ye)], 10, Ge))), 128))], 16)) : _("", !0)]));
|
|
357
|
+
}
|
|
358
|
+
}), Ze = Symbol("ug-checkbox-group"), Qe = [
|
|
359
|
+
"for",
|
|
360
|
+
"data-state",
|
|
361
|
+
"data-size"
|
|
362
|
+
], $e = {
|
|
363
|
+
class: "relative inline-flex",
|
|
364
|
+
"data-ug-slot": "control"
|
|
365
|
+
}, et = [
|
|
366
|
+
"id",
|
|
367
|
+
"checked",
|
|
368
|
+
"aria-checked",
|
|
369
|
+
"disabled",
|
|
370
|
+
"name",
|
|
371
|
+
"form",
|
|
372
|
+
"value"
|
|
373
|
+
], tt = {
|
|
374
|
+
class: "pt-px",
|
|
375
|
+
"data-ug-slot": "label"
|
|
376
|
+
}, nt = ["data-state", "data-size"], rt = {
|
|
377
|
+
class: "relative inline-flex",
|
|
378
|
+
"data-ug-slot": "control"
|
|
379
|
+
}, it = [
|
|
380
|
+
"id",
|
|
381
|
+
"checked",
|
|
382
|
+
"aria-checked",
|
|
383
|
+
"disabled",
|
|
384
|
+
"name",
|
|
385
|
+
"form",
|
|
386
|
+
"value"
|
|
387
|
+
], at = /* @__PURE__ */ S({
|
|
388
|
+
name: "UCheckbox",
|
|
389
|
+
inheritAttrs: !1,
|
|
390
|
+
__name: "checkbox",
|
|
391
|
+
props: {
|
|
392
|
+
modelValue: {
|
|
393
|
+
type: Boolean,
|
|
394
|
+
default: void 0
|
|
395
|
+
},
|
|
396
|
+
defaultChecked: {
|
|
397
|
+
type: Boolean,
|
|
398
|
+
default: !1
|
|
399
|
+
},
|
|
400
|
+
indeterminate: {
|
|
401
|
+
type: Boolean,
|
|
402
|
+
default: !1
|
|
403
|
+
},
|
|
404
|
+
size: {},
|
|
405
|
+
disabled: {
|
|
406
|
+
type: Boolean,
|
|
407
|
+
default: void 0
|
|
408
|
+
},
|
|
409
|
+
label: {},
|
|
410
|
+
value: {},
|
|
411
|
+
id: {},
|
|
412
|
+
class: {},
|
|
413
|
+
labelClass: {}
|
|
414
|
+
},
|
|
415
|
+
emits: ["update:modelValue", "change"],
|
|
416
|
+
setup(n, { expose: a, emit: o }) {
|
|
417
|
+
let s = n, c = o, l = P(null), u = P(s.defaultChecked), d = null, f = te(), p = i(), m = w(Ze, null), x = h(() => m !== null && s.value !== void 0), S = h(() => x.value && s.value !== void 0 ? m.values.value.includes(s.value) : s.modelValue ?? u.value), C = h(() => t(s.size ?? m?.size.value, p.value.size)), T = h(() => x.value && s.value !== void 0 ? m.isOptionDisabled(s.value, S.value, s.disabled) : r(s.disabled, p.value.disabled)), k = h(() => m?.name.value ?? f.name), M = h(() => m?.form.value ?? f.form), N = V(), F = h(() => s.id ?? N), L = h(() => {
|
|
418
|
+
let e = { ...f };
|
|
419
|
+
return delete e.class, delete e.id, delete e.name, delete e.form, e;
|
|
420
|
+
});
|
|
421
|
+
G(() => s.indeterminate, (e) => {
|
|
422
|
+
l.value && (l.value.indeterminate = e);
|
|
423
|
+
}, { immediate: !0 }), ee(() => {
|
|
424
|
+
l.value && (l.value.indeterminate = s.indeterminate);
|
|
425
|
+
});
|
|
426
|
+
let z = {
|
|
427
|
+
sm: "h-[calc(var(--control-height-sm)*0.5)] w-[calc(var(--control-height-sm)*0.5)]",
|
|
428
|
+
default: "h-[calc(var(--control-height-md)*0.45)] w-[calc(var(--control-height-md)*0.45)]",
|
|
429
|
+
lg: "h-[calc(var(--control-height-lg)*0.45)] w-[calc(var(--control-height-lg)*0.45)]"
|
|
430
|
+
}, H = {
|
|
431
|
+
unchecked: "border-border-strong bg-surface-1 text-transparent hover:border-primary/70 hover:bg-surface-2",
|
|
432
|
+
active: "border-primary bg-primary text-primary-fg"
|
|
433
|
+
}, U = h(() => e("peer inline-flex shrink-0 items-center justify-center rounded-[var(--radius-control)] border shadow-sm transition-colors peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring/35 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-surface-0 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", z[C.value], s.indeterminate || S.value ? H.active : H.unchecked, s.class)), W = h(() => e("shrink-0", C.value === "sm" ? "h-[calc(var(--control-height-sm)*0.35)] w-[calc(var(--control-height-sm)*0.35)]" : C.value === "lg" ? "h-[calc(var(--control-height-lg)*0.3)] w-[calc(var(--control-height-lg)*0.3)]" : "h-[calc(var(--control-height-md)*0.3)] w-[calc(var(--control-height-md)*0.3)]")), ne = h(() => {
|
|
434
|
+
let e = s.indeterminate ? "indeterminate" : S.value ? "checked" : "unchecked";
|
|
435
|
+
return T.value ? `${e} disabled` : e;
|
|
436
|
+
}), re = h(() => e("inline-flex min-h-[var(--control-height-sm)] cursor-pointer items-center gap-2.5 text-sm leading-5 text-text-primary select-none", T.value && "cursor-not-allowed opacity-60", s.labelClass));
|
|
437
|
+
function K(e) {
|
|
438
|
+
let t = e.target;
|
|
439
|
+
x.value && s.value !== void 0 ? m.toggleValue(s.value, t.checked) : s.modelValue === void 0 && (u.value = t.checked), t.indeterminate = s.indeterminate, c("update:modelValue", t.checked), c("change", t.checked);
|
|
440
|
+
}
|
|
441
|
+
function q(e) {
|
|
442
|
+
l.value?.focus(e);
|
|
443
|
+
}
|
|
444
|
+
function J() {
|
|
445
|
+
l.value?.blur();
|
|
446
|
+
}
|
|
447
|
+
function Y() {
|
|
448
|
+
!x.value && s.modelValue === void 0 && (u.value = s.defaultChecked);
|
|
449
|
+
}
|
|
450
|
+
function ae() {
|
|
451
|
+
let e = l.value?.form ?? null;
|
|
452
|
+
d !== e && (d?.removeEventListener("reset", Y), d = e, d?.addEventListener("reset", Y));
|
|
453
|
+
}
|
|
454
|
+
return ee(() => void D(ae)), G(M, () => void D(ae)), A(() => d?.removeEventListener("reset", Y)), a({
|
|
455
|
+
focus: q,
|
|
456
|
+
blur: J,
|
|
457
|
+
el: l
|
|
458
|
+
}), (e, t) => n.label !== void 0 || e.$slots.label ? (j(), v("label", {
|
|
459
|
+
key: 0,
|
|
460
|
+
for: F.value,
|
|
461
|
+
class: O(re.value),
|
|
462
|
+
"data-ug": "checkbox",
|
|
463
|
+
"data-state": ne.value,
|
|
464
|
+
"data-variant": "default",
|
|
465
|
+
"data-size": C.value
|
|
466
|
+
}, [y("span", $e, [y("input", E({
|
|
467
|
+
id: F.value,
|
|
468
|
+
ref_key: "inputRef",
|
|
469
|
+
ref: l,
|
|
470
|
+
type: "checkbox",
|
|
471
|
+
class: "peer sr-only",
|
|
472
|
+
checked: S.value,
|
|
473
|
+
"aria-checked": n.indeterminate ? "mixed" : S.value,
|
|
474
|
+
disabled: T.value,
|
|
475
|
+
name: k.value,
|
|
476
|
+
form: M.value,
|
|
477
|
+
value: n.value,
|
|
478
|
+
"data-ug-slot": "input"
|
|
479
|
+
}, L.value, { onChange: K }), null, 16, et), y("span", {
|
|
480
|
+
"aria-hidden": "true",
|
|
481
|
+
class: O(U.value),
|
|
482
|
+
"data-ug-slot": "indicator"
|
|
483
|
+
}, [n.indeterminate ? (j(), g(B(de), {
|
|
484
|
+
key: 0,
|
|
485
|
+
class: O(W.value),
|
|
486
|
+
"data-ug-slot": "icon"
|
|
487
|
+
}, null, 8, ["class"])) : S.value ? (j(), g(B(ie), {
|
|
488
|
+
key: 1,
|
|
489
|
+
class: O(W.value),
|
|
490
|
+
"data-ug-slot": "icon"
|
|
491
|
+
}, null, 8, ["class"])) : _("", !0)], 2)]), y("span", tt, [I(e.$slots, "label", {}, () => [b(R(n.label), 1)])])], 10, Qe)) : (j(), v("span", {
|
|
492
|
+
key: 1,
|
|
493
|
+
"data-ug": "checkbox",
|
|
494
|
+
"data-state": ne.value,
|
|
495
|
+
"data-variant": "default",
|
|
496
|
+
"data-size": C.value
|
|
497
|
+
}, [y("span", rt, [y("input", E({
|
|
498
|
+
id: F.value,
|
|
499
|
+
ref_key: "inputRef",
|
|
500
|
+
ref: l,
|
|
501
|
+
type: "checkbox",
|
|
502
|
+
class: "peer sr-only",
|
|
503
|
+
checked: S.value,
|
|
504
|
+
"aria-checked": n.indeterminate ? "mixed" : S.value,
|
|
505
|
+
disabled: T.value,
|
|
506
|
+
name: k.value,
|
|
507
|
+
form: M.value,
|
|
508
|
+
value: n.value,
|
|
509
|
+
"data-ug-slot": "input"
|
|
510
|
+
}, L.value, { onChange: K }), null, 16, it), y("span", {
|
|
511
|
+
"aria-hidden": "true",
|
|
512
|
+
class: O(U.value),
|
|
513
|
+
"data-ug-slot": "indicator"
|
|
514
|
+
}, [n.indeterminate ? (j(), g(B(de), {
|
|
515
|
+
key: 0,
|
|
516
|
+
class: O(W.value),
|
|
517
|
+
"data-ug-slot": "icon"
|
|
518
|
+
}, null, 8, ["class"])) : S.value ? (j(), g(B(ie), {
|
|
519
|
+
key: 1,
|
|
520
|
+
class: O(W.value),
|
|
521
|
+
"data-ug-slot": "icon"
|
|
522
|
+
}, null, 8, ["class"])) : _("", !0)], 2)])], 8, nt));
|
|
523
|
+
}
|
|
524
|
+
}), ot = [
|
|
525
|
+
"data-size",
|
|
526
|
+
"data-state",
|
|
527
|
+
"data-variant",
|
|
528
|
+
"aria-disabled"
|
|
529
|
+
], st = /* @__PURE__ */ S({
|
|
530
|
+
name: "UCheckboxGroup",
|
|
531
|
+
__name: "checkbox-group",
|
|
532
|
+
props: {
|
|
533
|
+
modelValue: { default: void 0 },
|
|
534
|
+
defaultValue: { default: () => [] },
|
|
535
|
+
disabled: {
|
|
536
|
+
type: Boolean,
|
|
537
|
+
default: void 0
|
|
538
|
+
},
|
|
539
|
+
size: { default: void 0 },
|
|
540
|
+
name: { default: void 0 },
|
|
541
|
+
form: { default: void 0 },
|
|
542
|
+
orientation: { default: "horizontal" },
|
|
543
|
+
min: { default: 0 },
|
|
544
|
+
max: { default: void 0 },
|
|
545
|
+
class: { default: void 0 }
|
|
546
|
+
},
|
|
547
|
+
emits: ["update:modelValue", "change"],
|
|
548
|
+
setup(n, { emit: a }) {
|
|
549
|
+
let o = n, s = a, c = i(), l = P(null), u = P([...o.defaultValue]), d = null, f = h(() => o.modelValue ?? u.value), p = h(() => r(o.disabled, c.value.disabled)), m = h(() => t(o.size, c.value.size)), g = h(() => Math.max(0, o.min)), _ = h(() => o.max === void 0 ? void 0 : Math.max(g.value, o.max));
|
|
550
|
+
function y(e, t, n = !1) {
|
|
551
|
+
return p.value || n ? !0 : t ? f.value.length <= g.value : _.value !== void 0 && f.value.length >= _.value && !f.value.includes(e);
|
|
552
|
+
}
|
|
553
|
+
function b(e, t) {
|
|
554
|
+
let n = t ? f.value.includes(e) ? [...f.value] : [...f.value, e] : f.value.filter((t) => t !== e);
|
|
555
|
+
n.length < g.value || _.value !== void 0 && n.length > _.value || (o.modelValue === void 0 && (u.value = n), s("update:modelValue", n), s("change", n));
|
|
556
|
+
}
|
|
557
|
+
function x() {
|
|
558
|
+
o.modelValue === void 0 && (u.value = [...o.defaultValue]);
|
|
559
|
+
}
|
|
560
|
+
function S() {
|
|
561
|
+
let e = o.form ? document.getElementById(o.form) : l.value?.closest("form") ?? null;
|
|
562
|
+
d !== e && (d?.removeEventListener("reset", x), d = e, d?.addEventListener("reset", x));
|
|
563
|
+
}
|
|
564
|
+
ee(() => void D(S)), G(() => o.form, () => void D(S)), A(() => d?.removeEventListener("reset", x)), M(Ze, {
|
|
565
|
+
values: f,
|
|
566
|
+
form: h(() => o.form),
|
|
567
|
+
name: h(() => o.name),
|
|
568
|
+
size: m,
|
|
569
|
+
disabled: p,
|
|
570
|
+
isOptionDisabled: y,
|
|
571
|
+
toggleValue: b
|
|
572
|
+
});
|
|
573
|
+
let C = h(() => e("flex", o.orientation === "vertical" ? "flex-col items-start gap-2" : "flex-row flex-wrap items-center gap-x-5 gap-y-2", o.class));
|
|
574
|
+
return (e, t) => (j(), v("div", {
|
|
575
|
+
ref_key: "rootRef",
|
|
576
|
+
ref: l,
|
|
577
|
+
class: O(C.value),
|
|
578
|
+
"data-size": m.value,
|
|
579
|
+
"data-state": p.value ? "disabled" : "default",
|
|
580
|
+
"data-ug": "checkbox-group",
|
|
581
|
+
"data-ug-slot": "root",
|
|
582
|
+
"data-variant": n.orientation,
|
|
583
|
+
role: "group",
|
|
584
|
+
"aria-disabled": p.value || void 0
|
|
585
|
+
}, [I(e.$slots, "default")], 10, ot));
|
|
586
|
+
}
|
|
587
|
+
}), ct = Symbol("ug-radio-group-context"), lt = [
|
|
588
|
+
"for",
|
|
589
|
+
"data-state",
|
|
590
|
+
"data-size"
|
|
591
|
+
], ut = {
|
|
592
|
+
class: "relative inline-flex",
|
|
593
|
+
"data-ug-slot": "control"
|
|
594
|
+
}, dt = [
|
|
595
|
+
"id",
|
|
596
|
+
"value",
|
|
597
|
+
"checked",
|
|
598
|
+
"disabled",
|
|
599
|
+
"name",
|
|
600
|
+
"form",
|
|
601
|
+
"required"
|
|
602
|
+
], ft = {
|
|
603
|
+
class: "pt-px",
|
|
604
|
+
"data-ug-slot": "label"
|
|
605
|
+
}, pt = ["data-state", "data-size"], mt = {
|
|
606
|
+
class: "relative inline-flex",
|
|
607
|
+
"data-ug-slot": "control"
|
|
608
|
+
}, ht = [
|
|
609
|
+
"id",
|
|
610
|
+
"value",
|
|
611
|
+
"checked",
|
|
612
|
+
"disabled",
|
|
613
|
+
"name",
|
|
614
|
+
"form",
|
|
615
|
+
"required"
|
|
616
|
+
], gt = /* @__PURE__ */ S({
|
|
617
|
+
name: "URadio",
|
|
618
|
+
inheritAttrs: !1,
|
|
619
|
+
__name: "radio",
|
|
620
|
+
props: {
|
|
621
|
+
value: {},
|
|
622
|
+
checked: {
|
|
623
|
+
type: Boolean,
|
|
624
|
+
default: void 0
|
|
625
|
+
},
|
|
626
|
+
defaultChecked: {
|
|
627
|
+
type: Boolean,
|
|
628
|
+
default: !1
|
|
629
|
+
},
|
|
630
|
+
disabled: {
|
|
631
|
+
type: Boolean,
|
|
632
|
+
default: void 0
|
|
633
|
+
},
|
|
634
|
+
size: {},
|
|
635
|
+
label: {},
|
|
636
|
+
id: {},
|
|
637
|
+
name: {},
|
|
638
|
+
required: { type: Boolean },
|
|
639
|
+
class: {},
|
|
640
|
+
labelClass: {}
|
|
641
|
+
},
|
|
642
|
+
emits: ["change"],
|
|
643
|
+
setup(n, { expose: a, emit: o }) {
|
|
644
|
+
let s = n, c = o, l = w(ct, null), u = te(), d = i(), f = V(), p = h(() => s.id ?? f), m = P(null), g = P(s.defaultChecked), x = null, S = h(() => l ? l.value.value === s.value : s.checked ?? g.value), C = h(() => l ? l.disabled.value || !!s.disabled : r(s.disabled, d.value.disabled)), T = h(() => t(s.size ?? l?.size.value, d.value.size)), k = h(() => l ? l.name.value : s.name), M = h(() => l?.form.value ?? u.form), N = h(() => l?.required.value ?? !!s.required), F = h(() => {
|
|
645
|
+
let e = { ...u };
|
|
646
|
+
return delete e.class, delete e.id, delete e.form, delete e.required, e;
|
|
647
|
+
});
|
|
648
|
+
function L() {
|
|
649
|
+
C.value || (l ? l.onValueChange(s.value) : (s.checked === void 0 && (g.value = !0), c("change", s.value)));
|
|
650
|
+
}
|
|
651
|
+
function z(e) {
|
|
652
|
+
m.value?.focus(e);
|
|
653
|
+
}
|
|
654
|
+
function H() {
|
|
655
|
+
m.value?.blur();
|
|
656
|
+
}
|
|
657
|
+
function U() {
|
|
658
|
+
!l && s.checked === void 0 && (g.value = s.defaultChecked);
|
|
659
|
+
}
|
|
660
|
+
function W() {
|
|
661
|
+
let e = m.value?.form ?? null;
|
|
662
|
+
x !== e && (x?.removeEventListener("reset", U), x = e, x?.addEventListener("reset", U));
|
|
663
|
+
}
|
|
664
|
+
ee(() => void D(W)), G(M, () => void D(W)), A(() => x?.removeEventListener("reset", U)), a({
|
|
665
|
+
focus: z,
|
|
666
|
+
blur: H,
|
|
667
|
+
el: m
|
|
668
|
+
});
|
|
669
|
+
let ne = {
|
|
670
|
+
sm: "h-[calc(var(--control-height-sm)*0.5)] w-[calc(var(--control-height-sm)*0.5)]",
|
|
671
|
+
default: "h-[calc(var(--control-height-md)*0.45)] w-[calc(var(--control-height-md)*0.45)]",
|
|
672
|
+
lg: "h-[calc(var(--control-height-lg)*0.45)] w-[calc(var(--control-height-lg)*0.45)]"
|
|
673
|
+
}, re = {
|
|
674
|
+
sm: "h-[calc(var(--control-height-sm)*0.2)] w-[calc(var(--control-height-sm)*0.2)]",
|
|
675
|
+
default: "h-[calc(var(--control-height-md)*0.2)] w-[calc(var(--control-height-md)*0.2)]",
|
|
676
|
+
lg: "h-[calc(var(--control-height-lg)*0.22)] w-[calc(var(--control-height-lg)*0.22)]"
|
|
677
|
+
}, K = h(() => e("relative inline-flex shrink-0 items-center justify-center rounded-[var(--radius-overlay)] border shadow-sm transition-colors peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring/35 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-surface-0 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", ne[T.value], S.value ? "border-primary bg-surface-1" : "border-border-strong bg-surface-1 hover:border-primary/70 hover:bg-surface-2", C.value && "cursor-not-allowed opacity-50", s.class)), q = h(() => e("inline-flex min-h-[var(--control-height-sm)] cursor-pointer items-center gap-2.5 text-sm leading-5 text-text-primary select-none", C.value && "cursor-not-allowed opacity-60", s.labelClass)), J = h(() => C.value ? S.value ? "checked disabled" : "unchecked disabled" : S.value ? "checked" : "unchecked");
|
|
678
|
+
return (t, r) => n.label !== void 0 || t.$slots.label ? (j(), v("label", {
|
|
679
|
+
key: 0,
|
|
680
|
+
for: p.value,
|
|
681
|
+
class: O(q.value),
|
|
682
|
+
"data-ug": "radio",
|
|
683
|
+
"data-state": J.value,
|
|
684
|
+
"data-variant": "default",
|
|
685
|
+
"data-size": T.value
|
|
686
|
+
}, [y("span", ut, [y("input", E({
|
|
687
|
+
id: p.value,
|
|
688
|
+
ref_key: "inputRef",
|
|
689
|
+
ref: m,
|
|
690
|
+
type: "radio",
|
|
691
|
+
class: "peer sr-only",
|
|
692
|
+
value: n.value,
|
|
693
|
+
checked: S.value,
|
|
694
|
+
disabled: C.value,
|
|
695
|
+
name: k.value,
|
|
696
|
+
form: M.value,
|
|
697
|
+
required: N.value,
|
|
698
|
+
"data-ug-slot": "input"
|
|
699
|
+
}, F.value, { onChange: L }), null, 16, dt), y("span", {
|
|
700
|
+
"aria-hidden": "true",
|
|
701
|
+
class: O(K.value),
|
|
702
|
+
"data-ug-slot": "indicator"
|
|
703
|
+
}, [S.value ? (j(), v("span", {
|
|
704
|
+
key: 0,
|
|
705
|
+
class: O(B(e)("rounded-[var(--radius-overlay)] bg-primary", re[T.value])),
|
|
706
|
+
"data-ug-slot": "dot"
|
|
707
|
+
}, null, 2)) : _("", !0)], 2)]), y("span", ft, [I(t.$slots, "label", {}, () => [b(R(n.label), 1)])])], 10, lt)) : (j(), v("span", {
|
|
708
|
+
key: 1,
|
|
709
|
+
"data-ug": "radio",
|
|
710
|
+
"data-state": J.value,
|
|
711
|
+
"data-variant": "default",
|
|
712
|
+
"data-size": T.value
|
|
713
|
+
}, [y("span", mt, [y("input", E({
|
|
714
|
+
id: p.value,
|
|
715
|
+
ref_key: "inputRef",
|
|
716
|
+
ref: m,
|
|
717
|
+
type: "radio",
|
|
718
|
+
class: "peer sr-only",
|
|
719
|
+
value: n.value,
|
|
720
|
+
checked: S.value,
|
|
721
|
+
disabled: C.value,
|
|
722
|
+
name: k.value,
|
|
723
|
+
form: M.value,
|
|
724
|
+
required: N.value,
|
|
725
|
+
"data-ug-slot": "input"
|
|
726
|
+
}, F.value, { onChange: L }), null, 16, ht), y("span", {
|
|
727
|
+
"aria-hidden": "true",
|
|
728
|
+
class: O(K.value),
|
|
729
|
+
"data-ug-slot": "indicator"
|
|
730
|
+
}, [S.value ? (j(), v("span", {
|
|
731
|
+
key: 0,
|
|
732
|
+
class: O(B(e)("rounded-[var(--radius-overlay)] bg-primary", re[T.value])),
|
|
733
|
+
"data-ug-slot": "dot"
|
|
734
|
+
}, null, 2)) : _("", !0)], 2)])], 8, pt));
|
|
735
|
+
}
|
|
736
|
+
}), _t = [
|
|
737
|
+
"aria-disabled",
|
|
738
|
+
"aria-required",
|
|
739
|
+
"data-state",
|
|
740
|
+
"data-variant",
|
|
741
|
+
"data-size"
|
|
742
|
+
], vt = /* @__PURE__ */ S({
|
|
743
|
+
name: "URadioGroup",
|
|
744
|
+
__name: "radio-group",
|
|
745
|
+
props: {
|
|
746
|
+
modelValue: {},
|
|
747
|
+
defaultValue: {},
|
|
748
|
+
disabled: {
|
|
749
|
+
type: Boolean,
|
|
750
|
+
default: void 0
|
|
751
|
+
},
|
|
752
|
+
size: {},
|
|
753
|
+
name: {},
|
|
754
|
+
form: {},
|
|
755
|
+
required: { type: Boolean },
|
|
756
|
+
orientation: { default: "vertical" },
|
|
757
|
+
class: {}
|
|
758
|
+
},
|
|
759
|
+
emits: ["update:modelValue", "change"],
|
|
760
|
+
setup(n, { emit: a }) {
|
|
761
|
+
let o = n, s = a, c = h(() => o.modelValue !== void 0), l = i(), u = P(null), d = `ug-radio-${V()}`, f = h(() => r(o.disabled, l.value.disabled)), p = h(() => t(o.size, l.value.size)), m = P(o.defaultValue), g = null, _ = h(() => c.value ? o.modelValue : m.value);
|
|
762
|
+
function y(e) {
|
|
763
|
+
c.value || (m.value = e), s("update:modelValue", e), s("change", e);
|
|
764
|
+
}
|
|
765
|
+
function b() {
|
|
766
|
+
c.value || (m.value = o.defaultValue);
|
|
767
|
+
}
|
|
768
|
+
function x() {
|
|
769
|
+
let e = o.form ? document.getElementById(o.form) : u.value?.closest("form") ?? null;
|
|
770
|
+
g !== e && (g?.removeEventListener("reset", b), g = e, g?.addEventListener("reset", b));
|
|
771
|
+
}
|
|
772
|
+
ee(() => void D(x)), G(() => o.form, () => void D(x)), A(() => g?.removeEventListener("reset", b)), M(ct, {
|
|
773
|
+
value: _,
|
|
774
|
+
onValueChange: y,
|
|
775
|
+
name: h(() => o.name ?? d),
|
|
776
|
+
form: h(() => o.form),
|
|
777
|
+
required: h(() => !!o.required),
|
|
778
|
+
disabled: f,
|
|
779
|
+
size: p
|
|
780
|
+
});
|
|
781
|
+
let S = h(() => e("flex", o.orientation === "vertical" ? "flex-col gap-2.5" : "flex-row flex-wrap gap-x-5 gap-y-2.5", o.class));
|
|
782
|
+
return (e, t) => (j(), v("div", {
|
|
783
|
+
ref_key: "rootRef",
|
|
784
|
+
ref: u,
|
|
785
|
+
role: "radiogroup",
|
|
786
|
+
"aria-disabled": f.value || void 0,
|
|
787
|
+
"aria-required": n.required || void 0,
|
|
788
|
+
class: O(S.value),
|
|
789
|
+
"data-ug": "radio-group",
|
|
790
|
+
"data-state": f.value ? "disabled" : "default",
|
|
791
|
+
"data-variant": n.orientation,
|
|
792
|
+
"data-size": p.value
|
|
793
|
+
}, [I(e.$slots, "default")], 10, _t));
|
|
794
|
+
}
|
|
795
|
+
}), yt = [
|
|
796
|
+
"data-state",
|
|
797
|
+
"data-variant",
|
|
798
|
+
"data-size"
|
|
799
|
+
], bt = [
|
|
800
|
+
"name",
|
|
801
|
+
"form",
|
|
802
|
+
"value",
|
|
803
|
+
"disabled"
|
|
804
|
+
], xt = ["disabled"], St = [
|
|
805
|
+
"value",
|
|
806
|
+
"disabled",
|
|
807
|
+
"readonly",
|
|
808
|
+
"placeholder",
|
|
809
|
+
"form",
|
|
810
|
+
"aria-valuemin",
|
|
811
|
+
"aria-valuemax",
|
|
812
|
+
"aria-valuenow",
|
|
813
|
+
"aria-readonly"
|
|
814
|
+
], Ct = ["disabled"], wt = ["disabled"], Tt = ["disabled"], Et = /* @__PURE__ */ S({
|
|
815
|
+
name: "UNumberInput",
|
|
816
|
+
inheritAttrs: !1,
|
|
817
|
+
__name: "number-input",
|
|
818
|
+
props: {
|
|
819
|
+
modelValue: {},
|
|
820
|
+
defaultValue: { default: 0 },
|
|
821
|
+
min: {},
|
|
822
|
+
max: {},
|
|
823
|
+
step: { default: 1 },
|
|
824
|
+
precision: {},
|
|
825
|
+
stepStrictly: {
|
|
826
|
+
type: Boolean,
|
|
827
|
+
default: !1
|
|
828
|
+
},
|
|
829
|
+
controls: {
|
|
830
|
+
type: Boolean,
|
|
831
|
+
default: !0
|
|
832
|
+
},
|
|
833
|
+
controlsPosition: { default: "both" },
|
|
834
|
+
disabled: {
|
|
835
|
+
type: Boolean,
|
|
836
|
+
default: void 0
|
|
837
|
+
},
|
|
838
|
+
readonly: {
|
|
839
|
+
type: Boolean,
|
|
840
|
+
default: !1
|
|
841
|
+
},
|
|
842
|
+
placeholder: {},
|
|
843
|
+
valueOnClear: { default: null },
|
|
844
|
+
formatter: {},
|
|
845
|
+
parser: {
|
|
846
|
+
type: Function,
|
|
847
|
+
default: (e) => {
|
|
848
|
+
let t = Number(e);
|
|
849
|
+
return Number.isFinite(t) ? t : null;
|
|
850
|
+
}
|
|
851
|
+
},
|
|
852
|
+
decrementIcon: {},
|
|
853
|
+
incrementIcon: {},
|
|
854
|
+
size: {},
|
|
855
|
+
class: {}
|
|
856
|
+
},
|
|
857
|
+
emits: [
|
|
858
|
+
"update:modelValue",
|
|
859
|
+
"input",
|
|
860
|
+
"change"
|
|
861
|
+
],
|
|
862
|
+
setup(n, { expose: a, emit: o }) {
|
|
863
|
+
let s = n, c = o, l = te(), u = i(), d = P(null), f = h(() => s.modelValue !== void 0), p = P(s.defaultValue), m = h(() => f.value ? s.modelValue : p.value), b = h(() => r(s.disabled, u.value.disabled)), x = h(() => t(s.size, u.value.size)), S = (e) => {
|
|
864
|
+
let [t = "", n = "0"] = Math.abs(e).toString().toLowerCase().split("e"), r = t.split(".")[1]?.length ?? 0, i = Number(n);
|
|
865
|
+
return Math.max(0, r - (Number.isFinite(i) ? i : 0));
|
|
866
|
+
}, C = h(() => Number.isFinite(s.step) && s.step > 0 ? s.step : 1), w = h(() => s.min !== void 0 && s.max !== void 0 ? Math.min(s.min, s.max) : s.min), T = h(() => s.min !== void 0 && s.max !== void 0 ? Math.max(s.min, s.max) : s.max), k = h(() => Math.min(12, Math.max(S(C.value), s.precision ?? S(C.value)))), M = P(!1);
|
|
867
|
+
function N(e) {
|
|
868
|
+
return e === null ? "" : s.formatter?.(e) ?? e.toFixed(k.value);
|
|
869
|
+
}
|
|
870
|
+
let F = P(N(m.value));
|
|
871
|
+
function R(e) {
|
|
872
|
+
let t = e;
|
|
873
|
+
if (w.value !== void 0 && (t = Math.max(w.value, t)), T.value !== void 0 && (t = Math.min(T.value, t)), s.stepStrictly) {
|
|
874
|
+
let e = w.value ?? 0;
|
|
875
|
+
t = e + Math.round((t - e) / C.value) * C.value;
|
|
876
|
+
}
|
|
877
|
+
return w.value !== void 0 && (t = Math.max(w.value, t)), T.value !== void 0 && (t = Math.min(T.value, t)), Number(t.toFixed(k.value));
|
|
878
|
+
}
|
|
879
|
+
function z(e, t = !1) {
|
|
880
|
+
let n = e === null ? null : R(e);
|
|
881
|
+
return f.value || (p.value = n), c("update:modelValue", n), c("input", n), t && c("change", n), n;
|
|
882
|
+
}
|
|
883
|
+
function V(e) {
|
|
884
|
+
if (b.value || s.readonly) return;
|
|
885
|
+
let t = z((m.value ?? w.value ?? 0) + e * C.value, !0);
|
|
886
|
+
F.value = N(t);
|
|
887
|
+
}
|
|
888
|
+
function H(e) {
|
|
889
|
+
let t = e.currentTarget.value;
|
|
890
|
+
if (F.value = t, t.trim() === "") return;
|
|
891
|
+
let n = s.parser(t);
|
|
892
|
+
n !== null && Number.isFinite(n) && z(n);
|
|
893
|
+
}
|
|
894
|
+
function U() {
|
|
895
|
+
let e = F.value.trim(), t = e === "" ? s.valueOnClear : s.parser(e), n = z(t === null || !Number.isFinite(t) ? s.valueOnClear : t, !0);
|
|
896
|
+
F.value = N(n);
|
|
897
|
+
}
|
|
898
|
+
function W(e) {
|
|
899
|
+
e.key === "ArrowUp" ? (e.preventDefault(), V(1)) : e.key === "ArrowDown" ? (e.preventDefault(), V(-1)) : e.key === "Enter" && U();
|
|
900
|
+
}
|
|
901
|
+
function ne() {
|
|
902
|
+
M.value = !0, F.value = m.value === null ? "" : String(m.value);
|
|
903
|
+
}
|
|
904
|
+
function re() {
|
|
905
|
+
M.value = !1, U();
|
|
906
|
+
}
|
|
907
|
+
G([
|
|
908
|
+
m,
|
|
909
|
+
() => s.formatter,
|
|
910
|
+
k
|
|
911
|
+
], () => {
|
|
912
|
+
M.value || (F.value = N(m.value));
|
|
913
|
+
});
|
|
914
|
+
let K = h(() => m.value !== null && w.value !== void 0 && m.value <= w.value), q = h(() => m.value !== null && T.value !== void 0 && m.value >= T.value), J = h(() => b.value || s.readonly), ie = h(() => [
|
|
915
|
+
b.value ? "disabled" : void 0,
|
|
916
|
+
s.readonly ? "readonly" : void 0,
|
|
917
|
+
K.value ? "min" : void 0,
|
|
918
|
+
q.value ? "max" : void 0
|
|
919
|
+
].filter(Boolean).join(" ") || "default"), Y = h(() => {
|
|
920
|
+
let e = { ...l };
|
|
921
|
+
return delete e.class, delete e.name, e;
|
|
922
|
+
}), oe = h(() => typeof l.name == "string" ? l.name : void 0), se = h(() => typeof l.form == "string" ? l.form : void 0), le = null;
|
|
923
|
+
function ue() {
|
|
924
|
+
if (f.value) return;
|
|
925
|
+
let e = s.defaultValue === null ? null : R(s.defaultValue);
|
|
926
|
+
p.value = e, F.value = N(e);
|
|
927
|
+
}
|
|
928
|
+
function pe() {
|
|
929
|
+
let e = d.value?.form ?? null;
|
|
930
|
+
le !== e && (le?.removeEventListener("reset", ue), le = e, le?.addEventListener("reset", ue));
|
|
931
|
+
}
|
|
932
|
+
ee(() => void D(pe)), G(se, () => void D(pe)), A(() => {
|
|
933
|
+
le?.removeEventListener("reset", ue);
|
|
934
|
+
});
|
|
935
|
+
let me = {
|
|
936
|
+
sm: "[height:var(--control-height-sm)] text-xs",
|
|
937
|
+
default: "[height:var(--control-height-md)] text-sm",
|
|
938
|
+
lg: "[height:var(--control-height-lg)] text-base"
|
|
939
|
+
}, X = {
|
|
940
|
+
sm: "w-[calc(var(--control-height-sm)*0.875)]",
|
|
941
|
+
default: "w-[var(--control-height-md)]",
|
|
942
|
+
lg: "w-[calc(var(--control-height-lg)*0.875)]"
|
|
943
|
+
}, he = {
|
|
944
|
+
sm: "w-7",
|
|
945
|
+
default: "w-8",
|
|
946
|
+
lg: "w-10"
|
|
947
|
+
}, ge = {
|
|
948
|
+
sm: 12,
|
|
949
|
+
default: 14,
|
|
950
|
+
lg: 16
|
|
951
|
+
}, Z = "inline-flex shrink-0 items-center justify-center bg-surface-2 text-text-secondary transition-colors hover:bg-surface-3 hover:text-text-primary disabled:pointer-events-none disabled:opacity-40", Q = h(() => e("inline-flex w-40 max-w-full min-w-0 items-stretch overflow-hidden border border-border-strong bg-surface-1 shadow-sm transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-ring/25 [border-radius:var(--radius-control)]", b.value && "pointer-events-none opacity-60", me[x.value], s.class));
|
|
952
|
+
return a({
|
|
953
|
+
focus: () => d.value?.focus(),
|
|
954
|
+
blur: () => d.value?.blur(),
|
|
955
|
+
select: () => d.value?.select(),
|
|
956
|
+
input: d
|
|
957
|
+
}), (t, r) => (j(), v("div", {
|
|
958
|
+
class: O(Q.value),
|
|
959
|
+
"data-ug": "number-input",
|
|
960
|
+
"data-state": ie.value,
|
|
961
|
+
"data-variant": n.controls ? n.controlsPosition : "control-only",
|
|
962
|
+
"data-size": x.value
|
|
963
|
+
}, [
|
|
964
|
+
oe.value ? (j(), v("input", {
|
|
965
|
+
key: 0,
|
|
966
|
+
type: "hidden",
|
|
967
|
+
name: oe.value,
|
|
968
|
+
form: se.value,
|
|
969
|
+
value: m.value === null ? "" : R(m.value),
|
|
970
|
+
disabled: b.value,
|
|
971
|
+
"data-ug-slot": "native-input"
|
|
972
|
+
}, null, 8, bt)) : _("", !0),
|
|
973
|
+
n.controls && n.controlsPosition === "both" ? (j(), v("button", {
|
|
974
|
+
key: 1,
|
|
975
|
+
type: "button",
|
|
976
|
+
"aria-label": "减少数值",
|
|
977
|
+
disabled: J.value || K.value,
|
|
978
|
+
class: O(B(e)(Z, X[x.value], "border-r border-border-base")),
|
|
979
|
+
"data-ug-slot": "decrement",
|
|
980
|
+
tabindex: "-1",
|
|
981
|
+
onClick: r[0] || (r[0] = (e) => V(-1))
|
|
982
|
+
}, [I(t.$slots, "decrement-icon", {}, () => [n.decrementIcon ? (j(), g(L(n.decrementIcon), { key: 0 })) : (j(), g(B(de), {
|
|
983
|
+
key: 1,
|
|
984
|
+
size: ge[x.value]
|
|
985
|
+
}, null, 8, ["size"]))])], 10, xt)) : _("", !0),
|
|
986
|
+
y("input", E({
|
|
987
|
+
ref_key: "inputRef",
|
|
988
|
+
ref: d,
|
|
989
|
+
type: "text",
|
|
990
|
+
role: "spinbutton",
|
|
991
|
+
inputmode: "decimal",
|
|
992
|
+
value: F.value,
|
|
993
|
+
disabled: b.value,
|
|
994
|
+
readonly: n.readonly,
|
|
995
|
+
placeholder: n.placeholder,
|
|
996
|
+
form: se.value,
|
|
997
|
+
"aria-valuemin": w.value,
|
|
998
|
+
"aria-valuemax": T.value,
|
|
999
|
+
"aria-valuenow": m.value ?? void 0,
|
|
1000
|
+
"aria-readonly": n.readonly || void 0,
|
|
1001
|
+
class: "min-w-0 flex-1 bg-transparent px-[var(--control-padding-x-sm)] text-center font-medium text-text-primary outline-none placeholder:text-text-tertiary",
|
|
1002
|
+
"data-ug-slot": "control"
|
|
1003
|
+
}, Y.value, {
|
|
1004
|
+
onInput: H,
|
|
1005
|
+
onKeydown: W,
|
|
1006
|
+
onFocus: ne,
|
|
1007
|
+
onBlur: re
|
|
1008
|
+
}), null, 16, St),
|
|
1009
|
+
n.controls && n.controlsPosition === "both" ? (j(), v("button", {
|
|
1010
|
+
key: 2,
|
|
1011
|
+
type: "button",
|
|
1012
|
+
"aria-label": "增加数值",
|
|
1013
|
+
disabled: J.value || q.value,
|
|
1014
|
+
class: O(B(e)(Z, X[x.value], "border-l border-border-base")),
|
|
1015
|
+
"data-ug-slot": "increment",
|
|
1016
|
+
tabindex: "-1",
|
|
1017
|
+
onClick: r[1] || (r[1] = (e) => V(1))
|
|
1018
|
+
}, [I(t.$slots, "increment-icon", {}, () => [n.incrementIcon ? (j(), g(L(n.incrementIcon), { key: 0 })) : (j(), g(B(fe), {
|
|
1019
|
+
key: 1,
|
|
1020
|
+
size: ge[x.value]
|
|
1021
|
+
}, null, 8, ["size"]))])], 10, Ct)) : _("", !0),
|
|
1022
|
+
n.controls && n.controlsPosition === "right" ? (j(), v("span", {
|
|
1023
|
+
key: 3,
|
|
1024
|
+
class: O(B(e)("grid shrink-0 grid-rows-2 border-l border-border-base", he[x.value])),
|
|
1025
|
+
"data-ug-slot": "controls"
|
|
1026
|
+
}, [y("button", {
|
|
1027
|
+
type: "button",
|
|
1028
|
+
"aria-label": "增加数值",
|
|
1029
|
+
disabled: J.value || q.value,
|
|
1030
|
+
class: O(B(e)(Z, "[min-height:0] border-b border-border-base")),
|
|
1031
|
+
"data-ug-slot": "increment",
|
|
1032
|
+
tabindex: "-1",
|
|
1033
|
+
onClick: r[2] || (r[2] = (e) => V(1))
|
|
1034
|
+
}, [I(t.$slots, "increment-icon", {}, () => [n.incrementIcon ? (j(), g(L(n.incrementIcon), { key: 0 })) : (j(), g(B(ce), {
|
|
1035
|
+
key: 1,
|
|
1036
|
+
size: ge[x.value]
|
|
1037
|
+
}, null, 8, ["size"]))])], 10, wt), y("button", {
|
|
1038
|
+
type: "button",
|
|
1039
|
+
"aria-label": "减少数值",
|
|
1040
|
+
disabled: J.value || K.value,
|
|
1041
|
+
class: O(B(e)(Z, "[min-height:0]")),
|
|
1042
|
+
"data-ug-slot": "decrement",
|
|
1043
|
+
tabindex: "-1",
|
|
1044
|
+
onClick: r[3] || (r[3] = (e) => V(-1))
|
|
1045
|
+
}, [I(t.$slots, "decrement-icon", {}, () => [n.decrementIcon ? (j(), g(L(n.decrementIcon), { key: 0 })) : (j(), g(B(ae), {
|
|
1046
|
+
key: 1,
|
|
1047
|
+
size: ge[x.value]
|
|
1048
|
+
}, null, 8, ["size"]))])], 10, Tt)], 2)) : _("", !0)
|
|
1049
|
+
], 10, yt));
|
|
1050
|
+
}
|
|
1051
|
+
}), Dt = [
|
|
1052
|
+
"data-state",
|
|
1053
|
+
"data-variant",
|
|
1054
|
+
"data-size",
|
|
1055
|
+
"data-orientation"
|
|
1056
|
+
], Ot = {
|
|
1057
|
+
key: 0,
|
|
1058
|
+
class: "shrink-0 text-xs font-medium tabular-nums text-text-primary",
|
|
1059
|
+
"data-ug-slot": "value"
|
|
1060
|
+
}, kt = [
|
|
1061
|
+
"min",
|
|
1062
|
+
"max",
|
|
1063
|
+
"step",
|
|
1064
|
+
"value",
|
|
1065
|
+
"disabled",
|
|
1066
|
+
"aria-label",
|
|
1067
|
+
"aria-valuetext",
|
|
1068
|
+
"aria-orientation",
|
|
1069
|
+
"data-ug-handle",
|
|
1070
|
+
"onInput",
|
|
1071
|
+
"onKeydown"
|
|
1072
|
+
], At = /* @__PURE__ */ S({
|
|
1073
|
+
name: "USlider",
|
|
1074
|
+
inheritAttrs: !1,
|
|
1075
|
+
__name: "slider",
|
|
1076
|
+
props: {
|
|
1077
|
+
modelValue: {},
|
|
1078
|
+
defaultValue: { default: 0 },
|
|
1079
|
+
min: { default: 0 },
|
|
1080
|
+
max: { default: 100 },
|
|
1081
|
+
step: { default: 1 },
|
|
1082
|
+
range: { type: Boolean },
|
|
1083
|
+
vertical: {
|
|
1084
|
+
type: Boolean,
|
|
1085
|
+
default: !1
|
|
1086
|
+
},
|
|
1087
|
+
height: { default: 200 },
|
|
1088
|
+
disabled: {
|
|
1089
|
+
type: Boolean,
|
|
1090
|
+
default: void 0
|
|
1091
|
+
},
|
|
1092
|
+
showValue: {
|
|
1093
|
+
type: Boolean,
|
|
1094
|
+
default: !1
|
|
1095
|
+
},
|
|
1096
|
+
showStops: {
|
|
1097
|
+
type: Boolean,
|
|
1098
|
+
default: !1
|
|
1099
|
+
},
|
|
1100
|
+
showInput: {
|
|
1101
|
+
type: Boolean,
|
|
1102
|
+
default: !1
|
|
1103
|
+
},
|
|
1104
|
+
showInputControls: {
|
|
1105
|
+
type: Boolean,
|
|
1106
|
+
default: !0
|
|
1107
|
+
},
|
|
1108
|
+
inputSize: {},
|
|
1109
|
+
showTooltip: {
|
|
1110
|
+
type: Boolean,
|
|
1111
|
+
default: !1
|
|
1112
|
+
},
|
|
1113
|
+
formatTooltip: {
|
|
1114
|
+
type: Function,
|
|
1115
|
+
default: (e) => e
|
|
1116
|
+
},
|
|
1117
|
+
formatValueText: {},
|
|
1118
|
+
tooltipPlacement: {},
|
|
1119
|
+
rangeStartLabel: { default: "最小值" },
|
|
1120
|
+
rangeEndLabel: { default: "最大值" },
|
|
1121
|
+
marks: {},
|
|
1122
|
+
class: {},
|
|
1123
|
+
size: {}
|
|
1124
|
+
},
|
|
1125
|
+
emits: [
|
|
1126
|
+
"update:modelValue",
|
|
1127
|
+
"input",
|
|
1128
|
+
"change"
|
|
1129
|
+
],
|
|
1130
|
+
setup(n, { expose: a, emit: o }) {
|
|
1131
|
+
let s = n, c = o, l = te(), u = i(), d = P([]), p = h(() => Math.min(s.min, s.max)), m = h(() => Math.max(s.min, s.max)), x = h(() => typeof s.step == "number" && Number.isFinite(s.step) && s.step > 0 ? s.step : 1), S = h(() => s.range ?? Array.isArray(s.modelValue ?? s.defaultValue)), C = h(() => s.modelValue !== void 0), w = h(() => r(s.disabled, u.value.disabled)), T = h(() => t(s.size, u.value.size)), M = (e) => Math.min(m.value, Math.max(p.value, Number.isFinite(e) ? e : p.value));
|
|
1132
|
+
function N(e) {
|
|
1133
|
+
if (!S.value) return M(Array.isArray(e) ? e[0] : e);
|
|
1134
|
+
let t = Array.isArray(e) ? e : [p.value, e], n = M(t[0] ?? p.value), r = M(t[1] ?? m.value);
|
|
1135
|
+
return n <= r ? [n, r] : [r, n];
|
|
1136
|
+
}
|
|
1137
|
+
let I = P(N(s.defaultValue)), z = h(() => N(C.value ? s.modelValue : I.value)), V = h(() => Array.isArray(z.value) ? z.value : [z.value]), H = h(() => V.value.map((e) => m.value === p.value ? 0 : (e - p.value) / (m.value - p.value) * 100)), U = h(() => S.value ? H.value[0] ?? 0 : 0), W = h(() => S.value ? H.value[1] ?? 0 : H.value[0] ?? 0), ne = h(() => w.value ? "disabled" : "default"), re = {
|
|
1138
|
+
sm: "h-[var(--control-height-sm)]",
|
|
1139
|
+
default: "h-[var(--control-height-md)]",
|
|
1140
|
+
lg: "h-[var(--control-height-lg)]"
|
|
1141
|
+
}, K = h(() => {
|
|
1142
|
+
let e = { ...l };
|
|
1143
|
+
return delete e.class, e;
|
|
1144
|
+
});
|
|
1145
|
+
function q(e) {
|
|
1146
|
+
return typeof e == "object" && e && "label" in e ? e : { label: e };
|
|
1147
|
+
}
|
|
1148
|
+
let J = h(() => Object.entries(s.marks ?? {}).map(([e, t]) => ({
|
|
1149
|
+
value: Number(e),
|
|
1150
|
+
...q(t)
|
|
1151
|
+
})).filter(({ value: e }) => Number.isFinite(e) && e >= p.value && e <= m.value).sort((e, t) => e.value - t.value)), ie = h(() => J.value.map(({ value: e }) => e)), Y = h(() => {
|
|
1152
|
+
if (!s.showStops) return [];
|
|
1153
|
+
if (s.step === "mark") return ie.value;
|
|
1154
|
+
let e = Math.floor((m.value - p.value) / x.value);
|
|
1155
|
+
return e > 1e3 ? [] : Array.from({ length: Math.max(0, e - 1) }, (e, t) => Number((p.value + x.value * (t + 1)).toFixed(12))).filter((e) => e < m.value);
|
|
1156
|
+
}), ae = h(() => s.tooltipPlacement ?? (s.vertical ? "right" : "top")), oe = {
|
|
1157
|
+
top: "bottom-full -translate-x-1/2 mb-1",
|
|
1158
|
+
right: "left-full -translate-y-1/2 ml-2",
|
|
1159
|
+
bottom: "top-full -translate-x-1/2 mt-1",
|
|
1160
|
+
left: "right-full -translate-y-1/2 mr-2"
|
|
1161
|
+
}, se = (e) => typeof e == "number" ? `${e}px` : e;
|
|
1162
|
+
function ce(e, t) {
|
|
1163
|
+
e instanceof HTMLInputElement && (d.value[t] = e);
|
|
1164
|
+
}
|
|
1165
|
+
function le(e, t = !1) {
|
|
1166
|
+
let n = e[0] ?? p.value, r = e[1] ?? m.value, i = S.value ? [Math.min(n, r), Math.max(n, r)] : n;
|
|
1167
|
+
return C.value || (I.value = i), t ? c("change", i) : (c("update:modelValue", i), c("input", i)), i;
|
|
1168
|
+
}
|
|
1169
|
+
function ue(e) {
|
|
1170
|
+
return s.step !== "mark" || ie.value.length === 0 ? e : ie.value.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
|
|
1171
|
+
}
|
|
1172
|
+
function de(e, t) {
|
|
1173
|
+
let n = [...V.value];
|
|
1174
|
+
n[e] = ue(Number(t.currentTarget.value)), S.value && (e === 0 ? n[0] = Math.min(n[0] ?? p.value, n[1] ?? m.value) : n[1] = Math.max(n[1] ?? m.value, n[0] ?? p.value)), le(n);
|
|
1175
|
+
}
|
|
1176
|
+
function fe(e, t) {
|
|
1177
|
+
if (s.step !== "mark" || ie.value.length === 0) return;
|
|
1178
|
+
let n = t.key === "ArrowRight" || t.key === "ArrowUp" ? 1 : t.key === "ArrowLeft" || t.key === "ArrowDown" ? -1 : 0;
|
|
1179
|
+
if (!n) return;
|
|
1180
|
+
t.preventDefault();
|
|
1181
|
+
let r = ie.value.indexOf(V.value[e] ?? 0), i = Math.min(ie.value.length - 1, Math.max(0, (r < 0 ? 0 : r) + n)), a = [...V.value];
|
|
1182
|
+
a[e] = ie.value[i] ?? p.value, le(a);
|
|
1183
|
+
}
|
|
1184
|
+
function pe(e) {
|
|
1185
|
+
e !== null && le([e]);
|
|
1186
|
+
}
|
|
1187
|
+
function me(e) {
|
|
1188
|
+
e !== null && c("change", e);
|
|
1189
|
+
}
|
|
1190
|
+
function X() {
|
|
1191
|
+
c("change", z.value);
|
|
1192
|
+
}
|
|
1193
|
+
function he(e) {
|
|
1194
|
+
if (w.value || e.target instanceof HTMLInputElement) return;
|
|
1195
|
+
let t = e.currentTarget.getBoundingClientRect(), n = s.vertical ? (t.bottom - e.clientY) / t.height : (e.clientX - t.left) / t.width, r = M(p.value + Math.min(1, Math.max(0, n)) * (m.value - p.value)), i = s.step === "mark" ? ue(r) : M(Number((p.value + Math.round((r - p.value) / x.value) * x.value).toFixed(12))), a = S.value && Math.abs((V.value[1] ?? m.value) - i) < Math.abs((V.value[0] ?? p.value) - i) ? 1 : 0, o = [...V.value];
|
|
1196
|
+
o[a] = i;
|
|
1197
|
+
let l = le(o);
|
|
1198
|
+
c("change", l), D(() => d.value[a]?.focus());
|
|
1199
|
+
}
|
|
1200
|
+
let ge = null;
|
|
1201
|
+
function Z() {
|
|
1202
|
+
C.value || (I.value = N(s.defaultValue));
|
|
1203
|
+
}
|
|
1204
|
+
function Q() {
|
|
1205
|
+
let e = d.value[0]?.form ?? null;
|
|
1206
|
+
ge !== e && (ge?.removeEventListener("reset", Z), ge = e, ge?.addEventListener("reset", Z));
|
|
1207
|
+
}
|
|
1208
|
+
ee(() => void D(Q)), G(() => l.form, () => void D(Q)), A(() => {
|
|
1209
|
+
ge?.removeEventListener("reset", Z);
|
|
1210
|
+
});
|
|
1211
|
+
function $(e) {
|
|
1212
|
+
return m.value === p.value ? 0 : (e - p.value) / (m.value - p.value) * 100;
|
|
1213
|
+
}
|
|
1214
|
+
return a({
|
|
1215
|
+
focus: (e = 0) => d.value[e]?.focus(),
|
|
1216
|
+
blur: () => d.value.forEach((e) => e.blur()),
|
|
1217
|
+
inputs: d
|
|
1218
|
+
}), (t, r) => (j(), v("div", {
|
|
1219
|
+
class: O(B(e)("flex gap-3", n.vertical ? "w-fit flex-row items-stretch" : "w-full flex-col", s.class)),
|
|
1220
|
+
"data-ug": "slider",
|
|
1221
|
+
"data-state": ne.value,
|
|
1222
|
+
"data-variant": S.value ? "range" : "single",
|
|
1223
|
+
"data-size": T.value,
|
|
1224
|
+
"data-orientation": n.vertical ? "vertical" : "horizontal"
|
|
1225
|
+
}, [n.showValue ? (j(), v("span", Ot, R(V.value.join(" – ")), 1)) : _("", !0), y("div", { class: O(B(e)("flex min-w-0 gap-4", n.vertical ? "items-stretch" : "w-full items-center")) }, [y("div", {
|
|
1226
|
+
class: O(B(e)("relative", n.vertical ? "w-[var(--control-height-md)]" : B(e)("min-w-0 flex-1", re[T.value]))),
|
|
1227
|
+
style: k(n.vertical ? { height: se(n.height) } : void 0),
|
|
1228
|
+
"data-ug-slot": "control",
|
|
1229
|
+
onPointerdown: he
|
|
1230
|
+
}, [
|
|
1231
|
+
y("div", {
|
|
1232
|
+
class: O(B(e)("pointer-events-none absolute [border-radius:var(--radius-control)] bg-surface-3", n.vertical ? "bottom-0 left-1/2 h-full [width:var(--ug-slider-track-size)] -translate-x-1/2" : "left-0 top-1/2 w-full [height:var(--ug-slider-track-size)] -translate-y-1/2")),
|
|
1233
|
+
"data-ug-slot": "track"
|
|
1234
|
+
}, null, 2),
|
|
1235
|
+
(j(!0), v(f, null, F(Y.value, (t) => (j(), v("span", {
|
|
1236
|
+
key: `stop-${t}`,
|
|
1237
|
+
class: O(B(e)("pointer-events-none absolute z-[1] size-1 rounded-full bg-surface-1", n.vertical ? "left-1/2 -translate-x-1/2 translate-y-1/2" : "top-1/2 -translate-x-1/2 -translate-y-1/2")),
|
|
1238
|
+
style: k(n.vertical ? { bottom: `${$(t)}%` } : { left: `${$(t)}%` }),
|
|
1239
|
+
"data-ug-slot": "stop"
|
|
1240
|
+
}, null, 6))), 128)),
|
|
1241
|
+
y("div", {
|
|
1242
|
+
class: O(B(e)("pointer-events-none absolute z-[2] [border-radius:var(--radius-control)] bg-primary", n.vertical ? "left-1/2 [width:var(--ug-slider-track-size)] -translate-x-1/2" : "top-1/2 [height:var(--ug-slider-track-size)] -translate-y-1/2")),
|
|
1243
|
+
style: k(n.vertical ? {
|
|
1244
|
+
bottom: `${U.value}%`,
|
|
1245
|
+
height: `${W.value - U.value}%`
|
|
1246
|
+
} : {
|
|
1247
|
+
insetInlineStart: `${U.value}%`,
|
|
1248
|
+
width: `${W.value - U.value}%`
|
|
1249
|
+
}),
|
|
1250
|
+
"data-ug-slot": "range"
|
|
1251
|
+
}, null, 6),
|
|
1252
|
+
(j(!0), v(f, null, F(V.value, (t, r) => (j(), v(f, { key: r }, [n.showTooltip ? (j(), v("span", {
|
|
1253
|
+
key: 0,
|
|
1254
|
+
class: O(B(e)("pointer-events-none absolute z-20 whitespace-nowrap [border-radius:var(--radius-control)] bg-surface-inverse px-[calc(var(--control-padding-x-sm)*0.5)] py-[calc(var(--content-gap)*0.25)] text-xs text-text-inverse", oe[ae.value])),
|
|
1255
|
+
style: k(ae.value === "left" || ae.value === "right" ? { bottom: `${H.value[r]}%` } : { left: `${H.value[r]}%` }),
|
|
1256
|
+
"data-ug-slot": "tooltip"
|
|
1257
|
+
}, R(n.formatTooltip(t)), 7)) : _("", !0), y("input", E({
|
|
1258
|
+
ref_for: !0,
|
|
1259
|
+
ref: (e) => ce(e, r),
|
|
1260
|
+
type: "range",
|
|
1261
|
+
min: p.value,
|
|
1262
|
+
max: m.value,
|
|
1263
|
+
step: x.value,
|
|
1264
|
+
value: t,
|
|
1265
|
+
disabled: w.value,
|
|
1266
|
+
"aria-label": typeof B(l)["aria-label"] == "string" ? B(l)["aria-label"] : S.value ? r === 0 ? n.rangeStartLabel : n.rangeEndLabel : "当前值",
|
|
1267
|
+
"aria-valuetext": n.formatValueText?.(t),
|
|
1268
|
+
"aria-orientation": n.vertical ? "vertical" : "horizontal",
|
|
1269
|
+
class: B(e)("pointer-events-none absolute z-10 appearance-none bg-transparent outline-none", "[&::-webkit-slider-runnable-track]:bg-transparent", "[&::-moz-range-track]:bg-transparent", "[&::-webkit-slider-thumb]:pointer-events-auto", "[&::-webkit-slider-thumb]:h-[calc(var(--control-height-sm)*0.625)] [&::-webkit-slider-thumb]:w-[calc(var(--control-height-sm)*0.625)]", "[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:[border-radius:var(--radius-control)]", "[&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary", "[&::-webkit-slider-thumb]:bg-surface-1 [&::-webkit-slider-thumb]:shadow-sm", "[&::-moz-range-thumb]:pointer-events-auto", "[&::-moz-range-thumb]:h-[calc(var(--control-height-sm)*0.625)] [&::-moz-range-thumb]:w-[calc(var(--control-height-sm)*0.625)]", "[&::-moz-range-thumb]:[border-radius:var(--radius-control)] [&::-moz-range-thumb]:border-2", "[&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-surface-1", "focus-visible:[&::-webkit-slider-thumb]:ring-4", "focus-visible:[&::-webkit-slider-thumb]:ring-ring/25", "disabled:cursor-not-allowed disabled:opacity-50", n.vertical ? "left-1/2 top-1/2 h-[calc(var(--control-height-sm)*0.625)] w-[var(--slider-length)] -translate-x-1/2 -translate-y-1/2 -rotate-90" : "inset-0 h-full w-full"),
|
|
1270
|
+
style: n.vertical ? { "--slider-length": se(n.height) } : void 0,
|
|
1271
|
+
"data-ug-slot": "input",
|
|
1272
|
+
"data-ug-handle": S.value ? r === 0 ? "start" : "end" : "single"
|
|
1273
|
+
}, { ref_for: !0 }, K.value, {
|
|
1274
|
+
onInput: (e) => de(r, e),
|
|
1275
|
+
onKeydown: (e) => fe(r, e),
|
|
1276
|
+
onChange: X,
|
|
1277
|
+
onBlur: X,
|
|
1278
|
+
onKeyup: X,
|
|
1279
|
+
onPointerup: X
|
|
1280
|
+
}), null, 16, kt)], 64))), 128)),
|
|
1281
|
+
(j(!0), v(f, null, F(J.value, (t) => (j(), v("span", {
|
|
1282
|
+
key: t.value,
|
|
1283
|
+
class: O(B(e)("pointer-events-none absolute text-xs text-text-secondary", n.vertical ? "left-[calc(50%+12px)] -translate-y-1/2" : "top-[calc(50%+12px)] -translate-x-1/2")),
|
|
1284
|
+
style: k(n.vertical ? { bottom: `${$(t.value)}%` } : { left: `${$(t.value)}%` }),
|
|
1285
|
+
"data-ug-slot": "mark"
|
|
1286
|
+
}, [y("span", { style: k(t.style) }, [typeof t.label != "string" && typeof t.label != "number" ? (j(), g(L(t.label), { key: 0 })) : (j(), v(f, { key: 1 }, [b(R(t.label), 1)], 64))], 4)], 6))), 128))
|
|
1287
|
+
], 38), n.showInput && !S.value && !n.vertical && n.step !== "mark" ? (j(), g(Et, {
|
|
1288
|
+
key: 0,
|
|
1289
|
+
class: "w-32 shrink-0",
|
|
1290
|
+
"model-value": V.value[0],
|
|
1291
|
+
min: p.value,
|
|
1292
|
+
max: m.value,
|
|
1293
|
+
step: x.value,
|
|
1294
|
+
controls: n.showInputControls,
|
|
1295
|
+
"controls-position": "right",
|
|
1296
|
+
size: n.inputSize ?? T.value,
|
|
1297
|
+
disabled: w.value,
|
|
1298
|
+
"aria-label": typeof B(l)["aria-label"] == "string" ? B(l)["aria-label"] : "滑块数值",
|
|
1299
|
+
"onUpdate:modelValue": pe,
|
|
1300
|
+
onChange: me
|
|
1301
|
+
}, null, 8, [
|
|
1302
|
+
"model-value",
|
|
1303
|
+
"min",
|
|
1304
|
+
"max",
|
|
1305
|
+
"step",
|
|
1306
|
+
"controls",
|
|
1307
|
+
"size",
|
|
1308
|
+
"disabled",
|
|
1309
|
+
"aria-label"
|
|
1310
|
+
])) : _("", !0)], 2)], 10, Dt));
|
|
1311
|
+
}
|
|
1312
|
+
}), jt = ["data-state"], Mt = [
|
|
1313
|
+
"value",
|
|
1314
|
+
"disabled",
|
|
1315
|
+
"aria-label",
|
|
1316
|
+
"data-state",
|
|
1317
|
+
"onInput",
|
|
1318
|
+
"onKeydown"
|
|
1319
|
+
], Nt = /* @__PURE__ */ S({
|
|
1320
|
+
name: "UOTPInput",
|
|
1321
|
+
__name: "otp-input",
|
|
1322
|
+
props: /*@__PURE__*/ T({
|
|
1323
|
+
length: { default: 6 },
|
|
1324
|
+
disabled: {
|
|
1325
|
+
type: Boolean,
|
|
1326
|
+
default: !1
|
|
1327
|
+
},
|
|
1328
|
+
class: { default: void 0 }
|
|
1329
|
+
}, {
|
|
1330
|
+
modelValue: { default: "" },
|
|
1331
|
+
modelModifiers: {}
|
|
1332
|
+
}),
|
|
1333
|
+
emits: /*@__PURE__*/ T(["complete"], ["update:modelValue"]),
|
|
1334
|
+
setup(t, { emit: n }) {
|
|
1335
|
+
let r = t, i = n, a = H(t, "modelValue"), o = P([]), s = h(() => Math.max(1, Math.floor(r.length) || 1)), c = h(() => a.value.replace(/[^\d ]/g, "").slice(0, s.value)), l = h(() => c.value.padEnd(s.value, " ").split("").map((e) => /\d/.test(e) ? e : ""));
|
|
1336
|
+
function u(e) {
|
|
1337
|
+
D(() => {
|
|
1338
|
+
let t = o.value[e];
|
|
1339
|
+
t && (t.focus(), t.setSelectionRange(t.value.length, t.value.length));
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
function d(e, t) {
|
|
1343
|
+
let n = c.value.padEnd(s.value, " ").split("");
|
|
1344
|
+
n[e] = t || " ";
|
|
1345
|
+
let r = n.join("").trimEnd();
|
|
1346
|
+
a.value = r, n.every((e) => /\d/.test(e)) && i("complete", r);
|
|
1347
|
+
}
|
|
1348
|
+
function p(e, t) {
|
|
1349
|
+
let n = t.target, r = n.value.replace(/\D/g, "").slice(-1);
|
|
1350
|
+
n.value = r, d(e, r), r && e < s.value - 1 && u(e + 1);
|
|
1351
|
+
}
|
|
1352
|
+
function m(e, t) {
|
|
1353
|
+
t.key === "ArrowLeft" ? (t.preventDefault(), e > 0 && u(e - 1)) : t.key === "ArrowRight" ? (t.preventDefault(), e < s.value - 1 && u(e + 1)) : t.key === "Backspace" && (t.preventDefault(), l.value[e] ?? "" ? d(e, "") : e > 0 && (d(e - 1, ""), u(e - 1)));
|
|
1354
|
+
}
|
|
1355
|
+
function g(e) {
|
|
1356
|
+
e.preventDefault();
|
|
1357
|
+
let t = (e.clipboardData?.getData("text") ?? "").replace(/\D/g, "").slice(0, s.value);
|
|
1358
|
+
if (!t) return;
|
|
1359
|
+
let n = t.padEnd(s.value, " ").split("").slice(0, s.value).join("").trimEnd();
|
|
1360
|
+
a.value = n, u(Math.min(t.length, s.value - 1)), t.length === s.value && i("complete", n);
|
|
1361
|
+
}
|
|
1362
|
+
function _(e) {
|
|
1363
|
+
e.target.select();
|
|
1364
|
+
}
|
|
1365
|
+
let y = h(() => e("flex items-center gap-[calc(var(--content-gap)*0.5)]", r.class)), b = h(() => r.disabled ? "disabled" : l.value.every((e) => /\d/.test(e)) ? "complete" : "default");
|
|
1366
|
+
function x(t) {
|
|
1367
|
+
return e("h-[var(--control-height-md)] w-[var(--control-height-md)] rounded-[var(--radius-control)] border text-center text-sm font-medium text-text-primary transition-colors", "outline-none focus:border-primary focus:ring-2 focus:ring-ring/20", "disabled:cursor-not-allowed disabled:opacity-50", t ? "border-border-strong" : "border-border-base");
|
|
1368
|
+
}
|
|
1369
|
+
function S(e) {
|
|
1370
|
+
return r.disabled ? "disabled" : e ? "filled" : "empty";
|
|
1371
|
+
}
|
|
1372
|
+
return (e, n) => (j(), v("div", {
|
|
1373
|
+
class: O(y.value),
|
|
1374
|
+
role: "group",
|
|
1375
|
+
"aria-label": "验证码输入",
|
|
1376
|
+
"data-ug": "otp-input",
|
|
1377
|
+
"data-state": b.value,
|
|
1378
|
+
"data-variant": "default",
|
|
1379
|
+
"data-size": "md"
|
|
1380
|
+
}, [(j(!0), v(f, null, F(l.value, (e, n) => (j(), v("input", {
|
|
1381
|
+
key: n,
|
|
1382
|
+
ref_for: !0,
|
|
1383
|
+
ref: (e) => {
|
|
1384
|
+
o.value[n] = e;
|
|
1385
|
+
},
|
|
1386
|
+
type: "text",
|
|
1387
|
+
inputmode: "numeric",
|
|
1388
|
+
pattern: "[0-9]",
|
|
1389
|
+
maxlength: 1,
|
|
1390
|
+
value: e,
|
|
1391
|
+
disabled: t.disabled,
|
|
1392
|
+
"aria-label": `验证码第 ${n + 1} 位`,
|
|
1393
|
+
class: O(x(e)),
|
|
1394
|
+
"data-ug-slot": "cell",
|
|
1395
|
+
"data-state": S(e),
|
|
1396
|
+
"data-variant": "default",
|
|
1397
|
+
"data-size": "md",
|
|
1398
|
+
onInput: (e) => p(n, e),
|
|
1399
|
+
onKeydown: (e) => m(n, e),
|
|
1400
|
+
onPaste: g,
|
|
1401
|
+
onClick: _
|
|
1402
|
+
}, null, 42, Mt))), 128))], 10, jt));
|
|
1403
|
+
}
|
|
1404
|
+
}), Pt = Symbol("ug-form-context"), Ft = Symbol("ug-form-field-context");
|
|
1405
|
+
function It() {
|
|
1406
|
+
let e = w(Ft);
|
|
1407
|
+
if (!e) throw Error("FormField 子组件必须在 <UFormField> 内使用");
|
|
1408
|
+
return e;
|
|
1409
|
+
}
|
|
1410
|
+
function Lt() {
|
|
1411
|
+
return w(Pt) || {
|
|
1412
|
+
layout: h(() => "vertical"),
|
|
1413
|
+
labelWidth: h(() => "8rem"),
|
|
1414
|
+
labelPosition: h(() => "top"),
|
|
1415
|
+
labelSuffix: h(() => ""),
|
|
1416
|
+
showRequiredMark: h(() => !0),
|
|
1417
|
+
requiredMarkPosition: h(() => "left"),
|
|
1418
|
+
showMessage: h(() => !0),
|
|
1419
|
+
inlineMessage: h(() => !1),
|
|
1420
|
+
controller: h(() => void 0)
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
function Rt(e) {
|
|
1424
|
+
return e;
|
|
1425
|
+
}
|
|
1426
|
+
function zt(e, t) {
|
|
1427
|
+
let n = e?.rules?.[t];
|
|
1428
|
+
return (Array.isArray(n) ? n : n ? [n] : []).some((e) => e.required);
|
|
1429
|
+
}
|
|
1430
|
+
//#endregion
|
|
1431
|
+
//#region src/components/form.vue?vue&type=script&setup=true&lang.ts
|
|
1432
|
+
var Bt = [
|
|
1433
|
+
"data-state",
|
|
1434
|
+
"data-size",
|
|
1435
|
+
"data-layout",
|
|
1436
|
+
"novalidate"
|
|
1437
|
+
], Vt = S({
|
|
1438
|
+
name: "UFormField",
|
|
1439
|
+
props: {
|
|
1440
|
+
name: {
|
|
1441
|
+
type: String,
|
|
1442
|
+
required: !0
|
|
1443
|
+
},
|
|
1444
|
+
error: {
|
|
1445
|
+
type: String,
|
|
1446
|
+
default: void 0
|
|
1447
|
+
},
|
|
1448
|
+
required: {
|
|
1449
|
+
type: Boolean,
|
|
1450
|
+
default: !1
|
|
1451
|
+
},
|
|
1452
|
+
status: {
|
|
1453
|
+
type: String,
|
|
1454
|
+
default: "default"
|
|
1455
|
+
},
|
|
1456
|
+
labelPosition: {
|
|
1457
|
+
type: String,
|
|
1458
|
+
default: void 0
|
|
1459
|
+
},
|
|
1460
|
+
class: {
|
|
1461
|
+
type: String,
|
|
1462
|
+
default: void 0
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1465
|
+
setup(t, { attrs: n, slots: r }) {
|
|
1466
|
+
let i = Lt(), a = V(), o = P(!1), s = P(!1), c = h(() => t.name), l = h(() => t.error === void 0 ? i.controller.value?.errors.value[t.name] : t.error), u = h(() => `form-field-${a}`), d = h(() => t.required || zt(i.controller.value, t.name)), f = h(() => l.value || s.value ? "invalid" : i.controller.value?.validatingFields.value[t.name] ? "validating" : t.status);
|
|
1467
|
+
return M(Ft, {
|
|
1468
|
+
name: c,
|
|
1469
|
+
error: l,
|
|
1470
|
+
id: u,
|
|
1471
|
+
required: d,
|
|
1472
|
+
status: f,
|
|
1473
|
+
labelPosition: h(() => t.labelPosition),
|
|
1474
|
+
descriptionPresent: o,
|
|
1475
|
+
messagePresent: s
|
|
1476
|
+
}), () => {
|
|
1477
|
+
let a = (e) => {
|
|
1478
|
+
e.currentTarget?.contains(e.relatedTarget) || i.controller.value?.handleBlur(t.name);
|
|
1479
|
+
};
|
|
1480
|
+
return C("div", {
|
|
1481
|
+
...n,
|
|
1482
|
+
ref: (e) => {
|
|
1483
|
+
i.controller.value?.registerField(t.name, e instanceof HTMLElement ? e : null);
|
|
1484
|
+
},
|
|
1485
|
+
class: e(n.class, t.class),
|
|
1486
|
+
"data-ug-slot": "field",
|
|
1487
|
+
"data-state": f.value,
|
|
1488
|
+
onFocusout: [n.onFocusout, a].filter(Boolean)
|
|
1489
|
+
}, r.default?.());
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
}), Ht = S({
|
|
1493
|
+
name: "UFormItem",
|
|
1494
|
+
props: { class: {
|
|
1495
|
+
type: String,
|
|
1496
|
+
default: void 0
|
|
1497
|
+
} },
|
|
1498
|
+
setup(t, { slots: n }) {
|
|
1499
|
+
let r = Lt(), i = It(), a = h(() => i.labelPosition.value ?? r.labelPosition.value), o = h(() => r.layout.value !== "inline" && a.value !== "top"), s = h(() => e(r.layout.value !== "inline" && a.value === "top" && "flex flex-col gap-1.5", o.value && "grid items-start gap-x-4 gap-y-1.5", r.layout.value === "inline" && "inline-flex flex-wrap items-start gap-2", t.class)), c = h(() => o.value ? { gridTemplateColumns: `${r.labelWidth.value} minmax(0, 1fr)` } : void 0);
|
|
1500
|
+
return () => C("div", {
|
|
1501
|
+
class: s.value,
|
|
1502
|
+
style: c.value,
|
|
1503
|
+
"data-ug-slot": "item",
|
|
1504
|
+
"data-layout": r.layout.value,
|
|
1505
|
+
"data-label-position": a.value
|
|
1506
|
+
}, n.default?.());
|
|
1507
|
+
}
|
|
1508
|
+
}), Ut = S({
|
|
1509
|
+
name: "UFormLabel",
|
|
1510
|
+
props: {
|
|
1511
|
+
required: {
|
|
1512
|
+
type: Boolean,
|
|
1513
|
+
default: void 0
|
|
1514
|
+
},
|
|
1515
|
+
for: {
|
|
1516
|
+
type: String,
|
|
1517
|
+
default: void 0
|
|
1518
|
+
},
|
|
1519
|
+
class: {
|
|
1520
|
+
type: String,
|
|
1521
|
+
default: void 0
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
setup(t, { slots: n }) {
|
|
1525
|
+
let r = It(), i = Lt(), a = h(() => r.labelPosition.value ?? i.labelPosition.value), o = h(() => e("leading-none text-sm font-medium text-text-primary", i.layout.value !== "inline" && a.value !== "top" && "col-start-1 pt-2", a.value === "right" && "text-right", a.value === "left" && "text-left", i.layout.value === "inline" && "pt-2", t.class)), s = h(() => t.for ?? r.id.value), c = h(() => t.required ?? (r.required.value && i.showRequiredMark.value));
|
|
1526
|
+
return () => {
|
|
1527
|
+
let t = c.value ? C("span", {
|
|
1528
|
+
class: e("text-danger", i.requiredMarkPosition.value === "left" ? "mr-0.5" : "ml-0.5"),
|
|
1529
|
+
"aria-hidden": "true"
|
|
1530
|
+
}, "*") : null;
|
|
1531
|
+
return C("label", {
|
|
1532
|
+
for: s.value,
|
|
1533
|
+
class: o.value,
|
|
1534
|
+
"data-ug-slot": "label",
|
|
1535
|
+
"data-required": c.value || void 0
|
|
1536
|
+
}, [
|
|
1537
|
+
i.requiredMarkPosition.value === "left" ? t : null,
|
|
1538
|
+
n.default?.(),
|
|
1539
|
+
i.labelSuffix.value,
|
|
1540
|
+
i.requiredMarkPosition.value === "right" ? t : null
|
|
1541
|
+
]);
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
}), Wt = S({
|
|
1545
|
+
name: "UFormControl",
|
|
1546
|
+
props: { class: {
|
|
1547
|
+
type: String,
|
|
1548
|
+
default: void 0
|
|
1549
|
+
} },
|
|
1550
|
+
setup(t, { slots: n }) {
|
|
1551
|
+
let r = It(), i = Lt(), a = h(() => r.labelPosition.value ?? i.labelPosition.value), o = h(() => `${r.id.value}-description`), s = h(() => `${r.id.value}-message`);
|
|
1552
|
+
return () => {
|
|
1553
|
+
let c = (n.default?.() ?? []).find((e) => typeof e.type != "symbol");
|
|
1554
|
+
if (!c) return null;
|
|
1555
|
+
let l = c.props ?? {}, u = [
|
|
1556
|
+
l["aria-describedby"],
|
|
1557
|
+
r.descriptionPresent.value ? o.value : void 0,
|
|
1558
|
+
r.messagePresent.value ? s.value : void 0
|
|
1559
|
+
].filter(Boolean).join(" ");
|
|
1560
|
+
return m(c, {
|
|
1561
|
+
id: l.id ?? r.id.value,
|
|
1562
|
+
name: l.name ?? r.name.value,
|
|
1563
|
+
class: e(l.class, i.layout.value !== "inline" && a.value !== "top" && "col-start-2 min-w-0", t.class) || void 0,
|
|
1564
|
+
"aria-describedby": u || void 0,
|
|
1565
|
+
"aria-invalid": r.status.value === "invalid" ? "true" : void 0,
|
|
1566
|
+
"aria-required": r.required.value ? "true" : void 0,
|
|
1567
|
+
"aria-busy": r.status.value === "validating" ? "true" : void 0,
|
|
1568
|
+
"data-ug-slot": "control",
|
|
1569
|
+
"data-state": r.status.value
|
|
1570
|
+
});
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
}), Gt = S({
|
|
1574
|
+
name: "UFormDescription",
|
|
1575
|
+
props: { class: {
|
|
1576
|
+
type: String,
|
|
1577
|
+
default: void 0
|
|
1578
|
+
} },
|
|
1579
|
+
setup(t, { slots: n }) {
|
|
1580
|
+
let r = It(), i = Lt(), a = h(() => r.labelPosition.value ?? i.labelPosition.value), o = h(() => e("text-xs text-text-secondary", i.layout.value !== "inline" && a.value !== "top" && "col-start-2", t.class)), s = h(() => `${r.id.value}-description`);
|
|
1581
|
+
return ee(() => {
|
|
1582
|
+
r.descriptionPresent.value = !0;
|
|
1583
|
+
}), A(() => {
|
|
1584
|
+
r.descriptionPresent.value = !1;
|
|
1585
|
+
}), () => C("p", {
|
|
1586
|
+
id: s.value,
|
|
1587
|
+
class: o.value,
|
|
1588
|
+
"data-ug-slot": "description"
|
|
1589
|
+
}, n.default?.());
|
|
1590
|
+
}
|
|
1591
|
+
}), Kt = S({
|
|
1592
|
+
name: "UFormMessage",
|
|
1593
|
+
props: { class: {
|
|
1594
|
+
type: String,
|
|
1595
|
+
default: void 0
|
|
1596
|
+
} },
|
|
1597
|
+
setup(t, { slots: n }) {
|
|
1598
|
+
let r = It(), i = Lt(), a = h(() => r.labelPosition.value ?? i.labelPosition.value), o = h(() => e("text-xs text-danger-soft-fg", i.layout.value !== "inline" && a.value !== "top" && "col-start-2", i.inlineMessage.value && "inline-flex", t.class)), s = h(() => `${r.id.value}-message`), c = !!n.default;
|
|
1599
|
+
function l() {
|
|
1600
|
+
r.messagePresent.value = i.showMessage.value && !!(r.error.value || c);
|
|
1601
|
+
}
|
|
1602
|
+
return l(), G([r.error, i.showMessage], l), A(() => {
|
|
1603
|
+
r.messagePresent.value = !1;
|
|
1604
|
+
}), () => {
|
|
1605
|
+
let e = r.error.value, t = n.default?.(), a = t && t.length > 0;
|
|
1606
|
+
return !e && !a || !i.showMessage.value ? null : C("p", {
|
|
1607
|
+
id: s.value,
|
|
1608
|
+
class: o.value,
|
|
1609
|
+
role: "alert",
|
|
1610
|
+
"data-ug-slot": "message",
|
|
1611
|
+
"data-state": "invalid"
|
|
1612
|
+
}, e ?? t);
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
}), qt = /* @__PURE__ */ S({
|
|
1616
|
+
name: "UForm",
|
|
1617
|
+
__name: "form",
|
|
1618
|
+
props: {
|
|
1619
|
+
class: { default: void 0 },
|
|
1620
|
+
size: {},
|
|
1621
|
+
disabled: {
|
|
1622
|
+
type: Boolean,
|
|
1623
|
+
default: void 0
|
|
1624
|
+
},
|
|
1625
|
+
layout: { default: "vertical" },
|
|
1626
|
+
labelWidth: { default: "8rem" },
|
|
1627
|
+
labelPosition: { default: void 0 },
|
|
1628
|
+
labelSuffix: { default: "" },
|
|
1629
|
+
showRequiredMark: {
|
|
1630
|
+
type: Boolean,
|
|
1631
|
+
default: !0
|
|
1632
|
+
},
|
|
1633
|
+
requiredMarkPosition: { default: "left" },
|
|
1634
|
+
showMessage: {
|
|
1635
|
+
type: Boolean,
|
|
1636
|
+
default: !0
|
|
1637
|
+
},
|
|
1638
|
+
inlineMessage: {
|
|
1639
|
+
type: Boolean,
|
|
1640
|
+
default: !1
|
|
1641
|
+
},
|
|
1642
|
+
controller: { default: void 0 }
|
|
1643
|
+
},
|
|
1644
|
+
emits: ["submit", "reset"],
|
|
1645
|
+
setup(o, { emit: s }) {
|
|
1646
|
+
let c = o, l = s, u = i(), d = h(() => t(c.size, u.value.size)), f = h(() => r(c.disabled, u.value.disabled)), p = h(() => n(d.value)), m = h(() => e(c.class)), g = h(() => typeof c.labelWidth == "number" ? `${c.labelWidth}px` : c.labelWidth), _ = h(() => c.labelPosition ?? (c.layout === "vertical" ? "top" : "right"));
|
|
1647
|
+
M(Pt, {
|
|
1648
|
+
layout: h(() => c.layout),
|
|
1649
|
+
labelWidth: g,
|
|
1650
|
+
labelPosition: _,
|
|
1651
|
+
labelSuffix: h(() => c.labelSuffix),
|
|
1652
|
+
showRequiredMark: h(() => c.showRequiredMark),
|
|
1653
|
+
requiredMarkPosition: h(() => c.requiredMarkPosition),
|
|
1654
|
+
showMessage: h(() => c.showMessage),
|
|
1655
|
+
inlineMessage: h(() => c.inlineMessage),
|
|
1656
|
+
controller: h(() => Rt(c.controller))
|
|
1657
|
+
});
|
|
1658
|
+
function y(e) {
|
|
1659
|
+
l("submit", e);
|
|
1660
|
+
}
|
|
1661
|
+
function b(e) {
|
|
1662
|
+
l("reset", e), e.defaultPrevented || Rt(c.controller)?.reset();
|
|
1663
|
+
}
|
|
1664
|
+
return (e, t) => (j(), v("form", {
|
|
1665
|
+
class: O(m.value),
|
|
1666
|
+
"data-ug": "form",
|
|
1667
|
+
"data-state": f.value ? "disabled" : "default",
|
|
1668
|
+
"data-variant": "default",
|
|
1669
|
+
"data-size": d.value,
|
|
1670
|
+
"data-layout": c.layout,
|
|
1671
|
+
novalidate: c.controller ? !0 : void 0,
|
|
1672
|
+
onSubmit: y,
|
|
1673
|
+
onReset: b
|
|
1674
|
+
}, [x(a, {
|
|
1675
|
+
size: p.value,
|
|
1676
|
+
disabled: f.value
|
|
1677
|
+
}, {
|
|
1678
|
+
default: ne(() => [I(e.$slots, "default")]),
|
|
1679
|
+
_: 3
|
|
1680
|
+
}, 8, ["size", "disabled"])], 42, Bt));
|
|
1681
|
+
}
|
|
1682
|
+
}), Jt = Symbol("ug-tabs-context");
|
|
1683
|
+
//#endregion
|
|
1684
|
+
//#region src/components/tabs.vue?vue&type=script&setup=true&lang.ts
|
|
1685
|
+
function Yt(e, t, n) {
|
|
1686
|
+
return `${e}-${n}-${encodeURIComponent(t)}`;
|
|
1687
|
+
}
|
|
1688
|
+
function Xt() {
|
|
1689
|
+
let e = w(Jt);
|
|
1690
|
+
if (!e) throw Error("Tabs 子组件必须在 <UTabs> 内使用");
|
|
1691
|
+
return e;
|
|
1692
|
+
}
|
|
1693
|
+
var Zt = S({
|
|
1694
|
+
name: "UTabsList",
|
|
1695
|
+
props: { class: {
|
|
1696
|
+
type: String,
|
|
1697
|
+
default: void 0
|
|
1698
|
+
} },
|
|
1699
|
+
setup(t, { slots: n }) {
|
|
1700
|
+
let r = h(() => e("inline-flex w-full items-center gap-0 border-b border-border-base", t.class));
|
|
1701
|
+
return () => C("div", {
|
|
1702
|
+
role: "tablist",
|
|
1703
|
+
class: r.value,
|
|
1704
|
+
"data-ug-slot": "list"
|
|
1705
|
+
}, n.default?.());
|
|
1706
|
+
}
|
|
1707
|
+
}), Qt = S({
|
|
1708
|
+
name: "UTabsTrigger",
|
|
1709
|
+
props: {
|
|
1710
|
+
value: {
|
|
1711
|
+
type: String,
|
|
1712
|
+
required: !0
|
|
1713
|
+
},
|
|
1714
|
+
disabled: {
|
|
1715
|
+
type: Boolean,
|
|
1716
|
+
default: !1
|
|
1717
|
+
},
|
|
1718
|
+
class: {
|
|
1719
|
+
type: String,
|
|
1720
|
+
default: void 0
|
|
1721
|
+
}
|
|
1722
|
+
},
|
|
1723
|
+
emits: { click: (e) => !0 },
|
|
1724
|
+
setup(t, { emit: n, slots: r }) {
|
|
1725
|
+
let i = Xt(), a = h(() => i.modelValue.value === t.value), o = h(() => [a.value ? "selected" : void 0, t.disabled ? "disabled" : void 0].filter(Boolean).join(" ") || "default"), s = h(() => e("relative px-[var(--control-padding-x-md)] py-[calc(var(--content-gap)*0.5)] text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-offset-1 disabled:pointer-events-none disabled:opacity-50", "after:absolute after:bottom-0 after:left-0 after:h-[calc(var(--control-height-sm)*0.0625)] after:w-full after:transition-colors", a.value ? "text-text-primary after:bg-primary" : "text-text-secondary hover:text-text-primary after:bg-transparent", t.class));
|
|
1726
|
+
function c(e) {
|
|
1727
|
+
t.disabled || (i.setValue(t.value), n("click", e));
|
|
1728
|
+
}
|
|
1729
|
+
function l(e) {
|
|
1730
|
+
if (![
|
|
1731
|
+
"ArrowLeft",
|
|
1732
|
+
"ArrowRight",
|
|
1733
|
+
"Home",
|
|
1734
|
+
"End"
|
|
1735
|
+
].includes(e.key)) return;
|
|
1736
|
+
let t = e.currentTarget, n = Array.from(t.closest("[role=\"tablist\"]")?.querySelectorAll("[role=\"tab\"]:not(:disabled)") ?? []), r = n.indexOf(t);
|
|
1737
|
+
if (r < 0 || n.length === 0) return;
|
|
1738
|
+
e.preventDefault();
|
|
1739
|
+
let i = e.key === "Home" ? 0 : e.key === "End" ? n.length - 1 : (r + (e.key === "ArrowRight" ? 1 : -1) + n.length) % n.length;
|
|
1740
|
+
n[i]?.focus(), n[i]?.click();
|
|
1741
|
+
}
|
|
1742
|
+
return () => C("button", {
|
|
1743
|
+
type: "button",
|
|
1744
|
+
role: "tab",
|
|
1745
|
+
id: Yt(i.baseId, t.value, "trigger"),
|
|
1746
|
+
"aria-controls": Yt(i.baseId, t.value, "panel"),
|
|
1747
|
+
"aria-selected": a.value,
|
|
1748
|
+
tabindex: a.value ? 0 : -1,
|
|
1749
|
+
disabled: t.disabled,
|
|
1750
|
+
class: s.value,
|
|
1751
|
+
"data-ug-slot": "trigger",
|
|
1752
|
+
"data-state": o.value,
|
|
1753
|
+
"data-variant": "default",
|
|
1754
|
+
"data-size": "md",
|
|
1755
|
+
onClick: c,
|
|
1756
|
+
onKeydown: l
|
|
1757
|
+
}, r.default?.());
|
|
1758
|
+
}
|
|
1759
|
+
}), $t = S({
|
|
1760
|
+
name: "UTabsContent",
|
|
1761
|
+
props: {
|
|
1762
|
+
value: {
|
|
1763
|
+
type: String,
|
|
1764
|
+
required: !0
|
|
1765
|
+
},
|
|
1766
|
+
class: {
|
|
1767
|
+
type: String,
|
|
1768
|
+
default: void 0
|
|
1769
|
+
}
|
|
1770
|
+
},
|
|
1771
|
+
setup(t, { slots: n }) {
|
|
1772
|
+
let r = Xt(), i = h(() => r.modelValue.value === t.value), a = h(() => e("mt-4 focus-visible:outline-none", t.class));
|
|
1773
|
+
return () => i.value ? C("div", {
|
|
1774
|
+
role: "tabpanel",
|
|
1775
|
+
id: Yt(r.baseId, t.value, "panel"),
|
|
1776
|
+
"aria-labelledby": Yt(r.baseId, t.value, "trigger"),
|
|
1777
|
+
tabindex: 0,
|
|
1778
|
+
class: a.value,
|
|
1779
|
+
"data-ug-slot": "content",
|
|
1780
|
+
"data-state": "selected"
|
|
1781
|
+
}, n.default?.()) : null;
|
|
1782
|
+
}
|
|
1783
|
+
}), en = /* @__PURE__ */ S({
|
|
1784
|
+
name: "UTabs",
|
|
1785
|
+
__name: "tabs",
|
|
1786
|
+
props: /*@__PURE__*/ T({ class: { default: void 0 } }, {
|
|
1787
|
+
modelValue: { default: "" },
|
|
1788
|
+
modelModifiers: {}
|
|
1789
|
+
}),
|
|
1790
|
+
emits: /*@__PURE__*/ T(["valueChange"], ["update:modelValue"]),
|
|
1791
|
+
setup(t, { emit: n }) {
|
|
1792
|
+
let r = t, i = H(t, "modelValue"), a = n, o = h(() => e("w-full", r.class)), s = `ug-tabs-${V()}`;
|
|
1793
|
+
function c(e) {
|
|
1794
|
+
i.value = e, a("valueChange", e);
|
|
1795
|
+
}
|
|
1796
|
+
return M(Jt, {
|
|
1797
|
+
modelValue: i,
|
|
1798
|
+
setValue: c,
|
|
1799
|
+
baseId: s
|
|
1800
|
+
}), (e, t) => (j(), v("div", {
|
|
1801
|
+
class: O(o.value),
|
|
1802
|
+
"data-ug": "tabs",
|
|
1803
|
+
"data-state": "default",
|
|
1804
|
+
"data-variant": "default",
|
|
1805
|
+
"data-size": "md"
|
|
1806
|
+
}, [I(e.$slots, "default")], 2));
|
|
1807
|
+
}
|
|
1808
|
+
}), tn = Symbol("ug-accordion-context"), nn = Symbol("ug-accordion-item-context"), rn = ["data-variant"];
|
|
1809
|
+
function an() {
|
|
1810
|
+
let e = w(tn);
|
|
1811
|
+
if (!e) throw Error("Accordion 子组件必须在 <UAccordion> 内使用");
|
|
1812
|
+
return e;
|
|
1813
|
+
}
|
|
1814
|
+
function on() {
|
|
1815
|
+
let e = w(nn);
|
|
1816
|
+
if (!e) throw Error("AccordionTrigger/AccordionContent 必须在 <UAccordionItem> 内使用");
|
|
1817
|
+
return e;
|
|
1818
|
+
}
|
|
1819
|
+
var sn = S({
|
|
1820
|
+
name: "UAccordionItem",
|
|
1821
|
+
inheritAttrs: !1,
|
|
1822
|
+
props: {
|
|
1823
|
+
value: {
|
|
1824
|
+
type: String,
|
|
1825
|
+
required: !0
|
|
1826
|
+
},
|
|
1827
|
+
class: {
|
|
1828
|
+
type: String,
|
|
1829
|
+
default: void 0
|
|
1830
|
+
},
|
|
1831
|
+
disabled: {
|
|
1832
|
+
type: Boolean,
|
|
1833
|
+
default: !1
|
|
1834
|
+
}
|
|
1835
|
+
},
|
|
1836
|
+
setup(t, { attrs: n, slots: r }) {
|
|
1837
|
+
let i = an(), a = V(), o = h(() => i.type.value === "single" ? i.value.value === t.value : i.value.value.includes(t.value));
|
|
1838
|
+
M(nn, {
|
|
1839
|
+
itemValue: t.value,
|
|
1840
|
+
isOpen: o,
|
|
1841
|
+
disabled: z(t, "disabled"),
|
|
1842
|
+
triggerId: `${a}-trigger`,
|
|
1843
|
+
contentId: `${a}-content`
|
|
1844
|
+
});
|
|
1845
|
+
let s = h(() => e("", t.class));
|
|
1846
|
+
return () => C("div", {
|
|
1847
|
+
...n,
|
|
1848
|
+
class: s.value,
|
|
1849
|
+
"aria-disabled": t.disabled || void 0,
|
|
1850
|
+
"data-disabled": t.disabled ? "" : void 0,
|
|
1851
|
+
"data-ug-slot": "item",
|
|
1852
|
+
"data-state": o.value ? "open" : "closed"
|
|
1853
|
+
}, r.default?.());
|
|
1854
|
+
}
|
|
1855
|
+
}), cn = S({
|
|
1856
|
+
name: "UAccordionTrigger",
|
|
1857
|
+
inheritAttrs: !1,
|
|
1858
|
+
props: {
|
|
1859
|
+
class: {
|
|
1860
|
+
type: String,
|
|
1861
|
+
default: void 0
|
|
1862
|
+
},
|
|
1863
|
+
disabled: {
|
|
1864
|
+
type: Boolean,
|
|
1865
|
+
default: !1
|
|
1866
|
+
}
|
|
1867
|
+
},
|
|
1868
|
+
emits: { click: (e) => !0 },
|
|
1869
|
+
setup(t, { attrs: n, emit: r, slots: i }) {
|
|
1870
|
+
let a = an(), o = on(), s = h(() => o.disabled.value || t.disabled), c = h(() => e("flex min-h-[var(--control-height-md)] w-full items-center justify-between gap-[calc(var(--content-gap)*0.75)] px-[var(--control-padding-x-md)] py-[calc(var(--content-gap)*0.625)] text-left text-sm font-medium text-text-primary transition-colors hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-inset", s.value ? "cursor-not-allowed opacity-50" : "", t.class)), l = h(() => e("shrink-0 text-text-secondary transition-transform duration-200", o.isOpen.value ? "rotate-180" : ""));
|
|
1871
|
+
function u(e) {
|
|
1872
|
+
r("click", e), !e.defaultPrevented && !s.value && a.onValueChange(o.itemValue);
|
|
1873
|
+
}
|
|
1874
|
+
return () => C("button", {
|
|
1875
|
+
...n,
|
|
1876
|
+
id: o.triggerId,
|
|
1877
|
+
type: "button",
|
|
1878
|
+
"aria-expanded": o.isOpen.value,
|
|
1879
|
+
"aria-controls": o.contentId,
|
|
1880
|
+
disabled: s.value,
|
|
1881
|
+
class: c.value,
|
|
1882
|
+
"data-ug-slot": "trigger",
|
|
1883
|
+
"data-state": o.isOpen.value ? "open" : "closed",
|
|
1884
|
+
onClick: u
|
|
1885
|
+
}, [...i.default?.() ?? [], C(ae, {
|
|
1886
|
+
size: 16,
|
|
1887
|
+
class: l.value,
|
|
1888
|
+
"data-ug-slot": "indicator"
|
|
1889
|
+
})]);
|
|
1890
|
+
}
|
|
1891
|
+
}), ln = S({
|
|
1892
|
+
name: "UAccordionContent",
|
|
1893
|
+
inheritAttrs: !1,
|
|
1894
|
+
props: { class: {
|
|
1895
|
+
type: String,
|
|
1896
|
+
default: void 0
|
|
1897
|
+
} },
|
|
1898
|
+
setup(t, { attrs: n, slots: r }) {
|
|
1899
|
+
let i = on(), a = h(() => e("px-[var(--control-padding-x-md)] pb-[calc(var(--content-gap)*1.25)] pt-[calc(var(--content-gap)*0.375)] text-sm leading-5 text-text-secondary", t.class));
|
|
1900
|
+
return () => i.isOpen.value ? C("div", {
|
|
1901
|
+
...n,
|
|
1902
|
+
id: i.contentId,
|
|
1903
|
+
role: "region",
|
|
1904
|
+
"aria-labelledby": i.triggerId,
|
|
1905
|
+
class: a.value,
|
|
1906
|
+
"data-ug-slot": "content",
|
|
1907
|
+
"data-state": "open"
|
|
1908
|
+
}, r.default?.()) : null;
|
|
1909
|
+
}
|
|
1910
|
+
}), un = /* @__PURE__ */ S({
|
|
1911
|
+
name: "UAccordion",
|
|
1912
|
+
__name: "accordion",
|
|
1913
|
+
props: {
|
|
1914
|
+
type: { default: "single" },
|
|
1915
|
+
modelValue: { default: void 0 },
|
|
1916
|
+
defaultValue: { default: void 0 },
|
|
1917
|
+
collapsible: {
|
|
1918
|
+
type: Boolean,
|
|
1919
|
+
default: !1
|
|
1920
|
+
},
|
|
1921
|
+
class: { default: void 0 }
|
|
1922
|
+
},
|
|
1923
|
+
emits: ["update:modelValue"],
|
|
1924
|
+
setup(t, { emit: n }) {
|
|
1925
|
+
let r = t, i = n, a = P(r.defaultValue === void 0 ? r.type === "multiple" ? [] : "" : r.defaultValue), o = h(() => r.modelValue !== void 0), s = h(() => o.value ? r.modelValue : a.value);
|
|
1926
|
+
G(() => r.type, (e) => {
|
|
1927
|
+
o.value || (a.value = e === "multiple" ? [] : "");
|
|
1928
|
+
});
|
|
1929
|
+
let c = h(() => e("w-full overflow-hidden divide-y divide-border-base border border-border-base [border-radius:var(--radius-panel)]", r.class));
|
|
1930
|
+
function l(e) {
|
|
1931
|
+
if (r.type === "single") {
|
|
1932
|
+
let t = s.value === e && r.collapsible ? "" : e;
|
|
1933
|
+
o.value || (a.value = t), i("update:modelValue", t);
|
|
1934
|
+
} else {
|
|
1935
|
+
let t = s.value, n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
|
|
1936
|
+
o.value || (a.value = n), i("update:modelValue", n);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
return M(tn, {
|
|
1940
|
+
type: z(r, "type"),
|
|
1941
|
+
value: s,
|
|
1942
|
+
onValueChange: l,
|
|
1943
|
+
collapsible: z(r, "collapsible")
|
|
1944
|
+
}), (e, n) => (j(), v("div", {
|
|
1945
|
+
class: O(c.value),
|
|
1946
|
+
"data-ug": "accordion",
|
|
1947
|
+
"data-state": "default",
|
|
1948
|
+
"data-variant": t.type,
|
|
1949
|
+
"data-size": "md"
|
|
1950
|
+
}, [I(e.$slots, "default")], 10, rn));
|
|
1951
|
+
}
|
|
1952
|
+
}), dn = ["data-state", "data-variant"], fn = ["aria-current", "data-state"], pn = {
|
|
1953
|
+
key: 1,
|
|
1954
|
+
"data-ug-slot": "icon"
|
|
1955
|
+
}, mn = /* @__PURE__ */ S({
|
|
1956
|
+
__name: "steps",
|
|
1957
|
+
props: {
|
|
1958
|
+
current: {},
|
|
1959
|
+
items: {},
|
|
1960
|
+
direction: { default: "horizontal" },
|
|
1961
|
+
status: { default: "process" },
|
|
1962
|
+
class: {}
|
|
1963
|
+
},
|
|
1964
|
+
setup(t) {
|
|
1965
|
+
let n = t, r = {
|
|
1966
|
+
horizontal: "flex items-start",
|
|
1967
|
+
vertical: "flex flex-col gap-1"
|
|
1968
|
+
}, i = h(() => e(r[n.direction], n.class)), a = h(() => n.direction === "horizontal");
|
|
1969
|
+
function o(e) {
|
|
1970
|
+
return e < n.current || e === n.current && n.status === "finish";
|
|
1971
|
+
}
|
|
1972
|
+
function s(e) {
|
|
1973
|
+
return e === n.current && n.status !== "finish";
|
|
1974
|
+
}
|
|
1975
|
+
function c(e) {
|
|
1976
|
+
return e === n.current && n.status === "error";
|
|
1977
|
+
}
|
|
1978
|
+
function l(e) {
|
|
1979
|
+
return o(e) ? "border-primary bg-primary text-primary-fg shadow-primary/20" : c(e) ? "border-danger bg-danger-soft text-danger-soft-fg shadow-danger/10" : s(e) ? "border-primary bg-primary-soft text-primary-soft-fg shadow-primary/10" : "border-border-strong bg-surface-1 text-text-tertiary";
|
|
1980
|
+
}
|
|
1981
|
+
function u(e) {
|
|
1982
|
+
return c(e) ? "text-danger" : s(e) ? "text-primary" : o(e) ? "text-text-primary" : "text-text-tertiary";
|
|
1983
|
+
}
|
|
1984
|
+
function d(e) {
|
|
1985
|
+
return o(e) ? "bg-primary" : "bg-border-strong";
|
|
1986
|
+
}
|
|
1987
|
+
return (n, r) => (j(), v("div", {
|
|
1988
|
+
class: O(i.value),
|
|
1989
|
+
role: "list",
|
|
1990
|
+
"aria-label": "进度步骤",
|
|
1991
|
+
"data-ug": "steps",
|
|
1992
|
+
"data-state": t.status,
|
|
1993
|
+
"data-variant": t.direction,
|
|
1994
|
+
"data-size": "md"
|
|
1995
|
+
}, [(j(!0), v(f, null, F(t.items, (n, r) => (j(), v("div", {
|
|
1996
|
+
key: r,
|
|
1997
|
+
role: "listitem",
|
|
1998
|
+
"aria-current": s(r) ? "step" : void 0,
|
|
1999
|
+
class: O(B(e)(a.value ? "flex flex-1 items-start" : "flex items-start")),
|
|
2000
|
+
"data-ug-slot": "item",
|
|
2001
|
+
"data-state": c(r) ? "error" : o(r) ? "finish" : s(r) ? "process" : "pending"
|
|
2002
|
+
}, [
|
|
2003
|
+
y("div", { class: O(B(e)("flex", a.value ? "flex-col items-center" : "items-start")) }, [y("div", {
|
|
2004
|
+
class: O(B(e)("flex shrink-0 items-center justify-center border-2 text-sm font-semibold shadow-sm transition-colors [height:var(--control-height-md)] [width:var(--control-height-md)] [border-radius:calc(var(--radius-overlay)*999)]", l(r))),
|
|
2005
|
+
"data-ug-slot": "marker"
|
|
2006
|
+
}, [o(r) ? (j(), g(B(ie), {
|
|
2007
|
+
key: 0,
|
|
2008
|
+
size: 16,
|
|
2009
|
+
"stroke-width": 2.5,
|
|
2010
|
+
"data-ug-slot": "icon"
|
|
2011
|
+
})) : (j(), v("span", pn, R(r + 1), 1))], 2), !a.value && r < t.items.length - 1 ? (j(), v("div", {
|
|
2012
|
+
key: 0,
|
|
2013
|
+
class: O(B(e)("ml-[calc(var(--control-height-md)*0.425)] mt-1 flex-1 self-stretch [width:calc(var(--control-height-sm)*0.0625)] [border-radius:var(--radius-control)]", d(r))),
|
|
2014
|
+
style: { "min-height": "calc(var(--control-height-md) * 0.65)" },
|
|
2015
|
+
"data-ug-slot": "connector"
|
|
2016
|
+
}, null, 2)) : _("", !0)], 2),
|
|
2017
|
+
y("div", { class: O(B(e)(a.value ? "mt-2 text-center" : "ml-3.5", !a.value && r < t.items.length - 1 ? "pb-5" : "")) }, [y("p", {
|
|
2018
|
+
class: O(B(e)("text-sm font-semibold leading-5", u(r))),
|
|
2019
|
+
"data-ug-slot": "title"
|
|
2020
|
+
}, R(n.title), 3), n.description ? (j(), v("p", {
|
|
2021
|
+
key: 0,
|
|
2022
|
+
class: O(B(e)("mt-0.5 text-xs leading-5", c(r) ? "text-danger" : "text-text-secondary")),
|
|
2023
|
+
"data-ug-slot": "description"
|
|
2024
|
+
}, R(n.description), 3)) : _("", !0)], 2),
|
|
2025
|
+
a.value && r < t.items.length - 1 ? (j(), v("div", {
|
|
2026
|
+
key: 0,
|
|
2027
|
+
class: O(B(e)("mx-2 mt-4 flex-1 [height:calc(var(--control-height-sm)*0.0625)]", d(r))),
|
|
2028
|
+
"data-ug-slot": "connector"
|
|
2029
|
+
}, null, 2)) : _("", !0)
|
|
2030
|
+
], 10, fn))), 128))], 10, dn));
|
|
2031
|
+
}
|
|
2032
|
+
}), hn = Symbol("ug-dropdown-context"), gn = ["data-state"];
|
|
2033
|
+
function _n() {
|
|
2034
|
+
let e = w(hn);
|
|
2035
|
+
if (!e) throw Error("Dropdown 子组件必须在 <UDropdown> 内使用");
|
|
2036
|
+
return e;
|
|
2037
|
+
}
|
|
2038
|
+
var vn = [
|
|
2039
|
+
"button:not([disabled])",
|
|
2040
|
+
"a[href]",
|
|
2041
|
+
"input:not([disabled])",
|
|
2042
|
+
"select:not([disabled])",
|
|
2043
|
+
"textarea:not([disabled])",
|
|
2044
|
+
"[tabindex]:not([tabindex=\"-1\"])"
|
|
2045
|
+
].join(",");
|
|
2046
|
+
function yn(e) {
|
|
2047
|
+
return e ? e.querySelector(vn) ?? e : null;
|
|
2048
|
+
}
|
|
2049
|
+
function bn(e) {
|
|
2050
|
+
return e ? Array.from(e.querySelectorAll("[role=\"menuitem\"]:not(:disabled)")) : [];
|
|
2051
|
+
}
|
|
2052
|
+
function xn(e) {
|
|
2053
|
+
window.requestAnimationFrame(e);
|
|
2054
|
+
}
|
|
2055
|
+
function Sn() {
|
|
2056
|
+
return typeof window < "u" && typeof document < "u";
|
|
2057
|
+
}
|
|
2058
|
+
function Cn(e, t, n) {
|
|
2059
|
+
let r = window.scrollX + 8, i = window.scrollX + window.innerWidth - n.offsetWidth - 8, a = window.scrollY + 8, o = window.scrollY + window.innerHeight - n.offsetHeight - 8;
|
|
2060
|
+
return {
|
|
2061
|
+
top: Math.max(a, Math.min(e, Math.max(a, o))),
|
|
2062
|
+
left: Math.max(r, Math.min(t, Math.max(r, i)))
|
|
2063
|
+
};
|
|
2064
|
+
}
|
|
2065
|
+
var wn = S({
|
|
2066
|
+
name: "UDropdownTrigger",
|
|
2067
|
+
props: { class: {
|
|
2068
|
+
type: String,
|
|
2069
|
+
default: void 0
|
|
2070
|
+
} },
|
|
2071
|
+
emits: { click: (e) => !0 },
|
|
2072
|
+
setup(t, { emit: n, slots: r }) {
|
|
2073
|
+
let i = _n(), a = h(() => e("inline-flex cursor-pointer", t.class));
|
|
2074
|
+
function o(e) {
|
|
2075
|
+
i.triggerRef.value = e, s();
|
|
2076
|
+
}
|
|
2077
|
+
function s() {
|
|
2078
|
+
let e = yn(i.triggerRef.value);
|
|
2079
|
+
e && (e.setAttribute("aria-haspopup", "menu"), e.setAttribute("aria-expanded", String(i.open.value)), e.setAttribute("aria-controls", i.contentId));
|
|
2080
|
+
}
|
|
2081
|
+
function c(e) {
|
|
2082
|
+
i.toggleOpen(), n("click", e);
|
|
2083
|
+
}
|
|
2084
|
+
function l(e) {
|
|
2085
|
+
if (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") {
|
|
2086
|
+
e.preventDefault(), i.setOpen(!0), xn(i.focusFirstItem);
|
|
2087
|
+
return;
|
|
2088
|
+
}
|
|
2089
|
+
if (e.key === "ArrowUp") {
|
|
2090
|
+
e.preventDefault(), i.setOpen(!0), xn(i.focusLastItem);
|
|
2091
|
+
return;
|
|
2092
|
+
}
|
|
2093
|
+
e.key === "Escape" && i.open.value && (e.preventDefault(), i.setOpen(!1), xn(i.focusTrigger));
|
|
2094
|
+
}
|
|
2095
|
+
return G(() => i.open.value, async () => {
|
|
2096
|
+
await D(), s();
|
|
2097
|
+
}, { immediate: !0 }), () => C("span", {
|
|
2098
|
+
class: a.value,
|
|
2099
|
+
"data-ug-slot": "trigger",
|
|
2100
|
+
"data-state": i.open.value ? "open" : "default",
|
|
2101
|
+
onClick: c,
|
|
2102
|
+
onKeydown: l,
|
|
2103
|
+
onVnodeMounted(e) {
|
|
2104
|
+
o(e.el);
|
|
2105
|
+
},
|
|
2106
|
+
onVnodeUpdated(e) {
|
|
2107
|
+
o(e.el);
|
|
2108
|
+
}
|
|
2109
|
+
}, r.default?.());
|
|
2110
|
+
}
|
|
2111
|
+
}), Tn = S({
|
|
2112
|
+
name: "UDropdownContent",
|
|
2113
|
+
props: {
|
|
2114
|
+
align: {
|
|
2115
|
+
type: String,
|
|
2116
|
+
default: "start"
|
|
2117
|
+
},
|
|
2118
|
+
class: {
|
|
2119
|
+
type: String,
|
|
2120
|
+
default: void 0
|
|
2121
|
+
}
|
|
2122
|
+
},
|
|
2123
|
+
setup(t, { slots: n }) {
|
|
2124
|
+
let r = _n(), i = l(), a = h(() => c(i.value)), o = P({
|
|
2125
|
+
top: 0,
|
|
2126
|
+
left: 0
|
|
2127
|
+
}), s = h(() => e("absolute z-50 min-w-44 overflow-hidden rounded-[var(--radius-control)] border border-border-base bg-surface-1 p-[calc(var(--content-gap)*0.25)] text-text-primary shadow-xl", t.class));
|
|
2128
|
+
function u() {
|
|
2129
|
+
if (!r.triggerRef.value || !r.contentRef.value || !Sn()) return;
|
|
2130
|
+
let e = r.triggerRef.value.getBoundingClientRect(), n = r.contentRef.value, i = n.offsetWidth, a = e.bottom + window.scrollY + 4, s = e.top + window.scrollY - n.offsetHeight - 4, c = a + n.offsetHeight > window.scrollY + window.innerHeight - 8 && s >= window.scrollY + 8 ? s : a, l = t.align === "end" ? e.right + window.scrollX - i : e.left + window.scrollX;
|
|
2131
|
+
o.value = Cn(c, l, n);
|
|
2132
|
+
}
|
|
2133
|
+
function d(e) {
|
|
2134
|
+
let t = e.target;
|
|
2135
|
+
r.contentRef.value?.contains(t) || r.triggerRef.value?.contains(t) || r.setOpen(!1);
|
|
2136
|
+
}
|
|
2137
|
+
function f() {
|
|
2138
|
+
Sn() && (window.addEventListener("resize", u), window.addEventListener("scroll", u, !0), document.addEventListener("mousedown", d));
|
|
2139
|
+
}
|
|
2140
|
+
function m() {
|
|
2141
|
+
Sn() && (window.removeEventListener("resize", u), window.removeEventListener("scroll", u, !0), document.removeEventListener("mousedown", d));
|
|
2142
|
+
}
|
|
2143
|
+
G(() => r.open.value, async (e) => {
|
|
2144
|
+
m(), !(!e || !Sn()) && (await D(), u(), f());
|
|
2145
|
+
}, { immediate: !0 }), A(() => {
|
|
2146
|
+
m();
|
|
2147
|
+
});
|
|
2148
|
+
function g(e) {
|
|
2149
|
+
let t = bn(r.contentRef.value);
|
|
2150
|
+
if (!t.length) return;
|
|
2151
|
+
let n = t.indexOf(document.activeElement), i = null;
|
|
2152
|
+
if (e.key === "ArrowDown") i = n < 0 ? 0 : (n + 1) % t.length;
|
|
2153
|
+
else if (e.key === "ArrowUp") i = n < 0 ? t.length - 1 : (n - 1 + t.length) % t.length;
|
|
2154
|
+
else if (e.key === "Home") i = 0;
|
|
2155
|
+
else if (e.key === "End") i = t.length - 1;
|
|
2156
|
+
else if (e.key === "Escape") {
|
|
2157
|
+
e.preventDefault(), r.setOpen(!1), xn(r.focusTrigger);
|
|
2158
|
+
return;
|
|
2159
|
+
} else if (e.key === "Tab") {
|
|
2160
|
+
r.setOpen(!1);
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
i !== null && (e.preventDefault(), t[i]?.focus());
|
|
2164
|
+
}
|
|
2165
|
+
return () => r.open.value ? C(p, { to: "body" }, [C("div", {
|
|
2166
|
+
ref: r.contentRef,
|
|
2167
|
+
id: r.contentId,
|
|
2168
|
+
role: "menu",
|
|
2169
|
+
"aria-orientation": "vertical",
|
|
2170
|
+
...a.value,
|
|
2171
|
+
class: s.value,
|
|
2172
|
+
style: {
|
|
2173
|
+
top: `${o.value.top}px`,
|
|
2174
|
+
left: `${o.value.left}px`
|
|
2175
|
+
},
|
|
2176
|
+
"data-ug": "dropdown",
|
|
2177
|
+
"data-ug-slot": "content",
|
|
2178
|
+
"data-state": "open",
|
|
2179
|
+
"data-variant": "default",
|
|
2180
|
+
"data-size": "md",
|
|
2181
|
+
onKeydown: g
|
|
2182
|
+
}, n.default?.())]) : null;
|
|
2183
|
+
}
|
|
2184
|
+
}), En = S({
|
|
2185
|
+
name: "UDropdownItem",
|
|
2186
|
+
props: {
|
|
2187
|
+
destructive: {
|
|
2188
|
+
type: Boolean,
|
|
2189
|
+
default: !1
|
|
2190
|
+
},
|
|
2191
|
+
disabled: {
|
|
2192
|
+
type: Boolean,
|
|
2193
|
+
default: !1
|
|
2194
|
+
},
|
|
2195
|
+
class: {
|
|
2196
|
+
type: String,
|
|
2197
|
+
default: void 0
|
|
2198
|
+
}
|
|
2199
|
+
},
|
|
2200
|
+
emits: { click: (e) => !0 },
|
|
2201
|
+
setup(t, { emit: n, slots: r }) {
|
|
2202
|
+
let i = _n(), a = h(() => e("flex min-h-[var(--control-height-sm)] w-full items-center gap-2 rounded-[var(--radius-control)] px-[var(--control-padding-x-sm)] py-[calc(var(--content-gap)*0.5)] text-left text-sm leading-none transition-colors focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50", t.destructive ? "text-danger hover:bg-danger-soft focus-visible:bg-danger-soft" : "text-text-primary hover:bg-surface-2 focus-visible:bg-surface-2", t.class));
|
|
2203
|
+
function o(e) {
|
|
2204
|
+
t.disabled || (i.setOpen(!1), n("click", e), xn(i.focusTrigger));
|
|
2205
|
+
}
|
|
2206
|
+
return () => C("button", {
|
|
2207
|
+
type: "button",
|
|
2208
|
+
role: "menuitem",
|
|
2209
|
+
tabindex: -1,
|
|
2210
|
+
disabled: t.disabled,
|
|
2211
|
+
class: a.value,
|
|
2212
|
+
"data-ug-slot": "item",
|
|
2213
|
+
"data-state": t.disabled ? "disabled" : "default",
|
|
2214
|
+
"data-variant": t.destructive ? "destructive" : "default",
|
|
2215
|
+
"data-size": "md",
|
|
2216
|
+
onClick: o
|
|
2217
|
+
}, r.default?.());
|
|
2218
|
+
}
|
|
2219
|
+
}), Dn = S({
|
|
2220
|
+
name: "UDropdownSeparator",
|
|
2221
|
+
props: { class: {
|
|
2222
|
+
type: String,
|
|
2223
|
+
default: void 0
|
|
2224
|
+
} },
|
|
2225
|
+
setup(t, { attrs: n }) {
|
|
2226
|
+
let r = h(() => e("-mx-[calc(var(--content-gap)*0.25)] my-[calc(var(--content-gap)*0.25)] h-[1px] bg-border-base", t.class));
|
|
2227
|
+
return () => C("div", {
|
|
2228
|
+
...n,
|
|
2229
|
+
role: "separator",
|
|
2230
|
+
class: r.value,
|
|
2231
|
+
"data-ug-slot": "separator",
|
|
2232
|
+
"data-state": "default",
|
|
2233
|
+
"data-variant": "default",
|
|
2234
|
+
"data-size": "md"
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
}), On = /* @__PURE__ */ S({
|
|
2238
|
+
name: "UDropdown",
|
|
2239
|
+
__name: "dropdown",
|
|
2240
|
+
props: /*@__PURE__*/ T({ class: { default: void 0 } }, {
|
|
2241
|
+
open: {
|
|
2242
|
+
type: Boolean,
|
|
2243
|
+
default: !1
|
|
2244
|
+
},
|
|
2245
|
+
openModifiers: {}
|
|
2246
|
+
}),
|
|
2247
|
+
emits: /*@__PURE__*/ T(["openChange"], ["update:open"]),
|
|
2248
|
+
setup(t, { emit: n }) {
|
|
2249
|
+
let r = t, i = H(t, "open"), a = n, o = P(null), s = P(null), c = `ug-dropdown-${V().replace(/:/g, "")}`, l = h(() => e("relative inline-block", r.class));
|
|
2250
|
+
function u(e) {
|
|
2251
|
+
i.value = e, a("openChange", e);
|
|
2252
|
+
}
|
|
2253
|
+
function d() {
|
|
2254
|
+
u(!i.value);
|
|
2255
|
+
}
|
|
2256
|
+
function f() {
|
|
2257
|
+
yn(o.value)?.focus();
|
|
2258
|
+
}
|
|
2259
|
+
function p() {
|
|
2260
|
+
bn(s.value)[0]?.focus();
|
|
2261
|
+
}
|
|
2262
|
+
function m() {
|
|
2263
|
+
let e = bn(s.value);
|
|
2264
|
+
e[e.length - 1]?.focus();
|
|
2265
|
+
}
|
|
2266
|
+
return M(hn, {
|
|
2267
|
+
open: i,
|
|
2268
|
+
triggerRef: o,
|
|
2269
|
+
contentRef: s,
|
|
2270
|
+
contentId: c,
|
|
2271
|
+
setOpen: u,
|
|
2272
|
+
toggleOpen: d,
|
|
2273
|
+
focusTrigger: f,
|
|
2274
|
+
focusFirstItem: p,
|
|
2275
|
+
focusLastItem: m
|
|
2276
|
+
}), (e, t) => (j(), v("div", {
|
|
2277
|
+
class: O(l.value),
|
|
2278
|
+
"data-ug": "dropdown",
|
|
2279
|
+
"data-state": i.value ? "open" : "default",
|
|
2280
|
+
"data-variant": "default",
|
|
2281
|
+
"data-size": "md"
|
|
2282
|
+
}, [I(e.$slots, "default")], 10, gn));
|
|
2283
|
+
}
|
|
2284
|
+
}), kn = Symbol("ug-popover-context"), An = ["data-state"];
|
|
2285
|
+
function jn() {
|
|
2286
|
+
let e = w(kn);
|
|
2287
|
+
if (!e) throw Error("Popover 子组件必须在 <UPopover> 内使用");
|
|
2288
|
+
return e;
|
|
2289
|
+
}
|
|
2290
|
+
function Mn() {
|
|
2291
|
+
return typeof window < "u" && typeof document < "u";
|
|
2292
|
+
}
|
|
2293
|
+
function Nn(e, t, n) {
|
|
2294
|
+
let r = window.scrollX + 8, i = window.scrollX + window.innerWidth - n.offsetWidth - 8, a = window.scrollY + 8, o = window.scrollY + window.innerHeight - n.offsetHeight - 8;
|
|
2295
|
+
return {
|
|
2296
|
+
top: Math.max(a, Math.min(e, Math.max(a, o))),
|
|
2297
|
+
left: Math.max(r, Math.min(t, Math.max(r, i)))
|
|
2298
|
+
};
|
|
2299
|
+
}
|
|
2300
|
+
function Pn(e, t, n, r, i) {
|
|
2301
|
+
let a = t.offsetWidth, o = t.offsetHeight, s = 0, c = 0;
|
|
2302
|
+
return n === "left" ? (s = e.top + window.scrollY + e.height / 2 - o / 2, c = e.left + window.scrollX - a - i, Nn(s, c, t)) : n === "right" ? (s = e.top + window.scrollY + e.height / 2 - o / 2, c = e.right + window.scrollX + i, Nn(s, c, t)) : (s = n === "top" ? e.top + window.scrollY - o - i : e.bottom + window.scrollY + i, c = r === "start" ? e.left + window.scrollX : r === "end" ? e.right + window.scrollX - a : e.left + window.scrollX + e.width / 2 - a / 2, Nn(s, c, t));
|
|
2303
|
+
}
|
|
2304
|
+
var Fn = S({
|
|
2305
|
+
name: "UPopoverTrigger",
|
|
2306
|
+
props: { class: {
|
|
2307
|
+
type: String,
|
|
2308
|
+
default: void 0
|
|
2309
|
+
} },
|
|
2310
|
+
emits: { click: (e) => !0 },
|
|
2311
|
+
setup(t, { emit: n, slots: r }) {
|
|
2312
|
+
let i = jn(), a = h(() => e("inline-flex", t.class));
|
|
2313
|
+
function o(e) {
|
|
2314
|
+
i.triggerRef.value = e, c();
|
|
2315
|
+
}
|
|
2316
|
+
function s() {
|
|
2317
|
+
let e = i.triggerRef.value;
|
|
2318
|
+
return e?.querySelector("button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") ?? e;
|
|
2319
|
+
}
|
|
2320
|
+
function c() {
|
|
2321
|
+
let e = s();
|
|
2322
|
+
e?.setAttribute("aria-controls", i.contentId), e?.setAttribute("aria-expanded", String(i.open.value));
|
|
2323
|
+
}
|
|
2324
|
+
function l(e) {
|
|
2325
|
+
i.toggleOpen(), n("click", e);
|
|
2326
|
+
}
|
|
2327
|
+
return G(() => i.open.value, c, { immediate: !0 }), A(() => {
|
|
2328
|
+
let e = s();
|
|
2329
|
+
e?.getAttribute("aria-controls") === i.contentId && (e.removeAttribute("aria-controls"), e.removeAttribute("aria-expanded"));
|
|
2330
|
+
}), () => C("span", {
|
|
2331
|
+
class: a.value,
|
|
2332
|
+
"data-ug-slot": "trigger",
|
|
2333
|
+
"data-state": i.open.value ? "open" : "default",
|
|
2334
|
+
onClick: l,
|
|
2335
|
+
onKeydown: (e) => {
|
|
2336
|
+
e.key === "Escape" && (e.preventDefault(), i.setOpen(!1));
|
|
2337
|
+
},
|
|
2338
|
+
onVnodeMounted(e) {
|
|
2339
|
+
o(e.el);
|
|
2340
|
+
},
|
|
2341
|
+
onVnodeUpdated(e) {
|
|
2342
|
+
o(e.el);
|
|
2343
|
+
}
|
|
2344
|
+
}, r.default?.());
|
|
2345
|
+
}
|
|
2346
|
+
}), In = S({
|
|
2347
|
+
name: "UPopoverContent",
|
|
2348
|
+
props: {
|
|
2349
|
+
side: {
|
|
2350
|
+
type: String,
|
|
2351
|
+
default: "bottom"
|
|
2352
|
+
},
|
|
2353
|
+
align: {
|
|
2354
|
+
type: String,
|
|
2355
|
+
default: "center"
|
|
2356
|
+
},
|
|
2357
|
+
sideOffset: {
|
|
2358
|
+
type: Number,
|
|
2359
|
+
default: 4
|
|
2360
|
+
},
|
|
2361
|
+
class: {
|
|
2362
|
+
type: String,
|
|
2363
|
+
default: void 0
|
|
2364
|
+
}
|
|
2365
|
+
},
|
|
2366
|
+
setup(t, { slots: n }) {
|
|
2367
|
+
let r = jn(), i = l(), a = h(() => c(i.value)), o = P(null), s = P({
|
|
2368
|
+
top: 0,
|
|
2369
|
+
left: 0
|
|
2370
|
+
}), u = h(() => e("absolute z-50 min-w-40 rounded-[var(--radius-control)] border border-border-base bg-surface-1 p-[calc(var(--content-gap)*0.75)] shadow-lg", t.class));
|
|
2371
|
+
function d() {
|
|
2372
|
+
if (!r.triggerRef.value || !o.value || !Mn()) return;
|
|
2373
|
+
let e = r.triggerRef.value.getBoundingClientRect();
|
|
2374
|
+
s.value = Pn(e, o.value, t.side, t.align, t.sideOffset);
|
|
2375
|
+
}
|
|
2376
|
+
function f(e) {
|
|
2377
|
+
let t = e.target;
|
|
2378
|
+
o.value?.contains(t) || r.triggerRef.value?.contains(t) || r.setOpen(!1);
|
|
2379
|
+
}
|
|
2380
|
+
function m(e) {
|
|
2381
|
+
if (e.key !== "Escape") return;
|
|
2382
|
+
r.setOpen(!1);
|
|
2383
|
+
let t = r.triggerRef.value;
|
|
2384
|
+
(t?.querySelector("button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") ?? t)?.focus();
|
|
2385
|
+
}
|
|
2386
|
+
function g() {
|
|
2387
|
+
Mn() && (window.addEventListener("resize", d), window.addEventListener("scroll", d, !0), document.addEventListener("mousedown", f), document.addEventListener("keydown", m));
|
|
2388
|
+
}
|
|
2389
|
+
function _() {
|
|
2390
|
+
Mn() && (window.removeEventListener("resize", d), window.removeEventListener("scroll", d, !0), document.removeEventListener("mousedown", f), document.removeEventListener("keydown", m));
|
|
2391
|
+
}
|
|
2392
|
+
return G(() => r.open.value, async (e) => {
|
|
2393
|
+
_(), !(!e || !Mn()) && (await D(), d(), g());
|
|
2394
|
+
}, { immediate: !0 }), A(() => {
|
|
2395
|
+
_();
|
|
2396
|
+
}), () => r.open.value ? C(p, { to: "body" }, [C("div", {
|
|
2397
|
+
ref: o,
|
|
2398
|
+
id: r.contentId,
|
|
2399
|
+
role: "dialog",
|
|
2400
|
+
"aria-label": "弹出内容",
|
|
2401
|
+
...a.value,
|
|
2402
|
+
class: u.value,
|
|
2403
|
+
style: {
|
|
2404
|
+
top: `${s.value.top}px`,
|
|
2405
|
+
left: `${s.value.left}px`
|
|
2406
|
+
},
|
|
2407
|
+
"data-ug": "popover",
|
|
2408
|
+
"data-ug-slot": "content",
|
|
2409
|
+
"data-state": "open",
|
|
2410
|
+
"data-variant": "default",
|
|
2411
|
+
"data-size": "md"
|
|
2412
|
+
}, n.default?.())]) : null;
|
|
2413
|
+
}
|
|
2414
|
+
}), Ln = /* @__PURE__ */ S({
|
|
2415
|
+
name: "UPopover",
|
|
2416
|
+
__name: "popover",
|
|
2417
|
+
props: /*@__PURE__*/ T({ class: { default: void 0 } }, {
|
|
2418
|
+
open: {
|
|
2419
|
+
type: Boolean,
|
|
2420
|
+
default: !1
|
|
2421
|
+
},
|
|
2422
|
+
openModifiers: {}
|
|
2423
|
+
}),
|
|
2424
|
+
emits: /*@__PURE__*/ T(["openChange"], ["update:open"]),
|
|
2425
|
+
setup(t, { emit: n }) {
|
|
2426
|
+
let r = t, i = n, a = H(t, "open"), o = P(null), s = `ug-popover-${V()}`, c = h(() => e("contents", r.class));
|
|
2427
|
+
function l(e) {
|
|
2428
|
+
a.value = e, i("openChange", e);
|
|
2429
|
+
}
|
|
2430
|
+
function u() {
|
|
2431
|
+
l(!a.value);
|
|
2432
|
+
}
|
|
2433
|
+
return M(kn, {
|
|
2434
|
+
open: a,
|
|
2435
|
+
triggerRef: o,
|
|
2436
|
+
setOpen: l,
|
|
2437
|
+
toggleOpen: u,
|
|
2438
|
+
contentId: s
|
|
2439
|
+
}), (e, t) => (j(), v("span", {
|
|
2440
|
+
class: O(c.value),
|
|
2441
|
+
"data-ug": "popover",
|
|
2442
|
+
"data-state": a.value ? "open" : "default",
|
|
2443
|
+
"data-variant": "default",
|
|
2444
|
+
"data-size": "md"
|
|
2445
|
+
}, [I(e.$slots, "default")], 10, An));
|
|
2446
|
+
}
|
|
2447
|
+
}), Rn = Symbol("ug-context-menu-context"), zn = ["data-state"];
|
|
2448
|
+
function Bn() {
|
|
2449
|
+
let e = w(Rn);
|
|
2450
|
+
if (!e) throw Error("ContextMenu 子组件必须在 <UContextMenu> 内使用");
|
|
2451
|
+
return e;
|
|
2452
|
+
}
|
|
2453
|
+
function Vn() {
|
|
2454
|
+
return typeof document < "u";
|
|
2455
|
+
}
|
|
2456
|
+
function Hn(e) {
|
|
2457
|
+
(e?.querySelector("button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") ?? e)?.focus();
|
|
2458
|
+
}
|
|
2459
|
+
var Un = S({
|
|
2460
|
+
name: "UContextMenuTrigger",
|
|
2461
|
+
props: { class: {
|
|
2462
|
+
type: String,
|
|
2463
|
+
default: void 0
|
|
2464
|
+
} },
|
|
2465
|
+
setup(t, { slots: n }) {
|
|
2466
|
+
let r = Bn(), i = h(() => e(t.class));
|
|
2467
|
+
function a(e) {
|
|
2468
|
+
e.preventDefault(), r.openAt({
|
|
2469
|
+
x: e.clientX,
|
|
2470
|
+
y: e.clientY
|
|
2471
|
+
});
|
|
2472
|
+
}
|
|
2473
|
+
function o(e) {
|
|
2474
|
+
if (e.key !== "ContextMenu" && !(e.shiftKey && e.key === "F10")) return;
|
|
2475
|
+
e.preventDefault();
|
|
2476
|
+
let t = e.currentTarget.getBoundingClientRect();
|
|
2477
|
+
r.openAt({
|
|
2478
|
+
x: t.left,
|
|
2479
|
+
y: t.bottom
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
2482
|
+
function s(e) {
|
|
2483
|
+
r.triggerRef.value = e, l();
|
|
2484
|
+
}
|
|
2485
|
+
function c() {
|
|
2486
|
+
let e = r.triggerRef.value;
|
|
2487
|
+
return e?.querySelector("button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") ?? e;
|
|
2488
|
+
}
|
|
2489
|
+
function l() {
|
|
2490
|
+
let e = c();
|
|
2491
|
+
e?.setAttribute("aria-haspopup", "menu"), e?.setAttribute("aria-controls", r.menuId), e?.setAttribute("aria-expanded", String(r.open.value));
|
|
2492
|
+
}
|
|
2493
|
+
return G(() => r.open.value, l, { immediate: !0 }), A(() => {
|
|
2494
|
+
let e = c();
|
|
2495
|
+
e?.getAttribute("aria-controls") === r.menuId && (e.removeAttribute("aria-haspopup"), e.removeAttribute("aria-controls"), e.removeAttribute("aria-expanded"));
|
|
2496
|
+
}), () => C("div", {
|
|
2497
|
+
class: i.value || void 0,
|
|
2498
|
+
onContextmenu: a,
|
|
2499
|
+
onKeydown: o,
|
|
2500
|
+
"data-ug-slot": "trigger",
|
|
2501
|
+
"data-state": r.open.value ? "open" : "default",
|
|
2502
|
+
onVnodeMounted: (e) => s(e.el),
|
|
2503
|
+
onVnodeUpdated: (e) => s(e.el)
|
|
2504
|
+
}, n.default?.());
|
|
2505
|
+
}
|
|
2506
|
+
}), Wn = S({
|
|
2507
|
+
name: "UContextMenuContent",
|
|
2508
|
+
props: { class: {
|
|
2509
|
+
type: String,
|
|
2510
|
+
default: void 0
|
|
2511
|
+
} },
|
|
2512
|
+
setup(t, { slots: n }) {
|
|
2513
|
+
let r = Bn(), i = l(), a = h(() => c(i.value)), o = P(null), s = h(() => e("fixed z-50 min-w-40 rounded-[var(--radius-control)] border border-border-base bg-surface-1 py-[calc(var(--content-gap)*0.25)] shadow-lg", t.class));
|
|
2514
|
+
function u(e) {
|
|
2515
|
+
o.value && !o.value.contains(e.target) && r.setOpen(!1);
|
|
2516
|
+
}
|
|
2517
|
+
function d(e) {
|
|
2518
|
+
e.key === "Escape" && (r.setOpen(!1), Hn(r.triggerRef.value));
|
|
2519
|
+
}
|
|
2520
|
+
function f(e) {
|
|
2521
|
+
let t = e.currentTarget, n = Array.from(t.querySelectorAll("[role=\"menuitem\"]:not([disabled])"));
|
|
2522
|
+
if (n.length === 0) return;
|
|
2523
|
+
let i = n.indexOf(document.activeElement), a = i;
|
|
2524
|
+
if (e.key === "ArrowDown") a = (i + 1 + n.length) % n.length;
|
|
2525
|
+
else if (e.key === "ArrowUp") a = (i - 1 + n.length) % n.length;
|
|
2526
|
+
else if (e.key === "Home") a = 0;
|
|
2527
|
+
else if (e.key === "End") a = n.length - 1;
|
|
2528
|
+
else if (e.key === "Escape") {
|
|
2529
|
+
e.preventDefault(), e.stopPropagation(), r.setOpen(!1), Hn(r.triggerRef.value);
|
|
2530
|
+
return;
|
|
2531
|
+
} else return;
|
|
2532
|
+
e.preventDefault(), n[a]?.focus();
|
|
2533
|
+
}
|
|
2534
|
+
function m() {
|
|
2535
|
+
Vn() && (document.addEventListener("mousedown", u), document.addEventListener("keydown", d));
|
|
2536
|
+
}
|
|
2537
|
+
function g() {
|
|
2538
|
+
Vn() && (document.removeEventListener("mousedown", u), document.removeEventListener("keydown", d));
|
|
2539
|
+
}
|
|
2540
|
+
return G(() => r.open.value, async (e) => {
|
|
2541
|
+
g(), e && Vn() && (m(), await D(), o.value?.querySelector("[role=\"menuitem\"]:not([disabled])")?.focus());
|
|
2542
|
+
}, { immediate: !0 }), A(() => {
|
|
2543
|
+
g();
|
|
2544
|
+
}), () => r.open.value ? C(p, { to: "body" }, [C("div", {
|
|
2545
|
+
ref: o,
|
|
2546
|
+
id: r.menuId,
|
|
2547
|
+
...a.value,
|
|
2548
|
+
class: s.value,
|
|
2549
|
+
style: {
|
|
2550
|
+
top: `${r.position.value.y}px`,
|
|
2551
|
+
left: `${r.position.value.x}px`
|
|
2552
|
+
},
|
|
2553
|
+
"data-ug": "context-menu",
|
|
2554
|
+
"data-ug-slot": "content",
|
|
2555
|
+
"data-state": "open",
|
|
2556
|
+
"data-variant": "default",
|
|
2557
|
+
"data-size": "md",
|
|
2558
|
+
role: "menu",
|
|
2559
|
+
tabindex: -1,
|
|
2560
|
+
onKeydown: f
|
|
2561
|
+
}, n.default?.())]) : null;
|
|
2562
|
+
}
|
|
2563
|
+
}), Gn = S({
|
|
2564
|
+
name: "UContextMenuItem",
|
|
2565
|
+
props: {
|
|
2566
|
+
destructive: {
|
|
2567
|
+
type: Boolean,
|
|
2568
|
+
default: !1
|
|
2569
|
+
},
|
|
2570
|
+
disabled: {
|
|
2571
|
+
type: Boolean,
|
|
2572
|
+
default: !1
|
|
2573
|
+
},
|
|
2574
|
+
class: {
|
|
2575
|
+
type: String,
|
|
2576
|
+
default: void 0
|
|
2577
|
+
}
|
|
2578
|
+
},
|
|
2579
|
+
emits: { click: (e) => !0 },
|
|
2580
|
+
setup(t, { emit: n, slots: r }) {
|
|
2581
|
+
let i = Bn(), a = h(() => e("w-full px-[var(--control-padding-x-sm)] py-[calc(var(--content-gap)*0.375)] text-left text-sm transition-colors focus-visible:bg-surface-3 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50", t.destructive ? "text-danger hover:bg-danger-soft/10" : "text-text-primary hover:bg-surface-3", t.class));
|
|
2582
|
+
function o(e) {
|
|
2583
|
+
t.disabled || (i.setOpen(!1), Hn(i.triggerRef.value), n("click", e));
|
|
2584
|
+
}
|
|
2585
|
+
return () => C("button", {
|
|
2586
|
+
type: "button",
|
|
2587
|
+
role: "menuitem",
|
|
2588
|
+
tabindex: -1,
|
|
2589
|
+
disabled: t.disabled,
|
|
2590
|
+
class: a.value,
|
|
2591
|
+
"data-ug-slot": "item",
|
|
2592
|
+
"data-state": t.disabled ? "disabled" : "default",
|
|
2593
|
+
"data-variant": t.destructive ? "destructive" : "default",
|
|
2594
|
+
"data-size": "md",
|
|
2595
|
+
onClick: o
|
|
2596
|
+
}, r.default?.());
|
|
2597
|
+
}
|
|
2598
|
+
}), Kn = S({
|
|
2599
|
+
name: "UContextMenuSeparator",
|
|
2600
|
+
props: { class: {
|
|
2601
|
+
type: String,
|
|
2602
|
+
default: void 0
|
|
2603
|
+
} },
|
|
2604
|
+
setup(t) {
|
|
2605
|
+
let n = h(() => e("my-[calc(var(--content-gap)*0.25)] h-[1px] bg-border-base", t.class));
|
|
2606
|
+
return () => C("div", {
|
|
2607
|
+
role: "separator",
|
|
2608
|
+
class: n.value,
|
|
2609
|
+
"data-ug-slot": "separator",
|
|
2610
|
+
"data-state": "default"
|
|
2611
|
+
});
|
|
2612
|
+
}
|
|
2613
|
+
}), qn = /* @__PURE__ */ S({
|
|
2614
|
+
name: "UContextMenu",
|
|
2615
|
+
__name: "context-menu",
|
|
2616
|
+
props: { class: { default: void 0 } },
|
|
2617
|
+
setup(t) {
|
|
2618
|
+
let n = t, r = P(!1), i = P(null), a = `ug-context-menu-${V()}`, o = P({
|
|
2619
|
+
x: 0,
|
|
2620
|
+
y: 0
|
|
2621
|
+
}), s = h(() => e("relative", n.class)), c = h(() => r.value ? "open" : "closed");
|
|
2622
|
+
function l(e) {
|
|
2623
|
+
r.value = e;
|
|
2624
|
+
}
|
|
2625
|
+
function u(e) {
|
|
2626
|
+
o.value = e, r.value = !0;
|
|
2627
|
+
}
|
|
2628
|
+
return M(Rn, {
|
|
2629
|
+
open: r,
|
|
2630
|
+
position: o,
|
|
2631
|
+
setOpen: l,
|
|
2632
|
+
openAt: u,
|
|
2633
|
+
triggerRef: i,
|
|
2634
|
+
menuId: a
|
|
2635
|
+
}), (e, t) => (j(), v("div", {
|
|
2636
|
+
class: O(s.value),
|
|
2637
|
+
"data-ug": "context-menu",
|
|
2638
|
+
"data-state": c.value,
|
|
2639
|
+
"data-variant": "default",
|
|
2640
|
+
"data-size": "md"
|
|
2641
|
+
}, [I(e.$slots, "default")], 10, zn));
|
|
2642
|
+
}
|
|
2643
|
+
}), Jn = Symbol("ug-navigation-menu-context"), Yn = Symbol("ug-navigation-menu-item-context");
|
|
2644
|
+
//#endregion
|
|
2645
|
+
//#region src/components/navigation-menu.vue?vue&type=script&setup=true&lang.ts
|
|
2646
|
+
function Xn() {
|
|
2647
|
+
let e = w(Jn);
|
|
2648
|
+
if (!e) throw Error("NavigationMenu 子组件必须在 <UNavigationMenu> 内使用");
|
|
2649
|
+
return e;
|
|
2650
|
+
}
|
|
2651
|
+
function Zn() {
|
|
2652
|
+
let e = w(Yn);
|
|
2653
|
+
if (!e) throw Error("UNavigationMenuTrigger/UNavigationMenuContent 必须在 <UNavigationMenuItem> 内使用");
|
|
2654
|
+
return e;
|
|
2655
|
+
}
|
|
2656
|
+
var Qn = S({
|
|
2657
|
+
name: "UNavigationMenuItem",
|
|
2658
|
+
props: { class: {
|
|
2659
|
+
type: String,
|
|
2660
|
+
default: void 0
|
|
2661
|
+
} },
|
|
2662
|
+
setup(t, { slots: n }) {
|
|
2663
|
+
let r = `ug-navigation-item-${V()}`, i = Xn(), a = h(() => i.activeItem.value === r), o = h(() => e("relative", t.class));
|
|
2664
|
+
M(Yn, { itemId: r });
|
|
2665
|
+
function s() {
|
|
2666
|
+
i.setActiveItem(r);
|
|
2667
|
+
}
|
|
2668
|
+
function c() {
|
|
2669
|
+
i.setActiveItem(null);
|
|
2670
|
+
}
|
|
2671
|
+
function l(e) {
|
|
2672
|
+
e.currentTarget.contains(e.relatedTarget) || i.setActiveItem(null);
|
|
2673
|
+
}
|
|
2674
|
+
return () => C("div", {
|
|
2675
|
+
class: o.value,
|
|
2676
|
+
"data-ug-slot": "item",
|
|
2677
|
+
"data-state": a.value ? "open" : "closed",
|
|
2678
|
+
onMouseenter: s,
|
|
2679
|
+
onMouseleave: c,
|
|
2680
|
+
onFocusout: l
|
|
2681
|
+
}, n.default?.());
|
|
2682
|
+
}
|
|
2683
|
+
}), $n = S({
|
|
2684
|
+
name: "UNavigationMenuLink",
|
|
2685
|
+
props: {
|
|
2686
|
+
href: {
|
|
2687
|
+
type: String,
|
|
2688
|
+
default: void 0
|
|
2689
|
+
},
|
|
2690
|
+
active: {
|
|
2691
|
+
type: Boolean,
|
|
2692
|
+
default: !1
|
|
2693
|
+
},
|
|
2694
|
+
class: {
|
|
2695
|
+
type: String,
|
|
2696
|
+
default: void 0
|
|
2697
|
+
}
|
|
2698
|
+
},
|
|
2699
|
+
setup(t, { slots: n }) {
|
|
2700
|
+
let r = h(() => e("inline-flex items-center px-[var(--control-padding-x-sm)] py-[calc(var(--control-height-sm)*0.2)] text-sm font-medium transition-colors [border-radius:var(--radius-control)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-offset-1", t.active ? "bg-surface-3 text-text-primary" : "text-text-secondary hover:bg-surface-3 hover:text-text-primary", t.class));
|
|
2701
|
+
return () => C("a", {
|
|
2702
|
+
href: t.href,
|
|
2703
|
+
class: r.value,
|
|
2704
|
+
"data-ug-slot": "link",
|
|
2705
|
+
"data-state": t.active ? "active" : "default",
|
|
2706
|
+
"aria-current": t.active ? "page" : void 0
|
|
2707
|
+
}, n.default?.());
|
|
2708
|
+
}
|
|
2709
|
+
}), er = S({
|
|
2710
|
+
name: "UNavigationMenuTrigger",
|
|
2711
|
+
props: { class: {
|
|
2712
|
+
type: String,
|
|
2713
|
+
default: void 0
|
|
2714
|
+
} },
|
|
2715
|
+
emits: { click: (e) => !0 },
|
|
2716
|
+
setup(t, { emit: n, slots: r }) {
|
|
2717
|
+
let i = Xn(), a = Zn(), o = h(() => i.activeItem.value === a.itemId), s = `${a.itemId}-trigger`, c = `${a.itemId}-content`, l = h(() => e("inline-flex items-center gap-1 px-[var(--control-padding-x-sm)] py-[calc(var(--control-height-sm)*0.2)] text-sm font-medium transition-colors [border-radius:var(--radius-control)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-offset-1", o.value ? "bg-surface-3 text-text-primary" : "text-text-secondary hover:bg-surface-3 hover:text-text-primary", t.class)), u = h(() => e("transition-transform duration-200", o.value ? "rotate-180" : ""));
|
|
2718
|
+
function d(e) {
|
|
2719
|
+
i.setActiveItem(o.value ? null : a.itemId), n("click", e);
|
|
2720
|
+
}
|
|
2721
|
+
function f(e) {
|
|
2722
|
+
D(() => {
|
|
2723
|
+
let t = Array.from(document.getElementById(c)?.querySelectorAll("a[href], button:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") ?? []);
|
|
2724
|
+
(e === "first" ? t[0] : t.at(-1))?.focus();
|
|
2725
|
+
});
|
|
2726
|
+
}
|
|
2727
|
+
function p(e) {
|
|
2728
|
+
e.key === "Escape" ? (e.preventDefault(), i.setActiveItem(null)) : (e.key === "ArrowDown" || e.key === "ArrowUp") && (e.preventDefault(), i.setActiveItem(a.itemId), f(e.key === "ArrowDown" ? "first" : "last"));
|
|
2729
|
+
}
|
|
2730
|
+
return () => C("button", {
|
|
2731
|
+
type: "button",
|
|
2732
|
+
id: s,
|
|
2733
|
+
"aria-controls": c,
|
|
2734
|
+
"aria-expanded": o.value,
|
|
2735
|
+
class: l.value,
|
|
2736
|
+
"data-ug-slot": "trigger",
|
|
2737
|
+
"data-state": o.value ? "open" : "closed",
|
|
2738
|
+
onClick: d,
|
|
2739
|
+
onKeydown: p
|
|
2740
|
+
}, [r.default?.(), C(ae, {
|
|
2741
|
+
size: 14,
|
|
2742
|
+
class: u.value,
|
|
2743
|
+
"data-ug-slot": "indicator"
|
|
2744
|
+
})]);
|
|
2745
|
+
}
|
|
2746
|
+
}), tr = S({
|
|
2747
|
+
name: "UNavigationMenuContent",
|
|
2748
|
+
props: { class: {
|
|
2749
|
+
type: String,
|
|
2750
|
+
default: void 0
|
|
2751
|
+
} },
|
|
2752
|
+
setup(t, { slots: n }) {
|
|
2753
|
+
let r = Xn(), i = Zn(), a = h(() => r.activeItem.value === i.itemId), o = h(() => e("absolute left-0 top-full z-50 mt-1 min-w-40 border border-border-base bg-surface-1 py-[calc(var(--content-gap)*0.25)] shadow-lg [border-radius:var(--radius-panel)]", t.class));
|
|
2754
|
+
return () => a.value ? C("div", {
|
|
2755
|
+
id: `${i.itemId}-content`,
|
|
2756
|
+
class: o.value,
|
|
2757
|
+
"data-ug-slot": "content",
|
|
2758
|
+
"data-state": "open",
|
|
2759
|
+
onKeydown: (e) => {
|
|
2760
|
+
e.key === "Escape" && (e.preventDefault(), r.setActiveItem(null), document.getElementById(`${i.itemId}-trigger`)?.focus());
|
|
2761
|
+
}
|
|
2762
|
+
}, n.default?.()) : null;
|
|
2763
|
+
}
|
|
2764
|
+
}), nr = /* @__PURE__ */ S({
|
|
2765
|
+
name: "UNavigationMenu",
|
|
2766
|
+
__name: "navigation-menu",
|
|
2767
|
+
props: { class: { default: void 0 } },
|
|
2768
|
+
setup(t) {
|
|
2769
|
+
let n = t, r = P(null), i = h(() => e("relative flex items-center gap-1", n.class));
|
|
2770
|
+
function a(e) {
|
|
2771
|
+
r.value = e;
|
|
2772
|
+
}
|
|
2773
|
+
return M(Jn, {
|
|
2774
|
+
activeItem: r,
|
|
2775
|
+
setActiveItem: a
|
|
2776
|
+
}), (e, t) => (j(), v("nav", {
|
|
2777
|
+
"aria-label": "主导航",
|
|
2778
|
+
class: O(i.value),
|
|
2779
|
+
"data-ug": "navigation-menu",
|
|
2780
|
+
"data-state": "default",
|
|
2781
|
+
"data-variant": "default",
|
|
2782
|
+
"data-size": "md"
|
|
2783
|
+
}, [I(e.$slots, "default")], 2));
|
|
2784
|
+
}
|
|
2785
|
+
}), rr = Symbol("AvatarContext"), ir = ["data-state", "data-size"];
|
|
2786
|
+
function ar(e) {
|
|
2787
|
+
let t = w(rr);
|
|
2788
|
+
if (!t) throw Error(`<${e}> 必须在 <UAvatar> 内使用`);
|
|
2789
|
+
return t;
|
|
2790
|
+
}
|
|
2791
|
+
var or = S({
|
|
2792
|
+
name: "UAvatarImage",
|
|
2793
|
+
inheritAttrs: !1,
|
|
2794
|
+
props: {
|
|
2795
|
+
src: {
|
|
2796
|
+
type: String,
|
|
2797
|
+
required: !0
|
|
2798
|
+
},
|
|
2799
|
+
alt: {
|
|
2800
|
+
type: String,
|
|
2801
|
+
default: ""
|
|
2802
|
+
},
|
|
2803
|
+
class: {
|
|
2804
|
+
type: String,
|
|
2805
|
+
default: void 0
|
|
2806
|
+
}
|
|
2807
|
+
},
|
|
2808
|
+
emits: {
|
|
2809
|
+
error: (e) => !0,
|
|
2810
|
+
load: (e) => !0
|
|
2811
|
+
},
|
|
2812
|
+
setup(t, { attrs: n, emit: r }) {
|
|
2813
|
+
let i = ar("UAvatarImage");
|
|
2814
|
+
G(() => t.src, (e) => {
|
|
2815
|
+
i.setImageLoadingStatus(e ? "loading" : "error");
|
|
2816
|
+
}, { immediate: !0 });
|
|
2817
|
+
function a(e) {
|
|
2818
|
+
i.setImageLoadingStatus("error"), r("error", e);
|
|
2819
|
+
}
|
|
2820
|
+
function o(e) {
|
|
2821
|
+
i.setImageLoadingStatus("loaded"), r("load", e);
|
|
2822
|
+
}
|
|
2823
|
+
return () => {
|
|
2824
|
+
let r = i.imageLoadingStatus.value;
|
|
2825
|
+
return r !== "loaded" && r !== "loading" ? null : C("img", {
|
|
2826
|
+
...n,
|
|
2827
|
+
src: t.src,
|
|
2828
|
+
alt: t.alt,
|
|
2829
|
+
class: e("block h-full w-full max-w-none object-cover object-center", r === "loading" && "invisible", t.class),
|
|
2830
|
+
"data-ug-slot": "image",
|
|
2831
|
+
"data-state": r,
|
|
2832
|
+
onError: a,
|
|
2833
|
+
onLoad: o
|
|
2834
|
+
});
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
}), sr = S({
|
|
2838
|
+
name: "UAvatarFallback",
|
|
2839
|
+
props: { class: {
|
|
2840
|
+
type: String,
|
|
2841
|
+
default: void 0
|
|
2842
|
+
} },
|
|
2843
|
+
setup(t, { attrs: n, slots: r }) {
|
|
2844
|
+
let i = ar("UAvatarFallback"), a = h(() => e("absolute inset-0 flex items-center justify-center font-medium text-text-secondary", t.class));
|
|
2845
|
+
return () => i.imageLoadingStatus.value === "loaded" ? null : C("span", {
|
|
2846
|
+
...n,
|
|
2847
|
+
class: a.value,
|
|
2848
|
+
"data-ug-slot": "fallback",
|
|
2849
|
+
"data-state": i.imageLoadingStatus.value
|
|
2850
|
+
}, r.default?.() ?? [C(he, { size: 16 })]);
|
|
2851
|
+
}
|
|
2852
|
+
}), cr = /* @__PURE__ */ S({
|
|
2853
|
+
name: "UAvatar",
|
|
2854
|
+
__name: "avatar",
|
|
2855
|
+
props: {
|
|
2856
|
+
size: { default: "md" },
|
|
2857
|
+
class: { default: void 0 }
|
|
2858
|
+
},
|
|
2859
|
+
setup(t) {
|
|
2860
|
+
let n = t, r = {
|
|
2861
|
+
sm: "[height:var(--control-height-sm)] [width:var(--control-height-sm)] text-xs",
|
|
2862
|
+
md: "[height:var(--control-height-md)] [width:var(--control-height-md)] text-sm",
|
|
2863
|
+
lg: "[height:var(--control-height-lg)] [width:var(--control-height-lg)] text-base",
|
|
2864
|
+
xl: "[height:calc(var(--control-height-lg)+var(--content-gap))] [width:calc(var(--control-height-lg)+var(--content-gap))] text-xl"
|
|
2865
|
+
}, i = h(() => e("relative inline-flex shrink-0 items-center justify-center overflow-hidden bg-surface-3 [border-radius:calc(var(--radius-overlay)*999)]", r[n.size], n.class)), a = P("idle");
|
|
2866
|
+
return M(rr, {
|
|
2867
|
+
imageLoadingStatus: a,
|
|
2868
|
+
setImageLoadingStatus: (e) => {
|
|
2869
|
+
a.value = e;
|
|
2870
|
+
}
|
|
2871
|
+
}), (e, n) => (j(), v("span", {
|
|
2872
|
+
class: O(i.value),
|
|
2873
|
+
"data-ug": "avatar",
|
|
2874
|
+
"data-state": a.value,
|
|
2875
|
+
"data-variant": "default",
|
|
2876
|
+
"data-size": t.size
|
|
2877
|
+
}, [I(e.$slots, "default")], 10, ir));
|
|
2878
|
+
}
|
|
2879
|
+
}), lr = ["data-state", "data-size"], ur = ["data-size"], dr = [
|
|
2880
|
+
"src",
|
|
2881
|
+
"alt",
|
|
2882
|
+
"onError",
|
|
2883
|
+
"onLoad"
|
|
2884
|
+
], fr = {
|
|
2885
|
+
key: 1,
|
|
2886
|
+
class: "flex h-full w-full items-center justify-center font-medium text-text-secondary",
|
|
2887
|
+
"data-ug-slot": "fallback"
|
|
2888
|
+
}, pr = ["aria-label", "data-size"], mr = /* @__PURE__ */ S({
|
|
2889
|
+
name: "UAvatarGroup",
|
|
2890
|
+
__name: "avatar-group",
|
|
2891
|
+
props: {
|
|
2892
|
+
items: {},
|
|
2893
|
+
max: { default: 5 },
|
|
2894
|
+
size: { default: "default" },
|
|
2895
|
+
class: { default: void 0 }
|
|
2896
|
+
},
|
|
2897
|
+
setup(t) {
|
|
2898
|
+
let n = t, r = {
|
|
2899
|
+
sm: "h-[var(--control-height-sm)] w-[var(--control-height-sm)] text-xs",
|
|
2900
|
+
default: "h-[var(--control-height-md)] w-[var(--control-height-md)] text-sm",
|
|
2901
|
+
lg: "h-[var(--control-height-lg)] w-[var(--control-height-lg)] text-base"
|
|
2902
|
+
}, i = {
|
|
2903
|
+
sm: "ring-2",
|
|
2904
|
+
default: "ring-2",
|
|
2905
|
+
lg: "ring-[3px]"
|
|
2906
|
+
}, a = {
|
|
2907
|
+
sm: "-ml-[calc(var(--control-height-sm)*0.1875)]",
|
|
2908
|
+
default: "-ml-[calc(var(--control-height-md)*0.2)]",
|
|
2909
|
+
lg: "-ml-[calc(var(--control-height-lg)*0.25)]"
|
|
2910
|
+
}, o = h(() => Math.max(0, Math.floor(Number.isFinite(n.max) ? n.max : 5))), s = h(() => n.items.slice(0, o.value)), c = h(() => Math.max(0, n.items.length - o.value)), l = h(() => e("flex max-w-full items-center overflow-hidden py-[calc(var(--content-gap)*0.125)]", n.class)), u = h(() => c.value > 0 ? "overflow" : "default");
|
|
2911
|
+
function d(t) {
|
|
2912
|
+
return e("relative inline-flex shrink-0 overflow-hidden [border-radius:calc(var(--radius-overlay)*999)] border border-border-base bg-surface-2 ring-surface-1", r[n.size], i[n.size], t > 0 && a[n.size]);
|
|
2913
|
+
}
|
|
2914
|
+
let p = h(() => e("relative inline-flex shrink-0 items-center justify-center [border-radius:calc(var(--radius-overlay)*999)] border border-border-base bg-surface-2 font-medium text-text-secondary ring-surface-1", r[n.size], i[n.size], a[n.size])), m = N(/* @__PURE__ */ new Map());
|
|
2915
|
+
function y(e, t) {
|
|
2916
|
+
return !!t && m.get(e) === t;
|
|
2917
|
+
}
|
|
2918
|
+
function x(e, t) {
|
|
2919
|
+
t && m.set(e, t);
|
|
2920
|
+
}
|
|
2921
|
+
function S(e) {
|
|
2922
|
+
m.delete(e);
|
|
2923
|
+
}
|
|
2924
|
+
return (e, n) => (j(), v("div", {
|
|
2925
|
+
class: O(l.value),
|
|
2926
|
+
"data-ug": "avatar-group",
|
|
2927
|
+
"data-state": u.value,
|
|
2928
|
+
"data-variant": "default",
|
|
2929
|
+
"data-size": t.size
|
|
2930
|
+
}, [(j(!0), v(f, null, F(s.value, (e, n) => (j(), v("span", {
|
|
2931
|
+
key: n,
|
|
2932
|
+
class: O(d(n)),
|
|
2933
|
+
"data-ug-slot": "item",
|
|
2934
|
+
"data-state": "default",
|
|
2935
|
+
"data-variant": "default",
|
|
2936
|
+
"data-size": t.size
|
|
2937
|
+
}, [e.src && !y(n, e.src) ? (j(), v("img", {
|
|
2938
|
+
key: 0,
|
|
2939
|
+
src: e.src,
|
|
2940
|
+
alt: e.alt ?? "",
|
|
2941
|
+
class: "block h-full w-full max-w-none object-cover object-center",
|
|
2942
|
+
"data-ug-slot": "image",
|
|
2943
|
+
onError: (t) => x(n, e.src),
|
|
2944
|
+
onLoad: (e) => S(n)
|
|
2945
|
+
}, null, 40, dr)) : (j(), v("span", fr, [e.fallback ? (j(), v(f, { key: 0 }, [b(R(e.fallback), 1)], 64)) : (j(), g(B(he), {
|
|
2946
|
+
key: 1,
|
|
2947
|
+
size: 16
|
|
2948
|
+
}))]))], 10, ur))), 128)), c.value > 0 ? (j(), v("span", {
|
|
2949
|
+
key: 0,
|
|
2950
|
+
class: O(p.value),
|
|
2951
|
+
"aria-label": `还有 ${c.value} 人`,
|
|
2952
|
+
"data-ug-slot": "overflow",
|
|
2953
|
+
"data-state": "overflow",
|
|
2954
|
+
"data-variant": "default",
|
|
2955
|
+
"data-size": t.size
|
|
2956
|
+
}, " +" + R(c.value), 11, pr)) : _("", !0)], 10, lr));
|
|
2957
|
+
}
|
|
2958
|
+
}), hr = Symbol("ug-tooltip-context"), gr = ["data-state"];
|
|
2959
|
+
function _r() {
|
|
2960
|
+
let e = w(hr);
|
|
2961
|
+
if (!e) throw Error("Tooltip 子组件必须在 <UTooltip> 内使用");
|
|
2962
|
+
return e;
|
|
2963
|
+
}
|
|
2964
|
+
function vr() {
|
|
2965
|
+
return typeof window < "u" && typeof document < "u";
|
|
2966
|
+
}
|
|
2967
|
+
var yr = {
|
|
2968
|
+
top: "after:absolute after:left-1/2 after:top-full after:-translate-x-1/2 after:border-4 after:border-transparent after:border-t-text-primary",
|
|
2969
|
+
bottom: "after:absolute after:bottom-full after:left-1/2 after:-translate-x-1/2 after:border-4 after:border-transparent after:border-b-text-primary",
|
|
2970
|
+
left: "after:absolute after:left-full after:top-1/2 after:-translate-y-1/2 after:border-4 after:border-transparent after:border-l-text-primary",
|
|
2971
|
+
right: "after:absolute after:right-full after:top-1/2 after:-translate-y-1/2 after:border-4 after:border-transparent after:border-r-text-primary"
|
|
2972
|
+
}, br = S({
|
|
2973
|
+
name: "UTooltipTrigger",
|
|
2974
|
+
props: { class: {
|
|
2975
|
+
type: String,
|
|
2976
|
+
default: void 0
|
|
2977
|
+
} },
|
|
2978
|
+
setup(t, { slots: n }) {
|
|
2979
|
+
let r = _r(), i = h(() => e("inline-flex", t.class));
|
|
2980
|
+
function a(e) {
|
|
2981
|
+
r.triggerRef.value = e, s();
|
|
2982
|
+
}
|
|
2983
|
+
function o() {
|
|
2984
|
+
let e = r.triggerRef.value;
|
|
2985
|
+
return e?.querySelector("button:not(:disabled), a[href], input:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") ?? e;
|
|
2986
|
+
}
|
|
2987
|
+
function s() {
|
|
2988
|
+
let e = o();
|
|
2989
|
+
r.open.value ? e?.setAttribute("aria-describedby", r.contentId) : e?.getAttribute("aria-describedby") === r.contentId && e.removeAttribute("aria-describedby");
|
|
2990
|
+
}
|
|
2991
|
+
function c() {
|
|
2992
|
+
typeof window > "u" || (r.delayTimer.value !== null && window.clearTimeout(r.delayTimer.value), r.delayTimer.value = window.setTimeout(() => {
|
|
2993
|
+
r.setOpen(!0);
|
|
2994
|
+
}, 200));
|
|
2995
|
+
}
|
|
2996
|
+
function l() {
|
|
2997
|
+
typeof window < "u" && r.delayTimer.value !== null && (window.clearTimeout(r.delayTimer.value), r.delayTimer.value = null), r.triggerRef.value?.contains(document.activeElement) || r.setOpen(!1);
|
|
2998
|
+
}
|
|
2999
|
+
return G(() => r.open.value, s, { immediate: !0 }), A(() => {
|
|
3000
|
+
let e = o();
|
|
3001
|
+
e?.getAttribute("aria-describedby") === r.contentId && e.removeAttribute("aria-describedby");
|
|
3002
|
+
}), () => C("span", {
|
|
3003
|
+
class: i.value,
|
|
3004
|
+
"data-ug-slot": "trigger",
|
|
3005
|
+
"data-state": r.open.value ? "open" : "default",
|
|
3006
|
+
onMouseenter: c,
|
|
3007
|
+
onMouseleave: l,
|
|
3008
|
+
onFocusin: () => r.setOpen(!0),
|
|
3009
|
+
onFocusout: (e) => {
|
|
3010
|
+
e.currentTarget.contains(e.relatedTarget) || r.setOpen(!1);
|
|
3011
|
+
},
|
|
3012
|
+
onKeydown: (e) => {
|
|
3013
|
+
e.key === "Escape" && (e.preventDefault(), r.setOpen(!1));
|
|
3014
|
+
},
|
|
3015
|
+
onVnodeMounted(e) {
|
|
3016
|
+
a(e.el);
|
|
3017
|
+
},
|
|
3018
|
+
onVnodeUpdated(e) {
|
|
3019
|
+
a(e.el);
|
|
3020
|
+
}
|
|
3021
|
+
}, n.default?.());
|
|
3022
|
+
}
|
|
3023
|
+
}), xr = S({
|
|
3024
|
+
name: "UTooltipContent",
|
|
3025
|
+
props: {
|
|
3026
|
+
side: {
|
|
3027
|
+
type: String,
|
|
3028
|
+
default: "top"
|
|
3029
|
+
},
|
|
3030
|
+
class: {
|
|
3031
|
+
type: String,
|
|
3032
|
+
default: void 0
|
|
3033
|
+
}
|
|
3034
|
+
},
|
|
3035
|
+
setup(t, { slots: n }) {
|
|
3036
|
+
let r = _r(), i = l(), a = h(() => c(i.value)), o = P(null), s = P({
|
|
3037
|
+
top: 0,
|
|
3038
|
+
left: 0
|
|
3039
|
+
}), u = h(() => e("absolute z-50 rounded-[var(--radius-control)] bg-text-primary px-[var(--control-padding-x-sm)] py-[calc(var(--content-gap)*0.375)] text-xs text-surface-1 shadow-md", yr[t.side], t.class));
|
|
3040
|
+
function d() {
|
|
3041
|
+
if (!r.triggerRef.value || !o.value || !vr()) return;
|
|
3042
|
+
let e = r.triggerRef.value.getBoundingClientRect(), n = o.value.offsetWidth, i = o.value.offsetHeight, a = 0, c = 0;
|
|
3043
|
+
t.side === "top" ? (a = e.top + window.scrollY - i - 8, c = e.left + window.scrollX + e.width / 2 - n / 2) : t.side === "bottom" ? (a = e.bottom + window.scrollY + 8, c = e.left + window.scrollX + e.width / 2 - n / 2) : t.side === "left" ? (a = e.top + window.scrollY + e.height / 2 - i / 2, c = e.left + window.scrollX - n - 8) : (a = e.top + window.scrollY + e.height / 2 - i / 2, c = e.right + window.scrollX + 8), s.value = {
|
|
3044
|
+
top: a,
|
|
3045
|
+
left: c
|
|
3046
|
+
};
|
|
3047
|
+
}
|
|
3048
|
+
function f() {
|
|
3049
|
+
vr() && (window.addEventListener("resize", d), window.addEventListener("scroll", d, !0));
|
|
3050
|
+
}
|
|
3051
|
+
function m() {
|
|
3052
|
+
vr() && (window.removeEventListener("resize", d), window.removeEventListener("scroll", d, !0));
|
|
3053
|
+
}
|
|
3054
|
+
return G(() => r.open.value, async (e) => {
|
|
3055
|
+
m(), !(!e || !vr()) && (await D(), d(), f());
|
|
3056
|
+
}, { immediate: !0 }), A(() => {
|
|
3057
|
+
m();
|
|
3058
|
+
}), () => r.open.value ? C(p, { to: "body" }, [C("div", {
|
|
3059
|
+
ref: o,
|
|
3060
|
+
id: r.contentId,
|
|
3061
|
+
role: "tooltip",
|
|
3062
|
+
...a.value,
|
|
3063
|
+
class: u.value,
|
|
3064
|
+
style: {
|
|
3065
|
+
top: `${s.value.top}px`,
|
|
3066
|
+
left: `${s.value.left}px`
|
|
3067
|
+
},
|
|
3068
|
+
"data-ug": "tooltip",
|
|
3069
|
+
"data-ug-slot": "content",
|
|
3070
|
+
"data-state": "open",
|
|
3071
|
+
"data-variant": "default",
|
|
3072
|
+
"data-size": "md"
|
|
3073
|
+
}, n.default?.())]) : null;
|
|
3074
|
+
}
|
|
3075
|
+
}), Sr = /* @__PURE__ */ S({
|
|
3076
|
+
name: "UTooltip",
|
|
3077
|
+
__name: "tooltip",
|
|
3078
|
+
props: { class: { default: void 0 } },
|
|
3079
|
+
setup(t) {
|
|
3080
|
+
let n = t, r = P(!1), i = P(null), a = P(null), o = `ug-tooltip-${V()}`, s = h(() => e("relative inline-flex", n.class));
|
|
3081
|
+
function c(e) {
|
|
3082
|
+
r.value = e;
|
|
3083
|
+
}
|
|
3084
|
+
return M(hr, {
|
|
3085
|
+
open: r,
|
|
3086
|
+
triggerRef: i,
|
|
3087
|
+
delayTimer: a,
|
|
3088
|
+
setOpen: c,
|
|
3089
|
+
contentId: o
|
|
3090
|
+
}), (e, t) => (j(), v("span", {
|
|
3091
|
+
class: O(s.value),
|
|
3092
|
+
"data-ug": "tooltip",
|
|
3093
|
+
"data-state": r.value ? "open" : "default",
|
|
3094
|
+
"data-variant": "default",
|
|
3095
|
+
"data-size": "md"
|
|
3096
|
+
}, [I(e.$slots, "default")], 10, gr));
|
|
3097
|
+
}
|
|
3098
|
+
}), Cr = ["data-variant"], wr = {
|
|
3099
|
+
"data-ug-slot": "content",
|
|
3100
|
+
class: "flex flex-col gap-0.5"
|
|
3101
|
+
};
|
|
3102
|
+
function Tr(t, n, r, i) {
|
|
3103
|
+
return S({
|
|
3104
|
+
name: t,
|
|
3105
|
+
props: { class: {
|
|
3106
|
+
type: String,
|
|
3107
|
+
default: void 0
|
|
3108
|
+
} },
|
|
3109
|
+
setup(t, { attrs: a, slots: o }) {
|
|
3110
|
+
let s = h(() => e(i, t.class));
|
|
3111
|
+
return () => C(n, {
|
|
3112
|
+
...a,
|
|
3113
|
+
class: s.value,
|
|
3114
|
+
"data-ug-slot": r
|
|
3115
|
+
}, o.default?.());
|
|
3116
|
+
}
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
var Er = Tr("UAlertTitle", "p", "title", "text-sm font-semibold leading-5"), Dr = Tr("UAlertDescription", "p", "description", "text-sm leading-5 opacity-90"), Or = /* @__PURE__ */ S({
|
|
3120
|
+
name: "UAlert",
|
|
3121
|
+
__name: "alert",
|
|
3122
|
+
props: {
|
|
3123
|
+
variant: { default: "default" },
|
|
3124
|
+
class: { default: void 0 }
|
|
3125
|
+
},
|
|
3126
|
+
setup(t) {
|
|
3127
|
+
let n = t, r = {
|
|
3128
|
+
default: "border-l-primary bg-info-soft text-info-soft-fg",
|
|
3129
|
+
info: "border-l-info bg-info-soft text-info-soft-fg",
|
|
3130
|
+
success: "border-l-success bg-success-soft text-success-soft-fg",
|
|
3131
|
+
warning: "border-l-warning bg-warning-soft text-warning-soft-fg",
|
|
3132
|
+
destructive: "border-l-danger bg-danger-soft text-danger-soft-fg"
|
|
3133
|
+
}, i = {
|
|
3134
|
+
default: q,
|
|
3135
|
+
info: le,
|
|
3136
|
+
success: Y,
|
|
3137
|
+
warning: J,
|
|
3138
|
+
destructive: q
|
|
3139
|
+
}, a = {
|
|
3140
|
+
default: "text-info",
|
|
3141
|
+
info: "text-info",
|
|
3142
|
+
success: "text-success",
|
|
3143
|
+
warning: "text-warning",
|
|
3144
|
+
destructive: "text-danger"
|
|
3145
|
+
}, o = h(() => e("relative flex gap-3 rounded-[var(--radius-panel)] border-l-4 p-[var(--content-gap)]", r[n.variant], n.class)), s = h(() => i[n.variant]), c = h(() => e("mt-0.5 shrink-0", a[n.variant]));
|
|
3146
|
+
return (e, n) => (j(), v("div", {
|
|
3147
|
+
role: "alert",
|
|
3148
|
+
class: O(o.value),
|
|
3149
|
+
"data-ug": "alert",
|
|
3150
|
+
"data-state": "default",
|
|
3151
|
+
"data-variant": t.variant,
|
|
3152
|
+
"data-size": "md"
|
|
3153
|
+
}, [(j(), g(L(s.value), {
|
|
3154
|
+
size: 18,
|
|
3155
|
+
class: O(c.value),
|
|
3156
|
+
"aria-hidden": "true",
|
|
3157
|
+
focusable: "false",
|
|
3158
|
+
"data-ug-slot": "icon"
|
|
3159
|
+
}, null, 8, ["class"])), y("div", wr, [I(e.$slots, "default")])], 10, Cr));
|
|
3160
|
+
}
|
|
3161
|
+
}), kr = {
|
|
3162
|
+
class: "flex flex-wrap items-center gap-0 text-sm text-text-secondary",
|
|
3163
|
+
"data-ug-slot": "list"
|
|
3164
|
+
}, Ar = S({
|
|
3165
|
+
name: "UBreadcrumbItem",
|
|
3166
|
+
props: { class: {
|
|
3167
|
+
type: String,
|
|
3168
|
+
default: void 0
|
|
3169
|
+
} },
|
|
3170
|
+
setup(t, { attrs: n, slots: r }) {
|
|
3171
|
+
let i = h(() => e("flex items-center gap-1", t.class));
|
|
3172
|
+
return () => C("li", {
|
|
3173
|
+
...n,
|
|
3174
|
+
class: i.value,
|
|
3175
|
+
"data-ug-slot": "item"
|
|
3176
|
+
}, r.default?.());
|
|
3177
|
+
}
|
|
3178
|
+
}), jr = S({
|
|
3179
|
+
name: "UBreadcrumbLink",
|
|
3180
|
+
inheritAttrs: !1,
|
|
3181
|
+
props: {
|
|
3182
|
+
current: {
|
|
3183
|
+
type: Boolean,
|
|
3184
|
+
default: !1
|
|
3185
|
+
},
|
|
3186
|
+
href: {
|
|
3187
|
+
type: String,
|
|
3188
|
+
default: void 0
|
|
3189
|
+
},
|
|
3190
|
+
class: {
|
|
3191
|
+
type: String,
|
|
3192
|
+
default: void 0
|
|
3193
|
+
}
|
|
3194
|
+
},
|
|
3195
|
+
setup(t, { attrs: n, slots: r }) {
|
|
3196
|
+
let i = h(() => e(t.current ? "font-medium text-text-primary" : "transition-colors hover:text-text-primary", t.class));
|
|
3197
|
+
return () => t.current ? C("span", {
|
|
3198
|
+
...n,
|
|
3199
|
+
"aria-current": "page",
|
|
3200
|
+
class: i.value,
|
|
3201
|
+
"data-ug-slot": "link",
|
|
3202
|
+
"data-state": "current"
|
|
3203
|
+
}, r.default?.()) : C("a", {
|
|
3204
|
+
...n,
|
|
3205
|
+
href: t.href,
|
|
3206
|
+
class: i.value,
|
|
3207
|
+
"data-ug-slot": "link",
|
|
3208
|
+
"data-state": "default"
|
|
3209
|
+
}, r.default?.());
|
|
3210
|
+
}
|
|
3211
|
+
}), Mr = S({
|
|
3212
|
+
name: "UBreadcrumbSeparator",
|
|
3213
|
+
props: { class: {
|
|
3214
|
+
type: String,
|
|
3215
|
+
default: void 0
|
|
3216
|
+
} },
|
|
3217
|
+
setup(t, { attrs: n, slots: r }) {
|
|
3218
|
+
let i = h(() => e("text-text-tertiary", t.class));
|
|
3219
|
+
return () => C("li", {
|
|
3220
|
+
...n,
|
|
3221
|
+
role: "presentation",
|
|
3222
|
+
"aria-hidden": "true",
|
|
3223
|
+
class: i.value,
|
|
3224
|
+
"data-ug-slot": "separator"
|
|
3225
|
+
}, r.default?.() ?? [C(se, { size: 14 })]);
|
|
3226
|
+
}
|
|
3227
|
+
}), Nr = /* @__PURE__ */ S({
|
|
3228
|
+
name: "UBreadcrumb",
|
|
3229
|
+
__name: "breadcrumb",
|
|
3230
|
+
props: { class: { default: void 0 } },
|
|
3231
|
+
setup(t) {
|
|
3232
|
+
let n = t, r = h(() => e(n.class));
|
|
3233
|
+
return (e, t) => (j(), v("nav", {
|
|
3234
|
+
"aria-label": "面包屑导航",
|
|
3235
|
+
class: O(r.value),
|
|
3236
|
+
"data-ug": "breadcrumb",
|
|
3237
|
+
"data-state": "default",
|
|
3238
|
+
"data-variant": "default",
|
|
3239
|
+
"data-size": "md"
|
|
3240
|
+
}, [y("ol", kr, [I(e.$slots, "default")])], 2));
|
|
3241
|
+
}
|
|
3242
|
+
}), Pr = [
|
|
3243
|
+
"for",
|
|
3244
|
+
"data-state",
|
|
3245
|
+
"data-size"
|
|
3246
|
+
], Fr = {
|
|
3247
|
+
key: 0,
|
|
3248
|
+
"data-ug-slot": "label"
|
|
3249
|
+
}, Ir = [
|
|
3250
|
+
"id",
|
|
3251
|
+
"form",
|
|
3252
|
+
"aria-checked",
|
|
3253
|
+
"disabled",
|
|
3254
|
+
"aria-busy",
|
|
3255
|
+
"data-state",
|
|
3256
|
+
"data-size"
|
|
3257
|
+
], Lr = [
|
|
3258
|
+
"name",
|
|
3259
|
+
"value",
|
|
3260
|
+
"form",
|
|
3261
|
+
"checked",
|
|
3262
|
+
"disabled"
|
|
3263
|
+
], Rr = {
|
|
3264
|
+
key: 4,
|
|
3265
|
+
"data-ug-slot": "label"
|
|
3266
|
+
}, zr = [
|
|
3267
|
+
"id",
|
|
3268
|
+
"form",
|
|
3269
|
+
"aria-checked",
|
|
3270
|
+
"disabled",
|
|
3271
|
+
"aria-busy",
|
|
3272
|
+
"data-state",
|
|
3273
|
+
"data-size"
|
|
3274
|
+
], Br = [
|
|
3275
|
+
"name",
|
|
3276
|
+
"value",
|
|
3277
|
+
"form",
|
|
3278
|
+
"checked",
|
|
3279
|
+
"disabled"
|
|
3280
|
+
], Vr = /* @__PURE__ */ S({
|
|
3281
|
+
name: "USwitch",
|
|
3282
|
+
inheritAttrs: !1,
|
|
3283
|
+
__name: "switch",
|
|
3284
|
+
props: /*@__PURE__*/ T({
|
|
3285
|
+
defaultChecked: {
|
|
3286
|
+
type: Boolean,
|
|
3287
|
+
default: !1
|
|
3288
|
+
},
|
|
3289
|
+
disabled: {
|
|
3290
|
+
type: Boolean,
|
|
3291
|
+
default: void 0
|
|
3292
|
+
},
|
|
3293
|
+
label: { default: void 0 },
|
|
3294
|
+
labelPlacement: { default: "right" },
|
|
3295
|
+
width: { default: void 0 },
|
|
3296
|
+
inlinePrompt: {
|
|
3297
|
+
type: Boolean,
|
|
3298
|
+
default: !1
|
|
3299
|
+
},
|
|
3300
|
+
activeText: { default: void 0 },
|
|
3301
|
+
inactiveText: { default: void 0 },
|
|
3302
|
+
activeIcon: { default: void 0 },
|
|
3303
|
+
inactiveIcon: { default: void 0 },
|
|
3304
|
+
activeAction: { default: void 0 },
|
|
3305
|
+
inactiveAction: { default: void 0 },
|
|
3306
|
+
size: {},
|
|
3307
|
+
id: { default: void 0 },
|
|
3308
|
+
class: { default: void 0 },
|
|
3309
|
+
name: { default: void 0 },
|
|
3310
|
+
value: { default: "on" },
|
|
3311
|
+
form: { default: void 0 },
|
|
3312
|
+
loading: {
|
|
3313
|
+
type: Boolean,
|
|
3314
|
+
default: !1
|
|
3315
|
+
},
|
|
3316
|
+
beforeChange: {
|
|
3317
|
+
type: Function,
|
|
3318
|
+
default: void 0
|
|
3319
|
+
}
|
|
3320
|
+
}, {
|
|
3321
|
+
checked: { type: Boolean },
|
|
3322
|
+
checkedModifiers: {}
|
|
3323
|
+
}),
|
|
3324
|
+
emits: /*@__PURE__*/ T(["change"], ["update:checked"]),
|
|
3325
|
+
setup(n, { expose: a, emit: o }) {
|
|
3326
|
+
let s = n, c = o, l = H(n, "checked"), u = P(!1), d = P(null), p = null, m = V(), x = te(), S = i(), C = h(() => s.id ?? m), w = h(() => r(s.disabled, S.value.disabled)), T = h(() => t(s.size, S.value.size)), k = h(() => s.loading || u.value), M = h({
|
|
3327
|
+
get: () => l.value ?? s.defaultChecked,
|
|
3328
|
+
set: (e) => {
|
|
3329
|
+
l.value = e;
|
|
3330
|
+
}
|
|
3331
|
+
}), N = {
|
|
3332
|
+
sm: "var(--control-height-sm)",
|
|
3333
|
+
default: "var(--control-height-md)",
|
|
3334
|
+
lg: "var(--control-height-lg)"
|
|
3335
|
+
}, F = (e) => typeof e == "number" ? `${e}px` : e, I = h(() => ({
|
|
3336
|
+
"--ug-switch-height": N[T.value],
|
|
3337
|
+
"--ug-switch-width": s.width === void 0 ? `calc(${N[T.value]} * 1.1)` : F(s.width)
|
|
3338
|
+
})), z = h(() => s.activeIcon ?? s.activeText), U = h(() => s.inactiveIcon ?? s.inactiveText), W = h(() => M.value ? z.value : U.value), ne = h(() => M.value ? s.activeAction : s.inactiveAction), re = h(() => !s.inlinePrompt && (z.value !== void 0 || U.value !== void 0)), K = h(() => !!(s.label || re.value)), q = h(() => e("relative inline-flex h-[calc(var(--ug-switch-height)*0.6)] w-[var(--ug-switch-width)] min-w-[calc(var(--ug-switch-height)*1.1)] shrink-0 items-center rounded-[var(--radius-overlay)] border border-transparent p-[calc(var(--ug-switch-height)*0.05)] shadow-sm transition-colors duration-200", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0", "disabled:cursor-not-allowed disabled:opacity-50", M.value ? "bg-primary hover:bg-primary-hover" : "bg-surface-3 hover:bg-border-strong", s.class)), J = h(() => e("inline-flex cursor-pointer items-center gap-2.5 text-sm font-medium leading-5 text-text-primary", w.value && "cursor-not-allowed opacity-50")), ie = h(() => k.value ? M.value ? "checked loading" : "unchecked loading" : w.value ? M.value ? "checked disabled" : "unchecked disabled" : M.value ? "checked" : "unchecked"), Y = h(() => {
|
|
3339
|
+
let e = { ...x };
|
|
3340
|
+
return delete e.class, delete e.id, e;
|
|
3341
|
+
});
|
|
3342
|
+
async function ae() {
|
|
3343
|
+
if (w.value || k.value) return;
|
|
3344
|
+
let e = !M.value;
|
|
3345
|
+
if (s.beforeChange) {
|
|
3346
|
+
u.value = !0;
|
|
3347
|
+
try {
|
|
3348
|
+
if (await s.beforeChange(e) === !1) return;
|
|
3349
|
+
} catch {
|
|
3350
|
+
return;
|
|
3351
|
+
} finally {
|
|
3352
|
+
u.value = !1;
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
M.value = e, c("change", e);
|
|
3356
|
+
}
|
|
3357
|
+
function oe() {
|
|
3358
|
+
M.value = s.defaultChecked, u.value = !1;
|
|
3359
|
+
}
|
|
3360
|
+
function se() {
|
|
3361
|
+
let e = d.value?.form ?? null;
|
|
3362
|
+
p !== e && (p?.removeEventListener("reset", oe), p = e, p?.addEventListener("reset", oe));
|
|
3363
|
+
}
|
|
3364
|
+
return ee(() => void D(se)), G(() => s.form, () => void D(se)), A(() => p?.removeEventListener("reset", oe)), a({
|
|
3365
|
+
focus: () => d.value?.focus(),
|
|
3366
|
+
blur: () => d.value?.blur(),
|
|
3367
|
+
el: d
|
|
3368
|
+
}), (t, r) => (j(), v(f, null, [K.value ? (j(), v("label", {
|
|
3369
|
+
key: 0,
|
|
3370
|
+
for: C.value,
|
|
3371
|
+
class: O(J.value),
|
|
3372
|
+
"data-ug": "switch",
|
|
3373
|
+
"data-state": ie.value,
|
|
3374
|
+
"data-variant": "default",
|
|
3375
|
+
"data-size": T.value
|
|
3376
|
+
}, [
|
|
3377
|
+
n.label && n.labelPlacement === "left" ? (j(), v("span", Fr, R(n.label), 1)) : _("", !0),
|
|
3378
|
+
re.value ? (j(), v("span", {
|
|
3379
|
+
key: 1,
|
|
3380
|
+
class: O(B(e)("text-xs transition-colors", M.value ? "text-text-secondary" : "text-primary")),
|
|
3381
|
+
"aria-hidden": "true",
|
|
3382
|
+
"data-ug-slot": "inactive-content"
|
|
3383
|
+
}, [n.inactiveIcon ? (j(), g(L(n.inactiveIcon), { key: 0 })) : (j(), v(f, { key: 1 }, [b(R(n.inactiveText), 1)], 64))], 2)) : _("", !0),
|
|
3384
|
+
y("button", E({
|
|
3385
|
+
id: C.value,
|
|
3386
|
+
ref_key: "triggerRef",
|
|
3387
|
+
ref: d,
|
|
3388
|
+
type: "button",
|
|
3389
|
+
form: n.form,
|
|
3390
|
+
role: "switch",
|
|
3391
|
+
"aria-checked": M.value,
|
|
3392
|
+
disabled: w.value || k.value,
|
|
3393
|
+
"aria-busy": k.value || void 0,
|
|
3394
|
+
style: I.value,
|
|
3395
|
+
class: q.value,
|
|
3396
|
+
"data-ug-slot": "track",
|
|
3397
|
+
"data-state": ie.value,
|
|
3398
|
+
"data-variant": "default",
|
|
3399
|
+
"data-size": T.value
|
|
3400
|
+
}, Y.value, { onClick: ae }), [n.inlinePrompt && W.value !== void 0 ? (j(), v("span", {
|
|
3401
|
+
key: 0,
|
|
3402
|
+
class: O(B(e)("pointer-events-none absolute inset-y-0 flex max-w-[60%] items-center overflow-hidden text-ellipsis whitespace-nowrap px-[calc(var(--ug-switch-height)*0.12)] text-[10px] font-semibold leading-none text-primary-fg", M.value ? "left-0" : "right-0")),
|
|
3403
|
+
"data-ug-slot": "content"
|
|
3404
|
+
}, [typeof W.value == "string" ? (j(), v(f, { key: 1 }, [b(R(W.value), 1)], 64)) : (j(), g(L(W.value), { key: 0 }))], 2)) : _("", !0), y("span", {
|
|
3405
|
+
class: O(B(e)("pointer-events-none relative z-[1] flex h-[calc(var(--ug-switch-height)*0.5)] w-[calc(var(--ug-switch-height)*0.5)] items-center justify-center rounded-[var(--radius-control)] bg-primary-fg text-[10px] text-primary shadow-md ring-0 transition-transform duration-200", M.value ? "translate-x-[calc(var(--ug-switch-height)*0.5)]" : "translate-x-0", k.value && "animate-pulse")),
|
|
3406
|
+
"data-ug-slot": "thumb"
|
|
3407
|
+
}, [ne.value ? (j(), g(L(ne.value), { key: 0 })) : _("", !0)], 2)], 16, Ir),
|
|
3408
|
+
re.value ? (j(), v("span", {
|
|
3409
|
+
key: 2,
|
|
3410
|
+
class: O(B(e)("text-xs transition-colors", M.value ? "text-primary" : "text-text-secondary")),
|
|
3411
|
+
"aria-hidden": "true",
|
|
3412
|
+
"data-ug-slot": "active-content"
|
|
3413
|
+
}, [n.activeIcon ? (j(), g(L(n.activeIcon), { key: 0 })) : (j(), v(f, { key: 1 }, [b(R(n.activeText), 1)], 64))], 2)) : _("", !0),
|
|
3414
|
+
n.name ? (j(), v("input", {
|
|
3415
|
+
key: 3,
|
|
3416
|
+
type: "checkbox",
|
|
3417
|
+
hidden: "",
|
|
3418
|
+
tabindex: "-1",
|
|
3419
|
+
"aria-hidden": "true",
|
|
3420
|
+
name: n.name,
|
|
3421
|
+
value: n.value,
|
|
3422
|
+
form: n.form,
|
|
3423
|
+
checked: M.value,
|
|
3424
|
+
disabled: w.value || k.value,
|
|
3425
|
+
"data-ug-slot": "native"
|
|
3426
|
+
}, null, 8, Lr)) : _("", !0),
|
|
3427
|
+
n.label && n.labelPlacement === "right" ? (j(), v("span", Rr, R(n.label), 1)) : _("", !0)
|
|
3428
|
+
], 10, Pr)) : (j(), v("button", E({
|
|
3429
|
+
key: 1,
|
|
3430
|
+
id: C.value,
|
|
3431
|
+
ref_key: "triggerRef",
|
|
3432
|
+
ref: d,
|
|
3433
|
+
type: "button",
|
|
3434
|
+
form: n.form,
|
|
3435
|
+
role: "switch",
|
|
3436
|
+
"aria-checked": M.value,
|
|
3437
|
+
disabled: w.value || k.value,
|
|
3438
|
+
"aria-busy": k.value || void 0,
|
|
3439
|
+
style: I.value,
|
|
3440
|
+
class: q.value,
|
|
3441
|
+
"data-ug": "switch",
|
|
3442
|
+
"data-ug-slot": "track",
|
|
3443
|
+
"data-state": ie.value,
|
|
3444
|
+
"data-variant": "default",
|
|
3445
|
+
"data-size": T.value
|
|
3446
|
+
}, Y.value, { onClick: ae }), [n.inlinePrompt && W.value !== void 0 ? (j(), v("span", {
|
|
3447
|
+
key: 0,
|
|
3448
|
+
class: O(B(e)("pointer-events-none absolute inset-y-0 flex max-w-[60%] items-center overflow-hidden text-ellipsis whitespace-nowrap px-[calc(var(--ug-switch-height)*0.12)] text-[10px] font-semibold leading-none text-primary-fg", M.value ? "left-0" : "right-0")),
|
|
3449
|
+
"data-ug-slot": "content"
|
|
3450
|
+
}, [typeof W.value == "string" ? (j(), v(f, { key: 1 }, [b(R(W.value), 1)], 64)) : (j(), g(L(W.value), { key: 0 }))], 2)) : _("", !0), y("span", {
|
|
3451
|
+
class: O(B(e)("pointer-events-none relative z-[1] flex h-[calc(var(--ug-switch-height)*0.5)] w-[calc(var(--ug-switch-height)*0.5)] items-center justify-center rounded-[var(--radius-control)] bg-primary-fg text-[10px] text-primary shadow-md ring-0 transition-transform duration-200", M.value ? "translate-x-[calc(var(--ug-switch-height)*0.5)]" : "translate-x-0", k.value && "animate-pulse")),
|
|
3452
|
+
"data-ug-slot": "thumb"
|
|
3453
|
+
}, [ne.value ? (j(), g(L(ne.value), { key: 0 })) : _("", !0)], 2)], 16, zr)), !n.label && n.name ? (j(), v("input", {
|
|
3454
|
+
key: 2,
|
|
3455
|
+
type: "checkbox",
|
|
3456
|
+
hidden: "",
|
|
3457
|
+
tabindex: "-1",
|
|
3458
|
+
"aria-hidden": "true",
|
|
3459
|
+
name: n.name,
|
|
3460
|
+
value: n.value,
|
|
3461
|
+
form: n.form,
|
|
3462
|
+
checked: M.value,
|
|
3463
|
+
disabled: w.value || k.value,
|
|
3464
|
+
"data-ug-slot": "native"
|
|
3465
|
+
}, null, 8, Br)) : _("", !0)], 64));
|
|
3466
|
+
}
|
|
3467
|
+
}), Hr = [
|
|
3468
|
+
"data-size",
|
|
3469
|
+
"data-state",
|
|
3470
|
+
"data-variant"
|
|
3471
|
+
], Ur = ["for"], Wr = {
|
|
3472
|
+
class: "relative min-w-0",
|
|
3473
|
+
"data-ug-slot": "wrapper"
|
|
3474
|
+
}, Gr = [
|
|
3475
|
+
"id",
|
|
3476
|
+
"aria-describedby",
|
|
3477
|
+
"aria-invalid",
|
|
3478
|
+
"disabled",
|
|
3479
|
+
"maxlength",
|
|
3480
|
+
"placeholder",
|
|
3481
|
+
"readonly",
|
|
3482
|
+
"rows",
|
|
3483
|
+
"value"
|
|
3484
|
+
], Kr = {
|
|
3485
|
+
key: 1,
|
|
3486
|
+
"aria-hidden": "true",
|
|
3487
|
+
class: "pointer-events-none absolute bottom-2 right-3 text-xs tabular-nums text-text-tertiary",
|
|
3488
|
+
"data-ug-slot": "count"
|
|
3489
|
+
}, qr = {
|
|
3490
|
+
key: 1,
|
|
3491
|
+
"aria-hidden": "true",
|
|
3492
|
+
class: "self-end text-xs tabular-nums text-text-tertiary",
|
|
3493
|
+
"data-ug-slot": "count"
|
|
3494
|
+
}, Jr = ["id"], Yr = ["id"], Xr = /* @__PURE__ */ S({
|
|
3495
|
+
name: "UTextarea",
|
|
3496
|
+
inheritAttrs: !1,
|
|
3497
|
+
__name: "textarea",
|
|
3498
|
+
props: /*@__PURE__*/ T({
|
|
3499
|
+
label: { default: void 0 },
|
|
3500
|
+
error: { default: void 0 },
|
|
3501
|
+
helperText: { default: void 0 },
|
|
3502
|
+
id: { default: void 0 },
|
|
3503
|
+
rows: { default: 3 },
|
|
3504
|
+
disabled: {
|
|
3505
|
+
type: Boolean,
|
|
3506
|
+
default: void 0
|
|
3507
|
+
},
|
|
3508
|
+
readonly: {
|
|
3509
|
+
type: Boolean,
|
|
3510
|
+
default: !1
|
|
3511
|
+
},
|
|
3512
|
+
size: { default: void 0 },
|
|
3513
|
+
placeholder: { default: void 0 },
|
|
3514
|
+
maxlength: { default: void 0 },
|
|
3515
|
+
resize: { default: "vertical" },
|
|
3516
|
+
autosize: {
|
|
3517
|
+
type: [Boolean, Object],
|
|
3518
|
+
default: !1
|
|
3519
|
+
},
|
|
3520
|
+
clearable: {
|
|
3521
|
+
type: Boolean,
|
|
3522
|
+
default: !1
|
|
3523
|
+
},
|
|
3524
|
+
clearIcon: { default: void 0 },
|
|
3525
|
+
showWordLimit: {
|
|
3526
|
+
type: Boolean,
|
|
3527
|
+
default: !1
|
|
3528
|
+
},
|
|
3529
|
+
wordLimitPosition: { default: "inside" },
|
|
3530
|
+
countCharacters: { default: void 0 },
|
|
3531
|
+
class: { default: void 0 }
|
|
3532
|
+
}, {
|
|
3533
|
+
modelValue: {},
|
|
3534
|
+
modelModifiers: {}
|
|
3535
|
+
}),
|
|
3536
|
+
emits: /*@__PURE__*/ T([
|
|
3537
|
+
"blur",
|
|
3538
|
+
"focus",
|
|
3539
|
+
"input",
|
|
3540
|
+
"change",
|
|
3541
|
+
"clear",
|
|
3542
|
+
"compositionend",
|
|
3543
|
+
"compositionstart"
|
|
3544
|
+
], ["update:modelValue"]),
|
|
3545
|
+
setup(n, { expose: a, emit: o }) {
|
|
3546
|
+
let s = n, c = o, l = H(n, "modelValue"), u = te(), d = i(), f = V(), p = P(null), m = P(!1), b = null, x = h(() => s.id ?? f), S = h(() => `${x.value}-message`), C = h(() => r(s.disabled, d.value.disabled)), w = h(() => t(s.size, d.value.size)), T = h(() => l.value ?? ""), O = h(() => !!(s.error || s.helperText || s.showWordLimit && s.maxlength)), k = h(() => Z(T.value, s.countCharacters)), M = h(() => s.clearable && T.value.length > 0 && !C.value && !s.readonly), N = h(() => s.showWordLimit && s.maxlength && s.wordLimitPosition === "inside"), F = h(() => [
|
|
3547
|
+
s.error && "invalid",
|
|
3548
|
+
C.value && "disabled",
|
|
3549
|
+
s.readonly && "readonly"
|
|
3550
|
+
].filter(Boolean).join(" ") || "default"), z = {
|
|
3551
|
+
none: "resize-none",
|
|
3552
|
+
both: "resize",
|
|
3553
|
+
horizontal: "resize-x",
|
|
3554
|
+
vertical: "resize-y"
|
|
3555
|
+
}, U = h(() => e("block w-full border bg-surface-1 text-text-primary placeholder:text-text-tertiary [border-radius:var(--radius-control)]", {
|
|
3556
|
+
"min-h-[calc(var(--control-height-sm)*2)] px-[var(--control-padding-x-sm)] py-1.5 text-xs": w.value === "sm",
|
|
3557
|
+
"min-h-[calc(var(--control-height-md)*2)] px-[var(--control-padding-x-md)] py-2 text-sm": w.value === "default",
|
|
3558
|
+
"min-h-[calc(var(--control-height-lg)*2)] px-[var(--control-padding-x-lg)] py-2.5 text-base": w.value === "lg"
|
|
3559
|
+
}, s.autosize ? "resize-none" : z[s.resize], N.value && "pb-7", M.value && "pr-9", "transition-[background,border-color,box-shadow] duration-[var(--motion-duration-base)] ease-[var(--motion-easing-standard)] motion-reduce:transition-none", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1", "disabled:cursor-not-allowed disabled:opacity-50", s.readonly && "bg-surface-2", s.error ? "border-danger focus-visible:ring-danger/30" : "border-border-strong focus-visible:border-primary focus-visible:ring-ring/30", s.class)), W = h(() => {
|
|
3560
|
+
let e = { ...u };
|
|
3561
|
+
return delete e.class, delete e["aria-describedby"], delete e["aria-invalid"], e;
|
|
3562
|
+
}), ne = h(() => typeof u["aria-describedby"] == "string" ? u["aria-describedby"] : O.value ? S.value : void 0), re = h(() => {
|
|
3563
|
+
let e = u["aria-invalid"];
|
|
3564
|
+
return typeof e == "boolean" || e === "true" || e === "false" || e === "grammar" || e === "spelling" ? e : s.error ? !0 : void 0;
|
|
3565
|
+
});
|
|
3566
|
+
function K() {
|
|
3567
|
+
let e = p.value;
|
|
3568
|
+
if (!e || !s.autosize) return;
|
|
3569
|
+
let t = typeof s.autosize == "object" ? s.autosize : {}, n = getComputedStyle(e), r = Number.parseFloat(n.lineHeight) || Number.parseFloat(n.fontSize) * 1.5, i = Number.parseFloat(n.paddingTop) + Number.parseFloat(n.paddingBottom) + Number.parseFloat(n.borderTopWidth) + Number.parseFloat(n.borderBottomWidth), a = Math.max(1, t.minRows ?? s.rows), o = t.maxRows ? Math.max(a, t.maxRows) : void 0, c = r * a + i, l = o ? r * o + i : Infinity;
|
|
3570
|
+
e.style.height = "auto", e.style.height = `${Math.min(l, Math.max(c, e.scrollHeight))}px`, e.style.overflowY = e.scrollHeight > l ? "auto" : "hidden";
|
|
3571
|
+
}
|
|
3572
|
+
function q(e) {
|
|
3573
|
+
let t = e.target, n = m.value ? t.value : $(t.value, s.maxlength, s.countCharacters);
|
|
3574
|
+
n !== t.value && (t.value = n), l.value = n, D(K), c("input", e);
|
|
3575
|
+
}
|
|
3576
|
+
function J(e) {
|
|
3577
|
+
m.value = !0, c("compositionstart", e);
|
|
3578
|
+
}
|
|
3579
|
+
function ie(e) {
|
|
3580
|
+
m.value = !1;
|
|
3581
|
+
let t = e.target, n = $(t.value, s.maxlength, s.countCharacters);
|
|
3582
|
+
n !== t.value && (t.value = n), l.value = n, D(K), c("compositionend", e);
|
|
3583
|
+
}
|
|
3584
|
+
function Y() {
|
|
3585
|
+
p.value?.focus();
|
|
3586
|
+
}
|
|
3587
|
+
function ae() {
|
|
3588
|
+
p.value?.blur();
|
|
3589
|
+
}
|
|
3590
|
+
function oe() {
|
|
3591
|
+
l.value = "", c("clear"), p.value?.focus();
|
|
3592
|
+
}
|
|
3593
|
+
function se() {
|
|
3594
|
+
D(K);
|
|
3595
|
+
}
|
|
3596
|
+
function ce() {
|
|
3597
|
+
let e = p.value?.form ?? null;
|
|
3598
|
+
b !== e && (b?.removeEventListener("reset", se), b = e, b?.addEventListener("reset", se));
|
|
3599
|
+
}
|
|
3600
|
+
return G(() => [
|
|
3601
|
+
l.value,
|
|
3602
|
+
s.autosize,
|
|
3603
|
+
s.rows
|
|
3604
|
+
], () => void D(K), { deep: !0 }), ee(() => void D(() => {
|
|
3605
|
+
K(), ce();
|
|
3606
|
+
})), G(() => u.form, () => void D(ce)), A(() => b?.removeEventListener("reset", se)), a({
|
|
3607
|
+
focus: Y,
|
|
3608
|
+
blur: ae,
|
|
3609
|
+
clear: oe,
|
|
3610
|
+
resizeTextarea: K,
|
|
3611
|
+
el: p
|
|
3612
|
+
}), (e, t) => (j(), v("div", {
|
|
3613
|
+
class: "flex min-w-0 flex-col gap-1",
|
|
3614
|
+
"data-size": w.value,
|
|
3615
|
+
"data-state": F.value,
|
|
3616
|
+
"data-ug": "textarea",
|
|
3617
|
+
"data-ug-slot": "root",
|
|
3618
|
+
"data-variant": n.autosize ? "autosize" : n.resize
|
|
3619
|
+
}, [
|
|
3620
|
+
n.label ? (j(), v("label", {
|
|
3621
|
+
key: 0,
|
|
3622
|
+
for: x.value,
|
|
3623
|
+
class: "text-sm font-medium text-text-primary",
|
|
3624
|
+
"data-ug-slot": "label"
|
|
3625
|
+
}, R(n.label), 9, Ur)) : _("", !0),
|
|
3626
|
+
y("div", Wr, [
|
|
3627
|
+
y("textarea", E(W.value, {
|
|
3628
|
+
id: x.value,
|
|
3629
|
+
ref_key: "textareaRef",
|
|
3630
|
+
ref: p,
|
|
3631
|
+
"aria-describedby": ne.value,
|
|
3632
|
+
"aria-invalid": re.value,
|
|
3633
|
+
class: U.value,
|
|
3634
|
+
"data-ug-slot": "control",
|
|
3635
|
+
disabled: C.value,
|
|
3636
|
+
maxlength: n.countCharacters ? void 0 : n.maxlength,
|
|
3637
|
+
placeholder: n.placeholder,
|
|
3638
|
+
readonly: n.readonly,
|
|
3639
|
+
rows: n.rows,
|
|
3640
|
+
value: T.value,
|
|
3641
|
+
onBlur: t[0] || (t[0] = (e) => c("blur", e)),
|
|
3642
|
+
onChange: t[1] || (t[1] = (e) => c("change", e)),
|
|
3643
|
+
onCompositionend: ie,
|
|
3644
|
+
onCompositionstart: J,
|
|
3645
|
+
onFocus: t[2] || (t[2] = (e) => c("focus", e)),
|
|
3646
|
+
onInput: q
|
|
3647
|
+
}), null, 16, Gr),
|
|
3648
|
+
M.value ? (j(), v("button", {
|
|
3649
|
+
key: 0,
|
|
3650
|
+
"aria-label": "清空输入",
|
|
3651
|
+
class: "absolute right-2 top-2 inline-flex size-7 items-center justify-center rounded-[var(--radius-control)] text-text-secondary hover:bg-surface-2 hover:text-text-primary",
|
|
3652
|
+
"data-ug-slot": "clear",
|
|
3653
|
+
tabindex: "-1",
|
|
3654
|
+
type: "button",
|
|
3655
|
+
onClick: oe
|
|
3656
|
+
}, [I(e.$slots, "clearIcon", {}, () => [(j(), g(L(n.clearIcon || B(ge)), {
|
|
3657
|
+
"aria-hidden": "true",
|
|
3658
|
+
size: 14
|
|
3659
|
+
}))])])) : _("", !0),
|
|
3660
|
+
N.value ? (j(), v("span", Kr, R(k.value) + "/" + R(n.maxlength), 1)) : _("", !0)
|
|
3661
|
+
]),
|
|
3662
|
+
n.showWordLimit && n.maxlength && n.wordLimitPosition === "outside" ? (j(), v("span", qr, R(k.value) + "/" + R(n.maxlength), 1)) : _("", !0),
|
|
3663
|
+
n.error ? (j(), v("p", {
|
|
3664
|
+
key: 2,
|
|
3665
|
+
id: S.value,
|
|
3666
|
+
class: "text-xs text-danger",
|
|
3667
|
+
"data-ug-slot": "message"
|
|
3668
|
+
}, R(n.error), 9, Jr)) : n.helperText ? (j(), v("p", {
|
|
3669
|
+
key: 3,
|
|
3670
|
+
id: S.value,
|
|
3671
|
+
class: "text-xs text-text-secondary",
|
|
3672
|
+
"data-ug-slot": "message"
|
|
3673
|
+
}, R(n.helperText), 9, Yr)) : _("", !0)
|
|
3674
|
+
], 8, Hr));
|
|
3675
|
+
}
|
|
3676
|
+
}), Zr = ["data-variant"], Qr = /* @__PURE__ */ S({
|
|
3677
|
+
name: "USkeleton",
|
|
3678
|
+
inheritAttrs: !1,
|
|
3679
|
+
__name: "skeleton",
|
|
3680
|
+
props: {
|
|
3681
|
+
variant: { default: "rect" },
|
|
3682
|
+
class: { default: void 0 }
|
|
3683
|
+
},
|
|
3684
|
+
setup(t) {
|
|
3685
|
+
let n = t, r = {
|
|
3686
|
+
text: "w-full [height:calc(var(--control-height-sm)*0.5)] [border-radius:calc(var(--radius-control)*0.5)]",
|
|
3687
|
+
circle: "[border-radius:calc(var(--radius-overlay)*999)]",
|
|
3688
|
+
rect: "[border-radius:var(--radius-panel)]"
|
|
3689
|
+
}, i = h(() => e("animate-pulse bg-surface-3", r[n.variant], n.class));
|
|
3690
|
+
return (e, n) => (j(), v("div", E(e.$attrs, {
|
|
3691
|
+
class: i.value,
|
|
3692
|
+
"aria-hidden": "true",
|
|
3693
|
+
"data-ug": "skeleton",
|
|
3694
|
+
"data-ug-slot": "placeholder",
|
|
3695
|
+
"data-state": "loading",
|
|
3696
|
+
"data-variant": t.variant,
|
|
3697
|
+
"data-size": "md"
|
|
3698
|
+
}), null, 16, Zr));
|
|
3699
|
+
}
|
|
3700
|
+
}), $r = ["data-state", "data-variant"], ei = ["aria-valuenow", "aria-valuemax"], ti = {
|
|
3701
|
+
key: 0,
|
|
3702
|
+
class: "w-9 shrink-0 text-right text-xs font-medium tabular-nums text-text-secondary",
|
|
3703
|
+
"data-ug-slot": "label"
|
|
3704
|
+
}, ni = /* @__PURE__ */ S({
|
|
3705
|
+
name: "UProgress",
|
|
3706
|
+
__name: "progress",
|
|
3707
|
+
props: {
|
|
3708
|
+
value: {},
|
|
3709
|
+
max: { default: 100 },
|
|
3710
|
+
showLabel: {
|
|
3711
|
+
type: Boolean,
|
|
3712
|
+
default: !1
|
|
3713
|
+
},
|
|
3714
|
+
color: { default: "primary" },
|
|
3715
|
+
class: { default: void 0 }
|
|
3716
|
+
},
|
|
3717
|
+
setup(t) {
|
|
3718
|
+
let n = {
|
|
3719
|
+
primary: "bg-primary",
|
|
3720
|
+
success: "bg-success",
|
|
3721
|
+
warning: "bg-warning",
|
|
3722
|
+
danger: "bg-danger",
|
|
3723
|
+
info: "bg-info"
|
|
3724
|
+
}, r = t, i = h(() => Number.isFinite(r.max) && r.max > 0 ? r.max : 100), a = h(() => Number.isFinite(r.value) ? r.value : 0), o = h(() => Math.min(Math.max(a.value, 0), i.value)), s = h(() => Math.round(o.value / i.value * 100)), c = h(() => s.value >= 100 ? "complete" : "active"), l = h(() => e("flex w-full min-w-0 items-center gap-3", r.class)), u = h(() => e("h-full transition-all duration-500 ease-out [border-radius:calc(var(--radius-control)*999)]", n[r.color]));
|
|
3725
|
+
return (e, n) => (j(), v("div", {
|
|
3726
|
+
class: O(l.value),
|
|
3727
|
+
"data-ug": "progress",
|
|
3728
|
+
"data-state": c.value,
|
|
3729
|
+
"data-variant": t.color,
|
|
3730
|
+
"data-size": "md"
|
|
3731
|
+
}, [y("div", {
|
|
3732
|
+
role: "progressbar",
|
|
3733
|
+
"aria-valuenow": o.value,
|
|
3734
|
+
"aria-valuemin": "0",
|
|
3735
|
+
"aria-valuemax": i.value,
|
|
3736
|
+
class: "min-w-0 flex-1 overflow-hidden bg-surface-2 [height:calc(var(--control-height-sm)*0.25)] [border-radius:calc(var(--radius-control)*999)]",
|
|
3737
|
+
"data-ug-slot": "track"
|
|
3738
|
+
}, [y("div", {
|
|
3739
|
+
class: O(u.value),
|
|
3740
|
+
style: k({ width: `${s.value}%` }),
|
|
3741
|
+
"data-ug-slot": "indicator"
|
|
3742
|
+
}, null, 6)], 8, ei), t.showLabel ? (j(), v("span", ti, R(s.value) + "% ", 1)) : _("", !0)], 10, $r));
|
|
3743
|
+
}
|
|
3744
|
+
}), ri = [
|
|
3745
|
+
"aria-labelledby",
|
|
3746
|
+
"aria-label",
|
|
3747
|
+
"data-variant"
|
|
3748
|
+
], ii = {
|
|
3749
|
+
key: 0,
|
|
3750
|
+
class: "flex items-center justify-between border-b border-border-base p-[var(--content-gap)]",
|
|
3751
|
+
"data-ug-slot": "header"
|
|
3752
|
+
}, ai = ["id"], oi = { key: 1 }, si = {
|
|
3753
|
+
"data-ug-slot": "body",
|
|
3754
|
+
class: "flex-1 overflow-y-auto p-[var(--content-gap)]"
|
|
3755
|
+
}, ci = {
|
|
3756
|
+
key: 1,
|
|
3757
|
+
class: "border-t border-border-base p-[var(--content-gap)]"
|
|
3758
|
+
}, li = /* @__PURE__ */ S({
|
|
3759
|
+
name: "USheet",
|
|
3760
|
+
__name: "sheet",
|
|
3761
|
+
props: /*@__PURE__*/ T({
|
|
3762
|
+
side: { default: "right" },
|
|
3763
|
+
title: { default: void 0 },
|
|
3764
|
+
closeOnOverlay: {
|
|
3765
|
+
type: Boolean,
|
|
3766
|
+
default: !0
|
|
3767
|
+
},
|
|
3768
|
+
closeOnEsc: {
|
|
3769
|
+
type: Boolean,
|
|
3770
|
+
default: !0
|
|
3771
|
+
},
|
|
3772
|
+
showCloseButton: {
|
|
3773
|
+
type: Boolean,
|
|
3774
|
+
default: !0
|
|
3775
|
+
},
|
|
3776
|
+
class: { default: void 0 }
|
|
3777
|
+
}, {
|
|
3778
|
+
open: {
|
|
3779
|
+
type: Boolean,
|
|
3780
|
+
default: !1
|
|
3781
|
+
},
|
|
3782
|
+
openModifiers: {}
|
|
3783
|
+
}),
|
|
3784
|
+
emits: /*@__PURE__*/ T(["close", "openChange"], ["update:open"]),
|
|
3785
|
+
setup(t, { emit: n }) {
|
|
3786
|
+
let r = t, i = n, a = H(t, "open");
|
|
3787
|
+
o(a, T);
|
|
3788
|
+
let u = P(null), d = V(), f = s(a, u), m = h(() => e("relative flex h-full w-[min(20rem,100vw)] max-w-full flex-col bg-surface-1 shadow-xl transition-transform duration-300 ease-in-out", r.side === "right" ? "ml-auto" : "mr-auto", r.class)), b = l(), S = h(() => c(b.value));
|
|
3789
|
+
function C() {
|
|
3790
|
+
a.value = !1, i("openChange", !1), i("close");
|
|
3791
|
+
}
|
|
3792
|
+
function w() {
|
|
3793
|
+
r.closeOnOverlay && C();
|
|
3794
|
+
}
|
|
3795
|
+
function T(e) {
|
|
3796
|
+
e.key === "Escape" && r.closeOnEsc && a.value && C();
|
|
3797
|
+
}
|
|
3798
|
+
return G(a, (e) => {
|
|
3799
|
+
e && i("openChange", !0);
|
|
3800
|
+
}, { immediate: !0 }), (e, n) => (j(), g(p, { to: "body" }, [a.value ? (j(), v("div", E({
|
|
3801
|
+
key: 0,
|
|
3802
|
+
ref_key: "dialogRef",
|
|
3803
|
+
ref: u
|
|
3804
|
+
}, S.value, {
|
|
3805
|
+
class: "fixed inset-0 z-50 flex",
|
|
3806
|
+
role: "dialog",
|
|
3807
|
+
"aria-modal": "true",
|
|
3808
|
+
"aria-labelledby": t.title ? B(d) : void 0,
|
|
3809
|
+
"aria-label": t.title ? void 0 : "侧边面板",
|
|
3810
|
+
tabindex: "-1",
|
|
3811
|
+
onKeydown: n[1] || (n[1] = (...e) => B(f) && B(f)(...e)),
|
|
3812
|
+
"data-ug": "sheet",
|
|
3813
|
+
"data-state": "open",
|
|
3814
|
+
"data-variant": t.side,
|
|
3815
|
+
"data-size": "md"
|
|
3816
|
+
}), [y("div", {
|
|
3817
|
+
"data-ug-slot": "overlay",
|
|
3818
|
+
class: "absolute inset-0 bg-overlay transition-opacity",
|
|
3819
|
+
"aria-hidden": "true",
|
|
3820
|
+
onClick: w
|
|
3821
|
+
}), y("div", {
|
|
3822
|
+
"data-ug-slot": "panel",
|
|
3823
|
+
class: O(m.value),
|
|
3824
|
+
onClick: n[0] || (n[0] = K(() => {}, ["stop"]))
|
|
3825
|
+
}, [
|
|
3826
|
+
t.title || e.$slots.header || t.showCloseButton ? (j(), v("div", ii, [I(e.$slots, "header", {}, () => [t.title ? (j(), v("h2", {
|
|
3827
|
+
key: 0,
|
|
3828
|
+
id: B(d),
|
|
3829
|
+
class: "text-base font-semibold text-text-primary",
|
|
3830
|
+
"data-ug-slot": "title"
|
|
3831
|
+
}, R(t.title), 9, ai)) : (j(), v("div", oi))]), t.showCloseButton ? (j(), v("button", {
|
|
3832
|
+
key: 0,
|
|
3833
|
+
type: "button",
|
|
3834
|
+
class: "rounded-[var(--radius-control)] p-[calc(var(--content-gap)*0.25)] text-text-tertiary transition-colors hover:bg-surface-3 hover:text-text-secondary",
|
|
3835
|
+
"aria-label": "关闭",
|
|
3836
|
+
"data-ug-slot": "close",
|
|
3837
|
+
onClick: C
|
|
3838
|
+
}, [x(B(ge), { size: 18 })])) : _("", !0)])) : _("", !0),
|
|
3839
|
+
y("div", si, [I(e.$slots, "default")]),
|
|
3840
|
+
e.$slots.footer ? (j(), v("div", ci, [I(e.$slots, "footer")])) : _("", !0)
|
|
3841
|
+
], 2)], 16, ri)) : _("", !0)]));
|
|
3842
|
+
}
|
|
3843
|
+
}), ui = [
|
|
3844
|
+
"role",
|
|
3845
|
+
"aria-labelledby",
|
|
3846
|
+
"aria-describedby"
|
|
3847
|
+
], di = {
|
|
3848
|
+
key: 0,
|
|
3849
|
+
class: "flex items-center justify-center bg-surface-2 [height:calc(var(--control-height-lg)+var(--content-gap))] [width:calc(var(--control-height-lg)+var(--content-gap))] [border-radius:calc(var(--radius-overlay)*999)]",
|
|
3850
|
+
"data-ug-slot": "icon"
|
|
3851
|
+
}, fi = {
|
|
3852
|
+
class: "flex flex-col gap-1",
|
|
3853
|
+
"data-ug-slot": "content"
|
|
3854
|
+
}, pi = {
|
|
3855
|
+
key: 0,
|
|
3856
|
+
class: "mt-1",
|
|
3857
|
+
"data-ug-slot": "action"
|
|
3858
|
+
}, mi = /* @__PURE__ */ S({
|
|
3859
|
+
name: "UEmptyState",
|
|
3860
|
+
inheritAttrs: !1,
|
|
3861
|
+
__name: "empty-state",
|
|
3862
|
+
props: {
|
|
3863
|
+
icon: { default: void 0 },
|
|
3864
|
+
title: { default: void 0 },
|
|
3865
|
+
description: { default: void 0 },
|
|
3866
|
+
class: { default: void 0 }
|
|
3867
|
+
},
|
|
3868
|
+
setup(t) {
|
|
3869
|
+
let n = t, r = h(() => e("flex flex-col items-center justify-center gap-3 py-[calc(var(--section-gap)*2)] text-center", n.class)), i = te(), a = V(), o = `${a}-title`, s = `${a}-description`, c = h(() => typeof i.role == "string" ? i.role : "status"), l = h(() => {
|
|
3870
|
+
if (typeof i["aria-labelledby"] == "string") return i["aria-labelledby"];
|
|
3871
|
+
if (!i["aria-label"]) return o;
|
|
3872
|
+
}), u = h(() => typeof i["aria-describedby"] == "string" ? i["aria-describedby"] : s);
|
|
3873
|
+
return (e, n) => (j(), v("div", E(B(i), {
|
|
3874
|
+
class: r.value,
|
|
3875
|
+
role: c.value,
|
|
3876
|
+
"aria-labelledby": e.$slots.title || t.title ? l.value : void 0,
|
|
3877
|
+
"aria-describedby": e.$slots.description || t.description ? u.value : void 0,
|
|
3878
|
+
"data-ug": "empty-state",
|
|
3879
|
+
"data-state": "default",
|
|
3880
|
+
"data-variant": "default",
|
|
3881
|
+
"data-size": "md"
|
|
3882
|
+
}), [
|
|
3883
|
+
I(e.$slots, "icon", {}, () => [t.icon ? (j(), v("div", di, [(j(), g(L(t.icon), {
|
|
3884
|
+
size: 28,
|
|
3885
|
+
class: "text-text-tertiary"
|
|
3886
|
+
}))])) : _("", !0)]),
|
|
3887
|
+
y("div", fi, [e.$slots.title || t.title ? (j(), v("p", {
|
|
3888
|
+
key: 0,
|
|
3889
|
+
id: o,
|
|
3890
|
+
class: "text-base font-semibold text-text-primary",
|
|
3891
|
+
"data-ug-slot": "title"
|
|
3892
|
+
}, [I(e.$slots, "title", {}, () => [b(R(t.title), 1)])])) : _("", !0), e.$slots.description || t.description ? (j(), v("p", {
|
|
3893
|
+
key: 1,
|
|
3894
|
+
id: s,
|
|
3895
|
+
class: "max-w-xs text-sm text-text-secondary",
|
|
3896
|
+
"data-ug-slot": "description"
|
|
3897
|
+
}, [I(e.$slots, "description", {}, () => [b(R(t.description), 1)])])) : _("", !0)]),
|
|
3898
|
+
e.$slots.action ? (j(), v("div", pi, [I(e.$slots, "action")])) : _("", !0)
|
|
3899
|
+
], 16, ui));
|
|
3900
|
+
}
|
|
3901
|
+
}), hi = ["disabled", "data-state"], gi = {
|
|
3902
|
+
key: 0,
|
|
3903
|
+
class: "inline-flex min-w-[calc(var(--control-height-sm)*0.75)] shrink-0 items-center justify-center select-none text-text-tertiary [height:var(--control-height-sm)]",
|
|
3904
|
+
"data-ug-slot": "ellipsis"
|
|
3905
|
+
}, _i = [
|
|
3906
|
+
"aria-label",
|
|
3907
|
+
"aria-current",
|
|
3908
|
+
"data-state",
|
|
3909
|
+
"onClick"
|
|
3910
|
+
], vi = ["disabled", "data-state"], yi = /* @__PURE__ */ S({
|
|
3911
|
+
name: "UPagination",
|
|
3912
|
+
__name: "pagination",
|
|
3913
|
+
props: /*@__PURE__*/ T({
|
|
3914
|
+
totalPages: {},
|
|
3915
|
+
class: { default: void 0 }
|
|
3916
|
+
}, {
|
|
3917
|
+
page: { default: 1 },
|
|
3918
|
+
pageModifiers: {}
|
|
3919
|
+
}),
|
|
3920
|
+
emits: /*@__PURE__*/ T(["pageChange"], ["update:page"]),
|
|
3921
|
+
setup(t, { emit: n }) {
|
|
3922
|
+
let r = t, i = n, a = H(t, "page"), o = "inline-flex min-w-[var(--control-height-sm)] shrink-0 items-center justify-center px-[var(--control-padding-x-sm)] text-sm font-medium transition-colors [height:var(--control-height-sm)] [border-radius:var(--radius-control)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-offset-2 focus-visible:ring-offset-surface-0 disabled:pointer-events-none disabled:opacity-40", s = "border border-border-strong bg-surface-1 text-text-primary hover:border-primary/60 hover:bg-surface-2", c = h(() => e("flex max-w-full flex-wrap items-center gap-1", r.class)), l = h(() => Math.max(0, Math.floor(r.totalPages))), u = h(() => l.value === 0 ? 0 : Math.min(Math.max(Math.floor(a.value), 1), l.value)), d = h(() => {
|
|
3923
|
+
let e = u.value, t = l.value;
|
|
3924
|
+
return t <= 5 ? Array.from({ length: t }, (e, t) => t + 1) : e <= 3 ? [
|
|
3925
|
+
1,
|
|
3926
|
+
2,
|
|
3927
|
+
3,
|
|
3928
|
+
"...",
|
|
3929
|
+
t
|
|
3930
|
+
] : e >= t - 2 ? [
|
|
3931
|
+
1,
|
|
3932
|
+
"...",
|
|
3933
|
+
t - 2,
|
|
3934
|
+
t - 1,
|
|
3935
|
+
t
|
|
3936
|
+
] : [
|
|
3937
|
+
1,
|
|
3938
|
+
"...",
|
|
3939
|
+
e,
|
|
3940
|
+
"...",
|
|
3941
|
+
t
|
|
3942
|
+
];
|
|
3943
|
+
});
|
|
3944
|
+
function p(e) {
|
|
3945
|
+
if (l.value === 0) return;
|
|
3946
|
+
let t = Math.min(Math.max(e, 1), l.value);
|
|
3947
|
+
t !== a.value && (a.value = t, i("pageChange", t));
|
|
3948
|
+
}
|
|
3949
|
+
return (t, n) => (j(), v("nav", {
|
|
3950
|
+
"aria-label": "分页导航",
|
|
3951
|
+
class: O(c.value),
|
|
3952
|
+
"data-ug": "pagination",
|
|
3953
|
+
"data-state": "default",
|
|
3954
|
+
"data-variant": "default",
|
|
3955
|
+
"data-size": "md"
|
|
3956
|
+
}, [
|
|
3957
|
+
y("button", {
|
|
3958
|
+
type: "button",
|
|
3959
|
+
class: O(B(e)(o, s)),
|
|
3960
|
+
disabled: u.value <= 1,
|
|
3961
|
+
"aria-label": "上一页",
|
|
3962
|
+
"data-ug-slot": "prev",
|
|
3963
|
+
"data-state": u.value <= 1 ? "disabled" : "default",
|
|
3964
|
+
onClick: n[0] || (n[0] = (e) => p(u.value - 1))
|
|
3965
|
+
}, [x(B(oe), { size: 16 })], 10, hi),
|
|
3966
|
+
(j(!0), v(f, null, F(d.value, (t, n) => (j(), v(f, { key: `${t}-${n}` }, [t === "..." ? (j(), v("span", gi, "…")) : (j(), v("button", {
|
|
3967
|
+
key: 1,
|
|
3968
|
+
type: "button",
|
|
3969
|
+
class: O(B(e)(o, t === u.value ? "bg-primary text-primary-fg shadow-sm" : s)),
|
|
3970
|
+
"aria-label": `第 ${t} 页`,
|
|
3971
|
+
"aria-current": t === u.value ? "page" : void 0,
|
|
3972
|
+
"data-ug-slot": "item",
|
|
3973
|
+
"data-state": t === u.value ? "active" : "default",
|
|
3974
|
+
onClick: (e) => p(t)
|
|
3975
|
+
}, R(t), 11, _i))], 64))), 128)),
|
|
3976
|
+
y("button", {
|
|
3977
|
+
type: "button",
|
|
3978
|
+
class: O(B(e)(o, s)),
|
|
3979
|
+
disabled: l.value === 0 || u.value >= l.value,
|
|
3980
|
+
"aria-label": "下一页",
|
|
3981
|
+
"data-ug-slot": "next",
|
|
3982
|
+
"data-state": l.value === 0 || u.value >= l.value ? "disabled" : "default",
|
|
3983
|
+
onClick: n[1] || (n[1] = (e) => p(u.value + 1))
|
|
3984
|
+
}, [x(B(se), { size: 16 })], 10, vi)
|
|
3985
|
+
], 2));
|
|
3986
|
+
}
|
|
3987
|
+
}), bi = [
|
|
3988
|
+
"data-state",
|
|
3989
|
+
"data-variant",
|
|
3990
|
+
"data-size"
|
|
3991
|
+
], xi = ["for"], Si = [
|
|
3992
|
+
"id",
|
|
3993
|
+
"value",
|
|
3994
|
+
"multiple",
|
|
3995
|
+
"disabled",
|
|
3996
|
+
"name",
|
|
3997
|
+
"required"
|
|
3998
|
+
], Ci = {
|
|
3999
|
+
key: 0,
|
|
4000
|
+
value: ""
|
|
4001
|
+
}, wi = [
|
|
4002
|
+
"data-ug-key",
|
|
4003
|
+
"value",
|
|
4004
|
+
"disabled"
|
|
4005
|
+
], Ti = {
|
|
4006
|
+
class: "relative min-w-0",
|
|
4007
|
+
"data-ug-slot": "control"
|
|
4008
|
+
}, Ei = [
|
|
4009
|
+
"id",
|
|
4010
|
+
"disabled",
|
|
4011
|
+
"aria-describedby",
|
|
4012
|
+
"aria-invalid",
|
|
4013
|
+
"aria-required",
|
|
4014
|
+
"aria-expanded",
|
|
4015
|
+
"aria-controls",
|
|
4016
|
+
"aria-activedescendant",
|
|
4017
|
+
"data-state",
|
|
4018
|
+
"data-variant",
|
|
4019
|
+
"data-size"
|
|
4020
|
+
], Di = ["title"], Oi = {
|
|
4021
|
+
key: 1,
|
|
4022
|
+
"aria-hidden": "true",
|
|
4023
|
+
class: "size-4 shrink-0"
|
|
4024
|
+
}, ki = [
|
|
4025
|
+
"id",
|
|
4026
|
+
"aria-multiselectable",
|
|
4027
|
+
"data-side",
|
|
4028
|
+
"data-variant",
|
|
4029
|
+
"data-size"
|
|
4030
|
+
], Ai = {
|
|
4031
|
+
key: 0,
|
|
4032
|
+
class: "mb-1 flex items-center gap-2 rounded-[var(--radius-control)] border border-border-base px-[var(--control-padding-x-sm)]",
|
|
4033
|
+
"data-ug-slot": "filter"
|
|
4034
|
+
}, ji = [
|
|
4035
|
+
"aria-controls",
|
|
4036
|
+
"aria-expanded",
|
|
4037
|
+
"aria-activedescendant"
|
|
4038
|
+
], Mi = {
|
|
4039
|
+
key: 1,
|
|
4040
|
+
class: "px-[var(--control-padding-x-sm)] py-[var(--content-gap)] text-center text-sm text-text-tertiary",
|
|
4041
|
+
"data-ug-slot": "loading"
|
|
4042
|
+
}, Ni = {
|
|
4043
|
+
key: 2,
|
|
4044
|
+
class: "px-[var(--control-padding-x-sm)] py-[var(--content-gap)] text-center text-sm text-text-tertiary",
|
|
4045
|
+
"data-ug-slot": "empty"
|
|
4046
|
+
}, Pi = {
|
|
4047
|
+
key: 0,
|
|
4048
|
+
class: "px-[var(--control-padding-x-sm)] py-[calc(var(--content-gap)*0.375)] text-xs font-medium text-text-tertiary",
|
|
4049
|
+
"data-ug-slot": "group"
|
|
4050
|
+
}, Fi = [
|
|
4051
|
+
"id",
|
|
4052
|
+
"disabled",
|
|
4053
|
+
"aria-disabled",
|
|
4054
|
+
"aria-selected",
|
|
4055
|
+
"data-state",
|
|
4056
|
+
"onClick",
|
|
4057
|
+
"onPointerenter"
|
|
4058
|
+
], Ii = { class: "min-w-0 flex-1 truncate" }, Li = ["id"], Ri = ["id"], zi = /* @__PURE__ */ S({
|
|
4059
|
+
name: "USelect",
|
|
4060
|
+
inheritAttrs: !1,
|
|
4061
|
+
__name: "select",
|
|
4062
|
+
props: /*@__PURE__*/ T({
|
|
4063
|
+
label: { default: void 0 },
|
|
4064
|
+
error: { default: void 0 },
|
|
4065
|
+
helperText: { default: void 0 },
|
|
4066
|
+
options: {},
|
|
4067
|
+
placeholder: { default: "请选择" },
|
|
4068
|
+
id: { default: void 0 },
|
|
4069
|
+
disabled: {
|
|
4070
|
+
type: Boolean,
|
|
4071
|
+
default: void 0
|
|
4072
|
+
},
|
|
4073
|
+
size: { default: void 0 },
|
|
4074
|
+
name: { default: void 0 },
|
|
4075
|
+
required: {
|
|
4076
|
+
type: Boolean,
|
|
4077
|
+
default: !1
|
|
4078
|
+
},
|
|
4079
|
+
defaultValue: { default: void 0 },
|
|
4080
|
+
multiple: {
|
|
4081
|
+
type: Boolean,
|
|
4082
|
+
default: !1
|
|
4083
|
+
},
|
|
4084
|
+
multipleLimit: { default: 0 },
|
|
4085
|
+
clearable: {
|
|
4086
|
+
type: Boolean,
|
|
4087
|
+
default: !1
|
|
4088
|
+
},
|
|
4089
|
+
filterable: {
|
|
4090
|
+
type: Boolean,
|
|
4091
|
+
default: !1
|
|
4092
|
+
},
|
|
4093
|
+
filterMethod: {
|
|
4094
|
+
type: Function,
|
|
4095
|
+
default: void 0
|
|
4096
|
+
},
|
|
4097
|
+
remote: {
|
|
4098
|
+
type: Boolean,
|
|
4099
|
+
default: !1
|
|
4100
|
+
},
|
|
4101
|
+
remoteMethod: {
|
|
4102
|
+
type: Function,
|
|
4103
|
+
default: void 0
|
|
4104
|
+
},
|
|
4105
|
+
remoteDebounce: { default: 300 },
|
|
4106
|
+
loading: {
|
|
4107
|
+
type: Boolean,
|
|
4108
|
+
default: !1
|
|
4109
|
+
},
|
|
4110
|
+
loadingText: { default: "加载中" },
|
|
4111
|
+
reserveKeyword: {
|
|
4112
|
+
type: Boolean,
|
|
4113
|
+
default: !1
|
|
4114
|
+
},
|
|
4115
|
+
allowCreate: {
|
|
4116
|
+
type: Boolean,
|
|
4117
|
+
default: !1
|
|
4118
|
+
},
|
|
4119
|
+
defaultFirstOption: {
|
|
4120
|
+
type: Boolean,
|
|
4121
|
+
default: !1
|
|
4122
|
+
},
|
|
4123
|
+
collapseTags: {
|
|
4124
|
+
type: Boolean,
|
|
4125
|
+
default: !1
|
|
4126
|
+
},
|
|
4127
|
+
maxCollapseTags: { default: 1 },
|
|
4128
|
+
collapseTagsTooltip: {
|
|
4129
|
+
type: Boolean,
|
|
4130
|
+
default: !1
|
|
4131
|
+
},
|
|
4132
|
+
noDataText: { default: "暂无选项" },
|
|
4133
|
+
noMatchText: { default: "没有匹配项" },
|
|
4134
|
+
teleported: {
|
|
4135
|
+
type: Boolean,
|
|
4136
|
+
default: !0
|
|
4137
|
+
},
|
|
4138
|
+
appendTo: { default: "body" },
|
|
4139
|
+
class: { default: void 0 }
|
|
4140
|
+
}, {
|
|
4141
|
+
modelValue: {},
|
|
4142
|
+
modelModifiers: {}
|
|
4143
|
+
}),
|
|
4144
|
+
emits: /*@__PURE__*/ T([
|
|
4145
|
+
"blur",
|
|
4146
|
+
"focus",
|
|
4147
|
+
"change",
|
|
4148
|
+
"valueChange",
|
|
4149
|
+
"openChange",
|
|
4150
|
+
"clear"
|
|
4151
|
+
], ["update:modelValue"]),
|
|
4152
|
+
setup(n, { expose: a, emit: o }) {
|
|
4153
|
+
let s = n, u = o, d = H(n, "modelValue"), m = te(), b = i(), S = l(), C = h(() => c(S.value)), w = V(), T = h(() => s.id ?? w), k = h(() => `${T.value}-listbox`), M = h(() => `${T.value}-message`), N = h(() => r(s.disabled, b.value.disabled)), I = h(() => t(s.size, b.value.size)), L = P(null), z = P(null), U = P(null), ne = P(null), K = P(null), q = P(!1), J = P(-1), Y = P(""), oe = P(!1), se = P([]), ce = P({
|
|
4154
|
+
top: 0,
|
|
4155
|
+
left: 0,
|
|
4156
|
+
width: 0,
|
|
4157
|
+
side: "bottom"
|
|
4158
|
+
}), le = "", de, fe, me = null, X = h(() => {
|
|
4159
|
+
let e = new Set(s.options.map((e) => Q(e.value)));
|
|
4160
|
+
return [...s.options, ...se.value.filter((t) => !e.has(Q(t.value)))];
|
|
4161
|
+
}), he = h(() => {
|
|
4162
|
+
let e = d.value;
|
|
4163
|
+
return _e(e);
|
|
4164
|
+
}), Z = h(() => new Set(he.value)), $ = h(() => X.value.filter((e) => Z.value.has(Q(e.value)))), ve = h(() => {
|
|
4165
|
+
let e = Y.value.trim().toLocaleLowerCase();
|
|
4166
|
+
return s.remote || !s.filterable || !e ? X.value : X.value.filter((t) => s.filterMethod ? s.filterMethod(Y.value, t) : t.label.toLocaleLowerCase().includes(e));
|
|
4167
|
+
}), ye = h(() => {
|
|
4168
|
+
let e = Y.value.trim();
|
|
4169
|
+
if (!(!s.allowCreate || !s.filterable || !e)) return X.value.some((t) => t.label.toLocaleLowerCase() === e.toLocaleLowerCase() || Q(t.value) === Q(e)) ? void 0 : {
|
|
4170
|
+
label: e,
|
|
4171
|
+
value: e
|
|
4172
|
+
};
|
|
4173
|
+
}), be = h(() => ye.value ? [ye.value, ...ve.value] : ve.value), xe = h(() => Math.max(1, Math.trunc(s.maxCollapseTags) || 1)), Se = h(() => s.multiple && s.collapseTags ? $.value.slice(0, xe.value) : $.value), Ce = h(() => $.value.length - Se.value.length), we = h(() => $.value.slice(xe.value).map((e) => e.label).join("、")), Te = h(() => s.multiple ? Se.value.map((e) => e.label).join("、") : $.value[0]?.label), Ee = h(() => [
|
|
4174
|
+
q.value ? "open" : void 0,
|
|
4175
|
+
N.value ? "disabled" : void 0,
|
|
4176
|
+
s.error ? "invalid" : void 0
|
|
4177
|
+
].filter(Boolean).join(" ") || "default"), De = h(() => e("flex w-full min-w-0 items-center gap-2 rounded-[var(--radius-control)] border bg-surface-1 py-0 text-left leading-5 text-text-primary shadow-sm transition-colors", {
|
|
4178
|
+
"min-h-[var(--control-height-sm)] px-[var(--control-padding-x-sm)] text-xs": I.value === "sm",
|
|
4179
|
+
"min-h-[var(--control-height-md)] px-[var(--control-padding-x-md)] text-sm": I.value === "default",
|
|
4180
|
+
"min-h-[var(--control-height-lg)] px-[var(--control-padding-x-lg)] text-base": I.value === "lg"
|
|
4181
|
+
}, "hover:border-primary/60 focus-visible:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/25", "disabled:cursor-not-allowed disabled:bg-surface-2 disabled:text-text-tertiary disabled:opacity-70", s.error ? "border-danger focus-visible:ring-danger/25" : "border-border-strong", s.class)), Oe = h(() => {
|
|
4182
|
+
let e = { ...m };
|
|
4183
|
+
return delete e.class, delete e.id, e;
|
|
4184
|
+
}), ke = h(() => e("z-[70] max-h-[calc(var(--control-height-md)*7)] overflow-auto rounded-[var(--radius-panel)] border border-border-strong bg-surface-1 p-[calc(var(--content-gap)*0.25)] shadow-xl", s.teleported ? "fixed" : "absolute left-0 right-0 top-full mt-[calc(var(--content-gap)*0.25)]")), Ae = h(() => s.teleported ? {
|
|
4185
|
+
top: `${ce.value.top}px`,
|
|
4186
|
+
left: `${ce.value.left}px`,
|
|
4187
|
+
width: `${ce.value.width}px`
|
|
4188
|
+
} : void 0);
|
|
4189
|
+
function je(e, t) {
|
|
4190
|
+
let n = be.value;
|
|
4191
|
+
if (n.length === 0) return -1;
|
|
4192
|
+
for (let r = 0; r < n.length; r += 1) {
|
|
4193
|
+
let i = (e + t * r + n.length) % n.length;
|
|
4194
|
+
if (!n[i]?.disabled) return i;
|
|
4195
|
+
}
|
|
4196
|
+
return -1;
|
|
4197
|
+
}
|
|
4198
|
+
function Me(e) {
|
|
4199
|
+
if (N.value && e || q.value === e) return;
|
|
4200
|
+
if (q.value = e, u("openChange", e), !e) {
|
|
4201
|
+
s.multiple && s.reserveKeyword || (Y.value = "");
|
|
4202
|
+
return;
|
|
4203
|
+
}
|
|
4204
|
+
let t = be.value.findIndex((e) => Z.value.has(Q(e.value)) && !e.disabled), n = be.value.findIndex((e) => !e.disabled);
|
|
4205
|
+
J.value = t >= 0 ? t : n, s.filterable && D(() => ne.value?.focus());
|
|
4206
|
+
}
|
|
4207
|
+
function Ne(e) {
|
|
4208
|
+
z.value && (Array.from(z.value.options).forEach((t) => {
|
|
4209
|
+
t.selected = e.includes(t.dataset.ugKey ?? "");
|
|
4210
|
+
}), z.value.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
4211
|
+
}
|
|
4212
|
+
function Pe(e, t = X.value) {
|
|
4213
|
+
let n = t.filter((t) => e.includes(Q(t.value))), r = s.multiple ? n.map((e) => e.value) : n[0]?.value;
|
|
4214
|
+
d.value = r, u("valueChange", r), Ne(e);
|
|
4215
|
+
}
|
|
4216
|
+
function Fe(e) {
|
|
4217
|
+
if (N.value || e.disabled) return;
|
|
4218
|
+
let t = Q(e.value), n = !X.value.some((e) => Q(e.value) === t), r = n ? [...X.value, e] : X.value;
|
|
4219
|
+
if (n && se.value.push(e), s.multiple) {
|
|
4220
|
+
let e = Z.value.has(t);
|
|
4221
|
+
if (!e && s.multipleLimit > 0 && he.value.length >= s.multipleLimit) return;
|
|
4222
|
+
Pe(e ? he.value.filter((e) => e !== t) : [...he.value, t], r), s.reserveKeyword || (Y.value = "");
|
|
4223
|
+
return;
|
|
4224
|
+
}
|
|
4225
|
+
Pe([t], r), Me(!1), U.value?.focus();
|
|
4226
|
+
}
|
|
4227
|
+
function Ie(e) {
|
|
4228
|
+
e?.stopPropagation(), !(N.value || he.value.length === 0) && (Pe([]), u("clear"), Y.value = "", D(() => U.value?.focus()));
|
|
4229
|
+
}
|
|
4230
|
+
function Le(e) {
|
|
4231
|
+
if (!e.isComposing) {
|
|
4232
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
4233
|
+
if (e.preventDefault(), !q.value) {
|
|
4234
|
+
Me(!0);
|
|
4235
|
+
return;
|
|
4236
|
+
}
|
|
4237
|
+
let t = e.key === "ArrowDown" ? 1 : -1;
|
|
4238
|
+
J.value = je(J.value + t, t);
|
|
4239
|
+
return;
|
|
4240
|
+
}
|
|
4241
|
+
if (e.key === "Home" || e.key === "End") {
|
|
4242
|
+
e.preventDefault(), q.value || Me(!0), J.value = e.key === "Home" ? je(0, 1) : je(be.value.length - 1, -1);
|
|
4243
|
+
return;
|
|
4244
|
+
}
|
|
4245
|
+
if (e.key === "Enter" || !s.filterable && e.key === " ") {
|
|
4246
|
+
if (e.preventDefault(), !q.value) {
|
|
4247
|
+
Me(!0);
|
|
4248
|
+
return;
|
|
4249
|
+
}
|
|
4250
|
+
let t = be.value[J.value];
|
|
4251
|
+
t && Fe(t);
|
|
4252
|
+
return;
|
|
4253
|
+
}
|
|
4254
|
+
if (e.key === "Escape") {
|
|
4255
|
+
e.preventDefault(), Me(!1), U.value?.focus();
|
|
4256
|
+
return;
|
|
4257
|
+
}
|
|
4258
|
+
if (e.key === "Backspace" && s.multiple && Y.value === "" && he.value.length > 0) {
|
|
4259
|
+
e.preventDefault(), Pe(he.value.slice(0, -1));
|
|
4260
|
+
return;
|
|
4261
|
+
}
|
|
4262
|
+
if (!s.filterable && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
|
|
4263
|
+
le += e.key.toLocaleLowerCase(), de && clearTimeout(de), de = setTimeout(() => {
|
|
4264
|
+
le = "", de = void 0;
|
|
4265
|
+
}, 500);
|
|
4266
|
+
let t = be.value.findIndex((e) => !e.disabled && e.label.toLocaleLowerCase().startsWith(le));
|
|
4267
|
+
t >= 0 && (J.value = t, Me(!0));
|
|
4268
|
+
}
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
function Re(e) {
|
|
4272
|
+
u("change", e);
|
|
4273
|
+
}
|
|
4274
|
+
function ze(e) {
|
|
4275
|
+
let t = e.target;
|
|
4276
|
+
!L.value?.contains(t) && !K.value?.contains(t) && Me(!1);
|
|
4277
|
+
}
|
|
4278
|
+
function Be(e) {
|
|
4279
|
+
let t = e.relatedTarget;
|
|
4280
|
+
!L.value?.contains(t) && !K.value?.contains(t) && Me(!1);
|
|
4281
|
+
}
|
|
4282
|
+
function Ve() {
|
|
4283
|
+
if (!s.teleported || !U.value || !K.value) return;
|
|
4284
|
+
let e = U.value.getBoundingClientRect(), t = K.value.offsetHeight, n = window.innerHeight - e.bottom - 8, r = e.top - 8, i = n < t + 4 && r > n ? "top" : "bottom", a = Math.max(8, window.innerWidth - e.width - 8);
|
|
4285
|
+
ce.value = {
|
|
4286
|
+
top: i === "bottom" ? e.bottom + 4 : Math.max(8, e.top - t - 4),
|
|
4287
|
+
left: Math.min(Math.max(8, e.left), a),
|
|
4288
|
+
width: Math.max(0, e.width),
|
|
4289
|
+
side: i
|
|
4290
|
+
};
|
|
4291
|
+
}
|
|
4292
|
+
function He() {
|
|
4293
|
+
!s.teleported || typeof window > "u" || (window.addEventListener("resize", Ve), window.addEventListener("scroll", Ve, !0));
|
|
4294
|
+
}
|
|
4295
|
+
function Ue() {
|
|
4296
|
+
typeof window > "u" || (window.removeEventListener("resize", Ve), window.removeEventListener("scroll", Ve, !0));
|
|
4297
|
+
}
|
|
4298
|
+
function We() {
|
|
4299
|
+
U.value?.focus();
|
|
4300
|
+
}
|
|
4301
|
+
function Ge() {
|
|
4302
|
+
U.value?.blur();
|
|
4303
|
+
}
|
|
4304
|
+
function Ke() {
|
|
4305
|
+
Me(!0);
|
|
4306
|
+
}
|
|
4307
|
+
function qe() {
|
|
4308
|
+
Ie();
|
|
4309
|
+
}
|
|
4310
|
+
function Je() {
|
|
4311
|
+
d.value = s.defaultValue ?? (s.multiple ? [] : void 0), se.value = [], q.value = !1, Y.value = "";
|
|
4312
|
+
}
|
|
4313
|
+
function Ye() {
|
|
4314
|
+
let e = z.value?.form ?? null;
|
|
4315
|
+
me !== e && (me?.removeEventListener("reset", Je), me = e, me?.addEventListener("reset", Je));
|
|
4316
|
+
}
|
|
4317
|
+
return G(q, (e) => {
|
|
4318
|
+
typeof document > "u" || (document.removeEventListener("pointerdown", ze), Ue(), e && (document.addEventListener("pointerdown", ze), D(() => {
|
|
4319
|
+
Ve(), He();
|
|
4320
|
+
})));
|
|
4321
|
+
}), G([Y, oe], ([e, t]) => {
|
|
4322
|
+
fe && (clearTimeout(fe), fe = void 0), !(!s.remote || !s.remoteMethod || t) && (fe = setTimeout(() => {
|
|
4323
|
+
Promise.resolve(s.remoteMethod?.(e)).catch(() => void 0), fe = void 0;
|
|
4324
|
+
}, Math.max(0, s.remoteDebounce)));
|
|
4325
|
+
}), G([Y, be], ([e]) => {
|
|
4326
|
+
!q.value || !s.filterable || !e || (J.value = s.defaultFirstOption ? je(0, 1) : -1);
|
|
4327
|
+
}), ee(() => void D(Ye)), G(() => m.form, () => void D(Ye)), A(() => {
|
|
4328
|
+
de && clearTimeout(de), fe && clearTimeout(fe), typeof document < "u" && document.removeEventListener("pointerdown", ze), Ue(), me?.removeEventListener("reset", Je);
|
|
4329
|
+
}), a({
|
|
4330
|
+
focus: We,
|
|
4331
|
+
blur: Ge,
|
|
4332
|
+
select: Ke,
|
|
4333
|
+
clear: qe,
|
|
4334
|
+
open: () => Me(!0),
|
|
4335
|
+
close: () => Me(!1),
|
|
4336
|
+
el: z
|
|
4337
|
+
}), (t, r) => (j(), v("div", {
|
|
4338
|
+
ref_key: "rootRef",
|
|
4339
|
+
ref: L,
|
|
4340
|
+
class: "relative flex min-w-0 flex-col gap-1.5",
|
|
4341
|
+
"data-ug": "select",
|
|
4342
|
+
"data-state": Ee.value,
|
|
4343
|
+
"data-variant": n.multiple ? "multiple" : "single",
|
|
4344
|
+
"data-size": I.value,
|
|
4345
|
+
onFocusout: Be
|
|
4346
|
+
}, [
|
|
4347
|
+
n.label ? (j(), v("label", {
|
|
4348
|
+
key: 0,
|
|
4349
|
+
for: T.value,
|
|
4350
|
+
class: "text-sm font-medium text-text-primary",
|
|
4351
|
+
"data-ug-slot": "label"
|
|
4352
|
+
}, R(n.label), 9, xi)) : _("", !0),
|
|
4353
|
+
y("select", E({
|
|
4354
|
+
id: `${T.value}-native`,
|
|
4355
|
+
ref_key: "selectRef",
|
|
4356
|
+
ref: z,
|
|
4357
|
+
value: n.multiple ? $.value.map((e) => String(e.value)) : $.value[0] ? String($.value[0].value) : "",
|
|
4358
|
+
multiple: n.multiple,
|
|
4359
|
+
disabled: N.value,
|
|
4360
|
+
name: n.name,
|
|
4361
|
+
required: n.required,
|
|
4362
|
+
class: "sr-only",
|
|
4363
|
+
tabindex: "-1",
|
|
4364
|
+
"aria-hidden": "true",
|
|
4365
|
+
"data-ug-slot": "native"
|
|
4366
|
+
}, Oe.value, { onChange: Re }), [n.multiple ? _("", !0) : (j(), v("option", Ci, R(n.placeholder), 1)), (j(!0), v(f, null, F(X.value, (e) => (j(), v("option", {
|
|
4367
|
+
key: B(Q)(e.value),
|
|
4368
|
+
"data-ug-key": B(Q)(e.value),
|
|
4369
|
+
value: String(e.value),
|
|
4370
|
+
disabled: e.disabled
|
|
4371
|
+
}, R(e.label), 9, wi))), 128))], 16, Si),
|
|
4372
|
+
y("div", Ti, [y("button", {
|
|
4373
|
+
id: T.value,
|
|
4374
|
+
ref_key: "triggerRef",
|
|
4375
|
+
ref: U,
|
|
4376
|
+
type: "button",
|
|
4377
|
+
disabled: N.value,
|
|
4378
|
+
class: O(De.value),
|
|
4379
|
+
"aria-describedby": n.error || n.helperText ? M.value : void 0,
|
|
4380
|
+
"aria-invalid": n.error ? !0 : void 0,
|
|
4381
|
+
"aria-required": n.required || void 0,
|
|
4382
|
+
role: "combobox",
|
|
4383
|
+
"aria-haspopup": "listbox",
|
|
4384
|
+
"aria-expanded": q.value,
|
|
4385
|
+
"aria-controls": k.value,
|
|
4386
|
+
"aria-activedescendant": q.value && J.value >= 0 ? `${k.value}-option-${J.value}` : void 0,
|
|
4387
|
+
"data-ug-slot": "trigger",
|
|
4388
|
+
"data-state": Ee.value,
|
|
4389
|
+
"data-variant": n.multiple ? "multiple" : "single",
|
|
4390
|
+
"data-size": I.value,
|
|
4391
|
+
onClick: r[0] || (r[0] = (e) => Me(!q.value)),
|
|
4392
|
+
onKeydown: Le,
|
|
4393
|
+
onFocus: r[1] || (r[1] = (e) => u("focus", e)),
|
|
4394
|
+
onBlur: r[2] || (r[2] = (e) => u("blur", e))
|
|
4395
|
+
}, [
|
|
4396
|
+
y("span", {
|
|
4397
|
+
class: O(B(e)("min-w-0 flex-1 truncate", $.value.length === 0 && "text-text-tertiary")),
|
|
4398
|
+
"data-ug-slot": "value"
|
|
4399
|
+
}, R(Te.value || n.placeholder), 3),
|
|
4400
|
+
n.multiple && n.collapseTags && Ce.value > 0 ? (j(), v("span", {
|
|
4401
|
+
key: 0,
|
|
4402
|
+
class: "shrink-0 text-xs text-text-secondary",
|
|
4403
|
+
"data-ug-slot": "count",
|
|
4404
|
+
title: n.collapseTagsTooltip ? we.value : void 0
|
|
4405
|
+
}, " +" + R(Ce.value), 9, Di)) : _("", !0),
|
|
4406
|
+
n.clearable && $.value.length > 0 && !N.value && !n.loading ? (j(), v("span", Oi)) : n.loading ? (j(), g(B(ue), {
|
|
4407
|
+
key: 2,
|
|
4408
|
+
"aria-hidden": "true",
|
|
4409
|
+
class: "size-4 shrink-0 animate-spin text-text-tertiary motion-reduce:animate-none",
|
|
4410
|
+
"data-ug-slot": "loading"
|
|
4411
|
+
})) : (j(), g(B(ae), {
|
|
4412
|
+
key: 3,
|
|
4413
|
+
"aria-hidden": "true",
|
|
4414
|
+
class: O(B(e)("size-4 shrink-0 text-text-tertiary transition-transform", q.value && "rotate-180")),
|
|
4415
|
+
"data-ug-slot": "icon"
|
|
4416
|
+
}, null, 8, ["class"]))
|
|
4417
|
+
], 42, Ei), n.clearable && $.value.length > 0 && !N.value && !n.loading ? (j(), v("button", {
|
|
4418
|
+
key: 0,
|
|
4419
|
+
type: "button",
|
|
4420
|
+
"aria-label": "清空选择",
|
|
4421
|
+
class: "absolute right-[var(--control-padding-x-sm)] top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-[var(--radius-control)] text-text-tertiary hover:bg-surface-2 hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30",
|
|
4422
|
+
"data-ug-slot": "clear",
|
|
4423
|
+
onClick: Ie
|
|
4424
|
+
}, [x(B(ge), {
|
|
4425
|
+
"aria-hidden": "true",
|
|
4426
|
+
class: "size-4"
|
|
4427
|
+
})])) : _("", !0)]),
|
|
4428
|
+
(j(), g(p, {
|
|
4429
|
+
to: n.appendTo,
|
|
4430
|
+
disabled: !n.teleported
|
|
4431
|
+
}, [q.value ? (j(), v("div", E({
|
|
4432
|
+
key: 0,
|
|
4433
|
+
id: k.value,
|
|
4434
|
+
ref_key: "contentRef",
|
|
4435
|
+
ref: K,
|
|
4436
|
+
role: "listbox",
|
|
4437
|
+
"aria-multiselectable": n.multiple || void 0,
|
|
4438
|
+
class: ke.value,
|
|
4439
|
+
style: Ae.value
|
|
4440
|
+
}, C.value, {
|
|
4441
|
+
"data-ug-slot": "content",
|
|
4442
|
+
"data-state": "open",
|
|
4443
|
+
"data-side": ce.value.side,
|
|
4444
|
+
"data-variant": n.multiple ? "multiple" : "single",
|
|
4445
|
+
"data-size": I.value,
|
|
4446
|
+
onFocusout: Be
|
|
4447
|
+
}), [n.filterable ? (j(), v("label", Ai, [x(B(pe), {
|
|
4448
|
+
"aria-hidden": "true",
|
|
4449
|
+
class: "size-4 shrink-0 text-text-tertiary"
|
|
4450
|
+
}), re(y("input", {
|
|
4451
|
+
ref_key: "filterRef",
|
|
4452
|
+
ref: ne,
|
|
4453
|
+
"onUpdate:modelValue": r[3] || (r[3] = (e) => Y.value = e),
|
|
4454
|
+
placeholder: "筛选选项",
|
|
4455
|
+
role: "combobox",
|
|
4456
|
+
"aria-autocomplete": "list",
|
|
4457
|
+
"aria-controls": k.value,
|
|
4458
|
+
"aria-expanded": q.value,
|
|
4459
|
+
"aria-activedescendant": J.value >= 0 ? `${k.value}-option-${J.value}` : void 0,
|
|
4460
|
+
class: "h-[var(--control-height-sm)] min-w-0 flex-1 bg-transparent text-sm text-text-primary outline-none placeholder:text-text-tertiary",
|
|
4461
|
+
onKeydown: Le,
|
|
4462
|
+
onCompositionstart: r[4] || (r[4] = (e) => oe.value = !0),
|
|
4463
|
+
onCompositionend: r[5] || (r[5] = (e) => {
|
|
4464
|
+
oe.value = !1, Y.value = e.target.value;
|
|
4465
|
+
})
|
|
4466
|
+
}, null, 40, ji), [[W, Y.value]])])) : _("", !0), n.loading ? (j(), v("div", Mi, R(n.loadingText), 1)) : be.value.length === 0 ? (j(), v("div", Ni, R(X.value.length === 0 ? n.noDataText : n.noMatchText), 1)) : (j(!0), v(f, { key: 3 }, F(be.value, (t, r) => (j(), v(f, { key: B(Q)(t.value) }, [t.group && t.group !== be.value[r - 1]?.group ? (j(), v("div", Pi, R(t.group), 1)) : _("", !0), y("button", {
|
|
4467
|
+
id: `${k.value}-option-${r}`,
|
|
4468
|
+
type: "button",
|
|
4469
|
+
role: "option",
|
|
4470
|
+
tabindex: "-1",
|
|
4471
|
+
disabled: t.disabled || n.multiple && !Z.value.has(B(Q)(t.value)) && n.multipleLimit > 0 && he.value.length >= n.multipleLimit,
|
|
4472
|
+
"aria-disabled": t.disabled || n.multiple && !Z.value.has(B(Q)(t.value)) && n.multipleLimit > 0 && he.value.length >= n.multipleLimit || void 0,
|
|
4473
|
+
"aria-selected": Z.value.has(B(Q)(t.value)),
|
|
4474
|
+
"data-ug-slot": "item",
|
|
4475
|
+
"data-state": t.disabled || n.multiple && !Z.value.has(B(Q)(t.value)) && n.multipleLimit > 0 && he.value.length >= n.multipleLimit ? "disabled" : Z.value.has(B(Q)(t.value)) ? "selected" : "default",
|
|
4476
|
+
class: O(B(e)("flex w-full items-center gap-2 rounded-[var(--radius-control)] px-[var(--control-padding-x-sm)] py-[calc(var(--content-gap)*0.5)] text-left text-sm text-text-primary transition-colors hover:bg-surface-2", Z.value.has(B(Q)(t.value)) && "bg-primary-soft text-primary-soft-fg", J.value === r && !Z.value.has(B(Q)(t.value)) && "bg-surface-2", (t.disabled || n.multiple && !Z.value.has(B(Q)(t.value)) && n.multipleLimit > 0 && he.value.length >= n.multipleLimit) && "cursor-not-allowed opacity-50 hover:bg-transparent")),
|
|
4477
|
+
onClick: (e) => Fe(t),
|
|
4478
|
+
onPointerenter: (e) => !t.disabled && !(n.multiple && !Z.value.has(B(Q)(t.value)) && n.multipleLimit > 0 && he.value.length >= n.multipleLimit) && (J.value = r)
|
|
4479
|
+
}, [y("span", Ii, R(t.label), 1), Z.value.has(B(Q)(t.value)) ? (j(), g(B(ie), {
|
|
4480
|
+
key: 0,
|
|
4481
|
+
"aria-hidden": "true",
|
|
4482
|
+
class: "size-4 shrink-0",
|
|
4483
|
+
"data-ug-slot": "check"
|
|
4484
|
+
})) : _("", !0)], 42, Fi)], 64))), 128))], 16, ki)) : _("", !0)], 8, ["to", "disabled"])),
|
|
4485
|
+
n.error ? (j(), v("p", {
|
|
4486
|
+
key: 1,
|
|
4487
|
+
id: M.value,
|
|
4488
|
+
class: "text-xs text-danger",
|
|
4489
|
+
"data-ug-slot": "message"
|
|
4490
|
+
}, R(n.error), 9, Li)) : n.helperText ? (j(), v("p", {
|
|
4491
|
+
key: 2,
|
|
4492
|
+
id: M.value,
|
|
4493
|
+
class: "text-xs text-text-secondary",
|
|
4494
|
+
"data-ug-slot": "message"
|
|
4495
|
+
}, R(n.helperText), 9, Ri)) : _("", !0)
|
|
4496
|
+
], 40, bi));
|
|
4497
|
+
}
|
|
4498
|
+
}), Bi = ["data-variant", "data-size"], Vi = {
|
|
4499
|
+
key: 0,
|
|
4500
|
+
class: "mb-[calc(var(--content-gap)*0.75)] text-base font-semibold text-text-primary",
|
|
4501
|
+
"data-ug-slot": "title"
|
|
4502
|
+
}, Hi = {
|
|
4503
|
+
key: 1,
|
|
4504
|
+
class: "overflow-hidden rounded-[var(--radius-panel)] border border-border-base bg-surface-1",
|
|
4505
|
+
"data-ug-slot": "panel"
|
|
4506
|
+
}, Ui = {
|
|
4507
|
+
class: "w-full table-fixed border-separate border-spacing-0",
|
|
4508
|
+
"data-ug-slot": "table"
|
|
4509
|
+
}, Wi = ["colspan"], Gi = ["data-span"], Ki = S({
|
|
4510
|
+
name: "UDescriptionsItem",
|
|
4511
|
+
props: {
|
|
4512
|
+
label: {
|
|
4513
|
+
type: String,
|
|
4514
|
+
required: !0
|
|
4515
|
+
},
|
|
4516
|
+
span: {
|
|
4517
|
+
type: Number,
|
|
4518
|
+
default: 1
|
|
4519
|
+
},
|
|
4520
|
+
class: {
|
|
4521
|
+
type: String,
|
|
4522
|
+
default: void 0
|
|
4523
|
+
}
|
|
4524
|
+
},
|
|
4525
|
+
setup(t, { slots: n, attrs: r }) {
|
|
4526
|
+
return () => C("div", {
|
|
4527
|
+
...r,
|
|
4528
|
+
class: e("grid grid-cols-[max-content_minmax(0,1fr)] items-baseline gap-x-2", t.class),
|
|
4529
|
+
"data-ug-slot": "item"
|
|
4530
|
+
}, [C("span", {
|
|
4531
|
+
class: "text-xs font-medium text-text-secondary after:content-[':']",
|
|
4532
|
+
"data-ug-slot": "label"
|
|
4533
|
+
}, t.label), C("span", {
|
|
4534
|
+
class: "text-sm text-text-primary",
|
|
4535
|
+
"data-ug-slot": "value"
|
|
4536
|
+
}, n.default?.())]);
|
|
4537
|
+
}
|
|
4538
|
+
}), qi = /* @__PURE__ */ S({
|
|
4539
|
+
name: "UDescriptions",
|
|
4540
|
+
__name: "descriptions",
|
|
4541
|
+
props: {
|
|
4542
|
+
column: { default: 2 },
|
|
4543
|
+
bordered: {
|
|
4544
|
+
type: Boolean,
|
|
4545
|
+
default: !1
|
|
4546
|
+
},
|
|
4547
|
+
size: { default: "default" },
|
|
4548
|
+
title: { default: void 0 },
|
|
4549
|
+
class: { default: void 0 }
|
|
4550
|
+
},
|
|
4551
|
+
setup(t) {
|
|
4552
|
+
let n = t, r = {
|
|
4553
|
+
1: "grid-cols-1",
|
|
4554
|
+
2: "grid-cols-1 sm:grid-cols-2",
|
|
4555
|
+
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
|
4556
|
+
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4"
|
|
4557
|
+
}, i = {
|
|
4558
|
+
sm: "px-[var(--control-padding-x-sm)] py-[calc(var(--content-gap)*0.5)] text-xs",
|
|
4559
|
+
default: "px-[var(--control-padding-x-md)] py-[calc(var(--content-gap)*0.625)] text-sm",
|
|
4560
|
+
lg: "px-[var(--control-padding-x-lg)] py-[calc(var(--content-gap)*0.75)] text-base"
|
|
4561
|
+
}, a = {
|
|
4562
|
+
sm: "px-[var(--control-padding-x-sm)] py-[calc(var(--content-gap)*0.5)] text-xs",
|
|
4563
|
+
default: "px-[var(--control-padding-x-md)] py-[calc(var(--content-gap)*0.625)] text-sm",
|
|
4564
|
+
lg: "px-[var(--control-padding-x-lg)] py-[calc(var(--content-gap)*0.75)] text-base"
|
|
4565
|
+
}, o = h(() => e("w-full", n.class)), s = h(() => e("grid gap-x-[calc(var(--content-gap)*1.5)] gap-y-[var(--content-gap)]", r[n.column])), c = h(() => e("border-r border-border-base bg-surface-2/80 font-medium text-text-secondary", i[n.size])), l = h(() => e("break-words font-medium text-text-primary", a[n.size])), u = U();
|
|
4566
|
+
function d(e) {
|
|
4567
|
+
let t = Number.isFinite(e) ? Math.floor(e ?? 1) : 1;
|
|
4568
|
+
return Math.min(n.column, Math.max(1, t));
|
|
4569
|
+
}
|
|
4570
|
+
function p(e) {
|
|
4571
|
+
return e <= 1 || n.column === 1 ? "col-span-1" : e === 2 ? "col-span-1 sm:col-span-2" : e === 3 ? "col-span-1 sm:col-span-2 lg:col-span-3" : "col-span-1 sm:col-span-2 lg:col-span-4";
|
|
4572
|
+
}
|
|
4573
|
+
let m = S({
|
|
4574
|
+
name: "UDescriptionsValue",
|
|
4575
|
+
props: { node: {
|
|
4576
|
+
type: Object,
|
|
4577
|
+
required: !0
|
|
4578
|
+
} },
|
|
4579
|
+
setup(e) {
|
|
4580
|
+
return () => {
|
|
4581
|
+
let t = e.node.children;
|
|
4582
|
+
return t && typeof t == "object" && !Array.isArray(t) ? t.default?.() ?? null : t;
|
|
4583
|
+
};
|
|
4584
|
+
}
|
|
4585
|
+
});
|
|
4586
|
+
function g() {
|
|
4587
|
+
let e = u.default?.({}) ?? [], t = [];
|
|
4588
|
+
for (let n of e) n.type?.name === "UDescriptionsItem" && t.push(n);
|
|
4589
|
+
return t;
|
|
4590
|
+
}
|
|
4591
|
+
let b = h(() => {
|
|
4592
|
+
let e = g(), t = [], r = [], i = 0;
|
|
4593
|
+
for (let a of e) {
|
|
4594
|
+
let e = a.props, o = e?.label ?? "", s = d(e?.span);
|
|
4595
|
+
i + s > n.column && (t.push(r), r = [], i = 0), r.push({
|
|
4596
|
+
label: o,
|
|
4597
|
+
span: s,
|
|
4598
|
+
class: e?.class,
|
|
4599
|
+
node: a
|
|
4600
|
+
}), i += s;
|
|
4601
|
+
}
|
|
4602
|
+
return r.length > 0 && t.push(r), t;
|
|
4603
|
+
}), C = h(() => g().map((e) => {
|
|
4604
|
+
let t = e.props, n = d(t?.span);
|
|
4605
|
+
return {
|
|
4606
|
+
label: t?.label ?? "",
|
|
4607
|
+
span: n,
|
|
4608
|
+
class: t?.class,
|
|
4609
|
+
node: e
|
|
4610
|
+
};
|
|
4611
|
+
})), w = h(() => n.column === 1 ? "34%" : `${Math.max(12, 100 / (n.column * 2))}%`);
|
|
4612
|
+
return (n, r) => (j(), v("div", {
|
|
4613
|
+
class: O(o.value),
|
|
4614
|
+
"data-ug": "descriptions",
|
|
4615
|
+
"data-state": "default",
|
|
4616
|
+
"data-variant": t.bordered ? "bordered" : "plain",
|
|
4617
|
+
"data-size": t.size
|
|
4618
|
+
}, [t.title ? (j(), v("div", Vi, R(t.title), 1)) : _("", !0), t.bordered ? (j(), v("div", Hi, [y("table", Ui, [y("tbody", null, [(j(!0), v(f, null, F(b.value, (t, n) => (j(), v("tr", {
|
|
4619
|
+
key: n,
|
|
4620
|
+
"data-ug-slot": "row"
|
|
4621
|
+
}, [(j(!0), v(f, null, F(t, (t, r) => (j(), v(f, { key: r }, [y("th", {
|
|
4622
|
+
scope: "row",
|
|
4623
|
+
class: O(B(e)(c.value, n < b.value.length - 1 && "border-b border-border-base")),
|
|
4624
|
+
style: k({ width: w.value }),
|
|
4625
|
+
"data-ug-slot": "label"
|
|
4626
|
+
}, R(t.label), 7), y("td", {
|
|
4627
|
+
class: O(B(e)(l.value, n < b.value.length - 1 && "border-b border-border-base")),
|
|
4628
|
+
colspan: t.span > 1 ? t.span * 2 - 1 : 1,
|
|
4629
|
+
"data-ug-slot": "value"
|
|
4630
|
+
}, [x(B(m), { node: t.node }, null, 8, ["node"])], 10, Wi)], 64))), 128))]))), 128))])])])) : (j(), v("div", {
|
|
4631
|
+
key: 2,
|
|
4632
|
+
class: O(s.value),
|
|
4633
|
+
"data-ug-slot": "panel"
|
|
4634
|
+
}, [(j(!0), v(f, null, F(C.value, (n, r) => (j(), v("div", {
|
|
4635
|
+
key: r,
|
|
4636
|
+
class: O(B(e)("grid grid-cols-[max-content_minmax(0,1fr)] items-baseline gap-x-2", p(n.span), n.class)),
|
|
4637
|
+
"data-ug-slot": "item",
|
|
4638
|
+
"data-span": n.span
|
|
4639
|
+
}, [y("span", {
|
|
4640
|
+
class: O(B(e)("font-medium text-text-secondary after:content-[':']", t.size === "sm" ? "text-xs" : t.size === "lg" ? "text-sm" : "text-xs")),
|
|
4641
|
+
"data-ug-slot": "label"
|
|
4642
|
+
}, R(n.label), 3), y("span", {
|
|
4643
|
+
class: O(B(e)("text-text-primary", t.size === "sm" ? "text-sm" : t.size === "lg" ? "text-base" : "text-sm")),
|
|
4644
|
+
"data-ug-slot": "value"
|
|
4645
|
+
}, [x(B(m), { node: n.node }, null, 8, ["node"])], 2)], 10, Gi))), 128))], 2))], 10, Bi));
|
|
4646
|
+
}
|
|
4647
|
+
}), Ji = [
|
|
4648
|
+
"data-state",
|
|
4649
|
+
"data-variant",
|
|
4650
|
+
"data-size"
|
|
4651
|
+
], Yi = {
|
|
4652
|
+
class: "flex items-baseline gap-[calc(var(--content-gap)*0.25)]",
|
|
4653
|
+
"data-ug-slot": "value-row"
|
|
4654
|
+
}, Xi = {
|
|
4655
|
+
key: 1,
|
|
4656
|
+
class: "flex items-center gap-[calc(var(--content-gap)*0.25)]",
|
|
4657
|
+
"data-ug-slot": "trend"
|
|
4658
|
+
}, Zi = /* @__PURE__ */ S({
|
|
4659
|
+
name: "UStatistic",
|
|
4660
|
+
__name: "statistic",
|
|
4661
|
+
props: {
|
|
4662
|
+
title: { default: void 0 },
|
|
4663
|
+
value: {},
|
|
4664
|
+
precision: { default: void 0 },
|
|
4665
|
+
suffix: { default: void 0 },
|
|
4666
|
+
trend: { default: void 0 },
|
|
4667
|
+
change: { default: void 0 },
|
|
4668
|
+
size: { default: "default" },
|
|
4669
|
+
class: { default: void 0 }
|
|
4670
|
+
},
|
|
4671
|
+
setup(t) {
|
|
4672
|
+
let n = t, r = {
|
|
4673
|
+
sm: "text-xs",
|
|
4674
|
+
default: "text-sm",
|
|
4675
|
+
lg: "text-base"
|
|
4676
|
+
}, i = {
|
|
4677
|
+
sm: "text-2xl",
|
|
4678
|
+
default: "text-3xl",
|
|
4679
|
+
lg: "text-4xl"
|
|
4680
|
+
}, a = {
|
|
4681
|
+
sm: "text-xs",
|
|
4682
|
+
default: "text-sm",
|
|
4683
|
+
lg: "text-base"
|
|
4684
|
+
}, o = {
|
|
4685
|
+
up: "text-success",
|
|
4686
|
+
down: "text-danger",
|
|
4687
|
+
flat: "text-text-secondary"
|
|
4688
|
+
}, s = {
|
|
4689
|
+
up: "text-success",
|
|
4690
|
+
down: "text-danger",
|
|
4691
|
+
flat: "text-text-secondary"
|
|
4692
|
+
}, c = {
|
|
4693
|
+
up: X,
|
|
4694
|
+
down: me,
|
|
4695
|
+
flat: de
|
|
4696
|
+
}, l = h(() => e("flex flex-col gap-[calc(var(--content-gap)*0.25)]", n.class)), u = h(() => e("font-medium text-text-secondary", r[n.size])), d = h(() => e("font-bold tabular-nums text-text-primary", i[n.size])), f = h(() => e("text-text-secondary", a[n.size])), p = h(() => e("text-text-primary", a[n.size])), m = h(() => n.trend ? o[n.trend] : ""), x = h(() => n.trend ? e("text-xs font-medium", s[n.trend]) : ""), S = h(() => n.size === "sm" ? 14 : n.size === "lg" ? 18 : 16), C = h(() => n.trend ? c[n.trend] : null), w = h(() => n.trend ?? "default"), T = h(() => {
|
|
4697
|
+
if (typeof n.value == "string") return n.value;
|
|
4698
|
+
let e = n.precision === void 0 ? 0 : Math.min(20, Math.max(0, Math.floor(Number.isFinite(n.precision) ? n.precision : 0)));
|
|
4699
|
+
return new Intl.NumberFormat("zh-CN", {
|
|
4700
|
+
minimumFractionDigits: e,
|
|
4701
|
+
maximumFractionDigits: e
|
|
4702
|
+
}).format(n.value);
|
|
4703
|
+
});
|
|
4704
|
+
return (e, n) => (j(), v("div", {
|
|
4705
|
+
class: O(l.value),
|
|
4706
|
+
"data-ug": "statistic",
|
|
4707
|
+
"data-state": w.value,
|
|
4708
|
+
"data-variant": t.trend ?? "default",
|
|
4709
|
+
"data-size": t.size
|
|
4710
|
+
}, [
|
|
4711
|
+
t.title ? (j(), v("span", {
|
|
4712
|
+
key: 0,
|
|
4713
|
+
class: O(u.value),
|
|
4714
|
+
"data-ug-slot": "title"
|
|
4715
|
+
}, R(t.title), 3)) : _("", !0),
|
|
4716
|
+
y("div", Yi, [
|
|
4717
|
+
e.$slots.prefix ? (j(), v("span", {
|
|
4718
|
+
key: 0,
|
|
4719
|
+
class: O(p.value),
|
|
4720
|
+
"data-ug-slot": "prefix"
|
|
4721
|
+
}, [I(e.$slots, "prefix")], 2)) : _("", !0),
|
|
4722
|
+
y("span", {
|
|
4723
|
+
class: O(d.value),
|
|
4724
|
+
"data-ug-slot": "value"
|
|
4725
|
+
}, R(T.value), 3),
|
|
4726
|
+
e.$slots.suffix || t.suffix ? (j(), v("span", {
|
|
4727
|
+
key: 1,
|
|
4728
|
+
class: O(f.value),
|
|
4729
|
+
"data-ug-slot": "suffix"
|
|
4730
|
+
}, [I(e.$slots, "suffix", {}, () => [b(R(t.suffix), 1)])], 2)) : _("", !0)
|
|
4731
|
+
]),
|
|
4732
|
+
t.trend || t.change ? (j(), v("div", Xi, [C.value ? (j(), g(L(C.value), {
|
|
4733
|
+
key: 0,
|
|
4734
|
+
size: S.value,
|
|
4735
|
+
class: O(m.value),
|
|
4736
|
+
"data-ug-slot": "trend-icon"
|
|
4737
|
+
}, null, 8, ["size", "class"])) : _("", !0), t.change ? (j(), v("span", {
|
|
4738
|
+
key: 1,
|
|
4739
|
+
class: O(t.trend ? x.value : "text-xs font-medium text-text-secondary"),
|
|
4740
|
+
"data-ug-slot": "change"
|
|
4741
|
+
}, R(t.change), 3)) : _("", !0)])) : _("", !0)
|
|
4742
|
+
], 10, Ji));
|
|
4743
|
+
}
|
|
4744
|
+
});
|
|
4745
|
+
//#endregion
|
|
4746
|
+
export { qt as $, er as A, Tn as B, cr as C, Ne as Ct, tr as D, Ee as Dt, nr as E, Me as Et, Un as F, un as G, Dn as H, Ln as I, cn as J, ln as K, In as L, Wn as M, Gn as N, Qn as O, Kn as P, Qt as Q, Fn as R, mr as S, Ae as St, or as T, je as Tt, wn as U, En as V, mn as W, $t as X, en as Y, Zt as Z, Dr as _, He as _t, yi as a, Kt as at, xr as b, Ie as bt, ni as c, Et as ct, Vr as d, st as dt, Wt as et, Nr as f, at as ft, Or as g, Ue as gt, Mr as h, Be as ht, zi as i, Ut as it, qn as j, $n as k, Qr as l, vt as lt, jr as m, We as mt, qi as n, Vt as nt, mi as o, Nt as ot, Ar as p, Xe as pt, sn as q, Ki as r, Ht as rt, li as s, At as st, Zi as t, Gt as tt, Xr as u, gt as ut, Er as v, ze as vt, sr as w, Pe as wt, br as x, Fe as xt, Sr as y, Ve as yt, On as z };
|
|
4747
|
+
|
|
4748
|
+
//# sourceMappingURL=statistic-DBlNBT-A.js.map
|