mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 19:57:55 +01:00
feat(CommandPalette): add active field on items for consistency
This commit is contained in:
@@ -42,6 +42,7 @@ Each group takes some `items` as an array of objects with the following properti
|
|||||||
- `avatar?: AvatarProps`{lang="ts-type"}
|
- `avatar?: AvatarProps`{lang="ts-type"}
|
||||||
- `chip?: ChipProps`{lang="ts-type"}
|
- `chip?: ChipProps`{lang="ts-type"}
|
||||||
- `kbds?: string[] | KbdProps[]`{lang="ts-type"}
|
- `kbds?: string[] | KbdProps[]`{lang="ts-type"}
|
||||||
|
- `active?: boolean`{lang="ts-type"}
|
||||||
- `loading?: boolean`{lang="ts-type"}
|
- `loading?: boolean`{lang="ts-type"}
|
||||||
- `disabled?: boolean`{lang="ts-type"}
|
- `disabled?: boolean`{lang="ts-type"}
|
||||||
- [`slot?: string`{lang="ts-type"}](#with-custom-slot)
|
- [`slot?: string`{lang="ts-type"}](#with-custom-slot)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export interface CommandPaletteItem {
|
|||||||
avatar?: AvatarProps
|
avatar?: AvatarProps
|
||||||
chip?: ChipProps
|
chip?: ChipProps
|
||||||
kbds?: KbdProps['value'][] | KbdProps[]
|
kbds?: KbdProps['value'][] | KbdProps[]
|
||||||
|
active?: boolean
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
slot?: string
|
slot?: string
|
||||||
@@ -276,7 +277,7 @@ const groups = computed(() => {
|
|||||||
:key="`group-${groupIndex}-${index}`"
|
:key="`group-${groupIndex}-${index}`"
|
||||||
:value="omit(item, ['matches' as any, 'group' as any, 'onSelect', 'labelHtml', 'suffixHtml'])"
|
:value="omit(item, ['matches' as any, 'group' as any, 'onSelect', 'labelHtml', 'suffixHtml'])"
|
||||||
:disabled="item.disabled"
|
:disabled="item.disabled"
|
||||||
:class="ui.item({ class: props.ui?.item })"
|
:class="ui.item({ class: props.ui?.item, active: item.active })"
|
||||||
@select="item.onSelect"
|
@select="item.onSelect"
|
||||||
>
|
>
|
||||||
<slot :name="item.slot || group.slot || 'item'" :item="item" :index="index">
|
<slot :name="item.slot || group.slot || 'item'" :item="item" :index="index">
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ export default (options: Required<ModuleOptions>) => ({
|
|||||||
group: 'p-1 isolate',
|
group: 'p-1 isolate',
|
||||||
empty: 'py-6 text-center text-sm text-[var(--ui-text-muted)]',
|
empty: 'py-6 text-center text-sm text-[var(--ui-text-muted)]',
|
||||||
label: 'px-2 py-1.5 text-xs font-semibold text-[var(--ui-text-highlighted)]',
|
label: 'px-2 py-1.5 text-xs font-semibold text-[var(--ui-text-highlighted)]',
|
||||||
item: ['group relative w-full flex items-center gap-2 px-2 py-1.5 text-sm select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-[calc(var(--ui-radius)*1.5)] data-disabled:cursor-not-allowed data-disabled:opacity-75 text-[var(--ui-text)] data-highlighted:text-[var(--ui-text-highlighted)] data-highlighted:before:bg-[var(--ui-bg-elevated)]/50', options.theme.transitions && 'transition-colors before:transition-colors'],
|
item: 'group relative w-full flex items-center gap-2 px-2 py-1.5 text-sm select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-[calc(var(--ui-radius)*1.5)] data-disabled:cursor-not-allowed data-disabled:opacity-75',
|
||||||
itemLeadingIcon: ['shrink-0 size-5 text-[var(--ui-text-dimmed)] group-data-highlighted:text-[var(--ui-text)]', options.theme.transitions && 'transition-colors'],
|
itemLeadingIcon: 'shrink-0 size-5',
|
||||||
itemLeadingAvatar: 'shrink-0',
|
itemLeadingAvatar: 'shrink-0',
|
||||||
itemLeadingAvatarSize: '2xs',
|
itemLeadingAvatarSize: '2xs',
|
||||||
itemLeadingChip: 'shrink-0 size-5',
|
itemLeadingChip: 'shrink-0 size-5',
|
||||||
@@ -27,6 +27,16 @@ export default (options: Required<ModuleOptions>) => ({
|
|||||||
itemLabelSuffix: 'text-[var(--ui-text-dimmed)] [&>mark]:text-[var(--ui-bg)] [&>mark]:bg-[var(--ui-primary)]'
|
itemLabelSuffix: 'text-[var(--ui-text-dimmed)] [&>mark]:text-[var(--ui-bg)] [&>mark]:bg-[var(--ui-primary)]'
|
||||||
},
|
},
|
||||||
variants: {
|
variants: {
|
||||||
|
active: {
|
||||||
|
true: {
|
||||||
|
item: 'text-[var(--ui-text-highlighted)] before:bg-[var(--ui-bg-elevated)]',
|
||||||
|
itemLeadingIcon: 'text-[var(--ui-text)]'
|
||||||
|
},
|
||||||
|
false: {
|
||||||
|
item: ['text-[var(--ui-text)] data-highlighted:text-[var(--ui-text-highlighted)] data-highlighted:before:bg-[var(--ui-bg-elevated)]/50', options.theme.transitions && 'transition-colors before:transition-colors'],
|
||||||
|
itemLeadingIcon: ['text-[var(--ui-text-dimmed)] group-data-highlighted:text-[var(--ui-text)]', options.theme.transitions && 'transition-colors']
|
||||||
|
}
|
||||||
|
},
|
||||||
loading: {
|
loading: {
|
||||||
true: {
|
true: {
|
||||||
itemLeadingIcon: 'animate-spin'
|
itemLeadingIcon: 'animate-spin'
|
||||||
|
|||||||
Reference in New Issue
Block a user