Skip to content

Commit

Permalink
(#0) Add InputDatePicker Feedback Props
Browse files Browse the repository at this point in the history
  • Loading branch information
cause38 committed Jan 30, 2024
1 parent 0703fa5 commit fd259b9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/core/components/Input/InputBase/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const InputBase = forwardRef(
required,
readOnly,
feedback,
feedbackColor = "error",
...props
}: InputBaseProps<T>,
ref: React.ComponentPropsWithRef<T>["ref"],
Expand All @@ -48,7 +49,7 @@ const InputBase = forwardRef(
{inputComponent && inputComponent}
{!readOnly && endComponent && endComponent}
</div>
{feedback ? <Typography theme = "body-03-regular" color = "error" text = {feedback} /> : null}
{feedback ? <Typography theme = "body-03-regular" color = {feedbackColor} text = {feedback} /> : null}
</Component>
);
});
Expand Down
1 change: 1 addition & 0 deletions src/core/components/Input/InputBase/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export interface InputBaseProps<T extends React.ElementType> extends React.HTMLA
error?: boolean
readOnly?: boolean;
feedback?: React.ReactNode;
feedbackColor?: ThemeColors;
}
4 changes: 4 additions & 0 deletions src/core/components/Input/InputDatePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const InputDatePicker = ({
dateLabel,
closeButtonText,
placeholder,
feedback,
feedbackColor,
}: InputDatePickerProps & HTMLAttributes<HTMLInputElement>) => {
const id = useId();
const [ periodDates, setPeriodDates ] = useState<PeriodDates>({
Expand Down Expand Up @@ -86,6 +88,8 @@ const InputDatePicker = ({
onClick = {handleDatePicker}
label = {label}
required = {required}
feedback = {feedback}
feedbackColor = {feedbackColor}
inputComponent = {
<input
type = "text"
Expand Down
27 changes: 15 additions & 12 deletions src/core/components/Input/InputDatePicker/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DatePickerCalendarProps, PeriodDates } from "@/core/components/Calendar/DatePickerCalendar/types/DatePickerCalendarProps";
import { InputBaseProps } from "../../InputBase/types";

export interface DatePickerProps extends Pick<DatePickerCalendarProps, "useHoliday" | "disabled" | "disabledDates" | "cutoffDate" | "cutoffAfterDate" | "initialDate" | "afterAllDate"> {
variants?: DatePickerCalendarProps["variants"];
Expand All @@ -7,7 +8,7 @@ export interface DatePickerProps extends Pick<DatePickerCalendarProps, "useHolid
isOpen: boolean;
close: DatePickerCalendarProps["onDateClick"];
useTab?: boolean;
dateLabel?: DatePickerCalendarProps["label"]
dateLabel?: DatePickerCalendarProps["label"];
}

type CreateOverlayElement = (props: {
Expand All @@ -21,15 +22,17 @@ export interface ExternalDates {
endDate: string | null;
}

export interface InputDatePickerProps extends Omit<DatePickerProps, "isOpen"| "close" | "periodDates" | "setPeriodDates" | "setIsAfterAllDate"> {
required?: boolean;
inputClassName?: string;
label?: string;
getPeriodDates: DatePickerCalendarProps["onDateClick"];
dateLabel?: DatePickerCalendarProps["label"]
overlay: {
open: (overlayElement: CreateOverlayElement) => void;
close: () => void;
exit: () => void;
export interface InputDatePickerProps extends
Omit<DatePickerProps, "isOpen"| "close" | "periodDates" | "setPeriodDates" | "setIsAfterAllDate">,
Pick<InputBaseProps<"div">, "feedback" | "feedbackColor"> {
required?: boolean;
inputClassName?: string;
label?: string;
getPeriodDates: DatePickerCalendarProps["onDateClick"];
dateLabel?: DatePickerCalendarProps["label"];
overlay: {
open: (overlayElement: CreateOverlayElement) => void;
close: () => void;
exit: () => void;
}
}
}

0 comments on commit fd259b9

Please sign in to comment.