@cognite/aura 0.3.2 → 0.3.4
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 +134 -5
- package/README.md +24 -3
- package/dist/components/index.d.ts +5 -1
- package/dist/components/index.js +59 -327
- package/dist/components/ui/core/accordion/accordion.js +79 -114
- package/dist/components/ui/core/action-toolbar/action-toolbar.js +108 -176
- package/dist/components/ui/core/alert/alert.js +158 -206
- package/dist/components/ui/core/avatar/avatar.js +64 -90
- package/dist/components/ui/core/badge/badge.js +73 -108
- package/dist/components/ui/core/banner/banner.js +146 -215
- package/dist/components/ui/core/breadcrumb/breadcrumb.js +105 -200
- package/dist/components/ui/core/button/button.js +47 -52
- package/dist/components/ui/core/button-group/button-group.js +40 -79
- package/dist/components/ui/core/calendar/calendar-header.js +63 -0
- package/dist/components/ui/core/calendar/calendar-utils.js +39 -0
- package/dist/components/ui/core/calendar/calendar.js +68 -0
- package/dist/components/ui/core/calendar/constants.d.ts +1 -0
- package/dist/components/ui/core/card/card.js +102 -185
- package/dist/components/ui/core/chart/chart.js +116 -206
- package/dist/components/ui/core/chart/index.js +2 -8
- package/dist/components/ui/core/checkbox/checkbox.js +67 -132
- package/dist/components/ui/core/checkbox/checkbox.metadata.js +7 -7
- package/dist/components/ui/core/code-block/code-block.d.ts +1 -1
- package/dist/components/ui/core/code-block/code-block.js +179 -267
- package/dist/components/ui/core/collapsible/collapsible.js +29 -49
- package/dist/components/ui/core/combobox/combobox.js +41 -0
- package/dist/components/ui/core/command/command.js +85 -150
- package/dist/components/ui/core/count/count.js +21 -32
- package/dist/components/ui/core/data-grid/data-grid-cell.d.ts +10 -0
- package/dist/components/ui/core/data-grid/data-grid-header-row.d.ts +13 -0
- package/dist/components/ui/core/data-grid/data-grid-row.d.ts +18 -0
- package/dist/components/ui/core/data-grid/data-grid.d.ts +43 -0
- package/dist/components/ui/core/data-grid/data-grid.fixtures.d.ts +12 -0
- package/dist/components/ui/core/data-grid/data-grid.utils.d.ts +9 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +60 -72
- package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +2 -1
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +36 -51
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +63 -87
- package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +2 -1
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +60 -68
- package/dist/components/ui/core/date-time-pickers/date-time-picker/index.d.ts +1 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/types.d.ts +36 -0
- package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +118 -174
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +7 -6
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +104 -145
- package/dist/components/ui/core/date-time-pickers/index.d.ts +3 -1
- package/dist/components/ui/core/date-time-pickers/index.js +6 -10
- package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.d.ts +3 -2
- package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +42 -56
- package/dist/components/ui/core/date-time-pickers/shared/constants.d.ts +3 -8
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +64 -98
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +38 -67
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +23 -23
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +52 -62
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +18 -18
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +24 -31
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.d.ts +3 -3
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +24 -33
- package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +4 -7
- package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.d.ts +3 -2
- package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +17 -31
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +3 -2
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +40 -40
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +33 -50
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +78 -99
- package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +5 -4
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +41 -63
- package/dist/components/ui/core/date-time-pickers/time-range-picker/index.d.ts +1 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/types.d.ts +40 -0
- package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/utils/format-utils.d.ts +1 -0
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.d.ts +3 -3
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +7 -15
- package/dist/components/ui/core/dialog/dialog.js +82 -155
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +150 -248
- package/dist/components/ui/core/empty-state/empty-state.context.js +5 -8
- package/dist/components/ui/core/empty-state/empty-state.js +86 -138
- package/dist/components/ui/core/helper-text/helper-text.js +37 -65
- package/dist/components/ui/core/hover-card/hover-card.js +54 -80
- package/dist/components/ui/core/inline-citation/inline-citation.js +98 -181
- package/dist/components/ui/core/input/input.js +12 -27
- package/dist/components/ui/core/input-group/input-group.js +76 -173
- package/dist/components/ui/core/kbd/kbd.js +20 -36
- package/dist/components/ui/core/label/label.js +26 -43
- package/dist/components/ui/core/loader/loader.js +80 -117
- package/dist/components/ui/core/message/message-response-default-streamdown-controls.js +12 -12
- package/dist/components/ui/core/message/message.d.ts +2 -2
- package/dist/components/ui/core/message/message.js +316 -542
- package/dist/components/ui/core/overflow-list/overflow-list.utils.d.ts +52 -0
- package/dist/components/ui/core/pagination/pagination-size-context.js +5 -6
- package/dist/components/ui/core/pagination/pagination-teleport.js +86 -106
- package/dist/components/ui/core/pagination/pagination-teleport.utils.js +6 -6
- package/dist/components/ui/core/pagination/pagination.js +231 -334
- package/dist/components/ui/core/popover/popover.js +90 -157
- package/dist/components/ui/core/progress/progress.js +36 -61
- package/dist/components/ui/core/prompt-input/prompt-input.js +274 -413
- package/dist/components/ui/core/radio-group/radio-group.js +58 -113
- package/dist/components/ui/core/reasoning/reasoning.js +55 -86
- package/dist/components/ui/core/scroll-area/scroll-area.js +41 -71
- package/dist/components/ui/core/search/search.js +77 -99
- package/dist/components/ui/core/segmented-control/segmented-control.js +110 -167
- package/dist/components/ui/core/select/select.js +168 -293
- package/dist/components/ui/core/separator/separator.js +13 -23
- package/dist/components/ui/core/shimmer/shimmer.d.ts +2 -4
- package/dist/components/ui/core/shimmer/shimmer.js +40 -107
- package/dist/components/ui/core/skeleton/skeleton.js +13 -18
- package/dist/components/ui/core/slider/slider.d.ts +9 -0
- package/dist/components/ui/core/slider/slider.js +40 -0
- package/dist/components/ui/core/sonner-toast/sonner-toast.js +54 -47
- package/dist/components/ui/core/sources/sources.d.ts +5 -1
- package/dist/components/ui/core/sources/sources.js +58 -79
- package/dist/components/ui/core/switch/switch.js +62 -0
- package/dist/components/ui/core/tabs/tabs.js +149 -223
- package/dist/components/ui/core/tabs/tabs.utils.js +6 -8
- package/dist/components/ui/core/textarea/textarea.js +13 -27
- package/dist/components/ui/core/toggle/toggle.js +55 -74
- package/dist/components/ui/core/tool/tool.js +127 -163
- package/dist/components/ui/core/tooltip/tooltip.js +47 -86
- package/dist/components/ui/core/topbar/topbar.js +106 -190
- package/dist/eslint/index.js +5 -10
- package/dist/eslint/no-overriding-styles.js +178 -237
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/lib/highlight-code.d.ts +9 -0
- package/dist/lib/highlight-code.js +42 -0
- package/dist/lib/portal-container-context.js +8 -9
- package/dist/lib/style-scope.js +6 -6
- package/dist/lib/use-controllable-state.js +21 -30
- package/dist/lib/utils.d.ts +0 -2
- package/dist/lib/utils.js +32 -112
- package/dist/styles.css +1 -1
- package/dist/styles.source.css +26 -0
- package/package.json +42 -8
- package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +0 -119
- package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.js +0 -93
- package/dist/components/ui/core/date-time-pickers/shared/constants.js +0 -14
- package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +0 -52
- /package/dist/components/ui/core/{date-time-pickers/shared/calendar-header → calendar}/calendar-header.d.ts +0 -0
- /package/dist/components/ui/core/{date-time-pickers/utils → calendar}/calendar-utils.d.ts +0 -0
- /package/dist/components/ui/core/{date-time-pickers/shared/calendar → calendar}/calendar.d.ts +0 -0
|
@@ -1,52 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
displayedMonth: f,
|
|
36
|
-
tempDate: d,
|
|
37
|
-
handleOpenChange: (e) => {
|
|
38
|
-
D(), a(e);
|
|
39
|
-
},
|
|
40
|
-
handleDateClick: i,
|
|
41
|
-
handleMonthChange: h,
|
|
42
|
-
handleApplyShortcut: (e) => {
|
|
43
|
-
const k = Array.isArray(e) ? e[0] : e;
|
|
44
|
-
t(k), a(!1);
|
|
45
|
-
},
|
|
46
|
-
inputRef: p,
|
|
47
|
-
popoverRef: c
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export {
|
|
51
|
-
x as useDatePicker
|
|
1
|
+
import { usePopoverState as e } from "../shared/hooks/use-popover-state.js";
|
|
2
|
+
import { useSingleDateState as t } from "../shared/hooks/use-single-date-state.js";
|
|
3
|
+
import { useCallback as n, useEffect as r, useRef as i } from "react";
|
|
4
|
+
import a from "dayjs";
|
|
5
|
+
//#region libs/aura/src/components/ui/core/date-time-pickers/date-picker/use-date-picker.ts
|
|
6
|
+
var o = ({ value: o, onChange: s, defaultDate: c = a() }) => {
|
|
7
|
+
let l = i(() => {}), { isOpen: u, setIsOpen: d, popoverRef: f, inputRef: p } = e({ onBackspace: n(() => l.current(), []) }), { tempDate: m, displayedMonth: h, handleDateClick: g, handleMonthChange: _, clearDate: v, resetDate: y } = t({
|
|
8
|
+
value: o,
|
|
9
|
+
defaultDate: c,
|
|
10
|
+
onDateSelected: (e) => {
|
|
11
|
+
s(e), d(!1);
|
|
12
|
+
}
|
|
13
|
+
}), b = () => {
|
|
14
|
+
y(o);
|
|
15
|
+
}, x = () => {
|
|
16
|
+
v() && s(null);
|
|
17
|
+
};
|
|
18
|
+
return r(() => {
|
|
19
|
+
l.current = x;
|
|
20
|
+
}), {
|
|
21
|
+
isOpen: u,
|
|
22
|
+
displayedMonth: h,
|
|
23
|
+
tempDate: m,
|
|
24
|
+
handleOpenChange: (e) => {
|
|
25
|
+
b(), d(e);
|
|
26
|
+
},
|
|
27
|
+
handleDateClick: g,
|
|
28
|
+
handleMonthChange: _,
|
|
29
|
+
handleApplyShortcut: (e) => {
|
|
30
|
+
s(Array.isArray(e) ? e[0] : e), d(!1);
|
|
31
|
+
},
|
|
32
|
+
inputRef: p,
|
|
33
|
+
popoverRef: f
|
|
34
|
+
};
|
|
52
35
|
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { o as useDatePicker };
|
|
@@ -1,88 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
shortcuts: t,
|
|
64
|
-
onShortcutClick: P
|
|
65
|
-
}
|
|
66
|
-
),
|
|
67
|
-
/* @__PURE__ */ e("div", { className: "p-3", children: /* @__PURE__ */ e(
|
|
68
|
-
Y,
|
|
69
|
-
{
|
|
70
|
-
displayedMonth: v,
|
|
71
|
-
selectedRange: [o, l],
|
|
72
|
-
hoverDate: r === "end" ? f : null,
|
|
73
|
-
displayWeekNumber: h,
|
|
74
|
-
onDateClick: D,
|
|
75
|
-
onMonthChange: u,
|
|
76
|
-
onDateHover: C
|
|
77
|
-
}
|
|
78
|
-
) })
|
|
79
|
-
] })
|
|
80
|
-
}
|
|
81
|
-
)
|
|
82
|
-
] })
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
export {
|
|
87
|
-
z as DateRangePicker
|
|
1
|
+
import { cn as e } from "../../../../../lib/utils.js";
|
|
2
|
+
import { Popover as t, PopoverContent as n, PopoverTrigger as r } from "../../popover/popover.js";
|
|
3
|
+
import { Calendar as i } from "../../calendar/calendar.js";
|
|
4
|
+
import { DateTimeInput as a } from "../shared/date-time-input/date-time-input.js";
|
|
5
|
+
import { ShortcutsPanel as o } from "../shared/shortcuts-panel/shortcuts-panel.js";
|
|
6
|
+
import { useDateRangePicker as s } from "./use-date-range-picker.js";
|
|
7
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
|
+
//#region libs/aura/src/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.tsx
|
|
9
|
+
var u = ({ value: u, onChange: d, format: f = "DD/MM/YYYY", placeholder: p, displayWeekNumber: m = !1, shortcuts: h, defaultDate: g, className: _ }) => {
|
|
10
|
+
let { isOpen: v, step: y, displayedMonth: b, tempStart: x, tempEnd: S, hoverDate: C, handleOpenChange: w, handleDateClick: T, handleMonthChange: E, handleDateHover: D, handleSetStep: O, handleApplyShortcut: k, inputRef: A, popoverRef: j } = s({
|
|
11
|
+
value: u,
|
|
12
|
+
onChange: d,
|
|
13
|
+
defaultDate: g
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ c("div", {
|
|
16
|
+
"data-slot": "date-range-picker",
|
|
17
|
+
className: e("relative w-full", _),
|
|
18
|
+
children: /* @__PURE__ */ l(t, {
|
|
19
|
+
open: v,
|
|
20
|
+
onOpenChange: w,
|
|
21
|
+
children: [/* @__PURE__ */ c(r, {
|
|
22
|
+
render: /* @__PURE__ */ c("div", {
|
|
23
|
+
ref: A,
|
|
24
|
+
className: "w-full"
|
|
25
|
+
}),
|
|
26
|
+
children: /* @__PURE__ */ c(a, {
|
|
27
|
+
value: v ? [x, S] : u,
|
|
28
|
+
format: f,
|
|
29
|
+
placeholder: p,
|
|
30
|
+
isOpen: v,
|
|
31
|
+
variant: "date",
|
|
32
|
+
activeRangePart: v ? y : void 0,
|
|
33
|
+
onRangePartClick: v ? O : void 0
|
|
34
|
+
})
|
|
35
|
+
}), /* @__PURE__ */ c(n, {
|
|
36
|
+
ref: j,
|
|
37
|
+
className: "rounded-xl w-auto p-0",
|
|
38
|
+
side: "bottom",
|
|
39
|
+
align: "start",
|
|
40
|
+
children: /* @__PURE__ */ l("div", {
|
|
41
|
+
"data-slot": "date-range-picker-content",
|
|
42
|
+
className: "flex flex-row",
|
|
43
|
+
children: [h && h.length > 0 && /* @__PURE__ */ c(o, {
|
|
44
|
+
shortcuts: h,
|
|
45
|
+
onShortcutClick: k
|
|
46
|
+
}), /* @__PURE__ */ c("div", {
|
|
47
|
+
className: "p-3",
|
|
48
|
+
children: /* @__PURE__ */ c(i, {
|
|
49
|
+
displayedMonth: b,
|
|
50
|
+
selectedRange: [x, S],
|
|
51
|
+
hoverDate: y === "end" ? C : null,
|
|
52
|
+
displayWeekNumber: m,
|
|
53
|
+
onDateClick: T,
|
|
54
|
+
onMonthChange: E,
|
|
55
|
+
onDateHover: D
|
|
56
|
+
})
|
|
57
|
+
})]
|
|
58
|
+
})
|
|
59
|
+
})]
|
|
60
|
+
})
|
|
61
|
+
});
|
|
88
62
|
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { u as DateRangePicker };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
2
|
import { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';
|
|
3
|
+
import { ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';
|
|
3
4
|
export type { RangeSelectionStep };
|
|
4
5
|
export interface UseDateRangePickerProps {
|
|
5
6
|
value: [Dayjs | null, Dayjs | null];
|
|
@@ -18,7 +19,7 @@ export interface UseDateRangePickerReturn {
|
|
|
18
19
|
handleMonthChange: (month: Dayjs) => void;
|
|
19
20
|
handleDateHover: (date: Dayjs | null) => void;
|
|
20
21
|
handleSetStep: (step: RangeSelectionStep) => void;
|
|
21
|
-
handleApplyShortcut: (range:
|
|
22
|
+
handleApplyShortcut: (range: ShortcutValueDayjs) => void;
|
|
22
23
|
inputRef: React.RefObject<HTMLDivElement>;
|
|
23
24
|
popoverRef: React.RefObject<HTMLDivElement>;
|
|
24
25
|
}
|
package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js
CHANGED
|
@@ -1,69 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
handleApplyShortcut: (e) => {
|
|
60
|
-
const l = Array.isArray(e) ? e : [e, e];
|
|
61
|
-
t(l), s(!1), a();
|
|
62
|
-
},
|
|
63
|
-
inputRef: k,
|
|
64
|
-
popoverRef: u
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
export {
|
|
68
|
-
L as useDateRangePicker
|
|
1
|
+
import { usePopoverState as e } from "../shared/hooks/use-popover-state.js";
|
|
2
|
+
import { useRangeDateState as t } from "../shared/hooks/use-range-date-state.js";
|
|
3
|
+
import { useRangeStepManager as n } from "../shared/hooks/use-range-step-manager.js";
|
|
4
|
+
import { useCallback as r, useEffect as i, useRef as a } from "react";
|
|
5
|
+
import o from "dayjs";
|
|
6
|
+
//#region libs/aura/src/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.ts
|
|
7
|
+
var s = ({ value: s, onChange: c, defaultDate: l = o() }) => {
|
|
8
|
+
let u = a(() => {}), { isOpen: d, setIsOpen: f, popoverRef: p, inputRef: m } = e({ onBackspace: r(() => u.current(), []) }), { step: h, handleBack: g, handleNext: _, resetStep: v } = n(), { tempStart: y, tempEnd: b, displayedMonth: x, hoverDate: S, handleDateClick: C, handleDateHover: w, handleMonthChange: T, clearActiveSegment: E, resetDates: D } = t({
|
|
9
|
+
value: s,
|
|
10
|
+
defaultDate: l,
|
|
11
|
+
onEndDateSelected: r((e, t) => {
|
|
12
|
+
c([e, t]), f(!1), v();
|
|
13
|
+
}, [
|
|
14
|
+
c,
|
|
15
|
+
f,
|
|
16
|
+
v
|
|
17
|
+
])
|
|
18
|
+
}), O = r(() => {
|
|
19
|
+
D(s), v();
|
|
20
|
+
}, [
|
|
21
|
+
D,
|
|
22
|
+
v,
|
|
23
|
+
s
|
|
24
|
+
]), k = r(() => {
|
|
25
|
+
let e = E(h);
|
|
26
|
+
e === null ? g() : e[0] === null && e[1] === null && c(e);
|
|
27
|
+
}, [
|
|
28
|
+
E,
|
|
29
|
+
h,
|
|
30
|
+
g,
|
|
31
|
+
c
|
|
32
|
+
]);
|
|
33
|
+
return i(() => {
|
|
34
|
+
u.current = k;
|
|
35
|
+
}, [k]), {
|
|
36
|
+
isOpen: d,
|
|
37
|
+
step: h,
|
|
38
|
+
displayedMonth: x,
|
|
39
|
+
tempStart: y,
|
|
40
|
+
tempEnd: b,
|
|
41
|
+
hoverDate: S,
|
|
42
|
+
handleOpenChange: (e) => {
|
|
43
|
+
O(), f(e);
|
|
44
|
+
},
|
|
45
|
+
handleDateClick: (e) => {
|
|
46
|
+
C(e, h), h === "start" && _();
|
|
47
|
+
},
|
|
48
|
+
handleMonthChange: T,
|
|
49
|
+
handleDateHover: w,
|
|
50
|
+
handleSetStep: (e) => {
|
|
51
|
+
e === "start" ? g() : _();
|
|
52
|
+
},
|
|
53
|
+
handleApplyShortcut: (e) => {
|
|
54
|
+
c(Array.isArray(e) ? e : [e, e]), f(!1), v();
|
|
55
|
+
},
|
|
56
|
+
inputRef: m,
|
|
57
|
+
popoverRef: p
|
|
58
|
+
};
|
|
69
59
|
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { s as useDateRangePicker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { DateTimePickerProps, UseDateTimePickerProps, UseDateTimePickerReturn, } from './types';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
import { ShortcutItem, ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';
|
|
3
|
+
import { AmPm, TimeFormat } from '../utils/format-utils';
|
|
4
|
+
export interface UseDateTimePickerProps {
|
|
5
|
+
value: Dayjs | null;
|
|
6
|
+
onChange: (datetime: Dayjs | null) => void;
|
|
7
|
+
timeFormat?: TimeFormat;
|
|
8
|
+
defaultDate?: Dayjs;
|
|
9
|
+
}
|
|
10
|
+
export interface UseDateTimePickerReturn {
|
|
11
|
+
isOpen: boolean;
|
|
12
|
+
displayedMonth: Dayjs;
|
|
13
|
+
tempDate: Dayjs | null;
|
|
14
|
+
hour: number;
|
|
15
|
+
minute: number;
|
|
16
|
+
amPm: AmPm;
|
|
17
|
+
displayValue: Dayjs | null;
|
|
18
|
+
canApply: boolean;
|
|
19
|
+
handleOpenChange: (open: boolean) => void;
|
|
20
|
+
handleApply: () => void;
|
|
21
|
+
handleDateClick: (date: Dayjs) => void;
|
|
22
|
+
handleMonthChange: (month: Dayjs) => void;
|
|
23
|
+
handleHourChange: (hour: number) => void;
|
|
24
|
+
handleMinuteChange: (minute: number) => void;
|
|
25
|
+
handleAmPmChange: (amPm: AmPm) => void;
|
|
26
|
+
handleApplyShortcut: (shortcutValue: ShortcutValueDayjs) => void;
|
|
27
|
+
inputRef: React.RefObject<HTMLDivElement>;
|
|
28
|
+
popoverRef: React.RefObject<HTMLDivElement>;
|
|
29
|
+
}
|
|
30
|
+
export interface DateTimePickerProps extends UseDateTimePickerProps {
|
|
31
|
+
format?: string;
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
displayWeekNumber?: boolean;
|
|
34
|
+
shortcuts?: ShortcutItem[];
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { UseDateTimePickerProps, UseDateTimePickerReturn } from './types';
|
|
2
|
+
export type { UseDateTimePickerProps, UseDateTimePickerReturn };
|
|
3
|
+
export declare const useDateTimePicker: ({ value, onChange, timeFormat, defaultDate, }: UseDateTimePickerProps) => UseDateTimePickerReturn;
|