UNPKG

@vuesax-alpha/nightly

Version:
125 lines (122 loc) 4.65 kB
import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, unref, withDirectives, isRef, vModelRadio, renderSlot, createCommentVNode, createVNode, createTextVNode, toDisplayString } from 'vue'; import '../../../hooks/index.mjs'; import '../../../utils/index.mjs'; import { IconLoading } from '../../icon/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'; import { useId } from '../../../hooks/use-id/index.mjs'; import { useColor } from '../../../hooks/use-common-props/index.mjs'; import { useVuesaxBaseComponent } from '../../../hooks/use-base-component/index.mjs'; import { getVsColor } from '../../../utils/color.mjs'; const _hoisted_1 = ["id", "disabled", "readonly", "name"]; const _hoisted_2 = ["for"]; const __default__ = defineComponent({ name: "VsRadio" }); const _sfc_main = defineComponent({ ...__default__, props: radioProps, emits: radioEmits, setup(__props, { emit }) { const props = __props; const ns = useNamespace("radio"); const uid = useId(); const { isDisabled, loading, model, focus, checked } = useRadio(props, emit); const color = useColor("primary"); const vsBaseClasses = useVuesaxBaseComponent(color); const radioKls = computed(() => [ vsBaseClasses, ns.b("wrapper"), ns.is("loading", loading.value), ns.is("disabled", isDisabled.value), ns.is("active", checked.value), ns.is("label-before", props.labelBefore) ]); const radioStyles = computed(() => [ ns.cssVar({ color: getVsColor(color.value) }) ]); return (_ctx, _cache) => { return openBlock(), createElementBlock( "div", { class: normalizeClass(radioKls.value), style: normalizeStyle(radioStyles.value) }, [ createElementVNode( "div", { class: normalizeClass(unref(ns).b()) }, [ withDirectives(createElementVNode("input", { id: unref(uid), "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null), type: "radio", disabled: unref(isDisabled), readonly: unref(isDisabled), name: _ctx.name, onFocus: _cache[1] || (_cache[1] = ($event) => focus.value = true), onBlur: _cache[2] || (_cache[2] = ($event) => focus.value = false) }, null, 40, _hoisted_1), [ [vModelRadio, unref(model)] ]), createElementVNode( "span", { class: normalizeClass(unref(ns).e("effect")) }, [ _ctx.$slots.icon ? (openBlock(), createElementBlock( "span", { key: 0, class: normalizeClass(unref(ns).em("effect", "icon")) }, [ renderSlot(_ctx.$slots, "icon") ], 2 )) : createCommentVNode("v-if", true), unref(loading) ? (openBlock(), createElementBlock( "span", { key: 1, class: normalizeClass(unref(ns).em("effect", "loading")) }, [ createVNode(unref(IconLoading)) ], 2 )) : createCommentVNode("v-if", true) ], 2 ) ], 2 ), _ctx.$slots.default || _ctx.label ? (openBlock(), createElementBlock("label", { key: 0, for: unref(uid), class: normalizeClass(unref(ns).e("label")) }, [ renderSlot(_ctx.$slots, "default", {}, () => [ createTextVNode( toDisplayString(_ctx.label), 1 ) ]) ], 10, _hoisted_2)) : createCommentVNode("v-if", true) ], 6 ); }; } }); var Radio = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/vuesax-alpha/vuesax-alpha/packages/components/radio/src/radio.vue"]]); export { Radio as default }; //# sourceMappingURL=radio2.mjs.map