@fesjs/fes-design
Version:
fes-design for PC
88 lines (83 loc) • 2.62 kB
JavaScript
import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createTextVNode, toDisplayString } from 'vue';
import getPrefixCls from '../_util/getPrefixCls';
import { useTheme } from '../_theme/useTheme';
import useSelect from '../_util/use/useSelect';
import { radioGroupKey, COMPONENT_NAME } from '../radio-group/const';
import { UPDATE_MODEL_EVENT, CHANGE_EVENT } from '../_util/constants';
import { radioProps } from './props';
const prefixCls = getPrefixCls('radio');
var script = defineComponent({
name: 'FRadio',
props: radioProps,
emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT],
setup(props, _ref) {
let {
emit
} = _ref;
useTheme();
const {
isGroup,
group,
hover,
checked,
innerDisabled,
handleClick,
handleMouseOver,
handleMouseOut
} = useSelect({
props,
emit,
parent: {
groupKey: radioGroupKey,
name: COMPONENT_NAME
}
});
const wrapperClass = computed(() => {
const arr = [`${prefixCls}`];
if (checked.value) {
arr.push('is-checked');
}
if (innerDisabled.value) {
arr.push('is-disabled');
}
if (hover.value) {
arr.push('is-hover');
}
if (isGroup) {
arr.push('is-item');
if (group.props.vertical) {
arr.push('is-item-vertical');
}
}
return arr;
});
return {
prefixCls,
handleClick,
handleMouseOver,
handleMouseOut,
wrapperClass
};
}
});
function render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("label", {
class: normalizeClass(_ctx.wrapperClass),
onClick: _cache[0] || (_cache[0] = function () {
return _ctx.handleClick && _ctx.handleClick(...arguments);
}),
onMouseover: _cache[1] || (_cache[1] = function () {
return _ctx.handleMouseOver && _ctx.handleMouseOver(...arguments);
}),
onMouseout: _cache[2] || (_cache[2] = function () {
return _ctx.handleMouseOut && _ctx.handleMouseOut(...arguments);
})
}, [createElementVNode("span", {
class: normalizeClass(`${_ctx.prefixCls}-inner`)
}, null, 2 /* CLASS */), createElementVNode("span", {
class: normalizeClass(`${_ctx.prefixCls}-content`)
}, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(_ctx.label), 1 /* TEXT */)])], 2 /* CLASS */)], 34 /* CLASS, NEED_HYDRATION */);
}
script.render = render;
script.__file = "components/radio/radio.vue";
export { script as default };