diff --git a/packages/design-system/src/ui/input/combobox.tsx b/packages/design-system/src/ui/input/combobox.tsx index d9c6d86..d752616 100644 --- a/packages/design-system/src/ui/input/combobox.tsx +++ b/packages/design-system/src/ui/input/combobox.tsx @@ -11,6 +11,7 @@ import { twMerge } from "tailwind-merge"; import * as React from "react"; import { forwardRef, useImperativeHandle, useRef } from "react"; import { ClearButton } from "./clearButton"; +import { ChevronDownIcon } from "../../icons/ChevronDown"; const Combobox = React.forwardRef< React.ElementRef, @@ -69,6 +70,9 @@ const Input = forwardRef< onChange={handleChange} {...props} /> + {showClearButton && } ); diff --git a/packages/design-system/src/ui/input/inputField.tsx b/packages/design-system/src/ui/input/inputField.tsx index ac03d3c..ad5938e 100644 --- a/packages/design-system/src/ui/input/inputField.tsx +++ b/packages/design-system/src/ui/input/inputField.tsx @@ -26,7 +26,7 @@ type Props = { const InputField = forwardRef, Props>( ( { label, error, showClearButton, icon, placeholder, ...props }: Props, - ref, + ref ) => { // if error is present, we pass it to all the sub-components const hasError = !!error; @@ -42,6 +42,11 @@ const InputField = forwardRef, Props>( return ( + {label && ( + + )} {hasIcon && } , Props>( placeholder={showPlaceholder ? placeholder : undefined} showClearButton={showClearButton} /> - {label && ( - - )} + {hasError && ( <> - - {/*Custom error - must be text as in zod validator*/} - {`Fix the ${label?.toLowerCase()}`} - + {error} )} ); - }, + } ); export { InputField }; diff --git a/packages/design-system/src/ui/input/selectField.tsx b/packages/design-system/src/ui/input/selectField.tsx index ecd8be9..02deaac 100644 --- a/packages/design-system/src/ui/input/selectField.tsx +++ b/packages/design-system/src/ui/input/selectField.tsx @@ -1,4 +1,4 @@ -import React, { forwardRef } from "react"; +import React, { forwardRef, useState } from "react"; import { Description } from "./description"; import { Field } from "./field"; import { Combobox, Input, Options, Option, Button } from "./combobox"; @@ -24,6 +24,14 @@ type Props = { icon?: React.ComponentType>; } & InheritedInputProps; +// Test options +const options = [ + { id: 1, name: "Option 1" }, + { id: 2, name: "Option 2" }, + { id: 3, name: "Option 3" }, + { id: 4, name: "Option 4" }, +]; + const SelectInputField = forwardRef, Props>( ( { label, error, showClearButton, icon, placeholder, ...props }: Props, @@ -41,28 +49,49 @@ const SelectInputField = forwardRef, Props>( const Icon = icon; const hasIcon = !!Icon; + const [selectedOption, setSelectedOption] = useState(options[0]); + const [query, setQuery] = useState(""); + + //Filtering the options based on the query + const filteredOptions = + query === "" + ? options + : options.filter((option) => { + return option.name.toLowerCase().includes(query.toLowerCase()); + }); + return ( {hasIcon && } - -
- & { - defaultValue?: string; - })} - ref={ref} - className="k1-bg-transparent k1-outline-none k1-flex-grow" - placeholder={showPlaceholder ? placeholder : undefined} - showClearButton={showClearButton} - /> - -
- - - - + setQuery("")} + > + & { + defaultValue?: string; + })} + ref={ref} + displayValue={(option) => option?.name} + className={twMerge( + "k1-bg-transparent k1-outline-none k1-flex-grow" + )} + placeholder={showPlaceholder ? placeholder : undefined} + showClearButton={showClearButton} + onChange={(event) => setQuery(event.target.value)} + /> + + {filteredOptions.map((option) => ( + + ))}