@tedi-design-system/react 18.2.0-rc.1 → 18.2.0-rc.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.
- package/bundle-stats.html +1 -1
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/tedi/components/content/calendar/calendar.cjs.js +1 -1
- package/src/tedi/components/content/calendar/calendar.d.ts +39 -3
- package/src/tedi/components/content/calendar/calendar.es.js +121 -101
- package/src/tedi/components/content/calendar/calendar.module.scss.cjs.js +1 -1
- package/src/tedi/components/content/calendar/calendar.module.scss.es.js +5 -2
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.cjs.js +1 -1
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.d.ts +4 -2
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.es.js +42 -42
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.module.scss.cjs.js +1 -1
- package/src/tedi/components/content/calendar/components/calendar-header/calendar-header.module.scss.es.js +1 -0
- package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field.d.ts +10 -1
- package/src/tedi/components/form/date-field/date-field.es.js +147 -144
- package/src/tedi/components/form/date-field/date-picker-modal/date-picker-modal.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-picker-modal/date-picker-modal.d.ts +3 -0
- package/src/tedi/components/form/date-field/date-picker-modal/date-picker-modal.es.js +41 -39
- package/src/tedi/components/form/file-dropzone/file-dropzone.cjs.js +1 -1
- package/src/tedi/components/form/file-dropzone/file-dropzone.d.ts +14 -1
- package/src/tedi/components/form/file-dropzone/file-dropzone.es.js +120 -82
- package/src/tedi/components/form/file-dropzone/file-dropzone.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/file-dropzone/file-dropzone.module.scss.es.js +1 -0
- package/src/tedi/components/form/file-upload/file-upload.d.ts +1 -1
- package/src/tedi/helpers/hooks/use-file-upload.d.ts +1 -1
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +307 -306
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useFloating as
|
|
1
|
+
import { jsxs as Mt, Fragment as At, jsx as D } from "react/jsx-runtime";
|
|
2
|
+
import { useFloating as xt, useClick as Ft, useInteractions as vt, useDismiss as wt, useRole as Nt, FloatingPortal as kt, FloatingFocusManager as Pt } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
|
|
3
3
|
import V from "../../../../../external/classnames/index.es.js";
|
|
4
4
|
import B, { useState as _, useCallback as ue, useEffect as T, useMemo as me } from "react";
|
|
5
|
-
import { Calendar as
|
|
6
|
-
import { MultiValueField as
|
|
7
|
-
import { TextField as
|
|
5
|
+
import { Calendar as Et } from "../../content/calendar/calendar.es.js";
|
|
6
|
+
import { MultiValueField as Ot } from "../multi-value-field/multi-value-field.es.js";
|
|
7
|
+
import { TextField as Rt } from "../textfield/textfield.es.js";
|
|
8
8
|
import g from "./date-field.module.scss.es.js";
|
|
9
|
-
import { getLocaleDateParts as
|
|
10
|
-
import { DatePickerModal as
|
|
11
|
-
import { useBreakpointProps as
|
|
12
|
-
import { useLabels as
|
|
13
|
-
import { et as
|
|
14
|
-
import
|
|
9
|
+
import { getLocaleDateParts as It, buildDateRegexSource as Vt, resolveRangeSelection as Bt, CALENDAR_POPOVER_OFFSET as Tt, CALENDAR_POPOVER_PADDING as Le } from "./date-field-helpers.es.js";
|
|
10
|
+
import { DatePickerModal as $t } from "./date-picker-modal/date-picker-modal.es.js";
|
|
11
|
+
import { useBreakpointProps as Lt } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
12
|
+
import { useLabels as jt } from "../../../providers/label-provider/use-labels.es.js";
|
|
13
|
+
import { et as Ht } from "../../../../../external/react-day-picker/dist/esm/locale/et.es.js";
|
|
14
|
+
import St, { isBreakpointBelow as je } from "../../../helpers/hooks/use-breakpoint.es.js";
|
|
15
15
|
import { autoUpdate as Wt } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
|
|
16
|
-
import { offset as Yt, flip as
|
|
17
|
-
import { dateMatchModifiers as
|
|
18
|
-
const
|
|
19
|
-
const { getCurrentBreakpointProps:
|
|
20
|
-
useNativePicker:
|
|
16
|
+
import { offset as Yt, flip as Ut, shift as qt, size as zt } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
|
|
17
|
+
import { dateMatchModifiers as Gt } from "../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.es.js";
|
|
18
|
+
const Xt = B.forwardRef(($, v) => {
|
|
19
|
+
const { getCurrentBreakpointProps: He } = Lt($.defaultServerBreakpoint), { getLabel: z } = jt(), {
|
|
20
|
+
useNativePicker: Se = !1,
|
|
21
21
|
enableCalendar: m = !0,
|
|
22
22
|
calendarTrigger: L = "button",
|
|
23
23
|
numberOfMonths: G
|
|
24
|
-
} =
|
|
24
|
+
} = He($), {
|
|
25
25
|
id: pe,
|
|
26
26
|
mode: s = "single",
|
|
27
27
|
label: he,
|
|
@@ -34,67 +34,68 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
34
34
|
formatDate: f,
|
|
35
35
|
required: j,
|
|
36
36
|
showOutsideDays: ge = !0,
|
|
37
|
-
parseDate:
|
|
37
|
+
parseDate: Ue,
|
|
38
38
|
monthYearSelectType: ye,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
dayStatus: be,
|
|
40
|
+
tagsDirection: qe,
|
|
41
|
+
showNavigation: De = !0,
|
|
41
42
|
selectionLevel: P = "days",
|
|
42
43
|
initialView: H,
|
|
43
|
-
locale:
|
|
44
|
-
localeCode:
|
|
45
|
-
initialMonth:
|
|
46
|
-
closeOnSelect:
|
|
47
|
-
footer:
|
|
48
|
-
defaultValue:
|
|
44
|
+
locale: _e = Ht,
|
|
45
|
+
localeCode: S = "et-EE",
|
|
46
|
+
initialMonth: W,
|
|
47
|
+
closeOnSelect: ze,
|
|
48
|
+
footer: Ce,
|
|
49
|
+
defaultValue: Y,
|
|
49
50
|
minDate: X,
|
|
50
51
|
maxDate: J,
|
|
51
|
-
disablePast:
|
|
52
|
-
disableFuture:
|
|
52
|
+
disablePast: Me,
|
|
53
|
+
disableFuture: Ae,
|
|
53
54
|
shouldDisableMonth: K,
|
|
54
55
|
shouldDisableYear: Q,
|
|
55
56
|
readOnly: E,
|
|
56
|
-
availableDays:
|
|
57
|
+
availableDays: xe,
|
|
57
58
|
inputProps: i,
|
|
58
59
|
modal: Z = !1,
|
|
59
|
-
modalProps:
|
|
60
|
-
modalTitle:
|
|
61
|
-
disabledDateErrorMessage:
|
|
62
|
-
invalidDateErrorMessage:
|
|
63
|
-
useNativePicker:
|
|
64
|
-
enableCalendar:
|
|
65
|
-
calendarTrigger:
|
|
66
|
-
numberOfMonths:
|
|
67
|
-
defaultServerBreakpoint:
|
|
68
|
-
sm:
|
|
69
|
-
md:
|
|
70
|
-
lg:
|
|
71
|
-
xl:
|
|
72
|
-
xxl:
|
|
73
|
-
...
|
|
74
|
-
} = $, c =
|
|
60
|
+
modalProps: Ge,
|
|
61
|
+
modalTitle: Xe,
|
|
62
|
+
disabledDateErrorMessage: Je = z("dateField.disabledDateError"),
|
|
63
|
+
invalidDateErrorMessage: Ke = z("dateField.invalidDateError"),
|
|
64
|
+
useNativePicker: Jt,
|
|
65
|
+
enableCalendar: Kt,
|
|
66
|
+
calendarTrigger: Qt,
|
|
67
|
+
numberOfMonths: Zt,
|
|
68
|
+
defaultServerBreakpoint: er,
|
|
69
|
+
sm: tr,
|
|
70
|
+
md: rr,
|
|
71
|
+
lg: ar,
|
|
72
|
+
xl: ir,
|
|
73
|
+
xxl: or,
|
|
74
|
+
...Fe
|
|
75
|
+
} = $, c = Se && s === "single", ve = St($.defaultServerBreakpoint), x = je(ve, "md"), [Qe, y] = _(w ?? Y), [p, O] = _(!1), [ee, we] = _(!1), [Ze, Ne] = _(H ?? P), [te, b] = _(""), [ke, u] = _(!1), [Pe, re] = _(!1), h = m && !c && !E && (Z === !0 || typeof Z == "string" && je(ve, Z)), Ee = x && !h && typeof G == "number" && G > 1 ? 1 : G, d = w !== void 0, n = d ? w : Qe, ae = B.useRef(null), Oe = B.useRef(null), et = B.useCallback(
|
|
75
76
|
(e) => {
|
|
76
77
|
ae.current = e, typeof v == "function" ? v(e) : v && (v.current = e);
|
|
77
78
|
},
|
|
78
79
|
[v]
|
|
79
|
-
),
|
|
80
|
+
), tt = (e) => {
|
|
80
81
|
if (!e) return "";
|
|
81
82
|
const t = e.getFullYear(), r = String(e.getMonth() + 1).padStart(2, "0"), o = String(e.getDate()).padStart(2, "0");
|
|
82
83
|
return `${t}-${r}-${o}`;
|
|
83
|
-
},
|
|
84
|
+
}, rt = c && n instanceof Date ? tt(n) : "", ie = ue((e, t) => e instanceof Date ? e : Array.isArray(e) && e.length > 0 ? [...e].sort((r, o) => r.getTime() - o.getTime())[0] : e && typeof e == "object" && "from" in e && e.from instanceof Date ? e.from : e && typeof e == "object" && "to" in e && e.to instanceof Date ? e.to : t ?? /* @__PURE__ */ new Date(), []), [at, oe] = _(() => ie(n, W));
|
|
84
85
|
T(() => {
|
|
85
|
-
p || oe(ie(n,
|
|
86
|
-
}, [n,
|
|
87
|
-
p &&
|
|
86
|
+
p || oe(ie(n, W));
|
|
87
|
+
}, [n, W, p, ie]), T(() => {
|
|
88
|
+
p && Ne(H ?? P);
|
|
88
89
|
}, [p, P, H]), T(() => {
|
|
89
90
|
d && y(w);
|
|
90
91
|
}, [w, d]);
|
|
91
92
|
const C = me(
|
|
92
|
-
() => new Intl.DateTimeFormat(
|
|
93
|
+
() => new Intl.DateTimeFormat(S, {
|
|
93
94
|
day: "2-digit",
|
|
94
95
|
month: "2-digit",
|
|
95
96
|
year: "numeric"
|
|
96
97
|
}),
|
|
97
|
-
[
|
|
98
|
+
[S]
|
|
98
99
|
), M = ue(
|
|
99
100
|
(e) => {
|
|
100
101
|
if (!e) return "";
|
|
@@ -107,47 +108,47 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
107
108
|
return "";
|
|
108
109
|
},
|
|
109
110
|
[C]
|
|
110
|
-
), ne =
|
|
111
|
+
), ne = ze ?? s === "single", Re = s === "multiple" && Array.isArray(n) ? n.map((e, t) => ({
|
|
111
112
|
id: t,
|
|
112
113
|
label: f ? f(e) : M(e),
|
|
113
114
|
date: e
|
|
114
115
|
})) : [], U = me(() => {
|
|
115
116
|
const e = [];
|
|
116
|
-
return N && (Array.isArray(N) ? e.push(...N) : e.push(N)), k && (Array.isArray(k) ? e.push(...k) : e.push(k)), X && e.push({ before: X }), J && e.push({ after: J }),
|
|
117
|
+
return N && (Array.isArray(N) ? e.push(...N) : e.push(N)), k && (Array.isArray(k) ? e.push(...k) : e.push(k)), X && e.push({ before: X }), J && e.push({ after: J }), Me && e.push({ before: /* @__PURE__ */ new Date() }), Ae && e.push({ after: /* @__PURE__ */ new Date() }), K && e.push((t) => K(t)), Q && e.push((t) => Q(t)), e;
|
|
117
118
|
}, [
|
|
118
119
|
N,
|
|
119
120
|
k,
|
|
120
121
|
X,
|
|
121
122
|
J,
|
|
122
|
-
Ce,
|
|
123
123
|
Me,
|
|
124
|
+
Ae,
|
|
124
125
|
K,
|
|
125
126
|
Q
|
|
126
127
|
]), F = ue(
|
|
127
|
-
(e) =>
|
|
128
|
+
(e) => Gt(e, U),
|
|
128
129
|
[U]
|
|
129
|
-
),
|
|
130
|
-
const l = s === "range" ?
|
|
130
|
+
), it = (e, t, r, o) => {
|
|
131
|
+
const l = s === "range" ? Bt(e, n, t) : e;
|
|
131
132
|
if (u(!1), d || y(l), a == null || a(l, t, r, o), l) {
|
|
132
133
|
const A = f ? f(l) : M(l);
|
|
133
134
|
b(A);
|
|
134
135
|
} else
|
|
135
136
|
b("");
|
|
136
137
|
ne && O(!1);
|
|
137
|
-
},
|
|
138
|
+
}, ot = (e) => {
|
|
138
139
|
if (F(e)) return;
|
|
139
140
|
const t = s === "range" ? { from: e, to: void 0 } : s === "multiple" ? [...Array.isArray(n) ? n : [], e] : e;
|
|
140
141
|
u(!1), d || y(t), a == null || a(t, e, {}, {});
|
|
141
142
|
const r = f ? f(t) : M(t);
|
|
142
143
|
b(r), ne && O(!1);
|
|
143
|
-
},
|
|
144
|
-
const e =
|
|
144
|
+
}, nt = me(() => {
|
|
145
|
+
const e = It(C), t = new RegExp(`^${Vt(e)}$`), { fieldOrder: r } = e;
|
|
145
146
|
return (o) => {
|
|
146
147
|
const l = o.match(t);
|
|
147
148
|
if (!l) return;
|
|
148
149
|
const A = {};
|
|
149
|
-
r.forEach((
|
|
150
|
-
A[
|
|
150
|
+
r.forEach((_t, Ct) => {
|
|
151
|
+
A[_t] = Number(l[Ct + 1]);
|
|
151
152
|
});
|
|
152
153
|
const { day: fe, month: de, year: ce } = A;
|
|
153
154
|
if (fe === void 0 || de === void 0 || ce === void 0) return;
|
|
@@ -155,14 +156,14 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
155
156
|
if (!(isNaN(I.getTime()) || I.getFullYear() !== ce || I.getMonth() !== de - 1 || I.getDate() !== fe))
|
|
156
157
|
return I;
|
|
157
158
|
};
|
|
158
|
-
}, [C]),
|
|
159
|
-
}))(e),
|
|
159
|
+
}, [C]), Ie = (e) => (Ue ?? (s === "single" ? nt : () => {
|
|
160
|
+
}))(e), Ve = (e) => s === "single" && e instanceof Date || s === "multiple" && Array.isArray(e) || s === "range" && !!e && !Array.isArray(e) && "from" in e, st = (e) => {
|
|
160
161
|
if (b(e), re(!1), e.trim() === "") {
|
|
161
162
|
u(!1);
|
|
162
163
|
return;
|
|
163
164
|
}
|
|
164
|
-
const t =
|
|
165
|
-
if (!
|
|
165
|
+
const t = Ie(e);
|
|
166
|
+
if (!Ve(t)) {
|
|
166
167
|
u(!1);
|
|
167
168
|
return;
|
|
168
169
|
}
|
|
@@ -172,12 +173,12 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
172
173
|
return;
|
|
173
174
|
}
|
|
174
175
|
u(!1), d || y(t), a == null || a(t, t, {}, {}), t instanceof Date && oe(t), ne && O(!1);
|
|
175
|
-
},
|
|
176
|
+
}, lt = () => {
|
|
176
177
|
if (te.trim() === "") {
|
|
177
178
|
re(!1);
|
|
178
179
|
return;
|
|
179
180
|
}
|
|
180
|
-
re(!Ie(
|
|
181
|
+
re(!Ve(Ie(te)));
|
|
181
182
|
};
|
|
182
183
|
T(() => {
|
|
183
184
|
if (d) {
|
|
@@ -185,21 +186,21 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
185
186
|
b(e);
|
|
186
187
|
}
|
|
187
188
|
}, [n, d, f, M]), T(() => {
|
|
188
|
-
if (!d &&
|
|
189
|
-
const e = f ? f(
|
|
189
|
+
if (!d && Y) {
|
|
190
|
+
const e = f ? f(Y) : M(Y);
|
|
190
191
|
b(e);
|
|
191
192
|
}
|
|
192
193
|
}, []);
|
|
193
|
-
const
|
|
194
|
+
const ft = xt({
|
|
194
195
|
open: p,
|
|
195
196
|
onOpenChange: O,
|
|
196
197
|
placement: L === "input" ? "bottom-start" : "bottom-end",
|
|
197
198
|
middleware: [
|
|
198
|
-
Yt(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
padding:
|
|
199
|
+
Yt(Tt),
|
|
200
|
+
Ut(),
|
|
201
|
+
qt({ padding: Le }),
|
|
202
|
+
zt({
|
|
203
|
+
padding: Le,
|
|
203
204
|
apply({ availableWidth: e, elements: t }) {
|
|
204
205
|
const r = t.floating;
|
|
205
206
|
if (r.style.width = "", r.style.maxWidth = "", r.style.overflowX = "", x) return;
|
|
@@ -208,22 +209,22 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
208
209
|
})
|
|
209
210
|
],
|
|
210
211
|
whileElementsMounted: Wt
|
|
211
|
-
}), { refs: R, context: q, x:
|
|
212
|
-
...m && !c && L === "input" && !h ? [
|
|
213
|
-
|
|
212
|
+
}), { refs: R, context: q, x: dt, y: ct, strategy: ut } = ft, mt = Ft(q), Be = vt([
|
|
213
|
+
...m && !c && L === "input" && !h ? [mt] : [],
|
|
214
|
+
wt(q, {
|
|
214
215
|
outsidePress: (e) => {
|
|
215
216
|
const t = e.target;
|
|
216
217
|
return !(t != null && t.closest('[role="menu"], [role="listbox"]'));
|
|
217
218
|
}
|
|
218
219
|
}),
|
|
219
|
-
|
|
220
|
+
Nt(q, { role: "dialog" })
|
|
220
221
|
]);
|
|
221
222
|
B.useEffect(() => {
|
|
222
223
|
var t, r;
|
|
223
|
-
const e = s === "multiple" ? ((t =
|
|
224
|
+
const e = s === "multiple" ? ((t = Oe.current) == null ? void 0 : t.wrapper) ?? null : ((r = ae.current) == null ? void 0 : r.input) ?? null;
|
|
224
225
|
R.setPositionReference(e ?? R.reference.current);
|
|
225
226
|
}, [s, p, R]);
|
|
226
|
-
const
|
|
227
|
+
const pt = () => {
|
|
227
228
|
var t;
|
|
228
229
|
const e = (t = ae.current) == null ? void 0 : t.input;
|
|
229
230
|
if (e) {
|
|
@@ -236,14 +237,14 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
236
237
|
e.focus();
|
|
237
238
|
}
|
|
238
239
|
}, se = () => {
|
|
239
|
-
!m || E || (c ?
|
|
240
|
-
},
|
|
240
|
+
!m || E || (c ? pt() : h ? we(!0) : O((e) => !e));
|
|
241
|
+
}, ht = (e) => {
|
|
241
242
|
if (u(!1), d || y(e), a == null || a(e, e, {}, {}), e) {
|
|
242
243
|
const t = f ? f(e) : M(e);
|
|
243
244
|
b(t);
|
|
244
245
|
} else
|
|
245
246
|
b("");
|
|
246
|
-
},
|
|
247
|
+
}, gt = (e) => {
|
|
247
248
|
if (!e) {
|
|
248
249
|
u(!1), d || y(void 0), a == null || a(void 0, void 0, {}, {});
|
|
249
250
|
return;
|
|
@@ -258,44 +259,44 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
258
259
|
}
|
|
259
260
|
u(!1), d || y(l), a == null || a(l, l, {}, {});
|
|
260
261
|
}
|
|
261
|
-
},
|
|
262
|
+
}, yt = Be.getReferenceProps(
|
|
262
263
|
h && L === "input" ? { onClick: () => se() } : void 0
|
|
263
264
|
), {
|
|
264
|
-
role:
|
|
265
|
-
"aria-expanded":
|
|
266
|
-
"aria-haspopup":
|
|
267
|
-
"aria-controls":
|
|
268
|
-
...
|
|
269
|
-
} =
|
|
265
|
+
role: nr,
|
|
266
|
+
"aria-expanded": sr,
|
|
267
|
+
"aria-haspopup": lr,
|
|
268
|
+
"aria-controls": bt,
|
|
269
|
+
...Dt
|
|
270
|
+
} = yt, Te = h ? void 0 : bt, le = z("dateField.openCalendar"), $e = {
|
|
270
271
|
"aria-label": le,
|
|
271
272
|
"aria-expanded": h ? ee : p,
|
|
272
273
|
"aria-haspopup": "dialog",
|
|
273
|
-
"aria-controls":
|
|
274
|
+
"aria-controls": Te
|
|
274
275
|
};
|
|
275
|
-
return /* @__PURE__ */
|
|
276
|
+
return /* @__PURE__ */ Mt(At, { children: [
|
|
276
277
|
/* @__PURE__ */ D(
|
|
277
278
|
"div",
|
|
278
279
|
{
|
|
279
280
|
className: V(g["tedi-date-field__container"], Ye),
|
|
280
|
-
...
|
|
281
|
+
...Dt,
|
|
281
282
|
ref: R.setReference,
|
|
282
283
|
children: s === "multiple" ? /* @__PURE__ */ D(
|
|
283
|
-
|
|
284
|
+
Ot,
|
|
284
285
|
{
|
|
285
286
|
...i,
|
|
286
|
-
ref:
|
|
287
|
+
ref: Oe,
|
|
287
288
|
id: pe,
|
|
288
289
|
label: he,
|
|
289
|
-
tagsDirection:
|
|
290
|
-
values:
|
|
290
|
+
tagsDirection: qe,
|
|
291
|
+
values: Re.map((e) => e.label),
|
|
291
292
|
icon: "calendar_today",
|
|
292
293
|
onIconClick: se,
|
|
293
|
-
iconButtonProps: m ?
|
|
294
|
+
iconButtonProps: m ? $e : { "aria-label": le },
|
|
294
295
|
isClearable: !0,
|
|
295
296
|
required: j,
|
|
296
297
|
onChange: (e) => {
|
|
297
298
|
if (!Array.isArray(n)) return;
|
|
298
|
-
const t =
|
|
299
|
+
const t = Re.filter((r) => e.includes(r.label)).map((r) => r.date);
|
|
299
300
|
d || y(t), a == null || a(t, {}, {}, {});
|
|
300
301
|
},
|
|
301
302
|
className: V(g["tedi-date-field__textfield"], {
|
|
@@ -303,28 +304,28 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
303
304
|
})
|
|
304
305
|
}
|
|
305
306
|
) : /* @__PURE__ */ D(
|
|
306
|
-
|
|
307
|
+
Rt,
|
|
307
308
|
{
|
|
308
309
|
...i,
|
|
309
|
-
ref:
|
|
310
|
+
ref: et,
|
|
310
311
|
id: pe,
|
|
311
312
|
label: he,
|
|
312
313
|
readOnly: E,
|
|
313
|
-
value: c ?
|
|
314
|
+
value: c ? rt : te,
|
|
314
315
|
placeholder: We,
|
|
315
316
|
icon: "calendar_today",
|
|
316
317
|
isClearable: !0,
|
|
317
318
|
onIconClick: se,
|
|
318
|
-
iconButtonProps: m && !c ?
|
|
319
|
-
onChange: (e) => c ?
|
|
319
|
+
iconButtonProps: m && !c ? $e : { "aria-label": le },
|
|
320
|
+
onChange: (e) => c ? gt(e) : st(e),
|
|
320
321
|
onBlur: (e) => {
|
|
321
322
|
var t;
|
|
322
|
-
c ||
|
|
323
|
+
c || lt(), (t = i == null ? void 0 : i.onBlur) == null || t.call(i, e);
|
|
323
324
|
},
|
|
324
325
|
required: j,
|
|
325
|
-
invalid:
|
|
326
|
+
invalid: ke || Pe || (i == null ? void 0 : i.invalid),
|
|
326
327
|
helper: (() => {
|
|
327
|
-
const e = i == null ? void 0 : i.helper, t =
|
|
328
|
+
const e = i == null ? void 0 : i.helper, t = ke ? Je : Pe ? Ke : null, r = t ? { text: t, type: "error" } : null;
|
|
328
329
|
return r ? e ? Array.isArray(e) ? [...e, r] : [e, r] : r : e;
|
|
329
330
|
})(),
|
|
330
331
|
className: V(g["tedi-date-field__textfield"], {
|
|
@@ -338,7 +339,7 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
338
339
|
role: "combobox",
|
|
339
340
|
"aria-haspopup": "dialog",
|
|
340
341
|
"aria-expanded": h ? ee : p,
|
|
341
|
-
"aria-controls":
|
|
342
|
+
"aria-controls": Te
|
|
342
343
|
} : {}
|
|
343
344
|
}
|
|
344
345
|
}
|
|
@@ -346,69 +347,71 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
346
347
|
}
|
|
347
348
|
),
|
|
348
349
|
h && /* @__PURE__ */ D(
|
|
349
|
-
|
|
350
|
+
$t,
|
|
350
351
|
{
|
|
351
352
|
open: ee,
|
|
352
|
-
onOpenChange:
|
|
353
|
+
onOpenChange: we,
|
|
353
354
|
value: n,
|
|
354
|
-
onConfirm:
|
|
355
|
+
onConfirm: ht,
|
|
355
356
|
mode: s,
|
|
356
|
-
numberOfMonths:
|
|
357
|
-
locale:
|
|
358
|
-
localeCode:
|
|
357
|
+
numberOfMonths: Ee,
|
|
358
|
+
locale: _e,
|
|
359
|
+
localeCode: S,
|
|
359
360
|
showOutsideDays: ge,
|
|
360
361
|
disabledMatchers: U,
|
|
361
362
|
required: j,
|
|
362
|
-
availableDays:
|
|
363
|
-
footer:
|
|
363
|
+
availableDays: xe,
|
|
364
|
+
footer: Ce,
|
|
364
365
|
monthYearSelectType: ye,
|
|
365
|
-
|
|
366
|
+
dayStatus: be,
|
|
367
|
+
showNavigation: De,
|
|
366
368
|
selectionLevel: P,
|
|
367
369
|
initialView: H,
|
|
368
|
-
initialMonth:
|
|
369
|
-
modalProps:
|
|
370
|
-
...
|
|
371
|
-
title:
|
|
370
|
+
initialMonth: W,
|
|
371
|
+
modalProps: Ge,
|
|
372
|
+
...Fe,
|
|
373
|
+
title: Xe
|
|
372
374
|
}
|
|
373
375
|
),
|
|
374
|
-
m && !c && !h && /* @__PURE__ */ D(
|
|
376
|
+
m && !c && !h && /* @__PURE__ */ D(kt, { children: p && /* @__PURE__ */ D(Pt, { context: q, modal: !1, initialFocus: -1, children: /* @__PURE__ */ D(
|
|
375
377
|
"div",
|
|
376
378
|
{
|
|
377
379
|
ref: R.setFloating,
|
|
378
380
|
className: V({
|
|
379
381
|
[g["tedi-date-field__calendar-popover--fullwidth"]]: x
|
|
380
382
|
}),
|
|
381
|
-
...
|
|
383
|
+
...Be.getFloatingProps({
|
|
382
384
|
style: {
|
|
383
|
-
position:
|
|
384
|
-
top:
|
|
385
|
-
left: x ? 0 :
|
|
385
|
+
position: ut,
|
|
386
|
+
top: ct ?? 0,
|
|
387
|
+
left: x ? 0 : dt ?? 0,
|
|
386
388
|
right: x ? 0 : void 0
|
|
387
389
|
}
|
|
388
390
|
}),
|
|
389
391
|
children: /* @__PURE__ */ D(
|
|
390
|
-
|
|
392
|
+
Et,
|
|
391
393
|
{
|
|
392
|
-
...
|
|
393
|
-
numberOfMonths:
|
|
394
|
-
view:
|
|
394
|
+
...Fe,
|
|
395
|
+
numberOfMonths: Ee,
|
|
396
|
+
view: Ze,
|
|
395
397
|
selectionLevel: P,
|
|
396
|
-
currentMonth:
|
|
398
|
+
currentMonth: at,
|
|
397
399
|
setCurrentMonth: oe,
|
|
398
|
-
setView:
|
|
400
|
+
setView: Ne,
|
|
399
401
|
mode: s,
|
|
400
402
|
value: n,
|
|
401
|
-
locale:
|
|
402
|
-
localeCode:
|
|
403
|
+
locale: _e,
|
|
404
|
+
localeCode: S,
|
|
403
405
|
showOutsideDays: ge,
|
|
404
406
|
disabledMatchers: U,
|
|
405
407
|
required: j,
|
|
406
|
-
availableDays:
|
|
407
|
-
footer:
|
|
408
|
+
availableDays: xe,
|
|
409
|
+
footer: Ce,
|
|
408
410
|
monthYearSelectType: ye,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
411
|
+
dayStatus: be,
|
|
412
|
+
showNavigation: De,
|
|
413
|
+
handleSelect: it,
|
|
414
|
+
applyValue: ot,
|
|
412
415
|
className: V(g["tedi-date-field__calendar"], {
|
|
413
416
|
[g["tedi-date-field__calendar--fullwidth"]]: x
|
|
414
417
|
})
|
|
@@ -418,7 +421,7 @@ const Gt = B.forwardRef(($, v) => {
|
|
|
418
421
|
) }) })
|
|
419
422
|
] });
|
|
420
423
|
});
|
|
421
|
-
|
|
424
|
+
Xt.displayName = "DateField";
|
|
422
425
|
export {
|
|
423
|
-
|
|
426
|
+
Xt as DateField
|
|
424
427
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),J=require("../../../../../../external/classnames/index.cjs.js"),d=require("react"),Q=require("../../../base/typography/heading/heading.cjs.js"),C=require("../../../buttons/button/button.cjs.js"),U=require("../../../buttons/closing-button/closing-button.cjs.js"),W=require("../../../content/calendar/calendar.cjs.js"),X=require("../date-field-helpers.cjs.js"),u=require("./date-picker-modal.module.scss.cjs.js"),Z=require("../../../../providers/label-provider/use-labels.cjs.js"),c=require("../../../overlays/modal/modal.cjs.js"),$=require("../../../overlays/modal/modal-context.cjs.js"),D=(e,r)=>e instanceof Date?e:Array.isArray(e)&&e.length>0?[...e].sort((o,l)=>o.getTime()-l.getTime())[0]:e&&typeof e=="object"&&"from"in e&&e.from instanceof Date?e.from:e&&typeof e=="object"&&"to"in e&&e.to instanceof Date?e.to:r??new Date,v=({title:e})=>{const{labelId:r,onOpenChange:o}=$.useModal();return t.jsxs("div",{className:u.default["tedi-date-picker-modal__header"],children:[t.jsx(Q.Heading,{element:"h2",modifiers:"h4",id:r,className:u.default["tedi-date-picker-modal__title"],children:e}),t.jsx(U.ClosingButton,{size:"small",onClick:()=>o(!1)})]})},q=e=>{const{open:r,onOpenChange:o,value:l,onConfirm:S,mode:n="single",numberOfMonths:T,locale:_,localeCode:w,showOutsideDays:N=!0,disabledMatchers:A,required:p,availableDays:B,footer:O,monthYearSelectType:H,dayStatus:L,showNavigation:P,selectionLevel:f="days",initialView:y,initialMonth:g,modalProps:i,title:R,...V}=e,{getLabel:b}=Z.useLabels(),[a,m]=d.useState(l),[F,M]=d.useState(y??f),[I,j]=d.useState(()=>D(l,g));d.useEffect(()=>{r&&(m(l),M(y??f),j(D(l,g)))},[r,l,f,y,g]);const K=d.useCallback((s,h)=>{m(n==="range"?G=>X.resolveRangeSelection(s,G,h):s)},[n]),z=d.useCallback(s=>{m(h=>n==="range"?{from:s,to:void 0}:n==="multiple"?[...Array.isArray(h)?h:[],s]:s)},[n]),E=n==="multiple"?Array.isArray(a)&&a.length>0:n==="range"?!!a&&typeof a=="object"&&"from"in a&&a.from instanceof Date:a instanceof Date,k=p===!0&&!E,Y=()=>{k||(S(a),o(!1))},x=R??b(n==="range"?"date-field.modal-title-range":n==="multiple"?"date-field.modal-title-multiple":"date-field.modal-title");return t.jsx(c.Modal,{open:r,onToggle:o,children:t.jsxs(c.Modal.Content,{position:"center","aria-label":x,...i,md:{width:"max-content",...i==null?void 0:i.md},sm:{width:"full",...i==null?void 0:i.sm},className:J.default(u.default["tedi-date-picker-modal"],i==null?void 0:i.className),children:[t.jsx(c.Modal.Header,{children:t.jsx(v,{title:x})}),t.jsx(c.Modal.Body,{className:u.default["tedi-date-picker-modal__body"],children:t.jsx(W.Calendar,{...V,numberOfMonths:T,view:F,selectionLevel:f,currentMonth:I,setCurrentMonth:j,setView:M,mode:n,value:a,locale:_,localeCode:w,showOutsideDays:N,disabledMatchers:A,required:p,availableDays:B,footer:O,monthYearSelectType:H,dayStatus:L,showNavigation:P,handleSelect:K,applyValue:z,className:u.default["tedi-date-picker-modal__calendar"],bordered:!1})}),t.jsxs(c.Modal.Footer,{children:[t.jsx(C.Button,{visualType:"secondary",onClick:()=>o(!1),children:b("date-field.cancel")}),t.jsx(C.Button,{onClick:Y,disabled:k,children:b("date-field.confirm")})]})]})})};q.displayName="DatePickerModal";exports.DatePickerModal=q;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { DateRange, DayPickerProps, Locale, Matcher } from 'react-day-picker';
|
|
3
|
+
import { DayStatusFn } from '../../../content/calendar/calendar';
|
|
3
4
|
import { ModalContentProps } from '../../../overlays/modal';
|
|
4
5
|
import { CalendarView } from '../date-field';
|
|
5
6
|
type DateFieldMode = 'single' | 'multiple' | 'range';
|
|
@@ -27,6 +28,8 @@ export interface DatePickerModalProps extends Omit<DayPickerProps, 'mode' | 'sel
|
|
|
27
28
|
availableDays?: Date[] | ((date: Date) => boolean);
|
|
28
29
|
footer?: React.ReactNode;
|
|
29
30
|
monthYearSelectType?: 'dropdown' | 'grid';
|
|
31
|
+
/** Per-day status overlay forwarded to `Calendar`. */
|
|
32
|
+
dayStatus?: DayStatusFn;
|
|
30
33
|
showNavigation?: boolean;
|
|
31
34
|
selectionLevel?: CalendarView;
|
|
32
35
|
/** Grid the calendar opens on, independent of `selectionLevel`. Defaults to `selectionLevel`. */
|