@studiolxd/brand 42.0.0 → 44.0.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.
- package/CHANGELOG.md +113 -0
- package/dist/_shared/datepicker.js +75 -78
- package/dist/_shared/imagecropdialog.js +124 -123
- package/dist/_shared/validate.js +31 -5
- package/dist/_types/atoms/FileUpload/FileUpload.d.ts +79 -11
- package/dist/_types/atoms/FileUpload/validate.d.ts +36 -3
- package/dist/_types/atoms/TimeSelect/TimeSelect.d.ts +34 -6
- package/dist/_types/messages/BrandMessages.d.ts +13 -1
- package/dist/_types/messages/index.d.ts +1 -1
- package/dist/_types/molecules/AvatarUpload/AvatarUpload.d.ts +123 -25
- package/dist/_types/molecules/Calendar/Calendar.d.ts +44 -13
- package/dist/_types/molecules/CalendarPlanner/CalendarPlanner.d.ts +5 -4
- package/dist/_types/molecules/CalendarRoster/CalendarRoster.d.ts +5 -4
- package/dist/_types/molecules/DatePicker/DatePicker.d.ts +56 -26
- package/dist/_types/molecules/DatePicker/dateMask.d.ts +9 -2
- package/dist/_types/molecules/DateTimeField/DateTimeField.d.ts +12 -12
- package/dist/_types/molecules/ImageCropDialog/ImageCropDialog.d.ts +28 -4
- package/dist/_types/molecules/TimeField/TimeField.d.ts +9 -2
- package/dist/_types/molecules/_shared/calendarGrid.d.ts +6 -2
- package/dist/avatar-upload.js +98 -95
- package/dist/calendar-planner.js +47 -46
- package/dist/calendar-roster.js +62 -61
- package/dist/calendar.js +87 -86
- package/dist/file-upload.js +120 -117
- package/dist/time-select.js +57 -56
- package/package.json +1 -1
package/dist/calendar-planner.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import './calendar-planner.css';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { n as e } from "./_shared/brandmessagescontext.js";
|
|
4
|
+
import { VisuallyHidden as t } from "./visually-hidden.js";
|
|
5
|
+
import { Tag as n } from "./tag.js";
|
|
6
|
+
import { Modal as r } from "./modal.js";
|
|
7
|
+
import { c as i, i as a, l as o, n as s, o as c, r as l, s as u, t as d } from "./_shared/calendargrid.js";
|
|
8
|
+
import { useCallback as f, useId as ee, useState as p } from "react";
|
|
8
9
|
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
9
10
|
//#region src/stories/molecules/CalendarPlanner/CalendarPlanner.tsx
|
|
10
|
-
function _({ events: _ = [], renderDay: v, maxItemsPerDay: y = 3, onMoreClick: b, showMoreDialog: x, onDayClick: S, month: C, defaultMonth: w, onMonthChange: T, navigable: E = !0, locale: D = "es-ES", previousMonthLabel: O
|
|
11
|
-
let [
|
|
12
|
-
|
|
13
|
-
}, [T]), H = /* @__PURE__ */ new Date(), U =
|
|
11
|
+
function _({ events: _ = [], renderDay: v, maxItemsPerDay: y = 3, onMoreClick: b, showMoreDialog: x, onDayClick: S, month: C, defaultMonth: w, onMonthChange: T, navigable: E = !0, locale: D = "es-ES", previousMonthLabel: O, nextMonthLabel: k, gridLabel: A, moreLabel: te = (e) => `+${e} más`, size: j = "md", className: M }) {
|
|
12
|
+
let [N, P] = p(() => C ?? w ?? /* @__PURE__ */ new Date()), [F, I] = p(null), L = x ?? !b, R = f(() => I(null), []), z = C ?? N, B = f((e) => {
|
|
13
|
+
P(e), T?.(e);
|
|
14
|
+
}, [T]), V = e("calendar"), H = /* @__PURE__ */ new Date(), U = j === "sm" ? "xs" : j === "lg" ? "md" : "sm", W = new Intl.DateTimeFormat(D, {
|
|
14
15
|
month: "long",
|
|
15
16
|
year: "numeric"
|
|
16
|
-
}).format(
|
|
17
|
+
}).format(z), G = new Intl.DateTimeFormat(D, {
|
|
17
18
|
weekday: "long",
|
|
18
19
|
day: "numeric",
|
|
19
20
|
month: "long",
|
|
@@ -23,27 +24,27 @@ function _({ events: _ = [], renderDay: v, maxItemsPerDay: y = 3, onMoreClick: b
|
|
|
23
24
|
day: "numeric",
|
|
24
25
|
month: "long",
|
|
25
26
|
year: "numeric"
|
|
26
|
-
}), q =
|
|
27
|
-
month:
|
|
28
|
-
onMonthChange:
|
|
27
|
+
}), q = l(D, "short"), J = d(s(z)), Y = i(z, -1), X = i(z, 1), Z = (e) => _.filter((t) => a(t.date, e)), Q = o({
|
|
28
|
+
month: z,
|
|
29
|
+
onMonthChange: B,
|
|
29
30
|
onActivate: S ? (e) => S(e, Z(e)) : void 0
|
|
30
|
-
}), $ = `${
|
|
31
|
+
}), $ = `${ee()}-planner-title-${z.getFullYear()}-${z.getMonth()}`;
|
|
31
32
|
return /* @__PURE__ */ g("div", {
|
|
32
33
|
className: [
|
|
33
34
|
"calendar-planner",
|
|
34
|
-
`calendar-planner--${
|
|
35
|
-
|
|
35
|
+
`calendar-planner--${j}`,
|
|
36
|
+
M
|
|
36
37
|
].filter(Boolean).join(" "),
|
|
37
38
|
children: [
|
|
38
|
-
|
|
39
|
+
c({
|
|
39
40
|
block: "calendar-planner",
|
|
40
41
|
title: W,
|
|
41
42
|
titleId: $,
|
|
42
43
|
navigable: E,
|
|
43
|
-
previousLabel: O,
|
|
44
|
-
nextLabel: k,
|
|
45
|
-
onPrev: () =>
|
|
46
|
-
onNext: () =>
|
|
44
|
+
previousLabel: E ? V("previousMonth", O) : void 0,
|
|
45
|
+
nextLabel: E ? V("nextMonth", k) : void 0,
|
|
46
|
+
onPrev: () => B(Y),
|
|
47
|
+
onNext: () => B(X),
|
|
47
48
|
chevronSize: U
|
|
48
49
|
}),
|
|
49
50
|
/* @__PURE__ */ g("div", {
|
|
@@ -52,65 +53,65 @@ function _({ events: _ = [], renderDay: v, maxItemsPerDay: y = 3, onMoreClick: b
|
|
|
52
53
|
"aria-label": A,
|
|
53
54
|
"aria-labelledby": A ? void 0 : $,
|
|
54
55
|
onKeyDown: S ? Q.onKeyDown : void 0,
|
|
55
|
-
children: [
|
|
56
|
+
children: [u({
|
|
56
57
|
block: "calendar-planner",
|
|
57
58
|
rowModifier: "header",
|
|
58
59
|
weekdays: q
|
|
59
|
-
}), J.map((
|
|
60
|
+
}), J.map((e, r) => /* @__PURE__ */ h("div", {
|
|
60
61
|
role: "row",
|
|
61
62
|
className: "calendar-planner__row",
|
|
62
|
-
children:
|
|
63
|
-
let
|
|
63
|
+
children: e.map(({ date: e, outside: r }) => {
|
|
64
|
+
let i = a(e, H), o = Z(e), s = o.slice(0, y), c = o.length - s.length, l = [
|
|
64
65
|
"calendar-planner__cell",
|
|
65
66
|
r && "calendar-planner__cell--outside",
|
|
66
|
-
|
|
67
|
+
i && "calendar-planner__cell--today"
|
|
67
68
|
].filter(Boolean).join(" "), u = [
|
|
68
69
|
"calendar-planner__day-number",
|
|
69
|
-
|
|
70
|
+
i && "calendar-planner__day-number--today",
|
|
70
71
|
r && "calendar-planner__day-number--outside"
|
|
71
72
|
].filter(Boolean).join(" ");
|
|
72
73
|
return /* @__PURE__ */ g("div", {
|
|
73
|
-
ref: S ? Q.cellRef(
|
|
74
|
+
ref: S ? Q.cellRef(e) : void 0,
|
|
74
75
|
role: "gridcell",
|
|
75
76
|
className: [l, S ? "calendar-planner__cell--clickable" : ""].filter(Boolean).join(" "),
|
|
76
|
-
"aria-current":
|
|
77
|
-
tabIndex: S ? Q.isTabbable(
|
|
78
|
-
onFocus: S ? () => Q.onCellFocus(
|
|
79
|
-
onClick: S ? () => S(
|
|
77
|
+
"aria-current": i ? "date" : void 0,
|
|
78
|
+
tabIndex: S ? Q.isTabbable(e) ? 0 : -1 : void 0,
|
|
79
|
+
onFocus: S ? () => Q.onCellFocus(e) : void 0,
|
|
80
|
+
onClick: S ? () => S(e, o) : void 0,
|
|
80
81
|
children: [/* @__PURE__ */ g("span", {
|
|
81
82
|
className: u,
|
|
82
|
-
children: [/* @__PURE__ */ h(
|
|
83
|
+
children: [/* @__PURE__ */ h(t, { children: G.format(e) }), /* @__PURE__ */ h("span", {
|
|
83
84
|
"aria-hidden": "true",
|
|
84
|
-
children:
|
|
85
|
+
children: e.getDate()
|
|
85
86
|
})]
|
|
86
87
|
}), /* @__PURE__ */ h("div", {
|
|
87
88
|
className: "calendar-planner__cell-body",
|
|
88
|
-
children: v ? v(
|
|
89
|
+
children: v ? v(e, o) : /* @__PURE__ */ g(m, { children: [s.map((e) => /* @__PURE__ */ h(n, {
|
|
89
90
|
variant: e.variant ?? "neutral",
|
|
90
91
|
children: e.label
|
|
91
92
|
}, e.id)), c > 0 && /* @__PURE__ */ h("button", {
|
|
92
93
|
type: "button",
|
|
93
94
|
className: "calendar-planner__more",
|
|
94
|
-
onClick: (
|
|
95
|
-
|
|
96
|
-
date:
|
|
95
|
+
onClick: (t) => {
|
|
96
|
+
t.stopPropagation(), L && I({
|
|
97
|
+
date: e,
|
|
97
98
|
events: o
|
|
98
|
-
}), b?.(
|
|
99
|
+
}), b?.(e, o);
|
|
99
100
|
},
|
|
100
|
-
children:
|
|
101
|
+
children: te(c)
|
|
101
102
|
})] })
|
|
102
103
|
})]
|
|
103
|
-
},
|
|
104
|
+
}, e.toISOString());
|
|
104
105
|
})
|
|
105
106
|
}, r))]
|
|
106
107
|
}),
|
|
107
|
-
/* @__PURE__ */ h(
|
|
108
|
-
open:
|
|
109
|
-
onClose:
|
|
110
|
-
title:
|
|
108
|
+
/* @__PURE__ */ h(r, {
|
|
109
|
+
open: F !== null,
|
|
110
|
+
onClose: R,
|
|
111
|
+
title: F ? K.format(F.date) : void 0,
|
|
111
112
|
children: /* @__PURE__ */ h("div", {
|
|
112
113
|
className: "calendar-planner__modal-events",
|
|
113
|
-
children:
|
|
114
|
+
children: F?.events.map((e) => /* @__PURE__ */ h(n, {
|
|
114
115
|
variant: e.variant ?? "neutral",
|
|
115
116
|
children: e.label
|
|
116
117
|
}, e.id))
|
package/dist/calendar-roster.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import './calendar-roster.css';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { n as e } from "./_shared/brandmessagescontext.js";
|
|
4
|
+
import { Tag as t } from "./tag.js";
|
|
5
|
+
import { PrevNextNav as n } from "./prev-next-nav.js";
|
|
6
|
+
import { c as r, i } from "./_shared/calendargrid.js";
|
|
7
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
8
|
//#region src/stories/molecules/CalendarRoster/CalendarRoster.tsx
|
|
8
|
-
function
|
|
9
|
+
function c(e) {
|
|
9
10
|
let t = e.getDay();
|
|
10
11
|
return t === 0 || t === 6;
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function l(e) {
|
|
13
14
|
let t = e.getFullYear(), n = e.getMonth(), r = new Date(t, n + 1, 0).getDate();
|
|
14
15
|
return Array.from({ length: r }, (e, r) => new Date(t, n, r + 1));
|
|
15
16
|
}
|
|
16
|
-
var
|
|
17
|
+
var u = {
|
|
17
18
|
holiday: "neutral",
|
|
18
19
|
vacation: "info",
|
|
19
20
|
absence: "danger",
|
|
20
21
|
recovery: "success",
|
|
21
22
|
birthday: "info"
|
|
22
|
-
},
|
|
23
|
+
}, d = [
|
|
23
24
|
{
|
|
24
25
|
type: "holiday",
|
|
25
26
|
label: "Festivo"
|
|
@@ -45,67 +46,67 @@ var l = {
|
|
|
45
46
|
label: "No laborable"
|
|
46
47
|
}
|
|
47
48
|
];
|
|
48
|
-
function
|
|
49
|
-
let
|
|
49
|
+
function f({ rows: f, month: p, onMonthChange: m, hrefBuilder: h, linkComponent: g, renderCell: _, nameLabel: v = "Empleado", birthdayPrefix: y = "🎂 ", showLegend: b = !0, locale: x = "es-ES", legendItems: S = d, legendLabel: C = "Leyenda", previousMonthLabel: w, nextMonthLabel: T, className: E }) {
|
|
50
|
+
let D = e("calendar"), O = /* @__PURE__ */ new Date(), k = l(p), A = r(p, -1), j = r(p, 1), M = new Intl.DateTimeFormat(x, {
|
|
50
51
|
month: "long",
|
|
51
52
|
year: "numeric"
|
|
52
|
-
}).format(
|
|
53
|
-
|
|
54
|
-
} : void 0,
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
className: ["calendar-roster",
|
|
53
|
+
}).format(p), N = new Intl.DateTimeFormat(x, { weekday: "narrow" }), P = new Intl.DateTimeFormat(x, { weekday: "long" }), F = m ? (e) => (t) => {
|
|
54
|
+
h && t.preventDefault(), m(e);
|
|
55
|
+
} : void 0, I = `roster-title-${p.getFullYear()}-${p.getMonth()}`;
|
|
56
|
+
return /* @__PURE__ */ s("div", {
|
|
57
|
+
className: ["calendar-roster", E].filter(Boolean).join(" "),
|
|
57
58
|
children: [
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
+
/* @__PURE__ */ o("div", {
|
|
59
60
|
className: "calendar-roster__nav",
|
|
60
|
-
children: /* @__PURE__ */
|
|
61
|
-
label:
|
|
62
|
-
labelId:
|
|
63
|
-
prevHref:
|
|
64
|
-
nextHref:
|
|
65
|
-
prevOnClick:
|
|
66
|
-
nextOnClick:
|
|
67
|
-
prevLabel:
|
|
68
|
-
nextLabel:
|
|
69
|
-
linkComponent:
|
|
61
|
+
children: /* @__PURE__ */ o(n, {
|
|
62
|
+
label: M,
|
|
63
|
+
labelId: I,
|
|
64
|
+
prevHref: h?.(A),
|
|
65
|
+
nextHref: h?.(j),
|
|
66
|
+
prevOnClick: F?.(A),
|
|
67
|
+
nextOnClick: F?.(j),
|
|
68
|
+
prevLabel: D("previousMonth", w),
|
|
69
|
+
nextLabel: D("nextMonth", T),
|
|
70
|
+
linkComponent: g
|
|
70
71
|
})
|
|
71
72
|
}),
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
+
/* @__PURE__ */ o("div", {
|
|
73
74
|
className: "calendar-roster__wrap",
|
|
74
|
-
children: /* @__PURE__ */
|
|
75
|
+
children: /* @__PURE__ */ s("table", {
|
|
75
76
|
className: "calendar-roster__table",
|
|
76
|
-
"aria-labelledby":
|
|
77
|
-
children: [/* @__PURE__ */
|
|
77
|
+
"aria-labelledby": I,
|
|
78
|
+
children: [/* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", {
|
|
78
79
|
className: "calendar-roster__th-name",
|
|
79
80
|
scope: "col",
|
|
80
|
-
children:
|
|
81
|
-
}),
|
|
82
|
-
let t =
|
|
81
|
+
children: v
|
|
82
|
+
}), k.map((e) => {
|
|
83
|
+
let t = i(e, O), n = [
|
|
83
84
|
"calendar-roster__th-day",
|
|
84
|
-
|
|
85
|
+
c(e) && "calendar-roster__th-day--weekend",
|
|
85
86
|
t && "calendar-roster__th-day--today"
|
|
86
|
-
].filter(Boolean).join(" "),
|
|
87
|
-
return /* @__PURE__ */
|
|
87
|
+
].filter(Boolean).join(" "), r = String(e.getDate()).padStart(2, "0"), a = N.format(e), l = P.format(e);
|
|
88
|
+
return /* @__PURE__ */ s("th", {
|
|
88
89
|
className: n,
|
|
89
90
|
scope: "col",
|
|
90
|
-
children: [/* @__PURE__ */
|
|
91
|
+
children: [/* @__PURE__ */ o("div", {
|
|
91
92
|
className: "calendar-roster__th-day-number",
|
|
92
|
-
children:
|
|
93
|
-
}), /* @__PURE__ */
|
|
93
|
+
children: r
|
|
94
|
+
}), /* @__PURE__ */ o("div", {
|
|
94
95
|
className: "calendar-roster__th-day-sub",
|
|
95
|
-
children: /* @__PURE__ */
|
|
96
|
+
children: /* @__PURE__ */ o("abbr", {
|
|
96
97
|
title: l,
|
|
97
|
-
children:
|
|
98
|
+
children: a
|
|
98
99
|
})
|
|
99
100
|
})]
|
|
100
101
|
}, e.getDate());
|
|
101
|
-
})] }) }), /* @__PURE__ */
|
|
102
|
+
})] }) }), /* @__PURE__ */ o("tbody", { children: f.map((e) => /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", {
|
|
102
103
|
scope: "row",
|
|
103
104
|
className: "calendar-roster__th-name-row",
|
|
104
|
-
title:
|
|
105
|
-
children:
|
|
106
|
-
}),
|
|
107
|
-
let
|
|
108
|
-
return /* @__PURE__ */
|
|
105
|
+
title: e.name,
|
|
106
|
+
children: e.name
|
|
107
|
+
}), k.map((n) => {
|
|
108
|
+
let r = n.getDate(), l = e.cells[r] ?? null, d = c(n), f = i(n, O), p = l?.type === "holiday", m = l?.type === "non-working";
|
|
109
|
+
return /* @__PURE__ */ o("td", {
|
|
109
110
|
className: [
|
|
110
111
|
"calendar-roster__cell",
|
|
111
112
|
d && "calendar-roster__cell--weekend",
|
|
@@ -113,31 +114,31 @@ function d({ rows: d, month: f, onMonthChange: p, hrefBuilder: m, linkComponent:
|
|
|
113
114
|
m && "calendar-roster__cell--non-working",
|
|
114
115
|
f && "calendar-roster__cell--today"
|
|
115
116
|
].filter(Boolean).join(" "),
|
|
116
|
-
children:
|
|
117
|
+
children: _ ? _(r, n, l) : /* @__PURE__ */ s(a, { children: [l?.type === "schedule" && /* @__PURE__ */ o("span", {
|
|
117
118
|
className: "calendar-roster__schedule",
|
|
118
|
-
children:
|
|
119
|
-
}),
|
|
120
|
-
variant: l
|
|
121
|
-
children:
|
|
119
|
+
children: l.label
|
|
120
|
+
}), l && l.type !== "schedule" && l.type !== "non-working" && /* @__PURE__ */ o(t, {
|
|
121
|
+
variant: u[l.type],
|
|
122
|
+
children: l.type === "birthday" ? `${y}${l.label}` : l.label
|
|
122
123
|
})] })
|
|
123
|
-
},
|
|
124
|
-
})] },
|
|
124
|
+
}, r);
|
|
125
|
+
})] }, e.id)) })]
|
|
125
126
|
})
|
|
126
127
|
}),
|
|
127
|
-
|
|
128
|
+
b && /* @__PURE__ */ o("div", {
|
|
128
129
|
className: "calendar-roster__legend",
|
|
129
130
|
role: "group",
|
|
130
|
-
"aria-label":
|
|
131
|
-
children:
|
|
131
|
+
"aria-label": C,
|
|
132
|
+
children: S.map(({ type: e, label: n }) => /* @__PURE__ */ o("span", {
|
|
132
133
|
className: "calendar-roster__legend-item",
|
|
133
|
-
children:
|
|
134
|
-
variant:
|
|
134
|
+
children: e === "non-working" ? /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("span", { className: "calendar-roster__legend-swatch calendar-roster__legend-swatch--non-working" }), n] }) : /* @__PURE__ */ o(t, {
|
|
135
|
+
variant: u[e],
|
|
135
136
|
children: n
|
|
136
137
|
})
|
|
137
|
-
},
|
|
138
|
+
}, e))
|
|
138
139
|
})
|
|
139
140
|
]
|
|
140
141
|
});
|
|
141
142
|
}
|
|
142
143
|
//#endregion
|
|
143
|
-
export {
|
|
144
|
+
export { f as CalendarRoster };
|
package/dist/calendar.js
CHANGED
|
@@ -1,121 +1,122 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import './calendar.css';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { n as e } from "./_shared/brandmessagescontext.js";
|
|
4
|
+
import { a as t, c as n, i as r, l as i, n as a, o, r as ee, s as te, t as ne } from "./_shared/calendargrid.js";
|
|
5
|
+
import { useCallback as s, useEffect as c, useId as l, useRef as u, useState as d } from "react";
|
|
6
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
7
|
//#region src/stories/molecules/Calendar/Calendar.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
return Math.floor(e /
|
|
8
|
+
var m = 12, h = 4;
|
|
9
|
+
function g(e) {
|
|
10
|
+
return Math.floor(e / m) * m;
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
let [
|
|
13
|
-
|
|
14
|
-
}, [
|
|
12
|
+
function _({ value: _, onChange: re, defaultMonth: ie, month: v, onMonthChange: y, navigable: b = !0, disabledDates: x, minDate: S, maxDate: C, locale: w = "es-ES", previousMonthLabel: ae, nextMonthLabel: oe, previousYearsLabel: T, nextYearsLabel: E, yearGridLabel: D, gridLabel: O, size: k = "md", className: A }) {
|
|
13
|
+
let j = e("calendar"), [se, ce] = d(() => v ?? ie ?? (_ instanceof Date ? _ : /* @__PURE__ */ new Date())), M = v ?? se, N = s((e) => {
|
|
14
|
+
ce(e), y?.(e);
|
|
15
|
+
}, [y]), P = /* @__PURE__ */ new Date(), le = s((e) => S && e < S || C && e > C ? !0 : Array.isArray(x) ? x.some((t) => r(t, e)) : typeof x == "function" ? x(e) : !1, [
|
|
15
16
|
x,
|
|
16
17
|
S,
|
|
17
18
|
C
|
|
18
|
-
]),
|
|
19
|
-
month:
|
|
20
|
-
onMonthChange:
|
|
21
|
-
selected:
|
|
19
|
+
]), F = i({
|
|
20
|
+
month: M,
|
|
21
|
+
onMonthChange: N,
|
|
22
|
+
selected: _ ?? null,
|
|
22
23
|
minDate: S,
|
|
23
24
|
maxDate: C
|
|
24
|
-
}), [
|
|
25
|
-
let e =
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
-
|
|
29
|
-
}, []),
|
|
30
|
-
|
|
25
|
+
}), [I, L] = d("days"), [R, z] = d(() => g(M.getFullYear())), [B, V] = d(() => M.getFullYear()), H = u(null), U = u(/* @__PURE__ */ new Map()), W = u(null), ue = s(() => {
|
|
26
|
+
let e = M.getFullYear();
|
|
27
|
+
z(g(e)), V(e), W.current = "year", L("years");
|
|
28
|
+
}, [M]), G = s(() => {
|
|
29
|
+
W.current = "title", L("days");
|
|
30
|
+
}, []), de = s((e) => {
|
|
31
|
+
N(new Date(e, M.getMonth(), 1)), G();
|
|
31
32
|
}, [
|
|
32
33
|
G,
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
M,
|
|
35
|
+
N
|
|
35
36
|
]);
|
|
36
37
|
c(() => {
|
|
37
|
-
if (!
|
|
38
|
-
let e =
|
|
39
|
-
|
|
40
|
-
}, [
|
|
41
|
-
let
|
|
38
|
+
if (!W.current) return;
|
|
39
|
+
let e = W.current;
|
|
40
|
+
W.current = null, e === "title" ? H.current?.focus() : U.current.get(B)?.focus();
|
|
41
|
+
}, [I, B]);
|
|
42
|
+
let fe = k === "sm" ? "xs" : k === "lg" ? "md" : "sm", pe = new Intl.DateTimeFormat(w, {
|
|
42
43
|
month: "long",
|
|
43
44
|
year: "numeric"
|
|
44
|
-
}).format(
|
|
45
|
+
}).format(M), me = new Intl.DateTimeFormat(w, { year: "numeric" }), K = (e) => me.format(new Date(e, 0, 1)), he = Array.from({ length: m }, (e, t) => R + t), ge = `${K(R)}–${K(R + m - 1)}`, _e = new Intl.DateTimeFormat(w, {
|
|
45
46
|
weekday: "long",
|
|
46
47
|
day: "numeric",
|
|
47
48
|
month: "long",
|
|
48
49
|
year: "numeric"
|
|
49
|
-
}),
|
|
50
|
-
(e <
|
|
51
|
-
},
|
|
50
|
+
}), ve = ee(w, "narrow"), ye = ne(a(M)), q = n(M, -1), J = n(M, 1), be = S ? !t(q, S) && q < S : !1, xe = C ? !t(J, C) && J > C : !1, Se = (e) => (S ? e < S.getFullYear() : !1) || (C ? e > C.getFullYear() : !1), Ce = S ? R - 1 < S.getFullYear() : !1, we = C ? R + m > C.getFullYear() : !1, Y = I === "years", X = B >= R && B <= R + m - 1 ? B : R, Te = (e) => {
|
|
51
|
+
(e < R || e > R + m - 1) && z(g(e)), W.current = "year", V(e);
|
|
52
|
+
}, Z = (e) => {
|
|
52
53
|
let t = null;
|
|
53
54
|
switch (e.key) {
|
|
54
55
|
case "ArrowLeft":
|
|
55
|
-
t =
|
|
56
|
+
t = X - 1;
|
|
56
57
|
break;
|
|
57
58
|
case "ArrowRight":
|
|
58
|
-
t =
|
|
59
|
+
t = X + 1;
|
|
59
60
|
break;
|
|
60
61
|
case "ArrowUp":
|
|
61
|
-
t =
|
|
62
|
+
t = X - h;
|
|
62
63
|
break;
|
|
63
64
|
case "ArrowDown":
|
|
64
|
-
t =
|
|
65
|
+
t = X + h;
|
|
65
66
|
break;
|
|
66
67
|
case "Home":
|
|
67
|
-
t =
|
|
68
|
+
t = R;
|
|
68
69
|
break;
|
|
69
70
|
case "End":
|
|
70
|
-
t =
|
|
71
|
+
t = R + m - 1;
|
|
71
72
|
break;
|
|
72
73
|
case "PageUp":
|
|
73
|
-
t =
|
|
74
|
+
t = X - m;
|
|
74
75
|
break;
|
|
75
76
|
case "PageDown":
|
|
76
|
-
t =
|
|
77
|
+
t = X + m;
|
|
77
78
|
break;
|
|
78
79
|
case "Escape":
|
|
79
80
|
e.preventDefault(), G();
|
|
80
81
|
return;
|
|
81
82
|
default: return;
|
|
82
83
|
}
|
|
83
|
-
e.preventDefault(),
|
|
84
|
-
}, Q =
|
|
85
|
-
return /* @__PURE__ */
|
|
84
|
+
e.preventDefault(), Te(t);
|
|
85
|
+
}, Q = l(), $ = Y ? `${Q}-calendar-title-${R}` : `${Q}-calendar-title-${M.getFullYear()}-${M.getMonth()}`;
|
|
86
|
+
return /* @__PURE__ */ p("div", {
|
|
86
87
|
className: [
|
|
87
88
|
"calendar",
|
|
88
|
-
`calendar--${
|
|
89
|
-
|
|
89
|
+
`calendar--${k}`,
|
|
90
|
+
A
|
|
90
91
|
].filter(Boolean).join(" "),
|
|
91
|
-
children: [
|
|
92
|
+
children: [o({
|
|
92
93
|
block: "calendar",
|
|
93
|
-
title:
|
|
94
|
+
title: Y ? ge : pe,
|
|
94
95
|
titleId: $,
|
|
95
|
-
navigable:
|
|
96
|
-
previousLabel:
|
|
97
|
-
nextLabel:
|
|
98
|
-
prevDisabled:
|
|
99
|
-
nextDisabled:
|
|
100
|
-
onPrev:
|
|
101
|
-
onNext:
|
|
102
|
-
chevronSize:
|
|
103
|
-
onTitleClick:
|
|
104
|
-
titleExpanded:
|
|
105
|
-
titleRef:
|
|
106
|
-
}),
|
|
96
|
+
navigable: b,
|
|
97
|
+
previousLabel: b ? Y ? j("previousYears", T) : j("previousMonth", ae) : void 0,
|
|
98
|
+
nextLabel: b ? Y ? j("nextYears", E) : j("nextMonth", oe) : void 0,
|
|
99
|
+
prevDisabled: Y ? Ce : be,
|
|
100
|
+
nextDisabled: Y ? we : xe,
|
|
101
|
+
onPrev: Y ? () => z(R - m) : () => N(q),
|
|
102
|
+
onNext: Y ? () => z(R + m) : () => N(J),
|
|
103
|
+
chevronSize: fe,
|
|
104
|
+
onTitleClick: Y ? G : ue,
|
|
105
|
+
titleExpanded: Y,
|
|
106
|
+
titleRef: H
|
|
107
|
+
}), Y ? /* @__PURE__ */ f("div", {
|
|
107
108
|
className: "calendar__years",
|
|
108
109
|
role: "grid",
|
|
109
|
-
"aria-label":
|
|
110
|
-
onKeyDown:
|
|
111
|
-
children: Array.from({ length:
|
|
110
|
+
"aria-label": j("yearGrid", D),
|
|
111
|
+
onKeyDown: Z,
|
|
112
|
+
children: Array.from({ length: m / h }, (e, t) => /* @__PURE__ */ f("div", {
|
|
112
113
|
role: "row",
|
|
113
114
|
className: "calendar__row",
|
|
114
|
-
children:
|
|
115
|
-
let t =
|
|
116
|
-
return /* @__PURE__ */
|
|
115
|
+
children: he.slice(t * h, t * h + h).map((e) => {
|
|
116
|
+
let t = Se(e), n = e === P.getFullYear(), r = _ instanceof Date ? _.getFullYear() === e : !1;
|
|
117
|
+
return /* @__PURE__ */ f("button", {
|
|
117
118
|
ref: (t) => {
|
|
118
|
-
t ?
|
|
119
|
+
t ? U.current.set(e, t) : U.current.delete(e);
|
|
119
120
|
},
|
|
120
121
|
type: "button",
|
|
121
122
|
role: "gridcell",
|
|
@@ -128,45 +129,45 @@ function g({ value: g, onChange: _, defaultMonth: v, month: y, onMonthChange: b,
|
|
|
128
129
|
"aria-selected": r,
|
|
129
130
|
"aria-disabled": t ? "true" : void 0,
|
|
130
131
|
"aria-current": n ? "date" : void 0,
|
|
131
|
-
tabIndex: e ===
|
|
132
|
-
onFocus: () =>
|
|
133
|
-
onClick: t ? void 0 : () =>
|
|
132
|
+
tabIndex: e === X ? 0 : -1,
|
|
133
|
+
onFocus: () => V(e),
|
|
134
|
+
onClick: t ? void 0 : () => de(e),
|
|
134
135
|
children: K(e)
|
|
135
136
|
}, e);
|
|
136
137
|
})
|
|
137
138
|
}, t))
|
|
138
|
-
}) : /* @__PURE__ */
|
|
139
|
+
}) : /* @__PURE__ */ p("div", {
|
|
139
140
|
className: "calendar__grid",
|
|
140
141
|
role: "grid",
|
|
141
|
-
"aria-label":
|
|
142
|
-
"aria-labelledby":
|
|
143
|
-
onKeyDown:
|
|
144
|
-
children: [
|
|
142
|
+
"aria-label": O,
|
|
143
|
+
"aria-labelledby": O ? void 0 : $,
|
|
144
|
+
onKeyDown: F.onKeyDown,
|
|
145
|
+
children: [te({
|
|
145
146
|
block: "calendar",
|
|
146
|
-
weekdays:
|
|
147
|
-
}),
|
|
147
|
+
weekdays: ve
|
|
148
|
+
}), ye.map((e, t) => /* @__PURE__ */ f("div", {
|
|
148
149
|
role: "row",
|
|
149
150
|
className: "calendar__row",
|
|
150
151
|
children: e.map(({ date: e, outside: t }) => {
|
|
151
|
-
let
|
|
152
|
+
let n = le(e), i = r(e, P), a = _ instanceof Date ? r(e, _) : !1, o = [
|
|
152
153
|
"calendar__day",
|
|
153
154
|
t && "calendar__day--outside",
|
|
154
155
|
i && "calendar__day--today",
|
|
155
156
|
a && "calendar__day--selected",
|
|
156
|
-
|
|
157
|
+
n && "calendar__day--disabled"
|
|
157
158
|
].filter(Boolean).join(" ");
|
|
158
|
-
return /* @__PURE__ */
|
|
159
|
-
ref:
|
|
159
|
+
return /* @__PURE__ */ f("button", {
|
|
160
|
+
ref: F.cellRef(e),
|
|
160
161
|
type: "button",
|
|
161
162
|
role: "gridcell",
|
|
162
163
|
className: o,
|
|
163
|
-
"aria-label":
|
|
164
|
+
"aria-label": _e.format(e),
|
|
164
165
|
"aria-selected": a,
|
|
165
|
-
"aria-disabled":
|
|
166
|
+
"aria-disabled": n ? "true" : void 0,
|
|
166
167
|
"aria-current": i ? "date" : void 0,
|
|
167
|
-
tabIndex:
|
|
168
|
-
onFocus: () =>
|
|
169
|
-
onClick:
|
|
168
|
+
tabIndex: F.isTabbable(e) ? 0 : -1,
|
|
169
|
+
onFocus: () => F.onCellFocus(e),
|
|
170
|
+
onClick: n ? void 0 : () => re?.(e),
|
|
170
171
|
children: e.getDate()
|
|
171
172
|
}, e.toISOString());
|
|
172
173
|
})
|
|
@@ -175,4 +176,4 @@ function g({ value: g, onChange: _, defaultMonth: v, month: y, onMonthChange: b,
|
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
//#endregion
|
|
178
|
-
export {
|
|
179
|
+
export { _ as Calendar };
|