Skip to content

Commit

Permalink
(#0) npm publish (0.0.89)
Browse files Browse the repository at this point in the history
  • Loading branch information
baegofda committed Dec 7, 2023
1 parent 3a8057b commit f5b3787
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bbodek-ui",
"version": "0.0.88",
"version": "0.0.89",
"type": "module",
"author": "Bbodek",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import clsx from "clsx";

import { CalendarDateDto } from "@/core/components/Calendar/common/types/CalendarDateDto";
import { PeriodDates } from "../types/CalendarComponentProps";

Expand All @@ -20,7 +21,6 @@ export const CalendarComponentDayText = ({
const isStartDate = isPeriod && periodDates.startDate === currentDate;
const isEndDate = isPeriod && periodDates.endDate === currentDate;
const singleSelectedDate = (periodDates.startDate && !periodDates.endDate) && currentDate === periodDates.startDate;
console.log(isStartDate);

return (
<div
Expand Down
8 changes: 7 additions & 1 deletion src/core/components/Input/InputDatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useId, useState } from "react";
import { useEffect, useId, useState } from "react";

import Button from "../../Button";
import DatePickerCalendar from "../../Calendar/DatePickerCalendar";
Expand All @@ -15,6 +15,7 @@ const DatePicker = ({
currentMonth,
disabled,
disabledDates,
externalDates,
useTab = false,
}: DatePickerProps) => {
const id = useId();
Expand All @@ -23,6 +24,7 @@ const DatePicker = ({
startDate: "",
endDate: "",
});

const [ tabSelected, setTabSelected ] = useState("selectedDate");
const tabData = [
{ key: "selectedDate", label: "선택한 기간만 적용" },
Expand All @@ -33,6 +35,10 @@ const DatePicker = ({
close(periodDates);
};

useEffect(() => {
externalDates && setPeriodDates(externalDates);
}, [externalDates]);

const tabItems = tabData.map(item => (
<GeneralTab.Item
key = {item.key}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meta } from "@storybook/react";

import { OverlayProvider, useOverlay } from "@toss/use-overlay";
import { useState } from "react";

import { PeriodDates } from "../../Calendar/DatePickerCalendar/types/CalendarComponentProps";
import ModalPopUp from "../../Modal/ModalPopUp";
import InputDatePicker from "./index";
Expand All @@ -17,12 +18,19 @@ export default meta;

const DefaultLayout = () => {
const overlay = useOverlay();
const [ myDates, setMyDates ] = useState({
startDate: "",
endDate: "",
});
const getDate = (periodDates: PeriodDates) => console.log(periodDates);

const onDatesClick = () => setMyDates({ startDate: "22222", endDate: "1111" });

return (
<div className = "flex gap-2">
<div className = "w-[500px]">
<InputDatePicker overlay = {overlay} useTab getPeriodDates = {getDate}/>
<button onClick = {onDatesClick}>날짜 변경</button>
<InputDatePicker overlay = {overlay} useTab getPeriodDates = {getDate} externalDates = {myDates} />
</div>
</div>
);
Expand All @@ -46,7 +54,7 @@ const InputDatePickerInModalPopUpLayout = () => {
overlay.open(({ isOpen }) => {
return (
<ModalPopUp isOpen = {isOpen}>
<InputDatePicker overlay = {inputDatePickerOverlay} useTab = {false} getPeriodDates = {getDate}/>
<InputDatePicker overlay = {inputDatePickerOverlay} useTab = {false} getPeriodDates = {getDate} />
</ModalPopUp>
);
});
Expand Down
8 changes: 7 additions & 1 deletion src/core/components/Input/InputDatePicker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CalendarBlank } from "@phosphor-icons/react";
import dayjs from "dayjs";
import { useState } from "react";
import { useEffect, useState } from "react";

import { PeriodDates } from "../../Calendar/DatePickerCalendar/types/CalendarComponentProps";
import Typography from "../../Typography";
Expand All @@ -12,6 +12,7 @@ const InputDatePicker = ({
disabledDates,
getPeriodDates,
currentMonth,
externalDates,
useTab = false,
disabled = false,
}: InputDatePickerProps) => {
Expand All @@ -34,6 +35,7 @@ const InputDatePicker = ({
getPeriodDates(periodDates);
close();
}}
externalDates = {periodDates}
useTab = {useTab}
disabledDates = {disabledDates}/>
));
Expand All @@ -46,6 +48,10 @@ const InputDatePicker = ({
setPeriodDates(periodDates);
};

useEffect(() => {
externalDates && setPeriodDates(externalDates);
}, [externalDates]);

return (
<div>
<button
Expand Down
3 changes: 2 additions & 1 deletion src/core/components/Input/InputDatePicker/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CalendarComponentProps, PeriodDates } from "@/core/components/Calendar/DatePickerCalendar/types/CalendarComponentProps";

export interface DatePickerProps extends Pick<CalendarComponentProps, "currentMonth" | "disabled" | "disabledDates"> {
externalDates?: PeriodDates;
isOpen: boolean;
close: (periodDates: PeriodDates) => void;
useTab?: boolean;
Expand All @@ -12,7 +13,7 @@ type CreateOverlayElement = (props: {
exit: () => void;
}) => JSX.Element;

export interface InputDatePickerProps extends Omit<DatePickerProps, "isOpen"| "close"> {
export interface InputDatePickerProps extends Omit<DatePickerProps, "isOpen"| "close" | "periodDates" | "setPeriodDates"> {
getPeriodDates: (periodDates: PeriodDates) => void;
overlay: {
open: (overlayElement: CreateOverlayElement) => void;
Expand Down

0 comments on commit f5b3787

Please sign in to comment.