Files
libredesk/frontend/shared-ui/components/ui/auto-form/AutoFormFieldBoolean.vue
T
Abhinav Raut 5b6a58fba0 wip: intercom like live chat with chat widget
- new vue app for serving live chat widget, created subdirectories inside frontend dir `main` and `widget`
- vite changes for both main app and widget app.
- new backend live chat channel
- apis for live chat widget
2025-06-29 04:59:55 +05:30

53 lines
1.5 KiB
Vue

<script setup>
import { computed } from 'vue'
import { beautifyObjectName } from './utils'
import AutoFormLabel from './AutoFormLabel.vue'
import {
FormControl,
FormDescription,
FormField,
FormItem,
FormMessage
} from '../form'
import { Switch } from '../switch'
import { Checkbox } from '../checkbox'
const props = defineProps({
fieldName: { type: String, required: true },
label: { type: String, required: false },
required: { type: Boolean, required: false },
config: { type: Object, required: false },
disabled: { type: Boolean, required: false }
})
const booleanComponent = computed(() => (props.config?.component === 'switch' ? Switch : Checkbox))
</script>
<template>
<FormField v-slot="slotProps" :name="fieldName">
<FormItem>
<div class="space-y-0 mb-3 flex items-center gap-3">
<FormControl>
<slot v-bind="slotProps">
<component
:is="booleanComponent"
v-bind="{ ...slotProps.componentField }"
:disabled="disabled"
:checked="slotProps.componentField.modelValue"
@update:checked="slotProps.componentField['onUpdate:modelValue']"
/>
</slot>
</FormControl>
<AutoFormLabel v-if="!config?.hideLabel" :required="required">
{{ config?.label || beautifyObjectName(label ?? fieldName) }}
</AutoFormLabel>
</div>
<FormDescription v-if="config?.description">
{{ config.description }}
</FormDescription>
<FormMessage />
</FormItem>
</FormField>
</template>