@nexus-cross/design-system 1.0.8 → 1.0.10

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,98 +0,0 @@
1
- import { cn } from './chunk-MCKOWMLS.mjs';
2
- import * as React from 'react';
3
- import { DayPicker } from 'react-day-picker';
4
- import { format } from 'date-fns';
5
- import { ko } from 'date-fns/locale';
6
- import { jsxs, jsx } from 'react/jsx-runtime';
7
-
8
- var CalendarIcon = ({ className }) => /* @__PURE__ */ jsxs("svg", { className, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
9
- /* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "14", height: "14", rx: "2" }),
10
- /* @__PURE__ */ jsx("path", { d: "M3 8h14M7 2v4M13 2v4", strokeLinecap: "round" })
11
- ] });
12
- var DatePicker = ({
13
- value,
14
- defaultValue,
15
- onChange,
16
- placeholder = "\uB0A0\uC9DC \uC120\uD0DD",
17
- disabled = false,
18
- minDate,
19
- maxDate,
20
- locale: localeProp = "ko",
21
- formatStr = "yyyy-MM-dd",
22
- className
23
- }) => {
24
- const [internalDate, setInternalDate] = React.useState(defaultValue);
25
- const [open, setOpen] = React.useState(false);
26
- const wrapperRef = React.useRef(null);
27
- const selected = value ?? internalDate;
28
- const handleSelect = React.useCallback(
29
- (date) => {
30
- if (!value) setInternalDate(date);
31
- onChange?.(date);
32
- setOpen(false);
33
- },
34
- [value, onChange]
35
- );
36
- React.useEffect(() => {
37
- const handleClickOutside = (e) => {
38
- if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
39
- setOpen(false);
40
- }
41
- };
42
- if (open) document.addEventListener("mousedown", handleClickOutside);
43
- return () => document.removeEventListener("mousedown", handleClickOutside);
44
- }, [open]);
45
- const displayText = selected ? format(selected, formatStr, { locale: localeProp === "ko" ? ko : void 0 }) : placeholder;
46
- return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: cn("nexus-datepicker", className), children: [
47
- /* @__PURE__ */ jsxs(
48
- "button",
49
- {
50
- type: "button",
51
- className: cn(
52
- "nexus-datepicker__trigger",
53
- !selected && "nexus-datepicker__trigger--placeholder"
54
- ),
55
- onClick: () => !disabled && setOpen(!open),
56
- disabled,
57
- children: [
58
- /* @__PURE__ */ jsx(CalendarIcon, { className: "nexus-datepicker__icon" }),
59
- /* @__PURE__ */ jsx("span", { children: displayText })
60
- ]
61
- }
62
- ),
63
- open && /* @__PURE__ */ jsx("div", { className: "nexus-datepicker__popover", children: /* @__PURE__ */ jsx(
64
- DayPicker,
65
- {
66
- mode: "single",
67
- selected,
68
- onSelect: handleSelect,
69
- locale: localeProp === "ko" ? ko : void 0,
70
- disabled: [
71
- ...minDate ? [{ before: minDate }] : [],
72
- ...maxDate ? [{ after: maxDate }] : []
73
- ],
74
- classNames: {
75
- root: "nexus-calendar",
76
- months: "nexus-calendar__months",
77
- month_caption: "nexus-calendar__caption",
78
- nav: "nexus-calendar__nav",
79
- button_previous: "nexus-calendar__nav-btn",
80
- button_next: "nexus-calendar__nav-btn",
81
- month_grid: "nexus-calendar__grid",
82
- weekdays: "nexus-calendar__head-row",
83
- weekday: "nexus-calendar__head-cell",
84
- week: "nexus-calendar__row",
85
- day: "nexus-calendar__cell",
86
- day_button: "nexus-calendar__day",
87
- selected: "nexus-calendar__day--selected",
88
- today: "nexus-calendar__day--today",
89
- outside: "nexus-calendar__day--outside",
90
- disabled: "nexus-calendar__day--disabled"
91
- }
92
- }
93
- ) })
94
- ] });
95
- };
96
- DatePicker.displayName = "DatePicker";
97
-
98
- export { DatePicker };