hongluan-ui
Version:
Hongluan Component Library for Vue 3
106 lines (101 loc) • 3.31 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../hooks/index.js');
var radio = require('./radio.js');
var useRadio = require('./use-radio.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index = require('../../../hooks/use-namespace/index.js');
const _sfc_main = vue.defineComponent({
name: "Radio",
props: radio.radioProps,
emits: radio.radioEmits,
setup(props, { emit }) {
const { namespace } = index.useNamespace("radio");
const {
radioRef,
radioGroup,
isGroup,
focus,
radioSize,
radioFill,
isDisabled,
radioType,
radioCustom,
tabIndex,
modelValue,
actualValue
} = useRadio.useRadio(props, emit);
function handleChange() {
vue.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 vue.openBlock(), vue.createElementBlock("label", {
class: vue.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
}])
}, [
vue.withDirectives(vue.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: vue.withModifiers(() => {
}, ["stop"])
}, null, 40, ["onUpdate:modelValue", "value", "name", "disabled", "checked", "onFocus", "onBlur", "onChange", "onClick"]), [
[vue.vModelRadio, _ctx.modelValue]
]),
!_ctx.radioCustom ? (vue.openBlock(), vue.createElementBlock("em", {
key: 0,
class: "radio-inner"
})) : vue.createCommentVNode("v-if", true),
_ctx.radioCustom ? vue.renderSlot(_ctx.$slots, "default", { key: 1 }) : _ctx.showLabel && (_ctx.$slots.default || _ctx.label) ? (vue.openBlock(), vue.createElementBlock("span", {
key: 2,
class: "radio-label",
onKeydown: vue.withModifiers(() => {
}, ["stop"])
}, [
vue.renderSlot(_ctx.$slots, "default", {}, () => [
vue.createTextVNode(vue.toDisplayString(_ctx.label), 1)
])
], 40, ["onKeydown"])) : vue.createCommentVNode("v-if", true)
], 2);
}
var Radio = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render]]);
exports["default"] = Radio;
//# sourceMappingURL=radio2.js.map