@deepnoid/ui 0.0.89 → 0.0.90
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/chunk-2ZFHB4JM.mjs +76 -0
- package/dist/chunk-75HLCORR.mjs +1 -0
- package/dist/{chunk-FPCP4OOL.mjs → chunk-EDEV4IK4.mjs} +3 -3
- package/dist/{chunk-HFVZFUC3.mjs → chunk-L7P6OBUX.mjs} +1 -1
- package/dist/chunk-N6IEGD4K.mjs +119 -0
- package/dist/chunk-P732YGHO.mjs +18 -0
- package/dist/chunk-S2VUKVCH.mjs +319 -0
- package/dist/{chunk-MOINJECK.mjs → chunk-S3O52LLG.mjs} +1 -2
- package/dist/chunk-WX32MAKV.mjs +219 -0
- package/dist/components/accordion/accordion.d.mts +2 -2
- package/dist/components/accordion/accordion.d.ts +2 -2
- package/dist/components/accordion/accordion.test.mjs +3 -3
- package/dist/components/accordion/accordionItem.d.mts +2 -2
- package/dist/components/accordion/accordionItem.d.ts +2 -2
- package/dist/components/button/button-group.d.mts +2 -2
- package/dist/components/button/button-group.d.ts +2 -2
- package/dist/components/button/button-group.test.mjs +3 -3
- package/dist/components/button/button.d.mts +2 -2
- package/dist/components/button/button.d.ts +2 -2
- package/dist/components/button/button.test.mjs +3 -3
- package/dist/components/card/card.d.mts +2 -2
- package/dist/components/card/card.d.ts +2 -2
- package/dist/components/checkbox/checkbox.d.mts +2 -2
- package/dist/components/checkbox/checkbox.d.ts +2 -2
- package/dist/components/checkbox/checkbox.test.mjs +3 -3
- package/dist/components/dateTimePicker/calendar.d.mts +118 -0
- package/dist/components/dateTimePicker/calendar.d.ts +118 -0
- package/dist/components/dateTimePicker/calendar.js +3854 -0
- package/dist/components/dateTimePicker/calendar.mjs +16 -0
- package/dist/components/dateTimePicker/dateTimePicker.d.mts +443 -0
- package/dist/components/dateTimePicker/dateTimePicker.d.ts +443 -0
- package/dist/components/dateTimePicker/dateTimePicker.js +4486 -0
- package/dist/components/dateTimePicker/dateTimePicker.mjs +22 -0
- package/dist/components/dateTimePicker/index.d.mts +5 -0
- package/dist/components/dateTimePicker/index.d.ts +5 -0
- package/dist/components/dateTimePicker/index.js +4487 -0
- package/dist/components/dateTimePicker/index.mjs +21 -0
- package/dist/components/dateTimePicker/timePicker.d.mts +10 -0
- package/dist/components/dateTimePicker/timePicker.d.ts +10 -0
- package/dist/components/dateTimePicker/timePicker.js +342 -0
- package/dist/components/dateTimePicker/timePicker.mjs +13 -0
- package/dist/components/dateTimePicker/useDateTimePicker.d.mts +31 -0
- package/dist/components/dateTimePicker/useDateTimePicker.d.ts +31 -0
- package/dist/components/dateTimePicker/useDateTimePicker.js +106 -0
- package/dist/components/dateTimePicker/useDateTimePicker.mjs +9 -0
- package/dist/components/dateTimePicker/util.d.mts +4 -0
- package/dist/components/dateTimePicker/util.d.ts +4 -0
- package/dist/components/dateTimePicker/util.js +42 -0
- package/dist/components/dateTimePicker/util.mjs +10 -0
- package/dist/components/input/input.d.mts +2 -2
- package/dist/components/input/input.d.ts +2 -2
- package/dist/components/input/input.test.mjs +1 -1
- package/dist/components/list/index.js +3 -3
- package/dist/components/list/index.mjs +1 -1
- package/dist/components/list/list.d.mts +2 -2
- package/dist/components/list/list.d.ts +2 -2
- package/dist/components/list/listItem.d.mts +3 -3
- package/dist/components/list/listItem.d.ts +3 -3
- package/dist/components/list/listItem.js +3 -3
- package/dist/components/list/listItem.mjs +1 -1
- package/dist/components/modal/index.js +1 -1
- package/dist/components/modal/index.mjs +1 -1
- package/dist/components/modal/modal.d.mts +2 -2
- package/dist/components/modal/modal.d.ts +2 -2
- package/dist/components/modal/modal.js +1 -1
- package/dist/components/modal/modal.mjs +1 -1
- package/dist/components/modal/modal.test.js +1 -1
- package/dist/components/modal/modal.test.mjs +2 -2
- package/dist/components/pagination/pagination.d.mts +2 -2
- package/dist/components/pagination/pagination.d.ts +2 -2
- package/dist/components/progress/progress.d.mts +2 -2
- package/dist/components/progress/progress.d.ts +2 -2
- package/dist/components/radio/radio.d.mts +2 -2
- package/dist/components/radio/radio.d.ts +2 -2
- package/dist/components/select/index.mjs +2 -2
- package/dist/components/select/select.d.mts +2 -2
- package/dist/components/select/select.d.ts +2 -2
- package/dist/components/select/select.mjs +2 -2
- package/dist/components/select/select.test.mjs +5 -5
- package/dist/components/select/useSelect.d.mts +3 -3
- package/dist/components/select/useSelect.d.ts +3 -3
- package/dist/components/slider/slider.d.mts +2 -2
- package/dist/components/slider/slider.d.ts +2 -2
- package/dist/components/switch/index.js +1 -2
- package/dist/components/switch/index.mjs +1 -1
- package/dist/components/switch/switch.d.mts +2 -2
- package/dist/components/switch/switch.d.ts +2 -2
- package/dist/components/switch/switch.js +1 -2
- package/dist/components/switch/switch.mjs +1 -1
- package/dist/components/switch/switch.test.js +1 -2
- package/dist/components/switch/switch.test.mjs +1 -1
- package/dist/components/table/table-body.d.mts +2 -2
- package/dist/components/table/table-body.d.ts +2 -2
- package/dist/components/table/table.d.mts +5 -5
- package/dist/components/table/table.d.ts +5 -5
- package/dist/components/tabs/tabs.d.mts +2 -2
- package/dist/components/tabs/tabs.d.ts +2 -2
- package/dist/components/tabs/tabs.test.mjs +3 -3
- package/dist/components/textarea/textarea.d.mts +2 -2
- package/dist/components/textarea/textarea.d.ts +2 -2
- package/dist/components/textarea/textarea.test.mjs +1 -1
- package/dist/components/toast/toast.d.mts +2 -2
- package/dist/components/toast/toast.d.ts +2 -2
- package/dist/components/tooltip/index.d.mts +1 -1
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/components/tooltip/tooltip-utils.d.mts +1 -1
- package/dist/components/tooltip/tooltip-utils.d.ts +1 -1
- package/dist/components/tooltip/tooltip.d.mts +3 -3
- package/dist/components/tooltip/tooltip.d.ts +3 -3
- package/dist/components/tooltip/tooltip.test.mjs +3 -3
- package/dist/components/tooltip/useTooltip.d.mts +1 -1
- package/dist/components/tooltip/useTooltip.d.ts +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +697 -6
- package/dist/index.mjs +62 -43
- package/dist/{tooltip-utils-DCKA5gnI.d.mts → tooltip-utils-CrCabndd.d.mts} +2 -2
- package/dist/{tooltip-utils-DCKA5gnI.d.ts → tooltip-utils-CrCabndd.d.ts} +2 -2
- package/package.json +1 -1
- package/dist/{chunk-JN7EGKJL.mjs → chunk-2BCJZILI.mjs} +3 -3
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
formatDateToString
|
|
4
|
+
} from "./chunk-P732YGHO.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/dateTimePicker/useDateTimePicker.tsx
|
|
7
|
+
import { useState, useEffect, useRef } from "react";
|
|
8
|
+
var useDatePicker = ({ initialDate, initialTime }) => {
|
|
9
|
+
const [selectedDate, setSelectedDate] = useState(
|
|
10
|
+
initialDate ? formatDateToString(initialDate) : ""
|
|
11
|
+
);
|
|
12
|
+
const [selectedTime, setSelectedTime] = useState(initialTime ? initialTime : "");
|
|
13
|
+
const [targetRect, setTargetRect] = useState(null);
|
|
14
|
+
const [popupWidth, setPopupWidth] = useState(0);
|
|
15
|
+
const [popupHeight, setPopupHeight] = useState(0);
|
|
16
|
+
const dateInputRef = useRef(null);
|
|
17
|
+
const datePickerWrapperRef = useRef(null);
|
|
18
|
+
const datePickerRef = useRef(null);
|
|
19
|
+
const dataPickerGap = 4;
|
|
20
|
+
const calculatePositionWithScroll = (targetRect2, popupHeight2) => {
|
|
21
|
+
if (popupWidth === 0 || popupHeight2 === 0) return;
|
|
22
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
|
|
23
|
+
const scrollLeft = window.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft;
|
|
24
|
+
const spaceBelow = window.innerHeight - (targetRect2.y + targetRect2.height + dataPickerGap);
|
|
25
|
+
const spaceAbove = targetRect2.y - dataPickerGap;
|
|
26
|
+
const top = spaceBelow < popupHeight2 && spaceAbove > popupHeight2 ? targetRect2.y - popupHeight2 - dataPickerGap : targetRect2.y + targetRect2.height + dataPickerGap;
|
|
27
|
+
return {
|
|
28
|
+
top: top + scrollTop,
|
|
29
|
+
left: targetRect2.x + targetRect2.width - popupWidth + scrollLeft
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const handleToggleDatePicker = () => {
|
|
33
|
+
if (datePickerRef.current) {
|
|
34
|
+
const rect = datePickerRef.current.getBoundingClientRect();
|
|
35
|
+
setTargetRect((prevRect) => prevRect ? null : { x: rect.x, y: rect.y, width: rect.width, height: rect.height });
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const handleChangeDate = (date) => {
|
|
39
|
+
setSelectedDate(date);
|
|
40
|
+
};
|
|
41
|
+
const handleChangeTime = (time) => {
|
|
42
|
+
setSelectedTime(time);
|
|
43
|
+
};
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const onClickOutside = (e) => {
|
|
46
|
+
if (datePickerRef.current && !datePickerRef.current.contains(e.target) && datePickerWrapperRef.current && !datePickerWrapperRef.current.contains(e.target)) {
|
|
47
|
+
setTargetRect(null);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
window.addEventListener("mousedown", onClickOutside);
|
|
51
|
+
return () => window.removeEventListener("mousedown", onClickOutside);
|
|
52
|
+
}, []);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (datePickerWrapperRef.current) {
|
|
55
|
+
setPopupHeight(datePickerWrapperRef.current.getBoundingClientRect().height);
|
|
56
|
+
setPopupWidth(datePickerWrapperRef.current.getBoundingClientRect().width);
|
|
57
|
+
}
|
|
58
|
+
}, [targetRect]);
|
|
59
|
+
return {
|
|
60
|
+
selectedDate,
|
|
61
|
+
selectedTime,
|
|
62
|
+
targetRect,
|
|
63
|
+
popupHeight,
|
|
64
|
+
dateInputRef,
|
|
65
|
+
datePickerWrapperRef,
|
|
66
|
+
datePickerRef,
|
|
67
|
+
handleToggleDatePicker,
|
|
68
|
+
handleChangeDate,
|
|
69
|
+
handleChangeTime,
|
|
70
|
+
calculatePositionWithScroll
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
useDatePicker
|
|
76
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -65,13 +65,13 @@ var listItem = tv({
|
|
|
65
65
|
},
|
|
66
66
|
size: {
|
|
67
67
|
sm: {
|
|
68
|
-
base: "h-[30px] text-sm"
|
|
68
|
+
base: "min-h-[30px] text-sm"
|
|
69
69
|
},
|
|
70
70
|
md: {
|
|
71
|
-
base: "h-[40px] text-md"
|
|
71
|
+
base: "min-h-[40px] text-md"
|
|
72
72
|
},
|
|
73
73
|
lg: {
|
|
74
|
-
base: "h-[50px] text-lg"
|
|
74
|
+
base: "min-h-[50px] text-lg"
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
color: {
|
|
@@ -149,7 +149,7 @@ Modal.displayName = "Modal";
|
|
|
149
149
|
var modal_default = Modal;
|
|
150
150
|
var modal = tv({
|
|
151
151
|
slots: {
|
|
152
|
-
backdrop: ["relative w-screen h-screen fixed inset-0 bg-black/60", "z-[
|
|
152
|
+
backdrop: ["relative w-screen h-screen fixed inset-0 bg-black/60", "z-[900]"],
|
|
153
153
|
modalWrapper: ["group/modal", "absolute", "top-1/2", "-translate-y-1/2", "left-1/2", "-translate-x-1/2"],
|
|
154
154
|
icon: ["absolute", "top-[20px]", "left-1/2", "-translate-x-1/2", "z-10"],
|
|
155
155
|
closeIcon: [
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
list_default
|
|
4
|
+
} from "./chunk-EYY4CRRR.mjs";
|
|
5
|
+
import {
|
|
6
|
+
listItem_default
|
|
7
|
+
} from "./chunk-EDEV4IK4.mjs";
|
|
8
|
+
|
|
9
|
+
// src/components/dateTimePicker/timePicker.tsx
|
|
10
|
+
import { useState, useRef, useEffect } from "react";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
var TimePicker = ({ color = "primary", selectedTime, onChangeTime }) => {
|
|
13
|
+
const TOTAL_HOURS = 12;
|
|
14
|
+
const TOTAL_MINUTES = 60;
|
|
15
|
+
const ITEM_HEIGHT = 30;
|
|
16
|
+
const PERIODS = ["AM", "PM"];
|
|
17
|
+
const [selectedHour, setSelectedHour] = useState("01");
|
|
18
|
+
const [selectedMinute, setSelectedMinute] = useState("00");
|
|
19
|
+
const [selectedPeriod, setSelectedPeriod] = useState("AM");
|
|
20
|
+
const hourRef = useRef(null);
|
|
21
|
+
const minuteRef = useRef(null);
|
|
22
|
+
const periodRef = useRef(null);
|
|
23
|
+
const hoursArray = [...Array(TOTAL_HOURS).keys()].map((i) => (i + 1).toString().padStart(2, "0"));
|
|
24
|
+
const minutesArray = [...Array(TOTAL_MINUTES).keys()].map((i) => i.toString().padStart(2, "0"));
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (selectedTime) {
|
|
27
|
+
const { formattedHour, minute, period } = parseAndFormatTime(selectedTime);
|
|
28
|
+
setSelectedHour(formattedHour);
|
|
29
|
+
setSelectedMinute(minute);
|
|
30
|
+
setSelectedPeriod(period);
|
|
31
|
+
}
|
|
32
|
+
}, [selectedTime]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
scrollToSelectedTime();
|
|
35
|
+
}, []);
|
|
36
|
+
const parseAndFormatTime = (time) => {
|
|
37
|
+
const [hour, minute] = time.split(":").map((part) => part.padStart(2, "0"));
|
|
38
|
+
const parsedHour = parseInt(hour, 10);
|
|
39
|
+
const period = parsedHour >= 12 ? "PM" : "AM";
|
|
40
|
+
const formattedHour = parsedHour % 12 === 0 ? "12" : (parsedHour % 12).toString().padStart(2, "0");
|
|
41
|
+
return { formattedHour, minute, period };
|
|
42
|
+
};
|
|
43
|
+
const scrollToSelectedTime = () => {
|
|
44
|
+
if (selectedTime) {
|
|
45
|
+
const { formattedHour, minute, period } = parseAndFormatTime(selectedTime);
|
|
46
|
+
if (hourRef.current) {
|
|
47
|
+
hourRef.current.scrollTop = (parseInt(formattedHour) - 1) * ITEM_HEIGHT;
|
|
48
|
+
}
|
|
49
|
+
if (minuteRef.current) {
|
|
50
|
+
minuteRef.current.scrollTop = parseInt(minute) * ITEM_HEIGHT;
|
|
51
|
+
}
|
|
52
|
+
if (periodRef.current) {
|
|
53
|
+
periodRef.current.scrollTop = period === "AM" ? 0 : ITEM_HEIGHT;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const handleTimeChange = (hour, minute, period) => {
|
|
58
|
+
const parsedHour = parseInt(hour);
|
|
59
|
+
let hour24 = parsedHour;
|
|
60
|
+
if (period === "PM" && parsedHour !== 12) {
|
|
61
|
+
hour24 = parsedHour + 12;
|
|
62
|
+
} else if (period === "AM" && parsedHour === 12) {
|
|
63
|
+
hour24 = 0;
|
|
64
|
+
}
|
|
65
|
+
const formattedTime = `${hour24.toString().padStart(2, "0")}:${minute}`;
|
|
66
|
+
if (onChangeTime) {
|
|
67
|
+
onChangeTime(formattedTime);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-[200px] p-[10px] gap-[5px] border border-neutral-main rounded-md bg-background shadow-lg", children: [
|
|
71
|
+
/* @__PURE__ */ jsx(list_default, { ref: periodRef, classNames: { base: "overflow-y-auto scrollbar-hide" }, children: PERIODS.map((period, index) => /* @__PURE__ */ jsx(
|
|
72
|
+
listItem_default,
|
|
73
|
+
{
|
|
74
|
+
color,
|
|
75
|
+
selected: period === selectedPeriod,
|
|
76
|
+
title: period,
|
|
77
|
+
size: "sm",
|
|
78
|
+
classNames: { base: "w-[50px] min-h-[30px]", titleWrapper: "flex justify-center" },
|
|
79
|
+
onClick: () => {
|
|
80
|
+
handleTimeChange(selectedHour, selectedMinute, period);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
`${period}-${index}`
|
|
84
|
+
)) }),
|
|
85
|
+
/* @__PURE__ */ jsx(list_default, { ref: hourRef, classNames: { base: "overflow-y-auto scrollbar-hide" }, children: hoursArray.map((hour, index) => /* @__PURE__ */ jsx(
|
|
86
|
+
listItem_default,
|
|
87
|
+
{
|
|
88
|
+
color,
|
|
89
|
+
selected: hour === selectedHour,
|
|
90
|
+
title: hour,
|
|
91
|
+
size: "sm",
|
|
92
|
+
classNames: { base: "w-[50px] min-h-[30px]", titleWrapper: "flex justify-center" },
|
|
93
|
+
onClick: () => {
|
|
94
|
+
handleTimeChange(hour, selectedMinute, selectedPeriod);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
`${hour}-${index}`
|
|
98
|
+
)) }),
|
|
99
|
+
/* @__PURE__ */ jsx(list_default, { ref: minuteRef, classNames: { base: "overflow-y-auto scrollbar-hide" }, children: minutesArray.map((minute, index) => /* @__PURE__ */ jsx(
|
|
100
|
+
listItem_default,
|
|
101
|
+
{
|
|
102
|
+
color,
|
|
103
|
+
selected: minute === selectedMinute,
|
|
104
|
+
title: minute,
|
|
105
|
+
size: "sm",
|
|
106
|
+
classNames: { base: "w-[50px] min-h-[30px]", titleWrapper: "flex justify-center" },
|
|
107
|
+
onClick: () => {
|
|
108
|
+
handleTimeChange(selectedHour, minute, selectedPeriod);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
`${minute}-${index}`
|
|
112
|
+
)) })
|
|
113
|
+
] });
|
|
114
|
+
};
|
|
115
|
+
var timePicker_default = TimePicker;
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
timePicker_default
|
|
119
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/dateTimePicker/util.ts
|
|
4
|
+
var formatDateToString = (date) => {
|
|
5
|
+
const year = date.getFullYear();
|
|
6
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
7
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
8
|
+
return `${year}-${month}-${day}`;
|
|
9
|
+
};
|
|
10
|
+
var formatStringToDate = (date) => {
|
|
11
|
+
const formattedDate = new Date(date);
|
|
12
|
+
return formattedDate;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
formatDateToString,
|
|
17
|
+
formatStringToDate
|
|
18
|
+
};
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useDatePicker
|
|
4
|
+
} from "./chunk-2ZFHB4JM.mjs";
|
|
5
|
+
import {
|
|
6
|
+
calendar_default
|
|
7
|
+
} from "./chunk-WX32MAKV.mjs";
|
|
8
|
+
import {
|
|
9
|
+
timePicker_default
|
|
10
|
+
} from "./chunk-N6IEGD4K.mjs";
|
|
11
|
+
import {
|
|
12
|
+
Icon_default
|
|
13
|
+
} from "./chunk-LCI6RPWE.mjs";
|
|
14
|
+
import {
|
|
15
|
+
mapPropsVariants
|
|
16
|
+
} from "./chunk-E3G5QXSH.mjs";
|
|
17
|
+
import {
|
|
18
|
+
tv
|
|
19
|
+
} from "./chunk-J725QONZ.mjs";
|
|
20
|
+
|
|
21
|
+
// src/components/dateTimePicker/dateTimePicker.tsx
|
|
22
|
+
import React, { forwardRef, useCallback, useMemo } from "react";
|
|
23
|
+
import { createPortal } from "react-dom";
|
|
24
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
25
|
+
var DatePicker = forwardRef((originalProps, ref) => {
|
|
26
|
+
const [props, variantProps] = mapPropsVariants(originalProps, dateTimePickerStyle.variantKeys);
|
|
27
|
+
const { classNames, label, errorMessage, startContent, endContent, type = "date", ...inputProps } = props;
|
|
28
|
+
const slots = useMemo(() => dateTimePickerStyle({ ...variantProps }), [variantProps]);
|
|
29
|
+
const {
|
|
30
|
+
selectedDate,
|
|
31
|
+
selectedTime,
|
|
32
|
+
targetRect,
|
|
33
|
+
popupHeight,
|
|
34
|
+
datePickerRef,
|
|
35
|
+
dateInputRef,
|
|
36
|
+
datePickerWrapperRef,
|
|
37
|
+
handleToggleDatePicker,
|
|
38
|
+
handleChangeDate,
|
|
39
|
+
handleChangeTime,
|
|
40
|
+
calculatePositionWithScroll
|
|
41
|
+
} = useDatePicker({
|
|
42
|
+
initialDate: void 0
|
|
43
|
+
});
|
|
44
|
+
const position = targetRect ? calculatePositionWithScroll(targetRect, popupHeight) : null;
|
|
45
|
+
const getBaseProps = useCallback(
|
|
46
|
+
() => ({
|
|
47
|
+
className: slots.base({ class: classNames == null ? void 0 : classNames.base })
|
|
48
|
+
}),
|
|
49
|
+
[slots, classNames]
|
|
50
|
+
);
|
|
51
|
+
const getLabelProps = useCallback(
|
|
52
|
+
() => ({
|
|
53
|
+
className: slots.label({ class: classNames == null ? void 0 : classNames.label })
|
|
54
|
+
}),
|
|
55
|
+
[slots, classNames]
|
|
56
|
+
);
|
|
57
|
+
const getInnerWrapperProps = useCallback(
|
|
58
|
+
() => ({
|
|
59
|
+
className: slots.innerWrapper({ class: classNames == null ? void 0 : classNames.innerWrapper })
|
|
60
|
+
}),
|
|
61
|
+
[slots, classNames]
|
|
62
|
+
);
|
|
63
|
+
const getInputWrapperProps = useCallback(
|
|
64
|
+
() => ({
|
|
65
|
+
className: slots.inputWrapper({ class: classNames == null ? void 0 : classNames.inputWrapper }),
|
|
66
|
+
ref: datePickerRef
|
|
67
|
+
}),
|
|
68
|
+
[slots, classNames]
|
|
69
|
+
);
|
|
70
|
+
const getInputProps = useCallback(
|
|
71
|
+
() => ({
|
|
72
|
+
...inputProps,
|
|
73
|
+
ref: ref || dateInputRef,
|
|
74
|
+
className: slots.input({ class: classNames == null ? void 0 : classNames.input }),
|
|
75
|
+
size: 0,
|
|
76
|
+
type,
|
|
77
|
+
value: type === "date" ? selectedDate || "" : type === "time" ? selectedTime || "" : "",
|
|
78
|
+
onChange: (e) => {
|
|
79
|
+
if (type === "date") {
|
|
80
|
+
handleChangeDate(e.target.value);
|
|
81
|
+
} else if (type === "time") {
|
|
82
|
+
handleChangeTime(e.target.value);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
max: "9999-12-31"
|
|
86
|
+
}),
|
|
87
|
+
[inputProps, ref, dateInputRef, slots, classNames == null ? void 0 : classNames.input, selectedDate]
|
|
88
|
+
);
|
|
89
|
+
const getContentProps = useCallback(
|
|
90
|
+
() => ({
|
|
91
|
+
className: slots.content({ class: classNames == null ? void 0 : classNames.content }),
|
|
92
|
+
size: originalProps.size
|
|
93
|
+
}),
|
|
94
|
+
[slots, classNames, originalProps.size]
|
|
95
|
+
);
|
|
96
|
+
const getErrorMessageProps = useCallback(
|
|
97
|
+
() => ({
|
|
98
|
+
className: slots.errorMessage({ class: classNames == null ? void 0 : classNames.errorMessage })
|
|
99
|
+
}),
|
|
100
|
+
[slots, classNames]
|
|
101
|
+
);
|
|
102
|
+
const renderStartContent = () => {
|
|
103
|
+
if (React.isValidElement(startContent)) {
|
|
104
|
+
const existingProps = startContent.props;
|
|
105
|
+
const mergedProps = {
|
|
106
|
+
...getContentProps(),
|
|
107
|
+
className: `${getContentProps().className || ""} ${existingProps.className || ""}`.trim()
|
|
108
|
+
};
|
|
109
|
+
return React.cloneElement(startContent, mergedProps);
|
|
110
|
+
} else {
|
|
111
|
+
const contentProps = getContentProps();
|
|
112
|
+
return /* @__PURE__ */ jsx("div", { ...contentProps, children: startContent });
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const renderDateTimePickerIcon = () => /* @__PURE__ */ jsx("div", { ...getContentProps(), onClick: handleToggleDatePicker, children: /* @__PURE__ */ jsx(
|
|
116
|
+
Icon_default,
|
|
117
|
+
{
|
|
118
|
+
name: type === "time" ? "clock" : "calendar",
|
|
119
|
+
size: originalProps.size,
|
|
120
|
+
className: "cursor-pointer",
|
|
121
|
+
fill: type === "date"
|
|
122
|
+
}
|
|
123
|
+
) });
|
|
124
|
+
const renderContentWithIcon = () => {
|
|
125
|
+
if (React.isValidElement(endContent)) {
|
|
126
|
+
const existingProps = endContent.props;
|
|
127
|
+
const mergedProps = {
|
|
128
|
+
...getContentProps(),
|
|
129
|
+
className: `${getContentProps().className || ""} ${existingProps.className || ""}`.trim()
|
|
130
|
+
};
|
|
131
|
+
return React.cloneElement(endContent, mergedProps);
|
|
132
|
+
} else if (errorMessage) {
|
|
133
|
+
const iconProps = { ...getContentProps(), className: getContentProps().className };
|
|
134
|
+
return /* @__PURE__ */ jsx("div", { ...iconProps, children: /* @__PURE__ */ jsx(Icon_default, { name: "exclamation-circle", fill: true, size: originalProps.size }) });
|
|
135
|
+
} else {
|
|
136
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const renderEndContent = () => {
|
|
140
|
+
switch (type) {
|
|
141
|
+
case "date":
|
|
142
|
+
case "datetime-local":
|
|
143
|
+
case "month":
|
|
144
|
+
case "week":
|
|
145
|
+
case "time":
|
|
146
|
+
return renderDateTimePickerIcon();
|
|
147
|
+
default:
|
|
148
|
+
return renderContentWithIcon();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
152
|
+
/* @__PURE__ */ jsxs("div", { ...getBaseProps(), children: [
|
|
153
|
+
label && /* @__PURE__ */ jsx("label", { ...getLabelProps(), children: label }),
|
|
154
|
+
/* @__PURE__ */ jsxs("div", { ...getInnerWrapperProps(), children: [
|
|
155
|
+
/* @__PURE__ */ jsxs("div", { ...getInputWrapperProps(), children: [
|
|
156
|
+
startContent && renderStartContent(),
|
|
157
|
+
/* @__PURE__ */ jsx("input", { ...getInputProps() }),
|
|
158
|
+
renderEndContent()
|
|
159
|
+
] }),
|
|
160
|
+
errorMessage && /* @__PURE__ */ jsx("p", { ...getErrorMessageProps(), children: errorMessage })
|
|
161
|
+
] })
|
|
162
|
+
] }),
|
|
163
|
+
targetRect && /* @__PURE__ */ jsx(Fragment, { children: createPortal(
|
|
164
|
+
/* @__PURE__ */ jsxs(
|
|
165
|
+
"div",
|
|
166
|
+
{
|
|
167
|
+
ref: datePickerWrapperRef,
|
|
168
|
+
style: {
|
|
169
|
+
position: "absolute",
|
|
170
|
+
top: position == null ? void 0 : position.top,
|
|
171
|
+
left: position == null ? void 0 : position.left,
|
|
172
|
+
zIndex: 1e3
|
|
173
|
+
},
|
|
174
|
+
children: [
|
|
175
|
+
type === "date" && /* @__PURE__ */ jsx(
|
|
176
|
+
calendar_default,
|
|
177
|
+
{
|
|
178
|
+
color: originalProps.color,
|
|
179
|
+
selectedDate,
|
|
180
|
+
highlightWeekend: originalProps.highlightWeekend,
|
|
181
|
+
onChangeDate: handleChangeDate
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
type === "time" && /* @__PURE__ */ jsx(timePicker_default, { color: originalProps.color, selectedTime, onChangeTime: handleChangeTime })
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
document.body
|
|
189
|
+
) })
|
|
190
|
+
] });
|
|
191
|
+
});
|
|
192
|
+
DatePicker.displayName = "DatePicker";
|
|
193
|
+
var dateTimePicker_default = DatePicker;
|
|
194
|
+
var dateTimePickerStyle = tv({
|
|
195
|
+
slots: {
|
|
196
|
+
base: ["group/input", "flex", "flex-col", "inline-block"],
|
|
197
|
+
label: ["flex", "items-center"],
|
|
198
|
+
innerWrapper: ["flex", "flex-col"],
|
|
199
|
+
inputWrapper: [
|
|
200
|
+
"flex",
|
|
201
|
+
"items-center",
|
|
202
|
+
"transition",
|
|
203
|
+
"duration-200",
|
|
204
|
+
"group-has-[p]/input:border-danger-main",
|
|
205
|
+
"group-has-[p]/input:bg-danger-soft"
|
|
206
|
+
],
|
|
207
|
+
input: ["w-full", "h-full", "bg-transparent", "placeholder:text-neutral-main", "focus-visible:outline-none"],
|
|
208
|
+
content: ["flex", "items-center", "select-none", "group-has-[p]/input:text-danger-main"],
|
|
209
|
+
errorMessage: ["text-danger-main"]
|
|
210
|
+
},
|
|
211
|
+
variants: {
|
|
212
|
+
variant: {
|
|
213
|
+
solid: {
|
|
214
|
+
inputWrapper: ["bg-trans-soft", "hover:bg-trans-light", "has-[:focus]:bg-trans-light"]
|
|
215
|
+
},
|
|
216
|
+
normal: {
|
|
217
|
+
inputWrapper: [
|
|
218
|
+
"bg-transparent",
|
|
219
|
+
"border",
|
|
220
|
+
"border-neutral-main",
|
|
221
|
+
"hover:bg-trans-soft",
|
|
222
|
+
"has-[:focus]:bg-trans-soft"
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
line: {
|
|
226
|
+
inputWrapper: [
|
|
227
|
+
"bg-transparent",
|
|
228
|
+
"border-b",
|
|
229
|
+
"border-neutral-main",
|
|
230
|
+
"!rounded-none",
|
|
231
|
+
"hover:bg-trans-soft",
|
|
232
|
+
"has-[:focus]:bg-trans-soft"
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
color: {
|
|
237
|
+
primary: {
|
|
238
|
+
inputWrapper: ["has-[:focus]:border-primary-main"],
|
|
239
|
+
content: ["text-primary-main"]
|
|
240
|
+
},
|
|
241
|
+
secondary: {
|
|
242
|
+
inputWrapper: ["has-[:focus]:border-secondary-main"],
|
|
243
|
+
content: ["text-secondary-main"]
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
size: {
|
|
247
|
+
sm: {
|
|
248
|
+
base: ["text-sm", "gap-[6px]"],
|
|
249
|
+
innerWrapper: ["group-has-[p]/input:gap-[6px]"],
|
|
250
|
+
inputWrapper: ["w-[240px]", "h-[24px]", "rounded-sm", "px-[6px]", "py-[4.5px]", "gap-[6px]"],
|
|
251
|
+
errorMessage: ["text-sm"]
|
|
252
|
+
},
|
|
253
|
+
md: {
|
|
254
|
+
base: ["text-md", "gap-[8px]"],
|
|
255
|
+
innerWrapper: ["group-has-[p]/input:gap-[8px]"],
|
|
256
|
+
inputWrapper: ["w-[240px]", "h-[30px]", "rounded-md", "px-[8px]", "py-[6.5px]", "gap-[8px]"],
|
|
257
|
+
errorMessage: ["text-md"]
|
|
258
|
+
},
|
|
259
|
+
lg: {
|
|
260
|
+
base: ["text-lg", "gap-[10px]"],
|
|
261
|
+
innerWrapper: ["group-has-[p]/input:gap-[10px]"],
|
|
262
|
+
inputWrapper: ["w-[240px]", "h-[36px]", "rounded-lg", "px-[10px]", "py-[8px]", "gap-[10px]"],
|
|
263
|
+
errorMessage: ["text-lg"]
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
radius: {
|
|
267
|
+
default: "",
|
|
268
|
+
none: {
|
|
269
|
+
inputWrapper: ["rounded-none"]
|
|
270
|
+
},
|
|
271
|
+
full: {
|
|
272
|
+
inputWrapper: ["rounded-full"]
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
fullWidth: {
|
|
276
|
+
true: {
|
|
277
|
+
base: ["w-full"],
|
|
278
|
+
innerWrapper: ["flex-1"],
|
|
279
|
+
inputWrapper: ["w-full"]
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
isDisabled: {
|
|
283
|
+
true: {
|
|
284
|
+
label: ["text-neutral-light"],
|
|
285
|
+
inputWrapper: ["bg-neutral-soft", "border-neutral-light", "pointer-events-none"],
|
|
286
|
+
input: ["text-neutral-light", "placeholder:text-neutral-light"],
|
|
287
|
+
content: ["text-neutral-light"],
|
|
288
|
+
errorMessage: ["text-danger-light"]
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
isRequired: {
|
|
292
|
+
true: {
|
|
293
|
+
label: ["after:content-['*']", "after:text-danger-main", "after:ml-0.5"]
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
defaultVariants: {
|
|
298
|
+
variant: "solid",
|
|
299
|
+
color: "primary",
|
|
300
|
+
size: "md",
|
|
301
|
+
fullWidth: false,
|
|
302
|
+
isDisabled: false,
|
|
303
|
+
isRequired: false
|
|
304
|
+
},
|
|
305
|
+
compoundVariants: [
|
|
306
|
+
{
|
|
307
|
+
isDisabled: true,
|
|
308
|
+
isRequired: true,
|
|
309
|
+
class: {
|
|
310
|
+
label: ["after:text-danger-light"]
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
]
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
export {
|
|
317
|
+
dateTimePicker_default,
|
|
318
|
+
dateTimePickerStyle
|
|
319
|
+
};
|