Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/content/docs/2.components/input-menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,43 @@ You can customize this icon globally in your `vite.config.ts` under `ui.icons.cl
:::
::

### Collapse tags
With ``multiple`` enabled, you can set a maximum number of selected items to display as tags. Any additional selected items will be shown in a counter.

::component-code
---
prettier: true ignore:
- modelValue :
- backlog
- Todo
- mutliple external:
- collapse-tags: 2
- items :
- Backlog
- Todo
- In Progress
- Done
---
::
### Collapse hover
With ``multiple`` and ``collapse-tags`` enabled, hovering over the counter in the tags will display the remaining selected items.

::component-code
---
prettier: true ignore:
- modelValue:
- backlog
- Todo
- multiple external:
- collapse-tags: 2
- collapse-hover external:
- items :
- Backlog
- Todo
- In Progress
- Done
---
::
### Placeholder

Use the `placeholder` prop to set a placeholder text.
Expand Down
18 changes: 18 additions & 0 deletions playgrounds/nuxt/app/pages/components/input-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

const value = ref('Apple')
const valueMultiple = ref([fruits[0]!, vegetables[0]!])
const valueMaxValue = ref([fruits[0]!, fruits[1]!, vegetables[0]!, vegetables[1]!])
</script>

<template>
Expand All @@ -80,6 +81,23 @@
v-bind="props"
clear
/>
<UInputMenu
:default-value="valueMaxValue"
multiple
:collapse-tags="2"
placeholder="Collapse"
:items="items"
v-bind="props"
/>

Check failure on line 91 in playgrounds/nuxt/app/pages/components/input-menu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected indentation of 4 spaces but found 6 spaces
<UInputMenu
:default-value="valueMaxValue"
multiple
:collapse-tags="2"
placeholder="Collapse with hover"
:items="items"
collapse-hover
v-bind="props"
/>

Check failure on line 100 in playgrounds/nuxt/app/pages/components/input-menu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected indentation of 4 spaces but found 6 spaces
<UInputMenu placeholder="Highlight" highlight :items="items" v-bind="props" />
<UInputMenu placeholder="Disabled" disabled :items="items" v-bind="props" />
<UInputMenu placeholder="Required" required :items="items" v-bind="props" />
Expand Down
85 changes: 74 additions & 11 deletions src/runtime/components/InputMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@
modelModifiers?: Omit<ModelModifiers<GetModelValue<T, VK, M>>, 'lazy'>
/** Whether multiple options can be selected or not. */
multiple?: M & boolean
/** Maximum number of selected options the input should display.

Check warning on line 148 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Should have no text on the "0th" line (after the `/**`)
* If the number of selected options exceeds this value, a counter shows how many additional options have been selected.
* @defaultValue undefined
*/

Check warning on line 151 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected JSDoc block to be aligned
collapseTags?: number

/** If `collapseTags` is defined, the remaining selected items are shown when hovering over the counter.

Check failure on line 154 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Trailing spaces not allowed

Check warning on line 154 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Should have no text on the "0th" line (after the `/**`)
* @defaultValue false
*/
collapseHover?: boolean
/** Highlight the ring color like a focus state. */
highlight?: boolean
/**
Expand Down Expand Up @@ -592,19 +602,72 @@
@blur="onBlur"
@focus="onFocus"
@remove-tag="onRemoveTag($event, modelValue as GetModelValue<T, VK, true>)"
>

Check failure on line 605 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected 1 line break after opening tag (`<TagsInputRoot>`), but 2 line breaks found
<TagsInputItem v-for="(item, index) in tags" :key="index" :value="item" data-slot="tagsItem" :class="ui.tagsItem({ class: [uiProp?.tagsItem, isInputItem(item) && item.ui?.tagsItem] })">
<TagsInputItemText data-slot="tagsItemText" :class="ui.tagsItemText({ class: [uiProp?.tagsItemText, isInputItem(item) && item.ui?.tagsItemText] })">
<slot name="tags-item-text" :item="(item as NestedItem<T>)" :index="index">
{{ displayValue(item as GetItemValue<T, VK>) }}
</slot>
</TagsInputItemText>

<TagsInputItemDelete data-slot="tagsItemDelete" :class="ui.tagsItemDelete({ class: [uiProp?.tagsItemDelete, isInputItem(item) && item.ui?.tagsItemDelete] })" :disabled="disabled">
<slot name="tags-item-delete" :item="(item as NestedItem<T>)" :index="index" :ui="ui">
<UIcon :name="deleteIcon || appConfig.ui.icons.close" data-slot="tagsItemDeleteIcon" :class="ui.tagsItemDeleteIcon({ class: [uiProp?.tagsItemDeleteIcon, isInputItem(item) && item.ui?.tagsItemDeleteIcon] })" />
</slot>
</TagsInputItemDelete>
<template v-for="(item, index) in tags" :key="index">
<TagsInputItem

Check failure on line 608 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Trailing spaces not allowed
v-if="!collapseTags || collapseTags > index"

Check failure on line 609 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Trailing spaces not allowed
:value="item" data-slot="tagsItem"

Check failure on line 610 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

'data-slot' should be on a new line
:class="ui.tagsItem({ class: [props.ui?.tagsItem, isInputItem(item) && item.ui?.tagsItem] })"
>
<TagsInputItemText

Check failure on line 613 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Trailing spaces not allowed
data-slot="tagsItemText"
:class="ui.tagsItemText({ class: [props.ui?.tagsItemText, isInputItem(item) && item.ui?.tagsItemText] })"
>
<slot

Check failure on line 617 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Trailing spaces not allowed
name="tags-item-text"

Check failure on line 618 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Trailing spaces not allowed
:item="(item as NestedItem<T>)"
:index="index"
>
{{ displayValue((item as GetItemValue<T,VK>)) }}
</slot>
</TagsInputItemText>
<TagsInputItemDelete
data-slot="tagsItemDelete"
:class="ui.tagsItemDelete({ class: [props.ui?.tagsItemDelete, isInputItem(item) && item.ui?.tagsItemDelete] })"
:disabled="disabled">

Check warning on line 628 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected 1 line break before closing bracket, but no line breaks found
<slot
name="tags-item-delete"
:item="(item as NestedItem<T>)"
:index="index"
:ui="ui"
>
<UIcon
:name="deleteIcon || appConfig.ui.icons.close"
data-slot="tagsItemDeleteIcon"
:class="ui.tagsItemDeleteIcon({ class: [props.ui?.tagsItemDeleteIcon, isInputItem(item) && item.ui?.tagsItemDeleteIcon] })"
/>
</slot>
</TagsInputItemDelete>
</TagsInputItem>
</template>
<TagsInputItem
v-if="!!collapseTags && collapseTags < tags.length"
:value="tags.length - collapseTags"
data-slot="tagsCollapse"
:class="ui.tagsItem({ class: [props.ui?.tagsItem, 'group relative cursor-pointer'] })">

Check warning on line 648 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected 1 line break before closing bracket, but no line breaks found
<TagsInputItemText data-slot="tagsCollapseText" :class="ui.tagsItemText({ class: [props.ui?.tagsItemText] })">
<slot name="tags-item-text" :item="(tags.length - collapseTags as NestedItem<T>)" :index="tags.length - collapseTags">
+{{ displayValue((tags.length - collapseTags as GetItemValue<T,VK>)) }}</slot>
</TagsInputItemText>
<div v-if="collapseHover == true"

Check warning on line 653 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected a linebreak before this attribute
class="absolute top-[100%] translate-x-[-50%] pt-[.5em] opacity-0 z-99 invisible group-hover:visible group-hover:opacity-100 transition duration-300">

Check warning on line 654 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected 1 line break before closing bracket, but no line breaks found
<div class="bg-default ring ring-inset ring-accented p-[.5em] rounded-md space-y-[.5em]">
<template
v-for="(item, index) in tags"
>
<div
v-if="index + 1 > collapseTags"
:class="ui.tagsItem({ class: [props.ui?.tagsItem] })">

Check warning on line 661 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected 1 line break before closing bracket, but no line breaks found
<div
:class="ui.tagsItemText({ class: [props.ui?.tagsItemText] })">

Check warning on line 663 in src/runtime/components/InputMenu.vue

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 22)

Expected 1 line break before closing bracket, but no line breaks found
{{ item }}
</div>
</div>
</template>
</div>

</div>
</TagsInputItem>

<ComboboxInput v-model="searchTerm" as-child>
Expand Down