diff --git a/packages/ui-next/src/components/primitives/input.tsx b/packages/ui-next/src/components/primitives/input.tsx index 49b576664..31e9043ea 100644 --- a/packages/ui-next/src/components/primitives/input.tsx +++ b/packages/ui-next/src/components/primitives/input.tsx @@ -1,21 +1,42 @@ import * as React from "react"; import { cn } from "@/utils"; +import { TimesCircleIcon } from "../icons"; +import { Button } from "./button"; +import { Spinner } from "../spinner"; -export type InputProps = React.InputHTMLAttributes; +export type InputProps = React.InputHTMLAttributes & { + isLoading?: boolean; + onClear?: () => void; +}; const Input = React.forwardRef( - ({ className, type, ...props }, ref) => { + ({ isLoading, onClear, className, type, ...props }, ref) => { return ( - + + {isLoading && ( + )} - ref={ref} - {...props} - /> + {!isLoading && onClear && ( + + )} + ); }, ); diff --git a/packages/ui-next/src/stories/input.stories.tsx b/packages/ui-next/src/stories/input.stories.tsx index d52395d20..2bc64ae59 100644 --- a/packages/ui-next/src/stories/input.stories.tsx +++ b/packages/ui-next/src/stories/input.stories.tsx @@ -1,4 +1,4 @@ -import { Input as UIInput } from "@/components/primitives/input"; +import { Input } from "@/components/primitives/input"; import { Meta, StoryObj } from "@storybook/react"; const meta: Meta = { @@ -11,8 +11,25 @@ export default meta; type Story = StoryObj; -export const Default: Story = {}; +export const Default: Story = { + args: { + type: "email", + placeholder: "Email", + }, +}; + +export const Loading: Story = { + args: { + value: "Some text value", + isLoading: true, + }, +}; -function Input() { - return ; -} +export const Clear: Story = { + args: { + value: "Some text value", + onClear: () => { + console.log("cleared!"); + }, + }, +};