radio-button2.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. require('../../../hooks/index.js');
  5. var useRadio = require('./use-radio.js');
  6. var radioButton = require('./radio-button.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: "ElRadioButton"
  12. });
  13. const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  14. ...__default__,
  15. props: radioButton.radioButtonProps,
  16. setup(__props) {
  17. const props = __props;
  18. const ns = index.useNamespace("radio");
  19. const { radioRef, focus, size, disabled, modelValue, radioGroup } = useRadio.useRadio(props);
  20. const activeStyle = vue.computed(() => {
  21. return {
  22. backgroundColor: (radioGroup == null ? void 0 : radioGroup.fill) || "",
  23. borderColor: (radioGroup == null ? void 0 : radioGroup.fill) || "",
  24. boxShadow: (radioGroup == null ? void 0 : radioGroup.fill) ? `-1px 0 0 0 ${radioGroup.fill}` : "",
  25. color: (radioGroup == null ? void 0 : radioGroup.textColor) || ""
  26. };
  27. });
  28. return (_ctx, _cache) => {
  29. var _a;
  30. return vue.openBlock(), vue.createElementBlock("label", {
  31. class: vue.normalizeClass([
  32. vue.unref(ns).b("button"),
  33. vue.unref(ns).is("active", vue.unref(modelValue) === _ctx.label),
  34. vue.unref(ns).is("disabled", vue.unref(disabled)),
  35. vue.unref(ns).is("focus", vue.unref(focus)),
  36. vue.unref(ns).bm("button", vue.unref(size))
  37. ])
  38. }, [
  39. vue.withDirectives(vue.createElementVNode("input", {
  40. ref_key: "radioRef",
  41. ref: radioRef,
  42. "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.isRef(modelValue) ? modelValue.value = $event : null),
  43. class: vue.normalizeClass(vue.unref(ns).be("button", "original-radio")),
  44. value: _ctx.label,
  45. type: "radio",
  46. name: _ctx.name || ((_a = vue.unref(radioGroup)) == null ? void 0 : _a.name),
  47. disabled: vue.unref(disabled),
  48. onFocus: _cache[1] || (_cache[1] = ($event) => focus.value = true),
  49. onBlur: _cache[2] || (_cache[2] = ($event) => focus.value = false)
  50. }, null, 42, _hoisted_1), [
  51. [vue.vModelRadio, vue.unref(modelValue)]
  52. ]),
  53. vue.createElementVNode("span", {
  54. class: vue.normalizeClass(vue.unref(ns).be("button", "inner")),
  55. style: vue.normalizeStyle(vue.unref(modelValue) === _ctx.label ? vue.unref(activeStyle) : {}),
  56. onKeydown: _cache[3] || (_cache[3] = vue.withModifiers(() => {
  57. }, ["stop"]))
  58. }, [
  59. vue.renderSlot(_ctx.$slots, "default", {}, () => [
  60. vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
  61. ])
  62. ], 38)
  63. ], 2);
  64. };
  65. }
  66. });
  67. var RadioButton = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/radio/src/radio-button.vue"]]);
  68. exports["default"] = RadioButton;
  69. //# sourceMappingURL=radio-button2.js.map