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">
|
<script setup lang="ts">
|
||||||
|
import type { CheckboxItemProps, BaseItemComputedProps } from '@/types/form'
|
||||||
|
|
||||||
withDefaults(
|
withDefaults(
|
||||||
defineProps<{
|
defineProps<CheckboxItemProps & BaseItemComputedProps<boolean>>(),
|
||||||
modelValue: boolean
|
|
||||||
id?: string
|
|
||||||
label?: string
|
|
||||||
labels?: { true: string; false: string }
|
|
||||||
}>(),
|
|
||||||
{
|
{
|
||||||
id: undefined,
|
id: undefined,
|
||||||
|
name: undefined,
|
||||||
|
placeholder: undefined,
|
||||||
|
touchKey: undefined,
|
||||||
label: undefined,
|
label: undefined,
|
||||||
labels: () => ({ true: 'yes', false: 'no' }),
|
labels: () => ({ true: 'yes', false: 'no' }),
|
||||||
|
|
||||||
|
ariaDescribedby: undefined,
|
||||||
|
modelValue: undefined,
|
||||||
|
state: undefined,
|
||||||
|
validation: undefined,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const emit = defineEmits<{
|
defineEmits<{
|
||||||
'update:modelValue': [value: boolean]
|
'update:modelValue': [value: boolean]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const model = defineModel<boolean>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<BFormCheckbox
|
<BFormCheckbox
|
||||||
:modelValue="modelValue"
|
|
||||||
@update:modelValue="emit('update:modelValue', $event)"
|
|
||||||
:id="id"
|
:id="id"
|
||||||
:aria-describedby="$parent.id + '__BV_description_'"
|
v-model="model"
|
||||||
|
:name="name"
|
||||||
|
:aria-describedby="ariaDescribedby"
|
||||||
|
:state="state"
|
||||||
switch
|
switch
|
||||||
>
|
>
|
||||||
{{ label || $t(labels[modelValue]) }}
|
{{ label || $t(labels[modelValue ? 'true' : 'false']) }}
|
||||||
</BFormCheckbox>
|
</BFormCheckbox>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -26,3 +26,10 @@ export type AdressModelValue = {
|
||||||
separator: string
|
separator: string
|
||||||
domain: string | null
|
domain: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CheckboxItemProps = BaseWritableItemProps & {
|
||||||
|
label?: string
|
||||||
|
labels?: { true: string; false: string }
|
||||||
|
// FIXME unused?
|
||||||
|
// choices: string[]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue