Skip to content

Commit

Permalink
fix(SelectCustom): move wrapper under Listbox
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Apr 28, 2022
1 parent cde6b50 commit 936d6a5
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/runtime/components/forms/SelectCustom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@
<Listbox
:model-value="modelValue"
:multiple="multiple"
as="div"
:class="wrapperClass"
@update:model-value="$emit('update:modelValue', $event)"
>
<input :value="modelValue" :required="required" class="absolute inset-0 w-px opacity-0 cursor-default" tabindex="-1">
<div :class="wrapperClass">
<input :value="modelValue" :required="required" class="absolute inset-0 w-px opacity-0 cursor-default" tabindex="-1">

<ListboxButton :class="selectCustomClass">
<slot>
<span v-if="modelValue" class="block truncate">{{ modelValue[textAttribute] }}</span>
<span v-else class="block truncate u-text-gray-400">{{ placeholder }}</span>
</slot>
<span :class="iconWrapperClass">
<Icon name="heroicons-solid:selector" :class="iconClass" aria-hidden="true" />
</span>
</ListboxButton>
<ListboxButton :class="selectCustomClass">
<slot>
<span v-if="modelValue" class="block truncate">{{ modelValue[textAttribute] }}</span>
<span v-else class="block truncate u-text-gray-400">{{ placeholder }}</span>
</slot>
<span :class="iconWrapperClass">
<Icon name="heroicons-solid:selector" :class="iconClass" aria-hidden="true" />
</span>
</ListboxButton>

<transition leave-active-class="transition ease-in duration-100" leave-from-class="opacity-100" leave-to-class="opacity-0">
<ListboxOptions :class="listBaseClass">
<ListboxOption
v-for="(option, index) in options"
v-slot="{ active, selected, disabled }"
:key="index"
as="template"
:value="option"
:disabled="option.disabled"
>
<li :class="resolveOptionClass({ active, disabled })">
<span :class="[selected ? 'font-semibold' : 'font-normal', 'block truncate']">
<slot name="option" :option="option">
{{ option[textAttribute] }}
</slot>
</span>
<transition leave-active-class="transition ease-in duration-100" leave-from-class="opacity-100" leave-to-class="opacity-0">
<ListboxOptions :class="listBaseClass">
<ListboxOption
v-for="(option, index) in options"
v-slot="{ active, selected, disabled }"
:key="index"
as="template"
:value="option"
:disabled="option.disabled"
>
<li :class="resolveOptionClass({ active, disabled })">
<span :class="[selected ? 'font-semibold' : 'font-normal', 'block truncate']">
<slot name="option" :option="option">
{{ option[textAttribute] }}
</slot>
</span>

<span v-if="selected" :class="resolveOptionIconClass({ active })">
<Icon name="heroicons-solid:check" :class="listOptionIconSizeClass" aria-hidden="true" />
</span>
</li>
</ListboxOption>
</ListboxOptions>
</transition>
<span v-if="selected" :class="resolveOptionIconClass({ active })">
<Icon name="heroicons-solid:check" :class="listOptionIconSizeClass" aria-hidden="true" />
</span>
</li>
</ListboxOption>
</ListboxOptions>
</transition>
</div>
</Listbox>
</template>

Expand Down

1 comment on commit 936d6a5

@vercel
Copy link

@vercel vercel bot commented on 936d6a5 Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui-git-dev-nuxtlabs.vercel.app
nuxthq-ui.vercel.app
ui-nuxtlabs.vercel.app

Please sign in to comment.