UNPKG

@nextcloud/vue

Version:
75 lines (74 loc) 3.19 kB
import '../assets/NcFormGroup-C9rXaPCl.css'; import { defineComponent, useSlots, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createTextVNode, toDisplayString, createCommentVNode } from "vue"; import { c as createElementId } from "./createElementId-DhjFt1I9.mjs"; import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.mjs"; const _hoisted_1 = ["aria-describedby"]; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "NcFormGroup", props: { label: { default: () => void 0 }, description: { default: () => void 0 }, hideLabel: { type: Boolean, default: false }, hideDescription: { type: Boolean, default: false }, noGap: { type: Boolean, default: false } }, setup(__props) { const slots = useSlots(); const id = `nc-form-group-${createElementId()}`; const descriptionId = `${id}-description`; const hasDescription = () => !!__props.description || !!slots.description; const getDescriptionId = () => hasDescription() ? descriptionId : void 0; const hasContentOnly = () => __props.hideLabel && (!hasDescription() || __props.hideDescription); return (_ctx, _cache) => { return openBlock(), createElementBlock("fieldset", { class: normalizeClass([_ctx.$style.formGroup, { [_ctx.$style.formGroup_noGap]: __props.noGap }]), "aria-describedby": getDescriptionId() }, [ createElementVNode("legend", { class: normalizeClass([_ctx.$style.formGroup__label, { "hidden-visually": __props.hideLabel }]) }, [ renderSlot(_ctx.$slots, "label", {}, () => [ createTextVNode(toDisplayString(__props.label || "⚠️ Missing label"), 1) ]) ], 2), hasDescription() ? (openBlock(), createElementBlock("div", { key: 0, id: descriptionId, class: normalizeClass([_ctx.$style.formGroup__description, { "hidden-visually": __props.hideDescription }]) }, [ renderSlot(_ctx.$slots, "description", {}, () => [ createTextVNode(toDisplayString(__props.description), 1) ]) ], 2)) : createCommentVNode("", true), createElementVNode("div", { class: normalizeClass([_ctx.$style.formGroup__content, { [_ctx.$style.formGroup__content_only]: hasContentOnly() }]) }, [ renderSlot(_ctx.$slots, "default") ], 2) ], 10, _hoisted_1); }; } }); const formGroup = "_formGroup_qS7n2"; const formGroup_noGap = "_formGroup_noGap_-dO6k"; const formGroup__label = "_formGroup__label_sqDH-"; const formGroup__description = "_formGroup__description_TJcbK"; const formGroup__content = "_formGroup__content_qlp3e"; const formGroup__content_only = "_formGroup__content_only_-KAAy"; const style0 = { "material-design-icon": "_material-design-icon_9zf-E", formGroup, formGroup_noGap, formGroup__label, formGroup__description, formGroup__content, formGroup__content_only }; const cssModules = { "$style": style0 }; const NcFormGroup = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]); export { NcFormGroup as N }; //# sourceMappingURL=NcFormGroup-W-Wgps0q.mjs.map