various-ui
Version:
This is a test version of the Vue 3 component library
34 lines (31 loc) • 994 B
JavaScript
import { inject, computed } from 'vue';
import { UiRadioGroupInjectionKey } from '../../default-group/index.mjs';
const useComposable = (define, emits) => {
const radioGroup = inject(UiRadioGroupInjectionKey, void 0);
const computeds = {
//* 选择状态
checked: computed(() => {
if ((radioGroup == null ? void 0 : radioGroup.define.modelValue) == define.value) return true;
else {
return define.modelValue == define.value;
}
}),
//* 标签类名
className: computed(() => {
const result = [];
if (computeds.checked.value) result.push("ui-active");
return result.join(" ");
})
};
const methods = {
switchRatio: (_ev) => {
const el = _ev.target;
emits("update:modelValue", el.value || "");
emits("change", _ev);
radioGroup == null ? void 0 : radioGroup.change(define.value);
}
};
return { computeds, methods };
};
export { useComposable };
//# sourceMappingURL=composable.mjs.map