@lingtools/ui 0.0.0-stage → 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 +373 -0
- package/README.md +78 -2
- package/dist/index.js +320 -0
- package/dist/src/components/LingActionItem/LingActionItem.d.ts +31 -0
- package/dist/src/components/LingActionItem/LingActionItem.vue.d.ts +25 -0
- package/dist/src/components/LingActionItem/index.d.ts +8 -0
- package/dist/src/components/LingActionPanel/LingActionPanel.d.ts +85 -0
- package/dist/src/components/LingActionPanel/LingActionPanel.vue.d.ts +35 -0
- package/dist/src/components/LingActionPanel/filter.d.ts +11 -0
- package/dist/src/components/LingActionPanel/index.d.ts +12 -0
- package/dist/src/components/LingDevBadge/LingDevBadge.d.ts +5 -0
- package/dist/src/components/LingDevBadge/LingDevBadge.vue.d.ts +3 -0
- package/dist/src/components/LingDevBadge/index.d.ts +4 -0
- package/dist/src/components/LingFooter/LingFooter.d.ts +5 -0
- package/dist/src/components/LingFooter/LingFooter.vue.d.ts +22 -0
- package/dist/src/components/LingFooter/index.d.ts +4 -0
- package/dist/src/components/LingFooterDivider/LingFooterDivider.d.ts +4 -0
- package/dist/src/components/LingFooterDivider/LingFooterDivider.vue.d.ts +3 -0
- package/dist/src/components/LingFooterDivider/index.d.ts +4 -0
- package/dist/src/components/LingKeycaps/LingKeycaps.d.ts +12 -0
- package/dist/src/components/LingKeycaps/LingKeycaps.vue.d.ts +9 -0
- package/dist/src/components/LingKeycaps/index.d.ts +8 -0
- package/dist/src/components/LingShortcutButton/LingShortcutButton.d.ts +14 -0
- package/dist/src/components/LingShortcutButton/LingShortcutButton.vue.d.ts +20 -0
- package/dist/src/components/LingShortcutButton/index.d.ts +8 -0
- package/dist/src/composables/use-list-selection.d.ts +85 -0
- package/dist/src/index.d.ts +69 -0
- package/dist/src/theme/index.d.ts +13 -0
- package/dist/src/theme/use-theme.d.ts +130 -0
- package/dist/style.css +2 -0
- package/dist/theme.js +4 -0
- package/dist/tokens.generated.less +127 -0
- package/dist/tokens.less +50 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +49 -0
- package/package.json +77 -3
- package/src/components/LingActionItem/LingActionItem.ts +32 -0
- package/src/components/LingActionItem/LingActionItem.vue +105 -0
- package/src/components/LingActionItem/index.ts +8 -0
- package/src/components/LingActionPanel/LingActionPanel.ts +89 -0
- package/src/components/LingActionPanel/LingActionPanel.vue +340 -0
- package/src/components/LingActionPanel/filter.ts +25 -0
- package/src/components/LingActionPanel/index.ts +17 -0
- package/src/components/LingDevBadge/LingDevBadge.ts +5 -0
- package/src/components/LingDevBadge/LingDevBadge.vue +33 -0
- package/src/components/LingDevBadge/index.ts +4 -0
- package/src/components/LingFooter/LingFooter.ts +5 -0
- package/src/components/LingFooter/LingFooter.vue +55 -0
- package/src/components/LingFooter/index.ts +4 -0
- package/src/components/LingFooterDivider/LingFooterDivider.ts +4 -0
- package/src/components/LingFooterDivider/LingFooterDivider.vue +23 -0
- package/src/components/LingFooterDivider/index.ts +4 -0
- package/src/components/LingKeycaps/LingKeycaps.ts +13 -0
- package/src/components/LingKeycaps/LingKeycaps.vue +51 -0
- package/src/components/LingKeycaps/index.ts +8 -0
- package/src/components/LingShortcutButton/LingShortcutButton.ts +15 -0
- package/src/components/LingShortcutButton/LingShortcutButton.vue +71 -0
- package/src/components/LingShortcutButton/index.ts +8 -0
- package/src/composables/use-list-selection.ts +202 -0
- package/src/index.ts +97 -0
- package/src/theme/base.css +45 -0
- package/src/theme/index.ts +13 -0
- package/src/theme/tokens.generated.less +127 -0
- package/src/theme/tokens.json +308 -0
- package/src/theme/tokens.less +50 -0
- package/src/theme/use-theme.ts +227 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import './style.css'
|
|
2
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createSlots as o, createVNode as s, defineComponent as c, nextTick as l, normalizeClass as u, openBlock as d, readonly as f, ref as p, renderList as m, renderSlot as h, resolveComponent as g, shallowRef as _, toDisplayString as v, toValue as y, unref as b, useTemplateRef as x, watch as S, withCtx as C } from "vue";
|
|
3
|
+
import { onClickOutside as ee } from "@vueuse/core";
|
|
4
|
+
// src/components/LingDevBadge/LingDevBadge.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var w = {
|
|
6
|
+
class: "ling-dev-badge",
|
|
7
|
+
title: "开发版"
|
|
8
|
+
}, T = /*@__PURE__*/ c({
|
|
9
|
+
__name: "LingDevBadge",
|
|
10
|
+
setup(e) {
|
|
11
|
+
return (e, t) => (d(), i("span", w, " dev "));
|
|
12
|
+
}
|
|
13
|
+
}), E = (e, t) => {
|
|
14
|
+
let n = e.__vccOpts || e;
|
|
15
|
+
for (let [e, r] of t) n[e] = r;
|
|
16
|
+
return n;
|
|
17
|
+
}, D = /*#__PURE__*/ E(T, [["__scopeId", "data-v-5702a8c9"]]), O = { class: "ling-footer" }, k = { class: "ling-footer__start" }, A = { class: "ling-footer__end" }, j = /*#__PURE__*/ E(/* @__PURE__ */ c({
|
|
18
|
+
__name: "LingFooter",
|
|
19
|
+
setup(e) {
|
|
20
|
+
return (e, t) => (d(), i("footer", O, [a("div", k, [h(e.$slots, "start", {}, void 0, !0)]), a("div", A, [h(e.$slots, "default", {}, void 0, !0)])]));
|
|
21
|
+
}
|
|
22
|
+
}), [["__scopeId", "data-v-35fceea8"]]), M = {
|
|
23
|
+
class: "ling-keycaps",
|
|
24
|
+
"aria-hidden": "true"
|
|
25
|
+
}, N = /*#__PURE__*/ E(/* @__PURE__ */ c({
|
|
26
|
+
__name: "LingKeycaps",
|
|
27
|
+
props: { keys: {} },
|
|
28
|
+
setup(t) {
|
|
29
|
+
return (n, r) => (d(), i("span", M, [(d(!0), i(e, null, m(t.keys, (e, t) => (d(), i("kbd", {
|
|
30
|
+
key: t,
|
|
31
|
+
class: "ling-keycaps__key"
|
|
32
|
+
}, v(e), 1))), 128))]));
|
|
33
|
+
}
|
|
34
|
+
}), [["__scopeId", "data-v-562b9600"]]), te = { class: "ling-shortcut-button__content" }, P = /*#__PURE__*/ E(/* @__PURE__ */ c({
|
|
35
|
+
__name: "LingShortcutButton",
|
|
36
|
+
props: { keys: {} },
|
|
37
|
+
setup(e) {
|
|
38
|
+
return (t, i) => {
|
|
39
|
+
let o = g("el-button");
|
|
40
|
+
return d(), n(o, {
|
|
41
|
+
class: "ling-shortcut-button",
|
|
42
|
+
text: "",
|
|
43
|
+
size: "small"
|
|
44
|
+
}, {
|
|
45
|
+
default: C(() => [a("span", te, [
|
|
46
|
+
h(t.$slots, "icon", {}, void 0, !0),
|
|
47
|
+
h(t.$slots, "default", {}, void 0, !0),
|
|
48
|
+
e.keys.length > 0 ? (d(), n(b(N), {
|
|
49
|
+
key: 0,
|
|
50
|
+
class: "ling-shortcut-button__keys",
|
|
51
|
+
keys: e.keys
|
|
52
|
+
}, null, 8, ["keys"])) : r("", !0)
|
|
53
|
+
])]),
|
|
54
|
+
_: 3
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}), [["__scopeId", "data-v-6b619b5d"]]), F = /*#__PURE__*/ E(/* @__PURE__ */ c({
|
|
59
|
+
__name: "LingFooterDivider",
|
|
60
|
+
setup(e) {
|
|
61
|
+
return (e, t) => {
|
|
62
|
+
let r = g("el-divider");
|
|
63
|
+
return d(), n(r, {
|
|
64
|
+
class: "ling-footer-divider",
|
|
65
|
+
direction: "vertical"
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}), [["__scopeId", "data-v-8b9a193f"]]), I = ["aria-selected", "aria-disabled"], ne = {
|
|
70
|
+
key: 0,
|
|
71
|
+
class: "ling-action-item__icon",
|
|
72
|
+
"aria-hidden": "true"
|
|
73
|
+
}, re = { class: "ling-action-item__title" }, L = /*#__PURE__*/ E(/* @__PURE__ */ c({
|
|
74
|
+
__name: "LingActionItem",
|
|
75
|
+
props: {
|
|
76
|
+
title: {},
|
|
77
|
+
keys: { default: () => [] },
|
|
78
|
+
current: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: !1
|
|
81
|
+
},
|
|
82
|
+
disabled: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: !1
|
|
85
|
+
},
|
|
86
|
+
danger: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: !1
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
setup(e) {
|
|
92
|
+
return (t, o) => (d(), i("div", {
|
|
93
|
+
class: u(["ling-action-item", {
|
|
94
|
+
"ling-action-item--current": e.current,
|
|
95
|
+
"ling-action-item--disabled": e.disabled,
|
|
96
|
+
"ling-action-item--danger": e.danger
|
|
97
|
+
}]),
|
|
98
|
+
role: "option",
|
|
99
|
+
"aria-selected": e.current,
|
|
100
|
+
"aria-disabled": e.disabled
|
|
101
|
+
}, [
|
|
102
|
+
t.$slots.icon ? (d(), i("span", ne, [h(t.$slots, "icon", {}, void 0, !0)])) : r("", !0),
|
|
103
|
+
a("span", re, v(e.title), 1),
|
|
104
|
+
h(t.$slots, "suffix", {}, void 0, !0),
|
|
105
|
+
e.keys.length > 0 ? (d(), n(b(N), {
|
|
106
|
+
key: 1,
|
|
107
|
+
class: "ling-action-item__keys",
|
|
108
|
+
keys: e.keys
|
|
109
|
+
}, null, 8, ["keys"])) : r("", !0)
|
|
110
|
+
], 10, I));
|
|
111
|
+
}
|
|
112
|
+
}), [["__scopeId", "data-v-bd38b9f8"]]);
|
|
113
|
+
// src/components/LingActionPanel/filter.ts
|
|
114
|
+
function R(e, t) {
|
|
115
|
+
let n = t.trim().toLowerCase();
|
|
116
|
+
return n ? e.filter((e) => e.title.toLowerCase().includes(n) || (e.alias?.toLowerCase().includes(n) ?? !1)) : [...e];
|
|
117
|
+
}
|
|
118
|
+
// src/components/LingActionPanel/LingActionPanel.vue?vue&type=script&setup=true&lang.ts
|
|
119
|
+
var z = ["aria-label"], B = { class: "ling-action-panel__title" }, V = {
|
|
120
|
+
class: "ling-action-panel__list",
|
|
121
|
+
role: "listbox"
|
|
122
|
+
}, H = {
|
|
123
|
+
key: 0,
|
|
124
|
+
class: "ling-action-panel__section-title"
|
|
125
|
+
}, U = {
|
|
126
|
+
key: 1,
|
|
127
|
+
class: "ling-action-panel__separator",
|
|
128
|
+
"aria-hidden": "true"
|
|
129
|
+
}, W = { class: "ling-action-panel__search-row" }, G = /*#__PURE__*/ E(/* @__PURE__ */ c({
|
|
130
|
+
__name: "LingActionPanel",
|
|
131
|
+
props: {
|
|
132
|
+
title: {},
|
|
133
|
+
actions: {},
|
|
134
|
+
sections: {}
|
|
135
|
+
},
|
|
136
|
+
emits: ["run", "close"],
|
|
137
|
+
setup(c, { expose: l, emit: u }) {
|
|
138
|
+
let f = c, _ = u, y = x("root"), w = x("input"), T = p({ keyword: "" }), E = t(() => R(f.actions, T.value.keyword)), D = p(null);
|
|
139
|
+
function O(e) {
|
|
140
|
+
let t = E.value[e], n = E.value[e - 1];
|
|
141
|
+
return T.value.keyword.trim() || n?.section === t.section ? null : f.sections?.[t.section] ?? null;
|
|
142
|
+
}
|
|
143
|
+
function k(e) {
|
|
144
|
+
let t = E.value[e - 1];
|
|
145
|
+
return !T.value.keyword.trim() && t !== void 0 && t.section !== E.value[e].section && O(e) === null;
|
|
146
|
+
}
|
|
147
|
+
function A(e) {
|
|
148
|
+
let t = E.value, n = t.findIndex((e) => e.id === D.value);
|
|
149
|
+
for (n += e; n >= 0 && n < t.length; n += e) if (t[n].enabled) {
|
|
150
|
+
D.value = t[n].id;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function j(e) {
|
|
155
|
+
f.actions.find((t) => t.id === e)?.enabled && _("run", e);
|
|
156
|
+
}
|
|
157
|
+
function M(e) {
|
|
158
|
+
if (e instanceof KeyboardEvent && !e.isComposing) switch (e.key) {
|
|
159
|
+
case "ArrowDown":
|
|
160
|
+
e.preventDefault(), A(1);
|
|
161
|
+
break;
|
|
162
|
+
case "ArrowUp":
|
|
163
|
+
e.preventDefault(), A(-1);
|
|
164
|
+
break;
|
|
165
|
+
case "Enter":
|
|
166
|
+
e.preventDefault(), D.value !== null && j(D.value);
|
|
167
|
+
break;
|
|
168
|
+
case "Escape": e.preventDefault(), e.stopPropagation(), T.value.keyword ? T.value.keyword = "" : _("close");
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return S(E, (e) => {
|
|
172
|
+
D.value = e.find((e) => e.enabled)?.id ?? null;
|
|
173
|
+
}, { immediate: !0 }), ee(y, () => _("close")), l({ focus: () => w.value?.focus() }), (t, l) => {
|
|
174
|
+
let u = g("el-switch"), f = g("el-empty"), p = g("el-input");
|
|
175
|
+
return d(), i("div", {
|
|
176
|
+
ref: "root",
|
|
177
|
+
class: "ling-action-panel",
|
|
178
|
+
role: "dialog",
|
|
179
|
+
"aria-label": c.title
|
|
180
|
+
}, [
|
|
181
|
+
a("div", B, v(c.title), 1),
|
|
182
|
+
a("div", V, [(d(!0), i(e, null, m(E.value, (a, c) => (d(), i(e, { key: a.id }, [O(c) === null ? k(c) ? (d(), i("div", U)) : r("", !0) : (d(), i("div", H, v(O(c)), 1)), s(b(L), {
|
|
183
|
+
title: a.title,
|
|
184
|
+
keys: a.keys,
|
|
185
|
+
current: a.id === D.value,
|
|
186
|
+
disabled: !a.enabled,
|
|
187
|
+
danger: a.danger,
|
|
188
|
+
"aria-checked": a.checked,
|
|
189
|
+
"data-action": a.id,
|
|
190
|
+
onMousemove: (e) => a.enabled && (D.value = a.id),
|
|
191
|
+
onClick: (e) => j(a.id)
|
|
192
|
+
}, o({ _: 2 }, [t.$slots.icon ? {
|
|
193
|
+
name: "icon",
|
|
194
|
+
fn: C(() => [h(t.$slots, "icon", { action: a }, void 0, !0)]),
|
|
195
|
+
key: "0"
|
|
196
|
+
} : void 0, t.$slots.suffix || a.checked !== void 0 ? {
|
|
197
|
+
name: "suffix",
|
|
198
|
+
fn: C(() => [h(t.$slots, "suffix", { action: a }, void 0, !0), a.checked === void 0 ? r("", !0) : (d(), n(u, {
|
|
199
|
+
key: 0,
|
|
200
|
+
class: "ling-action-panel__switch",
|
|
201
|
+
"model-value": a.checked,
|
|
202
|
+
disabled: !a.enabled,
|
|
203
|
+
tabindex: -1,
|
|
204
|
+
size: "small",
|
|
205
|
+
"aria-hidden": "true"
|
|
206
|
+
}, null, 8, ["model-value", "disabled"]))]),
|
|
207
|
+
key: "1"
|
|
208
|
+
} : void 0]), 1032, [
|
|
209
|
+
"title",
|
|
210
|
+
"keys",
|
|
211
|
+
"current",
|
|
212
|
+
"disabled",
|
|
213
|
+
"danger",
|
|
214
|
+
"aria-checked",
|
|
215
|
+
"data-action",
|
|
216
|
+
"onMousemove",
|
|
217
|
+
"onClick"
|
|
218
|
+
])], 64))), 128)), E.value.length === 0 ? (d(), n(f, {
|
|
219
|
+
key: 0,
|
|
220
|
+
class: "ling-action-panel__empty",
|
|
221
|
+
"image-size": 0,
|
|
222
|
+
description: "没有匹配的操作"
|
|
223
|
+
})) : r("", !0)]),
|
|
224
|
+
a("div", W, [s(p, {
|
|
225
|
+
ref: "input",
|
|
226
|
+
modelValue: T.value.keyword,
|
|
227
|
+
"onUpdate:modelValue": l[0] ||= (e) => T.value.keyword = e,
|
|
228
|
+
class: "ling-action-panel__search",
|
|
229
|
+
placeholder: "搜索操作…",
|
|
230
|
+
autocomplete: "off",
|
|
231
|
+
onKeydown: M
|
|
232
|
+
}, null, 8, ["modelValue"])])
|
|
233
|
+
], 8, z);
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}), [["__scopeId", "data-v-6f0d9b12"]]), K = "data-list-key", q = 2;
|
|
237
|
+
function J(e, t, n, r) {
|
|
238
|
+
if (n !== null && e.some((e) => t(e) === n)) return n;
|
|
239
|
+
let i = e[Math.min(Math.max(r, 0), e.length - 1)];
|
|
240
|
+
return i === void 0 ? null : t(i);
|
|
241
|
+
}
|
|
242
|
+
function Y(e) {
|
|
243
|
+
let { keyOf: n } = e, r = e.nearEndRows ?? q, i = _(null);
|
|
244
|
+
function a(e, t) {
|
|
245
|
+
return t === null ? -1 : e.findIndex((e) => n(e) === t);
|
|
246
|
+
}
|
|
247
|
+
let o = t(() => {
|
|
248
|
+
let t = y(e.items);
|
|
249
|
+
return t[a(t, i.value)] ?? null;
|
|
250
|
+
});
|
|
251
|
+
S(() => y(e.items), (e, t) => {
|
|
252
|
+
let r = a(t ?? [], i.value);
|
|
253
|
+
i.value = J(e, n, i.value, Math.max(r, 0));
|
|
254
|
+
}, {
|
|
255
|
+
immediate: !0,
|
|
256
|
+
flush: "sync"
|
|
257
|
+
});
|
|
258
|
+
function s() {
|
|
259
|
+
l(() => {
|
|
260
|
+
let t = i.value, n = y(e.listElement);
|
|
261
|
+
t !== null && n && [...n.querySelectorAll(`[${K}]`)].find((e) => e.getAttribute(K) === String(t))?.scrollIntoView?.({ block: "nearest" });
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function c(e) {
|
|
265
|
+
i.value = e, s();
|
|
266
|
+
}
|
|
267
|
+
function u(t) {
|
|
268
|
+
let o = y(e.items);
|
|
269
|
+
if (o.length === 0) return;
|
|
270
|
+
let s = a(o, i.value), l = s < 0 ? o[0] : o[s + t];
|
|
271
|
+
l !== void 0 && c(n(l)), t === 1 && a(o, i.value) >= o.length - r && e.onNearEnd?.();
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
selectedKey: i,
|
|
275
|
+
current: o,
|
|
276
|
+
select: c,
|
|
277
|
+
move: u,
|
|
278
|
+
scrollToSelected: s
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
// src/theme/use-theme.ts
|
|
282
|
+
function X(e, t) {
|
|
283
|
+
if (!e.vibrancy && !e.backgroundImage) return "off";
|
|
284
|
+
switch (t) {
|
|
285
|
+
case "host": return "blurred";
|
|
286
|
+
case "menu": return "unblurred";
|
|
287
|
+
case "plugin": return e.vibrancy ? "blurred" : "unblurred";
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function ie(e) {
|
|
291
|
+
let t = document.documentElement.classList;
|
|
292
|
+
t.toggle("glass", e !== "off"), t.toggle("glass-unblurred", e === "unblurred");
|
|
293
|
+
}
|
|
294
|
+
var Z = p("light"), Q = p("off"), $ = 0;
|
|
295
|
+
function ae(e) {
|
|
296
|
+
let t = e.kind ?? "host", n = e.setLightTheme ?? (() => document.documentElement.classList.remove("dark")), r = e.setDarkTheme ?? (() => document.documentElement.classList.add("dark")), i = e.setGlass ?? ie;
|
|
297
|
+
function a(e) {
|
|
298
|
+
$ += 1, e.isDark ? r() : n(), Z.value = e.isDark ? "dark" : "light";
|
|
299
|
+
let a = X(e, t);
|
|
300
|
+
i(a), Q.value = a;
|
|
301
|
+
}
|
|
302
|
+
async function o() {
|
|
303
|
+
let t = $, n = await e.source.read();
|
|
304
|
+
t === $ && a(n);
|
|
305
|
+
}
|
|
306
|
+
return e.source.subscribe(a), {
|
|
307
|
+
themeReady: o(),
|
|
308
|
+
themeRefresh: o
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function oe() {
|
|
312
|
+
return f(Z);
|
|
313
|
+
}
|
|
314
|
+
function se() {
|
|
315
|
+
return f(Q);
|
|
316
|
+
}
|
|
317
|
+
function ce() {
|
|
318
|
+
return Z.value;
|
|
319
|
+
}
|
|
320
|
+
export { K as LIST_KEY_ATTRIBUTE, L as LingActionItem, G as LingActionPanel, D as LingDevBadge, j as LingFooter, F as LingFooterDivider, N as LingKeycaps, P as LingShortcutButton, R as filterActionPanelItems, ce as getCurrentTheme, X as glassModeOf, J as keepListSelection, se as useCurrentGlass, oe as useCurrentTheme, Y as useListSelection, ae as useTheme };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 操作行契约:操作面板里的一行,「[图标] 名称 [后缀] 键帽」,带当前 / 禁用 / 危险三种状态。
|
|
3
|
+
* 只负责显示与无障碍属性;键盘、过滤与执行由所在面板负责。
|
|
4
|
+
* `id`、`click`、`mousemove`、`mousedown.prevent`、`aria-checked` 等经属性透传到根元素。
|
|
5
|
+
* 行高取 CSS 变量 `--ling-action-item-height`(默认 36px),需要按行高计算面板高度的使用方用同一个常量设置它。
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 操作行的输入。
|
|
9
|
+
*/
|
|
10
|
+
export interface LingActionItemProps {
|
|
11
|
+
/**
|
|
12
|
+
* 显示名称。
|
|
13
|
+
*/
|
|
14
|
+
title: string;
|
|
15
|
+
/**
|
|
16
|
+
* 键帽文字,按显示顺序;由调用方按平台生成,空数组(默认)时不画键帽。
|
|
17
|
+
*/
|
|
18
|
+
keys?: readonly string[];
|
|
19
|
+
/**
|
|
20
|
+
* 是否为键盘 / 鼠标的当前项(画选中底色);由所在面板持有。
|
|
21
|
+
*/
|
|
22
|
+
current?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 是否不可执行:文字置灰、键帽变淡;是否响应单击由所在面板决定。
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 是否为危险操作(删除、清空):图标与文字用危险色。
|
|
29
|
+
*/
|
|
30
|
+
danger?: boolean;
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LingActionItemProps } from './LingActionItem';
|
|
2
|
+
type __VLS_Slots = {
|
|
3
|
+
/**
|
|
4
|
+
* 名称前的图标,16px,颜色跟随文字色。
|
|
5
|
+
*/
|
|
6
|
+
icon?(): unknown;
|
|
7
|
+
/**
|
|
8
|
+
* 名称与键帽之间的附加标记(如开关项开启时的勾)。
|
|
9
|
+
*/
|
|
10
|
+
suffix?(): unknown;
|
|
11
|
+
};
|
|
12
|
+
declare const __VLS_base: import("vue").DefineComponent<LingActionItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<LingActionItemProps> & Readonly<{}>, {
|
|
13
|
+
keys: readonly string[];
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
danger: boolean;
|
|
16
|
+
current: boolean;
|
|
17
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
19
|
+
declare const _default: typeof __VLS_export;
|
|
20
|
+
export default _default;
|
|
21
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
22
|
+
new (): {
|
|
23
|
+
$slots: S;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 操作面板契约(插件页面内的 ⌘K 面板):标题、按组分隔的操作行(组可以带小标题)、底部搜索框。
|
|
3
|
+
* 面板只负责选择:过滤、当前项、键盘与点外收起在面板内完成;执行由父级按操作标识处理,
|
|
4
|
+
* 显隐由父级 `v-if` 控制、定位由父级给 class。
|
|
5
|
+
* 按键冒泡:只有 Esc 在面板内 `stopPropagation`(不让 SDK 当成退出插件);↑↓、↵ 只 `preventDefault`,
|
|
6
|
+
* 仍会冒泡到父级的键盘分派,父级在面板打开时要忽略它们;其他组合键照常交给父级。
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 操作面板里的一项。
|
|
10
|
+
*/
|
|
11
|
+
export interface LingActionPanelItem<T extends string> {
|
|
12
|
+
/**
|
|
13
|
+
* 操作标识,`run` 事件原样带回。
|
|
14
|
+
*/
|
|
15
|
+
id: T;
|
|
16
|
+
/**
|
|
17
|
+
* 显示名称(中文)。
|
|
18
|
+
*/
|
|
19
|
+
title: string;
|
|
20
|
+
/**
|
|
21
|
+
* 英文别名,只参与搜索、不显示;没有时只按名称搜索。
|
|
22
|
+
*/
|
|
23
|
+
alias?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 是否可执行:不可执行的置灰、键盘移动时跳过、单击无效。
|
|
26
|
+
*/
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 分组标识:未搜索时,相邻两项分组不同就在中间画分隔线。
|
|
30
|
+
*/
|
|
31
|
+
section: string | number;
|
|
32
|
+
/**
|
|
33
|
+
* 键帽文字,由调用方按平台换算好;没有快捷键时不传。
|
|
34
|
+
*/
|
|
35
|
+
keys?: readonly string[];
|
|
36
|
+
/**
|
|
37
|
+
* 是否为危险操作(删除、清空),画危险色。
|
|
38
|
+
*/
|
|
39
|
+
danger?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* 开关项的当前状态:有这个字段时行尾画开关(只显示,切换由父级在 `run` 里完成),行上标出 `aria-checked`;
|
|
42
|
+
* 普通操作不传。
|
|
43
|
+
*/
|
|
44
|
+
checked?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 操作面板的输入。
|
|
48
|
+
*/
|
|
49
|
+
export interface LingActionPanelProps<T extends string> {
|
|
50
|
+
/**
|
|
51
|
+
* 面板标题:选中行的名称与概况(如「Google Chrome · 24 个进程」)。
|
|
52
|
+
*/
|
|
53
|
+
title: string;
|
|
54
|
+
/**
|
|
55
|
+
* 选中行的全部操作,已按显示顺序排列;父级持有,面板打开期间可以更新(如可用性变化)。
|
|
56
|
+
*/
|
|
57
|
+
actions: readonly LingActionPanelItem<T>[];
|
|
58
|
+
/**
|
|
59
|
+
* 组的小标题,按 `section` 取;未搜索时画在该组第一项上方,代替与上一组之间的分隔线。没有标题的组照常画分隔线。
|
|
60
|
+
* 由父级持有,缺省时都不画。
|
|
61
|
+
*/
|
|
62
|
+
sections?: Readonly<Partial<Record<string | number, string>>>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 操作面板的事件。
|
|
66
|
+
*/
|
|
67
|
+
export interface LingActionPanelEmits<T extends string> {
|
|
68
|
+
/**
|
|
69
|
+
* 单击或回车执行一项可用的操作。
|
|
70
|
+
*/
|
|
71
|
+
run: [id: T];
|
|
72
|
+
/**
|
|
73
|
+
* Esc(搜索框为空时)或单击面板外:收起。
|
|
74
|
+
*/
|
|
75
|
+
close: [];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 父级驱动的一次性动作。
|
|
79
|
+
*/
|
|
80
|
+
export interface LingActionPanelInstance {
|
|
81
|
+
/**
|
|
82
|
+
* 把焦点交给底部搜索框;父级在面板挂载后调用。
|
|
83
|
+
*/
|
|
84
|
+
focus(): void;
|
|
85
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { LingActionPanelInstance, LingActionPanelItem, LingActionPanelProps } from './LingActionPanel';
|
|
2
|
+
declare const __VLS_export: <T extends string>(__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<{
|
|
3
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<LingActionPanelProps<T> & {
|
|
4
|
+
onClose?: (() => any) | undefined;
|
|
5
|
+
onRun?: ((id: T) => any) | undefined;
|
|
6
|
+
}> & (typeof globalThis extends {
|
|
7
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
8
|
+
} ? P : {});
|
|
9
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<LingActionPanelInstance>) => void;
|
|
10
|
+
attrs: any;
|
|
11
|
+
slots: {
|
|
12
|
+
/**
|
|
13
|
+
* 每一项名称前的图标(项目图标类名写在使用方自己的 `.vue` 里)。
|
|
14
|
+
*/
|
|
15
|
+
icon?(props: {
|
|
16
|
+
action: LingActionPanelItem<T>;
|
|
17
|
+
}): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* 每一项名称与键帽之间的附加内容(如子列表的当前值与箭头、单选项的勾),图标同样由使用方提供。
|
|
20
|
+
*/
|
|
21
|
+
suffix?(props: {
|
|
22
|
+
action: LingActionPanelItem<T>;
|
|
23
|
+
}): unknown;
|
|
24
|
+
};
|
|
25
|
+
emit: ((evt: "close") => void) & ((evt: "run", id: T) => void);
|
|
26
|
+
}>) => import("vue").VNode & {
|
|
27
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
28
|
+
};
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
32
|
+
[K in keyof T]: T[K];
|
|
33
|
+
} : {
|
|
34
|
+
[K in keyof T as K]: T[K];
|
|
35
|
+
}) & {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 操作面板的过滤:按中文名称或英文别名,不区分大小写。
|
|
3
|
+
*/
|
|
4
|
+
import type { LingActionPanelItem } from './LingActionPanel';
|
|
5
|
+
/**
|
|
6
|
+
* 过滤操作:去掉首尾空格后不区分大小写,名称或别名包含关键字即保留;关键字为空时返回全部(新数组)。
|
|
7
|
+
* @param actions 全部操作,按显示顺序。
|
|
8
|
+
* @param keyword 搜索框的输入。
|
|
9
|
+
* @returns 保留的操作,顺序不变。
|
|
10
|
+
*/
|
|
11
|
+
export declare function filterActionPanelItems<T extends string>(actions: readonly LingActionPanelItem<T>[], keyword: string): LingActionPanelItem<T>[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 公开操作面板组件,供插件页面内的 ⌘K 面板使用。
|
|
3
|
+
*/
|
|
4
|
+
export { default } from './LingActionPanel.vue';
|
|
5
|
+
/**
|
|
6
|
+
* 公开操作面板的过滤函数(名称或别名,不区分大小写)。
|
|
7
|
+
*/
|
|
8
|
+
export { filterActionPanelItems } from './filter';
|
|
9
|
+
/**
|
|
10
|
+
* 公开操作面板的操作项、输入、事件与实例契约。
|
|
11
|
+
*/
|
|
12
|
+
export type { LingActionPanelEmits, LingActionPanelInstance, LingActionPanelItem, LingActionPanelProps, } from './LingActionPanel';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件底栏外壳:左区占满剩余宽度(内容超长时由内容自己省略),右区靠右不收缩。
|
|
3
|
+
*/
|
|
4
|
+
type __VLS_Slots = {
|
|
5
|
+
/**
|
|
6
|
+
* 左区:返回按钮、提示、状态文字。
|
|
7
|
+
*/
|
|
8
|
+
start?(): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* 右区:`LingShortcutButton` 与 `LingFooterDivider`。
|
|
11
|
+
*/
|
|
12
|
+
default?(): unknown;
|
|
13
|
+
};
|
|
14
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
15
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
18
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
19
|
+
new (): {
|
|
20
|
+
$slots: S;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 键帽:把快捷键显示成一排圆角小方块(参照 Raycast 底栏与弹层右侧的按键提示)。
|
|
3
|
+
* 搜索栏与内置插件共用(`@lingtools/ui`)。
|
|
4
|
+
* 只负责展示,按键文字由调用方按平台生成(`shortcutKeycaps`)。
|
|
5
|
+
*/
|
|
6
|
+
import type { LingKeycapsProps } from './LingKeycaps';
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<LingKeycapsProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<LingKeycapsProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 底栏按钮契约:可选的前置图标、文字、一组键帽(参照 Raycast 底栏右侧的动作按钮)。
|
|
3
|
+
* 只负责外观;快捷键由页面自己的键盘分派处理,键帽只是提示。
|
|
4
|
+
* `disabled`、`@click`、`@mousedown.prevent` 等经属性透传到根元素 `el-button`。
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* 底栏按钮的输入。
|
|
8
|
+
*/
|
|
9
|
+
export interface LingShortcutButtonProps {
|
|
10
|
+
/**
|
|
11
|
+
* 键帽文字,按显示顺序,如 `['⌘', 'K']`;由调用方按平台生成(`acceleratorKeycaps`),空数组时不画键帽。
|
|
12
|
+
*/
|
|
13
|
+
keys: readonly string[];
|
|
14
|
+
}
|