vueless 0.0.542 → 0.0.544
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, useId, useTemplateRef } from "vue";
|
|
2
|
+
import { watch, computed, useId, ref, useTemplateRef, nextTick } from "vue";
|
|
3
3
|
import { merge } from "lodash-es";
|
|
4
4
|
|
|
5
5
|
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
@@ -49,6 +49,10 @@ const emit = defineEmits([
|
|
|
49
49
|
|
|
50
50
|
const wrapperRef = useTemplateRef<HTMLDivElement>("wrapper");
|
|
51
51
|
const optionsRef = useTemplateRef<HTMLLIElement[]>("option");
|
|
52
|
+
const emptyOptionRef = useTemplateRef<HTMLLIElement>("empty-option");
|
|
53
|
+
const addOptionRef = useTemplateRef<HTMLLIElement>("add-option");
|
|
54
|
+
|
|
55
|
+
const wrapperMaxHeight = ref("");
|
|
52
56
|
|
|
53
57
|
const { pointer, pointerDirty, pointerSet, pointerBackward, pointerForward, pointerReset } =
|
|
54
58
|
usePointer(props.options, optionsRef, wrapperRef);
|
|
@@ -80,16 +84,30 @@ const addOptionKeyCombination = computed(() => {
|
|
|
80
84
|
return isMac ? "(⌘ + Enter)" : "(Ctrl + Enter)";
|
|
81
85
|
});
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
watch(
|
|
88
|
+
() => props.options,
|
|
89
|
+
() => {
|
|
90
|
+
nextTick(() => {
|
|
91
|
+
const options = [
|
|
92
|
+
...(optionsRef.value || []),
|
|
93
|
+
...(addOptionRef.value ? [addOptionRef.value] : []),
|
|
94
|
+
...(emptyOptionRef.value ? [emptyOptionRef.value] : []),
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
if (props.visibleOptions) {
|
|
98
|
+
options.slice(0, props.visibleOptions);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const maxHeight = options
|
|
102
|
+
.slice(0, props.visibleOptions)
|
|
103
|
+
.map((el) => el.getBoundingClientRect().height)
|
|
104
|
+
.reduce((acc, cur) => acc + cur, 0);
|
|
105
|
+
|
|
106
|
+
wrapperMaxHeight.value = `${maxHeight + 10}px`;
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
{ immediate: true },
|
|
110
|
+
);
|
|
93
111
|
|
|
94
112
|
function onClickAddOption() {
|
|
95
113
|
emit("add");
|
|
@@ -202,7 +220,7 @@ defineExpose({
|
|
|
202
220
|
<div
|
|
203
221
|
ref="wrapper"
|
|
204
222
|
tabindex="1"
|
|
205
|
-
:style="{ maxHeight:
|
|
223
|
+
:style="{ maxHeight: wrapperMaxHeight }"
|
|
206
224
|
v-bind="wrapperAttrs"
|
|
207
225
|
@keydown.self.down.prevent="pointerForward"
|
|
208
226
|
@keydown.self.up.prevent="pointerBackward"
|
|
@@ -267,21 +285,34 @@ defineExpose({
|
|
|
267
285
|
</template>
|
|
268
286
|
</li>
|
|
269
287
|
|
|
270
|
-
<
|
|
288
|
+
<li
|
|
289
|
+
v-if="!options.length"
|
|
290
|
+
:id="`${elementId}-empty`"
|
|
291
|
+
ref="empty-option"
|
|
292
|
+
role="option"
|
|
293
|
+
v-bind="optionAttrs"
|
|
294
|
+
>
|
|
271
295
|
<!-- @slot Use it to add something instead of empty state. -->
|
|
272
296
|
<slot name="empty">
|
|
273
297
|
<span v-bind="optionContentAttrs" v-text="currentLocale.noDataToShow" />
|
|
274
298
|
</slot>
|
|
275
|
-
</
|
|
299
|
+
</li>
|
|
276
300
|
|
|
277
301
|
<!-- Add button -->
|
|
278
302
|
<template v-if="addOption">
|
|
279
|
-
<
|
|
280
|
-
|
|
303
|
+
<li
|
|
304
|
+
:id="`${elementId}-addOption`"
|
|
305
|
+
ref="add-option"
|
|
306
|
+
role="option"
|
|
307
|
+
v-bind="addOptionLabelWrapperAttrs"
|
|
308
|
+
@click="onClickAddOption"
|
|
309
|
+
@mouseenter.self="pointerSet(options.length + 1)"
|
|
310
|
+
>
|
|
311
|
+
<span v-bind="addOptionLabelAttrs">
|
|
281
312
|
{{ currentLocale.add }}
|
|
282
313
|
<span v-bind="addOptionLabelHotkeyAttrs" v-text="addOptionKeyCombination" />
|
|
283
|
-
</
|
|
284
|
-
</
|
|
314
|
+
</span>
|
|
315
|
+
</li>
|
|
285
316
|
|
|
286
317
|
<UButton round square v-bind="addOptionButtonAttrs" @click="onClickAddOption">
|
|
287
318
|
<UIcon
|
|
@@ -5,13 +5,13 @@ export default /*tw*/ {
|
|
|
5
5
|
overflow-auto [-webkit-overflow-scrolling:touch]
|
|
6
6
|
focus:outline-none
|
|
7
7
|
`,
|
|
8
|
-
list: "m-1 inline-block list-none align-top w-full
|
|
8
|
+
list: "m-1 p-0 inline-block list-none align-top w-full",
|
|
9
9
|
listItem: "group/item block",
|
|
10
10
|
option: {
|
|
11
11
|
base: `
|
|
12
12
|
rounded px-2 py-2.5 flex items-center align-middle whitespace-nowrap cursor-pointer
|
|
13
13
|
font-normal !leading-none normal-case text-gray-900
|
|
14
|
-
hover:bg-brand-50
|
|
14
|
+
hover:bg-brand-50 active:bg-brand-100
|
|
15
15
|
overflow-hidden text-ellipsis
|
|
16
16
|
`,
|
|
17
17
|
variants: {
|
|
@@ -49,13 +49,10 @@ export default /*tw*/ {
|
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
|
-
addOptionLabelWrapper:
|
|
53
|
-
|
|
54
|
-
active:bg-brand-100 active:font-medium -mb-6
|
|
55
|
-
`,
|
|
56
|
-
addOptionLabel: "text-sm font-medium text-gray-900",
|
|
52
|
+
addOptionLabelWrapper: "-mb-[1.375rem] active:bg-brand-100",
|
|
53
|
+
addOptionLabel: "leading-none font-medium",
|
|
57
54
|
addOptionLabelHotkey: "text-gray-500",
|
|
58
|
-
addOptionButton: "{UButton} sticky left-[calc(100%-2.
|
|
55
|
+
addOptionButton: "{UButton} !leading-none sticky left-[calc(100%-2.15rem)] bottom-2 p-1",
|
|
59
56
|
addOptionIcon: "{UIcon} bg-transparent",
|
|
60
57
|
i18n: {
|
|
61
58
|
noDataToShow: "No data to show.",
|
|
@@ -65,7 +62,6 @@ export default /*tw*/ {
|
|
|
65
62
|
size: "md",
|
|
66
63
|
labelKey: "label",
|
|
67
64
|
valueKey: "id",
|
|
68
|
-
optionHeight: 40,
|
|
69
65
|
visibleOptions: undefined,
|
|
70
66
|
disabled: false,
|
|
71
67
|
addOption: false,
|
|
@@ -16,6 +16,9 @@ export default function useAttrs(props: UDropdownListProps): UseAttrs<Config> {
|
|
|
16
16
|
const extendingKeysClasses = getExtendingKeysClasses(extendingKeys);
|
|
17
17
|
|
|
18
18
|
const keysAttrs = getKeysAttrs({}, [], {
|
|
19
|
+
addOptionLabelWrapper: {
|
|
20
|
+
base: computed(() => [extendingKeysClasses.option.value]),
|
|
21
|
+
},
|
|
19
22
|
group: {
|
|
20
23
|
base: computed(() => [extendingKeysClasses.option.value]),
|
|
21
24
|
},
|