1 line
9.3 KiB
Plaintext
1 line
9.3 KiB
Plaintext
{"version":3,"file":"wd-checkbox.js","sources":["../../../../../../../node_modules/wot-design-uni/components/wd-checkbox/wd-checkbox.vue","../../../../../../../uniComponent:/RDovQXBwL1dvcmsvYWRkci9hY2RyLXVpL25vZGVfbW9kdWxlcy93b3QtZGVzaWduLXVuaS9jb21wb25lbnRzL3dkLWNoZWNrYm94L3dkLWNoZWNrYm94LnZ1ZQ"],"sourcesContent":["<template>\n <view\n :class=\"`wd-checkbox ${innerCell ? 'is-cell-box' : ''} ${innerShape === 'button' ? 'is-button-box' : ''} ${isChecked ? 'is-checked' : ''} ${\n isFirst ? 'is-first-child' : ''\n } ${isLast ? 'is-last-child' : ''} ${innerInline ? 'is-inline' : ''} ${innerShape === 'button' ? 'is-button' : ''} ${\n innerDisabled ? 'is-disabled' : ''\n } ${innerSize ? 'is-' + innerSize : ''} ${customClass}`\"\n :style=\"customStyle\"\n @click=\"toggle\"\n >\n <!--shape为button时,移除wd-checkbox__shape,只保留wd-checkbox__label-->\n <view\n v-if=\"innerShape !== 'button'\"\n :class=\"`wd-checkbox__shape ${innerShape === 'square' ? 'is-square' : ''} ${customShapeClass}`\"\n :style=\"isChecked && !innerDisabled && innerCheckedColor ? 'color :' + innerCheckedColor : ''\"\n >\n <wd-icon custom-class=\"wd-checkbox__check\" name=\"check-bold\" size=\"14px\" />\n </view>\n <!--shape为button时只保留wd-checkbox__label-->\n <view\n :class=\"`wd-checkbox__label ${customLabelClass}`\"\n :style=\"isChecked && innerShape === 'button' && !innerDisabled && innerCheckedColor ? 'color:' + innerCheckedColor : ''\"\n >\n <!--button选中时展示的icon-->\n <wd-icon v-if=\"innerShape === 'button' && isChecked\" custom-class=\"wd-checkbox__btn-check\" name=\"check-bold\" size=\"14px\" />\n <!--文案-->\n <view class=\"wd-checkbox__txt\" :style=\"maxWidth ? 'max-width:' + maxWidth : ''\">\n <slot></slot>\n </view>\n </view>\n </view>\n</template>\n\n<script lang=\"ts\">\nexport default {\n name: 'wd-checkbox',\n options: {\n addGlobalClass: true,\n virtualHost: true,\n styleIsolation: 'shared'\n }\n}\n</script>\n\n<script lang=\"ts\" setup>\nimport { computed, getCurrentInstance, onBeforeMount, watch } from 'vue'\nimport { useParent } from '../composables/useParent'\nimport { CHECKBOX_GROUP_KEY } from '../wd-checkbox-group/types'\nimport { isDef } from '../common/util'\nimport { checkboxProps, type CheckboxExpose } from './types'\n\nconst props = defineProps(checkboxProps)\nconst emit = defineEmits(['change', 'update:modelValue'])\n\ndefineExpose<CheckboxExpose>({\n toggle\n})\n\nconst { parent: checkboxGroup, index } = useParent(CHECKBOX_GROUP_KEY)\n\nconst isChecked = computed(() => {\n if (checkboxGroup) {\n return checkboxGroup.props.modelValue.indexOf(props.modelValue) > -1\n } else {\n return props.modelValue === props.trueValue\n }\n}) // 是否被选中\n\nconst isFirst = computed(() => {\n return index.value === 0\n})\n\nconst isLast = computed(() => {\n const children = isDef(checkboxGroup) ? checkboxGroup.children : []\n return index.value === children.length - 1\n})\nconst { proxy } = getCurrentInstance() as any\n\nwatch(\n () => props.modelValue,\n () => {\n // 组合使用走这个逻辑\n if (checkboxGroup) {\n checkName()\n }\n }\n)\n\nwatch(\n () => props.shape,\n (newValue) => {\n const type = ['circle', 'square', 'button']\n if (type.indexOf(newValue) === -1) console.error(`shape must be one of ${type.toString()}`)\n }\n)\n\nconst innerShape = computed(() => {\n if (!props.shape && checkboxGroup && checkboxGroup.props.shape) {\n return checkboxGroup.props.shape\n } else {\n return props.shape\n }\n})\n\nconst innerCheckedColor = computed(() => {\n if (!props.checkedColor && checkboxGroup && checkboxGroup.props.checkedColor) {\n return checkboxGroup.props.checkedColor\n } else {\n return props.checkedColor\n }\n})\n\nconst innerDisabled = computed(() => {\n let innerDisabled = props.disabled\n if (checkboxGroup) {\n if (\n // max 生效时,group 已经选满,禁止其它节点再选中。\n (checkboxGroup.props.max && checkboxGroup.props.modelValue.length >= checkboxGroup.props.max && !isChecked.value) ||\n // min 生效时,group 选中的节点数量仅满足最小值,禁止取消已选中的节点。\n (checkboxGroup.props.min && checkboxGroup.props.modelValue.length <= checkboxGroup.props.min && isChecked.value) ||\n // 只要子节点自己要求 disabled,那就 disabled。\n props.disabled === true ||\n // 父节点要求全局 disabled,子节点没吱声,那就 disabled。\n (checkboxGroup.props.disabled && props.disabled === null)\n ) {\n innerDisabled = true\n }\n }\n return innerDisabled\n})\n\nconst innerInline = computed(() => {\n if (checkboxGroup && checkboxGroup.props.inline) {\n return checkboxGroup.props.inline\n } else {\n return false\n }\n})\n\nconst innerCell = computed(() => {\n if (checkboxGroup && checkboxGroup.props.cell) {\n return checkboxGroup.props.cell\n } else {\n return false\n }\n})\n\nconst innerSize = computed(() => {\n if (!props.size && checkboxGroup && checkboxGroup.props.size) {\n return checkboxGroup.props.size\n } else {\n return props.size\n }\n})\n\nonBeforeMount(() => {\n // eslint-disable-next-line quotes\n if (props.modelValue === null) console.error(\"checkbox's value must be set\")\n})\n\n/**\n * @description 检测checkbox绑定的value是否和其它checkbox的value冲突\n * @param {Object} self 自身\n * @param myName 自己的标识符\n */\nfunction checkName() {\n checkboxGroup &&\n checkboxGroup.children &&\n checkboxGroup.children.forEach((child: any) => {\n if (child.$.uid !== proxy.$.uid && child.modelValue === props.modelValue) {\n console.error(`The checkbox's bound value: ${props.modelValue} has been used`)\n }\n })\n}\n/**\n * @description 点击checkbox的Event handle\n */\nfunction toggle() {\n if (innerDisabled.value) return\n // 复选框单独使用时点击反选,并且在checkbox上触发change事件\n if (checkboxGroup) {\n emit('change', {\n value: !isChecked.value\n })\n checkboxGroup.changeSelectState(props.modelValue)\n } else {\n const newVal = props.modelValue === props.trueValue ? props.falseValue : props.trueValue\n emit('update:modelValue', newVal)\n emit('change', {\n value: newVal\n })\n }\n}\n</script>\n\n<style lang=\"scss\" scoped>\n@import './index.scss';\n</style>\n","import Component from 'D:/App/Work/addr/acdr-ui/node_modules/wot-design-uni/components/wd-checkbox/wd-checkbox.vue'\nwx.createCompon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