@cognite/aura 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +2243 -729
- package/README.md +133 -11
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.js +183 -176
- package/dist/components/ui/core/action-toolbar/action-toolbar.js +4 -4
- package/dist/components/ui/core/alert/alert.js +3 -3
- package/dist/components/ui/core/banner/banner.js +6 -6
- package/dist/components/ui/core/button/button.js +4 -4
- package/dist/components/ui/core/checkbox/checkbox.js +8 -8
- package/dist/components/ui/core/code-block/code-block.js +6 -6
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.d.ts +15 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +73 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +17 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +52 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +64 -75
- package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +1 -2
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +51 -64
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +146 -161
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +1 -2
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +124 -137
- package/dist/components/ui/core/date-time-pickers/index.d.ts +4 -0
- package/dist/components/ui/core/date-time-pickers/index.js +10 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +8 -8
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.d.ts +1 -1
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +1 -1
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.d.ts +0 -2
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +18 -34
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.d.ts +23 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +32 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.d.ts +2 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +19 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +41 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.d.ts +16 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +100 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +23 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +64 -0
- package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +3 -3
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +1 -1
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +17 -15
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +83 -85
- package/dist/components/ui/core/hover-card/hover-card.js +3 -3
- package/dist/components/ui/core/input/input.js +1 -1
- package/dist/components/ui/core/message/message.js +387 -101
- package/dist/components/ui/core/pagination/pagination.js +9 -7
- package/dist/components/ui/core/prompt-input/prompt-input.js +16 -16
- package/dist/components/ui/core/radio-group/radio-group.js +7 -7
- package/dist/components/ui/core/reasoning/reasoning.js +1 -1
- package/dist/components/ui/core/segmented-control/segmented-control.js +3 -3
- package/dist/components/ui/core/select/select.d.ts +2 -1
- package/dist/components/ui/core/select/select.js +134 -110
- package/dist/components/ui/core/shimmer/shimmer.d.ts +3 -1
- package/dist/components/ui/core/shimmer/shimmer.js +89 -49
- package/dist/components/ui/core/tabs/tabs.js +3 -3
- package/dist/components/ui/core/textarea/textarea.js +1 -1
- package/dist/components/ui/core/toggle/toggle.d.ts +15 -0
- package/dist/components/ui/core/toggle/toggle.js +74 -0
- package/dist/components/ui/core/tool/tool.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/lib/portal-container-context.js +3 -3
- package/dist/lib/use-controllable-state.js +17 -17
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +7 -7
- package/dist/styles.css +1 -1
- package/dist/styles.source.css +3 -0
- package/package.json +200 -18
- package/dist/index.js +0 -308
|
@@ -3,7 +3,7 @@ import { forwardRef as r } from "react";
|
|
|
3
3
|
import { Checkbox as i } from "@base-ui/react/checkbox";
|
|
4
4
|
import { IconCheck as l, IconMinus as b } from "@tabler/icons-react";
|
|
5
5
|
import { cva as m } from "class-variance-authority";
|
|
6
|
-
import { cn as d,
|
|
6
|
+
import { cn as d, selectionItemBase as h, selectionItemCard as k, selectionItemDefault as u, invalidState as x, focusState as p, selectionItemLabel as g, selectionItemDescription as f } from "../../../../lib/utils.js";
|
|
7
7
|
const I = r(
|
|
8
8
|
({ className: a, orientation: e = "vertical", role: t = "group", ...c }, n) => /* @__PURE__ */ o(
|
|
9
9
|
"div",
|
|
@@ -21,11 +21,11 @@ const I = r(
|
|
|
21
21
|
)
|
|
22
22
|
);
|
|
23
23
|
I.displayName = "CheckboxGroup";
|
|
24
|
-
const C = m(d("group/checkbox-item",
|
|
24
|
+
const C = m(d("group/checkbox-item", h), {
|
|
25
25
|
variants: {
|
|
26
26
|
variant: {
|
|
27
|
-
default:
|
|
28
|
-
card:
|
|
27
|
+
default: u,
|
|
28
|
+
card: k
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
defaultVariants: {
|
|
@@ -55,8 +55,8 @@ const N = r(({ className: a, ...e }, t) => /* @__PURE__ */ o(
|
|
|
55
55
|
"data-unchecked:not-data-disabled:hover:border-secondary-foreground group-hover/checkbox-item:data-unchecked:not-data-disabled:border-secondary-foreground",
|
|
56
56
|
"data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:border-transparent data-disabled:bg-disabled-background data-disabled:text-disabled-foreground data-disabled:data-unchecked:border-border",
|
|
57
57
|
"[&[data-checked]_[data-slot=checkbox-check]]:block [&[data-indeterminate]_[data-slot=checkbox-dash]]:block",
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
p,
|
|
59
|
+
x,
|
|
60
60
|
a
|
|
61
61
|
),
|
|
62
62
|
...e,
|
|
@@ -97,7 +97,7 @@ const y = r(
|
|
|
97
97
|
ref: t,
|
|
98
98
|
"data-slot": "checkbox-item-label",
|
|
99
99
|
className: d(
|
|
100
|
-
|
|
100
|
+
g,
|
|
101
101
|
"group-has-[[data-checked]]/checkbox-item:text-foreground",
|
|
102
102
|
"group-has-[[data-indeterminate]]/checkbox-item:text-foreground",
|
|
103
103
|
"group-has-[[data-disabled]]/checkbox-item:text-disabled-foreground",
|
|
@@ -115,7 +115,7 @@ const z = r(
|
|
|
115
115
|
ref: t,
|
|
116
116
|
"data-slot": "checkbox-item-description",
|
|
117
117
|
className: d(
|
|
118
|
-
|
|
118
|
+
f,
|
|
119
119
|
"group-has-[[data-disabled]]/checkbox-item:text-disabled-foreground",
|
|
120
120
|
a
|
|
121
121
|
),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as L, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as w, useState as x, useMemo as D, useEffect as
|
|
3
|
-
import {
|
|
2
|
+
import { createContext as F, forwardRef as w, useState as x, useMemo as D, useEffect as O, useContext as H } from "react";
|
|
3
|
+
import { IconCheck as K, IconCopy as V, IconSelector as $, IconDownload as q } from "@tabler/icons-react";
|
|
4
4
|
import { isStorybookTestEnv as v, highlightCode as M, cn as f } from "../../../../lib/utils.js";
|
|
5
5
|
import { Button as S } from "../button/button.js";
|
|
6
|
-
const I =
|
|
6
|
+
const I = F({
|
|
7
7
|
code: "",
|
|
8
8
|
copyText: "",
|
|
9
9
|
isCollapsed: !1,
|
|
@@ -48,7 +48,7 @@ const ee = "min(60vh, 32rem)", oe = "dark:hidden [&>pre]:m-0 [&>pre]:min-h-10 [&
|
|
|
48
48
|
() => v ? `<pre><code>${P(s)}</code></pre>` : "",
|
|
49
49
|
[s]
|
|
50
50
|
);
|
|
51
|
-
|
|
51
|
+
O(() => {
|
|
52
52
|
if (v) return;
|
|
53
53
|
let g = !1;
|
|
54
54
|
const B = (u) => {
|
|
@@ -183,7 +183,7 @@ const re = w(
|
|
|
183
183
|
c instanceof Error ? c : new Error("Clipboard write failed")
|
|
184
184
|
);
|
|
185
185
|
}
|
|
186
|
-
}, p = C ?
|
|
186
|
+
}, p = C ? K : V;
|
|
187
187
|
return /* @__PURE__ */ r(
|
|
188
188
|
S,
|
|
189
189
|
{
|
|
@@ -213,7 +213,7 @@ const le = w(
|
|
|
213
213
|
size: "icon-sm",
|
|
214
214
|
variant: "secondary",
|
|
215
215
|
...n,
|
|
216
|
-
children: e ?? /* @__PURE__ */ r(
|
|
216
|
+
children: e ?? /* @__PURE__ */ r($, { size: 14 })
|
|
217
217
|
}
|
|
218
218
|
);
|
|
219
219
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Dayjs } from 'dayjs';
|
|
3
|
+
import { ShortcutItem } from '../shared/shortcuts-panel/shortcuts-panel';
|
|
4
|
+
export type { ShortcutItem };
|
|
5
|
+
export interface DatePickerProps {
|
|
6
|
+
value: Dayjs | null;
|
|
7
|
+
onChange: (date: Dayjs | null) => void;
|
|
8
|
+
format?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
displayWeekNumber?: boolean;
|
|
11
|
+
shortcuts?: ShortcutItem[];
|
|
12
|
+
defaultDate?: Dayjs;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare const DatePicker: FC<DatePickerProps>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { cn as k } from "../../../../../lib/utils.js";
|
|
3
|
+
import { Popover as x, PopoverTrigger as P, PopoverContent as M } from "../../popover/popover.js";
|
|
4
|
+
import { Calendar as N } from "../shared/calendar/calendar.js";
|
|
5
|
+
import { DateTimeInput as w } from "../shared/date-time-input/date-time-input.js";
|
|
6
|
+
import { ShortcutsPanel as R } from "../shared/shortcuts-panel/shortcuts-panel.js";
|
|
7
|
+
import { useDatePicker as S } from "./use-date-picker.js";
|
|
8
|
+
const Y = (n) => n ? [n, n] : [null, null], V = ({
|
|
9
|
+
value: n,
|
|
10
|
+
onChange: r,
|
|
11
|
+
format: i = "DD/MM/YYYY",
|
|
12
|
+
placeholder: p,
|
|
13
|
+
displayWeekNumber: c = !1,
|
|
14
|
+
shortcuts: t,
|
|
15
|
+
defaultDate: d,
|
|
16
|
+
className: s
|
|
17
|
+
}) => {
|
|
18
|
+
const {
|
|
19
|
+
isOpen: o,
|
|
20
|
+
displayedMonth: m,
|
|
21
|
+
tempDate: a,
|
|
22
|
+
handleOpenChange: h,
|
|
23
|
+
handleDateClick: f,
|
|
24
|
+
handleMonthChange: u,
|
|
25
|
+
handleApplyShortcut: v,
|
|
26
|
+
inputRef: g,
|
|
27
|
+
popoverRef: C
|
|
28
|
+
} = S({ value: n, onChange: r, defaultDate: d }), D = o ? a : n;
|
|
29
|
+
return /* @__PURE__ */ e("div", { "data-slot": "date-picker", className: k("relative w-full", s), children: /* @__PURE__ */ l(x, { open: o, onOpenChange: h, children: [
|
|
30
|
+
/* @__PURE__ */ e(P, { render: /* @__PURE__ */ e("div", { ref: g, className: "w-full" }), children: /* @__PURE__ */ e(
|
|
31
|
+
w,
|
|
32
|
+
{
|
|
33
|
+
value: D,
|
|
34
|
+
format: i,
|
|
35
|
+
placeholder: p,
|
|
36
|
+
isOpen: o,
|
|
37
|
+
variant: "date"
|
|
38
|
+
}
|
|
39
|
+
) }),
|
|
40
|
+
/* @__PURE__ */ e(
|
|
41
|
+
M,
|
|
42
|
+
{
|
|
43
|
+
ref: C,
|
|
44
|
+
className: "rounded-xl w-auto p-0",
|
|
45
|
+
side: "bottom",
|
|
46
|
+
align: "start",
|
|
47
|
+
children: /* @__PURE__ */ l("div", { "data-slot": "date-picker-content", className: "flex flex-row", children: [
|
|
48
|
+
t && t.length > 0 && /* @__PURE__ */ e(
|
|
49
|
+
R,
|
|
50
|
+
{
|
|
51
|
+
shortcuts: t,
|
|
52
|
+
onShortcutClick: v
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ e("div", { className: "p-3", children: /* @__PURE__ */ e(
|
|
56
|
+
N,
|
|
57
|
+
{
|
|
58
|
+
displayedMonth: m,
|
|
59
|
+
selectedRange: Y(a),
|
|
60
|
+
hoverDate: null,
|
|
61
|
+
displayWeekNumber: c,
|
|
62
|
+
onDateClick: f,
|
|
63
|
+
onMonthChange: u
|
|
64
|
+
}
|
|
65
|
+
) })
|
|
66
|
+
] })
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
] }) });
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
V as DatePicker
|
|
73
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Dayjs } from 'dayjs';
|
|
2
|
+
export interface UseDatePickerProps {
|
|
3
|
+
value: Dayjs | null;
|
|
4
|
+
onChange: (date: Dayjs | null) => void;
|
|
5
|
+
defaultDate?: Dayjs;
|
|
6
|
+
}
|
|
7
|
+
export interface UseDatePickerReturn {
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
displayedMonth: Dayjs;
|
|
10
|
+
tempDate: Dayjs | null;
|
|
11
|
+
handleOpenChange: (open: boolean) => void;
|
|
12
|
+
handleDateClick: (date: Dayjs) => void;
|
|
13
|
+
handleMonthChange: (month: Dayjs) => void;
|
|
14
|
+
handleApplyShortcut: (shortcutValue: Dayjs | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null]) => void;
|
|
15
|
+
inputRef: React.RefObject<HTMLDivElement>;
|
|
16
|
+
popoverRef: React.RefObject<HTMLDivElement>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useRef as y, useCallback as A, useEffect as O } from "react";
|
|
2
|
+
import R from "dayjs";
|
|
3
|
+
import { usePopoverState as B } from "../shared/hooks/use-popover-state.js";
|
|
4
|
+
import { useSingleDateState as C } from "../shared/hooks/use-single-date-state.js";
|
|
5
|
+
const x = ({
|
|
6
|
+
value: n,
|
|
7
|
+
onChange: t,
|
|
8
|
+
defaultDate: o = R()
|
|
9
|
+
}) => {
|
|
10
|
+
const s = y(() => {
|
|
11
|
+
}), { isOpen: r, setIsOpen: a, popoverRef: c, inputRef: p } = B({
|
|
12
|
+
onBackspace: A(() => s.current(), [])
|
|
13
|
+
}), l = C({
|
|
14
|
+
value: n,
|
|
15
|
+
defaultDate: o,
|
|
16
|
+
onDateSelected: (e) => {
|
|
17
|
+
t(e), a(!1);
|
|
18
|
+
}
|
|
19
|
+
}), {
|
|
20
|
+
tempDate: d,
|
|
21
|
+
displayedMonth: f,
|
|
22
|
+
handleDateClick: i,
|
|
23
|
+
handleMonthChange: h,
|
|
24
|
+
clearDate: m,
|
|
25
|
+
resetDate: u
|
|
26
|
+
} = l, D = () => {
|
|
27
|
+
u(n);
|
|
28
|
+
}, S = () => {
|
|
29
|
+
m() && t(null);
|
|
30
|
+
};
|
|
31
|
+
return O(() => {
|
|
32
|
+
s.current = S;
|
|
33
|
+
}), {
|
|
34
|
+
isOpen: r,
|
|
35
|
+
displayedMonth: f,
|
|
36
|
+
tempDate: d,
|
|
37
|
+
handleOpenChange: (e) => {
|
|
38
|
+
D(), a(e);
|
|
39
|
+
},
|
|
40
|
+
handleDateClick: i,
|
|
41
|
+
handleMonthChange: h,
|
|
42
|
+
handleApplyShortcut: (e) => {
|
|
43
|
+
const k = Array.isArray(e) ? e[0] : e;
|
|
44
|
+
t(k), a(!1);
|
|
45
|
+
},
|
|
46
|
+
inputRef: p,
|
|
47
|
+
popoverRef: c
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
x as useDatePicker
|
|
52
|
+
};
|
|
@@ -1,99 +1,88 @@
|
|
|
1
1
|
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
|
2
|
-
import { cn as
|
|
3
|
-
import { Popover as
|
|
4
|
-
import { Calendar as
|
|
5
|
-
import { DateTimeInput as
|
|
6
|
-
import { ShortcutsPanel as
|
|
7
|
-
import { useDateRangePicker as
|
|
8
|
-
const
|
|
9
|
-
value:
|
|
2
|
+
import { cn as S } from "../../../../../lib/utils.js";
|
|
3
|
+
import { Popover as M, PopoverTrigger as N, PopoverContent as w } from "../../popover/popover.js";
|
|
4
|
+
import { Calendar as Y } from "../shared/calendar/calendar.js";
|
|
5
|
+
import { DateTimeInput as O } from "../shared/date-time-input/date-time-input.js";
|
|
6
|
+
import { ShortcutsPanel as j } from "../shared/shortcuts-panel/shortcuts-panel.js";
|
|
7
|
+
import { useDateRangePicker as y } from "./use-date-range-picker.js";
|
|
8
|
+
const z = ({
|
|
9
|
+
value: n,
|
|
10
10
|
onChange: d,
|
|
11
11
|
format: p = "DD/MM/YYYY",
|
|
12
12
|
placeholder: c,
|
|
13
13
|
displayWeekNumber: h = !1,
|
|
14
|
-
shortcuts:
|
|
14
|
+
shortcuts: t,
|
|
15
15
|
defaultDate: m,
|
|
16
16
|
className: s
|
|
17
17
|
}) => {
|
|
18
18
|
const {
|
|
19
19
|
isOpen: a,
|
|
20
|
-
step:
|
|
20
|
+
step: r,
|
|
21
21
|
displayedMonth: v,
|
|
22
|
-
tempStart:
|
|
22
|
+
tempStart: o,
|
|
23
23
|
tempEnd: l,
|
|
24
24
|
hoverDate: f,
|
|
25
|
-
|
|
26
|
-
handleCancel: C,
|
|
25
|
+
handleOpenChange: g,
|
|
27
26
|
handleDateClick: D,
|
|
28
27
|
handleMonthChange: u,
|
|
29
|
-
handleDateHover:
|
|
30
|
-
handleSetStep:
|
|
31
|
-
handleApplyShortcut:
|
|
32
|
-
inputRef:
|
|
33
|
-
popoverRef:
|
|
34
|
-
} =
|
|
28
|
+
handleDateHover: C,
|
|
29
|
+
handleSetStep: k,
|
|
30
|
+
handleApplyShortcut: P,
|
|
31
|
+
inputRef: R,
|
|
32
|
+
popoverRef: x
|
|
33
|
+
} = y({ value: n, onChange: d, defaultDate: m });
|
|
35
34
|
return /* @__PURE__ */ e(
|
|
36
35
|
"div",
|
|
37
36
|
{
|
|
38
37
|
"data-slot": "date-range-picker",
|
|
39
|
-
className:
|
|
40
|
-
children: /* @__PURE__ */ i(
|
|
41
|
-
w,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
onMonthChange: u,
|
|
85
|
-
onDateHover: k
|
|
86
|
-
}
|
|
87
|
-
) })
|
|
88
|
-
] })
|
|
89
|
-
}
|
|
90
|
-
)
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
)
|
|
38
|
+
className: S("relative w-full", s),
|
|
39
|
+
children: /* @__PURE__ */ i(M, { open: a, onOpenChange: g, children: [
|
|
40
|
+
/* @__PURE__ */ e(N, { render: /* @__PURE__ */ e("div", { ref: R, className: "w-full" }), children: /* @__PURE__ */ e(
|
|
41
|
+
O,
|
|
42
|
+
{
|
|
43
|
+
value: a ? [o, l] : n,
|
|
44
|
+
format: p,
|
|
45
|
+
placeholder: c,
|
|
46
|
+
isOpen: a,
|
|
47
|
+
variant: "date",
|
|
48
|
+
activeRangePart: a ? r : void 0,
|
|
49
|
+
onRangePartClick: a ? k : void 0
|
|
50
|
+
}
|
|
51
|
+
) }),
|
|
52
|
+
/* @__PURE__ */ e(
|
|
53
|
+
w,
|
|
54
|
+
{
|
|
55
|
+
ref: x,
|
|
56
|
+
className: "rounded-xl w-auto p-0",
|
|
57
|
+
side: "bottom",
|
|
58
|
+
align: "start",
|
|
59
|
+
children: /* @__PURE__ */ i("div", { "data-slot": "date-range-picker-content", className: "flex flex-row", children: [
|
|
60
|
+
t && t.length > 0 && /* @__PURE__ */ e(
|
|
61
|
+
j,
|
|
62
|
+
{
|
|
63
|
+
shortcuts: t,
|
|
64
|
+
onShortcutClick: P
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ e("div", { className: "p-3", children: /* @__PURE__ */ e(
|
|
68
|
+
Y,
|
|
69
|
+
{
|
|
70
|
+
displayedMonth: v,
|
|
71
|
+
selectedRange: [o, l],
|
|
72
|
+
hoverDate: r === "end" ? f : null,
|
|
73
|
+
displayWeekNumber: h,
|
|
74
|
+
onDateClick: D,
|
|
75
|
+
onMonthChange: u,
|
|
76
|
+
onDateHover: C
|
|
77
|
+
}
|
|
78
|
+
) })
|
|
79
|
+
] })
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
] })
|
|
94
83
|
}
|
|
95
84
|
);
|
|
96
85
|
};
|
|
97
86
|
export {
|
|
98
|
-
|
|
87
|
+
z as DateRangePicker
|
|
99
88
|
};
|
|
@@ -13,8 +13,7 @@ export interface UseDateRangePickerReturn {
|
|
|
13
13
|
tempStart: Dayjs | null;
|
|
14
14
|
tempEnd: Dayjs | null;
|
|
15
15
|
hoverDate: Dayjs | null;
|
|
16
|
-
|
|
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;
|
package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js
CHANGED
|
@@ -1,82 +1,69 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import
|
|
3
|
-
import { usePopoverState as
|
|
4
|
-
import { useRangeDateState as
|
|
5
|
-
import { useRangeStepManager as
|
|
6
|
-
const
|
|
1
|
+
import { useRef as E, useCallback as c, useEffect as x } from "react";
|
|
2
|
+
import P from "dayjs";
|
|
3
|
+
import { usePopoverState as b } from "../shared/hooks/use-popover-state.js";
|
|
4
|
+
import { useRangeDateState as j } from "../shared/hooks/use-range-date-state.js";
|
|
5
|
+
import { useRangeStepManager as H } from "../shared/hooks/use-range-step-manager.js";
|
|
6
|
+
const L = ({
|
|
7
7
|
value: r,
|
|
8
8
|
onChange: t,
|
|
9
|
-
defaultDate:
|
|
9
|
+
defaultDate: S = P()
|
|
10
10
|
}) => {
|
|
11
|
-
const
|
|
12
|
-
}),
|
|
13
|
-
|
|
14
|
-
|
|
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({
|
|
11
|
+
const p = E(() => {
|
|
12
|
+
}), { isOpen: m, setIsOpen: s, popoverRef: u, inputRef: k } = b({
|
|
13
|
+
onBackspace: c(() => p.current(), [])
|
|
14
|
+
}), D = H(), { step: n, handleBack: o, handleNext: d, resetStep: a } = D, R = j({
|
|
23
15
|
value: r,
|
|
24
|
-
defaultDate:
|
|
25
|
-
onEndDateSelected:
|
|
26
|
-
(e,
|
|
27
|
-
t([e,
|
|
16
|
+
defaultDate: S,
|
|
17
|
+
onEndDateSelected: c(
|
|
18
|
+
(e, l) => {
|
|
19
|
+
t([e, l]), s(!1), a();
|
|
28
20
|
},
|
|
29
|
-
[t,
|
|
21
|
+
[t, s, a]
|
|
30
22
|
)
|
|
31
23
|
}), {
|
|
32
|
-
tempStart:
|
|
33
|
-
tempEnd:
|
|
34
|
-
displayedMonth:
|
|
35
|
-
hoverDate:
|
|
36
|
-
handleDateClick:
|
|
37
|
-
handleDateHover:
|
|
38
|
-
handleMonthChange:
|
|
39
|
-
clearActiveSegment:
|
|
40
|
-
resetDates:
|
|
41
|
-
} =
|
|
42
|
-
|
|
43
|
-
}, [
|
|
44
|
-
const e =
|
|
45
|
-
e === null ?
|
|
46
|
-
}, [
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
}, [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
handleTogglePopover: () => {
|
|
59
|
-
i || l(), y();
|
|
60
|
-
},
|
|
61
|
-
handleCancel: () => {
|
|
62
|
-
l(), a(!1);
|
|
24
|
+
tempStart: y,
|
|
25
|
+
tempEnd: A,
|
|
26
|
+
displayedMonth: B,
|
|
27
|
+
hoverDate: C,
|
|
28
|
+
handleDateClick: M,
|
|
29
|
+
handleDateHover: O,
|
|
30
|
+
handleMonthChange: g,
|
|
31
|
+
clearActiveSegment: i,
|
|
32
|
+
resetDates: h
|
|
33
|
+
} = R, v = c(() => {
|
|
34
|
+
h(r), a();
|
|
35
|
+
}, [h, a, r]), f = c(() => {
|
|
36
|
+
const e = i(n);
|
|
37
|
+
e === null ? o() : e[0] === null && e[1] === null && t(e);
|
|
38
|
+
}, [i, n, o, t]);
|
|
39
|
+
return x(() => {
|
|
40
|
+
p.current = f;
|
|
41
|
+
}, [f]), {
|
|
42
|
+
isOpen: m,
|
|
43
|
+
step: n,
|
|
44
|
+
displayedMonth: B,
|
|
45
|
+
tempStart: y,
|
|
46
|
+
tempEnd: A,
|
|
47
|
+
hoverDate: C,
|
|
48
|
+
handleOpenChange: (e) => {
|
|
49
|
+
v(), s(e);
|
|
63
50
|
},
|
|
64
51
|
handleDateClick: (e) => {
|
|
65
|
-
|
|
52
|
+
M(e, n), n === "start" && d();
|
|
66
53
|
},
|
|
67
|
-
handleMonthChange:
|
|
68
|
-
handleDateHover:
|
|
54
|
+
handleMonthChange: g,
|
|
55
|
+
handleDateHover: O,
|
|
69
56
|
handleSetStep: (e) => {
|
|
70
|
-
e === "start" ?
|
|
57
|
+
e === "start" ? o() : d();
|
|
71
58
|
},
|
|
72
59
|
handleApplyShortcut: (e) => {
|
|
73
|
-
const
|
|
74
|
-
t(
|
|
60
|
+
const l = Array.isArray(e) ? e : [e, e];
|
|
61
|
+
t(l), s(!1), a();
|
|
75
62
|
},
|
|
76
|
-
inputRef:
|
|
77
|
-
popoverRef:
|
|
63
|
+
inputRef: k,
|
|
64
|
+
popoverRef: u
|
|
78
65
|
};
|
|
79
66
|
};
|
|
80
67
|
export {
|
|
81
|
-
|
|
68
|
+
L as useDateRangePicker
|
|
82
69
|
};
|