UNPKG

@opensig/opendesign

Version:

55 lines (54 loc) 1.62 kB
"use strict"; const vue = require("vue"); const types = require("./types.js"); const provide$1 = require("./provide.js"); const is = require("../_utils/is.js"); const provide = require("../form/provide.js"); const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "ORadioGroup", props: types.radioGroupProps, emits: ["update:modelValue", "change"], setup(__props, { emit: __emit }) { const props = __props; const emits = __emit; const realValue = vue.ref(props.modelValue ?? props.defaultValue); const formItemInjection = vue.inject(provide.formItemInjectKey, null); vue.watch( () => props.modelValue, (val) => { if (!is.isUndefined(val)) { realValue.value = val; } } ); const updateModelValue = (val) => { realValue.value = val; emits("update:modelValue", val); }; const onChange = (val, ev) => { var _a, _b; emits("change", val, ev); (_b = formItemInjection == null ? void 0 : (_a = formItemInjection.fieldHandlers).onChange) == null ? void 0 : _b.call(_a); }; vue.provide(provide$1.radioGroupInjectKey, { realValue, disabled: vue.toRef(props, "disabled"), updateModelValue, onChange }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock( "div", { class: vue.normalizeClass(["o-radio-group", [`o-radio-group-${props.direction}`]]) }, [ vue.renderSlot(_ctx.$slots, "default") ], 2 /* CLASS */ ); }; } }); module.exports = _sfc_main;