@deepnoid/ui 0.0.90 → 0.0.92
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-L7P6OBUX.mjs → chunk-3WTG4YNN.mjs} +2 -2
- package/dist/{chunk-2ZFHB4JM.mjs → chunk-FWJ2ZKH6.mjs} +23 -12
- package/dist/{chunk-N6IEGD4K.mjs → chunk-NUIYVRYF.mjs} +6 -3
- package/dist/{chunk-EDEV4IK4.mjs → chunk-SKQNTNEA.mjs} +5 -5
- package/dist/{chunk-S2VUKVCH.mjs → chunk-VNO4XOQG.mjs} +50 -10
- package/dist/components/dateTimePicker/dateTimePicker.d.mts +2 -0
- package/dist/components/dateTimePicker/dateTimePicker.d.ts +2 -0
- package/dist/components/dateTimePicker/dateTimePicker.js +81 -27
- package/dist/components/dateTimePicker/dateTimePicker.mjs +4 -4
- package/dist/components/dateTimePicker/index.js +81 -27
- package/dist/components/dateTimePicker/index.mjs +4 -4
- package/dist/components/dateTimePicker/timePicker.d.mts +2 -1
- package/dist/components/dateTimePicker/timePicker.d.ts +2 -1
- package/dist/components/dateTimePicker/timePicker.js +10 -7
- package/dist/components/dateTimePicker/timePicker.mjs +2 -2
- package/dist/components/dateTimePicker/useDateTimePicker.d.mts +4 -1
- package/dist/components/dateTimePicker/useDateTimePicker.d.ts +4 -1
- package/dist/components/dateTimePicker/useDateTimePicker.js +23 -12
- package/dist/components/dateTimePicker/useDateTimePicker.mjs +1 -1
- package/dist/components/list/index.js +5 -5
- package/dist/components/list/index.mjs +1 -1
- package/dist/components/list/listItem.js +5 -5
- package/dist/components/list/listItem.mjs +1 -1
- package/dist/components/modal/index.js +2 -2
- package/dist/components/modal/index.mjs +1 -1
- package/dist/components/modal/modal.js +2 -2
- package/dist/components/modal/modal.mjs +1 -1
- package/dist/components/modal/modal.test.js +2 -2
- package/dist/components/modal/modal.test.mjs +1 -1
- package/dist/components/select/index.mjs +2 -2
- package/dist/components/select/select.mjs +2 -2
- package/dist/components/select/select.test.mjs +2 -2
- package/dist/index.js +83 -29
- package/dist/index.mjs +20 -20
- package/package.json +1 -1
- package/dist/{chunk-2BCJZILI.mjs → chunk-JN7EGKJL.mjs} +3 -3
|
@@ -151,7 +151,7 @@ var modal = tv({
|
|
|
151
151
|
slots: {
|
|
152
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
|
-
icon: ["absolute", "top-[
|
|
154
|
+
icon: ["absolute", "top-[0px]", "left-1/2", "-translate-x-1/2", "z-10"],
|
|
155
155
|
closeIcon: [
|
|
156
156
|
"absolute",
|
|
157
157
|
"top-[20px]",
|
|
@@ -170,7 +170,7 @@ var modal = tv({
|
|
|
170
170
|
"bg-background",
|
|
171
171
|
"shadow-drop shadow-foreground/20 rounded-xxlg",
|
|
172
172
|
"overflow-hidden",
|
|
173
|
-
"group-data-[icon-visibility=true]/modal:mt-[
|
|
173
|
+
"group-data-[icon-visibility=true]/modal:mt-[40px]",
|
|
174
174
|
"group-data-[icon-visibility=true]/modal:pt-[60px]"
|
|
175
175
|
],
|
|
176
176
|
body: ["flex", "flex-col", "gap-[20px]"],
|
|
@@ -13,21 +13,23 @@ var useDatePicker = ({ initialDate, initialTime }) => {
|
|
|
13
13
|
const [targetRect, setTargetRect] = useState(null);
|
|
14
14
|
const [popupWidth, setPopupWidth] = useState(0);
|
|
15
15
|
const [popupHeight, setPopupHeight] = useState(0);
|
|
16
|
+
const [isFocusInput, setIsFocusInput] = useState(false);
|
|
16
17
|
const dateInputRef = useRef(null);
|
|
17
18
|
const datePickerWrapperRef = useRef(null);
|
|
18
19
|
const datePickerRef = useRef(null);
|
|
19
|
-
const
|
|
20
|
-
const calculatePositionWithScroll = (targetRect2
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const DATE_PICKER_GAP = 4;
|
|
21
|
+
const calculatePositionWithScroll = (targetRect2) => {
|
|
22
|
+
if (targetRect2 && popupWidth && popupHeight) {
|
|
23
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
|
|
24
|
+
const scrollLeft = window.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft;
|
|
25
|
+
const spaceBelow = window.innerHeight - (targetRect2.y + targetRect2.height + DATE_PICKER_GAP);
|
|
26
|
+
const spaceAbove = targetRect2.y - DATE_PICKER_GAP;
|
|
27
|
+
const top = spaceBelow < popupHeight && spaceAbove > popupHeight ? targetRect2.y - popupHeight - DATE_PICKER_GAP : targetRect2.y + targetRect2.height + DATE_PICKER_GAP;
|
|
28
|
+
return {
|
|
29
|
+
top: top + scrollTop,
|
|
30
|
+
left: targetRect2.x + targetRect2.width - popupWidth + scrollLeft
|
|
31
|
+
};
|
|
32
|
+
}
|
|
31
33
|
};
|
|
32
34
|
const handleToggleDatePicker = () => {
|
|
33
35
|
if (datePickerRef.current) {
|
|
@@ -41,6 +43,12 @@ var useDatePicker = ({ initialDate, initialTime }) => {
|
|
|
41
43
|
const handleChangeTime = (time) => {
|
|
42
44
|
setSelectedTime(time);
|
|
43
45
|
};
|
|
46
|
+
const handleFocusInput = () => {
|
|
47
|
+
setIsFocusInput(true);
|
|
48
|
+
};
|
|
49
|
+
const handleBlueInput = () => {
|
|
50
|
+
setIsFocusInput(false);
|
|
51
|
+
};
|
|
44
52
|
useEffect(() => {
|
|
45
53
|
const onClickOutside = (e) => {
|
|
46
54
|
if (datePickerRef.current && !datePickerRef.current.contains(e.target) && datePickerWrapperRef.current && !datePickerWrapperRef.current.contains(e.target)) {
|
|
@@ -61,12 +69,15 @@ var useDatePicker = ({ initialDate, initialTime }) => {
|
|
|
61
69
|
selectedTime,
|
|
62
70
|
targetRect,
|
|
63
71
|
popupHeight,
|
|
72
|
+
isFocusInput,
|
|
64
73
|
dateInputRef,
|
|
65
74
|
datePickerWrapperRef,
|
|
66
75
|
datePickerRef,
|
|
67
76
|
handleToggleDatePicker,
|
|
68
77
|
handleChangeDate,
|
|
69
78
|
handleChangeTime,
|
|
79
|
+
handleFocusInput,
|
|
80
|
+
handleBlueInput,
|
|
70
81
|
calculatePositionWithScroll
|
|
71
82
|
};
|
|
72
83
|
};
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
} from "./chunk-EYY4CRRR.mjs";
|
|
5
5
|
import {
|
|
6
6
|
listItem_default
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-SKQNTNEA.mjs";
|
|
8
8
|
|
|
9
9
|
// src/components/dateTimePicker/timePicker.tsx
|
|
10
10
|
import { useState, useRef, useEffect } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
var TimePicker = ({ color = "primary", selectedTime, onChangeTime }) => {
|
|
12
|
+
var TimePicker = ({ color = "primary", selectedTime, isFocusInput, onChangeTime }) => {
|
|
13
13
|
const TOTAL_HOURS = 12;
|
|
14
14
|
const TOTAL_MINUTES = 60;
|
|
15
15
|
const ITEM_HEIGHT = 30;
|
|
@@ -29,7 +29,10 @@ var TimePicker = ({ color = "primary", selectedTime, onChangeTime }) => {
|
|
|
29
29
|
setSelectedMinute(minute);
|
|
30
30
|
setSelectedPeriod(period);
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
if (isFocusInput) {
|
|
33
|
+
scrollToSelectedTime();
|
|
34
|
+
}
|
|
35
|
+
}, [selectedTime, isFocusInput]);
|
|
33
36
|
useEffect(() => {
|
|
34
37
|
scrollToSelectedTime();
|
|
35
38
|
}, []);
|
|
@@ -94,10 +94,10 @@ var listItem = tv({
|
|
|
94
94
|
color: "primary",
|
|
95
95
|
class: {
|
|
96
96
|
base: [
|
|
97
|
-
"hover:text-primary-
|
|
97
|
+
"hover:text-primary-strong",
|
|
98
98
|
"hover:bg-primary-soft",
|
|
99
|
-
"data-[selected=true]:text-
|
|
100
|
-
"data-[selected=true]:bg-primary-
|
|
99
|
+
"data-[selected=true]:text-white",
|
|
100
|
+
"data-[selected=true]:bg-primary-main"
|
|
101
101
|
]
|
|
102
102
|
}
|
|
103
103
|
},
|
|
@@ -108,8 +108,8 @@ var listItem = tv({
|
|
|
108
108
|
base: [
|
|
109
109
|
"hover:text-secondary-main",
|
|
110
110
|
"hover:bg-secondary-soft",
|
|
111
|
-
"data-[selected=true]:text-
|
|
112
|
-
"data-[selected=true]:bg-secondary-
|
|
111
|
+
"data-[selected=true]:text-white",
|
|
112
|
+
"data-[selected=true]:bg-secondary-main"
|
|
113
113
|
]
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useDatePicker
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FWJ2ZKH6.mjs";
|
|
5
5
|
import {
|
|
6
6
|
calendar_default
|
|
7
7
|
} from "./chunk-WX32MAKV.mjs";
|
|
8
8
|
import {
|
|
9
9
|
timePicker_default
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NUIYVRYF.mjs";
|
|
11
11
|
import {
|
|
12
12
|
Icon_default
|
|
13
13
|
} from "./chunk-LCI6RPWE.mjs";
|
|
@@ -24,24 +24,38 @@ import { createPortal } from "react-dom";
|
|
|
24
24
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
25
25
|
var DatePicker = forwardRef((originalProps, ref) => {
|
|
26
26
|
const [props, variantProps] = mapPropsVariants(originalProps, dateTimePickerStyle.variantKeys);
|
|
27
|
-
const {
|
|
27
|
+
const {
|
|
28
|
+
classNames,
|
|
29
|
+
label,
|
|
30
|
+
errorMessage,
|
|
31
|
+
startContent,
|
|
32
|
+
endContent,
|
|
33
|
+
type = "date",
|
|
34
|
+
value,
|
|
35
|
+
onChangeDate,
|
|
36
|
+
onChangeTime,
|
|
37
|
+
...inputProps
|
|
38
|
+
} = props;
|
|
28
39
|
const slots = useMemo(() => dateTimePickerStyle({ ...variantProps }), [variantProps]);
|
|
29
40
|
const {
|
|
30
41
|
selectedDate,
|
|
31
42
|
selectedTime,
|
|
32
43
|
targetRect,
|
|
33
44
|
popupHeight,
|
|
45
|
+
isFocusInput,
|
|
34
46
|
datePickerRef,
|
|
35
47
|
dateInputRef,
|
|
36
48
|
datePickerWrapperRef,
|
|
37
49
|
handleToggleDatePicker,
|
|
38
50
|
handleChangeDate,
|
|
39
51
|
handleChangeTime,
|
|
52
|
+
handleFocusInput,
|
|
53
|
+
handleBlueInput,
|
|
40
54
|
calculatePositionWithScroll
|
|
41
55
|
} = useDatePicker({
|
|
42
56
|
initialDate: void 0
|
|
43
57
|
});
|
|
44
|
-
const position = targetRect ? calculatePositionWithScroll(targetRect
|
|
58
|
+
const position = targetRect ? calculatePositionWithScroll(targetRect) : null;
|
|
45
59
|
const getBaseProps = useCallback(
|
|
46
60
|
() => ({
|
|
47
61
|
className: slots.base({ class: classNames == null ? void 0 : classNames.base })
|
|
@@ -74,17 +88,29 @@ var DatePicker = forwardRef((originalProps, ref) => {
|
|
|
74
88
|
className: slots.input({ class: classNames == null ? void 0 : classNames.input }),
|
|
75
89
|
size: 0,
|
|
76
90
|
type,
|
|
77
|
-
value: type === "date" ? selectedDate || "" : type === "time" ? selectedTime || "" : "",
|
|
91
|
+
value: value !== void 0 ? value : type === "date" ? selectedDate || "" : type === "time" ? selectedTime || "" : "",
|
|
78
92
|
onChange: (e) => {
|
|
79
93
|
if (type === "date") {
|
|
80
94
|
handleChangeDate(e.target.value);
|
|
95
|
+
if (onChangeDate) {
|
|
96
|
+
onChangeDate(e.target.value);
|
|
97
|
+
}
|
|
81
98
|
} else if (type === "time") {
|
|
82
99
|
handleChangeTime(e.target.value);
|
|
100
|
+
if (onChangeTime) {
|
|
101
|
+
onChangeTime(e.target.value);
|
|
102
|
+
}
|
|
83
103
|
}
|
|
84
104
|
},
|
|
105
|
+
onFocus: (e) => {
|
|
106
|
+
handleFocusInput();
|
|
107
|
+
},
|
|
108
|
+
onBlur: (e) => {
|
|
109
|
+
handleBlueInput();
|
|
110
|
+
},
|
|
85
111
|
max: "9999-12-31"
|
|
86
112
|
}),
|
|
87
|
-
[inputProps, ref, dateInputRef, slots, classNames == null ? void 0 : classNames.input, selectedDate]
|
|
113
|
+
[inputProps, ref, dateInputRef, slots, classNames == null ? void 0 : classNames.input, selectedDate, selectedTime, type, value]
|
|
88
114
|
);
|
|
89
115
|
const getContentProps = useCallback(
|
|
90
116
|
() => ({
|
|
@@ -167,8 +193,8 @@ var DatePicker = forwardRef((originalProps, ref) => {
|
|
|
167
193
|
ref: datePickerWrapperRef,
|
|
168
194
|
style: {
|
|
169
195
|
position: "absolute",
|
|
170
|
-
top: position == null ? void 0 : position.top,
|
|
171
|
-
left: position == null ? void 0 : position.left,
|
|
196
|
+
top: (position == null ? void 0 : position.top) || -99999,
|
|
197
|
+
left: (position == null ? void 0 : position.left) || -99999,
|
|
172
198
|
zIndex: 1e3
|
|
173
199
|
},
|
|
174
200
|
children: [
|
|
@@ -178,10 +204,24 @@ var DatePicker = forwardRef((originalProps, ref) => {
|
|
|
178
204
|
color: originalProps.color,
|
|
179
205
|
selectedDate,
|
|
180
206
|
highlightWeekend: originalProps.highlightWeekend,
|
|
181
|
-
onChangeDate:
|
|
207
|
+
onChangeDate: (date) => {
|
|
208
|
+
handleChangeDate(date);
|
|
209
|
+
if (onChangeDate) onChangeDate(date);
|
|
210
|
+
}
|
|
182
211
|
}
|
|
183
212
|
),
|
|
184
|
-
type === "time" && /* @__PURE__ */ jsx(
|
|
213
|
+
type === "time" && /* @__PURE__ */ jsx(
|
|
214
|
+
timePicker_default,
|
|
215
|
+
{
|
|
216
|
+
color: originalProps.color,
|
|
217
|
+
selectedTime,
|
|
218
|
+
isFocusInput,
|
|
219
|
+
onChangeTime: (time) => {
|
|
220
|
+
handleChangeTime(time);
|
|
221
|
+
if (onChangeTime) onChangeTime(time);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
)
|
|
185
225
|
]
|
|
186
226
|
}
|
|
187
227
|
),
|
|
@@ -17,6 +17,8 @@ interface Props extends Omit<ComponentProps<"input">, "size"> {
|
|
|
17
17
|
size?: "sm" | "md" | "lg";
|
|
18
18
|
}> | string;
|
|
19
19
|
classNames?: SlotsToClasses<DateTimePickerSlots>;
|
|
20
|
+
onChangeDate?: (date: string) => void;
|
|
21
|
+
onChangeTime?: (time: string) => void;
|
|
20
22
|
}
|
|
21
23
|
type DateTimePickerProps = Props & DateTimePickerVariantProps;
|
|
22
24
|
declare const DatePicker: React__default.ForwardRefExoticComponent<Omit<DateTimePickerProps, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
|
|
@@ -17,6 +17,8 @@ interface Props extends Omit<ComponentProps<"input">, "size"> {
|
|
|
17
17
|
size?: "sm" | "md" | "lg";
|
|
18
18
|
}> | string;
|
|
19
19
|
classNames?: SlotsToClasses<DateTimePickerSlots>;
|
|
20
|
+
onChangeDate?: (date: string) => void;
|
|
21
|
+
onChangeTime?: (time: string) => void;
|
|
20
22
|
}
|
|
21
23
|
type DateTimePickerProps = Props & DateTimePickerVariantProps;
|
|
22
24
|
declare const DatePicker: React__default.ForwardRefExoticComponent<Omit<DateTimePickerProps, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
|
|
@@ -101,21 +101,23 @@ var useDatePicker = ({ initialDate, initialTime }) => {
|
|
|
101
101
|
const [targetRect, setTargetRect] = (0, import_react.useState)(null);
|
|
102
102
|
const [popupWidth, setPopupWidth] = (0, import_react.useState)(0);
|
|
103
103
|
const [popupHeight, setPopupHeight] = (0, import_react.useState)(0);
|
|
104
|
+
const [isFocusInput, setIsFocusInput] = (0, import_react.useState)(false);
|
|
104
105
|
const dateInputRef = (0, import_react.useRef)(null);
|
|
105
106
|
const datePickerWrapperRef = (0, import_react.useRef)(null);
|
|
106
107
|
const datePickerRef = (0, import_react.useRef)(null);
|
|
107
|
-
const
|
|
108
|
-
const calculatePositionWithScroll = (targetRect2
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
const DATE_PICKER_GAP = 4;
|
|
109
|
+
const calculatePositionWithScroll = (targetRect2) => {
|
|
110
|
+
if (targetRect2 && popupWidth && popupHeight) {
|
|
111
|
+
const scrollTop = window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
|
|
112
|
+
const scrollLeft = window.scrollX || document.documentElement.scrollLeft || document.body.scrollLeft;
|
|
113
|
+
const spaceBelow = window.innerHeight - (targetRect2.y + targetRect2.height + DATE_PICKER_GAP);
|
|
114
|
+
const spaceAbove = targetRect2.y - DATE_PICKER_GAP;
|
|
115
|
+
const top = spaceBelow < popupHeight && spaceAbove > popupHeight ? targetRect2.y - popupHeight - DATE_PICKER_GAP : targetRect2.y + targetRect2.height + DATE_PICKER_GAP;
|
|
116
|
+
return {
|
|
117
|
+
top: top + scrollTop,
|
|
118
|
+
left: targetRect2.x + targetRect2.width - popupWidth + scrollLeft
|
|
119
|
+
};
|
|
120
|
+
}
|
|
119
121
|
};
|
|
120
122
|
const handleToggleDatePicker = () => {
|
|
121
123
|
if (datePickerRef.current) {
|
|
@@ -129,6 +131,12 @@ var useDatePicker = ({ initialDate, initialTime }) => {
|
|
|
129
131
|
const handleChangeTime = (time) => {
|
|
130
132
|
setSelectedTime(time);
|
|
131
133
|
};
|
|
134
|
+
const handleFocusInput = () => {
|
|
135
|
+
setIsFocusInput(true);
|
|
136
|
+
};
|
|
137
|
+
const handleBlueInput = () => {
|
|
138
|
+
setIsFocusInput(false);
|
|
139
|
+
};
|
|
132
140
|
(0, import_react.useEffect)(() => {
|
|
133
141
|
const onClickOutside = (e) => {
|
|
134
142
|
if (datePickerRef.current && !datePickerRef.current.contains(e.target) && datePickerWrapperRef.current && !datePickerWrapperRef.current.contains(e.target)) {
|
|
@@ -149,12 +157,15 @@ var useDatePicker = ({ initialDate, initialTime }) => {
|
|
|
149
157
|
selectedTime,
|
|
150
158
|
targetRect,
|
|
151
159
|
popupHeight,
|
|
160
|
+
isFocusInput,
|
|
152
161
|
dateInputRef,
|
|
153
162
|
datePickerWrapperRef,
|
|
154
163
|
datePickerRef,
|
|
155
164
|
handleToggleDatePicker,
|
|
156
165
|
handleChangeDate,
|
|
157
166
|
handleChangeTime,
|
|
167
|
+
handleFocusInput,
|
|
168
|
+
handleBlueInput,
|
|
158
169
|
calculatePositionWithScroll
|
|
159
170
|
};
|
|
160
171
|
};
|
|
@@ -4059,10 +4070,10 @@ var listItem = tv({
|
|
|
4059
4070
|
color: "primary",
|
|
4060
4071
|
class: {
|
|
4061
4072
|
base: [
|
|
4062
|
-
"hover:text-primary-
|
|
4073
|
+
"hover:text-primary-strong",
|
|
4063
4074
|
"hover:bg-primary-soft",
|
|
4064
|
-
"data-[selected=true]:text-
|
|
4065
|
-
"data-[selected=true]:bg-primary-
|
|
4075
|
+
"data-[selected=true]:text-white",
|
|
4076
|
+
"data-[selected=true]:bg-primary-main"
|
|
4066
4077
|
]
|
|
4067
4078
|
}
|
|
4068
4079
|
},
|
|
@@ -4073,8 +4084,8 @@ var listItem = tv({
|
|
|
4073
4084
|
base: [
|
|
4074
4085
|
"hover:text-secondary-main",
|
|
4075
4086
|
"hover:bg-secondary-soft",
|
|
4076
|
-
"data-[selected=true]:text-
|
|
4077
|
-
"data-[selected=true]:bg-secondary-
|
|
4087
|
+
"data-[selected=true]:text-white",
|
|
4088
|
+
"data-[selected=true]:bg-secondary-main"
|
|
4078
4089
|
]
|
|
4079
4090
|
}
|
|
4080
4091
|
}
|
|
@@ -4083,7 +4094,7 @@ var listItem = tv({
|
|
|
4083
4094
|
|
|
4084
4095
|
// src/components/dateTimePicker/timePicker.tsx
|
|
4085
4096
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
4086
|
-
var TimePicker = ({ color = "primary", selectedTime, onChangeTime }) => {
|
|
4097
|
+
var TimePicker = ({ color = "primary", selectedTime, isFocusInput, onChangeTime }) => {
|
|
4087
4098
|
const TOTAL_HOURS = 12;
|
|
4088
4099
|
const TOTAL_MINUTES = 60;
|
|
4089
4100
|
const ITEM_HEIGHT = 30;
|
|
@@ -4103,7 +4114,10 @@ var TimePicker = ({ color = "primary", selectedTime, onChangeTime }) => {
|
|
|
4103
4114
|
setSelectedMinute(minute);
|
|
4104
4115
|
setSelectedPeriod(period);
|
|
4105
4116
|
}
|
|
4106
|
-
|
|
4117
|
+
if (isFocusInput) {
|
|
4118
|
+
scrollToSelectedTime();
|
|
4119
|
+
}
|
|
4120
|
+
}, [selectedTime, isFocusInput]);
|
|
4107
4121
|
(0, import_react5.useEffect)(() => {
|
|
4108
4122
|
scrollToSelectedTime();
|
|
4109
4123
|
}, []);
|
|
@@ -4192,24 +4206,38 @@ var timePicker_default = TimePicker;
|
|
|
4192
4206
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
4193
4207
|
var DatePicker = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
4194
4208
|
const [props, variantProps] = mapPropsVariants(originalProps, dateTimePickerStyle.variantKeys);
|
|
4195
|
-
const {
|
|
4209
|
+
const {
|
|
4210
|
+
classNames,
|
|
4211
|
+
label,
|
|
4212
|
+
errorMessage,
|
|
4213
|
+
startContent,
|
|
4214
|
+
endContent,
|
|
4215
|
+
type = "date",
|
|
4216
|
+
value,
|
|
4217
|
+
onChangeDate,
|
|
4218
|
+
onChangeTime,
|
|
4219
|
+
...inputProps
|
|
4220
|
+
} = props;
|
|
4196
4221
|
const slots = (0, import_react6.useMemo)(() => dateTimePickerStyle({ ...variantProps }), [variantProps]);
|
|
4197
4222
|
const {
|
|
4198
4223
|
selectedDate,
|
|
4199
4224
|
selectedTime,
|
|
4200
4225
|
targetRect,
|
|
4201
4226
|
popupHeight,
|
|
4227
|
+
isFocusInput,
|
|
4202
4228
|
datePickerRef,
|
|
4203
4229
|
dateInputRef,
|
|
4204
4230
|
datePickerWrapperRef,
|
|
4205
4231
|
handleToggleDatePicker,
|
|
4206
4232
|
handleChangeDate,
|
|
4207
4233
|
handleChangeTime,
|
|
4234
|
+
handleFocusInput,
|
|
4235
|
+
handleBlueInput,
|
|
4208
4236
|
calculatePositionWithScroll
|
|
4209
4237
|
} = useDatePicker({
|
|
4210
4238
|
initialDate: void 0
|
|
4211
4239
|
});
|
|
4212
|
-
const position = targetRect ? calculatePositionWithScroll(targetRect
|
|
4240
|
+
const position = targetRect ? calculatePositionWithScroll(targetRect) : null;
|
|
4213
4241
|
const getBaseProps = (0, import_react6.useCallback)(
|
|
4214
4242
|
() => ({
|
|
4215
4243
|
className: slots.base({ class: classNames == null ? void 0 : classNames.base })
|
|
@@ -4242,17 +4270,29 @@ var DatePicker = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
|
4242
4270
|
className: slots.input({ class: classNames == null ? void 0 : classNames.input }),
|
|
4243
4271
|
size: 0,
|
|
4244
4272
|
type,
|
|
4245
|
-
value: type === "date" ? selectedDate || "" : type === "time" ? selectedTime || "" : "",
|
|
4273
|
+
value: value !== void 0 ? value : type === "date" ? selectedDate || "" : type === "time" ? selectedTime || "" : "",
|
|
4246
4274
|
onChange: (e) => {
|
|
4247
4275
|
if (type === "date") {
|
|
4248
4276
|
handleChangeDate(e.target.value);
|
|
4277
|
+
if (onChangeDate) {
|
|
4278
|
+
onChangeDate(e.target.value);
|
|
4279
|
+
}
|
|
4249
4280
|
} else if (type === "time") {
|
|
4250
4281
|
handleChangeTime(e.target.value);
|
|
4282
|
+
if (onChangeTime) {
|
|
4283
|
+
onChangeTime(e.target.value);
|
|
4284
|
+
}
|
|
4251
4285
|
}
|
|
4252
4286
|
},
|
|
4287
|
+
onFocus: (e) => {
|
|
4288
|
+
handleFocusInput();
|
|
4289
|
+
},
|
|
4290
|
+
onBlur: (e) => {
|
|
4291
|
+
handleBlueInput();
|
|
4292
|
+
},
|
|
4253
4293
|
max: "9999-12-31"
|
|
4254
4294
|
}),
|
|
4255
|
-
[inputProps, ref, dateInputRef, slots, classNames == null ? void 0 : classNames.input, selectedDate]
|
|
4295
|
+
[inputProps, ref, dateInputRef, slots, classNames == null ? void 0 : classNames.input, selectedDate, selectedTime, type, value]
|
|
4256
4296
|
);
|
|
4257
4297
|
const getContentProps = (0, import_react6.useCallback)(
|
|
4258
4298
|
() => ({
|
|
@@ -4335,8 +4375,8 @@ var DatePicker = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
|
4335
4375
|
ref: datePickerWrapperRef,
|
|
4336
4376
|
style: {
|
|
4337
4377
|
position: "absolute",
|
|
4338
|
-
top: position == null ? void 0 : position.top,
|
|
4339
|
-
left: position == null ? void 0 : position.left,
|
|
4378
|
+
top: (position == null ? void 0 : position.top) || -99999,
|
|
4379
|
+
left: (position == null ? void 0 : position.left) || -99999,
|
|
4340
4380
|
zIndex: 1e3
|
|
4341
4381
|
},
|
|
4342
4382
|
children: [
|
|
@@ -4346,10 +4386,24 @@ var DatePicker = (0, import_react6.forwardRef)((originalProps, ref) => {
|
|
|
4346
4386
|
color: originalProps.color,
|
|
4347
4387
|
selectedDate,
|
|
4348
4388
|
highlightWeekend: originalProps.highlightWeekend,
|
|
4349
|
-
onChangeDate:
|
|
4389
|
+
onChangeDate: (date) => {
|
|
4390
|
+
handleChangeDate(date);
|
|
4391
|
+
if (onChangeDate) onChangeDate(date);
|
|
4392
|
+
}
|
|
4350
4393
|
}
|
|
4351
4394
|
),
|
|
4352
|
-
type === "time" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4395
|
+
type === "time" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4396
|
+
timePicker_default,
|
|
4397
|
+
{
|
|
4398
|
+
color: originalProps.color,
|
|
4399
|
+
selectedTime,
|
|
4400
|
+
isFocusInput,
|
|
4401
|
+
onChangeTime: (time) => {
|
|
4402
|
+
handleChangeTime(time);
|
|
4403
|
+
if (onChangeTime) onChangeTime(time);
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
)
|
|
4353
4407
|
]
|
|
4354
4408
|
}
|
|
4355
4409
|
),
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
dateTimePickerStyle,
|
|
4
4
|
dateTimePicker_default
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
5
|
+
} from "../../chunk-VNO4XOQG.mjs";
|
|
6
|
+
import "../../chunk-FWJ2ZKH6.mjs";
|
|
7
7
|
import "../../chunk-WX32MAKV.mjs";
|
|
8
8
|
import "../../chunk-P732YGHO.mjs";
|
|
9
|
-
import "../../chunk-
|
|
9
|
+
import "../../chunk-NUIYVRYF.mjs";
|
|
10
10
|
import "../../chunk-7MVEAQ7Z.mjs";
|
|
11
11
|
import "../../chunk-EYY4CRRR.mjs";
|
|
12
|
-
import "../../chunk-
|
|
12
|
+
import "../../chunk-SKQNTNEA.mjs";
|
|
13
13
|
import "../../chunk-ZYIIXWVY.mjs";
|
|
14
14
|
import "../../chunk-LCI6RPWE.mjs";
|
|
15
15
|
import "../../chunk-IOCRFIQF.mjs";
|