@deepnoid/ui 0.1.124 → 0.1.127
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/.turbo/turbo-build.log +469 -461
- package/dist/{chunk-WUGITHV6.mjs → chunk-4WHX4RXX.mjs} +3 -3
- package/dist/{chunk-QXYGQPY3.mjs → chunk-4X67BUPA.mjs} +2 -2
- package/dist/{chunk-TSBG5FXL.mjs → chunk-5R3ARH2N.mjs} +1 -1
- package/dist/{chunk-3ZF7LQOM.mjs → chunk-ANILRUAS.mjs} +5 -4
- package/dist/{chunk-OL22LVBG.mjs → chunk-BBEOPH6B.mjs} +1 -1
- package/dist/{chunk-C5IJSWWJ.mjs → chunk-BD4M2FZM.mjs} +3 -3
- package/dist/{chunk-Y3CGQN3I.mjs → chunk-DDK4NEDX.mjs} +2 -2
- package/dist/{chunk-WNNOVISA.mjs → chunk-FQJD2IY3.mjs} +79 -37
- package/dist/{chunk-BG4DIGKH.mjs → chunk-GQFNYXJZ.mjs} +30 -0
- package/dist/{chunk-KRGI6HW7.mjs → chunk-IBYQBC6D.mjs} +114 -33
- package/dist/{chunk-WOGNHRNX.mjs → chunk-IT6RD6KS.mjs} +1 -1
- package/dist/{chunk-2GFE25AI.mjs → chunk-JC6635TJ.mjs} +1 -1
- package/dist/{chunk-KJ7L6CO6.mjs → chunk-KP2KOY5Z.mjs} +1 -1
- package/dist/{chunk-HO533YTO.mjs → chunk-MPUZ5T7X.mjs} +10 -10
- package/dist/{chunk-5XW5QDIW.mjs → chunk-NCK5E2NL.mjs} +1 -1
- package/dist/{chunk-6UKNZTOL.mjs → chunk-OLQJXFHU.mjs} +1 -1
- package/dist/{chunk-F4ORNNYB.mjs → chunk-ORZW6F6E.mjs} +2 -2
- package/dist/{chunk-3HY74IGR.mjs → chunk-TRLIC34S.mjs} +1 -1
- package/dist/chunk-WC5PVVT6.mjs +138 -0
- package/dist/{chunk-YZ57UYAS.mjs → chunk-XX2PHROM.mjs} +1 -1
- package/dist/{chunk-LX7NPKFE.mjs → chunk-YWLC7KRK.mjs} +1 -2
- package/dist/{chunk-HKONMHXA.mjs → chunk-ZI3MLO7X.mjs} +1 -1
- package/dist/components/avatar/avatar.js +30 -0
- package/dist/components/avatar/avatar.mjs +2 -2
- package/dist/components/avatar/index.js +30 -0
- package/dist/components/avatar/index.mjs +2 -2
- package/dist/components/breadcrumb/breadcrumb.js +30 -0
- package/dist/components/breadcrumb/breadcrumb.mjs +6 -6
- package/dist/components/breadcrumb/index.js +30 -0
- package/dist/components/breadcrumb/index.mjs +6 -6
- package/dist/components/button/button.js +30 -0
- package/dist/components/button/button.mjs +3 -3
- package/dist/components/button/icon-button.js +30 -0
- package/dist/components/button/icon-button.mjs +3 -3
- package/dist/components/button/index.js +30 -0
- package/dist/components/button/index.mjs +7 -7
- package/dist/components/charts/barChart.d.mts +4 -4
- package/dist/components/charts/barChart.d.ts +4 -4
- package/dist/components/charts/barChart.js +79 -39
- package/dist/components/charts/barChart.mjs +1 -1
- package/dist/components/charts/circularProgress.js +1 -1
- package/dist/components/charts/circularProgress.mjs +1 -1
- package/dist/components/charts/index.js +79 -37
- package/dist/components/charts/index.mjs +5 -5
- package/dist/components/chip/chip.js +30 -0
- package/dist/components/chip/chip.mjs +3 -3
- package/dist/components/chip/index.js +30 -0
- package/dist/components/chip/index.mjs +3 -3
- package/dist/components/fileUpload/fileUpload.js +30 -0
- package/dist/components/fileUpload/fileUpload.mjs +7 -7
- package/dist/components/fileUpload/index.js +30 -0
- package/dist/components/fileUpload/index.mjs +7 -7
- package/dist/components/icon/Icon.d.mts +4 -0
- package/dist/components/icon/Icon.d.ts +4 -0
- package/dist/components/icon/Icon.js +30 -0
- package/dist/components/icon/Icon.mjs +2 -2
- package/dist/components/icon/index.js +30 -0
- package/dist/components/icon/index.mjs +2 -2
- package/dist/components/icon/template.d.mts +1 -0
- package/dist/components/icon/template.d.ts +1 -0
- package/dist/components/icon/template.js +30 -0
- package/dist/components/icon/template.mjs +1 -1
- package/dist/components/input/index.js +30 -0
- package/dist/components/input/index.mjs +3 -3
- package/dist/components/input/input.js +30 -0
- package/dist/components/input/input.mjs +3 -3
- package/dist/components/list/index.js +30 -0
- package/dist/components/list/index.mjs +4 -4
- package/dist/components/list/listItem.js +30 -0
- package/dist/components/list/listItem.mjs +4 -4
- package/dist/components/modal/index.js +30 -0
- package/dist/components/modal/index.mjs +6 -6
- package/dist/components/modal/modal.js +30 -0
- package/dist/components/modal/modal.mjs +6 -6
- package/dist/components/pagination/index.js +141 -29
- package/dist/components/pagination/index.mjs +4 -4
- package/dist/components/pagination/pagination.d.mts +1 -1
- package/dist/components/pagination/pagination.d.ts +1 -1
- package/dist/components/pagination/pagination.js +142 -35
- package/dist/components/pagination/pagination.mjs +5 -7
- package/dist/components/picker/datePicker.js +30 -0
- package/dist/components/picker/datePicker.mjs +8 -8
- package/dist/components/picker/index.js +30 -1
- package/dist/components/picker/index.mjs +10 -10
- package/dist/components/picker/timePicker.js +30 -1
- package/dist/components/picker/timePicker.mjs +4 -4
- package/dist/components/select/index.js +30 -1
- package/dist/components/select/index.mjs +3 -3
- package/dist/components/select/select.js +30 -1
- package/dist/components/select/select.mjs +3 -3
- package/dist/components/table/definition-table.d.mts +2 -0
- package/dist/components/table/definition-table.d.ts +2 -0
- package/dist/components/table/definition-table.js +67 -14
- package/dist/components/table/definition-table.mjs +1 -1
- package/dist/components/table/index.js +209 -43
- package/dist/components/table/index.mjs +10 -10
- package/dist/components/table/table-body.js +142 -29
- package/dist/components/table/table-body.mjs +7 -7
- package/dist/components/table/table-head.js +142 -29
- package/dist/components/table/table-head.mjs +7 -7
- package/dist/components/table/table.js +142 -29
- package/dist/components/table/table.mjs +7 -7
- package/dist/components/timePicker/calendar.d.mts +72 -0
- package/dist/components/timePicker/calendar.d.ts +72 -0
- package/dist/components/timePicker/calendar.js +5360 -0
- package/dist/components/timePicker/calendar.mjs +300 -0
- package/dist/components/timePicker/useDateTimePicker.d.mts +38 -0
- package/dist/components/timePicker/useDateTimePicker.d.ts +38 -0
- package/dist/components/timePicker/useDateTimePicker.js +126 -0
- package/dist/components/timePicker/useDateTimePicker.mjs +96 -0
- package/dist/components/toast/index.js +30 -0
- package/dist/components/toast/index.mjs +4 -4
- package/dist/components/toast/toast.js +30 -0
- package/dist/components/toast/toast.mjs +3 -3
- package/dist/components/toast/use-toast.js +30 -0
- package/dist/components/toast/use-toast.mjs +4 -4
- package/dist/components/tree/index.js +30 -0
- package/dist/components/tree/index.mjs +3 -3
- package/dist/components/tree/tree.js +30 -0
- package/dist/components/tree/tree.mjs +3 -3
- package/dist/index.js +288 -81
- package/dist/index.mjs +54 -54
- package/package.json +1 -1
- package/dist/chunk-SJNXRXV5.mjs +0 -85
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
formatDateToString,
|
|
4
|
+
formatStringToDate
|
|
5
|
+
} from "../../chunk-FWFEKWWD.mjs";
|
|
6
|
+
import "../../chunk-ZYIIXWVY.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Icon_default
|
|
9
|
+
} from "../../chunk-XX2PHROM.mjs";
|
|
10
|
+
import {
|
|
11
|
+
mapPropsVariants
|
|
12
|
+
} from "../../chunk-E3G5QXSH.mjs";
|
|
13
|
+
import "../../chunk-GQFNYXJZ.mjs";
|
|
14
|
+
import {
|
|
15
|
+
tv
|
|
16
|
+
} from "../../chunk-76QIZILI.mjs";
|
|
17
|
+
import "../../chunk-AC6TWLRT.mjs";
|
|
18
|
+
|
|
19
|
+
// src/components/timePicker/calendar.tsx
|
|
20
|
+
import React, {
|
|
21
|
+
forwardRef,
|
|
22
|
+
useCallback,
|
|
23
|
+
useMemo,
|
|
24
|
+
useState,
|
|
25
|
+
useImperativeHandle,
|
|
26
|
+
useEffect
|
|
27
|
+
} from "react";
|
|
28
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
29
|
+
var Calendar = forwardRef((originalProps, ref) => {
|
|
30
|
+
const [props, variantProps] = mapPropsVariants(originalProps, calendarStyle.variantKeys);
|
|
31
|
+
const {
|
|
32
|
+
selectedDate,
|
|
33
|
+
startDate,
|
|
34
|
+
endDate,
|
|
35
|
+
range = false,
|
|
36
|
+
classNames,
|
|
37
|
+
highlightWeekend = true,
|
|
38
|
+
onChangeDate,
|
|
39
|
+
onChangeDateRange,
|
|
40
|
+
...inputProps
|
|
41
|
+
} = props;
|
|
42
|
+
const [currentDate, setCurrentDate] = useState(selectedDate ? new Date(selectedDate) : /* @__PURE__ */ new Date());
|
|
43
|
+
const [tempStartDate, setTempStartDate] = useState(startDate);
|
|
44
|
+
const [tempEndDate, setTempEndDate] = useState(endDate);
|
|
45
|
+
const [isSelectingRange, setIsSelectingRange] = useState(false);
|
|
46
|
+
const daysOfWeek = ["S", "M", "T", "W", "T", "F", "S"];
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (selectedDate) {
|
|
49
|
+
setCurrentDate(new Date(selectedDate));
|
|
50
|
+
}
|
|
51
|
+
}, [selectedDate]);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (range) {
|
|
54
|
+
setTempStartDate(startDate);
|
|
55
|
+
setTempEndDate(endDate);
|
|
56
|
+
}
|
|
57
|
+
}, [startDate, endDate, range]);
|
|
58
|
+
const getCalendarDates = useCallback(() => {
|
|
59
|
+
const year = currentDate.getFullYear();
|
|
60
|
+
const month = currentDate.getMonth();
|
|
61
|
+
const firstDayOfMonth = new Date(year, month, 1).getDay();
|
|
62
|
+
const lastDateOfMonth = new Date(year, month + 1, 0).getDate();
|
|
63
|
+
const lastDateOfPrevMonth = new Date(year, month, 0).getDate();
|
|
64
|
+
let dates = [];
|
|
65
|
+
for (let i = firstDayOfMonth - 1; i >= 0; i--) {
|
|
66
|
+
dates.push({
|
|
67
|
+
date: lastDateOfPrevMonth - i,
|
|
68
|
+
currentMonth: false
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
for (let date = 1; date <= lastDateOfMonth; date++) {
|
|
72
|
+
dates.push({
|
|
73
|
+
date,
|
|
74
|
+
currentMonth: true
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const remainingDays = 42 - dates.length;
|
|
78
|
+
for (let i = 1; i <= remainingDays; i++) {
|
|
79
|
+
dates.push({
|
|
80
|
+
date: i,
|
|
81
|
+
currentMonth: false
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const weeks = [];
|
|
85
|
+
for (let i = 0; i < dates.length; i += 7) {
|
|
86
|
+
weeks.push(dates.slice(i, i + 7));
|
|
87
|
+
}
|
|
88
|
+
return weeks;
|
|
89
|
+
}, [currentDate]);
|
|
90
|
+
const handlePrevMonth = () => {
|
|
91
|
+
setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() - 1));
|
|
92
|
+
};
|
|
93
|
+
const handleNextMonth = () => {
|
|
94
|
+
setCurrentDate(new Date(currentDate.getFullYear(), currentDate.getMonth() + 1));
|
|
95
|
+
};
|
|
96
|
+
const handleDateSelect = (date, isCurrentMonth) => {
|
|
97
|
+
if (!isCurrentMonth) return;
|
|
98
|
+
const selected = new Date(currentDate.getFullYear(), currentDate.getMonth(), date);
|
|
99
|
+
const formatted = formatDateToString(selected);
|
|
100
|
+
if (range) {
|
|
101
|
+
if (!tempStartDate || tempStartDate && tempEndDate) {
|
|
102
|
+
setTempStartDate(formatted);
|
|
103
|
+
setTempEndDate(void 0);
|
|
104
|
+
setIsSelectingRange(true);
|
|
105
|
+
} else if (tempStartDate && !tempEndDate) {
|
|
106
|
+
const startDateObj = new Date(tempStartDate);
|
|
107
|
+
const endDateObj = selected;
|
|
108
|
+
if (endDateObj >= startDateObj) {
|
|
109
|
+
setTempEndDate(formatted);
|
|
110
|
+
onChangeDateRange == null ? void 0 : onChangeDateRange(tempStartDate, formatted);
|
|
111
|
+
} else {
|
|
112
|
+
setTempStartDate(formatted);
|
|
113
|
+
setTempEndDate(tempStartDate);
|
|
114
|
+
onChangeDateRange == null ? void 0 : onChangeDateRange(formatted, tempStartDate);
|
|
115
|
+
}
|
|
116
|
+
setIsSelectingRange(false);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
onChangeDate == null ? void 0 : onChangeDate(formatted);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const isDateInRange = (date, isCurrentMonth) => {
|
|
123
|
+
if (!range || !tempStartDate || !isCurrentMonth) return false;
|
|
124
|
+
const currentDateObj = new Date(currentDate.getFullYear(), currentDate.getMonth(), date);
|
|
125
|
+
const startDateObj = new Date(tempStartDate);
|
|
126
|
+
const endDateObj = tempEndDate ? new Date(tempEndDate) : null;
|
|
127
|
+
if (endDateObj) {
|
|
128
|
+
return currentDateObj >= startDateObj && currentDateObj <= endDateObj;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
};
|
|
132
|
+
const isDateRangeStart = (date, isCurrentMonth) => {
|
|
133
|
+
if (!range || !tempStartDate || !isCurrentMonth) return false;
|
|
134
|
+
const currentDateObj = new Date(currentDate.getFullYear(), currentDate.getMonth(), date);
|
|
135
|
+
const startDateObj = new Date(tempStartDate);
|
|
136
|
+
return currentDateObj.getTime() === startDateObj.getTime();
|
|
137
|
+
};
|
|
138
|
+
const isDateRangeEnd = (date, isCurrentMonth) => {
|
|
139
|
+
if (!range || !tempEndDate || !isCurrentMonth) return false;
|
|
140
|
+
const currentDateObj = new Date(currentDate.getFullYear(), currentDate.getMonth(), date);
|
|
141
|
+
const endDateObj = new Date(tempEndDate);
|
|
142
|
+
return currentDateObj.getTime() === endDateObj.getTime();
|
|
143
|
+
};
|
|
144
|
+
useImperativeHandle(ref, () => ({
|
|
145
|
+
getSelectedDate: () => selectedDate,
|
|
146
|
+
getStartDate: () => tempStartDate,
|
|
147
|
+
getEndDate: () => tempEndDate
|
|
148
|
+
}));
|
|
149
|
+
const slots = useMemo(() => calendarStyle({ ...variantProps }), [variantProps]);
|
|
150
|
+
const getBaseProps = useCallback(
|
|
151
|
+
() => ({
|
|
152
|
+
className: `${slots.base({ class: classNames == null ? void 0 : classNames.base })}`
|
|
153
|
+
}),
|
|
154
|
+
[slots, classNames]
|
|
155
|
+
);
|
|
156
|
+
const getDateTitleProps = useCallback(
|
|
157
|
+
(index) => {
|
|
158
|
+
return {
|
|
159
|
+
className: `${slots.dateTitle({
|
|
160
|
+
class: classNames == null ? void 0 : classNames.dateTitle
|
|
161
|
+
})}`,
|
|
162
|
+
"data-saturday": highlightWeekend && index === 6,
|
|
163
|
+
"data-sunday": highlightWeekend && index === 0
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
[slots, classNames, highlightWeekend]
|
|
167
|
+
);
|
|
168
|
+
const getDateProps = useCallback(
|
|
169
|
+
(dateObj) => {
|
|
170
|
+
const today = /* @__PURE__ */ new Date();
|
|
171
|
+
const isToday = today.getDate() === dateObj.date && today.getMonth() === currentDate.getMonth() && today.getFullYear() === currentDate.getFullYear();
|
|
172
|
+
const formatted = selectedDate ? formatStringToDate(selectedDate) : "";
|
|
173
|
+
const isSelected = !range && formatted ? formatted.getDate() === dateObj.date && formatted.getMonth() === currentDate.getMonth() && formatted.getFullYear() === currentDate.getFullYear() : false;
|
|
174
|
+
const inRange = isDateInRange(dateObj.date, dateObj.currentMonth);
|
|
175
|
+
const rangeStart = isDateRangeStart(dateObj.date, dateObj.currentMonth);
|
|
176
|
+
const rangeEnd = isDateRangeEnd(dateObj.date, dateObj.currentMonth);
|
|
177
|
+
const dayOfWeek = new Date(currentDate.getFullYear(), currentDate.getMonth(), dateObj.date).getDay();
|
|
178
|
+
return {
|
|
179
|
+
className: `${slots.date({
|
|
180
|
+
class: classNames == null ? void 0 : classNames.date
|
|
181
|
+
})}`,
|
|
182
|
+
"data-today": dateObj.currentMonth && isToday,
|
|
183
|
+
"data-selected": dateObj.currentMonth && isSelected,
|
|
184
|
+
"data-range-start": dateObj.currentMonth && rangeStart,
|
|
185
|
+
"data-range-end": dateObj.currentMonth && rangeEnd,
|
|
186
|
+
"data-in-range": dateObj.currentMonth && inRange,
|
|
187
|
+
"data-disabled": !dateObj.currentMonth,
|
|
188
|
+
"data-saturday": highlightWeekend && dayOfWeek === 6,
|
|
189
|
+
"data-sunday": highlightWeekend && dayOfWeek === 0,
|
|
190
|
+
onClick: () => handleDateSelect(dateObj.date, dateObj.currentMonth)
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
[slots, classNames, selectedDate, currentDate, highlightWeekend, range, tempStartDate, tempEndDate]
|
|
194
|
+
);
|
|
195
|
+
const calendarDates = getCalendarDates();
|
|
196
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { ...getBaseProps(), children: [
|
|
197
|
+
/* @__PURE__ */ jsxs("div", { className: "calendar-header mb-4 flex items-center justify-between", children: [
|
|
198
|
+
/* @__PURE__ */ jsx(Icon_default, { name: "brace-left", size: "md", className: "cursor-pointer", onClick: handlePrevMonth }),
|
|
199
|
+
/* @__PURE__ */ jsx("span", { className: "text-h6 font-semibold", children: currentDate.toLocaleString("default", { year: "numeric", month: "2-digit" }) }),
|
|
200
|
+
/* @__PURE__ */ jsx(Icon_default, { name: "brace-right", size: "md", className: "cursor-pointer", onClick: handleNextMonth })
|
|
201
|
+
] }),
|
|
202
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-2 text-center", children: daysOfWeek.map((day, index) => /* @__PURE__ */ jsx("div", { ...getDateTitleProps(index), children: day }, `${day}-${index}`)) }),
|
|
203
|
+
/* @__PURE__ */ jsx("div", { className: "mt-2 grid grid-cols-7 gap-[5px] text-center", children: calendarDates.map((week, weekIndex) => {
|
|
204
|
+
const hasCurrentMonthDates = week.some((dateObj) => dateObj.currentMonth);
|
|
205
|
+
if (!hasCurrentMonthDates) return null;
|
|
206
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: week.map((dateObj, index) => {
|
|
207
|
+
return /* @__PURE__ */ jsx("div", { ...getDateProps(dateObj), children: dateObj.date }, index);
|
|
208
|
+
}) }, weekIndex);
|
|
209
|
+
}) })
|
|
210
|
+
] }) });
|
|
211
|
+
});
|
|
212
|
+
Calendar.displayName = "Calendar";
|
|
213
|
+
var calendar_default = Calendar;
|
|
214
|
+
var calendarStyle = tv({
|
|
215
|
+
slots: {
|
|
216
|
+
base: [
|
|
217
|
+
"flex",
|
|
218
|
+
"flex-col",
|
|
219
|
+
"w-[240px]",
|
|
220
|
+
"border",
|
|
221
|
+
"border-neutral-main",
|
|
222
|
+
"bg-background",
|
|
223
|
+
"rounded-md",
|
|
224
|
+
"p-4",
|
|
225
|
+
"shadow-lg",
|
|
226
|
+
"select-none"
|
|
227
|
+
],
|
|
228
|
+
dateTitle: ["text-sm", "font-[500]", "data-[saturday=true]:text-[#1E7EEE]", "data-[sunday=true]:text-[#FF4684]"],
|
|
229
|
+
date: [
|
|
230
|
+
"flex",
|
|
231
|
+
"justify-center",
|
|
232
|
+
"items-center",
|
|
233
|
+
"h-[25px]",
|
|
234
|
+
"text-sm",
|
|
235
|
+
"rounded-full",
|
|
236
|
+
"cursor-pointer",
|
|
237
|
+
"hover:bg-neutral-soft",
|
|
238
|
+
"data-[today=true]:border",
|
|
239
|
+
"data-[today=true]:border-foreground",
|
|
240
|
+
"data-[saturday=true]:text-[#1E7EEE]",
|
|
241
|
+
"data-[saturday=true]:!border-[#1E7EEE]",
|
|
242
|
+
"data-[sunday=true]:text-[#FF4684]",
|
|
243
|
+
"data-[sunday=true]:!border-[#FF4684]",
|
|
244
|
+
"data-[selected=true]:!text-white",
|
|
245
|
+
"data-[selected=true]:border-none",
|
|
246
|
+
"data-[range-start=true]:!text-white",
|
|
247
|
+
"data-[range-start=true]:border-none",
|
|
248
|
+
"data-[range-end=true]:!text-white",
|
|
249
|
+
"data-[range-end=true]:border-none",
|
|
250
|
+
"data-[in-range=true]:!bg-opacity-20",
|
|
251
|
+
"data-[disabled=true]:!text-neutral-main",
|
|
252
|
+
"data-[disabled=true]:cursor-default",
|
|
253
|
+
"data-[disabled=true]:hover:bg-transparent"
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
variants: {
|
|
257
|
+
variant: {
|
|
258
|
+
solid: {}
|
|
259
|
+
},
|
|
260
|
+
color: {
|
|
261
|
+
primary: {
|
|
262
|
+
date: [
|
|
263
|
+
"data-[selected=true]:!border-primary-main",
|
|
264
|
+
"data-[selected=true]:bg-primary-main",
|
|
265
|
+
"data-[range-start=true]:!border-primary-main",
|
|
266
|
+
"data-[range-start=true]:bg-primary-main",
|
|
267
|
+
"data-[range-end=true]:!border-primary-main",
|
|
268
|
+
"data-[range-end=true]:bg-primary-main",
|
|
269
|
+
"data-[in-range=true]:!bg-primary-main"
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
secondary: {
|
|
273
|
+
date: [
|
|
274
|
+
"data-[selected=true]:!border-secondary-main",
|
|
275
|
+
"data-[selected=true]:bg-secondary-main",
|
|
276
|
+
"data-[range-start=true]:!border-secondary-main",
|
|
277
|
+
"data-[range-start=true]:bg-secondary-main",
|
|
278
|
+
"data-[range-end=true]:!border-secondary-main",
|
|
279
|
+
"data-[range-end=true]:bg-secondary-main",
|
|
280
|
+
"data-[in-range=true]:!bg-secondary-main"
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
defaultVariants: {
|
|
286
|
+
variant: "solid",
|
|
287
|
+
color: "primary"
|
|
288
|
+
},
|
|
289
|
+
compoundVariants: [
|
|
290
|
+
{
|
|
291
|
+
disabled: true,
|
|
292
|
+
isRequired: true,
|
|
293
|
+
class: {}
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
});
|
|
297
|
+
export {
|
|
298
|
+
calendarStyle,
|
|
299
|
+
calendar_default as default
|
|
300
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
interface DatePickerHookProps {
|
|
4
|
+
initialDate?: Date;
|
|
5
|
+
initialTime?: string;
|
|
6
|
+
range?: boolean;
|
|
7
|
+
onChange?: (date: Date) => void;
|
|
8
|
+
}
|
|
9
|
+
type TargetRect = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
declare const useDatePicker: ({ initialDate, initialTime, range }: DatePickerHookProps) => {
|
|
16
|
+
selectedDate: string | undefined;
|
|
17
|
+
selectedTime: string | undefined;
|
|
18
|
+
startDate: string | undefined;
|
|
19
|
+
endDate: string | undefined;
|
|
20
|
+
targetRect: TargetRect | null;
|
|
21
|
+
popupHeight: number;
|
|
22
|
+
isFocusInput: boolean;
|
|
23
|
+
dateInputRef: react.RefObject<HTMLInputElement | null>;
|
|
24
|
+
datePickerWrapperRef: react.RefObject<HTMLDivElement | null>;
|
|
25
|
+
datePickerRef: react.RefObject<HTMLDivElement | null>;
|
|
26
|
+
handleToggleDatePicker: () => void;
|
|
27
|
+
handleChangeDate: (date: string) => void;
|
|
28
|
+
handleChangeTime: (time: string) => void;
|
|
29
|
+
handleChangeDateRange: (start: string, end: string) => void;
|
|
30
|
+
handleFocusInput: () => void;
|
|
31
|
+
handleBlurInput: () => void;
|
|
32
|
+
calculatePositionWithScroll: (targetRect: TargetRect) => {
|
|
33
|
+
top: number;
|
|
34
|
+
left: number;
|
|
35
|
+
} | undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { useDatePicker };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
interface DatePickerHookProps {
|
|
4
|
+
initialDate?: Date;
|
|
5
|
+
initialTime?: string;
|
|
6
|
+
range?: boolean;
|
|
7
|
+
onChange?: (date: Date) => void;
|
|
8
|
+
}
|
|
9
|
+
type TargetRect = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
declare const useDatePicker: ({ initialDate, initialTime, range }: DatePickerHookProps) => {
|
|
16
|
+
selectedDate: string | undefined;
|
|
17
|
+
selectedTime: string | undefined;
|
|
18
|
+
startDate: string | undefined;
|
|
19
|
+
endDate: string | undefined;
|
|
20
|
+
targetRect: TargetRect | null;
|
|
21
|
+
popupHeight: number;
|
|
22
|
+
isFocusInput: boolean;
|
|
23
|
+
dateInputRef: react.RefObject<HTMLInputElement | null>;
|
|
24
|
+
datePickerWrapperRef: react.RefObject<HTMLDivElement | null>;
|
|
25
|
+
datePickerRef: react.RefObject<HTMLDivElement | null>;
|
|
26
|
+
handleToggleDatePicker: () => void;
|
|
27
|
+
handleChangeDate: (date: string) => void;
|
|
28
|
+
handleChangeTime: (time: string) => void;
|
|
29
|
+
handleChangeDateRange: (start: string, end: string) => void;
|
|
30
|
+
handleFocusInput: () => void;
|
|
31
|
+
handleBlurInput: () => void;
|
|
32
|
+
calculatePositionWithScroll: (targetRect: TargetRect) => {
|
|
33
|
+
top: number;
|
|
34
|
+
left: number;
|
|
35
|
+
} | undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { useDatePicker };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/timePicker/useDateTimePicker.tsx
|
|
22
|
+
var useDateTimePicker_exports = {};
|
|
23
|
+
__export(useDateTimePicker_exports, {
|
|
24
|
+
useDatePicker: () => useDatePicker
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(useDateTimePicker_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
|
|
29
|
+
// src/components/picker/utils.ts
|
|
30
|
+
var formatDateToString = (date) => {
|
|
31
|
+
const year = date.getFullYear();
|
|
32
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
33
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
34
|
+
return `${year}-${month}-${day}`;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/components/timePicker/useDateTimePicker.tsx
|
|
38
|
+
var useDatePicker = ({ initialDate, initialTime, range = false }) => {
|
|
39
|
+
const [selectedDate, setSelectedDate] = (0, import_react.useState)(
|
|
40
|
+
initialDate ? formatDateToString(initialDate) : ""
|
|
41
|
+
);
|
|
42
|
+
const [selectedTime, setSelectedTime] = (0, import_react.useState)(initialTime ? initialTime : "");
|
|
43
|
+
const [startDate, setStartDate] = (0, import_react.useState)("");
|
|
44
|
+
const [endDate, setEndDate] = (0, import_react.useState)("");
|
|
45
|
+
const [targetRect, setTargetRect] = (0, import_react.useState)(null);
|
|
46
|
+
const [popupWidth, setPopupWidth] = (0, import_react.useState)(0);
|
|
47
|
+
const [popupHeight, setPopupHeight] = (0, import_react.useState)(0);
|
|
48
|
+
const [isFocusInput, setIsFocusInput] = (0, import_react.useState)(false);
|
|
49
|
+
const dateInputRef = (0, import_react.useRef)(null);
|
|
50
|
+
const datePickerWrapperRef = (0, import_react.useRef)(null);
|
|
51
|
+
const datePickerRef = (0, import_react.useRef)(null);
|
|
52
|
+
const DATE_PICKER_GAP = 4;
|
|
53
|
+
const calculatePositionWithScroll = (targetRect2) => {
|
|
54
|
+
if (targetRect2 && popupWidth && popupHeight) {
|
|
55
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
|
|
56
|
+
const scrollLeft = window.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft;
|
|
57
|
+
const spaceBelow = window.innerHeight - (targetRect2.y + targetRect2.height + DATE_PICKER_GAP);
|
|
58
|
+
const spaceAbove = targetRect2.y - DATE_PICKER_GAP;
|
|
59
|
+
const top = spaceBelow < popupHeight && spaceAbove > popupHeight ? targetRect2.y - popupHeight - DATE_PICKER_GAP : targetRect2.y + targetRect2.height + DATE_PICKER_GAP;
|
|
60
|
+
return {
|
|
61
|
+
top: top + scrollTop,
|
|
62
|
+
left: targetRect2.x + targetRect2.width - popupWidth + scrollLeft
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const handleToggleDatePicker = () => {
|
|
67
|
+
if (datePickerRef.current) {
|
|
68
|
+
const rect = datePickerRef.current.getBoundingClientRect();
|
|
69
|
+
setTargetRect((prevRect) => prevRect ? null : { x: rect.x, y: rect.y, width: rect.width, height: rect.height });
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const handleChangeDate = (date) => {
|
|
73
|
+
setSelectedDate(date);
|
|
74
|
+
};
|
|
75
|
+
const handleChangeTime = (time) => {
|
|
76
|
+
setSelectedTime(time);
|
|
77
|
+
};
|
|
78
|
+
const handleChangeDateRange = (start, end) => {
|
|
79
|
+
setStartDate(start);
|
|
80
|
+
setEndDate(end);
|
|
81
|
+
};
|
|
82
|
+
const handleFocusInput = () => {
|
|
83
|
+
setIsFocusInput(true);
|
|
84
|
+
};
|
|
85
|
+
const handleBlurInput = () => {
|
|
86
|
+
setIsFocusInput(false);
|
|
87
|
+
};
|
|
88
|
+
(0, import_react.useEffect)(() => {
|
|
89
|
+
const onClickOutside = (e) => {
|
|
90
|
+
if (datePickerRef.current && !datePickerRef.current.contains(e.target) && datePickerWrapperRef.current && !datePickerWrapperRef.current.contains(e.target)) {
|
|
91
|
+
setTargetRect(null);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
window.addEventListener("mousedown", onClickOutside);
|
|
95
|
+
return () => window.removeEventListener("mousedown", onClickOutside);
|
|
96
|
+
}, []);
|
|
97
|
+
(0, import_react.useEffect)(() => {
|
|
98
|
+
if (datePickerWrapperRef.current) {
|
|
99
|
+
setPopupHeight(datePickerWrapperRef.current.getBoundingClientRect().height);
|
|
100
|
+
setPopupWidth(datePickerWrapperRef.current.getBoundingClientRect().width);
|
|
101
|
+
}
|
|
102
|
+
}, [targetRect]);
|
|
103
|
+
return {
|
|
104
|
+
selectedDate,
|
|
105
|
+
selectedTime,
|
|
106
|
+
startDate,
|
|
107
|
+
endDate,
|
|
108
|
+
targetRect,
|
|
109
|
+
popupHeight,
|
|
110
|
+
isFocusInput,
|
|
111
|
+
dateInputRef,
|
|
112
|
+
datePickerWrapperRef,
|
|
113
|
+
datePickerRef,
|
|
114
|
+
handleToggleDatePicker,
|
|
115
|
+
handleChangeDate,
|
|
116
|
+
handleChangeTime,
|
|
117
|
+
handleChangeDateRange,
|
|
118
|
+
handleFocusInput,
|
|
119
|
+
handleBlurInput,
|
|
120
|
+
calculatePositionWithScroll
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
useDatePicker
|
|
126
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
formatDateToString
|
|
4
|
+
} from "../../chunk-FWFEKWWD.mjs";
|
|
5
|
+
import "../../chunk-AC6TWLRT.mjs";
|
|
6
|
+
|
|
7
|
+
// src/components/timePicker/useDateTimePicker.tsx
|
|
8
|
+
import { useState, useEffect, useRef } from "react";
|
|
9
|
+
var useDatePicker = ({ initialDate, initialTime, range = false }) => {
|
|
10
|
+
const [selectedDate, setSelectedDate] = useState(
|
|
11
|
+
initialDate ? formatDateToString(initialDate) : ""
|
|
12
|
+
);
|
|
13
|
+
const [selectedTime, setSelectedTime] = useState(initialTime ? initialTime : "");
|
|
14
|
+
const [startDate, setStartDate] = useState("");
|
|
15
|
+
const [endDate, setEndDate] = useState("");
|
|
16
|
+
const [targetRect, setTargetRect] = useState(null);
|
|
17
|
+
const [popupWidth, setPopupWidth] = useState(0);
|
|
18
|
+
const [popupHeight, setPopupHeight] = useState(0);
|
|
19
|
+
const [isFocusInput, setIsFocusInput] = useState(false);
|
|
20
|
+
const dateInputRef = useRef(null);
|
|
21
|
+
const datePickerWrapperRef = useRef(null);
|
|
22
|
+
const datePickerRef = useRef(null);
|
|
23
|
+
const DATE_PICKER_GAP = 4;
|
|
24
|
+
const calculatePositionWithScroll = (targetRect2) => {
|
|
25
|
+
if (targetRect2 && popupWidth && popupHeight) {
|
|
26
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
|
|
27
|
+
const scrollLeft = window.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft;
|
|
28
|
+
const spaceBelow = window.innerHeight - (targetRect2.y + targetRect2.height + DATE_PICKER_GAP);
|
|
29
|
+
const spaceAbove = targetRect2.y - DATE_PICKER_GAP;
|
|
30
|
+
const top = spaceBelow < popupHeight && spaceAbove > popupHeight ? targetRect2.y - popupHeight - DATE_PICKER_GAP : targetRect2.y + targetRect2.height + DATE_PICKER_GAP;
|
|
31
|
+
return {
|
|
32
|
+
top: top + scrollTop,
|
|
33
|
+
left: targetRect2.x + targetRect2.width - popupWidth + scrollLeft
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const handleToggleDatePicker = () => {
|
|
38
|
+
if (datePickerRef.current) {
|
|
39
|
+
const rect = datePickerRef.current.getBoundingClientRect();
|
|
40
|
+
setTargetRect((prevRect) => prevRect ? null : { x: rect.x, y: rect.y, width: rect.width, height: rect.height });
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const handleChangeDate = (date) => {
|
|
44
|
+
setSelectedDate(date);
|
|
45
|
+
};
|
|
46
|
+
const handleChangeTime = (time) => {
|
|
47
|
+
setSelectedTime(time);
|
|
48
|
+
};
|
|
49
|
+
const handleChangeDateRange = (start, end) => {
|
|
50
|
+
setStartDate(start);
|
|
51
|
+
setEndDate(end);
|
|
52
|
+
};
|
|
53
|
+
const handleFocusInput = () => {
|
|
54
|
+
setIsFocusInput(true);
|
|
55
|
+
};
|
|
56
|
+
const handleBlurInput = () => {
|
|
57
|
+
setIsFocusInput(false);
|
|
58
|
+
};
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const onClickOutside = (e) => {
|
|
61
|
+
if (datePickerRef.current && !datePickerRef.current.contains(e.target) && datePickerWrapperRef.current && !datePickerWrapperRef.current.contains(e.target)) {
|
|
62
|
+
setTargetRect(null);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
window.addEventListener("mousedown", onClickOutside);
|
|
66
|
+
return () => window.removeEventListener("mousedown", onClickOutside);
|
|
67
|
+
}, []);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (datePickerWrapperRef.current) {
|
|
70
|
+
setPopupHeight(datePickerWrapperRef.current.getBoundingClientRect().height);
|
|
71
|
+
setPopupWidth(datePickerWrapperRef.current.getBoundingClientRect().width);
|
|
72
|
+
}
|
|
73
|
+
}, [targetRect]);
|
|
74
|
+
return {
|
|
75
|
+
selectedDate,
|
|
76
|
+
selectedTime,
|
|
77
|
+
startDate,
|
|
78
|
+
endDate,
|
|
79
|
+
targetRect,
|
|
80
|
+
popupHeight,
|
|
81
|
+
isFocusInput,
|
|
82
|
+
dateInputRef,
|
|
83
|
+
datePickerWrapperRef,
|
|
84
|
+
datePickerRef,
|
|
85
|
+
handleToggleDatePicker,
|
|
86
|
+
handleChangeDate,
|
|
87
|
+
handleChangeTime,
|
|
88
|
+
handleChangeDateRange,
|
|
89
|
+
handleFocusInput,
|
|
90
|
+
handleBlurInput,
|
|
91
|
+
calculatePositionWithScroll
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export {
|
|
95
|
+
useDatePicker
|
|
96
|
+
};
|