@bds-web/ui 1.18.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.
@@ -1 +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"}
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"}
@@ -1,21 +1,17 @@
1
1
  "use client";
2
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
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";
13
8
  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" })] }) })] }));
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
+ } })] }));
21
17
  };
@@ -6,49 +6,8 @@ export declare const DateText: import("@emotion/styled").StyledComponent<{
6
6
  theme?: import("@emotion/react").Theme;
7
7
  as?: React.ElementType;
8
8
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
9
- export declare const Calender: import("@emotion/styled").StyledComponent<{
9
+ export declare const HiddenDateInput: import("@emotion/styled").StyledComponent<{
10
10
  theme?: import("@emotion/react").Theme;
11
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>, {}>;
12
+ }, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
54
13
  //# sourceMappingURL=style.d.ts.map
@@ -1 +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"}
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"}
@@ -22,61 +22,9 @@ export const DateText = styled.span `
22
22
  flex: 1;
23
23
  user-select: none;
24
24
  `;
25
- export const Calender = styled.div `
26
- background-color: ${colors.static.white};
27
- border-radius: ${shapes.large};
25
+ export const HiddenDateInput = styled.input `
28
26
  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;
27
+ inset: 0;
28
+ opacity: 0;
78
29
  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
30
  `;
@@ -0,0 +1,2 @@
1
+ export declare const formatDateInput: (date: Date) => string;
2
+ //# sourceMappingURL=format-date-input.d.ts.map
@@ -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,6 @@
1
+ export const formatDateInput = (date) => {
2
+ const yyyy = date.getFullYear();
3
+ const mm = String(date.getMonth() + 1).padStart(2, "0");
4
+ const dd = String(date.getDate()).padStart(2, "0");
5
+ return `${yyyy}-${mm}-${dd}`;
6
+ };
@@ -0,0 +1,2 @@
1
+ export declare const formatDate: (date?: Date) => string;
2
+ //# sourceMappingURL=format-date.d.ts.map
@@ -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,8 @@
1
+ export const formatDate = (date) => {
2
+ if (!date)
3
+ return "";
4
+ const d = new Date(date);
5
+ const month = (d.getMonth() + 1).toString().padStart(2, "0");
6
+ const day = d.getDate().toString().padStart(2, "0");
7
+ return `${d.getFullYear()}-${month}-${day}`;
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bds-web/ui",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",