import * as Uebersicht from "uebersicht"; import * as Icons from "../icons/icons.jsx"; import * as Utils from "../../utils"; import * as Settings from "../../settings"; import SettingsInner from "./settings-inner.jsx"; const { React } = Uebersicht; const settingsKeys = { batteryWidget: "batteryWidgetOptions", browserTrackWidget: "browserTrackWidgetOptions", cpuWidget: "cpuWidgetOptions", cryptoWidget: "cryptoWidgetOptions", dateWidget: "dateWidgetOptions", gpuWidget: "gpuWidgetOptions", memoryWidget: "memoryWidgetOptions", keyboardWidget: "keyboardWidgetOptions", micWidget: "micWidgetOptions", mpdWidget: "mpdWidgetOptions", musicWidget: "musicWidgetOptions", netstatsWidget: "netstatsWidgetOptions", nextMeetingWidget: "nextMeetingWidgetOptions", notificationsWidget: "notificationsWidgetOptions", soundWidget: "soundWidgetOptions", spotifyWidget: "spotifyWidgetOptions", stockWidget: "stockWidgetOptions", timeWidget: "timeWidgetOptions", vpnWidget: "vpnWidgetOptions", githubWidget: "githubWidgetOptions", weatherWidget: "weatherWidgetOptions", wifiWidget: "networkWidgetOptions", youtubeMusicWidget: "youtubeMusicWidgetOptions", zoomWidget: "zoomWidgetOptions", userWidgets: "userWidgets", }; /** * SettingsWidgets component to render widgets setting category. * @param {Object} props - Component properties. * @param {Object} props.newSettings - Object containing current modified settings. * @param {Function} props.setNewSettings - Function allowing to save newly modified settings. */ export default function SettingsWidgets({ newSettings, setNewSettings }) { const [currentWidget, setCurrentWidget] = React.useState(null); const currentSetting = Settings.data[currentWidget]; /** * Removes the current widget setting, */ const removeCurrentWidget = () => { setCurrentWidget(null); }; /** * Prevent checkbox click from propagating to the parent element, * allowing to avoid triggering the widget selection. */ const handleCheckboxClick = (e) => { e.stopPropagation(); Utils.clickEffect(e); }; /** * Updates the current widget based on the clicked element. * @param {string} widget - The key of the widget to update. */ const updateCurrentWidget = (widget) => (e) => { if (widget === "processWidget") return; Utils.clickEffect(e); const widgetKey = settingsKeys[widget]; setCurrentWidget(currentWidget === widgetKey ? null : widgetKey); }; return (