mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-24 08:50:34 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cda8ce32a3 | ||
|
|
2bc0eb05d1 | ||
|
|
cfc4bdfbfe | ||
|
|
370d05921d | ||
|
|
b6455a151d | ||
|
|
8c0e0ec823 | ||
|
|
4f56921096 | ||
|
|
6a5ee32e05 |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -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.
|
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.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)
|
### [0.1.24](https://github.com/nuxtlabs/ui/compare/v0.1.23...v0.1.24) (2023-01-04)
|
||||||
|
|
||||||
### [0.1.23](https://github.com/nuxtlabs/ui/compare/v0.1.22...v0.1.23) (2022-12-20)
|
### [0.1.23](https://github.com/nuxtlabs/ui/compare/v0.1.22...v0.1.23) (2022-12-20)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nuxthq/ui",
|
"name": "@nuxthq/ui",
|
||||||
"version": "0.1.24",
|
"version": "0.1.28",
|
||||||
"repository": "https://github.com/nuxtlabs/ui",
|
"repository": "https://github.com/nuxtlabs/ui",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<Menu v-slot="{ open }" as="div" :class="wrapperClass" @mouseleave="onMouseLeave">
|
<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">
|
<slot :open="open">
|
||||||
<button>Open</button>
|
<button>Open</button>
|
||||||
</slot>
|
</slot>
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
:class="wrapperClass"
|
:class="wrapperClass"
|
||||||
@update:model-value="onUpdate"
|
@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">
|
<slot :open="open" :disabled="buttonDisabled">
|
||||||
<button :class="selectCustomClass" :disabled="disabled" type="button">
|
<button :class="selectCustomClass" :disabled="disabled" type="button">
|
||||||
<slot name="label">
|
<slot name="label">
|
||||||
|
|||||||
@@ -19,7 +19,14 @@
|
|||||||
@change="query = $event.target.value"
|
@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>
|
</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">
|
<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>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<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 { Combobox, ComboboxInput, ComboboxOptions } from '@headlessui/vue'
|
||||||
import type { ComputedRef, PropType, ComponentPublicInstance } from 'vue'
|
import type { ComputedRef, PropType, ComponentPublicInstance } from 'vue'
|
||||||
import { useFuse } from '@vueuse/integrations/useFuse'
|
import { useFuse } from '@vueuse/integrations/useFuse'
|
||||||
@@ -174,11 +181,19 @@ const groups = computed(() => map(groupBy(results.value, command => command.item
|
|||||||
} as Group
|
} 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
|
// Methods
|
||||||
|
|
||||||
function activateFirstOption () {
|
function activateFirstOption () {
|
||||||
// hack combobox by using keyboard event
|
// 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(() => {
|
setTimeout(() => {
|
||||||
comboboxInput.value?.$el.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown' }))
|
comboboxInput.value?.$el.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown' }))
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<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">
|
<h2 v-if="group[groupAttribute]" class="px-3 my-2 text-xs font-semibold u-text-gray-900">
|
||||||
{{ group[groupAttribute] }}
|
{{ group[groupAttribute] }}
|
||||||
</h2>
|
</h2>
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
v-else-if="command.avatar"
|
v-else-if="command.avatar"
|
||||||
v-bind="{ size: 'xxxs', ...command.avatar }"
|
v-bind="{ size: 'xxxs', ...command.avatar }"
|
||||||
class="flex-shrink-0"
|
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}` }" />
|
<span v-else-if="command.chip" class="flex-shrink-0 w-2 h-2 mx-1 rounded-full" :style="{ background: `#${command.chip}` }" />
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<Popover v-slot="{ open, close }" :class="wrapperClass" @mouseleave="onMouseLeave">
|
<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">
|
<slot :open="open" :close="close">
|
||||||
<button>Open</button>
|
<button>Open</button>
|
||||||
</slot>
|
</slot>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<TransitionRoot as="template" :appear="appear" :show="isOpen">
|
<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
|
<TransitionChild
|
||||||
v-if="overlay"
|
v-if="overlay"
|
||||||
as="template"
|
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({
|
const isOpen: WritableComputedRef<boolean> = computed({
|
||||||
get () {
|
get () {
|
||||||
@@ -129,6 +129,11 @@ const slideoverTransition = computed(() => {
|
|||||||
...props.transitionClass
|
...props.transitionClass
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function close (value: boolean) {
|
||||||
|
isOpen.value = value
|
||||||
|
emit('close')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|||||||
Reference in New Issue
Block a user