radio-button2.js 3.4 KB

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