<commit_before><template lang="html">
  <span :class="wrapClasses" @click="_toggle">
    <span :class="prefix + '-inner'">
      <slot v-if="checkStatus" name="checkedChildren"></slot>
      <slot v-if="!checkStatus" name="unCheckedChildren"></slot>
    </span>
  </span>
</template>

<script lang="babel">
import emitter from '../../mixins/emitter';
export default {
    name: 'Switch',
    mixins: [emitter],
    data() {
        return {
            prefix: 'ant-switch',
            defaultValue: this.value
        }
    },
    props:{
        size: {
            type: String
        },
        value: {
            default: false
        },
        disabled: {
            type: Boolean,
            default: false
        },
        trueValue:{
            default : true
        },
        falseValue:{
            default : false
        }
    },
    computed: {
        wrapClasses () {
            let size = ['small'].indexOf(this.size) !== -1?this.size:'';

            return [
                this.prefix,
                {[`${this.prefix}-checked`]: this.checkStatus},
                {[`${this.prefix}-disabled`]: this.disabled},
                {[`${this.prefix}-${size}`]: size}
            ]
        },
        checkStatus(){
            return this.defaultValue === this.trueValue;
        },
    },
    watch: {
        value(val) {
            this.defaultValue = val;
        }
    },
    methods: {
        _toggle () {
            if (this.disabled) return;
            this.defaultValue = this.checkStatus ? this.falseValue : this.trueValue;
            this.$emit('input', this.defaultValue);
            this.dispatch('FormItem', 'form.change', [this.defaultValue]);
        }
    }
}

</script><commit_msg>Switch 添加自定义状态码<commit_after><template lang="html">
  <span :class="wrapClasses" @click="_toggle">
    <span :class="prefix + '-inner'">
      <slot v-if="checkStatus" name="checkedChildren"></slot>
      <slot v-if="!checkStatus" name="unCheckedChildren"></slot>
    </span>
  </span>
</template>

<script lang="babel">
import emitter from '../../mixins/emitter';
export default {
    name: 'Switch',
    mixins: [emitter],
    data() {
        return {
            prefix: 'ant-switch',
            defaultValue: this.value
        }
    },
    props:{
        size: {
            type: String
        },
        value: {
            default: false
        },
        disabled: {
            type: Boolean,
            default: false
        },
        trueValue:{
            default : true
        },
        falseValue:{
            default : false
        }
    },
    computed: {
        wrapClasses () {
            let size = ['small'].indexOf(this.size) !== -1?this.size:'';

            return [
                this.prefix,
                {[`${this.prefix}-checked`]: this.checkStatus},
                {[`${this.prefix}-disabled`]: this.disabled},
                {[`${this.prefix}-${size}`]: size}
            ]
        },
        checkStatus(){
            return this.defaultValue === this.trueValue;
        }
    },
    watch: {
        value(val) {
            this.defaultValue = val;
        }
    },
    methods: {
        _toggle () {
            if (this.disabled) return;
            this.defaultValue = this.checkStatus ? this.falseValue : this.trueValue;
            this.$emit('input', this.defaultValue);
            this.dispatch('FormItem', 'form.change', [this.defaultValue]);
        }
    }
}

</script>
{'fraction_non_alphanumeric': 0.15683453237410072, 'fraction_numerical': 0.0005755395683453237, 'mean_word_length': 1.5596465390279823, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3287741', 'n_tokens_mistral': 989, 'n_tokens_neox': 971, 'n_words': 180}