No navigation items yet
diff --git a/src/components/ui/Input.tsx b/src/components/ui/Input.tsx
index e78f2c55..b03574ae 100644
--- a/src/components/ui/Input.tsx
+++ b/src/components/ui/Input.tsx
@@ -1,6 +1,9 @@
-import { forwardRef, useCallback, useMemo } from "react"
+import { Fragment, forwardRef, useCallback, useMemo, useState } from "react"
import type { ReactElement } from "react"
+import { Combobox, Transition } from "@headlessui/react"
+import { CheckIcon, ChevronUpDownIcon } from "@heroicons/react/20/solid"
+
import { cn } from "~/lib/utils"
import { FieldLabel } from "./FieldLabel"
@@ -13,6 +16,7 @@ type InputProps
= {
error?: string
help?: React.ReactNode
multiline?: TMultiline
+ options?: string[]
renderInput?: (props: Omit, "renderInput">) => ReactElement
} & React.ComponentPropsWithRef
@@ -31,6 +35,7 @@ export const Input = forwardRef(function Input<
help,
multiline,
renderInput,
+ options,
...inputProps
}: InputProps,
ref: TMultiline extends true
@@ -56,9 +61,106 @@ export const Input = forwardRef(function Input<
[className, hasAddon, hasPrefix, inputProps, isBlock, ref],
)
+ const [selected, setSelected] = useState()
+ const [query, setQuery] = useState("")
+ const filteredOptions = options
+ ? query === ""
+ ? options
+ : options.filter((option) =>
+ option
+ .toLowerCase()
+ .replace(/\s+/g, "")
+ .includes(query.toLowerCase().replace(/\s+/g, "")),
+ )
+ : []
+
const renderInputComponent = useCallback(() => {
if (renderInput) {
return renderInput(inputComponentProps)
+ } else if (options) {
+ return (
+ {
+ setSelected(value)
+ inputComponentProps.onChange?.({
+ target: {
+ value,
+ },
+ })
+ }}
+ >
+
+
+ option}
+ onChange={(event) => {
+ setQuery(event.target.value)
+ inputComponentProps.onChange?.(event)
+ }}
+ />
+
+
+
+
+
setQuery("")}
+ >
+
+ {filteredOptions.length === 0 && query !== "" ? (
+
+ Nothing found.
+
+ ) : (
+ filteredOptions.map((option) => (
+
+ `relative cursor-default select-none py-2 pl-10 pr-4 ${
+ active ? "bg-accent text-white" : "text-gray-900"
+ }`
+ }
+ value={option}
+ >
+ {({ selected, active }) => (
+ <>
+
+ {option}
+
+ {selected ? (
+
+
+
+ ) : null}
+ >
+ )}
+
+ ))
+ )}
+
+
+
+
+ )
} else if (multiline) {
return
} else {