UNPKG

myprint-design

Version:

操作简单,组件丰富的一站式打印解决方案打印设计器

1 lines 2.32 kB
{"version":3,"file":"my-switch.vue2.mjs","sources":["../../../../../../src/components/my/switch/my-switch.vue"],"sourcesContent":["<template>\n <div class=\"my-switch\"\n :class=\"{'is-checked': modelValueComputed}\"\n @click=\"click\">\n <div class=\"my-switch__core\">\n <div class=\"my-switch__inner\">\n <span class=\"is-text\" aria-hidden=\"false\">{{ statusText }}</span>\n </div>\n <div class=\"my-switch__action\" />\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n\nimport { computed } from 'vue-demi';\nimport { i18n } from '@myprint/design/locales';\n\nconst emit = defineEmits(['update:modelValue', 'click', 'change']);\n\nconst props = withDefaults(defineProps<{\n enable?: boolean,\n modelValue?: number,\n nullActive?: boolean,\n activeText?: string\n inactiveText?: string\n }>(),\n {\n enable: true,\n modelValue: undefined,\n nullActive: false,\n activeText: i18n('common.switch.open'),\n inactiveText: i18n('common.switch.close')\n });\n\nconst modelValueComputed = computed(() => {\n return props.modelValue == 1 || (props.modelValue == null && props.nullActive);\n});\n\nconst statusText = computed(() => {\n if (modelValueComputed.value) {\n return props.activeText;\n }\n return props.inactiveText;\n});\n\nfunction click() {\n if (!props.enable) {\n return;\n }\n emit('update:modelValue', modelValueComputed.value ? 0 : 1);\n emit('click');\n emit('change');\n}\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkBA,IAAA,MAAM,IAAO,GAAA,MAAA,CAAA;AAEb,IAAA,MAAM,KAAQ,GAAA,OAAA,CAAA;AAed,IAAM,MAAA,kBAAA,GAAqB,SAAS,MAAM;AACtC,MAAA,OAAO,MAAM,UAAc,IAAA,CAAA,IAAM,KAAM,CAAA,UAAA,IAAc,QAAQ,KAAM,CAAA,UAAA,CAAA;AAAA,KACtE,CAAA,CAAA;AAED,IAAM,MAAA,UAAA,GAAa,SAAS,MAAM;AAC9B,MAAA,IAAI,mBAAmB,KAAO,EAAA;AAC1B,QAAA,OAAO,KAAM,CAAA,UAAA,CAAA;AAAA,OACjB;AACA,MAAA,OAAO,KAAM,CAAA,YAAA,CAAA;AAAA,KAChB,CAAA,CAAA;AAED,IAAA,SAAS,KAAQ,GAAA;AACb,MAAI,IAAA,CAAC,MAAM,MAAQ,EAAA;AACf,QAAA,OAAA;AAAA,OACJ;AACA,MAAA,IAAA,CAAK,mBAAqB,EAAA,kBAAA,CAAmB,KAAQ,GAAA,CAAA,GAAI,CAAC,CAAA,CAAA;AAC1D,MAAA,IAAA,CAAK,OAAO,CAAA,CAAA;AACZ,MAAA,IAAA,CAAK,QAAQ,CAAA,CAAA;AAAA,KACjB;;;;;;;;;;;;;;;;;;;"}