field checkbox

This commit is contained in:
AntoXa PRO 2023-07-13 14:31:02 +03:00
parent 1b283b0d56
commit 288c5cbb7e
3 changed files with 13 additions and 10 deletions

View File

@ -1,7 +1,7 @@
{
"name": "axp-ui",
"descriiption": "My helper ui lib",
"version": "1.5.17",
"version": "1.5.18",
"homepage": "https://antoxahub.ru/antoxa/axp-ui",
"repository": {
"type": "git",

View File

@ -6,6 +6,7 @@ const props = defineProps<{
error?: string
readonly?: boolean
disabled?: boolean
checked?: boolean
tag?: 'input' | 'textarea' | 'select'
}>()
@ -58,6 +59,7 @@ const inputHandler = (val: any) => {
:value="props.modelValue"
:reatonly="props.readonly"
:disabled="props.disabled"
:checked="checked"
@input="inputHandler"
class="input"
/>

View File

@ -11,16 +11,17 @@ const props = defineProps<{
const emit = defineEmits<{ (e: 'update:modelValue', v?: boolean): void }>()
// Value.
const valueStr = computed({
get: () => {
if (props.modelValue) return 'on'
},
set: val => {
if (val !== undefined) emit('update:modelValue', !props.modelValue)
}
})
const value = computed(() => props.modelValue)
// Handlers.
const updateHandler = () => emit('update:modelValue', !props.modelValue)
</script>
<template>
<ui-field type="checkbox" class="ui-field-checkbox" v-model="valueStr" />
<ui-field
type="checkbox"
class="ui-field-checkbox"
:checked="value"
@input="updateHandler"
/>
</template>