@bds-web/ui 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/CalendarIcon/index.d.ts +2 -0
  2. package/dist/CalendarIcon/index.d.ts.map +1 -0
  3. package/dist/CalendarIcon/index.js +1 -0
  4. package/dist/CalendarIcon/ui/index.d.ts +7 -0
  5. package/dist/CalendarIcon/ui/index.d.ts.map +1 -0
  6. package/dist/CalendarIcon/ui/index.js +5 -0
  7. package/dist/ChevronIcon/index.d.ts +2 -0
  8. package/dist/ChevronIcon/index.d.ts.map +1 -0
  9. package/dist/ChevronIcon/index.js +1 -0
  10. package/dist/ChevronIcon/ui/index.d.ts +8 -0
  11. package/dist/ChevronIcon/ui/index.d.ts.map +1 -0
  12. package/dist/ChevronIcon/ui/index.js +5 -0
  13. package/dist/DatePicker/constants/index.d.ts +10 -0
  14. package/dist/DatePicker/constants/index.d.ts.map +1 -0
  15. package/dist/DatePicker/constants/index.js +9 -0
  16. package/dist/DatePicker/hooks/useClickOutside.d.ts +3 -0
  17. package/dist/DatePicker/hooks/useClickOutside.d.ts.map +1 -0
  18. package/dist/DatePicker/hooks/useClickOutside.js +22 -0
  19. package/dist/DatePicker/hooks/useDatePicker.d.ts +13 -0
  20. package/dist/DatePicker/hooks/useDatePicker.d.ts.map +1 -0
  21. package/dist/DatePicker/hooks/useDatePicker.js +28 -0
  22. package/dist/DatePicker/hooks/useTimePicker.d.ts +13 -0
  23. package/dist/DatePicker/hooks/useTimePicker.d.ts.map +1 -0
  24. package/dist/DatePicker/hooks/useTimePicker.js +72 -0
  25. package/dist/DatePicker/index.d.ts +3 -0
  26. package/dist/DatePicker/index.d.ts.map +1 -0
  27. package/dist/DatePicker/index.js +2 -0
  28. package/dist/DatePicker/types/calendar-cell.d.ts +5 -0
  29. package/dist/DatePicker/types/calendar-cell.d.ts.map +1 -0
  30. package/dist/DatePicker/types/calendar-cell.js +2 -0
  31. package/dist/DatePicker/types/props.d.ts +7 -0
  32. package/dist/DatePicker/types/props.d.ts.map +1 -0
  33. package/dist/DatePicker/types/props.js +1 -0
  34. package/dist/DatePicker/types/time.d.ts +5 -0
  35. package/dist/DatePicker/types/time.d.ts.map +1 -0
  36. package/dist/DatePicker/types/time.js +1 -0
  37. package/dist/DatePicker/ui/DatePickerPortal.d.ts +9 -0
  38. package/dist/DatePicker/ui/DatePickerPortal.d.ts.map +1 -0
  39. package/dist/DatePicker/ui/DatePickerPortal.js +30 -0
  40. package/dist/DatePicker/ui/index.d.ts +3 -0
  41. package/dist/DatePicker/ui/index.d.ts.map +1 -0
  42. package/dist/DatePicker/ui/index.js +21 -0
  43. package/dist/DatePicker/ui/style.d.ts +54 -0
  44. package/dist/DatePicker/ui/style.d.ts.map +1 -0
  45. package/dist/DatePicker/ui/style.js +82 -0
  46. package/dist/DatePicker/utils/get-current-time.d.ts +5 -0
  47. package/dist/DatePicker/utils/get-current-time.d.ts.map +1 -0
  48. package/dist/DatePicker/utils/get-current-time.js +7 -0
  49. package/dist/DatePicker/utils/get-is-past.d.ts +2 -0
  50. package/dist/DatePicker/utils/get-is-past.d.ts.map +1 -0
  51. package/dist/DatePicker/utils/get-is-past.js +5 -0
  52. package/dist/DatePicker/utils/get-month-calendar.d.ts +3 -0
  53. package/dist/DatePicker/utils/get-month-calendar.d.ts.map +1 -0
  54. package/dist/DatePicker/utils/get-month-calendar.js +16 -0
  55. package/dist/DatePicker/utils/pad.d.ts +2 -0
  56. package/dist/DatePicker/utils/pad.d.ts.map +1 -0
  57. package/dist/DatePicker/utils/pad.js +1 -0
  58. package/dist/DatePicker/utils/parse-date.d.ts +2 -0
  59. package/dist/DatePicker/utils/parse-date.d.ts.map +1 -0
  60. package/dist/DatePicker/utils/parse-date.js +6 -0
  61. package/dist/index.d.ts +1 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +1 -0
  64. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ export * from "./ui";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/CalendarIcon/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./ui";
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ size?: number;
3
+ pointer?: boolean;
4
+ }
5
+ export declare const CalendarIcon: ({ size, pointer }: Props) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/CalendarIcon/ui/index.tsx"],"names":[],"mappings":"AAEA,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,GAAI,mBAAgC,KAAK,4CAejE,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export const CalendarIcon = ({ size = 16, pointer = false }) => {
4
+ return (_jsx("svg", { width: size * (14 / 16), height: size, viewBox: "0 0 14 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: { cursor: pointer ? "pointer" : "default" }, children: _jsx("path", { d: "M1.55556 16C1.12778 16 0.761574 15.8433 0.456944 15.53C0.152315 15.2167 0 14.84 0 14.4V3.2C0 2.76 0.152315 2.38333 0.456944 2.07C0.761574 1.75667 1.12778 1.6 1.55556 1.6H2.33333V0H3.88889V1.6H10.1111V0H11.6667V1.6H12.4444C12.8722 1.6 13.2384 1.75667 13.5431 2.07C13.8477 2.38333 14 2.76 14 3.2V14.4C14 14.84 13.8477 15.2167 13.5431 15.53C13.2384 15.8433 12.8722 16 12.4444 16H1.55556ZM1.55556 14.4H12.4444V6.4H1.55556V14.4ZM1.55556 4.8H12.4444V3.2H1.55556V4.8Z", fill: "currentColor" }) }));
5
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./ui";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ChevronIcon/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./ui";
@@ -0,0 +1,8 @@
1
+ interface Props {
2
+ className?: string;
3
+ size?: number;
4
+ rotate?: number;
5
+ }
6
+ export declare const ChevronIcon: ({ className, size, rotate }: Props) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ChevronIcon/ui/index.tsx"],"names":[],"mappings":"AAEA,UAAU,KAAK;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,WAAW,GAAI,6BAAuC,KAAK,4CA6CvE,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ export const ChevronIcon = ({ className, size = 16, rotate = 90 }) => {
4
+ return (_jsxs("svg", { width: size, height: size, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, style: { transform: `rotate(${rotate}deg)` }, children: [_jsx("mask", { id: "mask0_13542_2460", style: { maskType: "alpha" }, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: size, height: size, children: _jsx("rect", { y: size, width: size, height: size, rx: "2", transform: "rotate(-90 0 16)", fill: "#D9D9D9" }) }), _jsxs("g", { mask: "url(#mask0_13542_2460)", children: [_jsx("path", { d: "M14.6666 5.33333L7.99998 12L1.33331 5.33333L2.51665 4.15L7.99998 9.63333L13.4833 4.15L14.6666 5.33333Z", fill: "currentColor" }), _jsx("path", { d: "M14.6666 5.33333L7.99998 12L1.33331 5.33333L2.51665 4.15L7.99998 9.63333L13.4833 4.15L14.6666 5.33333Z", fill: "currentColor", fillOpacity: "0.2" }), _jsx("path", { d: "M14.6666 5.33333L7.99998 12L1.33331 5.33333L2.51665 4.15L7.99998 9.63333L13.4833 4.15L14.6666 5.33333Z", fill: "currentColor", fillOpacity: "0.2" })] })] }));
5
+ };
@@ -0,0 +1,10 @@
1
+ export declare const DAYS: readonly ["일", "월", "화", "수", "목", "금", "토"];
2
+ export declare const ITEM_HEIGHT = 44;
3
+ export declare const VISIBLE_COUNT = 5;
4
+ export declare const OFFSET: number;
5
+ export declare const HOURS: number[];
6
+ export declare const MINUTES: number[];
7
+ export declare const REPEAT_COUNT = 3;
8
+ export declare const INFINITE_HOURS: any[];
9
+ export declare const INFINITE_MINUTES: any[];
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/constants/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,8CAA+C,CAAC;AAEjE,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,MAAM,QAAgC,CAAC;AAEpD,eAAO,MAAM,KAAK,UAA0C,CAAC;AAC7D,eAAO,MAAM,OAAO,UAA0C,CAAC;AAE/D,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,cAAc,OAAyC,CAAC;AACrE,eAAO,MAAM,gBAAgB,OAA2C,CAAC"}
@@ -0,0 +1,9 @@
1
+ export const DAYS = ['일', '월', '화', '수', '목', '금', '토'];
2
+ export const ITEM_HEIGHT = 44;
3
+ export const VISIBLE_COUNT = 5;
4
+ export const OFFSET = Math.floor(VISIBLE_COUNT / 2);
5
+ export const HOURS = Array.from({ length: 24 }, (_, i) => i);
6
+ export const MINUTES = Array.from({ length: 60 }, (_, i) => i);
7
+ export const REPEAT_COUNT = 3;
8
+ export const INFINITE_HOURS = Array(REPEAT_COUNT).fill(HOURS).flat();
9
+ export const INFINITE_MINUTES = Array(REPEAT_COUNT).fill(MINUTES).flat();
@@ -0,0 +1,3 @@
1
+ import { RefObject } from "react";
2
+ export declare const useClickOutside: <T extends HTMLElement>(onClickOutside: () => void, ignoreRefs?: RefObject<HTMLElement | null>[]) => RefObject<T | null>;
3
+ //# sourceMappingURL=useClickOutside.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useClickOutside.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/hooks/useClickOutside.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,WAAW,EACnD,gBAAgB,MAAM,IAAI,EAC1B,aAAY,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAAO,wBA+BjD,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useEffect, useRef } from "react";
3
+ export const useClickOutside = (onClickOutside, ignoreRefs = []) => {
4
+ const ref = useRef(null);
5
+ useEffect(() => {
6
+ const handler = (e) => {
7
+ const target = e.target;
8
+ if (!ref.current)
9
+ return;
10
+ if (ref.current.contains(target))
11
+ return;
12
+ if (ignoreRefs.some(ignoreRef => ignoreRef.current &&
13
+ ignoreRef.current.contains(target))) {
14
+ return;
15
+ }
16
+ onClickOutside();
17
+ };
18
+ document.addEventListener("mousedown", handler);
19
+ return () => document.removeEventListener("mousedown", handler);
20
+ }, [onClickOutside, ignoreRefs]);
21
+ return ref;
22
+ };
@@ -0,0 +1,13 @@
1
+ import { RefObject } from "react";
2
+ export declare const useDatePicker: (date: Date, portalRef?: RefObject<HTMLElement | null>) => {
3
+ isOpen: boolean;
4
+ setIsOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
5
+ current: Date;
6
+ goPrevMonth: () => void;
7
+ goNextMonth: () => void;
8
+ selected: Date;
9
+ setSelected: import("react").Dispatch<import("react").SetStateAction<Date>>;
10
+ calendar: import("../types/calendar-cell").CalendarCell[];
11
+ containerRef: RefObject<HTMLDivElement | null>;
12
+ };
13
+ //# sourceMappingURL=useDatePicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDatePicker.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/hooks/useDatePicker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,SAAS,EAAE,MAAM,OAAO,CAAC;AAIzD,eAAO,MAAM,aAAa,GACxB,MAAM,IAAI,EACV,YAAY,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC;;;;;;;;;;CAuC1C,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { useCallback, useState } from "react";
3
+ import { getMonthCalendar } from "../utils/get-month-calendar";
4
+ import { useClickOutside } from "./useClickOutside";
5
+ export const useDatePicker = (date, portalRef) => {
6
+ const [isOpen, setIsOpen] = useState(false);
7
+ const [current, setCurrent] = useState(() => new Date(date.getFullYear(), date.getMonth(), 1));
8
+ const [selected, setSelected] = useState(date);
9
+ const year = current.getFullYear();
10
+ const month = current.getMonth();
11
+ const calendar = getMonthCalendar(year, month);
12
+ const goPrevMonth = () => setCurrent(new Date(year, month - 1, 1));
13
+ const goNextMonth = () => setCurrent(new Date(year, month + 1, 1));
14
+ const close = useCallback(() => setIsOpen(false), []);
15
+ const ignoreRefs = portalRef ? [portalRef] : [];
16
+ const containerRef = useClickOutside(close, ignoreRefs);
17
+ return {
18
+ isOpen,
19
+ setIsOpen,
20
+ current,
21
+ goPrevMonth,
22
+ goNextMonth,
23
+ selected,
24
+ setSelected,
25
+ calendar,
26
+ containerRef,
27
+ };
28
+ };
@@ -0,0 +1,13 @@
1
+ import { Time } from "../types/time";
2
+ export declare const useTimePicker: (time: Time) => {
3
+ isOpen: boolean;
4
+ setIsOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
5
+ selected: Time;
6
+ hourRef: import("react").RefObject<HTMLDivElement | null>;
7
+ minuteRef: import("react").RefObject<HTMLDivElement | null>;
8
+ handleScroll: (ref: React.RefObject<HTMLDivElement>, values: number[], infiniteValues: number[], key: "hour" | "minute") => () => void;
9
+ containerRef: import("react").RefObject<HTMLDivElement>;
10
+ infiniteHours: any[];
11
+ infiniteMinutes: any[];
12
+ };
13
+ //# sourceMappingURL=useTimePicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTimePicker.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/hooks/useTimePicker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,eAAO,MAAM,aAAa,GAAI,MAAM,IAAI;;;;;;wBA6B7B,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,UAC5B,MAAM,EAAE,kBACA,MAAM,EAAE,OACnB,MAAM,GAAG,QAAQ;;;;CAuD3B,CAAC"}
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { useEffect, useRef, useCallback, useState } from "react";
3
+ import { ITEM_HEIGHT, HOURS, MINUTES, INFINITE_HOURS, INFINITE_MINUTES, OFFSET } from "../constants";
4
+ import { useClickOutside } from "./useClickOutside";
5
+ export const useTimePicker = (time) => {
6
+ const hourRef = useRef(null);
7
+ const minuteRef = useRef(null);
8
+ const snapTimer = useRef();
9
+ const isAdjusting = useRef(false);
10
+ const [isOpen, setIsOpen] = useState(false);
11
+ const [selected, setSelected] = useState(time);
12
+ const close = useCallback(() => setIsOpen(false), []);
13
+ const containerRef = useClickOutside(close);
14
+ const getMiddleOffset = (value, total) => {
15
+ return (total + value - OFFSET) * ITEM_HEIGHT;
16
+ };
17
+ useEffect(() => {
18
+ if (!isOpen)
19
+ return;
20
+ setSelected(time);
21
+ if (hourRef.current) {
22
+ hourRef.current.scrollTop = getMiddleOffset(time.hour, HOURS.length);
23
+ }
24
+ if (minuteRef.current) {
25
+ minuteRef.current.scrollTop = getMiddleOffset(time.minute, MINUTES.length);
26
+ }
27
+ }, [isOpen]);
28
+ const handleScroll = useCallback((ref, values, infiniteValues, key) => () => {
29
+ if (isAdjusting.current || !ref.current)
30
+ return;
31
+ window.clearTimeout(snapTimer.current);
32
+ snapTimer.current = window.setTimeout(() => {
33
+ if (!ref.current)
34
+ return;
35
+ const scrollTop = ref.current.scrollTop;
36
+ const index = Math.round(scrollTop / ITEM_HEIGHT) + OFFSET;
37
+ const totalItems = values.length;
38
+ ref.current.scrollTo({
39
+ top: (index - OFFSET) * ITEM_HEIGHT,
40
+ behavior: "smooth",
41
+ });
42
+ const actualValue = infiniteValues[index];
43
+ setSelected((prev) => ({
44
+ ...prev,
45
+ [key]: actualValue,
46
+ }));
47
+ setTimeout(() => {
48
+ if (!ref.current)
49
+ return;
50
+ const currentScrollTop = ref.current.scrollTop;
51
+ const currentIndex = Math.round(currentScrollTop / ITEM_HEIGHT) + OFFSET;
52
+ if (currentIndex < totalItems || currentIndex >= totalItems * 2) {
53
+ isAdjusting.current = true;
54
+ const middleIndex = totalItems + actualValue;
55
+ ref.current.scrollTop = (middleIndex - OFFSET) * ITEM_HEIGHT;
56
+ isAdjusting.current = false;
57
+ }
58
+ }, 150);
59
+ }, 80);
60
+ }, []);
61
+ return {
62
+ isOpen,
63
+ setIsOpen,
64
+ selected,
65
+ hourRef,
66
+ minuteRef,
67
+ handleScroll,
68
+ containerRef,
69
+ infiniteHours: INFINITE_HOURS,
70
+ infiniteMinutes: INFINITE_MINUTES,
71
+ };
72
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./ui";
2
+ export * from "./types/props";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DatePicker/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./ui";
2
+ export * from "./types/props";
@@ -0,0 +1,5 @@
1
+ export interface CalendarCell {
2
+ date: Date | null;
3
+ day: number | null;
4
+ }
5
+ //# sourceMappingURL=calendar-cell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-cell.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/types/calendar-cell.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ ;
2
+ export {};
@@ -0,0 +1,7 @@
1
+ export interface DatePickerProps {
2
+ date?: Date;
3
+ onChangeDate?: (date: Date) => void;
4
+ disablePast?: boolean;
5
+ title?: string;
6
+ }
7
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/types/props.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface Time {
2
+ hour: number;
3
+ minute: number;
4
+ }
5
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/types/time.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ interface DatePickerPortalProps {
2
+ children: React.ReactNode;
3
+ containerRef: React.RefObject<HTMLDivElement | null>;
4
+ portalRef: React.RefObject<HTMLDivElement | null>;
5
+ isOpen: boolean;
6
+ }
7
+ export declare const DatePickerPortal: ({ children, containerRef, portalRef, isOpen, }: DatePickerPortalProps) => import("react").ReactPortal | null;
8
+ export {};
9
+ //# sourceMappingURL=DatePickerPortal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatePickerPortal.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/ui/DatePickerPortal.tsx"],"names":[],"mappings":"AAKA,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACrD,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAClD,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,gBAAgB,GAAI,gDAK9B,qBAAqB,uCAqCvB,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useState } from "react";
4
+ import { createPortal } from "react-dom";
5
+ export const DatePickerPortal = ({ children, containerRef, portalRef, isOpen, }) => {
6
+ const [position, setPosition] = useState({
7
+ top: 0,
8
+ left: 0,
9
+ width: 0,
10
+ });
11
+ useEffect(() => {
12
+ if (!isOpen || !containerRef.current)
13
+ return;
14
+ const rect = containerRef.current.getBoundingClientRect();
15
+ setPosition({
16
+ top: rect.bottom + window.scrollY + 8,
17
+ left: rect.left + window.scrollX,
18
+ width: rect.width,
19
+ });
20
+ }, [isOpen, containerRef]);
21
+ if (!isOpen)
22
+ return null;
23
+ return createPortal(_jsx("div", { ref: portalRef, style: {
24
+ position: "absolute",
25
+ top: position.top,
26
+ left: position.left,
27
+ width: position.width,
28
+ zIndex: 100000,
29
+ }, onPointerDown: e => e.stopPropagation(), children: children }), document.body);
30
+ };
@@ -0,0 +1,3 @@
1
+ import { DatePickerProps } from "../types/props";
2
+ export declare const DatePicker: ({ date, onChangeDate, disablePast, title, }: DatePickerProps) => import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/ui/index.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAOjD,eAAO,MAAM,UAAU,GAAI,6CAKxB,eAAe,4CA0FjB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as S from "./style";
4
+ import { parseDate } from "../utils/parse-date";
5
+ import { DAYS } from "../constants";
6
+ import { getIsPast } from "../utils/get-is-past";
7
+ import { useDatePicker } from "../hooks/useDatePicker";
8
+ import { CalendarIcon } from "../../CalendarIcon";
9
+ import { ChevronIcon } from "../../ChevronIcon";
10
+ import { Button } from "../../Button";
11
+ import { DatePickerPortal } from "./DatePickerPortal";
12
+ import { useRef } from "react";
13
+ export const DatePicker = ({ date = new Date(), onChangeDate = () => { }, disablePast = false, title = "날짜 선택", }) => {
14
+ const portalRef = useRef(null);
15
+ const { isOpen, setIsOpen, current, goPrevMonth, goNextMonth, selected, setSelected, calendar, containerRef, } = useDatePicker(date, portalRef);
16
+ return (_jsxs(S.Container, { ref: containerRef, onClick: () => setIsOpen(prev => !prev), children: [_jsx(S.DateText, { children: parseDate(date) }), _jsx(CalendarIcon, { size: 16, pointer: true }), _jsx(DatePickerPortal, { containerRef: containerRef, portalRef: portalRef, isOpen: isOpen, children: _jsxs(S.Calender, { ref: portalRef, "$isOpen": isOpen, onClick: e => e.stopPropagation(), children: [_jsx(S.Title, { children: title }), _jsxs(S.Header, { children: [_jsxs(S.MonthText, { children: [current.getFullYear(), "\uB144 ", current.getMonth() + 1, "\uC6D4"] }), _jsxs(S.Arrows, { children: [_jsx(S.Arrow, { onClick: goPrevMonth, children: _jsx(ChevronIcon, { size: 16, rotate: 90 }) }), _jsx(S.Arrow, { onClick: goNextMonth, children: _jsx(ChevronIcon, { size: 16, rotate: -90 }) })] })] }), _jsx(S.WeekRow, { children: DAYS.map(day => (_jsx(S.Week, { children: day }, day))) }), _jsx(S.Grid, { children: calendar.map((cell, i) => cell.day ? (_jsx(S.Day, { "$selected": selected?.toDateString() ===
17
+ cell.date?.toDateString(), "$isPast": disablePast && getIsPast(cell.date), onClick: () => setSelected(cell.date), children: cell.day }, i)) : (_jsx("div", {}, i))) }), _jsx(Button, { buttonSize: "large", buttonType: "primary", onClick: () => {
18
+ onChangeDate(selected);
19
+ setIsOpen(false);
20
+ }, children: "\uC120\uD0DD" })] }) })] }));
21
+ };
@@ -0,0 +1,54 @@
1
+ export declare const Container: import("@emotion/styled").StyledComponent<{
2
+ theme?: import("@emotion/react").Theme;
3
+ as?: React.ElementType;
4
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
5
+ export declare const DateText: import("@emotion/styled").StyledComponent<{
6
+ theme?: import("@emotion/react").Theme;
7
+ as?: React.ElementType;
8
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
9
+ export declare const Calender: import("@emotion/styled").StyledComponent<{
10
+ theme?: import("@emotion/react").Theme;
11
+ as?: React.ElementType;
12
+ } & {
13
+ $isOpen: boolean;
14
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
15
+ export declare const Title: import("@emotion/styled").StyledComponent<{
16
+ theme?: import("@emotion/react").Theme;
17
+ as?: React.ElementType;
18
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, {}>;
19
+ export declare const Header: import("@emotion/styled").StyledComponent<{
20
+ theme?: import("@emotion/react").Theme;
21
+ as?: React.ElementType;
22
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
23
+ export declare const MonthText: import("@emotion/styled").StyledComponent<{
24
+ theme?: import("@emotion/react").Theme;
25
+ as?: React.ElementType;
26
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
27
+ export declare const Arrows: import("@emotion/styled").StyledComponent<{
28
+ theme?: import("@emotion/react").Theme;
29
+ as?: React.ElementType;
30
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
31
+ export declare const Arrow: import("@emotion/styled").StyledComponent<{
32
+ theme?: import("@emotion/react").Theme;
33
+ as?: React.ElementType;
34
+ }, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
35
+ export declare const WeekRow: import("@emotion/styled").StyledComponent<{
36
+ theme?: import("@emotion/react").Theme;
37
+ as?: React.ElementType;
38
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
39
+ export declare const Week: import("@emotion/styled").StyledComponent<{
40
+ theme?: import("@emotion/react").Theme;
41
+ as?: React.ElementType;
42
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
43
+ export declare const Grid: import("@emotion/styled").StyledComponent<{
44
+ theme?: import("@emotion/react").Theme;
45
+ as?: React.ElementType;
46
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
47
+ export declare const Day: import("@emotion/styled").StyledComponent<{
48
+ theme?: import("@emotion/react").Theme;
49
+ as?: React.ElementType;
50
+ } & {
51
+ $selected?: boolean;
52
+ $isPast?: boolean;
53
+ }, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
54
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/ui/style.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS;;;yGAarB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;2GAIpB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;aAAyB,OAAO;yGAYpD,CAAC;AAEF,eAAO,MAAM,KAAK;;;iHAEjB,CAAC;AAEF,eAAO,MAAM,MAAM;;;yGAIlB,CAAC;AAEF,eAAO,MAAM,SAAS;;;yGAErB,CAAC;AAEF,eAAO,MAAM,MAAM;;;yGAGlB,CAAC;AAEF,eAAO,MAAM,KAAK;;;qHAGjB,CAAC;AAEF,eAAO,MAAM,OAAO;;;yGAMnB,CAAC;AAEF,eAAO,MAAM,IAAI;;;2GAGhB,CAAC;AAEF,eAAO,MAAM,IAAI;;;yGAIhB,CAAC;AAEF,eAAO,MAAM,GAAG;;;;gBAA+B,OAAO;cAAY,OAAO;qHASxE,CAAC"}
@@ -0,0 +1,82 @@
1
+ "use client";
2
+ import { colors } from "@bds-web/colors";
3
+ import { shapes } from "@bds-web/shapes";
4
+ import { typoCss } from "@bds-web/typography";
5
+ import styled from "@emotion/styled";
6
+ export const Container = styled.div `
7
+ width: fit-content;
8
+ height: 48px;
9
+ background-color: ${colors.static.white};
10
+ border-radius: ${shapes.medium};
11
+ padding: 5px 20px;
12
+ color: ${colors.greyScale[90]};
13
+ display: flex;
14
+ align-items: center;
15
+ cursor: pointer;
16
+ position: relative;
17
+ gap: 10px;
18
+ box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.05);
19
+ `;
20
+ export const DateText = styled.span `
21
+ ${typoCss("Body")}
22
+ flex: 1;
23
+ user-select: none;
24
+ `;
25
+ export const Calender = styled.div `
26
+ background-color: ${colors.static.white};
27
+ border-radius: ${shapes.large};
28
+ position: absolute;
29
+ top: calc(100% + 8px);
30
+ left: -2px;
31
+ padding: 24px;
32
+ display: flex;
33
+ flex-direction: column;
34
+ gap: 16px;
35
+ cursor: default;
36
+ z-index: ${({ $isOpen }) => ($isOpen ? 1000 : -1)};
37
+ `;
38
+ export const Title = styled.h2 `
39
+ ${typoCss("H3")}
40
+ `;
41
+ export const Header = styled.div `
42
+ display: flex;
43
+ justify-content: space-between;
44
+ align-items: center;
45
+ `;
46
+ export const MonthText = styled.div `
47
+ ${typoCss("Body")}
48
+ `;
49
+ export const Arrows = styled.div `
50
+ display: flex;
51
+ gap: 8px;
52
+ `;
53
+ export const Arrow = styled.button `
54
+ padding: 8px;
55
+ cursor: pointer;
56
+ `;
57
+ export const WeekRow = styled.div `
58
+ display: grid;
59
+ grid-template-columns: repeat(7, 1fr);
60
+ text-align: center;
61
+ color: ${colors.greyScale[60]};
62
+ margin-bottom: 4px;
63
+ `;
64
+ export const Week = styled.span `
65
+ ${typoCss("Caption1")}
66
+ flex: 1;
67
+ `;
68
+ export const Grid = styled.div `
69
+ width: 280px;
70
+ display: grid;
71
+ grid-template-columns: repeat(7, 1fr);
72
+ `;
73
+ export const Day = styled.button `
74
+ ${typoCss("Body")}
75
+ height: 38px;
76
+ border-radius: ${shapes.small};
77
+ border: none;
78
+ cursor: pointer;
79
+ background: ${({ $selected }) => ($selected ? colors.blue.light : 'transparent')};
80
+ color: ${({ $selected }) => ($selected ? colors.static.white : colors.greyScale[60])};
81
+ opacity: ${({ $isPast }) => ($isPast ? 0.5 : 1)};
82
+ `;
@@ -0,0 +1,5 @@
1
+ export declare const getCurrentTime: () => {
2
+ hour: number;
3
+ minute: number;
4
+ };
5
+ //# sourceMappingURL=get-current-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-current-time.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/utils/get-current-time.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;CAM1B,CAAA"}
@@ -0,0 +1,7 @@
1
+ export const getCurrentTime = () => {
2
+ const now = new Date();
3
+ return {
4
+ hour: now.getHours(),
5
+ minute: now.getMinutes(),
6
+ };
7
+ };
@@ -0,0 +1,2 @@
1
+ export declare const getIsPast: (date: Date | null) => boolean;
2
+ //# sourceMappingURL=get-is-past.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-is-past.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/utils/get-is-past.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,MAAM,IAAI,GAAG,IAAI,KAAG,OAG7C,CAAA"}
@@ -0,0 +1,5 @@
1
+ export const getIsPast = (date) => {
2
+ if (!date)
3
+ return false;
4
+ return Number(date) < Number(new Date(new Date().setHours(0, 0, 0, 0)));
5
+ };
@@ -0,0 +1,3 @@
1
+ import { CalendarCell } from "../types/calendar-cell";
2
+ export declare const getMonthCalendar: (year: number, month: number) => CalendarCell[];
3
+ //# sourceMappingURL=get-month-calendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-month-calendar.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/utils/get-month-calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,YAAY,EAoB1E,CAAA"}
@@ -0,0 +1,16 @@
1
+ export const getMonthCalendar = (year, month) => {
2
+ const firstDayOfMonth = new Date(year, month, 1);
3
+ const startWeekDay = firstDayOfMonth.getDay();
4
+ const daysInMonth = new Date(year, month + 1, 0).getDate();
5
+ const cells = [];
6
+ for (let i = 0; i < startWeekDay; i++) {
7
+ cells.push({ date: null, day: null });
8
+ }
9
+ for (let day = 1; day <= daysInMonth; day++) {
10
+ cells.push({
11
+ date: new Date(year, month, day),
12
+ day,
13
+ });
14
+ }
15
+ return cells;
16
+ };
@@ -0,0 +1,2 @@
1
+ export declare const pad: (n: number) => string;
2
+ //# sourceMappingURL=pad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pad.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/utils/pad.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,WAAkC,CAAC"}
@@ -0,0 +1 @@
1
+ export const pad = (n) => n.toString().padStart(2, '0');
@@ -0,0 +1,2 @@
1
+ export declare const parseDate: (date: Date) => string;
2
+ //# sourceMappingURL=parse-date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-date.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/utils/parse-date.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAI,MAAM,IAAI,KAAG,MAMtC,CAAA"}
@@ -0,0 +1,6 @@
1
+ export const parseDate = (date) => {
2
+ const year = date.getFullYear();
3
+ const month = String(date.getMonth() + 1).padStart(2, "0");
4
+ const day = String(date.getDate()).padStart(2, "0");
5
+ return `${year}. ${month}. ${day}`;
6
+ };
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from "./TextInput";
4
4
  export * from "./Modal";
5
5
  export * from "./Dropdown";
6
6
  export * from "./Checkbox";
7
+ export * from "./DatePicker";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -4,3 +4,4 @@ export * from "./TextInput";
4
4
  export * from "./Modal";
5
5
  export * from "./Dropdown";
6
6
  export * from "./Checkbox";
7
+ export * from "./DatePicker";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bds-web/ui",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",