CHANGED: Types

This commit is contained in:
2024-02-01 16:23:59 +04:00
parent dc4b8baaf8
commit ab4ae37015
19 changed files with 238 additions and 248 deletions

View File

@@ -1,8 +1,8 @@
'use client';
import React, { forwardRef, useState } from 'react';
import { bool, string } from 'prop-types';
import { type TextFieldInterface } from './text-field.types';
import { bool, oneOf, string } from 'prop-types';
import React, { FocusEvent, forwardRef, useState } from 'react';
import { TextFieldInterface } from './text-field.types';
export const TextField = forwardRef<HTMLInputElement, TextFieldInterface>(
(
@@ -15,11 +15,9 @@ export const TextField = forwardRef<HTMLInputElement, TextFieldInterface>(
},
ref,
) => {
const [raised, setRaised] = useState<boolean>(
props.placeholder ?? false,
);
const [raised, setRaised] = useState<boolean>(!props.placeholder);
const callback = (e: any): void => {
const callback = (e: FocusEvent<HTMLInputElement>): void => {
if (
e.type === 'blur' &&
e.target.value.length === 0 &&
@@ -97,7 +95,7 @@ TextField.propTypes = {
withBeforeIcon: bool,
withAfterIcon: bool,
className: string,
variant: string,
variant: oneOf(['filled', 'outlined']),
placeholder: string,
supportingText: string,
};