UNPKG

@nextcloud/vue

Version:
110 lines (109 loc) 3.37 kB
require('../assets/NcActionRadio-DFcWmvae.css'); "use strict"; const actionGlobal = require("../chunks/actionGlobal-L0Ls8tPJ.cjs"); const GenRandomId = require("../chunks/GenRandomId-BQDud3d4.cjs"); const _pluginVue2_normalizer = require("../chunks/_plugin-vue2_normalizer-V0q-tHlQ.cjs"); const _sfc_main = { name: "NcActionRadio", mixins: [actionGlobal.ActionGlobalMixin], inject: { isInSemanticMenu: { from: "NcActions:isSemanticMenu", default: false } }, props: { /** * id attribute of the radio element */ id: { type: String, default: () => "action-" + GenRandomId.GenRandomId(), validator: (id) => id.trim() !== "" }, /** * checked state of the the radio element */ checked: { type: Boolean, default: false }, /** * 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: [ "update:checked", "change" ], computed: { /** * determines if the action is focusable * * @return {boolean} is the action focusable ? */ isFocusable() { return !this.disabled; }, /** * aria-checked attribute for role="menuitemcheckbox" * * @return {'true'|'false'|undefined} aria-checked value if needed */ ariaChecked() { if (this.isInSemanticMenu) { return this.checked ? "true" : "false"; } return void 0; } }, methods: { toggleInput(event) { this.$refs.label.click(); }, onChange(event) { this.$emit("update:checked", this.$refs.radio.checked); this.$emit("change", event); } } }; var _sfc_render = function render() { var _vm = this, _c = _vm._self._c; return _c("li", { staticClass: "action", class: { "action--disabled": _vm.disabled }, attrs: { "role": _vm.isInSemanticMenu && "presentation" } }, [_c("span", { staticClass: "action-radio", attrs: { "role": "menuitemradio", "aria-checked": _vm.ariaChecked } }, [_c("input", { ref: "radio", staticClass: "radio action-radio__radio", class: { focusable: _vm.isFocusable }, attrs: { "id": _vm.id, "disabled": _vm.disabled, "name": _vm.name, "type": "radio" }, domProps: { "checked": _vm.checked, "value": _vm.value }, on: { "keydown": function($event) { if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")) return null; if ($event.ctrlKey || $event.shiftKey || $event.altKey || $event.metaKey) return null; $event.preventDefault(); return _vm.toggleInput.apply(null, arguments); }, "change": _vm.onChange } }), _c("label", { ref: "label", staticClass: "action-radio__label", attrs: { "for": _vm.id } }, [_vm._v(_vm._s(_vm.text))]), _vm._e()], 2)]); }; var _sfc_staticRenderFns = []; var __component__ = /* @__PURE__ */ _pluginVue2_normalizer.normalizeComponent( _sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "8c1a9122" ); const NcActionRadio = __component__.exports; module.exports = NcActionRadio;