mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-29 11:20:36 +01:00
fix(forms)!: bind $attrs to elements (#279)
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex items-center shadow-sm">
|
<ClientOnly>
|
||||||
<ClientOnly>
|
<div class="inline-flex shadow-sm rounded-md">
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="primary"
|
v-model="primary"
|
||||||
name="primary"
|
name="primary"
|
||||||
class="w-full [&>div>button]:!rounded-r-none"
|
class="!rounded-r-none !shadow-none focus:z-[1]"
|
||||||
color="gray"
|
color="gray"
|
||||||
:ui="{ width: 'w-[194px]' }"
|
:ui="{ width: 'w-[194px]' }"
|
||||||
:popper="{ placement: 'bottom-start' }"
|
:popper="{ placement: 'bottom-start' }"
|
||||||
@@ -22,15 +22,13 @@
|
|||||||
{{ option.text }}
|
{{ option.text }}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</ClientOnly>
|
|
||||||
|
|
||||||
<ClientOnly>
|
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-model="gray"
|
v-model="gray"
|
||||||
name="gray"
|
name="gray"
|
||||||
class="w-full [&>div>button]:!rounded-l-none [&>div>button]:-ml-px"
|
class="!rounded-l-none !shadow-none"
|
||||||
color="gray"
|
color="gray"
|
||||||
:ui="{ width: 'w-[194px]' }"
|
:ui="{ width: 'w-[194px]', wrapper: '-ml-px' }"
|
||||||
:popper="{ placement: 'bottom-end' }"
|
:popper="{ placement: 'bottom-end' }"
|
||||||
:options="grayOptions"
|
:options="grayOptions"
|
||||||
>
|
>
|
||||||
@@ -46,8 +44,8 @@
|
|||||||
{{ option.text }}
|
{{ option.text }}
|
||||||
</template>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
</ClientOnly>
|
</div>
|
||||||
</div>
|
</ClientOnly>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|||||||
@@ -8,18 +8,16 @@
|
|||||||
v-model="componentProps[prop.name]"
|
v-model="componentProps[prop.name]"
|
||||||
:name="`prop-${prop.name}`"
|
:name="`prop-${prop.name}`"
|
||||||
variant="none"
|
variant="none"
|
||||||
class="justify-center"
|
:ui="{ wrapper: 'relative flex items-start justify-center' }"
|
||||||
/>
|
/>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
v-else-if="prop.type === 'string' && prop.options.length"
|
v-else-if="prop.type === 'string' && prop.options.length"
|
||||||
v-model="componentProps[prop.name]"
|
v-model="componentProps[prop.name]"
|
||||||
:options="prop.options"
|
:options="prop.options"
|
||||||
:name="`prop-${prop.name}`"
|
:name="`prop-${prop.name}`"
|
||||||
:label="componentProps[prop.name]"
|
|
||||||
variant="none"
|
variant="none"
|
||||||
class="inline-flex"
|
:ui="{ width: 'w-32 !-mt-px', rounded: 'rounded-b-md', wrapper: 'relative inline-flex' }"
|
||||||
:ui="{ width: 'w-32 !-mt-px', rounded: 'rounded-b-md' }"
|
class="!py-0"
|
||||||
:ui-select="{ custom: '!py-0' }"
|
|
||||||
:popper="{ strategy: 'fixed', placement: 'bottom-start' }"
|
:popper="{ strategy: 'fixed', placement: 'bottom-start' }"
|
||||||
/>
|
/>
|
||||||
<UInput
|
<UInput
|
||||||
@@ -29,7 +27,7 @@
|
|||||||
:name="`prop-${prop.name}`"
|
:name="`prop-${prop.name}`"
|
||||||
variant="none"
|
variant="none"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
:ui="{ custom: '!py-0' }"
|
class="!py-0"
|
||||||
@update:model-value="val => componentProps[prop.name] = prop.type === 'number' ? Number(val) : val"
|
@update:model-value="val => componentProps[prop.name] = prop.type === 'number' ? Number(val) : val"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -281,7 +281,6 @@ const input = {
|
|||||||
base: 'relative block w-full disabled:cursor-not-allowed disabled:opacity-75 focus:outline-none border-0',
|
base: 'relative block w-full disabled:cursor-not-allowed disabled:opacity-75 focus:outline-none border-0',
|
||||||
rounded: 'rounded-md',
|
rounded: 'rounded-md',
|
||||||
placeholder: 'placeholder-gray-400 dark:placeholder-gray-500',
|
placeholder: 'placeholder-gray-400 dark:placeholder-gray-500',
|
||||||
custom: '',
|
|
||||||
size: {
|
size: {
|
||||||
'2xs': 'text-xs',
|
'2xs': 'text-xs',
|
||||||
xs: 'text-xs',
|
xs: 'text-xs',
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
class="form-checkbox"
|
class="form-checkbox"
|
||||||
:class="[ui.base, ui.rounded, ui.custom]"
|
:class="[ui.base, ui.rounded, ui.custom]"
|
||||||
|
v-bind="$attrs"
|
||||||
@focus="$emit('focus', $event)"
|
@focus="$emit('focus', $event)"
|
||||||
@blur="$emit('blur', $event)"
|
@blur="$emit('blur', $event)"
|
||||||
>
|
>
|
||||||
@@ -41,6 +42,7 @@ import appConfig from '#build/app.config'
|
|||||||
// const appConfig = useAppConfig()
|
// const appConfig = useAppConfig()
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: [String, Number, Boolean, Object],
|
type: [String, Number, Boolean, Object],
|
||||||
|
|||||||
@@ -9,11 +9,9 @@
|
|||||||
:required="required"
|
:required="required"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:disabled="disabled || loading"
|
:disabled="disabled || loading"
|
||||||
:readonly="readonly"
|
|
||||||
:autocomplete="autocomplete"
|
|
||||||
:spellcheck="spellcheck"
|
|
||||||
class="form-input"
|
class="form-input"
|
||||||
:class="inputClass"
|
:class="inputClass"
|
||||||
|
v-bind="$attrs"
|
||||||
@input="onInput"
|
@input="onInput"
|
||||||
@focus="$emit('focus', $event)"
|
@focus="$emit('focus', $event)"
|
||||||
@blur="$emit('blur', $event)"
|
@blur="$emit('blur', $event)"
|
||||||
@@ -51,6 +49,7 @@ export default defineComponent({
|
|||||||
components: {
|
components: {
|
||||||
UIcon
|
UIcon
|
||||||
},
|
},
|
||||||
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
@@ -76,22 +75,10 @@ export default defineComponent({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
readonly: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
autofocus: {
|
autofocus: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
autocomplete: {
|
|
||||||
type: String,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
spellcheck: {
|
|
||||||
type: Boolean,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
icon: {
|
icon: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null
|
default: null
|
||||||
@@ -189,8 +176,7 @@ export default defineComponent({
|
|||||||
props.padded ? ui.value.padding[props.size] : 'p-0',
|
props.padded ? ui.value.padding[props.size] : 'p-0',
|
||||||
variant?.replaceAll('{color}', props.color),
|
variant?.replaceAll('{color}', props.color),
|
||||||
(isLeading.value || slots.leading) && ui.value.leading.padding[props.size],
|
(isLeading.value || slots.leading) && ui.value.leading.padding[props.size],
|
||||||
(isTrailing.value || slots.trailing) && ui.value.trailing.padding[props.size],
|
(isTrailing.value || slots.trailing) && ui.value.trailing.padding[props.size]
|
||||||
ui.value.custom
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
type="radio"
|
type="radio"
|
||||||
class="form-radio"
|
class="form-radio"
|
||||||
:class="[ui.base, ui.custom]"
|
:class="[ui.base, ui.custom]"
|
||||||
|
v-bind="$attrs"
|
||||||
@focus="$emit('focus', $event)"
|
@focus="$emit('focus', $event)"
|
||||||
@blur="$emit('blur', $event)"
|
@blur="$emit('blur', $event)"
|
||||||
>
|
>
|
||||||
@@ -39,6 +40,7 @@ import appConfig from '#build/app.config'
|
|||||||
// const appConfig = useAppConfig()
|
// const appConfig = useAppConfig()
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: [String, Number, Boolean],
|
type: [String, Number, Boolean],
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
:disabled="disabled || loading"
|
:disabled="disabled || loading"
|
||||||
class="form-select"
|
class="form-select"
|
||||||
:class="selectClass"
|
:class="selectClass"
|
||||||
|
v-bind="$attrs"
|
||||||
@input="onInput"
|
@input="onInput"
|
||||||
>
|
>
|
||||||
<template v-for="(option, index) in normalizedOptionsWithPlaceholder">
|
<template v-for="(option, index) in normalizedOptionsWithPlaceholder">
|
||||||
@@ -69,6 +70,7 @@ export default defineComponent({
|
|||||||
components: {
|
components: {
|
||||||
UIcon
|
UIcon
|
||||||
},
|
},
|
||||||
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [String, Number, Object],
|
type: [String, Number, Object],
|
||||||
@@ -236,8 +238,7 @@ export default defineComponent({
|
|||||||
props.padded ? ui.value.padding[props.size] : 'p-0',
|
props.padded ? ui.value.padding[props.size] : 'p-0',
|
||||||
variant?.replaceAll('{color}', props.color),
|
variant?.replaceAll('{color}', props.color),
|
||||||
(isLeading.value || slots.leading) && ui.value.leading.padding[props.size],
|
(isLeading.value || slots.leading) && ui.value.leading.padding[props.size],
|
||||||
(isTrailing.value || slots.trailing) && ui.value.trailing.padding[props.size],
|
(isTrailing.value || slots.trailing) && ui.value.trailing.padding[props.size]
|
||||||
ui.value.custom
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
class="inline-flex w-full"
|
class="inline-flex w-full"
|
||||||
>
|
>
|
||||||
<slot :open="open" :disabled="disabled" :loading="loading">
|
<slot :open="open" :disabled="disabled" :loading="loading">
|
||||||
<button :class="selectMenuClass" :disabled="disabled || loading" type="button">
|
<button :class="selectMenuClass" :disabled="disabled || loading" type="button" v-bind="$attrs">
|
||||||
<span v-if="(isLeading && leadingIconName) || $slots.leading" :class="leadingWrapperIconClass">
|
<span v-if="(isLeading && leadingIconName) || $slots.leading" :class="leadingWrapperIconClass">
|
||||||
<slot name="leading" :disabled="disabled" :loading="loading">
|
<slot name="leading" :disabled="disabled" :loading="loading">
|
||||||
<UIcon :name="leadingIconName" :class="leadingIconClass" />
|
<UIcon :name="leadingIconName" :class="leadingIconClass" />
|
||||||
@@ -146,6 +146,7 @@ export default defineComponent({
|
|||||||
UIcon,
|
UIcon,
|
||||||
UAvatar
|
UAvatar
|
||||||
},
|
},
|
||||||
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [String, Number, Object, Array],
|
type: [String, Number, Object, Array],
|
||||||
@@ -300,7 +301,6 @@ export default defineComponent({
|
|||||||
variant?.replaceAll('{color}', props.color),
|
variant?.replaceAll('{color}', props.color),
|
||||||
(isLeading.value || slots.leading) && uiSelect.value.leading.padding[props.size],
|
(isLeading.value || slots.leading) && uiSelect.value.leading.padding[props.size],
|
||||||
(isTrailing.value || slots.trailing) && uiSelect.value.trailing.padding[props.size],
|
(isTrailing.value || slots.trailing) && uiSelect.value.trailing.padding[props.size],
|
||||||
uiSelect.value.custom,
|
|
||||||
'inline-flex items-center'
|
'inline-flex items-center'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
:required="required"
|
:required="required"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:autocomplete="autocomplete"
|
|
||||||
class="form-textarea"
|
class="form-textarea"
|
||||||
:class="textareaClass"
|
:class="textareaClass"
|
||||||
|
v-bind="$attrs"
|
||||||
@input="onInput"
|
@input="onInput"
|
||||||
@focus="$emit('focus', $event)"
|
@focus="$emit('focus', $event)"
|
||||||
@blur="$emit('blur', $event)"
|
@blur="$emit('blur', $event)"
|
||||||
@@ -32,6 +32,7 @@ import appConfig from '#build/app.config'
|
|||||||
// const appConfig = useAppConfig()
|
// const appConfig = useAppConfig()
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
inheritAttrs: false,
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
@@ -65,10 +66,6 @@ export default defineComponent({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
autocomplete: {
|
|
||||||
type: String,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
resize: {
|
resize: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
@@ -170,8 +167,7 @@ export default defineComponent({
|
|||||||
ui.value.size[props.size],
|
ui.value.size[props.size],
|
||||||
props.padded ? ui.value.padding[props.size] : 'p-0',
|
props.padded ? ui.value.padding[props.size] : 'p-0',
|
||||||
variant?.replaceAll('{color}', props.color),
|
variant?.replaceAll('{color}', props.color),
|
||||||
!props.resize && 'resize-none',
|
!props.resize && 'resize-none'
|
||||||
ui.value.custom
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user