@bds-web/ui 1.17.0 → 1.19.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.
- package/dist/CalendarIcon/index.d.ts +2 -0
- package/dist/CalendarIcon/index.d.ts.map +1 -0
- package/dist/CalendarIcon/index.js +1 -0
- package/dist/CalendarIcon/ui/index.d.ts +7 -0
- package/dist/CalendarIcon/ui/index.d.ts.map +1 -0
- package/dist/CalendarIcon/ui/index.js +5 -0
- package/dist/ChevronIcon/index.d.ts +2 -0
- package/dist/ChevronIcon/index.d.ts.map +1 -0
- package/dist/ChevronIcon/index.js +1 -0
- package/dist/ChevronIcon/ui/index.d.ts +8 -0
- package/dist/ChevronIcon/ui/index.d.ts.map +1 -0
- package/dist/ChevronIcon/ui/index.js +5 -0
- package/dist/DatePicker/constants/index.d.ts +10 -0
- package/dist/DatePicker/constants/index.d.ts.map +1 -0
- package/dist/DatePicker/constants/index.js +9 -0
- package/dist/DatePicker/hooks/useClickOutside.d.ts +3 -0
- package/dist/DatePicker/hooks/useClickOutside.d.ts.map +1 -0
- package/dist/DatePicker/hooks/useClickOutside.js +22 -0
- package/dist/DatePicker/hooks/useDatePicker.d.ts +13 -0
- package/dist/DatePicker/hooks/useDatePicker.d.ts.map +1 -0
- package/dist/DatePicker/hooks/useDatePicker.js +28 -0
- package/dist/DatePicker/hooks/useTimePicker.d.ts +13 -0
- package/dist/DatePicker/hooks/useTimePicker.d.ts.map +1 -0
- package/dist/DatePicker/hooks/useTimePicker.js +72 -0
- package/dist/DatePicker/index.d.ts +3 -0
- package/dist/DatePicker/index.d.ts.map +1 -0
- package/dist/DatePicker/index.js +2 -0
- package/dist/DatePicker/types/calendar-cell.d.ts +5 -0
- package/dist/DatePicker/types/calendar-cell.d.ts.map +1 -0
- package/dist/DatePicker/types/calendar-cell.js +2 -0
- package/dist/DatePicker/types/props.d.ts +7 -0
- package/dist/DatePicker/types/props.d.ts.map +1 -0
- package/dist/DatePicker/types/props.js +1 -0
- package/dist/DatePicker/types/time.d.ts +5 -0
- package/dist/DatePicker/types/time.d.ts.map +1 -0
- package/dist/DatePicker/types/time.js +1 -0
- package/dist/DatePicker/ui/DatePickerPortal.d.ts +9 -0
- package/dist/DatePicker/ui/DatePickerPortal.d.ts.map +1 -0
- package/dist/DatePicker/ui/DatePickerPortal.js +30 -0
- package/dist/DatePicker/ui/index.d.ts +3 -0
- package/dist/DatePicker/ui/index.d.ts.map +1 -0
- package/dist/DatePicker/ui/index.js +17 -0
- package/dist/DatePicker/ui/style.d.ts +13 -0
- package/dist/DatePicker/ui/style.d.ts.map +1 -0
- package/dist/DatePicker/ui/style.js +30 -0
- package/dist/DatePicker/utils/format-date-input.d.ts +2 -0
- package/dist/DatePicker/utils/format-date-input.d.ts.map +1 -0
- package/dist/DatePicker/utils/format-date-input.js +6 -0
- package/dist/DatePicker/utils/format-date.d.ts +2 -0
- package/dist/DatePicker/utils/format-date.d.ts.map +1 -0
- package/dist/DatePicker/utils/format-date.js +8 -0
- package/dist/DatePicker/utils/get-current-time.d.ts +5 -0
- package/dist/DatePicker/utils/get-current-time.d.ts.map +1 -0
- package/dist/DatePicker/utils/get-current-time.js +7 -0
- package/dist/DatePicker/utils/get-is-past.d.ts +2 -0
- package/dist/DatePicker/utils/get-is-past.d.ts.map +1 -0
- package/dist/DatePicker/utils/get-is-past.js +5 -0
- package/dist/DatePicker/utils/get-month-calendar.d.ts +3 -0
- package/dist/DatePicker/utils/get-month-calendar.d.ts.map +1 -0
- package/dist/DatePicker/utils/get-month-calendar.js +16 -0
- package/dist/DatePicker/utils/pad.d.ts +2 -0
- package/dist/DatePicker/utils/pad.d.ts.map +1 -0
- package/dist/DatePicker/utils/pad.js +1 -0
- package/dist/DatePicker/utils/parse-date.d.ts +2 -0
- package/dist/DatePicker/utils/parse-date.d.ts.map +1 -0
- package/dist/DatePicker/utils/parse-date.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/ui/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKjD,eAAO,MAAM,UAAU,GAAI,6CAKxB,eAAe,4CAyBjB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { CalendarIcon } from "../../CalendarIcon";
|
|
5
|
+
import { formatDate } from "../utils/format-date";
|
|
6
|
+
import { formatDateInput } from "../utils/format-date-input";
|
|
7
|
+
import * as S from "./style";
|
|
8
|
+
export const DatePicker = ({ date = new Date(), onChangeDate = () => { }, disablePast = false, title = "날짜 선택", }) => {
|
|
9
|
+
const ref = useRef(null);
|
|
10
|
+
const value = formatDateInput(date);
|
|
11
|
+
const min = disablePast ? formatDateInput(new Date()) : undefined;
|
|
12
|
+
return (_jsxs(S.Container, { onClick: () => ref.current?.showPicker(), children: [_jsx(S.DateText, { children: formatDate(date) }), _jsx(CalendarIcon, { size: 16 }), _jsx(S.HiddenDateInput, { ref: ref, type: "date", value: value, min: min, "aria-label": title, onChange: (e) => {
|
|
13
|
+
if (e.target.value) {
|
|
14
|
+
onChangeDate(new Date(e.target.value));
|
|
15
|
+
}
|
|
16
|
+
} })] }));
|
|
17
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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 HiddenDateInput: import("@emotion/styled").StyledComponent<{
|
|
10
|
+
theme?: import("@emotion/react").Theme;
|
|
11
|
+
as?: React.ElementType;
|
|
12
|
+
}, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
|
|
13
|
+
//# 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,eAAe;;;kHAK3B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 HiddenDateInput = styled.input `
|
|
26
|
+
position: absolute;
|
|
27
|
+
inset: 0;
|
|
28
|
+
opacity: 0;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-date-input.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/utils/format-date-input.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,WAMzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-date.d.ts","sourceRoot":"","sources":["../../../src/DatePicker/utils/format-date.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,OAAO,IAAI,WAMrC,CAAA"}
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -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