delete 4 files and update 2 files

master
mahdi 3 years ago
parent 81dc16dd55
commit 9b4ca72c73
  1. 0
      src/components/AnimatedInput/Input.js
  2. 0
      src/components/AnimatedInput/fixNumbers.js
  3. 4
      src/components/FormInput/index.js
  4. 22
      src/components/TestComponentNew/fixNumbers.js
  5. 49
      src/components/TestComponentNew/index.js
  6. 66
      src/components/TestComponentNew/input.js

@ -1,8 +1,8 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import DateRangePicker from "../DateRangePicker";
import Input from "./Input"; import DateRangePicker from "../DateRangePicker";
import Input from "../AnimatedInput/Input";
const FormInput = () => { const FormInput = () => {
const { register, getValues } = useForm(); const { register, getValues } = useForm();

@ -1,22 +0,0 @@
const persianNumbers = [
/۰/g,
/۱/g,
/۲/g,
/۳/g,
/۴/g,
/۵/g,
/۶/g,
/۷/g,
/۸/g,
/۹/g,
],
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
fixNumbers = function (str) {
if (typeof str === "string") {
for (var i = 0; i < 10; i++) {
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
}
}
return str;
};
export default fixNumbers;

@ -1,54 +1,7 @@
import React from "react"; import React from "react";
import { useForm } from "react-hook-form";
import Input from "../FormInput/Input";
const TestComponentNew = () => { const TestComponentNew = () => {
const { register, getValues } = useForm(); return <div>TestComponentNew</div>;
return (
<div>
<div className="flex mx-72 justify-between divide-x-2 divide-x-reverse bg-red-50">
<div className="flex-grow text-center font-bold bg-blue-400 px-5">
<Input
register={register("firstName")}
// defaultValue={info?.firstName}
label="نام "
/>
<Input
register={register("lastName")}
// defaultValue={info?.lastName}
label="نام خانوادگی"
/>
</div>
<div className="flex-grow text-center font-bold bg-blue-400 px-5">
<Input
register={register("firstName")}
// defaultValue={info?.firstName}
label="نام "
/>
<Input
register={register("lastName")}
// defaultValue={info?.lastName}
label="نام خانوادگی"
/>
</div>
<div className="flex-grow text-center font-bold bg-blue-400 px-5">
<Input
register={register("firstName")}
// defaultValue={info?.firstName}
label="نام "
/>
<Input
register={register("lastName")}
// defaultValue={info?.lastName}
label="نام خانوادگی"
/>
</div>
</div>
</div>
);
}; };
export default TestComponentNew; export default TestComponentNew;

@ -1,66 +0,0 @@
import fixNumbers from "./fixNumbers";
import { useState } from "react";
const Input = ({
defaultValue,
set,
label,
className,
type,
maxLength,
max,
min,
register,
}) => {
const [value, setValue] = useState(defaultValue);
return (
<div
className={
"h-full rounded border border-color7 mx-1 relative flex items-center flex-row-reverse bg-color2_5 " +
className +
(value ? " border-blue-500 bg-white border rounded" : " bg-transparent")
}
>
<div
className={
" text-sm absolute transition-all duration-300 pointer-events-none px-3 PY-2 text-left transform translate-x-[-10px] " +
(value
? `text-blue-500 bg-white top-[-10px]`
: "text-color19 top-[20px]")
}
>
{label}
</div>
{type !== "textarea" ? (
<input
{...register}
maxLength={maxLength}
value={value}
type={"text"}
className={"rtl w-full h-full px-4 outline-0 "}
onChange={(e) => setValue(e.target.value)}
inputMode={type === "number" ? "numeric" : ""}
onInput={(e) => {
let value = e.target.value;
if (type === "number")
value = fixNumbers(value).replace(/[^\d.-]/g, "");
if (maxLength && value.length > maxLength)
value = value.slice(0, maxLength);
if (!isNaN(max) && +e.target.value > max) value = max;
if (!isNaN(min) && +e.target.value < min) value = min;
e.target.value = value;
}}
/>
) : (
<textarea
{...register}
className={"rtl w-full h-full p-4 outline-0 resize-none"}
onChange={(e) => setValue(e.target.value)}
>
{value}
</textarea>
)}
</div>
);
};
export default Input;
Loading…
Cancel
Save