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 lines
8.3 KiB
1 lines
8.3 KiB
{"ast":null,"code":"import { defineComponent, useSlots, inject, computed, openBlock, createElementBlock, normalizeClass, unref, withDirectives, isRef, withModifiers, vModelCheckbox, normalizeStyle, renderSlot, createTextVNode, toDisplayString, createCommentVNode } from 'vue';\nimport { checkboxGroupContextKey } from './constants.mjs';\nimport { checkboxProps, checkboxEmits } from './checkbox.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: \"ElCheckboxButton\"\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 isFocused,\n isChecked,\n isDisabled,\n checkboxButtonSize,\n model,\n actualValue,\n handleChange\n } = useCheckbox(props, slots);\n const checkboxGroup = inject(checkboxGroupContextKey, void 0);\n const ns = useNamespace(\"checkbox\");\n const activeStyle = computed(() => {\n var _a, _b, _c, _d;\n const fillValue = (_b = (_a = checkboxGroup == null ? void 0 : checkboxGroup.fill) == null ? void 0 : _a.value) != null ? _b : \"\";\n return {\n backgroundColor: fillValue,\n borderColor: fillValue,\n color: (_d = (_c = checkboxGroup == null ? void 0 : checkboxGroup.textColor) == null ? void 0 : _c.value) != null ? _d : \"\",\n boxShadow: fillValue ? `-1px 0 0 0 ${fillValue}` : void 0\n };\n });\n const labelKls = computed(() => {\n return [ns.b(\"button\"), ns.bm(\"button\", checkboxButtonSize.value), ns.is(\"disabled\", isDisabled.value), ns.is(\"checked\", isChecked.value), ns.is(\"focus\", isFocused.value)];\n });\n return (_ctx, _cache) => {\n var _a, _b, _c, _d;\n return openBlock(), createElementBlock(\"label\", {\n class: normalizeClass(unref(labelKls))\n }, [_ctx.trueValue || _ctx.falseValue || _ctx.trueLabel || _ctx.falseLabel ? withDirectives((openBlock(), createElementBlock(\"input\", {\n key: 0,\n \"onUpdate:modelValue\": $event => isRef(model) ? model.value = $event : null,\n class: normalizeClass(unref(ns).be(\"button\", \"original\")),\n type: \"checkbox\",\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, [\"onUpdate:modelValue\", \"name\", \"tabindex\", \"disabled\", \"true-value\", \"false-value\", \"onChange\", \"onFocus\", \"onBlur\", \"onClick\"])), [[vModelCheckbox, unref(model)]]) : withDirectives((openBlock(), createElementBlock(\"input\", {\n key: 1,\n \"onUpdate:modelValue\": $event => isRef(model) ? model.value = $event : null,\n class: normalizeClass(unref(ns).be(\"button\", \"original\")),\n type: \"checkbox\",\n name: _ctx.name,\n tabindex: _ctx.tabindex,\n disabled: unref(isDisabled),\n value: unref(actualValue),\n onChange: unref(handleChange),\n onFocus: $event => isFocused.value = true,\n onBlur: $event => isFocused.value = false,\n onClick: withModifiers(() => {}, [\"stop\"])\n }, null, 42, [\"onUpdate:modelValue\", \"name\", \"tabindex\", \"disabled\", \"value\", \"onChange\", \"onFocus\", \"onBlur\", \"onClick\"])), [[vModelCheckbox, unref(model)]]), _ctx.$slots.default || _ctx.label ? (openBlock(), createElementBlock(\"span\", {\n key: 2,\n class: normalizeClass(unref(ns).be(\"button\", \"inner\")),\n style: normalizeStyle(unref(isChecked) ? unref(activeStyle) : void 0)\n }, [renderSlot(_ctx.$slots, \"default\", {}, () => [createTextVNode(toDisplayString(_ctx.label), 1)])], 6)) : createCommentVNode(\"v-if\", true)], 2);\n };\n }\n});\nvar CheckboxButton = /* @__PURE__ */_export_sfc(_sfc_main, [[\"__file\", \"checkbox-button.vue\"]]);\nexport { CheckboxButton as default };","map":{"version":3,"names":["name","slots","useSlots","isFocused","isChecked","isDisabled","checkboxButtonSize","model","actualValue","handleChange","useCheckbox","props","checkboxGroup","inject","checkboxGroupContextKey","ns","useNamespace","activeStyle","computed","_a","_b","_c","_d","fillValue","fill","value","backgroundColor","borderColor","color","textColor","boxShadow","labelKls","b","bm","is"],"sources":["../../../../../../packages/components/checkbox/src/checkbox-button.vue"],"sourcesContent":["<template>\n <label :class=\"labelKls\">\n <input\n v-if=\"trueValue || falseValue || trueLabel || falseLabel\"\n v-model=\"model\"\n :class=\"ns.be('button', 'original')\"\n type=\"checkbox\"\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 v-model=\"model\"\n :class=\"ns.be('button', 'original')\"\n type=\"checkbox\"\n :name=\"name\"\n :tabindex=\"tabindex\"\n :disabled=\"isDisabled\"\n :value=\"actualValue\"\n @change=\"handleChange\"\n @focus=\"isFocused = true\"\n @blur=\"isFocused = false\"\n @click.stop\n />\n\n <span\n v-if=\"$slots.default || label\"\n :class=\"ns.be('button', 'inner')\"\n :style=\"isChecked ? activeStyle : undefined\"\n >\n <slot>{{ label }}</slot>\n </span>\n </label>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, inject, useSlots } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { checkboxGroupContextKey } from './constants'\nimport { useCheckbox } from './composables'\nimport { checkboxEmits, checkboxProps } from './checkbox'\n\nimport type { CSSProperties } from 'vue'\n\ndefineOptions({\n name: 'ElCheckboxButton',\n})\n\nconst props = defineProps(checkboxProps)\ndefineEmits(checkboxEmits)\nconst slots = useSlots()\n\nconst {\n isFocused,\n isChecked,\n isDisabled,\n checkboxButtonSize,\n model,\n actualValue,\n handleChange,\n} = useCheckbox(props, slots)\nconst checkboxGroup = inject(checkboxGroupContextKey, undefined)\nconst ns = useNamespace('checkbox')\n\nconst activeStyle = computed<CSSProperties>(() => {\n const fillValue = checkboxGroup?.fill?.value ?? ''\n return {\n backgroundColor: fillValue,\n borderColor: fillValue,\n color: checkboxGroup?.textColor?.value ?? '',\n boxShadow: fillValue ? `-1px 0 0 0 ${fillValue}` : undefined,\n }\n})\n\nconst labelKls = computed(() => {\n return [\n ns.b('button'),\n ns.bm('button', checkboxButtonSize.value),\n ns.is('disabled', isDisabled.value),\n ns.is('checked', isChecked.value),\n ns.is('focus', isFocused.value),\n ]\n})\n</script>\n"],"mappings":";;;;;;mCAmDc;EACZA,IAAM;AACR;;;;;;;IAIA,MAAMC,KAAA,GAAQC,QAAS;IAEjB;MACJC,SAAA;MACAC,SAAA;MACAC,UAAA;MACAC,kBAAA;MACAC,KAAA;MACAC,WAAA;MACAC;IAAA,CACF,GAAIC,WAAY,CAAAC,KAAA,EAAOV,KAAK;IACtB,MAAAW,aAAA,GAAgBC,MAAO,CAAAC,uBAAA,EAAyB,KAAS;IACzD,MAAAC,EAAA,GAAKC,YAAA,CAAa,UAAU;IAE5B,MAAAC,WAAA,GAAcC,QAAA,CAAwB,MAAM;MAC1C,IAAAC,EAAA,EAAAC,EAAA,EAAAC,EAAA,EAAAC,EAAY;MACX,MAAAC,SAAA,IAAAH,EAAA,IAAAD,EAAA,GAAAP,aAAA,oBAAAA,aAAA,CAAAY,IAAA,qBAAAL,EAAA,CAAAM,KAAA,YAAAL,EAAA;MAAA,OACY;QACjBM,eAAa,EAAAH,SAAA;QACbI,WAAsB,EAAAJ,SAAA;QACtBK,KAAW,GAAAN,EAAA,IAAAD,EAAA,GAAAT,aAA0B,gBAAc,IAAAA,aAAA,CAAAiB,SAAA,qBAAAR,EAAA,CAAAI,KAAA,YAAAH,EAAA;QACrDQ,SAAA,EAAAP,SAAA,iBAAAA,SAAA;MAAA,CACD;IAED,CAAM;IACG,MAAAQ,QAAA,GAAAb,QAAA;MACL,OAAK,CACLH,EAAG,CAAAiB,CAAA,SAAa,GAChBjB,EAAG,CAAAkB,EAAA,CAAG,QAAY,EAAA3B,kBAAgB,CAAAmB,KAAA,GAClCV,EAAG,CAAAmB,EAAA,CAAG,UAAW,EAAA7B,UAAe,CAAAoB,KAAA,GAChCV,EAAG,CAAAmB,EAAA,CAAG,SAAS,EAAA9B,SAAe,CAAAqB,KAAA,GAChCV,EAAA,CAAAmB,EAAA,UAAA/B,SAAA,CAAAsB,KAAA,EACD","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}
|