You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
8.9 KiB

{"ast":null,"code":"import { defineComponent, useSlots, computed, openBlock, createBlock, resolveDynamicComponent, unref, normalizeClass, withCtx, createElementVNode, withDirectives, createElementBlock, isRef, withModifiers, vModelCheckbox, renderSlot, Fragment, createTextVNode, toDisplayString, createCommentVNode } from 'vue';\nimport '../../../hooks/index.mjs';\nimport { checkboxProps, checkboxEmits } from './checkbox.mjs';\nimport './composables/index.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useCheckbox } from './composables/use-checkbox.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nconst __default__ = defineComponent({\n name: \"ElCheckbox\"\n});\nconst _sfc_main = /* @__PURE__ */defineComponent({\n ...__default__,\n props: checkboxProps,\n emits: checkboxEmits,\n setup(__props) {\n const props = __props;\n const slots = useSlots();\n const {\n inputId,\n isLabeledByFormItem,\n isChecked,\n isDisabled,\n isFocused,\n checkboxSize,\n hasOwnLabel,\n model,\n actualValue,\n handleChange,\n onClickRoot\n } = useCheckbox(props, slots);\n const ns = useNamespace(\"checkbox\");\n const compKls = computed(() => {\n return [ns.b(), ns.m(checkboxSize.value), ns.is(\"disabled\", isDisabled.value), ns.is(\"bordered\", props.border), ns.is(\"checked\", isChecked.value)];\n });\n const spanKls = computed(() => {\n return [ns.e(\"input\"), ns.is(\"disabled\", isDisabled.value), ns.is(\"checked\", isChecked.value), ns.is(\"indeterminate\", props.indeterminate), ns.is(\"focus\", isFocused.value)];\n });\n return (_ctx, _cache) => {\n return openBlock(), createBlock(resolveDynamicComponent(!unref(hasOwnLabel) && unref(isLabeledByFormItem) ? \"span\" : \"label\"), {\n class: normalizeClass(unref(compKls)),\n \"aria-controls\": _ctx.indeterminate ? _ctx.ariaControls : null,\n onClick: unref(onClickRoot)\n }, {\n default: withCtx(() => {\n var _a, _b, _c, _d;\n return [createElementVNode(\"span\", {\n class: normalizeClass(unref(spanKls))\n }, [_ctx.trueValue || _ctx.falseValue || _ctx.trueLabel || _ctx.falseLabel ? withDirectives((openBlock(), createElementBlock(\"input\", {\n key: 0,\n id: unref(inputId),\n \"onUpdate:modelValue\": $event => isRef(model) ? model.value = $event : null,\n class: normalizeClass(unref(ns).e(\"original\")),\n type: \"checkbox\",\n indeterminate: _ctx.indeterminate,\n name: _ctx.name,\n tabindex: _ctx.tabindex,\n disabled: unref(isDisabled),\n \"true-value\": (_b = (_a = _ctx.trueValue) != null ? _a : _ctx.trueLabel) != null ? _b : true,\n \"false-value\": (_d = (_c = _ctx.falseValue) != null ? _c : _ctx.falseLabel) != null ? _d : false,\n onChange: unref(handleChange),\n onFocus: $event => isFocused.value = true,\n onBlur: $event => isFocused.value = false,\n onClick: withModifiers(() => {}, [\"stop\"])\n }, null, 42, [\"id\", \"onUpdate:modelValue\", \"indeterminate\", \"name\", \"tabindex\", \"disabled\", \"true-value\", \"false-value\", \"onChange\", \"onFocus\", \"onBlur\", \"onClick\"])), [[vModelCheckbox, unref(model)]]) : withDirectives((openBlock(), createElementBlock(\"input\", {\n key: 1,\n id: unref(inputId),\n \"onUpdate:modelValue\": $event => isRef(model) ? model.value = $event : null,\n class: normalizeClass(unref(ns).e(\"original\")),\n type: \"checkbox\",\n indeterminate: _ctx.indeterminate,\n disabled: unref(isDisabled),\n value: unref(actualValue),\n name: _ctx.name,\n tabindex: _ctx.tabindex,\n onChange: unref(handleChange),\n onFocus: $event => isFocused.value = true,\n onBlur: $event => isFocused.value = false,\n onClick: withModifiers(() => {}, [\"stop\"])\n }, null, 42, [\"id\", \"onUpdate:modelValue\", \"indeterminate\", \"disabled\", \"value\", \"name\", \"tabindex\", \"onChange\", \"onFocus\", \"onBlur\", \"onClick\"])), [[vModelCheckbox, unref(model)]]), createElementVNode(\"span\", {\n class: normalizeClass(unref(ns).e(\"inner\"))\n }, null, 2)], 2), unref(hasOwnLabel) ? (openBlock(), createElementBlock(\"span\", {\n key: 0,\n class: normalizeClass(unref(ns).e(\"label\"))\n }, [renderSlot(_ctx.$slots, \"default\"), !_ctx.$slots.default ? (openBlock(), createElementBlock(Fragment, {\n key: 0\n }, [createTextVNode(toDisplayString(_ctx.label), 1)], 64)) : createCommentVNode(\"v-if\", true)], 2)) : createCommentVNode(\"v-if\", true)];\n }),\n _: 3\n }, 8, [\"class\", \"aria-controls\", \"onClick\"]);\n };\n }\n});\nvar Checkbox = /* @__PURE__ */_export_sfc(_sfc_main, [[\"__file\", \"checkbox.vue\"]]);\nexport { Checkbox as default };","map":{"version":3,"names":["name","slots","useSlots","inputId","isLabeledByFormItem","isChecked","isDisabled","isFocused","checkboxSize","hasOwnLabel","model","actualValue","handleChange","onClickRoot","useCheckbox","props","ns","useNamespace","compKls","computed","b","m","value","is","border","spanKls","e","indeterminate"],"sources":["../../../../../../packages/components/checkbox/src/checkbox.vue"],"sourcesContent":["<template>\n <component\n :is=\"!hasOwnLabel && isLabeledByFormItem ? 'span' : 'label'\"\n :class=\"compKls\"\n :aria-controls=\"indeterminate ? ariaControls : null\"\n @click=\"onClickRoot\"\n >\n <span :class=\"spanKls\">\n <input\n v-if=\"trueValue || falseValue || trueLabel || falseLabel\"\n :id=\"inputId\"\n v-model=\"model\"\n :class=\"ns.e('original')\"\n type=\"checkbox\"\n :indeterminate=\"indeterminate\"\n :name=\"name\"\n :tabindex=\"tabindex\"\n :disabled=\"isDisabled\"\n :true-value=\"trueValue ?? trueLabel ?? true\"\n :false-value=\"falseValue ?? falseLabel ?? false\"\n @change=\"handleChange\"\n @focus=\"isFocused = true\"\n @blur=\"isFocused = false\"\n @click.stop\n />\n <input\n v-else\n :id=\"inputId\"\n v-model=\"model\"\n :class=\"ns.e('original')\"\n type=\"checkbox\"\n :indeterminate=\"indeterminate\"\n :disabled=\"isDisabled\"\n :value=\"actualValue\"\n :name=\"name\"\n :tabindex=\"tabindex\"\n @change=\"handleChange\"\n @focus=\"isFocused = true\"\n @blur=\"isFocused = false\"\n @click.stop\n />\n <span :class=\"ns.e('inner')\" />\n </span>\n <span v-if=\"hasOwnLabel\" :class=\"ns.e('label')\">\n <slot />\n <template v-if=\"!$slots.default\">{{ label }}</template>\n </span>\n </component>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, useSlots } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { checkboxEmits, checkboxProps } from './checkbox'\nimport { useCheckbox } from './composables'\n\ndefineOptions({\n name: 'ElCheckbox',\n})\n\nconst props = defineProps(checkboxProps)\ndefineEmits(checkboxEmits)\nconst slots = useSlots()\n\nconst {\n inputId,\n isLabeledByFormItem,\n isChecked,\n isDisabled,\n isFocused,\n checkboxSize,\n hasOwnLabel,\n model,\n actualValue,\n handleChange,\n onClickRoot,\n} = useCheckbox(props, slots)\n\nconst ns = useNamespace('checkbox')\n\nconst compKls = computed(() => {\n return [\n ns.b(),\n ns.m(checkboxSize.value),\n ns.is('disabled', isDisabled.value),\n ns.is('bordered', props.border),\n ns.is('checked', isChecked.value),\n ]\n})\n\nconst spanKls = computed(() => {\n return [\n ns.e('input'),\n ns.is('disabled', isDisabled.value),\n ns.is('checked', isChecked.value),\n ns.is('indeterminate', props.indeterminate),\n ns.is('focus', isFocused.value),\n ]\n})\n</script>\n"],"mappings":";;;;;;;mCAwDc;EACZA,IAAM;AACR;;;;;;;IAIA,MAAMC,KAAA,GAAQC,QAAS;IAEjB;MACJC,OAAA;MACAC,mBAAA;MACAC,SAAA;MACAC,UAAA;MACAC,SAAA;MACAC,YAAA;MACAC,WAAA;MACAC,KAAA;MACAC,WAAA;MACAC,YAAA;MACAC;IAAA,CACF,GAAIC,WAAY,CAAAC,KAAA,EAAOd,KAAK;IAEtB,MAAAe,EAAA,GAAKC,YAAA,CAAa,UAAU;IAE5B,MAAAC,OAAA,GAAUC,QAAA,CAAS,MAAM;MACtB,QACLH,EAAA,CAAGI,CAAE,IACLJ,EAAA,CAAGK,CAAE,CAAAb,YAAA,CAAac,KAAK,GACvBN,EAAG,CAAAO,EAAA,CAAG,UAAY,EAAAjB,UAAA,CAAWgB,KAAK,GAClCN,EAAG,CAAAO,EAAA,CAAG,UAAY,EAAAR,KAAA,CAAMS,MAAM,GAC9BR,EAAG,CAAAO,EAAA,CAAG,SAAW,EAAAlB,SAAA,CAAUiB,KAAK,EAClC;IAAA,CACD;IAEK,MAAAG,OAAA,GAAUN,QAAA,CAAS,MAAM;MACtB,QACLH,EAAA,CAAGU,CAAA,CAAE,OAAO,GACZV,EAAG,CAAAO,EAAA,CAAG,UAAY,EAAAjB,UAAA,CAAWgB,KAAK,GAClCN,EAAG,CAAAO,EAAA,CAAG,SAAW,EAAAlB,SAAA,CAAUiB,KAAK,GAChCN,EAAG,CAAAO,EAAA,CAAG,eAAiB,EAAAR,KAAA,CAAMY,aAAa,GAC1CX,EAAG,CAAAO,EAAA,CAAG,OAAS,EAAAhB,SAAA,CAAUe,KAAK,EAChC;IAAA,CACD","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}