UNPKG

@nextcloud/vue

Version:
121 lines (120 loc) 3.78 kB
import '../assets/NcActionRadio.css'; import { f as mdiRadioboxMarked, g as mdiRadioboxBlank } from "./mdi.mjs"; import { resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, withDirectives, vModelRadio, createVNode, toDisplayString, useModel } from "vue"; import { N as NcIconSvgWrapper } from "./NcIconSvgWrapper.mjs"; import { A as ActionGlobalMixin } from "./actionGlobal.mjs"; import { c as createElementId } from "./createElementId.mjs"; import { a as NC_ACTIONS_IS_SEMANTIC_MENU } from "./useNcActions.mjs"; import { _ as _export_sfc } from "./_plugin-vue_export-helper.mjs"; const _sfc_main = { name: "NcActionRadio", components: { NcIconSvgWrapper }, mixins: [ActionGlobalMixin], inject: { isInSemanticMenu: { from: NC_ACTIONS_IS_SEMANTIC_MENU, default: false } }, props: { /** * id attribute of the radio element */ id: { type: String, default: () => createElementId(), validator: (id) => id.trim() !== "" }, /** * checked state of the radio element */ modelValue: { type: [String, Number], default: "" }, /** * Define if this radio is part of a set. * Checking the radio will disable all the * others with the same name. */ name: { type: String, required: true }, /** * value of the radio input */ value: { type: [String, Number], default: "" }, /** * disabled state of the radio element */ disabled: { type: Boolean, default: false } }, emits: [ "change", "update:modelValue" ], setup(props) { return { model: useModel(props, "modelValue"), mdiRadioboxBlank, mdiRadioboxMarked }; }, computed: { checked() { return this.model === this.value; } } }; const _hoisted_1 = ["role"]; const _hoisted_2 = ["role", "aria-checked"]; const _hoisted_3 = { class: "action-radio__icon" }; const _hoisted_4 = ["id", "value", "name", "disabled"]; const _hoisted_5 = { class: "action-radio__text" }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { const _component_NcIconSvgWrapper = resolveComponent("NcIconSvgWrapper"); return openBlock(), createElementBlock("li", { class: normalizeClass(["action", { "action--disabled": $props.disabled }]), role: $options.isInSemanticMenu && "presentation" }, [ createElementVNode("label", { class: "action-radio", role: $options.isInSemanticMenu && "menuitemradio", "aria-checked": $options.isInSemanticMenu && $options.checked.toString() }, [ createElementVNode("span", _hoisted_3, [ withDirectives(createElementVNode("input", { id: $props.id, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $setup.model = $event), type: "radio", class: normalizeClass(["action-radio__input", { focusable: !$props.disabled }]), value: $props.value, name: $props.name, disabled: $props.disabled, onChange: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("change", $event)) }, null, 42, _hoisted_4), [ [vModelRadio, $setup.model] ]), createVNode(_component_NcIconSvgWrapper, { path: $options.checked ? $setup.mdiRadioboxMarked : $setup.mdiRadioboxBlank, size: 20 }, null, 8, ["path"]) ]), createElementVNode("span", _hoisted_5, toDisplayString(_ctx.text), 1) ], 8, _hoisted_2) ], 10, _hoisted_1); } const NcActionRadio = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6c208ddd"]]); export { NcActionRadio as N }; //# sourceMappingURL=NcActionRadio.mjs.map