@cognite/aura 0.1.7 → 0.3.0

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 (232) hide show
  1. package/DESIGN.md +34 -92
  2. package/README.md +33 -0
  3. package/dist/colors.css +471 -214
  4. package/dist/components/index.d.ts +17 -33
  5. package/dist/components/index.js +315 -281
  6. package/dist/components/ui/core/accordion/accordion.d.ts +7 -7
  7. package/dist/components/ui/core/accordion/accordion.js +64 -62
  8. package/dist/components/ui/core/action-toolbar/action-toolbar.d.ts +41 -0
  9. package/dist/components/ui/core/action-toolbar/action-toolbar.js +176 -0
  10. package/dist/components/ui/core/alert/alert.d.ts +23 -12
  11. package/dist/components/ui/core/alert/alert.js +123 -120
  12. package/dist/components/ui/core/avatar/avatar.d.ts +12 -8
  13. package/dist/components/ui/core/avatar/avatar.js +10 -10
  14. package/dist/components/ui/core/badge/badge.d.ts +11 -8
  15. package/dist/components/ui/core/badge/badge.js +13 -13
  16. package/dist/components/ui/core/banner/banner.d.ts +18 -28
  17. package/dist/components/ui/core/banner/banner.js +6 -6
  18. package/dist/components/ui/core/breadcrumb/breadcrumb.d.ts +12 -0
  19. package/dist/components/ui/core/breadcrumb/breadcrumb.js +200 -0
  20. package/dist/components/ui/core/button/button.d.ts +8 -5
  21. package/dist/components/ui/core/button/button.js +22 -19
  22. package/dist/components/ui/core/button-group/button-group.d.ts +7 -6
  23. package/dist/components/ui/core/card/card.d.ts +18 -14
  24. package/dist/components/ui/core/card/card.js +131 -87
  25. package/dist/components/ui/core/chart/chart.d.ts +69 -0
  26. package/dist/components/ui/core/chart/chart.js +215 -0
  27. package/dist/components/ui/core/chart/index.d.ts +2 -0
  28. package/dist/components/ui/core/chart/index.js +8 -0
  29. package/dist/components/ui/core/checkbox/checkbox.d.ts +17 -0
  30. package/dist/components/ui/core/checkbox/checkbox.js +133 -0
  31. package/dist/components/ui/core/{badge/badge.metadata.d.ts → checkbox/checkbox.metadata.d.ts} +1 -1
  32. package/dist/components/ui/core/checkbox/checkbox.metadata.js +8 -0
  33. package/dist/components/ui/core/code-block/code-block.d.ts +6 -9
  34. package/dist/components/ui/core/code-block/code-block.js +52 -48
  35. package/dist/components/ui/core/collapsible/collapsible.d.ts +5 -3
  36. package/dist/components/ui/core/combobox/combobox.d.ts +2 -2
  37. package/dist/components/ui/core/command/command.d.ts +11 -78
  38. package/dist/components/ui/core/command/command.js +53 -52
  39. package/dist/components/ui/core/count/count.d.ts +9 -0
  40. package/dist/components/ui/core/count/count.js +32 -0
  41. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.d.ts +15 -0
  42. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +99 -0
  43. package/dist/components/ui/core/date-time-pickers/date-range-picker/index.d.ts +3 -0
  44. package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +25 -0
  45. package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.d.ts +4 -0
  46. package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +82 -0
  47. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.d.ts +17 -0
  48. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +190 -0
  49. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/index.d.ts +3 -0
  50. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +42 -0
  51. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.d.ts +3 -0
  52. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +161 -0
  53. package/dist/components/ui/core/date-time-pickers/index.d.ts +6 -0
  54. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.d.ts +7 -0
  55. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +57 -0
  56. package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.d.ts +13 -0
  57. package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +119 -0
  58. package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.d.ts +10 -0
  59. package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.js +93 -0
  60. package/dist/components/ui/core/date-time-pickers/shared/constants.d.ts +20 -0
  61. package/dist/components/ui/core/date-time-pickers/shared/constants.js +14 -0
  62. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.d.ts +19 -0
  63. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +99 -0
  64. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.d.ts +12 -0
  65. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +68 -0
  66. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.d.ts +12 -0
  67. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +40 -0
  68. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.d.ts +29 -0
  69. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +63 -0
  70. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.d.ts +8 -0
  71. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +19 -0
  72. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.d.ts +17 -0
  73. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +34 -0
  74. package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.d.ts +8 -0
  75. package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +7 -0
  76. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.d.ts +13 -0
  77. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +31 -0
  78. package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.d.ts +10 -0
  79. package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +52 -0
  80. package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.d.ts +48 -0
  81. package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +52 -0
  82. package/dist/components/ui/core/date-time-pickers/utils/date-range-utils.d.ts +26 -0
  83. package/dist/components/ui/core/date-time-pickers/utils/format-utils.d.ts +37 -0
  84. package/dist/components/ui/core/date-time-pickers/utils/segment-utils.d.ts +34 -0
  85. package/dist/components/ui/core/date-time-pickers/utils/time-utils.d.ts +43 -0
  86. package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +15 -0
  87. package/dist/components/ui/core/date-time-pickers/utils/time-validation.d.ts +23 -0
  88. package/dist/components/ui/core/dialog/dialog.d.ts +10 -10
  89. package/dist/components/ui/core/dialog/dialog.js +12 -3
  90. package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +24 -47
  91. package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +125 -123
  92. package/dist/components/ui/core/empty-state/empty-state.context.d.ts +10 -0
  93. package/dist/components/ui/core/empty-state/empty-state.context.js +8 -0
  94. package/dist/components/ui/core/empty-state/empty-state.d.ts +18 -0
  95. package/dist/components/ui/core/empty-state/empty-state.js +139 -0
  96. package/dist/components/ui/core/helper-text/helper-text.d.ts +7 -5
  97. package/dist/components/ui/core/hover-card/hover-card.d.ts +5 -7
  98. package/dist/components/ui/core/hover-card/hover-card.js +26 -25
  99. package/dist/components/ui/core/inline-citation/inline-citation.d.ts +10 -10
  100. package/dist/components/ui/core/inline-citation/inline-citation.js +65 -57
  101. package/dist/components/ui/core/input/input.d.ts +2 -1
  102. package/dist/components/ui/core/input-group/input-group.d.ts +17 -13
  103. package/dist/components/ui/core/input-group/input-group.js +35 -36
  104. package/dist/components/ui/core/kbd/kbd.d.ts +4 -0
  105. package/dist/components/ui/core/kbd/kbd.js +36 -0
  106. package/dist/components/ui/core/label/label.d.ts +3 -2
  107. package/dist/components/ui/core/loader/loader.d.ts +11 -3
  108. package/dist/components/ui/core/loader/loader.js +106 -107
  109. package/dist/components/ui/core/message/message.d.ts +18 -17
  110. package/dist/components/ui/core/message/message.js +15 -13
  111. package/dist/components/ui/core/pagination/pagination-size-context.d.ts +5 -0
  112. package/dist/components/ui/core/pagination/pagination-size-context.js +6 -0
  113. package/dist/components/ui/core/pagination/pagination-teleport.d.ts +11 -0
  114. package/dist/components/ui/core/pagination/pagination-teleport.js +108 -0
  115. package/dist/components/ui/core/pagination/pagination-teleport.utils.d.ts +1 -0
  116. package/dist/components/ui/core/pagination/pagination-teleport.utils.js +7 -0
  117. package/dist/components/ui/core/pagination/pagination.d.ts +41 -0
  118. package/dist/components/ui/core/pagination/pagination.js +335 -0
  119. package/dist/components/ui/core/popover/popover.d.ts +12 -16
  120. package/dist/components/ui/core/popover/popover.js +52 -51
  121. package/dist/components/ui/core/progress/progress.d.ts +7 -4
  122. package/dist/components/ui/core/prompt-input/prompt-input.d.ts +36 -103
  123. package/dist/components/ui/core/prompt-input/prompt-input.js +193 -180
  124. package/dist/components/ui/core/radio-group/radio-group.d.ts +20 -0
  125. package/dist/components/ui/core/radio-group/radio-group.js +113 -0
  126. package/dist/components/ui/core/reasoning/reasoning.d.ts +5 -5
  127. package/dist/components/ui/core/reasoning/reasoning.js +1 -1
  128. package/dist/components/ui/core/scroll-area/scroll-area.d.ts +4 -2
  129. package/dist/components/ui/core/search/search.d.ts +10 -0
  130. package/dist/components/ui/core/search/search.js +99 -0
  131. package/dist/components/ui/core/segmented-control/segmented-control.d.ts +20 -0
  132. package/dist/components/ui/core/segmented-control/segmented-control.js +172 -0
  133. package/dist/components/ui/core/select/select.d.ts +13 -13
  134. package/dist/components/ui/core/select/select.js +13 -10
  135. package/dist/components/ui/core/separator/separator.d.ts +2 -4
  136. package/dist/components/ui/core/separator/separator.js +4 -5
  137. package/dist/components/ui/core/shimmer/shimmer.d.ts +3 -5
  138. package/dist/components/ui/core/shimmer/shimmer.js +25 -26
  139. package/dist/components/ui/core/skeleton/skeleton.d.ts +2 -1
  140. package/dist/components/ui/core/sonner-toast/sonner-toast.d.ts +4 -0
  141. package/dist/components/ui/core/sonner-toast/sonner-toast.js +48 -0
  142. package/dist/components/ui/core/sources/sources.d.ts +3 -3
  143. package/dist/components/ui/core/sources/sources.js +6 -1
  144. package/dist/components/ui/core/switch/switch.d.ts +11 -0
  145. package/dist/components/ui/core/{button/button.metadata.d.ts → switch/switch.metadata.d.ts} +1 -1
  146. package/dist/components/ui/core/tabs/tabs.d.ts +27 -0
  147. package/dist/components/ui/core/tabs/tabs.js +224 -0
  148. package/dist/components/ui/core/tabs/tabs.utils.d.ts +2 -0
  149. package/dist/components/ui/core/tabs/tabs.utils.js +9 -0
  150. package/dist/components/ui/core/textarea/textarea.d.ts +2 -1
  151. package/dist/components/ui/core/textarea/textarea.js +20 -18
  152. package/dist/components/ui/core/tool/tool.d.ts +7 -6
  153. package/dist/components/ui/core/tool/tool.js +48 -44
  154. package/dist/components/ui/core/tooltip/tooltip.d.ts +6 -5
  155. package/dist/components/ui/core/tooltip/tooltip.js +10 -8
  156. package/dist/components/ui/core/topbar/topbar.d.ts +28 -0
  157. package/dist/components/ui/core/topbar/topbar.js +190 -0
  158. package/dist/eslint/index.d.ts +2 -1
  159. package/dist/index.d.ts +1 -1
  160. package/dist/index.js +298 -273
  161. package/dist/lib/portal-container-context.d.ts +2 -1
  162. package/dist/lib/portal-container-context.js +1 -3
  163. package/dist/lib/utils.d.ts +11 -0
  164. package/dist/lib/utils.js +40 -29
  165. package/dist/styles.css +1 -1
  166. package/dist/styles.source.css +75 -8
  167. package/package.json +26 -5
  168. package/dist/components/ui/core/accordion/accordion.metadata.d.ts +0 -2
  169. package/dist/components/ui/core/accordion/accordion.metadata.js +0 -9
  170. package/dist/components/ui/core/alert/alert.metadata.d.ts +0 -2
  171. package/dist/components/ui/core/alert/alert.metadata.js +0 -9
  172. package/dist/components/ui/core/avatar/avatar.metadata.d.ts +0 -8
  173. package/dist/components/ui/core/avatar/avatar.metadata.js +0 -9
  174. package/dist/components/ui/core/badge/badge.metadata.js +0 -8
  175. package/dist/components/ui/core/banner/banner.metadata.d.ts +0 -2
  176. package/dist/components/ui/core/banner/banner.metadata.js +0 -9
  177. package/dist/components/ui/core/button/button.metadata.js +0 -9
  178. package/dist/components/ui/core/button-group/button-group.metadata.d.ts +0 -2
  179. package/dist/components/ui/core/button-group/button-group.metadata.js +0 -8
  180. package/dist/components/ui/core/card/card.metadata.d.ts +0 -8
  181. package/dist/components/ui/core/card/card.metadata.js +0 -9
  182. package/dist/components/ui/core/code-block/code-block.metadata.d.ts +0 -2
  183. package/dist/components/ui/core/code-block/code-block.metadata.js +0 -8
  184. package/dist/components/ui/core/collapsible/collapsible.metadata.d.ts +0 -2
  185. package/dist/components/ui/core/collapsible/collapsible.metadata.js +0 -9
  186. package/dist/components/ui/core/combobox/combobox.metadata.d.ts +0 -2
  187. package/dist/components/ui/core/command/command.metadata.d.ts +0 -2
  188. package/dist/components/ui/core/command/command.metadata.js +0 -9
  189. package/dist/components/ui/core/dialog/dialog.metadata.d.ts +0 -2
  190. package/dist/components/ui/core/dialog/dialog.metadata.js +0 -9
  191. package/dist/components/ui/core/dropdown-menu/dropdown-menu.metadata.d.ts +0 -2
  192. package/dist/components/ui/core/dropdown-menu/dropdown-menu.metadata.js +0 -9
  193. package/dist/components/ui/core/helper-text/helper-text.metadata.d.ts +0 -2
  194. package/dist/components/ui/core/helper-text/helper-text.metadata.js +0 -9
  195. package/dist/components/ui/core/hover-card/hover-card.metadata.d.ts +0 -2
  196. package/dist/components/ui/core/hover-card/hover-card.metadata.js +0 -8
  197. package/dist/components/ui/core/inline-citation/inline-citation.metadata.d.ts +0 -2
  198. package/dist/components/ui/core/inline-citation/inline-citation.metadata.js +0 -8
  199. package/dist/components/ui/core/input/input.metadata.d.ts +0 -2
  200. package/dist/components/ui/core/input/input.metadata.js +0 -9
  201. package/dist/components/ui/core/input-group/input-group.metadata.d.ts +0 -2
  202. package/dist/components/ui/core/input-group/input-group.metadata.js +0 -9
  203. package/dist/components/ui/core/label/label.metadata.d.ts +0 -2
  204. package/dist/components/ui/core/label/label.metadata.js +0 -9
  205. package/dist/components/ui/core/loader/loader.metadata.d.ts +0 -2
  206. package/dist/components/ui/core/loader/loader.metadata.js +0 -9
  207. package/dist/components/ui/core/message/message.metadata.d.ts +0 -2
  208. package/dist/components/ui/core/popover/popover.metadata.d.ts +0 -2
  209. package/dist/components/ui/core/popover/popover.metadata.js +0 -9
  210. package/dist/components/ui/core/progress/progress.metadata.d.ts +0 -2
  211. package/dist/components/ui/core/progress/progress.metadata.js +0 -9
  212. package/dist/components/ui/core/prompt-input/prompt-input.metadata.d.ts +0 -2
  213. package/dist/components/ui/core/prompt-input/prompt-input.metadata.js +0 -9
  214. package/dist/components/ui/core/reasoning/reasoning.metadata.d.ts +0 -2
  215. package/dist/components/ui/core/reasoning/reasoning.metadata.js +0 -8
  216. package/dist/components/ui/core/scroll-area/scroll-area.metadata.d.ts +0 -2
  217. package/dist/components/ui/core/scroll-area/scroll-area.metadata.js +0 -9
  218. package/dist/components/ui/core/select/select.metadata.d.ts +0 -2
  219. package/dist/components/ui/core/select/select.metadata.js +0 -9
  220. package/dist/components/ui/core/separator/separator.metadata.d.ts +0 -2
  221. package/dist/components/ui/core/separator/separator.metadata.js +0 -8
  222. package/dist/components/ui/core/shimmer/shimmer.metadata.d.ts +0 -2
  223. package/dist/components/ui/core/shimmer/shimmer.metadata.js +0 -9
  224. package/dist/components/ui/core/skeleton/skeleton.metadata.d.ts +0 -2
  225. package/dist/components/ui/core/skeleton/skeleton.metadata.js +0 -9
  226. package/dist/components/ui/core/sources/sources.metadata.d.ts +0 -2
  227. package/dist/components/ui/core/textarea/textarea.metadata.d.ts +0 -2
  228. package/dist/components/ui/core/textarea/textarea.metadata.js +0 -9
  229. package/dist/components/ui/core/tool/tool.metadata.d.ts +0 -2
  230. package/dist/components/ui/core/tool/tool.metadata.js +0 -8
  231. package/dist/components/ui/core/tooltip/tooltip.metadata.d.ts +0 -8
  232. package/dist/components/ui/core/tooltip/tooltip.metadata.js +0 -9
