[ { "fileName": "SelectOptionComponent.tsx", "language": "tsx", "code": "import { useState } from 'react';\nimport { Combobox, Group, Input, InputBase, Text, useCombobox } from '@mantine/core';\n\ninterface Item {\n emoji: string;\n value: string;\n description: string;\n}\n\nconst groceries: Item[] = [\n { emoji: '🍎', value: 'Apples', description: 'Crisp and refreshing fruit' },\n { emoji: '🍌', value: 'Bananas', description: 'Naturally sweet and potassium-rich fruit' },\n { emoji: '🥦', value: 'Broccoli', description: 'Nutrient-packed green vegetable' },\n { emoji: '🥕', value: 'Carrots', description: 'Crunchy and vitamin-rich root vegetable' },\n { emoji: '🍫', value: 'Chocolate', description: 'Indulgent and decadent treat' },\n];\n\nfunction SelectOption({ emoji, value, description }: Item) {\n return (\n \n {emoji}\n \n \n {value}\n \n \n {description}\n \n \n \n );\n}\n\nexport function SelectOptionComponent() {\n const combobox = useCombobox({\n onDropdownClose: () => combobox.resetSelectedOption(),\n });\n\n const [value, setValue] = useState(null);\n const selectedOption = groceries.find((item) => item.value === value);\n\n const options = groceries.map((item) => (\n \n \n \n ));\n\n return (\n {\n setValue(val);\n combobox.closeDropdown();\n }}\n >\n \n }\n onClick={() => combobox.toggleDropdown()}\n rightSectionPointerEvents=\"none\"\n multiline\n >\n {selectedOption ? (\n \n ) : (\n Pick value\n )}\n \n \n\n \n {options}\n \n \n );\n}\n" } ]