diff --git a/package.json b/package.json index 3881e23..3e09e3e 100644 --- a/package.json +++ b/package.json @@ -30,22 +30,23 @@ "storybook:build": "storybook build" }, "peerDependencies": { - "react": "18.2.0", - "react-dom": "18.2.0", "@types/react": "18.2.0", "@types/react-dom": "18.2.0", + "react": "18.2.0", + "react-dom": "18.2.0", "tailwindcss": "3.3.5" }, "dependencies": { "@phosphor-icons/react": "2.0.15", + "@toss/use-overlay": "1.3.8", "autoprefixer": "10.4.16", "clsx": "2.0.0", "dayjs": "1.11.10", "postcss": "8.4.31", "react": "18.2.0", "react-dom": "18.2.0", - "react-tooltip": "5.24.0", "react-quill": "2.0.0", + "react-tooltip": "5.24.0", "tailwindcss": "3.3.5" }, "devDependencies": { diff --git a/src/core/components/Input/InputDatePicker/DatePicker.tsx b/src/core/components/Input/InputDatePicker/DatePicker.tsx new file mode 100644 index 0000000..8e05172 --- /dev/null +++ b/src/core/components/Input/InputDatePicker/DatePicker.tsx @@ -0,0 +1,88 @@ +import { useId, useState } from "react"; + +import Button from "../../Button"; +import DatePickerCalendar from "../../Calendar/DatePickerCalendar"; +import { PeriodDates } from "../../Calendar/DatePickerCalendar/types/CalendarComponentProps"; +import Divider from "../../Divider"; +import ModalPopUp from "../../Modal/ModalPopUp"; +import GeneralTab from "../../Tab/GeneralTab/GeneralTab"; +import Typography from "../../Typography"; +import { DatePickerProps } from "./types"; + +const DatePicker = ({ + isOpen, + close, + currentMonth, + disabled, + disabledDates, + useTab = false, +}: DatePickerProps) => { + const id = useId(); + const [ selectedDate, setSelectedDate ] = useState(""); + const [ periodDates, setPeriodDates ] = useState({ + startDate: "", + endDate: "", + }); + const [ tabSelected, setTabSelected ] = useState("selectedDate"); + const tabData = [ + { key: "selectedDate", label: "선택한 기간만 적용" }, + { key: "afterAllDate", label: "시작일부터 모든 날짜 적용" }, + ]; + + const handleClose = () => { + close(periodDates); + }; + + const tabItems = tabData.map(item => ( + ) => { + setTabSelected(e.target.value); + }} + /> + )); + + const onDateClick = (date: string, periodDates: PeriodDates) => { + setSelectedDate(date); + setPeriodDates(periodDates!); + }; + + return ( + +
+
+ + {useTab && } + +
+ +
+
+
+
+ ); +}; + +export default DatePicker; diff --git a/src/core/components/Input/InputDatePicker/InputDatePicker.stories.tsx b/src/core/components/Input/InputDatePicker/InputDatePicker.stories.tsx index eba1e3c..b50b355 100644 --- a/src/core/components/Input/InputDatePicker/InputDatePicker.stories.tsx +++ b/src/core/components/Input/InputDatePicker/InputDatePicker.stories.tsx @@ -1,50 +1,57 @@ -import { useState } from "react"; import { Meta } from "@storybook/react"; -import { PeriodDates } from "@/core/components/Calendar/DatePickerCalendar/types/CalendarComponentProps"; +import { OverlayProvider, useOverlay } from "@toss/use-overlay"; +import ModalPopUp from "../../Modal/ModalPopUp"; import InputDatePicker from "./index"; const meta = { title: "core/Input/InputDatePicker", + parameters: { + layout: "fullscreen", + }, component: InputDatePicker, } satisfies Meta; export default meta; export const Default = () => { - const [ isOpen, setIsOpen ] = useState(false); - const [ selectedDate, setSelectedDate ] = useState(""); - const [ periodDates, setPeriodDates ] = useState({ - startDate: "", - endDate: "", - }); - - const onDateClick = (date: string, periodDates: PeriodDates) => { - setSelectedDate(date); - setPeriodDates(periodDates!); - }; - const onCalendarToggle = () => { - setIsOpen(prev => !prev); - }; + return ( + +