UNPKG

@ccos/webos-vue

Version:

A Web-Ui Framework for Skyworth/Coocaa TV

70 lines (69 loc) 2.53 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const vue = require("vue"); const _hoisted_1 = { class: "m-radio" }; const _hoisted_2 = ["onClick"]; const _hoisted_3 = { class: "u-label" }; const _sfc_main = /* @__PURE__ */ vue.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 = vue.computed(() => { return props.options.length; }); const styleObject = vue.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 vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.options, (option, index) => { return vue.openBlock(), vue.createElementBlock("div", { class: vue.normalizeClass(["m-radio-wrap", { "vertical": _ctx.vertical }]), style: vue.normalizeStyle(sum.value !== index + 1 ? styleObject.value : ""), key: index }, [ vue.createElementVNode("div", { class: vue.normalizeClass(["m-box", { "m-radio-disabled": _ctx.disabled || option.disabled }]), onClick: ($event) => _ctx.disabled || option.disabled ? () => false : onClick(option.value) }, [ vue.createElementVNode("span", _hoisted_3, [ vue.renderSlot(_ctx.$slots, "default", { label: option.label }, () => [ vue.createTextVNode(vue.toDisplayString(option.label), 1) ], true) ]), vue.createElementVNode("span", { class: vue.normalizeClass(["u-radio", { "u-radio-checked": _ctx.value === option.value }]) }, null, 2) ], 10, _hoisted_2) ], 6); }), 128)) ]); }; } }); exports.default = _sfc_main;