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", "name": "axp-ui",
"descriiption": "My helper ui lib", "descriiption": "My helper ui lib",
"version": "1.5.17", "version": "1.5.18",
"homepage": "https://antoxahub.ru/antoxa/axp-ui", "homepage": "https://antoxahub.ru/antoxa/axp-ui",
"repository": { "repository": {
"type": "git", "type": "git",

View File

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

View File

@ -11,16 +11,17 @@ const props = defineProps<{
const emit = defineEmits<{ (e: 'update:modelValue', v?: boolean): void }>() const emit = defineEmits<{ (e: 'update:modelValue', v?: boolean): void }>()
// Value. // Value.
const valueStr = computed({ const value = computed(() => props.modelValue)
get: () => {
if (props.modelValue) return 'on' // Handlers.
}, const updateHandler = () => emit('update:modelValue', !props.modelValue)
set: val => {
if (val !== undefined) emit('update:modelValue', !props.modelValue)
}
})
</script> </script>
<template> <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> </template>