@cognite/aura 0.3.2 → 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 (108) hide show
  1. package/DESIGN.md +134 -5
  2. package/README.md +24 -3
  3. package/dist/components/index.d.ts +2 -0
  4. package/dist/components/index.js +58 -327
  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 -72
  26. package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +36 -51
  27. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +63 -87
  28. package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +60 -68
  29. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +118 -174
  30. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +104 -145
  31. package/dist/components/ui/core/date-time-pickers/index.js +5 -10
  32. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +42 -56
  33. package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +66 -117
  34. package/dist/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.js +63 -93
  35. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +64 -98
  36. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +38 -67
  37. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +23 -23
  38. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +52 -62
  39. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +18 -18
  40. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +24 -31
  41. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +24 -33
  42. package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +4 -7
  43. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +17 -31
  44. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +40 -40
  45. package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +33 -50
  46. package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +78 -99
  47. package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +41 -63
  48. package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +39 -52
  49. package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +7 -15
  50. package/dist/components/ui/core/dialog/dialog.js +82 -155
  51. package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +2 -2
  52. package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +150 -248
  53. package/dist/components/ui/core/empty-state/empty-state.context.js +5 -8
  54. package/dist/components/ui/core/empty-state/empty-state.js +86 -138
  55. package/dist/components/ui/core/helper-text/helper-text.js +37 -65
  56. package/dist/components/ui/core/hover-card/hover-card.js +54 -80
  57. package/dist/components/ui/core/inline-citation/inline-citation.js +98 -181
  58. package/dist/components/ui/core/input/input.js +12 -27
  59. package/dist/components/ui/core/input-group/input-group.js +76 -173
  60. package/dist/components/ui/core/kbd/kbd.js +20 -36
  61. package/dist/components/ui/core/label/label.js +26 -43
  62. package/dist/components/ui/core/loader/loader.js +80 -117
  63. package/dist/components/ui/core/message/message-response-default-streamdown-controls.js +12 -12
  64. package/dist/components/ui/core/message/message.d.ts +2 -2
  65. package/dist/components/ui/core/message/message.js +316 -542
  66. package/dist/components/ui/core/pagination/pagination-size-context.js +5 -6
  67. package/dist/components/ui/core/pagination/pagination-teleport.js +86 -106
  68. package/dist/components/ui/core/pagination/pagination-teleport.utils.js +6 -6
  69. package/dist/components/ui/core/pagination/pagination.js +231 -334
  70. package/dist/components/ui/core/popover/popover.js +90 -157
  71. package/dist/components/ui/core/progress/progress.js +36 -61
  72. package/dist/components/ui/core/prompt-input/prompt-input.js +274 -413
  73. package/dist/components/ui/core/radio-group/radio-group.js +58 -113
  74. package/dist/components/ui/core/reasoning/reasoning.js +55 -86
  75. package/dist/components/ui/core/scroll-area/scroll-area.js +41 -71
  76. package/dist/components/ui/core/search/search.js +77 -99
  77. package/dist/components/ui/core/segmented-control/segmented-control.js +110 -167
  78. package/dist/components/ui/core/select/select.js +168 -293
  79. package/dist/components/ui/core/separator/separator.js +13 -23
  80. package/dist/components/ui/core/shimmer/shimmer.d.ts +2 -4
  81. package/dist/components/ui/core/shimmer/shimmer.js +40 -107
  82. package/dist/components/ui/core/skeleton/skeleton.js +13 -18
  83. package/dist/components/ui/core/sonner-toast/sonner-toast.js +54 -47
  84. package/dist/components/ui/core/sources/sources.d.ts +5 -1
  85. package/dist/components/ui/core/sources/sources.js +58 -79
  86. package/dist/components/ui/core/switch/switch.js +62 -0
  87. package/dist/components/ui/core/tabs/tabs.js +149 -223
  88. package/dist/components/ui/core/tabs/tabs.utils.js +6 -8
  89. package/dist/components/ui/core/textarea/textarea.js +13 -27
  90. package/dist/components/ui/core/toggle/toggle.js +55 -74
  91. package/dist/components/ui/core/tool/tool.js +127 -163
  92. package/dist/components/ui/core/tooltip/tooltip.js +47 -86
  93. package/dist/components/ui/core/topbar/topbar.js +106 -190
  94. package/dist/eslint/index.js +5 -10
  95. package/dist/eslint/no-overriding-styles.js +178 -237
  96. package/dist/icons/index.d.ts +1 -0
  97. package/dist/icons/index.js +1 -0
  98. package/dist/lib/highlight-code.d.ts +9 -0
  99. package/dist/lib/highlight-code.js +42 -0
  100. package/dist/lib/portal-container-context.js +8 -9
  101. package/dist/lib/style-scope.js +6 -6
  102. package/dist/lib/use-controllable-state.js +21 -30
  103. package/dist/lib/utils.d.ts +0 -2
  104. package/dist/lib/utils.js +32 -112
  105. package/dist/styles.css +1 -1
  106. package/dist/styles.source.css +23 -0
  107. package/package.json +23 -7
  108. package/dist/components/ui/core/date-time-pickers/shared/constants.js +0 -14
