@nextcloud/vue
Version:
Nextcloud vue components
76 lines (75 loc) • 2.67 kB
JavaScript
import '../assets/NcRadioGroup-1zpSX8V5.css';
import { defineComponent, mergeModels, useModel, ref, provide, computed, warn, createBlock, openBlock, withCtx, createElementBlock, renderSlot, normalizeClass } from "vue";
import { N as NcFormBox } from "./NcFormBox-K2tCRm3B.mjs";
import { N as NcFormGroup } from "./NcFormGroup-CnSfPFey.mjs";
import { I as INSIDE_RADIO_GROUP_KEY } from "./useNcRadioGroup-DaZbEKbf.mjs";
import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "NcRadioGroup",
props: /* @__PURE__ */ mergeModels({
label: {},
labelHidden: { type: Boolean },
hideLabel: { type: Boolean },
description: {}
}, {
"modelValue": { required: false, default: "" },
"modelModifiers": {}
}),
emits: ["update:modelValue"],
setup(__props) {
const modelValue = useModel(__props, "modelValue");
const buttonVariant = ref();
provide(INSIDE_RADIO_GROUP_KEY, computed(() => ({
register,
modelValue: modelValue.value,
onUpdate
})));
function register(isButton) {
if (buttonVariant.value !== void 0 && buttonVariant.value !== isButton) {
warn("[NcRadioGroup] Mixing NcCheckboxRadioSwitch and NcRadioGroupButton is not possible!");
}
buttonVariant.value = isButton;
}
function onUpdate(value) {
modelValue.value = value;
}
return (_ctx, _cache) => {
return openBlock(), createBlock(NcFormGroup, {
label: _ctx.label,
description: _ctx.description,
"hide-label": _ctx.labelHidden || _ctx.hideLabel
}, {
default: withCtx(() => [
buttonVariant.value ? (openBlock(), createBlock(NcFormBox, {
key: 0,
row: ""
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default")
]),
_: 3
})) : (openBlock(), createElementBlock("span", {
key: 1,
class: normalizeClass(_ctx.$style.radioGroup_checkboxRadioContainer)
}, [
renderSlot(_ctx.$slots, "default")
], 2))
]),
_: 3
}, 8, ["label", "description", "hide-label"]);
};
}
});
const radioGroup_checkboxRadioContainer = "_radioGroup_checkboxRadioContainer_14z4o_20";
const style0 = {
"material-design-icon": "_material-design-icon_14z4o_12",
radioGroup_checkboxRadioContainer
};
const cssModules = {
"$style": style0
};
const NcRadioGroup = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]);
export {
NcRadioGroup as N
};
//# sourceMappingURL=NcRadioGroup-CLtk-WPR.mjs.map