28a2b1104839544880956f38a5cf5b42c80ca8f8a97f02986ff6be78ab5ac2e4f5d09caa29b27ab94cdff7c330b33c0ccaa82d9d00d7d30a2b01d13b4490a2 3.0 KB

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