@guoyg578/k-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/components/KAlert.js +7 -0
- package/dist/components/KAlert.vue.d.ts +40 -0
- package/dist/components/KAlert.vue_vue_type_script_setup_true_lang.js +76 -0
- package/dist/components/KAvatar.js +7 -0
- package/dist/components/KAvatar.vue.d.ts +15 -0
- package/dist/components/KAvatar.vue_vue_type_script_setup_true_lang.js +53 -0
- package/dist/components/KAvatarGroup.js +7 -0
- package/dist/components/KAvatarGroup.vue.d.ts +18 -0
- package/dist/components/KAvatarGroup.vue_vue_type_script_setup_true_lang.js +11 -0
- package/dist/components/KBreadcrumb.js +7 -0
- package/dist/components/KBreadcrumb.vue.d.ts +12 -0
- package/dist/components/KBreadcrumb.vue_vue_type_script_setup_true_lang.js +38 -0
- package/dist/components/KButton.js +7 -0
- package/dist/components/KButton.vue.d.ts +36 -0
- package/dist/components/KButton.vue_vue_type_script_setup_true_lang.js +50 -0
- package/dist/components/KCard.js +7 -0
- package/dist/components/KCard.vue.d.ts +33 -0
- package/dist/components/KCard.vue_vue_type_script_setup_true_lang.js +50 -0
- package/dist/components/KCarousel.js +7 -0
- package/dist/components/KCarousel.vue.d.ts +59 -0
- package/dist/components/KCarousel.vue_vue_type_script_setup_true_lang.js +141 -0
- package/dist/components/KCheckbox.js +7 -0
- package/dist/components/KCheckbox.vue.d.ts +26 -0
- package/dist/components/KCheckbox.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/KCheckboxGroup.js +7 -0
- package/dist/components/KCheckboxGroup.vue.d.ts +27 -0
- package/dist/components/KCheckboxGroup.vue_vue_type_script_setup_true_lang.js +36 -0
- package/dist/components/KCombobox.js +8 -0
- package/dist/components/KCombobox.vue.d.ts +28 -0
- package/dist/components/KCombobox.vue_vue_type_script_setup_true_lang.js +120 -0
- package/dist/components/KCommandPalette.js +7 -0
- package/dist/components/KCommandPalette.vue.d.ts +31 -0
- package/dist/components/KCommandPalette.vue_vue_type_script_setup_true_lang.js +169 -0
- package/dist/components/KConfirmDialog.js +6 -0
- package/dist/components/KConfirmDialog.vue.d.ts +3 -0
- package/dist/components/KConfirmDialog.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/KDataTable.js +7 -0
- package/dist/components/KDataTable.vue.d.ts +47 -0
- package/dist/components/KDataTable.vue_vue_type_script_setup_true_lang.js +62 -0
- package/dist/components/KDatePicker.js +6 -0
- package/dist/components/KDatePicker.vue.d.ts +19 -0
- package/dist/components/KDatePicker.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/components/KDialog.js +7 -0
- package/dist/components/KDialog.vue.d.ts +52 -0
- package/dist/components/KDialog.vue_vue_type_script_setup_true_lang.js +117 -0
- package/dist/components/KDiff.js +7 -0
- package/dist/components/KDiff.vue.d.ts +13 -0
- package/dist/components/KDiff.vue_vue_type_script_setup_true_lang.js +116 -0
- package/dist/components/KDrawer.js +7 -0
- package/dist/components/KDrawer.vue.d.ts +37 -0
- package/dist/components/KDrawer.vue_vue_type_script_setup_true_lang.js +81 -0
- package/dist/components/KDropdown.js +7 -0
- package/dist/components/KDropdown.vue.d.ts +56 -0
- package/dist/components/KDropdown.vue_vue_type_script_setup_true_lang.js +93 -0
- package/dist/components/KEmpty.js +5 -0
- package/dist/components/KEmpty.vue.d.ts +22 -0
- package/dist/components/KEmpty.vue_vue_type_script_setup_true_lang.js +30 -0
- package/dist/components/KForm.js +7 -0
- package/dist/components/KForm.vue.d.ts +38 -0
- package/dist/components/KForm.vue_vue_type_script_setup_true_lang.js +69 -0
- package/dist/components/KFormField.js +7 -0
- package/dist/components/KFormField.vue.d.ts +32 -0
- package/dist/components/KFormField.vue_vue_type_script_setup_true_lang.js +84 -0
- package/dist/components/KGridSkeleton.js +5 -0
- package/dist/components/KGridSkeleton.vue.d.ts +10 -0
- package/dist/components/KGridSkeleton.vue_vue_type_script_setup_true_lang.js +21 -0
- package/dist/components/KImage.js +7 -0
- package/dist/components/KImage.vue.d.ts +25 -0
- package/dist/components/KImage.vue_vue_type_script_setup_true_lang.js +97 -0
- package/dist/components/KImageViewer.js +7 -0
- package/dist/components/KImageViewer.vue.d.ts +14 -0
- package/dist/components/KImageViewer.vue_vue_type_script_setup_true_lang.js +108 -0
- package/dist/components/KInput.js +7 -0
- package/dist/components/KInput.vue.d.ts +43 -0
- package/dist/components/KInput.vue_vue_type_script_setup_true_lang.js +89 -0
- package/dist/components/KInputNumber.js +7 -0
- package/dist/components/KInputNumber.vue.d.ts +28 -0
- package/dist/components/KInputNumber.vue_vue_type_script_setup_true_lang.js +109 -0
- package/dist/components/KListSkeleton.js +5 -0
- package/dist/components/KListSkeleton.vue.d.ts +8 -0
- package/dist/components/KListSkeleton.vue_vue_type_script_setup_true_lang.js +14 -0
- package/dist/components/KLoadingOverlay.js +7 -0
- package/dist/components/KLoadingOverlay.vue.d.ts +11 -0
- package/dist/components/KLoadingOverlay.vue_vue_type_script_setup_true_lang.js +34 -0
- package/dist/components/KMessage.d.ts +20 -0
- package/dist/components/KMessage.js +55 -0
- package/dist/components/KMessageContainer.js +7 -0
- package/dist/components/KMessageContainer.vue.d.ts +15 -0
- package/dist/components/KMessageContainer.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/components/KPagination.js +7 -0
- package/dist/components/KPagination.vue.d.ts +14 -0
- package/dist/components/KPagination.vue_vue_type_script_setup_true_lang.js +104 -0
- package/dist/components/KPopover.js +6 -0
- package/dist/components/KPopover.vue.d.ts +40 -0
- package/dist/components/KPopover.vue_vue_type_script_setup_true_lang.js +63 -0
- package/dist/components/KProgress.js +7 -0
- package/dist/components/KProgress.vue.d.ts +21 -0
- package/dist/components/KProgress.vue_vue_type_script_setup_true_lang.js +108 -0
- package/dist/components/KRadio.js +7 -0
- package/dist/components/KRadio.vue.d.ts +18 -0
- package/dist/components/KRadio.vue_vue_type_script_setup_true_lang.js +26 -0
- package/dist/components/KRadioGroup.js +7 -0
- package/dist/components/KRadioGroup.vue.d.ts +26 -0
- package/dist/components/KRadioGroup.vue_vue_type_script_setup_true_lang.js +32 -0
- package/dist/components/KRefetchOverlay.js +5 -0
- package/dist/components/KRefetchOverlay.vue.d.ts +8 -0
- package/dist/components/KRefetchOverlay.vue_vue_type_script_setup_true_lang.js +26 -0
- package/dist/components/KResizablePanel.js +7 -0
- package/dist/components/KResizablePanel.vue.d.ts +30 -0
- package/dist/components/KResizablePanel.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/components/KResult.js +7 -0
- package/dist/components/KResult.vue.d.ts +29 -0
- package/dist/components/KResult.vue_vue_type_script_setup_true_lang.js +82 -0
- package/dist/components/KSearchBar.js +5 -0
- package/dist/components/KSearchBar.vue.d.ts +11 -0
- package/dist/components/KSearchBar.vue_vue_type_script_setup_true_lang.js +38 -0
- package/dist/components/KSelect.js +9 -0
- package/dist/components/KSelect.vue.d.ts +22 -0
- package/dist/components/KSelect.vue_vue_type_script_setup_true_lang.js +96 -0
- package/dist/components/KSkeleton.js +7 -0
- package/dist/components/KSkeleton.vue.d.ts +14 -0
- package/dist/components/KSkeleton.vue_vue_type_script_setup_true_lang.js +27 -0
- package/dist/components/KSteps.js +7 -0
- package/dist/components/KSteps.vue.d.ts +20 -0
- package/dist/components/KSteps.vue_vue_type_script_setup_true_lang.js +39 -0
- package/dist/components/KSwitch.js +7 -0
- package/dist/components/KSwitch.vue.d.ts +16 -0
- package/dist/components/KSwitch.vue_vue_type_script_setup_true_lang.js +35 -0
- package/dist/components/KTabs.js +7 -0
- package/dist/components/KTabs.vue.d.ts +35 -0
- package/dist/components/KTabs.vue_vue_type_script_setup_true_lang.js +47 -0
- package/dist/components/KTag.js +7 -0
- package/dist/components/KTag.vue.d.ts +32 -0
- package/dist/components/KTag.vue_vue_type_script_setup_true_lang.js +40 -0
- package/dist/components/KTextarea.js +7 -0
- package/dist/components/KTextarea.vue.d.ts +23 -0
- package/dist/components/KTextarea.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/components/KThemeToggleButton.js +7 -0
- package/dist/components/KThemeToggleButton.vue.d.ts +14 -0
- package/dist/components/KThemeToggleButton.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/KTooltip.js +6 -0
- package/dist/components/KTooltip.vue.d.ts +23 -0
- package/dist/components/KTooltip.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/components/KTreeNode.js +7 -0
- package/dist/components/KTreeNode.vue.d.ts +8 -0
- package/dist/components/KTreeNode.vue_vue_type_script_setup_true_lang.js +47 -0
- package/dist/components/KTreeView.js +7 -0
- package/dist/components/KTreeView.vue.d.ts +22 -0
- package/dist/components/KTreeView.vue_vue_type_script_setup_true_lang.js +45 -0
- package/dist/components/KUpload.js +7 -0
- package/dist/components/KUpload.vue.d.ts +81 -0
- package/dist/components/KUpload.vue_vue_type_script_setup_true_lang.js +181 -0
- package/dist/components/KVirtualList.js +7 -0
- package/dist/components/KVirtualList.vue.d.ts +31 -0
- package/dist/components/KVirtualList.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/components/form-context.d.ts +25 -0
- package/dist/components/form-context.js +4 -0
- package/dist/components/tree-context.d.ts +16 -0
- package/dist/components/tree-context.js +4 -0
- package/dist/composables/useConfirm.d.ts +17 -0
- package/dist/composables/useConfirm.js +31 -0
- package/dist/directives/index.d.ts +6 -0
- package/dist/directives/index.js +8 -0
- package/dist/directives/reveal.d.ts +20 -0
- package/dist/directives/reveal.js +18 -0
- package/dist/directives/spotlight.d.ts +22 -0
- package/dist/directives/spotlight.js +25 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +55 -0
- package/dist/k-ui.css +2 -0
- package/dist/styles/components.css +92 -0
- package/dist/styles/index.css +2 -0
- package/dist/styles/menu.css +59 -0
- package/dist/styles/tokens.css +229 -0
- package/dist/types.d.ts +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Fragment as e, createBlock as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, createVNode as o, defineComponent as s, normalizeClass as c, normalizeStyle as l, openBlock as u, ref as d, renderList as f, toDisplayString as p, unref as m, withModifiers as h } from "vue";
|
|
2
|
+
import { AlertCircle as g, CheckCircle2 as _, FileText as v, Loader2 as y, Upload as b, X as x } from "lucide-vue-next";
|
|
3
|
+
//#region components/KUpload.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var S = { class: "k-upload" }, C = { class: "k-upload__hint" }, w = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "k-upload__meta"
|
|
7
|
+
}, T = { key: 0 }, E = { key: 1 }, D = { key: 2 }, O = ["multiple", "accept"], k = {
|
|
8
|
+
key: 2,
|
|
9
|
+
class: "k-upload__list"
|
|
10
|
+
}, A = { class: "k-upload__file-info" }, j = { class: "k-upload__file-name" }, M = { class: "k-upload__file-meta" }, N = {
|
|
11
|
+
key: 0,
|
|
12
|
+
class: "k-upload__error-text"
|
|
13
|
+
}, P = {
|
|
14
|
+
key: 0,
|
|
15
|
+
class: "k-upload__progress"
|
|
16
|
+
}, F = { class: "k-upload__file-status" }, I = ["onClick"], L = /* @__PURE__ */ s({
|
|
17
|
+
__name: "KUpload",
|
|
18
|
+
props: {
|
|
19
|
+
multiple: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: !1
|
|
22
|
+
},
|
|
23
|
+
accept: {},
|
|
24
|
+
maxSize: {},
|
|
25
|
+
uploader: {},
|
|
26
|
+
drag: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: !0
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: [
|
|
32
|
+
"change",
|
|
33
|
+
"success",
|
|
34
|
+
"error"
|
|
35
|
+
],
|
|
36
|
+
setup(s, { expose: L, emit: R }) {
|
|
37
|
+
let z = s, B = R, V = d([]), H = d(!1), U = d(null);
|
|
38
|
+
function W(e) {
|
|
39
|
+
return e < 1024 ? e + " B" : e < 1024 * 1024 ? (e / 1024).toFixed(1) + " KB" : (e / 1024 / 1024).toFixed(2) + " MB";
|
|
40
|
+
}
|
|
41
|
+
let G = 0;
|
|
42
|
+
async function K(e) {
|
|
43
|
+
let t = Array.from(e);
|
|
44
|
+
!z.multiple && t.length > 1 && (t = t.slice(0, 1));
|
|
45
|
+
let n = [];
|
|
46
|
+
for (let e of t) {
|
|
47
|
+
if (z.maxSize && e.size > z.maxSize) {
|
|
48
|
+
V.value.push({
|
|
49
|
+
id: String(++G),
|
|
50
|
+
name: e.name,
|
|
51
|
+
size: e.size,
|
|
52
|
+
status: "error",
|
|
53
|
+
progress: 0,
|
|
54
|
+
error: `超过最大 ${W(z.maxSize)}`
|
|
55
|
+
});
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
let t = {
|
|
59
|
+
id: String(++G),
|
|
60
|
+
name: e.name,
|
|
61
|
+
size: e.size,
|
|
62
|
+
status: "pending",
|
|
63
|
+
progress: 0,
|
|
64
|
+
raw: e
|
|
65
|
+
};
|
|
66
|
+
V.value.push(t), n.push({
|
|
67
|
+
uf: t,
|
|
68
|
+
raw: e
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (B("change", V.value), z.uploader) {
|
|
72
|
+
let e = z.uploader;
|
|
73
|
+
await Promise.all(n.map(async ({ uf: t, raw: n }) => {
|
|
74
|
+
t.status = "uploading";
|
|
75
|
+
try {
|
|
76
|
+
let r = await e(n, (e) => t.progress = e);
|
|
77
|
+
if (!V.value.includes(t)) return;
|
|
78
|
+
t.status = "success", t.progress = 100, t.url = r?.url, B("success", t);
|
|
79
|
+
} catch (e) {
|
|
80
|
+
if (!V.value.includes(t)) return;
|
|
81
|
+
t.status = "error", t.error = e?.message || "上传失败", B("error", t, e);
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
} else n.forEach(({ uf: e }) => {
|
|
85
|
+
e.status = "success", e.progress = 100;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function q() {
|
|
89
|
+
U.value?.click();
|
|
90
|
+
}
|
|
91
|
+
function J(e) {
|
|
92
|
+
let t = e.target;
|
|
93
|
+
t.files && K(t.files), t.value = "";
|
|
94
|
+
}
|
|
95
|
+
function Y(e) {
|
|
96
|
+
H.value = !1, e.dataTransfer?.files && K(e.dataTransfer.files);
|
|
97
|
+
}
|
|
98
|
+
function X(e) {
|
|
99
|
+
V.value = V.value.filter((t) => t.id !== e), B("change", V.value);
|
|
100
|
+
}
|
|
101
|
+
return L({
|
|
102
|
+
files: V,
|
|
103
|
+
remove: X,
|
|
104
|
+
addFiles: K
|
|
105
|
+
}), (d, L) => (u(), r("div", S, [
|
|
106
|
+
s.drag ? (u(), r("div", {
|
|
107
|
+
key: 0,
|
|
108
|
+
class: c(["k-upload__zone", { "k-upload__zone--over": H.value }]),
|
|
109
|
+
onClick: q,
|
|
110
|
+
onDragover: L[0] ||= h((e) => H.value = !0, ["prevent"]),
|
|
111
|
+
onDragleave: L[1] ||= h((e) => H.value = !1, ["prevent"]),
|
|
112
|
+
onDrop: h(Y, ["prevent"])
|
|
113
|
+
}, [o(m(b), {
|
|
114
|
+
size: 28,
|
|
115
|
+
class: "k-upload__icon"
|
|
116
|
+
}), i("div", C, [
|
|
117
|
+
L[2] ||= i("strong", null, "点击选择", -1),
|
|
118
|
+
L[3] ||= a(" 或 ", -1),
|
|
119
|
+
L[4] ||= i("strong", null, "拖拽文件", -1),
|
|
120
|
+
L[5] ||= a(" 到此处 ", -1),
|
|
121
|
+
s.accept || s.maxSize ? (u(), r("div", w, [
|
|
122
|
+
s.accept ? (u(), r("span", T, "支持: " + p(s.accept), 1)) : n("", !0),
|
|
123
|
+
s.accept && s.maxSize ? (u(), r("span", E, " · ")) : n("", !0),
|
|
124
|
+
s.maxSize ? (u(), r("span", D, "最大: " + p(W(s.maxSize)), 1)) : n("", !0)
|
|
125
|
+
])) : n("", !0)
|
|
126
|
+
])], 34)) : (u(), r("button", {
|
|
127
|
+
key: 1,
|
|
128
|
+
type: "button",
|
|
129
|
+
class: "k-upload__btn",
|
|
130
|
+
onClick: q
|
|
131
|
+
}, [o(m(b), { size: 14 }), L[6] ||= a(" 选择文件 ", -1)])),
|
|
132
|
+
i("input", {
|
|
133
|
+
ref_key: "fileInputRef",
|
|
134
|
+
ref: U,
|
|
135
|
+
type: "file",
|
|
136
|
+
multiple: s.multiple,
|
|
137
|
+
accept: s.accept,
|
|
138
|
+
class: "k-upload__input",
|
|
139
|
+
onChange: J
|
|
140
|
+
}, null, 40, O),
|
|
141
|
+
V.value.length > 0 ? (u(), r("ul", k, [(u(!0), r(e, null, f(V.value, (e) => (u(), r("li", {
|
|
142
|
+
key: e.id,
|
|
143
|
+
class: c(["k-upload__item", `k-upload__item--${e.status}`])
|
|
144
|
+
}, [
|
|
145
|
+
o(m(v), {
|
|
146
|
+
size: 14,
|
|
147
|
+
class: "k-upload__file-icon"
|
|
148
|
+
}),
|
|
149
|
+
i("div", A, [
|
|
150
|
+
i("div", j, p(e.name), 1),
|
|
151
|
+
i("div", M, [a(p(W(e.size)) + " ", 1), e.error ? (u(), r("span", N, "· " + p(e.error), 1)) : n("", !0)]),
|
|
152
|
+
e.status === "uploading" ? (u(), r("div", P, [i("div", {
|
|
153
|
+
class: "k-upload__progress-bar",
|
|
154
|
+
style: l({ width: e.progress + "%" })
|
|
155
|
+
}, null, 4)])) : n("", !0)
|
|
156
|
+
]),
|
|
157
|
+
i("div", F, [e.status === "uploading" ? (u(), t(m(y), {
|
|
158
|
+
key: 0,
|
|
159
|
+
size: 14,
|
|
160
|
+
class: "k-upload__spin"
|
|
161
|
+
})) : e.status === "success" ? (u(), t(m(_), {
|
|
162
|
+
key: 1,
|
|
163
|
+
size: 14,
|
|
164
|
+
style: { color: "#10b981" }
|
|
165
|
+
})) : e.status === "error" ? (u(), t(m(g), {
|
|
166
|
+
key: 2,
|
|
167
|
+
size: 14,
|
|
168
|
+
style: { color: "#dc2626" }
|
|
169
|
+
})) : n("", !0)]),
|
|
170
|
+
i("button", {
|
|
171
|
+
type: "button",
|
|
172
|
+
class: "k-upload__remove",
|
|
173
|
+
"aria-label": "移除",
|
|
174
|
+
onClick: (t) => X(e.id)
|
|
175
|
+
}, [o(m(x), { size: 12 })], 8, I)
|
|
176
|
+
], 2))), 128))])) : n("", !0)
|
|
177
|
+
]));
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
//#endregion
|
|
181
|
+
export { L as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import e from "../_virtual/_plugin-vue_export-helper.js";
|
|
2
|
+
import t from "./KVirtualList.vue_vue_type_script_setup_true_lang.js";
|
|
3
|
+
/* empty css */
|
|
4
|
+
//#region components/KVirtualList.vue
|
|
5
|
+
var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-9e845dfb"]]);
|
|
6
|
+
//#endregion
|
|
7
|
+
export { n as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
2
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<{
|
|
3
|
+
items: T[];
|
|
4
|
+
/** 固定每项高度 (px) */
|
|
5
|
+
itemHeight: number;
|
|
6
|
+
/** 容器高度 (px) */
|
|
7
|
+
height: number;
|
|
8
|
+
/** 上下额外渲染的 buffer 项数 */
|
|
9
|
+
buffer?: number;
|
|
10
|
+
}> & (typeof globalThis extends {
|
|
11
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
12
|
+
} ? P : {});
|
|
13
|
+
expose: (exposed: {}) => void;
|
|
14
|
+
attrs: any;
|
|
15
|
+
slots: {
|
|
16
|
+
default?: (props: {
|
|
17
|
+
item: T;
|
|
18
|
+
index: number;
|
|
19
|
+
}) => any;
|
|
20
|
+
};
|
|
21
|
+
emit: {};
|
|
22
|
+
}>) => import("vue").VNode & {
|
|
23
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
24
|
+
};
|
|
25
|
+
declare const _default: typeof __VLS_export;
|
|
26
|
+
export default _default;
|
|
27
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
28
|
+
[K in keyof T]: T[K];
|
|
29
|
+
} : {
|
|
30
|
+
[K in keyof T as K]: T[K];
|
|
31
|
+
}) & {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createElementBlock as n, createElementVNode as r, defineComponent as i, normalizeStyle as a, openBlock as o, ref as s, renderList as c, renderSlot as l } from "vue";
|
|
2
|
+
//#region components/KVirtualList.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var u = /* @__PURE__ */ i({
|
|
4
|
+
__name: "KVirtualList",
|
|
5
|
+
props: {
|
|
6
|
+
items: {},
|
|
7
|
+
itemHeight: {},
|
|
8
|
+
height: {},
|
|
9
|
+
buffer: { default: 5 }
|
|
10
|
+
},
|
|
11
|
+
setup(i) {
|
|
12
|
+
let u = i, d = s(0);
|
|
13
|
+
function f(e) {
|
|
14
|
+
d.value = e.target.scrollTop;
|
|
15
|
+
}
|
|
16
|
+
let p = t(() => u.items.length * u.itemHeight), m = t(() => Math.ceil(u.height / u.itemHeight)), h = t(() => Math.max(0, Math.floor(d.value / u.itemHeight) - u.buffer)), g = t(() => Math.min(u.items.length, h.value + m.value + 2 * u.buffer)), _ = t(() => u.items.slice(h.value, g.value).map((e, t) => ({
|
|
17
|
+
item: e,
|
|
18
|
+
index: h.value + t
|
|
19
|
+
}))), v = t(() => h.value * u.itemHeight);
|
|
20
|
+
return (t, s) => (o(), n("div", {
|
|
21
|
+
class: "k-vlist",
|
|
22
|
+
style: a({ height: i.height + "px" }),
|
|
23
|
+
onScroll: f
|
|
24
|
+
}, [r("div", {
|
|
25
|
+
class: "k-vlist__phantom",
|
|
26
|
+
style: a({ height: p.value + "px" })
|
|
27
|
+
}, [r("div", {
|
|
28
|
+
class: "k-vlist__items",
|
|
29
|
+
style: a({ transform: `translateY(${v.value}px)` })
|
|
30
|
+
}, [(o(!0), n(e, null, c(_.value, ({ item: e, index: r }) => (o(), n("div", {
|
|
31
|
+
key: r,
|
|
32
|
+
class: "k-vlist__item",
|
|
33
|
+
style: a({ height: i.itemHeight + "px" })
|
|
34
|
+
}, [l(t.$slots, "default", {
|
|
35
|
+
item: e,
|
|
36
|
+
index: r
|
|
37
|
+
}, void 0, !0)], 4))), 128))], 4)], 4)], 36));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
//#endregion
|
|
41
|
+
export { u as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { InjectionKey } from 'vue';
|
|
2
|
+
export interface FormRule {
|
|
3
|
+
required?: boolean;
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
pattern?: RegExp;
|
|
7
|
+
validator?: (value: any) => boolean | string | Promise<boolean | string>;
|
|
8
|
+
message?: string;
|
|
9
|
+
trigger?: 'blur' | 'change';
|
|
10
|
+
}
|
|
11
|
+
export interface FormFieldRef {
|
|
12
|
+
validate: () => Promise<boolean>;
|
|
13
|
+
reset: () => void;
|
|
14
|
+
clearValidate: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface FormContext {
|
|
17
|
+
model: Record<string, any>;
|
|
18
|
+
rules?: Record<string, FormRule | FormRule[]>;
|
|
19
|
+
labelWidth: string;
|
|
20
|
+
labelPosition: 'top' | 'left';
|
|
21
|
+
size: 'sm' | 'md' | 'lg';
|
|
22
|
+
registerField: (name: string, field: FormFieldRef) => void;
|
|
23
|
+
unregisterField: (name: string) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const formContextKey: InjectionKey<FormContext>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey, Component } from 'vue';
|
|
2
|
+
export interface TreeNode {
|
|
3
|
+
id: string | number;
|
|
4
|
+
label: string;
|
|
5
|
+
children?: TreeNode[];
|
|
6
|
+
icon?: Component;
|
|
7
|
+
}
|
|
8
|
+
export interface KTreeContext {
|
|
9
|
+
expanded: ComputedRef<(string | number)[]>;
|
|
10
|
+
selected: ComputedRef<string | number | null>;
|
|
11
|
+
/** computed 而非 primitive: 父组件改 :indent 时, 嵌套 KTreeNode 才能跟着重排 */
|
|
12
|
+
indent: ComputedRef<number>;
|
|
13
|
+
toggle: (id: string | number) => void;
|
|
14
|
+
select: (node: TreeNode) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const kTreeContextKey: InjectionKey<KTreeContext>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ConfirmOptions {
|
|
2
|
+
title: string;
|
|
3
|
+
message?: string;
|
|
4
|
+
confirmText?: string;
|
|
5
|
+
cancelText?: string;
|
|
6
|
+
destructive?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function useConfirm(): {
|
|
9
|
+
isOpen: import("vue").Ref<boolean, boolean>;
|
|
10
|
+
title: import("vue").Ref<string, string>;
|
|
11
|
+
message: import("vue").Ref<string | undefined, string | undefined>;
|
|
12
|
+
confirmText: import("vue").Ref<string | undefined, string | undefined>;
|
|
13
|
+
cancelText: import("vue").Ref<string | undefined, string | undefined>;
|
|
14
|
+
destructive: import("vue").Ref<boolean, boolean>;
|
|
15
|
+
open: (opts: ConfirmOptions) => Promise<boolean>;
|
|
16
|
+
close: (ok: boolean) => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ref as e } from "vue";
|
|
2
|
+
//#region composables/useConfirm.ts
|
|
3
|
+
var t = e(!1), n = e(""), r = e(void 0), i = e(void 0), a = e(void 0), o = e(!1), s = null;
|
|
4
|
+
function c() {
|
|
5
|
+
function e(e) {
|
|
6
|
+
if (s) {
|
|
7
|
+
let e = s;
|
|
8
|
+
s = null, e(!1);
|
|
9
|
+
}
|
|
10
|
+
return n.value = e.title, r.value = e.message, i.value = e.confirmText, a.value = e.cancelText, o.value = e.destructive ?? !1, t.value = !0, new Promise((e) => {
|
|
11
|
+
s = e;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function c(e) {
|
|
15
|
+
t.value = !1;
|
|
16
|
+
let n = s;
|
|
17
|
+
s = null, n?.(e);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
isOpen: t,
|
|
21
|
+
title: n,
|
|
22
|
+
message: r,
|
|
23
|
+
confirmText: i,
|
|
24
|
+
cancelText: a,
|
|
25
|
+
destructive: o,
|
|
26
|
+
open: e,
|
|
27
|
+
close: c
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { c as useConfirm };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Directive } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* v-reveal — 滚动入场: 元素进入视口时淡入 + 上移. 一次性触发.
|
|
4
|
+
*
|
|
5
|
+
* 用法:
|
|
6
|
+
* <div v-reveal>...</div>
|
|
7
|
+
*
|
|
8
|
+
* <!-- 兄弟节点错落 (CSS 读 --reveal-delay) -->
|
|
9
|
+
* <div v-for="(item, i) in items" v-reveal :style="`--reveal-delay: ${i * 80}ms`">
|
|
10
|
+
* ...
|
|
11
|
+
* </div>
|
|
12
|
+
*
|
|
13
|
+
* 配套 class 已经在 styles/base.css 定义 (.k-reveal / .k-reveal-on).
|
|
14
|
+
*/
|
|
15
|
+
declare const IO_KEY: unique symbol;
|
|
16
|
+
interface ElWithIO extends HTMLElement {
|
|
17
|
+
[IO_KEY]?: IntersectionObserver;
|
|
18
|
+
}
|
|
19
|
+
export declare const vReveal: Directive<ElWithIO, void>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region directives/reveal.ts
|
|
2
|
+
var e = Symbol("k.reveal.io"), t = {
|
|
3
|
+
mounted(t) {
|
|
4
|
+
t.classList.add("k-reveal");
|
|
5
|
+
let n = new IntersectionObserver((e) => {
|
|
6
|
+
for (let r of e) r.isIntersecting && (t.classList.add("k-reveal-on"), n.unobserve(t));
|
|
7
|
+
}, {
|
|
8
|
+
threshold: .12,
|
|
9
|
+
rootMargin: "0px 0px -8% 0px"
|
|
10
|
+
});
|
|
11
|
+
n.observe(t), t[e] = n;
|
|
12
|
+
},
|
|
13
|
+
unmounted(t) {
|
|
14
|
+
t[e]?.disconnect(), delete t[e];
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { t as vReveal };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Directive } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* v-spotlight — Vercel/Linear 风格的鼠标跟随光晕.
|
|
4
|
+
* mousemove 时 rAF 节流更新 --mx / --my CSS 变量,
|
|
5
|
+
* CSS 用 radial-gradient(... at var(--mx) var(--my) ...) 渲染光晕.
|
|
6
|
+
*
|
|
7
|
+
* 用法 (元素需要有自己的圆角 / 背景, 指令只负责加光晕层):
|
|
8
|
+
* <div v-spotlight class="border rounded-lg p-4 bg-white">...</div>
|
|
9
|
+
*
|
|
10
|
+
* 配套 class 在 styles/base.css 的 .k-spotlight.
|
|
11
|
+
*/
|
|
12
|
+
declare const STORE: unique symbol;
|
|
13
|
+
interface SpotlightState {
|
|
14
|
+
handleMove: (e: MouseEvent) => void;
|
|
15
|
+
handleLeave: () => void;
|
|
16
|
+
raf: number;
|
|
17
|
+
}
|
|
18
|
+
interface ElWithStore extends HTMLElement {
|
|
19
|
+
[STORE]?: SpotlightState;
|
|
20
|
+
}
|
|
21
|
+
export declare const vSpotlight: Directive<ElWithStore, void>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region directives/spotlight.ts
|
|
2
|
+
var e = Symbol("k.spotlight"), t = {
|
|
3
|
+
mounted(t) {
|
|
4
|
+
t.classList.add("k-spotlight");
|
|
5
|
+
let n = {
|
|
6
|
+
raf: 0,
|
|
7
|
+
handleMove(e) {
|
|
8
|
+
cancelAnimationFrame(n.raf), n.raf = requestAnimationFrame(() => {
|
|
9
|
+
let n = t.getBoundingClientRect(), r = (e.clientX - n.left) / n.width * 100, i = (e.clientY - n.top) / n.height * 100;
|
|
10
|
+
t.style.setProperty("--mx", `${r}%`), t.style.setProperty("--my", `${i}%`);
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
handleLeave() {
|
|
14
|
+
cancelAnimationFrame(n.raf);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
t.addEventListener("mousemove", n.handleMove), t.addEventListener("mouseleave", n.handleLeave), t[e] = n;
|
|
18
|
+
},
|
|
19
|
+
unmounted(t) {
|
|
20
|
+
let n = t[e];
|
|
21
|
+
n && (t.removeEventListener("mousemove", n.handleMove), t.removeEventListener("mouseleave", n.handleLeave), cancelAnimationFrame(n.raf), delete t[e]);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { t as vSpotlight };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export { default as KButton } from './components/KButton.vue';
|
|
2
|
+
export { default as KInput } from './components/KInput.vue';
|
|
3
|
+
export { default as KTextarea } from './components/KTextarea.vue';
|
|
4
|
+
export { default as KInputNumber } from './components/KInputNumber.vue';
|
|
5
|
+
export { default as KSearchBar } from './components/KSearchBar.vue';
|
|
6
|
+
export { default as KTag } from './components/KTag.vue';
|
|
7
|
+
export { default as KSelect } from './components/KSelect.vue';
|
|
8
|
+
export { default as KCombobox } from './components/KCombobox.vue';
|
|
9
|
+
export { default as KDatePicker } from './components/KDatePicker.vue';
|
|
10
|
+
export { default as KSwitch } from './components/KSwitch.vue';
|
|
11
|
+
export { default as KCheckbox } from './components/KCheckbox.vue';
|
|
12
|
+
export { default as KCheckboxGroup } from './components/KCheckboxGroup.vue';
|
|
13
|
+
export { default as KRadio } from './components/KRadio.vue';
|
|
14
|
+
export { default as KRadioGroup } from './components/KRadioGroup.vue';
|
|
15
|
+
export { default as KForm } from './components/KForm.vue';
|
|
16
|
+
export { default as KFormField } from './components/KFormField.vue';
|
|
17
|
+
export type { FormRule, FormFieldRef } from './components/form-context';
|
|
18
|
+
export { default as KConfirmDialog } from './components/KConfirmDialog.vue';
|
|
19
|
+
export { default as KDialog } from './components/KDialog.vue';
|
|
20
|
+
export { default as KDrawer } from './components/KDrawer.vue';
|
|
21
|
+
export { default as KTooltip } from './components/KTooltip.vue';
|
|
22
|
+
export { default as KPopover } from './components/KPopover.vue';
|
|
23
|
+
export { default as KDropdown } from './components/KDropdown.vue';
|
|
24
|
+
export type { DropdownItem } from './components/KDropdown.vue';
|
|
25
|
+
export { default as KAlert } from './components/KAlert.vue';
|
|
26
|
+
export { KMessage } from './components/KMessage';
|
|
27
|
+
export type { MessageOptions } from './components/KMessage';
|
|
28
|
+
export { useConfirm } from './composables/useConfirm';
|
|
29
|
+
export type { ConfirmOptions } from './composables/useConfirm';
|
|
30
|
+
export { default as KDataTable } from './components/KDataTable.vue';
|
|
31
|
+
export type { Column } from './components/KDataTable.vue';
|
|
32
|
+
export { default as KPagination } from './components/KPagination.vue';
|
|
33
|
+
export { default as KEmpty } from './components/KEmpty.vue';
|
|
34
|
+
export { default as KLoadingOverlay } from './components/KLoadingOverlay.vue';
|
|
35
|
+
export { default as KRefetchOverlay } from './components/KRefetchOverlay.vue';
|
|
36
|
+
export { default as KProgress } from './components/KProgress.vue';
|
|
37
|
+
export { default as KAvatar } from './components/KAvatar.vue';
|
|
38
|
+
export { default as KAvatarGroup } from './components/KAvatarGroup.vue';
|
|
39
|
+
export { default as KSkeleton } from './components/KSkeleton.vue';
|
|
40
|
+
export { default as KListSkeleton } from './components/KListSkeleton.vue';
|
|
41
|
+
export { default as KGridSkeleton } from './components/KGridSkeleton.vue';
|
|
42
|
+
export { default as KTabs } from './components/KTabs.vue';
|
|
43
|
+
export { default as KBreadcrumb } from './components/KBreadcrumb.vue';
|
|
44
|
+
export { default as KCard } from './components/KCard.vue';
|
|
45
|
+
export { default as KResult } from './components/KResult.vue';
|
|
46
|
+
export { default as KSteps } from './components/KSteps.vue';
|
|
47
|
+
export { default as KImage } from './components/KImage.vue';
|
|
48
|
+
export { default as KImageViewer } from './components/KImageViewer.vue';
|
|
49
|
+
export { default as KCarousel } from './components/KCarousel.vue';
|
|
50
|
+
export type { CarouselItem } from './components/KCarousel.vue';
|
|
51
|
+
export { default as KUpload } from './components/KUpload.vue';
|
|
52
|
+
export type { UploadFile } from './components/KUpload.vue';
|
|
53
|
+
export { default as KCommandPalette } from './components/KCommandPalette.vue';
|
|
54
|
+
export type { CmdItem } from './components/KCommandPalette.vue';
|
|
55
|
+
export { default as KVirtualList } from './components/KVirtualList.vue';
|
|
56
|
+
export { default as KResizablePanel } from './components/KResizablePanel.vue';
|
|
57
|
+
export { default as KTreeView } from './components/KTreeView.vue';
|
|
58
|
+
export type { TreeNode } from './components/tree-context';
|
|
59
|
+
export { default as KDiff } from './components/KDiff.vue';
|
|
60
|
+
export { default as KThemeToggleButton } from './components/KThemeToggleButton.vue';
|
|
61
|
+
export type { ThemeMode } from './types';
|
|
62
|
+
export { installDirectives, vReveal, vSpotlight } from './directives';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import e from "./components/KButton.js";
|
|
2
|
+
import t from "./components/KInput.js";
|
|
3
|
+
import n from "./components/KTextarea.js";
|
|
4
|
+
import r from "./components/KInputNumber.js";
|
|
5
|
+
import i from "./components/KSearchBar.js";
|
|
6
|
+
import a from "./components/KTag.js";
|
|
7
|
+
import o from "./components/KSelect.js";
|
|
8
|
+
import s from "./components/KCombobox.js";
|
|
9
|
+
import c from "./components/KDatePicker.js";
|
|
10
|
+
import l from "./components/KSwitch.js";
|
|
11
|
+
import u from "./components/KCheckbox.js";
|
|
12
|
+
import d from "./components/KCheckboxGroup.js";
|
|
13
|
+
import f from "./components/KRadio.js";
|
|
14
|
+
import p from "./components/KRadioGroup.js";
|
|
15
|
+
import m from "./components/KForm.js";
|
|
16
|
+
import h from "./components/KFormField.js";
|
|
17
|
+
import { useConfirm as g } from "./composables/useConfirm.js";
|
|
18
|
+
import _ from "./components/KConfirmDialog.js";
|
|
19
|
+
import v from "./components/KDialog.js";
|
|
20
|
+
import y from "./components/KDrawer.js";
|
|
21
|
+
import b from "./components/KTooltip.js";
|
|
22
|
+
import x from "./components/KPopover.js";
|
|
23
|
+
import S from "./components/KDropdown.js";
|
|
24
|
+
import C from "./components/KAlert.js";
|
|
25
|
+
import { KMessage as w } from "./components/KMessage.js";
|
|
26
|
+
import T from "./components/KLoadingOverlay.js";
|
|
27
|
+
import E from "./components/KEmpty.js";
|
|
28
|
+
import D from "./components/KDataTable.js";
|
|
29
|
+
import O from "./components/KPagination.js";
|
|
30
|
+
import k from "./components/KRefetchOverlay.js";
|
|
31
|
+
import A from "./components/KProgress.js";
|
|
32
|
+
import j from "./components/KAvatar.js";
|
|
33
|
+
import M from "./components/KAvatarGroup.js";
|
|
34
|
+
import N from "./components/KSkeleton.js";
|
|
35
|
+
import P from "./components/KListSkeleton.js";
|
|
36
|
+
import F from "./components/KGridSkeleton.js";
|
|
37
|
+
import I from "./components/KTabs.js";
|
|
38
|
+
import L from "./components/KBreadcrumb.js";
|
|
39
|
+
import R from "./components/KCard.js";
|
|
40
|
+
import z from "./components/KResult.js";
|
|
41
|
+
import B from "./components/KSteps.js";
|
|
42
|
+
import V from "./components/KImageViewer.js";
|
|
43
|
+
import H from "./components/KImage.js";
|
|
44
|
+
import U from "./components/KCarousel.js";
|
|
45
|
+
import W from "./components/KUpload.js";
|
|
46
|
+
import G from "./components/KCommandPalette.js";
|
|
47
|
+
import K from "./components/KVirtualList.js";
|
|
48
|
+
import q from "./components/KResizablePanel.js";
|
|
49
|
+
import J from "./components/KTreeView.js";
|
|
50
|
+
import Y from "./components/KDiff.js";
|
|
51
|
+
import X from "./components/KThemeToggleButton.js";
|
|
52
|
+
import { vReveal as Z } from "./directives/reveal.js";
|
|
53
|
+
import { vSpotlight as Q } from "./directives/spotlight.js";
|
|
54
|
+
import { installDirectives as $ } from "./directives/index.js";
|
|
55
|
+
export { C as KAlert, j as KAvatar, M as KAvatarGroup, L as KBreadcrumb, e as KButton, R as KCard, U as KCarousel, u as KCheckbox, d as KCheckboxGroup, s as KCombobox, G as KCommandPalette, _ as KConfirmDialog, D as KDataTable, c as KDatePicker, v as KDialog, Y as KDiff, y as KDrawer, S as KDropdown, E as KEmpty, m as KForm, h as KFormField, F as KGridSkeleton, H as KImage, V as KImageViewer, t as KInput, r as KInputNumber, P as KListSkeleton, T as KLoadingOverlay, w as KMessage, O as KPagination, x as KPopover, A as KProgress, f as KRadio, p as KRadioGroup, k as KRefetchOverlay, q as KResizablePanel, z as KResult, i as KSearchBar, o as KSelect, N as KSkeleton, B as KSteps, l as KSwitch, I as KTabs, a as KTag, n as KTextarea, X as KThemeToggleButton, b as KTooltip, J as KTreeView, W as KUpload, K as KVirtualList, $ as installDirectives, g as useConfirm, Z as vReveal, Q as vSpotlight };
|