This commit is contained in:
Никита Круглицкий
2024-11-26 18:01:19 +03:00
parent e87c62aaeb
commit 75cdae594a
17 changed files with 29 additions and 424 deletions

View File

@@ -1,44 +0,0 @@
import { useField } from 'vee-validate'
import { computed, ref, toRef } from 'vue'
import type { ComponentInternalInstance } from 'vue'
interface Props {
id: string
label?: string
disabled?: boolean
modelValue?: boolean | string | number
trueValue?: boolean | string | number
falseValue?: boolean | string | number
required?: boolean
}
export default (props: Props, slots: ComponentInternalInstance['slots']) => {
const { checked, errorMessage, handleChange } = useField(
toRef(props, 'id'),
computed(() => ({
required: props.required,
})),
{
type: 'checkbox',
initialValue: props.modelValue,
checkedValue: props.trueValue ?? true,
uncheckedValue: props.falseValue ?? false,
syncVModel: true,
},
)
const focused = ref(false)
const active = computed(() => !props.disabled)
const invalid = computed(() => active.value && !!errorMessage.value)
const hasLabel = computed(() => !!props.label || slots.default)
return {
focused,
checked,
active,
invalid,
hasLabel,
handleChange,
}
}

View File

@@ -1,3 +0,0 @@
import notify from '../components/ui/notification/notify'
export default () => notify

View File

@@ -1,40 +0,0 @@
import { useField } from 'vee-validate'
import { computed, ref, toRef } from 'vue'
import type { ComponentInternalInstance } from 'vue'
interface Props {
id: string
value: string | number
label?: string
disabled?: boolean
modelValue?: string | number
required?: boolean
}
export default (props: Props, slots: ComponentInternalInstance['slots']) => {
const { checked, handleChange } = useField(
toRef(props, 'id'),
computed(() => ({
required: props.required,
})),
{
type: 'radio',
initialValue: props.modelValue,
checkedValue: props.value,
syncVModel: true,
},
)
const focused = ref(false)
const active = computed(() => !props.disabled)
const hasLabel = computed(() => !!props.label || slots.default)
return {
focused,
active,
checked,
hasLabel,
handleChange,
}
}