fix: support disabled for date + enum
This commit is contained in:
parent
0c77d1943f
commit
f4684033f1
|
|
@ -9,7 +9,7 @@ import { cn } from '@/lib/utils'
|
||||||
import { DateFormatter, getLocalTimeZone } from '@internationalized/date'
|
import { DateFormatter, getLocalTimeZone } from '@internationalized/date'
|
||||||
import { CalendarIcon } from 'lucide-vue-next'
|
import { CalendarIcon } from 'lucide-vue-next'
|
||||||
import AutoFormLabel from './AutoFormLabel.vue'
|
import AutoFormLabel from './AutoFormLabel.vue'
|
||||||
import { beautifyObjectName } from './utils'
|
import { beautifyObjectName, maybeBooleanishToBoolean } from './utils'
|
||||||
|
|
||||||
defineProps<FieldProps>()
|
defineProps<FieldProps>()
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ const df = new DateFormatter('en-US', {
|
||||||
<slot v-bind="slotProps">
|
<slot v-bind="slotProps">
|
||||||
<div>
|
<div>
|
||||||
<Popover>
|
<Popover>
|
||||||
<PopoverTrigger as-child :disabled="disabled">
|
<PopoverTrigger as-child :disabled="maybeBooleanishToBoolean(config?.inputProps?.disabled) ?? disabled">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
:class="cn(
|
:class="cn(
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { Label } from '@/lib/registry/default/ui/label'
|
||||||
import { RadioGroup, RadioGroupItem } from '@/lib/registry/default/ui/radio-group'
|
import { RadioGroup, RadioGroupItem } from '@/lib/registry/default/ui/radio-group'
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/lib/registry/default/ui/select'
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/lib/registry/default/ui/select'
|
||||||
import AutoFormLabel from './AutoFormLabel.vue'
|
import AutoFormLabel from './AutoFormLabel.vue'
|
||||||
import { beautifyObjectName } from './utils'
|
import { beautifyObjectName, maybeBooleanishToBoolean } from './utils'
|
||||||
|
|
||||||
defineProps<FieldProps & {
|
defineProps<FieldProps & {
|
||||||
options?: string[]
|
options?: string[]
|
||||||
|
|
@ -20,14 +20,14 @@ defineProps<FieldProps & {
|
||||||
</AutoFormLabel>
|
</AutoFormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<slot v-bind="slotProps">
|
<slot v-bind="slotProps">
|
||||||
<RadioGroup v-if="config?.component === 'radio'" :disabled="disabled" :orientation="'vertical'" v-bind="{ ...slotProps.componentField }">
|
<RadioGroup v-if="config?.component === 'radio'" :disabled="maybeBooleanishToBoolean(config?.inputProps?.disabled) ?? disabled" :orientation="'vertical'" v-bind="{ ...slotProps.componentField }">
|
||||||
<div v-for="(option, index) in options" :key="option" class="mb-2 flex items-center gap-3 space-y-0">
|
<div v-for="(option, index) in options" :key="option" class="mb-2 flex items-center gap-3 space-y-0">
|
||||||
<RadioGroupItem :id="`${option}-${index}`" :value="option" />
|
<RadioGroupItem :id="`${option}-${index}`" :value="option" />
|
||||||
<Label :for="`${option}-${index}`">{{ beautifyObjectName(option) }}</Label>
|
<Label :for="`${option}-${index}`">{{ beautifyObjectName(option) }}</Label>
|
||||||
</div>
|
</div>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
<Select v-else :disabled="disabled" v-bind="{ ...slotProps.componentField }">
|
<Select v-else :disabled="maybeBooleanishToBoolean(config?.inputProps?.disabled) ?? disabled" v-bind="{ ...slotProps.componentField }">
|
||||||
<SelectTrigger class="w-full">
|
<SelectTrigger class="w-full">
|
||||||
<SelectValue :placeholder="config?.inputProps?.placeholder" />
|
<SelectValue :placeholder="config?.inputProps?.placeholder" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { cn } from '@/lib/utils'
|
||||||
import { DateFormatter, getLocalTimeZone } from '@internationalized/date'
|
import { DateFormatter, getLocalTimeZone } from '@internationalized/date'
|
||||||
import { CalendarIcon } from '@radix-icons/vue'
|
import { CalendarIcon } from '@radix-icons/vue'
|
||||||
import AutoFormLabel from './AutoFormLabel.vue'
|
import AutoFormLabel from './AutoFormLabel.vue'
|
||||||
import { beautifyObjectName } from './utils'
|
import { beautifyObjectName, maybeBooleanishToBoolean } from './utils'
|
||||||
|
|
||||||
defineProps<FieldProps>()
|
defineProps<FieldProps>()
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ const df = new DateFormatter('en-US', {
|
||||||
<slot v-bind="slotProps">
|
<slot v-bind="slotProps">
|
||||||
<div>
|
<div>
|
||||||
<Popover>
|
<Popover>
|
||||||
<PopoverTrigger as-child :disabled="disabled">
|
<PopoverTrigger as-child :disabled="maybeBooleanishToBoolean(config?.inputProps?.disabled) ?? disabled">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
:class="cn(
|
:class="cn(
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { Label } from '@/lib/registry/new-york/ui/label'
|
||||||
import { RadioGroup, RadioGroupItem } from '@/lib/registry/new-york/ui/radio-group'
|
import { RadioGroup, RadioGroupItem } from '@/lib/registry/new-york/ui/radio-group'
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/lib/registry/new-york/ui/select'
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/lib/registry/new-york/ui/select'
|
||||||
import AutoFormLabel from './AutoFormLabel.vue'
|
import AutoFormLabel from './AutoFormLabel.vue'
|
||||||
import { beautifyObjectName } from './utils'
|
import { beautifyObjectName, maybeBooleanishToBoolean } from './utils'
|
||||||
|
|
||||||
defineProps<FieldProps & {
|
defineProps<FieldProps & {
|
||||||
options?: string[]
|
options?: string[]
|
||||||
|
|
@ -20,14 +20,14 @@ defineProps<FieldProps & {
|
||||||
</AutoFormLabel>
|
</AutoFormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<slot v-bind="slotProps">
|
<slot v-bind="slotProps">
|
||||||
<RadioGroup v-if="config?.component === 'radio'" :disabled="disabled" :orientation="'vertical'" v-bind="{ ...slotProps.componentField }">
|
<RadioGroup v-if="config?.component === 'radio'" :disabled="maybeBooleanishToBoolean(config?.inputProps?.disabled) ?? disabled" :orientation="'vertical'" v-bind="{ ...slotProps.componentField }">
|
||||||
<div v-for="(option, index) in options" :key="option" class="mb-2 flex items-center gap-3 space-y-0">
|
<div v-for="(option, index) in options" :key="option" class="mb-2 flex items-center gap-3 space-y-0">
|
||||||
<RadioGroupItem :id="`${option}-${index}`" :value="option" />
|
<RadioGroupItem :id="`${option}-${index}`" :value="option" />
|
||||||
<Label :for="`${option}-${index}`">{{ beautifyObjectName(option) }}</Label>
|
<Label :for="`${option}-${index}`">{{ beautifyObjectName(option) }}</Label>
|
||||||
</div>
|
</div>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
<Select v-else :disabled="disabled" v-bind="{ ...slotProps.componentField }">
|
<Select v-else :disabled="maybeBooleanishToBoolean(config?.inputProps?.disabled) ?? disabled" v-bind="{ ...slotProps.componentField }">
|
||||||
<SelectTrigger class="w-full">
|
<SelectTrigger class="w-full">
|
||||||
<SelectValue :placeholder="config?.inputProps?.placeholder" />
|
<SelectValue :placeholder="config?.inputProps?.placeholder" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user