jvetrau-ds 0.1.39 → 0.1.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.
- package/components/calendar-month/calendar-month.cjs +366 -0
- package/components/calendar-month/calendar-month.cjs.map +1 -0
- package/components/calendar-month/calendar-month.css +237 -0
- package/components/calendar-month/calendar-month.d.ts +42 -0
- package/components/calendar-month/calendar-month.js +360 -0
- package/components/calendar-month/calendar-month.js.map +1 -0
- package/components/calendar-month/index.cjs +16 -0
- package/components/calendar-month/index.cjs.map +1 -0
- package/components/calendar-month/index.d.ts +2 -0
- package/components/calendar-month/index.js +3 -0
- package/components/calendar-month/index.js.map +1 -0
- package/components/course-outline/course-outline.cjs +196 -0
- package/components/course-outline/course-outline.cjs.map +1 -0
- package/components/course-outline/course-outline.css +616 -0
- package/components/course-outline/course-outline.d.ts +27 -0
- package/components/course-outline/course-outline.js +190 -0
- package/components/course-outline/course-outline.js.map +1 -0
- package/components/course-outline/index.cjs +13 -0
- package/components/course-outline/index.cjs.map +1 -0
- package/components/course-outline/index.d.ts +2 -0
- package/components/course-outline/index.js +3 -0
- package/components/course-outline/index.js.map +1 -0
- package/components/discussion/discussion.cjs +63 -0
- package/components/discussion/discussion.cjs.map +1 -0
- package/components/discussion/discussion.css +167 -0
- package/components/discussion/discussion.d.ts +14 -0
- package/components/discussion/discussion.js +61 -0
- package/components/discussion/discussion.js.map +1 -0
- package/components/discussion/index.cjs +13 -0
- package/components/discussion/index.cjs.map +1 -0
- package/components/discussion/index.d.ts +2 -0
- package/components/discussion/index.js +3 -0
- package/components/discussion/index.js.map +1 -0
- package/components/index.cjs +19 -0
- package/components/index.d.ts +5 -0
- package/components/index.js +3 -0
- package/index.cjs +19 -0
- package/index.d.ts +5 -0
- package/index.js +3 -0
- package/package.json +1 -1
- package/styles.css +1026 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
require('./calendar-month.css');
|
|
6
|
+
var classnames = require('../helpers/classnames');
|
|
7
|
+
|
|
8
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
11
|
+
|
|
12
|
+
const isoDatePattern = /^(\d{4})-(\d{2})-(\d{2})$/u;
|
|
13
|
+
function isValidDateParts(year, monthIndex, day) {
|
|
14
|
+
const date = new Date(
|
|
15
|
+
year,
|
|
16
|
+
monthIndex,
|
|
17
|
+
day,
|
|
18
|
+
12
|
|
19
|
+
);
|
|
20
|
+
return date.getFullYear() === year && date.getMonth() === monthIndex && date.getDate() === day;
|
|
21
|
+
}
|
|
22
|
+
function parseCalendarDate(value) {
|
|
23
|
+
if (value instanceof Date) {
|
|
24
|
+
if (Number.isNaN(value.getTime())) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
year: value.getFullYear(),
|
|
29
|
+
monthIndex: value.getMonth(),
|
|
30
|
+
day: value.getDate()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const match = isoDatePattern.exec(value);
|
|
34
|
+
if (!match) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const year = Number(match[1]);
|
|
38
|
+
const monthIndex = Number(match[2]) - 1;
|
|
39
|
+
const day = Number(match[3]);
|
|
40
|
+
if (!isValidDateParts(
|
|
41
|
+
year,
|
|
42
|
+
monthIndex,
|
|
43
|
+
day
|
|
44
|
+
)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
year,
|
|
49
|
+
monthIndex,
|
|
50
|
+
day
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function createLocalDate(date) {
|
|
54
|
+
return new Date(
|
|
55
|
+
date.year,
|
|
56
|
+
date.monthIndex,
|
|
57
|
+
date.day,
|
|
58
|
+
12
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
function createDateKey(date) {
|
|
62
|
+
return [
|
|
63
|
+
String(date.year).padStart(4, "0"),
|
|
64
|
+
String(date.monthIndex + 1).padStart(
|
|
65
|
+
2,
|
|
66
|
+
"0"
|
|
67
|
+
),
|
|
68
|
+
String(date.day).padStart(2, "0")
|
|
69
|
+
].join("-");
|
|
70
|
+
}
|
|
71
|
+
function createMonthKey(date) {
|
|
72
|
+
return [
|
|
73
|
+
String(date.year).padStart(4, "0"),
|
|
74
|
+
String(date.monthIndex + 1).padStart(
|
|
75
|
+
2,
|
|
76
|
+
"0"
|
|
77
|
+
)
|
|
78
|
+
].join("-");
|
|
79
|
+
}
|
|
80
|
+
function isSameMonth(first, second) {
|
|
81
|
+
return first.year === second.year && first.monthIndex === second.monthIndex;
|
|
82
|
+
}
|
|
83
|
+
function getDaysInMonth(year, monthIndex) {
|
|
84
|
+
return new Date(
|
|
85
|
+
year,
|
|
86
|
+
monthIndex + 1,
|
|
87
|
+
0,
|
|
88
|
+
12
|
|
89
|
+
).getDate();
|
|
90
|
+
}
|
|
91
|
+
function buildCalendarDays(month, weekStartsOn) {
|
|
92
|
+
const firstDayOfMonth = new Date(
|
|
93
|
+
month.year,
|
|
94
|
+
month.monthIndex,
|
|
95
|
+
1,
|
|
96
|
+
12
|
|
97
|
+
);
|
|
98
|
+
const leadingEmptyCellCount = (firstDayOfMonth.getDay() - weekStartsOn + 7) % 7;
|
|
99
|
+
const daysInMonth = getDaysInMonth(
|
|
100
|
+
month.year,
|
|
101
|
+
month.monthIndex
|
|
102
|
+
);
|
|
103
|
+
const cellCount = Math.ceil(
|
|
104
|
+
(leadingEmptyCellCount + daysInMonth) / 7
|
|
105
|
+
) * 7;
|
|
106
|
+
return Array.from(
|
|
107
|
+
{
|
|
108
|
+
length: cellCount
|
|
109
|
+
},
|
|
110
|
+
(_, cellIndex) => {
|
|
111
|
+
const day = cellIndex - leadingEmptyCellCount + 1;
|
|
112
|
+
if (day < 1 || day > daysInMonth) {
|
|
113
|
+
return {
|
|
114
|
+
key: `empty-${cellIndex}`,
|
|
115
|
+
date: null
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const date = {
|
|
119
|
+
year: month.year,
|
|
120
|
+
monthIndex: month.monthIndex,
|
|
121
|
+
day
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
key: createDateKey(date),
|
|
125
|
+
date
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
function chunkCalendarDays(days) {
|
|
131
|
+
const weeks = [];
|
|
132
|
+
for (let index = 0; index < days.length; index += 7) {
|
|
133
|
+
weeks.push(days.slice(index, index + 7));
|
|
134
|
+
}
|
|
135
|
+
return weeks;
|
|
136
|
+
}
|
|
137
|
+
function getWeekdayDates(weekStartsOn) {
|
|
138
|
+
const sunday = new Date(
|
|
139
|
+
2024,
|
|
140
|
+
0,
|
|
141
|
+
7,
|
|
142
|
+
12
|
|
143
|
+
);
|
|
144
|
+
return Array.from(
|
|
145
|
+
{
|
|
146
|
+
length: 7
|
|
147
|
+
},
|
|
148
|
+
(_, index) => {
|
|
149
|
+
const weekday = new Date(sunday);
|
|
150
|
+
weekday.setDate(
|
|
151
|
+
sunday.getDate() + weekStartsOn + index
|
|
152
|
+
);
|
|
153
|
+
return weekday;
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function createWeekdayLabels(formatters, weekStartsOn) {
|
|
158
|
+
return getWeekdayDates(
|
|
159
|
+
weekStartsOn
|
|
160
|
+
).map((date) => ({
|
|
161
|
+
key: String(date.getDay()),
|
|
162
|
+
short: formatters.weekdayShort.format(
|
|
163
|
+
date
|
|
164
|
+
),
|
|
165
|
+
long: formatters.weekdayLong.format(
|
|
166
|
+
date
|
|
167
|
+
)
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
function createMarkedDateKeys(markedDates, month) {
|
|
171
|
+
const keys = /* @__PURE__ */ new Set();
|
|
172
|
+
for (const value of markedDates) {
|
|
173
|
+
const date = parseCalendarDate(value);
|
|
174
|
+
if (date && isSameMonth(date, month)) {
|
|
175
|
+
keys.add(createDateKey(date));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return keys;
|
|
179
|
+
}
|
|
180
|
+
function createFormatters(locale) {
|
|
181
|
+
try {
|
|
182
|
+
return {
|
|
183
|
+
month: new Intl.DateTimeFormat(
|
|
184
|
+
locale,
|
|
185
|
+
{
|
|
186
|
+
month: "long"
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
fullDate: new Intl.DateTimeFormat(
|
|
190
|
+
locale,
|
|
191
|
+
{
|
|
192
|
+
year: "numeric",
|
|
193
|
+
month: "long",
|
|
194
|
+
day: "numeric"
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
weekdayShort: new Intl.DateTimeFormat(
|
|
198
|
+
locale,
|
|
199
|
+
{
|
|
200
|
+
weekday: "short"
|
|
201
|
+
}
|
|
202
|
+
),
|
|
203
|
+
weekdayLong: new Intl.DateTimeFormat(
|
|
204
|
+
locale,
|
|
205
|
+
{
|
|
206
|
+
weekday: "long"
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
};
|
|
210
|
+
} catch {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const CalendarMonth = ({
|
|
215
|
+
month,
|
|
216
|
+
markedDates = [],
|
|
217
|
+
markedDateLabel = "\u041E\u0442\u043C\u0435\u0447\u0435\u043D\u043D\u0430\u044F \u0434\u0430\u0442\u0430",
|
|
218
|
+
locale = "ru-RU",
|
|
219
|
+
weekStartsOn = 1,
|
|
220
|
+
className = "",
|
|
221
|
+
...props
|
|
222
|
+
}) => {
|
|
223
|
+
const parsedMonth = parseCalendarDate(month);
|
|
224
|
+
const componentId = React__default.default.useId();
|
|
225
|
+
if (!parsedMonth) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
const formatters = createFormatters(locale);
|
|
229
|
+
if (!formatters) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
const normalizedMonth = {
|
|
233
|
+
year: parsedMonth.year,
|
|
234
|
+
monthIndex: parsedMonth.monthIndex,
|
|
235
|
+
day: 1
|
|
236
|
+
};
|
|
237
|
+
const monthKey = createMonthKey(normalizedMonth);
|
|
238
|
+
const monthTitleId = `${componentId}-${monthKey}-title`;
|
|
239
|
+
const monthTitle = formatters.month.format(
|
|
240
|
+
createLocalDate(normalizedMonth)
|
|
241
|
+
);
|
|
242
|
+
const weekdayLabels = createWeekdayLabels(
|
|
243
|
+
formatters,
|
|
244
|
+
weekStartsOn
|
|
245
|
+
);
|
|
246
|
+
const calendarDays = buildCalendarDays(
|
|
247
|
+
normalizedMonth,
|
|
248
|
+
weekStartsOn
|
|
249
|
+
);
|
|
250
|
+
const weeks = chunkCalendarDays(calendarDays);
|
|
251
|
+
const markedDateKeys = createMarkedDateKeys(
|
|
252
|
+
markedDates,
|
|
253
|
+
normalizedMonth
|
|
254
|
+
);
|
|
255
|
+
const classes = classnames.classnames(
|
|
256
|
+
"calendar-month",
|
|
257
|
+
className,
|
|
258
|
+
{}
|
|
259
|
+
);
|
|
260
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
261
|
+
"div",
|
|
262
|
+
{
|
|
263
|
+
className: classes,
|
|
264
|
+
...props,
|
|
265
|
+
children: [
|
|
266
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
267
|
+
"div",
|
|
268
|
+
{
|
|
269
|
+
className: "calendar-month__title",
|
|
270
|
+
id: monthTitleId,
|
|
271
|
+
children: monthTitle
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
275
|
+
"table",
|
|
276
|
+
{
|
|
277
|
+
className: "calendar-month__table",
|
|
278
|
+
"aria-labelledby": monthTitleId,
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: weekdayLabels.map(
|
|
281
|
+
(weekday) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
282
|
+
"th",
|
|
283
|
+
{
|
|
284
|
+
className: "calendar-month__weekday",
|
|
285
|
+
scope: "col",
|
|
286
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
287
|
+
"abbr",
|
|
288
|
+
{
|
|
289
|
+
title: weekday.long,
|
|
290
|
+
children: weekday.short
|
|
291
|
+
}
|
|
292
|
+
)
|
|
293
|
+
},
|
|
294
|
+
weekday.key
|
|
295
|
+
)
|
|
296
|
+
) }) }),
|
|
297
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: weeks.map(
|
|
298
|
+
(week, weekIndex) => /* @__PURE__ */ jsxRuntime.jsx("tr", { children: week.map((calendarDay) => {
|
|
299
|
+
if (!calendarDay.date) {
|
|
300
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
301
|
+
"td",
|
|
302
|
+
{
|
|
303
|
+
className: "calendar-month__cell calendar-month__cell--empty",
|
|
304
|
+
"aria-hidden": "true"
|
|
305
|
+
},
|
|
306
|
+
calendarDay.key
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
const dateKey = createDateKey(
|
|
310
|
+
calendarDay.date
|
|
311
|
+
);
|
|
312
|
+
const isMarked = markedDateKeys.has(
|
|
313
|
+
dateKey
|
|
314
|
+
);
|
|
315
|
+
const fullDate = formatters.fullDate.format(
|
|
316
|
+
createLocalDate(
|
|
317
|
+
calendarDay.date
|
|
318
|
+
)
|
|
319
|
+
);
|
|
320
|
+
const accessibleLabel = isMarked ? `${fullDate}: ${markedDateLabel}` : fullDate;
|
|
321
|
+
const dateClasses = classnames.classnames(
|
|
322
|
+
"calendar-month__date",
|
|
323
|
+
"",
|
|
324
|
+
{
|
|
325
|
+
"calendar-month__date--marked": isMarked
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
329
|
+
"td",
|
|
330
|
+
{
|
|
331
|
+
className: "calendar-month__cell",
|
|
332
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
333
|
+
"time",
|
|
334
|
+
{
|
|
335
|
+
className: dateClasses,
|
|
336
|
+
dateTime: dateKey,
|
|
337
|
+
"aria-label": accessibleLabel,
|
|
338
|
+
children: [
|
|
339
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: calendarDay.date.day }),
|
|
340
|
+
isMarked && /* @__PURE__ */ jsxRuntime.jsx(
|
|
341
|
+
"span",
|
|
342
|
+
{
|
|
343
|
+
className: "calendar-month__marker",
|
|
344
|
+
"aria-hidden": "true"
|
|
345
|
+
}
|
|
346
|
+
)
|
|
347
|
+
]
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
},
|
|
351
|
+
calendarDay.key
|
|
352
|
+
);
|
|
353
|
+
}) }, `week-${weekIndex}`)
|
|
354
|
+
) })
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
);
|
|
361
|
+
};
|
|
362
|
+
var calendar_month_default = CalendarMonth;
|
|
363
|
+
|
|
364
|
+
module.exports = calendar_month_default;
|
|
365
|
+
//# sourceMappingURL=calendar-month.cjs.map
|
|
366
|
+
//# sourceMappingURL=calendar-month.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/calendar-month/calendar-month.tsx"],"names":["React","classnames","jsxs","jsx"],"mappings":";;;;;;;;;;;AA6EA,MAAM,cAAA,GACJ,4BAAA;AAEF,SAAS,gBAAA,CACP,IAAA,EACA,UAAA,EACA,GAAA,EACS;AACT,EAAA,MAAM,OAAO,IAAI,IAAA;AAAA,IACf,IAAA;AAAA,IACA,UAAA;AAAA,IACA,GAAA;AAAA,IACA;AAAA,GACF;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AGF,QAAA,EAAA;AAAA,4CAAAC,cAAA,CAAC,MAAA,EAAA,EAAK,aAAA,EAAY,MAAA,EAEd,QAAA,EAAA,WAAA,CAAY,KACT,GAAA,EAEP,CAAA;AAAA,4BAEC,QAAA,oBACCA,cAAA;AAAA,8BAAC,MAAA;AAAA,8BAAA;AAAA,gCACC,SAAA,EAAU,wBAAA;AAAA,gCACV,aAAA,EAAY;AAAA;AAAA;AACd;AAAA;AAAA;AAEJ,qBAAA;AAAA,oBAvBK,WAAA,CAAY;AAAA,mBAwBnB;AAAA,gBAEJ,CAAC,CAAA,EAAA,EAxEM,CAAA,KAAA,EAAQ,SAAS,CAAA,CAyE1B;AAAA,eAEJ,EACF;AAAA;AAAA;AAAA;AACF;AAAA;AAAA,GACF;AAEJ,CAAA;AAEA,IAAO,sBAAA,GAAQ","file":"calendar-month.cjs","sourcesContent":["import React from 'react';\n\nimport './calendar-month.css';\nimport { classnames } from '../helpers/classnames';\n\n/**\n * A local calendar date represented either by a Date instance\n * or by a strict YYYY-MM-DD string.\n *\n * String values with a time, timezone or another date format\n * are not supported.\n */\nexport type CalendarMonthDate = Date | string;\n\nexport interface CalendarMonthProps\n extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'children'\n > {\n /**\n * The month to display.\n *\n * Accepts a Date instance or a strict YYYY-MM-DD string.\n * Only the year and month are used; the day and time are ignored.\n */\n month: CalendarMonthDate;\n\n /**\n * Dates to mark inside the displayed month.\n *\n * Accepts Date instances or strict YYYY-MM-DD strings.\n * Invalid values and dates outside the displayed month are ignored.\n * Duplicate dates produce a single marker.\n */\n markedDates?: CalendarMonthDate[];\n\n /**\n * Accessible description appended to marked dates.\n */\n markedDateLabel?: string;\n\n /**\n * Locale used to format the month title, weekdays and full dates.\n */\n locale?: string;\n\n /**\n * First day of the calendar week:\n * 0 for Sunday, 1 for Monday.\n */\n weekStartsOn?: 0 | 1;\n}\n\ntype CalendarDateParts = {\n year: number;\n monthIndex: number;\n day: number;\n};\n\ntype CalendarDay = {\n key: string;\n date: CalendarDateParts | null;\n};\n\ntype WeekdayLabel = {\n key: string;\n short: string;\n long: string;\n};\n\ntype CalendarMonthFormatters = {\n month: Intl.DateTimeFormat;\n fullDate: Intl.DateTimeFormat;\n weekdayShort: Intl.DateTimeFormat;\n weekdayLong: Intl.DateTimeFormat;\n};\n\nconst isoDatePattern =\n /^(\\d{4})-(\\d{2})-(\\d{2})$/u;\n\nfunction isValidDateParts(\n year: number,\n monthIndex: number,\n day: number,\n): boolean {\n const date = new Date(\n year,\n monthIndex,\n day,\n 12,\n );\n\n return (\n date.getFullYear() === year &&\n date.getMonth() === monthIndex &&\n date.getDate() === day\n );\n}\n\nfunction parseCalendarDate(\n value: CalendarMonthDate,\n): CalendarDateParts | null {\n if (value instanceof Date) {\n if (Number.isNaN(value.getTime())) {\n return null;\n }\n\n return {\n year: value.getFullYear(),\n monthIndex: value.getMonth(),\n day: value.getDate(),\n };\n }\n\n const match = isoDatePattern.exec(value);\n\n if (!match) {\n return null;\n }\n\n const year = Number(match[1]);\n const monthIndex = Number(match[2]) - 1;\n const day = Number(match[3]);\n\n if (\n !isValidDateParts(\n year,\n monthIndex,\n day,\n )\n ) {\n return null;\n }\n\n return {\n year,\n monthIndex,\n day,\n };\n}\n\nfunction createLocalDate(\n date: CalendarDateParts,\n): Date {\n return new Date(\n date.year,\n date.monthIndex,\n date.day,\n 12,\n );\n}\n\nfunction createDateKey(\n date: CalendarDateParts,\n): string {\n return [\n String(date.year).padStart(4, '0'),\n String(date.monthIndex + 1).padStart(\n 2,\n '0',\n ),\n String(date.day).padStart(2, '0'),\n ].join('-');\n}\n\nfunction createMonthKey(\n date: CalendarDateParts,\n): string {\n return [\n String(date.year).padStart(4, '0'),\n String(date.monthIndex + 1).padStart(\n 2,\n '0',\n ),\n ].join('-');\n}\n\nfunction isSameMonth(\n first: CalendarDateParts,\n second: CalendarDateParts,\n): boolean {\n return (\n first.year === second.year &&\n first.monthIndex === second.monthIndex\n );\n}\n\nfunction getDaysInMonth(\n year: number,\n monthIndex: number,\n): number {\n return new Date(\n year,\n monthIndex + 1,\n 0,\n 12,\n ).getDate();\n}\n\nfunction buildCalendarDays(\n month: CalendarDateParts,\n weekStartsOn: 0 | 1,\n): CalendarDay[] {\n const firstDayOfMonth = new Date(\n month.year,\n month.monthIndex,\n 1,\n 12,\n );\n\n const leadingEmptyCellCount =\n (\n firstDayOfMonth.getDay() -\n weekStartsOn +\n 7\n ) % 7;\n\n const daysInMonth = getDaysInMonth(\n month.year,\n month.monthIndex,\n );\n\n const cellCount =\n Math.ceil(\n (\n leadingEmptyCellCount +\n daysInMonth\n ) / 7,\n ) * 7;\n\n return Array.from(\n {\n length: cellCount,\n },\n (_, cellIndex) => {\n const day =\n cellIndex -\n leadingEmptyCellCount +\n 1;\n\n if (\n day < 1 ||\n day > daysInMonth\n ) {\n return {\n key: `empty-${cellIndex}`,\n date: null,\n };\n }\n\n const date = {\n year: month.year,\n monthIndex: month.monthIndex,\n day,\n };\n\n return {\n key: createDateKey(date),\n date,\n };\n },\n );\n}\n\nfunction chunkCalendarDays(\n days: CalendarDay[],\n): CalendarDay[][] {\n const weeks: CalendarDay[][] = [];\n\n for (\n let index = 0;\n index < days.length;\n index += 7\n ) {\n weeks.push(days.slice(index, index + 7));\n }\n\n return weeks;\n}\n\nfunction getWeekdayDates(\n weekStartsOn: 0 | 1,\n): Date[] {\n const sunday = new Date(\n 2024,\n 0,\n 7,\n 12,\n );\n\n return Array.from(\n {\n length: 7,\n },\n (_, index) => {\n const weekday = new Date(sunday);\n\n weekday.setDate(\n sunday.getDate() +\n weekStartsOn +\n index,\n );\n\n return weekday;\n },\n );\n}\n\nfunction createWeekdayLabels(\n formatters: CalendarMonthFormatters,\n weekStartsOn: 0 | 1,\n): WeekdayLabel[] {\n return getWeekdayDates(\n weekStartsOn,\n ).map((date) => ({\n key: String(date.getDay()),\n short:\n formatters.weekdayShort.format(\n date,\n ),\n long:\n formatters.weekdayLong.format(\n date,\n ),\n }));\n}\n\nfunction createMarkedDateKeys(\n markedDates: CalendarMonthDate[],\n month: CalendarDateParts,\n): Set<string> {\n const keys = new Set<string>();\n\n for (const value of markedDates) {\n const date = parseCalendarDate(value);\n\n if (\n date &&\n isSameMonth(date, month)\n ) {\n keys.add(createDateKey(date));\n }\n }\n\n return keys;\n}\n\nfunction createFormatters(\n locale: string,\n): CalendarMonthFormatters | null {\n try {\n return {\n month: new Intl.DateTimeFormat(\n locale,\n {\n month: 'long',\n },\n ),\n\n fullDate: new Intl.DateTimeFormat(\n locale,\n {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n },\n ),\n\n weekdayShort:\n new Intl.DateTimeFormat(\n locale,\n {\n weekday: 'short',\n },\n ),\n\n weekdayLong:\n new Intl.DateTimeFormat(\n locale,\n {\n weekday: 'long',\n },\n ),\n };\n } catch {\n return null;\n }\n}\n\nconst CalendarMonth: React.FC<\n CalendarMonthProps\n> = ({\n month,\n markedDates = [],\n markedDateLabel = 'Отмеченная дата',\n locale = 'ru-RU',\n weekStartsOn = 1,\n className = '',\n ...props\n}) => {\n const parsedMonth =\n parseCalendarDate(month);\n\n const componentId = React.useId();\n\n if (!parsedMonth) {\n return null;\n }\n\n const formatters =\n createFormatters(locale);\n\n if (!formatters) {\n return null;\n }\n\n const normalizedMonth = {\n year: parsedMonth.year,\n monthIndex: parsedMonth.monthIndex,\n day: 1,\n };\n\n const monthKey =\n createMonthKey(normalizedMonth);\n\n const monthTitleId =\n `${componentId}-${monthKey}-title`;\n\n const monthTitle =\n formatters.month.format(\n createLocalDate(normalizedMonth),\n );\n\n const weekdayLabels =\n createWeekdayLabels(\n formatters,\n weekStartsOn,\n );\n\n const calendarDays =\n buildCalendarDays(\n normalizedMonth,\n weekStartsOn,\n );\n\n const weeks =\n chunkCalendarDays(calendarDays);\n\n const markedDateKeys =\n createMarkedDateKeys(\n markedDates,\n normalizedMonth,\n );\n\n const classes = classnames(\n 'calendar-month',\n className,\n {},\n );\n\n return (\n <div\n className={classes}\n {...props}\n >\n <div\n className=\"calendar-month__title\"\n id={monthTitleId}\n >\n {monthTitle}\n </div>\n\n <table\n className=\"calendar-month__table\"\n aria-labelledby={monthTitleId}\n >\n <thead>\n <tr>\n {weekdayLabels.map(\n (weekday) => (\n <th\n key={weekday.key}\n className=\"calendar-month__weekday\"\n scope=\"col\"\n >\n <abbr\n title={weekday.long}\n >\n {weekday.short}\n </abbr>\n </th>\n ),\n )}\n </tr>\n </thead>\n\n <tbody>\n {weeks.map(\n (week, weekIndex) => (\n <tr key={`week-${weekIndex}`}>\n {week.map((calendarDay) => {\n if (!calendarDay.date) {\n return (\n <td\n key={calendarDay.key}\n className=\"calendar-month__cell calendar-month__cell--empty\"\n aria-hidden=\"true\"\n />\n );\n }\n\n const dateKey =\n createDateKey(\n calendarDay.date,\n );\n\n const isMarked =\n markedDateKeys.has(\n dateKey,\n );\n\n const fullDate =\n formatters.fullDate.format(\n createLocalDate(\n calendarDay.date,\n ),\n );\n\n const accessibleLabel =\n isMarked\n ? `${fullDate}: ${markedDateLabel}`\n : fullDate;\n\n const dateClasses =\n classnames(\n 'calendar-month__date',\n '',\n {\n 'calendar-month__date--marked':\n isMarked,\n },\n );\n\n return (\n <td\n key={calendarDay.key}\n className=\"calendar-month__cell\"\n >\n <time\n className={dateClasses}\n dateTime={dateKey}\n aria-label={\n accessibleLabel\n }\n >\n <span aria-hidden=\"true\">\n {\n calendarDay.date\n .day\n }\n </span>\n\n {isMarked && (\n <span\n className=\"calendar-month__marker\"\n aria-hidden=\"true\"\n />\n )}\n </time>\n </td>\n );\n })}\n </tr>\n ),\n )}\n </tbody>\n </table>\n </div>\n );\n};\n\nexport default CalendarMonth;"]}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
.calendar-month {
|
|
2
|
+
/* color */
|
|
3
|
+
--calendar-month-color: inherit;
|
|
4
|
+
--calendar-month-note-color: var(--color-text-note);
|
|
5
|
+
--calendar-month-marker-color: var(--color-primary);
|
|
6
|
+
|
|
7
|
+
color: var(--calendar-month-color);
|
|
8
|
+
|
|
9
|
+
/* typography */
|
|
10
|
+
--calendar-month-title-font-family:
|
|
11
|
+
var(--font-h4-family);
|
|
12
|
+
--calendar-month-title-font-size:
|
|
13
|
+
var(--font-h4);
|
|
14
|
+
--calendar-month-title-font-weight:
|
|
15
|
+
var(--font-h4-weight);
|
|
16
|
+
--calendar-month-title-line-height:
|
|
17
|
+
var(--font-h4-line);
|
|
18
|
+
--calendar-month-title-letter-spacing:
|
|
19
|
+
var(--font-h4-letter-spacing);
|
|
20
|
+
|
|
21
|
+
--calendar-month-weekday-font-family:
|
|
22
|
+
var(--font-note-family);
|
|
23
|
+
--calendar-month-weekday-font-size:
|
|
24
|
+
var(--font-note);
|
|
25
|
+
--calendar-month-weekday-font-weight:
|
|
26
|
+
var(--font-note-weight);
|
|
27
|
+
--calendar-month-weekday-line-height:
|
|
28
|
+
var(--font-note-line);
|
|
29
|
+
--calendar-month-weekday-letter-spacing:
|
|
30
|
+
var(--font-note-letter-spacing);
|
|
31
|
+
|
|
32
|
+
--calendar-month-date-font-family:
|
|
33
|
+
var(--font-body-family);
|
|
34
|
+
--calendar-month-date-font-size:
|
|
35
|
+
var(--font-body);
|
|
36
|
+
--calendar-month-date-font-weight:
|
|
37
|
+
var(--font-body-weight);
|
|
38
|
+
--calendar-month-date-line-height:
|
|
39
|
+
var(--font-body-line);
|
|
40
|
+
--calendar-month-date-letter-spacing:
|
|
41
|
+
var(--font-body-letter-spacing);
|
|
42
|
+
|
|
43
|
+
/* size */
|
|
44
|
+
--calendar-month-gap:
|
|
45
|
+
var(--margin-item);
|
|
46
|
+
|
|
47
|
+
--calendar-month-cell-size:
|
|
48
|
+
2.5rem;
|
|
49
|
+
|
|
50
|
+
--calendar-month-marker-size:
|
|
51
|
+
0.375rem;
|
|
52
|
+
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
gap: var(--calendar-month-gap);
|
|
56
|
+
width: 100%;
|
|
57
|
+
min-width: 0;
|
|
58
|
+
|
|
59
|
+
/* border */
|
|
60
|
+
|
|
61
|
+
/* depth */
|
|
62
|
+
|
|
63
|
+
/* motion */
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.calendar-month__title {
|
|
67
|
+
/* color */
|
|
68
|
+
color: inherit;
|
|
69
|
+
|
|
70
|
+
/* typography */
|
|
71
|
+
font-family:
|
|
72
|
+
var(--calendar-month-title-font-family);
|
|
73
|
+
font-size:
|
|
74
|
+
var(--calendar-month-title-font-size);
|
|
75
|
+
font-weight:
|
|
76
|
+
var(--calendar-month-title-font-weight);
|
|
77
|
+
line-height:
|
|
78
|
+
var(--calendar-month-title-line-height);
|
|
79
|
+
letter-spacing:
|
|
80
|
+
var(--calendar-month-title-letter-spacing);
|
|
81
|
+
|
|
82
|
+
/* size */
|
|
83
|
+
min-width: 0;
|
|
84
|
+
overflow-wrap: anywhere;
|
|
85
|
+
|
|
86
|
+
/* border */
|
|
87
|
+
|
|
88
|
+
/* depth */
|
|
89
|
+
|
|
90
|
+
/* motion */
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.calendar-month__table {
|
|
94
|
+
/* color */
|
|
95
|
+
|
|
96
|
+
/* typography */
|
|
97
|
+
|
|
98
|
+
/* size */
|
|
99
|
+
width: 100%;
|
|
100
|
+
table-layout: fixed;
|
|
101
|
+
border-collapse: collapse;
|
|
102
|
+
|
|
103
|
+
/* border */
|
|
104
|
+
|
|
105
|
+
/* depth */
|
|
106
|
+
|
|
107
|
+
/* motion */
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.calendar-month__weekday {
|
|
111
|
+
/* color */
|
|
112
|
+
color: var(--calendar-month-note-color);
|
|
113
|
+
|
|
114
|
+
/* typography */
|
|
115
|
+
font-family:
|
|
116
|
+
var(--calendar-month-weekday-font-family);
|
|
117
|
+
font-size:
|
|
118
|
+
var(--calendar-month-weekday-font-size);
|
|
119
|
+
font-weight:
|
|
120
|
+
var(--calendar-month-weekday-font-weight);
|
|
121
|
+
line-height:
|
|
122
|
+
var(--calendar-month-weekday-line-height);
|
|
123
|
+
letter-spacing:
|
|
124
|
+
var(--calendar-month-weekday-letter-spacing);
|
|
125
|
+
text-align: center;
|
|
126
|
+
|
|
127
|
+
/* size */
|
|
128
|
+
padding-block-end:
|
|
129
|
+
var(--margin-text);
|
|
130
|
+
|
|
131
|
+
/* border */
|
|
132
|
+
|
|
133
|
+
/* depth */
|
|
134
|
+
|
|
135
|
+
/* motion */
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.calendar-month__weekday abbr {
|
|
139
|
+
text-decoration: none;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.calendar-month__cell {
|
|
143
|
+
/* color */
|
|
144
|
+
|
|
145
|
+
/* typography */
|
|
146
|
+
|
|
147
|
+
/* size */
|
|
148
|
+
width: calc(100% / 7);
|
|
149
|
+
height: var(--calendar-month-cell-size);
|
|
150
|
+
padding: 0;
|
|
151
|
+
vertical-align: middle;
|
|
152
|
+
text-align: center;
|
|
153
|
+
|
|
154
|
+
/* border */
|
|
155
|
+
|
|
156
|
+
/* depth */
|
|
157
|
+
|
|
158
|
+
/* motion */
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.calendar-month__cell--empty {
|
|
162
|
+
/* color */
|
|
163
|
+
|
|
164
|
+
/* typography */
|
|
165
|
+
|
|
166
|
+
/* size */
|
|
167
|
+
|
|
168
|
+
/* border */
|
|
169
|
+
|
|
170
|
+
/* depth */
|
|
171
|
+
|
|
172
|
+
/* motion */
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.calendar-month__date {
|
|
176
|
+
/* color */
|
|
177
|
+
color: inherit;
|
|
178
|
+
|
|
179
|
+
/* typography */
|
|
180
|
+
font-family:
|
|
181
|
+
var(--calendar-month-date-font-family);
|
|
182
|
+
font-size:
|
|
183
|
+
var(--calendar-month-date-font-size);
|
|
184
|
+
font-weight:
|
|
185
|
+
var(--calendar-month-date-font-weight);
|
|
186
|
+
line-height:
|
|
187
|
+
var(--calendar-month-date-line-height);
|
|
188
|
+
letter-spacing:
|
|
189
|
+
var(--calendar-month-date-letter-spacing);
|
|
190
|
+
|
|
191
|
+
/* size */
|
|
192
|
+
display: inline-flex;
|
|
193
|
+
flex-direction: column;
|
|
194
|
+
align-items: center;
|
|
195
|
+
justify-content: center;
|
|
196
|
+
gap: 0.25rem;
|
|
197
|
+
width: 100%;
|
|
198
|
+
height: 100%;
|
|
199
|
+
|
|
200
|
+
/* border */
|
|
201
|
+
|
|
202
|
+
/* depth */
|
|
203
|
+
|
|
204
|
+
/* motion */
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.calendar-month__date--marked {
|
|
208
|
+
/* color */
|
|
209
|
+
|
|
210
|
+
/* typography */
|
|
211
|
+
|
|
212
|
+
/* size */
|
|
213
|
+
|
|
214
|
+
/* border */
|
|
215
|
+
|
|
216
|
+
/* depth */
|
|
217
|
+
|
|
218
|
+
/* motion */
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.calendar-month__marker {
|
|
222
|
+
/* color */
|
|
223
|
+
background: var(--calendar-month-marker-color);
|
|
224
|
+
|
|
225
|
+
/* typography */
|
|
226
|
+
|
|
227
|
+
/* size */
|
|
228
|
+
width: var(--calendar-month-marker-size);
|
|
229
|
+
height: var(--calendar-month-marker-size);
|
|
230
|
+
|
|
231
|
+
/* border */
|
|
232
|
+
border-radius: 999px;
|
|
233
|
+
|
|
234
|
+
/* depth */
|
|
235
|
+
|
|
236
|
+
/* motion */
|
|
237
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './calendar-month.css';
|
|
3
|
+
/**
|
|
4
|
+
* A local calendar date represented either by a Date instance
|
|
5
|
+
* or by a strict YYYY-MM-DD string.
|
|
6
|
+
*
|
|
7
|
+
* String values with a time, timezone or another date format
|
|
8
|
+
* are not supported.
|
|
9
|
+
*/
|
|
10
|
+
export type CalendarMonthDate = Date | string;
|
|
11
|
+
export interface CalendarMonthProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
12
|
+
/**
|
|
13
|
+
* The month to display.
|
|
14
|
+
*
|
|
15
|
+
* Accepts a Date instance or a strict YYYY-MM-DD string.
|
|
16
|
+
* Only the year and month are used; the day and time are ignored.
|
|
17
|
+
*/
|
|
18
|
+
month: CalendarMonthDate;
|
|
19
|
+
/**
|
|
20
|
+
* Dates to mark inside the displayed month.
|
|
21
|
+
*
|
|
22
|
+
* Accepts Date instances or strict YYYY-MM-DD strings.
|
|
23
|
+
* Invalid values and dates outside the displayed month are ignored.
|
|
24
|
+
* Duplicate dates produce a single marker.
|
|
25
|
+
*/
|
|
26
|
+
markedDates?: CalendarMonthDate[];
|
|
27
|
+
/**
|
|
28
|
+
* Accessible description appended to marked dates.
|
|
29
|
+
*/
|
|
30
|
+
markedDateLabel?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Locale used to format the month title, weekdays and full dates.
|
|
33
|
+
*/
|
|
34
|
+
locale?: string;
|
|
35
|
+
/**
|
|
36
|
+
* First day of the calendar week:
|
|
37
|
+
* 0 for Sunday, 1 for Monday.
|
|
38
|
+
*/
|
|
39
|
+
weekStartsOn?: 0 | 1;
|
|
40
|
+
}
|
|
41
|
+
declare const CalendarMonth: React.FC<CalendarMonthProps>;
|
|
42
|
+
export default CalendarMonth;
|