Skip to content

Commit

Permalink
Merge pull request #780 from invoiceninja/801-datepicker-fixes
Browse files Browse the repository at this point in the history
Use native datepicker instead of custom solution
  • Loading branch information
beganovich authored Jun 16, 2023
2 parents e42c1ff + f8f732e commit 6260c2f
Showing 1 changed file with 27 additions and 40 deletions.
67 changes: 27 additions & 40 deletions src/components/forms/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { DebounceInput } from 'react-debounce-input';
import { AiFillEye, AiFillEyeInvisible } from 'react-icons/ai';
import CommonProps from '../../common/interfaces/common-props.interface';
import { InputLabel } from './InputLabel';
import { DatePicker } from '$app/components/forms/Datepicker';

interface Props extends CommonProps {
label?: string | null;
Expand Down Expand Up @@ -64,45 +63,33 @@ export function InputField(props: Props) {
)}

<div className="relative">
{props.type === 'date' ? (
<DatePicker
id={props.id}
required={props.required}
value={props.value}
onChange={props.onChange}
onValueChange={props.onValueChange}
disabled={props.disabled}
minDate={props.min}
/>
) : (
<DebounceInput
min={props.min}
maxLength={props.maxLength}
disabled={props.disabled}
element={props.element || 'input'}
inputRef={props.innerRef}
debounceTimeout={props.debounceTimeout ?? 300}
required={props.required}
id={props.id}
type={inputType}
className={classNames(
`w-full py-2 px-3 rounded text-sm text-gray-900 dark:bg-gray-800 dark:border-transparent dark:text-gray-100 disabled:bg-gray-100 disabled:cursor-not-allowed ${props.className}`,
{
'border border-gray-300': props.border !== false,
}
)}
placeholder={props.placeholder || ''}
onChange={(event) => {
props.onValueChange && props.onValueChange(event.target.value);
props.onChange && props.onChange(event);
}}
value={props.value}
list={props.list}
rows={props.textareaRows || 5}
step={props.step}
data-cy={props.cypressRef}
/>
)}
<DebounceInput
min={props.min}
maxLength={props.maxLength}
disabled={props.disabled}
element={props.element || 'input'}
inputRef={props.innerRef}
debounceTimeout={props.debounceTimeout ?? 300}
required={props.required}
id={props.id}
type={inputType}
className={classNames(
`w-full py-2 px-3 rounded text-sm text-gray-900 dark:bg-gray-800 dark:border-transparent dark:text-gray-100 disabled:bg-gray-100 disabled:cursor-not-allowed ${props.className}`,
{
'border border-gray-300': props.border !== false,
}
)}
placeholder={props.placeholder || ''}
onChange={(event) => {
props.onValueChange && props.onValueChange(event.target.value);
props.onChange && props.onChange(event);
}}
value={props.value}
list={props.list}
rows={props.textareaRows || 5}
step={props.step}
data-cy={props.cypressRef}
/>

{isInitialTypePassword && (
<span className="absolute top-1/4 right-3 cursor-pointer">
Expand Down

0 comments on commit 6260c2f

Please sign in to comment.