element-plus
Version:
A Component Library for Vue 3
1 lines • 1.09 kB
Source Map (JSON)
{"version":3,"file":"check-tag2.mjs","names":[],"sources":["../../../../../../packages/components/check-tag/src/check-tag.vue"],"sourcesContent":["<template>\n <span :class=\"containerKls\" @click=\"handleChange\">\n <slot />\n </span>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed } from 'vue'\nimport { CHANGE_EVENT } from '@element-plus/constants'\nimport { useNamespace } from '@element-plus/hooks'\nimport { checkTagEmits } from './check-tag'\n\nimport type { CheckTagProps } from './check-tag'\n\ndefineOptions({\n name: 'ElCheckTag',\n})\nconst props = withDefaults(defineProps<CheckTagProps>(), {\n type: 'primary',\n})\nconst emit = defineEmits(checkTagEmits)\n\nconst ns = useNamespace('check-tag')\nconst containerKls = computed(() => [\n ns.b(),\n ns.is('checked', props.checked),\n ns.is('disabled', props.disabled),\n ns.m(props.type || 'primary'),\n])\n\nconst handleChange = () => {\n if (props.disabled) return\n\n const checked = !props.checked\n emit(CHANGE_EVENT, checked)\n emit('update:checked', checked)\n}\n</script>\n"],"mappings":""}