"use client"; import React from "react"; import { Combobox, Group, InputBase, Loader, ScrollArea, Text, useCombobox } from "@mantine/core"; import { IconCheck } from "@tabler/icons-react"; import type { SupportedLanguage } from "@homarr/translation"; import { localeConfigurations, supportedLanguages } from "@homarr/translation"; import { LanguageIcon } from "./language-icon"; interface LanguageComboboxProps { label?: string; value: SupportedLanguage; onChange: (value: SupportedLanguage) => void; isPending?: boolean; width?: string; withinPortal?: boolean; } export const LanguageCombobox = ({ label, value, onChange, isPending, width, withinPortal = false, }: LanguageComboboxProps) => { const combobox = useCombobox({ onDropdownClose: () => combobox.resetSelectedOption() }); return ( { onChange(nextValue as SupportedLanguage); combobox.closeDropdown(); }} > : null} rightSection={} rightSectionPointerEvents="none" onClick={() => combobox.toggleDropdown()} variant="filled" w={width} > {supportedLanguages.map((locale) => ( ))} ); }; const OptionItem = ({ currentLocale, localeKey, showCheck, }: { currentLocale: SupportedLanguage; localeKey: SupportedLanguage; showCheck?: boolean; }) => ( {localeConfigurations[localeKey].name} ({localeConfigurations[localeKey].translatedName}) {showCheck && localeKey === currentLocale && } );