@cognite/aura 0.2.0 → 0.3.1
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 +869 -870
- package/README.md +143 -9
- package/dist/colors.css +30 -0
- package/dist/components/index.d.ts +7 -36
- package/dist/components/index.js +319 -350
- package/dist/components/ui/core/accordion/accordion.d.ts +7 -7
- package/dist/components/ui/core/accordion/accordion.js +49 -47
- package/dist/components/ui/core/action-toolbar/action-toolbar.d.ts +41 -0
- package/dist/components/ui/core/action-toolbar/action-toolbar.js +176 -0
- package/dist/components/ui/core/alert/alert.d.ts +23 -12
- package/dist/components/ui/core/alert/alert.js +123 -120
- package/dist/components/ui/core/avatar/avatar.d.ts +12 -8
- package/dist/components/ui/core/badge/badge.d.ts +11 -8
- package/dist/components/ui/core/banner/banner.d.ts +18 -28
- package/dist/components/ui/core/breadcrumb/breadcrumb.d.ts +10 -9
- package/dist/components/ui/core/breadcrumb/breadcrumb.js +98 -88
- package/dist/components/ui/core/button/button.d.ts +8 -5
- package/dist/components/ui/core/button/button.js +22 -19
- package/dist/components/ui/core/button-group/button-group.d.ts +7 -6
- package/dist/components/ui/core/card/card.d.ts +17 -16
- package/dist/components/ui/core/chart/chart.d.ts +69 -0
- package/dist/components/ui/core/chart/chart.js +215 -0
- package/dist/components/ui/core/chart/index.d.ts +2 -0
- package/dist/components/ui/core/chart/index.js +8 -0
- package/dist/components/ui/core/checkbox/checkbox.d.ts +13 -9
- package/dist/components/ui/core/checkbox/checkbox.js +32 -28
- package/dist/components/ui/core/code-block/code-block.d.ts +6 -9
- package/dist/components/ui/core/code-block/code-block.js +48 -44
- package/dist/components/ui/core/collapsible/collapsible.d.ts +5 -3
- package/dist/components/ui/core/combobox/combobox.d.ts +2 -2
- package/dist/components/ui/core/command/command.d.ts +11 -78
- package/dist/components/ui/core/command/command.js +53 -52
- package/dist/components/ui/core/count/count.d.ts +7 -6
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.d.ts +15 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +84 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +18 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +63 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.d.ts +15 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +99 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +25 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.d.ts +4 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +82 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.d.ts +17 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +190 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +42 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +161 -0
- package/dist/components/ui/core/date-time-pickers/index.d.ts +8 -0
- package/dist/components/ui/core/date-time-pickers/index.js +8 -0
- package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.d.ts +7 -0
- package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +57 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.d.ts +13 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +119 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.d.ts +10 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.js +93 -0
- package/dist/components/ui/core/date-time-pickers/shared/constants.d.ts +20 -0
- package/dist/components/ui/core/date-time-pickers/shared/constants.js +14 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.d.ts +19 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +99 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.d.ts +12 -0
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +68 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.d.ts +12 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +40 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.d.ts +29 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +63 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.d.ts +8 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +19 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.d.ts +23 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +32 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.d.ts +17 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +34 -0
- package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.d.ts +8 -0
- package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +7 -0
- package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.d.ts +13 -0
- package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +31 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.d.ts +10 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +52 -0
- package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.d.ts +48 -0
- package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +52 -0
- package/dist/components/ui/core/date-time-pickers/utils/date-range-utils.d.ts +26 -0
- package/dist/components/ui/core/date-time-pickers/utils/format-utils.d.ts +37 -0
- package/dist/components/ui/core/date-time-pickers/utils/segment-utils.d.ts +34 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.d.ts +43 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +15 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-validation.d.ts +23 -0
- package/dist/components/ui/core/dialog/dialog.d.ts +10 -10
- package/dist/components/ui/core/dialog/dialog.js +12 -3
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +24 -47
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +125 -123
- package/dist/components/ui/core/empty-state/empty-state.context.d.ts +10 -0
- package/dist/components/ui/core/empty-state/empty-state.context.js +8 -0
- package/dist/components/ui/core/empty-state/empty-state.d.ts +18 -0
- package/dist/components/ui/core/empty-state/empty-state.js +139 -0
- package/dist/components/ui/core/helper-text/helper-text.d.ts +7 -5
- package/dist/components/ui/core/hover-card/hover-card.d.ts +5 -7
- package/dist/components/ui/core/hover-card/hover-card.js +23 -22
- package/dist/components/ui/core/inline-citation/inline-citation.d.ts +10 -10
- package/dist/components/ui/core/inline-citation/inline-citation.js +57 -49
- package/dist/components/ui/core/input/input.d.ts +2 -1
- package/dist/components/ui/core/input/input.js +1 -1
- package/dist/components/ui/core/input-group/input-group.d.ts +17 -13
- package/dist/components/ui/core/input-group/input-group.js +35 -36
- package/dist/components/ui/core/kbd/kbd.d.ts +3 -2
- package/dist/components/ui/core/label/label.d.ts +3 -2
- package/dist/components/ui/core/loader/loader.d.ts +2 -2
- package/dist/components/ui/core/message/message.d.ts +18 -17
- package/dist/components/ui/core/message/message.js +387 -99
- package/dist/components/ui/core/pagination/pagination-size-context.d.ts +5 -0
- package/dist/components/ui/core/pagination/pagination-size-context.js +6 -0
- package/dist/components/ui/core/pagination/pagination-teleport.d.ts +11 -0
- package/dist/components/ui/core/pagination/pagination-teleport.js +108 -0
- package/dist/components/ui/core/pagination/pagination-teleport.utils.d.ts +1 -0
- package/dist/components/ui/core/pagination/pagination-teleport.utils.js +7 -0
- package/dist/components/ui/core/pagination/pagination.d.ts +41 -0
- package/dist/components/ui/core/pagination/pagination.js +337 -0
- package/dist/components/ui/core/popover/popover.d.ts +12 -16
- package/dist/components/ui/core/popover/popover.js +52 -51
- package/dist/components/ui/core/progress/progress.d.ts +7 -4
- package/dist/components/ui/core/prompt-input/prompt-input.d.ts +36 -103
- package/dist/components/ui/core/prompt-input/prompt-input.js +180 -167
- package/dist/components/ui/core/radio-group/radio-group.d.ts +12 -8
- package/dist/components/ui/core/radio-group/radio-group.js +56 -53
- package/dist/components/ui/core/reasoning/reasoning.d.ts +5 -5
- package/dist/components/ui/core/scroll-area/scroll-area.d.ts +4 -2
- package/dist/components/ui/core/search/search.d.ts +10 -0
- package/dist/components/ui/core/search/search.js +99 -0
- package/dist/components/ui/core/segmented-control/segmented-control.d.ts +15 -11
- package/dist/components/ui/core/segmented-control/segmented-control.js +4 -1
- package/dist/components/ui/core/select/select.d.ts +15 -14
- package/dist/components/ui/core/select/select.js +135 -108
- package/dist/components/ui/core/separator/separator.d.ts +2 -4
- package/dist/components/ui/core/separator/separator.js +4 -5
- package/dist/components/ui/core/shimmer/shimmer.d.ts +5 -5
- package/dist/components/ui/core/shimmer/shimmer.js +91 -52
- package/dist/components/ui/core/skeleton/skeleton.d.ts +2 -1
- package/dist/components/ui/core/sonner-toast/sonner-toast.d.ts +2 -1
- package/dist/components/ui/core/sources/sources.d.ts +3 -3
- package/dist/components/ui/core/sources/sources.js +6 -1
- package/dist/components/ui/core/switch/switch.d.ts +11 -0
- package/dist/components/ui/core/{button/button.metadata.d.ts → switch/switch.metadata.d.ts} +1 -1
- package/dist/components/ui/core/tabs/tabs.d.ts +21 -17
- package/dist/components/ui/core/tabs/tabs.js +11 -9
- package/dist/components/ui/core/textarea/textarea.d.ts +2 -1
- package/dist/components/ui/core/textarea/textarea.js +20 -18
- package/dist/components/ui/core/toggle/toggle.d.ts +15 -0
- package/dist/components/ui/core/toggle/toggle.js +74 -0
- package/dist/components/ui/core/tool/tool.d.ts +7 -6
- package/dist/components/ui/core/tool/tool.js +47 -43
- package/dist/components/ui/core/tooltip/tooltip.d.ts +6 -5
- package/dist/components/ui/core/tooltip/tooltip.js +10 -8
- package/dist/components/ui/core/topbar/topbar.d.ts +11 -13
- package/dist/eslint/index.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/lib/portal-container-context.d.ts +2 -1
- package/dist/lib/portal-container-context.js +3 -5
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +7 -7
- package/dist/styles.css +1 -1
- package/dist/styles.source.css +12 -1
- package/package.json +217 -14
- package/dist/components/ui/core/accordion/accordion.metadata.d.ts +0 -2
- package/dist/components/ui/core/accordion/accordion.metadata.js +0 -9
- package/dist/components/ui/core/alert/alert.metadata.d.ts +0 -2
- package/dist/components/ui/core/alert/alert.metadata.js +0 -9
- package/dist/components/ui/core/avatar/avatar.metadata.d.ts +0 -8
- package/dist/components/ui/core/avatar/avatar.metadata.js +0 -9
- package/dist/components/ui/core/badge/badge.metadata.d.ts +0 -2
- package/dist/components/ui/core/badge/badge.metadata.js +0 -8
- package/dist/components/ui/core/banner/banner.metadata.d.ts +0 -2
- package/dist/components/ui/core/banner/banner.metadata.js +0 -9
- package/dist/components/ui/core/breadcrumb/breadcrumb.metadata.d.ts +0 -2
- package/dist/components/ui/core/breadcrumb/breadcrumb.metadata.js +0 -9
- package/dist/components/ui/core/button/button.metadata.js +0 -9
- package/dist/components/ui/core/button-group/button-group.metadata.d.ts +0 -2
- package/dist/components/ui/core/button-group/button-group.metadata.js +0 -8
- package/dist/components/ui/core/card/card.metadata.d.ts +0 -8
- package/dist/components/ui/core/card/card.metadata.js +0 -9
- package/dist/components/ui/core/code-block/code-block.metadata.d.ts +0 -2
- package/dist/components/ui/core/code-block/code-block.metadata.js +0 -8
- package/dist/components/ui/core/collapsible/collapsible.metadata.d.ts +0 -2
- package/dist/components/ui/core/collapsible/collapsible.metadata.js +0 -9
- package/dist/components/ui/core/combobox/combobox.metadata.d.ts +0 -2
- package/dist/components/ui/core/command/command.metadata.d.ts +0 -2
- package/dist/components/ui/core/command/command.metadata.js +0 -9
- package/dist/components/ui/core/dialog/dialog.metadata.d.ts +0 -2
- package/dist/components/ui/core/dialog/dialog.metadata.js +0 -9
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.metadata.d.ts +0 -2
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.metadata.js +0 -9
- package/dist/components/ui/core/helper-text/helper-text.metadata.d.ts +0 -2
- package/dist/components/ui/core/helper-text/helper-text.metadata.js +0 -9
- package/dist/components/ui/core/hover-card/hover-card.metadata.d.ts +0 -2
- package/dist/components/ui/core/hover-card/hover-card.metadata.js +0 -8
- package/dist/components/ui/core/inline-citation/inline-citation.metadata.d.ts +0 -2
- package/dist/components/ui/core/inline-citation/inline-citation.metadata.js +0 -8
- package/dist/components/ui/core/input/input.metadata.d.ts +0 -2
- package/dist/components/ui/core/input/input.metadata.js +0 -9
- package/dist/components/ui/core/input-group/input-group.metadata.d.ts +0 -2
- package/dist/components/ui/core/input-group/input-group.metadata.js +0 -9
- package/dist/components/ui/core/kbd/kbd.metadata.d.ts +0 -2
- package/dist/components/ui/core/kbd/kbd.metadata.js +0 -9
- package/dist/components/ui/core/label/label.metadata.d.ts +0 -2
- package/dist/components/ui/core/label/label.metadata.js +0 -9
- package/dist/components/ui/core/loader/loader.metadata.d.ts +0 -2
- package/dist/components/ui/core/loader/loader.metadata.js +0 -9
- package/dist/components/ui/core/message/message.metadata.d.ts +0 -2
- package/dist/components/ui/core/popover/popover.metadata.d.ts +0 -2
- package/dist/components/ui/core/popover/popover.metadata.js +0 -9
- package/dist/components/ui/core/progress/progress.metadata.d.ts +0 -2
- package/dist/components/ui/core/progress/progress.metadata.js +0 -9
- package/dist/components/ui/core/prompt-input/prompt-input.metadata.d.ts +0 -2
- package/dist/components/ui/core/prompt-input/prompt-input.metadata.js +0 -9
- package/dist/components/ui/core/radio-group/radio-group.metadata.d.ts +0 -2
- package/dist/components/ui/core/radio-group/radio-group.metadata.js +0 -9
- package/dist/components/ui/core/reasoning/reasoning.metadata.d.ts +0 -2
- package/dist/components/ui/core/reasoning/reasoning.metadata.js +0 -8
- package/dist/components/ui/core/scroll-area/scroll-area.metadata.d.ts +0 -2
- package/dist/components/ui/core/scroll-area/scroll-area.metadata.js +0 -9
- package/dist/components/ui/core/select/select.metadata.d.ts +0 -2
- package/dist/components/ui/core/select/select.metadata.js +0 -9
- package/dist/components/ui/core/separator/separator.metadata.d.ts +0 -2
- package/dist/components/ui/core/separator/separator.metadata.js +0 -8
- package/dist/components/ui/core/shimmer/shimmer.metadata.d.ts +0 -2
- package/dist/components/ui/core/shimmer/shimmer.metadata.js +0 -9
- package/dist/components/ui/core/skeleton/skeleton.metadata.d.ts +0 -2
- package/dist/components/ui/core/skeleton/skeleton.metadata.js +0 -9
- package/dist/components/ui/core/sonner-toast/sonner-toast.metadata.d.ts +0 -2
- package/dist/components/ui/core/sonner-toast/sonner-toast.metadata.js +0 -9
- package/dist/components/ui/core/sources/sources.metadata.d.ts +0 -2
- package/dist/components/ui/core/textarea/textarea.metadata.d.ts +0 -2
- package/dist/components/ui/core/textarea/textarea.metadata.js +0 -9
- package/dist/components/ui/core/tool/tool.metadata.d.ts +0 -2
- package/dist/components/ui/core/tool/tool.metadata.js +0 -8
- package/dist/components/ui/core/tooltip/tooltip.metadata.d.ts +0 -8
- package/dist/components/ui/core/tooltip/tooltip.metadata.js +0 -9
- package/dist/index.js +0 -342
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as e, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { cn as x } from "../../../../../lib/utils.js";
|
|
3
|
+
import { Popover as M, PopoverTrigger as N, PopoverContent as w } from "../../popover/popover.js";
|
|
4
|
+
import { Calendar as R } from "../shared/calendar/calendar.js";
|
|
5
|
+
import { DateTimeInput as S } from "../shared/date-time-input/date-time-input.js";
|
|
6
|
+
import { ShortcutsPanel as Y } from "../shared/shortcuts-panel/shortcuts-panel.js";
|
|
7
|
+
import { useDatePicker as y } from "./use-date-picker.js";
|
|
8
|
+
const T = (o) => o ? [o, o] : [null, null], z = ({
|
|
9
|
+
value: o,
|
|
10
|
+
onChange: r,
|
|
11
|
+
format: i = "DD/MM/YYYY",
|
|
12
|
+
placeholder: c,
|
|
13
|
+
displayWeekNumber: d = !1,
|
|
14
|
+
shortcuts: n,
|
|
15
|
+
defaultDate: p,
|
|
16
|
+
className: s
|
|
17
|
+
}) => {
|
|
18
|
+
const {
|
|
19
|
+
isOpen: l,
|
|
20
|
+
displayedMonth: m,
|
|
21
|
+
tempDate: t,
|
|
22
|
+
handleTogglePopover: h,
|
|
23
|
+
handleCancel: f,
|
|
24
|
+
handleDateClick: u,
|
|
25
|
+
handleMonthChange: v,
|
|
26
|
+
handleApplyShortcut: g,
|
|
27
|
+
inputRef: C,
|
|
28
|
+
popoverRef: D
|
|
29
|
+
} = y({ value: o, onChange: r, defaultDate: p }), k = l ? t : o;
|
|
30
|
+
return /* @__PURE__ */ e("div", { "data-slot": "date-picker", className: x("relative w-full", s), children: /* @__PURE__ */ a(
|
|
31
|
+
M,
|
|
32
|
+
{
|
|
33
|
+
open: l,
|
|
34
|
+
onOpenChange: (P) => {
|
|
35
|
+
P || f();
|
|
36
|
+
},
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ e(N, { render: /* @__PURE__ */ e("div", { ref: C, className: "w-full" }), children: /* @__PURE__ */ e(
|
|
39
|
+
S,
|
|
40
|
+
{
|
|
41
|
+
value: k,
|
|
42
|
+
format: i,
|
|
43
|
+
placeholder: c,
|
|
44
|
+
onClick: h,
|
|
45
|
+
isOpen: l,
|
|
46
|
+
variant: "date"
|
|
47
|
+
}
|
|
48
|
+
) }),
|
|
49
|
+
/* @__PURE__ */ e(
|
|
50
|
+
w,
|
|
51
|
+
{
|
|
52
|
+
ref: D,
|
|
53
|
+
className: "rounded-xl w-auto p-0",
|
|
54
|
+
side: "bottom",
|
|
55
|
+
align: "start",
|
|
56
|
+
children: /* @__PURE__ */ a("div", { "data-slot": "date-picker-content", className: "flex flex-row", children: [
|
|
57
|
+
n && n.length > 0 && /* @__PURE__ */ e(
|
|
58
|
+
Y,
|
|
59
|
+
{
|
|
60
|
+
shortcuts: n,
|
|
61
|
+
onShortcutClick: g
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ e("div", { className: "p-3", children: /* @__PURE__ */ e(
|
|
65
|
+
R,
|
|
66
|
+
{
|
|
67
|
+
displayedMonth: m,
|
|
68
|
+
selectedRange: T(t),
|
|
69
|
+
hoverDate: null,
|
|
70
|
+
displayWeekNumber: d,
|
|
71
|
+
onDateClick: u,
|
|
72
|
+
onMonthChange: v
|
|
73
|
+
}
|
|
74
|
+
) })
|
|
75
|
+
] })
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
) });
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
z as DatePicker
|
|
84
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
export interface UseDatePickerProps {
|
|
3
|
+
value: Dayjs | null;
|
|
4
|
+
onChange: (date: Dayjs | null) => void;
|
|
5
|
+
defaultDate?: Dayjs;
|
|
6
|
+
}
|
|
7
|
+
export interface UseDatePickerReturn {
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
displayedMonth: Dayjs;
|
|
10
|
+
tempDate: Dayjs | null;
|
|
11
|
+
handleTogglePopover: () => void;
|
|
12
|
+
handleCancel: () => void;
|
|
13
|
+
handleDateClick: (date: Dayjs) => void;
|
|
14
|
+
handleMonthChange: (month: Dayjs) => void;
|
|
15
|
+
handleApplyShortcut: (shortcutValue: Dayjs | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null]) => void;
|
|
16
|
+
inputRef: React.RefObject<HTMLDivElement>;
|
|
17
|
+
popoverRef: React.RefObject<HTMLDivElement>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useRef as c, useCallback as p, useEffect as A } from "react";
|
|
2
|
+
import C from "dayjs";
|
|
3
|
+
import { usePopoverState as R } from "../shared/hooks/use-popover-state.js";
|
|
4
|
+
import { useSingleDateState as B } from "../shared/hooks/use-single-date-state.js";
|
|
5
|
+
const I = ({
|
|
6
|
+
value: a,
|
|
7
|
+
onChange: t,
|
|
8
|
+
defaultDate: d = C()
|
|
9
|
+
}) => {
|
|
10
|
+
const r = c(() => {
|
|
11
|
+
}), s = c(() => {
|
|
12
|
+
}), {
|
|
13
|
+
isOpen: l,
|
|
14
|
+
setIsOpen: o,
|
|
15
|
+
popoverRef: f,
|
|
16
|
+
inputRef: i,
|
|
17
|
+
handleTogglePopover: h
|
|
18
|
+
} = R({
|
|
19
|
+
onClose: p(() => r.current(), []),
|
|
20
|
+
onBackspace: p(() => s.current(), [])
|
|
21
|
+
}), u = B({
|
|
22
|
+
value: a,
|
|
23
|
+
defaultDate: d,
|
|
24
|
+
onDateSelected: (e) => {
|
|
25
|
+
t(e), o(!1);
|
|
26
|
+
}
|
|
27
|
+
}), {
|
|
28
|
+
tempDate: m,
|
|
29
|
+
displayedMonth: g,
|
|
30
|
+
handleDateClick: D,
|
|
31
|
+
handleMonthChange: S,
|
|
32
|
+
clearDate: k,
|
|
33
|
+
resetDate: y
|
|
34
|
+
} = u, n = () => {
|
|
35
|
+
y(a);
|
|
36
|
+
}, P = () => {
|
|
37
|
+
k() && t(null);
|
|
38
|
+
};
|
|
39
|
+
return A(() => {
|
|
40
|
+
r.current = n, s.current = P;
|
|
41
|
+
}), {
|
|
42
|
+
isOpen: l,
|
|
43
|
+
displayedMonth: g,
|
|
44
|
+
tempDate: m,
|
|
45
|
+
handleTogglePopover: () => {
|
|
46
|
+
l || n(), h();
|
|
47
|
+
},
|
|
48
|
+
handleCancel: () => {
|
|
49
|
+
n(), o(!1);
|
|
50
|
+
},
|
|
51
|
+
handleDateClick: D,
|
|
52
|
+
handleMonthChange: S,
|
|
53
|
+
handleApplyShortcut: (e) => {
|
|
54
|
+
const v = Array.isArray(e) ? e[0] : e;
|
|
55
|
+
t(v), o(!1);
|
|
56
|
+
},
|
|
57
|
+
inputRef: i,
|
|
58
|
+
popoverRef: f
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
I as useDatePicker
|
|
63
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Dayjs } from 'dayjs';
|
|
3
|
+
import { ShortcutItem } from '../shared/shortcuts-panel/shortcuts-panel';
|
|
4
|
+
export type { ShortcutItem };
|
|
5
|
+
export interface DateRangePickerProps {
|
|
6
|
+
value: [Dayjs | null, Dayjs | null];
|
|
7
|
+
onChange: (range: [Dayjs | null, Dayjs | null]) => void;
|
|
8
|
+
format?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
displayWeekNumber?: boolean;
|
|
11
|
+
shortcuts?: ShortcutItem[];
|
|
12
|
+
defaultDate?: Dayjs;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const DateRangePicker: FC<DateRangePickerProps>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { cn as N } from "../../../../../lib/utils.js";
|
|
3
|
+
import { Popover as w, PopoverTrigger as Y, PopoverContent as T } from "../../popover/popover.js";
|
|
4
|
+
import { Calendar as j } from "../shared/calendar/calendar.js";
|
|
5
|
+
import { DateTimeInput as y } from "../shared/date-time-input/date-time-input.js";
|
|
6
|
+
import { ShortcutsPanel as H } from "../shared/shortcuts-panel/shortcuts-panel.js";
|
|
7
|
+
import { useDateRangePicker as O } from "./use-date-range-picker.js";
|
|
8
|
+
const F = ({
|
|
9
|
+
value: t,
|
|
10
|
+
onChange: d,
|
|
11
|
+
format: p = "DD/MM/YYYY",
|
|
12
|
+
placeholder: c,
|
|
13
|
+
displayWeekNumber: h = !1,
|
|
14
|
+
shortcuts: n,
|
|
15
|
+
defaultDate: m,
|
|
16
|
+
className: s
|
|
17
|
+
}) => {
|
|
18
|
+
const {
|
|
19
|
+
isOpen: a,
|
|
20
|
+
step: o,
|
|
21
|
+
displayedMonth: v,
|
|
22
|
+
tempStart: r,
|
|
23
|
+
tempEnd: l,
|
|
24
|
+
hoverDate: f,
|
|
25
|
+
handleTogglePopover: g,
|
|
26
|
+
handleCancel: C,
|
|
27
|
+
handleDateClick: D,
|
|
28
|
+
handleMonthChange: u,
|
|
29
|
+
handleDateHover: k,
|
|
30
|
+
handleSetStep: P,
|
|
31
|
+
handleApplyShortcut: R,
|
|
32
|
+
inputRef: x,
|
|
33
|
+
popoverRef: S
|
|
34
|
+
} = O({ value: t, onChange: d, defaultDate: m });
|
|
35
|
+
return /* @__PURE__ */ e(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
"data-slot": "date-range-picker",
|
|
39
|
+
className: N("relative w-full", s),
|
|
40
|
+
children: /* @__PURE__ */ i(
|
|
41
|
+
w,
|
|
42
|
+
{
|
|
43
|
+
open: a,
|
|
44
|
+
onOpenChange: (M) => {
|
|
45
|
+
M || C();
|
|
46
|
+
},
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ e(Y, { render: /* @__PURE__ */ e("div", { ref: x, className: "w-full" }), children: /* @__PURE__ */ e(
|
|
49
|
+
y,
|
|
50
|
+
{
|
|
51
|
+
value: a ? [r, l] : t,
|
|
52
|
+
format: p,
|
|
53
|
+
placeholder: c,
|
|
54
|
+
onClick: g,
|
|
55
|
+
isOpen: a,
|
|
56
|
+
variant: "date",
|
|
57
|
+
activeRangePart: a ? o : void 0,
|
|
58
|
+
onRangePartClick: a ? P : void 0
|
|
59
|
+
}
|
|
60
|
+
) }),
|
|
61
|
+
/* @__PURE__ */ e(
|
|
62
|
+
T,
|
|
63
|
+
{
|
|
64
|
+
ref: S,
|
|
65
|
+
className: "rounded-xl w-auto p-0",
|
|
66
|
+
side: "bottom",
|
|
67
|
+
align: "start",
|
|
68
|
+
children: /* @__PURE__ */ i("div", { "data-slot": "date-range-picker-content", className: "flex flex-row", children: [
|
|
69
|
+
n && n.length > 0 && /* @__PURE__ */ e(
|
|
70
|
+
H,
|
|
71
|
+
{
|
|
72
|
+
shortcuts: n,
|
|
73
|
+
onShortcutClick: R
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ e("div", { className: "p-3", children: /* @__PURE__ */ e(
|
|
77
|
+
j,
|
|
78
|
+
{
|
|
79
|
+
displayedMonth: v,
|
|
80
|
+
selectedRange: [r, l],
|
|
81
|
+
hoverDate: o === "end" ? f : null,
|
|
82
|
+
displayWeekNumber: h,
|
|
83
|
+
onDateClick: D,
|
|
84
|
+
onMonthChange: u,
|
|
85
|
+
onDateHover: k
|
|
86
|
+
}
|
|
87
|
+
) })
|
|
88
|
+
] })
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
export {
|
|
98
|
+
F as DateRangePicker
|
|
99
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';
|
|
3
|
+
export type { RangeSelectionStep };
|
|
4
|
+
export interface UseDateRangePickerProps {
|
|
5
|
+
value: [Dayjs | null, Dayjs | null];
|
|
6
|
+
onChange: (range: [Dayjs | null, Dayjs | null]) => void;
|
|
7
|
+
defaultDate?: Dayjs;
|
|
8
|
+
}
|
|
9
|
+
export interface UseDateRangePickerReturn {
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
step: RangeSelectionStep;
|
|
12
|
+
displayedMonth: Dayjs;
|
|
13
|
+
tempStart: Dayjs | null;
|
|
14
|
+
tempEnd: Dayjs | null;
|
|
15
|
+
hoverDate: Dayjs | null;
|
|
16
|
+
handleTogglePopover: () => void;
|
|
17
|
+
handleCancel: () => void;
|
|
18
|
+
handleDateClick: (date: Dayjs) => void;
|
|
19
|
+
handleMonthChange: (month: Dayjs) => void;
|
|
20
|
+
handleDateHover: (date: Dayjs | null) => void;
|
|
21
|
+
handleSetStep: (step: RangeSelectionStep) => void;
|
|
22
|
+
handleApplyShortcut: (range: Dayjs | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null]) => void;
|
|
23
|
+
inputRef: React.RefObject<HTMLDivElement>;
|
|
24
|
+
popoverRef: React.RefObject<HTMLDivElement>;
|
|
25
|
+
}
|
package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';
|
|
2
|
+
import { UseDateRangePickerProps, UseDateRangePickerReturn } from './types';
|
|
3
|
+
export type { RangeSelectionStep, UseDateRangePickerProps, UseDateRangePickerReturn, };
|
|
4
|
+
export declare const useDateRangePicker: ({ value, onChange, defaultDate, }: UseDateRangePickerProps) => UseDateRangePickerReturn;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useRef as k, useCallback as s, useEffect as g } from "react";
|
|
2
|
+
import b from "dayjs";
|
|
3
|
+
import { usePopoverState as j } from "../shared/hooks/use-popover-state.js";
|
|
4
|
+
import { useRangeDateState as H } from "../shared/hooks/use-range-date-state.js";
|
|
5
|
+
import { useRangeStepManager as I } from "../shared/hooks/use-range-step-manager.js";
|
|
6
|
+
const U = ({
|
|
7
|
+
value: r,
|
|
8
|
+
onChange: t,
|
|
9
|
+
defaultDate: D = b()
|
|
10
|
+
}) => {
|
|
11
|
+
const d = k(() => {
|
|
12
|
+
}), f = k(() => {
|
|
13
|
+
}), {
|
|
14
|
+
isOpen: i,
|
|
15
|
+
setIsOpen: a,
|
|
16
|
+
popoverRef: R,
|
|
17
|
+
inputRef: v,
|
|
18
|
+
handleTogglePopover: y
|
|
19
|
+
} = j({
|
|
20
|
+
onClose: s(() => d.current(), []),
|
|
21
|
+
onBackspace: s(() => f.current(), [])
|
|
22
|
+
}), A = I(), { step: o, handleBack: c, handleNext: h, resetStep: n } = A, C = H({
|
|
23
|
+
value: r,
|
|
24
|
+
defaultDate: D,
|
|
25
|
+
onEndDateSelected: s(
|
|
26
|
+
(e, p) => {
|
|
27
|
+
t([e, p]), a(!1), n();
|
|
28
|
+
},
|
|
29
|
+
[t, a, n]
|
|
30
|
+
)
|
|
31
|
+
}), {
|
|
32
|
+
tempStart: P,
|
|
33
|
+
tempEnd: B,
|
|
34
|
+
displayedMonth: M,
|
|
35
|
+
hoverDate: E,
|
|
36
|
+
handleDateClick: T,
|
|
37
|
+
handleDateHover: x,
|
|
38
|
+
handleMonthChange: O,
|
|
39
|
+
clearActiveSegment: u,
|
|
40
|
+
resetDates: S
|
|
41
|
+
} = C, l = s(() => {
|
|
42
|
+
S(r), n();
|
|
43
|
+
}, [S, n, r]), m = s(() => {
|
|
44
|
+
const e = u(o);
|
|
45
|
+
e === null ? c() : e[0] === null && e[1] === null && t(e);
|
|
46
|
+
}, [u, o, c, t]);
|
|
47
|
+
return g(() => {
|
|
48
|
+
d.current = l;
|
|
49
|
+
}, [l]), g(() => {
|
|
50
|
+
f.current = m;
|
|
51
|
+
}, [m]), {
|
|
52
|
+
isOpen: i,
|
|
53
|
+
step: o,
|
|
54
|
+
displayedMonth: M,
|
|
55
|
+
tempStart: P,
|
|
56
|
+
tempEnd: B,
|
|
57
|
+
hoverDate: E,
|
|
58
|
+
handleTogglePopover: () => {
|
|
59
|
+
i || l(), y();
|
|
60
|
+
},
|
|
61
|
+
handleCancel: () => {
|
|
62
|
+
l(), a(!1);
|
|
63
|
+
},
|
|
64
|
+
handleDateClick: (e) => {
|
|
65
|
+
T(e, o), o === "start" && h();
|
|
66
|
+
},
|
|
67
|
+
handleMonthChange: O,
|
|
68
|
+
handleDateHover: x,
|
|
69
|
+
handleSetStep: (e) => {
|
|
70
|
+
e === "start" ? c() : h();
|
|
71
|
+
},
|
|
72
|
+
handleApplyShortcut: (e) => {
|
|
73
|
+
const p = Array.isArray(e) ? e : [e, e];
|
|
74
|
+
t(p), a(!1), n();
|
|
75
|
+
},
|
|
76
|
+
inputRef: v,
|
|
77
|
+
popoverRef: R
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export {
|
|
81
|
+
U as useDateRangePicker
|
|
82
|
+
};
|
package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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 DateTimeRangePickerProps {
|
|
7
|
+
value: [Dayjs | null, Dayjs | null];
|
|
8
|
+
onChange: (range: [Dayjs | null, Dayjs | null]) => void;
|
|
9
|
+
format?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
displayWeekNumber?: boolean;
|
|
12
|
+
shortcuts?: ShortcutItem[];
|
|
13
|
+
timeFormat?: TimeFormat;
|
|
14
|
+
defaultDate?: Dayjs;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const DateTimeRangePicker: FC<DateTimeRangePickerProps>;
|
package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { jsx as e, jsxs as t, Fragment as te } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as re } from "react";
|
|
3
|
+
import { cn as ae } from "../../../../../lib/utils.js";
|
|
4
|
+
import { Button as v } from "../../button/button.js";
|
|
5
|
+
import { Popover as oe, PopoverTrigger as le, PopoverContent as ie } from "../../popover/popover.js";
|
|
6
|
+
import { AmPmScroll as de } from "../shared/am-pm-scroll/am-pm-scroll.js";
|
|
7
|
+
import { Calendar as ce } from "../shared/calendar/calendar.js";
|
|
8
|
+
import { DateTimeInput as se } from "../shared/date-time-input/date-time-input.js";
|
|
9
|
+
import { ShortcutsPanel as he } from "../shared/shortcuts-panel/shortcuts-panel.js";
|
|
10
|
+
import { TimePickerScroll as f } from "../shared/time-picker-scroll/time-picker-scroll.js";
|
|
11
|
+
import { convert12HourTo24Hour as C } from "../utils/time-utils.js";
|
|
12
|
+
import { useDateTimeRangePicker as me } from "./use-date-time-range-picker.js";
|
|
13
|
+
const He = ({
|
|
14
|
+
value: x,
|
|
15
|
+
onChange: P,
|
|
16
|
+
format: k = "DD/MM/YYYY HH:mm",
|
|
17
|
+
placeholder: b,
|
|
18
|
+
displayWeekNumber: N = !1,
|
|
19
|
+
shortcuts: c,
|
|
20
|
+
timeFormat: r = "24h",
|
|
21
|
+
defaultDate: S,
|
|
22
|
+
className: H
|
|
23
|
+
}) => {
|
|
24
|
+
const {
|
|
25
|
+
isOpen: l,
|
|
26
|
+
step: n,
|
|
27
|
+
displayedMonth: M,
|
|
28
|
+
tempStart: a,
|
|
29
|
+
tempEnd: o,
|
|
30
|
+
hoverDate: A,
|
|
31
|
+
tempStartHour: i,
|
|
32
|
+
tempStartMinute: s,
|
|
33
|
+
tempEndHour: d,
|
|
34
|
+
tempEndMinute: h,
|
|
35
|
+
startAmPm: m,
|
|
36
|
+
endAmPm: p,
|
|
37
|
+
handleTogglePopover: D,
|
|
38
|
+
handleSetStep: y,
|
|
39
|
+
handleDateClick: T,
|
|
40
|
+
handleMonthChange: w,
|
|
41
|
+
handleDateHover: R,
|
|
42
|
+
handleStartHourChange: E,
|
|
43
|
+
handleStartMinuteChange: Y,
|
|
44
|
+
handleEndHourChange: j,
|
|
45
|
+
handleEndMinuteChange: B,
|
|
46
|
+
handleStartAmPmChange: O,
|
|
47
|
+
handleEndAmPmChange: W,
|
|
48
|
+
handleNext: I,
|
|
49
|
+
handleApply: L,
|
|
50
|
+
handleCancel: g,
|
|
51
|
+
handleBack: V,
|
|
52
|
+
handleApplyShortcut: q,
|
|
53
|
+
popoverRef: z,
|
|
54
|
+
inputRef: G
|
|
55
|
+
} = me({
|
|
56
|
+
value: x,
|
|
57
|
+
onChange: P,
|
|
58
|
+
timeFormat: r,
|
|
59
|
+
defaultDate: S
|
|
60
|
+
}), J = n === "start" ? a !== null : o !== null, K = n === "start" ? "Next" : "Apply", Q = n === "start" ? I : L, U = n === "start" ? i : d, X = n === "start" ? s : h, Z = n === "start" ? m : p, _ = n === "start" ? E : j, $ = n === "start" ? Y : B, F = n === "start" ? O : W, ee = re(() => {
|
|
61
|
+
const u = a ? a.hour(
|
|
62
|
+
r === "12h" ? C(i, m) : i
|
|
63
|
+
).minute(s) : null, ne = o ? o.hour(
|
|
64
|
+
r === "12h" ? C(d, p) : d
|
|
65
|
+
).minute(h) : null;
|
|
66
|
+
return [u, ne];
|
|
67
|
+
}, [
|
|
68
|
+
a,
|
|
69
|
+
o,
|
|
70
|
+
i,
|
|
71
|
+
s,
|
|
72
|
+
d,
|
|
73
|
+
h,
|
|
74
|
+
m,
|
|
75
|
+
p,
|
|
76
|
+
r
|
|
77
|
+
]);
|
|
78
|
+
return /* @__PURE__ */ e(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
"data-slot": "date-time-range-picker",
|
|
82
|
+
className: ae("relative w-full", H),
|
|
83
|
+
children: /* @__PURE__ */ t(
|
|
84
|
+
oe,
|
|
85
|
+
{
|
|
86
|
+
open: l,
|
|
87
|
+
onOpenChange: (u) => {
|
|
88
|
+
u || g();
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ e(le, { render: /* @__PURE__ */ e("div", { ref: G, className: "w-full" }), children: /* @__PURE__ */ e(
|
|
92
|
+
se,
|
|
93
|
+
{
|
|
94
|
+
value: ee,
|
|
95
|
+
format: k,
|
|
96
|
+
placeholder: b,
|
|
97
|
+
onClick: D,
|
|
98
|
+
isOpen: l,
|
|
99
|
+
variant: "datetime",
|
|
100
|
+
activeRangePart: l ? n : void 0,
|
|
101
|
+
onRangePartClick: l ? y : void 0
|
|
102
|
+
}
|
|
103
|
+
) }),
|
|
104
|
+
/* @__PURE__ */ e(
|
|
105
|
+
ie,
|
|
106
|
+
{
|
|
107
|
+
ref: z,
|
|
108
|
+
className: "rounded-xl w-auto p-0",
|
|
109
|
+
side: "bottom",
|
|
110
|
+
align: "start",
|
|
111
|
+
children: /* @__PURE__ */ t(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
"data-slot": "date-time-range-picker-content",
|
|
115
|
+
className: "flex flex-col",
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ t("div", { className: "flex flex-row", children: [
|
|
118
|
+
c && c.length > 0 && /* @__PURE__ */ e(
|
|
119
|
+
he,
|
|
120
|
+
{
|
|
121
|
+
shortcuts: c,
|
|
122
|
+
onShortcutClick: q
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ e("div", { className: "p-3 border-r border-border", children: /* @__PURE__ */ e(
|
|
126
|
+
ce,
|
|
127
|
+
{
|
|
128
|
+
displayedMonth: M,
|
|
129
|
+
selectedRange: [a, o],
|
|
130
|
+
hoverDate: n === "end" ? A : null,
|
|
131
|
+
displayWeekNumber: N,
|
|
132
|
+
onDateClick: T,
|
|
133
|
+
onMonthChange: w,
|
|
134
|
+
onDateHover: R
|
|
135
|
+
}
|
|
136
|
+
) }),
|
|
137
|
+
/* @__PURE__ */ t("div", { className: "flex items-stretch", children: [
|
|
138
|
+
/* @__PURE__ */ e("div", { className: "px-3", children: /* @__PURE__ */ e(
|
|
139
|
+
f,
|
|
140
|
+
{
|
|
141
|
+
value: U,
|
|
142
|
+
onChange: _,
|
|
143
|
+
type: "hour",
|
|
144
|
+
timeFormat: r
|
|
145
|
+
}
|
|
146
|
+
) }),
|
|
147
|
+
/* @__PURE__ */ e("div", { className: "w-px bg-border shrink-0 self-stretch" }),
|
|
148
|
+
/* @__PURE__ */ e("div", { className: "px-3", children: /* @__PURE__ */ e(
|
|
149
|
+
f,
|
|
150
|
+
{
|
|
151
|
+
value: X,
|
|
152
|
+
onChange: $,
|
|
153
|
+
type: "minute"
|
|
154
|
+
}
|
|
155
|
+
) }),
|
|
156
|
+
r === "12h" && /* @__PURE__ */ t(te, { children: [
|
|
157
|
+
/* @__PURE__ */ e("div", { className: "w-px bg-border shrink-0 self-stretch" }),
|
|
158
|
+
/* @__PURE__ */ e("div", { className: "px-3", children: /* @__PURE__ */ e(de, { value: Z, onChange: F }) })
|
|
159
|
+
] })
|
|
160
|
+
] })
|
|
161
|
+
] }),
|
|
162
|
+
/* @__PURE__ */ t("div", { className: "flex p-2 justify-between items-center self-stretch border-t border-border", children: [
|
|
163
|
+
/* @__PURE__ */ e(v, { variant: "ghost", onClick: g, children: "Cancel" }),
|
|
164
|
+
/* @__PURE__ */ t("div", { className: "flex gap-2", children: [
|
|
165
|
+
n === "end" && /* @__PURE__ */ e(v, { variant: "ghost", onClick: V, children: "Back" }),
|
|
166
|
+
/* @__PURE__ */ e(
|
|
167
|
+
v,
|
|
168
|
+
{
|
|
169
|
+
variant: "secondary",
|
|
170
|
+
onClick: Q,
|
|
171
|
+
disabled: !J,
|
|
172
|
+
children: K
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] })
|
|
176
|
+
] })
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
};
|
|
188
|
+
export {
|
|
189
|
+
He as DateTimeRangePicker
|
|
190
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';
|
|
3
|
+
import { TimeFormat } from '../utils/format-utils';
|
|
4
|
+
export type { RangeSelectionStep };
|
|
5
|
+
export interface UseDateTimeRangePickerProps {
|
|
6
|
+
value: [Dayjs | null, Dayjs | null];
|
|
7
|
+
onChange: (range: [Dayjs | null, Dayjs | null]) => void;
|
|
8
|
+
timeFormat?: TimeFormat;
|
|
9
|
+
defaultDate?: Dayjs;
|
|
10
|
+
}
|
|
11
|
+
export interface UseDateTimeRangePickerReturn {
|
|
12
|
+
isOpen: boolean;
|
|
13
|
+
step: RangeSelectionStep;
|
|
14
|
+
displayedMonth: Dayjs;
|
|
15
|
+
tempStart: Dayjs | null;
|
|
16
|
+
tempEnd: Dayjs | null;
|
|
17
|
+
hoverDate: Dayjs | null;
|
|
18
|
+
tempStartHour: number;
|
|
19
|
+
tempStartMinute: number;
|
|
20
|
+
tempEndHour: number;
|
|
21
|
+
tempEndMinute: number;
|
|
22
|
+
startAmPm: 'AM' | 'PM';
|
|
23
|
+
endAmPm: 'AM' | 'PM';
|
|
24
|
+
handleTogglePopover: () => void;
|
|
25
|
+
handleSetStep: (step: RangeSelectionStep) => void;
|
|
26
|
+
handleDateClick: (date: Dayjs) => void;
|
|
27
|
+
handleMonthChange: (month: Dayjs) => void;
|
|
28
|
+
handleDateHover: (date: Dayjs | null) => void;
|
|
29
|
+
handleStartHourChange: (hour: number) => void;
|
|
30
|
+
handleStartMinuteChange: (minute: number) => void;
|
|
31
|
+
handleEndHourChange: (hour: number) => void;
|
|
32
|
+
handleEndMinuteChange: (minute: number) => void;
|
|
33
|
+
handleStartAmPmChange: (value: 'AM' | 'PM') => void;
|
|
34
|
+
handleEndAmPmChange: (value: 'AM' | 'PM') => void;
|
|
35
|
+
handleNext: () => void;
|
|
36
|
+
handleApply: () => void;
|
|
37
|
+
handleCancel: () => void;
|
|
38
|
+
handleBack: () => void;
|
|
39
|
+
handleApplyShortcut: (range: Dayjs | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null]) => void;
|
|
40
|
+
popoverRef: React.RefObject<HTMLDivElement>;
|
|
41
|
+
inputRef: React.RefObject<HTMLDivElement>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { RangeSelectionStep, UseDateTimeRangePickerProps, UseDateTimeRangePickerReturn } from './types';
|
|
2
|
+
export type { RangeSelectionStep, UseDateTimeRangePickerProps, UseDateTimeRangePickerReturn, };
|
|
3
|
+
export declare const useDateTimeRangePicker: ({ value, onChange, timeFormat, defaultDate, }: UseDateTimeRangePickerProps) => UseDateTimeRangePickerReturn;
|