@@ -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,3 @@
1
+ export { DateTimeRangePicker } from './date-time-range-picker';
2
+ export type { DateTimeRangePickerProps } from './date-time-range-picker';
3
+ export type { ShortcutItem } from './date-time-range-picker';
@@ -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;
@@ -0,0 +1,161 @@
1
+ import { useRef as U, useCallback as n, useEffect as F } from "react";
2
+ import le from "dayjs";
3
+ import { DEFAULT_MINUTE as g, START_OF_DAY_HOUR as A, END_OF_DAY_MINUTE as T, END_OF_DAY_HOUR as D } from "../shared/constants.js";
4
+ import { usePopoverState as pe } from "../shared/hooks/use-popover-state.js";
5
+ import { useRangeDateState as fe } from "../shared/hooks/use-range-date-state.js";
6
+ import { useRangeStepManager as Se } from "../shared/hooks/use-range-step-manager.js";
7
+ import { useTimeState as I } from "../shared/hooks/use-time-state.js";
8
+ function ge(t) {
9
+ return t.hour(A).minute(g);
10
+ }
11
+ function Ae(t) {
12
+ return t.hour(D).minute(T);
13
+ }
14
+ const Re = ({
15
+ value: t,
16
+ onChange: r,
17
+ timeFormat: M = "24h",
18
+ defaultDate: Y = le()
19
+ }) => {
20
+ const C = U(() => {
21
+ }), E = U(() => {
22
+ }), {
23
+ isOpen: h,
24
+ setIsOpen: o,
25
+ popoverRef: w,
26
+ inputRef: x,
27
+ handleTogglePopover: H
28
+ } = pe({
29
+ onClose: n(() => C.current(), []),
30
+ onBackspace: n(() => E.current(), [])
31
+ }), b = Se(), { step: m, handleNext: d, handleBack: a, resetStep: P } = b, j = fe({
32
+ value: t,
33
+ defaultDate: Y,
34
+ mapDate: (e, i) => i === "start" ? ge(e) : Ae(e)
35
+ }), {
36
+ tempStart: L,
37
+ tempEnd: q,
38
+ displayedMonth: z,
39
+ hoverDate: G,
40
+ stateRef: u,
41
+ handleDateClick: R,
42
+ handleDateHover: J,
43
+ handleMonthChange: K,
44
+ clearActiveSegment: k,
45
+ resetDates: c
46
+ } = j, Q = I({
47
+ initialHour: t[0]?.hour() ?? A,
48
+ initialMinute: t[0]?.minute() ?? g,
49
+ timeFormat: M
50
+ }), {
51
+ hour: W,
52
+ minute: l,
53
+ amPm: X,
54
+ hour24: O,
55
+ handleHourChange: Z,
56
+ handleMinuteChange: $,
57
+ handleAmPmChange: v,
58
+ resetTime: _
59
+ } = Q, V = I({
60
+ initialHour: t[1]?.hour() ?? D,
61
+ initialMinute: t[1]?.minute() ?? T,
62
+ timeFormat: M
63
+ }), {
64
+ hour: ee,
65
+ minute: p,
66
+ amPm: te,
67
+ hour24: y,
68
+ handleHourChange: ne,
69
+ handleMinuteChange: re,
70
+ handleAmPmChange: oe,
71
+ resetTime: B
72
+ } = V, s = n(() => {
73
+ c(t), P(), _(
74
+ t[0]?.hour() ?? A,
75
+ t[0]?.minute() ?? g
76
+ ), B(
77
+ t[1]?.hour() ?? D,
78
+ t[1]?.minute() ?? T
79
+ );
80
+ }, [t, c, P, _, B]), N = n(() => {
81
+ const e = k(m);
82
+ e === null ? a() : e[0] === null && e[1] === null && r(e);
83
+ }, [k, m, a, r]);
84
+ F(() => {
85
+ C.current = s;
86
+ }, [s]), F(() => {
87
+ E.current = N;
88
+ }, [N]);
89
+ const ae = n(() => {
90
+ h || s(), H();
91
+ }, [h, H, s]), se = n(
92
+ (e) => {
93
+ e === "start" ? a() : d();
94
+ },
95
+ [a, d]
96
+ ), ie = n(
97
+ (e) => {
98
+ R(e, m);
99
+ },
100
+ [R, m]
101
+ ), me = n(() => {
102
+ const { tempStart: e, tempEnd: i } = u.current;
103
+ if (e && i) {
104
+ const f = e.hour(O).minute(l).startOf("minute"), S = i.hour(y).minute(p).endOf("minute"), de = f.isAfter(S) ? [S, f] : [f, S];
105
+ r(de), o(!1);
106
+ }
107
+ }, [
108
+ u,
109
+ O,
110
+ l,
111
+ y,
112
+ p,
113
+ r,
114
+ o
115
+ ]), ue = n(() => {
116
+ s(), o(!1);
117
+ }, [s, o]), ce = n(() => {
118
+ a(), c([u.current.tempStart, null]);
119
+ }, [a, c, u]), he = n(
120
+ (e) => {
121
+ const i = Array.isArray(e) ? e : [e, e];
122
+ r(i), o(!1);
123
+ },
124
+ [r, o]
125
+ );
126
+ return {
127
+ isOpen: h,
128
+ step: m,
129
+ displayedMonth: z,
130
+ tempStart: L,
131
+ tempEnd: q,
132
+ hoverDate: G,
133
+ tempStartHour: W,
134
+ tempStartMinute: l,
135
+ tempEndHour: ee,
136
+ tempEndMinute: p,
137
+ startAmPm: X,
138
+ endAmPm: te,
139
+ handleTogglePopover: ae,
140
+ handleSetStep: se,
141
+ handleDateClick: ie,
142
+ handleMonthChange: K,
143
+ handleDateHover: J,
144
+ handleStartHourChange: Z,
145
+ handleStartMinuteChange: $,
146
+ handleEndHourChange: ne,
147
+ handleEndMinuteChange: re,
148
+ handleStartAmPmChange: v,
149
+ handleEndAmPmChange: oe,
150
+ handleNext: d,
151
+ handleApply: me,
152
+ handleCancel: ue,
153
+ handleBack: ce,
154
+ handleApplyShortcut: he,
155
+ popoverRef: w,
156
+ inputRef: x
157
+ };
158
+ };
159
+ export {
160
+ Re as useDateTimeRangePicker
161
+ };
@@ -0,0 +1,6 @@
1
+ export { DateRangePicker } from './date-range-picker';
2
+ export type { DateRangePickerProps } from './date-range-picker';
3
+ export { DateTimeRangePicker } from './date-time-range-picker';
4
+ export type { DateTimeRangePickerProps } from './date-time-range-picker';
5
+ export type { ShortcutItem } from './date-time-range-picker';
6
+ export type { TimeFormat } from './utils/format-utils';
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ export type AmPmScrollProps = {
3
+ value: 'AM' | 'PM' | null;
4
+ onChange: (value: 'AM' | 'PM') => void;
5
+ className?: string;
6
+ };
7
+ export declare const AmPmScroll: FC<AmPmScrollProps>;
@@ -0,0 +1,57 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { useRef as s, useEffect as L } from "react";
3
+ import { cn as l } from "../../../../../../lib/utils.js";
4
+ import { SCROLL_ITEM_SELECTED_CLASSES as _, SCROLL_ITEM_UNSELECTED_CLASSES as C, SCROLL_ITEM_BASE_CLASSES as a, SCROLL_CONTAINER_CLASSES as d } from "../scroll-cell-classes.js";
5
+ const A = ["AM", "PM"], p = ({
6
+ value: e,
7
+ onChange: c,
8
+ className: S
9
+ }) => {
10
+ const r = s(null), n = s(null);
11
+ L(() => {
12
+ if (e !== null && n.current && r.current) {
13
+ const o = r.current, t = n.current;
14
+ o.scrollTo({
15
+ top: t.offsetTop - o.offsetHeight / 2 + t.offsetHeight / 2,
16
+ behavior: "smooth"
17
+ });
18
+ }
19
+ }, [e]);
20
+ const f = (o, t) => {
21
+ (o.key === "Enter" || o.key === " ") && (o.preventDefault(), c(t));
22
+ };
23
+ return /* @__PURE__ */ i(
24
+ "div",
25
+ {
26
+ "data-slot": "am-pm-scroll",
27
+ ref: r,
28
+ role: "listbox",
29
+ "aria-label": "AM/PM",
30
+ "aria-orientation": "vertical",
31
+ className: l(d, S),
32
+ children: A.map((o) => {
33
+ const t = e !== null && o === e;
34
+ return /* @__PURE__ */ i(
35
+ "div",
36
+ {
37
+ ref: t ? n : void 0,
38
+ tabIndex: 0,
39
+ className: l(
40
+ a,
41
+ t ? _ : C
42
+ ),
43
+ onClick: () => c(o),
44
+ onKeyDown: (E) => f(E, o),
45
+ role: "option",
46
+ "aria-selected": t,
47
+ children: o
48
+ },
49
+ o
50
+ );
51
+ })
52
+ }
53
+ );
54
+ };
55
+ export {
56
+ p as AmPmScroll
57
+ };
@@ -0,0 +1,13 @@
1
+ import { FC } from 'react';
2
+ import { Dayjs } from 'dayjs';
3
+ export interface CalendarProps {
4
+ displayedMonth: Dayjs;
5
+ selectedRange: [Dayjs | null, Dayjs | null];
6
+ hoverDate: Dayjs | null;
7
+ displayWeekNumber?: boolean;
8
+ onDateClick: (date: Dayjs) => void;
9
+ onMonthChange: (month: Dayjs) => void;
10
+ onDateHover?: (date: Dayjs | null) => void;
11
+ className?: string;
12
+ }
13
+ export declare const Calendar: FC<CalendarProps>;
@@ -0,0 +1,119 @@
1
+ import { jsxs as x, jsx as l } from "react/jsx-runtime";
2
+ import C from "react";
3
+ import { cn as b } from "../../../../../../lib/utils.js";
4
+ import { getCalendarDays as _, getWeekdayNames as E, getWeekNumbers as O, isDateInRange as v, isSameDay as f, isToday as T, isOutsideMonth as B } from "../../utils/calendar-utils.js";
5
+ import { CalendarHeader as K } from "../calendar-header/calendar-header.js";
6
+ import { DAYS_IN_WEEK as p } from "../constants.js";
7
+ function P({
8
+ isOutsideMonth: r,
9
+ isSelected: t,
10
+ isToday: s,
11
+ isRangeStart: o,
12
+ isRangeEnd: c,
13
+ isInRange: a,
14
+ isInHoverRange: i
15
+ }) {
16
+ return b(
17
+ "w-9 h-9 flex items-center justify-center text-sm font-medium cursor-pointer select-none relative transition-colors",
18
+ "focus-visible:ring-2 focus-visible:ring-border focus-visible:outline-none",
19
+ // border-radius for range endpoints
20
+ o && c && "rounded-lg",
21
+ o && !c && "rounded-l-lg",
22
+ c && !o && "rounded-r-lg",
23
+ // selected day
24
+ t && "bg-primary-background text-foreground-on-primary hover:bg-primary-background",
25
+ // unselected text
26
+ !t && r && "text-muted-foreground/50",
27
+ !t && !r && (a || i) ? "text-foreground" : !t && !r && "text-secondary-foreground",
28
+ // range highlight
29
+ !t && (a || i) && "bg-accent-background",
30
+ !t && "hover:bg-accent-background hover:rounded-lg hover:text-foreground",
31
+ // today outline
32
+ s && !t && "border border-border rounded-lg"
33
+ );
34
+ }
35
+ const W = ({
36
+ displayedMonth: r,
37
+ selectedRange: t,
38
+ hoverDate: s,
39
+ displayWeekNumber: o = !1,
40
+ onDateClick: c,
41
+ onMonthChange: a,
42
+ onDateHover: i,
43
+ className: N
44
+ }) => {
45
+ const [n, m] = t, h = _(r), M = E(), k = o ? O(h) : [], Y = () => {
46
+ a(r.subtract(1, "month"));
47
+ }, D = () => {
48
+ a(r.add(1, "month"));
49
+ }, w = (e) => {
50
+ const d = {
51
+ isOutsideMonth: B(e, r),
52
+ isToday: T(e),
53
+ isSelected: f(e, n) || f(e, m),
54
+ isRangeStart: f(e, n),
55
+ isRangeEnd: f(e, m),
56
+ isInRange: v(e, n, m),
57
+ isInHoverRange: !1
58
+ };
59
+ if (s && n && !m) {
60
+ const u = n.isBefore(s) ? n : s, g = n.isBefore(s) ? s : n;
61
+ d.isInHoverRange = v(e, u, g);
62
+ }
63
+ return d;
64
+ };
65
+ return /* @__PURE__ */ x("div", { "data-slot": "calendar", className: b("flex flex-col gap-4", N), children: [
66
+ /* @__PURE__ */ l(
67
+ K,
68
+ {
69
+ displayedMonth: r,
70
+ onPrevMonth: Y,
71
+ onNextMonth: D,
72
+ onMonthChange: a
73
+ }
74
+ ),
75
+ /* @__PURE__ */ x(
76
+ "div",
77
+ {
78
+ className: b(
79
+ "grid gap-0",
80
+ o ? "grid-cols-calendar-weeks" : "grid-cols-calendar"
81
+ ),
82
+ children: [
83
+ o && /* @__PURE__ */ l("div", { className: "text-xs font-semibold text-muted-foreground text-center py-2 px-1", children: "#" }),
84
+ M.map((e) => /* @__PURE__ */ l(
85
+ "div",
86
+ {
87
+ className: "text-xs font-medium text-muted-foreground text-center py-2 px-1 tracking-tighter",
88
+ children: e
89
+ },
90
+ e
91
+ )),
92
+ h.map((e, d) => {
93
+ const u = w(e), g = Math.floor(d / p), I = o && d % p === 0, j = `day-${e.format("YYYY-MM-DD")}`;
94
+ return /* @__PURE__ */ x(C.Fragment, { children: [
95
+ I && /* @__PURE__ */ l("div", { className: "text-xs text-muted-foreground text-center flex items-center justify-center h-9", children: k[g] }),
96
+ /* @__PURE__ */ l(
97
+ "div",
98
+ {
99
+ className: P(u),
100
+ onClick: () => c(e),
101
+ onMouseEnter: () => i?.(e),
102
+ onMouseLeave: () => i?.(null),
103
+ role: "gridcell",
104
+ tabIndex: 0,
105
+ "aria-label": e.format("DD MMMM YYYY"),
106
+ "aria-selected": u.isSelected,
107
+ children: e.date()
108
+ }
109
+ )
110
+ ] }, j);
111
+ })
112
+ ]
113
+ }
114
+ )
115
+ ] });
116
+ };
117
+ export {
118
+ W as Calendar
119
+ };
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ import { Dayjs } from 'dayjs';
3
+ export interface CalendarHeaderProps {
4
+ displayedMonth: Dayjs;
5
+ onPrevMonth: () => void;
6
+ onNextMonth: () => void;
7
+ onMonthChange: (month: Dayjs) => void;
8
+ className?: string;
9
+ }
10
+ export declare const CalendarHeader: FC<CalendarHeaderProps>;