ui(InputNumber): adding label element in InputNumber Component and … (#3501)
This commit is contained in:
parent
92273b25b3
commit
5ab74f5020
@ -2,9 +2,10 @@ import React, { useState, useCallback } from 'react';
|
|||||||
import IconButton from '../IconButton';
|
import IconButton from '../IconButton';
|
||||||
import Icon from '../Icon';
|
import Icon from '../Icon';
|
||||||
import './InputNumber.css';
|
import './InputNumber.css';
|
||||||
|
import Label from '../Label';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* React Number Input component'
|
* React Number Input component'
|
||||||
* it has two props, value and onChange
|
* it has two props, value and onChange
|
||||||
* value is a number value
|
* value is a number value
|
||||||
* onChange is a function that will be called when the number input is changed
|
* onChange is a function that will be called when the number input is changed
|
||||||
@ -14,6 +15,7 @@ import './InputNumber.css';
|
|||||||
|
|
||||||
const sizesClasses = {
|
const sizesClasses = {
|
||||||
sm: 'w-[45px] h-[28px]',
|
sm: 'w-[45px] h-[28px]',
|
||||||
|
lg: 'w-[206px] h-[35px]',
|
||||||
};
|
};
|
||||||
|
|
||||||
const InputNumber: React.FC<{
|
const InputNumber: React.FC<{
|
||||||
@ -24,6 +26,8 @@ const InputNumber: React.FC<{
|
|||||||
step: number;
|
step: number;
|
||||||
size?: string;
|
size?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
labelClassName?: string;
|
||||||
|
label?: string;
|
||||||
}> = ({
|
}> = ({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
@ -32,6 +36,8 @@ const InputNumber: React.FC<{
|
|||||||
size = 'sm',
|
size = 'sm',
|
||||||
minValue = 0,
|
minValue = 0,
|
||||||
maxValue = 100,
|
maxValue = 100,
|
||||||
|
labelClassName,
|
||||||
|
label,
|
||||||
}) => {
|
}) => {
|
||||||
const [numberValue, setNumberValue] = useState(value);
|
const [numberValue, setNumberValue] = useState(value);
|
||||||
|
|
||||||
@ -76,6 +82,8 @@ const InputNumber: React.FC<{
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div className={'flex flex-col flex-1'}>
|
||||||
|
{label && <Label className={labelClassName} text={label}></Label>}
|
||||||
<div
|
<div
|
||||||
className={`flex items-center bg-black border-2 px-1 overflow-hidden justify-center border-secondary-light rounded-md ${sizesClasses[size]
|
className={`flex items-center bg-black border-2 px-1 overflow-hidden justify-center border-secondary-light rounded-md ${sizesClasses[size]
|
||||||
} ${className ? className : ''}`}
|
} ${className ? className : ''}`}
|
||||||
@ -112,6 +120,7 @@ const InputNumber: React.FC<{
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,7 @@ export {
|
|||||||
IconButton,
|
IconButton,
|
||||||
Input,
|
Input,
|
||||||
InputRange,
|
InputRange,
|
||||||
|
InputNumber,
|
||||||
InputDateRange,
|
InputDateRange,
|
||||||
InputGroup,
|
InputGroup,
|
||||||
InputLabelWrapper,
|
InputLabelWrapper,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user