<template>
  <div class="common-switch switch-wrapper">
    <el-switch
      :model-value="flag"
      size="default"
      style="--el-switch-on-color: #ac014d; --el-switch-off-color: #b1b1b1"
      @change="updateFlag"
    />
    <span class="switch-label">{{ label }}</span>
  </div>
</template>

<script setup lang="ts">
import { ElSwitch } from 'element-plus'
const props = defineProps({
  flag: {
    type: Boolean,
    required: true
  },
  label: {
    type: String
  }
})

const emit = defineEmits(['update:flag'])

const updateFlag = (val: boolean | number | string) => {
  emit('update:flag', val)
}
</script>

<style scoped lang="scss">
.switch-wrapper {
  height: 32px;
  .switch-label {
    padding-left: 4px;
    line-height: 32px;
  }
}
</style>
