UNPKG

@ccos/webos-vue

Version:

A Web-Ui Framework for Skyworth/Coocaa TV

70 lines (69 loc) 2.5 kB
import { defineComponent, computed, openBlock, createElementBlock, Fragment, renderList, normalizeClass, normalizeStyle, createElementVNode, renderSlot, createTextVNode, toDisplayString } from "vue"; const _hoisted_1 = { class: "m-radio" }; const _hoisted_2 = ["onClick"]; const _hoisted_3 = { class: "u-label" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "radio", props: { options: { default: () => [] }, disabled: { type: Boolean, default: false }, vertical: { type: Boolean, default: false }, value: { default: null }, gap: { default: 8 } }, emits: ["update:value", "change"], setup(__props, { emit: __emit }) { const props = __props; const sum = computed(() => { return props.options.length; }); const styleObject = computed(() => { if (props.vertical) { return { marginBottom: props.gap + "px" }; } else { return { marginRight: props.gap + "px" }; } }); const emits = __emit; function onClick(value) { if (value !== props.value) { emits("update:value", value); emits("change", value); } } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (option, index) => { return openBlock(), createElementBlock("div", { class: normalizeClass(["m-radio-wrap", { "vertical": _ctx.vertical }]), style: normalizeStyle(sum.value !== index + 1 ? styleObject.value : ""), key: index }, [ createElementVNode("div", { class: normalizeClass(["m-box", { "m-radio-disabled": _ctx.disabled || option.disabled }]), onClick: ($event) => _ctx.disabled || option.disabled ? () => false : onClick(option.value) }, [ createElementVNode("span", _hoisted_3, [ renderSlot(_ctx.$slots, "default", { label: option.label }, () => [ createTextVNode(toDisplayString(option.label), 1) ], true) ]), createElementVNode("span", { class: normalizeClass(["u-radio", { "u-radio-checked": _ctx.value === option.value }]) }, null, 2) ], 10, _hoisted_2) ], 6); }), 128)) ]); }; } }); export { _sfc_main as default };