|
|
@ -45,24 +45,6 @@ const options = computed<SelectOptionType[]>(() => { |
|
|
|
return [] |
|
|
|
return [] |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const handleKeys = (e: KeyboardEvent) => { |
|
|
|
|
|
|
|
switch (e.key) { |
|
|
|
|
|
|
|
case 'Escape': |
|
|
|
|
|
|
|
e.preventDefault() |
|
|
|
|
|
|
|
isOpen.value = false |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
case 'ArrowDown': |
|
|
|
|
|
|
|
case 'ArrowUp': |
|
|
|
|
|
|
|
if (isOpen.value) e.stopPropagation() |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
case 'Enter': |
|
|
|
|
|
|
|
isOpen.value = true |
|
|
|
|
|
|
|
e.stopPropagation() |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleClose = (e: MouseEvent) => { |
|
|
|
const handleClose = (e: MouseEvent) => { |
|
|
|
if (aselect.value && !aselect.value.$el.contains(e.target)) { |
|
|
|
if (aselect.value && !aselect.value.$el.contains(e.target)) { |
|
|
|
isOpen.value = false |
|
|
|
isOpen.value = false |
|
|
@ -72,7 +54,6 @@ const handleClose = (e: MouseEvent) => { |
|
|
|
|
|
|
|
|
|
|
|
useEventListener(document, 'click', handleClose) |
|
|
|
useEventListener(document, 'click', handleClose) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch(isOpen, (n, _o) => { |
|
|
|
watch(isOpen, (n, _o) => { |
|
|
|
if (!n) { |
|
|
|
if (!n) { |
|
|
|
aselect.value?.$el?.querySelector('input')?.blur() |
|
|
|
aselect.value?.$el?.querySelector('input')?.blur() |
|
|
@ -80,6 +61,19 @@ watch(isOpen, (n, _o) => { |
|
|
|
aselect.value?.$el?.querySelector('input')?.focus() |
|
|
|
aselect.value?.$el?.querySelector('input')?.focus() |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useSelectedCellKeyupListener(active, (e) => { |
|
|
|
|
|
|
|
switch (e.key) { |
|
|
|
|
|
|
|
case 'Escape': |
|
|
|
|
|
|
|
isOpen.value = false |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
case 'Enter': |
|
|
|
|
|
|
|
if (active.value && !isOpen.value) { |
|
|
|
|
|
|
|
isOpen.value = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
@ -94,7 +88,7 @@ watch(isOpen, (n, _o) => { |
|
|
|
:show-arrow="!readOnly && (active || vModel === null)" |
|
|
|
:show-arrow="!readOnly && (active || vModel === null)" |
|
|
|
:dropdown-class-name="`nc-dropdown-single-select-cell ${isOpen ? 'active' : ''}`" |
|
|
|
:dropdown-class-name="`nc-dropdown-single-select-cell ${isOpen ? 'active' : ''}`" |
|
|
|
@select="isOpen = false" |
|
|
|
@select="isOpen = false" |
|
|
|
@keydown="isOpen ? handleKeys : null" |
|
|
|
@keydown.enter.stop |
|
|
|
@click="isOpen = active && !isOpen" |
|
|
|
@click="isOpen = active && !isOpen" |
|
|
|
> |
|
|
|
> |
|
|
|
<a-select-option |
|
|
|
<a-select-option |
|
|
|