Compare commits

..

8 Commits

Author SHA1 Message Date
Benjamin Canac
91f273c117 chore(release): 0.1.29 2023-01-17 15:00:19 +01:00
Benjamin Canac
cda8ce32a3 chore(release): 0.1.28 2023-01-13 18:33:18 +01:00
Benjamin Canac
2bc0eb05d1 chore(Slideover): emit event 2023-01-13 18:32:45 +01:00
Benjamin Canac
cfc4bdfbfe chore(release): 0.1.27 2023-01-12 15:33:35 +01:00
Sylvain Marroufin
370d05921d chore(lighthouse): improve CommandPalette 2023-01-12 14:28:29 +01:00
Sylvain Marroufin
b6455a151d chore(lighthouse): improve components accessibility (#127) 2023-01-12 12:32:42 +01:00
Benjamin Canac
8c0e0ec823 chore(release): 0.1.26 2023-01-09 18:43:45 +01:00
Sylvain Marroufin
4f56921096 fix(CommandPalette): select first item on search changes (#126) 2023-01-09 18:43:12 +01:00
8 changed files with 51 additions and 11 deletions

View File

@@ -2,6 +2,19 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.1.29](https://github.com/nuxtlabs/ui/compare/v0.1.28...v0.1.29) (2023-01-17)
### [0.1.28](https://github.com/nuxtlabs/ui/compare/v0.1.27...v0.1.28) (2023-01-13)
### [0.1.27](https://github.com/nuxtlabs/ui/compare/v0.1.26...v0.1.27) (2023-01-12)
### [0.1.26](https://github.com/nuxtlabs/ui/compare/v0.1.25...v0.1.26) (2023-01-09)
### Bug Fixes
* **CommandPalette:** select first item on search changes ([#126](https://github.com/nuxtlabs/ui/issues/126)) ([4f56921](https://github.com/nuxtlabs/ui/commit/4f56921096f5885cdab8b7cb5c5aa01304188e11))
### [0.1.25](https://github.com/nuxtlabs/ui/compare/v0.1.24...v0.1.25) (2023-01-09)
### [0.1.24](https://github.com/nuxtlabs/ui/compare/v0.1.23...v0.1.24) (2023-01-04)

View File

@@ -1,6 +1,6 @@
{
"name": "@nuxthq/ui",
"version": "0.1.25",
"version": "0.1.29",
"repository": "https://github.com/nuxtlabs/ui",
"license": "MIT",
"exports": {

View File

@@ -1,6 +1,12 @@
<template>
<Menu v-slot="{ open }" as="div" :class="wrapperClass" @mouseleave="onMouseLeave">
<MenuButton ref="trigger" as="div" class="inline-flex w-full" @mouseover="onMouseOver">
<MenuButton
ref="trigger"
as="div"
class="inline-flex w-full"
role="button"
@mouseover="onMouseOver"
>
<slot :open="open">
<button>Open</button>
</slot>

View File

@@ -10,9 +10,9 @@
:class="wrapperClass"
@update:model-value="onUpdate"
>
<input :value="modelValue" :required="required" class="absolute inset-0 w-px opacity-0 cursor-default" tabindex="-1">
<input :value="modelValue" :required="required" class="absolute inset-0 w-px opacity-0 cursor-default" tabindex="-1" aria-hidden="true">
<ComboboxButton ref="trigger" v-slot="{ disabled: buttonDisabled }" as="div" class="inline-flex w-full">
<ComboboxButton ref="trigger" v-slot="{ disabled: buttonDisabled }" as="div" role="button" class="inline-flex w-full">
<slot :open="open" :disabled="buttonDisabled">
<button :class="selectCustomClass" :disabled="disabled" type="button">
<slot name="label">

View File

@@ -19,7 +19,14 @@
@change="query = $event.target.value"
/>
<Button v-if="closeIcon" :icon="closeIcon" variant="transparent" class="absolute right-3" @click="onClear" />
<Button
v-if="closeIcon"
:icon="closeIcon"
variant="transparent"
class="absolute right-3"
aria-label="close"
@click="onClear"
/>
</div>
<ComboboxOptions v-if="groups.length" static hold class="relative flex-1 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800 scroll-py-2">
@@ -41,7 +48,7 @@
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { ref, computed, watch, onMounted } from 'vue'
import { Combobox, ComboboxInput, ComboboxOptions } from '@headlessui/vue'
import type { ComputedRef, PropType, ComponentPublicInstance } from 'vue'
import { useFuse } from '@vueuse/integrations/useFuse'
@@ -174,11 +181,19 @@ const groups = computed(() => map(groupBy(results.value, command => command.item
} as Group
}))
watch(groups, () => {
// Select first item on search changes
setTimeout(() => {
// https://github.com/tailwindlabs/headlessui/blob/6fa6074cd5d3a96f78a2d965392aa44101f5eede/packages/%40headlessui-vue/src/components/combobox/combobox.ts#L804
comboboxInput.value?.$el.dispatchEvent(new KeyboardEvent('keydown', { key: 'PageUp' }))
}, 0)
})
// Methods
function activateFirstOption () {
// hack combobox by using keyboard event
// https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-vue/src/components/combobox/combobox.ts#L692
// https://github.com/tailwindlabs/headlessui/blob/6fa6074cd5d3a96f78a2d965392aa44101f5eede/packages/%40headlessui-vue/src/components/combobox/combobox.ts#L769
setTimeout(() => {
comboboxInput.value?.$el.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown' }))
}, 0)

View File

@@ -1,5 +1,5 @@
<template>
<li class="p-2">
<li class="p-2" role="option">
<h2 v-if="group[groupAttribute]" class="px-3 my-2 text-xs font-semibold u-text-gray-900">
{{ group[groupAttribute] }}
</h2>
@@ -20,6 +20,7 @@
v-else-if="command.avatar"
v-bind="{ size: 'xxxs', ...command.avatar }"
class="flex-shrink-0"
aria-hidden="true"
/>
<span v-else-if="command.chip" class="flex-shrink-0 w-2 h-2 mx-1 rounded-full" :style="{ background: `#${command.chip}` }" />

View File

@@ -1,6 +1,6 @@
<template>
<Popover v-slot="{ open, close }" :class="wrapperClass" @mouseleave="onMouseLeave">
<PopoverButton ref="trigger" as="div" class="inline-flex w-full" @mouseover="onMouseOver">
<PopoverButton ref="trigger" as="div" class="inline-flex w-full" role="button" @mouseover="onMouseOver">
<slot :open="open" :close="close">
<button>Open</button>
</slot>

View File

@@ -1,6 +1,6 @@
<template>
<TransitionRoot as="template" :appear="appear" :show="isOpen">
<Dialog :class="[wrapperClass, { 'justify-end': side === 'right' }]" @close="isOpen = false">
<Dialog :class="[wrapperClass, { 'justify-end': side === 'right' }]" @close="close">
<TransitionChild
v-if="overlay"
as="template"
@@ -89,7 +89,7 @@ const props = defineProps({
}
})
const emit = defineEmits(['update:modelValue'])
const emit = defineEmits(['update:modelValue', 'close'])
const isOpen: WritableComputedRef<boolean> = computed({
get () {
@@ -129,6 +129,11 @@ const slideoverTransition = computed(() => {
...props.transitionClass
}
})
function close (value: boolean) {
isOpen.value = value
emit('close')
}
</script>
<script lang="ts">