tiefen_space_h5/components/OwnInput/index.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-10-09 16:59:04 +08:00
"use client";
import React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faClose } from "@fortawesome/free-solid-svg-icons";
// import styles from "./index.module.scss";
export default function OwnInput({
value,
onChange,
type = "text",
name,
placeholder,
clearable,
disabled = false,
2024-11-05 20:37:22 +08:00
className,
inputClassName = "",
2024-11-05 20:37:22 +08:00
id,
2024-11-14 20:04:20 +08:00
maxLength = 999,
2024-10-09 16:59:04 +08:00
}) {
return (
2024-11-05 20:37:22 +08:00
<div className={`flex flex-1 relative ${className}`}>
2024-10-09 16:59:04 +08:00
<input
2024-11-05 20:37:22 +08:00
id={id}
2024-10-09 16:59:04 +08:00
placeholder={placeholder}
disabled={disabled}
name={name}
type={type}
2024-11-14 20:04:20 +08:00
maxLength={maxLength}
2024-10-09 16:59:04 +08:00
onChange={(e) => onChange(e.target?.value)}
value={value}
2024-11-14 18:56:24 +08:00
className={`w-full placeholder:text-[#FFFFFF80] text-[16px] focus:text-[16px] ${inputClassName}`}
2024-10-09 16:59:04 +08:00
/>
{clearable && value != "" && (
<div className="w-4 h-4 absolute right-2 top-[2px] flex justify-center items-center bg-[#ffffff33] p-1 rounded-full">
<FontAwesomeIcon
color="#ffffff40"
icon={faClose}
style={{ maxWidth: "12px" }}
onClick={() => {
onChange && onChange("");
}}
/>
</div>
)}
</div>
);
}