import type { ReactNode } from "react"; import { Center, Group, Loader, Stack, Text } from "@mantine/core"; import { IconCheck } from "@tabler/icons-react"; import { useScopedI18n } from "@homarr/translation/client"; import { interaction } from "../../../../lib/interaction"; export const PreferenceDetailHeader = ({ titleKey }: { titleKey: string }) => { const tOption = useScopedI18n("search.mode.command.group.preferences.option"); const t = useScopedI18n("search.mode.command.group.preferences"); return ( {tOption(titleKey as never)} {t("children.detail.backHint")} ); }; export const createCheckmarkPreferenceAction = ({ key, label, labelContent, isSelected, onSelect, dimmed, isPending, }: { key: string; label?: string; labelContent?: ReactNode; isSelected: boolean; onSelect: () => void; dimmed?: boolean; isPending?: boolean; }) => ({ key, Component() { return ( {labelContent ?? {label}} {isSelected && } ); }, useInteraction: interaction.javaScript(() => ({ onSelect: isPending ? () => undefined : onSelect, closeSpotlightOnTrigger: false, })), }); export const createLoadingPreferenceAction = () => ({ key: "loading", Component() { return (
); }, useInteraction: interaction.javaScript(() => ({ onSelect: () => undefined, closeSpotlightOnTrigger: false, })), });