mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-07 02:19:47 +08:00
49 lines
1.0 KiB
Vue
49 lines
1.0 KiB
Vue
<template>
|
|
<component
|
|
class="tmagic-design-checkbox"
|
|
:is="uiComponent.component"
|
|
v-bind="uiProps"
|
|
@update:modelValue="updateModelValue"
|
|
@change="changeHandler"
|
|
>
|
|
<template #default>
|
|
<slot></slot>
|
|
</template>
|
|
</component>
|
|
</template>
|
|
|
|
<script setup lang="ts" name="TMCheckbox">
|
|
import { computed } from 'vue';
|
|
|
|
import { getConfig } from './config';
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
modelValue?: string | number | boolean;
|
|
label?: any;
|
|
trueLabel?: string | number | boolean;
|
|
falseLabel?: string | number | boolean;
|
|
disabled?: boolean;
|
|
size?: 'large' | 'default' | 'small';
|
|
}>(),
|
|
{
|
|
trueLabel: undefined,
|
|
falseLabel: undefined,
|
|
},
|
|
);
|
|
|
|
const uiComponent = getConfig('components').checkbox;
|
|
|
|
const uiProps = computed(() => uiComponent.props(props));
|
|
|
|
const emit = defineEmits(['change', 'update:modelValue']);
|
|
|
|
const changeHandler = (v: any) => {
|
|
emit('change', v);
|
|
};
|
|
|
|
const updateModelValue = (v: any) => {
|
|
emit('update:modelValue', v);
|
|
};
|
|
</script>
|