@cognite/aura 0.3.1 → 0.3.3

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.
Files changed (120) hide show
  1. package/DESIGN.md +1651 -7
  2. package/README.md +45 -3
  3. package/dist/components/index.d.ts +4 -2
  4. package/dist/components/index.js +58 -325
  5. package/dist/components/ui/core/accordion/accordion.js +79 -114
  6. package/dist/components/ui/core/action-toolbar/action-toolbar.js +108 -176
  7. package/dist/components/ui/core/alert/alert.js +158 -206
  8. package/dist/components/ui/core/avatar/avatar.js +64 -90
  9. package/dist/components/ui/core/badge/badge.js +73 -108
  10. package/dist/components/ui/core/banner/banner.js +146 -215
  11. package/dist/components/ui/core/breadcrumb/breadcrumb.js +105 -200
  12. package/dist/components/ui/core/button/button.js +47 -52
  13. package/dist/components/ui/core/button-group/button-group.js +40 -79
  14. package/dist/components/ui/core/card/card.js +102 -185
  15. package/dist/components/ui/core/chart/chart.js +116 -206
  16. package/dist/components/ui/core/chart/index.js +2 -8
  17. package/dist/components/ui/core/checkbox/checkbox.js +67 -132
  18. package/dist/components/ui/core/checkbox/checkbox.metadata.js +7 -7
  19. package/dist/components/ui/core/code-block/code-block.d.ts +1 -1
  20. package/dist/components/ui/core/code-block/code-block.js +179 -267
  21. package/dist/components/ui/core/collapsible/collapsible.js +29 -49
  22. package/dist/components/ui/core/combobox/combobox.js +41 -0
  23. package/dist/components/ui/core/command/command.js +85 -150
  24. package/dist/components/ui/core/count/count.js +21 -32
  25. package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +60 -83
  26. package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +1 -2
  27. package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +36 -62
  28. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +63 -98
  29. package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +1 -2
  30. package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +60 -81
  31. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +118 -189
  32. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +1 -2
  33. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +104 -158
  34. package/dist/components/ui/core/date-time-pickers/index.d.ts +2 -0
  35. package/dist/components/ui/core/date-time-pickers/index.js +5 -8
  36. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +42 -56
  37. package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +66 -117
  38. package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.js +63 -93
  39. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.d.ts +1 -1
  40. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +64 -98
  41. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +38 -67
  42. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.d.ts +0 -2
  43. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +23 -39
  44. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +52 -62
  45. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +18 -18
  46. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +24 -31
  47. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +24 -33
  48. package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +4 -7
  49. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +17 -31
  50. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.d.ts +2 -0
  51. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +19 -0
  52. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +41 -0
  53. package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +33 -50
  54. package/dist/components/ui/core/date-time-pickers/time-picker/index.d.ts +3 -0
  55. package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.d.ts +16 -0
  56. package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +79 -0
  57. package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +23 -0
  58. package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.d.ts +3 -0
  59. package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +42 -0
  60. package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +39 -52
  61. package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +7 -15
  62. package/dist/components/ui/core/dialog/dialog.js +82 -155
  63. package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +19 -17
  64. package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +150 -250
  65. package/dist/components/ui/core/empty-state/empty-state.context.js +5 -8
  66. package/dist/components/ui/core/empty-state/empty-state.js +86 -138
  67. package/dist/components/ui/core/helper-text/helper-text.js +37 -65
  68. package/dist/components/ui/core/hover-card/hover-card.js +54 -80
  69. package/dist/components/ui/core/inline-citation/inline-citation.js +98 -181
  70. package/dist/components/ui/core/input/input.js +12 -27
  71. package/dist/components/ui/core/input-group/input-group.js +76 -173
  72. package/dist/components/ui/core/kbd/kbd.js +20 -36
  73. package/dist/components/ui/core/label/label.js +26 -43
  74. package/dist/components/ui/core/loader/loader.js +80 -117
  75. package/dist/components/ui/core/message/message-response-default-streamdown-controls.js +12 -12
  76. package/dist/components/ui/core/message/message.d.ts +2 -2
  77. package/dist/components/ui/core/message/message.js +316 -542
  78. package/dist/components/ui/core/pagination/pagination-size-context.js +5 -6
  79. package/dist/components/ui/core/pagination/pagination-teleport.js +86 -106
  80. package/dist/components/ui/core/pagination/pagination-teleport.utils.js +6 -6
  81. package/dist/components/ui/core/pagination/pagination.js +231 -334
  82. package/dist/components/ui/core/popover/popover.js +90 -157
  83. package/dist/components/ui/core/progress/progress.js +36 -61
  84. package/dist/components/ui/core/prompt-input/prompt-input.js +274 -413
  85. package/dist/components/ui/core/radio-group/radio-group.js +58 -113
  86. package/dist/components/ui/core/reasoning/reasoning.js +55 -86
  87. package/dist/components/ui/core/scroll-area/scroll-area.js +41 -71
  88. package/dist/components/ui/core/search/search.js +77 -99
  89. package/dist/components/ui/core/segmented-control/segmented-control.js +110 -167
  90. package/dist/components/ui/core/select/select.js +168 -293
  91. package/dist/components/ui/core/separator/separator.js +13 -23
  92. package/dist/components/ui/core/shimmer/shimmer.d.ts +2 -4
  93. package/dist/components/ui/core/shimmer/shimmer.js +40 -107
  94. package/dist/components/ui/core/skeleton/skeleton.js +13 -18
  95. package/dist/components/ui/core/sonner-toast/sonner-toast.js +54 -47
  96. package/dist/components/ui/core/sources/sources.d.ts +5 -1
  97. package/dist/components/ui/core/sources/sources.js +58 -79
  98. package/dist/components/ui/core/switch/switch.js +62 -0
  99. package/dist/components/ui/core/tabs/tabs.js +149 -223
  100. package/dist/components/ui/core/tabs/tabs.utils.js +6 -8
  101. package/dist/components/ui/core/textarea/textarea.js +13 -27
  102. package/dist/components/ui/core/toggle/toggle.js +55 -74
  103. package/dist/components/ui/core/tool/tool.js +127 -163
  104. package/dist/components/ui/core/tooltip/tooltip.js +47 -86
  105. package/dist/components/ui/core/topbar/topbar.js +106 -190
  106. package/dist/eslint/index.js +5 -10
  107. package/dist/eslint/no-overriding-styles.js +178 -237
  108. package/dist/icons/index.d.ts +1 -0
  109. package/dist/icons/index.js +1 -0
  110. package/dist/lib/highlight-code.d.ts +9 -0
  111. package/dist/lib/highlight-code.js +42 -0
  112. package/dist/lib/portal-container-context.js +8 -9
  113. package/dist/lib/style-scope.js +6 -6
  114. package/dist/lib/use-controllable-state.js +21 -30
  115. package/dist/lib/utils.d.ts +0 -2
  116. package/dist/lib/utils.js +32 -112
  117. package/dist/styles.css +1 -1
  118. package/dist/styles.source.css +23 -0
  119. package/package.json +23 -7
  120. package/dist/components/ui/core/date-time-pickers/shared/constants.js +0 -14
