@nextcloud/vue
Version:
Nextcloud vue components
76 lines (75 loc) • 2.62 kB
JavaScript
import '../assets/NcRadioGroup.css';
import { defineComponent, useModel, ref, provide, computed, warn, openBlock, createBlock, withCtx, renderSlot, createElementBlock, normalizeClass, mergeModels } from "vue";
import { N as NcFormBox } from "./NcFormBox.mjs";
import { N as NcFormGroup } from "./NcFormGroup.mjs";
import { I as INSIDE_RADIO_GROUP_KEY } from "./useNcRadioGroup.mjs";
import { _ as _export_sfc } from "./_plugin-vue_export-helper.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: __props.label,
description: __props.description,
hideLabel: __props.labelHidden || __props.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", "hideLabel"]);
};
}
});
const radioGroup_checkboxRadioContainer = "_radioGroup_checkboxRadioContainer_0rsOE";
const style0 = {
"material-design-icon": "_material-design-icon_SHkNa",
radioGroup_checkboxRadioContainer
};
const cssModules = {
"$style": style0
};
const NcRadioGroup = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]);
export {
NcRadioGroup as N
};
//# sourceMappingURL=NcRadioGroup.mjs.map