checkbox-group2.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var lodashUnified = require('lodash-unified');
  5. var checkboxGroup = require('./checkbox-group.js');
  6. var constants = require('./constants.js');
  7. var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
  8. var index = require('../../../hooks/use-namespace/index.js');
  9. var useFormItem = require('../../form/src/hooks/use-form-item.js');
  10. var error = require('../../../utils/error.js');
  11. var event = require('../../../constants/event.js');
  12. const __default__ = vue.defineComponent({
  13. name: "ElCheckboxGroup"
  14. });
  15. const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  16. ...__default__,
  17. props: checkboxGroup.checkboxGroupProps,
  18. emits: checkboxGroup.checkboxGroupEmits,
  19. setup(__props, { emit }) {
  20. const props = __props;
  21. const ns = index.useNamespace("checkbox");
  22. const { formItem } = useFormItem.useFormItem();
  23. const { inputId: groupId, isLabeledByFormItem } = useFormItem.useFormItemInputId(props, {
  24. formItemContext: formItem
  25. });
  26. const changeEvent = async (value) => {
  27. emit(event.UPDATE_MODEL_EVENT, value);
  28. await vue.nextTick();
  29. emit(event.CHANGE_EVENT, value);
  30. };
  31. const modelValue = vue.computed({
  32. get() {
  33. return props.modelValue;
  34. },
  35. set(val) {
  36. changeEvent(val);
  37. }
  38. });
  39. vue.provide(constants.checkboxGroupContextKey, {
  40. ...lodashUnified.pick(vue.toRefs(props), [
  41. "size",
  42. "min",
  43. "max",
  44. "disabled",
  45. "validateEvent",
  46. "fill",
  47. "textColor"
  48. ]),
  49. modelValue,
  50. changeEvent
  51. });
  52. vue.watch(() => props.modelValue, () => {
  53. if (props.validateEvent) {
  54. formItem == null ? void 0 : formItem.validate("change").catch((err) => error.debugWarn(err));
  55. }
  56. });
  57. return (_ctx, _cache) => {
  58. var _a;
  59. return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.tag), {
  60. id: vue.unref(groupId),
  61. class: vue.normalizeClass(vue.unref(ns).b("group")),
  62. role: "group",
  63. "aria-label": !vue.unref(isLabeledByFormItem) ? _ctx.ariaLabel || "checkbox-group" : void 0,
  64. "aria-labelledby": vue.unref(isLabeledByFormItem) ? (_a = vue.unref(formItem)) == null ? void 0 : _a.labelId : void 0
  65. }, {
  66. default: vue.withCtx(() => [
  67. vue.renderSlot(_ctx.$slots, "default")
  68. ]),
  69. _: 3
  70. }, 8, ["id", "class", "aria-label", "aria-labelledby"]);
  71. };
  72. }
  73. });
  74. var CheckboxGroup = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "checkbox-group.vue"]]);
  75. exports["default"] = CheckboxGroup;
  76. //# sourceMappingURL=checkbox-group2.js.map