UNPKG

@nextcloud/vue

Version:
62 lines (61 loc) 2.68 kB
import '../assets/NcAppSettingsSection-ObwpPdgW.css'; import { defineComponent, useSlots, inject, computed, watch, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, unref, createElementVNode, toDisplayString, renderSlot } from "vue"; import { l as logger } from "./logger-D3RVzcfQ.mjs"; import { u as useAppSettingsDialog, A as APP_SETTINGS_LEGACY_DESIGN_KEY } from "./useAppSettingsDialog-DbtEkXa4.mjs"; import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.mjs"; const _hoisted_1 = ["id", "aria-labelledby"]; const _hoisted_2 = ["id"]; const _hoisted_3 = { class: "app-settings-section__description" }; const _hoisted_4 = { class: "app-settings-section__content" }; const _sfc_main = /* @__PURE__ */ defineComponent({ __name: "NcAppSettingsSection", props: { name: {}, description: {}, id: {}, order: {} }, setup(__props) { const props = __props; const slots = useSlots(); const { registerSection, unregisterSection } = useAppSettingsDialog(); const legacy = inject(APP_SETTINGS_LEGACY_DESIGN_KEY); const htmlId = computed(() => "settings-section_" + props.id); watch(() => props.id, () => { if (!/^[a-z0-9\-_]+$/.test(props.id)) { logger.warn(`Invalid id prop: ${props.id}. Only alphanumeric, dash and underscore are allowed.`); } }, { immediate: true }); watch([() => props.id, () => props.name, () => props.order], ([newId, newName, newOrder], [oldId, ,]) => { unregisterSection(oldId); registerSection(newId, newName, newOrder, slots?.icon?.()); }); onMounted(() => { registerSection(props.id, props.name, props.order, slots?.icon?.()); }); onBeforeUnmount(() => { unregisterSection(props.id); }); return (_ctx, _cache) => { return openBlock(), createElementBlock("section", { id: htmlId.value, "aria-labelledby": `${htmlId.value}--label`, class: normalizeClass(["app-settings-section", { "app-settings-section__legacy": unref(legacy) }]) }, [ createElementVNode("h3", { id: `${htmlId.value}--label`, class: "app-settings-section__name" }, toDisplayString(_ctx.name), 9, _hoisted_2), createElementVNode("div", _hoisted_3, toDisplayString(_ctx.description), 1), createElementVNode("div", _hoisted_4, [ renderSlot(_ctx.$slots, "default", {}, void 0, true) ]) ], 10, _hoisted_1); }; } }); const NcAppSettingsSection = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4095bb7f"]]); export { NcAppSettingsSection as N }; //# sourceMappingURL=NcAppSettingsSection-B9R7enkC.mjs.map