@xleddyl/443-components-vue 0.16.89 → 0.16.90
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/CATALOG.md +19 -18
- package/README.md +32 -3
- package/dist/components/core/Input.vue +1 -1
- package/dist/components/core/Input.vue.d.ts +1 -0
- package/dist/components/core/Textarea.vue +1 -1
- package/dist/components/core/Textarea.vue.d.ts +1 -0
- package/dist/components/data/Tree.vue +1 -1
- package/dist/components/data/Tree.vue.d.ts +1 -0
- package/dist/components/forms/Checkbox.vue +1 -1
- package/dist/components/forms/CheckboxGroup.vue +1 -1
- package/dist/components/forms/ColorInput.vue +1 -1
- package/dist/components/forms/ColorInput.vue.d.ts +1 -0
- package/dist/components/forms/Combobox.vue +1 -1
- package/dist/components/forms/DateInput.vue +1 -1
- package/dist/components/forms/DateInput.vue.d.ts +1 -0
- package/dist/components/forms/DatePicker.vue +1 -1
- package/dist/components/forms/DatePicker.vue.d.ts +1 -0
- package/dist/components/forms/FileInput.vue +1 -1
- package/dist/components/forms/FileInput.vue.d.ts +1 -0
- package/dist/components/forms/NumberInput.vue +1 -1
- package/dist/components/forms/NumberInput.vue.d.ts +1 -0
- package/dist/components/forms/PaletteSelect.vue +1 -1
- package/dist/components/forms/PaletteSelect.vue.d.ts +1 -0
- package/dist/components/forms/PasswordInput.vue +1 -1
- package/dist/components/forms/PasswordInput.vue.d.ts +1 -0
- package/dist/components/forms/PinInput.vue +1 -1
- package/dist/components/forms/PinInput.vue.d.ts +1 -0
- package/dist/components/forms/RadioGroup.vue +1 -1
- package/dist/components/forms/SegmentedControl.vue +1 -1
- package/dist/components/forms/Select.vue +1 -1
- package/dist/components/forms/Slider.vue +1 -1
- package/dist/components/forms/Slider.vue.d.ts +1 -0
- package/dist/components/forms/Switch.vue +1 -1
- package/dist/components/forms/Switch.vue.d.ts +1 -0
- package/dist/components/forms/TimeInput.vue +1 -1
- package/dist/components/forms/TimeInput.vue.d.ts +1 -0
- package/dist/components/forms/TreeSelect.vue +1 -1
- package/dist/components/forms/TreeSelect.vue.d.ts +1 -0
- package/dist/components/overlays/CommandList.vue +397 -0
- package/dist/components/overlays/CommandList.vue.d.ts +255 -0
- package/dist/components/overlays/CommandPalette.vue +48 -315
- package/dist/components/overlays/CommandPalette.vue.d.ts +2 -1
- package/dist/components/overlays/Popover.vue +24 -5
- package/dist/components/overlays/Popover.vue.d.ts +4 -1
- package/dist/components/overlays/index.d.ts +1 -0
- package/dist/components/overlays/index.mjs +1 -0
- package/dist/components/overlays/types.d.ts +1 -0
- package/dist/composables/useField.mjs +1 -1
- package/dist/editor/RichTextEditor.vue +1 -1
- package/dist/editor/RichTextEditor.vue.d.ts +1 -0
- package/dist/editor/TemplateEditor.vue +1 -1
- package/dist/editor/TemplateEditor.vue.d.ts +1 -0
- package/dist/internal/core/DivElement.d.ts +2 -0
- package/dist/internal/core/DivElement.mjs +8 -0
- package/dist/internal/floating/layer.d.ts +1 -0
- package/dist/internal/floating/layer.mjs +56 -7
- package/dist/internal/floating/position.d.ts +2 -0
- package/dist/internal/floating/position.mjs +25 -0
- package/dist/styles/overlays/command.css +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DivElement v-bind="$attrs" class="k-command-list">
|
|
3
|
+
<div class="k-command-bar">
|
|
4
|
+
<label :id="labelId" :for="inputId" class="k-visually-hidden">{{ labelText }}</label>
|
|
5
|
+
<Icon name="magnifying-glass" class="k-command-bar-icon" />
|
|
6
|
+
<input
|
|
7
|
+
:id="inputId"
|
|
8
|
+
ref="inputRef"
|
|
9
|
+
v-model="query"
|
|
10
|
+
:autofocus="autofocus"
|
|
11
|
+
type="text"
|
|
12
|
+
role="combobox"
|
|
13
|
+
class="k-command-input"
|
|
14
|
+
:placeholder="placeholderText"
|
|
15
|
+
autocomplete="off"
|
|
16
|
+
autocapitalize="off"
|
|
17
|
+
spellcheck="false"
|
|
18
|
+
aria-autocomplete="list"
|
|
19
|
+
:aria-controls="listId"
|
|
20
|
+
:aria-expanded="flat.length > 0 ? 'true' : 'false'"
|
|
21
|
+
:aria-activedescendant="activeId"
|
|
22
|
+
@keydown="onKeydown"
|
|
23
|
+
/>
|
|
24
|
+
<Spinner v-if="busy" size="xs" decorative />
|
|
25
|
+
<span aria-hidden="true"><Kbd size="sm">Esc</Kbd></span>
|
|
26
|
+
</div>
|
|
27
|
+
<div ref="bodyRef" class="k-command-body">
|
|
28
|
+
<div
|
|
29
|
+
v-show="flat.length"
|
|
30
|
+
:id="listId"
|
|
31
|
+
role="listbox"
|
|
32
|
+
:aria-labelledby="labelId"
|
|
33
|
+
class="k-command-results"
|
|
34
|
+
>
|
|
35
|
+
<div
|
|
36
|
+
v-for="(group, groupIndex) in rendered"
|
|
37
|
+
:key="group.key"
|
|
38
|
+
role="group"
|
|
39
|
+
:aria-labelledby="hasLabel(group) ? `${listId}-group-${groupIndex}` : void 0"
|
|
40
|
+
class="k-command-group"
|
|
41
|
+
:class="{ 'is-pinned': group.pinned }"
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
v-if="hasLabel(group)"
|
|
45
|
+
:id="`${listId}-group-${groupIndex}`"
|
|
46
|
+
class="k-command-group-label"
|
|
47
|
+
>
|
|
48
|
+
<slot
|
|
49
|
+
name="group-label"
|
|
50
|
+
:group="group.source"
|
|
51
|
+
:label="group.label"
|
|
52
|
+
:description="group.description"
|
|
53
|
+
:recent="group.recent"
|
|
54
|
+
>
|
|
55
|
+
<span class="k-command-group-title">{{ group.label }}</span>
|
|
56
|
+
<span v-if="group.description" class="k-command-group-description">
|
|
57
|
+
{{ group.description }}
|
|
58
|
+
</span>
|
|
59
|
+
</slot>
|
|
60
|
+
</div>
|
|
61
|
+
<div
|
|
62
|
+
v-for="entry in group.items"
|
|
63
|
+
:id="optionId(entry.index)"
|
|
64
|
+
:key="entry.key"
|
|
65
|
+
role="option"
|
|
66
|
+
class="k-command-option"
|
|
67
|
+
:class="{ 'is-active': entry.index === active }"
|
|
68
|
+
:aria-selected="entry.index === active ? 'true' : 'false'"
|
|
69
|
+
:aria-disabled="entry.item.disabled ? 'true' : void 0"
|
|
70
|
+
@pointermove="active = entry.index"
|
|
71
|
+
@click="select(entry)"
|
|
72
|
+
>
|
|
73
|
+
<slot name="item" :item="entry.item" :active="entry.index === active">
|
|
74
|
+
<Icon
|
|
75
|
+
:name="
|
|
76
|
+
entry.item.icon ?? group.icon ?? (group.recent ? 'arrow-path' : group.pinned ? 'plus' : 'arrow-right')
|
|
77
|
+
"
|
|
78
|
+
class="k-command-option-icon"
|
|
79
|
+
/>
|
|
80
|
+
<span class="k-command-option-text">
|
|
81
|
+
<span class="k-command-option-label">{{ entry.item.label }}</span>
|
|
82
|
+
<span v-if="entry.item.description" class="k-command-option-description">
|
|
83
|
+
{{ entry.item.description }}
|
|
84
|
+
</span>
|
|
85
|
+
</span>
|
|
86
|
+
<Badge
|
|
87
|
+
v-if="entry.item.badge"
|
|
88
|
+
v-bind="badgeProps(entry.item.badge)"
|
|
89
|
+
size="sm"
|
|
90
|
+
class="k-command-option-badge"
|
|
91
|
+
/>
|
|
92
|
+
<span
|
|
93
|
+
v-if="entry.item.shortcut"
|
|
94
|
+
class="k-command-option-shortcut"
|
|
95
|
+
aria-hidden="true"
|
|
96
|
+
>
|
|
97
|
+
<Kbd
|
|
98
|
+
v-for="(key, keyIndex) in formatHotkey(entry.item.shortcut, apple)"
|
|
99
|
+
:key="keyIndex"
|
|
100
|
+
size="sm"
|
|
101
|
+
>
|
|
102
|
+
{{ key }}
|
|
103
|
+
</Kbd>
|
|
104
|
+
</span>
|
|
105
|
+
</slot>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<p v-if="hint" class="k-command-hint">
|
|
110
|
+
<slot name="empty" :query="query">{{ hint }}</slot>
|
|
111
|
+
</p>
|
|
112
|
+
<div v-if="resultCount && (notice || $slots['after-results'])" class="k-command-notice">
|
|
113
|
+
<slot name="after-results" :query="query" :count="resultCount">{{ notice }}</slot>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
<div v-if="footer" class="k-command-footer" aria-hidden="true">
|
|
117
|
+
<span><Kbd size="sm">↑</Kbd><Kbd size="sm">↓</Kbd> {{ moveText }}</span>
|
|
118
|
+
<span><Kbd size="sm">↵</Kbd> {{ selectText }}</span>
|
|
119
|
+
<span><Kbd size="sm">Esc</Kbd> {{ closeText }}</span>
|
|
120
|
+
</div>
|
|
121
|
+
<LiveRegion :message="status" />
|
|
122
|
+
</DivElement>
|
|
123
|
+
</template>
|
|
124
|
+
|
|
125
|
+
<script setup>
|
|
126
|
+
import { computed, nextTick, onMounted, ref, shallowRef, useId, useTemplateRef, watch } from "vue";
|
|
127
|
+
import { formatHotkey } from "../../composables/useHotkey";
|
|
128
|
+
import { useApplePlatform } from "../../internal/core/env";
|
|
129
|
+
import { useLocale } from "../../composables/useLocale";
|
|
130
|
+
import { nextEnabledIndex } from "../../internal/core/roving";
|
|
131
|
+
import { useAsyncSearch } from "../../internal/core/search";
|
|
132
|
+
import { matchesSearch } from "../../internal/core/text";
|
|
133
|
+
import { readStorageJson, writeStorageJson } from "../../internal/core/storage";
|
|
134
|
+
import { useRouterLike } from "../../internal/layout/route";
|
|
135
|
+
import { DivElement } from "../../internal/core/DivElement";
|
|
136
|
+
import LiveRegion from "../../internal/core/LiveRegion.vue";
|
|
137
|
+
import Icon from "../core/Icon.vue";
|
|
138
|
+
import Badge from "../data/Badge.vue";
|
|
139
|
+
import Kbd from "../core/Kbd.vue";
|
|
140
|
+
import Spinner from "../core/Spinner.vue";
|
|
141
|
+
import { provideFieldBoundary } from "../../composables/useFieldBoundary";
|
|
142
|
+
defineOptions({ inheritAttrs: false });
|
|
143
|
+
provideFieldBoundary();
|
|
144
|
+
const props = defineProps({
|
|
145
|
+
groups: { type: Array, required: false, default: () => [] },
|
|
146
|
+
search: { type: Function, required: false },
|
|
147
|
+
pinned: { type: [Array, Function], required: false },
|
|
148
|
+
debounce: { type: Number, required: false, default: 150 },
|
|
149
|
+
minQueryLength: { type: Number, required: false, default: 0 },
|
|
150
|
+
filter: { type: Boolean, required: false, default: true },
|
|
151
|
+
loading: { type: Boolean, required: false },
|
|
152
|
+
placeholder: { type: String, required: false },
|
|
153
|
+
label: { type: String, required: false },
|
|
154
|
+
autofocus: { type: Boolean, required: false, default: true },
|
|
155
|
+
recentKey: { type: String, required: false },
|
|
156
|
+
recentLimit: { type: Number, required: false, default: 5 },
|
|
157
|
+
recentLabel: { type: String, required: false },
|
|
158
|
+
emptyText: { type: [String, Function], required: false },
|
|
159
|
+
minQueryText: { type: String, required: false },
|
|
160
|
+
errorText: { type: String, required: false },
|
|
161
|
+
loadingText: { type: String, required: false },
|
|
162
|
+
resultsText: { type: Function, required: false },
|
|
163
|
+
footer: { type: Boolean, required: false },
|
|
164
|
+
footerMove: { type: String, required: false },
|
|
165
|
+
footerSelect: { type: String, required: false },
|
|
166
|
+
footerClose: { type: String, required: false },
|
|
167
|
+
notice: { type: String, required: false }
|
|
168
|
+
});
|
|
169
|
+
const { t } = useLocale();
|
|
170
|
+
const apple = useApplePlatform();
|
|
171
|
+
const placeholderText = computed(() => props.placeholder ?? t("commandPalette.placeholder"));
|
|
172
|
+
const labelText = computed(() => props.label ?? t("commandPalette.label"));
|
|
173
|
+
const recentText = computed(() => props.recentLabel ?? t("commandPalette.recent"));
|
|
174
|
+
const emptyLabel = computed(() => {
|
|
175
|
+
const text = props.emptyText;
|
|
176
|
+
if (typeof text === "function") return text(term.value);
|
|
177
|
+
return text ?? t("common.noResults");
|
|
178
|
+
});
|
|
179
|
+
const minQueryLabel = computed(() => props.minQueryText ?? t("commandPalette.minQuery"));
|
|
180
|
+
const errorLabel = computed(() => props.errorText ?? t("commandPalette.error"));
|
|
181
|
+
const loadingLabel = computed(() => props.loadingText ?? t("common.loading"));
|
|
182
|
+
const moveText = computed(() => props.footerMove ?? t("commandPalette.move"));
|
|
183
|
+
const selectText = computed(() => props.footerSelect ?? t("commandPalette.select"));
|
|
184
|
+
const closeText = computed(() => props.footerClose ?? t("commandPalette.close"));
|
|
185
|
+
const emit = defineEmits(["select", "close"]);
|
|
186
|
+
const slots = defineSlots();
|
|
187
|
+
const query = defineModel("query", { type: String, ...{ default: "" } });
|
|
188
|
+
const baseId = useId();
|
|
189
|
+
const labelId = `${baseId}-label`;
|
|
190
|
+
const inputId = `${baseId}-input`;
|
|
191
|
+
const listId = `${baseId}-list`;
|
|
192
|
+
const bodyRef = useTemplateRef("bodyRef");
|
|
193
|
+
const inputRef = useTemplateRef("inputRef");
|
|
194
|
+
const router = useRouterLike();
|
|
195
|
+
const active = ref(0);
|
|
196
|
+
const remote = shallowRef(null);
|
|
197
|
+
const recent = shallowRef([]);
|
|
198
|
+
const term = computed(() => query.value.trim());
|
|
199
|
+
const busy = computed(() => props.loading || search.searching.value);
|
|
200
|
+
const belowMinimum = computed(
|
|
201
|
+
() => Boolean(props.search) && term.value.length > 0 && term.value.length < props.minQueryLength
|
|
202
|
+
);
|
|
203
|
+
const pinnedItems = computed(() => {
|
|
204
|
+
const pinned = props.pinned;
|
|
205
|
+
if (!pinned) return [];
|
|
206
|
+
return typeof pinned === "function" ? pinned(term.value) : pinned;
|
|
207
|
+
});
|
|
208
|
+
const resultGroups = computed(() => {
|
|
209
|
+
if (props.search && term.value) return remote.value ?? [];
|
|
210
|
+
if (!props.filter || !term.value || props.search) return props.groups;
|
|
211
|
+
return props.groups.map((group) => ({
|
|
212
|
+
...group,
|
|
213
|
+
items: group.items.filter(
|
|
214
|
+
(item) => matchesSearch([item.label, item.description, ...item.keywords ?? []], term.value)
|
|
215
|
+
)
|
|
216
|
+
})).filter((group) => group.items.length);
|
|
217
|
+
});
|
|
218
|
+
const allItems = computed(() => props.groups.flatMap((group) => group.items));
|
|
219
|
+
const rendered = computed(() => {
|
|
220
|
+
const list = [];
|
|
221
|
+
let index = 0;
|
|
222
|
+
if (pinnedItems.value.length) {
|
|
223
|
+
list.push({
|
|
224
|
+
key: "pinned",
|
|
225
|
+
recent: false,
|
|
226
|
+
pinned: true,
|
|
227
|
+
items: pinnedItems.value.map((item) => ({
|
|
228
|
+
key: `pinned-${item.id}`,
|
|
229
|
+
index: index++,
|
|
230
|
+
item,
|
|
231
|
+
pinned: true
|
|
232
|
+
}))
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
if (!term.value && props.recentKey && recent.value.length) {
|
|
236
|
+
list.push({
|
|
237
|
+
key: "recent",
|
|
238
|
+
label: recentText.value,
|
|
239
|
+
recent: true,
|
|
240
|
+
pinned: false,
|
|
241
|
+
items: recent.value.map((snapshot) => {
|
|
242
|
+
const item = allItems.value.find((candidate) => candidate.id === snapshot.id) ?? snapshot;
|
|
243
|
+
return { key: `recent-${snapshot.id}`, index: index++, item, pinned: false };
|
|
244
|
+
})
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
for (const group of resultGroups.value) {
|
|
248
|
+
const items = group.more ? [
|
|
249
|
+
...group.items,
|
|
250
|
+
{
|
|
251
|
+
icon: "arrow-right",
|
|
252
|
+
...group.more,
|
|
253
|
+
id: group.more.id ?? `${group.id}:more`
|
|
254
|
+
}
|
|
255
|
+
] : group.items;
|
|
256
|
+
list.push({
|
|
257
|
+
key: `group-${group.id}`,
|
|
258
|
+
label: group.label,
|
|
259
|
+
description: group.description,
|
|
260
|
+
icon: group.icon,
|
|
261
|
+
source: group,
|
|
262
|
+
recent: false,
|
|
263
|
+
pinned: false,
|
|
264
|
+
items: items.map((item) => ({
|
|
265
|
+
key: `${group.id}-${item.id}`,
|
|
266
|
+
index: index++,
|
|
267
|
+
item,
|
|
268
|
+
pinned: false
|
|
269
|
+
}))
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return list;
|
|
273
|
+
});
|
|
274
|
+
const flat = computed(() => rendered.value.flatMap((group) => group.items));
|
|
275
|
+
const resultCount = computed(() => flat.value.filter((entry) => !entry.pinned).length);
|
|
276
|
+
const activeId = computed(() => flat.value.length ? optionId(active.value) : void 0);
|
|
277
|
+
const hint = computed(() => {
|
|
278
|
+
if (belowMinimum.value) return minQueryLabel.value;
|
|
279
|
+
if (search.failed.value) return errorLabel.value;
|
|
280
|
+
if (!busy.value && !resultCount.value && (term.value || !props.search)) return emptyLabel.value;
|
|
281
|
+
return "";
|
|
282
|
+
});
|
|
283
|
+
const status = computed(() => {
|
|
284
|
+
if (hint.value) return hint.value;
|
|
285
|
+
if (busy.value) return loadingLabel.value;
|
|
286
|
+
const count = resultCount.value;
|
|
287
|
+
return props.resultsText ? props.resultsText(count) : t("commandPalette.results", { count });
|
|
288
|
+
});
|
|
289
|
+
function hasLabel(group) {
|
|
290
|
+
return !group.pinned && Boolean(group.label || slots["group-label"]);
|
|
291
|
+
}
|
|
292
|
+
function optionId(index) {
|
|
293
|
+
return `${listId}-option-${index}`;
|
|
294
|
+
}
|
|
295
|
+
const search = useAsyncSearch({
|
|
296
|
+
search: () => props.search,
|
|
297
|
+
onResults: (groups) => remote.value = groups,
|
|
298
|
+
onError: () => remote.value = []
|
|
299
|
+
});
|
|
300
|
+
function firstEnabled() {
|
|
301
|
+
return Math.max(0, nextEnabledIndex(flat.value.length, 0, 1, isDisabled));
|
|
302
|
+
}
|
|
303
|
+
watch(term, (value) => {
|
|
304
|
+
active.value = firstEnabled();
|
|
305
|
+
if (!props.search) return;
|
|
306
|
+
if (!value || value.length < props.minQueryLength) {
|
|
307
|
+
search.cancel();
|
|
308
|
+
remote.value = null;
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
search.schedule(value, props.debounce);
|
|
312
|
+
});
|
|
313
|
+
watch(flat, (items) => {
|
|
314
|
+
if (active.value >= items.length || isDisabled(active.value)) active.value = firstEnabled();
|
|
315
|
+
});
|
|
316
|
+
watch(active, (index) => {
|
|
317
|
+
nextTick(() => {
|
|
318
|
+
const option = document.getElementById(optionId(index));
|
|
319
|
+
if (option && bodyRef.value?.contains(option)) option.scrollIntoView({ block: "nearest" });
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
function badgeProps(badge) {
|
|
323
|
+
return typeof badge === "string" ? { label: badge } : badge;
|
|
324
|
+
}
|
|
325
|
+
function readRecent() {
|
|
326
|
+
if (!props.recentKey) return;
|
|
327
|
+
const stored = readStorageJson(props.recentKey);
|
|
328
|
+
recent.value = Array.isArray(stored) ? stored.slice(0, props.recentLimit) : [];
|
|
329
|
+
}
|
|
330
|
+
function saveRecent(item) {
|
|
331
|
+
if (!props.recentKey) return;
|
|
332
|
+
const snapshot = {
|
|
333
|
+
id: item.id,
|
|
334
|
+
label: item.label,
|
|
335
|
+
description: item.description,
|
|
336
|
+
icon: item.icon,
|
|
337
|
+
to: item.to,
|
|
338
|
+
href: item.href
|
|
339
|
+
};
|
|
340
|
+
recent.value = [snapshot, ...recent.value.filter((entry) => entry.id !== item.id)].slice(
|
|
341
|
+
0,
|
|
342
|
+
props.recentLimit
|
|
343
|
+
);
|
|
344
|
+
writeStorageJson(props.recentKey, recent.value);
|
|
345
|
+
}
|
|
346
|
+
function navigate(item) {
|
|
347
|
+
if (item.to !== void 0 && router) {
|
|
348
|
+
router.push(item.to);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const href = item.href ?? (typeof item.to === "string" ? item.to : void 0);
|
|
352
|
+
if (href) window.location.assign(href);
|
|
353
|
+
}
|
|
354
|
+
function select(entry) {
|
|
355
|
+
const item = entry?.item;
|
|
356
|
+
if (!item || item.disabled) return;
|
|
357
|
+
if (!entry.pinned) saveRecent(item);
|
|
358
|
+
emit("select", item);
|
|
359
|
+
item.onSelect?.(item);
|
|
360
|
+
if (!item.onSelect) navigate(item);
|
|
361
|
+
}
|
|
362
|
+
function isDisabled(index) {
|
|
363
|
+
return Boolean(flat.value[index]?.item.disabled);
|
|
364
|
+
}
|
|
365
|
+
function onKeydown(event) {
|
|
366
|
+
const count = flat.value.length;
|
|
367
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
368
|
+
event.preventDefault();
|
|
369
|
+
if (!count) return;
|
|
370
|
+
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
371
|
+
const next = nextEnabledIndex(count, active.value + step, step, isDisabled);
|
|
372
|
+
if (next !== -1) active.value = next;
|
|
373
|
+
} else if ((event.key === "Home" || event.key === "End") && event.ctrlKey && count) {
|
|
374
|
+
event.preventDefault();
|
|
375
|
+
const next = event.key === "Home" ? nextEnabledIndex(count, 0, 1, isDisabled) : nextEnabledIndex(count, count - 1, -1, isDisabled);
|
|
376
|
+
if (next !== -1) active.value = next;
|
|
377
|
+
} else if (event.key === "Enter" && !event.isComposing) {
|
|
378
|
+
event.preventDefault();
|
|
379
|
+
select(flat.value[active.value]);
|
|
380
|
+
} else if (event.key === "Escape" && !event.isComposing) {
|
|
381
|
+
emit("close");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function focus() {
|
|
385
|
+
inputRef.value?.focus({ preventScroll: true });
|
|
386
|
+
inputRef.value?.select();
|
|
387
|
+
}
|
|
388
|
+
function refresh() {
|
|
389
|
+
readRecent();
|
|
390
|
+
active.value = firstEnabled();
|
|
391
|
+
}
|
|
392
|
+
onMounted(() => {
|
|
393
|
+
readRecent();
|
|
394
|
+
if (props.autofocus) inputRef.value?.focus({ preventScroll: true });
|
|
395
|
+
});
|
|
396
|
+
defineExpose({ focus, refresh });
|
|
397
|
+
</script>
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import type { CommandEmptyText, CommandGroup, CommandGroupLabelSlotProps, CommandItem, CommandPinned, CommandSearch } from './types';
|
|
2
|
+
declare const __VLS_export: <T = unknown>(__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<({
|
|
4
|
+
groups?: CommandGroup<T>[];
|
|
5
|
+
search?: CommandSearch<T>;
|
|
6
|
+
pinned?: CommandPinned<T>;
|
|
7
|
+
debounce?: number;
|
|
8
|
+
minQueryLength?: number;
|
|
9
|
+
filter?: boolean;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
autofocus?: boolean;
|
|
14
|
+
recentKey?: string;
|
|
15
|
+
recentLimit?: number;
|
|
16
|
+
recentLabel?: string;
|
|
17
|
+
emptyText?: CommandEmptyText;
|
|
18
|
+
minQueryText?: string;
|
|
19
|
+
errorText?: string;
|
|
20
|
+
loadingText?: string;
|
|
21
|
+
resultsText?: (count: number) => string;
|
|
22
|
+
footer?: boolean;
|
|
23
|
+
footerMove?: string;
|
|
24
|
+
footerSelect?: string;
|
|
25
|
+
footerClose?: string;
|
|
26
|
+
notice?: string;
|
|
27
|
+
} & {
|
|
28
|
+
query?: string;
|
|
29
|
+
}) & {
|
|
30
|
+
onClose?: (() => any) | undefined;
|
|
31
|
+
onSelect?: ((item: CommandItem<T>) => any) | undefined;
|
|
32
|
+
"onUpdate:query"?: ((value: string) => any) | undefined;
|
|
33
|
+
} & Partial<NonNullable<Partial<{
|
|
34
|
+
inlist?: any;
|
|
35
|
+
}> & Omit<{
|
|
36
|
+
readonly prefix?: string | undefined | undefined;
|
|
37
|
+
readonly title?: string | undefined | undefined;
|
|
38
|
+
readonly style?: import("vue").StyleValue;
|
|
39
|
+
readonly results?: (string | number) | undefined;
|
|
40
|
+
readonly placeholder?: string | undefined | undefined;
|
|
41
|
+
readonly id?: string | undefined | undefined;
|
|
42
|
+
readonly dir?: string | undefined | undefined;
|
|
43
|
+
readonly contextmenu?: string | undefined | undefined;
|
|
44
|
+
readonly hidden?: "" | "hidden" | (boolean | "true" | "false") | "until-found" | undefined;
|
|
45
|
+
readonly class?: import("vue").ClassValue;
|
|
46
|
+
readonly role?: string | undefined | undefined;
|
|
47
|
+
readonly 'aria-label'?: string | undefined | undefined;
|
|
48
|
+
readonly 'aria-hidden'?: (boolean | "true" | "false") | undefined;
|
|
49
|
+
readonly onCopy?: ((payload: ClipboardEvent) => void) | undefined;
|
|
50
|
+
readonly onCut?: ((payload: ClipboardEvent) => void) | undefined;
|
|
51
|
+
readonly onPaste?: ((payload: ClipboardEvent) => void) | undefined;
|
|
52
|
+
readonly onCompositionend?: ((payload: CompositionEvent) => void) | undefined;
|
|
53
|
+
readonly onCompositionstart?: ((payload: CompositionEvent) => void) | undefined;
|
|
54
|
+
readonly onCompositionupdate?: ((payload: CompositionEvent) => void) | undefined;
|
|
55
|
+
readonly onDrag?: ((payload: DragEvent) => void) | undefined;
|
|
56
|
+
readonly onDragend?: ((payload: DragEvent) => void) | undefined;
|
|
57
|
+
readonly onDragenter?: ((payload: DragEvent) => void) | undefined;
|
|
58
|
+
readonly onDragexit?: ((payload: DragEvent) => void) | undefined;
|
|
59
|
+
readonly onDragleave?: ((payload: DragEvent) => void) | undefined;
|
|
60
|
+
readonly onDragover?: ((payload: DragEvent) => void) | undefined;
|
|
61
|
+
readonly onDragstart?: ((payload: DragEvent) => void) | undefined;
|
|
62
|
+
readonly onDrop?: ((payload: DragEvent) => void) | undefined;
|
|
63
|
+
readonly onFocus?: ((payload: FocusEvent) => void) | undefined;
|
|
64
|
+
readonly onFocusin?: ((payload: FocusEvent) => void) | undefined;
|
|
65
|
+
readonly onFocusout?: ((payload: FocusEvent) => void) | undefined;
|
|
66
|
+
readonly onBlur?: ((payload: FocusEvent) => void) | undefined;
|
|
67
|
+
readonly onChange?: ((payload: Event) => void) | undefined;
|
|
68
|
+
readonly onBeforeinput?: ((payload: InputEvent) => void) | undefined;
|
|
69
|
+
readonly onFormdata?: ((payload: FormDataEvent) => void) | undefined;
|
|
70
|
+
readonly onInput?: ((payload: InputEvent) => void) | undefined;
|
|
71
|
+
readonly onReset?: ((payload: Event) => void) | undefined;
|
|
72
|
+
readonly onSubmit?: ((payload: SubmitEvent) => void) | undefined;
|
|
73
|
+
readonly onInvalid?: ((payload: Event) => void) | undefined;
|
|
74
|
+
readonly onFullscreenchange?: ((payload: Event) => void) | undefined;
|
|
75
|
+
readonly onFullscreenerror?: ((payload: Event) => void) | undefined;
|
|
76
|
+
readonly onLoad?: ((payload: Event) => void) | undefined;
|
|
77
|
+
readonly onError?: ((payload: Event) => void) | undefined;
|
|
78
|
+
readonly onKeydown?: ((payload: KeyboardEvent) => void) | undefined;
|
|
79
|
+
readonly onKeypress?: ((payload: KeyboardEvent) => void) | undefined;
|
|
80
|
+
readonly onKeyup?: ((payload: KeyboardEvent) => void) | undefined;
|
|
81
|
+
readonly onDblclick?: ((payload: MouseEvent) => void) | undefined;
|
|
82
|
+
readonly onMousedown?: ((payload: MouseEvent) => void) | undefined;
|
|
83
|
+
readonly onMouseenter?: ((payload: MouseEvent) => void) | undefined;
|
|
84
|
+
readonly onMouseleave?: ((payload: MouseEvent) => void) | undefined;
|
|
85
|
+
readonly onMousemove?: ((payload: MouseEvent) => void) | undefined;
|
|
86
|
+
readonly onMouseout?: ((payload: MouseEvent) => void) | undefined;
|
|
87
|
+
readonly onMouseover?: ((payload: MouseEvent) => void) | undefined;
|
|
88
|
+
readonly onMouseup?: ((payload: MouseEvent) => void) | undefined;
|
|
89
|
+
readonly onAbort?: ((payload: UIEvent) => void) | undefined;
|
|
90
|
+
readonly onCanplay?: ((payload: Event) => void) | undefined;
|
|
91
|
+
readonly onCanplaythrough?: ((payload: Event) => void) | undefined;
|
|
92
|
+
readonly onDurationchange?: ((payload: Event) => void) | undefined;
|
|
93
|
+
readonly onEmptied?: ((payload: Event) => void) | undefined;
|
|
94
|
+
readonly onEncrypted?: ((payload: MediaEncryptedEvent) => void) | undefined;
|
|
95
|
+
readonly onEnded?: ((payload: Event) => void) | undefined;
|
|
96
|
+
readonly onLoadeddata?: ((payload: Event) => void) | undefined;
|
|
97
|
+
readonly onLoadedmetadata?: ((payload: Event) => void) | undefined;
|
|
98
|
+
readonly onLoadstart?: ((payload: Event) => void) | undefined;
|
|
99
|
+
readonly onPause?: ((payload: Event) => void) | undefined;
|
|
100
|
+
readonly onPlay?: ((payload: Event) => void) | undefined;
|
|
101
|
+
readonly onPlaying?: ((payload: Event) => void) | undefined;
|
|
102
|
+
readonly onProgress?: ((payload: ProgressEvent<EventTarget>) => void) | undefined;
|
|
103
|
+
readonly onRatechange?: ((payload: Event) => void) | undefined;
|
|
104
|
+
readonly onSeeked?: ((payload: Event) => void) | undefined;
|
|
105
|
+
readonly onSeeking?: ((payload: Event) => void) | undefined;
|
|
106
|
+
readonly onStalled?: ((payload: Event) => void) | undefined;
|
|
107
|
+
readonly onSuspend?: ((payload: Event) => void) | undefined;
|
|
108
|
+
readonly onTimeupdate?: ((payload: Event) => void) | undefined;
|
|
109
|
+
readonly onVolumechange?: ((payload: Event) => void) | undefined;
|
|
110
|
+
readonly onWaiting?: ((payload: Event) => void) | undefined;
|
|
111
|
+
readonly onScroll?: ((payload: Event) => void) | undefined;
|
|
112
|
+
readonly onScrollend?: ((payload: Event) => void) | undefined;
|
|
113
|
+
readonly onTouchcancel?: ((payload: TouchEvent) => void) | undefined;
|
|
114
|
+
readonly onTouchend?: ((payload: TouchEvent) => void) | undefined;
|
|
115
|
+
readonly onTouchmove?: ((payload: TouchEvent) => void) | undefined;
|
|
116
|
+
readonly onTouchstart?: ((payload: TouchEvent) => void) | undefined;
|
|
117
|
+
readonly onAuxclick?: ((payload: PointerEvent) => void) | undefined;
|
|
118
|
+
readonly onClick?: ((payload: PointerEvent) => void) | undefined;
|
|
119
|
+
readonly onContextmenu?: ((payload: PointerEvent) => void) | undefined;
|
|
120
|
+
readonly onGotpointercapture?: ((payload: PointerEvent) => void) | undefined;
|
|
121
|
+
readonly onLostpointercapture?: ((payload: PointerEvent) => void) | undefined;
|
|
122
|
+
readonly onPointerdown?: ((payload: PointerEvent) => void) | undefined;
|
|
123
|
+
readonly onPointermove?: ((payload: PointerEvent) => void) | undefined;
|
|
124
|
+
readonly onPointerup?: ((payload: PointerEvent) => void) | undefined;
|
|
125
|
+
readonly onPointercancel?: ((payload: PointerEvent) => void) | undefined;
|
|
126
|
+
readonly onPointerenter?: ((payload: PointerEvent) => void) | undefined;
|
|
127
|
+
readonly onPointerleave?: ((payload: PointerEvent) => void) | undefined;
|
|
128
|
+
readonly onPointerover?: ((payload: PointerEvent) => void) | undefined;
|
|
129
|
+
readonly onPointerout?: ((payload: PointerEvent) => void) | undefined;
|
|
130
|
+
readonly onBeforetoggle?: ((payload: ToggleEvent) => void) | undefined;
|
|
131
|
+
readonly onToggle?: ((payload: ToggleEvent) => void) | undefined;
|
|
132
|
+
readonly onWheel?: ((payload: WheelEvent) => void) | undefined;
|
|
133
|
+
readonly onAnimationcancel?: ((payload: AnimationEvent) => void) | undefined;
|
|
134
|
+
readonly onAnimationstart?: ((payload: AnimationEvent) => void) | undefined;
|
|
135
|
+
readonly onAnimationend?: ((payload: AnimationEvent) => void) | undefined;
|
|
136
|
+
readonly onAnimationiteration?: ((payload: AnimationEvent) => void) | undefined;
|
|
137
|
+
readonly onSecuritypolicyviolation?: ((payload: SecurityPolicyViolationEvent) => void) | undefined;
|
|
138
|
+
readonly onTransitioncancel?: ((payload: TransitionEvent) => void) | undefined;
|
|
139
|
+
readonly onTransitionend?: ((payload: TransitionEvent) => void) | undefined;
|
|
140
|
+
readonly onTransitionrun?: ((payload: TransitionEvent) => void) | undefined;
|
|
141
|
+
readonly onTransitionstart?: ((payload: TransitionEvent) => void) | undefined;
|
|
142
|
+
readonly innerHTML?: string | undefined | undefined;
|
|
143
|
+
readonly color?: string | undefined | undefined;
|
|
144
|
+
readonly lang?: string | undefined | undefined;
|
|
145
|
+
readonly tabindex?: (string | number) | undefined;
|
|
146
|
+
readonly 'aria-activedescendant'?: string | undefined | undefined;
|
|
147
|
+
readonly 'aria-atomic'?: (boolean | "true" | "false") | undefined;
|
|
148
|
+
readonly 'aria-autocomplete'?: "none" | "inline" | "list" | "both" | undefined | undefined;
|
|
149
|
+
readonly 'aria-busy'?: (boolean | "true" | "false") | undefined;
|
|
150
|
+
readonly 'aria-checked'?: (boolean | "true" | "false") | "mixed" | undefined;
|
|
151
|
+
readonly 'aria-colcount'?: (string | number) | undefined;
|
|
152
|
+
readonly 'aria-colindex'?: (string | number) | undefined;
|
|
153
|
+
readonly 'aria-colspan'?: (string | number) | undefined;
|
|
154
|
+
readonly 'aria-controls'?: string | undefined | undefined;
|
|
155
|
+
readonly 'aria-current'?: "page" | "time" | (boolean | "true" | "false") | "step" | "location" | "date" | undefined;
|
|
156
|
+
readonly 'aria-describedby'?: string | undefined | undefined;
|
|
157
|
+
readonly 'aria-details'?: string | undefined | undefined;
|
|
158
|
+
readonly 'aria-disabled'?: (boolean | "true" | "false") | undefined;
|
|
159
|
+
readonly 'aria-dropeffect'?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined | undefined;
|
|
160
|
+
readonly 'aria-errormessage'?: string | undefined | undefined;
|
|
161
|
+
readonly 'aria-expanded'?: (boolean | "true" | "false") | undefined;
|
|
162
|
+
readonly 'aria-flowto'?: string | undefined | undefined;
|
|
163
|
+
readonly 'aria-grabbed'?: (boolean | "true" | "false") | undefined;
|
|
164
|
+
readonly 'aria-haspopup'?: "grid" | "tree" | "dialog" | "menu" | (boolean | "true" | "false") | "listbox" | undefined;
|
|
165
|
+
readonly 'aria-invalid'?: (boolean | "true" | "false") | "grammar" | "spelling" | undefined;
|
|
166
|
+
readonly 'aria-keyshortcuts'?: string | undefined | undefined;
|
|
167
|
+
readonly 'aria-labelledby'?: string | undefined | undefined;
|
|
168
|
+
readonly 'aria-level'?: (string | number) | undefined;
|
|
169
|
+
readonly 'aria-live'?: "off" | "assertive" | "polite" | undefined | undefined;
|
|
170
|
+
readonly 'aria-modal'?: (boolean | "true" | "false") | undefined;
|
|
171
|
+
readonly 'aria-multiline'?: (boolean | "true" | "false") | undefined;
|
|
172
|
+
readonly 'aria-multiselectable'?: (boolean | "true" | "false") | undefined;
|
|
173
|
+
readonly 'aria-orientation'?: "horizontal" | "vertical" | undefined | undefined;
|
|
174
|
+
readonly 'aria-owns'?: string | undefined | undefined;
|
|
175
|
+
readonly 'aria-placeholder'?: string | undefined | undefined;
|
|
176
|
+
readonly 'aria-posinset'?: (string | number) | undefined;
|
|
177
|
+
readonly 'aria-pressed'?: (boolean | "true" | "false") | "mixed" | undefined;
|
|
178
|
+
readonly 'aria-readonly'?: (boolean | "true" | "false") | undefined;
|
|
179
|
+
readonly 'aria-relevant'?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined | undefined;
|
|
180
|
+
readonly 'aria-required'?: (boolean | "true" | "false") | undefined;
|
|
181
|
+
readonly 'aria-roledescription'?: string | undefined | undefined;
|
|
182
|
+
readonly 'aria-rowcount'?: (string | number) | undefined;
|
|
183
|
+
readonly 'aria-rowindex'?: (string | number) | undefined;
|
|
184
|
+
readonly 'aria-rowspan'?: (string | number) | undefined;
|
|
185
|
+
readonly 'aria-selected'?: (boolean | "true" | "false") | undefined;
|
|
186
|
+
readonly 'aria-setsize'?: (string | number) | undefined;
|
|
187
|
+
readonly 'aria-sort'?: "none" | "ascending" | "descending" | "other" | undefined | undefined;
|
|
188
|
+
readonly 'aria-valuemax'?: (string | number) | undefined;
|
|
189
|
+
readonly 'aria-valuemin'?: (string | number) | undefined;
|
|
190
|
+
readonly 'aria-valuenow'?: (string | number) | undefined;
|
|
191
|
+
readonly 'aria-valuetext'?: string | undefined | undefined;
|
|
192
|
+
readonly accesskey?: string | undefined | undefined;
|
|
193
|
+
readonly contenteditable?: (boolean | "true" | "false") | "inherit" | "plaintext-only" | undefined;
|
|
194
|
+
readonly draggable?: (boolean | "true" | "false") | undefined;
|
|
195
|
+
readonly enterkeyhint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
|
|
196
|
+
readonly enterKeyHint?: "search" | "done" | "previous" | "next" | "enter" | "go" | "send" | undefined;
|
|
197
|
+
readonly inert?: (boolean | "true" | "false") | undefined;
|
|
198
|
+
readonly spellcheck?: (boolean | "true" | "false") | undefined;
|
|
199
|
+
readonly translate?: "yes" | "no" | undefined | undefined;
|
|
200
|
+
readonly radiogroup?: string | undefined | undefined;
|
|
201
|
+
readonly about?: string | undefined | undefined;
|
|
202
|
+
readonly datatype?: string | undefined | undefined;
|
|
203
|
+
readonly inlist?: any;
|
|
204
|
+
readonly property?: string | undefined | undefined;
|
|
205
|
+
readonly resource?: string | undefined | undefined;
|
|
206
|
+
readonly typeof?: string | undefined | undefined;
|
|
207
|
+
readonly vocab?: string | undefined | undefined;
|
|
208
|
+
readonly autocapitalize?: string | undefined | undefined;
|
|
209
|
+
readonly autocorrect?: string | undefined | undefined;
|
|
210
|
+
readonly autosave?: string | undefined | undefined;
|
|
211
|
+
readonly itemprop?: string | undefined | undefined;
|
|
212
|
+
readonly itemscope?: (boolean | "true" | "false") | undefined;
|
|
213
|
+
readonly itemtype?: string | undefined | undefined;
|
|
214
|
+
readonly itemid?: string | undefined | undefined;
|
|
215
|
+
readonly itemref?: string | undefined | undefined;
|
|
216
|
+
readonly security?: string | undefined | undefined;
|
|
217
|
+
readonly unselectable?: "on" | "off" | undefined | undefined;
|
|
218
|
+
readonly inputmode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined | undefined;
|
|
219
|
+
readonly is?: string | undefined | undefined;
|
|
220
|
+
readonly exportparts?: string | undefined;
|
|
221
|
+
readonly part?: string | undefined;
|
|
222
|
+
readonly popover?: (import("../../index.ts").PopoverMode | "" | boolean) | undefined;
|
|
223
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "inlist" | undefined>>>> & (typeof globalThis extends {
|
|
224
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
225
|
+
} ? P : {});
|
|
226
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
227
|
+
focus: () => void;
|
|
228
|
+
refresh: () => void;
|
|
229
|
+
}>) => void;
|
|
230
|
+
attrs: any;
|
|
231
|
+
slots: {
|
|
232
|
+
empty?: (props: {
|
|
233
|
+
query: string;
|
|
234
|
+
}) => unknown;
|
|
235
|
+
'group-label'?: (props: CommandGroupLabelSlotProps<T>) => unknown;
|
|
236
|
+
item?: (props: {
|
|
237
|
+
item: CommandItem<T>;
|
|
238
|
+
active: boolean;
|
|
239
|
+
}) => unknown;
|
|
240
|
+
'after-results'?: (props: {
|
|
241
|
+
query: string;
|
|
242
|
+
count: number;
|
|
243
|
+
}) => unknown;
|
|
244
|
+
};
|
|
245
|
+
emit: (((evt: "close") => void) & ((evt: "select", item: CommandItem<T>) => void)) & ((event: "update:query", value: string) => void);
|
|
246
|
+
}>) => import("vue").VNode & {
|
|
247
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
248
|
+
};
|
|
249
|
+
declare const _default: typeof __VLS_export;
|
|
250
|
+
export default _default;
|
|
251
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
252
|
+
[K in keyof T]: T[K];
|
|
253
|
+
} : {
|
|
254
|
+
[K in keyof T as K]: T[K];
|
|
255
|
+
}) & {};
|