mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
refactor: CheckboxItem typing
This commit is contained in:
parent
0414f82d53
commit
5cd0ed23a5
2 changed files with 26 additions and 11 deletions
|
@ -1,31 +1,39 @@
|
|||
<script setup lang="ts">
|
||||
import type { CheckboxItemProps, BaseItemComputedProps } from '@/types/form'
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
modelValue: boolean
|
||||
id?: string
|
||||
label?: string
|
||||
labels?: { true: string; false: string }
|
||||
}>(),
|
||||
defineProps<CheckboxItemProps & BaseItemComputedProps<boolean>>(),
|
||||
{
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
placeholder: undefined,
|
||||
touchKey: undefined,
|
||||
label: undefined,
|
||||
labels: () => ({ true: 'yes', false: 'no' }),
|
||||
|
||||
ariaDescribedby: undefined,
|
||||
modelValue: undefined,
|
||||
state: undefined,
|
||||
validation: undefined,
|
||||
},
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
defineEmits<{
|
||||
'update:modelValue': [value: boolean]
|
||||
}>()
|
||||
|
||||
const model = defineModel<boolean>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BFormCheckbox
|
||||
:modelValue="modelValue"
|
||||
@update:modelValue="emit('update:modelValue', $event)"
|
||||
:id="id"
|
||||
:aria-describedby="$parent.id + '__BV_description_'"
|
||||
v-model="model"
|
||||
:name="name"
|
||||
:aria-describedby="ariaDescribedby"
|
||||
:state="state"
|
||||
switch
|
||||
>
|
||||
{{ label || $t(labels[modelValue]) }}
|
||||
{{ label || $t(labels[modelValue ? 'true' : 'false']) }}
|
||||
</BFormCheckbox>
|
||||
</template>
|
||||
|
|
|
@ -26,3 +26,10 @@ export type AdressModelValue = {
|
|||
separator: string
|
||||
domain: string | null
|
||||
}
|
||||
|
||||
export type CheckboxItemProps = BaseWritableItemProps & {
|
||||
label?: string
|
||||
labels?: { true: string; false: string }
|
||||
// FIXME unused?
|
||||
// choices: string[]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue