Files
chatwoot/app/javascript/v3/components/Form/Input.vue
Shivam Mishra 2e108653ae feat: allow SP initiated SAML (#12447)
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2025-09-23 18:29:16 +05:30

73 lines
1.7 KiB
Vue

<script setup>
import { defineProps, defineModel } from 'vue';
import WithLabel from './WithLabel.vue';
defineProps({
label: {
type: String,
required: true,
},
type: {
type: String,
default: 'text',
},
icon: {
type: String,
default: '',
},
name: {
type: String,
required: true,
},
hasError: Boolean,
errorMessage: {
type: String,
default: '',
},
spacing: {
type: String,
default: 'base',
validator: value => ['base', 'compact'].includes(value),
},
});
defineOptions({
inheritAttrs: false,
});
const model = defineModel({
type: [String, Number],
required: true,
});
</script>
<template>
<WithLabel
:label="label"
:icon="icon"
:name="name"
:has-error="hasError"
:error-message="errorMessage"
>
<template #rightOfLabel>
<slot />
</template>
<input
v-bind="$attrs"
v-model="model"
:name="name"
:type="type"
class="block w-full border-none rounded-md shadow-sm bg-n-alpha-black2 appearance-none outline outline-1 focus:outline focus:outline-1 text-n-slate-12 placeholder:text-n-slate-10 sm:text-sm sm:leading-6 px-3 py-3"
:class="{
'error outline-n-ruby-8 dark:outline-n-ruby-8 hover:outline-n-ruby-9 dark:hover:outline-n-ruby-9 disabled:outline-n-ruby-8 dark:disabled:outline-n-ruby-8':
hasError,
'outline-n-weak dark:outline-n-weak hover:outline-n-slate-6 dark:hover:outline-n-slate-6 focus:outline-n-brand dark:focus:outline-n-brand':
!hasError,
'px-3 py-3': spacing === 'base',
'px-3 py-2 mb-0': spacing === 'compact',
'pl-9': icon,
}"
/>
</WithLabel>
</template>