@xleddyl/443-components-vue 0.16.88 → 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 +20 -19
- package/README.md +33 -4
- 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 +87 -17
- package/dist/components/data/Tree.vue.d.ts +19 -3
- package/dist/components/data/types.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/locale/de.mjs +2 -1
- package/dist/locale/en.mjs +2 -1
- package/dist/locale/it.mjs +2 -1
- package/dist/locale/types.d.ts +1 -0
- package/dist/styles/data/tree.css +23 -4
- package/dist/styles/forced-colors.css +6 -1
- package/dist/styles/overlays/command.css +22 -0
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<dialog
|
|
19
19
|
ref="dialogRef"
|
|
20
20
|
class="k-modal k-command"
|
|
21
|
-
:aria-
|
|
21
|
+
:aria-label="labelText"
|
|
22
22
|
closedby="closerequest"
|
|
23
23
|
@cancel="onCancel"
|
|
24
24
|
@close="onClose"
|
|
@@ -26,152 +26,64 @@
|
|
|
26
26
|
@click="onClick"
|
|
27
27
|
>
|
|
28
28
|
<div v-if="present" ref="panelRef" class="k-modal-panel k-command-panel" tabindex="-1">
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
group.label || $slots['group-label'] ? `${listId}-group-${groupIndex}` : void 0
|
|
70
|
-
"
|
|
71
|
-
class="k-command-group"
|
|
72
|
-
>
|
|
73
|
-
<div
|
|
74
|
-
v-if="group.label || $slots['group-label']"
|
|
75
|
-
:id="`${listId}-group-${groupIndex}`"
|
|
76
|
-
class="k-command-group-label"
|
|
77
|
-
>
|
|
78
|
-
<slot
|
|
79
|
-
name="group-label"
|
|
80
|
-
:group="group.source"
|
|
81
|
-
:label="group.label"
|
|
82
|
-
:description="group.description"
|
|
83
|
-
:recent="group.recent"
|
|
84
|
-
>
|
|
85
|
-
<span class="k-command-group-title">{{ group.label }}</span>
|
|
86
|
-
<span v-if="group.description" class="k-command-group-description">
|
|
87
|
-
{{ group.description }}
|
|
88
|
-
</span>
|
|
89
|
-
</slot>
|
|
90
|
-
</div>
|
|
91
|
-
<div
|
|
92
|
-
v-for="entry in group.items"
|
|
93
|
-
:id="optionId(entry.index)"
|
|
94
|
-
:key="entry.key"
|
|
95
|
-
role="option"
|
|
96
|
-
class="k-command-option"
|
|
97
|
-
:class="{ 'is-active': entry.index === active }"
|
|
98
|
-
:aria-selected="entry.index === active ? 'true' : 'false'"
|
|
99
|
-
:aria-disabled="entry.item.disabled ? 'true' : void 0"
|
|
100
|
-
@pointermove="active = entry.index"
|
|
101
|
-
@click="select(entry.item)"
|
|
102
|
-
>
|
|
103
|
-
<slot name="item" :item="entry.item" :active="entry.index === active">
|
|
104
|
-
<Icon
|
|
105
|
-
:name="
|
|
106
|
-
entry.item.icon ?? group.icon ?? (group.recent ? 'arrow-path' : 'arrow-right')
|
|
107
|
-
"
|
|
108
|
-
class="k-command-option-icon"
|
|
109
|
-
/>
|
|
110
|
-
<span class="k-command-option-text">
|
|
111
|
-
<span class="k-command-option-label">{{ entry.item.label }}</span>
|
|
112
|
-
<span v-if="entry.item.description" class="k-command-option-description">
|
|
113
|
-
{{ entry.item.description }}
|
|
114
|
-
</span>
|
|
115
|
-
</span>
|
|
116
|
-
<Badge
|
|
117
|
-
v-if="entry.item.badge"
|
|
118
|
-
v-bind="badgeProps(entry.item.badge)"
|
|
119
|
-
size="sm"
|
|
120
|
-
class="k-command-option-badge"
|
|
121
|
-
/>
|
|
122
|
-
<span
|
|
123
|
-
v-if="entry.item.shortcut"
|
|
124
|
-
class="k-command-option-shortcut"
|
|
125
|
-
aria-hidden="true"
|
|
126
|
-
>
|
|
127
|
-
<Kbd
|
|
128
|
-
v-for="(key, keyIndex) in formatHotkey(entry.item.shortcut, apple)"
|
|
129
|
-
:key="keyIndex"
|
|
130
|
-
size="sm"
|
|
131
|
-
>
|
|
132
|
-
{{ key }}
|
|
133
|
-
</Kbd>
|
|
134
|
-
</span>
|
|
135
|
-
</slot>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
<div v-if="flat.length && (notice || $slots['after-results'])" class="k-command-notice">
|
|
140
|
-
<slot name="after-results" :query="query" :count="flat.length">{{ notice }}</slot>
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
143
|
-
<div class="k-command-footer" aria-hidden="true">
|
|
144
|
-
<span><Kbd size="sm">↑</Kbd><Kbd size="sm">↓</Kbd> {{ moveText }}</span>
|
|
145
|
-
<span><Kbd size="sm">↵</Kbd> {{ selectText }}</span>
|
|
146
|
-
<span><Kbd size="sm">Esc</Kbd> {{ closeText }}</span>
|
|
147
|
-
</div>
|
|
148
|
-
<LiveRegion :message="status" />
|
|
29
|
+
<CommandList
|
|
30
|
+
ref="listRef"
|
|
31
|
+
v-model:query="query"
|
|
32
|
+
:groups="groups"
|
|
33
|
+
:search="search"
|
|
34
|
+
:pinned="pinned"
|
|
35
|
+
:debounce="debounce"
|
|
36
|
+
:min-query-length="minQueryLength"
|
|
37
|
+
:filter="filter"
|
|
38
|
+
:loading="loading"
|
|
39
|
+
:placeholder="placeholder"
|
|
40
|
+
:label="label"
|
|
41
|
+
:recent-key="recentKey"
|
|
42
|
+
:recent-limit="recentLimit"
|
|
43
|
+
:recent-label="recentLabel"
|
|
44
|
+
:empty-text="emptyText"
|
|
45
|
+
:min-query-text="minQueryText"
|
|
46
|
+
:error-text="errorText"
|
|
47
|
+
:loading-text="loadingText"
|
|
48
|
+
:results-text="resultsText"
|
|
49
|
+
footer
|
|
50
|
+
:footer-move="footerMove"
|
|
51
|
+
:footer-select="footerSelect"
|
|
52
|
+
:footer-close="footerClose"
|
|
53
|
+
:notice="notice"
|
|
54
|
+
@select="select"
|
|
55
|
+
>
|
|
56
|
+
<template v-if="$slots.empty" #empty="scope">
|
|
57
|
+
<slot name="empty" v-bind="scope" />
|
|
58
|
+
</template>
|
|
59
|
+
<template v-if="$slots['group-label']" #group-label="scope">
|
|
60
|
+
<slot name="group-label" v-bind="scope" />
|
|
61
|
+
</template>
|
|
62
|
+
<template v-if="$slots.item" #item="scope">
|
|
63
|
+
<slot name="item" v-bind="scope" />
|
|
64
|
+
</template>
|
|
65
|
+
<template v-if="$slots['after-results']" #after-results="scope">
|
|
66
|
+
<slot name="after-results" v-bind="scope" />
|
|
67
|
+
</template>
|
|
68
|
+
</CommandList>
|
|
149
69
|
</div>
|
|
150
70
|
</dialog>
|
|
151
71
|
</template>
|
|
152
72
|
|
|
153
73
|
<script setup>
|
|
154
|
-
import { computed,
|
|
74
|
+
import { computed, useTemplateRef } from "vue";
|
|
155
75
|
import { ariaKeyShortcuts, formatHotkey, useHotkey } from "../../composables/useHotkey";
|
|
156
76
|
import { useLocale } from "../../composables/useLocale";
|
|
157
77
|
import { useModalDialog } from "../../internal/overlays/dialog";
|
|
158
|
-
import { nextEnabledIndex } from "../../internal/core/roving";
|
|
159
|
-
import { useAsyncSearch } from "../../internal/core/search";
|
|
160
|
-
import { matchesSearch } from "../../internal/core/text";
|
|
161
|
-
import { readStorageJson, writeStorageJson } from "../../internal/core/storage";
|
|
162
|
-
import { useRouterLike } from "../../internal/layout/route";
|
|
163
78
|
import { ButtonElement } from "../../internal/core/ButtonElement";
|
|
164
|
-
import LiveRegion from "../../internal/core/LiveRegion.vue";
|
|
165
79
|
import Icon from "../core/Icon.vue";
|
|
166
|
-
import Badge from "../data/Badge.vue";
|
|
167
80
|
import Kbd from "../core/Kbd.vue";
|
|
168
|
-
import
|
|
169
|
-
import { provideFieldBoundary } from "../../composables/useFieldBoundary";
|
|
81
|
+
import CommandList from "./CommandList.vue";
|
|
170
82
|
defineOptions({ inheritAttrs: false });
|
|
171
|
-
provideFieldBoundary();
|
|
172
83
|
const props = defineProps({
|
|
173
84
|
groups: { type: Array, required: false, default: () => [] },
|
|
174
85
|
search: { type: Function, required: false },
|
|
86
|
+
pinned: { type: [Array, Function], required: false },
|
|
175
87
|
debounce: { type: Number, required: false, default: 150 },
|
|
176
88
|
minQueryLength: { type: Number, required: false, default: 0 },
|
|
177
89
|
filter: { type: Boolean, required: false, default: true },
|
|
@@ -195,198 +107,21 @@ const props = defineProps({
|
|
|
195
107
|
notice: { type: String, required: false }
|
|
196
108
|
});
|
|
197
109
|
const { t } = useLocale();
|
|
198
|
-
const placeholderText = computed(() => props.placeholder ?? t("commandPalette.placeholder"));
|
|
199
110
|
const labelText = computed(() => props.label ?? t("commandPalette.label"));
|
|
200
111
|
const triggerText = computed(() => props.triggerLabel ?? t("common.search"));
|
|
201
|
-
const recentText = computed(() => props.recentLabel ?? t("commandPalette.recent"));
|
|
202
|
-
const emptyLabel = computed(() => {
|
|
203
|
-
const text = props.emptyText;
|
|
204
|
-
if (typeof text === "function") return text(term.value);
|
|
205
|
-
return text ?? t("common.noResults");
|
|
206
|
-
});
|
|
207
|
-
const minQueryLabel = computed(() => props.minQueryText ?? t("commandPalette.minQuery"));
|
|
208
|
-
const errorLabel = computed(() => props.errorText ?? t("commandPalette.error"));
|
|
209
|
-
const loadingLabel = computed(() => props.loadingText ?? t("common.loading"));
|
|
210
|
-
const moveText = computed(() => props.footerMove ?? t("commandPalette.move"));
|
|
211
|
-
const selectText = computed(() => props.footerSelect ?? t("commandPalette.select"));
|
|
212
|
-
const closeText = computed(() => props.footerClose ?? t("commandPalette.close"));
|
|
213
112
|
const emit = defineEmits(["select", "open", "close"]);
|
|
214
113
|
defineSlots();
|
|
215
114
|
const open = defineModel("open", { type: Boolean, ...{ default: false } });
|
|
216
115
|
const query = defineModel("query", { type: String, ...{ default: "" } });
|
|
217
|
-
const baseId = useId();
|
|
218
|
-
const labelId = `${baseId}-label`;
|
|
219
|
-
const inputId = `${baseId}-input`;
|
|
220
|
-
const listId = `${baseId}-list`;
|
|
221
116
|
const dialogRef = useTemplateRef("dialogRef");
|
|
222
117
|
const panelRef = useTemplateRef("panelRef");
|
|
223
|
-
const
|
|
224
|
-
const inputRef = useTemplateRef("inputRef");
|
|
225
|
-
const router = useRouterLike();
|
|
226
|
-
const active = ref(0);
|
|
227
|
-
const remote = shallowRef(null);
|
|
228
|
-
const recent = shallowRef([]);
|
|
118
|
+
const listRef = useTemplateRef("listRef");
|
|
229
119
|
const shortcutKeys = computed(
|
|
230
120
|
() => props.shortcut ? formatHotkey(props.shortcut, apple.value) : []
|
|
231
121
|
);
|
|
232
|
-
const term = computed(() => query.value.trim());
|
|
233
|
-
const busy = computed(() => props.loading || search.searching.value);
|
|
234
|
-
const belowMinimum = computed(
|
|
235
|
-
() => Boolean(props.search) && term.value.length > 0 && term.value.length < props.minQueryLength
|
|
236
|
-
);
|
|
237
|
-
const resultGroups = computed(() => {
|
|
238
|
-
if (props.search && term.value) return remote.value ?? [];
|
|
239
|
-
if (!props.filter || !term.value || props.search) return props.groups;
|
|
240
|
-
return props.groups.map((group) => ({
|
|
241
|
-
...group,
|
|
242
|
-
items: group.items.filter(
|
|
243
|
-
(item) => matchesSearch([item.label, item.description, ...item.keywords ?? []], term.value)
|
|
244
|
-
)
|
|
245
|
-
})).filter((group) => group.items.length);
|
|
246
|
-
});
|
|
247
|
-
const allItems = computed(() => props.groups.flatMap((group) => group.items));
|
|
248
|
-
const rendered = computed(() => {
|
|
249
|
-
const list = [];
|
|
250
|
-
let index = 0;
|
|
251
|
-
if (!term.value && props.recentKey && recent.value.length) {
|
|
252
|
-
list.push({
|
|
253
|
-
key: "recent",
|
|
254
|
-
label: recentText.value,
|
|
255
|
-
recent: true,
|
|
256
|
-
items: recent.value.map((snapshot) => {
|
|
257
|
-
const item = allItems.value.find((candidate) => candidate.id === snapshot.id) ?? snapshot;
|
|
258
|
-
return { key: `recent-${snapshot.id}`, index: index++, item };
|
|
259
|
-
})
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
for (const group of resultGroups.value) {
|
|
263
|
-
const items = group.more ? [
|
|
264
|
-
...group.items,
|
|
265
|
-
{
|
|
266
|
-
icon: "arrow-right",
|
|
267
|
-
...group.more,
|
|
268
|
-
id: group.more.id ?? `${group.id}:more`
|
|
269
|
-
}
|
|
270
|
-
] : group.items;
|
|
271
|
-
list.push({
|
|
272
|
-
key: `group-${group.id}`,
|
|
273
|
-
label: group.label,
|
|
274
|
-
description: group.description,
|
|
275
|
-
icon: group.icon,
|
|
276
|
-
source: group,
|
|
277
|
-
recent: false,
|
|
278
|
-
items: items.map((item) => ({
|
|
279
|
-
key: `${group.id}-${item.id}`,
|
|
280
|
-
index: index++,
|
|
281
|
-
item
|
|
282
|
-
}))
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
return list;
|
|
286
|
-
});
|
|
287
|
-
const flat = computed(() => rendered.value.flatMap((group) => group.items));
|
|
288
|
-
const activeId = computed(() => flat.value.length ? optionId(active.value) : void 0);
|
|
289
|
-
const hint = computed(() => {
|
|
290
|
-
if (belowMinimum.value) return minQueryLabel.value;
|
|
291
|
-
if (search.failed.value) return errorLabel.value;
|
|
292
|
-
if (!busy.value && !flat.value.length && (term.value || !props.search)) return emptyLabel.value;
|
|
293
|
-
return "";
|
|
294
|
-
});
|
|
295
|
-
const status = computed(() => {
|
|
296
|
-
if (hint.value) return hint.value;
|
|
297
|
-
if (busy.value) return loadingLabel.value;
|
|
298
|
-
const count = flat.value.length;
|
|
299
|
-
return props.resultsText ? props.resultsText(count) : t("commandPalette.results", { count });
|
|
300
|
-
});
|
|
301
|
-
function optionId(index) {
|
|
302
|
-
return `${listId}-option-${index}`;
|
|
303
|
-
}
|
|
304
|
-
const search = useAsyncSearch({
|
|
305
|
-
search: () => props.search,
|
|
306
|
-
onResults: (groups) => remote.value = groups,
|
|
307
|
-
onError: () => remote.value = []
|
|
308
|
-
});
|
|
309
|
-
function firstEnabled() {
|
|
310
|
-
return Math.max(0, nextEnabledIndex(flat.value.length, 0, 1, isDisabled));
|
|
311
|
-
}
|
|
312
|
-
watch(term, (value) => {
|
|
313
|
-
active.value = firstEnabled();
|
|
314
|
-
if (!props.search) return;
|
|
315
|
-
if (!value || value.length < props.minQueryLength) {
|
|
316
|
-
search.cancel();
|
|
317
|
-
remote.value = null;
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
search.schedule(value, props.debounce);
|
|
321
|
-
});
|
|
322
|
-
watch(flat, (items) => {
|
|
323
|
-
if (active.value >= items.length || isDisabled(active.value)) active.value = firstEnabled();
|
|
324
|
-
});
|
|
325
|
-
watch(active, (index) => {
|
|
326
|
-
nextTick(() => {
|
|
327
|
-
const option = document.getElementById(optionId(index));
|
|
328
|
-
if (option && bodyRef.value?.contains(option)) option.scrollIntoView({ block: "nearest" });
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
function badgeProps(badge) {
|
|
332
|
-
return typeof badge === "string" ? { label: badge } : badge;
|
|
333
|
-
}
|
|
334
|
-
function readRecent() {
|
|
335
|
-
if (!props.recentKey) return;
|
|
336
|
-
const stored = readStorageJson(props.recentKey);
|
|
337
|
-
recent.value = Array.isArray(stored) ? stored.slice(0, props.recentLimit) : [];
|
|
338
|
-
}
|
|
339
|
-
function saveRecent(item) {
|
|
340
|
-
if (!props.recentKey) return;
|
|
341
|
-
const snapshot = {
|
|
342
|
-
id: item.id,
|
|
343
|
-
label: item.label,
|
|
344
|
-
description: item.description,
|
|
345
|
-
icon: item.icon,
|
|
346
|
-
to: item.to,
|
|
347
|
-
href: item.href
|
|
348
|
-
};
|
|
349
|
-
recent.value = [snapshot, ...recent.value.filter((entry) => entry.id !== item.id)].slice(
|
|
350
|
-
0,
|
|
351
|
-
props.recentLimit
|
|
352
|
-
);
|
|
353
|
-
writeStorageJson(props.recentKey, recent.value);
|
|
354
|
-
}
|
|
355
|
-
function navigate(item) {
|
|
356
|
-
if (item.to !== void 0 && router) {
|
|
357
|
-
router.push(item.to);
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
const href = item.href ?? (typeof item.to === "string" ? item.to : void 0);
|
|
361
|
-
if (href) window.location.assign(href);
|
|
362
|
-
}
|
|
363
122
|
function select(item) {
|
|
364
|
-
if (!item || item.disabled) return;
|
|
365
|
-
saveRecent(item);
|
|
366
123
|
open.value = false;
|
|
367
124
|
emit("select", item);
|
|
368
|
-
item.onSelect?.(item);
|
|
369
|
-
if (!item.onSelect) navigate(item);
|
|
370
|
-
}
|
|
371
|
-
function isDisabled(index) {
|
|
372
|
-
return Boolean(flat.value[index]?.item.disabled);
|
|
373
|
-
}
|
|
374
|
-
function onKeydown(event) {
|
|
375
|
-
const count = flat.value.length;
|
|
376
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
377
|
-
event.preventDefault();
|
|
378
|
-
if (!count) return;
|
|
379
|
-
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
380
|
-
const next = nextEnabledIndex(count, active.value + step, step, isDisabled);
|
|
381
|
-
if (next !== -1) active.value = next;
|
|
382
|
-
} else if ((event.key === "Home" || event.key === "End") && event.ctrlKey && count) {
|
|
383
|
-
event.preventDefault();
|
|
384
|
-
const next = event.key === "Home" ? nextEnabledIndex(count, 0, 1, isDisabled) : nextEnabledIndex(count, count - 1, -1, isDisabled);
|
|
385
|
-
if (next !== -1) active.value = next;
|
|
386
|
-
} else if (event.key === "Enter" && !event.isComposing) {
|
|
387
|
-
event.preventDefault();
|
|
388
|
-
select(flat.value[active.value]?.item);
|
|
389
|
-
}
|
|
390
125
|
}
|
|
391
126
|
const { present, onCancel, onClose, onPointerDown, onClick } = useModalDialog({
|
|
392
127
|
dialog: dialogRef,
|
|
@@ -394,9 +129,8 @@ const { present, onCancel, onClose, onPointerDown, onClick } = useModalDialog({
|
|
|
394
129
|
open,
|
|
395
130
|
dismissible: () => true,
|
|
396
131
|
onOpen: () => {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
inputRef.value?.select();
|
|
132
|
+
listRef.value?.refresh();
|
|
133
|
+
listRef.value?.focus();
|
|
400
134
|
emit("open");
|
|
401
135
|
},
|
|
402
136
|
onClose: () => emit("close")
|
|
@@ -404,11 +138,10 @@ const { present, onCancel, onClose, onPointerDown, onClick } = useModalDialog({
|
|
|
404
138
|
const { apple } = useHotkey(
|
|
405
139
|
() => props.shortcut ? [props.shortcut] : [],
|
|
406
140
|
() => {
|
|
407
|
-
if (open.value)
|
|
141
|
+
if (open.value) listRef.value?.focus();
|
|
408
142
|
else open.value = true;
|
|
409
143
|
},
|
|
410
144
|
{ enabled: () => Boolean(props.shortcut) }
|
|
411
145
|
);
|
|
412
|
-
onMounted(readRecent);
|
|
413
146
|
defineExpose({ show: () => open.value = true, hide: () => open.value = false });
|
|
414
147
|
</script>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { CommandEmptyText, CommandGroup, CommandGroupLabelSlotProps, CommandItem, CommandSearch } from './types';
|
|
1
|
+
import type { CommandEmptyText, CommandGroup, CommandGroupLabelSlotProps, CommandItem, CommandPinned, CommandSearch } from './types';
|
|
2
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
3
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<({
|
|
4
4
|
groups?: CommandGroup<T>[];
|
|
5
5
|
search?: CommandSearch<T>;
|
|
6
|
+
pinned?: CommandPinned<T>;
|
|
6
7
|
debounce?: number;
|
|
7
8
|
minQueryLength?: number;
|
|
8
9
|
filter?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<span ref="triggerRef" class="k-overlay-trigger">
|
|
2
|
+
<span v-if="$slots.default" ref="triggerRef" class="k-overlay-trigger">
|
|
3
3
|
<slot :open="layer.isOpen.value" :close="layer.hide" />
|
|
4
4
|
</span>
|
|
5
5
|
<div
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script setup>
|
|
24
|
-
import { computed, ref, useAttrs, useId, useTemplateRef, watch } from "vue";
|
|
24
|
+
import { computed, onMounted, ref, useAttrs, useId, useSlots, useTemplateRef, watch } from "vue";
|
|
25
25
|
import FieldBoundary from "../core/FieldBoundary.vue";
|
|
26
26
|
import { focusFirst, hasFocusWithin } from "../../internal/core/focus";
|
|
27
27
|
import { ARROW_OFFSET, syncOpenModel, useFloatingLayer } from "../../internal/floating/layer";
|
|
28
28
|
import { setAttributes, useInvoker, useSlotTrigger } from "../../internal/floating/trigger";
|
|
29
|
-
import { hasNameAttrs } from "../../internal/forms/name";
|
|
29
|
+
import { hasNameAttrs, warnUnnamed } from "../../internal/forms/name";
|
|
30
30
|
defineOptions({ inheritAttrs: false });
|
|
31
31
|
const props = defineProps({
|
|
32
32
|
placement: { type: null, required: false, default: "bottom-start" },
|
|
@@ -35,7 +35,8 @@ const props = defineProps({
|
|
|
35
35
|
role: { type: String, required: false, default: "dialog" },
|
|
36
36
|
label: { type: String, required: false },
|
|
37
37
|
initialFocus: { type: Boolean, required: false, default: true },
|
|
38
|
-
haspopup: { type: String, required: false, default: "dialog" }
|
|
38
|
+
haspopup: { type: String, required: false, default: "dialog" },
|
|
39
|
+
anchor: { type: null, required: false, default: null }
|
|
39
40
|
});
|
|
40
41
|
const open = defineModel("open", { type: Boolean, ...{ default: false } });
|
|
41
42
|
const contentId = `${useId()}-popover`;
|
|
@@ -43,6 +44,7 @@ const triggerRef = useTemplateRef("triggerRef");
|
|
|
43
44
|
const floatingRef = useTemplateRef("floatingRef");
|
|
44
45
|
const trigger = useSlotTrigger(triggerRef);
|
|
45
46
|
const attrs = useAttrs();
|
|
47
|
+
const slots = useSlots();
|
|
46
48
|
const triggerId = ref();
|
|
47
49
|
const fallbackLabelledBy = computed(() => {
|
|
48
50
|
if (props.label || hasNameAttrs(attrs)) return void 0;
|
|
@@ -50,7 +52,8 @@ const fallbackLabelledBy = computed(() => {
|
|
|
50
52
|
});
|
|
51
53
|
const layer = useFloatingLayer({
|
|
52
54
|
floating: floatingRef,
|
|
53
|
-
anchor: () => trigger.value,
|
|
55
|
+
anchor: () => props.anchor ?? trigger.value,
|
|
56
|
+
focusTarget: () => props.anchor,
|
|
54
57
|
placement: () => props.placement,
|
|
55
58
|
offset: () => props.offset + (props.arrow ? ARROW_OFFSET : 0),
|
|
56
59
|
mode: "auto",
|
|
@@ -90,6 +93,22 @@ watch(
|
|
|
90
93
|
},
|
|
91
94
|
{ flush: "post" }
|
|
92
95
|
);
|
|
96
|
+
watch(
|
|
97
|
+
() => props.anchor,
|
|
98
|
+
(anchor) => {
|
|
99
|
+
if (!anchor) return;
|
|
100
|
+
if (layer.isOpen.value) layer.reposition();
|
|
101
|
+
else if (open.value) layer.show(trigger.value);
|
|
102
|
+
},
|
|
103
|
+
{ flush: "post" }
|
|
104
|
+
);
|
|
105
|
+
onMounted(() => {
|
|
106
|
+
if (open.value && props.anchor && !layer.isOpen.value) layer.show(trigger.value);
|
|
107
|
+
});
|
|
108
|
+
warnUnnamed(
|
|
109
|
+
"Popover",
|
|
110
|
+
() => props.role !== "dialog" || Boolean(props.label || hasNameAttrs(attrs) || slots.default)
|
|
111
|
+
);
|
|
93
112
|
defineExpose({
|
|
94
113
|
show: () => layer.show(trigger.value),
|
|
95
114
|
hide: layer.hide,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OverlayPlacement } from './types';
|
|
1
|
+
import type { OverlayAnchorTarget, OverlayPlacement } from './types';
|
|
2
2
|
declare var __VLS_1: {
|
|
3
3
|
open: boolean;
|
|
4
4
|
close: () => void;
|
|
@@ -18,6 +18,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
18
18
|
label?: string;
|
|
19
19
|
initialFocus?: boolean;
|
|
20
20
|
haspopup?: string;
|
|
21
|
+
anchor?: OverlayAnchorTarget | null;
|
|
21
22
|
open?: boolean;
|
|
22
23
|
key?: PropertyKey | undefined;
|
|
23
24
|
prefix?: string | undefined | undefined;
|
|
@@ -224,6 +225,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
224
225
|
label?: string;
|
|
225
226
|
initialFocus?: boolean;
|
|
226
227
|
haspopup?: string;
|
|
228
|
+
anchor?: OverlayAnchorTarget | null;
|
|
227
229
|
open?: boolean;
|
|
228
230
|
key?: PropertyKey | undefined;
|
|
229
231
|
prefix?: string | undefined | undefined;
|
|
@@ -419,6 +421,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
419
421
|
}> & Readonly<{
|
|
420
422
|
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
421
423
|
}>, {
|
|
424
|
+
anchor: OverlayAnchorTarget | null;
|
|
422
425
|
role: string;
|
|
423
426
|
offset: number;
|
|
424
427
|
placement: OverlayPlacement;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as CommandButton } from './CommandButton.vue';
|
|
2
|
+
export { default as CommandList } from './CommandList.vue';
|
|
2
3
|
export { default as CommandPalette } from './CommandPalette.vue';
|
|
3
4
|
export { default as ConfirmDialog } from './ConfirmDialog.vue';
|
|
4
5
|
export { default as ConfirmHost } from './ConfirmHost.vue';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as CommandButton } from "./CommandButton.vue";
|
|
2
|
+
export { default as CommandList } from "./CommandList.vue";
|
|
2
3
|
export { default as CommandPalette } from "./CommandPalette.vue";
|
|
3
4
|
export { default as ConfirmDialog } from "./ConfirmDialog.vue";
|
|
4
5
|
export { default as ConfirmHost } from "./ConfirmHost.vue";
|
|
@@ -100,4 +100,5 @@ export interface CommandGroupLabelSlotProps<T = unknown> {
|
|
|
100
100
|
recent: boolean;
|
|
101
101
|
}
|
|
102
102
|
export type CommandSearch<T = unknown> = (query: string, signal: AbortSignal) => CommandGroup<T>[] | Promise<CommandGroup<T>[]>;
|
|
103
|
+
export type CommandPinned<T = unknown> = CommandItem<T>[] | ((query: string) => CommandItem<T>[]);
|
|
103
104
|
export type CommandEmptyText = string | ((query: string) => string);
|
|
@@ -17,7 +17,7 @@ export function useFieldControl(options = {}) {
|
|
|
17
17
|
() => Boolean(toValue(options.required) || field.value?.required.value)
|
|
18
18
|
);
|
|
19
19
|
const disabled = computed(
|
|
20
|
-
() =>
|
|
20
|
+
() => toValue(options.disabled) ?? Boolean(parent?.disabled.value || formDisabled?.value)
|
|
21
21
|
);
|
|
22
22
|
const describedBy = computed(
|
|
23
23
|
() => joinIds(toValue(options.describedBy), field.value?.describedBy.value)
|
|
@@ -154,7 +154,7 @@ const props = defineProps({
|
|
|
154
154
|
format: { type: String, required: false, default: "html" },
|
|
155
155
|
placeholder: { type: String, required: false },
|
|
156
156
|
readonly: { type: Boolean, required: false },
|
|
157
|
-
disabled: { type: Boolean, required: false },
|
|
157
|
+
disabled: { type: Boolean, required: false, default: void 0 },
|
|
158
158
|
invalid: { type: Boolean, required: false, default: void 0 },
|
|
159
159
|
required: { type: Boolean, required: false },
|
|
160
160
|
maxLength: { type: Number, required: false },
|
|
@@ -432,6 +432,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
432
432
|
"onUpdate:modelValue"?: ((value: EditorValue) => any) | undefined;
|
|
433
433
|
}>, {
|
|
434
434
|
invalid: boolean;
|
|
435
|
+
disabled: boolean;
|
|
435
436
|
format: EditorFormat;
|
|
436
437
|
minHeight: string;
|
|
437
438
|
headings: EditorHeadingLevel[];
|
|
@@ -71,7 +71,7 @@ const props = defineProps({
|
|
|
71
71
|
tokens: { type: Array, required: true },
|
|
72
72
|
placeholder: { type: String, required: false },
|
|
73
73
|
readonly: { type: Boolean, required: false },
|
|
74
|
-
disabled: { type: Boolean, required: false },
|
|
74
|
+
disabled: { type: Boolean, required: false, default: void 0 },
|
|
75
75
|
invalid: { type: Boolean, required: false, default: void 0 },
|
|
76
76
|
required: { type: Boolean, required: false },
|
|
77
77
|
maxLength: { type: Number, required: false },
|
|
@@ -421,6 +421,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
|
|
|
421
421
|
}>, {
|
|
422
422
|
invalid: boolean;
|
|
423
423
|
preview: string | null;
|
|
424
|
+
disabled: boolean;
|
|
424
425
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
425
426
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
426
427
|
declare const _default: typeof __VLS_export;
|
|
@@ -10,6 +10,7 @@ export interface FloatingLayerOptions {
|
|
|
10
10
|
manualPositioning?: () => boolean;
|
|
11
11
|
matchWidth?: boolean;
|
|
12
12
|
returnFocus?: () => boolean;
|
|
13
|
+
focusTarget?: () => AnchorTarget | null | undefined;
|
|
13
14
|
onBeforeOpen?: () => void;
|
|
14
15
|
onOpen?: () => void;
|
|
15
16
|
onClose?: () => void;
|