@cognite/aura 0.3.1 → 0.3.2
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/DESIGN.md +1517 -2
- package/README.md +21 -0
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +37 -35
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +64 -75
- package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +1 -2
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +38 -49
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +64 -75
- package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +1 -2
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +51 -64
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +146 -161
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +1 -2
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +124 -137
- package/dist/components/ui/core/date-time-pickers/index.d.ts +2 -0
- package/dist/components/ui/core/date-time-pickers/index.js +6 -4
- package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +8 -8
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.d.ts +1 -1
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +1 -1
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.d.ts +0 -2
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +18 -34
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.d.ts +2 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +19 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +41 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.d.ts +16 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +100 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +23 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +64 -0
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +17 -15
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +83 -85
- package/dist/lib/use-controllable-state.js +17 -17
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ export interface UseDateTimeRangePickerReturn {
|
|
|
21
21
|
tempEndMinute: number;
|
|
22
22
|
startAmPm: 'AM' | 'PM';
|
|
23
23
|
endAmPm: 'AM' | 'PM';
|
|
24
|
-
|
|
24
|
+
handleOpenChange: (open: boolean) => void;
|
|
25
25
|
handleSetStep: (step: RangeSelectionStep) => void;
|
|
26
26
|
handleDateClick: (date: Dayjs) => void;
|
|
27
27
|
handleMonthChange: (month: Dayjs) => void;
|
|
@@ -34,7 +34,6 @@ export interface UseDateTimeRangePickerReturn {
|
|
|
34
34
|
handleEndAmPmChange: (value: 'AM' | 'PM') => void;
|
|
35
35
|
handleNext: () => void;
|
|
36
36
|
handleApply: () => void;
|
|
37
|
-
handleCancel: () => void;
|
|
38
37
|
handleBack: () => void;
|
|
39
38
|
handleApplyShortcut: (range: Dayjs | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null]) => void;
|
|
40
39
|
popoverRef: React.RefObject<HTMLDivElement>;
|
|
@@ -1,161 +1,148 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import
|
|
3
|
-
import { DEFAULT_MINUTE as
|
|
4
|
-
import { usePopoverState as
|
|
5
|
-
import { useRangeDateState as
|
|
6
|
-
import { useRangeStepManager as
|
|
7
|
-
import { useTimeState as
|
|
8
|
-
function
|
|
9
|
-
return
|
|
1
|
+
import { useRef as mt, useCallback as n, useEffect as ut } from "react";
|
|
2
|
+
import ht from "dayjs";
|
|
3
|
+
import { DEFAULT_MINUTE as f, START_OF_DAY_HOUR as S, END_OF_DAY_MINUTE as A, END_OF_DAY_HOUR as D } from "../shared/constants.js";
|
|
4
|
+
import { usePopoverState as ct } from "../shared/hooks/use-popover-state.js";
|
|
5
|
+
import { useRangeDateState as dt } from "../shared/hooks/use-range-date-state.js";
|
|
6
|
+
import { useRangeStepManager as lt } from "../shared/hooks/use-range-step-manager.js";
|
|
7
|
+
import { useTimeState as _ } from "../shared/hooks/use-time-state.js";
|
|
8
|
+
function pt(e) {
|
|
9
|
+
return e.hour(S).minute(f);
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function ft(e) {
|
|
12
|
+
return e.hour(D).minute(A);
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
value:
|
|
14
|
+
const gt = ({
|
|
15
|
+
value: e,
|
|
16
16
|
onChange: r,
|
|
17
17
|
timeFormat: M = "24h",
|
|
18
|
-
defaultDate:
|
|
18
|
+
defaultDate: y = ht()
|
|
19
19
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
}),
|
|
22
|
-
}), {
|
|
23
|
-
isOpen: h,
|
|
24
|
-
setIsOpen: o,
|
|
25
|
-
popoverRef: w,
|
|
26
|
-
inputRef: x,
|
|
27
|
-
handleTogglePopover: H
|
|
28
|
-
} = pe({
|
|
29
|
-
onClose: n(() => C.current(), []),
|
|
20
|
+
const E = mt(() => {
|
|
21
|
+
}), { isOpen: B, setIsOpen: s, popoverRef: N, inputRef: U } = ct({
|
|
30
22
|
onBackspace: n(() => E.current(), [])
|
|
31
|
-
}),
|
|
32
|
-
value:
|
|
33
|
-
defaultDate:
|
|
34
|
-
mapDate: (
|
|
23
|
+
}), F = lt(), { step: i, handleNext: h, handleBack: a, resetStep: H } = F, I = dt({
|
|
24
|
+
value: e,
|
|
25
|
+
defaultDate: y,
|
|
26
|
+
mapDate: (t, o) => o === "start" ? pt(t) : ft(t)
|
|
35
27
|
}), {
|
|
36
|
-
tempStart:
|
|
37
|
-
tempEnd:
|
|
38
|
-
displayedMonth:
|
|
39
|
-
hoverDate:
|
|
40
|
-
stateRef:
|
|
41
|
-
handleDateClick:
|
|
42
|
-
handleDateHover:
|
|
43
|
-
handleMonthChange:
|
|
44
|
-
clearActiveSegment:
|
|
45
|
-
resetDates:
|
|
46
|
-
} =
|
|
47
|
-
initialHour:
|
|
48
|
-
initialMinute:
|
|
28
|
+
tempStart: Y,
|
|
29
|
+
tempEnd: w,
|
|
30
|
+
displayedMonth: x,
|
|
31
|
+
hoverDate: b,
|
|
32
|
+
stateRef: m,
|
|
33
|
+
handleDateClick: T,
|
|
34
|
+
handleDateHover: j,
|
|
35
|
+
handleMonthChange: L,
|
|
36
|
+
clearActiveSegment: g,
|
|
37
|
+
resetDates: u
|
|
38
|
+
} = I, q = _({
|
|
39
|
+
initialHour: e[0]?.hour() ?? S,
|
|
40
|
+
initialMinute: e[0]?.minute() ?? f,
|
|
49
41
|
timeFormat: M
|
|
50
42
|
}), {
|
|
51
|
-
hour:
|
|
52
|
-
minute:
|
|
53
|
-
amPm:
|
|
54
|
-
hour24:
|
|
55
|
-
handleHourChange:
|
|
56
|
-
handleMinuteChange:
|
|
57
|
-
handleAmPmChange:
|
|
58
|
-
resetTime:
|
|
59
|
-
} =
|
|
60
|
-
initialHour:
|
|
61
|
-
initialMinute:
|
|
43
|
+
hour: z,
|
|
44
|
+
minute: c,
|
|
45
|
+
amPm: G,
|
|
46
|
+
hour24: C,
|
|
47
|
+
handleHourChange: J,
|
|
48
|
+
handleMinuteChange: K,
|
|
49
|
+
handleAmPmChange: Q,
|
|
50
|
+
resetTime: O
|
|
51
|
+
} = q, W = _({
|
|
52
|
+
initialHour: e[1]?.hour() ?? D,
|
|
53
|
+
initialMinute: e[1]?.minute() ?? A,
|
|
62
54
|
timeFormat: M
|
|
63
55
|
}), {
|
|
64
|
-
hour:
|
|
65
|
-
minute:
|
|
66
|
-
amPm:
|
|
67
|
-
hour24:
|
|
68
|
-
handleHourChange:
|
|
69
|
-
handleMinuteChange:
|
|
70
|
-
handleAmPmChange:
|
|
71
|
-
resetTime:
|
|
72
|
-
} =
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
),
|
|
77
|
-
|
|
78
|
-
|
|
56
|
+
hour: X,
|
|
57
|
+
minute: d,
|
|
58
|
+
amPm: Z,
|
|
59
|
+
hour24: k,
|
|
60
|
+
handleHourChange: $,
|
|
61
|
+
handleMinuteChange: V,
|
|
62
|
+
handleAmPmChange: v,
|
|
63
|
+
resetTime: R
|
|
64
|
+
} = W, tt = n(() => {
|
|
65
|
+
u(e), H(), O(
|
|
66
|
+
e[0]?.hour() ?? S,
|
|
67
|
+
e[0]?.minute() ?? f
|
|
68
|
+
), R(
|
|
69
|
+
e[1]?.hour() ?? D,
|
|
70
|
+
e[1]?.minute() ?? A
|
|
79
71
|
);
|
|
80
|
-
}, [
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
}, [
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}, [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
(e) => {
|
|
93
|
-
e === "start" ? a() : d();
|
|
72
|
+
}, [e, u, H, O, R]), P = n(() => {
|
|
73
|
+
const t = g(i);
|
|
74
|
+
t === null ? a() : t[0] === null && t[1] === null && r(t);
|
|
75
|
+
}, [g, i, a, r]);
|
|
76
|
+
ut(() => {
|
|
77
|
+
E.current = P;
|
|
78
|
+
}, [P]);
|
|
79
|
+
const et = (t) => {
|
|
80
|
+
tt(), s(t);
|
|
81
|
+
}, nt = n(
|
|
82
|
+
(t) => {
|
|
83
|
+
t === "start" ? a() : h();
|
|
94
84
|
},
|
|
95
|
-
[a,
|
|
96
|
-
),
|
|
97
|
-
(
|
|
98
|
-
|
|
85
|
+
[a, h]
|
|
86
|
+
), rt = n(
|
|
87
|
+
(t) => {
|
|
88
|
+
T(t, i);
|
|
99
89
|
},
|
|
100
|
-
[
|
|
101
|
-
),
|
|
102
|
-
const { tempStart:
|
|
103
|
-
if (
|
|
104
|
-
const
|
|
105
|
-
r(
|
|
90
|
+
[T, i]
|
|
91
|
+
), at = n(() => {
|
|
92
|
+
const { tempStart: t, tempEnd: o } = m.current;
|
|
93
|
+
if (t && o) {
|
|
94
|
+
const l = t.hour(C).minute(c).startOf("minute"), p = o.hour(k).minute(d).endOf("minute"), it = l.isAfter(p) ? [p, l] : [l, p];
|
|
95
|
+
r(it), s(!1);
|
|
106
96
|
}
|
|
107
97
|
}, [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
98
|
+
m,
|
|
99
|
+
C,
|
|
100
|
+
c,
|
|
101
|
+
k,
|
|
102
|
+
d,
|
|
113
103
|
r,
|
|
114
|
-
|
|
115
|
-
]),
|
|
116
|
-
|
|
117
|
-
}, [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const i = Array.isArray(e) ? e : [e, e];
|
|
122
|
-
r(i), o(!1);
|
|
104
|
+
s
|
|
105
|
+
]), ot = n(() => {
|
|
106
|
+
a(), u([m.current.tempStart, null]);
|
|
107
|
+
}, [a, u, m]), st = n(
|
|
108
|
+
(t) => {
|
|
109
|
+
const o = Array.isArray(t) ? t : [t, t];
|
|
110
|
+
r(o), s(!1);
|
|
123
111
|
},
|
|
124
|
-
[r,
|
|
112
|
+
[r, s]
|
|
125
113
|
);
|
|
126
114
|
return {
|
|
127
|
-
isOpen:
|
|
128
|
-
step:
|
|
129
|
-
displayedMonth:
|
|
130
|
-
tempStart:
|
|
131
|
-
tempEnd:
|
|
132
|
-
hoverDate:
|
|
133
|
-
tempStartHour:
|
|
134
|
-
tempStartMinute:
|
|
135
|
-
tempEndHour:
|
|
136
|
-
tempEndMinute:
|
|
137
|
-
startAmPm:
|
|
138
|
-
endAmPm:
|
|
139
|
-
|
|
140
|
-
handleSetStep:
|
|
141
|
-
handleDateClick:
|
|
142
|
-
handleMonthChange:
|
|
143
|
-
handleDateHover:
|
|
144
|
-
handleStartHourChange:
|
|
145
|
-
handleStartMinuteChange:
|
|
146
|
-
handleEndHourChange:
|
|
147
|
-
handleEndMinuteChange:
|
|
148
|
-
handleStartAmPmChange:
|
|
149
|
-
handleEndAmPmChange:
|
|
150
|
-
handleNext:
|
|
151
|
-
handleApply:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
inputRef: x
|
|
115
|
+
isOpen: B,
|
|
116
|
+
step: i,
|
|
117
|
+
displayedMonth: x,
|
|
118
|
+
tempStart: Y,
|
|
119
|
+
tempEnd: w,
|
|
120
|
+
hoverDate: b,
|
|
121
|
+
tempStartHour: z,
|
|
122
|
+
tempStartMinute: c,
|
|
123
|
+
tempEndHour: X,
|
|
124
|
+
tempEndMinute: d,
|
|
125
|
+
startAmPm: G,
|
|
126
|
+
endAmPm: Z,
|
|
127
|
+
handleOpenChange: et,
|
|
128
|
+
handleSetStep: nt,
|
|
129
|
+
handleDateClick: rt,
|
|
130
|
+
handleMonthChange: L,
|
|
131
|
+
handleDateHover: j,
|
|
132
|
+
handleStartHourChange: J,
|
|
133
|
+
handleStartMinuteChange: K,
|
|
134
|
+
handleEndHourChange: $,
|
|
135
|
+
handleEndMinuteChange: V,
|
|
136
|
+
handleStartAmPmChange: Q,
|
|
137
|
+
handleEndAmPmChange: v,
|
|
138
|
+
handleNext: h,
|
|
139
|
+
handleApply: at,
|
|
140
|
+
handleBack: ot,
|
|
141
|
+
handleApplyShortcut: st,
|
|
142
|
+
popoverRef: N,
|
|
143
|
+
inputRef: U
|
|
157
144
|
};
|
|
158
145
|
};
|
|
159
146
|
export {
|
|
160
|
-
|
|
147
|
+
gt as useDateTimeRangePicker
|
|
161
148
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { DatePicker } from './date-picker';
|
|
2
2
|
export type { DatePickerProps } from './date-picker';
|
|
3
|
+
export { TimePicker } from './time-picker';
|
|
4
|
+
export type { TimePickerProps } from './time-picker';
|
|
3
5
|
export { DateRangePicker } from './date-range-picker';
|
|
4
6
|
export type { DateRangePickerProps } from './date-range-picker';
|
|
5
7
|
export { DateTimeRangePicker } from './date-time-range-picker';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { DatePicker as o } from "./date-picker/date-picker.js";
|
|
2
|
-
import { DateRangePicker as
|
|
3
|
-
import { DateTimeRangePicker as
|
|
2
|
+
import { DateRangePicker as i } from "./date-range-picker/date-range-picker.js";
|
|
3
|
+
import { DateTimeRangePicker as a } from "./date-time-range-picker/date-time-range-picker.js";
|
|
4
|
+
import { TimePicker as f } from "./time-picker/time-picker.js";
|
|
4
5
|
export {
|
|
5
6
|
o as DatePicker,
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
i as DateRangePicker,
|
|
8
|
+
a as DateTimeRangePicker,
|
|
9
|
+
f as TimePicker
|
|
8
10
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsxs as x, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import C from "react";
|
|
3
3
|
import { cn as b } from "../../../../../../lib/utils.js";
|
|
4
|
-
import { getCalendarDays as
|
|
5
|
-
import { CalendarHeader as
|
|
4
|
+
import { getCalendarDays as E, getWeekdayNames as O, getWeekNumbers as T, isDateInRange as v, isSameDay as f, isToday as B, isOutsideMonth as K } from "../../utils/calendar-utils.js";
|
|
5
|
+
import { CalendarHeader as P } from "../calendar-header/calendar-header.js";
|
|
6
6
|
import { DAYS_IN_WEEK as p } from "../constants.js";
|
|
7
|
-
function
|
|
7
|
+
function _({
|
|
8
8
|
isOutsideMonth: r,
|
|
9
9
|
isSelected: t,
|
|
10
10
|
isToday: s,
|
|
@@ -42,14 +42,14 @@ const W = ({
|
|
|
42
42
|
onDateHover: i,
|
|
43
43
|
className: N
|
|
44
44
|
}) => {
|
|
45
|
-
const [n, m] = t, h =
|
|
45
|
+
const [n, m] = t, h = E(r), M = O(), k = o ? T(h) : [], Y = () => {
|
|
46
46
|
a(r.subtract(1, "month"));
|
|
47
47
|
}, D = () => {
|
|
48
48
|
a(r.add(1, "month"));
|
|
49
49
|
}, w = (e) => {
|
|
50
50
|
const d = {
|
|
51
|
-
isOutsideMonth:
|
|
52
|
-
isToday:
|
|
51
|
+
isOutsideMonth: K(e, r),
|
|
52
|
+
isToday: B(e),
|
|
53
53
|
isSelected: f(e, n) || f(e, m),
|
|
54
54
|
isRangeStart: f(e, n),
|
|
55
55
|
isRangeEnd: f(e, m),
|
|
@@ -64,7 +64,7 @@ const W = ({
|
|
|
64
64
|
};
|
|
65
65
|
return /* @__PURE__ */ x("div", { "data-slot": "calendar", className: b("flex flex-col gap-4", N), children: [
|
|
66
66
|
/* @__PURE__ */ l(
|
|
67
|
-
|
|
67
|
+
P,
|
|
68
68
|
{
|
|
69
69
|
displayedMonth: r,
|
|
70
70
|
onPrevMonth: Y,
|
|
@@ -96,7 +96,7 @@ const W = ({
|
|
|
96
96
|
/* @__PURE__ */ l(
|
|
97
97
|
"div",
|
|
98
98
|
{
|
|
99
|
-
className:
|
|
99
|
+
className: _(u),
|
|
100
100
|
onClick: () => c(e),
|
|
101
101
|
onMouseEnter: () => i?.(e),
|
|
102
102
|
onMouseLeave: () => i?.(null),
|
|
@@ -37,11 +37,11 @@ const v = "Date picker", C = () => {
|
|
|
37
37
|
"relative flex items-center cursor-pointer w-full group",
|
|
38
38
|
i
|
|
39
39
|
),
|
|
40
|
-
onClick: n,
|
|
41
40
|
role: "combobox",
|
|
42
41
|
"aria-label": l,
|
|
43
42
|
"aria-expanded": t,
|
|
44
43
|
"aria-controls": c,
|
|
44
|
+
onClick: n,
|
|
45
45
|
children: [
|
|
46
46
|
/* @__PURE__ */ r(
|
|
47
47
|
R,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export interface UsePopoverStateOptions {
|
|
2
|
-
onClose?: () => void;
|
|
3
2
|
onBackspace?: () => void;
|
|
4
3
|
}
|
|
5
4
|
export interface UsePopoverStateReturn {
|
|
@@ -7,6 +6,5 @@ export interface UsePopoverStateReturn {
|
|
|
7
6
|
setIsOpen: (isOpen: boolean) => void;
|
|
8
7
|
popoverRef: React.RefObject<HTMLDivElement>;
|
|
9
8
|
inputRef: React.RefObject<HTMLDivElement>;
|
|
10
|
-
handleTogglePopover: () => void;
|
|
11
9
|
}
|
|
12
10
|
export declare const usePopoverState: (options?: UsePopoverStateOptions) => UsePopoverStateReturn;
|
|
@@ -1,40 +1,24 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
const
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!(e instanceof Node)) return;
|
|
11
|
-
const l = i.current?.contains(e) ?? !1, k = r.current?.contains(e) ?? !1, v = t.composedPath().some(
|
|
12
|
-
(d) => d instanceof HTMLElement && d.hasAttribute("data-picker-overlay")
|
|
13
|
-
);
|
|
14
|
-
!l && !k && !v && (n(!1), s?.());
|
|
15
|
-
}, u = (t) => {
|
|
16
|
-
if (t.key === "Escape") {
|
|
17
|
-
n(!1), s?.();
|
|
18
|
-
return;
|
|
1
|
+
import { useState as f, useRef as c, useEffect as p } from "react";
|
|
2
|
+
const m = (r = {}) => {
|
|
3
|
+
const { onBackspace: t } = r, [n, a] = f(!1), u = c(null), i = c(null);
|
|
4
|
+
return p(() => {
|
|
5
|
+
if (!n) return;
|
|
6
|
+
const s = (o) => {
|
|
7
|
+
if (o.key === "Backspace" && t) {
|
|
8
|
+
const { target: e } = o;
|
|
9
|
+
e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLElement && e.isContentEditable || (o.preventDefault(), t());
|
|
19
10
|
}
|
|
20
|
-
if (t.key === "Backspace" && c) {
|
|
21
|
-
const { target: e } = t;
|
|
22
|
-
e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLElement && e.isContentEditable || (t.preventDefault(), c());
|
|
23
|
-
}
|
|
24
|
-
}, E = setTimeout(() => {
|
|
25
|
-
document.addEventListener("mousedown", o);
|
|
26
|
-
}, 0);
|
|
27
|
-
return document.addEventListener("keydown", u), () => {
|
|
28
|
-
clearTimeout(E), document.removeEventListener("mousedown", o), document.removeEventListener("keydown", u);
|
|
29
11
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
12
|
+
return document.addEventListener("keydown", s), () => {
|
|
13
|
+
document.removeEventListener("keydown", s);
|
|
14
|
+
};
|
|
15
|
+
}, [n, t]), {
|
|
16
|
+
isOpen: n,
|
|
17
|
+
setIsOpen: a,
|
|
18
|
+
popoverRef: u,
|
|
19
|
+
inputRef: i
|
|
36
20
|
};
|
|
37
21
|
};
|
|
38
22
|
export {
|
|
39
|
-
|
|
23
|
+
m as usePopoverState
|
|
40
24
|
};
|
package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
type TimePickerPanelBaseProps = {
|
|
3
|
+
hour: number;
|
|
4
|
+
minute: number;
|
|
5
|
+
onHourChange: (hour: number) => void;
|
|
6
|
+
onMinuteChange: (minute: number) => void;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export type TimePickerPanelProps = TimePickerPanelBaseProps & ({
|
|
10
|
+
timeFormat: '12h';
|
|
11
|
+
amPm: 'AM' | 'PM';
|
|
12
|
+
onAmPmChange: (amPm: 'AM' | 'PM') => void;
|
|
13
|
+
} | {
|
|
14
|
+
timeFormat?: '24h';
|
|
15
|
+
amPm?: undefined;
|
|
16
|
+
onAmPmChange?: undefined;
|
|
17
|
+
});
|
|
18
|
+
export declare const TimePickerPanel: FC<TimePickerPanelProps>;
|
|
19
|
+
export {};
|
package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsxs as r, jsx as e, Fragment as c } from "react/jsx-runtime";
|
|
2
|
+
import { cn as h } from "../../../../../../lib/utils.js";
|
|
3
|
+
import { AmPmScroll as d } from "../am-pm-scroll/am-pm-scroll.js";
|
|
4
|
+
import { TimePickerScroll as a } from "../time-picker-scroll/time-picker-scroll.js";
|
|
5
|
+
const f = (m) => {
|
|
6
|
+
const { hour: t, minute: i, onHourChange: n, onMinuteChange: l, className: o } = m, s = m.timeFormat ?? "24h";
|
|
7
|
+
return /* @__PURE__ */ r(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
"data-slot": "time-picker-panel",
|
|
11
|
+
className: h("flex items-stretch", o),
|
|
12
|
+
children: [
|
|
13
|
+
/* @__PURE__ */ e("div", { className: "px-3", children: /* @__PURE__ */ e(
|
|
14
|
+
a,
|
|
15
|
+
{
|
|
16
|
+
value: t,
|
|
17
|
+
onChange: n,
|
|
18
|
+
type: "hour",
|
|
19
|
+
timeFormat: s
|
|
20
|
+
}
|
|
21
|
+
) }),
|
|
22
|
+
/* @__PURE__ */ e("div", { className: "w-px bg-border shrink-0 self-stretch" }),
|
|
23
|
+
/* @__PURE__ */ e("div", { className: "px-3", children: /* @__PURE__ */ e(
|
|
24
|
+
a,
|
|
25
|
+
{
|
|
26
|
+
value: i,
|
|
27
|
+
onChange: l,
|
|
28
|
+
type: "minute"
|
|
29
|
+
}
|
|
30
|
+
) }),
|
|
31
|
+
m.timeFormat === "12h" && /* @__PURE__ */ r(c, { children: [
|
|
32
|
+
/* @__PURE__ */ e("div", { className: "w-px bg-border shrink-0 self-stretch" }),
|
|
33
|
+
/* @__PURE__ */ e("div", { className: "px-3", children: /* @__PURE__ */ e(d, { value: m.amPm, onChange: m.onAmPmChange }) })
|
|
34
|
+
] })
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
f as TimePickerPanel
|
|
41
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Dayjs } from 'dayjs';
|
|
3
|
+
import { ShortcutItem } from '../shared/shortcuts-panel/shortcuts-panel';
|
|
4
|
+
import { TimeFormat } from '../utils/format-utils';
|
|
5
|
+
export type { ShortcutItem };
|
|
6
|
+
export interface TimePickerProps {
|
|
7
|
+
value: Dayjs | null;
|
|
8
|
+
onChange: (time: Dayjs | null) => void;
|
|
9
|
+
timeFormat?: TimeFormat;
|
|
10
|
+
format?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
shortcuts?: ShortcutItem[];
|
|
13
|
+
defaultDate?: Dayjs;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const TimePicker: FC<TimePickerProps>;
|