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
6.1 KiB
1 lines
6.1 KiB
{"ast":null,"code":"import { defineComponent, computed, provide, toRefs, watch, openBlock, createBlock, resolveDynamicComponent, unref, normalizeClass, withCtx, renderSlot, nextTick } from 'vue';\nimport { pick } from 'lodash-unified';\nimport { checkboxGroupProps, checkboxGroupEmits } from './checkbox-group.mjs';\nimport { checkboxGroupContextKey } from './constants.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { useFormItem, useFormItemInputId } from '../../form/src/hooks/use-form-item.mjs';\nimport { debugWarn } from '../../../utils/error.mjs';\nimport { UPDATE_MODEL_EVENT } from '../../../constants/event.mjs';\nconst __default__ = defineComponent({\n name: \"ElCheckboxGroup\"\n});\nconst _sfc_main = /* @__PURE__ */defineComponent({\n ...__default__,\n props: checkboxGroupProps,\n emits: checkboxGroupEmits,\n setup(__props, {\n emit\n }) {\n const props = __props;\n const ns = useNamespace(\"checkbox\");\n const {\n formItem\n } = useFormItem();\n const {\n inputId: groupId,\n isLabeledByFormItem\n } = useFormItemInputId(props, {\n formItemContext: formItem\n });\n const changeEvent = async value => {\n emit(UPDATE_MODEL_EVENT, value);\n await nextTick();\n emit(\"change\", value);\n };\n const modelValue = computed({\n get() {\n return props.modelValue;\n },\n set(val) {\n changeEvent(val);\n }\n });\n provide(checkboxGroupContextKey, {\n ...pick(toRefs(props), [\"size\", \"min\", \"max\", \"disabled\", \"validateEvent\", \"fill\", \"textColor\"]),\n modelValue,\n changeEvent\n });\n watch(() => props.modelValue, () => {\n if (props.validateEvent) {\n formItem == null ? void 0 : formItem.validate(\"change\").catch(err => debugWarn(err));\n }\n });\n return (_ctx, _cache) => {\n var _a;\n return openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {\n id: unref(groupId),\n class: normalizeClass(unref(ns).b(\"group\")),\n role: \"group\",\n \"aria-label\": !unref(isLabeledByFormItem) ? _ctx.ariaLabel || \"checkbox-group\" : void 0,\n \"aria-labelledby\": unref(isLabeledByFormItem) ? (_a = unref(formItem)) == null ? void 0 : _a.labelId : void 0\n }, {\n default: withCtx(() => [renderSlot(_ctx.$slots, \"default\")]),\n _: 3\n }, 8, [\"id\", \"class\", \"aria-label\", \"aria-labelledby\"]);\n };\n }\n});\nvar CheckboxGroup = /* @__PURE__ */_export_sfc(_sfc_main, [[\"__file\", \"checkbox-group.vue\"]]);\nexport { CheckboxGroup as default };","map":{"version":3,"names":["name","ns","useNamespace","formItem","useFormItem","inputId","groupId","isLabeledByFormItem","useFormItemInputId","props","formItemContext","changeEvent","value","emit","UPDATE_MODEL_EVENT","nextTick","modelValue","computed","get","set","val","provide","checkboxGroupContextKey","pick","toRefs","watch","validateEvent","validate","catch","err","debugWarn","_ctx","_cache","_a","openBlock","createBlock","resolveDynamicComponent","tag"],"sources":["../../../../../../packages/components/checkbox/src/checkbox-group.vue"],"sourcesContent":["<template>\n <component\n :is=\"tag\"\n :id=\"groupId\"\n :class=\"ns.b('group')\"\n role=\"group\"\n :aria-label=\"\n !isLabeledByFormItem ? ariaLabel || 'checkbox-group' : undefined\n \"\n :aria-labelledby=\"isLabeledByFormItem ? formItem?.labelId : undefined\"\n >\n <slot />\n </component>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, nextTick, provide, toRefs, watch } from 'vue'\nimport { pick } from 'lodash-unified'\nimport { UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { debugWarn } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { useFormItem, useFormItemInputId } from '@element-plus/components/form'\nimport { checkboxGroupEmits, checkboxGroupProps } from './checkbox-group'\nimport { checkboxGroupContextKey } from './constants'\n\nimport type { CheckboxGroupValueType } from './checkbox-group'\n\ndefineOptions({\n name: 'ElCheckboxGroup',\n})\n\nconst props = defineProps(checkboxGroupProps)\nconst emit = defineEmits(checkboxGroupEmits)\nconst ns = useNamespace('checkbox')\n\nconst { formItem } = useFormItem()\nconst { inputId: groupId, isLabeledByFormItem } = useFormItemInputId(props, {\n formItemContext: formItem,\n})\n\nconst changeEvent = async (value: CheckboxGroupValueType) => {\n emit(UPDATE_MODEL_EVENT, value)\n await nextTick()\n emit('change', value)\n}\n\nconst modelValue = computed({\n get() {\n return props.modelValue\n },\n set(val: CheckboxGroupValueType) {\n changeEvent(val)\n },\n})\n\nprovide(checkboxGroupContextKey, {\n ...pick(toRefs(props), [\n 'size',\n 'min',\n 'max',\n 'disabled',\n 'validateEvent',\n 'fill',\n 'textColor',\n ]),\n modelValue,\n changeEvent,\n})\n\nwatch(\n () => props.modelValue,\n () => {\n if (props.validateEvent) {\n formItem?.validate('change').catch((err) => debugWarn(err))\n }\n }\n)\n</script>\n"],"mappings":";;;;;;;;;mCA2Bc;EACZA,IAAM;AACR;;;;;;;;;IAIM,MAAAC,EAAA,GAAKC,YAAA,CAAa,UAAU;IAE5B;MAAEC;IAAS,IAAIC,WAAY;IACjC,MAAM;MAAEC,OAAS,EAAAC,OAAA;MAASC;IAAoB,IAAIC,kBAAA,CAAmBC,KAAO;MAC1EC,eAAiB,EAAAP;IAAA,CAClB;IAEK,MAAAQ,WAAA,GAAc,MAAOC,KAAkC;MAC3DC,IAAA,CAAKC,kBAAA,EAAoBF,KAAK;MAC9B,MAAMG,QAAS;MACfF,IAAA,CAAK,UAAUD,KAAK;IAAA,CACtB;IAEA,MAAMI,UAAA,GAAaC,QAAS;MAC1BC,GAAMA,CAAA;QACJ,OAAOT,KAAM,CAAAO,UAAA;MAAA,CACf;MACAG,IAAIC,GAA6B;QAC/BT,WAAA,CAAYS,GAAG;MAAA;IACjB,CACD;IAEDC,OAAA,CAAQC,uBAAyB;MAC/B,GAAGC,IAAA,CAAKC,MAAO,CAAAf,KAAK,CAAG,GACrB,QACA,OACA,OACA,YACA,iBACA,QACA,YACD;MACDO,UAAA;MACAL;IAAA,CACD;IAEDc,KAAA,OAAAhB,KAAA,CAAAO,UAAA;MACE,IAAAP,KAAY,CAAAiB,aAAA;QACNvB,QAAA,oBAAAA,QAAA,CAAAwB,QAAA,WAAAC,KAAA,CAAAC,GAAA,IAAAC,SAAA,CAAAD,GAAA;MACJ;IACE,CAAU;IACZ,QAAAE,IAAA,EAAAC,MAAA;MACF,IAAAC,EAAA;MACF,OAAAC,SAAA,IAAAC,WAAA,CAAAC,uBAAA,CAAAL,IAAA,CAAAM,GAAA","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}
|