UNPKG

hongluan-ui

Version:
102 lines (99 loc) 3.33 kB
import { defineComponent, nextTick, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, withModifiers, vModelRadio, createCommentVNode, renderSlot, createTextVNode, toDisplayString } from 'vue'; import '../../../hooks/index.mjs'; import { radioProps, radioEmits } from './radio.mjs'; import { useRadio } from './use-radio.mjs'; import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs'; import { useNamespace } from '../../../hooks/use-namespace/index.mjs'; const _sfc_main = defineComponent({ name: "Radio", props: radioProps, emits: radioEmits, setup(props, { emit }) { const { namespace } = useNamespace("radio"); const { radioRef, radioGroup, isGroup, focus, radioSize, radioFill, isDisabled, radioType, radioCustom, tabIndex, modelValue, actualValue } = useRadio(props, emit); function handleChange() { nextTick(() => emit("change", modelValue.value)); } return { namespace, actualValue, focus, isGroup, radioGroup, modelValue, tabIndex, radioSize, radioFill, isDisabled, radioType, radioCustom, radioRef, handleChange }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { var _a; return openBlock(), createElementBlock("label", { class: normalizeClass([{ [_ctx.namespace]: true, "is-radio": true, "is-disabled": _ctx.isDisabled, "is-focus": _ctx.focus, "is-checked": _ctx.modelValue === _ctx.actualValue, "fill": _ctx.radioFill, "custom": _ctx.radioCustom, [_ctx.radioType]: !!_ctx.radioType, [_ctx.radioSize]: !!_ctx.radioSize, "show-label": _ctx.showLabel }]) }, [ withDirectives(createElementVNode("input", { ref: "radioRef", "onUpdate:modelValue": ($event) => _ctx.modelValue = $event, class: "radio-input", value: _ctx.actualValue, type: "radio", name: _ctx.name || ((_a = _ctx.radioGroup) == null ? void 0 : _a.name), disabled: _ctx.isDisabled, checked: _ctx.modelValue === _ctx.actualValue, onFocus: ($event) => _ctx.focus = true, onBlur: ($event) => _ctx.focus = false, onChange: _ctx.handleChange, onClick: withModifiers(() => { }, ["stop"]) }, null, 40, ["onUpdate:modelValue", "value", "name", "disabled", "checked", "onFocus", "onBlur", "onChange", "onClick"]), [ [vModelRadio, _ctx.modelValue] ]), !_ctx.radioCustom ? (openBlock(), createElementBlock("em", { key: 0, class: "radio-inner" })) : createCommentVNode("v-if", true), _ctx.radioCustom ? renderSlot(_ctx.$slots, "default", { key: 1 }) : _ctx.showLabel && (_ctx.$slots.default || _ctx.label) ? (openBlock(), createElementBlock("span", { key: 2, class: "radio-label", onKeydown: withModifiers(() => { }, ["stop"]) }, [ renderSlot(_ctx.$slots, "default", {}, () => [ createTextVNode(toDisplayString(_ctx.label), 1) ]) ], 40, ["onKeydown"])) : createCommentVNode("v-if", true) ], 2); } var Radio = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { Radio as default }; //# sourceMappingURL=radio2.mjs.map