radio2.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. require('../../../hooks/index.js');
  5. var radio = require('./radio.js');
  6. var useRadio = require('./use-radio.js');
  7. var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
  8. var index = require('../../../hooks/use-namespace/index.js');
  9. const _hoisted_1 = ["value", "name", "disabled"];
  10. const __default__ = vue.defineComponent({
  11. name: "ElRadio"
  12. });
  13. const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  14. ...__default__,
  15. props: radio.radioProps,
  16. emits: radio.radioEmits,
  17. setup(__props, { emit }) {
  18. const props = __props;
  19. const ns = index.useNamespace("radio");
  20. const { radioRef, radioGroup, focus, size, disabled, modelValue } = useRadio.useRadio(props, emit);
  21. function handleChange() {
  22. vue.nextTick(() => emit("change", modelValue.value));
  23. }
  24. return (_ctx, _cache) => {
  25. var _a;
  26. return vue.openBlock(), vue.createElementBlock("label", {
  27. class: vue.normalizeClass([
  28. vue.unref(ns).b(),
  29. vue.unref(ns).is("disabled", vue.unref(disabled)),
  30. vue.unref(ns).is("focus", vue.unref(focus)),
  31. vue.unref(ns).is("bordered", _ctx.border),
  32. vue.unref(ns).is("checked", vue.unref(modelValue) === _ctx.label),
  33. vue.unref(ns).m(vue.unref(size))
  34. ])
  35. }, [
  36. vue.createElementVNode("span", {
  37. class: vue.normalizeClass([
  38. vue.unref(ns).e("input"),
  39. vue.unref(ns).is("disabled", vue.unref(disabled)),
  40. vue.unref(ns).is("checked", vue.unref(modelValue) === _ctx.label)
  41. ])
  42. }, [
  43. vue.withDirectives(vue.createElementVNode("input", {
  44. ref_key: "radioRef",
  45. ref: radioRef,
  46. "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.isRef(modelValue) ? modelValue.value = $event : null),
  47. class: vue.normalizeClass(vue.unref(ns).e("original")),
  48. value: _ctx.label,
  49. name: _ctx.name || ((_a = vue.unref(radioGroup)) == null ? void 0 : _a.name),
  50. disabled: vue.unref(disabled),
  51. type: "radio",
  52. onFocus: _cache[1] || (_cache[1] = ($event) => focus.value = true),
  53. onBlur: _cache[2] || (_cache[2] = ($event) => focus.value = false),
  54. onChange: handleChange
  55. }, null, 42, _hoisted_1), [
  56. [vue.vModelRadio, vue.unref(modelValue)]
  57. ]),
  58. vue.createElementVNode("span", {
  59. class: vue.normalizeClass(vue.unref(ns).e("inner"))
  60. }, null, 2)
  61. ], 2),
  62. vue.createElementVNode("span", {
  63. class: vue.normalizeClass(vue.unref(ns).e("label")),
  64. onKeydown: _cache[3] || (_cache[3] = vue.withModifiers(() => {
  65. }, ["stop"]))
  66. }, [
  67. vue.renderSlot(_ctx.$slots, "default", {}, () => [
  68. vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
  69. ])
  70. ], 34)
  71. ], 2);
  72. };
  73. }
  74. });
  75. var Radio = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/radio/src/radio.vue"]]);
  76. exports["default"] = Radio;
  77. //# sourceMappingURL=radio2.js.map