[
{
"fileName": "DropdownFooter.tsx",
"language": "tsx",
"code": "import { useState } from 'react';\nimport { Anchor, Combobox, ScrollArea, Text, TextInput, useCombobox } from '@mantine/core';\n\nconst groceries = [\n '🍎 Apples',\n '🍌 Bananas',\n '🥦 Broccoli',\n '🥕 Carrots',\n '🍫 Chocolate',\n '🍇 Grapes',\n '🍋 Lemon',\n '🥬 Lettuce',\n '🍄 Mushrooms',\n '🍊 Oranges',\n '🥔 Potatoes',\n '🍅 Tomatoes',\n '🥚 Eggs',\n '🥛 Milk',\n '🍞 Bread',\n '🍗 Chicken',\n '🍔 Hamburger',\n '🧀 Cheese',\n '🥩 Steak',\n '🍟 French Fries',\n '🍕 Pizza',\n '🥦 Cauliflower',\n '🥜 Peanuts',\n '🍦 Ice Cream',\n '🍯 Honey',\n '🥖 Baguette',\n '🍣 Sushi',\n '🥝 Kiwi',\n '🍓 Strawberries',\n];\n\nexport function DropdownFooter() {\n const combobox = useCombobox({\n onDropdownClose: () => combobox.resetSelectedOption(),\n });\n\n const [value, setValue] = useState('');\n const shouldFilterOptions = !groceries.some((item) => item === value);\n const filteredOptions = shouldFilterOptions\n ? groceries.filter((item) => item.toLowerCase().includes(value.toLowerCase().trim()))\n : groceries;\n\n const options = filteredOptions.map((item) => (\n \n {item}\n \n ));\n\n return (\n {\n setValue(optionValue);\n combobox.closeDropdown();\n }}\n store={combobox}\n withinPortal={false}\n >\n \n {\n setValue(event.currentTarget.value);\n combobox.openDropdown();\n combobox.updateSelectedOptionIndex();\n }}\n onClick={() => combobox.openDropdown()}\n onFocus={() => combobox.openDropdown()}\n onBlur={() => combobox.closeDropdown()}\n />\n \n\n \n \n \n {options.length === 0 ? Nothing found : options}\n \n \n \n \n Search powered by{' '}\n \n Mantine\n \n \n \n \n \n );\n}\n"
}
]