@@ -1,99 +1,64 @@
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
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 "../shared/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
+ });
99
62
  };
63
+ //#endregion
64
+ export { u as DateRangePicker };
@@ -13,8 +13,7 @@ export interface UseDateRangePickerReturn {
13
13
  tempStart: Dayjs | null;
14
14
  tempEnd: Dayjs | null;
15
15
  hoverDate: Dayjs | null;
16
- handleTogglePopover: () => void;
17
- handleCancel: () => void;
16
+ handleOpenChange: (open: boolean) => void;
18
17
  handleDateClick: (date: Dayjs) => void;
19
18
  handleMonthChange: (month: Dayjs) => void;
20
19
  handleDateHover: (date: Dayjs | null) => void;
@@ -1,82 +1,61 @@
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
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
+ };
82
59
  };
60
+ //#endregion
61
+ export { s as useDateRangePicker };
@@ -1,190 +1,119 @@
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
1
+ import { cn as e } from "../../../../../lib/utils.js";
2
+ import { Button as t } from "../../button/button.js";
3
+ import { Popover as ee, PopoverContent as te, PopoverTrigger as n } from "../../popover/popover.js";
4
+ import { Calendar as r } from "../shared/calendar/calendar.js";
5
+ import { DateTimeInput as i } from "../shared/date-time-input/date-time-input.js";
6
+ import { ShortcutsPanel as a } from "../shared/shortcuts-panel/shortcuts-panel.js";
7
+ import { convert12HourTo24Hour as o } from "../utils/time-utils.js";
8
+ import { TimePickerPanel as s } from "../shared/time-picker-panel/time-picker-panel.js";
9
+ import { useDateTimeRangePicker as c } from "./use-date-time-range-picker.js";
10
+ import { useMemo as l } from "react";
11
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
12
+ //#region libs/aura/src/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.tsx
13
+ var f = ({ value: f, onChange: p, format: m = "DD/MM/YYYY HH:mm", placeholder: h, displayWeekNumber: g = !1, shortcuts: _, timeFormat: v = "24h", defaultDate: ne, className: re }) => {
14
+ let { isOpen: y, step: b, displayedMonth: x, tempStart: S, tempEnd: C, hoverDate: w, tempStartHour: T, tempStartMinute: E, tempEndHour: D, tempEndMinute: O, startAmPm: k, endAmPm: A, handleOpenChange: j, handleSetStep: M, handleDateClick: N, handleMonthChange: P, handleDateHover: F, handleStartHourChange: ie, handleStartMinuteChange: I, handleEndHourChange: L, handleEndMinuteChange: R, handleStartAmPmChange: z, handleEndAmPmChange: B, handleNext: V, handleApply: H, handleBack: U, handleApplyShortcut: W, popoverRef: G, inputRef: K } = c({
15
+ value: f,
16
+ onChange: p,
17
+ timeFormat: v,
18
+ defaultDate: ne
19
+ }), q = b === "start" ? S !== null : C !== null, J = b === "start" ? "Next" : "Apply", Y = b === "start" ? V : H, X = b === "start" ? T : D, Z = b === "start" ? E : O, ae = b === "start" ? k : A, Q = b === "start" ? ie : L, $ = b === "start" ? I : R, oe = b === "start" ? z : B, se = l(() => [S ? S.hour(v === "12h" ? o(T, k) : T).minute(E) : null, C ? C.hour(v === "12h" ? o(D, A) : D).minute(O) : null], [
20
+ S,
21
+ C,
22
+ T,
23
+ E,
24
+ D,
25
+ O,
26
+ k,
27
+ A,
28
+ v
29
+ ]);
30
+ return /* @__PURE__ */ u("div", {
31
+ "data-slot": "date-time-range-picker",
32
+ className: e("relative w-full", re),
33
+ children: /* @__PURE__ */ d(ee, {
34
+ open: y,
35
+ onOpenChange: j,
36
+ children: [/* @__PURE__ */ u(n, {
37
+ render: /* @__PURE__ */ u("div", {
38
+ ref: K,
39
+ className: "w-full"
40
+ }),
41
+ children: /* @__PURE__ */ u(i, {
42
+ value: se,
43
+ format: m,
44
+ placeholder: h,
45
+ isOpen: y,
46
+ variant: "datetime",
47
+ activeRangePart: y ? b : void 0,
48
+ onRangePartClick: y ? M : void 0
49
+ })
50
+ }), /* @__PURE__ */ u(te, {
51
+ ref: G,
52
+ className: "rounded-xl w-auto p-0",
53
+ side: "bottom",
54
+ align: "start",
55
+ children: /* @__PURE__ */ d("div", {
56
+ "data-slot": "date-time-range-picker-content",
57
+ className: "flex flex-col",
58
+ children: [/* @__PURE__ */ d("div", {
59
+ className: "flex flex-row",
60
+ children: [
61
+ _ && _.length > 0 && /* @__PURE__ */ u(a, {
62
+ shortcuts: _,
63
+ onShortcutClick: W
64
+ }),
65
+ /* @__PURE__ */ u("div", {
66
+ className: "p-3 border-r border-border",
67
+ children: /* @__PURE__ */ u(r, {
68
+ displayedMonth: x,
69
+ selectedRange: [S, C],
70
+ hoverDate: b === "end" ? w : null,
71
+ displayWeekNumber: g,
72
+ onDateClick: N,
73
+ onMonthChange: P,
74
+ onDateHover: F
75
+ })
76
+ }),
77
+ v === "12h" ? /* @__PURE__ */ u(s, {
78
+ hour: X,
79
+ minute: Z,
80
+ amPm: ae,
81
+ timeFormat: "12h",
82
+ onHourChange: Q,
83
+ onMinuteChange: $,
84
+ onAmPmChange: oe
85
+ }) : /* @__PURE__ */ u(s, {
86
+ hour: X,
87
+ minute: Z,
88
+ timeFormat: "24h",
89
+ onHourChange: Q,
90
+ onMinuteChange: $
91
+ })
92
+ ]
93
+ }), /* @__PURE__ */ d("div", {
94
+ className: "flex p-2 justify-between items-center self-stretch border-t border-border",
95
+ children: [/* @__PURE__ */ u(t, {
96
+ variant: "ghost",
97
+ onClick: () => j(!1),
98
+ children: "Cancel"
99
+ }), /* @__PURE__ */ d("div", {
100
+ className: "flex gap-2",
101
+ children: [b === "end" && /* @__PURE__ */ u(t, {
102
+ variant: "ghost",
103
+ onClick: U,
104
+ children: "Back"
105
+ }), /* @__PURE__ */ u(t, {
106
+ variant: "secondary",
107
+ onClick: Y,
108
+ disabled: !q,
109
+ children: J
110
+ })]
111
+ })]
112
+ })]
113
+ })
114
+ })]
115
+ })
116
+ });
190
117
  };
118
+ //#endregion
119
+ export { f as DateTimeRangePicker };
@@ -21,7 +21,7 @@ export interface UseDateTimeRangePickerReturn {
21
21
  tempEndMinute: number;
22
22
  startAmPm: 'AM' | 'PM';
23
23
  endAmPm: 'AM' | 'PM';
24
- handleTogglePopover: () => void;
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>;