Made Mission marker DB compatible
This commit is contained in:
47
packages/ui/src/components/Input.tsx
Normal file
47
packages/ui/src/components/Input.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import React from "react";
|
||||
import {
|
||||
FieldValues,
|
||||
Path,
|
||||
RegisterOptions,
|
||||
UseFormReturn,
|
||||
} from "react-hook-form";
|
||||
import { cn } from "../helper/cn";
|
||||
|
||||
interface InputProps<T extends FieldValues>
|
||||
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "form"> {
|
||||
name: Path<T>;
|
||||
form: UseFormReturn<T>;
|
||||
formOptions?: RegisterOptions<T>;
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export const Input = <T extends FieldValues>({
|
||||
name,
|
||||
label = name,
|
||||
placeholder = label,
|
||||
form,
|
||||
formOptions,
|
||||
className,
|
||||
...inputProps
|
||||
}: InputProps<T>) => {
|
||||
return (
|
||||
<label className="floating-label w-full mt-5">
|
||||
<span className="text-lg flex items-center gap-2">{label}</span>
|
||||
<input
|
||||
{...form.register(name, formOptions)}
|
||||
className={cn(
|
||||
"input input-bordered w-full placeholder:text-neutral-600",
|
||||
className,
|
||||
)}
|
||||
placeholder={placeholder}
|
||||
{...inputProps}
|
||||
/>
|
||||
{form.formState.errors[name] && (
|
||||
<p className="text-error">
|
||||
{form.formState.errors[name].message as string}
|
||||
</p>
|
||||
)}
|
||||
</label>
|
||||
);
|
||||
};
|
||||
1
packages/ui/src/components/index.ts
Normal file
1
packages/ui/src/components/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./Input";
|
||||
6
packages/ui/src/helper/cn.ts
Normal file
6
packages/ui/src/helper/cn.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import clsx, { ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export const cn = (...inputs: ClassValue[]) => {
|
||||
return twMerge(clsx(inputs));
|
||||
};
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./helper/event";
|
||||
export * from "./components";
|
||||
|
||||
Reference in New Issue
Block a user