@mcistudio/unoui-vue 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -0
- package/dist/alert/Alert.vue.d.ts +67 -0
- package/dist/alert/index.d.ts +40 -0
- package/dist/alert/index.js +2 -0
- package/dist/attrs.d.ts +11 -0
- package/dist/attrs.js +16 -0
- package/dist/attrs.js.map +1 -0
- package/dist/badge/Badge.vue.d.ts +57 -0
- package/dist/badge/BadgeRibbon.vue.d.ts +34 -0
- package/dist/badge/index.d.ts +42 -0
- package/dist/badge/index.js +2 -0
- package/dist/build.d.ts +2 -0
- package/dist/button/Button.vue.d.ts +46 -0
- package/dist/button/ButtonGroup.vue.d.ts +13 -0
- package/dist/button/index.d.ts +13 -0
- package/dist/button/index.js +2 -0
- package/dist/checkbox/Checkbox.vue.d.ts +47 -0
- package/dist/checkbox/CheckboxGroup.vue.d.ts +38 -0
- package/dist/checkbox/index.d.ts +30 -0
- package/dist/checkbox/index.js +2 -0
- package/dist/chunks/Progress-BL4KZ3HE.js +271 -0
- package/dist/chunks/Progress-BL4KZ3HE.js.map +1 -0
- package/dist/chunks/Skeleton-ohStUD4M.js +153 -0
- package/dist/chunks/Skeleton-ohStUD4M.js.map +1 -0
- package/dist/chunks/Table-DhXmuKQd.js +330 -0
- package/dist/chunks/Table-DhXmuKQd.js.map +1 -0
- package/dist/chunks/_plugin-vue_export-helper-B3ysoDQm.js +8 -0
- package/dist/chunks/alert-CczW_DKs.js +190 -0
- package/dist/chunks/alert-CczW_DKs.js.map +1 -0
- package/dist/chunks/badge-BHOZeImh.js +287 -0
- package/dist/chunks/badge-BHOZeImh.js.map +1 -0
- package/dist/chunks/button-pDObrN_X.js +168 -0
- package/dist/chunks/button-pDObrN_X.js.map +1 -0
- package/dist/chunks/checkbox-9_0oR4kg.js +260 -0
- package/dist/chunks/checkbox-9_0oR4kg.js.map +1 -0
- package/dist/chunks/colorpicker-CcizUCQv.js +594 -0
- package/dist/chunks/colorpicker-CcizUCQv.js.map +1 -0
- package/dist/chunks/datepicker-Cy808x7X.js +1414 -0
- package/dist/chunks/datepicker-Cy808x7X.js.map +1 -0
- package/dist/chunks/drawer-C3JZ28Xo.js +193 -0
- package/dist/chunks/drawer-C3JZ28Xo.js.map +1 -0
- package/dist/chunks/dropdown-0l967g7D.js +329 -0
- package/dist/chunks/dropdown-0l967g7D.js.map +1 -0
- package/dist/chunks/form-Qeqkd-HH.js +642 -0
- package/dist/chunks/form-Qeqkd-HH.js.map +1 -0
- package/dist/chunks/input-BDOXVCrK.js +1281 -0
- package/dist/chunks/input-BDOXVCrK.js.map +1 -0
- package/dist/chunks/inputOtp-Dyxj9lNj.js +261 -0
- package/dist/chunks/inputOtp-Dyxj9lNj.js.map +1 -0
- package/dist/chunks/message-xPfuG0EX.js +107 -0
- package/dist/chunks/message-xPfuG0EX.js.map +1 -0
- package/dist/chunks/millercolumns-Dp3fBrq6.js +426 -0
- package/dist/chunks/millercolumns-Dp3fBrq6.js.map +1 -0
- package/dist/chunks/modal-D6l1iIvE.js +81 -0
- package/dist/chunks/modal-D6l1iIvE.js.map +1 -0
- package/dist/chunks/pagination-Bc583AQX.js +265 -0
- package/dist/chunks/pagination-Bc583AQX.js.map +1 -0
- package/dist/chunks/popconfirm-D6lUfSxG.js +343 -0
- package/dist/chunks/popconfirm-D6lUfSxG.js.map +1 -0
- package/dist/chunks/qrcode-B0t_pZna.js +1099 -0
- package/dist/chunks/qrcode-B0t_pZna.js.map +1 -0
- package/dist/chunks/radio-DnYm59xH.js +477 -0
- package/dist/chunks/radio-DnYm59xH.js.map +1 -0
- package/dist/chunks/rate-0sme__Kb.js +309 -0
- package/dist/chunks/rate-0sme__Kb.js.map +1 -0
- package/dist/chunks/select-ChTfQM5u.js +417 -0
- package/dist/chunks/select-ChTfQM5u.js.map +1 -0
- package/dist/chunks/slider-C-W5GzTP.js +724 -0
- package/dist/chunks/slider-C-W5GzTP.js.map +1 -0
- package/dist/chunks/splitter-CgfiXY65.js +524 -0
- package/dist/chunks/splitter-CgfiXY65.js.map +1 -0
- package/dist/chunks/switch-BULGbODP.js +327 -0
- package/dist/chunks/switch-BULGbODP.js.map +1 -0
- package/dist/chunks/tab-Dxfg1_To.js +663 -0
- package/dist/chunks/tab-Dxfg1_To.js.map +1 -0
- package/dist/chunks/tag-BYmNsrZC.js +167 -0
- package/dist/chunks/tag-BYmNsrZC.js.map +1 -0
- package/dist/chunks/timepicker-DsGIdcf8.js +1059 -0
- package/dist/chunks/timepicker-DsGIdcf8.js.map +1 -0
- package/dist/chunks/tooltip-DMhiAqto.js +242 -0
- package/dist/chunks/tooltip-DMhiAqto.js.map +1 -0
- package/dist/colorpicker/ColorPicker.vue.d.ts +30 -0
- package/dist/colorpicker/color.d.ts +56 -0
- package/dist/colorpicker/color.js +99 -0
- package/dist/colorpicker/color.js.map +1 -0
- package/dist/colorpicker/index.d.ts +12 -0
- package/dist/colorpicker/index.js +2 -0
- package/dist/config.d.ts +55 -0
- package/dist/config.js +260 -0
- package/dist/config.js.map +1 -0
- package/dist/datepicker/DatePicker.vue.d.ts +82 -0
- package/dist/datepicker/RangePicker.vue.d.ts +87 -0
- package/dist/datepicker/index.d.ts +59 -0
- package/dist/datepicker/index.js +2 -0
- package/dist/drawer/Drawer.vue.d.ts +86 -0
- package/dist/drawer/index.d.ts +23 -0
- package/dist/drawer/index.js +2 -0
- package/dist/dropdown/Dropdown.vue.d.ts +118 -0
- package/dist/dropdown/index.d.ts +2 -0
- package/dist/dropdown/index.js +2 -0
- package/dist/form/Form.vue.d.ts +170 -0
- package/dist/form/FormItem.vue.d.ts +83 -0
- package/dist/form/index.d.ts +176 -0
- package/dist/form/index.js +2 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +32 -0
- package/dist/input/Autocomplete.vue.d.ts +121 -0
- package/dist/input/Input.vue.d.ts +142 -0
- package/dist/input/InputI18n.vue.d.ts +80 -0
- package/dist/input/InputTag.vue.d.ts +114 -0
- package/dist/input/index.d.ts +41 -0
- package/dist/input/index.js +2 -0
- package/dist/inputOtp/InputOtp.vue.d.ts +60 -0
- package/dist/inputOtp/index.d.ts +21 -0
- package/dist/inputOtp/index.js +2 -0
- package/dist/message/MessageContainer.vue.d.ts +11 -0
- package/dist/message/index.d.ts +20 -0
- package/dist/message/index.js +2 -0
- package/dist/message/types.d.ts +25 -0
- package/dist/millercolumns/MillerColumns.vue.d.ts +88 -0
- package/dist/millercolumns/index.d.ts +39 -0
- package/dist/millercolumns/index.js +2 -0
- package/dist/modal/Modal.vue.d.ts +54 -0
- package/dist/modal/index.d.ts +2 -0
- package/dist/modal/index.js +2 -0
- package/dist/pagination/Pagination.vue.d.ts +70 -0
- package/dist/pagination/index.d.ts +12 -0
- package/dist/pagination/index.js +2 -0
- package/dist/popconfirm/Popconfirm.vue.d.ts +104 -0
- package/dist/popconfirm/index.d.ts +36 -0
- package/dist/popconfirm/index.js +2 -0
- package/dist/progress/Progress.vue.d.ts +64 -0
- package/dist/progress/index.d.ts +26 -0
- package/dist/progress/index.js +2 -0
- package/dist/qrcode/QRCode.vue.d.ts +87 -0
- package/dist/qrcode/index.d.ts +43 -0
- package/dist/qrcode/index.js +2 -0
- package/dist/qrcode/qr.d.ts +51 -0
- package/dist/qrcode/qrcodegen.d.ts +94 -0
- package/dist/radio/Radio.vue.d.ts +52 -0
- package/dist/radio/RadioGroup.vue.d.ts +44 -0
- package/dist/radio/index.d.ts +55 -0
- package/dist/radio/index.js +2 -0
- package/dist/rate/Rate.vue.d.ts +100 -0
- package/dist/rate/index.d.ts +38 -0
- package/dist/rate/index.js +2 -0
- package/dist/select/Select.vue.d.ts +129 -0
- package/dist/select/index.d.ts +33 -0
- package/dist/select/index.js +2 -0
- package/dist/skeleton/Skeleton.vue.d.ts +31 -0
- package/dist/skeleton/index.d.ts +2 -0
- package/dist/skeleton/index.js +2 -0
- package/dist/slider/Slider.vue.d.ts +81 -0
- package/dist/slider/index.d.ts +61 -0
- package/dist/slider/index.js +2 -0
- package/dist/splitter/Splitter.vue.d.ts +63 -0
- package/dist/splitter/SplitterPanel.vue.d.ts +53 -0
- package/dist/splitter/index.d.ts +39 -0
- package/dist/splitter/index.js +2 -0
- package/dist/style.css +2 -0
- package/dist/switch/Switch.vue.d.ts +97 -0
- package/dist/switch/index.d.ts +31 -0
- package/dist/switch/index.js +2 -0
- package/dist/tab/TabPane.vue.d.ts +32 -0
- package/dist/tab/Tabs.vue.d.ts +87 -0
- package/dist/tab/index.d.ts +78 -0
- package/dist/tab/index.js +2 -0
- package/dist/table/Table.vue.d.ts +96 -0
- package/dist/table/index.d.ts +3 -0
- package/dist/table/index.js +2 -0
- package/dist/table/types.d.ts +35 -0
- package/dist/table/types.js +0 -0
- package/dist/tag/Tag.vue.d.ts +46 -0
- package/dist/tag/index.d.ts +11 -0
- package/dist/tag/index.js +2 -0
- package/dist/timepicker/TimePicker.vue.d.ts +92 -0
- package/dist/timepicker/TimeRangePicker.vue.d.ts +90 -0
- package/dist/timepicker/index.d.ts +39 -0
- package/dist/timepicker/index.js +2 -0
- package/dist/tooltip/Tooltip.vue.d.ts +79 -0
- package/dist/tooltip/index.d.ts +14 -0
- package/dist/tooltip/index.js +2 -0
- package/dist/uno.d.ts +32 -0
- package/dist/uno.js +83 -0
- package/dist/uno.js.map +1 -0
- package/dist/utils/DnD.d.ts +38 -0
- package/package.json +115 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
|
|
2
|
+
import { cva as t } from "class-variance-authority";
|
|
3
|
+
import { Teleport as n, Transition as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as ee, createVNode as l, defineComponent as u, inject as d, nextTick as te, normalizeClass as f, normalizeStyle as p, onBeforeUnmount as m, openBlock as h, provide as ne, ref as g, renderSlot as _, toDisplayString as re, unref as v, vShow as y, watch as b, withCtx as x, withDirectives as S, withModifiers as C } from "vue";
|
|
4
|
+
//#region src/drawer/Drawer.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var w = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "flex min-h-12 items-center justify-between gap-3 border-b border-zinc-100/50 px-4 py-3 dark:border-zinc-800/50"
|
|
8
|
+
}, T = { class: "min-w-0 truncate text-xs font-bold uppercase tracking-widest text-zinc-500" }, E = {
|
|
9
|
+
key: 1,
|
|
10
|
+
class: "flex justify-end gap-2 border-t border-zinc-100/50 bg-zinc-50/30 px-3 py-2.5 dark:border-zinc-800/50 dark:bg-zinc-800/30"
|
|
11
|
+
}, D = 180, O = /*#__PURE__*/ e(/* @__PURE__ */ u({
|
|
12
|
+
__name: "Drawer",
|
|
13
|
+
props: {
|
|
14
|
+
modelValue: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: void 0
|
|
17
|
+
},
|
|
18
|
+
visible: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: void 0
|
|
21
|
+
},
|
|
22
|
+
title: { default: "" },
|
|
23
|
+
direction: { default: "rtl" },
|
|
24
|
+
size: { default: "30%" },
|
|
25
|
+
withHeader: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: !0
|
|
28
|
+
},
|
|
29
|
+
showClose: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: !0
|
|
32
|
+
},
|
|
33
|
+
closeOnClickModal: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: !0
|
|
36
|
+
},
|
|
37
|
+
closeOnPressEscape: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: !0
|
|
40
|
+
},
|
|
41
|
+
beforeClose: {
|
|
42
|
+
type: Function,
|
|
43
|
+
default: void 0
|
|
44
|
+
},
|
|
45
|
+
destroyOnClose: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: !1
|
|
48
|
+
},
|
|
49
|
+
modal: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: !0
|
|
52
|
+
},
|
|
53
|
+
lockScroll: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: !0
|
|
56
|
+
},
|
|
57
|
+
zIndex: { default: 2e3 },
|
|
58
|
+
bodyClass: { default: "" },
|
|
59
|
+
push: {
|
|
60
|
+
type: [Boolean, Object],
|
|
61
|
+
default: !0
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
emits: [
|
|
65
|
+
"update:modelValue",
|
|
66
|
+
"update:visible",
|
|
67
|
+
"open",
|
|
68
|
+
"opened",
|
|
69
|
+
"close",
|
|
70
|
+
"closed"
|
|
71
|
+
],
|
|
72
|
+
setup(e, { emit: t }) {
|
|
73
|
+
let u = e, O = t, j = i(() => u.modelValue ?? u.visible ?? !1), M = g(j.value), N = Symbol("ui-drawer"), P = d(k, null), F = g([]), I = i(() => u.direction === "rtl" || u.direction === "ltr"), L = i(() => typeof u.size == "number" ? `${u.size}px` : u.size), R = i(() => u.push === !1 ? 0 : typeof u.push == "object" && u.push.distance !== void 0 ? u.push.distance : P ? P.pushDistance.value : D), z = i(() => K(R.value)), B = i(() => {
|
|
74
|
+
if (!F.value.length) return;
|
|
75
|
+
let e = z.value;
|
|
76
|
+
if (e !== "0px") switch (u.direction) {
|
|
77
|
+
case "rtl": return `translateX(-${e})`;
|
|
78
|
+
case "ltr": return `translateX(${e})`;
|
|
79
|
+
case "ttb": return `translateY(${e})`;
|
|
80
|
+
case "btt": return `translateY(-${e})`;
|
|
81
|
+
default: return;
|
|
82
|
+
}
|
|
83
|
+
}), V = i(() => ({
|
|
84
|
+
width: I.value ? L.value : void 0,
|
|
85
|
+
height: I.value ? void 0 : L.value,
|
|
86
|
+
transform: B.value
|
|
87
|
+
})), H = i(() => `ui-drawer-${u.direction}`), U = "", W = !1, G = !1;
|
|
88
|
+
function K(e) {
|
|
89
|
+
return typeof e == "number" ? `${e}px` : e;
|
|
90
|
+
}
|
|
91
|
+
function q(e) {
|
|
92
|
+
O("update:modelValue", e), O("update:visible", e);
|
|
93
|
+
}
|
|
94
|
+
function J() {
|
|
95
|
+
q(!1), O("close");
|
|
96
|
+
}
|
|
97
|
+
async function Y() {
|
|
98
|
+
if (!u.beforeClose) {
|
|
99
|
+
J();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
let e = !1, t = await u.beforeClose(() => {
|
|
103
|
+
e = !0, J();
|
|
104
|
+
});
|
|
105
|
+
t === !1 || e || (u.beforeClose.length === 0 || t !== void 0) && J();
|
|
106
|
+
}
|
|
107
|
+
function X(e) {
|
|
108
|
+
!j.value || !u.closeOnPressEscape || e.key !== "Escape" || (e.preventDefault(), e.stopPropagation(), Y());
|
|
109
|
+
}
|
|
110
|
+
function Z() {
|
|
111
|
+
!u.lockScroll || typeof document > "u" || (U = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
112
|
+
}
|
|
113
|
+
function Q() {
|
|
114
|
+
!u.lockScroll || typeof document > "u" || (document.body.style.overflow = U);
|
|
115
|
+
}
|
|
116
|
+
function ie(e) {
|
|
117
|
+
u.push === !1 || F.value.includes(e) || (F.value = [...F.value, e]);
|
|
118
|
+
}
|
|
119
|
+
function ae(e) {
|
|
120
|
+
F.value.includes(e) && (F.value = F.value.filter((t) => t !== e));
|
|
121
|
+
}
|
|
122
|
+
function oe() {
|
|
123
|
+
!P || G || (P.push(N), G = !0);
|
|
124
|
+
}
|
|
125
|
+
function $() {
|
|
126
|
+
!P || !G || (P.pull(N), G = !1);
|
|
127
|
+
}
|
|
128
|
+
return ne(k, {
|
|
129
|
+
pushDistance: R,
|
|
130
|
+
push: ie,
|
|
131
|
+
pull: ae
|
|
132
|
+
}), b(j, (e) => {
|
|
133
|
+
e ? (M.value = !0, W = !0, oe(), Z(), O("open"), window.addEventListener("keydown", X, { capture: !0 }), te(() => O("opened"))) : ($(), F.value = [], Q(), window.removeEventListener("keydown", X, { capture: !0 }), W && O("closed"), u.destroyOnClose && window.setTimeout(() => {
|
|
134
|
+
j.value || (M.value = !1);
|
|
135
|
+
}, 180));
|
|
136
|
+
}, { immediate: !0 }), m(() => {
|
|
137
|
+
$(), Q(), window.removeEventListener("keydown", X, { capture: !0 });
|
|
138
|
+
}), (t, i) => (h(), a(n, { to: "body" }, [l(r, { name: "ui-drawer-fade" }, {
|
|
139
|
+
default: x(() => [M.value ? S((h(), s("div", {
|
|
140
|
+
key: 0,
|
|
141
|
+
class: "fixed inset-0 pointer-events-auto",
|
|
142
|
+
style: p({ zIndex: e.zIndex }),
|
|
143
|
+
onMousemove: i[1] ||= C(() => {}, ["stop"]),
|
|
144
|
+
onMousedown: i[2] ||= C(() => {}, ["stop"]),
|
|
145
|
+
onMouseup: i[3] ||= C(() => {}, ["stop"]),
|
|
146
|
+
onPointermove: i[4] ||= C(() => {}, ["stop"]),
|
|
147
|
+
onPointerdown: i[5] ||= C(() => {}, ["stop"]),
|
|
148
|
+
onPointerup: i[6] ||= C(() => {}, ["stop"]),
|
|
149
|
+
onWheel: i[7] ||= C(() => {}, ["stop"]),
|
|
150
|
+
onClick: i[8] ||= C(() => {}, ["stop"]),
|
|
151
|
+
onDblclick: i[9] ||= C(() => {}, ["stop"]),
|
|
152
|
+
onContextmenu: i[10] ||= C(() => {}, ["stop"])
|
|
153
|
+
}, [e.modal ? (h(), s("div", {
|
|
154
|
+
key: 0,
|
|
155
|
+
class: "absolute inset-0 bg-zinc-900/10 backdrop-blur-sm",
|
|
156
|
+
onClick: i[0] ||= (t) => e.closeOnClickModal && Y()
|
|
157
|
+
})) : o("", !0), l(r, {
|
|
158
|
+
name: H.value,
|
|
159
|
+
appear: ""
|
|
160
|
+
}, {
|
|
161
|
+
default: x(() => [S(c("aside", {
|
|
162
|
+
class: f(["ui-drawer-panel", v(A)({ direction: e.direction })]),
|
|
163
|
+
style: p(V.value),
|
|
164
|
+
"data-ui-drawer": "true"
|
|
165
|
+
}, [
|
|
166
|
+
e.withHeader ? (h(), s("header", w, [_(t.$slots, "header", {}, () => [c("h3", T, [_(t.$slots, "icon", {}, void 0, !0), ee(" " + re(e.title), 1)])], !0), e.showClose ? (h(), s("button", {
|
|
167
|
+
key: 0,
|
|
168
|
+
type: "button",
|
|
169
|
+
"aria-label": "关闭",
|
|
170
|
+
class: "group flex size-7 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-brand-200 dark:hover:bg-brand-500",
|
|
171
|
+
onClick: Y
|
|
172
|
+
}, [...i[11] ||= [c("span", { class: "i-lucide:x size-4 text-zinc-400 group-hover:text-brand-600 dark:group-hover:text-brand-200" }, null, -1)]])) : o("", !0)])) : o("", !0),
|
|
173
|
+
c("div", { class: f(["min-h-0 flex-1 overflow-auto", e.bodyClass]) }, [!e.destroyOnClose || j.value ? _(t.$slots, "default", { key: 0 }, void 0, !0) : o("", !0)], 2),
|
|
174
|
+
t.$slots.footer ? (h(), s("footer", E, [_(t.$slots, "footer", {}, void 0, !0)])) : o("", !0)
|
|
175
|
+
], 6), [[y, j.value]])]),
|
|
176
|
+
_: 3
|
|
177
|
+
}, 8, ["name"])], 36)), [[y, j.value]]) : o("", !0)]),
|
|
178
|
+
_: 3
|
|
179
|
+
})]));
|
|
180
|
+
}
|
|
181
|
+
}), [["__scopeId", "data-v-f21b8c82"]]), k = Symbol("ui-drawer-context"), A = t("fixed z-10 flex bg-white/95 shadow-2xl backdrop-blur-md dark:bg-zinc-900/95", {
|
|
182
|
+
variants: { direction: {
|
|
183
|
+
rtl: "inset-y-0 right-0 flex-col border-l border-white/20 dark:border-zinc-800/50",
|
|
184
|
+
ltr: "inset-y-0 left-0 flex-col border-r border-white/20 dark:border-zinc-800/50",
|
|
185
|
+
ttb: "inset-x-0 top-0 flex-col border-b border-white/20 dark:border-zinc-800/50",
|
|
186
|
+
btt: "inset-x-0 bottom-0 flex-col border-t border-white/20 dark:border-zinc-800/50"
|
|
187
|
+
} },
|
|
188
|
+
defaultVariants: { direction: "rtl" }
|
|
189
|
+
});
|
|
190
|
+
//#endregion
|
|
191
|
+
export { A as n, O as r, k as t };
|
|
192
|
+
|
|
193
|
+
//# sourceMappingURL=drawer-C3JZ28Xo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer-C3JZ28Xo.js","names":["$slots"],"sources":["../../src/drawer/Drawer.vue","../../src/drawer/Drawer.vue","../../src/drawer/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, inject, nextTick, onBeforeUnmount, provide, ref, watch, type CSSProperties } from 'vue'\n\nimport { drawerContextKey, drawerPanel, type DrawerDirection, type DrawerPush, type DrawerPushDistance } from '.'\n\ntype DrawerBeforeClose = (done: () => void) => void | boolean | Promise<void | boolean>\n\nconst DEFAULT_PUSH_DISTANCE = 180\n\nconst props = withDefaults(\n defineProps<{\n /** modelValue 控制抽屉显示状态,兼容 Element Plus v-model。 */\n modelValue?: boolean\n /** visible 控制抽屉显示状态,兼容本地 Modal 的 v-model:visible。 */\n visible?: boolean\n /** title 是默认标题文本。 */\n title?: string\n /** direction 是抽屉弹出方向,可选 rtl/ltr/ttb/btt。 */\n direction?: DrawerDirection\n /** size 是抽屉宽度或高度,数字按 px 处理。 */\n size?: number | string\n /** withHeader 表示是否渲染头部区域。 */\n withHeader?: boolean\n /** showClose 表示是否展示关闭按钮。 */\n showClose?: boolean\n /** closeOnClickModal 表示是否允许点击遮罩关闭。 */\n closeOnClickModal?: boolean\n /** closeOnPressEscape 表示是否允许 Esc 关闭。 */\n closeOnPressEscape?: boolean\n /** beforeClose 在关闭前执行,返回 false 或不调用 done 可阻止关闭。 */\n beforeClose?: DrawerBeforeClose\n /** destroyOnClose 表示关闭后是否销毁默认插槽内容。 */\n destroyOnClose?: boolean\n /** modal 表示是否展示遮罩。 */\n modal?: boolean\n /** lockScroll 表示打开时是否锁定 body 滚动。 */\n lockScroll?: boolean\n /** zIndex 控制抽屉层级。 */\n zIndex?: number | string\n /** bodyClass 是正文区域额外类名。 */\n bodyClass?: string\n /** push 控制多层 Drawer 打开时父级抽屉是否被推动。 */\n push?: DrawerPush\n }>(),\n {\n modelValue: undefined,\n visible: undefined,\n title: '',\n direction: 'rtl',\n size: '30%',\n withHeader: true,\n showClose: true,\n closeOnClickModal: true,\n closeOnPressEscape: true,\n beforeClose: undefined,\n destroyOnClose: false,\n modal: true,\n lockScroll: true,\n zIndex: 2000,\n bodyClass: '',\n push: true\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: boolean): void\n (e: 'update:visible', value: boolean): void\n (e: 'open'): void\n (e: 'opened'): void\n (e: 'close'): void\n (e: 'closed'): void\n}>()\n\nconst isVisible = computed(() => props.modelValue ?? props.visible ?? false)\nconst shouldRender = ref(isVisible.value)\nconst drawerId = Symbol('ui-drawer')\nconst parentDrawer = inject(drawerContextKey, null)\nconst pushedChildIds = ref<symbol[]>([])\nconst isHorizontal = computed(() => props.direction === 'rtl' || props.direction === 'ltr')\nconst normalizedSize = computed(() => (typeof props.size === 'number' ? `${props.size}px` : props.size))\nconst pushDistance = computed<DrawerPushDistance>(() => {\n if (props.push === false) return 0\n if (typeof props.push === 'object' && props.push.distance !== undefined) return props.push.distance\n if (parentDrawer) return parentDrawer.pushDistance.value\n return DEFAULT_PUSH_DISTANCE\n})\nconst normalizedPushDistance = computed(() => normalizeCssSize(pushDistance.value))\nconst pushTransform = computed(() => {\n if (!pushedChildIds.value.length) return undefined\n\n const distance = normalizedPushDistance.value\n if (distance === '0px') return undefined\n\n switch (props.direction) {\n case 'rtl':\n return `translateX(-${distance})`\n case 'ltr':\n return `translateX(${distance})`\n case 'ttb':\n return `translateY(${distance})`\n case 'btt':\n return `translateY(-${distance})`\n default:\n return undefined\n }\n})\nconst panelStyle = computed<CSSProperties>(() => ({\n width: isHorizontal.value ? normalizedSize.value : undefined,\n height: isHorizontal.value ? undefined : normalizedSize.value,\n transform: pushTransform.value\n}))\nconst transitionName = computed(() => `ui-drawer-${props.direction}`)\nlet previousBodyOverflow = ''\nlet hasOpened = false\nlet hasPushedParent = false\n\nfunction normalizeCssSize(value: DrawerPushDistance) {\n return typeof value === 'number' ? `${value}px` : value\n}\n\nfunction syncVisible(value: boolean) {\n emit('update:modelValue', value)\n emit('update:visible', value)\n}\n\nfunction closeNow() {\n syncVisible(false)\n emit('close')\n}\n\nasync function requestClose() {\n if (!props.beforeClose) {\n closeNow()\n return\n }\n\n let doneCalled = false\n const done = () => {\n doneCalled = true\n closeNow()\n }\n\n const result = await props.beforeClose(done)\n if (result === false || doneCalled) return\n if (props.beforeClose.length === 0 || result !== undefined) closeNow()\n}\n\nfunction handleKeydown(event: KeyboardEvent) {\n if (!isVisible.value || !props.closeOnPressEscape || event.key !== 'Escape') return\n event.preventDefault()\n event.stopPropagation()\n void requestClose()\n}\n\nfunction lockBodyScroll() {\n if (!props.lockScroll || typeof document === 'undefined') return\n previousBodyOverflow = document.body.style.overflow\n document.body.style.overflow = 'hidden'\n}\n\nfunction unlockBodyScroll() {\n if (!props.lockScroll || typeof document === 'undefined') return\n document.body.style.overflow = previousBodyOverflow\n}\n\nfunction pushChild(id: symbol) {\n if (props.push === false || pushedChildIds.value.includes(id)) return\n pushedChildIds.value = [...pushedChildIds.value, id]\n}\n\nfunction pullChild(id: symbol) {\n if (!pushedChildIds.value.includes(id)) return\n pushedChildIds.value = pushedChildIds.value.filter((childId) => childId !== id)\n}\n\nfunction pushParent() {\n if (!parentDrawer || hasPushedParent) return\n parentDrawer.push(drawerId)\n hasPushedParent = true\n}\n\nfunction pullParent() {\n if (!parentDrawer || !hasPushedParent) return\n parentDrawer.pull(drawerId)\n hasPushedParent = false\n}\n\nprovide(drawerContextKey, {\n pushDistance,\n push: pushChild,\n pull: pullChild\n})\n\nwatch(\n isVisible,\n (visible) => {\n if (visible) {\n shouldRender.value = true\n hasOpened = true\n pushParent()\n lockBodyScroll()\n emit('open')\n window.addEventListener('keydown', handleKeydown, { capture: true })\n nextTick(() => emit('opened'))\n } else {\n pullParent()\n pushedChildIds.value = []\n unlockBodyScroll()\n window.removeEventListener('keydown', handleKeydown, { capture: true })\n if (hasOpened) emit('closed')\n if (props.destroyOnClose) {\n window.setTimeout(() => {\n if (!isVisible.value) shouldRender.value = false\n }, 180)\n }\n }\n },\n { immediate: true }\n)\n\nonBeforeUnmount(() => {\n pullParent()\n unlockBodyScroll()\n window.removeEventListener('keydown', handleKeydown, { capture: true })\n})\n</script>\n\n<template>\n <Teleport to=\"body\">\n <Transition name=\"ui-drawer-fade\">\n <div\n v-if=\"shouldRender\"\n v-show=\"isVisible\"\n class=\"fixed inset-0 pointer-events-auto\"\n :style=\"{ zIndex }\"\n @mousemove.stop\n @mousedown.stop\n @mouseup.stop\n @pointermove.stop\n @pointerdown.stop\n @pointerup.stop\n @wheel.stop\n @click.stop\n @dblclick.stop\n @contextmenu.stop\n >\n <div v-if=\"modal\" class=\"absolute inset-0 bg-zinc-900/10 backdrop-blur-sm\" @click=\"closeOnClickModal && requestClose()\"></div>\n\n <Transition :name=\"transitionName\" appear>\n <aside v-show=\"isVisible\" :class=\"['ui-drawer-panel', drawerPanel({ direction })]\" :style=\"panelStyle\" data-ui-drawer=\"true\">\n <header v-if=\"withHeader\" class=\"flex min-h-12 items-center justify-between gap-3 border-b border-zinc-100/50 px-4 py-3 dark:border-zinc-800/50\">\n <slot name=\"header\">\n <h3 class=\"min-w-0 truncate text-xs font-bold uppercase tracking-widest text-zinc-500\">\n <slot name=\"icon\"></slot>\n {{ title }}\n </h3>\n </slot>\n <button v-if=\"showClose\" type=\"button\" aria-label=\"关闭\" class=\"group flex size-7 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-brand-200 dark:hover:bg-brand-500\" @click=\"requestClose\">\n <span class=\"i-lucide:x size-4 text-zinc-400 group-hover:text-brand-600 dark:group-hover:text-brand-200\"></span>\n </button>\n </header>\n\n <div class=\"min-h-0 flex-1 overflow-auto\" :class=\"bodyClass\">\n <slot v-if=\"!destroyOnClose || isVisible\"></slot>\n </div>\n\n <footer v-if=\"$slots.footer\" class=\"flex justify-end gap-2 border-t border-zinc-100/50 bg-zinc-50/30 px-3 py-2.5 dark:border-zinc-800/50 dark:bg-zinc-800/30\">\n <slot name=\"footer\"></slot>\n </footer>\n </aside>\n </Transition>\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<style scoped>\n.ui-drawer-fade-enter-active,\n.ui-drawer-fade-leave-active {\n transition: opacity 160ms ease;\n}\n\n.ui-drawer-fade-enter-from,\n.ui-drawer-fade-leave-to {\n opacity: 0;\n}\n\n.ui-drawer-panel {\n transition: transform 180ms ease;\n}\n\n.ui-drawer-rtl-enter-active,\n.ui-drawer-rtl-leave-active,\n.ui-drawer-ltr-enter-active,\n.ui-drawer-ltr-leave-active,\n.ui-drawer-ttb-enter-active,\n.ui-drawer-ttb-leave-active,\n.ui-drawer-btt-enter-active,\n.ui-drawer-btt-leave-active {\n transition: transform 180ms ease;\n}\n\n.ui-drawer-rtl-enter-from,\n.ui-drawer-rtl-leave-to {\n transform: translateX(100%);\n}\n\n.ui-drawer-ltr-enter-from,\n.ui-drawer-ltr-leave-to {\n transform: translateX(-100%);\n}\n\n.ui-drawer-ttb-enter-from,\n.ui-drawer-ttb-leave-to {\n transform: translateY(-100%);\n}\n\n.ui-drawer-btt-enter-from,\n.ui-drawer-btt-leave-to {\n transform: translateY(100%);\n}\n</style>\n","<script setup lang=\"ts\">\nimport { computed, inject, nextTick, onBeforeUnmount, provide, ref, watch, type CSSProperties } from 'vue'\n\nimport { drawerContextKey, drawerPanel, type DrawerDirection, type DrawerPush, type DrawerPushDistance } from '.'\n\ntype DrawerBeforeClose = (done: () => void) => void | boolean | Promise<void | boolean>\n\nconst DEFAULT_PUSH_DISTANCE = 180\n\nconst props = withDefaults(\n defineProps<{\n /** modelValue 控制抽屉显示状态,兼容 Element Plus v-model。 */\n modelValue?: boolean\n /** visible 控制抽屉显示状态,兼容本地 Modal 的 v-model:visible。 */\n visible?: boolean\n /** title 是默认标题文本。 */\n title?: string\n /** direction 是抽屉弹出方向,可选 rtl/ltr/ttb/btt。 */\n direction?: DrawerDirection\n /** size 是抽屉宽度或高度,数字按 px 处理。 */\n size?: number | string\n /** withHeader 表示是否渲染头部区域。 */\n withHeader?: boolean\n /** showClose 表示是否展示关闭按钮。 */\n showClose?: boolean\n /** closeOnClickModal 表示是否允许点击遮罩关闭。 */\n closeOnClickModal?: boolean\n /** closeOnPressEscape 表示是否允许 Esc 关闭。 */\n closeOnPressEscape?: boolean\n /** beforeClose 在关闭前执行,返回 false 或不调用 done 可阻止关闭。 */\n beforeClose?: DrawerBeforeClose\n /** destroyOnClose 表示关闭后是否销毁默认插槽内容。 */\n destroyOnClose?: boolean\n /** modal 表示是否展示遮罩。 */\n modal?: boolean\n /** lockScroll 表示打开时是否锁定 body 滚动。 */\n lockScroll?: boolean\n /** zIndex 控制抽屉层级。 */\n zIndex?: number | string\n /** bodyClass 是正文区域额外类名。 */\n bodyClass?: string\n /** push 控制多层 Drawer 打开时父级抽屉是否被推动。 */\n push?: DrawerPush\n }>(),\n {\n modelValue: undefined,\n visible: undefined,\n title: '',\n direction: 'rtl',\n size: '30%',\n withHeader: true,\n showClose: true,\n closeOnClickModal: true,\n closeOnPressEscape: true,\n beforeClose: undefined,\n destroyOnClose: false,\n modal: true,\n lockScroll: true,\n zIndex: 2000,\n bodyClass: '',\n push: true\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: boolean): void\n (e: 'update:visible', value: boolean): void\n (e: 'open'): void\n (e: 'opened'): void\n (e: 'close'): void\n (e: 'closed'): void\n}>()\n\nconst isVisible = computed(() => props.modelValue ?? props.visible ?? false)\nconst shouldRender = ref(isVisible.value)\nconst drawerId = Symbol('ui-drawer')\nconst parentDrawer = inject(drawerContextKey, null)\nconst pushedChildIds = ref<symbol[]>([])\nconst isHorizontal = computed(() => props.direction === 'rtl' || props.direction === 'ltr')\nconst normalizedSize = computed(() => (typeof props.size === 'number' ? `${props.size}px` : props.size))\nconst pushDistance = computed<DrawerPushDistance>(() => {\n if (props.push === false) return 0\n if (typeof props.push === 'object' && props.push.distance !== undefined) return props.push.distance\n if (parentDrawer) return parentDrawer.pushDistance.value\n return DEFAULT_PUSH_DISTANCE\n})\nconst normalizedPushDistance = computed(() => normalizeCssSize(pushDistance.value))\nconst pushTransform = computed(() => {\n if (!pushedChildIds.value.length) return undefined\n\n const distance = normalizedPushDistance.value\n if (distance === '0px') return undefined\n\n switch (props.direction) {\n case 'rtl':\n return `translateX(-${distance})`\n case 'ltr':\n return `translateX(${distance})`\n case 'ttb':\n return `translateY(${distance})`\n case 'btt':\n return `translateY(-${distance})`\n default:\n return undefined\n }\n})\nconst panelStyle = computed<CSSProperties>(() => ({\n width: isHorizontal.value ? normalizedSize.value : undefined,\n height: isHorizontal.value ? undefined : normalizedSize.value,\n transform: pushTransform.value\n}))\nconst transitionName = computed(() => `ui-drawer-${props.direction}`)\nlet previousBodyOverflow = ''\nlet hasOpened = false\nlet hasPushedParent = false\n\nfunction normalizeCssSize(value: DrawerPushDistance) {\n return typeof value === 'number' ? `${value}px` : value\n}\n\nfunction syncVisible(value: boolean) {\n emit('update:modelValue', value)\n emit('update:visible', value)\n}\n\nfunction closeNow() {\n syncVisible(false)\n emit('close')\n}\n\nasync function requestClose() {\n if (!props.beforeClose) {\n closeNow()\n return\n }\n\n let doneCalled = false\n const done = () => {\n doneCalled = true\n closeNow()\n }\n\n const result = await props.beforeClose(done)\n if (result === false || doneCalled) return\n if (props.beforeClose.length === 0 || result !== undefined) closeNow()\n}\n\nfunction handleKeydown(event: KeyboardEvent) {\n if (!isVisible.value || !props.closeOnPressEscape || event.key !== 'Escape') return\n event.preventDefault()\n event.stopPropagation()\n void requestClose()\n}\n\nfunction lockBodyScroll() {\n if (!props.lockScroll || typeof document === 'undefined') return\n previousBodyOverflow = document.body.style.overflow\n document.body.style.overflow = 'hidden'\n}\n\nfunction unlockBodyScroll() {\n if (!props.lockScroll || typeof document === 'undefined') return\n document.body.style.overflow = previousBodyOverflow\n}\n\nfunction pushChild(id: symbol) {\n if (props.push === false || pushedChildIds.value.includes(id)) return\n pushedChildIds.value = [...pushedChildIds.value, id]\n}\n\nfunction pullChild(id: symbol) {\n if (!pushedChildIds.value.includes(id)) return\n pushedChildIds.value = pushedChildIds.value.filter((childId) => childId !== id)\n}\n\nfunction pushParent() {\n if (!parentDrawer || hasPushedParent) return\n parentDrawer.push(drawerId)\n hasPushedParent = true\n}\n\nfunction pullParent() {\n if (!parentDrawer || !hasPushedParent) return\n parentDrawer.pull(drawerId)\n hasPushedParent = false\n}\n\nprovide(drawerContextKey, {\n pushDistance,\n push: pushChild,\n pull: pullChild\n})\n\nwatch(\n isVisible,\n (visible) => {\n if (visible) {\n shouldRender.value = true\n hasOpened = true\n pushParent()\n lockBodyScroll()\n emit('open')\n window.addEventListener('keydown', handleKeydown, { capture: true })\n nextTick(() => emit('opened'))\n } else {\n pullParent()\n pushedChildIds.value = []\n unlockBodyScroll()\n window.removeEventListener('keydown', handleKeydown, { capture: true })\n if (hasOpened) emit('closed')\n if (props.destroyOnClose) {\n window.setTimeout(() => {\n if (!isVisible.value) shouldRender.value = false\n }, 180)\n }\n }\n },\n { immediate: true }\n)\n\nonBeforeUnmount(() => {\n pullParent()\n unlockBodyScroll()\n window.removeEventListener('keydown', handleKeydown, { capture: true })\n})\n</script>\n\n<template>\n <Teleport to=\"body\">\n <Transition name=\"ui-drawer-fade\">\n <div\n v-if=\"shouldRender\"\n v-show=\"isVisible\"\n class=\"fixed inset-0 pointer-events-auto\"\n :style=\"{ zIndex }\"\n @mousemove.stop\n @mousedown.stop\n @mouseup.stop\n @pointermove.stop\n @pointerdown.stop\n @pointerup.stop\n @wheel.stop\n @click.stop\n @dblclick.stop\n @contextmenu.stop\n >\n <div v-if=\"modal\" class=\"absolute inset-0 bg-zinc-900/10 backdrop-blur-sm\" @click=\"closeOnClickModal && requestClose()\"></div>\n\n <Transition :name=\"transitionName\" appear>\n <aside v-show=\"isVisible\" :class=\"['ui-drawer-panel', drawerPanel({ direction })]\" :style=\"panelStyle\" data-ui-drawer=\"true\">\n <header v-if=\"withHeader\" class=\"flex min-h-12 items-center justify-between gap-3 border-b border-zinc-100/50 px-4 py-3 dark:border-zinc-800/50\">\n <slot name=\"header\">\n <h3 class=\"min-w-0 truncate text-xs font-bold uppercase tracking-widest text-zinc-500\">\n <slot name=\"icon\"></slot>\n {{ title }}\n </h3>\n </slot>\n <button v-if=\"showClose\" type=\"button\" aria-label=\"关闭\" class=\"group flex size-7 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-brand-200 dark:hover:bg-brand-500\" @click=\"requestClose\">\n <span class=\"i-lucide:x size-4 text-zinc-400 group-hover:text-brand-600 dark:group-hover:text-brand-200\"></span>\n </button>\n </header>\n\n <div class=\"min-h-0 flex-1 overflow-auto\" :class=\"bodyClass\">\n <slot v-if=\"!destroyOnClose || isVisible\"></slot>\n </div>\n\n <footer v-if=\"$slots.footer\" class=\"flex justify-end gap-2 border-t border-zinc-100/50 bg-zinc-50/30 px-3 py-2.5 dark:border-zinc-800/50 dark:bg-zinc-800/30\">\n <slot name=\"footer\"></slot>\n </footer>\n </aside>\n </Transition>\n </div>\n </Transition>\n </Teleport>\n</template>\n\n<style scoped>\n.ui-drawer-fade-enter-active,\n.ui-drawer-fade-leave-active {\n transition: opacity 160ms ease;\n}\n\n.ui-drawer-fade-enter-from,\n.ui-drawer-fade-leave-to {\n opacity: 0;\n}\n\n.ui-drawer-panel {\n transition: transform 180ms ease;\n}\n\n.ui-drawer-rtl-enter-active,\n.ui-drawer-rtl-leave-active,\n.ui-drawer-ltr-enter-active,\n.ui-drawer-ltr-leave-active,\n.ui-drawer-ttb-enter-active,\n.ui-drawer-ttb-leave-active,\n.ui-drawer-btt-enter-active,\n.ui-drawer-btt-leave-active {\n transition: transform 180ms ease;\n}\n\n.ui-drawer-rtl-enter-from,\n.ui-drawer-rtl-leave-to {\n transform: translateX(100%);\n}\n\n.ui-drawer-ltr-enter-from,\n.ui-drawer-ltr-leave-to {\n transform: translateX(-100%);\n}\n\n.ui-drawer-ttb-enter-from,\n.ui-drawer-ttb-leave-to {\n transform: translateY(-100%);\n}\n\n.ui-drawer-btt-enter-from,\n.ui-drawer-btt-leave-to {\n transform: translateY(100%);\n}\n</style>\n","import { cva } from 'class-variance-authority'\nimport type { VariantProps } from 'class-variance-authority'\nimport type { ComputedRef, InjectionKey } from 'vue'\n\nexport { default as Drawer } from './Drawer.vue'\n\n/** DrawerDirection 是抽屉弹出方向,命名兼容 Element Plus。 */\nexport type DrawerDirection = 'rtl' | 'ltr' | 'ttb' | 'btt'\n\n/** DrawerPushDistance 是多层 Drawer 推动父级抽屉的距离。 */\nexport type DrawerPushDistance = number | string\n\n/** DrawerPush 控制多层 Drawer 打开时父级抽屉是否被推动。 */\nexport type DrawerPush = boolean | { distance?: DrawerPushDistance }\n\nexport interface DrawerContext {\n pushDistance: ComputedRef<DrawerPushDistance>\n push: (id: symbol) => void\n pull: (id: symbol) => void\n}\n\nexport const drawerContextKey: InjectionKey<DrawerContext> = Symbol('ui-drawer-context')\n\n/** drawerPanel 定义 Drawer 面板基础位置和布局。 */\nexport const drawerPanel = cva('fixed z-10 flex bg-white/95 shadow-2xl backdrop-blur-md dark:bg-zinc-900/95', {\n variants: {\n direction: {\n rtl: 'inset-y-0 right-0 flex-col border-l border-white/20 dark:border-zinc-800/50',\n ltr: 'inset-y-0 left-0 flex-col border-r border-white/20 dark:border-zinc-800/50',\n ttb: 'inset-x-0 top-0 flex-col border-b border-white/20 dark:border-zinc-800/50',\n btt: 'inset-x-0 bottom-0 flex-col border-t border-white/20 dark:border-zinc-800/50'\n }\n },\n defaultVariants: {\n direction: 'rtl'\n }\n})\n\n/** DrawerProps 是 drawerPanel 变体推导出的组件属性类型。 */\nexport type DrawerProps = VariantProps<typeof drawerPanel>\n"],"mappings":";;;;;;;;;;GAOM,IAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE9B,IAAM,IAAQ,GAuDR,IAAO,GASP,IAAY,QAAe,EAAM,cAAc,EAAM,WAAW,EAAK,GACrE,IAAe,EAAI,EAAU,KAAK,GAClC,IAAW,OAAO,W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,CAAA,CAAA,IAAA,EAAA,IAAA,EAAA,CAAA,CAAA;;;;yCEnNZ,IAAgD,OAAO,mBAAmB,GAG1E,IAAc,EAAI,+EAA+E;CAC5G,UAAU,EACR,WAAW;EACT,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;CACP,EACF;CACA,iBAAiB,EACf,WAAW,MACb;AACF,CAAC"}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
|
|
2
|
+
import { Fragment as t, Teleport as n, Transition as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createVNode as l, defineComponent as u, mergeModels as d, nextTick as f, normalizeClass as p, normalizeStyle as m, onMounted as ee, onUnmounted as h, openBlock as g, ref as _, renderList as te, renderSlot as v, unref as ne, useModel as re, useSlots as ie, useTemplateRef as y, vShow as ae, watch as oe, withCtx as se, withDirectives as ce } from "vue";
|
|
3
|
+
import le from "simplebar-vue";
|
|
4
|
+
import "simplebar-vue/dist/simplebar.min.css";
|
|
5
|
+
//#region src/dropdown/Dropdown.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var ue = ["data-placement"], de = [
|
|
7
|
+
"data-selected",
|
|
8
|
+
"onMouseenter",
|
|
9
|
+
"onClick"
|
|
10
|
+
], b = 4, x = 8, S = 8, C = /*#__PURE__*/ e(/* @__PURE__ */ u({
|
|
11
|
+
__name: "Dropdown",
|
|
12
|
+
props: /*@__PURE__*/ d({
|
|
13
|
+
items: {},
|
|
14
|
+
valueKey: {},
|
|
15
|
+
align: { default: "left" },
|
|
16
|
+
placement: {},
|
|
17
|
+
trigger: { default: "click" },
|
|
18
|
+
arrow: {
|
|
19
|
+
type: [Boolean, Object],
|
|
20
|
+
default: !1
|
|
21
|
+
},
|
|
22
|
+
autoAdjustOverflow: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: !0
|
|
25
|
+
},
|
|
26
|
+
disabled: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: !1
|
|
29
|
+
},
|
|
30
|
+
destroyOnHidden: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: !0
|
|
33
|
+
},
|
|
34
|
+
closeOnSelect: { type: Boolean },
|
|
35
|
+
minWidth: { default: "128px" },
|
|
36
|
+
width: {},
|
|
37
|
+
maxHeight: { default: "320px" },
|
|
38
|
+
contentClass: {},
|
|
39
|
+
popupStyle: {},
|
|
40
|
+
focusOnOpen: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: !0
|
|
43
|
+
},
|
|
44
|
+
fullWidth: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: !1
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
value: {},
|
|
50
|
+
valueModifiers: {},
|
|
51
|
+
open: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: !1
|
|
54
|
+
},
|
|
55
|
+
openModifiers: {}
|
|
56
|
+
}),
|
|
57
|
+
emits: /*@__PURE__*/ d([
|
|
58
|
+
"select",
|
|
59
|
+
"openChange",
|
|
60
|
+
"visible-change",
|
|
61
|
+
"visibleChange"
|
|
62
|
+
], ["update:value", "update:open"]),
|
|
63
|
+
setup(e, { expose: u, emit: d }) {
|
|
64
|
+
let C = e, w = re(e, "value"), T = re(e, "open"), fe = ie(), E = y("dropdownRef"), D = y("menuContainerRef"), pe = y("menuRef"), O = _(-1), k = _(!1), A = _(null), j = _(C.maxHeight), M = _(null), N = 0, P = 0, F = !1, me = "trigger", I = null, L, R = _({
|
|
65
|
+
top: 0,
|
|
66
|
+
bottom: 0,
|
|
67
|
+
left: 0,
|
|
68
|
+
right: 0,
|
|
69
|
+
width: 0,
|
|
70
|
+
height: 0
|
|
71
|
+
}), z = _(C.placement ?? (C.align === "right" ? "bottomRight" : "bottomLeft")), B = _(null), he = () => {
|
|
72
|
+
let e = E.value;
|
|
73
|
+
if (!e) return null;
|
|
74
|
+
let t = e.getBoundingClientRect();
|
|
75
|
+
return {
|
|
76
|
+
top: t.top,
|
|
77
|
+
bottom: t.bottom,
|
|
78
|
+
left: t.left,
|
|
79
|
+
right: t.right,
|
|
80
|
+
width: t.width,
|
|
81
|
+
height: t.height
|
|
82
|
+
};
|
|
83
|
+
}, ge = () => {
|
|
84
|
+
let e = he();
|
|
85
|
+
e && (R.value = e);
|
|
86
|
+
}, V = (e) => {
|
|
87
|
+
let t = e?.match(/^(\d+(?:\.\d+)?)px$/);
|
|
88
|
+
return t ? Number(t[1]) : void 0;
|
|
89
|
+
}, H = () => C.placement ?? (C.align === "right" ? "bottomRight" : "bottomLeft"), _e = i(() => Array.isArray(C.trigger) ? C.trigger : [C.trigger]), ve = i(() => T.value || !C.destroyOnHidden), ye = i(() => !!C.arrow), be = i(() => typeof C.arrow == "object" && !!C.arrow.pointAtCenter), xe = (e) => e || {}, Se = i(() => xe(C.popupStyle)), U = (e) => e.endsWith("Left") ? "left" : e.endsWith("Right") ? "right" : "center", W = (e) => e.startsWith("top") ? "top" : "bottom", Ce = (e) => {
|
|
90
|
+
let t = U(e), n = e.startsWith("top");
|
|
91
|
+
return t === "left" ? n ? "bottomLeft" : "topLeft" : t === "right" ? n ? "bottomRight" : "topRight" : n ? "bottom" : "top";
|
|
92
|
+
}, we = (e, t, n) => {
|
|
93
|
+
if (B.value) return B.value.left;
|
|
94
|
+
let r = U(e);
|
|
95
|
+
return r === "center" ? t.left + (t.width - n) / 2 : r === "right" ? t.right - n : t.left;
|
|
96
|
+
}, Te = () => {
|
|
97
|
+
if (!B.value) return R.value;
|
|
98
|
+
let { left: e, top: t } = B.value;
|
|
99
|
+
return {
|
|
100
|
+
top: t,
|
|
101
|
+
bottom: t,
|
|
102
|
+
left: e,
|
|
103
|
+
right: e,
|
|
104
|
+
width: 0,
|
|
105
|
+
height: 0
|
|
106
|
+
};
|
|
107
|
+
}, G = (e, t, n) => Math.max(t, Math.min(e, n)), Ee = (e, t, n) => C.autoAdjustOverflow ? G(e, x, Math.max(x, n - t - x)) : e, De = (e, t) => {
|
|
108
|
+
let n = B.value ? B.value.left : R.value.left + R.value.width / 2;
|
|
109
|
+
return be.value ? G(n - e - S / 2, S, Math.max(S, t - S * 2)) : U(z.value) === "center" ? G(t / 2 - S / 2, S, Math.max(S, t - S * 2)) : G(n - e - S / 2, S, Math.max(S, t - S * 2));
|
|
110
|
+
}, Oe = i(() => {
|
|
111
|
+
let e = Te(), t = M.value ?? V(C.width) ?? V(C.minWidth) ?? 0, n = typeof window > "u" ? 0 : window.innerWidth, r = t || e.width || V(C.minWidth) || 128, i = we(z.value, e, r), a = {
|
|
112
|
+
position: "fixed",
|
|
113
|
+
top: `${A.value ?? e.bottom + b}px`,
|
|
114
|
+
left: `${Ee(i, r, n)}px`,
|
|
115
|
+
minWidth: C.minWidth,
|
|
116
|
+
maxWidth: C.autoAdjustOverflow ? `calc(100vw - ${x * 2}px)` : "none",
|
|
117
|
+
zIndex: 2e3
|
|
118
|
+
};
|
|
119
|
+
return C.width && (a.width = C.width), a;
|
|
120
|
+
}), ke = i(() => {
|
|
121
|
+
let e = M.value ?? V(C.width) ?? V(C.minWidth) ?? R.value.width ?? 128;
|
|
122
|
+
return { left: `${De(parseFloat(String(Oe.value.left || "0")), e)}px` };
|
|
123
|
+
}), Ae = i(() => W(z.value) === "top" ? "bottom-[-4px] border-b border-r" : "top-[-4px] border-l border-t"), je = i(() => {
|
|
124
|
+
let e = W(z.value), t = U(z.value);
|
|
125
|
+
return `${t === "left" ? "left" : t === "right" ? "right" : "center"} ${e === "top" ? "bottom" : "top"}`;
|
|
126
|
+
}), Me = i(() => !!fe.default), Ne = i(() => ({ maxHeight: j.value })), K = d, q = () => {
|
|
127
|
+
let e = pe.value;
|
|
128
|
+
return e ? e instanceof HTMLElement ? e : e.$el || null : null;
|
|
129
|
+
}, J = (e, t = "trigger") => {
|
|
130
|
+
C.disabled && e || (me = t, T.value = e);
|
|
131
|
+
}, Pe = () => {
|
|
132
|
+
B.value = null, z.value = H(), J(!0, "trigger");
|
|
133
|
+
}, Fe = () => {
|
|
134
|
+
J(!1, "trigger");
|
|
135
|
+
}, Ie = () => {
|
|
136
|
+
B.value = null, z.value = H(), J(!T.value, "trigger");
|
|
137
|
+
}, Y = () => {
|
|
138
|
+
L !== void 0 && (window.clearTimeout(L), L = void 0);
|
|
139
|
+
}, Le = async (e = !1) => {
|
|
140
|
+
let t = ++P;
|
|
141
|
+
if (!T.value) return;
|
|
142
|
+
j.value = C.maxHeight, await f();
|
|
143
|
+
let n = D.value;
|
|
144
|
+
if (t !== P || !T.value || !n) return;
|
|
145
|
+
if (e) {
|
|
146
|
+
let e = he();
|
|
147
|
+
if (!e) return;
|
|
148
|
+
R.value = e;
|
|
149
|
+
}
|
|
150
|
+
let r = Te(), i = z.value, a = W(i), o = window.innerHeight - x, s = a === "top" ? r.top - n.offsetHeight - b : r.bottom + b, c = n.offsetHeight;
|
|
151
|
+
if (M.value = n.offsetWidth, !C.autoAdjustOverflow) {
|
|
152
|
+
A.value = s;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
let l = r.bottom + b + c <= o, u = r.top - c - b >= 8;
|
|
156
|
+
if (a === "bottom" && (l || !u)) {
|
|
157
|
+
A.value = r.bottom + b;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (a === "top" && (u || !l)) {
|
|
161
|
+
A.value = r.top - c - b;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
z.value = Ce(i);
|
|
165
|
+
let d = W(z.value), p = d === "top" ? r.top - c - b : r.bottom + b;
|
|
166
|
+
if (p >= 8 && p + c <= o) {
|
|
167
|
+
A.value = p;
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
let m = q(), ee = Me.value ? 0 : Math.max(0, c - (m?.offsetHeight || 0)), h = Math.max(0, o - (r.bottom + b)), g = Math.max(0, r.top - b - 8), _ = d === "top" ? g >= h : g > h;
|
|
171
|
+
z.value = _ ? z.value.endsWith("Right") ? "topRight" : z.value.endsWith("Left") ? "topLeft" : "top" : z.value.endsWith("Right") ? "bottomRight" : z.value.endsWith("Left") ? "bottomLeft" : "bottom";
|
|
172
|
+
let te = _ ? g : Math.max(h, o - 8);
|
|
173
|
+
if (j.value = `${Math.max(0, Math.floor(te - ee))}px`, await f(), t !== P || !T.value) return;
|
|
174
|
+
let v = n.offsetHeight, ne = r.bottom + b;
|
|
175
|
+
A.value = _ ? Math.max(8, r.top - v - b) : Math.min(ne, o - v);
|
|
176
|
+
}, X = (e = {}) => {
|
|
177
|
+
T.value && (F ||= !!e.refreshTriggerBounds, N && cancelAnimationFrame(N), N = requestAnimationFrame(() => {
|
|
178
|
+
N = 0;
|
|
179
|
+
let e = F;
|
|
180
|
+
F = !1, Le(e);
|
|
181
|
+
}));
|
|
182
|
+
}, Z = () => X({ refreshTriggerBounds: !0 }), Re = (e) => {
|
|
183
|
+
let t = e.target;
|
|
184
|
+
t instanceof Node && D.value?.contains(t) || Z();
|
|
185
|
+
}, Q = (e) => !C.disabled && _e.value.includes(e), ze = (e) => e instanceof Node ? !!(E.value?.contains(e) || D.value?.contains(e)) : !1, Be = () => {
|
|
186
|
+
Q("click") && Ie();
|
|
187
|
+
}, Ve = (e) => {
|
|
188
|
+
Q("contextMenu") && (e.preventDefault(), B.value = {
|
|
189
|
+
left: e.clientX,
|
|
190
|
+
top: e.clientY
|
|
191
|
+
}, z.value = H(), J(!0, "trigger"));
|
|
192
|
+
}, He = () => {
|
|
193
|
+
Q("hover") && (Y(), L = window.setTimeout(() => {
|
|
194
|
+
L = void 0, Pe();
|
|
195
|
+
}, 80));
|
|
196
|
+
}, Ue = (e) => {
|
|
197
|
+
Q("hover") && (L !== void 0 && (window.clearTimeout(L), L = void 0), !ze(e.relatedTarget) && Fe());
|
|
198
|
+
}, We = (e) => C.valueKey ? e[C.valueKey] : e, Ge = (e) => C.items ? C.items.findIndex((t) => {
|
|
199
|
+
let n = We(t);
|
|
200
|
+
return Array.isArray(e) ? e.includes(n) : n === e;
|
|
201
|
+
}) : -1, $ = (e) => {
|
|
202
|
+
let t = We(e);
|
|
203
|
+
return Array.isArray(w.value) ? w.value.includes(t) : w.value === t;
|
|
204
|
+
};
|
|
205
|
+
oe(T, (e) => {
|
|
206
|
+
k.value = !1, K("openChange", e, { source: me }), K("visible-change", e), K("visibleChange", e), e ? (O.value = Ge(w.value), B.value || (z.value = H()), A.value = null, M.value = null, B.value || ge(), f(() => {
|
|
207
|
+
X();
|
|
208
|
+
let e = q();
|
|
209
|
+
if (C.focusOnOpen && e?.focus(), O.value >= 0) {
|
|
210
|
+
let t = e?.querySelectorAll(".dropdown-item-wrapper")?.[O.value];
|
|
211
|
+
t && "scrollIntoView" in t && typeof t.scrollIntoView == "function" && t.scrollIntoView({ block: "nearest" });
|
|
212
|
+
}
|
|
213
|
+
})) : (Y(), B.value = null, F = !1, A.value = null, M.value = null, j.value = C.maxHeight);
|
|
214
|
+
}), oe(() => C.items, () => {
|
|
215
|
+
k.value = !1;
|
|
216
|
+
}), oe(() => [
|
|
217
|
+
C.items,
|
|
218
|
+
C.width,
|
|
219
|
+
C.minWidth,
|
|
220
|
+
C.maxHeight,
|
|
221
|
+
C.placement,
|
|
222
|
+
C.align
|
|
223
|
+
], () => {
|
|
224
|
+
O.value = Ge(w.value), z.value = H(), j.value = C.maxHeight, X();
|
|
225
|
+
});
|
|
226
|
+
let Ke = (e) => {
|
|
227
|
+
if (!T.value || !C.items?.length) return !1;
|
|
228
|
+
let t = C.items, n = t.length;
|
|
229
|
+
if (e.preventDefault(), e.stopPropagation(), e.code === "ArrowDown") k.value = !0, O.value = (O.value + 1) % n;
|
|
230
|
+
else if (e.code === "ArrowUp") k.value = !0, O.value = (O.value - 1 + n) % n;
|
|
231
|
+
else if (e.code === "PageDown") k.value = !0, O.value = Math.min(O.value + 5, n - 1);
|
|
232
|
+
else if (e.code === "PageUp") k.value = !0, O.value = Math.max(O.value - 5, 0);
|
|
233
|
+
else if (e.code === "Enter" || e.code === "Space") return k.value = !0, O.value >= 0 ? (Je(t[O.value]), !0) : !1;
|
|
234
|
+
else if (e.code === "Escape") return T.value = !1, !0;
|
|
235
|
+
return O.value >= 0 && f(() => {
|
|
236
|
+
let e = q()?.querySelectorAll(".dropdown-item-wrapper")[O.value];
|
|
237
|
+
e && "scrollIntoView" in e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
|
|
238
|
+
}), !0;
|
|
239
|
+
}, qe = (e) => {
|
|
240
|
+
O.value = e, k.value = !1;
|
|
241
|
+
}, Je = (e) => {
|
|
242
|
+
if (e?.disabled) return;
|
|
243
|
+
let t = Array.isArray(w.value), n = We(e);
|
|
244
|
+
t && Array.isArray(w.value) ? w.value.indexOf(n) === -1 ? w.value = [...w.value, n] : w.value = w.value.filter((e) => e !== n) : (w.value = n, (C.closeOnSelect ?? !0) && J(!1, "menu")), t && C.closeOnSelect && J(!1, "menu"), K("select", e);
|
|
245
|
+
}, Ye = (e) => {
|
|
246
|
+
let t = e.target, n = E.value && !E.value.contains(t), r = D.value && !D.value.contains(t);
|
|
247
|
+
n && r && Fe();
|
|
248
|
+
};
|
|
249
|
+
return ee(() => {
|
|
250
|
+
ge(), T.value && (O.value = Ge(w.value), z.value = H(), X()), document.addEventListener("pointerdown", Ye, !0), document.addEventListener("scroll", Re, !0), window.addEventListener("resize", Z), typeof ResizeObserver < "u" && E.value && (I = new ResizeObserver(() => X()), I.observe(E.value));
|
|
251
|
+
}), h(() => {
|
|
252
|
+
Y(), document.removeEventListener("pointerdown", Ye, !0), document.removeEventListener("scroll", Re, !0), window.removeEventListener("resize", Z), I?.disconnect(), N && cancelAnimationFrame(N);
|
|
253
|
+
}), u({
|
|
254
|
+
close: () => T.value = !1,
|
|
255
|
+
open: () => T.value = !0,
|
|
256
|
+
handleKeyDown: Ke
|
|
257
|
+
}), (i, u) => (g(), s("div", {
|
|
258
|
+
ref_key: "dropdownRef",
|
|
259
|
+
ref: E,
|
|
260
|
+
class: p([
|
|
261
|
+
"relative inline-block",
|
|
262
|
+
e.fullWidth ? "w-full min-w-0" : "",
|
|
263
|
+
{ "pointer-events-none opacity-50": e.disabled }
|
|
264
|
+
]),
|
|
265
|
+
onMouseenter: He,
|
|
266
|
+
onMouseleave: Ue,
|
|
267
|
+
onContextmenu: Ve
|
|
268
|
+
}, [c("div", {
|
|
269
|
+
class: p(["h-full flex items-center", e.fullWidth ? "w-full min-w-0" : ""]),
|
|
270
|
+
onClick: Be
|
|
271
|
+
}, [v(i.$slots, "trigger", { open: T.value }, void 0, !0)], 2), (g(), a(n, { to: "body" }, [l(r, { name: "ui-dropdown-motion" }, {
|
|
272
|
+
default: se(() => [ve.value ? ce((g(), s("div", {
|
|
273
|
+
key: 0,
|
|
274
|
+
ref_key: "menuContainerRef",
|
|
275
|
+
ref: D,
|
|
276
|
+
class: p(["fixed bg-primary border border-medium shadow-xl rounded-lg outline-none overflow-hidden", e.contentClass]),
|
|
277
|
+
style: m([
|
|
278
|
+
Oe.value,
|
|
279
|
+
{ transformOrigin: je.value },
|
|
280
|
+
Se.value
|
|
281
|
+
]),
|
|
282
|
+
"data-placement": z.value,
|
|
283
|
+
onMouseenter: He,
|
|
284
|
+
onMouseleave: Ue
|
|
285
|
+
}, [
|
|
286
|
+
ye.value ? (g(), s("span", {
|
|
287
|
+
key: 0,
|
|
288
|
+
class: p(["absolute z-1 size-2 rotate-45 border-medium bg-primary", Ae.value]),
|
|
289
|
+
style: m(ke.value)
|
|
290
|
+
}, null, 6)) : o("", !0),
|
|
291
|
+
v(i.$slots, "header", {}, void 0, !0),
|
|
292
|
+
i.$slots.default ? v(i.$slots, "default", { key: 1 }, void 0, !0) : (g(), a(ne(le), {
|
|
293
|
+
key: 2,
|
|
294
|
+
ref_key: "menuRef",
|
|
295
|
+
ref: pe,
|
|
296
|
+
tabindex: "-1",
|
|
297
|
+
role: "menu",
|
|
298
|
+
onKeydown: Ke,
|
|
299
|
+
class: "outline-none",
|
|
300
|
+
style: m(Ne.value)
|
|
301
|
+
}, {
|
|
302
|
+
default: se(() => [(g(!0), s(t, null, te(e.items, (e, t) => (g(), s("div", {
|
|
303
|
+
key: t,
|
|
304
|
+
class: p(["dropdown-item-wrapper", {
|
|
305
|
+
"is-active": k.value && t === O.value,
|
|
306
|
+
"is-selected": $(e),
|
|
307
|
+
"pointer-events-none opacity-50": e.disabled
|
|
308
|
+
}]),
|
|
309
|
+
"data-selected": $(e) ? "true" : void 0,
|
|
310
|
+
onMouseenter: (e) => qe(t),
|
|
311
|
+
onClick: (t) => Je(e)
|
|
312
|
+
}, [v(i.$slots, "item", {
|
|
313
|
+
item: e,
|
|
314
|
+
index: t,
|
|
315
|
+
active: k.value && t === O.value,
|
|
316
|
+
selected: $(e)
|
|
317
|
+
}, void 0, !0)], 42, de))), 128))]),
|
|
318
|
+
_: 3
|
|
319
|
+
}, 8, ["style"])),
|
|
320
|
+
v(i.$slots, "footer", {}, void 0, !0)
|
|
321
|
+
], 46, ue)), [[ae, T.value]]) : o("", !0)]),
|
|
322
|
+
_: 3
|
|
323
|
+
})]))], 34));
|
|
324
|
+
}
|
|
325
|
+
}), [["__scopeId", "data-v-6e1f537e"]]);
|
|
326
|
+
//#endregion
|
|
327
|
+
export { C as t };
|
|
328
|
+
|
|
329
|
+
//# sourceMappingURL=dropdown-0l967g7D.js.map
|