@byyuurin/ui 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -2
- package/dist/runtime/components/Accordion.vue +2 -2
- package/dist/runtime/components/Accordion.vue.d.ts +11 -7
- package/dist/runtime/components/Alert.vue +2 -1
- package/dist/runtime/components/Alert.vue.d.ts +4 -4
- package/dist/runtime/components/App.vue +2 -1
- package/dist/runtime/components/App.vue.d.ts +11 -7
- package/dist/runtime/components/Avatar.vue +2 -1
- package/dist/runtime/components/Avatar.vue.d.ts +4 -3
- package/dist/runtime/components/AvatarGroup.vue +2 -1
- package/dist/runtime/components/AvatarGroup.vue.d.ts +1 -1
- package/dist/runtime/components/Badge.vue +4 -3
- package/dist/runtime/components/Badge.vue.d.ts +2 -2
- package/dist/runtime/components/Breadcrumb.vue +2 -2
- package/dist/runtime/components/Breadcrumb.vue.d.ts +10 -6
- package/dist/runtime/components/Button.vue +8 -8
- package/dist/runtime/components/Button.vue.d.ts +1 -1
- package/dist/runtime/components/Calendar.vue +2 -1
- package/dist/runtime/components/Calendar.vue.d.ts +16 -12
- package/dist/runtime/components/Card.vue +2 -1
- package/dist/runtime/components/Card.vue.d.ts +1 -1
- package/dist/runtime/components/Carousel.vue +2 -1
- package/dist/runtime/components/Carousel.vue.d.ts +14 -10
- package/dist/runtime/components/Checkbox.vue +4 -2
- package/dist/runtime/components/Checkbox.vue.d.ts +4 -3
- package/dist/runtime/components/CheckboxGroup.vue +4 -3
- package/dist/runtime/components/CheckboxGroup.vue.d.ts +11 -7
- package/dist/runtime/components/Chip.vue +5 -1
- package/dist/runtime/components/Chip.vue.d.ts +2 -2
- package/dist/runtime/components/Collapsible.vue +2 -1
- package/dist/runtime/components/Collapsible.vue.d.ts +2 -2
- package/dist/runtime/components/Drawer.vue +2 -1
- package/dist/runtime/components/Drawer.vue.d.ts +6 -6
- package/dist/runtime/components/DropdownMenu.vue +3 -3
- package/dist/runtime/components/DropdownMenu.vue.d.ts +17 -9
- package/dist/runtime/components/DropdownMenuContent.vue +11 -12
- package/dist/runtime/components/DropdownMenuContent.vue.d.ts +11 -7
- package/dist/runtime/components/FieldGroup.vue +2 -1
- package/dist/runtime/components/FieldGroup.vue.d.ts +2 -2
- package/dist/runtime/components/FileUpload.vue +267 -0
- package/dist/runtime/components/FileUpload.vue.d.ts +178 -0
- package/dist/runtime/components/Form.vue +2 -1
- package/dist/runtime/components/Form.vue.d.ts +13 -8
- package/dist/runtime/components/FormField.vue +6 -4
- package/dist/runtime/components/FormField.vue.d.ts +7 -2
- package/dist/runtime/components/Icon.vue.d.ts +1 -1
- package/dist/runtime/components/Input.vue +4 -4
- package/dist/runtime/components/Input.vue.d.ts +16 -12
- package/dist/runtime/components/InputNumber.vue +3 -2
- package/dist/runtime/components/InputNumber.vue.d.ts +128 -124
- package/dist/runtime/components/InputTags.vue +2 -1
- package/dist/runtime/components/InputTags.vue.d.ts +16 -11
- package/dist/runtime/components/Kbd.vue +2 -1
- package/dist/runtime/components/Kbd.vue.d.ts +2 -2
- package/dist/runtime/components/Link.vue +5 -3
- package/dist/runtime/components/Link.vue.d.ts +16 -6
- package/dist/runtime/components/LinkBase.vue.d.ts +2 -2
- package/dist/runtime/components/Marquee.vue +2 -1
- package/dist/runtime/components/Marquee.vue.d.ts +3 -3
- package/dist/runtime/components/Modal.vue +3 -2
- package/dist/runtime/components/Modal.vue.d.ts +6 -6
- package/dist/runtime/components/NavigationMenu.vue +2 -2
- package/dist/runtime/components/NavigationMenu.vue.d.ts +11 -7
- package/dist/runtime/components/Pagination.vue +2 -1
- package/dist/runtime/components/Pagination.vue.d.ts +4 -4
- package/dist/runtime/components/PinInput.vue +4 -4
- package/dist/runtime/components/PinInput.vue.d.ts +14 -10
- package/dist/runtime/components/Popover.vue +1 -1
- package/dist/runtime/components/Popover.vue.d.ts +11 -7
- package/dist/runtime/components/Progress.vue +2 -1
- package/dist/runtime/components/Progress.vue.d.ts +2 -2
- package/dist/runtime/components/RadioGroup.vue +3 -3
- package/dist/runtime/components/RadioGroup.vue.d.ts +11 -7
- package/dist/runtime/components/ScrollArea.vue +2 -1
- package/dist/runtime/components/ScrollArea.vue.d.ts +2 -2
- package/dist/runtime/components/Select.vue +282 -131
- package/dist/runtime/components/Select.vue.d.ts +103 -123
- package/dist/runtime/components/Separator.vue +2 -1
- package/dist/runtime/components/Separator.vue.d.ts +2 -2
- package/dist/runtime/components/Skeleton.vue +2 -1
- package/dist/runtime/components/Skeleton.vue.d.ts +2 -2
- package/dist/runtime/components/Slider.vue +2 -1
- package/dist/runtime/components/Slider.vue.d.ts +11 -7
- package/dist/runtime/components/Stepper.vue +117 -0
- package/dist/runtime/components/Stepper.vue.d.ts +83 -0
- package/dist/runtime/components/Switch.vue +3 -4
- package/dist/runtime/components/Switch.vue.d.ts +4 -3
- package/dist/runtime/components/Table.vue +2 -1
- package/dist/runtime/components/Table.vue.d.ts +13 -8
- package/dist/runtime/components/Tabs.vue +2 -2
- package/dist/runtime/components/Tabs.vue.d.ts +12 -8
- package/dist/runtime/components/Textarea.vue +3 -3
- package/dist/runtime/components/Textarea.vue.d.ts +16 -11
- package/dist/runtime/components/Timeline.vue +2 -1
- package/dist/runtime/components/Timeline.vue.d.ts +11 -7
- package/dist/runtime/components/Toast.vue +2 -1
- package/dist/runtime/components/Toast.vue.d.ts +5 -5
- package/dist/runtime/components/ToastProvider.vue +2 -2
- package/dist/runtime/components/ToastProvider.vue.d.ts +3 -3
- package/dist/runtime/components/Tooltip.vue +4 -4
- package/dist/runtime/components/Tooltip.vue.d.ts +2 -2
- package/dist/runtime/components/Tree.vue +241 -0
- package/dist/runtime/components/Tree.vue.d.ts +121 -0
- package/dist/runtime/composables/defineShortcuts.d.ts +1 -0
- package/dist/runtime/composables/defineShortcuts.js +44 -8
- package/dist/runtime/composables/useFileUpload.d.ts +19 -0
- package/dist/runtime/composables/useFileUpload.js +79 -0
- package/dist/runtime/composables/useLocale.d.ts +18 -0
- package/dist/runtime/locale/en.d.ts +9 -0
- package/dist/runtime/locale/en.js +9 -0
- package/dist/runtime/locale/zh_tw.d.ts +9 -0
- package/dist/runtime/locale/zh_tw.js +9 -0
- package/dist/runtime/types/html.d.ts +8 -0
- package/dist/runtime/types/html.js +0 -0
- package/dist/runtime/types/index.d.ts +3 -0
- package/dist/runtime/types/index.js +3 -0
- package/dist/runtime/types/input.d.ts +5 -5
- package/dist/runtime/types/locale.d.ts +9 -0
- package/dist/runtime/types/utils.d.ts +4 -4
- package/dist/runtime/utils/index.d.ts +3 -3
- package/dist/runtime/utils/link.d.ts +2 -1
- package/dist/runtime/utils/link.js +40 -29
- package/dist/runtime/vue/components/Icon.vue.d.ts +1 -1
- package/dist/runtime/vue/components/Link.vue +7 -12
- package/dist/runtime/vue/components/Link.vue.d.ts +11 -40
- package/dist/setup.d.mts +1 -1
- package/dist/shared/{ui.DpbffTXs.d.mts → ui.CGCKYv7g.d.mts} +6 -2
- package/dist/shared/{ui.CzIlLITK.mjs → ui.DYMXCXO6.mjs} +9 -5
- package/dist/shared/{ui.DLOxhmP0.mjs → ui.DcEKQd0n.mjs} +490 -20
- package/dist/unocss.mjs +1 -1
- package/dist/unplugin.d.mts +1 -1
- package/dist/unplugin.mjs +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +2 -2
- package/package.json +31 -31
|
@@ -3,29 +3,37 @@ import theme from "#build/ui/select";
|
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script setup>
|
|
6
|
-
import { reactivePick } from "@vueuse/core";
|
|
6
|
+
import { createReusableTemplate, reactivePick } from "@vueuse/core";
|
|
7
7
|
import { defu } from "defu";
|
|
8
|
-
import {
|
|
9
|
-
import { computed, onMounted, shallowRef, toRef } from "vue";
|
|
8
|
+
import { ComboboxAnchor, ComboboxArrow, ComboboxCancel, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxItemIndicator, ComboboxLabel, ComboboxPortal, ComboboxRoot, ComboboxSeparator, ComboboxTrigger, FocusScope, useFilter, useForwardPropsEmits } from "reka-ui";
|
|
9
|
+
import { computed, onMounted, shallowRef, toRaw, toRef } from "vue";
|
|
10
10
|
import { useAppConfig } from "#imports";
|
|
11
11
|
import { useComponentIcons } from "../composables/useComponentIcons";
|
|
12
12
|
import { useFieldGroup } from "../composables/useFieldGroup";
|
|
13
13
|
import { useFormField } from "../composables/useFormField";
|
|
14
|
+
import { useLocale } from "../composables/useLocale";
|
|
14
15
|
import { usePortal } from "../composables/usePortal";
|
|
15
|
-
import { get, getDisplayValue, isArrayOfArray } from "../utils";
|
|
16
|
+
import { compare, get, getDisplayValue, isArrayOfArray, looseToNumber, pick } from "../utils";
|
|
16
17
|
import { cv, merge } from "../utils/style";
|
|
17
18
|
import Avatar from "./Avatar.vue";
|
|
19
|
+
import Button from "./Button.vue";
|
|
18
20
|
import Chip from "./Chip.vue";
|
|
19
21
|
import Icon from "./Icon.vue";
|
|
22
|
+
import Input from "./Input.vue";
|
|
20
23
|
defineOptions({ inheritAttrs: false });
|
|
21
24
|
const props = defineProps({
|
|
22
25
|
id: { type: String, required: false },
|
|
23
26
|
placeholder: { type: String, required: false },
|
|
27
|
+
searchInput: { type: [Boolean, Object], required: false, default: false },
|
|
28
|
+
searchTerm: { type: String, required: false, default: "" },
|
|
29
|
+
required: { type: Boolean, required: false },
|
|
24
30
|
variant: { type: null, required: false },
|
|
25
31
|
size: { type: null, required: false },
|
|
26
32
|
color: { type: null, required: false },
|
|
27
33
|
trailingIcon: { type: [String, Object], required: false },
|
|
28
34
|
selectedIcon: { type: [String, Object], required: false },
|
|
35
|
+
clear: { type: [Boolean, Object], required: false },
|
|
36
|
+
clearIcon: { type: [String, Object], required: false },
|
|
29
37
|
content: { type: Object, required: false },
|
|
30
38
|
arrow: { type: [Boolean, Object], required: false },
|
|
31
39
|
portal: { type: [Boolean, String], required: false, skipCheck: true, default: true },
|
|
@@ -35,8 +43,12 @@ const props = defineProps({
|
|
|
35
43
|
items: { type: null, required: false },
|
|
36
44
|
defaultValue: { type: null, required: false },
|
|
37
45
|
modelValue: { type: null, required: false },
|
|
46
|
+
modelModifiers: { type: Object, required: false },
|
|
38
47
|
multiple: { type: Boolean, required: false },
|
|
39
48
|
highlight: { type: Boolean, required: false },
|
|
49
|
+
createItem: { type: [Boolean, String, Object], required: false },
|
|
50
|
+
filterFields: { type: Array, required: false },
|
|
51
|
+
ignoreFilter: { type: Boolean, required: false },
|
|
40
52
|
autofocus: { type: Boolean, required: false },
|
|
41
53
|
autofocusDelay: { type: Number, required: false, default: 0 },
|
|
42
54
|
ui: { type: null, required: false },
|
|
@@ -50,17 +62,25 @@ const props = defineProps({
|
|
|
50
62
|
loadingIcon: { type: [String, Object], required: false },
|
|
51
63
|
open: { type: Boolean, required: false },
|
|
52
64
|
defaultOpen: { type: Boolean, required: false },
|
|
53
|
-
autocomplete: { type: String, required: false },
|
|
54
65
|
disabled: { type: Boolean, required: false },
|
|
55
66
|
name: { type: String, required: false },
|
|
56
|
-
|
|
67
|
+
resetSearchTermOnBlur: { type: Boolean, required: false, default: true },
|
|
68
|
+
resetSearchTermOnSelect: { type: Boolean, required: false, default: true },
|
|
69
|
+
resetModelValueOnClear: { type: Boolean, required: false, default: true },
|
|
70
|
+
highlightOnHover: { type: Boolean, required: false }
|
|
57
71
|
});
|
|
58
|
-
const emit = defineEmits(["update:open", "change", "blur", "focus", "update:modelValue"]);
|
|
72
|
+
const emit = defineEmits(["highlight", "update:open", "change", "blur", "focus", "create", "clear", "update:searchTerm", "update:modelValue"]);
|
|
59
73
|
const slots = defineSlots();
|
|
60
|
-
const
|
|
74
|
+
const [DefineCreateItemTemplate, ReuseCreateItemTemplate] = createReusableTemplate();
|
|
75
|
+
const { t } = useLocale();
|
|
76
|
+
const searchTerm = defineModel("searchTerm", { type: String, ...{ default: "" } });
|
|
77
|
+
const { contains } = useFilter({ sensitivity: "base" });
|
|
78
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, "modelValue", "defaultValue", "open", "defaultOpen", "required", "multiple", "resetSearchTermOnBlur", "resetSearchTermOnSelect", "resetModelValueOnClear", "highlightOnHover"), emit);
|
|
61
79
|
const portalProps = usePortal(toRef(() => props.portal));
|
|
62
80
|
const contentProps = toRef(() => defu(props.content, { side: "bottom", sideOffset: 8, collisionPadding: 8, position: "popper" }));
|
|
63
81
|
const arrowProps = toRef(() => props.arrow);
|
|
82
|
+
const clearProps = computed(() => typeof props.clear === "object" ? props.clear : {});
|
|
83
|
+
const searchInputProps = toRef(() => defu(props.searchInput, { placeholder: t("select.search"), ...props.searchInput ? {} : { readonly: true } }));
|
|
64
84
|
const { id, name, size: formFieldSize, color, highlight, disabled, ariaAttrs, emitFormChange, emitFormInput, emitFormBlur, emitFormFocus } = useFormField(props);
|
|
65
85
|
const { size: fieldGroupSize, orientation } = useFieldGroup(props);
|
|
66
86
|
const appConfig = useAppConfig();
|
|
@@ -70,19 +90,47 @@ const { isLeading, isTrailing, leadingIconName, trailingIconName } = useComponen
|
|
|
70
90
|
const ui = computed(() => {
|
|
71
91
|
const styler = cv(merge(theme, appConfig.ui.select));
|
|
72
92
|
return styler({
|
|
73
|
-
...props,
|
|
74
|
-
fieldGroup: orientation.value,
|
|
75
|
-
size: fieldGroupSize.value || formFieldSize.value,
|
|
93
|
+
...pick(props, ["variant", "loading"]),
|
|
76
94
|
color: color.value,
|
|
95
|
+
size: fieldGroupSize.value || formFieldSize.value,
|
|
77
96
|
highlight: highlight.value,
|
|
78
97
|
leading: isLeading.value || !!props.avatar || !!slots.leading,
|
|
79
|
-
trailing: isTrailing.value || !!slots.trailing
|
|
98
|
+
trailing: isTrailing.value || !!slots.trailing,
|
|
99
|
+
fieldGroup: orientation.value,
|
|
100
|
+
searchInput: !!props.searchInput
|
|
80
101
|
});
|
|
81
102
|
});
|
|
82
103
|
const groups = computed(
|
|
83
104
|
() => props.items?.length ? isArrayOfArray(props.items) ? props.items : [props.items] : []
|
|
84
105
|
);
|
|
85
106
|
const items = computed(() => groups.value.flat());
|
|
107
|
+
const filteredGroups = computed(() => {
|
|
108
|
+
if (props.ignoreFilter || !searchTerm.value)
|
|
109
|
+
return groups.value;
|
|
110
|
+
const fields = Array.isArray(props.filterFields) ? props.filterFields : [props.labelKey];
|
|
111
|
+
return groups.value.map((items2) => items2.filter((item) => {
|
|
112
|
+
if (item == null)
|
|
113
|
+
return false;
|
|
114
|
+
if (typeof item !== "object")
|
|
115
|
+
return contains(String(item), searchTerm.value);
|
|
116
|
+
if (item.type && ["label", "separator"].includes(item.type))
|
|
117
|
+
return true;
|
|
118
|
+
return fields.some((field) => {
|
|
119
|
+
const value = get(item, field);
|
|
120
|
+
return value != null && contains(String(value), searchTerm.value);
|
|
121
|
+
});
|
|
122
|
+
})).filter((group) => group.some((item) => !isSelectItem(item) || (!item.type || !["label", "separator"].includes(item.type))));
|
|
123
|
+
});
|
|
124
|
+
const filteredItems = computed(() => filteredGroups.value.flat());
|
|
125
|
+
const createItem = computed(() => {
|
|
126
|
+
if (!props.createItem || !searchTerm.value)
|
|
127
|
+
return false;
|
|
128
|
+
const newItem = props.valueKey ? { [props.valueKey]: searchTerm.value } : searchTerm.value;
|
|
129
|
+
if (typeof props.createItem === "object" && props.createItem.when === "always" || props.createItem === "always")
|
|
130
|
+
return !filteredItems.value.some((item) => compare(item, newItem, props.valueKey));
|
|
131
|
+
return !filteredItems.value.length;
|
|
132
|
+
});
|
|
133
|
+
const createItemPosition = computed(() => typeof props.createItem === "object" ? props.createItem.position : "bottom");
|
|
86
134
|
function displayValue(value) {
|
|
87
135
|
if (props.multiple && Array.isArray(value)) {
|
|
88
136
|
const displayedValues = value.map((item) => getDisplayValue(items.value, item, {
|
|
@@ -108,167 +156,270 @@ onMounted(() => {
|
|
|
108
156
|
setTimeout(() => autoFocus(), props.autofocusDelay);
|
|
109
157
|
});
|
|
110
158
|
function onUpdate(value) {
|
|
159
|
+
if (toRaw(props.modelValue) === value)
|
|
160
|
+
return;
|
|
161
|
+
if (props.modelModifiers?.trim)
|
|
162
|
+
value = value?.trim() ?? null;
|
|
163
|
+
if (props.modelModifiers?.number)
|
|
164
|
+
value = looseToNumber(value);
|
|
165
|
+
if (props.modelModifiers?.nullable)
|
|
166
|
+
value ??= null;
|
|
167
|
+
if (props.modelModifiers?.optional)
|
|
168
|
+
value ??= void 0;
|
|
111
169
|
const event = new Event("change", { target: { value } });
|
|
112
170
|
emit("change", event);
|
|
113
171
|
emitFormChange();
|
|
114
172
|
emitFormInput();
|
|
173
|
+
if (props.resetSearchTermOnSelect)
|
|
174
|
+
searchTerm.value = "";
|
|
115
175
|
}
|
|
116
176
|
function onUpdateOpen(value) {
|
|
177
|
+
let timeoutId;
|
|
117
178
|
if (value) {
|
|
118
179
|
const event = new FocusEvent("focus");
|
|
119
180
|
emit("focus", event);
|
|
120
181
|
emitFormFocus();
|
|
182
|
+
clearTimeout(timeoutId);
|
|
121
183
|
} else {
|
|
122
184
|
const event = new FocusEvent("blur");
|
|
123
185
|
emit("blur", event);
|
|
124
186
|
emitFormBlur();
|
|
187
|
+
if (props.resetSearchTermOnBlur) {
|
|
188
|
+
const STATE_ANIMATION_DELAY_MS = 100;
|
|
189
|
+
timeoutId = setTimeout(() => {
|
|
190
|
+
searchTerm.value = "";
|
|
191
|
+
}, STATE_ANIMATION_DELAY_MS);
|
|
192
|
+
}
|
|
125
193
|
}
|
|
126
194
|
}
|
|
195
|
+
function onCreate(e) {
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
e.stopPropagation();
|
|
198
|
+
emit("create", searchTerm.value);
|
|
199
|
+
}
|
|
200
|
+
function onSelect(e, item) {
|
|
201
|
+
if (!isSelectItem(item))
|
|
202
|
+
return;
|
|
203
|
+
if (item.disabled) {
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
item.onSelect?.(e);
|
|
208
|
+
}
|
|
127
209
|
function isSelectItem(item) {
|
|
128
210
|
return typeof item === "object" && item !== null;
|
|
129
211
|
}
|
|
212
|
+
function isModelValueEmpty(modelValue) {
|
|
213
|
+
if (props.multiple && Array.isArray(modelValue))
|
|
214
|
+
return modelValue.length === 0;
|
|
215
|
+
return modelValue == null || modelValue === "";
|
|
216
|
+
}
|
|
217
|
+
function onClear() {
|
|
218
|
+
emit("clear");
|
|
219
|
+
}
|
|
130
220
|
defineExpose({
|
|
131
|
-
triggerRef
|
|
221
|
+
triggerRef: toRef(() => triggerRef.value?.$el)
|
|
132
222
|
});
|
|
133
223
|
</script>
|
|
134
224
|
|
|
135
225
|
<template>
|
|
136
|
-
<
|
|
226
|
+
<DefineCreateItemTemplate>
|
|
227
|
+
<ComboboxItem
|
|
228
|
+
:value="searchTerm"
|
|
229
|
+
:class="ui.item({ class: props.ui?.item })"
|
|
230
|
+
data-part="item"
|
|
231
|
+
@select="onCreate"
|
|
232
|
+
>
|
|
233
|
+
<span :class="ui.itemLabel({ class: props.ui?.itemLabel })" data-part="itemLabel">
|
|
234
|
+
<slot name="create-item-label" :item="searchTerm">
|
|
235
|
+
{{ t("select.create", { label: searchTerm }) }}
|
|
236
|
+
</slot>
|
|
237
|
+
</span>
|
|
238
|
+
</ComboboxItem>
|
|
239
|
+
</DefineCreateItemTemplate>
|
|
240
|
+
|
|
241
|
+
<ComboboxRoot
|
|
242
|
+
:id="id"
|
|
137
243
|
v-slot="{ modelValue, open }"
|
|
244
|
+
v-bind="{ ...rootProps, ...$attrs, ...ariaAttrs }"
|
|
138
245
|
:name="name"
|
|
139
|
-
v-bind="rootProps"
|
|
140
|
-
:default-value="defaultValue"
|
|
141
|
-
:model-value="modelValue"
|
|
142
|
-
:autocomplete="props.autocomplete"
|
|
143
246
|
:disabled="disabled"
|
|
247
|
+
ignore-filter
|
|
248
|
+
as-child
|
|
144
249
|
@update:model-value="onUpdate"
|
|
145
250
|
@update:open="onUpdateOpen"
|
|
146
251
|
>
|
|
147
|
-
<
|
|
148
|
-
ref="triggerRef"
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
252
|
+
<ComboboxAnchor as-child>
|
|
253
|
+
<ComboboxTrigger ref="triggerRef" :class="ui.base({ class: [props.ui?.base, props.class] })" data-part="base" tabindex="0">
|
|
254
|
+
<span v-if="isLeading || !!props.avatar || slots.leading" :class="ui.leading({ class: props.ui?.leading })" data-part="leading">
|
|
255
|
+
<slot name="leading" :model-value="modelValue" :open="open" :ui="ui">
|
|
256
|
+
<Icon
|
|
257
|
+
v-if="isLeading && leadingIconName"
|
|
258
|
+
:name="leadingIconName"
|
|
259
|
+
:class="ui.leadingIcon({ class: props.ui?.leadingIcon })"
|
|
260
|
+
data-part="leadingIcon"
|
|
261
|
+
/>
|
|
262
|
+
<Avatar
|
|
263
|
+
v-else-if="props.avatar"
|
|
264
|
+
:size="props.ui?.itemLeadingChipSize || ui.itemLeadingAvatarSize()"
|
|
265
|
+
v-bind="props.avatar"
|
|
266
|
+
:class="ui.leadingAvatar({ class: props.ui?.leadingAvatar })"
|
|
267
|
+
data-part="leadingAvatar"
|
|
268
|
+
/>
|
|
269
|
+
</slot>
|
|
270
|
+
</span>
|
|
271
|
+
|
|
272
|
+
<slot :model-value="modelValue" :open="open" :ui="ui">
|
|
273
|
+
<template v-for="displayedModelValue in [displayValue(modelValue)]" :key="displayedModelValue">
|
|
274
|
+
<span v-if="displayedModelValue != null" :class="ui.value({ class: props.ui?.value })" data-part="value">
|
|
275
|
+
{{ displayedModelValue }}
|
|
276
|
+
</span>
|
|
277
|
+
<span v-else :class="ui.placeholder({ class: props.ui?.placeholder })" data-part="placeholder">
|
|
278
|
+
<template v-if="props.placeholder">{{ props.placeholder }}</template>
|
|
279
|
+
<template v-else> </template>
|
|
280
|
+
</span>
|
|
281
|
+
</template>
|
|
168
282
|
</slot>
|
|
169
|
-
</span>
|
|
170
283
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
284
|
+
<span v-if="isTrailing || !!slots.trailing || props.clear" :class="ui.trailing({ class: props.ui?.trailing })" data-part="trailing">
|
|
285
|
+
<slot name="trailing" :model-value="modelValue" :open="open" :ui="ui">
|
|
286
|
+
<ComboboxCancel v-if="props.clear && !isModelValueEmpty(modelValue)" as-child>
|
|
287
|
+
<Button
|
|
288
|
+
as="span"
|
|
289
|
+
:icon="props.clearIcon || appConfig.ui.icons.close"
|
|
290
|
+
variant="link"
|
|
291
|
+
color="neutral"
|
|
292
|
+
tabindex="-1"
|
|
293
|
+
v-bind="clearProps"
|
|
294
|
+
:class="ui.trailingClear({ class: props.ui?.trailingClear })"
|
|
295
|
+
data-part="trailingClear"
|
|
296
|
+
@click.stop="onClear"
|
|
297
|
+
/>
|
|
298
|
+
</ComboboxCancel>
|
|
299
|
+
<Icon v-else-if="trailingIconName" :name="trailingIconName" :class="ui.trailingIcon({ class: props.ui?.trailingIcon })" data-part="trailingIcon" />
|
|
300
|
+
</slot>
|
|
301
|
+
</span>
|
|
302
|
+
</ComboboxTrigger>
|
|
303
|
+
</ComboboxAnchor>
|
|
182
304
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</span>
|
|
188
|
-
</SelectTrigger>
|
|
305
|
+
<ComboboxPortal v-bind="portalProps">
|
|
306
|
+
<ComboboxContent v-bind="contentProps" :class="ui.content({ class: props.ui?.content })" data-part="content">
|
|
307
|
+
<FocusScope trapped :class="ui.focusScope({ class: props.ui?.focusScope })" data-part="focusScope">
|
|
308
|
+
<slot name="content-top"></slot>
|
|
189
309
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
310
|
+
<ComboboxInput v-model="searchTerm" :display-value="() => searchTerm" as-child>
|
|
311
|
+
<Input
|
|
312
|
+
autofocus
|
|
313
|
+
autocomplete="off"
|
|
314
|
+
:size="props.size"
|
|
315
|
+
v-bind="searchInputProps"
|
|
316
|
+
:class="ui.input({ class: props.ui?.input })"
|
|
317
|
+
data-part="input"
|
|
318
|
+
@change.stop
|
|
319
|
+
/>
|
|
320
|
+
</ComboboxInput>
|
|
193
321
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
</SelectLabel>
|
|
322
|
+
<ComboboxEmpty :class="ui.empty({ class: props.ui?.empty })" data-part="empty">
|
|
323
|
+
<slot name="empty" :search-term="searchTerm">
|
|
324
|
+
{{ searchTerm ? t("select.noMatch", { searchTerm }) : t("select.noData") }}
|
|
325
|
+
</slot>
|
|
326
|
+
</ComboboxEmpty>
|
|
200
327
|
|
|
201
|
-
|
|
328
|
+
<div role="presentation" :class="ui.viewport({ class: props.ui?.viewport })" data-part="viewport">
|
|
329
|
+
<ComboboxGroup v-if="createItem && createItemPosition === 'top'" :class="ui.group({ class: props.ui?.group })" data-part="group">
|
|
330
|
+
<ReuseCreateItemTemplate />
|
|
331
|
+
</ComboboxGroup>
|
|
202
332
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
333
|
+
<ComboboxGroup v-for="(group, groupIndex) in filteredGroups" :key="`group-${groupIndex}`" :class="ui.group({ class: props.ui?.group })" data-part="group">
|
|
334
|
+
<template v-for="(item, index) in group" :key="`group-${groupIndex}-${index}`">
|
|
335
|
+
<ComboboxLabel
|
|
336
|
+
v-if="isSelectItem(item) && item.type === 'label'"
|
|
337
|
+
:class="ui.label({ class: [props.ui?.label, item.ui?.label, item.class] })"
|
|
338
|
+
data-part="label"
|
|
339
|
+
>
|
|
340
|
+
{{ get(item, props.labelKey) }}
|
|
341
|
+
</ComboboxLabel>
|
|
342
|
+
|
|
343
|
+
<ComboboxSeparator
|
|
344
|
+
v-else-if="isSelectItem(item) && item.type === 'separator'"
|
|
345
|
+
:class="ui.separator({ class: [props.ui?.separator, item.ui?.separator, item.class] })"
|
|
346
|
+
data-part="separator"
|
|
347
|
+
/>
|
|
348
|
+
|
|
349
|
+
<ComboboxItem
|
|
350
|
+
v-else
|
|
351
|
+
:value="props.valueKey && isSelectItem(item) ? get(item, props.valueKey) : item"
|
|
352
|
+
:disabled="isSelectItem(item) && item.disabled"
|
|
353
|
+
:class="ui.item({ class: [props.ui?.item, ...isSelectItem(item) ? [item.ui?.item, item.class] : []] })"
|
|
354
|
+
data-part="item"
|
|
355
|
+
@select="onSelect($event, item)"
|
|
356
|
+
>
|
|
357
|
+
<slot name="item" :item="item" :index="index" :ui="ui">
|
|
358
|
+
<slot name="item-leading" :item="item" :index="index" :ui="ui">
|
|
359
|
+
<Icon
|
|
360
|
+
v-if="isSelectItem(item) && item.icon"
|
|
361
|
+
:name="item.icon"
|
|
362
|
+
:class="ui.itemLeadingIcon({ class: [props.ui?.itemLeadingIcon, item.ui?.itemLeadingIcon] })"
|
|
363
|
+
data-part="itemLeadingIcon"
|
|
364
|
+
/>
|
|
365
|
+
<Avatar
|
|
366
|
+
v-else-if="isSelectItem(item) && item.avatar"
|
|
367
|
+
:size="item.ui?.itemLeadingAvatarSize || props.ui?.itemLeadingAvatarSize || ui.itemLeadingAvatarSize()"
|
|
368
|
+
v-bind="item.avatar"
|
|
369
|
+
:class="ui.itemLeadingAvatar({ class: [props.ui?.leadingAvatar, item.ui?.itemLeadingAvatar] })"
|
|
370
|
+
data-part="itemLeadingAvatar"
|
|
371
|
+
/>
|
|
372
|
+
<Chip
|
|
373
|
+
v-else-if="isSelectItem(item) && item.chip"
|
|
374
|
+
:size="item.ui?.itemLeadingChipSize || props.ui?.itemLeadingChipSize || ui.itemLeadingChipSize()"
|
|
375
|
+
inset
|
|
376
|
+
standalone
|
|
377
|
+
v-bind="item.chip"
|
|
378
|
+
:class="ui.itemLeadingChip({ class: [props.ui?.itemLeadingChip, item.ui?.itemLeadingChip] })"
|
|
379
|
+
data-part="itemLeadingChip"
|
|
380
|
+
/>
|
|
381
|
+
</slot>
|
|
236
382
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
383
|
+
<span :class="ui.itemWrapper({ class: [props.ui?.itemWrapper, isSelectItem(item) && item.ui?.itemWrapper] })" data-part="itemWrapper">
|
|
384
|
+
<span :class="ui.itemLabel({ class: [props.ui?.itemLabel, isSelectItem(item) && item.ui?.itemLabel] })" data-part="itemLabel">
|
|
385
|
+
<slot name="item-label" :item="item" :index="index">
|
|
386
|
+
{{ isSelectItem(item) ? get(item, props.labelKey) : item }}
|
|
387
|
+
</slot>
|
|
388
|
+
</span>
|
|
243
389
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
390
|
+
<span
|
|
391
|
+
v-if="isSelectItem(item) && get(item, props.descriptionKey) || !!slots['item-description']"
|
|
392
|
+
:class="ui.itemDescription({ class: [props.ui?.itemDescription, isSelectItem(item) && item.ui?.itemDescription] })"
|
|
393
|
+
data-part="itemDescription"
|
|
394
|
+
>
|
|
395
|
+
<slot name="item-description" :item="item" :index="index">
|
|
396
|
+
{{ isSelectItem(item) ? get(item, props.descriptionKey) : "" }}
|
|
397
|
+
</slot>
|
|
398
|
+
</span>
|
|
252
399
|
</span>
|
|
253
|
-
</span>
|
|
254
400
|
|
|
255
|
-
|
|
256
|
-
|
|
401
|
+
<span :class="ui.itemTrailing({ class: [props.ui?.itemTrailing, isSelectItem(item) && item.ui?.itemTrailing] })" data-part="itemTrailing">
|
|
402
|
+
<slot name="item-trailing" :item="item" :index="index" :ui="ui"></slot>
|
|
403
|
+
|
|
404
|
+
<ComboboxItemIndicator as-child>
|
|
405
|
+
<Icon :name="props.selectedIcon || appConfig.ui.icons.check" :class="ui.itemTrailingIcon({ class: [props.ui?.itemTrailingIcon, isSelectItem(item) && item.ui?.itemTrailingIcon] })" data-part="itemTrailingIcon" />
|
|
406
|
+
</ComboboxItemIndicator>
|
|
407
|
+
</span>
|
|
408
|
+
</slot>
|
|
409
|
+
</ComboboxItem>
|
|
410
|
+
</template>
|
|
411
|
+
</ComboboxGroup>
|
|
257
412
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
</slot>
|
|
263
|
-
</RekaSelectItem>
|
|
264
|
-
</template>
|
|
265
|
-
</SelectGroup>
|
|
266
|
-
</div>
|
|
413
|
+
<ComboboxGroup v-if="createItem && createItemPosition === 'bottom'" :class="ui.group({ class: props.ui?.group })" data-part="group">
|
|
414
|
+
<ReuseCreateItemTemplate />
|
|
415
|
+
</ComboboxGroup>
|
|
416
|
+
</div>
|
|
267
417
|
|
|
268
|
-
|
|
418
|
+
<slot name="content-bottom"></slot>
|
|
419
|
+
</FocusScope>
|
|
269
420
|
|
|
270
|
-
<
|
|
271
|
-
</
|
|
272
|
-
</
|
|
273
|
-
</
|
|
421
|
+
<ComboboxArrow v-if="props.arrow" v-bind="arrowProps" :class="ui.arrow({ class: props.ui?.arrow })" data-part="arrow" />
|
|
422
|
+
</ComboboxContent>
|
|
423
|
+
</ComboboxPortal>
|
|
424
|
+
</ComboboxRoot>
|
|
274
425
|
</template>
|