@@ -1,93 +1,63 @@
1
- import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { IconChevronLeft as h, IconChevronRight as u, IconChevronDown as p } from "@tabler/icons-react";
3
- import i from "dayjs";
4
- import { cn as N } from "../../../../../../lib/utils.js";
5
- import { Button as l } from "../../../button/button.js";
6
- import { DropdownMenu as g, DropdownMenuTrigger as v, DropdownMenuContent as x, DropdownMenuItem as w } from "../../../dropdown-menu/dropdown-menu.js";
7
- const M = Array.from(
8
- { length: 12 },
9
- (r, a) => i().month(a).format("MMMM")
10
- ), c = i().year() - 50, b = i().year() + 10, z = Array.from(
11
- { length: b - c + 1 },
12
- (r, a) => c + a
13
- ), d = ({
14
- label: r,
15
- items: a,
16
- onSelect: s
17
- }) => /* @__PURE__ */ t(g, { modal: !1, children: [
18
- /* @__PURE__ */ e(
19
- v,
20
- {
21
- render: /* @__PURE__ */ t(
22
- l,
23
- {
24
- variant: "ghost",
25
- size: "sm",
26
- className: "h-7 px-2 gap-1 text-sm font-medium text-secondary-foreground",
27
- children: [
28
- r,
29
- /* @__PURE__ */ e(p, { className: "size-4" })
30
- ]
31
- }
32
- )
33
- }
34
- ),
35
- /* @__PURE__ */ e(x, { className: "max-h-60 overflow-y-auto", children: a.map(({ value: n, label: m }) => /* @__PURE__ */ e(w, { onClick: () => s(n), children: m }, n)) })
36
- ] }), E = ({
37
- displayedMonth: r,
38
- onPrevMonth: a,
39
- onNextMonth: s,
40
- onMonthChange: n,
41
- className: m
42
- }) => /* @__PURE__ */ t(
43
- "div",
44
- {
45
- "data-slot": "calendar-header",
46
- className: N("flex items-center justify-between pt-1 w-full", m),
47
- children: [
48
- /* @__PURE__ */ e(
49
- l,
50
- {
51
- variant: "ghost",
52
- size: "icon-sm",
53
- className: "size-7 rounded-md text-secondary-foreground",
54
- onClick: a,
55
- "aria-label": "Previous month",
56
- children: /* @__PURE__ */ e(h, { className: "size-4" })
57
- }
58
- ),
59
- /* @__PURE__ */ t("div", { className: "flex items-center gap-0.5", children: [
60
- /* @__PURE__ */ e(
61
- d,
62
- {
63
- label: r.format("MMMM"),
64
- items: M.map((o, f) => ({ value: f, label: o })),
65
- onSelect: (o) => n(r.date(1).month(o))
66
- }
67
- ),
68
- /* @__PURE__ */ e(
69
- d,
70
- {
71
- label: r.format("YYYY"),
72
- items: z.map((o) => ({ value: o, label: String(o) })),
73
- onSelect: (o) => n(r.date(1).year(o))
74
- }
75
- )
76
- ] }),
77
- /* @__PURE__ */ e(
78
- l,
79
- {
80
- variant: "ghost",
81
- size: "icon-sm",
82
- className: "size-7 rounded-md text-secondary-foreground",
83
- onClick: s,
84
- "aria-label": "Next month",
85
- children: /* @__PURE__ */ e(u, { className: "size-4" })
86
- }
87
- )
88
- ]
89
- }
90
- );
91
- export {
92
- E as CalendarHeader
93
- };
1
+ import { cn as e } from "../../../../../../lib/utils.js";
2
+ import { Button as t } from "../../../button/button.js";
3
+ import { DropdownMenu as n, DropdownMenuContent as r, DropdownMenuItem as i, DropdownMenuTrigger as a } from "../../../dropdown-menu/dropdown-menu.js";
4
+ import { IconChevronDown as o, IconChevronLeft as s, IconChevronRight as c } from "@tabler/icons-react";
5
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
6
+ import d from "dayjs";
7
+ //#region libs/aura/src/components/ui/core/date-time-pickers/shared/calendar-header/calendar-header.tsx
8
+ var f = Array.from({ length: 12 }, (e, t) => d().month(t).format("MMMM")), p = d().year() - 50, m = d().year() + 10, h = Array.from({ length: m - p + 1 }, (e, t) => p + t), g = ({ label: e, items: s, onSelect: c }) => /* @__PURE__ */ u(n, {
9
+ modal: !1,
10
+ children: [/* @__PURE__ */ l(a, { render: /* @__PURE__ */ u(t, {
11
+ variant: "ghost",
12
+ size: "sm",
13
+ className: "h-7 px-2 gap-1 text-sm font-medium text-secondary-foreground",
14
+ children: [e, /* @__PURE__ */ l(o, { className: "size-4" })]
15
+ }) }), /* @__PURE__ */ l(r, {
16
+ className: "max-h-60 overflow-y-auto",
17
+ children: s.map(({ value: e, label: t }) => /* @__PURE__ */ l(i, {
18
+ onClick: () => c(e),
19
+ children: t
20
+ }, e))
21
+ })]
22
+ }), _ = ({ displayedMonth: n, onPrevMonth: r, onNextMonth: i, onMonthChange: a, className: o }) => /* @__PURE__ */ u("div", {
23
+ "data-slot": "calendar-header",
24
+ className: e("flex items-center justify-between pt-1 w-full", o),
25
+ children: [
26
+ /* @__PURE__ */ l(t, {
27
+ variant: "ghost",
28
+ size: "icon-sm",
29
+ className: "size-7 rounded-md text-secondary-foreground",
30
+ onClick: r,
31
+ "aria-label": "Previous month",
32
+ children: /* @__PURE__ */ l(s, { className: "size-4" })
33
+ }),
34
+ /* @__PURE__ */ u("div", {
35
+ className: "flex items-center gap-0.5",
36
+ children: [/* @__PURE__ */ l(g, {
37
+ label: n.format("MMMM"),
38
+ items: f.map((e, t) => ({
39
+ value: t,
40
+ label: e
41
+ })),
42
+ onSelect: (e) => a(n.date(1).month(e))
43
+ }), /* @__PURE__ */ l(g, {
44
+ label: n.format("YYYY"),
45
+ items: h.map((e) => ({
46
+ value: e,
47
+ label: String(e)
48
+ })),
49
+ onSelect: (e) => a(n.date(1).year(e))
50
+ })]
51
+ }),
52
+ /* @__PURE__ */ l(t, {
53
+ variant: "ghost",
54
+ size: "icon-sm",
55
+ className: "size-7 rounded-md text-secondary-foreground",
56
+ onClick: i,
57
+ "aria-label": "Next month",
58
+ children: /* @__PURE__ */ l(c, { className: "size-4" })
59
+ })
60
+ ]
61
+ });
62
+ //#endregion
63
+ export { _ as CalendarHeader };
@@ -1,99 +1,65 @@
1
- import { jsxs as u, jsx as r } from "react/jsx-runtime";
2
- import { IconCalendarClock as A, IconClock as I, IconCalendar as y } from "@tabler/icons-react";
3
- import { cn as a } from "../../../../../../lib/utils.js";
4
- import { Input as D } from "../../../input/input.js";
5
- import { RangeInputDisplay as R } from "./range-input-display.js";
6
- const v = "Date picker", C = () => {
7
- }, p = {
8
- date: /* @__PURE__ */ r(y, { "aria-label": "date-icon", className: "size-4" }),
9
- time: /* @__PURE__ */ r(I, { "aria-label": "time-icon", className: "size-4" }),
10
- datetime: /* @__PURE__ */ r(A, { "aria-label": "datetime-icon", className: "size-4" })
11
- }, g = (e, o) => a(
12
- "absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",
13
- "flex items-center justify-center",
14
- "transition-colors duration-150",
15
- o || e ? "text-foreground" : "text-muted-foreground",
16
- "group-hover:text-foreground"
17
- ), _ = ({
18
- value: e,
19
- format: o,
20
- placeholder: b,
21
- onClick: n,
22
- isOpen: t,
23
- className: i,
24
- ariaLabel: l = v,
25
- variant: s = "date",
26
- activeRangePart: f,
27
- onRangePartClick: x,
28
- popoverId: c
29
- }) => {
30
- if (Array.isArray(e)) {
31
- const N = e[0] !== null || e[1] !== null;
32
- return /* @__PURE__ */ u(
33
- "div",
34
- {
35
- "data-slot": "date-time-input",
36
- className: a(
37
- "relative flex items-center cursor-pointer w-full group",
38
- i
39
- ),
40
- role: "combobox",
41
- "aria-label": l,
42
- "aria-expanded": t,
43
- "aria-controls": c,
44
- onClick: n,
45
- children: [
46
- /* @__PURE__ */ r(
47
- R,
48
- {
49
- startDate: e[0],
50
- endDate: e[1],
51
- format: o,
52
- activeRangePart: f,
53
- onRangePartClick: x,
54
- isOpen: t
55
- }
56
- ),
57
- /* @__PURE__ */ r("div", { className: g(t, N), children: p[s] })
58
- ]
59
- }
60
- );
61
- }
62
- const d = e?.format(o) ?? "", m = d.length > 0, h = b ?? o;
63
- return /* @__PURE__ */ u(
64
- "div",
65
- {
66
- "data-slot": "date-time-input",
67
- className: a(
68
- "relative flex items-center cursor-pointer w-full group",
69
- i
70
- ),
71
- onClick: n,
72
- children: [
73
- /* @__PURE__ */ r(
74
- D,
75
- {
76
- value: d,
77
- placeholder: h,
78
- onChange: C,
79
- "aria-label": l,
80
- "aria-expanded": t,
81
- "aria-controls": c,
82
- role: "combobox",
83
- className: a(
84
- "border-transparent bg-muted-background cursor-pointer caret-transparent pr-9",
85
- m ? "text-foreground" : "text-muted-foreground",
86
- "hover:border-border-emphasized",
87
- t && "!bg-background !text-foreground !border-border"
88
- )
89
- }
90
- ),
91
- /* @__PURE__ */ r("div", { className: g(t, m), children: p[s] })
92
- ]
93
- }
94
- );
95
- };
96
- export {
97
- v as DEFAULT_ARIA_LABEL,
98
- _ as DateTimeInput
1
+ import { cn as e } from "../../../../../../lib/utils.js";
2
+ import { Input as t } from "../../../input/input.js";
3
+ import { RangeInputDisplay as n } from "./range-input-display.js";
4
+ import { IconCalendar as r, IconCalendarClock as i, IconClock as a } from "@tabler/icons-react";
5
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
+ //#region libs/aura/src/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.tsx
7
+ var c = "Date picker", l = () => void 0, u = {
8
+ date: /* @__PURE__ */ o(r, {
9
+ "aria-label": "date-icon",
10
+ className: "size-4"
11
+ }),
12
+ time: /* @__PURE__ */ o(a, {
13
+ "aria-label": "time-icon",
14
+ className: "size-4"
15
+ }),
16
+ datetime: /* @__PURE__ */ o(i, {
17
+ "aria-label": "datetime-icon",
18
+ className: "size-4"
19
+ })
20
+ }, d = (t, n) => e("absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none", "flex items-center justify-center", "transition-colors duration-150", n || t ? "text-foreground" : "text-muted-foreground", "group-hover:text-foreground"), f = ({ value: r, format: i, placeholder: a, onClick: f, isOpen: p, className: m, ariaLabel: h = c, variant: g = "date", activeRangePart: _, onRangePartClick: v, popoverId: y }) => {
21
+ if (Array.isArray(r)) {
22
+ let t = r[0] !== null || r[1] !== null;
23
+ return /* @__PURE__ */ s("div", {
24
+ "data-slot": "date-time-input",
25
+ className: e("relative flex items-center cursor-pointer w-full group", m),
26
+ role: "combobox",
27
+ "aria-label": h,
28
+ "aria-expanded": p,
29
+ "aria-controls": y,
30
+ onClick: f,
31
+ children: [/* @__PURE__ */ o(n, {
32
+ startDate: r[0],
33
+ endDate: r[1],
34
+ format: i,
35
+ activeRangePart: _,
36
+ onRangePartClick: v,
37
+ isOpen: p
38
+ }), /* @__PURE__ */ o("div", {
39
+ className: d(p, t),
40
+ children: u[g]
41
+ })]
42
+ });
43
+ }
44
+ let b = r?.format(i) ?? "", x = b.length > 0, S = a ?? i;
45
+ return /* @__PURE__ */ s("div", {
46
+ "data-slot": "date-time-input",
47
+ className: e("relative flex items-center cursor-pointer w-full group", m),
48
+ onClick: f,
49
+ children: [/* @__PURE__ */ o(t, {
50
+ value: b,
51
+ placeholder: S,
52
+ onChange: l,
53
+ "aria-label": h,
54
+ "aria-expanded": p,
55
+ "aria-controls": y,
56
+ role: "combobox",
57
+ className: e("border-transparent bg-muted-background cursor-pointer caret-transparent pr-9", x ? "text-foreground" : "text-muted-foreground", "hover:border-border-emphasized", p && "!bg-background !text-foreground !border-border")
58
+ }), /* @__PURE__ */ o("div", {
59
+ className: d(p, x),
60
+ children: u[g]
61
+ })]
62
+ });
99
63
  };
64
+ //#endregion
65
+ export { c as DEFAULT_ARIA_LABEL, f as DateTimeInput };
@@ -1,68 +1,39 @@
1
- import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
- import { cn as n } from "../../../../../../lib/utils.js";
3
- const a = "px-1 py-0.5 rounded-sm transition-colors duration-150", i = "text-muted-foreground group-hover:text-foreground transition-colors duration-150", x = ({
4
- startDate: d,
5
- endDate: t,
6
- format: e,
7
- activeRangePart: s,
8
- onRangePartClick: r,
9
- isOpen: l
10
- }) => {
11
- const u = d !== null || t !== null, c = (b) => (g) => {
12
- r && (g.stopPropagation(), r(b));
13
- };
14
- return /* @__PURE__ */ p(
15
- "div",
16
- {
17
- className: n(
18
- "flex items-center w-full py-1 px-3 pr-9 border rounded-lg",
19
- "text-sm leading-5 h-9 box-border whitespace-nowrap overflow-hidden",
20
- "transition-[background,border-color,color,box-shadow] duration-150",
21
- l ? "bg-background text-foreground border-border shadow-focus-ring" : [
22
- "bg-muted-background border-transparent",
23
- "hover:bg-accent-background hover:text-foreground hover:border-border-emphasized",
24
- u ? "text-foreground" : "text-muted-foreground"
25
- ]
26
- ),
27
- children: [
28
- /* @__PURE__ */ o(
29
- "span",
30
- {
31
- className: n(
32
- a,
33
- r ? "cursor-pointer" : "cursor-default",
34
- s === "start" ? "bg-active-muted-background" : r && "hover:bg-active-muted-background-hover"
35
- ),
36
- onClick: c("start"),
37
- children: d ? d.format(e) : /* @__PURE__ */ o("span", { className: i, children: e })
38
- }
39
- ),
40
- /* @__PURE__ */ o(
41
- "span",
42
- {
43
- className: n(
44
- "select-none transition-colors duration-150",
45
- u ? "text-foreground" : "text-muted-foreground group-hover:text-foreground"
46
- ),
47
- children: " – "
48
- }
49
- ),
50
- /* @__PURE__ */ o(
51
- "span",
52
- {
53
- className: n(
54
- a,
55
- r ? "cursor-pointer" : "cursor-default",
56
- s === "end" ? "bg-active-muted-background" : r && "hover:bg-active-muted-background-hover"
57
- ),
58
- onClick: c("end"),
59
- children: t ? t.format(e) : /* @__PURE__ */ o("span", { className: i, children: e })
60
- }
61
- )
62
- ]
63
- }
64
- );
65
- };
66
- export {
67
- x as RangeInputDisplay
1
+ import { cn as e } from "../../../../../../lib/utils.js";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ //#region libs/aura/src/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.tsx
4
+ var r = "px-1 py-0.5 rounded-sm transition-colors duration-150", i = "text-muted-foreground group-hover:text-foreground transition-colors duration-150", a = ({ startDate: a, endDate: o, format: s, activeRangePart: c, onRangePartClick: l, isOpen: u }) => {
5
+ let d = a !== null || o !== null, f = (e) => (t) => {
6
+ l && (t.stopPropagation(), l(e));
7
+ };
8
+ return /* @__PURE__ */ n("div", {
9
+ className: e("flex items-center w-full py-1 px-3 pr-9 border rounded-lg", "text-sm leading-5 h-9 box-border whitespace-nowrap overflow-hidden", "transition-[background,border-color,color,box-shadow] duration-150", u ? "bg-background text-foreground border-border shadow-focus-ring" : [
10
+ "bg-muted-background border-transparent",
11
+ "hover:bg-accent-background hover:text-foreground hover:border-border-emphasized",
12
+ d ? "text-foreground" : "text-muted-foreground"
13
+ ]),
14
+ children: [
15
+ /* @__PURE__ */ t("span", {
16
+ className: e(r, l ? "cursor-pointer" : "cursor-default", c === "start" ? "bg-active-muted-background" : l && "hover:bg-active-muted-background-hover"),
17
+ onClick: f("start"),
18
+ children: a ? a.format(s) : /* @__PURE__ */ t("span", {
19
+ className: i,
20
+ children: s
21
+ })
22
+ }),
23
+ /* @__PURE__ */ t("span", {
24
+ className: e("select-none transition-colors duration-150", d ? "text-foreground" : "text-muted-foreground group-hover:text-foreground"),
25
+ children: " – "
26
+ }),
27
+ /* @__PURE__ */ t("span", {
28
+ className: e(r, l ? "cursor-pointer" : "cursor-default", c === "end" ? "bg-active-muted-background" : l && "hover:bg-active-muted-background-hover"),
29
+ onClick: f("end"),
30
+ children: o ? o.format(s) : /* @__PURE__ */ t("span", {
31
+ className: i,
32
+ children: s
33
+ })
34
+ })
35
+ ]
36
+ });
68
37
  };
38
+ //#endregion
39
+ export { a as RangeInputDisplay };
@@ -1,24 +1,24 @@
1
- import { useState as f, useRef as c, useEffect as p } from "react";
2
- const m = (r = {}) => {
3
- const { onBackspace: t } = r, [n, a] = f(!1), u = c(null), i = c(null);
4
- return p(() => {
5
- if (!n) return;
6
- const s = (o) => {
7
- if (o.key === "Backspace" && t) {
8
- const { target: e } = o;
9
- e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLElement && e.isContentEditable || (o.preventDefault(), t());
10
- }
11
- };
12
- return document.addEventListener("keydown", s), () => {
13
- document.removeEventListener("keydown", s);
14
- };
15
- }, [n, t]), {
16
- isOpen: n,
17
- setIsOpen: a,
18
- popoverRef: u,
19
- inputRef: i
20
- };
21
- };
22
- export {
23
- m as usePopoverState
1
+ import { useEffect as e, useRef as t, useState as n } from "react";
2
+ //#region libs/aura/src/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.ts
3
+ var r = (r = {}) => {
4
+ let { onBackspace: i } = r, [a, o] = n(!1), s = t(null), c = t(null);
5
+ return e(() => {
6
+ if (!a) return;
7
+ let e = (e) => {
8
+ if (e.key === "Backspace" && i) {
9
+ let { target: t } = e;
10
+ t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLElement && t.isContentEditable || (e.preventDefault(), i());
11
+ }
12
+ };
13
+ return document.addEventListener("keydown", e), () => {
14
+ document.removeEventListener("keydown", e);
15
+ };
16
+ }, [a, i]), {
17
+ isOpen: a,
18
+ setIsOpen: o,
19
+ popoverRef: s,
20
+ inputRef: c
21
+ };
24
22
  };
23
+ //#endregion
24
+ export { r as usePopoverState };
@@ -1,63 +1,53 @@
1
- import { useCallback as e, useState as u, useRef as b } from "react";
2
- const A = ({
3
- value: c,
4
- defaultDate: p,
5
- mapDate: a,
6
- onEndDateSelected: S
7
- }) => {
8
- const o = e(
9
- (t, m) => a ? a(t, m) : t,
10
- [a]
11
- ), [E, f] = u(c[0]), [y, M] = u(c[1]), [g, i] = u(
12
- () => c[0] ?? p
13
- ), [C, l] = u(null), n = b({
14
- tempStart: c[0],
15
- tempEnd: c[1]
16
- }), s = e((t) => {
17
- n.current.tempStart = t, f(t);
18
- }, []), r = e((t) => {
19
- n.current.tempEnd = t, M(t);
20
- }, []), R = e(
21
- (t, m) => {
22
- if (m === "start") {
23
- s(o(t, "start")), r(null), l(null);
24
- return;
25
- }
26
- const d = n.current.tempStart;
27
- if (d && t.isBefore(d, "day")) {
28
- s(o(t, "start")), r(null), l(null);
29
- return;
30
- }
31
- const h = o(t, "end");
32
- r(h), l(null), S?.(n.current.tempStart, h);
33
- },
34
- [o, s, r, S]
35
- ), k = e((t) => {
36
- l(t);
37
- }, []), D = e((t) => {
38
- i(t);
39
- }, []), H = e(
40
- (t) => t === "start" ? (s(null), [null, n.current.tempEnd]) : n.current.tempEnd === null ? null : (r(null), [n.current.tempStart, null]),
41
- [s, r]
42
- ), T = e(
43
- (t) => {
44
- s(t[0]), r(t[1]), l(null), i(t[0] ?? p);
45
- },
46
- [s, r, p]
47
- );
48
- return {
49
- tempStart: E,
50
- tempEnd: y,
51
- displayedMonth: g,
52
- hoverDate: C,
53
- stateRef: n,
54
- handleDateClick: R,
55
- handleDateHover: k,
56
- handleMonthChange: D,
57
- clearActiveSegment: H,
58
- resetDates: T
59
- };
60
- };
61
- export {
62
- A as useRangeDateState
1
+ import { useCallback as e, useRef as t, useState as n } from "react";
2
+ //#region libs/aura/src/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.ts
3
+ var r = ({ value: r, defaultDate: i, mapDate: a, onEndDateSelected: o }) => {
4
+ let s = e((e, t) => a ? a(e, t) : e, [a]), [c, l] = n(r[0]), [u, d] = n(r[1]), [f, p] = n(() => r[0] ?? i), [m, h] = n(null), g = t({
5
+ tempStart: r[0],
6
+ tempEnd: r[1]
7
+ }), _ = e((e) => {
8
+ g.current.tempStart = e, l(e);
9
+ }, []), v = e((e) => {
10
+ g.current.tempEnd = e, d(e);
11
+ }, []);
12
+ return {
13
+ tempStart: c,
14
+ tempEnd: u,
15
+ displayedMonth: f,
16
+ hoverDate: m,
17
+ stateRef: g,
18
+ handleDateClick: e((e, t) => {
19
+ if (t === "start") {
20
+ _(s(e, "start")), v(null), h(null);
21
+ return;
22
+ }
23
+ let n = g.current.tempStart;
24
+ if (n && e.isBefore(n, "day")) {
25
+ _(s(e, "start")), v(null), h(null);
26
+ return;
27
+ }
28
+ let r = s(e, "end");
29
+ v(r), h(null), o?.(g.current.tempStart, r);
30
+ }, [
31
+ s,
32
+ _,
33
+ v,
34
+ o
35
+ ]),
36
+ handleDateHover: e((e) => {
37
+ h(e);
38
+ }, []),
39
+ handleMonthChange: e((e) => {
40
+ p(e);
41
+ }, []),
42
+ clearActiveSegment: e((e) => e === "start" ? (_(null), [null, g.current.tempEnd]) : g.current.tempEnd === null ? null : (v(null), [g.current.tempStart, null]), [_, v]),
43
+ resetDates: e((e) => {
44
+ _(e[0]), v(e[1]), h(null), p(e[0] ?? i);
45
+ }, [
46
+ _,
47
+ v,
48
+ i
49
+ ])
50
+ };
63
51
  };
52
+ //#endregion
53
+ export { r as useRangeDateState };
@@ -1,19 +1,19 @@
1
- import { useState as o, useCallback as e } from "react";
2
- const p = () => {
3
- const [s, t] = o("start"), a = e(() => {
4
- t("end");
5
- }, []), n = e(() => {
6
- t("start");
7
- }, []), r = e(() => {
8
- t("start");
9
- }, []);
10
- return {
11
- step: s,
12
- handleNext: a,
13
- handleBack: n,
14
- resetStep: r
15
- };
16
- };
17
- export {
18
- p as useRangeStepManager
1
+ import { useCallback as e, useState as t } from "react";
2
+ //#region libs/aura/src/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.ts
3
+ var n = () => {
4
+ let [n, r] = t("start");
5
+ return {
6
+ step: n,
7
+ handleNext: e(() => {
8
+ r("end");
9
+ }, []),
10
+ handleBack: e(() => {
11
+ r("start");
12
+ }, []),
13
+ resetStep: e(() => {
14
+ r("start");
15
+ }, [])
16
+ };
19
17
  };
18
+ //#endregion
19
+ export { n as useRangeStepManager };