@vkzstudio/muza-ui 1.0.41 → 1.0.42
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { DateRange } from 'react-day-picker';
|
|
3
3
|
import { CalendarBaseProps } from '../Calendar';
|
|
4
|
+
import { PopoverContentProps } from '../Popover/Popover';
|
|
4
5
|
import { Presets } from './utils/getDateRange';
|
|
5
6
|
/**
|
|
6
7
|
* Props for the DatePicker component.
|
|
@@ -64,6 +65,17 @@ export type DatePickerProps = {
|
|
|
64
65
|
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
65
66
|
/** Prevents the popover from overflowing viewport boundaries. @default true */
|
|
66
67
|
avoidCollisions?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Additional props forwarded to the underlying {@link PopoverContent}.
|
|
70
|
+
* Use for fine-tuning positioning (`sideOffset`, `alignOffset`, `sticky`,
|
|
71
|
+
* `hideWhenDetached`) or intercepting Radix events (`onOpenAutoFocus`,
|
|
72
|
+
* `onCloseAutoFocus`, `onEscapeKeyDown`, `onPointerDownOutside`, etc.).
|
|
73
|
+
*
|
|
74
|
+
* Props already exposed on DatePicker (`align` via `alignCalendar`, `side`,
|
|
75
|
+
* `avoidCollisions`, `className` via `classNames.popoverContent`) are
|
|
76
|
+
* intentionally excluded.
|
|
77
|
+
*/
|
|
78
|
+
popoverContentProps?: Omit<PopoverContentProps, 'align' | 'side' | 'avoidCollisions' | 'className'>;
|
|
67
79
|
/** Replaces the default Input trigger with a custom rendered element. */
|
|
68
80
|
renderCustomTrigger?: () => ReactNode;
|
|
69
81
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAA2C,MAAM,OAAO,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,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IACpC,2GAA2G;IAC3G,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAA;IAChD,iEAAiE;IACjE,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,MAAM,CAAA;CAC5C,CAAA;AAED,4CAA4C;AAC5C,MAAM,MAAM,qBAAqB,GAAG;IAClC,qCAAqC;IACrC,IAAI,EAAE,QAAQ,CAAA;IACd,4CAA4C;IAC5C,KAAK,CAAC,EAAE,IAAI,GAAG,SAAS,CAAA;IACxB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,IAAI,GAAG,SAAS,CAAA;IAC/B,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,KAAK,IAAI,CAAA;IAC3C,2DAA2D;IAC3D,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,UAAU,8GA6PtB,CAAA"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { useIsDesktop as
|
|
4
|
-
import { useIsMobile as
|
|
5
|
-
import { Popover as pt, PopoverTrigger as
|
|
6
|
-
import { getDateRange as
|
|
7
|
-
import { resolveOneDayRange as
|
|
8
|
-
import { Input as
|
|
9
|
-
import { formatDate as
|
|
10
|
-
import { formatDateRange as
|
|
11
|
-
import { Calendar as
|
|
1
|
+
import { jsx as n, jsxs as ot } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as et, useState as k, useRef as Y, useEffect as it } from "react";
|
|
3
|
+
import { useIsDesktop as ft } from "../../hooks/use-is-desktop.js";
|
|
4
|
+
import { useIsMobile as ct } from "../../hooks/use-is-mobile.js";
|
|
5
|
+
import { Popover as pt, PopoverTrigger as nt, PopoverContent as dt } from "../Popover/Popover.js";
|
|
6
|
+
import { getDateRange as ut } from "./utils/getDateRange.js";
|
|
7
|
+
import { resolveOneDayRange as bt } from "./utils/resolveOneDayRange.js";
|
|
8
|
+
import { Input as st } from "../Input/Input.js";
|
|
9
|
+
import { formatDate as xt } from "../Calendar/utils/formatDate.js";
|
|
10
|
+
import { formatDateRange as lt } from "../Calendar/utils/formatDateRange.js";
|
|
11
|
+
import { Calendar as A } from "../Calendar/Calendar.js";
|
|
12
12
|
import { cn as l } from "../../utils/cn.js";
|
|
13
|
-
import { typographyVariants as
|
|
14
|
-
import { CalendarBold as
|
|
15
|
-
const vt =
|
|
13
|
+
import { typographyVariants as yt } from "../Typography/Typography.js";
|
|
14
|
+
import { CalendarBold as mt } from "@solar-icons/react-perf";
|
|
15
|
+
const vt = et(
|
|
16
16
|
({
|
|
17
17
|
alignCalendar: G,
|
|
18
18
|
mode: y,
|
|
19
|
-
allowedPresets:
|
|
19
|
+
allowedPresets: m,
|
|
20
20
|
dateFormatter: H,
|
|
21
21
|
value: e,
|
|
22
22
|
defaultValue: b,
|
|
@@ -31,39 +31,40 @@ const vt = ot(
|
|
|
31
31
|
placeholder: Q,
|
|
32
32
|
avoidCollisions: T = !0,
|
|
33
33
|
side: U = "bottom",
|
|
34
|
+
popoverContentProps: W,
|
|
34
35
|
renderCustomTrigger: S,
|
|
35
36
|
immediateCommit: f,
|
|
36
37
|
allowOneDayRange: B,
|
|
37
38
|
shouldResetToDefaultValue: I,
|
|
38
39
|
required: x,
|
|
39
|
-
disableRequiredAsterisk:
|
|
40
|
-
numberOfMonths:
|
|
41
|
-
hideNavigation:
|
|
42
|
-
hideCaption:
|
|
43
|
-
hideWeekdays:
|
|
44
|
-
showOutsideDays:
|
|
45
|
-
hideBottomText:
|
|
46
|
-
hideResetButton:
|
|
47
|
-
hideBottomBar:
|
|
48
|
-
...
|
|
49
|
-
},
|
|
50
|
-
const
|
|
40
|
+
disableRequiredAsterisk: X,
|
|
41
|
+
numberOfMonths: Z,
|
|
42
|
+
hideNavigation: _,
|
|
43
|
+
hideCaption: $,
|
|
44
|
+
hideWeekdays: V,
|
|
45
|
+
showOutsideDays: q,
|
|
46
|
+
hideBottomText: w,
|
|
47
|
+
hideResetButton: O,
|
|
48
|
+
hideBottomBar: g,
|
|
49
|
+
...a
|
|
50
|
+
}, N) => {
|
|
51
|
+
const h = ft(), C = ct(), [tt, M] = k(!1), P = typeof s == "boolean" ? s : tt, [j, c] = k(
|
|
51
52
|
e ?? b
|
|
52
|
-
), [i, u] = k(e ?? b),
|
|
53
|
+
), [i, u] = k(e ?? b), z = Y(!1), v = Y(
|
|
53
54
|
e ?? b
|
|
54
55
|
);
|
|
55
|
-
|
|
56
|
-
if (!
|
|
57
|
-
|
|
56
|
+
it(() => {
|
|
57
|
+
if (!z.current) {
|
|
58
|
+
z.current = !0;
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
c(e), u(e), P || (v.current = e);
|
|
61
62
|
}, [e]);
|
|
62
|
-
const
|
|
63
|
+
const rt = m == null ? void 0 : m.map((t) => /* @__PURE__ */ n(
|
|
63
64
|
"button",
|
|
64
65
|
{
|
|
65
66
|
className: l(
|
|
66
|
-
|
|
67
|
+
yt({
|
|
67
68
|
variant: "cta",
|
|
68
69
|
weight: "medium",
|
|
69
70
|
size: "sm",
|
|
@@ -76,41 +77,41 @@ const vt = ot(
|
|
|
76
77
|
o == null ? void 0 : o.leftPanelButton
|
|
77
78
|
),
|
|
78
79
|
onClick: () => {
|
|
79
|
-
const
|
|
80
|
-
u(
|
|
80
|
+
const p = ut(t.type);
|
|
81
|
+
u(p), f && (c(p), r == null || r(p));
|
|
81
82
|
},
|
|
82
83
|
children: t.name
|
|
83
84
|
},
|
|
84
85
|
t.type
|
|
85
|
-
)), D = H ?? (y === "single" ?
|
|
86
|
-
...
|
|
87
|
-
numberOfMonths:
|
|
88
|
-
hideNavigation:
|
|
89
|
-
hideCaption:
|
|
90
|
-
hideWeekdays:
|
|
91
|
-
showOutsideDays:
|
|
92
|
-
hideBottomText:
|
|
93
|
-
hideResetButton:
|
|
94
|
-
hideBottomBar: f ?
|
|
86
|
+
)), D = H ?? (y === "single" ? xt : lt), F = f ? e !== void 0 ? e : i : j, E = {
|
|
87
|
+
...a,
|
|
88
|
+
numberOfMonths: Z ?? (h ? 2 : 1),
|
|
89
|
+
hideNavigation: _,
|
|
90
|
+
hideCaption: $,
|
|
91
|
+
hideWeekdays: V,
|
|
92
|
+
showOutsideDays: q,
|
|
93
|
+
hideBottomText: w,
|
|
94
|
+
hideResetButton: O,
|
|
95
|
+
hideBottomBar: f ? g : void 0,
|
|
95
96
|
required: x,
|
|
96
97
|
onReset: () => {
|
|
97
|
-
const t = I ? b : f ?
|
|
98
|
-
u(t), f && (
|
|
98
|
+
const t = I ? b : f ? v.current : j;
|
|
99
|
+
u(t), f && (c(t), r == null || r(t));
|
|
99
100
|
},
|
|
100
101
|
onConfirm: () => {
|
|
101
|
-
f ?
|
|
102
|
+
f ? c(i) : (i !== void 0 || I || x === !1) && (c(i), r == null || r(i)), s === void 0 && M(!1), d == null || d(!1);
|
|
102
103
|
}
|
|
103
104
|
};
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
+
return /* @__PURE__ */ ot(
|
|
105
106
|
pt,
|
|
106
107
|
{
|
|
107
108
|
open: P,
|
|
108
109
|
onOpenChange: (t) => {
|
|
109
|
-
t && (
|
|
110
|
+
t && (v.current = e ?? i), s === void 0 && M(t), d == null || d(t);
|
|
110
111
|
},
|
|
111
112
|
children: [
|
|
112
113
|
/* @__PURE__ */ n(
|
|
113
|
-
|
|
114
|
+
nt,
|
|
114
115
|
{
|
|
115
116
|
className: l(
|
|
116
117
|
"group cursor-pointer rounded-full text-left outline-0",
|
|
@@ -118,10 +119,10 @@ const vt = ot(
|
|
|
118
119
|
),
|
|
119
120
|
disabled: R,
|
|
120
121
|
children: S ? S() : /* @__PURE__ */ n(
|
|
121
|
-
|
|
122
|
+
st,
|
|
122
123
|
{
|
|
123
|
-
ref:
|
|
124
|
-
value:
|
|
124
|
+
ref: N,
|
|
125
|
+
value: F ? D(F) : "",
|
|
125
126
|
placeholder: Q,
|
|
126
127
|
error: J,
|
|
127
128
|
disabled: R,
|
|
@@ -129,52 +130,52 @@ const vt = ot(
|
|
|
129
130
|
hint: K,
|
|
130
131
|
tabIndex: -1,
|
|
131
132
|
required: x,
|
|
132
|
-
disableRequiredAsterisk:
|
|
133
|
+
disableRequiredAsterisk: X,
|
|
133
134
|
className: l(
|
|
134
135
|
"pointer-events-none",
|
|
135
136
|
o == null ? void 0 : o.input,
|
|
136
137
|
"group-hover:border-comp-input-stroke-hover group-focus-visible:border-comp-input-stroke-focused"
|
|
137
138
|
),
|
|
138
|
-
suffix: /* @__PURE__ */ n(
|
|
139
|
+
suffix: /* @__PURE__ */ n(mt, { className: "size-icon-medium text-icon-dark-secondary-def" })
|
|
139
140
|
}
|
|
140
141
|
)
|
|
141
142
|
}
|
|
142
143
|
),
|
|
143
144
|
/* @__PURE__ */ n(
|
|
144
|
-
|
|
145
|
+
dt,
|
|
145
146
|
{
|
|
147
|
+
...W,
|
|
146
148
|
className: l("flex w-auto p-0", o == null ? void 0 : o.popoverContent),
|
|
147
149
|
align: G,
|
|
148
150
|
side: U,
|
|
149
151
|
avoidCollisions: T,
|
|
150
|
-
onOpenAutoFocus: (t) => t.preventDefault(),
|
|
151
152
|
children: y === "single" ? /* @__PURE__ */ n(
|
|
152
|
-
|
|
153
|
+
A,
|
|
153
154
|
{
|
|
154
|
-
...
|
|
155
|
+
...E,
|
|
155
156
|
mode: "single",
|
|
156
157
|
selected: i,
|
|
157
158
|
onSelect: f ? (t) => {
|
|
158
|
-
u(t),
|
|
159
|
+
u(t), c(t), r == null || r(t);
|
|
159
160
|
} : u,
|
|
160
161
|
dateFormatter: D
|
|
161
162
|
}
|
|
162
163
|
) : /* @__PURE__ */ n(
|
|
163
|
-
|
|
164
|
+
A,
|
|
164
165
|
{
|
|
165
|
-
...
|
|
166
|
+
...E,
|
|
166
167
|
mode: "range",
|
|
167
168
|
min: B ? 1 : void 0,
|
|
168
169
|
selected: i,
|
|
169
170
|
onSelect: (t) => {
|
|
170
|
-
const
|
|
171
|
+
const p = B ? bt(
|
|
171
172
|
i,
|
|
172
173
|
t,
|
|
173
174
|
x
|
|
174
175
|
) : t;
|
|
175
|
-
u(
|
|
176
|
+
u(p), f && (c(p), r == null || r(p));
|
|
176
177
|
},
|
|
177
|
-
leftPanelChildren: y === "range" && !
|
|
178
|
+
leftPanelChildren: y === "range" && !C && rt,
|
|
178
179
|
dateRangeFormatter: D
|
|
179
180
|
}
|
|
180
181
|
)
|