feat(frontend): add disabled prop to FormField component

When disabled is true, the component now automatically adds the
'disabled' CSS class and sets the native disabled attribute on the
input element.
This commit is contained in:
kolaente
2026-01-10 21:05:57 +01:00
parent e0235a6806
commit 3577ba5132

View File

@@ -6,6 +6,7 @@ interface Props {
label?: string
error?: string | null
id?: string
disabled?: boolean
}
const props = defineProps<Props>()
@@ -33,6 +34,11 @@ const controlClasses = computed(() => [
{'is-expanded': hasAddon.value},
])
const inputClasses = computed(() => [
'input',
{'disabled': props.disabled},
])
// Only bind value when modelValue is explicitly provided (not undefined)
// This allows the component to be used without v-model for native input behavior
const inputBindings = computed(() => {
@@ -68,7 +74,8 @@ defineExpose({
:id="inputId"
ref="inputRef"
v-bind="{ ...$attrs, ...inputBindings }"
class="input"
:class="inputClasses"
:disabled="disabled || undefined"
@input="$emit('update:modelValue', ($event.target as HTMLInputElement).value)"
>
</slot>